@contractspec/lib.jobs 1.57.0 → 1.59.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.
Files changed (92) hide show
  1. package/dist/contracts/index.d.ts +494 -500
  2. package/dist/contracts/index.d.ts.map +1 -1
  3. package/dist/contracts/index.js +298 -461
  4. package/dist/entities/index.d.ts +117 -122
  5. package/dist/entities/index.d.ts.map +1 -1
  6. package/dist/entities/index.js +170 -193
  7. package/dist/events.d.ts +297 -303
  8. package/dist/events.d.ts.map +1 -1
  9. package/dist/events.js +199 -351
  10. package/dist/handlers/gmail-sync-handler.d.ts +5 -9
  11. package/dist/handlers/gmail-sync-handler.d.ts.map +1 -1
  12. package/dist/handlers/gmail-sync-handler.js +8 -8
  13. package/dist/handlers/index.d.ts +5 -9
  14. package/dist/handlers/index.d.ts.map +1 -1
  15. package/dist/handlers/index.js +53 -10
  16. package/dist/handlers/ping-job.d.ts +6 -10
  17. package/dist/handlers/ping-job.d.ts.map +1 -1
  18. package/dist/handlers/ping-job.js +13 -12
  19. package/dist/handlers/storage-document-handler.d.ts +7 -11
  20. package/dist/handlers/storage-document-handler.d.ts.map +1 -1
  21. package/dist/handlers/storage-document-handler.js +15 -13
  22. package/dist/index.d.ts +7 -24
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1366 -64
  25. package/dist/jobs.capability.d.ts +2 -7
  26. package/dist/jobs.capability.d.ts.map +1 -1
  27. package/dist/jobs.capability.js +29 -33
  28. package/dist/jobs.feature.d.ts +1 -6
  29. package/dist/jobs.feature.d.ts.map +1 -1
  30. package/dist/jobs.feature.js +45 -108
  31. package/dist/node/contracts/index.js +318 -0
  32. package/dist/node/entities/index.js +174 -0
  33. package/dist/node/events.js +200 -0
  34. package/dist/node/handlers/gmail-sync-handler.js +9 -0
  35. package/dist/node/handlers/index.js +55 -0
  36. package/dist/node/handlers/ping-job.js +14 -0
  37. package/dist/node/handlers/storage-document-handler.js +16 -0
  38. package/dist/node/index.js +1368 -0
  39. package/dist/node/jobs.capability.js +28 -0
  40. package/dist/node/jobs.feature.js +46 -0
  41. package/dist/node/queue/gcp-cloud-tasks.js +66 -0
  42. package/dist/node/queue/gcp-pubsub.js +54 -0
  43. package/dist/node/queue/index.js +478 -0
  44. package/dist/node/queue/memory-queue.js +160 -0
  45. package/dist/node/queue/register-defined-job.js +15 -0
  46. package/dist/node/queue/scaleway-sqs-queue.js +206 -0
  47. package/dist/node/queue/types.js +10 -0
  48. package/dist/node/scheduler/index.js +117 -0
  49. package/dist/queue/gcp-cloud-tasks.d.ts +33 -36
  50. package/dist/queue/gcp-cloud-tasks.d.ts.map +1 -1
  51. package/dist/queue/gcp-cloud-tasks.js +65 -59
  52. package/dist/queue/gcp-pubsub.d.ts +18 -21
  53. package/dist/queue/gcp-pubsub.d.ts.map +1 -1
  54. package/dist/queue/gcp-pubsub.js +53 -45
  55. package/dist/queue/index.d.ts +6 -15
  56. package/dist/queue/index.d.ts.map +1 -1
  57. package/dist/queue/index.js +476 -20
  58. package/dist/queue/memory-queue.d.ts +25 -29
  59. package/dist/queue/memory-queue.d.ts.map +1 -1
  60. package/dist/queue/memory-queue.js +159 -138
  61. package/dist/queue/register-defined-job.d.ts +3 -7
  62. package/dist/queue/register-defined-job.d.ts.map +1 -1
  63. package/dist/queue/register-defined-job.js +14 -14
  64. package/dist/queue/scaleway-sqs-queue.d.ts +31 -35
  65. package/dist/queue/scaleway-sqs-queue.d.ts.map +1 -1
  66. package/dist/queue/scaleway-sqs-queue.js +205 -173
  67. package/dist/queue/types.d.ts +2 -8
  68. package/dist/queue/types.d.ts.map +1 -1
  69. package/dist/queue/types.js +11 -12
  70. package/dist/scheduler/index.d.ts +68 -72
  71. package/dist/scheduler/index.d.ts.map +1 -1
  72. package/dist/scheduler/index.js +113 -141
  73. package/package.json +176 -50
  74. package/dist/_virtual/_rolldown/runtime.js +0 -36
  75. package/dist/contracts/index.js.map +0 -1
  76. package/dist/entities/index.js.map +0 -1
  77. package/dist/events.js.map +0 -1
  78. package/dist/handlers/gmail-sync-handler.js.map +0 -1
  79. package/dist/handlers/index.js.map +0 -1
  80. package/dist/handlers/ping-job.js.map +0 -1
  81. package/dist/handlers/storage-document-handler.js.map +0 -1
  82. package/dist/index.js.map +0 -1
  83. package/dist/jobs.capability.js.map +0 -1
  84. package/dist/jobs.feature.js.map +0 -1
  85. package/dist/queue/gcp-cloud-tasks.js.map +0 -1
  86. package/dist/queue/gcp-pubsub.js.map +0 -1
  87. package/dist/queue/index.js.map +0 -1
  88. package/dist/queue/memory-queue.js.map +0 -1
  89. package/dist/queue/register-defined-job.js.map +0 -1
  90. package/dist/queue/scaleway-sqs-queue.js.map +0 -1
  91. package/dist/queue/types.js.map +0 -1
  92. package/dist/scheduler/index.js.map +0 -1
