ignotum 0.0.11 → 0.0.12

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 (48) hide show
  1. package/README.md +8 -3
  2. package/dist/cli/bin.mjs +560 -102
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/runtime/{api-DR_8vfKg.d.ts → api-5XSrIeqW.d.ts} +4 -3
  5. package/dist/runtime/client.d.ts +6 -5
  6. package/dist/runtime/client.js +170 -75
  7. package/dist/runtime/client.js.map +1 -1
  8. package/dist/runtime/{descriptor-C5VA9qRl-DuQsowaQ.js → descriptor-XzDX2JDw-j3O6YHgW.js} +23 -4
  9. package/dist/runtime/descriptor-XzDX2JDw-j3O6YHgW.js.map +1 -0
  10. package/dist/runtime/{id-Cs82tq9Q-hmYFyqTa.d.ts → id-Cs82tq9Q-CK-maMgN.d.ts} +12 -12
  11. package/dist/runtime/{index-2q9FwJud.d.ts → index-CrWg4Z0y.d.ts} +132 -76
  12. package/dist/runtime/internal/api.d.ts +1 -1
  13. package/dist/runtime/internal/host.d.ts +18 -17
  14. package/dist/runtime/internal/host.js +10 -5
  15. package/dist/runtime/internal/host.js.map +1 -1
  16. package/dist/runtime/internal/server.d.ts +1 -1
  17. package/dist/runtime/internal/server.js +1 -1
  18. package/dist/runtime/internal/types.d.ts +1 -1
  19. package/dist/runtime/internal/types.js +1 -1
  20. package/dist/runtime/pagination-CX5IPbEi.d.ts +1 -0
  21. package/dist/runtime/{pagination-Bt3l7QaC-BYEGmLBE.d.ts → pagination-D-R9NR61-CpIoHFoI.d.ts} +8 -5
  22. package/dist/runtime/result-DIjKM-p4.d.ts +1 -0
  23. package/dist/runtime/{schema-ERFjT8-m.js → schema-B9XxyRO8.js} +132 -16
  24. package/dist/runtime/schema-B9XxyRO8.js.map +1 -0
  25. package/dist/runtime/server.d.ts +7 -3
  26. package/dist/runtime/server.js +5 -3
  27. package/dist/runtime/server.js.map +1 -1
  28. package/dist/runtime/{sync-a2EdGSdY.d.ts → sync-avN7NkcU.d.ts} +2 -2
  29. package/package.json +4 -4
  30. package/src/cli/agent-files.ts +2 -0
  31. package/src/cli/auth-client.ts +1 -1
  32. package/src/cli/bin.ts +13 -3
  33. package/src/cli/build/server.ts +102 -13
  34. package/src/cli/codegen.ts +7 -4
  35. package/src/cli/control-client.ts +30 -8
  36. package/src/cli/deploy.ts +7 -2
  37. package/src/cli/environment.ts +133 -0
  38. package/src/client/files.ts +43 -27
  39. package/src/client/hooks.ts +26 -17
  40. package/src/client/page-observers.ts +77 -0
  41. package/src/client/sync.ts +71 -59
  42. package/src/dev-runtime/functions.ts +127 -4
  43. package/src/dev-runtime/sync.ts +38 -9
  44. package/src/server/index.ts +11 -1
  45. package/dist/runtime/descriptor-C5VA9qRl-DuQsowaQ.js.map +0 -1
  46. package/dist/runtime/pagination-CFJ3xlAt.d.ts +0 -1
  47. package/dist/runtime/schema-ERFjT8-m.js.map +0 -1
  48. package/src/dev-runtime/id.ts +0 -3
