ignotum 0.0.6 → 0.0.8

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 (54) hide show
  1. package/README.md +85 -101
  2. package/dist/cli/bin.mjs +1487 -168
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/runtime/{api-DtX8qPrq.js → api-BTeMI5tx.js} +27 -3
  5. package/dist/runtime/api-BTeMI5tx.js.map +1 -0
  6. package/dist/runtime/{api-D2bsAz4T.d.ts → api-D9lV-5av.d.ts} +7 -10
  7. package/dist/runtime/client.d.ts +27 -3
  8. package/dist/runtime/client.js +468 -68
  9. package/dist/runtime/client.js.map +1 -1
  10. package/dist/runtime/{descriptor-t6BOEGw9-BTHR-ZMv.js → descriptor-C5VA9qRl-C338iC6l.js} +63 -5
  11. package/dist/runtime/descriptor-C5VA9qRl-C338iC6l.js.map +1 -0
  12. package/dist/runtime/file-BXf63ulU.js +166 -0
  13. package/dist/runtime/file-BXf63ulU.js.map +1 -0
  14. package/dist/runtime/{result-BgcHn25t.d.ts → id-Btwac71X-DGj0DQuu.d.ts} +56 -4
  15. package/dist/runtime/{index-Dl_VQGmA.d.ts → index-CF04_Dps.d.ts} +96 -86
  16. package/dist/runtime/internal/api.d.ts +2 -2
  17. package/dist/runtime/internal/api.js +1 -1
  18. package/dist/runtime/internal/host.d.ts +25 -8
  19. package/dist/runtime/internal/host.js +209 -15
  20. package/dist/runtime/internal/host.js.map +1 -1
  21. package/dist/runtime/internal/server.d.ts +1 -1
  22. package/dist/runtime/internal/server.js +1 -1
  23. package/dist/runtime/internal/types.d.ts +1 -1
  24. package/dist/runtime/internal/types.js +1 -1
  25. package/dist/runtime/pagination-BNFhAjns.d.ts +1 -0
  26. package/dist/runtime/pagination-DrOowBve-Bnipd34u.d.ts +84 -0
  27. package/dist/runtime/{schema-B-jMZEbs.js → schema-DJfwfq87.js} +108 -30
  28. package/dist/runtime/schema-DJfwfq87.js.map +1 -0
  29. package/dist/runtime/server.d.ts +3 -3
  30. package/dist/runtime/server.js +2 -2
  31. package/dist/runtime/server.js.map +1 -1
  32. package/dist/runtime/sync-mIXn9eKv.d.ts +8 -0
  33. package/package.json +2 -2
  34. package/src/cli/agent-files.ts +56 -13
  35. package/src/cli/app-configuration.ts +4 -1
  36. package/src/cli/build/server.ts +83 -6
  37. package/src/cli/new-app.ts +15 -0
  38. package/src/client/files.ts +168 -0
  39. package/src/client/hooks.ts +166 -17
  40. package/src/client/index.ts +9 -1
  41. package/src/client/sync.ts +137 -21
  42. package/src/dev-runtime/database.ts +621 -78
  43. package/src/dev-runtime/files.ts +338 -0
  44. package/src/dev-runtime/functions.ts +14 -6
  45. package/src/dev-runtime/migrations.ts +44 -0
  46. package/src/dev-runtime/sync.ts +123 -5
  47. package/src/internal/api.ts +16 -1
  48. package/src/server/index.ts +8 -1
  49. package/dist/runtime/api-DtX8qPrq.js.map +0 -1
  50. package/dist/runtime/descriptor-t6BOEGw9-BTHR-ZMv.js.map +0 -1
  51. package/dist/runtime/id-Btwac71X-B9OeBzvq.d.ts +0 -9
  52. package/dist/runtime/id-D570vudg.js +0 -26
  53. package/dist/runtime/id-D570vudg.js.map +0 -1
  54. package/dist/runtime/schema-B-jMZEbs.js.map +0 -1
