ignotum 0.0.7 → 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 +869 -175
  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-Dp4J-xt-.d.ts → api-D9lV-5av.d.ts} +7 -9
  7. package/dist/runtime/client.d.ts +12 -5
  8. package/dist/runtime/client.js +275 -52
  9. package/dist/runtime/client.js.map +1 -1
  10. package/dist/runtime/{descriptor-t6BOEGw9-C1rwYIlx.js → descriptor-C5VA9qRl-C338iC6l.js} +38 -7
  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/{id-Btwac71X-DhnKYsjY.d.ts → id-Btwac71X-DGj0DQuu.d.ts} +50 -4
  15. package/dist/runtime/{index-B5KSOjGN.d.ts → index-CF04_Dps.d.ts} +39 -20
  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 +8 -7
  19. package/dist/runtime/internal/host.js +21 -10
  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-B1BzNkh8-BUSTbeSg.d.ts → pagination-DrOowBve-Bnipd34u.d.ts} +8 -4
  27. package/dist/runtime/{schema-D9RmboaS.js → schema-DJfwfq87.js} +17 -3
  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 +4 -4
  34. package/src/cli/agent-files.ts +52 -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 +2 -15
  40. package/src/client/index.ts +7 -0
  41. package/src/client/sync.ts +137 -21
  42. package/src/dev-runtime/database.ts +69 -57
  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 +14 -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-C1rwYIlx.js.map +0 -1
  51. package/dist/runtime/id-D570vudg.js +0 -26
  52. package/dist/runtime/id-D570vudg.js.map +0 -1
  53. package/dist/runtime/pagination-BKPko9Hm.d.ts +0 -1
  54. package/dist/runtime/schema-D9RmboaS.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,CAA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KAAK,MAAM,CAAC,OAAO,UAAU,MAAM,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
@@ -123,5 +169,5 @@ declare const GeneratedId: Schema.brand<Schema.String, "ignotum/id"> & {
123
169
  };
124
170
  type GeneratedId = typeof GeneratedId.Type;
125
171
  //#endregion
126
- export { InternalServerError as a, Result as c, TransportObject as d, TransportValue as f, ErrorValue as i, SettledResult as l, DocumentNotFoundValue as n, Match as o, ErrorBrand as r, QueryResult as s, GeneratedId as t, documentNotFound as u };
127
- //# sourceMappingURL=id-Btwac71X-DhnKYsjY.d.ts.map
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,5 +1,5 @@
1
- import { c as Result, i as ErrorValue, n as DocumentNotFoundValue, r as ErrorBrand, t as GeneratedId } from "./id-Btwac71X-DhnKYsjY.js";
2
- import { a as ValueDescriptorCarrier, i as ValueDescriptor, n as PaginationPage, o as ValueFields, r as DescribedValue, t as PaginationOptions } from "./pagination-B1BzNkh8-BUSTbeSg.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
4
  //#region ../contracts/dist/types-DDg3XIFc.d.ts
5
5
  //#region src/schema/types.d.ts
@@ -99,6 +99,19 @@ declare const number: () => DescribedValue<Schema.Finite>;
99
99
  declare const integer: () => DescribedValue<Schema.Int>;
100
100
  declare const boolean: () => DescribedValue<Schema.Boolean>;
101
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]>>;
102
115
  declare const never: () => DescribedValue<Schema.Never>;
103
116
  declare const nullValue: () => DescribedValue<Schema.Null>;
104
117
  declare const literal: <const Value extends LiteralValue>(value: Value) => DescribedValue<Schema.Literal<Value>>;
@@ -123,6 +136,7 @@ declare const values: {
123
136
  array: typeof array;
124
137
  boolean: typeof boolean;
125
138
  date: typeof date;
139
+ file: typeof file;
126
140
  error: typeof error;
127
141
  id: typeof id;
128
142
  integer: typeof integer;
@@ -181,6 +195,11 @@ interface ErrorSchema extends Schema.ConstraintCodec<ErrorValue, unknown, never,
181
195
  interface ResolvedFunctionValue {
182
196
  readonly [UnresolvedReferencesTypeId]?: never;
183
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;
184
203
  type ResolvedFunctionFields<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields]: Fields[FieldName] & ResolvedFunctionValue & TransportSchema; };
185
204
  interface ForbiddenSystemFields {
186
205
  readonly id?: never;
@@ -234,10 +253,10 @@ interface DatabaseReader<Definition extends Tables> {
234
253
  get<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>): Result<Document<Definition, Name>, DocumentNotFound<Name>>;
235
254
  }
