@cedarjs/jobs 7.1.0 → 7.1.1-next.468
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.d.ts +133 -0
- package/dist/adapters/BaseAdapter/BaseAdapter.d.ts.map +1 -1
- package/dist/adapters/BaseAdapter/BaseAdapter.js +6 -0
- package/dist/adapters/PrismaAdapter/PrismaAdapter.d.ts +67 -3
- package/dist/adapters/PrismaAdapter/PrismaAdapter.d.ts.map +1 -1
- package/dist/adapters/PrismaAdapter/PrismaAdapter.js +378 -59
- package/dist/adapters/PrismaAdapter/errors.d.ts +14 -0
- package/dist/adapters/PrismaAdapter/errors.d.ts.map +1 -1
- package/dist/adapters/PrismaAdapter/errors.js +17 -1
- package/dist/bins/cedar-jobs-worker.d.ts +11 -0
- package/dist/bins/cedar-jobs-worker.d.ts.map +1 -1
- package/dist/bins/cedar-jobs-worker.js +12 -1
- package/dist/bins/cedar-jobs.d.ts +25 -1
- package/dist/bins/cedar-jobs.d.ts.map +1 -1
- package/dist/bins/cedar-jobs.js +104 -3
- package/dist/consts.d.ts +9 -0
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +7 -1
- package/dist/core/Executor.d.ts.map +1 -1
- package/dist/core/Executor.js +11 -4
- package/dist/core/JobManager.d.ts +76 -0
- package/dist/core/JobManager.d.ts.map +1 -1
- package/dist/core/JobManager.js +210 -1
- package/dist/core/Scheduler.d.ts.map +1 -1
- package/dist/core/Scheduler.js +16 -3
- package/dist/core/Worker.d.ts +8 -0
- package/dist/core/Worker.d.ts.map +1 -1
- package/dist/core/Worker.js +46 -1
- package/dist/errors.d.ts +54 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +60 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/loaders.d.ts +29 -0
- package/dist/loaders.d.ts.map +1 -1
- package/dist/loaders.js +48 -1
- package/dist/types.d.ts +101 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/core/Worker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAA;AAUzE,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/core/Worker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAA;AAUzE,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AASnE,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IAGxD,OAAO,EAAE,WAAW,CAAA;IACpB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAA;IACnB,oEAAoE;IACpE,MAAM,EAAE,MAAM,EAAE,CAAA;IAIhB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,KAAK,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;AAc9C,qBAAa,MAAM;;IACjB,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;IAC/B,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IAC3C,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjC,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IAC3C,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,oBAAoB,EAAE,eAAe,CAAC,sBAAsB,CAAC,CAAA;IAC7D,gBAAgB,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAA;IACrD,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,aAAa,EAAE,IAAI,CAAA;gBAEP,OAAO,EAAE,aAAa;IA2ElC,GAAG;IAoBH;;;;;;OAMG;IACG,aAAa;IA4CnB,IAAI,UAAU,WAMb;CAyDF"}
|
package/dist/core/Worker.js
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "../consts.js";
|
|
10
10
|
import { AdapterRequiredError, QueuesRequiredError } from "../errors.js";
|
|
11
11
|
import { Executor } from "./Executor.js";
|
|
12
|
+
const PAUSED_JOBS_LIMIT = 1e3;
|
|
13
|
+
const PAUSED_JOBS_SHOWN = 10;
|
|
12
14
|
const DEFAULT_OPTIONS = {
|
|
13
15
|
logger: DEFAULT_LOGGER,
|
|
14
16
|
clear: false,
|
|
@@ -72,9 +74,52 @@ class Worker {
|
|
|
72
74
|
run() {
|
|
73
75
|
if (this.clear) {
|
|
74
76
|
return this.#clearQueue();
|
|
75
|
-
} else {
|
|
77
|
+
} else if (this.workoff) {
|
|
76
78
|
return this.#work();
|
|
79
|
+
} else {
|
|
80
|
+
const forever = this.forever;
|
|
81
|
+
return this.logPausedJobs().then(() => {
|
|
82
|
+
if (forever && !this.forever) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
return this.#work();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Logs a warning listing the paused jobs in this worker's queues, so a
|
|
91
|
+
* pause that was forgotten shows up whenever a long-running worker starts.
|
|
92
|
+
* Does nothing when the adapter can't list jobs or there are no paused
|
|
93
|
+
* ones, and never throws: a failed query is logged and the worker starts
|
|
94
|
+
* anyway
|
|
95
|
+
*/
|
|
96
|
+
async logPausedJobs() {
|
|
97
|
+
if (!this.adapter.list) {
|
|
98
|
+
return;
|
|
77
99
|
}
|
|
100
|
+
let paused;
|
|
101
|
+
try {
|
|
102
|
+
paused = await this.adapter.list({
|
|
103
|
+
limit: PAUSED_JOBS_LIMIT,
|
|
104
|
+
queues: this.queues,
|
|
105
|
+
paused: true
|
|
106
|
+
});
|
|
107
|
+
} catch (e) {
|
|
108
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
109
|
+
this.logger.warn(
|
|
110
|
+
`[${this.processName}] Could not check for paused jobs: ${message}`
|
|
111
|
+
);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (paused.length === 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const shown = paused.slice(0, PAUSED_JOBS_SHOWN).map((job) => `${job.id} (${job.name})`);
|
|
118
|
+
const more = paused.length - shown.length;
|
|
119
|
+
const count = paused.length === PAUSED_JOBS_LIMIT ? `${PAUSED_JOBS_LIMIT} or more` : String(paused.length);
|
|
120
|
+
this.logger.warn(
|
|
121
|
+
`[${this.processName}] ${count} paused job(s) in queue(s) ${this.queueNames} won't run until resumed: ${shown.join(", ")}` + (more > 0 ? ` and ${more} more` : "") + `. Resume one with \`yarn cedar jobs resume <id>\``
|
|
122
|
+
);
|
|
78
123
|
}
|
|
79
124
|
get queueNames() {
|
|
80
125
|
if (this.queues.length === 1 && this.queues[0] === "*") {
|
package/dist/errors.d.ts
CHANGED
|
@@ -115,4 +115,58 @@ export declare class QueueNotDefinedError extends CedarJSJobsError {
|
|
|
115
115
|
export declare class WorkerConfigIndexNotFoundError extends CedarJSJobsError {
|
|
116
116
|
constructor(index: number);
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Thrown when pausing, resuming or listing jobs through an adapter that
|
|
120
|
+
* doesn't implement `pause()`, `resume()` or `list()`
|
|
121
|
+
*/
|
|
122
|
+
export declare class PauseNotImplementedError extends CedarJSJobsError {
|
|
123
|
+
constructor(method: 'pause' | 'resume' | 'list');
|
|
124
|
+
}
|
|
125
|
+
/** Thrown when pausing or resuming a job id that no job has */
|
|
126
|
+
export declare class JobIdNotFoundError extends CedarJSJobsError {
|
|
127
|
+
constructor(jobId: string | number);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Thrown when pausing or resuming a job that has completed or failed for
|
|
131
|
+
* good (which includes cancelled jobs)
|
|
132
|
+
*/
|
|
133
|
+
export declare class JobNotActiveError extends CedarJSJobsError {
|
|
134
|
+
constructor(jobId: string | number, state: 'completed' | 'failed');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Thrown when it's unclear which adapter to use: the `JobManager` has
|
|
138
|
+
* several and none was named
|
|
139
|
+
*/
|
|
140
|
+
export declare class AdapterNameRequiredError extends CedarJSJobsError {
|
|
141
|
+
constructor(names: string[]);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Thrown when scheduling a job with a unique `key` through an adapter that
|
|
145
|
+
* doesn't support unique keys
|
|
146
|
+
*/
|
|
147
|
+
export declare class UniqueKeysNotSupportedError extends CedarJSJobsError {
|
|
148
|
+
constructor();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Thrown when a job is scheduled with a key that starts with the prefix
|
|
152
|
+
* Cedar reserves for its own keys
|
|
153
|
+
*/
|
|
154
|
+
export declare class ReservedKeyError extends CedarJSJobsError {
|
|
155
|
+
constructor(key: string, prefix: string);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Thrown when jobs declare `schedules` but the adapter that should store them
|
|
159
|
+
* doesn't implement `syncSchedules()`
|
|
160
|
+
*/
|
|
161
|
+
export declare class SchedulesNotSupportedError extends CedarJSJobsError {
|
|
162
|
+
constructor(adapterName: string);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Thrown when the jobs' declared `schedules` can't be synced as declared: a
|
|
166
|
+
* schedule is missing its key, two schedules share an identity, a cron
|
|
167
|
+
* expression doesn't parse, or it's unclear which adapter stores them
|
|
168
|
+
*/
|
|
169
|
+
export declare class ScheduleConfigError extends CedarJSJobsError {
|
|
170
|
+
constructor(message: string);
|
|
171
|
+
}
|
|
118
172
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,gBAAgB;;CAI9D;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;;CAIzD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;;CAIxD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;;CAIrD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACxC,IAAI,EAAE,MAAM;CAGzB;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB;gBAC9C,IAAI,EAAE,MAAM;CAGzB;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;;CASzD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;gBAC5C,IAAI,EAAE,MAAM;CAKzB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;gBAC3C,IAAI,EAAE,MAAM;CAKzB;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,gBAAgB;gBACjD,IAAI,EAAE,MAAM;CAGzB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,gBA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E,WAAW,GAAG,QAAQ;CAQlE;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,gBAAgB;gBAChD,KAAK,EAAE,MAAM,EAAE;CAK5B;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,gBAAgB;;CAQhE;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACxC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAMxC;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,gBAAgB;gBAClD,WAAW,EAAE,MAAM;CAQhC;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;gBAC3C,OAAO,EAAE,MAAM;CAG5B"}
|
package/dist/errors.js
CHANGED
|
@@ -109,23 +109,83 @@ class WorkerConfigIndexNotFoundError extends CedarJSJobsError {
|
|
|
109
109
|
super(`Worker index ${index} not found in jobs config`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
class PauseNotImplementedError extends CedarJSJobsError {
|
|
113
|
+
constructor(method) {
|
|
114
|
+
super(
|
|
115
|
+
`The configured adapter does not implement \`${method}()\`, so it does not support pausing, resuming or listing jobs`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class JobIdNotFoundError extends CedarJSJobsError {
|
|
120
|
+
constructor(jobId) {
|
|
121
|
+
super(`No job with the id ${jobId} was found`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class JobNotActiveError extends CedarJSJobsError {
|
|
125
|
+
constructor(jobId, state) {
|
|
126
|
+
super(
|
|
127
|
+
state === "failed" ? `Job ${jobId} has failed for good (or was cancelled), so it can't be paused or resumed` : `Job ${jobId} has completed, so it can't be paused or resumed`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class AdapterNameRequiredError extends CedarJSJobsError {
|
|
132
|
+
constructor(names) {
|
|
133
|
+
super(
|
|
134
|
+
`Name the adapter to use, the JobManager has several: ${names.join(", ")}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class UniqueKeysNotSupportedError extends CedarJSJobsError {
|
|
139
|
+
constructor() {
|
|
140
|
+
super(
|
|
141
|
+
"The configured adapter does not support unique job keys, so the job was not scheduled. Schedule it without `key`, or use an adapter that supports keys, like the PrismaAdapter"
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class ReservedKeyError extends CedarJSJobsError {
|
|
146
|
+
constructor(key, prefix) {
|
|
147
|
+
super(
|
|
148
|
+
`The job key \`${key}\` starts with \`${prefix}\`, which is reserved for keys Cedar creates itself, like the keys of declared schedules`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
class SchedulesNotSupportedError extends CedarJSJobsError {
|
|
153
|
+
constructor(adapterName) {
|
|
154
|
+
super(
|
|
155
|
+
`Jobs declare \`schedules\`, but the \`${adapterName}\` adapter does not support syncing declared schedules. Use an adapter that does, like the PrismaAdapter, and point \`scheduleAdapter\` in your JobManager config at it`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
class ScheduleConfigError extends CedarJSJobsError {
|
|
160
|
+
constructor(message) {
|
|
161
|
+
super(`[CedarJS Jobs] ${message}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
112
164
|
export {
|
|
165
|
+
AdapterNameRequiredError,
|
|
113
166
|
AdapterNotConfiguredError,
|
|
114
167
|
AdapterNotFoundError,
|
|
115
168
|
AdapterRequiredError,
|
|
116
169
|
CancelNotImplementedError,
|
|
117
170
|
CedarJSJobsError,
|
|
118
171
|
JobExportNotFoundError,
|
|
172
|
+
JobIdNotFoundError,
|
|
173
|
+
JobNotActiveError,
|
|
119
174
|
JobNotFoundError,
|
|
120
175
|
JobRequiredError,
|
|
121
176
|
JobTimeoutError,
|
|
122
177
|
JobsLibNotFoundError,
|
|
123
178
|
LoggerNotFoundError,
|
|
179
|
+
PauseNotImplementedError,
|
|
124
180
|
PerformError,
|
|
125
181
|
QueueNotDefinedError,
|
|
126
182
|
QueuesRequiredError,
|
|
183
|
+
ReservedKeyError,
|
|
127
184
|
RethrownJobError,
|
|
185
|
+
ScheduleConfigError,
|
|
186
|
+
SchedulesNotSupportedError,
|
|
128
187
|
SchedulingError,
|
|
188
|
+
UniqueKeysNotSupportedError,
|
|
129
189
|
WorkerConfigIndexNotFoundError,
|
|
130
190
|
WorkerConfigNotFoundError
|
|
131
191
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
export * from './errors.js';
|
|
2
2
|
export { JobManager } from './core/JobManager.js';
|
|
3
|
+
export type { JobAdapterOptions } from './core/JobManager.js';
|
|
3
4
|
export { Executor } from './core/Executor.js';
|
|
4
5
|
export { Worker } from './core/Worker.js';
|
|
5
6
|
export { getJobExecutionContext } from './core/executionContext.js';
|
|
6
7
|
export type { JobExecutionContext } from './core/executionContext.js';
|
|
7
8
|
export { BaseAdapter } from './adapters/BaseAdapter/BaseAdapter.js';
|
|
8
9
|
export { PrismaAdapter } from './adapters/PrismaAdapter/PrismaAdapter.js';
|
|
9
|
-
export {
|
|
10
|
+
export type { PrismaJob, ScheduledPrismaJob, } from './adapters/PrismaAdapter/PrismaAdapter.js';
|
|
11
|
+
export { KeyColumnMissingError, PausedAtColumnMissingError, } from './adapters/PrismaAdapter/errors.js';
|
|
12
|
+
export type { ListedJob, ListJobsOptions, PauseOptions, PauseResult, ResumeOptions, ResumeResult, ScheduleDefinition, SyncSchedulesOptions, SyncSchedulesResult, } from './adapters/BaseAdapter/BaseAdapter.js';
|
|
13
|
+
export { isJobModuleFile, jobsFromModules, loadAllJobs, loadJobsManager, setJobLoaderOverrides, } from './loaders.js';
|
|
10
14
|
export type { JobLoaderOverrides } from './loaders.js';
|
|
11
15
|
export type * from './types.js';
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AACzE,YAAY,EACV,SAAS,EACT,kBAAkB,GACnB,MAAM,2CAA2C,CAAA;AAClD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,oCAAoC,CAAA;AAC3C,YAAY,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACL,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,qBAAqB,GACtB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,mBAAmB,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,29 @@ import { Worker } from "./core/Worker.js";
|
|
|
5
5
|
import { getJobExecutionContext } from "./core/executionContext.js";
|
|
6
6
|
import { BaseAdapter } from "./adapters/BaseAdapter/BaseAdapter.js";
|
|
7
7
|
import { PrismaAdapter } from "./adapters/PrismaAdapter/PrismaAdapter.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
KeyColumnMissingError,
|
|
10
|
+
PausedAtColumnMissingError
|
|
11
|
+
} from "./adapters/PrismaAdapter/errors.js";
|
|
12
|
+
import {
|
|
13
|
+
isJobModuleFile,
|
|
14
|
+
jobsFromModules,
|
|
15
|
+
loadAllJobs,
|
|
16
|
+
loadJobsManager,
|
|
17
|
+
setJobLoaderOverrides
|
|
18
|
+
} from "./loaders.js";
|
|
9
19
|
export {
|
|
10
20
|
BaseAdapter,
|
|
11
21
|
Executor,
|
|
12
22
|
JobManager,
|
|
23
|
+
KeyColumnMissingError,
|
|
24
|
+
PausedAtColumnMissingError,
|
|
13
25
|
PrismaAdapter,
|
|
14
26
|
Worker,
|
|
15
27
|
getJobExecutionContext,
|
|
28
|
+
isJobModuleFile,
|
|
29
|
+
jobsFromModules,
|
|
30
|
+
loadAllJobs,
|
|
16
31
|
loadJobsManager,
|
|
17
32
|
setJobLoaderOverrides
|
|
18
33
|
};
|
package/dist/loaders.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ import type { Adapters, BasicLogger, Job, JobComputedProperties, QueueNames } fr
|
|
|
3
3
|
export interface JobLoaderOverrides {
|
|
4
4
|
loadJobsManager: () => Promise<JobManager<Adapters, QueueNames, BasicLogger>>;
|
|
5
5
|
loadJob: (computedProperties: JobComputedProperties) => Promise<Job<QueueNames, unknown[]>>;
|
|
6
|
+
/**
|
|
7
|
+
* Imports every job module and returns the jobs they export. Used to find
|
|
8
|
+
* the jobs' declared `schedules`. Without it, `loadAllJobs()` throws while
|
|
9
|
+
* the overrides are set, as an empty list would make the schedule sync
|
|
10
|
+
* remove every stored schedule
|
|
11
|
+
*/
|
|
12
|
+
loadAllJobs?: () => Promise<Job<QueueNames, unknown[]>[]>;
|
|
6
13
|
}
|
|
7
14
|
export declare const setJobLoaderOverrides: (newOverrides: JobLoaderOverrides | undefined) => void;
|
|
8
15
|
/**
|
|
@@ -15,4 +22,26 @@ export declare const loadJobsManager: () => Promise<JobManager<Adapters, QueueNa
|
|
|
15
22
|
* Load a specific job implementation from the users project
|
|
16
23
|
*/
|
|
17
24
|
export declare const loadJob: (computedProperties: JobComputedProperties) => Promise<Job<QueueNames, unknown[]>>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether `value` is a job created with `createJob()` and given its `name`
|
|
27
|
+
* and `path` by the build
|
|
28
|
+
*/
|
|
29
|
+
export declare const isJob: (value: unknown) => value is Job<QueueNames, unknown[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Collects the jobs a set of imported modules export, each job once (a job
|
|
32
|
+
* re-exported from several modules is the same object)
|
|
33
|
+
*/
|
|
34
|
+
export declare const jobsFromModules: (modules: Record<string, unknown>[]) => Job<QueueNames, unknown[]>[];
|
|
35
|
+
/**
|
|
36
|
+
* Whether a file in the jobs directory is a module that can hold jobs: a
|
|
37
|
+
* script file that isn't a test, scenario, mock or type declaration
|
|
38
|
+
*/
|
|
39
|
+
export declare const isJobModuleFile: (file: string) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Imports every job module from the user's project and returns the jobs
|
|
42
|
+
* they export. A module that fails to import makes this throw, rather than
|
|
43
|
+
* leave that module's jobs out: the schedule sync removes stored schedules
|
|
44
|
+
* that aren't declared, so a job left out would silently lose its schedules
|
|
45
|
+
*/
|
|
46
|
+
export declare const loadAllJobs: () => Promise<Job<QueueNames, unknown[]>[]>;
|
|
18
47
|
//# sourceMappingURL=loaders.d.ts.map
|
package/dist/loaders.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../src/loaders.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../src/loaders.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAMtD,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,GAAG,EACH,qBAAqB,EACrB,UAAU,EACX,MAAM,YAAY,CAAA;AAGnB,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;IAC7E,OAAO,EAAE,CACP,kBAAkB,EAAE,qBAAqB,KACtC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACxC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;CAC1D;AASD,eAAO,MAAM,qBAAqB,GAChC,cAAc,kBAAkB,GAAG,SAAS,SAG7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAa,OAAO,CAC9C,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAoB9C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,oBAAoB,qBAAqB,KACxC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAsBpC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAaxE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,iCAYjE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,YAIG,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,CA8BxE,CAAA"}
|
package/dist/loaders.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CedarJSJobsError,
|
|
6
|
+
JobsLibNotFoundError,
|
|
7
|
+
JobNotFoundError
|
|
8
|
+
} from "./errors.js";
|
|
5
9
|
import { makeFilePath } from "./util.js";
|
|
6
10
|
let overrides;
|
|
7
11
|
const setJobLoaderOverrides = (newOverrides) => {
|
|
@@ -38,7 +42,50 @@ const loadJob = async (computedProperties) => {
|
|
|
38
42
|
}
|
|
39
43
|
return jobModule[jobName];
|
|
40
44
|
};
|
|
45
|
+
const isJob = (value) => {
|
|
46
|
+
if (typeof value !== "object" || value === null) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const candidate = value;
|
|
50
|
+
return typeof candidate.perform === "function" && typeof candidate.queue === "string" && typeof candidate.name === "string" && typeof candidate.path === "string";
|
|
51
|
+
};
|
|
52
|
+
const jobsFromModules = (modules) => {
|
|
53
|
+
const jobs = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const mod of modules) {
|
|
55
|
+
for (const value of Object.values(mod)) {
|
|
56
|
+
if (isJob(value)) {
|
|
57
|
+
jobs.add(value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...jobs];
|
|
62
|
+
};
|
|
63
|
+
const isJobModuleFile = (file) => /\.(c|m)?(j|t)sx?$/.test(file) && !/\.d\.(c|m)?ts$/.test(file) && !/\.(test|spec|scenarios|mock)\.[^.]+$/.test(file) && !/(^|[\\/])__(tests|mocks)__[\\/]/.test(file);
|
|
64
|
+
const loadAllJobs = async () => {
|
|
65
|
+
if (overrides) {
|
|
66
|
+
if (!overrides.loadAllJobs) {
|
|
67
|
+
throw new CedarJSJobsError(
|
|
68
|
+
"The job loader overrides do not implement `loadAllJobs()`, so the jobs' declared schedules can't be found"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return overrides.loadAllJobs();
|
|
72
|
+
}
|
|
73
|
+
const jobsDir = getPaths().api.distJobs;
|
|
74
|
+
if (!fs.existsSync(jobsDir)) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const files = fs.readdirSync(jobsDir, { recursive: true, encoding: "utf-8" }).filter((file) => file.endsWith(".js") && isJobModuleFile(file)).sort();
|
|
78
|
+
const modules = [];
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
modules.push(await import(makeFilePath(path.join(jobsDir, file))));
|
|
81
|
+
}
|
|
82
|
+
return jobsFromModules(modules);
|
|
83
|
+
};
|
|
41
84
|
export {
|
|
85
|
+
isJob,
|
|
86
|
+
isJobModuleFile,
|
|
87
|
+
jobsFromModules,
|
|
88
|
+
loadAllJobs,
|
|
42
89
|
loadJob,
|
|
43
90
|
loadJobsManager,
|
|
44
91
|
setJobLoaderOverrides
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface BaseJob {
|
|
|
17
17
|
args: unknown[];
|
|
18
18
|
attempts: number;
|
|
19
19
|
cron?: string | undefined | null;
|
|
20
|
+
/**
|
|
21
|
+
* The job's unique key, for adapters that support keys. Declared schedules
|
|
22
|
+
* have a key starting with `cedar:schedule:`
|
|
23
|
+
*/
|
|
24
|
+
key?: string | undefined | null;
|
|
20
25
|
}
|
|
21
26
|
export type PossibleBaseJob = BaseJob | undefined;
|
|
22
27
|
export type Adapters = Record<string, BaseAdapter>;
|
|
@@ -115,6 +120,12 @@ export interface JobManagerConfig<TAdapters extends Adapters, TQueues extends Qu
|
|
|
115
120
|
* An array of worker configurations that define how jobs should be processed.
|
|
116
121
|
*/
|
|
117
122
|
workers: WorkerConfig<TAdapters, TQueues>[];
|
|
123
|
+
/**
|
|
124
|
+
* The name of the adapter that stores the recurring schedules jobs declare
|
|
125
|
+
* with `schedules` in `createJob()`. Can be left out when there is only one
|
|
126
|
+
* adapter.
|
|
127
|
+
*/
|
|
128
|
+
scheduleAdapter?: keyof TAdapters;
|
|
118
129
|
}
|
|
119
130
|
export interface CreateSchedulerConfig<TAdapters extends Adapters, TAdapterName extends keyof TAdapters = keyof TAdapters> {
|
|
120
131
|
/**
|
|
@@ -141,6 +152,35 @@ export interface JobDefinition<TQueues extends QueueNames, TArgs extends unknown
|
|
|
141
152
|
* @default 50
|
|
142
153
|
*/
|
|
143
154
|
priority?: PriorityValue;
|
|
155
|
+
/**
|
|
156
|
+
* The recurring schedules this job runs on, declared in code. Every job
|
|
157
|
+
* worker syncs the declared schedules to the adapter when it starts: missing
|
|
158
|
+
* schedules are added, changed ones are updated and schedules that are no
|
|
159
|
+
* longer declared are removed. There's no script to run after changing a
|
|
160
|
+
* schedule, restarting the workers (which every deploy does) is enough.
|
|
161
|
+
*
|
|
162
|
+
* Each schedule has a `key` that identifies it, so one job can run on
|
|
163
|
+
* several schedules with different arguments. The key can be left out when
|
|
164
|
+
* the job has a single schedule.
|
|
165
|
+
*
|
|
166
|
+
* Declared schedules need an adapter that implements `syncSchedules()`,
|
|
167
|
+
* like the `PrismaAdapter`.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* export const ReportJob = jobs.createJob({
|
|
172
|
+
* queue: 'default',
|
|
173
|
+
* schedules: [
|
|
174
|
+
* { key: 'hourly', cron: '0 * * * *', args: ['summary'] },
|
|
175
|
+
* { key: 'nightly', cron: '0 3 * * *', args: ['full'] },
|
|
176
|
+
* ],
|
|
177
|
+
* perform: async (kind: 'summary' | 'full') => {
|
|
178
|
+
* // ...
|
|
179
|
+
* },
|
|
180
|
+
* })
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
schedules?: readonly JobSchedule<NoInfer<TArgs>>[];
|
|
144
184
|
/**
|
|
145
185
|
* The function to run when this job is executed.
|
|
146
186
|
*
|
|
@@ -148,6 +188,34 @@ export interface JobDefinition<TQueues extends QueueNames, TArgs extends unknown
|
|
|
148
188
|
*/
|
|
149
189
|
perform: (...args: TArgs) => Promise<void> | void;
|
|
150
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* One recurring schedule of a job, declared in the job's `schedules` array.
|
|
193
|
+
*/
|
|
194
|
+
export type JobSchedule<TArgs extends unknown[] = unknown[]> = {
|
|
195
|
+
/**
|
|
196
|
+
* Identifies this schedule among the job's schedules. The job's name and
|
|
197
|
+
* this key together are the schedule's identity in the adapter: changing
|
|
198
|
+
* the `cron` or `args` of a schedule updates it, changing its `key`
|
|
199
|
+
* replaces it with a new one.
|
|
200
|
+
*
|
|
201
|
+
* Required when the job has more than one schedule.
|
|
202
|
+
*
|
|
203
|
+
* @default 'default'
|
|
204
|
+
*/
|
|
205
|
+
key?: string;
|
|
206
|
+
/**
|
|
207
|
+
* When the job runs, in the format described in the [cron-parser
|
|
208
|
+
* documentation](https://github.com/harrisiirak/cron-parser#cron-format).
|
|
209
|
+
* Evaluated in the time zone of the job worker.
|
|
210
|
+
*/
|
|
211
|
+
cron: string;
|
|
212
|
+
} & ([] extends TArgs ? {
|
|
213
|
+
/** The arguments `perform()` gets on every run of this schedule */
|
|
214
|
+
args?: TArgs;
|
|
215
|
+
} : {
|
|
216
|
+
/** The arguments `perform()` gets on every run of this schedule */
|
|
217
|
+
args: TArgs;
|
|
218
|
+
});
|
|
151
219
|
export type JobComputedProperties = {
|
|
152
220
|
/**
|
|
153
221
|
* The name of the job that was defined in the job file.
|
|
@@ -159,7 +227,13 @@ export type JobComputedProperties = {
|
|
|
159
227
|
path: string;
|
|
160
228
|
};
|
|
161
229
|
export type Job<TQueues extends QueueNames, TArgs extends unknown[] = []> = JobDefinition<TQueues, TArgs> & JobComputedProperties;
|
|
162
|
-
|
|
230
|
+
/** When a scheduled job runs */
|
|
231
|
+
export type ScheduleJobTiming = {
|
|
232
|
+
/** Without `wait`, `waitUntil` or `cron` the job runs right away */
|
|
233
|
+
wait?: never;
|
|
234
|
+
waitUntil?: never;
|
|
235
|
+
cron?: never;
|
|
236
|
+
} | {
|
|
163
237
|
/**
|
|
164
238
|
* The number of seconds to wait before scheduling this job. This is
|
|
165
239
|
* mutually exclusive with `waitUntil` and `cron`.
|
|
@@ -188,6 +262,31 @@ export type ScheduleJobOptions = {
|
|
|
188
262
|
*/
|
|
189
263
|
cron: string;
|
|
190
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* Options for scheduling a job with `later()`: when it runs (`wait`,
|
|
267
|
+
* `waitUntil` or `cron`) and, optionally, a unique `key`.
|
|
268
|
+
*/
|
|
269
|
+
export type ScheduleJobOptions = ScheduleJobTiming & {
|
|
270
|
+
/**
|
|
271
|
+
* Makes the job unique while it's queued: if a job scheduled with the same
|
|
272
|
+
* key is still waiting to run, no new job is added and the adapter returns
|
|
273
|
+
* the queued one instead (the `PrismaAdapter` returns it with
|
|
274
|
+
* `alreadyQueued: true`).
|
|
275
|
+
*
|
|
276
|
+
* A job holds its key until a worker picks it up. From then on a new job
|
|
277
|
+
* with the same key can be queued, so work requested while the job runs
|
|
278
|
+
* isn't lost. A recurring (`cron`) job holds its key for as long as its
|
|
279
|
+
* schedule is active.
|
|
280
|
+
*
|
|
281
|
+
* The key alone decides uniqueness: the arguments of the queued job are not
|
|
282
|
+
* compared, so put whatever must be distinct into the key, like
|
|
283
|
+
* `` `thumbnails:${caseId}` ``. Keys starting with `cedar:` are reserved.
|
|
284
|
+
*
|
|
285
|
+
* Needs an adapter that supports unique keys, like the `PrismaAdapter`
|
|
286
|
+
* (which needs a `key String? @unique` column on its model).
|
|
287
|
+
*/
|
|
288
|
+
key?: string;
|
|
289
|
+
};
|
|
191
290
|
/**
|
|
192
291
|
* A union of the integers from 0 up to, but not including, `TEnd`. `TEnd` must
|
|
193
292
|
* be a non-negative integer literal.
|
|
@@ -203,6 +302,6 @@ type PriorityValue = Exclude<NumbersBelow<101>, 0>;
|
|
|
203
302
|
* If the job has arguments:
|
|
204
303
|
* - you must pass the arguments and then optionally pass the scheduler options
|
|
205
304
|
*/
|
|
206
|
-
export type CreateSchedulerArgs<TJob extends Job<QueueNames>> = Parameters<TJob['perform']> extends [] ? [ScheduleJobOptions?] | [[], ScheduleJobOptions?] : [Parameters<TJob['perform']>, ScheduleJobOptions?];
|
|
305
|
+
export type CreateSchedulerArgs<TJob extends Job<QueueNames, any[]>> = Parameters<TJob['perform']> extends [] ? [ScheduleJobOptions?] | [[], ScheduleJobOptions?] : [Parameters<TJob['perform']>, ScheduleJobOptions?];
|
|
207
306
|
export {};
|
|
208
307
|
//# sourceMappingURL=types.d.ts.map
|
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,WAAW,EAAE,MAAM,uCAAuC,CAAA;AAExE,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IACxD,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IACvD,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,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Y,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,CAAC,IAAI,SAAS,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IACjE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,GAClC,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC,GACjD,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/jobs",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1-next.468",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -33,21 +33,27 @@
|
|
|
33
33
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
34
34
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
35
35
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
36
|
+
"setup:test": "npx prisma generate --config ./src/__tests__/prisma.config.ts && npx prisma migrate diff --config ./src/__tests__/prisma.config.ts --from-empty --to-schema ./src/__tests__/unit-test-schema.prisma --script -o ./src/__tests__/unit-test-schema.sql",
|
|
36
37
|
"test": "vitest run",
|
|
37
38
|
"test:watch": "vitest"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@cedarjs/cli-helpers": "7.1.
|
|
41
|
-
"@cedarjs/project-config": "7.1.
|
|
42
|
-
"cron-parser": "5.10.
|
|
41
|
+
"@cedarjs/cli-helpers": "7.1.1-next.468",
|
|
42
|
+
"@cedarjs/project-config": "7.1.1-next.468",
|
|
43
|
+
"cron-parser": "5.10.2"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@cedarjs/framework-tools": "7.1.
|
|
46
|
-
"@prisma/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
46
|
+
"@cedarjs/framework-tools": "7.1.1-next.468",
|
|
47
|
+
"@prisma/adapter-better-sqlite3": "7.10.0",
|
|
48
|
+
"@prisma/client": "7.10.0",
|
|
49
|
+
"@types/better-sqlite3": "7.6.13",
|
|
50
|
+
"better-sqlite3": "12.11.1",
|
|
51
|
+
"concurrently": "9.2.5",
|
|
52
|
+
"prisma": "7.10.0",
|
|
53
|
+
"publint": "0.3.25",
|
|
49
54
|
"typescript": "5.9.3",
|
|
50
|
-
"vitest": "4.1.11"
|
|
55
|
+
"vitest": "4.1.11",
|
|
56
|
+
"zx": "8.8.5"
|
|
51
57
|
},
|
|
52
58
|
"engines": {
|
|
53
59
|
"node": ">=24"
|