@cedarjs/jobs 5.0.6 → 5.0.7-next.219
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/adapters/BaseAdapter/BaseAdapter.js +4 -28
- package/dist/adapters/PrismaAdapter/PrismaAdapter.js +11 -35
- package/dist/adapters/PrismaAdapter/errors.js +4 -28
- package/dist/bins/cedar-jobs-worker.js +25 -60
- package/dist/bins/cedar-jobs.js +35 -72
- package/dist/bins/rw-jobs-worker.js +1 -2
- package/dist/consts.js +4 -52
- package/dist/core/Executor.js +19 -39
- package/dist/core/JobManager.js +8 -32
- package/dist/core/Scheduler.js +20 -35
- package/dist/core/Worker.js +23 -40
- package/dist/errors.js +2 -41
- package/dist/index.js +9 -39
- package/dist/loaders.js +16 -51
- package/dist/setupEnv.js +4 -28
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -16
- package/dist/util.js +4 -28
- package/package.json +11 -13
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var BaseAdapter_exports = {};
|
|
20
|
-
__export(BaseAdapter_exports, {
|
|
21
|
-
BaseAdapter: () => BaseAdapter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(BaseAdapter_exports);
|
|
24
|
-
var import_consts = require("../../consts.js");
|
|
1
|
+
import { DEFAULT_LOGGER } from "../../consts.js";
|
|
25
2
|
class BaseAdapter {
|
|
26
3
|
options;
|
|
27
4
|
logger;
|
|
28
5
|
constructor(options) {
|
|
29
6
|
this.options = options;
|
|
30
|
-
this.logger = options?.logger ??
|
|
7
|
+
this.logger = options?.logger ?? DEFAULT_LOGGER;
|
|
31
8
|
}
|
|
32
9
|
}
|
|
33
|
-
|
|
34
|
-
0 && (module.exports = {
|
|
10
|
+
export {
|
|
35
11
|
BaseAdapter
|
|
36
|
-
}
|
|
12
|
+
};
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var PrismaAdapter_exports = {};
|
|
20
|
-
__export(PrismaAdapter_exports, {
|
|
21
|
-
PrismaAdapter: () => PrismaAdapter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(PrismaAdapter_exports);
|
|
24
|
-
var import_change_case = require("change-case");
|
|
25
|
-
var import_consts = require("../../consts.js");
|
|
26
|
-
var import_BaseAdapter = require("../BaseAdapter/BaseAdapter.js");
|
|
27
|
-
var import_errors = require("./errors.js");
|
|
1
|
+
import { camelCase } from "change-case";
|
|
2
|
+
import { DEFAULT_MAX_RUNTIME, DEFAULT_MODEL_NAME } from "../../consts.js";
|
|
3
|
+
import { BaseAdapter } from "../BaseAdapter/BaseAdapter.js";
|
|
4
|
+
import { ModelNameError } from "./errors.js";
|
|
28
5
|
function isPrismaAdapterDelegate(value) {
|
|
29
6
|
const candidate = value;
|
|
30
7
|
return candidate !== null && typeof candidate === "object" && typeof candidate.findFirst === "function" && typeof candidate.updateMany === "function" && typeof candidate.delete === "function" && typeof candidate.update === "function" && typeof candidate.create === "function" && typeof candidate.deleteMany === "function";
|
|
@@ -32,7 +9,7 @@ function isPrismaAdapterDelegate(value) {
|
|
|
32
9
|
function getDelegate(db, model) {
|
|
33
10
|
const delegate = db[model];
|
|
34
11
|
if (!isPrismaAdapterDelegate(delegate)) {
|
|
35
|
-
throw new
|
|
12
|
+
throw new ModelNameError(model);
|
|
36
13
|
}
|
|
37
14
|
return delegate;
|
|
38
15
|
}
|
|
@@ -46,7 +23,7 @@ function getActiveProvider(db) {
|
|
|
46
23
|
}
|
|
47
24
|
return provider;
|
|
48
25
|
}
|
|
49
|
-
class PrismaAdapter extends
|
|
26
|
+
class PrismaAdapter extends BaseAdapter {
|
|
50
27
|
db;
|
|
51
28
|
model;
|
|
52
29
|
accessor;
|
|
@@ -54,8 +31,8 @@ class PrismaAdapter extends import_BaseAdapter.BaseAdapter {
|
|
|
54
31
|
constructor(options) {
|
|
55
32
|
super(options);
|
|
56
33
|
this.db = options.db;
|
|
57
|
-
this.model = options.model ||
|
|
58
|
-
const camelName =
|
|
34
|
+
this.model = options.model || DEFAULT_MODEL_NAME;
|
|
35
|
+
const camelName = camelCase(String(this.model));
|
|
59
36
|
this.accessor = getDelegate(this.db, camelName);
|
|
60
37
|
this.provider = getActiveProvider(options.db);
|
|
61
38
|
}
|
|
@@ -71,7 +48,7 @@ class PrismaAdapter extends import_BaseAdapter.BaseAdapter {
|
|
|
71
48
|
queues
|
|
72
49
|
}) {
|
|
73
50
|
const maxRuntimeExpire = new Date(
|
|
74
|
-
(/* @__PURE__ */ new Date()).getTime() + (maxRuntime ||
|
|
51
|
+
(/* @__PURE__ */ new Date()).getTime() + (maxRuntime || DEFAULT_MAX_RUNTIME * 1e3)
|
|
75
52
|
);
|
|
76
53
|
const where = {
|
|
77
54
|
AND: [
|
|
@@ -201,7 +178,6 @@ ${error.stack}`,
|
|
|
201
178
|
await this.accessor.deleteMany();
|
|
202
179
|
}
|
|
203
180
|
}
|
|
204
|
-
|
|
205
|
-
0 && (module.exports = {
|
|
181
|
+
export {
|
|
206
182
|
PrismaAdapter
|
|
207
|
-
}
|
|
183
|
+
};
|
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var errors_exports = {};
|
|
20
|
-
__export(errors_exports, {
|
|
21
|
-
ModelNameError: () => ModelNameError
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(errors_exports);
|
|
24
|
-
var import_errors = require("../../errors.js");
|
|
25
|
-
class ModelNameError extends import_errors.CedarJSJobsError {
|
|
1
|
+
import { CedarJSJobsError } from "../../errors.js";
|
|
2
|
+
class ModelNameError extends CedarJSJobsError {
|
|
26
3
|
constructor(name) {
|
|
27
4
|
super(`Model \`${name}\` not found in PrismaClient`);
|
|
28
5
|
}
|
|
29
6
|
}
|
|
30
|
-
|
|
31
|
-
0 && (module.exports = {
|
|
7
|
+
export {
|
|
32
8
|
ModelNameError
|
|
33
|
-
}
|
|
9
|
+
};
|
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var cedar_jobs_worker_exports = {};
|
|
31
|
-
__export(cedar_jobs_worker_exports, {
|
|
32
|
-
getWorker: () => getWorker,
|
|
33
|
-
processName: () => processName
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(cedar_jobs_worker_exports);
|
|
36
|
-
var import_node_process = __toESM(require("node:process"));
|
|
37
|
-
var import_helpers = require("yargs/helpers");
|
|
38
|
-
var import_yargs = __toESM(require("yargs/yargs"));
|
|
39
|
-
var import_consts = require("../consts.js");
|
|
40
|
-
var import_errors = require("../errors.js");
|
|
41
|
-
var import_loaders = require("../loaders.js");
|
|
42
|
-
var import_setupEnv = require("../setupEnv.js");
|
|
43
|
-
(0, import_setupEnv.setupEnv)();
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { hideBin } from "yargs/helpers";
|
|
4
|
+
import yargs from "yargs/yargs";
|
|
5
|
+
import { PROCESS_TITLE_PREFIX } from "../consts.js";
|
|
6
|
+
import { WorkerConfigIndexNotFoundError } from "../errors.js";
|
|
7
|
+
import { loadJobsManager } from "../loaders.js";
|
|
8
|
+
import { setupEnv } from "../setupEnv.js";
|
|
9
|
+
setupEnv();
|
|
44
10
|
const parseArgs = (argv) => {
|
|
45
|
-
return (
|
|
11
|
+
return yargs(hideBin(argv)).usage(
|
|
46
12
|
"Starts a single CedarJS Jobs worker to process background jobs\n\nUsage: $0 [options]"
|
|
47
13
|
).option("index", {
|
|
48
14
|
type: "number",
|
|
@@ -66,20 +32,20 @@ const processName = ({
|
|
|
66
32
|
id,
|
|
67
33
|
queues
|
|
68
34
|
}) => {
|
|
69
|
-
return `${
|
|
35
|
+
return `${PROCESS_TITLE_PREFIX}.${[queues].flat().join("-")}.${id}`;
|
|
70
36
|
};
|
|
71
37
|
const setupSignals = ({ worker }) => {
|
|
72
|
-
|
|
38
|
+
process.on("SIGINT", () => {
|
|
73
39
|
worker.logger.warn(
|
|
74
|
-
`[${
|
|
40
|
+
`[${process.title}] SIGINT received at ${(/* @__PURE__ */ new Date()).toISOString()}, finishing work...`
|
|
75
41
|
);
|
|
76
42
|
worker.forever = false;
|
|
77
43
|
});
|
|
78
|
-
|
|
44
|
+
process.on("SIGTERM", () => {
|
|
79
45
|
worker.logger.warn(
|
|
80
|
-
`[${
|
|
46
|
+
`[${process.title}] SIGTERM received at ${(/* @__PURE__ */ new Date()).toISOString()}, exiting now!`
|
|
81
47
|
);
|
|
82
|
-
|
|
48
|
+
process.exit(0);
|
|
83
49
|
});
|
|
84
50
|
};
|
|
85
51
|
const getWorker = async ({
|
|
@@ -90,14 +56,14 @@ const getWorker = async ({
|
|
|
90
56
|
}) => {
|
|
91
57
|
let manager;
|
|
92
58
|
try {
|
|
93
|
-
manager = await
|
|
59
|
+
manager = await loadJobsManager();
|
|
94
60
|
} catch (e) {
|
|
95
61
|
console.error(e);
|
|
96
|
-
|
|
62
|
+
process.exit(1);
|
|
97
63
|
}
|
|
98
64
|
const workerConfig = manager.workers[index];
|
|
99
65
|
if (!workerConfig) {
|
|
100
|
-
throw new
|
|
66
|
+
throw new WorkerConfigIndexNotFoundError(index);
|
|
101
67
|
}
|
|
102
68
|
return manager.createWorker({
|
|
103
69
|
index,
|
|
@@ -107,20 +73,19 @@ const getWorker = async ({
|
|
|
107
73
|
});
|
|
108
74
|
};
|
|
109
75
|
const main = async () => {
|
|
110
|
-
const { index, id, clear, workoff } = await parseArgs(
|
|
76
|
+
const { index, id, clear, workoff } = await parseArgs(process.argv);
|
|
111
77
|
const worker = await getWorker({ index, id, clear, workoff });
|
|
112
|
-
|
|
78
|
+
process.title = processName({ id, queues: worker.queues });
|
|
113
79
|
worker.run().then(() => {
|
|
114
|
-
worker.logger.info(`[${
|
|
115
|
-
|
|
80
|
+
worker.logger.info(`[${process.title}] Worker finished, shutting down.`);
|
|
81
|
+
process.exit(0);
|
|
116
82
|
});
|
|
117
83
|
setupSignals({ worker });
|
|
118
84
|
};
|
|
119
|
-
if (
|
|
85
|
+
if (process.env.NODE_ENV !== "test") {
|
|
120
86
|
main();
|
|
121
87
|
}
|
|
122
|
-
|
|
123
|
-
0 && (module.exports = {
|
|
88
|
+
export {
|
|
124
89
|
getWorker,
|
|
125
90
|
processName
|
|
126
|
-
}
|
|
91
|
+
};
|
package/dist/bins/cedar-jobs.js
CHANGED
|
@@ -1,59 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var cedar_jobs_exports = {};
|
|
31
|
-
__export(cedar_jobs_exports, {
|
|
32
|
-
buildNumWorkers: () => buildNumWorkers,
|
|
33
|
-
clearQueue: () => clearQueue,
|
|
34
|
-
startWorkers: () => startWorkers,
|
|
35
|
-
stopWorkers: () => stopWorkers
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(cedar_jobs_exports);
|
|
38
|
-
var import_node_child_process = require("node:child_process");
|
|
39
|
-
var import_node_console = __toESM(require("node:console"));
|
|
40
|
-
var import_node_path = __toESM(require("node:path"));
|
|
41
|
-
var import_node_process = __toESM(require("node:process"));
|
|
42
|
-
var import_node_timers = require("node:timers");
|
|
43
|
-
var import_helpers = require("yargs/helpers");
|
|
44
|
-
var import_yargs = __toESM(require("yargs/yargs"));
|
|
45
|
-
var import_consts = require("../consts.js");
|
|
46
|
-
var import_loaders = require("../loaders.js");
|
|
47
|
-
var import_setupEnv = require("../setupEnv.js");
|
|
48
|
-
(0, import_setupEnv.setupEnv)();
|
|
49
|
-
import_node_process.default.title = "cedar-jobs";
|
|
50
|
-
const WORKER_PATH = import_node_path.default.join(__dirname, "cedar-jobs-worker.js");
|
|
2
|
+
import { fork, exec } from "node:child_process";
|
|
3
|
+
import console from "node:console";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { setTimeout } from "node:timers";
|
|
7
|
+
import { hideBin } from "yargs/helpers";
|
|
8
|
+
import yargs from "yargs/yargs";
|
|
9
|
+
import { DEFAULT_LOGGER, PROCESS_TITLE_PREFIX } from "../consts.js";
|
|
10
|
+
import { loadJobsManager } from "../loaders.js";
|
|
11
|
+
import { setupEnv } from "../setupEnv.js";
|
|
12
|
+
setupEnv();
|
|
13
|
+
process.title = "cedar-jobs";
|
|
14
|
+
const WORKER_PATH = path.join(import.meta.dirname, "cedar-jobs-worker.js");
|
|
51
15
|
const parseArgs = (argv) => {
|
|
52
|
-
const commandString =
|
|
16
|
+
const commandString = hideBin(argv);
|
|
53
17
|
if (commandString.length === 1 && commandString[0] === "jobs") {
|
|
54
18
|
commandString.shift();
|
|
55
19
|
}
|
|
56
|
-
const parsed = (
|
|
20
|
+
const parsed = yargs(commandString).usage(
|
|
57
21
|
"Starts the CedarJS Jobs runner to process background jobs\n\nUsage: cedar jobs <command> [options]"
|
|
58
22
|
).command("work", "Start a worker and process jobs").command("workoff", "Start a worker and exit after all jobs processed").command("start", "Start workers in daemon mode").command("stop", "Stop any daemonized job workers").command("restart", "Stop and start any daemonized job workers").command("clear", "Clear the job queue").demandCommand(1, "You must specify a mode to start in").example(
|
|
59
23
|
"cedar jobs work",
|
|
@@ -64,7 +28,7 @@ const parseArgs = (argv) => {
|
|
|
64
28
|
).help().parse(commandString, (_err, _argv, output) => {
|
|
65
29
|
if (output) {
|
|
66
30
|
const newOutput = output.replaceAll("cedar-jobs.js", "cedar jobs");
|
|
67
|
-
|
|
31
|
+
console.log(newOutput);
|
|
68
32
|
}
|
|
69
33
|
});
|
|
70
34
|
return { command: parsed._[0] };
|
|
@@ -90,10 +54,10 @@ const startWorkers = ({
|
|
|
90
54
|
if (workoff) {
|
|
91
55
|
workerArgs.push("--workoff");
|
|
92
56
|
}
|
|
93
|
-
const worker =
|
|
57
|
+
const worker = fork(WORKER_PATH, workerArgs, {
|
|
94
58
|
detached: detach,
|
|
95
59
|
stdio: detach ? "ignore" : "inherit",
|
|
96
|
-
env:
|
|
60
|
+
env: process.env
|
|
97
61
|
});
|
|
98
62
|
if (detach) {
|
|
99
63
|
worker.unref();
|
|
@@ -119,22 +83,22 @@ const stopWorkers = async ({
|
|
|
119
83
|
}
|
|
120
84
|
for (const processId of processIds) {
|
|
121
85
|
logger.info(`Stopping process id ${processId}...`);
|
|
122
|
-
|
|
86
|
+
process.kill(processId, signal);
|
|
123
87
|
while ((await findWorkerProcesses(processId)).length) {
|
|
124
|
-
await new Promise((resolve) =>
|
|
88
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
125
89
|
}
|
|
126
90
|
}
|
|
127
91
|
};
|
|
128
92
|
const clearQueue = ({ logger }) => {
|
|
129
93
|
logger.warn(`Starting worker to clear job queue...`);
|
|
130
|
-
|
|
94
|
+
fork(WORKER_PATH, ["--clear", "--index", "0", "--id", "0"]);
|
|
131
95
|
};
|
|
132
96
|
const signalSetup = ({
|
|
133
97
|
workers,
|
|
134
98
|
logger
|
|
135
99
|
}) => {
|
|
136
100
|
let sigtermCount = 0;
|
|
137
|
-
|
|
101
|
+
process.on("SIGINT", () => {
|
|
138
102
|
sigtermCount++;
|
|
139
103
|
let message = "SIGINT received: shutting down workers gracefully (press Ctrl-C again to exit immediately)...";
|
|
140
104
|
if (sigtermCount > 1) {
|
|
@@ -152,12 +116,12 @@ const signalSetup = ({
|
|
|
152
116
|
};
|
|
153
117
|
const findWorkerProcesses = async (id) => {
|
|
154
118
|
return new Promise(function(resolve, reject) {
|
|
155
|
-
const platform =
|
|
156
|
-
const cmd = platform === "win32" ? "tasklist" : platform === "darwin" ? "ps -ax | grep " +
|
|
119
|
+
const platform = process.platform;
|
|
120
|
+
const cmd = platform === "win32" ? "tasklist" : platform === "darwin" ? "ps -ax | grep " + PROCESS_TITLE_PREFIX : platform === "linux" ? "ps -A" : "";
|
|
157
121
|
if (cmd === "") {
|
|
158
122
|
resolve([]);
|
|
159
123
|
}
|
|
160
|
-
|
|
124
|
+
exec(cmd, function(err, stdout) {
|
|
161
125
|
if (err) {
|
|
162
126
|
reject(err);
|
|
163
127
|
}
|
|
@@ -181,17 +145,17 @@ const findWorkerProcesses = async (id) => {
|
|
|
181
145
|
});
|
|
182
146
|
};
|
|
183
147
|
const main = async () => {
|
|
184
|
-
const { command } = parseArgs(
|
|
148
|
+
const { command } = parseArgs(process.argv);
|
|
185
149
|
let jobsConfig;
|
|
186
150
|
try {
|
|
187
|
-
jobsConfig = await
|
|
151
|
+
jobsConfig = await loadJobsManager();
|
|
188
152
|
} catch (e) {
|
|
189
|
-
|
|
190
|
-
|
|
153
|
+
console.error(e);
|
|
154
|
+
process.exit(1);
|
|
191
155
|
}
|
|
192
156
|
const workerConfig = jobsConfig.workers;
|
|
193
157
|
const numWorkers = buildNumWorkers(workerConfig);
|
|
194
|
-
const logger = jobsConfig.logger ??
|
|
158
|
+
const logger = jobsConfig.logger ?? DEFAULT_LOGGER;
|
|
195
159
|
logger.warn(`Starting CedarJS Jobs Runner at ${(/* @__PURE__ */ new Date()).toISOString()}...`);
|
|
196
160
|
switch (command) {
|
|
197
161
|
case "start":
|
|
@@ -200,7 +164,7 @@ const main = async () => {
|
|
|
200
164
|
detach: true,
|
|
201
165
|
logger
|
|
202
166
|
});
|
|
203
|
-
return
|
|
167
|
+
return process.exit(0);
|
|
204
168
|
case "stop":
|
|
205
169
|
return await stopWorkers({
|
|
206
170
|
numWorkers,
|
|
@@ -214,7 +178,7 @@ const main = async () => {
|
|
|
214
178
|
detach: true,
|
|
215
179
|
logger
|
|
216
180
|
});
|
|
217
|
-
return
|
|
181
|
+
return process.exit(0);
|
|
218
182
|
case "work":
|
|
219
183
|
return signalSetup({
|
|
220
184
|
workers: startWorkers({
|
|
@@ -236,13 +200,12 @@ const main = async () => {
|
|
|
236
200
|
return clearQueue({ logger });
|
|
237
201
|
}
|
|
238
202
|
};
|
|
239
|
-
if (
|
|
203
|
+
if (process.env.NODE_ENV !== "test") {
|
|
240
204
|
main();
|
|
241
205
|
}
|
|
242
|
-
|
|
243
|
-
0 && (module.exports = {
|
|
206
|
+
export {
|
|
244
207
|
buildNumWorkers,
|
|
245
208
|
clearQueue,
|
|
246
209
|
startWorkers,
|
|
247
210
|
stopWorkers
|
|
248
|
-
}
|
|
211
|
+
};
|
package/dist/consts.js
CHANGED
|
@@ -1,57 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var consts_exports = {};
|
|
30
|
-
__export(consts_exports, {
|
|
31
|
-
DEFAULT_ADAPTER_NAME: () => DEFAULT_ADAPTER_NAME,
|
|
32
|
-
DEFAULT_DELETE_FAILED_JOBS: () => DEFAULT_DELETE_FAILED_JOBS,
|
|
33
|
-
DEFAULT_DELETE_SUCCESSFUL_JOBS: () => DEFAULT_DELETE_SUCCESSFUL_JOBS,
|
|
34
|
-
DEFAULT_LOGGER: () => DEFAULT_LOGGER,
|
|
35
|
-
DEFAULT_LOGGER_NAME: () => DEFAULT_LOGGER_NAME,
|
|
36
|
-
DEFAULT_MAX_ATTEMPTS: () => DEFAULT_MAX_ATTEMPTS,
|
|
37
|
-
DEFAULT_MAX_RUNTIME: () => DEFAULT_MAX_RUNTIME,
|
|
38
|
-
DEFAULT_MODEL_NAME: () => DEFAULT_MODEL_NAME,
|
|
39
|
-
DEFAULT_PRIORITY: () => DEFAULT_PRIORITY,
|
|
40
|
-
DEFAULT_QUEUE: () => DEFAULT_QUEUE,
|
|
41
|
-
DEFAULT_SLEEP_DELAY: () => DEFAULT_SLEEP_DELAY,
|
|
42
|
-
DEFAULT_WAIT: () => DEFAULT_WAIT,
|
|
43
|
-
DEFAULT_WAIT_UNTIL: () => DEFAULT_WAIT_UNTIL,
|
|
44
|
-
DEFAULT_WORK_QUEUE: () => DEFAULT_WORK_QUEUE,
|
|
45
|
-
PROCESS_TITLE_PREFIX: () => PROCESS_TITLE_PREFIX
|
|
46
|
-
});
|
|
47
|
-
module.exports = __toCommonJS(consts_exports);
|
|
48
|
-
var import_node_console = __toESM(require("node:console"));
|
|
1
|
+
import console from "node:console";
|
|
49
2
|
const DEFAULT_MAX_ATTEMPTS = 24;
|
|
50
3
|
const DEFAULT_MAX_RUNTIME = 14400;
|
|
51
4
|
const DEFAULT_SLEEP_DELAY = 5;
|
|
52
5
|
const DEFAULT_DELETE_SUCCESSFUL_JOBS = true;
|
|
53
6
|
const DEFAULT_DELETE_FAILED_JOBS = false;
|
|
54
|
-
const DEFAULT_LOGGER =
|
|
7
|
+
const DEFAULT_LOGGER = console;
|
|
55
8
|
const DEFAULT_QUEUE = "default";
|
|
56
9
|
const DEFAULT_WORK_QUEUE = "*";
|
|
57
10
|
const DEFAULT_PRIORITY = 50;
|
|
@@ -61,8 +14,7 @@ const PROCESS_TITLE_PREFIX = "cedar-jobs-worker";
|
|
|
61
14
|
const DEFAULT_MODEL_NAME = "BackgroundJob";
|
|
62
15
|
const DEFAULT_ADAPTER_NAME = "adapter";
|
|
63
16
|
const DEFAULT_LOGGER_NAME = "logger";
|
|
64
|
-
|
|
65
|
-
0 && (module.exports = {
|
|
17
|
+
export {
|
|
66
18
|
DEFAULT_ADAPTER_NAME,
|
|
67
19
|
DEFAULT_DELETE_FAILED_JOBS,
|
|
68
20
|
DEFAULT_DELETE_SUCCESSFUL_JOBS,
|
|
@@ -78,4 +30,4 @@ const DEFAULT_LOGGER_NAME = "logger";
|
|
|
78
30
|
DEFAULT_WAIT_UNTIL,
|
|
79
31
|
DEFAULT_WORK_QUEUE,
|
|
80
32
|
PROCESS_TITLE_PREFIX
|
|
81
|
-
}
|
|
33
|
+
};
|
package/dist/core/Executor.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Executor_exports = {};
|
|
20
|
-
__export(Executor_exports, {
|
|
21
|
-
DEFAULTS: () => DEFAULTS,
|
|
22
|
-
Executor: () => Executor
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Executor_exports);
|
|
25
|
-
var import_cron_parser = require("cron-parser");
|
|
26
|
-
var import_consts = require("../consts.js");
|
|
27
|
-
var import_errors = require("../errors.js");
|
|
28
|
-
var import_loaders = require("../loaders.js");
|
|
1
|
+
import { CronExpressionParser } from "cron-parser";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_MAX_ATTEMPTS,
|
|
4
|
+
DEFAULT_DELETE_FAILED_JOBS,
|
|
5
|
+
DEFAULT_DELETE_SUCCESSFUL_JOBS,
|
|
6
|
+
DEFAULT_LOGGER
|
|
7
|
+
} from "../consts.js";
|
|
8
|
+
import { AdapterRequiredError, JobRequiredError } from "../errors.js";
|
|
9
|
+
import { loadJob } from "../loaders.js";
|
|
29
10
|
const DEFAULTS = {
|
|
30
|
-
logger:
|
|
31
|
-
maxAttempts:
|
|
32
|
-
deleteFailedJobs:
|
|
33
|
-
deleteSuccessfulJobs:
|
|
11
|
+
logger: DEFAULT_LOGGER,
|
|
12
|
+
maxAttempts: DEFAULT_MAX_ATTEMPTS,
|
|
13
|
+
deleteFailedJobs: DEFAULT_DELETE_FAILED_JOBS,
|
|
14
|
+
deleteSuccessfulJobs: DEFAULT_DELETE_SUCCESSFUL_JOBS
|
|
34
15
|
};
|
|
35
16
|
class Executor {
|
|
36
17
|
options;
|
|
@@ -43,10 +24,10 @@ class Executor {
|
|
|
43
24
|
constructor(options) {
|
|
44
25
|
this.options = { ...DEFAULTS, ...options };
|
|
45
26
|
if (!this.options.adapter) {
|
|
46
|
-
throw new
|
|
27
|
+
throw new AdapterRequiredError();
|
|
47
28
|
}
|
|
48
29
|
if (!this.options.job) {
|
|
49
|
-
throw new
|
|
30
|
+
throw new JobRequiredError();
|
|
50
31
|
}
|
|
51
32
|
this.adapter = this.options.adapter;
|
|
52
33
|
this.logger = this.options.logger;
|
|
@@ -61,9 +42,9 @@ class Executor {
|
|
|
61
42
|
async perform() {
|
|
62
43
|
this.logger.info(`[CedarJS Jobs] Started job ${this.jobIdentifier}`);
|
|
63
44
|
try {
|
|
64
|
-
const job = await
|
|
45
|
+
const job = await loadJob({ name: this.job.name, path: this.job.path });
|
|
65
46
|
await job.perform(...this.job.args);
|
|
66
|
-
const runAt = this.job.cron ?
|
|
47
|
+
const runAt = this.job.cron ? CronExpressionParser.parse(this.job.cron).next().toDate() : void 0;
|
|
67
48
|
await this.adapter.success({
|
|
68
49
|
job: this.job,
|
|
69
50
|
runAt,
|
|
@@ -94,8 +75,7 @@ class Executor {
|
|
|
94
75
|
return 1e3 * attempts ** 4;
|
|
95
76
|
}
|
|
96
77
|
}
|
|
97
|
-
|
|
98
|
-
0 && (module.exports = {
|
|
78
|
+
export {
|
|
99
79
|
DEFAULTS,
|
|
100
80
|
Executor
|
|
101
|
-
}
|
|
81
|
+
};
|
package/dist/core/JobManager.js
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var JobManager_exports = {};
|
|
20
|
-
__export(JobManager_exports, {
|
|
21
|
-
JobManager: () => JobManager
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(JobManager_exports);
|
|
24
|
-
var import_errors = require("../errors.js");
|
|
25
|
-
var import_Scheduler = require("./Scheduler.js");
|
|
26
|
-
var import_Worker = require("./Worker.js");
|
|
1
|
+
import { AdapterNotFoundError } from "../errors.js";
|
|
2
|
+
import { Scheduler } from "./Scheduler.js";
|
|
3
|
+
import { Worker } from "./Worker.js";
|
|
27
4
|
class JobManager {
|
|
28
5
|
adapters;
|
|
29
6
|
queues;
|
|
@@ -36,7 +13,7 @@ class JobManager {
|
|
|
36
13
|
this.workers = config.workers;
|
|
37
14
|
}
|
|
38
15
|
createScheduler(schedulerConfig) {
|
|
39
|
-
const scheduler = new
|
|
16
|
+
const scheduler = new Scheduler({
|
|
40
17
|
adapter: this.adapters[schedulerConfig.adapter],
|
|
41
18
|
logger: schedulerConfig.logger ?? this.logger
|
|
42
19
|
});
|
|
@@ -55,9 +32,9 @@ class JobManager {
|
|
|
55
32
|
const config = this.workers[index];
|
|
56
33
|
const adapter = this.adapters[config.adapter];
|
|
57
34
|
if (!adapter) {
|
|
58
|
-
throw new
|
|
35
|
+
throw new AdapterNotFoundError(config.adapter.toString());
|
|
59
36
|
}
|
|
60
|
-
return new
|
|
37
|
+
return new Worker({
|
|
61
38
|
adapter: this.adapters[config.adapter],
|
|
62
39
|
logger: config.logger || this.logger,
|
|
63
40
|
maxAttempts: config.maxAttempts,
|
|
@@ -72,7 +49,6 @@ class JobManager {
|
|
|
72
49
|
});
|
|
73
50
|
}
|
|
74
51
|
}
|
|
75
|
-
|
|
76
|
-
0 && (module.exports = {
|
|
52
|
+
export {
|
|
77
53
|
JobManager
|
|
78
|
-
}
|
|
54
|
+
};
|
package/dist/core/Scheduler.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Scheduler_exports = {};
|
|
20
|
-
__export(Scheduler_exports, {
|
|
21
|
-
Scheduler: () => Scheduler
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(Scheduler_exports);
|
|
24
|
-
var import_consts = require("../consts.js");
|
|
25
|
-
var import_errors = require("../errors.js");
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LOGGER,
|
|
3
|
+
DEFAULT_PRIORITY,
|
|
4
|
+
DEFAULT_WAIT,
|
|
5
|
+
DEFAULT_WAIT_UNTIL
|
|
6
|
+
} from "../consts.js";
|
|
7
|
+
import {
|
|
8
|
+
AdapterNotConfiguredError,
|
|
9
|
+
QueueNotDefinedError,
|
|
10
|
+
SchedulingError
|
|
11
|
+
} from "../errors.js";
|
|
26
12
|
class Scheduler {
|
|
27
13
|
adapter;
|
|
28
14
|
logger;
|
|
29
15
|
constructor({ adapter, logger }) {
|
|
30
|
-
this.logger = logger ??
|
|
16
|
+
this.logger = logger ?? DEFAULT_LOGGER;
|
|
31
17
|
this.adapter = adapter;
|
|
32
18
|
if (!this.adapter) {
|
|
33
|
-
throw new
|
|
19
|
+
throw new AdapterNotConfiguredError();
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
22
|
computeRunAt({ wait, waitUntil }) {
|
|
@@ -48,12 +34,12 @@ class Scheduler {
|
|
|
48
34
|
options
|
|
49
35
|
}) {
|
|
50
36
|
const queue = job.queue;
|
|
51
|
-
const priority = job.priority ??
|
|
52
|
-
const wait = options?.wait ??
|
|
53
|
-
const waitUntil = options?.waitUntil ??
|
|
37
|
+
const priority = job.priority ?? DEFAULT_PRIORITY;
|
|
38
|
+
const wait = options?.wait ?? DEFAULT_WAIT;
|
|
39
|
+
const waitUntil = options?.waitUntil ?? DEFAULT_WAIT_UNTIL;
|
|
54
40
|
const cron = options?.cron;
|
|
55
41
|
if (!queue) {
|
|
56
|
-
throw new
|
|
42
|
+
throw new QueueNotDefinedError();
|
|
57
43
|
}
|
|
58
44
|
if (cron && (wait || waitUntil)) {
|
|
59
45
|
throw new Error(
|
|
@@ -85,14 +71,13 @@ class Scheduler {
|
|
|
85
71
|
await this.adapter.schedule(payload);
|
|
86
72
|
return true;
|
|
87
73
|
} catch (e) {
|
|
88
|
-
throw new
|
|
74
|
+
throw new SchedulingError(
|
|
89
75
|
`[CedarJS Jobs] Exception when scheduling ${payload.name}`,
|
|
90
76
|
e
|
|
91
77
|
);
|
|
92
78
|
}
|
|
93
79
|
}
|
|
94
80
|
}
|
|
95
|
-
|
|
96
|
-
0 && (module.exports = {
|
|
81
|
+
export {
|
|
97
82
|
Scheduler
|
|
98
|
-
}
|
|
83
|
+
};
|
package/dist/core/Worker.js
CHANGED
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Worker_exports = {};
|
|
20
|
-
__export(Worker_exports, {
|
|
21
|
-
Worker: () => Worker
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(Worker_exports);
|
|
24
|
-
var import_node_timers = require("node:timers");
|
|
25
|
-
var import_consts = require("../consts.js");
|
|
26
|
-
var import_errors = require("../errors.js");
|
|
27
|
-
var import_Executor = require("./Executor.js");
|
|
1
|
+
import { setTimeout } from "node:timers";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_DELETE_FAILED_JOBS,
|
|
4
|
+
DEFAULT_DELETE_SUCCESSFUL_JOBS,
|
|
5
|
+
DEFAULT_LOGGER,
|
|
6
|
+
DEFAULT_MAX_ATTEMPTS,
|
|
7
|
+
DEFAULT_MAX_RUNTIME,
|
|
8
|
+
DEFAULT_SLEEP_DELAY
|
|
9
|
+
} from "../consts.js";
|
|
10
|
+
import { AdapterRequiredError, QueuesRequiredError } from "../errors.js";
|
|
11
|
+
import { Executor } from "./Executor.js";
|
|
28
12
|
const DEFAULT_OPTIONS = {
|
|
29
|
-
logger:
|
|
13
|
+
logger: DEFAULT_LOGGER,
|
|
30
14
|
clear: false,
|
|
31
|
-
maxAttempts:
|
|
32
|
-
maxRuntime:
|
|
33
|
-
deleteSuccessfulJobs:
|
|
34
|
-
deleteFailedJobs:
|
|
35
|
-
sleepDelay:
|
|
15
|
+
maxAttempts: DEFAULT_MAX_ATTEMPTS,
|
|
16
|
+
maxRuntime: DEFAULT_MAX_RUNTIME,
|
|
17
|
+
deleteSuccessfulJobs: DEFAULT_DELETE_SUCCESSFUL_JOBS,
|
|
18
|
+
deleteFailedJobs: DEFAULT_DELETE_FAILED_JOBS,
|
|
19
|
+
sleepDelay: DEFAULT_SLEEP_DELAY,
|
|
36
20
|
workoff: false,
|
|
37
21
|
forever: true
|
|
38
22
|
};
|
|
@@ -63,10 +47,10 @@ class Worker {
|
|
|
63
47
|
queues: options?.queues
|
|
64
48
|
};
|
|
65
49
|
if (!options?.adapter) {
|
|
66
|
-
throw new
|
|
50
|
+
throw new AdapterRequiredError();
|
|
67
51
|
}
|
|
68
52
|
if (!options?.queues || options.queues.length === 0) {
|
|
69
|
-
throw new
|
|
53
|
+
throw new QueuesRequiredError();
|
|
70
54
|
}
|
|
71
55
|
this.adapter = this.options.adapter;
|
|
72
56
|
this.logger = this.options.logger;
|
|
@@ -114,7 +98,7 @@ class Worker {
|
|
|
114
98
|
queues: this.queues
|
|
115
99
|
});
|
|
116
100
|
if (job) {
|
|
117
|
-
await new
|
|
101
|
+
await new Executor({
|
|
118
102
|
adapter: this.adapter,
|
|
119
103
|
logger: this.logger,
|
|
120
104
|
job,
|
|
@@ -134,10 +118,9 @@ class Worker {
|
|
|
134
118
|
} while (this.forever);
|
|
135
119
|
}
|
|
136
120
|
#wait(ms) {
|
|
137
|
-
return new Promise((resolve) =>
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
138
122
|
}
|
|
139
123
|
}
|
|
140
|
-
|
|
141
|
-
0 && (module.exports = {
|
|
124
|
+
export {
|
|
142
125
|
Worker
|
|
143
|
-
}
|
|
126
|
+
};
|
package/dist/errors.js
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var errors_exports = {};
|
|
20
|
-
__export(errors_exports, {
|
|
21
|
-
AdapterNotConfiguredError: () => AdapterNotConfiguredError,
|
|
22
|
-
AdapterNotFoundError: () => AdapterNotFoundError,
|
|
23
|
-
AdapterRequiredError: () => AdapterRequiredError,
|
|
24
|
-
CedarJSJobsError: () => CedarJSJobsError,
|
|
25
|
-
JobExportNotFoundError: () => JobExportNotFoundError,
|
|
26
|
-
JobNotFoundError: () => JobNotFoundError,
|
|
27
|
-
JobRequiredError: () => JobRequiredError,
|
|
28
|
-
JobsLibNotFoundError: () => JobsLibNotFoundError,
|
|
29
|
-
LoggerNotFoundError: () => LoggerNotFoundError,
|
|
30
|
-
PerformError: () => PerformError,
|
|
31
|
-
QueueNotDefinedError: () => QueueNotDefinedError,
|
|
32
|
-
QueuesRequiredError: () => QueuesRequiredError,
|
|
33
|
-
RethrownJobError: () => RethrownJobError,
|
|
34
|
-
SchedulingError: () => SchedulingError,
|
|
35
|
-
WorkerConfigIndexNotFoundError: () => WorkerConfigIndexNotFoundError,
|
|
36
|
-
WorkerConfigNotFoundError: () => WorkerConfigNotFoundError
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(errors_exports);
|
|
39
1
|
const JOBS_CONFIG_FILENAME = "jobs.{ts,js}";
|
|
40
2
|
class CedarJSJobsError extends Error {
|
|
41
3
|
constructor(message) {
|
|
@@ -135,8 +97,7 @@ class WorkerConfigIndexNotFoundError extends CedarJSJobsError {
|
|
|
135
97
|
super(`Worker index ${index} not found in jobs config`);
|
|
136
98
|
}
|
|
137
99
|
}
|
|
138
|
-
|
|
139
|
-
0 && (module.exports = {
|
|
100
|
+
export {
|
|
140
101
|
AdapterNotConfiguredError,
|
|
141
102
|
AdapterNotFoundError,
|
|
142
103
|
AdapterRequiredError,
|
|
@@ -153,4 +114,4 @@ class WorkerConfigIndexNotFoundError extends CedarJSJobsError {
|
|
|
153
114
|
SchedulingError,
|
|
154
115
|
WorkerConfigIndexNotFoundError,
|
|
155
116
|
WorkerConfigNotFoundError
|
|
156
|
-
}
|
|
117
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var index_exports = {};
|
|
21
|
-
__export(index_exports, {
|
|
22
|
-
BaseAdapter: () => import_BaseAdapter.BaseAdapter,
|
|
23
|
-
Executor: () => import_Executor.Executor,
|
|
24
|
-
JobManager: () => import_JobManager.JobManager,
|
|
25
|
-
PrismaAdapter: () => import_PrismaAdapter.PrismaAdapter,
|
|
26
|
-
Worker: () => import_Worker.Worker
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
__reExport(index_exports, require("./errors.js"), module.exports);
|
|
30
|
-
var import_JobManager = require("./core/JobManager.js");
|
|
31
|
-
var import_Executor = require("./core/Executor.js");
|
|
32
|
-
var import_Worker = require("./core/Worker.js");
|
|
33
|
-
var import_BaseAdapter = require("./adapters/BaseAdapter/BaseAdapter.js");
|
|
34
|
-
var import_PrismaAdapter = require("./adapters/PrismaAdapter/PrismaAdapter.js");
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
1
|
+
export * from "./errors.js";
|
|
2
|
+
import { JobManager } from "./core/JobManager.js";
|
|
3
|
+
import { Executor } from "./core/Executor.js";
|
|
4
|
+
import { Worker } from "./core/Worker.js";
|
|
5
|
+
import { BaseAdapter } from "./adapters/BaseAdapter/BaseAdapter.js";
|
|
6
|
+
import { PrismaAdapter } from "./adapters/PrismaAdapter/PrismaAdapter.js";
|
|
7
|
+
export {
|
|
37
8
|
BaseAdapter,
|
|
38
9
|
Executor,
|
|
39
10
|
JobManager,
|
|
40
11
|
PrismaAdapter,
|
|
41
|
-
Worker
|
|
42
|
-
|
|
43
|
-
});
|
|
12
|
+
Worker
|
|
13
|
+
};
|
package/dist/loaders.js
CHANGED
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var loaders_exports = {};
|
|
30
|
-
__export(loaders_exports, {
|
|
31
|
-
loadJob: () => loadJob,
|
|
32
|
-
loadJobsManager: () => loadJobsManager
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(loaders_exports);
|
|
35
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
-
var import_node_path = __toESM(require("node:path"));
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_errors = require("./errors.js");
|
|
39
|
-
var import_util = require("./util.js");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
+
import { JobsLibNotFoundError, JobNotFoundError } from "./errors.js";
|
|
5
|
+
import { makeFilePath } from "./util.js";
|
|
40
6
|
const loadJobsManager = async () => {
|
|
41
|
-
const jobsConfigPath =
|
|
7
|
+
const jobsConfigPath = getPaths().api.distJobsConfig;
|
|
42
8
|
if (!jobsConfigPath) {
|
|
43
|
-
throw new
|
|
9
|
+
throw new JobsLibNotFoundError();
|
|
44
10
|
}
|
|
45
|
-
const importPath =
|
|
11
|
+
const importPath = makeFilePath(jobsConfigPath);
|
|
46
12
|
const { jobs } = await import(importPath);
|
|
47
13
|
if (!jobs) {
|
|
48
|
-
throw new
|
|
14
|
+
throw new JobsLibNotFoundError();
|
|
49
15
|
}
|
|
50
16
|
return jobs;
|
|
51
17
|
};
|
|
@@ -53,19 +19,18 @@ const loadJob = async ({
|
|
|
53
19
|
name: jobName,
|
|
54
20
|
path: jobPath
|
|
55
21
|
}) => {
|
|
56
|
-
const completeJobPath =
|
|
57
|
-
if (!
|
|
58
|
-
throw new
|
|
22
|
+
const completeJobPath = path.join(getPaths().api.distJobs, jobPath) + ".js";
|
|
23
|
+
if (!fs.existsSync(completeJobPath)) {
|
|
24
|
+
throw new JobNotFoundError(jobName);
|
|
59
25
|
}
|
|
60
|
-
const importPath =
|
|
26
|
+
const importPath = makeFilePath(completeJobPath);
|
|
61
27
|
const jobModule = await import(importPath);
|
|
62
28
|
if (!jobModule[jobName]) {
|
|
63
|
-
throw new
|
|
29
|
+
throw new JobNotFoundError(jobName);
|
|
64
30
|
}
|
|
65
31
|
return jobModule[jobName];
|
|
66
32
|
};
|
|
67
|
-
|
|
68
|
-
0 && (module.exports = {
|
|
33
|
+
export {
|
|
69
34
|
loadJob,
|
|
70
35
|
loadJobsManager
|
|
71
|
-
}
|
|
36
|
+
};
|
package/dist/setupEnv.js
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var setupEnv_exports = {};
|
|
20
|
-
__export(setupEnv_exports, {
|
|
21
|
-
setupEnv: () => setupEnv
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(setupEnv_exports);
|
|
24
|
-
var import_loadEnvFiles = require("@cedarjs/cli-helpers/loadEnvFiles");
|
|
1
|
+
import { loadEnvFiles } from "@cedarjs/cli-helpers/loadEnvFiles";
|
|
25
2
|
const setupEnv = () => {
|
|
26
|
-
|
|
3
|
+
loadEnvFiles();
|
|
27
4
|
if (process.env.NODE_ENV === void 0) {
|
|
28
5
|
process.env.NODE_ENV = "development";
|
|
29
6
|
}
|
|
30
7
|
};
|
|
31
|
-
|
|
32
|
-
0 && (module.exports = {
|
|
8
|
+
export {
|
|
33
9
|
setupEnv
|
|
34
|
-
}
|
|
10
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IntRange } from 'type-fest'
|
|
1
|
+
import type { IntRange } from 'type-fest' with { 'resolution-mode': 'import' };
|
|
2
2
|
import type { BaseAdapter } from './adapters/BaseAdapter/BaseAdapter.js';
|
|
3
3
|
/** CedarJS's logger and the standard console logger conform to this shape. */
|
|
4
4
|
export interface BasicLogger {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
package/dist/util.js
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var util_exports = {};
|
|
20
|
-
__export(util_exports, {
|
|
21
|
-
makeFilePath: () => makeFilePath
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(util_exports);
|
|
24
|
-
var import_node_url = require("node:url");
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
25
2
|
function makeFilePath(path) {
|
|
26
|
-
return
|
|
3
|
+
return pathToFileURL(path).href;
|
|
27
4
|
}
|
|
28
|
-
|
|
29
|
-
0 && (module.exports = {
|
|
5
|
+
export {
|
|
30
6
|
makeFilePath
|
|
31
|
-
}
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/jobs",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7-next.219",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
7
|
"directory": "packages/jobs"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"default": "./dist/index.js"
|
|
16
|
-
}
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
17
15
|
},
|
|
18
16
|
"./package.json": "./package.json"
|
|
19
17
|
},
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
"dist"
|
|
29
27
|
],
|
|
30
28
|
"scripts": {
|
|
31
|
-
"build": "node ./build.mts
|
|
29
|
+
"build": "node ./build.mts",
|
|
32
30
|
"build:pack": "yarn pack -o cedarjs-jobs.tgz",
|
|
33
31
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
34
32
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
@@ -39,18 +37,18 @@
|
|
|
39
37
|
"test:watch": "vitest"
|
|
40
38
|
},
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@cedarjs/cli-helpers": "5.0.
|
|
43
|
-
"@cedarjs/project-config": "5.0.
|
|
44
|
-
"cron-parser": "5.
|
|
40
|
+
"@cedarjs/cli-helpers": "5.0.7-next.219",
|
|
41
|
+
"@cedarjs/project-config": "5.0.7-next.219",
|
|
42
|
+
"cron-parser": "5.6.2",
|
|
45
43
|
"type-fest": "5.6.0"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@cedarjs/framework-tools": "5.0.
|
|
46
|
+
"@cedarjs/framework-tools": "5.0.7-next.219",
|
|
49
47
|
"@prisma/client": "7.8.0",
|
|
50
48
|
"concurrently": "9.2.4",
|
|
51
|
-
"publint": "0.3.
|
|
49
|
+
"publint": "0.3.22",
|
|
52
50
|
"typescript": "5.9.3",
|
|
53
|
-
"vitest": "
|
|
51
|
+
"vitest": "4.1.10"
|
|
54
52
|
},
|
|
55
53
|
"engines": {
|
|
56
54
|
"node": ">=24"
|