ignotum 0.0.16 → 0.0.17

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 (123) hide show
  1. package/README.md +6 -6
  2. package/dist/cli/bin.mjs +13256 -2688
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/platform/_headers +3 -0
  5. package/dist/platform/_ignotum/v1.0/client.js +12 -0
  6. package/dist/runtime/{api-B4fwp5a2.d.ts → api-BnUKx9cj-D49Tf0rX.d.ts} +4 -3
  7. package/dist/runtime/api-C-tltz6s.js +31 -0
  8. package/dist/runtime/api-C-tltz6s.js.map +1 -0
  9. package/dist/runtime/artifact-BB5qzoa6.js +42 -0
  10. package/dist/runtime/artifact-BB5qzoa6.js.map +1 -0
  11. package/dist/runtime/{bootstrap-BTFScKAc.d.ts → bootstrap-DjTwGJao-DBx5zdFI.d.ts} +64 -64
  12. package/dist/runtime/{bootstrap-BISQSn_O.js → bootstrap-DlNIfH-r.js} +9 -9
  13. package/dist/runtime/bootstrap-DlNIfH-r.js.map +1 -0
  14. package/dist/runtime/client.d.ts +24 -20
  15. package/dist/runtime/client.js +9 -9
  16. package/dist/runtime/client.js.map +1 -1
  17. package/dist/runtime/id-BI08JkmR.d.ts +1 -0
  18. package/dist/runtime/{id--1m0NuUL.js → id-BrEnxY-r.js} +118 -53
  19. package/dist/runtime/id-BrEnxY-r.js.map +1 -0
  20. package/dist/runtime/{image-Djtjy4Z8.js → image-gofzZeCm.js} +2 -2
  21. package/dist/runtime/image-gofzZeCm.js.map +1 -0
  22. package/dist/runtime/{index-D4seNHlX.d.ts → index-Biaw5vdF.d.ts} +2 -2
  23. package/dist/runtime/internal/api.d.ts +1 -1
  24. package/dist/runtime/internal/api.js +1 -30
  25. package/dist/runtime/internal/bootstrap.d.ts +1 -1
  26. package/dist/runtime/internal/bootstrap.js +1 -1
  27. package/dist/runtime/internal/client.d.ts +2 -2
  28. package/dist/runtime/internal/client.js +4 -4
  29. package/dist/runtime/internal/client.js.map +1 -1
  30. package/dist/runtime/internal/host.d.ts +4 -4
  31. package/dist/runtime/internal/host.js +4 -4
  32. package/dist/runtime/internal/routes.d.ts +1 -1
  33. package/dist/runtime/internal/routes.js +1 -1
  34. package/dist/runtime/internal/server.d.ts +3 -2
  35. package/dist/runtime/internal/server.js +2 -2
  36. package/dist/runtime/internal/server.js.map +1 -1
  37. package/dist/runtime/internal/types.d.ts +2 -2
  38. package/dist/runtime/internal/types.js +1 -1
  39. package/dist/runtime/{pagination-D3qd6s9N.js → pagination--f4kMKf6.js} +2 -2
  40. package/dist/runtime/{pagination-D3qd6s9N.js.map → pagination--f4kMKf6.js.map} +1 -1
  41. package/dist/runtime/pagination-BI08JkmR.d.ts +1 -0
  42. package/dist/runtime/{router-BSBI1oN1.js → router-C1eC9yy5.js} +462 -419
  43. package/dist/runtime/router-C1eC9yy5.js.map +1 -0
  44. package/dist/runtime/routes-DnU39R7c.js +152 -0
  45. package/dist/runtime/routes-DnU39R7c.js.map +1 -0
  46. package/dist/runtime/{schema-D1wOqiNH.js → schema-BSjepoNF.js} +271 -6
  47. package/dist/runtime/schema-BSjepoNF.js.map +1 -0
  48. package/dist/runtime/server.d.ts +5 -4
  49. package/dist/runtime/server.js +3 -3
  50. package/dist/runtime/server.js.map +1 -1
  51. package/dist/runtime/{sync-DzUwA8W9.js → sync-BwgS19Xy.js} +4 -16
  52. package/dist/runtime/sync-BwgS19Xy.js.map +1 -0
  53. package/dist/runtime/{sync-D-GK2sv9.d.ts → sync-By2hX5ev.d.ts} +1 -2
  54. package/dist/runtime/{types-DeCCyqLU-BIm7rU-0.d.ts → types-DeCCyqLU-CHx7KFtx.d.ts} +2 -2
  55. package/package.json +8 -2
  56. package/src/cli/agent-files.ts +2 -0
  57. package/src/cli/build/asset-names.ts +190 -0
  58. package/src/cli/build/managed-client.ts +151 -81
  59. package/src/cli/build/managed-server.ts +4 -4
  60. package/src/cli/build/managed.ts +5 -6
  61. package/src/cli/command.ts +6 -15
  62. package/src/cli/control-client.ts +7 -9
  63. package/src/cli/deploy.ts +45 -15
  64. package/src/cli/dev.ts +50 -99
  65. package/src/cli/image-assets.ts +5 -2
  66. package/src/cli/managed-client-boundaries.ts +6 -6
  67. package/src/cli/managed-dev-platform.ts +52 -66
  68. package/src/cli/managed-exports.ts +5 -66
  69. package/src/cli/new-app.ts +7 -2
  70. package/src/cli/upload-journal.ts +130 -0
  71. package/src/client/bootstrap.ts +1 -110
  72. package/src/client/errors.ts +1 -70
  73. package/src/client/files.ts +1 -233
  74. package/src/client/hooks.ts +1 -367
  75. package/src/client/id.ts +1 -263
  76. package/src/client/image.ts +1 -28
  77. package/src/client/index.ts +1 -126
  78. package/src/client/jsx-dev-runtime.ts +1 -2
  79. package/src/client/jsx-runtime.ts +1 -2
  80. package/src/client/managed-client.ts +1 -729
  81. package/src/client/managed-upgrade.ts +1 -283
  82. package/src/client/page-observers.ts +1 -77
  83. package/src/client/query.ts +1 -17
  84. package/src/client/recovery-journal.ts +1 -195
  85. package/src/client/route-boundaries.ts +1 -184
  86. package/src/client/router-history.ts +1 -152
  87. package/src/client/router-store.ts +1 -644
  88. package/src/client/router.ts +1 -324
  89. package/src/client/routes.ts +1 -28
  90. package/src/client/sync.ts +1 -286
  91. package/src/dev-runtime/id.ts +1 -1
  92. package/src/dev-runtime/managed-functions.ts +10 -18
  93. package/src/dev-runtime/managed-sync.ts +16 -16
  94. package/src/dev-runtime/sync.ts +6 -4
  95. package/src/internal/api.ts +1 -156
  96. package/src/internal/client.ts +1 -186
  97. package/src/internal/host.ts +1 -1
  98. package/src/internal/http-paths.ts +1 -4
  99. package/src/internal/routes.ts +1 -45
  100. package/src/internal/server.ts +1 -3
  101. package/src/internal/types.ts +1 -2
  102. package/src/server/index.ts +1 -27
  103. package/dist/cli/managed-release-WHYLZwaS.mjs +0 -10902
  104. package/dist/cli/managed-release-WHYLZwaS.mjs.map +0 -1
  105. package/dist/cli/managed-release.d.mts +0 -1
  106. package/dist/cli/managed-release.mjs +0 -14
  107. package/dist/cli/managed-release.mjs.map +0 -1
  108. package/dist/runtime/bootstrap-BISQSn_O.js.map +0 -1
  109. package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js +0 -269
  110. package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js.map +0 -1
  111. package/dist/runtime/id--1m0NuUL.js.map +0 -1
  112. package/dist/runtime/id-CBOt2kDo.d.ts +0 -1
  113. package/dist/runtime/identity-QjtJRxBD.d.ts +0 -2
  114. package/dist/runtime/image-Djtjy4Z8.js.map +0 -1
  115. package/dist/runtime/internal/api.js.map +0 -1
  116. package/dist/runtime/pagination-CBOt2kDo.d.ts +0 -1
  117. package/dist/runtime/router-BSBI1oN1.js.map +0 -1
  118. package/dist/runtime/routes-Ce8TVP-T.js +0 -690
  119. package/dist/runtime/routes-Ce8TVP-T.js.map +0 -1
  120. package/dist/runtime/schema-D1wOqiNH.js.map +0 -1
  121. package/dist/runtime/sync-DzUwA8W9.js.map +0 -1
  122. package/src/cli/managed-release-bin.ts +0 -13
  123. package/src/cli/managed-release.ts +0 -260
