@aws/cloudformation-validate 1.6.0-beta → 1.7.0-beta

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/README.md CHANGED
@@ -53,33 +53,57 @@ diagnostics for the same template and config.
53
53
 
54
54
  ### `EngineConfig`
55
55
 
56
- Passed to the constructor. All fields optional, default to empty arrays.
56
+ Passed to the constructor. All fields are optional; omitted rule arrays are empty and an omitted
57
+ `schemaValidatorConfig` uses only the bundled schemas.
57
58
 
58
59
  ```typescript
59
60
  interface EngineConfig {
60
- customRules?: RuleSource[]; // engine-native rules (Rego for RegoEngine, CEL for CelEngine)
61
- guardRules?: RuleSource[]; // CloudFormation Guard DSL rules — translated internally by each engine
61
+ customRules?: RuleSource[]; // engine-native rules (Rego for RegoEngine, CEL for CelEngine)
62
+ guardRules?: RuleSource[]; // CloudFormation Guard DSL rules — translated internally
63
+ schemaValidatorConfig?: SchemaValidatorConfig; // schema validation and overlay configuration
64
+ }
65
+
66
+ interface SchemaValidatorConfig {
67
+ additionalSchemas?: SchemaSource[]; // resource provider schemas merged over the bundled schemas
62
68
  }
63
69
 
64
70
  type RuleSource = ExternalRuleSource | RuleFile;
71
+ type SchemaSource = AdditionalSchemaSource | SchemaFile;
65
72
 
66
73
  class RuleFile {
67
74
  constructor(path: string); // rule file read from disk; the path becomes the rule source name
68
75
  }
69
76
 
77
+ class SchemaFile {
78
+ constructor(path: string, typeName?: string); // schema file; typeName defaults to the value inside the JSON
79
+ }
80
+
70
81
  interface ExternalRuleSource {
71
82
  name: string; // identifier shown in diagnostics (e.g. file path)
72
83
  content: string; // full rule source text
73
84
  }
85
+
86
+ interface AdditionalSchemaSource {
87
+ typeName?: string; // omit to use the typeName inside the schema JSON
88
+ schema: string; // complete resource provider schema JSON
89
+ }
74
90
  ```
75
91
 
76
92
  Pass a `RuleFile` to load a rule from disk — the same pattern as `TemplateFile` for templates — or an
77
- `ExternalRuleSource` when you already have the rule text in memory. The two can be mixed freely:
93
+ `ExternalRuleSource` when you already have the rule text in memory. `SchemaFile` does the same for an additional
94
+ resource provider schema. Its optional constructor `typeName` may be omitted when the schema JSON contains its own
95
+ `typeName`.
96
+
97
+ The generated `AdditionalSchemaSource` record exposes `typeName` as an optional field. Omit it (or leave the
98
+ `SchemaFile` constructor argument unset) for an in-memory schema whose JSON already contains its own `typeName`.
78
99
 
79
100
  ```typescript
80
101
  const engine = new CelEngine({
81
102
  customRules: [new RuleFile("rules/s3_encryption.json")],
82
103
  guardRules: [new RuleFile("rules/compliance.guard")],
104
+ schemaValidatorConfig: {
105
+ additionalSchemas: [new SchemaFile("schemas/aws-lambda-function.json")],
106
+ },
83
107
  });
84
108
  ```
85
109
 
@@ -84,7 +84,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84
84
  ******************************
85
85
 
86
86
  anyhow
87
- 1.0.103 <https://github.com/dtolnay/anyhow>
87
+ 1.0.104 <https://github.com/dtolnay/anyhow>
88
88
  Apache License
89
89
  Version 2.0, January 2004
90
90
  http://www.apache.org/licenses/
@@ -3445,7 +3445,7 @@ the following restrictions:
3445
3445
  ******************************
3446
3446
 
3447
3447
  futures-core
3448
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3448
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3449
3449
  Apache License
3450
3450
  Version 2.0, January 2004
3451
3451
  http://www.apache.org/licenses/
@@ -3653,7 +3653,7 @@ limitations under the License.
3653
3653
  ******************************