236
255
  interface DatabaseWriter<Definition extends Tables> extends DatabaseReader<Definition> {
237
- 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>>;
238
257
  insert<const Name extends TableNameOf<Definition>>(name: Name, value: InsertOf<Definition[NoInfer<Name>]>): Result<Id<Name>, never>;
239
- patch<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: PatchOf<Definition[NoInfer<Name>]>): Result<void, never>;
240
- 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>>;
241
260
  }
242
261
  interface QueryContext<Definition extends Tables> {
243
262
  readonly db: DatabaseReader<Definition>;
@@ -268,40 +287,40 @@ type FunctionDefinition<Kind extends FunctionKind, Definition extends Tables, Ar
268
287
  interface FunctionInput<Kind extends FunctionKind, Definition extends Tables, Args extends FunctionArgs, Success, Failure extends ErrorValue> {
269
288
  readonly handler: Handler<Kind, Definition, Args, Success, Failure>;
270
289
  }
271
- type WithArgs<Args extends Schema.Struct.Fields> = {
272
- 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);
273
292
  };
274
293
  interface WithoutArgs {
275
294
  readonly args?: never;
276
295
  }
277
- type WithReturns<Returns extends TransportSchema> = {
278
- 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);
279
298
  };
280
299
  interface WithoutReturns {
281
300
  readonly returns?: never;
282
301
  }
283
302
  interface DefineFunction<Kind extends FunctionKind, Definition extends Tables> {
284
- <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> & {
285
- 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">;
286
305
  }): FunctionDefinition<Kind, Definition, Args, Returns, Errors, Errors["Type"]>;
287
- <Returns extends TransportSchema, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, undefined, Returns["Type"], Errors["Type"]> & WithoutArgs & WithReturns<Returns> & {
288
- 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">;
289
308
  }): FunctionDefinition<Kind, Definition, undefined, Returns, Errors, Errors["Type"]>;
290
- <const Args extends Schema.Struct.Fields, Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, Args, void, Errors["Type"]> & WithArgs<Args> & WithoutReturns & {
291
- 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">;
292
311
  }): FunctionDefinition<Kind, Definition, Args, undefined, Errors, Errors["Type"]>;
293
312
  <Errors extends ErrorSchema>(definition: FunctionInput<Kind, Definition, undefined, void, Errors["Type"]> & WithoutArgs & WithoutReturns & {
294
- readonly errors: Errors & ResolvedFunctionValue;
313
+ readonly errors: Errors & ResolvedFunctionValue & FileFree<Errors["Type"], "errors">;
295
314
  }): FunctionDefinition<Kind, Definition, undefined, undefined, Errors, Errors["Type"]>;
296
- <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> & {
297
316
  readonly errors?: never;
298
317
  readonly handler: HandlerType;
299
318
  }): FunctionDefinition<Kind, Definition, Args, Returns, undefined, HandlerFailure<HandlerType>>;
300
- <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> & {
301
320
  readonly errors?: never;
302
321
  readonly handler: HandlerType;
303
322
  }): FunctionDefinition<Kind, Definition, undefined, Returns, undefined, HandlerFailure<HandlerType>>;
304
- <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 & {
305
324
  readonly errors?: never;
306
325
  readonly handler: HandlerType;
307
326
  }): FunctionDefinition<Kind, Definition, Args, undefined, undefined, HandlerFailure<HandlerType>>;
@@ -320,4 +339,4 @@ interface SchemaBindings<Definition extends Tables> extends FunctionBuilders<Def
320
339
  declare const bindSchema: <const Definition extends Tables>(schema: DefinedSchema<Definition>) => SchemaBindings<Definition>;
321
340
  //#endregion
322
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 };
323
- //# sourceMappingURL=index-B5KSOjGN.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-Dp4J-xt-.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,13 +1,14 @@
1
- import { c as Result, d as TransportObject, f as TransportValue, i as ErrorValue, u as documentNotFound } from "../id-Btwac71X-DhnKYsjY.js";
2
- import { n as PaginationPage, t as PaginationOptions } from "../pagination-B1BzNkh8-BUSTbeSg.js";
3
- import "../pagination-BKPko9Hm.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";
4
5
  import { Effect, Schema } from "effect";
5
6
  //#region ../contracts/dist/runtime/functions.d.ts
6
7
  //#region src/runtime/functions.d.ts
7
8
  declare const FunctionKind: Schema.Literals<readonly ["Mutation", "Query"]>;
8
9
  type FunctionKind = typeof FunctionKind.Type;
9
10
  //#endregion
10
- //#region ../runtime/dist/guest.d.ts
11
+ //#region ../runtime/dist/guest-DjAV4yQ0.d.ts
11
12
  //#region src/guest.d.ts
