@inflatable-cookie/longhorn 0.5.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 (167) 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/inject.ts +4 -1
  6. package/src/agent-control/selection.ts +42 -25
  7. package/src/agent-control/shim.ts +428 -198
  8. package/src/bridge/direct.ts +1 -1
  9. package/src/bridge/generated/fields.ts +4 -3
  10. package/src/bridge/generated/protocol.ts +62 -7
  11. package/src/bridge/generated/variant-fields.ts +1 -1
  12. package/src/bridge/job.ts +49 -12
  13. package/src/bridge/loopback.ts +7 -25
  14. package/src/bridge/operation.ts +13 -43
  15. package/src/bridge/router.ts +10 -23
  16. package/src/bridge/runtime/connection.ts +78 -109
  17. package/src/bridge/runtime/policy.ts +8 -28
  18. package/src/bridge/runtime/retry.ts +6 -18
  19. package/src/bridge/session.ts +4 -14
  20. package/src/bridge/stream/connection.ts +24 -55
  21. package/src/bridge/stream/source.ts +2 -6
  22. package/src/bridge/stream/tracker.ts +12 -12
  23. package/src/bridge/supervision.ts +104 -97
  24. package/src/bridge/validation/base.ts +21 -63
  25. package/src/bridge/validation/jobs.ts +11 -25
  26. package/src/bridge/validation/negotiation.ts +28 -43
  27. package/src/bridge/validation/operations.ts +29 -65
  28. package/src/bridge/validation/streams.ts +3 -10
  29. package/src/commands/client.ts +37 -28
  30. package/src/commands/controller.ts +119 -96
  31. package/src/commands/generated/fields.ts +7 -6
  32. package/src/commands/generated/protocol.ts +28 -1
  33. package/src/commands/generated/variant-fields.ts +1 -1
  34. package/src/commands/keyboard.ts +94 -100
  35. package/src/commands/physical-code.ts +11 -0
  36. package/src/commands/ports.ts +8 -13
  37. package/src/commands/projectors.ts +100 -75
  38. package/src/commands/validation.ts +434 -241
  39. package/src/config/client.ts +9 -22
  40. package/src/config/generated/base.ts +22 -6
  41. package/src/config/generated/fields.ts +4 -3
  42. package/src/config/generated/label-template.ts +1 -1
  43. package/src/config/generated/labels.ts +1 -1
  44. package/src/config/generated/protocol.ts +1 -1
  45. package/src/config/generated/restore.ts +35 -12
  46. package/src/config/generated/variant-fields.ts +1 -1
  47. package/src/config/names.ts +6 -12
  48. package/src/config/validation/commands.ts +11 -25
  49. package/src/config/validation/outcomes.ts +163 -70
  50. package/src/config/validation/primitives.ts +35 -80
  51. package/src/config/validation/projection.ts +100 -128
  52. package/src/core/connection.ts +187 -83
  53. package/src/core/controller-lifecycle.ts +144 -0
  54. package/src/core/generated/identifiers.ts +4 -0
  55. package/src/core/identifiers.ts +40 -0
  56. package/src/core/index.ts +10 -1
  57. package/src/core/json-value.ts +58 -0
  58. package/src/core/listeners.ts +35 -0
  59. package/src/core/record.ts +80 -0
  60. package/src/core/transport.ts +9 -11
  61. package/src/core/wire-copy.ts +7 -0
  62. package/src/history/client.ts +11 -13
  63. package/src/history/controller.ts +106 -108
  64. package/src/history/direct.ts +1 -3
  65. package/src/history/generated/fields.ts +4 -3
  66. package/src/history/generated/protocol.ts +8 -5
  67. package/src/history/generated/variant-fields.ts +1 -1
  68. package/src/history/ports.ts +7 -4
  69. package/src/history/serialized.ts +9 -13
  70. package/src/history/validation.ts +69 -75
  71. package/src/history-tree/client.ts +89 -11
  72. package/src/history-tree/controller.ts +380 -96
  73. package/src/history-tree/direct.ts +3 -1
  74. package/src/history-tree/generated/fields.ts +5 -3
  75. package/src/history-tree/generated/protocol.ts +43 -7
  76. package/src/history-tree/generated/variant-fields.ts +7 -1
  77. package/src/history-tree/ports.ts +12 -5
  78. package/src/history-tree/serialized.ts +39 -11
  79. package/src/history-tree/validation.ts +286 -78
  80. package/src/layout/generated/protocol.ts +4 -3
  81. package/src/layout/generated/variant-fields.ts +47 -0
  82. package/src/layout/index.ts +1 -1
  83. package/src/layout/ratio.ts +10 -9
  84. package/src/layout/validation.ts +98 -32
  85. package/src/layout/visibility.ts +1 -2
  86. package/src/licence/client.ts +48 -7
  87. package/src/licence/controller.ts +127 -70
  88. package/src/licence/direct.ts +3 -1
  89. package/src/licence/generated/fields.ts +4 -3
  90. package/src/licence/generated/key-conformance.json +28 -0
  91. package/src/licence/generated/protocol.ts +9 -5
  92. package/src/licence/generated/variant-fields.ts +1 -1
  93. package/src/licence/key.ts +42 -18
  94. package/src/licence/ports.ts +10 -3
  95. package/src/licence/serialized.ts +32 -9
  96. package/src/licence/validation.ts +134 -43
  97. package/src/native-content/client.ts +207 -234
  98. package/src/native-content/generated/fields.ts +6 -6
  99. package/src/native-content/generated/protocol.ts +16 -5
  100. package/src/native-content/generated/variant-fields.ts +1 -1
  101. package/src/native-content/ports.ts +11 -16
  102. package/src/native-content/serialized.ts +12 -19
  103. package/src/native-content/validation/base.ts +57 -80
  104. package/src/native-content/validation/messages.ts +24 -35
  105. package/src/native-content/validation/state.ts +31 -33
  106. package/src/notifications/client.ts +85 -51
  107. package/src/notifications/controller.ts +400 -145
  108. package/src/notifications/direct.ts +3 -1
  109. package/src/notifications/generated/fields.ts +4 -3
  110. package/src/notifications/generated/labels.ts +1 -1
  111. package/src/notifications/generated/protocol.ts +5 -1
  112. package/src/notifications/generated/variant-fields.ts +1 -1
  113. package/src/notifications/ports.ts +9 -4
  114. package/src/notifications/serialized.ts +11 -9
  115. package/src/notifications/tone.ts +1 -1
  116. package/src/notifications/validation.ts +165 -71
  117. package/src/operation/bridge.ts +187 -60
  118. package/src/operation/client.ts +48 -62
  119. package/src/operation/controller.ts +67 -97
  120. package/src/operation/direct.ts +1 -3
  121. package/src/operation/generated/fields.ts +4 -3
  122. package/src/operation/generated/labels.ts +1 -1
  123. package/src/operation/generated/protocol.ts +5 -1
  124. package/src/operation/generated/variant-fields.ts +1 -1
  125. package/src/operation/ports.ts +12 -10
  126. package/src/operation/serialized.ts +8 -9
  127. package/src/operation/validation.ts +189 -104
  128. package/src/settings/client.ts +11 -44
  129. package/src/settings/connection.ts +35 -53
  130. package/src/settings/generated/fields.ts +5 -4
  131. package/src/settings/generated/protocol.ts +14 -5
  132. package/src/settings/generated/variant-fields.ts +1 -1
  133. package/src/settings/names.ts +2 -4
  134. package/src/settings/registry.ts +23 -25
  135. package/src/settings/validation/authority.ts +21 -19
  136. package/src/settings/validation/command.ts +22 -41
  137. package/src/settings/validation/error.ts +2 -8
  138. package/src/settings/validation/primitives.ts +46 -97
  139. package/src/settings/validation/projection.ts +8 -24
  140. package/src/settings/validation/registry.ts +33 -79
  141. package/src/surface-transfer/client.ts +6 -18
  142. package/src/surface-transfer/generated/fields.ts +3 -3
  143. package/src/surface-transfer/generated/protocol.ts +3 -3
  144. package/src/surface-transfer/generated/variant-fields.ts +1 -1
  145. package/src/surface-transfer/validation.ts +91 -86
  146. package/src/surfaces/client.ts +33 -55
  147. package/src/surfaces/generated/fields.ts +3 -3
  148. package/src/surfaces/generated/protocol.ts +1 -1
  149. package/src/surfaces/generated/variant-fields.ts +1 -1
  150. package/src/surfaces/validation.ts +227 -99
  151. package/src/transfer/client.ts +26 -60
  152. package/src/transfer/connection.ts +29 -51
  153. package/src/transfer/generated/fields.ts +7 -6
  154. package/src/transfer/generated/protocol.ts +13 -5
  155. package/src/transfer/generated/variant-fields.ts +1 -1
  156. package/src/transfer/index.ts +8 -1
  157. package/src/transfer/payload.ts +20 -35
  158. package/src/transfer/validation.ts +169 -119
  159. package/src/update/client.ts +86 -9
  160. package/src/update/controller.ts +264 -116
  161. package/src/update/direct.ts +3 -1
  162. package/src/update/generated/fields.ts +5 -4
  163. package/src/update/generated/protocol.ts +25 -9
  164. package/src/update/generated/variant-fields.ts +4 -2
  165. package/src/update/ports.ts +14 -6
  166. package/src/update/serialized.ts +36 -10
  167. package/src/update/validation.ts +118 -48
