ignotum 0.0.11 → 0.0.13

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 (61) hide show
  1. package/README.md +8 -3
  2. package/dist/cli/bin.mjs +1372 -492
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/runtime/{api-DzcR7spt.js → api-CAgKDij7.js} +38 -2
  5. package/dist/runtime/api-CAgKDij7.js.map +1 -0
  6. package/dist/runtime/{api-DR_8vfKg.d.ts → api-Cv3hMbzo.d.ts} +4 -3
  7. package/dist/runtime/client.d.ts +39 -8
  8. package/dist/runtime/client.js +505 -131
  9. package/dist/runtime/client.js.map +1 -1
  10. package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js +154 -0
  11. package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js.map +1 -0
  12. package/dist/runtime/id-Bt9XWRGL.js +423 -0
  13. package/dist/runtime/id-Bt9XWRGL.js.map +1 -0
  14. package/dist/runtime/{id-Cs82tq9Q-hmYFyqTa.d.ts → id-BzFHf3Wo-DGPCjgrf.d.ts} +13 -13
  15. package/dist/runtime/id-Dz0apuB3.d.ts +1 -0
  16. package/dist/runtime/{index-2q9FwJud.d.ts → index-D54flWtH.d.ts} +136 -76
  17. package/dist/runtime/internal/api.d.ts +1 -1
  18. package/dist/runtime/internal/api.js +1 -1
  19. package/dist/runtime/internal/host.d.ts +21 -17
  20. package/dist/runtime/internal/host.js +22 -8
  21. package/dist/runtime/internal/host.js.map +1 -1
  22. package/dist/runtime/internal/server.d.ts +1 -1
  23. package/dist/runtime/internal/server.js +1 -1
  24. package/dist/runtime/internal/types.d.ts +1 -1
  25. package/dist/runtime/internal/types.js +1 -1
  26. package/dist/runtime/{pagination-Bt3l7QaC-BYEGmLBE.d.ts → pagination-DnKg3dkI-r5ZUxBBx.d.ts} +34 -6
  27. package/dist/runtime/pagination-Dz0apuB3.d.ts +1 -0
  28. package/dist/runtime/result-DKAA4gpS.d.ts +1 -0
  29. package/dist/runtime/{schema-ERFjT8-m.js → schema-1Zs03-iS.js} +135 -17
  30. package/dist/runtime/schema-1Zs03-iS.js.map +1 -0
  31. package/dist/runtime/server.d.ts +9 -3
  32. package/dist/runtime/server.js +5 -3
  33. package/dist/runtime/server.js.map +1 -1
  34. package/dist/runtime/{sync-a2EdGSdY.d.ts → sync-Bs8J3fIr.d.ts} +2 -2
  35. package/package.json +4 -4
  36. package/src/cli/agent-files.ts +8 -0
  37. package/src/cli/auth-client.ts +1 -1
  38. package/src/cli/bin.ts +13 -3
  39. package/src/cli/build/server.ts +102 -13
  40. package/src/cli/codegen.ts +7 -4
  41. package/src/cli/control-client.ts +30 -8
  42. package/src/cli/deploy.ts +7 -2
  43. package/src/cli/environment.ts +133 -0
  44. package/src/client/files.ts +43 -27
  45. package/src/client/hooks.ts +94 -17
  46. package/src/client/id.ts +259 -0
  47. package/src/client/index.ts +5 -2
  48. package/src/client/page-observers.ts +77 -0
  49. package/src/client/sync.ts +214 -69
  50. package/src/dev-runtime/functions.ts +232 -86
  51. package/src/dev-runtime/id.ts +174 -2
  52. package/src/dev-runtime/query-cache.ts +105 -0
  53. package/src/dev-runtime/sync.ts +187 -26
  54. package/src/server/index.ts +13 -1
  55. package/dist/runtime/api-DzcR7spt.js.map +0 -1
  56. package/dist/runtime/descriptor-C5VA9qRl-DuQsowaQ.js +0 -311
  57. package/dist/runtime/descriptor-C5VA9qRl-DuQsowaQ.js.map +0 -1
  58. package/dist/runtime/file-C1abuMgd.js +0 -173
  59. package/dist/runtime/file-C1abuMgd.js.map +0 -1
  60. package/dist/runtime/pagination-CFJ3xlAt.d.ts +0 -1
  61. package/dist/runtime/schema-ERFjT8-m.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { g as runtimeFileOccurrencesOf, y as GeneratedId } from "../file-C1abuMgd.js";
2
- import { _ as TransportObjectTypeSchema, a as PaginationCursor, f as documentNotFound, g as resultFromEffect, o as PaginationPageSize, u as ErrorValueSchema, v as datePathsOf, y as datePathsOfObject } from "../descriptor-C5VA9qRl-DuQsowaQ.js";
3
- import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-ERFjT8-m.js";
1
+ import { C as TransportObjectTypeSchema, S as resultFromEffect, T as datePathsOfObject, V as runtimeFileOccurrencesOf, W as GeneratedId, g as ErrorValueSchema, s as User, u as makeIdContext, v as documentNotFound, w as datePathsOf } from "../id-Bt9XWRGL.js";
2
+ import { o as PaginationCursor, s as PaginationPageSize } from "../descriptor-Cyo9FP9n-C0SRVXNW.js";
3
+ import { c as getFunctionSchema, o as emptyEnv, r as decodeDefinedEnvironment, s as getFunctionEnvironment, t as SchemaDefinitionTypeId } from "../schema-1Zs03-iS.js";
4
4
  import { Effect, Predicate, Schema } from "effect";
5
5
  //#region ../contracts/dist/runtime/host.js
