@intentius/chant 0.39.0 → 0.41.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/dist/apply.d.ts +171 -0
- package/dist/apply.d.ts.map +1 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/codegen/naming.d.ts +48 -1
- package/dist/codegen/naming.d.ts.map +1 -1
- package/dist/codegen/validate.d.ts +31 -0
- package/dist/codegen/validate.d.ts.map +1 -1
- package/dist/discovery/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apply.test.ts +169 -0
- package/src/apply.ts +249 -0
- package/src/cli/commands/doctor.test.ts +45 -0
- package/src/cli/commands/doctor.ts +40 -0
- package/src/codegen/naming.test.ts +129 -0
- package/src/codegen/naming.ts +72 -1
- package/src/codegen/validate.test.ts +86 -0
- package/src/codegen/validate.ts +74 -0
- package/src/discovery/index.ts +59 -0
- package/src/discovery/params-cjs-warning.test.ts +75 -0
- package/src/index.ts +1 -0
package/dist/apply.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apply contract (#1446) — what a lexicon's applier is allowed to mean.
|
|
3
|
+
*
|
|
4
|
+
* The peer of `./observation.ts`, and it exists for the same reason on the other
|
|
5
|
+
* side of the lifecycle.
|
|
6
|
+
*
|
|
7
|
+
* The read path had two ways to return nothing for a declared entity and no way
|
|
8
|
+
* to tell them apart — "the provider says it is absent" versus "I never looked"
|
|
9
|
+
* — and the second was classifying as `create`. #1089 made that a tri-state and
|
|
10
|
+
* #1201 built a conformance suite so a lexicon could not pass by returning a
|
|
11
|
+
* well-shaped result that still proposed a create.
|
|
12
|
+
*
|
|
13
|
+
* The write path had the identical hole. An applier could skip a resource and
|
|
14
|
+
* report nothing:
|
|
15
|
+
*
|
|
16
|
+
* const mapper = MAPPERS[r.kind];
|
|
17
|
+
* if (!mapper) {
|
|
18
|
+
* console.log(`skip: no mapper for kind ${r.kind}`);
|
|
19
|
+
* continue; // never appears in `applied`, or anywhere
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* A caller receiving `{ applied: [...] }` could not distinguish a complete apply
|
|
23
|
+
* from one that dropped half the manifest, and `ApplyOp` had nothing to gate on.
|
|
24
|
+
* A `console.log` on stdout is not a signal in a result, the same way a warn on
|
|
25
|
+
* stderr was not a signal in a change set (#1447 was the concrete bug; #1457
|
|
26
|
+
* found the same shape in two more appliers).
|
|
27
|
+
*
|
|
28
|
+
* The contract is a tri-state, per resource in the plan:
|
|
29
|
+
*
|
|
30
|
+
* - **APPLIED** — the provider was called and converged. Carries the action
|
|
31
|
+
* (`created` / `updated` / `unchanged`) and the physical id when resolved.
|
|
32
|
+
* - **PRUNED** — owned, no longer declared, deleted.
|
|
33
|
+
* - **NOT-ATTEMPTED** — carrying a total {@link NotAttemptedReason}. Never
|
|
34
|
+
* silent, never inferred from absence.
|
|
35
|
+
*
|
|
36
|
+
* The three are **disjoint and total**: every resource the applier was given
|
|
37
|
+
* appears in exactly one. That is the assertion the conformance suite exists to
|
|
38
|
+
* make, and the one the gcp skip failed.
|
|
39
|
+
*
|
|
40
|
+
* Compatibility: an applier may keep returning its own shape. The envelope is
|
|
41
|
+
* discriminated by its literal `apply: "v1"` field, the same mechanism
|
|
42
|
+
* `observation: "v1"` uses, so an un-migrated applier normalizes to "everything
|
|
43
|
+
* I was handed, I attempted" and nothing breaks. Reporting NOT-ATTEMPTED
|
|
44
|
+
* requires the envelope — which is the point: you cannot claim the guarantee
|
|
45
|
+
* without adopting the shape that can express its absence.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Why a resource in the plan was not attempted. Total: an applier that skips a
|
|
49
|
+
* resource must pick one of these, and consumers may switch exhaustively.
|
|
50
|
+
*
|
|
51
|
+
* - `unsupported-kind` — the lexicon has no mapper/writer for this type. The
|
|
52
|
+
* resource is declared and simply was not written.
|
|
53
|
+
* - `no-credentials` — no usable credentials/authorization for the target.
|
|
54
|
+
* - `no-binding` — the environment resolves to no concrete target (no cluster
|
|
55
|
+
* context, no subscription, no resource group, no endpoint).
|
|
56
|
+
* - `dependency-failed` — an upstream resource in the same run failed, so this
|
|
57
|
+
* one was never reached. Distinct from a failure of its own.
|
|
58
|
+
* - `filtered` — reached but deliberately withheld by a caller-requested scope.
|
|
59
|
+
* - `not-prunable` — an owned orphan of a kind the applier cannot enumerate or
|
|
60
|
+
* delete. The prune-side shape: not "there was nothing to prune" but "I could
|
|
61
|
+
* not look for anything to prune here".
|
|
62
|
+
*/
|
|
63
|
+
export type NotAttemptedReason = "unsupported-kind" | "no-credentials" | "no-binding" | "dependency-failed" | "filtered" | "not-prunable";
|
|
64
|
+
/** Every legal {@link NotAttemptedReason}, for validation and conformance checks. */
|
|
65
|
+
export declare const NOT_ATTEMPTED_REASONS: readonly NotAttemptedReason[];
|
|
66
|
+
/** True when `value` is a legal {@link NotAttemptedReason}. */
|
|
67
|
+
export declare function isNotAttemptedReason(value: unknown): value is NotAttemptedReason;
|
|
68
|
+
/** What an apply did to a resource that it did reach. */
|
|
69
|
+
export type AppliedAction = "created" | "updated" | "unchanged";
|
|
70
|
+
/** Every legal {@link AppliedAction}. */
|
|
71
|
+
export declare const APPLIED_ACTIONS: readonly AppliedAction[];
|
|
72
|
+
/** How a resource is named across appliers whose native vocabularies differ. */
|
|
73
|
+
export interface ApplyRef {
|
|
74
|
+
/**
|
|
75
|
+
* The provider's own type name — a CNRM `kind`, an ARM `type`, a
|
|
76
|
+
* CloudFormation resource type, a Fly entity class. Kept verbatim rather than
|
|
77
|
+
* normalized into a chant vocabulary, so an applier stays true to its target.
|
|
78
|
+
*/
|
|
79
|
+
kind: string;
|
|
80
|
+
/** The resource's name within its scope. */
|
|
81
|
+
name: string;
|
|
82
|
+
}
|
|
83
|
+
/** APPLIED — the provider was called and the resource converged. */
|
|
84
|
+
export interface AppliedResource extends ApplyRef {
|
|
85
|
+
action: AppliedAction;
|
|
86
|
+
/** Provider-assigned identifier, when the response carried one. */
|
|
87
|
+
physicalId?: string;
|
|
88
|
+
}
|
|
89
|
+
/** PRUNED — owned, no longer declared, deleted. */
|
|
90
|
+
export interface PrunedResource extends ApplyRef {
|
|
91
|
+
/**
|
|
92
|
+
* False when the delete was a no-op because the resource was already gone.
|
|
93
|
+
* Still PRUNED: the applier looked, decided, and acted.
|
|
94
|
+
*/
|
|
95
|
+
deleted: boolean;
|
|
96
|
+
}
|
|
97
|
+
/** NOT-ATTEMPTED — no provider call was made, and why. */
|
|
98
|
+
export interface NotAttemptedResource extends ApplyRef {
|
|
99
|
+
reason: NotAttemptedReason;
|
|
100
|
+
/** Detail for the operator: the status and body, the missing binding, the unsupported kind. */
|
|
101
|
+
detail?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The apply envelope. Explicitly versioned: `apply: "v1"`, which discriminates
|
|
105
|
+
* it from an applier's own return shape.
|
|
106
|
+
*/
|
|
107
|
+
export interface ApplyResult {
|
|
108
|
+
/** Discriminant + wire version. */
|
|
109
|
+
readonly apply: "v1";
|
|
110
|
+
applied: AppliedResource[];
|
|
111
|
+
pruned?: PrunedResource[];
|
|
112
|
+
/** Omit or leave empty when everything in the plan was attempted. */
|
|
113
|
+
notAttempted?: NotAttemptedResource[];
|
|
114
|
+
}
|
|
115
|
+
/** Normalized form every consumer works with. All three arrays always present. */
|
|
116
|
+
export interface NormalizedApply {
|
|
117
|
+
applied: AppliedResource[];
|
|
118
|
+
pruned: PrunedResource[];
|
|
119
|
+
notAttempted: NotAttemptedResource[];
|
|
120
|
+
}
|
|
121
|
+
/** True when `value` is the versioned {@link ApplyResult} envelope. */
|
|
122
|
+
export declare function isApplyResult(value: unknown): value is ApplyResult;
|
|
123
|
+
/**
|
|
124
|
+
* Build an {@link ApplyResult}. Appliers use this rather than writing the
|
|
125
|
+
* discriminant by hand.
|
|
126
|
+
*/
|
|
127
|
+
export declare function applyResult(applied: AppliedResource[], pruned?: PrunedResource[], notAttempted?: NotAttemptedResource[]): ApplyResult;
|
|
128
|
+
/**
|
|
129
|
+
* Normalize an applier's return value.
|
|
130
|
+
*
|
|
131
|
+
* A non-envelope value normalizes to "everything I was handed, I attempted" —
|
|
132
|
+
* an empty `notAttempted`. That is the compatibility path, and it is also
|
|
133
|
+
* exactly the claim an un-migrated applier is implicitly making, so nothing is
|
|
134
|
+
* invented on its behalf.
|
|
135
|
+
*
|
|
136
|
+
* `undefined` normalizes to three empty arrays. An applier that means "I applied
|
|
137
|
+
* nothing because I could not" must say so with {@link notAttemptedAll} rather
|
|
138
|
+
* than returning nothing, for the same reason `unobservedAll` exists on the read
|
|
139
|
+
* side.
|
|
140
|
+
*/
|
|
141
|
+
export declare function normalizeApply(value: ApplyResult | Partial<NormalizedApply> | undefined): NormalizedApply;
|
|
142
|
+
/**
|
|
143
|
+
* Mark every named resource NOT-ATTEMPTED with one reason — the whole-run
|
|
144
|
+
* failure case (no credentials, no binding, the transport never came up). Core
|
|
145
|
+
* applies this when an applier throws, so a thrown apply degrades to an honest
|
|
146
|
+
* "did not attempt" per resource instead of an empty result that reads as a
|
|
147
|
+
* successful no-op.
|
|
148
|
+
*/
|
|
149
|
+
export declare function notAttemptedAll(refs: Iterable<ApplyRef>, reason: NotAttemptedReason, detail?: string): NotAttemptedResource[];
|
|
150
|
+
/** A resource's identity within one apply, for disjointness checks. */
|
|
151
|
+
export declare function applyRefKey(ref: ApplyRef): string;
|
|
152
|
+
/**
|
|
153
|
+
* Every resource that appears in more than one bucket. Empty is the contract;
|
|
154
|
+
* a non-empty result means the applier both wrote and skipped the same
|
|
155
|
+
* resource, which is not a state that can be true.
|
|
156
|
+
*
|
|
157
|
+
* Pruned is checked against the other two but not against itself: an applier
|
|
158
|
+
* may legitimately apply a resource and prune a different, same-named one only
|
|
159
|
+
* if their kinds differ, and {@link applyRefKey} already separates those.
|
|
160
|
+
*/
|
|
161
|
+
export declare function overlappingRefs(result: NormalizedApply): string[];
|
|
162
|
+
/**
|
|
163
|
+
* Resources in `plan` that the result accounts for in no bucket — the silent
|
|
164
|
+
* drop this contract exists to make impossible.
|
|
165
|
+
*
|
|
166
|
+
* The conformance suite's central assertion. Before #1447, gcp's applier failed
|
|
167
|
+
* exactly this: an unmapped kind was in the plan, in no bucket, and the result
|
|
168
|
+
* looked complete.
|
|
169
|
+
*/
|
|
170
|
+
export declare function unaccountedRefs(plan: Iterable<ApplyRef>, result: NormalizedApply): string[];
|
|
171
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../src/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,UAAU,GACV,cAAc,CAAC;AAEnB,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAO9D,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED,yDAAyD;AACzD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAAwC,CAAC;AAE7F,gFAAgF;AAChF,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,MAAM,EAAE,aAAa,CAAC;IACtB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;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AG,EAAE,QAAQ,GAAG,MAAM,CAEjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAYjE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAM3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/doctor.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/doctor.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAoSvE"}
|
package/dist/codegen/naming.d.ts
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Collision-free naming strategy for TypeScript class names.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 6-phase algorithm:
|
|
5
5
|
* 1. Priority names (backward compatibility)
|
|
6
|
+
* 1a. Reserved names — names this lexicon has already published (chant #1459)
|
|
6
7
|
* 2. Priority aliases (additional short names)
|
|
7
8
|
* 3. Short names (last segment of type)
|
|
8
9
|
* 4. Collision resolution (service-prefixed)
|
|
9
10
|
* 5. Property type aliases (globally unique defs)
|
|
11
|
+
*
|
|
12
|
+
* ## Why phase 1a exists
|
|
13
|
+
*
|
|
14
|
+
* Phases 3 and 4 assign a short name to whoever asks first and service-qualify
|
|
15
|
+
* everyone after. Membership of that contest is the whole input set, so a
|
|
16
|
+
* resource's name was a function of its NEIGHBOURS: removing
|
|
17
|
+
* `AWS::Athena::Session` upstream freed `Session`, and `AWS::Macie::Session`
|
|
18
|
+
* silently changed from `MacieSession` to `Session` — a breaking rename for a
|
|
19
|
+
* resource whose schema had not moved. Adding a resource does the same in
|
|
20
|
+
* reverse: `AWS::QuickSight::Space` appearing renamed `AWS::SageMaker::Space`
|
|
21
|
+
* from `Space` to `SageMakerSpace`.
|
|
22
|
+
*
|
|
23
|
+
* Worse, it is reversible. These are read-only registry types that come and go,
|
|
24
|
+
* so a name could flip back on the next upgrade and break consumers again.
|
|
25
|
+
*
|
|
26
|
+
* Reserved names invert the bias: a name that has already shipped belongs to
|
|
27
|
+
* the type that shipped it, and a newcomer colliding with it gets qualified
|
|
28
|
+
* instead. A published name then changes only when its own type disappears,
|
|
29
|
+
* which is a genuine breaking change rather than an incidental one.
|
|
10
30
|
*/
|
|
11
31
|
/**
|
|
12
32
|
* Minimal input required by the naming strategy — avoids coupling
|
|
@@ -35,7 +55,34 @@ export interface NamingConfig {
|
|
|
35
55
|
shortName: (typeName: string) => string;
|
|
36
56
|
/** Extract the service name from a type name (e.g. "Vendor::Service::Resource" → "Service"). */
|
|
37
57
|
serviceName: (typeName: string) => string;
|
|
58
|
+
/**
|
|
59
|
+
* chant #1459 — spec type name → the TypeScript name this lexicon has
|
|
60
|
+
* already published for it, normally read from the committed
|
|
61
|
+
* `surface.snapshot.json` via {@link reservedNamesFromSnapshot}.
|
|
62
|
+
*
|
|
63
|
+
* Claimed before short names are contested, so a shipped name is not taken
|
|
64
|
+
* away from its owner by an unrelated upstream change. Omit for a lexicon
|
|
65
|
+
* with no published surface yet; an entry for a type that is no longer in
|
|
66
|
+
* the input is ignored, so a removed type frees its name for reuse.
|
|
67
|
+
*/
|
|
68
|
+
reservedNames?: Record<string, string>;
|
|
38
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* The names a lexicon has already published, read from a committed surface
|
|
72
|
+
* snapshot (chant #1459).
|
|
73
|
+
*
|
|
74
|
+
* The snapshot is keyed by TypeScript name with the spec type inside, which is
|
|
75
|
+
* exactly the mapping phase 1a needs, inverted. Only `resource` entries are
|
|
76
|
+
* reserved: property-type names are derived from their owning resource's name
|
|
77
|
+
* (phase 5), so pinning the resource pins them, and reserving them separately
|
|
78
|
+
* would freeze aliases that are meant to follow their parent.
|
|
79
|
+
*/
|
|
80
|
+
export declare function reservedNamesFromSnapshot(snapshot: {
|
|
81
|
+
entries?: Record<string, {
|
|
82
|
+
kind?: string;
|
|
83
|
+
resourceType?: string;
|
|
84
|
+
}>;
|
|
85
|
+
} | undefined): Record<string, string>;
|
|
39
86
|
export declare class NamingStrategy {
|
|
40
87
|
private config;
|
|
41
88
|
private assigned;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/codegen/naming.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/codegen/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CA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C,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAInC,sDAAsD;IACtD,cAAc,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAcpC,8CAA8C;IAC9C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;CAGvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5E"}
|
|
@@ -14,6 +14,11 @@ export interface ValidateResult {
|
|
|
14
14
|
success: boolean;
|
|
15
15
|
checks: ValidateCheck[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Set by the publish workflow to arm the release-time surface gate
|
|
19
|
+
* (chant #1473). Absent in ordinary CI, where upstream drift is expected.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RELEASE_GATE_ENV = "CHANT_RELEASE_GATE";
|
|
17
22
|
export interface LexiconValidationConfig {
|
|
18
23
|
/** Filename of the lexicon JSON (e.g. "lexicon-mydom.json") */
|
|
19
24
|
lexiconJsonFilename: string;
|
|
@@ -29,6 +34,32 @@ export interface LexiconValidationConfig {
|
|
|
29
34
|
requiredNamesMatchSubstring?: boolean;
|
|
30
35
|
/** Base path of the lexicon package */
|
|
31
36
|
basePath: string;
|
|
37
|
+
/**
|
|
38
|
+
* chant #1473 — this lexicon's release is gated on the generated API
|
|
39
|
+
* matching the committed `surface.snapshot.json`.
|
|
40
|
+
*
|
|
41
|
+
* Two conditions, both required. The lexicon opts in here, AND
|
|
42
|
+
* {@link RELEASE_GATE_ENV} is set — which the publish workflow does and
|
|
43
|
+
* ordinary CI does not.
|
|
44
|
+
*
|
|
45
|
+
* The env half is not caution, it is correctness. `validate` runs on every
|
|
46
|
+
* PR, and the upstream a lexicon generates from can move at any time: the
|
|
47
|
+
* CloudFormation archive republishes schemas several times a day, and some
|
|
48
|
+
* of those edits do change the surface. A hard surface check on every PR
|
|
49
|
+
* would turn any unrelated change red the moment upstream moved, which is
|
|
50
|
+
* the same trap the spec pin fell into one level down. Drift between
|
|
51
|
+
* releases is expected and is what the scheduled lexicon-upgrade job exists
|
|
52
|
+
* to report (#1423).
|
|
53
|
+
*
|
|
54
|
+
* What must never happen is *publishing* a surface nobody reviewed. That is
|
|
55
|
+
* a release-time property, so it is checked at release time.
|
|
56
|
+
*
|
|
57
|
+
* Opt-in per lexicon because k8s and azure are currently adrift from their
|
|
58
|
+
* own baselines (393 and 483 entries, #1475).
|
|
59
|
+
*/
|
|
60
|
+
checkSurfaceSnapshot?: boolean;
|
|
61
|
+
/** Environment to read {@link RELEASE_GATE_ENV} from. Defaults to `process.env`; overridden in tests. */
|
|
62
|
+
env?: NodeJS.ProcessEnv;
|
|
32
63
|
/** Path to the generated directory (defaults to basePath/src/generated) */
|
|
33
64
|
generatedDir?: string;
|
|
34
65
|
/** Coverage thresholds (optional) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/codegen/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/codegen/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGvF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yGAAyG;IACzG,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC,CAqJvG;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAWlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAA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AAe,CAAC,CA0RjG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from "./import/parser.js";
|
|
|
48
48
|
export * from "./import/generator.js";
|
|
49
49
|
export * from "./lexicon.js";
|
|
50
50
|
export * from "./observation.js";
|
|
51
|
+
export * from "./apply.js";
|
|
51
52
|
export * from "./deep-observation.js";
|
|
52
53
|
export * from "./owner-chain.js";
|
|
53
54
|
export * from "./lexicon-integrity.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,C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EACL,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAClE,cAAc,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5F,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
NOT_ATTEMPTED_REASONS,
|
|
4
|
+
isNotAttemptedReason,
|
|
5
|
+
isApplyResult,
|
|
6
|
+
applyResult,
|
|
7
|
+
normalizeApply,
|
|
8
|
+
notAttemptedAll,
|
|
9
|
+
applyRefKey,
|
|
10
|
+
overlappingRefs,
|
|
11
|
+
unaccountedRefs,
|
|
12
|
+
type ApplyRef,
|
|
13
|
+
} from "./apply";
|
|
14
|
+
|
|
15
|
+
const ref = (kind: string, name: string): ApplyRef => ({ kind, name });
|
|
16
|
+
|
|
17
|
+
describe("NotAttemptedReason is total (#1446)", () => {
|
|
18
|
+
test("every reason is recognised, and nothing else is", () => {
|
|
19
|
+
for (const r of NOT_ATTEMPTED_REASONS) expect(isNotAttemptedReason(r)).toBe(true);
|
|
20
|
+
expect(isNotAttemptedReason("skipped")).toBe(false);
|
|
21
|
+
expect(isNotAttemptedReason("")).toBe(false);
|
|
22
|
+
expect(isNotAttemptedReason(undefined)).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// The write-side peer of UnobservedReason. Free-form strings are what let the
|
|
26
|
+
// gcp skip say "no mapper for kind X" to stdout and nothing to the caller.
|
|
27
|
+
test("the prune-side reason exists, because it is a different fact", () => {
|
|
28
|
+
expect(NOT_ATTEMPTED_REASONS).toContain("not-prunable");
|
|
29
|
+
expect(NOT_ATTEMPTED_REASONS).toContain("unsupported-kind");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("the envelope discriminates itself (#1446)", () => {
|
|
34
|
+
test("isApplyResult recognises the versioned shape only", () => {
|
|
35
|
+
expect(isApplyResult(applyResult([]))).toBe(true);
|
|
36
|
+
expect(isApplyResult({ applied: [], pruned: [] })).toBe(false);
|
|
37
|
+
expect(isApplyResult({ apply: "v2" })).toBe(false);
|
|
38
|
+
expect(isApplyResult(null)).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("applyResult omits empty buckets rather than emitting empty arrays", () => {
|
|
42
|
+
expect(applyResult([{ ...ref("Bucket", "a"), action: "created" }])).toEqual({
|
|
43
|
+
apply: "v1",
|
|
44
|
+
applied: [{ kind: "Bucket", name: "a", action: "created" }],
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("normalizeApply (#1446)", () => {
|
|
50
|
+
test("an un-migrated applier's shape means 'everything I was handed, I attempted'", () => {
|
|
51
|
+
// The compatibility path. Nothing is invented on its behalf — an empty
|
|
52
|
+
// notAttempted is exactly the claim that shape implicitly makes.
|
|
53
|
+
const n = normalizeApply({ applied: [{ ...ref("K", "a"), action: "created" }] });
|
|
54
|
+
expect(n.notAttempted).toEqual([]);
|
|
55
|
+
expect(n.pruned).toEqual([]);
|
|
56
|
+
expect(n.applied).toHaveLength(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("the envelope's notAttempted survives normalization", () => {
|
|
60
|
+
const n = normalizeApply(
|
|
61
|
+
applyResult([], [], [{ ...ref("SQLInstance", "db"), reason: "unsupported-kind" }]),
|
|
62
|
+
);
|
|
63
|
+
expect(n.notAttempted).toEqual([{ kind: "SQLInstance", name: "db", reason: "unsupported-kind" }]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// The read side has the same rule for the same reason: returning nothing must
|
|
67
|
+
// not be a way to claim success over work that never happened.
|
|
68
|
+
test("undefined normalizes to empty, so 'I could not' must be said explicitly", () => {
|
|
69
|
+
expect(normalizeApply(undefined)).toEqual({ applied: [], pruned: [], notAttempted: [] });
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("notAttemptedAll (#1446)", () => {
|
|
74
|
+
test("marks a whole plan with one reason, for the run-level failure", () => {
|
|
75
|
+
const out = notAttemptedAll([ref("K", "a"), ref("K", "b")], "no-credentials", "no token");
|
|
76
|
+
expect(out).toEqual([
|
|
77
|
+
{ kind: "K", name: "a", reason: "no-credentials", detail: "no token" },
|
|
78
|
+
{ kind: "K", name: "b", reason: "no-credentials", detail: "no token" },
|
|
79
|
+
]);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("omits detail when none is given", () => {
|
|
83
|
+
expect(notAttemptedAll([ref("K", "a")], "no-binding")).toEqual([
|
|
84
|
+
{ kind: "K", name: "a", reason: "no-binding" },
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("the three buckets are disjoint (#1446)", () => {
|
|
90
|
+
test("no overlap is the contract", () => {
|
|
91
|
+
expect(
|
|
92
|
+
overlappingRefs({
|
|
93
|
+
applied: [{ ...ref("K", "a"), action: "created" }],
|
|
94
|
+
pruned: [{ ...ref("K", "b"), deleted: true }],
|
|
95
|
+
notAttempted: [{ ...ref("K", "c"), reason: "unsupported-kind" }],
|
|
96
|
+
}),
|
|
97
|
+
).toEqual([]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// A resource cannot be both written and skipped. An applier reporting that has
|
|
101
|
+
// a bug the return shape would otherwise hide.
|
|
102
|
+
test("the same resource in two buckets is reported", () => {
|
|
103
|
+
expect(
|
|
104
|
+
overlappingRefs({
|
|
105
|
+
applied: [{ ...ref("K", "a"), action: "created" }],
|
|
106
|
+
pruned: [],
|
|
107
|
+
notAttempted: [{ ...ref("K", "a"), reason: "filtered" }],
|
|
108
|
+
}),
|
|
109
|
+
).toEqual(["K/a"]);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("same name, different kind, is not an overlap", () => {
|
|
113
|
+
expect(
|
|
114
|
+
overlappingRefs({
|
|
115
|
+
applied: [{ ...ref("Bucket", "x"), action: "created" }],
|
|
116
|
+
pruned: [{ ...ref("Topic", "x"), deleted: true }],
|
|
117
|
+
notAttempted: [],
|
|
118
|
+
}),
|
|
119
|
+
).toEqual([]);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("nothing in the plan is dropped (#1446)", () => {
|
|
124
|
+
// The suite's central assertion, and the one gcp failed before #1447: the
|
|
125
|
+
// unmapped kind was in the plan, in no bucket, and the result looked complete.
|
|
126
|
+
test("a plan entry in no bucket is reported", () => {
|
|
127
|
+
const plan = [ref("Bucket", "mapped"), ref("SQLInstance", "unmapped")];
|
|
128
|
+
const dropped = unaccountedRefs(plan, {
|
|
129
|
+
applied: [{ ...ref("Bucket", "mapped"), action: "created" }],
|
|
130
|
+
pruned: [],
|
|
131
|
+
notAttempted: [],
|
|
132
|
+
});
|
|
133
|
+
expect(dropped).toEqual(["SQLInstance/unmapped"]);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("the same plan accounted for in notAttempted passes", () => {
|
|
137
|
+
const plan = [ref("Bucket", "mapped"), ref("SQLInstance", "unmapped")];
|
|
138
|
+
expect(
|
|
139
|
+
unaccountedRefs(plan, {
|
|
140
|
+
applied: [{ ...ref("Bucket", "mapped"), action: "created" }],
|
|
141
|
+
pruned: [],
|
|
142
|
+
notAttempted: [{ ...ref("SQLInstance", "unmapped"), reason: "unsupported-kind" }],
|
|
143
|
+
}),
|
|
144
|
+
).toEqual([]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("an empty plan is trivially accounted for", () => {
|
|
148
|
+
expect(unaccountedRefs([], { applied: [], pruned: [], notAttempted: [] })).toEqual([]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Prune deletes things the plan does not contain, by definition — so a pruned
|
|
152
|
+
// resource being outside the plan is correct, not a drop.
|
|
153
|
+
test("a pruned resource outside the plan is not a drop", () => {
|
|
154
|
+
expect(
|
|
155
|
+
unaccountedRefs([ref("Bucket", "keep")], {
|
|
156
|
+
applied: [{ ...ref("Bucket", "keep"), action: "unchanged" }],
|
|
157
|
+
pruned: [{ ...ref("Bucket", "orphan"), deleted: true }],
|
|
158
|
+
notAttempted: [],
|
|
159
|
+
}),
|
|
160
|
+
).toEqual([]);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe("applyRefKey", () => {
|
|
165
|
+
test("separates resources by kind and name", () => {
|
|
166
|
+
expect(applyRefKey(ref("Bucket", "x"))).toBe("Bucket/x");
|
|
167
|
+
expect(applyRefKey(ref("Topic", "x"))).not.toBe(applyRefKey(ref("Bucket", "x")));
|
|
168
|
+
});
|
|
169
|
+
});
|