@inflatable-cookie/longhorn 0.6.0 → 0.7.0

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 (133) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -7
  3. package/src/agent-control/generated/protocol.ts +228 -0
  4. package/src/agent-control/index.ts +1 -5
  5. package/src/agent-control/selection.ts +10 -8
  6. package/src/agent-control/shim.ts +149 -77
  7. package/src/bridge/generated/fields.ts +1 -1
  8. package/src/bridge/generated/protocol.ts +55 -4
  9. package/src/bridge/generated/variant-fields.ts +1 -1
  10. package/src/bridge/job.ts +49 -2
  11. package/src/bridge/runtime/connection.ts +11 -14
  12. package/src/bridge/stream/connection.ts +14 -23
  13. package/src/bridge/stream/tracker.ts +5 -0
  14. package/src/bridge/supervision.ts +102 -80
  15. package/src/bridge/validation/base.ts +7 -27
  16. package/src/bridge/validation/negotiation.ts +1 -6
  17. package/src/bridge/validation/operations.ts +2 -14
  18. package/src/commands/client.ts +16 -2
  19. package/src/commands/controller.ts +96 -58
  20. package/src/commands/generated/fields.ts +4 -4
  21. package/src/commands/generated/protocol.ts +24 -1
  22. package/src/commands/generated/variant-fields.ts +1 -1
  23. package/src/commands/keyboard.ts +4 -13
  24. package/src/commands/physical-code.ts +11 -0
  25. package/src/commands/ports.ts +2 -1
  26. package/src/commands/projectors.ts +52 -29
  27. package/src/commands/validation.ts +408 -188
  28. package/src/config/client.ts +3 -3
  29. package/src/config/generated/base.ts +22 -6
  30. package/src/config/generated/fields.ts +2 -1
  31. package/src/config/generated/label-template.ts +1 -1
  32. package/src/config/generated/labels.ts +1 -1
  33. package/src/config/generated/protocol.ts +1 -1
  34. package/src/config/generated/restore.ts +35 -12
  35. package/src/config/generated/variant-fields.ts +1 -1
  36. package/src/config/validation/commands.ts +11 -13
  37. package/src/config/validation/outcomes.ts +147 -46
  38. package/src/config/validation/primitives.ts +11 -39
  39. package/src/config/validation/projection.ts +44 -44
  40. package/src/core/connection.ts +124 -29
  41. package/src/core/controller-lifecycle.ts +144 -0
  42. package/src/core/generated/identifiers.ts +4 -0
  43. package/src/core/identifiers.ts +40 -0
  44. package/src/core/index.ts +10 -1
  45. package/src/core/json-value.ts +58 -0
  46. package/src/core/listeners.ts +35 -0
  47. package/src/core/record.ts +76 -0
  48. package/src/core/transport.ts +10 -1
  49. package/src/core/wire-copy.ts +1 -0
  50. package/src/history/client.ts +11 -7
  51. package/src/history/controller.ts +72 -74
  52. package/src/history/generated/fields.ts +2 -1
  53. package/src/history/generated/protocol.ts +8 -5
  54. package/src/history/generated/variant-fields.ts +1 -1
  55. package/src/history/ports.ts +7 -2
  56. package/src/history/validation.ts +15 -37
  57. package/src/history-tree/client.ts +15 -13
  58. package/src/history-tree/controller.ts +131 -90
  59. package/src/history-tree/generated/fields.ts +3 -1
  60. package/src/history-tree/generated/protocol.ts +43 -7
  61. package/src/history-tree/generated/variant-fields.ts +7 -1
  62. package/src/history-tree/ports.ts +9 -4
  63. package/src/history-tree/validation.ts +44 -35
  64. package/src/layout/generated/protocol.ts +2 -1
  65. package/src/layout/generated/variant-fields.ts +47 -0
  66. package/src/layout/index.ts +1 -1
  67. package/src/layout/ratio.ts +9 -2
  68. package/src/layout/validation.ts +88 -13
  69. package/src/licence/client.ts +11 -7
  70. package/src/licence/controller.ts +64 -43
  71. package/src/licence/generated/fields.ts +2 -1
  72. package/src/licence/generated/protocol.ts +8 -4
  73. package/src/licence/generated/variant-fields.ts +1 -1
  74. package/src/licence/key.ts +2 -6
  75. package/src/licence/ports.ts +7 -2
  76. package/src/licence/validation.ts +27 -20
  77. package/src/native-content/client.ts +32 -1
  78. package/src/native-content/generated/fields.ts +4 -4
  79. package/src/native-content/generated/protocol.ts +16 -5
  80. package/src/native-content/generated/variant-fields.ts +1 -1
  81. package/src/native-content/ports.ts +2 -1
  82. package/src/native-content/validation/base.ts +16 -46
  83. package/src/native-content/validation/messages.ts +3 -0
  84. package/src/notifications/client.ts +17 -39
  85. package/src/notifications/controller.ts +266 -165
  86. package/src/notifications/generated/fields.ts +2 -1
  87. package/src/notifications/generated/labels.ts +1 -1
  88. package/src/notifications/generated/protocol.ts +5 -1
  89. package/src/notifications/generated/variant-fields.ts +1 -1
  90. package/src/notifications/ports.ts +2 -1
  91. package/src/notifications/tone.ts +1 -1
  92. package/src/notifications/validation.ts +41 -51
  93. package/src/operation/bridge.ts +79 -19
  94. package/src/operation/client.ts +17 -45
  95. package/src/operation/controller.ts +38 -59
  96. package/src/operation/generated/fields.ts +2 -1
  97. package/src/operation/generated/labels.ts +1 -1
  98. package/src/operation/generated/protocol.ts +5 -1
  99. package/src/operation/generated/variant-fields.ts +1 -1
  100. package/src/operation/ports.ts +2 -1
  101. package/src/operation/validation.ts +48 -50
  102. package/src/settings/connection.ts +10 -14
  103. package/src/settings/generated/fields.ts +2 -1
  104. package/src/settings/generated/protocol.ts +5 -1
  105. package/src/settings/generated/variant-fields.ts +1 -1
  106. package/src/settings/validation/authority.ts +2 -2
  107. package/src/settings/validation/command.ts +5 -4
  108. package/src/settings/validation/primitives.ts +32 -67
  109. package/src/settings/validation/registry.ts +13 -11
  110. package/src/surface-transfer/generated/fields.ts +1 -1
  111. package/src/surface-transfer/generated/protocol.ts +3 -3
  112. package/src/surface-transfer/generated/variant-fields.ts +1 -1
  113. package/src/surface-transfer/validation.ts +76 -53
  114. package/src/surfaces/client.ts +26 -38
  115. package/src/surfaces/generated/fields.ts +1 -1
  116. package/src/surfaces/generated/protocol.ts +1 -1
  117. package/src/surfaces/generated/variant-fields.ts +1 -1
  118. package/src/surfaces/validation.ts +198 -61
  119. package/src/transfer/connection.ts +25 -39
  120. package/src/transfer/generated/fields.ts +2 -1
  121. package/src/transfer/generated/protocol.ts +9 -1
  122. package/src/transfer/generated/variant-fields.ts +1 -1
  123. package/src/transfer/index.ts +8 -1
  124. package/src/transfer/payload.ts +12 -9
  125. package/src/transfer/validation.ts +146 -60
  126. package/src/update/client.ts +43 -16
  127. package/src/update/controller.ts +187 -104
  128. package/src/update/generated/fields.ts +2 -1
  129. package/src/update/generated/protocol.ts +19 -7
  130. package/src/update/generated/variant-fields.ts +3 -2
  131. package/src/update/ports.ts +11 -7
  132. package/src/update/serialized.ts +8 -6
  133. package/src/update/validation.ts +18 -28
