@confect/server 1.0.0-next.0

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 (157) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +7 -0
  3. package/dist/ActionCtx.d.ts +12 -0
  4. package/dist/ActionCtx.d.ts.map +1 -0
  5. package/dist/ActionCtx.js +10 -0
  6. package/dist/ActionCtx.js.map +1 -0
  7. package/dist/ActionRunner.d.ts +15 -0
  8. package/dist/ActionRunner.d.ts.map +1 -0
  9. package/dist/ActionRunner.js +23 -0
  10. package/dist/ActionRunner.js.map +1 -0
  11. package/dist/Api.d.ts +27 -0
  12. package/dist/Api.d.ts.map +1 -0
  13. package/dist/Api.js +26 -0
  14. package/dist/Api.js.map +1 -0
  15. package/dist/Auth.d.ts +30 -0
  16. package/dist/Auth.d.ts.map +1 -0
  17. package/dist/Auth.js +24 -0
  18. package/dist/Auth.js.map +1 -0
  19. package/dist/DataModel.d.ts +33 -0
  20. package/dist/DataModel.d.ts.map +1 -0
  21. package/dist/DataModel.js +6 -0
  22. package/dist/DataModel.js.map +1 -0
  23. package/dist/DatabaseReader.d.ts +73 -0
  24. package/dist/DatabaseReader.d.ts.map +1 -0
  25. package/dist/DatabaseReader.js +32 -0
  26. package/dist/DatabaseReader.js.map +1 -0
  27. package/dist/DatabaseSchema.d.ts +139 -0
  28. package/dist/DatabaseSchema.d.ts.map +1 -0
  29. package/dist/DatabaseSchema.js +45 -0
  30. package/dist/DatabaseSchema.js.map +1 -0
  31. package/dist/DatabaseWriter.d.ts +39 -0
  32. package/dist/DatabaseWriter.d.ts.map +1 -0
  33. package/dist/DatabaseWriter.js +43 -0
  34. package/dist/DatabaseWriter.js.map +1 -0
  35. package/dist/Document.d.ts +47 -0
  36. package/dist/Document.d.ts.map +1 -0
  37. package/dist/Document.js +66 -0
  38. package/dist/Document.js.map +1 -0
  39. package/dist/FunctionImpl.d.ts +34 -0
  40. package/dist/FunctionImpl.d.ts.map +1 -0
  41. package/dist/FunctionImpl.js +35 -0
  42. package/dist/FunctionImpl.js.map +1 -0
  43. package/dist/GroupImpl.d.ts +24 -0
  44. package/dist/GroupImpl.d.ts.map +1 -0
  45. package/dist/GroupImpl.js +14 -0
  46. package/dist/GroupImpl.js.map +1 -0
  47. package/dist/Handler.d.ts +31 -0
  48. package/dist/Handler.d.ts.map +1 -0
  49. package/dist/Handler.js +6 -0
  50. package/dist/Handler.js.map +1 -0
  51. package/dist/HttpApi.d.ts +26 -0
  52. package/dist/HttpApi.d.ts.map +1 -0
  53. package/dist/HttpApi.js +74 -0
  54. package/dist/HttpApi.js.map +1 -0
  55. package/dist/Impl.d.ts +24 -0
  56. package/dist/Impl.d.ts.map +1 -0
  57. package/dist/Impl.js +28 -0
  58. package/dist/Impl.js.map +1 -0
  59. package/dist/MutationCtx.d.ts +12 -0
  60. package/dist/MutationCtx.d.ts.map +1 -0
  61. package/dist/MutationCtx.js +10 -0
  62. package/dist/MutationCtx.js.map +1 -0
  63. package/dist/MutationRunner.d.ts +24 -0
  64. package/dist/MutationRunner.d.ts.map +1 -0
  65. package/dist/MutationRunner.js +33 -0
  66. package/dist/MutationRunner.js.map +1 -0
  67. package/dist/OrderedQuery.d.ts +23 -0
  68. package/dist/OrderedQuery.d.ts.map +1 -0
  69. package/dist/OrderedQuery.js +34 -0
  70. package/dist/OrderedQuery.js.map +1 -0
  71. package/dist/QueryCtx.d.ts +12 -0
  72. package/dist/QueryCtx.d.ts.map +1 -0
  73. package/dist/QueryCtx.js +10 -0
  74. package/dist/QueryCtx.js.map +1 -0
  75. package/dist/QueryInitializer.d.ts +49 -0
  76. package/dist/QueryInitializer.d.ts.map +1 -0
  77. package/dist/QueryInitializer.js +83 -0
  78. package/dist/QueryInitializer.js.map +1 -0
  79. package/dist/QueryRunner.d.ts +14 -0
  80. package/dist/QueryRunner.d.ts.map +1 -0
  81. package/dist/QueryRunner.js +23 -0
  82. package/dist/QueryRunner.js.map +1 -0
  83. package/dist/RegisteredFunctions.d.ts +66 -0
  84. package/dist/RegisteredFunctions.d.ts.map +1 -0
  85. package/dist/RegisteredFunctions.js +71 -0
  86. package/dist/RegisteredFunctions.js.map +1 -0
  87. package/dist/Registry.d.ts +15 -0
  88. package/dist/Registry.d.ts.map +1 -0
  89. package/dist/Registry.js +10 -0
  90. package/dist/Registry.js.map +1 -0
  91. package/dist/RegistryItem.d.ts +31 -0
  92. package/dist/RegistryItem.d.ts.map +1 -0
  93. package/dist/RegistryItem.js +20 -0
  94. package/dist/RegistryItem.js.map +1 -0
  95. package/dist/Scheduler.d.ts +23 -0
  96. package/dist/Scheduler.d.ts.map +1 -0
  97. package/dist/Scheduler.js +24 -0
  98. package/dist/Scheduler.js.map +1 -0
  99. package/dist/SchemaToValidator.d.ts +88 -0
  100. package/dist/SchemaToValidator.d.ts.map +1 -0
  101. package/dist/SchemaToValidator.js +155 -0
  102. package/dist/SchemaToValidator.js.map +1 -0
  103. package/dist/Storage.d.ts +69 -0
  104. package/dist/Storage.d.ts.map +1 -0
  105. package/dist/Storage.js +46 -0
  106. package/dist/Storage.js.map +1 -0
  107. package/dist/Table.d.ts +247 -0
  108. package/dist/Table.d.ts.map +1 -0
  109. package/dist/Table.js +97 -0
  110. package/dist/Table.js.map +1 -0
  111. package/dist/TableInfo.d.ts +48 -0
  112. package/dist/TableInfo.d.ts.map +1 -0
  113. package/dist/TableInfo.js +6 -0
  114. package/dist/TableInfo.js.map +1 -0
  115. package/dist/VectorSearch.d.ts +42 -0
  116. package/dist/VectorSearch.d.ts.map +1 -0
  117. package/dist/VectorSearch.js +16 -0
  118. package/dist/VectorSearch.js.map +1 -0
  119. package/dist/_virtual/rolldown_runtime.js +13 -0
  120. package/dist/index.d.ts +30 -0
  121. package/dist/index.js +31 -0
  122. package/dist/internal/utils.d.ts +15 -0
  123. package/dist/internal/utils.d.ts.map +1 -0
  124. package/dist/internal/utils.js +49 -0
  125. package/dist/internal/utils.js.map +1 -0
  126. package/package.json +90 -0
  127. package/src/ActionCtx.ts +9 -0
  128. package/src/ActionRunner.ts +28 -0
  129. package/src/Api.ts +63 -0
  130. package/src/Auth.ts +31 -0
  131. package/src/DataModel.ts +69 -0
  132. package/src/DatabaseReader.ts +75 -0
  133. package/src/DatabaseSchema.ts +134 -0
  134. package/src/DatabaseWriter.ts +166 -0
  135. package/src/Document.ts +200 -0
  136. package/src/FunctionImpl.ts +112 -0
  137. package/src/GroupImpl.ts +60 -0
  138. package/src/Handler.ts +105 -0
  139. package/src/HttpApi.ts +232 -0
  140. package/src/Impl.ts +57 -0
  141. package/src/MutationCtx.ts +11 -0
  142. package/src/MutationRunner.ts +41 -0
  143. package/src/OrderedQuery.ts +109 -0
  144. package/src/QueryCtx.ts +9 -0
  145. package/src/QueryInitializer.ts +308 -0
  146. package/src/QueryRunner.ts +29 -0
  147. package/src/RegisteredFunctions.ts +381 -0
  148. package/src/Registry.ts +13 -0
  149. package/src/RegistryItem.ts +44 -0
  150. package/src/Scheduler.ts +39 -0
  151. package/src/SchemaToValidator.ts +619 -0
  152. package/src/Storage.ts +86 -0
  153. package/src/Table.ts +439 -0
  154. package/src/TableInfo.ts +91 -0
  155. package/src/VectorSearch.ts +46 -0
  156. package/src/index.ts +29 -0
  157. package/src/internal/utils.ts +87 -0
