@gaganref/confect-core 10.3.1-fork.1 → 10.3.1-fork.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +2 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.d.ts +3 -3
- package/dist/Callback.d.ts.map +1 -1
- package/dist/Callback.js.map +1 -1
- package/dist/Component.d.ts +8 -8
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js.map +1 -1
- package/dist/FunctionProvenance.d.ts +2 -2
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +4 -4
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +2 -2
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +1 -1
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupPath.js.map +1 -1
- package/dist/GroupSpec.d.ts +4 -4
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Http.d.ts +1 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js.map +1 -1
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +1 -1
- package/dist/MiddlewareAttachment.d.ts.map +1 -1
- package/dist/MiddlewareAttachment.js.map +1 -1
- package/dist/MiddlewareSpec.d.ts +3 -3
- package/dist/MiddlewareSpec.d.ts.map +1 -1
- package/dist/MiddlewareSpec.js.map +1 -1
- package/dist/Ref.d.ts +5 -5
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +5 -5
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +2 -2
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Spec.d.ts +1 -1
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +2 -2
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.d.ts +3 -3
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.ts +1 -1
- package/src/Auth.ts +2 -2
- package/src/Callback.ts +3 -3
- package/src/Component.ts +11 -11
- package/src/FunctionProvenance.ts +3 -3
- package/src/FunctionSpec.ts +5 -5
- package/src/GenericId.ts +2 -2
- package/src/GroupPath.ts +1 -1
- package/src/GroupSpec.ts +5 -5
- package/src/Http.ts +1 -1
- package/src/Manifest.ts +1 -1
- package/src/MiddlewareAttachment.ts +1 -1
- package/src/MiddlewareSpec.ts +4 -4
- package/src/Ref.ts +6 -6
- package/src/Refs.ts +5 -5
- package/src/SchemaToValidator.ts +3 -3
- package/src/Spec.ts +1 -1
- package/src/SystemFields.ts +2 -2
- package/src/Table.ts +4 -4
- package/src/index.ts +29 -29
package/dist/Spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spec.js","names":["GroupSpec.withName"],"sources":["../src/Spec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as GroupSpec from \"./GroupSpec\";\n\nexport const TypeId = \"~@confect/core/Spec\";\nexport type TypeId = typeof TypeId;\n\nexport const isSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A Confect spec: a flat container of function groups. Groups may be of any\n * runtime—a group built with `GroupSpec.makeNode()` (a Node action group) sits\n * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a\n * group lives on the group itself (`GroupSpec.runtime`) and on each function's\n * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.\n */\nexport interface Spec<\n Groups_ extends Record.ReadonlyRecord<string, GroupSpec.AnyWithProps> = {},\n> {\n readonly [TypeId]: Readonly<Groups_>;\n}\n\nexport interface Any {\n readonly [TypeId]: unknown;\n}\n\nexport interface AnyWithProps extends Any {\n readonly [TypeId]: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>;\n}\n\nexport type Groups<Spec_ extends AnyWithProps> =\n Spec_[TypeId][keyof Spec_[TypeId]];\n\n/**\n * The group record stored by a spec, with its precise member types.\n */\nexport const groups = <Spec_ extends AnyWithProps>(\n self: Spec_,\n): Spec_[TypeId] => self[TypeId];\n\nexport const fromGroups = (\n record: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n): AnyWithProps => ({\n [TypeId]: Record.map(record, (group, name) =>\n GroupSpec.withName(name, group),\n ),\n});\n"],"mappings":";;;;;;;;;;;AAIA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM;;;;AA6BjC,MAAa,UACX,SACkB,KAAK;AAEzB,MAAa,cACX,YACkB,GACjB,SAAS,OAAO,IAAI,SAAS,OAAO,SACnCA,SAAmB,MAAM,KAAK,CAChC,EACF"}
|
|
1
|
+
{"version":3,"file":"Spec.js","names":["GroupSpec.withName"],"sources":["../src/Spec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as GroupSpec from \"./GroupSpec.js\";\n\nexport const TypeId = \"~@confect/core/Spec\";\nexport type TypeId = typeof TypeId;\n\nexport const isSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A Confect spec: a flat container of function groups. Groups may be of any\n * runtime—a group built with `GroupSpec.makeNode()` (a Node action group) sits\n * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a\n * group lives on the group itself (`GroupSpec.runtime`) and on each function's\n * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.\n */\nexport interface Spec<\n Groups_ extends Record.ReadonlyRecord<string, GroupSpec.AnyWithProps> = {},\n> {\n readonly [TypeId]: Readonly<Groups_>;\n}\n\nexport interface Any {\n readonly [TypeId]: unknown;\n}\n\nexport interface AnyWithProps extends Any {\n readonly [TypeId]: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>;\n}\n\nexport type Groups<Spec_ extends AnyWithProps> =\n Spec_[TypeId][keyof Spec_[TypeId]];\n\n/**\n * The group record stored by a spec, with its precise member types.\n */\nexport const groups = <Spec_ extends AnyWithProps>(\n self: Spec_,\n): Spec_[TypeId] => self[TypeId];\n\nexport const fromGroups = (\n record: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n): AnyWithProps => ({\n [TypeId]: Record.map(record, (group, name) =>\n GroupSpec.withName(name, group),\n ),\n});\n"],"mappings":";;;;;;;;;;;AAIA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM;;;;AA6BjC,MAAa,UACX,SACkB,KAAK;AAEzB,MAAa,cACX,YACkB,GACjB,SAAS,OAAO,IAAI,SAAS,OAAO,SACnCA,SAAmB,MAAM,KAAK,CAChC,EACF"}
|
package/dist/SystemFields.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type * as IdScope from "./IdScope";
|
|
1
|
+
import type * as IdScope from "./IdScope.js";
|
|
2
2
|
import type { SystemFields as NonIdSystemFields } from "convex/server";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
import * as Struct from "effect/Struct";
|
|
5
|
-
import * as GenericId from "./GenericId";
|
|
5
|
+
import * as GenericId from "./GenericId.js";
|
|
6
6
|
/**
|
|
7
7
|
* Produces a schema for Convex system fields. In Confect, system fields include
|
|
8
8
|
* `_id`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemFields.d.ts","sourceRoot":"","sources":["../src/SystemFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"SystemFields.d.ts","sourceRoot":"","sources":["../src/SystemFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOvE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,SAAS,MAAM,EACxB,KAAK,CAAC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,aAEtC,SAAS,UACZ,KAAK;;;EAKX,CAAC;AAEL;;;GAGG;AACH,KAAK,eAAe,CAClB,SAAS,SAAS,MAAM,EACxB,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,IACzC,UAAU,CAAC,OAAO,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AA0HhE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,SAAS,MAAM,EACxB,WAAW,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1C,KAAK,CAAC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,aAEtC,SAAS,UACZ,WAAW,UACX,KAAK,KACZ,sBAAsB,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CA0CtD,CAAC;AAEF;;;;GAIG;AACH,KAAK,iBAAiB,CACp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,GACxB;IAAE,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;CAAE,GAAG,iBAAiB,GAChE,QAAQ,GACV,KAAK,CAAC"}
|
package/dist/SystemFields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemFields.js","names":["GenericId.GenericId"],"sources":["../src/SystemFields.ts"],"sourcesContent":["import type * as IdScope from \"./IdScope\";\nimport type { SystemFields as NonIdSystemFields } from \"convex/server\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as SchemaTransformation from \"effect/SchemaTransformation\";\nimport * as Struct from \"effect/Struct\";\nimport * as GenericId from \"./GenericId\";\n\n/**\n * Produces a schema for Convex system fields. In Confect, system fields include\n * `_id`.\n */\nexport const SystemFields = <\n TableName extends string,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n scope?: Scope,\n) =>\n Schema.Struct({\n _id: GenericId.GenericId(tableName, scope),\n _creationTime: Schema.Finite,\n });\n\n/**\n * The field map added to a table schema, derived from {@link SystemFields} so it\n * stays in lockstep with the runtime schema.\n */\ntype SystemFieldsFor<\n TableName extends string,\n Scope extends IdScope.IdScope = IdScope.App,\n> = ReturnType<typeof SystemFields<TableName, Scope>>[\"fields\"];\n\n/**\n * The system field names, derived from {@link SystemFields} so they stay in\n * lockstep with the schema.\n */\nconst systemFieldNames: ReadonlyArray<string> = Record.keys(\n SystemFields(\"\").fields,\n);\n\nconst isSystemFieldKey = (key: string | symbol): key is string =>\n Predicate.isString(key) && Array.contains(systemFieldNames, key);\n\nconst splitSystemFields = (input: { [key: PropertyKey]: unknown }) => {\n const keys = Reflect.ownKeys(input);\n const pick = (pickedKeys: ReadonlyArray<string | symbol>) =>\n Record.fromEntries(\n Array.map(pickedKeys, (key) => [key, input[key]] as const),\n );\n return {\n system: pick(Array.filter(keys, isSystemFieldKey)),\n rest: pick(Array.filter(keys, Predicate.not(isSystemFieldKey))),\n };\n};\n\n/**\n * Wraps a transformation getter so the system fields bypass it: they are split\n * off the input before the user-defined getter runs and merged back into its\n * output. Transformations construct fresh objects, so without this the system\n * fields would be dropped at every transformation step.\n */\nconst wrapGetter = <R>(\n getter: SchemaGetter.Getter<any, any, R>,\n): SchemaGetter.Getter<any, any, R> =>\n SchemaGetter.transformOptionalEffect((input, options) => {\n if (Option.isNone(input) || !Predicate.isObject(input.value)) {\n return SchemaGetter.run(getter, input, options);\n }\n const { system, rest } = splitSystemFields(input.value);\n return SchemaGetter.run(getter, Option.some(rest), options).pipe(\n Effect.map(\n Option.map((output) =>\n Predicate.isObject(output) ? Struct.assign(output, system) : output,\n ),\n ),\n );\n });\n\nconst wrapTransformation = (\n transformation: SchemaAST.Link[\"transformation\"],\n): SchemaTransformation.Transformation<any, any, any, any> => {\n if (!SchemaTransformation.isTransformation(transformation)) {\n throw new Error(\n \"Cannot extend a table schema that uses decoding/encoding middleware with system fields\",\n );\n }\n return new SchemaTransformation.Transformation(\n wrapGetter(transformation.decode),\n wrapGetter(transformation.encode),\n );\n};\n\n/**\n * Builds an AST walker that adds the given system-field property signatures to\n * every object node of a schema's AST—including each step of its encoding\n * chain—wrapping transformations so the fields survive them.\n */\nconst makeExtendAst = (\n systemPropertySignatures: ReadonlyArray<SchemaAST.PropertySignature>,\n) => {\n const extendEncoding = (encoding: SchemaAST.Encoding): SchemaAST.Encoding =>\n Array.map(\n encoding,\n (link) =>\n new SchemaAST.Link(\n extendAst(link.to),\n wrapTransformation(link.transformation),\n ),\n );\n\n const extendAst = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (SchemaAST.isUnion(ast)) {\n return new SchemaAST.Union(\n Array.map(ast.types, extendAst),\n ast.options,\n ast.annotations,\n ast.checks,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n ast.encodingChecks,\n );\n }\n if (SchemaAST.isSuspend(ast)) {\n return new SchemaAST.Suspend(\n () => extendAst(ast.thunk()),\n ast.annotations,\n undefined,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n );\n }\n if (SchemaAST.isObjects(ast)) {\n return new SchemaAST.Objects(\n Array.appendAll(ast.propertySignatures, systemPropertySignatures),\n ast.indexSignatures,\n ast.annotations,\n ast.checks,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n ast.encodingChecks,\n );\n }\n throw new Error(\n ast._tag === \"Declaration\"\n ? \"Cannot extend a `Declaration` schema (such as a `Schema.Class`) with system fields: its decoded values are constructed instances, which cannot gain extra fields. Use a plain `Schema.Struct`, or transform to one with `Schema.decodeTo`.\"\n : `Cannot extend a \\`${ast._tag}\\` schema node with system fields: a table schema must resolve to an object shape at every step of its encoding.`,\n );\n };\n\n return extendAst;\n};\n\n/**\n * Extend a table schema with Convex system fields.\n *\n * A plain `Struct` gains the fields via `mapFields` and a `Union` has them\n * distributed across its members via `mapMembers`, preserving the schema's\n * checks and `Struct`/`Union` structure. Any other object-shaped schema—one\n * built with `Schema.decodeTo`/`Schema.encodeKeys`, a branded struct, a\n * suspended schema—is extended at the AST level: every object node in its\n * encoding chain gains the system fields, and each transformation is wrapped so\n * the fields bypass the user-defined getters. Schemas that do not resolve to an\n * object shape at every step (such as `Schema.Class`, whose decoded values are\n * class instances) are rejected with a descriptive error.\n *\n * Note that struct-level checks on an extended schema observe the value with\n * the system fields attached, and encoding an extended schema emits the system\n * fields alongside the table fields.\n */\nexport const extendWithSystemFields = <\n TableName extends string,\n TableSchema extends Schema.Codec<any, any>,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n schema: TableSchema,\n scope?: Scope,\n): ExtendWithSystemFields<TableName, TableSchema, Scope> => {\n const system = SystemFields(tableName, scope).fields;\n\n const extendAst = makeExtendAst(\n pipe(\n system,\n Record.toEntries,\n Array.map(\n ([name, field]) => new SchemaAST.PropertySignature(name, field.ast),\n ),\n ),\n );\n\n const extend = (s: Schema.Top): Schema.Top => {\n if (\n s.ast.encoding === undefined &&\n SchemaAST.isUnion(s.ast) &&\n Array.isArray((s as { readonly members?: unknown }).members)\n ) {\n return (s as Schema.Union<ReadonlyArray<Schema.Top>>).mapMembers(\n Array.map(extend),\n { unsafePreserveChecks: true },\n );\n }\n if (\n s.ast.encoding === undefined &&\n SchemaAST.isObjects(s.ast) &&\n typeof (s as { readonly mapFields?: unknown }).mapFields === \"function\"\n ) {\n return (s as Schema.Struct<Schema.Struct.Fields>).mapFields(\n Struct.assign(system),\n { unsafePreserveChecks: true },\n );\n }\n return Schema.make(extendAst(s.ast));\n };\n\n return extend(schema) as unknown as ExtendWithSystemFields<\n TableName,\n TableSchema,\n Scope\n >;\n};\n\n/**\n * Applies the system fields to a single struct, mirroring\n * `Schema.fieldsAssign`. Any other (already-extended or opaque) schema falls\n * back to a `Codec` carrying the system-field document shape.\n */\ntype ApplySystemFields<\n TableName extends string,\n Schema_,\n Scope extends IdScope.IdScope,\n> =\n Schema_ extends Schema.Struct<infer Fields extends Schema.Struct.Fields>\n ? Schema.Struct<\n Struct.Simplify<\n Struct.Assign<Fields, SystemFieldsFor<TableName, Scope>>\n >\n >\n : Schema_ extends Schema.Codec<infer Type, infer Encoded>\n ? Schema.Codec<\n WithSystemFields<TableName, Type, Scope>,\n WithSystemFields<TableName, Encoded, Scope>\n >\n : never;\n\n/**\n * Extend a table schema with Convex system fields at the type level.\n *\n * This mirrors the runtime {@link extendWithSystemFields}: a `Struct` gains the\n * system fields directly (matching `Schema.fieldsAssign`), and a `Union` has\n * them distributed across its members (matching\n * `union.mapMembers(Tuple.map(Schema.fieldsAssign(...)))`). The\n * `Struct`/`Union` structure is preserved rather than collapsed to a bare\n * `Codec`; any other schema falls back to a `Codec` carrying the system-field\n * document shape, matching the runtime's AST-level extension.\n */\nexport type ExtendWithSystemFields<\n TableName extends string,\n TableSchema extends Schema.Top,\n Scope extends IdScope.IdScope = IdScope.App,\n> =\n TableSchema extends Schema.Union<\n infer Members extends ReadonlyArray<Schema.Top>\n >\n ? Schema.Union<\n Struct.Simplify<\n Readonly<{\n [MemberIndex in keyof Members]: ExtendWithSystemFields<\n TableName,\n Members[MemberIndex],\n Scope\n >;\n }>\n >\n >\n : ApplySystemFields<TableName, TableSchema, Scope>;\n\n/**\n * The decoded/encoded document shape: a table's fields plus Convex's system\n * fields. Deliberately a bare intersection (no `Expand`/`Simplify`)—flattening\n * it with a homomorphic mapped type collapses to `{ [x: string]: any }` when\n * `Document` is still an unresolved generic, which breaks structural\n * comparability in the database reader/writer plumbing.\n */\nexport type WithSystemFields<\n TableName extends string,\n Document,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Document extends unknown\n ? { _id: GenericId.GenericId<TableName, Scope> } & NonIdSystemFields &\n Document\n : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,gBAIX,WACA,UAEA,OAAO,OAAO;CACZ,KAAKA,UAAoB,WAAW,KAAK;CACzC,eAAe,OAAO;AACxB,CAAC;;;;;AAeH,MAAM,mBAA0C,OAAO,KACrD,aAAa,EAAE,CAAC,CAAC,MACnB;AAEA,MAAM,oBAAoB,QACxB,UAAU,SAAS,GAAG,KAAK,MAAM,SAAS,kBAAkB,GAAG;AAEjE,MAAM,qBAAqB,UAA2C;CACpE,MAAM,OAAO,QAAQ,QAAQ,KAAK;CAClC,MAAM,QAAQ,eACZ,OAAO,YACL,MAAM,IAAI,aAAa,QAAQ,CAAC,KAAK,MAAM,IAAI,CAAU,CAC3D;CACF,OAAO;EACL,QAAQ,KAAK,MAAM,OAAO,MAAM,gBAAgB,CAAC;EACjD,MAAM,KAAK,MAAM,OAAO,MAAM,UAAU,IAAI,gBAAgB,CAAC,CAAC;CAChE;AACF;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,QACnB,MAAM,UAAU,IAAI,oBAAoB,wBAAwB,GAChE,IAAI,iBACJ,IAAI,aACJ,IAAI,QACJ,IAAI,aAAa,KAAA,IAAY,KAAA,IAAY,eAAe,IAAI,QAAQ,GACpE,IAAI,SACJ,IAAI,cACN;EAEF,MAAM,IAAI,MACR,IAAI,SAAS,gBACT,+OACA,qBAAqB,IAAI,KAAK,iHACpC;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,MAAa,0BAKX,WACA,QACA,UAC0D;CAC1D,MAAM,SAAS,aAAa,WAAW,KAAK,CAAC,CAAC;CAE9C,MAAM,YAAY,cAChB,KACE,QACA,OAAO,WACP,MAAM,KACH,CAAC,MAAM,WAAW,IAAI,UAAU,kBAAkB,MAAM,MAAM,GAAG,CACpE,CACF,CACF;CAEA,MAAM,UAAU,MAA8B;EAC5C,IACE,EAAE,IAAI,aAAa,KAAA,KACnB,UAAU,QAAQ,EAAE,GAAG,KACvB,MAAM,QAAS,EAAqC,OAAO,GAE3D,OAAQ,EAA8C,WACpD,MAAM,IAAI,MAAM,GAChB,EAAE,sBAAsB,KAAK,CAC/B;EAEF,IACE,EAAE,IAAI,aAAa,KAAA,KACnB,UAAU,UAAU,EAAE,GAAG,KACzB,OAAQ,EAAuC,cAAc,YAE7D,OAAQ,EAA0C,UAChD,OAAO,OAAO,MAAM,GACpB,EAAE,sBAAsB,KAAK,CAC/B;EAEF,OAAO,OAAO,KAAK,UAAU,EAAE,GAAG,CAAC;CACrC;CAEA,OAAO,OAAO,MAAM;AAKtB"}
|
|
1
|
+
{"version":3,"file":"SystemFields.js","names":["GenericId.GenericId"],"sources":["../src/SystemFields.ts"],"sourcesContent":["import type * as IdScope from \"./IdScope.js\";\nimport type { SystemFields as NonIdSystemFields } from \"convex/server\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as SchemaTransformation from \"effect/SchemaTransformation\";\nimport * as Struct from \"effect/Struct\";\nimport * as GenericId from \"./GenericId.js\";\n\n/**\n * Produces a schema for Convex system fields. In Confect, system fields include\n * `_id`.\n */\nexport const SystemFields = <\n TableName extends string,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n scope?: Scope,\n) =>\n Schema.Struct({\n _id: GenericId.GenericId(tableName, scope),\n _creationTime: Schema.Finite,\n });\n\n/**\n * The field map added to a table schema, derived from {@link SystemFields} so it\n * stays in lockstep with the runtime schema.\n */\ntype SystemFieldsFor<\n TableName extends string,\n Scope extends IdScope.IdScope = IdScope.App,\n> = ReturnType<typeof SystemFields<TableName, Scope>>[\"fields\"];\n\n/**\n * The system field names, derived from {@link SystemFields} so they stay in\n * lockstep with the schema.\n */\nconst systemFieldNames: ReadonlyArray<string> = Record.keys(\n SystemFields(\"\").fields,\n);\n\nconst isSystemFieldKey = (key: string | symbol): key is string =>\n Predicate.isString(key) && Array.contains(systemFieldNames, key);\n\nconst splitSystemFields = (input: { [key: PropertyKey]: unknown }) => {\n const keys = Reflect.ownKeys(input);\n const pick = (pickedKeys: ReadonlyArray<string | symbol>) =>\n Record.fromEntries(\n Array.map(pickedKeys, (key) => [key, input[key]] as const),\n );\n return {\n system: pick(Array.filter(keys, isSystemFieldKey)),\n rest: pick(Array.filter(keys, Predicate.not(isSystemFieldKey))),\n };\n};\n\n/**\n * Wraps a transformation getter so the system fields bypass it: they are split\n * off the input before the user-defined getter runs and merged back into its\n * output. Transformations construct fresh objects, so without this the system\n * fields would be dropped at every transformation step.\n */\nconst wrapGetter = <R>(\n getter: SchemaGetter.Getter<any, any, R>,\n): SchemaGetter.Getter<any, any, R> =>\n SchemaGetter.transformOptionalEffect((input, options) => {\n if (Option.isNone(input) || !Predicate.isObject(input.value)) {\n return SchemaGetter.run(getter, input, options);\n }\n const { system, rest } = splitSystemFields(input.value);\n return SchemaGetter.run(getter, Option.some(rest), options).pipe(\n Effect.map(\n Option.map((output) =>\n Predicate.isObject(output) ? Struct.assign(output, system) : output,\n ),\n ),\n );\n });\n\nconst wrapTransformation = (\n transformation: SchemaAST.Link[\"transformation\"],\n): SchemaTransformation.Transformation<any, any, any, any> => {\n if (!SchemaTransformation.isTransformation(transformation)) {\n throw new Error(\n \"Cannot extend a table schema that uses decoding/encoding middleware with system fields\",\n );\n }\n return new SchemaTransformation.Transformation(\n wrapGetter(transformation.decode),\n wrapGetter(transformation.encode),\n );\n};\n\n/**\n * Builds an AST walker that adds the given system-field property signatures to\n * every object node of a schema's AST—including each step of its encoding\n * chain—wrapping transformations so the fields survive them.\n */\nconst makeExtendAst = (\n systemPropertySignatures: ReadonlyArray<SchemaAST.PropertySignature>,\n) => {\n const extendEncoding = (encoding: SchemaAST.Encoding): SchemaAST.Encoding =>\n Array.map(\n encoding,\n (link) =>\n new SchemaAST.Link(\n extendAst(link.to),\n wrapTransformation(link.transformation),\n ),\n );\n\n const extendAst = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (SchemaAST.isUnion(ast)) {\n return new SchemaAST.Union(\n Array.map(ast.types, extendAst),\n ast.options,\n ast.annotations,\n ast.checks,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n ast.encodingChecks,\n );\n }\n if (SchemaAST.isSuspend(ast)) {\n return new SchemaAST.Suspend(\n () => extendAst(ast.thunk()),\n ast.annotations,\n undefined,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n );\n }\n if (SchemaAST.isObjects(ast)) {\n return new SchemaAST.Objects(\n Array.appendAll(ast.propertySignatures, systemPropertySignatures),\n ast.indexSignatures,\n ast.annotations,\n ast.checks,\n ast.encoding === undefined ? undefined : extendEncoding(ast.encoding),\n ast.context,\n ast.encodingChecks,\n );\n }\n throw new Error(\n ast._tag === \"Declaration\"\n ? \"Cannot extend a `Declaration` schema (such as a `Schema.Class`) with system fields: its decoded values are constructed instances, which cannot gain extra fields. Use a plain `Schema.Struct`, or transform to one with `Schema.decodeTo`.\"\n : `Cannot extend a \\`${ast._tag}\\` schema node with system fields: a table schema must resolve to an object shape at every step of its encoding.`,\n );\n };\n\n return extendAst;\n};\n\n/**\n * Extend a table schema with Convex system fields.\n *\n * A plain `Struct` gains the fields via `mapFields` and a `Union` has them\n * distributed across its members via `mapMembers`, preserving the schema's\n * checks and `Struct`/`Union` structure. Any other object-shaped schema—one\n * built with `Schema.decodeTo`/`Schema.encodeKeys`, a branded struct, a\n * suspended schema—is extended at the AST level: every object node in its\n * encoding chain gains the system fields, and each transformation is wrapped so\n * the fields bypass the user-defined getters. Schemas that do not resolve to an\n * object shape at every step (such as `Schema.Class`, whose decoded values are\n * class instances) are rejected with a descriptive error.\n *\n * Note that struct-level checks on an extended schema observe the value with\n * the system fields attached, and encoding an extended schema emits the system\n * fields alongside the table fields.\n */\nexport const extendWithSystemFields = <\n TableName extends string,\n TableSchema extends Schema.Codec<any, any>,\n const Scope extends IdScope.IdScope = IdScope.App,\n>(\n tableName: TableName,\n schema: TableSchema,\n scope?: Scope,\n): ExtendWithSystemFields<TableName, TableSchema, Scope> => {\n const system = SystemFields(tableName, scope).fields;\n\n const extendAst = makeExtendAst(\n pipe(\n system,\n Record.toEntries,\n Array.map(\n ([name, field]) => new SchemaAST.PropertySignature(name, field.ast),\n ),\n ),\n );\n\n const extend = (s: Schema.Top): Schema.Top => {\n if (\n s.ast.encoding === undefined &&\n SchemaAST.isUnion(s.ast) &&\n Array.isArray((s as { readonly members?: unknown }).members)\n ) {\n return (s as Schema.Union<ReadonlyArray<Schema.Top>>).mapMembers(\n Array.map(extend),\n { unsafePreserveChecks: true },\n );\n }\n if (\n s.ast.encoding === undefined &&\n SchemaAST.isObjects(s.ast) &&\n typeof (s as { readonly mapFields?: unknown }).mapFields === \"function\"\n ) {\n return (s as Schema.Struct<Schema.Struct.Fields>).mapFields(\n Struct.assign(system),\n { unsafePreserveChecks: true },\n );\n }\n return Schema.make(extendAst(s.ast));\n };\n\n return extend(schema) as unknown as ExtendWithSystemFields<\n TableName,\n TableSchema,\n Scope\n >;\n};\n\n/**\n * Applies the system fields to a single struct, mirroring\n * `Schema.fieldsAssign`. Any other (already-extended or opaque) schema falls\n * back to a `Codec` carrying the system-field document shape.\n */\ntype ApplySystemFields<\n TableName extends string,\n Schema_,\n Scope extends IdScope.IdScope,\n> =\n Schema_ extends Schema.Struct<infer Fields extends Schema.Struct.Fields>\n ? Schema.Struct<\n Struct.Simplify<\n Struct.Assign<Fields, SystemFieldsFor<TableName, Scope>>\n >\n >\n : Schema_ extends Schema.Codec<infer Type, infer Encoded>\n ? Schema.Codec<\n WithSystemFields<TableName, Type, Scope>,\n WithSystemFields<TableName, Encoded, Scope>\n >\n : never;\n\n/**\n * Extend a table schema with Convex system fields at the type level.\n *\n * This mirrors the runtime {@link extendWithSystemFields}: a `Struct` gains the\n * system fields directly (matching `Schema.fieldsAssign`), and a `Union` has\n * them distributed across its members (matching\n * `union.mapMembers(Tuple.map(Schema.fieldsAssign(...)))`). The\n * `Struct`/`Union` structure is preserved rather than collapsed to a bare\n * `Codec`; any other schema falls back to a `Codec` carrying the system-field\n * document shape, matching the runtime's AST-level extension.\n */\nexport type ExtendWithSystemFields<\n TableName extends string,\n TableSchema extends Schema.Top,\n Scope extends IdScope.IdScope = IdScope.App,\n> =\n TableSchema extends Schema.Union<\n infer Members extends ReadonlyArray<Schema.Top>\n >\n ? Schema.Union<\n Struct.Simplify<\n Readonly<{\n [MemberIndex in keyof Members]: ExtendWithSystemFields<\n TableName,\n Members[MemberIndex],\n Scope\n >;\n }>\n >\n >\n : ApplySystemFields<TableName, TableSchema, Scope>;\n\n/**\n * The decoded/encoded document shape: a table's fields plus Convex's system\n * fields. Deliberately a bare intersection (no `Expand`/`Simplify`)—flattening\n * it with a homomorphic mapped type collapses to `{ [x: string]: any }` when\n * `Document` is still an unresolved generic, which breaks structural\n * comparability in the database reader/writer plumbing.\n */\nexport type WithSystemFields<\n TableName extends string,\n Document,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Document extends unknown\n ? { _id: GenericId.GenericId<TableName, Scope> } & NonIdSystemFields &\n Document\n : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,gBAIX,WACA,UAEA,OAAO,OAAO;CACZ,KAAKA,UAAoB,WAAW,KAAK;CACzC,eAAe,OAAO;AACxB,CAAC;;;;;AAeH,MAAM,mBAA0C,OAAO,KACrD,aAAa,EAAE,CAAC,CAAC,MACnB;AAEA,MAAM,oBAAoB,QACxB,UAAU,SAAS,GAAG,KAAK,MAAM,SAAS,kBAAkB,GAAG;AAEjE,MAAM,qBAAqB,UAA2C;CACpE,MAAM,OAAO,QAAQ,QAAQ,KAAK;CAClC,MAAM,QAAQ,eACZ,OAAO,YACL,MAAM,IAAI,aAAa,QAAQ,CAAC,KAAK,MAAM,IAAI,CAAU,CAC3D;CACF,OAAO;EACL,QAAQ,KAAK,MAAM,OAAO,MAAM,gBAAgB,CAAC;EACjD,MAAM,KAAK,MAAM,OAAO,MAAM,UAAU,IAAI,gBAAgB,CAAC,CAAC;CAChE;AACF;;;;;;;AAQA,MAAM,cACJ,WAEA,aAAa,yBAAyB,OAAO,YAAY;CACvD,IAAI,OAAO,OAAO,KAAK,KAAK,CAAC,UAAU,SAAS,MAAM,KAAK,GACzD,OAAO,aAAa,IAAI,QAAQ,OAAO,OAAO;CAEhD,MAAM,EAAE,QAAQ,SAAS,kBAAkB,MAAM,KAAK;CACtD,OAAO,aAAa,IAAI,QAAQ,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,KAC1D,OAAO,IACL,OAAO,KAAK,WACV,UAAU,SAAS,MAAM,IAAI,OAAO,OAAO,QAAQ,MAAM,IAAI,MAC/D,CACF,CACF;AACF,CAAC;AAEH,MAAM,sBACJ,mBAC4D;CAC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AAW,IAAI,UAAU,kBAAkB,MAAM,MAAM,GAAG,CACpE,CACF,CACF;CAEA,MAAM,UAAU,MAA8B;EAC5C,IACE,EAAE,IAAI,aAAa,KAAA,KACnB,UAAU,QAAQ,EAAE,GAAG,KACvB,MAAM,QAAS,EAAqC,OAAO,GAE3D,OAAQ,EAA8C,WACpD,MAAM,IAAI,MAAM,GAChB,EAAE,sBAAsB,KAAK,CAC/B;EAEF,IACE,EAAE,IAAI,aAAa,KAAA,KACnB,UAAU,UAAU,EAAE,GAAG,KACzB,OAAQ,EAAuC,cAAc,YAE7D,OAAQ,EAA0C,UAChD,OAAO,OAAO,MAAM,GACpB,EAAE,sBAAsB,KAAK,CAC/B;EAEF,OAAO,OAAO,KAAK,UAAU,EAAE,GAAG,CAAC;CACrC;CAEA,OAAO,OAAO,MAAM;AAKtB"}
|
package/dist/Table.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as IdScope from "./IdScope";
|
|
2
|
-
import * as SystemFields from "./SystemFields";
|
|
3
|
-
import type { TableSchemaToTableValidator } from "./SchemaToValidator";
|
|
1
|
+
import * as IdScope from "./IdScope.js";
|
|
2
|
+
import * as SystemFields from "./SystemFields.js";
|
|
3
|
+
import type { TableSchemaToTableValidator } from "./SchemaToValidator.js";
|
|
4
4
|
import type { SystemFields as ConvexSystemFields, Expand, GenericTableIndexes, GenericTableSearchIndexes, GenericTableVectorIndexes, IndexTiebreakerField, SearchIndexConfig, VectorIndexConfig } from "convex/server";
|
|
5
5
|
import type { GenericValidator, Validator } from "convex/values";
|
|
6
6
|
import type * as Schema from "effect/Schema";
|
package/dist/Table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../src/Table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../src/Table.ts"],"names":[],"mappings":"AA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M,MAAM,QAAQ,CAClB,QAAQ,SAAS,YAAY,EAC7B,KAAK,SAAS,MAAM,IAClB,QAAQ,SAAS;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEtE,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,YAAY,IAAI;IACtD,QAAQ,EAAE,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CACpE,CAAC;AAoLF,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,YAAY,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,cACxD,MAAM,YAAY,KAC7B,YAAY,CAAC,YAAY,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAUtE,CAAC;AAIF;;;;;;GAMG;AACH,KAAK,iBAAiB,CAAC,eAAe,SAAS,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAIrE,eAAe,CAAC,YAAY,CAAC,GAAG,MAAM,kBAAkB,CAAC"}
|
package/dist/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","names":["SystemFields.extendWithSystemFields","IdScope.app"],"sources":["../src/Table.ts"],"sourcesContent":["import * as IdScope from \"./IdScope\";\nimport * as Lazy from \"./Lazy\";\nimport * as SystemFields from \"./SystemFields\";\nimport type { TableSchemaToTableValidator } from \"./SchemaToValidator\";\nimport type {\n SystemFields as ConvexSystemFields,\n Expand,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IndexTiebreakerField,\n SearchIndexConfig,\n VectorIndexConfig,\n} from \"convex/server\";\nimport type { GenericValidator, Validator } from \"convex/values\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\n\nexport const TypeId = \"~@confect/core/Table\";\nexport type TypeId = typeof TypeId;\n\n// -----------------------------------------------------------------------------\n// Predicates\n// -----------------------------------------------------------------------------\n//\n// Both bound `Table`s and `UnnamedTable` callables share the same `[TypeId]`\n// brand. They disambiguate by whether a `tableName` property is set: bound\n// tables have one, unnamed callables do not.\n//\n// The discriminator is `tableName` (not `name`) so it does not collide with\n// the built-in `Function.prototype.name` that every JS function carries.\n\nexport const isTable = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, \"tableName\");\n\nexport const isUnnamedTable = (u: unknown): u is UnnamedAny =>\n Predicate.hasProperty(u, TypeId) && !Predicate.hasProperty(u, \"tableName\");\n\n// -----------------------------------------------------------------------------\n// Bound Table\n// -----------------------------------------------------------------------------\n//\n// A bound `Table` is the client-safe document schema: `Fields`, `Doc`, and\n// the index metadata records. The Convex deploy `tableDefinition` (which\n// value-imports `convex/server`) is produced separately by\n// `@confect/server/Table.tableDefinition`.\n\nexport interface Table<\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n Scope_ extends IdScope.IdScope = IdScope.App,\n> {\n readonly [TypeId]: TypeId;\n readonly tableName: Name_;\n readonly scope: Scope_;\n readonly Fields: TableSchema_;\n readonly Doc: SystemFields.ExtendWithSystemFields<\n Name_,\n TableSchema_,\n Scope_\n >;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly tableName: string;\n}\n\nexport type AnyWithProps = Table<\n any,\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdScope.IdScope\n>;\n\n// -----------------------------------------------------------------------------\n// UnnamedTable (callable)\n// -----------------------------------------------------------------------------\n//\n// `Table.make(lazyFields)` returns an `UnnamedTable`: a callable that\n// produces a fully bound `Table` when invoked with a name. Chaining methods\n// (`.index`, `.searchIndex`, `.vectorIndex`) live here and return new\n// `UnnamedTable`s, accumulating plain index metadata records. The\n// user-supplied `lazyFields` callback is just carried through until first\n// access of `Fields`/`Doc` on a bound table. The codegen pipeline emits a\n// wrapper file per user-authored table that simply invokes the unnamed\n// callable with the filename basename.\n\nexport interface UnnamedTable<\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n> {\n <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n readonly [TypeId]: TypeId;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<TableValidator_>,\n RestFieldPaths extends ExtractFieldPaths<TableValidator_>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Expand<\n Indexes_ &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<SearchIndexConfig<SearchField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n Expand<\n SearchIndexes_ &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes_\n >;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<VectorIndexConfig<VectorField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n Expand<\n VectorIndexes_ &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n}\n\nexport interface UnnamedAny {\n readonly [TypeId]: TypeId;\n}\n\nexport type UnnamedAnyWithProps = UnnamedTable<\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes\n>;\n\n// -----------------------------------------------------------------------------\n// Type extractors\n// -----------------------------------------------------------------------------\n\nexport type Name<TableDef extends AnyWithProps> = TableDef[\"tableName\"] &\n string;\n\nexport type TableSchema<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\n\nexport type TableValidator<TableDef extends AnyWithProps> =\n TableDef[\"~TableValidator\"];\n\nexport type Indexes<TableDef extends AnyWithProps> = TableDef[\"indexes\"];\n\nexport type SearchIndexes<TableDef extends AnyWithProps> =\n TableDef[\"searchIndexes\"];\n\nexport type VectorIndexes<TableDef extends AnyWithProps> =\n TableDef[\"vectorIndexes\"];\n\nexport type Doc<TableDef extends AnyWithProps> = TableDef[\"Doc\"];\n\nexport type Fields<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\nexport type Scope<TableDef extends AnyWithProps> = TableDef[\"scope\"];\n\nexport type WithName<\n TableDef extends AnyWithProps,\n Name_ extends string,\n> = TableDef extends { readonly tableName: Name_ } ? TableDef : never;\n\nexport type TablesRecord<Tables extends AnyWithProps> = {\n readonly [TableName_ in Name<Tables>]: WithName<Tables, TableName_>;\n};\n\n// -----------------------------------------------------------------------------\n// Construction\n// -----------------------------------------------------------------------------\n//\n// `make` only stores the user-supplied `lazyFields` callback alongside any\n// chained index metadata. Neither `Fields` nor `Doc` is constructed until\n// first access on a bound `Table`. Each chain step is O(1) (plain object\n// spread of the metadata records) and never invokes the callback. Binding\n// via `unnamed(tableName)` installs lazy memoised getters for `Fields` and\n// `Doc` via `Lazy.defineProperty`, so the first access materialises the\n// value and replaces the getter with a plain data property—second-and-\n// subsequent accesses are observably indistinguishable from a plain\n// property and avoid all function-call overhead.\n\ninterface UnnamedState<\n TableSchema_ extends Schema.Codec<any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n> {\n readonly lazyFields: () => TableSchema_;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n}\n\nconst makeBound = <\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n Scope_ extends IdScope.IdScope,\n>(\n tableName: Name_,\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n scope: Scope_,\n): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n> => {\n const bound = {\n [TypeId]: TypeId as TypeId,\n tableName,\n scope,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n } as Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n Lazy.defineProperty(bound, \"Fields\", () => state.lazyFields());\n\n Lazy.defineProperty(bound, \"Doc\", () =>\n SystemFields.extendWithSystemFields(\n tableName,\n (bound as { Fields: TableSchema_ }).Fields,\n scope,\n ),\n );\n\n return bound;\n};\n\nconst makeUnnamed = <\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n>(\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n> => {\n type UnnamedTable_ = UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n type UnnamedTableFunction<FunctionName extends keyof UnnamedTable_> =\n UnnamedTable_[FunctionName];\n\n const bind = <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n > =>\n makeBound<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >(tableName, state, (scope ?? IdScope.app) as Scope_);\n\n const index: UnnamedTableFunction<\"index\"> = (name, fields) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: {\n ...state.indexes,\n [name]: fields,\n } as any,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n });\n\n const searchIndex: UnnamedTableFunction<\"searchIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: {\n ...state.searchIndexes,\n [name]: indexConfig,\n } as any,\n vectorIndexes: state.vectorIndexes,\n });\n\n const vectorIndex: UnnamedTableFunction<\"vectorIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: {\n ...state.vectorIndexes,\n [name]: indexConfig,\n } as any,\n });\n\n return Object.assign(bind, {\n [TypeId]: TypeId as TypeId,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n index,\n searchIndex,\n vectorIndex,\n }) as UnnamedTable_;\n};\n\nexport const make = <const TableSchema_ extends Schema.Codec<any, any>>(\n lazyFields: () => TableSchema_,\n): UnnamedTable<TableSchema_, TableSchemaToTableValidator<TableSchema_>> => {\n type TableValidator_ = TableSchemaToTableValidator<TableSchema_>;\n type UnnamedTable_ = UnnamedTable<TableSchema_, TableValidator_>;\n\n return makeUnnamed<TableSchema_, TableValidator_, {}, {}, {}>({\n lazyFields,\n indexes: {},\n searchIndexes: {},\n vectorIndexes: {},\n }) as UnnamedTable_;\n};\n\n// Vendored types from convex-js, partially modified. Ideally we could use these directly. See https://github.com/get-convex/convex-js/pull/14\n\n/**\n * Extract all of the index field paths within a Convex `Validator`.\n *\n * This is used when declaring table indexes.\n *\n * @public\n */\ntype ExtractFieldPaths<TableValidator_ extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n TableValidator_[\"fieldPaths\"] | keyof ConvexSystemFields;\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,SAAS;AActB,MAAa,WAAW,MACtB,UAAU,YAAY,GAAA,sBAAS,KAAK,UAAU,YAAY,GAAG,WAAW;AAE1E,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAA,sBAAS,KAAK,CAAC,UAAU,YAAY,GAAG,WAAW;AA6O3E,MAAM,aASJ,WACA,OACA,UASG;CACH,MAAM,QAAQ;GACX,SAAS;EACV;EACA;EACA,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB;CAUA,eAAoB,OAAO,gBAAgB,MAAM,WAAW,CAAC;CAE7D,eAAoB,OAAO,aACzBA,uBACE,WACC,MAAmC,QACpC,KACF,CACF;CAEA,OAAO;AACT;AAEA,MAAM,eAOJ,UAOG;CAYH,MAAM,QAIJ,WACA,UAUA,UAQE,WAAW,OAAQ,SAASC,GAAsB;CAEtD,MAAM,SAAwC,MAAM,WAClD,YAAY;EACV,YAAY,MAAM;EAClB,SAAS;GACP,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;CACF,CAAC;CAEH,OAAO,OAAO,OAAO,MAAM;GACxB,SAAS;EACV,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAa,QACX,eAC0E;CAI1E,OAAO,YAAuD;EAC5D;EACA,SAAS,CAAC;EACV,eAAe,CAAC;EAChB,eAAe,CAAC;CAClB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Table.js","names":["SystemFields.extendWithSystemFields","IdScope.app"],"sources":["../src/Table.ts"],"sourcesContent":["import * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as SystemFields from \"./SystemFields.js\";\nimport type { TableSchemaToTableValidator } from \"./SchemaToValidator.js\";\nimport type {\n SystemFields as ConvexSystemFields,\n Expand,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IndexTiebreakerField,\n SearchIndexConfig,\n VectorIndexConfig,\n} from \"convex/server\";\nimport type { GenericValidator, Validator } from \"convex/values\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\n\nexport const TypeId = \"~@confect/core/Table\";\nexport type TypeId = typeof TypeId;\n\n// -----------------------------------------------------------------------------\n// Predicates\n// -----------------------------------------------------------------------------\n//\n// Both bound `Table`s and `UnnamedTable` callables share the same `[TypeId]`\n// brand. They disambiguate by whether a `tableName` property is set: bound\n// tables have one, unnamed callables do not.\n//\n// The discriminator is `tableName` (not `name`) so it does not collide with\n// the built-in `Function.prototype.name` that every JS function carries.\n\nexport const isTable = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, \"tableName\");\n\nexport const isUnnamedTable = (u: unknown): u is UnnamedAny =>\n Predicate.hasProperty(u, TypeId) && !Predicate.hasProperty(u, \"tableName\");\n\n// -----------------------------------------------------------------------------\n// Bound Table\n// -----------------------------------------------------------------------------\n//\n// A bound `Table` is the client-safe document schema: `Fields`, `Doc`, and\n// the index metadata records. The Convex deploy `tableDefinition` (which\n// value-imports `convex/server`) is produced separately by\n// `@confect/server/Table.tableDefinition`.\n\nexport interface Table<\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n Scope_ extends IdScope.IdScope = IdScope.App,\n> {\n readonly [TypeId]: TypeId;\n readonly tableName: Name_;\n readonly scope: Scope_;\n readonly Fields: TableSchema_;\n readonly Doc: SystemFields.ExtendWithSystemFields<\n Name_,\n TableSchema_,\n Scope_\n >;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly tableName: string;\n}\n\nexport type AnyWithProps = Table<\n any,\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdScope.IdScope\n>;\n\n// -----------------------------------------------------------------------------\n// UnnamedTable (callable)\n// -----------------------------------------------------------------------------\n//\n// `Table.make(lazyFields)` returns an `UnnamedTable`: a callable that\n// produces a fully bound `Table` when invoked with a name. Chaining methods\n// (`.index`, `.searchIndex`, `.vectorIndex`) live here and return new\n// `UnnamedTable`s, accumulating plain index metadata records. The\n// user-supplied `lazyFields` callback is just carried through until first\n// access of `Fields`/`Doc` on a bound table. The codegen pipeline emits a\n// wrapper file per user-authored table that simply invokes the unnamed\n// callable with the filename basename.\n\nexport interface UnnamedTable<\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n> {\n <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n readonly [TypeId]: TypeId;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<TableValidator_>,\n RestFieldPaths extends ExtractFieldPaths<TableValidator_>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Expand<\n Indexes_ &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<SearchIndexConfig<SearchField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n Expand<\n SearchIndexes_ &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes_\n >;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<VectorIndexConfig<VectorField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n Expand<\n VectorIndexes_ &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n}\n\nexport interface UnnamedAny {\n readonly [TypeId]: TypeId;\n}\n\nexport type UnnamedAnyWithProps = UnnamedTable<\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes\n>;\n\n// -----------------------------------------------------------------------------\n// Type extractors\n// -----------------------------------------------------------------------------\n\nexport type Name<TableDef extends AnyWithProps> = TableDef[\"tableName\"] &\n string;\n\nexport type TableSchema<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\n\nexport type TableValidator<TableDef extends AnyWithProps> =\n TableDef[\"~TableValidator\"];\n\nexport type Indexes<TableDef extends AnyWithProps> = TableDef[\"indexes\"];\n\nexport type SearchIndexes<TableDef extends AnyWithProps> =\n TableDef[\"searchIndexes\"];\n\nexport type VectorIndexes<TableDef extends AnyWithProps> =\n TableDef[\"vectorIndexes\"];\n\nexport type Doc<TableDef extends AnyWithProps> = TableDef[\"Doc\"];\n\nexport type Fields<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\nexport type Scope<TableDef extends AnyWithProps> = TableDef[\"scope\"];\n\nexport type WithName<\n TableDef extends AnyWithProps,\n Name_ extends string,\n> = TableDef extends { readonly tableName: Name_ } ? TableDef : never;\n\nexport type TablesRecord<Tables extends AnyWithProps> = {\n readonly [TableName_ in Name<Tables>]: WithName<Tables, TableName_>;\n};\n\n// -----------------------------------------------------------------------------\n// Construction\n// -----------------------------------------------------------------------------\n//\n// `make` only stores the user-supplied `lazyFields` callback alongside any\n// chained index metadata. Neither `Fields` nor `Doc` is constructed until\n// first access on a bound `Table`. Each chain step is O(1) (plain object\n// spread of the metadata records) and never invokes the callback. Binding\n// via `unnamed(tableName)` installs lazy memoised getters for `Fields` and\n// `Doc` via `Lazy.defineProperty`, so the first access materialises the\n// value and replaces the getter with a plain data property—second-and-\n// subsequent accesses are observably indistinguishable from a plain\n// property and avoid all function-call overhead.\n\ninterface UnnamedState<\n TableSchema_ extends Schema.Codec<any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n> {\n readonly lazyFields: () => TableSchema_;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n}\n\nconst makeBound = <\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n Scope_ extends IdScope.IdScope,\n>(\n tableName: Name_,\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n scope: Scope_,\n): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n> => {\n const bound = {\n [TypeId]: TypeId as TypeId,\n tableName,\n scope,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n } as Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n Lazy.defineProperty(bound, \"Fields\", () => state.lazyFields());\n\n Lazy.defineProperty(bound, \"Doc\", () =>\n SystemFields.extendWithSystemFields(\n tableName,\n (bound as { Fields: TableSchema_ }).Fields,\n scope,\n ),\n );\n\n return bound;\n};\n\nconst makeUnnamed = <\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n>(\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n> => {\n type UnnamedTable_ = UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n type UnnamedTableFunction<FunctionName extends keyof UnnamedTable_> =\n UnnamedTable_[FunctionName];\n\n const bind = <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n > =>\n makeBound<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >(tableName, state, (scope ?? IdScope.app) as Scope_);\n\n const index: UnnamedTableFunction<\"index\"> = (name, fields) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: {\n ...state.indexes,\n [name]: fields,\n } as any,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n });\n\n const searchIndex: UnnamedTableFunction<\"searchIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: {\n ...state.searchIndexes,\n [name]: indexConfig,\n } as any,\n vectorIndexes: state.vectorIndexes,\n });\n\n const vectorIndex: UnnamedTableFunction<\"vectorIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: {\n ...state.vectorIndexes,\n [name]: indexConfig,\n } as any,\n });\n\n return Object.assign(bind, {\n [TypeId]: TypeId as TypeId,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n index,\n searchIndex,\n vectorIndex,\n }) as UnnamedTable_;\n};\n\nexport const make = <const TableSchema_ extends Schema.Codec<any, any>>(\n lazyFields: () => TableSchema_,\n): UnnamedTable<TableSchema_, TableSchemaToTableValidator<TableSchema_>> => {\n type TableValidator_ = TableSchemaToTableValidator<TableSchema_>;\n type UnnamedTable_ = UnnamedTable<TableSchema_, TableValidator_>;\n\n return makeUnnamed<TableSchema_, TableValidator_, {}, {}, {}>({\n lazyFields,\n indexes: {},\n searchIndexes: {},\n vectorIndexes: {},\n }) as UnnamedTable_;\n};\n\n// Vendored types from convex-js, partially modified. Ideally we could use these directly. See https://github.com/get-convex/convex-js/pull/14\n\n/**\n * Extract all of the index field paths within a Convex `Validator`.\n *\n * This is used when declaring table indexes.\n *\n * @public\n */\ntype ExtractFieldPaths<TableValidator_ extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n TableValidator_[\"fieldPaths\"] | keyof ConvexSystemFields;\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,SAAS;AActB,MAAa,WAAW,MACtB,UAAU,YAAY,GAAA,sBAAS,KAAK,UAAU,YAAY,GAAG,WAAW;AAE1E,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAA,sBAAS,KAAK,CAAC,UAAU,YAAY,GAAG,WAAW;AA6O3E,MAAM,aASJ,WACA,OACA,UASG;CACH,MAAM,QAAQ;GACX,SAAS;EACV;EACA;EACA,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB;CAUA,eAAoB,OAAO,gBAAgB,MAAM,WAAW,CAAC;CAE7D,eAAoB,OAAO,aACzBA,uBACE,WACC,MAAmC,QACpC,KACF,CACF;CAEA,OAAO;AACT;AAEA,MAAM,eAOJ,UAOG;CAYH,MAAM,QAIJ,WACA,UAUA,UAQE,WAAW,OAAQ,SAASC,GAAsB;CAEtD,MAAM,SAAwC,MAAM,WAClD,YAAY;EACV,YAAY,MAAM;EAClB,SAAS;GACP,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;CACF,CAAC;CAEH,OAAO,OAAO,OAAO,MAAM;GACxB,SAAS;EACV,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAa,QACX,eAC0E;CAI1E,OAAO,YAAuD;EAC5D;EACA,SAAS,CAAC;EACV,eAAe,CAAC;EAChB,eAAe,CAAC;CAClB,CAAC;AACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export * as Callback from "./Callback";
|
|
2
|
-
export * as FunctionProvenance from "./FunctionProvenance";
|
|
3
|
-
export * as FunctionSpec from "./FunctionSpec";
|
|
4
|
-
export * as GenericId from "./GenericId";
|
|
5
|
-
export * as App from "./App";
|
|
6
|
-
export * as Auth from "./Auth";
|
|
7
|
-
export * as Component from "./Component";
|
|
8
|
-
export * as Env from "./Env";
|
|
9
|
-
export * as Http from "./Http";
|
|
10
|
-
export * as IdScope from "./IdScope";
|
|
11
|
-
export * as GroupPath from "./GroupPath";
|
|
12
|
-
export * as GroupSpec from "./GroupSpec";
|
|
13
|
-
export * as Identifier from "./Identifier";
|
|
14
|
-
export * as Lazy from "./Lazy";
|
|
15
|
-
export * as Manifest from "./Manifest";
|
|
16
|
-
export * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
17
|
-
export * as MiddlewareSpec from "./MiddlewareSpec";
|
|
18
|
-
export * as PaginationError from "./PaginationError";
|
|
19
|
-
export * as PaginationOptions from "./PaginationOptions";
|
|
20
|
-
export * as PaginationResult from "./PaginationResult";
|
|
21
|
-
export * as Ref from "./Ref";
|
|
22
|
-
export * as Refs from "./Refs";
|
|
23
|
-
export * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
24
|
-
export * as SchemaToValidator from "./SchemaToValidator";
|
|
25
|
-
export * as Spec from "./Spec";
|
|
26
|
-
export * as SystemFields from "./SystemFields";
|
|
27
|
-
export * as Table from "./Table";
|
|
28
|
-
export * as Types from "./Types";
|
|
29
|
-
export * as UserIdentity from "./UserIdentity";
|
|
1
|
+
export * as Callback from "./Callback.js";
|
|
2
|
+
export * as FunctionProvenance from "./FunctionProvenance.js";
|
|
3
|
+
export * as FunctionSpec from "./FunctionSpec.js";
|
|
4
|
+
export * as GenericId from "./GenericId.js";
|
|
5
|
+
export * as App from "./App.js";
|
|
6
|
+
export * as Auth from "./Auth.js";
|
|
7
|
+
export * as Component from "./Component.js";
|
|
8
|
+
export * as Env from "./Env.js";
|
|
9
|
+
export * as Http from "./Http.js";
|
|
10
|
+
export * as IdScope from "./IdScope.js";
|
|
11
|
+
export * as GroupPath from "./GroupPath.js";
|
|
12
|
+
export * as GroupSpec from "./GroupSpec.js";
|
|
13
|
+
export * as Identifier from "./Identifier.js";
|
|
14
|
+
export * as Lazy from "./Lazy.js";
|
|
15
|
+
export * as Manifest from "./Manifest.js";
|
|
16
|
+
export * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
17
|
+
export * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
18
|
+
export * as PaginationError from "./PaginationError.js";
|
|
19
|
+
export * as PaginationOptions from "./PaginationOptions.js";
|
|
20
|
+
export * as PaginationResult from "./PaginationResult.js";
|
|
21
|
+
export * as Ref from "./Ref.js";
|
|
22
|
+
export * as Refs from "./Refs.js";
|
|
23
|
+
export * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
24
|
+
export * as SchemaToValidator from "./SchemaToValidator.js";
|
|
25
|
+
export * as Spec from "./Spec.js";
|
|
26
|
+
export * as SystemFields from "./SystemFields.js";
|
|
27
|
+
export * as Table from "./Table.js";
|
|
28
|
+
export * as Types from "./Types.js";
|
|
29
|
+
export * as UserIdentity from "./UserIdentity.js";
|
|
30
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,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/package.json
CHANGED
package/src/App.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ComponentDefinition, EnvDefinition } from "convex/server";
|
|
|
2
2
|
import type { Infer, Validator } from "convex/values";
|
|
3
3
|
import type * as HttpApi from "effect/http-api/HttpApi";
|
|
4
4
|
import * as Predicate from "effect/Predicate";
|
|
5
|
-
import type * as Env from "./Env";
|
|
5
|
+
import type * as Env from "./Env.js";
|
|
6
6
|
|
|
7
7
|
const TypeId = "~@confect/core/App";
|
|
8
8
|
const MountTypeId = "~@confect/core/App/Mount";
|
package/src/Auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
|
-
import type * as App from "./App";
|
|
4
|
-
import type { TypeError } from "./Types";
|
|
3
|
+
import type * as App from "./App.js";
|
|
4
|
+
import type { TypeError } from "./Types.js";
|
|
5
5
|
|
|
6
6
|
const TypeId = "~@confect/core/Auth";
|
|
7
7
|
const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
package/src/Callback.ts
CHANGED
|
@@ -6,9 +6,9 @@ import type {
|
|
|
6
6
|
import * as Predicate from "effect/Predicate";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
9
|
-
import * as FunctionProvenance from "./FunctionProvenance";
|
|
10
|
-
import * as Ref from "./Ref";
|
|
11
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
9
|
+
import * as FunctionProvenance from "./FunctionProvenance.js";
|
|
10
|
+
import * as Ref from "./Ref.js";
|
|
11
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
12
12
|
|
|
13
13
|
export const TypeId = "~@confect/core/Callback";
|
|
14
14
|
export type TypeId = typeof TypeId;
|
package/src/Component.ts
CHANGED
|
@@ -7,17 +7,17 @@ import { memoize, pipe } from "effect/Function";
|
|
|
7
7
|
import * as Match from "effect/Match";
|
|
8
8
|
import * as Record from "effect/Record";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
11
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
12
|
-
import * as GenericId from "./GenericId";
|
|
13
|
-
import type * as GroupSpec from "./GroupSpec";
|
|
14
|
-
import * as IdScope from "./IdScope";
|
|
15
|
-
import * as Lazy from "./Lazy";
|
|
16
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
17
|
-
import * as Ref from "./Ref";
|
|
18
|
-
import type * as Refs from "./Refs";
|
|
19
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
20
|
-
import * as Spec from "./Spec";
|
|
10
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
11
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
12
|
+
import * as GenericId from "./GenericId.js";
|
|
13
|
+
import type * as GroupSpec from "./GroupSpec.js";
|
|
14
|
+
import * as IdScope from "./IdScope.js";
|
|
15
|
+
import * as Lazy from "./Lazy.js";
|
|
16
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
17
|
+
import * as Ref from "./Ref.js";
|
|
18
|
+
import type * as Refs from "./Refs.js";
|
|
19
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
20
|
+
import * as Spec from "./Spec.js";
|
|
21
21
|
|
|
22
22
|
export class EmptyComponentScopeError extends Data.TaggedError(
|
|
23
23
|
"EmptyComponentScopeError",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DefaultFunctionArgs } from "convex/server";
|
|
2
2
|
import * as Data from "effect/Data";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import * as Lazy from "./Lazy";
|
|
5
|
-
import * as PaginationOptions from "./PaginationOptions";
|
|
6
|
-
import * as PaginationResult from "./PaginationResult";
|
|
4
|
+
import * as Lazy from "./Lazy.js";
|
|
5
|
+
import * as PaginationOptions from "./PaginationOptions.js";
|
|
6
|
+
import * as PaginationResult from "./PaginationResult.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A field map accepted as Confect function args. Restricting each field to a
|
package/src/FunctionSpec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import type * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import type {
|
|
3
3
|
DefaultFunctionArgs,
|
|
4
4
|
FunctionType,
|
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
} from "convex/server";
|
|
10
10
|
import type * as Schema from "effect/Schema";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
12
|
-
import * as FunctionProvenance from "./FunctionProvenance";
|
|
13
|
-
import { validateConfectFunctionIdentifier } from "./Identifier";
|
|
14
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
15
|
-
import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
12
|
+
import * as FunctionProvenance from "./FunctionProvenance.js";
|
|
13
|
+
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
14
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
15
|
+
import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
16
16
|
|
|
17
17
|
export const TypeId = "~@confect/core/FunctionSpec";
|
|
18
18
|
export type TypeId = typeof TypeId;
|
package/src/GenericId.ts
CHANGED
|
@@ -5,8 +5,8 @@ import * as Match from "effect/Match";
|
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as SchemaAST from "effect/SchemaAST";
|
|
8
|
-
import * as IdScope from "./IdScope";
|
|
9
|
-
import type * as Ref from "./Ref";
|
|
8
|
+
import * as IdScope from "./IdScope.js";
|
|
9
|
+
import type * as Ref from "./Ref.js";
|
|
10
10
|
|
|
11
11
|
const ConvexId = "~@confect/core/ConvexId";
|
|
12
12
|
const ConvexIdScope = "~@confect/core/ConvexIdScope";
|
package/src/GroupPath.ts
CHANGED
package/src/GroupSpec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
3
|
import * as Record from "effect/Record";
|
|
4
4
|
import * as Result from "effect/Result";
|
|
5
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
6
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
7
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
8
|
-
import { validateConfectFunctionIdentifier } from "./Identifier";
|
|
5
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
6
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
7
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
8
|
+
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
9
9
|
|
|
10
10
|
export const TypeId = "~@confect/core/GroupSpec";
|
|
11
11
|
export type TypeId = typeof TypeId;
|
package/src/Http.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type * as HttpApi from "effect/http-api/HttpApi";
|
|
|
8
8
|
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
|
|
9
9
|
import type * as HttpApiGroup from "effect/http-api/HttpApiGroup";
|
|
10
10
|
import * as HttpApiScalar from "effect/http-api/HttpApiScalar";
|
|
11
|
-
import * as App from "./App";
|
|
11
|
+
import * as App from "./App.js";
|
|
12
12
|
|
|
13
13
|
const TypeId = "~@confect/core/Http";
|
|
14
14
|
|
package/src/Manifest.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Data from "effect/Data";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
4
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
5
5
|
|
|
6
6
|
export type MiddlewareAttachment<
|
|
7
7
|
MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec =
|
package/src/MiddlewareSpec.ts
CHANGED
|
@@ -3,10 +3,10 @@ import type * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Predicate from "effect/Predicate";
|
|
4
4
|
import type * as Schema from "effect/Schema";
|
|
5
5
|
import type { unhandled } from "effect/Types";
|
|
6
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
7
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
8
|
-
import * as Lazy from "./Lazy";
|
|
9
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
6
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
7
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
8
|
+
import * as Lazy from "./Lazy.js";
|
|
9
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
10
10
|
|
|
11
11
|
export const TypeId = "~@confect/core/MiddlewareSpec";
|
|
12
12
|
export type TypeId = typeof TypeId;
|
package/src/Ref.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import type * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import type {
|
|
3
3
|
DefaultFunctionArgs,
|
|
4
4
|
FunctionReference as ConvexFunctionReference,
|
|
@@ -14,11 +14,11 @@ import * as Match from "effect/Match";
|
|
|
14
14
|
import * as Option from "effect/Option";
|
|
15
15
|
import * as Predicate from "effect/Predicate";
|
|
16
16
|
import * as Schema from "effect/Schema";
|
|
17
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
18
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
19
|
-
import * as Lazy from "./Lazy";
|
|
20
|
-
import * as MiddlewareSpec from "./MiddlewareSpec";
|
|
21
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
17
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
18
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
19
|
+
import * as Lazy from "./Lazy.js";
|
|
20
|
+
import * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
21
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
22
22
|
|
|
23
23
|
export const TypeId = "~@confect/core/Ref";
|
|
24
24
|
export type TypeId = typeof TypeId;
|
package/src/Refs.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { Types } from "effect";
|
|
|
2
2
|
import { pipe } from "effect/Function";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
4
|
import * as Record from "effect/Record";
|
|
5
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
6
|
-
import type * as GroupSpec from "./GroupSpec";
|
|
7
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
8
|
-
import * as Ref from "./Ref";
|
|
9
|
-
import * as Spec from "./Spec";
|
|
5
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
6
|
+
import type * as GroupSpec from "./GroupSpec.js";
|
|
7
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
8
|
+
import * as Ref from "./Ref.js";
|
|
9
|
+
import * as Spec from "./Spec.js";
|
|
10
10
|
|
|
11
11
|
export type Refs<
|
|
12
12
|
Spec_ extends Spec.AnyWithProps,
|
package/src/SchemaToValidator.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as IdScope from "./IdScope";
|
|
1
|
+
import * as IdScope from "./IdScope.js";
|
|
2
2
|
import type {
|
|
3
3
|
GenericId as ConvexGenericId,
|
|
4
4
|
PropertyValidators,
|
|
@@ -30,7 +30,7 @@ import * as Schema from "effect/Schema";
|
|
|
30
30
|
import * as SchemaAST from "effect/SchemaAST";
|
|
31
31
|
import * as String from "effect/String";
|
|
32
32
|
|
|
33
|
-
import * as GenericId from "./GenericId";
|
|
33
|
+
import * as GenericId from "./GenericId.js";
|
|
34
34
|
import type {
|
|
35
35
|
IsAny,
|
|
36
36
|
IsOptional,
|
|
@@ -39,7 +39,7 @@ import type {
|
|
|
39
39
|
IsUnion,
|
|
40
40
|
TypeError,
|
|
41
41
|
UnionToTuple,
|
|
42
|
-
} from "./Types";
|
|
42
|
+
} from "./Types.js";
|
|
43
43
|
|
|
44
44
|
// Args
|
|
45
45
|
|
package/src/Spec.ts
CHANGED
package/src/SystemFields.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as IdScope from "./IdScope";
|
|
1
|
+
import type * as IdScope from "./IdScope.js";
|
|
2
2
|
import type { SystemFields as NonIdSystemFields } from "convex/server";
|
|
3
3
|
import { pipe } from "effect/Function";
|
|
4
4
|
import * as Array from "effect/Array";
|
|
@@ -11,7 +11,7 @@ import * as SchemaAST from "effect/SchemaAST";
|
|
|
11
11
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
12
12
|
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
13
13
|
import * as Struct from "effect/Struct";
|
|
14
|
-
import * as GenericId from "./GenericId";
|
|
14
|
+
import * as GenericId from "./GenericId.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Produces a schema for Convex system fields. In Confect, system fields include
|
package/src/Table.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as IdScope from "./IdScope";
|
|
2
|
-
import * as Lazy from "./Lazy";
|
|
3
|
-
import * as SystemFields from "./SystemFields";
|
|
4
|
-
import type { TableSchemaToTableValidator } from "./SchemaToValidator";
|
|
1
|
+
import * as IdScope from "./IdScope.js";
|
|
2
|
+
import * as Lazy from "./Lazy.js";
|
|
3
|
+
import * as SystemFields from "./SystemFields.js";
|
|
4
|
+
import type { TableSchemaToTableValidator } from "./SchemaToValidator.js";
|
|
5
5
|
import type {
|
|
6
6
|
SystemFields as ConvexSystemFields,
|
|
7
7
|
Expand,
|