@confect/core 10.0.0-next.20 → 10.0.0-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -80
- package/dist/FunctionProvenance.d.ts +5 -6
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +3 -4
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +3 -1
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +12 -6
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GroupSpec.d.ts +5 -1
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +31 -17
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +1 -1
- package/dist/Identifier.js +1 -1
- package/dist/Identifier.js.map +1 -1
- package/dist/Lazy.d.ts +4 -5
- package/dist/Lazy.d.ts.map +1 -1
- package/dist/Lazy.js +4 -5
- package/dist/Lazy.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +171 -0
- package/dist/MiddlewareAttachment.d.ts.map +1 -0
- package/dist/MiddlewareAttachment.js +48 -0
- package/dist/MiddlewareAttachment.js.map +1 -0
- package/dist/MiddlewareSpec.d.ts +35 -23
- package/dist/MiddlewareSpec.d.ts.map +1 -1
- package/dist/MiddlewareSpec.js +1 -0
- package/dist/MiddlewareSpec.js.map +1 -1
- package/dist/PaginationOptions.d.ts +1 -1
- package/dist/PaginationOptions.js +1 -1
- package/dist/PaginationOptions.js.map +1 -1
- package/dist/Ref.d.ts +8 -7
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +11 -9
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.js +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +4 -2
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Spec.d.ts +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +3 -4
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +5 -6
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/package.json +10 -10
- package/src/FunctionProvenance.ts +6 -8
- package/src/FunctionSpec.ts +21 -7
- package/src/GroupSpec.ts +74 -26
- package/src/Identifier.ts +1 -1
- package/src/Lazy.ts +4 -5
- package/src/MiddlewareAttachment.ts +106 -0
- package/src/MiddlewareSpec.ts +55 -21
- package/src/PaginationOptions.ts +1 -1
- package/src/Ref.ts +42 -37
- package/src/Refs.ts +1 -1
- package/src/SchemaToValidator.ts +56 -45
- package/src/Spec.ts +1 -1
- package/src/SystemFields.ts +9 -10
- package/src/Table.ts +2 -2
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareSpec.js","names":[],"sources":["../src/MiddlewareSpec.ts"],"sourcesContent":["import type { FunctionType, FunctionVisibility } from \"convex/server\";\nimport type * as Effect from \"effect/Effect\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\nimport type { unhandled } from \"effect/Types\";\nimport type * as FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport const TypeId = \"~@confect/core/MiddlewareSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isMiddlewareSpec = (u: unknown): u is AnyMiddlewareSpec =>\n Predicate.hasProperty(u, TypeId);\n\nexport const allFunctionTypes: ReadonlyArray<FunctionType> = [\n \"query\",\n \"mutation\",\n \"action\",\n];\n\nexport interface SupportedFunctionTypes {\n readonly query: boolean;\n readonly mutation: boolean;\n readonly action: boolean;\n}\n\n/**\n * Marker success type used by middleware to represent the handler's outcome\n * without exposing its concrete success value.\n *\n * Mirrors `RpcMiddleware.SuccessValue` in Effect.\n */\nexport interface SuccessValue {\n readonly _: unique symbol;\n}\n\n/**\n * The wrap-style middleware implementation shape: receives the downstream\n * effect (the remaining middleware plus the function handler) and the\n * covered invocation's metadata, and returns the effect that runs in its\n * place.\n *\n * Mirrors `RpcMiddleware.RpcMiddleware` in Effect.\n */\nexport interface MiddlewareImpl<Provides_, E, R> {\n (\n effect: Effect.Effect<SuccessValue, E | unhandled, Provides_>,\n options: MiddlewareOptions,\n ): Effect.Effect<SuccessValue, E | unhandled, R>;\n}\n\nexport interface MiddlewareOptions {\n readonly name: string;\n readonly functionType: FunctionType;\n readonly functionVisibility: FunctionVisibility;\n readonly args: unknown;\n}\n\nexport interface AnyMiddlewareImpl extends MiddlewareImpl<any, any, any> {}\n\n/**\n * The class shape produced by {@link MiddlewareSpec}. Only the static side is ever\n * used — the class is a value-level carrier for the middleware's key, its\n * declared functionTypes, and its (lazily-evaluated) error schema, plus the\n * type-level `Provides`/`Error` metadata. It is deliberately not a\n * `Context.Tag`: implementations are registered through the group `Registry`\n * (like `FunctionImpl`s), not resolved from a Layer context.\n */\nexport interface MiddlewareSpec<\n in out Self,\n Key_ extends string,\n Provides_,\n Requires_,\n ErrorSchema_ extends Schema.Codec<any, any>,\n FunctionTypes_ extends FunctionType,\n> {\n new (_: never): {\n readonly [TypeId]: TypeId;\n readonly key: Key_;\n };\n readonly [TypeId]: TypeId;\n readonly key: Key_;\n readonly functionTypes: SupportedFunctionTypes;\n readonly error?: ErrorSchema_;\n readonly \"~Provides\": Provides_;\n readonly \"~Requires\": Requires_;\n readonly \"~Error\": ErrorSchema_;\n readonly \"~FunctionTypes\": FunctionTypes_;\n readonly \"~Self\": Self;\n}\n\nexport interface AnyMiddlewareSpec {\n readonly [TypeId]: TypeId;\n readonly key: string;\n readonly functionTypes: SupportedFunctionTypes;\n readonly error?: Schema.Codec<any, any>;\n readonly \"~Provides\": any;\n readonly \"~Requires\": any;\n readonly \"~Error\": any;\n readonly \"~FunctionTypes\": FunctionType;\n}\n\nexport type Key<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_[\"key\"];\n\nexport type Provides<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Provides\"]\n : never;\n\n/**\n * The services a middleware's implementation may consume from middleware\n * that runs earlier in the same chain (type-level only, like `provides`).\n */\nexport type Requires<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Requires\"]\n : never;\n\nexport type ErrorSchema<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec ? MiddlewareSpec_[\"~Error\"] : never;\n\nexport type Error<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Error\"][\"Type\"]\n : never;\n\nexport type EncodedError<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Error\"][\"Encoded\"]\n : never;\n\nexport type FunctionTypes<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~FunctionTypes\"]\n : never;\n\n/**\n * Declare a middleware's client-safe interface: its identifying key, the\n * service it provides to downstream handlers, the error schema its failures\n * encode through, and the function types it may attach to.\n *\n * ```ts\n * class RequireUser extends MiddlewareSpec.MiddlewareSpec<RequireUser, {\n * provides: CurrentUser\n * }>()(\"RequireUser\", {\n * error: () => NotSignedIn,\n * functionTypes: { query: true, mutation: true, action: false },\n * }) {}\n * ```\n *\n * The implementation is server-only and supplied separately via\n * `MiddlewareImpl.make` (or `makeByFunctionType`/`provides`) in `@confect/server`.\n */\nexport const MiddlewareSpec =\n <Self, Config extends { provides?: any; requires?: any } = {}>() =>\n <\n const Key_ extends string,\n const FunctionTypesConfig_ extends SupportedFunctionTypes,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n >(\n key: Key_,\n options: {\n readonly error?: () => ErrorSchema_;\n readonly functionTypes: FunctionTypesConfig_ &\n ValidateFunctionTypesConfig<FunctionTypesConfig_>;\n },\n ): MiddlewareSpec<\n Self,\n Key_,\n \"provides\" extends keyof Config ? Config[\"provides\"] : never,\n \"requires\" extends keyof Config ? Config[\"requires\"] : never,\n ErrorSchema_,\n FunctionTypesFromConfig<FunctionTypesConfig_>\n > => {\n const { query, mutation, action } = options.functionTypes;\n if (!query && !mutation && !action) {\n throw new Error(\n `Middleware \"${key}\" must declare at least one function type`,\n );\n }\n\n function MiddlewareSpecClass() {}\n const class_ = MiddlewareSpecClass as any;\n class_[TypeId] = TypeId;\n class_.key = key;\n class_.functionTypes = {\n query,\n mutation,\n action,\n } satisfies SupportedFunctionTypes;\n if (options.error !== undefined) {\n Lazy.defineProperty(class_, \"error\", options.error);\n }\n return class_;\n };\n\ntype FunctionTypesFromConfig<Config extends SupportedFunctionTypes> = {\n [K in FunctionType]: Config[K] extends true ? K : never;\n}[FunctionType];\n\ntype ValidateFunctionTypesConfig<Config extends SupportedFunctionTypes> =\n ValidationResult<\n | {\n [K in keyof Config]: boolean extends Config[K]\n ? AttachmentError<`Function type flag \"${K & string}\" must be a literal \\`true\\` or \\`false\\`, not a computed \\`boolean\\``>\n : never;\n }[keyof Config]\n | ([FunctionTypesFromConfig<Config>] extends [never]\n ? AttachmentError<`A middleware must declare at least one function type`>\n : never)\n >;\n\nexport const errorSchemas = (\n middlewareSpecs: ReadonlyArray<AnyMiddlewareSpec>,\n): ReadonlyArray<Schema.Codec<any, any>> =>\n middlewareSpecs.flatMap((middlewareSpec) =>\n \"error\" in middlewareSpec && middlewareSpec.error !== undefined\n ? [middlewareSpec.error]\n : [],\n );\n\n/**\n * A branded, unconstructible type carrying a spec-authoring error message.\n * Surfaced as (part of) a parameter type so the diagnostic names the exact\n * problem at the `.middleware()` / `.addFunction()` call site.\n */\nexport interface AttachmentError<Message extends string> {\n readonly \"~@confect/core/MiddlewareSpec/AttachmentError\": Message;\n}\n\ntype FunctionTypeOf<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n FunctionSpec_[\"runtimeAndFunctionType\"][\"functionType\"];\n\ntype ValidationResult<Errors> = [Errors] extends [never] ? unknown : Errors;\n\n/**\n * A matching-type Convex-provenance function is rejected rather than\n * silently skipped: its raw handler passes through Confect untouched, so\n * the middleware could not actually cover it, and skipping it would be a\n * policy hole.\n */\nexport type ValidateFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n> = FunctionSpec_ extends any\n ? MiddlewareSpec_ extends any\n ? FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Convex\" };\n }\n ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_>\n ? AttachmentError<`Convex-provenance function \"${FunctionSpec_[\"name\"]}\" cannot be covered by middleware \"${Key<MiddlewareSpec_>}\" — attach middleware only to groups whose matching-type functions are all Confect-provenance`>\n : never\n : [\n Extract<\n FunctionSpec.MiddlewareSpecs<FunctionSpec_>,\n { readonly key: Key<MiddlewareSpec_> }\n >,\n ] extends [never]\n ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_>\n ? never\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" does not declare function type \"${FunctionTypeOf<FunctionSpec_>}\", the type of function \"${FunctionSpec_[\"name\"]}\"`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to function \"${FunctionSpec_[\"name\"]}\"`>\n : never\n : never;\n\n/**\n * Attachment order is chain order, so requiring `requires` to be satisfied\n * by already-attached middleware is exactly requiring the provider to run\n * earlier.\n */\nexport type ValidateAttach<\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n Functions_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = [\n Extract<MiddlewareSpecs_, { readonly key: Key<MiddlewareSpec_> }>,\n] extends [never]\n ? [Exclude<Requires<MiddlewareSpec_>, Provides<MiddlewareSpecs_>>] extends [\n never,\n ]\n ? ValidationResult<ValidateFunction<Functions_, MiddlewareSpec_>>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" requires services that no middleware attached earlier to this group provides — attach the providing middleware first`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to this group`>;\n\nexport type ValidateAddedFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = [MiddlewareSpecs_] extends [never]\n ? unknown\n : ValidationResult<\n | ValidateFunction<FunctionSpec_, MiddlewareSpecs_>\n | GroupOverlap<FunctionSpec_, MiddlewareSpecs_>\n >;\n\ntype GroupOverlap<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> =\n FunctionSpec.MiddlewareSpecs<FunctionSpec_> extends infer FunctionMiddlewareSpec\n ? FunctionMiddlewareSpec extends AnyMiddlewareSpec\n ? [\n Extract<\n MiddlewareSpecs_,\n { readonly key: Key<FunctionMiddlewareSpec> }\n >,\n ] extends [never]\n ? never\n : AttachmentError<`Middleware \"${Key<FunctionMiddlewareSpec>}\" is attached to both function \"${FunctionSpec_[\"name\"]}\" and its group`>\n : never\n : never;\n\n/**\n * The parameter-type validation applied to the group spec at\n * `GroupImpl.make`: every function's attached middleware must have its\n * `requires` services provided by some middleware covering that function\n * (the group's or the function's own). Checked here — with the group fully\n * assembled — rather than at the spec builders, because a function-level\n * middleware's `requires` may legitimately be satisfied by a group\n * middleware the function spec never sees, and group attachment is\n * declaratively order-independent with respect to `addFunction`.\n */\nexport type ValidateImplRequires<\n Functions_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = ValidationResult<\n Functions_ extends any\n ? [\n Exclude<\n Requires<FunctionSpec.MiddlewareSpecs<Functions_>>,\n Provides<\n GroupMiddlewareSpecs_ | FunctionSpec.MiddlewareSpecs<Functions_>\n >\n >,\n ] extends [never]\n ? never\n : AttachmentError<`Function \"${Functions_[\"name\"]}\" has middleware requiring services that no middleware covering it provides`>\n : never\n>;\n\nexport type ValidateFunctionAttach<\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = FunctionProvenance_ extends { readonly _tag: \"Convex\" }\n ? AttachmentError<`Plain Convex functions cannot have middleware — their raw handlers are passed through untouched`>\n : [\n Extract<MiddlewareSpecs_, { readonly key: Key<MiddlewareSpec_> }>,\n ] extends [never]\n ? RuntimeAndFunctionType_[\"functionType\"] extends FunctionTypes<MiddlewareSpec_>\n ? unknown\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" does not declare function type \"${RuntimeAndFunctionType_[\"functionType\"]}\"`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to this function`>;\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,SAAS;AAGtB,MAAa,oBAAoB,MAC/B,UAAU,YAAY,GAAG,MAAM;AAEjC,MAAa,mBAAgD;CAC3D;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;AAwIA,MAAa,wBAOT,KACA,YAYG;CACH,MAAM,EAAE,OAAO,UAAU,WAAW,QAAQ;CAC5C,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,QAC1B,MAAM,IAAI,MACR,eAAe,IAAI,0CACrB;CAGF,SAAS,sBAAsB,CAAC;CAChC,MAAM,SAAS;CACf,OAAO,UAAU;CACjB,OAAO,MAAM;CACb,OAAO,gBAAgB;EACrB;EACA;EACA;CACF;CACA,IAAI,QAAQ,UAAU,KAAA,GACpB,eAAoB,QAAQ,SAAS,QAAQ,KAAK;CAEpD,OAAO;AACT;AAkBF,MAAa,gBACX,oBAEA,gBAAgB,SAAS,mBACvB,WAAW,kBAAkB,eAAe,UAAU,KAAA,IAClD,CAAC,eAAe,KAAK,IACrB,CAAC,CACP"}
|
|
1
|
+
{"version":3,"file":"MiddlewareSpec.js","names":[],"sources":["../src/MiddlewareSpec.ts"],"sourcesContent":["import type { FunctionType, FunctionVisibility } from \"convex/server\";\nimport type * as Effect from \"effect/Effect\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\nimport type { unhandled } from \"effect/Types\";\nimport type * as FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport const TypeId = \"~@confect/core/MiddlewareSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isMiddlewareSpec = (u: unknown): u is AnyMiddlewareSpec =>\n Predicate.hasProperty(u, TypeId);\n\nexport const allFunctionTypes: ReadonlyArray<FunctionType> = [\n \"query\",\n \"mutation\",\n \"action\",\n];\n\nexport interface SupportedFunctionTypes {\n readonly query: boolean;\n readonly mutation: boolean;\n readonly action: boolean;\n}\n\n/**\n * Marker success type used by middleware to represent the handler's outcome\n * without exposing its concrete success value.\n *\n * Mirrors `RpcMiddleware.SuccessValue` in Effect.\n */\nexport interface SuccessValue {\n readonly _: unique symbol;\n}\n\n/**\n * The wrap-style middleware implementation shape: receives the downstream\n * effect (the remaining middleware plus the function handler) and the\n * covered invocation's metadata, and returns the effect that runs in its\n * place.\n *\n * Mirrors `RpcMiddleware.RpcMiddleware` in Effect.\n */\nexport interface MiddlewareImpl<Provides_, E, R, Options_ = never> {\n (\n effect: Effect.Effect<SuccessValue, E | unhandled, Provides_>,\n context: MiddlewareOptions<Options_>,\n ): Effect.Effect<SuccessValue, E | unhandled, R>;\n}\n\nexport type MiddlewareOptions<Options_ = never> = {\n readonly invocation: {\n readonly name: string;\n readonly functionType: FunctionType;\n readonly functionVisibility: FunctionVisibility;\n readonly args: unknown;\n };\n} & ([Options_] extends [never] ? unknown : { readonly options: Options_ });\n\nexport interface AnyMiddlewareImpl {\n (\n effect: Effect.Effect<SuccessValue, any, any>,\n context: MiddlewareOptions | MiddlewareOptions<unknown>,\n ): Effect.Effect<SuccessValue, any, any>;\n}\n\n/**\n * The class shape produced by {@link MiddlewareSpec}. Only the static side is ever\n * used—the class is a value-level carrier for the middleware's key, its\n * declared functionTypes, and its (lazily-evaluated) error schema, plus the\n * type-level `Provides`/`Error` metadata. It is deliberately not a\n * `Context.Tag`: implementations are registered through the group `Registry`\n * (like `FunctionImpl`s), not resolved from a Layer context.\n */\nexport interface MiddlewareSpec<\n in out Self,\n Key_ extends string,\n Provides_,\n Requires_,\n ErrorSchema_ extends Schema.Codec<any, any>,\n FunctionTypes_ extends FunctionType,\n OptionsSchema_ extends Schema.Schema<any> = never,\n> {\n new (_: never): {\n readonly [TypeId]: TypeId;\n readonly key: Key_;\n };\n readonly [TypeId]: TypeId;\n readonly key: Key_;\n readonly functionTypes: SupportedFunctionTypes;\n readonly error?: ErrorSchema_;\n readonly options?: OptionsSchema_;\n readonly \"~Provides\": Provides_;\n readonly \"~Requires\": Requires_;\n readonly \"~Error\": ErrorSchema_;\n readonly \"~FunctionTypes\": FunctionTypes_;\n readonly \"~Self\": Self;\n readonly \"~Options\": OptionsSchema_;\n}\n\nexport interface AnyMiddlewareSpec {\n readonly [TypeId]: TypeId;\n readonly key: string;\n readonly functionTypes: SupportedFunctionTypes;\n readonly error?: Schema.Codec<any, any>;\n readonly options?: Schema.Schema<any>;\n readonly \"~Provides\": any;\n readonly \"~Requires\": any;\n readonly \"~Error\": any;\n readonly \"~FunctionTypes\": FunctionType;\n readonly \"~Options\": any;\n}\n\nexport type Options<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_[\"~Options\"][\"Type\"];\n\nexport type WithoutOptions<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? [MiddlewareSpec_[\"~Options\"]] extends [never]\n ? MiddlewareSpec_\n : never\n : never;\n\nexport type Key<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_[\"key\"];\n\nexport type Provides<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Provides\"]\n : never;\n\n/**\n * The services a middleware's implementation may consume from middleware\n * that runs earlier in the same chain (type-level only, like `provides`).\n */\nexport type Requires<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Requires\"]\n : never;\n\nexport type ErrorSchema<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec ? MiddlewareSpec_[\"~Error\"] : never;\n\nexport type Error<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Error\"][\"Type\"]\n : never;\n\nexport type EncodedError<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~Error\"][\"Encoded\"]\n : never;\n\nexport type FunctionTypes<MiddlewareSpec_ extends AnyMiddlewareSpec> =\n MiddlewareSpec_ extends AnyMiddlewareSpec\n ? MiddlewareSpec_[\"~FunctionTypes\"]\n : never;\n\n/**\n * Declare a middleware's client-safe interface: its identifying key, the\n * service it provides to downstream handlers, the error schema its failures\n * encode through, and the function types it may attach to.\n *\n * ```ts\n * class RequireUser extends MiddlewareSpec.MiddlewareSpec<RequireUser, {\n * provides: CurrentUser\n * }>()(\"RequireUser\", {\n * error: () => NotSignedIn,\n * functionTypes: { query: true, mutation: true, action: false },\n * }) {}\n * ```\n *\n * The implementation is server-only and supplied separately via\n * `MiddlewareImpl.make` (or `makeByFunctionType`/`provides`) in `@confect/server`.\n */\nexport const MiddlewareSpec =\n <Self, Config extends { provides?: any; requires?: any } = {}>() =>\n <\n const Key_ extends string,\n const FunctionTypesConfig_ extends SupportedFunctionTypes,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n OptionsSchema_ extends Schema.Schema<any> = never,\n >(\n key: Key_,\n options: {\n readonly error?: () => ErrorSchema_;\n readonly options?: () => OptionsSchema_;\n readonly functionTypes: FunctionTypesConfig_ &\n ValidateFunctionTypesConfig<FunctionTypesConfig_>;\n },\n ): MiddlewareSpec<\n Self,\n Key_,\n \"provides\" extends keyof Config ? Config[\"provides\"] : never,\n \"requires\" extends keyof Config ? Config[\"requires\"] : never,\n ErrorSchema_,\n FunctionTypesFromConfig<FunctionTypesConfig_>,\n OptionsSchema_\n > => {\n const { query, mutation, action } = options.functionTypes;\n if (!query && !mutation && !action) {\n throw new Error(\n `Middleware \"${key}\" must declare at least one function type`,\n );\n }\n\n function MiddlewareSpecClass() {}\n const class_ = MiddlewareSpecClass as any;\n class_[TypeId] = TypeId;\n class_.key = key;\n class_.functionTypes = {\n query,\n mutation,\n action,\n } satisfies SupportedFunctionTypes;\n if (options.error !== undefined) {\n Lazy.defineProperty(class_, \"error\", options.error);\n }\n if (options.options !== undefined) {\n Lazy.defineProperty(class_, \"options\", options.options);\n }\n return class_;\n };\n\ntype FunctionTypesFromConfig<Config extends SupportedFunctionTypes> = {\n [K in FunctionType]: Config[K] extends true ? K : never;\n}[FunctionType];\n\ntype ValidateFunctionTypesConfig<Config extends SupportedFunctionTypes> =\n ValidationResult<\n | {\n [K in keyof Config]: boolean extends Config[K]\n ? AttachmentError<`Function type flag \"${K & string}\" must be a literal \\`true\\` or \\`false\\`, not a computed \\`boolean\\``>\n : never;\n }[keyof Config]\n | ([FunctionTypesFromConfig<Config>] extends [never]\n ? AttachmentError<`A middleware must declare at least one function type`>\n : never)\n >;\n\nexport const errorSchemas = (\n middlewareSpecs: ReadonlyArray<AnyMiddlewareSpec>,\n): ReadonlyArray<Schema.Codec<any, any>> =>\n middlewareSpecs.flatMap((middlewareSpec) =>\n \"error\" in middlewareSpec && middlewareSpec.error !== undefined\n ? [middlewareSpec.error]\n : [],\n );\n\n/**\n * A branded, unconstructible type carrying a spec-authoring error message.\n * Surfaced as (part of) a parameter type so the diagnostic names the exact\n * problem at the `.middleware()`/`.addFunction()` call site.\n */\nexport interface AttachmentError<Message extends string> {\n readonly \"~@confect/core/MiddlewareSpec/AttachmentError\": Message;\n}\n\ntype FunctionTypeOf<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n FunctionSpec_[\"runtimeAndFunctionType\"][\"functionType\"];\n\ntype ValidationResult<Errors> = [Errors] extends [never] ? unknown : Errors;\n\n/**\n * A matching-type Convex-provenance function is rejected rather than\n * silently skipped: its raw handler passes through Confect untouched, so\n * the middleware could not actually cover it, and skipping it would be a\n * policy hole.\n */\nexport type ValidateFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n> = FunctionSpec_ extends any\n ? MiddlewareSpec_ extends any\n ? FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Convex\" };\n }\n ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_>\n ? AttachmentError<`Convex-provenance function \"${FunctionSpec_[\"name\"]}\" cannot be covered by middleware \"${Key<MiddlewareSpec_>}\"—attach middleware only to groups whose matching-type functions are all Confect-provenance`>\n : never\n : [\n Extract<\n FunctionSpec.MiddlewareSpecs<FunctionSpec_>,\n { readonly key: Key<WithoutOptions<MiddlewareSpec_>> }\n >,\n ] extends [never]\n ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_>\n ? never\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" does not declare function type \"${FunctionTypeOf<FunctionSpec_>}\", the type of function \"${FunctionSpec_[\"name\"]}\"`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to function \"${FunctionSpec_[\"name\"]}\"`>\n : never\n : never;\n\n/**\n * Attachment order is chain order, so requiring `requires` to be satisfied\n * by already-attached middleware is exactly requiring the provider to run\n * earlier.\n */\nexport type ValidateAttach<\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n Functions_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = [\n Extract<\n MiddlewareSpecs_,\n { readonly key: Key<WithoutOptions<MiddlewareSpec_>> }\n >,\n] extends [never]\n ? [Exclude<Requires<MiddlewareSpec_>, Provides<MiddlewareSpecs_>>] extends [\n never,\n ]\n ? ValidationResult<ValidateFunction<Functions_, MiddlewareSpec_>>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" requires services that no middleware attached earlier to this group provides—attach the providing middleware first`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to this group`>;\n\nexport type ValidateAddedFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = [MiddlewareSpecs_] extends [never]\n ? unknown\n : ValidationResult<\n | ValidateFunction<FunctionSpec_, MiddlewareSpecs_>\n | GroupOverlap<FunctionSpec_, MiddlewareSpecs_>\n >;\n\ntype GroupOverlap<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> =\n FunctionSpec.MiddlewareSpecs<FunctionSpec_> extends infer FunctionMiddlewareSpec\n ? FunctionMiddlewareSpec extends AnyMiddlewareSpec\n ? [\n Extract<\n MiddlewareSpecs_,\n { readonly key: Key<WithoutOptions<FunctionMiddlewareSpec>> }\n >,\n ] extends [never]\n ? never\n : AttachmentError<`Middleware \"${Key<FunctionMiddlewareSpec>}\" is attached to both function \"${FunctionSpec_[\"name\"]}\" and its group`>\n : never\n : never;\n\n/**\n * The parameter-type validation applied to the group spec at\n * `GroupImpl.make`: every function's attached middleware must have its\n * `requires` services provided by some middleware covering that function\n * (the group's or the function's own). Checked here—with the group fully\n * assembled—rather than at the spec builders, because a function-level\n * middleware's `requires` may legitimately be satisfied by a group\n * middleware the function spec never sees, and group attachment is\n * declaratively order-independent with respect to `addFunction`.\n */\nexport type ValidateImplRequires<\n Functions_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = ValidationResult<\n Functions_ extends any\n ? [\n Exclude<\n Requires<FunctionSpec.MiddlewareSpecs<Functions_>>,\n Provides<\n GroupMiddlewareSpecs_ | FunctionSpec.MiddlewareSpecs<Functions_>\n >\n >,\n ] extends [never]\n ? never\n : AttachmentError<`Function \"${Functions_[\"name\"]}\" has middleware requiring services that no middleware covering it provides`>\n : never\n>;\n\nexport type ValidateFunctionAttach<\n MiddlewareSpec_ extends AnyMiddlewareSpec,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends AnyMiddlewareSpec,\n> = FunctionProvenance_ extends { readonly _tag: \"Convex\" }\n ? AttachmentError<`Plain Convex functions cannot have middleware—their raw handlers are passed through untouched`>\n : [\n Extract<\n MiddlewareSpecs_,\n { readonly key: Key<WithoutOptions<MiddlewareSpec_>> }\n >,\n ] extends [never]\n ? RuntimeAndFunctionType_[\"functionType\"] extends FunctionTypes<MiddlewareSpec_>\n ? unknown\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" does not declare function type \"${RuntimeAndFunctionType_[\"functionType\"]}\"`>\n : AttachmentError<`Middleware \"${Key<MiddlewareSpec_>}\" is already attached to this function`>;\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,SAAS;AAGtB,MAAa,oBAAoB,MAC/B,UAAU,YAAY,GAAG,MAAM;AAEjC,MAAa,mBAAgD;CAC3D;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;AA8JA,MAAa,wBAQT,KACA,YAcG;CACH,MAAM,EAAE,OAAO,UAAU,WAAW,QAAQ;CAC5C,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,QAC1B,MAAM,IAAI,MACR,eAAe,IAAI,0CACrB;CAGF,SAAS,sBAAsB,CAAC;CAChC,MAAM,SAAS;CACf,OAAO,UAAU;CACjB,OAAO,MAAM;CACb,OAAO,gBAAgB;EACrB;EACA;EACA;CACF;CACA,IAAI,QAAQ,UAAU,KAAA,GACpB,eAAoB,QAAQ,SAAS,QAAQ,KAAK;CAEpD,IAAI,QAAQ,YAAY,KAAA,GACtB,eAAoB,QAAQ,WAAW,QAAQ,OAAO;CAExD,OAAO;AACT;AAkBF,MAAa,gBACX,oBAEA,gBAAgB,SAAS,mBACvB,WAAW,kBAAkB,eAAe,UAAU,KAAA,IAClD,CAAC,eAAe,KAAK,IACrB,CAAC,CACP"}
|
|
@@ -6,7 +6,7 @@ import * as Schema from "effect/Schema";
|
|
|
6
6
|
* Use this as the `paginationOpts` field of a paginated query's args schema.
|
|
7
7
|
* Beyond `numItems` and `cursor`, Convex's pagination protocol sends the
|
|
8
8
|
* optional fields (`endCursor`, `id`, `maximumRowsRead`, `maximumBytesRead`)
|
|
9
|
-
* with real requests
|
|
9
|
+
* with real requests—most notably `usePaginatedQuery` from `convex/react`
|
|
10
10
|
* always includes `id`, and includes `endCursor` when splitting pages.
|
|
11
11
|
* Declaring them is required for the generated Convex argument validator to
|
|
12
12
|
* accept those requests and for the fields to survive decoding and reach
|
|
@@ -9,7 +9,7 @@ var PaginationOptions_exports = /* @__PURE__ */ __exportAll({ PaginationOptions:
|
|
|
9
9
|
* Use this as the `paginationOpts` field of a paginated query's args schema.
|
|
10
10
|
* Beyond `numItems` and `cursor`, Convex's pagination protocol sends the
|
|
11
11
|
* optional fields (`endCursor`, `id`, `maximumRowsRead`, `maximumBytesRead`)
|
|
12
|
-
* with real requests
|
|
12
|
+
* with real requests—most notably `usePaginatedQuery` from `convex/react`
|
|
13
13
|
* always includes `id`, and includes `endCursor` when splitting pages.
|
|
14
14
|
* Declaring them is required for the generated Convex argument validator to
|
|
15
15
|
* accept those requests and for the fields to survive decoding and reach
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationOptions.js","names":[],"sources":["../src/PaginationOptions.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\n/**\n * Schema for the `paginationOpts` argument that every paginated query\n * receives. Mirrors `paginationOptsValidator` from `convex/server`.\n *\n * Use this as the `paginationOpts` field of a paginated query's args schema.\n * Beyond `numItems` and `cursor`, Convex's pagination protocol sends the\n * optional fields (`endCursor`, `id`, `maximumRowsRead`, `maximumBytesRead`)\n * with real requests
|
|
1
|
+
{"version":3,"file":"PaginationOptions.js","names":[],"sources":["../src/PaginationOptions.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\n/**\n * Schema for the `paginationOpts` argument that every paginated query\n * receives. Mirrors `paginationOptsValidator` from `convex/server`.\n *\n * Use this as the `paginationOpts` field of a paginated query's args schema.\n * Beyond `numItems` and `cursor`, Convex's pagination protocol sends the\n * optional fields (`endCursor`, `id`, `maximumRowsRead`, `maximumBytesRead`)\n * with real requests—most notably `usePaginatedQuery` from `convex/react`\n * always includes `id`, and includes `endCursor` when splitting pages.\n * Declaring them is required for the generated Convex argument validator to\n * accept those requests and for the fields to survive decoding and reach\n * `paginate`.\n */\nexport const PaginationOptions = Schema.Struct({\n numItems: Schema.Finite,\n cursor: Schema.Union([Schema.String, Schema.Null]),\n endCursor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),\n id: Schema.optionalKey(Schema.Finite),\n maximumRowsRead: Schema.optionalKey(Schema.Finite),\n maximumBytesRead: Schema.optionalKey(Schema.Finite),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAa,oBAAoB,OAAO,OAAO;CAC7C,UAAU,OAAO;CACjB,QAAQ,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC;CACjD,WAAW,OAAO,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;CACxE,IAAI,OAAO,YAAY,OAAO,MAAM;CACpC,iBAAiB,OAAO,YAAY,OAAO,MAAM;CACjD,kBAAkB,OAAO,YAAY,OAAO,MAAM;AACpD,CAAC"}
|
package/dist/Ref.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
2
|
import type { DefaultFunctionArgs, FunctionReference as ConvexFunctionReference, FunctionVisibility, PaginationOptions, PaginationResult } from "convex/server";
|
|
2
3
|
import type { Value } from "convex/values";
|
|
3
4
|
import { ConvexError } from "convex/values";
|
|
@@ -35,6 +36,7 @@ interface ConfectRefWithTypes<RuntimeAndFunctionType_ extends RuntimeAndFunction
|
|
|
35
36
|
readonly returns: Schema.Codec<any, any>;
|
|
36
37
|
readonly kind: FunctionProvenance.ConfectKind;
|
|
37
38
|
readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
|
|
39
|
+
readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;
|
|
38
40
|
readonly error?: Schema.Codec<any, any>;
|
|
39
41
|
}
|
|
40
42
|
export interface ConvexRef<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType, FunctionVisibility_ extends FunctionVisibility, Args_ extends DefaultFunctionArgs, Returns_, Error_ = never> extends Base<RuntimeAndFunctionType_, FunctionVisibility_, Args_, Returns_, Error_> {
|
|
@@ -101,7 +103,7 @@ export declare const make: <FunctionSpec_ extends FunctionSpec.AnyWithProps>(
|
|
|
101
103
|
* colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be
|
|
102
104
|
* `myGroupDir/myGroupMod`.
|
|
103
105
|
*/
|
|
104
|
-
convexFunctionNamespace: string, functionSpec: FunctionSpec_,
|
|
106
|
+
convexFunctionNamespace: string, functionSpec: FunctionSpec_, groupMiddlewareAttachments?: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>) => FromFunctionSpec<FunctionSpec_>;
|
|
105
107
|
export declare const getConvexFunctionName: (ref: Any) => string;
|
|
106
108
|
export declare const getFunctionReference: <Ref_ extends Any>(ref: Ref_) => FunctionReference<Ref_>;
|
|
107
109
|
export declare const hasErrorSchema: (ref: Any) => boolean;
|
|
@@ -123,7 +125,7 @@ export declare const isConvexError: (error: unknown) => error is ConvexError<Val
|
|
|
123
125
|
*/
|
|
124
126
|
export declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) => (error: unknown) => Error<Ref_> | E;
|
|
125
127
|
/**
|
|
126
|
-
* Decode `encodedError` against the ref's error schema
|
|
128
|
+
* Decode `encodedError` against the ref's error schema—the function's
|
|
127
129
|
* declared `error` schema unioned with its covering middlewares' error
|
|
128
130
|
* schemas. Returns `None` if the ref declares no typed error at all (Confect
|
|
129
131
|
* ref without an `error` schema and without failing middleware, or a
|
|
@@ -134,14 +136,14 @@ export declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnkn
|
|
|
134
136
|
export declare const decodeError: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>;
|
|
135
137
|
/**
|
|
136
138
|
* Synchronous counterpart to `decodeError`. Returns `None` when the value is
|
|
137
|
-
* not this ref's typed error
|
|
139
|
+
* not this ref's typed error—either because the ref declares no `error`
|
|
138
140
|
* schema, or because `encodedError` doesn't match the one it declares.
|
|
139
141
|
*
|
|
140
142
|
* The second case is reachable in normal operation: Convex raises its own
|
|
141
143
|
* `ConvexError`s (an `InvalidCursor` pagination error, for instance), and
|
|
142
144
|
* those never match a user-declared error schema. Callers pair this with a
|
|
143
145
|
* fallback that surfaces the original error, so failing to decode must not
|
|
144
|
-
* throw
|
|
146
|
+
* throw—a `ParseError` here would replace the real error with an opaque one
|
|
145
147
|
* and lose the only useful diagnostic. Hence the `Option` suffix rather than
|
|
146
148
|
* `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers
|
|
147
149
|
* in this module all throw on a parse failure, and this one deliberately
|
|
@@ -149,8 +151,7 @@ export declare const decodeError: <Ref_ extends Any>(ref: Ref_, encodedError: un
|
|
|
149
151
|
*/
|
|
150
152
|
export declare const decodeErrorOption: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Option.Option<Error<Ref_>>;
|
|
151
153
|
/**
|
|
152
|
-
* Encode the args of a paginated query ref via its user-args schema
|
|
153
|
-
* `paginationOpts` is excluded, since the pagination protocol fields are
|
|
154
|
+
* Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are
|
|
154
155
|
* managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by
|
|
155
156
|
* the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`
|
|
156
157
|
* (or `internalPaginatedQuery`).
|
|
@@ -170,6 +171,6 @@ export declare const decodePaginationPageSync: <Ref_ extends AnyPublicPaginatedQ
|
|
|
170
171
|
* `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when
|
|
171
172
|
* no handler is provided.
|
|
172
173
|
*/
|
|
173
|
-
export declare const runWithCodec: <Ref_ extends Any, E = never>(ref: Ref_, args: Args<Ref_>, call: (functionReference: FunctionReference<Ref_>, encodedArgs: unknown) => PromiseLike<unknown>, mapUnknownError?: (error: unknown) => E) => Effect.Effect<Returns<Ref_>, E | Error<Ref_
|
|
174
|
+
export declare const runWithCodec: <Ref_ extends Any, E = never>(ref: Ref_, args: Args<Ref_>, call: (functionReference: FunctionReference<Ref_>, encodedArgs: unknown) => PromiseLike<unknown>, mapUnknownError?: ((error: unknown) => E) | undefined) => Effect.Effect<Returns<Ref_>, E | Schema.SchemaError | Error<Ref_>, never>;
|
|
174
175
|
export {};
|
|
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C,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAO3D,CAAC;AAEL;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,GAAG,OAC3C,IAAI,gBACK,OAAO,KACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAOzB,CAAC;AAwBJ;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,SAAS,uBAAuB,OAE/B,IAAI,QACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,KACvC,OAOA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,SAAS,uBAAuB,OACtE,IAAI,eACI,OAAO,KACnB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAOK,CAAC;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,SAAS,GAAG,EAChB,CAAC,iEAKoB,iBAAiB,CAAC,IAAI,CAAC,eAC7B,OAAO,KACjB,WAAW,CAAC,OAAO,CAAC,6BACC,OAAO,KAAK,CAAC,2FAyBvC,CAAC"}
|
package/dist/Ref.js
CHANGED
|
@@ -27,7 +27,7 @@ var Ref_exports = /* @__PURE__ */ __exportAll({
|
|
|
27
27
|
make: () => make,
|
|
28
28
|
runWithCodec: () => runWithCodec
|
|
29
29
|
});
|
|
30
|
-
const make = (convexFunctionNamespace, functionSpec,
|
|
30
|
+
const make = (convexFunctionNamespace, functionSpec, groupMiddlewareAttachments = []) => {
|
|
31
31
|
const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;
|
|
32
32
|
return Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => ({
|
|
33
33
|
_tag: "Convex",
|
|
@@ -37,7 +37,10 @@ const make = (convexFunctionNamespace, functionSpec, groupMiddlewareSpecs = [])
|
|
|
37
37
|
_tag: "Confect",
|
|
38
38
|
convexFunctionName,
|
|
39
39
|
kind: provenance.kind,
|
|
40
|
-
|
|
40
|
+
middlewareAttachments: [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments],
|
|
41
|
+
get middlewareSpecs() {
|
|
42
|
+
return this.middlewareAttachments.map(({ spec }) => spec);
|
|
43
|
+
}
|
|
41
44
|
};
|
|
42
45
|
defineProperty(ref, "args", () => provenance.args);
|
|
43
46
|
defineProperty(ref, "returns", () => provenance.returns);
|
|
@@ -85,7 +88,7 @@ const errorSchemaOf = (ref) => Match.value(ref).pipe(Match.tag("Confect", (confe
|
|
|
85
88
|
return schemas.length === 0 ? Option.none() : Option.some(schemas.length === 1 ? schemas[0] : Schema.Union(schemas));
|
|
86
89
|
}), Match.tag("Convex", () => Option.none()), Match.exhaustive);
|
|
87
90
|
/**
|
|
88
|
-
* Decode `encodedError` against the ref's error schema
|
|
91
|
+
* Decode `encodedError` against the ref's error schema—the function's
|
|
89
92
|
* declared `error` schema unioned with its covering middlewares' error
|
|
90
93
|
* schemas. Returns `None` if the ref declares no typed error at all (Confect
|
|
91
94
|
* ref without an `error` schema and without failing middleware, or a
|
|
@@ -95,18 +98,18 @@ const errorSchemaOf = (ref) => Match.value(ref).pipe(Match.tag("Confect", (confe
|
|
|
95
98
|
*/
|
|
96
99
|
const decodeError = (ref, encodedError) => Option.match(errorSchemaOf(ref), {
|
|
97
100
|
onNone: () => Effect.succeed(Option.none()),
|
|
98
|
-
onSome: (schema) => Effect.
|
|
101
|
+
onSome: (schema) => Effect.asSome(Schema.decodeUnknownEffect(schema)(encodedError))
|
|
99
102
|
});
|
|
100
103
|
/**
|
|
101
104
|
* Synchronous counterpart to `decodeError`. Returns `None` when the value is
|
|
102
|
-
* not this ref's typed error
|
|
105
|
+
* not this ref's typed error—either because the ref declares no `error`
|
|
103
106
|
* schema, or because `encodedError` doesn't match the one it declares.
|
|
104
107
|
*
|
|
105
108
|
* The second case is reachable in normal operation: Convex raises its own
|
|
106
109
|
* `ConvexError`s (an `InvalidCursor` pagination error, for instance), and
|
|
107
110
|
* those never match a user-declared error schema. Callers pair this with a
|
|
108
111
|
* fallback that surfaces the original error, so failing to decode must not
|
|
109
|
-
* throw
|
|
112
|
+
* throw—a `ParseError` here would replace the real error with an opaque one
|
|
110
113
|
* and lose the only useful diagnostic. Hence the `Option` suffix rather than
|
|
111
114
|
* `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers
|
|
112
115
|
* in this module all throw on a parse failure, and this one deliberately
|
|
@@ -124,8 +127,7 @@ const paginatedKind = (ref) => Match.value(ref.kind).pipe(Match.tag("Paginated",
|
|
|
124
127
|
throw missingPaginatedProvenanceError(ref);
|
|
125
128
|
}), Match.exhaustive);
|
|
126
129
|
/**
|
|
127
|
-
* Encode the args of a paginated query ref via its user-args schema
|
|
128
|
-
* `paginationOpts` is excluded, since the pagination protocol fields are
|
|
130
|
+
* Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are
|
|
129
131
|
* managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by
|
|
130
132
|
* the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`
|
|
131
133
|
* (or `internalPaginatedQuery`).
|
|
@@ -145,7 +147,7 @@ const decodePaginationPageSync = (ref, encodedPage) => Match.value(ref).pipe(Mat
|
|
|
145
147
|
* `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when
|
|
146
148
|
* no handler is provided.
|
|
147
149
|
*/
|
|
148
|
-
const runWithCodec = (ref, args, call, mapUnknownError)
|
|
150
|
+
const runWithCodec = Effect.fnUntraced(function* (ref, args, call, mapUnknownError) {
|
|
149
151
|
const functionReference = getFunctionReference(ref);
|
|
150
152
|
const invoke = (encodedArgs) => Effect.tryPromise({
|
|
151
153
|
try: () => Promise.resolve(call(functionReference, encodedArgs)),
|
package/dist/Ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> {\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly convexFunctionName: string;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed\n * errors. A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives\n * the same values from its fields and schemas.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: Schema.Codec<any, any>;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly error?: Schema.Codec<any, any>;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/** Erased Confect-provenance ref used by provenance-specific APIs. */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/** The field map captured by a Confect-provenance ref. */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/** The assembled args schema carried by a Confect-provenance ref. */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_> | MiddlewareError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec> = [],\n): FromFunctionSpec<FunctionSpec_> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n _tag: \"Convex\",\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any => {\n const ref = {\n _tag: \"Confect\" as const,\n convexFunctionName,\n kind: provenance.kind,\n middlewareSpecs: [\n ...groupMiddlewareSpecs,\n ...functionSpec.middlewareSpecs,\n ],\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as Any;\n }),\n Match.exhaustive,\n ) as FromFunctionSpec<FunctionSpec_>;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema — the function's\n * declared `error` schema unioned with its covering middlewares' error\n * schemas. Returns `None` if the ref declares no typed error at all (Confect\n * ref without an `error` schema and without failing middleware, or a\n * Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.map(\n Schema.decodeUnknownEffect(schema)(encodedError),\n Option.some,\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error — either because the ref declares no `error`\n * schema, or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and\n * those never match a user-declared error schema. Callers pair this with a\n * fallback that surfaces the original error, so failing to decode must not\n * throw — a `ParseError` here would replace the real error with an opaque one\n * and lose the only useful diagnostic. Hence the `Option` suffix rather than\n * `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers\n * in this module all throw on a parse failure, and this one deliberately\n * doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args schema —\n * `paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`\n * (or `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = <Ref_ extends Any, E = never>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.Effect<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> =>\n Effect.gen(function* () {\n const functionReference = getFunctionReference(ref);\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4TA,MAAa,QAMX,yBACA,cACA,uBAAwE,CAAC,MACrC;CACpC,MAAM,qBA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ACA,gBAEA,MAAM,MAAW,GAAG,CAAC,CAAC,KACpB,MAAM,IAAI,YAAY,eACpB,OAAO,kBAAkB,cAAc,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CACtE,GACA,MAAM,IAAI,gBAAgB,WAAW,GACrC,MAAM,UACR;;;;;;;;;AAUF,MAAa,gBACX,KACA,MACA,MAIA,oBAEA,OAAO,IAAI,aAAa;CACtB,MAAM,oBAAoB,qBAAqB,GAAG;CAClD,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,WAAW,CAAC;EAC/D,QAAQ,UAA2B;GACjC,IAAI,cAAc,KAAK,GAAG;IACxB,MAAM,UAAU,kBAAkB,KAAK,MAAM,IAAI;IACjD,IAAI,OAAO,OAAO,OAAO,GACvB,OAAO,QAAQ;GAEnB;GACA,IAAI,oBAAoB,KAAA,GACtB,OAAO,gBAAgB,KAAK;GAE9B,MAAM;EACR;CACF,CAAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
|
|
1
|
+
{"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> {\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly convexFunctionName: string;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed\n * errors. A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives\n * the same values from its fields and schemas.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: Schema.Codec<any, any>;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: Schema.Codec<any, any>;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/** Erased Confect-provenance ref used by provenance-specific APIs. */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/** The field map captured by a Confect-provenance ref. */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/** The assembled args schema carried by a Confect-provenance ref. */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_> | MiddlewareError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment> = [],\n): FromFunctionSpec<FunctionSpec_> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n _tag: \"Convex\",\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any => {\n const ref = {\n _tag: \"Confect\" as const,\n convexFunctionName,\n kind: provenance.kind,\n middlewareAttachments: [\n ...groupMiddlewareAttachments,\n ...functionSpec.middlewareAttachments,\n ],\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as Any;\n }),\n Match.exhaustive,\n ) as FromFunctionSpec<FunctionSpec_>;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema—the function's\n * declared `error` schema unioned with its covering middlewares' error\n * schemas. Returns `None` if the ref declares no typed error at all (Confect\n * ref without an `error` schema and without failing middleware, or a\n * Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.asSome(\n Schema.decodeUnknownEffect(schema)(encodedError),\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error—either because the ref declares no `error`\n * schema, or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and\n * those never match a user-declared error schema. Callers pair this with a\n * fallback that surfaces the original error, so failing to decode must not\n * throw—a `ParseError` here would replace the real error with an opaque one\n * and lose the only useful diagnostic. Hence the `Option` suffix rather than\n * `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers\n * in this module all throw on a parse failure, and this one deliberately\n * doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`\n * (or `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = Effect.fnUntraced(function* <\n Ref_ extends Any,\n E = never,\n>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.fn.Return<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> {\n const functionReference = getFunctionReference(ref);\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8TA,MAAa,QAMX,yBACA,cACA,6BAAuF,CAAC,MACpD;CACpC,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;EACC,MAAM;EACN;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eAAoB;EACxC,MAAM,MAAM;GACV,MAAM;GACN;GACA,MAAM,WAAW;GACjB,uBAAuB,CACrB,GAAG,4BACH,GAAG,aAAa,qBAClB;GACA,IAAI,kBAAkB;IACpB,OAAO,KAAK,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A,MACA,MAIA,iBACuE;CACvE,MAAM,oBAAoB,qBAAqB,GAAG;CAClD,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,WAAW,CAAC;EAC/D,QAAQ,UAA2B;GACjC,IAAI,cAAc,KAAK,GAAG;IACxB,MAAM,UAAU,kBAAkB,KAAK,MAAM,IAAI;IACjD,IAAI,OAAO,OAAO,OAAO,GACvB,OAAO,QAAQ;GAEnB;GACA,IAAI,oBAAoB,KAAA,GACtB,OAAO,gBAAgB,KAAK;GAE9B,MAAM;EACR;CACF,CAAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
|
package/dist/Refs.js
CHANGED
|
@@ -17,7 +17,7 @@ const makeHelper = (groups, convexFunctionNamespace = Option.none()) => pipe(gro
|
|
|
17
17
|
onNone: () => name,
|
|
18
18
|
onSome: (parentNamespace) => `${parentNamespace}/${name}`
|
|
19
19
|
});
|
|
20
|
-
return Record.union(makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)), Record.map(group.functions, (function_) => make$1(currentConvexFunctionNamespace, function_, group.
|
|
20
|
+
return Record.union(makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)), Record.map(group.functions, (function_) => make$1(currentConvexFunctionNamespace, function_, group.middlewareAttachments)), (_subGroup, _function) => {
|
|
21
21
|
throw new Error(`Group and function at same level have same name ('${getConvexFunctionName(_function)}')`);
|
|
22
22
|
});
|
|
23
23
|
}));
|
package/dist/Refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.js","names":["Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { pipe } from \"effect/Function\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as GroupSpec from \"./GroupSpec\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n Spec_ extends Spec.AnyWithProps,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;\n\nexport interface FromSpec<Spec_ extends Spec.AnyWithProps> {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n}\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<\n GroupSpec.Functions<Group>,\n Predicate,\n MiddlewareSpec.Error<GroupSpec.MiddlewareSpecs<Group>>\n >\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FunctionSpecMatchesPredicate<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> =\n Ref.Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n any,\n any,\n any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n MiddlewareError,\n> = {\n [\n Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<\n FunctionSpecs,\n Name\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true\n ? Name\n : never\n : never\n ]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<\n F,\n F extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ?\n | MiddlewareError\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<F>>\n : never\n >\n : never;\n};\n\ntype Helper<\n Groups extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupRefs<Group, Predicate>\n : never;\n};\n\ntype Any =\n | {\n readonly [key: string]: Any;\n }\n | Ref.Any;\n\nexport const make = <Spec_ extends Spec.AnyWithProps>(\n spec: Spec_,\n): FromSpec<Spec_> => {\n const refs = makeHelper(spec.groups);\n return {\n public: refs as Refs<Spec_, Ref.AnyPublic>,\n internal: refs as Refs<Spec_, Ref.AnyInternal>,\n };\n};\n\nconst makeHelper = (\n groups: Record.ReadonlyRecord<string, GroupSpec.Any>,\n convexFunctionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentConvexFunctionNamespace = Option.match(\n convexFunctionNamespace,\n {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n },\n );\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(\n currentConvexFunctionNamespace,\n function_,\n group.
|
|
1
|
+
{"version":3,"file":"Refs.js","names":["Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { pipe } from \"effect/Function\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as GroupSpec from \"./GroupSpec\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n Spec_ extends Spec.AnyWithProps,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;\n\nexport interface FromSpec<Spec_ extends Spec.AnyWithProps> {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n}\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<\n GroupSpec.Functions<Group>,\n Predicate,\n MiddlewareSpec.Error<GroupSpec.MiddlewareSpecs<Group>>\n >\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FunctionSpecMatchesPredicate<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> =\n Ref.Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n any,\n any,\n any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n MiddlewareError,\n> = {\n [\n Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<\n FunctionSpecs,\n Name\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true\n ? Name\n : never\n : never\n ]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<\n F,\n F extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ?\n | MiddlewareError\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<F>>\n : never\n >\n : never;\n};\n\ntype Helper<\n Groups extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupRefs<Group, Predicate>\n : never;\n};\n\ntype Any =\n | {\n readonly [key: string]: Any;\n }\n | Ref.Any;\n\nexport const make = <Spec_ extends Spec.AnyWithProps>(\n spec: Spec_,\n): FromSpec<Spec_> => {\n const refs = makeHelper(spec.groups);\n return {\n public: refs as Refs<Spec_, Ref.AnyPublic>,\n internal: refs as Refs<Spec_, Ref.AnyInternal>,\n };\n};\n\nconst makeHelper = (\n groups: Record.ReadonlyRecord<string, GroupSpec.Any>,\n convexFunctionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentConvexFunctionNamespace = Option.match(\n convexFunctionNamespace,\n {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n },\n );\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(\n currentConvexFunctionNamespace,\n function_,\n group.middlewareAttachments,\n ),\n ),\n (_subGroup, _function) => {\n throw new Error(\n `Group and function at same level have same name ('${Ref.getConvexFunctionName(_function)}')`,\n );\n },\n );\n }),\n );\n"],"mappings":";;;;;;;AAiGA,MAAa,QACX,SACoB;CACpB,MAAM,OAAO,WAAW,KAAK,MAAM;CACnC,OAAO;EACL,QAAQ;EACR,UAAU;CACZ;AACF;AAEA,MAAM,cACJ,QACA,0BAAiD,OAAO,KAAK,MAE7D,KACE,QACA,OAAO,KAAK,OAAO,SAAS;CAC1B,MAAM,iCAAiC,OAAO,MAC5C,yBACA;EACE,cAAc;EACd,SAAS,oBAAoB,GAAG,gBAAgB,GAAG;CACrD,CACF;CAEA,OAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,OAAO,KAAK,8BAA8B,CAAC,GACpE,OAAO,IAAI,MAAM,YAAY,cAC3BA,OACE,gCACA,WACA,MAAM,qBACR,CACF,IACC,WAAW,cAAc;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Aa,6BAA8B,SAAQ,kCAElD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,0BAA2B,SAAQ,gCAE9C;IACA,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;IAEA,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,mCAAoC,SAAQ,wCAExD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,mDAAoD,SAAQ,wDAExE;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,yCAA0C,SAAQ,8CAE9D;IAEC,IAAa,OAAO,WAEnB;CAEF"}
|
|
@@ -48,7 +48,8 @@ const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false) => isRecursive
|
|
|
48
48
|
onSuccess: () => v.bytes(),
|
|
49
49
|
onFailure: () => new UnsupportedSchemaTypeError({ schemaType: declaration._tag })
|
|
50
50
|
})), Match.tag("Suspend", () => Effect.succeed(v.any())), Match.tag("UniqueSymbol", "Symbol", "Undefined", "Void", "Never", "Enum", "TemplateLiteral", "ObjectKeyword", () => Effect.fail(new UnsupportedSchemaTypeError({ schemaType: ast._tag }))), Match.exhaustive);
|
|
51
|
-
const handleUnion = ({ types }, isOptionalPropertyOfTypeLiteral) =>
|
|
51
|
+
const handleUnion = ({ types }, isOptionalPropertyOfTypeLiteral) => handleUnionTypes(types, isOptionalPropertyOfTypeLiteral);
|
|
52
|
+
const handleUnionTypes = Effect.fnUntraced(function* (types, isOptionalPropertyOfTypeLiteral) {
|
|
52
53
|
const members = isOptionalPropertyOfTypeLiteral ? Array.filter(types, Predicate.not(SchemaAST.isUndefined)) : types;
|
|
53
54
|
const [firstValidator, secondValidator, ...restValidators] = yield* Effect.all(Array.map(members, (type) => compileAst(type)));
|
|
54
55
|
if (firstValidator === void 0) return yield* new EmptyUnionIsNotSupportedError();
|
|
@@ -65,7 +66,8 @@ const handleObjects = (objectsAst) => pipe(objectsAst.indexSignatures, Array.hea
|
|
|
65
66
|
onSome: () => Effect.fail(new MixedIndexAndPropertySignaturesAreNotSupportedError())
|
|
66
67
|
}))
|
|
67
68
|
}));
|
|
68
|
-
const handleArrays = ({ elements, rest }) =>
|
|
69
|
+
const handleArrays = ({ elements, rest }) => handleArrayElements(elements, rest);
|
|
70
|
+
const handleArrayElements = Effect.fnUntraced(function* (elements, rest) {
|
|
69
71
|
const [f, s, ...r] = elements;
|
|
70
72
|
const elementToValidator = (element) => SchemaAST.isOptional(element) ? Effect.fail(new OptionalTupleElementsAreNotSupportedError()) : compileAst(element);
|
|
71
73
|
const arrayItemsValidator = yield* f === void 0 ? pipe(rest, Array.head, Option.match({
|