@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,223 @@
|
|
|
1
|
+
import { validateControllerIdentifier, validateControllerOrigin } from '../private/controllercontract.js';
|
|
2
|
+
import { isPlainRecord, readDataProperty, readExactDataRecord } from '../private/dataproperties.js';
|
|
3
|
+
import { isClusterNodeId } from '../private/nodeidentifier.js';
|
|
4
|
+
import { isBoundedInteger } from '../private/runtimepolicy.js';
|
|
5
|
+
import { validateServiceId } from './coremail.runtime.js';
|
|
6
|
+
|
|
7
|
+
export type TCorestoreReplicationRole = 'primary' | 'replica' | 'standalone';
|
|
8
|
+
|
|
9
|
+
export interface ICorestoreReplicationBinding {
|
|
10
|
+
organizationId: string;
|
|
11
|
+
serviceId: string;
|
|
12
|
+
bindingId: string;
|
|
13
|
+
capability: 'database' | 'objectstorage';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ICorestoreReplicationTimeline {
|
|
17
|
+
timelineId: string;
|
|
18
|
+
/** A positive counter for this binding, advanced on writer changes. */
|
|
19
|
+
epoch: number;
|
|
20
|
+
/** The lowest admissible sequence on this timeline, inclusive. */
|
|
21
|
+
sequenceFloor: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type TCorestoreReplicationBindingRole =
|
|
25
|
+
| { role: 'standalone'; timeline: null }
|
|
26
|
+
| { role: 'primary' | 'replica'; timeline: ICorestoreReplicationTimeline };
|
|
27
|
+
|
|
28
|
+
export interface ICorestoreReplicationLagReport {
|
|
29
|
+
role: TCorestoreReplicationRole;
|
|
30
|
+
timelineId: string | null;
|
|
31
|
+
/** Null represents unknown or inapplicable lag. Zero represents measured zero lag. */
|
|
32
|
+
lagBytes: number | null;
|
|
33
|
+
lagMs: number | null;
|
|
34
|
+
/** Whether this replica has completed a usable first copy on the reported timeline. */
|
|
35
|
+
firstCopyComplete: boolean;
|
|
36
|
+
/** Time of the last successful replica sync, in Unix milliseconds. */
|
|
37
|
+
lastSyncAt: number | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Public identity and routing metadata for a specific provider-local binding. */
|
|
41
|
+
export interface ICorestoreReplicationPeer {
|
|
42
|
+
locationId: string;
|
|
43
|
+
clusterId: string;
|
|
44
|
+
nodeId: string;
|
|
45
|
+
localBindingId: string;
|
|
46
|
+
/** Opaque public identity reference to compare with the authenticated transport peer. */
|
|
47
|
+
peerIdentityId: string;
|
|
48
|
+
directOrigin: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Expected authority for the exact directed link, never a bearer or writer capability. */
|
|
52
|
+
export interface ICorestoreReplicationFence {
|
|
53
|
+
linkId: string;
|
|
54
|
+
binding: ICorestoreReplicationBinding;
|
|
55
|
+
/** Monotone for the binding even after revocation. */
|
|
56
|
+
generation: number;
|
|
57
|
+
controllerId: string;
|
|
58
|
+
controllerEpoch: number;
|
|
59
|
+
timeline: ICorestoreReplicationTimeline;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Cloudly authorizes this directed binding and both Corestores persist the metadata. Replication
|
|
64
|
+
* proceeds directly between authenticated peers during Cloudly downtime. Each peer compares the
|
|
65
|
+
* grant with the durable fence and its authenticated counterpart before opening the data path.
|
|
66
|
+
* Provider tokens stay at their own site.
|
|
67
|
+
*/
|
|
68
|
+
export interface ICorestoreReplicationGrant {
|
|
69
|
+
fence: ICorestoreReplicationFence;
|
|
70
|
+
primary: ICorestoreReplicationPeer;
|
|
71
|
+
replica: ICorestoreReplicationPeer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** An authenticated, durable source receipt for a planned switchover. */
|
|
75
|
+
export interface ICorestoreReplicationQuiescence {
|
|
76
|
+
fence: ICorestoreReplicationFence;
|
|
77
|
+
fenceReceiptId: string;
|
|
78
|
+
/** The final committed source sequence after closing writes. */
|
|
79
|
+
finalSequence: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ICorestoreReplicationPromotion {
|
|
83
|
+
expected: ICorestoreReplicationFence;
|
|
84
|
+
nextTimeline: ICorestoreReplicationTimeline;
|
|
85
|
+
/** A reference to verified old-writer fencing, resolved by the authority that owns it. */
|
|
86
|
+
fenceReceiptId: string;
|
|
87
|
+
/** The minimum sequence applied on the old timeline. Switchover uses the final sequence. */
|
|
88
|
+
minimumAppliedSequence: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const invalid = (): never => { throw new Error('Corestore replication contract rejected.'); };
|
|
92
|
+
|
|
93
|
+
const exact = (value: unknown, keys: readonly string[]) => readExactDataRecord(value, keys) ?? invalid();
|
|
94
|
+
const identifier = (value: unknown): string =>
|
|
95
|
+
typeof value === 'string' && validateControllerIdentifier(value, 'identifier').length === 0 ? value : invalid();
|
|
96
|
+
|
|
97
|
+
const counter = (value: unknown, minimum: number): number =>
|
|
98
|
+
isBoundedInteger(value, minimum, Number.MAX_SAFE_INTEGER) ? value : invalid();
|
|
99
|
+
|
|
100
|
+
const optionalCounter = (value: unknown, minimum: number): number | null =>
|
|
101
|
+
value === null ? null : counter(value, minimum);
|
|
102
|
+
|
|
103
|
+
const roleOf = (value: unknown): TCorestoreReplicationRole => {
|
|
104
|
+
if (value === 'primary' || value === 'replica' || value === 'standalone') return value;
|
|
105
|
+
return invalid();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const timelineOf = (value: unknown): ICorestoreReplicationTimeline => {
|
|
109
|
+
const timeline = exact(value, ['timelineId', 'epoch', 'sequenceFloor']);
|
|
110
|
+
return {
|
|
111
|
+
timelineId: identifier(timeline.timelineId),
|
|
112
|
+
epoch: counter(timeline.epoch, 1),
|
|
113
|
+
sequenceFloor: counter(timeline.sequenceFloor, 0),
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** Standalone has no replication timeline. Both linked roles carry an exact timeline. */
|
|
118
|
+
export const snapshotCorestoreReplicationBindingRole = (value: unknown): TCorestoreReplicationBindingRole => {
|
|
119
|
+
const state = exact(value, ['role', 'timeline']);
|
|
120
|
+
const role = roleOf(state.role);
|
|
121
|
+
if (role === 'standalone') return state.timeline === null ? { role, timeline: null } : invalid();
|
|
122
|
+
return { role, timeline: timelineOf(state.timeline) };
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const lagKeys = ['role', 'timelineId', 'lagBytes', 'lagMs', 'firstCopyComplete', 'lastSyncAt'] as const;
|
|
126
|
+
|
|
127
|
+
const lagOf = (value: Record<string, unknown>): ICorestoreReplicationLagReport => {
|
|
128
|
+
const role = roleOf(value.role);
|
|
129
|
+
if (role === 'standalone' && value.timelineId !== null) return invalid();
|
|
130
|
+
const timelineId = role === 'standalone' ? null : identifier(value.timelineId);
|
|
131
|
+
if (typeof value.firstCopyComplete !== 'boolean') return invalid();
|
|
132
|
+
const { firstCopyComplete } = value;
|
|
133
|
+
const lagBytes = optionalCounter(value.lagBytes, 0);
|
|
134
|
+
const lagMs = optionalCounter(value.lagMs, 0);
|
|
135
|
+
const lastSyncAt = optionalCounter(value.lastSyncAt, 1);
|
|
136
|
+
if ((role !== 'replica' && firstCopyComplete)
|
|
137
|
+
|| (!firstCopyComplete && (lagBytes !== null || lagMs !== null || lastSyncAt !== null))) return invalid();
|
|
138
|
+
return { role, timelineId, lagBytes, lagMs, firstCopyComplete, lastSyncAt };
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** Select only public observations from a local provider sample without reading other properties. */
|
|
142
|
+
export const projectCorestoreReplicationLagReport = (value: unknown): ICorestoreReplicationLagReport => {
|
|
143
|
+
if (!isPlainRecord(value)) return invalid();
|
|
144
|
+
const fields = Object.fromEntries(lagKeys.map((key) => {
|
|
145
|
+
const field = readDataProperty(value, key) ?? invalid();
|
|
146
|
+
return [key, field.value];
|
|
147
|
+
}));
|
|
148
|
+
return lagOf(fields);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** Read an exact wire report and refuse any additional field. Lag alone never authorizes a write. */
|
|
152
|
+
export const snapshotCorestoreReplicationLagReport = (value: unknown): ICorestoreReplicationLagReport =>
|
|
153
|
+
lagOf(exact(value, lagKeys));
|
|
154
|
+
|
|
155
|
+
const bindingOf = (value: unknown): ICorestoreReplicationBinding => {
|
|
156
|
+
const binding = exact(value, ['organizationId', 'serviceId', 'bindingId', 'capability']);
|
|
157
|
+
const { capability, serviceId } = binding;
|
|
158
|
+
if ((capability !== 'database' && capability !== 'objectstorage')
|
|
159
|
+
|| typeof serviceId !== 'string' || validateServiceId(serviceId).length !== 0) return invalid();
|
|
160
|
+
return { organizationId: identifier(binding.organizationId), serviceId, bindingId: identifier(binding.bindingId), capability };
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const peerOf = (value: unknown): ICorestoreReplicationPeer => {
|
|
164
|
+
const peer = exact(value, ['locationId', 'clusterId', 'nodeId', 'localBindingId', 'peerIdentityId', 'directOrigin']);
|
|
165
|
+
const { nodeId, directOrigin } = peer;
|
|
166
|
+
if (!isClusterNodeId(nodeId) || typeof directOrigin !== 'string'
|
|
167
|
+
|| validateControllerOrigin(directOrigin, 'directOrigin', 2048).length !== 0) return invalid();
|
|
168
|
+
return {
|
|
169
|
+
locationId: identifier(peer.locationId),
|
|
170
|
+
clusterId: identifier(peer.clusterId),
|
|
171
|
+
nodeId,
|
|
172
|
+
localBindingId: identifier(peer.localBindingId),
|
|
173
|
+
peerIdentityId: identifier(peer.peerIdentityId),
|
|
174
|
+
directOrigin,
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const snapshotCorestoreReplicationFence = (value: unknown): ICorestoreReplicationFence => {
|
|
179
|
+
const fence = exact(value, ['linkId', 'binding', 'generation', 'controllerId', 'controllerEpoch', 'timeline']);
|
|
180
|
+
return {
|
|
181
|
+
linkId: identifier(fence.linkId),
|
|
182
|
+
binding: bindingOf(fence.binding),
|
|
183
|
+
generation: counter(fence.generation, 1),
|
|
184
|
+
controllerId: identifier(fence.controllerId),
|
|
185
|
+
controllerEpoch: counter(fence.controllerEpoch, 1),
|
|
186
|
+
timeline: timelineOf(fence.timeline),
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** Check the grant shape. Consumers resolve both peer/binding identities from trusted records. */
|
|
191
|
+
export const snapshotCorestoreReplicationGrant = (value: unknown): ICorestoreReplicationGrant => {
|
|
192
|
+
const grant = exact(value, ['fence', 'primary', 'replica']);
|
|
193
|
+
const primary = peerOf(grant.primary);
|
|
194
|
+
const replica = peerOf(grant.replica);
|
|
195
|
+
if (primary.locationId === replica.locationId || primary.clusterId === replica.clusterId
|
|
196
|
+
|| primary.nodeId === replica.nodeId || primary.peerIdentityId === replica.peerIdentityId
|
|
197
|
+
|| primary.directOrigin === replica.directOrigin) return invalid();
|
|
198
|
+
return { fence: snapshotCorestoreReplicationFence(grant.fence), primary, replica };
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const snapshotCorestoreReplicationQuiescence = (value: unknown): ICorestoreReplicationQuiescence => {
|
|
202
|
+
const receipt = exact(value, ['fence', 'fenceReceiptId', 'finalSequence']);
|
|
203
|
+
const fence = snapshotCorestoreReplicationFence(receipt.fence);
|
|
204
|
+
return {
|
|
205
|
+
fence,
|
|
206
|
+
fenceReceiptId: identifier(receipt.fenceReceiptId),
|
|
207
|
+
finalSequence: counter(receipt.finalSequence, fence.timeline.sequenceFloor),
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/** Validate the proposed timeline transition. Only provider evidence can prove fencing and apply. */
|
|
212
|
+
export const snapshotCorestoreReplicationPromotion = (value: unknown): ICorestoreReplicationPromotion => {
|
|
213
|
+
const promotion = exact(value, ['expected', 'nextTimeline', 'fenceReceiptId', 'minimumAppliedSequence']);
|
|
214
|
+
const expected = snapshotCorestoreReplicationFence(promotion.expected);
|
|
215
|
+
const nextTimeline = timelineOf(promotion.nextTimeline);
|
|
216
|
+
if (nextTimeline.timelineId === expected.timeline.timelineId || nextTimeline.epoch <= expected.timeline.epoch) return invalid();
|
|
217
|
+
return {
|
|
218
|
+
expected,
|
|
219
|
+
nextTimeline,
|
|
220
|
+
fenceReceiptId: identifier(promotion.fenceReceiptId),
|
|
221
|
+
minimumAppliedSequence: counter(promotion.minimumAppliedSequence, expected.timeline.sequenceFloor),
|
|
222
|
+
};
|
|
223
|
+
};
|