const ZoneFromURL = S.transformOrFail(
S.String,
ComputeZone,
{
strict: true,
decode: (zoneURL) => S.decodeUnknown(ComputeZone)(zoneURL.split("/").pop()).pipe(
Effect.mapError((e) => e.issue)
),
encode: (zone) => Effect.gen(function*() {
const projectId = yield* ProjectId // <- how can I make this work? I want `ProjectId` to be a requirement of the schema. Is this possible?
return `https://www.googleapis.com/compute/v1/projects/${projectId}/zones/${zone}`
})
}
)
const ZoneFromURL = S.transformOrFail(
S.String,
ComputeZone,
{
strict: true,
decode: (zoneURL) => S.decodeUnknown(ComputeZone)(zoneURL.split("/").pop()).pipe(
Effect.mapError((e) => e.issue)
),
encode: (zone) => Effect.gen(function*() {
const projectId = yield* ProjectId // <- how can I make this work? I want `ProjectId` to be a requirement of the schema. Is this possible?
return `https://www.googleapis.com/compute/v1/projects/${projectId}/zones/${zone}`
})
}
)