@@ -0,0 +1,166 @@
1
+ import { Predicate, Schema, SchemaGetter } from "effect";
2
+ //#region ../contracts/dist/runtime/id.js
3
+ const IdAlphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
4
+ const IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));
5
+ const IdPayloadPattern = /^[0-9a-z]{24}$/;
6
+ const withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });
7
+ const defineId = (prefix, brand) => {
8
+ const idPrefix = Schema.decodeSync(IdPrefix)(prefix);
9
+ return withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);
10
+ };
11
+ const GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand("ignotum/id")), void 0);
12
+ const AppId = defineId("app", "ignotum/hosted/AppId");
13
+ const DeploymentId = defineId("dep", "ignotum/hosted/DeploymentId");
14
+ defineId("team", "ignotum/hosted/TeamId");
15
+ const TableId = defineId("table", "ignotum/runtime/TableId");
16
+ defineId("prn", "ignotum/control/PlatformPrincipalId");
17
+ const InvocationId = defineId("inv", "ignotum/sync/InvocationId");
18
+ const SubscriptionId = defineId("sub", "ignotum/sync/SubscriptionId");
19
+ defineId("conn", "ignotum/gateway/ConnectionId");
20
+ const RuntimeRequestNonce = defineId("nonce", "ignotum/runtime/RequestNonce");
21
+ const RequestId = defineId("req", "ignotum/runtime/RequestId");
22
+ defineId("lock", "ignotum/dev/DatabaseLockId");
23
+ //#endregion
24
+ //#region ../contracts/dist/schema/file.js
25
+ const fileFormats = [
26
+ "jpeg",
27
+ "png",
28
+ "webp",
29
+ "avif",
30
+ "gif"
31
+ ];
32
+ const FileFormat = Schema.Literals(fileFormats);
33
+ const fileMimeTypes = {
34
+ avif: "image/avif",
35
+ gif: "image/gif",
36
+ jpeg: "image/jpeg",
37
+ png: "image/png",
38
+ webp: "image/webp"
39
+ };
40
+ const fileLimits = {
41
+ activeGrantsPerConnection: 1024,
42
+ distinctFilesPerQuerySnapshot: 256,
43
+ fileBytes: 10485760,
44
+ filesPerMutation: 8,
45
+ filenameBytes: 255,
46
+ mutationBytes: 26214400,
47
+ preparationLifetimeMillis: 9e5,
48
+ stagedBytesPerApp: 104857600
49
+ };
50
+ const FileId = Object.assign(Schema.String.pipe(Schema.check(Schema.isPattern(/^file_[0-9A-Za-z_-]{20,128}$/)), Schema.brand("ignotum/file/FileId")), { idPrefix: "file" });
51
+ defineId("upload", "ignotum/file/FileUploadToken");
52
+ defineId("grant", "ignotum/file/FileGrantToken");
53
+ const FileValueTypeId = Symbol.for("ignotum/file/FileValue");
54
+ const FileGrantTypeId = Symbol.for("ignotum/file/FileGrant");
55
+ const isFileValue = (value) => Predicate.isObject(value) && Predicate.hasProperty(value, FileValueTypeId) && Predicate.isObject(value[FileValueTypeId]) && Predicate.hasProperty(value[FileValueTypeId], "id") && Schema.is(FileId)(value[FileValueTypeId].id) && Predicate.hasProperty(value, "format") && Schema.is(FileFormat)(value.format) && Predicate.hasProperty(value, "name") && Predicate.isString(value.name) && Predicate.hasProperty(value, "size") && Predicate.isNumber(value.size) && Predicate.hasProperty(value, "mimeType") && value.mimeType === fileMimeTypes[value.format];
56
+ const buildFileValue = (id, metadata, grantUrl) => {
57
+ const value = {
58
+ format: metadata.format,
59
+ mimeType: fileMimeTypes[metadata.format],
60
+ name: metadata.name,
61
+ size: metadata.size
62
+ };
63
+ Object.defineProperty(value, FileValueTypeId, {
64
+ configurable: false,
65
+ enumerable: false,
66
+ value: Object.freeze({ id }),
67
+ writable: false
68
+ });
69
+ if (grantUrl !== void 0) Object.defineProperty(value, FileGrantTypeId, {
70
+ configurable: false,
71
+ enumerable: false,
72
+ value: grantUrl,
73
+ writable: false
74
+ });
75
+ return Object.freeze(value);
76
+ };
77
+ const makeFileValue = (id, metadata) => buildFileValue(id, metadata);
78
+ const fileIdOf = (value) => value[FileValueTypeId].id;
79
+ const grantFileValue = (value, url) => {
80
+ return buildFileValue(fileIdOf(value), value, url);
81
+ };
82
+ const fileGrantUrlOf = (value) => value[FileGrantTypeId];
83
+ const EncodedFileValue = Schema.Struct({
84
+ $ignotum: Schema.Literal("file"),
85
+ id: FileId,
86
+ format: FileFormat,
87
+ name: Schema.String,
88
+ size: Schema.Int.check(Schema.isBetween({
89
+ minimum: 0,
90
+ maximum: fileLimits.fileBytes
91
+ }))
92
+ });
93
+ const RuntimeFileMetadata = Schema.Struct({
94
+ id: FileId,
95
+ format: FileFormat,
96
+ name: Schema.String,
97
+ size: Schema.Int.check(Schema.isBetween({
98
+ minimum: 0,
99
+ maximum: fileLimits.fileBytes
100
+ }))
101
+ });
102
+ const FilePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));
103
+ const RuntimeFileOccurrence = Schema.Struct({
104
+ path: FilePath,
105
+ file: RuntimeFileMetadata
106
+ });
107
+ const DecodedFileValue = Schema.declare(isFileValue, { title: "FileValue" });
108
+ const FileValue = EncodedFileValue.pipe(Schema.decodeTo(DecodedFileValue, {
109
+ decode: SchemaGetter.transform((encoded) => makeFileValue(encoded.id, {
110
+ format: encoded.format,
111
+ name: encoded.name,
112
+ size: encoded.size
113
+ })),
114
+ encode: SchemaGetter.transform((value) => ({
115
+ $ignotum: "file",
116
+ format: value.format,
117
+ id: fileIdOf(value),
118
+ name: value.name,
119
+ size: value.size
120
+ }))
121
+ }));
122
+ const constrainedFileValue = (formats, maxBytes) => FileValue.pipe(Schema.check(Schema.makeFilter((value) => {
123
+ const issues = [];
124
+ if (!formats.includes(value.format)) issues.push({
125
+ path: ["format"],
126
+ issue: `File format '${value.format}' is not allowed by this field.`
127
+ });
128
+ if (value.size > maxBytes) issues.push({
129
+ path: ["size"],
130
+ issue: `File size ${value.size} exceeds this field's ${maxBytes} byte limit.`
131
+ });
132
+ return issues;
133
+ })));
134
+ const collectFileOccurrences = (value, path, occurrences) => {
135
+ if (isFileValue(value)) {
136
+ occurrences.push({
137
+ file: value,
138
+ path
139
+ });
140
+ return;
141
+ }
142
+ if (globalThis.Array.isArray(value)) {
143
+ for (const [index, child] of value.entries()) collectFileOccurrences(child, [...path, index], occurrences);
144
+ return;
145
+ }
146
+ if (!Predicate.isObject(value) || Predicate.isDate(value)) return;
147
+ for (const [key, child] of Object.entries(value)) collectFileOccurrences(child, [...path, key], occurrences);
148
+ };
149
+ const fileOccurrencesOf = (value) => {
150
+ const occurrences = [];
151
+ collectFileOccurrences(value, [], occurrences);
152
+ return occurrences;
153
+ };
154
+ const runtimeFileOccurrencesOf = (value) => fileOccurrencesOf(value).map(({ file, path }) => ({
155
+ path,
156
+ file: {
157
+ format: file.format,
158
+ id: fileIdOf(file),
159
+ name: file.name,
160
+ size: file.size
161
+ }
162
+ }));
163
+ //#endregion
164
+ export { RuntimeRequestNonce as C, RequestId as S, TableId as T, AppId as _, RuntimeFileMetadata as a, IdAlphabet as b, fileFormats as c, fileLimits as d, fileMimeTypes as f, runtimeFileOccurrencesOf as g, makeFileValue as h, FileValue as i, fileGrantUrlOf as l, isFileValue as m, FileFormat as n, RuntimeFileOccurrence as o, grantFileValue as p, FileId as r, constrainedFileValue as s, EncodedFileValue as t, fileIdOf as u, DeploymentId as v, SubscriptionId as w, InvocationId as x, GeneratedId as y };
165
+
166
+ //# sourceMappingURL=file-BXf63ulU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-BXf63ulU.js","names":[],"sources":["../../../contracts/dist/runtime/id.js","../../../contracts/dist/schema/file.js"],"sourcesContent":["import { Schema } from \"effect\";\n//#region src/runtime/id.ts\nconst IdAlphabet = \"0123456789abcdefghijklmnopqrstuvwxyz\";\nconst IdLength = 24;\nconst IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));\nconst IdPayloadPattern = /^[0-9a-z]{24}$/;\nconst withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });\nconst defineId = (prefix, brand) => {\n\tconst idPrefix = Schema.decodeSync(IdPrefix)(prefix);\n\treturn withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);\n};\nconst GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand(\"ignotum/id\")), void 0);\nconst AppId = defineId(\"app\", \"ignotum/hosted/AppId\");\nconst DeploymentId = defineId(\"dep\", \"ignotum/hosted/DeploymentId\");\nconst TeamId = defineId(\"team\", \"ignotum/hosted/TeamId\");\nconst TableId = defineId(\"table\", \"ignotum/runtime/TableId\");\nconst PlatformPrincipalId = defineId(\"prn\", \"ignotum/control/PlatformPrincipalId\");\nconst InvocationId = defineId(\"inv\", \"ignotum/sync/InvocationId\");\nconst SubscriptionId = defineId(\"sub\", \"ignotum/sync/SubscriptionId\");\nconst ConnectionId = defineId(\"conn\", \"ignotum/gateway/ConnectionId\");\nconst RuntimeRequestNonce = defineId(\"nonce\", \"ignotum/runtime/RequestNonce\");\nconst RequestId = defineId(\"req\", \"ignotum/runtime/RequestId\");\nconst DevDatabaseLockId = defineId(\"lock\", \"ignotum/dev/DatabaseLockId\");\n//#endregion\nexport { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, GeneratedId, IdAlphabet, IdLength, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId, defineId };\n\n//# sourceMappingURL=id.js.map","import { defineId } from \"../runtime/id.js\";\nimport { Predicate, Schema, SchemaGetter } from \"effect\";\n//#region src/schema/file.ts\nconst fileFormats = [\n\t\"jpeg\",\n\t\"png\",\n\t\"webp\",\n\t\"avif\",\n\t\"gif\"\n];\nconst FileFormat = Schema.Literals(fileFormats);\nconst fileMimeTypes = {\n\tavif: \"image/avif\",\n\tgif: \"image/gif\",\n\tjpeg: \"image/jpeg\",\n\tpng: \"image/png\",\n\twebp: \"image/webp\"\n};\nconst fileLimits = {\n\tactiveGrantsPerConnection: 1024,\n\tdistinctFilesPerQuerySnapshot: 256,\n\tfileBytes: 10485760,\n\tfilesPerMutation: 8,\n\tfilenameBytes: 255,\n\tmutationBytes: 26214400,\n\tpreparationLifetimeMillis: 9e5,\n\tstagedBytesPerApp: 104857600\n};\nconst FileId = Object.assign(Schema.String.pipe(Schema.check(Schema.isPattern(/^file_[0-9A-Za-z_-]{20,128}$/)), Schema.brand(\"ignotum/file/FileId\")), { idPrefix: \"file\" });\nconst FileUploadToken = defineId(\"upload\", \"ignotum/file/FileUploadToken\");\nconst FileGrantToken = defineId(\"grant\", \"ignotum/file/FileGrantToken\");\nconst FileValueTypeId = Symbol.for(\"ignotum/file/FileValue\");\nconst FileGrantTypeId = Symbol.for(\"ignotum/file/FileGrant\");\nconst isFileValue = (value) => Predicate.isObject(value) && Predicate.hasProperty(value, FileValueTypeId) && Predicate.isObject(value[FileValueTypeId]) && Predicate.hasProperty(value[FileValueTypeId], \"id\") && Schema.is(FileId)(value[FileValueTypeId].id) && Predicate.hasProperty(value, \"format\") && Schema.is(FileFormat)(value.format) && Predicate.hasProperty(value, \"name\") && Predicate.isString(value.name) && Predicate.hasProperty(value, \"size\") && Predicate.isNumber(value.size) && Predicate.hasProperty(value, \"mimeType\") && value.mimeType === fileMimeTypes[value.format];\nconst buildFileValue = (id, metadata, grantUrl) => {\n\tconst value = {\n\t\tformat: metadata.format,\n\t\tmimeType: fileMimeTypes[metadata.format],\n\t\tname: metadata.name,\n\t\tsize: metadata.size\n\t};\n\tObject.defineProperty(value, FileValueTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: Object.freeze({ id }),\n\t\twritable: false\n\t});\n\tif (grantUrl !== void 0) Object.defineProperty(value, FileGrantTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: grantUrl,\n\t\twritable: false\n\t});\n\treturn Object.freeze(value);\n};\nconst makeFileValue = (id, metadata) => buildFileValue(id, metadata);\nconst fileIdOf = (value) => value[FileValueTypeId].id;\nconst grantFileValue = (value, url) => {\n\treturn buildFileValue(fileIdOf(value), value, url);\n};\nconst fileGrantUrlOf = (value) => value[FileGrantTypeId];\nconst EncodedFileValue = Schema.Struct({\n\t$ignotum: Schema.Literal(\"file\"),\n\tid: FileId,\n\tformat: FileFormat,\n\tname: Schema.String,\n\tsize: Schema.Int.check(Schema.isBetween({\n\t\tminimum: 0,\n\t\tmaximum: fileLimits.fileBytes\n\t}))\n});\nconst RuntimeFileMetadata = Schema.Struct({\n\tid: FileId,\n\tformat: FileFormat,\n\tname: Schema.String,\n\tsize: Schema.Int.check(Schema.isBetween({\n\t\tminimum: 0,\n\t\tmaximum: fileLimits.fileBytes\n\t}))\n});\nconst FilePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));\nconst RuntimeFileOccurrence = Schema.Struct({\n\tpath: FilePath,\n\tfile: RuntimeFileMetadata\n});\nconst DecodedFileValue = Schema.declare(isFileValue, { title: \"FileValue\" });\nconst FileValue = EncodedFileValue.pipe(Schema.decodeTo(DecodedFileValue, {\n\tdecode: SchemaGetter.transform((encoded) => makeFileValue(encoded.id, {\n\t\tformat: encoded.format,\n\t\tname: encoded.name,\n\t\tsize: encoded.size\n\t})),\n\tencode: SchemaGetter.transform((value) => ({\n\t\t$ignotum: \"file\",\n\t\tformat: value.format,\n\t\tid: fileIdOf(value),\n\t\tname: value.name,\n\t\tsize: value.size\n\t}))\n}));\nconst constrainedFileValue = (formats, maxBytes) => FileValue.pipe(Schema.check(Schema.makeFilter((value) => {\n\tconst issues = [];\n\tif (!formats.includes(value.format)) issues.push({\n\t\tpath: [\"format\"],\n\t\tissue: `File format '${value.format}' is not allowed by this field.`\n\t});\n\tif (value.size > maxBytes) issues.push({\n\t\tpath: [\"size\"],\n\t\tissue: `File size ${value.size} exceeds this field's ${maxBytes} byte limit.`\n\t});\n\treturn issues;\n})));\nconst collectFileOccurrences = (value, path, occurrences) => {\n\tif (isFileValue(value)) {\n\t\toccurrences.push({\n\t\t\tfile: value,\n\t\t\tpath\n\t\t});\n\t\treturn;\n\t}\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectFileOccurrences(child, [...path, index], occurrences);\n\t\treturn;\n\t}\n\tif (!Predicate.isObject(value) || Predicate.isDate(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectFileOccurrences(child, [...path, key], occurrences);\n};\nconst fileOccurrencesOf = (value) => {\n\tconst occurrences = [];\n\tcollectFileOccurrences(value, [], occurrences);\n\treturn occurrences;\n};\nconst runtimeFileOccurrencesOf = (value) => fileOccurrencesOf(value).map(({ file, path }) => ({\n\tpath,\n\tfile: {\n\t\tformat: file.format,\n\t\tid: fileIdOf(file),\n\t\tname: file.name,\n\t\tsize: file.size\n\t}\n}));\nconst collectEncodedFileOccurrences = (value, path, occurrences) => {\n\tif (Schema.is(EncodedFileValue)(value)) {\n\t\tconst file = Schema.decodeUnknownSync(EncodedFileValue)(value);\n\t\toccurrences.push({\n\t\t\tpath,\n\t\t\tfile: {\n\t\t\t\tformat: file.format,\n\t\t\t\tid: file.id,\n\t\t\t\tname: file.name,\n\t\t\t\tsize: file.size\n\t\t\t}\n\t\t});\n\t\treturn;\n\t}\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectEncodedFileOccurrences(child, [...path, index], occurrences);\n\t\treturn;\n\t}\n\tif (!Schema.is(Schema.JsonObject)(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectEncodedFileOccurrences(child, [...path, key], occurrences);\n};\nconst encodedFileOccurrencesOf = (value) => {\n\tconst occurrences = [];\n\tcollectEncodedFileOccurrences(value, [], occurrences);\n\treturn occurrences;\n};\n//#endregion\nexport { EncodedFileValue, FileFormat, FileGrantToken, FileGrantTypeId, FileId, FilePath, FileUploadToken, FileValue, FileValueTypeId, RuntimeFileMetadata, RuntimeFileOccurrence, constrainedFileValue, encodedFileOccurrencesOf, fileFormats, fileGrantUrlOf, fileIdOf, fileLimits, fileMimeTypes, fileOccurrencesOf, grantFileValue, isFileValue, makeFileValue, runtimeFileOccurrencesOf };\n\n//# sourceMappingURL=file.js.map"],"mappings":";;AAEA,MAAM,aAAa;AAEnB,MAAM,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,UAAU,CAAC;AACjE,MAAM,mBAAmB;AACzB,MAAM,cAAc,YAAY,aAAa,OAAO,OAAO,YAAY,EAAE,SAAS,CAAC;AACnF,MAAM,YAAY,QAAQ,UAAU;CACnC,MAAM,WAAW,OAAO,WAAW,QAAQ,CAAC,CAAC,MAAM;CACnD,OAAO,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,IAAI,OAAO,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,CAAC,GAAG,QAAQ;AACtI;AACA,MAAM,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AM,QAAQ,GAAG,uBAAuB,OAAO,CAAC,GAAG,MAAM,KAAK,GAAG,WAAW;EACzG;CACD;CACA,IAAI,CAAC,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,KAAK,GAAG;CAC3D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG,uBAAuB,OAAO,CAAC,GAAG,MAAM,GAAG,GAAG,WAAW;AAC5G;AACA,MAAM,qBAAqB,UAAU;CACpC,MAAM,cAAc,CAAC;CACrB,uBAAuB,OAAO,CAAC,GAAG,WAAW;CAC7C,OAAO;AACR;AACA,MAAM,4BAA4B,UAAU,kBAAkB,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,YAAY;CAC7F;CACA,MAAM;EACL,QAAQ,KAAK;EACb,IAAI,SAAS,IAAI;EACjB,MAAM,KAAK;EACX,MAAM,KAAK;CACZ;AACD,EAAE"}
@@ -1,11 +1,57 @@
1
1
  import { Brand, Effect, Schema } from "effect";