@@ -0,0 +1,45 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
+ import { scheduledFunctionsTable, storageTable, systemTables } from "./Table.js";
3
+ import { Array, Predicate, Record, pipe } from "effect";
4
+ import { defineSchema } from "convex/server";
5
+
6
+ //#region src/DatabaseSchema.ts
7
+ var DatabaseSchema_exports = /* @__PURE__ */ __export({
8
+ TypeId: () => TypeId,
9
+ extendWithSystemTables: () => extendWithSystemTables,
10
+ isSchema: () => isSchema,
11
+ make: () => make,
12
+ systemSchema: () => systemSchema
13
+ });
14
+ const TypeId = "@confect/server/DatabaseSchema";
15
+ const isSchema = (u) => Predicate.hasProperty(u, TypeId);
16
+ const Proto = {
17
+ [TypeId]: TypeId,
18
+ addTable(table) {
19
+ const newTablesArray = [...Object.values(this.tables), table];
20
+ return makeProto({
21
+ tables: Record.set(this.tables, table.name, table),
22
+ convexSchemaDefinition: pipe(newTablesArray, Array.map(({ name, tableDefinition }) => [name, tableDefinition]), Record.fromEntries, defineSchema)
23
+ });
24
+ }
25
+ };
26
+ const makeProto = ({ tables, convexSchemaDefinition }) => Object.assign(Object.create(Proto), {
27
+ tables,
28
+ convexSchemaDefinition
29
+ });
30
+ /**
31
+ * Create an empty schema definition. Add tables incrementally via `addTable`.
32
+ */
33
+ const make = () => makeProto({
34
+ tables: Record.empty(),
35
+ convexSchemaDefinition: defineSchema({})
36
+ });
37
+ const systemSchema = make().addTable(scheduledFunctionsTable).addTable(storageTable);
38
+ const extendWithSystemTables = (tables) => ({
39
+ ...tables,
40
+ ...systemTables
41
+ });
42
+
43
+ //#endregion
44
+ export { DatabaseSchema_exports, TypeId, extendWithSystemTables, isSchema, make, systemSchema };
45
+ //# sourceMappingURL=DatabaseSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseSchema.js","names":["defineConvexSchema","Table.scheduledFunctionsTable","Table.storageTable","Table.systemTables"],"sources":["../src/DatabaseSchema.ts"],"sourcesContent":["import type { Expand, GenericSchema } from \"convex/server\";\nimport {\n defineSchema as defineConvexSchema,\n type SchemaDefinition,\n} from \"convex/server\";\nimport { Array, pipe, Predicate, Record } from \"effect\";\nimport * as Table from \"./Table\";\n\nexport const TypeId = \"@confect/server/DatabaseSchema\";\nexport type TypeId = typeof TypeId;\n\nexport const isSchema = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A schema definition tracks the schema and its Convex schema definition.\n */\nexport interface DatabaseSchema<Tables_ extends Table.AnyWithProps = never> {\n readonly [TypeId]: TypeId;\n readonly tables: Table.TablesRecord<Tables_>;\n readonly convexSchemaDefinition: SchemaDefinition<\n ConvexDatabaseSchemaFromTables<Tables_>,\n true\n >;\n\n /**\n * Add a table definition to the schema.\n */\n addTable<TableDef extends Table.AnyWithProps>(\n table: TableDef,\n ): DatabaseSchema<Tables_ | TableDef>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps {\n readonly [TypeId]: TypeId;\n readonly tables: Record<string, Table.AnyWithProps>;\n readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n addTable<TableDef extends Table.AnyWithProps>(table: TableDef): AnyWithProps;\n}\n\nexport type Tables<DatabaseSchema_ extends AnyWithProps> =\n DatabaseSchema_ extends DatabaseSchema<infer Tables_> ? Tables_ : never;\n\nexport type TableNames<DatabaseSchema_ extends AnyWithProps> = Table.Name<\n Tables<DatabaseSchema_>\n> &\n string;\n\nexport type TableWithName<\n DatabaseSchema_ extends AnyWithProps,\n TableName extends TableNames<DatabaseSchema_>,\n> = Extract<Tables<DatabaseSchema_>, { readonly name: TableName }>;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n addTable<TableDef extends Table.AnyWithProps>(\n this: DatabaseSchema<Table.AnyWithProps>,\n table: TableDef,\n ) {\n const tablesArray = Object.values(this.tables) as Table.AnyWithProps[];\n const newTablesArray = [...tablesArray, table];\n\n return makeProto({\n tables: Record.set(this.tables, table.name, table),\n convexSchemaDefinition: pipe(\n newTablesArray,\n Array.map(\n ({ name, tableDefinition }) => [name, tableDefinition] as const,\n ),\n Record.fromEntries,\n defineConvexSchema,\n ),\n });\n },\n};\n\nconst makeProto = <Tables_ extends Table.AnyWithProps>({\n tables,\n convexSchemaDefinition,\n}: {\n tables: Record.ReadonlyRecord<string, Tables_>;\n convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n}): DatabaseSchema<Tables_> =>\n Object.assign(Object.create(Proto), {\n tables,\n convexSchemaDefinition,\n });\n\n/**\n * Create an empty schema definition. Add tables incrementally via `addTable`.\n */\nexport const make = (): DatabaseSchema<never> =>\n makeProto({\n tables: Record.empty(),\n convexSchemaDefinition: defineConvexSchema({}),\n });\n\nexport type ConvexDatabaseSchemaFromTables<Tables_ extends Table.AnyWithProps> =\n Expand<{\n [TableName in Table.Name<Tables_> & string]: Table.WithName<\n Tables_,\n TableName\n >[\"tableDefinition\"];\n }>;\n\n// System tables\n\nexport const systemSchema = make()\n .addTable(Table.scheduledFunctionsTable)\n .addTable(Table.storageTable);\n\nexport const extendWithSystemTables = <Tables_ extends Table.AnyWithProps>(\n tables: Table.TablesRecord<Tables_>,\n): ExtendWithSystemTables<Tables_> =>\n ({\n ...tables,\n ...Table.systemTables,\n }) as ExtendWithSystemTables<Tables_>;\n\nexport type ExtendWithSystemTables<Tables_ extends Table.AnyWithProps> =\n Table.TablesRecord<Tables_ | Table.SystemTables>;\n\nexport type IncludeSystemTables<Tables_ extends Table.AnyWithProps> =\n | Tables_\n | Table.SystemTables extends infer T\n ? T extends Table.AnyWithProps\n ? T\n : never\n : never;\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAa,SAAS;AAGtB,MAAa,YAAY,MACvB,UAAU,YAAY,GAAG,OAAO;AA6ClC,MAAM,QAAQ;EACX,SAAS;CAEV,SAEE,OACA;EAEA,MAAM,iBAAiB,CAAC,GADJ,OAAO,OAAO,KAAK,OAAO,EACN,MAAM;AAE9C,SAAO,UAAU;GACf,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAM,MAAM,MAAM;GAClD,wBAAwB,KACtB,gBACA,MAAM,KACH,EAAE,MAAM,sBAAsB,CAAC,MAAM,gBAAgB,CACvD,EACD,OAAO,aACPA,aACD;GACF,CAAC;;CAEL;AAED,MAAM,aAAiD,EACrD,QACA,6BAKA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACD,CAAC;;;;AAKJ,MAAa,aACX,UAAU;CACR,QAAQ,OAAO,OAAO;CACtB,wBAAwBA,aAAmB,EAAE,CAAC;CAC/C,CAAC;AAYJ,MAAa,eAAe,MAAM,CAC/B,SAASC,wBAA8B,CACvC,SAASC,aAAmB;AAE/B,MAAa,0BACX,YAEC;CACC,GAAG;CACH,GAAGC;CACJ"}
@@ -0,0 +1,39 @@
1
+ import { AnyWithProps } from "./DatabaseSchema.js";
2
+ import { DocumentDecodeError, DocumentEncodeError, WithoutSystemFields as WithoutSystemFields$1 } from "./Document.js";
3
+ import { DocumentByName, FromSchema, TableNames, ToConvex } from "./DataModel.js";
4
+ import { GetByIdFailure } from "./QueryInitializer.js";
5
+ import { Context, Effect, Layer } from "effect";
6
+ import { BetterOmit, Expand, GenericDatabaseWriter, WithoutSystemFields } from "convex/server";
7
+ import { GenericId } from "convex/values";
8
+
9
+ //#region src/DatabaseWriter.d.ts
10
+ declare namespace DatabaseWriter_d_exports {
11
+ export { DatabaseWriter, layer, make };
12
+ }
13
+ declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => {
14
+ insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
15
+ patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
16
+ replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<void, DocumentEncodeError, never>;
17
+ delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
18
+ };
19
+ declare const DatabaseWriter: <DatabaseSchema_ extends AnyWithProps>() => Context.Tag<{
20
+ insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
21
+ patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
22
+ replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
23
+ delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
24
+ }, {
25
+ insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
26
+ patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
27
+ replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
28
+ delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
29
+ }>;
30
+ type DatabaseWriter<DatabaseSchema_ extends AnyWithProps> = ReturnType<typeof DatabaseWriter<DatabaseSchema_>>["Identifier"];
31
+ declare const layer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<{
32
+ insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
33
+ patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
34
+ replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
35
+ delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
36
+ }, never, never>;
37
+ //#endregion
38
+ export { DatabaseWriter, DatabaseWriter_d_exports, layer, make };
39
+ //# sourceMappingURL=DatabaseWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseWriter.d.ts","names":[],"sources":["../src/DatabaseWriter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;cAiBa,+BAAgC,8BAC3B,uCACM,sBACpB,SAAmB,WAAqB;6BAKR,WAAoB,WAAA,8BACzC,qBACD,sBACR,eAAe,WAAA,kBAAa,gBAC7B,MAAA,CAAA,OAAA,UAAA,YAAA;4BAyB8B,WAAoB,WAAA,8BACxC,eACP,UAAU,2BACC,QACb,oBAAoB,eAAe,WAAA,kBAAa,iBACjD,MAAA,CAA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_runtime.js";
2
+ import { encode } from "./Document.js";
3
+ import { getById } from "./QueryInitializer.js";
4
+ import { Context, Effect, Layer, Record, pipe } from "effect";
5
+
6
+ //#region src/DatabaseWriter.ts
7
+ var DatabaseWriter_exports = /* @__PURE__ */ __export({
8
+ DatabaseWriter: () => DatabaseWriter,
9
+ layer: () => layer,
10
+ make: () => make
11
+ });
12
+ const make = (databaseSchema, convexDatabaseWriter) => {
13
+ const insert = (tableName, document) => Effect.gen(function* () {
14
+ const table = databaseSchema.tables[tableName];
15
+ const encodedDocument = yield* encode(document, tableName, table.Fields);
16
+ return yield* Effect.promise(() => convexDatabaseWriter.insert(tableName, encodedDocument));
17
+ });
18
+ const patch = (tableName, id, patchedValues) => Effect.gen(function* () {
19
+ const table = databaseSchema.tables[tableName];
20
+ const tableSchema = table.Fields;
21
+ const originalDecodedDoc = yield* getById(tableName, convexDatabaseWriter, table)(id);
22
+ const updatedEncodedDoc = yield* pipe(patchedValues, Record.reduce(originalDecodedDoc, (acc, value, key) => value === void 0 ? Record.remove(acc, key) : Record.set(acc, key, value)), encode(tableName, tableSchema));
23
+ yield* Effect.promise(() => convexDatabaseWriter.replace(id, updatedEncodedDoc));
24
+ });
25
+ const replace = (tableName, id, value) => Effect.gen(function* () {
26
+ const tableSchema = databaseSchema.tables[tableName].Fields;
27
+ const updatedEncodedDoc = yield* encode(value, tableName, tableSchema);
28
+ yield* Effect.promise(() => convexDatabaseWriter.replace(id, updatedEncodedDoc));
29
+ });
30
+ const delete_ = (_tableName, id) => Effect.promise(() => convexDatabaseWriter.delete(id));
31
+ return {
32
+ insert,
33
+ patch,
34
+ replace,
35
+ delete: delete_
36
+ };
37
+ };
38
+ const DatabaseWriter = () => Context.GenericTag("@confect/server/DatabaseWriter");
39
+ const layer = (databaseSchema, convexDatabaseWriter) => Layer.succeed(DatabaseWriter(), make(databaseSchema, convexDatabaseWriter));
40
+
41
+ //#endregion
42
+ export { DatabaseWriter, DatabaseWriter_exports, layer, make };
43
+ //# sourceMappingURL=DatabaseWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseWriter.js","names":["Document.encode","QueryInitializer.getById"],"sources":["../src/DatabaseWriter.ts"],"sourcesContent":["import type {\n BetterOmit,\n DocumentByName,\n Expand,\n GenericDatabaseWriter,\n WithoutSystemFields,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\nimport { Context, Effect, Layer, pipe, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport type { DocumentByName as DocumentByName_ } from \"./DataModel\";\nimport * as Document from \"./Document\";\nimport * as QueryInitializer from \"./QueryInitializer\";\nimport type * as Table from \"./Table\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexDatabaseWriter: GenericDatabaseWriter<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) => {\n type DataModel_ = DataModel.FromSchema<DatabaseSchema_>;\n\n const insert = <TableName extends DataModel.TableNames<DataModel_>>(\n tableName: TableName,\n document: Document.WithoutSystemFields<\n DocumentByName_<DataModel_, TableName>\n >,\n ) =>\n Effect.gen(function* () {\n const table = (\n databaseSchema.tables as Record<string, Table.AnyWithProps>\n )[tableName]!;\n\n const encodedDocument = yield* Document.encode(\n document,\n tableName,\n table.Fields,\n );\n\n const id = yield* Effect.promise(() =>\n convexDatabaseWriter.insert(\n tableName,\n encodedDocument as WithoutSystemFields<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>\n >,\n ),\n );\n\n return id;\n });\n\n const patch = <TableName extends DataModel.TableNames<DataModel_>>(\n tableName: TableName,\n id: GenericId<TableName>,\n patchedValues: Partial<\n WithoutSystemFields<DocumentByName_<DataModel_, TableName>>\n >,\n ) =>\n Effect.gen(function* () {\n const table = (\n databaseSchema.tables as Record<string, Table.AnyWithProps>\n )[tableName]!;\n\n const tableSchema = table.Fields as TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >;\n\n const originalDecodedDoc = yield* QueryInitializer.getById(\n tableName,\n convexDatabaseWriter as any,\n table,\n )(id);\n\n const updatedEncodedDoc = yield* pipe(\n patchedValues,\n Record.reduce(originalDecodedDoc, (acc, value, key) =>\n value === undefined\n ? Record.remove(acc, key)\n : Record.set(acc, key, value),\n ),\n Document.encode(tableName, tableSchema),\n );\n\n yield* Effect.promise(() =>\n convexDatabaseWriter.replace(\n id,\n updatedEncodedDoc as Expand<\n BetterOmit<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,\n \"_creationTime\" | \"_id\"\n >\n >,\n ),\n );\n });\n\n const replace = <TableName extends DataModel.TableNames<DataModel_>>(\n tableName: TableName,\n id: GenericId<TableName>,\n value: WithoutSystemFields<DocumentByName_<DataModel_, TableName>>,\n ) =>\n Effect.gen(function* () {\n const table = (\n databaseSchema.tables as Record<string, Table.AnyWithProps>\n )[tableName]!;\n\n const tableSchema = table.Fields as TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >;\n\n const updatedEncodedDoc = yield* Document.encode(\n value,\n tableName,\n tableSchema,\n );\n\n yield* Effect.promise(() =>\n convexDatabaseWriter.replace(\n id,\n updatedEncodedDoc as Expand<\n BetterOmit<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,\n \"_creationTime\" | \"_id\"\n >\n >,\n ),\n );\n });\n\n const delete_ = <TableName extends DataModel.TableNames<DataModel_>>(\n _tableName: TableName,\n id: GenericId<TableName>,\n ) => Effect.promise(() => convexDatabaseWriter.delete(id));\n\n return {\n insert,\n patch,\n replace,\n delete: delete_,\n };\n};\n\nexport const DatabaseWriter = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>() =>\n Context.GenericTag<ReturnType<typeof make<DatabaseSchema_>>>(\n \"@confect/server/DatabaseWriter\",\n );\n\nexport type DatabaseWriter<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> = ReturnType<typeof DatabaseWriter<DatabaseSchema_>>[\"Identifier\"];\n\nexport const layer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexDatabaseWriter: GenericDatabaseWriter<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.succeed(\n DatabaseWriter<DatabaseSchema_>(),\n make(databaseSchema, convexDatabaseWriter),\n );\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,QACX,gBACA,yBAGG;CAGH,MAAM,UACJ,WACA,aAIA,OAAO,IAAI,aAAa;EACtB,MAAM,QACJ,eAAe,OACf;EAEF,MAAM,kBAAkB,OAAOA,OAC7B,UACA,WACA,MAAM,OACP;AAWD,SATW,OAAO,OAAO,cACvB,qBAAqB,OACnB,WACA,gBAGD,CACF;GAGD;CAEJ,MAAM,SACJ,WACA,IACA,kBAIA,OAAO,IAAI,aAAa;EACtB,MAAM,QACJ,eAAe,OACf;EAEF,MAAM,cAAc,MAAM;EAI1B,MAAM,qBAAqB,OAAOC,QAChC,WACA,sBACA,MACD,CAAC,GAAG;EAEL,MAAM,oBAAoB,OAAO,KAC/B,eACA,OAAO,OAAO,qBAAqB,KAAK,OAAO,QAC7C,UAAU,SACN,OAAO,OAAO,KAAK,IAAI,GACvB,OAAO,IAAI,KAAK,KAAK,MAAM,CAChC,EACDD,OAAgB,WAAW,YAAY,CACxC;AAED,SAAO,OAAO,cACZ,qBAAqB,QACnB,IACA,kBAMD,CACF;GACD;CAEJ,MAAM,WACJ,WACA,IACA,UAEA,OAAO,IAAI,aAAa;EAKtB,MAAM,cAHJ,eAAe,OACf,WAEwB;EAI1B,MAAM,oBAAoB,OAAOA,OAC/B,OACA,WACA,YACD;AAED,SAAO,OAAO,cACZ,qBAAqB,QACnB,IACA,kBAMD,CACF;GACD;CAEJ,MAAM,WACJ,YACA,OACG,OAAO,cAAc,qBAAqB,OAAO,GAAG,CAAC;AAE1D,QAAO;EACL;EACA;EACA;EACA,QAAQ;EACT;;AAGH,MAAa,uBAGX,QAAQ,WACN,iCACD;AAMH,MAAa,SACX,gBACA,yBAIA,MAAM,QACJ,gBAAiC,EACjC,KAAK,gBAAgB,qBAAqB,CAC3C"}
@@ -0,0 +1,47 @@
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>);
16
+ declare const DocumentDecodeError_base: Schema.TaggedErrorClass<DocumentDecodeError, "DocumentDecodeError", {
17
+ readonly _tag: Schema.tag<"DocumentDecodeError">;
18
+ } & {
19
+ tableName: typeof Schema.String;
20
+ id: typeof Schema.String;
21
+ parseError: typeof Schema.String;
22
+ }>;
23
+ declare class DocumentDecodeError extends DocumentDecodeError_base {
24
+ get message(): string;
25
+ }
26
+ declare const DocumentEncodeError_base: Schema.TaggedErrorClass<DocumentEncodeError, "DocumentEncodeError", {
27
+ readonly _tag: Schema.tag<"DocumentEncodeError">;
28
+ } & {
29
+ tableName: typeof Schema.String;
30
+ id: typeof Schema.String;
31
+ parseError: typeof Schema.String;
32
+ }>;
33
+ declare class DocumentEncodeError extends DocumentEncodeError_base {
34
+ get message(): string;
35
+ }
36
+ declare const documentErrorMessage: ({
37
+ id,
38
+ tableName,
39
+ message
40
+ }: {
41
+ id: string;
42
+ tableName: string;
43
+ message: string;
44
+ }) => string;
45
+ //#endregion
46
+ export { Any, AnyEncoded, DocumentDecodeError, DocumentEncodeError, Document_d_exports, WithoutSystemFields, decode, documentErrorMessage, encode };
47
+ //# sourceMappingURL=Document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.d.ts","names":[],"sources":["../src/Document.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAOY,2BAA2B,KAAK;KAEhC,GAAA;KACA,UAAA,GAAa,uBAAuB;cAEnC,6BAEU,gCACD,WAAqB,wBAE5B,wBACE,YACX,mBAA6B,YAAY,uBAGrC,mBAA6B,YAAY,iCAC5C,MAAA,CAAO,OACV,mBAA6B,YAAY,wBACzC,6CAGmB,gCACD,WAAqB,mBAEjC,mBAA6B,YAAY,yCACpC,wBACE,YACX,mBAA6B,YAAY,gBAExC,MAAA,CAAO,OACV,mBAA6B,YAAY,wBACzC;cA+CS,6BAEU,gCACD,WAAqB,wBAE5B,wBACE,YACX,mBAA6B,YAAY,uBAGrC,mBAA6B,YAAY,2BAC5C,MAAA,CAAO,OACV,mBAA6B,YAAY,+BACzC,6CAGmB,gCACD,WAAqB,mBAEjC,mBAA6B,YAAY,mCACpC,wBACE,YACX,mBAA6B,YAAY,gBAExC,MAAA,CAAO,OACV,mBAA6B,YAAY,+BACzC;cA8CF;;;;;;;cAEW,mBAAA,SAA4B,wBAAA;EAxJ7B,IAAA,OAAA,CAAA,CAAA,EAAA,MAAA;AAEZ;AACA,cAmKC,wBAnK+C,yBAAT,oBAAA,EAAA,qBAAA,EAAA;EAE1B,SAuEZ,IAAA,YAAA,CAAA,qBAAA,CAAA;CArEsB,GAAA;EACoB,SAAA,EAAA,oBAAA;EAArB,EAAA,EAAA,oBAAA;EAEP,UAAA,EAAA,oBAAA;CAEoB,CAAA;AAAY,cA4JlC,mBAAA,SAA4B,wBAAA,CA5JM;EAAzC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAA;;AAGiC,cAyK1B,oBAzK0B,EAAA,CAAA;EAAA,EAAA;EAAA,SAAA;EAAA;CAAA,EAAA;EAAY,EAAA,EAAA,MAAA;EAAzC,SAAA,EAAA,MAAA;EAEuB,OAAA,EAAA,MAAA;CAAY,EAAA,GAAA,MAAA"}
@@ -0,0 +1,66 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
+ import { Effect, Function, ParseResult, Schema, pipe } from "effect";
3
+ import * as SystemFields from "@confect/core/SystemFields";
4
+
5
+ //#region src/Document.ts
6
+ var Document_exports = /* @__PURE__ */ __export({
7
+ DocumentDecodeError: () => DocumentDecodeError,
8
+ DocumentEncodeError: () => DocumentEncodeError,
9
+ decode: () => decode,
10
+ documentErrorMessage: () => documentErrorMessage,
11
+ encode: () => encode
12
+ });
13
+ const decode = Function.dual(3, (self, tableName, tableSchema) => Effect.gen(function* () {
14
+ const TableSchemaWithSystemFields = SystemFields.extendWithSystemFields(tableName, tableSchema);
15
+ const encodedDoc = self;
16
+ return yield* pipe(encodedDoc, Schema.decode(TableSchemaWithSystemFields), Effect.catchTag("ParseError", (parseError) => Effect.gen(function* () {
17
+ const formattedParseError = yield* ParseResult.TreeFormatter.formatError(parseError);
18
+ return yield* new DocumentDecodeError({
19
+ tableName,
20
+ id: encodedDoc._id,
21
+ parseError: formattedParseError
22
+ });
23
+ })));
24
+ }));
25
+ const encode = Function.dual(3, (self, tableName, tableSchema) => Effect.gen(function* () {
26
+ const decodedDoc = self;
27
+ return yield* pipe(decodedDoc, Schema.encode(tableSchema), Effect.catchTag("ParseError", (parseError) => Effect.gen(function* () {
28
+ const formattedParseError = yield* ParseResult.TreeFormatter.formatError(parseError);
29
+ return yield* new DocumentEncodeError({
30
+ tableName,
31
+ id: decodedDoc._id,
32
+ parseError: formattedParseError
33
+ });
34
+ })));
35
+ }));
36
+ var DocumentDecodeError = class extends Schema.TaggedError("DocumentDecodeError")("DocumentDecodeError", {
37
+ tableName: Schema.String,
38
+ id: Schema.String,
39
+ parseError: Schema.String
40
+ }) {
41
+ get message() {
42
+ return documentErrorMessage({
43
+ id: this.id,
44
+ tableName: this.tableName,
45
+ message: `could not be decoded:\n\n${this.parseError}`
46
+ });
47
+ }
48
+ };
49
+ var DocumentEncodeError = class extends Schema.TaggedError("DocumentEncodeError")("DocumentEncodeError", {
50
+ tableName: Schema.String,
51
+ id: Schema.String,
52
+ parseError: Schema.String
53
+ }) {
54
+ get message() {
55
+ return documentErrorMessage({
56
+ id: this.id,
57
+ tableName: this.tableName,
58
+ message: `could not be encoded:\n\n${this.parseError}`
59
+ });
60
+ }
61
+ };
62
+ const documentErrorMessage = ({ id, tableName, message }) => `Document with ID '${id}' in table '${tableName}' ${message}`;
63
+
64
+ //#endregion
65
+ export { DocumentDecodeError, DocumentEncodeError, Document_exports, decode, documentErrorMessage, encode };
66
+ //# sourceMappingURL=Document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.js","names":[],"sources":["../src/Document.ts"],"sourcesContent":["import { Effect, Function, ParseResult, pipe, Schema } from \"effect\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport * as SystemFields from \"@confect/core/SystemFields\";\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\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 Effect.gen(function* () {\n const TableSchemaWithSystemFields = SystemFields.extendWithSystemFields(\n tableName,\n tableSchema,\n );\n\n const encodedDoc =\n self as (typeof TableSchemaWithSystemFields)[\"Encoded\"];\n\n const decodedDoc = yield* pipe(\n encodedDoc,\n Schema.decode(TableSchemaWithSystemFields),\n Effect.catchTag(\"ParseError\", (parseError) =>\n Effect.gen(function* () {\n const formattedParseError =\n yield* ParseResult.TreeFormatter.formatError(parseError);\n\n return yield* new DocumentDecodeError({\n tableName,\n id: encodedDoc._id,\n parseError: formattedParseError,\n });\n }),\n ),\n );\n\n return decodedDoc;\n }),\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 Effect.gen(function* () {\n type TableSchemaWithSystemFields = SystemFields.ExtendWithSystemFields<\n TableName,\n TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >\n >;\n\n const decodedDoc = self as TableSchemaWithSystemFields[\"Type\"];\n\n const encodedDoc = yield* pipe(\n decodedDoc,\n Schema.encode(tableSchema),\n Effect.catchTag(\"ParseError\", (parseError) =>\n Effect.gen(function* () {\n const formattedParseError =\n yield* ParseResult.TreeFormatter.formatError(parseError);\n\n return yield* new DocumentEncodeError({\n tableName,\n id: decodedDoc._id,\n parseError: formattedParseError,\n });\n }),\n ),\n );\n\n return encodedDoc;\n }),\n);\n\nexport class DocumentDecodeError extends Schema.TaggedError<DocumentDecodeError>(\n \"DocumentDecodeError\",\n)(\"DocumentDecodeError\", {\n tableName: Schema.String,\n id: Schema.String,\n parseError: Schema.String,\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)(\"DocumentEncodeError\", {\n tableName: Schema.String,\n id: Schema.String,\n parseError: Schema.String,\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":";;;;;;;;;;;;AAYA,MAAa,SAAS,SAAS,KA6B7B,IAKE,MACA,WACA,gBAOA,OAAO,IAAI,aAAa;CACtB,MAAM,8BAA8B,aAAa,uBAC/C,WACA,YACD;CAED,MAAM,aACJ;AAmBF,QAjBmB,OAAO,KACxB,YACA,OAAO,OAAO,4BAA4B,EAC1C,OAAO,SAAS,eAAe,eAC7B,OAAO,IAAI,aAAa;EACtB,MAAM,sBACJ,OAAO,YAAY,cAAc,YAAY,WAAW;AAE1D,SAAO,OAAO,IAAI,oBAAoB;GACpC;GACA,IAAI,WAAW;GACf,YAAY;GACb,CAAC;GACF,CACH,CACF;EAGD,CACL;AAED,MAAa,SAAS,SAAS,KA6B7B,IAKE,MACA,WACA,gBAOA,OAAO,IAAI,aAAa;CAQtB,MAAM,aAAa;AAmBnB,QAjBmB,OAAO,KACxB,YACA,OAAO,OAAO,YAAY,EAC1B,OAAO,SAAS,eAAe,eAC7B,OAAO,IAAI,aAAa;EACtB,MAAM,sBACJ,OAAO,YAAY,cAAc,YAAY,WAAW;AAE1D,SAAO,OAAO,IAAI,oBAAoB;GACpC;GACA,IAAI,WAAW;GACf,YAAY;GACb,CAAC;GACF,CACH,CACF;EAGD,CACL;AAED,IAAa,sBAAb,cAAyC,OAAO,YAC9C,sBACD,CAAC,uBAAuB;CACvB,WAAW,OAAO;CAClB,IAAI,OAAO;CACX,YAAY,OAAO;CACpB,CAAC,CAAC;CACD,IAAa,UAAkB;AAC7B,SAAO,qBAAqB;GAC1B,IAAI,KAAK;GACT,WAAW,KAAK;GAChB,SAAS,4BAA4B,KAAK;GAC3C,CAAC;;;AAIN,IAAa,sBAAb,cAAyC,OAAO,YAC9C,sBACD,CAAC,uBAAuB;CACvB,WAAW,OAAO;CAClB,IAAI,OAAO;CACX,YAAY,OAAO;CACpB,CAAC,CAAC;CACD,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"}
@@ -0,0 +1,34 @@
1
+ import { AnyWithProps, Groups, 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 GroupPath from "@confect/core/GroupPath";
6
+ import * as GroupSpec from "@confect/core/GroupSpec";
7
+
8
+ //#region src/FunctionImpl.d.ts
9
+ declare namespace FunctionImpl_d_exports {
10
+ export { ForGroupPathAndFunction, FromGroupAtPath, FunctionImpl, make };
11
+ }
12
+ interface FunctionImpl<GroupPath_ extends string, FunctionName extends string> {
13
+ readonly groupPath: GroupPath_;
14
+ readonly functionName: FunctionName;
15
+ }
16
+ declare const FunctionImpl: <GroupPath_ extends string, FunctionName extends string>({
17
+ groupPath,
18
+ functionName
19
+ }: {
20
+ groupPath: GroupPath_;
21
+ functionName: FunctionName;
22
+ }) => Context.Tag<FunctionImpl<GroupPath_, FunctionName>, FunctionImpl<GroupPath_, FunctionName>>;
23
+ declare const make: <Api_ extends AnyWithProps, const GroupPath_ extends GroupPath.All<Groups<Api_>>, const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<GroupPath.GroupAt<Groups<Api_>, GroupPath_>>>>(api: Api_, groupPath: GroupPath_, functionName: FunctionName, handler: WithName<Schema$1<Api_>, GroupSpec.Functions<GroupPath.GroupAt<Groups<Api_>, GroupPath_>>, FunctionName>) => Layer.Layer<FunctionImpl<GroupPath_, FunctionName>>;
24
+ /**
25
+ * Get the function implementation service type for a specific group path and function name.
26
+ */
27
+ type ForGroupPathAndFunction<GroupPath_ extends string, FunctionName extends string> = FunctionImpl<GroupPath_, FunctionName>;
28
+ /**
29
+ * Get all function implementation services required for a group at a given path.
30
+ */
31
+ type FromGroupAtPath<GroupPath_ extends string, Group extends GroupSpec.AnyWithProps> = GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends GroupSpec.AnyWithProps ? FunctionSpec.Name<GroupSpec.Functions<GroupAtPath>> extends infer FunctionNames extends string ? FunctionNames extends string ? FunctionImpl<GroupPath_, FunctionNames> : never : never : never;
32
+ //#endregion
33
+ export { ForGroupPathAndFunction, FromGroupAtPath, FunctionImpl, FunctionImpl_d_exports, make };
34
+ //# sourceMappingURL=FunctionImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionImpl.d.ts","names":[],"sources":["../src/FunctionImpl.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;UAUiB;sBAIK;yBACG;;cAGZ;;;;aAOA;gBACG;MACf,OAAA,CAAA,IAAA,aAAA,YAAA,eAAA,aAAA,YAAA;cAKY,oBACE,uCACY,SAAA,CAAU,IAAI,OAAW,mCACvB,YAAA,CAAa,KACtC,SAAA,CAAU,UAAU,SAAA,CAAU,QAAQ,OAAW,OAAO,oBAGrD,iBACM,0BACG,uBACL,SACP,SAAW,OACX,SAAA,CAAU,UAAU,SAAA,CAAU,QAAQ,OAAW,OAAO,cACxD,kBAED,KAAA,CAAM,MAAM,aAAa,YAAY;AArCxC;AAQA;;AAGE,KAqEU,uBArEV,CAAA,mBAAA,MAAA,EAAA,qBAAA,MAAA,CAAA,GAwEE,YAxEF,CAwEe,UAxEf,EAwE2B,YAxE3B,CAAA;;;;AAMD,KAuEW,eAvEX,CAAA,mBAAA,MAAA,EAAA,cAyEe,SAAA,CAAU,YAzEzB,CAAA,GA2EC,SAAA,CAAU,OA3EX,CA2EmB,KA3EnB,EA2E0B,UA3E1B,CAAA,SAAA,KAAA,qBA4EG,SAAA,CAAU,YA5Eb,GA6EK,YAAA,CAAa,IA7ElB,CA8EO,SAAA,CAAU,SA9EjB,CA8E2B,WA9E3B,CAAA,CAAA,SAAA,KAAA,uBAAA,MAAA,GAgFO,aAhFP,SAAA,MAAA,GAiFS,YAjFT,CAiFsB,UAjFtB,EAiFkC,aAjFlC,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA"}
@@ -0,0 +1,35 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
+ import { setNestedProperty } from "./internal/utils.js";
3
+ import { Registry } from "./Registry.js";
4
+ import { make as make$1 } from "./RegistryItem.js";
5
+ import { Array, Context, Effect, Layer, Ref, String } from "effect";
6
+
7
+ //#region src/FunctionImpl.ts
8
+ var FunctionImpl_exports = /* @__PURE__ */ __export({
9
+ FunctionImpl: () => FunctionImpl,
10
+ make: () => make
11
+ });
12
+ const FunctionImpl = ({ groupPath, functionName }) => Context.GenericTag(`@confect/server/FunctionImpl/${groupPath}/${functionName}`);
13
+ const make = (api, groupPath, functionName, handler) => {
14
+ const groupPathParts = String.split(groupPath, ".");
15
+ const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;
16
+ const function_ = Array.reduce(restGroupPathParts, api.spec.groups[firstGroupPathPart], (currentGroup, groupPathPart) => currentGroup.groups[groupPathPart]).functions[functionName];
17
+ return Layer.effect(FunctionImpl({
18
+ groupPath,
19
+ functionName
20
+ }), Effect.gen(function* () {
21
+ const registry = yield* Registry;
22
+ yield* Ref.update(registry, (registryItems) => setNestedProperty(registryItems, [...groupPathParts, functionName], make$1({
23
+ function_,
24
+ handler
25
+ })));
26
+ return {
27
+ groupPath,
28
+ functionName
29
+ };
30
+ }));
31
+ };
32
+
33
+ //#endregion
34
+ export { FunctionImpl, FunctionImpl_exports, make };
35
+ //# sourceMappingURL=FunctionImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionImpl.js","names":["Registry.Registry","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Array, Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as Registry from \"./Registry\";\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 const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n const FunctionName extends FunctionSpec.Name<\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>\n >,\n>(\n api: Api_,\n groupPath: GroupPath_,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {\n const groupPathParts = String.split(groupPath, \".\");\n const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;\n\n const group_: GroupSpec.AnyWithProps = Array.reduce(\n restGroupPathParts,\n (api as any).spec.groups[firstGroupPathPart as any]!,\n (currentGroup: any, groupPathPart: any) =>\n currentGroup.groups[groupPathPart],\n );\n\n const function_ = group_.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<GroupPath_, 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 [...groupPathParts, functionName],\n RegistryItem.make({\n function_,\n handler: handler as Handler.AnyWithProps,\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 at a given path.\n */\nexport type FromGroupAtPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends\n GroupSpec.AnyWithProps\n ? FunctionSpec.Name<\n GroupSpec.Functions<GroupAtPath>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<GroupPath_, FunctionNames>\n : never\n : never\n : never;\n"],"mappings":";;;;;;;;;;;AAkBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAOX,KACA,WACA,cACA,YAKwD;CACxD,MAAM,iBAAiB,OAAO,MAAM,WAAW,IAAI;CACnD,MAAM,CAAC,oBAAoB,GAAG,sBAAsB;CASpD,MAAM,YAPiC,MAAM,OAC3C,oBACC,IAAY,KAAK,OAAO,sBACxB,cAAmB,kBAClB,aAAa,OAAO,eACvB,CAEwB,UAAU;AAEnC,QAAO,MAAM,OACX,aAAuC;EACrC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAOA;AAExB,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,gBAAgB,aAAa,EACjCC,OAAkB;GAChB;GACS;GACV,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
@@ -0,0 +1,24 @@
1
+ import { AnyWithProps, Groups } from "./Api.js";
2
+ import { FromGroupAtPath } from "./FunctionImpl.js";
3
+ import { Context, Layer } from "effect";
4
+ import * as GroupPath from "@confect/core/GroupPath";
5
+ import * as GroupSpec from "@confect/core/GroupSpec";
6
+
7
+ //#region src/GroupImpl.d.ts
8
+ declare namespace GroupImpl_d_exports {
9
+ export { FromGroupWithPath, FromGroups, GroupImpl, make };
10
+ }
11
+ interface GroupImpl<GroupPath_ extends string> {
12
+ readonly groupPath: GroupPath_;
13
+ }
14
+ declare const GroupImpl: <GroupPath_ extends string>({
15
+ groupPath
16
+ }: {
17
+ groupPath: GroupPath_;
18
+ }) => Context.Tag<GroupImpl<GroupPath_>, GroupImpl<GroupPath_>>;
19
+ declare const make: <Api_ extends AnyWithProps, const GroupPath_ extends GroupPath.All<Groups<Api_>>>(_api: Api_, groupPath: GroupPath_) => Layer.Layer<GroupImpl<GroupPath_>, never, FromGroupWithPath<GroupPath_, Groups<Api_>> | FromGroupAtPath<GroupPath_, Groups<Api_>>>;
20
+ type FromGroups<Groups$1 extends GroupSpec.Any> = Groups$1 extends never ? never : Groups$1 extends GroupSpec.AnyWithProps ? GroupImpl<GroupSpec.Name<Groups$1>> : never;
21
+ type FromGroupWithPath<GroupPath_ extends string, Group extends GroupSpec.AnyWithProps> = GroupPath.SubGroupsAt<Group, GroupPath_> extends infer SubGroupPaths ? SubGroupPaths extends string ? GroupImpl<SubGroupPaths> : never : never;
22
+ //#endregion
23
+ export { FromGroupWithPath, FromGroups, GroupImpl, GroupImpl_d_exports, make };
24
+ //# sourceMappingURL=GroupImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAMiB;sBACK;;cAGT;;;aAGA;MACZ,OAAA,CAAA,IAAA,UAAA,aAAA,UAAA;cAKY,oBACE,uCACY,SAAA,CAAU,IAAI,OAAW,cAE5C,iBACK,eACV,KAAA,CAAM,MACP,UAAU,oBAER,kBAAkB,YAAY,OAAW,SACzC,gBAA6B,YAAY,OAAW;KAgB5C,4BAA0B,SAAA,CAAU,OAAO,iCAEnD,iBAAe,SAAA,CAAU,eACvB,UAAU,SAAA,CAAU,KAAK;KAGnB,2DAEI,SAAA,CAAU,gBAExB,SAAA,CAAU,YAAY,OAAO,0CACzB,+BACE,UAAU"}
@@ -0,0 +1,14 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
+ import { Context, Layer } from "effect";
3
+
4
+ //#region src/GroupImpl.ts
5
+ var GroupImpl_exports = /* @__PURE__ */ __export({
6
+ GroupImpl: () => GroupImpl,
7
+ make: () => make
8
+ });
9
+ const GroupImpl = ({ groupPath }) => Context.GenericTag(`@confect/server/GroupImpl/${groupPath}`);
10
+ const make = (_api, groupPath) => Layer.succeed(GroupImpl({ groupPath }), { groupPath });
11
+
12
+ //#endregion
13
+ export { GroupImpl, GroupImpl_exports, make };
14
+ //# sourceMappingURL=GroupImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Context, Layer } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\n\nexport interface GroupImpl<GroupPath_ extends string> {\n readonly groupPath: GroupPath_;\n}\n\nexport const GroupImpl = <GroupPath_ extends string>({\n groupPath,\n}: {\n groupPath: GroupPath_;\n}) =>\n Context.GenericTag<GroupImpl<GroupPath_>>(\n `@confect/server/GroupImpl/${groupPath}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n>(\n _api: Api_,\n groupPath: GroupPath_,\n): Layer.Layer<\n GroupImpl<GroupPath_>,\n never,\n | FromGroupWithPath<GroupPath_, Api.Groups<Api_>>\n | FunctionImpl.FromGroupAtPath<GroupPath_, Api.Groups<Api_>>\n> =>\n Layer.succeed(\n GroupImpl<GroupPath_>({\n groupPath,\n }),\n {\n groupPath,\n },\n ) as Layer.Layer<\n GroupImpl<GroupPath_>,\n never,\n | FromGroupWithPath<GroupPath_, Api.Groups<Api_>>\n | FunctionImpl.FromGroupAtPath<GroupPath_, Api.Groups<Api_>>\n >;\n\nexport type FromGroups<Groups extends GroupSpec.Any> = Groups extends never\n ? never\n : Groups extends GroupSpec.AnyWithProps\n ? GroupImpl<GroupSpec.Name<Groups>>\n : never;\n\nexport type FromGroupWithPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.SubGroupsAt<Group, GroupPath_> extends infer SubGroupPaths\n ? SubGroupPaths extends string\n ? GroupImpl<SubGroupPaths>\n : never\n : never;\n"],"mappings":";;;;;;;;AAUA,MAAa,aAAwC,EACnD,gBAIA,QAAQ,WACN,6BAA6B,YAC9B;AAEH,MAAa,QAIX,MACA,cAOA,MAAM,QACJ,UAAsB,EACpB,WACD,CAAC,EACF,EACE,WACD,CACF"}
@@ -0,0 +1,31 @@
1
+ import { ActionCtx } from "./ActionCtx.js";
2
+ import { ActionRunner } from "./ActionRunner.js";
3
+ import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
4
+ import { Auth } from "./Auth.js";
5
+ import { FromSchema, ToConvex } from "./DataModel.js";
6
+ import { DatabaseReader } from "./DatabaseReader.js";
7
+ import { DatabaseWriter } from "./DatabaseWriter.js";
8
+ import { MutationCtx } from "./MutationCtx.js";
9
+ import { MutationRunner } from "./MutationRunner.js";
10
+ import { QueryCtx } from "./QueryCtx.js";
11
+ import { QueryRunner } from "./QueryRunner.js";
12
+ import { Scheduler } from "./Scheduler.js";
13
+ import { StorageActionWriter, StorageReader, StorageWriter } from "./Storage.js";
14
+ import { VectorSearch } from "./VectorSearch.js";
15
+ import { Effect } from "effect";
16
+ import { FunctionSpec } from "@confect/core";
17
+
18
+ //#region src/Handler.d.ts
19
+ declare namespace Handler_d_exports {
20
+ export { Action, AnyWithProps, Handler, Mutation, Query, WithName };
21
+ }
22
+ type Handler<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? Query<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? Mutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "action"> ? Action<DatabaseSchema_, FunctionSpec_> : never;
23
+ type Query<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<"query">> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | Auth | StorageReader | QueryRunner | QueryCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
24
+ type Mutation<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<"mutation">> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | DatabaseWriter<DatabaseSchema_> | Auth | Scheduler | StorageReader | StorageWriter | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
25
+ type Action<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<"action">> = Base<FunctionSpec_, Scheduler | Auth | StorageReader | StorageWriter | StorageActionWriter | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
26
+ type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (args: FunctionSpec.Args<FunctionSpec_>["Type"]) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>["Type"], never, R>;
27
+ type AnyWithProps = Handler<AnyWithProps$1, FunctionSpec.AnyWithProps>;
28
+ type WithName<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps, FunctionName extends string> = Handler<DatabaseSchema_, FunctionSpec.WithName<FunctionSpec_, FunctionName>>;
29
+ //#endregion
30
+ export { Action, AnyWithProps, Handler, Handler_d_exports, Mutation, Query, WithName };
31
+ //# sourceMappingURL=Handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;KAqBY,gCACc,sCACF,YAAA,CAAa,gBAEnC,sBAAsB,YAAA,CAAa,iBAAiB,0BAChD,MAAM,iBAAiB,iBACvB,sBAAsB,YAAA,CAAa,iBAC/B,6BAGF,SAAS,iBAAiB,iBAC1B,sBAAsB,YAAA,CAAa,iBAC/B,2BAGF,OAAO,iBAAiB;KAGtB,8BACc,sCACF,YAAA,CAAa,yCACjC,KACF,eACE,eAA8B,mBAC9B,OACA,gBACA,cACA,SAAkB,SAAmB,WAAqB;KAGlD,iCACc,sCACF,YAAA,CAAa,4CACjC,KACF,eACE,eAA8B,mBAC9B,eAA8B,mBAC9B,OACA,YACA,gBACA,gBACA,cACA,iBACA,YACE,SAAmB,WAAqB;KAIlC,+BACc,sCACF,YAAA,CAAa,0CACjC,KACF,eACE,YACA,OACA,gBACA,gBACA,sBACA,cACA,iBACA,eACA,aAA0B,WAAqB,oBAC/C,UACE,SAAmB,WAAqB;KAIzC,2BAA2B,YAAA,CAAa,0BACrC,YAAA,CAAa,KAAK,2BACrB,MAAA,CAAO,OAAO,YAAA,CAAa,QAAQ,+BAA+B;KAE3D,YAAA,GAAe,QACzB,gBACA,YAAA,CAAa;KAGH,iCACc,sCACF,YAAA,CAAa,6CAEjC,QACF,iBACA,YAAA,CAAa,SAAS,eAAe"}
@@ -0,0 +1,6 @@
1
+ //#region src/Handler.ts
2
+ var Handler_exports = {};
3
+
4
+ //#endregion
5
+ export { Handler_exports };
6
+ //# sourceMappingURL=Handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec } from \"@confect/core\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./Storage\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? Query<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? Mutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"action\"\n >\n ? Action<DatabaseSchema_, FunctionSpec_>\n : never;\n\nexport type Query<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<\"query\">,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>\n>;\n\nexport type Mutation<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<\"mutation\">,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | DatabaseWriter.DatabaseWriter<DatabaseSchema_>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\nexport type Action<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<\"action\">,\n> = Base<\n FunctionSpec_,\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>\n | ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\ntype Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (\n args: FunctionSpec.Args<FunctionSpec_>[\"Type\"],\n) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>[\"Type\"], never, R>;\n\nexport type AnyWithProps = Handler<\n DatabaseSchema.AnyWithProps,\n FunctionSpec.AnyWithProps\n>;\n\nexport type WithName<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n FunctionName extends string,\n> = Handler<\n DatabaseSchema_,\n FunctionSpec.WithName<FunctionSpec_, FunctionName>\n>;\n"],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { ActionRunner } from "./ActionRunner.js";
2
+ import { Auth as Auth$1 } from "./Auth.js";
3
+ import { MutationRunner } from "./MutationRunner.js";
4
+ import { QueryRunner } from "./QueryRunner.js";
5
+ import { Scheduler as Scheduler$1 } from "./Scheduler.js";
6
+ import { StorageActionWriter as StorageActionWriter$1, StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
7
+ import { Layer } from "effect";
8
+ import { HttpRouter } from "convex/server";
9
+ import { HttpApi, HttpApiBuilder, HttpApiScalar, HttpApp, HttpRouter as HttpRouter$1 } from "@effect/platform";
10
+
11
+ //#region src/HttpApi.d.ts
12
+ declare namespace HttpApi_d_exports {
13
+ export { HttpApi_, RoutePath, make };
14
+ }
15
+ type Middleware = (httpApp: HttpApp.Default) => HttpApp.Default<never, HttpApi.Api | HttpApiBuilder.Router | HttpRouter$1.HttpRouter.DefaultServices>;
16
+ type HttpApi_ = {
17
+ apiLive: Layer.Layer<HttpApi.Api, never, QueryRunner | MutationRunner | ActionRunner | Scheduler$1 | Auth$1 | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1>;
18
+ middleware?: Middleware;
19
+ scalar?: HttpApiScalar.ScalarConfig;
20
+ };
21
+ type RoutePath = "/" | `/${string}/`;
22
+ type HttpApis = Partial<Record<RoutePath, HttpApi_>>;
23
+ declare const make: (httpApis: HttpApis) => HttpRouter;
24
+ //#endregion
25
+ export { HttpApi_, HttpApi_d_exports, RoutePath, make };
26
+ //# sourceMappingURL=HttpApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpApi.d.ts","names":[],"sources":["../src/HttpApi.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KA0BK,UAAA,aACM,OAAA,CAAQ,YACd,OAAA,CAAQ,eAEX,OAAA,CAAQ,MAAM,cAAA,CAAe,SAAS,YAAA,CAAW,UAAA,CAAW;KAqGlD,QAAA;WACD,KAAA,CAAM,MACb,OAAA,CAAQ,YAEN,cACA,iBACA,eACA,cACA,SACA,kBACA,kBACA;eAES;WACJ,aAAA,CAAc;;KAGb,SAAA;KA8CP,QAAA,GAAW,QAAQ,OAAO,WAAW;AAxKrC,cA0KQ,IA1KE,EAAA,CAAA,QAAA,EA0KgB,QA1KhB,EAAA,GA0K2B,UA1K3B"}