ignotum 0.0.8 → 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 +6 -2
- package/dist/cli/bin.mjs +294 -64
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-BTeMI5tx.js → api-DzcR7spt.js} +22 -23
- package/dist/runtime/api-DzcR7spt.js.map +1 -0
- package/dist/runtime/{api-D9lV-5av.d.ts → api-jCl8Hzry.d.ts} +3 -3
- package/dist/runtime/client.d.ts +5 -5
- package/dist/runtime/client.js +57 -55
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-C5VA9qRl-C338iC6l.js → descriptor-C5VA9qRl-BKbdenuU.js} +2 -2
- package/dist/runtime/{descriptor-C5VA9qRl-C338iC6l.js.map → descriptor-C5VA9qRl-BKbdenuU.js.map} +1 -1
- package/dist/runtime/{file-BXf63ulU.js → file-C1abuMgd.js} +8 -1
- package/dist/runtime/file-C1abuMgd.js.map +1 -0
- package/dist/runtime/{id-Btwac71X-DGj0DQuu.d.ts → id-Cs82tq9Q-Caqfx54f.d.ts} +2 -2
- package/dist/runtime/{index-CF04_Dps.d.ts → index-D6VLTbDB.d.ts} +4 -4
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +4 -4
- package/dist/runtime/internal/host.js +3 -3
- 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-DrOowBve-Bnipd34u.d.ts → pagination-Bt3l7QaC-D_zI5zsu.d.ts} +3 -3
- package/dist/runtime/pagination-DcIkTOFs.d.ts +1 -0
- package/dist/runtime/{schema-DJfwfq87.js → schema-B6PK_ZwV.js} +3 -3
- package/dist/runtime/{schema-DJfwfq87.js.map → schema-B6PK_ZwV.js.map} +1 -1
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/{sync-mIXn9eKv.d.ts → sync-bMQq9tXx.d.ts} +2 -2
- package/package.json +4 -2
- package/src/cli/auth-client.ts +286 -0
- package/src/cli/command.ts +65 -2
- package/src/cli/control-client.ts +19 -6
- package/src/cli/new-app.ts +2 -1
- package/src/client/errors.ts +7 -10
- package/src/client/files.ts +36 -51
- package/src/client/sync.ts +35 -23
- package/src/dev-runtime/files.ts +30 -31
- package/src/dev-runtime/sync.ts +19 -25
- package/dist/runtime/api-BTeMI5tx.js.map +0 -1
- package/dist/runtime/file-BXf63ulU.js.map +0 -1
- package/dist/runtime/pagination-BNFhAjns.d.ts +0 -1
package/src/client/sync.ts
CHANGED
|
@@ -26,7 +26,7 @@ import type {
|
|
|
26
26
|
import { failureFromWire, pending, Result } from "@ignotum/contracts/runtime/result";
|
|
27
27
|
import {
|
|
28
28
|
ClientMessageJson,
|
|
29
|
-
|
|
29
|
+
DeploymentCloseCode,
|
|
30
30
|
InvocationId,
|
|
31
31
|
ServerMessageJson,
|
|
32
32
|
SubscriptionId,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
ConnectionUnavailable,
|
|
43
43
|
InvalidClientMessage,
|
|
44
44
|
InvalidServerMessage,
|
|
45
|
-
|
|
45
|
+
ServerError,
|
|
46
46
|
InvalidMutationArguments,
|
|
47
47
|
clientErrorReporterLayer,
|
|
48
48
|
reportClientError,
|
|
@@ -213,8 +213,7 @@ const resultFromWire = Effect.fn("SyncClient.resultFromWire")(
|
|
|
213
213
|
),
|
|
214
214
|
);
|
|
215
215
|
|
|
216
|
-
export const shouldReloadForCloseCode = (code: number): boolean =>
|
|
217
|
-
code === DeploymentChangedCloseCode;
|
|
216
|
+
export const shouldReloadForCloseCode = (code: number): boolean => code === DeploymentCloseCode;
|
|
218
217
|
|
|
219
218
|
const handshakesMatch = (first: SyncHandshake, next: SyncHandshake): boolean =>
|
|
220
219
|
first.appId === next.appId &&
|
|
@@ -265,9 +264,9 @@ interface PendingInvocation {
|
|
|
265
264
|
ClientInfrastructureError
|
|
266
265
|
>;
|
|
267
266
|
readonly function: FunctionAddress;
|
|
268
|
-
readonly message: Extract<ClientMessage, { readonly type: "Invoke" | "
|
|
267
|
+
readonly message: Extract<ClientMessage, { readonly type: "Invoke" | "Prepare" }>;
|
|
269
268
|
readonly prepared: Deferred.Deferred<
|
|
270
|
-
Extract<ServerMessage, { readonly type: "
|
|
269
|
+
Extract<ServerMessage, { readonly type: "Preparation" }>["uploads"],
|
|
271
270
|
ClientInfrastructureError
|
|
272
271
|
>;
|
|
273
272
|
}
|
|
@@ -339,7 +338,7 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
339
338
|
};
|
|
340
339
|
|
|
341
340
|
const handleMessage = Effect.fn("SyncClient.handleMessage")(function* (
|
|
342
|
-
message: Exclude<ServerMessage, SyncHandshake | { readonly type: "
|
|
341
|
+
message: Exclude<ServerMessage, SyncHandshake | { readonly type: "Deployment" }>,
|
|
343
342
|
) {
|
|
344
343
|
switch (message.type) {
|
|
345
344
|
case "Snapshot": {
|
|
@@ -352,7 +351,7 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
352
351
|
);
|
|
353
352
|
return;
|
|
354
353
|
}
|
|
355
|
-
case "
|
|
354
|
+
case "Preparation": {
|
|
356
355
|
const pendingInvocation = HashMap.getUnsafe(invocations, message.id);
|
|
357
356
|
if (pendingInvocation !== undefined) {
|
|
358
357
|
yield* Deferred.succeed(pendingInvocation.prepared, message.uploads);
|
|
@@ -368,14 +367,14 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
368
367
|
);
|
|
369
368
|
return;
|
|
370
369
|
}
|
|
371
|
-
case "
|
|
370
|
+
case "Error": {
|
|
372
371
|
const error =
|
|
373
372
|
message.operation === undefined
|
|
374
|
-
?
|
|
373
|
+
? ServerError.make({
|
|
375
374
|
code: message.code,
|
|
376
375
|
message: message.message,
|
|
377
376
|
})
|
|
378
|
-
:
|
|
377
|
+
: ServerError.make({
|
|
379
378
|
code: message.code,
|
|
380
379
|
message: message.message,
|
|
381
380
|
operation: message.operation,
|
|
@@ -449,7 +448,7 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
449
448
|
),
|
|
450
449
|
);
|
|
451
450
|
if (message.type === "Handshake") return yield* acceptHandshake(message);
|
|
452
|
-
if (message.type === "
|
|
451
|
+
if (message.type === "Deployment") {
|
|
453
452
|
requestReload();
|
|
454
453
|
return;
|
|
455
454
|
}
|
|
@@ -534,7 +533,7 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
534
533
|
ClientInfrastructureError
|
|
535
534
|
>();
|
|
536
535
|
const prepared = yield* Deferred.make<
|
|
537
|
-
Extract<ServerMessage, { readonly type: "
|
|
536
|
+
Extract<ServerMessage, { readonly type: "Preparation" }>["uploads"],
|
|
538
537
|
ClientInfrastructureError
|
|
539
538
|
>();
|
|
540
539
|
const invokeMessage: Extract<ClientMessage, { readonly type: "Invoke" }> = {
|
|
@@ -545,15 +544,15 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
545
544
|
args: jsonArgs,
|
|
546
545
|
};
|
|
547
546
|
const message: PendingInvocation["message"] =
|
|
548
|
-
preparedArguments.
|
|
547
|
+
preparedArguments.fileIds.length === 0
|
|
549
548
|
? invokeMessage
|
|
550
549
|
: {
|
|
551
|
-
type: "
|
|
550
|
+
type: "Prepare",
|
|
552
551
|
id: invocationId,
|
|
553
552
|
kind: "Mutation",
|
|
554
553
|
function: functionAddress,
|
|
555
554
|
args: jsonArgs,
|
|
556
|
-
files: preparedArguments.
|
|
555
|
+
files: preparedArguments.fileIds,
|
|
557
556
|
};
|
|
558
557
|
invocations = HashMap.set(invocations, invocationId, {
|
|
559
558
|
deferred,
|
|
@@ -570,20 +569,27 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
570
569
|
}),
|
|
571
570
|
);
|
|
572
571
|
}
|
|
573
|
-
if (message.type === "
|
|
572
|
+
if (message.type === "Prepare") {
|
|
574
573
|
const uploads = yield* Deferred.await(prepared);
|
|
575
|
-
const
|
|
574
|
+
const expected = new Set(message.files);
|
|
575
|
+
const received = new Set<string>();
|
|
576
576
|
for (const upload of uploads) {
|
|
577
|
-
if (upload.
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
577
|
+
if (!expected.has(upload.id) || received.has(upload.id)) {
|
|
578
|
+
return yield* InvalidServerMessage.make({
|
|
579
|
+
cause: new Error(`Unexpected prepared file '${upload.id}'.`),
|
|
580
|
+
message: "The server returned invalid application file preparation data.",
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
received.add(upload.id);
|
|
584
|
+
const file = preparedArguments.nativeFiles.get(upload.id);
|
|
581
585
|
if (file === undefined) {
|
|
582
586
|
return yield* InvalidServerMessage.make({
|
|
583
|
-
cause: new Error(`Missing native file '${upload.
|
|
587
|
+
cause: new Error(`Missing native file '${upload.id}'.`),
|
|
584
588
|
message: "The server prepared an unknown application file.",
|
|
585
589
|
});
|
|
586
590
|
}
|
|
591
|
+
if (upload.url === undefined) continue;
|
|
592
|
+
const uploadUrl = upload.url;
|
|
587
593
|
const response = yield* Effect.tryPromise({
|
|
588
594
|
try: () =>
|
|
589
595
|
fetch(uploadUrl, {
|
|
@@ -606,6 +612,12 @@ export class SyncClient extends Context.Service<SyncClient, SyncClientService>()
|
|
|
606
612
|
});
|
|
607
613
|
}
|
|
608
614
|
}
|
|
615
|
+
if (received.size !== expected.size) {
|
|
616
|
+
return yield* InvalidServerMessage.make({
|
|
617
|
+
cause: new Error("The server omitted a prepared file."),
|
|
618
|
+
message: "The server returned incomplete application file preparation data.",
|
|
619
|
+
});
|
|
620
|
+
}
|
|
609
621
|
const pendingInvocation = HashMap.getUnsafe(invocations, invocationId);
|
|
610
622
|
if (pendingInvocation === undefined) return yield* Deferred.await(deferred);
|
|
611
623
|
invocations = HashMap.set(invocations, invocationId, {
|
package/src/dev-runtime/files.ts
CHANGED
|
@@ -45,8 +45,8 @@ interface LocalApplicationFilesService {
|
|
|
45
45
|
invocationId: InvocationId,
|
|
46
46
|
functionAddress: FunctionAddress,
|
|
47
47
|
args: Schema.Json,
|
|
48
|
-
|
|
49
|
-
) => Effect.Effect<ReadonlyArray<
|
|
48
|
+
fileIds: ReadonlyArray<FileId>,
|
|
49
|
+
) => Effect.Effect<ReadonlyArray<{ readonly id: FileId; readonly url?: string }>>;
|
|
50
50
|
readonly admit: (
|
|
51
51
|
invocationId: InvocationId,
|
|
52
52
|
functionAddress: FunctionAddress,
|
|
@@ -56,7 +56,7 @@ interface LocalApplicationFilesService {
|
|
|
56
56
|
readonly grants: (
|
|
57
57
|
subscriptionId: SubscriptionId,
|
|
58
58
|
files: ReadonlyArray<RuntimeFileOccurrenceValue>,
|
|
59
|
-
) => Effect.Effect<ReadonlyArray<
|
|
59
|
+
) => Effect.Effect<ReadonlyArray<{ readonly id: FileId; readonly url: string }>>;
|
|
60
60
|
readonly releaseGrants: (subscriptionId: SubscriptionId) => Effect.Effect<void>;
|
|
61
61
|
readonly readGrant: (
|
|
62
62
|
token: FileGrantToken,
|
|
@@ -74,8 +74,11 @@ export const LocalApplicationFiles = Context.Reference<LocalApplicationFilesServ
|
|
|
74
74
|
admit: (_invocationId, _functionAddress, args) =>
|
|
75
75
|
Effect.succeed(encodedFileOccurrencesOf(args)),
|
|
76
76
|
grants: (_subscriptionId, files) =>
|
|
77
|
-
Effect.succeed(
|
|
78
|
-
|
|
77
|
+
Effect.succeed(
|
|
78
|
+
Array.from(new Set(files.map(({ file }) => file.id)), (id) => ({ id, url: "" })),
|
|
79
|
+
),
|
|
80
|
+
prepare: (_invocationId, _functionAddress, _args, fileIds) =>
|
|
81
|
+
Effect.succeed(fileIds.map((id) => ({ id }))),
|
|
79
82
|
upload: () => Effect.die("Local application file storage is unavailable."),
|
|
80
83
|
releaseGrants: () => Effect.void,
|
|
81
84
|
readGrant: () => Effect.succeed(Option.none()),
|
|
@@ -125,8 +128,19 @@ export const localApplicationFilesLayer = (appDirectory: string) =>
|
|
|
125
128
|
invocationId: InvocationId,
|
|
126
129
|
functionAddress: FunctionAddress,
|
|
127
130
|
args: Schema.Json,
|
|
128
|
-
|
|
131
|
+
fileIds: ReadonlyArray<FileId>,
|
|
129
132
|
) {
|
|
133
|
+
if (fileIds.length === 0) throw new Error("A file preparation must contain a file ID.");
|
|
134
|
+
const selected = new Set(fileIds);
|
|
135
|
+
if (selected.size !== fileIds.length) {
|
|
136
|
+
throw new Error("A file preparation contains a duplicate file ID.");
|
|
137
|
+
}
|
|
138
|
+
const files = encodedFileOccurrencesOf(args).filter((occurrence) =>
|
|
139
|
+
selected.has(occurrence.file.id),
|
|
140
|
+
);
|
|
141
|
+
if (new Set(files.map((occurrence) => occurrence.file.id)).size !== selected.size) {
|
|
142
|
+
throw new Error("Prepared files do not match the mutation arguments.");
|
|
143
|
+
}
|
|
130
144
|
const existing = preparations.get(invocationId);
|
|
131
145
|
if (existing !== undefined) {
|
|
132
146
|
if (
|
|
@@ -136,27 +150,14 @@ export const localApplicationFilesLayer = (appDirectory: string) =>
|
|
|
136
150
|
) {
|
|
137
151
|
throw new Error("The invocation ID already belongs to another file preparation.");
|
|
138
152
|
}
|
|
139
|
-
return
|
|
140
|
-
const token = existing.uploads.get(
|
|
141
|
-
return token === undefined
|
|
142
|
-
? occurrence
|
|
143
|
-
: { ...occurrence, url: `${fileUploadUrlPrefix}${token}` };
|
|
153
|
+
return fileIds.map((id) => {
|
|
154
|
+
const token = existing.uploads.get(id);
|
|
155
|
+
return token === undefined ? { id } : { id, url: `${fileUploadUrlPrefix}${token}` };
|
|
144
156
|
});
|
|
145
157
|
}
|
|
146
|
-
const all = new Map(
|
|
147
|
-
encodedFileOccurrencesOf(args).map((occurrence) => [
|
|
148
|
-
encodeCanonicalJson(occurrence.path),
|
|
149
|
-
occurrence.file,
|
|
150
|
-
]),
|
|
151
|
-
);
|
|
152
158
|
const distinct = new Map<FileId, RuntimeFileMetadata>();
|
|
153
159
|
for (const occurrence of files) {
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
arg === undefined ||
|
|
157
|
-
!sameFile(arg, occurrence.file) ||
|
|
158
|
-
!validFilename(occurrence.file.name)
|
|
159
|
-
) {
|
|
160
|
+
if (!validFilename(occurrence.file.name)) {
|
|
160
161
|
throw new Error("Prepared files do not match the mutation arguments.");
|
|
161
162
|
}
|
|
162
163
|
const prior = distinct.get(occurrence.file.id);
|
|
@@ -214,11 +215,9 @@ export const localApplicationFilesLayer = (appDirectory: string) =>
|
|
|
214
215
|
`;
|
|
215
216
|
}
|
|
216
217
|
preparations.set(invocationId, { function: functionAddress, args, files, uploads });
|
|
217
|
-
return
|
|
218
|
-
const token = uploads.get(
|
|
219
|
-
return token === undefined
|
|
220
|
-
? occurrence
|
|
221
|
-
: { ...occurrence, url: `${fileUploadUrlPrefix}${token}` };
|
|
218
|
+
return fileIds.map((id) => {
|
|
219
|
+
const token = uploads.get(id);
|
|
220
|
+
return token === undefined ? { id } : { id, url: `${fileUploadUrlPrefix}${token}` };
|
|
222
221
|
});
|
|
223
222
|
});
|
|
224
223
|
|
|
@@ -279,9 +278,9 @@ export const localApplicationFilesLayer = (appDirectory: string) =>
|
|
|
279
278
|
tokens.set(occurrence.file.id, token);
|
|
280
279
|
grants.set(token, { subscriptionId, file: occurrence.file });
|
|
281
280
|
}
|
|
282
|
-
return
|
|
283
|
-
|
|
284
|
-
url: `${fileGrantUrlPrefix}${
|
|
281
|
+
return Array.from(tokens, ([id, token]) => ({
|
|
282
|
+
id,
|
|
283
|
+
url: `${fileGrantUrlPrefix}${token}`,
|
|
285
284
|
}));
|
|
286
285
|
});
|
|
287
286
|
|
package/src/dev-runtime/sync.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type ClientMessage,
|
|
20
20
|
type FunctionAddress,
|
|
21
21
|
type Operation,
|
|
22
|
-
type
|
|
22
|
+
type ErrorCode,
|
|
23
23
|
type ServerMessage,
|
|
24
24
|
type SubscriptionId,
|
|
25
25
|
} from "@ignotum/contracts/runtime/sync";
|
|
@@ -181,15 +181,11 @@ const operationForSubscription = (subscriptionId: SubscriptionId): Operation =>
|
|
|
181
181
|
id: subscriptionId,
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
const
|
|
185
|
-
code: ProtocolErrorCode,
|
|
186
|
-
message: string,
|
|
187
|
-
operation?: Operation,
|
|
188
|
-
): ServerMessage => {
|
|
184
|
+
const syncError = (code: ErrorCode, message: string, operation?: Operation): ServerMessage => {
|
|
189
185
|
if (operation === undefined) {
|
|
190
|
-
return { type: "
|
|
186
|
+
return { type: "Error", code, message };
|
|
191
187
|
}
|
|
192
|
-
return { type: "
|
|
188
|
+
return { type: "Error", code, message, operation };
|
|
193
189
|
};
|
|
194
190
|
|
|
195
191
|
export const runSession = Effect.fn("SyncServer.runSession")(function* (socket: Socket.Socket) {
|
|
@@ -221,8 +217,8 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
221
217
|
message: ServerMessage,
|
|
222
218
|
) => Effect.Effect<void, Schema.SchemaError | Socket.SocketError> = send,
|
|
223
219
|
) => {
|
|
224
|
-
const code:
|
|
225
|
-
return deliver(
|
|
220
|
+
const code: ErrorCode = error._tag;
|
|
221
|
+
return deliver(syncError(code, error.message, operation));
|
|
226
222
|
};
|
|
227
223
|
|
|
228
224
|
const isActive = (subscriptionId: SubscriptionId, subscription: QuerySubscription) =>
|
|
@@ -340,7 +336,7 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
340
336
|
const operation = operationForSubscription(message.id);
|
|
341
337
|
if (encodedFileOccurrencesOf(message.args).length > 0) {
|
|
342
338
|
yield* send(
|
|
343
|
-
|
|
339
|
+
syncError("InvalidArguments", "Queries cannot take files as arguments.", operation),
|
|
344
340
|
);
|
|
345
341
|
return;
|
|
346
342
|
}
|
|
@@ -348,11 +344,7 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
348
344
|
|
|
349
345
|
if (HashMap.has(current, message.id)) {
|
|
350
346
|
yield* send(
|
|
351
|
-
|
|
352
|
-
"DuplicateOperationId",
|
|
353
|
-
`Subscription ${message.id} already exists.`,
|
|
354
|
-
operation,
|
|
355
|
-
),
|
|
347
|
+
syncError("DuplicateOperationId", `Subscription ${message.id} already exists.`, operation),
|
|
356
348
|
);
|
|
357
349
|
return;
|
|
358
350
|
}
|
|
@@ -388,7 +380,7 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
388
380
|
Effect.as(true),
|
|
389
381
|
Effect.catchCause((cause) =>
|
|
390
382
|
send(
|
|
391
|
-
|
|
383
|
+
syncError(
|
|
392
384
|
"InvalidArguments",
|
|
393
385
|
`The mutation files could not be admitted: ${String(cause)}`,
|
|
394
386
|
operation,
|
|
@@ -454,7 +446,7 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
454
446
|
Effect.catchTags({
|
|
455
447
|
InvocationIdConflict: () =>
|
|
456
448
|
send(
|
|
457
|
-
|
|
449
|
+
syncError(
|
|
458
450
|
"InvocationIdConflict",
|
|
459
451
|
`Invocation ${message.id} was already used with different inputs.`,
|
|
460
452
|
operation,
|
|
@@ -472,15 +464,17 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
472
464
|
);
|
|
473
465
|
});
|
|
474
466
|
|
|
475
|
-
const
|
|
476
|
-
message: Extract<ClientMessage, { readonly type: "
|
|
467
|
+
const handlePrepare = Effect.fn("SyncServer.handlePrepare")(function* (
|
|
468
|
+
message: Extract<ClientMessage, { readonly type: "Prepare" }>,
|
|
477
469
|
) {
|
|
478
470
|
const operation: Operation = { type: "Invocation", id: message.id };
|
|
479
471
|
yield* files.prepare(message.id, message.function, message.args, message.files).pipe(
|
|
480
|
-
Effect.flatMap((uploads) =>
|
|
472
|
+
Effect.flatMap((uploads) =>
|
|
473
|
+
send({ type: "Preparation", id: message.id, kind: message.kind, uploads }),
|
|
474
|
+
),
|
|
481
475
|
Effect.catchCause((cause) =>
|
|
482
476
|
send(
|
|
483
|
-
|
|
477
|
+
syncError(
|
|
484
478
|
"InvalidArguments",
|
|
485
479
|
`The mutation files could not be prepared: ${String(cause)}`,
|
|
486
480
|
operation,
|
|
@@ -493,7 +487,7 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
493
487
|
const handleMessage = Effect.fn("SyncServer.handleMessage")(function* (text: string) {
|
|
494
488
|
const message = yield* Schema.decodeEffect(ClientMessageJson)(text).pipe(
|
|
495
489
|
Effect.catch(() =>
|
|
496
|
-
send(
|
|
490
|
+
send(syncError("InvalidMessage", "The WebSocket frame is not valid Ignotum JSON.")),
|
|
497
491
|
),
|
|
498
492
|
);
|
|
499
493
|
|
|
@@ -510,8 +504,8 @@ export const runSession = Effect.fn("SyncServer.runSession")(function* (socket:
|
|
|
510
504
|
yield* Ref.update(subscriptions, HashMap.remove(message.id));
|
|
511
505
|
yield* files.releaseGrants(message.id);
|
|
512
506
|
return;
|
|
513
|
-
case "
|
|
514
|
-
yield*
|
|
507
|
+
case "Prepare":
|
|
508
|
+
yield* handlePrepare(message);
|
|
515
509
|
return;
|
|
516
510
|
case "Invoke":
|
|
517
511
|
yield* handleInvoke(message);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-BTeMI5tx.js","names":[],"sources":["../../../contracts/dist/runtime/identity.js","../../../contracts/dist/runtime/sync.js","../../src/internal/api.ts"],"sourcesContent":["import { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId } from \"./id.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/identity.ts\nconst InvocationKey = Schema.String.pipe(Schema.brand(\"ignotum/hosted/InvocationKey\"));\nconst DeploymentGeneration = Schema.Natural.pipe(Schema.brand(\"ignotum/hosted/DeploymentGeneration\"));\nconst AppStateRevision = Schema.Natural.pipe(Schema.brand(\"ignotum/hosted/AppStateRevision\"));\n//#endregion\nexport { AppId, AppStateRevision, ConnectionId, DeploymentGeneration, DeploymentId, DevDatabaseLockId, InvocationId, InvocationKey, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId };\n\n//# sourceMappingURL=identity.js.map","import { AppId, DeploymentId, InvocationId, SubscriptionId } from \"./id.js\";\nimport { AppStateRevision, DeploymentGeneration } from \"./identity.js\";\nimport { RuntimeFileMetadata, RuntimeFileOccurrence } from \"../schema/file.js\";\nimport { TransportValueSchema, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue } from \"./value.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/sync.ts\nconst FunctionNamePart = Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/));\nconst ApiFunctionAddressParts = Schema.TemplateLiteralParser([\n\t\"api.\",\n\tFunctionNamePart,\n\t\".\",\n\tFunctionNamePart\n]);\nconst FunctionAddress = Schema.TemplateLiteral([\n\t\"api.\",\n\tFunctionNamePart,\n\t\".\",\n\tFunctionNamePart\n]);\nconst apiFunctionParts = (address) => {\n\tconst [, moduleName, , functionName] = Schema.decodeSync(ApiFunctionAddressParts)(address);\n\treturn {\n\t\tfunctionName,\n\t\tmoduleName\n\t};\n};\nconst Subscribe = Schema.Struct({\n\ttype: Schema.Literal(\"Subscribe\"),\n\tid: SubscriptionId,\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n});\nconst Unsubscribe = Schema.Struct({\n\ttype: Schema.Literal(\"Unsubscribe\"),\n\tid: SubscriptionId\n});\nconst Invoke = Schema.Struct({\n\ttype: Schema.Literal(\"Invoke\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n});\nconst PrepareMutation = Schema.Struct({\n\ttype: Schema.Literal(\"PrepareMutation\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tfunction: FunctionAddress,\n\targs: Schema.Json,\n\tfiles: Schema.Array(RuntimeFileOccurrence)\n});\nconst ClientMessage = Schema.Union([\n\tSubscribe,\n\tUnsubscribe,\n\tPrepareMutation,\n\tInvoke\n]);\nconst SubscriptionOperation = Schema.Struct({\n\ttype: Schema.Literal(\"Subscription\"),\n\tid: SubscriptionId\n});\nconst InvocationOperation = Schema.Struct({\n\ttype: Schema.Literal(\"Invocation\"),\n\tid: InvocationId\n});\nconst Operation = Schema.Union([SubscriptionOperation, InvocationOperation]);\nconst DatePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));\nconst DatePaths = Schema.Array(DatePath);\nconst WireSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Success\"),\n\tvalue: Schema.optional(Schema.Json),\n\tdates: Schema.optional(DatePaths)\n});\nconst WireFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Failure\"),\n\terror: Schema.Json,\n\tdates: Schema.optional(DatePaths)\n});\nconst WireResult = Schema.Union([WireSuccess, WireFailure]);\nconst SyncHandshake = Schema.Struct({\n\ttype: Schema.Literal(\"Handshake\"),\n\tappId: AppId,\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration\n});\nconst Snapshot = Schema.Struct({\n\ttype: Schema.Literal(\"Snapshot\"),\n\tid: SubscriptionId,\n\tresult: WireResult,\n\trevision: AppStateRevision,\n\tfiles: Schema.optional(Schema.Array(Schema.Struct({\n\t\tpath: RuntimeFileOccurrence.fields.path,\n\t\tfile: RuntimeFileMetadata,\n\t\turl: Schema.String\n\t})))\n});\nconst MutationPrepared = Schema.Struct({\n\ttype: Schema.Literal(\"MutationPrepared\"),\n\tid: InvocationId,\n\tuploads: Schema.Array(Schema.Struct({\n\t\tpath: RuntimeFileOccurrence.fields.path,\n\t\tfile: RuntimeFileMetadata,\n\t\turl: Schema.optional(Schema.String)\n\t}))\n});\nconst SyncResultSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Result\"),\n\tid: InvocationId,\n\tresult: WireSuccess,\n\tcommittedRevision: AppStateRevision\n});\nconst SyncResultFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Result\"),\n\tid: InvocationId,\n\tresult: WireFailure\n});\nconst ProtocolErrorCode = Schema.Literals([\n\t\"DuplicateOperationId\",\n\t\"FunctionUnavailable\",\n\t\"InvalidArguments\",\n\t\"InvalidMessage\",\n\t\"InvocationIdConflict\",\n\t\"ResourceLimitExceeded\",\n\t\"UnknownFunction\",\n\t\"WrongFunctionKind\"\n]);\nconst ProtocolError = Schema.Struct({\n\ttype: Schema.Literal(\"ProtocolError\"),\n\toperation: Schema.optional(Operation),\n\tcode: ProtocolErrorCode,\n\tmessage: Schema.String\n});\nconst DeploymentChanged = Schema.Struct({\n\ttype: Schema.Literal(\"DeploymentChanged\"),\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration\n});\nconst DeploymentChangedCloseCode = 4409;\nconst ServerMessage = Schema.Union([\n\tSyncHandshake,\n\tSnapshot,\n\tMutationPrepared,\n\tSyncResultSuccess,\n\tSyncResultFailure,\n\tProtocolError,\n\tDeploymentChanged\n]);\nconst ClientMessageJson = Schema.fromJsonString(ClientMessage);\nconst ServerMessageJson = Schema.fromJsonString(ServerMessage);\n//#endregion\nexport { ClientMessage, ClientMessageJson, DatePath, DeploymentChanged, DeploymentChangedCloseCode, FunctionAddress, FunctionNamePart, InvocationId, Operation, ProtocolErrorCode, ServerMessage, ServerMessageJson, SubscriptionId, SyncHandshake, TransportValueSchema, WireFailure, WireResult, WireSuccess, apiFunctionParts, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue };\n\n//# sourceMappingURL=sync.js.map","import { Predicate } from \"effect\";\nimport type { Effect } from \"effect\";\n\nimport type { ErrorValue, InternalServerError } from \"@ignotum/contracts/runtime/result\";\nimport { FunctionAddress } from \"@ignotum/contracts/runtime/sync\";\nimport type { FileValue } from \"@ignotum/contracts/schema/file\";\n\nconst FunctionReferenceTypeId: unique symbol = Symbol.for(\"ignotum/internal/api/FunctionReference\");\ndeclare const FunctionReferenceTypesTypeId: unique symbol;\n\ntype FunctionKind = \"Mutation\" | \"Query\";\n\nexport type MutationInput<Value> = Value extends FileValue\n ? Value | File\n : Value extends Date\n ? Value\n : Value extends ReadonlyArray<infer Item>\n ? ReadonlyArray<MutationInput<Item>>\n : Value extends object\n ? { readonly [Key in keyof Value]: MutationInput<Value[Key]> }\n : Value;\n\nexport interface FunctionReference<\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n> {\n readonly [FunctionReferenceTypeId]: FunctionAddress;\n readonly [FunctionReferenceTypesTypeId]?: {\n readonly kind: Kind;\n readonly args: Args;\n readonly value: Success;\n readonly error: Failure;\n };\n}\n\ntype ReferenceTypes<Reference> = Reference extends {\n readonly [FunctionReferenceTypesTypeId]?: infer Types;\n}\n ? Exclude<Types, undefined>\n : never;\n\nexport declare namespace FunctionReference {\n type Args<Reference> =\n ReferenceTypes<Reference> extends { readonly args: infer Args } ? Args : never;\n type Failure<Reference> =\n ReferenceTypes<Reference> extends {\n readonly error: infer Failure;\n }\n ? Failure\n : never;\n type Kind<Reference> =\n ReferenceTypes<Reference> extends { readonly kind: infer Kind } ? Kind : never;\n type Success<Reference> =\n ReferenceTypes<Reference> extends {\n readonly value: infer Success;\n }\n ? Success\n : never;\n}\n\ntype ReferenceOf<Definition> = Definition extends {\n readonly _tag: infer Kind extends FunctionKind;\n readonly handler: (\n ...arguments_: infer HandlerArguments\n ) => Generator<infer Yielded, infer Success, never>;\n}\n ? HandlerArguments extends readonly [infer _Context, ...infer Rest]\n ? FunctionReference<\n Kind,\n Rest extends readonly [infer Args, ...ReadonlyArray<unknown>]\n ? Kind extends \"Mutation\"\n ? MutationInput<Args>\n : Args\n : void,\n Success,\n | (Yielded extends Effect.Effect<unknown, infer Failure extends ErrorValue, never>\n ? Failure\n : never)\n | InternalServerError\n >\n : never\n : never;\n\ntype ApiModule<Module> = {\n readonly [FunctionName in keyof Module as FunctionName extends string\n ? ReferenceOf<Module[FunctionName]> extends never\n ? never\n : FunctionName\n : never]: ReferenceOf<Module[FunctionName]>;\n};\n\nexport type Api<Modules> = {\n readonly [ModuleName in keyof Modules]: ApiModule<Modules[ModuleName]>;\n};\n\nexport const functionPathOf = <\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n>(\n reference: FunctionReference<Kind, Args, Success, Failure>,\n) => reference[FunctionReferenceTypeId];\n\nconst makeModuleReference = (moduleName: string) => {\n const references = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, functionName) => {\n if (!Predicate.isString(functionName)) {\n return undefined;\n }\n\n const existing = references.get(functionName);\n if (existing !== undefined) {\n return existing;\n }\n\n const reference = {\n [FunctionReferenceTypeId]: FunctionAddress.make(`api.${moduleName}.${functionName}`),\n };\n references.set(functionName, reference);\n return reference;\n },\n },\n );\n};\n\nexport function createApi<Modules>(): Api<Modules>;\nexport function createApi() {\n const modules = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, moduleName) => {\n if (!Predicate.isString(moduleName)) {\n return undefined;\n }\n\n const existing = modules.get(moduleName);\n if (existing !== undefined) {\n return existing;\n }\n\n const moduleReference = makeModuleReference(moduleName);\n modules.set(moduleName, moduleReference);\n return moduleReference;\n },\n },\n );\n}\n"],"mappings":";;;AAGA,MAAM,gBAAgB,OAAO,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACrF,MAAM,uBAAuB,OAAO,QAAQ,KAAK,OAAO,MAAM,qCAAqC,CAAC;AACpG,MAAM,mBAAmB,OAAO,QAAQ,KAAK,OAAO,MAAM,iCAAiC,CAAC;;;ACC5F,MAAM,mBAAmB,OAAO,OAAO,MAAM,OAAO,UAAU,4BAA4B,CAAC;AAC3D,OAAO,sBAAsB;CAC5D;CACA;CACA;CACA;A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B,OAAO,MAAM;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,oBAAoB,OAAO,eAAe,aAAa;AAC7D,MAAM,oBAAoB,OAAO,eAAe,aAAa;;;AC7I7D,MAAM,0BAAyC,OAAO,IAAI,wCAAwC;AA0FlG,MAAa,kBAMX,cACG,UAAU;AAEf,MAAM,uBAAuB,eAAuB;CAClD,MAAM,6BAAa,IAAI,IAAoB;CAE3C,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,iBAAiB;EAC9B,IAAI,CAAC,UAAU,SAAS,YAAY,GAClC;EAGF,MAAM,WAAW,WAAW,IAAI,YAAY;EAC5C,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,YAAY,GACf,0BAA0B,gBAAgB,KAAK,OAAO,WAAW,GAAG,cAAc,EACrF;EACA,WAAW,IAAI,cAAc,SAAS;EACtC,OAAO;CACT,EACF,CACF;AACF;AAGA,SAAgB,YAAY;CAC1B,MAAM,0BAAU,IAAI,IAAoB;CAExC,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,eAAe;EAC5B,IAAI,CAAC,UAAU,SAAS,UAAU,GAChC;EAGF,MAAM,WAAW,QAAQ,IAAI,UAAU;EACvC,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,kBAAkB,oBAAoB,UAAU;EACtD,QAAQ,IAAI,YAAY,eAAe;EACvC,OAAO;CACT,EACF,CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
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,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;AACjF,MAAM,eAAe,SAAS,OAAO,2BAA2B;AAChE,MAAM,iBAAiB,SAAS,OAAO,6BAA6B;AAC/C,SAAS,QAAQ,8BAA8B;AACpE,MAAM,sBAAsB,SAAS,SAAS,8BAA8B;AAC5E,MAAM,YAAY,SAAS,OAAO,2BAA2B;AACnC,SAAS,QAAQ,4BAA4B;;;ACnBvE,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;AACD;AACA,MAAM,aAAa,OAAO,SAAS,WAAW;AAC9C,MAAM,gBAAgB;CACrB,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MA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