Leon4gr45 commited on
Commit
0553e35
·
verified ·
1 Parent(s): 9f96b63

Upload folder using huggingface_hub (part 3)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/ajv-formats/LICENSE +21 -0
  2. node_modules/ajv-formats/README.md +125 -0
  3. node_modules/ajv-formats/package.json +74 -0
  4. node_modules/ajv-formats/src/formats.ts +269 -0
  5. node_modules/ajv-formats/src/index.ts +62 -0
  6. node_modules/ajv-formats/src/limit.ts +99 -0
  7. node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts +10 -0
  8. node_modules/ajv/lib/vocabularies/errors.ts +18 -0
  9. node_modules/ajv/lib/vocabularies/format/format.ts +120 -0
  10. node_modules/ajv/lib/vocabularies/format/index.ts +6 -0
  11. node_modules/ajv/lib/vocabularies/jtd/discriminator.ts +89 -0
  12. node_modules/ajv/lib/vocabularies/jtd/elements.ts +32 -0
  13. node_modules/ajv/lib/vocabularies/jtd/enum.ts +45 -0
  14. node_modules/ajv/lib/vocabularies/jtd/error.ts +23 -0
  15. node_modules/ajv/lib/vocabularies/jtd/index.ts +37 -0
  16. node_modules/ajv/lib/vocabularies/jtd/metadata.ts +24 -0
  17. node_modules/ajv/lib/vocabularies/jtd/nullable.ts +21 -0
  18. node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts +15 -0
  19. node_modules/ajv/lib/vocabularies/jtd/properties.ts +184 -0
  20. node_modules/ajv/lib/vocabularies/jtd/ref.ts +76 -0
  21. node_modules/ajv/lib/vocabularies/jtd/type.ts +75 -0
  22. node_modules/ajv/lib/vocabularies/jtd/union.ts +12 -0
  23. node_modules/ajv/lib/vocabularies/jtd/values.ts +58 -0
  24. node_modules/ajv/lib/vocabularies/metadata.ts +17 -0
  25. node_modules/ajv/lib/vocabularies/next.ts +8 -0
  26. node_modules/ajv/lib/vocabularies/unevaluated/index.ts +7 -0
  27. node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts +47 -0
  28. node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +85 -0
  29. node_modules/ajv/lib/vocabularies/validation/const.ts +28 -0
  30. node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts +23 -0
  31. node_modules/ajv/lib/vocabularies/validation/enum.ts +54 -0
  32. node_modules/ajv/lib/vocabularies/validation/index.ts +49 -0
  33. node_modules/ajv/lib/vocabularies/validation/limitContains.ts +16 -0
  34. node_modules/ajv/lib/vocabularies/validation/limitItems.ts +26 -0
  35. node_modules/ajv/lib/vocabularies/validation/limitLength.ts +30 -0
  36. node_modules/ajv/lib/vocabularies/validation/limitNumber.ts +42 -0
  37. node_modules/ajv/lib/vocabularies/validation/limitProperties.ts +26 -0
  38. node_modules/ajv/lib/vocabularies/validation/multipleOf.ts +34 -0
  39. node_modules/ajv/lib/vocabularies/validation/pattern.ts +39 -0
  40. node_modules/ajv/lib/vocabularies/validation/required.ts +98 -0
  41. node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts +79 -0
  42. node_modules/ajv/package.json +126 -0
  43. node_modules/ansis/LICENSE +15 -0
  44. node_modules/ansis/README.md +5 -0
  45. node_modules/ansis/index.cjs +1 -0
  46. node_modules/ansis/index.d.ts +1 -0
  47. node_modules/ansis/index.mjs +1 -0
  48. node_modules/ansis/package.json +19 -0
  49. node_modules/any-base/LICENSE +21 -0
  50. node_modules/any-base/README.md +55 -0