@@ -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,OAAO,QAAQ,SAAS;CAC9B,OAAO,OAAO;AACf,CAAC;AACD,MAAM,sBAAsB,OAAO,OAAO;CACzC,OAAO,OAAO;CACd,OAAO,OAAO;AACf,CAAC;AACD,MAAM,iBAAiB,OAAO,OAAO;CACpC,OAAO,OAAO,MAAM,mBAAmB;CACvC,OAAO,OAAO,SAAS,OAAO,OAAO;EACpC,GAAG,oBAAoB;EACvB,WAAW,OAAO;CACnB,CAAC,CAAC;CACF,OAAO,OAAO,SAAS,OAAO,OAAO;EACpC,GAAG,oBAAoB;EACvB,WAAW,OAAO;CACnB,CAAC,CAAC;AACH,CAAC;AACD,MAAM,YAAY,OAAO,OAAO;CAC/B,MAAM,OAAO,QAAQ,OAAO;CAC5B,OAAO,OAAO;CACd,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,OAAO,OAAO,SAAS,cAAc;CACrC,OAAO,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC;CACtC,OAAO,OAAO,SAAS,OAAO,OAAO;AACtC,CAAC;AACD,MAAM,eAAe,OAAO,OAAO;CAClC,MAAM,OAAO,QAAQ,UAAU;CAC/B,OAAO,OAAO;CACd,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,OAAO,OAAO,SAAS,cAAc;CACrC,OAAO,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC;CACtC,YAAY,OAAO,OAAO;EACzB,QAAQ,OAAO,OAAO,gBAAgB;EACtC,UAAU;CACX,CAAC;AACF,CAAC;AACD,MAAM,WAAW,OAAO,OAAO;CAC9B,MAAM,OAAO,QAAQ,MAAM;CAC3B,OAA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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 { 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 { 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])));\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});\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":";;;;;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,OAAO,QAAQ,SAAS;CAC9B,OAAO,OAAO;AACf,CAA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-1,4 +1,4 @@
1
- import { r as bindSchema$1 } from "../index-2q9FwJud.js";
1
+ import { r as bindSchema$1 } from "../index-CrWg4Z0y.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-B9XxyRO8.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-CrWg4Z0y.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-B9XxyRO8.js";
2
2
  export { SchemaDefinitionTypeId };
@@ -0,0 +1 @@
1
+ import "./pagination-D-R9NR61-CpIoHFoI.js";
@@ -1,6 +1,6 @@
1
- import "./id-Cs82tq9Q-hmYFyqTa.js";
1
+ import "./id-Cs82tq9Q-CK-maMgN.js";
2
2
  import { Schema } from "effect";
3
- //#region ../contracts/dist/descriptor-CEi5Jjiv.d.ts
3
+ //#region ../contracts/dist/descriptor-CxL_qKgP.d.ts
4
4
  //#region src/schema/descriptor.d.ts
5
5
  interface DescriptorField {
6
6
  readonly name: string;
@@ -50,6 +50,9 @@ type ValueDescriptor = {
50
50
  } | {
51
51
  readonly type: "record";
52
52
  readonly value: ValueDescriptor;
53
+ } | {
54
+ readonly type: "secret";
55
+ readonly value: ValueDescriptor;
53
56
  } | {
54
57
  readonly type: "string";
55
58
  } | {
@@ -66,7 +69,7 @@ type ValueFields = {
66
69
  readonly [fieldName: PropertyKey]: DescribedValue;
67
70
  };
68
71
  //#endregion
69
- //#region ../contracts/dist/pagination-Bt3l7QaC.d.ts
72
+ //#region ../contracts/dist/pagination-D-R9NR61.d.ts
70
73
  //#region src/runtime/pagination.d.ts
71
74
  declare const PaginationCursor: Schema.brand<Schema.String, "ignotum/runtime/PaginationCursor">;
72
75
  type PaginationCursor = typeof PaginationCursor.Type;
@@ -80,5 +83,5 @@ interface PaginationPage<Item> {
80
83
  readonly nextCursor: PaginationCursor | null;
81
84
  }
82
85
  //#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
86
+ export { ValueDescriptor as a, DescriptorField as i, PaginationPage as n, ValueDescriptorCarrier as o, DescribedValue as r, ValueFields as s, PaginationOptions as t };
87
+ //# sourceMappingURL=pagination-D-R9NR61-CpIoHFoI.d.ts.map
@@ -0,0 +1 @@
1
+ import "./id-Cs82tq9Q-CK-maMgN.js";
@@ -1,6 +1,6 @@
1
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";
2
+ import { a as getValueDescriptor, i as descriptorFields, n as attachValueDescriptor, o as PaginationCursor, r as descriptorAllowedInEnvironment, s as PaginationPageSize, u as ErrorBrand } from "./descriptor-XzDX2JDw-j3O6YHgW.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}'.`);
@@ -187,6 +187,16 @@ const union = (...members) => {
187
187
  members: members.map(requireDescriptor)
188
188
  });
189
189
  };