2
- //#region ../contracts/dist/value-CiN-5gJo.d.ts
2
+ //#region ../contracts/dist/file-8gh4oKiS.d.ts
3
+ //#region src/schema/file.d.ts
4
+ declare const fileFormats: readonly ["jpeg", "png", "webp", "avif", "gif"];
5
+ declare const FileFormat: Schema.Literals<readonly ["jpeg", "png", "webp", "avif", "gif"]>;
6
+ type FileFormat = typeof FileFormat.Type;
7
+ declare const fileMimeTypes: {
8
+ readonly avif: "image/avif";
9
+ readonly gif: "image/gif";
10
+ readonly jpeg: "image/jpeg";
11
+ readonly png: "image/png";
12
+ readonly webp: "image/webp";
13
+ };
14
+ type FileMimeType<Format extends FileFormat = FileFormat> = (typeof fileMimeTypes)[Format];
15
+ declare const FileId: Schema.brand<Schema.String, "ignotum/file/FileId"> & {
16
+ readonly idPrefix: "file";
17
+ };
18
+ type FileId = typeof FileId.Type;
19
+ declare const FileValueTypeId: unique symbol;
20
+ declare const FileGrantTypeId: unique symbol;
21
+ interface FileIdentity {
22
+ readonly id: FileId;
23
+ }
24
+ interface FileValue<Format extends FileFormat = FileFormat> {
25
+ readonly name: string;
26
+ readonly format: Format;
27
+ readonly mimeType: FileMimeType<Format>;
28
+ readonly size: number;
29
+ readonly [FileValueTypeId]: FileIdentity;
30
+ readonly [FileGrantTypeId]?: string;
31
+ }
32
+ interface FileMetadata<Format extends FileFormat = FileFormat> {
33
+ readonly name: string;
34
+ readonly format: Format;
35
+ readonly mimeType: FileMimeType<Format>;
36
+ readonly size: number;
37
+ }
38
+ declare const FileValue: Schema.decodeTo<Schema.declare<FileValue<"avif" | "gif" | "jpeg" | "png" | "webp">, FileValue<"avif" | "gif" | "jpeg" | "png" | "webp">>, Schema.Struct<{
39
+ readonly $ignotum: Schema.Literal<"file">;
40
+ readonly id: Schema.brand<Schema.String, "ignotum/file/FileId"> & {
41
+ readonly idPrefix: "file";
42
+ };
43
+ readonly format: Schema.Literals<readonly ["jpeg", "png", "webp", "avif", "gif"]>;
44
+ readonly name: Schema.String;
45
+ readonly size: Schema.Int;
46
+ }>, never, never>;
47
+ //#endregion
48
+ //#region ../contracts/dist/value-BqGe6EhK.d.ts
3
49
  //#region src/runtime/value.d.ts
