@serve.zone/interfaces 32.113.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 +22 -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 +15 -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 +208 -0
- package/dist_ts/requests/gatewaycertificatestore.js +240 -0
- 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 +105 -1
- package/readme.md +96 -9
- 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 +20 -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 +411 -0
- 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,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,9 +99,14 @@ 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';
|
|
105
106
|
export * as gatewayremoteingress from './gatewayremoteingress.js';
|
|
106
107
|
export * as gatewaysmtpaccounts from './gatewaysmtpaccounts.js';
|
|
107
108
|
export * as gatewayopstokens from './gatewayopstokens.js';
|
|
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
|
+
}
|