node_modules/ajv-formats/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Evgeny Poberezkin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/ajv-formats/README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ajv-formats
2
+
3
+ JSON Schema formats for Ajv
4
+
5
+ [![Build Status](https://travis-ci.org/ajv-validator/ajv-formats.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv-formats)
6
+ [![npm](https://img.shields.io/npm/v/ajv-formats.svg)](https://www.npmjs.com/package/ajv-formats)
7
+ [![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
8
+ [![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)
9
+
10
+ ## Usage
11
+
12
+ ```javascript
13
+ // ESM/TypeScript import
14
+ import Ajv from "ajv"
15
+ import addFormats from "ajv-formats"
16
+ // Node.js require:
17
+ const Ajv = require("ajv")
18
+ const addFormats = require("ajv-formats")
19
+
20
+ const ajv = new Ajv()
21
+ addFormats(ajv)
22
+ ```
23
+
24
+ ## Formats
25
+
26
+ The package defines these formats:
27
+
28
+ - _date_: full-date according to [RFC3339](http://tools.ietf.org/html/rfc3339#section-5.6).
29
+ - _time_: time (time-zone is mandatory).
30
+ - _date-time_: date-time (time-zone is mandatory).
31
+ - _iso-time_: time with optional time-zone.
32
+ - _iso-date-time_: date-time with optional time-zone.
33
+ - _duration_: duration from [RFC3339](https://tools.ietf.org/html/rfc3339#appendix-A)
34
+ - _uri_: full URI.
35
+ - _uri-reference_: URI reference, including full and relative URIs.
36
+ - _uri-template_: URI template according to [RFC6570](https://tools.ietf.org/html/rfc6570)
37
+ - _url_ (deprecated): [URL record](https://url.spec.whatwg.org/#concept-url).
38
+ - _email_: email address.
39
+ - _hostname_: host name according to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5).
40
+ - _ipv4_: IP address v4.
41
+ - _ipv6_: IP address v6.
42
+ - _regex_: tests whether a string is a valid regular expression by passing it to RegExp constructor.
43
+ - _uuid_: Universally Unique IDentifier according to [RFC4122](http://tools.ietf.org/html/rfc4122).
44
+ - _json-pointer_: JSON-pointer according to [RFC6901](https://tools.ietf.org/html/rfc6901).
45
+ - _relative-json-pointer_: relative JSON-pointer according to [this draft](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00).
46
+ - _byte_: base64 encoded data according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
47
+ - _int32_: signed 32 bits integer according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
48
+ - _int64_: signed 64 bits according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
49
+ - _float_: float according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
50
+ - _double_: double according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
51
+ - _password_: password string according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
52
+ - _binary_: binary string according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types)
53
+
54
+ See regular expressions used for format validation and the sources that were used in [formats.ts](https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts).
55
+
56
+ **Please note**: JSON Schema draft-07 also defines formats `iri`, `iri-reference`, `idn-hostname` and `idn-email` for URLs, hostnames and emails with international characters. These formats are available in [ajv-formats-draft2019](https://github.com/luzlab/ajv-formats-draft2019) plugin.
57
+
58
+ ## Keywords to compare values: `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum`
59
+
60
+ These keywords allow to define minimum/maximum constraints when the format keyword defines ordering (`compare` function in format definition).
61
+
62
+ These keywords are added to ajv instance when ajv-formats is used without options or with option `keywords: true`.
63
+
64
+ These keywords apply only to strings. If the data is not a string, the validation succeeds.
65
+
66
+ The value of keywords `formatMaximum`/`formatMinimum` and `formatExclusiveMaximum`/`formatExclusiveMinimum` should be a string or [\$data reference](https://github.com/ajv-validator/ajv/blob/master/docs/validation.md#data-reference). This value is the maximum (minimum) allowed value for the data to be valid as determined by `format` keyword. If `format` keyword is not present schema compilation will throw exception.
67
+
68
+ When these keyword are added, they also add comparison functions to formats `"date"`, `"time"` and `"date-time"`. User-defined formats also can have comparison functions. See [addFormat](https://github.com/ajv-validator/ajv/blob/master/docs/api.md#api-addformat) method.
69
+
70
+ ```javascript
71
+ require("ajv-formats")(ajv)
72
+
73
+ const schema = {
74
+ type: "string",
75
+ format: "date",
76
+ formatMinimum: "2016-02-06",
77
+ formatExclusiveMaximum: "2016-12-27",
78
+ }
79
+
80
+ const validDataList = ["2016-02-06", "2016-12-26"]
81
+
82
+ const invalidDataList = ["2016-02-05", "2016-12-27", "abc"]
83
+ ```
84
+
85
+ ## Options
86
+
87
+ Options can be passed via the second parameter. Options value can be
88
+
89
+ 1. The list of format names that will be added to ajv instance:
90
+
91
+ ```javascript
92
+ addFormats(ajv, ["date", "time"])
93
+ ```
94
+
95
+ **Please note**: when ajv encounters an undefined format it throws exception (unless ajv instance was configured with `strict: false` option). To allow specific undefined formats they have to be passed to ajv instance via `formats` option with `true` value:
96
+
97
+ ```javascript
98
+ const ajv = new Ajv((formats: {date: true, time: true})) // to ignore "date" and "time" formats in schemas.
99
+ ```
100
+
101
+ 2. Format validation mode (default is `"full"`) with optional list of format names and `keywords` option to add additional format comparison keywords:
102
+
103
+ ```javascript
104
+ addFormats(ajv, {mode: "fast"})
105
+ ```
106
+
107
+ or
108
+
109
+ ```javascript
110
+ addFormats(ajv, {mode: "fast", formats: ["date", "time"], keywords: true})
111
+ ```
112
+
113
+ In `"fast"` mode the following formats are simplified: `"date"`, `"time"`, `"date-time"`, `"iso-time"`, `"iso-date-time"`, `"uri"`, `"uri-reference"`, `"email"`. For example, `"date"`, `"time"` and `"date-time"` do not validate ranges in `"fast"` mode, only string structure, and other formats have simplified regular expressions.
114
+
115
+ ## Tests
116
+
117
+ ```bash
118
+ npm install
119
+ git submodule update --init
120
+ npm test
121
+ ```
122
+
123
+ ## License
124
+
125
+ [MIT](https://github.com/ajv-validator/ajv-formats/blob/master/LICENSE)
node_modules/ajv-formats/package.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ajv-formats",
3
+ "version": "3.0.1",
4
+ "description": "Format validation for Ajv v7+",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "src/",
9
+ "dist/"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "prettier:write": "prettier --write \"./**/*.{md,json,yaml,js,ts}\"",
14
+ "prettier:check": "prettier --list-different \"./**/*.{md,json,yaml,js,ts}\"",
15
+ "eslint": "eslint --ext .ts ./src/**/*",
16
+ "test-spec": "jest",
17
+ "test-cov": "jest --coverage",
18
+ "test": "npm run prettier:check && npm run build && npm run eslint && npm run test-cov",
19
+ "ci-test": "npm run test"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/ajv-validator/ajv-formats.git"
24
+ },
25
+ "keywords": [
26
+ "Ajv",
27
+ "JSON-Schema",
28
+ "format",
29
+ "validation"
30
+ ],
31
+ "author": "Evgeny Poberezkin",
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/ajv-validator/ajv-formats/issues"
35
+ },
36
+ "homepage": "https://github.com/ajv-validator/ajv-formats#readme",
37
+ "dependencies": {
38
+ "ajv": "^8.0.0"
39
+ },
40
+ "peerDependencies": {
41
+ "ajv": "^8.0.0"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "ajv": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "devDependencies": {
49
+ "@ajv-validator/config": "^0.3.0",
50
+ "@types/jest": "^26.0.5",
51
+ "@types/node": "^14.10.1",
52
+ "@typescript-eslint/eslint-plugin": "^3.7.0",
53
+ "@typescript-eslint/parser": "^3.7.0",
54
+ "ajv": "^8.0.0",
55
+ "eslint": "^7.5.0",
56
+ "eslint-config-prettier": "^6.11.0",
57
+ "husky": "^4.2.5",
58
+ "jest": "^26.1.0",
59
+ "json-schema-test": "^2.0.0",
60
+ "lint-staged": "^10.2.11",
61
+ "prettier": "^2.3.2",
62
+ "ts-jest": "^26.1.3",
63
+ "typescript": "^4.0.0"
64
+ },
65
+ "prettier": "@ajv-validator/config/prettierrc.json",
66
+ "husky": {
67
+ "hooks": {
68
+ "pre-commit": "lint-staged && npm test"
69
+ }
70
+ },
71
+ "lint-staged": {
72
+ "*.{md,json,yaml,js,ts}": "prettier --write"
73
+ }
74
+ }
node_modules/ajv-formats/src/formats.ts ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {Format, FormatDefinition} from "ajv"
2
+ import type {FormatValidator, FormatCompare} from "ajv/dist/types"
3
+
4
+ export type FormatMode = "fast" | "full"
5
+
6
+ export type FormatName =
7
+ | "date"
8
+ | "time"
9
+ | "date-time"
10
+ | "iso-time"
11
+ | "iso-date-time"
12
+ | "duration"
13
+ | "uri"
14
+ | "uri-reference"
15
+ | "uri-template"
16
+ | "url"
17
+ | "email"
18
+ | "hostname"
19
+ | "ipv4"
20
+ | "ipv6"
21
+ | "regex"
22
+ | "uuid"
23
+ | "json-pointer"
24
+ | "json-pointer-uri-fragment"
25
+ | "relative-json-pointer"
26
+ | "byte"
27
+ | "int32"
28
+ | "int64"
29
+ | "float"
30
+ | "double"
31
+ | "password"
32
+ | "binary"
33
+
34
+ export type DefinedFormats = {
35
+ [key in FormatName]: Format
36
+ }
37
+
38
+ function fmtDef(
39
+ validate: RegExp | FormatValidator<string>,
40
+ compare: FormatCompare<string>
41
+ ): FormatDefinition<string> {
42
+ return {validate, compare}
43
+ }
44
+
45
+ export const fullFormats: DefinedFormats = {
46
+ // date: http://tools.ietf.org/html/rfc3339#section-5.6
47
+ date: fmtDef(date, compareDate),
48
+ // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
49
+ time: fmtDef(getTime(true), compareTime),
50
+ "date-time": fmtDef(getDateTime(true), compareDateTime),
51
+ "iso-time": fmtDef(getTime(), compareIsoTime),
52
+ "iso-date-time": fmtDef(getDateTime(), compareIsoDateTime),
53
+ // duration: https://tools.ietf.org/html/rfc3339#appendix-A
54
+ duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,
55
+ uri,
56
+ "uri-reference":
57
+ /^(?:[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,
58
+ // uri-template: https://tools.ietf.org/html/rfc6570
59
+ "uri-template":
60
+ /^(?:(?:[^\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,
61
+ // For the source: https://gist.github.com/dperini/729294
62
+ // For test cases: https://mathiasbynens.be/demo/url-regex
63
+ url: /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|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-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,
64
+ email:
65
+ /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
66
+ hostname:
67
+ /^(?=.{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,
68
+ // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
69
+ ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
70
+ 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,
71
+ regex,
72
+ // uuid: http://tools.ietf.org/html/rfc4122
73
+ uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,
74
+ // JSON-pointer: https://tools.ietf.org/html/rfc6901
75
+ // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
76
+ "json-pointer": /^(?:\/(?:[^~/]|~0|~1)*)*$/,
77
+ "json-pointer-uri-fragment": /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,
78
+ // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
79
+ "relative-json-pointer": /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,
80
+ // the following formats are used by the openapi specification: https://spec.openapis.org/oas/v3.0.0#data-types
81
+ // byte: https://github.com/miguelmota/is-base64
82
+ byte,
83
+ // signed 32 bit integer
84
+ int32: {type: "number", validate: validateInt32},
85
+ // signed 64 bit integer
86
+ int64: {type: "number", validate: validateInt64},
87
+ // C-type float
88
+ float: {type: "number", validate: validateNumber},
89
+ // C-type double
90
+ double: {type: "number", validate: validateNumber},
91
+ // hint to the UI to hide input strings
92
+ password: true,
93
+ // unchecked string payload
94
+ binary: true,
95
+ }
96
+
97
+ export const fastFormats: DefinedFormats = {
98
+ ...fullFormats,
99
+ date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate),
100
+ time: fmtDef(
101
+ /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
102
+ compareTime
103
+ ),
104
+ "date-time": fmtDef(
105
+ /^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
106
+ compareDateTime
107
+ ),
108
+ "iso-time": fmtDef(
109
+ /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
110
+ compareIsoTime
111
+ ),
112
+ "iso-date-time": fmtDef(
113
+ /^\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,
114
+ compareIsoDateTime
115
+ ),
116
+ // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
117
+ uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
118
+ "uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
119
+ // email (sources from jsen validator):
120
+ // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
121
+ // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'wilful violation')
122
+ email:
123
+ /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
124
+ }
125
+
126
+ export const formatNames = Object.keys(fullFormats) as FormatName[]
127
+
128
+ function isLeapYear(year: number): boolean {
129
+ // https://tools.ietf.org/html/rfc3339#appendix-C
130
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
131
+ }
132
+
133
+ const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
134
+ const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
135
+
136
+ function date(str: string): boolean {
137
+ // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
138
+ const matches: string[] | null = DATE.exec(str)
139
+ if (!matches) return false
140
+ const year: number = +matches[1]
141
+ const month: number = +matches[2]
142
+ const day: number = +matches[3]
143
+ return (
144
+ month >= 1 &&
145
+ month <= 12 &&
146
+ day >= 1 &&
147
+ day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month])
148
+ )
149
+ }
150
+
151
+ function compareDate(d1: string, d2: string): number | undefined {
152
+ if (!(d1 && d2)) return undefined
153
+ if (d1 > d2) return 1
154
+ if (d1 < d2) return -1
155
+ return 0
156
+ }
157
+
158
+ const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i
159
+
160
+ function getTime(strictTimeZone?: boolean): (str: string) => boolean {
161
+ return function time(str: string): boolean {
162
+ const matches: string[] | null = TIME.exec(str)
163
+ if (!matches) return false
164
+ const hr: number = +matches[1]
165
+ const min: number = +matches[2]
166
+ const sec: number = +matches[3]
167
+ const tz: string | undefined = matches[4]
168
+ const tzSign: number = matches[5] === "-" ? -1 : 1
169
+ const tzH: number = +(matches[6] || 0)
170
+ const tzM: number = +(matches[7] || 0)
171
+ if (tzH > 23 || tzM > 59 || (strictTimeZone && !tz)) return false
172
+ if (hr <= 23 && min <= 59 && sec < 60) return true
173
+ // leap second
174
+ const utcMin = min - tzM * tzSign
175
+ const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0)
176
+ return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61
177
+ }
178
+ }
179
+
180
+ function compareTime(s1: string, s2: string): number | undefined {
181
+ if (!(s1 && s2)) return undefined
182
+ const t1 = new Date("2020-01-01T" + s1).valueOf()
183
+ const t2 = new Date("2020-01-01T" + s2).valueOf()
184
+ if (!(t1 && t2)) return undefined
185
+ return t1 - t2
186
+ }
187
+
188
+ function compareIsoTime(t1: string, t2: string): number | undefined {
189
+ if (!(t1 && t2)) return undefined
190
+ const a1 = TIME.exec(t1)
191
+ const a2 = TIME.exec(t2)
192
+ if (!(a1 && a2)) return undefined
193
+ t1 = a1[1] + a1[2] + a1[3]
194
+ t2 = a2[1] + a2[2] + a2[3]
195
+ if (t1 > t2) return 1
196
+ if (t1 < t2) return -1
197
+ return 0
198
+ }
199
+
200
+ const DATE_TIME_SEPARATOR = /t|\s/i
201
+ function getDateTime(strictTimeZone?: boolean): (str: string) => boolean {
202
+ const time = getTime(strictTimeZone)
203
+
204
+ return function date_time(str: string): boolean {
205
+ // http://tools.ietf.org/html/rfc3339#section-5.6
206
+ const dateTime: string[] = str.split(DATE_TIME_SEPARATOR)
207
+ return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1])
208
+ }
209
+ }
210
+
211
+ function compareDateTime(dt1: string, dt2: string): number | undefined {
212
+ if (!(dt1 && dt2)) return undefined
213
+ const d1 = new Date(dt1).valueOf()
214
+ const d2 = new Date(dt2).valueOf()
215
+ if (!(d1 && d2)) return undefined
216
+ return d1 - d2
217
+ }
218
+
219
+ function compareIsoDateTime(dt1: string, dt2: string): number | undefined {
220
+ if (!(dt1 && dt2)) return undefined
221
+ const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR)
222
+ const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR)
223
+ const res = compareDate(d1, d2)
224
+ if (res === undefined) return undefined
225
+ return res || compareTime(t1, t2)
226
+ }
227
+
228
+ const NOT_URI_FRAGMENT = /\/|:/
229
+ const URI =
230
+ /^(?:[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
231
+
232
+ function uri(str: string): boolean {
233
+ // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
234
+ return NOT_URI_FRAGMENT.test(str) && URI.test(str)
235
+ }
236
+
237
+ const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm
238
+
239
+ function byte(str: string): boolean {
240
+ BYTE.lastIndex = 0
241
+ return BYTE.test(str)
242
+ }
243
+
244
+ const MIN_INT32 = -(2 ** 31)
245
+ const MAX_INT32 = 2 ** 31 - 1
246
+
247
+ function validateInt32(value: number): boolean {
248
+ return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32
249
+ }
250
+
251
+ function validateInt64(value: number): boolean {
252
+ // JSON and javascript max Int is 2**53, so any int that passes isInteger is valid for Int64
253
+ return Number.isInteger(value)
254
+ }
255
+
256
+ function validateNumber(): boolean {
257
+ return true
258
+ }
259
+
260
+ const Z_ANCHOR = /[^\\]\\Z/
261
+ function regex(str: string): boolean {
262
+ if (Z_ANCHOR.test(str)) return false
263
+ try {
264
+ new RegExp(str)
265
+ return true
266
+ } catch (e) {
267
+ return false
268
+ }
269
+ }
node_modules/ajv-formats/src/index.ts ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ DefinedFormats,
3
+ FormatMode,
4
+ FormatName,
5
+ formatNames,
6
+ fastFormats,
7
+ fullFormats,
8
+ } from "./formats"
9
+ import formatLimit from "./limit"
10
+ import type Ajv from "ajv"
11
+ import type {Plugin, Format} from "ajv"
12
+ import {_, Name} from "ajv/dist/compile/codegen"
13
+
14
+ export {FormatMode, FormatName} from "./formats"
15
+ export {LimitFormatError} from "./limit"
16
+ export interface FormatOptions {
17
+ mode?: FormatMode
18
+ formats?: FormatName[]
19
+ keywords?: boolean
20
+ }
21
+
22
+ export type FormatsPluginOptions = FormatName[] | FormatOptions
23
+
24
+ export interface FormatsPlugin extends Plugin<FormatsPluginOptions> {
25
+ get: (format: FormatName, mode?: FormatMode) => Format
26
+ }
27
+
28
+ const fullName = new Name("fullFormats")
29
+ const fastName = new Name("fastFormats")
30
+
31
+ const formatsPlugin: FormatsPlugin = (
32
+ ajv: Ajv,
33
+ opts: FormatsPluginOptions = {keywords: true}
34
+ ): Ajv => {
35
+ if (Array.isArray(opts)) {
36
+ addFormats(ajv, opts, fullFormats, fullName)
37
+ return ajv
38
+ }
39
+ const [formats, exportName] =
40
+ opts.mode === "fast" ? [fastFormats, fastName] : [fullFormats, fullName]
41
+ const list = opts.formats || formatNames
42
+ addFormats(ajv, list, formats, exportName)
43
+ if (opts.keywords) formatLimit(ajv)
44
+ return ajv
45
+ }
46
+
47
+ formatsPlugin.get = (name: FormatName, mode: FormatMode = "full"): Format => {
48
+ const formats = mode === "fast" ? fastFormats : fullFormats
49
+ const f = formats[name]
50
+ if (!f) throw new Error(`Unknown format "${name}"`)
51
+ return f
52
+ }
53
+
54
+ function addFormats(ajv: Ajv, list: FormatName[], fs: DefinedFormats, exportName: Name): void {
55
+ ajv.opts.code.formats ??= _`require("ajv-formats/dist/formats").${exportName}`
56
+ for (const f of list) ajv.addFormat(f, fs[f])
57
+ }
58
+
59
+ module.exports = exports = formatsPlugin
60
+ Object.defineProperty(exports, "__esModule", {value: true})
61
+
62
+ export default formatsPlugin
node_modules/ajv-formats/src/limit.ts ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type Ajv from "ajv"
2
+ import type {
3
+ Plugin,
4
+ CodeKeywordDefinition,
5
+ KeywordErrorDefinition,
6
+ Code,
7
+ Name,
8
+ ErrorObject,
9
+ } from "ajv"
10
+ import type {AddedFormat} from "ajv/dist/types"
11
+ import type {Rule} from "ajv/dist/compile/rules"
12
+ import {KeywordCxt} from "ajv"
13
+ import {_, str, or, getProperty, operators} from "ajv/dist/compile/codegen"
14
+
15
+ type Kwd = "formatMaximum" | "formatMinimum" | "formatExclusiveMaximum" | "formatExclusiveMinimum"
16
+
17
+ type Comparison = "<=" | ">=" | "<" | ">"
18
+
19
+ const ops = operators
20
+
21
+ const KWDs: {[K in Kwd]: {okStr: Comparison; ok: Code; fail: Code}} = {
22
+ formatMaximum: {okStr: "<=", ok: ops.LTE, fail: ops.GT},
23
+ formatMinimum: {okStr: ">=", ok: ops.GTE, fail: ops.LT},
24
+ formatExclusiveMaximum: {okStr: "<", ok: ops.LT, fail: ops.GTE},
25
+ formatExclusiveMinimum: {okStr: ">", ok: ops.GT, fail: ops.LTE},
26
+ }
27
+
28
+ export type LimitFormatError = ErrorObject<Kwd, {limit: string; comparison: Comparison}>
29
+
30
+ const error: KeywordErrorDefinition = {
31
+ message: ({keyword, schemaCode}) => str`should be ${KWDs[keyword as Kwd].okStr} ${schemaCode}`,
32
+ params: ({keyword, schemaCode}) =>
33
+ _`{comparison: ${KWDs[keyword as Kwd].okStr}, limit: ${schemaCode}}`,
34
+ }
35
+
36
+ export const formatLimitDefinition: CodeKeywordDefinition = {
37
+ keyword: Object.keys(KWDs),
38
+ type: "string",
39
+ schemaType: "string",
40
+ $data: true,
41
+ error,
42
+ code(cxt) {
43
+ const {gen, data, schemaCode, keyword, it} = cxt
44
+ const {opts, self} = it
45
+ if (!opts.validateFormats) return
46
+
47
+ const fCxt = new KeywordCxt(it, (self.RULES.all.format as Rule).definition, "format")
48
+ if (fCxt.$data) validate$DataFormat()
49
+ else validateFormat()
50
+
51
+ function validate$DataFormat(): void {
52
+ const fmts = gen.scopeValue("formats", {
53
+ ref: self.formats,
54
+ code: opts.code.formats,
55
+ })
56
+ const fmt = gen.const("fmt", _`${fmts}[${fCxt.schemaCode}]`)
57
+ cxt.fail$data(
58
+ or(
59
+ _`typeof ${fmt} != "object"`,
60
+ _`${fmt} instanceof RegExp`,
61
+ _`typeof ${fmt}.compare != "function"`,
62
+ compareCode(fmt)
63
+ )
64
+ )
65
+ }
66
+
67
+ function validateFormat(): void {
68
+ const format = fCxt.schema as string
69
+ const fmtDef: AddedFormat | undefined = self.formats[format]
70
+ if (!fmtDef || fmtDef === true) return
71
+ if (
72
+ typeof fmtDef != "object" ||
73
+ fmtDef instanceof RegExp ||
74
+ typeof fmtDef.compare != "function"
75
+ ) {
76
+ throw new Error(`"${keyword}": format "${format}" does not define "compare" function`)
77
+ }
78
+ const fmt = gen.scopeValue("formats", {
79
+ key: format,
80
+ ref: fmtDef,
81
+ code: opts.code.formats ? _`${opts.code.formats}${getProperty(format)}` : undefined,
82
+ })
83
+
84
+ cxt.fail$data(compareCode(fmt))
85
+ }
86
+
87
+ function compareCode(fmt: Name): Code {
88
+ return _`${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword as Kwd].fail} 0`
89
+ }
90
+ },
91
+ dependencies: ["format"],
92
+ }
93
+
94
+ const formatLimitPlugin: Plugin<undefined> = (ajv: Ajv): Ajv => {
95
+ ajv.addKeyword(formatLimitDefinition)
96
+ return ajv
97
+ }
98
+
99
+ export default formatLimitPlugin
node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition} from "../../types"
2
+ import {dynamicRef} from "./dynamicRef"
3
+
4
+ const def: CodeKeywordDefinition = {
5
+ keyword: "$recursiveRef",
6
+ schemaType: "string",
7
+ code: (cxt) => dynamicRef(cxt, cxt.schema),
8
+ }
9
+
10
+ export default def
node_modules/ajv/lib/vocabularies/errors.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {TypeError} from "../compile/validate/dataType"
2
+ import type {ApplicatorKeywordError} from "./applicator"
3
+ import type {ValidationKeywordError} from "./validation"
4
+ import type {FormatError} from "./format/format"
5
+ import type {UnevaluatedPropertiesError} from "./unevaluated/unevaluatedProperties"
6
+ import type {UnevaluatedItemsError} from "./unevaluated/unevaluatedItems"
7
+ import type {DependentRequiredError} from "./validation/dependentRequired"
8
+ import type {DiscriminatorError} from "./discriminator"
9
+
10
+ export type DefinedError =
11
+ | TypeError
12
+ | ApplicatorKeywordError
13
+ | ValidationKeywordError
14
+ | FormatError
15
+ | UnevaluatedPropertiesError
16
+ | UnevaluatedItemsError
17
+ | DependentRequiredError
18
+ | DiscriminatorError
node_modules/ajv/lib/vocabularies/format/format.ts ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ AddedFormat,
3
+ FormatValidator,
4
+ AsyncFormatValidator,
5
+ CodeKeywordDefinition,
6
+ KeywordErrorDefinition,
7
+ ErrorObject,
8
+ } from "../../types"
9
+ import type {KeywordCxt} from "../../compile/validate"
10
+ import {_, str, nil, or, Code, getProperty, regexpCode} from "../../compile/codegen"
11
+
12
+ type FormatValidate =
13
+ | FormatValidator<string>
14
+ | FormatValidator<number>
15
+ | AsyncFormatValidator<string>
16
+ | AsyncFormatValidator<number>
17
+ | RegExp
18
+ | string
19
+ | true
20
+
21
+ export type FormatError = ErrorObject<"format", {format: string}, string | {$data: string}>
22
+
23
+ const error: KeywordErrorDefinition = {
24
+ message: ({schemaCode}) => str`must match format "${schemaCode}"`,
25
+ params: ({schemaCode}) => _`{format: ${schemaCode}}`,
26
+ }
27
+
28
+ const def: CodeKeywordDefinition = {
29
+ keyword: "format",
30
+ type: ["number", "string"],
31
+ schemaType: "string",
32
+ $data: true,
33
+ error,
34
+ code(cxt: KeywordCxt, ruleType?: string) {
35
+ const {gen, data, $data, schema, schemaCode, it} = cxt
36
+ const {opts, errSchemaPath, schemaEnv, self} = it
37
+ if (!opts.validateFormats) return
38
+
39
+ if ($data) validate$DataFormat()
40
+ else validateFormat()
41
+
42
+ function validate$DataFormat(): void {
43
+ const fmts = gen.scopeValue("formats", {
44
+ ref: self.formats,
45
+ code: opts.code.formats,
46
+ })
47
+ const fDef = gen.const("fDef", _`${fmts}[${schemaCode}]`)
48
+ const fType = gen.let("fType")
49
+ const format = gen.let("format")
50
+ // TODO simplify
51
+ gen.if(
52
+ _`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`,
53
+ () => gen.assign(fType, _`${fDef}.type || "string"`).assign(format, _`${fDef}.validate`),
54
+ () => gen.assign(fType, _`"string"`).assign(format, fDef)
55
+ )
56
+ cxt.fail$data(or(unknownFmt(), invalidFmt()))
57
+
58
+ function unknownFmt(): Code {
59
+ if (opts.strictSchema === false) return nil
60
+ return _`${schemaCode} && !${format}`
61
+ }
62
+
63
+ function invalidFmt(): Code {
64
+ const callFormat = schemaEnv.$async
65
+ ? _`(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))`
66
+ : _`${format}(${data})`
67
+ const validData = _`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`
68
+ return _`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`
69
+ }
70
+ }
71
+
72
+ function validateFormat(): void {
73
+ const formatDef: AddedFormat | undefined = self.formats[schema]
74
+ if (!formatDef) {
75
+ unknownFormat()
76
+ return
77
+ }
78
+ if (formatDef === true) return
79
+ const [fmtType, format, fmtRef] = getFormat(formatDef)
80
+ if (fmtType === ruleType) cxt.pass(validCondition())
81
+
82
+ function unknownFormat(): void {
83
+ if (opts.strictSchema === false) {
84
+ self.logger.warn(unknownMsg())
85
+ return
86
+ }
87
+ throw new Error(unknownMsg())
88
+
89
+ function unknownMsg(): string {
90
+ return `unknown format "${schema as string}" ignored in schema at path "${errSchemaPath}"`
91
+ }
92
+ }
93
+
94
+ function getFormat(fmtDef: AddedFormat): [string, FormatValidate, Code] {
95
+ const code =
96
+ fmtDef instanceof RegExp
97
+ ? regexpCode(fmtDef)
98
+ : opts.code.formats
99
+ ? _`${opts.code.formats}${getProperty(schema)}`
100
+ : undefined
101
+ const fmt = gen.scopeValue("formats", {key: schema, ref: fmtDef, code})
102
+ if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
103
+ return [fmtDef.type || "string", fmtDef.validate, _`${fmt}.validate`]
104
+ }
105
+
106
+ return ["string", fmtDef, fmt]
107
+ }
108
+
109
+ function validCondition(): Code {
110
+ if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) {
111
+ if (!schemaEnv.$async) throw new Error("async format in sync schema")
112
+ return _`await ${fmtRef}(${data})`
113
+ }
114
+ return typeof format == "function" ? _`${fmtRef}(${data})` : _`${fmtRef}.test(${data})`
115
+ }
116
+ }
117
+ },
118
+ }
119
+
120
+ export default def
node_modules/ajv/lib/vocabularies/format/index.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import type {Vocabulary} from "../../types"
2
+ import formatKeyword from "./format"
3
+
4
+ const format: Vocabulary = [formatKeyword]
5
+
6
+ export default format
node_modules/ajv/lib/vocabularies/jtd/discriminator.ts ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, not, getProperty, Name} from "../../compile/codegen"
4
+ import {checkMetadata} from "./metadata"
5
+ import {checkNullableObject} from "./nullable"
6
+ import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"
7
+ import {DiscrError, DiscrErrorObj} from "../discriminator/types"
8
+
9
+ export type JTDDiscriminatorError =
10
+ | _JTDTypeError<"discriminator", "object", string>
11
+ | DiscrErrorObj<DiscrError.Tag>
12
+ | DiscrErrorObj<DiscrError.Mapping>
13
+
14
+ const error: KeywordErrorDefinition = {
15
+ message: (cxt) => {
16
+ const {schema, params} = cxt
17
+ return params.discrError
18
+ ? params.discrError === DiscrError.Tag
19
+ ? `tag "${schema}" must be string`
20
+ : `value of tag "${schema}" must be in mapping`
21
+ : typeErrorMessage(cxt, "object")
22
+ },
23
+ params: (cxt) => {
24
+ const {schema, params} = cxt
25
+ return params.discrError
26
+ ? _`{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}`
27
+ : typeErrorParams(cxt, "object")
28
+ },
29
+ }
30
+
31
+ const def: CodeKeywordDefinition = {
32
+ keyword: "discriminator",
33
+ schemaType: "string",
34
+ implements: ["mapping"],
35
+ error,
36
+ code(cxt: KeywordCxt) {
37
+ checkMetadata(cxt)
38
+ const {gen, data, schema, parentSchema} = cxt
39
+ const [valid, cond] = checkNullableObject(cxt, data)
40
+
41
+ gen.if(cond)
42
+ validateDiscriminator()
43
+ gen.elseIf(not(valid))
44
+ cxt.error()
45
+ gen.endIf()
46
+ cxt.ok(valid)
47
+
48
+ function validateDiscriminator(): void {
49
+ const tag = gen.const("tag", _`${data}${getProperty(schema)}`)
50
+ gen.if(_`${tag} === undefined`)
51
+ cxt.error(false, {discrError: DiscrError.Tag, tag})
52
+ gen.elseIf(_`typeof ${tag} == "string"`)
53
+ validateMapping(tag)
54
+ gen.else()
55
+ cxt.error(false, {discrError: DiscrError.Tag, tag}, {instancePath: schema})
56
+ gen.endIf()
57
+ }
58
+
59
+ function validateMapping(tag: Name): void {
60
+ gen.if(false)
61
+ for (const tagValue in parentSchema.mapping) {
62
+ gen.elseIf(_`${tag} === ${tagValue}`)
63
+ gen.assign(valid, applyTagSchema(tagValue))
64
+ }
65
+ gen.else()
66
+ cxt.error(
67
+ false,
68
+ {discrError: DiscrError.Mapping, tag},
69
+ {instancePath: schema, schemaPath: "mapping", parentSchema: true}
70
+ )
71
+ gen.endIf()
72
+ }
73
+
74
+ function applyTagSchema(schemaProp: string): Name {
75
+ const _valid = gen.name("valid")
76
+ cxt.subschema(
77
+ {
78
+ keyword: "mapping",
79
+ schemaProp,
80
+ jtdDiscriminator: schema,
81
+ },
82
+ _valid
83
+ )
84
+ return _valid
85
+ }
86
+ },
87
+ }
88
+
89
+ export default def
node_modules/ajv/lib/vocabularies/jtd/elements.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, SchemaObject} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {alwaysValidSchema} from "../../compile/util"
4
+ import {validateArray} from "../code"
5
+ import {_, not} from "../../compile/codegen"
6
+ import {checkMetadata} from "./metadata"
7
+ import {checkNullable} from "./nullable"
8
+ import {typeError, _JTDTypeError} from "./error"
9
+
10
+ export type JTDElementsError = _JTDTypeError<"elements", "array", SchemaObject>
11
+
12
+ const def: CodeKeywordDefinition = {
13
+ keyword: "elements",
14
+ schemaType: "object",
15
+ error: typeError("array"),
16
+ code(cxt: KeywordCxt) {
17
+ checkMetadata(cxt)
18
+ const {gen, data, schema, it} = cxt
19
+ if (alwaysValidSchema(it, schema)) return
20
+ const [valid] = checkNullable(cxt)
21
+ gen.if(not(valid), () =>
22
+ gen.if(
23
+ _`Array.isArray(${data})`,
24
+ () => gen.assign(valid, validateArray(cxt)),
25
+ () => cxt.error()
26
+ )
27
+ )
28
+ cxt.ok(valid)
29
+ },
30
+ }
31
+
32
+ export default def
node_modules/ajv/lib/vocabularies/jtd/enum.ts ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, or, and, Code} from "../../compile/codegen"
4
+ import {checkMetadata} from "./metadata"
5
+ import {checkNullable} from "./nullable"
6
+
7
+ export type JTDEnumError = ErrorObject<"enum", {allowedValues: string[]}, string[]>
8
+
9
+ const error: KeywordErrorDefinition = {
10
+ message: "must be equal to one of the allowed values",
11
+ params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`,
12
+ }
13
+
14
+ const def: CodeKeywordDefinition = {
15
+ keyword: "enum",
16
+ schemaType: "array",
17
+ error,
18
+ code(cxt: KeywordCxt) {
19
+ checkMetadata(cxt)
20
+ const {gen, data, schema, schemaValue, parentSchema, it} = cxt
21
+ if (schema.length === 0) throw new Error("enum must have non-empty array")
22
+ if (schema.length !== new Set(schema).size) throw new Error("enum items must be unique")
23
+ let valid: Code
24
+ const isString = _`typeof ${data} == "string"`
25
+ if (schema.length >= it.opts.loopEnum) {
26
+ let cond: Code
27
+ ;[valid, cond] = checkNullable(cxt, isString)
28
+ gen.if(cond, loopEnum)
29
+ } else {
30
+ /* istanbul ignore if */
31
+ if (!Array.isArray(schema)) throw new Error("ajv implementation error")
32
+ valid = and(isString, or(...schema.map((value: string) => _`${data} === ${value}`)))
33
+ if (parentSchema.nullable) valid = or(_`${data} === null`, valid)
34
+ }
35
+ cxt.pass(valid)
36
+
37
+ function loopEnum(): void {
38
+ gen.forOf("v", schemaValue as Code, (v) =>
39
+ gen.if(_`${valid} = ${data} === ${v}`, () => gen.break())
40
+ )
41
+ }
42
+ },
43
+ }
44
+
45
+ export default def
node_modules/ajv/lib/vocabularies/jtd/error.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {KeywordErrorDefinition, KeywordErrorCxt, ErrorObject} from "../../types"
2
+ import {_, Code} from "../../compile/codegen"
3
+
4
+ export type _JTDTypeError<K extends string, T extends string, S> = ErrorObject<
5
+ K,
6
+ {type: T; nullable: boolean},
7
+ S
8
+ >
9
+
10
+ export function typeError(t: string): KeywordErrorDefinition {
11
+ return {
12
+ message: (cxt) => typeErrorMessage(cxt, t),
13
+ params: (cxt) => typeErrorParams(cxt, t),
14
+ }
15
+ }
16
+
17
+ export function typeErrorMessage({parentSchema}: KeywordErrorCxt, t: string): string {
18
+ return parentSchema?.nullable ? `must be ${t} or null` : `must be ${t}`
19
+ }
20
+
21
+ export function typeErrorParams({parentSchema}: KeywordErrorCxt, t: string): Code {
22
+ return _`{type: ${t}, nullable: ${!!parentSchema?.nullable}}`
23
+ }
node_modules/ajv/lib/vocabularies/jtd/index.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {Vocabulary} from "../../types"
2
+ import refKeyword from "./ref"
3
+ import typeKeyword, {JTDTypeError} from "./type"
4
+ import enumKeyword, {JTDEnumError} from "./enum"
5
+ import elements, {JTDElementsError} from "./elements"
6
+ import properties, {JTDPropertiesError} from "./properties"
7
+ import optionalProperties from "./optionalProperties"
8
+ import discriminator, {JTDDiscriminatorError} from "./discriminator"
9
+ import values, {JTDValuesError} from "./values"
10
+ import union from "./union"
11
+ import metadata from "./metadata"
12
+
13
+ const jtdVocabulary: Vocabulary = [
14
+ "definitions",
15
+ refKeyword,
16
+ typeKeyword,
17
+ enumKeyword,
18
+ elements,
19
+ properties,
20
+ optionalProperties,
21
+ discriminator,
22
+ values,
23
+ union,
24
+ metadata,
25
+ {keyword: "additionalProperties", schemaType: "boolean"},
26
+ {keyword: "nullable", schemaType: "boolean"},
27
+ ]
28
+
29
+ export default jtdVocabulary
30
+
31
+ export type JTDErrorObject =
32
+ | JTDTypeError
33
+ | JTDEnumError
34
+ | JTDElementsError
35
+ | JTDPropertiesError
36
+ | JTDDiscriminatorError
37
+ | JTDValuesError
node_modules/ajv/lib/vocabularies/jtd/metadata.ts ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {KeywordCxt} from "../../ajv"
2
+ import type {CodeKeywordDefinition} from "../../types"
3
+ import {alwaysValidSchema} from "../../compile/util"
4
+
5
+ const def: CodeKeywordDefinition = {
6
+ keyword: "metadata",
7
+ schemaType: "object",
8
+ code(cxt: KeywordCxt) {
9
+ checkMetadata(cxt)
10
+ const {gen, schema, it} = cxt
11
+ if (alwaysValidSchema(it, schema)) return
12
+ const valid = gen.name("valid")
13
+ cxt.subschema({keyword: "metadata", jtdMetadata: true}, valid)
14
+ cxt.ok(valid)
15
+ },
16
+ }
17
+
18
+ export function checkMetadata({it, keyword}: KeywordCxt, metadata?: boolean): void {
19
+ if (it.jtdMetadata !== metadata) {
20
+ throw new Error(`JTD: "${keyword}" cannot be used in this schema location`)
21
+ }
22
+ }
23
+
24
+ export default def
node_modules/ajv/lib/vocabularies/jtd/nullable.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {KeywordCxt} from "../../compile/validate"
2
+ import {_, not, nil, Code, Name} from "../../compile/codegen"
3
+
4
+ export function checkNullable(
5
+ {gen, data, parentSchema}: KeywordCxt,
6
+ cond: Code = nil
7
+ ): [Name, Code] {
8
+ const valid = gen.name("valid")
9
+ if (parentSchema.nullable) {
10
+ gen.let(valid, _`${data} === null`)
11
+ cond = not(valid)
12
+ } else {
13
+ gen.let(valid, false)
14
+ }
15
+ return [valid, cond]
16
+ }
17
+
18
+ export function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code] {
19
+ const [valid, cond_] = checkNullable(cxt, cond)
20
+ return [valid, _`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`]
21
+ }
node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {validateProperties, error} from "./properties"
4
+
5
+ const def: CodeKeywordDefinition = {
6
+ keyword: "optionalProperties",
7
+ schemaType: "object",
8
+ error,
9
+ code(cxt: KeywordCxt) {
10
+ if (cxt.parentSchema.properties) return
11
+ validateProperties(cxt)
12
+ },
13
+ }
14
+
15
+ export default def
node_modules/ajv/lib/vocabularies/jtd/properties.ts ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ CodeKeywordDefinition,
3
+ ErrorObject,
4
+ KeywordErrorDefinition,
5
+ SchemaObject,
6
+ } from "../../types"
7
+ import type {KeywordCxt} from "../../compile/validate"
8
+ import {propertyInData, allSchemaProperties, isOwnProperty} from "../code"
9
+ import {alwaysValidSchema, schemaRefOrVal} from "../../compile/util"
10
+ import {_, and, not, Code, Name} from "../../compile/codegen"
11
+ import {checkMetadata} from "./metadata"
12
+ import {checkNullableObject} from "./nullable"
13
+ import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"
14
+
15
+ enum PropError {
16
+ Additional = "additional",
17
+ Missing = "missing",
18
+ }
19
+
20
+ type PropKeyword = "properties" | "optionalProperties"
21
+
22
+ type PropSchema = {[P in string]?: SchemaObject}
23
+
24
+ export type JTDPropertiesError =
25
+ | _JTDTypeError<PropKeyword, "object", PropSchema>
26
+ | ErrorObject<PropKeyword, {error: PropError.Additional; additionalProperty: string}, PropSchema>
27
+ | ErrorObject<PropKeyword, {error: PropError.Missing; missingProperty: string}, PropSchema>
28
+
29
+ export const error: KeywordErrorDefinition = {
30
+ message: (cxt) => {
31
+ const {params} = cxt
32
+ return params.propError
33
+ ? params.propError === PropError.Additional
34
+ ? "must NOT have additional properties"
35
+ : `must have property '${params.missingProperty}'`
36
+ : typeErrorMessage(cxt, "object")
37
+ },
38
+ params: (cxt) => {
39
+ const {params} = cxt
40
+ return params.propError
41
+ ? params.propError === PropError.Additional
42
+ ? _`{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}`
43
+ : _`{error: ${params.propError}, missingProperty: ${params.missingProperty}}`
44
+ : typeErrorParams(cxt, "object")
45
+ },
46
+ }
47
+
48
+ const def: CodeKeywordDefinition = {
49
+ keyword: "properties",
50
+ schemaType: "object",
51
+ error,
52
+ code: validateProperties,
53
+ }
54
+
55
+ // const error: KeywordErrorDefinition = {
56
+ // message: "should NOT have additional properties",
57
+ // params: ({params}) => _`{additionalProperty: ${params.additionalProperty}}`,
58
+ // }
59
+
60
+ export function validateProperties(cxt: KeywordCxt): void {
61
+ checkMetadata(cxt)
62
+ const {gen, data, parentSchema, it} = cxt
63
+ const {additionalProperties, nullable} = parentSchema
64
+ if (it.jtdDiscriminator && nullable) throw new Error("JTD: nullable inside discriminator mapping")
65
+ if (commonProperties()) {
66
+ throw new Error("JTD: properties and optionalProperties have common members")
67
+ }
68
+ const [allProps, properties] = schemaProperties("properties")
69
+ const [allOptProps, optProperties] = schemaProperties("optionalProperties")
70
+ if (properties.length === 0 && optProperties.length === 0 && additionalProperties) {
71
+ return
72
+ }
73
+
74
+ const [valid, cond] =
75
+ it.jtdDiscriminator === undefined
76
+ ? checkNullableObject(cxt, data)
77
+ : [gen.let("valid", false), true]
78
+ gen.if(cond, () =>
79
+ gen.assign(valid, true).block(() => {
80
+ validateProps(properties, "properties", true)
81
+ validateProps(optProperties, "optionalProperties")
82
+ if (!additionalProperties) validateAdditional()
83
+ })
84
+ )
85
+ cxt.pass(valid)
86
+
87
+ function commonProperties(): boolean {
88
+ const props = parentSchema.properties as Record<string, any> | undefined
89
+ const optProps = parentSchema.optionalProperties as Record<string, any> | undefined
90
+ if (!(props && optProps)) return false
91
+ for (const p in props) {
92
+ if (Object.prototype.hasOwnProperty.call(optProps, p)) return true
93
+ }
94
+ return false
95
+ }
96
+
97
+ function schemaProperties(keyword: string): [string[], string[]] {
98
+ const schema = parentSchema[keyword]
99
+ const allPs = schema ? allSchemaProperties(schema) : []
100
+ if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
101
+ throw new Error(`JTD: discriminator tag used in ${keyword}`)
102
+ }
103
+ const ps = allPs.filter((p) => !alwaysValidSchema(it, schema[p]))
104
+ return [allPs, ps]
105
+ }
106
+
107
+ function validateProps(props: string[], keyword: string, required?: boolean): void {
108
+ const _valid = gen.var("valid")
109
+ for (const prop of props) {
110
+ gen.if(
111
+ propertyInData(gen, data, prop, it.opts.ownProperties),
112
+ () => applyPropertySchema(prop, keyword, _valid),
113
+ () => missingProperty(prop)
114
+ )
115
+ cxt.ok(_valid)
116
+ }
117
+
118
+ function missingProperty(prop: string): void {
119
+ if (required) {
120
+ gen.assign(_valid, false)
121
+ cxt.error(false, {propError: PropError.Missing, missingProperty: prop}, {schemaPath: prop})
122
+ } else {
123
+ gen.assign(_valid, true)
124
+ }
125
+ }
126
+ }
127
+
128
+ function applyPropertySchema(prop: string, keyword: string, _valid: Name): void {
129
+ cxt.subschema(
130
+ {
131
+ keyword,
132
+ schemaProp: prop,
133
+ dataProp: prop,
134
+ },
135
+ _valid
136
+ )
137
+ }
138
+
139
+ function validateAdditional(): void {
140
+ gen.forIn("key", data, (key: Name) => {
141
+ const addProp = isAdditional(key, allProps, "properties", it.jtdDiscriminator)
142
+ const addOptProp = isAdditional(key, allOptProps, "optionalProperties")
143
+ const extra =
144
+ addProp === true ? addOptProp : addOptProp === true ? addProp : and(addProp, addOptProp)
145
+ gen.if(extra, () => {
146
+ if (it.opts.removeAdditional) {
147
+ gen.code(_`delete ${data}[${key}]`)
148
+ } else {
149
+ cxt.error(
150
+ false,
151
+ {propError: PropError.Additional, additionalProperty: key},
152
+ {instancePath: key, parentSchema: true}
153
+ )
154
+ if (!it.opts.allErrors) gen.break()
155
+ }
156
+ })
157
+ })
158
+ }
159
+
160
+ function isAdditional(
161
+ key: Name,
162
+ props: string[],
163
+ keyword: string,
164
+ jtdDiscriminator?: string
165
+ ): Code | true {
166
+ let additional: Code | boolean
167
+ if (props.length > 8) {
168
+ // TODO maybe an option instead of hard-coded 8?
169
+ const propsSchema = schemaRefOrVal(it, parentSchema[keyword], keyword)
170
+ additional = not(isOwnProperty(gen, propsSchema as Code, key))
171
+ if (jtdDiscriminator !== undefined) {
172
+ additional = and(additional, _`${key} !== ${jtdDiscriminator}`)
173
+ }
174
+ } else if (props.length || jtdDiscriminator !== undefined) {
175
+ const ps = jtdDiscriminator === undefined ? props : [jtdDiscriminator].concat(props)
176
+ additional = and(...ps.map((p) => _`${key} !== ${p}`))
177
+ } else {
178
+ additional = true
179
+ }
180
+ return additional
181
+ }
182
+ }
183
+
184
+ export default def
node_modules/ajv/lib/vocabularies/jtd/ref.ts ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, AnySchemaObject} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {compileSchema, SchemaEnv} from "../../compile"
4
+ import {_, not, nil, stringify} from "../../compile/codegen"
5
+ import MissingRefError from "../../compile/ref_error"
6
+ import N from "../../compile/names"
7
+ import {getValidate, callRef} from "../core/ref"
8
+ import {checkMetadata} from "./metadata"
9
+
10
+ const def: CodeKeywordDefinition = {
11
+ keyword: "ref",
12
+ schemaType: "string",
13
+ code(cxt: KeywordCxt) {
14
+ checkMetadata(cxt)
15
+ const {gen, data, schema: ref, parentSchema, it} = cxt
16
+ const {
17
+ schemaEnv: {root},
18
+ } = it
19
+ const valid = gen.name("valid")
20
+ if (parentSchema.nullable) {
21
+ gen.var(valid, _`${data} === null`)
22
+ gen.if(not(valid), validateJtdRef)
23
+ } else {
24
+ gen.var(valid, false)
25
+ validateJtdRef()
26
+ }
27
+ cxt.ok(valid)
28
+
29
+ function validateJtdRef(): void {
30
+ const refSchema = (root.schema as AnySchemaObject).definitions?.[ref]
31
+ if (!refSchema) {
32
+ throw new MissingRefError(it.opts.uriResolver, "", ref, `No definition ${ref}`)
33
+ }
34
+ if (hasRef(refSchema) || !it.opts.inlineRefs) callValidate(refSchema)
35
+ else inlineRefSchema(refSchema)
36
+ }
37
+
38
+ function callValidate(schema: AnySchemaObject): void {
39
+ const sch = compileSchema.call(
40
+ it.self,
41
+ new SchemaEnv({schema, root, schemaPath: `/definitions/${ref}`})
42
+ )
43
+ const v = getValidate(cxt, sch)
44
+ const errsCount = gen.const("_errs", N.errors)
45
+ callRef(cxt, v, sch, sch.$async)
46
+ gen.assign(valid, _`${errsCount} === ${N.errors}`)
47
+ }
48
+
49
+ function inlineRefSchema(schema: AnySchemaObject): void {
50
+ const schName = gen.scopeValue(
51
+ "schema",
52
+ it.opts.code.source === true ? {ref: schema, code: stringify(schema)} : {ref: schema}
53
+ )
54
+ cxt.subschema(
55
+ {
56
+ schema,
57
+ dataTypes: [],
58
+ schemaPath: nil,
59
+ topSchemaRef: schName,
60
+ errSchemaPath: `/definitions/${ref}`,
61
+ },
62
+ valid
63
+ )
64
+ }
65
+ },
66
+ }
67
+
68
+ export function hasRef(schema: AnySchemaObject): boolean {
69
+ for (const key in schema) {
70
+ let sch: AnySchemaObject
71
+ if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch))) return true
72
+ }
73
+ return false
74
+ }
75
+
76
+ export default def
node_modules/ajv/lib/vocabularies/jtd/type.ts ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, nil, or, Code} from "../../compile/codegen"
4
+ import validTimestamp from "../../runtime/timestamp"
5
+ import {useFunc} from "../../compile/util"
6
+ import {checkMetadata} from "./metadata"
7
+ import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error"
8
+
9
+ export type JTDTypeError = _JTDTypeError<"type", JTDType, JTDType>
10
+
11
+ export type IntType = "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32"
12
+
13
+ export const intRange: {[T in IntType]: [number, number, number]} = {
14
+ int8: [-128, 127, 3],
15
+ uint8: [0, 255, 3],
16
+ int16: [-32768, 32767, 5],
17
+ uint16: [0, 65535, 5],
18
+ int32: [-2147483648, 2147483647, 10],
19
+ uint32: [0, 4294967295, 10],
20
+ }
21
+
22
+ export type JTDType = "boolean" | "string" | "timestamp" | "float32" | "float64" | IntType
23
+
24
+ const error: KeywordErrorDefinition = {
25
+ message: (cxt) => typeErrorMessage(cxt, cxt.schema),
26
+ params: (cxt) => typeErrorParams(cxt, cxt.schema),
27
+ }
28
+
29
+ function timestampCode(cxt: KeywordCxt): Code {
30
+ const {gen, data, it} = cxt
31
+ const {timestamp, allowDate} = it.opts
32
+ if (timestamp === "date") return _`${data} instanceof Date `
33
+ const vts = useFunc(gen, validTimestamp)
34
+ const allowDateArg = allowDate ? _`, true` : nil
35
+ const validString = _`typeof ${data} == "string" && ${vts}(${data}${allowDateArg})`
36
+ return timestamp === "string" ? validString : or(_`${data} instanceof Date`, validString)
37
+ }
38
+
39
+ const def: CodeKeywordDefinition = {
40
+ keyword: "type",
41
+ schemaType: "string",
42
+ error,
43
+ code(cxt: KeywordCxt) {
44
+ checkMetadata(cxt)
45
+ const {data, schema, parentSchema, it} = cxt
46
+ let cond: Code
47
+ switch (schema) {
48
+ case "boolean":
49
+ case "string":
50
+ cond = _`typeof ${data} == ${schema}`
51
+ break
52
+ case "timestamp": {
53
+ cond = timestampCode(cxt)
54
+ break
55
+ }
56
+ case "float32":
57
+ case "float64":
58
+ cond = _`typeof ${data} == "number"`
59
+ break
60
+ default: {
61
+ const sch = schema as IntType
62
+ cond = _`typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`
63
+ if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
64
+ if (sch === "uint32") cond = _`${cond} && ${data} >= 0`
65
+ } else {
66
+ const [min, max] = intRange[sch]
67
+ cond = _`${cond} && ${data} >= ${min} && ${data} <= ${max}`
68
+ }
69
+ }
70
+ }
71
+ cxt.pass(parentSchema.nullable ? or(_`${data} === null`, cond) : cond)
72
+ },
73
+ }
74
+
75
+ export default def
node_modules/ajv/lib/vocabularies/jtd/union.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition} from "../../types"
2
+ import {validateUnion} from "../code"
3
+
4
+ const def: CodeKeywordDefinition = {
5
+ keyword: "union",
6
+ schemaType: "array",
7
+ trackErrors: true,
8
+ code: validateUnion,
9
+ error: {message: "must match a schema in union"},
10
+ }
11
+
12
+ export default def
node_modules/ajv/lib/vocabularies/jtd/values.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, SchemaObject} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {alwaysValidSchema, Type} from "../../compile/util"
4
+ import {not, or, Name} from "../../compile/codegen"
5
+ import {checkMetadata} from "./metadata"
6
+ import {checkNullableObject} from "./nullable"
7
+ import {typeError, _JTDTypeError} from "./error"
8
+
9
+ export type JTDValuesError = _JTDTypeError<"values", "object", SchemaObject>
10
+
11
+ const def: CodeKeywordDefinition = {
12
+ keyword: "values",
13
+ schemaType: "object",
14
+ error: typeError("object"),
15
+ code(cxt: KeywordCxt) {
16
+ checkMetadata(cxt)
17
+ const {gen, data, schema, it} = cxt
18
+ const [valid, cond] = checkNullableObject(cxt, data)
19
+ if (alwaysValidSchema(it, schema)) {
20
+ gen.if(not(or(cond, valid)), () => cxt.error())
21
+ } else {
22
+ gen.if(cond)
23
+ gen.assign(valid, validateMap())
24
+ gen.elseIf(not(valid))
25
+ cxt.error()
26
+ gen.endIf()
27
+ }
28
+ cxt.ok(valid)
29
+
30
+ function validateMap(): Name | boolean {
31
+ const _valid = gen.name("valid")
32
+ if (it.allErrors) {
33
+ const validMap = gen.let("valid", true)
34
+ validateValues(() => gen.assign(validMap, false))
35
+ return validMap
36
+ }
37
+ gen.var(_valid, true)
38
+ validateValues(() => gen.break())
39
+ return _valid
40
+
41
+ function validateValues(notValid: () => void): void {
42
+ gen.forIn("key", data, (key) => {
43
+ cxt.subschema(
44
+ {
45
+ keyword: "values",
46
+ dataProp: key,
47
+ dataPropType: Type.Str,
48
+ },
49
+ _valid
50
+ )
51
+ gen.if(not(_valid), notValid)
52
+ })
53
+ }
54
+ }
55
+ },
56
+ }
57
+
58
+ export default def
node_modules/ajv/lib/vocabularies/metadata.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {Vocabulary} from "../types"
2
+
3
+ export const metadataVocabulary: Vocabulary = [
4
+ "title",
5
+ "description",
6
+ "default",
7
+ "deprecated",
8
+ "readOnly",
9
+ "writeOnly",
10
+ "examples",
11
+ ]
12
+
13
+ export const contentVocabulary: Vocabulary = [
14
+ "contentMediaType",
15
+ "contentEncoding",
16
+ "contentSchema",
17
+ ]
node_modules/ajv/lib/vocabularies/next.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import type {Vocabulary} from "../types"
2
+ import dependentRequired from "./validation/dependentRequired"
3
+ import dependentSchemas from "./applicator/dependentSchemas"
4
+ import limitContains from "./validation/limitContains"
5
+
6
+ const next: Vocabulary = [dependentRequired, dependentSchemas, limitContains]
7
+
8
+ export default next
node_modules/ajv/lib/vocabularies/unevaluated/index.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import type {Vocabulary} from "../../types"
2
+ import unevaluatedProperties from "./unevaluatedProperties"
3
+ import unevaluatedItems from "./unevaluatedItems"
4
+
5
+ const unevaluated: Vocabulary = [unevaluatedProperties, unevaluatedItems]
6
+
7
+ export default unevaluated
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ CodeKeywordDefinition,
3
+ ErrorObject,
4
+ KeywordErrorDefinition,
5
+ AnySchema,
6
+ } from "../../types"
7
+ import type {KeywordCxt} from "../../compile/validate"
8
+ import {_, str, not, Name} from "../../compile/codegen"
9
+ import {alwaysValidSchema, Type} from "../../compile/util"
10
+
11
+ export type UnevaluatedItemsError = ErrorObject<"unevaluatedItems", {limit: number}, AnySchema>
12
+
13
+ const error: KeywordErrorDefinition = {
14
+ message: ({params: {len}}) => str`must NOT have more than ${len} items`,
15
+ params: ({params: {len}}) => _`{limit: ${len}}`,
16
+ }
17
+
18
+ const def: CodeKeywordDefinition = {
19
+ keyword: "unevaluatedItems",
20
+ type: "array",
21
+ schemaType: ["boolean", "object"],
22
+ error,
23
+ code(cxt: KeywordCxt) {
24
+ const {gen, schema, data, it} = cxt
25
+ const items = it.items || 0
26
+ if (items === true) return
27
+ const len = gen.const("len", _`${data}.length`)
28
+ if (schema === false) {
29
+ cxt.setParams({len: items})
30
+ cxt.fail(_`${len} > ${items}`)
31
+ } else if (typeof schema == "object" && !alwaysValidSchema(it, schema)) {
32
+ const valid = gen.var("valid", _`${len} <= ${items}`)
33
+ gen.if(not(valid), () => validateItems(valid, items))
34
+ cxt.ok(valid)
35
+ }
36
+ it.items = true
37
+
38
+ function validateItems(valid: Name, from: Name | number): void {
39
+ gen.forRange("i", from, len, (i) => {
40
+ cxt.subschema({keyword: "unevaluatedItems", dataProp: i, dataPropType: Type.Num}, valid)
41
+ if (!it.allErrors) gen.if(not(valid), () => gen.break())
42
+ })
43
+ }
44
+ },
45
+ }
46
+
47
+ export default def
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ CodeKeywordDefinition,
3
+ KeywordErrorDefinition,
4
+ ErrorObject,
5
+ AnySchema,
6
+ } from "../../types"
7
+ import {_, not, and, Name, Code} from "../../compile/codegen"
8
+ import {alwaysValidSchema, Type} from "../../compile/util"
9
+ import N from "../../compile/names"
10
+
11
+ export type UnevaluatedPropertiesError = ErrorObject<
12
+ "unevaluatedProperties",
13
+ {unevaluatedProperty: string},
14
+ AnySchema
15
+ >
16
+
17
+ const error: KeywordErrorDefinition = {
18
+ message: "must NOT have unevaluated properties",
19
+ params: ({params}) => _`{unevaluatedProperty: ${params.unevaluatedProperty}}`,
20
+ }
21
+
22
+ const def: CodeKeywordDefinition = {
23
+ keyword: "unevaluatedProperties",
24
+ type: "object",
25
+ schemaType: ["boolean", "object"],
26
+ trackErrors: true,
27
+ error,
28
+ code(cxt) {
29
+ const {gen, schema, data, errsCount, it} = cxt
30
+ /* istanbul ignore if */
31
+ if (!errsCount) throw new Error("ajv implementation error")
32
+ const {allErrors, props} = it
33
+ if (props instanceof Name) {
34
+ gen.if(_`${props} !== true`, () =>
35
+ gen.forIn("key", data, (key: Name) =>
36
+ gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key))
37
+ )
38
+ )
39
+ } else if (props !== true) {
40
+ gen.forIn("key", data, (key: Name) =>
41
+ props === undefined
42
+ ? unevaluatedPropCode(key)
43
+ : gen.if(unevaluatedStatic(props, key), () => unevaluatedPropCode(key))
44
+ )
45
+ }
46
+ it.props = true
47
+ cxt.ok(_`${errsCount} === ${N.errors}`)
48
+
49
+ function unevaluatedPropCode(key: Name): void {
50
+ if (schema === false) {
51
+ cxt.setParams({unevaluatedProperty: key})
52
+ cxt.error()
53
+ if (!allErrors) gen.break()
54
+ return
55
+ }
56
+
57
+ if (!alwaysValidSchema(it, schema)) {
58
+ const valid = gen.name("valid")
59
+ cxt.subschema(
60
+ {
61
+ keyword: "unevaluatedProperties",
62
+ dataProp: key,
63
+ dataPropType: Type.Str,
64
+ },
65
+ valid
66
+ )
67
+ if (!allErrors) gen.if(not(valid), () => gen.break())
68
+ }
69
+ }
70
+
71
+ function unevaluatedDynamic(evaluatedProps: Name, key: Name): Code {
72
+ return _`!${evaluatedProps} || !${evaluatedProps}[${key}]`
73
+ }
74
+
75
+ function unevaluatedStatic(evaluatedProps: {[K in string]?: true}, key: Name): Code {
76
+ const ps: Code[] = []
77
+ for (const p in evaluatedProps) {
78
+ if (evaluatedProps[p] === true) ps.push(_`${key} !== ${p}`)
79
+ }
80
+ return and(...ps)
81
+ }
82
+ },
83
+ }
84
+
85
+ export default def
node_modules/ajv/lib/vocabularies/validation/const.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_} from "../../compile/codegen"
4
+ import {useFunc} from "../../compile/util"
5
+ import equal from "../../runtime/equal"
6
+
7
+ export type ConstError = ErrorObject<"const", {allowedValue: any}>
8
+
9
+ const error: KeywordErrorDefinition = {
10
+ message: "must be equal to constant",
11
+ params: ({schemaCode}) => _`{allowedValue: ${schemaCode}}`,
12
+ }
13
+
14
+ const def: CodeKeywordDefinition = {
15
+ keyword: "const",
16
+ $data: true,
17
+ error,
18
+ code(cxt: KeywordCxt) {
19
+ const {gen, data, $data, schemaCode, schema} = cxt
20
+ if ($data || (schema && typeof schema == "object")) {
21
+ cxt.fail$data(_`!${useFunc(gen, equal)}(${data}, ${schemaCode})`)
22
+ } else {
23
+ cxt.fail(_`${schema} !== ${data}`)
24
+ }
25
+ },
26
+ }
27
+
28
+ export default def
node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject} from "../../types"
2
+ import {
3
+ validatePropertyDeps,
4
+ error,
5
+ DependenciesErrorParams,
6
+ PropertyDependencies,
7
+ } from "../applicator/dependencies"
8
+
9
+ export type DependentRequiredError = ErrorObject<
10
+ "dependentRequired",
11
+ DependenciesErrorParams,
12
+ PropertyDependencies
13
+ >
14
+
15
+ const def: CodeKeywordDefinition = {
16
+ keyword: "dependentRequired",
17
+ type: "object",
18
+ schemaType: "object",
19
+ error,
20
+ code: (cxt) => validatePropertyDeps(cxt),
21
+ }
22
+
23
+ export default def
node_modules/ajv/lib/vocabularies/validation/enum.ts ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, or, Name, Code} from "../../compile/codegen"
4
+ import {useFunc} from "../../compile/util"
5
+ import equal from "../../runtime/equal"
6
+
7
+ export type EnumError = ErrorObject<"enum", {allowedValues: any[]}, any[] | {$data: string}>
8
+
9
+ const error: KeywordErrorDefinition = {
10
+ message: "must be equal to one of the allowed values",
11
+ params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`,
12
+ }
13
+
14
+ const def: CodeKeywordDefinition = {
15
+ keyword: "enum",
16
+ schemaType: "array",
17
+ $data: true,
18
+ error,
19
+ code(cxt: KeywordCxt) {
20
+ const {gen, data, $data, schema, schemaCode, it} = cxt
21
+ if (!$data && schema.length === 0) throw new Error("enum must have non-empty array")
22
+ const useLoop = schema.length >= it.opts.loopEnum
23
+ let eql: Name | undefined
24
+ const getEql = (): Name => (eql ??= useFunc(gen, equal))
25
+
26
+ let valid: Code
27
+ if (useLoop || $data) {
28
+ valid = gen.let("valid")
29
+ cxt.block$data(valid, loopEnum)
30
+ } else {
31
+ /* istanbul ignore if */
32
+ if (!Array.isArray(schema)) throw new Error("ajv implementation error")
33
+ const vSchema = gen.const("vSchema", schemaCode)
34
+ valid = or(...schema.map((_x: unknown, i: number) => equalCode(vSchema, i)))
35
+ }
36
+ cxt.pass(valid)
37
+
38
+ function loopEnum(): void {
39
+ gen.assign(valid, false)
40
+ gen.forOf("v", schemaCode as Code, (v) =>
41
+ gen.if(_`${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break())
42
+ )
43
+ }
44
+
45
+ function equalCode(vSchema: Name, i: number): Code {
46
+ const sch = schema[i]
47
+ return typeof sch === "object" && sch !== null
48
+ ? _`${getEql()}(${data}, ${vSchema}[${i}])`
49
+ : _`${data} === ${sch}`
50
+ }
51
+ },
52
+ }
53
+
54
+ export default def
node_modules/ajv/lib/vocabularies/validation/index.ts ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {ErrorObject, Vocabulary} from "../../types"
2
+ import limitNumber, {LimitNumberError} from "./limitNumber"
3
+ import multipleOf, {MultipleOfError} from "./multipleOf"
4
+ import limitLength from "./limitLength"
5
+ import pattern, {PatternError} from "./pattern"
6
+ import limitProperties from "./limitProperties"
7
+ import required, {RequiredError} from "./required"
8
+ import limitItems from "./limitItems"
9
+ import uniqueItems, {UniqueItemsError} from "./uniqueItems"
10
+ import constKeyword, {ConstError} from "./const"
11
+ import enumKeyword, {EnumError} from "./enum"
12
+
13
+ const validation: Vocabulary = [
14
+ // number
15
+ limitNumber,
16
+ multipleOf,
17
+ // string
18
+ limitLength,
19
+ pattern,
20
+ // object
21
+ limitProperties,
22
+ required,
23
+ // array
24
+ limitItems,
25
+ uniqueItems,
26
+ // any
27
+ {keyword: "type", schemaType: ["string", "array"]},
28
+ {keyword: "nullable", schemaType: "boolean"},
29
+ constKeyword,
30
+ enumKeyword,
31
+ ]
32
+
33
+ export default validation
34
+
35
+ type LimitError = ErrorObject<
36
+ "maxItems" | "minItems" | "minProperties" | "maxProperties" | "minLength" | "maxLength",
37
+ {limit: number},
38
+ number | {$data: string}
39
+ >
40
+
41
+ export type ValidationKeywordError =
42
+ | LimitError
43
+ | LimitNumberError
44
+ | MultipleOfError
45
+ | PatternError
46
+ | RequiredError
47
+ | UniqueItemsError
48
+ | ConstError
49
+ | EnumError
node_modules/ajv/lib/vocabularies/validation/limitContains.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {checkStrictMode} from "../../compile/util"
4
+
5
+ const def: CodeKeywordDefinition = {
6
+ keyword: ["maxContains", "minContains"],
7
+ type: "array",
8
+ schemaType: "number",
9
+ code({keyword, parentSchema, it}: KeywordCxt) {
10
+ if (parentSchema.contains === undefined) {
11
+ checkStrictMode(it, `"${keyword}" without "contains" is ignored`)
12
+ }
13
+ },
14
+ }
15
+
16
+ export default def
node_modules/ajv/lib/vocabularies/validation/limitItems.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, str, operators} from "../../compile/codegen"
4
+
5
+ const error: KeywordErrorDefinition = {
6
+ message({keyword, schemaCode}) {
7
+ const comp = keyword === "maxItems" ? "more" : "fewer"
8
+ return str`must NOT have ${comp} than ${schemaCode} items`
9
+ },
10
+ params: ({schemaCode}) => _`{limit: ${schemaCode}}`,
11
+ }
12
+
13
+ const def: CodeKeywordDefinition = {
14
+ keyword: ["maxItems", "minItems"],
15
+ type: "array",
16
+ schemaType: "number",
17
+ $data: true,
18
+ error,
19
+ code(cxt: KeywordCxt) {
20
+ const {keyword, data, schemaCode} = cxt
21
+ const op = keyword === "maxItems" ? operators.GT : operators.LT
22
+ cxt.fail$data(_`${data}.length ${op} ${schemaCode}`)
23
+ },
24
+ }
25
+
26
+ export default def
node_modules/ajv/lib/vocabularies/validation/limitLength.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, str, operators} from "../../compile/codegen"
4
+ import {useFunc} from "../../compile/util"
5
+ import ucs2length from "../../runtime/ucs2length"
6
+
7
+ const error: KeywordErrorDefinition = {
8
+ message({keyword, schemaCode}) {
9
+ const comp = keyword === "maxLength" ? "more" : "fewer"
10
+ return str`must NOT have ${comp} than ${schemaCode} characters`
11
+ },
12
+ params: ({schemaCode}) => _`{limit: ${schemaCode}}`,
13
+ }
14
+
15
+ const def: CodeKeywordDefinition = {
16
+ keyword: ["maxLength", "minLength"],
17
+ type: "string",
18
+ schemaType: "number",
19
+ $data: true,
20
+ error,
21
+ code(cxt: KeywordCxt) {
22
+ const {keyword, data, schemaCode, it} = cxt
23
+ const op = keyword === "maxLength" ? operators.GT : operators.LT
24
+ const len =
25
+ it.opts.unicode === false ? _`${data}.length` : _`${useFunc(cxt.gen, ucs2length)}(${data})`
26
+ cxt.fail$data(_`${len} ${op} ${schemaCode}`)
27
+ },
28
+ }
29
+
30
+ export default def
node_modules/ajv/lib/vocabularies/validation/limitNumber.ts ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, str, operators, Code} from "../../compile/codegen"
4
+
5
+ const ops = operators
6
+
7
+ type Kwd = "maximum" | "minimum" | "exclusiveMaximum" | "exclusiveMinimum"
8
+
9
+ type Comparison = "<=" | ">=" | "<" | ">"
10
+
11
+ const KWDs: {[K in Kwd]: {okStr: Comparison; ok: Code; fail: Code}} = {
12
+ maximum: {okStr: "<=", ok: ops.LTE, fail: ops.GT},
13
+ minimum: {okStr: ">=", ok: ops.GTE, fail: ops.LT},
14
+ exclusiveMaximum: {okStr: "<", ok: ops.LT, fail: ops.GTE},
15
+ exclusiveMinimum: {okStr: ">", ok: ops.GT, fail: ops.LTE},
16
+ }
17
+
18
+ export type LimitNumberError = ErrorObject<
19
+ Kwd,
20
+ {limit: number; comparison: Comparison},
21
+ number | {$data: string}
22
+ >
23
+
24
+ const error: KeywordErrorDefinition = {
25
+ message: ({keyword, schemaCode}) => str`must be ${KWDs[keyword as Kwd].okStr} ${schemaCode}`,
26
+ params: ({keyword, schemaCode}) =>
27
+ _`{comparison: ${KWDs[keyword as Kwd].okStr}, limit: ${schemaCode}}`,
28
+ }
29
+
30
+ const def: CodeKeywordDefinition = {
31
+ keyword: Object.keys(KWDs),
32
+ type: "number",
33
+ schemaType: "number",
34
+ $data: true,
35
+ error,
36
+ code(cxt: KeywordCxt) {
37
+ const {keyword, data, schemaCode} = cxt
38
+ cxt.fail$data(_`${data} ${KWDs[keyword as Kwd].fail} ${schemaCode} || isNaN(${data})`)
39
+ },
40
+ }
41
+
42
+ export default def
node_modules/ajv/lib/vocabularies/validation/limitProperties.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, str, operators} from "../../compile/codegen"
4
+
5
+ const error: KeywordErrorDefinition = {
6
+ message({keyword, schemaCode}) {
7
+ const comp = keyword === "maxProperties" ? "more" : "fewer"
8
+ return str`must NOT have ${comp} than ${schemaCode} properties`
9
+ },
10
+ params: ({schemaCode}) => _`{limit: ${schemaCode}}`,
11
+ }
12
+
13
+ const def: CodeKeywordDefinition = {
14
+ keyword: ["maxProperties", "minProperties"],
15
+ type: "object",
16
+ schemaType: "number",
17
+ $data: true,
18
+ error,
19
+ code(cxt: KeywordCxt) {
20
+ const {keyword, data, schemaCode} = cxt
21
+ const op = keyword === "maxProperties" ? operators.GT : operators.LT
22
+ cxt.fail$data(_`Object.keys(${data}).length ${op} ${schemaCode}`)
23
+ },
24
+ }
25
+
26
+ export default def
node_modules/ajv/lib/vocabularies/validation/multipleOf.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {_, str} from "../../compile/codegen"
4
+
5
+ export type MultipleOfError = ErrorObject<
6
+ "multipleOf",
7
+ {multipleOf: number},
8
+ number | {$data: string}
9
+ >
10
+
11
+ const error: KeywordErrorDefinition = {
12
+ message: ({schemaCode}) => str`must be multiple of ${schemaCode}`,
13
+ params: ({schemaCode}) => _`{multipleOf: ${schemaCode}}`,
14
+ }
15
+
16
+ const def: CodeKeywordDefinition = {
17
+ keyword: "multipleOf",
18
+ type: "number",
19
+ schemaType: "number",
20
+ $data: true,
21
+ error,
22
+ code(cxt: KeywordCxt) {
23
+ const {gen, data, schemaCode, it} = cxt
24
+ // const bdt = bad$DataType(schemaCode, <string>def.schemaType, $data)
25
+ const prec = it.opts.multipleOfPrecision
26
+ const res = gen.let("res")
27
+ const invalid = prec
28
+ ? _`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
29
+ : _`${res} !== parseInt(${res})`
30
+ cxt.fail$data(_`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`)
31
+ },
32
+ }
33
+
34
+ export default def
node_modules/ajv/lib/vocabularies/validation/pattern.ts ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {usePattern} from "../code"
4
+ import {useFunc} from "../../compile/util"
5
+ import {_, str} from "../../compile/codegen"
6
+
7
+ export type PatternError = ErrorObject<"pattern", {pattern: string}, string | {$data: string}>
8
+
9
+ const error: KeywordErrorDefinition = {
10
+ message: ({schemaCode}) => str`must match pattern "${schemaCode}"`,
11
+ params: ({schemaCode}) => _`{pattern: ${schemaCode}}`,
12
+ }
13
+
14
+ const def: CodeKeywordDefinition = {
15
+ keyword: "pattern",
16
+ type: "string",
17
+ schemaType: "string",
18
+ $data: true,
19
+ error,
20
+ code(cxt: KeywordCxt) {
21
+ const {gen, data, $data, schema, schemaCode, it} = cxt
22
+ const u = it.opts.unicodeRegExp ? "u" : ""
23
+ if ($data) {
24
+ const {regExp} = it.opts.code
25
+ const regExpCode = regExp.code === "new RegExp" ? _`new RegExp` : useFunc(gen, regExp)
26
+ const valid = gen.let("valid")
27
+ gen.try(
28
+ () => gen.assign(valid, _`${regExpCode}(${schemaCode}, ${u}).test(${data})`),
29
+ () => gen.assign(valid, false)
30
+ )
31
+ cxt.fail$data(_`!${valid}`)
32
+ } else {
33
+ const regExp = usePattern(cxt, schema)
34
+ cxt.fail$data(_`!${regExp}.test(${data})`)
35
+ }
36
+ },
37
+ }
38
+
39
+ export default def
node_modules/ajv/lib/vocabularies/validation/required.ts ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {
4
+ checkReportMissingProp,
5
+ checkMissingProp,
6
+ reportMissingProp,
7
+ propertyInData,
8
+ noPropertyInData,
9
+ } from "../code"
10
+ import {_, str, nil, not, Name, Code} from "../../compile/codegen"
11
+ import {checkStrictMode} from "../../compile/util"
12
+
13
+ export type RequiredError = ErrorObject<
14
+ "required",
15
+ {missingProperty: string},
16
+ string[] | {$data: string}
17
+ >
18
+
19
+ const error: KeywordErrorDefinition = {
20
+ message: ({params: {missingProperty}}) => str`must have required property '${missingProperty}'`,
21
+ params: ({params: {missingProperty}}) => _`{missingProperty: ${missingProperty}}`,
22
+ }
23
+
24
+ const def: CodeKeywordDefinition = {
25
+ keyword: "required",
26
+ type: "object",
27
+ schemaType: "array",
28
+ $data: true,
29
+ error,
30
+ code(cxt: KeywordCxt) {
31
+ const {gen, schema, schemaCode, data, $data, it} = cxt
32
+ const {opts} = it
33
+ if (!$data && schema.length === 0) return
34
+ const useLoop = schema.length >= opts.loopRequired
35
+ if (it.allErrors) allErrorsMode()
36
+ else exitOnErrorMode()
37
+
38
+ if (opts.strictRequired) {
39
+ const props = cxt.parentSchema.properties
40
+ const {definedProperties} = cxt.it
41
+ for (const requiredKey of schema) {
42
+ if (props?.[requiredKey] === undefined && !definedProperties.has(requiredKey)) {
43
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath
44
+ const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`
45
+ checkStrictMode(it, msg, it.opts.strictRequired)
46
+ }
47
+ }
48
+ }
49
+
50
+ function allErrorsMode(): void {
51
+ if (useLoop || $data) {
52
+ cxt.block$data(nil, loopAllRequired)
53
+ } else {
54
+ for (const prop of schema) {
55
+ checkReportMissingProp(cxt, prop)
56
+ }
57
+ }
58
+ }
59
+
60
+ function exitOnErrorMode(): void {
61
+ const missing = gen.let("missing")
62
+ if (useLoop || $data) {
63
+ const valid = gen.let("valid", true)
64
+ cxt.block$data(valid, () => loopUntilMissing(missing, valid))
65
+ cxt.ok(valid)
66
+ } else {
67
+ gen.if(checkMissingProp(cxt, schema, missing))
68
+ reportMissingProp(cxt, missing)
69
+ gen.else()
70
+ }
71
+ }
72
+
73
+ function loopAllRequired(): void {
74
+ gen.forOf("prop", schemaCode as Code, (prop) => {
75
+ cxt.setParams({missingProperty: prop})
76
+ gen.if(noPropertyInData(gen, data, prop, opts.ownProperties), () => cxt.error())
77
+ })
78
+ }
79
+
80
+ function loopUntilMissing(missing: Name, valid: Name): void {
81
+ cxt.setParams({missingProperty: missing})
82
+ gen.forOf(
83
+ missing,
84
+ schemaCode as Code,
85
+ () => {
86
+ gen.assign(valid, propertyInData(gen, data, missing, opts.ownProperties))
87
+ gen.if(not(valid), () => {
88
+ cxt.error()
89
+ gen.break()
90
+ })
91
+ },
92
+ nil
93
+ )
94
+ }
95
+ },
96
+ }
97
+
98
+ export default def
node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
2
+ import type {KeywordCxt} from "../../compile/validate"
3
+ import {checkDataTypes, getSchemaTypes, DataType} from "../../compile/validate/dataType"
4
+ import {_, str, Name} from "../../compile/codegen"
5
+ import {useFunc} from "../../compile/util"
6
+ import equal from "../../runtime/equal"
7
+
8
+ export type UniqueItemsError = ErrorObject<
9
+ "uniqueItems",
10
+ {i: number; j: number},
11
+ boolean | {$data: string}
12
+ >
13
+
14
+ const error: KeywordErrorDefinition = {
15
+ message: ({params: {i, j}}) =>
16
+ str`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
17
+ params: ({params: {i, j}}) => _`{i: ${i}, j: ${j}}`,
18
+ }
19
+
20
+ const def: CodeKeywordDefinition = {
21
+ keyword: "uniqueItems",
22
+ type: "array",
23
+ schemaType: "boolean",
24
+ $data: true,
25
+ error,
26
+ code(cxt: KeywordCxt) {
27
+ const {gen, data, $data, schema, parentSchema, schemaCode, it} = cxt
28
+ if (!$data && !schema) return
29
+ const valid = gen.let("valid")
30
+ const itemTypes = parentSchema.items ? getSchemaTypes(parentSchema.items) : []
31
+ cxt.block$data(valid, validateUniqueItems, _`${schemaCode} === false`)
32
+ cxt.ok(valid)
33
+
34
+ function validateUniqueItems(): void {
35
+ const i = gen.let("i", _`${data}.length`)
36
+ const j = gen.let("j")
37
+ cxt.setParams({i, j})
38
+ gen.assign(valid, true)
39
+ gen.if(_`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j))
40
+ }
41
+
42
+ function canOptimize(): boolean {
43
+ return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array")
44
+ }
45
+
46
+ function loopN(i: Name, j: Name): void {
47
+ const item = gen.name("item")
48
+ const wrongType = checkDataTypes(itemTypes, item, it.opts.strictNumbers, DataType.Wrong)
49
+ const indices = gen.const("indices", _`{}`)
50
+ gen.for(_`;${i}--;`, () => {
51
+ gen.let(item, _`${data}[${i}]`)
52
+ gen.if(wrongType, _`continue`)
53
+ if (itemTypes.length > 1) gen.if(_`typeof ${item} == "string"`, _`${item} += "_"`)
54
+ gen
55
+ .if(_`typeof ${indices}[${item}] == "number"`, () => {
56
+ gen.assign(j, _`${indices}[${item}]`)
57
+ cxt.error()
58
+ gen.assign(valid, false).break()
59
+ })
60
+ .code(_`${indices}[${item}] = ${i}`)
61
+ })
62
+ }
63
+
64
+ function loopN2(i: Name, j: Name): void {
65
+ const eql = useFunc(gen, equal)
66
+ const outer = gen.name("outer")
67
+ gen.label(outer).for(_`;${i}--;`, () =>
68
+ gen.for(_`${j} = ${i}; ${j}--;`, () =>
69
+ gen.if(_`${eql}(${data}[${i}], ${data}[${j}])`, () => {
70
+ cxt.error()
71
+ gen.assign(valid, false).break(outer)
72
+ })
73
+ )
74
+ )
75
+ }
76
+ },
77
+ }
78
+
79
+ export default def
node_modules/ajv/package.json ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ajv",
3
+ "version": "8.20.0",
4
+ "description": "Another JSON Schema Validator",
5
+ "main": "dist/ajv.js",
6
+ "types": "dist/ajv.d.ts",
7
+ "files": [
8
+ "lib/",
9
+ "dist/",
10
+ ".runkit_example.js"
11
+ ],
12
+ "sideEffects": false,
13
+ "scripts": {
14
+ "eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" --ignore-pattern spec/JSON-Schema-Test-Suite",
15
+ "prettier:write": "prettier --write \"./**/*.{json,yaml,js,ts}\"",
16
+ "prettier:check": "prettier --list-different \"./**/*.{json,yaml,js,ts}\"",
17
+ "test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register \"spec/**/*.spec.{ts,js}\" -R dot",
18
+ "test-codegen": "nyc cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/codegen.spec.ts' -R spec",
19
+ "test-debug": "npm run test-spec -- --inspect-brk",
20
+ "test-cov": "nyc npm run test-spec",
21
+ "rollup": "rm -rf bundle && rollup -c",
22
+ "bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019 && node ./scripts/bundle.js 2020 ajv2020 ajv2020 && node ./scripts/bundle.js jtd ajvJTD ajvJTD",
23
+ "build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts && rm dist/refs/json-schema-2020-12/index.ts && rm dist/refs/jtd-schema.ts",
24
+ "json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests",
25
+ "test-karma": "karma start",
26
+ "test-browser": "rm -rf .browser && npm run bundle && scripts/prepare-tests && karma start",
27
+ "test-all": "npm run test-cov",
28
+ "test": "npm run json-tests && npm run prettier:check && npm run eslint && npm link && npm link --legacy-peer-deps ajv && npm run test-cov",
29
+ "test-ci": "AJV_FULL_TEST=true npm test",
30
+ "prepublish": "npm run build",
31
+ "benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link --legacy-peer-deps ajv && npm i && node ./jtd",
32
+ "docs:dev": "./scripts/prepare-site && vuepress dev docs",
33
+ "docs:build": "./scripts/prepare-site && vuepress build docs"
34
+ },
35
+ "nyc": {
36
+ "exclude": [
37
+ "**/spec/**",
38
+ "node_modules"
39
+ ],
40
+ "reporter": [
41
+ "lcov",
42
+ "text-summary"
43
+ ]
44
+ },
45
+ "repository": "ajv-validator/ajv",
46
+ "keywords": [
47
+ "JSON",
48
+ "schema",
49
+ "validator",
50
+ "validation",
51
+ "jsonschema",
52
+ "json-schema",
53
+ "json-schema-validator",
54
+ "json-schema-validation"
55
+ ],
56
+ "author": "Evgeny Poberezkin",
57
+ "license": "MIT",
58
+ "bugs": "https://github.com/ajv-validator/ajv/issues",
59
+ "homepage": "https://ajv.js.org",
60
+ "runkitExampleFilename": ".runkit_example.js",
61
+ "dependencies": {
62
+ "fast-deep-equal": "^3.1.3",
63
+ "fast-uri": "^3.0.1",
64
+ "json-schema-traverse": "^1.0.0",
65
+ "require-from-string": "^2.0.2"
66
+ },
67
+ "devDependencies": {
68
+ "@ajv-validator/config": "^0.5.0",
69
+ "@rollup/plugin-commonjs": "^25.0.7",
70
+ "@rollup/plugin-json": "^6.1.0",
71
+ "@rollup/plugin-node-resolve": "^15.2.3",
72
+ "@rollup/plugin-typescript": "^11.1.6",
73
+ "@types/chai": "^4.3.11",
74
+ "@types/mocha": "^10.0.6",
75
+ "@types/node": "^20.11.30",
76
+ "@types/require-from-string": "^1.2.3",
77
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
78
+ "@typescript-eslint/parser": "^7.3.1",
79
+ "ajv-formats": "^3.0.1",
80
+ "browserify": "^17.0.0",
81
+ "chai": "^4.4.1",
82
+ "cross-env": "^7.0.3",
83
+ "dayjs": "^1.11.10",
84
+ "dayjs-plugin-utc": "^0.1.2",
85
+ "eslint": "^8.57.0",
86
+ "eslint-config-prettier": "^9.1.0",
87
+ "glob": "^10.3.10",
88
+ "husky": "^9.0.11",
89
+ "jimp": "^0.22.10",
90
+ "js-beautify": "^1.15.1",
91
+ "json-schema-test": "^2.0.0",
92
+ "karma": "^6.4.2",
93
+ "karma-chrome-launcher": "^3.2.0",
94
+ "karma-mocha": "^2.0.1",
95
+ "lint-staged": "^15.2.2",
96
+ "mocha": "^10.3.0",
97
+ "module-from-string": "^3.3.0",
98
+ "node-fetch": "^3.3.2",
99
+ "nyc": "^15.1.0",
100
+ "prettier": "3.0.3",
101
+ "re2": "^1.20.9",
102
+ "rollup": "^2.79.1",
103
+ "rollup-plugin-terser": "^7.0.2",
104
+ "ts-node": "^10.9.2",
105
+ "tsify": "^5.0.4",
106
+ "typescript": "5.3.3",
107
+ "uri-js": "^4.4.1"
108
+ },
109
+ "collective": {
110
+ "type": "opencollective",
111
+ "url": "https://opencollective.com/ajv"
112
+ },
113
+ "funding": {
114
+ "type": "github",
115
+ "url": "https://github.com/sponsors/epoberezkin"
116
+ },
117
+ "prettier": "@ajv-validator/config/prettierrc.json",
118
+ "husky": {
119
+ "hooks": {
120
+ "pre-commit": "lint-staged && npm test"
121
+ }
122
+ },
123
+ "lint-staged": {
124
+ "*.{json,yaml,js,ts}": "prettier --write"
125
+ }
126
+ }
node_modules/ansis/LICENSE ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ISC License
2
+
3
+ Copyright (c) 2026, webdiscus
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
node_modules/ansis/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Ansis
2
+
3
+ ANSI color library - [Docs](../../)
4
+
5
+ ![](docs/n.png)
node_modules/ansis/index.cjs ADDED
@@ -0,0 +1 @@
 
 
1
+ let e,{defineProperty:r,getPrototypeOf:t,setPrototypeOf:n,create:o,keys:l}=Object,i="",{round:f,max:s}=Math,u=e=>{let r=/([a-f\d]{3,6})/i.exec(e)?.[0],t=r?.length,n="0x"+(6^t?3^t?"0":r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)|0;return[n>>16,n>>8&255,255&n]},a=e=>{if(8>e)return 30+e;if(16>e)return 82+e;if(e>231)return e>243?37:30;let r=(e-=16)%36,t=e/36|0,n=r/6|0,o=r%6;return 30+(t>2|(n>2)<<1|(o>2)<<2)+(s(t,n,o)>4?60:0)},c={open:i,close:i},g=(e,{open:r="",close:o="",f:l})=>{let f=(e.open||i)+r,s=o+(e.close||i),u=(e,...t)=>{if(!e){if(!o)return r;if((e??i)===i)return i}let n,a=l?l(e,...t):e.raw?String.raw({raw:e},...t):i+e,c=u;if(a.includes(""))for(;c=c.p;){let{t:e,o:r}=c,t=r.length,o=i,l=0;if(t)for(;~(n=a.indexOf(r,l));l=n+t)o+=a.slice(l,n)+e;a=o+a.slice(l)}return f+(a.includes("\n")?a.replace(/(\r?\n)/g,s+"$1"+f):a)+s};return n(u,t(e)).p={t:r,o,p:e.p},u.open=f,u.close=s,u};const d=new function t(s=globalThis){let d="number"==typeof s?s:(r=>{let t=r.process??{},n=t.argv??[],o=t.env??{},i=0;try{i=((r,t,n)=>(e=t.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[t.COLORTERM]||(t.CI?/,GITHUB/.test(n)?3:1:(t.PM2_HOME||/edge/.test(t.NEXT_RUNTIME)||r.stdout?.isTTY)&&"dumb"!==e?"win32"===r.platform?3:/-256/.test(e)?2:1:0)))(t,o,","+l(o).join(","))}catch(e){o={}}let f,s=i||1,u="FORCE_COLOR",a={false:0,0:0,1:1,2:2,3:3}[o[u]]??s,c=-1;for(f of n)/^--color=?(true|always)?$/.test(f)&&(c=s),/^--(no-color|color=(false|never))$/.test(f)&&(c=0);return r.window?.chrome?3:u in o?a:~c?c:o.NO_COLOR?0:i})(s),b={},p={Ansis:t,level:d,isSupported:()=>m,strip:e=>e.replace(/][^]*|[›][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,i),extend(e){for(let r in e){let t=e[r];"s"===(typeof t)[0]&&(h(w(r),A(...u(t))),t=P(...u(t))),h(r,t)}return n(p,o({},b))}},h=(e,t)=>{b[e]={get(){return r(this,e,{value:t.call?(...e)=>g(this,t(...e)):g(this,t)})[e]}}},y=1^d,$=d>2,m=d>0,O=(e,r)=>m?{open:`[${e}m`,close:r?`[${r}m`:i}:c,w=e=>"bg"+e[0].toUpperCase()+e.slice(1),v=e=>r=>e(...u(r)),x=(e,r)=>(t,n,o)=>O(`${e}8;2;${t};${n};${o}`,r),_=e=>(r,t,n)=>e(((e,r,t)=>e^r|r^t?16+36*f(e/51)+6*f(r/51)+f(t/51):8>e?16:e>248?231:f(24*(e-8)/247)+232)(r,t,n)),k=e=>O(y?"38;5;"+e:a(e),39),R=e=>O(y?"48;5;"+e:a(e)+10,49),P=$?x(3,39):_(k),A=$?x(4,49):_(R),B={fg:k,bg:R,rgb:P,bgRgb:A,hex:v(P),bgHex:v(A),visible:c,reset:O(0,i),bold:O(1,22),dim:O(2,22),italic:O(3,23),underline:O(4,24),inverse:O(7,27),hidden:O(8,28),strikethrough:O(9,29),link:{f:(e,r=e)=>m?`]8;;${e}${r}]8;;`:r!=e?r+` (​${e}​)`:e}},C=(e,r)=>{B[e]=O(r,39),B[w(e)]=O(r+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((e,r)=>{r?C(e+"Bright",89+r):r=61,C(e,29+r)})),p.extend(B)};module.exports=d.default=d;
node_modules/ansis/index.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ type N=number;type S=string;type C='red'|'green'|'yellow'|'blue'|'magenta'|'cyan'|'white';type H=`${C}Bright`;export type AnsiColors='black'|'gray'|C|H|`bg${'Black'|'Gray'|Capitalize<C|H>}`;export type AnsiStyles='reset'|'inverse'|'hidden'|'visible'|'bold'|'dim'|'italic'|'underline'|'strikethrough';type Q=(n:N)=>A;type L=(s:S)=>A;type R=(r:N,g:N,b:N)=>A;type W=(text:S,url?:S)=>S;type A=Ansis;type Ansis={level:N;open:S;close:S;(v:unknown):S;(s:TemplateStringsArray,...v:any[]):S;fg:Q;bg:Q;rgb:R;bgRgb:R;hex:L;bgHex:L;link:W;isSupported():boolean;strip(s:S):S;extend<U extends S>(c:Record<U,S|{open:S;close:S}>):A&Record<U|`bg${Capitalize<U>}`,A>}&{[K in AnsiStyles|AnsiColors]:A};declare const Ansis:new (o?:N|object)=>A,a:A,fg:Q,rgb:R,hex:L,link:W;export{a as default,Ansis,fg,fg as bg,rgb,rgb as bgRgb,hex,hex as bgHex,link,a as reset,a as inverse,a as hidden,a as visible,a as bold,a as dim,a as italic,a as underline,a as strikethrough,a as black,a as red,a as green,a as yellow,a as blue,a as magenta,a as cyan,a as white,a as gray,a as redBright,a as greenBright,a as yellowBright,a as blueBright,a as magentaBright,a as cyanBright,a as whiteBright,a as bgBlack,a as bgRed,a as bgGreen,a as bgYellow,a as bgBlue,a as bgMagenta,a as bgCyan,a as bgWhite,a as bgGray,a as bgRedBright,a as bgGreenBright,a as bgYellowBright,a as bgBlueBright,a as bgMagentaBright,a as bgCyanBright,a as bgWhiteBright};
node_modules/ansis/index.mjs ADDED
@@ -0,0 +1 @@
 
 
1
+ import a from"./index.cjs";export default a;export const{Ansis,fg,bg,rgb,bgRgb,hex,bgHex,reset,inverse,hidden,visible,link,bold,dim,italic,underline,strikethrough,black,red,green,yellow,blue,magenta,cyan,white,gray,redBright,greenBright,yellowBright,blueBright,magentaBright,cyanBright,whiteBright,bgBlack,bgRed,bgGreen,bgYellow,bgBlue,bgMagenta,bgCyan,bgWhite,bgGray,bgRedBright,bgGreenBright,bgYellowBright,bgBlueBright,bgMagentaBright,bgCyanBright,bgWhiteBright}=a;
node_modules/ansis/package.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name":"ansis",
3
+ "version":"4.3.1",
4
+ "description":"ANSI color lib",
5
+ "keywords":["ansi","colors","cli"],
6
+ "license":"ISC",
7
+ "author":"webdiscus",
8
+ "repository":"webdiscus/ansis",
9
+ "type":"module",
10
+ "exports":{
11
+ ".":{
12
+ "types":"./index.d.ts",
13
+ "require":"./index.cjs",
14
+ "import":"./index.mjs"
15
+ }
16
+ },
17
+ "sideEffects":false,
18
+ "engines":{"node":">=14"}
19
+ }
node_modules/any-base/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kamil Harasimowicz and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/any-base/README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # README #
2
+
3
+ The library allows you to convert any large numbers in any number base to another number base. The base is determined by specifying the alphabet. So is full freedom
4
+
5
+ [![NPM](https://nodei.co/npm/any-base.png?downloads=true&stars=true)](https://nodei.co/npm/any-base/)
6
+
7
+ ## Installation ##
8
+
9
+ ```
10
+ npm install any-base --save
11
+ ```
12
+
13
+ ## API ##
14
+
15
+ ### AnyBase() ###
16
+
17
+ ```
18
+ converterFunction = anyBase(sourceAlphabet, destinationAlphabet);
19
+ ```
20
+
21
+ #### Parameters ####
22
+
23
+ * {String} __sourceAlphabet__ digits from smallest to the largest
24
+ * {String} __destinationAlphabet__ digits from smallest to the largest
25
+
26
+ #### Return Values ####
27
+
28
+ Returns __function__ that converts the number of source base to the destination
29
+
30
+ ### Convert() ###
31
+
32
+ ```
33
+ converterFunction(number)
34
+ ```
35
+
36
+ #### Parameters ####
37
+
38
+ * {String} __number__ number of source base
39
+
40
+ #### Return Values ####
41
+
42
+ Returns number of destonation base
43
+
44
+ ## Example ##
45
+
46
+ ```js
47
+ var anyBase = require('any-base'),
48
+ dec2hex = anyBase(anyBase.DEC, anyBase.HEX),
49
+ shortId = anyBase(anyBase.DEC, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^'),
50
+ longId = anyBase('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^', anyBase.DEC);
51
+
52
+ dec2hex('123456'); // return: '1E240'
53
+ shortId('1234567890'); // return: 'PtmIa'
54
+ longId('PtmIa'); // return: '1234567890'
55
+ ```