@contractspec/lib.jobs 1.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/_virtual/rolldown_runtime.js +36 -0
- package/dist/contracts/index.d.ts +547 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +482 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/entities/index.d.ts +145 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +198 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/events.d.ts +388 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +353 -0
- package/dist/events.js.map +1 -0
- package/dist/handlers/gmail-sync-handler.d.ts +10 -0
- package/dist/handlers/gmail-sync-handler.d.ts.map +1 -0
- package/dist/handlers/gmail-sync-handler.js +10 -0
- package/dist/handlers/gmail-sync-handler.js.map +1 -0
- package/dist/handlers/index.d.ts +10 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +13 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/ping-job.d.ts +11 -0
- package/dist/handlers/ping-job.d.ts.map +1 -0
- package/dist/handlers/ping-job.js +14 -0
- package/dist/handlers/ping-job.js.map +1 -0
- package/dist/handlers/storage-document-handler.d.ts +13 -0
- package/dist/handlers/storage-document-handler.d.ts.map +1 -0
- package/dist/handlers/storage-document-handler.js +15 -0
- package/dist/handlers/storage-document-handler.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs.feature.d.ts +12 -0
- package/dist/jobs.feature.d.ts.map +1 -0
- package/dist/jobs.feature.js +103 -0
- package/dist/jobs.feature.js.map +1 -0
- package/dist/queue/gcp-cloud-tasks.d.ts +42 -0
- package/dist/queue/gcp-cloud-tasks.d.ts.map +1 -0
- package/dist/queue/gcp-cloud-tasks.js +61 -0
- package/dist/queue/gcp-cloud-tasks.js.map +1 -0
- package/dist/queue/gcp-pubsub.d.ts +26 -0
- package/dist/queue/gcp-pubsub.d.ts.map +1 -0
- package/dist/queue/gcp-pubsub.js +47 -0
- package/dist/queue/gcp-pubsub.js.map +1 -0
- package/dist/queue/index.d.ts +16 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +23 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/memory-queue.d.ts +35 -0
- package/dist/queue/memory-queue.d.ts.map +1 -0
- package/dist/queue/memory-queue.js +140 -0
- package/dist/queue/memory-queue.js.map +1 -0
- package/dist/queue/register-defined-job.d.ts +8 -0
- package/dist/queue/register-defined-job.d.ts.map +1 -0
- package/dist/queue/register-defined-job.js +16 -0
- package/dist/queue/register-defined-job.js.map +1 -0
- package/dist/queue/scaleway-sqs-queue.d.ts +39 -0
- package/dist/queue/scaleway-sqs-queue.d.ts.map +1 -0
- package/dist/queue/scaleway-sqs-queue.js +175 -0
- package/dist/queue/scaleway-sqs-queue.js.map +1 -0
- package/dist/queue/types.d.ts +8 -0
- package/dist/queue/types.d.ts.map +1 -0
- package/dist/queue/types.js +12 -0
- package/dist/queue/types.js.map +1 -0
- package/dist/scheduler/index.d.ts +93 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +146 -0
- package/dist/scheduler/index.js.map +1 -0
- package/package.json +90 -0
package/dist/events.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
import { StabilityEnum, defineEvent } from "@contractspec/lib.contracts";
|
|
3
|
+
|
|
4
|
+
//#region src/events.ts
|
|
5
|
+
const JobEnqueuedPayload = defineSchemaModel({
|
|
6
|
+
name: "JobEnqueuedEventPayload",
|
|
7
|
+
description: "Payload when a job is added to the queue",
|
|
8
|
+
fields: {
|
|
9
|
+
jobId: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
type: {
|
|
14
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
15
|
+
isOptional: false
|
|
16
|
+
},
|
|
17
|
+
priority: {
|
|
18
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
19
|
+
isOptional: false
|
|
20
|
+
},
|
|
21
|
+
scheduledAt: {
|
|
22
|
+
type: ScalarTypeEnum.DateTime(),
|
|
23
|
+
isOptional: true
|
|
24
|
+
},
|
|
25
|
+
tenantId: {
|
|
26
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
27
|
+
isOptional: true
|
|
28
|
+
},
|
|
29
|
+
enqueuedAt: {
|
|
30
|
+
type: ScalarTypeEnum.DateTime(),
|
|
31
|
+
isOptional: false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const JobStartedPayload = defineSchemaModel({
|
|
36
|
+
name: "JobStartedEventPayload",
|
|
37
|
+
description: "Payload when a job starts processing",
|
|
38
|
+
fields: {
|
|
39
|
+
jobId: {
|
|
40
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
41
|
+
isOptional: false
|
|
42
|
+
},
|
|
43
|
+
type: {
|
|
44
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
45
|
+
isOptional: false
|
|
46
|
+
},
|
|
47
|
+
attempt: {
|
|
48
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
49
|
+
isOptional: false
|
|
50
|
+
},
|
|
51
|
+
startedAt: {
|
|
52
|
+
type: ScalarTypeEnum.DateTime(),
|
|
53
|
+
isOptional: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const JobCompletedPayload = defineSchemaModel({
|
|
58
|
+
name: "JobCompletedEventPayload",
|
|
59
|
+
description: "Payload when a job completes successfully",
|
|
60
|
+
fields: {
|
|
61
|
+
jobId: {
|
|
62
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
63
|
+
isOptional: false
|
|
64
|
+
},
|
|
65
|
+
type: {
|
|
66
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
67
|
+
isOptional: false
|
|
68
|
+
},
|
|
69
|
+
attempt: {
|
|
70
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
71
|
+
isOptional: false
|
|
72
|
+
},
|
|
73
|
+
durationMs: {
|
|
74
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
75
|
+
isOptional: false
|
|
76
|
+
},
|
|
77
|
+
completedAt: {
|
|
78
|
+
type: ScalarTypeEnum.DateTime(),
|
|
79
|
+
isOptional: false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const JobFailedPayload = defineSchemaModel({
|
|
84
|
+
name: "JobFailedEventPayload",
|
|
85
|
+
description: "Payload when a job attempt fails",
|
|
86
|
+
fields: {
|
|
87
|
+
jobId: {
|
|
88
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
89
|
+
isOptional: false
|
|
90
|
+
},
|
|
91
|
+
type: {
|
|
92
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
93
|
+
isOptional: false
|
|
94
|
+
},
|
|
95
|
+
attempt: {
|
|
96
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
97
|
+
isOptional: false
|
|
98
|
+
},
|
|
99
|
+
error: {
|
|
100
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
101
|
+
isOptional: false
|
|
102
|
+
},
|
|
103
|
+
willRetry: {
|
|
104
|
+
type: ScalarTypeEnum.Boolean(),
|
|
105
|
+
isOptional: false
|
|
106
|
+
},
|
|
107
|
+
failedAt: {
|
|
108
|
+
type: ScalarTypeEnum.DateTime(),
|
|
109
|
+
isOptional: false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const JobRetryingPayload = defineSchemaModel({
|
|
114
|
+
name: "JobRetryingEventPayload",
|
|
115
|
+
description: "Payload when a job is scheduled for retry",
|
|
116
|
+
fields: {
|
|
117
|
+
jobId: {
|
|
118
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
119
|
+
isOptional: false
|
|
120
|
+
},
|
|
121
|
+
type: {
|
|
122
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
123
|
+
isOptional: false
|
|
124
|
+
},
|
|
125
|
+
attempt: {
|
|
126
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
127
|
+
isOptional: false
|
|
128
|
+
},
|
|
129
|
+
nextAttemptAt: {
|
|
130
|
+
type: ScalarTypeEnum.DateTime(),
|
|
131
|
+
isOptional: false
|
|
132
|
+
},
|
|
133
|
+
backoffMs: {
|
|
134
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
135
|
+
isOptional: false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const JobDeadLetteredPayload = defineSchemaModel({
|
|
140
|
+
name: "JobDeadLetteredEventPayload",
|
|
141
|
+
description: "Payload when a job is moved to dead letter queue",
|
|
142
|
+
fields: {
|
|
143
|
+
jobId: {
|
|
144
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
145
|
+
isOptional: false
|
|
146
|
+
},
|
|
147
|
+
type: {
|
|
148
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
149
|
+
isOptional: false
|
|
150
|
+
},
|
|
151
|
+
attempts: {
|
|
152
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
153
|
+
isOptional: false
|
|
154
|
+
},
|
|
155
|
+
lastError: {
|
|
156
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
157
|
+
isOptional: false
|
|
158
|
+
},
|
|
159
|
+
deadLetteredAt: {
|
|
160
|
+
type: ScalarTypeEnum.DateTime(),
|
|
161
|
+
isOptional: false
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const JobCancelledPayload = defineSchemaModel({
|
|
166
|
+
name: "JobCancelledEventPayload",
|
|
167
|
+
description: "Payload when a job is cancelled",
|
|
168
|
+
fields: {
|
|
169
|
+
jobId: {
|
|
170
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
171
|
+
isOptional: false
|
|
172
|
+
},
|
|
173
|
+
type: {
|
|
174
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
175
|
+
isOptional: false
|
|
176
|
+
},
|
|
177
|
+
cancelledBy: {
|
|
178
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
179
|
+
isOptional: true
|
|
180
|
+
},
|
|
181
|
+
cancelledAt: {
|
|
182
|
+
type: ScalarTypeEnum.DateTime(),
|
|
183
|
+
isOptional: false
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const ScheduledJobTriggeredPayload = defineSchemaModel({
|
|
188
|
+
name: "ScheduledJobTriggeredEventPayload",
|
|
189
|
+
description: "Payload when a scheduled job is triggered",
|
|
190
|
+
fields: {
|
|
191
|
+
scheduleName: {
|
|
192
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
193
|
+
isOptional: false
|
|
194
|
+
},
|
|
195
|
+
jobId: {
|
|
196
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
197
|
+
isOptional: false
|
|
198
|
+
},
|
|
199
|
+
jobType: {
|
|
200
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
201
|
+
isOptional: false
|
|
202
|
+
},
|
|
203
|
+
triggeredAt: {
|
|
204
|
+
type: ScalarTypeEnum.DateTime(),
|
|
205
|
+
isOptional: false
|
|
206
|
+
},
|
|
207
|
+
nextRunAt: {
|
|
208
|
+
type: ScalarTypeEnum.DateTime(),
|
|
209
|
+
isOptional: true
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
/**
|
|
214
|
+
* Emitted when a job is enqueued.
|
|
215
|
+
*/
|
|
216
|
+
const JobEnqueuedEvent = defineEvent({
|
|
217
|
+
meta: {
|
|
218
|
+
key: "job.enqueued",
|
|
219
|
+
version: 1,
|
|
220
|
+
description: "A job has been added to the queue.",
|
|
221
|
+
stability: StabilityEnum.Stable,
|
|
222
|
+
owners: ["@contractspec.libs.jobs"],
|
|
223
|
+
tags: ["job-queue", "lifecycle"]
|
|
224
|
+
},
|
|
225
|
+
payload: JobEnqueuedPayload
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* Emitted when a job starts processing.
|
|
229
|
+
*/
|
|
230
|
+
const JobStartedEvent = defineEvent({
|
|
231
|
+
meta: {
|
|
232
|
+
key: "job.started",
|
|
233
|
+
version: 1,
|
|
234
|
+
description: "A job has started processing.",
|
|
235
|
+
stability: StabilityEnum.Stable,
|
|
236
|
+
owners: ["@contractspec.libs.jobs"],
|
|
237
|
+
tags: ["job-queue", "lifecycle"]
|
|
238
|
+
},
|
|
239
|
+
payload: JobStartedPayload
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* Emitted when a job completes successfully.
|
|
243
|
+
*/
|
|
244
|
+
const JobCompletedEvent = defineEvent({
|
|
245
|
+
meta: {
|
|
246
|
+
key: "job.completed",
|
|
247
|
+
version: 1,
|
|
248
|
+
description: "A job has completed successfully.",
|
|
249
|
+
stability: StabilityEnum.Stable,
|
|
250
|
+
owners: ["@contractspec.libs.jobs"],
|
|
251
|
+
tags: ["job-queue", "lifecycle"]
|
|
252
|
+
},
|
|
253
|
+
payload: JobCompletedPayload
|
|
254
|
+
});
|
|
255
|
+
/**
|
|
256
|
+
* Emitted when a job fails (single attempt).
|
|
257
|
+
*/
|
|
258
|
+
const JobFailedEvent = defineEvent({
|
|
259
|
+
meta: {
|
|
260
|
+
key: "job.failed",
|
|
261
|
+
version: 1,
|
|
262
|
+
description: "A job attempt has failed.",
|
|
263
|
+
stability: StabilityEnum.Stable,
|
|
264
|
+
owners: ["@contractspec.libs.jobs"],
|
|
265
|
+
tags: [
|
|
266
|
+
"job-queue",
|
|
267
|
+
"lifecycle",
|
|
268
|
+
"error"
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
payload: JobFailedPayload
|
|
272
|
+
});
|
|
273
|
+
/**
|
|
274
|
+
* Emitted when a job is being retried.
|
|
275
|
+
*/
|
|
276
|
+
const JobRetryingEvent = defineEvent({
|
|
277
|
+
meta: {
|
|
278
|
+
key: "job.retrying",
|
|
279
|
+
version: 1,
|
|
280
|
+
description: "A job is being scheduled for retry.",
|
|
281
|
+
stability: StabilityEnum.Stable,
|
|
282
|
+
owners: ["@contractspec.libs.jobs"],
|
|
283
|
+
tags: [
|
|
284
|
+
"job-queue",
|
|
285
|
+
"lifecycle",
|
|
286
|
+
"retry"
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
payload: JobRetryingPayload
|
|
290
|
+
});
|
|
291
|
+
/**
|
|
292
|
+
* Emitted when a job is moved to dead letter queue.
|
|
293
|
+
*/
|
|
294
|
+
const JobDeadLetteredEvent = defineEvent({
|
|
295
|
+
meta: {
|
|
296
|
+
key: "job.dead_lettered",
|
|
297
|
+
version: 1,
|
|
298
|
+
description: "A job has exhausted all retries and moved to dead letter queue.",
|
|
299
|
+
stability: StabilityEnum.Stable,
|
|
300
|
+
owners: ["@contractspec.libs.jobs"],
|
|
301
|
+
tags: [
|
|
302
|
+
"job-queue",
|
|
303
|
+
"lifecycle",
|
|
304
|
+
"error"
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
payload: JobDeadLetteredPayload
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* Emitted when a job is cancelled.
|
|
311
|
+
*/
|
|
312
|
+
const JobCancelledEvent = defineEvent({
|
|
313
|
+
meta: {
|
|
314
|
+
key: "job.cancelled",
|
|
315
|
+
version: 1,
|
|
316
|
+
description: "A job has been cancelled.",
|
|
317
|
+
stability: StabilityEnum.Stable,
|
|
318
|
+
owners: ["@contractspec.libs.jobs"],
|
|
319
|
+
tags: ["job-queue", "lifecycle"]
|
|
320
|
+
},
|
|
321
|
+
payload: JobCancelledPayload
|
|
322
|
+
});
|
|
323
|
+
/**
|
|
324
|
+
* Emitted when a scheduled job is triggered.
|
|
325
|
+
*/
|
|
326
|
+
const ScheduledJobTriggeredEvent = defineEvent({
|
|
327
|
+
meta: {
|
|
328
|
+
key: "scheduler.job_triggered",
|
|
329
|
+
version: 1,
|
|
330
|
+
description: "A scheduled job has been triggered.",
|
|
331
|
+
stability: StabilityEnum.Stable,
|
|
332
|
+
owners: ["@contractspec.libs.jobs"],
|
|
333
|
+
tags: ["job-queue", "scheduler"]
|
|
334
|
+
},
|
|
335
|
+
payload: ScheduledJobTriggeredPayload
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* All job events.
|
|
339
|
+
*/
|
|
340
|
+
const JobEvents = {
|
|
341
|
+
JobEnqueuedEvent,
|
|
342
|
+
JobStartedEvent,
|
|
343
|
+
JobCompletedEvent,
|
|
344
|
+
JobFailedEvent,
|
|
345
|
+
JobRetryingEvent,
|
|
346
|
+
JobDeadLetteredEvent,
|
|
347
|
+
JobCancelledEvent,
|
|
348
|
+
ScheduledJobTriggeredEvent
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
//#endregion
|
|
352
|
+
export { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent };
|
|
353
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineEvent, StabilityEnum } from '@contractspec/lib.contracts';\n\n// ============ Event Payloads ============\n\nconst JobEnqueuedPayload = defineSchemaModel({\n name: 'JobEnqueuedEventPayload',\n description: 'Payload when a job is added to the queue',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n tenantId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n enqueuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst JobStartedPayload = defineSchemaModel({\n name: 'JobStartedEventPayload',\n description: 'Payload when a job starts processing',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n attempt: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst JobCompletedPayload = defineSchemaModel({\n name: 'JobCompletedEventPayload',\n description: 'Payload when a job completes successfully',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n attempt: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst JobFailedPayload = defineSchemaModel({\n name: 'JobFailedEventPayload',\n description: 'Payload when a job attempt fails',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n attempt: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n error: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n willRetry: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n failedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst JobRetryingPayload = defineSchemaModel({\n name: 'JobRetryingEventPayload',\n description: 'Payload when a job is scheduled for retry',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n attempt: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n nextAttemptAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n backoffMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst JobDeadLetteredPayload = defineSchemaModel({\n name: 'JobDeadLetteredEventPayload',\n description: 'Payload when a job is moved to dead letter queue',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n attempts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n lastError: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n deadLetteredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst JobCancelledPayload = defineSchemaModel({\n name: 'JobCancelledEventPayload',\n description: 'Payload when a job is cancelled',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n cancelledBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n cancelledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ScheduledJobTriggeredPayload = defineSchemaModel({\n name: 'ScheduledJobTriggeredEventPayload',\n description: 'Payload when a scheduled job is triggered',\n fields: {\n scheduleName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n nextRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n },\n});\n\n// ============ Events ============\n\n/**\n * Emitted when a job is enqueued.\n */\nexport const JobEnqueuedEvent = defineEvent({\n meta: {\n key: 'job.enqueued',\n version: 1,\n description: 'A job has been added to the queue.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle'],\n },\n payload: JobEnqueuedPayload,\n});\n\n/**\n * Emitted when a job starts processing.\n */\nexport const JobStartedEvent = defineEvent({\n meta: {\n key: 'job.started',\n version: 1,\n description: 'A job has started processing.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle'],\n },\n payload: JobStartedPayload,\n});\n\n/**\n * Emitted when a job completes successfully.\n */\nexport const JobCompletedEvent = defineEvent({\n meta: {\n key: 'job.completed',\n version: 1,\n description: 'A job has completed successfully.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle'],\n },\n payload: JobCompletedPayload,\n});\n\n/**\n * Emitted when a job fails (single attempt).\n */\nexport const JobFailedEvent = defineEvent({\n meta: {\n key: 'job.failed',\n version: 1,\n description: 'A job attempt has failed.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle', 'error'],\n },\n payload: JobFailedPayload,\n});\n\n/**\n * Emitted when a job is being retried.\n */\nexport const JobRetryingEvent = defineEvent({\n meta: {\n key: 'job.retrying',\n version: 1,\n description: 'A job is being scheduled for retry.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle', 'retry'],\n },\n payload: JobRetryingPayload,\n});\n\n/**\n * Emitted when a job is moved to dead letter queue.\n */\nexport const JobDeadLetteredEvent = defineEvent({\n meta: {\n key: 'job.dead_lettered',\n version: 1,\n description:\n 'A job has exhausted all retries and moved to dead letter queue.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle', 'error'],\n },\n payload: JobDeadLetteredPayload,\n});\n\n/**\n * Emitted when a job is cancelled.\n */\nexport const JobCancelledEvent = defineEvent({\n meta: {\n key: 'job.cancelled',\n version: 1,\n description: 'A job has been cancelled.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'lifecycle'],\n },\n payload: JobCancelledPayload,\n});\n\n/**\n * Emitted when a scheduled job is triggered.\n */\nexport const ScheduledJobTriggeredEvent = defineEvent({\n meta: {\n key: 'scheduler.job_triggered',\n version: 1,\n description: 'A scheduled job has been triggered.',\n stability: StabilityEnum.Stable,\n owners: ['@contractspec.libs.jobs'],\n tags: ['job-queue', 'scheduler'],\n },\n payload: ScheduledJobTriggeredPayload,\n});\n\n/**\n * All job events.\n */\nexport const JobEvents = {\n JobEnqueuedEvent,\n JobStartedEvent,\n JobCompletedEvent,\n JobFailedEvent,\n JobRetryingEvent,\n JobDeadLetteredEvent,\n JobCancelledEvent,\n ScheduledJobTriggeredEvent,\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JobHandler } from "@contractspec/lib.contracts/jobs/queue";
|
|
2
|
+
import { GmailIngestionAdapter } from "@contractspec/lib.knowledge/ingestion/gmail-adapter";
|
|
3
|
+
import { EmailThreadListQuery } from "@contractspec/lib.contracts/integrations/providers/email";
|
|
4
|
+
|
|
5
|
+
//#region src/handlers/gmail-sync-handler.d.ts
|
|
6
|
+
type GmailSyncJobPayload = EmailThreadListQuery;
|
|
7
|
+
declare function createGmailSyncHandler(adapter: GmailIngestionAdapter): JobHandler<GmailSyncJobPayload>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { GmailSyncJobPayload, createGmailSyncHandler };
|
|
10
|
+
//# sourceMappingURL=gmail-sync-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gmail-sync-handler.d.ts","names":[],"sources":["../../src/handlers/gmail-sync-handler.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,mBAAA,GAAsB;iBAElB,sBAAA,UACL,wBACR,WAAW"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/handlers/gmail-sync-handler.ts
|
|
2
|
+
function createGmailSyncHandler(adapter) {
|
|
3
|
+
return async (job) => {
|
|
4
|
+
await adapter.syncThreads(job.payload);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createGmailSyncHandler };
|
|
10
|
+
//# sourceMappingURL=gmail-sync-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gmail-sync-handler.js","names":[],"sources":["../../src/handlers/gmail-sync-handler.ts"],"sourcesContent":["import type { JobHandler } from '@contractspec/lib.contracts/jobs/queue';\nimport type { GmailIngestionAdapter } from '@contractspec/lib.knowledge/ingestion/gmail-adapter';\nimport type { EmailThreadListQuery } from '@contractspec/lib.contracts/integrations/providers/email';\n\nexport type GmailSyncJobPayload = EmailThreadListQuery;\n\nexport function createGmailSyncHandler(\n adapter: GmailIngestionAdapter\n): JobHandler<GmailSyncJobPayload> {\n return async (job) => {\n await adapter.syncThreads(job.payload);\n };\n}\n"],"mappings":";AAMA,SAAgB,uBACd,SACiC;AACjC,QAAO,OAAO,QAAQ;AACpB,QAAM,QAAQ,YAAY,IAAI,QAAQ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GmailSyncJobPayload, createGmailSyncHandler } from "./gmail-sync-handler.js";
|
|
2
|
+
import { PING_JOB_TYPE, PingPayload, PingPayloadSchema, pingJob } from "./ping-job.js";
|
|
3
|
+
import { StorageDocumentJobPayload, createStorageDocumentHandler } from "./storage-document-handler.js";
|
|
4
|
+
import { JobQueue } from "@contractspec/lib.contracts/jobs/queue";
|
|
5
|
+
|
|
6
|
+
//#region src/handlers/index.d.ts
|
|
7
|
+
declare function registerAllJobs(queue: JobQueue): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { GmailSyncJobPayload, PING_JOB_TYPE, PingPayload, PingPayloadSchema, StorageDocumentJobPayload, createGmailSyncHandler, createStorageDocumentHandler, pingJob, registerAllJobs };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/handlers/index.ts"],"sourcesContent":[],"mappings":";;;;;;iBAUgB,eAAA,QAAuB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { registerDefinedJob } from "../queue/register-defined-job.js";
|
|
2
|
+
import { PING_JOB_TYPE, PingPayloadSchema, pingJob } from "./ping-job.js";
|
|
3
|
+
import { createGmailSyncHandler } from "./gmail-sync-handler.js";
|
|
4
|
+
import { createStorageDocumentHandler } from "./storage-document-handler.js";
|
|
5
|
+
|
|
6
|
+
//#region src/handlers/index.ts
|
|
7
|
+
function registerAllJobs(queue) {
|
|
8
|
+
registerDefinedJob(queue, pingJob);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PING_JOB_TYPE, PingPayloadSchema, createGmailSyncHandler, createStorageDocumentHandler, pingJob, registerAllJobs };
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/handlers/index.ts"],"sourcesContent":["export * from './ping-job';\nexport * from './gmail-sync-handler';\nexport * from './storage-document-handler';\nimport type { JobQueue } from '@contractspec/lib.contracts/jobs/queue';\nimport { registerDefinedJob } from '../queue/register-defined-job';\n\nimport { pingJob } from './ping-job';\n// import { equityaRecomputePlanJob } from './types/equitya.recompute-plan';\n// import { artisanosGenerateQuoteJob } from './types/artisanos.generate-quote';\n\nexport function registerAllJobs(queue: JobQueue): void {\n registerDefinedJob(queue, pingJob);\n // registerDefinedJob(queue, equityaRecomputePlanJob);\n // registerDefinedJob(queue, artisanosGenerateQuoteJob);\n}\n"],"mappings":";;;;;;AAUA,SAAgB,gBAAgB,OAAuB;AACrD,oBAAmB,OAAO,QAAQ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { DefinedJob } from "@contractspec/lib.contracts/jobs/define-job";
|
|
3
|
+
|
|
4
|
+
//#region src/handlers/ping-job.d.ts
|
|
5
|
+
declare const PING_JOB_TYPE: "core.ping";
|
|
6
|
+
declare const PingPayloadSchema: z.ZodObject<{}, z.core.$strip>;
|
|
7
|
+
type PingPayload = z.infer<typeof PingPayloadSchema>;
|
|
8
|
+
declare const pingJob: DefinedJob<PingPayload>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PING_JOB_TYPE, PingPayload, PingPayloadSchema, pingJob };
|
|
11
|
+
//# sourceMappingURL=ping-job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-job.d.ts","names":[],"sources":["../../src/handlers/ping-job.ts"],"sourcesContent":[],"mappings":";;;;cAIa;cAEA,mBAAiB,CAAA,CAAA,cAAA,CAAA,CAAA,IAAA,CAAA;AAFjB,KAID,WAAA,GAAc,CAAA,CAAE,KAJqB,CAAA,OAIR,iBAJQ,CAAA;AAEpC,cAIA,OAJgC,EAIvB,UAJQ,CAIG,WAJH,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/handlers/ping-job.ts
|
|
4
|
+
const PING_JOB_TYPE = "core.ping";
|
|
5
|
+
const PingPayloadSchema = z.object({});
|
|
6
|
+
const pingJob = {
|
|
7
|
+
type: PING_JOB_TYPE,
|
|
8
|
+
schema: PingPayloadSchema,
|
|
9
|
+
handler: async (_payload, _job) => {}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { PING_JOB_TYPE, PingPayloadSchema, pingJob };
|
|
14
|
+
//# sourceMappingURL=ping-job.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-job.js","names":["pingJob: DefinedJob<PingPayload>"],"sources":["../../src/handlers/ping-job.ts"],"sourcesContent":["import * as z from 'zod';\nimport type { DefinedJob } from '@contractspec/lib.contracts/jobs/define-job';\nimport type { Job } from '@contractspec/lib.contracts/jobs/queue';\n\nexport const PING_JOB_TYPE = 'core.ping' as const;\n\nexport const PingPayloadSchema = z.object({});\n\nexport type PingPayload = z.infer<typeof PingPayloadSchema>;\n\nexport const pingJob: DefinedJob<PingPayload> = {\n type: PING_JOB_TYPE,\n schema: PingPayloadSchema,\n handler: async (_payload: PingPayload, _job: Job<PingPayload>) => {\n /* noop - ping job has no operation */\n },\n};\n"],"mappings":";;;AAIA,MAAa,gBAAgB;AAE7B,MAAa,oBAAoB,EAAE,OAAO,EAAE,CAAC;AAI7C,MAAaA,UAAmC;CAC9C,MAAM;CACN,QAAQ;CACR,SAAS,OAAO,UAAuB,SAA2B;CAGnE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JobHandler } from "@contractspec/lib.contracts/jobs/queue";
|
|
2
|
+
import { ObjectStorageProvider } from "@contractspec/lib.contracts/integrations/providers/storage";
|
|
3
|
+
import { StorageIngestionAdapter } from "@contractspec/lib.knowledge/ingestion/storage-adapter";
|
|
4
|
+
|
|
5
|
+
//#region src/handlers/storage-document-handler.d.ts
|
|
6
|
+
interface StorageDocumentJobPayload {
|
|
7
|
+
bucket: string;
|
|
8
|
+
key: string;
|
|
9
|
+
}
|
|
10
|
+
declare function createStorageDocumentHandler(storage: ObjectStorageProvider, adapter: StorageIngestionAdapter): JobHandler<StorageDocumentJobPayload>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { StorageDocumentJobPayload, createStorageDocumentHandler };
|
|
13
|
+
//# sourceMappingURL=storage-document-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-document-handler.d.ts","names":[],"sources":["../../src/handlers/storage-document-handler.ts"],"sourcesContent":[],"mappings":";;;;;UAIiB,yBAAA;;EAAA,GAAA,EAAA,MAAA;AAKjB;AACW,iBADK,4BAAA,CACL,OAAA,EAAA,qBAAA,EAAA,OAAA,EACA,uBADA,CAAA,EAER,UAFQ,CAEG,yBAFH,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/handlers/storage-document-handler.ts
|
|
2
|
+
function createStorageDocumentHandler(storage, adapter) {
|
|
3
|
+
return async (job) => {
|
|
4
|
+
const object = await storage.getObject({
|
|
5
|
+
bucket: job.payload.bucket,
|
|
6
|
+
key: job.payload.key
|
|
7
|
+
});
|
|
8
|
+
if (!object) throw new Error(`Object ${job.payload.bucket}/${job.payload.key} not found`);
|
|
9
|
+
await adapter.ingestObject(object);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createStorageDocumentHandler };
|
|
15
|
+
//# sourceMappingURL=storage-document-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-document-handler.js","names":[],"sources":["../../src/handlers/storage-document-handler.ts"],"sourcesContent":["import type { ObjectStorageProvider } from '@contractspec/lib.contracts/integrations/providers/storage';\nimport type { StorageIngestionAdapter } from '@contractspec/lib.knowledge/ingestion/storage-adapter';\nimport type { JobHandler } from '@contractspec/lib.contracts/jobs/queue';\n\nexport interface StorageDocumentJobPayload {\n bucket: string;\n key: string;\n}\n\nexport function createStorageDocumentHandler(\n storage: ObjectStorageProvider,\n adapter: StorageIngestionAdapter\n): JobHandler<StorageDocumentJobPayload> {\n return async (job) => {\n const object = await storage.getObject({\n bucket: job.payload.bucket,\n key: job.payload.key,\n });\n if (!object) {\n throw new Error(\n `Object ${job.payload.bucket}/${job.payload.key} not found`\n );\n }\n await adapter.ingestObject(object);\n };\n}\n"],"mappings":";AASA,SAAgB,6BACd,SACA,SACuC;AACvC,QAAO,OAAO,QAAQ;EACpB,MAAM,SAAS,MAAM,QAAQ,UAAU;GACrC,QAAQ,IAAI,QAAQ;GACpB,KAAK,IAAI,QAAQ;GAClB,CAAC;AACF,MAAI,CAAC,OACH,OAAM,IAAI,MACR,UAAU,IAAI,QAAQ,OAAO,GAAG,IAAI,QAAQ,IAAI,YACjD;AAEH,QAAM,QAAQ,aAAa,OAAO"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __exportAll, __reExport } from "./_virtual/rolldown_runtime.js";
|
|
2
|
+
import { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GetJobContract, GetQueueStatsContract, JobModel, ListScheduledJobsContract, QueueStatsModel, ScheduledJobModel, ToggleScheduledJobContract } from "./contracts/index.js";
|
|
3
|
+
import { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution } from "./entities/index.js";
|
|
4
|
+
import { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent } from "./events.js";
|
|
5
|
+
import { GmailSyncJobPayload, createGmailSyncHandler } from "./handlers/gmail-sync-handler.js";
|
|
6
|
+
import { PING_JOB_TYPE, PingPayload, PingPayloadSchema, pingJob } from "./handlers/ping-job.js";
|
|
7
|
+
import { StorageDocumentJobPayload, createStorageDocumentHandler } from "./handlers/storage-document-handler.js";
|
|
8
|
+
import { registerAllJobs } from "./handlers/index.js";
|
|
9
|
+
import { MemoryJobQueue, MemoryQueueOptions } from "./queue/memory-queue.js";
|
|
10
|
+
import { ScalewaySqsJobQueue, ScalewaySqsQueueConfig, ScalewaySqsQueueCredentials } from "./queue/scaleway-sqs-queue.js";
|
|
11
|
+
import { GcpCloudTasksQueue, GcpCloudTasksQueueOptions } from "./queue/gcp-cloud-tasks.js";
|
|
12
|
+
import { GcpPubSubQueue, GcpPubSubQueueOptions } from "./queue/gcp-pubsub.js";
|
|
13
|
+
import { registerDefinedJob } from "./queue/register-defined-job.js";
|
|
14
|
+
import { index_d_exports as index_d_exports$1 } from "./queue/index.js";
|
|
15
|
+
import { ActiveSchedule, JobScheduler, ScheduledJobConfig, createScheduler, defineSchedule } from "./scheduler/index.js";
|
|
16
|
+
import { JobsFeature } from "./jobs.feature.js";
|
|
17
|
+
export * from "@contractspec/lib.contracts/jobs/queue";
|
|
18
|
+
|
|
19
|
+
//#region src/index.d.ts
|
|
20
|
+
declare namespace index_d_exports {
|
|
21
|
+
export { ActiveSchedule, CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GcpCloudTasksQueue, GcpCloudTasksQueueOptions, GcpPubSubQueue, GcpPubSubQueueOptions, GetJobContract, GetQueueStatsContract, GmailSyncJobPayload, JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEntity, JobEvents, JobExecutionEntity, JobFailedEvent, JobModel, JobRetryingEvent, JobScheduler, JobStartedEvent, JobStatusEnum, JobsFeature, ListScheduledJobsContract, MemoryJobQueue, MemoryQueueOptions, PING_JOB_TYPE, PingPayload, PingPayloadSchema, QueueStatsModel, ScalewaySqsJobQueue, ScalewaySqsQueueConfig, ScalewaySqsQueueCredentials, ScheduledJobConfig, ScheduledJobEntity, ScheduledJobModel, ScheduledJobTriggeredEvent, StorageDocumentJobPayload, ToggleScheduledJobContract, createGmailSyncHandler, createScheduler, createStorageDocumentHandler, defineSchedule, jobEntities, jobsSchemaContribution, pingJob, registerAllJobs, registerDefinedJob };
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ActiveSchedule, CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GcpCloudTasksQueue, GcpCloudTasksQueueOptions, GcpPubSubQueue, GcpPubSubQueueOptions, GetJobContract, GetQueueStatsContract, GmailSyncJobPayload, JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEntity, JobEvents, JobExecutionEntity, JobFailedEvent, JobModel, JobRetryingEvent, JobScheduler, JobStartedEvent, JobStatusEnum, JobsFeature, ListScheduledJobsContract, MemoryJobQueue, MemoryQueueOptions, PING_JOB_TYPE, PingPayload, PingPayloadSchema, QueueStatsModel, ScalewaySqsJobQueue, ScalewaySqsQueueConfig, ScalewaySqsQueueCredentials, ScheduledJobConfig, ScheduledJobEntity, ScheduledJobModel, ScheduledJobTriggeredEvent, StorageDocumentJobPayload, ToggleScheduledJobContract, createGmailSyncHandler, createScheduler, createStorageDocumentHandler, defineSchedule, jobEntities, jobsSchemaContribution, pingJob, registerAllJobs, registerDefinedJob };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { __exportAll, __reExport } from "./_virtual/rolldown_runtime.js";
|
|
2
|
+
import { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent } from "./events.js";
|
|
3
|
+
import { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution } from "./entities/index.js";
|
|
4
|
+
import { MemoryJobQueue } from "./queue/memory-queue.js";
|
|
5
|
+
import { ScalewaySqsJobQueue } from "./queue/scaleway-sqs-queue.js";
|
|
6
|
+
import { GcpCloudTasksQueue } from "./queue/gcp-cloud-tasks.js";
|
|
7
|
+
import { GcpPubSubQueue } from "./queue/gcp-pubsub.js";
|
|
8
|
+
import { registerDefinedJob } from "./queue/register-defined-job.js";
|
|
9
|
+
import { queue_exports } from "./queue/index.js";
|
|
10
|
+
import { PING_JOB_TYPE, PingPayloadSchema, pingJob } from "./handlers/ping-job.js";
|
|
11
|
+
import { createGmailSyncHandler } from "./handlers/gmail-sync-handler.js";
|
|
12
|
+
import { createStorageDocumentHandler } from "./handlers/storage-document-handler.js";
|
|
13
|
+
import { registerAllJobs } from "./handlers/index.js";
|
|
14
|
+
import { JobScheduler, createScheduler, defineSchedule } from "./scheduler/index.js";
|
|
15
|
+
import { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GetJobContract, GetQueueStatsContract, JobModel, ListScheduledJobsContract, QueueStatsModel, ScheduledJobModel, ToggleScheduledJobContract } from "./contracts/index.js";
|
|
16
|
+
import { JobsFeature } from "./jobs.feature.js";
|
|
17
|
+
|
|
18
|
+
export * from "@contractspec/lib.contracts/jobs/queue"
|
|
19
|
+
|
|
20
|
+
//#region src/index.ts
|
|
21
|
+
var src_exports = /* @__PURE__ */ __exportAll({
|
|
22
|
+
CancelJobContract: () => CancelJobContract,
|
|
23
|
+
CreateScheduledJobContract: () => CreateScheduledJobContract,
|
|
24
|
+
EnqueueJobContract: () => EnqueueJobContract,
|
|
25
|
+
GcpCloudTasksQueue: () => GcpCloudTasksQueue,
|
|
26
|
+
GcpPubSubQueue: () => GcpPubSubQueue,
|
|
27
|
+
GetJobContract: () => GetJobContract,
|
|
28
|
+
GetQueueStatsContract: () => GetQueueStatsContract,
|
|
29
|
+
JobCancelledEvent: () => JobCancelledEvent,
|
|
30
|
+
JobCompletedEvent: () => JobCompletedEvent,
|
|
31
|
+
JobDeadLetteredEvent: () => JobDeadLetteredEvent,
|
|
32
|
+
JobEnqueuedEvent: () => JobEnqueuedEvent,
|
|
33
|
+
JobEntity: () => JobEntity,
|
|
34
|
+
JobEvents: () => JobEvents,
|
|
35
|
+
JobExecutionEntity: () => JobExecutionEntity,
|
|
36
|
+
JobFailedEvent: () => JobFailedEvent,
|
|
37
|
+
JobModel: () => JobModel,
|
|
38
|
+
JobRetryingEvent: () => JobRetryingEvent,
|
|
39
|
+
JobScheduler: () => JobScheduler,
|
|
40
|
+
JobStartedEvent: () => JobStartedEvent,
|
|
41
|
+
JobStatusEnum: () => JobStatusEnum,
|
|
42
|
+
JobsFeature: () => JobsFeature,
|
|
43
|
+
ListScheduledJobsContract: () => ListScheduledJobsContract,
|
|
44
|
+
MemoryJobQueue: () => MemoryJobQueue,
|
|
45
|
+
PING_JOB_TYPE: () => PING_JOB_TYPE,
|
|
46
|
+
PingPayloadSchema: () => PingPayloadSchema,
|
|
47
|
+
QueueStatsModel: () => QueueStatsModel,
|
|
48
|
+
ScalewaySqsJobQueue: () => ScalewaySqsJobQueue,
|
|
49
|
+
ScheduledJobEntity: () => ScheduledJobEntity,
|
|
50
|
+
ScheduledJobModel: () => ScheduledJobModel,
|
|
51
|
+
ScheduledJobTriggeredEvent: () => ScheduledJobTriggeredEvent,
|
|
52
|
+
ToggleScheduledJobContract: () => ToggleScheduledJobContract,
|
|
53
|
+
createGmailSyncHandler: () => createGmailSyncHandler,
|
|
54
|
+
createScheduler: () => createScheduler,
|
|
55
|
+
createStorageDocumentHandler: () => createStorageDocumentHandler,
|
|
56
|
+
defineSchedule: () => defineSchedule,
|
|
57
|
+
jobEntities: () => jobEntities,
|
|
58
|
+
jobsSchemaContribution: () => jobsSchemaContribution,
|
|
59
|
+
pingJob: () => pingJob,
|
|
60
|
+
registerAllJobs: () => registerAllJobs,
|
|
61
|
+
registerDefinedJob: () => registerDefinedJob
|
|
62
|
+
});
|
|
63
|
+
__reExport(src_exports, queue_exports);
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GcpCloudTasksQueue, GcpPubSubQueue, GetJobContract, GetQueueStatsContract, JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEntity, JobEvents, JobExecutionEntity, JobFailedEvent, JobModel, JobRetryingEvent, JobScheduler, JobStartedEvent, JobStatusEnum, JobsFeature, ListScheduledJobsContract, MemoryJobQueue, PING_JOB_TYPE, PingPayloadSchema, QueueStatsModel, ScalewaySqsJobQueue, ScheduledJobEntity, ScheduledJobModel, ScheduledJobTriggeredEvent, ToggleScheduledJobContract, createGmailSyncHandler, createScheduler, createStorageDocumentHandler, defineSchedule, jobEntities, jobsSchemaContribution, pingJob, registerAllJobs, registerDefinedJob };
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Entity definitions for schema generation\nexport * from './entities';\n\n// Queue implementations\nexport * from './queue';\n\n// Job handlers (runtime wiring)\nexport * from './handlers';\n\n// Scheduler\nexport * from './scheduler';\n\n// Contract specifications\nexport * from './contracts';\n\n// Domain events\nexport * from './events';\n\n// Feature module specification\nexport * from './jobs.feature';\n"],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FeatureModuleSpec } from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/jobs.feature.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Jobs feature module that bundles job queue management,
|
|
7
|
+
* background processing, and scheduled task capabilities.
|
|
8
|
+
*/
|
|
9
|
+
declare const JobsFeature: FeatureModuleSpec;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { JobsFeature };
|
|
12
|
+
//# sourceMappingURL=jobs.feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.feature.d.ts","names":[],"sources":["../src/jobs.feature.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAWa,aAAa"}
|