cdk-common 2.0.38 → 2.0.42

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.
Files changed (65) hide show
  1. package/.jsii +3 -3
  2. package/changelog.md +1 -1
  3. package/lib/main.js +1 -1
  4. package/node_modules/@aws-cdk/assert/package.json +8 -8
  5. package/node_modules/@aws-cdk/cfnspec/coverage/build-tools/index.html +1 -1
  6. package/node_modules/@aws-cdk/cfnspec/coverage/build-tools/massage-spec.ts.html +1 -1
  7. package/node_modules/@aws-cdk/cfnspec/coverage/build-tools/patch-set.ts.html +1 -1
  8. package/node_modules/@aws-cdk/cfnspec/coverage/build-tools/scrutiny.ts.html +1 -1
  9. package/node_modules/@aws-cdk/cfnspec/coverage/build-tools/validate-cfn.ts.html +1 -1
  10. package/node_modules/@aws-cdk/cfnspec/coverage/index.html +1 -1
  11. package/node_modules/@aws-cdk/cfnspec/coverage/junit.xml +6030 -6030
  12. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/build-tools/index.html +1 -1
  13. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/build-tools/massage-spec.ts.html +1 -1
  14. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/build-tools/patch-set.ts.html +1 -1
  15. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/build-tools/scrutiny.ts.html +1 -1
  16. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/build-tools/validate-cfn.ts.html +1 -1
  17. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/index.html +1 -1
  18. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/canned-metrics/canned-metrics-schema.ts.html +1 -1
  19. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/canned-metrics/index.html +1 -1
  20. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/canned-metrics.ts.html +1 -1
  21. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/index.html +1 -1
  22. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/index.ts.html +1 -1
  23. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/augmentation.ts.html +1 -1
  24. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/base-types.ts.html +1 -1
  25. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/index.html +1 -1
  26. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/index.ts.html +1 -1
  27. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/property.ts.html +1 -1
  28. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/resource-type.ts.html +1 -1
  29. package/node_modules/@aws-cdk/cfnspec/coverage/lcov-report/lib/schema/specification.ts.html +1 -1
  30. package/node_modules/@aws-cdk/cfnspec/coverage/lib/canned-metrics/canned-metrics-schema.ts.html +1 -1
  31. package/node_modules/@aws-cdk/cfnspec/coverage/lib/canned-metrics/index.html +1 -1
  32. package/node_modules/@aws-cdk/cfnspec/coverage/lib/canned-metrics.ts.html +1 -1
  33. package/node_modules/@aws-cdk/cfnspec/coverage/lib/index.html +1 -1
  34. package/node_modules/@aws-cdk/cfnspec/coverage/lib/index.ts.html +1 -1
  35. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/augmentation.ts.html +1 -1
  36. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/base-types.ts.html +1 -1
  37. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/index.html +1 -1
  38. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/index.ts.html +1 -1
  39. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/property.ts.html +1 -1
  40. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/resource-type.ts.html +1 -1
  41. package/node_modules/@aws-cdk/cfnspec/coverage/lib/schema/specification.ts.html +1 -1
  42. package/node_modules/@aws-cdk/cfnspec/package.json +3 -3
  43. package/node_modules/@aws-cdk/cfnspec/tsconfig.tsbuildinfo +4 -4
  44. package/node_modules/@aws-cdk/cloudformation-diff/package.json +5 -5
  45. package/node_modules/table/node_modules/ajv/README.md +1 -1
  46. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.d.ts +1 -0
  47. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js +9 -1
  48. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
  49. package/node_modules/table/node_modules/ajv/dist/core.d.ts +1 -0
  50. package/node_modules/table/node_modules/ajv/dist/core.js.map +1 -1
  51. package/node_modules/table/node_modules/ajv/dist/standalone/index.js +8 -1
  52. package/node_modules/table/node_modules/ajv/dist/standalone/index.js.map +1 -1
  53. package/node_modules/table/node_modules/ajv/dist/types/jtd-schema.d.ts +2 -1
  54. package/node_modules/table/node_modules/ajv/dist/vocabularies/discriminator/index.js +10 -3
  55. package/node_modules/table/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
  56. package/node_modules/table/node_modules/ajv/lib/compile/codegen/code.ts +8 -0
  57. package/node_modules/table/node_modules/ajv/lib/core.ts +1 -0
  58. package/node_modules/table/node_modules/ajv/lib/standalone/index.ts +9 -2
  59. package/node_modules/table/node_modules/ajv/lib/types/json-schema.ts +1 -4
  60. package/node_modules/table/node_modules/ajv/lib/types/jtd-schema.ts +4 -5
  61. package/node_modules/table/node_modules/ajv/lib/vocabularies/discriminator/index.ts +11 -3
  62. package/node_modules/table/node_modules/ajv/package.json +4 -3
  63. package/package.json +3 -3
  64. package/releasetag.txt +1 -1
  65. package/version.txt +1 -1