4
50
  interface TransportArray extends ReadonlyArray<TransportValue> {}
5
51
  interface TransportObject {
6
52
  readonly [key: string]: TransportValue | undefined;
7
53
  }
8
- type TransportValue = null | boolean | number | string | Date | TransportArray | TransportObject;
54
+ type TransportValue = null | boolean | number | string | Date | FileValue | TransportArray | TransportObject;
9
55
  //#endregion
10
56
  //#region ../contracts/dist/runtime/result.d.ts
11
57
  //#region src/runtime/result.d.ts
@@ -117,5 +163,11 @@ declare const Result: {
117
163
  try: typeof tryResult;
118
164
  };
119
165
  //#endregion
120
- export { Match as a, SettledResult as c, TransportValue as d, InternalServerError as i, documentNotFound as l, ErrorBrand as n, QueryResult as o, ErrorValue as r, Result as s, DocumentNotFoundValue as t, TransportObject as u };
121
- //# sourceMappingURL=result-BgcHn25t.d.ts.map
166
+ //#region ../contracts/dist/id-Btwac71X.d.ts
167
+ declare const GeneratedId: Schema.brand<Schema.String, "ignotum/id"> & {
168
+ readonly idPrefix: undefined;
169
+ };
170
+ type GeneratedId = typeof GeneratedId.Type;
171
+ //#endregion
172
+ export { fileFormats as _, InternalServerError as a, Result as c, TransportObject as d, TransportValue as f, FileValue as g, FileMimeType as h, ErrorValue as i, SettledResult as l, FileMetadata as m, DocumentNotFoundValue as n, Match as o, FileFormat as p, ErrorBrand as r, QueryResult as s, GeneratedId as t, documentNotFound as u };
173
+ //# sourceMappingURL=id-Btwac71X-DGj0DQuu.d.ts.map
@@ -1,68 +1,6 @@
1
- import { n as ErrorBrand, r as ErrorValue, s as Result, t as DocumentNotFoundValue } from "./result-BgcHn25t.js";
2
- import { t as GeneratedId } from "./id-Btwac71X-B9OeBzvq.js";
1
+ import { _ as fileFormats, c as Result, g as FileValue, i as ErrorValue, n as DocumentNotFoundValue, p as FileFormat, r as ErrorBrand, t as GeneratedId } from "./id-Btwac71X-DGj0DQuu.js";
2
+ import { a as ValueDescriptorCarrier, i as ValueDescriptor, n as PaginationPage, o as ValueFields, r as DescribedValue, t as PaginationOptions } from "./pagination-DrOowBve-Bnipd34u.js";
3
3
  import { Brand, Effect, Schema, Struct } from "effect";
