@gaganref/confect-core 10.3.1-fork.41 → 10.3.1-fork.43
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/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +1 -1
- package/dist/Component.js.map +1 -1
- package/dist/FunctionSpec.d.ts +35 -0
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +14 -9
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/Ref.d.ts +2 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +3 -2
- package/dist/Ref.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +10 -1
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +18 -3
- package/dist/SchemaToValidator.js.map +1 -1
- package/package.json +1 -1
- package/src/Component.ts +1 -0
- package/src/FunctionSpec.ts +50 -10
- package/src/Ref.ts +4 -0
- package/src/SchemaToValidator.ts +22 -1
package/dist/FunctionSpec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionSpec.js","names":["FunctionProvenance.Confect","FunctionProvenance.ConfectPaginated","RuntimeAndFunctionType.ConvexQuery","RuntimeAndFunctionType.ConvexMutation","RuntimeAndFunctionType.ConvexAction","RuntimeAndFunctionType.NodeAction","MiddlewareSpec.isMiddlewareSpec","FunctionProvenance.Convex"],"sources":["../src/FunctionSpec.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionType,\n FunctionVisibility,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n} from \"convex/server\";\nimport * as Schema from \"effect/Schema\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as Profile from \"./Profile.js\";\nimport * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/FunctionSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isFunctionSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface FunctionSpec<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtimeAndFunctionType: RuntimeAndFunctionType_;\n readonly functionVisibility: FunctionVisibility_;\n readonly name: Name_;\n readonly functionProvenance: FunctionProvenance_;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly middlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<MiddlewareSpecs_>\n >;\n}\n\nexport interface Builder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> extends FunctionSpec<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface DescribedBuilder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> extends Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n readonly description?: string;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\n/**\n * A spec built through {@link extend}, keeping its fields through middleware.\n */\nexport interface ExtendedBuilder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Fields_,\n> extends Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n readonly description?: string;\n readonly fields: Profile.Info<Fields_>[\"fields\"];\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): ExtendedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_,\n Fields_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {\n readonly description?: string;\n readonly fields?: object;\n}\n\nexport interface AnyConfect extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.AnyConfect,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyConvex extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.AnyConvex,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends FunctionSpec<\n RuntimeAndFunctionType.WithRuntime<Runtime>,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithFunctionType<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n> extends FunctionSpec<\n RuntimeAndFunctionType_,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithFunctionProvenance<\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n> extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance_,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type GetRuntimeAndFunctionType<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"runtimeAndFunctionType\"];\n\nexport type GetFunctionVisibility<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"functionVisibility\"];\n\nexport type GetFunctionProvenance<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"functionProvenance\"];\n\nexport type Name<FunctionSpec_ extends AnyWithProps> = FunctionSpec_[\"name\"];\n\nexport type MiddlewareSpecs<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"middlewareSpecs\"][number];\n\n/**\n * The field map declared by a Confect-provenance spec.\n */\nexport type ArgsFields<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n };\n }\n ? ArgsFields_\n : FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? FunctionProvenance.ArgsFields\n : never;\n\n/**\n * The args schema assembled from a Confect-provenance spec's field map.\n */\nexport type ArgsSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n };\n }\n ? Schema.Struct<ArgsFields_>\n : FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends\n FunctionProvenance.AnyArgsSchema;\n };\n }\n ? ArgsSchema_\n : never;\n\nexport type ReturnsSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n };\n }\n ? ReturnsSchema_\n : never;\n\nexport type ErrorSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n };\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<FunctionSpec_ extends AnyWithProps> = FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n}\n ? ArgsSchema<FunctionSpec_>[\"Type\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_,\n any\n >\n ? Args_\n : never;\n\nexport type Returns<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ReturnsSchema<FunctionSpec_>[\"Type\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n any,\n infer Returns_\n >\n ? Awaited<Returns_>\n : never;\n\nexport type EncodedArgs<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ArgsSchema<FunctionSpec_>[\"Encoded\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_,\n any\n >\n ? Args_\n : never;\n\nexport type EncodedReturns<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ReturnsSchema<FunctionSpec_>[\"Encoded\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n any,\n infer Returns_\n >\n ? Returns_\n : never;\n\nexport type Error<FunctionSpec_ extends AnyWithProps> =\n ErrorSchema<FunctionSpec_>[\"Type\"];\n\nexport type EncodedError<FunctionSpec_ extends AnyWithProps> =\n ErrorSchema<FunctionSpec_>[\"Encoded\"];\n\nexport type WithName<\n FunctionSpec_ extends AnyWithProps,\n Name_ extends string,\n> = Extract<FunctionSpec_, { readonly name: Name_ }>;\n\nexport type WithRuntimeAndFunctionType<\n FunctionSpec_ extends AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n> = Extract<\n FunctionSpec_,\n { readonly runtimeAndFunctionType: RuntimeAndFunctionType_ }\n>;\n\nexport type WithFunctionType<\n FunctionSpec_ extends AnyWithProps,\n FunctionType_ extends FunctionType,\n> = Extract<\n FunctionSpec_,\n { readonly runtimeAndFunctionType: { readonly functionType: FunctionType_ } }\n>;\n\nexport type WithFunctionProvenance<\n FunctionSpec_ extends AnyWithProps,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n> = Extract<\n FunctionSpec_,\n { readonly functionProvenance: FunctionProvenance_ }\n>;\n\nexport type WithoutName<\n FunctionSpec_ extends AnyWithProps,\n Name_ extends Name<FunctionSpec_>,\n> = Exclude<FunctionSpec_, { readonly name: Name_ }>;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n\n middleware(\n this: AnyWithProps,\n middlewareSpec: MiddlewareSpec.AnyMiddlewareSpec,\n ...options: ReadonlyArray<unknown>\n ) {\n if (this.functionProvenance._tag === \"Convex\") {\n throw new Error(\n `Plain Convex function \"${this.name}\" cannot have middleware`,\n );\n }\n const functionType = this.runtimeAndFunctionType.functionType;\n if (!middlewareSpec.functionTypes[functionType]) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" does not declare function type \"${functionType}\" of function \"${this.name}\"`,\n );\n }\n if (\n !(\"options\" in middlewareSpec) &&\n this.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is already attached to function \"${this.name}\"`,\n );\n }\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType: this.runtimeAndFunctionType,\n functionVisibility: this.functionVisibility,\n name: this.name,\n ...(\"description\" in this ? { description: this.description } : {}),\n ...(\"fields\" in this ? { fields: this.fields } : {}),\n functionProvenance: this.functionProvenance,\n middlewareAttachments: [\n ...this.middlewareAttachments,\n { spec: middlewareSpec, options: options[0] },\n ],\n });\n },\n} satisfies ThisType<AnyWithProps>;\n\ninterface Options {\n readonly description?: string;\n readonly name: string;\n readonly args?: () => FunctionProvenance.ArgsFields;\n readonly returns: () => Schema.Codec<any, any>;\n readonly error?: () => Schema.Codec<any, any>;\n}\n\nconst make = <\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n>(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n) => {\n function makeSpec<\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args: () => ArgsFields_;\n returns: () => Returns_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args?: never;\n returns: () => Returns_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<{}, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args: () => ArgsFields_;\n returns: () => Returns_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args?: never;\n returns: () => Returns_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<{}, Returns_, Error_>\n >;\n function makeSpec({ name, description, args, returns, error }: Options) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n ...(description === undefined ? {} : { description }),\n functionProvenance:\n args === undefined\n ? FunctionProvenance.Confect(() => ({}), returns, error)\n : FunctionProvenance.Confect(args, returns, error),\n middlewareAttachments: [],\n });\n }\n\n return makeSpec;\n};\n\n/**\n * `Schema.Struct` fields that must not declare `paginationOpts`. Used to reject\n * a user args schema that redeclares the field the paginated constructors add\n * themselves; the check reports at the `args` thunk with an unsatisfiable type\n * when violated.\n */\ntype ForbidPaginationOpts<\n UserArgsFields extends FunctionProvenance.ArgsFields,\n> = \"paginationOpts\" extends keyof UserArgsFields\n ? { readonly paginationOpts: never }\n : unknown;\n\ninterface PaginatedOptions {\n readonly description?: string;\n readonly name: string;\n readonly args?: () => FunctionProvenance.ArgsFields;\n readonly item: () => Schema.Codec<any, any>;\n readonly error?: () => Schema.Codec<any, any>;\n}\n\nconst makePaginated = <\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n>(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n) => {\n function makeSpec<\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;\n item: () => Item_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args?: never;\n item: () => Item_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<{}, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;\n item: () => Item_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args?: never;\n item: () => Item_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<{}, Item_, Error_>\n >;\n function makeSpec({\n name,\n description,\n args,\n item,\n error,\n }: PaginatedOptions) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n ...(description === undefined ? {} : { description }),\n functionProvenance:\n args === undefined\n ? FunctionProvenance.ConfectPaginated(() => ({}), item, error)\n : FunctionProvenance.ConfectPaginated(args, item, error),\n middlewareAttachments: [],\n });\n }\n\n return makeSpec;\n};\n\nexport const publicQuery = make(RuntimeAndFunctionType.ConvexQuery, \"public\");\nexport const internalQuery = make(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const publicPaginatedQuery = makePaginated(\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n);\nexport const internalPaginatedQuery = makePaginated(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const publicMutation = make(\n RuntimeAndFunctionType.ConvexMutation,\n \"public\",\n);\nexport const internalMutation = make(\n RuntimeAndFunctionType.ConvexMutation,\n \"internal\",\n);\nexport const publicAction = make(RuntimeAndFunctionType.ConvexAction, \"public\");\nexport const internalAction = make(\n RuntimeAndFunctionType.ConvexAction,\n \"internal\",\n);\n\nexport const publicNodeAction = make(\n RuntimeAndFunctionType.NodeAction,\n \"public\",\n);\nexport const internalNodeAction = make(\n RuntimeAndFunctionType.NodeAction,\n \"internal\",\n);\n\ntype OptionlessMiddlewareSpec = MiddlewareSpec.AnyMiddlewareSpec & {\n readonly \"~Options\": never;\n};\n\ntype BuilderOption =\n | \"name\"\n | \"description\"\n | \"args\"\n | \"returns\"\n | \"item\"\n | \"error\";\n\n/**\n * Only a required description string may name a builder option. The builder\n * reads it as that option. The conditional keeps the mapped type out of a\n * builder call's inference, which would otherwise widen the function's name to\n * `string` when reporting the error.\n */\ntype OptionFree<Type> = [keyof Type & BuilderOption] extends [never]\n ? unknown\n : {\n readonly [\n Option in keyof Type & BuilderOption as Option extends \"description\"\n ? Type[Option] extends string\n ? string extends Type[Option]\n ? never\n : Option\n : Option\n : Option\n ]: never;\n };\n\n/**\n * A function's fields, checked once applied, since a profile's field type can\n * branch on the function's name.\n */\ntype CheckedFields<Type> = Type & OptionFree<Type>;\n\ntype NotRepeated<\n Middleware_,\n Inherited extends MiddlewareSpec.AnyMiddlewareSpec,\n> = Middleware_ extends {\n readonly key: infer Key extends MiddlewareSpec.Key<Inherited>;\n}\n ? MiddlewareSpec.AttachmentError<`Middleware \"${Key}\" is already attached by this profile`>\n : Middleware_;\n\n/**\n * Refuses a middleware without options that an earlier layer attached, as it is\n * attached at most once; one with options may repeat. Each member of an\n * element's union is checked, so an array typed `(A | B)[]` is refused when\n * either was attached.\n */\ntype NotInherited<\n Middleware_ extends ReadonlyArray<unknown>,\n Inherited extends MiddlewareSpec.AnyMiddlewareSpec,\n> = {\n readonly [Index in keyof Middleware_]: NotRepeated<\n Middleware_[Index],\n Inherited\n >;\n};\n\n/**\n * A profile's middleware: a spec without options, or an attachment.\n */\ntype ProfileMiddleware<FieldsType> =\n | OptionlessMiddlewareSpec\n | Profile.Attachment<MiddlewareSpec.AnyMiddlewareSpec, FieldsType>;\n\ntype SpecOf<Middleware_> =\n Middleware_ extends Profile.Attachment<infer MiddlewareSpec_, any>\n ? MiddlewareSpec_\n : Extract<Middleware_, MiddlewareSpec.AnyMiddlewareSpec>;\n\n/**\n * `never` when a profile middleware does not declare the function type.\n */\ntype Declared<\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n FunctionType_ extends FunctionType,\n Make,\n> = [\n MiddlewareSpecs_ extends unknown\n ? FunctionType_ extends MiddlewareSpec.FunctionTypes<MiddlewareSpecs_>\n ? never\n : MiddlewareSpecs_\n : never,\n] extends [never]\n ? Make\n : never;\n\ntype Wrapped<\n Layers extends ReadonlyArray<Profile.Transforms>,\n Key extends keyof Profile.Transforms,\n Input,\n> = Layers extends readonly [\n infer First extends Profile.Transforms,\n ...infer Rest extends ReadonlyArray<Profile.Transforms>,\n]\n ? Wrapped<\n Rest,\n Key,\n Key extends keyof First\n ? [Input] extends [never]\n ? Key extends \"error\"\n ? Profile.Transform<First[Key], typeof Schema.Never>\n : never\n : Profile.Transform<First[Key], Input>\n : Input\n >\n : Input;\n\ntype UserArgs<A> = [A] extends [never] ? {} : A;\n\ntype ExtendedMake<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms>,\n> = Declared<\n MiddlewareSpecs_,\n RuntimeAndFunctionType_[\"functionType\"],\n <\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = never,\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n options: {\n readonly name: Name_;\n readonly description?: string;\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n } & NoInfer<\n CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>>\n >,\n ) => ExtendedBuilder<\n RuntimeAndFunctionType_,\n \"public\",\n Name_,\n FunctionProvenance.Confect<\n UserArgs<Wrapped<Layers, \"args\", ArgsFields_>>,\n Wrapped<Layers, \"returns\", Returns_>,\n Wrapped<Layers, \"error\", Error_>\n >,\n MiddlewareSpecs_,\n Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>\n >\n>;\n\ntype ExtendedMakePaginated<\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms>,\n> = Declared<\n MiddlewareSpecs_,\n \"query\",\n <\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields = never,\n Item_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n options: {\n readonly name: Name_;\n readonly description?: string;\n readonly args?: () => UserArgsFields_ &\n ForbidPaginationOpts<UserArgsFields_>;\n readonly item: () => Item_;\n readonly error?: () => Error_;\n } & NoInfer<\n CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>>\n >,\n ) => ExtendedBuilder<\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n Name_,\n FunctionProvenance.ConfectPaginated<\n UserArgs<Wrapped<Layers, \"args\", UserArgsFields_>>,\n Wrapped<Layers, \"item\", Item_>,\n Wrapped<Layers, \"error\", Error_>\n >,\n MiddlewareSpecs_,\n Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>\n >\n>;\n\ninterface ExtendedRuntimes {\n readonly publicQuery: RuntimeAndFunctionType.ConvexQuery;\n readonly publicMutation: RuntimeAndFunctionType.ConvexMutation;\n readonly publicAction: RuntimeAndFunctionType.ConvexAction;\n readonly publicNodeAction: RuntimeAndFunctionType.NodeAction;\n}\n\n/**\n * A profile's five public builders and its own `extend`.\n */\nexport type Extended<\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms> = [],\n> = {\n readonly [Builder_ in keyof ExtendedRuntimes]: ExtendedMake<\n ExtendedRuntimes[Builder_],\n Fields_,\n MiddlewareSpecs_,\n Layers\n >;\n} & {\n readonly publicPaginatedQuery: ExtendedMakePaginated<\n Fields_,\n MiddlewareSpecs_,\n Layers\n >;\n /**\n * Require more fields and attach more middleware after this profile's.\n */\n extend<\n Extension extends Profile.Fields = Profile.NoFields,\n Transforms extends Profile.Transforms = {},\n >(): <\n const Middleware_ extends ReadonlyArray<\n ProfileMiddleware<\n Profile.Apply<Profile.Both<Fields_, Extension>, string, any>\n >\n >,\n >(\n config: {\n readonly middleware: Middleware_ &\n NotInherited<Middleware_, MiddlewareSpecs_>;\n } & OptionFree<Extension[\"Type\"]> &\n Profile.SchemaConfig<\n Transforms,\n Profile.Apply<Profile.Both<Fields_, Extension>, string, any>\n >,\n ) => Extended<\n Profile.Both<Fields_, Extension>,\n MiddlewareSpecs_ | SpecOf<Middleware_[number]>,\n [...Layers, Transforms]\n >;\n};\n\ntype RuntimeWrappers = Partial<\n Record<\n keyof Profile.Transforms,\n (thunk: () => any, info: Profile.Info<any>) => () => any\n >\n>;\n\nconst makeExtended = (\n middleware: ReadonlyArray<ProfileMiddleware<any>>,\n schemas: ReadonlyArray<RuntimeWrappers> = [],\n): Extended<any, any> => {\n const extended =\n (makeSpec: (options: never) => object, paginated = false): any =>\n ({\n name,\n description,\n args,\n returns,\n item,\n error,\n ...fields\n }: Record<string, unknown>) => {\n const info = {\n name,\n ...(description === undefined ? {} : { description }),\n args: args ?? (() => ({})),\n fields,\n } as Profile.Info<unknown>;\n const thunks = {\n args,\n returns: paginated ? undefined : returns,\n item: paginated ? item : undefined,\n error,\n } as Partial<Record<keyof Profile.Transforms, () => any>>;\n for (const wrappers of schemas) {\n for (const key of [\"args\", \"returns\", \"item\", \"error\"] as const) {\n const wrap = wrappers[key];\n const thunk =\n thunks[key] ?? (key === \"error\" ? () => Schema.Never : undefined);\n if (wrap !== undefined && thunk !== undefined) {\n thunks[key] = () => wrap(thunk, info)();\n }\n }\n }\n return middleware.reduce(\n (spec: any, entry) =>\n MiddlewareSpec.isMiddlewareSpec(entry)\n ? spec.middleware(entry)\n : spec.middleware(entry.spec, entry.options(info)),\n Object.assign(makeSpec({ name, description, ...thunks } as never), {\n fields,\n }),\n );\n };\n\n return {\n publicQuery: extended(publicQuery),\n publicMutation: extended(publicMutation),\n publicAction: extended(publicAction),\n publicNodeAction: extended(publicNodeAction),\n publicPaginatedQuery: extended(publicPaginatedQuery, true),\n extend:\n () =>\n (config: {\n middleware: ReadonlyArray<ProfileMiddleware<any>>;\n schemas?: RuntimeWrappers;\n }) =>\n makeExtended(\n [...middleware, ...config.middleware],\n [...schemas, config.schemas ?? {}],\n ),\n };\n};\n\n/**\n * Public builders whose specs require and keep `Fields_`, with `middleware`.\n */\nexport const extend =\n <\n Fields_ extends Profile.Fields = Profile.NoFields,\n Transforms extends Profile.Transforms = {},\n >() =>\n <\n const Middleware_ extends ReadonlyArray<\n ProfileMiddleware<Profile.Apply<Fields_, string, any>>\n >,\n >(\n config: {\n readonly middleware: Middleware_;\n } & OptionFree<Fields_[\"Type\"]> &\n Profile.SchemaConfig<Transforms, Profile.Apply<Fields_, string, any>>,\n ) =>\n makeExtended(config.middleware, [config.schemas ?? {}]) as Extended<\n Fields_,\n SpecOf<Middleware_[number]>,\n [Transforms]\n >;\n\ntype MatchingRegisteredFunction<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n> =\n RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"query\"\n ? RegisteredQuery<FunctionVisibility_, any, any>\n : RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"mutation\"\n ? RegisteredMutation<FunctionVisibility_, any, any>\n : RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"action\"\n ? RegisteredAction<FunctionVisibility_, any, any>\n : never;\n\ntype ExtractArgs<F> =\n F extends RegisteredQuery<any, infer A extends DefaultFunctionArgs, any>\n ? A\n : F extends RegisteredMutation<\n any,\n infer A extends DefaultFunctionArgs,\n any\n >\n ? A\n : F extends RegisteredAction<\n any,\n infer A extends DefaultFunctionArgs,\n any\n >\n ? A\n : never;\n\ntype ExtractReturns<F> =\n F extends RegisteredQuery<any, any, infer R>\n ? R\n : F extends RegisteredMutation<any, any, infer R>\n ? R\n : F extends RegisteredAction<any, any, infer R>\n ? R\n : never;\n\nconst makeConvex =\n <\n RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n >(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n ) =>\n <\n F extends MatchingRegisteredFunction<\n RuntimeAndFunctionType_,\n FunctionVisibility_\n >,\n >() =>\n <const Name_ extends string>(\n name: Name_,\n ): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Convex<ExtractArgs<F>, ExtractReturns<F>>\n > => {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n functionProvenance: FunctionProvenance.Convex<\n ExtractArgs<F>,\n ExtractReturns<F>\n >(),\n middlewareAttachments: [],\n }) as any;\n };\n\nexport const convexPublicQuery = makeConvex(\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n);\nexport const convexInternalQuery = makeConvex(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const convexPublicMutation = makeConvex(\n RuntimeAndFunctionType.ConvexMutation,\n \"public\",\n);\nexport const convexInternalMutation = makeConvex(\n RuntimeAndFunctionType.ConvexMutation,\n \"internal\",\n);\nexport const convexPublicAction = makeConvex(\n RuntimeAndFunctionType.ConvexAction,\n \"public\",\n);\nexport const convexInternalAction = makeConvex(\n RuntimeAndFunctionType.ConvexAction,\n \"internal\",\n);\nexport const convexPublicNodeAction = makeConvex(\n RuntimeAndFunctionType.NodeAction,\n \"public\",\n);\nexport const convexInternalNodeAction = makeConvex(\n RuntimeAndFunctionType.NodeAction,\n \"internal\",\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAG,MAAM;AAyVjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAI,kBAAkB;EACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;CAC1D;CAEA,WAEE,gBACA,GAAG,SACH;EACA,IAAI,KAAK,mBAAmB,SAAS,UACnC,MAAM,IAAI,MACR,0BAA0B,KAAK,KAAK,yBACtC;EAEF,MAAM,eAAe,KAAK,uBAAuB;EACjD,IAAI,CAAC,eAAe,cAAc,eAChC,MAAM,IAAI,MACR,eAAe,eAAe,IAAI,oCAAoC,aAAa,iBAAiB,KAAK,KAAK,EAChH;EAEF,IACE,EAAE,aAAa,mBACf,KAAK,sBAAsB,MACxB,EAAE,WAAW,KAAK,QAAQ,eAAe,GAC5C,GAEA,MAAM,IAAI,MACR,eAAe,eAAe,IAAI,qCAAqC,KAAK,KAAK,EACnF;EAGF,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;GACzC,wBAAwB,KAAK;GAC7B,oBAAoB,KAAK;GACzB,MAAM,KAAK;GACX,GAAI,iBAAiB,OAAO,EAAE,aAAa,KAAK,YAAY,IAAI,C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Aa,OAAO,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC;AA4C1D,MAAM,cAMF,wBACA,8BASA,SAMG;CACH,kCAAkC,IAAI;CAEtC,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;EACzC;EACA;EACA;EACA,oBAAoBC,OAGlB;EACF,uBAAuB,CAAC;CAC1B,CAAC;AACH;AAEF,MAAa,oBAAoB,WAC/BL,aACA,QACF;AACA,MAAa,sBAAsB,WACjCA,aACA,UACF;AACA,MAAa,uBAAuB,WAClCC,gBACA,QACF;AACA,MAAa,yBAAyB,WACpCA,gBACA,UACF;AACA,MAAa,qBAAqB,WAChCC,cACA,QACF;AACA,MAAa,uBAAuB,WAClCA,cACA,UACF;AACA,MAAa,yBAAyB,WACpCC,YACA,QACF;AACA,MAAa,2BAA2B,WACtCA,YACA,UACF"}
|
|
1
|
+
{"version":3,"file":"FunctionSpec.js","names":["FunctionProvenance.Confect","FunctionProvenance.ConfectPaginated","RuntimeAndFunctionType.ConvexQuery","RuntimeAndFunctionType.ConvexMutation","RuntimeAndFunctionType.ConvexAction","RuntimeAndFunctionType.NodeAction","MiddlewareSpec.isMiddlewareSpec","FunctionProvenance.Convex"],"sources":["../src/FunctionSpec.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionType,\n FunctionVisibility,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n} from \"convex/server\";\nimport * as Schema from \"effect/Schema\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as Profile from \"./Profile.js\";\nimport * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/FunctionSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isFunctionSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface FunctionSpec<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtimeAndFunctionType: RuntimeAndFunctionType_;\n readonly functionVisibility: FunctionVisibility_;\n readonly name: Name_;\n readonly reservedArgument?: string;\n readonly functionProvenance: FunctionProvenance_;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly middlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<MiddlewareSpecs_>\n >;\n}\n\nexport interface Builder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> extends FunctionSpec<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface DescribedBuilder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> extends Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n readonly description?: string;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\n/**\n * A spec built through {@link extend}, keeping its fields through middleware.\n */\nexport interface ExtendedBuilder<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Name_ extends string,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Fields_,\n> extends Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_\n> {\n readonly description?: string;\n readonly fields: Profile.Info<Fields_>[\"fields\"];\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateFunctionAttach<\n MiddlewareSpec_,\n RuntimeAndFunctionType_,\n FunctionProvenance_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): ExtendedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance_,\n MiddlewareSpecs_ | MiddlewareSpec_,\n Fields_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {\n readonly description?: string;\n readonly fields?: object;\n}\n\nexport interface AnyConfect extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.AnyConfect,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyConvex extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance.AnyConvex,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends FunctionSpec<\n RuntimeAndFunctionType.WithRuntime<Runtime>,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithFunctionType<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n> extends FunctionSpec<\n RuntimeAndFunctionType_,\n FunctionVisibility,\n string,\n FunctionProvenance.FunctionProvenance,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithFunctionProvenance<\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n> extends FunctionSpec<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility,\n string,\n FunctionProvenance_,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type GetRuntimeAndFunctionType<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"runtimeAndFunctionType\"];\n\nexport type GetFunctionVisibility<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"functionVisibility\"];\n\nexport type GetFunctionProvenance<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"functionProvenance\"];\n\nexport type Name<FunctionSpec_ extends AnyWithProps> = FunctionSpec_[\"name\"];\n\nexport type MiddlewareSpecs<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_[\"middlewareSpecs\"][number];\n\n/**\n * The field map declared by a Confect-provenance spec.\n */\nexport type ArgsFields<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n };\n }\n ? ArgsFields_\n : FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? FunctionProvenance.ArgsFields\n : never;\n\n/**\n * The args schema assembled from a Confect-provenance spec's field map.\n */\nexport type ArgsSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n };\n }\n ? Schema.Struct<ArgsFields_>\n : FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends\n FunctionProvenance.AnyArgsSchema;\n };\n }\n ? ArgsSchema_\n : never;\n\nexport type ReturnsSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n };\n }\n ? ReturnsSchema_\n : never;\n\nexport type ErrorSchema<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n };\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<FunctionSpec_ extends AnyWithProps> = FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n}\n ? ArgsSchema<FunctionSpec_>[\"Type\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_,\n any\n >\n ? Args_\n : never;\n\nexport type Returns<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ReturnsSchema<FunctionSpec_>[\"Type\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n any,\n infer Returns_\n >\n ? Awaited<Returns_>\n : never;\n\nexport type EncodedArgs<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ArgsSchema<FunctionSpec_>[\"Encoded\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_,\n any\n >\n ? Args_\n : never;\n\nexport type EncodedReturns<FunctionSpec_ extends AnyWithProps> =\n FunctionSpec_ extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ? ReturnsSchema<FunctionSpec_>[\"Encoded\"]\n : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n any,\n infer Returns_\n >\n ? Returns_\n : never;\n\nexport type Error<FunctionSpec_ extends AnyWithProps> =\n ErrorSchema<FunctionSpec_>[\"Type\"];\n\nexport type EncodedError<FunctionSpec_ extends AnyWithProps> =\n ErrorSchema<FunctionSpec_>[\"Encoded\"];\n\nexport type WithName<\n FunctionSpec_ extends AnyWithProps,\n Name_ extends string,\n> = Extract<FunctionSpec_, { readonly name: Name_ }>;\n\nexport type WithRuntimeAndFunctionType<\n FunctionSpec_ extends AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n> = Extract<\n FunctionSpec_,\n { readonly runtimeAndFunctionType: RuntimeAndFunctionType_ }\n>;\n\nexport type WithFunctionType<\n FunctionSpec_ extends AnyWithProps,\n FunctionType_ extends FunctionType,\n> = Extract<\n FunctionSpec_,\n { readonly runtimeAndFunctionType: { readonly functionType: FunctionType_ } }\n>;\n\nexport type WithFunctionProvenance<\n FunctionSpec_ extends AnyWithProps,\n FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,\n> = Extract<\n FunctionSpec_,\n { readonly functionProvenance: FunctionProvenance_ }\n>;\n\nexport type WithoutName<\n FunctionSpec_ extends AnyWithProps,\n Name_ extends Name<FunctionSpec_>,\n> = Exclude<FunctionSpec_, { readonly name: Name_ }>;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n\n middleware(\n this: AnyWithProps,\n middlewareSpec: MiddlewareSpec.AnyMiddlewareSpec,\n ...options: ReadonlyArray<unknown>\n ) {\n if (this.functionProvenance._tag === \"Convex\") {\n throw new Error(\n `Plain Convex function \"${this.name}\" cannot have middleware`,\n );\n }\n const functionType = this.runtimeAndFunctionType.functionType;\n if (!middlewareSpec.functionTypes[functionType]) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" does not declare function type \"${functionType}\" of function \"${this.name}\"`,\n );\n }\n if (\n !(\"options\" in middlewareSpec) &&\n this.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is already attached to function \"${this.name}\"`,\n );\n }\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType: this.runtimeAndFunctionType,\n functionVisibility: this.functionVisibility,\n name: this.name,\n ...(this.reservedArgument === undefined\n ? {}\n : { reservedArgument: this.reservedArgument }),\n ...(\"description\" in this ? { description: this.description } : {}),\n ...(\"fields\" in this ? { fields: this.fields } : {}),\n functionProvenance: this.functionProvenance,\n middlewareAttachments: [\n ...this.middlewareAttachments,\n { spec: middlewareSpec, options: options[0] },\n ],\n });\n },\n} satisfies ThisType<AnyWithProps>;\n\ninterface Options {\n readonly reservedArgument?: string;\n readonly description?: string;\n readonly name: string;\n readonly args?: () => FunctionProvenance.ArgsFields;\n readonly returns: () => Schema.Codec<any, any>;\n readonly error?: () => Schema.Codec<any, any>;\n}\n\nconst make = <\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n>(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n) => {\n function makeSpec<\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n reservedArgument?: RuntimeAndFunctionType_[\"functionType\"] extends \"query\"\n ? never\n : string;\n name: Name_;\n description?: never;\n args: () => ArgsFields_;\n returns: () => Returns_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n reservedArgument?: RuntimeAndFunctionType_[\"functionType\"] extends \"query\"\n ? never\n : string;\n name: Name_;\n description?: never;\n args?: never;\n returns: () => Returns_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<{}, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n reservedArgument?: RuntimeAndFunctionType_[\"functionType\"] extends \"query\"\n ? never\n : string;\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args: () => ArgsFields_;\n returns: () => Returns_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n reservedArgument?: RuntimeAndFunctionType_[\"functionType\"] extends \"query\"\n ? never\n : string;\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args?: never;\n returns: () => Returns_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Confect<{}, Returns_, Error_>\n >;\n function makeSpec({\n name,\n description,\n args,\n returns,\n error,\n reservedArgument,\n }: Options) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n ...(runtimeAndFunctionType.functionType !== \"query\" &&\n reservedArgument !== undefined\n ? { reservedArgument }\n : {}),\n ...(description === undefined ? {} : { description }),\n functionProvenance:\n args === undefined\n ? FunctionProvenance.Confect(() => ({}), returns, error)\n : FunctionProvenance.Confect(args, returns, error),\n middlewareAttachments: [],\n });\n }\n\n return makeSpec;\n};\n\n/**\n * `Schema.Struct` fields that must not declare `paginationOpts`. Used to reject\n * a user args schema that redeclares the field the paginated constructors add\n * themselves; the check reports at the `args` thunk with an unsatisfiable type\n * when violated.\n */\ntype ForbidPaginationOpts<\n UserArgsFields extends FunctionProvenance.ArgsFields,\n> = \"paginationOpts\" extends keyof UserArgsFields\n ? { readonly paginationOpts: never }\n : unknown;\n\ninterface PaginatedOptions {\n readonly description?: string;\n readonly name: string;\n readonly args?: () => FunctionProvenance.ArgsFields;\n readonly item: () => Schema.Codec<any, any>;\n readonly error?: () => Schema.Codec<any, any>;\n}\n\nconst makePaginated = <\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n>(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n) => {\n function makeSpec<\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;\n item: () => Item_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: never;\n args?: never;\n item: () => Item_;\n error?: () => Error_;\n }): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<{}, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;\n item: () => Item_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>\n >;\n function makeSpec<\n const Name_ extends string,\n Item_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n >(options: {\n name: Name_;\n description?: FunctionVisibility_ extends \"public\" ? string : never;\n args?: never;\n item: () => Item_;\n error?: () => Error_;\n }): DescribedBuilder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.ConfectPaginated<{}, Item_, Error_>\n >;\n function makeSpec({\n name,\n description,\n args,\n item,\n error,\n }: PaginatedOptions) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n ...(description === undefined ? {} : { description }),\n functionProvenance:\n args === undefined\n ? FunctionProvenance.ConfectPaginated(() => ({}), item, error)\n : FunctionProvenance.ConfectPaginated(args, item, error),\n middlewareAttachments: [],\n });\n }\n\n return makeSpec;\n};\n\nexport const publicQuery = make(RuntimeAndFunctionType.ConvexQuery, \"public\");\nexport const internalQuery = make(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const publicPaginatedQuery = makePaginated(\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n);\nexport const internalPaginatedQuery = makePaginated(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const publicMutation = make(\n RuntimeAndFunctionType.ConvexMutation,\n \"public\",\n);\nexport const internalMutation = make(\n RuntimeAndFunctionType.ConvexMutation,\n \"internal\",\n);\nexport const publicAction = make(RuntimeAndFunctionType.ConvexAction, \"public\");\nexport const internalAction = make(\n RuntimeAndFunctionType.ConvexAction,\n \"internal\",\n);\n\nexport const publicNodeAction = make(\n RuntimeAndFunctionType.NodeAction,\n \"public\",\n);\nexport const internalNodeAction = make(\n RuntimeAndFunctionType.NodeAction,\n \"internal\",\n);\n\ntype OptionlessMiddlewareSpec = MiddlewareSpec.AnyMiddlewareSpec & {\n readonly \"~Options\": never;\n};\n\ntype BuilderOption =\n | \"name\"\n | \"description\"\n | \"args\"\n | \"returns\"\n | \"item\"\n | \"error\";\n\n/**\n * Only a required description string may name a builder option. The builder\n * reads it as that option. The conditional keeps the mapped type out of a\n * builder call's inference, which would otherwise widen the function's name to\n * `string` when reporting the error.\n */\ntype OptionFree<Type> = [keyof Type & BuilderOption] extends [never]\n ? unknown\n : {\n readonly [\n Option in keyof Type & BuilderOption as Option extends \"description\"\n ? Type[Option] extends string\n ? string extends Type[Option]\n ? never\n : Option\n : Option\n : Option\n ]: never;\n };\n\n/**\n * A function's fields, checked once applied, since a profile's field type can\n * branch on the function's name.\n */\ntype CheckedFields<Type> = Type & OptionFree<Type>;\n\ntype NotRepeated<\n Middleware_,\n Inherited extends MiddlewareSpec.AnyMiddlewareSpec,\n> = Middleware_ extends {\n readonly key: infer Key extends MiddlewareSpec.Key<Inherited>;\n}\n ? MiddlewareSpec.AttachmentError<`Middleware \"${Key}\" is already attached by this profile`>\n : Middleware_;\n\n/**\n * Refuses a middleware without options that an earlier layer attached, as it is\n * attached at most once; one with options may repeat. Each member of an\n * element's union is checked, so an array typed `(A | B)[]` is refused when\n * either was attached.\n */\ntype NotInherited<\n Middleware_ extends ReadonlyArray<unknown>,\n Inherited extends MiddlewareSpec.AnyMiddlewareSpec,\n> = {\n readonly [Index in keyof Middleware_]: NotRepeated<\n Middleware_[Index],\n Inherited\n >;\n};\n\n/**\n * A profile's middleware: a spec without options, or an attachment.\n */\ntype ProfileMiddleware<FieldsType> =\n | OptionlessMiddlewareSpec\n | Profile.Attachment<MiddlewareSpec.AnyMiddlewareSpec, FieldsType>;\n\ntype SpecOf<Middleware_> =\n Middleware_ extends Profile.Attachment<infer MiddlewareSpec_, any>\n ? MiddlewareSpec_\n : Extract<Middleware_, MiddlewareSpec.AnyMiddlewareSpec>;\n\n/**\n * `never` when a profile middleware does not declare the function type.\n */\ntype Declared<\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n FunctionType_ extends FunctionType,\n Make,\n> = [\n MiddlewareSpecs_ extends unknown\n ? FunctionType_ extends MiddlewareSpec.FunctionTypes<MiddlewareSpecs_>\n ? never\n : MiddlewareSpecs_\n : never,\n] extends [never]\n ? Make\n : never;\n\ntype Wrapped<\n Layers extends ReadonlyArray<Profile.Transforms>,\n Key extends keyof Profile.Transforms,\n Input,\n> = Layers extends readonly [\n infer First extends Profile.Transforms,\n ...infer Rest extends ReadonlyArray<Profile.Transforms>,\n]\n ? Wrapped<\n Rest,\n Key,\n Key extends keyof First\n ? [Input] extends [never]\n ? Key extends \"error\"\n ? Profile.Transform<First[Key], typeof Schema.Never>\n : never\n : Profile.Transform<First[Key], Input>\n : Input\n >\n : Input;\n\ntype UserArgs<A> = [A] extends [never] ? {} : A;\n\ntype ExtendedMake<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms>,\n> = Declared<\n MiddlewareSpecs_,\n RuntimeAndFunctionType_[\"functionType\"],\n <\n const Name_ extends string,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = never,\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n options: {\n readonly name: Name_;\n readonly description?: string;\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n } & NoInfer<\n CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>>\n >,\n ) => ExtendedBuilder<\n RuntimeAndFunctionType_,\n \"public\",\n Name_,\n FunctionProvenance.Confect<\n UserArgs<Wrapped<Layers, \"args\", ArgsFields_>>,\n Wrapped<Layers, \"returns\", Returns_>,\n Wrapped<Layers, \"error\", Error_>\n >,\n MiddlewareSpecs_,\n Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>\n >\n>;\n\ntype ExtendedMakePaginated<\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms>,\n> = Declared<\n MiddlewareSpecs_,\n \"query\",\n <\n const Name_ extends string,\n const UserArgsFields_ extends FunctionProvenance.ArgsFields = never,\n Item_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n options: {\n readonly name: Name_;\n readonly description?: string;\n readonly args?: () => UserArgsFields_ &\n ForbidPaginationOpts<UserArgsFields_>;\n readonly item: () => Item_;\n readonly error?: () => Error_;\n } & NoInfer<\n CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>>\n >,\n ) => ExtendedBuilder<\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n Name_,\n FunctionProvenance.ConfectPaginated<\n UserArgs<Wrapped<Layers, \"args\", UserArgsFields_>>,\n Wrapped<Layers, \"item\", Item_>,\n Wrapped<Layers, \"error\", Error_>\n >,\n MiddlewareSpecs_,\n Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>\n >\n>;\n\ninterface ExtendedRuntimes {\n readonly publicQuery: RuntimeAndFunctionType.ConvexQuery;\n readonly publicMutation: RuntimeAndFunctionType.ConvexMutation;\n readonly publicAction: RuntimeAndFunctionType.ConvexAction;\n readonly publicNodeAction: RuntimeAndFunctionType.NodeAction;\n}\n\n/**\n * A profile's five public builders and its own `extend`.\n */\nexport type Extended<\n Fields_ extends Profile.Fields,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Layers extends ReadonlyArray<Profile.Transforms> = [],\n> = {\n readonly [Builder_ in keyof ExtendedRuntimes]: ExtendedMake<\n ExtendedRuntimes[Builder_],\n Fields_,\n MiddlewareSpecs_,\n Layers\n >;\n} & {\n readonly publicPaginatedQuery: ExtendedMakePaginated<\n Fields_,\n MiddlewareSpecs_,\n Layers\n >;\n /**\n * Require more fields and attach more middleware after this profile's.\n */\n extend<\n Extension extends Profile.Fields = Profile.NoFields,\n Transforms extends Profile.Transforms = {},\n >(): <\n const Middleware_ extends ReadonlyArray<\n ProfileMiddleware<\n Profile.Apply<Profile.Both<Fields_, Extension>, string, any>\n >\n >,\n >(\n config: {\n readonly reservedArgument?: string;\n readonly middleware: Middleware_ &\n NotInherited<Middleware_, MiddlewareSpecs_>;\n } & OptionFree<Extension[\"Type\"]> &\n Profile.SchemaConfig<\n Transforms,\n Profile.Apply<Profile.Both<Fields_, Extension>, string, any>\n >,\n ) => Extended<\n Profile.Both<Fields_, Extension>,\n MiddlewareSpecs_ | SpecOf<Middleware_[number]>,\n [...Layers, Transforms]\n >;\n};\n\ntype RuntimeWrappers = Partial<\n Record<\n keyof Profile.Transforms,\n (thunk: () => any, info: Profile.Info<any>) => () => any\n >\n>;\n\nconst makeExtended = (\n middleware: ReadonlyArray<ProfileMiddleware<any>>,\n schemas: ReadonlyArray<RuntimeWrappers> = [],\n reservedArgument?: string,\n): Extended<any, any> => {\n const extended =\n (\n makeSpec: (options: never) => object,\n paginated = false,\n reserves = false,\n ): any =>\n ({\n name,\n description,\n args,\n returns,\n item,\n error,\n ...fields\n }: Record<string, unknown>) => {\n const info = {\n name,\n ...(description === undefined ? {} : { description }),\n args: args ?? (() => ({})),\n fields,\n } as Profile.Info<unknown>;\n const thunks = {\n args,\n returns: paginated ? undefined : returns,\n item: paginated ? item : undefined,\n error,\n } as Partial<Record<keyof Profile.Transforms, () => any>>;\n for (const wrappers of schemas) {\n for (const key of [\"args\", \"returns\", \"item\", \"error\"] as const) {\n const wrap = wrappers[key];\n const thunk =\n thunks[key] ?? (key === \"error\" ? () => Schema.Never : undefined);\n if (wrap !== undefined && thunk !== undefined) {\n thunks[key] = () => wrap(thunk, info)();\n }\n }\n }\n return middleware.reduce(\n (spec: any, entry) =>\n MiddlewareSpec.isMiddlewareSpec(entry)\n ? spec.middleware(entry)\n : spec.middleware(entry.spec, entry.options(info)),\n Object.assign(makeSpec({ name, description, ...thunks } as never), {\n fields,\n ...(reserves && reservedArgument !== undefined\n ? { reservedArgument }\n : {}),\n }),\n );\n };\n\n return {\n publicQuery: extended(publicQuery),\n publicMutation: extended(publicMutation, false, true),\n publicAction: extended(publicAction, false, true),\n publicNodeAction: extended(publicNodeAction, false, true),\n publicPaginatedQuery: extended(publicPaginatedQuery, true),\n extend:\n () =>\n (config: {\n middleware: ReadonlyArray<ProfileMiddleware<any>>;\n schemas?: RuntimeWrappers;\n reservedArgument?: string;\n }) =>\n makeExtended(\n [...middleware, ...config.middleware],\n [...schemas, config.schemas ?? {}],\n config.reservedArgument ?? reservedArgument,\n ),\n };\n};\n\n/**\n * Public builders whose specs require and keep `Fields_`, with `middleware`.\n */\nexport const extend =\n <\n Fields_ extends Profile.Fields = Profile.NoFields,\n Transforms extends Profile.Transforms = {},\n >() =>\n <\n const Middleware_ extends ReadonlyArray<\n ProfileMiddleware<Profile.Apply<Fields_, string, any>>\n >,\n >(\n config: {\n readonly reservedArgument?: string;\n readonly middleware: Middleware_;\n } & OptionFree<Fields_[\"Type\"]> &\n Profile.SchemaConfig<Transforms, Profile.Apply<Fields_, string, any>>,\n ) =>\n makeExtended(\n config.middleware,\n [config.schemas ?? {}],\n config.reservedArgument,\n ) as Extended<Fields_, SpecOf<Middleware_[number]>, [Transforms]>;\n\ntype MatchingRegisteredFunction<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n> =\n RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"query\"\n ? RegisteredQuery<FunctionVisibility_, any, any>\n : RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"mutation\"\n ? RegisteredMutation<FunctionVisibility_, any, any>\n : RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends \"action\"\n ? RegisteredAction<FunctionVisibility_, any, any>\n : never;\n\ntype ExtractArgs<F> =\n F extends RegisteredQuery<any, infer A extends DefaultFunctionArgs, any>\n ? A\n : F extends RegisteredMutation<\n any,\n infer A extends DefaultFunctionArgs,\n any\n >\n ? A\n : F extends RegisteredAction<\n any,\n infer A extends DefaultFunctionArgs,\n any\n >\n ? A\n : never;\n\ntype ExtractReturns<F> =\n F extends RegisteredQuery<any, any, infer R>\n ? R\n : F extends RegisteredMutation<any, any, infer R>\n ? R\n : F extends RegisteredAction<any, any, infer R>\n ? R\n : never;\n\nconst makeConvex =\n <\n RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n >(\n runtimeAndFunctionType: RuntimeAndFunctionType_,\n functionVisibility: FunctionVisibility_,\n ) =>\n <\n F extends MatchingRegisteredFunction<\n RuntimeAndFunctionType_,\n FunctionVisibility_\n >,\n >() =>\n <const Name_ extends string>(\n name: Name_,\n ): Builder<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Name_,\n FunctionProvenance.Convex<ExtractArgs<F>, ExtractReturns<F>>\n > => {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\n functionProvenance: FunctionProvenance.Convex<\n ExtractArgs<F>,\n ExtractReturns<F>\n >(),\n middlewareAttachments: [],\n }) as any;\n };\n\nexport const convexPublicQuery = makeConvex(\n RuntimeAndFunctionType.ConvexQuery,\n \"public\",\n);\nexport const convexInternalQuery = makeConvex(\n RuntimeAndFunctionType.ConvexQuery,\n \"internal\",\n);\nexport const convexPublicMutation = makeConvex(\n RuntimeAndFunctionType.ConvexMutation,\n \"public\",\n);\nexport const convexInternalMutation = makeConvex(\n RuntimeAndFunctionType.ConvexMutation,\n \"internal\",\n);\nexport const convexPublicAction = makeConvex(\n RuntimeAndFunctionType.ConvexAction,\n \"public\",\n);\nexport const convexInternalAction = makeConvex(\n RuntimeAndFunctionType.ConvexAction,\n \"internal\",\n);\nexport const convexPublicNodeAction = makeConvex(\n RuntimeAndFunctionType.NodeAction,\n \"public\",\n);\nexport const convexInternalNodeAction = makeConvex(\n RuntimeAndFunctionType.NodeAction,\n \"internal\",\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAG,MAAM;AA0VjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAI,kBAAkB;EACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;CAC1D;CAEA,WAEE,gBACA,GAAG,SACH;EACA,IAAI,KAAK,mBAAmB,SAAS,UACnC,MAAM,IAAI,MACR,0BAA0B,KAAK,KAAK,yBACtC;E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AACA,MAAa,yBAAyB,WACpCC,YACA,QACF;AACA,MAAa,2BAA2B,WACtCA,YACA,UACF"}
|
package/dist/Ref.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface Base<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.Run
|
|
|
21
21
|
readonly "~Error": Error_;
|
|
22
22
|
readonly functionType?: RuntimeAndFunctionType_["functionType"];
|
|
23
23
|
readonly convexFunctionName: string;
|
|
24
|
+
readonly reservedArgument?: string;
|
|
24
25
|
/**
|
|
25
26
|
* Preserved for component references and function handles, which have no
|
|
26
27
|
* local name.
|
|
@@ -170,7 +171,7 @@ convexFunctionNamespace: string, functionSpec: FunctionSpec_, groupMiddlewareAtt
|
|
|
170
171
|
* and `error` from the provenance on first use, so building it forces no
|
|
171
172
|
* schema.
|
|
172
173
|
*/
|
|
173
|
-
export declare const fromProvenance: (convexFunctionName: string, provenance: FunctionProvenance.AnyConfect, middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>, functionReference?: ConvexFunctionReference<any, any>, functionType?: "query" | "mutation" | "action") => AnyConfect;
|
|
174
|
+
export declare const fromProvenance: (convexFunctionName: string, provenance: FunctionProvenance.AnyConfect, middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>, functionReference?: ConvexFunctionReference<any, any>, functionType?: "query" | "mutation" | "action", reservedArgument?: string) => AnyConfect;
|
|
174
175
|
export declare const getConvexFunctionName: (ref: Any) => string;
|
|
175
176
|
export declare const getFunctionReference: <Ref_ extends Any>(ref: Ref_) => FunctionReference<Ref_>;
|
|
176
177
|
/**
|
package/dist/Ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../src/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,IAAI,uBAAuB,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;;GAMG;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
|
@@ -44,7 +44,7 @@ const make = (convexFunctionNamespace, functionSpec, groupMiddlewareAttachments
|
|
|
44
44
|
_tag: "Convex",
|
|
45
45
|
functionType: functionSpec.runtimeAndFunctionType.functionType,
|
|
46
46
|
convexFunctionName
|
|
47
|
-
})), Match.tag("Confect", (provenance) => fromProvenance(convexFunctionName, provenance, [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments], void 0, functionSpec.runtimeAndFunctionType.functionType)), Match.exhaustive);
|
|
47
|
+
})), Match.tag("Confect", (provenance) => fromProvenance(convexFunctionName, provenance, [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments], void 0, functionSpec.runtimeAndFunctionType.functionType, functionSpec.reservedArgument)), Match.exhaustive);
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* Build a Confect ref that runs with `provenance`'s codecs. Pass
|
|
@@ -53,12 +53,13 @@ const make = (convexFunctionNamespace, functionSpec, groupMiddlewareAttachments
|
|
|
53
53
|
* and `error` from the provenance on first use, so building it forces no
|
|
54
54
|
* schema.
|
|
55
55
|
*/
|
|
56
|
-
const fromProvenance = (convexFunctionName, provenance, middlewareAttachments, functionReference, functionType) => {
|
|
56
|
+
const fromProvenance = (convexFunctionName, provenance, middlewareAttachments, functionReference, functionType, reservedArgument) => {
|
|
57
57
|
const ref = {
|
|
58
58
|
[TypeId]: TypeId,
|
|
59
59
|
_tag: "Confect",
|
|
60
60
|
...functionType === void 0 ? {} : { functionType },
|
|
61
61
|
convexFunctionName,
|
|
62
|
+
...reservedArgument === void 0 ? {} : { reservedArgument },
|
|
62
63
|
...functionReference === void 0 ? {} : { functionReference },
|
|
63
64
|
kind: provenance.kind,
|
|
64
65
|
middlewareAttachments,
|
package/dist/Ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { getFunctionAddress, 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 Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Ref\";\nexport type TypeId = typeof TypeId;\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 [TypeId]: TypeId;\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n // Concrete call inputs must not narrow across assignments. Erased refs and\n // pagination constraints use index signatures and keep their broad variance.\n readonly \"~ArgsVariance\"?: string extends keyof Args_\n ? unknown\n : (args: Args_) => void;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly functionType?: RuntimeAndFunctionType_[\"functionType\"];\n readonly convexFunctionName: string;\n /**\n * Preserved for component references and function handles, which have no\n * local name.\n */\n readonly functionReference?: ConvexFunctionReference<any, any>;\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 errors.\n * 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 MiddlewareEncodedError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_,\n ReturnsSchema_,\n ErrorSchema_,\n ErrorSchema_[\"Encoded\"] | MiddlewareEncodedError_\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 the\n * same values from its fields and schemas.\n *\n * The codecs keep their own types so that a ref's wire encoding stays visible\n * to type-level checks, and `~EncodedError` carries the wire form of every\n * error the function can fail with, middleware included. A ref built from value\n * types alone (`Ref`) has no codecs to keep and erases them.\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 ReturnsSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n EncodedError_ = any,\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: ReturnsSchema_;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: ErrorSchema_;\n readonly \"~EncodedError\": EncodedError_;\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\n/**\n * A ref's call contract without a visibility requirement. Use this for handlers\n * shared by a component's public ref and its host's internal binding. Args,\n * returns, errors, runtime and function kind remain constrained.\n */\nexport type Callable<Ref_ extends Any> = Ref<\n GetRuntimeAndFunctionType<Ref_>,\n FunctionVisibility,\n Args<Ref_>,\n Returns<Ref_>,\n Error<Ref_>\n>;\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/**\n * Recognizes references by their runtime type identity.\n */\nexport const isRef = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\n/**\n * Erased Confect-provenance ref used by provenance-specific APIs.\n */\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/**\n * The field map captured by a Confect-provenance ref.\n */\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/**\n * The assembled args schema carried by a Confect-provenance ref.\n */\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\n/**\n * The returns codec carried by a Confect-provenance ref.\n */\nexport type ReturnsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n}\n ? ReturnsSchema_\n : never;\n\n/**\n * The wire form of every error a ref can fail with: its function's declared\n * error and its middleware's errors.\n */\nexport type EncodedError<Ref_> = Ref_ extends {\n readonly \"~EncodedError\": infer EncodedError_;\n}\n ? EncodedError_\n : never;\n\n/**\n * The function's own error codec carried by a Confect-provenance ref; errors\n * contributed by middleware are not part of it.\n */\nexport type ErrorSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n}\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\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\n/**\n * The ref type of a function spec. Errors from middleware attached to the\n * function are included; pass the errors of middleware attached to its groups\n * as `MiddlewareError` and `MiddlewareEncodedError`.\n */\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n MiddlewareEncodedError = 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_>\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareError,\n FunctionSpec.ReturnsSchema<FunctionSpec_>,\n FunctionSpec.ErrorSchema<FunctionSpec_>,\n | FunctionSpec.EncodedError<FunctionSpec_>\n | MiddlewareSpec.EncodedError<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareEncodedError\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 ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any>,\n EncodedError_,\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 ReturnsSchema_,\n ErrorSchema_,\n EncodedError_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n>(\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<\n MiddlewareAttachment.MiddlewareAttachment<GroupMiddlewareSpec_>\n > = [],\n): FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n [TypeId]: TypeId,\n _tag: \"Convex\",\n functionType: functionSpec.runtimeAndFunctionType.functionType,\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any =>\n fromProvenance(\n convexFunctionName,\n provenance,\n [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments],\n undefined,\n functionSpec.runtimeAndFunctionType.functionType,\n ),\n ),\n Match.exhaustive,\n ) as FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n >;\n};\n\n/**\n * Build a Confect ref that runs with `provenance`'s codecs. Pass\n * `functionReference` when the function has no local name: an installed\n * component's function or a function handle. The ref reads `args`, `returns`\n * and `error` from the provenance on first use, so building it forces no\n * schema.\n */\nexport const fromProvenance = (\n convexFunctionName: string,\n provenance: FunctionProvenance.AnyConfect,\n middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n functionReference?: ConvexFunctionReference<any, any>,\n functionType?: \"query\" | \"mutation\" | \"action\",\n): AnyConfect => {\n const ref = {\n [TypeId]: TypeId as TypeId,\n _tag: \"Confect\" as const,\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName,\n ...(functionReference === undefined ? {} : { functionReference }),\n kind: provenance.kind,\n middlewareAttachments,\n get middlewareSpecs() {\n return 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 AnyConfect;\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 if (ref.functionReference !== undefined) {\n return ref.functionReference as FunctionReference<Ref_>;\n }\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\n/**\n * Adapt a native reference without assigning Confect codecs or typed errors.\n */\nexport const fromFunctionReference = <\n Type extends \"query\" | \"mutation\" | \"action\",\n Visibility extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n>(\n functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>,\n functionType?: NoInfer<Type>,\n): ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n> => {\n const address = getFunctionAddress(functionReference);\n return {\n [TypeId]: TypeId,\n _tag: \"Convex\",\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName:\n address.name ??\n address.reference ??\n address.functionHandle ??\n \"<external function>\",\n functionReference,\n } as ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n >;\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 outside\n * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter\n * callbacks for streamed subscriptions) to the same error semantics that\n * `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 declared\n * `error` schema unioned with its covering middlewares' error schemas. Returns\n * `None` if the ref declares no typed error at all (Confect ref without an\n * `error` schema and without failing middleware, or a Convex-provenance ref)—by\n * definition there's nothing to decode the value into, and the caller is\n * responsible for deciding what to do (typically: surface the original value as\n * 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` schema,\n * 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 those\n * never match a user-declared error schema. Callers pair this with a fallback\n * that surfaces the original error, so failing to decode must not throw—a\n * `ParseError` here would replace the real error with an opaque one and lose\n * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,\n * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this\n * module all throw on a parse failure, and this one deliberately 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\n * 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` (or\n * `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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,SAAS;;;;AAsJtB,MAAa,SAAS,UACpB,UAAU,YAAY,OAAO,MAAM;AAyPrC,MAAa,QASX,yBACA,cACA,6BAEI,CAAC,MAKF;CACH,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;GACE,SAAS;EACV,MAAM;EACN,cAAc,aAAa,uBAAuB;EAClD;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eACpB,eACE,oBACA,YACA,CAAC,GAAG,4BAA4B,GAAG,aAAa,qBAAqB,GACrE,KAAA,GACA,aAAa,uBAAuB,YACtC,CACF,GACA,MAAM,UACR;AAKF;;;;;;;;AASA,MAAa,kBACX,oBACA,YACA,uBACA,mBACA,iBACe;CACf,MAAM,MAAM;GACT,SAAS;EACV,MAAM;EACN,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACrD;EACA,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;EAC/D,MAAM,WAAW;EACjB;EACA,IAAI,kBAAkB;GACpB,OAAO,sBAAsB,KAAK,EAAE,WAAW,IAAI;EACrD;CACF;CAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;CACtD,eAAoB,KAAK,iBAAiB,WAAW,OAAO;CAC5D,IAAI,WAAW,YACb,eAAoB,KAAK,eAAe,WAAW,KAAK;CAG1D,OAAO;AACT;AAEA,MAAa,yBAAyB,QACpC,IAAI;AAEN,MAAM,yCAAyB,IAAI,IAAoC;AAEvE,MAAa,wBACX,QAC4B;CAC5B,IAAI,I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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.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { getFunctionAddress, 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 Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Ref\";\nexport type TypeId = typeof TypeId;\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 [TypeId]: TypeId;\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n // Concrete call inputs must not narrow across assignments. Erased refs and\n // pagination constraints use index signatures and keep their broad variance.\n readonly \"~ArgsVariance\"?: string extends keyof Args_\n ? unknown\n : (args: Args_) => void;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly functionType?: RuntimeAndFunctionType_[\"functionType\"];\n readonly convexFunctionName: string;\n readonly reservedArgument?: string;\n /**\n * Preserved for component references and function handles, which have no\n * local name.\n */\n readonly functionReference?: ConvexFunctionReference<any, any>;\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 errors.\n * 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 MiddlewareEncodedError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_,\n ReturnsSchema_,\n ErrorSchema_,\n ErrorSchema_[\"Encoded\"] | MiddlewareEncodedError_\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 the\n * same values from its fields and schemas.\n *\n * The codecs keep their own types so that a ref's wire encoding stays visible\n * to type-level checks, and `~EncodedError` carries the wire form of every\n * error the function can fail with, middleware included. A ref built from value\n * types alone (`Ref`) has no codecs to keep and erases them.\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 ReturnsSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n EncodedError_ = any,\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: ReturnsSchema_;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: ErrorSchema_;\n readonly \"~EncodedError\": EncodedError_;\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\n/**\n * A ref's call contract without a visibility requirement. Use this for handlers\n * shared by a component's public ref and its host's internal binding. Args,\n * returns, errors, runtime and function kind remain constrained.\n */\nexport type Callable<Ref_ extends Any> = Ref<\n GetRuntimeAndFunctionType<Ref_>,\n FunctionVisibility,\n Args<Ref_>,\n Returns<Ref_>,\n Error<Ref_>\n>;\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/**\n * Recognizes references by their runtime type identity.\n */\nexport const isRef = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\n/**\n * Erased Confect-provenance ref used by provenance-specific APIs.\n */\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/**\n * The field map captured by a Confect-provenance ref.\n */\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/**\n * The assembled args schema carried by a Confect-provenance ref.\n */\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\n/**\n * The returns codec carried by a Confect-provenance ref.\n */\nexport type ReturnsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n}\n ? ReturnsSchema_\n : never;\n\n/**\n * The wire form of every error a ref can fail with: its function's declared\n * error and its middleware's errors.\n */\nexport type EncodedError<Ref_> = Ref_ extends {\n readonly \"~EncodedError\": infer EncodedError_;\n}\n ? EncodedError_\n : never;\n\n/**\n * The function's own error codec carried by a Confect-provenance ref; errors\n * contributed by middleware are not part of it.\n */\nexport type ErrorSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n}\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\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\n/**\n * The ref type of a function spec. Errors from middleware attached to the\n * function are included; pass the errors of middleware attached to its groups\n * as `MiddlewareError` and `MiddlewareEncodedError`.\n */\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n MiddlewareEncodedError = 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_>\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareError,\n FunctionSpec.ReturnsSchema<FunctionSpec_>,\n FunctionSpec.ErrorSchema<FunctionSpec_>,\n | FunctionSpec.EncodedError<FunctionSpec_>\n | MiddlewareSpec.EncodedError<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareEncodedError\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 ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any>,\n EncodedError_,\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 ReturnsSchema_,\n ErrorSchema_,\n EncodedError_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n>(\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<\n MiddlewareAttachment.MiddlewareAttachment<GroupMiddlewareSpec_>\n > = [],\n): FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n [TypeId]: TypeId,\n _tag: \"Convex\",\n functionType: functionSpec.runtimeAndFunctionType.functionType,\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any =>\n fromProvenance(\n convexFunctionName,\n provenance,\n [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments],\n undefined,\n functionSpec.runtimeAndFunctionType.functionType,\n functionSpec.reservedArgument,\n ),\n ),\n Match.exhaustive,\n ) as FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n >;\n};\n\n/**\n * Build a Confect ref that runs with `provenance`'s codecs. Pass\n * `functionReference` when the function has no local name: an installed\n * component's function or a function handle. The ref reads `args`, `returns`\n * and `error` from the provenance on first use, so building it forces no\n * schema.\n */\nexport const fromProvenance = (\n convexFunctionName: string,\n provenance: FunctionProvenance.AnyConfect,\n middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n functionReference?: ConvexFunctionReference<any, any>,\n functionType?: \"query\" | \"mutation\" | \"action\",\n reservedArgument?: string,\n): AnyConfect => {\n const ref = {\n [TypeId]: TypeId as TypeId,\n _tag: \"Confect\" as const,\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName,\n ...(reservedArgument === undefined ? {} : { reservedArgument }),\n ...(functionReference === undefined ? {} : { functionReference }),\n kind: provenance.kind,\n middlewareAttachments,\n get middlewareSpecs() {\n return 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 AnyConfect;\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 if (ref.functionReference !== undefined) {\n return ref.functionReference as FunctionReference<Ref_>;\n }\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\n/**\n * Adapt a native reference without assigning Confect codecs or typed errors.\n */\nexport const fromFunctionReference = <\n Type extends \"query\" | \"mutation\" | \"action\",\n Visibility extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n>(\n functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>,\n functionType?: NoInfer<Type>,\n): ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n> => {\n const address = getFunctionAddress(functionReference);\n return {\n [TypeId]: TypeId,\n _tag: \"Convex\",\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName:\n address.name ??\n address.reference ??\n address.functionHandle ??\n \"<external function>\",\n functionReference,\n } as ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n >;\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 outside\n * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter\n * callbacks for streamed subscriptions) to the same error semantics that\n * `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 declared\n * `error` schema unioned with its covering middlewares' error schemas. Returns\n * `None` if the ref declares no typed error at all (Confect ref without an\n * `error` schema and without failing middleware, or a Convex-provenance ref)—by\n * definition there's nothing to decode the value into, and the caller is\n * responsible for deciding what to do (typically: surface the original value as\n * 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` schema,\n * 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 those\n * never match a user-declared error schema. Callers pair this with a fallback\n * that surfaces the original error, so failing to decode must not throw—a\n * `ParseError` here would replace the real error with an opaque one and lose\n * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,\n * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this\n * module all throw on a parse failure, and this one deliberately 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\n * 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` (or\n * `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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,SAAS;;;;AAuJtB,MAAa,SAAS,UACpB,UAAU,YAAY,OAAO,MAAM;AAyPrC,MAAa,QASX,yBACA,cACA,6BAEI,CAAC,MAKF;CACH,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;GACE,SAAS;EACV,MAAM;EACN,cAAc,aAAa,uBAAuB;EAClD;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eACpB,eACE,oBACA,YACA,CAAC,GAAG,4BAA4B,GAAG,aAAa,qBAAqB,GACrE,KAAA,GACA,aAAa,uBAAuB,cACpC,aAAa,gBACf,CACF,GACA,MAAM,UACR;AAKF;;;;;;;;AASA,MAAa,kBACX,oBACA,YACA,uBACA,mBACA,cACA,qBACe;CACf,MAAM,MAAM;GACT,SAAS;EACV,MAAM;EACN,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACrD;EACA,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;EAC7D,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;EAC/D,MAAM,WAAW;EACjB;EACA,IAAI,kBAAkB;GACpB,OAAO,sBAAsB,KAAK,EAAE,WAAW,IAAI;EACrD;CACF;CAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;CACtD,eAAoB,KA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Ac,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CACtE,GACA,MAAM,IAAI,gBAAgB,WAAW,GACrC,MAAM,UACR;;;;;;;;;AAUF,MAAa,eAAe,OAAO,WAAW,WAI5C,KACA,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"}
|
|
@@ -4,7 +4,16 @@ import * as Effect from "effect/Effect";
|
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as SchemaAST from "effect/SchemaAST";
|
|
6
6
|
import type { IsAny, IsOptional, IsRecord, IsRecursive, IsUnion, TypeError, UnionToTuple } from "./Types.js";
|
|
7
|
-
export declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Codec<ConfectValue, ConvexValue>, scope?: IdScope.IdScope) => PropertyValidators;
|
|
7
|
+
export declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Codec<ConfectValue, ConvexValue>, scope?: IdScope.IdScope, reservedArgument?: string, functionName?: string) => PropertyValidators;
|
|
8
|
+
declare const ReservedArgumentCollision_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
9
|
+
readonly _tag: "ReservedArgumentCollision";
|
|
10
|
+
} & Readonly<A>;
|
|
11
|
+
export declare class ReservedArgumentCollision extends ReservedArgumentCollision_base<{
|
|
12
|
+
readonly functionName: string | undefined;
|
|
13
|
+
readonly argument: string;
|
|
14
|
+
}> {
|
|
15
|
+
get message(): string;
|
|
16
|
+
}
|
|
8
17
|
export declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: Schema.Codec<ConfectValue, ConvexValue>, scope?: IdScope.IdScope) => Validator<any, any, any>;
|
|
9
18
|
/**
|
|
10
19
|
* Convert a table `Schema` to a table `Validator`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.d.ts","sourceRoot":"","sources":["../src/SchemaToValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EACV,SAAS,IAAI,eAAe,EAC5B,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACP,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAI9C,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACb,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,iBAAiB,GAAI,YAAY,EAAE,WAAW,cAC7C,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,UAC5C,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaToValidator.d.ts","sourceRoot":"","sources":["../src/SchemaToValidator.ts"],"names":[],"mappings":"AA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21
|
MixedIndexAndPropertySignaturesAreNotSupportedError: () => MixedIndexAndPropertySignaturesAreNotSupportedError,
|
|
22
22
|
OptionalTupleElementsAreNotSupportedError: () => OptionalTupleElementsAreNotSupportedError,
|
|
23
|
+
ReservedArgumentCollision: () => ReservedArgumentCollision,
|
|
23
24
|
TopLevelMustBeObjectError: () => TopLevelMustBeObjectError,
|
|
24
25
|
TopLevelMustBeObjectOrUnionError: () => TopLevelMustBeObjectOrUnionError,
|
|
25
26
|
UnsupportedPropertySignatureKeyTypeError: () => UnsupportedPropertySignatureKeyTypeError,
|
|
@@ -31,9 +32,23 @@ var SchemaToValidator_exports = /* @__PURE__ */ __exportAll({
|
|
|
31
32
|
compileTableSchema: () => compileTableSchema,
|
|
32
33
|
isRecursive: () => isRecursive
|
|
33
34
|
});
|
|
34
|
-
const compileArgsSchema = (argsSchema, scope = app) => {
|
|
35
|
+
const compileArgsSchema = (argsSchema, scope = app, reservedArgument, functionName) => {
|
|
35
36
|
const ast = Schema.toEncoded(argsSchema).ast;
|
|
36
|
-
|
|
37
|
+
const validators = pipe(ast, Match.value, Match.tag("Objects", (objectsAst) => Array.isReadonlyArrayEmpty(objectsAst.indexSignatures) ? handlePropertySignatures(objectsAst, scope) : Effect.fail(new IndexSignaturesAreNotSupportedError())), Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())), Effect.runSync);
|
|
38
|
+
if (reservedArgument === void 0) return validators;
|
|
39
|
+
if (Object.hasOwn(validators, reservedArgument)) throw new ReservedArgumentCollision({
|
|
40
|
+
functionName,
|
|
41
|
+
argument: reservedArgument
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
...validators,
|
|
45
|
+
[reservedArgument]: v.optional(v.any())
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var ReservedArgumentCollision = class extends Data.TaggedError("ReservedArgumentCollision") {
|
|
49
|
+
get message() {
|
|
50
|
+
return `${this.functionName} declares the argument "${this.argument}", which its profile reserves. Rename the argument.`;
|
|
51
|
+
}
|
|
37
52
|
};
|
|
38
53
|
const compileReturnsSchema = (schema, scope = app) => Effect.runSync(compileAst(Schema.toEncoded(schema).ast, false, scope));
|
|
39
54
|
const compileTableSchema = (schema, scope = app) => {
|
|
@@ -154,6 +169,6 @@ var OptionalTupleElementsAreNotSupportedError = class extends Data.TaggedError("
|
|
|
154
169
|
}
|
|
155
170
|
};
|
|
156
171
|
//#endregion
|
|
157
|
-
export { EmptyTupleIsNotSupportedError, EmptyUnionIsNotSupportedError, IndexSignaturesAreNotSupportedError, MixedIndexAndPropertySignaturesAreNotSupportedError, OptionalTupleElementsAreNotSupportedError, SchemaToValidator_exports, TopLevelMustBeObjectError, TopLevelMustBeObjectOrUnionError, UnsupportedPropertySignatureKeyTypeError, UnsupportedSchemaTypeError, compileArgsSchema, compileAst, compileReturnsSchema, compileSchema, compileTableSchema, isRecursive };
|
|
172
|
+
export { EmptyTupleIsNotSupportedError, EmptyUnionIsNotSupportedError, IndexSignaturesAreNotSupportedError, MixedIndexAndPropertySignaturesAreNotSupportedError, OptionalTupleElementsAreNotSupportedError, ReservedArgumentCollision, SchemaToValidator_exports, TopLevelMustBeObjectError, TopLevelMustBeObjectOrUnionError, UnsupportedPropertySignatureKeyTypeError, UnsupportedSchemaTypeError, compileArgsSchema, compileAst, compileReturnsSchema, compileSchema, compileTableSchema, isRecursive };
|
|
158
173
|
|
|
159
174
|
//# sourceMappingURL=SchemaToValidator.js.map
|