@@ -22,6 +22,10 @@ function standaloneCode(ajv, refsOrFunc) {
22
22
  const usedValues = {};
23
23
  const n = source === null || source === void 0 ? void 0 : source.validateName;
24
24
  const vCode = validateCode(usedValues, source);
25
+ if (ajv.opts.code.esm) {
26
+ // Always do named export as `validate` rather than the variable `n` which is `validateXX` for known export value
27
+ return `"use strict";${_n}export const validate = ${n};${_n}export default ${n};${_n}${vCode}`;
28
+ }
25
29
  return `"use strict";${_n}module.exports = ${n};${_n}module.exports.default = ${n};${_n}${vCode}`;
26
30
  }
27
31
  function multiExportsCode(schemas, getValidateFunc) {
@@ -32,7 +36,10 @@ function standaloneCode(ajv, refsOrFunc) {
32
36
  const v = getValidateFunc(schemas[name]);
33
37
  if (v) {
34
38
  const vCode = validateCode(usedValues, v.source);
35
- code = (0, code_1._) `${code}${_n}exports${(0, code_1.getProperty)(name)} = ${(_a = v.source) === null || _a === void 0 ? void 0 : _a.validateName};${_n}${vCode}`;
39
+ const exportSyntax = ajv.opts.code.esm
40
+ ? (0, code_1._) `export const ${(0, code_1.getEsmExportName)(name)}`
41
+ : (0, code_1._) `exports${(0, code_1.getProperty)(name)}`;
42
+ code = (0, code_1._) `${code}${_n}${exportSyntax} = ${(_a = v.source) === null || _a === void 0 ? void 0 : _a.validateName};${_n}${vCode}`;
36
43
  }
37
44
  }
38
45
  return `${code}`;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/standalone/index.ts"],"names":[],"mappings":";;AAGA,oDAAkG;AAClG,kDAAwE;AAExE,SAAS,cAAc,CACrB,GAAY,EACZ,UAA2D;IAE3D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;KACzE;IACD,MAAM,EAAC,EAAE,EAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA;IAC3B,OAAO,OAAO,UAAU,IAAI,UAAU;QACpC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC;QACnC,CAAC,CAAC,UAAU,KAAK,SAAS;YAC1B,CAAC,CAAC,gBAAgB,CAAS,UAAU,EAAE,WAAW,CAAC;YACnD,CAAC,CAAC,gBAAgB,CAAY,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAC/C,GAAG,CAAC,IAAI,CAA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AC,EAAA,GAAG,GAAG,IAAI,CAAC,iBAAiB,YAAY,IAAI,CAAA;gBAC7D,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,sBAAc,CAAC,OAAO;oBAAE,OAAO,OAAO,CAAA;gBACtE,MAAM,KAAK,GAAG,YAAY,CAAC,UAAU,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,CAAA;gBACxD,OAAO,IAAA,QAAC,EAAA,GAAG,OAAO,GAAG,EAAE,GAAG,KAAK,EAAE,CAAA;aAClC;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,SAAS,SAAS,CAAC,IAAoB;;YACrC,OAAO,MAAA,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,0CAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QAC3C,CAAC;QAED,SAAS,YAAY,CAAC,IAAoB,EAAE,KAAqB;YAC/D,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAA;YACrB,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC,CAAA;YACpE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,cAAc,CAAA;AACzC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,cAAc,CAAA"}
@@ -118,7 +118,8 @@ export declare type JTDSchemaType<T, D extends Record<string, unknown> = Record<
118
118
  [K in keyof D]: JTDSchemaType<D[K], D>;
119
119
  };
