@faapi/faapi 6.28.0 → 6.30.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/dist/cli/index.js +37 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +16 -20
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3548,6 +3548,31 @@ var init_generateAgentArtifacts = __esm({
|
|
|
3548
3548
|
import fg4 from "fast-glob";
|
|
3549
3549
|
import path16 from "path";
|
|
3550
3550
|
import fs12 from "fs";
|
|
3551
|
+
function detectIgnoredMetaFields(source, strictHit) {
|
|
3552
|
+
const declared = /* @__PURE__ */ new Set();
|
|
3553
|
+
for (const line of source.split("\n")) {
|
|
3554
|
+
const trimmed = line.trim();
|
|
3555
|
+
if (trimmed.startsWith("//")) continue;
|
|
3556
|
+
for (const field of ALL_META_FIELDS) {
|
|
3557
|
+
if (new RegExp(`\\b${field}\\s*:`).test(trimmed)) declared.add(field);
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
return ALL_META_FIELDS.filter((field) => declared.has(field) && !strictHit[field]);
|
|
3561
|
+
}
|
|
3562
|
+
function warnIgnoredMetaFields(name, fields) {
|
|
3563
|
+
for (const field of fields) {
|
|
3564
|
+
if (STRING_META_FIELDS.includes(field)) {
|
|
3565
|
+
console.warn(
|
|
3566
|
+
`[faapi] Task "${name}" declares "${field}" but its value is not a string literal \u2014 the declaration was ignored and the task will not be cron-scheduled. Meta values are extracted from source code without importing it, so only literal values are recognized: use a quoted literal (cron: '0 3 * * *'), not an expression or a dynamic value.`
|
|
3567
|
+
);
|
|
3568
|
+
} else {
|
|
3569
|
+
const consequence = field === "timeoutMs" ? " and the task will run in-process with no timeout" : "";
|
|
3570
|
+
console.warn(
|
|
3571
|
+
`[faapi] Task "${name}" declares "${field}" but its value is not a numeric literal \u2014 the declaration was ignored${consequence}. Meta values are extracted from source code without importing it, so only literal values are recognized (underscores allowed, e.g. 1_800_000); expressions like 30 * 60_000 or dynamic values are not supported.`
|
|
3572
|
+
);
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3551
3576
|
function parseNumericLiteral(raw) {
|
|
3552
3577
|
return Number(raw.replace(/_/g, ""));
|
|
3553
3578
|
}
|
|
@@ -3607,11 +3632,19 @@ async function scanTasks(rootDir, patterns) {
|
|
|
3607
3632
|
manifest.timeoutMs = value;
|
|
3608
3633
|
}
|
|
3609
3634
|
if (graceMs !== void 0) manifest.graceMs = parseNumericLiteral(graceMs);
|
|
3635
|
+
const strictHit = {
|
|
3636
|
+
cron: cron !== void 0,
|
|
3637
|
+
concurrency: concurrency !== void 0,
|
|
3638
|
+
retries: retries !== void 0,
|
|
3639
|
+
timeoutMs: timeoutMs !== void 0,
|
|
3640
|
+
graceMs: graceMs !== void 0
|
|
3641
|
+
};
|
|
3642
|
+
warnIgnoredMetaFields(name, detectIgnoredMetaFields(source, strictHit));
|
|
3610
3643
|
tasks.push(manifest);
|
|
3611
3644
|
}
|
|
3612
3645
|
return tasks.sort((a, b) => a.name.localeCompare(b.name));
|
|
3613
3646
|
}
|
|
3614
|
-
var TASK_PATTERNS, TASK_FILENAME, CRON_RE, NUM_LITERAL, CONCURRENCY_RE, RETRIES_RE, TIMEOUT_MS_RE, GRACE_MS_RE, MIN_ISOLATED_TIMEOUT_MS, MAX_ISOLATED_TIMEOUT_MS;
|
|
3647
|
+
var TASK_PATTERNS, TASK_FILENAME, CRON_RE, NUM_LITERAL, CONCURRENCY_RE, RETRIES_RE, TIMEOUT_MS_RE, GRACE_MS_RE, NUMERIC_META_FIELDS, STRING_META_FIELDS, ALL_META_FIELDS, MIN_ISOLATED_TIMEOUT_MS, MAX_ISOLATED_TIMEOUT_MS;
|
|
3615
3648
|
var init_scanTasks = __esm({
|
|
3616
3649
|
"src/task/scanTasks.ts"() {
|
|
3617
3650
|
"use strict";
|
|
@@ -3623,6 +3656,9 @@ var init_scanTasks = __esm({
|
|
|
3623
3656
|
RETRIES_RE = new RegExp(`(?:^|\\n)\\s*retries:\\s*${NUM_LITERAL}`);
|
|
3624
3657
|
TIMEOUT_MS_RE = new RegExp(`(?:^|\\n)\\s*timeoutMs:\\s*${NUM_LITERAL}`);
|
|
3625
3658
|
GRACE_MS_RE = new RegExp(`(?:^|\\n)\\s*graceMs:\\s*${NUM_LITERAL}`);
|
|
3659
|
+
NUMERIC_META_FIELDS = ["concurrency", "retries", "timeoutMs", "graceMs"];
|
|
3660
|
+
STRING_META_FIELDS = ["cron"];
|
|
3661
|
+
ALL_META_FIELDS = [...NUMERIC_META_FIELDS, ...STRING_META_FIELDS];
|
|
3626
3662
|
MIN_ISOLATED_TIMEOUT_MS = 6e4;
|
|
3627
3663
|
MAX_ISOLATED_TIMEOUT_MS = 23 * 60 * 6e4;
|
|
3628
3664
|
}
|
|
@@ -10352,7 +10388,6 @@ async function createAppBase(options) {
|
|
|
10352
10388
|
wsRoutes,
|
|
10353
10389
|
rootDir,
|
|
10354
10390
|
dist,
|
|
10355
|
-
resourcesDir,
|
|
10356
10391
|
tasks: taskQueue,
|
|
10357
10392
|
async listen(listenPort) {
|
|
10358
10393
|
const envPort = process.env.PORT ? Number(process.env.PORT) : void 0;
|