@inflatable-cookie/longhorn 0.4.3 → 0.6.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.
- package/package.json +1 -1
- package/src/agent-control/inject.ts +4 -1
- package/src/agent-control/selection.ts +35 -20
- package/src/agent-control/shim.ts +302 -144
- package/src/bridge/direct.ts +1 -1
- package/src/bridge/generated/fields.ts +3 -2
- package/src/bridge/generated/protocol.ts +7 -3
- package/src/bridge/job.ts +4 -14
- package/src/bridge/loopback.ts +7 -25
- package/src/bridge/operation.ts +13 -43
- package/src/bridge/router.ts +10 -23
- package/src/bridge/runtime/connection.ts +77 -105
- package/src/bridge/runtime/policy.ts +8 -28
- package/src/bridge/runtime/retry.ts +6 -18
- package/src/bridge/session.ts +4 -14
- package/src/bridge/stream/connection.ts +16 -38
- package/src/bridge/stream/source.ts +2 -6
- package/src/bridge/stream/tracker.ts +7 -12
- package/src/bridge/supervision.ts +11 -26
- package/src/bridge/validation/base.ts +17 -39
- package/src/bridge/validation/jobs.ts +11 -25
- package/src/bridge/validation/negotiation.ts +27 -37
- package/src/bridge/validation/operations.ts +28 -52
- package/src/bridge/validation/streams.ts +3 -10
- package/src/commands/client.ts +21 -26
- package/src/commands/controller.ts +32 -47
- package/src/commands/generated/fields.ts +3 -2
- package/src/commands/generated/protocol.ts +4 -0
- package/src/commands/keyboard.ts +92 -89
- package/src/commands/ports.ts +6 -12
- package/src/commands/projectors.ts +50 -48
- package/src/commands/validation.ts +70 -97
- package/src/config/client.ts +6 -19
- package/src/config/generated/fields.ts +2 -2
- package/src/config/names.ts +6 -12
- package/src/config/validation/commands.ts +5 -17
- package/src/config/validation/outcomes.ts +31 -39
- package/src/config/validation/primitives.ts +36 -53
- package/src/config/validation/projection.ts +66 -94
- package/src/core/connection.ts +70 -61
- package/src/core/record.ts +4 -0
- package/src/core/transport.ts +4 -15
- package/src/core/wire-copy.ts +6 -0
- package/src/history/client.ts +6 -12
- package/src/history/controller.ts +46 -46
- package/src/history/direct.ts +1 -3
- package/src/history/generated/fields.ts +2 -2
- package/src/history/ports.ts +4 -6
- package/src/history/serialized.ts +9 -13
- package/src/history/validation.ts +71 -55
- package/src/history-tree/client.ts +87 -11
- package/src/history-tree/controller.ts +313 -70
- package/src/history-tree/direct.ts +3 -1
- package/src/history-tree/generated/fields.ts +2 -2
- package/src/history-tree/ports.ts +3 -1
- package/src/history-tree/serialized.ts +39 -11
- package/src/history-tree/validation.ts +262 -63
- package/src/layout/generated/protocol.ts +2 -2
- package/src/layout/ratio.ts +2 -8
- package/src/layout/validation.ts +10 -19
- package/src/layout/visibility.ts +1 -2
- package/src/licence/client.ts +44 -7
- package/src/licence/controller.ts +76 -40
- package/src/licence/direct.ts +3 -1
- package/src/licence/generated/fields.ts +2 -2
- package/src/licence/generated/key-conformance.json +28 -0
- package/src/licence/generated/protocol.ts +1 -1
- package/src/licence/key.ts +40 -12
- package/src/licence/ports.ts +3 -1
- package/src/licence/serialized.ts +32 -9
- package/src/licence/validation.ts +120 -36
- package/src/native-content/client.ts +178 -236
- package/src/native-content/generated/fields.ts +2 -2
- package/src/native-content/ports.ts +9 -15
- package/src/native-content/serialized.ts +12 -19
- package/src/native-content/validation/base.ts +57 -50
- package/src/native-content/validation/messages.ts +21 -35
- package/src/native-content/validation/state.ts +31 -33
- package/src/notifications/client.ts +87 -31
- package/src/notifications/controller.ts +215 -61
- package/src/notifications/direct.ts +3 -1
- package/src/notifications/generated/fields.ts +2 -2
- package/src/notifications/ports.ts +7 -3
- package/src/notifications/serialized.ts +11 -9
- package/src/notifications/validation.ts +147 -43
- package/src/operation/bridge.ts +117 -50
- package/src/operation/client.ts +38 -24
- package/src/operation/controller.ts +33 -42
- package/src/operation/direct.ts +1 -3
- package/src/operation/generated/fields.ts +2 -2
- package/src/operation/ports.ts +10 -9
- package/src/operation/serialized.ts +8 -9
- package/src/operation/validation.ts +152 -65
- package/src/settings/client.ts +11 -44
- package/src/settings/connection.ts +26 -40
- package/src/settings/generated/fields.ts +3 -3
- package/src/settings/generated/protocol.ts +9 -4
- package/src/settings/names.ts +2 -4
- package/src/settings/registry.ts +23 -25
- package/src/settings/validation/authority.ts +19 -17
- package/src/settings/validation/command.ts +17 -37
- package/src/settings/validation/error.ts +2 -8
- package/src/settings/validation/primitives.ts +26 -42
- package/src/settings/validation/projection.ts +8 -24
- package/src/settings/validation/registry.ts +25 -73
- package/src/surface-transfer/client.ts +6 -18
- package/src/surface-transfer/generated/fields.ts +2 -2
- package/src/surface-transfer/validation.ts +31 -49
- package/src/surfaces/client.ts +12 -22
- package/src/surfaces/generated/fields.ts +2 -2
- package/src/surfaces/validation.ts +40 -49
- package/src/transfer/client.ts +26 -60
- package/src/transfer/connection.ts +12 -20
- package/src/transfer/generated/fields.ts +5 -5
- package/src/transfer/generated/protocol.ts +4 -4
- package/src/transfer/payload.ts +13 -31
- package/src/transfer/validation.ts +39 -75
- package/src/update/client.ts +59 -9
- package/src/update/controller.ts +113 -48
- package/src/update/direct.ts +3 -1
- package/src/update/generated/fields.ts +3 -3
- package/src/update/generated/protocol.ts +7 -3
- package/src/update/generated/variant-fields.ts +1 -0
- package/src/update/ports.ts +6 -2
- package/src/update/serialized.ts +34 -10
- package/src/update/validation.ts +115 -35
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRecord } from "../../core/record.ts";
|
|
1
2
|
import { CONFIG_MAXIMUM_OPAQUE_ID_BYTES } from "../generated/base.ts";
|
|
2
3
|
import { CONFIG_OPERATIONS_PROTOCOL_VERSION } from "../generated/protocol.ts";
|
|
3
4
|
|
|
@@ -10,11 +11,7 @@ export class ConfigProtocolValidationError extends Error {
|
|
|
10
11
|
readonly code: ConfigProtocolValidationCode;
|
|
11
12
|
readonly path: string;
|
|
12
13
|
|
|
13
|
-
constructor(
|
|
14
|
-
code: ConfigProtocolValidationCode,
|
|
15
|
-
path: string,
|
|
16
|
-
message: string,
|
|
17
|
-
) {
|
|
14
|
+
constructor(code: ConfigProtocolValidationCode, path: string, message: string) {
|
|
18
15
|
super(message);
|
|
19
16
|
this.name = "ConfigProtocolValidationError";
|
|
20
17
|
this.code = code;
|
|
@@ -25,7 +22,7 @@ export class ConfigProtocolValidationError extends Error {
|
|
|
25
22
|
export function baseCommand(
|
|
26
23
|
value: unknown,
|
|
27
24
|
path: string,
|
|
28
|
-
allowed?:
|
|
25
|
+
allowed?: ReadonlyArray<string>,
|
|
29
26
|
): Record<string, unknown> {
|
|
30
27
|
const command = record(value, path, allowed);
|
|
31
28
|
protocol(command.protocolVersion, `${path}.protocolVersion`);
|
|
@@ -58,13 +55,15 @@ export function protocol(value: unknown, path: string): void {
|
|
|
58
55
|
export function record(
|
|
59
56
|
value: unknown,
|
|
60
57
|
path: string,
|
|
61
|
-
allowed?:
|
|
58
|
+
allowed?: ReadonlyArray<string>,
|
|
62
59
|
): Record<string, unknown> {
|
|
63
|
-
if (
|
|
60
|
+
if (!isRecord(value)) {
|
|
64
61
|
fail("invalid_payload", path, "expected object");
|
|
65
62
|
}
|
|
66
|
-
const result = value
|
|
67
|
-
if (allowed === undefined)
|
|
63
|
+
const result = value;
|
|
64
|
+
if (allowed === undefined) {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
68
67
|
|
|
69
68
|
const permitted = new Set(allowed);
|
|
70
69
|
for (const key of Object.keys(result)) {
|
|
@@ -80,24 +79,20 @@ export function record(
|
|
|
80
79
|
return result;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
export function array(value: unknown, path: string): unknown
|
|
84
|
-
if (!Array.isArray(value))
|
|
82
|
+
export function array(value: unknown, path: string): Array<unknown> {
|
|
83
|
+
if (!Array.isArray(value)) {
|
|
84
|
+
fail("invalid_payload", path, "expected array");
|
|
85
|
+
}
|
|
85
86
|
return value;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
export function string(
|
|
89
|
-
value: unknown,
|
|
90
|
-
path: string,
|
|
91
|
-
): asserts value is string {
|
|
89
|
+
export function string(value: unknown, path: string): asserts value is string {
|
|
92
90
|
if (typeof value !== "string") {
|
|
93
91
|
fail("invalid_payload", path, "expected string");
|
|
94
92
|
}
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
export function nonempty(
|
|
98
|
-
value: unknown,
|
|
99
|
-
path: string,
|
|
100
|
-
): asserts value is string {
|
|
95
|
+
export function nonempty(value: unknown, path: string): asserts value is string {
|
|
101
96
|
string(value, path);
|
|
102
97
|
if (value.length === 0) {
|
|
103
98
|
fail("invalid_payload", path, "expected nonempty string");
|
|
@@ -105,13 +100,12 @@ export function nonempty(
|
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
export function nullableString(value: unknown, path: string): void {
|
|
108
|
-
if (value !== null)
|
|
103
|
+
if (value !== null) {
|
|
104
|
+
string(value, path);
|
|
105
|
+
}
|
|
109
106
|
}
|
|
110
107
|
|
|
111
|
-
export function digest(
|
|
112
|
-
value: unknown,
|
|
113
|
-
path: string,
|
|
114
|
-
): asserts value is string {
|
|
108
|
+
export function digest(value: unknown, path: string): asserts value is string {
|
|
115
109
|
string(value, path);
|
|
116
110
|
if (!/^[0-9a-f]{64}$/.test(value)) {
|
|
117
111
|
fail("invalid_payload", path, "expected lowercase SHA-256 digest");
|
|
@@ -119,36 +113,18 @@ export function digest(
|
|
|
119
113
|
}
|
|
120
114
|
|
|
121
115
|
export function nullableDigest(value: unknown, path: string): void {
|
|
122
|
-
if (value !== null)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
export function opaqueId(
|
|
126
|
-
value: unknown,
|
|
127
|
-
path: string,
|
|
128
|
-
): asserts value is string {
|
|
129
|
-
string(value, path);
|
|
130
|
-
if (
|
|
131
|
-
value.length === 0 ||
|
|
132
|
-
value.length > CONFIG_MAXIMUM_OPAQUE_ID_BYTES ||
|
|
133
|
-
!/^[a-z0-9._:-]+$/.test(value)
|
|
134
|
-
) {
|
|
135
|
-
fail("invalid_payload", path, "expected bounded lowercase opaque id");
|
|
116
|
+
if (value !== null) {
|
|
117
|
+
digest(value, path);
|
|
136
118
|
}
|
|
137
119
|
}
|
|
138
120
|
|
|
139
|
-
export function finiteNumber(
|
|
140
|
-
value: unknown,
|
|
141
|
-
path: string,
|
|
142
|
-
): asserts value is number {
|
|
121
|
+
export function finiteNumber(value: unknown, path: string): asserts value is number {
|
|
143
122
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
144
123
|
fail("invalid_payload", path, "expected non-negative safe integer");
|
|
145
124
|
}
|
|
146
125
|
}
|
|
147
126
|
|
|
148
|
-
export function boolean(
|
|
149
|
-
value: unknown,
|
|
150
|
-
path: string,
|
|
151
|
-
): asserts value is boolean {
|
|
127
|
+
export function boolean(value: unknown, path: string): asserts value is boolean {
|
|
152
128
|
if (typeof value !== "boolean") {
|
|
153
129
|
fail("invalid_payload", path, "expected boolean");
|
|
154
130
|
}
|
|
@@ -156,7 +132,7 @@ export function boolean(
|
|
|
156
132
|
|
|
157
133
|
export function discriminant(
|
|
158
134
|
value: unknown,
|
|
159
|
-
variants:
|
|
135
|
+
variants: ReadonlyArray<string>,
|
|
160
136
|
path: string,
|
|
161
137
|
): asserts value is string {
|
|
162
138
|
string(value, path);
|
|
@@ -165,10 +141,17 @@ export function discriminant(
|
|
|
165
141
|
}
|
|
166
142
|
}
|
|
167
143
|
|
|
168
|
-
export function fail(
|
|
169
|
-
code: ConfigProtocolValidationCode,
|
|
170
|
-
path: string,
|
|
171
|
-
message: string,
|
|
172
|
-
): never {
|
|
144
|
+
export function fail(code: ConfigProtocolValidationCode, path: string, message: string): never {
|
|
173
145
|
throw new ConfigProtocolValidationError(code, path, message);
|
|
174
146
|
}
|
|
147
|
+
|
|
148
|
+
function opaqueId(value: unknown, path: string): asserts value is string {
|
|
149
|
+
string(value, path);
|
|
150
|
+
if (
|
|
151
|
+
value.length === 0 ||
|
|
152
|
+
value.length > CONFIG_MAXIMUM_OPAQUE_ID_BYTES ||
|
|
153
|
+
!/^[a-z0-9._:-]+$/.test(value)
|
|
154
|
+
) {
|
|
155
|
+
fail("invalid_payload", path, "expected bounded lowercase opaque id");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
RESTORE_DOMAIN_COMPATIBILITY_STATUSES,
|
|
9
9
|
RESTORE_IDENTITY_STATUSES,
|
|
10
10
|
STORAGE_BOOTSTRAP_STATES,
|
|
11
|
-
type ConfigOperationsSnapshot,
|
|
12
11
|
} from "../generated/protocol.ts";
|
|
12
|
+
import type { ConfigOperationsSnapshot } from "../generated/protocol.ts";
|
|
13
13
|
import {
|
|
14
14
|
array,
|
|
15
15
|
boolean,
|
|
@@ -38,27 +38,25 @@ export function assertValidConfigOperationsSnapshot(
|
|
|
38
38
|
protocol(snapshot.protocolVersion, "$.protocolVersion");
|
|
39
39
|
finiteNumber(snapshot.generation, "$.generation");
|
|
40
40
|
array(snapshot.capabilities, "$.capabilities").forEach((capability, index) =>
|
|
41
|
-
discriminant(
|
|
42
|
-
capability,
|
|
43
|
-
CONFIG_OPERATION_CAPABILITIES,
|
|
44
|
-
`$.capabilities[${index}]`,
|
|
45
|
-
),
|
|
41
|
+
discriminant(capability, CONFIG_OPERATION_CAPABILITIES, `$.capabilities[${index}]`),
|
|
46
42
|
);
|
|
47
|
-
if (snapshot.storage !== null)
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
if (snapshot.storage !== null) {
|
|
44
|
+
storage(snapshot.storage, "$.storage");
|
|
45
|
+
}
|
|
46
|
+
if (snapshot.backup !== null) {
|
|
47
|
+
backup(snapshot.backup, "$.backup");
|
|
48
|
+
}
|
|
49
|
+
if (snapshot.restore !== null) {
|
|
50
|
+
restoreState(snapshot.restore, "$.restore");
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
export function assertRestoreInspection(value: unknown, path: string): void {
|
|
53
55
|
const inspection = record(value, path, CONFIG_FIELDS.RestoreInspectionProjection);
|
|
54
56
|
digest(inspection.archiveSha256, `${path}.archiveSha256`);
|
|
55
|
-
[
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"kind",
|
|
59
|
-
"applicationVersion",
|
|
60
|
-
"producerVersion",
|
|
61
|
-
].forEach((key) => nonempty(inspection[key], `${path}.${key}`));
|
|
57
|
+
["archiveId", "createdAt", "kind", "applicationVersion", "producerVersion"].forEach((key) =>
|
|
58
|
+
nonempty(inspection[key], `${path}.${key}`),
|
|
59
|
+
);
|
|
62
60
|
discriminant(inspection.integrity, ["verified"], `${path}.integrity`);
|
|
63
61
|
discriminant(
|
|
64
62
|
inspection.authenticity,
|
|
@@ -66,22 +64,14 @@ export function assertRestoreInspection(value: unknown, path: string): void {
|
|
|
66
64
|
`${path}.authenticity`,
|
|
67
65
|
);
|
|
68
66
|
identity(
|
|
69
|
-
record(
|
|
70
|
-
inspection.identity,
|
|
71
|
-
`${path}.identity`,
|
|
72
|
-
CONFIG_FIELDS.RestoreIdentityProjection,
|
|
73
|
-
),
|
|
67
|
+
record(inspection.identity, `${path}.identity`, CONFIG_FIELDS.RestoreIdentityProjection),
|
|
74
68
|
`${path}.identity`,
|
|
75
69
|
);
|
|
76
|
-
array(inspection.consistencyGroups, `${path}.consistencyGroups`).forEach(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
nonempty(group[key], `${groupPath}.${key}`),
|
|
82
|
-
);
|
|
83
|
-
},
|
|
84
|
-
);
|
|
70
|
+
array(inspection.consistencyGroups, `${path}.consistencyGroups`).forEach((value, index) => {
|
|
71
|
+
const groupPath = `${path}.consistencyGroups[${index}]`;
|
|
72
|
+
const group = record(value, groupPath, CONFIG_FIELDS.RestoreConsistencyGroupProjection);
|
|
73
|
+
["id", "mode", "authority"].forEach((key) => nonempty(group[key], `${groupPath}.${key}`));
|
|
74
|
+
});
|
|
85
75
|
array(inspection.domains, `${path}.domains`).forEach((value, index) =>
|
|
86
76
|
restoreDomain(value, `${path}.domains[${index}]`),
|
|
87
77
|
);
|
|
@@ -111,13 +101,11 @@ export function assertRestorePlan(value: unknown, path: string): void {
|
|
|
111
101
|
const entryPath = `${path}.entries[${index}]`;
|
|
112
102
|
const entry = record(value, entryPath, CONFIG_FIELDS.RestorePlanEntryProjection);
|
|
113
103
|
nonempty(entry.domainId, `${entryPath}.domainId`);
|
|
114
|
-
discriminant(
|
|
115
|
-
entry.choice,
|
|
116
|
-
["useArchive", "keepCurrent"],
|
|
117
|
-
`${entryPath}.choice`,
|
|
118
|
-
);
|
|
104
|
+
discriminant(entry.choice, ["useArchive", "keepCurrent"], `${entryPath}.choice`);
|
|
119
105
|
nullableString(entry.action, `${entryPath}.action`);
|
|
120
|
-
if (entry.current !== null)
|
|
106
|
+
if (entry.current !== null) {
|
|
107
|
+
currentEvidence(entry.current, `${entryPath}.current`);
|
|
108
|
+
}
|
|
121
109
|
});
|
|
122
110
|
countReceipt(plan.receipt, `${path}.receipt`, [
|
|
123
111
|
"selected",
|
|
@@ -130,10 +118,7 @@ export function assertRestorePlan(value: unknown, path: string): void {
|
|
|
130
118
|
]);
|
|
131
119
|
}
|
|
132
120
|
|
|
133
|
-
export function assertRestoreExecutionReceipt(
|
|
134
|
-
value: unknown,
|
|
135
|
-
path: string,
|
|
136
|
-
): void {
|
|
121
|
+
export function assertRestoreExecutionReceipt(value: unknown, path: string): void {
|
|
137
122
|
const receipt = record(value, path, CONFIG_FIELDS.RestoreExecutionReceiptProjection);
|
|
138
123
|
digest(receipt.confirmationDigest, `${path}.confirmationDigest`);
|
|
139
124
|
countReceipt(receipt.staging, `${path}.staging`, [
|
|
@@ -166,23 +151,15 @@ export function assertRestoreFailure(value: unknown, path: string): void {
|
|
|
166
151
|
string(failure.detail, `${path}.detail`);
|
|
167
152
|
}
|
|
168
153
|
|
|
169
|
-
export function assertRestoreAdapterReceipt(
|
|
170
|
-
value: unknown,
|
|
171
|
-
path: string,
|
|
172
|
-
): void {
|
|
154
|
+
export function assertRestoreAdapterReceipt(value: unknown, path: string): void {
|
|
173
155
|
const receipt = record(value, path, CONFIG_FIELDS.RestoreAdapterReceiptProjection);
|
|
174
|
-
["domainId", "adapter", "outcome"].forEach((key) =>
|
|
175
|
-
nonempty(receipt[key], `${path}.${key}`),
|
|
176
|
-
);
|
|
156
|
+
["domainId", "adapter", "outcome"].forEach((key) => nonempty(receipt[key], `${path}.${key}`));
|
|
177
157
|
participation(receipt.participation, `${path}.participation`);
|
|
178
158
|
digest(receipt.confirmationDigest, `${path}.confirmationDigest`);
|
|
179
159
|
nullableDigest(receipt.evidence, `${path}.evidence`);
|
|
180
160
|
}
|
|
181
161
|
|
|
182
|
-
export function assertRestoreRecoveryReceipt(
|
|
183
|
-
value: unknown,
|
|
184
|
-
path: string,
|
|
185
|
-
): void {
|
|
162
|
+
export function assertRestoreRecoveryReceipt(value: unknown, path: string): void {
|
|
186
163
|
const receipt = record(value, path, CONFIG_FIELDS.RestoreRecoveryReceiptProjection);
|
|
187
164
|
discriminant(
|
|
188
165
|
receipt.outcome,
|
|
@@ -192,10 +169,6 @@ export function assertRestoreRecoveryReceipt(
|
|
|
192
169
|
stringArray(receipt.domainIds, `${path}.domainIds`);
|
|
193
170
|
}
|
|
194
171
|
|
|
195
|
-
export function assertPublication(value: unknown, path: string): void {
|
|
196
|
-
publication(value, path);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
172
|
function storage(value: unknown, path: string): void {
|
|
200
173
|
const projection = record(value, path, CONFIG_FIELDS.StorageOperationsProjection);
|
|
201
174
|
const layout = record(projection.layout, `${path}.layout`, CONFIG_FIELDS.StorageLayoutProjection);
|
|
@@ -205,36 +178,40 @@ function storage(value: unknown, path: string): void {
|
|
|
205
178
|
);
|
|
206
179
|
digest(layout.layoutDigest, `${path}.layout.layoutDigest`);
|
|
207
180
|
array(layout.roots, `${path}.layout.roots`).forEach((rootValue, index) => {
|
|
208
|
-
const root = record(
|
|
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_PROFILES, `${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(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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", "kind"].forEach((key) =>
|
|
209
|
+
nonempty(archive[key], `${archivePath}.${key}`),
|
|
210
|
+
);
|
|
211
|
+
digest(archive.archiveSha256, `${archivePath}.archiveSha256`);
|
|
212
|
+
});
|
|
213
|
+
array(inventory.entries, `${path}.inventory.entries`).forEach((entryValue, index) =>
|
|
214
|
+
inventoryEntry(entryValue, `${path}.inventory.entries[${index}]`),
|
|
238
215
|
);
|
|
239
216
|
boolean(inventory.complete, `${path}.inventory.complete`);
|
|
240
217
|
const pending = record(projection.pending, `${path}.pending`);
|
|
@@ -242,23 +219,22 @@ function backup(value: unknown, path: string): void {
|
|
|
242
219
|
const encryption = record(projection.encryption, `${path}.encryption`);
|
|
243
220
|
discriminant(encryption.state, BACKUP_ENCRYPTION_STATES, `${path}.encryption.state`);
|
|
244
221
|
if (projection.retention !== null) {
|
|
245
|
-
const retention = record(
|
|
222
|
+
const retention = record(
|
|
223
|
+
projection.retention,
|
|
224
|
+
`${path}.retention`,
|
|
225
|
+
CONFIG_FIELDS.BackupRetentionProjection,
|
|
226
|
+
);
|
|
246
227
|
stringArray(retention.deletionPaths, `${path}.retention.deletionPaths`);
|
|
247
228
|
digest(retention.confirmationDigest, `${path}.retention.confirmationDigest`);
|
|
248
|
-
array(retention.diagnostics, `${path}.retention.diagnostics`).forEach(
|
|
249
|
-
(entryValue, index)
|
|
250
|
-
inventoryEntry(entryValue, `${path}.retention.diagnostics[${index}]`),
|
|
229
|
+
array(retention.diagnostics, `${path}.retention.diagnostics`).forEach((entryValue, index) =>
|
|
230
|
+
inventoryEntry(entryValue, `${path}.retention.diagnostics[${index}]`),
|
|
251
231
|
);
|
|
252
232
|
}
|
|
253
233
|
}
|
|
254
234
|
|
|
255
235
|
function restoreState(value: unknown, path: string): void {
|
|
256
236
|
const projection = record(value, path, CONFIG_FIELDS.RestoreOperationsProjection);
|
|
257
|
-
discriminant(
|
|
258
|
-
projection.state,
|
|
259
|
-
["inactive", "active", "recoveryRequired"],
|
|
260
|
-
`${path}.state`,
|
|
261
|
-
);
|
|
237
|
+
discriminant(projection.state, ["inactive", "active", "recoveryRequired"], `${path}.state`);
|
|
262
238
|
nullableDigest(projection.safetyBackupSha256, `${path}.safetyBackupSha256`);
|
|
263
239
|
}
|
|
264
240
|
|
|
@@ -276,8 +252,8 @@ function identity(value: Record<string, unknown>, path: string): void {
|
|
|
276
252
|
|
|
277
253
|
function restoreDomain(value: unknown, path: string): void {
|
|
278
254
|
const domain = record(value, path, CONFIG_FIELDS.RestoreDomainInspectionProjection);
|
|
279
|
-
["domainId", "storageClass", "consistencyGroup", "adapter", "sourceState"].forEach(
|
|
280
|
-
|
|
255
|
+
["domainId", "storageClass", "consistencyGroup", "adapter", "sourceState"].forEach((key) =>
|
|
256
|
+
nonempty(domain[key], `${path}.${key}`),
|
|
281
257
|
);
|
|
282
258
|
if (domain.sourceSchemaVersion !== null) {
|
|
283
259
|
finiteNumber(domain.sourceSchemaVersion, `${path}.sourceSchemaVersion`);
|
|
@@ -304,12 +280,10 @@ function restoreDomain(value: unknown, path: string): void {
|
|
|
304
280
|
|
|
305
281
|
function participation(value: unknown, path: string): void {
|
|
306
282
|
const projection = record(value, path);
|
|
307
|
-
discriminant(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
);
|
|
312
|
-
if (projection.kind === "excluded") nonempty(projection.reason, `${path}.reason`);
|
|
283
|
+
discriminant(projection.kind, RESTORE_ADAPTER_PARTICIPATION_KINDS, `${path}.kind`);
|
|
284
|
+
if (projection.kind === "excluded") {
|
|
285
|
+
nonempty(projection.reason, `${path}.reason`);
|
|
286
|
+
}
|
|
313
287
|
}
|
|
314
288
|
|
|
315
289
|
function currentEvidence(value: unknown, path: string): void {
|
|
@@ -334,14 +308,12 @@ function inventoryEntry(value: unknown, path: string): void {
|
|
|
334
308
|
|
|
335
309
|
function publication(value: unknown, path: string): void {
|
|
336
310
|
const receipt = record(value, path, CONFIG_FIELDS.BackupPublicationReceiptProjection);
|
|
337
|
-
["path", "destination", "durability"].forEach((key) =>
|
|
338
|
-
nonempty(receipt[key], `${path}.${key}`),
|
|
339
|
-
);
|
|
311
|
+
["path", "destination", "durability"].forEach((key) => nonempty(receipt[key], `${path}.${key}`));
|
|
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
|
|
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
|
}
|