@serve.zone/interfaces 32.114.0 → 32.116.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 +20 -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/controlledtakeover.d.ts +125 -0
- package/dist_ts/data/controlledtakeover.js +217 -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 +30 -14
- package/dist_ts/data/gatewayarearows.js +54 -21
- 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 +4 -0
- package/dist_ts/data/index.js +5 -1
- package/dist_ts/data/preparedimages.d.ts +80 -0
- package/dist_ts/data/preparedimages.js +154 -0
- package/dist_ts/index.d.ts +10 -2
- package/dist_ts/index.js +11 -3
- package/dist_ts/requests/backup.d.ts +1 -1
- package/dist_ts/requests/backup.js +2 -2
- package/dist_ts/requests/controlledtakeover.d.ts +50 -0
- package/dist_ts/requests/controlledtakeover.js +18 -0
- 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 +5 -0
- package/dist_ts/requests/index.js +6 -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 +113 -1
- package/readme.md +120 -10
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/backup/index.ts +2 -0
- package/ts/data/controlledtakeover.ts +338 -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 +76 -26
- package/ts/data/gatewayareas.ts +15 -3
- package/ts/data/gatewayareas.validation.ts +10 -4
- package/ts/data/index.ts +4 -0
- package/ts/data/preparedimages.ts +231 -0
- package/ts/index.ts +11 -2
- package/ts/requests/backup.ts +1 -1
- package/ts/requests/controlledtakeover.ts +108 -0
- 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 +5 -0
- package/ts/requests/mail.ts +1 -1
- package/ts/requests/preparedimages.ts +39 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import { readExactDataRecord } from '../private/dataproperties.js';
|
|
3
|
+
import {
|
|
4
|
+
snapshotControlledTakeoverAbortInput,
|
|
5
|
+
snapshotControlledTakeoverGetInput,
|
|
6
|
+
snapshotControlledTakeoverListInput,
|
|
7
|
+
snapshotControlledTakeoverStartInput,
|
|
8
|
+
snapshotNupstWebhookEndpointConfigureInput,
|
|
9
|
+
snapshotNupstWebhookEndpointRotateInput,
|
|
10
|
+
} from '../data/controlledtakeover.js';
|
|
11
|
+
import type {
|
|
12
|
+
IControlledTakeoverAbortInput,
|
|
13
|
+
IControlledTakeoverGetInput,
|
|
14
|
+
IControlledTakeoverListInput,
|
|
15
|
+
IControlledTakeoverListResponse,
|
|
16
|
+
IControlledTakeoverOperationResponse,
|
|
17
|
+
IControlledTakeoverStartInput,
|
|
18
|
+
INupstWebhookEndpointConfigureInput,
|
|
19
|
+
INupstWebhookEndpointResponse,
|
|
20
|
+
INupstWebhookEndpointRotateInput,
|
|
21
|
+
TControlledTakeoverAbortResponse,
|
|
22
|
+
} from '../data/controlledtakeover.js';
|
|
23
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
24
|
+
|
|
25
|
+
export interface IControlledTakeoverAdminRequest<TInput> {
|
|
26
|
+
identity: IIdentityCredential;
|
|
27
|
+
input: TInput;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Verify the administrator independently. The contract reader only checks the credential shape. */
|
|
31
|
+
const adminRequestOf = <TInput>(
|
|
32
|
+
value: unknown, readInput: (input: unknown) => TInput,
|
|
33
|
+
): IControlledTakeoverAdminRequest<TInput> => {
|
|
34
|
+
const request = readExactDataRecord(value, ['identity', 'input']);
|
|
35
|
+
const identity = request && readExactDataRecord(request.identity, ['jwt']);
|
|
36
|
+
if (!request || typeof identity?.jwt !== 'string' || identity.jwt.length === 0) {
|
|
37
|
+
throw new Error('Controlled takeover administrator request rejected.');
|
|
38
|
+
}
|
|
39
|
+
return { identity: { jwt: identity.jwt }, input: readInput(request.input) };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const snapshotStartControlledTakeoverRequest = (value: unknown) =>
|
|
43
|
+
adminRequestOf(value, snapshotControlledTakeoverStartInput);
|
|
44
|
+
export const snapshotGetControlledTakeoverOperationRequest = (value: unknown) =>
|
|
45
|
+
adminRequestOf(value, snapshotControlledTakeoverGetInput);
|
|
46
|
+
export const snapshotGetControlledTakeoverOperationsRequest = (value: unknown) =>
|
|
47
|
+
adminRequestOf(value, snapshotControlledTakeoverListInput);
|
|
48
|
+
export const snapshotAbortControlledTakeoverRequest = (value: unknown) =>
|
|
49
|
+
adminRequestOf(value, snapshotControlledTakeoverAbortInput);
|
|
50
|
+
export const snapshotConfigureNupstWebhookEndpointRequest = (value: unknown) =>
|
|
51
|
+
adminRequestOf(value, snapshotNupstWebhookEndpointConfigureInput);
|
|
52
|
+
export const snapshotRotateNupstWebhookEndpointSecretRequest = (value: unknown) =>
|
|
53
|
+
adminRequestOf(value, snapshotNupstWebhookEndpointRotateInput);
|
|
54
|
+
|
|
55
|
+
/** Operator admission. Cloudly derives locations and the service plan. The answer reports the
|
|
56
|
+
* operation as stored after admission, including when answering a retry of the same start. */
|
|
57
|
+
export interface IReq_Admin_Cloudly_StartControlledTakeover extends plugins.typedrequestInterfaces.implementsTR<
|
|
58
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_StartControlledTakeover
|
|
59
|
+
> {
|
|
60
|
+
method: 'startControlledTakeover';
|
|
61
|
+
request: IControlledTakeoverAdminRequest<IControlledTakeoverStartInput>;
|
|
62
|
+
response: IControlledTakeoverOperationResponse;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Read the recorded operation without advancing it. */
|
|
66
|
+
export interface IReq_Admin_Cloudly_GetControlledTakeoverOperation extends plugins.typedrequestInterfaces.implementsTR<
|
|
67
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_GetControlledTakeoverOperation
|
|
68
|
+
> {
|
|
69
|
+
method: 'getControlledTakeoverOperation';
|
|
70
|
+
request: IControlledTakeoverAdminRequest<IControlledTakeoverGetInput>;
|
|
71
|
+
response: IControlledTakeoverOperationResponse;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Read one page by operation ID. No delegated administrator scope admits these requests. */
|
|
75
|
+
export interface IReq_Admin_Cloudly_GetControlledTakeoverOperations extends plugins.typedrequestInterfaces.implementsTR<
|
|
76
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_GetControlledTakeoverOperations
|
|
77
|
+
> {
|
|
78
|
+
method: 'getControlledTakeoverOperations';
|
|
79
|
+
request: IControlledTakeoverAdminRequest<IControlledTakeoverListInput>;
|
|
80
|
+
response: IControlledTakeoverListResponse;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Cloudly checks the observed revision and the irreversible commit fence in the same transaction. */
|
|
84
|
+
export interface IReq_Admin_Cloudly_AbortControlledTakeover extends plugins.typedrequestInterfaces.implementsTR<
|
|
85
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_AbortControlledTakeover
|
|
86
|
+
> {
|
|
87
|
+
method: 'abortControlledTakeover';
|
|
88
|
+
request: IControlledTakeoverAdminRequest<IControlledTakeoverAbortInput>;
|
|
89
|
+
response: TControlledTakeoverAbortResponse;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Configure the endpoint's site binding, enabled state and margin. Secret state is server-owned. */
|
|
93
|
+
export interface IReq_Admin_Cloudly_ConfigureNupstWebhookEndpoint extends plugins.typedrequestInterfaces.implementsTR<
|
|
94
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_ConfigureNupstWebhookEndpoint
|
|
95
|
+
> {
|
|
96
|
+
method: 'configureNupstWebhookEndpoint';
|
|
97
|
+
request: IControlledTakeoverAdminRequest<INupstWebhookEndpointConfigureInput>;
|
|
98
|
+
response: INupstWebhookEndpointResponse;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Rotate against the observed secret version. Provisioning the sender happens outside this RPC. */
|
|
102
|
+
export interface IReq_Admin_Cloudly_RotateNupstWebhookEndpointSecret extends plugins.typedrequestInterfaces.implementsTR<
|
|
103
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_RotateNupstWebhookEndpointSecret
|
|
104
|
+
> {
|
|
105
|
+
method: 'rotateNupstWebhookEndpointSecret';
|
|
106
|
+
request: IControlledTakeoverAdminRequest<INupstWebhookEndpointRotateInput>;
|
|
107
|
+
response: INupstWebhookEndpointResponse;
|
|
108
|
+
}
|
package/ts/requests/corestore.ts
CHANGED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
3
|
+
import type {
|
|
4
|
+
ICorestoreReplicationBinding,
|
|
5
|
+
ICorestoreReplicationFence,
|
|
6
|
+
ICorestoreReplicationGrant,
|
|
7
|
+
ICorestoreReplicationLagReport,
|
|
8
|
+
ICorestoreReplicationPromotion,
|
|
9
|
+
ICorestoreReplicationQuiescence,
|
|
10
|
+
ICorestoreReplicationTimeline,
|
|
11
|
+
} from '../data/corestorereplication.js';
|
|
12
|
+
|
|
13
|
+
interface ICorestoreReplicationAdminCommand {
|
|
14
|
+
identity: IIdentityCredential;
|
|
15
|
+
expected: ICorestoreReplicationFence;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ICorestoreReplicationPromoted {
|
|
19
|
+
previous: ICorestoreReplicationFence;
|
|
20
|
+
timeline: ICorestoreReplicationTimeline;
|
|
21
|
+
displacedCopy: 'set-aside';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Cloudly verifies administrator authority and resolves both exact peers from trusted records.
|
|
26
|
+
* A grant installs a non-blocking stream for one workload database or bucket binding.
|
|
27
|
+
*/
|
|
28
|
+
export interface IReq_Admin_Cloudly_GrantCorestoreReplication extends plugins.typedrequestInterfaces.implementsTR<
|
|
29
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_GrantCorestoreReplication
|
|
30
|
+
> {
|
|
31
|
+
method: 'grantCorestoreReplication';
|
|
32
|
+
request: {
|
|
33
|
+
identity: IIdentityCredential;
|
|
34
|
+
binding: ICorestoreReplicationBinding;
|
|
35
|
+
primaryNodeId: string;
|
|
36
|
+
replicaNodeId: string;
|
|
37
|
+
/** Null requires no active grant. A replacement requires the exact current fence. */
|
|
38
|
+
expected: ICorestoreReplicationFence | null;
|
|
39
|
+
};
|
|
40
|
+
response: { grant: ICorestoreReplicationGrant };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Install an authorized grant on one of its named peers over authenticated controller RPC.
|
|
45
|
+
* Verify the live controller, the local binding and the stored fence at commit. Retain a durable
|
|
46
|
+
* high-water mark after revocation. An identical replay may acknowledge the current grant.
|
|
47
|
+
*/
|
|
48
|
+
export interface IReq_Controller_Corestore_InstallCorestoreReplicationGrant
|
|
49
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
50
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Controller_Corestore_InstallCorestoreReplicationGrant
|
|
51
|
+
> {
|
|
52
|
+
method: 'installCorestoreReplicationGrant';
|
|
53
|
+
request: { grant: ICorestoreReplicationGrant; expected: ICorestoreReplicationFence | null };
|
|
54
|
+
response: { installed: ICorestoreReplicationFence };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Read-only inspection of the named copy, including standalone bindings. */
|
|
58
|
+
export interface IReq_Admin_Cloudly_GetCorestoreReplicationLag extends plugins.typedrequestInterfaces.implementsTR<
|
|
59
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_GetCorestoreReplicationLag
|
|
60
|
+
> {
|
|
61
|
+
method: 'getCorestoreReplicationLag';
|
|
62
|
+
request: {
|
|
63
|
+
identity: IIdentityCredential;
|
|
64
|
+
binding: ICorestoreReplicationBinding;
|
|
65
|
+
nodeId: string;
|
|
66
|
+
};
|
|
67
|
+
response: { report: ICorestoreReplicationLagReport };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Pausing the replication stream leaves the source's workload writer authority in place. */
|
|
71
|
+
export interface IReq_Admin_Cloudly_PauseCorestoreReplication extends plugins.typedrequestInterfaces.implementsTR<
|
|
72
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_PauseCorestoreReplication
|
|
73
|
+
> {
|
|
74
|
+
method: 'pauseCorestoreReplication';
|
|
75
|
+
request: ICorestoreReplicationAdminCommand;
|
|
76
|
+
response: { paused: ICorestoreReplicationFence };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Close source writes for a planned move and return the durable final source position. */
|
|
80
|
+
export interface IReq_Admin_Cloudly_QuiesceCorestoreReplication extends plugins.typedrequestInterfaces.implementsTR<
|
|
81
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_QuiesceCorestoreReplication
|
|
82
|
+
> {
|
|
83
|
+
method: 'quiesceCorestoreReplication';
|
|
84
|
+
request: ICorestoreReplicationAdminCommand;
|
|
85
|
+
response: { quiescence: ICorestoreReplicationQuiescence };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Promote only with verified old-writer fencing and a replica that applied at least the stated
|
|
90
|
+
* sequence on the expected timeline. The new writer commits a fresh timeline.
|
|
91
|
+
*/
|
|
92
|
+
export interface IReq_Admin_Cloudly_PromoteCorestoreReplication extends plugins.typedrequestInterfaces.implementsTR<
|
|
93
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_PromoteCorestoreReplication
|
|
94
|
+
> {
|
|
95
|
+
method: 'promoteCorestoreReplication';
|
|
96
|
+
request: ICorestoreReplicationPromotion & { identity: IIdentityCredential };
|
|
97
|
+
response: ICorestoreReplicationPromoted;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Planned promotion after the service stops and the replica applies the source's actual final
|
|
102
|
+
* sequence. Resolve the source quiescence receipt and require its exact fence and final sequence.
|
|
103
|
+
*/
|
|
104
|
+
export interface IReq_Admin_Cloudly_SwitchoverCorestoreReplication
|
|
105
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
106
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_SwitchoverCorestoreReplication
|
|
107
|
+
> {
|
|
108
|
+
method: 'switchoverCorestoreReplication';
|
|
109
|
+
request: ICorestoreReplicationPromotion & { identity: IIdentityCredential };
|
|
110
|
+
response: ICorestoreReplicationPromoted;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Revoke the link and durably raise its binding generation. Revocation leaves provider content
|
|
115
|
+
* intact. A displaced NoSQLDB copy stays closed to clients until an authorized role read or copy.
|
|
116
|
+
*/
|
|
117
|
+
export interface IReq_Admin_Cloudly_RevokeCorestoreReplication extends plugins.typedrequestInterfaces.implementsTR<
|
|
118
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Admin_Cloudly_RevokeCorestoreReplication
|
|
119
|
+
> {
|
|
120
|
+
method: 'revokeCorestoreReplication';
|
|
121
|
+
request: ICorestoreReplicationAdminCommand;
|
|
122
|
+
response: { revoked: ICorestoreReplicationFence; generation: number };
|
|
123
|
+
}
|
|
@@ -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);
|