190
+ const Secret = {
191
+ isSecret: Redacted.isRedacted,
192
+ value: Redacted.value
193
+ };
194
+ function secret(value = string()) {
195
+ return attachValueDescriptor(Schema.RedactedFromValue(value, { disallowEncode: true }), {
196
+ type: "secret",
197
+ value: requireDescriptor(value)
198
+ });
199
+ }
190
200
  const paginationCursor = () => attachValueDescriptor(fresh(PaginationCursor), { type: "string" });
191
201
  const pagination = () => fixedObject({
192
202
  cursor: nullable(paginationCursor()),
@@ -233,6 +243,24 @@ const values = {
233
243
  string,
234
244
  union
235
245
  };
246
+ const environmentValues = {
247
+ array,
248
+ boolean,
249
+ date,
250
+ integer,
251
+ literal,
252
+ literals,
253
+ never,
254
+ null: nullValue,
255
+ nullable,
256
+ number,
257
+ object,
258
+ optional,
259
+ record,
260
+ secret,
261
+ string,
262
+ union
263
+ };
236
264
  const bindValues = (definition) => {
237
265
  const boundId = (tableName) => makeIdSchema(tableName);
238
266
  const doc = (tableName) => {
@@ -260,6 +288,7 @@ const bindValues = (definition) => {
260
288
  //#endregion
261
289
  //#region ../contracts/dist/runtime/schema.js
262
290
  const FunctionSchemaTypeId = Symbol.for("ignotum/runtime/schema/FunctionSchema");
291
+ const FunctionEnvironmentTypeId = Symbol.for("ignotum/runtime/schema/FunctionEnvironment");
263
292
  const attachFunctionSchema = (schema) => (definition) => {
264
293
  Object.defineProperty(definition, FunctionSchemaTypeId, {
265
294
  configurable: false,
@@ -270,6 +299,16 @@ const attachFunctionSchema = (schema) => (definition) => {
270
299
  return definition;
271
300
  };
272
301
  const getFunctionSchema = (value) => value[FunctionSchemaTypeId];
302
+ const attachFunctionEnvironment = (environment) => (definition) => {
303
+ Object.defineProperty(definition, FunctionEnvironmentTypeId, {
304
+ configurable: false,
305
+ enumerable: false,
306
+ value: environment,
307
+ writable: false
308
+ });
309
+ return definition;
310
+ };
311
+ const getFunctionEnvironment = (value) => value[FunctionEnvironmentTypeId];
273
312
  //#endregion
274
313
  //#region ../contracts/dist/schema/index.js
275
314
  const SchemaDefinitionTypeId = Symbol.for("ignotum/schema/SchemaDefinition");
@@ -284,22 +323,99 @@ const defineSchema = (define) => {
284
323
  [SchemaDefinitionTypeId]: definitions
285
324
  };
286
325
  };
287
- const makeFunctionBuilder = (schema, kind) => {
288
- const define = (definition) => attachFunctionSchema(schema)({
326
+ const EnvironmentDefinitionTypeId = Symbol.for("ignotum/schema/EnvironmentDefinition");
327
+ const EnvironmentDecoderTypeId = Symbol.for("ignotum/schema/EnvironmentDecoder");
328
+ const environmentLimits = {
329
+ bytes: 65536,
330
+ variables: 128
331
+ };
332
+ var EnvironmentValueInvalid = class extends Schema.TaggedError()("EnvironmentValueInvalid", {
333
+ key: Schema.optional(Schema.String),
334
+ message: Schema.String
335
+ }) {};
336
+ const environmentName = /^[A-Z_][A-Z0-9_]*$/;
337
+ const defineEnv = (define) => {
338
+ const fields = define({ values: environmentValues });
339
+ if (Reflect.ownKeys(fields).length > environmentLimits.variables) throw new Error(`Environments cannot declare more than ${environmentLimits.variables} variables.`);
340
+ for (const name of Reflect.ownKeys(fields)) {
341
+ if (!Predicate.isString(name)) throw new Error("Environment variable names must be strings.");
342
+ if (!environmentName.test(name)) throw new Error(`Environment variable '${name}' must match ${environmentName.source}.`);
343
+ if (name.startsWith("IGNOTUM_")) throw new Error(`Environment variable '${name}' uses the reserved IGNOTUM_ prefix.`);
344
+ }
345
+ const descriptors = descriptorFields(fields);
346
+ for (const field of descriptors) if (!descriptorAllowedInEnvironment(field.value)) throw new Error(`Environment variable '${field.name}' uses an unsupported validator.`);
347
+ const environment = {
348
+ _tag: "Environment",
349
+ fields,
350
+ descriptors,
351
+ schema: Schema.Struct(fields),
352
+ [EnvironmentDefinitionTypeId]: fields
353
+ };
354
+ Object.defineProperty(environment, EnvironmentDecoderTypeId, {
355
+ enumerable: false,
356
+ value: (raw) => decodeEnvironment(environment, raw)
357
+ });
358
+ return Object.freeze(environment);
359
+ };
360
+ const emptyEnv = defineEnv(() => ({}));
361
+ const utf8ByteLength = (value) => {
362
+ let bytes = 0;
363
+ for (const character of value) {
364
+ const point = character.codePointAt(0) ?? 0;
365
+ bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
366
+ }
367
+ return bytes;
368
+ };
369
+ const invalidValue = (key) => EnvironmentValueInvalid.make({
370
+ key,
371
+ message: `Environment variable '${key}' does not match its declaration.`
372
+ });
373
+ const decodeEnvironment = Effect.fn("Environment.decode")(function* (environment, raw) {
374
+ const declared = new Set(Object.keys(environment.fields));
375
+ const supplied = Object.keys(raw);
376
+ if (supplied.length > environmentLimits.variables) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot contain more than ${environmentLimits.variables} variables.` });
377
+ const rawJson = JSON.stringify(raw);
378
+ if (utf8ByteLength(rawJson) > environmentLimits.bytes) return yield* EnvironmentValueInvalid.make({ message: `Environments cannot exceed ${environmentLimits.bytes} UTF-8 bytes.` });
379
+ for (const key of supplied) if (!declared.has(key)) return yield* EnvironmentValueInvalid.make({
380
+ key,
381
+ message: `Environment variable '${key}' is not declared in server/env.ts.`
382
+ });
383
+ const decoded = {};
384
+ for (const [key, field] of Object.entries(environment.fields)) {
385
+ const input = Object.hasOwn(raw, key) ? raw[key] : void 0;
386
+ const direct = yield* Effect.result(Schema.decodeUnknownEffect(field)(input));
387
+ if (Result.isSuccess(direct)) {
388
+ if (direct.success !== void 0) Reflect.set(decoded, key, direct.success);
389
+ continue;
390
+ }
391
+ if (input === void 0) return yield* invalidValue(key);
392
+ const parsed = yield* Effect.result(Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(input));
393
+ if (Result.isFailure(parsed)) return yield* invalidValue(key);
394
+ const fromJson = yield* Effect.result(Schema.decodeUnknownEffect(field)(parsed.success));
395
+ if (Result.isFailure(fromJson)) return yield* invalidValue(key);
396
+ if (fromJson.success !== void 0) Reflect.set(decoded, key, fromJson.success);
397
+ }
398
+ return Object.freeze(decoded);
399
+ });
400
+ const decodeDefinedEnvironment = (environment, raw) => environment[EnvironmentDecoderTypeId](raw);
401
+ const makeFunctionBuilder = (schema, environment, kind) => {
402
+ const define = (definition) => attachFunctionEnvironment(environment)(attachFunctionSchema(schema)({
289
403
  _tag: kind,
290
404
  ...definition
291
- });
405
+ }));
292
406
  return define;
293
407
  };
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)
408
+ const makeFunctionBuilders = (schema, environment) => ({
409
+ mutation: makeFunctionBuilder(schema, environment, "Mutation"),
410
+ query: makeFunctionBuilder(schema, environment, "Query")
301
411
  });
412
+ function bindSchema(schema, environment = emptyEnv) {
413
+ return {
414
+ values: bindValues(schema[SchemaDefinitionTypeId]),
415
+ ...makeFunctionBuilders(schema, environment)
416
+ };
417
+ }
302
418
  //#endregion
303
- export { getFunctionSchema as i, bindSchema as n, defineSchema as r, SchemaDefinitionTypeId as t };
419
+ 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
420
 
305
- //# sourceMappingURL=schema-ERFjT8-m.js.map
421
+ //# sourceMappingURL=schema-B9XxyRO8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-B9XxyRO8.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 { c as getValueDescriptor, r as attachValueDescriptor, s as descriptorFields } from \"../descriptor-XzDX2JDw.js\";\nimport { PaginationCursor, PaginationPageSize } from \"../runtime/pagination.js\";\nimport { ErrorBrand } from \"../runtime/result.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 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\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 { a as descriptorContainsFile, c as getValueDescriptor, i as descriptorAllowedInEnvironment, n as ValueDescriptorTypeId, o as descriptorContainsSecret, s as descriptorFields, t as ValueDescriptor } from \"../descriptor-XzDX2JDw.js\";\nimport { Result } from \"../runtime/result.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":";;;;AAOA,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,IA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AAC;EAClG,MAAM;EACN,GAAG;CACJ,CAAC,CAAC;CACF,OAAO;AACR;AACA,MAAM,wBAAwB,QAAQ,iBAAiB;CACtD,UAAU,oBAAoB,QAAQ,aAAa,UAAU;CAC7D,OAAO,oBAAoB,QAAQ,aAAa,OAAO;AACxD;AACA,SAAS,WAAW,QAAQ,cAAc,UAAU;CACnD,OAAO;EACN,QAAQ,WAAW,OAAO,uBAAuB;EACjD,GAAG,qBAAqB,QAAQ,WAAW;CAC5C;AACD"}
@@ -1,9 +1,13 @@
1
- import { c as Result$1, g as FileValue, h as FileMimeType, i as ErrorValue, m as FileMetadata, p as FileFormat } from "./id-Cs82tq9Q-hmYFyqTa.js";
2
- import { i as defineSchema$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-Cs82tq9Q-CK-maMgN.js";
2
+ import "./result-DIjKM-p4.js";
3
+ 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-CrWg4Z0y.js";
3
4
  //#region src/server/index.d.ts
4
5
  declare const Result: typeof Result$1;
5
6
  type Result<Success, Failure extends ErrorValue> = Result$1<Success, Failure>;
7
+ declare const defineEnv: typeof defineEnv$1;
6
8
  declare const defineSchema: typeof defineSchema$1;
9
+ declare const Secret: typeof Secret$1;
10
+ type Secret<Value> = Secret$1<Value>;
7
11
  //#endregion
8
- export { type DefinedSchema, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Result, type SchemaAuthoring, defineSchema };
12
+ export { type DefinedEnv, type DefinedSchema, type EnvironmentAuthoring, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Result, type SchemaAuthoring, Secret, defineEnv, defineSchema };
9
13
  //# sourceMappingURL=server.d.ts.map
@@ -1,9 +1,11 @@
1
- import { d as Result$1 } from "./descriptor-C5VA9qRl-DuQsowaQ.js";
2
- import { r as defineSchema$1 } from "./schema-ERFjT8-m.js";
1
+ import { f as Result$1 } from "./descriptor-XzDX2JDw-j3O6YHgW.js";
2
+ import { a as defineSchema$1, i as defineEnv$1, l as Secret$1 } from "./schema-B9XxyRO8.js";
3
3
  //#region src/server/index.ts
4
4
  const Result = Result$1;
5
+ const defineEnv = defineEnv$1;
5
6
  const defineSchema = defineSchema$1;
7
+ const Secret = Secret$1;
6
8
  //#endregion
7
- export { Result, defineSchema };
9
+ export { Result, Secret, defineEnv, defineSchema };
8
10
 
9
11
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["contractResult","defineContractSchema"],"sources":["../../src/server/index.ts"],"sourcesContent":["import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, Result as ContractResult } from \"@ignotum/contracts/runtime/result\";\nimport { defineSchema as defineContractSchema } from \"@ignotum/contracts/schema\";\n\nexport const Result: typeof contractResult = contractResult;\nexport type Result<Success, Failure extends ErrorValue> = ContractResult<Success, Failure>;\nexport const defineSchema: typeof defineContractSchema = defineContractSchema;\nexport type {\n DefinedSchema,\n FileFormat,\n FileMetadata,\n FileMimeType,\n FileValue,\n SchemaAuthoring,\n} from \"@ignotum/contracts/schema\";\n"],"mappings":";;;AAIA,MAAa,SAAgCA;AAE7C,MAAa,eAA4CC"}
1
+ {"version":3,"file":"server.js","names":["contractResult","defineContractEnv","defineContractSchema","contractSecret"],"sources":["../../src/server/index.ts"],"sourcesContent":["import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, Result as ContractResult } from \"@ignotum/contracts/runtime/result\";\nimport {\n defineEnv as defineContractEnv,\n defineSchema as defineContractSchema,\n Secret as contractSecret,\n} from \"@ignotum/contracts/schema\";\nimport type { Secret as ContractSecret } from \"@ignotum/contracts/schema\";\n\nexport const Result: typeof contractResult = contractResult;\nexport type Result<Success, Failure extends ErrorValue> = ContractResult<Success, Failure>;\nexport const defineEnv: typeof defineContractEnv = defineContractEnv;\nexport const defineSchema: typeof defineContractSchema = defineContractSchema;\nexport const Secret: typeof contractSecret = contractSecret;\nexport type Secret<Value> = ContractSecret<Value>;\nexport type {\n DefinedEnv,\n DefinedSchema,\n EnvironmentAuthoring,\n FileFormat,\n FileMetadata,\n FileMimeType,\n FileValue,\n SchemaAuthoring,\n} from \"@ignotum/contracts/schema\";\n"],"mappings":";;;AASA,MAAa,SAAgCA;AAE7C,MAAa,YAAsCC;AACnD,MAAa,eAA4CC;AACzD,MAAa,SAAgCC"}
@@ -1,8 +1,8 @@
1
- import "./id-Cs82tq9Q-hmYFyqTa.js";
1
+ import "./id-Cs82tq9Q-CK-maMgN.js";
2
2
  import { Schema } from "effect";
3
3
  //#region ../contracts/dist/runtime/sync.d.ts
4
4
  declare const FunctionAddress: Schema.TemplateLiteral<readonly ["api.", Schema.String, ".", Schema.String]>;
5
5
  type FunctionAddress = typeof FunctionAddress.Type;
6
6
  //#endregion
7
7
  export { FunctionAddress as t };
8
- //# sourceMappingURL=sync-a2EdGSdY.d.ts.map
8
+ //# sourceMappingURL=sync-avN7NkcU.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ignotum",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Ignotum is an opinionated TypeScript application cloud.",
5
5
  "author": "Johannes Schießl",
6
6
  "repository": {
@@ -80,10 +80,10 @@
80
80
  "@effect/platform-node": "4.0.0-rc.111",
81
81
  "@effect/sql-sqlite-node": "4.0.0-rc.111",
82
82
  "redis": "6.2.1",
83
- "@ignotum/runtime": "1.0.0",
84
83
  "@ignotum/contracts": "1.0.0",
85
- "@ignotum/shared": "1.0.0",
86
- "@ignotum/deployment": "1.0.0"
84
+ "@ignotum/deployment": "1.0.0",
85
+ "@ignotum/runtime": "1.0.0",
86
+ "@ignotum/shared": "1.0.0"
87
87
  },
88
88
  "engines": {
89
89
  "node": ">=22.18.0"
@@ -8,6 +8,7 @@ import deployApp from "../../../../docs/user/deploy-app.md?raw";
8
8
  import deploymentModel from "../../../../docs/user/deployment-model.md?raw";
9
9
  import deployments from "../../../../docs/user/deployments.md?raw";
10
10
  import errors from "../../../../docs/user/errors.md?raw";
11
+ import environmentVariables from "../../../../docs/user/environment-variables.md?raw";
11
12
  import files from "../../../../docs/user/files.md?raw";
12
13
  import functions from "../../../../docs/user/functions.md?raw";
13
14
  import generatedCode from "../../../../docs/user/generated-code.md?raw";
@@ -45,6 +46,7 @@ const references = [
45
46
  ["deployment-model.md", deploymentModel],
46
47
  ["deployments.md", deployments],
47
48
  ["errors.md", errors],
49
+ ["environment-variables.md", environmentVariables],
48
50
  ["files.md", files],
49
51
  ["functions.md", functions],
50
52
  ["generated-code.md", generatedCode],
@@ -30,7 +30,7 @@ const AuthUrl = Schema.URL.check(
30
30
  Schema.makeFilter(
31
31
  (url) =>
32
32
  url.protocol === "https:" ||
33
- (url.protocol === "http:" && ["127.0.0.1", "::1", "localhost"].includes(url.hostname)),
33
+ (url.protocol === "http:" && ["127.0.0.1", "[::1]", "localhost"].includes(url.hostname)),
34
34
  { message: "The auth URL must use HTTPS unless it targets localhost." },
35
35
  ),
36
36
  );
package/src/cli/bin.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // @effect-diagnostics-next-line nodeBuiltinImport:off The isolated worker returns sensitive metadata over a dedicated inherited pipe.
4
+ import { writeSync } from "node:fs";
3
5
  import process from "node:process";
4
6
 
5
7
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
@@ -9,15 +11,23 @@ import { main } from "./command.js";
9
11
  import { runServerDiscoveryWorker } from "./build/server.js";
10
12
 
11
13
  const discoveryWorker = process.argv[2] === "__ignotum_discover_server";
14
+ const writeDiscovery = (encoded: string): void => {
15
+ const bytes = new TextEncoder().encode(encoded);
16
+ let offset = 0;
17
+ while (offset < bytes.byteLength) {
18
+ offset += writeSync(3, bytes, offset, bytes.byteLength - offset);
19
+ }
20
+ };
12
21
 
13
22
  if (discoveryWorker) {
14
23
  const appDirectory = process.argv[3];
15
24
  const moduleNames = process.argv[4];
16
- const outputPath = process.argv[5];
17
25
  globalThis.fetch = () => Promise.reject(new Error("Network access is disabled during builds."));
18
- (appDirectory === undefined || moduleNames === undefined || outputPath === undefined
26
+ (appDirectory === undefined || moduleNames === undefined
19
27
  ? Effect.die("Invalid isolated discovery arguments.")
20
- : runServerDiscoveryWorker(appDirectory, moduleNames, outputPath)
28
+ : runServerDiscoveryWorker(appDirectory, moduleNames).pipe(
29
+ Effect.tap((encoded) => Effect.sync(() => writeDiscovery(encoded))),
30
+ )
21
31
  ).pipe(
22
32
  // @effect-diagnostics-next-line strictEffectProvide:off The isolated worker is a process entry point.
23
33
  Effect.provide(NodeServices.layer),