cdk-common 2.0.55 → 2.0.59

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 (52) hide show
  1. package/.jsii +2 -2
  2. package/changelog.md +1 -1
  3. package/lib/main.js +1 -1
  4. package/node_modules/@types/concat-stream/node_modules/@types/node/README.md +2 -2
  5. package/node_modules/@types/concat-stream/node_modules/@types/node/index.d.ts +0 -1
  6. package/node_modules/@types/concat-stream/node_modules/@types/node/package.json +2 -7
  7. package/node_modules/@types/concat-stream/node_modules/@types/node/url.d.ts +27 -1
  8. package/node_modules/@types/form-data/node_modules/@types/node/README.md +2 -2
  9. package/node_modules/@types/form-data/node_modules/@types/node/index.d.ts +0 -1
  10. package/node_modules/@types/form-data/node_modules/@types/node/package.json +2 -7
  11. package/node_modules/@types/form-data/node_modules/@types/node/url.d.ts +27 -1
  12. package/node_modules/table/node_modules/ajv/README.md +1 -0
  13. package/node_modules/table/node_modules/ajv/dist/compile/index.js +8 -9
  14. package/node_modules/table/node_modules/ajv/dist/compile/index.js.map +1 -1
  15. package/node_modules/table/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
  16. package/node_modules/table/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
  17. package/node_modules/table/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
  18. package/node_modules/table/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
  19. package/node_modules/table/node_modules/ajv/dist/compile/ref_error.d.ts +2 -1
  20. package/node_modules/table/node_modules/ajv/dist/compile/ref_error.js +3 -3
  21. package/node_modules/table/node_modules/ajv/dist/compile/ref_error.js.map +1 -1
  22. package/node_modules/table/node_modules/ajv/dist/compile/resolve.d.ts +5 -5
  23. package/node_modules/table/node_modules/ajv/dist/compile/resolve.js +13 -11
  24. package/node_modules/table/node_modules/ajv/dist/compile/resolve.js.map +1 -1
  25. package/node_modules/table/node_modules/ajv/dist/compile/validate/index.js +1 -1
  26. package/node_modules/table/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
  27. package/node_modules/table/node_modules/ajv/dist/core.d.ts +3 -2
  28. package/node_modules/table/node_modules/ajv/dist/core.js +20 -17
  29. package/node_modules/table/node_modules/ajv/dist/core.js.map +1 -1
  30. package/node_modules/table/node_modules/ajv/dist/runtime/uri.d.ts +6 -0
  31. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js +6 -0
  32. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  33. package/node_modules/table/node_modules/ajv/dist/types/index.d.ts +6 -0
  34. package/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js +1 -1
  35. package/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
  36. package/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/ref.js +3 -2
  37. package/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -1
  38. package/node_modules/table/node_modules/ajv/lib/compile/index.ts +8 -8
  39. package/node_modules/table/node_modules/ajv/lib/compile/jtd/parse.ts +1 -1
  40. package/node_modules/table/node_modules/ajv/lib/compile/jtd/serialize.ts +1 -1
  41. package/node_modules/table/node_modules/ajv/lib/compile/ref_error.ts +4 -3
  42. package/node_modules/table/node_modules/ajv/lib/compile/resolve.ts +15 -12
  43. package/node_modules/table/node_modules/ajv/lib/compile/validate/index.ts +1 -1
  44. package/node_modules/table/node_modules/ajv/lib/core.ts +8 -2
  45. package/node_modules/table/node_modules/ajv/lib/runtime/uri.ts +6 -0
  46. package/node_modules/table/node_modules/ajv/lib/types/index.ts +7 -0
  47. package/node_modules/table/node_modules/ajv/lib/vocabularies/core/ref.ts +1 -1
  48. package/node_modules/table/node_modules/ajv/lib/vocabularies/jtd/ref.ts +3 -1
  49. package/node_modules/table/node_modules/ajv/package.json +2 -1
  50. package/package.json +1 -1
  51. package/releasetag.txt +1 -1
  52. package/version.txt +1 -1
@@ -1,9 +1,9 @@
1
- import type {AnySchema, AnySchemaObject} from "../types"
1
+ import type {AnySchema, AnySchemaObject, UriResolver} from "../types"
2
2
  import type Ajv from "../ajv"
3
+ import type {URIComponents} from "uri-js"
3
4
  import {eachItem} from "./util"
4
5
  import * as equal from "fast-deep-equal"
5
6
  import * as traverse from "json-schema-traverse"
6
- import * as URI from "uri-js"
7
7
 
8
8
  // the hash of local references inside the schema (created by getSchemaRefs), used for inline resolution
9
9
  export type LocalRefs = {[Ref in string]?: AnySchemaObject}
@@ -67,14 +67,15 @@ function countKeys(schema: AnySchemaObject): number {
67
67
  return count
68
68
  }