4
- //#region ../contracts/dist/descriptor-CVZycwe2.d.ts
5
- //#region src/schema/descriptor.d.ts
6
- interface DescriptorField {
7
- readonly name: string;
8
- readonly value: ValueDescriptor;
9
- }
10
- type ValueDescriptor = {
11
- readonly type: "array";
12
- readonly value: ValueDescriptor;
13
- } | {
14
- readonly type: "boolean";
15
- } | {
16
- readonly type: "date";
17
- } | {
18
- readonly type: "error";
19
- readonly tag: string;
20
- readonly fields: ReadonlyArray<DescriptorField>;
21
- } | {
22
- readonly type: "id";
23
- readonly table: string;
24
- } | {
25
- readonly type: "integer";
26
- } | {
27
- readonly type: "literal";
28
- readonly value: string | number | boolean;
29
- } | {
30
- readonly type: "literals";
31
- readonly values: ReadonlyArray<string | number | boolean>;
32
- } | {
33
- readonly type: "never";
34
- } | {
35
- readonly type: "null";
36
- } | {
37
- readonly type: "nullable";
38
- readonly value: ValueDescriptor;
39
- } | {
40
- readonly type: "number";
41
- } | {
42
- readonly type: "object";
43
- readonly fields: ReadonlyArray<DescriptorField>;
44
- } | {
45
- readonly type: "optional";
46
- readonly value: ValueDescriptor;
47
- } | {
48
- readonly type: "record";
49
- readonly value: ValueDescriptor;
50
- } | {
51
- readonly type: "string";
52
- } | {
53
- readonly type: "union";
54
- readonly members: ReadonlyArray<ValueDescriptor>;
55
- };
56
- declare const ValueDescriptor: Schema.Codec<ValueDescriptor>;
57
- declare const ValueDescriptorTypeId: unique symbol;
58
- interface ValueDescriptorCarrier {
59
- readonly [ValueDescriptorTypeId]: ValueDescriptor;
60
- }
61
- type DescribedValue<Value extends Schema.Constraint = Schema.Constraint> = Value & ValueDescriptorCarrier;
62
- type ValueFields = {
63
- readonly [fieldName: PropertyKey]: DescribedValue;
64
- };
65
- //#endregion
66
4
  //#region ../contracts/dist/types-DDg3XIFc.d.ts
67
5
  //#region src/schema/types.d.ts
68
6
  /** A document identifier branded with the table it belongs to. */
@@ -119,14 +57,26 @@ interface FixedObjectValidator<Fields extends Schema.Struct.Fields> extends Sche
119
57
  type ObjectDefinition<Fields extends Schema.Struct.Fields> = DescribedValue<PreserveIdMetadata<FixedObjectValidator<Fields>, Fields[keyof Fields]>>;
120
58
  type ResolvedFields<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields]: Omit<Fields[FieldName], typeof UnresolvedReferencesTypeId>; };
121
59
  type LiteralValue = string | number | boolean;
122
- interface TableDefinition<Fields extends Schema.Struct.Fields> {
60
+ interface IndexDefinition<Name extends string = string, FieldNames extends readonly string[] = readonly string[]> {
61
+ readonly name: Name;
62
+ readonly fields: FieldNames;
63
+ }
64
+ interface IndexDefinitions {
65
+ readonly [indexName: string]: IndexDefinition;
66
+ }
67
+ type IndexScalar = boolean | Date | number | string;
68
+ type IndexFieldName<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields & string]: Fields[FieldName]["Type"] extends IndexScalar ? FieldName : never; }[keyof Fields & string];
69
+ type IndexFieldTuple<Fields extends Schema.Struct.Fields> = readonly [IndexFieldName<Fields>, ...ReadonlyArray<IndexFieldName<Fields>>];
70
+ interface TableDefinition<Fields extends Schema.Struct.Fields, Indexes extends IndexDefinitions = {}> {
123
71
  readonly _tag: "Table";
124
72
  readonly descriptor: ValueDescriptor;
125
73
  readonly fields: Fields;
74
+ readonly indexes: Indexes;
126
75
  readonly schema: Schema.Struct<Fields>;
76
+ readonly index: <const Name extends string, const FieldNames extends IndexFieldTuple<Fields>>(name: Name extends keyof Indexes ? never : Name, fields: FieldNames) => TableDefinition<Fields, Indexes & Record<Name, IndexDefinition<Name, FieldNames>>>;
127
77
  }
128
78
  interface TableDefinitions {
129
- readonly [tableName: string]: TableDefinition<Schema.Struct.Fields>;
79
+ readonly [tableName: string]: TableDefinition<Schema.Struct.Fields, IndexDefinitions>;
130
80
  }
131
81
  type TableNameOf$1<Definition extends TableDefinitions> = keyof Definition & string;
132
82
  type ReservedFieldName = "createdAt" | "id" | "updatedAt";
@@ -149,6 +99,19 @@ declare const number: () => DescribedValue<Schema.Finite>;
149
99
  declare const integer: () => DescribedValue<Schema.Int>;
150
100
  declare const boolean: () => DescribedValue<Schema.Boolean>;
151
101
  declare const date: () => DescribedValue<Schema.DateFromMillis>;
102
+ interface FileOptions<Formats extends readonly FileFormat[]> {
103
+ readonly formats?: Formats;
104
+ readonly maxBytes?: number;
105
+ }
106
+ declare const file: <const Formats extends readonly FileFormat[] = typeof fileFormats>(options?: FileOptions<Formats>) => DescribedValue<Schema.decodeTo<Schema.declare<FileValue<"avif" | "gif" | "jpeg" | "png" | "webp">, FileValue<"avif" | "gif" | "jpeg" | "png" | "webp">>, Schema.Struct<{
107
+ readonly $ignotum: Schema.Literal<"file">;
108
+ readonly id: Schema.brand<Schema.String, "ignotum/file/FileId"> & {
109
+ readonly idPrefix: "file";
110
+ };
111
+ readonly format: Schema.Literals<readonly ["jpeg", "png", "webp", "avif", "gif"]>;
112
+ readonly name: Schema.String;
113
+ readonly size: Schema.Int;
114
+ }>, never, never>> & Schema.Schema<FileValue<Formats[number]>>;
152
115
  declare const never: () => DescribedValue<Schema.Never>;
153
116
  declare const nullValue: () => DescribedValue<Schema.Null>;