6
6
  const HostDocument = Schema.Struct({
@@ -74,7 +74,7 @@ const HostReplace = Schema.Struct({
74
74
  id: GeneratedId,
75
75
  fields: Schema.JsonObject
76
76
  });
77
- const QuickJsHostRequest = Schema.Union([
77
+ const DatabaseHostRequest = Schema.Union([
78
78
  HostCollect,
79
79
  HostQuery,
80
80
  HostPaginate,
@@ -84,6 +84,12 @@ const QuickJsHostRequest = Schema.Union([
84
84
  HostPatch,
85
85
  HostReplace
86
86
  ]);
87
+ const HostReadId = Schema.Struct({ type: Schema.Literal("ReadId") });
88
+ const QuickJsHostRequest = Schema.Union([DatabaseHostRequest, HostReadId]);
89
+ const HostIdentity = Schema.Struct({
90
+ type: Schema.Literal("Identity"),
91
+ user: Schema.NullOr(User)
92
+ });
87
93
  const HostDocuments = Schema.Struct({
88
94
  type: Schema.Literal("Documents"),
89
95
  documents: Schema.Array(HostDocument)
@@ -106,6 +112,7 @@ const HostCompleted = Schema.Struct({
106
112
  found: Schema.Boolean
107
113
  });
108
114
  Schema.Union([
115
+ HostIdentity,
109
116
  HostDocuments,
110
117
  HostPage,
111
118
  HostFound,
@@ -119,7 +126,8 @@ const decodeHostResponse = Schema.decodeEffect(Schema.fromJsonString(Schema.Unio
119
126
  HostPage,
120
127
  HostFound,
121
128
  HostInserted,
122
- HostCompleted
129
+ HostCompleted,
130
+ HostIdentity
123
131
  ])));
124
132
  const encodeHostRequest = Schema.encodeSync(Schema.fromJsonString(QuickJsHostRequest));
125
133
  const callHost = Effect.fn("Guest.callHost")(function* (call, request) {
@@ -378,9 +386,11 @@ const encodeFailure = Effect.fn("Guest.encodeFailure")(function* (definition, er
378
386
  dates
379
387
  };
380
388
  });
381
- const runGuest = Effect.fn("Guest.invoke")(function* (definition, encodedArgs, call) {
389
+ const runGuest = Effect.fn("Guest.invoke")(function* (definition, encodedArgs, call, rawEnvironment) {
382
390
  const schema = getFunctionSchema(definition);
383
391
  if (schema === void 0) return yield* Effect.die("The function has no bound schema.");
392
+ const environmentDefinition = getFunctionEnvironment(definition) ?? emptyEnv;
393
+ const environment = yield* decodeDefinedEnvironment(environmentDefinition, rawEnvironment).pipe(Effect.mapError(() => /* @__PURE__ */ new Error("The deployment environment is invalid.")));
384
394
  const decodedArgs = yield* Schema.decodeEffect(Schema.toCodecJson(guestCodec(Schema.Struct(definition.args ?? {}))))(encodedArgs).pipe(Effect.match({
385
395
  onFailure: () => ({ valid: false }),
386
396
  onSuccess: (value) => ({
@@ -394,13 +404,17 @@ const runGuest = Effect.fn("Guest.invoke")(function* (definition, encodedArgs, c
394
404
  message: "The invocation arguments do not match the function definition."
395
405
  };
396
406
  const args = yield* Schema.decodeUnknownEffect(Schema.ObjectKeyword)(decodedArgs.value);
397
- const context = Object.freeze({ db: definition._tag === "Query" ? makeReader(schema, call) : makeWriter(schema, call) });
407
+ const context = Object.freeze({
408
+ db: definition._tag === "Query" ? makeReader(schema, call) : makeWriter(schema, call),
409
+ env: environment,
410
+ id: makeIdContext(callHost(call, { type: "ReadId" }).pipe(Effect.flatMap((response) => response.type === "Identity" ? Effect.succeed(response.user) : Effect.die("The ID response is invalid."))))
411
+ });
398
412
  return yield* Effect.gen(() => definition.handler(context, args)).pipe(Effect.matchEffect({
399
413
  onFailure: (error) => encodeFailure(definition, error),
400
414
  onSuccess: (value) => encodeSuccess(definition, value)
401
415
  }));
402
416
  });
403
- const invoke = (definition, encodedArgs, call) => Effect.runPromise(runGuest(definition, encodedArgs, call)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));
417
+ const invoke = (definition, encodedArgs, call, rawEnvironment = {}) => Effect.runPromise(runGuest(definition, encodedArgs, call, rawEnvironment)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));
404
418
  //#endregion
405
419
  export { invoke };
406
420
 
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","names":[],"sources":["../../../../contracts/dist/runtime/host.js","../../../../runtime/dist/guest.js"],"sourcesContent":["import { GeneratedId } from \"./id.js\";\nimport { PaginationCursor, PaginationPageSize } from \"./pagination.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/host.ts\nconst HostDocument = Schema.Struct({\n\tid: GeneratedId,\n\tcreatedAt: Schema.Int,\n\tupdatedAt: Schema.Int,\n\tfields: Schema.JsonObject\n});\nconst HostCollect = Schema.Struct({\n\ttype: Schema.Literal(\"Collect\"),\n\ttable: Schema.String\n});\nconst HostIndexComparison = Schema.Struct({\n\tfield: Schema.String,\n\tvalue: Schema.Json\n});\nconst HostIndexRange = Schema.Struct({\n\tequal: Schema.Array(HostIndexComparison),\n\tlower: Schema.optional(Schema.Struct({\n\t\t...HostIndexComparison.fields,\n\t\tinclusive: Schema.Boolean\n\t})),\n\tupper: Schema.optional(Schema.Struct({\n\t\t...HostIndexComparison.fields,\n\t\tinclusive: Schema.Boolean\n\t}))\n});\nconst HostQuery = Schema.Struct({\n\ttype: Schema.Literal(\"Query\"),\n\ttable: Schema.String,\n\tindex: Schema.optional(Schema.String),\n\trange: Schema.optional(HostIndexRange),\n\torder: Schema.Literals([\"Asc\", \"Desc\"]),\n\tlimit: Schema.optional(Schema.Natural)\n});\nconst HostPaginate = Schema.Struct({\n\ttype: Schema.Literal(\"Paginate\"),\n\ttable: Schema.String,\n\tindex: Schema.optional(Schema.String),\n\trange: Schema.optional(HostIndexRange),\n\torder: Schema.Literals([\"Asc\", \"Desc\"]),\n\tpagination: Schema.Struct({\n\t\tcursor: Schema.NullOr(PaginationCursor),\n\t\tpageSize: PaginationPageSize\n\t})\n});\nconst HostFind = Schema.Struct({\n\ttype: Schema.Literal(\"Find\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostInsert = Schema.Struct({\n\ttype: Schema.Literal(\"Insert\"),\n\ttable: Schema.String,\n\tfields: Schema.JsonObject\n});\nconst HostDelete = Schema.Struct({\n\ttype: Schema.Literal(\"Delete\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostPatch = Schema.Struct({\n\ttype: Schema.Literal(\"Patch\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst HostReplace = Schema.Struct({\n\ttype: Schema.Literal(\"Replace\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst QuickJsHostRequest = Schema.Union([\n\tHostCollect,\n\tHostQuery,\n\tHostPaginate,\n\tHostFind,\n\tHostInsert,\n\tHostDelete,\n\tHostPatch,\n\tHostReplace\n]);\nconst HostDocuments = Schema.Struct({\n\ttype: Schema.Literal(\"Documents\"),\n\tdocuments: Schema.Array(HostDocument)\n});\nconst HostPage = Schema.Struct({\n\ttype: Schema.Literal(\"Page\"),\n\tdocuments: Schema.Array(HostDocument),\n\tnextCursor: Schema.NullOr(PaginationCursor)\n});\nconst HostFound = Schema.Struct({\n\ttype: Schema.Literal(\"Found\"),\n\tdocument: Schema.NullOr(HostDocument)\n});\nconst HostInserted = Schema.Struct({\n\ttype: Schema.Literal(\"Inserted\"),\n\tid: GeneratedId\n});\nconst HostCompleted = Schema.Struct({\n\ttype: Schema.Literal(\"Completed\"),\n\tfound: Schema.Boolean\n});\nconst QuickJsHostResponse = Schema.Union([\n\tHostDocuments,\n\tHostPage,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted\n]);\n//#endregion\nexport { HostCollect, HostCompleted, HostDelete, HostDocument, HostDocuments, HostFind, HostFound, HostIndexComparison, HostIndexRange, HostInsert, HostInserted, HostPage, HostPaginate, HostPatch, HostQuery, HostReplace, QuickJsHostRequest, QuickJsHostResponse };\n\n//# sourceMappingURL=host.js.map","import { HostCompleted, HostDocuments, HostFound, HostInserted, HostPage, QuickJsHostRequest } from \"@ignotum/contracts/runtime/host\";\nimport { runtimeFileOccurrencesOf } from \"@ignotum/contracts/schema/file\";\nimport { GeneratedId } from \"@ignotum/contracts/runtime/id\";\nimport { Effect, Predicate, Schema } from \"effect\";\nimport { ErrorValueSchema, documentNotFound, resultFromEffect } from \"@ignotum/contracts/runtime/result\";\nimport { getFunctionSchema } from \"@ignotum/contracts/runtime/schema\";\nimport { TransportObjectTypeSchema, datePathsOf, datePathsOfObject } from \"@ignotum/contracts/runtime/value\";\nimport { SchemaDefinitionTypeId } from \"@ignotum/contracts/schema\";\n//#region src/guest.ts\nconst decodeHostResponse = Schema.decodeEffect(Schema.fromJsonString(Schema.Union([\n\tHostDocuments,\n\tHostPage,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted\n])));\nconst encodeHostRequest = Schema.encodeSync(Schema.fromJsonString(QuickJsHostRequest));\nconst callHost = Effect.fn(\"Guest.callHost\")(function* (call, request) {\n\treturn yield* Effect.tryPromise(() => call(encodeHostRequest(request))).pipe(Effect.flatMap(decodeHostResponse), Effect.orDie);\n});\nconst tableFor = (schema, table) => {\n\tconst definition = schema[SchemaDefinitionTypeId][table];\n\tif (definition === void 0) throw new Error(`Unknown database table '${table}'.`);\n\treturn definition;\n};\nconst guestCodec = (schema) => schema;\nconst encodeFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeUnknownSync(Schema.JsonObject)(Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(definition.schema)), { onExcessProperty: \"error\" })(fields));\n};\nconst encodePatchFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeSync(Schema.JsonObject)(Object.fromEntries(Object.entries(fields).map(([name, value]) => {\n\t\tconst field = definition.fields[name];\n\t\tif (field === void 0) throw new Error(`Unknown field '${name}' on table '${table}'.`);\n\t\treturn [name, Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(field)))(value)];\n\t})));\n};\nconst documentCodec = (schema, table) => guestCodec(Schema.Struct({\n\t...tableFor(schema, table).fields,\n\tid: Schema.String,\n\tcreatedAt: Schema.DateFromMillis,\n\tupdatedAt: Schema.DateFromMillis\n}));\nconst decodeDocument = (schema, table, document) => Schema.decodeUnknownSync(TransportObjectTypeSchema)(Schema.decodeSync(Schema.toCodecJson(documentCodec(schema, table)))({\n\t...document.fields,\n\tid: document.id,\n\tcreatedAt: document.createdAt,\n\tupdatedAt: document.updatedAt\n}));\nconst expectResponse = (response, tag) => {\n\tif (response.type !== tag) throw new Error(`Unexpected host response '${response.type}'.`);\n\treturn response;\n};\nconst makeReader = (schema, call) => {\n\tconst findEffect = (table, id) => callHost(call, {\n\t\ttype: \"Find\",\n\t\ttable,\n\t\tid: GeneratedId.make(id)\n\t}).pipe(Effect.map((response) => expectResponse(response, \"Found\")), Effect.map(({ document }) => document === null ? void 0 : decodeDocument(schema, table, document)));\n\tconst query = (table, selectedIndex, selectedRange, order = \"Asc\") => {\n\t\tconst definition = tableFor(schema, table);\n\t\tconst encodeIndexValue = (field, value) => {\n\t\t\tconst codec = field === \"createdAt\" ? Schema.DateFromMillis : field === \"id\" ? GeneratedId : definition.fields[field];\n\t\t\tif (codec === void 0) throw new Error(`Unknown index field '${field}'.`);\n\t\t\treturn Schema.decodeUnknownSync(Schema.Json)(Schema.encodeUnknownSync(guestCodec(codec))(value));\n\t\t};\n\t\tconst execute = (limit) => {\n\t\t\tconst request = selectedIndex === void 0 ? {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\torder\n\t\t\t} : selectedRange === void 0 ? {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\torder\n\t\t\t} : {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\trange: selectedRange,\n\t\t\t\torder\n\t\t\t};\n\t\t\treturn callHost(call, limit === void 0 ? request : {\n\t\t\t\t...request,\n\t\t\t\tlimit\n\t\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Documents\")), Effect.map(({ documents }) => documents.map((document) => decodeDocument(schema, table, document))));\n\t\t};\n\t\tconst executePage = (pagination) => {\n\t\t\treturn callHost(call, selectedIndex === void 0 ? {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t} : selectedRange === void 0 ? {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t} : {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\trange: selectedRange,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Page\")), Effect.map(({ documents, nextCursor }) => ({\n\t\t\t\titems: documents.map((document) => decodeDocument(schema, table, document)),\n\t\t\t\tnextCursor\n\t\t\t})));\n\t\t};\n\t\tconst validateLimit = (count) => {\n\t\t\tif (!Number.isInteger(count) || count < 0 || count > 1e3) throw new Error(\"Query limits must be integers between 0 and 1000.\");\n\t\t\treturn count;\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tindex: (name, buildRange) => {\n\t\t\t\tif (selectedIndex !== void 0) throw new Error(\"A query can select only one index.\");\n\t\t\t\tconst index = definition.indexes[name];\n\t\t\t\tif (index === void 0) throw new Error(`Unknown index '${name}' on table '${table}'.`);\n\t\t\t\tif (buildRange === void 0) return query(table, name, void 0, order);\n\t\t\t\tconst fields = [\n\t\t\t\t\t...index.fields,\n\t\t\t\t\t\"createdAt\",\n\t\t\t\t\t\"id\"\n\t\t\t\t];\n\t\t\t\tconst range = { equal: [] };\n\t\t\t\tlet position = 0;\n\t\t\t\tlet boundedField;\n\t\t\t\tconst expectField = (field) => {\n\t\t\t\t\tconst expected = fields[position];\n\t\t\t\t\tif (field !== expected) throw new Error(`Expected index field '${expected}', received '${field}'.`);\n\t\t\t\t};\n\t\t\t\tconst builder = {\n\t\t\t\t\teq: (field, value) => {\n\t\t\t\t\t\tif (boundedField !== void 0) throw new Error(\"Equality cannot follow an index bound.\");\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\trange.equal.push({\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value)\n\t\t\t\t\t\t});\n\t\t\t\t\t\tposition += 1;\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tgt: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.lower !== void 0) throw new Error(\"An index range has only one lower bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.lower = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: false\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tgte: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.lower !== void 0) throw new Error(\"An index range has only one lower bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.lower = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: true\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tlt: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.upper !== void 0) throw new Error(\"An index range has only one upper bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.upper = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: false\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tlte: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.upper !== void 0) throw new Error(\"An index range has only one upper bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.upper = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: true\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst built = buildRange(builder);\n\t\t\t\tif (!Predicate.isObject(built)) throw new Error(\"An index range callback must return its builder.\");\n\t\t\t\treturn query(table, name, range, order);\n\t\t\t},\n\t\t\torder: (direction) => query(table, selectedIndex, selectedRange, direction === \"asc\" ? \"Asc\" : \"Desc\"),\n\t\t\tcollect: () => resultFromEffect(execute()),\n\t\t\ttake: (count) => resultFromEffect(execute(validateLimit(count))),\n\t\t\tfirst: () => resultFromEffect(execute(1).pipe(Effect.map((documents) => documents[0]))),\n\t\t\tunique: () => resultFromEffect(execute(2).pipe(Effect.flatMap((documents) => documents.length > 1 ? Effect.die(/* @__PURE__ */ new Error(\"A unique database query matched more than one document.\")) : Effect.succeed(documents[0])))),\n\t\t\tpaginate: (options) => resultFromEffect(executePage(options))\n\t\t});\n\t};\n\treturn Object.freeze({\n\t\tfind: (table, id) => resultFromEffect(findEffect(table, id)),\n\t\tget: (table, id) => resultFromEffect(findEffect(table, id).pipe(Effect.flatMap((document) => document === void 0 ? Effect.fail(documentNotFound(table, id)) : Effect.succeed(document)))),\n\t\tquery: (table) => query(table)\n\t});\n};\nconst makeWriter = (schema, call) => {\n\tconst reader = makeReader(schema, call);\n\tconst complete = Effect.fn(\"Guest.completeWrite\")(function* (table, id, request) {\n\t\tif (expectResponse(yield* callHost(call, request), \"Completed\").found === false) return yield* Effect.fail(documentNotFound(table, id));\n\t});\n\tconst writer = {\n\t\t...reader,\n\t\tdelete: (table, id) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Delete\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id)\n\t\t})),\n\t\tinsert: (table, value) => resultFromEffect(callHost(call, {\n\t\t\ttype: \"Insert\",\n\t\t\ttable,\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Inserted\").id))),\n\t\tpatch: (table, id, value) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Patch\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodePatchFields(schema, table, value)\n\t\t})),\n\t\treplace: (table, id, value) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Replace\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}))\n\t};\n\treturn Object.freeze(writer);\n};\nconst encodeSuccess = Effect.fn(\"Guest.encodeSuccess\")(function* (definition, value) {\n\tif (definition.returns === void 0) {\n\t\tyield* Schema.encodeUnknownEffect(Schema.Undefined)(value);\n\t\treturn { type: \"Success\" };\n\t}\n\tconst encoded = yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value);\n\tconst files = runtimeFileOccurrencesOf(value);\n\tconst result = files.length === 0 ? {\n\t\ttype: \"Success\",\n\t\tvalue: encoded\n\t} : {\n\t\ttype: \"Success\",\n\t\tvalue: encoded,\n\t\tfiles\n\t};\n\tconst dates = datePathsOf(value);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst encodeFailure = Effect.fn(\"Guest.encodeFailure\")(function* (definition, error) {\n\tconst result = {\n\t\ttype: \"Failure\",\n\t\terror: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.errors ?? ErrorValueSchema))(error)\n\t};\n\tconst dates = datePathsOfObject(error);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst runGuest = Effect.fn(\"Guest.invoke\")(function* (definition, encodedArgs, call) {\n\tconst schema = getFunctionSchema(definition);\n\tif (schema === void 0) return yield* Effect.die(\"The function has no bound schema.\");\n\tconst decodedArgs = yield* Schema.decodeEffect(Schema.toCodecJson(guestCodec(Schema.Struct(definition.args ?? {}))))(encodedArgs).pipe(Effect.match({\n\t\tonFailure: () => ({ valid: false }),\n\t\tonSuccess: (value) => ({\n\t\t\tvalid: true,\n\t\t\tvalue\n\t\t})\n\t}));\n\tif (!decodedArgs.valid) return {\n\t\ttype: \"InvocationRejected\",\n\t\tcode: \"InvalidArguments\",\n\t\tmessage: \"The invocation arguments do not match the function definition.\"\n\t};\n\tconst args = yield* Schema.decodeUnknownEffect(Schema.ObjectKeyword)(decodedArgs.value);\n\tconst context = Object.freeze({ db: definition._tag === \"Query\" ? makeReader(schema, call) : makeWriter(schema, call) });\n\treturn yield* Effect.gen(() => definition.handler(context, args)).pipe(Effect.matchEffect({\n\t\tonFailure: (error) => encodeFailure(definition, error),\n\t\tonSuccess: (value) => encodeSuccess(definition, value)\n\t}));\n});\nconst invoke = (definition, encodedArgs, call) => Effect.runPromise(runGuest(definition, encodedArgs, call)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));\n//#endregion\nexport { invoke };\n\n//# sourceMappingURL=guest.js.map"],"mappings":";;;;;AAIA,MAAM,eAAe,OAAO,OAAO;CAClC,IAAI;CACJ,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,QAAQ,OAAO;AAChB,CAAC;AACD,MAAM,cAAc,OAAO,OAAO;CACjC,MAAM,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;EACpC,GAAG;EACH;CACD;AACD,CAAC;AACD,MAAM,WAAW,OAAO,GAAG,cAAc,CAAC,CAAC,WAAW,YAAY,aAAa,MAAM;CACpF,MAAM,SAAS,kBAAkB,UAAU;CAC3C,IAAI,WAAW,KAAK,GAAG,OAAO,OAAO,OAAO,IAAI,mCAAmC;CACnF,MAAM,cAAc,OAAO,OAAO,aAAa,OAAO,YAAY,WAAW,OAAO,OAAO,WAAW,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,OAAO,MAAM;EACnJ,kBAAkB,EAAE,OAAO,MAAM;EACjC,YAAY,WAAW;GACtB,OAAO;GACP;EACD;CACD,CAAC,CAAC;CACF,IAAI,CAAC,YAAY,OAAO,OAAO;EAC9B,MAAM;EACN,MAAM;EACN,SAAS;CACV;CACA,MAAM,OAAO,OAAO,OAAO,oBAAoB,OAAO,aAAa,CAAC,CAAC,YAAY,KAAK;CACtF,MAAM,UAAU,OAAO,OAAO,EAAE,IAAI,WAAW,SAAS,UAAU,WAAW,QAAQ,IAAI,IAAI,WAAW,QAAQ,IAAI,EAAE,CAAC;CACvH,OAAO,OAAO,OAAO,UAAU,WAAW,QAAQ,SAAS,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,YAAY;EACzF,YAAY,UAAU,cAAc,YAAY,KAAK;EACrD,YAAY,UAAU,cAAc,YAAY,KAAK;CACtD,CAAC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,YAAY,aAAa,SAAS,OAAO,WAAW,SAAS,YAAY,aAAa,IAAI,CAAC,CAAC,CAAC,MAAM,WAAW,OAAO,WAAW,OAAO,eAAe,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC"}
1
+ {"version":3,"file":"host.js","names":[],"sources":["../../../../contracts/dist/runtime/host.js","../../../../runtime/dist/guest.js"],"sourcesContent":["import { GeneratedId } from \"./id.js\";\nimport { User } from \"../id.js\";\nimport { PaginationCursor, PaginationPageSize } from \"./pagination.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/host.ts\nconst HostDocument = Schema.Struct({\n\tid: GeneratedId,\n\tcreatedAt: Schema.Int,\n\tupdatedAt: Schema.Int,\n\tfields: Schema.JsonObject\n});\nconst HostCollect = Schema.Struct({\n\ttype: Schema.Literal(\"Collect\"),\n\ttable: Schema.String\n});\nconst HostIndexComparison = Schema.Struct({\n\tfield: Schema.String,\n\tvalue: Schema.Json\n});\nconst HostIndexRange = Schema.Struct({\n\tequal: Schema.Array(HostIndexComparison),\n\tlower: Schema.optional(Schema.Struct({\n\t\t...HostIndexComparison.fields,\n\t\tinclusive: Schema.Boolean\n\t})),\n\tupper: Schema.optional(Schema.Struct({\n\t\t...HostIndexComparison.fields,\n\t\tinclusive: Schema.Boolean\n\t}))\n});\nconst HostQuery = Schema.Struct({\n\ttype: Schema.Literal(\"Query\"),\n\ttable: Schema.String,\n\tindex: Schema.optional(Schema.String),\n\trange: Schema.optional(HostIndexRange),\n\torder: Schema.Literals([\"Asc\", \"Desc\"]),\n\tlimit: Schema.optional(Schema.Natural)\n});\nconst HostPaginate = Schema.Struct({\n\ttype: Schema.Literal(\"Paginate\"),\n\ttable: Schema.String,\n\tindex: Schema.optional(Schema.String),\n\trange: Schema.optional(HostIndexRange),\n\torder: Schema.Literals([\"Asc\", \"Desc\"]),\n\tpagination: Schema.Struct({\n\t\tcursor: Schema.NullOr(PaginationCursor),\n\t\tpageSize: PaginationPageSize\n\t})\n});\nconst HostFind = Schema.Struct({\n\ttype: Schema.Literal(\"Find\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostInsert = Schema.Struct({\n\ttype: Schema.Literal(\"Insert\"),\n\ttable: Schema.String,\n\tfields: Schema.JsonObject\n});\nconst HostDelete = Schema.Struct({\n\ttype: Schema.Literal(\"Delete\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostPatch = Schema.Struct({\n\ttype: Schema.Literal(\"Patch\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst HostReplace = Schema.Struct({\n\ttype: Schema.Literal(\"Replace\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst DatabaseHostRequest = Schema.Union([\n\tHostCollect,\n\tHostQuery,\n\tHostPaginate,\n\tHostFind,\n\tHostInsert,\n\tHostDelete,\n\tHostPatch,\n\tHostReplace\n]);\nconst HostReadId = Schema.Struct({ type: Schema.Literal(\"ReadId\") });\nconst QuickJsHostRequest = Schema.Union([DatabaseHostRequest, HostReadId]);\nconst HostIdentity = Schema.Struct({\n\ttype: Schema.Literal(\"Identity\"),\n\tuser: Schema.NullOr(User)\n});\nconst HostDocuments = Schema.Struct({\n\ttype: Schema.Literal(\"Documents\"),\n\tdocuments: Schema.Array(HostDocument)\n});\nconst HostPage = Schema.Struct({\n\ttype: Schema.Literal(\"Page\"),\n\tdocuments: Schema.Array(HostDocument),\n\tnextCursor: Schema.NullOr(PaginationCursor)\n});\nconst HostFound = Schema.Struct({\n\ttype: Schema.Literal(\"Found\"),\n\tdocument: Schema.NullOr(HostDocument)\n});\nconst HostInserted = Schema.Struct({\n\ttype: Schema.Literal(\"Inserted\"),\n\tid: GeneratedId\n});\nconst HostCompleted = Schema.Struct({\n\ttype: Schema.Literal(\"Completed\"),\n\tfound: Schema.Boolean\n});\nconst QuickJsHostResponse = Schema.Union([\n\tHostIdentity,\n\tHostDocuments,\n\tHostPage,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted\n]);\n//#endregion\nexport { DatabaseHostRequest, HostCollect, HostCompleted, HostDelete, HostDocument, HostDocuments, HostFind, HostFound, HostIdentity, HostIndexComparison, HostIndexRange, HostInsert, HostInserted, HostPage, HostPaginate, HostPatch, HostQuery, HostReadId, HostReplace, QuickJsHostRequest, QuickJsHostResponse };\n\n//# sourceMappingURL=host.js.map","import { HostCompleted, HostDocuments, HostFound, HostIdentity, HostInserted, HostPage, QuickJsHostRequest } from \"@ignotum/contracts/runtime/host\";\nimport { runtimeFileOccurrencesOf } from \"@ignotum/contracts/schema/file\";\nimport { GeneratedId } from \"@ignotum/contracts/runtime/id\";\nimport { Effect, Predicate, Schema } from \"effect\";\nimport { makeIdContext } from \"@ignotum/contracts/id\";\nimport { ErrorValueSchema, documentNotFound, resultFromEffect } from \"@ignotum/contracts/runtime/result\";\nimport { getFunctionEnvironment, getFunctionSchema } from \"@ignotum/contracts/runtime/schema\";\nimport { SchemaDefinitionTypeId, decodeDefinedEnvironment, emptyEnv } from \"@ignotum/contracts/schema\";\nimport { TransportObjectTypeSchema, datePathsOf, datePathsOfObject } from \"@ignotum/contracts/runtime/value\";\n//#region src/guest.ts\nconst decodeHostResponse = Schema.decodeEffect(Schema.fromJsonString(Schema.Union([\n\tHostDocuments,\n\tHostPage,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted,\n\tHostIdentity\n])));\nconst encodeHostRequest = Schema.encodeSync(Schema.fromJsonString(QuickJsHostRequest));\nconst callHost = Effect.fn(\"Guest.callHost\")(function* (call, request) {\n\treturn yield* Effect.tryPromise(() => call(encodeHostRequest(request))).pipe(Effect.flatMap(decodeHostResponse), Effect.orDie);\n});\nconst tableFor = (schema, table) => {\n\tconst definition = schema[SchemaDefinitionTypeId][table];\n\tif (definition === void 0) throw new Error(`Unknown database table '${table}'.`);\n\treturn definition;\n};\nconst guestCodec = (schema) => schema;\nconst encodeFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeUnknownSync(Schema.JsonObject)(Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(definition.schema)), { onExcessProperty: \"error\" })(fields));\n};\nconst encodePatchFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeSync(Schema.JsonObject)(Object.fromEntries(Object.entries(fields).map(([name, value]) => {\n\t\tconst field = definition.fields[name];\n\t\tif (field === void 0) throw new Error(`Unknown field '${name}' on table '${table}'.`);\n\t\treturn [name, Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(field)))(value)];\n\t})));\n};\nconst documentCodec = (schema, table) => guestCodec(Schema.Struct({\n\t...tableFor(schema, table).fields,\n\tid: Schema.String,\n\tcreatedAt: Schema.DateFromMillis,\n\tupdatedAt: Schema.DateFromMillis\n}));\nconst decodeDocument = (schema, table, document) => Schema.decodeUnknownSync(TransportObjectTypeSchema)(Schema.decodeSync(Schema.toCodecJson(documentCodec(schema, table)))({\n\t...document.fields,\n\tid: document.id,\n\tcreatedAt: document.createdAt,\n\tupdatedAt: document.updatedAt\n}));\nconst expectResponse = (response, tag) => {\n\tif (response.type !== tag) throw new Error(`Unexpected host response '${response.type}'.`);\n\treturn response;\n};\nconst makeReader = (schema, call) => {\n\tconst findEffect = (table, id) => callHost(call, {\n\t\ttype: \"Find\",\n\t\ttable,\n\t\tid: GeneratedId.make(id)\n\t}).pipe(Effect.map((response) => expectResponse(response, \"Found\")), Effect.map(({ document }) => document === null ? void 0 : decodeDocument(schema, table, document)));\n\tconst query = (table, selectedIndex, selectedRange, order = \"Asc\") => {\n\t\tconst definition = tableFor(schema, table);\n\t\tconst encodeIndexValue = (field, value) => {\n\t\t\tconst codec = field === \"createdAt\" ? Schema.DateFromMillis : field === \"id\" ? GeneratedId : definition.fields[field];\n\t\t\tif (codec === void 0) throw new Error(`Unknown index field '${field}'.`);\n\t\t\treturn Schema.decodeUnknownSync(Schema.Json)(Schema.encodeUnknownSync(guestCodec(codec))(value));\n\t\t};\n\t\tconst execute = (limit) => {\n\t\t\tconst request = selectedIndex === void 0 ? {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\torder\n\t\t\t} : selectedRange === void 0 ? {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\torder\n\t\t\t} : {\n\t\t\t\ttype: \"Query\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\trange: selectedRange,\n\t\t\t\torder\n\t\t\t};\n\t\t\treturn callHost(call, limit === void 0 ? request : {\n\t\t\t\t...request,\n\t\t\t\tlimit\n\t\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Documents\")), Effect.map(({ documents }) => documents.map((document) => decodeDocument(schema, table, document))));\n\t\t};\n\t\tconst executePage = (pagination) => {\n\t\t\treturn callHost(call, selectedIndex === void 0 ? {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t} : selectedRange === void 0 ? {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t} : {\n\t\t\t\ttype: \"Paginate\",\n\t\t\t\ttable,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\trange: selectedRange,\n\t\t\t\torder,\n\t\t\t\tpagination\n\t\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Page\")), Effect.map(({ documents, nextCursor }) => ({\n\t\t\t\titems: documents.map((document) => decodeDocument(schema, table, document)),\n\t\t\t\tnextCursor\n\t\t\t})));\n\t\t};\n\t\tconst validateLimit = (count) => {\n\t\t\tif (!Number.isInteger(count) || count < 0 || count > 1e3) throw new Error(\"Query limits must be integers between 0 and 1000.\");\n\t\t\treturn count;\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tindex: (name, buildRange) => {\n\t\t\t\tif (selectedIndex !== void 0) throw new Error(\"A query can select only one index.\");\n\t\t\t\tconst index = definition.indexes[name];\n\t\t\t\tif (index === void 0) throw new Error(`Unknown index '${name}' on table '${table}'.`);\n\t\t\t\tif (buildRange === void 0) return query(table, name, void 0, order);\n\t\t\t\tconst fields = [\n\t\t\t\t\t...index.fields,\n\t\t\t\t\t\"createdAt\",\n\t\t\t\t\t\"id\"\n\t\t\t\t];\n\t\t\t\tconst range = { equal: [] };\n\t\t\t\tlet position = 0;\n\t\t\t\tlet boundedField;\n\t\t\t\tconst expectField = (field) => {\n\t\t\t\t\tconst expected = fields[position];\n\t\t\t\t\tif (field !== expected) throw new Error(`Expected index field '${expected}', received '${field}'.`);\n\t\t\t\t};\n\t\t\t\tconst builder = {\n\t\t\t\t\teq: (field, value) => {\n\t\t\t\t\t\tif (boundedField !== void 0) throw new Error(\"Equality cannot follow an index bound.\");\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\trange.equal.push({\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value)\n\t\t\t\t\t\t});\n\t\t\t\t\t\tposition += 1;\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tgt: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.lower !== void 0) throw new Error(\"An index range has only one lower bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.lower = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: false\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tgte: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.lower !== void 0) throw new Error(\"An index range has only one lower bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.lower = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: true\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tlt: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.upper !== void 0) throw new Error(\"An index range has only one upper bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.upper = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: false\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t},\n\t\t\t\t\tlte: (field, value) => {\n\t\t\t\t\t\texpectField(field);\n\t\t\t\t\t\tif (range.upper !== void 0) throw new Error(\"An index range has only one upper bound.\");\n\t\t\t\t\t\tboundedField = field;\n\t\t\t\t\t\trange.upper = {\n\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\tvalue: encodeIndexValue(field, value),\n\t\t\t\t\t\t\tinclusive: true\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn builder;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst built = buildRange(builder);\n\t\t\t\tif (!Predicate.isObject(built)) throw new Error(\"An index range callback must return its builder.\");\n\t\t\t\treturn query(table, name, range, order);\n\t\t\t},\n\t\t\torder: (direction) => query(table, selectedIndex, selectedRange, direction === \"asc\" ? \"Asc\" : \"Desc\"),\n\t\t\tcollect: () => resultFromEffect(execute()),\n\t\t\ttake: (count) => resultFromEffect(execute(validateLimit(count))),\n\t\t\tfirst: () => resultFromEffect(execute(1).pipe(Effect.map((documents) => documents[0]))),\n\t\t\tunique: () => resultFromEffect(execute(2).pipe(Effect.flatMap((documents) => documents.length > 1 ? Effect.die(/* @__PURE__ */ new Error(\"A unique database query matched more than one document.\")) : Effect.succeed(documents[0])))),\n\t\t\tpaginate: (options) => resultFromEffect(executePage(options))\n\t\t});\n\t};\n\treturn Object.freeze({\n\t\tfind: (table, id) => resultFromEffect(findEffect(table, id)),\n\t\tget: (table, id) => resultFromEffect(findEffect(table, id).pipe(Effect.flatMap((document) => document === void 0 ? Effect.fail(documentNotFound(table, id)) : Effect.succeed(document)))),\n\t\tquery: (table) => query(table)\n\t});\n};\nconst makeWriter = (schema, call) => {\n\tconst reader = makeReader(schema, call);\n\tconst complete = Effect.fn(\"Guest.completeWrite\")(function* (table, id, request) {\n\t\tif (expectResponse(yield* callHost(call, request), \"Completed\").found === false) return yield* Effect.fail(documentNotFound(table, id));\n\t});\n\tconst writer = {\n\t\t...reader,\n\t\tdelete: (table, id) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Delete\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id)\n\t\t})),\n\t\tinsert: (table, value) => resultFromEffect(callHost(call, {\n\t\t\ttype: \"Insert\",\n\t\t\ttable,\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Inserted\").id))),\n\t\tpatch: (table, id, value) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Patch\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodePatchFields(schema, table, value)\n\t\t})),\n\t\treplace: (table, id, value) => resultFromEffect(complete(table, id, {\n\t\t\ttype: \"Replace\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}))\n\t};\n\treturn Object.freeze(writer);\n};\nconst encodeSuccess = Effect.fn(\"Guest.encodeSuccess\")(function* (definition, value) {\n\tif (definition.returns === void 0) {\n\t\tyield* Schema.encodeUnknownEffect(Schema.Undefined)(value);\n\t\treturn { type: \"Success\" };\n\t}\n\tconst encoded = yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value);\n\tconst files = runtimeFileOccurrencesOf(value);\n\tconst result = files.length === 0 ? {\n\t\ttype: \"Success\",\n\t\tvalue: encoded\n\t} : {\n\t\ttype: \"Success\",\n\t\tvalue: encoded,\n\t\tfiles\n\t};\n\tconst dates = datePathsOf(value);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst encodeFailure = Effect.fn(\"Guest.encodeFailure\")(function* (definition, error) {\n\tconst result = {\n\t\ttype: \"Failure\",\n\t\terror: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.errors ?? ErrorValueSchema))(error)\n\t};\n\tconst dates = datePathsOfObject(error);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst runGuest = Effect.fn(\"Guest.invoke\")(function* (definition, encodedArgs, call, rawEnvironment) {\n\tconst schema = getFunctionSchema(definition);\n\tif (schema === void 0) return yield* Effect.die(\"The function has no bound schema.\");\n\tconst environmentDefinition = getFunctionEnvironment(definition) ?? emptyEnv;\n\tconst environment = yield* decodeDefinedEnvironment(environmentDefinition, rawEnvironment).pipe(Effect.mapError(() => /* @__PURE__ */ new Error(\"The deployment environment is invalid.\")));\n\tconst decodedArgs = yield* Schema.decodeEffect(Schema.toCodecJson(guestCodec(Schema.Struct(definition.args ?? {}))))(encodedArgs).pipe(Effect.match({\n\t\tonFailure: () => ({ valid: false }),\n\t\tonSuccess: (value) => ({\n\t\t\tvalid: true,\n\t\t\tvalue\n\t\t})\n\t}));\n\tif (!decodedArgs.valid) return {\n\t\ttype: \"InvocationRejected\",\n\t\tcode: \"InvalidArguments\",\n\t\tmessage: \"The invocation arguments do not match the function definition.\"\n\t};\n\tconst args = yield* Schema.decodeUnknownEffect(Schema.ObjectKeyword)(decodedArgs.value);\n\tconst context = Object.freeze({\n\t\tdb: definition._tag === \"Query\" ? makeReader(schema, call) : makeWriter(schema, call),\n\t\tenv: environment,\n\t\tid: makeIdContext(callHost(call, { type: \"ReadId\" }).pipe(Effect.flatMap((response) => response.type === \"Identity\" ? Effect.succeed(response.user) : Effect.die(\"The ID response is invalid.\"))))\n\t});\n\treturn yield* Effect.gen(() => definition.handler(context, args)).pipe(Effect.matchEffect({\n\t\tonFailure: (error) => encodeFailure(definition, error),\n\t\tonSuccess: (value) => encodeSuccess(definition, value)\n\t}));\n});\nconst invoke = (definition, encodedArgs, call, rawEnvironment = {}) => Effect.runPromise(runGuest(definition, encodedArgs, call, rawEnvironment)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));\n//#endregion\nexport { invoke };\n\n//# sourceMappingURL=guest.js.map"],"mappings":";;;;;AAKA,MAAM,eAAe,OAAO,OAAO;CAClC,IAAI;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EACL,IAAI,cAAc,SAAS,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,aAAa,SAAS,SAAS,aAAa,OAAO,QAAQ,SAAS,IAAI,IAAI,OAAO,IAAI,6BAA6B,CAAC,CAAC,CAAC;CAClM,CAAC;CACD,OAAO,OAAO,OAAO,UAAU,WAAW,QAAQ,SAAS,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,YAAY;EACzF,YAAY,UAAU,cAAc,YAAY,KAAK;EACrD,YAAY,UAAU,cAAc,YAAY,KAAK;CACtD,CAAC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,YAAY,aAAa,MAAM,iBAAiB,CAAC,MAAM,OAAO,WAAW,SAAS,YAAY,aAAa,MAAM,cAAc,CAAC,CAAC,CAAC,MAAM,WAAW,OAAO,WAAW,OAAO,eAAe,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as bindSchema$1 } from "../index-2q9FwJud.js";
1
+ import { r as bindSchema$1 } from "../index-D54flWtH.js";
2
2
  //#region src/internal/server.d.ts
3
3
  declare const bindSchema: typeof bindSchema$1;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as bindSchema$1 } from "../schema-ERFjT8-m.js";
1
+ import { n as bindSchema$1 } from "../schema-1Zs03-iS.js";
2
2
  //#region src/internal/server.ts
3
3
  const bindSchema = bindSchema$1;
4
4
  //#endregion
@@ -1,2 +1,2 @@
1
- import { a as Document, c as SchemaDefinitionTypeId, o as Id, s as SchemaDefinitionOf } from "../index-2q9FwJud.js";
1
+ import { c as Id, l as SchemaDefinitionOf, o as Document, u as SchemaDefinitionTypeId } from "../index-D54flWtH.js";
2
2
  export { type Document, type Id, type SchemaDefinitionOf, SchemaDefinitionTypeId };
@@ -1,2 +1,2 @@
1
- import { t as SchemaDefinitionTypeId } from "../schema-ERFjT8-m.js";
1
+ import { t as SchemaDefinitionTypeId } from "../schema-1Zs03-iS.js";
2
2
  export { SchemaDefinitionTypeId };
@@ -1,6 +1,29 @@
1
- import "./id-Cs82tq9Q-hmYFyqTa.js";
2
- import { Schema } from "effect";
3
- //#region ../contracts/dist/descriptor-CEi5Jjiv.d.ts
1
+ import { c as Result$1 } from "./id-BzFHf3Wo-DGPCjgrf.js";
2
+ import { Effect, Schema } from "effect";
3
+ //#region ../contracts/dist/id-W_I1iiJQ.d.ts
4
+ declare const UserId: Schema.brand<Schema.String, "ignotum/id/UserId">;
5
+ type UserId = typeof UserId.Type;
6
+ declare const User: Schema.Struct<{
7
+ readonly id: Schema.brand<Schema.String, "ignotum/id/UserId">;
8
+ readonly name: Schema.optional<Schema.String>;
9
+ readonly email: Schema.optional<Schema.String>;
10
+ readonly image: Schema.optional<Schema.String>;
11
+ }>;
12
+ type User = typeof User.Type;
13
+ declare const ProfileField: Schema.Literals<readonly ["name", "email", "image"]>;
14
+ type ProfileField = typeof ProfileField.Type;
15
+ declare const IdRequired: Schema.brand<Schema.Struct<{
16
+ readonly _tag: Schema.tag<"IdRequired">;
17
+ }>, "ignotum/error">;
18
+ type IdRequired = typeof IdRequired.Type;
19
+ interface IdContext {
20
+ readonly current: () => Result$1<User | null, never>;
21
+ readonly require: () => Result$1<User, IdRequired>;
22
+ }
23
+ declare const SessionOutcome: Schema.Literals<readonly ["SignedIn", "ProfileUpdated", "Cancelled"]>;
24
+ type SessionOutcome = typeof SessionOutcome.Type;
25
+ //#endregion
26
+ //#region ../contracts/dist/descriptor-BM7e5QAn.d.ts
4
27
  //#region src/schema/descriptor.d.ts
5
28
  interface DescriptorField {
6
29
  readonly name: string;
@@ -24,6 +47,8 @@ type ValueDescriptor = {
24
47
  } | {
25
48
  readonly type: "id";
26
49
  readonly table: string;
50
+ } | {
51
+ readonly type: "userId";
27
52
  } | {
28
53
  readonly type: "integer";
29
54
  } | {
@@ -50,6 +75,9 @@ type ValueDescriptor = {
50
75
  } | {
51
76
  readonly type: "record";
52
77
  readonly value: ValueDescriptor;
78
+ } | {
79
+ readonly type: "secret";
80
+ readonly value: ValueDescriptor;
53
81
  } | {
54
82
  readonly type: "string";
55
83
  } | {
@@ -66,7 +94,7 @@ type ValueFields = {
66
94
  readonly [fieldName: PropertyKey]: DescribedValue;
67
95
  };
68
96
  //#endregion
69
- //#region ../contracts/dist/pagination-Bt3l7QaC.d.ts
97
+ //#region ../contracts/dist/pagination-DnKg3dkI.d.ts
70
98
  //#region src/runtime/pagination.d.ts
71
99
  declare const PaginationCursor: Schema.brand<Schema.String, "ignotum/runtime/PaginationCursor">;
72
100
  type PaginationCursor = typeof PaginationCursor.Type;
@@ -80,5 +108,5 @@ interface PaginationPage<Item> {
80
108
  readonly nextCursor: PaginationCursor | null;
81
109
  }
82
110
  //#endregion
83
- export { ValueDescriptorCarrier as a, ValueDescriptor as i, PaginationPage as n, ValueFields as o, DescribedValue as r, PaginationOptions as t };
84
- //# sourceMappingURL=pagination-Bt3l7QaC-BYEGmLBE.d.ts.map
111
+ export { ValueDescriptor as a, IdContext as c, User as d, UserId as f, DescriptorField as i, ProfileField as l, PaginationPage as n, ValueDescriptorCarrier as o, DescribedValue as r, ValueFields as s, PaginationOptions as t, SessionOutcome as u };
112
+ //# sourceMappingURL=pagination-DnKg3dkI-r5ZUxBBx.d.ts.map
@@ -0,0 +1 @@
1
+ import "./pagination-DnKg3dkI-r5ZUxBBx.js";
@@ -0,0 +1 @@
1
+ import "./id-BzFHf3Wo-DGPCjgrf.js";
@@ -1,6 +1,6 @@
1
- import { c as fileFormats, d as fileLimits, n as FileFormat, s as constrainedFileValue, y as GeneratedId } from "./file-C1abuMgd.js";
2
- import { a as PaginationCursor, i as getValueDescriptor, l as ErrorBrand, n as attachValueDescriptor, o as PaginationPageSize, r as descriptorFields } from "./descriptor-C5VA9qRl-DuQsowaQ.js";
3
- import { Schema, Struct } from "effect";
1
+ import { I as fileLimits, M as constrainedFileValue, N as fileFormats, O as FileFormat, W as GeneratedId, c as UserId, h as ErrorBrand } from "./id-Bt9XWRGL.js";
2
+ import { a as getValueDescriptor, i as descriptorFields, n as attachValueDescriptor, o as PaginationCursor, r as descriptorAllowedInEnvironment, s as PaginationPageSize } from "./descriptor-Cyo9FP9n-C0SRVXNW.js";
3
+ import { Effect, Predicate, Redacted, Result, Schema, Struct } from "effect";
4
4
  //#region ../contracts/dist/schema/values.js
5
5
  const LiteralValueSchema = Schema.Union([
6
6
  Schema.String,
@@ -14,7 +14,7 @@ const schemaIndexLimits = {
14
14
  keyBytes: 4096,
15
15
  nameBytes: 64
16
16
  };
17
- const utf8ByteLength = (value) => {
17
+ const utf8ByteLength$1 = (value) => {
18
18
  let bytes = 0;
19
19
  for (const character of value) {
20
20
  const point = character.codePointAt(0) ?? 0;
@@ -26,7 +26,7 @@ const table = (fields) => {
26
26
  const tableFields = fields;
27
27
  const make = (indexes) => {
28
28
  const index = (name, fieldNames) => {
29
- if (utf8ByteLength(name) > schemaIndexLimits.nameBytes) throw new Error(`Index names cannot exceed ${schemaIndexLimits.nameBytes} UTF-8 bytes.`);
29
+ if (utf8ByteLength$1(name) > schemaIndexLimits.nameBytes) throw new Error(`Index names cannot exceed ${schemaIndexLimits.nameBytes} UTF-8 bytes.`);
30
30
  if (name.length === 0) throw new Error("Index names cannot be empty.");
31
31
  if (name.startsWith("$")) throw new Error("Index names beginning with '$' are reserved.");
32
32
  if (Object.hasOwn(indexes, name)) throw new Error(`Duplicate index name '${name}'.`);
@@ -105,6 +105,7 @@ const makeIdSchema = (tableName) => {
105
105
  table: tableName
106
106
  });
107
107
  };
108
+ const userId = () => attachValueDescriptor(fresh(UserId), { type: "userId" });
108
109
  const id = (tableName) => makeIdSchema(tableName);
109
110
  const requireDescriptor = (value) => {
110
111
  const descriptor = getValueDescriptor(value);
@@ -187,6 +188,16 @@ const union = (...members) => {
187
188
  members: members.map(requireDescriptor)
188
189
  });
189
190
  };
191
+ const Secret = {
192
+ isSecret: Redacted.isRedacted,
193
+ value: Redacted.value
194
+ };
195
+ function secret(value = string()) {
196
+ return attachValueDescriptor(Schema.RedactedFromValue(value, { disallowEncode: true }), {
197
+ type: "secret",
198
+ value: requireDescriptor(value)
199
+ });
200
+ }
190
201
  const paginationCursor = () => attachValueDescriptor(fresh(PaginationCursor), { type: "string" });
191
202
  const pagination = () => fixedObject({
192
203
  cursor: nullable(paginationCursor()),
@@ -214,6 +225,7 @@ const error = (tag, fields) => {
214
225
  return definition;
215
226
  };
216
227
  const values = {
228
+ userId,
217
229
  array,
218
230
  boolean,
219
231
  date,
@@ -233,6 +245,24 @@ const values = {
233
245
  string,
234
246
  union
235
247
  };
248
+ const environmentValues = {
249
+ array,
250
+ boolean,
251
+ date,
252
+ integer,
253
+ literal,
254
+ literals,
255
+ never,
256
+ null: nullValue,
257
+ nullable,
258
+ number,
259
+ object,
260
+ optional,
261
+ record,
262
+ secret,
263
+ string,
264
+ union
265
+ };
236
266
  const bindValues = (definition) => {
237
267
  const boundId = (tableName) => makeIdSchema(tableName);
238
268
  const doc = (tableName) => {
@@ -260,6 +290,7 @@ const bindValues = (definition) => {
260
290
  //#endregion
261
291
  //#region ../contracts/dist/runtime/schema.js
262
292
  const FunctionSchemaTypeId = Symbol.for("ignotum/runtime/schema/FunctionSchema");
293
+ const FunctionEnvironmentTypeId = Symbol.for("ignotum/runtime/schema/FunctionEnvironment");
263
294
  const attachFunctionSchema = (schema) => (definition) => {
264
295
  Object.defineProperty(definition, FunctionSchemaTypeId, {
265
296
  configurable: false,
@@ -270,6 +301,16 @@ const attachFunctionSchema = (schema) => (definition) => {
270
301
  return definition;
271
302
  };
272
303
  const getFunctionSchema = (value) => value[FunctionSchemaTypeId];
304
+ const attachFunctionEnvironment = (environment) => (definition) => {
305
+ Object.defineProperty(definition, FunctionEnvironmentTypeId, {
306
+ configurable: false,
307
+ enumerable: false,
308
+ value: environment,
309
+ writable: false
310
+ });
311
+ return definition;
312
+ };
313
+ const getFunctionEnvironment = (value) => value[FunctionEnvironmentTypeId];
273
314
  //#endregion
274
315
  //#region ../contracts/dist/schema/index.js
275
316
  const SchemaDefinitionTypeId = Symbol.for("ignotum/schema/SchemaDefinition");
@@ -284,22 +325,99 @@ const defineSchema = (define) => {
284
325
  [SchemaDefinitionTypeId]: definitions
285
326
  };
286
327
  };
287
- const makeFunctionBuilder = (schema, kind) => {
288
- const define = (definition) => attachFunctionSchema(schema)({
328
+ const EnvironmentDefinitionTypeId = Symbol.for("ignotum/schema/EnvironmentDefinition");
329
+ const EnvironmentDecoderTypeId = Symbol.for("ignotum/schema/EnvironmentDecoder");
330
+ const environmentLimits = {
331
+ bytes: 65536,
332
+ variables: 128
333
+ };
334
+ var EnvironmentValueInvalid = class extends Schema.TaggedError()("EnvironmentValueInvalid", {
335
+ key: Schema.optional(Schema.String),
336
+ message: Schema.String
337
+ }) {};
338
+ const environmentName = /^[A-Z_][A-Z0-9_]*$/;
339
+ const defineEnv = (define) => {
340
+ const fields = define({ values: environmentValues });
341
+ if (Reflect.ownKeys(fields).length > environmentLimits.variables) throw new Error(`Environments cannot declare more than ${environmentLimits.variables} variables.`);
342
+ for (const name of Reflect.ownKeys(fields)) {
343
+ if (!Predicate.isString(name)) throw new Error("Environment variable names must be strings.");
344
+ if (!environmentName.test(name)) throw new Error(`Environment variable '${name}' must match ${environmentName.source}.`);
345
+ if (name.startsWith("IGNOTUM_")) throw new Error(`Environment variable '${name}' uses the reserved IGNOTUM_ prefix.`);
346
+ }
347
+ const descriptors = descriptorFields(fields);
348
+ for (const field of descriptors) if (!descriptorAllowedInEnvironment(field.value)) throw new Error(`Environment variable '${field.name}' uses an unsupported validator.`);
349
+ const environment = {
350
+ _tag: "Environment",
351
+ fields,
352
+ descriptors,
353
+ schema: Schema.Struct(fields),
354
+ [EnvironmentDefinitionTypeId]: fields
355
+ };
356
+ Object.defineProperty(environment, EnvironmentDecoderTypeId, {
357
+ enumerable: false,
358
+ value: (raw) => decodeEnvironment(environment, raw)
359
+ });
360
+ return Object.freeze(environment);
361
+ };
362
+ const emptyEnv = defineEnv(() => ({}));
363
+ const utf8ByteLength = (value) => {
364
+ let bytes = 0;
365
+ for (const character of value) {
366
+ const point = character.codePointAt(0) ?? 0;
367
+ bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
368
+ }
369
+ return bytes;
370
+ };
371
+ const invalidValue = (key) => EnvironmentValueInvalid.make({
372
+ key,
373
+ message: `Environment variable '${key}' does not match its declaration.`
374
+ });
375
+ const decodeEnvironment = Effect.fn("Environment.decode")(function* (environment, raw) {
376
+ const declared = new Set(Object.keys(environment.fields));
377
+ const supplied = Object.keys(raw);
378
+ if (supplied.length > environmentLimits.variables) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot contain more than ${environmentLimits.variables} variables.` });
379
+ const rawJson = JSON.stringify(raw);
380
+ if (utf8ByteLength(rawJson) > environmentLimits.bytes) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot exceed ${environmentLimits.bytes} UTF-8 bytes.` });
381
+ for (const key of supplied) if (!declared.has(key)) return yield* EnvironmentValueInvalid.make({
382
+ key,
383
+ message: `Environment variable '${key}' is not declared in server/env.ts.`
384
+ });
385
+ const decoded = {};
386
+ for (const [key, field] of Object.entries(environment.fields)) {
387
+ const input = Object.hasOwn(raw, key) ? raw[key] : void 0;
388
+ const direct = yield* Effect.result(Schema.decodeUnknownEffect(field)(input));
389
+ if (Result.isSuccess(direct)) {
390
+ if (direct.success !== void 0) Reflect.set(decoded, key, direct.success);
391
+ continue;
392
+ }
393
+ if (input === void 0) return yield* invalidValue(key);
394
+ const parsed = yield* Effect.result(Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(input));
395
+ if (Result.isFailure(parsed)) return yield* invalidValue(key);
396
+ const fromJson = yield* Effect.result(Schema.decodeUnknownEffect(field)(parsed.success));
397
+ if (Result.isFailure(fromJson)) return yield* invalidValue(key);
398
+ if (fromJson.success !== void 0) Reflect.set(decoded, key, fromJson.success);
399
+ }
400
+ return Object.freeze(decoded);
401
+ });
402
+ const decodeDefinedEnvironment = (environment, raw) => environment[EnvironmentDecoderTypeId](raw);
403
+ const makeFunctionBuilder = (schema, environment, kind) => {
404
+ const define = (definition) => attachFunctionEnvironment(environment)(attachFunctionSchema(schema)({
289
405
  _tag: kind,
290
406
  ...definition
291
- });
407
+ }));
292
408
  return define;
293
409
  };
294
- const makeFunctionBuilders = (schema) => ({
295
- mutation: makeFunctionBuilder(schema, "Mutation"),
296
- query: makeFunctionBuilder(schema, "Query")
297
- });
298
- const bindSchema = (schema) => ({
299
- values: bindValues(schema[SchemaDefinitionTypeId]),
300
- ...makeFunctionBuilders(schema)
410
+ const makeFunctionBuilders = (schema, environment) => ({
411
+ mutation: makeFunctionBuilder(schema, environment, "Mutation"),
412
+ query: makeFunctionBuilder(schema, environment, "Query")
301
413
  });
414
+ function bindSchema(schema, environment = emptyEnv) {
415
+ return {
416
+ values: bindValues(schema[SchemaDefinitionTypeId]),
417
+ ...makeFunctionBuilders(schema, environment)
418
+ };
419
+ }
302
420
  //#endregion
303
- export { getFunctionSchema as i, bindSchema as n, defineSchema as r, SchemaDefinitionTypeId as t };
421
+ export { defineSchema as a, getFunctionSchema as c, defineEnv as i, Secret as l, bindSchema as n, emptyEnv as o, decodeDefinedEnvironment as r, getFunctionEnvironment as s, SchemaDefinitionTypeId as t };
304
422
 
305
- //# sourceMappingURL=schema-ERFjT8-m.js.map
423
+ //# sourceMappingURL=schema-1Zs03-iS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-1Zs03-iS.js","names":["utf8ByteLength","Result$1"],"sources":["../../../contracts/dist/schema/values.js","../../../contracts/dist/runtime/schema.js","../../../contracts/dist/schema/index.js"],"sourcesContent":["import { GeneratedId } from \"../runtime/id.js\";\nimport { FileFormat, constrainedFileValue, fileFormats, fileLimits } from \"./file.js\";\nimport { ErrorBrand } from \"../runtime/result.js\";\nimport { UserId } from \"../id.js\";\nimport { c as getValueDescriptor, r as attachValueDescriptor, s as descriptorFields } from \"../descriptor-Cyo9FP9n.js\";\nimport { PaginationCursor, PaginationPageSize } from \"../runtime/pagination.js\";\nimport { Redacted, Schema, Struct } from \"effect\";\n//#region src/schema/values.ts\nconst LiteralValueSchema = Schema.Union([\n\tSchema.String,\n\tSchema.Finite,\n\tSchema.Boolean\n]);\nconst schemaIndexLimits = {\n\tfieldsPerIndex: 8,\n\tindexesPerSchema: 128,\n\tindexesPerTable: 16,\n\tkeyBytes: 4096,\n\tnameBytes: 64\n};\nconst utf8ByteLength = (value) => {\n\tlet bytes = 0;\n\tfor (const character of value) {\n\t\tconst point = character.codePointAt(0) ?? 0;\n\t\tbytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;\n\t}\n\treturn bytes;\n};\nconst table = (fields) => {\n\tconst tableFields = fields;\n\tconst make = (indexes) => {\n\t\tconst index = (name, fieldNames) => {\n\t\t\tif (utf8ByteLength(name) > schemaIndexLimits.nameBytes) throw new Error(`Index names cannot exceed ${schemaIndexLimits.nameBytes} UTF-8 bytes.`);\n\t\t\tif (name.length === 0) throw new Error(\"Index names cannot be empty.\");\n\t\t\tif (name.startsWith(\"$\")) throw new Error(\"Index names beginning with '$' are reserved.\");\n\t\t\tif (Object.hasOwn(indexes, name)) throw new Error(`Duplicate index name '${name}'.`);\n\t\t\tif (fieldNames.length > schemaIndexLimits.fieldsPerIndex) throw new Error(`Indexes cannot contain more than ${schemaIndexLimits.fieldsPerIndex} fields.`);\n\t\t\tif (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Index '${name}' contains duplicate fields.`);\n\t\t\tfor (const fieldName of fieldNames) {\n\t\t\t\tif (!Object.hasOwn(tableFields, fieldName)) throw new Error(`Index '${name}' references unknown field '${fieldName}'.`);\n\t\t\t\tconst descriptor = getValueDescriptor(tableFields[fieldName]);\n\t\t\t\tif (!(descriptor?.type === \"boolean\" || descriptor?.type === \"date\" || descriptor?.type === \"id\" || descriptor?.type === \"integer\" || descriptor?.type === \"number\" || descriptor?.type === \"string\" || descriptor?.type === \"literal\" || descriptor?.type === \"literals\")) throw new Error(`Index '${name}' field '${fieldName}' is not indexable.`);\n\t\t\t\tif (descriptor.type === \"literals\" && !(descriptor.values.every(Schema.is(Schema.Boolean)) || descriptor.values.every(Schema.is(Schema.Finite)) || descriptor.values.every(Schema.is(Schema.String)))) throw new Error(`Index '${name}' field '${fieldName}' mixes value types.`);\n\t\t\t}\n\t\t\tconst duplicate = Object.values(indexes).find((candidate) => candidate.fields.length === fieldNames.length && candidate.fields.every((fieldName, position) => fieldName === fieldNames[position]));\n\t\t\tif (duplicate !== void 0) throw new Error(`Index '${name}' duplicates index '${duplicate.name}'.`);\n\t\t\tif (Object.keys(indexes).length >= schemaIndexLimits.indexesPerTable) throw new Error(`Tables cannot declare more than ${schemaIndexLimits.indexesPerTable} indexes.`);\n\t\t\treturn make({\n\t\t\t\t...indexes,\n\t\t\t\t[name]: {\n\t\t\t\t\tname,\n\t\t\t\t\tfields: fieldNames\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\t_tag: \"Table\",\n\t\t\tdescriptor: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tfields: descriptorFields(tableFields)\n\t\t\t},\n\t\t\tfields: tableFields,\n\t\t\tindex,\n\t\t\tindexes,\n\t\t\tschema: Schema.Struct(tableFields)\n\t\t};\n\t};\n\treturn make({});\n};\nconst fresh = (value) => value.pipe(Schema.annotate({}));\nconst string = () => attachValueDescriptor(fresh(Schema.String), { type: \"string\" });\nconst number = () => attachValueDescriptor(fresh(Schema.Finite), { type: \"number\" });\nconst integer = () => attachValueDescriptor(fresh(Schema.Int), { type: \"integer\" });\nconst boolean = () => attachValueDescriptor(fresh(Schema.Boolean), { type: \"boolean\" });\nconst date = () => attachValueDescriptor(fresh(Schema.DateFromMillis), { type: \"date\" });\nconst file = (options = {}) => {\n\tconst formats = options.formats ?? fileFormats;\n\tif (formats.length === 0) throw new Error(\"File format lists cannot be empty.\");\n\tSchema.decodeUnknownSync(Schema.Array(FileFormat))(formats);\n\tif (new Set(formats).size !== formats.length) throw new Error(\"File format lists cannot contain duplicates.\");\n\tconst maxBytes = options.maxBytes ?? fileLimits.fileBytes;\n\tif (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || maxBytes > fileLimits.fileBytes) throw new Error(`File sizes must be between 1 and ${fileLimits.fileBytes} bytes.`);\n\treturn attachValueDescriptor(constrainedFileValue(formats, maxBytes), {\n\t\ttype: \"file\",\n\t\tformats: [...formats],\n\t\tmaxBytes\n\t});\n};\nconst never = () => attachValueDescriptor(fresh(Schema.Never), { type: \"never\" });\nconst nullValue = () => attachValueDescriptor(fresh(Schema.Null), { type: \"null\" });\nconst literal = (value) => {\n\tSchema.decodeSync(LiteralValueSchema)(value);\n\treturn attachValueDescriptor(Schema.Literal(value), {\n\t\ttype: \"literal\",\n\t\tvalue\n\t});\n};\nconst literals = (...members) => {\n\tSchema.decodeSync(Schema.Array(LiteralValueSchema))(members);\n\treturn attachValueDescriptor(Schema.Literals(members), {\n\t\ttype: \"literals\",\n\t\tvalues: members\n\t});\n};\nconst makeIdSchema = (tableName) => {\n\tconst identifier = `ignotum/id/${tableName}`;\n\treturn attachValueDescriptor(GeneratedId.pipe(Schema.brand(identifier), Schema.annotate({ \"ignotum/table\": tableName })), {\n\t\ttype: \"id\",\n\t\ttable: tableName\n\t});\n};\nconst userId = () => attachValueDescriptor(fresh(UserId), { type: \"userId\" });\nconst id = (tableName) => makeIdSchema(tableName);\nconst requireDescriptor = (value) => {\n\tconst descriptor = getValueDescriptor(value);\n\tif (descriptor === void 0) throw new Error(\"Ignotum value combinators require a values validator.\");\n\treturn descriptor;\n};\nconst array = (value) => {\n\treturn attachValueDescriptor(Schema.Array(value), {\n\t\ttype: \"array\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst assertFieldsExist = (fields, keys, operation) => {\n\tfor (const key of keys) if (!Object.hasOwn(fields, key)) throw new Error(`Cannot ${operation} unknown field '${String(key)}'.`);\n};\nconst fixedObject = (fields) => {\n\tconst pick = (...keys) => {\n\t\tassertFieldsExist(fields, keys, \"pick\");\n\t\treturn fixedObject(Struct.pick(fields, keys));\n\t};\n\tconst omit = (...keys) => {\n\t\tassertFieldsExist(fields, keys, \"omit\");\n\t\treturn fixedObject(Struct.omit(fields, keys));\n\t};\n\tconst extend = (addedFields, ..._validation) => {\n\t\tfor (const key of Reflect.ownKeys(addedFields)) if (Object.hasOwn(fields, key)) throw new Error(`Cannot extend existing field '${String(key)}'.`);\n\t\treturn fixedObject(Struct.assign(fields, addedFields));\n\t};\n\tconst override = (overriddenFields, ..._validation) => {\n\t\tassertFieldsExist(fields, Reflect.ownKeys(overriddenFields), \"override\");\n\t\treturn fixedObject(Struct.assign(fields, overriddenFields));\n\t};\n\tconst partial = () => {\n\t\tconst partialFields = Struct.map(fields, Schema.optional);\n\t\tfor (const name of Reflect.ownKeys(fields)) {\n\t\t\tconst field = fields[name];\n\t\t\tconst partialField = partialFields[name];\n\t\t\tif (field === void 0 || partialField === void 0) continue;\n\t\t\tattachValueDescriptor(partialField, {\n\t\t\t\ttype: \"optional\",\n\t\t\t\tvalue: requireDescriptor(field)\n\t\t\t});\n\t\t}\n\t\treturn fixedObject(partialFields);\n\t};\n\tconst schema = attachValueDescriptor(Schema.Struct(fields), {\n\t\ttype: \"object\",\n\t\tfields: descriptorFields(fields)\n\t});\n\treturn Object.assign(schema, {\n\t\textend,\n\t\tomit,\n\t\toverride,\n\t\tpartial,\n\t\tpick\n\t});\n};\nconst object = (fields) => fixedObject(fields);\nconst optional = (value) => {\n\treturn attachValueDescriptor(Schema.optional(value), {\n\t\ttype: \"optional\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst nullable = (value) => {\n\treturn attachValueDescriptor(Schema.NullOr(value), {\n\t\ttype: \"nullable\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst record = (value) => {\n\treturn attachValueDescriptor(Schema.Record(Schema.String, value), {\n\t\ttype: \"record\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst union = (...members) => {\n\treturn attachValueDescriptor(Schema.Union(members), {\n\t\ttype: \"union\",\n\t\tmembers: members.map(requireDescriptor)\n\t});\n};\nconst Secret = {\n\tisSecret: Redacted.isRedacted,\n\tvalue: Redacted.value\n};\nfunction secret(value = string()) {\n\treturn attachValueDescriptor(Schema.RedactedFromValue(value, { disallowEncode: true }), {\n\t\ttype: \"secret\",\n\t\tvalue: requireDescriptor(value)\n\t});\n}\nconst paginationCursor = () => attachValueDescriptor(fresh(PaginationCursor), { type: \"string\" });\nconst pagination = () => fixedObject({\n\tcursor: nullable(paginationCursor()),\n\tpageSize: attachValueDescriptor(fresh(PaginationPageSize), { type: \"integer\" })\n});\nconst page = (value) => {\n\treturn fixedObject({\n\t\titems: array(value),\n\t\tnextCursor: nullable(paginationCursor())\n\t});\n};\nconst error = (tag, fields) => {\n\tif (tag === \"InternalServerError\") throw new Error(\"The error tag 'InternalServerError' is reserved by Ignotum.\");\n\tconst errorFields = { ...fields };\n\tReflect.deleteProperty(errorFields, \"_tag\");\n\tconst schema = Schema.TaggedStruct(tag, errorFields).pipe(Schema.brand(ErrorBrand));\n\tconst make = (input) => schema.make(input);\n\tconst definition = Object.assign(make, schema);\n\tObject.setPrototypeOf(definition, Object.getPrototypeOf(schema));\n\tattachValueDescriptor(definition, {\n\t\ttype: \"error\",\n\t\ttag,\n\t\tfields: descriptorFields(errorFields)\n\t});\n\treturn definition;\n};\nconst values = {\n\tuserId,\n\tarray,\n\tboolean,\n\tdate,\n\tfile,\n\terror,\n\tid,\n\tinteger,\n\tliteral,\n\tliterals,\n\tnever,\n\tnull: nullValue,\n\tnullable,\n\tnumber,\n\tobject,\n\toptional,\n\trecord,\n\tstring,\n\tunion\n};\nconst environmentValues = {\n\tarray,\n\tboolean,\n\tdate,\n\tinteger,\n\tliteral,\n\tliterals,\n\tnever,\n\tnull: nullValue,\n\tnullable,\n\tnumber,\n\tobject,\n\toptional,\n\trecord,\n\tsecret,\n\tstring,\n\tunion\n};\nconst bindValues = (definition) => {\n\tconst boundId = (tableName) => makeIdSchema(tableName);\n\tconst doc = (tableName) => {\n\t\tconst tableDefinition = definition[tableName];\n\t\tif (tableDefinition === void 0) throw new Error(`Unknown table '${tableName}'.`);\n\t\tconst tableFields = tableDefinition.fields;\n\t\tconst systemFields = {\n\t\t\tid: boundId(tableName),\n\t\t\tcreatedAt: date(),\n\t\t\tupdatedAt: date()\n\t\t};\n\t\treturn fixedObject(Struct.assign(tableFields, systemFields));\n\t};\n\tconst boundPagination = () => {\n\t\treturn pagination();\n\t};\n\treturn {\n\t\t...values,\n\t\tdoc,\n\t\tid: boundId,\n\t\tpage,\n\t\tpagination: boundPagination\n\t};\n};\n//#endregion\nexport { Secret, bindValues, environmentValues, schemaIndexLimits, table, values };\n\n//# sourceMappingURL=values.js.map","//#region src/runtime/schema.ts\nconst FunctionSchemaTypeId = Symbol.for(\"ignotum/runtime/schema/FunctionSchema\");\nconst FunctionEnvironmentTypeId = Symbol.for(\"ignotum/runtime/schema/FunctionEnvironment\");\nconst attachFunctionSchema = (schema) => (definition) => {\n\tObject.defineProperty(definition, FunctionSchemaTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: schema,\n\t\twritable: false\n\t});\n\treturn definition;\n};\nconst getFunctionSchema = (value) => value[FunctionSchemaTypeId];\nconst attachFunctionEnvironment = (environment) => (definition) => {\n\tObject.defineProperty(definition, FunctionEnvironmentTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: environment,\n\t\twritable: false\n\t});\n\treturn definition;\n};\nconst getFunctionEnvironment = (value) => value[FunctionEnvironmentTypeId];\n//#endregion\nexport { FunctionEnvironmentTypeId, FunctionSchemaTypeId, attachFunctionEnvironment, attachFunctionSchema, getFunctionEnvironment, getFunctionSchema };\n\n//# sourceMappingURL=schema.js.map","import { FileFormat, FileId, FileValue, FileValueTypeId, fileFormats, fileLimits, fileMimeTypes, isFileValue } from \"./file.js\";\nimport { Result } from \"../runtime/result.js\";\nimport { a as descriptorContainsFile, c as getValueDescriptor, i as descriptorAllowedInEnvironment, n as ValueDescriptorTypeId, o as descriptorContainsSecret, s as descriptorFields, t as ValueDescriptor } from \"../descriptor-Cyo9FP9n.js\";\nimport { Secret, bindValues, environmentValues, schemaIndexLimits, table, values } from \"./values.js\";\nimport { attachFunctionEnvironment, attachFunctionSchema } from \"../runtime/schema.js\";\nimport { Effect, Predicate, Result as Result$1, Schema } from \"effect\";\n//#region src/schema/types.ts\nconst SchemaDefinitionTypeId = Symbol.for(\"ignotum/schema/SchemaDefinition\");\n//#endregion\n//#region src/schema/definition.ts\nconst defineSchema = (define) => {\n\tconst definitions = define({\n\t\ttable,\n\t\tvalues\n\t});\n\tif (Object.values(definitions).reduce((count, definition) => count + Object.keys(definition.indexes).length, 0) > schemaIndexLimits.indexesPerSchema) throw new Error(`Schemas cannot declare more than ${schemaIndexLimits.indexesPerSchema} indexes.`);\n\treturn {\n\t\t_tag: \"Schema\",\n\t\t[SchemaDefinitionTypeId]: definitions\n\t};\n};\nconst isDefinedSchema = (value) => value._tag === \"Schema\" && Predicate.isObject(value[SchemaDefinitionTypeId]);\n//#endregion\n//#region src/schema/environment.ts\nconst EnvironmentDefinitionTypeId = Symbol.for(\"ignotum/schema/EnvironmentDefinition\");\nconst EnvironmentDecoderTypeId = Symbol.for(\"ignotum/schema/EnvironmentDecoder\");\nconst environmentLimits = {\n\tbytes: 65536,\n\tvariables: 128\n};\nvar EnvironmentValueInvalid = class extends Schema.TaggedError()(\"EnvironmentValueInvalid\", {\n\tkey: Schema.optional(Schema.String),\n\tmessage: Schema.String\n}) {};\nconst environmentName = /^[A-Z_][A-Z0-9_]*$/;\nconst defineEnv = (define) => {\n\tconst fields = define({ values: environmentValues });\n\tif (Reflect.ownKeys(fields).length > environmentLimits.variables) throw new Error(`Environments cannot declare more than ${environmentLimits.variables} variables.`);\n\tfor (const name of Reflect.ownKeys(fields)) {\n\t\tif (!Predicate.isString(name)) throw new Error(\"Environment variable names must be strings.\");\n\t\tif (!environmentName.test(name)) throw new Error(`Environment variable '${name}' must match ${environmentName.source}.`);\n\t\tif (name.startsWith(\"IGNOTUM_\")) throw new Error(`Environment variable '${name}' uses the reserved IGNOTUM_ prefix.`);\n\t}\n\tconst descriptors = descriptorFields(fields);\n\tfor (const field of descriptors) if (!descriptorAllowedInEnvironment(field.value)) throw new Error(`Environment variable '${field.name}' uses an unsupported validator.`);\n\tconst environment = {\n\t\t_tag: \"Environment\",\n\t\tfields,\n\t\tdescriptors,\n\t\tschema: Schema.Struct(fields),\n\t\t[EnvironmentDefinitionTypeId]: fields\n\t};\n\tObject.defineProperty(environment, EnvironmentDecoderTypeId, {\n\t\tenumerable: false,\n\t\tvalue: (raw) => decodeEnvironment(environment, raw)\n\t});\n\treturn Object.freeze(environment);\n};\nconst emptyEnv = defineEnv(() => ({}));\nconst isDefinedEnv = (value) => value._tag === \"Environment\" && Predicate.isObject(value[EnvironmentDefinitionTypeId]);\nconst utf8ByteLength = (value) => {\n\tlet bytes = 0;\n\tfor (const character of value) {\n\t\tconst point = character.codePointAt(0) ?? 0;\n\t\tbytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;\n\t}\n\treturn bytes;\n};\nconst invalidValue = (key) => EnvironmentValueInvalid.make({\n\tkey,\n\tmessage: `Environment variable '${key}' does not match its declaration.`\n});\nconst decodeEnvironment = Effect.fn(\"Environment.decode\")(function* (environment, raw) {\n\tconst declared = new Set(Object.keys(environment.fields));\n\tconst supplied = Object.keys(raw);\n\tif (supplied.length > environmentLimits.variables) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot contain more than ${environmentLimits.variables} variables.` });\n\tconst rawJson = JSON.stringify(raw);\n\tif (utf8ByteLength(rawJson) > environmentLimits.bytes) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot exceed ${environmentLimits.bytes} UTF-8 bytes.` });\n\tfor (const key of supplied) if (!declared.has(key)) return yield* EnvironmentValueInvalid.make({\n\t\tkey,\n\t\tmessage: `Environment variable '${key}' is not declared in server/env.ts.`\n\t});\n\tconst decoded = {};\n\tfor (const [key, field] of Object.entries(environment.fields)) {\n\t\tconst input = Object.hasOwn(raw, key) ? raw[key] : void 0;\n\t\tconst direct = yield* Effect.result(Schema.decodeUnknownEffect(field)(input));\n\t\tif (Result$1.isSuccess(direct)) {\n\t\t\tif (direct.success !== void 0) Reflect.set(decoded, key, direct.success);\n\t\t\tcontinue;\n\t\t}\n\t\tif (input === void 0) return yield* invalidValue(key);\n\t\tconst parsed = yield* Effect.result(Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(input));\n\t\tif (Result$1.isFailure(parsed)) return yield* invalidValue(key);\n\t\tconst fromJson = yield* Effect.result(Schema.decodeUnknownEffect(field)(parsed.success));\n\t\tif (Result$1.isFailure(fromJson)) return yield* invalidValue(key);\n\t\tif (fromJson.success !== void 0) Reflect.set(decoded, key, fromJson.success);\n\t}\n\treturn Object.freeze(decoded);\n});\nconst decodeDefinedEnvironment = (environment, raw) => environment[EnvironmentDecoderTypeId](raw);\n//#endregion\n//#region src/schema/server.ts\nconst makeFunctionBuilder = (schema, environment, kind) => {\n\tconst define = (definition) => attachFunctionEnvironment(environment)(attachFunctionSchema(schema)({\n\t\t_tag: kind,\n\t\t...definition\n\t}));\n\treturn define;\n};\nconst makeFunctionBuilders = (schema, environment) => ({\n\tmutation: makeFunctionBuilder(schema, environment, \"Mutation\"),\n\tquery: makeFunctionBuilder(schema, environment, \"Query\")\n});\nfunction bindSchema(schema, environment = emptyEnv) {\n\treturn {\n\t\tvalues: bindValues(schema[SchemaDefinitionTypeId]),\n\t\t...makeFunctionBuilders(schema, environment)\n\t};\n}\n//#endregion\nexport { EnvironmentDefinitionTypeId, EnvironmentValueInvalid, FileFormat, FileId, FileValue, FileValueTypeId, Result, SchemaDefinitionTypeId, Secret, ValueDescriptor, ValueDescriptorTypeId, bindSchema, bindValues, decodeDefinedEnvironment, decodeEnvironment, defineEnv, defineSchema, descriptorAllowedInEnvironment, descriptorContainsFile, descriptorContainsSecret, descriptorFields, emptyEnv, environmentLimits, environmentValues, fileFormats, fileLimits, fileMimeTypes, getValueDescriptor, isDefinedEnv, isDefinedSchema, isFileValue, schemaIndexLimits, table, values };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;;;AAQA,MAAM,qBAAqB,OAAO,MAAM;CACvC,OAAO;CACP,OAAO;CACP,OAAO;AACR,CAAC;AACD,MAAM,oBAAoB;CACzB,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,UAAU;CACV,WAAW;AACZ;AACA,MAAMA,oBAAkB,UAAU;CACjC,IAAI,QAAQ;CACZ,KAAK,MAAM,aAAa,OAAO;EAC9B,MAAM,QAAQ,UAAU,YAAY,CAAC,KAAK;EAC1C,SAAS,SAAS,MAAM,IAAI,SAAS,OAAO,IAAI,SAAS,QAAQ,IAAI;CACtE;CACA,OAAO;AACR;AACA,MAAM,SAAS,WAAW;CACzB,MAAM,cAAc;CACpB,MAAM,QAAQ,YAAY;EACzB,MAAM,SAAS,MAAM,eAAe;GACnC,IAAIA,iBAAe,IAAI,IAAI,kBAAkB,WAAW,MAAM,IAAI,MAAM,6BAA6B,kBAAkB,UAAU,cAAc;GAC/I,IAAI,KAAK,WAAW,GAAG,MAAM,IAAI,MAAM,8BAA8B;GACrE,IAAI,KAAK,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,8CAA8C;GACxF,IAAI,OAAO,OAAO,SAAS,IAAI,GAAG,MAAM,IAAI,MAAM,yBAAyB,KAAK,GAAG;GACnF,IAAI,WAAW,SAAS,kBAAkB,gBAAgB,MAAM,IAAI,MAAM,oCAAoC,kBAAkB,eAAe,SAAS;GACxJ,IAAI,IAAI,IAAI,UAAU,CAAC,CAAC,SAAS,WAAW,QAAQ,MAAM,IAAI,MAAM,UAAU,KAAK,6BAA6B;GAChH,KAAK,MAAM,aAAa,YAAY;IACnC,IAAI,CAAC,OAAO,OAAO,aAAa,SAAS,GAAG,MAAM,I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ineSchema$1, n as SchemaAuthoring, t as DefinedSchema } from "./index-2q9FwJud.js";
1
+ import { c as Result$1, g as FileValue, h as FileMimeType, i as ErrorValue, m as FileMetadata, p as FileFormat } from "./id-BzFHf3Wo-DGPCjgrf.js";
2
+ import "./result-DKAA4gpS.js";
3
+ import { d as User, f as UserId } from "./pagination-DnKg3dkI-r5ZUxBBx.js";
4
+ import "./id-Dz0apuB3.js";
5
+ import { a as DefinedEnv, d as defineEnv$1, f as Secret$1, i as defineSchema$1, n as SchemaAuthoring, s as EnvironmentAuthoring, t as DefinedSchema } from "./index-D54flWtH.js";
3
6
  //#region src/server/index.d.ts
4
7
  declare const Result: typeof Result$1;
5
8
  type Result<Success, Failure extends ErrorValue> = Result$1<Success, Failure>;
9
+ declare const defineEnv: typeof defineEnv$1;
6
10
  declare const defineSchema: typeof defineSchema$1;
11
+ declare const Secret: typeof Secret$1;
12
+ type Secret<Value> = Secret$1<Value>;
7
13
  //#endregion
8
- export { type DefinedSchema, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Result, type SchemaAuthoring, defineSchema };
14
+ export { type DefinedEnv, type DefinedSchema, type EnvironmentAuthoring, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Result, type SchemaAuthoring, Secret, type User, type UserId, defineEnv, defineSchema };
9
15
  //# sourceMappingURL=server.d.ts.map