@webiny/api-scheduler-standalone 0.0.0-unstable.33e4fd9647
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/BreeSchedulerService.d.ts +54 -0
- package/BreeSchedulerService.js +138 -0
- package/BreeSchedulerService.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/jobs/pollWorker.d.ts +1 -0
- package/jobs/pollWorker.js +4 -0
- package/jobs/pollWorker.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ISchedulerServiceCreateParams, type ISchedulerServiceUpdateParams, SchedulerService } from "@webiny/api-scheduler/shared/abstractions.js";
|
|
2
|
+
import type { Logger } from "@webiny/api-core/features/logger/abstractions.js";
|
|
3
|
+
export interface IPendingAction {
|
|
4
|
+
id: string;
|
|
5
|
+
namespace: string;
|
|
6
|
+
tenant: string;
|
|
7
|
+
scheduledFor: Date;
|
|
8
|
+
}
|
|
9
|
+
export interface IBreeSchedulerServiceParams {
|
|
10
|
+
logger: Logger.Interface;
|
|
11
|
+
runAction: (id: string, namespace: string, tenant: string) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One-shot bree job per scheduled action — mirrors EventBridge behaviour. This is a long-lived root
|
|
15
|
+
* SINGLETON (started once at boot): it holds this process's live timers for ALL tenants, so each job
|
|
16
|
+
* records its own tenant and `runAction` is called with it (the action runs outside any request, so
|
|
17
|
+
* the tenant can't be read from a request context).
|
|
18
|
+
*
|
|
19
|
+
* With several processes, each holds its own timers for the same actions: `recover` runs again on a
|
|
20
|
+
* timer to arm what this process has not seen, and whoever supplies `runAction` makes sure an action
|
|
21
|
+
* runs once.
|
|
22
|
+
*/
|
|
23
|
+
export declare class BreeSchedulerService implements SchedulerService.Interface {
|
|
24
|
+
private readonly bree;
|
|
25
|
+
private readonly jobs;
|
|
26
|
+
private readonly logger;
|
|
27
|
+
private readonly runAction;
|
|
28
|
+
private readonly running;
|
|
29
|
+
private stopped;
|
|
30
|
+
constructor(params: IBreeSchedulerServiceParams);
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves once every trigger already started has finished, or after `timeoutMs`. Call it after
|
|
35
|
+
* `stop`, which keeps new ones from starting.
|
|
36
|
+
*/
|
|
37
|
+
waitForRunning(timeoutMs: number): Promise<void>;
|
|
38
|
+
create(params: ISchedulerServiceCreateParams): Promise<void>;
|
|
39
|
+
update(params: ISchedulerServiceUpdateParams): Promise<void>;
|
|
40
|
+
delete(params: SchedulerService.DeleteParams): Promise<void>;
|
|
41
|
+
exists(params: SchedulerService.ExistsParams): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* (Re)arm timers for a batch of persisted pending actions. Runs at boot (per tenant) to restore
|
|
44
|
+
* schedules after a restart, and then on a timer, so this process also arms actions another
|
|
45
|
+
* process scheduled or moved. Overdue actions fire immediately.
|
|
46
|
+
*
|
|
47
|
+
* An action already armed for the same time is left as it is; one armed for a different time was
|
|
48
|
+
* moved by another process and is re-armed.
|
|
49
|
+
*/
|
|
50
|
+
recover(pendingActions: IPendingAction[]): Promise<void>;
|
|
51
|
+
private arm;
|
|
52
|
+
private trigger;
|
|
53
|
+
private safeRemove;
|
|
54
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import bree from "bree";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { WebinyError } from "@webiny/error";
|
|
4
|
+
const workerPath = fileURLToPath(new URL("./jobs/pollWorker.js", import.meta.url));
|
|
5
|
+
class BreeSchedulerService {
|
|
6
|
+
constructor(params){
|
|
7
|
+
this.jobs = new Map();
|
|
8
|
+
this.running = new Set();
|
|
9
|
+
this.stopped = false;
|
|
10
|
+
this.logger = params.logger;
|
|
11
|
+
this.runAction = params.runAction;
|
|
12
|
+
this.bree = new bree({
|
|
13
|
+
root: false,
|
|
14
|
+
jobs: [],
|
|
15
|
+
logger: false,
|
|
16
|
+
workerMessageHandler: async ({ name })=>{
|
|
17
|
+
const job = this.jobs.get(name);
|
|
18
|
+
if (!job) return;
|
|
19
|
+
this.jobs.delete(name);
|
|
20
|
+
await this.trigger(name, job.namespace, job.tenant);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async start() {
|
|
25
|
+
this.stopped = false;
|
|
26
|
+
await this.bree.start();
|
|
27
|
+
}
|
|
28
|
+
async stop() {
|
|
29
|
+
this.stopped = true;
|
|
30
|
+
await this.bree.stop();
|
|
31
|
+
}
|
|
32
|
+
async waitForRunning(timeoutMs) {
|
|
33
|
+
let timer;
|
|
34
|
+
const timeout = new Promise((resolve)=>{
|
|
35
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
36
|
+
});
|
|
37
|
+
const running = Promise.allSettled([
|
|
38
|
+
...this.running
|
|
39
|
+
]);
|
|
40
|
+
await Promise.race([
|
|
41
|
+
running,
|
|
42
|
+
timeout
|
|
43
|
+
]);
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
}
|
|
46
|
+
async create(params) {
|
|
47
|
+
const { id, namespace, scheduleFor, tenant } = params;
|
|
48
|
+
if (scheduleFor <= new Date()) throw new WebinyError(`Cannot create a schedule for "${id}" with date in the past`, "INVALID_SCHEDULE_DATE", {
|
|
49
|
+
scheduleFor,
|
|
50
|
+
id
|
|
51
|
+
});
|
|
52
|
+
const exists = await this.exists({
|
|
53
|
+
id,
|
|
54
|
+
namespace,
|
|
55
|
+
tenant
|
|
56
|
+
});
|
|
57
|
+
if (exists) return this.update(params);
|
|
58
|
+
await this.arm(id, {
|
|
59
|
+
namespace,
|
|
60
|
+
tenant,
|
|
61
|
+
scheduledFor: scheduleFor
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async update(params) {
|
|
65
|
+
const { id, scheduleFor } = params;
|
|
66
|
+
if (scheduleFor <= new Date()) throw new WebinyError(`Cannot update an existing schedule for "${id}" with date in the past`, "INVALID_SCHEDULE_DATE", {
|
|
67
|
+
scheduleFor,
|
|
68
|
+
id
|
|
69
|
+
});
|
|
70
|
+
await this.safeRemove(id);
|
|
71
|
+
await this.create(params);
|
|
72
|
+
}
|
|
73
|
+
async delete(params) {
|
|
74
|
+
const { id } = params;
|
|
75
|
+
const exists = await this.exists(params);
|
|
76
|
+
if (!exists) throw new WebinyError(`Cannot delete schedule "${id}" because it does not exist.`);
|
|
77
|
+
await this.safeRemove(id);
|
|
78
|
+
}
|
|
79
|
+
async exists(params) {
|
|
80
|
+
const { id } = params;
|
|
81
|
+
return this.jobs.has(id);
|
|
82
|
+
}
|
|
83
|
+
async recover(pendingActions) {
|
|
84
|
+
const now = new Date();
|
|
85
|
+
for (const action of pendingActions){
|
|
86
|
+
if (this.stopped) return;
|
|
87
|
+
if (action.scheduledFor <= now) {
|
|
88
|
+
await this.trigger(action.id, action.namespace, action.tenant);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const armed = this.jobs.get(action.id);
|
|
92
|
+
if (!armed || armed.scheduledFor.getTime() !== action.scheduledFor.getTime()) {
|
|
93
|
+
if (armed) await this.safeRemove(action.id);
|
|
94
|
+
await this.arm(action.id, {
|
|
95
|
+
namespace: action.namespace,
|
|
96
|
+
tenant: action.tenant,
|
|
97
|
+
scheduledFor: action.scheduledFor
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async arm(id, job) {
|
|
103
|
+
if (this.stopped) return;
|
|
104
|
+
this.jobs.set(id, job);
|
|
105
|
+
await this.bree.add({
|
|
106
|
+
name: id,
|
|
107
|
+
date: job.scheduledFor,
|
|
108
|
+
path: workerPath
|
|
109
|
+
});
|
|
110
|
+
await this.bree.start(id);
|
|
111
|
+
}
|
|
112
|
+
async trigger(id, namespace, tenant) {
|
|
113
|
+
if (this.stopped) return;
|
|
114
|
+
const triggered = this.runAction(id, namespace, tenant);
|
|
115
|
+
this.running.add(triggered);
|
|
116
|
+
try {
|
|
117
|
+
await triggered;
|
|
118
|
+
} finally{
|
|
119
|
+
this.running.delete(triggered);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async safeRemove(id) {
|
|
123
|
+
this.jobs.delete(id);
|
|
124
|
+
try {
|
|
125
|
+
await this.bree.stop(id);
|
|
126
|
+
} catch {
|
|
127
|
+
this.logger.debug(`Could not stop bree job "${id}" — it may have already fired.`);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
await this.bree.remove(id);
|
|
131
|
+
} catch {
|
|
132
|
+
this.logger.debug(`Could not remove bree job "${id}" — it may have already been removed.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export { BreeSchedulerService };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=BreeSchedulerService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BreeSchedulerService.js","sources":["../src/BreeSchedulerService.ts"],"sourcesContent":["import Bree from \"bree\";\nimport { fileURLToPath } from \"node:url\";\nimport { WebinyError } from \"@webiny/error\";\nimport {\n type ISchedulerServiceCreateParams,\n type ISchedulerServiceUpdateParams,\n SchedulerService\n} from \"@webiny/api-scheduler/shared/abstractions.js\";\nimport type { Logger } from \"@webiny/api-core/features/logger/abstractions.js\";\n\n// bree loads this file at runtime via `new Worker(path)`. Referencing it through `new URL` (rather\n// than path.join) makes the app bundler emit pollWorker into build/ as an asset, resolved relative\n// to this module (the server build sets assetPrefix \"auto\"); fileURLToPath then hands bree a plain\n// path string. Un-bundled (dev), import.meta.url is real and it resolves to the dist/jobs file.\nconst workerPath = fileURLToPath(new URL(\"./jobs/pollWorker.js\", import.meta.url));\n\nexport interface IPendingAction {\n id: string;\n namespace: string;\n tenant: string;\n scheduledFor: Date;\n}\n\ninterface IScheduledJob {\n namespace: string;\n tenant: string;\n scheduledFor: Date;\n}\n\nexport interface IBreeSchedulerServiceParams {\n logger: Logger.Interface;\n runAction: (id: string, namespace: string, tenant: string) => Promise<void>;\n}\n\n/**\n * One-shot bree job per scheduled action — mirrors EventBridge behaviour. This is a long-lived root\n * SINGLETON (started once at boot): it holds this process's live timers for ALL tenants, so each job\n * records its own tenant and `runAction` is called with it (the action runs outside any request, so\n * the tenant can't be read from a request context).\n *\n * With several processes, each holds its own timers for the same actions: `recover` runs again on a\n * timer to arm what this process has not seen, and whoever supplies `runAction` makes sure an action\n * runs once.\n */\nexport class BreeSchedulerService implements SchedulerService.Interface {\n private readonly bree;\n private readonly jobs = new Map<string, IScheduledJob>();\n private readonly logger;\n private readonly runAction;\n // Triggers started and not finished yet, so a shutdown can wait for them.\n private readonly running = new Set<Promise<void>>();\n /*\n * Set by `stop`. A recovery that started before the stop runs overdue actions one by one and can\n * still be going after it; this keeps it from starting more actions or arming timers on a Bree\n * that is stopped. Actions it skips stay stored and are picked up by another process's recovery.\n */\n private stopped = false;\n\n public constructor(params: IBreeSchedulerServiceParams) {\n this.logger = params.logger;\n this.runAction = params.runAction;\n\n this.bree = new Bree({\n root: false,\n jobs: [],\n logger: false,\n /*\n * Bree runs each job as a script in a worker thread; it cannot call a function. Running an\n * action needs the DI container, database and tenancy, which only the main thread has, so\n * the job script (`jobs/pollWorker.js`) only posts \"poll\" and exits. Bree passes that\n * message here, in the main thread of the Webiny API process that started Bree, and the\n * action runs in this process. `name` is the job's name, which is the action id.\n */\n workerMessageHandler: async ({ name }) => {\n const job = this.jobs.get(name);\n if (!job) {\n return;\n }\n\n this.jobs.delete(name);\n await this.trigger(name, job.namespace, job.tenant);\n }\n });\n }\n\n public async start(): Promise<void> {\n this.stopped = false;\n await this.bree.start();\n }\n\n public async stop(): Promise<void> {\n this.stopped = true;\n await this.bree.stop();\n }\n\n /**\n * Resolves once every trigger already started has finished, or after `timeoutMs`. Call it after\n * `stop`, which keeps new ones from starting.\n */\n public async waitForRunning(timeoutMs: number): Promise<void> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<void>(resolve => {\n timer = setTimeout(resolve, timeoutMs);\n });\n const running = Promise.allSettled([...this.running]);\n await Promise.race([running, timeout]);\n clearTimeout(timer);\n }\n\n public async create(params: ISchedulerServiceCreateParams): Promise<void> {\n const { id, namespace, scheduleFor, tenant } = params;\n\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot create a schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n { scheduleFor, id }\n );\n }\n\n const exists = await this.exists({\n id,\n namespace,\n tenant\n });\n if (exists) {\n return this.update(params);\n }\n\n await this.arm(id, { namespace, tenant, scheduledFor: scheduleFor });\n }\n\n public async update(params: ISchedulerServiceUpdateParams): Promise<void> {\n const { id, scheduleFor } = params;\n\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot update an existing schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n { scheduleFor, id }\n );\n }\n\n await this.safeRemove(id);\n await this.create(params);\n }\n\n public async delete(params: SchedulerService.DeleteParams): Promise<void> {\n const { id } = params;\n const exists = await this.exists(params);\n if (!exists) {\n throw new WebinyError(`Cannot delete schedule \"${id}\" because it does not exist.`);\n }\n\n await this.safeRemove(id);\n }\n\n public async exists(params: SchedulerService.ExistsParams): Promise<boolean> {\n const { id } = params;\n return this.jobs.has(id);\n }\n\n /**\n * (Re)arm timers for a batch of persisted pending actions. Runs at boot (per tenant) to restore\n * schedules after a restart, and then on a timer, so this process also arms actions another\n * process scheduled or moved. Overdue actions fire immediately.\n *\n * An action already armed for the same time is left as it is; one armed for a different time was\n * moved by another process and is re-armed.\n */\n public async recover(pendingActions: IPendingAction[]): Promise<void> {\n const now = new Date();\n\n for (const action of pendingActions) {\n if (this.stopped) {\n return;\n }\n if (action.scheduledFor <= now) {\n /* Overdue — execute immediately. */\n await this.trigger(action.id, action.namespace, action.tenant);\n continue;\n }\n\n const armed = this.jobs.get(action.id);\n if (armed && armed.scheduledFor.getTime() === action.scheduledFor.getTime()) {\n continue;\n }\n if (armed) {\n await this.safeRemove(action.id);\n }\n\n await this.arm(action.id, {\n namespace: action.namespace,\n tenant: action.tenant,\n scheduledFor: action.scheduledFor\n });\n }\n }\n\n private async arm(id: string, job: IScheduledJob): Promise<void> {\n if (this.stopped) {\n return;\n }\n this.jobs.set(id, job);\n\n await this.bree.add({\n name: id,\n date: job.scheduledFor,\n path: workerPath\n });\n\n await this.bree.start(id);\n }\n\n private async trigger(id: string, namespace: string, tenant: string): Promise<void> {\n if (this.stopped) {\n return;\n }\n const triggered = this.runAction(id, namespace, tenant);\n this.running.add(triggered);\n try {\n await triggered;\n } finally {\n this.running.delete(triggered);\n }\n }\n\n private async safeRemove(id: string): Promise<void> {\n this.jobs.delete(id);\n\n try {\n await this.bree.stop(id);\n } catch {\n this.logger.debug(`Could not stop bree job \"${id}\" — it may have already fired.`);\n }\n\n try {\n await this.bree.remove(id);\n } catch {\n this.logger.debug(\n `Could not remove bree job \"${id}\" — it may have already been removed.`\n );\n }\n }\n}\n"],"names":["workerPath","fileURLToPath","URL","BreeSchedulerService","params","Map","Set","Bree","name","job","timeoutMs","timer","timeout","Promise","resolve","setTimeout","running","clearTimeout","id","namespace","scheduleFor","tenant","Date","WebinyError","exists","pendingActions","now","action","armed","triggered"],"mappings":";;;AAcA,MAAMA,aAAaC,cAAc,IAAIC,IAAI,wBAAwB,YAAY,GAAG;AA8BzE,MAAMC;IAcT,YAAmBC,MAAmC,CAAE;aAZvC,IAAI,GAAG,IAAIC;aAIX,OAAO,GAAG,IAAIC;QAK9B,KACO,OAAO,GAAG;QAGd,IAAI,CAAC,MAAM,GAAGF,OAAO,MAAM;QAC3B,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QAEjC,IAAI,CAAC,IAAI,GAAG,IAAIG,KAAK;YACjB,MAAM;YACN,MAAM,EAAE;YACR,QAAQ;YAQR,sBAAsB,OAAO,EAAEC,IAAI,EAAE;gBACjC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AU,EAAET,GAAkB,EAAiB;QAC7D,IAAI,IAAI,CAAC,OAAO,EACZ;QAEJ,IAAI,CAAC,IAAI,CAAC,GAAG,CAACS,IAAIT;QAElB,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YAChB,MAAMS;YACN,MAAMT,IAAI,YAAY;YACtB,MAAMT;QACV;QAEA,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAACkB;IAC1B;IAEA,MAAc,QAAQA,EAAU,EAAEC,SAAiB,EAAEE,MAAc,EAAiB;QAChF,IAAI,IAAI,CAAC,OAAO,EACZ;QAEJ,MAAMQ,YAAY,IAAI,CAAC,SAAS,CAACX,IAAIC,WAAWE;QAChD,IAAI,CAAC,OAAO,CAAC,GAAG,CAACQ;QACjB,IAAI;YACA,MAAMA;QACV,SAAU;YACN,IAAI,CAAC,OAAO,CAAC,MAAM,CAACA;QACxB;IACJ;IAEA,MAAc,WAAWX,EAAU,EAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,MAAM,CAACA;QAEjB,IAAI;YACA,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAACA;QACzB,EAAE,OAAM;YACJ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,yBAAyB,EAAEA,GAAG,8BAA8B,CAAC;QACpF;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAACA;QAC3B,EAAE,OAAM;YACJ,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,CAAC,2BAA2B,EAAEA,GAAG,qCAAqC,CAAC;QAE/E;IACJ;AACJ"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @webiny/api-scheduler-standalone
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BreeSchedulerService } from "./BreeSchedulerService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs/pollWorker.js","sources":["../../src/jobs/pollWorker.js"],"sourcesContent":["import { parentPort } from \"node:worker_threads\";\n\nif (parentPort) {\n parentPort.postMessage(\"poll\");\n}\n"],"names":["parentPort"],"mappings":";AAEA,IAAIA,YACAA,WAAW,WAAW,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-scheduler-standalone",
|
|
3
|
+
"version": "0.0.0-unstable.33e4fd9647",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
12
|
+
"directory": "packages/api-scheduler-standalone"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"scheduler:server"
|
|
16
|
+
],
|
|
17
|
+
"author": "Webiny Ltd",
|
|
18
|
+
"description": "Standalone cron-based implementation for the Webiny action scheduler.",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@webiny/api-core": "0.0.0-unstable.33e4fd9647",
|
|
22
|
+
"@webiny/api-scheduler": "0.0.0-unstable.33e4fd9647",
|
|
23
|
+
"@webiny/error": "0.0.0-unstable.33e4fd9647",
|
|
24
|
+
"bree": "9.2.9"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@webiny/build-tools": "0.0.0-unstable.33e4fd9647",
|
|
28
|
+
"typescript": "7.0.2",
|
|
29
|
+
"vitest": "4.1.11"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"webiny": {
|
|
35
|
+
"publishFrom": "dist"
|
|
36
|
+
}
|
|
37
|
+
}
|