hyperframes 0.8.114 → 0.8.115
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/dist/{add-KCBOVKEU.js → add-ZSLFODRZ.js} +15 -14
- package/dist/{animatedGifPrep-U7FMC7DB.js → animatedGifPrep-72A45YER.js} +5 -5
- package/dist/{asset-AJ4ZZE3K.js → asset-SGDOHBBN.js} +2 -2
- package/dist/{assetCataloger-5LCGR5XU.js → assetCataloger-Q7BCDARF.js} +2 -2
- package/dist/{auth-PSEHAWSA.js → auth-5JGFN7SV.js} +2 -2
- package/dist/{autoUpdate-E32YLKFZ.js → autoUpdate-ZVTMYO7Z.js} +2 -2
- package/dist/{backgroundChecks-FNHBA7YI.js → backgroundChecks-IY3G5G2D.js} +3 -3
- package/dist/backgroundChecksWorker.js +3 -3
- package/dist/{batchRender-QVJ7NEUH.js → batchRender-QVLLL5DN.js} +3 -3
- package/dist/{beats-F67KZC3V.js → beats-66KZIB5V.js} +14 -10
- package/dist/{benchmark-CGD6CPRK.js → benchmark-AWFKSWQH.js} +11 -11
- package/dist/{browser-FPX3Z2AR.js → browser-J54EXMCE.js} +8 -8
- package/dist/{bundleWithLocalizedFonts-4CVITCYK.js → bundleWithLocalizedFonts-BLLHP2TO.js} +2 -2
- package/dist/{capture-GLHK4ST7.js → capture-D4HRSVSK.js} +2 -2
- package/dist/{capture-F2Y7TIHU.js → capture-SLI2I5BS.js} +16 -11
- package/dist/{catalog-4BZX7MQQ.js → catalog-BUMLQU7L.js} +15 -14
- package/dist/{check-IO3HWLLU.js → check-HEZUK62C.js} +31 -29
- package/dist/{checkBrowser-JTQ7ABCL.js → checkBrowser-RVJM6IUO.js} +30 -28
- package/dist/{chunk-MR6BQLGM.js → chunk-2DX6JYL2.js} +2 -2
- package/dist/{chunk-BOUDTDBQ.js → chunk-2GWVY66H.js} +1 -1
- package/dist/{chunk-P3FGUSFK.js → chunk-2H37RGJ2.js} +7 -7
- package/dist/{chunk-7543YIMQ.js → chunk-3J4EBX5M.js} +1 -1
- package/dist/{chunk-MLLBZR2U.js → chunk-3R6P5BIG.js} +2 -2
- package/dist/{chunk-HGMKPPGD.js → chunk-3YTWSGBV.js} +4 -4
- package/dist/{chunk-RKSRXPKV.js → chunk-4HIF3LI3.js} +5 -5
- package/dist/{chunk-HTQR7SUZ.js → chunk-4P2TOD7N.js} +1 -1
- package/dist/{chunk-G2T2X6FZ.js → chunk-5MXN7WM4.js} +2 -2
- package/dist/{chunk-BORVRAHJ.js → chunk-5YSA3YXO.js} +14 -18
- package/dist/{chunk-JH7ZJRDL.js → chunk-6SEUZGID.js} +3 -3
- package/dist/{chunk-VLC7JS4K.js → chunk-74RAXWDF.js} +1 -1
- package/dist/{chunk-MST5JBOR.js → chunk-AXXK3LWL.js} +1 -1
- package/dist/chunk-BDNCUMZM.js +2961 -0
- package/dist/{chunk-E52XEEAA.js → chunk-BQG33YTI.js} +1 -1
- package/dist/{chunk-QPR4N2D4.js → chunk-CVBWF2MD.js} +1 -1
- package/dist/{chunk-7ZR25WGW.js → chunk-HOBR4IHC.js} +7 -7
- package/dist/{chunk-LSSIYIXI.js → chunk-HPWPLV5J.js} +2 -2
- package/dist/{chunk-FCEFKWPM.js → chunk-IEE7GIVX.js} +1 -1
- package/dist/{chunk-L5QASNBN.js → chunk-IOJAVV6J.js} +1 -1
- package/dist/{chunk-IPXPSCWV.js → chunk-KLZ7OCHR.js} +3 -3
- package/dist/{chunk-OCNCK5FQ.js → chunk-M7XTMZF5.js} +1 -1
- package/dist/{chunk-GDJ74GHW.js → chunk-MPB7BQT7.js} +1 -1
- package/dist/{chunk-3SH322X7.js → chunk-ORAISNGN.js} +14 -17
- package/dist/{chunk-IP3XINRB.js → chunk-P6LJ4Y32.js} +23 -2944
- package/dist/chunk-P73WQPSB.js +93 -0
- package/dist/{chunk-LYNBNESS.js → chunk-PLP4K6WZ.js} +122 -47
- package/dist/{chunk-LMC46FK5.js → chunk-QMFCL2ZN.js} +1 -1
- package/dist/{chunk-DR7QW6C5.js → chunk-QXNRRMBQ.js} +2 -2
- package/dist/{chunk-C6AIZOQN.js → chunk-RRPJEHHW.js} +1 -1
- package/dist/{chunk-6U3K3U62.js → chunk-SAO3NQPF.js} +1 -1
- package/dist/{chunk-3IUSKIZW.js → chunk-SC7ICSIU.js} +1 -1
- package/dist/{chunk-SSM2TJYE.js → chunk-SK53U3PF.js} +1 -1
- package/dist/{chunk-XXKBPGPJ.js → chunk-SOEQWMNS.js} +2 -2
- package/dist/{chunk-752X6G7T.js → chunk-SSZYJCAL.js} +2 -2
- package/dist/{chunk-SYQOD3W7.js → chunk-T5HXGUM3.js} +1 -1
- package/dist/{chunk-ENHAGQEP.js → chunk-TMCJPHPP.js} +1 -1
- package/dist/{chunk-XFJXFNJF.js → chunk-TWJT2RGZ.js} +27 -12
- package/dist/{chunk-ZMMSMDCA.js → chunk-VDASTWUM.js} +1 -1
- package/dist/{chunk-T3NMEYGM.js → chunk-WZYHTXZY.js} +1 -1
- package/dist/{chunk-WAS5VEA4.js → chunk-XJQ7TRLG.js} +1 -1
- package/dist/{chunk-LDSWUYZB.js → chunk-Y2Y4LBJD.js} +3 -3
- package/dist/{chunk-SIN32SJB.js → chunk-YNHP6OFJ.js} +2 -2
- package/dist/{chunk-4KGMIOMY.js → chunk-ZBQP54CD.js} +10 -7
- package/dist/{clean-MCL76KQH.js → clean-X6Y252ZC.js} +14 -14
- package/dist/cli.js +53 -52
- package/dist/{cloud-444K6HIK.js → cloud-EE4GALWR.js} +4 -4
- package/dist/{cloudrun-BML6ZG7K.js → cloudrun-Y6A42KHE.js} +3 -3
- package/dist/{compare-CGNTCOR2.js → compare-K6XJZ3OC.js} +25 -23
- package/dist/{compiler-ZHVIEP26.js → compiler-DYACPLUW.js} +2 -2
- package/dist/{component-HTXLOIHR.js → component-T6IYSCFP.js} +3 -3
- package/dist/{compositions-KK46F5AC.js → compositions-4KUTNS5L.js} +10 -10
- package/dist/{delete-SSRZKKWQ.js → delete-C64TWAPE.js} +2 -2
- package/dist/{dist-OKRUIHYU.js → dist-KNGSQALD.js} +2 -2
- package/dist/{doctor-IIOX25KM.js → doctor-WJXZK5QN.js} +9 -9
- package/dist/{events-DCUZBRW6.js → events-FVG3Y6Q4.js} +8 -8
- package/dist/{events-TYMMAKHX.js → events-QRWJBSV4.js} +7 -7
- package/dist/{feedback-RIAGW6LG.js → feedback-NQHRUOZP.js} +9 -9
- package/dist/{figma-VBOUGJNX.js → figma-MEX4CSIM.js} +3 -3
- package/dist/fontLocalizeCli.js +7 -7
- package/dist/{get-LT6NUGNR.js → get-CMJIHGSA.js} +2 -2
- package/dist/{gpuPolicy-LRMOZXFU.js → gpuPolicy-5S4OZDME.js} +5 -5
- package/dist/{grade-compare-WWYQSQUM.js → grade-compare-NIDMIUGZ.js} +25 -23
- package/dist/{help-55ZV2M5U.js → help-G6AWAWJW.js} +1 -1
- package/dist/{history-QCY7CO4P.js → history-ZBOK2JQF.js} +20 -18
- package/dist/hyperframe-runtime.js +36 -36
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +36 -36
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-ROTXHRAH.js → info-2ORQZ6I2.js} +10 -10
- package/dist/{init-5XFOWGGN.js → init-3PSKH6UR.js} +22 -21
- package/dist/{inspect-3UF4VLTM.js → inspect-NR54RMEE.js} +26 -24
- package/dist/{installer-DGYYDGWJ.js → installer-YQUWHYBZ.js} +5 -4
- package/dist/{keyframes-OFZ6XNMC.js → keyframes-KT7T4AEV.js} +11 -11
- package/dist/{lambda-OQBFCEFA.js → lambda-3FF4V3X3.js} +4 -4
- package/dist/{layout-B4XF2734.js → layout-RB3M37ER.js} +26 -24
- package/dist/{lint-3YIJITTC.js → lint-HR57M5YP.js} +11 -11
- package/dist/{list-276FF3QE.js → list-YDXYHXHF.js} +2 -2
- package/dist/{login-SA3MCAIS.js → login-N6UNRVYW.js} +4 -4
- package/dist/{media-treatment-ICA5DWHS.js → media-treatment-UXJOTNRO.js} +11 -11
- package/dist/{models-JF5OOZ5A.js → models-Z3XFMGXB.js} +6 -6
- package/dist/{motionShot-TQBDZZ4M.js → motionShot-KQMCXJ77.js} +15 -12
- package/dist/{normalize-audio-URNASKUV.js → normalize-audio-XJQMDWRV.js} +10 -10
- package/dist/{pipeline-IWPF5ZMK.js → pipeline-U3OISHWV.js} +5 -5
- package/dist/{play-JYBAII35.js → play-XP77PML5.js} +20 -19
- package/dist/{preflight-2GH2Z4GZ.js → preflight-CANFVC4Y.js} +6 -6
- package/dist/{present-WIEZRZET.js → present-MWGA3O4S.js} +15 -15
- package/dist/{preview-YUPU646E.js → preview-X5GWZ3Q6.js} +17 -16
- package/dist/{producer-SL66UNEP.js → producer-B2IHU7MA.js} +1 -1
- package/dist/{projectConfig-7AKXZNNR.js → projectConfig-2A64YU5H.js} +7 -6
- package/dist/{publication-B2OERUY7.js → publication-CFYBPLRS.js} +2 -2
- package/dist/{publish-ZGKT7KED.js → publish-WE6AS77D.js} +8 -7
- package/dist/{remove-background-4LRTT6YL.js → remove-background-XSDOCVN5.js} +6 -6
- package/dist/{render-AX77WC3C.js → render-5TMRIC73.js} +11 -11
- package/dist/{render-F3QVCKKA.js → render-HVZUCLYW.js} +21 -20
- package/dist/{render-TGCDBKMP.js → render-QX6AKB6Y.js} +3 -3
- package/dist/{render-batch-WRQFW4UC.js → render-batch-QJXFVTDE.js} +3 -3
- package/dist/{renderCancellation-BFCQYGVV.js → renderCancellation-WSSSHRFR.js} +5 -5
- package/dist/{resolver-37UOGAMT.js → resolver-WTXO6WXA.js} +5 -4
- package/dist/{sherpa-SDVKYXCX.js → sherpa-S6ZBBEFO.js} +6 -6
- package/dist/skills/hyperframes/SKILL.md +4 -0
- package/dist/skills/hyperframes-cli/SKILL.md +8 -0
- package/dist/skills/hyperframes-cli/references/upgrade-info-misc.md +8 -0
- package/dist/skills/media-use/audio/scripts/audio.mjs +4 -1
- package/dist/skills/media-use/audio/scripts/audio.test.mjs +33 -0
- package/dist/skills/media-use/audio/scripts/lib/tts.mjs +1 -0
- package/dist/skills/media-use/audio/scripts/lib/tts.test.mjs +44 -1
- package/dist/{skills-M6ETUUH5.js → skills-CDRSTETB.js} +10 -10
- package/dist/{skillsUpdateCheck-UTX5LT5C.js → skillsUpdateCheck-FKREJXSF.js} +3 -3
- package/dist/{snapshot-HMDAENTY.js → snapshot-T4PFSXTH.js} +26 -24
- package/dist/{src-PLWCT745.js → src-5BZDQAVN.js} +6 -6
- package/dist/{src-PJJ6NISA.js → src-IZMCUYK7.js} +4 -4
- package/dist/{staticProjectServer-XDH5SQV6.js → staticProjectServer-VN4ARAH4.js} +14 -13
- package/dist/{status-LENRPQS5.js → status-OJZWJB53.js} +5 -5
- package/dist/studio/assets/{hyperframes-player-aXNJKiIg.js → hyperframes-player-C-9N8nk0.js} +1 -1
- package/dist/studio/assets/{index-Bn2RJNTJ.js → index-BoUM6Xqb.js} +1 -1
- package/dist/studio/assets/{index-Dz7doz9l.js → index-CAvZ0AA-.js} +201 -201
- package/dist/studio/assets/{index-C9N-DGjC.js → index-CVuorIMv.js} +1 -1
- package/dist/studio/assets/{index-BYnsJnJV.css → index-t1LH6H5H.css} +1 -1
- package/dist/studio/{chunk-K47E2ZJA.js → chunk-5EKWJZLM.js} +504 -17
- package/dist/studio/chunk-5EKWJZLM.js.map +1 -0
- package/dist/studio/{chunk-VWT7STY3.js → chunk-J6Q572FA.js} +2 -2
- package/dist/studio/{chunk-BIUXP3PG.js → chunk-TXZMMOMA.js} +43 -276
- package/dist/studio/chunk-TXZMMOMA.js.map +1 -0
- package/dist/studio/{domEditingLayers-V67MS4WP.js → domEditingLayers-D7VYFJJD.js} +3 -5
- package/dist/studio/index.d.ts +43 -19
- package/dist/studio/index.html +2 -2
- package/dist/studio/index.js +2939 -2596
- package/dist/studio/index.js.map +1 -1
- package/dist/studio/player.js +2 -2
- package/dist/studio/styles.css +1 -1
- package/dist/{studio-api-E5WFZ7YK.js → studio-api-CIO2NKK5.js} +9 -7
- package/dist/{studioServer-C7GTHTRY.js → studioServer-G5GNYWDI.js} +45 -45
- package/dist/{system-4KRSV2B7.js → system-PPNNGVIM.js} +5 -5
- package/dist/{telemetry-XH6D37RL.js → telemetry-GMDMISOX.js} +8 -8
- package/dist/{timeline-4RR7O6QW.js → timeline-5LSQX4OS.js} +14 -14
- package/dist/{tokens-MVTK3RPO.js → tokens-VBXAT7CK.js} +2 -2
- package/dist/{transcribe-I6WDPH7E.js → transcribe-GYCAIIEQ.js} +11 -11
- package/dist/{transcribe-3UXXEDXX.js → transcribe-VGYAWRXS.js} +6 -6
- package/dist/{updateCheck-ELMPFCBF.js → updateCheck-AZEREUQV.js} +2 -2
- package/dist/{upgrade-6UAOGP4D.js → upgrade-S63QN2LA.js} +2 -2
- package/dist/{urlDownloader-4KNER64L.js → urlDownloader-SM6ODN5O.js} +4 -4
- package/dist/usage-EC3KFUIJ.js +2139 -0
- package/dist/{validate-ZMMGUMBD.js → validate-7MNUK5MH.js} +15 -14
- package/dist/{video-GINAMW5I.js → video-JEOHARTC.js} +5 -5
- package/package.json +1 -1
- package/dist/studio/chunk-BIUXP3PG.js.map +0 -1
- package/dist/studio/chunk-K47E2ZJA.js.map +0 -1
- /package/dist/studio/{chunk-VWT7STY3.js.map → chunk-J6Q572FA.js.map} +0 -0
- /package/dist/studio/{domEditingLayers-V67MS4WP.js.map → domEditingLayers-D7VYFJJD.js.map} +0 -0
|
@@ -0,0 +1,2139 @@
|
|
|
1
|
+
import { createRequire as __hf_createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname as __hf_dirname } from "node:path";
|
|
4
|
+
var require = __hf_createRequire(import.meta.url);
|
|
5
|
+
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __hf_dirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_code,
|
|
9
|
+
require_codegen,
|
|
10
|
+
require_compile,
|
|
11
|
+
require_core,
|
|
12
|
+
require_names,
|
|
13
|
+
require_ref,
|
|
14
|
+
require_ref_error,
|
|
15
|
+
require_types,
|
|
16
|
+
require_util,
|
|
17
|
+
require_validate,
|
|
18
|
+
require_validation_error
|
|
19
|
+
} from "./chunk-P6LJ4Y32.js";
|
|
20
|
+
import {
|
|
21
|
+
defineCommand
|
|
22
|
+
} from "./chunk-S3S4TGEH.js";
|
|
23
|
+
import {
|
|
24
|
+
__commonJS,
|
|
25
|
+
__toESM
|
|
26
|
+
} from "./chunk-M2WBOQ2Q.js";
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/metadata.js
|
|
29
|
+
var require_metadata = __commonJS({
|
|
30
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/metadata.js"(exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.checkMetadata = void 0;
|
|
34
|
+
var util_1 = require_util();
|
|
35
|
+
var def = {
|
|
36
|
+
keyword: "metadata",
|
|
37
|
+
schemaType: "object",
|
|
38
|
+
code(cxt) {
|
|
39
|
+
checkMetadata(cxt);
|
|
40
|
+
const { gen, schema, it } = cxt;
|
|
41
|
+
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
42
|
+
return;
|
|
43
|
+
const valid = gen.name("valid");
|
|
44
|
+
cxt.subschema({ keyword: "metadata", jtdMetadata: true }, valid);
|
|
45
|
+
cxt.ok(valid);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function checkMetadata({ it, keyword }, metadata) {
|
|
49
|
+
if (it.jtdMetadata !== metadata) {
|
|
50
|
+
throw new Error(`JTD: "${keyword}" cannot be used in this schema location`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.checkMetadata = checkMetadata;
|
|
54
|
+
exports.default = def;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/ref.js
|
|
59
|
+
var require_ref2 = __commonJS({
|
|
60
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/ref.js"(exports) {
|
|
61
|
+
"use strict";
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.hasRef = void 0;
|
|
64
|
+
var compile_1 = require_compile();
|
|
65
|
+
var codegen_1 = require_codegen();
|
|
66
|
+
var ref_error_1 = require_ref_error();
|
|
67
|
+
var names_1 = require_names();
|
|
68
|
+
var ref_1 = require_ref();
|
|
69
|
+
var metadata_1 = require_metadata();
|
|
70
|
+
var def = {
|
|
71
|
+
keyword: "ref",
|
|
72
|
+
schemaType: "string",
|
|
73
|
+
code(cxt) {
|
|
74
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
75
|
+
const { gen, data, schema: ref, parentSchema, it } = cxt;
|
|
76
|
+
const { schemaEnv: { root } } = it;
|
|
77
|
+
const valid = gen.name("valid");
|
|
78
|
+
if (parentSchema.nullable) {
|
|
79
|
+
gen.var(valid, (0, codegen_1._)`${data} === null`);
|
|
80
|
+
gen.if((0, codegen_1.not)(valid), validateJtdRef);
|
|
81
|
+
} else {
|
|
82
|
+
gen.var(valid, false);
|
|
83
|
+
validateJtdRef();
|
|
84
|
+
}
|
|
85
|
+
cxt.ok(valid);
|
|
86
|
+
function validateJtdRef() {
|
|
87
|
+
var _a;
|
|
88
|
+
const refSchema = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref];
|
|
89
|
+
if (!refSchema) {
|
|
90
|
+
throw new ref_error_1.default(it.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
91
|
+
}
|
|
92
|
+
if (hasRef(refSchema) || !it.opts.inlineRefs)
|
|
93
|
+
callValidate(refSchema);
|
|
94
|
+
else
|
|
95
|
+
inlineRefSchema(refSchema);
|
|
96
|
+
}
|
|
97
|
+
function callValidate(schema) {
|
|
98
|
+
const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root, schemaPath: `/definitions/${ref}` }));
|
|
99
|
+
const v = (0, ref_1.getValidate)(cxt, sch);
|
|
100
|
+
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
101
|
+
(0, ref_1.callRef)(cxt, v, sch, sch.$async);
|
|
102
|
+
gen.assign(valid, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
103
|
+
}
|
|
104
|
+
function inlineRefSchema(schema) {
|
|
105
|
+
const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: (0, codegen_1.stringify)(schema) } : { ref: schema });
|
|
106
|
+
cxt.subschema({
|
|
107
|
+
schema,
|
|
108
|
+
dataTypes: [],
|
|
109
|
+
schemaPath: codegen_1.nil,
|
|
110
|
+
topSchemaRef: schName,
|
|
111
|
+
errSchemaPath: `/definitions/${ref}`
|
|
112
|
+
}, valid);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function hasRef(schema) {
|
|
117
|
+
for (const key in schema) {
|
|
118
|
+
let sch;
|
|
119
|
+
if (key === "ref" || typeof (sch = schema[key]) == "object" && hasRef(sch))
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
exports.hasRef = hasRef;
|
|
125
|
+
exports.default = def;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/timestamp.js
|
|
130
|
+
var require_timestamp = __commonJS({
|
|
131
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/timestamp.js"(exports) {
|
|
132
|
+
"use strict";
|
|
133
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
134
|
+
var DT_SEPARATOR = /t|\s/i;
|
|
135
|
+
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
136
|
+
var TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i;
|
|
137
|
+
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
138
|
+
function validTimestamp(str, allowDate) {
|
|
139
|
+
const dt = str.split(DT_SEPARATOR);
|
|
140
|
+
return dt.length === 2 && validDate(dt[0]) && validTime(dt[1]) || allowDate && dt.length === 1 && validDate(dt[0]);
|
|
141
|
+
}
|
|
142
|
+
exports.default = validTimestamp;
|
|
143
|
+
function validDate(str) {
|
|
144
|
+
const matches = DATE.exec(str);
|
|
145
|
+
if (!matches)
|
|
146
|
+
return false;
|
|
147
|
+
const y = +matches[1];
|
|
148
|
+
const m = +matches[2];
|
|
149
|
+
const d = +matches[3];
|
|
150
|
+
return m >= 1 && m <= 12 && d >= 1 && (d <= DAYS[m] || // leap year: https://tools.ietf.org/html/rfc3339#appendix-C
|
|
151
|
+
m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0));
|
|
152
|
+
}
|
|
153
|
+
function validTime(str) {
|
|
154
|
+
const matches = TIME.exec(str);
|
|
155
|
+
if (!matches)
|
|
156
|
+
return false;
|
|
157
|
+
const hr = +matches[1];
|
|
158
|
+
const min = +matches[2];
|
|
159
|
+
const sec = +matches[3];
|
|
160
|
+
const tzH = +(matches[4] || 0);
|
|
161
|
+
const tzM = +(matches[5] || 0);
|
|
162
|
+
return hr <= 23 && min <= 59 && sec <= 59 || // leap second
|
|
163
|
+
hr - tzH === 23 && min - tzM === 59 && sec === 60;
|
|
164
|
+
}
|
|
165
|
+
validTimestamp.code = 'require("ajv/dist/runtime/timestamp").default';
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/error.js
|
|
170
|
+
var require_error = __commonJS({
|
|
171
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/error.js"(exports) {
|
|
172
|
+
"use strict";
|
|
173
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
174
|
+
exports.typeErrorParams = exports.typeErrorMessage = exports.typeError = void 0;
|
|
175
|
+
var codegen_1 = require_codegen();
|
|
176
|
+
function typeError(t) {
|
|
177
|
+
return {
|
|
178
|
+
message: (cxt) => typeErrorMessage(cxt, t),
|
|
179
|
+
params: (cxt) => typeErrorParams(cxt, t)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
exports.typeError = typeError;
|
|
183
|
+
function typeErrorMessage({ parentSchema }, t) {
|
|
184
|
+
return (parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable) ? `must be ${t} or null` : `must be ${t}`;
|
|
185
|
+
}
|
|
186
|
+
exports.typeErrorMessage = typeErrorMessage;
|
|
187
|
+
function typeErrorParams({ parentSchema }, t) {
|
|
188
|
+
return (0, codegen_1._)`{type: ${t}, nullable: ${!!(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable)}}`;
|
|
189
|
+
}
|
|
190
|
+
exports.typeErrorParams = typeErrorParams;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/type.js
|
|
195
|
+
var require_type = __commonJS({
|
|
196
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/type.js"(exports) {
|
|
197
|
+
"use strict";
|
|
198
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
199
|
+
exports.intRange = void 0;
|
|
200
|
+
var codegen_1 = require_codegen();
|
|
201
|
+
var timestamp_1 = require_timestamp();
|
|
202
|
+
var util_1 = require_util();
|
|
203
|
+
var metadata_1 = require_metadata();
|
|
204
|
+
var error_1 = require_error();
|
|
205
|
+
exports.intRange = {
|
|
206
|
+
int8: [-128, 127, 3],
|
|
207
|
+
uint8: [0, 255, 3],
|
|
208
|
+
int16: [-32768, 32767, 5],
|
|
209
|
+
uint16: [0, 65535, 5],
|
|
210
|
+
int32: [-2147483648, 2147483647, 10],
|
|
211
|
+
uint32: [0, 4294967295, 10]
|
|
212
|
+
};
|
|
213
|
+
var error = {
|
|
214
|
+
message: (cxt) => (0, error_1.typeErrorMessage)(cxt, cxt.schema),
|
|
215
|
+
params: (cxt) => (0, error_1.typeErrorParams)(cxt, cxt.schema)
|
|
216
|
+
};
|
|
217
|
+
function timestampCode(cxt) {
|
|
218
|
+
const { gen, data, it } = cxt;
|
|
219
|
+
const { timestamp, allowDate } = it.opts;
|
|
220
|
+
if (timestamp === "date")
|
|
221
|
+
return (0, codegen_1._)`${data} instanceof Date `;
|
|
222
|
+
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
|
|
223
|
+
const allowDateArg = allowDate ? (0, codegen_1._)`, true` : codegen_1.nil;
|
|
224
|
+
const validString = (0, codegen_1._)`typeof ${data} == "string" && ${vts}(${data}${allowDateArg})`;
|
|
225
|
+
return timestamp === "string" ? validString : (0, codegen_1.or)((0, codegen_1._)`${data} instanceof Date`, validString);
|
|
226
|
+
}
|
|
227
|
+
var def = {
|
|
228
|
+
keyword: "type",
|
|
229
|
+
schemaType: "string",
|
|
230
|
+
error,
|
|
231
|
+
code(cxt) {
|
|
232
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
233
|
+
const { data, schema, parentSchema, it } = cxt;
|
|
234
|
+
let cond;
|
|
235
|
+
switch (schema) {
|
|
236
|
+
case "boolean":
|
|
237
|
+
case "string":
|
|
238
|
+
cond = (0, codegen_1._)`typeof ${data} == ${schema}`;
|
|
239
|
+
break;
|
|
240
|
+
case "timestamp": {
|
|
241
|
+
cond = timestampCode(cxt);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
case "float32":
|
|
245
|
+
case "float64":
|
|
246
|
+
cond = (0, codegen_1._)`typeof ${data} == "number"`;
|
|
247
|
+
break;
|
|
248
|
+
default: {
|
|
249
|
+
const sch = schema;
|
|
250
|
+
cond = (0, codegen_1._)`typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`;
|
|
251
|
+
if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
|
|
252
|
+
if (sch === "uint32")
|
|
253
|
+
cond = (0, codegen_1._)`${cond} && ${data} >= 0`;
|
|
254
|
+
} else {
|
|
255
|
+
const [min, max] = exports.intRange[sch];
|
|
256
|
+
cond = (0, codegen_1._)`${cond} && ${data} >= ${min} && ${data} <= ${max}`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
cxt.pass(parentSchema.nullable ? (0, codegen_1.or)((0, codegen_1._)`${data} === null`, cond) : cond);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
exports.default = def;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/nullable.js
|
|
268
|
+
var require_nullable = __commonJS({
|
|
269
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/nullable.js"(exports) {
|
|
270
|
+
"use strict";
|
|
271
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
272
|
+
exports.checkNullableObject = exports.checkNullable = void 0;
|
|
273
|
+
var codegen_1 = require_codegen();
|
|
274
|
+
function checkNullable({ gen, data, parentSchema }, cond = codegen_1.nil) {
|
|
275
|
+
const valid = gen.name("valid");
|
|
276
|
+
if (parentSchema.nullable) {
|
|
277
|
+
gen.let(valid, (0, codegen_1._)`${data} === null`);
|
|
278
|
+
cond = (0, codegen_1.not)(valid);
|
|
279
|
+
} else {
|
|
280
|
+
gen.let(valid, false);
|
|
281
|
+
}
|
|
282
|
+
return [valid, cond];
|
|
283
|
+
}
|
|
284
|
+
exports.checkNullable = checkNullable;
|
|
285
|
+
function checkNullableObject(cxt, cond) {
|
|
286
|
+
const [valid, cond_] = checkNullable(cxt, cond);
|
|
287
|
+
return [valid, (0, codegen_1._)`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
|
|
288
|
+
}
|
|
289
|
+
exports.checkNullableObject = checkNullableObject;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/enum.js
|
|
294
|
+
var require_enum = __commonJS({
|
|
295
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/enum.js"(exports) {
|
|
296
|
+
"use strict";
|
|
297
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
298
|
+
var codegen_1 = require_codegen();
|
|
299
|
+
var metadata_1 = require_metadata();
|
|
300
|
+
var nullable_1 = require_nullable();
|
|
301
|
+
var error = {
|
|
302
|
+
message: "must be equal to one of the allowed values",
|
|
303
|
+
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
|
|
304
|
+
};
|
|
305
|
+
var def = {
|
|
306
|
+
keyword: "enum",
|
|
307
|
+
schemaType: "array",
|
|
308
|
+
error,
|
|
309
|
+
code(cxt) {
|
|
310
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
311
|
+
const { gen, data, schema, schemaValue, parentSchema, it } = cxt;
|
|
312
|
+
if (schema.length === 0)
|
|
313
|
+
throw new Error("enum must have non-empty array");
|
|
314
|
+
if (schema.length !== new Set(schema).size)
|
|
315
|
+
throw new Error("enum items must be unique");
|
|
316
|
+
let valid;
|
|
317
|
+
const isString = (0, codegen_1._)`typeof ${data} == "string"`;
|
|
318
|
+
if (schema.length >= it.opts.loopEnum) {
|
|
319
|
+
let cond;
|
|
320
|
+
[valid, cond] = (0, nullable_1.checkNullable)(cxt, isString);
|
|
321
|
+
gen.if(cond, loopEnum);
|
|
322
|
+
} else {
|
|
323
|
+
if (!Array.isArray(schema))
|
|
324
|
+
throw new Error("ajv implementation error");
|
|
325
|
+
valid = (0, codegen_1.and)(isString, (0, codegen_1.or)(...schema.map((value) => (0, codegen_1._)`${data} === ${value}`)));
|
|
326
|
+
if (parentSchema.nullable)
|
|
327
|
+
valid = (0, codegen_1.or)((0, codegen_1._)`${data} === null`, valid);
|
|
328
|
+
}
|
|
329
|
+
cxt.pass(valid);
|
|
330
|
+
function loopEnum() {
|
|
331
|
+
gen.forOf("v", schemaValue, (v) => gen.if((0, codegen_1._)`${valid} = ${data} === ${v}`, () => gen.break()));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
exports.default = def;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/elements.js
|
|
340
|
+
var require_elements = __commonJS({
|
|
341
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/elements.js"(exports) {
|
|
342
|
+
"use strict";
|
|
343
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
344
|
+
var util_1 = require_util();
|
|
345
|
+
var code_1 = require_code();
|
|
346
|
+
var codegen_1 = require_codegen();
|
|
347
|
+
var metadata_1 = require_metadata();
|
|
348
|
+
var nullable_1 = require_nullable();
|
|
349
|
+
var error_1 = require_error();
|
|
350
|
+
var def = {
|
|
351
|
+
keyword: "elements",
|
|
352
|
+
schemaType: "object",
|
|
353
|
+
error: (0, error_1.typeError)("array"),
|
|
354
|
+
code(cxt) {
|
|
355
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
356
|
+
const { gen, data, schema, it } = cxt;
|
|
357
|
+
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
358
|
+
return;
|
|
359
|
+
const [valid] = (0, nullable_1.checkNullable)(cxt);
|
|
360
|
+
gen.if((0, codegen_1.not)(valid), () => gen.if((0, codegen_1._)`Array.isArray(${data})`, () => gen.assign(valid, (0, code_1.validateArray)(cxt)), () => cxt.error()));
|
|
361
|
+
cxt.ok(valid);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
exports.default = def;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/properties.js
|
|
369
|
+
var require_properties = __commonJS({
|
|
370
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/properties.js"(exports) {
|
|
371
|
+
"use strict";
|
|
372
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
373
|
+
exports.validateProperties = exports.error = void 0;
|
|
374
|
+
var code_1 = require_code();
|
|
375
|
+
var util_1 = require_util();
|
|
376
|
+
var codegen_1 = require_codegen();
|
|
377
|
+
var metadata_1 = require_metadata();
|
|
378
|
+
var nullable_1 = require_nullable();
|
|
379
|
+
var error_1 = require_error();
|
|
380
|
+
var PropError;
|
|
381
|
+
(function(PropError2) {
|
|
382
|
+
PropError2["Additional"] = "additional";
|
|
383
|
+
PropError2["Missing"] = "missing";
|
|
384
|
+
})(PropError || (PropError = {}));
|
|
385
|
+
exports.error = {
|
|
386
|
+
message: (cxt) => {
|
|
387
|
+
const { params } = cxt;
|
|
388
|
+
return params.propError ? params.propError === PropError.Additional ? "must NOT have additional properties" : `must have property '${params.missingProperty}'` : (0, error_1.typeErrorMessage)(cxt, "object");
|
|
389
|
+
},
|
|
390
|
+
params: (cxt) => {
|
|
391
|
+
const { params } = cxt;
|
|
392
|
+
return params.propError ? params.propError === PropError.Additional ? (0, codegen_1._)`{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}` : (0, codegen_1._)`{error: ${params.propError}, missingProperty: ${params.missingProperty}}` : (0, error_1.typeErrorParams)(cxt, "object");
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
var def = {
|
|
396
|
+
keyword: "properties",
|
|
397
|
+
schemaType: "object",
|
|
398
|
+
error: exports.error,
|
|
399
|
+
code: validateProperties
|
|
400
|
+
};
|
|
401
|
+
function validateProperties(cxt) {
|
|
402
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
403
|
+
const { gen, data, parentSchema, it } = cxt;
|
|
404
|
+
const { additionalProperties, nullable } = parentSchema;
|
|
405
|
+
if (it.jtdDiscriminator && nullable)
|
|
406
|
+
throw new Error("JTD: nullable inside discriminator mapping");
|
|
407
|
+
if (commonProperties()) {
|
|
408
|
+
throw new Error("JTD: properties and optionalProperties have common members");
|
|
409
|
+
}
|
|
410
|
+
const [allProps, properties] = schemaProperties("properties");
|
|
411
|
+
const [allOptProps, optProperties] = schemaProperties("optionalProperties");
|
|
412
|
+
if (properties.length === 0 && optProperties.length === 0 && additionalProperties) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const [valid, cond] = it.jtdDiscriminator === void 0 ? (0, nullable_1.checkNullableObject)(cxt, data) : [gen.let("valid", false), true];
|
|
416
|
+
gen.if(cond, () => gen.assign(valid, true).block(() => {
|
|
417
|
+
validateProps(properties, "properties", true);
|
|
418
|
+
validateProps(optProperties, "optionalProperties");
|
|
419
|
+
if (!additionalProperties)
|
|
420
|
+
validateAdditional();
|
|
421
|
+
}));
|
|
422
|
+
cxt.pass(valid);
|
|
423
|
+
function commonProperties() {
|
|
424
|
+
const props = parentSchema.properties;
|
|
425
|
+
const optProps = parentSchema.optionalProperties;
|
|
426
|
+
if (!(props && optProps))
|
|
427
|
+
return false;
|
|
428
|
+
for (const p in props) {
|
|
429
|
+
if (Object.prototype.hasOwnProperty.call(optProps, p))
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
function schemaProperties(keyword) {
|
|
435
|
+
const schema = parentSchema[keyword];
|
|
436
|
+
const allPs = schema ? (0, code_1.allSchemaProperties)(schema) : [];
|
|
437
|
+
if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
|
|
438
|
+
throw new Error(`JTD: discriminator tag used in ${keyword}`);
|
|
439
|
+
}
|
|
440
|
+
const ps = allPs.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
|
|
441
|
+
return [allPs, ps];
|
|
442
|
+
}
|
|
443
|
+
function validateProps(props, keyword, required) {
|
|
444
|
+
const _valid = gen.var("valid");
|
|
445
|
+
for (const prop of props) {
|
|
446
|
+
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), () => missingProperty(prop));
|
|
447
|
+
cxt.ok(_valid);
|
|
448
|
+
}
|
|
449
|
+
function missingProperty(prop) {
|
|
450
|
+
if (required) {
|
|
451
|
+
gen.assign(_valid, false);
|
|
452
|
+
cxt.error(false, { propError: PropError.Missing, missingProperty: prop }, { schemaPath: prop });
|
|
453
|
+
} else {
|
|
454
|
+
gen.assign(_valid, true);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function applyPropertySchema(prop, keyword, _valid) {
|
|
459
|
+
cxt.subschema({
|
|
460
|
+
keyword,
|
|
461
|
+
schemaProp: prop,
|
|
462
|
+
dataProp: prop
|
|
463
|
+
}, _valid);
|
|
464
|
+
}
|
|
465
|
+
function validateAdditional() {
|
|
466
|
+
gen.forIn("key", data, (key) => {
|
|
467
|
+
const addProp = isAdditional(key, allProps, "properties", it.jtdDiscriminator);
|
|
468
|
+
const addOptProp = isAdditional(key, allOptProps, "optionalProperties");
|
|
469
|
+
const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : (0, codegen_1.and)(addProp, addOptProp);
|
|
470
|
+
gen.if(extra, () => {
|
|
471
|
+
if (it.opts.removeAdditional) {
|
|
472
|
+
gen.code((0, codegen_1._)`delete ${data}[${key}]`);
|
|
473
|
+
} else {
|
|
474
|
+
cxt.error(false, { propError: PropError.Additional, additionalProperty: key }, { instancePath: key, parentSchema: true });
|
|
475
|
+
if (!it.opts.allErrors)
|
|
476
|
+
gen.break();
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function isAdditional(key, props, keyword, jtdDiscriminator) {
|
|
482
|
+
let additional;
|
|
483
|
+
if (props.length > 8) {
|
|
484
|
+
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema[keyword], keyword);
|
|
485
|
+
additional = (0, codegen_1.not)((0, code_1.isOwnProperty)(gen, propsSchema, key));
|
|
486
|
+
if (jtdDiscriminator !== void 0) {
|
|
487
|
+
additional = (0, codegen_1.and)(additional, (0, codegen_1._)`${key} !== ${jtdDiscriminator}`);
|
|
488
|
+
}
|
|
489
|
+
} else if (props.length || jtdDiscriminator !== void 0) {
|
|
490
|
+
const ps = jtdDiscriminator === void 0 ? props : [jtdDiscriminator].concat(props);
|
|
491
|
+
additional = (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._)`${key} !== ${p}`));
|
|
492
|
+
} else {
|
|
493
|
+
additional = true;
|
|
494
|
+
}
|
|
495
|
+
return additional;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
exports.validateProperties = validateProperties;
|
|
499
|
+
exports.default = def;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js
|
|
504
|
+
var require_optionalProperties = __commonJS({
|
|
505
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js"(exports) {
|
|
506
|
+
"use strict";
|
|
507
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
508
|
+
var properties_1 = require_properties();
|
|
509
|
+
var def = {
|
|
510
|
+
keyword: "optionalProperties",
|
|
511
|
+
schemaType: "object",
|
|
512
|
+
error: properties_1.error,
|
|
513
|
+
code(cxt) {
|
|
514
|
+
if (cxt.parentSchema.properties)
|
|
515
|
+
return;
|
|
516
|
+
(0, properties_1.validateProperties)(cxt);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
exports.default = def;
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/discriminator.js
|
|
524
|
+
var require_discriminator = __commonJS({
|
|
525
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/discriminator.js"(exports) {
|
|
526
|
+
"use strict";
|
|
527
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
528
|
+
var codegen_1 = require_codegen();
|
|
529
|
+
var metadata_1 = require_metadata();
|
|
530
|
+
var nullable_1 = require_nullable();
|
|
531
|
+
var error_1 = require_error();
|
|
532
|
+
var types_1 = require_types();
|
|
533
|
+
var error = {
|
|
534
|
+
message: (cxt) => {
|
|
535
|
+
const { schema, params } = cxt;
|
|
536
|
+
return params.discrError ? params.discrError === types_1.DiscrError.Tag ? `tag "${schema}" must be string` : `value of tag "${schema}" must be in mapping` : (0, error_1.typeErrorMessage)(cxt, "object");
|
|
537
|
+
},
|
|
538
|
+
params: (cxt) => {
|
|
539
|
+
const { schema, params } = cxt;
|
|
540
|
+
return params.discrError ? (0, codegen_1._)`{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}` : (0, error_1.typeErrorParams)(cxt, "object");
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
var def = {
|
|
544
|
+
keyword: "discriminator",
|
|
545
|
+
schemaType: "string",
|
|
546
|
+
implements: ["mapping"],
|
|
547
|
+
error,
|
|
548
|
+
code(cxt) {
|
|
549
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
550
|
+
const { gen, data, schema, parentSchema } = cxt;
|
|
551
|
+
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
|
|
552
|
+
gen.if(cond);
|
|
553
|
+
validateDiscriminator();
|
|
554
|
+
gen.elseIf((0, codegen_1.not)(valid));
|
|
555
|
+
cxt.error();
|
|
556
|
+
gen.endIf();
|
|
557
|
+
cxt.ok(valid);
|
|
558
|
+
function validateDiscriminator() {
|
|
559
|
+
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(schema)}`);
|
|
560
|
+
gen.if((0, codegen_1._)`${tag} === undefined`);
|
|
561
|
+
cxt.error(false, { discrError: types_1.DiscrError.Tag, tag });
|
|
562
|
+
gen.elseIf((0, codegen_1._)`typeof ${tag} == "string"`);
|
|
563
|
+
validateMapping(tag);
|
|
564
|
+
gen.else();
|
|
565
|
+
cxt.error(false, { discrError: types_1.DiscrError.Tag, tag }, { instancePath: schema });
|
|
566
|
+
gen.endIf();
|
|
567
|
+
}
|
|
568
|
+
function validateMapping(tag) {
|
|
569
|
+
gen.if(false);
|
|
570
|
+
for (const tagValue in parentSchema.mapping) {
|
|
571
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
|
|
572
|
+
gen.assign(valid, applyTagSchema(tagValue));
|
|
573
|
+
}
|
|
574
|
+
gen.else();
|
|
575
|
+
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag }, { instancePath: schema, schemaPath: "mapping", parentSchema: true });
|
|
576
|
+
gen.endIf();
|
|
577
|
+
}
|
|
578
|
+
function applyTagSchema(schemaProp) {
|
|
579
|
+
const _valid = gen.name("valid");
|
|
580
|
+
cxt.subschema({
|
|
581
|
+
keyword: "mapping",
|
|
582
|
+
schemaProp,
|
|
583
|
+
jtdDiscriminator: schema
|
|
584
|
+
}, _valid);
|
|
585
|
+
return _valid;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
exports.default = def;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/values.js
|
|
594
|
+
var require_values = __commonJS({
|
|
595
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/values.js"(exports) {
|
|
596
|
+
"use strict";
|
|
597
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
598
|
+
var util_1 = require_util();
|
|
599
|
+
var codegen_1 = require_codegen();
|
|
600
|
+
var metadata_1 = require_metadata();
|
|
601
|
+
var nullable_1 = require_nullable();
|
|
602
|
+
var error_1 = require_error();
|
|
603
|
+
var def = {
|
|
604
|
+
keyword: "values",
|
|
605
|
+
schemaType: "object",
|
|
606
|
+
error: (0, error_1.typeError)("object"),
|
|
607
|
+
code(cxt) {
|
|
608
|
+
(0, metadata_1.checkMetadata)(cxt);
|
|
609
|
+
const { gen, data, schema, it } = cxt;
|
|
610
|
+
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
|
|
611
|
+
if ((0, util_1.alwaysValidSchema)(it, schema)) {
|
|
612
|
+
gen.if((0, codegen_1.not)((0, codegen_1.or)(cond, valid)), () => cxt.error());
|
|
613
|
+
} else {
|
|
614
|
+
gen.if(cond);
|
|
615
|
+
gen.assign(valid, validateMap());
|
|
616
|
+
gen.elseIf((0, codegen_1.not)(valid));
|
|
617
|
+
cxt.error();
|
|
618
|
+
gen.endIf();
|
|
619
|
+
}
|
|
620
|
+
cxt.ok(valid);
|
|
621
|
+
function validateMap() {
|
|
622
|
+
const _valid = gen.name("valid");
|
|
623
|
+
if (it.allErrors) {
|
|
624
|
+
const validMap = gen.let("valid", true);
|
|
625
|
+
validateValues(() => gen.assign(validMap, false));
|
|
626
|
+
return validMap;
|
|
627
|
+
}
|
|
628
|
+
gen.var(_valid, true);
|
|
629
|
+
validateValues(() => gen.break());
|
|
630
|
+
return _valid;
|
|
631
|
+
function validateValues(notValid) {
|
|
632
|
+
gen.forIn("key", data, (key) => {
|
|
633
|
+
cxt.subschema({
|
|
634
|
+
keyword: "values",
|
|
635
|
+
dataProp: key,
|
|
636
|
+
dataPropType: util_1.Type.Str
|
|
637
|
+
}, _valid);
|
|
638
|
+
gen.if((0, codegen_1.not)(_valid), notValid);
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
exports.default = def;
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/union.js
|
|
649
|
+
var require_union = __commonJS({
|
|
650
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/union.js"(exports) {
|
|
651
|
+
"use strict";
|
|
652
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
653
|
+
var code_1 = require_code();
|
|
654
|
+
var def = {
|
|
655
|
+
keyword: "union",
|
|
656
|
+
schemaType: "array",
|
|
657
|
+
trackErrors: true,
|
|
658
|
+
code: code_1.validateUnion,
|
|
659
|
+
error: { message: "must match a schema in union" }
|
|
660
|
+
};
|
|
661
|
+
exports.default = def;
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/index.js
|
|
666
|
+
var require_jtd = __commonJS({
|
|
667
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/jtd/index.js"(exports) {
|
|
668
|
+
"use strict";
|
|
669
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
670
|
+
var ref_1 = require_ref2();
|
|
671
|
+
var type_1 = require_type();
|
|
672
|
+
var enum_1 = require_enum();
|
|
673
|
+
var elements_1 = require_elements();
|
|
674
|
+
var properties_1 = require_properties();
|
|
675
|
+
var optionalProperties_1 = require_optionalProperties();
|
|
676
|
+
var discriminator_1 = require_discriminator();
|
|
677
|
+
var values_1 = require_values();
|
|
678
|
+
var union_1 = require_union();
|
|
679
|
+
var metadata_1 = require_metadata();
|
|
680
|
+
var jtdVocabulary = [
|
|
681
|
+
"definitions",
|
|
682
|
+
ref_1.default,
|
|
683
|
+
type_1.default,
|
|
684
|
+
enum_1.default,
|
|
685
|
+
elements_1.default,
|
|
686
|
+
properties_1.default,
|
|
687
|
+
optionalProperties_1.default,
|
|
688
|
+
discriminator_1.default,
|
|
689
|
+
values_1.default,
|
|
690
|
+
union_1.default,
|
|
691
|
+
metadata_1.default,
|
|
692
|
+
{ keyword: "additionalProperties", schemaType: "boolean" },
|
|
693
|
+
{ keyword: "nullable", schemaType: "boolean" }
|
|
694
|
+
];
|
|
695
|
+
exports.default = jtdVocabulary;
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/refs/jtd-schema.js
|
|
700
|
+
var require_jtd_schema = __commonJS({
|
|
701
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/refs/jtd-schema.js"(exports) {
|
|
702
|
+
"use strict";
|
|
703
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
704
|
+
var shared = (root) => {
|
|
705
|
+
const sch = {
|
|
706
|
+
nullable: { type: "boolean" },
|
|
707
|
+
metadata: {
|
|
708
|
+
optionalProperties: {
|
|
709
|
+
union: { elements: { ref: "schema" } }
|
|
710
|
+
},
|
|
711
|
+
additionalProperties: true
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
if (root)
|
|
715
|
+
sch.definitions = { values: { ref: "schema" } };
|
|
716
|
+
return sch;
|
|
717
|
+
};
|
|
718
|
+
var emptyForm = (root) => ({
|
|
719
|
+
optionalProperties: shared(root)
|
|
720
|
+
});
|
|
721
|
+
var refForm = (root) => ({
|
|
722
|
+
properties: {
|
|
723
|
+
ref: { type: "string" }
|
|
724
|
+
},
|
|
725
|
+
optionalProperties: shared(root)
|
|
726
|
+
});
|
|
727
|
+
var typeForm = (root) => ({
|
|
728
|
+
properties: {
|
|
729
|
+
type: {
|
|
730
|
+
enum: [
|
|
731
|
+
"boolean",
|
|
732
|
+
"timestamp",
|
|
733
|
+
"string",
|
|
734
|
+
"float32",
|
|
735
|
+
"float64",
|
|
736
|
+
"int8",
|
|
737
|
+
"uint8",
|
|
738
|
+
"int16",
|
|
739
|
+
"uint16",
|
|
740
|
+
"int32",
|
|
741
|
+
"uint32"
|
|
742
|
+
]
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
optionalProperties: shared(root)
|
|
746
|
+
});
|
|
747
|
+
var enumForm = (root) => ({
|
|
748
|
+
properties: {
|
|
749
|
+
enum: { elements: { type: "string" } }
|
|
750
|
+
},
|
|
751
|
+
optionalProperties: shared(root)
|
|
752
|
+
});
|
|
753
|
+
var elementsForm = (root) => ({
|
|
754
|
+
properties: {
|
|
755
|
+
elements: { ref: "schema" }
|
|
756
|
+
},
|
|
757
|
+
optionalProperties: shared(root)
|
|
758
|
+
});
|
|
759
|
+
var propertiesForm = (root) => ({
|
|
760
|
+
properties: {
|
|
761
|
+
properties: { values: { ref: "schema" } }
|
|
762
|
+
},
|
|
763
|
+
optionalProperties: {
|
|
764
|
+
optionalProperties: { values: { ref: "schema" } },
|
|
765
|
+
additionalProperties: { type: "boolean" },
|
|
766
|
+
...shared(root)
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
var optionalPropertiesForm = (root) => ({
|
|
770
|
+
properties: {
|
|
771
|
+
optionalProperties: { values: { ref: "schema" } }
|
|
772
|
+
},
|
|
773
|
+
optionalProperties: {
|
|
774
|
+
additionalProperties: { type: "boolean" },
|
|
775
|
+
...shared(root)
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
var discriminatorForm = (root) => ({
|
|
779
|
+
properties: {
|
|
780
|
+
discriminator: { type: "string" },
|
|
781
|
+
mapping: {
|
|
782
|
+
values: {
|
|
783
|
+
metadata: {
|
|
784
|
+
union: [propertiesForm(false), optionalPropertiesForm(false)]
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
optionalProperties: shared(root)
|
|
790
|
+
});
|
|
791
|
+
var valuesForm = (root) => ({
|
|
792
|
+
properties: {
|
|
793
|
+
values: { ref: "schema" }
|
|
794
|
+
},
|
|
795
|
+
optionalProperties: shared(root)
|
|
796
|
+
});
|
|
797
|
+
var schema = (root) => ({
|
|
798
|
+
metadata: {
|
|
799
|
+
union: [
|
|
800
|
+
emptyForm,
|
|
801
|
+
refForm,
|
|
802
|
+
typeForm,
|
|
803
|
+
enumForm,
|
|
804
|
+
elementsForm,
|
|
805
|
+
propertiesForm,
|
|
806
|
+
optionalPropertiesForm,
|
|
807
|
+
discriminatorForm,
|
|
808
|
+
valuesForm
|
|
809
|
+
].map((s) => s(root))
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
var jtdMetaSchema = {
|
|
813
|
+
definitions: {
|
|
814
|
+
schema: schema(false)
|
|
815
|
+
},
|
|
816
|
+
...schema(true)
|
|
817
|
+
};
|
|
818
|
+
exports.default = jtdMetaSchema;
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/types.js
|
|
823
|
+
var require_types2 = __commonJS({
|
|
824
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/types.js"(exports) {
|
|
825
|
+
"use strict";
|
|
826
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
827
|
+
exports.jtdForms = void 0;
|
|
828
|
+
exports.jtdForms = [
|
|
829
|
+
"elements",
|
|
830
|
+
"values",
|
|
831
|
+
"discriminator",
|
|
832
|
+
"properties",
|
|
833
|
+
"optionalProperties",
|
|
834
|
+
"enum",
|
|
835
|
+
"type",
|
|
836
|
+
"ref"
|
|
837
|
+
];
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/quote.js
|
|
842
|
+
var require_quote = __commonJS({
|
|
843
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/quote.js"(exports) {
|
|
844
|
+
"use strict";
|
|
845
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
846
|
+
var rxEscapable = (
|
|
847
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
848
|
+
/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g
|
|
849
|
+
);
|
|
850
|
+
var escaped = {
|
|
851
|
+
"\b": "\\b",
|
|
852
|
+
" ": "\\t",
|
|
853
|
+
"\n": "\\n",
|
|
854
|
+
"\f": "\\f",
|
|
855
|
+
"\r": "\\r",
|
|
856
|
+
'"': '\\"',
|
|
857
|
+
"\\": "\\\\"
|
|
858
|
+
};
|
|
859
|
+
function quote(s) {
|
|
860
|
+
rxEscapable.lastIndex = 0;
|
|
861
|
+
return '"' + (rxEscapable.test(s) ? s.replace(rxEscapable, (a) => {
|
|
862
|
+
const c = escaped[a];
|
|
863
|
+
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
864
|
+
}) : s) + '"';
|
|
865
|
+
}
|
|
866
|
+
exports.default = quote;
|
|
867
|
+
quote.code = 'require("ajv/dist/runtime/quote").default';
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/serialize.js
|
|
872
|
+
var require_serialize = __commonJS({
|
|
873
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/serialize.js"(exports) {
|
|
874
|
+
"use strict";
|
|
875
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
876
|
+
var types_1 = require_types2();
|
|
877
|
+
var __1 = require_compile();
|
|
878
|
+
var codegen_1 = require_codegen();
|
|
879
|
+
var ref_error_1 = require_ref_error();
|
|
880
|
+
var names_1 = require_names();
|
|
881
|
+
var code_1 = require_code();
|
|
882
|
+
var ref_1 = require_ref2();
|
|
883
|
+
var util_1 = require_util();
|
|
884
|
+
var quote_1 = require_quote();
|
|
885
|
+
var genSerialize = {
|
|
886
|
+
elements: serializeElements,
|
|
887
|
+
values: serializeValues,
|
|
888
|
+
discriminator: serializeDiscriminator,
|
|
889
|
+
properties: serializeProperties,
|
|
890
|
+
optionalProperties: serializeProperties,
|
|
891
|
+
enum: serializeString,
|
|
892
|
+
type: serializeType,
|
|
893
|
+
ref: serializeRef
|
|
894
|
+
};
|
|
895
|
+
function compileSerializer(sch, definitions) {
|
|
896
|
+
const _sch = __1.getCompilingSchema.call(this, sch);
|
|
897
|
+
if (_sch)
|
|
898
|
+
return _sch;
|
|
899
|
+
const { es5, lines } = this.opts.code;
|
|
900
|
+
const { ownProperties } = this.opts;
|
|
901
|
+
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties });
|
|
902
|
+
const serializeName = gen.scopeName("serialize");
|
|
903
|
+
const cxt = {
|
|
904
|
+
self: this,
|
|
905
|
+
gen,
|
|
906
|
+
schema: sch.schema,
|
|
907
|
+
schemaEnv: sch,
|
|
908
|
+
definitions,
|
|
909
|
+
data: names_1.default.data
|
|
910
|
+
};
|
|
911
|
+
let sourceCode;
|
|
912
|
+
try {
|
|
913
|
+
this._compilations.add(sch);
|
|
914
|
+
sch.serializeName = serializeName;
|
|
915
|
+
gen.func(serializeName, names_1.default.data, false, () => {
|
|
916
|
+
gen.let(names_1.default.json, (0, codegen_1.str)``);
|
|
917
|
+
serializeCode(cxt);
|
|
918
|
+
gen.return(names_1.default.json);
|
|
919
|
+
});
|
|
920
|
+
gen.optimize(this.opts.code.optimize);
|
|
921
|
+
const serializeFuncCode = gen.toString();
|
|
922
|
+
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${serializeFuncCode}`;
|
|
923
|
+
const makeSerialize = new Function(`${names_1.default.scope}`, sourceCode);
|
|
924
|
+
const serialize = makeSerialize(this.scope.get());
|
|
925
|
+
this.scope.value(serializeName, { ref: serialize });
|
|
926
|
+
sch.serialize = serialize;
|
|
927
|
+
} catch (e) {
|
|
928
|
+
if (sourceCode)
|
|
929
|
+
this.logger.error("Error compiling serializer, function code:", sourceCode);
|
|
930
|
+
delete sch.serialize;
|
|
931
|
+
delete sch.serializeName;
|
|
932
|
+
throw e;
|
|
933
|
+
} finally {
|
|
934
|
+
this._compilations.delete(sch);
|
|
935
|
+
}
|
|
936
|
+
return sch;
|
|
937
|
+
}
|
|
938
|
+
exports.default = compileSerializer;
|
|
939
|
+
function serializeCode(cxt) {
|
|
940
|
+
let form;
|
|
941
|
+
for (const key of types_1.jtdForms) {
|
|
942
|
+
if (key in cxt.schema) {
|
|
943
|
+
form = key;
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
serializeNullable(cxt, form ? genSerialize[form] : serializeEmpty);
|
|
948
|
+
}
|
|
949
|
+
function serializeNullable(cxt, serializeForm) {
|
|
950
|
+
const { gen, schema, data } = cxt;
|
|
951
|
+
if (!schema.nullable)
|
|
952
|
+
return serializeForm(cxt);
|
|
953
|
+
gen.if((0, codegen_1._)`${data} === undefined || ${data} === null`, () => gen.add(names_1.default.json, (0, codegen_1._)`"null"`), () => serializeForm(cxt));
|
|
954
|
+
}
|
|
955
|
+
function serializeElements(cxt) {
|
|
956
|
+
const { gen, schema, data } = cxt;
|
|
957
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`[`);
|
|
958
|
+
const first = gen.let("first", true);
|
|
959
|
+
gen.forOf("el", data, (el) => {
|
|
960
|
+
addComma(cxt, first);
|
|
961
|
+
serializeCode({ ...cxt, schema: schema.elements, data: el });
|
|
962
|
+
});
|
|
963
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`]`);
|
|
964
|
+
}
|
|
965
|
+
function serializeValues(cxt) {
|
|
966
|
+
const { gen, schema, data } = cxt;
|
|
967
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`{`);
|
|
968
|
+
const first = gen.let("first", true);
|
|
969
|
+
gen.forIn("key", data, (key) => serializeKeyValue(cxt, key, schema.values, first));
|
|
970
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`}`);
|
|
971
|
+
}
|
|
972
|
+
function serializeKeyValue(cxt, key, schema, first) {
|
|
973
|
+
const { gen, data } = cxt;
|
|
974
|
+
addComma(cxt, first);
|
|
975
|
+
serializeString({ ...cxt, data: key });
|
|
976
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`:`);
|
|
977
|
+
const value = gen.const("value", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(key)}`);
|
|
978
|
+
serializeCode({ ...cxt, schema, data: value });
|
|
979
|
+
}
|
|
980
|
+
function serializeDiscriminator(cxt) {
|
|
981
|
+
const { gen, schema, data } = cxt;
|
|
982
|
+
const { discriminator } = schema;
|
|
983
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`{${JSON.stringify(discriminator)}:`);
|
|
984
|
+
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(discriminator)}`);
|
|
985
|
+
serializeString({ ...cxt, data: tag });
|
|
986
|
+
gen.if(false);
|
|
987
|
+
for (const tagValue in schema.mapping) {
|
|
988
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
|
|
989
|
+
const sch = schema.mapping[tagValue];
|
|
990
|
+
serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);
|
|
991
|
+
}
|
|
992
|
+
gen.endIf();
|
|
993
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`}`);
|
|
994
|
+
}
|
|
995
|
+
function serializeProperties(cxt) {
|
|
996
|
+
const { gen } = cxt;
|
|
997
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`{`);
|
|
998
|
+
serializeSchemaProperties(cxt);
|
|
999
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`}`);
|
|
1000
|
+
}
|
|
1001
|
+
function serializeSchemaProperties(cxt, discriminator) {
|
|
1002
|
+
const { gen, schema, data } = cxt;
|
|
1003
|
+
const { properties, optionalProperties } = schema;
|
|
1004
|
+
const props = keys(properties);
|
|
1005
|
+
const optProps = keys(optionalProperties);
|
|
1006
|
+
const allProps = allProperties(props.concat(optProps));
|
|
1007
|
+
let first = !discriminator;
|
|
1008
|
+
let firstProp;
|
|
1009
|
+
for (const key of props) {
|
|
1010
|
+
if (first)
|
|
1011
|
+
first = false;
|
|
1012
|
+
else
|
|
1013
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`,`);
|
|
1014
|
+
serializeProperty(key, properties[key], keyValue(key));
|
|
1015
|
+
}
|
|
1016
|
+
if (first)
|
|
1017
|
+
firstProp = gen.let("first", true);
|
|
1018
|
+
for (const key of optProps) {
|
|
1019
|
+
const value = keyValue(key);
|
|
1020
|
+
gen.if((0, codegen_1.and)((0, codegen_1._)`${value} !== undefined`, (0, code_1.isOwnProperty)(gen, data, key)), () => {
|
|
1021
|
+
addComma(cxt, firstProp);
|
|
1022
|
+
serializeProperty(key, optionalProperties[key], value);
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
if (schema.additionalProperties) {
|
|
1026
|
+
gen.forIn("key", data, (key) => gen.if(isAdditional(key, allProps), () => serializeKeyValue(cxt, key, {}, firstProp)));
|
|
1027
|
+
}
|
|
1028
|
+
function keys(ps) {
|
|
1029
|
+
return ps ? Object.keys(ps) : [];
|
|
1030
|
+
}
|
|
1031
|
+
function allProperties(ps) {
|
|
1032
|
+
if (discriminator)
|
|
1033
|
+
ps.push(discriminator);
|
|
1034
|
+
if (new Set(ps).size !== ps.length) {
|
|
1035
|
+
throw new Error("JTD: properties/optionalProperties/disciminator overlap");
|
|
1036
|
+
}
|
|
1037
|
+
return ps;
|
|
1038
|
+
}
|
|
1039
|
+
function keyValue(key) {
|
|
1040
|
+
return gen.const("value", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(key)}`);
|
|
1041
|
+
}
|
|
1042
|
+
function serializeProperty(key, propSchema, value) {
|
|
1043
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`${JSON.stringify(key)}:`);
|
|
1044
|
+
serializeCode({ ...cxt, schema: propSchema, data: value });
|
|
1045
|
+
}
|
|
1046
|
+
function isAdditional(key, ps) {
|
|
1047
|
+
return ps.length ? (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._)`${key} !== ${p}`)) : true;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
function serializeType(cxt) {
|
|
1051
|
+
const { gen, schema, data } = cxt;
|
|
1052
|
+
switch (schema.type) {
|
|
1053
|
+
case "boolean":
|
|
1054
|
+
gen.add(names_1.default.json, (0, codegen_1._)`${data} ? "true" : "false"`);
|
|
1055
|
+
break;
|
|
1056
|
+
case "string":
|
|
1057
|
+
serializeString(cxt);
|
|
1058
|
+
break;
|
|
1059
|
+
case "timestamp":
|
|
1060
|
+
gen.if((0, codegen_1._)`${data} instanceof Date`, () => gen.add(names_1.default.json, (0, codegen_1._)`'"' + ${data}.toISOString() + '"'`), () => serializeString(cxt));
|
|
1061
|
+
break;
|
|
1062
|
+
default:
|
|
1063
|
+
serializeNumber(cxt);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
function serializeString({ gen, data }) {
|
|
1067
|
+
gen.add(names_1.default.json, (0, codegen_1._)`${(0, util_1.useFunc)(gen, quote_1.default)}(${data})`);
|
|
1068
|
+
}
|
|
1069
|
+
function serializeNumber({ gen, data, self }) {
|
|
1070
|
+
const condition = (0, codegen_1._)`${data} === Infinity || ${data} === -Infinity || ${data} !== ${data}`;
|
|
1071
|
+
if (self.opts.specialNumbers === void 0 || self.opts.specialNumbers === "fast") {
|
|
1072
|
+
gen.add(names_1.default.json, (0, codegen_1._)`"" + ${data}`);
|
|
1073
|
+
} else {
|
|
1074
|
+
gen.if(condition, () => gen.add(names_1.default.json, (0, codegen_1._)`null`), () => gen.add(names_1.default.json, (0, codegen_1._)`"" + ${data}`));
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function serializeRef(cxt) {
|
|
1078
|
+
const { gen, self, data, definitions, schema, schemaEnv } = cxt;
|
|
1079
|
+
const { ref } = schema;
|
|
1080
|
+
const refSchema = definitions[ref];
|
|
1081
|
+
if (!refSchema)
|
|
1082
|
+
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
1083
|
+
if (!(0, ref_1.hasRef)(refSchema))
|
|
1084
|
+
return serializeCode({ ...cxt, schema: refSchema });
|
|
1085
|
+
const { root } = schemaEnv;
|
|
1086
|
+
const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
|
|
1087
|
+
gen.add(names_1.default.json, (0, codegen_1._)`${getSerialize(gen, sch)}(${data})`);
|
|
1088
|
+
}
|
|
1089
|
+
function getSerialize(gen, sch) {
|
|
1090
|
+
return sch.serialize ? gen.scopeValue("serialize", { ref: sch.serialize }) : (0, codegen_1._)`${gen.scopeValue("wrapper", { ref: sch })}.serialize`;
|
|
1091
|
+
}
|
|
1092
|
+
function serializeEmpty({ gen, data }) {
|
|
1093
|
+
gen.add(names_1.default.json, (0, codegen_1._)`JSON.stringify(${data})`);
|
|
1094
|
+
}
|
|
1095
|
+
function addComma({ gen }, first) {
|
|
1096
|
+
if (first) {
|
|
1097
|
+
gen.if(first, () => gen.assign(first, false), () => gen.add(names_1.default.json, (0, codegen_1.str)`,`));
|
|
1098
|
+
} else {
|
|
1099
|
+
gen.add(names_1.default.json, (0, codegen_1.str)`,`);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/parseJson.js
|
|
1106
|
+
var require_parseJson = __commonJS({
|
|
1107
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/parseJson.js"(exports) {
|
|
1108
|
+
"use strict";
|
|
1109
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1110
|
+
exports.parseJsonString = exports.parseJsonNumber = exports.parseJson = void 0;
|
|
1111
|
+
var rxParseJson = /position\s(\d+)(?: \(line \d+ column \d+\))?$/;
|
|
1112
|
+
function parseJson(s, pos) {
|
|
1113
|
+
let endPos;
|
|
1114
|
+
parseJson.message = void 0;
|
|
1115
|
+
let matches;
|
|
1116
|
+
if (pos)
|
|
1117
|
+
s = s.slice(pos);
|
|
1118
|
+
try {
|
|
1119
|
+
parseJson.position = pos + s.length;
|
|
1120
|
+
return JSON.parse(s);
|
|
1121
|
+
} catch (e) {
|
|
1122
|
+
matches = rxParseJson.exec(e.message);
|
|
1123
|
+
if (!matches) {
|
|
1124
|
+
parseJson.message = "unexpected end";
|
|
1125
|
+
return void 0;
|
|
1126
|
+
}
|
|
1127
|
+
endPos = +matches[1];
|
|
1128
|
+
const c = s[endPos];
|
|
1129
|
+
s = s.slice(0, endPos);
|
|
1130
|
+
parseJson.position = pos + endPos;
|
|
1131
|
+
try {
|
|
1132
|
+
return JSON.parse(s);
|
|
1133
|
+
} catch (e1) {
|
|
1134
|
+
parseJson.message = `unexpected token ${c}`;
|
|
1135
|
+
return void 0;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
exports.parseJson = parseJson;
|
|
1140
|
+
parseJson.message = void 0;
|
|
1141
|
+
parseJson.position = 0;
|
|
1142
|
+
parseJson.code = 'require("ajv/dist/runtime/parseJson").parseJson';
|
|
1143
|
+
function parseJsonNumber(s, pos, maxDigits) {
|
|
1144
|
+
let numStr = "";
|
|
1145
|
+
let c;
|
|
1146
|
+
parseJsonNumber.message = void 0;
|
|
1147
|
+
if (s[pos] === "-") {
|
|
1148
|
+
numStr += "-";
|
|
1149
|
+
pos++;
|
|
1150
|
+
}
|
|
1151
|
+
if (s[pos] === "0") {
|
|
1152
|
+
numStr += "0";
|
|
1153
|
+
pos++;
|
|
1154
|
+
} else {
|
|
1155
|
+
if (!parseDigits(maxDigits)) {
|
|
1156
|
+
errorMessage();
|
|
1157
|
+
return void 0;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
if (maxDigits) {
|
|
1161
|
+
parseJsonNumber.position = pos;
|
|
1162
|
+
return +numStr;
|
|
1163
|
+
}
|
|
1164
|
+
if (s[pos] === ".") {
|
|
1165
|
+
numStr += ".";
|
|
1166
|
+
pos++;
|
|
1167
|
+
if (!parseDigits()) {
|
|
1168
|
+
errorMessage();
|
|
1169
|
+
return void 0;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (c = s[pos], c === "e" || c === "E") {
|
|
1173
|
+
numStr += "e";
|
|
1174
|
+
pos++;
|
|
1175
|
+
if (c = s[pos], c === "+" || c === "-") {
|
|
1176
|
+
numStr += c;
|
|
1177
|
+
pos++;
|
|
1178
|
+
}
|
|
1179
|
+
if (!parseDigits()) {
|
|
1180
|
+
errorMessage();
|
|
1181
|
+
return void 0;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
parseJsonNumber.position = pos;
|
|
1185
|
+
return +numStr;
|
|
1186
|
+
function parseDigits(maxLen) {
|
|
1187
|
+
let digit = false;
|
|
1188
|
+
while (c = s[pos], c >= "0" && c <= "9" && (maxLen === void 0 || maxLen-- > 0)) {
|
|
1189
|
+
digit = true;
|
|
1190
|
+
numStr += c;
|
|
1191
|
+
pos++;
|
|
1192
|
+
}
|
|
1193
|
+
return digit;
|
|
1194
|
+
}
|
|
1195
|
+
function errorMessage() {
|
|
1196
|
+
parseJsonNumber.position = pos;
|
|
1197
|
+
parseJsonNumber.message = pos < s.length ? `unexpected token ${s[pos]}` : "unexpected end";
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
exports.parseJsonNumber = parseJsonNumber;
|
|
1201
|
+
parseJsonNumber.message = void 0;
|
|
1202
|
+
parseJsonNumber.position = 0;
|
|
1203
|
+
parseJsonNumber.code = 'require("ajv/dist/runtime/parseJson").parseJsonNumber';
|
|
1204
|
+
var escapedChars = {
|
|
1205
|
+
b: "\b",
|
|
1206
|
+
f: "\f",
|
|
1207
|
+
n: "\n",
|
|
1208
|
+
r: "\r",
|
|
1209
|
+
t: " ",
|
|
1210
|
+
'"': '"',
|
|
1211
|
+
"/": "/",
|
|
1212
|
+
"\\": "\\"
|
|
1213
|
+
};
|
|
1214
|
+
var CODE_A = "a".charCodeAt(0);
|
|
1215
|
+
var CODE_0 = "0".charCodeAt(0);
|
|
1216
|
+
function parseJsonString(s, pos) {
|
|
1217
|
+
let str = "";
|
|
1218
|
+
let c;
|
|
1219
|
+
parseJsonString.message = void 0;
|
|
1220
|
+
while (true) {
|
|
1221
|
+
c = s[pos++];
|
|
1222
|
+
if (c === '"')
|
|
1223
|
+
break;
|
|
1224
|
+
if (c === "\\") {
|
|
1225
|
+
c = s[pos];
|
|
1226
|
+
if (c in escapedChars) {
|
|
1227
|
+
str += escapedChars[c];
|
|
1228
|
+
pos++;
|
|
1229
|
+
} else if (c === "u") {
|
|
1230
|
+
pos++;
|
|
1231
|
+
let count = 4;
|
|
1232
|
+
let code = 0;
|
|
1233
|
+
while (count--) {
|
|
1234
|
+
code <<= 4;
|
|
1235
|
+
c = s[pos];
|
|
1236
|
+
if (c === void 0) {
|
|
1237
|
+
errorMessage("unexpected end");
|
|
1238
|
+
return void 0;
|
|
1239
|
+
}
|
|
1240
|
+
c = c.toLowerCase();
|
|
1241
|
+
if (c >= "a" && c <= "f") {
|
|
1242
|
+
code += c.charCodeAt(0) - CODE_A + 10;
|
|
1243
|
+
} else if (c >= "0" && c <= "9") {
|
|
1244
|
+
code += c.charCodeAt(0) - CODE_0;
|
|
1245
|
+
} else {
|
|
1246
|
+
errorMessage(`unexpected token ${c}`);
|
|
1247
|
+
return void 0;
|
|
1248
|
+
}
|
|
1249
|
+
pos++;
|
|
1250
|
+
}
|
|
1251
|
+
str += String.fromCharCode(code);
|
|
1252
|
+
} else {
|
|
1253
|
+
errorMessage(`unexpected token ${c}`);
|
|
1254
|
+
return void 0;
|
|
1255
|
+
}
|
|
1256
|
+
} else if (c === void 0) {
|
|
1257
|
+
errorMessage("unexpected end");
|
|
1258
|
+
return void 0;
|
|
1259
|
+
} else {
|
|
1260
|
+
if (c.charCodeAt(0) >= 32) {
|
|
1261
|
+
str += c;
|
|
1262
|
+
} else {
|
|
1263
|
+
errorMessage(`unexpected token ${c}`);
|
|
1264
|
+
return void 0;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
parseJsonString.position = pos;
|
|
1269
|
+
return str;
|
|
1270
|
+
function errorMessage(msg) {
|
|
1271
|
+
parseJsonString.position = pos;
|
|
1272
|
+
parseJsonString.message = msg;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
exports.parseJsonString = parseJsonString;
|
|
1276
|
+
parseJsonString.message = void 0;
|
|
1277
|
+
parseJsonString.position = 0;
|
|
1278
|
+
parseJsonString.code = 'require("ajv/dist/runtime/parseJson").parseJsonString';
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/parse.js
|
|
1283
|
+
var require_parse = __commonJS({
|
|
1284
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/jtd/parse.js"(exports) {
|
|
1285
|
+
"use strict";
|
|
1286
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1287
|
+
var types_1 = require_types2();
|
|
1288
|
+
var __1 = require_compile();
|
|
1289
|
+
var codegen_1 = require_codegen();
|
|
1290
|
+
var ref_error_1 = require_ref_error();
|
|
1291
|
+
var names_1 = require_names();
|
|
1292
|
+
var code_1 = require_code();
|
|
1293
|
+
var ref_1 = require_ref2();
|
|
1294
|
+
var type_1 = require_type();
|
|
1295
|
+
var parseJson_1 = require_parseJson();
|
|
1296
|
+
var util_1 = require_util();
|
|
1297
|
+
var timestamp_1 = require_timestamp();
|
|
1298
|
+
var genParse = {
|
|
1299
|
+
elements: parseElements,
|
|
1300
|
+
values: parseValues,
|
|
1301
|
+
discriminator: parseDiscriminator,
|
|
1302
|
+
properties: parseProperties,
|
|
1303
|
+
optionalProperties: parseProperties,
|
|
1304
|
+
enum: parseEnum,
|
|
1305
|
+
type: parseType,
|
|
1306
|
+
ref: parseRef
|
|
1307
|
+
};
|
|
1308
|
+
function compileParser(sch, definitions) {
|
|
1309
|
+
const _sch = __1.getCompilingSchema.call(this, sch);
|
|
1310
|
+
if (_sch)
|
|
1311
|
+
return _sch;
|
|
1312
|
+
const { es5, lines } = this.opts.code;
|
|
1313
|
+
const { ownProperties } = this.opts;
|
|
1314
|
+
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties });
|
|
1315
|
+
const parseName = gen.scopeName("parse");
|
|
1316
|
+
const cxt = {
|
|
1317
|
+
self: this,
|
|
1318
|
+
gen,
|
|
1319
|
+
schema: sch.schema,
|
|
1320
|
+
schemaEnv: sch,
|
|
1321
|
+
definitions,
|
|
1322
|
+
data: names_1.default.data,
|
|
1323
|
+
parseName,
|
|
1324
|
+
char: gen.name("c")
|
|
1325
|
+
};
|
|
1326
|
+
let sourceCode;
|
|
1327
|
+
try {
|
|
1328
|
+
this._compilations.add(sch);
|
|
1329
|
+
sch.parseName = parseName;
|
|
1330
|
+
parserFunction(cxt);
|
|
1331
|
+
gen.optimize(this.opts.code.optimize);
|
|
1332
|
+
const parseFuncCode = gen.toString();
|
|
1333
|
+
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${parseFuncCode}`;
|
|
1334
|
+
const makeParse = new Function(`${names_1.default.scope}`, sourceCode);
|
|
1335
|
+
const parse = makeParse(this.scope.get());
|
|
1336
|
+
this.scope.value(parseName, { ref: parse });
|
|
1337
|
+
sch.parse = parse;
|
|
1338
|
+
} catch (e) {
|
|
1339
|
+
if (sourceCode)
|
|
1340
|
+
this.logger.error("Error compiling parser, function code:", sourceCode);
|
|
1341
|
+
delete sch.parse;
|
|
1342
|
+
delete sch.parseName;
|
|
1343
|
+
throw e;
|
|
1344
|
+
} finally {
|
|
1345
|
+
this._compilations.delete(sch);
|
|
1346
|
+
}
|
|
1347
|
+
return sch;
|
|
1348
|
+
}
|
|
1349
|
+
exports.default = compileParser;
|
|
1350
|
+
var undef = (0, codegen_1._)`undefined`;
|
|
1351
|
+
function parserFunction(cxt) {
|
|
1352
|
+
const { gen, parseName, char } = cxt;
|
|
1353
|
+
gen.func(parseName, (0, codegen_1._)`${names_1.default.json}, ${names_1.default.jsonPos}, ${names_1.default.jsonPart}`, false, () => {
|
|
1354
|
+
gen.let(names_1.default.data);
|
|
1355
|
+
gen.let(char);
|
|
1356
|
+
gen.assign((0, codegen_1._)`${parseName}.message`, undef);
|
|
1357
|
+
gen.assign((0, codegen_1._)`${parseName}.position`, undef);
|
|
1358
|
+
gen.assign(names_1.default.jsonPos, (0, codegen_1._)`${names_1.default.jsonPos} || 0`);
|
|
1359
|
+
gen.const(names_1.default.jsonLen, (0, codegen_1._)`${names_1.default.json}.length`);
|
|
1360
|
+
parseCode(cxt);
|
|
1361
|
+
skipWhitespace(cxt);
|
|
1362
|
+
gen.if(names_1.default.jsonPart, () => {
|
|
1363
|
+
gen.assign((0, codegen_1._)`${parseName}.position`, names_1.default.jsonPos);
|
|
1364
|
+
gen.return(names_1.default.data);
|
|
1365
|
+
});
|
|
1366
|
+
gen.if((0, codegen_1._)`${names_1.default.jsonPos} === ${names_1.default.jsonLen}`, () => gen.return(names_1.default.data));
|
|
1367
|
+
jsonSyntaxError(cxt);
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
function parseCode(cxt) {
|
|
1371
|
+
let form;
|
|
1372
|
+
for (const key of types_1.jtdForms) {
|
|
1373
|
+
if (key in cxt.schema) {
|
|
1374
|
+
form = key;
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
if (form)
|
|
1379
|
+
parseNullable(cxt, genParse[form]);
|
|
1380
|
+
else
|
|
1381
|
+
parseEmpty(cxt);
|
|
1382
|
+
}
|
|
1383
|
+
var parseBoolean = parseBooleanToken(true, parseBooleanToken(false, jsonSyntaxError));
|
|
1384
|
+
function parseNullable(cxt, parseForm) {
|
|
1385
|
+
const { gen, schema, data } = cxt;
|
|
1386
|
+
if (!schema.nullable)
|
|
1387
|
+
return parseForm(cxt);
|
|
1388
|
+
tryParseToken(cxt, "null", parseForm, () => gen.assign(data, null));
|
|
1389
|
+
}
|
|
1390
|
+
function parseElements(cxt) {
|
|
1391
|
+
const { gen, schema, data } = cxt;
|
|
1392
|
+
parseToken(cxt, "[");
|
|
1393
|
+
const ix = gen.let("i", 0);
|
|
1394
|
+
gen.assign(data, (0, codegen_1._)`[]`);
|
|
1395
|
+
parseItems(cxt, "]", () => {
|
|
1396
|
+
const el = gen.let("el");
|
|
1397
|
+
parseCode({ ...cxt, schema: schema.elements, data: el });
|
|
1398
|
+
gen.assign((0, codegen_1._)`${data}[${ix}++]`, el);
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
function parseValues(cxt) {
|
|
1402
|
+
const { gen, schema, data } = cxt;
|
|
1403
|
+
parseToken(cxt, "{");
|
|
1404
|
+
gen.assign(data, (0, codegen_1._)`{}`);
|
|
1405
|
+
parseItems(cxt, "}", () => parseKeyValue(cxt, schema.values));
|
|
1406
|
+
}
|
|
1407
|
+
function parseItems(cxt, endToken, block) {
|
|
1408
|
+
tryParseItems(cxt, endToken, block);
|
|
1409
|
+
parseToken(cxt, endToken);
|
|
1410
|
+
}
|
|
1411
|
+
function tryParseItems(cxt, endToken, block) {
|
|
1412
|
+
const { gen } = cxt;
|
|
1413
|
+
gen.for((0, codegen_1._)`;${names_1.default.jsonPos}<${names_1.default.jsonLen} && ${jsonSlice(1)}!==${endToken};`, () => {
|
|
1414
|
+
block();
|
|
1415
|
+
tryParseToken(cxt, ",", () => gen.break(), hasItem);
|
|
1416
|
+
});
|
|
1417
|
+
function hasItem() {
|
|
1418
|
+
tryParseToken(cxt, endToken, () => {
|
|
1419
|
+
}, jsonSyntaxError);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
function parseKeyValue(cxt, schema) {
|
|
1423
|
+
const { gen } = cxt;
|
|
1424
|
+
const key = gen.let("key");
|
|
1425
|
+
parseString({ ...cxt, data: key });
|
|
1426
|
+
parseToken(cxt, ":");
|
|
1427
|
+
parsePropertyValue(cxt, key, schema);
|
|
1428
|
+
}
|
|
1429
|
+
function parseDiscriminator(cxt) {
|
|
1430
|
+
const { gen, data, schema } = cxt;
|
|
1431
|
+
const { discriminator, mapping } = schema;
|
|
1432
|
+
parseToken(cxt, "{");
|
|
1433
|
+
gen.assign(data, (0, codegen_1._)`{}`);
|
|
1434
|
+
const startPos = gen.const("pos", names_1.default.jsonPos);
|
|
1435
|
+
const value = gen.let("value");
|
|
1436
|
+
const tag = gen.let("tag");
|
|
1437
|
+
tryParseItems(cxt, "}", () => {
|
|
1438
|
+
const key = gen.let("key");
|
|
1439
|
+
parseString({ ...cxt, data: key });
|
|
1440
|
+
parseToken(cxt, ":");
|
|
1441
|
+
gen.if(
|
|
1442
|
+
(0, codegen_1._)`${key} === ${discriminator}`,
|
|
1443
|
+
() => {
|
|
1444
|
+
parseString({ ...cxt, data: tag });
|
|
1445
|
+
gen.assign((0, codegen_1._)`${data}[${key}]`, tag);
|
|
1446
|
+
gen.break();
|
|
1447
|
+
},
|
|
1448
|
+
() => parseEmpty({ ...cxt, data: value })
|
|
1449
|
+
// can be discarded/skipped
|
|
1450
|
+
);
|
|
1451
|
+
});
|
|
1452
|
+
gen.assign(names_1.default.jsonPos, startPos);
|
|
1453
|
+
gen.if((0, codegen_1._)`${tag} === undefined`);
|
|
1454
|
+
parsingError(cxt, (0, codegen_1.str)`discriminator tag not found`);
|
|
1455
|
+
for (const tagValue in mapping) {
|
|
1456
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
|
|
1457
|
+
parseSchemaProperties({ ...cxt, schema: mapping[tagValue] }, discriminator);
|
|
1458
|
+
}
|
|
1459
|
+
gen.else();
|
|
1460
|
+
parsingError(cxt, (0, codegen_1.str)`discriminator value not in schema`);
|
|
1461
|
+
gen.endIf();
|
|
1462
|
+
}
|
|
1463
|
+
function parseProperties(cxt) {
|
|
1464
|
+
const { gen, data } = cxt;
|
|
1465
|
+
parseToken(cxt, "{");
|
|
1466
|
+
gen.assign(data, (0, codegen_1._)`{}`);
|
|
1467
|
+
parseSchemaProperties(cxt);
|
|
1468
|
+
}
|
|
1469
|
+
function parseSchemaProperties(cxt, discriminator) {
|
|
1470
|
+
const { gen, schema, data } = cxt;
|
|
1471
|
+
const { properties, optionalProperties, additionalProperties } = schema;
|
|
1472
|
+
parseItems(cxt, "}", () => {
|
|
1473
|
+
const key = gen.let("key");
|
|
1474
|
+
parseString({ ...cxt, data: key });
|
|
1475
|
+
parseToken(cxt, ":");
|
|
1476
|
+
gen.if(false);
|
|
1477
|
+
parseDefinedProperty(cxt, key, properties);
|
|
1478
|
+
parseDefinedProperty(cxt, key, optionalProperties);
|
|
1479
|
+
if (discriminator) {
|
|
1480
|
+
gen.elseIf((0, codegen_1._)`${key} === ${discriminator}`);
|
|
1481
|
+
const tag = gen.let("tag");
|
|
1482
|
+
parseString({ ...cxt, data: tag });
|
|
1483
|
+
}
|
|
1484
|
+
gen.else();
|
|
1485
|
+
if (additionalProperties) {
|
|
1486
|
+
parseEmpty({ ...cxt, data: (0, codegen_1._)`${data}[${key}]` });
|
|
1487
|
+
} else {
|
|
1488
|
+
parsingError(cxt, (0, codegen_1.str)`property ${key} not allowed`);
|
|
1489
|
+
}
|
|
1490
|
+
gen.endIf();
|
|
1491
|
+
});
|
|
1492
|
+
if (properties) {
|
|
1493
|
+
const hasProp = (0, code_1.hasPropFunc)(gen);
|
|
1494
|
+
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((p) => (0, codegen_1._)`${hasProp}.call(${data}, ${p})`));
|
|
1495
|
+
gen.if((0, codegen_1.not)(allProps), () => parsingError(cxt, (0, codegen_1.str)`missing required properties`));
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
function parseDefinedProperty(cxt, key, schemas = {}) {
|
|
1499
|
+
const { gen } = cxt;
|
|
1500
|
+
for (const prop in schemas) {
|
|
1501
|
+
gen.elseIf((0, codegen_1._)`${key} === ${prop}`);
|
|
1502
|
+
parsePropertyValue(cxt, key, schemas[prop]);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function parsePropertyValue(cxt, key, schema) {
|
|
1506
|
+
parseCode({ ...cxt, schema, data: (0, codegen_1._)`${cxt.data}[${key}]` });
|
|
1507
|
+
}
|
|
1508
|
+
function parseType(cxt) {
|
|
1509
|
+
const { gen, schema, data, self } = cxt;
|
|
1510
|
+
switch (schema.type) {
|
|
1511
|
+
case "boolean":
|
|
1512
|
+
parseBoolean(cxt);
|
|
1513
|
+
break;
|
|
1514
|
+
case "string":
|
|
1515
|
+
parseString(cxt);
|
|
1516
|
+
break;
|
|
1517
|
+
case "timestamp": {
|
|
1518
|
+
parseString(cxt);
|
|
1519
|
+
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
|
|
1520
|
+
const { allowDate, parseDate } = self.opts;
|
|
1521
|
+
const notValid = allowDate ? (0, codegen_1._)`!${vts}(${data}, true)` : (0, codegen_1._)`!${vts}(${data})`;
|
|
1522
|
+
const fail = parseDate ? (0, codegen_1.or)(notValid, (0, codegen_1._)`(${data} = new Date(${data}), false)`, (0, codegen_1._)`isNaN(${data}.valueOf())`) : notValid;
|
|
1523
|
+
gen.if(fail, () => parsingError(cxt, (0, codegen_1.str)`invalid timestamp`));
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
case "float32":
|
|
1527
|
+
case "float64":
|
|
1528
|
+
parseNumber(cxt);
|
|
1529
|
+
break;
|
|
1530
|
+
default: {
|
|
1531
|
+
const t = schema.type;
|
|
1532
|
+
if (!self.opts.int32range && (t === "int32" || t === "uint32")) {
|
|
1533
|
+
parseNumber(cxt, 16);
|
|
1534
|
+
if (t === "uint32") {
|
|
1535
|
+
gen.if((0, codegen_1._)`${data} < 0`, () => parsingError(cxt, (0, codegen_1.str)`integer out of range`));
|
|
1536
|
+
}
|
|
1537
|
+
} else {
|
|
1538
|
+
const [min, max, maxDigits] = type_1.intRange[t];
|
|
1539
|
+
parseNumber(cxt, maxDigits);
|
|
1540
|
+
gen.if((0, codegen_1._)`${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, (0, codegen_1.str)`integer out of range`));
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
function parseString(cxt) {
|
|
1546
|
+
parseToken(cxt, '"');
|
|
1547
|
+
parseWith(cxt, parseJson_1.parseJsonString);
|
|
1548
|
+
}
|
|
1549
|
+
function parseEnum(cxt) {
|
|
1550
|
+
const { gen, data, schema } = cxt;
|
|
1551
|
+
const enumSch = schema.enum;
|
|
1552
|
+
parseToken(cxt, '"');
|
|
1553
|
+
gen.if(false);
|
|
1554
|
+
for (const value of enumSch) {
|
|
1555
|
+
const valueStr = JSON.stringify(value).slice(1);
|
|
1556
|
+
gen.elseIf((0, codegen_1._)`${jsonSlice(valueStr.length)} === ${valueStr}`);
|
|
1557
|
+
gen.assign(data, (0, codegen_1.str)`${value}`);
|
|
1558
|
+
gen.add(names_1.default.jsonPos, valueStr.length);
|
|
1559
|
+
}
|
|
1560
|
+
gen.else();
|
|
1561
|
+
jsonSyntaxError(cxt);
|
|
1562
|
+
gen.endIf();
|
|
1563
|
+
}
|
|
1564
|
+
function parseNumber(cxt, maxDigits) {
|
|
1565
|
+
const { gen } = cxt;
|
|
1566
|
+
skipWhitespace(cxt);
|
|
1567
|
+
gen.if((0, codegen_1._)`"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
|
|
1568
|
+
}
|
|
1569
|
+
function parseBooleanToken(bool, fail) {
|
|
1570
|
+
return (cxt) => {
|
|
1571
|
+
const { gen, data } = cxt;
|
|
1572
|
+
tryParseToken(cxt, `${bool}`, () => fail(cxt), () => gen.assign(data, bool));
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
function parseRef(cxt) {
|
|
1576
|
+
const { gen, self, definitions, schema, schemaEnv } = cxt;
|
|
1577
|
+
const { ref } = schema;
|
|
1578
|
+
const refSchema = definitions[ref];
|
|
1579
|
+
if (!refSchema)
|
|
1580
|
+
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
1581
|
+
if (!(0, ref_1.hasRef)(refSchema))
|
|
1582
|
+
return parseCode({ ...cxt, schema: refSchema });
|
|
1583
|
+
const { root } = schemaEnv;
|
|
1584
|
+
const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
|
|
1585
|
+
partialParse(cxt, getParser(gen, sch), true);
|
|
1586
|
+
}
|
|
1587
|
+
function getParser(gen, sch) {
|
|
1588
|
+
return sch.parse ? gen.scopeValue("parse", { ref: sch.parse }) : (0, codegen_1._)`${gen.scopeValue("wrapper", { ref: sch })}.parse`;
|
|
1589
|
+
}
|
|
1590
|
+
function parseEmpty(cxt) {
|
|
1591
|
+
parseWith(cxt, parseJson_1.parseJson);
|
|
1592
|
+
}
|
|
1593
|
+
function parseWith(cxt, parseFunc, args) {
|
|
1594
|
+
partialParse(cxt, (0, util_1.useFunc)(cxt.gen, parseFunc), args);
|
|
1595
|
+
}
|
|
1596
|
+
function partialParse(cxt, parseFunc, args) {
|
|
1597
|
+
const { gen, data } = cxt;
|
|
1598
|
+
gen.assign(data, (0, codegen_1._)`${parseFunc}(${names_1.default.json}, ${names_1.default.jsonPos}${args ? (0, codegen_1._)`, ${args}` : codegen_1.nil})`);
|
|
1599
|
+
gen.assign(names_1.default.jsonPos, (0, codegen_1._)`${parseFunc}.position`);
|
|
1600
|
+
gen.if((0, codegen_1._)`${data} === undefined`, () => parsingError(cxt, (0, codegen_1._)`${parseFunc}.message`));
|
|
1601
|
+
}
|
|
1602
|
+
function parseToken(cxt, tok) {
|
|
1603
|
+
tryParseToken(cxt, tok, jsonSyntaxError);
|
|
1604
|
+
}
|
|
1605
|
+
function tryParseToken(cxt, tok, fail, success) {
|
|
1606
|
+
const { gen } = cxt;
|
|
1607
|
+
const n = tok.length;
|
|
1608
|
+
skipWhitespace(cxt);
|
|
1609
|
+
gen.if((0, codegen_1._)`${jsonSlice(n)} === ${tok}`, () => {
|
|
1610
|
+
gen.add(names_1.default.jsonPos, n);
|
|
1611
|
+
success === null || success === void 0 ? void 0 : success(cxt);
|
|
1612
|
+
}, () => fail(cxt));
|
|
1613
|
+
}
|
|
1614
|
+
function skipWhitespace({ gen, char: c }) {
|
|
1615
|
+
gen.code((0, codegen_1._)`while((${c}=${names_1.default.json}[${names_1.default.jsonPos}],${c}===" "||${c}==="\\n"||${c}==="\\r"||${c}==="\\t"))${names_1.default.jsonPos}++;`);
|
|
1616
|
+
}
|
|
1617
|
+
function jsonSlice(len) {
|
|
1618
|
+
return len === 1 ? (0, codegen_1._)`${names_1.default.json}[${names_1.default.jsonPos}]` : (0, codegen_1._)`${names_1.default.json}.slice(${names_1.default.jsonPos}, ${names_1.default.jsonPos}+${len})`;
|
|
1619
|
+
}
|
|
1620
|
+
function jsonSyntaxError(cxt) {
|
|
1621
|
+
parsingError(cxt, (0, codegen_1._)`"unexpected token " + ${names_1.default.json}[${names_1.default.jsonPos}]`);
|
|
1622
|
+
}
|
|
1623
|
+
function parsingError({ gen, parseName }, msg) {
|
|
1624
|
+
gen.assign((0, codegen_1._)`${parseName}.message`, msg);
|
|
1625
|
+
gen.assign((0, codegen_1._)`${parseName}.position`, names_1.default.jsonPos);
|
|
1626
|
+
gen.return(undef);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
});
|
|
1630
|
+
|
|
1631
|
+
// ../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/jtd.js
|
|
1632
|
+
var require_jtd2 = __commonJS({
|
|
1633
|
+
"../../node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/jtd.js"(exports, module) {
|
|
1634
|
+
"use strict";
|
|
1635
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1636
|
+
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
|
|
1637
|
+
var core_1 = require_core();
|
|
1638
|
+
var jtd_1 = require_jtd();
|
|
1639
|
+
var jtd_schema_1 = require_jtd_schema();
|
|
1640
|
+
var serialize_1 = require_serialize();
|
|
1641
|
+
var parse_1 = require_parse();
|
|
1642
|
+
var META_SCHEMA_ID = "JTD-meta-schema";
|
|
1643
|
+
var Ajv3 = class extends core_1.default {
|
|
1644
|
+
constructor(opts = {}) {
|
|
1645
|
+
super({
|
|
1646
|
+
...opts,
|
|
1647
|
+
jtd: true
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
_addVocabularies() {
|
|
1651
|
+
super._addVocabularies();
|
|
1652
|
+
this.addVocabulary(jtd_1.default);
|
|
1653
|
+
}
|
|
1654
|
+
_addDefaultMetaSchema() {
|
|
1655
|
+
super._addDefaultMetaSchema();
|
|
1656
|
+
if (!this.opts.meta)
|
|
1657
|
+
return;
|
|
1658
|
+
this.addMetaSchema(jtd_schema_1.default, META_SCHEMA_ID, false);
|
|
1659
|
+
}
|
|
1660
|
+
defaultMeta() {
|
|
1661
|
+
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
|
|
1662
|
+
}
|
|
1663
|
+
compileSerializer(schema) {
|
|
1664
|
+
const sch = this._addSchema(schema);
|
|
1665
|
+
return sch.serialize || this._compileSerializer(sch);
|
|
1666
|
+
}
|
|
1667
|
+
compileParser(schema) {
|
|
1668
|
+
const sch = this._addSchema(schema);
|
|
1669
|
+
return sch.parse || this._compileParser(sch);
|
|
1670
|
+
}
|
|
1671
|
+
_compileSerializer(sch) {
|
|
1672
|
+
serialize_1.default.call(this, sch, sch.schema.definitions || {});
|
|
1673
|
+
if (!sch.serialize)
|
|
1674
|
+
throw new Error("ajv implementation error");
|
|
1675
|
+
return sch.serialize;
|
|
1676
|
+
}
|
|
1677
|
+
_compileParser(sch) {
|
|
1678
|
+
parse_1.default.call(this, sch, sch.schema.definitions || {});
|
|
1679
|
+
if (!sch.parse)
|
|
1680
|
+
throw new Error("ajv implementation error");
|
|
1681
|
+
return sch.parse;
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
exports.Ajv = Ajv3;
|
|
1685
|
+
module.exports = exports = Ajv3;
|
|
1686
|
+
module.exports.Ajv = Ajv3;
|
|
1687
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1688
|
+
exports.default = Ajv3;
|
|
1689
|
+
var validate_1 = require_validate();
|
|
1690
|
+
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
1691
|
+
return validate_1.KeywordCxt;
|
|
1692
|
+
} });
|
|
1693
|
+
var codegen_1 = require_codegen();
|
|
1694
|
+
Object.defineProperty(exports, "_", { enumerable: true, get: function() {
|
|
1695
|
+
return codegen_1._;
|
|
1696
|
+
} });
|
|
1697
|
+
Object.defineProperty(exports, "str", { enumerable: true, get: function() {
|
|
1698
|
+
return codegen_1.str;
|
|
1699
|
+
} });
|
|
1700
|
+
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() {
|
|
1701
|
+
return codegen_1.stringify;
|
|
1702
|
+
} });
|
|
1703
|
+
Object.defineProperty(exports, "nil", { enumerable: true, get: function() {
|
|
1704
|
+
return codegen_1.nil;
|
|
1705
|
+
} });
|
|
1706
|
+
Object.defineProperty(exports, "Name", { enumerable: true, get: function() {
|
|
1707
|
+
return codegen_1.Name;
|
|
1708
|
+
} });
|
|
1709
|
+
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
|
|
1710
|
+
return codegen_1.CodeGen;
|
|
1711
|
+
} });
|
|
1712
|
+
var validation_error_1 = require_validation_error();
|
|
1713
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
|
|
1714
|
+
return validation_error_1.default;
|
|
1715
|
+
} });
|
|
1716
|
+
var ref_error_1 = require_ref_error();
|
|
1717
|
+
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function() {
|
|
1718
|
+
return ref_error_1.default;
|
|
1719
|
+
} });
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1723
|
+
// src/utils/harnessUsage.ts
|
|
1724
|
+
var import_jtd2 = __toESM(require_jtd2(), 1);
|
|
1725
|
+
import { execFile } from "child_process";
|
|
1726
|
+
import { createHash } from "crypto";
|
|
1727
|
+
import { readFile } from "fs/promises";
|
|
1728
|
+
import { homedir, userInfo } from "os";
|
|
1729
|
+
import { join } from "path";
|
|
1730
|
+
import { promisify } from "util";
|
|
1731
|
+
|
|
1732
|
+
// src/utils/usageBudget.ts
|
|
1733
|
+
var import_jtd = __toESM(require_jtd2(), 1);
|
|
1734
|
+
var windowSchema = {
|
|
1735
|
+
nullable: true,
|
|
1736
|
+
properties: { utilization: { type: "float64" } },
|
|
1737
|
+
optionalProperties: { resets_at: { type: "string", nullable: true } },
|
|
1738
|
+
additionalProperties: true
|
|
1739
|
+
};
|
|
1740
|
+
var usageSchema = {
|
|
1741
|
+
properties: { five_hour: windowSchema, seven_day: windowSchema },
|
|
1742
|
+
additionalProperties: true
|
|
1743
|
+
};
|
|
1744
|
+
var parseUsage = new import_jtd.default().compileParser(usageSchema);
|
|
1745
|
+
var unknownUsage = (reason) => ({ status: "unknown", reason });
|
|
1746
|
+
function parseHarnessUsage(text) {
|
|
1747
|
+
const usage = parseUsage(text);
|
|
1748
|
+
if (!usage) return unknownUsage("invalid_usage_response");
|
|
1749
|
+
const normalize = (window) => {
|
|
1750
|
+
if (window === null) return null;
|
|
1751
|
+
return {
|
|
1752
|
+
usedPercent: window.utilization,
|
|
1753
|
+
remainingPercent: 100 - window.utilization,
|
|
1754
|
+
resetsAt: window.resets_at ?? null
|
|
1755
|
+
};
|
|
1756
|
+
};
|
|
1757
|
+
const session = normalize(usage.five_hour);
|
|
1758
|
+
const weekly = normalize(usage.seven_day);
|
|
1759
|
+
return knownUsage("claude-code", session, weekly);
|
|
1760
|
+
}
|
|
1761
|
+
function knownUsage(harness, session, weekly, planTier = null) {
|
|
1762
|
+
const windows = [session, weekly].filter((window) => window !== null);
|
|
1763
|
+
if (!windows.length || windows.some(
|
|
1764
|
+
(window) => !Number.isFinite(window.remainingPercent) || window.remainingPercent < 0 || window.remainingPercent > 100
|
|
1765
|
+
))
|
|
1766
|
+
return unknownUsage("invalid_usage_response");
|
|
1767
|
+
return { status: "known", harness, session, weekly, planTier };
|
|
1768
|
+
}
|
|
1769
|
+
var codexWindowSchema = {
|
|
1770
|
+
nullable: true,
|
|
1771
|
+
properties: { used_percent: { type: "float64" } },
|
|
1772
|
+
optionalProperties: {
|
|
1773
|
+
limit_window_seconds: { type: "float64" },
|
|
1774
|
+
reset_at: { type: "float64" },
|
|
1775
|
+
reset_after_seconds: { type: "float64" }
|
|
1776
|
+
},
|
|
1777
|
+
additionalProperties: true
|
|
1778
|
+
};
|
|
1779
|
+
var codexSchema = {
|
|
1780
|
+
optionalProperties: { plan_type: { type: "string", nullable: true } },
|
|
1781
|
+
properties: {
|
|
1782
|
+
rate_limit: {
|
|
1783
|
+
optionalProperties: {
|
|
1784
|
+
primary_window: codexWindowSchema,
|
|
1785
|
+
secondary_window: codexWindowSchema
|
|
1786
|
+
},
|
|
1787
|
+
additionalProperties: true
|
|
1788
|
+
}
|
|
1789
|
+
},
|
|
1790
|
+
additionalProperties: true
|
|
1791
|
+
};
|
|
1792
|
+
var grokSchema = {
|
|
1793
|
+
properties: {
|
|
1794
|
+
config: {
|
|
1795
|
+
properties: {
|
|
1796
|
+
currentPeriod: {
|
|
1797
|
+
properties: {
|
|
1798
|
+
type: { type: "string" },
|
|
1799
|
+
start: { type: "string" },
|
|
1800
|
+
end: { type: "string" }
|
|
1801
|
+
},
|
|
1802
|
+
additionalProperties: true
|
|
1803
|
+
}
|
|
1804
|
+
},
|
|
1805
|
+
optionalProperties: { creditUsagePercent: { type: "float64" } },
|
|
1806
|
+
additionalProperties: true
|
|
1807
|
+
}
|
|
1808
|
+
},
|
|
1809
|
+
additionalProperties: true
|
|
1810
|
+
};
|
|
1811
|
+
var parser = new import_jtd.default();
|
|
1812
|
+
var parseCodex = parser.compileParser(codexSchema);
|
|
1813
|
+
var parseGrok = parser.compileParser(grokSchema);
|
|
1814
|
+
function codexWindowKind(seconds, index) {
|
|
1815
|
+
switch (seconds) {
|
|
1816
|
+
case 18e3:
|
|
1817
|
+
return "session";
|
|
1818
|
+
case 604800:
|
|
1819
|
+
return "weekly";
|
|
1820
|
+
case void 0:
|
|
1821
|
+
return index === 0 ? "session" : "weekly";
|
|
1822
|
+
default:
|
|
1823
|
+
return "unknown";
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
function normalizeCodexWindow(raw, now) {
|
|
1827
|
+
const reset = raw.reset_at ?? (raw.reset_after_seconds === void 0 ? void 0 : now / 1e3 + raw.reset_after_seconds);
|
|
1828
|
+
if (reset !== void 0 && (!Number.isFinite(reset) || Math.abs(reset * 1e3) > 864e13))
|
|
1829
|
+
return null;
|
|
1830
|
+
return {
|
|
1831
|
+
usedPercent: raw.used_percent,
|
|
1832
|
+
remainingPercent: 100 - raw.used_percent,
|
|
1833
|
+
resetsAt: reset === void 0 ? null : new Date(reset * 1e3).toISOString()
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
function parseCodexUsage(text, now = Date.now()) {
|
|
1837
|
+
const usage = parseCodex(text);
|
|
1838
|
+
if (!usage) return unknownUsage("invalid_usage_response");
|
|
1839
|
+
const windows = {
|
|
1840
|
+
session: null,
|
|
1841
|
+
weekly: null
|
|
1842
|
+
};
|
|
1843
|
+
for (const [index, raw] of [
|
|
1844
|
+
usage.rate_limit.primary_window,
|
|
1845
|
+
usage.rate_limit.secondary_window
|
|
1846
|
+
].entries()) {
|
|
1847
|
+
if (!raw) continue;
|
|
1848
|
+
const kind = codexWindowKind(raw.limit_window_seconds, index);
|
|
1849
|
+
if (kind === "unknown") return unknownUsage("unsupported_usage_window");
|
|
1850
|
+
const window = normalizeCodexWindow(raw, now);
|
|
1851
|
+
if (window === null || windows[kind] !== null) return unknownUsage("invalid_usage_response");
|
|
1852
|
+
windows[kind] = window;
|
|
1853
|
+
}
|
|
1854
|
+
return knownUsage("codex", windows.session, windows.weekly, usage.plan_type ?? null);
|
|
1855
|
+
}
|
|
1856
|
+
function parseGrokUsage(text) {
|
|
1857
|
+
const usage = parseGrok(text);
|
|
1858
|
+
if (!usage) return unknownUsage("invalid_usage_response");
|
|
1859
|
+
const period = usage.config.currentPeriod;
|
|
1860
|
+
const start = Date.parse(period.start);
|
|
1861
|
+
const end = Date.parse(period.end);
|
|
1862
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start)
|
|
1863
|
+
return unknownUsage("invalid_usage_response");
|
|
1864
|
+
if (period.type !== "USAGE_PERIOD_TYPE_WEEKLY") return unknownUsage("unsupported_usage_window");
|
|
1865
|
+
return knownUsage("grok", null, {
|
|
1866
|
+
usedPercent: usage.config.creditUsagePercent ?? 0,
|
|
1867
|
+
remainingPercent: 100 - (usage.config.creditUsagePercent ?? 0),
|
|
1868
|
+
resetsAt: new Date(end).toISOString()
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// src/utils/harnessUsage.ts
|
|
1873
|
+
var credentialSchema = {
|
|
1874
|
+
properties: {
|
|
1875
|
+
claudeAiOauth: {
|
|
1876
|
+
properties: { accessToken: { type: "string" } },
|
|
1877
|
+
optionalProperties: {
|
|
1878
|
+
expiresAt: { type: "float64" },
|
|
1879
|
+
scopes: { elements: { type: "string" } },
|
|
1880
|
+
subscriptionType: { type: "string", nullable: true }
|
|
1881
|
+
},
|
|
1882
|
+
additionalProperties: true
|
|
1883
|
+
}
|
|
1884
|
+
},
|
|
1885
|
+
additionalProperties: true
|
|
1886
|
+
};
|
|
1887
|
+
var parseCredentials = new import_jtd2.default().compileParser(
|
|
1888
|
+
credentialSchema
|
|
1889
|
+
);
|
|
1890
|
+
var exec = promisify(execFile);
|
|
1891
|
+
async function readHarnessUsage(harness) {
|
|
1892
|
+
switch (harness) {
|
|
1893
|
+
case "claude-code":
|
|
1894
|
+
return readClaudeUsage();
|
|
1895
|
+
case "codex":
|
|
1896
|
+
case "grok":
|
|
1897
|
+
return readOtherHarness(harness);
|
|
1898
|
+
default:
|
|
1899
|
+
return unknownUsage("unsupported_harness");
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
async function readClaudeUsage() {
|
|
1903
|
+
if ([
|
|
1904
|
+
"ANTHROPIC_API_KEY",
|
|
1905
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
1906
|
+
"ANTHROPIC_BASE_URL",
|
|
1907
|
+
"CLAUDE_CODE_CUSTOM_OAUTH_URL",
|
|
1908
|
+
"USE_LOCAL_OAUTH",
|
|
1909
|
+
"USE_STAGING_OAUTH"
|
|
1910
|
+
].some((key) => process.env[key]))
|
|
1911
|
+
return unknownUsage("unsupported_auth");
|
|
1912
|
+
const candidates = await readClaudeCandidates(process.env.CLAUDE_CONFIG_DIR);
|
|
1913
|
+
let reason = "no_subscription_login";
|
|
1914
|
+
for (const text of candidates) {
|
|
1915
|
+
const login = claudeLogin(text);
|
|
1916
|
+
if (login.status === "unavailable") {
|
|
1917
|
+
reason = login.reason;
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
const usage = await requestUsage("claude-code", login.credential);
|
|
1921
|
+
if (usage.status === "unknown" && ["http_401", "http_403"].includes(usage.reason)) {
|
|
1922
|
+
reason = usage.reason;
|
|
1923
|
+
continue;
|
|
1924
|
+
}
|
|
1925
|
+
return usage;
|
|
1926
|
+
}
|
|
1927
|
+
return unknownUsage(reason);
|
|
1928
|
+
}
|
|
1929
|
+
async function readClaudeCandidates(configDir) {
|
|
1930
|
+
const candidates = [];
|
|
1931
|
+
if (process.platform === "darwin") {
|
|
1932
|
+
let service = "Claude Code-credentials";
|
|
1933
|
+
if (configDir)
|
|
1934
|
+
service += `-${createHash("sha256").update(configDir.normalize("NFC")).digest("hex").slice(0, 8)}`;
|
|
1935
|
+
for (const accountArgs of [["-a", userInfo().username], []]) {
|
|
1936
|
+
try {
|
|
1937
|
+
const { stdout } = await exec(
|
|
1938
|
+
"/usr/bin/security",
|
|
1939
|
+
["find-generic-password", "-s", service, ...accountArgs, "-w"],
|
|
1940
|
+
{
|
|
1941
|
+
timeout: 2e3,
|
|
1942
|
+
maxBuffer: 1024 * 1024
|
|
1943
|
+
}
|
|
1944
|
+
);
|
|
1945
|
+
candidates.push(stdout);
|
|
1946
|
+
} catch {
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
try {
|
|
1951
|
+
candidates.push(
|
|
1952
|
+
await readFile(join(configDir ?? join(homedir(), ".claude"), ".credentials.json"), "utf8")
|
|
1953
|
+
);
|
|
1954
|
+
} catch {
|
|
1955
|
+
}
|
|
1956
|
+
return candidates;
|
|
1957
|
+
}
|
|
1958
|
+
var authParser = new import_jtd2.default();
|
|
1959
|
+
var codexAuthSchema = {
|
|
1960
|
+
properties: {
|
|
1961
|
+
tokens: {
|
|
1962
|
+
properties: { access_token: { type: "string" } },
|
|
1963
|
+
optionalProperties: { account_id: { type: "string" } },
|
|
1964
|
+
additionalProperties: true
|
|
1965
|
+
}
|
|
1966
|
+
},
|
|
1967
|
+
additionalProperties: true
|
|
1968
|
+
};
|
|
1969
|
+
var grokAuthSchema = {
|
|
1970
|
+
values: {
|
|
1971
|
+
optionalProperties: {
|
|
1972
|
+
key: { type: "string" },
|
|
1973
|
+
auth_mode: { type: "string" },
|
|
1974
|
+
oidc_issuer: { type: "string" },
|
|
1975
|
+
expires_at: { type: "string" },
|
|
1976
|
+
expires: { type: "string" }
|
|
1977
|
+
},
|
|
1978
|
+
additionalProperties: true
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
var jwtSchema = {
|
|
1982
|
+
optionalProperties: { exp: { type: "float64" } },
|
|
1983
|
+
additionalProperties: true
|
|
1984
|
+
};
|
|
1985
|
+
var parseCodexAuth = authParser.compileParser(codexAuthSchema);
|
|
1986
|
+
var parseGrokAuth = authParser.compileParser(grokAuthSchema);
|
|
1987
|
+
var parseJwt = authParser.compileParser(jwtSchema);
|
|
1988
|
+
var grokSettingsSchema = {
|
|
1989
|
+
optionalProperties: { subscription_tier_display: { type: "string", nullable: true } },
|
|
1990
|
+
additionalProperties: true
|
|
1991
|
+
};
|
|
1992
|
+
var parseGrokSettings = authParser.compileParser(grokSettingsSchema);
|
|
1993
|
+
function tokenExpiry(token) {
|
|
1994
|
+
const parts = token.split(".");
|
|
1995
|
+
const payload = parts[1];
|
|
1996
|
+
if (parts.length !== 3 || payload === void 0) return void 0;
|
|
1997
|
+
const expiry = parseJwt(Buffer.from(payload, "base64url").toString("utf8"))?.exp;
|
|
1998
|
+
return expiry === void 0 ? void 0 : expiry * 1e3;
|
|
1999
|
+
}
|
|
2000
|
+
function validLogin(credential, now) {
|
|
2001
|
+
if (credential.expiresAt !== void 0) {
|
|
2002
|
+
if (!Number.isFinite(credential.expiresAt))
|
|
2003
|
+
return { status: "unavailable", reason: "invalid_login" };
|
|
2004
|
+
if (credential.expiresAt <= now) return { status: "unavailable", reason: "expired_login" };
|
|
2005
|
+
}
|
|
2006
|
+
return { status: "ready", credential };
|
|
2007
|
+
}
|
|
2008
|
+
function claudeLogin(text) {
|
|
2009
|
+
const auth = parseCredentials(text)?.claudeAiOauth;
|
|
2010
|
+
if (!auth?.accessToken.trim()) return { status: "unavailable", reason: "no_subscription_login" };
|
|
2011
|
+
if (auth.scopes !== void 0 && !auth.scopes.includes("user:profile"))
|
|
2012
|
+
return { status: "unavailable", reason: "missing_profile_scope" };
|
|
2013
|
+
return validLogin(
|
|
2014
|
+
{
|
|
2015
|
+
token: auth.accessToken.trim(),
|
|
2016
|
+
headers: { "anthropic-beta": "oauth-2025-04-20" },
|
|
2017
|
+
expiresAt: auth.expiresAt,
|
|
2018
|
+
planTier: auth.subscriptionType ?? void 0
|
|
2019
|
+
},
|
|
2020
|
+
Date.now()
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
2023
|
+
function codexLogin(text) {
|
|
2024
|
+
const auth = parseCodexAuth(text)?.tokens;
|
|
2025
|
+
if (!auth?.access_token.trim()) return { status: "unavailable", reason: "no_subscription_login" };
|
|
2026
|
+
const token = auth.access_token.trim();
|
|
2027
|
+
const headers = {};
|
|
2028
|
+
if (auth.account_id) headers["ChatGPT-Account-Id"] = auth.account_id;
|
|
2029
|
+
return validLogin({ token, headers, expiresAt: tokenExpiry(token) }, Date.now());
|
|
2030
|
+
}
|
|
2031
|
+
function grokLogin(text) {
|
|
2032
|
+
const auth = parseGrokAuth(text);
|
|
2033
|
+
if (!auth) return { status: "unavailable", reason: "invalid_login" };
|
|
2034
|
+
const candidates = Object.values(auth).flatMap((entry2) => {
|
|
2035
|
+
const token2 = entry2.key?.trim();
|
|
2036
|
+
if (!token2 || !["oidc", "external"].includes(entry2.auth_mode ?? "") || entry2.oidc_issuer !== "https://auth.x.ai")
|
|
2037
|
+
return [];
|
|
2038
|
+
return [{ entry: entry2, token: token2 }];
|
|
2039
|
+
});
|
|
2040
|
+
if (!candidates.length) return { status: "unavailable", reason: "unsupported_auth" };
|
|
2041
|
+
const candidate = candidates[0];
|
|
2042
|
+
if (candidates.length !== 1 || candidate === void 0)
|
|
2043
|
+
return { status: "unavailable", reason: "ambiguous_login" };
|
|
2044
|
+
const { entry, token } = candidate;
|
|
2045
|
+
const storedExpiry = entry.expires_at ?? entry.expires;
|
|
2046
|
+
const expiresAt = tokenExpiry(token) ?? (storedExpiry === void 0 ? void 0 : Date.parse(storedExpiry));
|
|
2047
|
+
return validLogin(
|
|
2048
|
+
{ token, headers: { "X-XAI-Token-Auth": "xai-grok-cli" }, expiresAt },
|
|
2049
|
+
Date.now()
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
async function readOtherHarness(harness) {
|
|
2053
|
+
const path = harness === "codex" ? join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json") : process.env.GROK_AUTH_PATH || join(process.env.GROK_HOME || join(homedir(), ".grok"), "auth.json");
|
|
2054
|
+
let text;
|
|
2055
|
+
try {
|
|
2056
|
+
text = await readFile(path, "utf8");
|
|
2057
|
+
} catch {
|
|
2058
|
+
return unknownUsage("no_subscription_login");
|
|
2059
|
+
}
|
|
2060
|
+
const login = harness === "codex" ? codexLogin(text) : grokLogin(text);
|
|
2061
|
+
if (login.status === "unavailable") return unknownUsage(login.reason);
|
|
2062
|
+
return requestUsage(harness, login.credential);
|
|
2063
|
+
}
|
|
2064
|
+
var providers = {
|
|
2065
|
+
"claude-code": { url: "https://api.anthropic.com/api/oauth/usage", parse: parseHarnessUsage },
|
|
2066
|
+
codex: { url: "https://chatgpt.com/backend-api/wham/usage", parse: parseCodexUsage },
|
|
2067
|
+
grok: { url: "https://cli-chat-proxy.grok.com/v1/billing?format=credits", parse: parseGrokUsage }
|
|
2068
|
+
};
|
|
2069
|
+
async function requestUsage(harness, credential) {
|
|
2070
|
+
let response;
|
|
2071
|
+
let body;
|
|
2072
|
+
try {
|
|
2073
|
+
({ response, body } = await requestProvider(providers[harness].url, credential));
|
|
2074
|
+
} catch {
|
|
2075
|
+
return unknownUsage("usage_request_failed");
|
|
2076
|
+
}
|
|
2077
|
+
if (!response.ok) {
|
|
2078
|
+
if (harness === "grok" && response.status === 412 && body.toLowerCase().includes("no personal team"))
|
|
2079
|
+
return unknownUsage("team_quota_unavailable");
|
|
2080
|
+
return unknownUsage(`http_${response.status}`);
|
|
2081
|
+
}
|
|
2082
|
+
const usage = providers[harness].parse(body);
|
|
2083
|
+
if (usage.status === "unknown") return usage;
|
|
2084
|
+
if (harness === "grok") return { ...usage, planTier: await readGrokPlanTier(credential) };
|
|
2085
|
+
return { ...usage, planTier: credential.planTier ?? usage.planTier };
|
|
2086
|
+
}
|
|
2087
|
+
async function requestProvider(url, credential) {
|
|
2088
|
+
const response = await fetch(url, {
|
|
2089
|
+
headers: {
|
|
2090
|
+
Accept: "application/json",
|
|
2091
|
+
...credential.headers,
|
|
2092
|
+
Authorization: `Bearer ${credential.token}`
|
|
2093
|
+
},
|
|
2094
|
+
signal: AbortSignal.timeout(5e3),
|
|
2095
|
+
redirect: "error"
|
|
2096
|
+
});
|
|
2097
|
+
return { response, body: await response.text() };
|
|
2098
|
+
}
|
|
2099
|
+
async function readGrokPlanTier(credential) {
|
|
2100
|
+
let result;
|
|
2101
|
+
try {
|
|
2102
|
+
result = await requestProvider("https://cli-chat-proxy.grok.com/v1/settings", credential);
|
|
2103
|
+
} catch {
|
|
2104
|
+
return null;
|
|
2105
|
+
}
|
|
2106
|
+
if (!result.response.ok) return null;
|
|
2107
|
+
return parseGrokSettings(result.body)?.subscription_tier_display?.trim() || null;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
// src/commands/usage.ts
|
|
2111
|
+
var usage_default = defineCommand({
|
|
2112
|
+
meta: {
|
|
2113
|
+
name: "usage",
|
|
2114
|
+
description: "Read remaining harness subscription usage without telemetry"
|
|
2115
|
+
},
|
|
2116
|
+
args: {
|
|
2117
|
+
harness: {
|
|
2118
|
+
type: "string",
|
|
2119
|
+
description: "Harness to read (claude-code, codex, grok); otherwise detect the current harness"
|
|
2120
|
+
},
|
|
2121
|
+
json: { type: "boolean", description: "Print subscription usage as JSON", default: false }
|
|
2122
|
+
},
|
|
2123
|
+
async run({ args }) {
|
|
2124
|
+
const harness = args.harness ?? detectHarness();
|
|
2125
|
+
const usage = await readHarnessUsage(harness);
|
|
2126
|
+
if (args.json) console.log(JSON.stringify(usage));
|
|
2127
|
+
else if (usage.status === "unknown") console.log(`Usage unknown (${usage.reason}).`);
|
|
2128
|
+
else console.log(JSON.stringify(usage, null, 2));
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
function detectHarness() {
|
|
2132
|
+
if (process.env.CODEX_THREAD_ID) return "codex";
|
|
2133
|
+
if (process.env.GROK_AGENT === "1") return "grok";
|
|
2134
|
+
if (process.env.CLAUDECODE) return "claude-code";
|
|
2135
|
+
return "unknown";
|
|
2136
|
+
}
|
|
2137
|
+
export {
|
|
2138
|
+
usage_default as default
|
|
2139
|
+
};
|