@@ -1,6 +1,7 @@
1
- import { A as RuntimeFileMetadata, B as makeFileValue, D as encodeTransportObject, E as decodeTransportValue, F as fileIdOf, G as InvocationId, H as AppId, I as fileLimits, J as TableId, K as SessionEpoch, L as fileMimeTypes, N as fileFormats, P as fileGrantUrlOf, R as grantFileValue, U as GeneratedId, W as IdAlphabet, Y as VersionId, _ as Result$1, a as SessionResponse, d as sessionPath, f as sessionRequestsPath, i as SessionRequest, j as RuntimeFileOccurrence, k as FileId, l as developmentSelectionKey, n as SessionOutcome, o as SessionState, p as initial, q as SubscriptionId, r as SessionRedirect, t as DevelopmentSelection, x as pending, y as failureFromWire, z as isFileValue } from "./id--1m0NuUL.js";
2
- import { a as ActivationGeneration, i as WireSuccess, l as DataHistoryId, n as WireFailure, o as AppStateRevision, r as WireResult, t as FunctionAddress, u as InvocationKey } from "./sync-DzUwA8W9.js";
3
- import { a as RouteDefinition, d as RecoveryIdentity, f as RecoverySessionId, l as appDefinitionLimits, n as getRouteDefinition, p as sameExecutionSelection, r as LayoutDefinition, u as ExecutionSelection } from "./routes-Ce8TVP-T.js";
1
+ import { a as IdAlphabet, c as SessionEpoch, d as VersionId, f as defineId, i as GeneratedId, l as SubscriptionId, o as InvocationId, r as AppId, u as TableId } from "./artifact-BB5qzoa6.js";
2
+ import { A as encodeTransportObject, B as fileMimeTypes, C as sameSelection, G as ActivationGeneration, H as isFileValue, I as fileFormats, J as InvocationKey, K as AppStateRevision, L as fileGrantUrlOf, M as FileId, N as RuntimeFileMetadata, P as RuntimeFileOccurrence, R as fileIdOf, S as endpointUrl, U as makeFileValue, V as grantFileValue, _ as failureFromWire, a as SessionResponse, d as sessionPath, f as sessionRequestsPath, h as Result$1, i as SessionRequest, k as decodeTransportValue, l as developmentSelectionKey, n as SessionOutcome, o as SessionState, q as DataHistoryId, r as SessionRedirect, t as DevelopmentSelection, w as initial, x as ServingSelection, y as pending, z as fileLimits } from "./id-BrEnxY-r.js";
3
+ import { i as WireSuccess, n as WireFailure, r as WireResult, t as FunctionAddress } from "./sync-BwgS19Xy.js";
4
+ import { a as RouteDefinition, l as appDefinitionLimits, n as getRouteDefinition, r as LayoutDefinition } from "./routes-DnU39R7c.js";
4
5
  import { Array as Array$1, Cause, Context, DateTime, Deferred, Effect, ErrorReporter, Layer, ManagedRuntime, Option, Predicate, Schema, Semaphore, String as String$1 } from "effect";
5
6
  import { customAlphabet } from "nanoid";
6
7
  import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
@@ -14,7 +15,7 @@ const encodeJson = (value) => {
14
15
  };
15
16
  const encodeCanonicalJson = (value) => encodeJson(Schema.decodeSync(Schema.Json)(value));
16
17
  //#endregion
17
- //#region src/client/errors.ts
18
+ //#region ../platform/dist/versions/1/browser/errors.js
18
19
  /** @effect-diagnostics globalConsole:skip-file */
19
20
  var ConnectionUnavailable = class extends Schema.TaggedError()("ConnectionUnavailable", {
20
21
  cause: Schema.optional(Schema.Defect()),
@@ -74,7 +75,7 @@ var IdGenerator = class IdGenerator extends Context.Service()("@ignotum/shared/i
74
75
  });
75
76
  };
76
77
  //#endregion
77
- //#region src/client/files.ts
78
+ //#region ../platform/dist/versions/1/browser/files.js
78
79
  const Files = { url: (file) => {
79
80
  const url = fileGrantUrlOf(file);
80
81
  if (url === void 0) throw new Error("This FileValue has no active query grant.");
@@ -212,7 +213,7 @@ const uploadPreparedFiles = Effect.fn("uploadPreparedFiles")(function* (nativeFi
212
213
  });
213
214
  });
214
215
  //#endregion
215
- //#region src/client/id.ts
216
+ //#region ../platform/dist/versions/1/browser/id.js
216
217
  var IdRequestError = class extends Schema.TaggedError()("IdRequestError", { message: Schema.String }) {};
217
218
  const outcomeKey = "ignotum.id.outcome";
218
219
  const selectionJson = Schema.fromJsonString(DevelopmentSelection);
@@ -385,282 +386,195 @@ var BrowserSession = class BrowserSession extends Context.Service()("ignotum/cli
385
386
  })).pipe(Layer.provide(FetchHttpClient.layer));
386
387
  };
387
388
  //#endregion