69
69
 
70
- export function getFullPath(id = "", normalize?: boolean): string {
70
+ export function getFullPath(resolver: UriResolver, id = "", normalize?: boolean): string {
71
71
  if (normalize !== false) id = normalizeId(id)
72
- const p = URI.parse(id)
73
- return _getFullPath(p)
72
+ const p = resolver.parse(id)
73
+ return _getFullPath(resolver, p)
74
74
  }
75
75
 
76
- export function _getFullPath(p: URI.URIComponents): string {
77
- return URI.serialize(p).split("#")[0] + "#"
76
+ export function _getFullPath(resolver: UriResolver, p: URIComponents): string {
77
+ const serialized = resolver.serialize(p)
78
+ return serialized.split("#")[0] + "#"
78
79
  }
79
80
 
80
81
  const TRAILING_SLASH_HASH = /#\/?$/
@@ -82,19 +83,19 @@ export function normalizeId(id: string | undefined): string {
82
83
  return id ? id.replace(TRAILING_SLASH_HASH, "") : ""
83
84
  }
84
85
 
85
- export function resolveUrl(baseId: string, id: string): string {
86
+ export function resolveUrl(resolver: UriResolver, baseId: string, id: string): string {
86
87
  id = normalizeId(id)
87
- return URI.resolve(baseId, id)
88
+ return resolver.resolve(baseId, id)
88
89
  }
89
90
 
90
91
  const ANCHOR = /^[a-z_][-a-z0-9._]*$/i
91
92
 
92
93
  export function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
93
94
  if (typeof schema == "boolean") return {}
94
- const {schemaId} = this.opts
95
+ const {schemaId, uriResolver} = this.opts
95
96
  const schId = normalizeId(schema[schemaId] || baseId)
96
97
  const baseIds: {[JsonPtr in string]?: string} = {"": schId}
97
- const pathPrefix = getFullPath(schId, false)
98
+ const pathPrefix = getFullPath(uriResolver, schId, false)
98
99
  const localRefs: LocalRefs = {}
99
100
  const schemaRefs: Set<string> = new Set()
100
101
 
@@ -108,7 +109,9 @@ export function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): Loc
108
109
  baseIds[jsonPtr] = baseId
109
110
 
110
111
  function addRef(this: Ajv, ref: string): string {
111
- ref = normalizeId(baseId ? URI.resolve(baseId, ref) : ref)
112
+ // eslint-disable-next-line @typescript-eslint/unbound-method
113
+ const _resolve = this.opts.uriResolver.resolve
114
+ ref = normalizeId(baseId ? _resolve(baseId, ref) : ref)
112
115
  if (schemaRefs.has(ref)) throw ambiguos(ref)
113
116
  schemaRefs.add(ref)
114
117
  let schOrRef = this.refs[ref]
@@ -177,7 +177,7 @@ function checkNoDefault(it: SchemaObjCxt): void {
177
177
 
178
178
  function updateContext(it: SchemaObjCxt): void {
179
179
  const schId = it.schema[it.opts.schemaId]
180
- if (schId) it.baseId = resolveUrl(it.baseId, schId)
180
+ if (schId) it.baseId = resolveUrl(it.opts.uriResolver, it.baseId, schId)
181
181
  }
182
182
 
183
183
  function checkAsyncSchema(it: SchemaObjCxt): void {
@@ -49,6 +49,7 @@ import type {
49
49
  Format,
50
50
  AddedFormat,
51
51
  RegExpEngine,
52
+ UriResolver,
52
53
  } from "./types"
53
54
  import type {JSONSchemaType} from "./types/json-schema"
54
55
  import type {JTDSchemaType, SomeJTDSchemaType, JTDDataType} from "./types/jtd-schema"
@@ -60,9 +61,10 @@ import {Code, ValueScope} from "./compile/codegen"
60
61
  import {normalizeId, getSchemaRefs} from "./compile/resolve"
61
62
  import {getJSONTypes} from "./compile/validate/dataType"
62
63
  import {eachItem} from "./compile/util"
63
-
64
64
  import * as $dataRefSchema from "./refs/data.json"
65
65
 
66
+ import DefaultUriResolver from "./runtime/uri"
67
+
66
68
  const defaultRegExp: RegExpEngine = (str, flags) => new RegExp(str, flags)
67
69
  defaultRegExp.code = "new RegExp"
68
70
 
@@ -136,6 +138,7 @@ export interface CurrentOptions {
136
138
  int32range?: boolean // JTD only
137
139
  messages?: boolean
138
140
  code?: CodeOptions // NEW
141
+ uriResolver?: UriResolver
139
142
  }
140
143
 
141
144
  export interface CodeOptions {
@@ -226,7 +229,8 @@ type RequiredInstanceOptions = {
226
229
  | "validateSchema"
227
230
  | "validateFormats"
228
231
  | "int32range"
229
- | "unicodeRegExp"]: NonNullable<Options[K]>
232
+ | "unicodeRegExp"
233
+ | "uriResolver"]: NonNullable<Options[K]>
230
234
  } & {code: InstanceCodeOptions}
231
235
 
232
236
  export type InstanceOptions = Options & RequiredInstanceOptions
@@ -239,6 +243,7 @@ function requiredOptions(o: Options): RequiredInstanceOptions {
239
243
  const _optz = o.code?.optimize
240
244
  const optimize = _optz === true || _optz === undefined ? 1 : _optz || 0
241
245
  const regExp = o.code?.regExp ?? defaultRegExp
246
+ const uriResolver = o.uriResolver ?? DefaultUriResolver
242
247
  return {
243
248
  strictSchema: o.strictSchema ?? s ?? true,
244
249
  strictNumbers: o.strictNumbers ?? s ?? true,
@@ -257,6 +262,7 @@ function requiredOptions(o: Options): RequiredInstanceOptions {
257
262
  validateFormats: o.validateFormats ?? true,
258
263
  unicodeRegExp: o.unicodeRegExp ?? true,
259
264
  int32range: o.int32range ?? true,
265
+ uriResolver: uriResolver,
260
266
  }
261
267
  }
262
268
 
@@ -0,0 +1,6 @@
1
+ import * as uri from "uri-js"
2
+
3
+ type URI = typeof uri & {code: string}
4
+ ;(uri as URI).code = 'require("ajv/dist/runtime/uri").default'
5
+
6
+ export default uri as URI
@@ -1,3 +1,4 @@
1
+ import * as URI from "uri-js"
1
2
  import type {CodeGen, Code, Name, ScopeValueSets, ValueScopeName} from "../compile/codegen"
2
3
  import type {SchemaEnv, SchemaCxt, SchemaObjCxt} from "../compile"
3
4
  import type {JSONType} from "../compile/rules"
@@ -231,3 +232,9 @@ export interface RegExpEngine {
231
232
  export interface RegExpLike {
232
233
  test: (s: string) => boolean
233
234
  }
235
+
236
+ export interface UriResolver {
237
+ parse(uri: string): URI.URIComponents
238
+ resolve(base: string, path: string): string
239
+ serialize(component: URI.URIComponents): string
240
+ }
@@ -16,7 +16,7 @@ const def: CodeKeywordDefinition = {
16
16
  const {root} = env
17
17
  if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef()
18
18
  const schOrEnv = resolveRef.call(self, root, baseId, $ref)
19
- if (schOrEnv === undefined) throw new MissingRefError(baseId, $ref)
19
+ if (schOrEnv === undefined) throw new MissingRefError(it.opts.uriResolver, baseId, $ref)
20
20
  if (schOrEnv instanceof SchemaEnv) return callValidate(schOrEnv)
21
21
  return inlineRefSchema(schOrEnv)
22
22
 
@@ -28,7 +28,9 @@ const def: CodeKeywordDefinition = {
28
28
 
29
29
  function validateJtdRef(): void {
30
30
  const refSchema = (root.schema as AnySchemaObject).definitions?.[ref]
31
- if (!refSchema) throw new MissingRefError("", ref, `No definition ${ref}`)
31
+ if (!refSchema) {
32
+ throw new MissingRefError(it.opts.uriResolver, "", ref, `No definition ${ref}`)
33
+ }
32
34
  if (hasRef(refSchema) || !it.opts.inlineRefs) callValidate(refSchema)
33
35
  else inlineRefSchema(refSchema)
34
36
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajv",
3
- "version": "8.9.0",
3
+ "version": "8.10.0",
4
4
  "description": "Another JSON Schema Validator",
5
5
  "main": "dist/ajv.js",
6
6
  "types": "dist/ajv.d.ts",
@@ -83,6 +83,7 @@
83
83
  "dayjs-plugin-utc": "^0.1.2",
84
84
  "eslint": "^7.8.1",
85
85
  "eslint-config-prettier": "^7.0.0",
86
+ "fast-uri": "^1.0.0",
86
87
  "glob": "^7.0.0",
87
88
  "husky": "^7.0.1",
88
89
  "if-node-version": "^1.0.0",
package/package.json CHANGED
@@ -83,7 +83,7 @@
83
83
  ],
84
84
  "main": "lib/index.js",
85
85
  "license": "Apache-2.0",
86
- "version": "2.0.55",
86
+ "version": "2.0.59",
87
87
  "jest": {
88
88
  "testMatch": [
89
89
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",
package/releasetag.txt CHANGED
@@ -1 +1 @@
1
- v2.0.55
1
+ v2.0.59
package/version.txt CHANGED
@@ -1 +1 @@
1
- 2.0.55
1
+ 2.0.59