154
117
  declare const literal: <const Value extends LiteralValue>(value: Value) => DescribedValue<Schema.Literal<Value>>;
@@ -160,11 +123,20 @@ declare const optional: <Value extends DescribedValue>(value: Value) => Preserve
160
123
  declare const nullable: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.NullOr<Value>, Value>;
161
124
  declare const record: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.$Record<Schema.String, Value>, Value>;
162
125
  declare const union: <const Members extends ReadonlyArray<DescribedValue>>(...members: Members) => PreserveValueMetadata<Schema.Union<Members>, Members[number]>;
126
+ declare const pagination: () => ObjectDefinition<{
127
+ readonly cursor: DescribedValue<Schema.NullOr<DescribedValue<Schema.brand<Schema.String, "ignotum/runtime/PaginationCursor">>> & Schema.Constraint>;
128
+ readonly pageSize: DescribedValue<Schema.brand<Schema.Int, "ignotum/runtime/PaginationPageSize">>;
129
+ }>;
130
+ declare const page: <Value extends DescribedValue>(value: Value) => ObjectDefinition<{
131
+ readonly items: PreserveValueMetadata<Schema.$Array<Value>, Value>;
132
+ readonly nextCursor: DescribedValue<Schema.NullOr<DescribedValue<Schema.brand<Schema.String, "ignotum/runtime/PaginationCursor">>> & Schema.Constraint>;
133
+ }> & Schema.Schema<PaginationPage<Value["Type"]>>;
163
134
  declare const error: <const Tag extends string, const Fields extends ValueFields>(tag: Tag & ErrorTagValidation<Tag>, fields: Fields & ReservedErrorFieldValidation<NoInfer<Fields>>) => ErrorDefinition<Tag, Fields>;
164
135
  declare const values: {
165
136
  array: typeof array;
166
137
  boolean: typeof boolean;
167
138
  date: typeof date;
139
+ file: typeof file;
168
140
  error: typeof error;
169
141
  id: typeof id;
170
142
  integer: typeof integer;
@@ -188,11 +160,13 @@ type DocumentDefinition<Definition extends TableDefinitions, TableName extends T
188
160
  type BoundValues<Definition extends TableDefinitions> = Omit<typeof values, "id"> & {
189
161
  readonly doc: <const TableName extends TableNameOf$1<Definition>>(tableName: TableName) => DocumentDefinition<Definition, TableName>;
190
162
  readonly id: <const TableName extends TableNameOf$1<Definition>>(tableName: TableName) => IdDefinition<TableName>;
163
+ readonly page: typeof page;
164
+ readonly pagination: () => ReturnType<typeof pagination> & Schema.Schema<PaginationOptions>;
191
165
  };
192
166
  //#endregion
193
167
  //#region ../contracts/dist/schema/index.d.ts
194
168
  //#region src/schema/definition.d.ts
195
- type AnyTableDefinition = TableDefinition<Schema.Struct.Fields>;
169
+ type AnyTableDefinition = TableDefinition<Schema.Struct.Fields, IndexDefinitions>;
196
170
  interface Tables {
197
171
  readonly [tableName: string]: AnyTableDefinition;
198
172
  }
@@ -221,6 +195,11 @@ interface ErrorSchema extends Schema.ConstraintCodec<ErrorValue, unknown, never,
221
195
  interface ResolvedFunctionValue {
222
196
  readonly [UnresolvedReferencesTypeId]?: never;
223
197
  }
198
+ type ContainsFile<Value> = Value extends FileValue ? true : Value extends Date ? false : Value extends ReadonlyArray<infer Item> ? true extends ContainsFile<Item> ? true : false : Value extends object ? true extends { [Key in keyof Value]-?: ContainsFile<Value[Key]>; }[keyof Value] ? true : false : false;
199
+ declare const InvalidFilePositionTypeId: unique symbol;
200
+ type FileFree<Value, Position extends string> = true extends ContainsFile<Value> ? {
201
+ readonly [InvalidFilePositionTypeId]: `Files cannot appear in ${Position}`;
202
+ } : unknown;
224
203
  type ResolvedFunctionFields<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields]: Fields[FieldName] & ResolvedFunctionValue & TransportSchema; };
