export const ShopFromId: Schema<Shop, string, ShopFromId> = S.transformOrFail(
ShopId,
S.typeSchema(Shop),
{
decode: (id) => Shop.resolver.andThen((_) => _(id)),
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
encode: (u) => ParseResult.try({ try: () => u.id, catch: (e) => new ParseResult.Type(null as any, u, `${e}`) })
}
)
export class ConfiguratorShop extends S.Extended<ConfiguratorShop>()({
...ConfiguratorShopBase.omit("shopId"),
shop: S.propertySignature(ShopFromId).pipe(S.fromKey("shopId"))
}) {}
// shop resolver
ShopRepo.use((repo) =>
getShopByIdResolver
.pipe(
Effect.provideService(ShopRepo, repo),
Effect.map(
(resolver) => (id: ShopId) =>
Effect
.request(GetShopById({ id }), resolver)
.orDie()
)
)
)
export const ShopFromId: Schema<Shop, string, ShopFromId> = S.transformOrFail(
ShopId,
S.typeSchema(Shop),
{
decode: (id) => Shop.resolver.andThen((_) => _(id)),
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
encode: (u) => ParseResult.try({ try: () => u.id, catch: (e) => new ParseResult.Type(null as any, u, `${e}`) })
}
)
export class ConfiguratorShop extends S.Extended<ConfiguratorShop>()({
...ConfiguratorShopBase.omit("shopId"),
shop: S.propertySignature(ShopFromId).pipe(S.fromKey("shopId"))
}) {}
// shop resolver
ShopRepo.use((repo) =>
getShopByIdResolver
.pipe(
Effect.provideService(ShopRepo, repo),
Effect.map(
(resolver) => (id: ShopId) =>
Effect
.request(GetShopById({ id }), resolver)
.orDie()
)
)
)