@gaganref/confect-core 10.3.1-fork.3 → 10.3.1-fork.5
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/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +2 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.d.ts +3 -3
- package/dist/Callback.d.ts.map +1 -1
- package/dist/Callback.js.map +1 -1
- package/dist/Component.d.ts +8 -8
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js.map +1 -1
- package/dist/FunctionProvenance.d.ts +2 -2
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +4 -4
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +2 -2
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +1 -1
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupPath.js.map +1 -1
- package/dist/GroupSpec.d.ts +4 -4
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Http.d.ts +1 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js.map +1 -1
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +1 -1
- package/dist/MiddlewareAttachment.d.ts.map +1 -1
- package/dist/MiddlewareAttachment.js.map +1 -1
- package/dist/MiddlewareSpec.d.ts +3 -3
- package/dist/MiddlewareSpec.d.ts.map +1 -1
- package/dist/MiddlewareSpec.js.map +1 -1
- package/dist/Ref.d.ts +5 -5
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +5 -5
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +2 -2
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Spec.d.ts +1 -1
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +2 -2
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.d.ts +3 -3
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.ts +1 -1
- package/src/Auth.ts +2 -2
- package/src/Callback.ts +3 -3
- package/src/Component.ts +11 -11
- package/src/FunctionProvenance.ts +3 -3
- package/src/FunctionSpec.ts +5 -5
- package/src/GenericId.ts +2 -2
- package/src/GroupPath.ts +1 -1
- package/src/GroupSpec.ts +5 -5
- package/src/Http.ts +1 -1
- package/src/Manifest.ts +1 -1
- package/src/MiddlewareAttachment.ts +1 -1
- package/src/MiddlewareSpec.ts +4 -4
- package/src/Ref.ts +6 -6
- package/src/Refs.ts +5 -5
- package/src/SchemaToValidator.ts +3 -3
- package/src/Spec.ts +1 -1
- package/src/SystemFields.ts +2 -2
- package/src/Table.ts +4 -4
- package/src/index.ts +29 -29
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","FunctionProvenance.Convex"],"sources":["../src/FunctionSpec.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport type {\n DefaultFunctionArgs,\n FunctionType,\n FunctionVisibility,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n} from \"convex/server\";\nimport type * as Schema from \"effect/Schema\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as FunctionProvenance from \"./FunctionProvenance\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\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 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\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 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 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 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 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({ name, args, returns, error }: Options) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\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 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 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 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({ name, args, item, error }: PaginatedOptions) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAG,MAAM;AA8QjC,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,K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a,gBAAgB,KAC3BA,aACA,UACF;AACA,MAAa,uBAAuB,cAClCA,aACA,QACF;AACA,MAAa,yBAAyB,cACpCA,aACA,UACF;AACA,MAAa,iBAAiB,KAC5BC,gBACA,QACF;AACA,MAAa,mBAAmB,KAC9BA,gBACA,UACF;AACA,MAAa,eAAe,KAAKC,cAAqC,QAAQ;AAC9E,MAAa,iBAAiB,KAC5BA,cACA,UACF;AAEA,MAAa,mBAAmB,KAC9BC,YACA,QACF;AACA,MAAa,qBAAqB,KAChCA,YACA,UACF;AAwCA,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/BJ,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","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 type * as Schema from \"effect/Schema\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.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 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\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 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 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 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 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({ name, args, returns, error }: Options) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\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 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 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 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({ name, args, item, error }: PaginatedOptions) {\n validateConfectFunctionIdentifier(name);\n\n return Object.assign(Object.create(Proto), {\n runtimeAndFunctionType,\n functionVisibility,\n name,\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAG,MAAM;AA8QjC,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,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BACA,QACF;AACA,MAAa,mBAAmB,KAC9BA,gBACA,UACF;AACA,MAAa,eAAe,KAAKC,cAAqC,QAAQ;AAC9E,MAAa,iBAAiB,KAC5BA,cACA,UACF;AAEA,MAAa,mBAAmB,KAC9BC,YACA,QACF;AACA,MAAa,qBAAqB,KAChCA,YACA,UACF;AAwCA,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/BJ,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"}
|
package/dist/GenericId.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { GenericId as ConvexGenericId } from "convex/values";
|
|
|
2
2
|
import * as Option from "effect/Option";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
import * as SchemaAST from "effect/SchemaAST";
|
|
5
|
-
import * as IdScope from "./IdScope";
|
|
6
|
-
import type * as Ref from "./Ref";
|
|
5
|
+
import * as IdScope from "./IdScope.js";
|
|
6
|
+
import type * as Ref from "./Ref.js";
|
|
7
7
|
/**
|
|
8
8
|
* Scoping changes only the TypeScript identity, never the stored string. The
|
|
9
9
|
* qualified table brand prevents a component ID from also being assignable to a
|
package/dist/GenericId.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericId.d.ts","sourceRoot":"","sources":["../src/GenericId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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O,UAExB,OAAO,QACT,IAAI,MACN,EAAE,KACL,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAoKhC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,MAAM,OAC3C,SAAS,CAAC,GAAG,KACjB,MAAM,CAAC,MAAM,CAAC,SAAS,CAC2C,CAAC"}
|
package/dist/GenericId.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericId.js","names":["IdScope.app"],"sources":["../src/GenericId.ts"],"sourcesContent":["import type { GenericId as ConvexGenericId } from \"convex/values\";\nimport * as Array from \"effect/Array\";\nimport { memoize } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as IdScope from \"./IdScope\";\nimport type * as Ref from \"./Ref\";\n\nconst ConvexId = \"~@confect/core/ConvexId\";\nconst ConvexIdScope = \"~@confect/core/ConvexIdScope\";\n\n/**\n * Scoping changes only the TypeScript identity, never the stored string. The\n * qualified table brand prevents a component ID from also being assignable to a\n * vanilla application ID with the same table name.\n */\nexport type GenericId<\n TableName extends string,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? ConvexGenericId<TableName>\n : ConvexGenericId<`@confect(${Scope})/${TableName}`> & {\n readonly \"~@confect/core/ScopedId\": {\n readonly table: TableName;\n readonly scope: Scope;\n };\n };\n\nexport const GenericId = <\n TableName extends string,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n scope?: Scope,\n): Schema.Codec<GenericId<TableName, Scope>> =>\n Schema.String.annotate({\n [ConvexId]: tableName,\n [ConvexIdScope]: scope ?? IdScope.app,\n }) as unknown as Schema.Codec<GenericId<TableName, Scope>>;\n\nexport const scope = (ast: SchemaAST.AST): IdScope.IdScope =>\n SchemaAST.resolveAt<IdScope.IdScope>(ConvexIdScope)(ast) ?? IdScope.app;\n\n/**\n * Rebind only IDs owned by `From`; IDs belonging to other scopes survive. A ref\n * (such as a callback handle) names a function, not scoped data, so it passes\n * through unchanged.\n */\nexport type Rebase<\n A,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RebaseValue<A, From, To, true>;\n\n// Compare against a purely structural mapping. Comparing a recursive object\n// against its nominal-preserving mapping makes the compatibility check circular.\ntype RebaseValue<\n A,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n PreserveIdentity extends boolean,\n> = A extends { readonly [Ref.TypeId]: Ref.TypeId }\n ? A\n : A extends {\n readonly \"~@confect/core/ScopedId\": {\n readonly table: infer Table extends string;\n readonly scope: infer Scope extends IdScope.IdScope;\n };\n }\n ? GenericId<Table, IdScope.Rebase<Scope, From, To>>\n : A extends ConvexGenericId<infer Table>\n ? From extends IdScope.App\n ? GenericId<Table, To>\n : A\n : A extends\n | string\n | number\n | boolean\n | bigint\n | symbol\n | null\n | undefined\n | Date\n | URL\n | ArrayBuffer\n | RegExp\n | ((...args: never[]) => unknown)\n ? A\n : A extends Map<infer Key, infer Value>\n ? Map<\n RebaseValue<Key, From, To, PreserveIdentity>,\n RebaseValue<Value, From, To, PreserveIdentity>\n >\n : A extends ReadonlyMap<infer Key, infer Value>\n ? ReadonlyMap<\n RebaseValue<Key, From, To, PreserveIdentity>,\n RebaseValue<Value, From, To, PreserveIdentity>\n >\n : A extends Set<infer Value>\n ? Set<RebaseValue<Value, From, To, PreserveIdentity>>\n : A extends ReadonlySet<infer Value>\n ? ReadonlySet<RebaseValue<Value, From, To, PreserveIdentity>>\n : A extends object\n ? {\n [K in keyof A]: RebaseValue<\n A[K],\n From,\n To,\n PreserveIdentity\n >;\n } & (PreserveIdentity extends true\n ? A extends RebaseValue<A, From, To, false>\n ? A\n : unknown\n : unknown)\n : A;\n\n/**\n * Preserve Structs and field maps while rebinding their value types. Other\n * specialised schema members are not promised by the resulting codec.\n */\nexport type RebaseSchema<\n S extends Schema.Constraint,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> =\n S extends Schema.Struct<infer Fields>\n ? Schema.Struct<{ [K in keyof Fields]: RebaseSchema<Fields[K], From, To> }>\n : Schema.Codec<\n Rebase<S[\"Type\"], From, To>,\n Rebase<S[\"Encoded\"], From, To>,\n S[\"DecodingServices\"],\n S[\"EncodingServices\"]\n > &\n Pick<\n S,\n | \"~type.optionality\"\n | \"~encoded.optionality\"\n | \"~type.mutability\"\n | \"~encoded.mutability\"\n | \"~type.constructor.default\"\n > & {\n readonly \"~type.make.in\": Rebase<S[\"~type.make.in\"], From, To>;\n readonly \"~type.make\": Rebase<S[\"~type.make\"], From, To>;\n readonly Iso: Rebase<S[\"Iso\"], From, To>;\n } & (S extends {\n readonly fields: infer Fields extends Schema.Struct.Fields;\n }\n ? {\n readonly fields: {\n [K in keyof Fields]: RebaseSchema<Fields[K], From, To>;\n };\n }\n : unknown);\n\n/**\n * Scope annotations belong to both sides of a codec. Keep its transformations,\n * checks, optional fields and declaration parsers intact while rebinding IDs.\n */\nexport const rebase = <\n Schema_ extends Schema.ConstraintCodec<any, any, never, never>,\n const From extends IdScope.IdScope,\n const To extends IdScope.IdScope,\n>(\n schema: Schema_,\n from: From,\n to: To,\n): RebaseSchema<Schema_, From, To> => {\n const visit = memoize((ast: SchemaAST.AST): SchemaAST.AST => {\n // Suspended schemas must retain a lazy rebinding thunk even before it runs.\n let changed = SchemaAST.isSuspend(ast);\n const child = (input: SchemaAST.AST): SchemaAST.AST => {\n const next = visit(input);\n if (next !== input) changed = true;\n return next;\n };\n const next = Match.value(ast).pipe(\n Match.tag(\n \"Objects\",\n (objects) =>\n new SchemaAST.Objects(\n Array.map(\n objects.propertySignatures,\n (property) =>\n new SchemaAST.PropertySignature(\n property.name,\n child(property.type),\n ),\n ),\n Array.map(\n objects.indexSignatures,\n (index) =>\n new SchemaAST.IndexSignature(\n child(index.parameter),\n child(index.type),\n ),\n ),\n objects.annotations,\n objects.checks,\n undefined,\n objects.context,\n objects.encodingChecks,\n ),\n ),\n Match.tag(\n \"Arrays\",\n (arrays) =>\n new SchemaAST.Arrays(\n arrays.isMutable,\n Array.map(arrays.elements, child),\n Array.map(arrays.rest, child),\n arrays.annotations,\n arrays.checks,\n undefined,\n arrays.context,\n arrays.encodingChecks,\n ),\n ),\n Match.tag(\n \"Union\",\n (union) =>\n new SchemaAST.Union(\n Array.map(union.types, child),\n union.options,\n union.annotations,\n union.checks,\n undefined,\n union.context,\n union.encodingChecks,\n ),\n ),\n Match.tag(\n \"Suspend\",\n (suspend) =>\n new SchemaAST.Suspend(\n () => visit(suspend.thunk()),\n suspend.annotations,\n suspend.checks,\n undefined,\n suspend.context,\n ),\n ),\n Match.tag(\n \"Declaration\",\n (declaration) =>\n new SchemaAST.Declaration(\n Array.map(declaration.typeParameters, child),\n declaration.run,\n declaration.annotations,\n declaration.checks,\n undefined,\n declaration.context,\n declaration.encodingChecks,\n declaration.encodingRun,\n ),\n ),\n Match.tag(\n \"Null\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Unknown\",\n \"Any\",\n \"String\",\n \"Number\",\n \"Boolean\",\n \"BigInt\",\n \"Symbol\",\n \"Literal\",\n \"UniqueSymbol\",\n \"ObjectKeyword\",\n \"Enum\",\n \"TemplateLiteral\",\n (leaf) => leaf,\n ),\n Match.exhaustive,\n );\n const ownScope = scope(ast);\n const scoped =\n Option.isSome(tableName(ast)) &&\n (ownScope === from || ownScope.startsWith(`${from}/instance:`))\n ? Schema.make<Schema.Codec<unknown>>(next).annotate({\n [ConvexIdScope]: to + ownScope.slice(from.length),\n }).ast\n : next;\n if (ast.encoding === undefined) {\n return changed || scoped !== next ? scoped : ast;\n }\n const encoding = Array.map(ast.encoding, (link) => {\n const target = child(link.to);\n return target === link.to\n ? link\n : new SchemaAST.Link(target, link.transformation);\n });\n if (!changed && scoped === next) return ast;\n // Effect's replaceEncoding helper is internal and omitted from its published\n // declarations. Preserve AST prototypes and descriptors at this boundary;\n // spreading the node itself would lose its class behavior.\n return Object.create(Object.getPrototypeOf(scoped), {\n ...Object.getOwnPropertyDescriptors(scoped),\n encoding: {\n value: encoding,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n }) as SchemaAST.AST;\n });\n const rebuild = memoize((input: Schema.Constraint): Schema.Constraint => {\n const ast = visit(input.ast);\n if (ast === input.ast) return input;\n if (\"fields\" in input) {\n const fields = (input as { readonly fields: Schema.Struct.Fields })\n .fields;\n const reboundFields = Object.fromEntries(\n Reflect.ownKeys(fields).map((key) => [key, rebuild(fields[key]!)]),\n );\n if (\n ast.encoding === undefined &&\n SchemaAST.isObjects(ast) &&\n \"mapFields\" in input\n ) {\n return (input as Schema.Struct<Schema.Struct.Fields>)\n .mapFields(() => reboundFields, { unsafePreserveChecks: true })\n .rebuild(ast);\n }\n return Schema.make(ast, { fields: reboundFields });\n }\n return Schema.make(ast);\n });\n return rebuild(schema) as RebaseSchema<Schema_, From, To>;\n};\n\nexport const tableName = <TableName extends string>(\n ast: SchemaAST.AST,\n): Option.Option<TableName> =>\n Option.fromNullishOr(SchemaAST.resolveAt<TableName>(ConvexId)(ast));\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,WAAW;AACjB,MAAM,gBAAgB;AAmBtB,MAAa,aAIX,WACA,UAEA,OAAO,OAAO,SAAS;EACpB,WAAW;EACX,gBAAgB,SAASA;AAC5B,CAAC;AAEH,MAAa,SAAS,QACpB,UAAU,UAA2B,aAAa,CAAC,CAAC,GAAG,KAAKA;;;;;AAsH9D,MAAa,UAKX,QACA,MACA,OACoC;CACpC,MAAM,QAAQ,SAAS,QAAsC;EAE3D,IAAI,UAAU,UAAU,UAAU,GAAG;EACrC,MAAM,SAAS,UAAwC;GACrD,MAAM,OAAO,MAAM,KAAK;GACxB,IAAI,SAAS,OAAO,UAAU;GAC9B,OAAO;EACT;EACA,MAAM,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,KAC5B,MAAM,IACJ,YACC,YACC,IAAI,UAAU,QACZ,MAAM,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MAAM,KAAK,MAAM,EAClD,CAAC,CAAC,CAAC,MACH;EACN,IAAI,IAAI,aAAa,KAAA,GACnB,OAAO,WAAW,WAAW,OAAO,SAAS;EAE/C,MAAM,WAAW,MAAM,IAAI,IAAI,WAAW,SAAS;GACjD,MAAM,SAAS,MAAM,KAAK,EAAE;GAC5B,OAAO,WAAW,KAAK,KACnB,OACA,IAAI,UAAU,KAAK,QAAQ,KAAK,cAAc;EACpD,CAAC;EACD,IAAI,CAAC,WAAW,WAAW,MAAM,OAAO;EAIxC,OAAO,OAAO,OAAO,OAAO,eAAe,MAAM,GAAG;GAClD,GAAG,OAAO,0BAA0B,MAAM;GAC1C,UAAU;IACR,OAAO;IACP,YAAY;IACZ,cAAc;IACd,UAAU;GACZ;EACF,CAAC;CACH,CAAC;CACD,MAAM,UAAU,SAAS,UAAgD;EACvE,MAAM,MAAM,MAAM,MAAM,GAAG;EAC3B,IAAI,QAAQ,MAAM,KAAK,OAAO;EAC9B,IAAI,YAAY,OAAO;GACrB,MAAM,SAAU,MACb;GACH,MAAM,gBAAgB,OAAO,YAC3B,QAAQ,QAAQ,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,QAAQ,OAAO,IAAK,CAAC,CAAC,CACnE;GACA,IACE,IAAI,aAAa,KAAA,KACjB,UAAU,UAAU,GAAG,KACvB,eAAe,OAEf,OAAQ,MACL,gBAAgB,eAAe,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAC9D,QAAQ,GAAG;GAEhB,OAAO,OAAO,KAAK,KAAK,EAAE,QAAQ,cAAc,CAAC;EACnD;EACA,OAAO,OAAO,KAAK,GAAG;CACxB,CAAC;CACD,OAAO,QAAQ,MAAM;AACvB;AAEA,MAAa,aACX,QAEA,OAAO,cAAc,UAAU,UAAqB,QAAQ,CAAC,CAAC,GAAG,CAAC"}
|
|
1
|
+
{"version":3,"file":"GenericId.js","names":["IdScope.app"],"sources":["../src/GenericId.ts"],"sourcesContent":["import type { GenericId as ConvexGenericId } from \"convex/values\";\nimport * as Array from \"effect/Array\";\nimport { memoize } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as IdScope from \"./IdScope.js\";\nimport type * as Ref from \"./Ref.js\";\n\nconst ConvexId = \"~@confect/core/ConvexId\";\nconst ConvexIdScope = \"~@confect/core/ConvexIdScope\";\n\n/**\n * Scoping changes only the TypeScript identity, never the stored string. The\n * qualified table brand prevents a component ID from also being assignable to a\n * vanilla application ID with the same table name.\n */\nexport type GenericId<\n TableName extends string,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? ConvexGenericId<TableName>\n : ConvexGenericId<`@confect(${Scope})/${TableName}`> & {\n readonly \"~@confect/core/ScopedId\": {\n readonly table: TableName;\n readonly scope: Scope;\n };\n };\n\nexport const GenericId = <\n TableName extends string,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n scope?: Scope,\n): Schema.Codec<GenericId<TableName, Scope>> =>\n Schema.String.annotate({\n [ConvexId]: tableName,\n [ConvexIdScope]: scope ?? IdScope.app,\n }) as unknown as Schema.Codec<GenericId<TableName, Scope>>;\n\nexport const scope = (ast: SchemaAST.AST): IdScope.IdScope =>\n SchemaAST.resolveAt<IdScope.IdScope>(ConvexIdScope)(ast) ?? IdScope.app;\n\n/**\n * Rebind only IDs owned by `From`; IDs belonging to other scopes survive. A ref\n * (such as a callback handle) names a function, not scoped data, so it passes\n * through unchanged.\n */\nexport type Rebase<\n A,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RebaseValue<A, From, To, true>;\n\n// Compare against a purely structural mapping. Comparing a recursive object\n// against its nominal-preserving mapping makes the compatibility check circular.\ntype RebaseValue<\n A,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n PreserveIdentity extends boolean,\n> = A extends { readonly [Ref.TypeId]: Ref.TypeId }\n ? A\n : A extends {\n readonly \"~@confect/core/ScopedId\": {\n readonly table: infer Table extends string;\n readonly scope: infer Scope extends IdScope.IdScope;\n };\n }\n ? GenericId<Table, IdScope.Rebase<Scope, From, To>>\n : A extends ConvexGenericId<infer Table>\n ? From extends IdScope.App\n ? GenericId<Table, To>\n : A\n : A extends\n | string\n | number\n | boolean\n | bigint\n | symbol\n | null\n | undefined\n | Date\n | URL\n | ArrayBuffer\n | RegExp\n | ((...args: never[]) => unknown)\n ? A\n : A extends Map<infer Key, infer Value>\n ? Map<\n RebaseValue<Key, From, To, PreserveIdentity>,\n RebaseValue<Value, From, To, PreserveIdentity>\n >\n : A extends ReadonlyMap<infer Key, infer Value>\n ? ReadonlyMap<\n RebaseValue<Key, From, To, PreserveIdentity>,\n RebaseValue<Value, From, To, PreserveIdentity>\n >\n : A extends Set<infer Value>\n ? Set<RebaseValue<Value, From, To, PreserveIdentity>>\n : A extends ReadonlySet<infer Value>\n ? ReadonlySet<RebaseValue<Value, From, To, PreserveIdentity>>\n : A extends object\n ? {\n [K in keyof A]: RebaseValue<\n A[K],\n From,\n To,\n PreserveIdentity\n >;\n } & (PreserveIdentity extends true\n ? A extends RebaseValue<A, From, To, false>\n ? A\n : unknown\n : unknown)\n : A;\n\n/**\n * Preserve Structs and field maps while rebinding their value types. Other\n * specialised schema members are not promised by the resulting codec.\n */\nexport type RebaseSchema<\n S extends Schema.Constraint,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> =\n S extends Schema.Struct<infer Fields>\n ? Schema.Struct<{ [K in keyof Fields]: RebaseSchema<Fields[K], From, To> }>\n : Schema.Codec<\n Rebase<S[\"Type\"], From, To>,\n Rebase<S[\"Encoded\"], From, To>,\n S[\"DecodingServices\"],\n S[\"EncodingServices\"]\n > &\n Pick<\n S,\n | \"~type.optionality\"\n | \"~encoded.optionality\"\n | \"~type.mutability\"\n | \"~encoded.mutability\"\n | \"~type.constructor.default\"\n > & {\n readonly \"~type.make.in\": Rebase<S[\"~type.make.in\"], From, To>;\n readonly \"~type.make\": Rebase<S[\"~type.make\"], From, To>;\n readonly Iso: Rebase<S[\"Iso\"], From, To>;\n } & (S extends {\n readonly fields: infer Fields extends Schema.Struct.Fields;\n }\n ? {\n readonly fields: {\n [K in keyof Fields]: RebaseSchema<Fields[K], From, To>;\n };\n }\n : unknown);\n\n/**\n * Scope annotations belong to both sides of a codec. Keep its transformations,\n * checks, optional fields and declaration parsers intact while rebinding IDs.\n */\nexport const rebase = <\n Schema_ extends Schema.ConstraintCodec<any, any, never, never>,\n const From extends IdScope.IdScope,\n const To extends IdScope.IdScope,\n>(\n schema: Schema_,\n from: From,\n to: To,\n): RebaseSchema<Schema_, From, To> => {\n const visit = memoize((ast: SchemaAST.AST): SchemaAST.AST => {\n // Suspended schemas must retain a lazy rebinding thunk even before it runs.\n let changed = SchemaAST.isSuspend(ast);\n const child = (input: SchemaAST.AST): SchemaAST.AST => {\n const next = visit(input);\n if (next !== input) changed = true;\n return next;\n };\n const next = Match.value(ast).pipe(\n Match.tag(\n \"Objects\",\n (objects) =>\n new SchemaAST.Objects(\n Array.map(\n objects.propertySignatures,\n (property) =>\n new SchemaAST.PropertySignature(\n property.name,\n child(property.type),\n ),\n ),\n Array.map(\n objects.indexSignatures,\n (index) =>\n new SchemaAST.IndexSignature(\n child(index.parameter),\n child(index.type),\n ),\n ),\n objects.annotations,\n objects.checks,\n undefined,\n objects.context,\n objects.encodingChecks,\n ),\n ),\n Match.tag(\n \"Arrays\",\n (arrays) =>\n new SchemaAST.Arrays(\n arrays.isMutable,\n Array.map(arrays.elements, child),\n Array.map(arrays.rest, child),\n arrays.annotations,\n arrays.checks,\n undefined,\n arrays.context,\n arrays.encodingChecks,\n ),\n ),\n Match.tag(\n \"Union\",\n (union) =>\n new SchemaAST.Union(\n Array.map(union.types, child),\n union.options,\n union.annotations,\n union.checks,\n undefined,\n union.context,\n union.encodingChecks,\n ),\n ),\n Match.tag(\n \"Suspend\",\n (suspend) =>\n new SchemaAST.Suspend(\n () => visit(suspend.thunk()),\n suspend.annotations,\n suspend.checks,\n undefined,\n suspend.context,\n ),\n ),\n Match.tag(\n \"Declaration\",\n (declaration) =>\n new SchemaAST.Declaration(\n Array.map(declaration.typeParameters, child),\n declaration.run,\n declaration.annotations,\n declaration.checks,\n undefined,\n declaration.context,\n declaration.encodingChecks,\n declaration.encodingRun,\n ),\n ),\n Match.tag(\n \"Null\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Unknown\",\n \"Any\",\n \"String\",\n \"Number\",\n \"Boolean\",\n \"BigInt\",\n \"Symbol\",\n \"Literal\",\n \"UniqueSymbol\",\n \"ObjectKeyword\",\n \"Enum\",\n \"TemplateLiteral\",\n (leaf) => leaf,\n ),\n Match.exhaustive,\n );\n const ownScope = scope(ast);\n const scoped =\n Option.isSome(tableName(ast)) &&\n (ownScope === from || ownScope.startsWith(`${from}/instance:`))\n ? Schema.make<Schema.Codec<unknown>>(next).annotate({\n [ConvexIdScope]: to + ownScope.slice(from.length),\n }).ast\n : next;\n if (ast.encoding === undefined) {\n return changed || scoped !== next ? scoped : ast;\n }\n const encoding = Array.map(ast.encoding, (link) => {\n const target = child(link.to);\n return target === link.to\n ? link\n : new SchemaAST.Link(target, link.transformation);\n });\n if (!changed && scoped === next) return ast;\n // Effect's replaceEncoding helper is internal and omitted from its published\n // declarations. Preserve AST prototypes and descriptors at this boundary;\n // spreading the node itself would lose its class behavior.\n return Object.create(Object.getPrototypeOf(scoped), {\n ...Object.getOwnPropertyDescriptors(scoped),\n encoding: {\n value: encoding,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n }) as SchemaAST.AST;\n });\n const rebuild = memoize((input: Schema.Constraint): Schema.Constraint => {\n const ast = visit(input.ast);\n if (ast === input.ast) return input;\n if (\"fields\" in input) {\n const fields = (input as { readonly fields: Schema.Struct.Fields })\n .fields;\n const reboundFields = Object.fromEntries(\n Reflect.ownKeys(fields).map((key) => [key, rebuild(fields[key]!)]),\n );\n if (\n ast.encoding === undefined &&\n SchemaAST.isObjects(ast) &&\n \"mapFields\" in input\n ) {\n return (input as Schema.Struct<Schema.Struct.Fields>)\n .mapFields(() => reboundFields, { unsafePreserveChecks: true })\n .rebuild(ast);\n }\n return Schema.make(ast, { fields: reboundFields });\n }\n return Schema.make(ast);\n });\n return rebuild(schema) as RebaseSchema<Schema_, From, To>;\n};\n\nexport const tableName = <TableName extends string>(\n ast: SchemaAST.AST,\n): Option.Option<TableName> =>\n Option.fromNullishOr(SchemaAST.resolveAt<TableName>(ConvexId)(ast));\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,WAAW;AACjB,MAAM,gBAAgB;AAmBtB,MAAa,aAIX,WACA,UAEA,OAAO,OAAO,SAAS;EACpB,WAAW;EACX,gBAAgB,SAASA;AAC5B,CAAC;AAEH,MAAa,SAAS,QACpB,UAAU,UAA2B,aAAa,CAAC,CAAC,GAAG,KAAKA;;;;;AAsH9D,MAAa,UAKX,QACA,MACA,OACoC;CACpC,MAAM,QAAQ,SAAS,QAAsC;EAE3D,IAAI,UAAU,UAAU,UAAU,GAAG;EACrC,MAAM,SAAS,UAAwC;GACrD,MAAM,OAAO,MAAM,KAAK;GACxB,IAAI,SAAS,OAAO,UAAU;GAC9B,OAAO;EACT;EACA,MAAM,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,KAC5B,MAAM,IACJ,YACC,YACC,IAAI,UAAU,QACZ,MAAM,IACJ,QAAQ,qBACP,aACC,IAAI,UAAU,kBACZ,SAAS,MACT,MAAM,SAAS,IAAI,CACrB,CACJ,GACA,MAAM,IACJ,QAAQ,kBACP,UACC,IAAI,UAAU,eACZ,MAAM,MAAM,SAAS,GACrB,MAAM,MAAM,IAAI,CAClB,CACJ,GACA,QAAQ,aACR,QAAQ,QACR,KAAA,GACA,QAAQ,SACR,QAAQ,cACV,CACJ,GACA,MAAM,IACJ,WACC,WACC,IAAI,UAAU,OACZ,OAAO,WACP,MAAM,IAAI,OAAO,UAAU,KAAK,GAChC,MAAM,I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,MAAM,GAAG;GAClD,GAAG,OAAO,0BAA0B,MAAM;GAC1C,UAAU;IACR,OAAO;IACP,YAAY;IACZ,cAAc;IACd,UAAU;GACZ;EACF,CAAC;CACH,CAAC;CACD,MAAM,UAAU,SAAS,UAAgD;EACvE,MAAM,MAAM,MAAM,MAAM,GAAG;EAC3B,IAAI,QAAQ,MAAM,KAAK,OAAO;EAC9B,IAAI,YAAY,OAAO;GACrB,MAAM,SAAU,MACb;GACH,MAAM,gBAAgB,OAAO,YAC3B,QAAQ,QAAQ,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,QAAQ,OAAO,IAAK,CAAC,CAAC,CACnE;GACA,IACE,IAAI,aAAa,KAAA,KACjB,UAAU,UAAU,GAAG,KACvB,eAAe,OAEf,OAAQ,MACL,gBAAgB,eAAe,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAC9D,QAAQ,GAAG;GAEhB,OAAO,OAAO,KAAK,KAAK,EAAE,QAAQ,cAAc,CAAC;EACnD;EACA,OAAO,OAAO,KAAK,GAAG;CACxB,CAAC;CACD,OAAO,QAAQ,MAAM;AACvB;AAEA,MAAa,aACX,QAEA,OAAO,cAAc,UAAU,UAAqB,QAAQ,CAAC,CAAC,GAAG,CAAC"}
|
package/dist/GroupPath.d.ts
CHANGED
package/dist/GroupPath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPath.d.ts","sourceRoot":"","sources":["../src/GroupPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"GroupPath.d.ts","sourceRoot":"","sources":["../src/GroupPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CACb,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,KAAK,SAAS,CAAC,EAAE,GAAG,EAAE,IACpB,KA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S,SAAS,SAAS,CAAC,YAAY,GACtC,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAC3C,KAAK,GACP,KAAK,CAAC"}
|
package/dist/GroupPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPath.js","names":[],"sources":["../src/GroupPath.ts"],"sourcesContent":["import type * as GroupSpec from \"./GroupSpec\";\n\n/**\n * Recursively generates paths for a group and its nested groups.\n *\n * - For a group with no subgroups, returns just the group name.\n * - For a group with subgroups, returns the group name plus all possible paths\n * through its direct subgroups.\n */\nexport type All<\n Group extends GroupSpec.AnyWithProps,\n Depth extends 1[] = [],\n> = Depth[\"length\"] extends 15\n ? string\n : Group extends any\n ? [GroupSpec.Groups<Group>] extends [never]\n ? GroupSpec.Name<Group>\n : GroupSpec.Name<Group> | AllHelper<Group, GroupSpec.Groups<Group>, Depth>\n : never;\n\ntype AllHelper<\n Parent extends GroupSpec.AnyWithProps,\n Groups_ extends GroupSpec.AnyWithProps,\n Depth extends 1[] = [],\n> = Groups_ extends GroupSpec.AnyWithProps\n ? `${GroupSpec.Name<Parent>}.${All<Groups_, [...Depth, 1]>}`\n : never;\n\n/**\n * Recursively extracts the group at the given dot-separated path. Path must\n * match the format defined in `Path` above, e.g. \"group\" or \"group.subgroup\".\n *\n * @example\n * type G = WithPath<RootGroup, \"group.subgroup\">;\n */\nexport type GroupAt<\n Group,\n Path extends string,\n> = Group extends GroupSpec.AnyWithProps\n ? Path extends `${infer Head}.${infer Tail}`\n ? Group extends { readonly name: Head }\n ? GroupAt<GroupSpec.Groups<Group>, Tail>\n : never\n : GroupSpec.WithName<Group, Path>\n : never;\n\nexport type SubGroupsAt<\n Group extends GroupSpec.AnyWithProps,\n GroupPath extends string,\n> =\n GroupSpec.Groups<GroupAt<Group, GroupPath>> extends infer SubGroups\n ? SubGroups extends GroupSpec.AnyWithProps\n ? `${GroupPath}.${GroupSpec.Name<SubGroups>}`\n : never\n : never;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"GroupPath.js","names":[],"sources":["../src/GroupPath.ts"],"sourcesContent":["import type * as GroupSpec from \"./GroupSpec.js\";\n\n/**\n * Recursively generates paths for a group and its nested groups.\n *\n * - For a group with no subgroups, returns just the group name.\n * - For a group with subgroups, returns the group name plus all possible paths\n * through its direct subgroups.\n */\nexport type All<\n Group extends GroupSpec.AnyWithProps,\n Depth extends 1[] = [],\n> = Depth[\"length\"] extends 15\n ? string\n : Group extends any\n ? [GroupSpec.Groups<Group>] extends [never]\n ? GroupSpec.Name<Group>\n : GroupSpec.Name<Group> | AllHelper<Group, GroupSpec.Groups<Group>, Depth>\n : never;\n\ntype AllHelper<\n Parent extends GroupSpec.AnyWithProps,\n Groups_ extends GroupSpec.AnyWithProps,\n Depth extends 1[] = [],\n> = Groups_ extends GroupSpec.AnyWithProps\n ? `${GroupSpec.Name<Parent>}.${All<Groups_, [...Depth, 1]>}`\n : never;\n\n/**\n * Recursively extracts the group at the given dot-separated path. Path must\n * match the format defined in `Path` above, e.g. \"group\" or \"group.subgroup\".\n *\n * @example\n * type G = WithPath<RootGroup, \"group.subgroup\">;\n */\nexport type GroupAt<\n Group,\n Path extends string,\n> = Group extends GroupSpec.AnyWithProps\n ? Path extends `${infer Head}.${infer Tail}`\n ? Group extends { readonly name: Head }\n ? GroupAt<GroupSpec.Groups<Group>, Tail>\n : never\n : GroupSpec.WithName<Group, Path>\n : never;\n\nexport type SubGroupsAt<\n Group extends GroupSpec.AnyWithProps,\n GroupPath extends string,\n> =\n GroupSpec.Groups<GroupAt<Group, GroupPath>> extends infer SubGroups\n ? SubGroups extends GroupSpec.AnyWithProps\n ? `${GroupPath}.${GroupSpec.Name<SubGroups>}`\n : never\n : never;\n"],"mappings":""}
|
package/dist/GroupSpec.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import * as Record from "effect/Record";
|
|
3
3
|
import * as Result from "effect/Result";
|
|
4
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
5
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
6
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
4
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
5
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
6
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
7
7
|
export declare const TypeId = "~@confect/core/GroupSpec";
|
|
8
8
|
export type TypeId = typeof TypeId;
|
|
9
9
|
export declare const isGroupSpec: (u: unknown) => u is AnyWithProps;
|
package/dist/GroupSpec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.d.ts","sourceRoot":"","sources":["../src/GroupSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"GroupSpec.d.ts","sourceRoot":"","sources":["../src/GroupSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAG3E,eAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,eAAO,MAAM,WAAW,MAAO,OAAO,KAAG,CAAC,IAAI,YACZ,CAAC;AAEnC,MAAM,WAAW,SAAS,CACxB,OAAO,SAAS,sBAAsB,CAA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upSpec.ts"],"sourcesContent":["import * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Result from \"effect/Result\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\n\nexport const TypeId = \"~@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n // Subgroups may be of any runtime, independent of this group's own runtime: a\n // group is only a namespace for its children, which are otherwise-independent\n // modules. Functions, by contrast, stay homogeneous (a Node group only accepts\n // Node actions)—`addFunction` keeps the `<Runtime>` bound below.\n Groups_ extends AnyWithProps = never,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [\n FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >\n ]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly middlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<MiddlewareSpecs_>\n >;\n readonly \"~Functions\": Functions_;\n readonly \"~Groups\": Groups_;\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function &\n MiddlewareSpec.ValidateAddedFunction<Function, MiddlewareSpecs_>,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_ | Function,\n Groups_,\n MiddlewareSpecs_\n >;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateAttach<\n MiddlewareSpec_,\n Functions_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends GroupSpec<\n RuntimeAndFunctionType.Runtime,\n string,\n FunctionSpec.AnyWithProps,\n AnyWithProps,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> = Group[\"~Functions\"];\n\nexport type Groups<Group extends AnyWithProps> = Group[\"~Groups\"];\n\nexport type MiddlewareSpecs<Group extends AnyWithProps> =\n Group[\"middlewareSpecs\"][number];\n\nexport type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [\n never,\n]\n ? never\n : Name<Groups<Group>>;\n\nexport type WithName<\n Group extends AnyWithProps,\n Name_ extends Name<Group>,\n> = Extract<Group, { readonly name: Name_ }>;\n\n/**\n * Assigns a segment name to a leaf group created with {@link make} for typing\n * and refs.\n */\nexport type NamedAt<Group extends Any, Name_ extends string> = Omit<\n Group,\n \"name\"\n> & {\n readonly name: Name_;\n};\n\nexport type AddGroups<\n Group extends AnyWithProps,\n ExtraGroups extends AnyWithProps,\n> =\n Group extends GroupSpec<\n infer Runtime,\n string,\n infer Functions_,\n infer Groups_,\n infer MiddlewareSpecs_\n >\n ? GroupSpec<\n Runtime,\n Group[\"name\"],\n Functions_,\n Exclude<Groups_, { readonly name: Name<ExtraGroups> }> | ExtraGroups,\n MiddlewareSpecs_\n >\n : never;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n\n addFunction<Function extends FunctionSpec.AnyWithProps>(\n this: Any,\n function_: Function,\n ) {\n const this_ = this as AnyWithProps;\n\n const overlapping = function_.middlewareAttachments.find(\n ({ spec: functionMiddlewareSpec }) =>\n !(\"options\" in functionMiddlewareSpec) &&\n this_.middlewareAttachments.some(\n ({ spec: groupMiddlewareSpec }) =>\n groupMiddlewareSpec.key === functionMiddlewareSpec.key,\n ),\n );\n if (overlapping !== undefined) {\n throw new Error(\n `Middleware \"${overlapping.spec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\n middlewareAttachments: this_.middlewareAttachments,\n });\n },\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n this: Any,\n middlewareSpec: MiddlewareSpec_,\n ...options: ReadonlyArray<unknown>\n ) {\n const this_ = this as AnyWithProps;\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 this group`,\n );\n }\n\n for (const function_ of Object.values(this_.functions)) {\n if (\n !(\"options\" in middlewareSpec) &&\n function_.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: this_.groups,\n middlewareAttachments: [\n ...this_.middlewareAttachments,\n { spec: middlewareSpec, options: options[0] },\n ],\n });\n },\n} satisfies ThisType<AnyWithProps>;\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n Groups_ extends AnyWithProps,\n MiddlewareAttachments_ extends\n ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n>({\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n middlewareAttachments: MiddlewareAttachments_;\n}): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n }) as GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n >;\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport function withName<const Name_ extends string, Group extends Any>(\n name: Name_,\n group: Group,\n): NamedAt<Group, Name_>;\nexport function withName(name: string, group: Any): AnyWithProps {\n validateConfectFunctionIdentifier(name);\n const group_ = group as AnyWithProps;\n\n if (group_.name === name) {\n return group_;\n }\n\n return makeProto({\n runtime: group_.runtime,\n name,\n functions: group_.functions,\n groups: group_.groups,\n middlewareAttachments: group_.middlewareAttachments,\n });\n}\n\nexport const addGroupsAt = (\n group: AnyWithProps,\n children: Record.ReadonlyRecord<string, AnyWithProps>,\n): AnyWithProps =>\n makeProto({\n runtime: group.runtime,\n name: group.name,\n functions: group.functions,\n groups: Record.union(\n group.groups,\n Record.map(children, (child, name) => withName(name, child)),\n (_existing, incoming) => incoming,\n ),\n middlewareAttachments: group.middlewareAttachments,\n });\n\nexport const validateMiddleware = (\n group: AnyWithProps,\n): Result.Result<void, MiddlewareAttachment.ValidationError> =>\n Result.gen(function* () {\n yield* MiddlewareAttachment.validateAll(\n group.middlewareAttachments,\n `group \"${group.name}\"`,\n );\n for (const function_ of Object.values(group.functions)) {\n yield* MiddlewareAttachment.validateAll(\n [...group.middlewareAttachments, ...function_.middlewareAttachments],\n `function \"${function_.name}\"`,\n );\n }\n for (const child of Object.values(group.groups))\n yield* validateMiddleware(child);\n });\n"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,MAAM;AA4HjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAI,kBAAkB;EACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;CAC1D;CAEA,YAEE,WACA;EACA,MAAM,QAAQ;EAEd,MAAM,cAAc,UAAU,sBAAsB,MACjD,EAAE,MAAM,6BACP,EAAE,aAAa,2BACf,MAAM,sBAAsB,MACzB,EAAE,MAAM,0BACP,oBAAoB,QAAQ,uBAAuB,GACvD,CACJ;EACA,IAAI,gBAAgB,KAAA,GAClB,MAAM,IAAI,MACR,eAAe,YAAY,KAAK,IAAI,kCAAkC,UAAU,KAAK,gBACvF;EAGF,OAAO,UAAU;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,WAAW,OAAO,IAAI,MAAM,WAAW,UAAU,MAAM,SAAS;GAChE,QAAQ,MAAM;GACd,uBAAuB,MAAM;EAC/B,CAAC;CACH;CAEA,WAEE,gBACA,GAAG,SACH;EACA,MAAM,QAAQ;EAEd,IACE,EAAE,aAAa,mBACf,MAAM,sBAAsB,MACzB,EAAE,WAAW,KAAK,QAAQ,eAAe,GAC5C,GAEA,MAAM,IAAI,MACR,eAAe,eAAe,IAAI,oCACpC;EAGF,KAAK,MAAM,aAAa,OAAO,OAAO,MAAM,SAAS,GACnD,IACE,EAAE,aAAa,mBACf,UAAU,sBAAsB,MAC7B,EAAE,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,MAAM,aAAa,OAAO,OAAO,MAAM,SAAS,GACnD,OAAOA,YACL,CAAC,GAAG,MAAM,uBAAuB,GAAG,UAAU,qBAAqB,GACnE,aAAa,UAAU,KAAK,EAC9B;CAEF,KAAK,MAAM,SAAS,OAAO,OAAO,MAAM,MAAM,GAC5C,OAAO,mBAAmB,KAAK;AACnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"GroupSpec.js","names":["MiddlewareAttachment.validateAll"],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Result from \"effect/Result\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier.js\";\n\nexport const TypeId = \"~@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n // Subgroups may be of any runtime, independent of this group's own runtime: a\n // group is only a namespace for its children, which are otherwise-independent\n // modules. Functions, by contrast, stay homogeneous (a Node group only accepts\n // Node actions)—`addFunction` keeps the `<Runtime>` bound below.\n Groups_ extends AnyWithProps = never,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [\n FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >\n ]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly middlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<MiddlewareSpecs_>\n >;\n readonly \"~Functions\": Functions_;\n readonly \"~Groups\": Groups_;\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function &\n MiddlewareSpec.ValidateAddedFunction<Function, MiddlewareSpecs_>,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_ | Function,\n Groups_,\n MiddlewareSpecs_\n >;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateAttach<\n MiddlewareSpec_,\n Functions_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends GroupSpec<\n RuntimeAndFunctionType.Runtime,\n string,\n FunctionSpec.AnyWithProps,\n AnyWithProps,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> = Group[\"~Functions\"];\n\nexport type Groups<Group extends AnyWithProps> = Group[\"~Groups\"];\n\nexport type MiddlewareSpecs<Group extends AnyWithProps> =\n Group[\"middlewareSpecs\"][number];\n\nexport type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [\n never,\n]\n ? never\n : Name<Groups<Group>>;\n\nexport type WithName<\n Group extends AnyWithProps,\n Name_ extends Name<Group>,\n> = Extract<Group, { readonly name: Name_ }>;\n\n/**\n * Assigns a segment name to a leaf group created with {@link make} for typing\n * and refs.\n */\nexport type NamedAt<Group extends Any, Name_ extends string> = Omit<\n Group,\n \"name\"\n> & {\n readonly name: Name_;\n};\n\nexport type AddGroups<\n Group extends AnyWithProps,\n ExtraGroups extends AnyWithProps,\n> =\n Group extends GroupSpec<\n infer Runtime,\n string,\n infer Functions_,\n infer Groups_,\n infer MiddlewareSpecs_\n >\n ? GroupSpec<\n Runtime,\n Group[\"name\"],\n Functions_,\n Exclude<Groups_, { readonly name: Name<ExtraGroups> }> | ExtraGroups,\n MiddlewareSpecs_\n >\n : never;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n\n addFunction<Function extends FunctionSpec.AnyWithProps>(\n this: Any,\n function_: Function,\n ) {\n const this_ = this as AnyWithProps;\n\n const overlapping = function_.middlewareAttachments.find(\n ({ spec: functionMiddlewareSpec }) =>\n !(\"options\" in functionMiddlewareSpec) &&\n this_.middlewareAttachments.some(\n ({ spec: groupMiddlewareSpec }) =>\n groupMiddlewareSpec.key === functionMiddlewareSpec.key,\n ),\n );\n if (overlapping !== undefined) {\n throw new Error(\n `Middleware \"${overlapping.spec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\n middlewareAttachments: this_.middlewareAttachments,\n });\n },\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n this: Any,\n middlewareSpec: MiddlewareSpec_,\n ...options: ReadonlyArray<unknown>\n ) {\n const this_ = this as AnyWithProps;\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 this group`,\n );\n }\n\n for (const function_ of Object.values(this_.functions)) {\n if (\n !(\"options\" in middlewareSpec) &&\n function_.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: this_.groups,\n middlewareAttachments: [\n ...this_.middlewareAttachments,\n { spec: middlewareSpec, options: options[0] },\n ],\n });\n },\n} satisfies ThisType<AnyWithProps>;\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n Groups_ extends AnyWithProps,\n MiddlewareAttachments_ extends\n ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n>({\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n middlewareAttachments: MiddlewareAttachments_;\n}): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n }) as GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n >;\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport function withName<const Name_ extends string, Group extends Any>(\n name: Name_,\n group: Group,\n): NamedAt<Group, Name_>;\nexport function withName(name: string, group: Any): AnyWithProps {\n validateConfectFunctionIdentifier(name);\n const group_ = group as AnyWithProps;\n\n if (group_.name === name) {\n return group_;\n }\n\n return makeProto({\n runtime: group_.runtime,\n name,\n functions: group_.functions,\n groups: group_.groups,\n middlewareAttachments: group_.middlewareAttachments,\n });\n}\n\nexport const addGroupsAt = (\n group: AnyWithProps,\n children: Record.ReadonlyRecord<string, AnyWithProps>,\n): AnyWithProps =>\n makeProto({\n runtime: group.runtime,\n name: group.name,\n functions: group.functions,\n groups: Record.union(\n group.groups,\n Record.map(children, (child, name) => withName(name, child)),\n (_existing, incoming) => incoming,\n ),\n middlewareAttachments: group.middlewareAttachments,\n });\n\nexport const validateMiddleware = (\n group: AnyWithProps,\n): Result.Result<void, MiddlewareAttachment.ValidationError> =>\n Result.gen(function* () {\n yield* MiddlewareAttachment.validateAll(\n group.middlewareAttachments,\n `group \"${group.name}\"`,\n );\n for (const function_ of Object.values(group.functions)) {\n yield* MiddlewareAttachment.validateAll(\n [...group.middlewareAttachments, ...function_.middlewareAttachments],\n `function \"${function_.name}\"`,\n );\n }\n for (const child of Object.values(group.groups))\n yield* validateMiddleware(child);\n });\n"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,MAAM;AA4HjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAI,kBAAkB;EACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;CAC1D;CAEA,YAEE,WACA;EACA,MAAM,QAAQ;EAEd,MAAM,cAAc,UAAU,sBAAsB,MACjD,EAAE,MAAM,6BACP,EAAE,aAAa,2BACf,MAAM,sBAAsB,MACzB,EAAE,MAAM,0BACP,oBAAoB,QAAQ,uBAAuB,GACvD,CACJ;EACA,IAAI,gBAAgB,KAAA,GAClB,MAAM,IAAI,MACR,eAAe,YAAY,KAAK,IAAI,kCAAkC,UAAU,KAAK,gBACvF;EAGF,OAAO,UAAU;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,WAAW,OAAO,IAAI,MAAM,WAAW,UAAU,MAAM,SAAS;GAChE,QAAQ,MAAM;GACd,uBAAuB,MAAM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;CACR,SAAS,MAAM;CACf,MAAM,MAAM;CACZ,WAAW,MAAM;CACjB,QAAQ,OAAO,MACb,MAAM,QACN,OAAO,IAAI,WAAW,OAAO,SAAS,SAAS,MAAM,KAAK,CAAC,IAC1D,WAAW,aAAa,QAC3B;CACA,uBAAuB,MAAM;AAC/B,CAAC;AAEH,MAAa,sBACX,UAEA,OAAO,IAAI,aAAa;CACtB,OAAOA,YACL,MAAM,uBACN,UAAU,MAAM,KAAK,EACvB;CACA,KAAK,MAAM,aAAa,OAAO,OAAO,MAAM,SAAS,GACnD,OAAOA,YACL,CAAC,GAAG,MAAM,uBAAuB,GAAG,UAAU,qBAAqB,GACnE,aAAa,UAAU,KAAK,EAC9B;CAEF,KAAK,MAAM,SAAS,OAAO,OAAO,MAAM,MAAM,GAC5C,OAAO,mBAAmB,KAAK;AACnC,CAAC"}
|
package/dist/Http.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Layer from "effect/Layer";
|
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
3
|
import type * as HttpApi from "effect/http-api/HttpApi";
|
|
4
4
|
import type * as HttpApiGroup from "effect/http-api/HttpApiGroup";
|
|
5
|
-
import * as App from "./App";
|
|
5
|
+
import * as App from "./App.js";
|
|
6
6
|
declare const TypeId = "~@confect/core/Http";
|
|
7
7
|
/**
|
|
8
8
|
* A backend's HTTP declaration: the app's own `HttpApi`, its handlers, and an
|
package/dist/Http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../src/Http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,OAAO,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,GAAG,MAAM,
|
|
1
|
+
{"version":3,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AM,CAAA;KAAE,CAAC;CAC1E,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED,MAAM,MAAM,UAAU,GAClB,qBAAqB,GACrB,cAAc,GACd,wBAAwB,CAAC;AAsD7B;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,QACZ,GAAG,CAAC,GAAG,SACL,GAAG,KACT,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,UAAU,CAkFhD,CAAC"}
|
package/dist/Http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.js","names":["mounts","App.mounts"],"sources":["../src/Http.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Layer from \"effect/Layer\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport type * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as HttpApiBuilder from \"effect/http-api/HttpApiBuilder\";\nimport type * as HttpApiGroup from \"effect/http-api/HttpApiGroup\";\nimport * as HttpApiScalar from \"effect/http-api/HttpApiScalar\";\nimport * as App from \"./App\";\n\nconst TypeId = \"~@confect/core/Http\";\n\n/**\n * A backend's HTTP declaration: the app's own `HttpApi`, its handlers, and an\n * optional Scalar docs path. `routes` is the layer the generated\n * `convex/http.ts` serves. Mounted components serve their own routes.\n *\n * It does not reference `confect/app.ts`: `http.ts` runs in every HTTP action,\n * and `app.ts` imports component definitions that only load in Convex's config\n * analysis. Codegen checks these routes against the app's mounts.\n */\nexport interface Http<Api extends App.Api, Routes extends Layer.Any> {\n readonly [TypeId]: typeof TypeId;\n readonly api: Api;\n readonly docs: `/${string}` | undefined;\n readonly routes: Routes;\n}\n\nexport type Any = Http<App.Api, Layer.Any>;\n\n/**\n * Declare the backend's HTTP API, in `confect/http.ts`. Every route is an\n * `HttpApi` endpoint. `docs` serves a Scalar page for the api at that path.\n *\n * ```ts\n * export default Http.make({\n * api: TenantApi,\n * handlers: TenantHandlers,\n * docs: \"/docs\",\n * });\n * ```\n */\nexport const make = <\n Id extends string,\n Groups extends HttpApiGroup.Constraint,\n R,\n>(options: {\n readonly api: HttpApi.HttpApi<Id, Groups>;\n readonly handlers: Layer.Layer<HttpApiGroup.ToService<Id, Groups>, never, R>;\n readonly docs?: `/${string}`;\n}) => {\n const api = HttpApiBuilder.layer(options.api).pipe(\n Layer.provide(options.handlers),\n );\n const routes =\n options.docs === undefined\n ? api\n : Layer.merge(\n api,\n HttpApiScalar.layerCdn(options.api, { path: options.docs }),\n );\n const http: Http<HttpApi.HttpApi<Id, Groups>, typeof routes> = {\n [TypeId]: TypeId,\n api: options.api,\n docs: options.docs,\n routes,\n };\n return http;\n};\n\nexport const isHttp = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\nexport type Owner =\n | { readonly kind: \"app\" }\n | { readonly kind: \"docs\" }\n | { readonly kind: \"mount\"; readonly mount: string };\n\nexport interface Route {\n readonly method: string;\n readonly path: string;\n readonly owner: Owner;\n}\n\nexport class RouteUnderMountPrefix extends Data.TaggedError(\n \"RouteUnderMountPrefix\",\n)<{\n readonly method: string;\n readonly path: string;\n readonly mount: string;\n readonly httpPrefix: string;\n}> {\n override get message(): string {\n return `The app route ${this.method} ${this.path} is under the HTTP prefix ${this.httpPrefix} of the mount \"${this.mount}\". Convex would let it shadow the component's routes; move it or change the prefix.`;\n }\n}\n\nexport class DuplicateRoute extends Data.TaggedError(\"DuplicateRoute\")<{\n readonly method: string;\n readonly path: string;\n readonly first: Owner;\n readonly second: Owner;\n}> {\n override get message(): string {\n return `${this.method} ${this.path} is declared twice (${ownerLabel(this.first)} and ${ownerLabel(this.second)}).`;\n }\n}\n\nexport class OverlappingMountPrefixes extends Data.TaggedError(\n \"OverlappingMountPrefixes\",\n)<{\n readonly first: { readonly mount: string; readonly httpPrefix: string };\n readonly second: { readonly mount: string; readonly httpPrefix: string };\n}> {\n override get message(): string {\n return `The mounts \"${this.first.mount}\" (${this.first.httpPrefix}) and \"${this.second.mount}\" (${this.second.httpPrefix}) have overlapping HTTP prefixes.`;\n }\n}\n\nexport type RouteError =\n | RouteUnderMountPrefix\n | DuplicateRoute\n | OverlappingMountPrefixes;\n\nconst ownerLabel = (owner: Owner): string =>\n owner.kind === \"mount\" ? `mount \"${owner.mount}\"` : owner.kind;\n\nconst trimSlash = (prefix: string): string =>\n prefix.length > 1 && prefix.endsWith(\"/\") ? prefix.slice(0, -1) : prefix;\n\nconst isUnder = (path: string, prefix: string): boolean =>\n prefix === \"/\" ||\n path === prefix ||\n path === `${prefix}/` ||\n path.startsWith(`${prefix}/`);\n\n/**\n * The parameter names an endpoint declares. As in Effect's router, a colon\n * segment is a parameter only when its name is declared; otherwise it is\n * literal text.\n */\nconst paramNames = (params: Schema.Top | undefined): ReadonlySet<string> => {\n if (params === undefined) return new Set();\n let ast = params.ast;\n while (ast.encoding !== undefined) {\n ast = ast.encoding[ast.encoding.length - 1].to;\n }\n return SchemaAST.isObjects(ast)\n ? new Set(ast.propertySignatures.map(({ name }) => String(name)))\n : new Set();\n};\n\ninterface KeyedRoute {\n readonly route: Route;\n /**\n * Method and path with declared parameter names erased.\n */\n readonly key: string;\n}\n\nconst apiRoutes = (\n api: App.Api,\n prefix: string,\n owner: Owner,\n): ReadonlyArray<KeyedRoute> =>\n Object.values<HttpApiGroup.Top>(api.groups).flatMap((group) =>\n Object.values(group.endpoints).map((endpoint) => {\n const path = prefix + endpoint.path;\n const declared = paramNames(endpoint.params);\n return {\n route: { method: endpoint.method, path, owner },\n key: `${endpoint.method} ${path.replaceAll(/:(\\w+)/g, (param, name: string) => (declared.has(name) ? \":\" : param))}`,\n };\n }),\n );\n\n/**\n * Every HTTP route the backend serves: the app's api, its docs page and each\n * mount's api under its prefix. Fails when an app route or the docs page is at\n * or under a mount's prefix (Convex accepts that and lets the app route\n * silently shadow the component's), when two routes share a method and path, or\n * when two mount prefixes overlap.\n */\nexport const routes = (\n app: App.Any,\n http?: Any,\n): Result.Result<ReadonlyArray<Route>, RouteError> => {\n const mounts = App.mounts(app).flatMap(({ name, httpPrefix, api }) =>\n httpPrefix === undefined\n ? []\n : [{ name, httpPrefix: trimSlash(httpPrefix), api }],\n );\n\n for (const [index, first] of mounts.entries()) {\n for (const second of mounts.slice(index + 1)) {\n if (\n isUnder(second.httpPrefix, first.httpPrefix) ||\n isUnder(first.httpPrefix, second.httpPrefix)\n ) {\n return Result.fail(\n new OverlappingMountPrefixes({\n first: { mount: first.name, httpPrefix: first.httpPrefix },\n second: { mount: second.name, httpPrefix: second.httpPrefix },\n }),\n );\n }\n }\n }\n\n const own: ReadonlyArray<KeyedRoute> =\n http === undefined\n ? []\n : [\n ...apiRoutes(http.api, \"\", { kind: \"app\" }),\n ...(http.docs === undefined\n ? []\n : [\n {\n route: {\n method: \"GET\",\n path: http.docs,\n owner: { kind: \"docs\" } as const,\n },\n key: `GET ${http.docs}`,\n },\n ]),\n ];\n\n for (const { route } of own) {\n const mount = mounts.find(({ httpPrefix }) =>\n isUnder(route.path, httpPrefix),\n );\n if (mount !== undefined) {\n return Result.fail(\n new RouteUnderMountPrefix({\n method: route.method,\n path: route.path,\n mount: mount.name,\n httpPrefix: mount.httpPrefix,\n }),\n );\n }\n }\n\n const all = [\n ...own,\n ...mounts.flatMap(({ name, httpPrefix, api }) =>\n api === undefined\n ? []\n : apiRoutes(api, httpPrefix, { kind: \"mount\", mount: name }),\n ),\n ];\n const seen = new Map<string, Route>();\n for (const { route, key } of all) {\n const previous = seen.get(key);\n if (previous !== undefined) {\n return Result.fail(\n new DuplicateRoute({\n method: route.method,\n path: route.path,\n first: previous.owner,\n second: route.owner,\n }),\n );\n }\n seen.set(key, route);\n }\n return Result.succeed(all.map(({ route }) => route));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAYA,MAAM,SAAS;;;;;;;;;;;;;AAgCf,MAAa,QAIX,YAII;CACJ,MAAM,M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CACH;CAKN,MAAM,MACJ,SAAS,KAAA,IACL,CAAC,IACD,CACE,GAAG,UAAU,KAAK,KAAK,IAAI,EAAE,MAAM,MAAM,CAAC,GAC1C,GAAI,KAAK,SAAS,KAAA,IACd,CAAC,IACD,CACE;EACE,OAAO;GACL,QAAQ;GACR,MAAM,KAAK;GACX,OAAO,EAAE,MAAM,OAAO;EACxB;EACA,KAAK,OAAO,KAAK;CACnB,CACF,CACN;CAEN,KAAK,MAAM,EAAE,WAAW,KAAK;EAC3B,MAAM,QAAQA,SAAO,MAAM,EAAE,iBAC3B,QAAQ,MAAM,MAAM,UAAU,CAChC;EACA,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO,KACZ,IAAI,sBAAsB;GACxB,QAAQ,MAAM;GACd,MAAM,MAAM;GACZ,OAAO,MAAM;GACb,YAAY,MAAM;EACpB,CAAC,CACH;CAEJ;CAEA,MAAM,MAAM,CACV,GAAG,KACH,GAAGA,SAAO,SAAS,EAAE,MAAM,YAAY,UACrC,QAAQ,KAAA,IACJ,CAAC,IACD,UAAU,KAAK,YAAY;EAAE,MAAM;EAAS,OAAO;CAAK,CAAC,CAC/D,CACF;CACA,MAAM,uBAAO,IAAI,IAAmB;CACpC,KAAK,MAAM,EAAE,OAAO,SAAS,KAAK;EAChC,MAAM,WAAW,KAAK,IAAI,GAAG;EAC7B,IAAI,aAAa,KAAA,GACf,OAAO,OAAO,KACZ,IAAI,eAAe;GACjB,QAAQ,MAAM;GACd,MAAM,MAAM;GACZ,OAAO,SAAS;GAChB,QAAQ,MAAM;EAChB,CAAC,CACH;EAEF,KAAK,IAAI,KAAK,KAAK;CACrB;CACA,OAAO,OAAO,QAAQ,IAAI,KAAK,EAAE,YAAY,KAAK,CAAC;AACrD"}
|
|
1
|
+
{"version":3,"file":"Http.js","names":["mounts","App.mounts"],"sources":["../src/Http.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Layer from \"effect/Layer\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport type * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as HttpApiBuilder from \"effect/http-api/HttpApiBuilder\";\nimport type * as HttpApiGroup from \"effect/http-api/HttpApiGroup\";\nimport * as HttpApiScalar from \"effect/http-api/HttpApiScalar\";\nimport * as App from \"./App.js\";\n\nconst TypeId = \"~@confect/core/Http\";\n\n/**\n * A backend's HTTP declaration: the app's own `HttpApi`, its handlers, and an\n * optional Scalar docs path. `routes` is the layer the generated\n * `convex/http.ts` serves. Mounted components serve their own routes.\n *\n * It does not reference `confect/app.ts`: `http.ts` runs in every HTTP action,\n * and `app.ts` imports component definitions that only load in Convex's config\n * analysis. Codegen checks these routes against the app's mounts.\n */\nexport interface Http<Api extends App.Api, Routes extends Layer.Any> {\n readonly [TypeId]: typeof TypeId;\n readonly api: Api;\n readonly docs: `/${string}` | undefined;\n readonly routes: Routes;\n}\n\nexport type Any = Http<App.Api, Layer.Any>;\n\n/**\n * Declare the backend's HTTP API, in `confect/http.ts`. Every route is an\n * `HttpApi` endpoint. `docs` serves a Scalar page for the api at that path.\n *\n * ```ts\n * export default Http.make({\n * api: TenantApi,\n * handlers: TenantHandlers,\n * docs: \"/docs\",\n * });\n * ```\n */\nexport const make = <\n Id extends string,\n Groups extends HttpApiGroup.Constraint,\n R,\n>(options: {\n readonly api: HttpApi.HttpApi<Id, Groups>;\n readonly handlers: Layer.Layer<HttpApiGroup.ToService<Id, Groups>, never, R>;\n readonly docs?: `/${string}`;\n}) => {\n const api = HttpApiBuilder.layer(options.api).pipe(\n Layer.provide(options.handlers),\n );\n const routes =\n options.docs === undefined\n ? api\n : Layer.merge(\n api,\n HttpApiScalar.layerCdn(options.api, { path: options.docs }),\n );\n const http: Http<HttpApi.HttpApi<Id, Groups>, typeof routes> = {\n [TypeId]: TypeId,\n api: options.api,\n docs: options.docs,\n routes,\n };\n return http;\n};\n\nexport const isHttp = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\nexport type Owner =\n | { readonly kind: \"app\" }\n | { readonly kind: \"docs\" }\n | { readonly kind: \"mount\"; readonly mount: string };\n\nexport interface Route {\n readonly method: string;\n readonly path: string;\n readonly owner: Owner;\n}\n\nexport class RouteUnderMountPrefix extends Data.TaggedError(\n \"RouteUnderMountPrefix\",\n)<{\n readonly method: string;\n readonly path: string;\n readonly mount: string;\n readonly httpPrefix: string;\n}> {\n override get message(): string {\n return `The app route ${this.method} ${this.path} is under the HTTP prefix ${this.httpPrefix} of the mount \"${this.mount}\". Convex would let it shadow the component's routes; move it or change the prefix.`;\n }\n}\n\nexport class DuplicateRoute extends Data.TaggedError(\"DuplicateRoute\")<{\n readonly method: string;\n readonly path: string;\n readonly first: Owner;\n readonly second: Owner;\n}> {\n override get message(): string {\n return `${this.method} ${this.path} is declared twice (${ownerLabel(this.first)} and ${ownerLabel(this.second)}).`;\n }\n}\n\nexport class OverlappingMountPrefixes extends Data.TaggedError(\n \"OverlappingMountPrefixes\",\n)<{\n readonly first: { readonly mount: string; readonly httpPrefix: string };\n readonly second: { readonly mount: string; readonly httpPrefix: string };\n}> {\n override get message(): string {\n return `The mounts \"${this.first.mount}\" (${this.first.httpPrefix}) and \"${this.second.mount}\" (${this.second.httpPrefix}) have overlapping HTTP prefixes.`;\n }\n}\n\nexport type RouteError =\n | RouteUnderMountPrefix\n | DuplicateRoute\n | OverlappingMountPrefixes;\n\nconst ownerLabel = (owner: Owner): string =>\n owner.kind === \"mount\" ? `mount \"${owner.mount}\"` : owner.kind;\n\nconst trimSlash = (prefix: string): string =>\n prefix.length > 1 && prefix.endsWith(\"/\") ? prefix.slice(0, -1) : prefix;\n\nconst isUnder = (path: string, prefix: string): boolean =>\n prefix === \"/\" ||\n path === prefix ||\n path === `${prefix}/` ||\n path.startsWith(`${prefix}/`);\n\n/**\n * The parameter names an endpoint declares. As in Effect's router, a colon\n * segment is a parameter only when its name is declared; otherwise it is\n * literal text.\n */\nconst paramNames = (params: Schema.Top | undefined): ReadonlySet<string> => {\n if (params === undefined) return new Set();\n let ast = params.ast;\n while (ast.encoding !== undefined) {\n ast = ast.encoding[ast.encoding.length - 1].to;\n }\n return SchemaAST.isObjects(ast)\n ? new Set(ast.propertySignatures.map(({ name }) => String(name)))\n : new Set();\n};\n\ninterface KeyedRoute {\n readonly route: Route;\n /**\n * Method and path with declared parameter names erased.\n */\n readonly key: string;\n}\n\nconst apiRoutes = (\n api: App.Api,\n prefix: string,\n owner: Owner,\n): ReadonlyArray<KeyedRoute> =>\n Object.values<HttpApiGroup.Top>(api.groups).flatMap((group) =>\n Object.values(group.endpoints).map((endpoint) => {\n const path = prefix + endpoint.path;\n const declared = paramNames(endpoint.params);\n return {\n route: { method: endpoint.method, path, owner },\n key: `${endpoint.method} ${path.replaceAll(/:(\\w+)/g, (param, name: string) => (declared.has(name) ? \":\" : param))}`,\n };\n }),\n );\n\n/**\n * Every HTTP route the backend serves: the app's api, its docs page and each\n * mount's api under its prefix. Fails when an app route or the docs page is at\n * or under a mount's prefix (Convex accepts that and lets the app route\n * silently shadow the component's), when two routes share a method and path, or\n * when two mount prefixes overlap.\n */\nexport const routes = (\n app: App.Any,\n http?: Any,\n): Result.Result<ReadonlyArray<Route>, RouteError> => {\n const mounts = App.mounts(app).flatMap(({ name, httpPrefix, api }) =>\n httpPrefix === undefined\n ? []\n : [{ name, httpPrefix: trimSlash(httpPrefix), api }],\n );\n\n for (const [index, first] of mounts.entries()) {\n for (const second of mounts.slice(index + 1)) {\n if (\n isUnder(second.httpPrefix, first.httpPrefix) ||\n isUnder(first.httpPrefix, second.httpPrefix)\n ) {\n return Result.fail(\n new OverlappingMountPrefixes({\n first: { mount: first.name, httpPrefix: first.httpPrefix },\n second: { mount: second.name, httpPrefix: second.httpPrefix },\n }),\n );\n }\n }\n }\n\n const own: ReadonlyArray<KeyedRoute> =\n http === undefined\n ? []\n : [\n ...apiRoutes(http.api, \"\", { kind: \"app\" }),\n ...(http.docs === undefined\n ? []\n : [\n {\n route: {\n method: \"GET\",\n path: http.docs,\n owner: { kind: \"docs\" } as const,\n },\n key: `GET ${http.docs}`,\n },\n ]),\n ];\n\n for (const { route } of own) {\n const mount = mounts.find(({ httpPrefix }) =>\n isUnder(route.path, httpPrefix),\n );\n if (mount !== undefined) {\n return Result.fail(\n new RouteUnderMountPrefix({\n method: route.method,\n path: route.path,\n mount: mount.name,\n httpPrefix: mount.httpPrefix,\n }),\n );\n }\n }\n\n const all = [\n ...own,\n ...mounts.flatMap(({ name, httpPrefix, api }) =>\n api === undefined\n ? []\n : apiRoutes(api, httpPrefix, { kind: \"mount\", mount: name }),\n ),\n ];\n const seen = new Map<string, Route>();\n for (const { route, key } of all) {\n const previous = seen.get(key);\n if (previous !== undefined) {\n return Result.fail(\n new DuplicateRoute({\n method: route.method,\n path: route.path,\n first: previous.owner,\n second: route.owner,\n }),\n );\n }\n seen.set(key, route);\n }\n return Result.succeed(all.map(({ route }) => route));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAYA,MAAM,SAAS;;;;;;;;;;;;;AAgCf,MAAa,QAIX,YAII;CACJ,MAAM,MAAM,eAAe,MAAM,QAAQ,GAAG,CAAC,CAAC,KAC5C,MAAM,QAAQ,QAAQ,QAAQ,CAChC;CACA,MAAM,SACJ,QAAQ,SAAS,KAAA,IACb,MACA,MAAM,MACJ,KACA,cAAc,SAAS,QAAQ,KAAK,EAAE,MAAM,QAAQ,KAAK,CAAC,CAC5D;CAON,OAAO;GALJ,SAAS;EACV,KAAK,QAAQ;EACb,MAAM,QAAQ;EACd;CAEQ;AACZ;AAEA,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM,KAAK,EAAE,YAAY;AAapD,IAAa,wBAAb,cAA2C,KAAK,YAC9C,uBACF,CAAC,CAKE;CACD,IAAa,UAAkB;EAC7B,OAAO,iBAAiB,KAAK,OAAO,GAAG,KAAK,KAAK,4BAA4B,KAAK,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AO,MAAM;GACb,YAAY,MAAM;EACpB,CAAC,CACH;CAEJ;CAEA,MAAM,MAAM,CACV,GAAG,KACH,GAAGA,SAAO,SAAS,EAAE,MAAM,YAAY,UACrC,QAAQ,KAAA,IACJ,CAAC,IACD,UAAU,KAAK,YAAY;EAAE,MAAM;EAAS,OAAO;CAAK,CAAC,CAC/D,CACF;CACA,MAAM,uBAAO,IAAI,IAAmB;CACpC,KAAK,MAAM,EAAE,OAAO,SAAS,KAAK;EAChC,MAAM,WAAW,KAAK,IAAI,GAAG;EAC7B,IAAI,aAAa,KAAA,GACf,OAAO,OAAO,KACZ,IAAI,eAAe;GACjB,QAAQ,MAAM;GACd,MAAM,MAAM;GACZ,OAAO,SAAS;GAChB,QAAQ,MAAM;EAChB,CAAC,CACH;EAEF,KAAK,IAAI,KAAK,KAAK;CACrB;CACA,OAAO,OAAO,QAAQ,IAAI,KAAK,EAAE,YAAY,KAAK,CAAC;AACrD"}
|
package/dist/Manifest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Redacted from "effect/Redacted";
|
|
2
|
-
import type * as Env from "./Env";
|
|
2
|
+
import type * as Env from "./Env.js";
|
|
3
3
|
/**
|
|
4
4
|
* The shape of `confect/_generated/manifest.ts`: plain data with no imports,
|
|
5
5
|
* which infra reads instead of backend code. `env` lists each variable with its
|
package/dist/Manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../src/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../src/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAA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ACxE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;CACvB,CAAC"}
|
package/dist/Manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.js","names":[],"sources":["../src/Manifest.ts"],"sourcesContent":["import type * as Redacted from \"effect/Redacted\";\nimport type * as Env from \"./Env\";\n\n/**\n * The shape of `confect/_generated/manifest.ts`: plain data with no imports,\n * which infra reads instead of backend code. `env` lists each variable with its\n * kind, `http.mounts` each mount's HTTP prefix, and `digest` identifies the\n * declaration inputs it was generated from.\n */\nexport interface Manifest {\n readonly name: string;\n readonly env: Readonly<Record<string, Env.Descriptor>>;\n readonly http: { readonly mounts: Readonly<Record<string, string>> };\n readonly digest: string;\n}\n\ntype Value<D extends Env.Descriptor> = D extends { readonly kind: \"secret\" }\n ? Redacted.Redacted<string>\n : D extends { readonly kind: \"literals\"; readonly values: infer L }\n ? L extends ReadonlyArray<infer V>\n ? V\n : never\n : string;\n\n/**\n * The values a deployment must supply for a manifest's env: secrets as\n * `Redacted`, literals as one of their values, optional variables omittable.\n *\n * ```ts\n * import manifest from \"@tenant/convex/manifest\";\n *\n * const values: Manifest.Values<typeof manifest> = {\n * EMAIL_FROM: \"noreply@example.edu\",\n * RESEND_API_KEY: Redacted.make(key),\n * };\n * ```\n */\nexport type Values<M extends Manifest> = {\n readonly [\n K in keyof M[\"env\"] as M[\"env\"][K][\"optional\"] extends true ? never : K\n ]: Value<M[\"env\"][K]>;\n} & {\n readonly [\n K in keyof M[\"env\"] as M[\"env\"][K][\"optional\"] extends true ? K : never\n ]?: Value<M[\"env\"][K]>;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Manifest.js","names":[],"sources":["../src/Manifest.ts"],"sourcesContent":["import type * as Redacted from \"effect/Redacted\";\nimport type * as Env from \"./Env.js\";\n\n/**\n * The shape of `confect/_generated/manifest.ts`: plain data with no imports,\n * which infra reads instead of backend code. `env` lists each variable with its\n * kind, `http.mounts` each mount's HTTP prefix, and `digest` identifies the\n * declaration inputs it was generated from.\n */\nexport interface Manifest {\n readonly name: string;\n readonly env: Readonly<Record<string, Env.Descriptor>>;\n readonly http: { readonly mounts: Readonly<Record<string, string>> };\n readonly digest: string;\n}\n\ntype Value<D extends Env.Descriptor> = D extends { readonly kind: \"secret\" }\n ? Redacted.Redacted<string>\n : D extends { readonly kind: \"literals\"; readonly values: infer L }\n ? L extends ReadonlyArray<infer V>\n ? V\n : never\n : string;\n\n/**\n * The values a deployment must supply for a manifest's env: secrets as\n * `Redacted`, literals as one of their values, optional variables omittable.\n *\n * ```ts\n * import manifest from \"@tenant/convex/manifest\";\n *\n * const values: Manifest.Values<typeof manifest> = {\n * EMAIL_FROM: \"noreply@example.edu\",\n * RESEND_API_KEY: Redacted.make(key),\n * };\n * ```\n */\nexport type Values<M extends Manifest> = {\n readonly [\n K in keyof M[\"env\"] as M[\"env\"][K][\"optional\"] extends true ? never : K\n ]: Value<M[\"env\"][K]>;\n} & {\n readonly [\n K in keyof M[\"env\"] as M[\"env\"][K][\"optional\"] extends true ? K : never\n ]?: Value<M[\"env\"][K]>;\n};\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Data from "effect/Data";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
3
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
4
4
|
export type MiddlewareAttachment<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = MiddlewareSpec.AnyMiddlewareSpec> = MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec ? {
|
|
5
5
|
readonly spec: MiddlewareSpec_;
|
|
6
6
|
readonly options: [MiddlewareSpec_["~Options"]] extends [never] ? undefined : MiddlewareSpec.Options<MiddlewareSpec_>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareAttachment.d.ts","sourceRoot":"","sources":["../src/MiddlewareAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,cAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"MiddlewareAttachment.d.ts","sourceRoot":"","sources":["../src/MiddlewareAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,oBAAoB,CAC9B,eAAe,SAAS,cAAc,CAAC,iBAAiB,GACtD,cAAc,CAAC,iBAAiB,IAChC,eAAe,SAAS,cAAc,CAAC,iBAAiB,GACxD;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC3D,SAAS,GACT,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7C,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,IAAI,CAAC,eAAe,SAAS,cAAc,CAAC,iBAAiB,IAAI;IAC3E,eAAe,CAAC,UAAU,CAAC;CAC5B,SAAS,CAAC,KAAK,CAAC,GACb,EAAE,GACF,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC;IAC5C,cAAc,EAAE;QACd,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,gBAAgB,EAAE;QACh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X,MAAM;8BACC,MAAM;YA8BlC,CAAC;AAEH,eAAO,MAAM,WAAW,gBACT,aAAa,CAAC,oBAAoB,CAAC,YACtC,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CA2CrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareAttachment.js","names":[],"sources":["../src/MiddlewareAttachment.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\n\nexport type MiddlewareAttachment<\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec =\n MiddlewareSpec.AnyMiddlewareSpec,\n> = MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec\n ? {\n readonly spec: MiddlewareSpec_;\n readonly options: [MiddlewareSpec_[\"~Options\"]] extends [never]\n ? undefined\n : MiddlewareSpec.Options<MiddlewareSpec_>;\n }\n : never;\n\nexport type Args<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec> = [\n MiddlewareSpec_[\"~Options\"],\n] extends [never]\n ? []\n : [options: MiddlewareSpec.Options<MiddlewareSpec_>];\n\nexport type ValidationError = Data.TaggedEnum<{\n InvalidOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n };\n ConflictingSpecs: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n EquivalentOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n}>;\n\nexport const ValidationError = Data.taggedEnum<ValidationError>();\n\nexport const formatValidationError = ValidationError.$match({\n InvalidOptions: ({ middlewareKey, location, attachmentIndex }) =>\n `Middleware \"${middlewareKey}\" has invalid options at attachment ${attachmentIndex + 1} on ${location}`,\n ConflictingSpecs: ({ middlewareKey, location }) =>\n `Different middleware specs share key \"${middlewareKey}\" on ${location}`,\n EquivalentOptions: ({\n middlewareKey,\n location,\n attachmentIndex,\n previousIndex,\n }) =>\n `Middleware \"${middlewareKey}\" has equivalent options at attachments ${previousIndex + 1} and ${attachmentIndex + 1} on ${location}`,\n});\n\nexport const validateAll = (\n attachments: ReadonlyArray<MiddlewareAttachment>,\n location: string,\n): Result.Result<void, ValidationError> => {\n for (const [index, attachment] of attachments.entries()) {\n const schema = attachment.spec.options;\n if (schema !== undefined && !Schema.is(schema)(attachment.options)) {\n return Result.fail(\n ValidationError.InvalidOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n }),\n );\n }\n const equivalent =\n schema === undefined ? undefined : Schema.toEquivalence(schema);\n for (const [previousIndex, previous] of attachments.entries()) {\n if (previousIndex === index) break;\n if (previous.spec.key !== attachment.spec.key) continue;\n if (previous.spec !== attachment.spec) {\n return Result.fail(\n ValidationError.ConflictingSpecs({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n if (\n equivalent === undefined ||\n equivalent(previous.options, attachment.options)\n ) {\n return Result.fail(\n ValidationError.EquivalentOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n }\n }\n return Result.void;\n};\n"],"mappings":";;;;;;;;;;AA2CA,MAAa,kBAAkB,KAAK,WAA4B;AAEhE,MAAa,wBAAwB,gBAAgB,OAAO;CAC1D,iBAAiB,EAAE,eAAe,UAAU,sBAC1C,eAAe,cAAc,sCAAsC,kBAAkB,EAAE,MAAM;CAC/F,mBAAmB,EAAE,eAAe,eAClC,yCAAyC,cAAc,OAAO;CAChE,oBAAoB,EAClB,eACA,UACA,iBACA,oBAEA,eAAe,cAAc,0CAA0C,gBAAgB,EAAE,OAAO,kBAAkB,EAAE,MAAM;AAC9H,CAAC;AAED,MAAa,eACX,aACA,aACyC;CACzC,KAAK,MAAM,CAAC,OAAO,eAAe,YAAY,QAAQ,GAAG;EACvD,MAAM,SAAS,WAAW,KAAK;EAC/B,IAAI,WAAW,KAAA,KAAa,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,WAAW,OAAO,GAC/D,OAAO,OAAO,KACZ,gBAAgB,eAAe;GAC7B,eAAe,WAAW,KAAK;GAC/B;GACA,iBAAiB;EACnB,CAAC,CACH;EAEF,MAAM,aACJ,WAAW,KAAA,IAAY,KAAA,IAAY,OAAO,cAAc,MAAM;EAChE,KAAK,MAAM,CAAC,eAAe,aAAa,YAAY,QAAQ,GAAG;GAC7D,IAAI,kBAAkB,OAAO;GAC7B,IAAI,SAAS,KAAK,QAAQ,WAAW,KAAK,KAAK;GAC/C,IAAI,SAAS,SAAS,WAAW,MAC/B,OAAO,OAAO,KACZ,gBAAgB,iBAAiB;IAC/B,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;GAEF,IACE,eAAe,KAAA,KACf,WAAW,SAAS,SAAS,WAAW,OAAO,GAE/C,OAAO,OAAO,KACZ,gBAAgB,kBAAkB;IAChC,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;EAEJ;CACF;CACA,OAAO,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"MiddlewareAttachment.js","names":[],"sources":["../src/MiddlewareAttachment.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\n\nexport type MiddlewareAttachment<\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec =\n MiddlewareSpec.AnyMiddlewareSpec,\n> = MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec\n ? {\n readonly spec: MiddlewareSpec_;\n readonly options: [MiddlewareSpec_[\"~Options\"]] extends [never]\n ? undefined\n : MiddlewareSpec.Options<MiddlewareSpec_>;\n }\n : never;\n\nexport type Args<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec> = [\n MiddlewareSpec_[\"~Options\"],\n] extends [never]\n ? []\n : [options: MiddlewareSpec.Options<MiddlewareSpec_>];\n\nexport type ValidationError = Data.TaggedEnum<{\n InvalidOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n };\n ConflictingSpecs: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n EquivalentOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n}>;\n\nexport const ValidationError = Data.taggedEnum<ValidationError>();\n\nexport const formatValidationError = ValidationError.$match({\n InvalidOptions: ({ middlewareKey, location, attachmentIndex }) =>\n `Middleware \"${middlewareKey}\" has invalid options at attachment ${attachmentIndex + 1} on ${location}`,\n ConflictingSpecs: ({ middlewareKey, location }) =>\n `Different middleware specs share key \"${middlewareKey}\" on ${location}`,\n EquivalentOptions: ({\n middlewareKey,\n location,\n attachmentIndex,\n previousIndex,\n }) =>\n `Middleware \"${middlewareKey}\" has equivalent options at attachments ${previousIndex + 1} and ${attachmentIndex + 1} on ${location}`,\n});\n\nexport const validateAll = (\n attachments: ReadonlyArray<MiddlewareAttachment>,\n location: string,\n): Result.Result<void, ValidationError> => {\n for (const [index, attachment] of attachments.entries()) {\n const schema = attachment.spec.options;\n if (schema !== undefined && !Schema.is(schema)(attachment.options)) {\n return Result.fail(\n ValidationError.InvalidOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n }),\n );\n }\n const equivalent =\n schema === undefined ? undefined : Schema.toEquivalence(schema);\n for (const [previousIndex, previous] of attachments.entries()) {\n if (previousIndex === index) break;\n if (previous.spec.key !== attachment.spec.key) continue;\n if (previous.spec !== attachment.spec) {\n return Result.fail(\n ValidationError.ConflictingSpecs({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n if (\n equivalent === undefined ||\n equivalent(previous.options, attachment.options)\n ) {\n return Result.fail(\n ValidationError.EquivalentOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n }\n }\n return Result.void;\n};\n"],"mappings":";;;;;;;;;;AA2CA,MAAa,kBAAkB,KAAK,WAA4B;AAEhE,MAAa,wBAAwB,gBAAgB,OAAO;CAC1D,iBAAiB,EAAE,eAAe,UAAU,sBAC1C,eAAe,cAAc,sCAAsC,kBAAkB,EAAE,MAAM;CAC/F,mBAAmB,EAAE,eAAe,eAClC,yCAAyC,cAAc,OAAO;CAChE,oBAAoB,EAClB,eACA,UACA,iBACA,oBAEA,eAAe,cAAc,0CAA0C,gBAAgB,EAAE,OAAO,kBAAkB,EAAE,MAAM;AAC9H,CAAC;AAED,MAAa,eACX,aACA,aACyC;CACzC,KAAK,MAAM,CAAC,OAAO,eAAe,YAAY,QAAQ,GAAG;EACvD,MAAM,SAAS,WAAW,KAAK;EAC/B,IAAI,WAAW,KAAA,KAAa,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,WAAW,OAAO,GAC/D,OAAO,OAAO,KACZ,gBAAgB,eAAe;GAC7B,eAAe,WAAW,KAAK;GAC/B;GACA,iBAAiB;EACnB,CAAC,CACH;EAEF,MAAM,aACJ,WAAW,KAAA,IAAY,KAAA,IAAY,OAAO,cAAc,MAAM;EAChE,KAAK,MAAM,CAAC,eAAe,aAAa,YAAY,QAAQ,GAAG;GAC7D,IAAI,kBAAkB,OAAO;GAC7B,IAAI,SAAS,KAAK,QAAQ,WAAW,KAAK,KAAK;GAC/C,IAAI,SAAS,SAAS,WAAW,MAC/B,OAAO,OAAO,KACZ,gBAAgB,iBAAiB;IAC/B,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;GAEF,IACE,eAAe,KAAA,KACf,WAAW,SAAS,SAAS,WAAW,OAAO,GAE/C,OAAO,OAAO,KACZ,gBAAgB,kBAAkB;IAChC,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;EAEJ;CACF;CACA,OAAO,OAAO;AAChB"}
|
package/dist/MiddlewareSpec.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { FunctionType, FunctionVisibility } from "convex/server";
|
|
|
2
2
|
import type * as Effect from "effect/Effect";
|
|
3
3
|
import type * as Schema from "effect/Schema";
|
|
4
4
|
import type { unhandled } from "effect/Types";
|
|
5
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
6
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
7
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
5
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
6
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
7
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
8
8
|
export declare const TypeId = "~@confect/core/MiddlewareSpec";
|
|
9
9
|
export type TypeId = typeof TypeId;
|
|
10
10
|
export declare const isMiddlewareSpec: (u: unknown) => u is AnyMiddlewareSpec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareSpec.d.ts","sourceRoot":"","sources":["../src/MiddlewareSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,KAAK,kBAAkB,MAAM,
|
|
1
|
+
{"version":3,"file":"MiddlewareSpec.d.ts","sourceRoot":"","sources":["../src/MiddlewareSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,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