3654
3654
 
3655
3655
  futures-task
3656
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3656
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3657
3657
  Apache License
3658
3658
  Version 2.0, January 2004
3659
3659
  http://www.apache.org/licenses/
@@ -3861,7 +3861,7 @@ limitations under the License.
3861
3861
  ******************************
3862
3862
 
3863
3863
  futures-util
3864
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3864
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3865
3865
  Apache License
3866
3866
  Version 2.0, January 2004
3867
3867
  http://www.apache.org/licenses/
@@ -6789,7 +6789,7 @@ limitations under the License.
6789
6789
  ******************************
6790
6790
 
6791
6791
  memchr
6792
- 2.8.2 <https://github.com/BurntSushi/memchr>
6792
+ 2.8.3 <https://github.com/BurntSushi/memchr>
6793
6793
  The MIT License (MIT)
6794
6794
 
6795
6795
  Copyright (c) 2015 Andrew Gallant
@@ -7361,7 +7361,7 @@ SOFTWARE.
7361
7361
  ******************************
7362
7362
 
7363
7363
  num-bigint
7364
- 0.4.7 <https://github.com/rust-num/num-bigint>
7364
+ 0.4.8 <https://github.com/rust-num/num-bigint>
7365
7365
  Apache License
7366
7366
  Version 2.0, January 2004
7367
7367
  http://www.apache.org/licenses/
@@ -8968,7 +8968,7 @@ limitations under the License.
8968
8968
  ******************************
8969
8969
 
8970
8970
  proc-macro2
8971
- 1.0.106 <https://github.com/dtolnay/proc-macro2>
8971
+ 1.0.107 <https://github.com/dtolnay/proc-macro2>
8972
8972
  Apache License
8973
8973
  Version 2.0, January 2004
8974
8974
  http://www.apache.org/licenses/
@@ -9047,7 +9047,7 @@ limitations under the License.
9047
9047
  ******************************
9048
9048
 
9049
9049
  quote
9050
- 1.0.46 <https://github.com/dtolnay/quote>
9050
+ 1.0.47 <https://github.com/dtolnay/quote>
9051
9051
  Apache License
9052
9052
  Version 2.0, January 2004
9053
9053
  http://www.apache.org/licenses/
@@ -9126,7 +9126,7 @@ limitations under the License.
9126
9126
  ******************************
9127
9127
 
9128
9128
  rand
9129
- 0.9.4 <https://github.com/rust-random/rand>
9129
+ 0.9.5 <https://github.com/rust-random/rand>
9130
9130
  Apache License
9131
9131
  Version 2.0, January 2004
9132
9132
  http://www.apache.org/licenses/
@@ -9477,7 +9477,7 @@ APPENDIX: How to apply the Apache License to your work.
9477
9477
  ******************************
9478
9478
 
9479
9479
  regex
9480
- 1.12.4 <https://github.com/rust-lang/regex>
9480
+ 1.13.1 <https://github.com/rust-lang/regex>
9481
9481
  Apache License
9482
9482
  Version 2.0, January 2004
9483
9483
  http://www.apache.org/licenses/
@@ -9684,7 +9684,7 @@ limitations under the License.
9684
9684
  ******************************
9685
9685
 
9686
9686
  regex-automata
9687
- 0.4.14 <https://github.com/rust-lang/regex>
9687
+ 0.4.16 <https://github.com/rust-lang/regex>
9688
9688
  Apache License
9689
9689
  Version 2.0, January 2004
9690
9690
  http://www.apache.org/licenses/
@@ -10752,7 +10752,7 @@ limitations under the License.
10752
10752
  ******************************
10753
10753
 
10754
10754
  serde
10755
- 1.0.228 <https://github.com/serde-rs/serde>
10755
+ 1.0.229 <https://github.com/serde-rs/serde>
10756
10756
  Apache License
10757
10757
  Version 2.0, January 2004
10758
10758
  http://www.apache.org/licenses/
@@ -10858,7 +10858,7 @@ SOFTWARE.
10858
10858
  ******************************
