@gaganref/confect-core 10.3.1-fork.9 → 10.3.1-fork.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionCall.d.ts +18 -0
- package/dist/ActionCall.d.ts.map +1 -0
- package/dist/ActionCall.js +21 -0
- package/dist/ActionCall.js.map +1 -0
- package/dist/App.d.ts +38 -93
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +30 -38
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +33 -9
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +17 -2
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.d.ts +7 -2
- package/dist/Callback.d.ts.map +1 -1
- package/dist/Callback.js +11 -6
- package/dist/Callback.js.map +1 -1
- package/dist/CommitTs.d.ts +18 -0
- package/dist/CommitTs.d.ts.map +1 -0
- package/dist/CommitTs.js +20 -0
- package/dist/CommitTs.js.map +1 -0
- package/dist/Component.d.ts +106 -2
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +44 -18
- package/dist/Component.js.map +1 -1
- package/dist/FunctionSpec.d.ts +361 -2
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +68 -3
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.js +2 -2
- package/dist/GroupSpec.js +1 -1
- package/dist/Http.d.ts +4 -8
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +15 -22
- package/dist/Http.js.map +1 -1
- package/dist/ManifestSection.d.ts +101 -0
- package/dist/ManifestSection.d.ts.map +1 -0
- package/dist/ManifestSection.js +7 -0
- package/dist/ManifestSection.js.map +1 -0
- package/dist/Mount.d.ts +200 -0
- package/dist/Mount.d.ts.map +1 -0
- package/dist/Mount.js +116 -0
- package/dist/Mount.js.map +1 -0
- package/dist/PaginationError.js +1 -1
- package/dist/Profile.d.ts +95 -0
- package/dist/Profile.d.ts.map +1 -0
- package/dist/Profile.js +15 -0
- package/dist/Profile.js.map +1 -0
- package/dist/Ref.d.ts +4 -3
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +13 -19
- package/dist/Ref.js.map +1 -1
- package/dist/RefInternal.d.ts +3 -0
- package/dist/RefInternal.d.ts.map +1 -0
- package/dist/RefInternal.js +16 -0
- package/dist/RefInternal.js.map +1 -0
- package/dist/SchemaToValidator.d.ts +20 -6
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +45 -14
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/SystemFields.js +3 -3
- package/dist/Table.d.ts +48 -9
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +41 -13
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -6
- package/dist/internal/annotations.d.ts +2 -0
- package/dist/internal/annotations.d.ts.map +1 -0
- package/dist/internal/annotations.js +6 -0
- package/dist/internal/annotations.js.map +1 -0
- package/dist/internal/scalarDocs.d.ts +5 -0
- package/dist/internal/scalarDocs.d.ts.map +1 -0
- package/dist/internal/scalarDocs.js +43 -0
- package/dist/internal/scalarDocs.js.map +1 -0
- package/package.json +3 -3
- package/src/ActionCall.ts +25 -0
- package/src/App.ts +45 -136
- package/src/Auth.ts +54 -11
- package/src/Callback.ts +17 -4
- package/src/CommitTs.ts +26 -0
- package/src/Component.ts +204 -11
- package/src/FunctionSpec.ts +562 -5
- package/src/Http.ts +15 -37
- package/src/ManifestSection.ts +108 -0
- package/src/Mount.ts +401 -0
- package/src/Profile.ts +141 -0
- package/src/Ref.ts +19 -26
- package/src/RefInternal.ts +26 -0
- package/src/SchemaToValidator.ts +97 -22
- package/src/Table.ts +157 -23
- package/src/index.ts +5 -0
- package/src/internal/annotations.ts +1 -0
- package/src/internal/scalarDocs.ts +72 -0
package/dist/Callback.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Confect } from "./FunctionProvenance.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { getFunctionReference } from "./RefInternal.js";
|
|
4
|
+
import { fromProvenance, isRef } from "./Ref.js";
|
|
5
|
+
import { CallbackContract } from "./internal/annotations.js";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Predicate from "effect/Predicate";
|
|
6
8
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
7
9
|
//#region src/Callback.ts
|
|
8
10
|
var Callback_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -27,13 +29,16 @@ const query = make("query");
|
|
|
27
29
|
const mutation = make("mutation");
|
|
28
30
|
const action = make("action");
|
|
29
31
|
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 });
|
|
32
|
+
const fromText = (contract, text, reservedArgument) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text, contract.functionType, contract.functionType === "query" ? void 0 : reservedArgument), { [HandleTypeId]: contract.id });
|
|
31
33
|
/**
|
|
32
34
|
* The schema of a handle for `contract`: a string on the wire, a runnable ref
|
|
33
|
-
* once decoded. Use it in a component's function args or tables.
|
|
35
|
+
* once decoded. Use it in a component's function args or tables. It lowers to
|
|
36
|
+
* Convex's `v.function` with the contract's encoded args and returns.
|
|
37
|
+
* `reservedArgument` opts mutation and action handles into context forwarding.
|
|
38
|
+
* The host target must reserve the same argument name.
|
|
34
39
|
*/
|
|
35
|
-
const handle = (contract) => Schema.String.pipe(Schema.decodeTo(Schema.declare(isHandleOf(contract), { identifier: `Callback.Handle<${contract.id}>` }), {
|
|
36
|
-
decode: SchemaGetter.transform((text) => fromText(contract, text)),
|
|
40
|
+
const handle = (contract, options) => Schema.String.annotate({ [CallbackContract]: contract }).pipe(Schema.decodeTo(Schema.declare(isHandleOf(contract), { identifier: `Callback.Handle<${contract.id}>` }), {
|
|
41
|
+
decode: SchemaGetter.transform((text) => fromText(contract, text, options?.reservedArgument)),
|
|
37
42
|
encode: SchemaGetter.transform((ref) => ref.convexFunctionName)
|
|
38
43
|
}));
|
|
39
44
|
/**
|
package/dist/Callback.js.map
CHANGED
|
@@ -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"],"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 { getFunctionReference } from \"./RefInternal.js\";\nimport { CallbackContract } from \"./internal/annotations.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 reservedArgument?: 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 contract.functionType === \"query\" ? undefined : reservedArgument,\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. It lowers to\n * Convex's `v.function` with the contract's encoded args and returns.\n * `reservedArgument` opts mutation and action handles into context forwarding.\n * The host target must reserve the same argument name.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n options?: {\n readonly reservedArgument?: Contract_[\"functionType\"] extends \"query\"\n ? never\n : string;\n },\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.annotate({ [CallbackContract]: contract }).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, options?.reservedArgument),\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> => getFunctionReference(ref) as never;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,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,MACA,qBAEA,OAAO,OACLC,eACE,MACA,SAAS,oBACT,CAAC,GAED,MACA,SAAS,cACT,SAAS,iBAAiB,UAAU,KAAA,IAAY,gBAClD,GACA,GAAG,eAAe,SAAS,GAAG,CAChC;;;;;;;;AASF,MAAa,UACX,UACA,YAMA,OAAO,OAAO,SAAS,GAAG,mBAAmB,SAAS,CAAC,CAAC,CAAC,KACvD,OAAO,SACL,OAAO,QAAQ,WAAW,QAAQ,GAAG,EACnC,YAAY,mBAAmB,SAAS,GAAG,GAC7C,CAAC,GACD;CACE,QAAQ,aAAa,WAAW,SAC9B,SAAS,UAAU,MAAM,SAAS,gBAAgB,CACpD;CACA,QAAQ,aAAa,WAClB,QAA2B,IAAI,kBAClC;AACF,CACF,CACF;;;;;AA4HF,MAAa,YACX,QAMG,qBAAqB,GAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommitTsPlaceholder } from "convex/values";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
4
|
+
/**
|
|
5
|
+
* A commit timestamp as Convex types it. A mutation writes the database
|
|
6
|
+
* writer's `vars.commitTs` placeholder, which resolves to an int64 when the
|
|
7
|
+
* mutation commits. Reading the field back inside that mutation still yields
|
|
8
|
+
* the placeholder, so a reader narrows with `typeof value === "bigint"` before
|
|
9
|
+
* using it as a number.
|
|
10
|
+
*/
|
|
11
|
+
export type CommitTs = bigint | CommitTsPlaceholder;
|
|
12
|
+
/**
|
|
13
|
+
* A field Convex stores as `v.commitTs()`. An index on it orders documents by
|
|
14
|
+
* commit order.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CommitTs: Schema.Codec<CommitTs>;
|
|
17
|
+
export declare const isCommitTs: (ast: SchemaAST.AST) => boolean;
|
|
18
|
+
//# sourceMappingURL=CommitTs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommitTs.d.ts","sourceRoot":"","sources":["../src/CommitTs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAI9C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAGL,CAAC;AAExC,eAAO,MAAM,UAAU,QAAS,SAAS,CAAC,GAAG,KAAG,OACY,CAAC"}
|
package/dist/CommitTs.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
4
|
+
import { CommitTsPlaceholder } from "convex/values";
|
|
5
|
+
//#region src/CommitTs.ts
|
|
6
|
+
var CommitTs_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
CommitTs: () => CommitTs,
|
|
8
|
+
isCommitTs: () => isCommitTs
|
|
9
|
+
});
|
|
10
|
+
const ConvexCommitTs = "~@confect/core/ConvexCommitTs";
|
|
11
|
+
/**
|
|
12
|
+
* A field Convex stores as `v.commitTs()`. An index on it orders documents by
|
|
13
|
+
* commit order.
|
|
14
|
+
*/
|
|
15
|
+
const CommitTs = Schema.Union([Schema.BigInt, Schema.instanceOf(CommitTsPlaceholder)]).annotate({ [ConvexCommitTs]: true });
|
|
16
|
+
const isCommitTs = (ast) => SchemaAST.resolveAt(ConvexCommitTs)(ast) === true;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CommitTs, CommitTs_exports, isCommitTs };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=CommitTs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommitTs.js","names":[],"sources":["../src/CommitTs.ts"],"sourcesContent":["import { CommitTsPlaceholder } from \"convex/values\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\n\nconst ConvexCommitTs = \"~@confect/core/ConvexCommitTs\";\n\n/**\n * A commit timestamp as Convex types it. A mutation writes the database\n * writer's `vars.commitTs` placeholder, which resolves to an int64 when the\n * mutation commits. Reading the field back inside that mutation still yields\n * the placeholder, so a reader narrows with `typeof value === \"bigint\"` before\n * using it as a number.\n */\nexport type CommitTs = bigint | CommitTsPlaceholder;\n\n/**\n * A field Convex stores as `v.commitTs()`. An index on it orders documents by\n * commit order.\n */\nexport const CommitTs: Schema.Codec<CommitTs> = Schema.Union([\n Schema.BigInt,\n Schema.instanceOf(CommitTsPlaceholder),\n]).annotate({ [ConvexCommitTs]: true });\n\nexport const isCommitTs = (ast: SchemaAST.AST): boolean =>\n SchemaAST.resolveAt<boolean>(ConvexCommitTs)(ast) === true;\n"],"mappings":";;;;;;;;;AAIA,MAAM,iBAAiB;;;;;AAevB,MAAa,WAAmC,OAAO,MAAM,CAC3D,OAAO,QACP,OAAO,WAAW,mBAAmB,CACvC,CAAC,CAAC,CAAC,SAAS,GAAG,iBAAiB,KAAK,CAAC;AAEtC,MAAa,cAAc,QACzB,UAAU,UAAmB,cAAc,CAAC,CAAC,GAAG,MAAM"}
|
package/dist/Component.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as Ref from "./Ref.js";
|
|
|
8
8
|
import type * as Refs from "./Refs.js";
|
|
9
9
|
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
10
10
|
import * as Spec from "./Spec.js";
|
|
11
|
+
import type * as Table_ from "./Table.js";
|
|
11
12
|
declare const EmptyComponentScopeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
12
13
|
readonly _tag: "EmptyComponentScopeError";
|
|
13
14
|
} & Readonly<A>;
|
|
@@ -56,14 +57,60 @@ export type Api<Spec_ extends Spec.AnyWithProps, Name extends string | undefined
|
|
|
56
57
|
interface Tree {
|
|
57
58
|
readonly [key: string]: Tree | Ref.Any;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Each grouped table's name, mapped to its id field and that id's table.
|
|
62
|
+
*/
|
|
63
|
+
export interface GroupMap {
|
|
64
|
+
readonly [table: string]: {
|
|
65
|
+
readonly key: string;
|
|
66
|
+
readonly table: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface Component<Spec_ extends Spec.AnyWithProps, Scope extends IdScope.IdScope, Tables extends string = string, Groups_ extends GroupMap = GroupMap> {
|
|
60
70
|
readonly [TypeId]: {
|
|
61
71
|
readonly refs: Tree;
|
|
62
72
|
readonly scope: Scope;
|
|
63
73
|
readonly tables: ReadonlyArray<Tables>;
|
|
74
|
+
readonly groups: Groups_;
|
|
64
75
|
};
|
|
65
76
|
readonly "~Spec": Spec_;
|
|
66
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* A component's tables as `contract` takes them: a table, or the name of a
|
|
80
|
+
* system table.
|
|
81
|
+
*/
|
|
82
|
+
export type TableEntry = string | Table_.AnyWithProps;
|
|
83
|
+
type EntryName<Entry extends TableEntry> = Entry extends string ? Entry : Entry extends Table_.AnyWithProps ? Table_.Name<Entry> : never;
|
|
84
|
+
type Many<A, All = A> = string extends A ? true : number extends A ? true : A extends unknown ? [All] extends [A] ? never : true : never;
|
|
85
|
+
type Loose<Entries extends ReadonlyArray<TableEntry>> = true extends Many<Entries> | Many<Entries["length"]> | {
|
|
86
|
+
[Index in keyof Entries]: Many<Entries[Index]>;
|
|
87
|
+
}[number] ? "pass one table or one name per entry; a union may be absent at runtime" : never;
|
|
88
|
+
type StrayGroup<Entries extends ReadonlyArray<TableEntry>, Scope extends IdScope.IdScope> = [Loose<Entries>] extends [never] ? {
|
|
89
|
+
[Index in keyof Entries]: Entries[Index] extends {
|
|
90
|
+
readonly tableName: infer Name extends string;
|
|
91
|
+
readonly group: Table_.Group<infer Key, infer Target, infer GroupScope>;
|
|
92
|
+
} ? [Target, GroupScope] extends [EntryName<Entries[number]>, Scope] ? never : `${Name}.${Key} is not an id of a table of this component` : never;
|
|
93
|
+
}[number] : Loose<Entries>;
|
|
94
|
+
/**
|
|
95
|
+
* The group map `contract` publishes for these table entries.
|
|
96
|
+
*/
|
|
97
|
+
export type Groups<Entries extends ReadonlyArray<TableEntry>> = {
|
|
98
|
+
readonly [Entry in Extract<Entries[number], {
|
|
99
|
+
readonly tableName: string;
|
|
100
|
+
readonly group: Table_.Group;
|
|
101
|
+
}> as Entry["tableName"]]: {
|
|
102
|
+
readonly key: Entry["group"]["key"];
|
|
103
|
+
readonly table: Entry["group"]["table"];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* `unknown` when every entry is one table or name and every group's id names a
|
|
108
|
+
* table of this component in its scope, otherwise an object type naming the
|
|
109
|
+
* refused entry.
|
|
110
|
+
*/
|
|
111
|
+
export type CheckGroups<Entries extends ReadonlyArray<TableEntry>, Scope extends IdScope.IdScope> = [StrayGroup<Entries, Scope>] extends [never] ? unknown : {
|
|
112
|
+
readonly "~StrayGroup": StrayGroup<Entries, Scope>;
|
|
113
|
+
};
|
|
67
114
|
/**
|
|
68
115
|
* An opaque identity: its string representation is not part of the API.
|
|
69
116
|
*/
|
|
@@ -87,8 +134,18 @@ export type Bound<Spec_ extends Spec.AnyWithProps, From extends IdScope.IdScope,
|
|
|
87
134
|
};
|
|
88
135
|
/**
|
|
89
136
|
* Build a publishable contract containing only exported functions and codecs.
|
|
137
|
+
* `tables` lists the component's tables, each a table or a system table's name.
|
|
138
|
+
* A table grouped by an id must group by an id of one of these tables.
|
|
139
|
+
*/
|
|
140
|
+
export declare function contract<Spec_ extends Spec.AnyWithProps, const Scope extends IdScope.IdScope, const Entries extends ReadonlyArray<TableEntry>>(spec: Spec_, scope: Scope, tables: Entries & CheckGroups<Entries, Scope>): Component<Spec_, Scope, EntryName<Entries[number]>, Groups<Entries>>;
|
|
141
|
+
/**
|
|
142
|
+
* Table names alone, as in an explicit third type argument, carry no groups.
|
|
90
143
|
*/
|
|
91
|
-
export declare
|
|
144
|
+
export declare function contract<Spec_ extends Spec.AnyWithProps, const Scope extends IdScope.IdScope, const Tables extends string>(spec: Spec_, scope: Scope, tables: ReadonlyArray<Tables>): Component<Spec_, Scope, Tables, {}>;
|
|
145
|
+
/**
|
|
146
|
+
* Each grouped table's id field and the table that id names.
|
|
147
|
+
*/
|
|
148
|
+
export declare const groups: <Groups_ extends GroupMap>(component: Component<Spec.AnyWithProps, IdScope.IdScope, string, Groups_>) => Groups_;
|
|
92
149
|
/**
|
|
93
150
|
* Bind the published contract to an actual installed component reference.
|
|
94
151
|
*/
|
|
@@ -115,5 +172,52 @@ export declare const schema: <From extends IdScope.IdScope, To extends IdScope.I
|
|
|
115
172
|
readonly scope: To;
|
|
116
173
|
};
|
|
117
174
|
}, codec: Schema_) => GenericId.RebaseSchema<Schema_, From, To>;
|
|
175
|
+
/**
|
|
176
|
+
* A component's `init`: an internal Confect mutation whose args are the install
|
|
177
|
+
* args each mount passes.
|
|
178
|
+
*/
|
|
179
|
+
export type Init = Ref.AnyConfect & {
|
|
180
|
+
readonly "~RuntimeAndFunctionType": RuntimeAndFunctionType.ConvexMutation;
|
|
181
|
+
readonly "~FunctionVisibility": "internal";
|
|
182
|
+
};
|
|
183
|
+
export interface DescriptorOptions {
|
|
184
|
+
readonly init?: Init;
|
|
185
|
+
/**
|
|
186
|
+
* The component's `_generated/component` contract. A mount of a descriptor
|
|
187
|
+
* with one rebases a callback slot's args with `callbackArgs`.
|
|
188
|
+
*/
|
|
189
|
+
readonly contract?: Component<Spec.AnyWithProps, IdScope.IdScope, string>;
|
|
190
|
+
readonly env?: Readonly<Record<string, Schema.Top>>;
|
|
191
|
+
/**
|
|
192
|
+
* The package specifier of the test kit whose `register(t, name)` installs
|
|
193
|
+
* this component and its children under `TestConfect`, such as
|
|
194
|
+
* `"@acme/email/testing"`. Codegen imports it for each mount of the
|
|
195
|
+
* descriptor from another package in place of `<package>/testing` or
|
|
196
|
+
* `<package>/test`. A local component's mount ignores it.
|
|
197
|
+
*/
|
|
198
|
+
readonly testing?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Builds the component's client from its native mount, then the mount's
|
|
201
|
+
* `options` when the client takes any.
|
|
202
|
+
*/
|
|
203
|
+
readonly client: (...args: never) => unknown;
|
|
204
|
+
}
|
|
205
|
+
export type Descriptor<Name extends string = string, Options extends DescriptorOptions = DescriptorOptions> = Options & {
|
|
206
|
+
readonly name: Name;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Describe a Convex component for `Mount.make`, as `defineComponent` does for
|
|
210
|
+
* Convex. A component with `init` takes install `args` at each mount, and one
|
|
211
|
+
* with `env` takes `env`. Export it from the package's `./client` entry.
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* export default Component.make("email", {
|
|
215
|
+
* init: refs.internal.install.init,
|
|
216
|
+
* env: { RESEND_API_KEY: Schema.String },
|
|
217
|
+
* client: Client.make,
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare const make: <const Name extends string, const Options extends DescriptorOptions>(name: Name, options: Options) => Descriptor<Name, Options>;
|
|
118
222
|
export {};
|
|
119
223
|
//# sourceMappingURL=Component.d.ts.map
|
package/dist/Component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQ5E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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;AAEJ;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,GAAG;IAClC,QAAQ,CAAC,yBAAyB,EAAE,sBAAsB,CAAC,cAAc,CAAC;IAC1E,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC;CAC5C,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1E,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;CAC9C;AAED,MAAM,MAAM,UAAU,CACpB,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,IACnD,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,CAAC,OAAO,SAAS,iBAAiB,QAEjC,IAAI,WACD,OAAO,KACf,UAAU,CAAC,IAAI,EAAE,OAAO,CAA2B,CAAC"}
|
package/dist/Component.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineProperty } from "./Lazy.js";
|
|
|
3
3
|
import { fromProvenance, isRef, make as make$1 } from "./Ref.js";
|
|
4
4
|
import { app, instance } from "./IdScope.js";
|
|
5
5
|
import { GenericId, rebase } from "./GenericId.js";
|
|
6
|
-
import { groups } from "./Spec.js";
|
|
6
|
+
import { groups as groups$1 } from "./Spec.js";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as Data from "effect/Data";
|
|
9
9
|
import { getFunctionAddress } from "convex/server";
|
|
@@ -18,6 +18,8 @@ var Component_exports = /* @__PURE__ */ __exportAll({
|
|
|
18
18
|
EmptyComponentScopeError: () => EmptyComponentScopeError,
|
|
19
19
|
UninstalledComponentReferenceError: () => UninstalledComponentReferenceError,
|
|
20
20
|
bind: () => bind,
|
|
21
|
+
contract: () => contract,
|
|
22
|
+
groups: () => groups,
|
|
21
23
|
id: () => id,
|
|
22
24
|
make: () => make,
|
|
23
25
|
schema: () => schema
|
|
@@ -52,11 +54,8 @@ const validateNames = (groups, prefix = "") => {
|
|
|
52
54
|
const validateContract = (scope, groups) => scope === "" ? Result.fail(new EmptyComponentScopeError({ definitionScope: scope })) : validateNames(groups);
|
|
53
55
|
const TypeId = "~@confect/core/Component";
|
|
54
56
|
const BoundTypeId = "~@confect/core/BoundComponent";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
const make = (spec, scope, tables) => {
|
|
59
|
-
const specGroups = groups(spec);
|
|
57
|
+
function contract(spec, scope, tables) {
|
|
58
|
+
const specGroups = groups$1(spec);
|
|
60
59
|
Result.getOrThrow(validateContract(scope, specGroups));
|
|
61
60
|
const collect = (groups, prefix = "") => pipe(groups, Record.map((group, name) => {
|
|
62
61
|
const path = prefix === "" ? name : `${prefix}/${name}`;
|
|
@@ -68,21 +67,31 @@ const make = (spec, scope, tables) => {
|
|
|
68
67
|
...functions
|
|
69
68
|
};
|
|
70
69
|
}), Record.filter((children) => !Record.isEmptyRecord(children)));
|
|
71
|
-
|
|
70
|
+
const grouped = pipe(tables, Array.flatMap((entry) => typeof entry !== "string" && entry.group !== void 0 ? [[entry.tableName, entry.group]] : []), Record.fromEntries);
|
|
71
|
+
const published = {
|
|
72
72
|
refs: collect(specGroups),
|
|
73
73
|
scope,
|
|
74
|
-
tables
|
|
75
|
-
|
|
76
|
-
};
|
|
74
|
+
tables: Array.map(tables, (entry) => typeof entry === "string" ? entry : entry.tableName),
|
|
75
|
+
groups: grouped
|
|
76
|
+
};
|
|
77
|
+
return { [TypeId]: published };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Each grouped table's id field and the table that id names.
|
|
81
|
+
*/
|
|
82
|
+
const groups = (component) => Record.map(component[TypeId].groups, ({ key, table }) => ({
|
|
83
|
+
key,
|
|
84
|
+
table
|
|
85
|
+
}));
|
|
77
86
|
/**
|
|
78
87
|
* Bind the published contract to an actual installed component reference.
|
|
79
88
|
*/
|
|
80
89
|
const bind = (component, native, options) => {
|
|
81
|
-
const
|
|
90
|
+
const published = component[TypeId];
|
|
82
91
|
const address = getFunctionAddress(native);
|
|
83
|
-
const installedReference = Result.getOrThrow(Result.fromNullishOr(address.reference, () => new UninstalledComponentReferenceError({ definitionScope:
|
|
92
|
+
const installedReference = Result.getOrThrow(Result.fromNullishOr(address.reference, () => new UninstalledComponentReferenceError({ definitionScope: published.scope })));
|
|
84
93
|
const scope = instance(options?.parentScope ?? app, installedReference);
|
|
85
|
-
const rebase$1 = (schema) => rebase(schema,
|
|
94
|
+
const rebase$1 = (schema) => rebase(schema, published.scope, scope);
|
|
86
95
|
const rebaseMiddleware = memoize((middleware) => {
|
|
87
96
|
if (!("error" in middleware)) return middleware;
|
|
88
97
|
const boundMiddleware = Object.create(middleware);
|
|
@@ -119,15 +128,15 @@ const bind = (component, native, options) => {
|
|
|
119
128
|
return fromProvenance(ref.convexFunctionName, provenance, Array.map(ref.middlewareAttachments, (attachment) => ({
|
|
120
129
|
...attachment,
|
|
121
130
|
spec: rebaseMiddleware(attachment.spec)
|
|
122
|
-
})), nativeRef);
|
|
131
|
+
})), nativeRef, ref.functionType, ref.reservedArgument);
|
|
123
132
|
}), Match.exhaustive);
|
|
124
133
|
} else return visit(child, reference);
|
|
125
134
|
});
|
|
126
|
-
const refs = visit(
|
|
135
|
+
const refs = visit(published.refs, native);
|
|
127
136
|
Object.defineProperty(refs, BoundTypeId, { value: {
|
|
128
|
-
from:
|
|
137
|
+
from: published.scope,
|
|
129
138
|
scope,
|
|
130
|
-
tables:
|
|
139
|
+
tables: published.tables
|
|
131
140
|
} });
|
|
132
141
|
return refs;
|
|
133
142
|
};
|
|
@@ -140,7 +149,24 @@ const id = (component, table) => GenericId(table, component[BoundTypeId].scope);
|
|
|
140
149
|
* scope.
|
|
141
150
|
*/
|
|
142
151
|
const schema = (component, codec) => rebase(codec, component[BoundTypeId].from, component[BoundTypeId].scope);
|
|
152
|
+
/**
|
|
153
|
+
* Describe a Convex component for `Mount.make`, as `defineComponent` does for
|
|
154
|
+
* Convex. A component with `init` takes install `args` at each mount, and one
|
|
155
|
+
* with `env` takes `env`. Export it from the package's `./client` entry.
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* export default Component.make("email", {
|
|
159
|
+
* init: refs.internal.install.init,
|
|
160
|
+
* env: { RESEND_API_KEY: Schema.String },
|
|
161
|
+
* client: Client.make,
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
const make = (name, options) => ({
|
|
166
|
+
...options,
|
|
167
|
+
name
|
|
168
|
+
});
|
|
143
169
|
//#endregion
|
|
144
|
-
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind, id, make, schema };
|
|
170
|
+
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind, contract, groups, id, make, schema };
|
|
145
171
|
|
|
146
172
|
//# sourceMappingURL=Component.js.map
|
package/dist/Component.js.map
CHANGED
|
@@ -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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,OAAO;KACT,CAAC,GACD,MAAM,UACR;IACF;IACA,eAAoB,YAAY,cAC9B,OAAO,OAAO,OAAO,IAAI,IAAI,KAAK,QAAQA,QAAM,CAAC,CACnD;IACA,eAAoB,YAAY,iBAC9BA,SAAO,IAAI,OAAO,CACpB;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\";\nimport type * as Table_ from \"./Table.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\n/**\n * Each grouped table's name, mapped to its id field and that id's table.\n */\nexport interface GroupMap {\n readonly [table: string]: { readonly key: string; readonly table: string };\n}\n\nexport interface Component<\n Spec_ extends Spec.AnyWithProps,\n Scope extends IdScope.IdScope,\n Tables extends string = string,\n Groups_ extends GroupMap = GroupMap,\n> {\n readonly [TypeId]: {\n readonly refs: Tree;\n readonly scope: Scope;\n readonly tables: ReadonlyArray<Tables>;\n readonly groups: Groups_;\n };\n readonly \"~Spec\": Spec_;\n}\n\n/**\n * A component's tables as `contract` takes them: a table, or the name of a\n * system table.\n */\nexport type TableEntry = string | Table_.AnyWithProps;\n\ntype EntryName<Entry extends TableEntry> = Entry extends string\n ? Entry\n : Entry extends Table_.AnyWithProps\n ? Table_.Name<Entry>\n : never;\n\ntype Many<A, All = A> = string extends A\n ? true\n : number extends A\n ? true\n : A extends unknown\n ? [All] extends [A]\n ? never\n : true\n : never;\n\ntype Loose<Entries extends ReadonlyArray<TableEntry>> = true extends\n | Many<Entries>\n | Many<Entries[\"length\"]>\n | { [Index in keyof Entries]: Many<Entries[Index]> }[number]\n ? \"pass one table or one name per entry; a union may be absent at runtime\"\n : never;\n\ntype StrayGroup<\n Entries extends ReadonlyArray<TableEntry>,\n Scope extends IdScope.IdScope,\n> = [Loose<Entries>] extends [never]\n ? {\n [Index in keyof Entries]: Entries[Index] extends {\n readonly tableName: infer Name extends string;\n readonly group: Table_.Group<infer Key, infer Target, infer GroupScope>;\n }\n ? [Target, GroupScope] extends [EntryName<Entries[number]>, Scope]\n ? never\n : `${Name}.${Key} is not an id of a table of this component`\n : never;\n }[number]\n : Loose<Entries>;\n\n/**\n * The group map `contract` publishes for these table entries.\n */\nexport type Groups<Entries extends ReadonlyArray<TableEntry>> = {\n readonly [\n Entry in Extract<\n Entries[number],\n { readonly tableName: string; readonly group: Table_.Group }\n > as Entry[\"tableName\"]\n ]: {\n readonly key: Entry[\"group\"][\"key\"];\n readonly table: Entry[\"group\"][\"table\"];\n };\n};\n\n/**\n * `unknown` when every entry is one table or name and every group's id names a\n * table of this component in its scope, otherwise an object type naming the\n * refused entry.\n */\nexport type CheckGroups<\n Entries extends ReadonlyArray<TableEntry>,\n Scope extends IdScope.IdScope,\n> = [StrayGroup<Entries, Scope>] extends [never]\n ? unknown\n : { readonly \"~StrayGroup\": StrayGroup<Entries, Scope> };\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 * `tables` lists the component's tables, each a table or a system table's name.\n * A table grouped by an id must group by an id of one of these tables.\n */\nexport function contract<\n Spec_ extends Spec.AnyWithProps,\n const Scope extends IdScope.IdScope,\n const Entries extends ReadonlyArray<TableEntry>,\n>(\n spec: Spec_,\n scope: Scope,\n tables: Entries & CheckGroups<Entries, Scope>,\n): Component<Spec_, Scope, EntryName<Entries[number]>, Groups<Entries>>;\n/**\n * Table names alone, as in an explicit third type argument, carry no groups.\n */\nexport function contract<\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, {}>;\nexport function contract(\n spec: Spec.AnyWithProps,\n scope: IdScope.IdScope,\n tables: ReadonlyArray<TableEntry>,\n): Component<Spec.AnyWithProps, IdScope.IdScope> {\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 const grouped: GroupMap = pipe(\n tables,\n Array.flatMap((entry) =>\n typeof entry !== \"string\" && entry.group !== undefined\n ? [[entry.tableName, entry.group] as const]\n : [],\n ),\n Record.fromEntries,\n );\n const published: Component<\n Spec.AnyWithProps,\n IdScope.IdScope\n >[typeof TypeId] = {\n refs: collect(specGroups),\n scope,\n tables: Array.map(tables, (entry) =>\n typeof entry === \"string\" ? entry : entry.tableName,\n ),\n groups: grouped,\n };\n return { [TypeId]: published } as Component<\n Spec.AnyWithProps,\n IdScope.IdScope\n >;\n}\n\n/**\n * Each grouped table's id field and the table that id names.\n */\nexport const groups = <Groups_ extends GroupMap>(\n component: Component<Spec.AnyWithProps, IdScope.IdScope, string, Groups_>,\n): Groups_ =>\n Record.map(component[TypeId].groups, ({ key, table }) => ({\n key,\n table,\n })) as Groups_;\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 published = component[TypeId];\n const address = getFunctionAddress(native);\n const installedReference = Result.getOrThrow(\n Result.fromNullishOr(\n address.reference,\n () =>\n new UninstalledComponentReferenceError({\n definitionScope: published.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, published.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 ref.reservedArgument,\n );\n }),\n Match.exhaustive,\n );\n } else {\n return visit(child, reference);\n }\n });\n const refs = visit(published.refs, native);\n Object.defineProperty(refs, BoundTypeId, {\n value: { from: published.scope, scope, tables: published.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\n/**\n * A component's `init`: an internal Confect mutation whose args are the install\n * args each mount passes.\n */\nexport type Init = Ref.AnyConfect & {\n readonly \"~RuntimeAndFunctionType\": RuntimeAndFunctionType.ConvexMutation;\n readonly \"~FunctionVisibility\": \"internal\";\n};\n\nexport interface DescriptorOptions {\n readonly init?: Init;\n /**\n * The component's `_generated/component` contract. A mount of a descriptor\n * with one rebases a callback slot's args with `callbackArgs`.\n */\n readonly contract?: Component<Spec.AnyWithProps, IdScope.IdScope, string>;\n readonly env?: Readonly<Record<string, Schema.Top>>;\n /**\n * The package specifier of the test kit whose `register(t, name)` installs\n * this component and its children under `TestConfect`, such as\n * `\"@acme/email/testing\"`. Codegen imports it for each mount of the\n * descriptor from another package in place of `<package>/testing` or\n * `<package>/test`. A local component's mount ignores it.\n */\n readonly testing?: string;\n /**\n * Builds the component's client from its native mount, then the mount's\n * `options` when the client takes any.\n */\n readonly client: (...args: never) => unknown;\n}\n\nexport type Descriptor<\n Name extends string = string,\n Options extends DescriptorOptions = DescriptorOptions,\n> = Options & { readonly name: Name };\n\n/**\n * Describe a Convex component for `Mount.make`, as `defineComponent` does for\n * Convex. A component with `init` takes install `args` at each mount, and one\n * with `env` takes `env`. Export it from the package's `./client` entry.\n *\n * ```ts\n * export default Component.make(\"email\", {\n * init: refs.internal.install.init,\n * env: { RESEND_API_KEY: Schema.String },\n * client: Client.make,\n * });\n * ```\n */\nexport const make = <\n const Name extends string,\n const Options extends DescriptorOptions,\n>(\n name: Name,\n options: Options,\n): Descriptor<Name, Options> => ({ ...options, name });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,2BAAb,cAA8C,KAAK,YACjD,0BACF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