@cfworker/json-schema 2.0.1 → 3.0.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.
Files changed (44) hide show
  1. package/dist/cjs/deep-compare-strict.js +42 -0
  2. package/dist/{dereference.d.ts → cjs/dereference.d.ts} +1 -1
  3. package/dist/cjs/dereference.js +147 -0
  4. package/dist/cjs/format.js +122 -0
  5. package/dist/cjs/index.js +24 -0
  6. package/dist/cjs/pointer.js +10 -0
  7. package/dist/cjs/types.js +9 -0
  8. package/dist/cjs/ucs2-length.js +20 -0
  9. package/dist/{validate.d.ts → cjs/validate.d.ts} +1 -1
  10. package/dist/cjs/validate.js +805 -0
  11. package/dist/{validator.d.ts → cjs/validator.d.ts} +2 -2
  12. package/dist/cjs/validator.js +27 -0
  13. package/dist/esm/deep-compare-strict.d.ts +1 -0
  14. package/dist/esm/dereference.d.ts +7 -0
  15. package/dist/esm/format.d.ts +2 -0
  16. package/dist/esm/index.js +8 -0
  17. package/dist/esm/pointer.d.ts +2 -0
  18. package/dist/esm/types.d.ts +72 -0
  19. package/dist/esm/types.js +6 -0
  20. package/dist/esm/ucs2-length.d.ts +1 -0
  21. package/dist/esm/validate.d.ts +3 -0
  22. package/dist/esm/validator.d.ts +10 -0
  23. package/dist/tsconfig-cjs.tsbuildinfo +1 -0
  24. package/dist/tsconfig.tsbuildinfo +1 -0
  25. package/package.json +10 -6
  26. package/src/dereference.ts +3 -3
  27. package/src/ucs2-length.ts +1 -1
  28. package/src/validate.ts +1 -1
  29. package/src/validator.ts +3 -3
  30. package/dist/types.js +0 -1
  31. /package/dist/{deep-compare-strict.d.ts → cjs/deep-compare-strict.d.ts} +0 -0
  32. /package/dist/{format.d.ts → cjs/format.d.ts} +0 -0
  33. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  34. /package/dist/{pointer.d.ts → cjs/pointer.d.ts} +0 -0
  35. /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
  36. /package/dist/{ucs2-length.d.ts → cjs/ucs2-length.d.ts} +0 -0
  37. /package/dist/{deep-compare-strict.js → esm/deep-compare-strict.js} +0 -0
  38. /package/dist/{dereference.js → esm/dereference.js} +0 -0
  39. /package/dist/{format.js → esm/format.js} +0 -0
  40. /package/dist/{index.js → esm/index.d.ts} +0 -0
  41. /package/dist/{pointer.js → esm/pointer.js} +0 -0
  42. /package/dist/{ucs2-length.js → esm/ucs2-length.js} +0 -0
  43. /package/dist/{validate.js → esm/validate.js} +0 -0
  44. /package/dist/{validator.js → esm/validator.js} +0 -0
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepCompareStrict = deepCompareStrict;
4
+ function deepCompareStrict(a, b) {
5
+ const typeofa = typeof a;
6
+ if (typeofa !== typeof b) {
7
+ return false;
8
+ }
9
+ if (Array.isArray(a)) {
10
+ if (!Array.isArray(b)) {
11
+ return false;
12
+ }
13
+ const length = a.length;
14
+ if (length !== b.length) {
15
+ return false;
16
+ }
17
+ for (let i = 0; i < length; i++) {
18
+ if (!deepCompareStrict(a[i], b[i])) {
19
+ return false;
20
+ }
21
+ }
22
+ return true;
23
+ }
24
+ if (typeofa === 'object') {
25
+ if (!a || !b) {
26
+ return a === b;
27
+ }
28
+ const aKeys = Object.keys(a);
29
+ const bKeys = Object.keys(b);
30
+ const length = aKeys.length;
31
+ if (length !== bKeys.length) {
32
+ return false;
33
+ }
34
+ for (const k of aKeys) {
35
+ if (!deepCompareStrict(a[k], b[k])) {
36
+ return false;
37
+ }
38
+ }
39
+ return true;
40
+ }
41
+ return a === b;
42
+ }
@@ -4,4 +4,4 @@ export declare const schemaArrayKeyword: Record<string, boolean>;
4
4
  export declare const schemaMapKeyword: Record<string, boolean>;