10859
10859
 
10860
10860
  serde_core
10861
- 1.0.228 <https://github.com/serde-rs/serde>
10861
+ 1.0.229 <https://github.com/serde-rs/serde>
10862
10862
  Apache License
10863
10863
  Version 2.0, January 2004
10864
10864
  http://www.apache.org/licenses/
@@ -10937,7 +10937,7 @@ limitations under the License.
10937
10937
  ******************************
10938
10938
 
10939
10939
  serde_derive
10940
- 1.0.228 <https://github.com/serde-rs/serde>
10940
+ 1.0.229 <https://github.com/serde-rs/serde>
10941
10941
  Apache License
10942
10942
  Version 2.0, January 2004
10943
10943
  http://www.apache.org/licenses/
@@ -11095,7 +11095,7 @@ limitations under the License.
11095
11095
  ******************************
11096
11096
 
11097
11097
  serde_json
11098
- 1.0.150 <https://github.com/serde-rs/json>
11098
+ 1.0.151 <https://github.com/serde-rs/json>
11099
11099
  Apache License
11100
11100
  Version 2.0, January 2004
11101
11101
  http://www.apache.org/licenses/
@@ -11491,7 +11491,7 @@ limitations under the License.
11491
11491
  ******************************
11492
11492
 
11493
11493
  spin
11494
- 0.9.8 <https://github.com/mvdnes/spin-rs.git>
11494
+ 0.9.9 <https://github.com/mvdnes/spin-rs.git>
11495
11495
  The MIT License (MIT)
11496
11496
 
11497
11497
  Copyright (c) 2014 Mathijs van de Nes
@@ -11517,7 +11517,86 @@ SOFTWARE.
11517
11517
  ******************************
11518
11518
 
11519
11519
  syn
11520
- 2.0.118 <https://github.com/dtolnay/syn>
11520
+ 2.0.119 <https://github.com/dtolnay/syn>
11521
+ Apache License
11522
+ Version 2.0, January 2004
11523
+ http://www.apache.org/licenses/
11524
+
11525
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11526
+
11527
+ 1. Definitions.
11528
+
11529
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
11530
+
11531
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
11532
+
11533
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
11534
+
11535
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
11536
+
11537
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
11538
+
11539
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
11540
+
11541
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
11542
+
11543
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
11544
+
11545
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
11546
+
11547
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
11548
+
11549
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
11550
+
11551
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
11552
+
11553
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
11554
+
11555
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
11556
+
11557
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
11558
+
11559
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
11560
+
11561
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
11562
+
11563
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
11564
+
11565
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
11566
+
11567
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
11568
+
11569
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
11570
+
11571
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
11572
+
11573
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
11574
+
11575
+ END OF TERMS AND CONDITIONS
11576
+
11577
+ APPENDIX: How to apply the Apache License to your work.
11578
+
11579
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
11580
+
11581
+ Copyright [yyyy] [name of copyright owner]
11582
+
11583
+ Licensed under the Apache License, Version 2.0 (the "License");
11584
+ you may not use this file except in compliance with the License.
11585
+ You may obtain a copy of the License at
11586
+
11587
+ http://www.apache.org/licenses/LICENSE-2.0
11588
+
11589
+ Unless required by applicable law or agreed to in writing, software
11590
+ distributed under the License is distributed on an "AS IS" BASIS,
11591
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11592
+ See the License for the specific language governing permissions and
11593
+ limitations under the License.
11594
+
11595
+
11596
+ ******************************
11597
+
11598
+ syn
11599
+ 3.0.3 <https://github.com/dtolnay/syn>
11521
11600
  Apache License
11522
11601
  Version 2.0, January 2004
11523
11602
  http://www.apache.org/licenses/
@@ -11675,7 +11754,7 @@ limitations under the License.
11675
11754
  ******************************
11676
11755
 
11677
11756
  thiserror
11678
- 2.0.18 <https://github.com/dtolnay/thiserror>
11757
+ 2.0.19 <https://github.com/dtolnay/thiserror>
11679
11758
  Apache License
