ignotum 0.0.7 → 0.0.9
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.
- package/README.md +89 -101
- package/dist/cli/bin.mjs +1119 -195
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-DtX8qPrq.js → api-DzcR7spt.js} +36 -13
- package/dist/runtime/api-DzcR7spt.js.map +1 -0
- package/dist/runtime/{api-Dp4J-xt-.d.ts → api-jCl8Hzry.d.ts} +7 -9
- package/dist/runtime/client.d.ts +12 -5
- package/dist/runtime/client.js +285 -60
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-t6BOEGw9-C1rwYIlx.js → descriptor-C5VA9qRl-BKbdenuU.js} +38 -7
- package/dist/runtime/descriptor-C5VA9qRl-BKbdenuU.js.map +1 -0
- package/dist/runtime/file-C1abuMgd.js +173 -0
- package/dist/runtime/file-C1abuMgd.js.map +1 -0
- package/dist/runtime/{id-Btwac71X-DhnKYsjY.d.ts → id-Cs82tq9Q-Caqfx54f.d.ts} +51 -5
- package/dist/runtime/{index-B5KSOjGN.d.ts → index-D6VLTbDB.d.ts} +40 -21
- package/dist/runtime/internal/api.d.ts +2 -2
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +8 -7
- package/dist/runtime/internal/host.js +21 -10
- package/dist/runtime/internal/host.js.map +1 -1
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +1 -1
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/{pagination-B1BzNkh8-BUSTbeSg.d.ts → pagination-Bt3l7QaC-D_zI5zsu.d.ts} +8 -4
- package/dist/runtime/pagination-DcIkTOFs.d.ts +1 -0
- package/dist/runtime/{schema-D9RmboaS.js → schema-B6PK_ZwV.js} +17 -3
- package/dist/runtime/schema-B6PK_ZwV.js.map +1 -0
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/sync-bMQq9tXx.d.ts +8 -0
- package/package.json +7 -5
- package/src/cli/agent-files.ts +52 -13
- package/src/cli/app-configuration.ts +4 -1
- package/src/cli/auth-client.ts +286 -0
- package/src/cli/build/server.ts +83 -6
- package/src/cli/command.ts +65 -2
- package/src/cli/control-client.ts +19 -6
- package/src/cli/new-app.ts +16 -0
- package/src/client/errors.ts +7 -10
- package/src/client/files.ts +153 -0
- package/src/client/hooks.ts +2 -15
- package/src/client/index.ts +7 -0
- package/src/client/sync.ts +158 -30
- package/src/dev-runtime/database.ts +69 -57
- package/src/dev-runtime/files.ts +337 -0
- package/src/dev-runtime/functions.ts +14 -6
- package/src/dev-runtime/migrations.ts +14 -0
- package/src/dev-runtime/sync.ts +134 -22
- package/src/internal/api.ts +16 -1
- package/src/server/index.ts +8 -1
- package/dist/runtime/api-DtX8qPrq.js.map +0 -1
- package/dist/runtime/descriptor-t6BOEGw9-C1rwYIlx.js.map +0 -1
- package/dist/runtime/id-D570vudg.js +0 -26
- package/dist/runtime/id-D570vudg.js.map +0 -1
- package/dist/runtime/pagination-BKPko9Hm.d.ts +0 -1
- package/dist/runtime/schema-D9RmboaS.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
defineId("ses", "ignotum/auth/SessionId");
|
|
18
|
+
defineId("acct", "ignotum/auth/AccountId");
|
|
19
|
+
defineId("ver", "ignotum/auth/VerificationId");
|
|
20
|
+
defineId("mbr", "ignotum/auth/MemberId");
|
|
21
|
+
defineId("invt", "ignotum/auth/InvitationId");
|
|
22
|
+
defineId("dvc", "ignotum/auth/DeviceCodeId");
|
|
23
|
+
defineId("auth", "ignotum/auth/InternalId");
|
|
24
|
+
const InvocationId = defineId("inv", "ignotum/sync/InvocationId");
|
|
25
|
+
const SubscriptionId = defineId("sub", "ignotum/sync/SubscriptionId");
|
|
26
|
+
defineId("conn", "ignotum/gateway/ConnectionId");
|
|
27
|
+
const RuntimeRequestNonce = defineId("nonce", "ignotum/runtime/RequestNonce");
|
|
28
|
+
const RequestId = defineId("req", "ignotum/runtime/RequestId");
|
|
29
|
+
defineId("lock", "ignotum/dev/DatabaseLockId");
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../contracts/dist/schema/file.js
|
|
32
|
+
const fileFormats = [
|
|
33
|
+
"jpeg",
|
|
34
|
+
"png",
|
|
35
|
+
"webp",
|
|
36
|
+
"avif",
|
|
37
|
+
"gif"
|
|
38
|
+
];
|
|
39
|
+
const FileFormat = Schema.Literals(fileFormats);
|
|
40
|
+
const fileMimeTypes = {
|
|
41
|
+
avif: "image/avif",
|
|
42
|
+
gif: "image/gif",
|
|
43
|
+
jpeg: "image/jpeg",
|
|
44
|
+
png: "image/png",
|
|
45
|
+
webp: "image/webp"
|
|
46
|
+
};
|
|
47
|
+
const fileLimits = {
|
|
48
|
+
activeGrantsPerConnection: 1024,
|
|
49
|
+
distinctFilesPerQuerySnapshot: 256,
|
|
50
|
+
fileBytes: 10485760,
|
|
51
|
+
filesPerMutation: 8,
|
|
52
|
+
filenameBytes: 255,
|
|
53
|
+
mutationBytes: 26214400,
|
|
54
|
+
preparationLifetimeMillis: 9e5,
|
|
55
|
+
stagedBytesPerApp: 104857600
|
|
56
|
+
};
|
|
57
|
+
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" });
|
|
58
|
+
defineId("upload", "ignotum/file/FileUploadToken");
|
|
59
|
+
defineId("grant", "ignotum/file/FileGrantToken");
|
|
60
|
+
const FileValueTypeId = Symbol.for("ignotum/file/FileValue");
|
|
61
|
+
const FileGrantTypeId = Symbol.for("ignotum/file/FileGrant");
|
|
62
|
+
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];
|
|
63
|
+
const buildFileValue = (id, metadata, grantUrl) => {
|
|
64
|
+
const value = {
|
|
65
|
+
format: metadata.format,
|
|
66
|
+
mimeType: fileMimeTypes[metadata.format],
|
|
67
|
+
name: metadata.name,
|
|
68
|
+
size: metadata.size
|
|
69
|
+
};
|
|
70
|
+
Object.defineProperty(value, FileValueTypeId, {
|
|
71
|
+
configurable: false,
|
|
72
|
+
enumerable: false,
|
|
73
|
+
value: Object.freeze({ id }),
|
|
74
|
+
writable: false
|
|
75
|
+
});
|
|
76
|
+
if (grantUrl !== void 0) Object.defineProperty(value, FileGrantTypeId, {
|
|
77
|
+
configurable: false,
|
|
78
|
+
enumerable: false,
|
|
79
|
+
value: grantUrl,
|
|
80
|
+
writable: false
|
|
81
|
+
});
|
|
82
|
+
return Object.freeze(value);
|
|
83
|
+
};
|
|
84
|
+
const makeFileValue = (id, metadata) => buildFileValue(id, metadata);
|
|
85
|
+
const fileIdOf = (value) => value[FileValueTypeId].id;
|
|
86
|
+
const grantFileValue = (value, url) => {
|
|
87
|
+
return buildFileValue(fileIdOf(value), value, url);
|
|
88
|
+
};
|
|
89
|
+
const fileGrantUrlOf = (value) => value[FileGrantTypeId];
|
|
90
|
+
const EncodedFileValue = Schema.Struct({
|
|
91
|
+
$ignotum: Schema.Literal("file"),
|
|
92
|
+
id: FileId,
|
|
93
|
+
format: FileFormat,
|
|
94
|
+
name: Schema.String,
|
|
95
|
+
size: Schema.Int.check(Schema.isBetween({
|
|
96
|
+
minimum: 0,
|
|
97
|
+
maximum: fileLimits.fileBytes
|
|
98
|
+
}))
|
|
99
|
+
});
|
|
100
|
+
const RuntimeFileMetadata = Schema.Struct({
|
|
101
|
+
id: FileId,
|
|
102
|
+
format: FileFormat,
|
|
103
|
+
name: Schema.String,
|
|
104
|
+
size: Schema.Int.check(Schema.isBetween({
|
|
105
|
+
minimum: 0,
|
|
106
|
+
maximum: fileLimits.fileBytes
|
|
107
|
+
}))
|
|
108
|
+
});
|
|
109
|
+
const FilePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));
|
|
110
|
+
const RuntimeFileOccurrence = Schema.Struct({
|
|
111
|
+
path: FilePath,
|
|
112
|
+
file: RuntimeFileMetadata
|
|
113
|
+
});
|
|
114
|
+
const DecodedFileValue = Schema.declare(isFileValue, { title: "FileValue" });
|
|
115
|
+
const FileValue = EncodedFileValue.pipe(Schema.decodeTo(DecodedFileValue, {
|
|
116
|
+
decode: SchemaGetter.transform((encoded) => makeFileValue(encoded.id, {
|
|
117
|
+
format: encoded.format,
|
|
118
|
+
name: encoded.name,
|
|
119
|
+
size: encoded.size
|
|
120
|
+
})),
|
|
121
|
+
encode: SchemaGetter.transform((value) => ({
|
|
122
|
+
$ignotum: "file",
|
|
123
|
+
format: value.format,
|
|
124
|
+
id: fileIdOf(value),
|
|
125
|
+
name: value.name,
|
|
126
|
+
size: value.size
|
|
127
|
+
}))
|
|
128
|
+
}));
|
|
129
|
+
const constrainedFileValue = (formats, maxBytes) => FileValue.pipe(Schema.check(Schema.makeFilter((value) => {
|
|
130
|
+
const issues = [];
|
|
131
|
+
if (!formats.includes(value.format)) issues.push({
|
|
132
|
+
path: ["format"],
|
|
133
|
+
issue: `File format '${value.format}' is not allowed by this field.`
|
|
134
|
+
});
|
|
135
|
+
if (value.size > maxBytes) issues.push({
|
|
136
|
+
path: ["size"],
|
|
137
|
+
issue: `File size ${value.size} exceeds this field's ${maxBytes} byte limit.`
|
|
138
|
+
});
|
|
139
|
+
return issues;
|
|
140
|
+
})));
|
|
141
|
+
const collectFileOccurrences = (value, path, occurrences) => {
|
|
142
|
+
if (isFileValue(value)) {
|
|
143
|
+
occurrences.push({
|
|
144
|
+
file: value,
|
|
145
|
+
path
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (globalThis.Array.isArray(value)) {
|
|
150
|
+
for (const [index, child] of value.entries()) collectFileOccurrences(child, [...path, index], occurrences);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (!Predicate.isObject(value) || Predicate.isDate(value)) return;
|
|
154
|
+
for (const [key, child] of Object.entries(value)) collectFileOccurrences(child, [...path, key], occurrences);
|
|
155
|
+
};
|
|
156
|
+
const fileOccurrencesOf = (value) => {
|
|
157
|
+
const occurrences = [];
|
|
158
|
+
collectFileOccurrences(value, [], occurrences);
|
|
159
|
+
return occurrences;
|
|
160
|
+
};
|
|
161
|
+
const runtimeFileOccurrencesOf = (value) => fileOccurrencesOf(value).map(({ file, path }) => ({
|
|
162
|
+
path,
|
|
163
|
+
file: {
|
|
164
|
+
format: file.format,
|
|
165
|
+
id: fileIdOf(file),
|
|
166
|
+
name: file.name,
|
|
167
|
+
size: file.size
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
//#endregion
|
|
171
|
+
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 };
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=file-C1abuMgd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-C1abuMgd.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 AuthSessionId = defineId(\"ses\", \"ignotum/auth/SessionId\");\nconst AuthAccountId = defineId(\"acct\", \"ignotum/auth/AccountId\");\nconst AuthVerificationId = defineId(\"ver\", \"ignotum/auth/VerificationId\");\nconst AuthMemberId = defineId(\"mbr\", \"ignotum/auth/MemberId\");\nconst AuthInvitationId = defineId(\"invt\", \"ignotum/auth/InvitationId\");\nconst AuthDeviceCodeId = defineId(\"dvc\", \"ignotum/auth/DeviceCodeId\");\nconst AuthInternalId = defineId(\"auth\", \"ignotum/auth/InternalId\");\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, AuthAccountId, AuthDeviceCodeId, AuthInternalId, AuthInvitationId, AuthMemberId, AuthSessionId, AuthVerificationId, 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,cAAc,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,gBAAgB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,GAAG,KAAK,CAAC;AAC/H,MAAM,QAAQ,SAAS,OAAO,sBAAsB;AACpD,MAAM,eAAe,SAAS,OAAO,6BAA6B;AACnD,SAAS,QAAQ,uBAAuB;AACvD,MAAM,UAAU,SAAS,SAAS,yBAAyB;AAC/B,SAAS,OAAO,qCAAqC;AAC3D,SAAS,OAAO,wBAAwB;AACxC,SAAS,QAAQ,wBAAwB;AACpC,SAAS,OAAO,6BAA6B;AACnD,SAAS,OAAO,uBAAuB;AACnC,SAAS,QAAQ,2BAA2B;AAC5C,SAAS,OAAO,2BAA2B;AAC7C,SAAS,QAAQ,yBAAyB;AACjE,MAAM,eAAe,SAAS,OAAO,2BAA2B;AAChE,MAAM,iBAAiB,SAAS,OAAO,6BAA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ACR;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/
|
|
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,11 +163,11 @@ declare const Result: {
|
|
|
117
163
|
try: typeof tryResult;
|
|
118
164
|
};
|
|
119
165
|
//#endregion
|
|
120
|
-
//#region ../contracts/dist/id-
|
|
166
|
+
//#region ../contracts/dist/id-Cs82tq9Q.d.ts
|
|
121
167
|
declare const GeneratedId: Schema.brand<Schema.String, "ignotum/id"> & {
|
|
122
168
|
readonly idPrefix: undefined;
|
|
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-
|
|
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-Cs82tq9Q-Caqfx54f.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as Result, i as ErrorValue, n as DocumentNotFoundValue, r as ErrorBrand, t as GeneratedId } from "./id-
|
|
2
|
-
import { a as ValueDescriptorCarrier, i as ValueDescriptor, n as PaginationPage, o as ValueFields, r as DescribedValue, t as PaginationOptions } from "./pagination-
|
|
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-Cs82tq9Q-Caqfx54f.js";
|
|
2
|
+
import { a as ValueDescriptorCarrier, i as ValueDescriptor, n as PaginationPage, o as ValueFields, r as DescribedValue, t as PaginationOptions } from "./pagination-Bt3l7QaC-D_zI5zsu.js";
|
|
3
3
|
import { Brand, Effect, Schema, Struct } from "effect";
|
|
4
|
-
//#region ../contracts/dist/types-
|
|
4
|
+
//#region ../contracts/dist/types-MZtM0RHZ.d.ts
|
|
5
5
|
//#region src/schema/types.d.ts
|
|
6
6
|
/** A document identifier branded with the table it belongs to. */
|
|
7
7
|
type Id<TableName extends string> = GeneratedId & Brand.Brand<`ignotum/id/${TableName}`>;
|
|
@@ -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,
|
|
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,
|
|
240
|
-
replace<const Name extends TableNameOf<Definition>>(name: Name, id: Id<NoInfer<Name>>, value: InsertOf<Definition[NoInfer<Name>]>): Result<void,
|
|
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-
|
|
342
|
+
//# sourceMappingURL=index-D6VLTbDB.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
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-jCl8Hzry.js";
|
|
2
|
+
export { Api, FunctionReference, MutationInput, createApi, functionPathOf };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as functionPathOf, t as createApi } from "../api-
|
|
1
|
+
import { n as functionPathOf, t as createApi } from "../api-DzcR7spt.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-
|
|
2
|
-
import
|
|
3
|
-
import "../pagination-
|
|
1
|
+
import { c as Result, d as TransportObject, f as TransportValue, i as ErrorValue, u as documentNotFound } from "../id-Cs82tq9Q-Caqfx54f.js";
|
|
2
|
+
import "../sync-bMQq9tXx.js";
|
|
3
|
+
import { n as PaginationPage, t as PaginationOptions } from "../pagination-Bt3l7QaC-D_zI5zsu.js";
|
|
4
|
+
import "../pagination-DcIkTOFs.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,
|
|
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,
|
|
49
|
-
readonly replace: (table: string, id: string, value: TransportObject) => Result<void,
|
|
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 {
|
|
2
|
-
import { _ as
|
|
3
|
-
import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-
|
|
1
|
+
import { g as runtimeFileOccurrencesOf, y as GeneratedId } from "../file-C1abuMgd.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-BKbdenuU.js";
|
|
3
|
+
import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-B6PK_ZwV.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({
|
|
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 =
|
|
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
|
|
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:
|
|
361
|
+
value: encoded,
|
|
362
|
+
files
|
|
352
363
|
};
|
|
353
364
|
const dates = datePathsOf(value);
|
|
354
365
|
return dates.length === 0 ? result : {
|