12
13
  interface GuestFunctionDefinition {
13
14
  readonly _tag: FunctionKind;
@@ -43,10 +44,10 @@ interface GuestDatabaseReader {
43
44
  readonly query: (table: string) => GuestDatabaseQuery;
44
45
  }
45
46
  interface GuestDatabaseWriter extends GuestDatabaseReader {
46
- readonly delete: (table: string, id: string) => Result<void, never>;
47
+ readonly delete: (table: string, id: string) => Result<void, ReturnType<typeof documentNotFound>>;
47
48
  readonly insert: (table: string, value: TransportObject) => Result<string, never>;
48
- readonly patch: (table: string, id: string, value: TransportObject) => Result<void, never>;
49
- 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>>;
50
51
  }
51
52
  interface GuestQueryContext {
52
53
  readonly db: GuestDatabaseReader;
@@ -1,6 +1,6 @@
1
- import { r as GeneratedId } from "../id-D570vudg.js";
2
- import { _ as datePathsOfObject, a as PaginationCursor, c as ErrorValueSchema, g as datePathsOf, h as TransportValueSchema, m as resultFromEffect, o as PaginationPageSize, u as documentNotFound } from "../descriptor-t6BOEGw9-C1rwYIlx.js";
3
- import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-D9RmboaS.js";
1
+ import { g as runtimeFileOccurrencesOf, y as GeneratedId } from "../file-BXf63ulU.js";
2
+ import { _ as TransportValueSchema, a as PaginationCursor, f as documentNotFound, g as resultFromEffect, o as PaginationPageSize, u as ErrorValueSchema, v as datePathsOf, y as datePathsOfObject } from "../descriptor-C5VA9qRl-C338iC6l.js";
3
+ import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-DJfwfq87.js";
4
4
  import { Effect, Predicate, Schema } from "effect";
5
5
  //#region ../contracts/dist/runtime/host.js
6
6
  const HostDocument = Schema.Struct({
@@ -101,7 +101,10 @@ const HostInserted = Schema.Struct({
101
101
  type: Schema.Literal("Inserted"),
102
102
  id: GeneratedId
103
103
  });
104
- const HostCompleted = Schema.Struct({ type: Schema.Literal("Completed") });
104
+ const HostCompleted = Schema.Struct({
105
+ type: Schema.Literal("Completed"),
106
+ found: Schema.Boolean
107
+ });
105
108
  Schema.Union([
106
109
  HostDocuments,
107
110
  HostPage,
@@ -313,10 +316,12 @@ const makeReader = (schema, call) => {
313
316
  };
314
317
  const makeWriter = (schema, call) => {
315
318
  const reader = makeReader(schema, call);
316
- const complete = (request) => callHost(call, request).pipe(Effect.map((response) => expectResponse(response, "Completed")), Effect.asVoid);
319
+ const complete = Effect.fn("Guest.completeWrite")(function* (table, id, request) {
320
+ if (expectResponse(yield* callHost(call, request), "Completed").found === false) return yield* Effect.fail(documentNotFound(table, id));
321
+ });
317
322
  const writer = {
318
323
  ...reader,
319
- delete: (table, id) => resultFromEffect(complete({
324
+ delete: (table, id) => resultFromEffect(complete(table, id, {
320
325
  type: "Delete",
321
326
  table,
322
327
  id: GeneratedId.make(id)
@@ -326,13 +331,13 @@ const makeWriter = (schema, call) => {
326
331
  table,
327
332
  fields: encodeFields(schema, table, value)
328
333
  }).pipe(Effect.map((response) => expectResponse(response, "Inserted").id))),
329
- patch: (table, id, value) => resultFromEffect(complete({
334
+ patch: (table, id, value) => resultFromEffect(complete(table, id, {
330
335
  type: "Patch",
331
336
  table,
332
337
  id: GeneratedId.make(id),
333
338
  fields: encodePatchFields(schema, table, value)
334
339
  })),
335
- replace: (table, id, value) => resultFromEffect(complete({
340
+ replace: (table, id, value) => resultFromEffect(complete(table, id, {
336
341
  type: "Replace",
337
342
  table,
338
343
  id: GeneratedId.make(id),
@@ -346,9 +351,15 @@ const encodeSuccess = Effect.fn("Guest.encodeSuccess")(function* (definition, va
346
351
  yield* Schema.encodeUnknownEffect(Schema.Undefined)(value);
347
352
  return { type: "Success" };
348
353
  }
349
- const result = {
354
+ const encoded = yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value);
355
+ const files = runtimeFileOccurrencesOf(value);
356
+ const result = files.length === 0 ? {
357
+ type: "Success",
358
+ value: encoded
359
+ } : {
350
360
  type: "Success",
351
- value: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value)
361
+ value: encoded,
362
+ files
352
363
  };
353
364
  const dates = datePathsOf(value);
354
365
  return dates.length === 0 ? result : {