@@ -1,4 +1,4 @@
1
- import type { EventTransport } from "@inflatable-cookie/longhorn/core";
1
+ import type { InvokeTransport } from "@inflatable-cookie/longhorn/core";
2
2
 
3
3
  import type {
4
4
  BackupCreateCommand,
@@ -73,9 +73,9 @@ import {
73
73
  } from "./names.ts";
74
74
 
75
75
  export class ConfigOperationsClient {
76
- readonly #transport: EventTransport;
76
+ readonly #transport: InvokeTransport;
77
77
 
78
- constructor(transport: EventTransport) {
78
+ constructor(transport: InvokeTransport) {
79
79
  this.#transport = transport;
80
80
  }
81
81
 
@@ -1,11 +1,16 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Rust serde types are the wire authority.
3
3
  import type { RestoreOperationsProjection } from "./restore.ts";
4
4
 
5
5
  export const CONFIG_OPERATIONS_PROTOCOL_VERSION = 1 as const;
6
- export const CONFIG_MAXIMUM_OPAQUE_ID_BYTES = 128 as const;
7
6
  export const CONFIG_OPERATION_CAPABILITIES = ["storageDiagnostics","storageTransition","backupInventory","backupCreate","backupExport","backupRetention","backupEncryption","restoreInspection","restoreExecution","restoreAdapterExecution","restoreRecovery"] as const;
8
7
  export const CONFIG_OPERATION_REJECTION_CODES = ["unauthorized","unsupported","authorityChanged","confirmationMismatch","transitionActive","recoveryRequired","conflicts","pendingPublication","selectionCancelled","archiveChanged","archiveCorrupt","archiveFutureVersion","identityMismatch","restorePlanStale","restoreActive","restoreAdapterChanged","incompleteInventory","encryptionInteractionRequired","policyBlocked"] as const;
8
+ export const STORAGE_PROFILE_IDS = ["platform-native-v1","unified-app-root-v1","shared-product-root-v1","portable-v1"] as const;
9
+ export const STORAGE_LEAF_PROVENANCES = ["canonicalApplicationId","stableStorageName"] as const;
10
+ export const BACKUP_KINDS = ["operational","user-export","pre-migration","pre-restore"] as const;
11
+ export const STORAGE_CLASSES = ["defaults","policy","user-config","machine-state","workspace-local","project-shared","secret","cache","runtime","log"] as const;
12
+ export const BACKUP_INVENTORY_ENTRY_STATES = ["valid","locked","corrupt","foreign","unknown","unreadable","unmanaged"] as const;
13
+ export const BACKUP_PENDING_POLICIES = ["refuse","flush"] as const;
9
14
  export const STORAGE_BOOTSTRAP_STATES = ["selected","recoveryRequired"] as const;
10
15
  export const BACKUP_PENDING_STATES = ["clear","pending"] as const;
11
16
  export const BACKUP_ENCRYPTION_STATES = ["unavailable","available","interactionRequired","failed"] as const;
@@ -15,6 +20,7 @@ export const STORAGE_RECOVERY_STATUSES = ["recovered","rejected"] as const;
15
20
  export const STORAGE_CLEANUP_STATUSES = ["applied","rejected"] as const;
16
21
  export const BACKUP_CREATE_STATUSES = ["published","rejected"] as const;
17
22
  export const BACKUP_EXPORT_STATUSES = ["published","rejected"] as const;
23
+ export const BACKUP_PUBLICATION_DURABILITIES = ["fileSynced","fileAndDirectorySynced","portableFileAndDirectorySynced"] as const;
18
24
  export const BACKUP_RETENTION_APPLY_STATUSES = ["applied","rejected"] as const;
19
25
 
20
26
  export type ConfigProtocolVersion = number;
@@ -125,6 +131,8 @@ bootstrap: StorageBootstrapProjection,
125
131
  */
126
132
  availableProfiles: Array<StorageProfileId>, };
127
133
 
134
+ export type StorageClass = "defaults" | "policy" | "user-config" | "machine-state" | "workspace-local" | "project-shared" | "secret" | "cache" | "runtime" | "log";
135
+
128
136
  export type StorageTransitionDomainProjection = {
129
137
  /**
130
138
  * Stable configuration domain id.
@@ -133,7 +141,7 @@ domainId: string,
133
141
  /**
134
142
  * Storage lifecycle class.
135
143
  */
136
- storageClass: string,
144
+ storageClass: StorageClass,
137
145
  /**
138
146
  * Planned action.
139
147
  */
@@ -261,6 +269,8 @@ transitionReceiptDigest: string,
261
269
  */
262
270
  removedPaths: Array<string>, };
263
271
 
272
+ export type BackupKind = "operational" | "user-export" | "pre-migration" | "pre-restore";
273
+
264
274
  export type BackupArchiveProjection = {
265
275
  /**
266
276
  * Exact root-level archive path.
@@ -277,7 +287,7 @@ createdAt: string,
277
287
  /**
278
288
  * Backup kind.
279
289
  */
280
- kind: string,
290
+ kind: BackupKind,
281
291
  /**
282
292
  * Digest over exact published archive bytes.
283
293
  */
@@ -645,6 +655,8 @@ totalPayloadBytes: number,
645
655
  */
646
656
  flushedPendingPublication: boolean, };
647
657
 
658
+ export type BackupPublicationDurability = "fileSynced" | "fileAndDirectorySynced" | "portableFileAndDirectorySynced";
659
+
648
660
  export type BackupPublicationReceiptProjection = {
649
661
  /**
650
662
  * Exact published path.
@@ -659,9 +671,9 @@ destination: string,
659
671
  */
660
672
  archiveSha256: string,
661
673
  /**
662
- * Established durability level.
674
+ * Established visibility and filesystem durability.
663
675
  */
664
- durability: string,
676
+ durability: BackupPublicationDurability,
665
677
  /**
666
678
  * Whether an authorized export was replaced.
667
679
  */
@@ -712,3 +724,7 @@ snapshot: ConfigOperationsSnapshot, } | { "status": "rejected",
712
724
  * Typed refusal.
713
725
  */
714
726
  rejection: ConfigOperationRejection, };
727
+
728
+ export type ConfigOperationsHostErrorCode = "authorityUnavailable" | "stateUnavailable" | "hostInteraction";
729
+
730
+ export type ConfigOperationsHostError = { "code": ConfigOperationsHostErrorCode, "message": string, "retryable": boolean, };
@@ -1,4 +1,4 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Allowed field names per protocol type, from the Rust structs.
3
3
  // A `record()` given one of these rejects unknown and missing keys —
4
4
  // contract 010's Boundary Validation Target.
@@ -30,6 +30,7 @@ export const CONFIG_FIELDS = {
30
30
  "ConfigOperationRejection": ["code", "detail", "snapshot"],
31
31
  "BackupCaptureReceiptProjection": ["selectedDomains", "capturedDomains", "absentDomains", "sourcePreservedDomains", "excludedDomains", "customDomains", "externalConsistencyGroups", "totalPayloadBytes", "flushedPendingPublication"],
32
32
  "BackupPublicationReceiptProjection": ["path", "destination", "archiveSha256", "durability", "replacedExisting"],
33
+ "ConfigOperationsHostError": ["code", "message", "retryable"],
33
34
  "RestoreOperationsProjection": ["state", "safetyBackupSha256"],
34
35
  "RestoreIdentityProjection": ["application", "producer"],
35
36
  "RestoreConsistencyGroupProjection": ["id", "mode", "authority"],
@@ -1,4 +1,4 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Mirrors `longhorn_config::render_label_template`. One substitution rule: a
3
3
  // placeholder is a name in braces, and anything else is literal. An unknown
4
4
  // placeholder is left as written, so a mistake shows as `{typo}` on screen
@@ -1,4 +1,4 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Wording lives in Rust, on the enum that owns it. A label edited here is
3
3
  // a label that disagrees with the native surface.
4
4
 
@@ -1,3 +1,3 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  export * from "./base.ts";
3
3
  export * from "./restore.ts";
@@ -1,7 +1,14 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Rust serde types are the wire authority.
3
- import type { BackupPublicationReceiptProjection, ConfigGeneration, ConfigOperationRejection, ConfigOperationsSnapshot, ConfigProtocolVersion, ConfigRequestId } from "./base.ts";
4
-
3
+ import type { BackupPublicationReceiptProjection, ConfigGeneration, ConfigOperationRejection, ConfigOperationsSnapshot, ConfigProtocolVersion, ConfigRequestId, BackupKind, StorageClass } from "./base.ts";
4
+
5
+ export const BACKUP_CONSISTENCY_MODES = ["coordinated-bounded","external-snapshot"] as const;
6
+ export const BACKUP_SOURCE_STATES = ["present","absent","source-preserved"] as const;
7
+ export const RESTORE_INTEGRITY_VALUES = ["verified"] as const;
8
+ export const RESTORE_AUTHENTICITY_VALUES = ["unauthenticated","authenticated"] as const;
9
+ export const RESTORE_CONFLICT_CHOICES = ["useArchive","keepCurrent"] as const;
10
+ export const RESTORE_OPERATION_STATES = ["inactive","active","recoveryRequired"] as const;
11
+ export const RESTORE_ADAPTER_REQUIREMENTS = ["failureAtomic","allowSeparate"] as const;
5
12
  export const RESTORE_ARCHIVE_SELECTION_SOURCES = ["inventory","hostPicker"] as const;
6
13
  export const RESTORE_IDENTITY_STATUSES = ["compatible","mismatch"] as const;
7
14
  export const RESTORE_DOMAIN_COMPATIBILITY_STATUSES = ["ready","migrationRequired","unknownDomain","descriptorMismatch","domainCodeUnavailable","policyExcluded","customAdapterUnavailable","customAdapterReady","customAdapterRejected","targetUnavailable","sourcePreserved","sourceRejected","targetPreparationFailed"] as const;
@@ -9,6 +16,10 @@ export const RESTORE_ADAPTER_PARTICIPATION_KINDS = ["excluded","separate","failu
9
16
  export const RESTORE_CURRENT_EVIDENCE_STATES = ["absent","present"] as const;
10
17
  export const RESTORE_INSPECT_STATUSES = ["ready","locked","rejected"] as const;
11
18
  export const RESTORE_PLAN_STATUSES = ["ready","rejected"] as const;
19
+ export const RESTORE_EXECUTION_STAGES = ["validateSafetyBackup","recoverPrevious","recheckCurrent","captureRollback","captureSafetyBackup","encodeSafetyBackup","publishSafetyBackup","publishJournal","publishTarget","verifyTarget","rollback","cleanup"] as const;
20
+ export const RESTORE_FAILURE_TERMINALS = ["noLiveMutation","rolledBack","recoveryRequired"] as const;
21
+ export const RESTORE_ADAPTER_OUTCOMES = ["verified","rolledBack","recoveryRequired"] as const;
22
+ export const RESTORE_RECOVERY_RESULTS = ["noRecoveryNeeded","rolledBack","terminalCleanup"] as const;
12
23
  export const RESTORE_EXECUTE_STATUSES = ["succeeded","rolledBack","recoveryRequired","rejected"] as const;
13
24
  export const RESTORE_ADAPTER_EXECUTE_STATUSES = ["completed","rejected"] as const;
14
25
  export const RESTORE_RECOVERY_STATUSES = ["recovered","recoveryRequired","rejected"] as const;
@@ -55,6 +66,8 @@ application: RestoreIdentityStatusProjection,
55
66
  */
56
67
  producer: RestoreIdentityStatusProjection, };
57
68
 
69
+ export type BackupConsistencyMode = "coordinated-bounded" | "external-snapshot";
70
+
58
71
  export type RestoreConsistencyGroupProjection = {
59
72
  /**
60
73
  * Stable group id.
@@ -63,7 +76,7 @@ id: string,
63
76
  /**
64
77
  * Coordinated-bounded or external-snapshot mode.
65
78
  */
66
- mode: string,
79
+ mode: BackupConsistencyMode,
67
80
  /**
68
81
  * Declared transaction authority.
69
82
  */
@@ -129,6 +142,8 @@ export type RestoreAdapterParticipationProjection = { "kind": "excluded",
129
142
  */
130
143
  reason: string, } | { "kind": "separate" } | { "kind": "failureAtomic" } | { "kind": "groupedFailureAtomic" };
131
144
 
145
+ export type BackupSourceState = "present" | "absent" | "source-preserved";
146
+
132
147
  export type RestoreDomainInspectionProjection = {
133
148
  /**
134
149
  * Stable domain id.
@@ -137,7 +152,7 @@ domainId: string,
137
152
  /**
138
153
  * Manifest storage class.
139
154
  */
140
- storageClass: string,
155
+ storageClass: StorageClass,
141
156
  /**
142
157
  * Manifest consistency group.
143
158
  */
@@ -149,7 +164,7 @@ adapter: string,
149
164
  /**
150
165
  * Present, absent, or source-preserved state.
151
166
  */
152
- sourceState: string,
167
+ sourceState: BackupSourceState,
153
168
  /**
154
169
  * Archive source schema when readable.
155
170
  */
@@ -171,7 +186,7 @@ domainId: string,
171
186
  /**
172
187
  * Manifest storage class.
173
188
  */
174
- storageClass: string,
189
+ storageClass: StorageClass,
175
190
  /**
176
191
  * Stable manifest reason.
177
192
  */
@@ -223,7 +238,7 @@ createdAt: string,
223
238
  /**
224
239
  * Archive purpose.
225
240
  */
226
- kind: string,
241
+ kind: BackupKind,
227
242
  /**
228
243
  * Producing application version.
229
244
  */
@@ -495,11 +510,15 @@ skippedDomainIds: Array<string>,
495
510
  */
496
511
  excludedDomainIds: Array<string>, };
497
512
 
513
+ export type RestoreExecutionStageProjection = "validateSafetyBackup" | "recoverPrevious" | "recheckCurrent" | "captureRollback" | "captureSafetyBackup" | "encodeSafetyBackup" | "publishSafetyBackup" | "publishJournal" | "publishTarget" | "verifyTarget" | "rollback" | "cleanup";
514
+
515
+ export type RestoreFailureTerminalProjection = "noLiveMutation" | "rolledBack" | "recoveryRequired";
516
+
498
517
  export type RestoreExecutionFailureProjection = {
499
518
  /**
500
519
  * Failed journaled transaction phase.
501
520
  */
502
- stage: string,
521
+ stage: RestoreExecutionStageProjection,
503
522
  /**
504
523
  * First affected domain when known.
505
524
  */
@@ -507,7 +526,7 @@ domainId: string | null,
507
526
  /**
508
527
  * Exact terminal guarantee established before return.
509
528
  */
510
- terminal: string,
529
+ terminal: RestoreFailureTerminalProjection,
511
530
  /**
512
531
  * Safe failure detail.
513
532
  */
@@ -575,6 +594,8 @@ confirmationDigest: string,
575
594
  */
576
595
  requirement: RestoreAdapterRequirementProjection, };
577
596
 
597
+ export type RestoreAdapterOutcomeProjection = "verified" | "rolledBack" | "recoveryRequired";
598
+
578
599
  export type RestoreAdapterReceiptProjection = {
579
600
  /**
580
601
  * Restored custom domain.
@@ -595,7 +616,7 @@ confirmationDigest: string,
595
616
  /**
596
617
  * Verified, rolled-back, or recovery-required terminal.
597
618
  */
598
- outcome: string,
619
+ outcome: RestoreAdapterOutcomeProjection,
599
620
  /**
600
621
  * Exact semantic evidence when supplied.
601
622
  */
@@ -625,11 +646,13 @@ protocolVersion: ConfigProtocolVersion,
625
646
  */
626
647
  requestId: ConfigRequestId, };
627
648
 
649
+ export type RestoreRecoveryResultProjection = "noRecoveryNeeded" | "rolledBack" | "terminalCleanup";
650
+
628
651
  export type RestoreRecoveryReceiptProjection = {
629
652
  /**
630
653
  * No-op, verified rollback, or terminal cleanup.
631
654
  */
632
- outcome: string,
655
+ outcome: RestoreRecoveryResultProjection,
633
656
  /**
634
657
  * Journal domains considered by recovery.
635
658
  */
@@ -1,4 +1,4 @@
1
- // @generated by `effigy generate:config`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Allowed field names per tagged-union variant, from the Rust enums.
3
3
  // Keyed by type, then by discriminant. The discriminant itself is in
4
4
  // each list, because `exact()` compares every key.
@@ -14,7 +14,13 @@ import type {
14
14
  StorageTransitionExecuteCommand,
15
15
  StorageTransitionInspectCommand,
16
16
  } from "../generated/protocol.ts";
17
- import { RESTORE_ARCHIVE_SELECTION_SOURCES } from "../generated/protocol.ts";
17
+ import {
18
+ BACKUP_PENDING_POLICIES,
19
+ RESTORE_ADAPTER_REQUIREMENTS,
20
+ RESTORE_ARCHIVE_SELECTION_SOURCES,
21
+ RESTORE_CONFLICT_CHOICES,
22
+ STORAGE_PROFILE_IDS,
23
+ } from "../generated/protocol.ts";
18
24
  import {
19
25
  array,
20
26
  baseCommand,
@@ -26,14 +32,6 @@ import {
26
32
  record,
27
33
  } from "./primitives.ts";
28
34
 
29
- const STORAGE_PROFILES = [
30
- "platform-native-v1",
31
- "unified-app-root-v1",
32
- "shared-product-root-v1",
33
- "portable-v1",
34
- ] as const;
35
- const RESTORE_CHOICES = ["useArchive", "keepCurrent"] as const;
36
-
37
35
  export function assertValidConfigSnapshotCommand(
38
36
  value: unknown,
39
37
  ): asserts value is ConfigSnapshotCommand {
@@ -44,7 +42,7 @@ export function assertValidStorageTransitionInspectCommand(
44
42
  value: unknown,
45
43
  ): asserts value is StorageTransitionInspectCommand {
46
44
  const command = baseCommand(value, "$", CONFIG_FIELDS.StorageTransitionInspectCommand);
47
- discriminant(command.targetProfile, STORAGE_PROFILES, "$.targetProfile");
45
+ discriminant(command.targetProfile, STORAGE_PROFILE_IDS, "$.targetProfile");
48
46
  boolean(command.includeLogs, "$.includeLogs");
49
47
  }
50
48
 
@@ -72,7 +70,7 @@ export function assertValidBackupCreateCommand(
72
70
  value: unknown,
73
71
  ): asserts value is BackupCreateCommand {
74
72
  const command = baseCommand(value, "$", CONFIG_FIELDS.BackupCreateCommand);
75
- discriminant(command.pendingPolicy, ["refuse", "flush"], "$.pendingPolicy");
73
+ discriminant(command.pendingPolicy, BACKUP_PENDING_POLICIES, "$.pendingPolicy");
76
74
  }
77
75
 
78
76
  export function assertValidBackupExportCommand(
@@ -107,7 +105,7 @@ export function assertValidRestorePlanCommand(value: unknown): asserts value is
107
105
  const path = `$.choices[${index}]`;
108
106
  const choice = record(choiceValue, path, CONFIG_FIELDS.RestoreDomainChoice);
109
107
  nonempty(choice.domainId, `${path}.domainId`);
110
- discriminant(choice.choice, RESTORE_CHOICES, `${path}.choice`);
108
+ discriminant(choice.choice, RESTORE_CONFLICT_CHOICES, `${path}.choice`);
111
109
  });
112
110
  }
113
111
 
@@ -123,7 +121,7 @@ export function assertValidRestoreAdapterExecuteCommand(
123
121
  const command = generationConfirmationCommand(value, CONFIG_FIELDS.RestoreAdapterExecuteCommand);
124
122
  digest(command.archiveSha256, "$.archiveSha256");
125
123
  nonempty(command.domainId, "$.domainId");
126
- discriminant(command.requirement, ["failureAtomic", "allowSeparate"], "$.requirement");
124
+ discriminant(command.requirement, RESTORE_ADAPTER_REQUIREMENTS, "$.requirement");
127
125
  }
128
126
 
129
127
  export function assertValidRestoreRecoveryCommand(