@@ -1,15 +1,31 @@
1
1
  import { CONFIG_FIELDS } from "../generated/fields.ts";
2
2
  import {
3
3
  BACKUP_ENCRYPTION_STATES,
4
+ BACKUP_CONSISTENCY_MODES,
5
+ BACKUP_KINDS,
6
+ BACKUP_SOURCE_STATES,
7
+ STORAGE_CLASSES,
8
+ BACKUP_INVENTORY_ENTRY_STATES,
4
9
  BACKUP_PENDING_STATES,
10
+ BACKUP_PUBLICATION_DURABILITIES,
5
11
  CONFIG_OPERATION_CAPABILITIES,
12
+ RESTORE_ADAPTER_OUTCOMES,
13
+ RESTORE_AUTHENTICITY_VALUES,
14
+ RESTORE_CONFLICT_CHOICES,
15
+ RESTORE_INTEGRITY_VALUES,
16
+ RESTORE_OPERATION_STATES,
17
+ STORAGE_LEAF_PROVENANCES,
18
+ STORAGE_PROFILE_IDS,
6
19
  RESTORE_ADAPTER_PARTICIPATION_KINDS,
7
20
  RESTORE_CURRENT_EVIDENCE_STATES,
8
21
  RESTORE_DOMAIN_COMPATIBILITY_STATUSES,
22
+ RESTORE_EXECUTION_STAGES,
23
+ RESTORE_FAILURE_TERMINALS,
9
24
  RESTORE_IDENTITY_STATUSES,
25
+ RESTORE_RECOVERY_RESULTS,
10
26
  STORAGE_BOOTSTRAP_STATES,
11
- type ConfigOperationsSnapshot,
12
27
  } from "../generated/protocol.ts";
