@serve.zone/interfaces 32.93.0 → 32.95.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 +12 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/appstore/types.d.ts +6 -1
- package/dist_ts/appstore/types.js +1 -1
- package/dist_ts/appstore/versionconfig.js +2 -1
- package/dist_ts/data/deploymentoperation.js +7 -1
- package/dist_ts/data/deploymentpreflight.js +10 -1
- package/dist_ts/data/gatewayarearows.d.ts +1 -11
- package/dist_ts/data/gatewayarearows.js +2 -14
- package/dist_ts/data/gatewayareas.d.ts +17 -0
- package/dist_ts/data/gatewayareas.js +21 -1
- package/dist_ts/data/gatewayareas.validation.d.ts +0 -6
- package/dist_ts/data/gatewayareas.validation.js +2 -9
- package/dist_ts/data/gatewayconnector.d.ts +62 -4
- package/dist_ts/data/gatewayconnector.js +75 -4
- package/dist_ts/data/serviceports.d.ts +31 -0
- package/dist_ts/data/serviceports.js +7 -1
- package/package.json +1 -1
- package/readme.md +68 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/appstore/types.ts +6 -1
- package/ts/appstore/versionconfig.ts +1 -0
- package/ts/data/deploymentoperation.ts +6 -0
- package/ts/data/deploymentpreflight.ts +9 -0
- package/ts/data/gatewayarearows.ts +6 -14
- package/ts/data/gatewayareas.ts +25 -0
- package/ts/data/gatewayareas.validation.ts +1 -10
- package/ts/data/gatewayconnector.ts +146 -4
- package/ts/data/serviceports.ts +36 -0
package/ts/appstore/types.ts
CHANGED
|
@@ -479,7 +479,12 @@ export interface IAppStoreVersionConfig {
|
|
|
479
479
|
/** Exact OCI/Docker argument vector appended after the image entrypoint. */
|
|
480
480
|
containerArgs?: string[];
|
|
481
481
|
targetPorts?: IServiceTargetPort[];
|
|
482
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Service domain entries without `owner`: who may remove a hostname is a fact of the Service its
|
|
484
|
+
* host keeps, never of a published template, so `validateAppStoreVersionConfig` refuses `owner` as
|
|
485
|
+
* an unknown field.
|
|
486
|
+
*/
|
|
487
|
+
domains?: Omit<IServiceDomainRoute, 'owner'>[];
|
|
483
488
|
/** Edge/coretraffic public TCP/UDP exposure, distinct from Docker publishedPorts. */
|
|
484
489
|
publicPortMappings?: IServicePublicPortMapping[];
|
|
485
490
|
envVars?: TAppStoreEnvironmentDeclaration[];
|
|
@@ -253,6 +253,7 @@ const readDomains = (valueArg: unknown, labelArg: string): IServiceDomainRoute[]
|
|
|
253
253
|
readList(valueArg, `${labelArg} domains`).map((entryArg, indexArg) => {
|
|
254
254
|
const entryLabel = `${labelArg} domains[${indexArg}]`;
|
|
255
255
|
const entry = readRecord(entryArg, entryLabel);
|
|
256
|
+
// `owner` is absent on purpose: a template states no owner (`IAppStoreVersionConfig.domains`).
|
|
256
257
|
assertExactKeys(
|
|
257
258
|
entry,
|
|
258
259
|
['domainId', 'name', 'targetPort', 'port', 'protocol', 'sourceProfileRef', 'proxied'],
|
|
@@ -374,6 +374,12 @@ export const validateDeploymentReservationInput = (inputArg: unknown): string[]
|
|
|
374
374
|
})) {
|
|
375
375
|
errors.push('routes must be unique canonical declarations over declared numeric ports');
|
|
376
376
|
}
|
|
377
|
+
// Route entries are not exact-key, but `owner` has a meaning one object over
|
|
378
|
+
// (`IServiceDomainRoute.owner`), and a declaration never states who may remove a Service domain
|
|
379
|
+
// entry: a route that holds the member, whatever its value, is refused instead of ignored.
|
|
380
|
+
if (routes?.some((routeArg) => isRecord(routeArg) && Object.hasOwn(routeArg, 'owner'))) {
|
|
381
|
+
errors.push('routes must not state owner: a deployment declaration never states who may remove a Service domain entry');
|
|
382
|
+
}
|
|
377
383
|
if (inputArg.mode === 'greenfield') {
|
|
378
384
|
if (inputArg.expectedRolloutGeneration !== undefined
|
|
379
385
|
|| inputArg.expectedCurrentRolloutId !== undefined) {
|
|
@@ -526,6 +526,15 @@ export const validateDeploymentPreflightRequest = (
|
|
|
526
526
|
)) {
|
|
527
527
|
blockers.push({ code: 'INVALID_REQUEST', message: 'Deployment route declaration is malformed.' });
|
|
528
528
|
}
|
|
529
|
+
// As `validateDeploymentReservationInput` refuses it: a route that holds `owner`, whatever its
|
|
530
|
+
// value, would claim removal authority over a Service domain entry, which a declaration never has.
|
|
531
|
+
if (Array.isArray(requestArg.routes)
|
|
532
|
+
&& requestArg.routes.some((routeArg) => isRecord(routeArg) && Object.hasOwn(routeArg, 'owner'))) {
|
|
533
|
+
blockers.push({
|
|
534
|
+
code: 'INVALID_REQUEST',
|
|
535
|
+
message: 'A deployment route states owner; a deployment declaration never states who may remove a Service domain entry.',
|
|
536
|
+
});
|
|
537
|
+
}
|
|
529
538
|
// Presence is decided from the own property alone: reading `requestArg.protocol` would run an
|
|
530
539
|
// accessor a caller attached to the body, and the offer a validator judges has to be the value
|
|
531
540
|
// the server negotiates from. A data property holding `undefined` states no offer, exactly as
|
|
@@ -57,8 +57,12 @@ import type {
|
|
|
57
57
|
TGatewayAreaSecretClass,
|
|
58
58
|
TGatewayEngineConfig,
|
|
59
59
|
} from './gatewayareas.js';
|
|
60
|
-
import {
|
|
61
|
-
|
|
60
|
+
import {
|
|
61
|
+
gatewayAreaMembers,
|
|
62
|
+
gatewayAreaSecretPaths,
|
|
63
|
+
gatewayAreaSingletonMembers,
|
|
64
|
+
isGatewayAreaRowId,
|
|
65
|
+
} from './gatewayareas.js';
|
|
62
66
|
import { isGatewayConfigArea, type TGatewayConfigArea } from './gatewayconnector.js';
|
|
63
67
|
import type { TGatewayIntentRefusal } from './gatewayintent.js';
|
|
64
68
|
import { isSha256Digest, type TSha256Digest } from './immutableimage.js';
|
|
@@ -200,18 +204,6 @@ export interface IGatewayAreaRowWrites {
|
|
|
200
204
|
export type TGatewayAreaMember<TArea extends TGatewayConfigArea = TGatewayConfigArea> =
|
|
201
205
|
TArea extends TGatewayConfigArea ? keyof IGatewayAreaRowWrites[TArea] & string : never;
|
|
202
206
|
|
|
203
|
-
/**
|
|
204
|
-
* The members of each area that hold one value rather than rows (an object or `null`, never a list),
|
|
205
|
-
* addressed with `id: null`: the singletons of `gatewayAreaMembers`.
|
|
206
|
-
*/
|
|
207
|
-
export const gatewayAreaSingletonMembers = Object.freeze({
|
|
208
|
-
security: Object.freeze(['proxyPolicy'] as const),
|
|
209
|
-
dns: Object.freeze(['server', 'acme'] as const),
|
|
210
|
-
routes: Object.freeze(['http3'] as const),
|
|
211
|
-
mail: Object.freeze(['server'] as const),
|
|
212
|
-
edges: Object.freeze(['hub'] as const),
|
|
213
|
-
} as const);
|
|
214
|
-
|
|
215
207
|
/** A singleton member of an area. */
|
|
216
208
|
export type TGatewayAreaSingletonMember<TArea extends TGatewayConfigArea = TGatewayConfigArea> =
|
|
217
209
|
TArea extends TGatewayConfigArea ? typeof gatewayAreaSingletonMembers[TArea][number] : never;
|
package/ts/data/gatewayareas.ts
CHANGED
|
@@ -141,6 +141,19 @@ export const gatewayAreaContentContract = Object.freeze({
|
|
|
141
141
|
}),
|
|
142
142
|
} as const);
|
|
143
143
|
|
|
144
|
+
const rowIdControlCharacter = /[\u0000-\u001f\u007f]/;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Whether a value is a row id of the area contents: a text of 1 to
|
|
148
|
+
* `gatewayAreaContentContract.maximumRowIdLength` UTF-16 code units without a control character. A
|
|
149
|
+
* member may narrow its own ids further (`invalid-row-id`); this is the rule every row id meets.
|
|
150
|
+
*/
|
|
151
|
+
export const isGatewayAreaRowId = (valueArg: unknown): valueArg is string => (
|
|
152
|
+
typeof valueArg === 'string' && valueArg.length > 0
|
|
153
|
+
&& valueArg.length <= gatewayAreaContentContract.maximumRowIdLength
|
|
154
|
+
&& !rowIdControlCharacter.test(valueArg)
|
|
155
|
+
);
|
|
156
|
+
|
|
144
157
|
/**
|
|
145
158
|
* The API token scopes a gateway (dcrouter) knows, in its own order: the vocabulary a controller
|
|
146
159
|
* mints from. A table carries any scope of the scope syntax (`isGatewayApiTokenScope`), and a scope
|
|
@@ -1131,6 +1144,18 @@ export const gatewayAreaMembers = Object.freeze({
|
|
|
1131
1144
|
edges: Object.freeze(['hub', 'edges'] as const),
|
|
1132
1145
|
} as const);
|
|
1133
1146
|
|
|
1147
|
+
/**
|
|
1148
|
+
* The members of each area that hold one value rather than rows (an object or `null`, never a list),
|
|
1149
|
+
* addressed with `id: null`: the singletons of `gatewayAreaMembers`.
|
|
1150
|
+
*/
|
|
1151
|
+
export const gatewayAreaSingletonMembers = Object.freeze({
|
|
1152
|
+
security: Object.freeze(['proxyPolicy'] as const),
|
|
1153
|
+
dns: Object.freeze(['server', 'acme'] as const),
|
|
1154
|
+
routes: Object.freeze(['http3'] as const),
|
|
1155
|
+
mail: Object.freeze(['server'] as const),
|
|
1156
|
+
edges: Object.freeze(['hub'] as const),
|
|
1157
|
+
} as const);
|
|
1158
|
+
|
|
1134
1159
|
/** The secret classes of the area contents: a sealed value (`IGatewaySealedValue`) or a verifier. */
|
|
1135
1160
|
export type TGatewayAreaSecretClass = 'sealed' | 'verifier';
|
|
1136
1161
|
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
gatewayMailIdentityScramIterations,
|
|
42
42
|
gatewayRoutePathClasses,
|
|
43
43
|
isGatewayApiTokenScope,
|
|
44
|
+
isGatewayAreaRowId,
|
|
44
45
|
type IGatewayAreaSecretPath,
|
|
45
46
|
type IGatewayDnsStaticRecordRow,
|
|
46
47
|
type IGatewayScramVerifier,
|
|
@@ -322,16 +323,6 @@ const zoneLabel = /^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9])?$/;
|
|
|
322
323
|
const portKey = /^[1-9][0-9]{0,4}$/;
|
|
323
324
|
const clientTypes = ['onebox', 'cloudly', 'custom'] as const;
|
|
324
325
|
|
|
325
|
-
/**
|
|
326
|
-
* Whether a value is a row id of the area contents: a text of 1 to
|
|
327
|
-
* `gatewayAreaContentContract.maximumRowIdLength` UTF-16 code units without a control character. A
|
|
328
|
-
* member may narrow its own ids further (`invalid-row-id`); this is the rule every row id meets.
|
|
329
|
-
*/
|
|
330
|
-
export const isGatewayAreaRowId = (valueArg: unknown): valueArg is string => (
|
|
331
|
-
typeof valueArg === 'string' && valueArg.length > 0 && valueArg.length <= contract.maximumRowIdLength
|
|
332
|
-
&& !controlCharacter.test(valueArg)
|
|
333
|
-
);
|
|
334
|
-
|
|
335
326
|
const isZoneName = (valueArg: unknown): valueArg is string => (
|
|
336
327
|
typeof valueArg === 'string' && valueArg.length > 0 && valueArg.length <= 253
|
|
337
328
|
&& valueArg.split('.').every((labelArg) => zoneLabel.test(labelArg))
|
|
@@ -9,7 +9,13 @@ import {
|
|
|
9
9
|
validateControllerNonNegativeInteger,
|
|
10
10
|
validateControllerStrictJson,
|
|
11
11
|
} from '../private/controllercontract.js';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
hasExactKeys,
|
|
14
|
+
readDataElements,
|
|
15
|
+
readDataProperties,
|
|
16
|
+
readDataProperty,
|
|
17
|
+
readExactDataRecord,
|
|
18
|
+
} from '../private/dataproperties.js';
|
|
13
19
|
import { ipv4PrefixOfMapped, parseCanonicalIpAddress } from '../private/ipaddress.js';
|
|
14
20
|
import type { TCompleteKeyList } from '../private/keylist.js';
|
|
15
21
|
import { networkDigest } from '../private/networkcontract.js';
|
|
@@ -18,6 +24,13 @@ import { isGatewayClientIdText } from '../private/gatewayclientid.js';
|
|
|
18
24
|
import { clusterIngressLimits, validateClusterRouteSourceAllowList } from './clusteringress.js';
|
|
19
25
|
import { validateGatewayRouteDnsResult } from './gateway.js';
|
|
20
26
|
import { type IControllerPeerSet, validateControllerPeerSet } from './controller.js';
|
|
27
|
+
import type { TGatewayAreaListMember } from './gatewayarearows.js';
|
|
28
|
+
import {
|
|
29
|
+
gatewayAreaContentContract,
|
|
30
|
+
gatewayAreaMembers,
|
|
31
|
+
gatewayAreaSingletonMembers,
|
|
32
|
+
isGatewayAreaRowId,
|
|
33
|
+
} from './gatewayareas.js';
|
|
21
34
|
import type { TSha256Digest } from './immutableimage.js';
|
|
22
35
|
import { isLocationName } from './location.js';
|
|
23
36
|
import { isReleaseVersion } from './releaseversion.js';
|
|
@@ -63,6 +76,16 @@ export const gatewayConnectorContract = Object.freeze({
|
|
|
63
76
|
maximumDnsZones: 1024,
|
|
64
77
|
maximumHostnameLength: 253,
|
|
65
78
|
maximumRefusalDetailLength: 1024,
|
|
79
|
+
/**
|
|
80
|
+
* Entries one area refusal names (`IGatewayAreaApplyRefusal.rows`). The report travels in the
|
|
81
|
+
* hello, every status push and every apply answer: at this bound, with row ids and reasons at
|
|
82
|
+
* theirs, five refusing areas add at most about 1.1 MiB, so a status document at every bound of
|
|
83
|
+
* this contract, every free-text member at its widest JSON character, stays below the 2 MiB message
|
|
84
|
+
* cap of the controller's socket server (Cloudly): 1,584,299 bytes (`test.gatewayapplyrefusalrows`).
|
|
85
|
+
*/
|
|
86
|
+
maximumRefusalRows: 256,
|
|
87
|
+
/** Characters of one refused row's reason (`IGatewayAreaApplyRefusedRow.reason`). */
|
|
88
|
+
maximumRefusalRowReasonLength: 64,
|
|
66
89
|
maximumStorageBackendLength: 64,
|
|
67
90
|
maximumStoragePathLength: 4096,
|
|
68
91
|
/** Hostnames per `getGatewayRouteDnsResults` request. */
|
|
@@ -502,6 +525,58 @@ export const isGatewayApplyRefusal = (valueArg: unknown): valueArg is TGatewayAp
|
|
|
502
525
|
(gatewayApplyRefusals as readonly unknown[]).includes(valueArg)
|
|
503
526
|
);
|
|
504
527
|
|
|
528
|
+
/**
|
|
529
|
+
* One row an area refusal names as data (`IGatewayAreaApplyRefusal.rows`, Linus ruling 212): the
|
|
530
|
+
* row's address in the refused table and why the gateway refuses it, never a value of the row.
|
|
531
|
+
*/
|
|
532
|
+
export interface IGatewayAreaApplyRefusedRow {
|
|
533
|
+
/** A list member of the refused area (`gatewayAreaMembers` without `gatewayAreaSingletonMembers`). */
|
|
534
|
+
member: TGatewayAreaListMember;
|
|
535
|
+
/** The row's `id` in that member (`isGatewayAreaRowId`), without an unpaired UTF-16 surrogate. */
|
|
536
|
+
id: string;
|
|
537
|
+
/**
|
|
538
|
+
* Why the gateway refuses the row: one or more words of lowercase ASCII letters joined by single
|
|
539
|
+
* hyphens, at most `gatewayConnectorContract.maximumRefusalRowReasonLength` characters, such as
|
|
540
|
+
* `no-managed-domain`. The words are the gateway's own; this package judges their form only, so a
|
|
541
|
+
* new word needs no release of it, and a reader shows a word it does not know as text. The form
|
|
542
|
+
* excludes digits, dots and every separator but the hyphen, so no address, count or dotted
|
|
543
|
+
* hostname fits, and a gateway never writes a hostname here.
|
|
544
|
+
*/
|
|
545
|
+
reason: string;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Why a gateway refused one area of a desired state it accepted as a whole.
|
|
550
|
+
*
|
|
551
|
+
* `rows` names the rows of the area's table the gateway refuses, as data (Linus ruling 212): 1 to
|
|
552
|
+
* `gatewayConnectorContract.maximumRefusalRows` entries, each `(member, id, reason)` once, in no
|
|
553
|
+
* particular order. A gateway names a row only when it judged that row; a gateway that could not
|
|
554
|
+
* judge names none (Linus ruling 216). When the gateway names no row the key is omitted: every
|
|
555
|
+
* refusal of a gateway built before the member, every refusal that is not about rows, and every
|
|
556
|
+
* refusal of a gateway that could not judge; `rows: undefined` and `rows: []` are refused. It adds
|
|
557
|
+
* to `detail` and replaces nothing: `reason` and `detail` keep their meaning, and the detail still
|
|
558
|
+
* states the findings as text. It is no promise that the table applies without the named rows: the
|
|
559
|
+
* detail can state further causes.
|
|
560
|
+
*
|
|
561
|
+
* Writer rule above the bound (Linus ruling 216): the bound counts entries, so a row with two
|
|
562
|
+
* reasons takes two. A gateway that refuses more entries than the bound names the first
|
|
563
|
+
* `maximumRefusalRows` in a fixed order (member order of `gatewayAreaMembers`, then row order of the
|
|
564
|
+
* pushed table, then reason), and its `detail` starts with the total count. The controller holds
|
|
565
|
+
* what is named and pushes again, so the rest arrives in the next refusal.
|
|
566
|
+
*
|
|
567
|
+
* Reader before writer: the refusal is exact-keys like the area state and the report, so a reader
|
|
568
|
+
* built before `rows` refuses the whole report that carries it (the apply answer, the hello and the
|
|
569
|
+
* status document). The gateway learns no version of its controller and cannot gate the member on
|
|
570
|
+
* it, so the controller moves to a release that reads `rows` before any gateway writes it, and
|
|
571
|
+
* neither side goes back below such a release once a report with rows is stored.
|
|
572
|
+
*/
|
|
573
|
+
export interface IGatewayAreaApplyRefusal {
|
|
574
|
+
reason: TGatewayApplyRefusal;
|
|
575
|
+
/** 1 to `gatewayConnectorContract.maximumRefusalDetailLength` characters. */
|
|
576
|
+
detail: string;
|
|
577
|
+
rows?: IGatewayAreaApplyRefusedRow[];
|
|
578
|
+
}
|
|
579
|
+
|
|
505
580
|
/** Where one area of one gateway stands after the last desired state it received. */
|
|
506
581
|
export interface IGatewayAreaApplyState {
|
|
507
582
|
area: TGatewayConfigArea;
|
|
@@ -517,7 +592,7 @@ export interface IGatewayAreaApplyState {
|
|
|
517
592
|
* owns that no document carried is `applied` with `revision: null`.
|
|
518
593
|
*/
|
|
519
594
|
state: 'applied' | 'rejected' | 'not-attempted';
|
|
520
|
-
refusal:
|
|
595
|
+
refusal: IGatewayAreaApplyRefusal | null;
|
|
521
596
|
}
|
|
522
597
|
|
|
523
598
|
/** What a gateway applied, as `applyDesiredState` answers and the status document carries it. */
|
|
@@ -670,6 +745,14 @@ const desiredStateKeys: TCompleteKeyList<IGatewayDesiredState, typeof desiredSta
|
|
|
670
745
|
const areaApplyStateKeyList = ['area', 'owner', 'digest', 'revision', 'state', 'refusal'] as const;
|
|
671
746
|
const areaApplyStateKeys: TCompleteKeyList<IGatewayAreaApplyState, typeof areaApplyStateKeyList> =
|
|
672
747
|
areaApplyStateKeyList;
|
|
748
|
+
const areaApplyRefusalKeyList = ['reason', 'detail', 'rows'] as const;
|
|
749
|
+
const areaApplyRefusalKeys: TCompleteKeyList<IGatewayAreaApplyRefusal, typeof areaApplyRefusalKeyList> =
|
|
750
|
+
areaApplyRefusalKeyList;
|
|
751
|
+
/** `rows` is optional: a refusal of a gateway built before it carries exactly these. */
|
|
752
|
+
const areaApplyRefusalRequiredKeys = ['reason', 'detail'] as const satisfies readonly (keyof IGatewayAreaApplyRefusal)[];
|
|
753
|
+
const areaApplyRefusedRowKeyList = ['member', 'id', 'reason'] as const;
|
|
754
|
+
const areaApplyRefusedRowKeys: TCompleteKeyList<IGatewayAreaApplyRefusedRow, typeof areaApplyRefusedRowKeyList> =
|
|
755
|
+
areaApplyRefusedRowKeyList;
|
|
673
756
|
const applyReportKeyList = ['epoch', 'appliedRevision', 'areas'] as const;
|
|
674
757
|
const applyReportKeys: TCompleteKeyList<IGatewayApplyReport, typeof applyReportKeyList> = applyReportKeyList;
|
|
675
758
|
const statusDocumentKeyList = [
|
|
@@ -832,6 +915,62 @@ export const validateGatewayDesiredState = (
|
|
|
832
915
|
];
|
|
833
916
|
};
|
|
834
917
|
|
|
918
|
+
const refusedRowReason = /^[a-z]+(?:-[a-z]+)*$/;
|
|
919
|
+
|
|
920
|
+
/** A member of the area's `gatewayAreaMembers` that holds rows, not one value. */
|
|
921
|
+
const isAreaListMember = (areaArg: TGatewayConfigArea, memberArg: unknown): boolean => (
|
|
922
|
+
typeof memberArg === 'string'
|
|
923
|
+
&& (gatewayAreaMembers[areaArg] as readonly string[]).includes(memberArg)
|
|
924
|
+
&& !(gatewayAreaSingletonMembers[areaArg] as readonly string[]).includes(memberArg)
|
|
925
|
+
);
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* The rows one area refusal names (`IGatewayAreaApplyRefusal.rows`): 1 to `maximumRefusalRows`
|
|
929
|
+
* entries of exactly `{ member, id, reason }`, each triple once. The member is judged against the
|
|
930
|
+
* refused area only when that area is one; an unknown area is refused by its own check.
|
|
931
|
+
*/
|
|
932
|
+
const validateRefusedRows = (valueArg: unknown, areaArg: unknown, pathArg: string): string[] => {
|
|
933
|
+
const { maximumRefusalRows, maximumRefusalRowReasonLength } = gatewayConnectorContract;
|
|
934
|
+
const rows = readDataElements(valueArg, maximumRefusalRows);
|
|
935
|
+
if (rows === null || rows.length === 0) {
|
|
936
|
+
return [`${pathArg} must be a dense list of 1 to ${maximumRefusalRows} rows`];
|
|
937
|
+
}
|
|
938
|
+
const errors: string[] = [];
|
|
939
|
+
const named = new Set<string>();
|
|
940
|
+
let repeated = false;
|
|
941
|
+
rows.forEach((rowArg, indexArg) => {
|
|
942
|
+
const path = `${pathArg}[${indexArg}]`;
|
|
943
|
+
const row = readExactDataRecord(rowArg, areaApplyRefusedRowKeys);
|
|
944
|
+
if (row === null) {
|
|
945
|
+
errors.push(`${path} must use its exact schema`);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (isGatewayConfigArea(areaArg) && !isAreaListMember(areaArg, row.member)) {
|
|
949
|
+
errors.push(`${path} member must be a list member of the ${areaArg} area`);
|
|
950
|
+
}
|
|
951
|
+
// A row id of a table meets the table's strict-JSON check, which refuses an unpaired surrogate;
|
|
952
|
+
// the report does not run that check, so the id is held to it here (Linus ruling 216 point 3).
|
|
953
|
+
if (!isGatewayAreaRowId(row.id) || validateControllerStrictJson(row.id, `${path} id`).length > 0) {
|
|
954
|
+
errors.push(`${path} id must be a row id of 1 to ${gatewayAreaContentContract.maximumRowIdLength} characters `
|
|
955
|
+
+ 'without a control character or an unpaired UTF-16 surrogate');
|
|
956
|
+
}
|
|
957
|
+
if (typeof row.reason !== 'string' || row.reason.length > maximumRefusalRowReasonLength
|
|
958
|
+
|| !refusedRowReason.test(row.reason)) {
|
|
959
|
+
errors.push(`${path} reason must be lowercase letter words joined by single hyphens, at most `
|
|
960
|
+
+ `${maximumRefusalRowReasonLength} characters`);
|
|
961
|
+
}
|
|
962
|
+
if (typeof row.member === 'string' && typeof row.id === 'string' && typeof row.reason === 'string') {
|
|
963
|
+
const key = JSON.stringify([row.member, row.id, row.reason]);
|
|
964
|
+
repeated ||= named.has(key);
|
|
965
|
+
named.add(key);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
if (repeated) {
|
|
969
|
+
errors.push(`${pathArg} must name each member, id and reason once`);
|
|
970
|
+
}
|
|
971
|
+
return errors;
|
|
972
|
+
};
|
|
973
|
+
|
|
835
974
|
const validateAreaApplyState = (valueArg: unknown, pathArg: string): string[] => {
|
|
836
975
|
const record = readExactDataRecord(valueArg, areaApplyStateKeys);
|
|
837
976
|
if (record === null) {
|
|
@@ -857,8 +996,8 @@ const validateAreaApplyState = (valueArg: unknown, pathArg: string): string[] =>
|
|
|
857
996
|
if (record.state === 'applied') {
|
|
858
997
|
errors.push(`${pathArg} refusal must be null for an applied area`);
|
|
859
998
|
}
|
|
860
|
-
const refusal =
|
|
861
|
-
if (refusal === null) {
|
|
999
|
+
const refusal = readDataProperties(record.refusal);
|
|
1000
|
+
if (refusal === null || !hasExactKeys(refusal, areaApplyRefusalRequiredKeys, areaApplyRefusalKeys)) {
|
|
862
1001
|
errors.push(`${pathArg} refusal must be null or use its exact schema`);
|
|
863
1002
|
return errors;
|
|
864
1003
|
}
|
|
@@ -867,6 +1006,9 @@ const validateAreaApplyState = (valueArg: unknown, pathArg: string): string[] =>
|
|
|
867
1006
|
}
|
|
868
1007
|
errors.push(...validateBoundedString(refusal.detail, `${pathArg} refusal detail`,
|
|
869
1008
|
gatewayConnectorContract.maximumRefusalDetailLength));
|
|
1009
|
+
if (Object.hasOwn(refusal, 'rows')) {
|
|
1010
|
+
errors.push(...validateRefusedRows(refusal.rows, record.area, `${pathArg} refusal rows`));
|
|
1011
|
+
}
|
|
870
1012
|
return errors;
|
|
871
1013
|
};
|
|
872
1014
|
|
package/ts/data/serviceports.ts
CHANGED
|
@@ -8,6 +8,19 @@ export type TServiceTargetProtocol =
|
|
|
8
8
|
|
|
9
9
|
export type TServiceTargetPortRef = string | number;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Who may remove a Service domain entry (`IServiceDomainRoute.owner`): the deployment declaration
|
|
13
|
+
* the controller promotes (`declaration`) or the Service itself (`service`).
|
|
14
|
+
*/
|
|
15
|
+
export const serviceDomainOwners = Object.freeze(['declaration', 'service'] as const);
|
|
16
|
+
|
|
17
|
+
/** One of `serviceDomainOwners`. */
|
|
18
|
+
export type TServiceDomainOwner = typeof serviceDomainOwners[number];
|
|
19
|
+
|
|
20
|
+
export const isServiceDomainOwner = (valueArg: unknown): valueArg is TServiceDomainOwner => (
|
|
21
|
+
(serviceDomainOwners as readonly unknown[]).includes(valueArg)
|
|
22
|
+
);
|
|
23
|
+
|
|
11
24
|
export interface IServiceTargetPort {
|
|
12
25
|
name: string;
|
|
13
26
|
port: number;
|
|
@@ -32,6 +45,29 @@ export interface IServiceDomainRoute {
|
|
|
32
45
|
* Producers should persist an explicit boolean when gateway DNS reconciliation is enabled.
|
|
33
46
|
*/
|
|
34
47
|
proxied?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Who may remove the entry; exposure stays `sourceProfileRef`'s alone (Linus rulings 230 point 1
|
|
50
|
+
* and 232).
|
|
51
|
+
*
|
|
52
|
+
* - `declaration`: route promotion removes the entry when the deployment declaration it promotes
|
|
53
|
+
* omits the hostname. Route promotion removes no other entry, and a declaration that states no
|
|
54
|
+
* routes runs none: it makes no statement about hostnames.
|
|
55
|
+
* - `service`: only a Service update removes the entry. A declaration that states the hostname
|
|
56
|
+
* promotes and verifies its route, and the entry stays Service-owned.
|
|
57
|
+
*
|
|
58
|
+
* A Service create may state either value; absent gives `service`. A Service update that omits it
|
|
59
|
+
* keeps the stored owner of the hostname, and a hostname the update attaches becomes `service`. A
|
|
60
|
+
* Service write refuses any other stated value. A hostname a deployment declaration attaches for
|
|
61
|
+
* the first time starts by its profile: Public gives `declaration`, any other profile `service`.
|
|
62
|
+
* A declaration never changes a stored owner: `IDeploymentRouteRequest` carries none and a route
|
|
63
|
+
* stating one is refused, and `publicDomains` holds hostnames only. An App Store template states
|
|
64
|
+
* none (`IAppStoreVersionConfig.domains`).
|
|
65
|
+
*
|
|
66
|
+
* A stored entry without a valid owner (absent, `null`, any other value) reads as `service`. The
|
|
67
|
+
* normalizers (`normalizeServicePortConfig`, `normalizeServicePortData`) carry the member as
|
|
68
|
+
* stored, whatever it holds, and never judge it.
|
|
69
|
+
*/
|
|
70
|
+
owner?: TServiceDomainOwner;
|
|
35
71
|
}
|
|
36
72
|
|
|
37
73
|
export interface IServicePublicPortMapping {
|