@@ -1,482 +1,319 @@
1
+ // @bun
2
+ // src/contracts/index.ts
1
3
  import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
2
4
  import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
3
-
4
- //#region src/contracts/index.ts
5
- const OWNERS = ["platform.jobs"];
6
- const JobModel = defineSchemaModel({
7
- name: "Job",
8
- description: "Represents a background job",
9
- fields: {
10
- id: {
11
- type: ScalarTypeEnum.String_unsecure(),
12
- isOptional: false
13
- },
14
- type: {
15
- type: ScalarTypeEnum.String_unsecure(),
16
- isOptional: false
17
- },
18
- version: {
19
- type: ScalarTypeEnum.String_unsecure(),
20
- isOptional: false
21
- },
22
- payload: {
23
- type: ScalarTypeEnum.JSON(),
24
- isOptional: false
25
- },
26
- status: {
27
- type: ScalarTypeEnum.String_unsecure(),
28
- isOptional: false
29
- },
30
- priority: {
31
- type: ScalarTypeEnum.Int_unsecure(),
32
- isOptional: false
33
- },
34
- attempts: {
35
- type: ScalarTypeEnum.Int_unsecure(),
36
- isOptional: false
37
- },
38
- maxRetries: {
39
- type: ScalarTypeEnum.Int_unsecure(),
40
- isOptional: false
41
- },
42
- createdAt: {
43
- type: ScalarTypeEnum.DateTime(),
44
- isOptional: false
45
- },
46
- updatedAt: {
47
- type: ScalarTypeEnum.DateTime(),
48
- isOptional: false
49
- },
50
- scheduledAt: {
51
- type: ScalarTypeEnum.DateTime(),
52
- isOptional: true
53
- },
54
- startedAt: {
55
- type: ScalarTypeEnum.DateTime(),
56
- isOptional: true
57
- },
58
- completedAt: {
59
- type: ScalarTypeEnum.DateTime(),
60
- isOptional: true
61
- },
62
- lastError: {
63
- type: ScalarTypeEnum.String_unsecure(),
64
- isOptional: true
65
- }
66
- }
5
+ var OWNERS = ["platform.jobs"];
6
+ var JobModel = defineSchemaModel({
7
+ name: "Job",
8
+ description: "Represents a background job",
9
+ fields: {
10
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ payload: { type: ScalarTypeEnum.JSON(), isOptional: false },
14
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
15
+ priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
16
+ attempts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
17
+ maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
18
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
19
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
20
+ scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
21
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
22
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
23
+ lastError: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
24
+ }
67
25
  });
68
- const ScheduledJobModel = defineSchemaModel({
69
- name: "ScheduledJob",
70
- description: "Represents a scheduled/recurring job",
71
- fields: {
72
- id: {
73
- type: ScalarTypeEnum.String_unsecure(),
74
- isOptional: false
75
- },
76
- name: {
77
- type: ScalarTypeEnum.String_unsecure(),
78
- isOptional: false
79
- },
80
- description: {
81
- type: ScalarTypeEnum.String_unsecure(),
82
- isOptional: true
83
- },
84
- cronExpression: {
85
- type: ScalarTypeEnum.String_unsecure(),
86
- isOptional: false
87
- },
88
- timezone: {
89
- type: ScalarTypeEnum.String_unsecure(),
90
- isOptional: false
91
- },
92
- jobType: {
93
- type: ScalarTypeEnum.String_unsecure(),
94
- isOptional: false
95
- },
96
- enabled: {
97
- type: ScalarTypeEnum.Boolean(),
98
- isOptional: false
99
- },
100
- lastRunAt: {
101
- type: ScalarTypeEnum.DateTime(),
102
- isOptional: true
103
- },
104
- nextRunAt: {
105
- type: ScalarTypeEnum.DateTime(),
106
- isOptional: true
107
- },
108
- createdAt: {
109
- type: ScalarTypeEnum.DateTime(),
110
- isOptional: false
111
- }
112
- }
26
+ var ScheduledJobModel = defineSchemaModel({
27
+ name: "ScheduledJob",
28
+ description: "Represents a scheduled/recurring job",
29
+ fields: {
30
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
33
+ cronExpression: {
34
+ type: ScalarTypeEnum.String_unsecure(),
35
+ isOptional: false
36
+ },
37
+ timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
+ enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
40
+ lastRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
41
+ nextRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
42
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
43
+ }
113
44
  });
114
- const QueueStatsModel = defineSchemaModel({
115
- name: "QueueStats",
116
- description: "Job queue statistics",
117
- fields: {
118
- pending: {
119
- type: ScalarTypeEnum.Int_unsecure(),
120
- isOptional: false
121
- },
122
- running: {
123
- type: ScalarTypeEnum.Int_unsecure(),
124
- isOptional: false
125
- },
126
- completed: {
127
- type: ScalarTypeEnum.Int_unsecure(),
128
- isOptional: false
129
- },
130
- failed: {
131
- type: ScalarTypeEnum.Int_unsecure(),
132
- isOptional: false
133
- },
134
- deadLetter: {
135
- type: ScalarTypeEnum.Int_unsecure(),
136
- isOptional: false
137
- }
138
- }
45
+ var QueueStatsModel = defineSchemaModel({
46
+ name: "QueueStats",
47
+ description: "Job queue statistics",
48
+ fields: {
49
+ pending: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
50
+ running: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
51
+ completed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
52
+ failed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
53
+ deadLetter: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
54
+ }
139
55
  });
140
- const EnqueueJobInput = defineSchemaModel({
141
- name: "EnqueueJobInput",
142
- description: "Input for enqueuing a new job",
143
- fields: {
144
- type: {
145
- type: ScalarTypeEnum.String_unsecure(),
146
- isOptional: false
147
- },
148
- payload: {
149
- type: ScalarTypeEnum.JSON(),
150
- isOptional: false
151
- },
152
- delaySeconds: {
153
- type: ScalarTypeEnum.Int_unsecure(),
154
- isOptional: true
155
- },
156
- dedupeKey: {
157
- type: ScalarTypeEnum.String_unsecure(),
158
- isOptional: true
159
- },
160
- maxRetries: {
161
- type: ScalarTypeEnum.Int_unsecure(),
162
- isOptional: true
163
- },
164
- priority: {
165
- type: ScalarTypeEnum.Int_unsecure(),
166
- isOptional: true
167
- },
168
- timeoutMs: {
169
- type: ScalarTypeEnum.Int_unsecure(),
170
- isOptional: true
171
- }
172
- }
56
+ var EnqueueJobInput = defineSchemaModel({
57
+ name: "EnqueueJobInput",
58
+ description: "Input for enqueuing a new job",
59
+ fields: {
60
+ type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
61
+ payload: { type: ScalarTypeEnum.JSON(), isOptional: false },
62
+ delaySeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
63
+ dedupeKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
64
+ maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
65
+ priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
66
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
67
+ }
173
68
  });
174
- const GetJobInput = defineSchemaModel({
175
- name: "GetJobInput",
176
- description: "Input for getting a job by ID",
177
- fields: { jobId: {
178
- type: ScalarTypeEnum.String_unsecure(),
179
- isOptional: false
180
- } }
69
+ var GetJobInput = defineSchemaModel({
70
+ name: "GetJobInput",
71
+ description: "Input for getting a job by ID",
72
+ fields: {
73
+ jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
74
+ }
181
75
  });
182
- const CancelJobInput = defineSchemaModel({
183
- name: "CancelJobInput",
184
- description: "Input for cancelling a job",
185
- fields: { jobId: {
186
- type: ScalarTypeEnum.String_unsecure(),
187
- isOptional: false
188
- } }
76
+ var CancelJobInput = defineSchemaModel({
77
+ name: "CancelJobInput",
78
+ description: "Input for cancelling a job",
79
+ fields: {
80
+ jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
81
+ }
189
82
  });
190
- const CancelJobOutput = defineSchemaModel({
191
- name: "CancelJobOutput",
192
- description: "Output for cancel job operation",
193
- fields: { success: {
194
- type: ScalarTypeEnum.Boolean(),
195
- isOptional: false
196
- } }
83
+ var CancelJobOutput = defineSchemaModel({
84
+ name: "CancelJobOutput",
85
+ description: "Output for cancel job operation",
86
+ fields: {
87
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
88
+ }
197
89
  });
198
- const CreateScheduledJobInput = defineSchemaModel({
199
- name: "CreateScheduledJobInput",
200
- description: "Input for creating a scheduled job",
201
- fields: {
202
- name: {
203
- type: ScalarTypeEnum.String_unsecure(),
204
- isOptional: false
205
- },
206
- description: {
207
- type: ScalarTypeEnum.String_unsecure(),
208
- isOptional: true
209
- },
210
- cronExpression: {
211
- type: ScalarTypeEnum.String_unsecure(),
212
- isOptional: false
213
- },
214
- timezone: {
215
- type: ScalarTypeEnum.String_unsecure(),
216
- isOptional: true
217
- },
218
- jobType: {
219
- type: ScalarTypeEnum.String_unsecure(),
220
- isOptional: false
221
- },
222
- payload: {
223
- type: ScalarTypeEnum.JSON(),
224
- isOptional: true
225
- },
226
- maxRetries: {
227
- type: ScalarTypeEnum.Int_unsecure(),
228
- isOptional: true
229
- },
230
- enabled: {
231
- type: ScalarTypeEnum.Boolean(),
232
- isOptional: true
233
- }
234
- }
90
+ var CreateScheduledJobInput = defineSchemaModel({
91
+ name: "CreateScheduledJobInput",
92
+ description: "Input for creating a scheduled job",
93
+ fields: {
94
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
96
+ cronExpression: {
97
+ type: ScalarTypeEnum.String_unsecure(),
98
+ isOptional: false
99
+ },
100
+ timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
101
+ jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
102
+ payload: { type: ScalarTypeEnum.JSON(), isOptional: true },
103
+ maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
104
+ enabled: { type: ScalarTypeEnum.Boolean(), isOptional: true }
105
+ }
235
106
  });
236
- const ListScheduledJobsOutput = defineSchemaModel({
237
- name: "ListScheduledJobsOutput",
238
- description: "Output for listing scheduled jobs",
239
- fields: { schedules: {
240
- type: ScheduledJobModel,
241
- isArray: true,
242
- isOptional: false
243
- } }
107
+ var ListScheduledJobsOutput = defineSchemaModel({
108
+ name: "ListScheduledJobsOutput",
109
+ description: "Output for listing scheduled jobs",
110
+ fields: {
111
+ schedules: { type: ScheduledJobModel, isArray: true, isOptional: false }
112
+ }
244
113
  });
245
- const ToggleScheduledJobInput = defineSchemaModel({
246
- name: "ToggleScheduledJobInput",
247
- description: "Input for toggling a scheduled job",
248
- fields: {
249
- name: {
250
- type: ScalarTypeEnum.String_unsecure(),
251
- isOptional: false
252
- },
253
- enabled: {
254
- type: ScalarTypeEnum.Boolean(),
255
- isOptional: false
256
- }
257
- }
114
+ var ToggleScheduledJobInput = defineSchemaModel({
115
+ name: "ToggleScheduledJobInput",
116
+ description: "Input for toggling a scheduled job",
117
+ fields: {
118
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
119
+ enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false }
120
+ }
258
121
  });
259
- const JobEnqueuedPayload = defineSchemaModel({
260
- name: "JobEnqueuedPayload",
261
- description: "Payload for job.enqueued event",
262
- fields: {
263
- jobId: {
264
- type: ScalarTypeEnum.String_unsecure(),
265
- isOptional: false
266
- },
267
- type: {
268
- type: ScalarTypeEnum.String_unsecure(),
269
- isOptional: false
270
- },
271
- priority: {
272
- type: ScalarTypeEnum.Int_unsecure(),
273
- isOptional: false
274
- },
275
- scheduledAt: {
276
- type: ScalarTypeEnum.DateTime(),
277
- isOptional: true
278
- },
279
- tenantId: {
280
- type: ScalarTypeEnum.String_unsecure(),
281
- isOptional: true
282
- },
283
- enqueuedAt: {
284
- type: ScalarTypeEnum.DateTime(),
285
- isOptional: false
286
- }
287
- }
122
+ var JobEnqueuedPayload = defineSchemaModel({
123
+ name: "JobEnqueuedPayload",
124
+ description: "Payload for job.enqueued event",
125
+ fields: {
126
+ jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
127
+ type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
128
+ priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
129
+ scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
130
+ tenantId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
131
+ enqueuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
132
+ }
288
133
  });
289
- const JobCancelledPayload = defineSchemaModel({
290
- name: "JobCancelledPayload",
291
- description: "Payload for job.cancelled event",
292
- fields: { jobId: {
293
- type: ScalarTypeEnum.String_unsecure(),
294
- isOptional: false
295
- } }
134
+ var JobCancelledPayload = defineSchemaModel({
135
+ name: "JobCancelledPayload",
136
+ description: "Payload for job.cancelled event",
137
+ fields: {
138
+ jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
139
+ }
296
140
  });
297
- /**
298
- * Enqueue a job.
299
- */
300
- const EnqueueJobContract = defineCommand({
301
- meta: {
302
- key: "jobs.enqueue",
303
- version: "1.0.0",
304
- stability: "stable",
305
- owners: [...OWNERS],
306
- tags: ["jobs", "enqueue"],
307
- description: "Enqueue a background job for async processing.",
308
- goal: "Allow services to offload work to background processing.",
309
- context: "Called by any service that needs async processing."
310
- },
311
- io: {
312
- input: EnqueueJobInput,
313
- output: JobModel
314
- },
315
- policy: { auth: "user" },
316
- sideEffects: { emits: [{
317
- key: "job.enqueued",
318
- version: "1.0.0",
319
- when: "Job is enqueued",
320
- payload: JobEnqueuedPayload
321
- }] }
141
+ var EnqueueJobContract = defineCommand({
142
+ meta: {
143
+ key: "jobs.enqueue",
144
+ version: "1.0.0",
145
+ stability: "stable",
146
+ owners: [...OWNERS],
147
+ tags: ["jobs", "enqueue"],
148
+ description: "Enqueue a background job for async processing.",
149
+ goal: "Allow services to offload work to background processing.",
150
+ context: "Called by any service that needs async processing."
151
+ },
152
+ io: {
153
+ input: EnqueueJobInput,
154
+ output: JobModel
155
+ },
156
+ policy: {
157
+ auth: "user"
158
+ },
159
+ sideEffects: {
160
+ emits: [
161
+ {
162
+ key: "job.enqueued",
163
+ version: "1.0.0",
164
+ when: "Job is enqueued",
165
+ payload: JobEnqueuedPayload
166
+ }
167
+ ]
168
+ }
322
169
  });
323
- /**
324
- * Get job by ID.
325
- */
326
- const GetJobContract = defineQuery({
327
- meta: {
328
- key: "jobs.get",
329
- version: "1.0.0",
330
- stability: "stable",
331
- owners: [...OWNERS],
332
- tags: ["jobs", "get"],
333
- description: "Get a job by ID.",
334
- goal: "Check job status and result.",
335
- context: "Called to poll job status or retrieve results."
336
- },
337
- io: {
338
- input: GetJobInput,
339
- output: JobModel
340
- },
341
- policy: { auth: "user" }
170
+ var GetJobContract = defineQuery({
171
+ meta: {
172
+ key: "jobs.get",
173
+ version: "1.0.0",
174
+ stability: "stable",
175
+ owners: [...OWNERS],
176
+ tags: ["jobs", "get"],
177
+ description: "Get a job by ID.",
178
+ goal: "Check job status and result.",
179
+ context: "Called to poll job status or retrieve results."
180
+ },
181
+ io: {
182
+ input: GetJobInput,
183
+ output: JobModel
184
+ },
185
+ policy: {
186
+ auth: "user"
187
+ }
342
188
  });
343
- /**
344
- * Cancel a job.
345
- */
346
- const CancelJobContract = defineCommand({
347
- meta: {
348
- key: "jobs.cancel",
349
- version: "1.0.0",
350
- stability: "stable",
351
- owners: [...OWNERS],
352
- tags: ["jobs", "cancel"],
353
- description: "Cancel a pending job.",
354
- goal: "Allow cancellation of jobs that are no longer needed.",
355
- context: "Only pending jobs can be cancelled."
356
- },
357
- io: {
358
- input: CancelJobInput,
359
- output: CancelJobOutput,
360
- errors: {
361
- JOB_NOT_FOUND: {
362
- description: "Job does not exist",
363
- http: 404,
364
- gqlCode: "JOB_NOT_FOUND",
365
- when: "Job ID is invalid"
366
- },
367
- JOB_NOT_PENDING: {
368
- description: "Job is not in pending state",
369
- http: 409,
370
- gqlCode: "JOB_NOT_PENDING",
371
- when: "Job has already started or completed"
372
- }
373
- }
374
- },
375
- policy: { auth: "user" },
376
- sideEffects: { emits: [{
377
- key: "job.cancelled",
378
- version: "1.0.0",
379
- when: "Job is cancelled",
380
- payload: JobCancelledPayload
381
- }] }
189
+ var CancelJobContract = defineCommand({
190
+ meta: {
191
+ key: "jobs.cancel",
192
+ version: "1.0.0",
193
+ stability: "stable",
194
+ owners: [...OWNERS],
195
+ tags: ["jobs", "cancel"],
196
+ description: "Cancel a pending job.",
197
+ goal: "Allow cancellation of jobs that are no longer needed.",
198
+ context: "Only pending jobs can be cancelled."
199
+ },
200
+ io: {
201
+ input: CancelJobInput,
202
+ output: CancelJobOutput,
203
+ errors: {
204
+ JOB_NOT_FOUND: {
205
+ description: "Job does not exist",
206
+ http: 404,
207
+ gqlCode: "JOB_NOT_FOUND",
208
+ when: "Job ID is invalid"
209
+ },
210
+ JOB_NOT_PENDING: {
211
+ description: "Job is not in pending state",
212
+ http: 409,
213
+ gqlCode: "JOB_NOT_PENDING",
214
+ when: "Job has already started or completed"
215
+ }
216
+ }
217
+ },
218
+ policy: {
219
+ auth: "user"
220
+ },
221
+ sideEffects: {
222
+ emits: [
223
+ {
224
+ key: "job.cancelled",
225
+ version: "1.0.0",
226
+ when: "Job is cancelled",
227
+ payload: JobCancelledPayload
228
+ }
229
+ ]
230
+ }
382
231
  });
383
- /**
384
- * Get queue statistics.
385
- */
386
- const GetQueueStatsContract = defineQuery({
387
- meta: {
388
- key: "jobs.stats",
389
- version: "1.0.0",
390
- stability: "stable",
391
- owners: [...OWNERS],
392
- tags: [
393
- "jobs",
394
- "stats",
395
- "admin"
396
- ],
397
- description: "Get job queue statistics.",
398
- goal: "Monitor queue health and backlog.",
399
- context: "Admin dashboard monitoring."
400
- },
401
- io: {
402
- input: null,
403
- output: QueueStatsModel
404
- },
405
- policy: { auth: "admin" }
232
+ var GetQueueStatsContract = defineQuery({
233
+ meta: {
234
+ key: "jobs.stats",
235
+ version: "1.0.0",
236
+ stability: "stable",
237
+ owners: [...OWNERS],
238
+ tags: ["jobs", "stats", "admin"],
239
+ description: "Get job queue statistics.",
240
+ goal: "Monitor queue health and backlog.",
241
+ context: "Admin dashboard monitoring."
242
+ },
243
+ io: {
244
+ input: null,
245
+ output: QueueStatsModel
246
+ },
247
+ policy: {
248
+ auth: "admin"
249
+ }
406
250
  });
407
- /**
408
- * Create a scheduled job.
409
- */
410
- const CreateScheduledJobContract = defineCommand({
411
- meta: {
412
- key: "jobs.schedule.create",
413
- version: "1.0.0",
414
- stability: "stable",
415
- owners: [...OWNERS],
416
- tags: [
417
- "jobs",
418
- "schedule",
419
- "create"
420
- ],
421
- description: "Create a scheduled/recurring job.",
422
- goal: "Set up recurring background tasks.",
423
- context: "Admin configuration for periodic tasks."
424
- },
425
- io: {
426
- input: CreateScheduledJobInput,
427
- output: ScheduledJobModel
428
- },
429
- policy: { auth: "admin" }
251
+ var CreateScheduledJobContract = defineCommand({
252
+ meta: {
253
+ key: "jobs.schedule.create",
254
+ version: "1.0.0",
255
+ stability: "stable",
256
+ owners: [...OWNERS],
257
+ tags: ["jobs", "schedule", "create"],
258
+ description: "Create a scheduled/recurring job.",
259
+ goal: "Set up recurring background tasks.",
260
+ context: "Admin configuration for periodic tasks."
261
+ },
262
+ io: {
263
+ input: CreateScheduledJobInput,
264
+ output: ScheduledJobModel
265
+ },
266
+ policy: {
267
+ auth: "admin"
268
+ }
430
269
  });
431
- /**
432
- * List scheduled jobs.
433
- */
434
- const ListScheduledJobsContract = defineQuery({
435
- meta: {
436
- key: "jobs.schedule.list",
437
- version: "1.0.0",
438
- stability: "stable",
439
- owners: [...OWNERS],
440
- tags: [
441
- "jobs",
442
- "schedule",
443
- "list"
444
- ],
445
- description: "List all scheduled jobs.",
446
- goal: "View configured recurring tasks.",
447
- context: "Admin dashboard."
448
- },
449
- io: {
450
- input: null,
451
- output: ListScheduledJobsOutput
452
- },
453
- policy: { auth: "admin" }
270
+ var ListScheduledJobsContract = defineQuery({
271
+ meta: {
272
+ key: "jobs.schedule.list",
273
+ version: "1.0.0",
274
+ stability: "stable",
275
+ owners: [...OWNERS],
276
+ tags: ["jobs", "schedule", "list"],
277
+ description: "List all scheduled jobs.",
278
+ goal: "View configured recurring tasks.",
279
+ context: "Admin dashboard."
280
+ },
281
+ io: {
282
+ input: null,
283
+ output: ListScheduledJobsOutput
284
+ },
285
+ policy: {
286
+ auth: "admin"
287
+ }
454
288
  });
455
- /**
456
- * Toggle scheduled job enabled state.
457
- */
458
- const ToggleScheduledJobContract = defineCommand({
459
- meta: {
460
- key: "jobs.schedule.toggle",
461
- version: "1.0.0",
462
- stability: "stable",
463
- owners: [...OWNERS],
464
- tags: [
465
- "jobs",
466
- "schedule",
467
- "toggle"
468
- ],
469
- description: "Enable or disable a scheduled job.",
470
- goal: "Control when recurring tasks run.",
471
- context: "Admin control over scheduled tasks."
472
- },
473
- io: {
474
- input: ToggleScheduledJobInput,
475
- output: ScheduledJobModel
476
- },
477
- policy: { auth: "admin" }
289
+ var ToggleScheduledJobContract = defineCommand({
290
+ meta: {
291
+ key: "jobs.schedule.toggle",
292
+ version: "1.0.0",
293
+ stability: "stable",
294
+ owners: [...OWNERS],
295
+ tags: ["jobs", "schedule", "toggle"],
296
+ description: "Enable or disable a scheduled job.",
297
+ goal: "Control when recurring tasks run.",
298
+ context: "Admin control over scheduled tasks."
299
+ },
300
+ io: {
301
+ input: ToggleScheduledJobInput,
302
+ output: ScheduledJobModel
303
+ },
304
+ policy: {
305
+ auth: "admin"
306
+ }
478
307
  });
479
-
480
- //#endregion
481
- export { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GetJobContract, GetQueueStatsContract, JobModel, ListScheduledJobsContract, QueueStatsModel, ScheduledJobModel, ToggleScheduledJobContract };
482
- //# sourceMappingURL=index.js.map
308
+ export {
309
+ ToggleScheduledJobContract,
310
+ ScheduledJobModel,
311
+ QueueStatsModel,
312
+ ListScheduledJobsContract,
313
+ JobModel,
314
+ GetQueueStatsContract,
315
+ GetJobContract,
316
+ EnqueueJobContract,
317
+ CreateScheduledJobContract,
318
+ CancelJobContract
319
+ };