summary refs log tree commit diff
path: root/patches/ajv+8.6.2.patch
blob: 3f54881b17c7685062eeb315e486bd44c6f68195 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
diff --git a/node_modules/ajv/dist/compile/jtd/parse.js b/node_modules/ajv/dist/compile/jtd/parse.js
index 1eeb1be..7684121 100644
--- a/node_modules/ajv/dist/compile/jtd/parse.js
+++ b/node_modules/ajv/dist/compile/jtd/parse.js
@@ -239,6 +239,9 @@ function parseType(cxt) {
             gen.if(fail, () => parsingError(cxt, codegen_1.str `invalid timestamp`));
             break;
         }
+		case "bigint":
+			parseBigInt(cxt);
+			break
         case "float32":
         case "float64":
             parseNumber(cxt);
@@ -284,6 +287,15 @@ function parseNumber(cxt, maxDigits) {
     skipWhitespace(cxt);
     gen.if(codegen_1._ `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
 }
+function parseBigInt(cxt, maxDigits) {
+  const {gen} = cxt
+  skipWhitespace(cxt)
+  gen.if(
+    _`"-0123456789".indexOf(${jsonSlice(1)}) < 0`,
+    () => jsonSyntaxError(cxt),
+    () => parseWith(cxt, parseJson_1.parseJsonBigInt, maxDigits)
+  )
+}
 function parseBooleanToken(bool, fail) {
     return (cxt) => {
         const { gen, data } = cxt;
diff --git a/node_modules/ajv/dist/compile/rules.js b/node_modules/ajv/dist/compile/rules.js
index 82a591f..1ebd8fe 100644
--- a/node_modules/ajv/dist/compile/rules.js
+++ b/node_modules/ajv/dist/compile/rules.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.getRules = exports.isJSONType = void 0;
-const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
+const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array","bigint"];
 const jsonTypes = new Set(_jsonTypes);
 function isJSONType(x) {
     return typeof x == "string" && jsonTypes.has(x);
@@ -13,10 +13,11 @@ function getRules() {
         string: { type: "string", rules: [] },
         array: { type: "array", rules: [] },
         object: { type: "object", rules: [] },
+		bigint: {type: "bigint", rules: []}
     };
     return {
-        types: { ...groups, integer: true, boolean: true, null: true },
-        rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object],
+        types: { ...groups, integer: true, boolean: true, null: true, bigint: true },
+        rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object, groups.bigint],
         post: { rules: [] },
         all: {},
         keywords: {},
diff --git a/node_modules/ajv/dist/compile/validate/dataType.js b/node_modules/ajv/dist/compile/validate/dataType.js
index 6319e76..8b50b4c 100644
--- a/node_modules/ajv/dist/compile/validate/dataType.js
+++ b/node_modules/ajv/dist/compile/validate/dataType.js
@@ -52,7 +52,7 @@ function coerceAndCheckDataType(it, types) {
     return checkTypes;
 }
 exports.coerceAndCheckDataType = coerceAndCheckDataType;
-const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
+const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null","bigint"]);
 function coerceToTypes(types, coerceTypes) {
     return coerceTypes
         ? types.filter((t) => COERCIBLE.has(t) || (coerceTypes === "array" && t === "array"))
@@ -83,6 +83,14 @@ function coerceData(it, types, coerceTo) {
     });
     function coerceSpecificType(t) {
         switch (t) {
+			case "bigint":
+				gen
+				.elseIf(
+					codegen_1._`${dataType} == "boolean" || ${data} === null
+					|| (${dataType} == "string" && ${data} && ${data} == BigInt(${data}))`
+				)
+				.assign(coerced, codegen_1._`BigInt(${data})`)
+				return
             case "string":
                 gen
                     .elseIf(codegen_1._ `${dataType} == "number" || ${dataType} == "boolean"`)
@@ -143,6 +151,9 @@ function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {
         case "number":
             cond = numCond();
             break;
+		 case "bigint":
+			cond = codegen_1._`typeof ${data} == "bigint" && isFinite(${data})`
+			break
         default:
             return codegen_1._ `typeof ${data} ${EQ} ${dataType}`;
     }
diff --git a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
index 7027a12..25679c8 100644
--- a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
+++ b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
@@ -78,7 +78,7 @@
       "default": 0
     },
     "simpleTypes": {
-      "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+      "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
     },
     "stringArray": {
       "type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
index e0ae13d..57c9036 100644
--- a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
+++ b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
@@ -78,7 +78,7 @@
       "default": 0
     },
     "simpleTypes": {
-      "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+      "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
     },
     "stringArray": {
       "type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-06.json b/node_modules/ajv/dist/refs/json-schema-draft-06.json
index 5410064..774435b 100644
--- a/node_modules/ajv/dist/refs/json-schema-draft-06.json
+++ b/node_modules/ajv/dist/refs/json-schema-draft-06.json
@@ -16,7 +16,7 @@
       "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
     },
     "simpleTypes": {
-      "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+      "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
     },
     "stringArray": {
       "type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-07.json b/node_modules/ajv/dist/refs/json-schema-draft-07.json
index 6a74851..fc6dd7d 100644
--- a/node_modules/ajv/dist/refs/json-schema-draft-07.json
+++ b/node_modules/ajv/dist/refs/json-schema-draft-07.json
@@ -16,7 +16,7 @@
       "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
     },
     "simpleTypes": {
-      "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+      "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
     },
     "stringArray": {
       "type": "array",
diff --git a/node_modules/ajv/dist/refs/jtd-schema.js b/node_modules/ajv/dist/refs/jtd-schema.js
index 1ee940a..1148887 100644
--- a/node_modules/ajv/dist/refs/jtd-schema.js
+++ b/node_modules/ajv/dist/refs/jtd-schema.js
@@ -38,6 +38,7 @@ const typeForm = (root) => ({
                 "uint16",
                 "int32",
                 "uint32",
+                "bigint",
             ],
         },
     },
diff --git a/node_modules/ajv/dist/runtime/parseJson.js b/node_modules/ajv/dist/runtime/parseJson.js
index 2576a6e..e7447b1 100644
--- a/node_modules/ajv/dist/runtime/parseJson.js
+++ b/node_modules/ajv/dist/runtime/parseJson.js
@@ -97,6 +97,71 @@ exports.parseJsonNumber = parseJsonNumber;
 parseJsonNumber.message = undefined;
 parseJsonNumber.position = 0;
 parseJsonNumber.code = 'require("ajv/dist/runtime/parseJson").parseJsonNumber';
+
+function parseJsonBigInt(s, pos, maxDigits) {
+    let numStr = "";
+    let c;
+    parseJsonBigInt.message = undefined;
+    if (s[pos] === "-") {
+        numStr += "-";
+        pos++;
+    }
+    if (s[pos] === "0") {
+        numStr += "0";
+        pos++;
+    }
+    else {
+        if (!parseDigits(maxDigits)) {
+            errorMessage();
+            return undefined;
+        }
+    }
+    if (maxDigits) {
+        parseJsonBigInt.position = pos;
+        return BigInt(numStr);
+    }
+    if (s[pos] === ".") {
+        numStr += ".";
+        pos++;
+        if (!parseDigits()) {
+            errorMessage();
+            return undefined;
+        }
+    }
+    if (((c = s[pos]), c === "e" || c === "E")) {
+        numStr += "e";
+        pos++;
+        if (((c = s[pos]), c === "+" || c === "-")) {
+            numStr += c;
+            pos++;
+        }
+        if (!parseDigits()) {
+            errorMessage();
+            return undefined;
+        }
+    }
+    parseJsonBigInt.position = pos;
+    return BigInt(numStr);
+    function parseDigits(maxLen) {
+        let digit = false;
+        while (((c = s[pos]), c >= "0" && c <= "9" && (maxLen === undefined || maxLen-- > 0))) {
+            digit = true;
+            numStr += c;
+            pos++;
+        }
+        return digit;
+    }
+    function errorMessage() {
+        parseJsonBigInt.position = pos;
+        parseJsonBigInt.message = pos < s.length ? `unexpected token ${s[pos]}` : "unexpected end";
+    }
+}
+exports.parseJsonBigInt = parseJsonBigInt;
+parseJsonBigInt.message = undefined;
+parseJsonBigInt.position = 0;
+parseJsonBigInt.code = 'require("ajv/dist/runtime/parseJson").parseJsonBigInt';
+
+
 const escapedChars = {
     b: "\b",
     f: "\f",
diff --git a/node_modules/ajv/dist/vocabularies/jtd/type.js b/node_modules/ajv/dist/vocabularies/jtd/type.js
index 428bddb..fbc3070 100644
--- a/node_modules/ajv/dist/vocabularies/jtd/type.js
+++ b/node_modules/ajv/dist/vocabularies/jtd/type.js
@@ -45,6 +45,9 @@ const def = {
                 cond = timestampCode(cxt);
                 break;
             }
+			case "bigint":
+				cond = codegen_1._`typeof ${data} == "bigint" || typeof ${data} == "string"`
+				break
             case "float32":
             case "float64":
                 cond = codegen_1._ `typeof ${data} == "number"`;