5
5
  export declare const ignoredKeyword: Record<string, boolean>;
6
6
  export declare let initialBaseURI: URL;
7
- export declare function dereference(schema: Schema | boolean, lookup?: Record<string, Schema | boolean>, baseURI?: URL, basePointer?: string): Record<string, boolean | Schema>;
7
+ export declare function dereference(schema: Schema | boolean, lookup?: Record<string, Schema | boolean>, baseURI?: URL, basePointer?: string): Record<string, Schema | boolean>;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialBaseURI = exports.ignoredKeyword = exports.schemaMapKeyword = exports.schemaArrayKeyword = exports.schemaKeyword = void 0;
4
+ exports.dereference = dereference;
5
+ const pointer_js_1 = require("./pointer.js");
6
+ exports.schemaKeyword = {
7
+ additionalItems: true,
8
+ unevaluatedItems: true,
9
+ items: true,
10
+ contains: true,
11
+ additionalProperties: true,
12
+ unevaluatedProperties: true,
13
+ propertyNames: true,
14
+ not: true,
15
+ if: true,
16
+ then: true,
17
+ else: true
18
+ };
19
+ exports.schemaArrayKeyword = {
20
+ prefixItems: true,
21
+ items: true,
22
+ allOf: true,
23
+ anyOf: true,
24
+ oneOf: true
25
+ };
26
+ exports.schemaMapKeyword = {
27
+ $defs: true,
28
+ definitions: true,
29
+ properties: true,
30
+ patternProperties: true,
31
+ dependentSchemas: true
32
+ };
33
+ exports.ignoredKeyword = {
34
+ id: true,
35
+ $id: true,
36
+ $ref: true,
37
+ $schema: true,
38
+ $anchor: true,
39
+ $vocabulary: true,
40
+ $comment: true,
41
+ default: true,
42
+ enum: true,
43
+ const: true,
44
+ required: true,
45
+ type: true,
46
+ maximum: true,
47
+ minimum: true,
48
+ exclusiveMaximum: true,
49
+ exclusiveMinimum: true,
50
+ multipleOf: true,
51
+ maxLength: true,
52
+ minLength: true,
53
+ pattern: true,
54
+ format: true,
55
+ maxItems: true,
56
+ minItems: true,
57
+ uniqueItems: true,
58
+ maxProperties: true,
59
+ minProperties: true
60
+ };
61
+ exports.initialBaseURI = typeof self !== 'undefined' &&
62
+ self.location &&
63
+ self.location.origin !== 'null'
64
+ ?
65
+ new URL(self.location.origin + self.location.pathname + location.search)
66
+ : new URL('https://github.com/cfworker');
67
+ function dereference(schema, lookup = Object.create(null), baseURI = exports.initialBaseURI, basePointer = '') {
68
+ if (schema && typeof schema === 'object' && !Array.isArray(schema)) {
69
+ const id = schema.$id || schema.id;
70
+ if (id) {
71
+ const url = new URL(id, baseURI.href);
72
+ if (url.hash.length > 1) {
73
+ lookup[url.href] = schema;
74
+ }
75
+ else {
76
+ url.hash = '';
77
+ if (basePointer === '') {
78
+ baseURI = url;
79
+ }
80
+ else {
81
+ dereference(schema, lookup, baseURI);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ else if (schema !== true && schema !== false) {
87
+ return lookup;
88
+ }
89
+ const schemaURI = baseURI.href + (basePointer ? '#' + basePointer : '');
90
+ if (lookup[schemaURI] !== undefined) {
91
+ throw new Error(`Duplicate schema URI "${schemaURI}".`);
92
+ }
93
+ lookup[schemaURI] = schema;
94
+ if (schema === true || schema === false) {
95
+ return lookup;
96
+ }
97
+ if (schema.__absolute_uri__ === undefined) {
98
+ Object.defineProperty(schema, '__absolute_uri__', {
99
+ enumerable: false,
100
+ value: schemaURI
101
+ });
102
+ }
103
+ if (schema.$ref && schema.__absolute_ref__ === undefined) {
104
+ const url = new URL(schema.$ref, baseURI.href);
105
+ url.hash = url.hash;
106
+ Object.defineProperty(schema, '__absolute_ref__', {
107
+ enumerable: false,
108
+ value: url.href
109
+ });
110
+ }
111
+ if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
112
+ const url = new URL(schema.$recursiveRef, baseURI.href);
113
+ url.hash = url.hash;
114
+ Object.defineProperty(schema, '__absolute_recursive_ref__', {
115
+ enumerable: false,
116
+ value: url.href
117
+ });
118
+ }
119
+ if (schema.$anchor) {
120
+ const url = new URL('#' + schema.$anchor, baseURI.href);
121
+ lookup[url.href] = schema;
122
+ }
123
+ for (let key in schema) {
124
+ if (exports.ignoredKeyword[key]) {
125
+ continue;
126
+ }
127
+ const keyBase = `${basePointer}/${(0, pointer_js_1.encodePointer)(key)}`;
128
+ const subSchema = schema[key];
129
+ if (Array.isArray(subSchema)) {
130
+ if (exports.schemaArrayKeyword[key]) {
131
+ const length = subSchema.length;
132
+ for (let i = 0; i < length; i++) {
133
+ dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
134
+ }
135
+ }
136
+ }
137
+ else if (exports.schemaMapKeyword[key]) {
138
+ for (let subKey in subSchema) {
139
+ dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${(0, pointer_js_1.encodePointer)(subKey)}`);
140
+ }
141
+ }
142
+ else {
143
+ dereference(subSchema, lookup, baseURI, keyBase);
144
+ }
145
+ }
146
+ return lookup;
147
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fastFormat = exports.fullFormat = void 0;
4
+ const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
5
+ const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6
+ const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
7
+ const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
8
+ const URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
9
+ const URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
10
+ const URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
11
+ const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
12
+ const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
13
+ const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
14
+ const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
15
+ const FASTDATE = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
16
+ const FASTTIME = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
17
+ const FASTDATETIME = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i;
18
+ const FASTURIREFERENCE = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i;
19
+ const EMAIL = (input) => {
20
+ if (input[0] === '"')
21
+ return false;
22
+ const [name, host, ...rest] = input.split('@');
23
+ if (!name ||
24
+ !host ||
25
+ rest.length !== 0 ||
26
+ name.length > 64 ||
27
+ host.length > 253)
28
+ return false;
29
+ if (name[0] === '.' || name.endsWith('.') || name.includes('..'))
30
+ return false;
31
+ if (!/^[a-z0-9.-]+$/i.test(host) ||
32
+ !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
33
+ return false;
34
+ return host
35
+ .split('.')
36
+ .every(part => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
37
+ };
38
+ const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
39
+ const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
40
+ const DURATION = (input) => input.length > 1 &&
41
+ input.length < 80 &&
42
+ (/^P\d+([.,]\d+)?W$/.test(input) ||
43
+ (/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
44
+ /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
45
+ function bind(r) {
46
+ return r.test.bind(r);
47
+ }
48
+ exports.fullFormat = {
49
+ date,
50
+ time: time.bind(undefined, false),
51
+ 'date-time': date_time,
52
+ duration: DURATION,
53
+ uri,
54
+ 'uri-reference': bind(URIREF),
55
+ 'uri-template': bind(URITEMPLATE),
56
+ url: bind(URL_),
57
+ email: EMAIL,
58
+ hostname: bind(HOSTNAME),
59
+ ipv4: bind(IPV4),
60
+ ipv6: bind(IPV6),
61
+ regex: regex,
62
+ uuid: bind(UUID),
63
+ 'json-pointer': bind(JSON_POINTER),
64
+ 'json-pointer-uri-fragment': bind(JSON_POINTER_URI_FRAGMENT),
65
+ 'relative-json-pointer': bind(RELATIVE_JSON_POINTER)
66
+ };
67
+ exports.fastFormat = {
68
+ ...exports.fullFormat,
69
+ date: bind(FASTDATE),
70
+ time: bind(FASTTIME),
71
+ 'date-time': bind(FASTDATETIME),
72
+ 'uri-reference': bind(FASTURIREFERENCE)
73
+ };
74
+ function isLeapYear(year) {
75
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
76
+ }
77
+ function date(str) {
78
+ const matches = str.match(DATE);
79
+ if (!matches)
80
+ return false;
81
+ const year = +matches[1];
82
+ const month = +matches[2];
83
+ const day = +matches[3];
84
+ return (month >= 1 &&
85
+ month <= 12 &&
86
+ day >= 1 &&
87
+ day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
88
+ }
89
+ function time(full, str) {
90
+ const matches = str.match(TIME);
91
+ if (!matches)
92
+ return false;
93
+ const hour = +matches[1];
94
+ const minute = +matches[2];
95
+ const second = +matches[3];
96
+ const timeZone = !!matches[5];
97
+ return (((hour <= 23 && minute <= 59 && second <= 59) ||
98
+ (hour == 23 && minute == 59 && second == 60)) &&
99
+ (!full || timeZone));
100
+ }
101
+ const DATE_TIME_SEPARATOR = /t|\s/i;
102
+ function date_time(str) {
103
+ const dateTime = str.split(DATE_TIME_SEPARATOR);
104
+ return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
105
+ }
106
+ const NOT_URI_FRAGMENT = /\/|:/;
107
+ const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
108
+ function uri(str) {
109
+ return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
110
+ }
111
+ const Z_ANCHOR = /[^\\]\\Z/;
112
+ function regex(str) {
113
+ if (Z_ANCHOR.test(str))
114
+ return false;
115
+ try {
116
+ new RegExp(str, 'u');
117
+ return true;
118
+ }
119
+ catch (e) {
120
+ return false;
121
+ }
122
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./deep-compare-strict.js"), exports);
18
+ __exportStar(require("./dereference.js"), exports);
19
+ __exportStar(require("./format.js"), exports);
20
+ __exportStar(require("./pointer.js"), exports);
21
+ __exportStar(require("./types.js"), exports);
22
+ __exportStar(require("./ucs2-length.js"), exports);
23
+ __exportStar(require("./validate.js"), exports);
24
+ __exportStar(require("./validator.js"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodePointer = encodePointer;
4
+ exports.escapePointer = escapePointer;
5
+ function encodePointer(p) {
6
+ return encodeURI(escapePointer(p));
7
+ }
8
+ function escapePointer(p) {
9
+ return p.replace(/~/g, '~0').replace(/\//g, '~1');
10
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutputFormat = void 0;
4
+ var OutputFormat;
5
+ (function (OutputFormat) {
6
+ OutputFormat[OutputFormat["Flag"] = 1] = "Flag";
7
+ OutputFormat[OutputFormat["Basic"] = 2] = "Basic";
8
+ OutputFormat[OutputFormat["Detailed"] = 4] = "Detailed";
9
+ })(OutputFormat || (exports.OutputFormat = OutputFormat = {}));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ucs2length = ucs2length;
4
+ function ucs2length(s) {
5
+ let result = 0;
6
+ let length = s.length;
7
+ let index = 0;
8
+ let charCode;
9
+ while (index < length) {
10
+ result++;
11
+ charCode = s.charCodeAt(index++);
12
+ if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
13
+ charCode = s.charCodeAt(index);
14
+ if ((charCode & 0xfc00) == 0xdc00) {
15
+ index++;
16
+ }
17
+ }
18
+ }
19
+ return result;
20
+ }
@@ -1,3 +1,3 @@
1
1
  import { Schema, SchemaDraft, ValidationResult } from './types.js';
2
2
  export type Evaluated = Record<string | number, boolean>;
3
- export declare function validate(instance: any, schema: Schema | boolean, draft?: SchemaDraft, lookup?: Record<string, boolean | Schema>, shortCircuit?: boolean, recursiveAnchor?: Schema | null, instanceLocation?: string, schemaLocation?: string, evaluated?: Evaluated): ValidationResult;
3
+ export declare function validate(instance: any, schema: Schema | boolean, draft?: SchemaDraft, lookup?: Record<string, Schema | boolean>, shortCircuit?: boolean, recursiveAnchor?: Schema | null, instanceLocation?: string, schemaLocation?: string, evaluated?: Evaluated): ValidationResult;