@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.
Files changed (190) hide show
  1. package/CHANGELOG.md +299 -4
  2. package/dist/ActionCtx.d.ts +4 -11
  3. package/dist/ActionCtx.d.ts.map +1 -1
  4. package/dist/ActionCtx.js +1 -1
  5. package/dist/ActionCtx.js.map +1 -1
  6. package/dist/ActionRunner.d.ts +8 -13
  7. package/dist/ActionRunner.d.ts.map +1 -1
  8. package/dist/ActionRunner.js +4 -3
  9. package/dist/ActionRunner.js.map +1 -1
  10. package/dist/Auth.d.ts +17 -23
  11. package/dist/Auth.d.ts.map +1 -1
  12. package/dist/Auth.js +5 -1
  13. package/dist/Auth.js.map +1 -1
  14. package/dist/BlobNotFoundError.d.ts +6 -12
  15. package/dist/BlobNotFoundError.d.ts.map +1 -1
  16. package/dist/BlobNotFoundError.js +1 -1
  17. package/dist/BlobNotFoundError.js.map +1 -1
  18. package/dist/ConvexConfigProvider.d.ts +2 -9
  19. package/dist/ConvexConfigProvider.d.ts.map +1 -1
  20. package/dist/ConvexConfigProvider.js +6 -1
  21. package/dist/ConvexConfigProvider.js.map +1 -1
  22. package/dist/CronJob.d.ts +12 -19
  23. package/dist/CronJob.d.ts.map +1 -1
  24. package/dist/CronJob.js +1 -1
  25. package/dist/CronJob.js.map +1 -1
  26. package/dist/CronJobs.d.ts +11 -18
  27. package/dist/CronJobs.d.ts.map +1 -1
  28. package/dist/CronJobs.js +11 -4
  29. package/dist/CronJobs.js.map +1 -1
  30. package/dist/DataModel.d.ts +24 -29
  31. package/dist/DataModel.d.ts.map +1 -1
  32. package/dist/DatabaseReader.d.ts +4323 -64
  33. package/dist/DatabaseReader.d.ts.map +1 -1
  34. package/dist/DatabaseReader.js +6 -6
  35. package/dist/DatabaseReader.js.map +1 -1
  36. package/dist/DatabaseSchema.d.ts +38 -130
  37. package/dist/DatabaseSchema.d.ts.map +1 -1
  38. package/dist/DatabaseSchema.js +20 -30
  39. package/dist/DatabaseSchema.js.map +1 -1
  40. package/dist/DatabaseWriter.d.ts +38 -42
  41. package/dist/DatabaseWriter.d.ts.map +1 -1
  42. package/dist/DatabaseWriter.js +8 -5
  43. package/dist/DatabaseWriter.js.map +1 -1
  44. package/dist/Document.d.ts +28 -37
  45. package/dist/Document.d.ts.map +1 -1
  46. package/dist/Document.js +5 -1
  47. package/dist/Document.js.map +1 -1
  48. package/dist/FunctionImpl.d.ts +30 -29
  49. package/dist/FunctionImpl.d.ts.map +1 -1
  50. package/dist/FunctionImpl.js +25 -14
  51. package/dist/FunctionImpl.js.map +1 -1
  52. package/dist/GroupImpl.d.ts +45 -41
  53. package/dist/GroupImpl.d.ts.map +1 -1
  54. package/dist/GroupImpl.js +42 -35
  55. package/dist/GroupImpl.js.map +1 -1
  56. package/dist/Handler.d.ts +34 -40
  57. package/dist/Handler.d.ts.map +1 -1
  58. package/dist/HttpApi.d.ts +21 -25
  59. package/dist/HttpApi.d.ts.map +1 -1
  60. package/dist/HttpApi.js +11 -6
  61. package/dist/HttpApi.js.map +1 -1
  62. package/dist/MutationCtx.d.ts +4 -11
  63. package/dist/MutationCtx.d.ts.map +1 -1
  64. package/dist/MutationCtx.js +1 -1
  65. package/dist/MutationCtx.js.map +1 -1
  66. package/dist/MutationRunner.d.ts +8 -13
  67. package/dist/MutationRunner.d.ts.map +1 -1
  68. package/dist/MutationRunner.js +4 -3
  69. package/dist/MutationRunner.js.map +1 -1
  70. package/dist/OrderedQuery.d.ts +16 -21
  71. package/dist/OrderedQuery.d.ts.map +1 -1
  72. package/dist/OrderedQuery.js +4 -1
  73. package/dist/OrderedQuery.js.map +1 -1
  74. package/dist/QueryCtx.d.ts +4 -11
  75. package/dist/QueryCtx.d.ts.map +1 -1
  76. package/dist/QueryCtx.js +1 -1
  77. package/dist/QueryCtx.js.map +1 -1
  78. package/dist/QueryInitializer.d.ts +34 -39
  79. package/dist/QueryInitializer.d.ts.map +1 -1
  80. package/dist/QueryInitializer.js +5 -1
  81. package/dist/QueryInitializer.js.map +1 -1
  82. package/dist/QueryRunner.d.ts +8 -13
  83. package/dist/QueryRunner.d.ts.map +1 -1
  84. package/dist/QueryRunner.js +4 -3
  85. package/dist/QueryRunner.js.map +1 -1
  86. package/dist/RegisteredConvexFunction.d.ts +1107 -60
  87. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  88. package/dist/RegisteredConvexFunction.js +14 -9
  89. package/dist/RegisteredConvexFunction.js.map +1 -1
  90. package/dist/RegisteredFunction.d.ts +48 -64
  91. package/dist/RegisteredFunction.d.ts.map +1 -1
  92. package/dist/RegisteredFunction.js +9 -5
  93. package/dist/RegisteredFunction.js.map +1 -1
  94. package/dist/RegisteredFunctions.d.ts +48 -26
  95. package/dist/RegisteredFunctions.d.ts.map +1 -1
  96. package/dist/RegisteredFunctions.js +22 -9
  97. package/dist/RegisteredFunctions.js.map +1 -1
  98. package/dist/RegisteredNodeFunction.d.ts +4 -14
  99. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  100. package/dist/RegisteredNodeFunction.js +5 -4
  101. package/dist/RegisteredNodeFunction.js.map +1 -1
  102. package/dist/RegistryItem.d.ts +17 -27
  103. package/dist/RegistryItem.d.ts.map +1 -1
  104. package/dist/RegistryItem.js +1 -1
  105. package/dist/RegistryItem.js.map +1 -1
  106. package/dist/Scheduler.d.ts +16 -20
  107. package/dist/Scheduler.d.ts.map +1 -1
  108. package/dist/Scheduler.js +10 -6
  109. package/dist/Scheduler.js.map +1 -1
  110. package/dist/SchemaToValidator.d.ts +71 -64
  111. package/dist/SchemaToValidator.d.ts.map +1 -1
  112. package/dist/SchemaToValidator.js +15 -3
  113. package/dist/SchemaToValidator.js.map +1 -1
  114. package/dist/StorageActionWriter.d.ts +21 -28
  115. package/dist/StorageActionWriter.d.ts.map +1 -1
  116. package/dist/StorageActionWriter.js +4 -1
  117. package/dist/StorageActionWriter.js.map +1 -1
  118. package/dist/StorageReader.d.ts +14 -21
  119. package/dist/StorageReader.d.ts.map +1 -1
  120. package/dist/StorageReader.js +5 -1
  121. package/dist/StorageReader.js.map +1 -1
  122. package/dist/StorageWriter.d.ts +16 -23
  123. package/dist/StorageWriter.d.ts.map +1 -1
  124. package/dist/StorageWriter.js +4 -1
  125. package/dist/StorageWriter.js.map +1 -1
  126. package/dist/Table.d.ts +204 -197
  127. package/dist/Table.d.ts.map +1 -1
  128. package/dist/Table.js +72 -62
  129. package/dist/Table.js.map +1 -1
  130. package/dist/TableInfo.d.ts +35 -41
  131. package/dist/TableInfo.d.ts.map +1 -1
  132. package/dist/VectorSearch.d.ts +30 -35
  133. package/dist/VectorSearch.d.ts.map +1 -1
  134. package/dist/VectorSearch.js +3 -1
  135. package/dist/VectorSearch.js.map +1 -1
  136. package/dist/index.d.ts +35 -36
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +4 -5
  139. package/dist/internal/utils.d.ts +9 -11
  140. package/dist/internal/utils.d.ts.map +1 -1
  141. package/dist/internal/utils.js +3 -1
  142. package/dist/internal/utils.js.map +1 -1
  143. package/dist/node.d.ts +2 -2
  144. package/dist/node.d.ts.map +1 -0
  145. package/dist/tsconfig.src.tsbuildinfo +1 -0
  146. package/package.json +50 -59
  147. package/src/ActionCtx.ts +1 -1
  148. package/src/ActionRunner.ts +2 -1
  149. package/src/Auth.ts +5 -1
  150. package/src/BlobNotFoundError.ts +1 -1
  151. package/src/ConvexConfigProvider.ts +6 -8
  152. package/src/CronJob.ts +1 -1
  153. package/src/CronJobs.ts +8 -10
  154. package/src/DatabaseReader.ts +18 -21
  155. package/src/DatabaseSchema.ts +38 -98
  156. package/src/DatabaseWriter.ts +13 -6
  157. package/src/Document.ts +5 -1
  158. package/src/FunctionImpl.ts +36 -44
  159. package/src/GroupImpl.ts +54 -81
  160. package/src/HttpApi.ts +8 -9
  161. package/src/MutationCtx.ts +1 -1
  162. package/src/MutationRunner.ts +2 -1
  163. package/src/OrderedQuery.ts +5 -1
  164. package/src/QueryCtx.ts +1 -1
  165. package/src/QueryInitializer.ts +15 -3
  166. package/src/QueryRunner.ts +2 -1
  167. package/src/RegisteredConvexFunction.ts +11 -7
  168. package/src/RegisteredFunction.ts +5 -1
  169. package/src/RegisteredFunctions.ts +69 -93
  170. package/src/RegisteredNodeFunction.ts +7 -6
  171. package/src/RegistryItem.ts +1 -1
  172. package/src/Scheduler.ts +5 -1
  173. package/src/SchemaToValidator.ts +14 -16
  174. package/src/StorageActionWriter.ts +4 -1
  175. package/src/StorageReader.ts +5 -1
  176. package/src/StorageWriter.ts +4 -1
  177. package/src/Table.ts +253 -132
  178. package/src/VectorSearch.ts +3 -1
  179. package/src/index.ts +0 -1
  180. package/src/internal/utils.ts +3 -1
  181. package/dist/Api.d.ts +0 -30
  182. package/dist/Api.d.ts.map +0 -1
  183. package/dist/Api.js +0 -26
  184. package/dist/Api.js.map +0 -1
  185. package/dist/GroupPath.d.ts +0 -8
  186. package/dist/GroupPath.d.ts.map +0 -1
  187. package/dist/GroupPath.js +0 -10
  188. package/dist/GroupPath.js.map +0 -1
  189. package/src/Api.ts +0 -75
  190. package/src/GroupPath.ts +0 -43