11680
11759
  Version 2.0, January 2004
11681
11760
  http://www.apache.org/licenses/
@@ -11833,7 +11912,7 @@ limitations under the License.
11833
11912
  ******************************
11834
11913
 
11835
11914
  thiserror-impl
11836
- 2.0.18 <https://github.com/dtolnay/thiserror>
11915
+ 2.0.19 <https://github.com/dtolnay/thiserror>
11837
11916
  Apache License
11838
11917
  Version 2.0, January 2004
11839
11918
  http://www.apache.org/licenses/
@@ -12276,7 +12355,7 @@ THE SOFTWARE.
12276
12355
  ******************************
12277
12356
 
12278
12357
  uuid
12279
- 1.23.4 <https://github.com/uuid-rs/uuid>
12358
+ 1.24.0 <https://github.com/uuid-rs/uuid>
12280
12359
  Apache License
12281
12360
  Version 2.0, January 2004
12282
12361
  http://www.apache.org/licenses/
@@ -13923,7 +14002,7 @@ END OF TERMS AND CONDITIONS
13923
14002
  ******************************
13924
14003
 
13925
14004
  zerocopy
13926
- 0.8.52 <https://github.com/google/zerocopy>
14005
+ 0.8.55 <https://github.com/google/zerocopy>
13927
14006
  Apache License
13928
14007
  Version 2.0, January 2004
13929
14008
  http://www.apache.org/licenses/
@@ -14131,7 +14210,7 @@ zerocopy
14131
14210
  ******************************
14132
14211
 
14133
14212
  zmij
14134
- 1.0.21 <https://github.com/dtolnay/zmij>
14213
+ 1.0.23 <https://github.com/dtolnay/zmij>
14135
14214
  Permission is hereby granted, free of charge, to any
14136
14215
  person obtaining a copy of this software and associated
14137
14216
  documentation files (the "Software"), to deal in the
@@ -270,6 +270,31 @@ export interface DiagnosticCondition {
270
270
  mutexWith?: string[];
271
271
  }
272
272
 
273
+ /**
274
+ * A single additional CloudFormation resource provider schema to overlay on top
275
+ * of the bundled schemas.
276
+ *
277
+ * `type_name` identifies the resource type (e.g., `\"AWS::Lambda::Function\"`).
278
+ * When absent (`None`), the `typeName` field inside the schema JSON is used
279
+ * instead. When both are present they must agree.
280
+ *
281
+ * `schema` is the complete resource provider schema as a JSON string, in the
282
+ * standard CloudFormation registry format.
283
+ */
284
+ export interface AdditionalSchemaSource {
285
+ /**
286
+ * The resource type name (e.g., `\"AWS::Lambda::Function\"`). When absent, the
287
+ * `typeName` field of the schema JSON is used instead. When both are
288
+ * present they must agree.
289
+ */
290
+ typeName?: string;
291
+ /**
292
+ * The complete resource provider schema as a JSON string, in the standard
293
+ * CloudFormation registry format.
294
+ */
295
+ schema: string;
296
+ }
297
+
273
298
  /**
274
299
  * A single assertion within a template rule.
275
300
  */
@@ -579,6 +604,19 @@ export interface RelatedResource {
579
604
  message: string;
580
605
  }
581
606
 
607
+ /**
608
+ * Configuration for constructing a [`SchemaValidator`] with optional overlay
609
+ * schemas. Bindings and the CLI use this to build the validator separately from
610
+ * the rule engine.
611
+ */
612
+ export interface SchemaValidatorConfig {
613
+ /**
614
+ * Additional CloudFormation resource provider schemas to merge on top of the
615
+ * bundled schemas before schema validation.
616
+ */
617
+ additionalSchemas?: AdditionalSchemaSource[];
618
+ }
619
+
582
620
  /**
583
621
  * Controls the level of detail in validation output.
584
622
  */
