nvent 0.4.4 → 0.4.5
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/module.d.mts +3 -184
- package/dist/module.json +3 -3
- package/dist/module.mjs +133 -197
- package/dist/runtime/adapters/builtin/file-queue.d.ts +53 -0
- package/dist/runtime/adapters/builtin/file-queue.js +435 -0
- package/dist/runtime/adapters/builtin/file-store.d.ts +46 -0
- package/dist/runtime/adapters/builtin/file-store.js +225 -0
- package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
- package/dist/runtime/adapters/builtin/file-stream.js +56 -0
- package/dist/runtime/adapters/builtin/index.d.ts +10 -0
- package/dist/runtime/adapters/builtin/index.js +5 -0
- package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
- package/dist/runtime/adapters/builtin/memory-queue.js +239 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +57 -0
- package/dist/runtime/adapters/builtin/memory-store.js +263 -0
- package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
- package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
- package/dist/runtime/adapters/factory.d.ts +31 -0
- package/dist/runtime/adapters/factory.js +100 -0
- package/dist/runtime/adapters/index.d.ts +8 -0
- package/dist/runtime/adapters/index.js +3 -0
- package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
- package/dist/runtime/adapters/interfaces/index.js +3 -0
- package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
- package/dist/runtime/adapters/interfaces/store.d.ts +233 -0
- package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
- package/dist/runtime/adapters/registry.d.ts +85 -0
- package/dist/runtime/adapters/registry.js +161 -0
- package/dist/runtime/config/index.d.ts +29 -0
- package/dist/runtime/config/index.js +167 -0
- package/dist/runtime/config/types.d.ts +367 -0
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/events/types.d.ts +116 -0
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +99 -0
- package/dist/runtime/events/utils/stallDetector.js +237 -0
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +3 -8
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.js +119 -36
- package/dist/runtime/events/wiring/registry.d.ts +19 -0
- package/dist/runtime/events/wiring/registry.js +33 -0
- package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
- package/dist/runtime/events/wiring/stateWiring.js +92 -0
- package/dist/runtime/events/wiring/streamWiring.d.ts +32 -0
- package/dist/runtime/events/wiring/streamWiring.js +79 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +16 -5
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +21 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +12 -2
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +15 -4
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +11 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +21 -16
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +21 -19
- package/dist/runtime/server/api/_flows/ws.js +43 -22
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +8 -3
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +12 -3
- package/dist/runtime/server/api/_queues/index.get.js +66 -23
- package/dist/runtime/server/api/_queues/ws.js +14 -4
- package/dist/runtime/server/plugins/00.adapters.d.ts +14 -0
- package/dist/runtime/server/plugins/00.adapters.js +69 -0
- package/dist/runtime/server/plugins/02.workers.js +45 -0
- package/dist/runtime/tsconfig.json +8 -0
- package/dist/runtime/utils/adapters.d.ts +66 -0
- package/dist/runtime/utils/adapters.js +51 -0
- package/dist/runtime/utils/defineFunction.d.ts +10 -0
- package/dist/runtime/{server-utils/utils/defineQueueWorker.js → utils/defineFunction.js} +4 -4
- package/dist/runtime/{server-utils/utils/defineQueueConfig.d.ts → utils/defineFunctionConfig.d.ts} +3 -3
- package/dist/runtime/utils/defineFunctionConfig.js +2 -0
- package/dist/runtime/utils/registerAdapter.d.ts +59 -0
- package/dist/runtime/utils/registerAdapter.js +13 -0
- package/dist/runtime/utils/useFlowEngine.d.ts +19 -0
- package/dist/runtime/utils/useFlowEngine.js +108 -0
- package/dist/runtime/{server-utils/utils → utils}/useNventLogger.js +2 -2
- package/dist/runtime/utils/useStreamTopics.d.ts +72 -0
- package/dist/runtime/utils/useStreamTopics.js +47 -0
- package/dist/runtime/{server-utils/worker/runner/node.d.ts → worker/node/runner.d.ts} +18 -2
- package/dist/runtime/{server-utils/worker/runner/node.js → worker/node/runner.js} +44 -17
- package/dist/types.d.mts +2 -2
- package/package.json +14 -44
- package/LICENSE +0 -21
- package/README.md +0 -389
- package/dist/runtime/app/assets/vueflow.css +0 -1
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
- package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
- package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
- package/dist/runtime/app/components/FlowDiagram.vue +0 -338
- package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
- package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
- package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
- package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
- package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
- package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
- package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
- package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
- package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
- package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
- package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
- package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
- package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
- package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
- package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
- package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
- package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
- package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
- package/dist/runtime/app/components/JobScheduling.vue +0 -203
- package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
- package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
- package/dist/runtime/app/components/ListItem.vue +0 -70
- package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
- package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
- package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
- package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
- package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
- package/dist/runtime/app/components/StatCounter.vue +0 -25
- package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
- package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
- package/dist/runtime/app/components/TimelineList.vue +0 -210
- package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
- package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
- package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
- package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
- package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
- package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
- package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
- package/dist/runtime/app/composables/useComponentRouter.js +0 -240
- package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -80
- package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
- package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
- package/dist/runtime/app/composables/useFlowRuns.js +0 -32
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
- package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
- package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
- package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
- package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
- package/dist/runtime/app/composables/useFlowState.js +0 -211
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
- package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
- package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
- package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
- package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueJobs.js +0 -20
- package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
- package/dist/runtime/app/composables/useQueues.d.ts +0 -45
- package/dist/runtime/app/composables/useQueues.js +0 -26
- package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
- package/dist/runtime/app/composables/useQueuesLive.js +0 -143
- package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/flows/index.vue +0 -645
- package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/index.vue +0 -34
- package/dist/runtime/app/pages/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/index.vue +0 -229
- package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/job.vue +0 -262
- package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.vue +0 -291
- package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
- package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
- package/dist/runtime/app/plugins/vueflow.client.js +0 -11
- package/dist/runtime/constants.d.ts +0 -11
- package/dist/runtime/constants.js +0 -11
- package/dist/runtime/schema.d.ts +0 -37
- package/dist/runtime/schema.js +0 -20
- package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
- package/dist/runtime/server/plugins/00.event-store.js +0 -16
- package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
- package/dist/runtime/server/plugins/flow-management.js +0 -65
- package/dist/runtime/server/plugins/queue-management.js +0 -27
- package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
- package/dist/runtime/server/plugins/state-cleanup.js +0 -93
- package/dist/runtime/server/plugins/worker-management.js +0 -33
- package/dist/runtime/server/tsconfig.json +0 -3
- package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
- package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
- package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
- package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
- package/dist/runtime/server-utils/events/streamNames.js +0 -17
- package/dist/runtime/server-utils/events/types.d.ts +0 -63
- package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
- package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
- package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
- package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
- package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
- package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
- package/dist/runtime/server-utils/queue/types.d.ts +0 -47
- package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
- package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
- package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
- package/dist/runtime/server-utils/state/stateFactory.js +0 -17
- package/dist/runtime/server-utils/state/types.d.ts +0 -23
- package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
- package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
- package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
- package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
- package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
- package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
- package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
- package/dist/runtime/server-utils/utils/useLogs.js +0 -74
- package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
- package/dist/runtime/server-utils/utils/useQueue.js +0 -24
- package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
- package/dist/runtime/server-utils/worker/adapter.js +0 -66
- package/dist/runtime/types.d.ts +0 -132
- /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
- /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
- /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
- /package/dist/runtime/server/{plugins/queue-management.d.ts → api/_flows/[name]/runs/[runId]/cancel.post.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.d.ts → 01.ws-lifecycle.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.js → 01.ws-lifecycle.js} +0 -0
- /package/dist/runtime/server/plugins/{worker-management.d.ts → 02.workers.d.ts} +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.js +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.js +0 -0
- /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
export class MemoryStoreAdapter {
|
|
2
|
+
// Event Stream storage: subject -> events
|
|
3
|
+
eventStreams = /* @__PURE__ */ new Map();
|
|
4
|
+
eventSubscriptions = /* @__PURE__ */ new Map();
|
|
5
|
+
subscriptionCounter = 0;
|
|
6
|
+
// Document Store storage: collection -> id -> document
|
|
7
|
+
documents = /* @__PURE__ */ new Map();
|
|
8
|
+
// Key-Value Store storage: key -> value
|
|
9
|
+
kvStore = /* @__PURE__ */ new Map();
|
|
10
|
+
async close() {
|
|
11
|
+
this.eventStreams.clear();
|
|
12
|
+
this.eventSubscriptions.clear();
|
|
13
|
+
this.documents.clear();
|
|
14
|
+
this.kvStore.clear();
|
|
15
|
+
}
|
|
16
|
+
// ============================================================
|
|
17
|
+
// Event Stream
|
|
18
|
+
// ============================================================
|
|
19
|
+
async append(subject, event) {
|
|
20
|
+
const eventRecord = {
|
|
21
|
+
id: this.generateId(),
|
|
22
|
+
ts: Date.now(),
|
|
23
|
+
...event
|
|
24
|
+
};
|
|
25
|
+
if (!this.eventStreams.has(subject)) {
|
|
26
|
+
this.eventStreams.set(subject, []);
|
|
27
|
+
}
|
|
28
|
+
const stream = this.eventStreams.get(subject);
|
|
29
|
+
stream.push(eventRecord);
|
|
30
|
+
this.notifySubscribers(subject, eventRecord);
|
|
31
|
+
return eventRecord;
|
|
32
|
+
}
|
|
33
|
+
async read(subject, opts) {
|
|
34
|
+
const stream = this.eventStreams.get(subject) || [];
|
|
35
|
+
let events = [...stream];
|
|
36
|
+
if (opts?.types && opts.types.length > 0) {
|
|
37
|
+
events = events.filter((e) => opts.types.includes(e.type));
|
|
38
|
+
}
|
|
39
|
+
if (opts?.after) {
|
|
40
|
+
const afterIndex = events.findIndex((e) => e.id === opts.after);
|
|
41
|
+
if (afterIndex >= 0) {
|
|
42
|
+
events = events.slice(afterIndex + 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (opts?.before) {
|
|
46
|
+
const beforeIndex = events.findIndex((e) => e.id === opts.before);
|
|
47
|
+
if (beforeIndex >= 0) {
|
|
48
|
+
events = events.slice(0, beforeIndex);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (opts?.from) {
|
|
52
|
+
events = events.filter((e) => e.ts >= opts.from);
|
|
53
|
+
}
|
|
54
|
+
if (opts?.to) {
|
|
55
|
+
events = events.filter((e) => e.ts <= opts.to);
|
|
56
|
+
}
|
|
57
|
+
if (opts?.order === "desc") {
|
|
58
|
+
events.reverse();
|
|
59
|
+
}
|
|
60
|
+
if (opts?.limit) {
|
|
61
|
+
events = events.slice(0, opts.limit);
|
|
62
|
+
}
|
|
63
|
+
return events;
|
|
64
|
+
}
|
|
65
|
+
async subscribe(subject, onEvent) {
|
|
66
|
+
const subscriptionId = `sub-${++this.subscriptionCounter}`;
|
|
67
|
+
if (!this.eventSubscriptions.has(subject)) {
|
|
68
|
+
this.eventSubscriptions.set(subject, /* @__PURE__ */ new Map());
|
|
69
|
+
}
|
|
70
|
+
const subjectSubs = this.eventSubscriptions.get(subject);
|
|
71
|
+
subjectSubs.set(subscriptionId, onEvent);
|
|
72
|
+
return {
|
|
73
|
+
id: subscriptionId,
|
|
74
|
+
subject,
|
|
75
|
+
unsubscribe: async () => {
|
|
76
|
+
const subs = this.eventSubscriptions.get(subject);
|
|
77
|
+
if (subs) {
|
|
78
|
+
subs.delete(subscriptionId);
|
|
79
|
+
if (subs.size === 0) {
|
|
80
|
+
this.eventSubscriptions.delete(subject);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
notifySubscribers(subject, event) {
|
|
87
|
+
const subs = this.eventSubscriptions.get(subject);
|
|
88
|
+
if (subs) {
|
|
89
|
+
Array.from(subs.values()).forEach((callback) => {
|
|
90
|
+
try {
|
|
91
|
+
callback(event);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(`[MemoryStoreAdapter] Error in event subscription for ${subject}:`, error);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// ============================================================
|
|
99
|
+
// Document Store
|
|
100
|
+
// ============================================================
|
|
101
|
+
async save(collection, id, doc) {
|
|
102
|
+
if (!this.documents.has(collection)) {
|
|
103
|
+
this.documents.set(collection, /* @__PURE__ */ new Map());
|
|
104
|
+
}
|
|
105
|
+
const collectionDocs = this.documents.get(collection);
|
|
106
|
+
collectionDocs.set(id, doc);
|
|
107
|
+
}
|
|
108
|
+
async get(collection, id) {
|
|
109
|
+
const collectionDocs = this.documents.get(collection);
|
|
110
|
+
if (!collectionDocs) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return collectionDocs.get(id) || null;
|
|
114
|
+
}
|
|
115
|
+
async list(collection, opts) {
|
|
116
|
+
const collectionDocs = this.documents.get(collection);
|
|
117
|
+
if (!collectionDocs) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
let results = Array.from(collectionDocs.entries()).map(([id, doc]) => ({ id, doc }));
|
|
121
|
+
if (opts?.filter) {
|
|
122
|
+
results = results.filter((item) => {
|
|
123
|
+
return Object.entries(opts.filter).every(([key, value]) => {
|
|
124
|
+
return item.doc[key] === value;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (opts?.sortBy) {
|
|
129
|
+
results.sort((a, b) => {
|
|
130
|
+
const aVal = a.doc[opts.sortBy];
|
|
131
|
+
const bVal = b.doc[opts.sortBy];
|
|
132
|
+
if (aVal < bVal) return opts.order === "desc" ? 1 : -1;
|
|
133
|
+
if (aVal > bVal) return opts.order === "desc" ? -1 : 1;
|
|
134
|
+
return 0;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (opts?.offset) {
|
|
138
|
+
results = results.slice(opts.offset);
|
|
139
|
+
}
|
|
140
|
+
if (opts?.limit) {
|
|
141
|
+
results = results.slice(0, opts.limit);
|
|
142
|
+
}
|
|
143
|
+
return results;
|
|
144
|
+
}
|
|
145
|
+
async delete(collection, id) {
|
|
146
|
+
const collectionDocs = this.documents.get(collection);
|
|
147
|
+
if (collectionDocs) {
|
|
148
|
+
collectionDocs.delete(id);
|
|
149
|
+
if (collectionDocs.size === 0) {
|
|
150
|
+
this.documents.delete(collection);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// ============================================================
|
|
155
|
+
// Key-Value Store
|
|
156
|
+
// ============================================================
|
|
157
|
+
kv = {
|
|
158
|
+
get: async (key) => {
|
|
159
|
+
return this.kvStore.get(key) || null;
|
|
160
|
+
},
|
|
161
|
+
set: async (key, value, _ttl) => {
|
|
162
|
+
this.kvStore.set(key, value);
|
|
163
|
+
},
|
|
164
|
+
delete: async (key) => {
|
|
165
|
+
this.kvStore.delete(key);
|
|
166
|
+
},
|
|
167
|
+
clear: async (pattern) => {
|
|
168
|
+
const regex = new RegExp(`^${pattern.replace(/\*/g, ".*")}$`);
|
|
169
|
+
const keys = Array.from(this.kvStore.keys());
|
|
170
|
+
let count = 0;
|
|
171
|
+
for (const key of keys) {
|
|
172
|
+
if (regex.test(key)) {
|
|
173
|
+
this.kvStore.delete(key);
|
|
174
|
+
count++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return count;
|
|
178
|
+
},
|
|
179
|
+
increment: async (key, by = 1) => {
|
|
180
|
+
const current = this.kvStore.get(key) || 0;
|
|
181
|
+
const newValue = (typeof current === "number" ? current : 0) + by;
|
|
182
|
+
this.kvStore.set(key, newValue);
|
|
183
|
+
return newValue;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
// ============================================================
|
|
187
|
+
// Sorted Index (optional, for time-ordered listings)
|
|
188
|
+
// ============================================================
|
|
189
|
+
// Sorted index storage: key -> sorted array of {id, score, metadata}
|
|
190
|
+
sortedIndices = /* @__PURE__ */ new Map();
|
|
191
|
+
async indexAdd(key, id, score, metadata) {
|
|
192
|
+
if (!this.sortedIndices.has(key)) {
|
|
193
|
+
this.sortedIndices.set(key, []);
|
|
194
|
+
}
|
|
195
|
+
const index = this.sortedIndices.get(key);
|
|
196
|
+
const existingIndex = index.findIndex((entry2) => entry2.id === id);
|
|
197
|
+
const entry = {
|
|
198
|
+
id,
|
|
199
|
+
score,
|
|
200
|
+
metadata: metadata ? { version: 0, ...metadata } : void 0
|
|
201
|
+
};
|
|
202
|
+
if (existingIndex >= 0) {
|
|
203
|
+
index[existingIndex] = entry;
|
|
204
|
+
} else {
|
|
205
|
+
index.push(entry);
|
|
206
|
+
}
|
|
207
|
+
index.sort((a, b) => b.score - a.score);
|
|
208
|
+
}
|
|
209
|
+
async indexGet(key, id) {
|
|
210
|
+
const index = this.sortedIndices.get(key);
|
|
211
|
+
if (!index) return null;
|
|
212
|
+
const entry = index.find((e) => e.id === id);
|
|
213
|
+
return entry ? { ...entry } : null;
|
|
214
|
+
}
|
|
215
|
+
async indexRead(key, opts) {
|
|
216
|
+
const index = this.sortedIndices.get(key) || [];
|
|
217
|
+
const offset = opts?.offset || 0;
|
|
218
|
+
const limit = opts?.limit || 50;
|
|
219
|
+
return index.slice(offset, offset + limit).map((e) => ({ ...e }));
|
|
220
|
+
}
|
|
221
|
+
async indexUpdate(key, id, metadata) {
|
|
222
|
+
const index = this.sortedIndices.get(key);
|
|
223
|
+
if (!index) return false;
|
|
224
|
+
const entry = index.find((e) => e.id === id);
|
|
225
|
+
if (!entry || !entry.metadata) return false;
|
|
226
|
+
const currentVersion = entry.metadata.version || 0;
|
|
227
|
+
const expectedVersion = currentVersion;
|
|
228
|
+
entry.metadata = {
|
|
229
|
+
...entry.metadata,
|
|
230
|
+
...metadata,
|
|
231
|
+
version: expectedVersion + 1
|
|
232
|
+
};
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
async indexUpdateWithRetry(key, id, metadata, maxRetries = 3) {
|
|
236
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
237
|
+
const success = await this.indexUpdate(key, id, metadata);
|
|
238
|
+
if (success) return;
|
|
239
|
+
await new Promise((resolve) => setTimeout(resolve, 10 * Math.pow(2, attempt)));
|
|
240
|
+
}
|
|
241
|
+
throw new Error(`Failed to update index after ${maxRetries} retries`);
|
|
242
|
+
}
|
|
243
|
+
async indexIncrement(key, id, field, increment = 1) {
|
|
244
|
+
const index = this.sortedIndices.get(key);
|
|
245
|
+
if (!index) throw new Error(`Index not found: ${key}`);
|
|
246
|
+
const entry = index.find((e) => e.id === id);
|
|
247
|
+
if (!entry) throw new Error(`Entry not found: ${id} in index ${key}`);
|
|
248
|
+
if (!entry.metadata) {
|
|
249
|
+
entry.metadata = { version: 0 };
|
|
250
|
+
}
|
|
251
|
+
const currentValue = entry.metadata[field] || 0;
|
|
252
|
+
const newValue = (typeof currentValue === "number" ? currentValue : 0) + increment;
|
|
253
|
+
entry.metadata[field] = newValue;
|
|
254
|
+
entry.metadata.version = (entry.metadata.version || 0) + 1;
|
|
255
|
+
return newValue;
|
|
256
|
+
}
|
|
257
|
+
// ============================================================
|
|
258
|
+
// Helpers
|
|
259
|
+
// ============================================================
|
|
260
|
+
generateId() {
|
|
261
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Stream Adapter
|
|
3
|
+
*
|
|
4
|
+
* In-memory pub/sub implementation for development
|
|
5
|
+
* - Uses EventEmitter pattern
|
|
6
|
+
* - No external dependencies
|
|
7
|
+
* - Single instance only
|
|
8
|
+
* - Data lost on restart
|
|
9
|
+
*/
|
|
10
|
+
import type { StreamAdapter, StreamEvent, SubscribeOptions, SubscriptionHandle } from '../interfaces/stream.js';
|
|
11
|
+
export declare class MemoryStreamAdapter implements StreamAdapter {
|
|
12
|
+
private subscriptions;
|
|
13
|
+
private subscriptionCounter;
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
publish(topic: string, event: StreamEvent): Promise<void>;
|
|
16
|
+
subscribe(topic: string, handler: (event: StreamEvent) => void | Promise<void>, _opts?: SubscribeOptions): Promise<SubscriptionHandle>;
|
|
17
|
+
unsubscribe(handle: SubscriptionHandle): Promise<void>;
|
|
18
|
+
listTopics(): Promise<string[]>;
|
|
19
|
+
getSubscriptionCount(topic: string): Promise<number>;
|
|
20
|
+
shutdown(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class MemoryStreamAdapter {
|
|
2
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
3
|
+
subscriptionCounter = 0;
|
|
4
|
+
async init() {
|
|
5
|
+
}
|
|
6
|
+
async publish(topic, event) {
|
|
7
|
+
const topicSubscriptions = this.subscriptions.get(topic);
|
|
8
|
+
if (!topicSubscriptions || topicSubscriptions.size === 0) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const eventWithTs = {
|
|
12
|
+
...event,
|
|
13
|
+
timestamp: event.timestamp || Date.now()
|
|
14
|
+
};
|
|
15
|
+
const promises = [];
|
|
16
|
+
Array.from(topicSubscriptions.values()).forEach((handler) => {
|
|
17
|
+
promises.push(handler(eventWithTs));
|
|
18
|
+
});
|
|
19
|
+
await Promise.all(promises);
|
|
20
|
+
}
|
|
21
|
+
async subscribe(topic, handler, _opts) {
|
|
22
|
+
const subscriptionId = `sub-${++this.subscriptionCounter}`;
|
|
23
|
+
if (!this.subscriptions.has(topic)) {
|
|
24
|
+
this.subscriptions.set(topic, /* @__PURE__ */ new Map());
|
|
25
|
+
}
|
|
26
|
+
const topicSubscriptions = this.subscriptions.get(topic);
|
|
27
|
+
topicSubscriptions.set(subscriptionId, handler);
|
|
28
|
+
return {
|
|
29
|
+
id: subscriptionId,
|
|
30
|
+
topic,
|
|
31
|
+
unsubscribe: async () => {
|
|
32
|
+
await this.unsubscribe({ id: subscriptionId, topic, unsubscribe: async () => {
|
|
33
|
+
} });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async unsubscribe(handle) {
|
|
38
|
+
const topicSubscriptions = this.subscriptions.get(handle.topic);
|
|
39
|
+
if (topicSubscriptions) {
|
|
40
|
+
topicSubscriptions.delete(handle.id);
|
|
41
|
+
if (topicSubscriptions.size === 0) {
|
|
42
|
+
this.subscriptions.delete(handle.topic);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async listTopics() {
|
|
47
|
+
return Array.from(this.subscriptions.keys());
|
|
48
|
+
}
|
|
49
|
+
async getSubscriptionCount(topic) {
|
|
50
|
+
const topicSubscriptions = this.subscriptions.get(topic);
|
|
51
|
+
return topicSubscriptions ? topicSubscriptions.size : 0;
|
|
52
|
+
}
|
|
53
|
+
async shutdown() {
|
|
54
|
+
this.subscriptions.clear();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Factory (v0.4.1)
|
|
3
|
+
*
|
|
4
|
+
* Creates adapters independently without dependencies
|
|
5
|
+
* StoreAdapter is pure storage - streaming handled by wiring layer
|
|
6
|
+
*
|
|
7
|
+
* Now supports external adapters via the adapter registry.
|
|
8
|
+
* External adapters registered via the nvent:registerAdapter hook take precedence.
|
|
9
|
+
*/
|
|
10
|
+
import type { QueueAdapter } from './interfaces/queue.js';
|
|
11
|
+
import type { StreamAdapter } from './interfaces/stream.js';
|
|
12
|
+
import type { StoreAdapter } from './interfaces/store.js';
|
|
13
|
+
import type { QueueConfig, StreamConfig, StoreConfig } from '../config/types.js';
|
|
14
|
+
export interface AdapterSet {
|
|
15
|
+
queue: QueueAdapter;
|
|
16
|
+
stream: StreamAdapter;
|
|
17
|
+
store: StoreAdapter;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a complete set of adapters (v0.4.1)
|
|
21
|
+
* All adapters are independent - wiring layer handles coordination
|
|
22
|
+
*/
|
|
23
|
+
export declare function createAdapters(config: {
|
|
24
|
+
queue: QueueConfig;
|
|
25
|
+
stream: StreamConfig;
|
|
26
|
+
store: StoreConfig;
|
|
27
|
+
}): Promise<AdapterSet>;
|
|
28
|
+
/**
|
|
29
|
+
* Shutdown all adapters gracefully
|
|
30
|
+
*/
|
|
31
|
+
export declare function shutdownAdapters(adapters: AdapterSet): Promise<void>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useAdapterRegistry } from "./registry.js";
|
|
2
|
+
import {
|
|
3
|
+
MemoryQueueAdapter,
|
|
4
|
+
MemoryStreamAdapter,
|
|
5
|
+
MemoryStoreAdapter,
|
|
6
|
+
FileQueueAdapter,
|
|
7
|
+
FileStoreAdapter
|
|
8
|
+
} from "./builtin/index.js";
|
|
9
|
+
export async function createAdapters(config) {
|
|
10
|
+
const stream = await createStreamAdapter(config.stream);
|
|
11
|
+
const store = await createStoreAdapter(config.store);
|
|
12
|
+
const queue = await createQueueAdapter(config.queue);
|
|
13
|
+
return { queue, stream, store };
|
|
14
|
+
}
|
|
15
|
+
async function createStreamAdapter(config) {
|
|
16
|
+
const type = config.adapter || "memory";
|
|
17
|
+
const registry = useAdapterRegistry();
|
|
18
|
+
if (registry.hasStream(type)) {
|
|
19
|
+
const adapter = registry.getStream(type);
|
|
20
|
+
await adapter.init();
|
|
21
|
+
return adapter;
|
|
22
|
+
}
|
|
23
|
+
switch (type) {
|
|
24
|
+
case "memory": {
|
|
25
|
+
const adapter = new MemoryStreamAdapter();
|
|
26
|
+
await adapter.init();
|
|
27
|
+
return adapter;
|
|
28
|
+
}
|
|
29
|
+
case "redis":
|
|
30
|
+
throw new Error("Redis stream adapter not registered. Install @nvent/adapter-stream-redis and add it to your nuxt.config modules.");
|
|
31
|
+
case "rabbitmq":
|
|
32
|
+
throw new Error("RabbitMQ stream adapter not yet implemented");
|
|
33
|
+
case "kafka":
|
|
34
|
+
throw new Error("Kafka stream adapter not yet implemented");
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unknown stream adapter type: ${type}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function createStoreAdapter(config) {
|
|
40
|
+
const type = config.adapter || "file";
|
|
41
|
+
const registry = useAdapterRegistry();
|
|
42
|
+
if (registry.hasStore(type)) {
|
|
43
|
+
const adapter = registry.getStore(type);
|
|
44
|
+
return adapter;
|
|
45
|
+
}
|
|
46
|
+
switch (type) {
|
|
47
|
+
case "memory": {
|
|
48
|
+
return new MemoryStoreAdapter();
|
|
49
|
+
}
|
|
50
|
+
case "file": {
|
|
51
|
+
const dataDir = config.file?.dataDir || ".data/store";
|
|
52
|
+
const adapter = new FileStoreAdapter({
|
|
53
|
+
dataDir
|
|
54
|
+
});
|
|
55
|
+
await adapter.init();
|
|
56
|
+
return adapter;
|
|
57
|
+
}
|
|
58
|
+
case "redis":
|
|
59
|
+
throw new Error("Redis store adapter not registered. Install @nvent/adapter-store-redis and add it to your nuxt.config modules.");
|
|
60
|
+
case "postgres":
|
|
61
|
+
throw new Error("Postgres store adapter not yet implemented");
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`Unknown store adapter type: ${type}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function createQueueAdapter(config) {
|
|
67
|
+
const type = config.adapter || "file";
|
|
68
|
+
const registry = useAdapterRegistry();
|
|
69
|
+
if (registry.hasQueue(type)) {
|
|
70
|
+
const adapter = registry.getQueue(type);
|
|
71
|
+
await adapter.init();
|
|
72
|
+
return adapter;
|
|
73
|
+
}
|
|
74
|
+
switch (type) {
|
|
75
|
+
case "memory": {
|
|
76
|
+
const adapter = new MemoryQueueAdapter();
|
|
77
|
+
await adapter.init();
|
|
78
|
+
return adapter;
|
|
79
|
+
}
|
|
80
|
+
case "file": {
|
|
81
|
+
const dataDir = config.file?.dataDir || ".data/queue";
|
|
82
|
+
const adapter = new FileQueueAdapter({ dataDir });
|
|
83
|
+
await adapter.init();
|
|
84
|
+
return adapter;
|
|
85
|
+
}
|
|
86
|
+
case "redis":
|
|
87
|
+
throw new Error("Redis queue adapter not registered. Install @nvent/adapter-queue-redis and add it to your nuxt.config modules.");
|
|
88
|
+
case "postgres":
|
|
89
|
+
throw new Error("Postgres queue adapter (PGBoss) not yet implemented");
|
|
90
|
+
default:
|
|
91
|
+
throw new Error(`Unknown queue adapter type: ${type}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export async function shutdownAdapters(adapters) {
|
|
95
|
+
await Promise.all([
|
|
96
|
+
adapters.queue.close(),
|
|
97
|
+
adapters.stream.shutdown(),
|
|
98
|
+
adapters.store.close()
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Interfaces
|
|
3
|
+
*
|
|
4
|
+
* Three types of adapters for nvent:
|
|
5
|
+
* - QueueAdapter: Job execution infrastructure
|
|
6
|
+
* - StreamAdapter: Cross-instance pub/sub messaging
|
|
7
|
+
* - StoreAdapter: Three-tier storage (events, documents, key-value)
|
|
8
|
+
*/
|
|
9
|
+
export * from './queue.js';
|
|
10
|
+
export * from './stream.js';
|
|
11
|
+
export * from './store.js';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Adapter Interface
|
|
3
|
+
*
|
|
4
|
+
* Handles job queue operations only (enqueue, retrieve, manage)
|
|
5
|
+
* Does NOT handle event storage, state, or logging - those are separate concerns
|
|
6
|
+
*/
|
|
7
|
+
export interface QueueAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the queue adapter
|
|
10
|
+
*/
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Add a job to the queue
|
|
14
|
+
* @returns Job ID
|
|
15
|
+
*/
|
|
16
|
+
enqueue(queueName: string, job: JobInput): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Schedule a job (delayed or recurring)
|
|
19
|
+
* @returns Job ID
|
|
20
|
+
*/
|
|
21
|
+
schedule(queueName: string, job: JobInput, opts?: ScheduleOptions): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Get a specific job by ID
|
|
24
|
+
*/
|
|
25
|
+
getJob(queueName: string, id: string): Promise<Job | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get multiple jobs with optional filtering
|
|
28
|
+
*/
|
|
29
|
+
getJobs(queueName: string, query?: JobsQuery): Promise<Job[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to queue events
|
|
32
|
+
* @returns Unsubscribe function
|
|
33
|
+
*/
|
|
34
|
+
on(queueName: string, event: QueueEvent, callback: (payload: any) => void): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if queue is paused
|
|
37
|
+
*/
|
|
38
|
+
isPaused(queueName: string): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Get job counts by state
|
|
41
|
+
*/
|
|
42
|
+
getJobCounts(queueName: string): Promise<JobCounts>;
|
|
43
|
+
/**
|
|
44
|
+
* Get scheduled/repeatable jobs (cron jobs)
|
|
45
|
+
*/
|
|
46
|
+
getScheduledJobs?(queueName: string): Promise<ScheduledJobInfo[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Remove a scheduled/repeatable job
|
|
49
|
+
* @returns true if removed, false if not found
|
|
50
|
+
*/
|
|
51
|
+
removeScheduledJob?(scheduleId: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Pause the queue
|
|
54
|
+
*/
|
|
55
|
+
pause(queueName: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Resume the queue
|
|
58
|
+
*/
|
|
59
|
+
resume(queueName: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Register a worker handler for processing jobs
|
|
62
|
+
* This is called by the worker registration system
|
|
63
|
+
*/
|
|
64
|
+
registerWorker(queueName: string, jobName: string, handler: WorkerHandler, opts?: WorkerOptions): void;
|
|
65
|
+
/**
|
|
66
|
+
* Start processing waiting jobs for a queue
|
|
67
|
+
* Should be called after all handlers are registered
|
|
68
|
+
*/
|
|
69
|
+
startProcessingQueue?(queueName: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Close/cleanup the adapter
|
|
72
|
+
*/
|
|
73
|
+
close(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export interface JobInput {
|
|
76
|
+
name: string;
|
|
77
|
+
data: any;
|
|
78
|
+
opts?: JobOptions;
|
|
79
|
+
}
|
|
80
|
+
export interface JobOptions {
|
|
81
|
+
jobId?: string;
|
|
82
|
+
attempts?: number;
|
|
83
|
+
backoff?: {
|
|
84
|
+
type: 'exponential' | 'fixed';
|
|
85
|
+
delay: number;
|
|
86
|
+
};
|
|
87
|
+
delay?: number;
|
|
88
|
+
priority?: number;
|
|
89
|
+
timeout?: number;
|
|
90
|
+
removeOnComplete?: boolean | number;
|
|
91
|
+
removeOnFail?: boolean | number;
|
|
92
|
+
}
|
|
93
|
+
export interface Job {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
data: any;
|
|
97
|
+
returnvalue?: any;
|
|
98
|
+
failedReason?: string;
|
|
99
|
+
state: 'waiting' | 'active' | 'completed' | 'failed' | 'delayed' | 'paused';
|
|
100
|
+
timestamp?: number;
|
|
101
|
+
processedOn?: number;
|
|
102
|
+
finishedOn?: number;
|
|
103
|
+
attemptsMade?: number;
|
|
104
|
+
progress?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface JobsQuery {
|
|
107
|
+
state?: JobState[];
|
|
108
|
+
limit?: number;
|
|
109
|
+
offset?: number;
|
|
110
|
+
}
|
|
111
|
+
export type JobState = 'waiting' | 'active' | 'completed' | 'failed' | 'delayed' | 'paused';
|
|
112
|
+
export interface ScheduleOptions {
|
|
113
|
+
delay?: number;
|
|
114
|
+
cron?: string;
|
|
115
|
+
repeat?: {
|
|
116
|
+
pattern?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface JobCounts {
|
|
121
|
+
active: number;
|
|
122
|
+
completed: number;
|
|
123
|
+
failed: number;
|
|
124
|
+
delayed: number;
|
|
125
|
+
waiting: number;
|
|
126
|
+
paused: number;
|
|
127
|
+
}
|
|
128
|
+
export interface ScheduledJobInfo {
|
|
129
|
+
id: string;
|
|
130
|
+
jobName: string;
|
|
131
|
+
queueName: string;
|
|
132
|
+
cron?: string;
|
|
133
|
+
pattern?: string;
|
|
134
|
+
nextRun?: Date;
|
|
135
|
+
repeatCount?: number;
|
|
136
|
+
limit?: number;
|
|
137
|
+
}
|
|
138
|
+
export type QueueEvent = 'waiting' | 'active' | 'progress' | 'completed' | 'failed' | 'delayed' | 'paused' | 'stalled';
|
|
139
|
+
export interface WorkerHandler {
|
|
140
|
+
(payload: any, ctx: WorkerContext): Promise<any>;
|
|
141
|
+
}
|
|
142
|
+
export interface WorkerContext {
|
|
143
|
+
jobId: string;
|
|
144
|
+
queueName: string;
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
}
|
|
147
|
+
export interface WorkerOptions {
|
|
148
|
+
concurrency?: number;
|
|
149
|
+
autorun?: boolean;
|
|
150
|
+
}
|