225
204
  interface ForbiddenSystemFields {
226
205
  readonly id?: never;
@@ -234,8 +213,39 @@ type FunctionReturns = TransportSchema | undefined;
234
213
  type ArgsOf<Args extends FunctionArgs> = Args extends Schema.Struct.Fields ? keyof Args extends never ? void : Schema.Struct.Type<Args> : void;
235
214
  type ReturnOf<Returns extends FunctionReturns> = Returns extends TransportSchema ? Returns["Type"] : void;
236
215
  type DocumentNotFound<TableName extends string = string> = DocumentNotFoundValue<TableName, Id<TableName>>;
237
- interface DatabaseQuery<Definition extends Tables, Name extends TableNameOf<Definition>> {
216
+ declare const IndexRangeTypeId: unique symbol;
217
+ interface IndexRangeExpression {
218
+ readonly [IndexRangeTypeId]: true;
219
+ }
220
+ type IndexFields<Definition extends Tables, Name extends TableNameOf<Definition>, IndexName extends keyof Definition[Name]["indexes"]> = Definition[Name]["indexes"][IndexName]["fields"] extends (infer Fields extends readonly string[]) ? readonly [...Fields, "createdAt", "id"] : never;
221
+ type IndexFieldValue<Definition extends Tables, Name extends TableNameOf<Definition>, FieldName extends string> = FieldName extends "createdAt" ? Date : FieldName extends "id" ? Id<Name> : FieldName extends keyof FieldsOf<Definition[Name]> ? FieldsOf<Definition[Name]>[FieldName]["Type"] : never;
222
+ interface IndexLowerBound<Definition extends Tables, Name extends TableNameOf<Definition>, FieldName extends string> extends IndexRangeExpression {
223
+ lt(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexRangeExpression;
224
+ lte(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexRangeExpression;
225
+ }
226
+ interface IndexUpperBound<Definition extends Tables, Name extends TableNameOf<Definition>, FieldName extends string> extends IndexRangeExpression {
227
+ gt(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexRangeExpression;
228
+ gte(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexRangeExpression;
229
+ }
230
+ interface IndexRangeBuilder<Definition extends Tables, Name extends TableNameOf<Definition>, Fields extends readonly string[]> extends IndexRangeExpression {
231
+ eq<FieldName extends Fields[0]>(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexRangeBuilder<Definition, Name, Fields extends readonly [string, ...infer Rest extends string[]] ? Rest : []>;
232
+ gt<FieldName extends Fields[0]>(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexLowerBound<Definition, Name, FieldName>;
233
+ gte<FieldName extends Fields[0]>(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexLowerBound<Definition, Name, FieldName>;
234
+ lt<FieldName extends Fields[0]>(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexUpperBound<Definition, Name, FieldName>;
235
+ lte<FieldName extends Fields[0]>(field: FieldName, value: IndexFieldValue<Definition, Name, FieldName>): IndexUpperBound<Definition, Name, FieldName>;
236
+ }
237
+ interface OrderedDatabaseQuery<Definition extends Tables, Name extends TableNameOf<Definition>> {
238
238
  collect(): Result<ReadonlyArray<Document<Definition, Name>>, never>;
239
+ take(count: number): Result<ReadonlyArray<Document<Definition, Name>>, never>;
240
+ first(): Result<Document<Definition, Name> | undefined, never>;
241
+ unique(): Result<Document<Definition, Name> | undefined, never>;
242
+ paginate(options: PaginationOptions): Result<PaginationPage<Document<Definition, Name>>, never>;
243
+ }
244
+ interface SelectableDatabaseQuery<Definition extends Tables, Name extends TableNameOf<Definition>> extends OrderedDatabaseQuery<Definition, Name> {
245
+ order(direction: "asc" | "desc"): OrderedDatabaseQuery<Definition, Name>;
246
+ }
247
+ interface DatabaseQuery<Definition extends Tables, Name extends TableNameOf<Definition>> extends SelectableDatabaseQuery<Definition, Name> {
248
+ index<const IndexName extends keyof Definition[Name]["indexes"] & string>(name: IndexName, range?: (builder: IndexRangeBuilder<Definition, Name, IndexFields<Definition, Name, IndexName>>) => IndexRangeExpression): SelectableDatabaseQuery<Definition, Name>;
239
249
  }
240
250
  interface DatabaseReader<Definition extends Tables> {
241
251
  query<const Name extends TableNameOf<Definition>>(name: Name): DatabaseQuery<Definition, Name>;
@@ -243,10 +253,10 @@ interface DatabaseReader<Definition extends Tables> {
243
253
  get<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>): Result<Document<Definition, Name>, DocumentNotFound<Name>>;
244
254
  }
245
255
  interface DatabaseWriter<Definition extends Tables> extends DatabaseReader<Definition> {
246
- delete<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>): Result<void, never>;
256
+ delete<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>): Result<void, DocumentNotFound<Name>>;
247
257
  insert<const Name extends TableNameOf<Definition>>(name: Name, value: InsertOf<Definition[NoInfer<Name>]>): Result<Id<Name>, never>;
248
- patch<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: PatchOf<Definition[NoInfer<Name>]>): Result<void, never>;
249
- replace<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: InsertOf<Definition[NoInfer<Name>]>): Result<void, never>;
258
+ patch<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: PatchOf<Definition[NoInfer<Name>]>): Result<void, DocumentNotFound<Name>>;
259
+ replace<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: InsertOf<Definition[NoInfer<Name>]>): Result<void, DocumentNotFound<Name>>;
250
260
  }
251
261
  interface QueryContext<Definition extends Tables> {
252
262
  readonly db: DatabaseReader<Definition>;
@@ -277,40 +287,40 @@ type FunctionDefinition<Kind extends FunctionKind, Definition extends Tables, Ar
277
287
  interface FunctionInput<Kind extends FunctionKind, Definition extends Tables, Args extends FunctionArgs, Success, Failure extends ErrorValue> {
278
288
  readonly handler: Handler<Kind, Definition, Args, Success, Failure>;
279
289
  }
280
- type WithArgs<Args extends Schema.Struct.Fields> = {
281
- readonly args: Args & ResolvedFunctionFields<NoInfer<Args>>;
290
+ type WithArgs<Kind extends FunctionKind, Args extends Schema.Struct.Fields> = {
291
+ readonly args: Args & ResolvedFunctionFields<NoInfer<Args>> & (Kind extends "Query" ? FileFree<Schema.Struct.Type<Args>, "query arguments"> : unknown);
282
292
  };
283
293
  interface WithoutArgs {
284
294
  readonly args?: never;
285
295
  }
286
- type WithReturns<Returns extends TransportSchema> = {
287
- readonly returns: Returns & ResolvedFunctionValue;
296
+ type WithReturns<Kind extends FunctionKind, Returns extends TransportSchema> = {
297
+ readonly returns: Returns & ResolvedFunctionValue & (Kind extends "Mutation" ? FileFree<Returns["Type"], "mutation returns"> : unknown);
288
298
  };
289
299
  interface WithoutReturns {
290
300
  readonly returns?: never;
291
301
  }
292
302
  interface DefineFunction<Kind extends FunctionKind, Definition extends Tables> {
293
- <const Args extends Schema.Struct.Fields, Returns extends TransportSchema, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, Args, Returns["Type"], Errors["Type"]> & WithArgs<Args> & WithReturns<Returns> & {
294
- readonly errors: Errors & ResolvedFunctionValue;
303
+ <const Args extends Schema.Struct.Fields, Returns extends TransportSchema, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, Args, Returns["Type"], Errors["Type"]> & WithArgs<Kind, Args> & WithReturns<Kind, Returns> & {
304
+ readonly errors: Errors & ResolvedFunctionValue & FileFree<Errors["Type"], "errors">;
295
305
  }): FunctionDefinition<Kind, Definition, Args, Returns, Errors, Errors["Type"]>;
296
- <Returns extends TransportSchema, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, undefined, Returns["Type"], Errors["Type"]> & WithoutArgs & WithReturns<Returns> & {
297
- readonly errors: Errors & ResolvedFunctionValue;
306
+ <Returns extends TransportSchema, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, undefined, Returns["Type"], Errors["Type"]> & WithoutArgs & WithReturns<Kind, Returns> & {
307
+ readonly errors: Errors & ResolvedFunctionValue & FileFree<Errors["Type"], "errors">;
298
308
  }): FunctionDefinition<Kind, Definition, undefined, Returns, Errors, Errors["Type"]>;
299
- <const Args extends Schema.Struct.Fields, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, Args, void, Errors["Type"]> & WithArgs<Args> & WithoutReturns & {
300
- readonly errors: Errors & ResolvedFunctionValue;
309
+ <const Args extends Schema.Struct.Fields, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, Args, void, Errors["Type"]> & WithArgs<Kind, Args> & WithoutReturns & {
310
+ readonly errors: Errors & ResolvedFunctionValue & FileFree<Errors["Type"], "errors">;
301
311
  }): FunctionDefinition<Kind, Definition, Args, undefined, Errors, Errors["Type"]>;
302
312
  <Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, undefined, void, Errors["Type"]> & WithoutArgs & WithoutReturns & {
303
- readonly errors: Errors & ResolvedFunctionValue;
313
+ readonly errors: Errors & ResolvedFunctionValue & FileFree<Errors["Type"], "errors">;
304
314
  }): FunctionDefinition<Kind, Definition, undefined, undefined, Errors, Errors["Type"]>;
305
- <const Args extends Schema.Struct.Fields, Returns extends TransportSchema, HandlerType extends Handler<Kind, Definition, Args, Returns["Type"], ErrorValue> = Handler<Kind, Definition, Args, Returns["Type"], never>>(definition: WithArgs<Args> & WithReturns<Returns> & {
315
+ <const Args extends Schema.Struct.Fields, Returns extends TransportSchema, HandlerType extends Handler<Kind, Definition, Args, Returns["Type"], ErrorValue> = Handler<Kind, Definition, Args, Returns["Type"], never>>(definition: WithArgs<Kind, Args> & WithReturns<Kind, Returns> & {
306
316
  readonly errors?: never;
307
317
  readonly handler: HandlerType;
308
318
  }): FunctionDefinition<Kind, Definition, Args, Returns, undefined, HandlerFailure<HandlerType>>;
309
- <Returns extends TransportSchema, HandlerType extends Handler<Kind, Definition, undefined, Returns["Type"], ErrorValue> = Handler<Kind, Definition, undefined, Returns["Type"], never>>(definition: WithoutArgs & WithReturns<Returns> & {
319
+ <Returns extends TransportSchema, HandlerType extends Handler<Kind, Definition, undefined, Returns["Type"], ErrorValue> = Handler<Kind, Definition, undefined, Returns["Type"], never>>(definition: WithoutArgs & WithReturns<Kind, Returns> & {
310
320
  readonly errors?: never;
311
321
  readonly handler: HandlerType;
312
322
  }): FunctionDefinition<Kind, Definition, undefined, Returns, undefined, HandlerFailure<HandlerType>>;
313
- <const Args extends Schema.Struct.Fields, HandlerType extends Handler<Kind, Definition, Args, void, ErrorValue> = Handler<Kind, Definition, Args, void, never>>(definition: WithArgs<Args> & WithoutReturns & {
323
+ <const Args extends Schema.Struct.Fields, HandlerType extends Handler<Kind, Definition, Args, void, ErrorValue> = Handler<Kind, Definition, Args, void, never>>(definition: WithArgs<Kind, Args> & WithoutReturns & {
314
324
  readonly errors?: never;
315
325
  readonly handler: HandlerType;
316
326
  }): FunctionDefinition<Kind, Definition, Args, undefined, undefined, HandlerFailure<HandlerType>>;
@@ -329,4 +339,4 @@ interface SchemaBindings<Definition extends Tables> extends FunctionBuilders<Def
329
339
  declare const bindSchema: <const Definition extends Tables>(schema: DefinedSchema<Definition>) => SchemaBindings<Definition>;
330
340
  //#endregion
331
341
  export { Document as a, SchemaDefinitionTypeId as c, defineSchema as i, SchemaAuthoring as n, Id as o, bindSchema as r, SchemaDefinitionOf as s, DefinedSchema as t };
332
- //# sourceMappingURL=index-Dl_VQGmA.d.ts.map
342
+ //# sourceMappingURL=index-CF04_Dps.d.ts.map
@@ -1,2 +1,2 @@
1
- import { i as functionPathOf, n as FunctionReference, r as createApi, t as Api } from "../api-D2bsAz4T.js";
2
- export { Api, FunctionReference, createApi, functionPathOf };
1
+ import { a as functionPathOf, i as createApi, n as FunctionReference, r as MutationInput, t as Api } from "../api-D9lV-5av.js";
2
+ export { Api, FunctionReference, MutationInput, createApi, functionPathOf };
@@ -1,2 +1,2 @@
1
- import { n as functionPathOf, t as createApi } from "../api-DtX8qPrq.js";
1
+ import { n as functionPathOf, t as createApi } from "../api-BTeMI5tx.js";
2
2
  export { createApi, functionPathOf };
@@ -1,11 +1,14 @@
1
- import { d as TransportValue, l as documentNotFound, r as ErrorValue, s as Result, u as TransportObject } from "../result-BgcHn25t.js";
1
+ import { c as Result, d as TransportObject, f as TransportValue, i as ErrorValue, u as documentNotFound } from "../id-Btwac71X-DGj0DQuu.js";
2
+ import "../sync-mIXn9eKv.js";
3
+ import { n as PaginationPage, t as PaginationOptions } from "../pagination-DrOowBve-Bnipd34u.js";
4
+ import "../pagination-BNFhAjns.js";
2
5
  import { Effect, Schema } from "effect";
3
6
  //#region ../contracts/dist/runtime/functions.d.ts
4
7
  //#region src/runtime/functions.d.ts
5
8
  declare const FunctionKind: Schema.Literals<readonly ["Mutation", "Query"]>;
6
9
  type FunctionKind = typeof FunctionKind.Type;
7
10
  //#endregion
8
- //#region ../runtime/dist/guest.d.ts
11
+ //#region ../runtime/dist/guest-DjAV4yQ0.d.ts
9
12
  //#region src/guest.d.ts
10
13
  interface GuestFunctionDefinition {
11
14
  readonly _tag: FunctionKind;
@@ -19,18 +22,32 @@ declare const GuestFunctionArgumentsTypeId: unique symbol;
19
22
  interface GuestFunctionArguments {
20
23
  readonly [GuestFunctionArgumentsTypeId]?: never;
21
24
  }
25
+ interface GuestQueryRange {
26
+ readonly eq: (field: string, value: TransportValue) => GuestQueryRange;
27
+ readonly gt: (field: string, value: TransportValue) => GuestQueryRange;
28
+ readonly gte: (field: string, value: TransportValue) => GuestQueryRange;
29
+ readonly lt: (field: string, value: TransportValue) => GuestQueryRange;
30
+ readonly lte: (field: string, value: TransportValue) => GuestQueryRange;
31
+ }
32
+ interface GuestDatabaseQuery {
33
+ readonly index: (name: string, range?: (builder: GuestQueryRange) => GuestQueryRange) => GuestDatabaseQuery;
34
+ readonly order: (direction: "asc" | "desc") => GuestDatabaseQuery;
35
+ readonly collect: () => Result<ReadonlyArray<TransportObject>, never>;
36
+ readonly take: (count: number) => Result<ReadonlyArray<TransportObject>, never>;
37
+ readonly first: () => Result<TransportObject | undefined, never>;
38
+ readonly unique: () => Result<TransportObject | undefined, never>;
39
+ readonly paginate: (options: PaginationOptions) => Result<PaginationPage<TransportObject>, never>;
40
+ }
22
41
  interface GuestDatabaseReader {
23
42
  readonly find: (table: string, id: string) => Result<TransportObject | undefined, never>;
24
43
  readonly get: (table: string, id: string) => Result<TransportObject, ReturnType<typeof documentNotFound>>;
25
- readonly query: (table: string) => {
26
- readonly collect: () => Result<ReadonlyArray<TransportObject>, never>;
27
- };
44
+ readonly query: (table: string) => GuestDatabaseQuery;
28
45
  }
29
46
  interface GuestDatabaseWriter extends GuestDatabaseReader {
30
- readonly delete: (table: string, id: string) => Result<void, never>;
47
+ readonly delete: (table: string, id: string) => Result<void, ReturnType<typeof documentNotFound>>;
31
48
  readonly insert: (table: string, value: TransportObject) => Result<string, never>;
32
- readonly patch: (table: string, id: string, value: TransportObject) => Result<void, never>;
33
- readonly replace: (table: string, id: string, value: TransportObject) => Result<void, never>;
49
+ readonly patch: (table: string, id: string, value: TransportObject) => Result<void, ReturnType<typeof documentNotFound>>;
50
+ readonly replace: (table: string, id: string, value: TransportObject) => Result<void, ReturnType<typeof documentNotFound>>;
34
51
  }
35
52
  interface GuestQueryContext {
36
53
  readonly db: GuestDatabaseReader;