@aws-cdk/cloud-assembly-schema 53.23.0 → 53.25.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/.jsii CHANGED
@@ -8,8 +8,8 @@
8
8
  "url": "https://aws.amazon.com"
9
9
  },
10
10
  "bundled": {
11
- "jsonschema": "~1.4.1",
12
- "semver": "^7.7.4"
11
+ "jsonschema": "^1.5.0",
12
+ "semver": "^7.8.0"
13
13
  },
14
14
  "description": "Schema for the protocol between CDK framework and CDK CLI",
15
15
  "docs": {
@@ -6198,6 +6198,6 @@
6198
6198
  "symbolId": "lib/cloud-assembly/context-queries:VpcContextQuery"
6199
6199
  }
6200
6200
  },
6201
- "version": "53.23.0",
6202
- "fingerprint": "Q2fiJUIIwvX2vQZDRDA7VID8cdT9msx01BqiHyZaxVs="
6201
+ "version": "53.25.0",
6202
+ "fingerprint": "0RnAFDJ7s83trPcX6H+I4/CCwL3bX6i22L8JN7nr6BM="
6203
6203
  }
package/cli-version.json CHANGED
@@ -1 +1 @@
1
- {"version":"2.1122.0"}
1
+ {"version":"2.1123.0"}
package/lib/manifest.js CHANGED
@@ -258,7 +258,7 @@ class Manifest {
258
258
  }
259
259
  exports.Manifest = Manifest;
260
260
  _a = JSII_RTTI_SYMBOL_1;
261
- Manifest[_a] = { fqn: "@aws-cdk/cloud-assembly-schema.Manifest", version: "53.23.0" };
261
+ Manifest[_a] = { fqn: "@aws-cdk/cloud-assembly-schema.Manifest", version: "53.25.0" };
262
262
  function stripEnumErrors(errors) {
263
263
  return errors.filter((e) => typeof e.schema === 'string' || !('enum' in e.schema));
264
264
  }
