@gaganref/confect-core 10.3.1-fork.26 → 10.3.1-fork.27

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.
@@ -0,0 +1,18 @@
1
+ import * as Context from "effect/Context";
2
+ import type * as Effect from "effect/Effect";
3
+ import type * as Schema from "effect/Schema";
4
+ import * as FunctionSpec from "./FunctionSpec.js";
5
+ import * as MiddlewareSpec from "./MiddlewareSpec.js";
6
+ import type * as Ref from "./Ref.js";
7
+ export interface Call {
8
+ <Target extends Ref.AnyQuery | Ref.AnyMutation>(target: Target, ...args: Ref.OptionalArgs<NoInfer<Target>>): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;
9
+ }
10
+ declare const ActionCall_base: Context.ServiceClass<ActionCall, "@confect/core/ActionCall", Call>;
11
+ export declare class ActionCall extends ActionCall_base {
12
+ }
13
+ declare const Middleware_base: MiddlewareSpec.MiddlewareSpec<Middleware, "@confect/core/ActionCall/Middleware", ActionCall, never, never, "action", never>;
14
+ export declare class Middleware extends Middleware_base {
15
+ }
16
+ export declare const profile: FunctionSpec.Extended<import("./Profile.js").NoFields, typeof Middleware, [{}]>;
17
+ export {};
18
+ //# sourceMappingURL=ActionCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionCall.d.ts","sourceRoot":"","sources":["../src/ActionCall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,IAAI;IACnB,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,WAAW,EAC5C,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GACzC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;CAC/E;;AAED,qBAAa,UAAW,SAAQ,eAE/B;CAAG;;AACJ,qBAAa,UAAW,SAAQ,eAK9B;CAAG;AAEL,eAAO,MAAM,OAAO,iFAAsD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { MiddlewareSpec } from "./MiddlewareSpec.js";
3
+ import { extend } from "./FunctionSpec.js";
4
+ import * as Context from "effect/Context";
5
+ //#region src/ActionCall.ts
6
+ var ActionCall_exports = /* @__PURE__ */ __exportAll({
7
+ ActionCall: () => ActionCall,
8
+ Middleware: () => Middleware,
9
+ profile: () => profile
10
+ });
11
+ var ActionCall = class extends Context.Service()("@confect/core/ActionCall") {};
12
+ var Middleware = class extends MiddlewareSpec()("@confect/core/ActionCall/Middleware", { functionTypes: {
13
+ query: false,
14
+ mutation: false,
15
+ action: true
16
+ } }) {};
17
+ const profile = extend()({ middleware: [Middleware] });
18
+ //#endregion
19
+ export { ActionCall, ActionCall_exports, Middleware, profile };
20
+
21
+ //# sourceMappingURL=ActionCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionCall.js","names":["MiddlewareSpec.MiddlewareSpec","FunctionSpec.extend"],"sources":["../src/ActionCall.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport type * as Effect from \"effect/Effect\";\nimport type * as Schema from \"effect/Schema\";\nimport * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as Ref from \"./Ref.js\";\n\nexport interface Call {\n <Target extends Ref.AnyQuery | Ref.AnyMutation>(\n target: Target,\n ...args: Ref.OptionalArgs<NoInfer<Target>>\n ): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;\n}\n\nexport class ActionCall extends Context.Service<ActionCall, Call>()(\n \"@confect/core/ActionCall\",\n) {}\nexport class Middleware extends MiddlewareSpec.MiddlewareSpec<\n Middleware,\n { provides: ActionCall }\n>()(\"@confect/core/ActionCall/Middleware\", {\n functionTypes: { query: false, mutation: false, action: true },\n}) {}\n\nexport const profile = FunctionSpec.extend()({ middleware: [Middleware] });\n"],"mappings":";;;;;;;;;;AAcA,IAAa,aAAb,cAAgC,QAAQ,QAA0B,CAAC,CACjE,0BACF,CAAC,CAAC,CAAC;AACH,IAAa,aAAb,cAAgCA,eAG9B,CAAC,CAAC,uCAAuC,EACzC,eAAe;CAAE,OAAO;CAAO,UAAU;CAAO,QAAQ;AAAK,EAC/D,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,UAAUC,OAAoB,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Callback.d.ts","sourceRoot":"","sources":["../src/Callback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAE3E,eAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,QAAA,MAAM,YAAY,mCAAmC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAEvC;;;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AG,CAAC,GAAG,IAAI;IAC/D,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,SAAS,CAAC,KAAK,CAAC,GACb,OAAO,GACP;IAAE,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;CAAE,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,GAAG,CAAC,GAAG,OACtC,IAAI,KACR,wBAAwB,CACzB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EACzB,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAC/B,WAAW,CAAC,IAAI,CAAC,EACjB,cAAc,CAAC,IAAI,CAAC,CACqB,CAAC"}
package/dist/Callback.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { Confect } from "./FunctionProvenance.js";
3
3
  import { fromProvenance, getFunctionReference, isRef } from "./Ref.js";
4
- import * as Predicate from "effect/Predicate";
5
4
  import * as Schema from "effect/Schema";
5
+ import * as Predicate from "effect/Predicate";
6
6
  import * as SchemaGetter from "effect/SchemaGetter";
7
7
  //#region src/Callback.ts
