@intentius/chant-lexicon-aws 0.58.0 → 0.60.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.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Curated enum overlay (chant #1497).
3
+ *
4
+ * The CloudFormation Registry spec declares `enum` on some properties and not
5
+ * on others, and the split does not follow how often a property is written:
6
+ * `AWS::SageMaker::NotebookInstance.InstanceType` is a union while
7
+ * `AWS::EC2::Instance.InstanceType` is a bare `string`. Where the spec is
8
+ * silent the generated type stops teaching the API, and a wrong value survives
9
+ * `tsc` and `chant build` to fail at deploy.
10
+ *
11
+ * This overlay is a checked-in list of `(CFN type, JSON pointer, values)`
12
+ * entries merged into the raw schema before parsing, so a curated enum reaches
13
+ * the generated `.d.ts` and the lexicon registry by exactly the path a spec
14
+ * enum reaches them. Nothing here is fetched at build time: the values live in
15
+ * `enum-overlay.json` beside this file, each with the source it was read from
16
+ * and the date it was read, so `scripts/refresh-enum-overlay.ts` can diff them
17
+ * later.
18
+ *
19
+ * Precedence: the overlay only fills gaps. An entry whose target already
20
+ * declares `enum` (from the Registry spec or from a cfn-lint patch) leaves the
21
+ * spec alone and reports itself as redundant. Upstream is refreshed on every
22
+ * `generate`, so it is the source that keeps tracking AWS; a hand list allowed
23
+ * to win would rot invisibly and would make the generated type depend on which
24
+ * of two sources happened to be newer. Reporting the overlap instead surfaces
25
+ * the entry for retirement the moment upstream catches up.
26
+ *
27
+ * An entry that matches nothing is an error, not a shrug: a renamed or removed
28
+ * property means the curated values are being applied to a property that no
29
+ * longer exists, and silence there is how an overlay goes stale.
30
+ */
31
+ /** Where an entry's values were read from, and enough detail to read them again. */
32
+ export type EnumOverlaySource = {
33
+ kind: "botocore";
34
+ /** Directory under `botocore/data`, e.g. `elbv2`. */
35
+ service: string;
36
+ /** API version directory, e.g. `2015-12-01`. */
37
+ apiVersion: string;
38
+ /** Shape name carrying the `enum`, e.g. `ProtocolEnum`. */
39
+ shape: string;
40
+ } | {
41
+ kind: "docs";
42
+ /** Page the values were transcribed from. */
43
+ url: string;
44
+ };
45
+ /** One curated enum. */
46
+ export interface EnumOverlayEntry {
47
+ /** CloudFormation type name, e.g. `AWS::EC2::Instance`. */
48
+ type: string;
49
+ /**
50
+ * JSON pointer to the property inside that type's Registry schema, either
51
+ * `/properties/<Name>` or `/definitions/<Def>/properties/<Name>`.
52
+ */
53
+ pointer: string;
54
+ /**
55
+ * Name for the `definitions` entry this creates. The generator turns it into
56
+ * an exported type named `<class>_<enumName>`, e.g. `Function_Runtime`.
57
+ */
58
+ enumName: string;
59
+ /** Why this property earned a place in the first curated set. */
60
+ note: string;
61
+ source: EnumOverlaySource;
62
+ /** ISO date the values were last read from `source`. */
63
+ reviewed: string;
64
+ values: string[];
65
+ }
66
+ /** What happened to one entry during a generation run. */
67
+ export interface EnumOverlayApplication {
68
+ entry: EnumOverlayEntry;
69
+ /**
70
+ * `applied` narrowed the property; `redundant` left an upstream enum in
71
+ * place; `absent` means the schema in hand does not declare the property,
72
+ * which only a non-strict (fixture) run tolerates.
73
+ */
74
+ outcome: "applied" | "redundant" | "absent";
75
+ /** For `redundant`, the values upstream already declared. */
76
+ upstreamValues?: string[];
77
+ }
78
+ /** The curated entries, in file order. */
79
+ export declare function enumOverlayEntries(): EnumOverlayEntry[];
80
+ /** Entries grouped by CloudFormation type name. */
81
+ export declare function enumOverlayByType(entries?: EnumOverlayEntry[]): Map<string, EnumOverlayEntry[]>;
82
+ /**
83
+ * Apply the entries for one CloudFormation type to its raw schema bytes.
84
+ *
85
+ * Returns the (possibly rewritten) schema and one {@link EnumOverlayApplication}
86
+ * per entry. Throws when an entry cannot be honoured, which is always a
87
+ * curation bug rather than a spec quirk.
88
+ *
89
+ * `strict` is on for a run over the real schema zip and off for a run over the
90
+ * trimmed fixtures under `src/testdata/schemas`, which legitimately drop
91
+ * properties the overlay names. Only a strict run treats a missing property as
92
+ * an error.
93
+ */
94
+ export declare function applyEnumOverlay(typeName: string, data: Buffer | string, entries: EnumOverlayEntry[], opts?: {
95
+ strict?: boolean;
96
+ }): {
97
+ data: Buffer | string;
98
+ applications: EnumOverlayApplication[];
99
+ };
100
+ /**
101
+ * Fail on any entry the run never reached.
102
+ *
103
+ * `strict` is on for a run over the real schema zip and off for a run over a
104
+ * fixture subset, where most types are legitimately absent. A missing type in
105
+ * a full run means the resource left the Registry and the entry is dead.
106
+ */
107
+ export declare function assertOverlayCoverage(entries: EnumOverlayEntry[], seenTypes: Set<string>, strict: boolean): void;
108
+ /** One warning line per entry upstream has caught up with. */
109
+ export declare function redundantOverlayWarnings(applications: EnumOverlayApplication[]): Array<{
110
+ file: string;
111
+ error: string;
112
+ }>;
113
+ //# sourceMappingURL=enum-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum-overlay.d.ts","sourceRoot":"","sources":["../../src/codegen/enum-overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,oFAAoF;AACpF,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEN,wBAAwB;AACxB,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,E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