@@ -80,6 +80,8 @@ var p = {
80
80
  v.addSchema(addressSchema, '/SimpleAddress');
81
81
  console.log(v.validate(p, schema));
82
82
  ```
83
+ Returned ValidatorResult object, will show this example is NOT valid since: `"votes": "lots"` is not an integer.
84
+
83
85
  ### Example for Array schema
84
86
 
85
87
  ```json
@@ -268,6 +270,34 @@ function importNextSchema(){
268
270
  }
269
271
  importNextSchema();
270
272
  ```
273
+ ### Disallowing unknown attributes
274
+
275
+ Sometimes you may want to disallow unknown attributes passed in the body of the request, in order to disallow those unknown attributes before the validation of the body, you need to set additionalProperties to false.
276
+
277
+ ```javascript
278
+ {
279
+ "$schema": "http://json-schema.org/draft-04/schema#",
280
+ "title": "Accounting Resource - Add Item",
281
+ "type": "object",
282
+ "additionalProperties": false,
283
+ "properties": {
284
+ "itemNumber": {
285
+ "type":"string"
286
+ },
287
+ "title": {
288
+ "type":"string"
289
+ },
290
+ "description": {
291
+ "type":"string"
292
+ }
293
+ },
294
+ "required": [
295
+ "itemNumber",
296
+ "title",
297
+ "description"
298
+ ]
299
+ }
300
+ ```
271
301
 
272
302
  ### Default base URI
273
303
 
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var uri = require('url');
4
-
5
3
  var ValidationError = exports.ValidationError = function ValidationError (message, instance, schema, path, name, argument) {
6
4
  if(Array.isArray(path)){
7
5
  this.path = path;
@@ -84,7 +82,7 @@ Object.defineProperty(ValidatorResult.prototype, "valid", { get: function() {
84
82
 
85
83
  module.exports.ValidatorResultError = ValidatorResultError;
86
84
  function ValidatorResultError(result) {
87
- if(Error.captureStackTrace){
85
+ if(typeof Error.captureStackTrace === 'function'){
88
86
  Error.captureStackTrace(this, ValidatorResultError);
89
87
  }
90
88
  this.instance = result.instance;
@@ -105,7 +103,9 @@ var SchemaError = exports.SchemaError = function SchemaError (msg, schema) {
105
103
  this.message = msg;
106
104
  this.schema = schema;
107
105
  Error.call(this, msg);
108
- Error.captureStackTrace(this, SchemaError);
106
+ if(typeof Error.captureStackTrace === 'function'){
107
+ Error.captureStackTrace(this, SchemaError);
108
+ }
109
109
  };
110
110
  SchemaError.prototype = Object.create(Error.prototype,
111
111
  {
@@ -129,13 +129,13 @@ var SchemaContext = exports.SchemaContext = function SchemaContext (schema, opti
129
129
  };
130
130
 
131
131
  SchemaContext.prototype.resolve = function resolve (target) {
132
- return uri.resolve(this.base, target);
132
+ return (() => resolveUrl(this.base,target))();
133
133
  };
134
134
 
135
135
  SchemaContext.prototype.makeChild = function makeChild(schema, propertyName){
136
136
  var path = (propertyName===undefined) ? this.path : this.path.concat([propertyName]);
137
137
  var id = schema.$id || schema.id;
138
- var base = uri.resolve(this.base, id||'');
138
+ let base = (() => resolveUrl(this.base,id||''))();
139
139
  var ctx = new SchemaContext(schema, this.options, path, base, Object.create(this.schemas));
140
140
  if(id && !ctx.schemas[base]){
141
141
  ctx.schemas[base] = schema;
@@ -388,3 +388,19 @@ exports.isSchema = function isSchema(val){
388
388
  return (typeof val === 'object' && val) || (typeof val === 'boolean');
389
389
  };
390
390
 
391
+ /**
392
+ * Resolve target URL from a base and relative URL.
393
+ * Similar to Node's URL Lib's legacy resolve function.
394
+ * Code from example in deprecation note in said library.
395
+ * @param string
396
+ * @param string
397
+ * @returns {string}
398
+ */
399
+ var resolveUrl = exports.resolveUrl = function resolveUrl(from, to) {
400
+ const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
401
+ if (resolvedUrl.protocol === 'resolve:') {
402
+ const { pathname, search, hash } = resolvedUrl;
403
+ return pathname + search + hash;
404
+ }
405
+ return resolvedUrl.toString();
406
+ }
@@ -27,6 +27,13 @@ export declare class ValidatorResult {
27
27
  toString(): string;
28
28
  }
29
29
 
30
+ export declare class ValidatorResultError extends Error {
31
+ instance: any;
32
+ schema: Schema;
33
+ options: Options;
34
+ errors: ValidationError;
35
+ }
36
+
30
37
  export declare class ValidationError {
31
38
  constructor(message?: string, instance?: any, schema?: Schema, propertyPath?: any, name?: string, argument?: any);
32
39
  path: (string|number)[];
@@ -65,12 +72,14 @@ export interface Schema {
65
72
  pattern?: string | RegExp
66
73
  additionalItems?: boolean | Schema
67
74
  items?: Schema | Schema[]
75
+ contains?: Schema
68
76
  maxItems?: number
69
77
  minItems?: number
70
78
  uniqueItems?: boolean
71
79
  maxProperties?: number
72
80
  minProperties?: number
73
81
  required?: string[] | boolean
82
+ propertyNames?: boolean | Schema
74
83
  additionalProperties?: boolean | Schema
75
84
  definitions?: {
76
85
  [name: string]: Schema
@@ -95,6 +104,8 @@ export interface Schema {
95
104
  if?: Schema
96
105
  then?: Schema
97
106
  else?: Schema
107
+ default?: any
108
+ examples?: any[]
98
109
  }
99
110
 
100
111
  export interface Options {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var urilib = require('url');
4
3
  var helpers = require('./helpers');
5
4
 
6
5
  module.exports.SchemaScanResult = SchemaScanResult;
@@ -20,12 +19,13 @@ module.exports.scan = function scan(base, schema){
20
19
  if(!schema || typeof schema!='object') return;
21
20
  // Mark all referenced schemas so we can tell later which schemas are referred to, but never defined
22
21
  if(schema.$ref){
23
- var resolvedUri = urilib.resolve(baseuri, schema.$ref);
22
+ let resolvedUri = helpers.resolveUrl(baseuri,schema.$ref);
24
23
  ref[resolvedUri] = ref[resolvedUri] ? ref[resolvedUri]+1 : 0;
25
24
  return;
26
25
  }
27
26
  var id = schema.$id || schema.id;
28
- var ourBase = id ? urilib.resolve(baseuri, id) : baseuri;
27
+ let resolvedBase = helpers.resolveUrl(baseuri,id);
28
+ var ourBase = id ? resolvedBase : baseuri;
29
29
  if (ourBase) {
30
30
  // If there's no fragment, append an empty one
31
31
  if(ourBase.indexOf('#')<0) ourBase += '#';
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var urilib = require('url');
4
-
5
3
  var attribute = require('./attribute');
6
4
  var helpers = require('./helpers');
7
5
  var scanSchema = require('./scan').scan;
@@ -115,7 +113,7 @@ Validator.prototype.validate = function validate (instance, schema, options, ctx
115
113
  // This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
116
114
  // This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
117
115
  var id = schema.$id || schema.id;
118
- var base = urilib.resolve(options.base||anonymousBase, id||'');
116
+ let base = helpers.resolveUrl(options.base,id||'');
119
117
  if(!ctx){
120
118
  ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas));
121
119
  if (!ctx.schemas[base]) {
@@ -262,8 +260,8 @@ Validator.prototype.resolve = function resolve (schema, switchSchema, ctx) {
262
260
  return {subschema: ctx.schemas[switchSchema], switchSchema: switchSchema};
263
261
  }
264
262
  // Else try walking the property pointer
265
- var parsed = urilib.parse(switchSchema);
266
- var fragment = parsed && parsed.hash;
263
+ let parsed = new URL(switchSchema,'thismessage::/');
264
+ let fragment = parsed.hash;
267
265
  var document = fragment && fragment.length && switchSchema.substr(0, switchSchema.length - fragment.length);
268
266
  if (!document || !ctx.schemas[document]) {
269
267
  throw new SchemaError("no such schema <" + switchSchema + ">", schema);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Tom de Grunt <tom@degrunt.nl>",
3
3
  "name": "jsonschema",
4
- "version": "1.4.1",
4
+ "version": "1.5.0",
5
5
  "license": "MIT",
6
6
  "dependencies": {},
7
7
  "contributors": [
@@ -39,4 +39,4 @@
39
39
  "stryker": "stryker run",
40
40
  "test": "./node_modules/.bin/mocha -R spec"
41
41
  }
42
- }
42
+ }
@@ -56,6 +56,7 @@ const semverCompareLoose = require('semver/functions/compare-loose')
56
56
  const semverCompareBuild = require('semver/functions/compare-build')
57
57
  const semverSort = require('semver/functions/sort')
58
58
  const semverRsort = require('semver/functions/rsort')
59
+ const semverTruncate = require('semver/functions/truncate')
59
60
 
60
61
  // low-level comparators between versions
61
62
  const semverGt = require('semver/functions/gt')
@@ -399,12 +400,19 @@ nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
399
400
  tilde ::= '~' partial
400
401
  caret ::= '^' partial
401
402
  qualifier ::= ( '-' pre )? ( '+' build )?
402
- pre ::= parts
403
- build ::= parts
404
- parts ::= part ( '.' part ) *
405
- part ::= nr | [-0-9A-Za-z]+
403
+ pre ::= prepart ( '.' prepart ) *
404
+ prepart ::= nr | alphanumid
405
+ build ::= buildid ( '.' buildid ) *
406
+ alphanumid ::= ( ['0'-'9'] ) * [-A-Za-z] [-0-9A-Za-z] *
407
+ buildid ::= [-0-9A-Za-z]+
406
408
  ```
407
409
 
410
+ Note: Prerelease identifiers (`pre`) use `nr` for numeric parts, which
411
+ disallows leading zeros (e.g., `1.2.3-00` is invalid). Build metadata
412
+ identifiers (`build`) allow any alphanumeric string including leading
413
+ zeros (e.g., `1.2.3+00` is valid). This matches the
414
+ [SemVer 2.0.0 specification](https://semver.org/#spec-item-9).
415
+
408
416
  ## Functions
409
417
 
410
418
  All methods and classes take a final `options` object argument. All
@@ -449,6 +457,12 @@ strings that they parse.
449
457
  or comparators intersect.
450
458
  * `parse(v)`: Attempt to parse a string as a semantic version, returning either
451
459
  a `SemVer` object or `null`.
460
+ * `truncate(v, releaseType)`: Return the version with components _lower_
461
+ than `releaseType` dropped off, e.g.:
462
+ * `major` removes build & prerelease info and sets minor & patch to 0.
463
+ * `minor` removes build & prerelease info, and sets patch to 0
464
+ * `patch` removes build & prerelease info
465
+ * All prerelease types remove build info only
452
466
 
453
467
  ### Comparison
454
468
 
@@ -650,6 +664,7 @@ The following modules are available:
650
664
  * `require('semver/functions/rsort')`
651
665
  * `require('semver/functions/satisfies')`
652
666
  * `require('semver/functions/sort')`
667
+ * `require('semver/functions/truncate')`
653
668
  * `require('semver/functions/valid')`
654
669
  * `require('semver/ranges/gtr')`
655
670
  * `require('semver/ranges/intersects')`
@@ -46,6 +46,7 @@ const main = () => {
46
46
  a = a.slice(0, indexOfEqualSign)
47
47
  argv.unshift(value)
48
48
  }
49
+
49
50
  switch (a) {
50
51
  case '-rv': case '-rev': case '--rev': case '--reverse':
51
52
  reverse = true
@@ -60,15 +61,10 @@ const main = () => {
60
61
  versions.push(argv.shift())
61
62
  break
62
63
  case '-i': case '--inc': case '--increment':
63
- switch (argv[0]) {
64
- case 'major': case 'minor': case 'patch': case 'prerelease':
65
- case 'premajor': case 'preminor': case 'prepatch':
66
- case 'release':
67
- inc = argv.shift()
68
- break
69
- default:
70
- inc = 'patch'
71
- break
64
+ if (semver.RELEASE_TYPES.includes(argv[0]) || (argv[0] === 'release')) {
65
+ inc = { value: argv.shift(), maybeErrantValue: null, option: a }
66
+ } else {
67
+ inc = { value: 'patch', maybeErrantValue: argv[0], option: a }
72
68
  }
73
69
  break
74
70
  case '--preid':
@@ -102,6 +98,14 @@ const main = () => {
102
98
 
103
99
  options = parseOptions({ loose, includePrerelease, rtl })
104
100
 
101
+ if (
102
+ inc &&
103
+ versions.includes(inc.maybeErrantValue) &&
104
+ !semver.valid(inc.maybeErrantValue, options)
105
+ ) {
106
+ console.warn(`Invalid value for ${inc.option}; defaulting to 'patch'. This may become a failure in future major versions.`)
107
+ }
108
+
105
109
  versions = versions.map((v) => {
106
110
  return coerce ? (semver.coerce(v, options) || { version: v }).version : v
107
111
  }).filter((v) => {
@@ -125,7 +129,7 @@ const main = () => {
125
129
  versions
126
130
  .sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
127
131
  .map(v => semver.clean(v, options))
128
- .map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v)
132
+ .map(v => inc ? semver.inc(v, inc.value, options, identifier, identifierBase) : v)
129
133
  .forEach(v => console.log(v))
130
134
  }
131
135
 
@@ -0,0 +1,48 @@
1
+ 'use strict'
2
+
3
+ const parse = require('./parse')
4
+ const constants = require('../internal/constants')
5
+ const SemVer = require('../classes/semver')
6
+
7
+ const truncate = (version, truncation, options) => {
8
+ if (!constants.RELEASE_TYPES.includes(truncation)) {
9
+ return null
10
+ }
11
+
12
+ const clonedVersion = cloneInputVersion(version, options)
13
+ return clonedVersion && doTruncation(clonedVersion, truncation)
14
+ }
15
+
16
+ const cloneInputVersion = (version, options) => {
17
+ const versionStringToParse = (
18
+ version instanceof SemVer ? version.version : version
19
+ )
20
+
21
+ return parse(versionStringToParse, options)
22
+ }
23
+
24
+ const doTruncation = (version, truncation) => {
25
+ if (isPrerelease(truncation)) {
26
+ return version.version
27
+ }
28
+
29
+ version.prerelease = []
30
+
31
+ switch (truncation) {
32
+ case 'major':
33
+ version.minor = 0
34
+ version.patch = 0
35
+ break
36
+ case 'minor':
37
+ version.patch = 0
38
+ break
39
+ }
40
+
41
+ return version.format()
42
+ }
43
+
44
+ const isPrerelease = (type) => {
45
+ return type.startsWith('pre')
46
+ }
47
+
48
+ module.exports = truncate
@@ -28,6 +28,7 @@ const gte = require('./functions/gte')
28
28
  const lte = require('./functions/lte')
29
29
  const cmp = require('./functions/cmp')
30
30
  const coerce = require('./functions/coerce')
31
+ const truncate = require('./functions/truncate')
31
32
  const Comparator = require('./classes/comparator')
32
33
  const Range = require('./classes/range')
33
34
  const satisfies = require('./functions/satisfies')
@@ -66,6 +67,7 @@ module.exports = {
66
67
  lte,
67
68
  cmp,
68
69
  coerce,
70
+ truncate,
69
71
  Comparator,
70
72
  Range,
71
73
  satisfies,
@@ -136,7 +136,7 @@ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
136
136
  createToken('GTLT', '((?:<|>)?=?)')
137
137
 
138
138
  // Something like "2.*" or "1.2.x".
139
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
139
+ // Note that "x.x" is a valid xRange identifier, meaning "any version"
140
140
  // Only the first item is strictly required.
141
141
  createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
142
142
  createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "7.7.4",
3
+ "version": "7.8.0",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@npmcli/eslint-config": "^6.0.0",
18
- "@npmcli/template-oss": "4.29.0",
18
+ "@npmcli/template-oss": "5.0.0",
19
19
  "benchmark": "^2.1.4",
20
20
  "tap": "^16.0.0"
21
21
  },
@@ -52,7 +52,7 @@
52
52
  "author": "GitHub Inc.",
53
53
  "templateOSS": {
54
54
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
55
- "version": "4.29.0",
55
+ "version": "5.0.0",
56
56
  "engines": ">=10",
57
57
  "distPaths": [
58
58
  "classes/",
@@ -10,7 +10,8 @@ nr ::= '0' | [1-9] ( [0-9] ) *
10
10
  tilde ::= '~' partial
11
11
  caret ::= '^' partial
12
12
  qualifier ::= ( '-' pre )? ( '+' build )?
13
- pre ::= parts
14
- build ::= parts
15
- parts ::= part ( '.' part ) *
16
- part ::= nr | [-0-9A-Za-z]+
13
+ pre ::= prepart ( '.' prepart ) *
14
+ prepart ::= nr | alphanumid
15
+ build ::= buildid ( '.' buildid ) *
16
+ alphanumid ::= ( [0-9] ) * [A-Za-z-] [-0-9A-Za-z] *
17
+ buildid ::= [-0-9A-Za-z]+
package/package.json CHANGED
@@ -39,7 +39,7 @@
39
39
  "organization": true
40
40
  },
41
41
  "devDependencies": {
42
- "@cdklabs/eslint-plugin": "^2.0.4",
42
+ "@cdklabs/eslint-plugin": "^2.0.5",
43
43
  "@stylistic/eslint-plugin": "^3",
44
44
  "@types/jest": "^29.5.14",
45
45
  "@types/node": "^20",
@@ -58,22 +58,22 @@
58
58
  "jest": "^29.7.0",
59
59
  "jest-junit": "^16",
60
60
  "jsii": "5.9",
61
- "jsii-diff": "^1.129.0",
62
- "jsii-pacmak": "^1.129.0",
61
+ "jsii-diff": "^1.130.0",
62
+ "jsii-pacmak": "^1.130.0",
63
63
  "jsii-rosetta": "5.9",
64
64
  "license-checker": "^25.0.1",
65
65
  "mock-fs": "^5.5.0",
66
- "nx": "^22.7.1",
66
+ "nx": "^22.7.2",
67
67
  "prettier": "^2.8",
68
- "projen": "^0.99.57",
68
+ "projen": "^0.99.61",
69
69
  "ts-jest": "^29.4.9",
70
- "tsx": "^4.21.0",
70
+ "tsx": "^4.22.0",
71
71
  "typescript": "5.9",
72
72
  "typescript-json-schema": "^0.67.2"
73
73
  },
74
74
  "dependencies": {
75
- "jsonschema": "~1.4.1",
76
- "semver": "^7.7.4"
75
+ "jsonschema": "^1.5.0",
76
+ "semver": "^7.8.0"
77
77
  },
78
78
  "bundledDependencies": [
79
79
  "jsonschema",
@@ -99,7 +99,7 @@
99
99
  "publishConfig": {
100
100
  "access": "public"
101
101
  },
102
- "version": "53.23.0",
102
+ "version": "53.25.0",
103
103
  "packageManager": "yarn@4.13.0",
104
104
  "types": "lib/index.d.ts",
105
105
  "stability": "stable",