@confect/core 9.0.0-next.4 → 9.0.0-next.6
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/CHANGELOG.md +152 -0
- package/dist/FunctionProvenance.d.ts +47 -36
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +24 -5
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +24 -24
- package/dist/FunctionSpec.js +1 -1
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GroupSpec.js +1 -1
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +19 -0
- package/dist/Identifier.d.ts.map +1 -0
- package/dist/{internal/utils.js → Identifier.js} +26 -3
- package/dist/Identifier.js.map +1 -0
- package/dist/Lazy.d.ts +27 -0
- package/dist/Lazy.d.ts.map +1 -0
- package/dist/Lazy.js +44 -0
- package/dist/Lazy.js.map +1 -0
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +4 -4
- package/dist/Ref.js.map +1 -1
- package/dist/Spec.d.ts +3 -22
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +11 -45
- package/dist/Spec.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/package.json +41 -42
- package/src/FunctionProvenance.ts +31 -9
- package/src/FunctionSpec.ts +4 -4
- package/src/GroupSpec.ts +1 -1
- package/src/{internal/utils.ts → Identifier.ts} +34 -0
- package/src/Lazy.ts +40 -0
- package/src/Ref.ts +4 -5
- package/src/Spec.ts +6 -84
- package/src/index.ts +2 -0
- package/dist/internal/utils.d.ts +0 -5
- package/dist/internal/utils.d.ts.map +0 -1
- package/dist/internal/utils.js.map +0 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/Identifier.ts
|
|
4
|
+
var Identifier_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
validateConfectFunctionIdentifier: () => validateConfectFunctionIdentifier,
|
|
6
|
+
validateConfectTableIdentifier: () => validateConfectTableIdentifier
|
|
7
|
+
});
|
|
2
8
|
const RESERVED_JS_IDENTIFIERS = new Set([
|
|
3
9
|
"break",
|
|
4
10
|
"case",
|
|
@@ -54,15 +60,32 @@ const RESERVED_CONVEX_FILE_NAMES = new Set([
|
|
|
54
60
|
"crons"
|
|
55
61
|
]);
|
|
56
62
|
const jsIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
63
|
+
const tableNameRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
57
64
|
const isReservedJsIdentifier = (identifier) => RESERVED_JS_IDENTIFIERS.has(identifier);
|
|
58
65
|
const isReservedConvexFileName = (fileName) => RESERVED_CONVEX_FILE_NAMES.has(fileName);
|
|
59
66
|
const matchesJsIdentifierPattern = (identifier) => jsIdentifierRegex.test(identifier);
|
|
67
|
+
const matchesTableNamePattern = (identifier) => tableNameRegex.test(identifier);
|
|
60
68
|
const validateConfectFunctionIdentifier = (identifier) => {
|
|
61
69
|
if (!matchesJsIdentifierPattern(identifier)) throw new Error(`Expected a valid Confect function identifier, but received: "${identifier}". Valid identifiers must start with a letter, underscore, or dollar sign, and can only contain letters, numbers, underscores, or dollar signs.`);
|
|
62
70
|
if (isReservedJsIdentifier(identifier)) throw new Error(`Expected a valid Confect function identifier, but received: "${identifier}". "${identifier}" is a reserved JavaScript identifier.`);
|
|
63
71
|
if (isReservedConvexFileName(identifier)) throw new Error(`Expected a valid Confect function identifier, but received: "${identifier}". "${identifier}" is a reserved Convex file name.`);
|
|
64
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Validate that `identifier` is suitable as a Convex table name (and, equivalently,
|
|
75
|
+
* as a `confect/tables/<identifier>.ts` filename).
|
|
76
|
+
*
|
|
77
|
+
* Rules:
|
|
78
|
+
* - Must match `/^[A-Za-z][A-Za-z0-9_]*$/` — letter-leading, alphanumeric plus
|
|
79
|
+
* underscore. No `$` (not a valid Convex table name character); no leading
|
|
80
|
+
* `_` (Convex reserves `_<name>` for its system tables).
|
|
81
|
+
* - Must not be a reserved JavaScript identifier, so the name can also be used
|
|
82
|
+
* as a binding name in generated code without escaping.
|
|
83
|
+
*/
|
|
84
|
+
const validateConfectTableIdentifier = (identifier) => {
|
|
85
|
+
if (!matchesTableNamePattern(identifier)) throw new Error(`Expected a valid Confect table identifier, but received: "${identifier}". Valid table identifiers must start with a letter and can only contain letters, numbers, and underscores. Leading underscores are reserved for Convex system tables.`);
|
|
86
|
+
if (isReservedJsIdentifier(identifier)) throw new Error(`Expected a valid Confect table identifier, but received: "${identifier}". "${identifier}" is a reserved JavaScript identifier.`);
|
|
87
|
+
};
|
|
65
88
|
|
|
66
89
|
//#endregion
|
|
67
|
-
export { validateConfectFunctionIdentifier };
|
|
68
|
-
//# sourceMappingURL=
|
|
90
|
+
export { Identifier_exports, validateConfectFunctionIdentifier, validateConfectTableIdentifier };
|
|
91
|
+
//# sourceMappingURL=Identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Identifier.js","names":[],"sources":["../src/Identifier.ts"],"sourcesContent":["const RESERVED_JS_IDENTIFIERS = new Set([\n // Reserved keywords\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"export\",\n \"extends\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n // Future reserved keywords\n \"await\",\n \"enum\",\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n // Literal values that cannot be reassigned\n \"null\",\n \"true\",\n \"false\",\n // Global objects that shouldn't be shadowed\n \"undefined\",\n]);\n\nconst RESERVED_CONVEX_FILE_NAMES = new Set([\"schema\", \"http\", \"crons\"]);\n\nconst jsIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n// Stricter than `jsIdentifierRegex`: tables cannot start with `_` (Convex\n// reserves leading underscores for system tables) or `$` (Convex's table\n// naming grammar does not accept it). Letters/digits/underscore only,\n// letter-leading.\nconst tableNameRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nconst isReservedJsIdentifier = (identifier: string) =>\n RESERVED_JS_IDENTIFIERS.has(identifier);\n\nconst isReservedConvexFileName = (fileName: string) =>\n RESERVED_CONVEX_FILE_NAMES.has(fileName);\n\nconst matchesJsIdentifierPattern = (identifier: string) =>\n jsIdentifierRegex.test(identifier);\n\nconst matchesTableNamePattern = (identifier: string) =>\n tableNameRegex.test(identifier);\n\nexport const validateConfectFunctionIdentifier = (identifier: string) => {\n if (!matchesJsIdentifierPattern(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". Valid identifiers must start with a letter, underscore, or dollar sign, and can only contain letters, numbers, underscores, or dollar signs.`,\n );\n }\n\n if (isReservedJsIdentifier(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved JavaScript identifier.`,\n );\n }\n\n if (isReservedConvexFileName(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved Convex file name.`,\n );\n }\n};\n\n/**\n * Validate that `identifier` is suitable as a Convex table name (and, equivalently,\n * as a `confect/tables/<identifier>.ts` filename).\n *\n * Rules:\n * - Must match `/^[A-Za-z][A-Za-z0-9_]*$/` — letter-leading, alphanumeric plus\n * underscore. No `$` (not a valid Convex table name character); no leading\n * `_` (Convex reserves `_<name>` for its system tables).\n * - Must not be a reserved JavaScript identifier, so the name can also be used\n * as a binding name in generated code without escaping.\n */\nexport const validateConfectTableIdentifier = (identifier: string) => {\n if (!matchesTableNamePattern(identifier)) {\n throw new Error(\n `Expected a valid Confect table identifier, but received: \"${identifier}\". Valid table identifiers must start with a letter and can only contain letters, numbers, and underscores. Leading underscores are reserved for Convex system tables.`,\n );\n }\n\n if (isReservedJsIdentifier(identifier)) {\n throw new Error(\n `Expected a valid Confect table identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved JavaScript identifier.`,\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,MAAM,0BAA0B,IAAI,IAAI;CAEtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACD,CAAC;AAEF,MAAM,6BAA6B,IAAI,IAAI;CAAC;CAAU;CAAQ;CAAQ,CAAC;AAEvE,MAAM,oBAAoB;AAM1B,MAAM,iBAAiB;AAEvB,MAAM,0BAA0B,eAC9B,wBAAwB,IAAI,WAAW;AAEzC,MAAM,4BAA4B,aAChC,2BAA2B,IAAI,SAAS;AAE1C,MAAM,8BAA8B,eAClC,kBAAkB,KAAK,WAAW;AAEpC,MAAM,2BAA2B,eAC/B,eAAe,KAAK,WAAW;AAEjC,MAAa,qCAAqC,eAAuB;AACvE,KAAI,CAAC,2BAA2B,WAAW,CACzC,OAAM,IAAI,MACR,gEAAgE,WAAW,iJAC5E;AAGH,KAAI,uBAAuB,WAAW,CACpC,OAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,wCAC7F;AAGH,KAAI,yBAAyB,WAAW,CACtC,OAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,mCAC7F;;;;;;;;;;;;;AAeL,MAAa,kCAAkC,eAAuB;AACpE,KAAI,CAAC,wBAAwB,WAAW,CACtC,OAAM,IAAI,MACR,6DAA6D,WAAW,wKACzE;AAGH,KAAI,uBAAuB,WAAW,CACpC,OAAM,IAAI,MACR,6DAA6D,WAAW,MAAM,WAAW,wCAC1F"}
|
package/dist/Lazy.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare namespace Lazy_d_exports {
|
|
2
|
+
export { defineProperty };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Install a lazy memoised property on `target`. The first access runs
|
|
6
|
+
* `compute()` and replaces the getter with a plain, non-writable data
|
|
7
|
+
* property whose value is the computed result. Subsequent accesses hit
|
|
8
|
+
* the V8 fast path for own data properties — no function call, identical
|
|
9
|
+
* returned reference — so first and second-and-subsequent accesses are
|
|
10
|
+
* observably indistinguishable.
|
|
11
|
+
*
|
|
12
|
+
* The replacement property is `enumerable: true` so the lazy property
|
|
13
|
+
* still participates in `Object.keys` / `JSON.stringify` after it
|
|
14
|
+
* materialises, matching the shape of a plain data property. The property
|
|
15
|
+
* is also `enumerable` before materialising, so presence checks
|
|
16
|
+
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
17
|
+
* forcing the computation.
|
|
18
|
+
*
|
|
19
|
+
* This is the single shared implementation consumed across packages (e.g.
|
|
20
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and `@confect/server`'s lazy
|
|
21
|
+
* `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the
|
|
22
|
+
* two drifting apart.
|
|
23
|
+
*/
|
|
24
|
+
declare const defineProperty: <T extends object, K extends PropertyKey>(target: T, key: K, compute: () => unknown) => void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Lazy_d_exports, defineProperty };
|
|
27
|
+
//# sourceMappingURL=Lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lazy.d.ts","names":[],"sources":["../src/Lazy.ts"],"mappings":";;;;;;;AAoBA;;;;;;;;;;;;;;;;cAAa,cAAA,+BAA8C,WAAA,EACzD,MAAA,EAAQ,CAAA,EACR,GAAA,EAAK,CAAA,EACL,OAAA"}
|
package/dist/Lazy.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/Lazy.ts
|
|
4
|
+
var Lazy_exports = /* @__PURE__ */ __exportAll({ defineProperty: () => defineProperty });
|
|
5
|
+
/**
|
|
6
|
+
* Install a lazy memoised property on `target`. The first access runs
|
|
7
|
+
* `compute()` and replaces the getter with a plain, non-writable data
|
|
8
|
+
* property whose value is the computed result. Subsequent accesses hit
|
|
9
|
+
* the V8 fast path for own data properties — no function call, identical
|
|
10
|
+
* returned reference — so first and second-and-subsequent accesses are
|
|
11
|
+
* observably indistinguishable.
|
|
12
|
+
*
|
|
13
|
+
* The replacement property is `enumerable: true` so the lazy property
|
|
14
|
+
* still participates in `Object.keys` / `JSON.stringify` after it
|
|
15
|
+
* materialises, matching the shape of a plain data property. The property
|
|
16
|
+
* is also `enumerable` before materialising, so presence checks
|
|
17
|
+
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
18
|
+
* forcing the computation.
|
|
19
|
+
*
|
|
20
|
+
* This is the single shared implementation consumed across packages (e.g.
|
|
21
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and `@confect/server`'s lazy
|
|
22
|
+
* `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the
|
|
23
|
+
* two drifting apart.
|
|
24
|
+
*/
|
|
25
|
+
const defineProperty = (target, key, compute) => {
|
|
26
|
+
Object.defineProperty(target, key, {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get() {
|
|
30
|
+
const value = compute();
|
|
31
|
+
Object.defineProperty(this, key, {
|
|
32
|
+
value,
|
|
33
|
+
writable: false,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: false
|
|
36
|
+
});
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Lazy_exports, defineProperty };
|
|
44
|
+
//# sourceMappingURL=Lazy.js.map
|
package/dist/Lazy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lazy.js","names":[],"sources":["../src/Lazy.ts"],"sourcesContent":["/**\n * Install a lazy memoised property on `target`. The first access runs\n * `compute()` and replaces the getter with a plain, non-writable data\n * property whose value is the computed result. Subsequent accesses hit\n * the V8 fast path for own data properties — no function call, identical\n * returned reference — so first and second-and-subsequent accesses are\n * observably indistinguishable.\n *\n * The replacement property is `enumerable: true` so the lazy property\n * still participates in `Object.keys` / `JSON.stringify` after it\n * materialises, matching the shape of a plain data property. The property\n * is also `enumerable` before materialising, so presence checks\n * (`\"key\" in target`, `Object.hasOwn(target, key)`) observe it without\n * forcing the computation.\n *\n * This is the single shared implementation consumed across packages (e.g.\n * `@confect/core`'s lazy `FunctionSpec` schemas and `@confect/server`'s lazy\n * `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the\n * two drifting apart.\n */\nexport const defineProperty = <T extends object, K extends PropertyKey>(\n target: T,\n key: K,\n compute: () => unknown,\n): void => {\n Object.defineProperty(target, key, {\n configurable: true,\n enumerable: true,\n get(this: T) {\n const value = compute();\n Object.defineProperty(this, key, {\n value,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n return value;\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,kBACX,QACA,KACA,YACS;AACT,QAAO,eAAe,QAAQ,KAAK;EACjC,cAAc;EACd,YAAY;EACZ,MAAa;GACX,MAAM,QAAQ,SAAS;AACvB,UAAO,eAAe,MAAM,KAAK;IAC/B;IACA,UAAU;IACV,YAAY;IACZ,cAAc;IACf,CAAC;AACF,UAAO;;EAEV,CAAC"}
|
package/dist/Ref.d.ts.map
CHANGED
|
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,IAAA,IAAQ,WAAA,CAAY,UAAA"}
|
package/dist/Ref.js
CHANGED
|
@@ -26,7 +26,7 @@ const make = (functionNamespace, functionSpec) => ({
|
|
|
26
26
|
});
|
|
27
27
|
const getConvexFunctionName = (ref) => `${ref.functionNamespace}:${ref.functionSpec.name}`;
|
|
28
28
|
const getFunctionReference = (ref) => makeFunctionReference(getConvexFunctionName(ref));
|
|
29
|
-
const hasErrorSchema = (ref) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
29
|
+
const hasErrorSchema = (ref) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance), Match.tag("Convex", () => false), Match.exhaustive);
|
|
30
30
|
const encodeArgs = (ref, args) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.encode(confectFunctionProvenance.args)(args)), Match.tag("Convex", () => Effect.succeed(args)), Match.exhaustive);
|
|
31
31
|
const decodeReturns = (ref, returns) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.decode(confectFunctionProvenance.returns)(returns)), Match.tag("Convex", () => Effect.succeed(returns)), Match.exhaustive);
|
|
32
32
|
const encodeArgsSync = (ref, args) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.encodeSync(confectFunctionProvenance.args)(args)), Match.tag("Convex", () => args), Match.exhaustive);
|
|
@@ -56,13 +56,13 @@ const decodeErrorOrElse = (ref, mapUnknownError) => (error) => {
|
|
|
56
56
|
* into, and the caller is responsible for deciding what to do (typically:
|
|
57
57
|
* surface the original value as a defect).
|
|
58
58
|
*/
|
|
59
|
-
const decodeError = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
59
|
+
const decodeError = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Effect.map(Schema.decode(confectFunctionProvenance.error)(encodedError), Option.some) : Effect.succeed(Option.none())), Match.tag("Convex", () => Effect.succeed(Option.none())), Match.exhaustive);
|
|
60
60
|
/**
|
|
61
61
|
* Synchronous counterpart to `decodeError`. Throws on schema decode failure;
|
|
62
62
|
* returns `None` when the ref doesn't declare a typed error.
|
|
63
63
|
*/
|
|
64
|
-
const decodeErrorSync = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
65
|
-
const maybeDecodeErrorSync = (ref, error) => isConvexError(error) ? Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
64
|
+
const decodeErrorSync = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Option.some(Schema.decodeSync(confectFunctionProvenance.error)(encodedError)) : Option.none()), Match.tag("Convex", () => Option.none()), Match.exhaustive);
|
|
65
|
+
const maybeDecodeErrorSync = (ref, error) => isConvexError(error) ? Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Schema.decodeSync(confectFunctionProvenance.error)(error.data) : error), Match.tag("Convex", () => error), Match.exhaustive) : error;
|
|
66
66
|
/**
|
|
67
67
|
* Encode args via the ref's args schema, invoke `call`, decode returns via the
|
|
68
68
|
* ref's returns schema, and translate any thrown `ConvexError` into the ref's
|
package/dist/Ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type {\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport { Effect, Match, Option, Schema } from \"effect\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Ref<\n _RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n _FunctionVisibility extends FunctionVisibility,\n _Args,\n _Returns,\n _Error = never,\n> {\n readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;\n readonly _FunctionVisibility?: _FunctionVisibility;\n readonly _Args?: _Args;\n readonly _Returns?: _Returns;\n readonly _Error?: _Error;\n /** @internal */\n readonly functionSpec: FunctionSpec.AnyWithProps;\n /** @internal */\n readonly functionNamespace: string;\n}\n\nexport interface Any extends Ref<any, any, any, any, any> {}\n\nexport interface AnyInternal extends Ref<any, \"internal\", any, any, any> {}\n\nexport interface AnyPublic extends Ref<any, \"public\", any, any, any> {}\n\nexport interface AnyQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport type GetRuntimeAndFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionVisibility<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer FunctionVisibility_,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer Args_,\n infer _Returns,\n infer _Error\n >\n ? Args_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer Returns_,\n infer _Error\n >\n ? Returns_\n : never;\n\nexport type Error<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer Error_\n >\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_>\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n functionNamespace: string,\n functionSpec: FunctionSpec_,\n): FromFunctionSpec<FunctionSpec_> => ({ functionSpec, functionNamespace });\n\nexport const getConvexFunctionName = (ref: Any): string =>\n `${ref.functionNamespace}:${ref.functionSpec.name}`;\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> =>\n makeFunctionReference(getConvexFunctionName(ref)) as FunctionReference<Ref_>;\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Confect\",\n (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined,\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encode(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decode(confectFunctionProvenance.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encodeSync(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decodeSync(confectFunctionProvenance.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\n/**\n * Decode `encodedError` against the ref's error schema. Returns `None` if the\n * ref doesn't declare a typed error (Confect ref without an `error` schema, or\n * a Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Effect.map(\n Schema.decode(confectFunctionProvenance.error)(encodedError),\n Option.some,\n )\n : Effect.succeed(Option.none<Error<Ref_>>()),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(Option.none<Error<Ref_>>())),\n Match.exhaustive,\n );\n\n/**\n * Synchronous counterpart to `decodeError`. Throws on schema decode failure;\n * returns `None` when the ref doesn't declare a typed error.\n */\nexport const decodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Option.some(\n Schema.decodeSync(confectFunctionProvenance.error)(\n encodedError,\n ) as Error<Ref_>,\n )\n : Option.none<Error<Ref_>>(),\n ),\n Match.tag(\"Convex\", () => Option.none<Error<Ref_>>()),\n Match.exhaustive,\n );\n\nexport const maybeDecodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n error: unknown,\n): unknown =>\n isConvexError(error)\n ? Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Schema.decodeSync(confectFunctionProvenance.error)(error.data)\n : error,\n ),\n Match.tag(\"Convex\", () => error),\n Match.exhaustive,\n )\n : error;\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = <Ref_ extends Any, E = never>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionReference = getFunctionReference(ref);\n const functionProvenance = ref.functionSpec.functionProvenance;\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n return yield* Match.value(functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(\n confectFunctionProvenance.args,\n )(args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* Schema.decode(confectFunctionProvenance.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () => invoke(args)),\n Match.exhaustive,\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmLA,MAAa,QAMX,mBACA,kBACqC;CAAE;CAAc;CAAmB;AAE1E,MAAa,yBAAyB,QACpC,GAAG,IAAI,kBAAkB,GAAG,IAAI,aAAa;AAE/C,MAAa,wBACX,QAEA,sBAAsB,sBAAsB,IAAI,CAAC;AAEnD,MAAa,kBAAkB,QAC7B,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MAAM,IACJ,YACC,8BACC,0BAA0B,UAAU,OACvC,EACD,MAAM,IAAI,gBAAgB,MAAM,EAChC,MAAM,WACP;AAEH,MAAa,cACX,KACA,SAEA,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MAAM,IAAI,YAAY,8BACpB,OAAO,OAAO,0BAA0B,KAAK,CAAC,KAAK,CACpD,EACD,MAAM,IAAI,gBAAgB,OAAO,QAAQ,KAAK,CAAC,EAC/C,MAAM,WACP;AAEH,MAAa,iBACX,KACA,YAEA,MAAM,MAAM,IAAI,aAAa,mBAAmB,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"}
|
|
1
|
+
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type {\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport { Effect, Match, Option, Schema } from \"effect\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Ref<\n _RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n _FunctionVisibility extends FunctionVisibility,\n _Args,\n _Returns,\n _Error = never,\n> {\n readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;\n readonly _FunctionVisibility?: _FunctionVisibility;\n readonly _Args?: _Args;\n readonly _Returns?: _Returns;\n readonly _Error?: _Error;\n /** @internal */\n readonly functionSpec: FunctionSpec.AnyWithProps;\n /** @internal */\n readonly functionNamespace: string;\n}\n\nexport interface Any extends Ref<any, any, any, any, any> {}\n\nexport interface AnyInternal extends Ref<any, \"internal\", any, any, any> {}\n\nexport interface AnyPublic extends Ref<any, \"public\", any, any, any> {}\n\nexport interface AnyQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport type GetRuntimeAndFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionVisibility<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer FunctionVisibility_,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer Args_,\n infer _Returns,\n infer _Error\n >\n ? Args_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer Returns_,\n infer _Error\n >\n ? Returns_\n : never;\n\nexport type Error<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer Error_\n >\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_>\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n functionNamespace: string,\n functionSpec: FunctionSpec_,\n): FromFunctionSpec<FunctionSpec_> => ({ functionSpec, functionNamespace });\n\nexport const getConvexFunctionName = (ref: Any): string =>\n `${ref.functionNamespace}:${ref.functionSpec.name}`;\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> =>\n makeFunctionReference(getConvexFunctionName(ref)) as FunctionReference<Ref_>;\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Confect\",\n (confectFunctionProvenance) => \"error\" in confectFunctionProvenance,\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encode(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decode(confectFunctionProvenance.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encodeSync(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decodeSync(confectFunctionProvenance.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\n/**\n * Decode `encodedError` against the ref's error schema. Returns `None` if the\n * ref doesn't declare a typed error (Confect ref without an `error` schema, or\n * a Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Effect.map(\n Schema.decode(confectFunctionProvenance.error)(encodedError),\n Option.some,\n )\n : Effect.succeed(Option.none<Error<Ref_>>()),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(Option.none<Error<Ref_>>())),\n Match.exhaustive,\n );\n\n/**\n * Synchronous counterpart to `decodeError`. Throws on schema decode failure;\n * returns `None` when the ref doesn't declare a typed error.\n */\nexport const decodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Option.some(\n Schema.decodeSync(confectFunctionProvenance.error)(\n encodedError,\n ) as Error<Ref_>,\n )\n : Option.none<Error<Ref_>>(),\n ),\n Match.tag(\"Convex\", () => Option.none<Error<Ref_>>()),\n Match.exhaustive,\n );\n\nexport const maybeDecodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n error: unknown,\n): unknown =>\n isConvexError(error)\n ? Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Schema.decodeSync(confectFunctionProvenance.error)(error.data)\n : error,\n ),\n Match.tag(\"Convex\", () => error),\n Match.exhaustive,\n )\n : error;\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = <Ref_ extends Any, E = never>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionReference = getFunctionReference(ref);\n const functionProvenance = ref.functionSpec.functionProvenance;\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n return yield* Match.value(functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(\n confectFunctionProvenance.args,\n )(args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* Schema.decode(confectFunctionProvenance.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () => invoke(args)),\n Match.exhaustive,\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmLA,MAAa,QAMX,mBACA,kBACqC;CAAE;CAAc;CAAmB;AAE1E,MAAa,yBAAyB,QACpC,GAAG,IAAI,kBAAkB,GAAG,IAAI,aAAa;AAE/C,MAAa,wBACX,QAEA,sBAAsB,sBAAsB,IAAI,CAAC;AAEnD,MAAa,kBAAkB,QAC7B,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MAAM,IACJ,YACC,8BAA8B,WAAW,0BAC3C,EACD,MAAM,IAAI,gBAAgB,MAAM,EAChC,MAAM,WACP;AAEH,MAAa,cACX,KACA,SAEA,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MA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OAChC,0BAA0B,KAC3B,CAAC,KAAK,CAC0C;AACjD,SAAO,OAAO,OAAO,OAAO,0BAA0B,QAAQ,CAC5D,eACD;GACD,CACH,EACD,MAAM,IAAI,gBAAgB,OAAO,KAAK,CAAC,EACvC,MAAM,WACP;EACD"}
|
package/dist/Spec.d.ts
CHANGED
|
@@ -14,26 +14,8 @@ interface Spec<Runtime$1 extends Runtime, Groups_ extends AnyWithPropsWithRuntim
|
|
|
14
14
|
readonly [TypeId]: TypeId;
|
|
15
15
|
readonly runtime: Runtime$1;
|
|
16
16
|
readonly groups: { [GroupName in Name<Groups_>]: WithName<Groups_, GroupName> };
|
|
17
|
-
/**
|
|
18
|
-
* Mapping from an imported leaf `GroupSpec` reference to its full dot-path
|
|
19
|
-
* within this spec tree. Populated by codegen-emitted `_generated/spec.ts`
|
|
20
|
-
* via {@link Spec#addPath}; consumed by `FunctionImpl.make` /
|
|
21
|
-
* `GroupImpl.make` to resolve a spec's location without walking the tree.
|
|
22
|
-
*/
|
|
23
|
-
readonly paths: ReadonlyMap<AnyWithProps$1, string>;
|
|
24
17
|
add<Group extends AnyWithPropsWithRuntime$1<Runtime$1>>(group: Group): Spec<Runtime$1, Groups_ | Group>;
|
|
25
18
|
addAt<const Name$1 extends string, Group extends AnyWithPropsWithRuntime$1<Runtime$1>>(name: Name$1, group: Group): Spec<Runtime$1, Groups_ | NamedAt<Group, Name$1>>;
|
|
26
|
-
/**
|
|
27
|
-
* Register the imported leaf `group` at `path` within this spec's path
|
|
28
|
-
* mapping. Returns a new `Spec` with one additional entry. The tree shape
|
|
29
|
-
* (`groups`) is unaffected — registration and tree assembly are
|
|
30
|
-
* independent steps, both performed by codegen in `_generated/spec.ts`.
|
|
31
|
-
*
|
|
32
|
-
* Re-registering the same group with the same path is a no-op (cheap
|
|
33
|
-
* defense for codegen watch-mode re-imports). Re-registering with a
|
|
34
|
-
* different path throws.
|
|
35
|
-
*/
|
|
36
|
-
addPath(group: AnyWithProps$1, path: string): Spec<Runtime$1, Groups_>;
|
|
37
19
|
}
|
|
38
20
|
interface Any {
|
|
39
21
|
readonly [TypeId]: TypeId;
|
|
@@ -44,11 +26,10 @@ type Groups<Spec_ extends AnyWithProps> = Spec_["groups"][keyof Spec_["groups"]]
|
|
|
44
26
|
declare const make: () => Spec<"Convex">;
|
|
45
27
|
declare const makeNode: () => Spec<"Node">;
|
|
46
28
|
/**
|
|
47
|
-
* Merges a Convex spec with an optional Node spec
|
|
29
|
+
* Merges a Convex spec with an optional Node spec into a single assembled
|
|
30
|
+
* spec (used by codegen to build `Refs.make` and to enumerate function paths).
|
|
48
31
|
* When `nodeSpec` is provided, its groups are merged under a "node" namespace,
|
|
49
|
-
* mirroring the structure used by `Refs.make`.
|
|
50
|
-
* entries are re-prefixed with `"node."` so they continue to identify the
|
|
51
|
-
* same leaves at their new positions in the merged tree.
|
|
32
|
+
* mirroring the structure used by `Refs.make`.
|
|
52
33
|
*/
|
|
53
34
|
declare const merge: <ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node">>(convexSpec: ConvexSpec, nodeSpec?: NodeSpec) => AnyWithProps;
|
|
54
35
|
//#endregion
|
package/dist/Spec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spec.d.ts","names":[],"sources":["../src/Spec.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Spec.d.ts","names":[],"sources":["../src/Spec.ts"],"mappings":";;;;;;;cAIa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,MAAA,GAAU,CAAA,cAAa,CAAA,IAAK,YAAA;AAAA,cAG5B,YAAA,GACX,CAAA,cACC,CAAA,IAAK,uBAAA;AAAA,cAKK,UAAA,GAAc,CAAA,cAAa,CAAA,IAAK,uBAAA;AAAA,UAK5B,IAAA,mBACC,OAAA,kBACA,yBAAA,CAAkC,SAAA;EAAA,UAExC,MAAA,GAAS,MAAA;EAAA,SACV,OAAA,EAAS,SAAA;EAAA,SACT,MAAA,kBACO,IAAA,CAAe,OAAA,IAAW,QAAA,CACtC,OAAA,EACA,SAAA;EAIJ,GAAA,eAAkB,yBAAA,CAAkC,SAAA,GAClD,KAAA,EAAO,KAAA,GACN,IAAA,CAAK,SAAA,EAAS,OAAA,GAAU,KAAA;EAE3B,KAAA,4CAEgB,yBAAA,CAAkC,SAAA,GAEhD,IAAA,EAAM,MAAA,EACN,KAAA,EAAO,KAAA,GACN,IAAA,CAAK,SAAA,EAAS,OAAA,GAAU,OAAA,CAAkB,KAAA,EAAO,MAAA;AAAA;AAAA,UAGrC,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,IAAA,CACpC,OAAA,EACA,cAAA;AAAA,UAGe,uBAAA,mBACC,OAAA,UACR,IAAA,CAAK,SAAA,EAAS,yBAAA,CAAkC,SAAA;AAAA,KAE9C,MAAA,eAAqB,YAAA,IAC/B,KAAA,iBAAsB,KAAA;AAAA,cAuCX,IAAA,QAAW,IAAA;AAAA,cAGX,QAAA,QAAe,IAAA;;;;AAjG5B;;;cA0Ga,KAAA,sBACQ,uBAAA,6BACF,uBAAA,UAEjB,UAAA,EAAY,UAAA,EACZ,QAAA,GAAW,QAAA,KACV,YAAA"}
|
package/dist/Spec.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { validateConfectFunctionIdentifier } from "./internal/utils.js";
|
|
3
2
|
import { makeNodeAt, withName } from "./GroupSpec.js";
|
|
4
|
-
import { Array, Option, Predicate, Record
|
|
3
|
+
import { Array, Option, Predicate, Record } from "effect";
|
|
5
4
|
|
|
6
5
|
//#region src/Spec.ts
|
|
7
6
|
var Spec_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -17,68 +16,38 @@ const TypeId = "@confect/core/Spec";
|
|
|
17
16
|
const isSpec = (u) => Predicate.hasProperty(u, TypeId);
|
|
18
17
|
const isConvexSpec = (u) => Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, "runtime") && u.runtime === "Convex";
|
|
19
18
|
const isNodeSpec = (u) => Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, "runtime") && u.runtime === "Node";
|
|
20
|
-
const validatePath = (path) => {
|
|
21
|
-
if (path.length === 0) throw new Error("Expected a non-empty Confect group path, but received an empty string.");
|
|
22
|
-
const segments = String.split(path, ".");
|
|
23
|
-
for (const segment of segments) {
|
|
24
|
-
if (segment.length === 0) throw new Error(`Expected a Confect group path made of dot-separated identifier segments, but received: "${path}".`);
|
|
25
|
-
validateConfectFunctionIdentifier(segment);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
19
|
const Proto = {
|
|
29
20
|
[TypeId]: TypeId,
|
|
30
21
|
add(group) {
|
|
31
22
|
return makeProto({
|
|
32
23
|
runtime: this.runtime,
|
|
33
|
-
groups: Record.set(this.groups, group.name, group)
|
|
34
|
-
paths: this.paths
|
|
24
|
+
groups: Record.set(this.groups, group.name, group)
|
|
35
25
|
});
|
|
36
26
|
},
|
|
37
27
|
addAt(name, group) {
|
|
38
28
|
return makeProto({
|
|
39
29
|
runtime: this.runtime,
|
|
40
|
-
groups: Record.set(this.groups, name, withName(name, group))
|
|
41
|
-
paths: this.paths
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
addPath(group, path) {
|
|
45
|
-
validatePath(path);
|
|
46
|
-
const existing = this.paths.get(group);
|
|
47
|
-
if (existing !== void 0) {
|
|
48
|
-
if (existing === path) return this;
|
|
49
|
-
throw new Error(`Spec.addPath: the provided GroupSpec is already registered at "${existing}", but was re-registered at "${path}". Each GroupSpec must have at most one path.`);
|
|
50
|
-
}
|
|
51
|
-
const nextPaths = new Map(this.paths);
|
|
52
|
-
nextPaths.set(group, path);
|
|
53
|
-
return makeProto({
|
|
54
|
-
runtime: this.runtime,
|
|
55
|
-
groups: this.groups,
|
|
56
|
-
paths: nextPaths
|
|
30
|
+
groups: Record.set(this.groups, name, withName(name, group))
|
|
57
31
|
});
|
|
58
32
|
}
|
|
59
33
|
};
|
|
60
|
-
const makeProto = ({ runtime, groups
|
|
34
|
+
const makeProto = ({ runtime, groups }) => Object.assign(Object.create(Proto), {
|
|
61
35
|
runtime,
|
|
62
|
-
groups
|
|
63
|
-
paths
|
|
36
|
+
groups
|
|
64
37
|
});
|
|
65
|
-
const emptyPaths = () => /* @__PURE__ */ new Map();
|
|
66
38
|
const make = () => makeProto({
|
|
67
39
|
runtime: "Convex",
|
|
68
|
-
groups: {}
|
|
69
|
-
paths: emptyPaths()
|
|
40
|
+
groups: {}
|
|
70
41
|
});
|
|
71
42
|
const makeNode = () => makeProto({
|
|
72
43
|
runtime: "Node",
|
|
73
|
-
groups: {}
|
|
74
|
-
paths: emptyPaths()
|
|
44
|
+
groups: {}
|
|
75
45
|
});
|
|
76
46
|
/**
|
|
77
|
-
* Merges a Convex spec with an optional Node spec
|
|
47
|
+
* Merges a Convex spec with an optional Node spec into a single assembled
|
|
48
|
+
* spec (used by codegen to build `Refs.make` and to enumerate function paths).
|
|
78
49
|
* When `nodeSpec` is provided, its groups are merged under a "node" namespace,
|
|
79
|
-
* mirroring the structure used by `Refs.make`.
|
|
80
|
-
* entries are re-prefixed with `"node."` so they continue to identify the
|
|
81
|
-
* same leaves at their new positions in the merged tree.
|
|
50
|
+
* mirroring the structure used by `Refs.make`.
|
|
82
51
|
*/
|
|
83
52
|
const merge = (convexSpec, nodeSpec) => {
|
|
84
53
|
const groups = Option.fromNullable(nodeSpec).pipe(Option.map((nodeSpec_) => Array.reduce(Record.toEntries(nodeSpec_.groups), makeNodeAt("node"), (nodeGroupSpec, [name, group]) => nodeGroupSpec.addGroupAt(name, group))), Option.match({
|
|
@@ -88,12 +57,9 @@ const merge = (convexSpec, nodeSpec) => {
|
|
|
88
57
|
node: nodeGroup
|
|
89
58
|
})
|
|
90
59
|
}));
|
|
91
|
-
const paths = new Map(convexSpec.paths);
|
|
92
|
-
if (nodeSpec !== void 0) for (const [group, path] of nodeSpec.paths) paths.set(group, `node.${path}`);
|
|
93
60
|
return Object.assign(Object.create(Proto), {
|
|
94
61
|
runtime: "Convex",
|
|
95
|
-
groups
|
|
96
|
-
paths
|
|
62
|
+
groups
|
|
97
63
|
});
|
|
98
64
|
};
|
|
99
65
|
|
package/dist/Spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spec.js","names":["GroupSpec.withName","GroupSpec.makeNodeAt"],"sources":["../src/Spec.ts"],"sourcesContent":["import { Array, Option, Predicate, Record
|
|
1
|
+
{"version":3,"file":"Spec.js","names":["GroupSpec.withName","GroupSpec.makeNodeAt"],"sources":["../src/Spec.ts"],"sourcesContent":["import { Array, Option, Predicate, Record } from \"effect\";\nimport * as GroupSpec from \"./GroupSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\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\nexport const isConvexSpec = (\n u: unknown,\n): u is AnyWithPropsWithRuntime<\"Convex\"> =>\n Predicate.hasProperty(u, TypeId) &&\n Predicate.hasProperty(u, \"runtime\") &&\n u.runtime === \"Convex\";\n\nexport const isNodeSpec = (u: unknown): u is AnyWithPropsWithRuntime<\"Node\"> =>\n Predicate.hasProperty(u, TypeId) &&\n Predicate.hasProperty(u, \"runtime\") &&\n u.runtime === \"Node\";\n\nexport interface Spec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Groups_ extends GroupSpec.AnyWithPropsWithRuntime<Runtime> = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly groups: {\n [GroupName in GroupSpec.Name<Groups_>]: GroupSpec.WithName<\n Groups_,\n GroupName\n >;\n };\n\n add<Group extends GroupSpec.AnyWithPropsWithRuntime<Runtime>>(\n group: Group,\n ): Spec<Runtime, Groups_ | Group>;\n\n addAt<\n const Name extends string,\n Group extends GroupSpec.AnyWithPropsWithRuntime<Runtime>,\n >(\n name: Name,\n group: Group,\n ): Spec<Runtime, Groups_ | GroupSpec.NamedAt<Group, Name>>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Spec<\n RuntimeAndFunctionType.Runtime,\n GroupSpec.AnyWithProps\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends Spec<Runtime, GroupSpec.AnyWithPropsWithRuntime<Runtime>> {}\n\nexport type Groups<Spec_ extends AnyWithProps> =\n Spec_[\"groups\"][keyof Spec_[\"groups\"]];\n\nconst Proto = {\n [TypeId]: TypeId,\n\n add<Group extends GroupSpec.AnyWithProps>(this: AnyWithProps, group: Group) {\n return makeProto({\n runtime: this.runtime,\n groups: Record.set(this.groups, group.name, group),\n });\n },\n\n addAt<Group extends GroupSpec.AnyWithProps>(\n this: AnyWithProps,\n name: string,\n group: Group,\n ) {\n return makeProto({\n runtime: this.runtime,\n groups: Record.set(this.groups, name, GroupSpec.withName(name, group)),\n });\n },\n};\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Groups_ extends GroupSpec.AnyWithPropsWithRuntime<Runtime>,\n>({\n runtime,\n groups,\n}: {\n runtime: Runtime;\n groups: Record.ReadonlyRecord<string, Groups_>;\n}): Spec<Runtime, Groups_> =>\n Object.assign(Object.create(Proto), {\n runtime,\n groups,\n });\n\nexport const make = (): Spec<\"Convex\"> =>\n makeProto({ runtime: \"Convex\", groups: {} });\n\nexport const makeNode = (): Spec<\"Node\"> =>\n makeProto({ runtime: \"Node\", groups: {} });\n\n/**\n * Merges a Convex spec with an optional Node spec into a single assembled\n * spec (used by codegen to build `Refs.make` and to enumerate function paths).\n * When `nodeSpec` is provided, its groups are merged under a \"node\" namespace,\n * mirroring the structure used by `Refs.make`.\n */\nexport const merge = <\n ConvexSpec extends AnyWithPropsWithRuntime<\"Convex\">,\n NodeSpec extends AnyWithPropsWithRuntime<\"Node\">,\n>(\n convexSpec: ConvexSpec,\n nodeSpec?: NodeSpec,\n): AnyWithProps => {\n const groups = Option.fromNullable(nodeSpec).pipe(\n Option.map((nodeSpec_) =>\n Array.reduce(\n Record.toEntries(nodeSpec_.groups),\n GroupSpec.makeNodeAt(\"node\"),\n (nodeGroupSpec, [name, group]) => nodeGroupSpec.addGroupAt(name, group),\n ),\n ),\n Option.match({\n onNone: () => convexSpec.groups,\n onSome: (nodeGroup) => ({ ...convexSpec.groups, node: nodeGroup }),\n }),\n );\n\n return Object.assign(Object.create(Proto), {\n runtime: \"Convex\" as const,\n groups,\n }) as AnyWithProps;\n};\n"],"mappings":";;;;;;;;;;;;;;AAIA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,OAAO;AAElC,MAAa,gBACX,MAEA,UAAU,YAAY,GAAG,OAAO,IAChC,UAAU,YAAY,GAAG,UAAU,IACnC,EAAE,YAAY;AAEhB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAG,OAAO,IAChC,UAAU,YAAY,GAAG,UAAU,IACnC,EAAE,YAAY;AA4ChB,MAAM,QAAQ;EACX,SAAS;CAEV,IAA8D,OAAc;AAC1E,SAAO,UAAU;GACf,SAAS,KAAK;GACd,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAM,MAAM,MAAM;GACnD,CAAC;;CAGJ,MAEE,MACA,OACA;AACA,SAAO,UAAU;GACf,SAAS,KAAK;GACd,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAMA,SAAmB,MAAM,MAAM,CAAC;GACvE,CAAC;;CAEL;AAED,MAAM,aAGJ,EACA,SACA,aAKA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACD,CAAC;AAEJ,MAAa,aACX,UAAU;CAAE,SAAS;CAAU,QAAQ,EAAE;CAAE,CAAC;AAE9C,MAAa,iBACX,UAAU;CAAE,SAAS;CAAQ,QAAQ,EAAE;CAAE,CAAC;;;;;;;AAQ5C,MAAa,SAIX,YACA,aACiB;CACjB,MAAM,SAAS,OAAO,aAAa,SAAS,CAAC,KAC3C,OAAO,KAAK,cACV,MAAM,OACJ,OAAO,UAAU,UAAU,OAAO,EAClCC,WAAqB,OAAO,GAC3B,eAAe,CAAC,MAAM,WAAW,cAAc,WAAW,MAAM,MAAM,CACxE,CACF,EACD,OAAO,MAAM;EACX,cAAc,WAAW;EACzB,SAAS,eAAe;GAAE,GAAG,WAAW;GAAQ,MAAM;GAAW;EAClE,CAAC,CACH;AAED,QAAO,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;EACzC,SAAS;EACT;EACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { FunctionSpec_d_exports } from "./FunctionSpec.js";
|
|
|
4
4
|
import { GenericId_d_exports } from "./GenericId.js";
|
|
5
5
|
import { GroupSpec_d_exports } from "./GroupSpec.js";
|
|
6
6
|
import { GroupPath_d_exports } from "./GroupPath.js";
|
|
7
|
+
import { Identifier_d_exports } from "./Identifier.js";
|
|
8
|
+
import { Lazy_d_exports } from "./Lazy.js";
|
|
7
9
|
import { PaginationResult_d_exports } from "./PaginationResult.js";
|
|
8
10
|
import { Ref_d_exports } from "./Ref.js";
|
|
9
11
|
import { Spec_d_exports } from "./Spec.js";
|
|
@@ -12,4 +14,4 @@ import { Registry_d_exports } from "./Registry.js";
|
|
|
12
14
|
import { SystemFields_d_exports } from "./SystemFields.js";
|
|
13
15
|
import { Types_d_exports } from "./Types.js";
|
|
14
16
|
import { UserIdentity_d_exports } from "./UserIdentity.js";
|
|
15
|
-
export { FunctionProvenance_d_exports as FunctionProvenance, FunctionSpec_d_exports as FunctionSpec, GenericId_d_exports as GenericId, GroupPath_d_exports as GroupPath, GroupSpec_d_exports as GroupSpec, PaginationResult_d_exports as PaginationResult, Ref_d_exports as Ref, Refs_d_exports as Refs, Registry_d_exports as Registry, RuntimeAndFunctionType_d_exports as RuntimeAndFunctionType, Spec_d_exports as Spec, SystemFields_d_exports as SystemFields, Types_d_exports as Types, UserIdentity_d_exports as UserIdentity };
|
|
17
|
+
export { FunctionProvenance_d_exports as FunctionProvenance, FunctionSpec_d_exports as FunctionSpec, GenericId_d_exports as GenericId, GroupPath_d_exports as GroupPath, GroupSpec_d_exports as GroupSpec, Identifier_d_exports as Identifier, Lazy_d_exports as Lazy, PaginationResult_d_exports as PaginationResult, Ref_d_exports as Ref, Refs_d_exports as Refs, Registry_d_exports as Registry, RuntimeAndFunctionType_d_exports as RuntimeAndFunctionType, Spec_d_exports as Spec, SystemFields_d_exports as SystemFields, Types_d_exports as Types, UserIdentity_d_exports as UserIdentity };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Lazy_exports } from "./Lazy.js";
|
|
1
2
|
import { FunctionProvenance_exports } from "./FunctionProvenance.js";
|
|
3
|
+
import { Identifier_exports } from "./Identifier.js";
|
|
2
4
|
import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
|
|
3
5
|
import { FunctionSpec_exports } from "./FunctionSpec.js";
|
|
4
6
|
import { GenericId_exports } from "./GenericId.js";
|
|
@@ -13,4 +15,4 @@ import { SystemFields_exports } from "./SystemFields.js";
|
|
|
13
15
|
import { Types_exports } from "./Types.js";
|
|
14
16
|
import { UserIdentity_exports } from "./UserIdentity.js";
|
|
15
17
|
|
|
16
|
-
export { FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, PaginationResult_exports as PaginationResult, Ref_exports as Ref, Refs_exports as Refs, Registry_exports as Registry, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, Spec_exports as Spec, SystemFields_exports as SystemFields, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
|
18
|
+
export { FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Identifier_exports as Identifier, Lazy_exports as Lazy, PaginationResult_exports as PaginationResult, Ref_exports as Ref, Refs_exports as Refs, Registry_exports as Registry, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, Spec_exports as Spec, SystemFields_exports as SystemFields, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/core",
|
|
3
|
-
"version": "9.0.0-next.4",
|
|
4
3
|
"description": "Shared specs and schemas used by all Confect packages",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"url": "https://github.com/rjdellecese/confect.git"
|
|
8
|
-
},
|
|
4
|
+
"version": "9.0.0-next.6",
|
|
5
|
+
"author": "RJ Dellecese",
|
|
9
6
|
"bugs": {
|
|
10
7
|
"url": "https://github.com/rjdellecese/confect/issues"
|
|
11
8
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@ark/attest": "0.56.0",
|
|
11
|
+
"@effect/vitest": "0.29.0",
|
|
12
|
+
"@eslint/js": "10.0.1",
|
|
13
|
+
"@types/node": "25.3.3",
|
|
14
|
+
"effect": "3.21.2",
|
|
15
|
+
"eslint": "10.0.2",
|
|
16
|
+
"prettier": "3.8.1",
|
|
17
|
+
"tsdown": "0.20.3",
|
|
18
|
+
"tsx": "4.21.0",
|
|
19
|
+
"typescript": "5.9.3",
|
|
20
|
+
"typescript-eslint": "8.56.1",
|
|
21
|
+
"vitest": "3.2.4"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
23
26
|
"exports": {
|
|
24
27
|
".": {
|
|
25
28
|
"types": "./dist/index.d.ts",
|
|
@@ -32,46 +35,42 @@
|
|
|
32
35
|
"./package.json": "./package.json",
|
|
33
36
|
"./internal/*": null
|
|
34
37
|
},
|
|
38
|
+
"files": [
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist",
|
|
43
|
+
"package.json",
|
|
44
|
+
"src"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://confect.dev",
|
|
35
47
|
"keywords": [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
48
|
+
"convex",
|
|
49
|
+
"effect"
|
|
38
50
|
],
|
|
39
|
-
"author": "RJ Dellecese",
|
|
40
51
|
"license": "ISC",
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
"@effect/vitest": "0.29.0",
|
|
44
|
-
"@eslint/js": "10.0.1",
|
|
45
|
-
"@types/node": "25.3.3",
|
|
46
|
-
"effect": "3.21.2",
|
|
47
|
-
"eslint": "10.0.2",
|
|
48
|
-
"prettier": "3.8.1",
|
|
49
|
-
"tsdown": "0.20.3",
|
|
50
|
-
"tsx": "4.21.0",
|
|
51
|
-
"typescript": "5.9.3",
|
|
52
|
-
"typescript-eslint": "8.56.1",
|
|
53
|
-
"vitest": "3.2.4"
|
|
54
|
-
},
|
|
52
|
+
"main": "./dist/index.js",
|
|
53
|
+
"module": "./dist/index.js",
|
|
55
54
|
"peerDependencies": {
|
|
56
55
|
"convex": "1.39.1",
|
|
57
56
|
"effect": "^3.21.2"
|
|
58
57
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "https://github.com/rjdellecese/confect.git"
|
|
62
61
|
},
|
|
63
|
-
"
|
|
64
|
-
"
|
|
62
|
+
"sideEffects": false,
|
|
63
|
+
"type": "module",
|
|
65
64
|
"types": "./dist/index.d.ts",
|
|
66
65
|
"scripts": {
|
|
66
|
+
"bench": "tsx test/Refs.bench.ts",
|
|
67
67
|
"build": "tsdown --config-loader unrun",
|
|
68
|
+
"clean": "rm -rf dist coverage node_modules",
|
|
68
69
|
"dev": "tsdown --watch",
|
|
69
|
-
"test": "vitest run",
|
|
70
|
-
"typecheck": "tsc --noEmit --project tsconfig.json",
|
|
71
70
|
"fix": "prettier --write . && eslint --fix . --max-warnings=0",
|
|
72
71
|
"format": "prettier --check .",
|
|
73
72
|
"lint": "eslint . --max-warnings=0",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
76
75
|
}
|
|
77
76
|
}
|