8
8
  var Callback_exports = /* @__PURE__ */ __exportAll({
@@ -27,7 +27,7 @@ const query = make("query");
27
27
  const mutation = make("mutation");
28
28
  const action = make("action");
29
29
  const isHandleOf = (contract) => (value) => isRef(value) && Predicate.hasProperty(value, HandleTypeId) && value[HandleTypeId] === contract.id;
30
- const fromText = (contract, text) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text), { [HandleTypeId]: contract.id });
30
+ const fromText = (contract, text) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text, contract.functionType), { [HandleTypeId]: contract.id });
31
31
  /**
32
32
  * The schema of a handle for `contract`: a string on the wire, a runnable ref
33
33
  * once decoded. Use it in a component's function args or tables.
@@ -1 +1 @@
1
- {"version":3,"file":"Callback.js","names":["FunctionProvenance.Confect","Ref.isRef","Ref.fromProvenance","Ref.getFunctionReference"],"sources":["../src/Callback.ts"],"sourcesContent":["import type {\n FunctionReference,\n FunctionReference_future,\n FunctionType,\n} from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Callback\";\nexport type TypeId = typeof TypeId;\n\nconst HandleTypeId = \"~@confect/core/Callback/Handle\";\n\n/**\n * A contract's id, `\"<component>/<event>\"`.\n */\nexport type Id = `${string}/${string}`;\n\n/**\n * A function a component calls back into its host, declared by the component:\n * the args it sends and the returns and errors it accepts. A host proves that\n * one of its functions satisfies the contract when it creates a handle.\n */\nexport interface Contract<\n Id_ extends Id,\n FunctionType_ extends FunctionType,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n> {\n readonly [TypeId]: TypeId;\n readonly id: Id_;\n readonly functionType: FunctionType_;\n readonly functionProvenance: FunctionProvenance.Confect<\n ArgsFields_,\n Returns_,\n Error_,\n FunctionProvenance.Standard\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly id: Id;\n readonly functionType: FunctionType;\n readonly functionProvenance: FunctionProvenance.AnyConfect;\n}\n\nexport const isContract = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\ntype ArgsFields<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n }\n ? ArgsFields_\n : never;\n\ntype ReturnsSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"][\"returns\"];\n\ntype ErrorSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly error?: infer ErrorSchema_;\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<Contract_ extends Any> = Schema.Struct.Type<\n ArgsFields<Contract_>\n>;\n\nexport type Returns<Contract_ extends Any> = ReturnsSchema<Contract_>[\"Type\"];\n\nexport type Error<Contract_ extends Any> = ErrorSchema<Contract_>[\"Type\"];\n\n/**\n * A host function a component received for a contract. It is a ref, so the\n * runners and the scheduler run it with the contract's codecs, and declared\n * errors arrive by tag.\n */\nexport type Handle<Contract_ extends Any> = Ref.ConfectRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n {\n readonly runtime: \"Convex\";\n readonly functionType: Contract_[\"functionType\"];\n }\n >,\n \"internal\",\n ArgsFields<Contract_>,\n ReturnsSchema<Contract_>,\n ErrorSchema<Contract_>\n> & { readonly [HandleTypeId]: Contract_[\"id\"] };\n\nconst make =\n <FunctionType_ extends FunctionType>(functionType: FunctionType_) =>\n <\n const Id_ extends Id,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = {},\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n id: Id_,\n options: {\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n },\n ): Contract<Id_, FunctionType_, ArgsFields_, Returns_, Error_> => ({\n [TypeId]: TypeId,\n id,\n functionType,\n functionProvenance: FunctionProvenance.Confect(\n options.args ?? (() => ({}) as ArgsFields_),\n options.returns,\n options.error,\n ),\n });\n\nexport const query = make(\"query\");\nexport const mutation = make(\"mutation\");\nexport const action = make(\"action\");\n\nconst isHandleOf =\n <Contract_ extends Any>(contract: Contract_) =>\n (value: unknown): value is Handle<Contract_> =>\n Ref.isRef(value) &&\n Predicate.hasProperty(value, HandleTypeId) &&\n value[HandleTypeId] === contract.id;\n\nconst fromText = <Contract_ extends Any>(\n contract: Contract_,\n text: string,\n): Handle<Contract_> =>\n Object.assign(\n Ref.fromProvenance(\n text,\n contract.functionProvenance,\n [],\n // Convex types a handle as a string that is also a function reference.\n text as unknown as FunctionReference<any, any>,\n ),\n { [HandleTypeId]: contract.id },\n ) as unknown as Handle<Contract_>;\n\n/**\n * The schema of a handle for `contract`: a string on the wire, a runnable ref\n * once decoded. Use it in a component's function args or tables.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.pipe(\n Schema.decodeTo(\n Schema.declare(isHandleOf(contract), {\n identifier: `Callback.Handle<${contract.id}>`,\n }),\n {\n decode: SchemaGetter.transform((text: string) =>\n fromText(contract, text),\n ),\n encode: SchemaGetter.transform(\n (ref: Handle<Contract_>) => ref.convexFunctionName,\n ),\n },\n ),\n );\n\ntype EncodedArgs<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? Schema.Struct.Encoded<ArgsFields_>\n : Ref.Args<Ref_>;\n\ntype EncodedReturns<Ref_> = Ref_ extends { readonly _tag: \"Confect\" }\n ? Ref.ReturnsSchema<Ref_>[\"Encoded\"]\n : Ref.Returns<Ref_>;\n\ntype IsAny<A> = 0 extends 1 & A ? true : false;\n\n/**\n * A Confect ref typed from values alone, such as a bound component's ref, has\n * no codec types left to compare, and middleware attachments typed without\n * their specs erase their errors. True when any variant of `Ref_` is erased.\n */\ntype IsErased<Ref_> = true extends (\n Ref_ extends { readonly _tag: \"Confect\" }\n ? IsAny<Ref.ReturnsSchema<Ref_>[\"Encoded\"]> | IsAny<Ref.EncodedError<Ref_>>\n : false\n)\n ? true\n : false;\n\n/**\n * The shape a value has on the wire: a component's ID brands become `string`,\n * since the contract cannot name the host's scope, while the host's own IDs\n * keep their table. Arrays and tuples lose `readonly`, and an optional field is\n * the same whether or not it admits `undefined`, which Convex never transmits.\n * `unknown` stays `unknown`.\n */\ntype WireShape<A> = unknown extends A\n ? A\n : A extends { readonly \"~@confect/core/ScopedId\": unknown }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { -readonly [Key in keyof A]: WireShape<Exclude<A[Key], undefined>> };\n\ntype Identical<A, B> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2\n ? true\n : false;\n\ntype FirstOf<Checks extends ReadonlyArray<unknown>> = Checks extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? [Head] extends [never]\n ? FirstOf<Rest>\n : Head\n : never;\n\n/**\n * Every obligation a host ref owes a contract, in the order they are reported.\n * Each is `never` when it holds.\n */\ntype Obligations<Contract_ extends Any, Ref_ extends Ref.Any> = [\n IsErased<Ref_> extends true\n ? `the ref's codecs are erased, so its encoding cannot be checked against \"${Contract_[\"id\"]}\"; pass the host's generated ref`\n : never,\n [Ref.GetFunctionType<Ref_>] extends [Contract_[\"functionType\"]]\n ? never\n : `\"${Contract_[\"id\"]}\" needs a ${Contract_[\"functionType\"]}, not a ${Ref.GetFunctionType<Ref_>}`,\n Identical<\n WireShape<EncodedArgs<Handle<Contract_>>>,\n WireShape<EncodedArgs<Ref_>>\n > extends true\n ? never\n : `the ref's encoded args differ from the args \"${Contract_[\"id\"]}\" sends`,\n Identical<\n WireShape<EncodedReturns<Handle<Contract_>>>,\n WireShape<EncodedReturns<Ref_>>\n > extends true\n ? never\n : `the ref's returns are encoded differently from the returns of \"${Contract_[\"id\"]}\"`,\n [Ref.Error<Ref_>] extends [Error<Contract_>]\n ? never\n : `the ref fails with errors \"${Contract_[\"id\"]}\" does not declare`,\n [WireShape<Ref.EncodedError<Ref_>>] extends [\n WireShape<Ref.EncodedError<Handle<Contract_>>>,\n ]\n ? never\n : `the ref's errors are encoded differently from the errors of \"${Contract_[\"id\"]}\"`,\n];\n\ntype Mismatch<Contract_ extends Any, Ref_ extends Ref.Any> = FirstOf<\n Obligations<Contract_, Ref_>\n>;\n\n/**\n * `unknown` when host ref `Ref_` satisfies `Contract_` as far as its types\n * show, otherwise an object type naming the first mismatch. The check compares\n * the types that cross the wire, with a component's IDs compared as strings.\n * The host's encoded args and returns must equal the contract's, and its\n * encoded errors (middleware errors included) must be ones the contract's\n * codecs decode. A ref whose codecs are erased cannot be checked and is\n * refused. Types miss what only the validators show, such as field names behind\n * a `Record` type, so `Callback.create` in `@confect/server` also compares the\n * compiled validators before it creates a handle.\n */\nexport type Check<Contract_ extends Any, Ref_ extends Ref.Any> = [\n Mismatch<Contract_, Ref_>,\n] extends [never]\n ? unknown\n : { readonly \"~CallbackMismatch\": Mismatch<Contract_, Ref_> };\n\n/**\n * View a ref as Convex's `FunctionReference_future`, typed with its wire args\n * and returns, for `createFunctionHandle` and clients that accept it.\n */\nexport const toFuture = <Ref_ extends Ref.Any>(\n ref: Ref_,\n): FunctionReference_future<\n Ref.GetFunctionType<Ref_>,\n Ref.GetFunctionVisibility<Ref_>,\n EncodedArgs<Ref_>,\n EncodedReturns<Ref_>\n> => Ref.getFunctionReference(ref) as never;\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,MAAa,SAAS;AAGtB,MAAM,eAAe;AAqCrB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAA,yBAAS,KAAK,EAAA,+BAAA;AA+CtC,MAAM,QACiC,kBAOnC,IACA,aAKiE;EAChE,SAAS;CACV;CACA;CACA,oBAAoBA,QAClB,QAAQ,gBAAgB,CAAC,KACzB,QAAQ,SACR,QAAQ,KACV;AACF;AAEF,MAAa,QAAQ,KAAK,OAAO;AACjC,MAAa,WAAW,KAAK,UAAU;AACvC,MAAa,SAAS,KAAK,QAAQ;AAEnC,MAAM,cACoB,cACvB,UACCC,MAAU,KAAK,KACf,UAAU,YAAY,OAAO,YAAY,KACzC,MAAM,kBAAkB,SAAS;AAErC,MAAM,YACJ,UACA,SAEA,OAAO,OACLC,eACE,MACA,SAAS,oBACT,CAAC,GAED,IACF,GACA,GAAG,eAAe,SAAS,GAAG,CAChC;;;;;AAMF,MAAa,UACX,aAEA,OAAO,OAAO,KACZ,OAAO,SACL,OAAO,QAAQ,WAAW,QAAQ,GAAG,EACnC,YAAY,mBAAmB,SAAS,GAAG,GAC7C,CAAC,GACD;CACE,QAAQ,aAAa,WAAW,SAC9B,SAAS,UAAU,IAAI,CACzB;CACA,QAAQ,aAAa,WAClB,QAA2B,IAAI,kBAClC;AACF,CACF,CACF;;;;;AA4HF,MAAa,YACX,QAMGC,qBAAyB,GAAG"}
1
+ {"version":3,"file":"Callback.js","names":["FunctionProvenance.Confect","Ref.isRef","Ref.fromProvenance","Ref.getFunctionReference"],"sources":["../src/Callback.ts"],"sourcesContent":["import type {\n FunctionReference,\n FunctionReference_future,\n FunctionType,\n} from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Callback\";\nexport type TypeId = typeof TypeId;\n\nconst HandleTypeId = \"~@confect/core/Callback/Handle\";\n\n/**\n * A contract's id, `\"<component>/<event>\"`.\n */\nexport type Id = `${string}/${string}`;\n\n/**\n * A function a component calls back into its host, declared by the component:\n * the args it sends and the returns and errors it accepts. A host proves that\n * one of its functions satisfies the contract when it creates a handle.\n */\nexport interface Contract<\n Id_ extends Id,\n FunctionType_ extends FunctionType,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n> {\n readonly [TypeId]: TypeId;\n readonly id: Id_;\n readonly functionType: FunctionType_;\n readonly functionProvenance: FunctionProvenance.Confect<\n ArgsFields_,\n Returns_,\n Error_,\n FunctionProvenance.Standard\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly id: Id;\n readonly functionType: FunctionType;\n readonly functionProvenance: FunctionProvenance.AnyConfect;\n}\n\nexport const isContract = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\ntype ArgsFields<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n }\n ? ArgsFields_\n : never;\n\ntype ReturnsSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"][\"returns\"];\n\ntype ErrorSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly error?: infer ErrorSchema_;\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<Contract_ extends Any> = Schema.Struct.Type<\n ArgsFields<Contract_>\n>;\n\nexport type Returns<Contract_ extends Any> = ReturnsSchema<Contract_>[\"Type\"];\n\nexport type Error<Contract_ extends Any> = ErrorSchema<Contract_>[\"Type\"];\n\n/**\n * A host function a component received for a contract. It is a ref, so the\n * runners and the scheduler run it with the contract's codecs, and declared\n * errors arrive by tag.\n */\nexport type Handle<Contract_ extends Any> = Ref.ConfectRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n {\n readonly runtime: \"Convex\";\n readonly functionType: Contract_[\"functionType\"];\n }\n >,\n \"internal\",\n ArgsFields<Contract_>,\n ReturnsSchema<Contract_>,\n ErrorSchema<Contract_>\n> & { readonly [HandleTypeId]: Contract_[\"id\"] };\n\nconst make =\n <FunctionType_ extends FunctionType>(functionType: FunctionType_) =>\n <\n const Id_ extends Id,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = {},\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n id: Id_,\n options: {\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n },\n ): Contract<Id_, FunctionType_, ArgsFields_, Returns_, Error_> => ({\n [TypeId]: TypeId,\n id,\n functionType,\n functionProvenance: FunctionProvenance.Confect(\n options.args ?? (() => ({}) as ArgsFields_),\n options.returns,\n options.error,\n ),\n });\n\nexport const query = make(\"query\");\nexport const mutation = make(\"mutation\");\nexport const action = make(\"action\");\n\nconst isHandleOf =\n <Contract_ extends Any>(contract: Contract_) =>\n (value: unknown): value is Handle<Contract_> =>\n Ref.isRef(value) &&\n Predicate.hasProperty(value, HandleTypeId) &&\n value[HandleTypeId] === contract.id;\n\nconst fromText = <Contract_ extends Any>(\n contract: Contract_,\n text: string,\n): Handle<Contract_> =>\n Object.assign(\n Ref.fromProvenance(\n text,\n contract.functionProvenance,\n [],\n // Convex types a handle as a string that is also a function reference.\n text as unknown as FunctionReference<any, any>,\n contract.functionType,\n ),\n { [HandleTypeId]: contract.id },\n ) as unknown as Handle<Contract_>;\n\n/**\n * The schema of a handle for `contract`: a string on the wire, a runnable ref\n * once decoded. Use it in a component's function args or tables.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.pipe(\n Schema.decodeTo(\n Schema.declare(isHandleOf(contract), {\n identifier: `Callback.Handle<${contract.id}>`,\n }),\n {\n decode: SchemaGetter.transform((text: string) =>\n fromText(contract, text),\n ),\n encode: SchemaGetter.transform(\n (ref: Handle<Contract_>) => ref.convexFunctionName,\n ),\n },\n ),\n );\n\ntype EncodedArgs<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? Schema.Struct.Encoded<ArgsFields_>\n : Ref.Args<Ref_>;\n\ntype EncodedReturns<Ref_> = Ref_ extends { readonly _tag: \"Confect\" }\n ? Ref.ReturnsSchema<Ref_>[\"Encoded\"]\n : Ref.Returns<Ref_>;\n\ntype IsAny<A> = 0 extends 1 & A ? true : false;\n\n/**\n * A Confect ref typed from values alone, such as a bound component's ref, has\n * no codec types left to compare, and middleware attachments typed without\n * their specs erase their errors. True when any variant of `Ref_` is erased.\n */\ntype IsErased<Ref_> = true extends (\n Ref_ extends { readonly _tag: \"Confect\" }\n ? IsAny<Ref.ReturnsSchema<Ref_>[\"Encoded\"]> | IsAny<Ref.EncodedError<Ref_>>\n : false\n)\n ? true\n : false;\n\n/**\n * The shape a value has on the wire: a component's ID brands become `string`,\n * since the contract cannot name the host's scope, while the host's own IDs\n * keep their table. Arrays and tuples lose `readonly`, and an optional field is\n * the same whether or not it admits `undefined`, which Convex never transmits.\n * `unknown` stays `unknown`.\n */\ntype WireShape<A> = unknown extends A\n ? A\n : A extends { readonly \"~@confect/core/ScopedId\": unknown }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { -readonly [Key in keyof A]: WireShape<Exclude<A[Key], undefined>> };\n\ntype Identical<A, B> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2\n ? true\n : false;\n\ntype FirstOf<Checks extends ReadonlyArray<unknown>> = Checks extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? [Head] extends [never]\n ? FirstOf<Rest>\n : Head\n : never;\n\n/**\n * Every obligation a host ref owes a contract, in the order they are reported.\n * Each is `never` when it holds.\n */\ntype Obligations<Contract_ extends Any, Ref_ extends Ref.Any> = [\n IsErased<Ref_> extends true\n ? `the ref's codecs are erased, so its encoding cannot be checked against \"${Contract_[\"id\"]}\"; pass the host's generated ref`\n : never,\n [Ref.GetFunctionType<Ref_>] extends [Contract_[\"functionType\"]]\n ? never\n : `\"${Contract_[\"id\"]}\" needs a ${Contract_[\"functionType\"]}, not a ${Ref.GetFunctionType<Ref_>}`,\n Identical<\n WireShape<EncodedArgs<Handle<Contract_>>>,\n WireShape<EncodedArgs<Ref_>>\n > extends true\n ? never\n : `the ref's encoded args differ from the args \"${Contract_[\"id\"]}\" sends`,\n Identical<\n WireShape<EncodedReturns<Handle<Contract_>>>,\n WireShape<EncodedReturns<Ref_>>\n > extends true\n ? never\n : `the ref's returns are encoded differently from the returns of \"${Contract_[\"id\"]}\"`,\n [Ref.Error<Ref_>] extends [Error<Contract_>]\n ? never\n : `the ref fails with errors \"${Contract_[\"id\"]}\" does not declare`,\n [WireShape<Ref.EncodedError<Ref_>>] extends [\n WireShape<Ref.EncodedError<Handle<Contract_>>>,\n ]\n ? never\n : `the ref's errors are encoded differently from the errors of \"${Contract_[\"id\"]}\"`,\n];\n\ntype Mismatch<Contract_ extends Any, Ref_ extends Ref.Any> = FirstOf<\n Obligations<Contract_, Ref_>\n>;\n\n/**\n * `unknown` when host ref `Ref_` satisfies `Contract_` as far as its types\n * show, otherwise an object type naming the first mismatch. The check compares\n * the types that cross the wire, with a component's IDs compared as strings.\n * The host's encoded args and returns must equal the contract's, and its\n * encoded errors (middleware errors included) must be ones the contract's\n * codecs decode. A ref whose codecs are erased cannot be checked and is\n * refused. Types miss what only the validators show, such as field names behind\n * a `Record` type, so `Callback.create` in `@confect/server` also compares the\n * compiled validators before it creates a handle.\n */\nexport type Check<Contract_ extends Any, Ref_ extends Ref.Any> = [\n Mismatch<Contract_, Ref_>,\n] extends [never]\n ? unknown\n : { readonly \"~CallbackMismatch\": Mismatch<Contract_, Ref_> };\n\n/**\n * View a ref as Convex's `FunctionReference_future`, typed with its wire args\n * and returns, for `createFunctionHandle` and clients that accept it.\n */\nexport const toFuture = <Ref_ extends Ref.Any>(\n ref: Ref_,\n): FunctionReference_future<\n Ref.GetFunctionType<Ref_>,\n Ref.GetFunctionVisibility<Ref_>,\n EncodedArgs<Ref_>,\n EncodedReturns<Ref_>\n> => Ref.getFunctionReference(ref) as never;\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,MAAa,SAAS;AAGtB,MAAM,eAAe;AAqCrB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAA,yBAAS,KAAK,EAAA,+BAAA;AA+CtC,MAAM,QACiC,kBAOnC,IACA,aAKiE;EAChE,SAAS;CACV;CACA;CACA,oBAAoBA,QAClB,QAAQ,gBAAgB,CAAC,KACzB,QAAQ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EAC1B,MAAM,SAAS,MAAM,EACrB,KAAK,CAAC,KAAK,SAAS,MAAM,aAEf;IACT,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE;QACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KACxC,CAAC;CACH,SACM,KAAK,+FAC+C,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,MAAM,GACjB,IAAI,SAAS,OAAO,CAAC,OAAO,EAC5B,EAAE,SAAS,OAAO,CAAC,OAAO,EAC1B,OAAO,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,aAE3B;IACT,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAA;KAAE,CAAC;CACrE,SACM,OAAO,8CAMb,CAAC"}
package/dist/Component.js CHANGED
@@ -119,7 +119,7 @@ const bind = (component, native, options) => {
119
119
  return fromProvenance(ref.convexFunctionName, provenance, Array.map(ref.middlewareAttachments, (attachment) => ({
120
120
  ...attachment,
121
121
  spec: rebaseMiddleware(attachment.spec)
122
- })), nativeRef);
122
+ })), nativeRef, ref.functionType);
123
123
  }), Match.exhaustive);