28
+ import type { ConfigOperationsSnapshot } from "../generated/protocol.ts";
13
29
  import {
14
30
  array,
15
31
  boolean,
@@ -24,13 +40,6 @@ import {
24
40
  string,
25
41
  } from "./primitives.ts";
26
42
 
27
- const STORAGE_PROFILES = [
28
- "platform-native-v1",
29
- "unified-app-root-v1",
30
- "shared-product-root-v1",
31
- "portable-v1",
32
- ] as const;
33
-
34
43
  export function assertValidConfigOperationsSnapshot(
35
44
  value: unknown,
36
45
  ): asserts value is ConfigOperationsSnapshot {
@@ -38,59 +47,46 @@ export function assertValidConfigOperationsSnapshot(
38
47
  protocol(snapshot.protocolVersion, "$.protocolVersion");
39
48
  finiteNumber(snapshot.generation, "$.generation");
40
49
  array(snapshot.capabilities, "$.capabilities").forEach((capability, index) =>
41
- discriminant(
42
- capability,
43
- CONFIG_OPERATION_CAPABILITIES,
44
- `$.capabilities[${index}]`,
45
- ),
50
+ discriminant(capability, CONFIG_OPERATION_CAPABILITIES, `$.capabilities[${index}]`),
46
51
  );
47
- if (snapshot.storage !== null) storage(snapshot.storage, "$.storage");
48
- if (snapshot.backup !== null) backup(snapshot.backup, "$.backup");
49
- if (snapshot.restore !== null) restoreState(snapshot.restore, "$.restore");
52
+ if (snapshot.storage !== null) {
53
+ storage(snapshot.storage, "$.storage");
54
+ }
55
+ if (snapshot.backup !== null) {
56
+ backup(snapshot.backup, "$.backup");
57
+ }
58
+ if (snapshot.restore !== null) {
59
+ restoreState(snapshot.restore, "$.restore");
60
+ }
50
61
  }
51
62
 
52
63
  export function assertRestoreInspection(value: unknown, path: string): void {
53
64
  const inspection = record(value, path, CONFIG_FIELDS.RestoreInspectionProjection);
54
65
  digest(inspection.archiveSha256, `${path}.archiveSha256`);
55
- [
56
- "archiveId",
57
- "createdAt",
58
- "kind",
59
- "applicationVersion",
60
- "producerVersion",
61
- ].forEach((key) => nonempty(inspection[key], `${path}.${key}`));
62
- discriminant(inspection.integrity, ["verified"], `${path}.integrity`);
63
- discriminant(
64
- inspection.authenticity,
65
- ["unauthenticated", "authenticated"],
66
- `${path}.authenticity`,
66
+ ["archiveId", "createdAt", "applicationVersion", "producerVersion"].forEach((key) =>
67
+ nonempty(inspection[key], `${path}.${key}`),
67
68
  );
69
+ discriminant(inspection.kind, BACKUP_KINDS, `${path}.kind`);
70
+ discriminant(inspection.integrity, RESTORE_INTEGRITY_VALUES, `${path}.integrity`);
71
+ discriminant(inspection.authenticity, RESTORE_AUTHENTICITY_VALUES, `${path}.authenticity`);
68
72
  identity(
69
- record(
70
- inspection.identity,
71
- `${path}.identity`,
72
- CONFIG_FIELDS.RestoreIdentityProjection,
73
- ),
73
+ record(inspection.identity, `${path}.identity`, CONFIG_FIELDS.RestoreIdentityProjection),
74
74
  `${path}.identity`,
75
75
  );
76
- array(inspection.consistencyGroups, `${path}.consistencyGroups`).forEach(
77
- (value, index) => {
78
- const groupPath = `${path}.consistencyGroups[${index}]`;
79
- const group = record(value, groupPath, CONFIG_FIELDS.RestoreConsistencyGroupProjection);
80
- ["id", "mode", "authority"].forEach((key) =>
81
- nonempty(group[key], `${groupPath}.${key}`),
82
- );
83
- },
84
- );
76
+ array(inspection.consistencyGroups, `${path}.consistencyGroups`).forEach((value, index) => {
77
+ const groupPath = `${path}.consistencyGroups[${index}]`;
78
+ const group = record(value, groupPath, CONFIG_FIELDS.RestoreConsistencyGroupProjection);
79
+ ["id", "authority"].forEach((key) => nonempty(group[key], `${groupPath}.${key}`));
80
+ discriminant(group.mode, BACKUP_CONSISTENCY_MODES, `${groupPath}.mode`);
81
+ });
85
82
  array(inspection.domains, `${path}.domains`).forEach((value, index) =>
86
83
  restoreDomain(value, `${path}.domains[${index}]`),
87
84
  );
88
85
  array(inspection.exclusions, `${path}.exclusions`).forEach((value, index) => {
89
86
  const exclusionPath = `${path}.exclusions[${index}]`;
90
87
  const exclusion = record(value, exclusionPath, CONFIG_FIELDS.RestoreExclusionProjection);
91
- ["domainId", "storageClass", "reason"].forEach((key) =>
92
- nonempty(exclusion[key], `${exclusionPath}.${key}`),
93
- );
88
+ ["domainId", "reason"].forEach((key) => nonempty(exclusion[key], `${exclusionPath}.${key}`));
89
+ discriminant(exclusion.storageClass, STORAGE_CLASSES, `${exclusionPath}.storageClass`);
94
90
  boolean(exclusion.registered, `${exclusionPath}.registered`);
95
91
  });
96
92
  countReceipt(inspection.receipt, `${path}.receipt`, [
@@ -111,13 +107,11 @@ export function assertRestorePlan(value: unknown, path: string): void {
111
107
  const entryPath = `${path}.entries[${index}]`;
112
108
  const entry = record(value, entryPath, CONFIG_FIELDS.RestorePlanEntryProjection);
113
109
  nonempty(entry.domainId, `${entryPath}.domainId`);
114
- discriminant(
115
- entry.choice,
116
- ["useArchive", "keepCurrent"],
117
- `${entryPath}.choice`,
118
- );
110
+ discriminant(entry.choice, RESTORE_CONFLICT_CHOICES, `${entryPath}.choice`);
119
111
  nullableString(entry.action, `${entryPath}.action`);
120
- if (entry.current !== null) currentEvidence(entry.current, `${entryPath}.current`);
112
+ if (entry.current !== null) {
113
+ currentEvidence(entry.current, `${entryPath}.current`);
114
+ }
121
115
  });
122
116
  countReceipt(plan.receipt, `${path}.receipt`, [
123
117
  "selected",
@@ -130,10 +124,7 @@ export function assertRestorePlan(value: unknown, path: string): void {
130
124
  ]);
131
125
  }
132
126
 
133
- export function assertRestoreExecutionReceipt(
134
- value: unknown,
135
- path: string,
136
- ): void {
127
+ export function assertRestoreExecutionReceipt(value: unknown, path: string): void {
137
128
  const receipt = record(value, path, CONFIG_FIELDS.RestoreExecutionReceiptProjection);
138
129
  digest(receipt.confirmationDigest, `${path}.confirmationDigest`);
139
130
  countReceipt(receipt.staging, `${path}.staging`, [
@@ -143,7 +134,7 @@ export function assertRestoreExecutionReceipt(
143
134
  "unchanged",
144
135
  "totalDocumentBytes",
145
136
  ]);
146
- publication(receipt.safetyBackup, `${path}.safetyBackup`);
137
+ assertBackupPublication(receipt.safetyBackup, `${path}.safetyBackup`);
147
138
  [
148
139
  "restoredDomainIds",
149
140
  "deletedDomainIds",
@@ -156,85 +147,72 @@ export function assertRestoreExecutionReceipt(
156
147
 
157
148
  export function assertRestoreFailure(value: unknown, path: string): void {
158
149
  const failure = record(value, path, CONFIG_FIELDS.RestoreExecutionFailureProjection);
159
- nonempty(failure.stage, `${path}.stage`);
150
+ discriminant(failure.stage, RESTORE_EXECUTION_STAGES, `${path}.stage`);
160
151
  nullableString(failure.domainId, `${path}.domainId`);
161
- discriminant(
162
- failure.terminal,
163
- ["noLiveMutation", "rolledBack", "recoveryRequired"],
164
- `${path}.terminal`,
165
- );
152
+ discriminant(failure.terminal, RESTORE_FAILURE_TERMINALS, `${path}.terminal`);
166
153
  string(failure.detail, `${path}.detail`);
167
154
  }
168
155
 
169
- export function assertRestoreAdapterReceipt(
170
- value: unknown,
171
- path: string,
172
- ): void {
156
+ export function assertRestoreAdapterReceipt(value: unknown, path: string): void {
173
157
  const receipt = record(value, path, CONFIG_FIELDS.RestoreAdapterReceiptProjection);
174
- ["domainId", "adapter", "outcome"].forEach((key) =>
175
- nonempty(receipt[key], `${path}.${key}`),
176
- );
158
+ ["domainId", "adapter"].forEach((key) => nonempty(receipt[key], `${path}.${key}`));
159
+ discriminant(receipt.outcome, RESTORE_ADAPTER_OUTCOMES, `${path}.outcome`);
177
160
  participation(receipt.participation, `${path}.participation`);
178
161
  digest(receipt.confirmationDigest, `${path}.confirmationDigest`);
179
162
  nullableDigest(receipt.evidence, `${path}.evidence`);
180
163
  }
181
164
 
182
- export function assertRestoreRecoveryReceipt(
183
- value: unknown,
184
- path: string,
185
- ): void {
165
+ export function assertRestoreRecoveryReceipt(value: unknown, path: string): void {
186
166
  const receipt = record(value, path, CONFIG_FIELDS.RestoreRecoveryReceiptProjection);
187
- discriminant(
188
- receipt.outcome,
189
- ["noRecoveryNeeded", "rolledBack", "terminalCleanup"],
190
- `${path}.outcome`,
191
- );
167
+ discriminant(receipt.outcome, RESTORE_RECOVERY_RESULTS, `${path}.outcome`);
192
168
  stringArray(receipt.domainIds, `${path}.domainIds`);
193
169
  }
194
170
 
195
- export function assertPublication(value: unknown, path: string): void {
196
- publication(value, path);
197
- }
198
-
199
171
  function storage(value: unknown, path: string): void {
200
172
  const projection = record(value, path, CONFIG_FIELDS.StorageOperationsProjection);
201
173
  const layout = record(projection.layout, `${path}.layout`, CONFIG_FIELDS.StorageLayoutProjection);
202
- discriminant(layout.profile, STORAGE_PROFILES, `${path}.layout.profile`);
174
+ discriminant(layout.profile, STORAGE_PROFILE_IDS, `${path}.layout.profile`);
203
175
  ["platform", "canonicalApplicationId", "effectiveLeaf"].forEach((key) =>
204
176
  nonempty(layout[key], `${path}.layout.${key}`),
205
177
  );
178
+ discriminant(layout.leafProvenance, STORAGE_LEAF_PROVENANCES, `${path}.layout.leafProvenance`);
206
179
  digest(layout.layoutDigest, `${path}.layout.layoutDigest`);
207
180
  array(layout.roots, `${path}.layout.roots`).forEach((rootValue, index) => {
208
- const root = record(rootValue, `${path}.layout.roots[${index}]`, CONFIG_FIELDS.StorageRootProjection);
181
+ const root = record(
182
+ rootValue,
183
+ `${path}.layout.roots[${index}]`,
184
+ CONFIG_FIELDS.StorageRootProjection,
185
+ );
209
186
  ["kind", "path", "provenance"].forEach((key) =>
210
187
  nonempty(root[key], `${path}.layout.roots[${index}].${key}`),
211
188
  );
212
189
  });
213
190
  const bootstrap = record(projection.bootstrap, `${path}.bootstrap`);
214
191
  discriminant(bootstrap.state, STORAGE_BOOTSTRAP_STATES, `${path}.bootstrap.state`);
215
- array(projection.availableProfiles, `${path}.availableProfiles`).forEach(
216
- (profile, index) =>
217
- discriminant(profile, STORAGE_PROFILES, `${path}.availableProfiles[${index}]`),
192
+ array(projection.availableProfiles, `${path}.availableProfiles`).forEach((profile, index) =>
193
+ discriminant(profile, STORAGE_PROFILE_IDS, `${path}.availableProfiles[${index}]`),
218
194
  );
219
195
  }
220
196
 
221
197
  function backup(value: unknown, path: string): void {
222
198
  const projection = record(value, path, CONFIG_FIELDS.BackupOperationsProjection);
223
- const inventory = record(projection.inventory, `${path}.inventory`, CONFIG_FIELDS.BackupInventoryProjection);
224
- nonempty(inventory.root, `${path}.inventory.root`);
225
- array(inventory.archives, `${path}.inventory.archives`).forEach(
226
- (archiveValue, index) => {
227
- const archivePath = `${path}.inventory.archives[${index}]`;
228
- const archive = record(archiveValue, archivePath, CONFIG_FIELDS.BackupArchiveProjection);
229
- ["path", "archiveId", "createdAt", "kind"].forEach((key) =>
230
- nonempty(archive[key], `${archivePath}.${key}`),
231
- );
232
- digest(archive.archiveSha256, `${archivePath}.archiveSha256`);
233
- },
199
+ const inventory = record(
200
+ projection.inventory,
201
+ `${path}.inventory`,
202
+ CONFIG_FIELDS.BackupInventoryProjection,
234
203
  );
235
- array(inventory.entries, `${path}.inventory.entries`).forEach(
236
- (entryValue, index) =>
237
- inventoryEntry(entryValue, `${path}.inventory.entries[${index}]`),
204
+ nonempty(inventory.root, `${path}.inventory.root`);
205
+ array(inventory.archives, `${path}.inventory.archives`).forEach((archiveValue, index) => {
206
+ const archivePath = `${path}.inventory.archives[${index}]`;
207
+ const archive = record(archiveValue, archivePath, CONFIG_FIELDS.BackupArchiveProjection);
208
+ ["path", "archiveId", "createdAt"].forEach((key) =>
209
+ nonempty(archive[key], `${archivePath}.${key}`),
210
+ );
211
+ discriminant(archive.kind, BACKUP_KINDS, `${archivePath}.kind`);
212
+ digest(archive.archiveSha256, `${archivePath}.archiveSha256`);
213
+ });
214
+ array(inventory.entries, `${path}.inventory.entries`).forEach((entryValue, index) =>
215
+ inventoryEntry(entryValue, `${path}.inventory.entries[${index}]`),
238
216
  );
239
217
  boolean(inventory.complete, `${path}.inventory.complete`);
240
218
  const pending = record(projection.pending, `${path}.pending`);
@@ -242,23 +220,22 @@ function backup(value: unknown, path: string): void {
242
220
  const encryption = record(projection.encryption, `${path}.encryption`);
243
221
  discriminant(encryption.state, BACKUP_ENCRYPTION_STATES, `${path}.encryption.state`);
244
222
  if (projection.retention !== null) {
245
- const retention = record(projection.retention, `${path}.retention`, CONFIG_FIELDS.BackupRetentionProjection);
223
+ const retention = record(
224
+ projection.retention,
225
+ `${path}.retention`,
226
+ CONFIG_FIELDS.BackupRetentionProjection,
227
+ );
246
228
  stringArray(retention.deletionPaths, `${path}.retention.deletionPaths`);
247
229
  digest(retention.confirmationDigest, `${path}.retention.confirmationDigest`);
248
- array(retention.diagnostics, `${path}.retention.diagnostics`).forEach(
249
- (entryValue, index) =>
250
- inventoryEntry(entryValue, `${path}.retention.diagnostics[${index}]`),
230
+ array(retention.diagnostics, `${path}.retention.diagnostics`).forEach((entryValue, index) =>
231
+ inventoryEntry(entryValue, `${path}.retention.diagnostics[${index}]`),
251
232
  );
252
233
  }
253
234
  }
254
235
 
255
236
  function restoreState(value: unknown, path: string): void {
256
237
  const projection = record(value, path, CONFIG_FIELDS.RestoreOperationsProjection);
257
- discriminant(
258
- projection.state,
259
- ["inactive", "active", "recoveryRequired"],
260
- `${path}.state`,
261
- );
238
+ discriminant(projection.state, RESTORE_OPERATION_STATES, `${path}.state`);
262
239
  nullableDigest(projection.safetyBackupSha256, `${path}.safetyBackupSha256`);
263
240
  }
264
241
 
@@ -276,9 +253,11 @@ function identity(value: Record<string, unknown>, path: string): void {
276
253
 
277
254
  function restoreDomain(value: unknown, path: string): void {
278
255
  const domain = record(value, path, CONFIG_FIELDS.RestoreDomainInspectionProjection);
279
- ["domainId", "storageClass", "consistencyGroup", "adapter", "sourceState"].forEach(
280
- (key) => nonempty(domain[key], `${path}.${key}`),
256
+ ["domainId", "consistencyGroup", "adapter"].forEach((key) =>
257
+ nonempty(domain[key], `${path}.${key}`),
281
258
  );
259
+ discriminant(domain.storageClass, STORAGE_CLASSES, `${path}.storageClass`);
260
+ discriminant(domain.sourceState, BACKUP_SOURCE_STATES, `${path}.sourceState`);
282
261
  if (domain.sourceSchemaVersion !== null) {
283
262
  finiteNumber(domain.sourceSchemaVersion, `${path}.sourceSchemaVersion`);
284
263
  }
@@ -304,12 +283,10 @@ function restoreDomain(value: unknown, path: string): void {
304
283
 
305
284
  function participation(value: unknown, path: string): void {
306
285
  const projection = record(value, path);
307
- discriminant(
308
- projection.kind,
309
- RESTORE_ADAPTER_PARTICIPATION_KINDS,
310
- `${path}.kind`,
311
- );
312
- if (projection.kind === "excluded") nonempty(projection.reason, `${path}.reason`);
286
+ discriminant(projection.kind, RESTORE_ADAPTER_PARTICIPATION_KINDS, `${path}.kind`);
287
+ if (projection.kind === "excluded") {
288
+ nonempty(projection.reason, `${path}.reason`);
289
+ }
313
290
  }
314
291
 
315
292
  function currentEvidence(value: unknown, path: string): void {
@@ -323,25 +300,20 @@ function currentEvidence(value: unknown, path: string): void {
323
300
 
324
301
  function inventoryEntry(value: unknown, path: string): void {
325
302
  const entry = record(value, path, CONFIG_FIELDS.BackupInventoryEntry);
326
- discriminant(
327
- entry.state,
328
- ["valid", "locked", "corrupt", "foreign", "unknown", "unreadable", "unmanaged"],
329
- `${path}.state`,
330
- );
303
+ discriminant(entry.state, BACKUP_INVENTORY_ENTRY_STATES, `${path}.state`);
331
304
  nonempty(entry.diagnosticKind, `${path}.diagnosticKind`);
332
305
  string(entry.detail, `${path}.detail`);
333
306
  }
334
307
 
335
- function publication(value: unknown, path: string): void {
308
+ export function assertBackupPublication(value: unknown, path: string): void {
336
309
  const receipt = record(value, path, CONFIG_FIELDS.BackupPublicationReceiptProjection);
337
- ["path", "destination", "durability"].forEach((key) =>
338
- nonempty(receipt[key], `${path}.${key}`),
339
- );
310
+ ["path", "destination"].forEach((key) => nonempty(receipt[key], `${path}.${key}`));
311
+ discriminant(receipt.durability, BACKUP_PUBLICATION_DURABILITIES, `${path}.durability`);
340
312
  digest(receipt.archiveSha256, `${path}.archiveSha256`);
341
313
  boolean(receipt.replacedExisting, `${path}.replacedExisting`);
342
314
  }
343
315
 
344
- function countReceipt(value: unknown, path: string, keys: string[]): void {
316
+ function countReceipt(value: unknown, path: string, keys: Array<string>): void {
345
317
  const receipt = record(value, path);
346
318
  keys.forEach((key) => finiteNumber(receipt[key], `${path}.${key}`));
347
319
  }