@confect/server 9.0.0-next.0 → 9.0.0-next.10
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 +299 -4
- package/dist/ActionCtx.d.ts +4 -11
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/ActionRunner.d.ts +8 -13
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +4 -3
- package/dist/ActionRunner.js.map +1 -1
- package/dist/Auth.d.ts +17 -23
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +5 -1
- package/dist/Auth.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +6 -12
- package/dist/BlobNotFoundError.d.ts.map +1 -1
- package/dist/BlobNotFoundError.js +1 -1
- package/dist/BlobNotFoundError.js.map +1 -1
- package/dist/ConvexConfigProvider.d.ts +2 -9
- package/dist/ConvexConfigProvider.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.js +6 -1
- package/dist/ConvexConfigProvider.js.map +1 -1
- package/dist/CronJob.d.ts +12 -19
- package/dist/CronJob.d.ts.map +1 -1
- package/dist/CronJob.js +1 -1
- package/dist/CronJob.js.map +1 -1
- package/dist/CronJobs.d.ts +11 -18
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js +11 -4
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +24 -29
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DatabaseReader.d.ts +4323 -64
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +6 -6
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +38 -130
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +20 -30
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +38 -42
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +8 -5
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +28 -37
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +5 -1
- package/dist/Document.js.map +1 -1
- package/dist/FunctionImpl.d.ts +30 -29
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +25 -14
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts +45 -41
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +42 -35
- package/dist/GroupImpl.js.map +1 -1
- package/dist/Handler.d.ts +34 -40
- package/dist/Handler.d.ts.map +1 -1
- package/dist/HttpApi.d.ts +21 -25
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +11 -6
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationCtx.d.ts +4 -11
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +8 -13
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +4 -3
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +16 -21
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +4 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +4 -11
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +34 -39
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +5 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +8 -13
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +4 -3
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1107 -60
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +14 -9
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +48 -64
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +9 -5
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +48 -26
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +22 -9
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -14
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +5 -4
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +17 -27
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +1 -1
- package/dist/RegistryItem.js.map +1 -1
- package/dist/Scheduler.d.ts +16 -20
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +10 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +71 -64
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +15 -3
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +21 -28
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js +4 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +14 -21
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js +5 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +16 -23
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js +4 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/Table.d.ts +204 -197
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +72 -62
- package/dist/Table.js.map +1 -1
- package/dist/TableInfo.d.ts +35 -41
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/VectorSearch.d.ts +30 -35
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +3 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +35 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -5
- package/dist/internal/utils.d.ts +9 -11
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +3 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -0
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +50 -59
- package/src/ActionCtx.ts +1 -1
- package/src/ActionRunner.ts +2 -1
- package/src/Auth.ts +5 -1
- package/src/BlobNotFoundError.ts +1 -1
- package/src/ConvexConfigProvider.ts +6 -8
- package/src/CronJob.ts +1 -1
- package/src/CronJobs.ts +8 -10
- package/src/DatabaseReader.ts +18 -21
- package/src/DatabaseSchema.ts +38 -98
- package/src/DatabaseWriter.ts +13 -6
- package/src/Document.ts +5 -1
- package/src/FunctionImpl.ts +36 -44
- package/src/GroupImpl.ts +54 -81
- package/src/HttpApi.ts +8 -9
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +2 -1
- package/src/OrderedQuery.ts +5 -1
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +15 -3
- package/src/QueryRunner.ts +2 -1
- package/src/RegisteredConvexFunction.ts +11 -7
- package/src/RegisteredFunction.ts +5 -1
- package/src/RegisteredFunctions.ts +69 -93
- package/src/RegisteredNodeFunction.ts +7 -6
- package/src/RegistryItem.ts +1 -1
- package/src/Scheduler.ts +5 -1
- package/src/SchemaToValidator.ts +14 -16
- package/src/StorageActionWriter.ts +4 -1
- package/src/StorageReader.ts +5 -1
- package/src/StorageWriter.ts +4 -1
- package/src/Table.ts +253 -132
- package/src/VectorSearch.ts +3 -1
- package/src/index.ts +0 -1
- package/src/internal/utils.ts +3 -1
- package/dist/Api.d.ts +0 -30
- package/dist/Api.d.ts.map +0 -1
- package/dist/Api.js +0 -26
- package/dist/Api.js.map +0 -1
- package/dist/GroupPath.d.ts +0 -8
- package/dist/GroupPath.d.ts.map +0 -1
- package/dist/GroupPath.js +0 -10
- package/dist/GroupPath.js.map +0 -1
- package/src/Api.ts +0 -75
- package/src/GroupPath.ts +0 -43
package/dist/Document.d.ts
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type Any = any;
|
|
13
|
-
type AnyEncoded = ReadonlyRecord<string, ReadonlyValue>;
|
|
14
|
-
declare const decode: (<DataModel_ extends AnyWithProps, TableName extends TableNames<DataModel_>>(tableName: TableName, tableSchema: TableSchema<TableInfoWithName_<DataModel_, TableName>>) => (self: TableInfoWithName_<DataModel_, TableName>["convexDocument"]) => Effect.Effect<TableInfoWithName_<DataModel_, TableName>["document"], DocumentDecodeError>) & (<DataModel_ extends AnyWithProps, TableName extends TableNames<DataModel_>>(self: TableInfoWithName_<DataModel_, TableName>["convexDocument"], tableName: TableName, tableSchema: TableSchema<TableInfoWithName_<DataModel_, TableName>>) => Effect.Effect<TableInfoWithName_<DataModel_, TableName>["document"], DocumentDecodeError>);
|
|
15
|
-
declare const encode: (<DataModel_ extends AnyWithProps, TableName extends TableNames<DataModel_>>(tableName: TableName, tableSchema: TableSchema<TableInfoWithName_<DataModel_, TableName>>) => (self: TableInfoWithName_<DataModel_, TableName>["document"]) => Effect.Effect<TableInfoWithName_<DataModel_, TableName>["encodedDocument"], DocumentEncodeError>) & (<DataModel_ extends AnyWithProps, TableName extends TableNames<DataModel_>>(self: TableInfoWithName_<DataModel_, TableName>["document"], tableName: TableName, tableSchema: TableSchema<TableInfoWithName_<DataModel_, TableName>>) => Effect.Effect<TableInfoWithName_<DataModel_, TableName>["encodedDocument"], DocumentEncodeError>);
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type { ReadonlyRecord } from "effect/Record";
|
|
4
|
+
import type * as DataModel from "./DataModel";
|
|
5
|
+
import type { ReadonlyValue } from "./SchemaToValidator";
|
|
6
|
+
import type * as TableInfo from "./TableInfo";
|
|
7
|
+
export type WithoutSystemFields<Doc> = Omit<Doc, "_creationTime" | "_id">;
|
|
8
|
+
export type Any = any;
|
|
9
|
+
export type AnyEncoded = ReadonlyRecord<string, ReadonlyValue>;
|
|
10
|
+
export declare const decode: (<DataModel_ extends DataModel.AnyWithProps, TableName extends DataModel.TableNames<DataModel_>>(tableName: TableName, tableSchema: TableInfo.TableSchema<DataModel.TableInfoWithName_<DataModel_, TableName>>) => (self: DataModel.TableInfoWithName_<DataModel_, TableName>["convexDocument"]) => Effect.Effect<DataModel.TableInfoWithName_<DataModel_, TableName>["document"], DocumentDecodeError>) & (<DataModel_ extends DataModel.AnyWithProps, TableName extends DataModel.TableNames<DataModel_>>(self: DataModel.TableInfoWithName_<DataModel_, TableName>["convexDocument"], tableName: TableName, tableSchema: TableInfo.TableSchema<DataModel.TableInfoWithName_<DataModel_, TableName>>) => Effect.Effect<DataModel.TableInfoWithName_<DataModel_, TableName>["document"], DocumentDecodeError>);
|
|
11
|
+
export declare const encode: (<DataModel_ extends DataModel.AnyWithProps, TableName extends DataModel.TableNames<DataModel_>>(tableName: TableName, tableSchema: TableInfo.TableSchema<DataModel.TableInfoWithName_<DataModel_, TableName>>) => (self: DataModel.TableInfoWithName_<DataModel_, TableName>["document"]) => Effect.Effect<DataModel.TableInfoWithName_<DataModel_, TableName>["encodedDocument"], DocumentEncodeError>) & (<DataModel_ extends DataModel.AnyWithProps, TableName extends DataModel.TableNames<DataModel_>>(self: DataModel.TableInfoWithName_<DataModel_, TableName>["document"], tableName: TableName, tableSchema: TableInfo.TableSchema<DataModel.TableInfoWithName_<DataModel_, TableName>>) => Effect.Effect<DataModel.TableInfoWithName_<DataModel_, TableName>["encodedDocument"], DocumentEncodeError>);
|
|
16
12
|
declare const DocumentDecodeError_base: Schema.TaggedErrorClass<DocumentDecodeError, "DocumentDecodeError", {
|
|
17
|
-
|
|
13
|
+
readonly _tag: Schema.tag<"DocumentDecodeError">;
|
|
18
14
|
} & {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
tableName: typeof Schema.String;
|
|
16
|
+
id: typeof Schema.String;
|
|
17
|
+
parseError: typeof Schema.String;
|
|
22
18
|
}>;
|
|
23
|
-
declare class DocumentDecodeError extends DocumentDecodeError_base {
|
|
24
|
-
|
|
19
|
+
export declare class DocumentDecodeError extends DocumentDecodeError_base {
|
|
20
|
+
get message(): string;
|
|
25
21
|
}
|
|
26
22
|
declare const DocumentEncodeError_base: Schema.TaggedErrorClass<DocumentEncodeError, "DocumentEncodeError", {
|
|
27
|
-
|
|
23
|
+
readonly _tag: Schema.tag<"DocumentEncodeError">;
|
|
28
24
|
} & {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
tableName: typeof Schema.String;
|
|
26
|
+
id: typeof Schema.String;
|
|
27
|
+
parseError: typeof Schema.String;
|
|
32
28
|
}>;
|
|
33
|
-
declare class DocumentEncodeError extends DocumentEncodeError_base {
|
|
34
|
-
|
|
29
|
+
export declare class DocumentEncodeError extends DocumentEncodeError_base {
|
|
30
|
+
get message(): string;
|
|
35
31
|
}
|
|
36
|
-
declare const documentErrorMessage: ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}: {
|
|
41
|
-
id: string;
|
|
42
|
-
tableName: string;
|
|
43
|
-
message: string;
|
|
32
|
+
export declare const documentErrorMessage: ({ id, tableName, message, }: {
|
|
33
|
+
id: string;
|
|
34
|
+
tableName: string;
|
|
35
|
+
message: string;
|
|
44
36
|
}) => string;
|
|
45
|
-
|
|
46
|
-
export { Any, AnyEncoded, DocumentDecodeError, DocumentEncodeError, Document_d_exports, WithoutSystemFields, decode, documentErrorMessage, encode };
|
|
37
|
+
export {};
|
|
47
38
|
//# sourceMappingURL=Document.d.ts.map
|
package/dist/Document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.d.ts","
|
|
1
|
+
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../src/Document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,mBAAmB,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC;AAE1E,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC;AACtB,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAiC/D,eAAO,MAAM,MAAM,IAEf,UAAU,SAAS,SAAS,CAAC,YAAY,EACzC,SAAS,SAAS,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,aAEvC,SAAS,eACP,SAAS,CAAC,WAAW,CAChC,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CACpD,KACE,CACH,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,gBAAgB,CAAC,KACxE,MAAM,CAAC,MAAM,CAChB,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,UAAU,CAAC,EAC/D,mBAAmB,CACpB,MAEC,UAAU,SAAS,SAAS,CAAC,YAAY,EACzC,SAAS,SAAS,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,QAE5C,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,gBAAgB,CAAC,aAChE,SAAS,eACP,SAAS,CAAC,WAAW,CAChC,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CACpD,KACE,MAAM,CAAC,MAAM,CAChB,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,UAAU,CAAC,EAC/D,mBAAmB,CACpB,CAuCF,CAAC;AAcF,eAAO,MAAM,MAAM,IAEf,UAAU,SAAS,SAAS,CAAC,YAAY,EACzC,SAAS,SAAS,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,aAEvC,SAAS,eACP,SAAS,CAAC,WAAW,CAChC,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CACpD,KACE,CACH,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,UAAU,CAAC,KAClE,MAAM,CAAC,MAAM,CAChB,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,EACtE,mBAAmB,CACpB,MAEC,UAAU,SAAS,SAAS,CAAC,YAAY,EACzC,SAAS,SAAS,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,QAE5C,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,UAAU,CAAC,aAC1D,SAAS,eACP,SAAS,CAAC,WAAW,CAChC,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CACpD,KACE,MAAM,CAAC,MAAM,CAChB,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,EACtE,mBAAmB,CACpB,CAuCF,CAAC;;;;;;;;AAEF,qBAAa,mBAAoB,SAAQ,wBAOxC;IACC,IAAa,OAAO,IAAI,MAAM,CAM7B;CACF;;;;;;;;AAED,qBAAa,mBAAoB,SAAQ,wBAOxC;IACC,IAAa,OAAO,IAAI,MAAM,CAM7B;CACF;AAED,eAAO,MAAM,oBAAoB,GAAI,6BAIlC;IACD,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,WAAkE,CAAC"}
|
package/dist/Document.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import * as Function from "effect/Function";
|
|
3
|
+
import { pipe } from "effect/Function";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
3
6
|
import * as SystemFields from "@confect/core/SystemFields";
|
|
7
|
+
import * as ParseResult from "effect/ParseResult";
|
|
4
8
|
|
|
5
9
|
//#region src/Document.ts
|
|
6
10
|
var Document_exports = /* @__PURE__ */ __exportAll({
|
package/dist/Document.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.js","names":[],"sources":["../src/Document.ts"],"sourcesContent":["import * as SystemFields from \"@confect/core/SystemFields\";\nimport { Effect
|
|
1
|
+
{"version":3,"file":"Document.js","names":[],"sources":["../src/Document.ts"],"sourcesContent":["import * as SystemFields from \"@confect/core/SystemFields\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Function from \"effect/Function\";\nimport * as ParseResult from \"effect/ParseResult\";\nimport * as Schema from \"effect/Schema\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport type * as DataModel from \"./DataModel\";\nimport type { ReadonlyValue } from \"./SchemaToValidator\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport type WithoutSystemFields<Doc> = Omit<Doc, \"_creationTime\" | \"_id\">;\n\nexport type Any = any;\nexport type AnyEncoded = ReadonlyRecord<string, ReadonlyValue>;\n\ntype Decode = (doc: unknown) => Effect.Effect<unknown, ParseResult.ParseError>;\n\nconst decoderCache = new WeakMap<\n Schema.Schema.AnyNoContext,\n Map<string, Decode>\n>();\n\nconst getDecoder = (\n tableName: string,\n tableSchema: Schema.Schema.AnyNoContext,\n): Decode => {\n const byTable =\n decoderCache.get(tableSchema) ??\n (() => {\n const map = new Map<string, Decode>();\n decoderCache.set(tableSchema, map);\n return map;\n })();\n\n return (\n byTable.get(tableName) ??\n (() => {\n const decoder = Schema.decode(\n SystemFields.extendWithSystemFields(tableName, tableSchema),\n ) as Decode;\n byTable.set(tableName, decoder);\n return decoder;\n })()\n );\n};\n\nexport const decode = Function.dual<\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ) => (\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"convexDocument\"],\n ) => Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n DocumentDecodeError\n >,\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"convexDocument\"],\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ) => Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n DocumentDecodeError\n >\n>(\n 3,\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"convexDocument\"],\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ): Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n DocumentDecodeError\n > =>\n pipe(\n self,\n getDecoder(tableName, tableSchema),\n Effect.catchIf(ParseResult.isParseError, (parseError) =>\n Effect.gen(function* () {\n const formattedParseError =\n yield* ParseResult.TreeFormatter.formatError(parseError);\n\n return yield* new DocumentDecodeError({\n tableName,\n id: self._id,\n parseError: formattedParseError,\n });\n }),\n ),\n Effect.map(\n (decodedDoc) =>\n decodedDoc as DataModel.TableInfoWithName_<\n DataModel_,\n TableName\n >[\"document\"],\n ),\n ),\n);\n\ntype Encode = (doc: unknown) => Effect.Effect<unknown, ParseResult.ParseError>;\n\nconst encoderCache = new WeakMap<Schema.Schema.AnyNoContext, Encode>();\n\nconst getEncoder = (tableSchema: Schema.Schema.AnyNoContext): Encode =>\n encoderCache.get(tableSchema) ??\n (() => {\n const encoder = Schema.encode(tableSchema) as Encode;\n encoderCache.set(tableSchema, encoder);\n return encoder;\n })();\n\nexport const encode = Function.dual<\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ) => (\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n ) => Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"encodedDocument\"],\n DocumentEncodeError\n >,\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ) => Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"encodedDocument\"],\n DocumentEncodeError\n >\n>(\n 3,\n <\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n >(\n self: DataModel.TableInfoWithName_<DataModel_, TableName>[\"document\"],\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >,\n ): Effect.Effect<\n DataModel.TableInfoWithName_<DataModel_, TableName>[\"encodedDocument\"],\n DocumentEncodeError\n > =>\n pipe(\n self,\n getEncoder(tableSchema),\n Effect.catchIf(ParseResult.isParseError, (parseError) =>\n Effect.gen(function* () {\n const formattedParseError =\n yield* ParseResult.TreeFormatter.formatError(parseError);\n\n return yield* new DocumentEncodeError({\n tableName,\n id: self._id,\n parseError: formattedParseError,\n });\n }),\n ),\n Effect.map(\n (encodedDoc) =>\n encodedDoc as DataModel.TableInfoWithName_<\n DataModel_,\n TableName\n >[\"encodedDocument\"],\n ),\n ),\n);\n\nexport class DocumentDecodeError extends Schema.TaggedError<DocumentDecodeError>()(\n \"DocumentDecodeError\",\n {\n tableName: Schema.String,\n id: Schema.String,\n parseError: Schema.String,\n },\n) {\n override get message(): string {\n return documentErrorMessage({\n id: this.id,\n tableName: this.tableName,\n message: `could not be decoded:\\n\\n${this.parseError}`,\n });\n }\n}\n\nexport class DocumentEncodeError extends Schema.TaggedError<DocumentEncodeError>()(\n \"DocumentEncodeError\",\n {\n tableName: Schema.String,\n id: Schema.String,\n parseError: Schema.String,\n },\n) {\n override get message(): string {\n return documentErrorMessage({\n id: this.id,\n tableName: this.tableName,\n message: `could not be encoded:\\n\\n${this.parseError}`,\n });\n }\n}\n\nexport const documentErrorMessage = ({\n id,\n tableName,\n message,\n}: {\n id: string;\n tableName: string;\n message: string;\n}) => `Document with ID '${id}' in table '${tableName}' ${message}`;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,+BAAe,IAAI,SAGtB;AAEH,MAAM,cACJ,WACA,gBACW;CACX,MAAM,UACJ,aAAa,IAAI,YAAY,WACtB;EACL,MAAM,sBAAM,IAAI,KAAqB;AACrC,eAAa,IAAI,aAAa,IAAI;AAClC,SAAO;KACL;AAEN,QACE,QAAQ,IAAI,UAAU,WACf;EACL,MAAM,UAAU,OAAO,OACrB,aAAa,uBAAuB,WAAW,YAAY,CAC5D;AACD,UAAQ,IAAI,WAAW,QAAQ;AAC/B,SAAO;KACL;;AAIR,MAAa,SAAS,SAAS,KA6B7B,IAKE,MACA,WACA,gBAOA,KACE,MACA,WAAW,WAAW,YAAY,EAClC,OAAO,QAAQ,YAAY,eAAe,eACxC,OAAO,IAAI,aAAa;CACtB,MAAM,sBACJ,OAAO,YAAY,cAAc,YAAY,WAAW;AAE1D,QAAO,OAAO,IAAI,oBAAoB;EACpC;EACA,IAAI,KAAK;EACT,YAAY;EACb,CAAC;EACF,CACH,EACD,OAAO,KACJ,eACC,WAIH,CACF,CACJ;AAID,MAAM,+BAAe,IAAI,SAA6C;AAEtE,MAAM,cAAc,gBAClB,aAAa,IAAI,YAAY,WACtB;CACL,MAAM,UAAU,OAAO,OAAO,YAAY;AAC1C,cAAa,IAAI,aAAa,QAAQ;AACtC,QAAO;IACL;AAEN,MAAa,SAAS,SAAS,KA6B7B,IAKE,MACA,WACA,gBAOA,KACE,MACA,WAAW,YAAY,EACvB,OAAO,QAAQ,YAAY,eAAe,eACxC,OAAO,IAAI,aAAa;CACtB,MAAM,sBACJ,OAAO,YAAY,cAAc,YAAY,WAAW;AAE1D,QAAO,OAAO,IAAI,oBAAoB;EACpC;EACA,IAAI,KAAK;EACT,YAAY;EACb,CAAC;EACF,CACH,EACD,OAAO,KACJ,eACC,WAIH,CACF,CACJ;AAED,IAAa,sBAAb,cAAyC,OAAO,aAAkC,CAChF,uBACA;CACE,WAAW,OAAO;CAClB,IAAI,OAAO;CACX,YAAY,OAAO;CACpB,CACF,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO,qBAAqB;GAC1B,IAAI,KAAK;GACT,WAAW,KAAK;GAChB,SAAS,4BAA4B,KAAK;GAC3C,CAAC;;;AAIN,IAAa,sBAAb,cAAyC,OAAO,aAAkC,CAChF,uBACA;CACE,WAAW,OAAO;CAClB,IAAI,OAAO;CACX,YAAY,OAAO;CACpB,CACF,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO,qBAAqB;GAC1B,IAAI,KAAK;GACT,WAAW,KAAK;GAChB,SAAS,4BAA4B,KAAK;GAC3C,CAAC;;;AAIN,MAAa,wBAAwB,EACnC,IACA,WACA,cAKI,qBAAqB,GAAG,cAAc,UAAU,IAAI"}
|
package/dist/FunctionImpl.d.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { ForGroupPathAndFunction, FromGroupAtPath, FromGroupSpec, FunctionImpl, make };
|
|
1
|
+
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
6
|
+
import type * as Handler from "./Handler";
|
|
7
|
+
export interface FunctionImpl<FunctionName extends string> {
|
|
8
|
+
readonly functionName: FunctionName;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
declare const FunctionImpl: <GroupPath_ extends string, FunctionName extends string>({
|
|
16
|
-
groupPath,
|
|
17
|
-
functionName
|
|
18
|
-
}: {
|
|
19
|
-
groupPath: GroupPath_;
|
|
20
|
-
functionName: FunctionName;
|
|
21
|
-
}) => Context.Tag<FunctionImpl<GroupPath_, FunctionName>, FunctionImpl<GroupPath_, FunctionName>>;
|
|
22
|
-
declare const make: <Api_ extends AnyWithProps, Group extends GroupSpec.AnyWithProps, const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>>(api: Api_, group: Group, functionName: FunctionName, handler: WithName<Schema$1<Api_>, GroupSpec.Functions<Group>, FunctionName>) => Layer.Layer<FunctionImpl<string, FunctionName>>;
|
|
10
|
+
export declare const FunctionImpl: <FunctionName extends string>({ functionName, }: {
|
|
11
|
+
functionName: FunctionName;
|
|
12
|
+
}) => Context.Tag<FunctionImpl<FunctionName>, FunctionImpl<FunctionName>>;
|
|
23
13
|
/**
|
|
24
|
-
*
|
|
14
|
+
* Register a single function's implementation into the group's `Registry`.
|
|
15
|
+
*
|
|
16
|
+
* The function is registered under a flat, single-segment key (its own
|
|
17
|
+
* `functionName`), not a project-wide dot-path. Each group's impl layer is
|
|
18
|
+
* built in isolation — `RegisteredFunctions.buildForGroup` (and the CLI's
|
|
19
|
+
* `validateImpl`) provide a fresh `Registry` per group — so function names
|
|
20
|
+
* only need to be unique within their own group.
|
|
21
|
+
*
|
|
22
|
+
* `databaseSchema` is retained purely as a type-level carrier: the handler's
|
|
23
|
+
* ctx-service requirements (`DatabaseReader`, `QueryCtx<DataModel>`, …) are
|
|
24
|
+
* derived from it via `Handler.WithName`. It is not read at runtime — the
|
|
25
|
+
* generated per-group registry forwards the schema value to the function
|
|
26
|
+
* builders — so impls depend on `_generated/schema` (table schemas) rather than
|
|
27
|
+
* `_generated/api` (which transitively imports every function spec).
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
export declare const make: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps, Group extends GroupSpec.AnyWithProps, const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>>(_databaseSchema: DatabaseSchema_, group: Group, functionName: FunctionName, handler: Handler.WithName<DatabaseSchema_, GroupSpec.Functions<Group>, FunctionName>) => Layer.Layer<FunctionImpl<FunctionName>>;
|
|
27
30
|
/**
|
|
28
|
-
* Get
|
|
31
|
+
* Get the function implementation service type for a specific function name.
|
|
29
32
|
*/
|
|
30
|
-
type
|
|
33
|
+
export type ForFunction<FunctionName extends string> = FunctionImpl<FunctionName>;
|
|
31
34
|
/**
|
|
32
|
-
*
|
|
35
|
+
* Get all function implementation services required for a group spec.
|
|
33
36
|
*/
|
|
34
|
-
type
|
|
35
|
-
//#endregion
|
|
36
|
-
export { ForGroupPathAndFunction, FromGroupAtPath, FromGroupSpec, FunctionImpl, FunctionImpl_d_exports, make };
|
|
37
|
+
export type FromGroupSpec<Group extends GroupSpec.AnyWithProps> = FunctionSpec.Name<GroupSpec.Functions<Group>> extends infer FunctionNames extends string ? FunctionNames extends string ? FunctionImpl<FunctionNames> : never : never;
|
|
37
38
|
//# sourceMappingURL=FunctionImpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.d.ts","
|
|
1
|
+
{"version":3,"file":"FunctionImpl.d.ts","sourceRoot":"","sources":["../src/FunctionImpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,KAAK,OAAO,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,YAAY,CAAC,YAAY,SAAS,MAAM;IACvD,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;CACrC;AAED,eAAO,MAAM,YAAY,GAAI,YAAY,SAAS,MAAM,EAAE,mBAEvD;IACD,YAAY,EAAE,YAAY,CAAC;CAC5B,wEAGE,CAAC;AAEJ;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,IAAI,GACf,eAAe,SAAS,cAAc,CAAC,YAAY,EACnD,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,KAAK,CAAC,YAAY,SAAS,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAExE,iBAAiB,eAAe,EAChC,OAAO,KAAK,EACZ,cAAc,YAAY,EAC1B,SAAS,OAAO,CAAC,QAAQ,CACvB,eAAe,EACf,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAC1B,YAAY,CACb,KACA,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAsBxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,YAAY,SAAS,MAAM,IACjD,YAAY,CAAC,YAAY,CAAC,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,SAAS,CAAC,YAAY,IAC5D,YAAY,CAAC,IAAI,CACf,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAC3B,SAAS,MAAM,aAAa,SAAS,MAAM,GACxC,aAAa,SAAS,MAAM,GAC1B,YAAY,CAAC,aAAa,CAAC,GAC3B,KAAK,GACP,KAAK,CAAC"}
|
package/dist/FunctionImpl.js
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { resolveGroupPathUnsafe } from "./GroupPath.js";
|
|
3
2
|
import { setNestedProperty } from "./internal/utils.js";
|
|
4
3
|
import { make as make$1 } from "./RegistryItem.js";
|
|
5
|
-
import
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as Registry from "@confect/core/Registry";
|
|
8
|
+
import * as Ref from "effect/Ref";
|
|
7
9
|
|
|
8
10
|
//#region src/FunctionImpl.ts
|
|
9
11
|
var FunctionImpl_exports = /* @__PURE__ */ __exportAll({
|
|
10
12
|
FunctionImpl: () => FunctionImpl,
|
|
11
13
|
make: () => make
|
|
12
14
|
});
|
|
13
|
-
const FunctionImpl = ({
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const FunctionImpl = ({ functionName }) => Context.GenericTag(`@confect/server/FunctionImpl/${functionName}`);
|
|
16
|
+
/**
|
|
17
|
+
* Register a single function's implementation into the group's `Registry`.
|
|
18
|
+
*
|
|
19
|
+
* The function is registered under a flat, single-segment key (its own
|
|
20
|
+
* `functionName`), not a project-wide dot-path. Each group's impl layer is
|
|
21
|
+
* built in isolation — `RegisteredFunctions.buildForGroup` (and the CLI's
|
|
22
|
+
* `validateImpl`) provide a fresh `Registry` per group — so function names
|
|
23
|
+
* only need to be unique within their own group.
|
|
24
|
+
*
|
|
25
|
+
* `databaseSchema` is retained purely as a type-level carrier: the handler's
|
|
26
|
+
* ctx-service requirements (`DatabaseReader`, `QueryCtx<DataModel>`, …) are
|
|
27
|
+
* derived from it via `Handler.WithName`. It is not read at runtime — the
|
|
28
|
+
* generated per-group registry forwards the schema value to the function
|
|
29
|
+
* builders — so impls depend on `_generated/schema` (table schemas) rather than
|
|
30
|
+
* `_generated/api` (which transitively imports every function spec).
|
|
31
|
+
*/
|
|
32
|
+
const make = (_databaseSchema, group, functionName, handler) => {
|
|
16
33
|
const functionSpec = group.functions[functionName];
|
|
17
|
-
return Layer.effect(FunctionImpl({
|
|
18
|
-
groupPath,
|
|
19
|
-
functionName
|
|
20
|
-
}), Effect.gen(function* () {
|
|
34
|
+
return Layer.effect(FunctionImpl({ functionName }), Effect.gen(function* () {
|
|
21
35
|
const registry = yield* Registry.Registry;
|
|
22
|
-
yield* Ref.update(registry, (registryItems) => setNestedProperty(registryItems, [
|
|
36
|
+
yield* Ref.update(registry, (registryItems) => setNestedProperty(registryItems, [functionName], make$1({
|
|
23
37
|
functionSpec,
|
|
24
38
|
handler
|
|
25
39
|
})));
|
|
26
|
-
return {
|
|
27
|
-
groupPath,
|
|
28
|
-
functionName
|
|
29
|
-
};
|
|
40
|
+
return { functionName };
|
|
30
41
|
}));
|
|
31
42
|
};
|
|
32
43
|
|
package/dist/FunctionImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.js","names":["RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport
|
|
1
|
+
{"version":3,"file":"FunctionImpl.js","names":["RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<FunctionName extends string> {\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <FunctionName extends string>({\n functionName,\n}: {\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<FunctionName>>(\n `@confect/server/FunctionImpl/${functionName}`,\n );\n\n/**\n * Register a single function's implementation into the group's `Registry`.\n *\n * The function is registered under a flat, single-segment key (its own\n * `functionName`), not a project-wide dot-path. Each group's impl layer is\n * built in isolation — `RegisteredFunctions.buildForGroup` (and the CLI's\n * `validateImpl`) provide a fresh `Registry` per group — so function names\n * only need to be unique within their own group.\n *\n * `databaseSchema` is retained purely as a type-level carrier: the handler's\n * ctx-service requirements (`DatabaseReader`, `QueryCtx<DataModel>`, …) are\n * derived from it via `Handler.WithName`. It is not read at runtime — the\n * generated per-group registry forwards the schema value to the function\n * builders — so impls depend on `_generated/schema` (table schemas) rather than\n * `_generated/api` (which transitively imports every function spec).\n */\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>,\n>(\n _databaseSchema: DatabaseSchema_,\n group: Group,\n functionName: FunctionName,\n handler: Handler.WithName<\n DatabaseSchema_,\n GroupSpec.Functions<Group>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<FunctionName>> => {\n const functionSpec = group.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<FunctionName>({ functionName }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [functionName],\n RegistryItem.make({\n functionSpec,\n handler,\n }),\n ),\n );\n\n return { functionName };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific function name.\n */\nexport type ForFunction<FunctionName extends string> =\n FunctionImpl<FunctionName>;\n\n/**\n * Get all function implementation services required for a group spec.\n */\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionSpec.Name<\n GroupSpec.Functions<Group>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<FunctionNames>\n : never\n : never;\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,gBAA6C,EACxD,mBAIA,QAAQ,WACN,gCAAgC,eACjC;;;;;;;;;;;;;;;;;AAkBH,MAAa,QAKX,iBACA,OACA,cACA,YAK4C;CAC5C,MAAM,eAAe,MAAM,UAAU;AAErC,QAAO,MAAM,OACX,aAA2B,EAAE,cAAc,CAAC,EAC5C,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAO,SAAS;AAEjC,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,aAAa,EACdA,OAAkB;GAChB;GACA;GACD,CAAC,CACH,CACF;AAED,SAAO,EAAE,cAAc;GACvB,CACH"}
|
package/dist/GroupImpl.d.ts
CHANGED
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
5
|
+
import type * as FunctionImpl from "./FunctionImpl";
|
|
6
|
+
export declare const TypeId = "@confect/server/GroupImpl";
|
|
7
|
+
export type TypeId = typeof TypeId;
|
|
8
|
+
export type FinalizationStatus = "Unfinalized" | "Finalized";
|
|
9
|
+
export interface GroupImpl<FinalizationStatus_ extends FinalizationStatus = "Unfinalized"> {
|
|
10
|
+
readonly [TypeId]: TypeId;
|
|
11
|
+
readonly finalizationStatus: FinalizationStatus_;
|
|
12
|
+
/**
|
|
13
|
+
* Names of every function registered into this group's layer scope by
|
|
14
|
+
* `FunctionImpl.make`. Authoritative only when `finalizationStatus` is
|
|
15
|
+
* `"Finalized"`; the `"Unfinalized"` value is set to `[]` at `make`-time
|
|
16
|
+
* since the list is only known once `finalize` snapshots the registry.
|
|
17
|
+
*/
|
|
18
|
+
readonly registeredFunctionNames: ReadonlyArray<string>;
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
type TypeId = typeof TypeId;
|
|
12
|
-
type FinalizationStatus = "Unfinalized" | "Finalized";
|
|
13
|
-
interface GroupImpl<GroupPath_ extends string, FinalizationStatus_ extends FinalizationStatus = "Unfinalized"> {
|
|
14
|
-
readonly [TypeId]: TypeId;
|
|
15
|
-
readonly groupPath: GroupPath_;
|
|
16
|
-
readonly finalizationStatus: FinalizationStatus_;
|
|
17
|
-
/**
|
|
18
|
-
* Names of every function registered into this group's layer scope by
|
|
19
|
-
* `FunctionImpl.make`. Authoritative only when `finalizationStatus` is
|
|
20
|
-
* `"Finalized"`; the `"Unfinalized"` value is set to `[]` at `make`-time
|
|
21
|
-
* since the list is only known once `finalize` snapshots the registry.
|
|
22
|
-
*/
|
|
23
|
-
readonly registeredFunctionNames: ReadonlyArray<string>;
|
|
20
|
+
export interface Any extends GroupImpl<FinalizationStatus> {
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
interface AnyUnfinalized extends GroupImpl<
|
|
29
|
-
|
|
30
|
-
declare const
|
|
22
|
+
export declare const isGroupImpl: (u: unknown) => u is Any;
|
|
23
|
+
export interface AnyFinalized extends GroupImpl<"Finalized"> {
|
|
24
|
+
}
|
|
25
|
+
export interface AnyUnfinalized extends GroupImpl<"Unfinalized"> {
|
|
26
|
+
}
|
|
27
|
+
export declare const isFinalizedGroupImpl: (u: unknown) => u is AnyFinalized;
|
|
28
|
+
export declare const isUnfinalizedGroupImpl: (u: unknown) => u is AnyUnfinalized;
|
|
31
29
|
/**
|
|
32
30
|
* Build the runtime tag for a `GroupImpl` service. The finalization status is
|
|
33
31
|
* embedded in the tag string so that `Unfinalized` and `Finalized` are distinct
|
|
34
32
|
* services at runtime; consumers of a finalized layer (the server's
|
|
35
|
-
* `RegisteredFunctions.buildForGroup` and the CLI's `
|
|
33
|
+
* `RegisteredFunctions.buildForGroup` and the CLI's `validateImpl`) retrieve
|
|
36
34
|
* the typed `Finalized` service directly rather than scanning the context.
|
|
35
|
+
*
|
|
36
|
+
* The tag is keyed only by finalization status — no group path — because each
|
|
37
|
+
* group's impl layer is built in its own isolated scope (`buildForGroup` /
|
|
38
|
+
* `validateImpl` each provide a fresh `Registry`), so at most one `GroupImpl`
|
|
39
|
+
* service of each status exists per build.
|
|
40
|
+
*/
|
|
41
|
+
export declare const GroupImpl: <FinalizationStatus_ extends FinalizationStatus>({ finalizationStatus, }: {
|
|
42
|
+
finalizationStatus: FinalizationStatus_;
|
|
43
|
+
}) => Context.Tag<GroupImpl<FinalizationStatus_>, GroupImpl<FinalizationStatus_>>;
|
|
44
|
+
/**
|
|
45
|
+
* Begin a group's impl layer. `databaseSchema` and `group` are retained only as
|
|
46
|
+
* type-level carriers (`group` drives the required `FunctionImpl` services via
|
|
47
|
+
* `FromGroupSpec<Group>`; `databaseSchema` keeps the impl's dependency on
|
|
48
|
+
* `_generated/schema` symmetric with `FunctionImpl.make`). Neither is read at
|
|
49
|
+
* runtime.
|
|
37
50
|
*/
|
|
38
|
-
declare const
|
|
39
|
-
groupPath,
|
|
40
|
-
finalizationStatus
|
|
41
|
-
}: {
|
|
42
|
-
groupPath: GroupPath_;
|
|
43
|
-
finalizationStatus: FinalizationStatus_;
|
|
44
|
-
}) => Context.Tag<GroupImpl<GroupPath_, FinalizationStatus_>, GroupImpl<GroupPath_, FinalizationStatus_>>;
|
|
45
|
-
declare const make: <Api_ extends AnyWithProps, Group extends GroupSpec.AnyWithProps>(api: Api_, group: Group) => Layer.Layer<GroupImpl<string, "Unfinalized">, never, FromGroupSpec$1<Group>>;
|
|
51
|
+
export declare const make: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps, Group extends GroupSpec.AnyWithProps>(_databaseSchema: DatabaseSchema_, _group: Group) => Layer.Layer<GroupImpl<"Unfinalized">, never, FunctionImpl.FromGroupSpec<Group>>;
|
|
46
52
|
/**
|
|
47
53
|
* Mark a `GroupImpl` layer as fully implemented. The parameter type defaults
|
|
48
54
|
* `RIn = never`, so passing a layer that still requires any `FunctionImpl`
|
|
@@ -56,8 +62,6 @@ declare const make: <Api_ extends AnyWithProps, Group extends GroupSpec.AnyWithP
|
|
|
56
62
|
* impl completeness against a `GroupSpec`'s expected functions without
|
|
57
63
|
* having to inspect the `Registry` themselves.
|
|
58
64
|
*/
|
|
59
|
-
declare const finalize:
|
|
60
|
-
type FromGroupSpec<Group extends GroupSpec.AnyWithProps> = FromGroupSpec
|
|
61
|
-
//#endregion
|
|
62
|
-
export { Any, AnyFinalized, AnyUnfinalized, FinalizationStatus, FromGroupSpec, GroupImpl, GroupImpl_d_exports, TypeId, finalize, isFinalizedGroupImpl, isGroupImpl, isUnfinalizedGroupImpl, make };
|
|
65
|
+
export declare const finalize: (group: Layer.Layer<GroupImpl<"Unfinalized">>) => Layer.Layer<GroupImpl<"Finalized">>;
|
|
66
|
+
export type FromGroupSpec<Group extends GroupSpec.AnyWithProps> = FunctionImpl.FromGroupSpec<Group>;
|
|
63
67
|
//# sourceMappingURL=GroupImpl.d.ts.map
|
package/dist/GroupImpl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupImpl.d.ts","
|
|
1
|
+
{"version":3,"file":"GroupImpl.d.ts","sourceRoot":"","sources":["../src/GroupImpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAI1D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,MAAM,8BAA8B,CAAC;AAClD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,SAAS,CACxB,mBAAmB,SAAS,kBAAkB,GAAG,aAAa;IAE9D,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IACjD;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,GAAI,SAAQ,SAAS,CAAC,kBAAkB,CAAC;CAAG;AAE7D,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,GACZ,CAAC;AAEnC,MAAM,WAAW,YAAa,SAAQ,SAAS,CAAC,WAAW,CAAC;CAAG;AAC/D,MAAM,WAAW,cAAe,SAAQ,SAAS,CAAC,aAAa,CAAC;CAAG;AAEnE,eAAO,MAAM,oBAAoB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,YACC,CAAC;AAEzD,eAAO,MAAM,sBAAsB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,cACC,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,mBAAmB,SAAS,kBAAkB,EAAE,yBAEvE;IACD,kBAAkB,EAAE,mBAAmB,CAAC;CACzC,gFAGE,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GACf,eAAe,SAAS,cAAc,CAAC,YAAY,EACnD,KAAK,SAAS,SAAS,CAAC,YAAY,EAEpC,iBAAiB,eAAe,EAChC,QAAQ,KAAK,KACZ,KAAK,CAAC,KAAK,CACZ,SAAS,CAAC,aAAa,CAAC,EACxB,KAAK,EACL,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAahC,CAAC;AA0BJ;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,GACnB,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,KAC3C,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CA2BlC,CAAC;AAEJ,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,SAAS,CAAC,YAAY,IAC5D,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/GroupImpl.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import { pipe } from "effect/Function";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Array from "effect/Array";
|
|
8
|
+
import * as Predicate from "effect/Predicate";
|
|
9
|
+
import * as Record from "effect/Record";
|
|
4
10
|
import * as Registry from "@confect/core/Registry";
|
|
11
|
+
import * as Ref from "effect/Ref";
|
|
5
12
|
|
|
6
13
|
//#region src/GroupImpl.ts
|
|
7
14
|
var GroupImpl_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -21,28 +28,35 @@ const isUnfinalizedGroupImpl = (u) => isGroupImpl(u) && u.finalizationStatus ===
|
|
|
21
28
|
* Build the runtime tag for a `GroupImpl` service. The finalization status is
|
|
22
29
|
* embedded in the tag string so that `Unfinalized` and `Finalized` are distinct
|
|
23
30
|
* services at runtime; consumers of a finalized layer (the server's
|
|
24
|
-
* `RegisteredFunctions.buildForGroup` and the CLI's `
|
|
31
|
+
* `RegisteredFunctions.buildForGroup` and the CLI's `validateImpl`) retrieve
|
|
25
32
|
* the typed `Finalized` service directly rather than scanning the context.
|
|
33
|
+
*
|
|
34
|
+
* The tag is keyed only by finalization status — no group path — because each
|
|
35
|
+
* group's impl layer is built in its own isolated scope (`buildForGroup` /
|
|
36
|
+
* `validateImpl` each provide a fresh `Registry`), so at most one `GroupImpl`
|
|
37
|
+
* service of each status exists per build.
|
|
38
|
+
*/
|
|
39
|
+
const GroupImpl = ({ finalizationStatus }) => Context.GenericTag(`@confect/server/GroupImpl/${finalizationStatus}`);
|
|
40
|
+
/**
|
|
41
|
+
* Begin a group's impl layer. `databaseSchema` and `group` are retained only as
|
|
42
|
+
* type-level carriers (`group` drives the required `FunctionImpl` services via
|
|
43
|
+
* `FromGroupSpec<Group>`; `databaseSchema` keeps the impl's dependency on
|
|
44
|
+
* `_generated/schema` symmetric with `FunctionImpl.make`). Neither is read at
|
|
45
|
+
* runtime.
|
|
26
46
|
*/
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
finalizationStatus: "Unfinalized"
|
|
33
|
-
}), {
|
|
34
|
-
[TypeId]: TypeId,
|
|
35
|
-
groupPath,
|
|
36
|
-
finalizationStatus: "Unfinalized",
|
|
37
|
-
registeredFunctionNames: []
|
|
38
|
-
});
|
|
39
|
-
};
|
|
47
|
+
const make = (_databaseSchema, _group) => Layer.succeed(GroupImpl({ finalizationStatus: "Unfinalized" }), {
|
|
48
|
+
[TypeId]: TypeId,
|
|
49
|
+
finalizationStatus: "Unfinalized",
|
|
50
|
+
registeredFunctionNames: []
|
|
51
|
+
});
|
|
40
52
|
const isFunctionShaped = (value) => Predicate.isRecord(value) && "functionSpec" in value;
|
|
41
53
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
54
|
+
* Return the names of the function-shaped entries in a group's (flat,
|
|
55
|
+
* isolated) registry. `FunctionImpl.make` registers each function under a
|
|
56
|
+
* single-segment key, so the registry built for one group contains exactly
|
|
57
|
+
* that group's functions at the top level.
|
|
44
58
|
*/
|
|
45
|
-
const
|
|
59
|
+
const collectFunctionNames = (items) => pipe(Record.toEntries(items), Array.filterMap(([name, value]) => isFunctionShaped(value) ? Option.some(name) : Option.none()));
|
|
46
60
|
const findUnfinalizedGroupImpl = (context) => Array.findFirst(context.unsafeMap.values(), isUnfinalizedGroupImpl);
|
|
47
61
|
/**
|
|
48
62
|
* Mark a `GroupImpl` layer as fully implemented. The parameter type defaults
|
|
@@ -59,22 +73,15 @@ const findUnfinalizedGroupImpl = (context) => Array.findFirst(context.unsafeMap.
|
|
|
59
73
|
*/
|
|
60
74
|
const finalize = (group) => Layer.flatMap(group, (context) => findUnfinalizedGroupImpl(context).pipe(Option.match({
|
|
61
75
|
onNone: () => Layer.die(/* @__PURE__ */ new Error("GroupImpl.finalize: no Unfinalized GroupImpl service was found in the layer's context.")),
|
|
62
|
-
onSome: (
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
[TypeId]: TypeId,
|
|
72
|
-
groupPath,
|
|
73
|
-
finalizationStatus: "Finalized",
|
|
74
|
-
registeredFunctionNames: collectFunctionNamesAtPath(items, groupPath)
|
|
75
|
-
};
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
76
|
+
onSome: () => Layer.effect(GroupImpl({ finalizationStatus: "Finalized" }), Effect.gen(function* () {
|
|
77
|
+
const registry = yield* Registry.Registry;
|
|
78
|
+
const items = yield* Ref.get(registry);
|
|
79
|
+
return {
|
|
80
|
+
[TypeId]: TypeId,
|
|
81
|
+
finalizationStatus: "Finalized",
|
|
82
|
+
registeredFunctionNames: collectFunctionNames(items)
|
|
83
|
+
};
|
|
84
|
+
}))
|
|
78
85
|
})));
|
|
79
86
|
|
|
80
87
|
//#endregion
|
package/dist/GroupImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport {\
|
|
1
|
+
{"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Ref from \"effect/Ref\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\n\nexport const TypeId = \"@confect/server/GroupImpl\";\nexport type TypeId = typeof TypeId;\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface GroupImpl<\n FinalizationStatus_ extends FinalizationStatus = \"Unfinalized\",\n> {\n readonly [TypeId]: TypeId;\n readonly finalizationStatus: FinalizationStatus_;\n /**\n * Names of every function registered into this group's layer scope by\n * `FunctionImpl.make`. Authoritative only when `finalizationStatus` is\n * `\"Finalized\"`; the `\"Unfinalized\"` value is set to `[]` at `make`-time\n * since the list is only known once `finalize` snapshots the registry.\n */\n readonly registeredFunctionNames: ReadonlyArray<string>;\n}\n\nexport interface Any extends GroupImpl<FinalizationStatus> {}\n\nexport const isGroupImpl = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface AnyFinalized extends GroupImpl<\"Finalized\"> {}\nexport interface AnyUnfinalized extends GroupImpl<\"Unfinalized\"> {}\n\nexport const isFinalizedGroupImpl = (u: unknown): u is AnyFinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Finalized\";\n\nexport const isUnfinalizedGroupImpl = (u: unknown): u is AnyUnfinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Unfinalized\";\n\n/**\n * Build the runtime tag for a `GroupImpl` service. The finalization status is\n * embedded in the tag string so that `Unfinalized` and `Finalized` are distinct\n * services at runtime; consumers of a finalized layer (the server's\n * `RegisteredFunctions.buildForGroup` and the CLI's `validateImpl`) retrieve\n * the typed `Finalized` service directly rather than scanning the context.\n *\n * The tag is keyed only by finalization status — no group path — because each\n * group's impl layer is built in its own isolated scope (`buildForGroup` /\n * `validateImpl` each provide a fresh `Registry`), so at most one `GroupImpl`\n * service of each status exists per build.\n */\nexport const GroupImpl = <FinalizationStatus_ extends FinalizationStatus>({\n finalizationStatus,\n}: {\n finalizationStatus: FinalizationStatus_;\n}) =>\n Context.GenericTag<GroupImpl<FinalizationStatus_>>(\n `@confect/server/GroupImpl/${finalizationStatus}`,\n );\n\n/**\n * Begin a group's impl layer. `databaseSchema` and `group` are retained only as\n * type-level carriers (`group` drives the required `FunctionImpl` services via\n * `FromGroupSpec<Group>`; `databaseSchema` keeps the impl's dependency on\n * `_generated/schema` symmetric with `FunctionImpl.make`). Neither is read at\n * runtime.\n */\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n>(\n _databaseSchema: DatabaseSchema_,\n _group: Group,\n): Layer.Layer<\n GroupImpl<\"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n> =>\n Layer.succeed(\n GroupImpl<\"Unfinalized\">({ finalizationStatus: \"Unfinalized\" }),\n {\n [TypeId]: TypeId,\n finalizationStatus: \"Unfinalized\" as const,\n registeredFunctionNames: [],\n },\n ) as Layer.Layer<\n GroupImpl<\"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n >;\n\nconst isFunctionShaped = (value: unknown): boolean =>\n Predicate.isRecord(value) && \"functionSpec\" in value;\n\n/**\n * Return the names of the function-shaped entries in a group's (flat,\n * isolated) registry. `FunctionImpl.make` registers each function under a\n * single-segment key, so the registry built for one group contains exactly\n * that group's functions at the top level.\n */\nconst collectFunctionNames = (\n items: Registry.RegistryItems,\n): ReadonlyArray<string> =>\n pipe(\n Record.toEntries(items),\n Array.filterMap(([name, value]) =>\n isFunctionShaped(value) ? Option.some(name) : Option.none(),\n ),\n );\n\nconst findUnfinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<AnyUnfinalized> =>\n Array.findFirst(context.unsafeMap.values(), isUnfinalizedGroupImpl);\n\n/**\n * Mark a `GroupImpl` layer as fully implemented. The parameter type defaults\n * `RIn = never`, so passing a layer that still requires any `FunctionImpl`\n * service produces a type error at the impl author's site. The codegen\n * boundary requires the resulting `\"Finalized\"` brand, so omitting this call\n * is also rejected downstream.\n *\n * As a side effect of finalization, the names of every `FunctionImpl` that\n * registered into this group's scope are snapshotted onto the produced\n * service value's `registeredFunctionNames` field, so consumers can verify\n * impl completeness against a `GroupSpec`'s expected functions without\n * having to inspect the `Registry` themselves.\n */\nexport const finalize = (\n group: Layer.Layer<GroupImpl<\"Unfinalized\">>,\n): Layer.Layer<GroupImpl<\"Finalized\">> =>\n Layer.flatMap(\n group,\n (context): Layer.Layer<GroupImpl<\"Finalized\">> =>\n findUnfinalizedGroupImpl(context).pipe(\n Option.match({\n onNone: () =>\n Layer.die(\n new Error(\n \"GroupImpl.finalize: no Unfinalized GroupImpl service was found in the layer's context.\",\n ),\n ),\n onSome: () =>\n Layer.effect(\n GroupImpl<\"Finalized\">({ finalizationStatus: \"Finalized\" }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const items = yield* Ref.get(registry);\n return {\n [TypeId]: TypeId,\n finalizationStatus: \"Finalized\" as const,\n registeredFunctionNames: collectFunctionNames(items),\n };\n }),\n ),\n }),\n ),\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionImpl.FromGroupSpec<Group>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,SAAS;AAqBtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,OAAO;AAKlC,MAAa,wBAAwB,MACnC,YAAY,EAAE,IAAI,EAAE,uBAAuB;AAE7C,MAAa,0BAA0B,MACrC,YAAY,EAAE,IAAI,EAAE,uBAAuB;;;;;;;;;;;;;AAc7C,MAAa,aAA6D,EACxE,yBAIA,QAAQ,WACN,6BAA6B,qBAC9B;;;;;;;;AASH,MAAa,QAIX,iBACA,WAMA,MAAM,QACJ,UAAyB,EAAE,oBAAoB,eAAe,CAAC,EAC/D;EACG,SAAS;CACV,oBAAoB;CACpB,yBAAyB,EAAE;CAC5B,CACF;AAMH,MAAM,oBAAoB,UACxB,UAAU,SAAS,MAAM,IAAI,kBAAkB;;;;;;;AAQjD,MAAM,wBACJ,UAEA,KACE,OAAO,UAAU,MAAM,EACvB,MAAM,WAAW,CAAC,MAAM,WACtB,iBAAiB,MAAM,GAAG,OAAO,KAAK,KAAK,GAAG,OAAO,MAAM,CAC5D,CACF;AAEH,MAAM,4BACJ,YAEA,MAAM,UAAU,QAAQ,UAAU,QAAQ,EAAE,uBAAuB;;;;;;;;;;;;;;AAerE,MAAa,YACX,UAEA,MAAM,QACJ,QACC,YACC,yBAAyB,QAAQ,CAAC,KAChC,OAAO,MAAM;CACX,cACE,MAAM,oBACJ,IAAI,MACF,yFACD,CACF;CACH,cACE,MAAM,OACJ,UAAuB,EAAE,oBAAoB,aAAa,CAAC,EAC3D,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAO,SAAS;EACjC,MAAM,QAAQ,OAAO,IAAI,IAAI,SAAS;AACtC,SAAO;IACJ,SAAS;GACV,oBAAoB;GACpB,yBAAyB,qBAAqB,MAAM;GACrD;GACD,CACH;CACJ,CAAC,CACH,CACJ"}
|