pi-adaptive-thinking 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/config-loader.d.ts +16 -0
- package/dist/config.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2896 -0
- package/dist/thinking-levels.d.ts +5 -0
- package/package.json +78 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2896 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
6
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/string.mjs
|
|
7
|
+
function IsBetween(value, min, max) {
|
|
8
|
+
return value >= min && value <= max;
|
|
9
|
+
}
|
|
10
|
+
function IsRegionalIndicator(value) {
|
|
11
|
+
return IsBetween(value, 127462, 127487);
|
|
12
|
+
}
|
|
13
|
+
function IsVariationSelector(value) {
|
|
14
|
+
return IsBetween(value, 65024, 65039);
|
|
15
|
+
}
|
|
16
|
+
function IsCombiningMark$1(value) {
|
|
17
|
+
return IsBetween(value, 768, 879) || IsBetween(value, 6832, 6911) || IsBetween(value, 7616, 7679) || IsBetween(value, 65056, 65071);
|
|
18
|
+
}
|
|
19
|
+
function CodePointLength(value) {
|
|
20
|
+
return value > 65535 ? 2 : 1;
|
|
21
|
+
}
|
|
22
|
+
function ConsumeModifiers(value, index) {
|
|
23
|
+
while (index < value.length) {
|
|
24
|
+
const point = value.codePointAt(index);
|
|
25
|
+
if (IsCombiningMark$1(point) || IsVariationSelector(point)) index += CodePointLength(point);
|
|
26
|
+
else break;
|
|
27
|
+
}
|
|
28
|
+
return index;
|
|
29
|
+
}
|
|
30
|
+
function NextGraphemeClusterIndex(value, clusterStart) {
|
|
31
|
+
const startCP = value.codePointAt(clusterStart);
|
|
32
|
+
let clusterEnd = clusterStart + CodePointLength(startCP);
|
|
33
|
+
clusterEnd = ConsumeModifiers(value, clusterEnd);
|
|
34
|
+
while (clusterEnd < value.length - 1 && value[clusterEnd] === "") {
|
|
35
|
+
const nextCP = value.codePointAt(clusterEnd + 1);
|
|
36
|
+
clusterEnd += 1 + CodePointLength(nextCP);
|
|
37
|
+
clusterEnd = ConsumeModifiers(value, clusterEnd);
|
|
38
|
+
}
|
|
39
|
+
if (IsRegionalIndicator(startCP) && clusterEnd < value.length && IsRegionalIndicator(value.codePointAt(clusterEnd))) clusterEnd += CodePointLength(value.codePointAt(clusterEnd));
|
|
40
|
+
return clusterEnd;
|
|
41
|
+
}
|
|
42
|
+
function IsGraphemeCodePoint(value) {
|
|
43
|
+
return IsBetween(value, 55296, 56319) || IsBetween(value, 768, 879) || value === 8205;
|
|
44
|
+
}
|
|
45
|
+
/** Checks if a string has at least a minimum number of grapheme clusters */
|
|
46
|
+
function IsMinLength$2(value, minLength) {
|
|
47
|
+
if (minLength === 0) return true;
|
|
48
|
+
let count = 0;
|
|
49
|
+
let index = 0;
|
|
50
|
+
while (index < value.length) {
|
|
51
|
+
index = NextGraphemeClusterIndex(value, index);
|
|
52
|
+
count++;
|
|
53
|
+
if (count >= minLength) return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/** Checks if a string has at most a maximum number of grapheme clusters */
|
|
58
|
+
function IsMaxLength$2(value, maxLength) {
|
|
59
|
+
let count = 0;
|
|
60
|
+
let index = 0;
|
|
61
|
+
while (index < value.length) {
|
|
62
|
+
index = NextGraphemeClusterIndex(value, index);
|
|
63
|
+
count++;
|
|
64
|
+
if (count > maxLength) return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/** Fast check for minimum grapheme length, falls back to full check if needed */
|
|
69
|
+
function IsMinLengthFast(value, minLength) {
|
|
70
|
+
if (minLength === 0) return true;
|
|
71
|
+
let index = 0;
|
|
72
|
+
while (index < value.length) {
|
|
73
|
+
if (IsGraphemeCodePoint(value.charCodeAt(index))) return IsMinLength$2(value, minLength);
|
|
74
|
+
index++;
|
|
75
|
+
if (index >= minLength) return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
/** Fast check for maximum grapheme length, falls back to full check if needed */
|
|
80
|
+
function IsMaxLengthFast(value, maxLength) {
|
|
81
|
+
let index = 0;
|
|
82
|
+
while (index < value.length) {
|
|
83
|
+
if (IsGraphemeCodePoint(value.charCodeAt(index))) return IsMaxLength$2(value, maxLength);
|
|
84
|
+
index++;
|
|
85
|
+
if (index > maxLength) return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/guard.mjs
|
|
91
|
+
/** Returns true if this value is an array */
|
|
92
|
+
function IsArray(value) {
|
|
93
|
+
return Array.isArray(value);
|
|
94
|
+
}
|
|
95
|
+
/** Returns true if this value is an async iterator */
|
|
96
|
+
function IsAsyncIterator(value) {
|
|
97
|
+
return IsObject(value) && Symbol.asyncIterator in value;
|
|
98
|
+
}
|
|
99
|
+
/** Returns true if this value is bigint */
|
|
100
|
+
function IsBigInt(value) {
|
|
101
|
+
return IsEqual(typeof value, "bigint");
|
|
102
|
+
}
|
|
103
|
+
/** Returns true if this value is a boolean */
|
|
104
|
+
function IsBoolean$1(value) {
|
|
105
|
+
return IsEqual(typeof value, "boolean");
|
|
106
|
+
}
|
|
107
|
+
/** Returns true if this value is a constructor */
|
|
108
|
+
function IsConstructor(value) {
|
|
109
|
+
if (IsUndefined(value) || !IsFunction(value)) return false;
|
|
110
|
+
const result = Function.prototype.toString.call(value);
|
|
111
|
+
if (/^class\s/.test(result)) return true;
|
|
112
|
+
if (/\[native code\]/.test(result)) return true;
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/** Returns true if this value is a function */
|
|
116
|
+
function IsFunction(value) {
|
|
117
|
+
return IsEqual(typeof value, "function");
|
|
118
|
+
}
|
|
119
|
+
/** Returns true if this value is integer */
|
|
120
|
+
function IsInteger(value) {
|
|
121
|
+
return Number.isInteger(value);
|
|
122
|
+
}
|
|
123
|
+
/** Returns true if this value is an iterator */
|
|
124
|
+
function IsIterator(value) {
|
|
125
|
+
return IsObject(value) && Symbol.iterator in value;
|
|
126
|
+
}
|
|
127
|
+
/** Returns true if this value is null */
|
|
128
|
+
function IsNull(value) {
|
|
129
|
+
return IsEqual(value, null);
|
|
130
|
+
}
|
|
131
|
+
/** Returns true if this value is number */
|
|
132
|
+
function IsNumber$1(value) {
|
|
133
|
+
return Number.isFinite(value);
|
|
134
|
+
}
|
|
135
|
+
/** Returns true if this value is an object but not an array */
|
|
136
|
+
function IsObjectNotArray(value) {
|
|
137
|
+
return IsObject(value) && !IsArray(value);
|
|
138
|
+
}
|
|
139
|
+
/** Returns true if this value is an object */
|
|
140
|
+
function IsObject(value) {
|
|
141
|
+
return IsEqual(typeof value, "object") && !IsNull(value);
|
|
142
|
+
}
|
|
143
|
+
/** Returns true if this value is string */
|
|
144
|
+
function IsString$1(value) {
|
|
145
|
+
return IsEqual(typeof value, "string");
|
|
146
|
+
}
|
|
147
|
+
/** Returns true if this value is symbol */
|
|
148
|
+
function IsSymbol(value) {
|
|
149
|
+
return IsEqual(typeof value, "symbol");
|
|
150
|
+
}
|
|
151
|
+
/** Returns true if this value is undefined */
|
|
152
|
+
function IsUndefined(value) {
|
|
153
|
+
return IsEqual(value, void 0);
|
|
154
|
+
}
|
|
155
|
+
function IsEqual(left, right) {
|
|
156
|
+
return left === right;
|
|
157
|
+
}
|
|
158
|
+
function IsGreaterThan(left, right) {
|
|
159
|
+
return left > right;
|
|
160
|
+
}
|
|
161
|
+
function IsLessThan(left, right) {
|
|
162
|
+
return left < right;
|
|
163
|
+
}
|
|
164
|
+
function IsLessEqualThan(left, right) {
|
|
165
|
+
return left <= right;
|
|
166
|
+
}
|
|
167
|
+
function IsGreaterEqualThan(left, right) {
|
|
168
|
+
return left >= right;
|
|
169
|
+
}
|
|
170
|
+
function IsMultipleOf$1(dividend, divisor) {
|
|
171
|
+
if (IsBigInt(dividend) || IsBigInt(divisor)) return BigInt(dividend) % BigInt(divisor) === 0n;
|
|
172
|
+
const tolerance = 1e-10;
|
|
173
|
+
if (!IsNumber$1(dividend)) return true;
|
|
174
|
+
if (IsInteger(dividend) && 1 / divisor % 1 === 0) return true;
|
|
175
|
+
const mod = dividend % divisor;
|
|
176
|
+
return Math.min(Math.abs(mod), Math.abs(mod - divisor)) < tolerance;
|
|
177
|
+
}
|
|
178
|
+
function IsValueLike(value) {
|
|
179
|
+
return IsBigInt(value) || IsBoolean$1(value) || IsNull(value) || IsNumber$1(value) || IsString$1(value) || IsUndefined(value);
|
|
180
|
+
}
|
|
181
|
+
/** Returns true if the string has at most the given number of graphemes */
|
|
182
|
+
function IsMaxLength$1(value, length) {
|
|
183
|
+
return IsMaxLengthFast(value, length);
|
|
184
|
+
}
|
|
185
|
+
/** Returns true if the string has at least the given number of graphemes */
|
|
186
|
+
function IsMinLength$1(value, length) {
|
|
187
|
+
return IsMinLengthFast(value, length);
|
|
188
|
+
}
|
|
189
|
+
/** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */
|
|
190
|
+
function Every(value, offset, callback) {
|
|
191
|
+
for (let index = offset; index < value.length; index++) if (!callback(value[index], index)) return false;
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
/** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */
|
|
195
|
+
function EveryAll(value, offset, callback) {
|
|
196
|
+
let result = true;
|
|
197
|
+
for (let index = offset; index < value.length; index++) if (!callback(value[index], index)) result = false;
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
/** Returns true if the PropertyKey is Unsafe (ref: prototype-pollution). */
|
|
201
|
+
function IsUnsafePropertyKey(key) {
|
|
202
|
+
return IsEqual(key, "__proto__") || IsEqual(key, "constructor") || IsEqual(key, "prototype");
|
|
203
|
+
}
|
|
204
|
+
/** Returns true if this value has this property key */
|
|
205
|
+
function HasPropertyKey(value, key) {
|
|
206
|
+
return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;
|
|
207
|
+
}
|
|
208
|
+
/** Returns object entries as `[string, Value][]` */
|
|
209
|
+
function Entries(value) {
|
|
210
|
+
return Object.entries(value);
|
|
211
|
+
}
|
|
212
|
+
/** Returns property keys for this object via `Object.getOwnPropertyKeys({ ... })` */
|
|
213
|
+
function Keys(value) {
|
|
214
|
+
return Object.getOwnPropertyNames(value);
|
|
215
|
+
}
|
|
216
|
+
function DeepEqualObject(left, right) {
|
|
217
|
+
if (!IsObject(right)) return false;
|
|
218
|
+
const keys = Keys(left);
|
|
219
|
+
return IsEqual(keys.length, Keys(right).length) && keys.every((key) => IsDeepEqual(left[key], right[key]));
|
|
220
|
+
}
|
|
221
|
+
function DeepEqualArray(left, right) {
|
|
222
|
+
return IsArray(right) && IsEqual(left.length, right.length) && left.every((_, index) => IsDeepEqual(left[index], right[index]));
|
|
223
|
+
}
|
|
224
|
+
/** Tests values for deep equality */
|
|
225
|
+
function IsDeepEqual(left, right) {
|
|
226
|
+
return IsArray(left) ? DeepEqualArray(left, right) : IsObject(left) ? DeepEqualObject(left, right) : IsEqual(left, right);
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/globals.mjs
|
|
230
|
+
function IsBoolean(value) {
|
|
231
|
+
return value instanceof Boolean;
|
|
232
|
+
}
|
|
233
|
+
function IsNumber(value) {
|
|
234
|
+
return value instanceof Number;
|
|
235
|
+
}
|
|
236
|
+
function IsString(value) {
|
|
237
|
+
return value instanceof String;
|
|
238
|
+
}
|
|
239
|
+
function IsTypeArray(value) {
|
|
240
|
+
return globalThis.ArrayBuffer.isView(value);
|
|
241
|
+
}
|
|
242
|
+
/** Returns true if the value is a RegExp */
|
|
243
|
+
function IsRegExp(value) {
|
|
244
|
+
return value instanceof globalThis.RegExp;
|
|
245
|
+
}
|
|
246
|
+
/** Returns true if the value is a Date */
|
|
247
|
+
function IsDate$1(value) {
|
|
248
|
+
return value instanceof globalThis.Date;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/_guard.mjs
|
|
252
|
+
function IsGuardInterface(value) {
|
|
253
|
+
return IsObject(value) && HasPropertyKey(value, "check") && HasPropertyKey(value, "errors") && IsFunction(value.check) && IsFunction(value.errors);
|
|
254
|
+
}
|
|
255
|
+
function IsGuard(value) {
|
|
256
|
+
return HasPropertyKey(value, "~guard") && IsGuardInterface(value["~guard"]);
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/_refine.mjs
|
|
260
|
+
/**
|
|
261
|
+
* Returns true if the schema contains an '~refine` keyword
|
|
262
|
+
* @specification None
|
|
263
|
+
*/
|
|
264
|
+
function IsRefine(value) {
|
|
265
|
+
return HasPropertyKey(value, "~refine") && IsArray(value["~refine"]) && Every(value["~refine"], 0, (value) => IsObject(value) && HasPropertyKey(value, "check") && HasPropertyKey(value, "error") && IsFunction(value.check) && IsFunction(value.error));
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/schema.mjs
|
|
269
|
+
/** Returns true if this value is object like */
|
|
270
|
+
function IsSchemaObject(value) {
|
|
271
|
+
return IsObject(value) && !IsArray(value);
|
|
272
|
+
}
|
|
273
|
+
/** Returns true if this value is a boolean */
|
|
274
|
+
function IsBooleanSchema(value) {
|
|
275
|
+
return IsBoolean$1(value);
|
|
276
|
+
}
|
|
277
|
+
/** Returns true if this value is schema like */
|
|
278
|
+
function IsSchema(value) {
|
|
279
|
+
return IsSchemaObject(value) || IsBooleanSchema(value);
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/additionalItems.mjs
|
|
283
|
+
/**
|
|
284
|
+
* Returns true if the schema contains a valid additionalItems property
|
|
285
|
+
* @specification Json Schema 7
|
|
286
|
+
*/
|
|
287
|
+
function IsAdditionalItems(schema) {
|
|
288
|
+
return HasPropertyKey(schema, "additionalItems") && IsSchema(schema.additionalItems);
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/additionalProperties.mjs
|
|
292
|
+
/**
|
|
293
|
+
* Returns true if the schema contains a valid additionalProperties property
|
|
294
|
+
* @specification Json Schema 7
|
|
295
|
+
*/
|
|
296
|
+
function IsAdditionalProperties(schema) {
|
|
297
|
+
return HasPropertyKey(schema, "additionalProperties") && IsSchema(schema.additionalProperties);
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/allOf.mjs
|
|
301
|
+
/**
|
|
302
|
+
* Returns true if the schema contains a valid allOf property
|
|
303
|
+
* @specification Json Schema 7
|
|
304
|
+
*/
|
|
305
|
+
function IsAllOf(schema) {
|
|
306
|
+
return HasPropertyKey(schema, "allOf") && IsArray(schema.allOf) && schema.allOf.every((value) => IsSchema(value));
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/anchor.mjs
|
|
310
|
+
/**
|
|
311
|
+
* Returns true if the schema contains a valid $anchor property
|
|
312
|
+
*/
|
|
313
|
+
function IsAnchor(schema) {
|
|
314
|
+
return HasPropertyKey(schema, "$anchor") && IsString$1(schema.$anchor);
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/anyOf.mjs
|
|
318
|
+
/**
|
|
319
|
+
* Returns true if the schema contains a valid anyOf property
|
|
320
|
+
* @specification Json Schema 7
|
|
321
|
+
*/
|
|
322
|
+
function IsAnyOf(schema) {
|
|
323
|
+
return HasPropertyKey(schema, "anyOf") && IsArray(schema.anyOf) && schema.anyOf.every((value) => IsSchema(value));
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/const.mjs
|
|
327
|
+
/**
|
|
328
|
+
* Returns true if the schema contains a valid const property
|
|
329
|
+
* @specification Json Schema 7
|
|
330
|
+
*/
|
|
331
|
+
function IsConst(value) {
|
|
332
|
+
return HasPropertyKey(value, "const");
|
|
333
|
+
}
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/contains.mjs
|
|
336
|
+
/**
|
|
337
|
+
* Returns true if the schema contains a valid contains property
|
|
338
|
+
* @specification Json Schema 7
|
|
339
|
+
*/
|
|
340
|
+
function IsContains(schema) {
|
|
341
|
+
return HasPropertyKey(schema, "contains") && IsSchema(schema.contains);
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/dependencies.mjs
|
|
345
|
+
/**
|
|
346
|
+
* Returns true if the schema contains a valid dependencies property
|
|
347
|
+
* @specification Json Schema 7
|
|
348
|
+
*/
|
|
349
|
+
function IsDependencies(schema) {
|
|
350
|
+
return HasPropertyKey(schema, "dependencies") && IsObject(schema.dependencies) && Object.values(schema.dependencies).every((value) => IsSchema(value) || IsArray(value) && value.every((value) => IsString$1(value)));
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/dependentRequired.mjs
|
|
354
|
+
/**
|
|
355
|
+
* Returns true if the schema contains a valid dependentRequired property
|
|
356
|
+
* @specification Json Schema 2019-09
|
|
357
|
+
*/
|
|
358
|
+
function IsDependentRequired(schema) {
|
|
359
|
+
return HasPropertyKey(schema, "dependentRequired") && IsObject(schema.dependentRequired) && Object.values(schema.dependentRequired).every((value) => IsArray(value) && value.every((value) => IsString$1(value)));
|
|
360
|
+
}
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/dependentSchemas.mjs
|
|
363
|
+
/**
|
|
364
|
+
* Returns true if the schema contains a valid dependentRequired property
|
|
365
|
+
* @specification Json Schema 2019-09
|
|
366
|
+
*/
|
|
367
|
+
function IsDependentSchemas(schema) {
|
|
368
|
+
return HasPropertyKey(schema, "dependentSchemas") && IsObject(schema.dependentSchemas) && Object.values(schema.dependentSchemas).every((value) => IsSchema(value));
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/dynamicAnchor.mjs
|
|
372
|
+
/**
|
|
373
|
+
* Returns true if the schema contains a valid $dynamicAnchor property
|
|
374
|
+
*/
|
|
375
|
+
function IsDynamicAnchor(schema) {
|
|
376
|
+
return HasPropertyKey(schema, "$dynamicAnchor") && IsString$1(schema.$dynamicAnchor);
|
|
377
|
+
}
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/dynamicRef.mjs
|
|
380
|
+
/**
|
|
381
|
+
* Returns true if the schema contains a valid $dynamicRef property
|
|
382
|
+
*/
|
|
383
|
+
function IsDynamicRef(schema) {
|
|
384
|
+
return HasPropertyKey(schema, "$dynamicRef") && IsString$1(schema.$dynamicRef);
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/else.mjs
|
|
388
|
+
/**
|
|
389
|
+
* Returns true if the schema contains a valid else property
|
|
390
|
+
* @specification Json Schema 7
|
|
391
|
+
*/
|
|
392
|
+
function IsElse(schema) {
|
|
393
|
+
return HasPropertyKey(schema, "else") && IsSchema(schema.else);
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/enum.mjs
|
|
397
|
+
/**
|
|
398
|
+
* Returns true if the schema contains a valid enum property
|
|
399
|
+
* @specification Json Schema 7
|
|
400
|
+
*/
|
|
401
|
+
function IsEnum(schema) {
|
|
402
|
+
return HasPropertyKey(schema, "enum") && IsArray(schema.enum);
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/exclusiveMaximum.mjs
|
|
406
|
+
/**
|
|
407
|
+
* Returns true if the schema contains a valid exclusiveMaximum property
|
|
408
|
+
* @specification Json Schema 7
|
|
409
|
+
*/
|
|
410
|
+
function IsExclusiveMaximum(schema) {
|
|
411
|
+
return HasPropertyKey(schema, "exclusiveMaximum") && (IsNumber$1(schema.exclusiveMaximum) || IsBigInt(schema.exclusiveMaximum));
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/exclusiveMinimum.mjs
|
|
415
|
+
/**
|
|
416
|
+
* Returns true if the schema contains a valid exclusiveMinimum property
|
|
417
|
+
* @specification Json Schema 7
|
|
418
|
+
*/
|
|
419
|
+
function IsExclusiveMinimum(schema) {
|
|
420
|
+
return HasPropertyKey(schema, "exclusiveMinimum") && (IsNumber$1(schema.exclusiveMinimum) || IsBigInt(schema.exclusiveMinimum));
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/format.mjs
|
|
424
|
+
/**
|
|
425
|
+
* Returns true if the schema contains a valid format property
|
|
426
|
+
* @specification Json Schema 7
|
|
427
|
+
*/
|
|
428
|
+
function IsFormat(schema) {
|
|
429
|
+
return HasPropertyKey(schema, "format") && IsString$1(schema.format);
|
|
430
|
+
}
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/id.mjs
|
|
433
|
+
/**
|
|
434
|
+
* Returns true if the schema contains a valid $id property
|
|
435
|
+
* @specification Json Schema 7
|
|
436
|
+
*/
|
|
437
|
+
function IsId(schema) {
|
|
438
|
+
return HasPropertyKey(schema, "$id") && IsString$1(schema.$id);
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/if.mjs
|
|
442
|
+
/**
|
|
443
|
+
* Returns true if the schema contains a valid $id property
|
|
444
|
+
* @specification Json Schema 7
|
|
445
|
+
*/
|
|
446
|
+
function IsIf(schema) {
|
|
447
|
+
return HasPropertyKey(schema, "if") && IsSchema(schema.if);
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/items.mjs
|
|
451
|
+
/**
|
|
452
|
+
* Returns true if the schema contains a valid items property
|
|
453
|
+
* @specification Json Schema 7
|
|
454
|
+
*/
|
|
455
|
+
function IsItems(schema) {
|
|
456
|
+
return HasPropertyKey(schema, "items") && (IsSchema(schema.items) || IsArray(schema.items) && schema.items.every((value) => {
|
|
457
|
+
return IsSchema(value);
|
|
458
|
+
}));
|
|
459
|
+
}
|
|
460
|
+
/** Returns true if this schema is a sized items variant */
|
|
461
|
+
function IsItemsSized(schema) {
|
|
462
|
+
return IsItems(schema) && IsArray(schema.items);
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/maximum.mjs
|
|
466
|
+
/**
|
|
467
|
+
* Returns true if the schema contains a valid maximum property
|
|
468
|
+
* @specification Json Schema 7
|
|
469
|
+
*/
|
|
470
|
+
function IsMaximum(schema) {
|
|
471
|
+
return HasPropertyKey(schema, "maximum") && (IsNumber$1(schema.maximum) || IsBigInt(schema.maximum));
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/maxContains.mjs
|
|
475
|
+
/**
|
|
476
|
+
* Returns true if the schema contains a valid maxContains property
|
|
477
|
+
* @specification Json Schema 2019-09
|
|
478
|
+
*/
|
|
479
|
+
function IsMaxContains(schema) {
|
|
480
|
+
return HasPropertyKey(schema, "maxContains") && IsNumber$1(schema.maxContains);
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/maxItems.mjs
|
|
484
|
+
/**
|
|
485
|
+
* Returns true if the schema contains a valid maxItems property
|
|
486
|
+
* @specification Json Schema 7
|
|
487
|
+
*/
|
|
488
|
+
function IsMaxItems(schema) {
|
|
489
|
+
return HasPropertyKey(schema, "maxItems") && IsNumber$1(schema.maxItems);
|
|
490
|
+
}
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/maxLength.mjs
|
|
493
|
+
/**
|
|
494
|
+
* Returns true if the schema contains a valid maxLength property
|
|
495
|
+
* @specification Json Schema 7
|
|
496
|
+
*/
|
|
497
|
+
function IsMaxLength(schema) {
|
|
498
|
+
return HasPropertyKey(schema, "maxLength") && IsNumber$1(schema.maxLength);
|
|
499
|
+
}
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/maxProperties.mjs
|
|
502
|
+
/**
|
|
503
|
+
* Returns true if the schema contains a valid maxProperties property
|
|
504
|
+
* @specification Json Schema 7
|
|
505
|
+
*/
|
|
506
|
+
function IsMaxProperties(schema) {
|
|
507
|
+
return HasPropertyKey(schema, "maxProperties") && IsNumber$1(schema.maxProperties);
|
|
508
|
+
}
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/minimum.mjs
|
|
511
|
+
/**
|
|
512
|
+
* Returns true if the schema contains a valid minimum property
|
|
513
|
+
* @specification Json Schema 7
|
|
514
|
+
*/
|
|
515
|
+
function IsMinimum(schema) {
|
|
516
|
+
return HasPropertyKey(schema, "minimum") && (IsNumber$1(schema.minimum) || IsBigInt(schema.minimum));
|
|
517
|
+
}
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/minContains.mjs
|
|
520
|
+
/**
|
|
521
|
+
* Returns true if the schema contains a valid maxContains property
|
|
522
|
+
* @specification Json Schema 2019-09
|
|
523
|
+
*/
|
|
524
|
+
function IsMinContains(schema) {
|
|
525
|
+
return HasPropertyKey(schema, "minContains") && IsNumber$1(schema.minContains);
|
|
526
|
+
}
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/minItems.mjs
|
|
529
|
+
/**
|
|
530
|
+
* Returns true if the schema contains a valid minItems property
|
|
531
|
+
* @specification Json Schema 7
|
|
532
|
+
*/
|
|
533
|
+
function IsMinItems(schema) {
|
|
534
|
+
return HasPropertyKey(schema, "minItems") && IsNumber$1(schema.minItems);
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/minLength.mjs
|
|
538
|
+
/**
|
|
539
|
+
* Returns true if the schema contains a valid minLength property
|
|
540
|
+
* @specification Json Schema 7
|
|
541
|
+
*/
|
|
542
|
+
function IsMinLength(schema) {
|
|
543
|
+
return HasPropertyKey(schema, "minLength") && IsNumber$1(schema.minLength);
|
|
544
|
+
}
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/minProperties.mjs
|
|
547
|
+
/**
|
|
548
|
+
* Returns true if the schema contains a valid minProperties property
|
|
549
|
+
* @specification Json Schema 7
|
|
550
|
+
*/
|
|
551
|
+
function IsMinProperties(schema) {
|
|
552
|
+
return HasPropertyKey(schema, "minProperties") && IsNumber$1(schema.minProperties);
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/multipleOf.mjs
|
|
556
|
+
/**
|
|
557
|
+
* Returns true if the schema contains a valid multipleOf property
|
|
558
|
+
* @specification Json Schema 7
|
|
559
|
+
*/
|
|
560
|
+
function IsMultipleOf(schema) {
|
|
561
|
+
return HasPropertyKey(schema, "multipleOf") && (IsNumber$1(schema.multipleOf) || IsBigInt(schema.multipleOf));
|
|
562
|
+
}
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/not.mjs
|
|
565
|
+
/**
|
|
566
|
+
* Returns true if the schema contains a valid not property
|
|
567
|
+
* @specification Json Schema 7
|
|
568
|
+
*/
|
|
569
|
+
function IsNot(schema) {
|
|
570
|
+
return HasPropertyKey(schema, "not") && IsSchema(schema.not);
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/oneOf.mjs
|
|
574
|
+
/**
|
|
575
|
+
* Returns true if the schema contains a valid oneOf property
|
|
576
|
+
* @specification Json Schema 7
|
|
577
|
+
*/
|
|
578
|
+
function IsOneOf(schema) {
|
|
579
|
+
return HasPropertyKey(schema, "oneOf") && IsArray(schema.oneOf) && schema.oneOf.every((value) => IsSchema(value));
|
|
580
|
+
}
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/pattern.mjs
|
|
583
|
+
/**
|
|
584
|
+
* Returns true if the schema contains a valid pattern property
|
|
585
|
+
* @specification Json Schema 7
|
|
586
|
+
*/
|
|
587
|
+
function IsPattern(schema) {
|
|
588
|
+
return HasPropertyKey(schema, "pattern") && (IsString$1(schema.pattern) || schema.pattern instanceof RegExp);
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/patternProperties.mjs
|
|
592
|
+
/**
|
|
593
|
+
* Returns true if the schema contains a valid patternProperties property
|
|
594
|
+
* @specification Json Schema 7
|
|
595
|
+
*/
|
|
596
|
+
function IsPatternProperties(schema) {
|
|
597
|
+
return HasPropertyKey(schema, "patternProperties") && IsObject(schema.patternProperties) && Object.values(schema.patternProperties).every((value) => IsSchema(value));
|
|
598
|
+
}
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/prefixItems.mjs
|
|
601
|
+
/**
|
|
602
|
+
* Returns true if the schema contains a valid prefixItems property
|
|
603
|
+
*/
|
|
604
|
+
function IsPrefixItems(schema) {
|
|
605
|
+
return HasPropertyKey(schema, "prefixItems") && IsArray(schema.prefixItems) && schema.prefixItems.every((schema) => IsSchema(schema));
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/properties.mjs
|
|
609
|
+
/**
|
|
610
|
+
* Returns true if the schema contains a valid properties property
|
|
611
|
+
* @specification Json Schema 7
|
|
612
|
+
*/
|
|
613
|
+
function IsProperties(schema) {
|
|
614
|
+
return HasPropertyKey(schema, "properties") && IsObject(schema.properties) && Object.values(schema.properties).every((value) => IsSchema(value));
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/propertyNames.mjs
|
|
618
|
+
/**
|
|
619
|
+
* Returns true if the schema contains a valid propertyNames property
|
|
620
|
+
* @specification Json Schema 7
|
|
621
|
+
*/
|
|
622
|
+
function IsPropertyNames(schema) {
|
|
623
|
+
return HasPropertyKey(schema, "propertyNames") && (IsObject(schema.propertyNames) || IsSchema(schema.propertyNames));
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/recursiveAnchor.mjs
|
|
627
|
+
/**
|
|
628
|
+
* Returns true if the schema contains a valid $recursiveAnchor property
|
|
629
|
+
*/
|
|
630
|
+
function IsRecursiveAnchor(schema) {
|
|
631
|
+
return HasPropertyKey(schema, "$recursiveAnchor") && IsBoolean$1(schema.$recursiveAnchor);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Returns true if the schema contains a valid $recursiveAnchor property that is true
|
|
635
|
+
*/
|
|
636
|
+
function IsRecursiveAnchorTrue(schema) {
|
|
637
|
+
return IsRecursiveAnchor(schema) && IsEqual(schema.$recursiveAnchor, true);
|
|
638
|
+
}
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/recursiveRef.mjs
|
|
641
|
+
/**
|
|
642
|
+
* Returns true if the schema contains a valid $recursiveRef property
|
|
643
|
+
*/
|
|
644
|
+
function IsRecursiveRef(schema) {
|
|
645
|
+
return HasPropertyKey(schema, "$recursiveRef") && IsString$1(schema.$recursiveRef);
|
|
646
|
+
}
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/ref.mjs
|
|
649
|
+
/**
|
|
650
|
+
* Returns true if the schema contains a valid $ref property
|
|
651
|
+
* @specification Json Schema 7
|
|
652
|
+
*/
|
|
653
|
+
function IsRef(schema) {
|
|
654
|
+
return HasPropertyKey(schema, "$ref") && IsString$1(schema.$ref);
|
|
655
|
+
}
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/required.mjs
|
|
658
|
+
/**
|
|
659
|
+
* Returns true if the schema contains a valid required property
|
|
660
|
+
* @specification Json Schema 7
|
|
661
|
+
*/
|
|
662
|
+
function IsRequired(schema) {
|
|
663
|
+
return HasPropertyKey(schema, "required") && IsArray(schema.required) && schema.required.every((value) => IsString$1(value));
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/then.mjs
|
|
667
|
+
/**
|
|
668
|
+
* Returns true if the schema contains a valid then property
|
|
669
|
+
* @specification Json Schema 7
|
|
670
|
+
*/
|
|
671
|
+
function IsThen(schema) {
|
|
672
|
+
return HasPropertyKey(schema, "then") && IsSchema(schema.then);
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/type.mjs
|
|
676
|
+
/**
|
|
677
|
+
* Returns true if the schema contains a valid type property
|
|
678
|
+
* @specification Json Schema 7
|
|
679
|
+
*/
|
|
680
|
+
function IsType(schema) {
|
|
681
|
+
return HasPropertyKey(schema, "type") && (IsString$1(schema.type) || IsArray(schema.type) && schema.type.every((value) => IsString$1(value)));
|
|
682
|
+
}
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/uniqueItems.mjs
|
|
685
|
+
/**
|
|
686
|
+
* Returns true if the schema contains a valid uniqueItems property
|
|
687
|
+
* @specification Json Schema 7
|
|
688
|
+
*/
|
|
689
|
+
function IsUniqueItems(schema) {
|
|
690
|
+
return HasPropertyKey(schema, "uniqueItems") && IsBoolean$1(schema.uniqueItems);
|
|
691
|
+
}
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/unevaluatedItems.mjs
|
|
694
|
+
/**
|
|
695
|
+
* Returns true if the schema contains a valid unevaluatedItems property
|
|
696
|
+
* @specification Json Schema 2019-09
|
|
697
|
+
*/
|
|
698
|
+
function IsUnevaluatedItems(schema) {
|
|
699
|
+
return HasPropertyKey(schema, "unevaluatedItems") && IsSchema(schema.unevaluatedItems);
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/unevaluatedProperties.mjs
|
|
703
|
+
/**
|
|
704
|
+
* Returns true if the schema contains a valid unevaluatedProperties property
|
|
705
|
+
* @specification Json Schema 2019-09
|
|
706
|
+
*/
|
|
707
|
+
function IsUnevaluatedProperties(schema) {
|
|
708
|
+
return HasPropertyKey(schema, "unevaluatedProperties") && IsSchema(schema.unevaluatedProperties);
|
|
709
|
+
}
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/_context.mjs
|
|
712
|
+
var CheckContext = class {
|
|
713
|
+
constructor() {
|
|
714
|
+
const indices = /* @__PURE__ */ new Set();
|
|
715
|
+
const keys = /* @__PURE__ */ new Set();
|
|
716
|
+
this.stack = [{
|
|
717
|
+
indices,
|
|
718
|
+
keys
|
|
719
|
+
}];
|
|
720
|
+
}
|
|
721
|
+
Push() {
|
|
722
|
+
const indices = /* @__PURE__ */ new Set();
|
|
723
|
+
const keys = /* @__PURE__ */ new Set();
|
|
724
|
+
this.stack.push({
|
|
725
|
+
indices,
|
|
726
|
+
keys
|
|
727
|
+
});
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
Pop() {
|
|
731
|
+
this.stack.pop();
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
AddIndex(index) {
|
|
735
|
+
this.GetIndices().add(index);
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
AddKey(key) {
|
|
739
|
+
this.GetKeys().add(key);
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
GetIndices() {
|
|
743
|
+
return this.stack[this.stack.length - 1].indices;
|
|
744
|
+
}
|
|
745
|
+
GetKeys() {
|
|
746
|
+
return this.stack[this.stack.length - 1].keys;
|
|
747
|
+
}
|
|
748
|
+
Merge(results) {
|
|
749
|
+
for (const context of results) {
|
|
750
|
+
context.GetIndices().forEach((value) => this.GetIndices().add(value));
|
|
751
|
+
context.GetKeys().forEach((value) => this.GetKeys().add(value));
|
|
752
|
+
}
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
var ErrorContext = class extends CheckContext {
|
|
757
|
+
constructor(callback) {
|
|
758
|
+
super();
|
|
759
|
+
this.callback = callback;
|
|
760
|
+
}
|
|
761
|
+
AddError(error) {
|
|
762
|
+
this.callback(error);
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
var AccumulatedErrorContext = class extends ErrorContext {
|
|
767
|
+
constructor() {
|
|
768
|
+
super((error) => this.errors.push(error));
|
|
769
|
+
this.errors = [];
|
|
770
|
+
}
|
|
771
|
+
AddError(error) {
|
|
772
|
+
this.errors.push(error);
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
GetErrors() {
|
|
776
|
+
return this.errors;
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/_guard.mjs
|
|
781
|
+
function CheckGuard(_stack, _context, schema, value) {
|
|
782
|
+
return schema["~guard"].check(value);
|
|
783
|
+
}
|
|
784
|
+
function ErrorGuard(_stack, context, schemaPath, instancePath, schema, value) {
|
|
785
|
+
return schema["~guard"].check(value) || context.AddError({
|
|
786
|
+
keyword: "~guard",
|
|
787
|
+
schemaPath,
|
|
788
|
+
instancePath,
|
|
789
|
+
params: { errors: schema["~guard"].errors(value) }
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/unreachable/unreachable.mjs
|
|
794
|
+
/** Used for unreachable logic */
|
|
795
|
+
function Unreachable() {
|
|
796
|
+
throw new Error("Unreachable");
|
|
797
|
+
}
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/hashing/hash.mjs
|
|
800
|
+
function InstanceKeys(value) {
|
|
801
|
+
const propertyKeys = /* @__PURE__ */ new Set();
|
|
802
|
+
let current = value;
|
|
803
|
+
while (current && current !== Object.prototype) {
|
|
804
|
+
for (const key of Reflect.ownKeys(current)) if (key !== "constructor" && typeof key !== "symbol") propertyKeys.add(key);
|
|
805
|
+
current = Object.getPrototypeOf(current);
|
|
806
|
+
}
|
|
807
|
+
return [...propertyKeys];
|
|
808
|
+
}
|
|
809
|
+
function IsIEEE754(value) {
|
|
810
|
+
return typeof value === "number";
|
|
811
|
+
}
|
|
812
|
+
var ByteMarker;
|
|
813
|
+
(function(ByteMarker) {
|
|
814
|
+
ByteMarker[ByteMarker["Array"] = 0] = "Array";
|
|
815
|
+
ByteMarker[ByteMarker["BigInt"] = 1] = "BigInt";
|
|
816
|
+
ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean";
|
|
817
|
+
ByteMarker[ByteMarker["Date"] = 3] = "Date";
|
|
818
|
+
ByteMarker[ByteMarker["Constructor"] = 4] = "Constructor";
|
|
819
|
+
ByteMarker[ByteMarker["Function"] = 5] = "Function";
|
|
820
|
+
ByteMarker[ByteMarker["Null"] = 6] = "Null";
|
|
821
|
+
ByteMarker[ByteMarker["Number"] = 7] = "Number";
|
|
822
|
+
ByteMarker[ByteMarker["Object"] = 8] = "Object";
|
|
823
|
+
ByteMarker[ByteMarker["RegExp"] = 9] = "RegExp";
|
|
824
|
+
ByteMarker[ByteMarker["String"] = 10] = "String";
|
|
825
|
+
ByteMarker[ByteMarker["Symbol"] = 11] = "Symbol";
|
|
826
|
+
ByteMarker[ByteMarker["TypeArray"] = 12] = "TypeArray";
|
|
827
|
+
ByteMarker[ByteMarker["Undefined"] = 13] = "Undefined";
|
|
828
|
+
})(ByteMarker || (ByteMarker = {}));
|
|
829
|
+
let Accumulator = BigInt("14695981039346656037");
|
|
830
|
+
const [Prime, Size] = [BigInt("1099511628211"), BigInt("18446744073709551616")];
|
|
831
|
+
const Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));
|
|
832
|
+
const F64 = new Float64Array(1);
|
|
833
|
+
const F64In = new DataView(F64.buffer);
|
|
834
|
+
const F64Out = new Uint8Array(F64.buffer);
|
|
835
|
+
function FNV1A64_OP(byte) {
|
|
836
|
+
Accumulator = Accumulator ^ Bytes[byte];
|
|
837
|
+
Accumulator = Accumulator * Prime % Size;
|
|
838
|
+
}
|
|
839
|
+
function FromArray$1(value) {
|
|
840
|
+
FNV1A64_OP(ByteMarker.Array);
|
|
841
|
+
for (const item of value) FromValue$1(item);
|
|
842
|
+
}
|
|
843
|
+
function FromBigInt(value) {
|
|
844
|
+
FNV1A64_OP(ByteMarker.BigInt);
|
|
845
|
+
F64In.setBigInt64(0, value);
|
|
846
|
+
for (const byte of F64Out) FNV1A64_OP(byte);
|
|
847
|
+
}
|
|
848
|
+
function FromBoolean(value) {
|
|
849
|
+
FNV1A64_OP(ByteMarker.Boolean);
|
|
850
|
+
FNV1A64_OP(value ? 1 : 0);
|
|
851
|
+
}
|
|
852
|
+
function FromConstructor(value) {
|
|
853
|
+
FNV1A64_OP(ByteMarker.Constructor);
|
|
854
|
+
FromValue$1(value.toString());
|
|
855
|
+
}
|
|
856
|
+
function FromDate(value) {
|
|
857
|
+
FNV1A64_OP(ByteMarker.Date);
|
|
858
|
+
FromValue$1(value.getTime());
|
|
859
|
+
}
|
|
860
|
+
function FromFunction(value) {
|
|
861
|
+
FNV1A64_OP(ByteMarker.Function);
|
|
862
|
+
FromValue$1(value.toString());
|
|
863
|
+
}
|
|
864
|
+
function FromNull(_value) {
|
|
865
|
+
FNV1A64_OP(ByteMarker.Null);
|
|
866
|
+
}
|
|
867
|
+
function FromNumber(value) {
|
|
868
|
+
FNV1A64_OP(ByteMarker.Number);
|
|
869
|
+
F64In.setFloat64(0, value, true);
|
|
870
|
+
for (const byte of F64Out) FNV1A64_OP(byte);
|
|
871
|
+
}
|
|
872
|
+
function FromObject$1(value) {
|
|
873
|
+
FNV1A64_OP(ByteMarker.Object);
|
|
874
|
+
for (const key of InstanceKeys(value).sort()) {
|
|
875
|
+
FromValue$1(key);
|
|
876
|
+
FromValue$1(value[key]);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function FromRegExp(value) {
|
|
880
|
+
FNV1A64_OP(ByteMarker.RegExp);
|
|
881
|
+
FromString(value.toString());
|
|
882
|
+
}
|
|
883
|
+
const encoder = new TextEncoder();
|
|
884
|
+
function FromString(value) {
|
|
885
|
+
FNV1A64_OP(ByteMarker.String);
|
|
886
|
+
for (const byte of encoder.encode(value)) FNV1A64_OP(byte);
|
|
887
|
+
}
|
|
888
|
+
function FromSymbol(value) {
|
|
889
|
+
FNV1A64_OP(ByteMarker.Symbol);
|
|
890
|
+
FromValue$1(value.toString());
|
|
891
|
+
}
|
|
892
|
+
function FromTypeArray(value) {
|
|
893
|
+
FNV1A64_OP(ByteMarker.TypeArray);
|
|
894
|
+
const buffer = new Uint8Array(value.buffer);
|
|
895
|
+
for (let i = 0; i < buffer.length; i++) FNV1A64_OP(buffer[i]);
|
|
896
|
+
}
|
|
897
|
+
function FromUndefined(_value) {
|
|
898
|
+
return FNV1A64_OP(ByteMarker.Undefined);
|
|
899
|
+
}
|
|
900
|
+
function FromValue$1(value) {
|
|
901
|
+
return IsTypeArray(value) ? FromTypeArray(value) : IsDate$1(value) ? FromDate(value) : IsRegExp(value) ? FromRegExp(value) : IsBoolean(value) ? FromBoolean(value.valueOf()) : IsString(value) ? FromString(value.valueOf()) : IsNumber(value) ? FromNumber(value.valueOf()) : IsIEEE754(value) ? FromNumber(value) : IsArray(value) ? FromArray$1(value) : IsBoolean$1(value) ? FromBoolean(value) : IsBigInt(value) ? FromBigInt(value) : IsConstructor(value) ? FromConstructor(value) : IsNull(value) ? FromNull(value) : IsObject(value) ? FromObject$1(value) : IsString$1(value) ? FromString(value) : IsSymbol(value) ? FromSymbol(value) : IsUndefined(value) ? FromUndefined(value) : IsFunction(value) ? FromFunction(value) : Unreachable();
|
|
902
|
+
}
|
|
903
|
+
/** Generates a FNV1A-64 non cryptographic hash of the given value */
|
|
904
|
+
function HashCode(value) {
|
|
905
|
+
Accumulator = BigInt("14695981039346656037");
|
|
906
|
+
FromValue$1(value);
|
|
907
|
+
return Accumulator;
|
|
908
|
+
}
|
|
909
|
+
/** Generates a FNV1A-64 non cryptographic hash of the given value */
|
|
910
|
+
function Hash(value) {
|
|
911
|
+
return HashCode(value).toString(16).padStart(16, "0");
|
|
912
|
+
}
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/_refine.mjs
|
|
915
|
+
function CheckRefine(_stack, _context, schema, value) {
|
|
916
|
+
return Every(schema["~refine"], 0, (refinement, _) => refinement.check(value));
|
|
917
|
+
}
|
|
918
|
+
function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
|
|
919
|
+
return EveryAll(schema["~refine"], 0, (refinement, index) => {
|
|
920
|
+
return refinement.check(value) || context.AddError({
|
|
921
|
+
keyword: "~refine",
|
|
922
|
+
schemaPath,
|
|
923
|
+
instancePath,
|
|
924
|
+
params: {
|
|
925
|
+
index,
|
|
926
|
+
message: refinement.error(value)
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/additionalItems.mjs
|
|
933
|
+
function IsValid$4(schema) {
|
|
934
|
+
return IsItems(schema) && IsArray(schema.items);
|
|
935
|
+
}
|
|
936
|
+
function CheckAdditionalItems(stack, context, schema, value) {
|
|
937
|
+
if (!IsValid$4(schema)) return true;
|
|
938
|
+
return value.every((item, index) => {
|
|
939
|
+
return IsLessThan(index, schema.items.length) || CheckSchemaPushStack(stack, context, schema.additionalItems, item) && context.AddIndex(index);
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
943
|
+
if (!IsValid$4(schema)) return true;
|
|
944
|
+
return value.every((item, index) => {
|
|
945
|
+
const nextSchemaPath = `${schemaPath}/additionalItems`;
|
|
946
|
+
const nextInstancePath = `${instancePath}/${index}`;
|
|
947
|
+
return IsLessThan(index, schema.items.length) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalItems, item) && context.AddIndex(index);
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
//#endregion
|
|
951
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/additionalProperties.mjs
|
|
952
|
+
function GetPropertyKeyAsPattern(key) {
|
|
953
|
+
return `^${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
|
|
954
|
+
}
|
|
955
|
+
function GetPropertiesPattern(schema) {
|
|
956
|
+
const patterns = [];
|
|
957
|
+
if (IsPatternProperties(schema)) patterns.push(...Keys(schema.patternProperties));
|
|
958
|
+
if (IsProperties(schema)) patterns.push(...Keys(schema.properties).map(GetPropertyKeyAsPattern));
|
|
959
|
+
return IsEqual(patterns.length, 0) ? "(?!)" : `(${patterns.join("|")})`;
|
|
960
|
+
}
|
|
961
|
+
function CheckAdditionalProperties(stack, context, schema, value) {
|
|
962
|
+
const regexp = new RegExp(GetPropertiesPattern(schema));
|
|
963
|
+
return Every(Keys(value), 0, (key, _index) => {
|
|
964
|
+
return regexp.test(key) || CheckSchemaPushStack(stack, context, schema.additionalProperties, value[key]) && context.AddKey(key);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
968
|
+
const regexp = new RegExp(GetPropertiesPattern(schema));
|
|
969
|
+
const additionalProperties = [];
|
|
970
|
+
return EveryAll(Keys(value), 0, (key, _index) => {
|
|
971
|
+
const nextSchemaPath = `${schemaPath}/additionalProperties`;
|
|
972
|
+
const nextInstancePath = `${instancePath}/${key}`;
|
|
973
|
+
const nextContext = new AccumulatedErrorContext();
|
|
974
|
+
const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, nextContext, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
|
|
975
|
+
if (!isAdditionalProperty) additionalProperties.push(key);
|
|
976
|
+
return isAdditionalProperty;
|
|
977
|
+
}) || context.AddError({
|
|
978
|
+
keyword: "additionalProperties",
|
|
979
|
+
schemaPath,
|
|
980
|
+
instancePath,
|
|
981
|
+
params: { additionalProperties }
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/allOf.mjs
|
|
986
|
+
function CheckAllOf(stack, context, schema, value) {
|
|
987
|
+
const results = schema.allOf.reduce((result, schema) => {
|
|
988
|
+
const nextContext = new CheckContext();
|
|
989
|
+
return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
|
|
990
|
+
}, []);
|
|
991
|
+
return IsEqual(results.length, schema.allOf.length) && context.Merge(results);
|
|
992
|
+
}
|
|
993
|
+
function ErrorAllOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
994
|
+
const failedContexts = [];
|
|
995
|
+
const results = schema.allOf.reduce((result, schema, index) => {
|
|
996
|
+
const nextSchemaPath = `${schemaPath}/allOf/${index}`;
|
|
997
|
+
const nextContext = new AccumulatedErrorContext();
|
|
998
|
+
const isSchema = ErrorSchema(stack, nextContext, nextSchemaPath, instancePath, schema, value);
|
|
999
|
+
if (!isSchema) failedContexts.push(nextContext);
|
|
1000
|
+
return isSchema ? [...result, nextContext] : result;
|
|
1001
|
+
}, []);
|
|
1002
|
+
const isAllOf = IsEqual(results.length, schema.allOf.length) && context.Merge(results);
|
|
1003
|
+
if (!isAllOf) failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
|
|
1004
|
+
return isAllOf;
|
|
1005
|
+
}
|
|
1006
|
+
//#endregion
|
|
1007
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/anyOf.mjs
|
|
1008
|
+
function CheckAnyOf(stack, context, schema, value) {
|
|
1009
|
+
const results = schema.anyOf.reduce((result, schema) => {
|
|
1010
|
+
const nextContext = new CheckContext();
|
|
1011
|
+
return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
|
|
1012
|
+
}, []);
|
|
1013
|
+
return IsGreaterThan(results.length, 0) && context.Merge(results);
|
|
1014
|
+
}
|
|
1015
|
+
function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
1016
|
+
const failedContexts = [];
|
|
1017
|
+
const results = schema.anyOf.reduce((result, schema, index) => {
|
|
1018
|
+
const nextContext = new AccumulatedErrorContext();
|
|
1019
|
+
const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/anyOf/${index}`, instancePath, schema, value);
|
|
1020
|
+
if (!isSchema) failedContexts.push(nextContext);
|
|
1021
|
+
return isSchema ? [...result, nextContext] : result;
|
|
1022
|
+
}, []);
|
|
1023
|
+
const isAnyOf = IsGreaterThan(results.length, 0) && context.Merge(results);
|
|
1024
|
+
if (!isAnyOf) failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
|
|
1025
|
+
return isAnyOf || context.AddError({
|
|
1026
|
+
keyword: "anyOf",
|
|
1027
|
+
schemaPath,
|
|
1028
|
+
instancePath,
|
|
1029
|
+
params: {}
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/boolean.mjs
|
|
1034
|
+
function CheckBooleanSchema(_stack, _context, schema, _value) {
|
|
1035
|
+
return schema;
|
|
1036
|
+
}
|
|
1037
|
+
function ErrorBooleanSchema(stack, context, schemaPath, instancePath, schema, value) {
|
|
1038
|
+
return CheckBooleanSchema(stack, context, schema, value) || context.AddError({
|
|
1039
|
+
keyword: "boolean",
|
|
1040
|
+
schemaPath,
|
|
1041
|
+
instancePath,
|
|
1042
|
+
params: {}
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
1046
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/const.mjs
|
|
1047
|
+
function CheckConst(_stack, _context, schema, value) {
|
|
1048
|
+
return IsValueLike(schema.const) ? IsEqual(value, schema.const) : IsDeepEqual(value, schema.const);
|
|
1049
|
+
}
|
|
1050
|
+
function ErrorConst(stack, context, schemaPath, instancePath, schema, value) {
|
|
1051
|
+
return CheckConst(stack, context, schema, value) || context.AddError({
|
|
1052
|
+
keyword: "const",
|
|
1053
|
+
schemaPath,
|
|
1054
|
+
instancePath,
|
|
1055
|
+
params: { allowedValue: schema.const }
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/contains.mjs
|
|
1060
|
+
function IsValid$3(schema) {
|
|
1061
|
+
return !(IsMinContains(schema) && IsEqual(schema.minContains, 0));
|
|
1062
|
+
}
|
|
1063
|
+
function CheckContains(stack, context, schema, value) {
|
|
1064
|
+
if (!IsValid$3(schema)) return true;
|
|
1065
|
+
return !IsEqual(value.length, 0) && value.some((item) => CheckSchema(stack, context, schema.contains, item));
|
|
1066
|
+
}
|
|
1067
|
+
function ErrorContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
1068
|
+
return CheckContains(stack, context, schema, value) || context.AddError({
|
|
1069
|
+
keyword: "contains",
|
|
1070
|
+
schemaPath,
|
|
1071
|
+
instancePath,
|
|
1072
|
+
params: { minContains: 1 }
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/dependencies.mjs
|
|
1077
|
+
function CheckDependencies(stack, context, schema, value) {
|
|
1078
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1079
|
+
const isEvery = Every(Entries(schema.dependencies), 0, ([key, schema]) => {
|
|
1080
|
+
return !HasPropertyKey(value, key) || (IsArray(schema) ? schema.every((key) => HasPropertyKey(value, key)) : CheckSchema(stack, context, schema, value));
|
|
1081
|
+
});
|
|
1082
|
+
return isLength || isEvery;
|
|
1083
|
+
}
|
|
1084
|
+
function ErrorDependencies(stack, context, schemaPath, instancePath, schema, value) {
|
|
1085
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1086
|
+
const isEvery = EveryAll(Entries(schema.dependencies), 0, ([key, schema]) => {
|
|
1087
|
+
const nextSchemaPath = `${schemaPath}/dependencies/${key}`;
|
|
1088
|
+
return !HasPropertyKey(value, key) || (IsArray(schema) ? schema.every((dependency) => HasPropertyKey(value, dependency) || context.AddError({
|
|
1089
|
+
keyword: "dependencies",
|
|
1090
|
+
schemaPath,
|
|
1091
|
+
instancePath,
|
|
1092
|
+
params: {
|
|
1093
|
+
property: key,
|
|
1094
|
+
dependencies: schema
|
|
1095
|
+
}
|
|
1096
|
+
})) : ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value));
|
|
1097
|
+
});
|
|
1098
|
+
return isLength || isEvery;
|
|
1099
|
+
}
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/dependentRequired.mjs
|
|
1102
|
+
function CheckDependentRequired(_stack, _context, schema, value) {
|
|
1103
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1104
|
+
const isEvery = Every(Entries(schema.dependentRequired), 0, ([key, keys]) => {
|
|
1105
|
+
return !HasPropertyKey(value, key) || keys.every((key) => HasPropertyKey(value, key));
|
|
1106
|
+
});
|
|
1107
|
+
return isLength || isEvery;
|
|
1108
|
+
}
|
|
1109
|
+
function ErrorDependentRequired(_stack, context, schemaPath, instancePath, schema, value) {
|
|
1110
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1111
|
+
const isEveryEntry = EveryAll(Entries(schema.dependentRequired), 0, ([key, keys]) => {
|
|
1112
|
+
return !HasPropertyKey(value, key) || EveryAll(keys, 0, (dependency) => HasPropertyKey(value, dependency) || context.AddError({
|
|
1113
|
+
keyword: "dependentRequired",
|
|
1114
|
+
schemaPath,
|
|
1115
|
+
instancePath,
|
|
1116
|
+
params: {
|
|
1117
|
+
property: key,
|
|
1118
|
+
dependencies: keys
|
|
1119
|
+
}
|
|
1120
|
+
}));
|
|
1121
|
+
});
|
|
1122
|
+
return isLength || isEveryEntry;
|
|
1123
|
+
}
|
|
1124
|
+
//#endregion
|
|
1125
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/dependentSchemas.mjs
|
|
1126
|
+
function CheckDependentSchemas(stack, context, schema, value) {
|
|
1127
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1128
|
+
const isEvery = Every(Entries(schema.dependentSchemas), 0, ([key, schema]) => {
|
|
1129
|
+
return !HasPropertyKey(value, key) || CheckSchema(stack, context, schema, value);
|
|
1130
|
+
});
|
|
1131
|
+
return isLength || isEvery;
|
|
1132
|
+
}
|
|
1133
|
+
function ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value) {
|
|
1134
|
+
const isLength = IsEqual(Keys(value).length, 0);
|
|
1135
|
+
const isEvery = EveryAll(Entries(schema.dependentSchemas), 0, ([key, schema]) => {
|
|
1136
|
+
const nextSchemaPath = `${schemaPath}/dependentSchemas/${key}`;
|
|
1137
|
+
return !HasPropertyKey(value, key) || ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value);
|
|
1138
|
+
});
|
|
1139
|
+
return isLength || isEvery;
|
|
1140
|
+
}
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/dynamicRef.mjs
|
|
1143
|
+
function CheckDynamicRef(stack, context, schema, value) {
|
|
1144
|
+
const target = stack.DynamicRef(schema) ?? false;
|
|
1145
|
+
return IsSchema(target) && CheckSchema(stack, context, target, value);
|
|
1146
|
+
}
|
|
1147
|
+
function ErrorDynamicRef(stack, context, _schemaPath, instancePath, schema, value) {
|
|
1148
|
+
const target = stack.DynamicRef(schema) ?? false;
|
|
1149
|
+
return IsSchema(target) && ErrorSchema(stack, context, "#", instancePath, target, value);
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/enum.mjs
|
|
1153
|
+
function CheckEnum(_stack, _context, schema, value) {
|
|
1154
|
+
return schema.enum.some((option) => IsValueLike(option) ? IsEqual(value, option) : IsDeepEqual(value, option));
|
|
1155
|
+
}
|
|
1156
|
+
function ErrorEnum(stack, context, schemaPath, instancePath, schema, value) {
|
|
1157
|
+
return CheckEnum(stack, context, schema, value) || context.AddError({
|
|
1158
|
+
keyword: "enum",
|
|
1159
|
+
schemaPath,
|
|
1160
|
+
instancePath,
|
|
1161
|
+
params: { allowedValues: schema.enum }
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
//#endregion
|
|
1165
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs
|
|
1166
|
+
function CheckExclusiveMaximum(_stack, _context, schema, value) {
|
|
1167
|
+
return IsLessThan(value, schema.exclusiveMaximum);
|
|
1168
|
+
}
|
|
1169
|
+
function ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value) {
|
|
1170
|
+
return CheckExclusiveMaximum(stack, context, schema, value) || context.AddError({
|
|
1171
|
+
keyword: "exclusiveMaximum",
|
|
1172
|
+
schemaPath,
|
|
1173
|
+
instancePath,
|
|
1174
|
+
params: {
|
|
1175
|
+
comparison: "<",
|
|
1176
|
+
limit: schema.exclusiveMaximum
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs
|
|
1182
|
+
function CheckExclusiveMinimum(_stack, _context, schema, value) {
|
|
1183
|
+
return IsGreaterThan(value, schema.exclusiveMinimum);
|
|
1184
|
+
}
|
|
1185
|
+
function ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value) {
|
|
1186
|
+
return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError({
|
|
1187
|
+
keyword: "exclusiveMinimum",
|
|
1188
|
+
schemaPath,
|
|
1189
|
+
instancePath,
|
|
1190
|
+
params: {
|
|
1191
|
+
comparison: ">",
|
|
1192
|
+
limit: schema.exclusiveMinimum
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/date.mjs
|
|
1198
|
+
const DAYS = [
|
|
1199
|
+
0,
|
|
1200
|
+
31,
|
|
1201
|
+
28,
|
|
1202
|
+
31,
|
|
1203
|
+
30,
|
|
1204
|
+
31,
|
|
1205
|
+
30,
|
|
1206
|
+
31,
|
|
1207
|
+
31,
|
|
1208
|
+
30,
|
|
1209
|
+
31,
|
|
1210
|
+
30,
|
|
1211
|
+
31
|
|
1212
|
+
];
|
|
1213
|
+
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
1214
|
+
function IsLeapYear(year) {
|
|
1215
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Returns true if the value is a ISO8601 Date component string
|
|
1219
|
+
* @source ajv-formats
|
|
1220
|
+
* @example `2020-12-12`
|
|
1221
|
+
*/
|
|
1222
|
+
function IsDate(value) {
|
|
1223
|
+
const matches = DATE.exec(value);
|
|
1224
|
+
if (!matches) return false;
|
|
1225
|
+
const year = +matches[1];
|
|
1226
|
+
const month = +matches[2];
|
|
1227
|
+
const day = +matches[3];
|
|
1228
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && IsLeapYear(year) ? 29 : DAYS[month]);
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/time.mjs
|
|
1232
|
+
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(?:Z|([+-])(\d\d):(\d\d))?$/i;
|
|
1233
|
+
/**
|
|
1234
|
+
* Returns true if the value is a ISO time string
|
|
1235
|
+
* @specification
|
|
1236
|
+
*/
|
|
1237
|
+
function IsTime(value, strictTimeZone = true) {
|
|
1238
|
+
const matches = TIME.exec(value);
|
|
1239
|
+
if (!matches) return false;
|
|
1240
|
+
const hr = +matches[1];
|
|
1241
|
+
const min = +matches[2];
|
|
1242
|
+
const sec = +matches[3];
|
|
1243
|
+
const tzSign = matches[4] === "-" ? -1 : 1;
|
|
1244
|
+
const tzH = +(matches[5] || 0);
|
|
1245
|
+
const tzM = +(matches[6] || 0);
|
|
1246
|
+
if (tzH > 23 || tzM > 59) return false;
|
|
1247
|
+
if (strictTimeZone && !matches[4] && value.toLowerCase().indexOf("z") === -1) return false;
|
|
1248
|
+
if (hr <= 23 && min <= 59 && sec < 60) return true;
|
|
1249
|
+
const utcMin = min - tzM * tzSign;
|
|
1250
|
+
const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
|
|
1251
|
+
return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1254
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/date_time.mjs
|
|
1255
|
+
/**
|
|
1256
|
+
* Returns true if the value is a ISO8601 DateTime string
|
|
1257
|
+
* @source ajv-formats
|
|
1258
|
+
* @example `2020-12-12T20:20:40+00:00`
|
|
1259
|
+
*/
|
|
1260
|
+
function IsDateTime(value, strictTimeZone = true) {
|
|
1261
|
+
const dateTime = value.split(/T/i);
|
|
1262
|
+
return dateTime.length === 2 && IsDate(dateTime[0]) && IsTime(dateTime[1], strictTimeZone);
|
|
1263
|
+
}
|
|
1264
|
+
//#endregion
|
|
1265
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/duration.mjs
|
|
1266
|
+
const Duration = /^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;
|
|
1267
|
+
/**
|
|
1268
|
+
* Returns true if the value is a valid ISO-8601 duration.
|
|
1269
|
+
* @specification https://tools.ietf.org/html/rfc3339
|
|
1270
|
+
*/
|
|
1271
|
+
function IsDuration(value) {
|
|
1272
|
+
return Duration.test(value);
|
|
1273
|
+
}
|
|
1274
|
+
//#endregion
|
|
1275
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/email.mjs
|
|
1276
|
+
const Email = /^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[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;
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns true if the value is an Email
|
|
1279
|
+
* @specification ajv-formats
|
|
1280
|
+
*/
|
|
1281
|
+
function IsEmail(value) {
|
|
1282
|
+
return Email.test(value);
|
|
1283
|
+
}
|
|
1284
|
+
//#endregion
|
|
1285
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/_puny.mjs
|
|
1286
|
+
const PUNYCODE_BASE = 36;
|
|
1287
|
+
const PUNYCODE_TMIN = 1;
|
|
1288
|
+
const PUNYCODE_TMAX = 26;
|
|
1289
|
+
const PUNYCODE_SKEW = 38;
|
|
1290
|
+
const PUNYCODE_DAMP = 700;
|
|
1291
|
+
const PUNYCODE_INITIAL_BIAS = 72;
|
|
1292
|
+
const PUNYCODE_INITIAL_N = 128;
|
|
1293
|
+
function Adapt(delta, numPoints, firstTime) {
|
|
1294
|
+
delta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;
|
|
1295
|
+
delta += Math.floor(delta / numPoints);
|
|
1296
|
+
let k = 0;
|
|
1297
|
+
while (delta > 455) {
|
|
1298
|
+
delta = Math.floor(delta / (PUNYCODE_BASE - PUNYCODE_TMIN));
|
|
1299
|
+
k += PUNYCODE_BASE;
|
|
1300
|
+
}
|
|
1301
|
+
return k + Math.floor(36 * delta / (delta + PUNYCODE_SKEW));
|
|
1302
|
+
}
|
|
1303
|
+
function Decode(value) {
|
|
1304
|
+
const output = [];
|
|
1305
|
+
let n = PUNYCODE_INITIAL_N;
|
|
1306
|
+
let i = 0;
|
|
1307
|
+
let bias = PUNYCODE_INITIAL_BIAS;
|
|
1308
|
+
const delimIdx = value.lastIndexOf("-");
|
|
1309
|
+
if (delimIdx > 0) for (let j = 0; j < delimIdx; j++) {
|
|
1310
|
+
const cp = value.charCodeAt(j);
|
|
1311
|
+
if (cp >= 128) throw new Error("Invalid punycode: non-basic before delimiter");
|
|
1312
|
+
output.push(cp);
|
|
1313
|
+
}
|
|
1314
|
+
let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
|
|
1315
|
+
while (inIdx < value.length) {
|
|
1316
|
+
const oldi = i;
|
|
1317
|
+
let w = 1;
|
|
1318
|
+
let k = PUNYCODE_BASE;
|
|
1319
|
+
while (true) {
|
|
1320
|
+
if (inIdx >= value.length) throw new Error("Invalid punycode: unexpected end of input");
|
|
1321
|
+
const ch = value.charCodeAt(inIdx++);
|
|
1322
|
+
let digit;
|
|
1323
|
+
if (ch >= 97 && ch <= 122) digit = ch - 97;
|
|
1324
|
+
else if (ch >= 48 && ch <= 57) digit = ch - 48 + 26;
|
|
1325
|
+
else if (ch >= 65 && ch <= 90) digit = ch - 65;
|
|
1326
|
+
else throw new Error("Invalid punycode: bad digit character");
|
|
1327
|
+
i += digit * w;
|
|
1328
|
+
const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
|
|
1329
|
+
if (digit < t) break;
|
|
1330
|
+
w *= PUNYCODE_BASE - t;
|
|
1331
|
+
k += PUNYCODE_BASE;
|
|
1332
|
+
}
|
|
1333
|
+
const outLen = output.length + 1;
|
|
1334
|
+
bias = Adapt(i - oldi, outLen, oldi === 0);
|
|
1335
|
+
n += Math.floor(i / outLen);
|
|
1336
|
+
i %= outLen;
|
|
1337
|
+
output.splice(i, 0, n);
|
|
1338
|
+
i++;
|
|
1339
|
+
}
|
|
1340
|
+
return globalThis.String.fromCodePoint(...output);
|
|
1341
|
+
}
|
|
1342
|
+
//#endregion
|
|
1343
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/_idna.mjs
|
|
1344
|
+
function IsNonspacingMark(cp) {
|
|
1345
|
+
return /\p{Mn}/u.test(String.fromCodePoint(cp));
|
|
1346
|
+
}
|
|
1347
|
+
function IsSpacingCombiningMark(cp) {
|
|
1348
|
+
return /\p{Mc}/u.test(String.fromCodePoint(cp));
|
|
1349
|
+
}
|
|
1350
|
+
function IsEnclosingMark(cp) {
|
|
1351
|
+
return /\p{Me}/u.test(String.fromCodePoint(cp));
|
|
1352
|
+
}
|
|
1353
|
+
function IsCombiningMark(cp) {
|
|
1354
|
+
return IsNonspacingMark(cp) || IsSpacingCombiningMark(cp) || IsEnclosingMark(cp);
|
|
1355
|
+
}
|
|
1356
|
+
const RFC5892_DISALLOWED = new Set([
|
|
1357
|
+
1600,
|
|
1358
|
+
2042,
|
|
1359
|
+
12334,
|
|
1360
|
+
12335,
|
|
1361
|
+
12337,
|
|
1362
|
+
12338,
|
|
1363
|
+
12339,
|
|
1364
|
+
12340,
|
|
1365
|
+
12341,
|
|
1366
|
+
12347
|
|
1367
|
+
]);
|
|
1368
|
+
const VIRAMA_CPS = new Set([
|
|
1369
|
+
2381,
|
|
1370
|
+
2509,
|
|
1371
|
+
2637,
|
|
1372
|
+
2765,
|
|
1373
|
+
2893,
|
|
1374
|
+
3021,
|
|
1375
|
+
3149,
|
|
1376
|
+
3277,
|
|
1377
|
+
3387,
|
|
1378
|
+
3388,
|
|
1379
|
+
3405,
|
|
1380
|
+
3530,
|
|
1381
|
+
6980,
|
|
1382
|
+
7082,
|
|
1383
|
+
7083,
|
|
1384
|
+
43456,
|
|
1385
|
+
69702,
|
|
1386
|
+
69759,
|
|
1387
|
+
69817,
|
|
1388
|
+
69939,
|
|
1389
|
+
69940,
|
|
1390
|
+
70080,
|
|
1391
|
+
70197,
|
|
1392
|
+
70477,
|
|
1393
|
+
70722,
|
|
1394
|
+
70850,
|
|
1395
|
+
71103,
|
|
1396
|
+
71231,
|
|
1397
|
+
71350,
|
|
1398
|
+
72767,
|
|
1399
|
+
73028,
|
|
1400
|
+
73029
|
|
1401
|
+
]);
|
|
1402
|
+
function IsGreek(cp) {
|
|
1403
|
+
return /\p{Script=Greek}/u.test(String.fromCodePoint(cp));
|
|
1404
|
+
}
|
|
1405
|
+
function IsHebrew(cp) {
|
|
1406
|
+
return /\p{Script=Hebrew}/u.test(String.fromCodePoint(cp));
|
|
1407
|
+
}
|
|
1408
|
+
function IsHiragana(cp) {
|
|
1409
|
+
return /\p{Script=Hiragana}/u.test(String.fromCodePoint(cp));
|
|
1410
|
+
}
|
|
1411
|
+
function IsKatakana(cp) {
|
|
1412
|
+
return /\p{Script=Katakana}/u.test(String.fromCodePoint(cp));
|
|
1413
|
+
}
|
|
1414
|
+
function IsHan(cp) {
|
|
1415
|
+
return /\p{Script=Han}/u.test(String.fromCodePoint(cp));
|
|
1416
|
+
}
|
|
1417
|
+
function IsArabicIndicDigit(cp) {
|
|
1418
|
+
return cp >= 1632 && cp <= 1641;
|
|
1419
|
+
}
|
|
1420
|
+
function IsExtendedArabicIndicDigit(cp) {
|
|
1421
|
+
return cp >= 1776 && cp <= 1785;
|
|
1422
|
+
}
|
|
1423
|
+
function IsVirama(cp) {
|
|
1424
|
+
return VIRAMA_CPS.has(cp);
|
|
1425
|
+
}
|
|
1426
|
+
function IsUnicodeLabel(value) {
|
|
1427
|
+
if (value.length === 0) return false;
|
|
1428
|
+
const cps = [...value].map((c) => c.codePointAt(0));
|
|
1429
|
+
const len = cps.length;
|
|
1430
|
+
if (cps[0] === 45 || cps[len - 1] === 45) return false;
|
|
1431
|
+
if (len >= 4 && cps[2] === 45 && cps[3] === 45) return false;
|
|
1432
|
+
if (IsCombiningMark(cps[0])) return false;
|
|
1433
|
+
let hasJapanese = false;
|
|
1434
|
+
let hasArabicIndic = false;
|
|
1435
|
+
let hasExtendedArabicIndic = false;
|
|
1436
|
+
for (let i = 0; i < len; i++) {
|
|
1437
|
+
const cp = cps[i];
|
|
1438
|
+
if (RFC5892_DISALLOWED.has(cp)) return false;
|
|
1439
|
+
if (IsHiragana(cp) || IsKatakana(cp) || IsHan(cp)) hasJapanese = true;
|
|
1440
|
+
if (IsArabicIndicDigit(cp)) hasArabicIndic = true;
|
|
1441
|
+
if (IsExtendedArabicIndicDigit(cp)) hasExtendedArabicIndic = true;
|
|
1442
|
+
const prev = cps[i - 1], next = cps[i + 1];
|
|
1443
|
+
switch (cp) {
|
|
1444
|
+
case 183:
|
|
1445
|
+
if (prev !== 108 || next !== 108) return false;
|
|
1446
|
+
break;
|
|
1447
|
+
case 885:
|
|
1448
|
+
if (next === void 0 || !IsGreek(next)) return false;
|
|
1449
|
+
break;
|
|
1450
|
+
case 1523:
|
|
1451
|
+
case 1524:
|
|
1452
|
+
if (prev === void 0 || !IsHebrew(prev)) return false;
|
|
1453
|
+
break;
|
|
1454
|
+
case 8205:
|
|
1455
|
+
if (prev === void 0 || !IsVirama(prev)) return false;
|
|
1456
|
+
break;
|
|
1457
|
+
case 12539: break;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (value.includes("・") && !hasJapanese) return false;
|
|
1461
|
+
if (hasArabicIndic && hasExtendedArabicIndic) return false;
|
|
1462
|
+
return true;
|
|
1463
|
+
}
|
|
1464
|
+
function IsAsciiLabel(value) {
|
|
1465
|
+
if (value.charCodeAt(0) === 45 || value.charCodeAt(value.length - 1) === 45) return false;
|
|
1466
|
+
if (value.length >= 4 && value.charCodeAt(2) === 45 && value.charCodeAt(3) === 45) return false;
|
|
1467
|
+
for (let i = 0; i < value.length; i++) {
|
|
1468
|
+
const ch = value.charCodeAt(i);
|
|
1469
|
+
if (!(ch >= 97 && ch <= 122 || ch >= 65 && ch <= 90 || ch >= 48 && ch <= 57 || ch === 45)) return false;
|
|
1470
|
+
}
|
|
1471
|
+
return true;
|
|
1472
|
+
}
|
|
1473
|
+
function IsPuny(value) {
|
|
1474
|
+
return value.toLowerCase().startsWith("xn--");
|
|
1475
|
+
}
|
|
1476
|
+
function IsPunyLabel(value) {
|
|
1477
|
+
try {
|
|
1478
|
+
return IsUnicodeLabel(Decode(value.slice(4)));
|
|
1479
|
+
} catch {
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function IsIdnLabel(value) {
|
|
1484
|
+
if (value.length === 0 || value.length > 63) return false;
|
|
1485
|
+
return IsPuny(value) ? IsPunyLabel(value) : IsUnicodeLabel(value);
|
|
1486
|
+
}
|
|
1487
|
+
function IsLabel(value) {
|
|
1488
|
+
if (value.length === 0 || value.length > 63) return false;
|
|
1489
|
+
return IsPuny(value) ? IsPunyLabel(value) : IsAsciiLabel(value);
|
|
1490
|
+
}
|
|
1491
|
+
//#endregion
|
|
1492
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/hostname.mjs
|
|
1493
|
+
/**
|
|
1494
|
+
* Returns true if the value is a valid hostname.
|
|
1495
|
+
* @specification https://tools.ietf.org/html/rfc1123
|
|
1496
|
+
* @specification https://tools.ietf.org/html/rfc5891
|
|
1497
|
+
* @specification https://tools.ietf.org/html/rfc5892
|
|
1498
|
+
*/
|
|
1499
|
+
function IsHostname(value) {
|
|
1500
|
+
if (value.length === 0 || value.length > 253) return false;
|
|
1501
|
+
if (value.charCodeAt(value.length - 1) === 46) return false;
|
|
1502
|
+
for (const label of value.split(".")) if (!IsLabel(label)) return false;
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/idn_email.mjs
|
|
1507
|
+
const IdnEmail = /^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu;
|
|
1508
|
+
/**
|
|
1509
|
+
* Returns true if the value is an IdnEmail
|
|
1510
|
+
* @specification ajv-formats (unicode-extension)
|
|
1511
|
+
*/
|
|
1512
|
+
function IsIdnEmail(value) {
|
|
1513
|
+
return IdnEmail.test(value);
|
|
1514
|
+
}
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/idn_hostname.mjs
|
|
1517
|
+
/**
|
|
1518
|
+
* Returns true if the value is a valid internationalized (IDN) hostname.
|
|
1519
|
+
* @specification https://tools.ietf.org/html/rfc3490
|
|
1520
|
+
* @specification https://tools.ietf.org/html/rfc5891
|
|
1521
|
+
* @specification https://tools.ietf.org/html/rfc5892
|
|
1522
|
+
*/
|
|
1523
|
+
function IsIdnHostname(value) {
|
|
1524
|
+
if (value.length === 0 || value.includes(" ")) return false;
|
|
1525
|
+
const canonical = value.normalize("NFC").replace(/[\u002E\u3002\uFF0E\uFF61]/g, ".");
|
|
1526
|
+
if (canonical.length > 253) return false;
|
|
1527
|
+
for (const label of canonical.split(".")) if (!IsIdnLabel(label)) return false;
|
|
1528
|
+
return true;
|
|
1529
|
+
}
|
|
1530
|
+
//#endregion
|
|
1531
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/ipv4.mjs
|
|
1532
|
+
function IsIPv4Internal(value, start, end) {
|
|
1533
|
+
let dots = 0;
|
|
1534
|
+
let num = 0;
|
|
1535
|
+
let digits = 0;
|
|
1536
|
+
let leading = 0;
|
|
1537
|
+
for (let i = start; i < end; i++) {
|
|
1538
|
+
const ch = value.charCodeAt(i);
|
|
1539
|
+
if (ch === 46) {
|
|
1540
|
+
if (digits === 0 || num > 255 || leading === 48 && digits > 1) return false;
|
|
1541
|
+
dots++;
|
|
1542
|
+
num = 0;
|
|
1543
|
+
digits = 0;
|
|
1544
|
+
leading = 0;
|
|
1545
|
+
} else if (ch >= 48 && ch <= 57) {
|
|
1546
|
+
if (digits === 0) leading = ch;
|
|
1547
|
+
num = num * 10 + (ch - 48);
|
|
1548
|
+
digits++;
|
|
1549
|
+
} else return false;
|
|
1550
|
+
}
|
|
1551
|
+
return dots === 3 && digits > 0 && num <= 255 && !(leading === 48 && digits > 1);
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Returns true if the value is a IPV4 address
|
|
1555
|
+
* @specification http://tools.ietf.org/html/rfc2673#section-3.2
|
|
1556
|
+
*/
|
|
1557
|
+
function IsIPv4(value) {
|
|
1558
|
+
return IsIPv4Internal(value, 0, value.length);
|
|
1559
|
+
}
|
|
1560
|
+
//#endregion
|
|
1561
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/ipv6.mjs
|
|
1562
|
+
function InRange(ch) {
|
|
1563
|
+
return ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Returns true if the value is an IPv6 address
|
|
1567
|
+
* @specification http://tools.ietf.org/html/rfc2373#section-2.2
|
|
1568
|
+
*/
|
|
1569
|
+
function IsIPv6(value) {
|
|
1570
|
+
const length = value.length;
|
|
1571
|
+
if (length === 0) return false;
|
|
1572
|
+
let groups = 0;
|
|
1573
|
+
let compressed = false;
|
|
1574
|
+
let i = 0;
|
|
1575
|
+
if (value.charCodeAt(0) === 58 && value.charCodeAt(1) === 58) {
|
|
1576
|
+
if (length === 2) return true;
|
|
1577
|
+
compressed = true;
|
|
1578
|
+
i = 2;
|
|
1579
|
+
}
|
|
1580
|
+
while (i < length) {
|
|
1581
|
+
let digits = 0;
|
|
1582
|
+
const start = i;
|
|
1583
|
+
while (i < length && InRange(value.charCodeAt(i))) {
|
|
1584
|
+
i++;
|
|
1585
|
+
digits++;
|
|
1586
|
+
}
|
|
1587
|
+
if (digits === 0) return false;
|
|
1588
|
+
const next = value.charCodeAt(i);
|
|
1589
|
+
if (next === 46) {
|
|
1590
|
+
if (!IsIPv4Internal(value, start, length)) return false;
|
|
1591
|
+
groups += 2;
|
|
1592
|
+
i = length;
|
|
1593
|
+
break;
|
|
1594
|
+
}
|
|
1595
|
+
if (digits > 4) return false;
|
|
1596
|
+
groups++;
|
|
1597
|
+
if (i === length) break;
|
|
1598
|
+
if (next !== 58) return false;
|
|
1599
|
+
i++;
|
|
1600
|
+
if (value.charCodeAt(i) === 58) {
|
|
1601
|
+
if (compressed) return false;
|
|
1602
|
+
if (value.charCodeAt(i + 1) === 58) return false;
|
|
1603
|
+
compressed = true;
|
|
1604
|
+
i++;
|
|
1605
|
+
if (i === length) break;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
return compressed ? groups <= 7 : groups === 8;
|
|
1609
|
+
}
|
|
1610
|
+
//#endregion
|
|
1611
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/iri_reference.mjs
|
|
1612
|
+
function TryUrl(value) {
|
|
1613
|
+
try {
|
|
1614
|
+
new URL(value, "http://example.com");
|
|
1615
|
+
return true;
|
|
1616
|
+
} catch {
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Returns true if the value is a Iri reference
|
|
1622
|
+
* @specification
|
|
1623
|
+
*/
|
|
1624
|
+
function IsIriReference(value) {
|
|
1625
|
+
if (value.includes(" ")) return false;
|
|
1626
|
+
if (value.includes("\\")) return false;
|
|
1627
|
+
if (/[\x00-\x1F\x7F]/.test(value)) return false;
|
|
1628
|
+
if (/%(?![0-9a-fA-F]{2})/.test(value)) return false;
|
|
1629
|
+
if (value === "") return true;
|
|
1630
|
+
const colonIndex = value.indexOf(":");
|
|
1631
|
+
if (colonIndex > 0 && /^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(value.substring(0, colonIndex))) return TryUrl(value);
|
|
1632
|
+
else {
|
|
1633
|
+
if (value.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*)(\/\/)/) && colonIndex === -1) return false;
|
|
1634
|
+
return TryUrl(value);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
//#endregion
|
|
1638
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/iri.mjs
|
|
1639
|
+
/**
|
|
1640
|
+
* Returns true if the value is a Iri
|
|
1641
|
+
* @specification
|
|
1642
|
+
*/
|
|
1643
|
+
function IsIri(value) {
|
|
1644
|
+
try {
|
|
1645
|
+
new URL(value);
|
|
1646
|
+
return true;
|
|
1647
|
+
} catch {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
//#endregion
|
|
1652
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs
|
|
1653
|
+
const JsonPointerUriFragment = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
1654
|
+
/**
|
|
1655
|
+
* Returns true if the value is a json pointer uri fragment
|
|
1656
|
+
* @specification
|
|
1657
|
+
* @source ajv-formats
|
|
1658
|
+
*/
|
|
1659
|
+
function IsJsonPointerUriFragment(value) {
|
|
1660
|
+
return JsonPointerUriFragment.test(value);
|
|
1661
|
+
}
|
|
1662
|
+
//#endregion
|
|
1663
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/json_pointer.mjs
|
|
1664
|
+
const JsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
1665
|
+
/**
|
|
1666
|
+
* Returns true if the value is a json pointer
|
|
1667
|
+
* @specification
|
|
1668
|
+
* @source ajv-formats
|
|
1669
|
+
*/
|
|
1670
|
+
function IsJsonPointer(value) {
|
|
1671
|
+
return JsonPointer.test(value);
|
|
1672
|
+
}
|
|
1673
|
+
//#endregion
|
|
1674
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/regex.mjs
|
|
1675
|
+
/**
|
|
1676
|
+
* Returns true if the value is a regular expression string pattern
|
|
1677
|
+
* @specification
|
|
1678
|
+
* @source ajv-formats
|
|
1679
|
+
*/
|
|
1680
|
+
function IsRegex(value) {
|
|
1681
|
+
if (value.length === 0) return false;
|
|
1682
|
+
try {
|
|
1683
|
+
new RegExp(value);
|
|
1684
|
+
return true;
|
|
1685
|
+
} catch {
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
//#endregion
|
|
1690
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/relative_json_pointer.mjs
|
|
1691
|
+
const RelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
1692
|
+
/**
|
|
1693
|
+
* Returns true if the value is a relative json pointer
|
|
1694
|
+
* @specification
|
|
1695
|
+
* @source ajv-formats
|
|
1696
|
+
*/
|
|
1697
|
+
function IsRelativeJsonPointer(value) {
|
|
1698
|
+
return RelativeJsonPointer.test(value);
|
|
1699
|
+
}
|
|
1700
|
+
//#endregion
|
|
1701
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/uri_reference.mjs
|
|
1702
|
+
const UriReference = /^(?!.*[^\x00-\x7F])(?!.*\\)(?:(?:[a-z][a-z0-9+\-.]*:)?(?:\/\/[^\s[\]{}<>^`|]*)?|[^\s[\]{}<>^`|]*)(?:\?[^\s[\]{}<>^`|]*)?(?:#[^\s[\]{}<>^`|]*)?$/i;
|
|
1703
|
+
/**
|
|
1704
|
+
* Returns true if the value is a valid URI Reference.
|
|
1705
|
+
* @specification https://tools.ietf.org/html/rfc3986
|
|
1706
|
+
*/
|
|
1707
|
+
function IsUriReference(value) {
|
|
1708
|
+
return UriReference.test(value);
|
|
1709
|
+
}
|
|
1710
|
+
//#endregion
|
|
1711
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/uri_template.mjs
|
|
1712
|
+
const UriTemplate = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
|
1713
|
+
/**
|
|
1714
|
+
* Returns true if the value is a uri template
|
|
1715
|
+
* @specification
|
|
1716
|
+
* @source ajv-formats
|
|
1717
|
+
*/
|
|
1718
|
+
function IsUriTemplate(value) {
|
|
1719
|
+
return UriTemplate.test(value);
|
|
1720
|
+
}
|
|
1721
|
+
//#endregion
|
|
1722
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/uri.mjs
|
|
1723
|
+
function IsAlpha(ch) {
|
|
1724
|
+
return ch >= 97 && ch <= 122 || ch >= 65 && ch <= 90;
|
|
1725
|
+
}
|
|
1726
|
+
function IsAlphaNumeric(ch) {
|
|
1727
|
+
return IsAlpha(ch) || ch >= 48 && ch <= 57;
|
|
1728
|
+
}
|
|
1729
|
+
function IsHex(ch) {
|
|
1730
|
+
return ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
|
|
1731
|
+
}
|
|
1732
|
+
function IsSchemeChar(ch) {
|
|
1733
|
+
return IsAlphaNumeric(ch) || ch === 43 || ch === 45 || ch === 46;
|
|
1734
|
+
}
|
|
1735
|
+
function IsUnreserved(ch) {
|
|
1736
|
+
return IsAlphaNumeric(ch) || ch === 45 || ch === 46 || ch === 95 || ch === 126;
|
|
1737
|
+
}
|
|
1738
|
+
function IsSubDelim(ch) {
|
|
1739
|
+
return ch === 33 || ch === 36 || ch === 38 || ch === 39 || ch === 40 || ch === 41 || ch === 42 || ch === 43 || ch === 44 || ch === 59 || ch === 61;
|
|
1740
|
+
}
|
|
1741
|
+
function IsPchar(ch) {
|
|
1742
|
+
return IsUnreserved(ch) || IsSubDelim(ch) || ch === 58 || ch === 64;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Returns true if the value matches RFC 3986 URI syntax.
|
|
1746
|
+
* @specification https://tools.ietf.org/html/rfc3986
|
|
1747
|
+
*/
|
|
1748
|
+
function IsUri(value) {
|
|
1749
|
+
const length = value.length;
|
|
1750
|
+
if (length === 0) return false;
|
|
1751
|
+
if (!IsAlpha(value.charCodeAt(0))) return false;
|
|
1752
|
+
let i = 1;
|
|
1753
|
+
while (i < length) {
|
|
1754
|
+
const ch = value.charCodeAt(i);
|
|
1755
|
+
if (ch === 58) break;
|
|
1756
|
+
if (!IsSchemeChar(ch)) return false;
|
|
1757
|
+
i++;
|
|
1758
|
+
}
|
|
1759
|
+
if (value.charCodeAt(i) !== 58) return false;
|
|
1760
|
+
i++;
|
|
1761
|
+
if (value.charCodeAt(i) === 47 && value.charCodeAt(i + 1) === 47) {
|
|
1762
|
+
i += 2;
|
|
1763
|
+
const authorityStart = i;
|
|
1764
|
+
let atPos = -1;
|
|
1765
|
+
for (let j = i; j < length; j++) {
|
|
1766
|
+
const ch = value.charCodeAt(j);
|
|
1767
|
+
if (ch === 64) {
|
|
1768
|
+
atPos = j;
|
|
1769
|
+
break;
|
|
1770
|
+
}
|
|
1771
|
+
if (ch === 47 || ch === 63 || ch === 35) break;
|
|
1772
|
+
}
|
|
1773
|
+
if (atPos !== -1) {
|
|
1774
|
+
for (let j = authorityStart; j < atPos; j++) {
|
|
1775
|
+
const ch = value.charCodeAt(j);
|
|
1776
|
+
if (ch === 91 || ch === 93) return false;
|
|
1777
|
+
if (ch === 37) {
|
|
1778
|
+
if (j + 2 >= atPos || !IsHex(value.charCodeAt(j + 1)) || !IsHex(value.charCodeAt(j + 2))) return false;
|
|
1779
|
+
j += 2;
|
|
1780
|
+
} else if (!IsUnreserved(ch) && !IsSubDelim(ch) && ch !== 58) return false;
|
|
1781
|
+
}
|
|
1782
|
+
i = atPos + 1;
|
|
1783
|
+
}
|
|
1784
|
+
if (value.charCodeAt(i) === 91) {
|
|
1785
|
+
i++;
|
|
1786
|
+
while (i < length && value.charCodeAt(i) !== 93) i++;
|
|
1787
|
+
if (value.charCodeAt(i) !== 93) return false;
|
|
1788
|
+
i++;
|
|
1789
|
+
} else while (i < length) {
|
|
1790
|
+
const ch = value.charCodeAt(i);
|
|
1791
|
+
if (ch === 47 || ch === 63 || ch === 35 || ch === 58) break;
|
|
1792
|
+
if (ch < 128 && !IsUnreserved(ch) && !IsSubDelim(ch)) return false;
|
|
1793
|
+
i++;
|
|
1794
|
+
}
|
|
1795
|
+
if (value.charCodeAt(i) === 58) {
|
|
1796
|
+
i++;
|
|
1797
|
+
while (i < length) {
|
|
1798
|
+
const ch = value.charCodeAt(i);
|
|
1799
|
+
if (ch === 47 || ch === 63 || ch === 35) break;
|
|
1800
|
+
if (ch < 48 || ch > 57) return false;
|
|
1801
|
+
i++;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
while (i < length) {
|
|
1806
|
+
const ch = value.charCodeAt(i);
|
|
1807
|
+
if (ch === 37) {
|
|
1808
|
+
if (i + 2 >= length || !IsHex(value.charCodeAt(i + 1)) || !IsHex(value.charCodeAt(i + 2))) return false;
|
|
1809
|
+
i += 2;
|
|
1810
|
+
} else if (ch > 127) return false;
|
|
1811
|
+
else if (!(IsPchar(ch) || ch === 47 || ch === 63 || ch === 35)) return false;
|
|
1812
|
+
i++;
|
|
1813
|
+
}
|
|
1814
|
+
return true;
|
|
1815
|
+
}
|
|
1816
|
+
//#endregion
|
|
1817
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/url.mjs
|
|
1818
|
+
const 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;
|
|
1819
|
+
/**
|
|
1820
|
+
* Returns true if the value is a Url
|
|
1821
|
+
* @specification
|
|
1822
|
+
* @source ajv-formats
|
|
1823
|
+
*/
|
|
1824
|
+
function IsUrl(value) {
|
|
1825
|
+
return Url.test(value);
|
|
1826
|
+
}
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/uuid.mjs
|
|
1829
|
+
const Uuid = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
1830
|
+
/**
|
|
1831
|
+
* Returns true if the value is a uuid
|
|
1832
|
+
* @specification
|
|
1833
|
+
* @source ajv-formats
|
|
1834
|
+
*/
|
|
1835
|
+
function IsUuid(value) {
|
|
1836
|
+
return Uuid.test(value);
|
|
1837
|
+
}
|
|
1838
|
+
//#endregion
|
|
1839
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/format/_registry.mjs
|
|
1840
|
+
const formats = /* @__PURE__ */ new Map();
|
|
1841
|
+
/** Clears all entries */
|
|
1842
|
+
function Clear() {
|
|
1843
|
+
formats.clear();
|
|
1844
|
+
}
|
|
1845
|
+
/** Tests a value against a format, if the format is not registered, true */
|
|
1846
|
+
function Test(format, value) {
|
|
1847
|
+
return formats.get(format)?.(value) ?? true;
|
|
1848
|
+
}
|
|
1849
|
+
/** Resets all formats to defaults */
|
|
1850
|
+
function Reset() {
|
|
1851
|
+
Clear();
|
|
1852
|
+
formats.set("date-time", IsDateTime);
|
|
1853
|
+
formats.set("date", IsDate);
|
|
1854
|
+
formats.set("duration", IsDuration);
|
|
1855
|
+
formats.set("email", IsEmail);
|
|
1856
|
+
formats.set("hostname", IsHostname);
|
|
1857
|
+
formats.set("idn-email", IsIdnEmail);
|
|
1858
|
+
formats.set("idn-hostname", IsIdnHostname);
|
|
1859
|
+
formats.set("ipv4", IsIPv4);
|
|
1860
|
+
formats.set("ipv6", IsIPv6);
|
|
1861
|
+
formats.set("iri-reference", IsIriReference);
|
|
1862
|
+
formats.set("iri", IsIri);
|
|
1863
|
+
formats.set("json-pointer-uri-fragment", IsJsonPointerUriFragment);
|
|
1864
|
+
formats.set("json-pointer", IsJsonPointer);
|
|
1865
|
+
formats.set("regex", IsRegex);
|
|
1866
|
+
formats.set("relative-json-pointer", IsRelativeJsonPointer);
|
|
1867
|
+
formats.set("time", IsTime);
|
|
1868
|
+
formats.set("uri-reference", IsUriReference);
|
|
1869
|
+
formats.set("uri-template", IsUriTemplate);
|
|
1870
|
+
formats.set("uri", IsUri);
|
|
1871
|
+
formats.set("url", IsUrl);
|
|
1872
|
+
formats.set("uuid", IsUuid);
|
|
1873
|
+
}
|
|
1874
|
+
Reset();
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/format.mjs
|
|
1877
|
+
function CheckFormat(_stack, _context, schema, value) {
|
|
1878
|
+
return Test(schema.format, value);
|
|
1879
|
+
}
|
|
1880
|
+
function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
|
|
1881
|
+
return CheckFormat(stack, context, schema, value) || context.AddError({
|
|
1882
|
+
keyword: "format",
|
|
1883
|
+
schemaPath,
|
|
1884
|
+
instancePath,
|
|
1885
|
+
params: { format: schema.format }
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
//#endregion
|
|
1889
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/if.mjs
|
|
1890
|
+
function CheckIf(stack, context, schema, value) {
|
|
1891
|
+
const thenSchema = IsThen(schema) ? schema.then : true;
|
|
1892
|
+
const elseSchema = IsElse(schema) ? schema.else : true;
|
|
1893
|
+
return CheckSchema(stack, context, schema.if, value) ? CheckSchema(stack, context, thenSchema, value) : CheckSchema(stack, context, elseSchema, value);
|
|
1894
|
+
}
|
|
1895
|
+
function ErrorIf(stack, context, schemaPath, instancePath, schema, value) {
|
|
1896
|
+
const thenSchema = IsThen(schema) ? schema.then : true;
|
|
1897
|
+
const elseSchema = IsElse(schema) ? schema.else : true;
|
|
1898
|
+
const trueContext = new AccumulatedErrorContext();
|
|
1899
|
+
const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError({
|
|
1900
|
+
keyword: "if",
|
|
1901
|
+
schemaPath,
|
|
1902
|
+
instancePath,
|
|
1903
|
+
params: { failingKeyword: "then" }
|
|
1904
|
+
}) : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError({
|
|
1905
|
+
keyword: "if",
|
|
1906
|
+
schemaPath,
|
|
1907
|
+
instancePath,
|
|
1908
|
+
params: { failingKeyword: "else" }
|
|
1909
|
+
});
|
|
1910
|
+
if (isIf) context.Merge([trueContext]);
|
|
1911
|
+
return isIf;
|
|
1912
|
+
}
|
|
1913
|
+
//#endregion
|
|
1914
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/items.mjs
|
|
1915
|
+
function CheckItemsSized(stack, context, schema, value) {
|
|
1916
|
+
return Every(schema.items, 0, (schema, index) => {
|
|
1917
|
+
return IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context, schema, value[index]) && context.AddIndex(index);
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) {
|
|
1921
|
+
return EveryAll(schema.items, 0, (schema, index) => {
|
|
1922
|
+
const nextSchemaPath = `${schemaPath}/items/${index}`;
|
|
1923
|
+
const nextInstancePath = `${instancePath}/${index}`;
|
|
1924
|
+
return IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index);
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function CheckItemsUnsized(stack, context, schema, value) {
|
|
1928
|
+
return Every(value, IsPrefixItems(schema) ? schema.prefixItems.length : 0, (element, index) => {
|
|
1929
|
+
return CheckSchemaPushStack(stack, context, schema.items, element) && context.AddIndex(index);
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
function ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value) {
|
|
1933
|
+
return EveryAll(value, IsPrefixItems(schema) ? schema.prefixItems.length : 0, (element, index) => {
|
|
1934
|
+
return ErrorSchemaPushStack(stack, context, `${schemaPath}/items`, `${instancePath}/${index}`, schema.items, element) && context.AddIndex(index);
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
function CheckItems(stack, context, schema, value) {
|
|
1938
|
+
return IsItemsSized(schema) ? CheckItemsSized(stack, context, schema, value) : CheckItemsUnsized(stack, context, schema, value);
|
|
1939
|
+
}
|
|
1940
|
+
function ErrorItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
1941
|
+
return IsItemsSized(schema) ? ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value);
|
|
1942
|
+
}
|
|
1943
|
+
//#endregion
|
|
1944
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/maxContains.mjs
|
|
1945
|
+
function IsValid$2(schema) {
|
|
1946
|
+
return IsContains(schema);
|
|
1947
|
+
}
|
|
1948
|
+
function CheckMaxContains(stack, context, schema, value) {
|
|
1949
|
+
if (!IsValid$2(schema)) return true;
|
|
1950
|
+
return IsLessEqualThan(value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0), schema.maxContains);
|
|
1951
|
+
}
|
|
1952
|
+
function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
1953
|
+
const minContains = IsMinContains(schema) ? schema.minContains : 1;
|
|
1954
|
+
return CheckMaxContains(stack, context, schema, value) || context.AddError({
|
|
1955
|
+
keyword: "contains",
|
|
1956
|
+
schemaPath,
|
|
1957
|
+
instancePath,
|
|
1958
|
+
params: {
|
|
1959
|
+
minContains,
|
|
1960
|
+
maxContains: schema.maxContains
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
//#endregion
|
|
1965
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/maximum.mjs
|
|
1966
|
+
function CheckMaximum(_stack, _context, schema, value) {
|
|
1967
|
+
return IsLessEqualThan(value, schema.maximum);
|
|
1968
|
+
}
|
|
1969
|
+
function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
|
|
1970
|
+
return CheckMaximum(stack, context, schema, value) || context.AddError({
|
|
1971
|
+
keyword: "maximum",
|
|
1972
|
+
schemaPath,
|
|
1973
|
+
instancePath,
|
|
1974
|
+
params: {
|
|
1975
|
+
comparison: "<=",
|
|
1976
|
+
limit: schema.maximum
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
//#endregion
|
|
1981
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/maxItems.mjs
|
|
1982
|
+
function CheckMaxItems(_stack, _context, schema, value) {
|
|
1983
|
+
return IsLessEqualThan(value.length, schema.maxItems);
|
|
1984
|
+
}
|
|
1985
|
+
function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
1986
|
+
return CheckMaxItems(stack, context, schema, value) || context.AddError({
|
|
1987
|
+
keyword: "maxItems",
|
|
1988
|
+
schemaPath,
|
|
1989
|
+
instancePath,
|
|
1990
|
+
params: { limit: schema.maxItems }
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
//#endregion
|
|
1994
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/maxLength.mjs
|
|
1995
|
+
function CheckMaxLength(_stack, _context, schema, value) {
|
|
1996
|
+
return IsMaxLength$1(value, schema.maxLength);
|
|
1997
|
+
}
|
|
1998
|
+
function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value) {
|
|
1999
|
+
return CheckMaxLength(stack, context, schema, value) || context.AddError({
|
|
2000
|
+
keyword: "maxLength",
|
|
2001
|
+
schemaPath,
|
|
2002
|
+
instancePath,
|
|
2003
|
+
params: { limit: schema.maxLength }
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
//#endregion
|
|
2007
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/maxProperties.mjs
|
|
2008
|
+
function CheckMaxProperties(_stack, _context, schema, value) {
|
|
2009
|
+
return IsLessEqualThan(Keys(value).length, schema.maxProperties);
|
|
2010
|
+
}
|
|
2011
|
+
function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
2012
|
+
return CheckMaxProperties(stack, context, schema, value) || context.AddError({
|
|
2013
|
+
keyword: "maxProperties",
|
|
2014
|
+
schemaPath,
|
|
2015
|
+
instancePath,
|
|
2016
|
+
params: { limit: schema.maxProperties }
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
//#endregion
|
|
2020
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/minContains.mjs
|
|
2021
|
+
function IsValid$1(schema) {
|
|
2022
|
+
return IsContains(schema);
|
|
2023
|
+
}
|
|
2024
|
+
function CheckMinContains(stack, context, schema, value) {
|
|
2025
|
+
if (!IsValid$1(schema)) return true;
|
|
2026
|
+
return IsGreaterEqualThan(value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0), schema.minContains);
|
|
2027
|
+
}
|
|
2028
|
+
function ErrorMinContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
2029
|
+
return CheckMinContains(stack, context, schema, value) || context.AddError({
|
|
2030
|
+
keyword: "contains",
|
|
2031
|
+
schemaPath,
|
|
2032
|
+
instancePath,
|
|
2033
|
+
params: { minContains: schema.minContains }
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
//#endregion
|
|
2037
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/minimum.mjs
|
|
2038
|
+
function CheckMinimum(_stack, _context, schema, value) {
|
|
2039
|
+
return IsGreaterEqualThan(value, schema.minimum);
|
|
2040
|
+
}
|
|
2041
|
+
function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
|
|
2042
|
+
return CheckMinimum(stack, context, schema, value) || context.AddError({
|
|
2043
|
+
keyword: "minimum",
|
|
2044
|
+
schemaPath,
|
|
2045
|
+
instancePath,
|
|
2046
|
+
params: {
|
|
2047
|
+
comparison: ">=",
|
|
2048
|
+
limit: schema.minimum
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/minItems.mjs
|
|
2054
|
+
function CheckMinItems(_stack, _context, schema, value) {
|
|
2055
|
+
return IsGreaterEqualThan(value.length, schema.minItems);
|
|
2056
|
+
}
|
|
2057
|
+
function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
2058
|
+
return CheckMinItems(stack, context, schema, value) || context.AddError({
|
|
2059
|
+
keyword: "minItems",
|
|
2060
|
+
schemaPath,
|
|
2061
|
+
instancePath,
|
|
2062
|
+
params: { limit: schema.minItems }
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
//#endregion
|
|
2066
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/minLength.mjs
|
|
2067
|
+
function CheckMinLength(_stack, _context, schema, value) {
|
|
2068
|
+
return IsMinLength$1(value, schema.minLength);
|
|
2069
|
+
}
|
|
2070
|
+
function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value) {
|
|
2071
|
+
return CheckMinLength(stack, context, schema, value) || context.AddError({
|
|
2072
|
+
keyword: "minLength",
|
|
2073
|
+
schemaPath,
|
|
2074
|
+
instancePath,
|
|
2075
|
+
params: { limit: schema.minLength }
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
//#endregion
|
|
2079
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/minProperties.mjs
|
|
2080
|
+
function CheckMinProperties(_stack, _context, schema, value) {
|
|
2081
|
+
return IsGreaterEqualThan(Keys(value).length, schema.minProperties);
|
|
2082
|
+
}
|
|
2083
|
+
function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
2084
|
+
return CheckMinProperties(stack, context, schema, value) || context.AddError({
|
|
2085
|
+
keyword: "minProperties",
|
|
2086
|
+
schemaPath,
|
|
2087
|
+
instancePath,
|
|
2088
|
+
params: { limit: schema.minProperties }
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/multipleOf.mjs
|
|
2093
|
+
function CheckMultipleOf(_stack, _context, schema, value) {
|
|
2094
|
+
return IsMultipleOf$1(value, schema.multipleOf);
|
|
2095
|
+
}
|
|
2096
|
+
function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
2097
|
+
return CheckMultipleOf(stack, context, schema, value) || context.AddError({
|
|
2098
|
+
keyword: "multipleOf",
|
|
2099
|
+
schemaPath,
|
|
2100
|
+
instancePath,
|
|
2101
|
+
params: { multipleOf: schema.multipleOf }
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
//#endregion
|
|
2105
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/not.mjs
|
|
2106
|
+
function CheckNot(stack, context, schema, value) {
|
|
2107
|
+
const nextContext = new CheckContext();
|
|
2108
|
+
return !CheckSchema(stack, nextContext, schema.not, value) && context.Merge([nextContext]);
|
|
2109
|
+
}
|
|
2110
|
+
function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
|
|
2111
|
+
return CheckNot(stack, context, schema, value) || context.AddError({
|
|
2112
|
+
keyword: "not",
|
|
2113
|
+
schemaPath,
|
|
2114
|
+
instancePath,
|
|
2115
|
+
params: {}
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
//#endregion
|
|
2119
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/oneOf.mjs
|
|
2120
|
+
function CheckOneOf(stack, context, schema, value) {
|
|
2121
|
+
const passedContexts = schema.oneOf.reduce((result, schema) => {
|
|
2122
|
+
const nextContext = new CheckContext();
|
|
2123
|
+
return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
|
|
2124
|
+
}, []);
|
|
2125
|
+
return IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
|
|
2126
|
+
}
|
|
2127
|
+
function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
2128
|
+
const failedContexts = [];
|
|
2129
|
+
const passingSchemas = [];
|
|
2130
|
+
const passedContexts = schema.oneOf.reduce((result, schema, index) => {
|
|
2131
|
+
const nextContext = new AccumulatedErrorContext();
|
|
2132
|
+
const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/oneOf/${index}`, instancePath, schema, value);
|
|
2133
|
+
if (isSchema) passingSchemas.push(index);
|
|
2134
|
+
if (!isSchema) failedContexts.push(nextContext);
|
|
2135
|
+
return isSchema ? [...result, nextContext] : result;
|
|
2136
|
+
}, []);
|
|
2137
|
+
const isOneOf = IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
|
|
2138
|
+
if (!isOneOf && IsEqual(passingSchemas.length, 0)) failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
|
|
2139
|
+
return isOneOf || context.AddError({
|
|
2140
|
+
keyword: "oneOf",
|
|
2141
|
+
schemaPath,
|
|
2142
|
+
instancePath,
|
|
2143
|
+
params: { passingSchemas }
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/pattern.mjs
|
|
2148
|
+
function CheckPattern(_stack, _context, schema, value) {
|
|
2149
|
+
return (IsString$1(schema.pattern) ? new RegExp(schema.pattern, "u") : schema.pattern).test(value);
|
|
2150
|
+
}
|
|
2151
|
+
function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
|
|
2152
|
+
return CheckPattern(stack, context, schema, value) || context.AddError({
|
|
2153
|
+
keyword: "pattern",
|
|
2154
|
+
schemaPath,
|
|
2155
|
+
instancePath,
|
|
2156
|
+
params: { pattern: schema.pattern }
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
//#endregion
|
|
2160
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/patternProperties.mjs
|
|
2161
|
+
function CheckPatternProperties(stack, context, schema, value) {
|
|
2162
|
+
return Every(Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
2163
|
+
const regexp = new RegExp(pattern, "u");
|
|
2164
|
+
return Every(Entries(value), 0, ([key, prop]) => {
|
|
2165
|
+
return !regexp.test(key) || CheckSchemaPushStack(stack, context, schema, prop) && context.AddKey(key);
|
|
2166
|
+
});
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
2170
|
+
return EveryAll(Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
2171
|
+
const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
|
|
2172
|
+
const regexp = new RegExp(pattern, "u");
|
|
2173
|
+
return EveryAll(Entries(value), 0, ([key, value]) => {
|
|
2174
|
+
const nextInstancePath = `${instancePath}/${key}`;
|
|
2175
|
+
return !regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value) && context.AddKey(key);
|
|
2176
|
+
});
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
//#endregion
|
|
2180
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/prefixItems.mjs
|
|
2181
|
+
function CheckPrefixItems(stack, context, schema, value) {
|
|
2182
|
+
return IsEqual(value.length, 0) || Every(schema.prefixItems, 0, (schema, index) => {
|
|
2183
|
+
return IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context, schema, value[index]) && context.AddIndex(index);
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
function ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
2187
|
+
return IsEqual(value.length, 0) || EveryAll(schema.prefixItems, 0, (schema, index) => {
|
|
2188
|
+
const nextSchemaPath = `${schemaPath}/prefixItems/${index}`;
|
|
2189
|
+
const nextInstancePath = `${instancePath}/${index}`;
|
|
2190
|
+
return IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index);
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
//#endregion
|
|
2194
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/settings/settings.mjs
|
|
2195
|
+
const settings = {
|
|
2196
|
+
immutableTypes: false,
|
|
2197
|
+
maxErrors: 8,
|
|
2198
|
+
useAcceleration: true,
|
|
2199
|
+
exactOptionalPropertyTypes: false,
|
|
2200
|
+
enumerableKind: false,
|
|
2201
|
+
correctiveParse: false
|
|
2202
|
+
};
|
|
2203
|
+
/** Gets current system settings */
|
|
2204
|
+
function Get$2() {
|
|
2205
|
+
return settings;
|
|
2206
|
+
}
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/_exact_optional.mjs
|
|
2209
|
+
function IsExactOptional(required, key) {
|
|
2210
|
+
return required.includes(key) || Get$2().exactOptionalPropertyTypes;
|
|
2211
|
+
}
|
|
2212
|
+
function InexactOptionalCheck(value, key) {
|
|
2213
|
+
return IsUndefined(value[key]);
|
|
2214
|
+
}
|
|
2215
|
+
//#endregion
|
|
2216
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/properties.mjs
|
|
2217
|
+
function CheckProperties(stack, context, schema, value) {
|
|
2218
|
+
const required = IsRequired(schema) ? schema.required : [];
|
|
2219
|
+
return Every(Entries(schema.properties), 0, ([key, schema]) => {
|
|
2220
|
+
const isProperty = !HasPropertyKey(value, key) || CheckSchemaPushStack(stack, context, schema, value[key]) && context.AddKey(key);
|
|
2221
|
+
return IsExactOptional(required, key) ? isProperty : InexactOptionalCheck(value, key) || isProperty;
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
2225
|
+
const required = IsRequired(schema) ? schema.required : [];
|
|
2226
|
+
return EveryAll(Entries(schema.properties), 0, ([key, schema]) => {
|
|
2227
|
+
const nextSchemaPath = `${schemaPath}/properties/${key}`;
|
|
2228
|
+
const nextInstancePath = `${instancePath}/${key}`;
|
|
2229
|
+
const isProperty = () => !HasPropertyKey(value, key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[key]) && context.AddKey(key);
|
|
2230
|
+
return IsExactOptional(required, key) ? isProperty() : InexactOptionalCheck(value, key) || isProperty();
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
//#endregion
|
|
2234
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/propertyNames.mjs
|
|
2235
|
+
function CheckPropertyNames(stack, context, schema, value) {
|
|
2236
|
+
return Every(Keys(value), 0, (key, _index) => CheckSchema(stack, context, schema.propertyNames, key));
|
|
2237
|
+
}
|
|
2238
|
+
function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value) {
|
|
2239
|
+
const propertyNames = [];
|
|
2240
|
+
return EveryAll(Keys(value), 0, (key, _index) => {
|
|
2241
|
+
const nextInstancePath = `${instancePath}/${key}`;
|
|
2242
|
+
const nextSchemaPath = `${schemaPath}/propertyNames`;
|
|
2243
|
+
const isPropertyName = ErrorSchema(stack, new AccumulatedErrorContext(), nextSchemaPath, nextInstancePath, schema.propertyNames, key);
|
|
2244
|
+
if (!isPropertyName) propertyNames.push(key);
|
|
2245
|
+
return isPropertyName;
|
|
2246
|
+
}) || context.AddError({
|
|
2247
|
+
keyword: "propertyNames",
|
|
2248
|
+
schemaPath,
|
|
2249
|
+
instancePath,
|
|
2250
|
+
params: { propertyNames }
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
//#endregion
|
|
2254
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/recursiveRef.mjs
|
|
2255
|
+
function CheckRecursiveRef(stack, context, schema, value) {
|
|
2256
|
+
const target = stack.RecursiveRef(schema) ?? false;
|
|
2257
|
+
return IsSchema(target) && CheckSchema(stack, context, target, value);
|
|
2258
|
+
}
|
|
2259
|
+
function ErrorRecursiveRef(stack, context, _schemaPath, instancePath, schema, value) {
|
|
2260
|
+
const target = stack.RecursiveRef(schema) ?? false;
|
|
2261
|
+
return IsSchema(target) && ErrorSchema(stack, context, "#", instancePath, target, value);
|
|
2262
|
+
}
|
|
2263
|
+
//#endregion
|
|
2264
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/ref.mjs
|
|
2265
|
+
function CheckRef(stack, context, schema, value) {
|
|
2266
|
+
const target = stack.Ref(schema) ?? false;
|
|
2267
|
+
const nextContext = new CheckContext();
|
|
2268
|
+
const result = IsSchema(target) && CheckSchema(stack, nextContext, target, value);
|
|
2269
|
+
if (result) context.Merge([nextContext]);
|
|
2270
|
+
return result;
|
|
2271
|
+
}
|
|
2272
|
+
function ErrorRef(stack, context, _schemaPath, instancePath, schema, value) {
|
|
2273
|
+
const target = stack.Ref(schema) ?? false;
|
|
2274
|
+
const nextContext = new AccumulatedErrorContext();
|
|
2275
|
+
const result = IsSchema(target) && ErrorSchema(stack, nextContext, "#", instancePath, target, value);
|
|
2276
|
+
if (result) context.Merge([nextContext]);
|
|
2277
|
+
if (!result) nextContext.GetErrors().forEach((error) => context.AddError(error));
|
|
2278
|
+
return result;
|
|
2279
|
+
}
|
|
2280
|
+
//#endregion
|
|
2281
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/required.mjs
|
|
2282
|
+
function CheckRequired(_stack, _context, schema, value) {
|
|
2283
|
+
return Every(schema.required, 0, (key) => HasPropertyKey(value, key));
|
|
2284
|
+
}
|
|
2285
|
+
function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value) {
|
|
2286
|
+
const requiredProperties = [];
|
|
2287
|
+
return EveryAll(schema.required, 0, (key) => {
|
|
2288
|
+
const hasKey = HasPropertyKey(value, key);
|
|
2289
|
+
if (!hasKey) requiredProperties.push(key);
|
|
2290
|
+
return hasKey;
|
|
2291
|
+
}) || context.AddError({
|
|
2292
|
+
keyword: "required",
|
|
2293
|
+
schemaPath,
|
|
2294
|
+
instancePath,
|
|
2295
|
+
params: { requiredProperties }
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
//#endregion
|
|
2299
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/type.mjs
|
|
2300
|
+
function CheckTypeName(_stack, _context, type, _schema, value) {
|
|
2301
|
+
return IsEqual(type, "object") ? IsObjectNotArray(value) : IsEqual(type, "array") ? IsArray(value) : IsEqual(type, "boolean") ? IsBoolean$1(value) : IsEqual(type, "integer") ? IsInteger(value) : IsEqual(type, "number") ? IsNumber$1(value) : IsEqual(type, "null") ? IsNull(value) : IsEqual(type, "string") ? IsString$1(value) : IsEqual(type, "asyncIterator") ? IsAsyncIterator(value) : IsEqual(type, "bigint") ? IsBigInt(value) : IsEqual(type, "constructor") ? IsConstructor(value) : IsEqual(type, "function") ? IsFunction(value) : IsEqual(type, "iterator") ? IsIterator(value) : IsEqual(type, "symbol") ? IsSymbol(value) : IsEqual(type, "undefined") ? IsUndefined(value) : IsEqual(type, "void") ? IsUndefined(value) : true;
|
|
2302
|
+
}
|
|
2303
|
+
function CheckTypeNames(stack, context, types, schema, value) {
|
|
2304
|
+
return types.some((type) => CheckTypeName(stack, context, type, schema, value));
|
|
2305
|
+
}
|
|
2306
|
+
function CheckType(stack, context, schema, value) {
|
|
2307
|
+
return IsArray(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
|
|
2308
|
+
}
|
|
2309
|
+
function ErrorType(stack, context, schemaPath, instancePath, schema, value) {
|
|
2310
|
+
return (IsArray(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value)) || context.AddError({
|
|
2311
|
+
keyword: "type",
|
|
2312
|
+
schemaPath,
|
|
2313
|
+
instancePath,
|
|
2314
|
+
params: { type: schema.type }
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
//#endregion
|
|
2318
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs
|
|
2319
|
+
function CheckUnevaluatedItems(stack, context, schema, value) {
|
|
2320
|
+
const indices = context.GetIndices();
|
|
2321
|
+
return Every(value, 0, (item, index) => {
|
|
2322
|
+
return (indices.has(index) || CheckSchema(stack, context, schema.unevaluatedItems, item)) && context.AddIndex(index);
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
function ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
2326
|
+
const indices = context.GetIndices();
|
|
2327
|
+
const unevaluatedItems = [];
|
|
2328
|
+
return EveryAll(value, 0, (item, index) => {
|
|
2329
|
+
const nextContext = new AccumulatedErrorContext();
|
|
2330
|
+
const isEvaluatedItem = (indices.has(index) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedItems, item)) && context.AddIndex(index);
|
|
2331
|
+
if (!isEvaluatedItem) unevaluatedItems.push(index);
|
|
2332
|
+
return isEvaluatedItem;
|
|
2333
|
+
}) || context.AddError({
|
|
2334
|
+
keyword: "unevaluatedItems",
|
|
2335
|
+
schemaPath,
|
|
2336
|
+
instancePath,
|
|
2337
|
+
params: { unevaluatedItems }
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
//#endregion
|
|
2341
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs
|
|
2342
|
+
function CheckUnevaluatedProperties(stack, context, schema, value) {
|
|
2343
|
+
const keys = context.GetKeys();
|
|
2344
|
+
return Every(Entries(value), 0, ([key, prop]) => {
|
|
2345
|
+
return keys.has(key) || CheckSchema(stack, context, schema.unevaluatedProperties, prop) && context.AddKey(key);
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
function ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
2349
|
+
const keys = context.GetKeys();
|
|
2350
|
+
const unevaluatedProperties = [];
|
|
2351
|
+
return EveryAll(Entries(value), 0, ([key, prop]) => {
|
|
2352
|
+
const nextContext = new AccumulatedErrorContext();
|
|
2353
|
+
const isEvaluatedProperty = keys.has(key) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedProperties, prop) && context.AddKey(key);
|
|
2354
|
+
if (!isEvaluatedProperty) unevaluatedProperties.push(key);
|
|
2355
|
+
return isEvaluatedProperty;
|
|
2356
|
+
}) || context.AddError({
|
|
2357
|
+
keyword: "unevaluatedProperties",
|
|
2358
|
+
schemaPath,
|
|
2359
|
+
instancePath,
|
|
2360
|
+
params: { unevaluatedProperties }
|
|
2361
|
+
});
|
|
2362
|
+
}
|
|
2363
|
+
//#endregion
|
|
2364
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/uniqueItems.mjs
|
|
2365
|
+
function IsValid(schema) {
|
|
2366
|
+
return !IsEqual(schema.uniqueItems, false);
|
|
2367
|
+
}
|
|
2368
|
+
function CheckUniqueItems(_stack, _context, schema, value) {
|
|
2369
|
+
if (!IsValid(schema)) return true;
|
|
2370
|
+
const set = new Set(value.map(Hash)).size;
|
|
2371
|
+
const isLength = value.length;
|
|
2372
|
+
return IsEqual(set, isLength);
|
|
2373
|
+
}
|
|
2374
|
+
function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, value) {
|
|
2375
|
+
if (!IsValid(schema)) return true;
|
|
2376
|
+
const set = /* @__PURE__ */ new Set();
|
|
2377
|
+
const duplicateItems = value.reduce((result, value, index) => {
|
|
2378
|
+
const hash = Hash(value);
|
|
2379
|
+
if (set.has(hash)) return [...result, index];
|
|
2380
|
+
set.add(hash);
|
|
2381
|
+
return result;
|
|
2382
|
+
}, []);
|
|
2383
|
+
return IsEqual(duplicateItems.length, 0) || context.AddError({
|
|
2384
|
+
keyword: "uniqueItems",
|
|
2385
|
+
schemaPath,
|
|
2386
|
+
instancePath,
|
|
2387
|
+
params: { duplicateItems }
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
//#endregion
|
|
2391
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/schema.mjs
|
|
2392
|
+
function CheckSchemaPushStack(stack, context, schema, value) {
|
|
2393
|
+
return context.Push() && CheckSchema(stack, context, schema, value) && context.Pop();
|
|
2394
|
+
}
|
|
2395
|
+
function CheckSchema(stack, context, schema, value) {
|
|
2396
|
+
stack.Push(schema);
|
|
2397
|
+
const result = IsBooleanSchema(schema) ? CheckBooleanSchema(stack, context, schema, value) : (!IsType(schema) || CheckType(stack, context, schema, value)) && (!(IsObject(value) && !IsArray(value)) || (!IsRequired(schema) || CheckRequired(stack, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(stack, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(stack, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(stack, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(stack, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(stack, context, schema, value)) && (!IsProperties(schema) || CheckProperties(stack, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(stack, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(stack, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(stack, context, schema, value))) && (!IsArray(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(stack, context, schema, value)) && (!IsContains(schema) || CheckContains(stack, context, schema, value)) && (!IsItems(schema) || CheckItems(stack, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(stack, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(stack, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(stack, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(stack, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(stack, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(stack, context, schema, value))) && (!IsString$1(value) || (!IsMaxLength(schema) || CheckMaxLength(stack, context, schema, value)) && (!IsMinLength(schema) || CheckMinLength(stack, context, schema, value)) && (!IsFormat(schema) || CheckFormat(stack, context, schema, value)) && (!IsPattern(schema) || CheckPattern(stack, context, schema, value))) && (!(IsNumber$1(value) || IsBigInt(value)) || (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(stack, context, schema, value)) && (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(stack, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(stack, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(stack, context, schema, value)) && (!IsMultipleOf(schema) || CheckMultipleOf(stack, context, schema, value))) && (!IsRef(schema) || CheckRef(stack, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(stack, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(stack, context, schema, value)) && (!IsGuard(schema) || CheckGuard(stack, context, schema, value)) && (!IsConst(schema) || CheckConst(stack, context, schema, value)) && (!IsEnum(schema) || CheckEnum(stack, context, schema, value)) && (!IsIf(schema) || CheckIf(stack, context, schema, value)) && (!IsNot(schema) || CheckNot(stack, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(stack, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(stack, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(stack, context, schema, value)) && (!IsUnevaluatedItems(schema) || !IsArray(value) || CheckUnevaluatedItems(stack, context, schema, value)) && (!IsUnevaluatedProperties(schema) || !IsObject(value) || CheckUnevaluatedProperties(stack, context, schema, value)) && (!IsRefine(schema) || CheckRefine(stack, context, schema, value));
|
|
2398
|
+
stack.Pop(schema);
|
|
2399
|
+
return result;
|
|
2400
|
+
}
|
|
2401
|
+
function ErrorSchemaPushStack(stack, context, schemaPath, instancePath, schema, value) {
|
|
2402
|
+
return context.Push() && ErrorSchema(stack, context, schemaPath, instancePath, schema, value) && context.Pop();
|
|
2403
|
+
}
|
|
2404
|
+
function ErrorSchema(stack, context, schemaPath, instancePath, schema, value) {
|
|
2405
|
+
stack.Push(schema);
|
|
2406
|
+
const result = IsBooleanSchema(schema) ? ErrorBooleanSchema(stack, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(stack, context, schemaPath, instancePath, schema, value)) & +(!(IsObject(value) && !IsArray(value)) || !!(+(!IsRequired(schema) || ErrorRequired(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value)))) & +(!IsArray(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(stack, context, schemaPath, instancePath, schema, value)))) & +(!IsString$1(value) || !!(+(!IsMaxLength(schema) || ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinLength(schema) || ErrorMinLength(stack, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(stack, context, schemaPath, instancePath, schema, value)))) & +(!(IsNumber$1(value) || IsBigInt(value)) || !!(+(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf(schema) || ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value)))) & +(!IsRef(schema) || ErrorRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsGuard(schema) || ErrorGuard(stack, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(stack, context, schemaPath, instancePath, schema, value)) & +(!IsEnum(schema) || ErrorEnum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || !IsArray(value) || ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedProperties(schema) || !IsObject(value) || ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, schema, value))) && (!IsRefine(schema) || ErrorRefine(stack, context, schemaPath, instancePath, schema, value));
|
|
2407
|
+
stack.Pop(schema);
|
|
2408
|
+
return result;
|
|
2409
|
+
}
|
|
2410
|
+
//#endregion
|
|
2411
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/pointer/pointer.mjs
|
|
2412
|
+
function GetIndex(index, value) {
|
|
2413
|
+
return IsObject(value) && !IsUnsafePropertyKey(index) ? value[index] : void 0;
|
|
2414
|
+
}
|
|
2415
|
+
function GetIndices(indices, value) {
|
|
2416
|
+
return indices.reduce((value, index) => GetIndex(index, value), value);
|
|
2417
|
+
}
|
|
2418
|
+
/** Returns an array of path indices for the given pointer */
|
|
2419
|
+
function Indices(pointer) {
|
|
2420
|
+
if (IsEqual(pointer.length, 0)) return [];
|
|
2421
|
+
const indices = pointer.split("/").map((index) => index.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
2422
|
+
return indices.length > 0 && indices[0] === "" ? indices.slice(1) : indices;
|
|
2423
|
+
}
|
|
2424
|
+
/** Gets a value at the pointer, or undefined if not exists */
|
|
2425
|
+
function Get$1(value, pointer) {
|
|
2426
|
+
return GetIndices(Indices(pointer), value);
|
|
2427
|
+
}
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/resolve/ref.mjs
|
|
2430
|
+
function MatchId(schema, base, ref) {
|
|
2431
|
+
if (schema.$id === ref.hash) return schema;
|
|
2432
|
+
const absoluteId = new URL(schema.$id, base.href);
|
|
2433
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
2434
|
+
if (IsEqual(absoluteId.pathname, absoluteRef.pathname)) return ref.hash.startsWith("#") ? MatchHash(schema, base, ref) : schema;
|
|
2435
|
+
}
|
|
2436
|
+
function MatchAnchor(schema, base, ref) {
|
|
2437
|
+
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
2438
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
2439
|
+
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
2440
|
+
}
|
|
2441
|
+
function MatchDynamicAnchor(schema, base, ref) {
|
|
2442
|
+
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
2443
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
2444
|
+
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
2445
|
+
}
|
|
2446
|
+
function MatchHash(schema, _base, ref) {
|
|
2447
|
+
if (ref.href.endsWith("#")) return schema;
|
|
2448
|
+
if (!ref.hash.startsWith("#")) return void 0;
|
|
2449
|
+
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
2450
|
+
if (!fragment.startsWith("/")) return void 0;
|
|
2451
|
+
return Get$1(schema, fragment);
|
|
2452
|
+
}
|
|
2453
|
+
function Match$1(schema, base, ref) {
|
|
2454
|
+
if (IsId(schema)) {
|
|
2455
|
+
const result = MatchId(schema, base, ref);
|
|
2456
|
+
if (!IsUndefined(result)) return result;
|
|
2457
|
+
}
|
|
2458
|
+
if (IsAnchor(schema)) {
|
|
2459
|
+
const result = MatchAnchor(schema, base, ref);
|
|
2460
|
+
if (!IsUndefined(result)) return result;
|
|
2461
|
+
}
|
|
2462
|
+
if (IsDynamicAnchor(schema)) {
|
|
2463
|
+
const result = MatchDynamicAnchor(schema, base, ref);
|
|
2464
|
+
if (!IsUndefined(result)) return result;
|
|
2465
|
+
}
|
|
2466
|
+
return MatchHash(schema, base, ref);
|
|
2467
|
+
}
|
|
2468
|
+
function FromArray(schema, base, ref) {
|
|
2469
|
+
return schema.reduce((result, item) => {
|
|
2470
|
+
const match = FromValue(item, base, ref);
|
|
2471
|
+
return !IsUndefined(match) ? match : result;
|
|
2472
|
+
}, void 0);
|
|
2473
|
+
}
|
|
2474
|
+
function FromObject(schema, base, ref) {
|
|
2475
|
+
return Keys(schema).reduce((result, key) => {
|
|
2476
|
+
const match = FromValue(schema[key], base, ref);
|
|
2477
|
+
return !IsUndefined(match) ? match : result;
|
|
2478
|
+
}, void 0);
|
|
2479
|
+
}
|
|
2480
|
+
function FromValue(schema, base, ref) {
|
|
2481
|
+
const nextBase = IsSchemaObject(schema) && IsId(schema) ? new URL(schema.$id, base.href) : base;
|
|
2482
|
+
if (IsSchemaObject(schema)) {
|
|
2483
|
+
const result = Match$1(schema, nextBase, ref);
|
|
2484
|
+
if (!IsUndefined(result)) return result;
|
|
2485
|
+
}
|
|
2486
|
+
if (IsArray(schema)) return FromArray(schema, nextBase, ref);
|
|
2487
|
+
if (IsObject(schema)) return FromObject(schema, nextBase, ref);
|
|
2488
|
+
}
|
|
2489
|
+
function Ref(schema, ref) {
|
|
2490
|
+
const defaultBase = new URL("http://unknown/");
|
|
2491
|
+
const initialBase = IsId(schema) ? new URL(schema.$id, defaultBase.href) : defaultBase;
|
|
2492
|
+
return FromValue(schema, initialBase, new URL(ref, initialBase.href));
|
|
2493
|
+
}
|
|
2494
|
+
function DynamicRef(root, base, dynamicRef, dynamicAnchors) {
|
|
2495
|
+
const fragmentTarget = dynamicRef.$dynamicRef.startsWith("#") ? Ref(base, dynamicRef.$dynamicRef) : Ref(root, dynamicRef.$dynamicRef);
|
|
2496
|
+
if (IsUndefined(fragmentTarget)) return void 0;
|
|
2497
|
+
if (!IsSchemaObject(fragmentTarget) || !IsDynamicAnchor(fragmentTarget)) return fragmentTarget;
|
|
2498
|
+
if (new URL(dynamicRef.$dynamicRef, "http://unknown/").hash.startsWith("#/")) return fragmentTarget;
|
|
2499
|
+
return dynamicAnchors.find((anchor) => anchor.$dynamicAnchor === fragmentTarget.$dynamicAnchor) ?? fragmentTarget;
|
|
2500
|
+
}
|
|
2501
|
+
//#endregion
|
|
2502
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/engine/_stack.mjs
|
|
2503
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
2504
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
2505
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2506
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2507
|
+
};
|
|
2508
|
+
var _Stack_instances, _Stack_PushResourceAnchors, _Stack_PopResourceAnchors, _Stack_FromContext, _Stack_FromRef;
|
|
2509
|
+
var Stack = class {
|
|
2510
|
+
constructor(context, schema) {
|
|
2511
|
+
_Stack_instances.add(this);
|
|
2512
|
+
this.context = context;
|
|
2513
|
+
this.schema = schema;
|
|
2514
|
+
this.ids = [];
|
|
2515
|
+
this.anchors = [];
|
|
2516
|
+
this.recursiveAnchors = [];
|
|
2517
|
+
this.dynamicAnchors = [];
|
|
2518
|
+
}
|
|
2519
|
+
BaseURL() {
|
|
2520
|
+
return this.ids.reduce((result, schema) => new URL(schema.$id, result), new URL("http://unknown"));
|
|
2521
|
+
}
|
|
2522
|
+
Base() {
|
|
2523
|
+
return this.ids[this.ids.length - 1] ?? this.schema;
|
|
2524
|
+
}
|
|
2525
|
+
Push(schema) {
|
|
2526
|
+
if (!IsSchemaObject(schema)) return;
|
|
2527
|
+
if (IsId(schema)) {
|
|
2528
|
+
this.ids.push(schema);
|
|
2529
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PushResourceAnchors).call(this, schema);
|
|
2530
|
+
}
|
|
2531
|
+
if (IsAnchor(schema)) this.anchors.push(schema);
|
|
2532
|
+
if (IsRecursiveAnchorTrue(schema)) this.recursiveAnchors.push(schema);
|
|
2533
|
+
if (IsDynamicAnchor(schema)) this.dynamicAnchors.push(schema);
|
|
2534
|
+
}
|
|
2535
|
+
Pop(schema) {
|
|
2536
|
+
if (!IsSchemaObject(schema)) return;
|
|
2537
|
+
if (IsId(schema)) {
|
|
2538
|
+
this.ids.pop();
|
|
2539
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PopResourceAnchors).call(this, schema);
|
|
2540
|
+
}
|
|
2541
|
+
if (IsAnchor(schema)) this.anchors.pop();
|
|
2542
|
+
if (IsRecursiveAnchorTrue(schema)) this.recursiveAnchors.pop();
|
|
2543
|
+
if (IsDynamicAnchor(schema)) this.dynamicAnchors.pop();
|
|
2544
|
+
}
|
|
2545
|
+
Ref(ref) {
|
|
2546
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_FromContext).call(this, ref) ?? __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_FromRef).call(this, ref);
|
|
2547
|
+
}
|
|
2548
|
+
RecursiveRef(recursiveRef) {
|
|
2549
|
+
return IsRecursiveAnchorTrue(this.Base()) ? Ref(this.recursiveAnchors[0], recursiveRef.$recursiveRef) : Ref(this.Base(), recursiveRef.$recursiveRef);
|
|
2550
|
+
}
|
|
2551
|
+
DynamicRef(dynamicRef) {
|
|
2552
|
+
const root = this.schema;
|
|
2553
|
+
return DynamicRef(root, this.Base(), dynamicRef, this.dynamicAnchors);
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
_Stack_instances = /* @__PURE__ */ new WeakSet(), _Stack_PushResourceAnchors = function _Stack_PushResourceAnchors(schema, isRoot = true) {
|
|
2557
|
+
if (!IsSchemaObject(schema)) return;
|
|
2558
|
+
const current = schema;
|
|
2559
|
+
if (!isRoot && IsId(current)) return;
|
|
2560
|
+
if (!isRoot && IsDynamicAnchor(current)) this.dynamicAnchors.push(current);
|
|
2561
|
+
for (const key of Keys(current)) __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PushResourceAnchors).call(this, current[key], false);
|
|
2562
|
+
}, _Stack_PopResourceAnchors = function _Stack_PopResourceAnchors(schema, isRoot = true) {
|
|
2563
|
+
if (!IsSchemaObject(schema)) return;
|
|
2564
|
+
const current = schema;
|
|
2565
|
+
if (!isRoot && IsId(current)) return;
|
|
2566
|
+
if (!isRoot && IsDynamicAnchor(current)) this.dynamicAnchors.pop();
|
|
2567
|
+
for (const key of Keys(current)) __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PopResourceAnchors).call(this, current[key], false);
|
|
2568
|
+
}, _Stack_FromContext = function _Stack_FromContext(ref) {
|
|
2569
|
+
return HasPropertyKey(this.context, ref.$ref) ? this.context[ref.$ref] : void 0;
|
|
2570
|
+
}, _Stack_FromRef = function _Stack_FromRef(ref) {
|
|
2571
|
+
const root = this.schema;
|
|
2572
|
+
return !ref.$ref.startsWith("#") ? Ref(root, ref.$ref) : Ref(this.Base(), ref.$ref);
|
|
2573
|
+
};
|
|
2574
|
+
//#endregion
|
|
2575
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/arguments/arguments.mjs
|
|
2576
|
+
/**
|
|
2577
|
+
* Match arguments for overloaded functions that use the `...args: unknown[]` pattern. Arguments
|
|
2578
|
+
* are parsed using argument length only.
|
|
2579
|
+
*/
|
|
2580
|
+
function Match(args, match) {
|
|
2581
|
+
return match[args.length]?.(...args) ?? (() => {
|
|
2582
|
+
throw Error("Invalid Arguments");
|
|
2583
|
+
})();
|
|
2584
|
+
}
|
|
2585
|
+
//#endregion
|
|
2586
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/locale/en_US.mjs
|
|
2587
|
+
/** en_US: English (United States) - ISO 639-1 language code 'en' with ISO 3166-1 alpha-2 country code 'US' for United States. */
|
|
2588
|
+
function en_US(error) {
|
|
2589
|
+
switch (error.keyword) {
|
|
2590
|
+
case "additionalProperties": return "must not have additional properties";
|
|
2591
|
+
case "anyOf": return "must match a schema in anyOf";
|
|
2592
|
+
case "boolean": return "schema is false";
|
|
2593
|
+
case "const": return "must be equal to constant";
|
|
2594
|
+
case "contains": return "must contain at least 1 valid item";
|
|
2595
|
+
case "dependencies": return `must have properties ${error.params.dependencies.join(", ")} when property ${error.params.property} is present`;
|
|
2596
|
+
case "dependentRequired": return `must have properties ${error.params.dependencies.join(", ")} when property ${error.params.property} is present`;
|
|
2597
|
+
case "enum": return "must be equal to one of the allowed values";
|
|
2598
|
+
case "exclusiveMaximum": return `must be ${error.params.comparison} ${error.params.limit}`;
|
|
2599
|
+
case "exclusiveMinimum": return `must be ${error.params.comparison} ${error.params.limit}`;
|
|
2600
|
+
case "format": return `must match format "${error.params.format}"`;
|
|
2601
|
+
case "if": return `must match "${error.params.failingKeyword}" schema`;
|
|
2602
|
+
case "maxItems": return `must not have more than ${error.params.limit} items`;
|
|
2603
|
+
case "maxLength": return `must not have more than ${error.params.limit} characters`;
|
|
2604
|
+
case "maxProperties": return `must not have more than ${error.params.limit} properties`;
|
|
2605
|
+
case "maximum": return `must be ${error.params.comparison} ${error.params.limit}`;
|
|
2606
|
+
case "minItems": return `must not have fewer than ${error.params.limit} items`;
|
|
2607
|
+
case "minLength": return `must not have fewer than ${error.params.limit} characters`;
|
|
2608
|
+
case "minProperties": return `must not have fewer than ${error.params.limit} properties`;
|
|
2609
|
+
case "minimum": return `must be ${error.params.comparison} ${error.params.limit}`;
|
|
2610
|
+
case "multipleOf": return `must be multiple of ${error.params.multipleOf}`;
|
|
2611
|
+
case "not": return "must not be valid";
|
|
2612
|
+
case "oneOf": return "must match exactly one schema in oneOf";
|
|
2613
|
+
case "pattern": return `must match pattern "${error.params.pattern}"`;
|
|
2614
|
+
case "propertyNames": return `property names ${error.params.propertyNames.join(", ")} are invalid`;
|
|
2615
|
+
case "required": return `must have required properties ${error.params.requiredProperties.join(", ")}`;
|
|
2616
|
+
case "type": return typeof error.params.type === "string" ? `must be ${error.params.type}` : `must be either ${error.params.type.join(" or ")}`;
|
|
2617
|
+
case "unevaluatedItems": return "must not have unevaluated items";
|
|
2618
|
+
case "unevaluatedProperties": return "must not have unevaluated properties";
|
|
2619
|
+
case "uniqueItems": return `must not have duplicate items`;
|
|
2620
|
+
case "~guard": return `must match check function`;
|
|
2621
|
+
case "~refine": return error.params.message;
|
|
2622
|
+
default: return "an unknown validation error occurred";
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
//#endregion
|
|
2626
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/locale/_config.mjs
|
|
2627
|
+
let locale = en_US;
|
|
2628
|
+
/** Gets the locale */
|
|
2629
|
+
function Get() {
|
|
2630
|
+
return locale;
|
|
2631
|
+
}
|
|
2632
|
+
//#endregion
|
|
2633
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/errors.mjs
|
|
2634
|
+
/** Checks a value and returns validation errors */
|
|
2635
|
+
function Errors(...args) {
|
|
2636
|
+
const [context, schema, value] = Match(args, {
|
|
2637
|
+
3: (context, schema, value) => [
|
|
2638
|
+
context,
|
|
2639
|
+
schema,
|
|
2640
|
+
value
|
|
2641
|
+
],
|
|
2642
|
+
2: (schema, value) => [
|
|
2643
|
+
{},
|
|
2644
|
+
schema,
|
|
2645
|
+
value
|
|
2646
|
+
]
|
|
2647
|
+
});
|
|
2648
|
+
const settings = Get$2();
|
|
2649
|
+
const locale = Get();
|
|
2650
|
+
const errors = [];
|
|
2651
|
+
return [ErrorSchema(new Stack(context, schema), new ErrorContext((error) => {
|
|
2652
|
+
if (IsGreaterEqualThan(errors.length, settings.maxErrors)) return;
|
|
2653
|
+
return errors.push({
|
|
2654
|
+
...error,
|
|
2655
|
+
message: locale(error)
|
|
2656
|
+
});
|
|
2657
|
+
}), "#", "", schema, value), errors];
|
|
2658
|
+
}
|
|
2659
|
+
//#endregion
|
|
2660
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/check.mjs
|
|
2661
|
+
/** Checks a value against the provided schema */
|
|
2662
|
+
function Check(...args) {
|
|
2663
|
+
const [context, schema, value] = Match(args, {
|
|
2664
|
+
3: (context, schema, value) => [
|
|
2665
|
+
context,
|
|
2666
|
+
schema,
|
|
2667
|
+
value
|
|
2668
|
+
],
|
|
2669
|
+
2: (schema, value) => [
|
|
2670
|
+
{},
|
|
2671
|
+
schema,
|
|
2672
|
+
value
|
|
2673
|
+
]
|
|
2674
|
+
});
|
|
2675
|
+
return CheckSchema(new Stack(context, schema), new CheckContext(), schema, value);
|
|
2676
|
+
}
|
|
2677
|
+
//#endregion
|
|
2678
|
+
//#region node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/parse.mjs
|
|
2679
|
+
var ParseError = class {
|
|
2680
|
+
constructor(schema, value, errors) {
|
|
2681
|
+
this.schema = schema;
|
|
2682
|
+
this.value = value;
|
|
2683
|
+
this.errors = errors;
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
/** Parses a value against the provided schema */
|
|
2687
|
+
function Parse(...args) {
|
|
2688
|
+
const [context, schema, value] = Match(args, {
|
|
2689
|
+
3: (context, schema, value) => [
|
|
2690
|
+
context,
|
|
2691
|
+
schema,
|
|
2692
|
+
value
|
|
2693
|
+
],
|
|
2694
|
+
2: (schema, value) => [
|
|
2695
|
+
{},
|
|
2696
|
+
schema,
|
|
2697
|
+
value
|
|
2698
|
+
]
|
|
2699
|
+
});
|
|
2700
|
+
if (!Check(context, schema, value)) {
|
|
2701
|
+
const [_result, errors] = Errors(context, schema, value);
|
|
2702
|
+
throw new ParseError(schema, value, errors);
|
|
2703
|
+
}
|
|
2704
|
+
return value;
|
|
2705
|
+
}
|
|
2706
|
+
const configDefaults = {
|
|
2707
|
+
enabled: true,
|
|
2708
|
+
quiet: false,
|
|
2709
|
+
toolName: "set_reasoning_effort",
|
|
2710
|
+
toolDescription: "Set your reasoning effort",
|
|
2711
|
+
systemPrompt: "You MUST manage reasoning effort actively. Lower it before trivial or routine turns; raise it for ambiguity, debugging, risky changes, or multi-step synthesis. Reassess at turn start, after meaningful new evidence, and when the task shifts. NEVER leave the current level unchanged by inertia, and NEVER reply to a trivial turn before considering a downshift."
|
|
2712
|
+
};
|
|
2713
|
+
const ConfigSchema = Type.Object({
|
|
2714
|
+
enabled: Type.Boolean(),
|
|
2715
|
+
quiet: Type.Boolean(),
|
|
2716
|
+
toolName: Type.String({ minLength: 1 }),
|
|
2717
|
+
toolDescription: Type.String({ minLength: 1 }),
|
|
2718
|
+
systemPrompt: Type.String({ minLength: 1 })
|
|
2719
|
+
}, { additionalProperties: false });
|
|
2720
|
+
const parseConfig = (input) => {
|
|
2721
|
+
return Parse(ConfigSchema, input === void 0 ? configDefaults : {
|
|
2722
|
+
...configDefaults,
|
|
2723
|
+
...input
|
|
2724
|
+
});
|
|
2725
|
+
};
|
|
2726
|
+
//#endregion
|
|
2727
|
+
//#region src/config-loader.ts
|
|
2728
|
+
const hasCode = (error, code) => {
|
|
2729
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2730
|
+
};
|
|
2731
|
+
const errorMessage$1 = (error) => error instanceof Error ? error.message : String(error);
|
|
2732
|
+
const invalidConfig = (source, error) => ({
|
|
2733
|
+
success: false,
|
|
2734
|
+
source,
|
|
2735
|
+
error: /* @__PURE__ */ new Error(`Invalid Adaptive Thinking configuration in ${source}: ${errorMessage$1(error)}`)
|
|
2736
|
+
});
|
|
2737
|
+
const loadConfig = async ({ cwd, homeDir = homedir() }) => {
|
|
2738
|
+
const candidates = [join(cwd, ".pi", "adaptive-thinking.json"), join(homeDir, ".pi", "agent", "adaptive-thinking.json")];
|
|
2739
|
+
for (const source of candidates) {
|
|
2740
|
+
let raw;
|
|
2741
|
+
try {
|
|
2742
|
+
raw = await readFile(source, "utf8");
|
|
2743
|
+
} catch (error) {
|
|
2744
|
+
if (hasCode(error, "ENOENT")) continue;
|
|
2745
|
+
return invalidConfig(source, error);
|
|
2746
|
+
}
|
|
2747
|
+
try {
|
|
2748
|
+
return {
|
|
2749
|
+
success: true,
|
|
2750
|
+
source,
|
|
2751
|
+
config: parseConfig(JSON.parse(raw))
|
|
2752
|
+
};
|
|
2753
|
+
} catch (error) {
|
|
2754
|
+
return invalidConfig(source, error);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
return {
|
|
2758
|
+
success: true,
|
|
2759
|
+
config: parseConfig(void 0)
|
|
2760
|
+
};
|
|
2761
|
+
};
|
|
2762
|
+
//#endregion
|
|
2763
|
+
//#region src/thinking-levels.ts
|
|
2764
|
+
const fallbackThinkingLevels = [
|
|
2765
|
+
"off",
|
|
2766
|
+
"minimal",
|
|
2767
|
+
"low",
|
|
2768
|
+
"medium",
|
|
2769
|
+
"high",
|
|
2770
|
+
"xhigh"
|
|
2771
|
+
];
|
|
2772
|
+
const levelSet = new Set(fallbackThinkingLevels);
|
|
2773
|
+
const isThinkingLevel = (level) => levelSet.has(level);
|
|
2774
|
+
const resolveSupportedThinkingLevels = (model) => {
|
|
2775
|
+
if (!model) return [...fallbackThinkingLevels];
|
|
2776
|
+
return getSupportedThinkingLevels(model).filter((level) => isThinkingLevel(level));
|
|
2777
|
+
};
|
|
2778
|
+
//#endregion
|
|
2779
|
+
//#region src/index.ts
|
|
2780
|
+
const ToolParameters = Type.Object({
|
|
2781
|
+
level: Type.String({
|
|
2782
|
+
minLength: 1,
|
|
2783
|
+
description: "The level of reasoning effort to apply. Higher levels may improve hard-task quality but may take more time and resources."
|
|
2784
|
+
}),
|
|
2785
|
+
persist: Type.Optional(Type.Boolean({
|
|
2786
|
+
default: false,
|
|
2787
|
+
description: "Whether to persist the setting for this session; otherwise it applies only for the current turn."
|
|
2788
|
+
}))
|
|
2789
|
+
}, { additionalProperties: false });
|
|
2790
|
+
const textResult = (text) => ({
|
|
2791
|
+
content: [{
|
|
2792
|
+
type: "text",
|
|
2793
|
+
text
|
|
2794
|
+
}],
|
|
2795
|
+
details: void 0
|
|
2796
|
+
});
|
|
2797
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
2798
|
+
const notify = (ctx, type, message, config) => {
|
|
2799
|
+
if (config?.quiet) return;
|
|
2800
|
+
if (!ctx.hasUI) return;
|
|
2801
|
+
ctx.ui.notify(message, type);
|
|
2802
|
+
};
|
|
2803
|
+
const appendSystemPromptBlock = (systemPrompt, block) => {
|
|
2804
|
+
const trimmedBlock = block.trim();
|
|
2805
|
+
if (!trimmedBlock) return systemPrompt;
|
|
2806
|
+
if (!systemPrompt.trim()) return trimmedBlock;
|
|
2807
|
+
return `${systemPrompt.trimEnd()}\n\n${trimmedBlock}`;
|
|
2808
|
+
};
|
|
2809
|
+
const formatGuidance = (config, currentLevel, validLevels) => {
|
|
2810
|
+
return config.systemPrompt.trim() + " " + (currentLevel ? `Current reasoning effort level: ${currentLevel}. ` : "") + `Valid reasoning effort levels for this session: ${validLevels.join(", ")}. To change your reasoning effort, use the \`${config.toolName}\` tool with one of the valid levels. Only call it when the task complexity justifies changing levels.`;
|
|
2811
|
+
};
|
|
2812
|
+
function adaptiveThinking(pi) {
|
|
2813
|
+
let runtime;
|
|
2814
|
+
let runtimeHandlersRegistered = false;
|
|
2815
|
+
const registerRuntimeHandlers = () => {
|
|
2816
|
+
if (runtimeHandlersRegistered) return;
|
|
2817
|
+
runtimeHandlersRegistered = true;
|
|
2818
|
+
pi.on("thinking_level_select", async (event) => {
|
|
2819
|
+
if (!runtime) return;
|
|
2820
|
+
runtime.currentLevel = event.level;
|
|
2821
|
+
});
|
|
2822
|
+
pi.on("before_agent_start", async (event, ctx) => beforeAgentStart(event, ctx));
|
|
2823
|
+
pi.on("agent_end", async (_event, ctx) => {
|
|
2824
|
+
await resetTemporaryLevel(ctx);
|
|
2825
|
+
});
|
|
2826
|
+
};
|
|
2827
|
+
const beforeAgentStart = async (event, ctx) => {
|
|
2828
|
+
const state = runtime;
|
|
2829
|
+
if (!state) return { systemPrompt: event.systemPrompt };
|
|
2830
|
+
const currentLevel = state.currentLevel ?? pi.getThinkingLevel();
|
|
2831
|
+
if (isThinkingLevel(currentLevel)) state.currentLevel = currentLevel;
|
|
2832
|
+
const validLevels = resolveSupportedThinkingLevels(ctx.model);
|
|
2833
|
+
return { systemPrompt: appendSystemPromptBlock(event.systemPrompt, formatGuidance(state.config, state.currentLevel, validLevels)) };
|
|
2834
|
+
};
|
|
2835
|
+
const resetTemporaryLevel = async (ctx) => {
|
|
2836
|
+
const state = runtime;
|
|
2837
|
+
const resetLevel = state?.temporaryResetLevel;
|
|
2838
|
+
if (!state || !resetLevel) return;
|
|
2839
|
+
try {
|
|
2840
|
+
pi.setThinkingLevel(resetLevel);
|
|
2841
|
+
state.currentLevel = resetLevel;
|
|
2842
|
+
delete state.temporaryResetLevel;
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
notify(ctx, "error", `Failed to reset reasoning effort: ${errorMessage(error)}`, state.config);
|
|
2845
|
+
}
|
|
2846
|
+
};
|
|
2847
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
2848
|
+
const configResult = await loadConfig({ cwd: ctx.cwd });
|
|
2849
|
+
if (!configResult.success) {
|
|
2850
|
+
runtime = void 0;
|
|
2851
|
+
notify(ctx, "error", configResult.error.message);
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
const { config } = configResult;
|
|
2855
|
+
if (!config.enabled) {
|
|
2856
|
+
runtime = void 0;
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
const initialLevel = pi.getThinkingLevel();
|
|
2860
|
+
runtime = { config };
|
|
2861
|
+
if (isThinkingLevel(initialLevel)) runtime.currentLevel = initialLevel;
|
|
2862
|
+
pi.registerTool({
|
|
2863
|
+
name: config.toolName,
|
|
2864
|
+
label: "Set Reasoning Effort",
|
|
2865
|
+
description: config.toolDescription,
|
|
2866
|
+
promptSnippet: "Set the current reasoning effort / thinking level.",
|
|
2867
|
+
promptGuidelines: [`Use ${config.toolName} to change reasoning effort when task complexity justifies a different thinking level.`],
|
|
2868
|
+
parameters: ToolParameters,
|
|
2869
|
+
execute: async (_toolCallId, params, _signal, _onUpdate, ctx) => {
|
|
2870
|
+
const state = runtime;
|
|
2871
|
+
if (!state) return textResult("Adaptive Thinking is not enabled for this session.");
|
|
2872
|
+
const level = params.level.trim();
|
|
2873
|
+
const validLevels = resolveSupportedThinkingLevels(ctx.model);
|
|
2874
|
+
if (!isThinkingLevel(level) || !validLevels.includes(level)) return textResult(`Invalid reasoning effort level: ${level}. Valid levels: ${validLevels.join(", ")}.`);
|
|
2875
|
+
const persist = params.persist ?? false;
|
|
2876
|
+
const currentLevel = state.currentLevel ?? pi.getThinkingLevel();
|
|
2877
|
+
const resetLevel = state.persistedLevel ?? (isThinkingLevel(currentLevel) ? currentLevel : void 0);
|
|
2878
|
+
try {
|
|
2879
|
+
pi.setThinkingLevel(level);
|
|
2880
|
+
} catch (error) {
|
|
2881
|
+
return textResult(`Failed to set reasoning effort: ${errorMessage(error)}`);
|
|
2882
|
+
}
|
|
2883
|
+
state.currentLevel = level;
|
|
2884
|
+
if (persist) {
|
|
2885
|
+
state.persistedLevel = level;
|
|
2886
|
+
delete state.temporaryResetLevel;
|
|
2887
|
+
} else if (resetLevel && resetLevel !== level) state.temporaryResetLevel = resetLevel;
|
|
2888
|
+
else delete state.temporaryResetLevel;
|
|
2889
|
+
return textResult(`Reasoning effort set to ${level}`);
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2892
|
+
registerRuntimeHandlers();
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
//#endregion
|
|
2896
|
+
export { adaptiveThinking as default };
|