@@ -992,6 +1030,13 @@ export interface EngineConfig {
992
1030
  * Guard DSL rules as raw source text, usable regardless of the selected engine.
993
1031
  */
994
1032
  guardRules?: ExternalRuleSource[];
1033
+ /**
1034
+ * Optional schema validator configuration. A standalone engine derives its
1035
+ * schema-aware rule metadata from this config. Language APIs also use it to
1036
+ * construct the schema validator bundled with the engine, so both components
1037
+ * observe the same additional schemas.
1038
+ */
1039
+ schemaValidatorConfig?: SchemaValidatorConfig;
995
1040
  }
996
1041
 
997
1042
  export interface MapEntry {
@@ -1072,7 +1117,7 @@ export class WasmSchemaValidator {
1072
1117
  free(): void;
1073
1118
  [Symbol.dispose](): void;
1074
1119
  listRules(): any;
1075
- constructor();
1120
+ constructor(config: SchemaValidatorConfig);
1076
1121
  schemaCount(): number;
1077
1122
  validate(model: WasmSemanticModel, region?: string | null): any;
1078
1123
  }
package/bindings_wasm.js CHANGED
@@ -193,9 +193,15 @@ class WasmSchemaValidator {
193
193
  }
194
194
  return takeFromExternrefTable0(ret[0]);
195
195
  }