@@ -1,47 +1,38 @@
1
- import { ReadonlyValue } from "./SchemaToValidator.js";
2
- import { TableSchema } from "./TableInfo.js";
3
- import { AnyWithProps, TableInfoWithName_, TableNames } from "./DataModel.js";
4
- import { Effect, Schema } from "effect";
5
- import { ReadonlyRecord } from "effect/Record";
6
-
7
- //#region src/Document.d.ts
8
- declare namespace Document_d_exports {
9
- export { Any, AnyEncoded, DocumentDecodeError, DocumentEncodeError, WithoutSystemFields, decode, documentErrorMessage, encode };
10
- }
11
- type WithoutSystemFields<Doc> = Omit<Doc, "_creationTime" | "_id">;
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
- readonly _tag: Schema.tag<"DocumentDecodeError">;
13
+ readonly _tag: Schema.tag<"DocumentDecodeError">;
18
14
  } & {
19
- tableName: typeof Schema.String;
20
- id: typeof Schema.String;
21
- parseError: typeof Schema.String;
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
- get message(): string;
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
- readonly _tag: Schema.tag<"DocumentEncodeError">;
23
+ readonly _tag: Schema.tag<"DocumentEncodeError">;
28
24
  } & {
29
- tableName: typeof Schema.String;
30
- id: typeof Schema.String;
31
- parseError: typeof Schema.String;
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
- get message(): string;
29
+ export declare class DocumentEncodeError extends DocumentEncodeError_base {
30
+ get message(): string;
35
31
  }
36
- declare const documentErrorMessage: ({
37
- id,
38
- tableName,
39
- message
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
- //#endregion
46
- export { Any, AnyEncoded, DocumentDecodeError, DocumentEncodeError, Document_d_exports, WithoutSystemFields, decode, documentErrorMessage, encode };
37
+ export {};
47
38
  //# sourceMappingURL=Document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Document.d.ts","names":[],"sources":["../src/Document.ts"],"mappings":";;;;;;;;;;KAOY,mBAAA,QAA2B,IAAA,CAAK,GAAA;AAAA,KAEhC,GAAA;AAAA,KACA,UAAA,GAAa,cAAA,SAAuB,aAAA;AAAA,cAiCnC,MAAA,uBAEU,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,SAAA,EAEvC,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,QAG3C,IAAA,EAAM,kBAAA,CAA6B,UAAA,EAAY,SAAA,wBAC5C,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,eACzC,mBAAA,0BAGmB,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,IAAA,EAE5C,kBAAA,CAA6B,UAAA,EAAY,SAAA,qBAA4B,SAAA,EAChE,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,OAExC,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,eACzC,mBAAA;AAAA,cAsDS,MAAA,uBAEU,YAAA,oBAC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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 { Effect, Function, ParseResult, Schema, pipe } from "effect";
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({
@@ -1 +1 @@
1
- {"version":3,"file":"Document.js","names":[],"sources":["../src/Document.ts"],"sourcesContent":["import * as SystemFields from \"@confect/core/SystemFields\";\nimport { Effect, Function, ParseResult, pipe, Schema } from \"effect\";\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 '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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"}
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"}
@@ -1,37 +1,38 @@
1
- import { AnyWithProps, Schema as Schema$1 } from "./Api.js";
2
- import { WithName } from "./Handler.js";
3
- import { Context, Layer } from "effect";
4
- import * as FunctionSpec from "@confect/core/FunctionSpec";
5
- import * as GroupSpec from "@confect/core/GroupSpec";
6
-
7
- //#region src/FunctionImpl.d.ts
8
- declare namespace FunctionImpl_d_exports {
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
- interface FunctionImpl<GroupPath_ extends string, FunctionName extends string> {
12
- readonly groupPath: GroupPath_;
13
- readonly functionName: FunctionName;
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
- * Get the function implementation service type for a specific group path and function name.
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
- type ForGroupPathAndFunction<GroupPath_ extends string, FunctionName extends string> = FunctionImpl<GroupPath_, FunctionName>;
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 all function implementation services required for a group spec.
31
+ * Get the function implementation service type for a specific function name.
29
32
  */
30
- type FromGroupSpec<Group extends GroupSpec.AnyWithProps> = FunctionSpec.Name<GroupSpec.Functions<Group>> extends infer FunctionNames extends string ? FunctionNames extends string ? FunctionImpl<string, FunctionNames> : never : never;
33
+ export type ForFunction<FunctionName extends string> = FunctionImpl<FunctionName>;
31
34
  /**
32
- * @deprecated Use {@link FromGroupSpec} instead.
35
+ * Get all function implementation services required for a group spec.
33
36
  */
34
- type FromGroupAtPath<_GroupPath extends string, Group extends GroupSpec.AnyWithProps> = FromGroupSpec<Group>;
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","names":[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ACxD,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"}
@@ -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 { Context, Effect, Layer, Ref, String } from "effect";
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 = ({ groupPath, functionName }) => Context.GenericTag(`@confect/server/FunctionImpl/${groupPath}/${functionName}`);
14
- const make = (api, group, functionName, handler) => {
15
- const groupPath = resolveGroupPathUnsafe(api.spec, group);
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, [...String.split(groupPath, "."), functionName], make$1({
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
 
@@ -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 { Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport { resolveGroupPathUnsafe } from \"./GroupPath\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>,\n>(\n api: Api_,\n group: Group,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<Group>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<string, FunctionName>> => {\n const groupPath = resolveGroupPathUnsafe(api.spec, group);\n const functionSpec = group.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<string, FunctionName>({\n groupPath,\n functionName,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [...String.split(groupPath, \".\"), functionName],\n RegistryItem.make({\n functionSpec,\n handler,\n }),\n ),\n );\n\n return {\n groupPath,\n functionName,\n };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific group path and function name.\n */\nexport type ForGroupPathAndFunction<\n GroupPath_ extends string,\n FunctionName extends string,\n> = FunctionImpl<GroupPath_, 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<string, FunctionNames>\n : never\n : never;\n\n/**\n * @deprecated Use {@link FromGroupSpec} instead.\n */\nexport type FromGroupAtPath<\n _GroupPath extends string,\n Group extends GroupSpec.AnyWithProps,\n> = FromGroupSpec<Group>;\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAKX,KACA,OACA,cACA,YAKoD;CACpD,MAAM,YAAY,uBAAuB,IAAI,MAAM,MAAM;CACzD,MAAM,eAAe,MAAM,UAAU;AAErC,QAAO,MAAM,OACX,aAAmC;EACjC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAO,SAAS;AAEjC,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,OAAO,MAAM,WAAW,IAAI,EAAE,aAAa,EAC/CA,OAAkB;GAChB;GACA;GACD,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
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"}
@@ -1,48 +1,54 @@
1
- import { AnyWithProps } from "./Api.js";
2
- import { FromGroupSpec as FromGroupSpec$1 } from "./FunctionImpl.js";
3
- import { Context, Layer } from "effect";
4
- import * as GroupSpec from "@confect/core/GroupSpec";
5
-
6
- //#region src/GroupImpl.d.ts
7
- declare namespace GroupImpl_d_exports {
8
- export { Any, AnyFinalized, AnyUnfinalized, FinalizationStatus, FromGroupSpec, GroupImpl, TypeId, finalize, isFinalizedGroupImpl, isGroupImpl, isUnfinalizedGroupImpl, make };
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
- declare const TypeId = "@confect/server/GroupImpl";
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
- interface Any extends GroupImpl<string, FinalizationStatus> {}
26
- declare const isGroupImpl: (u: unknown) => u is Any;
27
- interface AnyFinalized extends GroupImpl<string, "Finalized"> {}
28
- interface AnyUnfinalized extends GroupImpl<string, "Unfinalized"> {}
29
- declare const isFinalizedGroupImpl: (u: unknown) => u is AnyFinalized;
30
- declare const isUnfinalizedGroupImpl: (u: unknown) => u is AnyUnfinalized;
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 `implValidation`) retrieve
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 GroupImpl: <GroupPath_ extends string, FinalizationStatus_ extends FinalizationStatus>({
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: <GroupPath_ extends string>(group: Layer.Layer<GroupImpl<GroupPath_, "Unfinalized">>) => Layer.Layer<GroupImpl<GroupPath_, "Finalized">>;
60
- type FromGroupSpec<Group extends GroupSpec.AnyWithProps> = FromGroupSpec$1<Group>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"mappings":";;;;;;;;;cAkBa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,KAEhB,kBAAA;AAAA,UAEK,SAAA,wDAEa,kBAAA;EAAA,UAElB,MAAA,GAAS,MAAA;EAAA,SACV,SAAA,EAAW,UAAA;EAAA,SACX,kBAAA,EAAoB,mBAAA;;;;;;;WAOpB,uBAAA,EAAyB,aAAA;AAAA;AAAA,UAGnB,GAAA,SAAY,SAAA,SAAkB,kBAAA;AAAA,cAElC,WAAA,GAAe,CAAA,cAAa,CAAA,IAAK,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,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 { resolveGroupPathUnsafe } from "./GroupPath.js";
3
- import { Array, Context, Effect, Layer, Option, Predicate, Record, Ref, String, pipe } from "effect";
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 `implValidation`) retrieve
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 GroupImpl = ({ groupPath, finalizationStatus }) => Context.GenericTag(`@confect/server/GroupImpl/${finalizationStatus}/${groupPath}`);
28
- const make = (api, group) => {
29
- const groupPath = resolveGroupPathUnsafe(api.spec, group);
30
- return Layer.succeed(GroupImpl({
31
- groupPath,
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
- * Walk a `RegistryItems` tree to the entries at `groupPath` and return the
43
- * names of the function-shaped leaves directly underneath.
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 collectFunctionNamesAtPath = (items, groupPath) => pipe(String.split(groupPath, "."), Array.reduce(Option.some(items), (acc, segment) => acc.pipe(Option.filter(Predicate.isRecord), Option.flatMap((node) => segment in node ? Option.some(node[segment]) : Option.none()))), Option.filter(Predicate.isRecord), Option.map(Record.toEntries), Option.map(Array.filterMap(([name, value]) => isFunctionShaped(value) ? Option.some(name) : Option.none())), Option.getOrElse(() => []));
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: (unfinalized) => {
63
- const groupPath = unfinalized.groupPath;
64
- return Layer.effect(GroupImpl({
65
- groupPath,
66
- finalizationStatus: "Finalized"
67
- }), Effect.gen(function* () {
68
- const registry = yield* Registry.Registry;
69
- const items = yield* Ref.get(registry);
70
- return {
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
@@ -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 {\n Array,\n Context,\n Effect,\n Layer,\n Option,\n pipe,\n Predicate,\n Record,\n Ref,\n String,\n} from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\nimport { resolveGroupPathUnsafe } from \"./GroupPath\";\n\nexport const TypeId = \"@confect/server/GroupImpl\";\nexport type TypeId = typeof TypeId;\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface GroupImpl<\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus = \"Unfinalized\",\n> {\n readonly [TypeId]: TypeId;\n readonly groupPath: GroupPath_;\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<string, FinalizationStatus> {}\n\nexport const isGroupImpl = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface AnyFinalized extends GroupImpl<string, \"Finalized\"> {}\nexport interface AnyUnfinalized extends GroupImpl<string, \"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 `implValidation`) retrieve\n * the typed `Finalized` service directly rather than scanning the context.\n */\nexport const GroupImpl = <\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus,\n>({\n groupPath,\n finalizationStatus,\n}: {\n groupPath: GroupPath_;\n finalizationStatus: FinalizationStatus_;\n}) =>\n Context.GenericTag<GroupImpl<GroupPath_, FinalizationStatus_>>(\n `@confect/server/GroupImpl/${finalizationStatus}/${groupPath}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n>(\n api: Api_,\n group: Group,\n): Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n> => {\n const groupPath = resolveGroupPathUnsafe(api.spec, group);\n\n return Layer.succeed(\n GroupImpl<string, \"Unfinalized\">({\n groupPath,\n finalizationStatus: \"Unfinalized\",\n }),\n {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Unfinalized\" as const,\n registeredFunctionNames: [],\n },\n ) as Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n >;\n};\n\nconst isFunctionShaped = (value: unknown): boolean =>\n Predicate.isRecord(value) && \"functionSpec\" in value;\n\n/**\n * Walk a `RegistryItems` tree to the entries at `groupPath` and return the\n * names of the function-shaped leaves directly underneath.\n */\nconst collectFunctionNamesAtPath = (\n items: Registry.RegistryItems,\n groupPath: string,\n): ReadonlyArray<string> =>\n pipe(\n String.split(groupPath, \".\"),\n Array.reduce(Option.some<unknown>(items), (acc, segment) =>\n acc.pipe(\n Option.filter(Predicate.isRecord),\n Option.flatMap((node) =>\n segment in node ? Option.some(node[segment]) : Option.none(),\n ),\n ),\n ),\n Option.filter(Predicate.isRecord),\n Option.map(Record.toEntries),\n Option.map(\n Array.filterMap(([name, value]) =>\n isFunctionShaped(value) ? Option.some(name) : Option.none(),\n ),\n ),\n Option.getOrElse((): ReadonlyArray<string> => []),\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 = <GroupPath_ extends string>(\n group: Layer.Layer<GroupImpl<GroupPath_, \"Unfinalized\">>,\n): Layer.Layer<GroupImpl<GroupPath_, \"Finalized\">> =>\n Layer.flatMap(\n group,\n (context): Layer.Layer<GroupImpl<GroupPath_, \"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: (unfinalized) => {\n const groupPath = unfinalized.groupPath as GroupPath_;\n return Layer.effect(\n GroupImpl<GroupPath_, \"Finalized\">({\n groupPath,\n finalizationStatus: \"Finalized\",\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const items = yield* Ref.get(registry);\n return {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Finalized\" as const,\n registeredFunctionNames: collectFunctionNamesAtPath(\n items,\n groupPath,\n ),\n };\n }),\n );\n },\n }),\n ),\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionImpl.FromGroupSpec<Group>;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,SAAS;AAuBtB,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;;;;;;;;AAS7C,MAAa,aAGX,EACA,WACA,yBAKA,QAAQ,WACN,6BAA6B,mBAAmB,GAAG,YACpD;AAEH,MAAa,QAIX,KACA,UAKG;CACH,MAAM,YAAY,uBAAuB,IAAI,MAAM,MAAM;AAEzD,QAAO,MAAM,QACX,UAAiC;EAC/B;EACA,oBAAoB;EACrB,CAAC,EACF;GACG,SAAS;EACV;EACA,oBAAoB;EACpB,yBAAyB,EAAE;EAC5B,CACF;;AAOH,MAAM,oBAAoB,UACxB,UAAU,SAAS,MAAM,IAAI,kBAAkB;;;;;AAMjD,MAAM,8BACJ,OACA,cAEA,KACE,OAAO,MAAM,WAAW,IAAI,EAC5B,MAAM,OAAO,OAAO,KAAc,MAAM,GAAG,KAAK,YAC9C,IAAI,KACF,OAAO,OAAO,UAAU,SAAS,EACjC,OAAO,SAAS,SACd,WAAW,OAAO,OAAO,KAAK,KAAK,SAAS,GAAG,OAAO,MAAM,CAC7D,CACF,CACF,EACD,OAAO,OAAO,UAAU,SAAS,EACjC,OAAO,IAAI,OAAO,UAAU,EAC5B,OAAO,IACL,MAAM,WAAW,CAAC,MAAM,WACtB,iBAAiB,MAAM,GAAG,OAAO,KAAK,KAAK,GAAG,OAAO,MAAM,CAC5D,CACF,EACD,OAAO,gBAAuC,EAAE,CAAC,CAClD;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,SAAS,gBAAgB;EACvB,MAAM,YAAY,YAAY;AAC9B,SAAO,MAAM,OACX,UAAmC;GACjC;GACA,oBAAoB;GACrB,CAAC,EACF,OAAO,IAAI,aAAa;GACtB,MAAM,WAAW,OAAO,SAAS;GACjC,MAAM,QAAQ,OAAO,IAAI,IAAI,SAAS;AACtC,UAAO;KACJ,SAAS;IACV;IACA,oBAAoB;IACpB,yBAAyB,2BACvB,OACA,UACD;IACF;IACD,CACH;;CAEJ,CAAC,CACH,CACJ"}
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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