124
124
  } else return visit(child, reference);
125
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","names":["Spec.groups","Ref.make","IdScope.instance","IdScope.app","rebase","GenericId.rebase","Ref.isRef","Ref.fromProvenance","GenericId.GenericId"],"sources":["../src/Component.ts"],"sourcesContent":["import type { DefaultFunctionArgs, FunctionReference } from \"convex/server\";\nimport { getFunctionAddress } from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport { memoize, pipe } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as GenericId from \"./GenericId.js\";\nimport type * as GroupSpec from \"./GroupSpec.js\";\nimport * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as Refs from \"./Refs.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\nimport * as Spec from \"./Spec.js\";\n\nexport class EmptyComponentScopeError extends Data.TaggedError(\n \"EmptyComponentScopeError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"A component contract requires a nonempty definition scope.\";\n }\n}\n\nexport class ComponentNameCollisionError extends Data.TaggedError(\n \"ComponentNameCollisionError\",\n)<{\n readonly groupPath: string;\n readonly functionName: string;\n}> {\n override get message(): string {\n return `Group and function at same level have same name ('${this.groupPath}:${this.functionName}')`;\n }\n}\n\nexport class UninstalledComponentReferenceError extends Data.TaggedError(\n \"UninstalledComponentReferenceError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"Component.bind expects an installed component from the generated components registry.\";\n }\n}\n\nconst validateNames = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n): Result.Result<void, ComponentNameCollisionError> => {\n for (const [name, group] of Record.toEntries(groups)) {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n for (const functionSpec of Record.values(group.functions)) {\n if (Record.has(group.groups, functionSpec.name)) {\n return Result.fail(\n new ComponentNameCollisionError({\n groupPath: path,\n functionName: functionSpec.name,\n }),\n );\n }\n }\n const nested = validateNames(group.groups, path);\n if (Result.isFailure(nested)) return nested;\n }\n return Result.succeed(undefined);\n};\n\nconst validateContract = (\n scope: IdScope.IdScope,\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n): Result.Result<\n void,\n EmptyComponentScopeError | ComponentNameCollisionError\n> =>\n scope === \"\"\n ? Result.fail(new EmptyComponentScopeError({ definitionScope: scope }))\n : validateNames(groups);\n\nconst TypeId = \"~@confect/core/Component\";\nconst BoundTypeId = \"~@confect/core/BoundComponent\";\n\n/**\n * Convex's generated ComponentApi erases database ID brands at the boundary.\n */\ntype Wire<A> = A extends { readonly __tableName: string }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { [K in keyof A]: Wire<A[K]> };\n\ntype OmitEmpty<A> = {\n [K in keyof A as keyof A[K] extends never ? never : K]: A[K];\n};\ntype ApiGroups<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = OmitEmpty<{\n [GroupName in GroupSpec.Name<GroupSpec_>]: ApiGroup<\n GroupSpec.WithName<GroupSpec_, GroupName>,\n Name\n >;\n}>;\ntype ApiGroup<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = ApiGroups<GroupSpec.Groups<GroupSpec_>, Name> & {\n [\n FunctionSpec_ in GroupSpec.Functions<GroupSpec_> as FunctionSpec.GetFunctionVisibility<FunctionSpec_> extends \"public\"\n ? FunctionSpec.Name<FunctionSpec_>\n : never\n ]: FunctionReference<\n RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n >,\n \"internal\",\n Extract<Wire<FunctionSpec.EncodedArgs<FunctionSpec_>>, DefaultFunctionArgs>,\n Wire<FunctionSpec.EncodedReturns<FunctionSpec_>>,\n Name\n >;\n};\n\nexport type Api<\n Spec_ extends Spec.AnyWithProps,\n Name extends string | undefined = string | undefined,\n> = ApiGroups<Spec.Groups<Spec_>, Name>;\n\ninterface Tree {\n readonly [key: string]: Tree | Ref.Any;\n}\n\nexport interface Component<\n Spec_ extends Spec.AnyWithProps,\n Scope extends IdScope.IdScope,\n Tables extends string = string,\n> {\n readonly [TypeId]: {\n readonly refs: Tree;\n readonly scope: Scope;\n readonly tables: ReadonlyArray<Tables>;\n };\n readonly \"~Spec\": Spec_;\n}\n\n/**\n * An opaque identity: its string representation is not part of the API.\n */\nexport type MountScope<\n Parent extends IdScope.IdScope,\n Name extends string | undefined,\n> = IdScope.Mount<Parent, Name>;\n\ntype MountName<ComponentApi> =\n ComponentApi extends FunctionReference<any, any, any, any, infer Name>\n ? Name\n : ComponentApi extends object\n ? {\n [Key in keyof ComponentApi]: MountName<ComponentApi[Key]>;\n }[keyof ComponentApi]\n : never;\n\ntype BindRefs<\n RefTree,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RefTree extends Ref.Any\n ? RefTree extends { readonly _tag: \"Convex\" }\n ? Ref.ConvexRef<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<Wire<Ref.Args<RefTree>>, DefaultFunctionArgs>,\n Wire<Ref.Returns<RefTree>>\n >\n : Extract<\n Ref.Ref<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<\n GenericId.Rebase<Ref.Args<RefTree>, From, To>,\n DefaultFunctionArgs\n >,\n GenericId.Rebase<Ref.Returns<RefTree>, From, To>,\n GenericId.Rebase<Ref.Error<RefTree>, From, To>\n >,\n { readonly _tag: RefTree[\"_tag\"] }\n >\n : { [Key in keyof RefTree]: BindRefs<RefTree[Key], From, To> };\n\nexport type Bound<\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n> = BindRefs<Refs.Refs<Spec_, Ref.AnyPublic>, From, To> & {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n};\n\n/**\n * Build a publishable contract containing only exported functions and codecs.\n */\nexport const make = <\n Spec_ extends Spec.AnyWithProps,\n const Scope extends IdScope.IdScope,\n const Tables extends string,\n>(\n spec: Spec_,\n scope: Scope,\n tables: ReadonlyArray<Tables>,\n): Component<Spec_, Scope, Tables> => {\n const specGroups = Spec.groups(spec);\n Result.getOrThrow(validateContract(scope, specGroups));\n const collect = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n ): Tree =>\n pipe(\n groups,\n Record.map((group, name) => {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n const functions = pipe(\n group.functions,\n Record.filter((functionSpec) => {\n return Match.value(functionSpec.functionVisibility).pipe(\n Match.when(\"public\", () => true),\n Match.when(\"internal\", () => false),\n Match.exhaustive,\n );\n }),\n Record.map((functionSpec) =>\n Ref.make(path, functionSpec, group.middlewareAttachments),\n ),\n );\n return { ...collect(group.groups, path), ...functions };\n }),\n Record.filter((children) => !Record.isEmptyRecord(children)),\n );\n return {\n [TypeId]: { refs: collect(specGroups), scope, tables },\n } as Component<Spec_, Scope, Tables>;\n};\n\n/**\n * Bind the published contract to an actual installed component reference.\n */\nexport const bind = <\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n Tables extends string,\n Native extends Api<NoInfer<Spec_>>,\n const Parent extends IdScope.IdScope = IdScope.App,\n>(\n component: Component<Spec_, From, Tables>,\n native: Native,\n options?: { readonly parentScope: Parent },\n): Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n> => {\n const contract = component[TypeId];\n const address = getFunctionAddress(native);\n const installedReference = Result.getOrThrow(\n Result.fromNullishOr(\n address.reference,\n () =>\n new UninstalledComponentReferenceError({\n definitionScope: contract.scope,\n }),\n ),\n );\n // Preserve the opaque address as an identity only. Calls retain the native\n // references; no component address is constructed or parsed for routing.\n const scope = IdScope.instance(\n options?.parentScope ?? IdScope.app,\n installedReference,\n );\n const rebase = (schema: Schema.ConstraintCodec<any, any, never, never>) =>\n GenericId.rebase(schema, contract.scope, scope);\n const rebaseMiddleware = memoize(\n (middleware: MiddlewareSpec.AnyMiddlewareSpec) => {\n if (!(\"error\" in middleware)) return middleware;\n const boundMiddleware = Object.create(\n middleware,\n ) as MiddlewareSpec.AnyMiddlewareSpec;\n Lazy.defineProperty(boundMiddleware, \"error\", () => {\n const error = middleware.error;\n return error === undefined ? undefined : rebase(error);\n });\n return boundMiddleware;\n },\n );\n const visit = (tree: Tree, references: unknown): Tree =>\n Record.map(tree, (child, key) => {\n const reference = (references as Record<string, unknown>)[key];\n if (Ref.isRef(child)) {\n const nativeRef = reference as FunctionReference<any, any>;\n return Match.value(child).pipe(\n Match.tag(\"Convex\", (ref) => ({\n ...ref,\n functionReference: nativeRef,\n })),\n Match.tag(\"Confect\", (ref) => {\n const provenance = {\n _tag: \"Confect\" as const,\n kind: Match.value(ref.kind).pipe(\n Match.tag(\"Standard\", (kind) => kind),\n Match.tag(\"Paginated\", (kind) => {\n const boundKind = { _tag: \"Paginated\" as const };\n Lazy.defineProperty(boundKind, \"userArgs\", () =>\n Schema.Struct(Record.map(kind.userArgs.fields, rebase)),\n );\n Lazy.defineProperty(boundKind, \"item\", () =>\n rebase(kind.item),\n );\n Lazy.defineProperty(boundKind, \"page\", () =>\n rebase(kind.page),\n );\n return boundKind as FunctionProvenance.Paginated;\n }),\n Match.exhaustive,\n ),\n };\n Lazy.defineProperty(provenance, \"args\", () =>\n Schema.Struct(Record.map(ref.args.fields, rebase)),\n );\n Lazy.defineProperty(provenance, \"returns\", () =>\n rebase(ref.returns),\n );\n if (\"error\" in ref) {\n Lazy.defineProperty(provenance, \"error\", () => {\n const error = ref.error;\n return error === undefined ? undefined : rebase(error);\n });\n }\n return Ref.fromProvenance(\n ref.convexFunctionName,\n provenance as FunctionProvenance.AnyConfect,\n Array.map(ref.middlewareAttachments, (attachment) => ({\n ...attachment,\n spec: rebaseMiddleware(attachment.spec),\n })),\n nativeRef,\n );\n }),\n Match.exhaustive,\n );\n } else {\n return visit(child, reference);\n }\n });\n const refs = visit(contract.refs, native);\n Object.defineProperty(refs, BoundTypeId, {\n value: { from: contract.scope, scope, tables: contract.tables },\n });\n return refs as Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n >;\n};\n\n/**\n * Reference an installed component's table ID in host schemas.\n */\nexport const id = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n const Table extends Tables,\n>(\n component: {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n },\n table: Table,\n) => GenericId.GenericId(table, component[BoundTypeId].scope);\n\n/**\n * Reuse a component's codec in a host function or table without losing its\n * scope.\n */\nexport const schema = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Schema_ extends Schema.Codec<any, any>,\n>(\n component: {\n readonly [BoundTypeId]: { readonly from: From; readonly scope: To };\n },\n codec: Schema_,\n) =>\n GenericId.rebase(\n codec,\n component[BoundTypeId].from,\n component[BoundTypeId].scope,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,2BAAb,cAA8C,KAAK,YACjD,0BACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,IAAa,8BAAb,cAAiD,KAAK,YACpD,6BACF,CAAC,CAGE;CACD,IAAa,UAAkB;EAC7B,OAAO,qDAAqD,KAAK,UAAU,GAAG,KAAK,aAAa;CAClG;AACF;AAEA,IAAa,qCAAb,cAAwD,KAAK,YAC3D,oCACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,MAAM,iBACJ,QACA,SAAS,OAC4C;CACrD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,UAAU,MAAM,GAAG;EACpD,MAAM,OAAO,WAAW,KAAK,OAAO,GAAG,OAAO,GAAG;EACjD,KAAK,MAAM,gBAAgB,OAAO,OAAO,MAAM,SAAS,GACtD,IAAI,OAAO,IAAI,MAAM,QAAQ,aAAa,IAAI,GAC5C,OAAO,OAAO,KACZ,IAAI,4BAA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pB;IACA,IAAI,WAAW,KACb,eAAoB,YAAY,eAAe;KAC7C,MAAM,QAAQ,IAAI;KAClB,OAAO,UAAU,KAAA,IAAY,KAAA,IAAYA,SAAO,KAAK;IACvD,CAAC;IAEH,OAAOG,eACL,IAAI,oBACJ,YACA,MAAM,IAAI,IAAI,wBAAwB,gBAAgB;KACpD,GAAG;KACH,MAAM,iBAAiB,WAAW,IAAI;IACxC,EAAE,GACF,SACF;GACF,CAAC,GACD,MAAM,UACR;EACF,OACE,OAAO,MAAM,OAAO,SAAS;CAEjC,CAAC;CACH,MAAM,OAAO,MAAM,SAAS,MAAM,MAAM;CACxC,OAAO,eAAe,MAAM,aAAa,EACvC,OAAO;EAAE,MAAM,SAAS;EAAO;EAAO,QAAQ,SAAS;CAAO,EAChE,CAAC;CACD,OAAO;AAMT;;;;AAKA,MAAa,MAMX,WAOA,UACGC,UAAoB,OAAO,UAAU,YAAY,CAAC,KAAK;;;;;AAM5D,MAAa,UAKX,WAGA,UAEAH,OACE,OACA,UAAU,YAAY,CAAC,MACvB,UAAU,YAAY,CAAC,KACzB"}
1
+ {"version":3,"file":"Component.js","names":["Spec.groups","Ref.make","IdScope.instance","IdScope.app","rebase","GenericId.rebase","Ref.isRef","Ref.fromProvenance","GenericId.GenericId"],"sources":["../src/Component.ts"],"sourcesContent":["import type { DefaultFunctionArgs, FunctionReference } from \"convex/server\";\nimport { getFunctionAddress } from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport { memoize, pipe } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as GenericId from \"./GenericId.js\";\nimport type * as GroupSpec from \"./GroupSpec.js\";\nimport * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as Refs from \"./Refs.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\nimport * as Spec from \"./Spec.js\";\n\nexport class EmptyComponentScopeError extends Data.TaggedError(\n \"EmptyComponentScopeError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"A component contract requires a nonempty definition scope.\";\n }\n}\n\nexport class ComponentNameCollisionError extends Data.TaggedError(\n \"ComponentNameCollisionError\",\n)<{\n readonly groupPath: string;\n readonly functionName: string;\n}> {\n override get message(): string {\n return `Group and function at same level have same name ('${this.groupPath}:${this.functionName}')`;\n }\n}\n\nexport class UninstalledComponentReferenceError extends Data.TaggedError(\n \"UninstalledComponentReferenceError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"Component.bind expects an installed component from the generated components registry.\";\n }\n}\n\nconst validateNames = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n): Result.Result<void, ComponentNameCollisionError> => {\n for (const [name, group] of Record.toEntries(groups)) {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n for (const functionSpec of Record.values(group.functions)) {\n if (Record.has(group.groups, functionSpec.name)) {\n return Result.fail(\n new ComponentNameCollisionError({\n groupPath: path,\n functionName: functionSpec.name,\n }),\n );\n }\n }\n const nested = validateNames(group.groups, path);\n if (Result.isFailure(nested)) return nested;\n }\n return Result.succeed(undefined);\n};\n\nconst validateContract = (\n scope: IdScope.IdScope,\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n): Result.Result<\n void,\n EmptyComponentScopeError | ComponentNameCollisionError\n> =>\n scope === \"\"\n ? Result.fail(new EmptyComponentScopeError({ definitionScope: scope }))\n : validateNames(groups);\n\nconst TypeId = \"~@confect/core/Component\";\nconst BoundTypeId = \"~@confect/core/BoundComponent\";\n\n/**\n * Convex's generated ComponentApi erases database ID brands at the boundary.\n */\ntype Wire<A> = A extends { readonly __tableName: string }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { [K in keyof A]: Wire<A[K]> };\n\ntype OmitEmpty<A> = {\n [K in keyof A as keyof A[K] extends never ? never : K]: A[K];\n};\ntype ApiGroups<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = OmitEmpty<{\n [GroupName in GroupSpec.Name<GroupSpec_>]: ApiGroup<\n GroupSpec.WithName<GroupSpec_, GroupName>,\n Name\n >;\n}>;\ntype ApiGroup<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = ApiGroups<GroupSpec.Groups<GroupSpec_>, Name> & {\n [\n FunctionSpec_ in GroupSpec.Functions<GroupSpec_> as FunctionSpec.GetFunctionVisibility<FunctionSpec_> extends \"public\"\n ? FunctionSpec.Name<FunctionSpec_>\n : never\n ]: FunctionReference<\n RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n >,\n \"internal\",\n Extract<Wire<FunctionSpec.EncodedArgs<FunctionSpec_>>, DefaultFunctionArgs>,\n Wire<FunctionSpec.EncodedReturns<FunctionSpec_>>,\n Name\n >;\n};\n\nexport type Api<\n Spec_ extends Spec.AnyWithProps,\n Name extends string | undefined = string | undefined,\n> = ApiGroups<Spec.Groups<Spec_>, Name>;\n\ninterface Tree {\n readonly [key: string]: Tree | Ref.Any;\n}\n\nexport interface Component<\n Spec_ extends Spec.AnyWithProps,\n Scope extends IdScope.IdScope,\n Tables extends string = string,\n> {\n readonly [TypeId]: {\n readonly refs: Tree;\n readonly scope: Scope;\n readonly tables: ReadonlyArray<Tables>;\n };\n readonly \"~Spec\": Spec_;\n}\n\n/**\n * An opaque identity: its string representation is not part of the API.\n */\nexport type MountScope<\n Parent extends IdScope.IdScope,\n Name extends string | undefined,\n> = IdScope.Mount<Parent, Name>;\n\ntype MountName<ComponentApi> =\n ComponentApi extends FunctionReference<any, any, any, any, infer Name>\n ? Name\n : ComponentApi extends object\n ? {\n [Key in keyof ComponentApi]: MountName<ComponentApi[Key]>;\n }[keyof ComponentApi]\n : never;\n\ntype BindRefs<\n RefTree,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RefTree extends Ref.Any\n ? RefTree extends { readonly _tag: \"Convex\" }\n ? Ref.ConvexRef<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<Wire<Ref.Args<RefTree>>, DefaultFunctionArgs>,\n Wire<Ref.Returns<RefTree>>\n >\n : Extract<\n Ref.Ref<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<\n GenericId.Rebase<Ref.Args<RefTree>, From, To>,\n DefaultFunctionArgs\n >,\n GenericId.Rebase<Ref.Returns<RefTree>, From, To>,\n GenericId.Rebase<Ref.Error<RefTree>, From, To>\n >,\n { readonly _tag: RefTree[\"_tag\"] }\n >\n : { [Key in keyof RefTree]: BindRefs<RefTree[Key], From, To> };\n\nexport type Bound<\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n> = BindRefs<Refs.Refs<Spec_, Ref.AnyPublic>, From, To> & {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n};\n\n/**\n * Build a publishable contract containing only exported functions and codecs.\n */\nexport const make = <\n Spec_ extends Spec.AnyWithProps,\n const Scope extends IdScope.IdScope,\n const Tables extends string,\n>(\n spec: Spec_,\n scope: Scope,\n tables: ReadonlyArray<Tables>,\n): Component<Spec_, Scope, Tables> => {\n const specGroups = Spec.groups(spec);\n Result.getOrThrow(validateContract(scope, specGroups));\n const collect = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n ): Tree =>\n pipe(\n groups,\n Record.map((group, name) => {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n const functions = pipe(\n group.functions,\n Record.filter((functionSpec) => {\n return Match.value(functionSpec.functionVisibility).pipe(\n Match.when(\"public\", () => true),\n Match.when(\"internal\", () => false),\n Match.exhaustive,\n );\n }),\n Record.map((functionSpec) =>\n Ref.make(path, functionSpec, group.middlewareAttachments),\n ),\n );\n return { ...collect(group.groups, path), ...functions };\n }),\n Record.filter((children) => !Record.isEmptyRecord(children)),\n );\n return {\n [TypeId]: { refs: collect(specGroups), scope, tables },\n } as Component<Spec_, Scope, Tables>;\n};\n\n/**\n * Bind the published contract to an actual installed component reference.\n */\nexport const bind = <\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n Tables extends string,\n Native extends Api<NoInfer<Spec_>>,\n const Parent extends IdScope.IdScope = IdScope.App,\n>(\n component: Component<Spec_, From, Tables>,\n native: Native,\n options?: { readonly parentScope: Parent },\n): Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n> => {\n const contract = component[TypeId];\n const address = getFunctionAddress(native);\n const installedReference = Result.getOrThrow(\n Result.fromNullishOr(\n address.reference,\n () =>\n new UninstalledComponentReferenceError({\n definitionScope: contract.scope,\n }),\n ),\n );\n // Preserve the opaque address as an identity only. Calls retain the native\n // references; no component address is constructed or parsed for routing.\n const scope = IdScope.instance(\n options?.parentScope ?? IdScope.app,\n installedReference,\n );\n const rebase = (schema: Schema.ConstraintCodec<any, any, never, never>) =>\n GenericId.rebase(schema, contract.scope, scope);\n const rebaseMiddleware = memoize(\n (middleware: MiddlewareSpec.AnyMiddlewareSpec) => {\n if (!(\"error\" in middleware)) return middleware;\n const boundMiddleware = Object.create(\n middleware,\n ) as MiddlewareSpec.AnyMiddlewareSpec;\n Lazy.defineProperty(boundMiddleware, \"error\", () => {\n const error = middleware.error;\n return error === undefined ? undefined : rebase(error);\n });\n return boundMiddleware;\n },\n );\n const visit = (tree: Tree, references: unknown): Tree =>\n Record.map(tree, (child, key) => {\n const reference = (references as Record<string, unknown>)[key];\n if (Ref.isRef(child)) {\n const nativeRef = reference as FunctionReference<any, any>;\n return Match.value(child).pipe(\n Match.tag(\"Convex\", (ref) => ({\n ...ref,\n functionReference: nativeRef,\n })),\n Match.tag(\"Confect\", (ref) => {\n const provenance = {\n _tag: \"Confect\" as const,\n kind: Match.value(ref.kind).pipe(\n Match.tag(\"Standard\", (kind) => kind),\n Match.tag(\"Paginated\", (kind) => {\n const boundKind = { _tag: \"Paginated\" as const };\n Lazy.defineProperty(boundKind, \"userArgs\", () =>\n Schema.Struct(Record.map(kind.userArgs.fields, rebase)),\n );\n Lazy.defineProperty(boundKind, \"item\", () =>\n rebase(kind.item),\n );\n Lazy.defineProperty(boundKind, \"page\", () =>\n rebase(kind.page),\n );\n return boundKind as FunctionProvenance.Paginated;\n }),\n Match.exhaustive,\n ),\n };\n Lazy.defineProperty(provenance, \"args\", () =>\n Schema.Struct(Record.map(ref.args.fields, rebase)),\n );\n Lazy.defineProperty(provenance, \"returns\", () =>\n rebase(ref.returns),\n );\n if (\"error\" in ref) {\n Lazy.defineProperty(provenance, \"error\", () => {\n const error = ref.error;\n return error === undefined ? undefined : rebase(error);\n });\n }\n return Ref.fromProvenance(\n ref.convexFunctionName,\n provenance as FunctionProvenance.AnyConfect,\n Array.map(ref.middlewareAttachments, (attachment) => ({\n ...attachment,\n spec: rebaseMiddleware(attachment.spec),\n })),\n nativeRef,\n ref.functionType,\n );\n }),\n Match.exhaustive,\n );\n } else {\n return visit(child, reference);\n }\n });\n const refs = visit(contract.refs, native);\n Object.defineProperty(refs, BoundTypeId, {\n value: { from: contract.scope, scope, tables: contract.tables },\n });\n return refs as Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n >;\n};\n\n/**\n * Reference an installed component's table ID in host schemas.\n */\nexport const id = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n const Table extends Tables,\n>(\n component: {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n },\n table: Table,\n) => GenericId.GenericId(table, component[BoundTypeId].scope);\n\n/**\n * Reuse a component's codec in a host function or table without losing its\n * scope.\n */\nexport const schema = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Schema_ extends Schema.Codec<any, any>,\n>(\n component: {\n readonly [BoundTypeId]: { readonly from: From; readonly scope: To };\n },\n codec: Schema_,\n) =>\n GenericId.rebase(\n codec,\n component[BoundTypeId].from,\n component[BoundTypeId].scope,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,2BAAb,cAA8C,KAAK,YACjD,0BACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,IAAa,8BAAb,cAAiD,KAAK,YACpD,6BACF,CAAC,CAGE;CACD,IAAa,UAAkB;EAC7B,OAAO,qDAAqD,KAAK,UAAU,GAAG,KAAK,aAAa;CAClG;AACF;AAEA,IAAa,qCAAb,cAAwD,KAAK,YAC3D,oCACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,MAAM,iBACJ,QACA,SAAS,OAC4C;CACrD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,UAAU,MAAM,GAAG;EACpD,MAAM,OAAO,WAAW,KAAK,OAAO,GAAG,OAAO,GAAG;EACjD,KAAK,MAAM,gBAAgB,OAAO,OAAO,MAAM,SAAS,GACtD,IAAI,OAAO,IAAI,MAAM,QAAQ,aAAa,IAAI,GAC5C,OAAO,OAAO,KACZ,IAAI,4BAA4B;GAC9B,WAAW;GACX,cAAc,aAAa;EAC7B,CAAC,CACH;EAGJ,MAAM,SAAS,cAAc,MAAM,QAAQ,IAAI;EAC/C,IAAI,OAAO,UAAU,MAAM,GAAG,OAAO;CACvC;CACA,OAAO,OAAO,QAAQ,KAAA,CAAS;AACjC;AAEA,MAAM,oBACJ,OACA,WAKA,UAAU,KACN,OAAO,KA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iB,WAAW,IAAI;IACxC,EAAE,GACF,WACA,IAAI,YACN;GACF,CAAC,GACD,MAAM,UACR;EACF,OACE,OAAO,MAAM,OAAO,SAAS;CAEjC,CAAC;CACH,MAAM,OAAO,MAAM,SAAS,MAAM,MAAM;CACxC,OAAO,eAAe,MAAM,aAAa,EACvC,OAAO;EAAE,MAAM,SAAS;EAAO;EAAO,QAAQ,SAAS;CAAO,EAChE,CAAC;CACD,OAAO;AAMT;;;;AAKA,MAAa,MAMX,WAOA,UACGC,UAAoB,OAAO,UAAU,YAAY,CAAC,KAAK;;;;;AAM5D,MAAa,UAKX,WAGA,UAEAH,OACE,OACA,UAAU,YAAY,CAAC,MACvB,UAAU,YAAY,CAAC,KACzB"}
@@ -1,10 +1,10 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { Confect, ConfectPaginated, Convex } from "./FunctionProvenance.js";
3
- import { isMiddlewareSpec } from "./MiddlewareSpec.js";
4
3
  import { validateConfectFunctionIdentifier } from "./Identifier.js";
4
+ import { isMiddlewareSpec } from "./MiddlewareSpec.js";
5
5
  import { ConvexAction, ConvexMutation, ConvexQuery, NodeAction } from "./RuntimeAndFunctionType.js";
6
- import * as Predicate from "effect/Predicate";
7
6
  import * as Schema from "effect/Schema";
7
+ import * as Predicate from "effect/Predicate";
8
8
  //#region src/FunctionSpec.ts
9
9
  var FunctionSpec_exports = /* @__PURE__ */ __exportAll({
10
10
  TypeId: () => TypeId,
package/dist/GroupSpec.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { validateAll } from "./MiddlewareAttachment.js";
3
2
  import { validateConfectFunctionIdentifier } from "./Identifier.js";
3
+ import { validateAll } from "./MiddlewareAttachment.js";
4
4
  import * as Predicate from "effect/Predicate";
5
5
  import * as Result from "effect/Result";
6
6
  import * as Record from "effect/Record";
package/dist/Ref.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface Base<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.Run
19
19
  readonly "~ArgsVariance"?: string extends keyof Args_ ? unknown : (args: Args_) => void;
20
20
  readonly "~Returns": Returns_;
21
21
  readonly "~Error": Error_;
22
+ readonly functionType?: RuntimeAndFunctionType_["functionType"];
22
23
  readonly convexFunctionName: string;
23
24
  /**
24
25
  * Preserved for component references and function handles, which have no
@@ -169,13 +170,13 @@ convexFunctionNamespace: string, functionSpec: FunctionSpec_, groupMiddlewareAtt
169
170
  * and `error` from the provenance on first use, so building it forces no
170
171
  * schema.
171
172
  */
172
- export declare const fromProvenance: (convexFunctionName: string, provenance: FunctionProvenance.AnyConfect, middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>, functionReference?: ConvexFunctionReference<any, any>) => AnyConfect;
173
+ export declare const fromProvenance: (convexFunctionName: string, provenance: FunctionProvenance.AnyConfect, middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>, functionReference?: ConvexFunctionReference<any, any>, functionType?: "query" | "mutation" | "action") => AnyConfect;
173
174
  export declare const getConvexFunctionName: (ref: Any) => string;
174
175
  export declare const getFunctionReference: <Ref_ extends Any>(ref: Ref_) => FunctionReference<Ref_>;
175
176
  /**
176
177
  * Adapt a native reference without assigning Confect codecs or typed errors.
177
178
  */
178
- export declare const fromFunctionReference: <Type extends "query" | "mutation" | "action", Visibility extends FunctionVisibility, Args_ extends DefaultFunctionArgs, Returns_>(functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>) => ConvexRef<Extract<RuntimeAndFunctionType.RuntimeAndFunctionType, {
179
+ export declare const fromFunctionReference: <Type extends "query" | "mutation" | "action", Visibility extends FunctionVisibility, Args_ extends DefaultFunctionArgs, Returns_>(functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>, functionType?: NoInfer<Type>) => ConvexRef<Extract<RuntimeAndFunctionType.RuntimeAndFunctionType, {
179
180
  readonly runtime: "Convex";
180
181
  readonly functionType: Type;
181
182
  }>, Visibility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zB,CAAC;AAwBJ;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,SAAS,uBAAuB,OAE/B,IAAI,QACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,KACvC,OAOA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,SAAS,uBAAuB,OACtE,IAAI,eACI,OAAO,KACnB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAOK,CAAC;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,SAAS,GAAG,EAChB,CAAC,iEAKoB,iBAAiB,CAAC,IAAI,CAAC,eAC7B,OAAO,KACjB,WAAW,CAAC,OAAO,CAAC,6BACC,OAAO,KAAK,CAAC,2FAyBvC,CAAC"}
package/dist/Ref.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { defineProperty } from "./Lazy.js";
3
3
  import { errorSchemas } from "./MiddlewareSpec.js";
4
- import * as Predicate from "effect/Predicate";
5
4
  import * as Schema from "effect/Schema";
5
+ import * as Predicate from "effect/Predicate";
6
6
  import { getFunctionAddress, makeFunctionReference } from "convex/server";
7
7
  import { ConvexError } from "convex/values";
8
8
  import * as Effect from "effect/Effect";
@@ -42,8 +42,9 @@ const make = (convexFunctionNamespace, functionSpec, groupMiddlewareAttachments
42
42
  return Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => ({
43
43
  [TypeId]: TypeId,
44
44
  _tag: "Convex",
45
+ functionType: functionSpec.runtimeAndFunctionType.functionType,
45
46
  convexFunctionName
46
- })), Match.tag("Confect", (provenance) => fromProvenance(convexFunctionName, provenance, [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments])), Match.exhaustive);
47
+ })), Match.tag("Confect", (provenance) => fromProvenance(convexFunctionName, provenance, [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments], void 0, functionSpec.runtimeAndFunctionType.functionType)), Match.exhaustive);
47
48
  };