196
- constructor() {
197
- const ret = wasm.wasmschemavalidator_new();
198
- this.__wbg_ptr = ret;
196
+ /**
197
+ * @param {SchemaValidatorConfig} config
198
+ */
199
+ constructor(config) {
200
+ const ret = wasm.wasmschemavalidator_new(config);
201
+ if (ret[2]) {
202
+ throw takeFromExternrefTable0(ret[1]);
203
+ }
204
+ this.__wbg_ptr = ret[0];
199
205
  WasmSchemaValidatorFinalization.register(this, this.__wbg_ptr, this);
200
206
  return this;
201
207
  }
Binary file
@@ -46,7 +46,7 @@ export const wasmregoengine_validateStandard: (
46
46
  f: number,
47
47
  ) => [number, number, number];
48
48
  export const wasmschemavalidator_listRules: (a: number) => [number, number, number];
49
- export const wasmschemavalidator_new: () => number;
49
+ export const wasmschemavalidator_new: (a: any) => [number, number, number];
50
50
  export const wasmschemavalidator_schemaCount: (a: number) => number;
51
51
  export const wasmschemavalidator_validate: (a: number, b: number, c: number, d: number) => [number, number, number];
52
52
  export const wasmsemanticmodel_conditions: (a: number) => [number, number, number];
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  DetailedReport,
3
3
  DiagnosticModel,
4
+ AdditionalSchemaSource,
4
5
  ExternalRuleSource,
5
6
  ParameterInfo,
6
7
  ResolvedOutput,
@@ -39,6 +40,7 @@ export type {
39
40
  PseudoParameterOverrides,
40
41
  ValidateConfig,
41
42
  ExternalRuleSource,
43
+ AdditionalSchemaSource,
42
44
  ResolvedValue,
43
45
  RefKind,
44
46
  ParameterInfo,
@@ -95,11 +97,39 @@ export declare class RuleFile {
95
97
  readContent(): string;
96
98
  }
97
99
  export type RuleSource = ExternalRuleSource | RuleFile;
100
+ /**
101
+ * A CloudFormation resource provider schema loaded from a file, for use as an
102
+ * overlay. `typeName` may be omitted to use the `typeName` inside the file.
103
+ */
104
+ export declare class SchemaFile {
105
+ readonly path: string;
106
+ readonly typeName?: string | undefined;
107
+ constructor(path: string, typeName?: string | undefined);
108
+ readContent(): string;
109
+ }
110
+ export type SchemaSource = AdditionalSchemaSource | SchemaFile;
98
111
  export interface EngineConfig {
99
112
  /** Engine-native rules (Rego for RegoEngine, CEL for CelEngine). */
100
113
  customRules?: RuleSource[];
101
114
  /** CloudFormation Guard DSL rules, usable with either engine. */
102
115
  guardRules?: RuleSource[];
116
+ /**
117
+ * Optional schema validator configuration. When present, the engine derives
118
+ * overlay-aware metadata from the configured additional schemas.
119
+ */
120
+ schemaValidatorConfig?: SchemaValidatorConfig;
121
+ }
122
+ /**
123
+ * Configuration for the schema validator. Additional schemas are merged on top
124
+ * of the bundled CloudFormation provider schemas before schema validation.
125
+ */
126
+ export interface SchemaValidatorConfig {
127
+ /**
128
+ * Additional CloudFormation resource provider schemas to merge on top of the
129
+ * bundled schemas. Each overlay extends or overrides the bundled schema for
130
+ * its resource type.
131
+ */
132
+ additionalSchemas?: SchemaSource[];
103
133
  }
104
134
  export declare class TemplateModel {
105
135
  private readonly inner;
@@ -117,6 +147,7 @@ export declare class TemplateModel {
117
147
  }
118
148
  export declare class SchemaValidator {
119
149
  private readonly inner;
150
+ constructor(config?: SchemaValidatorConfig);
120
151
  listRules(): RuleInfo[];
121
152
  schemaCount(): number;
122
153
  validate(template: TemplateFile, region?: string): StandardDiagnostic[];
package/index.js CHANGED
@@ -4,6 +4,7 @@ exports.CelEngine =
4
4
  exports.RegoEngine =
5
5
  exports.SchemaValidator =
6
6
  exports.TemplateModel =
7
+ exports.SchemaFile =
7
8
  exports.RuleFile =
8
9
  exports.TemplateFile =
9
10
  void 0;
@@ -28,15 +29,42 @@ class RuleFile {
28
29
  }
29
30
  }
30
31
  exports.RuleFile = RuleFile;
32
+ /**
33
+ * A CloudFormation resource provider schema loaded from a file, for use as an
34
+ * overlay. `typeName` may be omitted to use the `typeName` inside the file.
35
+ */
36
+ class SchemaFile {
37
+ constructor(path, typeName) {
38
+ this.path = path;
39
+ this.typeName = typeName;
40
+ }
41
+ readContent() {
42
+ return (0, fs_1.readFileSync)(this.path, 'utf8');
43
+ }
44
+ }
45
+ exports.SchemaFile = SchemaFile;
31
46
  function toExternalRuleSources(sources) {
32
47
  return (sources ?? []).map((source) =>
33
48
  source instanceof RuleFile ? { name: source.path, content: source.readContent() } : source,
34
49
  );
35
50
  }
51
+ function toAdditionalSchemas(sources) {
52
+ return (sources ?? []).map((source) =>
53
+ source instanceof SchemaFile ? { typeName: source.typeName, schema: source.readContent() } : source,
54
+ );
55
+ }
36
56
  function toWasmEngineConfig(config) {
37
57
  return {
38
58
  customRules: toExternalRuleSources(config?.customRules),
39
59
  guardRules: toExternalRuleSources(config?.guardRules),
60
+ schemaValidatorConfig: config?.schemaValidatorConfig
61
+ ? toWasmSchemaValidatorConfig(config.schemaValidatorConfig)
62
+ : undefined,
63
+ };
64
+ }
65
+ function toWasmSchemaValidatorConfig(config) {
66
+ return {
67
+ additionalSchemas: toAdditionalSchemas(config?.additionalSchemas),
40
68
  };
41
69
  }
42
70
  class TemplateModel {
@@ -76,8 +104,8 @@ class TemplateModel {
76
104
  }
77
105
  exports.TemplateModel = TemplateModel;
78
106
  class SchemaValidator {
79
- constructor() {
80
- this.inner = new bridge.WasmSchemaValidator();
107
+ constructor(config) {
108
+ this.inner = new bridge.WasmSchemaValidator(toWasmSchemaValidatorConfig(config));
81
109
  }
82
110
  listRules() {
83
111
  return this.inner.listRules();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/cloudformation-validate",
3
- "version": "1.6.0-beta",
3
+ "version": "1.7.0-beta",
4
4
  "description": "AWS CloudFormation Validate",
5
5
  "keywords": [
6
6
  "aws",