120
120
  };
121
- declare type JTDDataDef<S, D extends Record<string, unknown>> = (S extends {
121
+ declare type JTDDataDef<S, D extends Record<string, unknown>> = // ref
122
+ (S extends {
122
123
  ref: string;
123
124
  } ? D extends {
124
125
  [K in S["ref"]]: infer V;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const codegen_1 = require("../../compile/codegen");
4
4
  const types_1 = require("../discriminator/types");
5
+ const compile_1 = require("../../compile");
6
+ const util_1 = require("../../compile/util");
5
7
  const error = {
6
8
  message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag
7
9
  ? `tag "${tagName}" must be string`
@@ -53,10 +55,15 @@ const def = {
53
55
  const topRequired = hasRequired(parentSchema);
54
56
  let tagRequired = true;
55
57
  for (let i = 0; i < oneOf.length; i++) {
56
- const sch = oneOf[i];
57
- const propSch = (_a = sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
58
+ let sch = oneOf[i];
59
+ if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
60
+ sch = compile_1.resolveRef.call(it.self, it.schemaEnv, it.baseId, sch === null || sch === void 0 ? void 0 : sch.$ref);
61
+ if (sch instanceof compile_1.SchemaEnv)
62
+ sch = sch.schema;
63
+ }
64
+ const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
58
65
  if (typeof propSch != "object") {
59
- throw new Error(`discriminator: oneOf schemas must have "properties/${tagName}"`);
66
+ throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
60
67
  }
61
68
  tagRequired = tagRequired && (topRequired || hasRequired(sch));
62
69
  addMappings(propSch, i);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/vocabularies/discriminator/index.ts"],"names":[],"mappings":";;AAEA,mDAA0D;AAC1D,kDAAgE;AAIhE,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,EAAC,EAAE,EAAE,CAC3C,UAAU,KAAK,kBAAU,CAAC,GA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function getProperty(key: Code | string | number): Code {
155
155
  return typeof key == "string" && IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`
156
156
  }
157
157
 
158
+ //Does best effort to format the name properly
159
+ export function getEsmExportName(key: Code | string | number): Code {
160
+ if (typeof key == "string" && IDENTIFIER.test(key)) {
161
+ return new _Code(`${key}`)
162
+ }
163
+ throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`)
164
+ }
165
+
158
166
  export function regexpCode(rx: RegExp): Code {
159
167
  return new _Code(rx.toString())
160
168
  }
@@ -140,6 +140,7 @@ export interface CurrentOptions {
140
140
 
141
141
  export interface CodeOptions {
142
142
  es5?: boolean
143
+ esm?: boolean
143
144
  lines?: boolean
144
145
  optimize?: boolean | number
145
146
  formats?: Code // code to require (or construct) map of available formats - for standalone code
@@ -2,7 +2,7 @@ import type AjvCore from "../core"
2
2
  import type {AnyValidateFunction, SourceCode} from "../types"
3
3
  import type {SchemaEnv} from "../compile"
4
4
  import {UsedScopeValues, UsedValueState, ValueScopeName, varKinds} from "../compile/codegen/scope"
5
- import {_, nil, _Code, Code, getProperty} from "../compile/codegen/code"
5
+ import {_, nil, _Code, Code, getProperty, getEsmExportName} from "../compile/codegen/code"
6
6
 
7
7
  function standaloneCode(
8
8
  ajv: AjvCore,
@@ -30,6 +30,10 @@ function standaloneCode(
30
30
  const usedValues: UsedScopeValues = {}
31
31
  const n = source?.validateName
32
32
  const vCode = validateCode(usedValues, source)
33
+ if (ajv.opts.code.esm) {
34
+ // Always do named export as `validate` rather than the variable `n` which is `validateXX` for known export value
35
+ return `"use strict";${_n}export const validate = ${n};${_n}export default ${n};${_n}${vCode}`
36
+ }
33
37
  return `"use strict";${_n}module.exports = ${n};${_n}module.exports.default = ${n};${_n}${vCode}`
34
38
  }
35
39
 
@@ -43,7 +47,10 @@ function standaloneCode(
43
47
  const v = getValidateFunc(schemas[name] as T)
44
48
  if (v) {
45
49
  const vCode = validateCode(usedValues, v.source)
46
- code = _`${code}${_n}exports${getProperty(name)} = ${v.source?.validateName};${_n}${vCode}`
50
+ const exportSyntax = ajv.opts.code.esm
51
+ ? _`export const ${getEsmExportName(name)}`
52
+ : _`exports${getProperty(name)}`
53
+ code = _`${code}${_n}${exportSyntax} = ${v.source?.validateName};${_n}${vCode}`
47
54
  }
48
55
  }
49
56
  return `${code}`
@@ -113,10 +113,7 @@ type UncheckedJSONSchemaType<T, IsPartial extends boolean> = (
113
113
  dependentSchemas?: {[K in keyof T]?: UncheckedPartialSchema<T>}
114
114
  minProperties?: number
115
115
  maxProperties?: number
116
- } & (// "required" type does not guarantee that all required properties
117
- // are listed it only asserts that optional cannot be listed.
118
- // "required" is not necessary if it's a non-partial type with no required keys
119
- IsPartial extends true
116
+ } & (IsPartial extends true // "required" is not necessary if it's a non-partial type with no required keys // are listed it only asserts that optional cannot be listed. // "required" type does not guarantee that all required properties
120
117
  ? {required: Readonly<(keyof T)[]>}
121
118
  : [UncheckedRequiredMembers<T>] extends [never]
122
119
  ? {required?: Readonly<UncheckedRequiredMembers<T>[]>}
@@ -117,9 +117,8 @@ export type JTDSchemaType<T, D extends Record<string, unknown> = Record<string,
117
117
  : never))
118
118
  // empty - empty schemas also treat nullable differently in that it's now fully ignored
119
119
  | (unknown extends T ? {nullable?: boolean} : never)
120
- // all other types
121
- | ((// numbers - only accepts the type number
122
- true extends NullTypeEquality<T, number>
120
+ // all other types // numbers - only accepts the type number
121
+ | ((true extends NullTypeEquality<T, number>
123
122
  ? {type: NumberType}
124
123
  : // booleans - accepts the type boolean
125
124
  true extends NullTypeEquality<T, boolean>
@@ -198,8 +197,8 @@ export type JTDSchemaType<T, D extends Record<string, unknown> = Record<string,
198
197
  }
199
198
 
200
199
  type JTDDataDef<S, D extends Record<string, unknown>> =
201
- | (// ref
202
- S extends {ref: string}
200
+ | // ref
201
+ (S extends {ref: string}
203
202
  ? D extends {[K in S["ref"]]: infer V}
204
203
  ? JTDDataDef<V, D>
205
204
  : never
@@ -2,6 +2,8 @@ import type {CodeKeywordDefinition, AnySchemaObject, KeywordErrorDefinition} fro
2
2
  import type {KeywordCxt} from "../../compile/validate"
3
3
  import {_, getProperty, Name} from "../../compile/codegen"
4
4
  import {DiscrError, DiscrErrorObj} from "../discriminator/types"
5
+ import {resolveRef, SchemaEnv} from "../../compile"
6
+ import {schemaHasRulesButRef} from "../../compile/util"
5
7
 
6
8
  export type DiscriminatorError = DiscrErrorObj<DiscrError.Tag> | DiscrErrorObj<DiscrError.Mapping>
7
9
 
@@ -62,10 +64,16 @@ const def: CodeKeywordDefinition = {
62
64
  const topRequired = hasRequired(parentSchema)
63
65
  let tagRequired = true
64
66
  for (let i = 0; i < oneOf.length; i++) {
65
- const sch = oneOf[i]
66
- const propSch = sch.properties?.[tagName]
67
+ let sch = oneOf[i]
68
+ if (sch?.$ref && !schemaHasRulesButRef(sch, it.self.RULES)) {
69
+ sch = resolveRef.call(it.self, it.schemaEnv, it.baseId, sch?.$ref)
70
+ if (sch instanceof SchemaEnv) sch = sch.schema
71
+ }
72
+ const propSch = sch?.properties?.[tagName]
67
73
  if (typeof propSch != "object") {
68
- throw new Error(`discriminator: oneOf schemas must have "properties/${tagName}"`)
74
+ throw new Error(
75
+ `discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`
76
+ )
69
77
  }
70
78
  tagRequired = tagRequired && (topRequired || hasRequired(sch))
71
79
  addMappings(propSch, i)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajv",
3
- "version": "8.8.2",
3
+ "version": "8.9.0",
4
4
  "description": "Another JSON Schema Validator",
5
5
  "main": "dist/ajv.js",
6
6
  "types": "dist/ajv.d.ts",
@@ -71,7 +71,7 @@
71
71
  "@rollup/plugin-typescript": "^8.2.1",
72
72
  "@types/chai": "^4.2.12",
73
73
  "@types/mocha": "^9.0.0",
74
- "@types/node": "^16.3.2",
74
+ "@types/node": "^17.0.0",
75
75
  "@types/require-from-string": "^1.2.0",
76
76
  "@typescript-eslint/eslint-plugin": "^3.8.0",
77
77
  "@typescript-eslint/parser": "^3.8.0",
@@ -92,8 +92,9 @@
92
92
  "karma": "^6.0.0",
93
93
  "karma-chrome-launcher": "^3.0.0",
94
94
  "karma-mocha": "^2.0.0",
95
- "lint-staged": "^11.0.0",
95
+ "lint-staged": "^12.1.1",
96
96
  "mocha": "^9.0.2",
97
+ "module-from-string": "^3.1.3",
97
98
  "node-fetch": "^3.0.0",
98
99
  "nyc": "^15.0.0",
99
100
  "prettier": "^2.3.1",
package/package.json CHANGED
@@ -57,7 +57,7 @@
57
57
  "npm-check-updates": "^12",
58
58
  "projen": "0.50.24",
59
59
  "standard-version": "^9",
60
- "ts-jest": "^27.1.2",
60
+ "ts-jest": "^27.1.3",
61
61
  "typescript": "^4.5.4"
62
62
  },
63
63
  "peerDependencies": {
@@ -65,7 +65,7 @@
65
65
  "constructs": "^10.0.5"
66
66
  },
67
67
  "dependencies": {
68
- "@aws-cdk/assert": "^2.7.0",
68
+ "@aws-cdk/assert": "^2.8.0",
69
69
  "case": "^1.6.3",
70
70
  "sync-request": "^6.1.0"
71
71
  },
@@ -83,7 +83,7 @@
83
83
  ],
84
84
  "main": "lib/index.js",
85
85
  "license": "Apache-2.0",
86
- "version": "2.0.38",
86
+ "version": "2.0.42",
87
87
  "jest": {
88
88
  "testMatch": [
89
89
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",
package/releasetag.txt CHANGED
@@ -1 +1 @@
1
- v2.0.38
1
+ v2.0.42
package/version.txt CHANGED
@@ -1 +1 @@
1
- 2.0.38
1
+ 2.0.42