@gaganref/confect-server 10.3.1-fork.2 → 10.3.1-fork.21
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/ActionCtx.d.ts +1 -1
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/AiGatewayDecisionClient.d.ts +2 -2
- package/dist/AiGatewayDecisionClient.d.ts.map +1 -1
- package/dist/AiGatewayDecisionClient.js.map +1 -1
- package/dist/AiGatewayLanguageClient.d.ts +2 -2
- package/dist/AiGatewayLanguageClient.d.ts.map +1 -1
- package/dist/AiGatewayLanguageClient.js.map +1 -1
- package/dist/Auth.d.ts +1 -1
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/ComponentCtx.d.ts +1 -1
- package/dist/ComponentCtx.d.ts.map +1 -1
- package/dist/ConvexFunctionDefinitions.d.ts +4 -4
- package/dist/ConvexFunctionDefinitions.d.ts.map +1 -1
- package/dist/ConvexFunctionDefinitions.js.map +1 -1
- package/dist/CronJobs.d.ts +1 -1
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +3 -3
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DataModel.js.map +1 -1
- package/dist/DatabaseReader.d.ts +4 -4
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +1 -1
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +5 -5
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +23 -3
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +4 -4
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js.map +1 -1
- package/dist/FunctionImpl.d.ts +2 -2
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/FunctionRegistryItem.d.ts +1 -1
- package/dist/FunctionRegistryItem.d.ts.map +1 -1
- package/dist/FunctionRegistryItem.js.map +1 -1
- package/dist/GroupImpl.d.ts +24 -5
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +17 -18
- package/dist/GroupImpl.js.map +1 -1
- package/dist/GroupRegistry.d.ts +2 -2
- package/dist/GroupRegistry.d.ts.map +1 -1
- package/dist/GroupRegistry.js.map +1 -1
- package/dist/Handler.d.ts +23 -23
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpRouter.d.ts +13 -13
- package/dist/HttpRouter.d.ts.map +1 -1
- package/dist/HttpRouter.js.map +1 -1
- package/dist/MiddlewareImpl.d.ts +14 -14
- package/dist/MiddlewareImpl.d.ts.map +1 -1
- package/dist/MiddlewareImpl.js.map +1 -1
- package/dist/MutationCtx.d.ts +1 -1
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +1 -1
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js.map +1 -1
- package/dist/MutationTransactionContext.d.ts +2 -2
- package/dist/MutationTransactionContext.d.ts.map +1 -1
- package/dist/MutationTransactionContext.js.map +1 -1
- package/dist/OfficialComponent.d.ts +50 -0
- package/dist/OfficialComponent.d.ts.map +1 -0
- package/dist/OfficialComponent.js +70 -0
- package/dist/OfficialComponent.js.map +1 -0
- package/dist/OrderedQuery.d.ts +4 -4
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +1 -1
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +10 -10
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +2 -2
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js.map +1 -1
- package/dist/QueryStream.d.ts +11 -11
- package/dist/QueryStream.d.ts.map +1 -1
- package/dist/QueryStream.js.map +1 -1
- package/dist/QueryStreamCursor.d.ts +2 -2
- package/dist/QueryStreamCursor.d.ts.map +1 -1
- package/dist/QueryStreamCursor.js.map +1 -1
- package/dist/QueryStreamIndexPrefix.d.ts +2 -2
- package/dist/QueryStreamIndexPrefix.d.ts.map +1 -1
- package/dist/QueryStreamIndexPrefix.js.map +1 -1
- package/dist/QueryStreamIndexRange.d.ts +4 -4
- package/dist/QueryStreamIndexRange.d.ts.map +1 -1
- package/dist/QueryStreamIndexRange.js.map +1 -1
- package/dist/QueryStreamKey.d.ts +2 -2
- package/dist/QueryStreamKey.d.ts.map +1 -1
- package/dist/QueryStreamKey.js.map +1 -1
- package/dist/QueryStreamKeyBounds.d.ts +3 -3
- package/dist/QueryStreamKeyBounds.d.ts.map +1 -1
- package/dist/QueryStreamKeyBounds.js.map +1 -1
- package/dist/QueryStreamKeyLayout.d.ts +1 -1
- package/dist/QueryStreamKeyLayout.d.ts.map +1 -1
- package/dist/QueryStreamKeyLayout.js.map +1 -1
- package/dist/QueryStreamKeyValues.d.ts +1 -1
- package/dist/QueryStreamKeyValues.d.ts.map +1 -1
- package/dist/QueryStreamKeyValues.js.map +1 -1
- package/dist/QueryStreamPagination.d.ts +1 -1
- package/dist/QueryStreamPagination.d.ts.map +1 -1
- package/dist/QueryStreamPagination.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +20 -20
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +26 -26
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +3 -3
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +6 -6
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/Registry.d.ts +1 -1
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js.map +1 -1
- package/dist/RegistryItems.d.ts +7 -0
- package/dist/RegistryItems.d.ts.map +1 -1
- package/dist/RegistryItems.js +7 -2
- package/dist/RegistryItems.js.map +1 -1
- package/dist/ResolvedMiddleware.d.ts +2 -2
- package/dist/ResolvedMiddleware.d.ts.map +1 -1
- package/dist/ResolvedMiddleware.js.map +1 -1
- package/dist/Storage.d.ts +6 -6
- package/dist/Storage.d.ts.map +1 -1
- package/dist/Storage.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +1 -1
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +1 -1
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +1 -1
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/TableInfo.d.ts +2 -2
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/TableInfo.js.map +1 -1
- package/dist/VectorSearch.d.ts +1 -1
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +61 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/internal/AiGatewayDecisionClient.d.ts +1 -1
- package/dist/internal/AiGatewayDecisionClient.d.ts.map +1 -1
- package/dist/internal/AiGatewayDecisionClient.js.map +1 -1
- package/dist/internal/AiGatewayLanguageClient.d.ts +1 -1
- package/dist/internal/AiGatewayLanguageClient.d.ts.map +1 -1
- package/dist/internal/AiGatewayLanguageClient.js.map +1 -1
- package/dist/internal/DocumentPatch.d.ts +16 -0
- package/dist/internal/DocumentPatch.d.ts.map +1 -0
- package/dist/internal/DocumentPatch.js +36 -0
- package/dist/internal/DocumentPatch.js.map +1 -0
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/ActionCtx.ts +1 -1
- package/src/AiGatewayDecisionClient.ts +3 -3
- package/src/AiGatewayLanguageClient.ts +3 -3
- package/src/Auth.ts +1 -1
- package/src/ComponentCtx.ts +1 -1
- package/src/ConvexFunctionDefinitions.ts +8 -8
- package/src/CronJobs.ts +1 -1
- package/src/DataModel.ts +3 -3
- package/src/DatabaseReader.ts +4 -4
- package/src/DatabaseSchema.ts +1 -1
- package/src/DatabaseWriter.ts +100 -27
- package/src/Document.ts +4 -4
- package/src/FunctionImpl.ts +5 -5
- package/src/FunctionRegistryItem.ts +1 -1
- package/src/GroupImpl.ts +66 -13
- package/src/GroupRegistry.ts +4 -4
- package/src/Handler.ts +23 -23
- package/src/HttpRouter.ts +17 -17
- package/src/MiddlewareImpl.ts +17 -17
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +1 -1
- package/src/MutationTransactionContext.ts +2 -2
- package/src/OfficialComponent.ts +151 -0
- package/src/OrderedQuery.ts +4 -4
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +9 -9
- package/src/QueryRunner.ts +2 -2
- package/src/QueryStream.ts +15 -15
- package/src/QueryStreamCursor.ts +3 -3
- package/src/QueryStreamIndexPrefix.ts +2 -2
- package/src/QueryStreamIndexRange.ts +4 -4
- package/src/QueryStreamKey.ts +2 -2
- package/src/QueryStreamKeyBounds.ts +3 -3
- package/src/QueryStreamKeyLayout.ts +1 -1
- package/src/QueryStreamKeyValues.ts +1 -1
- package/src/QueryStreamPagination.ts +2 -2
- package/src/RegisteredConvexFunction.ts +21 -21
- package/src/RegisteredFunction.ts +18 -18
- package/src/RegisteredFunctions.ts +4 -4
- package/src/RegisteredNodeFunction.ts +8 -8
- package/src/Registry.ts +1 -1
- package/src/RegistryItems.ts +33 -2
- package/src/ResolvedMiddleware.ts +2 -2
- package/src/Storage.ts +3 -3
- package/src/StorageActionWriter.ts +1 -1
- package/src/StorageReader.ts +1 -1
- package/src/StorageWriter.ts +1 -1
- package/src/TableInfo.ts +2 -2
- package/src/VectorSearch.ts +1 -1
- package/src/index.ts +61 -60
- package/src/internal/AiGatewayDecisionClient.ts +2 -2
- package/src/internal/AiGatewayLanguageClient.ts +2 -2
- package/src/internal/DocumentPatch.ts +87 -0
- package/src/node.ts +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReadonlyValue } from "@confect/core/SchemaToValidator";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Record from "effect/Record";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import type * as Table from "../Table.js";
|
|
6
|
+
export type EncodedPatch = Record.ReadonlyRecord<string, ReadonlyValue | undefined>;
|
|
7
|
+
export type PatchEncoder = (patch: Record.ReadonlyRecord<string, unknown>) => Effect.Effect<EncodedPatch, Schema.SchemaError>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the encoder for patches to the table's documents, or `undefined` when
|
|
10
|
+
* the table's codec does not encode each field independently. The encoder maps
|
|
11
|
+
* every patched field of the table to its encoded value, or to `undefined` when
|
|
12
|
+
* the patch unsets the field or the field's codec encodes the value as an
|
|
13
|
+
* absent key. Keys outside the table's fields are left out.
|
|
14
|
+
*/
|
|
15
|
+
export declare const encoder: (table: Table.AnyWithProps) => PatchEncoder | undefined;
|
|
16
|
+
//# sourceMappingURL=DocumentPatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentPatch.d.ts","sourceRoot":"","sources":["../../src/internal/DocumentPatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAC9C,MAAM,EACN,aAAa,GAAG,SAAS,CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1C,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;AAIrD;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,UACX,KAAK,CAAC,YAAY,KACxB,YAAY,GAAG,SAOjB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { pipe } from "effect/Function";
|
|
4
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
5
|
+
import * as Record from "effect/Record";
|
|
6
|
+
//#region src/internal/DocumentPatch.ts
|
|
7
|
+
const patchEncoders = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
/**
|
|
9
|
+
* Returns the encoder for patches to the table's documents, or `undefined` when
|
|
10
|
+
* the table's codec does not encode each field independently. The encoder maps
|
|
11
|
+
* every patched field of the table to its encoded value, or to `undefined` when
|
|
12
|
+
* the patch unsets the field or the field's codec encodes the value as an
|
|
13
|
+
* absent key. Keys outside the table's fields are left out.
|
|
14
|
+
*/
|
|
15
|
+
const encoder = (table) => {
|
|
16
|
+
let cached = patchEncoders.get(table);
|
|
17
|
+
if (cached === void 0) {
|
|
18
|
+
cached = makePatchEncoder(table);
|
|
19
|
+
patchEncoders.set(table, cached);
|
|
20
|
+
}
|
|
21
|
+
return cached ?? void 0;
|
|
22
|
+
};
|
|
23
|
+
const makePatchEncoder = (table) => {
|
|
24
|
+
const ast = table.Fields.ast;
|
|
25
|
+
if (!SchemaAST.isObjects(ast) || ast.encoding !== void 0 || ast.checks !== void 0 || ast.indexSignatures.length > 0) return null;
|
|
26
|
+
const fieldEncoders = Object.fromEntries(ast.propertySignatures.map(({ name, type }) => {
|
|
27
|
+
const key = String(name);
|
|
28
|
+
const encode = Schema.encodeUnknownEffect(Schema.Struct({ [key]: Schema.optionalKey(Schema.make(type)) }));
|
|
29
|
+
return [key, (value) => Effect.map(encode({ [key]: value }), (encoded) => encoded[key])];
|
|
30
|
+
}));
|
|
31
|
+
return (patch) => pipe(fieldEncoders, Record.filter((_, name) => Object.hasOwn(patch, name)), Record.map((encode, name) => patch[name] === void 0 ? Effect.undefined : encode(patch[name])), Effect.all);
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { encoder };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=DocumentPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentPatch.js","names":[],"sources":["../../src/internal/DocumentPatch.ts"],"sourcesContent":["import type { ReadonlyValue } from \"@confect/core/SchemaToValidator\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport type * as Table from \"../Table.js\";\n\nexport type EncodedPatch = Record.ReadonlyRecord<\n string,\n ReadonlyValue | undefined\n>;\n\nexport type PatchEncoder = (\n patch: Record.ReadonlyRecord<string, unknown>,\n) => Effect.Effect<EncodedPatch, Schema.SchemaError>;\n\nconst patchEncoders = new WeakMap<Table.AnyWithProps, PatchEncoder | null>();\n\n/**\n * Returns the encoder for patches to the table's documents, or `undefined` when\n * the table's codec does not encode each field independently. The encoder maps\n * every patched field of the table to its encoded value, or to `undefined` when\n * the patch unsets the field or the field's codec encodes the value as an\n * absent key. Keys outside the table's fields are left out.\n */\nexport const encoder = (\n table: Table.AnyWithProps,\n): PatchEncoder | undefined => {\n let cached = patchEncoders.get(table);\n if (cached === undefined) {\n cached = makePatchEncoder(table);\n patchEncoders.set(table, cached);\n }\n return cached ?? undefined;\n};\n\n// A struct with no encoding of its own encodes each field through that field's\n// codec alone, so a patch encodes field by field. A union or a transformation\n// over the whole struct can make one field's encoding depend on another field.\n// A struct-level check must see the decoded fields before they are encoded,\n// and keys under an index signature have no field codec of their own.\nconst makePatchEncoder = (table: Table.AnyWithProps): PatchEncoder | null => {\n const ast = table.Fields.ast;\n if (\n !SchemaAST.isObjects(ast) ||\n ast.encoding !== undefined ||\n ast.checks !== undefined ||\n ast.indexSignatures.length > 0\n ) {\n return null;\n }\n // A field's codec runs only when the patch gives the field a value, since a\n // codec can handle a missing key. Each comes from the table, whose codecs\n // need no services.\n const fieldEncoders: Record.ReadonlyRecord<\n string,\n (\n value: unknown,\n ) => Effect.Effect<ReadonlyValue | undefined, Schema.SchemaError>\n > = Object.fromEntries(\n ast.propertySignatures.map(({ name, type }) => {\n const key = String(name);\n const encode = Schema.encodeUnknownEffect(\n Schema.Struct({\n [key]: Schema.optionalKey(\n Schema.make<Schema.Codec<unknown, ReadonlyValue>>(type),\n ),\n }),\n );\n return [\n key,\n (value: unknown) =>\n Effect.map(encode({ [key]: value }), (encoded) => encoded[key]),\n ];\n }),\n );\n return (patch) =>\n pipe(\n fieldEncoders,\n Record.filter((_, name) => Object.hasOwn(patch, name)),\n Record.map((encode, name) =>\n patch[name] === undefined ? Effect.undefined : encode(patch[name]),\n ),\n Effect.all,\n );\n};\n"],"mappings":";;;;;;AAiBA,MAAM,gCAAgB,IAAI,QAAiD;;;;;;;;AAS3E,MAAa,WACX,UAC6B;CAC7B,IAAI,SAAS,cAAc,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW;EACxB,SAAS,iBAAiB,KAAK;EAC/B,cAAc,IAAI,OAAO,MAAM;CACjC;CACA,OAAO,UAAU,KAAA;AACnB;AAOA,MAAM,oBAAoB,UAAmD;CAC3E,MAAM,MAAM,MAAM,OAAO;CACzB,IACE,CAAC,UAAU,UAAU,GAAG,KACxB,IAAI,aAAa,KAAA,KACjB,IAAI,WAAW,KAAA,KACf,IAAI,gBAAgB,SAAS,GAE7B,OAAO;CAKT,MAAM,gBAKF,OAAO,YACT,IAAI,mBAAmB,KAAK,EAAE,MAAM,WAAW;EAC7C,MAAM,MAAM,OAAO,IAAI;EACvB,MAAM,SAAS,OAAO,oBACpB,OAAO,OAAO,GACX,MAAM,OAAO,YACZ,OAAO,KAA2C,IAAI,CACxD,EACF,CAAC,CACH;EACA,OAAO,CACL,MACC,UACC,OAAO,IAAI,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,YAAY,QAAQ,IAAI,CAClE;CACF,CAAC,CACH;CACA,QAAQ,UACN,KACE,eACA,OAAO,QAAQ,GAAG,SAAS,OAAO,OAAO,OAAO,IAAI,CAAC,GACrD,OAAO,KAAK,QAAQ,SAClB,MAAM,UAAU,KAAA,IAAY,OAAO,YAAY,OAAO,MAAM,KAAK,CACnE,GACA,OAAO,GACT;AACJ"}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * as RegisteredNodeFunction from "./RegisteredNodeFunction";
|
|
1
|
+
export * as RegisteredNodeFunction from "./RegisteredNodeFunction.js";
|
|
2
2
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-server",
|
|
3
|
-
"version": "10.3.1-fork.
|
|
3
|
+
"version": "10.3.1-fork.21",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@effect/ai-openai-compat": "4.0.4",
|
|
6
6
|
"@effect/ai-openrouter": "4.0.4"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.21",
|
|
10
10
|
"@effect/platform-node": "^4.0.0",
|
|
11
11
|
"convex": "^1.45.0",
|
|
12
12
|
"effect": "^4.0.4"
|
package/src/ActionCtx.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as IdScope from "@confect/core/IdScope";
|
|
2
2
|
import type { GenericActionCtx, GenericDataModel } from "convex/server";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
|
-
import type * as ComponentCtx from "./ComponentCtx";
|
|
4
|
+
import type * as ComponentCtx from "./ComponentCtx.js";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
6
|
|
|
7
7
|
export type ActionCtxTag<
|
|
@@ -2,14 +2,14 @@ import * as OpenRouterClient from "@effect/ai-openrouter/OpenRouterClient";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
5
|
-
import * as InternalAiGatewayDecisionClient from "./internal/AiGatewayDecisionClient";
|
|
6
|
-
import * as AiGatewayServiceToken from "./internal/AiGatewayServiceToken";
|
|
5
|
+
import * as InternalAiGatewayDecisionClient from "./internal/AiGatewayDecisionClient.js";
|
|
6
|
+
import * as AiGatewayServiceToken from "./internal/AiGatewayServiceToken.js";
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
AiGatewayDisabled,
|
|
10
10
|
AiGatewayError,
|
|
11
11
|
AiGatewayUnavailable,
|
|
12
|
-
} from "./internal/AiGatewayServiceToken";
|
|
12
|
+
} from "./internal/AiGatewayServiceToken.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The client configured for Convex AI gateway decisions.
|
|
@@ -2,14 +2,14 @@ import * as OpenAiClient from "@effect/ai-openai-compat/OpenAiClient";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
5
|
-
import * as InternalAiGatewayLanguageClient from "./internal/AiGatewayLanguageClient";
|
|
6
|
-
import * as AiGatewayServiceToken from "./internal/AiGatewayServiceToken";
|
|
5
|
+
import * as InternalAiGatewayLanguageClient from "./internal/AiGatewayLanguageClient.js";
|
|
6
|
+
import * as AiGatewayServiceToken from "./internal/AiGatewayServiceToken.js";
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
AiGatewayDisabled,
|
|
10
10
|
AiGatewayError,
|
|
11
11
|
AiGatewayUnavailable,
|
|
12
|
-
} from "./internal/AiGatewayServiceToken";
|
|
12
|
+
} from "./internal/AiGatewayServiceToken.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The client service configured for Convex AI gateway language models.
|
package/src/Auth.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Layer from "effect/Layer";
|
|
|
6
6
|
import * as Match from "effect/Match";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
10
10
|
|
|
11
11
|
const make = (auth: ConvexAuth) => ({
|
|
12
12
|
getUserIdentity: Effect.promise(() => auth.getUserIdentity()).pipe(
|
package/src/ComponentCtx.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
VectorIndexNames,
|
|
18
18
|
VectorSearchQuery,
|
|
19
19
|
} from "convex/server";
|
|
20
|
-
import type { PatchValue } from "./DatabaseWriter";
|
|
20
|
+
import type { PatchValue } from "./DatabaseWriter.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Distinguishes raw component services from structurally compatible app ctxs.
|
|
@@ -3,14 +3,14 @@ import * as Match from "effect/Match";
|
|
|
3
3
|
import * as Record from "effect/Record";
|
|
4
4
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
5
5
|
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
6
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
7
|
-
import type * as GroupImpl from "./GroupImpl";
|
|
8
|
-
import * as GroupRegistry from "./GroupRegistry";
|
|
9
|
-
import * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
10
|
-
import * as RegisteredConvexFunction from "./RegisteredConvexFunction";
|
|
11
|
-
import type * as RegisteredFunctions from "./RegisteredFunctions";
|
|
12
|
-
import * as ResolvedMiddleware from "./ResolvedMiddleware";
|
|
13
|
-
import { mapLeaves } from "./internal/utils";
|
|
6
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
7
|
+
import type * as GroupImpl from "./GroupImpl.js";
|
|
8
|
+
import * as GroupRegistry from "./GroupRegistry.js";
|
|
9
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
10
|
+
import * as RegisteredConvexFunction from "./RegisteredConvexFunction.js";
|
|
11
|
+
import type * as RegisteredFunctions from "./RegisteredFunctions.js";
|
|
12
|
+
import * as ResolvedMiddleware from "./ResolvedMiddleware.js";
|
|
13
|
+
import { mapLeaves } from "./internal/utils.js";
|
|
14
14
|
|
|
15
15
|
export interface Definitions {
|
|
16
16
|
readonly [name: string]: RegisteredConvexFunction.Definition | Definitions;
|
package/src/CronJobs.ts
CHANGED
|
@@ -11,7 +11,7 @@ import * as Option from "effect/Option";
|
|
|
11
11
|
import * as Order from "effect/Order";
|
|
12
12
|
import * as Predicate from "effect/Predicate";
|
|
13
13
|
import * as Record from "effect/Record";
|
|
14
|
-
import type * as CronJob from "./CronJob";
|
|
14
|
+
import type * as CronJob from "./CronJob.js";
|
|
15
15
|
|
|
16
16
|
export const TypeId = "~@confect/server/CronJobs";
|
|
17
17
|
export type TypeId = typeof TypeId;
|
package/src/DataModel.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
2
|
-
import type * as Table from "./Table";
|
|
3
|
-
import type * as TableInfo from "./TableInfo";
|
|
1
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
2
|
+
import type * as Table from "./Table.js";
|
|
3
|
+
import type * as TableInfo from "./TableInfo.js";
|
|
4
4
|
import type * as GenericId from "@confect/core/GenericId";
|
|
5
5
|
|
|
6
6
|
export declare const TypeId: "~@confect/server/DataModel";
|
package/src/DatabaseReader.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { GenericDatabaseReader } from "convex/server";
|
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import type { BaseDatabaseReader } from "@confect/core/Types";
|
|
5
|
-
import * as DatabaseSchema from "./DatabaseSchema";
|
|
6
|
-
import type * as DataModel from "./DataModel";
|
|
7
|
-
import * as QueryInitializer from "./QueryInitializer";
|
|
8
|
-
import * as Table from "./Table";
|
|
5
|
+
import * as DatabaseSchema from "./DatabaseSchema.js";
|
|
6
|
+
import type * as DataModel from "./DataModel.js";
|
|
7
|
+
import * as QueryInitializer from "./QueryInitializer.js";
|
|
8
|
+
import * as Table from "./Table.js";
|
|
9
9
|
|
|
10
10
|
type IncludedTables<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =
|
|
11
11
|
| DatabaseSchema.Tables<DatabaseSchema_>
|
package/src/DatabaseSchema.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as Data from "effect/Data";
|
|
|
3
3
|
import * as Result from "effect/Result";
|
|
4
4
|
import * as Predicate from "effect/Predicate";
|
|
5
5
|
import * as Record from "effect/Record";
|
|
6
|
-
import type * as Table from "./Table";
|
|
6
|
+
import type * as Table from "./Table.js";
|
|
7
7
|
|
|
8
8
|
export class EmptyDatabaseScopeError extends Data.TaggedError(
|
|
9
9
|
"EmptyDatabaseScopeError",
|
package/src/DatabaseWriter.ts
CHANGED
|
@@ -10,13 +10,16 @@ import { pipe } from "effect/Function";
|
|
|
10
10
|
import * as Context from "effect/Context";
|
|
11
11
|
import * as Effect from "effect/Effect";
|
|
12
12
|
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Predicate from "effect/Predicate";
|
|
13
14
|
import * as Record from "effect/Record";
|
|
14
|
-
import * as
|
|
15
|
-
import
|
|
16
|
-
import type
|
|
17
|
-
import
|
|
18
|
-
import * as
|
|
19
|
-
import
|
|
15
|
+
import * as Result from "effect/Result";
|
|
16
|
+
import * as DatabaseSchema from "./DatabaseSchema.js";
|
|
17
|
+
import type * as DataModel from "./DataModel.js";
|
|
18
|
+
import type { DocumentByName as DocumentByName_ } from "./DataModel.js";
|
|
19
|
+
import * as Document from "./Document.js";
|
|
20
|
+
import * as DocumentPatch from "./internal/DocumentPatch.js";
|
|
21
|
+
import * as QueryInitializer from "./QueryInitializer.js";
|
|
22
|
+
import type * as Table from "./Table.js";
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* The argument accepted by `patch`: like `Partial<Doc>` without system fields,
|
|
@@ -131,38 +134,108 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
131
134
|
return id as unknown as DataModel.Id<DataModel_, TableName>;
|
|
132
135
|
});
|
|
133
136
|
|
|
137
|
+
// A codec whose encoding spans fields cannot encode a patch on its own, so
|
|
138
|
+
// the patch is merged into the decoded document and the result replaces it.
|
|
139
|
+
const replacePatched = (
|
|
140
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
141
|
+
patchedValues: PatchValue<
|
|
142
|
+
Document.WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
|
|
143
|
+
>,
|
|
144
|
+
) =>
|
|
145
|
+
Effect.gen(function* () {
|
|
146
|
+
const originalDecodedDoc = yield* QueryInitializer.getById<
|
|
147
|
+
Table.AnyWithProps,
|
|
148
|
+
TableName
|
|
149
|
+
>(
|
|
150
|
+
convexDatabaseWriter as any,
|
|
151
|
+
tableDef,
|
|
152
|
+
)(id as unknown as GenericId<TableName>);
|
|
153
|
+
|
|
154
|
+
const updatedEncodedDoc = yield* pipe(
|
|
155
|
+
patchedValues,
|
|
156
|
+
Record.reduce(originalDecodedDoc, (acc, value, key) =>
|
|
157
|
+
value === undefined
|
|
158
|
+
? Record.remove(acc, key)
|
|
159
|
+
: Record.set(acc, key, value),
|
|
160
|
+
),
|
|
161
|
+
Document.encode(tableDef),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
yield* Effect.promise(() =>
|
|
165
|
+
convexDatabaseWriter.replace(
|
|
166
|
+
id as unknown as GenericId<TableName>,
|
|
167
|
+
updatedEncodedDoc as Expand<
|
|
168
|
+
BetterOmit<
|
|
169
|
+
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,
|
|
170
|
+
"_creationTime" | "_id"
|
|
171
|
+
>
|
|
172
|
+
>,
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
134
177
|
const patch = Effect.fn("DatabaseWriter.patch")(function* (
|
|
135
178
|
id: DataModel.Id<DataModel_, TableName>,
|
|
136
179
|
patchedValues: PatchValue<
|
|
137
180
|
Document.WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
|
|
138
181
|
>,
|
|
139
182
|
) {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
183
|
+
const encodePatch = DocumentPatch.encoder(tableDef);
|
|
184
|
+
if (encodePatch === undefined) {
|
|
185
|
+
return yield* replacePatched(id, patchedValues);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const storedDoc = yield* pipe(
|
|
189
|
+
Effect.promise(() =>
|
|
190
|
+
convexDatabaseWriter.get(id as unknown as GenericId<TableName>),
|
|
191
|
+
),
|
|
192
|
+
Effect.andThen((value) =>
|
|
193
|
+
Effect.fromResult(
|
|
194
|
+
Result.fromNullishOr(
|
|
195
|
+
value,
|
|
196
|
+
() =>
|
|
197
|
+
new QueryInitializer.GetByIdFailure({
|
|
198
|
+
tableName,
|
|
199
|
+
id,
|
|
200
|
+
}),
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
),
|
|
204
|
+
);
|
|
205
|
+
// The patch must encode and the patched document must decode. When
|
|
206
|
+
// either fails, the stored document decides whose fault that is.
|
|
207
|
+
const encodedPatch = yield* pipe(
|
|
208
|
+
encodePatch(patchedValues),
|
|
209
|
+
Effect.mapError(({ message }) => message),
|
|
210
|
+
Effect.tap((delta) =>
|
|
211
|
+
pipe(
|
|
212
|
+
{ ...storedDoc, ...delta },
|
|
213
|
+
Record.filter(Predicate.isNotUndefined),
|
|
214
|
+
Document.decode(tableDef),
|
|
215
|
+
Effect.mapError(({ parseError }) => parseError),
|
|
216
|
+
),
|
|
217
|
+
),
|
|
218
|
+
Effect.catch((parseError) =>
|
|
219
|
+
pipe(
|
|
220
|
+
Document.decode(storedDoc, tableDef),
|
|
221
|
+
Effect.andThen(
|
|
222
|
+
Effect.fail(
|
|
223
|
+
new Document.DocumentEncodeError({
|
|
224
|
+
tableName,
|
|
225
|
+
id,
|
|
226
|
+
parseError,
|
|
227
|
+
}),
|
|
228
|
+
),
|
|
229
|
+
),
|
|
230
|
+
),
|
|
154
231
|
),
|
|
155
|
-
Document.encode(tableDef),
|
|
156
232
|
);
|
|
157
233
|
|
|
158
234
|
yield* Effect.promise(() =>
|
|
159
|
-
convexDatabaseWriter.
|
|
235
|
+
convexDatabaseWriter.patch(
|
|
160
236
|
id as unknown as GenericId<TableName>,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,
|
|
164
|
-
"_creationTime" | "_id"
|
|
165
|
-
>
|
|
237
|
+
encodedPatch as Partial<
|
|
238
|
+
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>
|
|
166
239
|
>,
|
|
167
240
|
),
|
|
168
241
|
);
|
package/src/Document.ts
CHANGED
|
@@ -4,10 +4,10 @@ import * as Effect from "effect/Effect";
|
|
|
4
4
|
import * as Function from "effect/Function";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
import type { ReadonlyRecord } from "effect/Record";
|
|
7
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
8
|
-
import type * as DataModel from "./DataModel";
|
|
9
|
-
import type * as TableInfo from "./TableInfo";
|
|
10
|
-
import type * as Table from "./Table";
|
|
7
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
8
|
+
import type * as DataModel from "./DataModel.js";
|
|
9
|
+
import type * as TableInfo from "./TableInfo.js";
|
|
10
|
+
import type * as Table from "./Table.js";
|
|
11
11
|
|
|
12
12
|
export type Document<
|
|
13
13
|
Schema_ extends DatabaseSchema.AnyWithProps,
|
package/src/FunctionImpl.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
2
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
3
|
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
4
|
-
import * as Registry from "./Registry";
|
|
4
|
+
import * as Registry from "./Registry.js";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Ref from "effect/Ref";
|
|
9
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
10
|
-
import type * as Handler from "./Handler";
|
|
11
|
-
import { setNestedProperty } from "./internal/utils";
|
|
12
|
-
import * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
10
|
+
import type * as Handler from "./Handler.js";
|
|
11
|
+
import { setNestedProperty } from "./internal/utils.js";
|
|
12
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
13
13
|
|
|
14
14
|
export interface FunctionImpl<Name_ extends string> {
|
|
15
15
|
readonly name: Name_;
|
|
@@ -5,7 +5,7 @@ import type { FunctionType, FunctionVisibility } from "convex/server";
|
|
|
5
5
|
import * as Match from "effect/Match";
|
|
6
6
|
import * as Predicate from "effect/Predicate";
|
|
7
7
|
import type * as Schema from "effect/Schema";
|
|
8
|
-
import type * as Handler from "./Handler";
|
|
8
|
+
import type * as Handler from "./Handler.js";
|
|
9
9
|
|
|
10
10
|
export const TypeId = "~@confect/server/FunctionRegistryItem";
|
|
11
11
|
export type TypeId = typeof TypeId;
|
package/src/GroupImpl.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
2
|
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
3
|
-
import * as Registry from "./Registry";
|
|
4
|
-
import * as RegistryItems from "./RegistryItems";
|
|
3
|
+
import * as Registry from "./Registry.js";
|
|
4
|
+
import * as RegistryItems from "./RegistryItems.js";
|
|
5
5
|
import * as Array from "effect/Array";
|
|
6
6
|
import * as Context from "effect/Context";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Data from "effect/Data";
|
|
8
9
|
import * as Layer from "effect/Layer";
|
|
9
10
|
import * as Option from "effect/Option";
|
|
10
11
|
import * as Predicate from "effect/Predicate";
|
|
11
12
|
import * as Ref from "effect/Ref";
|
|
12
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
13
|
-
import type * as FunctionImpl from "./FunctionImpl";
|
|
14
|
-
import type * as MiddlewareImpl from "./MiddlewareImpl";
|
|
13
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
14
|
+
import type * as FunctionImpl from "./FunctionImpl.js";
|
|
15
|
+
import type * as MiddlewareImpl from "./MiddlewareImpl.js";
|
|
15
16
|
|
|
16
17
|
export const TypeId = "~@confect/server/GroupImpl";
|
|
17
18
|
export type TypeId = typeof TypeId;
|
|
@@ -111,10 +112,20 @@ export const make = <
|
|
|
111
112
|
FunctionImpl.FromGroupSpec<Group> | MiddlewareImpl.FromGroupSpec<Group>
|
|
112
113
|
>;
|
|
113
114
|
|
|
114
|
-
const
|
|
115
|
-
context
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const findGroupImpl = <S>(context: Context.Context<S>): Option.Option<Any> =>
|
|
116
|
+
Array.findFirst(context.mapUnsafe.values(), isGroupImpl);
|
|
117
|
+
|
|
118
|
+
export class MissingRequiredMiddlewareError extends Data.TaggedError(
|
|
119
|
+
"MissingRequiredMiddlewareError",
|
|
120
|
+
)<{
|
|
121
|
+
readonly missing: ReadonlyArray<RegistryItems.MissingMiddleware>;
|
|
122
|
+
}> {
|
|
123
|
+
override get message(): string {
|
|
124
|
+
return `GroupImpl.finalize: ${this.missing.map(({ functionName, middlewareKey }) => `${functionName} requires middleware "${middlewareKey}"`).join("\n")}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type Finalizable = Layer.Layer<AnyUnfinalized> | Layer.Layer<AnyFinalized>;
|
|
118
129
|
|
|
119
130
|
/**
|
|
120
131
|
* Mark a `GroupImpl` layer as fully implemented. The parameter type defaults
|
|
@@ -127,20 +138,52 @@ const findUnfinalizedGroupImpl = <S>(
|
|
|
127
138
|
* registered into this group's scope are snapshotted onto the produced service
|
|
128
139
|
* value's `registeredFunctionNames` field, so consumers can verify impl
|
|
129
140
|
* completeness against a `GroupSpec`'s expected functions without having to
|
|
130
|
-
* inspect the `Registry` themselves.
|
|
141
|
+
* inspect the `Registry` themselves. Pass `{ required }` to check every
|
|
142
|
+
* registered function's middleware at layer build, including internal
|
|
143
|
+
* functions. This form also accepts a finalized layer so generated registration
|
|
144
|
+
* can enforce the backend declaration without changing authored impls. Pass
|
|
145
|
+
* `groupPath` to qualify uncovered function names in the diagnostic.
|
|
131
146
|
*/
|
|
132
|
-
export
|
|
147
|
+
export function finalize(options: {
|
|
148
|
+
readonly groupPath?: string;
|
|
149
|
+
readonly required: ReadonlyArray<
|
|
150
|
+
Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">
|
|
151
|
+
>;
|
|
152
|
+
}): (group: Finalizable) => Layer.Layer<GroupImpl<"Finalized">>;
|
|
153
|
+
export function finalize(
|
|
133
154
|
group: Layer.Layer<GroupImpl<"Unfinalized">>,
|
|
155
|
+
): Layer.Layer<GroupImpl<"Finalized">>;
|
|
156
|
+
export function finalize(
|
|
157
|
+
input:
|
|
158
|
+
| Finalizable
|
|
159
|
+
| {
|
|
160
|
+
readonly groupPath?: string;
|
|
161
|
+
readonly required: ReadonlyArray<
|
|
162
|
+
Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">
|
|
163
|
+
>;
|
|
164
|
+
},
|
|
165
|
+
):
|
|
166
|
+
| Layer.Layer<GroupImpl<"Finalized">>
|
|
167
|
+
| ((group: Finalizable) => Layer.Layer<GroupImpl<"Finalized">>) {
|
|
168
|
+
return "required" in input
|
|
169
|
+
? (group) => finalizeWith(group, input.required, input.groupPath)
|
|
170
|
+
: finalizeWith(input, []);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const finalizeWith = (
|
|
174
|
+
group: Layer.Layer<never>,
|
|
175
|
+
required: ReadonlyArray<Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">>,
|
|
176
|
+
groupPath = "",
|
|
134
177
|
): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
135
178
|
Layer.flatMap(group, (context): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
136
|
-
|
|
179
|
+
findGroupImpl(context).pipe(
|
|
137
180
|
Option.match({
|
|
138
181
|
onNone: () =>
|
|
139
182
|
Layer.effect(
|
|
140
183
|
GroupImpl<"Finalized">({ finalizationStatus: "Finalized" }),
|
|
141
184
|
Effect.die(
|
|
142
185
|
new Error(
|
|
143
|
-
"GroupImpl.finalize: no
|
|
186
|
+
"GroupImpl.finalize: no GroupImpl service was found in the layer's context.",
|
|
144
187
|
),
|
|
145
188
|
),
|
|
146
189
|
),
|
|
@@ -150,6 +193,16 @@ export const finalize = (
|
|
|
150
193
|
Effect.gen(function* () {
|
|
151
194
|
const registry = yield* Registry.Registry;
|
|
152
195
|
const items = yield* Ref.get(registry);
|
|
196
|
+
const missing = RegistryItems.missingRequired(
|
|
197
|
+
items,
|
|
198
|
+
required,
|
|
199
|
+
groupPath,
|
|
200
|
+
);
|
|
201
|
+
if (missing.length > 0) {
|
|
202
|
+
return yield* Effect.die(
|
|
203
|
+
new MissingRequiredMiddlewareError({ missing }),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
153
206
|
return {
|
|
154
207
|
[TypeId]: TypeId,
|
|
155
208
|
finalizationStatus: "Finalized" as const,
|
package/src/GroupRegistry.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type * as Layer from "effect/Layer";
|
|
3
3
|
import * as Ref from "effect/Ref";
|
|
4
|
-
import * as Registry from "./Registry";
|
|
5
|
-
import type * as RegistryItems from "./RegistryItems";
|
|
6
|
-
import type * as GroupImpl from "./GroupImpl";
|
|
7
|
-
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem";
|
|
4
|
+
import * as Registry from "./Registry.js";
|
|
5
|
+
import type * as RegistryItems from "./RegistryItems.js";
|
|
6
|
+
import type * as GroupImpl from "./GroupImpl.js";
|
|
7
|
+
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
8
8
|
|
|
9
9
|
export const make = (
|
|
10
10
|
groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>,
|
package/src/Handler.ts
CHANGED
|
@@ -2,29 +2,29 @@ import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
|
2
2
|
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
3
3
|
import type * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
4
|
import type { Effect } from "effect";
|
|
5
|
-
import type * as ActionCtx from "./ActionCtx";
|
|
6
|
-
import type * as ActionRunner from "./ActionRunner";
|
|
7
|
-
import type * as Auth from "./Auth";
|
|
8
|
-
import type * as DatabaseReader from "./DatabaseReader";
|
|
9
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
10
|
-
import type * as DatabaseWriter from "./DatabaseWriter";
|
|
11
|
-
import type * as DataModel from "./DataModel";
|
|
12
|
-
import type { ExecutionMetadata } from "./ExecutionMetadata";
|
|
13
|
-
import type { RequestMetadata } from "./RequestMetadata";
|
|
14
|
-
import type { TransactionMetadata } from "./TransactionMetadata";
|
|
15
|
-
import type * as MutationCtx from "./MutationCtx";
|
|
16
|
-
import type * as MutationRunner from "./MutationRunner";
|
|
17
|
-
import type { MutationTransactionContext } from "./MutationTransactionContext";
|
|
18
|
-
import type * as QueryCtx from "./QueryCtx";
|
|
19
|
-
import type * as QueryRunner from "./QueryRunner";
|
|
20
|
-
import type { QueryTransactionContext } from "./QueryTransactionContext";
|
|
21
|
-
import type * as RegisteredFunction from "./RegisteredFunction";
|
|
22
|
-
import type * as Scheduler from "./Scheduler";
|
|
23
|
-
import type { Storage } from "./Storage";
|
|
24
|
-
import type * as StorageActionWriter from "./StorageActionWriter";
|
|
25
|
-
import type * as StorageReader from "./StorageReader";
|
|
26
|
-
import type * as StorageWriter from "./StorageWriter";
|
|
27
|
-
import type * as VectorSearch from "./VectorSearch";
|
|
5
|
+
import type * as ActionCtx from "./ActionCtx.js";
|
|
6
|
+
import type * as ActionRunner from "./ActionRunner.js";
|
|
7
|
+
import type * as Auth from "./Auth.js";
|
|
8
|
+
import type * as DatabaseReader from "./DatabaseReader.js";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
10
|
+
import type * as DatabaseWriter from "./DatabaseWriter.js";
|
|
11
|
+
import type * as DataModel from "./DataModel.js";
|
|
12
|
+
import type { ExecutionMetadata } from "./ExecutionMetadata.js";
|
|
13
|
+
import type { RequestMetadata } from "./RequestMetadata.js";
|
|
14
|
+
import type { TransactionMetadata } from "./TransactionMetadata.js";
|
|
15
|
+
import type * as MutationCtx from "./MutationCtx.js";
|
|
16
|
+
import type * as MutationRunner from "./MutationRunner.js";
|
|
17
|
+
import type { MutationTransactionContext } from "./MutationTransactionContext.js";
|
|
18
|
+
import type * as QueryCtx from "./QueryCtx.js";
|
|
19
|
+
import type * as QueryRunner from "./QueryRunner.js";
|
|
20
|
+
import type { QueryTransactionContext } from "./QueryTransactionContext.js";
|
|
21
|
+
import type * as RegisteredFunction from "./RegisteredFunction.js";
|
|
22
|
+
import type * as Scheduler from "./Scheduler.js";
|
|
23
|
+
import type { Storage } from "./Storage.js";
|
|
24
|
+
import type * as StorageActionWriter from "./StorageActionWriter.js";
|
|
25
|
+
import type * as StorageReader from "./StorageReader.js";
|
|
26
|
+
import type * as StorageWriter from "./StorageWriter.js";
|
|
27
|
+
import type * as VectorSearch from "./VectorSearch.js";
|
|
28
28
|
|
|
29
29
|
export type Handler<
|
|
30
30
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|