openclaw-telegram-manager 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +0 -33
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/autopilot.d.ts +11 -1
- package/dist/commands/autopilot.d.ts.map +1 -1
- package/dist/commands/autopilot.js +70 -11
- package/dist/commands/autopilot.js.map +1 -1
- package/dist/commands/daily-report-all.d.ts +28 -0
- package/dist/commands/daily-report-all.d.ts.map +1 -0
- package/dist/commands/daily-report-all.js +255 -0
- package/dist/commands/daily-report-all.js.map +1 -0
- package/dist/commands/doctor-all.d.ts +1 -0
- package/dist/commands/doctor-all.d.ts.map +1 -1
- package/dist/commands/doctor-all.js +1 -1
- package/dist/commands/doctor-all.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +11 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +0 -22
- package/dist/commands/init.js.map +1 -1
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +2 -0
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/cron.d.ts +11 -0
- package/dist/lib/cron.d.ts.map +1 -1
- package/dist/lib/cron.js +40 -0
- package/dist/lib/cron.js.map +1 -1
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/registry.js +7 -0
- package/dist/lib/registry.js.map +1 -1
- package/dist/lib/telegram.d.ts.map +1 -1
- package/dist/lib/telegram.js +3 -2
- package/dist/lib/telegram.js.map +1 -1
- package/dist/lib/types.d.ts +2 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +3 -2
- package/dist/lib/types.js.map +1 -1
- package/dist/plugin.js +706 -452
- package/dist/setup.js +4 -8
- package/dist/setup.js.map +1 -1
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +23 -0
- package/dist/tool.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -86,14 +86,14 @@ var require_polyfills = __commonJS({
|
|
|
86
86
|
fs14.fstatSync = statFixSync(fs14.fstatSync);
|
|
87
87
|
fs14.lstatSync = statFixSync(fs14.lstatSync);
|
|
88
88
|
if (fs14.chmod && !fs14.lchmod) {
|
|
89
|
-
fs14.lchmod = function(
|
|
89
|
+
fs14.lchmod = function(path16, mode, cb) {
|
|
90
90
|
if (cb) process.nextTick(cb);
|
|
91
91
|
};
|
|
92
92
|
fs14.lchmodSync = function() {
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
if (fs14.chown && !fs14.lchown) {
|
|
96
|
-
fs14.lchown = function(
|
|
96
|
+
fs14.lchown = function(path16, uid, gid, cb) {
|
|
97
97
|
if (cb) process.nextTick(cb);
|
|
98
98
|
};
|
|
99
99
|
fs14.lchownSync = function() {
|
|
@@ -160,9 +160,9 @@ var require_polyfills = __commonJS({
|
|
|
160
160
|
};
|
|
161
161
|
})(fs14.readSync);
|
|
162
162
|
function patchLchmod(fs15) {
|
|
163
|
-
fs15.lchmod = function(
|
|
163
|
+
fs15.lchmod = function(path16, mode, callback) {
|
|
164
164
|
fs15.open(
|
|
165
|
-
|
|
165
|
+
path16,
|
|
166
166
|
constants.O_WRONLY | constants.O_SYMLINK,
|
|
167
167
|
mode,
|
|
168
168
|
function(err, fd) {
|
|
@@ -178,8 +178,8 @@ var require_polyfills = __commonJS({
|
|
|
178
178
|
}
|
|
179
179
|
);
|
|
180
180
|
};
|
|
181
|
-
fs15.lchmodSync = function(
|
|
182
|
-
var fd = fs15.openSync(
|
|
181
|
+
fs15.lchmodSync = function(path16, mode) {
|
|
182
|
+
var fd = fs15.openSync(path16, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
183
183
|
var threw = true;
|
|
184
184
|
var ret;
|
|
185
185
|
try {
|
|
@@ -200,8 +200,8 @@ var require_polyfills = __commonJS({
|
|
|
200
200
|
}
|
|
201
201
|
function patchLutimes(fs15) {
|
|
202
202
|
if (constants.hasOwnProperty("O_SYMLINK") && fs15.futimes) {
|
|
203
|
-
fs15.lutimes = function(
|
|
204
|
-
fs15.open(
|
|
203
|
+
fs15.lutimes = function(path16, at, mt, cb) {
|
|
204
|
+
fs15.open(path16, constants.O_SYMLINK, function(er, fd) {
|
|
205
205
|
if (er) {
|
|
206
206
|
if (cb) cb(er);
|
|
207
207
|
return;
|
|
@@ -213,8 +213,8 @@ var require_polyfills = __commonJS({
|
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
215
|
};
|
|
216
|
-
fs15.lutimesSync = function(
|
|
217
|
-
var fd = fs15.openSync(
|
|
216
|
+
fs15.lutimesSync = function(path16, at, mt) {
|
|
217
|
+
var fd = fs15.openSync(path16, constants.O_SYMLINK);
|
|
218
218
|
var ret;
|
|
219
219
|
var threw = true;
|
|
220
220
|
try {
|
|
@@ -332,11 +332,11 @@ var require_legacy_streams = __commonJS({
|
|
|
332
332
|
ReadStream,
|
|
333
333
|
WriteStream
|
|
334
334
|
};
|
|
335
|
-
function ReadStream(
|
|
336
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
335
|
+
function ReadStream(path16, options) {
|
|
336
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path16, options);
|
|
337
337
|
Stream.call(this);
|
|
338
338
|
var self = this;
|
|
339
|
-
this.path =
|
|
339
|
+
this.path = path16;
|
|
340
340
|
this.fd = null;
|
|
341
341
|
this.readable = true;
|
|
342
342
|
this.paused = false;
|
|
@@ -381,10 +381,10 @@ var require_legacy_streams = __commonJS({
|
|
|
381
381
|
self._read();
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
-
function WriteStream(
|
|
385
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
384
|
+
function WriteStream(path16, options) {
|
|
385
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path16, options);
|
|
386
386
|
Stream.call(this);
|
|
387
|
-
this.path =
|
|
387
|
+
this.path = path16;
|
|
388
388
|
this.fd = null;
|
|
389
389
|
this.writable = true;
|
|
390
390
|
this.flags = "w";
|
|
@@ -527,14 +527,14 @@ var require_graceful_fs = __commonJS({
|
|
|
527
527
|
fs15.createWriteStream = createWriteStream;
|
|
528
528
|
var fs$readFile = fs15.readFile;
|
|
529
529
|
fs15.readFile = readFile;
|
|
530
|
-
function readFile(
|
|
530
|
+
function readFile(path16, options, cb) {
|
|
531
531
|
if (typeof options === "function")
|
|
532
532
|
cb = options, options = null;
|
|
533
|
-
return go$readFile(
|
|
534
|
-
function go$readFile(
|
|
535
|
-
return fs$readFile(
|
|
533
|
+
return go$readFile(path16, options, cb);
|
|
534
|
+
function go$readFile(path17, options2, cb2, startTime) {
|
|
535
|
+
return fs$readFile(path17, options2, function(err) {
|
|
536
536
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
537
|
-
enqueue([go$readFile, [
|
|
537
|
+
enqueue([go$readFile, [path17, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
538
538
|
else {
|
|
539
539
|
if (typeof cb2 === "function")
|
|
540
540
|
cb2.apply(this, arguments);
|
|
@@ -544,14 +544,14 @@ var require_graceful_fs = __commonJS({
|
|
|
544
544
|
}
|
|
545
545
|
var fs$writeFile = fs15.writeFile;
|
|
546
546
|
fs15.writeFile = writeFile;
|
|
547
|
-
function writeFile(
|
|
547
|
+
function writeFile(path16, data, options, cb) {
|
|
548
548
|
if (typeof options === "function")
|
|
549
549
|
cb = options, options = null;
|
|
550
|
-
return go$writeFile(
|
|
551
|
-
function go$writeFile(
|
|
552
|
-
return fs$writeFile(
|
|
550
|
+
return go$writeFile(path16, data, options, cb);
|
|
551
|
+
function go$writeFile(path17, data2, options2, cb2, startTime) {
|
|
552
|
+
return fs$writeFile(path17, data2, options2, function(err) {
|
|
553
553
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
554
|
-
enqueue([go$writeFile, [
|
|
554
|
+
enqueue([go$writeFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
555
555
|
else {
|
|
556
556
|
if (typeof cb2 === "function")
|
|
557
557
|
cb2.apply(this, arguments);
|
|
@@ -562,14 +562,14 @@ var require_graceful_fs = __commonJS({
|
|
|
562
562
|
var fs$appendFile = fs15.appendFile;
|
|
563
563
|
if (fs$appendFile)
|
|
564
564
|
fs15.appendFile = appendFile;
|
|
565
|
-
function appendFile(
|
|
565
|
+
function appendFile(path16, data, options, cb) {
|
|
566
566
|
if (typeof options === "function")
|
|
567
567
|
cb = options, options = null;
|
|
568
|
-
return go$appendFile(
|
|
569
|
-
function go$appendFile(
|
|
570
|
-
return fs$appendFile(
|
|
568
|
+
return go$appendFile(path16, data, options, cb);
|
|
569
|
+
function go$appendFile(path17, data2, options2, cb2, startTime) {
|
|
570
|
+
return fs$appendFile(path17, data2, options2, function(err) {
|
|
571
571
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
572
|
-
enqueue([go$appendFile, [
|
|
572
|
+
enqueue([go$appendFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
573
573
|
else {
|
|
574
574
|
if (typeof cb2 === "function")
|
|
575
575
|
cb2.apply(this, arguments);
|
|
@@ -600,31 +600,31 @@ var require_graceful_fs = __commonJS({
|
|
|
600
600
|
var fs$readdir = fs15.readdir;
|
|
601
601
|
fs15.readdir = readdir;
|
|
602
602
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
603
|
-
function readdir(
|
|
603
|
+
function readdir(path16, options, cb) {
|
|
604
604
|
if (typeof options === "function")
|
|
605
605
|
cb = options, options = null;
|
|
606
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
607
|
-
return fs$readdir(
|
|
608
|
-
|
|
606
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path17, options2, cb2, startTime) {
|
|
607
|
+
return fs$readdir(path17, fs$readdirCallback(
|
|
608
|
+
path17,
|
|
609
609
|
options2,
|
|
610
610
|
cb2,
|
|
611
611
|
startTime
|
|
612
612
|
));
|
|
613
|
-
} : function go$readdir2(
|
|
614
|
-
return fs$readdir(
|
|
615
|
-
|
|
613
|
+
} : function go$readdir2(path17, options2, cb2, startTime) {
|
|
614
|
+
return fs$readdir(path17, options2, fs$readdirCallback(
|
|
615
|
+
path17,
|
|
616
616
|
options2,
|
|
617
617
|
cb2,
|
|
618
618
|
startTime
|
|
619
619
|
));
|
|
620
620
|
};
|
|
621
|
-
return go$readdir(
|
|
622
|
-
function fs$readdirCallback(
|
|
621
|
+
return go$readdir(path16, options, cb);
|
|
622
|
+
function fs$readdirCallback(path17, options2, cb2, startTime) {
|
|
623
623
|
return function(err, files) {
|
|
624
624
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
625
625
|
enqueue([
|
|
626
626
|
go$readdir,
|
|
627
|
-
[
|
|
627
|
+
[path17, options2, cb2],
|
|
628
628
|
err,
|
|
629
629
|
startTime || Date.now(),
|
|
630
630
|
Date.now()
|
|
@@ -695,7 +695,7 @@ var require_graceful_fs = __commonJS({
|
|
|
695
695
|
enumerable: true,
|
|
696
696
|
configurable: true
|
|
697
697
|
});
|
|
698
|
-
function ReadStream(
|
|
698
|
+
function ReadStream(path16, options) {
|
|
699
699
|
if (this instanceof ReadStream)
|
|
700
700
|
return fs$ReadStream.apply(this, arguments), this;
|
|
701
701
|
else
|
|
@@ -715,7 +715,7 @@ var require_graceful_fs = __commonJS({
|
|
|
715
715
|
}
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
|
-
function WriteStream(
|
|
718
|
+
function WriteStream(path16, options) {
|
|
719
719
|
if (this instanceof WriteStream)
|
|
720
720
|
return fs$WriteStream.apply(this, arguments), this;
|
|
721
721
|
else
|
|
@@ -733,22 +733,22 @@ var require_graceful_fs = __commonJS({
|
|
|
733
733
|
}
|
|
734
734
|
});
|
|
735
735
|
}
|
|
736
|
-
function createReadStream(
|
|
737
|
-
return new fs15.ReadStream(
|
|
736
|
+
function createReadStream(path16, options) {
|
|
737
|
+
return new fs15.ReadStream(path16, options);
|
|
738
738
|
}
|
|
739
|
-
function createWriteStream(
|
|
740
|
-
return new fs15.WriteStream(
|
|
739
|
+
function createWriteStream(path16, options) {
|
|
740
|
+
return new fs15.WriteStream(path16, options);
|
|
741
741
|
}
|
|
742
742
|
var fs$open = fs15.open;
|
|
743
743
|
fs15.open = open;
|
|
744
|
-
function open(
|
|
744
|
+
function open(path16, flags, mode, cb) {
|
|
745
745
|
if (typeof mode === "function")
|
|
746
746
|
cb = mode, mode = null;
|
|
747
|
-
return go$open(
|
|
748
|
-
function go$open(
|
|
749
|
-
return fs$open(
|
|
747
|
+
return go$open(path16, flags, mode, cb);
|
|
748
|
+
function go$open(path17, flags2, mode2, cb2, startTime) {
|
|
749
|
+
return fs$open(path17, flags2, mode2, function(err, fd) {
|
|
750
750
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
751
|
-
enqueue([go$open, [
|
|
751
|
+
enqueue([go$open, [path17, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
752
752
|
else {
|
|
753
753
|
if (typeof cb2 === "function")
|
|
754
754
|
cb2.apply(this, arguments);
|
|
@@ -1277,7 +1277,7 @@ var require_mtime_precision = __commonJS({
|
|
|
1277
1277
|
var require_lockfile = __commonJS({
|
|
1278
1278
|
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1279
1279
|
"use strict";
|
|
1280
|
-
var
|
|
1280
|
+
var path16 = __require("path");
|
|
1281
1281
|
var fs14 = require_graceful_fs();
|
|
1282
1282
|
var retry = require_retry2();
|
|
1283
1283
|
var onExit = require_signal_exit();
|
|
@@ -1288,7 +1288,7 @@ var require_lockfile = __commonJS({
|
|
|
1288
1288
|
}
|
|
1289
1289
|
function resolveCanonicalPath(file, options, callback) {
|
|
1290
1290
|
if (!options.realpath) {
|
|
1291
|
-
return callback(null,
|
|
1291
|
+
return callback(null, path16.resolve(file));
|
|
1292
1292
|
}
|
|
1293
1293
|
options.fs.realpath(file, callback);
|
|
1294
1294
|
}
|
|
@@ -2725,7 +2725,7 @@ var require_lib = __commonJS({
|
|
|
2725
2725
|
|
|
2726
2726
|
// src/index.ts
|
|
2727
2727
|
import * as fs13 from "node:fs";
|
|
2728
|
-
import * as
|
|
2728
|
+
import * as path15 from "node:path";
|
|
2729
2729
|
|
|
2730
2730
|
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
2731
2731
|
var value_exports = {};
|
|
@@ -6298,32 +6298,32 @@ var ValueErrorIterator = class {
|
|
|
6298
6298
|
return next.done ? void 0 : next.value;
|
|
6299
6299
|
}
|
|
6300
6300
|
};
|
|
6301
|
-
function Create(errorType, schema,
|
|
6301
|
+
function Create(errorType, schema, path16, value, errors = []) {
|
|
6302
6302
|
return {
|
|
6303
6303
|
type: errorType,
|
|
6304
6304
|
schema,
|
|
6305
|
-
path:
|
|
6305
|
+
path: path16,
|
|
6306
6306
|
value,
|
|
6307
|
-
message: GetErrorFunction()({ errorType, path:
|
|
6307
|
+
message: GetErrorFunction()({ errorType, path: path16, schema, value, errors }),
|
|
6308
6308
|
errors
|
|
6309
6309
|
};
|
|
6310
6310
|
}
|
|
6311
|
-
function* FromAny3(schema, references,
|
|
6311
|
+
function* FromAny3(schema, references, path16, value) {
|
|
6312
6312
|
}
|
|
6313
|
-
function* FromArgument3(schema, references,
|
|
6313
|
+
function* FromArgument3(schema, references, path16, value) {
|
|
6314
6314
|
}
|
|
6315
|
-
function* FromArray8(schema, references,
|
|
6315
|
+
function* FromArray8(schema, references, path16, value) {
|
|
6316
6316
|
if (!IsArray2(value)) {
|
|
6317
|
-
return yield Create(ValueErrorType.Array, schema,
|
|
6317
|
+
return yield Create(ValueErrorType.Array, schema, path16, value);
|
|
6318
6318
|
}
|
|
6319
6319
|
if (IsDefined2(schema.minItems) && !(value.length >= schema.minItems)) {
|
|
6320
|
-
yield Create(ValueErrorType.ArrayMinItems, schema,
|
|
6320
|
+
yield Create(ValueErrorType.ArrayMinItems, schema, path16, value);
|
|
6321
6321
|
}
|
|
6322
6322
|
if (IsDefined2(schema.maxItems) && !(value.length <= schema.maxItems)) {
|
|
6323
|
-
yield Create(ValueErrorType.ArrayMaxItems, schema,
|
|
6323
|
+
yield Create(ValueErrorType.ArrayMaxItems, schema, path16, value);
|
|
6324
6324
|
}
|
|
6325
6325
|
for (let i = 0; i < value.length; i++) {
|
|
6326
|
-
yield* Visit6(schema.items, references, `${
|
|
6326
|
+
yield* Visit6(schema.items, references, `${path16}/${i}`, value[i]);
|
|
6327
6327
|
}
|
|
6328
6328
|
if (schema.uniqueItems === true && !(function() {
|
|
6329
6329
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -6337,116 +6337,116 @@ function* FromArray8(schema, references, path15, value) {
|
|
|
6337
6337
|
}
|
|
6338
6338
|
return true;
|
|
6339
6339
|
})()) {
|
|
6340
|
-
yield Create(ValueErrorType.ArrayUniqueItems, schema,
|
|
6340
|
+
yield Create(ValueErrorType.ArrayUniqueItems, schema, path16, value);
|
|
6341
6341
|
}
|
|
6342
6342
|
if (!(IsDefined2(schema.contains) || IsDefined2(schema.minContains) || IsDefined2(schema.maxContains))) {
|
|
6343
6343
|
return;
|
|
6344
6344
|
}
|
|
6345
6345
|
const containsSchema = IsDefined2(schema.contains) ? schema.contains : Never();
|
|
6346
|
-
const containsCount = value.reduce((acc, value2, index) => Visit6(containsSchema, references, `${
|
|
6346
|
+
const containsCount = value.reduce((acc, value2, index) => Visit6(containsSchema, references, `${path16}${index}`, value2).next().done === true ? acc + 1 : acc, 0);
|
|
6347
6347
|
if (containsCount === 0) {
|
|
6348
|
-
yield Create(ValueErrorType.ArrayContains, schema,
|
|
6348
|
+
yield Create(ValueErrorType.ArrayContains, schema, path16, value);
|
|
6349
6349
|
}
|
|
6350
6350
|
if (IsNumber2(schema.minContains) && containsCount < schema.minContains) {
|
|
6351
|
-
yield Create(ValueErrorType.ArrayMinContains, schema,
|
|
6351
|
+
yield Create(ValueErrorType.ArrayMinContains, schema, path16, value);
|
|
6352
6352
|
}
|
|
6353
6353
|
if (IsNumber2(schema.maxContains) && containsCount > schema.maxContains) {
|
|
6354
|
-
yield Create(ValueErrorType.ArrayMaxContains, schema,
|
|
6354
|
+
yield Create(ValueErrorType.ArrayMaxContains, schema, path16, value);
|
|
6355
6355
|
}
|
|
6356
6356
|
}
|
|
6357
|
-
function* FromAsyncIterator5(schema, references,
|
|
6357
|
+
function* FromAsyncIterator5(schema, references, path16, value) {
|
|
6358
6358
|
if (!IsAsyncIterator2(value))
|
|
6359
|
-
yield Create(ValueErrorType.AsyncIterator, schema,
|
|
6359
|
+
yield Create(ValueErrorType.AsyncIterator, schema, path16, value);
|
|
6360
6360
|
}
|
|
6361
|
-
function* FromBigInt3(schema, references,
|
|
6361
|
+
function* FromBigInt3(schema, references, path16, value) {
|
|
6362
6362
|
if (!IsBigInt2(value))
|
|
6363
|
-
return yield Create(ValueErrorType.BigInt, schema,
|
|
6363
|
+
return yield Create(ValueErrorType.BigInt, schema, path16, value);
|
|
6364
6364
|
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
6365
|
-
yield Create(ValueErrorType.BigIntExclusiveMaximum, schema,
|
|
6365
|
+
yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path16, value);
|
|
6366
6366
|
}
|
|
6367
6367
|
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
6368
|
-
yield Create(ValueErrorType.BigIntExclusiveMinimum, schema,
|
|
6368
|
+
yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path16, value);
|
|
6369
6369
|
}
|
|
6370
6370
|
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
6371
|
-
yield Create(ValueErrorType.BigIntMaximum, schema,
|
|
6371
|
+
yield Create(ValueErrorType.BigIntMaximum, schema, path16, value);
|
|
6372
6372
|
}
|
|
6373
6373
|
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
6374
|
-
yield Create(ValueErrorType.BigIntMinimum, schema,
|
|
6374
|
+
yield Create(ValueErrorType.BigIntMinimum, schema, path16, value);
|
|
6375
6375
|
}
|
|
6376
6376
|
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
|
|
6377
|
-
yield Create(ValueErrorType.BigIntMultipleOf, schema,
|
|
6377
|
+
yield Create(ValueErrorType.BigIntMultipleOf, schema, path16, value);
|
|
6378
6378
|
}
|
|
6379
6379
|
}
|
|
6380
|
-
function* FromBoolean3(schema, references,
|
|
6380
|
+
function* FromBoolean3(schema, references, path16, value) {
|
|
6381
6381
|
if (!IsBoolean2(value))
|
|
6382
|
-
yield Create(ValueErrorType.Boolean, schema,
|
|
6382
|
+
yield Create(ValueErrorType.Boolean, schema, path16, value);
|
|
6383
6383
|
}
|
|
6384
|
-
function* FromConstructor5(schema, references,
|
|
6385
|
-
yield* Visit6(schema.returns, references,
|
|
6384
|
+
function* FromConstructor5(schema, references, path16, value) {
|
|
6385
|
+
yield* Visit6(schema.returns, references, path16, value.prototype);
|
|
6386
6386
|
}
|
|
6387
|
-
function* FromDate3(schema, references,
|
|
6387
|
+
function* FromDate3(schema, references, path16, value) {
|
|
6388
6388
|
if (!IsDate2(value))
|
|
6389
|
-
return yield Create(ValueErrorType.Date, schema,
|
|
6389
|
+
return yield Create(ValueErrorType.Date, schema, path16, value);
|
|
6390
6390
|
if (IsDefined2(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
6391
|
-
yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema,
|
|
6391
|
+
yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path16, value);
|
|
6392
6392
|
}
|
|
6393
6393
|
if (IsDefined2(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
|
|
6394
|
-
yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema,
|
|
6394
|
+
yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path16, value);
|
|
6395
6395
|
}
|
|
6396
6396
|
if (IsDefined2(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
|
|
6397
|
-
yield Create(ValueErrorType.DateMaximumTimestamp, schema,
|
|
6397
|
+
yield Create(ValueErrorType.DateMaximumTimestamp, schema, path16, value);
|
|
6398
6398
|
}
|
|
6399
6399
|
if (IsDefined2(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
|
|
6400
|
-
yield Create(ValueErrorType.DateMinimumTimestamp, schema,
|
|
6400
|
+
yield Create(ValueErrorType.DateMinimumTimestamp, schema, path16, value);
|
|
6401
6401
|
}
|
|
6402
6402
|
if (IsDefined2(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
|
|
6403
|
-
yield Create(ValueErrorType.DateMultipleOfTimestamp, schema,
|
|
6403
|
+
yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path16, value);
|
|
6404
6404
|
}
|
|
6405
6405
|
}
|
|
6406
|
-
function* FromFunction5(schema, references,
|
|
6406
|
+
function* FromFunction5(schema, references, path16, value) {
|
|
6407
6407
|
if (!IsFunction2(value))
|
|
6408
|
-
yield Create(ValueErrorType.Function, schema,
|
|
6408
|
+
yield Create(ValueErrorType.Function, schema, path16, value);
|
|
6409
6409
|
}
|
|
6410
|
-
function* FromImport2(schema, references,
|
|
6410
|
+
function* FromImport2(schema, references, path16, value) {
|
|
6411
6411
|
const definitions = globalThis.Object.values(schema.$defs);
|
|
6412
6412
|
const target = schema.$defs[schema.$ref];
|
|
6413
|
-
yield* Visit6(target, [...references, ...definitions],
|
|
6413
|
+
yield* Visit6(target, [...references, ...definitions], path16, value);
|
|
6414
6414
|
}
|
|
6415
|
-
function* FromInteger3(schema, references,
|
|
6415
|
+
function* FromInteger3(schema, references, path16, value) {
|
|
6416
6416
|
if (!IsInteger(value))
|
|
6417
|
-
return yield Create(ValueErrorType.Integer, schema,
|
|
6417
|
+
return yield Create(ValueErrorType.Integer, schema, path16, value);
|
|
6418
6418
|
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
6419
|
-
yield Create(ValueErrorType.IntegerExclusiveMaximum, schema,
|
|
6419
|
+
yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path16, value);
|
|
6420
6420
|
}
|
|
6421
6421
|
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
6422
|
-
yield Create(ValueErrorType.IntegerExclusiveMinimum, schema,
|
|
6422
|
+
yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path16, value);
|
|
6423
6423
|
}
|
|
6424
6424
|
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
6425
|
-
yield Create(ValueErrorType.IntegerMaximum, schema,
|
|
6425
|
+
yield Create(ValueErrorType.IntegerMaximum, schema, path16, value);
|
|
6426
6426
|
}
|
|
6427
6427
|
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
6428
|
-
yield Create(ValueErrorType.IntegerMinimum, schema,
|
|
6428
|
+
yield Create(ValueErrorType.IntegerMinimum, schema, path16, value);
|
|
6429
6429
|
}
|
|
6430
6430
|
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
6431
|
-
yield Create(ValueErrorType.IntegerMultipleOf, schema,
|
|
6431
|
+
yield Create(ValueErrorType.IntegerMultipleOf, schema, path16, value);
|
|
6432
6432
|
}
|
|
6433
6433
|
}
|
|
6434
|
-
function* FromIntersect10(schema, references,
|
|
6434
|
+
function* FromIntersect10(schema, references, path16, value) {
|
|
6435
6435
|
let hasError = false;
|
|
6436
6436
|
for (const inner of schema.allOf) {
|
|
6437
|
-
for (const error of Visit6(inner, references,
|
|
6437
|
+
for (const error of Visit6(inner, references, path16, value)) {
|
|
6438
6438
|
hasError = true;
|
|
6439
6439
|
yield error;
|
|
6440
6440
|
}
|
|
6441
6441
|
}
|
|
6442
6442
|
if (hasError) {
|
|
6443
|
-
return yield Create(ValueErrorType.Intersect, schema,
|
|
6443
|
+
return yield Create(ValueErrorType.Intersect, schema, path16, value);
|
|
6444
6444
|
}
|
|
6445
6445
|
if (schema.unevaluatedProperties === false) {
|
|
6446
6446
|
const keyCheck = new RegExp(KeyOfPattern(schema));
|
|
6447
6447
|
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
6448
6448
|
if (!keyCheck.test(valueKey)) {
|
|
6449
|
-
yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${
|
|
6449
|
+
yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path16}/${valueKey}`, value);
|
|
6450
6450
|
}
|
|
6451
6451
|
}
|
|
6452
6452
|
}
|
|
@@ -6454,59 +6454,59 @@ function* FromIntersect10(schema, references, path15, value) {
|
|
|
6454
6454
|
const keyCheck = new RegExp(KeyOfPattern(schema));
|
|
6455
6455
|
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
6456
6456
|
if (!keyCheck.test(valueKey)) {
|
|
6457
|
-
const next = Visit6(schema.unevaluatedProperties, references, `${
|
|
6457
|
+
const next = Visit6(schema.unevaluatedProperties, references, `${path16}/${valueKey}`, value[valueKey]).next();
|
|
6458
6458
|
if (!next.done)
|
|
6459
6459
|
yield next.value;
|
|
6460
6460
|
}
|
|
6461
6461
|
}
|
|
6462
6462
|
}
|
|
6463
6463
|
}
|
|
6464
|
-
function* FromIterator5(schema, references,
|
|
6464
|
+
function* FromIterator5(schema, references, path16, value) {
|
|
6465
6465
|
if (!IsIterator2(value))
|
|
6466
|
-
yield Create(ValueErrorType.Iterator, schema,
|
|
6466
|
+
yield Create(ValueErrorType.Iterator, schema, path16, value);
|
|
6467
6467
|
}
|
|
6468
|
-
function* FromLiteral4(schema, references,
|
|
6468
|
+
function* FromLiteral4(schema, references, path16, value) {
|
|
6469
6469
|
if (!(value === schema.const))
|
|
6470
|
-
yield Create(ValueErrorType.Literal, schema,
|
|
6470
|
+
yield Create(ValueErrorType.Literal, schema, path16, value);
|
|
6471
6471
|
}
|
|
6472
|
-
function* FromNever3(schema, references,
|
|
6473
|
-
yield Create(ValueErrorType.Never, schema,
|
|
6472
|
+
function* FromNever3(schema, references, path16, value) {
|
|
6473
|
+
yield Create(ValueErrorType.Never, schema, path16, value);
|
|
6474
6474
|
}
|
|
6475
|
-
function* FromNot3(schema, references,
|
|
6476
|
-
if (Visit6(schema.not, references,
|
|
6477
|
-
yield Create(ValueErrorType.Not, schema,
|
|
6475
|
+
function* FromNot3(schema, references, path16, value) {
|
|
6476
|
+
if (Visit6(schema.not, references, path16, value).next().done === true)
|
|
6477
|
+
yield Create(ValueErrorType.Not, schema, path16, value);
|
|
6478
6478
|
}
|
|
6479
|
-
function* FromNull3(schema, references,
|
|
6479
|
+
function* FromNull3(schema, references, path16, value) {
|
|
6480
6480
|
if (!IsNull2(value))
|
|
6481
|
-
yield Create(ValueErrorType.Null, schema,
|
|
6481
|
+
yield Create(ValueErrorType.Null, schema, path16, value);
|
|
6482
6482
|
}
|
|
6483
|
-
function* FromNumber3(schema, references,
|
|
6483
|
+
function* FromNumber3(schema, references, path16, value) {
|
|
6484
6484
|
if (!TypeSystemPolicy.IsNumberLike(value))
|
|
6485
|
-
return yield Create(ValueErrorType.Number, schema,
|
|
6485
|
+
return yield Create(ValueErrorType.Number, schema, path16, value);
|
|
6486
6486
|
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
6487
|
-
yield Create(ValueErrorType.NumberExclusiveMaximum, schema,
|
|
6487
|
+
yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path16, value);
|
|
6488
6488
|
}
|
|
6489
6489
|
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
6490
|
-
yield Create(ValueErrorType.NumberExclusiveMinimum, schema,
|
|
6490
|
+
yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path16, value);
|
|
6491
6491
|
}
|
|
6492
6492
|
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
6493
|
-
yield Create(ValueErrorType.NumberMaximum, schema,
|
|
6493
|
+
yield Create(ValueErrorType.NumberMaximum, schema, path16, value);
|
|
6494
6494
|
}
|
|
6495
6495
|
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
6496
|
-
yield Create(ValueErrorType.NumberMinimum, schema,
|
|
6496
|
+
yield Create(ValueErrorType.NumberMinimum, schema, path16, value);
|
|
6497
6497
|
}
|
|
6498
6498
|
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
6499
|
-
yield Create(ValueErrorType.NumberMultipleOf, schema,
|
|
6499
|
+
yield Create(ValueErrorType.NumberMultipleOf, schema, path16, value);
|
|
6500
6500
|
}
|
|
6501
6501
|
}
|
|
6502
|
-
function* FromObject9(schema, references,
|
|
6502
|
+
function* FromObject9(schema, references, path16, value) {
|
|
6503
6503
|
if (!TypeSystemPolicy.IsObjectLike(value))
|
|
6504
|
-
return yield Create(ValueErrorType.Object, schema,
|
|
6504
|
+
return yield Create(ValueErrorType.Object, schema, path16, value);
|
|
6505
6505
|
if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
6506
|
-
yield Create(ValueErrorType.ObjectMinProperties, schema,
|
|
6506
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path16, value);
|
|
6507
6507
|
}
|
|
6508
6508
|
if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
6509
|
-
yield Create(ValueErrorType.ObjectMaxProperties, schema,
|
|
6509
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path16, value);
|
|
6510
6510
|
}
|
|
6511
6511
|
const requiredKeys = Array.isArray(schema.required) ? schema.required : [];
|
|
6512
6512
|
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
@@ -6514,12 +6514,12 @@ function* FromObject9(schema, references, path15, value) {
|
|
|
6514
6514
|
for (const requiredKey of requiredKeys) {
|
|
6515
6515
|
if (unknownKeys.includes(requiredKey))
|
|
6516
6516
|
continue;
|
|
6517
|
-
yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${
|
|
6517
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path16}/${EscapeKey(requiredKey)}`, void 0);
|
|
6518
6518
|
}
|
|
6519
6519
|
if (schema.additionalProperties === false) {
|
|
6520
6520
|
for (const valueKey of unknownKeys) {
|
|
6521
6521
|
if (!knownKeys.includes(valueKey)) {
|
|
6522
|
-
yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${
|
|
6522
|
+
yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path16}/${EscapeKey(valueKey)}`, value[valueKey]);
|
|
6523
6523
|
}
|
|
6524
6524
|
}
|
|
6525
6525
|
}
|
|
@@ -6527,235 +6527,235 @@ function* FromObject9(schema, references, path15, value) {
|
|
|
6527
6527
|
for (const valueKey of unknownKeys) {
|
|
6528
6528
|
if (knownKeys.includes(valueKey))
|
|
6529
6529
|
continue;
|
|
6530
|
-
yield* Visit6(schema.additionalProperties, references, `${
|
|
6530
|
+
yield* Visit6(schema.additionalProperties, references, `${path16}/${EscapeKey(valueKey)}`, value[valueKey]);
|
|
6531
6531
|
}
|
|
6532
6532
|
}
|
|
6533
6533
|
for (const knownKey of knownKeys) {
|
|
6534
6534
|
const property = schema.properties[knownKey];
|
|
6535
6535
|
if (schema.required && schema.required.includes(knownKey)) {
|
|
6536
|
-
yield* Visit6(property, references, `${
|
|
6536
|
+
yield* Visit6(property, references, `${path16}/${EscapeKey(knownKey)}`, value[knownKey]);
|
|
6537
6537
|
if (ExtendsUndefinedCheck(schema) && !(knownKey in value)) {
|
|
6538
|
-
yield Create(ValueErrorType.ObjectRequiredProperty, property, `${
|
|
6538
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path16}/${EscapeKey(knownKey)}`, void 0);
|
|
6539
6539
|
}
|
|
6540
6540
|
} else {
|
|
6541
6541
|
if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey)) {
|
|
6542
|
-
yield* Visit6(property, references, `${
|
|
6542
|
+
yield* Visit6(property, references, `${path16}/${EscapeKey(knownKey)}`, value[knownKey]);
|
|
6543
6543
|
}
|
|
6544
6544
|
}
|
|
6545
6545
|
}
|
|
6546
6546
|
}
|
|
6547
|
-
function* FromPromise5(schema, references,
|
|
6547
|
+
function* FromPromise5(schema, references, path16, value) {
|
|
6548
6548
|
if (!IsPromise(value))
|
|
6549
|
-
yield Create(ValueErrorType.Promise, schema,
|
|
6549
|
+
yield Create(ValueErrorType.Promise, schema, path16, value);
|
|
6550
6550
|
}
|
|
6551
|
-
function* FromRecord5(schema, references,
|
|
6551
|
+
function* FromRecord5(schema, references, path16, value) {
|
|
6552
6552
|
if (!TypeSystemPolicy.IsRecordLike(value))
|
|
6553
|
-
return yield Create(ValueErrorType.Object, schema,
|
|
6553
|
+
return yield Create(ValueErrorType.Object, schema, path16, value);
|
|
6554
6554
|
if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
6555
|
-
yield Create(ValueErrorType.ObjectMinProperties, schema,
|
|
6555
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path16, value);
|
|
6556
6556
|
}
|
|
6557
6557
|
if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
6558
|
-
yield Create(ValueErrorType.ObjectMaxProperties, schema,
|
|
6558
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path16, value);
|
|
6559
6559
|
}
|
|
6560
6560
|
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
6561
6561
|
const regex = new RegExp(patternKey);
|
|
6562
6562
|
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
6563
6563
|
if (regex.test(propertyKey))
|
|
6564
|
-
yield* Visit6(patternSchema, references, `${
|
|
6564
|
+
yield* Visit6(patternSchema, references, `${path16}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
6565
6565
|
}
|
|
6566
6566
|
if (typeof schema.additionalProperties === "object") {
|
|
6567
6567
|
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
6568
6568
|
if (!regex.test(propertyKey))
|
|
6569
|
-
yield* Visit6(schema.additionalProperties, references, `${
|
|
6569
|
+
yield* Visit6(schema.additionalProperties, references, `${path16}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
6570
6570
|
}
|
|
6571
6571
|
}
|
|
6572
6572
|
if (schema.additionalProperties === false) {
|
|
6573
6573
|
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
6574
6574
|
if (regex.test(propertyKey))
|
|
6575
6575
|
continue;
|
|
6576
|
-
return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${
|
|
6576
|
+
return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path16}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
6577
6577
|
}
|
|
6578
6578
|
}
|
|
6579
6579
|
}
|
|
6580
|
-
function* FromRef6(schema, references,
|
|
6581
|
-
yield* Visit6(Deref(schema, references), references,
|
|
6580
|
+
function* FromRef6(schema, references, path16, value) {
|
|
6581
|
+
yield* Visit6(Deref(schema, references), references, path16, value);
|
|
6582
6582
|
}
|
|
6583
|
-
function* FromRegExp3(schema, references,
|
|
6583
|
+
function* FromRegExp3(schema, references, path16, value) {
|
|
6584
6584
|
if (!IsString2(value))
|
|
6585
|
-
return yield Create(ValueErrorType.String, schema,
|
|
6585
|
+
return yield Create(ValueErrorType.String, schema, path16, value);
|
|
6586
6586
|
if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
6587
|
-
yield Create(ValueErrorType.StringMinLength, schema,
|
|
6587
|
+
yield Create(ValueErrorType.StringMinLength, schema, path16, value);
|
|
6588
6588
|
}
|
|
6589
6589
|
if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
6590
|
-
yield Create(ValueErrorType.StringMaxLength, schema,
|
|
6590
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path16, value);
|
|
6591
6591
|
}
|
|
6592
6592
|
const regex = new RegExp(schema.source, schema.flags);
|
|
6593
6593
|
if (!regex.test(value)) {
|
|
6594
|
-
return yield Create(ValueErrorType.RegExp, schema,
|
|
6594
|
+
return yield Create(ValueErrorType.RegExp, schema, path16, value);
|
|
6595
6595
|
}
|
|
6596
6596
|
}
|
|
6597
|
-
function* FromString3(schema, references,
|
|
6597
|
+
function* FromString3(schema, references, path16, value) {
|
|
6598
6598
|
if (!IsString2(value))
|
|
6599
|
-
return yield Create(ValueErrorType.String, schema,
|
|
6599
|
+
return yield Create(ValueErrorType.String, schema, path16, value);
|
|
6600
6600
|
if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
6601
|
-
yield Create(ValueErrorType.StringMinLength, schema,
|
|
6601
|
+
yield Create(ValueErrorType.StringMinLength, schema, path16, value);
|
|
6602
6602
|
}
|
|
6603
6603
|
if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
6604
|
-
yield Create(ValueErrorType.StringMaxLength, schema,
|
|
6604
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path16, value);
|
|
6605
6605
|
}
|
|
6606
6606
|
if (IsString2(schema.pattern)) {
|
|
6607
6607
|
const regex = new RegExp(schema.pattern);
|
|
6608
6608
|
if (!regex.test(value)) {
|
|
6609
|
-
yield Create(ValueErrorType.StringPattern, schema,
|
|
6609
|
+
yield Create(ValueErrorType.StringPattern, schema, path16, value);
|
|
6610
6610
|
}
|
|
6611
6611
|
}
|
|
6612
6612
|
if (IsString2(schema.format)) {
|
|
6613
6613
|
if (!format_exports.Has(schema.format)) {
|
|
6614
|
-
yield Create(ValueErrorType.StringFormatUnknown, schema,
|
|
6614
|
+
yield Create(ValueErrorType.StringFormatUnknown, schema, path16, value);
|
|
6615
6615
|
} else {
|
|
6616
6616
|
const format = format_exports.Get(schema.format);
|
|
6617
6617
|
if (!format(value)) {
|
|
6618
|
-
yield Create(ValueErrorType.StringFormat, schema,
|
|
6618
|
+
yield Create(ValueErrorType.StringFormat, schema, path16, value);
|
|
6619
6619
|
}
|
|
6620
6620
|
}
|
|
6621
6621
|
}
|
|
6622
6622
|
}
|
|
6623
|
-
function* FromSymbol3(schema, references,
|
|
6623
|
+
function* FromSymbol3(schema, references, path16, value) {
|
|
6624
6624
|
if (!IsSymbol2(value))
|
|
6625
|
-
yield Create(ValueErrorType.Symbol, schema,
|
|
6625
|
+
yield Create(ValueErrorType.Symbol, schema, path16, value);
|
|
6626
6626
|
}
|
|
6627
|
-
function* FromTemplateLiteral5(schema, references,
|
|
6627
|
+
function* FromTemplateLiteral5(schema, references, path16, value) {
|
|
6628
6628
|
if (!IsString2(value))
|
|
6629
|
-
return yield Create(ValueErrorType.String, schema,
|
|
6629
|
+
return yield Create(ValueErrorType.String, schema, path16, value);
|
|
6630
6630
|
const regex = new RegExp(schema.pattern);
|
|
6631
6631
|
if (!regex.test(value)) {
|
|
6632
|
-
yield Create(ValueErrorType.StringPattern, schema,
|
|
6632
|
+
yield Create(ValueErrorType.StringPattern, schema, path16, value);
|
|
6633
6633
|
}
|
|
6634
6634
|
}
|
|
6635
|
-
function* FromThis2(schema, references,
|
|
6636
|
-
yield* Visit6(Deref(schema, references), references,
|
|
6635
|
+
function* FromThis2(schema, references, path16, value) {
|
|
6636
|
+
yield* Visit6(Deref(schema, references), references, path16, value);
|
|
6637
6637
|
}
|
|
6638
|
-
function* FromTuple7(schema, references,
|
|
6638
|
+
function* FromTuple7(schema, references, path16, value) {
|
|
6639
6639
|
if (!IsArray2(value))
|
|
6640
|
-
return yield Create(ValueErrorType.Tuple, schema,
|
|
6640
|
+
return yield Create(ValueErrorType.Tuple, schema, path16, value);
|
|
6641
6641
|
if (schema.items === void 0 && !(value.length === 0)) {
|
|
6642
|
-
return yield Create(ValueErrorType.TupleLength, schema,
|
|
6642
|
+
return yield Create(ValueErrorType.TupleLength, schema, path16, value);
|
|
6643
6643
|
}
|
|
6644
6644
|
if (!(value.length === schema.maxItems)) {
|
|
6645
|
-
return yield Create(ValueErrorType.TupleLength, schema,
|
|
6645
|
+
return yield Create(ValueErrorType.TupleLength, schema, path16, value);
|
|
6646
6646
|
}
|
|
6647
6647
|
if (!schema.items) {
|
|
6648
6648
|
return;
|
|
6649
6649
|
}
|
|
6650
6650
|
for (let i = 0; i < schema.items.length; i++) {
|
|
6651
|
-
yield* Visit6(schema.items[i], references, `${
|
|
6651
|
+
yield* Visit6(schema.items[i], references, `${path16}/${i}`, value[i]);
|
|
6652
6652
|
}
|
|
6653
6653
|
}
|
|
6654
|
-
function* FromUndefined3(schema, references,
|
|
6654
|
+
function* FromUndefined3(schema, references, path16, value) {
|
|
6655
6655
|
if (!IsUndefined2(value))
|
|
6656
|
-
yield Create(ValueErrorType.Undefined, schema,
|
|
6656
|
+
yield Create(ValueErrorType.Undefined, schema, path16, value);
|
|
6657
6657
|
}
|
|
6658
|
-
function* FromUnion12(schema, references,
|
|
6658
|
+
function* FromUnion12(schema, references, path16, value) {
|
|
6659
6659
|
if (Check(schema, references, value))
|
|
6660
6660
|
return;
|
|
6661
|
-
const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit6(variant, references,
|
|
6662
|
-
yield Create(ValueErrorType.Union, schema,
|
|
6661
|
+
const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit6(variant, references, path16, value)));
|
|
6662
|
+
yield Create(ValueErrorType.Union, schema, path16, value, errors);
|
|
6663
6663
|
}
|
|
6664
|
-
function* FromUint8Array3(schema, references,
|
|
6664
|
+
function* FromUint8Array3(schema, references, path16, value) {
|
|
6665
6665
|
if (!IsUint8Array2(value))
|
|
6666
|
-
return yield Create(ValueErrorType.Uint8Array, schema,
|
|
6666
|
+
return yield Create(ValueErrorType.Uint8Array, schema, path16, value);
|
|
6667
6667
|
if (IsDefined2(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
6668
|
-
yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema,
|
|
6668
|
+
yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path16, value);
|
|
6669
6669
|
}
|
|
6670
6670
|
if (IsDefined2(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
|
|
6671
|
-
yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema,
|
|
6671
|
+
yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path16, value);
|
|
6672
6672
|
}
|
|
6673
6673
|
}
|
|
6674
|
-
function* FromUnknown3(schema, references,
|
|
6674
|
+
function* FromUnknown3(schema, references, path16, value) {
|
|
6675
6675
|
}
|
|
6676
|
-
function* FromVoid3(schema, references,
|
|
6676
|
+
function* FromVoid3(schema, references, path16, value) {
|
|
6677
6677
|
if (!TypeSystemPolicy.IsVoidLike(value))
|
|
6678
|
-
yield Create(ValueErrorType.Void, schema,
|
|
6678
|
+
yield Create(ValueErrorType.Void, schema, path16, value);
|
|
6679
6679
|
}
|
|
6680
|
-
function* FromKind2(schema, references,
|
|
6680
|
+
function* FromKind2(schema, references, path16, value) {
|
|
6681
6681
|
const check2 = type_exports2.Get(schema[Kind]);
|
|
6682
6682
|
if (!check2(schema, value))
|
|
6683
|
-
yield Create(ValueErrorType.Kind, schema,
|
|
6683
|
+
yield Create(ValueErrorType.Kind, schema, path16, value);
|
|
6684
6684
|
}
|
|
6685
|
-
function* Visit6(schema, references,
|
|
6685
|
+
function* Visit6(schema, references, path16, value) {
|
|
6686
6686
|
const references_ = IsDefined2(schema.$id) ? [...references, schema] : references;
|
|
6687
6687
|
const schema_ = schema;
|
|
6688
6688
|
switch (schema_[Kind]) {
|
|
6689
6689
|
case "Any":
|
|
6690
|
-
return yield* FromAny3(schema_, references_,
|
|
6690
|
+
return yield* FromAny3(schema_, references_, path16, value);
|
|
6691
6691
|
case "Argument":
|
|
6692
|
-
return yield* FromArgument3(schema_, references_,
|
|
6692
|
+
return yield* FromArgument3(schema_, references_, path16, value);
|
|
6693
6693
|
case "Array":
|
|
6694
|
-
return yield* FromArray8(schema_, references_,
|
|
6694
|
+
return yield* FromArray8(schema_, references_, path16, value);
|
|
6695
6695
|
case "AsyncIterator":
|
|
6696
|
-
return yield* FromAsyncIterator5(schema_, references_,
|
|
6696
|
+
return yield* FromAsyncIterator5(schema_, references_, path16, value);
|
|
6697
6697
|
case "BigInt":
|
|
6698
|
-
return yield* FromBigInt3(schema_, references_,
|
|
6698
|
+
return yield* FromBigInt3(schema_, references_, path16, value);
|
|
6699
6699
|
case "Boolean":
|
|
6700
|
-
return yield* FromBoolean3(schema_, references_,
|
|
6700
|
+
return yield* FromBoolean3(schema_, references_, path16, value);
|
|
6701
6701
|
case "Constructor":
|
|
6702
|
-
return yield* FromConstructor5(schema_, references_,
|
|
6702
|
+
return yield* FromConstructor5(schema_, references_, path16, value);
|
|
6703
6703
|
case "Date":
|
|
6704
|
-
return yield* FromDate3(schema_, references_,
|
|
6704
|
+
return yield* FromDate3(schema_, references_, path16, value);
|
|
6705
6705
|
case "Function":
|
|
6706
|
-
return yield* FromFunction5(schema_, references_,
|
|
6706
|
+
return yield* FromFunction5(schema_, references_, path16, value);
|
|
6707
6707
|
case "Import":
|
|
6708
|
-
return yield* FromImport2(schema_, references_,
|
|
6708
|
+
return yield* FromImport2(schema_, references_, path16, value);
|
|
6709
6709
|
case "Integer":
|
|
6710
|
-
return yield* FromInteger3(schema_, references_,
|
|
6710
|
+
return yield* FromInteger3(schema_, references_, path16, value);
|
|
6711
6711
|
case "Intersect":
|
|
6712
|
-
return yield* FromIntersect10(schema_, references_,
|
|
6712
|
+
return yield* FromIntersect10(schema_, references_, path16, value);
|
|
6713
6713
|
case "Iterator":
|
|
6714
|
-
return yield* FromIterator5(schema_, references_,
|
|
6714
|
+
return yield* FromIterator5(schema_, references_, path16, value);
|
|
6715
6715
|
case "Literal":
|
|
6716
|
-
return yield* FromLiteral4(schema_, references_,
|
|
6716
|
+
return yield* FromLiteral4(schema_, references_, path16, value);
|
|
6717
6717
|
case "Never":
|
|
6718
|
-
return yield* FromNever3(schema_, references_,
|
|
6718
|
+
return yield* FromNever3(schema_, references_, path16, value);
|
|
6719
6719
|
case "Not":
|
|
6720
|
-
return yield* FromNot3(schema_, references_,
|
|
6720
|
+
return yield* FromNot3(schema_, references_, path16, value);
|
|
6721
6721
|
case "Null":
|
|
6722
|
-
return yield* FromNull3(schema_, references_,
|
|
6722
|
+
return yield* FromNull3(schema_, references_, path16, value);
|
|
6723
6723
|
case "Number":
|
|
6724
|
-
return yield* FromNumber3(schema_, references_,
|
|
6724
|
+
return yield* FromNumber3(schema_, references_, path16, value);
|
|
6725
6725
|
case "Object":
|
|
6726
|
-
return yield* FromObject9(schema_, references_,
|
|
6726
|
+
return yield* FromObject9(schema_, references_, path16, value);
|
|
6727
6727
|
case "Promise":
|
|
6728
|
-
return yield* FromPromise5(schema_, references_,
|
|
6728
|
+
return yield* FromPromise5(schema_, references_, path16, value);
|
|
6729
6729
|
case "Record":
|
|
6730
|
-
return yield* FromRecord5(schema_, references_,
|
|
6730
|
+
return yield* FromRecord5(schema_, references_, path16, value);
|
|
6731
6731
|
case "Ref":
|
|
6732
|
-
return yield* FromRef6(schema_, references_,
|
|
6732
|
+
return yield* FromRef6(schema_, references_, path16, value);
|
|
6733
6733
|
case "RegExp":
|
|
6734
|
-
return yield* FromRegExp3(schema_, references_,
|
|
6734
|
+
return yield* FromRegExp3(schema_, references_, path16, value);
|
|
6735
6735
|
case "String":
|
|
6736
|
-
return yield* FromString3(schema_, references_,
|
|
6736
|
+
return yield* FromString3(schema_, references_, path16, value);
|
|
6737
6737
|
case "Symbol":
|
|
6738
|
-
return yield* FromSymbol3(schema_, references_,
|
|
6738
|
+
return yield* FromSymbol3(schema_, references_, path16, value);
|
|
6739
6739
|
case "TemplateLiteral":
|
|
6740
|
-
return yield* FromTemplateLiteral5(schema_, references_,
|
|
6740
|
+
return yield* FromTemplateLiteral5(schema_, references_, path16, value);
|
|
6741
6741
|
case "This":
|
|
6742
|
-
return yield* FromThis2(schema_, references_,
|
|
6742
|
+
return yield* FromThis2(schema_, references_, path16, value);
|
|
6743
6743
|
case "Tuple":
|
|
6744
|
-
return yield* FromTuple7(schema_, references_,
|
|
6744
|
+
return yield* FromTuple7(schema_, references_, path16, value);
|
|
6745
6745
|
case "Undefined":
|
|
6746
|
-
return yield* FromUndefined3(schema_, references_,
|
|
6746
|
+
return yield* FromUndefined3(schema_, references_, path16, value);
|
|
6747
6747
|
case "Union":
|
|
6748
|
-
return yield* FromUnion12(schema_, references_,
|
|
6748
|
+
return yield* FromUnion12(schema_, references_, path16, value);
|
|
6749
6749
|
case "Uint8Array":
|
|
6750
|
-
return yield* FromUint8Array3(schema_, references_,
|
|
6750
|
+
return yield* FromUint8Array3(schema_, references_, path16, value);
|
|
6751
6751
|
case "Unknown":
|
|
6752
|
-
return yield* FromUnknown3(schema_, references_,
|
|
6752
|
+
return yield* FromUnknown3(schema_, references_, path16, value);
|
|
6753
6753
|
case "Void":
|
|
6754
|
-
return yield* FromVoid3(schema_, references_,
|
|
6754
|
+
return yield* FromVoid3(schema_, references_, path16, value);
|
|
6755
6755
|
default:
|
|
6756
6756
|
if (!type_exports2.Has(schema_[Kind]))
|
|
6757
6757
|
throw new ValueErrorsUnknownTypeError(schema);
|
|
6758
|
-
return yield* FromKind2(schema_, references_,
|
|
6758
|
+
return yield* FromKind2(schema_, references_, path16, value);
|
|
6759
6759
|
}
|
|
6760
6760
|
}
|
|
6761
6761
|
function Errors(...args) {
|
|
@@ -7797,58 +7797,58 @@ var TransformDecodeCheckError = class extends TypeBoxError {
|
|
|
7797
7797
|
}
|
|
7798
7798
|
};
|
|
7799
7799
|
var TransformDecodeError = class extends TypeBoxError {
|
|
7800
|
-
constructor(schema,
|
|
7800
|
+
constructor(schema, path16, value, error) {
|
|
7801
7801
|
super(error instanceof Error ? error.message : "Unknown error");
|
|
7802
7802
|
this.schema = schema;
|
|
7803
|
-
this.path =
|
|
7803
|
+
this.path = path16;
|
|
7804
7804
|
this.value = value;
|
|
7805
7805
|
this.error = error;
|
|
7806
7806
|
}
|
|
7807
7807
|
};
|
|
7808
|
-
function Default3(schema,
|
|
7808
|
+
function Default3(schema, path16, value) {
|
|
7809
7809
|
try {
|
|
7810
7810
|
return IsTransform(schema) ? schema[TransformKind].Decode(value) : value;
|
|
7811
7811
|
} catch (error) {
|
|
7812
|
-
throw new TransformDecodeError(schema,
|
|
7812
|
+
throw new TransformDecodeError(schema, path16, value, error);
|
|
7813
7813
|
}
|
|
7814
7814
|
}
|
|
7815
|
-
function FromArray14(schema, references,
|
|
7816
|
-
return IsArray2(value) ? Default3(schema,
|
|
7815
|
+
function FromArray14(schema, references, path16, value) {
|
|
7816
|
+
return IsArray2(value) ? Default3(schema, path16, value.map((value2, index) => Visit11(schema.items, references, `${path16}/${index}`, value2))) : Default3(schema, path16, value);
|
|
7817
7817
|
}
|
|
7818
|
-
function FromIntersect15(schema, references,
|
|
7818
|
+
function FromIntersect15(schema, references, path16, value) {
|
|
7819
7819
|
if (!IsObject2(value) || IsValueType(value))
|
|
7820
|
-
return Default3(schema,
|
|
7820
|
+
return Default3(schema, path16, value);
|
|
7821
7821
|
const knownEntries = KeyOfPropertyEntries(schema);
|
|
7822
7822
|
const knownKeys = knownEntries.map((entry) => entry[0]);
|
|
7823
7823
|
const knownProperties = { ...value };
|
|
7824
7824
|
for (const [knownKey, knownSchema] of knownEntries)
|
|
7825
7825
|
if (knownKey in knownProperties) {
|
|
7826
|
-
knownProperties[knownKey] = Visit11(knownSchema, references, `${
|
|
7826
|
+
knownProperties[knownKey] = Visit11(knownSchema, references, `${path16}/${knownKey}`, knownProperties[knownKey]);
|
|
7827
7827
|
}
|
|
7828
7828
|
if (!IsTransform(schema.unevaluatedProperties)) {
|
|
7829
|
-
return Default3(schema,
|
|
7829
|
+
return Default3(schema, path16, knownProperties);
|
|
7830
7830
|
}
|
|
7831
7831
|
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
7832
7832
|
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
7833
7833
|
const unknownProperties = { ...knownProperties };
|
|
7834
7834
|
for (const key of unknownKeys)
|
|
7835
7835
|
if (!knownKeys.includes(key)) {
|
|
7836
|
-
unknownProperties[key] = Default3(unevaluatedProperties, `${
|
|
7836
|
+
unknownProperties[key] = Default3(unevaluatedProperties, `${path16}/${key}`, unknownProperties[key]);
|
|
7837
7837
|
}
|
|
7838
|
-
return Default3(schema,
|
|
7838
|
+
return Default3(schema, path16, unknownProperties);
|
|
7839
7839
|
}
|
|
7840
|
-
function FromImport7(schema, references,
|
|
7840
|
+
function FromImport7(schema, references, path16, value) {
|
|
7841
7841
|
const additional = globalThis.Object.values(schema.$defs);
|
|
7842
7842
|
const target = schema.$defs[schema.$ref];
|
|
7843
|
-
const result = Visit11(target, [...references, ...additional],
|
|
7844
|
-
return Default3(schema,
|
|
7843
|
+
const result = Visit11(target, [...references, ...additional], path16, value);
|
|
7844
|
+
return Default3(schema, path16, result);
|
|
7845
7845
|
}
|
|
7846
|
-
function FromNot5(schema, references,
|
|
7847
|
-
return Default3(schema,
|
|
7846
|
+
function FromNot5(schema, references, path16, value) {
|
|
7847
|
+
return Default3(schema, path16, Visit11(schema.not, references, path16, value));
|
|
7848
7848
|
}
|
|
7849
|
-
function FromObject15(schema, references,
|
|
7849
|
+
function FromObject15(schema, references, path16, value) {
|
|
7850
7850
|
if (!IsObject2(value))
|
|
7851
|
-
return Default3(schema,
|
|
7851
|
+
return Default3(schema, path16, value);
|
|
7852
7852
|
const knownKeys = KeyOfPropertyKeys(schema);
|
|
7853
7853
|
const knownProperties = { ...value };
|
|
7854
7854
|
for (const key of knownKeys) {
|
|
@@ -7856,90 +7856,90 @@ function FromObject15(schema, references, path15, value) {
|
|
|
7856
7856
|
continue;
|
|
7857
7857
|
if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
|
|
7858
7858
|
continue;
|
|
7859
|
-
knownProperties[key] = Visit11(schema.properties[key], references, `${
|
|
7859
|
+
knownProperties[key] = Visit11(schema.properties[key], references, `${path16}/${key}`, knownProperties[key]);
|
|
7860
7860
|
}
|
|
7861
7861
|
if (!IsSchema(schema.additionalProperties)) {
|
|
7862
|
-
return Default3(schema,
|
|
7862
|
+
return Default3(schema, path16, knownProperties);
|
|
7863
7863
|
}
|
|
7864
7864
|
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
7865
7865
|
const additionalProperties = schema.additionalProperties;
|
|
7866
7866
|
const unknownProperties = { ...knownProperties };
|
|
7867
7867
|
for (const key of unknownKeys)
|
|
7868
7868
|
if (!knownKeys.includes(key)) {
|
|
7869
|
-
unknownProperties[key] = Default3(additionalProperties, `${
|
|
7869
|
+
unknownProperties[key] = Default3(additionalProperties, `${path16}/${key}`, unknownProperties[key]);
|
|
7870
7870
|
}
|
|
7871
|
-
return Default3(schema,
|
|
7871
|
+
return Default3(schema, path16, unknownProperties);
|
|
7872
7872
|
}
|
|
7873
|
-
function FromRecord10(schema, references,
|
|
7873
|
+
function FromRecord10(schema, references, path16, value) {
|
|
7874
7874
|
if (!IsObject2(value))
|
|
7875
|
-
return Default3(schema,
|
|
7875
|
+
return Default3(schema, path16, value);
|
|
7876
7876
|
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
7877
7877
|
const knownKeys = new RegExp(pattern);
|
|
7878
7878
|
const knownProperties = { ...value };
|
|
7879
7879
|
for (const key of Object.getOwnPropertyNames(value))
|
|
7880
7880
|
if (knownKeys.test(key)) {
|
|
7881
|
-
knownProperties[key] = Visit11(schema.patternProperties[pattern], references, `${
|
|
7881
|
+
knownProperties[key] = Visit11(schema.patternProperties[pattern], references, `${path16}/${key}`, knownProperties[key]);
|
|
7882
7882
|
}
|
|
7883
7883
|
if (!IsSchema(schema.additionalProperties)) {
|
|
7884
|
-
return Default3(schema,
|
|
7884
|
+
return Default3(schema, path16, knownProperties);
|
|
7885
7885
|
}
|
|
7886
7886
|
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
7887
7887
|
const additionalProperties = schema.additionalProperties;
|
|
7888
7888
|
const unknownProperties = { ...knownProperties };
|
|
7889
7889
|
for (const key of unknownKeys)
|
|
7890
7890
|
if (!knownKeys.test(key)) {
|
|
7891
|
-
unknownProperties[key] = Default3(additionalProperties, `${
|
|
7891
|
+
unknownProperties[key] = Default3(additionalProperties, `${path16}/${key}`, unknownProperties[key]);
|
|
7892
7892
|
}
|
|
7893
|
-
return Default3(schema,
|
|
7893
|
+
return Default3(schema, path16, unknownProperties);
|
|
7894
7894
|
}
|
|
7895
|
-
function FromRef11(schema, references,
|
|
7895
|
+
function FromRef11(schema, references, path16, value) {
|
|
7896
7896
|
const target = Deref(schema, references);
|
|
7897
|
-
return Default3(schema,
|
|
7897
|
+
return Default3(schema, path16, Visit11(target, references, path16, value));
|
|
7898
7898
|
}
|
|
7899
|
-
function FromThis7(schema, references,
|
|
7899
|
+
function FromThis7(schema, references, path16, value) {
|
|
7900
7900
|
const target = Deref(schema, references);
|
|
7901
|
-
return Default3(schema,
|
|
7901
|
+
return Default3(schema, path16, Visit11(target, references, path16, value));
|
|
7902
7902
|
}
|
|
7903
|
-
function FromTuple12(schema, references,
|
|
7904
|
-
return IsArray2(value) && IsArray2(schema.items) ? Default3(schema,
|
|
7903
|
+
function FromTuple12(schema, references, path16, value) {
|
|
7904
|
+
return IsArray2(value) && IsArray2(schema.items) ? Default3(schema, path16, schema.items.map((schema2, index) => Visit11(schema2, references, `${path16}/${index}`, value[index]))) : Default3(schema, path16, value);
|
|
7905
7905
|
}
|
|
7906
|
-
function FromUnion17(schema, references,
|
|
7906
|
+
function FromUnion17(schema, references, path16, value) {
|
|
7907
7907
|
for (const subschema of schema.anyOf) {
|
|
7908
7908
|
if (!Check(subschema, references, value))
|
|
7909
7909
|
continue;
|
|
7910
|
-
const decoded = Visit11(subschema, references,
|
|
7911
|
-
return Default3(schema,
|
|
7910
|
+
const decoded = Visit11(subschema, references, path16, value);
|
|
7911
|
+
return Default3(schema, path16, decoded);
|
|
7912
7912
|
}
|
|
7913
|
-
return Default3(schema,
|
|
7913
|
+
return Default3(schema, path16, value);
|
|
7914
7914
|
}
|
|
7915
|
-
function Visit11(schema, references,
|
|
7915
|
+
function Visit11(schema, references, path16, value) {
|
|
7916
7916
|
const references_ = Pushref(schema, references);
|
|
7917
7917
|
const schema_ = schema;
|
|
7918
7918
|
switch (schema[Kind]) {
|
|
7919
7919
|
case "Array":
|
|
7920
|
-
return FromArray14(schema_, references_,
|
|
7920
|
+
return FromArray14(schema_, references_, path16, value);
|
|
7921
7921
|
case "Import":
|
|
7922
|
-
return FromImport7(schema_, references_,
|
|
7922
|
+
return FromImport7(schema_, references_, path16, value);
|
|
7923
7923
|
case "Intersect":
|
|
7924
|
-
return FromIntersect15(schema_, references_,
|
|
7924
|
+
return FromIntersect15(schema_, references_, path16, value);
|
|
7925
7925
|
case "Not":
|
|
7926
|
-
return FromNot5(schema_, references_,
|
|
7926
|
+
return FromNot5(schema_, references_, path16, value);
|
|
7927
7927
|
case "Object":
|
|
7928
|
-
return FromObject15(schema_, references_,
|
|
7928
|
+
return FromObject15(schema_, references_, path16, value);
|
|
7929
7929
|
case "Record":
|
|
7930
|
-
return FromRecord10(schema_, references_,
|
|
7930
|
+
return FromRecord10(schema_, references_, path16, value);
|
|
7931
7931
|
case "Ref":
|
|
7932
|
-
return FromRef11(schema_, references_,
|
|
7932
|
+
return FromRef11(schema_, references_, path16, value);
|
|
7933
7933
|
case "Symbol":
|
|
7934
|
-
return Default3(schema_,
|
|
7934
|
+
return Default3(schema_, path16, value);
|
|
7935
7935
|
case "This":
|
|
7936
|
-
return FromThis7(schema_, references_,
|
|
7936
|
+
return FromThis7(schema_, references_, path16, value);
|
|
7937
7937
|
case "Tuple":
|
|
7938
|
-
return FromTuple12(schema_, references_,
|
|
7938
|
+
return FromTuple12(schema_, references_, path16, value);
|
|
7939
7939
|
case "Union":
|
|
7940
|
-
return FromUnion17(schema_, references_,
|
|
7940
|
+
return FromUnion17(schema_, references_, path16, value);
|
|
7941
7941
|
default:
|
|
7942
|
-
return Default3(schema_,
|
|
7942
|
+
return Default3(schema_, path16, value);
|
|
7943
7943
|
}
|
|
7944
7944
|
}
|
|
7945
7945
|
function TransformDecode(schema, references, value) {
|
|
@@ -7956,33 +7956,33 @@ var TransformEncodeCheckError = class extends TypeBoxError {
|
|
|
7956
7956
|
}
|
|
7957
7957
|
};
|
|
7958
7958
|
var TransformEncodeError = class extends TypeBoxError {
|
|
7959
|
-
constructor(schema,
|
|
7959
|
+
constructor(schema, path16, value, error) {
|
|
7960
7960
|
super(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
7961
7961
|
this.schema = schema;
|
|
7962
|
-
this.path =
|
|
7962
|
+
this.path = path16;
|
|
7963
7963
|
this.value = value;
|
|
7964
7964
|
this.error = error;
|
|
7965
7965
|
}
|
|
7966
7966
|
};
|
|
7967
|
-
function Default4(schema,
|
|
7967
|
+
function Default4(schema, path16, value) {
|
|
7968
7968
|
try {
|
|
7969
7969
|
return IsTransform(schema) ? schema[TransformKind].Encode(value) : value;
|
|
7970
7970
|
} catch (error) {
|
|
7971
|
-
throw new TransformEncodeError(schema,
|
|
7971
|
+
throw new TransformEncodeError(schema, path16, value, error);
|
|
7972
7972
|
}
|
|
7973
7973
|
}
|
|
7974
|
-
function FromArray15(schema, references,
|
|
7975
|
-
const defaulted = Default4(schema,
|
|
7976
|
-
return IsArray2(defaulted) ? defaulted.map((value2, index) => Visit12(schema.items, references, `${
|
|
7974
|
+
function FromArray15(schema, references, path16, value) {
|
|
7975
|
+
const defaulted = Default4(schema, path16, value);
|
|
7976
|
+
return IsArray2(defaulted) ? defaulted.map((value2, index) => Visit12(schema.items, references, `${path16}/${index}`, value2)) : defaulted;
|
|
7977
7977
|
}
|
|
7978
|
-
function FromImport8(schema, references,
|
|
7978
|
+
function FromImport8(schema, references, path16, value) {
|
|
7979
7979
|
const additional = globalThis.Object.values(schema.$defs);
|
|
7980
7980
|
const target = schema.$defs[schema.$ref];
|
|
7981
|
-
const result = Default4(schema,
|
|
7982
|
-
return Visit12(target, [...references, ...additional],
|
|
7981
|
+
const result = Default4(schema, path16, value);
|
|
7982
|
+
return Visit12(target, [...references, ...additional], path16, result);
|
|
7983
7983
|
}
|
|
7984
|
-
function FromIntersect16(schema, references,
|
|
7985
|
-
const defaulted = Default4(schema,
|
|
7984
|
+
function FromIntersect16(schema, references, path16, value) {
|
|
7985
|
+
const defaulted = Default4(schema, path16, value);
|
|
7986
7986
|
if (!IsObject2(value) || IsValueType(value))
|
|
7987
7987
|
return defaulted;
|
|
7988
7988
|
const knownEntries = KeyOfPropertyEntries(schema);
|
|
@@ -7990,7 +7990,7 @@ function FromIntersect16(schema, references, path15, value) {
|
|
|
7990
7990
|
const knownProperties = { ...defaulted };
|
|
7991
7991
|
for (const [knownKey, knownSchema] of knownEntries)
|
|
7992
7992
|
if (knownKey in knownProperties) {
|
|
7993
|
-
knownProperties[knownKey] = Visit12(knownSchema, references, `${
|
|
7993
|
+
knownProperties[knownKey] = Visit12(knownSchema, references, `${path16}/${knownKey}`, knownProperties[knownKey]);
|
|
7994
7994
|
}
|
|
7995
7995
|
if (!IsTransform(schema.unevaluatedProperties)) {
|
|
7996
7996
|
return knownProperties;
|
|
@@ -8000,15 +8000,15 @@ function FromIntersect16(schema, references, path15, value) {
|
|
|
8000
8000
|
const properties = { ...knownProperties };
|
|
8001
8001
|
for (const key of unknownKeys)
|
|
8002
8002
|
if (!knownKeys.includes(key)) {
|
|
8003
|
-
properties[key] = Default4(unevaluatedProperties, `${
|
|
8003
|
+
properties[key] = Default4(unevaluatedProperties, `${path16}/${key}`, properties[key]);
|
|
8004
8004
|
}
|
|
8005
8005
|
return properties;
|
|
8006
8006
|
}
|
|
8007
|
-
function FromNot6(schema, references,
|
|
8008
|
-
return Default4(schema.not,
|
|
8007
|
+
function FromNot6(schema, references, path16, value) {
|
|
8008
|
+
return Default4(schema.not, path16, Default4(schema, path16, value));
|
|
8009
8009
|
}
|
|
8010
|
-
function FromObject16(schema, references,
|
|
8011
|
-
const defaulted = Default4(schema,
|
|
8010
|
+
function FromObject16(schema, references, path16, value) {
|
|
8011
|
+
const defaulted = Default4(schema, path16, value);
|
|
8012
8012
|
if (!IsObject2(defaulted))
|
|
8013
8013
|
return defaulted;
|
|
8014
8014
|
const knownKeys = KeyOfPropertyKeys(schema);
|
|
@@ -8018,7 +8018,7 @@ function FromObject16(schema, references, path15, value) {
|
|
|
8018
8018
|
continue;
|
|
8019
8019
|
if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
|
|
8020
8020
|
continue;
|
|
8021
|
-
knownProperties[key] = Visit12(schema.properties[key], references, `${
|
|
8021
|
+
knownProperties[key] = Visit12(schema.properties[key], references, `${path16}/${key}`, knownProperties[key]);
|
|
8022
8022
|
}
|
|
8023
8023
|
if (!IsSchema(schema.additionalProperties)) {
|
|
8024
8024
|
return knownProperties;
|
|
@@ -8028,12 +8028,12 @@ function FromObject16(schema, references, path15, value) {
|
|
|
8028
8028
|
const properties = { ...knownProperties };
|
|
8029
8029
|
for (const key of unknownKeys)
|
|
8030
8030
|
if (!knownKeys.includes(key)) {
|
|
8031
|
-
properties[key] = Default4(additionalProperties, `${
|
|
8031
|
+
properties[key] = Default4(additionalProperties, `${path16}/${key}`, properties[key]);
|
|
8032
8032
|
}
|
|
8033
8033
|
return properties;
|
|
8034
8034
|
}
|
|
8035
|
-
function FromRecord11(schema, references,
|
|
8036
|
-
const defaulted = Default4(schema,
|
|
8035
|
+
function FromRecord11(schema, references, path16, value) {
|
|
8036
|
+
const defaulted = Default4(schema, path16, value);
|
|
8037
8037
|
if (!IsObject2(value))
|
|
8038
8038
|
return defaulted;
|
|
8039
8039
|
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
@@ -8041,7 +8041,7 @@ function FromRecord11(schema, references, path15, value) {
|
|
|
8041
8041
|
const knownProperties = { ...defaulted };
|
|
8042
8042
|
for (const key of Object.getOwnPropertyNames(value))
|
|
8043
8043
|
if (knownKeys.test(key)) {
|
|
8044
|
-
knownProperties[key] = Visit12(schema.patternProperties[pattern], references, `${
|
|
8044
|
+
knownProperties[key] = Visit12(schema.patternProperties[pattern], references, `${path16}/${key}`, knownProperties[key]);
|
|
8045
8045
|
}
|
|
8046
8046
|
if (!IsSchema(schema.additionalProperties)) {
|
|
8047
8047
|
return knownProperties;
|
|
@@ -8051,65 +8051,65 @@ function FromRecord11(schema, references, path15, value) {
|
|
|
8051
8051
|
const properties = { ...knownProperties };
|
|
8052
8052
|
for (const key of unknownKeys)
|
|
8053
8053
|
if (!knownKeys.test(key)) {
|
|
8054
|
-
properties[key] = Default4(additionalProperties, `${
|
|
8054
|
+
properties[key] = Default4(additionalProperties, `${path16}/${key}`, properties[key]);
|
|
8055
8055
|
}
|
|
8056
8056
|
return properties;
|
|
8057
8057
|
}
|
|
8058
|
-
function FromRef12(schema, references,
|
|
8058
|
+
function FromRef12(schema, references, path16, value) {
|
|
8059
8059
|
const target = Deref(schema, references);
|
|
8060
|
-
const resolved = Visit12(target, references,
|
|
8061
|
-
return Default4(schema,
|
|
8060
|
+
const resolved = Visit12(target, references, path16, value);
|
|
8061
|
+
return Default4(schema, path16, resolved);
|
|
8062
8062
|
}
|
|
8063
|
-
function FromThis8(schema, references,
|
|
8063
|
+
function FromThis8(schema, references, path16, value) {
|
|
8064
8064
|
const target = Deref(schema, references);
|
|
8065
|
-
const resolved = Visit12(target, references,
|
|
8066
|
-
return Default4(schema,
|
|
8065
|
+
const resolved = Visit12(target, references, path16, value);
|
|
8066
|
+
return Default4(schema, path16, resolved);
|
|
8067
8067
|
}
|
|
8068
|
-
function FromTuple13(schema, references,
|
|
8069
|
-
const value1 = Default4(schema,
|
|
8070
|
-
return IsArray2(schema.items) ? schema.items.map((schema2, index) => Visit12(schema2, references, `${
|
|
8068
|
+
function FromTuple13(schema, references, path16, value) {
|
|
8069
|
+
const value1 = Default4(schema, path16, value);
|
|
8070
|
+
return IsArray2(schema.items) ? schema.items.map((schema2, index) => Visit12(schema2, references, `${path16}/${index}`, value1[index])) : [];
|
|
8071
8071
|
}
|
|
8072
|
-
function FromUnion18(schema, references,
|
|
8072
|
+
function FromUnion18(schema, references, path16, value) {
|
|
8073
8073
|
for (const subschema of schema.anyOf) {
|
|
8074
8074
|
if (!Check(subschema, references, value))
|
|
8075
8075
|
continue;
|
|
8076
|
-
const value1 = Visit12(subschema, references,
|
|
8077
|
-
return Default4(schema,
|
|
8076
|
+
const value1 = Visit12(subschema, references, path16, value);
|
|
8077
|
+
return Default4(schema, path16, value1);
|
|
8078
8078
|
}
|
|
8079
8079
|
for (const subschema of schema.anyOf) {
|
|
8080
|
-
const value1 = Visit12(subschema, references,
|
|
8080
|
+
const value1 = Visit12(subschema, references, path16, value);
|
|
8081
8081
|
if (!Check(schema, references, value1))
|
|
8082
8082
|
continue;
|
|
8083
|
-
return Default4(schema,
|
|
8083
|
+
return Default4(schema, path16, value1);
|
|
8084
8084
|
}
|
|
8085
|
-
return Default4(schema,
|
|
8085
|
+
return Default4(schema, path16, value);
|
|
8086
8086
|
}
|
|
8087
|
-
function Visit12(schema, references,
|
|
8087
|
+
function Visit12(schema, references, path16, value) {
|
|
8088
8088
|
const references_ = Pushref(schema, references);
|
|
8089
8089
|
const schema_ = schema;
|
|
8090
8090
|
switch (schema[Kind]) {
|
|
8091
8091
|
case "Array":
|
|
8092
|
-
return FromArray15(schema_, references_,
|
|
8092
|
+
return FromArray15(schema_, references_, path16, value);
|
|
8093
8093
|
case "Import":
|
|
8094
|
-
return FromImport8(schema_, references_,
|
|
8094
|
+
return FromImport8(schema_, references_, path16, value);
|
|
8095
8095
|
case "Intersect":
|
|
8096
|
-
return FromIntersect16(schema_, references_,
|
|
8096
|
+
return FromIntersect16(schema_, references_, path16, value);
|
|
8097
8097
|
case "Not":
|
|
8098
|
-
return FromNot6(schema_, references_,
|
|
8098
|
+
return FromNot6(schema_, references_, path16, value);
|
|
8099
8099
|
case "Object":
|
|
8100
|
-
return FromObject16(schema_, references_,
|
|
8100
|
+
return FromObject16(schema_, references_, path16, value);
|
|
8101
8101
|
case "Record":
|
|
8102
|
-
return FromRecord11(schema_, references_,
|
|
8102
|
+
return FromRecord11(schema_, references_, path16, value);
|
|
8103
8103
|
case "Ref":
|
|
8104
|
-
return FromRef12(schema_, references_,
|
|
8104
|
+
return FromRef12(schema_, references_, path16, value);
|
|
8105
8105
|
case "This":
|
|
8106
|
-
return FromThis8(schema_, references_,
|
|
8106
|
+
return FromThis8(schema_, references_, path16, value);
|
|
8107
8107
|
case "Tuple":
|
|
8108
|
-
return FromTuple13(schema_, references_,
|
|
8108
|
+
return FromTuple13(schema_, references_, path16, value);
|
|
8109
8109
|
case "Union":
|
|
8110
|
-
return FromUnion18(schema_, references_,
|
|
8110
|
+
return FromUnion18(schema_, references_, path16, value);
|
|
8111
8111
|
default:
|
|
8112
|
-
return Default4(schema_,
|
|
8112
|
+
return Default4(schema_, path16, value);
|
|
8113
8113
|
}
|
|
8114
8114
|
}
|
|
8115
8115
|
function TransformEncode(schema, references, value) {
|
|
@@ -8377,18 +8377,18 @@ __export(pointer_exports, {
|
|
|
8377
8377
|
ValuePointerRootSetError: () => ValuePointerRootSetError
|
|
8378
8378
|
});
|
|
8379
8379
|
var ValuePointerRootSetError = class extends TypeBoxError {
|
|
8380
|
-
constructor(value,
|
|
8380
|
+
constructor(value, path16, update) {
|
|
8381
8381
|
super("Cannot set root value");
|
|
8382
8382
|
this.value = value;
|
|
8383
|
-
this.path =
|
|
8383
|
+
this.path = path16;
|
|
8384
8384
|
this.update = update;
|
|
8385
8385
|
}
|
|
8386
8386
|
};
|
|
8387
8387
|
var ValuePointerRootDeleteError = class extends TypeBoxError {
|
|
8388
|
-
constructor(value,
|
|
8388
|
+
constructor(value, path16) {
|
|
8389
8389
|
super("Cannot delete root value");
|
|
8390
8390
|
this.value = value;
|
|
8391
|
-
this.path =
|
|
8391
|
+
this.path = path16;
|
|
8392
8392
|
}
|
|
8393
8393
|
};
|
|
8394
8394
|
function Escape2(component) {
|
|
@@ -8532,82 +8532,82 @@ var ValueDiffError = class extends TypeBoxError {
|
|
|
8532
8532
|
this.value = value;
|
|
8533
8533
|
}
|
|
8534
8534
|
};
|
|
8535
|
-
function CreateUpdate(
|
|
8536
|
-
return { type: "update", path:
|
|
8535
|
+
function CreateUpdate(path16, value) {
|
|
8536
|
+
return { type: "update", path: path16, value };
|
|
8537
8537
|
}
|
|
8538
|
-
function CreateInsert(
|
|
8539
|
-
return { type: "insert", path:
|
|
8538
|
+
function CreateInsert(path16, value) {
|
|
8539
|
+
return { type: "insert", path: path16, value };
|
|
8540
8540
|
}
|
|
8541
|
-
function CreateDelete(
|
|
8542
|
-
return { type: "delete", path:
|
|
8541
|
+
function CreateDelete(path16) {
|
|
8542
|
+
return { type: "delete", path: path16 };
|
|
8543
8543
|
}
|
|
8544
8544
|
function AssertDiffable(value) {
|
|
8545
8545
|
if (globalThis.Object.getOwnPropertySymbols(value).length > 0)
|
|
8546
8546
|
throw new ValueDiffError(value, "Cannot diff objects with symbols");
|
|
8547
8547
|
}
|
|
8548
|
-
function* ObjectType4(
|
|
8548
|
+
function* ObjectType4(path16, current, next) {
|
|
8549
8549
|
AssertDiffable(current);
|
|
8550
8550
|
AssertDiffable(next);
|
|
8551
8551
|
if (!IsStandardObject(next))
|
|
8552
|
-
return yield CreateUpdate(
|
|
8552
|
+
return yield CreateUpdate(path16, next);
|
|
8553
8553
|
const currentKeys = globalThis.Object.getOwnPropertyNames(current);
|
|
8554
8554
|
const nextKeys = globalThis.Object.getOwnPropertyNames(next);
|
|
8555
8555
|
for (const key of nextKeys) {
|
|
8556
8556
|
if (HasPropertyKey2(current, key))
|
|
8557
8557
|
continue;
|
|
8558
|
-
yield CreateInsert(`${
|
|
8558
|
+
yield CreateInsert(`${path16}/${key}`, next[key]);
|
|
8559
8559
|
}
|
|
8560
8560
|
for (const key of currentKeys) {
|
|
8561
8561
|
if (!HasPropertyKey2(next, key))
|
|
8562
8562
|
continue;
|
|
8563
8563
|
if (Equal(current, next))
|
|
8564
8564
|
continue;
|
|
8565
|
-
yield* Visit15(`${
|
|
8565
|
+
yield* Visit15(`${path16}/${key}`, current[key], next[key]);
|
|
8566
8566
|
}
|
|
8567
8567
|
for (const key of currentKeys) {
|
|
8568
8568
|
if (HasPropertyKey2(next, key))
|
|
8569
8569
|
continue;
|
|
8570
|
-
yield CreateDelete(`${
|
|
8570
|
+
yield CreateDelete(`${path16}/${key}`);
|
|
8571
8571
|
}
|
|
8572
8572
|
}
|
|
8573
|
-
function* ArrayType4(
|
|
8573
|
+
function* ArrayType4(path16, current, next) {
|
|
8574
8574
|
if (!IsArray2(next))
|
|
8575
|
-
return yield CreateUpdate(
|
|
8575
|
+
return yield CreateUpdate(path16, next);
|
|
8576
8576
|
for (let i = 0; i < Math.min(current.length, next.length); i++) {
|
|
8577
|
-
yield* Visit15(`${
|
|
8577
|
+
yield* Visit15(`${path16}/${i}`, current[i], next[i]);
|
|
8578
8578
|
}
|
|
8579
8579
|
for (let i = 0; i < next.length; i++) {
|
|
8580
8580
|
if (i < current.length)
|
|
8581
8581
|
continue;
|
|
8582
|
-
yield CreateInsert(`${
|
|
8582
|
+
yield CreateInsert(`${path16}/${i}`, next[i]);
|
|
8583
8583
|
}
|
|
8584
8584
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
8585
8585
|
if (i < next.length)
|
|
8586
8586
|
continue;
|
|
8587
|
-
yield CreateDelete(`${
|
|
8587
|
+
yield CreateDelete(`${path16}/${i}`);
|
|
8588
8588
|
}
|
|
8589
8589
|
}
|
|
8590
|
-
function* TypedArrayType2(
|
|
8590
|
+
function* TypedArrayType2(path16, current, next) {
|
|
8591
8591
|
if (!IsTypedArray(next) || current.length !== next.length || globalThis.Object.getPrototypeOf(current).constructor.name !== globalThis.Object.getPrototypeOf(next).constructor.name)
|
|
8592
|
-
return yield CreateUpdate(
|
|
8592
|
+
return yield CreateUpdate(path16, next);
|
|
8593
8593
|
for (let i = 0; i < Math.min(current.length, next.length); i++) {
|
|
8594
|
-
yield* Visit15(`${
|
|
8594
|
+
yield* Visit15(`${path16}/${i}`, current[i], next[i]);
|
|
8595
8595
|
}
|
|
8596
8596
|
}
|
|
8597
|
-
function* ValueType2(
|
|
8597
|
+
function* ValueType2(path16, current, next) {
|
|
8598
8598
|
if (current === next)
|
|
8599
8599
|
return;
|
|
8600
|
-
yield CreateUpdate(
|
|
8600
|
+
yield CreateUpdate(path16, next);
|
|
8601
8601
|
}
|
|
8602
|
-
function* Visit15(
|
|
8602
|
+
function* Visit15(path16, current, next) {
|
|
8603
8603
|
if (IsStandardObject(current))
|
|
8604
|
-
return yield* ObjectType4(
|
|
8604
|
+
return yield* ObjectType4(path16, current, next);
|
|
8605
8605
|
if (IsArray2(current))
|
|
8606
|
-
return yield* ArrayType4(
|
|
8606
|
+
return yield* ArrayType4(path16, current, next);
|
|
8607
8607
|
if (IsTypedArray(current))
|
|
8608
|
-
return yield* TypedArrayType2(
|
|
8608
|
+
return yield* TypedArrayType2(path16, current, next);
|
|
8609
8609
|
if (IsValueType(current))
|
|
8610
|
-
return yield* ValueType2(
|
|
8610
|
+
return yield* ValueType2(path16, current, next);
|
|
8611
8611
|
throw new ValueDiffError(current, "Unable to diff value");
|
|
8612
8612
|
}
|
|
8613
8613
|
function Diff(current, next) {
|
|
@@ -8664,9 +8664,9 @@ var ValueMutateError = class extends TypeBoxError {
|
|
|
8664
8664
|
super(message);
|
|
8665
8665
|
}
|
|
8666
8666
|
};
|
|
8667
|
-
function ObjectType5(root,
|
|
8667
|
+
function ObjectType5(root, path16, current, next) {
|
|
8668
8668
|
if (!IsStandardObject2(current)) {
|
|
8669
|
-
pointer_exports.Set(root,
|
|
8669
|
+
pointer_exports.Set(root, path16, Clone2(next));
|
|
8670
8670
|
} else {
|
|
8671
8671
|
const currentKeys = Object.getOwnPropertyNames(current);
|
|
8672
8672
|
const nextKeys = Object.getOwnPropertyNames(next);
|
|
@@ -8681,43 +8681,43 @@ function ObjectType5(root, path15, current, next) {
|
|
|
8681
8681
|
}
|
|
8682
8682
|
}
|
|
8683
8683
|
for (const nextKey of nextKeys) {
|
|
8684
|
-
Visit16(root, `${
|
|
8684
|
+
Visit16(root, `${path16}/${nextKey}`, current[nextKey], next[nextKey]);
|
|
8685
8685
|
}
|
|
8686
8686
|
}
|
|
8687
8687
|
}
|
|
8688
|
-
function ArrayType5(root,
|
|
8688
|
+
function ArrayType5(root, path16, current, next) {
|
|
8689
8689
|
if (!IsArray2(current)) {
|
|
8690
|
-
pointer_exports.Set(root,
|
|
8690
|
+
pointer_exports.Set(root, path16, Clone2(next));
|
|
8691
8691
|
} else {
|
|
8692
8692
|
for (let index = 0; index < next.length; index++) {
|
|
8693
|
-
Visit16(root, `${
|
|
8693
|
+
Visit16(root, `${path16}/${index}`, current[index], next[index]);
|
|
8694
8694
|
}
|
|
8695
8695
|
current.splice(next.length);
|
|
8696
8696
|
}
|
|
8697
8697
|
}
|
|
8698
|
-
function TypedArrayType3(root,
|
|
8698
|
+
function TypedArrayType3(root, path16, current, next) {
|
|
8699
8699
|
if (IsTypedArray(current) && current.length === next.length) {
|
|
8700
8700
|
for (let i = 0; i < current.length; i++) {
|
|
8701
8701
|
current[i] = next[i];
|
|
8702
8702
|
}
|
|
8703
8703
|
} else {
|
|
8704
|
-
pointer_exports.Set(root,
|
|
8704
|
+
pointer_exports.Set(root, path16, Clone2(next));
|
|
8705
8705
|
}
|
|
8706
8706
|
}
|
|
8707
|
-
function ValueType3(root,
|
|
8707
|
+
function ValueType3(root, path16, current, next) {
|
|
8708
8708
|
if (current === next)
|
|
8709
8709
|
return;
|
|
8710
|
-
pointer_exports.Set(root,
|
|
8710
|
+
pointer_exports.Set(root, path16, next);
|
|
8711
8711
|
}
|
|
8712
|
-
function Visit16(root,
|
|
8712
|
+
function Visit16(root, path16, current, next) {
|
|
8713
8713
|
if (IsArray2(next))
|
|
8714
|
-
return ArrayType5(root,
|
|
8714
|
+
return ArrayType5(root, path16, current, next);
|
|
8715
8715
|
if (IsTypedArray(next))
|
|
8716
|
-
return TypedArrayType3(root,
|
|
8716
|
+
return TypedArrayType3(root, path16, current, next);
|
|
8717
8717
|
if (IsStandardObject2(next))
|
|
8718
|
-
return ObjectType5(root,
|
|
8718
|
+
return ObjectType5(root, path16, current, next);
|
|
8719
8719
|
if (IsValueType(next))
|
|
8720
|
-
return ValueType3(root,
|
|
8720
|
+
return ValueType3(root, path16, current, next);
|
|
8721
8721
|
}
|
|
8722
8722
|
function IsNonMutableValue(value) {
|
|
8723
8723
|
return IsTypedArray(value) || IsValueType(value);
|
|
@@ -8815,11 +8815,11 @@ __export(value_exports2, {
|
|
|
8815
8815
|
});
|
|
8816
8816
|
|
|
8817
8817
|
// src/lib/types.ts
|
|
8818
|
-
var CURRENT_REGISTRY_VERSION =
|
|
8818
|
+
var CURRENT_REGISTRY_VERSION = 7;
|
|
8819
8819
|
var CAPSULE_VERSION = 4;
|
|
8820
8820
|
var MAX_POST_ERROR_LENGTH = 500;
|
|
8821
8821
|
var MAX_NAME_LENGTH = 100;
|
|
8822
|
-
var DOCTOR_ALL_COOLDOWN_MS = 60 * 60 * 1e3;
|
|
8822
|
+
var DOCTOR_ALL_COOLDOWN_MS = 20 * 60 * 60 * 1e3;
|
|
8823
8823
|
var DOCTOR_PER_TOPIC_CAP_MS = 24 * 60 * 60 * 1e3;
|
|
8824
8824
|
var INACTIVE_AFTER_DAYS = 7;
|
|
8825
8825
|
var SPAM_THRESHOLD = 3;
|
|
@@ -8863,6 +8863,7 @@ var RegistrySchema = Type.Object({
|
|
|
8863
8863
|
topicManagerAdmins: Type.Array(Type.String()),
|
|
8864
8864
|
callbackSecret: Type.String(),
|
|
8865
8865
|
lastDoctorAllRunAt: Type.Union([Type.String(), Type.Null()]),
|
|
8866
|
+
dailyReportCronJobId: Type.Union([Type.String(), Type.Null()]),
|
|
8866
8867
|
autopilotEnabled: Type.Boolean(),
|
|
8867
8868
|
maxTopics: Type.Integer({ minimum: 1 }),
|
|
8868
8869
|
topics: Type.Record(Type.String(), TopicEntrySchema)
|
|
@@ -8943,6 +8944,12 @@ var migrations = {
|
|
|
8943
8944
|
}
|
|
8944
8945
|
}
|
|
8945
8946
|
return data;
|
|
8947
|
+
},
|
|
8948
|
+
"6_to_7": (data) => {
|
|
8949
|
+
if (data["dailyReportCronJobId"] === void 0) {
|
|
8950
|
+
data["dailyReportCronJobId"] = null;
|
|
8951
|
+
}
|
|
8952
|
+
return data;
|
|
8946
8953
|
}
|
|
8947
8954
|
};
|
|
8948
8955
|
function migrateRegistry(data) {
|
|
@@ -9298,6 +9305,8 @@ var AuthTier = {
|
|
|
9298
9305
|
var ADMIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
9299
9306
|
"doctor --all",
|
|
9300
9307
|
"doctor-all",
|
|
9308
|
+
"daily-report --all",
|
|
9309
|
+
"daily-report-all",
|
|
9301
9310
|
"list",
|
|
9302
9311
|
"sync",
|
|
9303
9312
|
"rename",
|
|
@@ -9517,8 +9526,9 @@ function buildHelpCard() {
|
|
|
9517
9526
|
"/tm doctor \u2014 run health checks",
|
|
9518
9527
|
"/tm doctor --all \u2014 check all topics at once",
|
|
9519
9528
|
"/tm daily-report \u2014 post a daily summary",
|
|
9520
|
-
"/tm
|
|
9521
|
-
"/tm autopilot
|
|
9529
|
+
"/tm daily-report --all \u2014 post daily summaries for all topics",
|
|
9530
|
+
"/tm autopilot enable \u2014 automatic daily reports and health checks",
|
|
9531
|
+
"/tm autopilot disable \u2014 turn off automatic reports and checks",
|
|
9522
9532
|
"",
|
|
9523
9533
|
"**Manage topics**",
|
|
9524
9534
|
"/tm rename new-name \u2014 rename this topic",
|
|
@@ -9867,20 +9877,22 @@ async function getConfigWrites(rpc) {
|
|
|
9867
9877
|
}
|
|
9868
9878
|
}
|
|
9869
9879
|
|
|
9880
|
+
// src/commands/autopilot.ts
|
|
9881
|
+
import * as fs6 from "node:fs";
|
|
9882
|
+
import * as path6 from "node:path";
|
|
9883
|
+
|
|
9870
9884
|
// src/lib/cron.ts
|
|
9871
9885
|
var DEFAULT_CRON_SCHEDULE = "0 9 * * *";
|
|
9872
9886
|
var DEFAULT_CRON_TZ = "UTC";
|
|
9873
|
-
async function
|
|
9887
|
+
async function registerCombinedCron(rpc, logger, schedule, tz) {
|
|
9874
9888
|
if (!rpc) {
|
|
9875
9889
|
return { jobId: null, error: "RPC not available" };
|
|
9876
9890
|
}
|
|
9877
|
-
const { topicName, slug, groupId, threadId, schedule, tz } = params;
|
|
9878
9891
|
const cronExpr = schedule ?? DEFAULT_CRON_SCHEDULE;
|
|
9879
9892
|
const timezone = tz ?? DEFAULT_CRON_TZ;
|
|
9880
|
-
const telegramTarget = `${groupId}:topic:${threadId}`;
|
|
9881
9893
|
try {
|
|
9882
9894
|
const result = await rpc.call("cron.add", {
|
|
9883
|
-
name:
|
|
9895
|
+
name: "tm-daily-combined",
|
|
9884
9896
|
schedule: {
|
|
9885
9897
|
kind: "cron",
|
|
9886
9898
|
expr: cronExpr,
|
|
@@ -9890,26 +9902,18 @@ async function registerDailyReportCron(rpc, params, logger) {
|
|
|
9890
9902
|
wakeMode: "now",
|
|
9891
9903
|
payload: {
|
|
9892
9904
|
kind: "agentTurn",
|
|
9893
|
-
message:
|
|
9894
|
-
},
|
|
9895
|
-
delivery: {
|
|
9896
|
-
mode: "announce",
|
|
9897
|
-
channels: {
|
|
9898
|
-
telegram: {
|
|
9899
|
-
to: telegramTarget
|
|
9900
|
-
}
|
|
9901
|
-
}
|
|
9905
|
+
message: 'Run topic_manager with command "daily-report --all" to post daily reports for all eligible topics. Then run topic_manager with command "doctor --all" to health-check all active topics.'
|
|
9902
9906
|
}
|
|
9903
9907
|
});
|
|
9904
9908
|
const jobId = result["jobId"] ?? result["id"] ?? null;
|
|
9905
9909
|
if (jobId) {
|
|
9906
|
-
logger.info(`[cron] Created daily
|
|
9910
|
+
logger.info(`[cron] Created combined daily job "${jobId}" (${cronExpr} ${timezone})`);
|
|
9907
9911
|
return { jobId };
|
|
9908
9912
|
}
|
|
9909
9913
|
return { jobId: null, error: "Gateway did not return a job ID" };
|
|
9910
9914
|
} catch (err) {
|
|
9911
9915
|
const msg = err instanceof Error ? err.message : String(err);
|
|
9912
|
-
logger.error(`[cron] Failed to create daily
|
|
9916
|
+
logger.error(`[cron] Failed to create combined daily job: ${msg}`);
|
|
9913
9917
|
return { jobId: null, error: msg };
|
|
9914
9918
|
}
|
|
9915
9919
|
}
|
|
@@ -9929,20 +9933,13 @@ async function removeCronJob(rpc, jobId, logger) {
|
|
|
9929
9933
|
}
|
|
9930
9934
|
|
|
9931
9935
|
// src/commands/autopilot.ts
|
|
9932
|
-
import * as fs6 from "node:fs";
|
|
9933
|
-
import * as path6 from "node:path";
|
|
9934
9936
|
var MARKER_START = "<!-- TM_AUTOPILOT_START -->";
|
|
9935
9937
|
var MARKER_END = "<!-- TM_AUTOPILOT_END -->";
|
|
9936
9938
|
var HEARTBEAT_BLOCK = `${MARKER_START}
|
|
9937
9939
|
## Topic Manager \u2014 Balanced Autopilot
|
|
9938
9940
|
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
1. CALL \`topic_manager\` with command "doctor --all" to health-check all active topics.
|
|
9942
|
-
This runs health checks AND posts daily progress reports for each eligible topic automatically.
|
|
9943
|
-
2. For each topic where STATUS.md "Last done (UTC)" is >3 days old:
|
|
9944
|
-
post a brief nudge in that topic asking the user for a status update.
|
|
9945
|
-
3. If no actions were taken in steps 1-2, do nothing (HEARTBEAT_OK).
|
|
9941
|
+
Daily reports and health checks are handled by the cron scheduler.
|
|
9942
|
+
No action needed here (HEARTBEAT_OK).
|
|
9946
9943
|
${MARKER_END}`;
|
|
9947
9944
|
var HEARTBEAT_FILENAME = "HEARTBEAT.md";
|
|
9948
9945
|
async function handleAutopilot(ctx, args) {
|
|
@@ -9968,7 +9965,7 @@ async function handleAutopilot(ctx, args) {
|
|
|
9968
9965
|
}
|
|
9969
9966
|
}
|
|
9970
9967
|
async function handleEnable(ctx) {
|
|
9971
|
-
const { workspaceDir } = ctx;
|
|
9968
|
+
const { workspaceDir, rpc, logger } = ctx;
|
|
9972
9969
|
const heartbeatPath = path6.join(workspaceDir, HEARTBEAT_FILENAME);
|
|
9973
9970
|
let content = "";
|
|
9974
9971
|
try {
|
|
@@ -9981,6 +9978,7 @@ async function handleEnable(ctx) {
|
|
|
9981
9978
|
await withRegistry(workspaceDir, (data) => {
|
|
9982
9979
|
data.autopilotEnabled = true;
|
|
9983
9980
|
});
|
|
9981
|
+
await ensureCombinedCron(workspaceDir, rpc, logger);
|
|
9984
9982
|
return { text: "Autopilot is already enabled." };
|
|
9985
9983
|
}
|
|
9986
9984
|
const newContent = content ? content.trimEnd() + "\n\n" + HEARTBEAT_BLOCK + "\n" : HEARTBEAT_BLOCK + "\n";
|
|
@@ -9988,14 +9986,17 @@ async function handleEnable(ctx) {
|
|
|
9988
9986
|
await withRegistry(workspaceDir, (data) => {
|
|
9989
9987
|
data.autopilotEnabled = true;
|
|
9990
9988
|
});
|
|
9989
|
+
await ensureCombinedCron(workspaceDir, rpc, logger);
|
|
9990
|
+
await cleanupPerTopicCrons(workspaceDir, rpc, logger);
|
|
9991
9991
|
return {
|
|
9992
|
-
text: "**Autopilot enabled.**\
|
|
9992
|
+
text: "**Autopilot enabled.**\nDaily reports and health checks will run automatically at 09:00 UTC."
|
|
9993
9993
|
};
|
|
9994
9994
|
}
|
|
9995
9995
|
async function handleDisable(ctx) {
|
|
9996
|
-
const { workspaceDir } = ctx;
|
|
9996
|
+
const { workspaceDir, rpc, logger } = ctx;
|
|
9997
9997
|
const heartbeatPath = path6.join(workspaceDir, HEARTBEAT_FILENAME);
|
|
9998
9998
|
if (!fs6.existsSync(heartbeatPath)) {
|
|
9999
|
+
await removeCombinedCron(workspaceDir, rpc, logger);
|
|
9999
10000
|
await withRegistry(workspaceDir, (data) => {
|
|
10000
10001
|
data.autopilotEnabled = false;
|
|
10001
10002
|
});
|
|
@@ -10003,6 +10004,7 @@ async function handleDisable(ctx) {
|
|
|
10003
10004
|
}
|
|
10004
10005
|
let content = fs6.readFileSync(heartbeatPath, "utf-8");
|
|
10005
10006
|
if (!content.includes(MARKER_START)) {
|
|
10007
|
+
await removeCombinedCron(workspaceDir, rpc, logger);
|
|
10006
10008
|
await withRegistry(workspaceDir, (data) => {
|
|
10007
10009
|
data.autopilotEnabled = false;
|
|
10008
10010
|
});
|
|
@@ -10020,11 +10022,12 @@ async function handleDisable(ctx) {
|
|
|
10020
10022
|
fs6.unlinkSync(heartbeatPath);
|
|
10021
10023
|
}
|
|
10022
10024
|
}
|
|
10025
|
+
await removeCombinedCron(workspaceDir, rpc, logger);
|
|
10023
10026
|
await withRegistry(workspaceDir, (data) => {
|
|
10024
10027
|
data.autopilotEnabled = false;
|
|
10025
10028
|
});
|
|
10026
10029
|
return {
|
|
10027
|
-
text: "**Autopilot disabled.**\nAutomatic health checks are now off."
|
|
10030
|
+
text: "**Autopilot disabled.**\nAutomatic daily reports and health checks are now off."
|
|
10028
10031
|
};
|
|
10029
10032
|
}
|
|
10030
10033
|
async function handleStatus(ctx) {
|
|
@@ -10032,14 +10035,52 @@ async function handleStatus(ctx) {
|
|
|
10032
10035
|
const registry = readRegistry(workspaceDir);
|
|
10033
10036
|
const enabled = registry.autopilotEnabled;
|
|
10034
10037
|
const lastRun = registry.lastDoctorAllRunAt ? relativeTime(registry.lastDoctorAllRunAt) : "never";
|
|
10038
|
+
const cronStatus = registry.dailyReportCronJobId ? "active (09:00 UTC)" : "not registered";
|
|
10035
10039
|
const lines = [
|
|
10036
10040
|
`**Autopilot:** ${enabled ? "enabled" : "disabled"}`,
|
|
10041
|
+
`**Daily cron:** ${cronStatus}`,
|
|
10037
10042
|
`**Last health check run:** ${lastRun}`
|
|
10038
10043
|
];
|
|
10039
10044
|
return {
|
|
10040
10045
|
text: lines.join("\n")
|
|
10041
10046
|
};
|
|
10042
10047
|
}
|
|
10048
|
+
async function ensureCombinedCron(workspaceDir, rpc, logger) {
|
|
10049
|
+
const registry = readRegistry(workspaceDir);
|
|
10050
|
+
if (registry.dailyReportCronJobId) return;
|
|
10051
|
+
const result = await registerCombinedCron(rpc, logger);
|
|
10052
|
+
if (result.jobId) {
|
|
10053
|
+
await withRegistry(workspaceDir, (data) => {
|
|
10054
|
+
data.dailyReportCronJobId = result.jobId;
|
|
10055
|
+
});
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10058
|
+
async function removeCombinedCron(workspaceDir, rpc, logger) {
|
|
10059
|
+
const registry = readRegistry(workspaceDir);
|
|
10060
|
+
if (!registry.dailyReportCronJobId) return;
|
|
10061
|
+
await removeCronJob(rpc, registry.dailyReportCronJobId, logger);
|
|
10062
|
+
await withRegistry(workspaceDir, (data) => {
|
|
10063
|
+
data.dailyReportCronJobId = null;
|
|
10064
|
+
});
|
|
10065
|
+
}
|
|
10066
|
+
async function cleanupPerTopicCrons(workspaceDir, rpc, logger) {
|
|
10067
|
+
const registry = readRegistry(workspaceDir);
|
|
10068
|
+
const topicsWithCron = Object.entries(registry.topics).filter(([, entry]) => entry.cronJobId !== null);
|
|
10069
|
+
if (topicsWithCron.length === 0) return;
|
|
10070
|
+
for (const [, entry] of topicsWithCron) {
|
|
10071
|
+
if (entry.cronJobId) {
|
|
10072
|
+
await removeCronJob(rpc, entry.cronJobId, logger);
|
|
10073
|
+
}
|
|
10074
|
+
}
|
|
10075
|
+
await withRegistry(workspaceDir, (data) => {
|
|
10076
|
+
for (const [key] of topicsWithCron) {
|
|
10077
|
+
const entry = data.topics[key];
|
|
10078
|
+
if (entry) {
|
|
10079
|
+
entry.cronJobId = null;
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
10082
|
+
});
|
|
10083
|
+
}
|
|
10043
10084
|
|
|
10044
10085
|
// src/commands/init.ts
|
|
10045
10086
|
var VALID_TYPES = /* @__PURE__ */ new Set(["coding", "research", "marketing", "general"]);
|
|
@@ -10181,25 +10222,6 @@ async function handleInit(ctx, args) {
|
|
|
10181
10222
|
restartMsg = `
|
|
10182
10223
|
Warning: config sync failed: ${msg}`;
|
|
10183
10224
|
}
|
|
10184
|
-
try {
|
|
10185
|
-
const cronResult = await registerDailyReportCron(rpc, {
|
|
10186
|
-
topicName: name,
|
|
10187
|
-
slug: finalSlug,
|
|
10188
|
-
groupId,
|
|
10189
|
-
threadId
|
|
10190
|
-
}, logger);
|
|
10191
|
-
if (cronResult.jobId) {
|
|
10192
|
-
await withRegistry(workspaceDir, (data) => {
|
|
10193
|
-
const entry = data.topics[key];
|
|
10194
|
-
if (entry) {
|
|
10195
|
-
entry.cronJobId = cronResult.jobId;
|
|
10196
|
-
}
|
|
10197
|
-
});
|
|
10198
|
-
}
|
|
10199
|
-
} catch (err) {
|
|
10200
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
10201
|
-
logger.error(`[init] Cron registration failed: ${msg}`);
|
|
10202
|
-
}
|
|
10203
10225
|
appendAudit(
|
|
10204
10226
|
workspaceDir,
|
|
10205
10227
|
buildAuditEntry(userId, "init", finalSlug, `Initialized topic name="${name}" type=${topicType} group=${groupId} thread=${threadId}`)
|
|
@@ -10646,6 +10668,15 @@ async function handleDoctor(ctx) {
|
|
|
10646
10668
|
if (!entry) {
|
|
10647
10669
|
return { text: "This topic is not registered. Run /tm init first." };
|
|
10648
10670
|
}
|
|
10671
|
+
if (entry.lastDoctorReportAt) {
|
|
10672
|
+
const elapsed = Date.now() - new Date(entry.lastDoctorReportAt).getTime();
|
|
10673
|
+
if (elapsed < DOCTOR_PER_TOPIC_CAP_MS) {
|
|
10674
|
+
const remainingHrs = Math.ceil((DOCTOR_PER_TOPIC_CAP_MS - elapsed) / 36e5);
|
|
10675
|
+
return {
|
|
10676
|
+
text: `This topic was checked recently. Next health check available in ~${remainingHrs} hour(s).`
|
|
10677
|
+
};
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10649
10680
|
const projectsBase = path9.join(workspaceDir, "projects");
|
|
10650
10681
|
if (!jailCheck(projectsBase, entry.slug)) {
|
|
10651
10682
|
return { text: "Something went wrong \u2014 path validation failed." };
|
|
@@ -11473,35 +11504,6 @@ async function handleArchiveToggle(ctx, archive) {
|
|
|
11473
11504
|
}
|
|
11474
11505
|
}
|
|
11475
11506
|
});
|
|
11476
|
-
if (archive && entry.cronJobId) {
|
|
11477
|
-
await removeCronJob(rpc, entry.cronJobId, logger);
|
|
11478
|
-
await withRegistry(workspaceDir, (data) => {
|
|
11479
|
-
const topic = data.topics[key];
|
|
11480
|
-
if (topic) {
|
|
11481
|
-
topic.cronJobId = null;
|
|
11482
|
-
}
|
|
11483
|
-
});
|
|
11484
|
-
} else if (!archive && !entry.cronJobId) {
|
|
11485
|
-
try {
|
|
11486
|
-
const cronResult = await registerDailyReportCron(rpc, {
|
|
11487
|
-
topicName: entry.name,
|
|
11488
|
-
slug: entry.slug,
|
|
11489
|
-
groupId,
|
|
11490
|
-
threadId
|
|
11491
|
-
}, logger);
|
|
11492
|
-
if (cronResult.jobId) {
|
|
11493
|
-
await withRegistry(workspaceDir, (data) => {
|
|
11494
|
-
const topic = data.topics[key];
|
|
11495
|
-
if (topic) {
|
|
11496
|
-
topic.cronJobId = cronResult.jobId;
|
|
11497
|
-
}
|
|
11498
|
-
});
|
|
11499
|
-
}
|
|
11500
|
-
} catch (err) {
|
|
11501
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
11502
|
-
logger.error(`[archive] Cron re-registration failed: ${msg}`);
|
|
11503
|
-
}
|
|
11504
|
-
}
|
|
11505
11507
|
let restartMsg = "";
|
|
11506
11508
|
try {
|
|
11507
11509
|
const updatedRegistry = readRegistry(workspaceDir);
|
|
@@ -11528,6 +11530,243 @@ Warning: config sync failed: ${msg}`;
|
|
|
11528
11530
|
};
|
|
11529
11531
|
}
|
|
11530
11532
|
|
|
11533
|
+
// src/commands/daily-report-all.ts
|
|
11534
|
+
import * as path14 from "node:path";
|
|
11535
|
+
function getDailyReportEligibility(entry, now, statusTimestamp) {
|
|
11536
|
+
if (entry.status === "archived") return { eligible: false, skipReason: "archived" };
|
|
11537
|
+
if (entry.snoozeUntil && new Date(entry.snoozeUntil).getTime() > now.getTime()) {
|
|
11538
|
+
return { eligible: false, skipReason: "snoozed" };
|
|
11539
|
+
}
|
|
11540
|
+
const lastActive = mostRecent(entry.lastMessageAt, statusTimestamp);
|
|
11541
|
+
if (lastActive) {
|
|
11542
|
+
const lastActiveMs = new Date(lastActive).getTime();
|
|
11543
|
+
const inactiveMs = INACTIVE_AFTER_DAYS * 24 * 60 * 60 * 1e3;
|
|
11544
|
+
if (now.getTime() - lastActiveMs > inactiveMs) {
|
|
11545
|
+
return { eligible: false, skipReason: "inactive" };
|
|
11546
|
+
}
|
|
11547
|
+
}
|
|
11548
|
+
if (entry.lastDailyReportAt) {
|
|
11549
|
+
const lastReport = new Date(entry.lastDailyReportAt);
|
|
11550
|
+
if (lastReport.getUTCFullYear() === now.getUTCFullYear() && lastReport.getUTCMonth() === now.getUTCMonth() && lastReport.getUTCDate() === now.getUTCDate()) {
|
|
11551
|
+
return { eligible: false, skipReason: "already-reported-today" };
|
|
11552
|
+
}
|
|
11553
|
+
}
|
|
11554
|
+
return { eligible: true };
|
|
11555
|
+
}
|
|
11556
|
+
var SKIP_ICONS2 = {
|
|
11557
|
+
archived: "\u{1F4E6}",
|
|
11558
|
+
// 📦
|
|
11559
|
+
snoozed: "\u{1F4A4}",
|
|
11560
|
+
// 💤
|
|
11561
|
+
inactive: "\u{1F507}",
|
|
11562
|
+
// 🔇
|
|
11563
|
+
"already-reported-today": "\u23F0"
|
|
11564
|
+
// ⏰
|
|
11565
|
+
};
|
|
11566
|
+
var SKIP_LABELS2 = {
|
|
11567
|
+
archived: "archived",
|
|
11568
|
+
snoozed: "snoozed",
|
|
11569
|
+
inactive: "inactive",
|
|
11570
|
+
"already-reported-today": "already reported today"
|
|
11571
|
+
};
|
|
11572
|
+
var SUMMARY_SOFT_LIMIT2 = 3800;
|
|
11573
|
+
function buildDailyReportAllSummary(data) {
|
|
11574
|
+
const {
|
|
11575
|
+
reportedTopics,
|
|
11576
|
+
skippedTopics,
|
|
11577
|
+
postFailures,
|
|
11578
|
+
migrationGroups,
|
|
11579
|
+
errors
|
|
11580
|
+
} = data;
|
|
11581
|
+
if (reportedTopics.length === 0 && skippedTopics.length === 0) {
|
|
11582
|
+
return "**Daily Report Summary**\n\nNo topics registered yet.";
|
|
11583
|
+
}
|
|
11584
|
+
const lines = ["**Daily Report Summary**", ""];
|
|
11585
|
+
let renderedCount = 0;
|
|
11586
|
+
for (const t of reportedTopics) {
|
|
11587
|
+
let icon;
|
|
11588
|
+
let label;
|
|
11589
|
+
switch (t.status) {
|
|
11590
|
+
case "reported":
|
|
11591
|
+
icon = "\u2705";
|
|
11592
|
+
label = "reported";
|
|
11593
|
+
break;
|
|
11594
|
+
case "post-failed":
|
|
11595
|
+
icon = "\u26A0\uFE0F";
|
|
11596
|
+
label = "failed to post";
|
|
11597
|
+
break;
|
|
11598
|
+
}
|
|
11599
|
+
const line = `${icon} ${t.name} \u2014 ${label}`;
|
|
11600
|
+
if (lines.join("\n").length + line.length > SUMMARY_SOFT_LIMIT2) {
|
|
11601
|
+
const remaining = reportedTopics.length - renderedCount;
|
|
11602
|
+
lines.push(`... and ${remaining} more`);
|
|
11603
|
+
break;
|
|
11604
|
+
}
|
|
11605
|
+
lines.push(line);
|
|
11606
|
+
renderedCount++;
|
|
11607
|
+
}
|
|
11608
|
+
if (skippedTopics.length > 0) {
|
|
11609
|
+
lines.push("");
|
|
11610
|
+
lines.push("\u23ED\uFE0F Skipped:");
|
|
11611
|
+
let skippedRendered = 0;
|
|
11612
|
+
for (const t of skippedTopics) {
|
|
11613
|
+
const icon = SKIP_ICONS2[t.reason];
|
|
11614
|
+
const label = SKIP_LABELS2[t.reason];
|
|
11615
|
+
const line = `${icon} ${t.name} \u2014 ${label}`;
|
|
11616
|
+
if (lines.join("\n").length + line.length > SUMMARY_SOFT_LIMIT2) {
|
|
11617
|
+
const remaining = skippedTopics.length - skippedRendered;
|
|
11618
|
+
lines.push(`... and ${remaining} more`);
|
|
11619
|
+
break;
|
|
11620
|
+
}
|
|
11621
|
+
lines.push(line);
|
|
11622
|
+
skippedRendered++;
|
|
11623
|
+
}
|
|
11624
|
+
}
|
|
11625
|
+
if (postFailures > 0) {
|
|
11626
|
+
lines.push("");
|
|
11627
|
+
lines.push(`\u26A0\uFE0F ${postFailures} topic(s) failed to post`);
|
|
11628
|
+
}
|
|
11629
|
+
if (migrationGroups > 0) {
|
|
11630
|
+
lines.push("");
|
|
11631
|
+
lines.push(`**Warning:** ${migrationGroups} group(s) had all topics fail. The group may have been migrated or deleted.`);
|
|
11632
|
+
}
|
|
11633
|
+
if (errors.length > 0) {
|
|
11634
|
+
lines.push("");
|
|
11635
|
+
lines.push(`**Errors (${errors.length}):**`);
|
|
11636
|
+
for (const e of errors.slice(0, 10)) {
|
|
11637
|
+
lines.push(`- ${e}`);
|
|
11638
|
+
}
|
|
11639
|
+
if (errors.length > 10) {
|
|
11640
|
+
lines.push(`... and ${errors.length - 10} more`);
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
return truncateMessage(lines.join("\n"));
|
|
11644
|
+
}
|
|
11645
|
+
async function handleDailyReportAll(ctx) {
|
|
11646
|
+
const { workspaceDir, logger } = ctx;
|
|
11647
|
+
const registry = readRegistry(workspaceDir);
|
|
11648
|
+
const userId = ctx.userId ?? registry.topicManagerAdmins[0];
|
|
11649
|
+
if (!userId) {
|
|
11650
|
+
return { text: "Something went wrong \u2014 could not identify your user account." };
|
|
11651
|
+
}
|
|
11652
|
+
const auth = checkAuthorization(userId, "daily-report-all", registry);
|
|
11653
|
+
if (!auth.authorized) {
|
|
11654
|
+
return { text: auth.message ?? "Not authorized." };
|
|
11655
|
+
}
|
|
11656
|
+
const now = /* @__PURE__ */ new Date();
|
|
11657
|
+
const projectsBase = path14.join(workspaceDir, "projects");
|
|
11658
|
+
const allEntries = Object.entries(registry.topics);
|
|
11659
|
+
const reportedTopics = [];
|
|
11660
|
+
const skippedTopics = [];
|
|
11661
|
+
const errors = [];
|
|
11662
|
+
const groupPostResults = /* @__PURE__ */ new Map();
|
|
11663
|
+
const reports = [];
|
|
11664
|
+
for (const [_key, entry] of allEntries) {
|
|
11665
|
+
const capsuleDir = path14.join(projectsBase, entry.slug);
|
|
11666
|
+
const statusContent = readFileOrNull(path14.join(capsuleDir, "STATUS.md"));
|
|
11667
|
+
const statusTs = statusContent ? extractStatusTimestamp(statusContent) : null;
|
|
11668
|
+
const eligibility = getDailyReportEligibility(entry, now, statusTs);
|
|
11669
|
+
if (!eligibility.eligible) {
|
|
11670
|
+
skippedTopics.push({ name: entry.name, reason: eligibility.skipReason });
|
|
11671
|
+
continue;
|
|
11672
|
+
}
|
|
11673
|
+
try {
|
|
11674
|
+
const doneContent = extractDoneSection(statusContent);
|
|
11675
|
+
const blockers = extractBlockers(statusContent);
|
|
11676
|
+
const nextContent = extractNextActions(statusContent);
|
|
11677
|
+
const reportData = {
|
|
11678
|
+
name: entry.name,
|
|
11679
|
+
doneContent,
|
|
11680
|
+
blockersContent: blockers,
|
|
11681
|
+
nextContent
|
|
11682
|
+
};
|
|
11683
|
+
const reportText = buildDailyReport(reportData, "html");
|
|
11684
|
+
reports.push({
|
|
11685
|
+
slug: entry.slug,
|
|
11686
|
+
groupId: entry.groupId,
|
|
11687
|
+
threadId: entry.threadId,
|
|
11688
|
+
text: reportText
|
|
11689
|
+
});
|
|
11690
|
+
const gk = entry.groupId;
|
|
11691
|
+
if (!groupPostResults.has(gk)) {
|
|
11692
|
+
groupPostResults.set(gk, { total: 0, failed: 0 });
|
|
11693
|
+
}
|
|
11694
|
+
groupPostResults.get(gk).total++;
|
|
11695
|
+
reportedTopics.push({ name: entry.name, slug: entry.slug, status: "reported" });
|
|
11696
|
+
} catch (err) {
|
|
11697
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11698
|
+
errors.push(`${entry.slug}: ${msg}`);
|
|
11699
|
+
logger.error(`[daily-report-all] Error processing ${entry.slug}: ${msg}`);
|
|
11700
|
+
const gk = entry.groupId;
|
|
11701
|
+
if (!groupPostResults.has(gk)) {
|
|
11702
|
+
groupPostResults.set(gk, { total: 0, failed: 0 });
|
|
11703
|
+
}
|
|
11704
|
+
groupPostResults.get(gk).total++;
|
|
11705
|
+
groupPostResults.get(gk).failed++;
|
|
11706
|
+
}
|
|
11707
|
+
}
|
|
11708
|
+
const migrationGroups = [];
|
|
11709
|
+
for (const [gid, stats] of groupPostResults) {
|
|
11710
|
+
if (stats.total > 0 && stats.failed === stats.total) {
|
|
11711
|
+
migrationGroups.push(gid);
|
|
11712
|
+
}
|
|
11713
|
+
}
|
|
11714
|
+
let postFailures = 0;
|
|
11715
|
+
const postFailedSlugs = /* @__PURE__ */ new Set();
|
|
11716
|
+
if (ctx.postFn && reports.length > 0) {
|
|
11717
|
+
const rateLimitedPost = createRateLimitedPoster(ctx.postFn);
|
|
11718
|
+
for (const report of reports) {
|
|
11719
|
+
try {
|
|
11720
|
+
await rateLimitedPost(report.groupId, report.threadId, report.text);
|
|
11721
|
+
await withRegistry(workspaceDir, (data) => {
|
|
11722
|
+
const key = `${report.groupId}:${report.threadId}`;
|
|
11723
|
+
const entry = data.topics[key];
|
|
11724
|
+
if (entry) {
|
|
11725
|
+
entry.lastDailyReportAt = now.toISOString();
|
|
11726
|
+
entry.lastPostError = null;
|
|
11727
|
+
}
|
|
11728
|
+
});
|
|
11729
|
+
} catch (err) {
|
|
11730
|
+
postFailures++;
|
|
11731
|
+
postFailedSlugs.add(report.slug);
|
|
11732
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11733
|
+
logger.error(`[daily-report-all] Post failed for ${report.slug}: ${msg}`);
|
|
11734
|
+
await withRegistry(workspaceDir, (data) => {
|
|
11735
|
+
const key = `${report.groupId}:${report.threadId}`;
|
|
11736
|
+
const entry = data.topics[key];
|
|
11737
|
+
if (entry) {
|
|
11738
|
+
entry.lastPostError = msg.slice(0, MAX_POST_ERROR_LENGTH);
|
|
11739
|
+
}
|
|
11740
|
+
});
|
|
11741
|
+
}
|
|
11742
|
+
}
|
|
11743
|
+
for (const outcome of reportedTopics) {
|
|
11744
|
+
if (postFailedSlugs.has(outcome.slug) && outcome.status === "reported") {
|
|
11745
|
+
outcome.status = "post-failed";
|
|
11746
|
+
}
|
|
11747
|
+
}
|
|
11748
|
+
} else if (reports.length > 0) {
|
|
11749
|
+
await withRegistry(workspaceDir, (data) => {
|
|
11750
|
+
for (const report of reports) {
|
|
11751
|
+
const key = `${report.groupId}:${report.threadId}`;
|
|
11752
|
+
const entry = data.topics[key];
|
|
11753
|
+
if (entry) {
|
|
11754
|
+
entry.lastDailyReportAt = now.toISOString();
|
|
11755
|
+
}
|
|
11756
|
+
}
|
|
11757
|
+
});
|
|
11758
|
+
}
|
|
11759
|
+
return {
|
|
11760
|
+
text: buildDailyReportAllSummary({
|
|
11761
|
+
reportedTopics,
|
|
11762
|
+
skippedTopics,
|
|
11763
|
+
postFailures,
|
|
11764
|
+
migrationGroups: migrationGroups.length,
|
|
11765
|
+
errors
|
|
11766
|
+
})
|
|
11767
|
+
};
|
|
11768
|
+
}
|
|
11769
|
+
|
|
11531
11770
|
// src/commands/help.ts
|
|
11532
11771
|
function handleHelp(_ctx) {
|
|
11533
11772
|
return {
|
|
@@ -11569,6 +11808,16 @@ function createTopicManagerTool(deps) {
|
|
|
11569
11808
|
logger.error(`[activity-tracking] Failed: ${msg}`);
|
|
11570
11809
|
});
|
|
11571
11810
|
}
|
|
11811
|
+
try {
|
|
11812
|
+
const migrationReg = readRegistry(workspaceDir);
|
|
11813
|
+
if (migrationReg.autopilotEnabled && !migrationReg.dailyReportCronJobId) {
|
|
11814
|
+
void ensureCombinedCron(workspaceDir, rpc, logger).then(() => cleanupPerTopicCrons(workspaceDir, rpc, logger)).catch((err) => {
|
|
11815
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11816
|
+
logger.error(`[cron-migration] Failed: ${msg}`);
|
|
11817
|
+
});
|
|
11818
|
+
}
|
|
11819
|
+
} catch {
|
|
11820
|
+
}
|
|
11572
11821
|
try {
|
|
11573
11822
|
switch (subCommand) {
|
|
11574
11823
|
case "init":
|
|
@@ -11599,7 +11848,12 @@ function createTopicManagerTool(deps) {
|
|
|
11599
11848
|
case "autopilot":
|
|
11600
11849
|
return await handleAutopilot(ctx, args);
|
|
11601
11850
|
case "daily-report":
|
|
11851
|
+
if (flags.has("--all") || flags.has("all")) {
|
|
11852
|
+
return await handleDailyReportAll(ctx);
|
|
11853
|
+
}
|
|
11602
11854
|
return await handleDailyReport(ctx);
|
|
11855
|
+
case "daily-report-all":
|
|
11856
|
+
return await handleDailyReportAll(ctx);
|
|
11603
11857
|
case "help":
|
|
11604
11858
|
return await handleHelp(ctx);
|
|
11605
11859
|
default:
|
|
@@ -11721,25 +11975,25 @@ async function handleCallback(data, ctx) {
|
|
|
11721
11975
|
// src/index.ts
|
|
11722
11976
|
function resolveConfigDir() {
|
|
11723
11977
|
const thisFile = new URL(import.meta.url).pathname;
|
|
11724
|
-
const parts = thisFile.split(
|
|
11978
|
+
const parts = thisFile.split(path15.sep);
|
|
11725
11979
|
const extIndex = parts.lastIndexOf("extensions");
|
|
11726
11980
|
if (extIndex > 0) {
|
|
11727
|
-
const candidate = parts.slice(0, extIndex).join(
|
|
11728
|
-
if (fs13.existsSync(
|
|
11981
|
+
const candidate = parts.slice(0, extIndex).join(path15.sep);
|
|
11982
|
+
if (fs13.existsSync(path15.join(candidate, "openclaw.json")) || fs13.existsSync(path15.join(candidate, "extensions"))) {
|
|
11729
11983
|
return candidate;
|
|
11730
11984
|
}
|
|
11731
11985
|
}
|
|
11732
11986
|
const envDir = process.env["OPENCLAW_CONFIG_DIR"];
|
|
11733
|
-
if (envDir && fs13.existsSync(envDir)) return
|
|
11987
|
+
if (envDir && fs13.existsSync(envDir)) return path15.resolve(envDir);
|
|
11734
11988
|
const homeDir = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
|
|
11735
|
-
const defaultDir =
|
|
11989
|
+
const defaultDir = path15.join(homeDir, ".openclaw");
|
|
11736
11990
|
if (fs13.existsSync(defaultDir)) return defaultDir;
|
|
11737
11991
|
return void 0;
|
|
11738
11992
|
}
|
|
11739
11993
|
function register(api) {
|
|
11740
11994
|
const resolvedConfigDir = resolveConfigDir();
|
|
11741
11995
|
const configDir = api.configDir ?? api.pluginConfig?.configDir ?? resolvedConfigDir;
|
|
11742
|
-
const workspaceDir = api.workspaceDir ?? api.pluginConfig?.workspaceDir ?? (resolvedConfigDir ?
|
|
11996
|
+
const workspaceDir = api.workspaceDir ?? api.pluginConfig?.workspaceDir ?? (resolvedConfigDir ? path15.join(resolvedConfigDir, "workspace") : void 0);
|
|
11743
11997
|
if (!configDir || !workspaceDir) {
|
|
11744
11998
|
api.logger.error(
|
|
11745
11999
|
"telegram-manager: configDir or workspaceDir not available. Plugin cannot initialize."
|