@serve.zone/interfaces 32.114.0 → 32.115.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/changelog.md +13 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/backup/index.d.ts +2 -0
- package/dist_ts/data/backup/index.js +3 -0
- package/dist_ts/data/coremail/index.d.ts +2 -0
- package/dist_ts/data/coremail/index.js +3 -0
- package/dist_ts/data/corestorereplication.d.ts +90 -0
- package/dist_ts/data/corestorereplication.js +129 -0
- package/dist_ts/data/dcstorage.d.ts +206 -0
- package/dist_ts/data/dcstorage.js +322 -0
- package/dist_ts/data/delegatedadmintoken.d.ts +4 -2
- package/dist_ts/data/delegatedadmintoken.js +9 -3
- package/dist_ts/data/gateway.d.ts +13 -0
- package/dist_ts/data/gateway.js +6 -2
- package/dist_ts/data/gatewayarearows.d.ts +17 -11
- package/dist_ts/data/gatewayarearows.js +27 -11
- package/dist_ts/data/gatewayareas.d.ts +12 -2
- package/dist_ts/data/gatewayareas.js +5 -2
- package/dist_ts/data/gatewayareas.validation.js +11 -5
- package/dist_ts/data/index.d.ts +3 -0
- package/dist_ts/data/index.js +4 -1
- package/dist_ts/data/preparedimages.d.ts +80 -0
- package/dist_ts/data/preparedimages.js +154 -0
- package/dist_ts/index.d.ts +8 -2
- package/dist_ts/index.js +9 -3
- package/dist_ts/requests/backup.d.ts +1 -1
- package/dist_ts/requests/backup.js +2 -2
- package/dist_ts/requests/corestore.d.ts +1 -1
- package/dist_ts/requests/corestore.js +1 -2
- package/dist_ts/requests/corestorereplication.d.ts +108 -0
- package/dist_ts/requests/corestorereplication.js +2 -0
- package/dist_ts/requests/dcstorage.d.ts +204 -0
- package/dist_ts/requests/dcstorage.js +2 -0
- package/dist_ts/requests/gateway.d.ts +1 -1
- package/dist_ts/requests/gateway.js +2 -2
- package/dist_ts/requests/gatewaycertificatestore.d.ts +10 -0
- package/dist_ts/requests/gatewaycertificatestore.js +27 -10
- package/dist_ts/requests/gatewayconnector.d.ts +1 -1
- package/dist_ts/requests/gatewayconnector.js +2 -2
- package/dist_ts/requests/gatewayhealth.d.ts +65 -0
- package/dist_ts/requests/gatewayhealth.js +72 -0
- package/dist_ts/requests/gatewayremoteingress.d.ts +10 -2
- package/dist_ts/requests/gatewayremoteingress.js +7 -2
- package/dist_ts/requests/index.d.ts +4 -0
- package/dist_ts/requests/index.js +5 -1
- package/dist_ts/requests/mail.d.ts +1 -1
- package/dist_ts/requests/mail.js +2 -2
- package/dist_ts/requests/preparedimages.d.ts +24 -0
- package/dist_ts/requests/preparedimages.js +2 -0
- package/package.json +105 -1
- package/readme.md +91 -10
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/backup/index.ts +2 -0
- package/ts/data/coremail/index.ts +2 -0
- package/ts/data/corestorereplication.ts +223 -0
- package/ts/data/dcstorage.ts +505 -0
- package/ts/data/delegatedadmintoken.ts +9 -3
- package/ts/data/gateway.ts +18 -1
- package/ts/data/gatewayarearows.ts +32 -13
- package/ts/data/gatewayareas.ts +15 -3
- package/ts/data/gatewayareas.validation.ts +10 -4
- package/ts/data/index.ts +3 -0
- package/ts/data/preparedimages.ts +231 -0
- package/ts/index.ts +9 -2
- package/ts/requests/backup.ts +1 -1
- package/ts/requests/corestore.ts +1 -1
- package/ts/requests/corestorereplication.ts +123 -0
- package/ts/requests/dcstorage.ts +208 -0
- package/ts/requests/gateway.ts +1 -1
- package/ts/requests/gatewaycertificatestore.ts +34 -9
- package/ts/requests/gatewayconnector.ts +1 -1
- package/ts/requests/gatewayhealth.ts +135 -0
- package/ts/requests/gatewayremoteingress.ts +15 -3
- package/ts/requests/index.ts +4 -0
- package/ts/requests/mail.ts +1 -1
- package/ts/requests/preparedimages.ts +39 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import type { IControllerPeerSet } from '../data/controller.js';
|
|
3
|
+
import type {
|
|
4
|
+
IDcStorageFailureDomain,
|
|
5
|
+
IDcStorageFilesystemIdentity,
|
|
6
|
+
IDcStorageNode,
|
|
7
|
+
IDcStorageNodeTelemetryReport,
|
|
8
|
+
IDcStoragePool,
|
|
9
|
+
IDcStoragePoolProfile,
|
|
10
|
+
IDcStorageSessionFence,
|
|
11
|
+
IDcStorageVolumeAssignment,
|
|
12
|
+
IDcStorageVolumeStatus,
|
|
13
|
+
IEnrollDcStorageNodeRequest,
|
|
14
|
+
IRegisterDcStorageNodeSessionRequest,
|
|
15
|
+
TDcStorageRefusal,
|
|
16
|
+
} from '../data/dcstorage.js';
|
|
17
|
+
import type { TOutcomeUnknownCode } from '../data/outcomeunknown.js';
|
|
18
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
19
|
+
import type { IProtocolOffer } from '../protocol.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The admin router requires an administrator and fresh sign-in for mutations. The node router
|
|
23
|
+
* accepts bootstrap and registration separately from session-scoped traffic. Either router uses
|
|
24
|
+
* TypedResponseError.errorData ({ code, retryable: false }); readers use readDcStorageRefusalErrorData.
|
|
25
|
+
* A missing mutation answer or outcome-unknown requires inspection before taking further action.
|
|
26
|
+
*/
|
|
27
|
+
interface IDcStorageAdminRequest { identity: IIdentityCredential }
|
|
28
|
+
|
|
29
|
+
interface IDcStorageAdminMutation extends IDcStorageAdminRequest {
|
|
30
|
+
/** Durable key for recovering the exact admitted intent. Reuse with another body is refused. */
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
controllerEpoch: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface IDcStorageNodeMutation extends IDcStorageAdminMutation {
|
|
36
|
+
nodeId: string;
|
|
37
|
+
nodeRevision: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface IDcStorageMemberMutation extends IDcStorageAdminMutation {
|
|
41
|
+
poolId: string;
|
|
42
|
+
poolRevision: number;
|
|
43
|
+
slot: number;
|
|
44
|
+
memberGeneration: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IDcStorageVolumeReference {
|
|
48
|
+
volumeId: string;
|
|
49
|
+
volumeGeneration: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type TDcStorageType = plugins.typedrequestInterfaces.ITypedRequest;
|
|
53
|
+
|
|
54
|
+
/** A durable admission receipt. Read getDcStorageOperation for progress or completion. */
|
|
55
|
+
export interface IDcStorageOperationReceipt { operationId: string }
|
|
56
|
+
|
|
57
|
+
export type TDcStorageOperationStatus =
|
|
58
|
+
| { state: 'accepted' | 'running' | 'completed'; pool: IDcStoragePool }
|
|
59
|
+
| { state: 'refused'; reason: Exclude<TDcStorageRefusal, TOutcomeUnknownCode>; pool: IDcStoragePool };
|
|
60
|
+
|
|
61
|
+
/** Discovery for administrators. The node still negotiates the release and its own capabilities. */
|
|
62
|
+
export interface IReq_Admin_Cloudly_GetDcStorageCapabilities extends
|
|
63
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageCapabilities> {
|
|
64
|
+
method: 'getDcStorageCapabilities';
|
|
65
|
+
request: IDcStorageAdminRequest;
|
|
66
|
+
response: {
|
|
67
|
+
controllerEpoch: number;
|
|
68
|
+
protocol: IProtocolOffer;
|
|
69
|
+
nodeEnrollment: boolean;
|
|
70
|
+
filesystemVolumes: boolean;
|
|
71
|
+
poolAdmission: boolean;
|
|
72
|
+
poolDrain: boolean;
|
|
73
|
+
poolReplacement: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Creates a pending node. The administrator's enrollment client keeps the random code. */
|
|
78
|
+
export interface IReq_Admin_Cloudly_CreateDcStorageEnrollment extends
|
|
79
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_CreateDcStorageEnrollment> {
|
|
80
|
+
method: 'createDcStorageEnrollment';
|
|
81
|
+
/** Suppress the request body from logs, including the code verifier. */
|
|
82
|
+
request: IDcStorageAdminMutation & { locationId: string; failureDomain: IDcStorageFailureDomain; pairingCodeSha256: string };
|
|
83
|
+
response: { node: IDcStorageNode; expiresAt: number };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Consumes the code and installs the bearer digest atomically. The request carries a secret. */
|
|
87
|
+
export interface IReq_DcStorage_Cloudly_EnrollDcStorageNode extends
|
|
88
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_EnrollDcStorageNode> {
|
|
89
|
+
method: 'enrollDcStorageNode';
|
|
90
|
+
request: IEnrollDcStorageNodeRequest;
|
|
91
|
+
response: { node: IDcStorageNode; controller: IControllerPeerSet; protocol: IProtocolOffer };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Authenticates a node on this socket. The request carries a secret. */
|
|
95
|
+
export interface IReq_DcStorage_Cloudly_RegisterDcStorageNodeSession extends
|
|
96
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_RegisterDcStorageNodeSession> {
|
|
97
|
+
method: 'registerDcStorageNodeSession';
|
|
98
|
+
request: IRegisterDcStorageNodeSessionRequest;
|
|
99
|
+
response: { controller: IControllerPeerSet; protocol: IProtocolOffer; fence: IDcStorageSessionFence };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Revokes control identity, closes its sessions and stops issuing grants. Ownership is retained. */
|
|
103
|
+
export interface IReq_Admin_Cloudly_RevokeDcStorageNode extends
|
|
104
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_RevokeDcStorageNode> {
|
|
105
|
+
method: 'revokeDcStorageNode';
|
|
106
|
+
request: IDcStorageNodeMutation;
|
|
107
|
+
response: IDcStorageNode;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface IReq_Admin_Cloudly_GetDcStorageNode extends
|
|
111
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageNode> {
|
|
112
|
+
method: 'getDcStorageNode';
|
|
113
|
+
request: IDcStorageAdminRequest & { nodeId: string };
|
|
114
|
+
response: {
|
|
115
|
+
node: IDcStorageNode;
|
|
116
|
+
assignments: IDcStorageVolumeAssignment[];
|
|
117
|
+
/** Last accepted observation. Read freshness from the node record and the session fence. */
|
|
118
|
+
telemetry: IDcStorageNodeTelemetryReport | null;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Reserves an explicitly provisioned identity. Assignment alone gives no write authority. */
|
|
123
|
+
export interface IReq_Admin_Cloudly_AssignDcStorageVolume extends
|
|
124
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_AssignDcStorageVolume> {
|
|
125
|
+
method: 'assignDcStorageVolume';
|
|
126
|
+
request: IDcStorageNodeMutation & { volumeId: string; expected: IDcStorageFilesystemIdentity };
|
|
127
|
+
response: { assignment: IDcStorageVolumeAssignment; nodeRevision: number };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Releases only the named generation after dependent members and writers are fenced. */
|
|
131
|
+
export interface IReq_Admin_Cloudly_UnassignDcStorageVolume extends
|
|
132
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_UnassignDcStorageVolume> {
|
|
133
|
+
method: 'unassignDcStorageVolume';
|
|
134
|
+
request: IDcStorageNodeMutation & IDcStorageVolumeReference;
|
|
135
|
+
response: { nodeRevision: number };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Fresh private verification on the authenticated owner session. */
|
|
139
|
+
export interface IReq_Admin_Cloudly_VerifyDcStorageVolume extends
|
|
140
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_VerifyDcStorageVolume> {
|
|
141
|
+
method: 'verifyDcStorageVolume';
|
|
142
|
+
request: IDcStorageAdminRequest & IDcStorageVolumeReference & { nodeId: string };
|
|
143
|
+
response: IDcStorageVolumeStatus;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Cloudly requests a read-only probe. The assignment and session fence must match on return. */
|
|
147
|
+
export interface IReq_Cloudly_DcStorage_ProbeDcStorageVolume extends
|
|
148
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Cloudly_DcStorage_ProbeDcStorageVolume> {
|
|
149
|
+
method: 'probeDcStorageVolume';
|
|
150
|
+
request: { assignment: IDcStorageVolumeAssignment; fence: IDcStorageSessionFence };
|
|
151
|
+
response: IDcStorageVolumeStatus;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface IReq_Admin_Cloudly_CreateDcStoragePool extends
|
|
155
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_CreateDcStoragePool> {
|
|
156
|
+
method: 'createDcStoragePool';
|
|
157
|
+
request: IDcStorageAdminMutation & { locationId: string; profile: IDcStoragePoolProfile };
|
|
158
|
+
response: IDcStoragePool;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface IReq_Admin_Cloudly_GetDcStoragePool extends
|
|
162
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStoragePool> {
|
|
163
|
+
method: 'getDcStoragePool';
|
|
164
|
+
request: IDcStorageAdminRequest & { poolId: string };
|
|
165
|
+
response: IDcStoragePool;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface IReq_Admin_Cloudly_AdmitDcStoragePoolMember extends
|
|
169
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_AdmitDcStoragePoolMember> {
|
|
170
|
+
method: 'admitDcStoragePoolMember';
|
|
171
|
+
request: Omit<IDcStorageMemberMutation, 'memberGeneration'> & IDcStorageVolumeReference & {
|
|
172
|
+
nodeId: string;
|
|
173
|
+
/** Null for a never-allocated slot. Otherwise match the pending slot's current generation. */
|
|
174
|
+
memberGeneration: number | null;
|
|
175
|
+
};
|
|
176
|
+
response: IDcStorageOperationReceipt;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface IReq_Admin_Cloudly_DrainDcStoragePoolMember extends
|
|
180
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_DrainDcStoragePoolMember> {
|
|
181
|
+
method: 'drainDcStoragePoolMember';
|
|
182
|
+
request: IDcStorageMemberMutation;
|
|
183
|
+
response: IDcStorageOperationReceipt;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface IReq_Admin_Cloudly_ReplaceDcStoragePoolMember extends
|
|
187
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_ReplaceDcStoragePoolMember> {
|
|
188
|
+
method: 'replaceDcStoragePoolMember';
|
|
189
|
+
request: IDcStorageMemberMutation & {
|
|
190
|
+
replacement: IDcStorageVolumeReference & { nodeId: string };
|
|
191
|
+
};
|
|
192
|
+
response: IDcStorageOperationReceipt;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface IReq_Admin_Cloudly_GetDcStorageOperation extends
|
|
196
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageOperation> {
|
|
197
|
+
method: 'getDcStorageOperation';
|
|
198
|
+
request: IDcStorageAdminRequest & { operationId: string };
|
|
199
|
+
response: TDcStorageOperationStatus;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Authenticated reverse session only. Acceptance acknowledges observation, never ownership. */
|
|
203
|
+
export interface IReq_DcStorage_Cloudly_ReportDcStorageNodeTelemetry extends
|
|
204
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_ReportDcStorageNodeTelemetry> {
|
|
205
|
+
method: 'reportDcStorageNodeTelemetry';
|
|
206
|
+
request: IDcStorageNodeTelemetryReport;
|
|
207
|
+
response: { acceptedSequence: number };
|
|
208
|
+
}
|
package/ts/requests/gateway.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { IIdentityCredential } from '../data/user.js';
|
|
|
4
4
|
import { isGatewayAreaRowId } from '../data/gatewayareas.js';
|
|
5
5
|
import { isSha256Digest, type TSha256Digest } from '../data/immutableimage.js';
|
|
6
6
|
import { compareWireTokens } from '../private/canonicaljson.js';
|
|
7
|
-
import { readDataElements, readDataProperties, readExactDataRecord } from '../private/dataproperties.js';
|
|
7
|
+
import { hasExactKeys, readDataElements, readDataProperties, readExactDataRecord } from '../private/dataproperties.js';
|
|
8
8
|
|
|
9
9
|
type ICert = plugins.tsclass.network.ICert;
|
|
10
10
|
|
|
@@ -63,10 +63,18 @@ export interface IGatewayCertificateStoreImpactConfirmation {
|
|
|
63
63
|
remoteIngress: boolean;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Plain creation has no observed backing. Related creation observes a different legacy selector;
|
|
68
|
+
* exact replacement observes the target itself. The gateway must compare both revisions and
|
|
69
|
+
* complete target-union impact in the same authorizing transaction as its write.
|
|
70
|
+
* The projector validates those three wire forms; keep this published interface extensible.
|
|
71
|
+
*/
|
|
66
72
|
export interface IGatewayCertificateStoreImport {
|
|
67
73
|
certificate: ICert;
|
|
68
74
|
/** Null creates; an observed gateway-issued selector ID replaces. */
|
|
69
75
|
id: string | null;
|
|
76
|
+
/** Related creation only, gated by certificates.storeRelatedImport. */
|
|
77
|
+
relatedSelectorId?: string;
|
|
70
78
|
expectedContentRevision: TSha256Digest | null;
|
|
71
79
|
expectedUsageRevision: TSha256Digest | null;
|
|
72
80
|
confirmImpact: IGatewayCertificateStoreImpactConfirmation;
|
|
@@ -287,18 +295,35 @@ export const projectLegacyCertificateFile = (value: unknown): ICert | null => {
|
|
|
287
295
|
csr: file.csr ?? '' };
|
|
288
296
|
};
|
|
289
297
|
|
|
298
|
+
/** The exact legacy backing for raw D; no trim, domain normalization, or preview is involved. */
|
|
299
|
+
export const deriveGatewayCertificateStoreRelatedDomainName = (rawDomainName: string): string | null =>
|
|
300
|
+
rawDomainName.startsWith('*') ? rawDomainName.replace(/^\*\.?/, '') : null;
|
|
301
|
+
|
|
290
302
|
export const projectGatewayCertificateStoreImport = (value: unknown): IGatewayCertificateStoreImport | null => {
|
|
291
|
-
const input =
|
|
303
|
+
const input = readDataProperties(value);
|
|
304
|
+
if (!input || !hasExactKeys(input, [
|
|
292
305
|
'certificate', 'id', 'expectedContentRevision', 'expectedUsageRevision', 'confirmImpact',
|
|
293
|
-
]);
|
|
294
|
-
|
|
295
|
-
|| (isGatewayAreaRowId(input.id) && isRevision(input.expectedContentRevision)
|
|
296
|
-
&& isRevision(input.expectedUsageRevision)))) return null;
|
|
306
|
+
], ['relatedSelectorId'])) return null;
|
|
307
|
+
const hasRelatedSelectorId = Object.hasOwn(input, 'relatedSelectorId');
|
|
297
308
|
const certificate = projectLegacyCertificateFile(input.certificate);
|
|
298
309
|
const confirmImpact = readConfirmation(input.confirmImpact);
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
310
|
+
if (!certificate || !confirmImpact) return null;
|
|
311
|
+
if (input.id === null && !hasRelatedSelectorId
|
|
312
|
+
&& input.expectedContentRevision === null && input.expectedUsageRevision === null) {
|
|
313
|
+
return { certificate, id: null, expectedContentRevision: null, expectedUsageRevision: null, confirmImpact };
|
|
314
|
+
}
|
|
315
|
+
if (!isRevision(input.expectedContentRevision) || !isRevision(input.expectedUsageRevision)) return null;
|
|
316
|
+
if (input.id === null && hasRelatedSelectorId && isGatewayAreaRowId(input.relatedSelectorId)
|
|
317
|
+
&& deriveGatewayCertificateStoreRelatedDomainName(certificate.domainName) !== null) {
|
|
318
|
+
return { certificate, id: null, relatedSelectorId: input.relatedSelectorId,
|
|
319
|
+
expectedContentRevision: input.expectedContentRevision, expectedUsageRevision: input.expectedUsageRevision,
|
|
320
|
+
confirmImpact };
|
|
321
|
+
}
|
|
322
|
+
if (isGatewayAreaRowId(input.id) && !hasRelatedSelectorId) {
|
|
323
|
+
return { certificate, id: input.id, expectedContentRevision: input.expectedContentRevision,
|
|
324
|
+
expectedUsageRevision: input.expectedUsageRevision, confirmImpact };
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
302
327
|
};
|
|
303
328
|
|
|
304
329
|
export const projectGatewayCertificateStoreTarget = (value: unknown): IGatewayCertificateStoreTarget | null => {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import { isReleaseVersion } from '../data/releaseversion.js';
|
|
3
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
4
|
+
import { hasExactKeys, readDataElements, readDataProperties, readExactDataRecord } from '../private/dataproperties.js';
|
|
5
|
+
|
|
6
|
+
// These are the states dcrouter's ServiceManager reports. Keep the wire vocabulary closed.
|
|
7
|
+
const overallStates = ['healthy', 'degraded', 'unhealthy'] as const;
|
|
8
|
+
const componentStates = ['stopped', 'starting', 'running', 'degraded', 'failed', 'stopping'] as const;
|
|
9
|
+
const componentCriticalities = ['critical', 'optional'] as const;
|
|
10
|
+
|
|
11
|
+
export type TGatewayServiceHealthOverall = typeof overallStates[number];
|
|
12
|
+
export type TGatewayServiceHealthState = typeof componentStates[number];
|
|
13
|
+
export type TGatewayServiceHealthCriticality = typeof componentCriticalities[number];
|
|
14
|
+
|
|
15
|
+
export interface IGatewayServiceHealthComponent {
|
|
16
|
+
/** The registered ServiceManager component name, an ASCII identifier. */
|
|
17
|
+
name: string;
|
|
18
|
+
state: TGatewayServiceHealthState;
|
|
19
|
+
criticality: TGatewayServiceHealthCriticality;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The value-free portion of a gateway's local Ops status page. */
|
|
23
|
+
export interface IGatewayServiceHealthSnapshot {
|
|
24
|
+
/** The published dcrouter version. */
|
|
25
|
+
version: string;
|
|
26
|
+
/** Time of this read, in Unix epoch milliseconds. */
|
|
27
|
+
generatedAt: number;
|
|
28
|
+
/** Whole seconds the gateway process has been running. */
|
|
29
|
+
uptimeSeconds: number;
|
|
30
|
+
overall: TGatewayServiceHealthOverall;
|
|
31
|
+
services: IGatewayServiceHealthComponent[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const gatewayServiceHealthBounds = Object.freeze({
|
|
35
|
+
services: 128,
|
|
36
|
+
componentNameLength: 128,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const localRefusals = ['health-unavailable'] as const;
|
|
40
|
+
const adminRefusals = ['gateway-disconnected', 'gateway-unsupported', ...localRefusals, 'gateway-unavailable'] as const;
|
|
41
|
+
|
|
42
|
+
export type TGatewayServiceHealthRefusal = typeof adminRefusals[number];
|
|
43
|
+
|
|
44
|
+
type TGatewayServiceHealthResult<TRefusal extends TGatewayServiceHealthRefusal> =
|
|
45
|
+
| { ok: true; snapshot: IGatewayServiceHealthSnapshot }
|
|
46
|
+
| { ok: false; reason: TRefusal };
|
|
47
|
+
|
|
48
|
+
/** Read-only on the adopted controller connector. Call only with `serviceHealth: true`. */
|
|
49
|
+
export interface IReq_Cloudly_Gateway_ReadGatewayServiceHealth extends plugins.typedrequestInterfaces.implementsTR<
|
|
50
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Cloudly_Gateway_ReadGatewayServiceHealth
|
|
51
|
+
> {
|
|
52
|
+
method: 'readGatewayServiceHealth';
|
|
53
|
+
request: Record<string, never>;
|
|
54
|
+
response: TGatewayServiceHealthResult<typeof localRefusals[number]>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A Cloudly administrator reads the current report from the selected gateway. */
|
|
58
|
+
export interface IReq_Admin_Cloudly_GetGatewayServiceHealth extends plugins.typedrequestInterfaces.implementsTR<
|
|
59
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_GetGatewayServiceHealth
|
|
60
|
+
> {
|
|
61
|
+
method: 'getGatewayServiceHealth';
|
|
62
|
+
request: { identity: IIdentityCredential; gatewayId: string };
|
|
63
|
+
response: TGatewayServiceHealthResult<TGatewayServiceHealthRefusal>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The connector read takes exactly an empty record. */
|
|
67
|
+
export const isGatewayServiceHealthReadRequest = (valueArg: unknown): valueArg is Record<string, never> =>
|
|
68
|
+
readExactDataRecord(valueArg, []) !== null;
|
|
69
|
+
|
|
70
|
+
const serviceNamePattern = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
71
|
+
|
|
72
|
+
/** Copy a component with exactly its projected fields. Pass no full ServiceManager status here. */
|
|
73
|
+
export const projectGatewayServiceHealthComponent = (valueArg: unknown): IGatewayServiceHealthComponent | null => {
|
|
74
|
+
const component = readExactDataRecord(valueArg, ['name', 'state', 'criticality']);
|
|
75
|
+
if (component === null) return null;
|
|
76
|
+
|
|
77
|
+
const { name } = component;
|
|
78
|
+
const state = componentStates.find((stateArg) => stateArg === component.state);
|
|
79
|
+
const criticality = componentCriticalities.find((criticalityArg) => criticalityArg === component.criticality);
|
|
80
|
+
if (typeof name !== 'string' || name.length > gatewayServiceHealthBounds.componentNameLength
|
|
81
|
+
|| !serviceNamePattern.test(name) || state === undefined || criticality === undefined) return null;
|
|
82
|
+
|
|
83
|
+
return { name, state, criticality };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Reject a malformed snapshot as a whole and return a detached copy of a valid one. */
|
|
87
|
+
export const projectGatewayServiceHealthSnapshot = (valueArg: unknown): IGatewayServiceHealthSnapshot | null => {
|
|
88
|
+
const snapshot = readExactDataRecord(valueArg, ['version', 'generatedAt', 'uptimeSeconds', 'overall', 'services']);
|
|
89
|
+
if (snapshot === null) return null;
|
|
90
|
+
|
|
91
|
+
const { version, generatedAt, uptimeSeconds } = snapshot;
|
|
92
|
+
const overall = overallStates.find((stateArg) => stateArg === snapshot.overall);
|
|
93
|
+
if (!isReleaseVersion(version) || typeof generatedAt !== 'number' || !Number.isSafeInteger(generatedAt)
|
|
94
|
+
|| generatedAt <= 0 || typeof uptimeSeconds !== 'number' || !Number.isSafeInteger(uptimeSeconds)
|
|
95
|
+
|| uptimeSeconds < 0 || overall === undefined) return null;
|
|
96
|
+
|
|
97
|
+
const entries = readDataElements(snapshot.services, gatewayServiceHealthBounds.services);
|
|
98
|
+
if (entries === null) return null;
|
|
99
|
+
const services: IGatewayServiceHealthComponent[] = [];
|
|
100
|
+
const names = new Set<string>();
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
const component = projectGatewayServiceHealthComponent(entry);
|
|
103
|
+
if (component === null || names.has(component.name)) return null;
|
|
104
|
+
names.add(component.name);
|
|
105
|
+
services.push(component);
|
|
106
|
+
}
|
|
107
|
+
return { version, generatedAt, uptimeSeconds, overall, services };
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const projectHealthResult = <TRefusal extends TGatewayServiceHealthRefusal>(
|
|
111
|
+
valueArg: unknown, refusalsArg: readonly TRefusal[],
|
|
112
|
+
): TGatewayServiceHealthResult<TRefusal> | null => {
|
|
113
|
+
const result = readDataProperties(valueArg);
|
|
114
|
+
if (result === null) return null;
|
|
115
|
+
|
|
116
|
+
if (result.ok === true && hasExactKeys(result, ['ok', 'snapshot'])) {
|
|
117
|
+
const snapshot = projectGatewayServiceHealthSnapshot(result.snapshot);
|
|
118
|
+
return snapshot === null ? null : { ok: true, snapshot };
|
|
119
|
+
}
|
|
120
|
+
if (result.ok === false && hasExactKeys(result, ['ok', 'reason'])) {
|
|
121
|
+
const reason = refusalsArg.find((reasonArg) => reasonArg === result.reason);
|
|
122
|
+
return reason === undefined ? null : { ok: false, reason };
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Check the gateway's complete connector answer before forwarding a report. */
|
|
128
|
+
export const projectGatewayServiceHealthReadResponse = (
|
|
129
|
+
valueArg: unknown,
|
|
130
|
+
): IReq_Cloudly_Gateway_ReadGatewayServiceHealth['response'] | null => projectHealthResult(valueArg, localRefusals);
|
|
131
|
+
|
|
132
|
+
/** Check Cloudly's complete administrator answer before displaying a report. */
|
|
133
|
+
export const projectGatewayServiceHealthAdminResponse = (
|
|
134
|
+
valueArg: unknown,
|
|
135
|
+
): IReq_Admin_Cloudly_GetGatewayServiceHealth['response'] | null => projectHealthResult(valueArg, adminRefusals);
|
|
@@ -2,6 +2,7 @@ import type { ITypedRequest, implementsTR } from '@api.global/typedrequest-inter
|
|
|
2
2
|
import { gatewayAreaContentContract, isGatewayAreaRowId } from '../data/gatewayareas.js';
|
|
3
3
|
import type { IIdentityCredential } from '../data/user.js';
|
|
4
4
|
import { compareWireTokens } from '../private/canonicaljson.js';
|
|
5
|
+
import { readDataProperty } from '../private/dataproperties.js';
|
|
5
6
|
|
|
6
7
|
export interface IGatewayRemoteIngressStatusPageRequest {
|
|
7
8
|
after?: string;
|
|
@@ -18,6 +19,8 @@ export interface IGatewayRemoteIngressConnection {
|
|
|
18
19
|
rejectedStreams: number;
|
|
19
20
|
activeUdpSessions: number;
|
|
20
21
|
droppedDatagrams: number;
|
|
22
|
+
/** The credential slot used by this connection. Omitted by older gateways. */
|
|
23
|
+
credentialSlot?: 'active' | 'staged';
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface IGatewayRemoteIngressEdge {
|
|
@@ -61,14 +64,20 @@ export const copyGatewayRemoteIngressConnectionTokenMethod = 'copyGatewayRemoteI
|
|
|
61
64
|
|
|
62
65
|
type TRemoteIngressConnectionTokenResult = { ok: true; token: string } | { ok: false; reason: 'token-unavailable' };
|
|
63
66
|
|
|
64
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Credential-bearing read served only on the registered controller connector. Returns the staged
|
|
69
|
+
* token once the hub acknowledges the staged credential, otherwise returns the active token.
|
|
70
|
+
*/
|
|
65
71
|
export interface IReq_Cloudly_Gateway_ReadGatewayRemoteIngressConnectionToken extends implementsTR<ITypedRequest, IReq_Cloudly_Gateway_ReadGatewayRemoteIngressConnectionToken> {
|
|
66
72
|
method: typeof readGatewayRemoteIngressConnectionTokenMethod;
|
|
67
73
|
request: { edgeId: string };
|
|
68
74
|
response: TRemoteIngressConnectionTokenResult;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* A fresh human administrator explicitly copies one edge's staged token once the hub acknowledges
|
|
79
|
+
* the staged credential, or its active token otherwise.
|
|
80
|
+
*/
|
|
72
81
|
export interface IReq_Admin_Cloudly_CopyGatewayRemoteIngressConnectionToken extends implementsTR<ITypedRequest, IReq_Admin_Cloudly_CopyGatewayRemoteIngressConnectionToken> {
|
|
73
82
|
method: typeof copyGatewayRemoteIngressConnectionTokenMethod;
|
|
74
83
|
request: { identity: IIdentityCredential; gatewayId: string; edgeId: string };
|
|
@@ -141,8 +150,11 @@ const projectConnection = (value: unknown): IGatewayRemoteIngressConnection | nu
|
|
|
141
150
|
if (typeof fallbackUsed !== 'boolean' || typeof egressEnabled !== 'boolean' || !isTimestamp(connectedAt)
|
|
142
151
|
|| !isCounter(activeStreams) || !isCounter(bytesIn) || !isCounter(bytesOut) || !isCounter(rejectedStreams)
|
|
143
152
|
|| !isCounter(activeUdpSessions) || !isCounter(droppedDatagrams)) return null;
|
|
153
|
+
const credentialSlot = readDataProperty(value, 'credentialSlot')?.value;
|
|
154
|
+
if ('credentialSlot' in value && credentialSlot !== 'active' && credentialSlot !== 'staged') return null;
|
|
144
155
|
return { transport, fallbackUsed, connectedAt, activeStreams, egressEnabled, bytesIn, bytesOut,
|
|
145
|
-
rejectedStreams, activeUdpSessions, droppedDatagrams
|
|
156
|
+
rejectedStreams, activeUdpSessions, droppedDatagrams,
|
|
157
|
+
...(credentialSlot === 'active' || credentialSlot === 'staged' ? { credentialSlot } : {}) };
|
|
146
158
|
};
|
|
147
159
|
|
|
148
160
|
/** Rebuilds the wire value at both boundaries and checks progress from the requested cursor. */
|
package/ts/requests/index.ts
CHANGED
|
@@ -99,6 +99,7 @@ export * from './hostedapp.js';
|
|
|
99
99
|
export * from './mail.js';
|
|
100
100
|
export * from './webpush.js';
|
|
101
101
|
export * as gatewaynetwork from './gatewaynetwork.js';
|
|
102
|
+
export * as gatewayhealth from './gatewayhealth.js';
|
|
102
103
|
export * as gatewayoperations from './gatewayoperations.js';
|
|
103
104
|
export * as gatewayevents from './gatewayevents.js';
|
|
104
105
|
export * as gatewaydnsoperations from './gatewaydnsoperations.js';
|
|
@@ -106,3 +107,6 @@ export * as gatewayremoteingress from './gatewayremoteingress.js';
|
|
|
106
107
|
export * as gatewaysmtpaccounts from './gatewaysmtpaccounts.js';
|
|
107
108
|
export * as gatewayopstokens from './gatewayopstokens.js';
|
|
108
109
|
export * as gatewaycertificatestore from './gatewaycertificatestore.js';
|
|
110
|
+
export * as dcstorage from './dcstorage.js';
|
|
111
|
+
export * as preparedimages from './preparedimages.js';
|
|
112
|
+
export * as corestorereplication from './corestorereplication.js';
|
package/ts/requests/mail.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import type {
|
|
3
|
+
IGetPreparedImagePullCredentialRequest,
|
|
4
|
+
IGetPreparedImagePullCredentialResponse,
|
|
5
|
+
IReportPreparedImagesRequest,
|
|
6
|
+
ISyncPreparedImagesRequest,
|
|
7
|
+
ISyncPreparedImagesResponse,
|
|
8
|
+
} from '../data/preparedimages.js';
|
|
9
|
+
|
|
10
|
+
/** Authenticated runtime-session push. Compare the binding against the live session at admission. */
|
|
11
|
+
export interface IReq_Controller_Pallet_SyncPreparedImages extends plugins.typedrequestInterfaces.implementsTR<
|
|
12
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Controller_Pallet_SyncPreparedImages
|
|
13
|
+
> {
|
|
14
|
+
method: 'syncPreparedImages';
|
|
15
|
+
request: ISyncPreparedImagesRequest;
|
|
16
|
+
response: ISyncPreparedImagesResponse;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Value-free observation from the live node session. Compare it to the node's current list. */
|
|
20
|
+
export interface IReq_Pallet_Controller_ReportPreparedImages extends plugins.typedrequestInterfaces.implementsTR<
|
|
21
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Pallet_Controller_ReportPreparedImages
|
|
22
|
+
> {
|
|
23
|
+
method: 'reportPreparedImages';
|
|
24
|
+
request: IReportPreparedImagesRequest;
|
|
25
|
+
response: Record<string, never>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolve at attempt time over the authenticated runtime session. The controller matches its live
|
|
30
|
+
* peer and the exact revision and target it stated for that node. Pallet uses the credential for
|
|
31
|
+
* that attempt only. Assignment credentials, secret delivery and slots have separate contracts.
|
|
32
|
+
*/
|
|
33
|
+
export interface IReq_Pallet_Controller_GetPreparedImagePullCredential extends plugins.typedrequestInterfaces.implementsTR<
|
|
34
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Pallet_Controller_GetPreparedImagePullCredential
|
|
35
|
+
> {
|
|
36
|
+
method: 'getPreparedImagePullCredential';
|
|
37
|
+
request: IGetPreparedImagePullCredentialRequest;
|
|
38
|
+
response: IGetPreparedImagePullCredentialResponse;
|
|
39
|
+
}
|