48
49
  /**
49
50
  * Build a Confect ref that runs with `provenance`'s codecs. Pass
@@ -52,10 +53,11 @@ const make = (convexFunctionNamespace, functionSpec, groupMiddlewareAttachments
52
53
  * and `error` from the provenance on first use, so building it forces no
53
54
  * schema.
54
55
  */
55
- const fromProvenance = (convexFunctionName, provenance, middlewareAttachments, functionReference) => {
56
+ const fromProvenance = (convexFunctionName, provenance, middlewareAttachments, functionReference, functionType) => {
56
57
  const ref = {
57
58
  [TypeId]: TypeId,
58
59
  _tag: "Confect",
60
+ ...functionType === void 0 ? {} : { functionType },
59
61
  convexFunctionName,
60
62
  ...functionReference === void 0 ? {} : { functionReference },
61
63
  kind: provenance.kind,
@@ -83,11 +85,12 @@ const getFunctionReference = (ref) => {
83
85
  /**
84
86
  * Adapt a native reference without assigning Confect codecs or typed errors.
85
87
  */
86
- const fromFunctionReference = (functionReference) => {
88
+ const fromFunctionReference = (functionReference, functionType) => {
87
89
  const address = getFunctionAddress(functionReference);
88
90
  return {
89
91
  [TypeId]: TypeId,
90
92
  _tag: "Convex",
93
+ ...functionType === void 0 ? {} : { functionType },
91
94
  convexFunctionName: address.name ?? address.reference ?? address.functionHandle ?? "<external function>",
92
95
  functionReference
93
96
  };
package/dist/Ref.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { getFunctionAddress, makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Ref\";\nexport type TypeId = typeof TypeId;\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> {\n readonly [TypeId]: TypeId;\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n // Concrete call inputs must not narrow across assignments. Erased refs and\n // pagination constraints use index signatures and keep their broad variance.\n readonly \"~ArgsVariance\"?: string extends keyof Args_\n ? unknown\n : (args: Args_) => void;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly convexFunctionName: string;\n /**\n * Preserved for component references and function handles, which have no\n * local name.\n */\n readonly functionReference?: ConvexFunctionReference<any, any>;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed errors.\n * A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n MiddlewareEncodedError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_,\n ReturnsSchema_,\n ErrorSchema_,\n ErrorSchema_[\"Encoded\"] | MiddlewareEncodedError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives the\n * same values from its fields and schemas.\n *\n * The codecs keep their own types so that a ref's wire encoding stays visible\n * to type-level checks, and `~EncodedError` carries the wire form of every\n * error the function can fail with, middleware included. A ref built from value\n * types alone (`Ref`) has no codecs to keep and erases them.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n ReturnsSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n EncodedError_ = any,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: ReturnsSchema_;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: ErrorSchema_;\n readonly \"~EncodedError\": EncodedError_;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\n/**\n * A ref's call contract without a visibility requirement. Use this for handlers\n * shared by a component's public ref and its host's internal binding. Args,\n * returns, errors, runtime and function kind remain constrained.\n */\nexport type Callable<Ref_ extends Any> = Ref<\n GetRuntimeAndFunctionType<Ref_>,\n FunctionVisibility,\n Args<Ref_>,\n Returns<Ref_>,\n Error<Ref_>\n>;\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/**\n * Recognizes references by their runtime type identity.\n */\nexport const isRef = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\n/**\n * Erased Confect-provenance ref used by provenance-specific APIs.\n */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/**\n * The field map captured by a Confect-provenance ref.\n */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/**\n * The assembled args schema carried by a Confect-provenance ref.\n */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\n/**\n * The returns codec carried by a Confect-provenance ref.\n */\nexport type ReturnsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n}\n ? ReturnsSchema_\n : never;\n\n/**\n * The wire form of every error a ref can fail with: its function's declared\n * error and its middleware's errors.\n */\nexport type EncodedError<Ref_> = Ref_ extends {\n readonly \"~EncodedError\": infer EncodedError_;\n}\n ? EncodedError_\n : never;\n\n/**\n * The function's own error codec carried by a Confect-provenance ref; errors\n * contributed by middleware are not part of it.\n */\nexport type ErrorSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n}\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\n/**\n * The ref type of a function spec. Errors from middleware attached to the\n * function are included; pass the errors of middleware attached to its groups\n * as `MiddlewareError` and `MiddlewareEncodedError`.\n */\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n MiddlewareEncodedError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n | FunctionSpec.Error<FunctionSpec_>\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareError,\n FunctionSpec.ReturnsSchema<FunctionSpec_>,\n FunctionSpec.ErrorSchema<FunctionSpec_>,\n | FunctionSpec.EncodedError<FunctionSpec_>\n | MiddlewareSpec.EncodedError<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareEncodedError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any>,\n EncodedError_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_,\n ReturnsSchema_,\n ErrorSchema_,\n EncodedError_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<GroupMiddlewareSpec_>\n > = [],\n): FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n [TypeId]: TypeId,\n _tag: \"Convex\",\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any =>\n fromProvenance(convexFunctionName, provenance, [\n ...groupMiddlewareAttachments,\n ...functionSpec.middlewareAttachments,\n ]),\n ),\n Match.exhaustive,\n ) as FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n >;\n};\n\n/**\n * Build a Confect ref that runs with `provenance`'s codecs. Pass\n * `functionReference` when the function has no local name: an installed\n * component's function or a function handle. The ref reads `args`, `returns`\n * and `error` from the provenance on first use, so building it forces no\n * schema.\n */\nexport const fromProvenance = (\n convexFunctionName: string,\n provenance: FunctionProvenance.AnyConfect,\n middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n functionReference?: ConvexFunctionReference<any, any>,\n): AnyConfect => {\n const ref = {\n [TypeId]: TypeId as TypeId,\n _tag: \"Confect\" as const,\n convexFunctionName,\n ...(functionReference === undefined ? {} : { functionReference }),\n kind: provenance.kind,\n middlewareAttachments,\n get middlewareSpecs() {\n return middlewareAttachments.map(({ spec }) => spec);\n },\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as AnyConfect;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n if (ref.functionReference !== undefined) {\n return ref.functionReference as FunctionReference<Ref_>;\n }\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\n/**\n * Adapt a native reference without assigning Confect codecs or typed errors.\n */\nexport const fromFunctionReference = <\n Type extends \"query\" | \"mutation\" | \"action\",\n Visibility extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n>(\n functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>,\n): ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n> => {\n const address = getFunctionAddress(functionReference);\n return {\n [TypeId]: TypeId,\n _tag: \"Convex\",\n convexFunctionName:\n address.name ??\n address.reference ??\n address.functionHandle ??\n \"<external function>\",\n functionReference,\n } as ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n >;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input _is_ a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls outside\n * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter\n * callbacks for streamed subscriptions) to the same error semantics that\n * `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema—the function's declared\n * `error` schema unioned with its covering middlewares' error schemas. Returns\n * `None` if the ref declares no typed error at all (Confect ref without an\n * `error` schema and without failing middleware, or a Convex-provenance ref)—by\n * definition there's nothing to decode the value into, and the caller is\n * responsible for deciding what to do (typically: surface the original value as\n * a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.asSome(\n Schema.decodeUnknownEffect(schema)(encodedError),\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error—either because the ref declares no `error` schema,\n * or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and those\n * never match a user-declared error schema. Callers pair this with a fallback\n * that surfaces the original error, so failing to decode must not throw—a\n * `ParseError` here would replace the real error with an opaque one and lose\n * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,\n * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this\n * module all throw on a parse failure, and this one deliberately doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args\n * schema—`paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = Effect.fnUntraced(function* <\n Ref_ extends Any,\n E = never,\n>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.fn.Return<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> {\n const functionReference = getFunctionReference(ref);\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,SAAS;;;;AAqJtB,MAAa,SAAS,UACpB,UAAU,YAAY,OAAO,MAAM;AAyPrC,MAAa,QASX,yBACA,cACA,6BAEI,CAAC,MAKF;CACH,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;GACE,SAAS;EACV,MAAM;EACN;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eACpB,eAAe,oBAAoB,YAAY,CAC7C,GAAG,4BACH,GAAG,aAAa,qBAClB,CAAC,CACH,GACA,MAAM,UACR;AAKF;;;;;;;;AASA,MAAa,kBACX,oBACA,YACA,uBACA,sBACe;CACf,MAAM,MAAM;GACT,SAAS;EACV,MAAM;EACN;EACA,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;EAC/D,MAAM,WAAW;EACjB;EACA,IAAI,kBAAkB;GACpB,OAAO,sBAAsB,KAAK,EAAE,WAAW,IAAI;EACrD;CACF;CAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;CACtD,eAAoB,KAAK,iBAAiB,WAAW,OAAO;CAC5D,IAAI,WAAW,YACb,eAAoB,KAAK,eAAe,WAAW,KAAK;CAG1D,OAAO;AACT;AAEA,MAA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CACvE,MAAM,oBAAoB,qBAAqB,GAAG;CAClD,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,WAAW,CAAC;EAC/D,QAAQ,UAA2B;GACjC,IAAI,cAAc,KAAK,GAAG;IACxB,MAAM,UAAU,kBAAkB,KAAK,MAAM,IAAI;IACjD,IAAI,OAAO,OAAO,OAAO,GACvB,OAAO,QAAQ;GAEnB;GACA,IAAI,oBAAoB,KAAA,GACtB,OAAO,gBAAgB,KAAK;GAE9B,MAAM;EACR;CACF,CAAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
1
+ {"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment.js\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { getFunctionAddress, makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Ref\";\nexport type TypeId = typeof TypeId;\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> {\n readonly [TypeId]: TypeId;\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType_;\n readonly \"~FunctionVisibility\": FunctionVisibility_;\n readonly \"~Args\": Args_;\n // Concrete call inputs must not narrow across assignments. Erased refs and\n // pagination constraints use index signatures and keep their broad variance.\n readonly \"~ArgsVariance\"?: string extends keyof Args_\n ? unknown\n : (args: Args_) => void;\n readonly \"~Returns\": Returns_;\n readonly \"~Error\": Error_;\n readonly functionType?: RuntimeAndFunctionType_[\"functionType\"];\n readonly convexFunctionName: string;\n /**\n * Preserved for component references and function handles, which have no\n * local name.\n */\n readonly functionReference?: ConvexFunctionReference<any, any>;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed errors.\n * A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n MiddlewareEncodedError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_,\n ReturnsSchema_,\n ErrorSchema_,\n ErrorSchema_[\"Encoded\"] | MiddlewareEncodedError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives the\n * same values from its fields and schemas.\n *\n * The codecs keep their own types so that a ref's wire encoding stays visible\n * to type-level checks, and `~EncodedError` carries the wire form of every\n * error the function can fail with, middleware included. A ref built from value\n * types alone (`Ref`) has no codecs to keep and erases them.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n ReturnsSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n EncodedError_ = any,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: ReturnsSchema_;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: ErrorSchema_;\n readonly \"~EncodedError\": EncodedError_;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\n/**\n * A ref's call contract without a visibility requirement. Use this for handlers\n * shared by a component's public ref and its host's internal binding. Args,\n * returns, errors, runtime and function kind remain constrained.\n */\nexport type Callable<Ref_ extends Any> = Ref<\n GetRuntimeAndFunctionType<Ref_>,\n FunctionVisibility,\n Args<Ref_>,\n Returns<Ref_>,\n Error<Ref_>\n>;\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/**\n * Recognizes references by their runtime type identity.\n */\nexport const isRef = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\n/**\n * Erased Confect-provenance ref used by provenance-specific APIs.\n */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/**\n * The field map captured by a Confect-provenance ref.\n */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/**\n * The assembled args schema carried by a Confect-provenance ref.\n */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\n/**\n * The returns codec carried by a Confect-provenance ref.\n */\nexport type ReturnsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;\n}\n ? ReturnsSchema_\n : never;\n\n/**\n * The wire form of every error a ref can fail with: its function's declared\n * error and its middleware's errors.\n */\nexport type EncodedError<Ref_> = Ref_ extends {\n readonly \"~EncodedError\": infer EncodedError_;\n}\n ? EncodedError_\n : never;\n\n/**\n * The function's own error codec carried by a Confect-provenance ref; errors\n * contributed by middleware are not part of it.\n */\nexport type ErrorSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly error?: infer ErrorSchema_;\n}\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\n/**\n * The ref type of a function spec. Errors from middleware attached to the\n * function are included; pass the errors of middleware attached to its groups\n * as `MiddlewareError` and `MiddlewareEncodedError`.\n */\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n MiddlewareEncodedError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n | FunctionSpec.Error<FunctionSpec_>\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareError,\n FunctionSpec.ReturnsSchema<FunctionSpec_>,\n FunctionSpec.ErrorSchema<FunctionSpec_>,\n | FunctionSpec.EncodedError<FunctionSpec_>\n | MiddlewareSpec.EncodedError<FunctionSpec.MiddlewareSpecs<FunctionSpec_>>\n | MiddlewareEncodedError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any>,\n EncodedError_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_,\n ReturnsSchema_,\n ErrorSchema_,\n EncodedError_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport const make = <\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n GroupMiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<GroupMiddlewareSpec_>\n > = [],\n): FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n [TypeId]: TypeId,\n _tag: \"Convex\",\n functionType: functionSpec.runtimeAndFunctionType.functionType,\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any =>\n fromProvenance(\n convexFunctionName,\n provenance,\n [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments],\n undefined,\n functionSpec.runtimeAndFunctionType.functionType,\n ),\n ),\n Match.exhaustive,\n ) as FromFunctionSpec<\n FunctionSpec_,\n MiddlewareSpec.Error<GroupMiddlewareSpec_>,\n MiddlewareSpec.EncodedError<GroupMiddlewareSpec_>\n >;\n};\n\n/**\n * Build a Confect ref that runs with `provenance`'s codecs. Pass\n * `functionReference` when the function has no local name: an installed\n * component's function or a function handle. The ref reads `args`, `returns`\n * and `error` from the provenance on first use, so building it forces no\n * schema.\n */\nexport const fromProvenance = (\n convexFunctionName: string,\n provenance: FunctionProvenance.AnyConfect,\n middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n functionReference?: ConvexFunctionReference<any, any>,\n functionType?: \"query\" | \"mutation\" | \"action\",\n): AnyConfect => {\n const ref = {\n [TypeId]: TypeId as TypeId,\n _tag: \"Confect\" as const,\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName,\n ...(functionReference === undefined ? {} : { functionReference }),\n kind: provenance.kind,\n middlewareAttachments,\n get middlewareSpecs() {\n return middlewareAttachments.map(({ spec }) => spec);\n },\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as AnyConfect;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n if (ref.functionReference !== undefined) {\n return ref.functionReference as FunctionReference<Ref_>;\n }\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\n/**\n * Adapt a native reference without assigning Confect codecs or typed errors.\n */\nexport const fromFunctionReference = <\n Type extends \"query\" | \"mutation\" | \"action\",\n Visibility extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n>(\n functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>,\n functionType?: NoInfer<Type>,\n): ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n> => {\n const address = getFunctionAddress(functionReference);\n return {\n [TypeId]: TypeId,\n _tag: \"Convex\",\n ...(functionType === undefined ? {} : { functionType }),\n convexFunctionName:\n address.name ??\n address.reference ??\n address.functionHandle ??\n \"<external function>\",\n functionReference,\n } as ConvexRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n { readonly runtime: \"Convex\"; readonly functionType: Type }\n >,\n Visibility,\n Args_,\n Returns_\n >;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input _is_ a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls outside\n * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter\n * callbacks for streamed subscriptions) to the same error semantics that\n * `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema—the function's declared\n * `error` schema unioned with its covering middlewares' error schemas. Returns\n * `None` if the ref declares no typed error at all (Confect ref without an\n * `error` schema and without failing middleware, or a Convex-provenance ref)—by\n * definition there's nothing to decode the value into, and the caller is\n * responsible for deciding what to do (typically: surface the original value as\n * a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.asSome(\n Schema.decodeUnknownEffect(schema)(encodedError),\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error—either because the ref declares no `error` schema,\n * or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and those\n * never match a user-declared error schema. Callers pair this with a fallback\n * that surfaces the original error, so failing to decode must not throw—a\n * `ParseError` here would replace the real error with an opaque one and lose\n * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,\n * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this\n * module all throw on a parse failure, and this one deliberately doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args\n * schema—`paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = Effect.fnUntraced(function* <\n Ref_ extends Any,\n E = never,\n>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.fn.Return<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> {\n const functionReference = getFunctionReference(ref);\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,SAAS;;;;AAsJtB,MAAa,SAAS,UACpB,UAAU,YAAY,OAAO,MAAM;AAyPrC,MAAa,QASX,yBACA,cACA,6BAEI,CAAC,MAKF;CACH,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;GACE,SAAS;EACV,MAAM;EACN,cAAc,aAAa,uBAAuB;EAClD;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eACpB,eACE,oBACA,YACA,CAAC,GAAG,4BAA4B,GAAG,aAAa,qBAAqB,GACrE,KAAA,GACA,aAAa,uBAAuB,YACtC,CACF,GACA,MAAM,UACR;AAKF;;;;;;;;AASA,MAAa,kBACX,oBACA,YACA,uBACA,mBACA,iBACe;CACf,MAAM,MAAM;GACT,SAAS;EACV,MAAM;EACN,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACrD;EACA,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;EAC/D,MAAM,WAAW;EACjB;EACA,IAAI,kBAAkB;GACpB,OAAO,sBAAsB,KAAK,EAAE,WAAW,IAAI;EACrD;CACF;CAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;CACtD,eAAoB,KAAK,iBAAiB,WAAW,OAAO;CAC5D,IAAI,WAAW,YACb,eAAoB,KAAK,eAAe,WAAW,KAAK;CAG1D,OAAO;AACT;AAEA,MAAa,yBAAyB,QACpC,IAAI;AAEN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AAW,WAI5C,KACA,MACA,MAIA,iBACuE;CACvE,MAAM,oBAAoB,qBAAqB,GAAG;CAClD,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,WAAW,CAAC;EAC/D,QAAQ,UAA2B;GACjC,IAAI,cAAc,KAAK,GAAG;IACxB,MAAM,UAAU,kBAAkB,KAAK,MAAM,IAAI;IACjD,IAAI,OAAO,OAAO,OAAO,GACvB,OAAO,QAAQ;GAEnB;GACA,IAAI,oBAAoB,KAAA,GACtB,OAAO,gBAAgB,KAAK;GAE9B,MAAM;EACR;CACF,CAAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { app } from "./IdScope.js";
3
3
  import { scope, tableName } from "./GenericId.js";
4
- import * as Predicate from "effect/Predicate";
5
4
  import * as Schema from "effect/Schema";
5
+ import * as Predicate from "effect/Predicate";
6
6
  import * as Data from "effect/Data";
7
7
  import { v } from "convex/values";
8
8
  import * as Effect from "effect/Effect";
@@ -1,7 +1,7 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { GenericId } from "./GenericId.js";
3
- import * as Predicate from "effect/Predicate";
4
3
  import * as Schema from "effect/Schema";
4
+ import * as Predicate from "effect/Predicate";
5
5
  import * as SchemaGetter from "effect/SchemaGetter";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Option from "effect/Option";
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * as ActionCall from "./ActionCall.js";
1
2
  export * as Callback from "./Callback.js";
2
3
  export * as FunctionProvenance from "./FunctionProvenance.js";
3
4
  export * as FunctionSpec from "./FunctionSpec.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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K,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,22 +1,23 @@
1
- import { App_exports } from "./App.js";
2
- import { Auth_exports } from "./Auth.js";
3
1
  import { Lazy_exports } from "./Lazy.js";
4
2
  import { PaginationOptions_exports } from "./PaginationOptions.js";
5
3
  import { PaginationResult_exports } from "./PaginationResult.js";
6
4
  import { FunctionProvenance_exports } from "./FunctionProvenance.js";
5
+ import { Identifier_exports } from "./Identifier.js";
7
6
  import { MiddlewareSpec_exports } from "./MiddlewareSpec.js";
7
+ import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
8
+ import { FunctionSpec_exports } from "./FunctionSpec.js";
9
+ import { ActionCall_exports } from "./ActionCall.js";
10
+ import { App_exports } from "./App.js";
11
+ import { Auth_exports } from "./Auth.js";
8
12
  import { Ref_exports } from "./Ref.js";
9
13
  import { Callback_exports } from "./Callback.js";
10
14
  import { IdScope_exports } from "./IdScope.js";
11
15
  import { GenericId_exports } from "./GenericId.js";
12
16
  import { MiddlewareAttachment_exports } from "./MiddlewareAttachment.js";
13
- import { Identifier_exports } from "./Identifier.js";
14
17
  import { GroupSpec_exports } from "./GroupSpec.js";
15
18
  import { Spec_exports } from "./Spec.js";
16
19
  import { Component_exports } from "./Component.js";
17
20
  import { Env_exports } from "./Env.js";
18
- import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
19
- import { FunctionSpec_exports } from "./FunctionSpec.js";
20
21
  import { GroupPath_exports } from "./GroupPath.js";
21
22
  import { Http_exports } from "./Http.js";
22
23
  import { Manifest_exports } from "./Manifest.js";
@@ -28,4 +29,4 @@ import { SystemFields_exports } from "./SystemFields.js";
28
29
  import { Table_exports } from "./Table.js";
29
30
  import { Types_exports } from "./Types.js";
30
31
  import { UserIdentity_exports } from "./UserIdentity.js";
31
- export { App_exports as App, Auth_exports as Auth, Callback_exports as Callback, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Profile_exports as Profile, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
32
+ export { ActionCall_exports as ActionCall, App_exports as App, Auth_exports as Auth, Callback_exports as Callback, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Profile_exports as Profile, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaganref/confect-core",
3
- "version": "10.3.1-fork.26",
3
+ "version": "10.3.1-fork.27",
4
4
  "peerDependencies": {
5
5
  "convex": "^1.46.0",
6
6
  "effect": "^4.0.0"
@@ -0,0 +1,25 @@
1
+ import * as Context from "effect/Context";
2
+ import type * as Effect from "effect/Effect";
3
+ import type * as Schema from "effect/Schema";
4
+ import * as FunctionSpec from "./FunctionSpec.js";
5
+ import * as MiddlewareSpec from "./MiddlewareSpec.js";
6
+ import type * as Ref from "./Ref.js";
7
+
8
+ export interface Call {
9
+ <Target extends Ref.AnyQuery | Ref.AnyMutation>(
10
+ target: Target,
11
+ ...args: Ref.OptionalArgs<NoInfer<Target>>
12
+ ): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;
13
+ }
14
+
15
+ export class ActionCall extends Context.Service<ActionCall, Call>()(
16
+ "@confect/core/ActionCall",
17
+ ) {}
18
+ export class Middleware extends MiddlewareSpec.MiddlewareSpec<
19
+ Middleware,
20
+ { provides: ActionCall }
21
+ >()("@confect/core/ActionCall/Middleware", {
22
+ functionTypes: { query: false, mutation: false, action: true },
23
+ }) {}
24
+
25
+ export const profile = FunctionSpec.extend()({ middleware: [Middleware] });
package/src/Callback.ts CHANGED
@@ -145,6 +145,7 @@ const fromText = <Contract_ extends Any>(
145
145
  [],
146
146
  // Convex types a handle as a string that is also a function reference.
147
147
  text as unknown as FunctionReference<any, any>,
148
+ contract.functionType,
148
149
  ),
149
150
  { [HandleTypeId]: contract.id },
150
151
  ) as unknown as Handle<Contract_>;
package/src/Component.ts CHANGED
@@ -358,6 +358,7 @@ export const bind = <
358
358
  spec: rebaseMiddleware(attachment.spec),
359
359
  })),
360
360
  nativeRef,
361
+ ref.functionType,
361
362
  );
362
363
  }),
363
364
  Match.exhaustive,
package/src/Ref.ts CHANGED
@@ -41,6 +41,7 @@ export interface Base<
41
41
  : (args: Args_) => void;
42
42
  readonly "~Returns": Returns_;
43
43
  readonly "~Error": Error_;
44
+ readonly functionType?: RuntimeAndFunctionType_["functionType"];
44
45
  readonly convexFunctionName: string;
45
46
  /**
46
47
  * Preserved for component references and function handles, which have no
@@ -447,14 +448,18 @@ export const make = <
447
448
  ({
448
449
  [TypeId]: TypeId,
449
450
  _tag: "Convex",
451
+ functionType: functionSpec.runtimeAndFunctionType.functionType,
450
452
  convexFunctionName,
451
453
  }) as Any,
452
454
  ),
453
455
  Match.tag("Confect", (provenance): Any =>
454
- fromProvenance(convexFunctionName, provenance, [
455
- ...groupMiddlewareAttachments,
456
- ...functionSpec.middlewareAttachments,
457
- ]),
456
+ fromProvenance(
457
+ convexFunctionName,
458
+ provenance,
459
+ [...groupMiddlewareAttachments, ...functionSpec.middlewareAttachments],
460
+ undefined,
461
+ functionSpec.runtimeAndFunctionType.functionType,
462
+ ),
458
463
  ),
459
464
  Match.exhaustive,
460
465
  ) as FromFunctionSpec<
@@ -476,10 +481,12 @@ export const fromProvenance = (
476
481
  provenance: FunctionProvenance.AnyConfect,
477
482
  middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,
478
483
  functionReference?: ConvexFunctionReference<any, any>,
484
+ functionType?: "query" | "mutation" | "action",
479
485
  ): AnyConfect => {
480
486
  const ref = {
481
487
  [TypeId]: TypeId as TypeId,
482
488
  _tag: "Confect" as const,
489
+ ...(functionType === undefined ? {} : { functionType }),
483
490
  convexFunctionName,
484
491
  ...(functionReference === undefined ? {} : { functionReference }),
485
492
  kind: provenance.kind,
@@ -532,6 +539,7 @@ export const fromFunctionReference = <
532
539
  Returns_,
533
540
  >(
534
541
  functionReference: ConvexFunctionReference<Type, Visibility, Args_, Returns_>,
542
+ functionType?: NoInfer<Type>,
535
543
  ): ConvexRef<
536
544
  Extract<
537
545
  RuntimeAndFunctionType.RuntimeAndFunctionType,
@@ -545,6 +553,7 @@ export const fromFunctionReference = <
545
553
  return {
546
554
  [TypeId]: TypeId,
547
555
  _tag: "Convex",
556
+ ...(functionType === undefined ? {} : { functionType }),
548
557
  convexFunctionName:
549
558
  address.name ??
550
559
  address.reference ??
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * as ActionCall from "./ActionCall.js";
1
2
  export * as Callback from "./Callback.js";
2
3
  export * as FunctionProvenance from "./FunctionProvenance.js";
3
4
  export * as FunctionSpec from "./FunctionSpec.js";