388
- //#region ../contracts/dist/runtime/index.js
389
- const IndexIdentity = Schema.String.pipe(Schema.brand("ignotum/runtime/IndexIdentity"));
390
- const EncodedIndexKey = Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2})*$/)).pipe(Schema.brand("ignotum/runtime/EncodedIndexKey"));
391
- Schema.Union([
392
- Schema.Boolean,
393
- Schema.Finite,
394
- Schema.String
395
- ]);
396
- Schema.String.pipe(Schema.brand("ignotum/hosted/QueryKey"));
397
- const TableDependency = Schema.Struct({
398
- type: Schema.Literal("Table"),
399
- tableId: TableId
400
- });
401
- const DocumentDependency = Schema.Struct({
402
- type: Schema.Literal("Document"),
403
- tableId: TableId,
404
- id: GeneratedId
405
- });
406
- const IndexRangeDependency = Schema.Struct({
407
- type: Schema.Literal("IndexRange"),
408
- tableId: TableId,
409
- index: IndexIdentity,
410
- lower: Schema.optional(EncodedIndexKey),
411
- upper: Schema.optional(EncodedIndexKey)
412
- });
413
- const IndexPointInvalidation = Schema.Struct({
414
- type: Schema.Literal("IndexPoint"),
415
- tableId: TableId,
416
- index: IndexIdentity,
417
- key: EncodedIndexKey
418
- });
419
- const IdDependency = Schema.Struct({ type: Schema.Literal("Id") });
420
- const ReadDependency = Schema.Union([
421
- IdDependency,
422
- TableDependency,
423
- DocumentDependency,
424
- IndexRangeDependency
425
- ]);
426
- const WriteInvalidation = Schema.Union([
427
- TableDependency,
428
- DocumentDependency,
429
- IndexPointInvalidation
430
- ]);
431
- Schema.Union([ReadDependency, IndexPointInvalidation]);
432
- const DependencySet = Schema.Array(ReadDependency);
433
- const InvalidationSet = Schema.Array(WriteInvalidation);
434
- const RuntimeQueryResult = Schema.Struct({
435
- type: Schema.Literal("Query"),
436
- result: WireResult,
437
- dependencies: DependencySet,
438
- observedRevision: AppStateRevision,
439
- files: Schema.optional(Schema.Array(RuntimeFileOccurrence))
440
- });
441
- const FileReferenceAdded = Schema.Struct({
442
- type: Schema.Literal("AddReference"),
443
- file: RuntimeFileMetadata,
444
- tableId: TableId,
445
- documentId: GeneratedId
446
- });
447
- const FileReferenceRemoved = Schema.Struct({
448
- type: Schema.Literal("RemoveReference"),
449
- fileId: FileId,
450
- tableId: TableId,
451
- documentId: GeneratedId
452
- });
453
- const FileReferenceEffect = Schema.Union([FileReferenceAdded, FileReferenceRemoved]);
454
- const FileEffectBatch = Schema.Struct({
455
- id: InvocationId,
456
- dataHistoryId: Schema.optional(DataHistoryId),
457
- committedRevision: AppStateRevision,
458
- effects: Schema.Array(FileReferenceEffect)
459
- });
460
- Schema.Struct({ appId: AppId });
461
- Schema.Struct({ batches: Schema.Array(FileEffectBatch) });
462
- Schema.Struct({
463
- appId: AppId,
389
+ //#region ../contracts/dist/execution.js
390
+ const strict = (fields) => Schema.Struct(fields).annotate({ parseOptions: { onExcessProperty: "error" } });
391
+ /** Browser recovery scope only; reconciliation must verify the owning session separately. */
392
+ const RecoverySessionId = defineId("rec", "ignotum/platform/RecoverySessionId");
393
+ const RecoveryIdentity = strict({
464
394
  invocationId: InvocationId,
465
- acknowledgedAt: Schema.Int,
466
- dataHistoryId: DataHistoryId
467
- });
468
- Schema.Struct({ completed: Schema.Literal(true) });
469
- const RuntimeMutationSuccess = Schema.Struct({
470
- type: Schema.Literal("Mutation"),
471
- result: WireSuccess,
472
- invalidations: InvalidationSet,
473
- committedRevision: AppStateRevision,
474
- fileEffects: Schema.optional(FileEffectBatch)
475
- });
476
- const RuntimeMutationFailure = Schema.Struct({
477
- type: Schema.Literal("Mutation"),
478
- result: WireFailure
479
- });
480
- const RuntimeMutationResult = Schema.Union([RuntimeMutationSuccess, RuntimeMutationFailure]);
481
- Schema.Union([RuntimeQueryResult, RuntimeMutationResult]);
482
- const RuntimeRecoveryOwner = Schema.Struct({
483
- clientSessionId: RecoverySessionId,
484
- sessionEpoch: Schema.NullOr(Schema.String)
395
+ originalSelection: ServingSelection
485
396
  });
486
- Schema.Struct({
487
- appId: AppId,
488
- identity: RecoveryIdentity,
489
- owner: RuntimeRecoveryOwner
490
- });
491
- const RuntimeMutationOutcome = Schema.Union([
492
- Schema.Struct({
493
- type: Schema.Literal("Settled"),
494
- result: RuntimeMutationResult
495
- }),
496
- Schema.Struct({ type: Schema.Literal("Interrupted") }),
497
- Schema.Struct({ type: Schema.Literal("Pending") }),
498
- Schema.Struct({ type: Schema.Literal("Uncertain") })
499
- ]);
500
- const InvocationBase = {
501
- appId: AppId,
502
- versionId: VersionId,
503
- generation: ActivationGeneration,
504
- selection: Schema.optional(ExecutionSelection),
505
- invocationKey: InvocationKey,
506
- function: FunctionAddress,
507
- args: Schema.Json,
508
- identity: Schema.optional(SessionState)
397
+ const RecoveryLimits = {
398
+ maxOperations: 1024,
399
+ maxRetentionMs: 6048e5
509
400
  };
510
- const QueryInvocation = Schema.Struct({
511
- ...InvocationBase,
512
- type: Schema.Literal("Query")
513
- });
514
- const MutationInvocation = Schema.Struct({
515
- ...InvocationBase,
516
- type: Schema.Literal("Mutation"),
517
- invocationId: InvocationId,
518
- recoveryOwner: Schema.optional(RuntimeRecoveryOwner),
519
- files: Schema.optional(Schema.Array(RuntimeFileOccurrence))
520
- });
521
- Schema.Union([QueryInvocation, MutationInvocation]);
522
- Schema.Struct({
523
- appId: AppId,
524
- expectedRevision: AppStateRevision
525
- });
526
- Schema.Struct({ currentRevision: AppStateRevision });
527
- var RuntimeVersionUnavailable = class extends Schema.TaggedError()("RuntimeVersionUnavailable", {
528
- versionId: VersionId,
529
- message: Schema.String
530
- }) {};
531
- const RuntimeInvocationRejectionCode = Schema.Literals([
532
- "SessionExpired",
533
- "FunctionUnavailable",
534
- "InvalidArguments",
535
- "InvocationIdConflict",
536
- "ResourceLimitExceeded",
537
- "UnknownFunction",
538
- "WrongFunctionKind"
539
- ]);
540
- var RuntimeInvocationRejected = class extends Schema.TaggedError()("RuntimeInvocationRejected", {
541
- code: RuntimeInvocationRejectionCode,
542
- invocationKey: InvocationKey,
543
- message: Schema.String
544
- }) {};
545
- var RuntimeInvocationUnavailable = class extends Schema.TaggedError()("RuntimeInvocationUnavailable", {
546
- invocationKey: InvocationKey,
547
- message: Schema.String
548
- }) {};
549
- Schema.TaggedError()("RuntimeRevisionRejected", {
401
+ const RecoveryRecordV1 = strict({
402
+ formatVersion: Schema.Literal(1),
550
403
  appId: AppId,
551
- message: Schema.String
552
- });
553
- Schema.Union([
554
- RuntimeVersionUnavailable,
555
- RuntimeInvocationRejected,
556
- RuntimeInvocationUnavailable
557
- ]);
404
+ clientSessionId: RecoverySessionId,
405
+ recordedAt: Schema.Natural,
406
+ expiresAt: Schema.Natural,
407
+ operations: Schema.Array(RecoveryIdentity).check(Schema.isMaxLength(RecoveryLimits.maxOperations))
408
+ }).check(Schema.makeFilter((record) => {
409
+ const issues = [];
410
+ if (record.expiresAt <= record.recordedAt || record.expiresAt - record.recordedAt > RecoveryLimits.maxRetentionMs) issues.push({
411
+ path: ["expiresAt"],
412
+ issue: "Recovery retention must be positive and bounded"
413
+ });
414
+ if (record.operations.some((operation) => operation.originalSelection.appId !== record.appId)) issues.push({
415
+ path: ["operations"],
416
+ issue: "Recovery operations must belong to the record's app"
417
+ });
418
+ const identities = record.operations.map((operation) => `${operation.originalSelection.dataHistoryId}/${operation.invocationId}`);
419
+ if (new Set(identities).size !== identities.length) issues.push({
420
+ path: ["operations"],
421
+ issue: "Recovery operation identities must be unique within a data history"
422
+ });
423
+ return issues;
424
+ })).annotate({ parseOptions: { onExcessProperty: "error" } });
425
+ initial(RecoveryRecordV1);
558
426
  //#endregion
559
- //#region ../contracts/dist/managed-sync.js
560
- const managedSyncPath = "/_ignotum/v2/sync";
561
- const managedSelectionPath = "/_ignotum/v2/selection";
562
- const ManagedSelectionResponse = Schema.Struct({
563
- protocolVersion: Schema.Literal(1),
564
- selection: ExecutionSelection
565
- });
566
- const ManagedClientMessage = Schema.Union([
567
- Schema.Struct({
568
- type: Schema.Literal("Connect"),
569
- protocolVersion: Schema.Natural,
570
- selection: ExecutionSelection,
571
- clientSessionId: RecoverySessionId
572
- }),
573
- Schema.Struct({
574
- type: Schema.Literal("Prepare"),
575
- invocationId: InvocationId,
576
- function: FunctionAddress,
577
- args: Schema.Json,
578
- files: Schema.Array(FileId).check(Schema.isMaxLength(fileLimits.filesPerMutation))
579
- }),
580
- Schema.Struct({
581
- type: Schema.Literal("Invoke"),
582
- invocationId: InvocationId,
583
- function: FunctionAddress,
584
- args: Schema.Json
585
- }),
586
- Schema.Struct({
587
- type: Schema.Literal("RecoverMutation"),
588
- id: Schema.String.check(Schema.isMaxLength(128)),
589
- identity: RecoveryIdentity
590
- }),
591
- Schema.Struct({
592
- type: Schema.Literal("Subscribe"),
593
- id: SubscriptionId,
594
- function: FunctionAddress,
595
- args: Schema.Json
596
- }),
597
- Schema.Struct({
598
- type: Schema.Literal("Unsubscribe"),
599
- id: SubscriptionId
600
- })
601
- ]);
602
- /** Decode this envelope before the normal server protocol, including on unsupported versions. */
603
- const ManagedUpgradeRequired = Schema.Struct({
604
- type: Schema.Literal("UpgradeRequired"),
605
- selection: ExecutionSelection
427
+ //#region ../platform/dist/versions/1/browser/recovery-journal.js
428
+ const RecoveryJournalLimits = {
429
+ maxEntries: 100,
430
+ retentionMs: 864e5,
431
+ maxBytes: 65536
432
+ };
433
+ const RecoveryEntry = Schema.Struct({
434
+ identity: RecoveryIdentity,
435
+ recordedAt: Schema.Natural,
436
+ expiresAt: Schema.Natural,
437
+ state: Schema.Literals([
438
+ "pending",
439
+ "settled",
440
+ "interrupted",
441
+ "uncertain"
442
+ ])
606
443
  });
607
- const ManagedServerMessage = Schema.Union([
608
- ManagedUpgradeRequired,
609
- Schema.Struct({
610
- type: Schema.Literal("Handshake"),
611
- protocolVersion: Schema.Literal(1),
612
- selection: ExecutionSelection,
613
- session: SessionState,
614
- serverTime: Schema.Finite
615
- }),
616
- Schema.Struct({
617
- type: Schema.Literal("Preparation"),
618
- invocationId: InvocationId,
619
- uploads: Schema.Array(Schema.Struct({
620
- id: FileId,
621
- url: Schema.optional(Schema.String)
622
- }))
623
- }),
624
- Schema.Struct({
625
- type: Schema.Literal("MutationOutcome"),
626
- id: Schema.String,
627
- identity: RecoveryIdentity,
628
- outcome: RuntimeMutationOutcome
629
- }),
630
- Schema.Struct({
631
- type: Schema.Literal("QuerySnapshot"),
632
- selection: ExecutionSelection,
633
- id: SubscriptionId,
634
- result: RuntimeQueryResult,
635
- files: Schema.optional(Schema.Array(Schema.Struct({
636
- id: FileId,
637
- url: Schema.String
638
- })))
639
- }),
640
- Schema.Struct({
641
- type: Schema.Literal("Error"),
642
- id: Schema.optional(Schema.String),
643
- code: Schema.Literals([
644
- "PlatformUpgrading",
645
- "SessionExpired",
646
- "InvalidMessage",
647
- "Unavailable",
648
- "InvalidArguments",
649
- "InvocationIdConflict",
650
- "ResourceLimitExceeded"
651
- ]),
652
- message: Schema.String
653
- })
654
- ]);
444
+ const RecoveryJournalV1 = Schema.Struct({
445
+ formatVersion: Schema.Literal(1),
446
+ appId: AppId,
447
+ sessionEpoch: Schema.String,
448
+ clientSessionId: RecoverySessionId,
449
+ entries: Schema.Array(RecoveryEntry).check(Schema.isMaxLength(RecoveryJournalLimits.maxEntries))
450
+ }).check(Schema.makeFilter((record) => {
451
+ const keys = record.entries.map((entry) => identityKey(entry.identity));
452
+ return new Set(keys).size === keys.length && record.entries.every((entry) => entry.identity.originalSelection.appId === record.appId && entry.expiresAt > entry.recordedAt && entry.expiresAt - entry.recordedAt <= RecoveryJournalLimits.retentionMs);
453
+ })).annotate({ parseOptions: { onExcessProperty: "error" } });
454
+ const RecoveryJournalRecord = initial(RecoveryJournalV1);
455
+ const identityKey = (identity) => `${identity.originalSelection.dataHistoryId}/${identity.invocationId}`;
456
+ const bytes = (value) => new TextEncoder().encode(value).byteLength;
457
+ /** sessionStorage isolates tabs. A cloned tab may look up copied identities, never replay them. */
458
+ var RecoveryJournal = class {
459
+ options;
460
+ storageKey;
461
+ clientSessionId;
462
+ constructor(options) {
463
+ this.options = options;
464
+ this.storageKey = `ignotum:recovery:${options.appId}`;
465
+ this.clientSessionId = options.clientSessionId;
466
+ }
467
+ storage() {
468
+ const storage = this.options.storage;
469
+ return storage === void 0 ? globalThis.sessionStorage : Predicate.isFunction(storage) ? storage() : storage;
470
+ }
471
+ now() {
472
+ return this.options.now?.() ?? DateTime.toEpochMillis(DateTime.nowUnsafe());
473
+ }
474
+ snapshot(entries, issues) {
475
+ return {
476
+ clientSessionId: this.clientSessionId,
477
+ entries,
478
+ issues
479
+ };
480
+ }
481
+ read() {
482
+ let raw;
483
+ try {
484
+ raw = this.storage().getItem(this.storageKey);
485
+ } catch {
486
+ return this.snapshot([], ["denied"]);
487
+ }
488
+ if (raw === null) return this.snapshot([], []);
489
+ if (bytes(raw) > RecoveryJournalLimits.maxBytes) return this.discard("full");
490
+ const parsed = Schema.decodeUnknownOption(Schema.fromJsonString(RecoveryJournalRecord))(raw);
491
+ if (parsed._tag === "None" || parsed.value.appId !== this.options.appId) return this.discard("corrupt");
492
+ if (parsed.value.sessionEpoch !== this.options.sessionEpoch) return this.discard("session-changed");
493
+ this.clientSessionId = parsed.value.clientSessionId;
494
+ const now = this.now();
495
+ const entries = parsed.value.entries.filter((entry) => entry.expiresAt > now && entry.recordedAt <= now);
496
+ const issues = entries.length === parsed.value.entries.length ? [] : ["expired"];
497
+ return issues.length === 0 ? this.snapshot(entries, issues) : this.persist(entries, issues);
498
+ }
499
+ discard(issue) {
500
+ try {
501
+ this.storage().removeItem(this.storageKey);
502
+ return this.snapshot([], [issue]);
503
+ } catch {
504
+ return this.snapshot([], [issue, "denied"]);
505
+ }
506
+ }
507
+ persist(entries, issues) {
508
+ const record = {
509
+ formatVersion: 1,
510
+ appId: this.options.appId,
511
+ sessionEpoch: this.options.sessionEpoch,
512
+ clientSessionId: this.clientSessionId,
513
+ entries
514
+ };
515
+ const encoded = Schema.encodeOption(Schema.fromJsonString(RecoveryJournalRecord))(record);
516
+ if (encoded._tag === "None") return this.snapshot(entries, [...issues, "corrupt"]);
517
+ if (bytes(encoded.value) > RecoveryJournalLimits.maxBytes) return this.snapshot(entries, [...issues, "full"]);
518
+ try {
519
+ this.storage().setItem(this.storageKey, encoded.value);
520
+ return this.snapshot(entries, issues);
521
+ } catch (error) {
522
+ return this.snapshot(entries, [...issues, error instanceof DOMException && error.name === "QuotaExceededError" ? "full" : "denied"]);
523
+ }
524
+ }
525
+ /** Call before abandoning the page; any issue means durable recovery is not proven. */
526
+ write(identities) {
527
+ const current = this.read();
528
+ if (current.issues.includes("denied")) return current;
529
+ const entries = new Map(current.entries.map((entry) => [identityKey(entry.identity), entry]));
530
+ const now = this.now();
531
+ for (const identity of identities) {
532
+ if (identity.originalSelection.appId !== this.options.appId) return this.snapshot(current.entries, [...current.issues, "corrupt"]);
533
+ const key = identityKey(identity);
534
+ if (!entries.has(key)) entries.set(key, {
535
+ identity: {
536
+ invocationId: identity.invocationId,
537
+ originalSelection: identity.originalSelection
538
+ },
539
+ recordedAt: now,
540
+ expiresAt: now + RecoveryJournalLimits.retentionMs,
541
+ state: "pending"
542
+ });
543
+ }
544
+ if (entries.size > RecoveryJournalLimits.maxEntries) return this.snapshot(current.entries, [...current.issues, "full"]);
545
+ return this.persist([...entries.values()], current.issues);
546
+ }
547
+ reconcile(identity, state) {
548
+ const current = this.read();
549
+ if (current.issues.includes("denied")) return current;
550
+ return this.persist(current.entries.map((entry) => identityKey(entry.identity) === identityKey(identity) ? {
551
+ ...entry,
552
+ state
553
+ } : entry), current.issues);
554
+ }
555
+ remove(identity) {
556
+ const current = this.read();
557
+ if (current.issues.includes("denied")) return current;
558
+ return this.persist(current.entries.filter((entry) => identityKey(entry.identity) !== identityKey(identity)), current.issues);
559
+ }
560
+ clear() {
561
+ try {
562
+ this.storage().removeItem(this.storageKey);
563
+ return this.snapshot([], []);
564
+ } catch {
565
+ return this.snapshot([], ["denied"]);
566
+ }
567
+ }
568
+ };
655
569
  //#endregion
656
- //#region src/client/managed-upgrade.ts
570
+ //#region ../platform/dist/versions/1/browser/managed-upgrade.js
657
571
  const TabStateV1 = Schema.Struct({
658
572
  formatVersion: Schema.Literal(1),
659
573
  appId: AppId,
660
574
  clientSessionId: RecoverySessionId,
661
575
  attempts: Schema.Natural.check(Schema.isLessThanOrEqualTo(3)),
662
576
  attemptedAt: Schema.Natural,
663
- target: Schema.NullOr(ExecutionSelection),
577
+ target: Schema.NullOr(ServingSelection),
664
578
  uncertainStorage: Schema.Boolean
665
579
  }).annotate({ parseOptions: { onExcessProperty: "error" } });
666
580
  const TabState = initial(TabStateV1);
@@ -687,7 +601,7 @@ var ManagedUpgrade = class {
687
601
  this.selection = selection;
688
602
  this.browser = browser;
689
603
  this.callbacks = callbacks;
690
- this.key = `ignotum.managed.tab.${selection.appId}`;
604
+ this.key = `ignotum.v3.tab.${selection.appId}`;
691
605
  this.tab = {
692
606
  formatVersion: 1,
693
607
  appId: selection.appId,
@@ -839,7 +753,7 @@ var ManagedUpgrade = class {
839
753
  if (!response.ok) throw new Error("The updated app document is temporarily unavailable.");
840
754
  await response.body?.cancel();
841
755
  if (this.disposed) return;
842
- const attempts = fresh !== void 0 && this.tab.target !== null && !sameExecutionSelection(this.tab.target, fresh) ? 0 : this.tab.attempts;
756
+ const attempts = fresh !== void 0 && this.tab.target !== null && !sameSelection(this.tab.target, fresh) ? 0 : this.tab.attempts;
843
757
  if (attempts >= 2) throw new Error("The app update could not load a consistent release. Try again when the connection or release is available.");
844
758
  this.tab = {
845
759
  ...this.tab,
@@ -883,7 +797,7 @@ var ManagedUpgrade = class {
883
797
  if (this.obsolete || this.disposed) return false;
884
798
  try {
885
799
  const fresh = await this.callbacks.freshSelection();
886
- if (fresh === void 0 || !sameExecutionSelection(this.selection, fresh)) {
800
+ if (fresh === void 0 || !sameSelection(this.selection, fresh)) {
887
801
  this.require(fresh);
888
802
  return false;
889
803
  }
@@ -900,150 +814,279 @@ var ManagedUpgrade = class {
900
814
  }
901
815
  };
902
816
  //#endregion
903
- //#region src/client/recovery-journal.ts
904
- const RecoveryJournalLimits = {
905
- maxEntries: 100,
906
- retentionMs: 864e5,
907
- maxBytes: 65536
908
- };
909
- const RecoveryEntry = Schema.Struct({
910
- identity: RecoveryIdentity,
911
- recordedAt: Schema.Natural,
912
- expiresAt: Schema.Natural,
913
- state: Schema.Literals([
914
- "pending",
915
- "settled",
916
- "interrupted",
917
- "uncertain"
918
- ])
817
+ //#region ../contracts/dist/runtime/index.js
818
+ const IndexIdentity = Schema.String.pipe(Schema.brand("ignotum/runtime/IndexIdentity"));
819
+ const EncodedIndexKey = Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2})*$/)).pipe(Schema.brand("ignotum/runtime/EncodedIndexKey"));
820
+ Schema.Union([
821
+ Schema.Boolean,
822
+ Schema.Finite,
823
+ Schema.String
824
+ ]);
825
+ Schema.String.pipe(Schema.brand("ignotum/hosted/QueryKey"));
826
+ const TableDependency = Schema.Struct({
827
+ type: Schema.Literal("Table"),
828
+ tableId: TableId
919
829
  });
920
- const RecoveryJournalV1 = Schema.Struct({
921
- formatVersion: Schema.Literal(1),
830
+ const DocumentDependency = Schema.Struct({
831
+ type: Schema.Literal("Document"),
832
+ tableId: TableId,
833
+ id: GeneratedId
834
+ });
835
+ const IndexRangeDependency = Schema.Struct({
836
+ type: Schema.Literal("IndexRange"),
837
+ tableId: TableId,
838
+ index: IndexIdentity,
839
+ lower: Schema.optional(EncodedIndexKey),
840
+ upper: Schema.optional(EncodedIndexKey)
841
+ });
842
+ const IndexPointInvalidation = Schema.Struct({
843
+ type: Schema.Literal("IndexPoint"),
844
+ tableId: TableId,
845
+ index: IndexIdentity,
846
+ key: EncodedIndexKey
847
+ });
848
+ const IdDependency = Schema.Struct({ type: Schema.Literal("Id") });
849
+ const ReadDependency = Schema.Union([
850
+ IdDependency,
851
+ TableDependency,
852
+ DocumentDependency,
853
+ IndexRangeDependency
854
+ ]);
855
+ const WriteInvalidation = Schema.Union([
856
+ TableDependency,
857
+ DocumentDependency,
858
+ IndexPointInvalidation
859
+ ]);
860
+ Schema.Union([ReadDependency, IndexPointInvalidation]);
861
+ const DependencySet = Schema.Array(ReadDependency);
862
+ const InvalidationSet = Schema.Array(WriteInvalidation);
863
+ const RuntimeQueryResult = Schema.Struct({
864
+ type: Schema.Literal("Query"),
865
+ result: WireResult,
866
+ dependencies: DependencySet,
867
+ observedRevision: AppStateRevision,
868
+ files: Schema.optional(Schema.Array(RuntimeFileOccurrence))
869
+ });
870
+ const FileReferenceAdded = Schema.Struct({
871
+ type: Schema.Literal("AddReference"),
872
+ file: RuntimeFileMetadata,
873
+ tableId: TableId,
874
+ documentId: GeneratedId
875
+ });
876
+ const FileReferenceRemoved = Schema.Struct({
877
+ type: Schema.Literal("RemoveReference"),
878
+ fileId: FileId,
879
+ tableId: TableId,
880
+ documentId: GeneratedId
881
+ });
882
+ const FileReferenceEffect = Schema.Union([FileReferenceAdded, FileReferenceRemoved]);
883
+ const FileEffectBatch = Schema.Struct({
884
+ id: InvocationId,
885
+ dataHistoryId: Schema.optional(DataHistoryId),
886
+ committedRevision: AppStateRevision,
887
+ effects: Schema.Array(FileReferenceEffect)
888
+ });
889
+ Schema.Struct({ appId: AppId });
890
+ Schema.Struct({ batches: Schema.Array(FileEffectBatch) });
891
+ Schema.Struct({
922
892
  appId: AppId,
923
- sessionEpoch: Schema.String,
924
- clientSessionId: RecoverySessionId,
925
- entries: Schema.Array(RecoveryEntry).check(Schema.isMaxLength(RecoveryJournalLimits.maxEntries))
926
- }).check(Schema.makeFilter((record) => {
927
- const keys = record.entries.map((entry) => identityKey(entry.identity));
928
- return new Set(keys).size === keys.length && record.entries.every((entry) => entry.identity.originalSelection.appId === record.appId && entry.expiresAt > entry.recordedAt && entry.expiresAt - entry.recordedAt <= RecoveryJournalLimits.retentionMs);
929
- })).annotate({ parseOptions: { onExcessProperty: "error" } });
930
- const RecoveryJournalRecord = initial(RecoveryJournalV1);
931
- const identityKey = (identity) => `${identity.originalSelection.dataHistoryId}/${identity.invocationId}`;
932
- const bytes = (value) => new TextEncoder().encode(value).byteLength;
933
- /** sessionStorage isolates tabs. A cloned tab may look up copied identities, never replay them. */
934
- var RecoveryJournal = class {
935
- options;
936
- storageKey;
937
- clientSessionId;
938
- constructor(options) {
939
- this.options = options;
940
- this.storageKey = `ignotum:recovery:${options.appId}`;
941
- this.clientSessionId = options.clientSessionId;
942
- }
943
- storage() {
944
- const storage = this.options.storage;
945
- return storage === void 0 ? globalThis.sessionStorage : Predicate.isFunction(storage) ? storage() : storage;
946
- }
947
- now() {
948
- return this.options.now?.() ?? DateTime.toEpochMillis(DateTime.nowUnsafe());
949
- }
950
- snapshot(entries, issues) {
951
- return {
952
- clientSessionId: this.clientSessionId,
953
- entries,
954
- issues
955
- };
956
- }
957
- read() {
958
- let raw;
959
- try {
960
- raw = this.storage().getItem(this.storageKey);
961
- } catch {
962
- return this.snapshot([], ["denied"]);
963
- }
964
- if (raw === null) return this.snapshot([], []);
965
- if (bytes(raw) > RecoveryJournalLimits.maxBytes) return this.discard("full");
966
- const parsed = Schema.decodeUnknownOption(Schema.fromJsonString(RecoveryJournalRecord))(raw);
967
- if (parsed._tag === "None" || parsed.value.appId !== this.options.appId) return this.discard("corrupt");
968
- if (parsed.value.sessionEpoch !== this.options.sessionEpoch) return this.discard("session-changed");
969
- this.clientSessionId = parsed.value.clientSessionId;
970
- const now = this.now();
971
- const entries = parsed.value.entries.filter((entry) => entry.expiresAt > now && entry.recordedAt <= now);
972
- const issues = entries.length === parsed.value.entries.length ? [] : ["expired"];
973
- return issues.length === 0 ? this.snapshot(entries, issues) : this.persist(entries, issues);
974
- }
975
- discard(issue) {
976
- try {
977
- this.storage().removeItem(this.storageKey);
978
- return this.snapshot([], [issue]);
979
- } catch {
980
- return this.snapshot([], [issue, "denied"]);
981
- }
982
- }
983
- persist(entries, issues) {
984
- const record = {
985
- formatVersion: 1,
986
- appId: this.options.appId,
987
- sessionEpoch: this.options.sessionEpoch,
988
- clientSessionId: this.clientSessionId,
989
- entries
990
- };
991
- const encoded = Schema.encodeOption(Schema.fromJsonString(RecoveryJournalRecord))(record);
992
- if (encoded._tag === "None") return this.snapshot(entries, [...issues, "corrupt"]);
993
- if (bytes(encoded.value) > RecoveryJournalLimits.maxBytes) return this.snapshot(entries, [...issues, "full"]);
994
- try {
995
- this.storage().setItem(this.storageKey, encoded.value);
996
- return this.snapshot(entries, issues);
997
- } catch (error) {
998
- return this.snapshot(entries, [...issues, error instanceof DOMException && error.name === "QuotaExceededError" ? "full" : "denied"]);
999
- }
1000
- }
1001
- /** Call before abandoning the page; any issue means durable recovery is not proven. */
1002
- write(identities) {
1003
- const current = this.read();
1004
- if (current.issues.includes("denied")) return current;
1005
- const entries = new Map(current.entries.map((entry) => [identityKey(entry.identity), entry]));
1006
- const now = this.now();
1007
- for (const identity of identities) {
1008
- if (identity.originalSelection.appId !== this.options.appId) return this.snapshot(current.entries, [...current.issues, "corrupt"]);
1009
- const key = identityKey(identity);
1010
- if (!entries.has(key)) entries.set(key, {
1011
- identity: {
1012
- invocationId: identity.invocationId,
1013
- originalSelection: identity.originalSelection
1014
- },
1015
- recordedAt: now,
1016
- expiresAt: now + RecoveryJournalLimits.retentionMs,
1017
- state: "pending"
1018
- });
1019
- }
1020
- if (entries.size > RecoveryJournalLimits.maxEntries) return this.snapshot(current.entries, [...current.issues, "full"]);
1021
- return this.persist([...entries.values()], current.issues);
1022
- }
1023
- reconcile(identity, state) {
1024
- const current = this.read();
1025
- if (current.issues.includes("denied")) return current;
1026
- return this.persist(current.entries.map((entry) => identityKey(entry.identity) === identityKey(identity) ? {
1027
- ...entry,
1028
- state
1029
- } : entry), current.issues);
1030
- }
1031
- remove(identity) {
1032
- const current = this.read();
1033
- if (current.issues.includes("denied")) return current;
1034
- return this.persist(current.entries.filter((entry) => identityKey(entry.identity) !== identityKey(identity)), current.issues);
1035
- }
1036
- clear() {
1037
- try {
1038
- this.storage().removeItem(this.storageKey);
1039
- return this.snapshot([], []);
1040
- } catch {
1041
- return this.snapshot([], ["denied"]);
1042
- }
1043
- }
893
+ invocationId: InvocationId,
894
+ acknowledgedAt: Schema.Int,
895
+ dataHistoryId: DataHistoryId
896
+ });
897
+ Schema.Struct({ completed: Schema.Literal(true) });
898
+ const RuntimeMutationSuccess = Schema.Struct({
899
+ type: Schema.Literal("Mutation"),
900
+ result: WireSuccess,
901
+ invalidations: InvalidationSet,
902
+ committedRevision: AppStateRevision,
903
+ fileEffects: Schema.optional(FileEffectBatch)
904
+ });
905
+ const RuntimeMutationFailure = Schema.Struct({
906
+ type: Schema.Literal("Mutation"),
907
+ result: WireFailure
908
+ });
909
+ const RuntimeMutationResult = Schema.Union([RuntimeMutationSuccess, RuntimeMutationFailure]);
910
+ Schema.Union([RuntimeQueryResult, RuntimeMutationResult]);
911
+ const RuntimeRecoveryOwner = Schema.Struct({
912
+ clientSessionId: RecoverySessionId,
913
+ sessionEpoch: Schema.NullOr(Schema.String)
914
+ });
915
+ Schema.Struct({
916
+ appId: AppId,
917
+ identity: RecoveryIdentity,
918
+ owner: RuntimeRecoveryOwner
919
+ });
920
+ const RuntimeMutationOutcome = Schema.Union([
921
+ Schema.Struct({
922
+ type: Schema.Literal("Settled"),
923
+ result: RuntimeMutationResult
924
+ }),
925
+ Schema.Struct({ type: Schema.Literal("Interrupted") }),
926
+ Schema.Struct({ type: Schema.Literal("Pending") }),
927
+ Schema.Struct({ type: Schema.Literal("Uncertain") })
928
+ ]);
929
+ const InvocationBase = {
930
+ appId: AppId,
931
+ versionId: VersionId,
932
+ generation: ActivationGeneration,
933
+ selection: Schema.optional(ServingSelection),
934
+ invocationKey: InvocationKey,
935
+ function: FunctionAddress,
936
+ args: Schema.Json,
937
+ identity: Schema.optional(SessionState)
1044
938
  };
939
+ const QueryInvocation = Schema.Struct({
940
+ ...InvocationBase,
941
+ type: Schema.Literal("Query")
942
+ });
943
+ const MutationInvocation = Schema.Struct({
944
+ ...InvocationBase,
945
+ type: Schema.Literal("Mutation"),
946
+ invocationId: InvocationId,
947
+ recoveryOwner: Schema.optional(RuntimeRecoveryOwner),
948
+ files: Schema.optional(Schema.Array(RuntimeFileOccurrence))
949
+ });
950
+ Schema.Union([QueryInvocation, MutationInvocation]);
951
+ Schema.Struct({
952
+ appId: AppId,
953
+ expectedRevision: AppStateRevision
954
+ });
955
+ Schema.Struct({ currentRevision: AppStateRevision });
956
+ var RuntimeVersionUnavailable = class extends Schema.TaggedError()("RuntimeVersionUnavailable", {
957
+ versionId: VersionId,
958
+ message: Schema.String
959
+ }) {};
960
+ const RuntimeInvocationRejectionCode = Schema.Literals([
961
+ "SessionExpired",
962
+ "FunctionUnavailable",
963
+ "InvalidArguments",
964
+ "InvocationIdConflict",
965
+ "ResourceLimitExceeded",
966
+ "UnknownFunction",
967
+ "WrongFunctionKind"
968
+ ]);
969
+ var RuntimeInvocationRejected = class extends Schema.TaggedError()("RuntimeInvocationRejected", {
970
+ code: RuntimeInvocationRejectionCode,
971
+ invocationKey: InvocationKey,
972
+ message: Schema.String
973
+ }) {};
974
+ var RuntimeInvocationUnavailable = class extends Schema.TaggedError()("RuntimeInvocationUnavailable", {
975
+ invocationKey: InvocationKey,
976
+ message: Schema.String
977
+ }) {};
978
+ Schema.TaggedError()("RuntimeRevisionRejected", {
979
+ appId: AppId,
980
+ message: Schema.String
981
+ });
982
+ Schema.Union([
983
+ RuntimeVersionUnavailable,
984
+ RuntimeInvocationRejected,
985
+ RuntimeInvocationUnavailable
986
+ ]);
987
+ //#endregion
988
+ //#region ../contracts/dist/managed-sync.js
989
+ const platformRevision = {
990
+ major: 1,
991
+ minor: 0
992
+ };
993
+ const managedSyncPath = endpointUrl(platformRevision, "sync");
994
+ const managedSelectionPath = endpointUrl(platformRevision, "selection");
995
+ const ManagedSelectionResponse = Schema.Struct({
996
+ protocolVersion: Schema.Literal(1),
997
+ selection: ServingSelection
998
+ });
999
+ const ManagedClientMessage = Schema.Union([
1000
+ Schema.Struct({
1001
+ type: Schema.Literal("Connect"),
1002
+ protocolVersion: Schema.Natural,
1003
+ selection: ServingSelection,
1004
+ clientSessionId: RecoverySessionId
1005
+ }),
1006
+ Schema.Struct({
1007
+ type: Schema.Literal("Prepare"),
1008
+ invocationId: InvocationId,
1009
+ function: FunctionAddress,
1010
+ args: Schema.Json,
1011
+ files: Schema.Array(FileId).check(Schema.isMaxLength(fileLimits.filesPerMutation))
1012
+ }),
1013
+ Schema.Struct({
1014
+ type: Schema.Literal("Invoke"),
1015
+ invocationId: InvocationId,
1016
+ function: FunctionAddress,
1017
+ args: Schema.Json
1018
+ }),
1019
+ Schema.Struct({
1020
+ type: Schema.Literal("RecoverMutation"),
1021
+ id: Schema.String.check(Schema.isMaxLength(128)),
1022
+ identity: RecoveryIdentity
1023
+ }),
1024
+ Schema.Struct({
1025
+ type: Schema.Literal("Subscribe"),
1026
+ id: SubscriptionId,
1027
+ function: FunctionAddress,
1028
+ args: Schema.Json
1029
+ }),
1030
+ Schema.Struct({
1031
+ type: Schema.Literal("Unsubscribe"),
1032
+ id: SubscriptionId
1033
+ })
1034
+ ]);
1035
+ /** Decode this envelope before the normal server protocol, including on unsupported versions. */
1036
+ const ManagedUpgradeRequired = Schema.Struct({
1037
+ type: Schema.Literal("UpgradeRequired"),
1038
+ selection: ServingSelection
1039
+ });
1040
+ const ManagedServerMessage = Schema.Union([
1041
+ ManagedUpgradeRequired,
1042
+ Schema.Struct({
1043
+ type: Schema.Literal("Handshake"),
1044
+ protocolVersion: Schema.Literal(1),
1045
+ selection: ServingSelection,
1046
+ session: SessionState,
1047
+ serverTime: Schema.Finite
1048
+ }),
1049
+ Schema.Struct({
1050
+ type: Schema.Literal("Preparation"),
1051
+ invocationId: InvocationId,
1052
+ uploads: Schema.Array(Schema.Struct({
1053
+ id: FileId,
1054
+ url: Schema.optional(Schema.String)
1055
+ }))
1056
+ }),
1057
+ Schema.Struct({
1058
+ type: Schema.Literal("MutationOutcome"),
1059
+ id: Schema.String,
1060
+ identity: RecoveryIdentity,
1061
+ outcome: RuntimeMutationOutcome
1062
+ }),
1063
+ Schema.Struct({
1064
+ type: Schema.Literal("QuerySnapshot"),
1065
+ selection: ServingSelection,
1066
+ id: SubscriptionId,
1067
+ result: RuntimeQueryResult,
1068
+ files: Schema.optional(Schema.Array(Schema.Struct({
1069
+ id: FileId,
1070
+ url: Schema.String
1071
+ })))
1072
+ }),
1073
+ Schema.Struct({
1074
+ type: Schema.Literal("Error"),
1075
+ id: Schema.optional(Schema.String),
1076
+ code: Schema.Literals([
1077
+ "PlatformUpgrading",
1078
+ "SessionExpired",
1079
+ "InvalidMessage",
1080
+ "Unavailable",
1081
+ "InvalidArguments",
1082
+ "InvocationIdConflict",
1083
+ "ResourceLimitExceeded"
1084
+ ]),
1085
+ message: Schema.String
1086
+ })
1087
+ ]);
1045
1088
  //#endregion
1046
- //#region src/client/managed-client.ts
1089
+ //#region ../platform/dist/versions/1/browser/managed-client.js
1047
1090
  const issueMessage = (issue) => {
1048
1091
  switch (issue) {
1049
1092
  case "denied": return "Browser storage is unavailable. Some previous mutation outcomes may be unknown.";
@@ -1249,7 +1292,7 @@ var ManagedBrowserClient = class {
1249
1292
  return;
1250
1293
  }
1251
1294
  if (message.type === "Handshake") {
1252
- if (!sameExecutionSelection(this.selection, message.selection)) {
1295
+ if (!sameSelection(this.selection, message.selection)) {
1253
1296
  this.upgrade.require(message.selection);
1254
1297
  return;
1255
1298
  }
@@ -1322,7 +1365,7 @@ var ManagedBrowserClient = class {
1322
1365
  }
1323
1366
  case "QuerySnapshot": {
1324
1367
  if (!this.canSend()) return;
1325
- if (!sameExecutionSelection(this.selection, message.selection)) {
1368
+ if (!sameSelection(this.selection, message.selection)) {
1326
1369
  this.upgrade.require(message.selection);
1327
1370
  return;
1328
1371
  }
@@ -1331,7 +1374,7 @@ var ManagedBrowserClient = class {
1331
1374
  return;
1332
1375
  }
1333
1376
  case "MutationOutcome":
1334
- if (!sameExecutionSelection(message.identity.originalSelection, this.selection) && !this.recovery.has(message.id)) return;
1377
+ if (!sameSelection(message.identity.originalSelection, this.selection) && !this.recovery.has(message.id)) return;
1335
1378
  this.outcome(message.id, message.identity, message.outcome);
1336
1379
  return;
1337
1380
  case "Error":
@@ -1405,7 +1448,7 @@ var ManagedBrowserClient = class {
1405
1448
  const pending = this.pending.get(identity.invocationId);
1406
1449
  if (recovery === void 0 && pending === void 0) return;
1407
1450
  const expected = recovery ?? pending.identity;
1408
- if (expected.invocationId !== identity.invocationId || !sameExecutionSelection(expected.originalSelection, identity.originalSelection)) return;
1451
+ if (expected.invocationId !== identity.invocationId || !sameSelection(expected.originalSelection, identity.originalSelection)) return;
1409
1452
  this.recovery.delete(id);
1410
1453
  const timeout = this.recoveryTimeouts.get(id);
1411
1454
  if (timeout !== void 0) {
@@ -1575,7 +1618,7 @@ var ManagedBrowserClient = class {
1575
1618
  }
1576
1619
  };
1577
1620
  //#endregion
1578
- //#region src/client/sync.ts
1621
+ //#region ../platform/dist/versions/1/browser/sync.js
1579
1622
  const queryKey = (functionAddress, args) => encodeCanonicalJson([functionAddress, args]);
1580
1623
  const subscribeMessage = (entry) => ({
1581
1624
  type: "Subscribe",
@@ -2170,7 +2213,7 @@ const buildUrl = Effect.fn("Routing.buildUrl")(function* (input, values = {}) {
2170
2213
  return `/${segments.join("/")}${search === "" ? "" : `?${search}`}${hash}`;
2171
2214
  });
2172
2215
  //#endregion
2173
- //#region src/client/router.ts
2216
+ //#region ../platform/dist/versions/1/browser/router.js
2174
2217
  const RouterContext = createContext(void 0);
2175
2218
  const useRouter = () => {
2176
2219
  const router = useContext(RouterContext);
@@ -2374,4 +2417,4 @@ function Redirect(props) {
2374
2417
  //#endregion
2375
2418
  export { Files as C, BrowserSession as S, matchPattern as _, url as a, syncClientInternals as b, useMatch as c, useRoute as d, useRouterSnapshot as f, matchDirectory as g, compilePatterns as h, RouterContext as i, useNavigate as l, parseLocation as m, NavLink as n, useBlocker as o, decodeRouteInputs as p, Redirect as r, useLocation as s, Link as t, useNavigation as u, SyncClient as v, ClientInfrastructureError as w, syncRuntime as x, mountManagedSync as y };
2376
2419
 
2377
- //# sourceMappingURL=router-BSBI1oN1.js.map
2420
+ //# sourceMappingURL=router-C1eC9yy5.js.map