@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
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
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.Int_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
|
+
}
|
|
67
|
+
});
|
|
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
|
+
}
|
|
113
|
+
});
|
|
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
|
+
}
|
|
139
|
+
});
|
|
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
|
+
}
|
|
173
|
+
});
|
|
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
|
+
} }
|
|
181
|
+
});
|
|
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
|
+
} }
|
|
189
|
+
});
|
|
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
|
+
} }
|
|
197
|
+
});
|
|
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
|
+
}
|
|
235
|
+
});
|
|
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
|
+
} }
|
|
244
|
+
});
|
|
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
|
+
}
|
|
258
|
+
});
|
|
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
|
+
}
|
|
288
|
+
});
|
|
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
|
+
} }
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* Enqueue a job.
|
|
299
|
+
*/
|
|
300
|
+
const EnqueueJobContract = defineCommand({
|
|
301
|
+
meta: {
|
|
302
|
+
key: "jobs.enqueue",
|
|
303
|
+
version: 1,
|
|
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,
|
|
319
|
+
when: "Job is enqueued",
|
|
320
|
+
payload: JobEnqueuedPayload
|
|
321
|
+
}] }
|
|
322
|
+
});
|
|
323
|
+
/**
|
|
324
|
+
* Get job by ID.
|
|
325
|
+
*/
|
|
326
|
+
const GetJobContract = defineQuery({
|
|
327
|
+
meta: {
|
|
328
|
+
key: "jobs.get",
|
|
329
|
+
version: 1,
|
|
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" }
|
|
342
|
+
});
|
|
343
|
+
/**
|
|
344
|
+
* Cancel a job.
|
|
345
|
+
*/
|
|
346
|
+
const CancelJobContract = defineCommand({
|
|
347
|
+
meta: {
|
|
348
|
+
key: "jobs.cancel",
|
|
349
|
+
version: 1,
|
|
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,
|
|
379
|
+
when: "Job is cancelled",
|
|
380
|
+
payload: JobCancelledPayload
|
|
381
|
+
}] }
|
|
382
|
+
});
|
|
383
|
+
/**
|
|
384
|
+
* Get queue statistics.
|
|
385
|
+
*/
|
|
386
|
+
const GetQueueStatsContract = defineQuery({
|
|
387
|
+
meta: {
|
|
388
|
+
key: "jobs.stats",
|
|
389
|
+
version: 1,
|
|
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" }
|
|
406
|
+
});
|
|
407
|
+
/**
|
|
408
|
+
* Create a scheduled job.
|
|
409
|
+
*/
|
|
410
|
+
const CreateScheduledJobContract = defineCommand({
|
|
411
|
+
meta: {
|
|
412
|
+
key: "jobs.schedule.create",
|
|
413
|
+
version: 1,
|
|
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" }
|
|
430
|
+
});
|
|
431
|
+
/**
|
|
432
|
+
* List scheduled jobs.
|
|
433
|
+
*/
|
|
434
|
+
const ListScheduledJobsContract = defineQuery({
|
|
435
|
+
meta: {
|
|
436
|
+
key: "jobs.schedule.list",
|
|
437
|
+
version: 1,
|
|
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" }
|
|
454
|
+
});
|
|
455
|
+
/**
|
|
456
|
+
* Toggle scheduled job enabled state.
|
|
457
|
+
*/
|
|
458
|
+
const ToggleScheduledJobContract = defineCommand({
|
|
459
|
+
meta: {
|
|
460
|
+
key: "jobs.schedule.toggle",
|
|
461
|
+
version: 1,
|
|
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" }
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
//#endregion
|
|
481
|
+
export { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GetJobContract, GetQueueStatsContract, JobModel, ListScheduledJobsContract, QueueStatsModel, ScheduledJobModel, ToggleScheduledJobContract };
|
|
482
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/contracts/index.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineCommand, defineQuery } from '@contractspec/lib.contracts';\n\nconst OWNERS = ['platform.jobs'] as const;\n\n// ============ Schema Models ============\n\nexport const JobModel = defineSchemaModel({\n name: 'Job',\n description: 'Represents a background job',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n version: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n payload: { type: ScalarTypeEnum.JSON(), isOptional: false },\n status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }, // JobStatus enum value\n priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n attempts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n lastError: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nexport const ScheduledJobModel = defineSchemaModel({\n name: 'ScheduledJob',\n description: 'Represents a scheduled/recurring job',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n cronExpression: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n lastRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n nextRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const QueueStatsModel = defineSchemaModel({\n name: 'QueueStats',\n description: 'Job queue statistics',\n fields: {\n pending: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n running: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n completed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n failed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n deadLetter: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\n// ============ Input/Output Models ============\n\nconst EnqueueJobInput = defineSchemaModel({\n name: 'EnqueueJobInput',\n description: 'Input for enqueuing a new job',\n fields: {\n type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n payload: { type: ScalarTypeEnum.JSON(), isOptional: false },\n delaySeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n dedupeKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n\nconst GetJobInput = defineSchemaModel({\n name: 'GetJobInput',\n description: 'Input for getting a job by ID',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst CancelJobInput = defineSchemaModel({\n name: 'CancelJobInput',\n description: 'Input for cancelling a job',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst CancelJobOutput = defineSchemaModel({\n name: 'CancelJobOutput',\n description: 'Output for cancel job operation',\n fields: {\n success: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n },\n});\n\nconst CreateScheduledJobInput = defineSchemaModel({\n name: 'CreateScheduledJobInput',\n description: 'Input for creating a scheduled job',\n fields: {\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n cronExpression: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n payload: { type: ScalarTypeEnum.JSON(), isOptional: true },\n maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n enabled: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n },\n});\n\nconst ListScheduledJobsOutput = defineSchemaModel({\n name: 'ListScheduledJobsOutput',\n description: 'Output for listing scheduled jobs',\n fields: {\n schedules: { type: ScheduledJobModel, isArray: true, isOptional: false },\n },\n});\n\nconst ToggleScheduledJobInput = defineSchemaModel({\n name: 'ToggleScheduledJobInput',\n description: 'Input for toggling a scheduled job',\n fields: {\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n },\n});\n\n// ============ Event Payloads ============\n\nconst JobEnqueuedPayload = defineSchemaModel({\n name: 'JobEnqueuedPayload',\n description: 'Payload for job.enqueued event',\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 JobCancelledPayload = defineSchemaModel({\n name: 'JobCancelledPayload',\n description: 'Payload for job.cancelled event',\n fields: {\n jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\n// ============ Contracts ============\n\n/**\n * Enqueue a job.\n */\nexport const EnqueueJobContract = defineCommand({\n meta: {\n key: 'jobs.enqueue',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'enqueue'],\n description: 'Enqueue a background job for async processing.',\n goal: 'Allow services to offload work to background processing.',\n context: 'Called by any service that needs async processing.',\n },\n io: {\n input: EnqueueJobInput,\n output: JobModel,\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'job.enqueued',\n version: 1,\n when: 'Job is enqueued',\n payload: JobEnqueuedPayload,\n },\n ],\n },\n});\n\n/**\n * Get job by ID.\n */\nexport const GetJobContract = defineQuery({\n meta: {\n key: 'jobs.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'get'],\n description: 'Get a job by ID.',\n goal: 'Check job status and result.',\n context: 'Called to poll job status or retrieve results.',\n },\n io: {\n input: GetJobInput,\n output: JobModel,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Cancel a job.\n */\nexport const CancelJobContract = defineCommand({\n meta: {\n key: 'jobs.cancel',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'cancel'],\n description: 'Cancel a pending job.',\n goal: 'Allow cancellation of jobs that are no longer needed.',\n context: 'Only pending jobs can be cancelled.',\n },\n io: {\n input: CancelJobInput,\n output: CancelJobOutput,\n errors: {\n JOB_NOT_FOUND: {\n description: 'Job does not exist',\n http: 404,\n gqlCode: 'JOB_NOT_FOUND',\n when: 'Job ID is invalid',\n },\n JOB_NOT_PENDING: {\n description: 'Job is not in pending state',\n http: 409,\n gqlCode: 'JOB_NOT_PENDING',\n when: 'Job has already started or completed',\n },\n },\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'job.cancelled',\n version: 1,\n when: 'Job is cancelled',\n payload: JobCancelledPayload,\n },\n ],\n },\n});\n\n/**\n * Get queue statistics.\n */\nexport const GetQueueStatsContract = defineQuery({\n meta: {\n key: 'jobs.stats',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'stats', 'admin'],\n description: 'Get job queue statistics.',\n goal: 'Monitor queue health and backlog.',\n context: 'Admin dashboard monitoring.',\n },\n io: {\n input: null,\n output: QueueStatsModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Create a scheduled job.\n */\nexport const CreateScheduledJobContract = defineCommand({\n meta: {\n key: 'jobs.schedule.create',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'schedule', 'create'],\n description: 'Create a scheduled/recurring job.',\n goal: 'Set up recurring background tasks.',\n context: 'Admin configuration for periodic tasks.',\n },\n io: {\n input: CreateScheduledJobInput,\n output: ScheduledJobModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * List scheduled jobs.\n */\nexport const ListScheduledJobsContract = defineQuery({\n meta: {\n key: 'jobs.schedule.list',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'schedule', 'list'],\n description: 'List all scheduled jobs.',\n goal: 'View configured recurring tasks.',\n context: 'Admin dashboard.',\n },\n io: {\n input: null,\n output: ListScheduledJobsOutput,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Toggle scheduled job enabled state.\n */\nexport const ToggleScheduledJobContract = defineCommand({\n meta: {\n key: 'jobs.schedule.toggle',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['jobs', 'schedule', 'toggle'],\n description: 'Enable or disable a scheduled job.',\n goal: 'Control when recurring tasks run.',\n context: 'Admin control over scheduled tasks.',\n },\n io: {\n input: ToggleScheduledJobInput,\n output: ScheduledJobModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n"],"mappings":";;;;AAGA,MAAM,SAAS,CAAC,gBAAgB;AAIhC,MAAa,WAAW,kBAAkB;CACxC,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,MAAM;GAAE,MAAM,eAAe,iBAAiB;G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a,EACX,OAAO,CACL;EACE,KAAK;EACL,SAAS;EACT,MAAM;EACN,SAAS;EACV,CACF,EACF;CACF,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAQ;GAAS;GAAQ;EAChC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,6BAA6B,cAAc;CACtD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAQ;GAAY;GAAS;EACpC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,4BAA4B,YAAY;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAQ;GAAY;GAAO;EAClC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,6BAA6B,cAAc;CACtD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAQ;GAAY;GAAS;EACpC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema234 from "@contractspec/lib.schema";
|
|
2
|
+
import { ModuleSchemaContribution } from "@contractspec/lib.schema";
|
|
3
|
+
|
|
4
|
+
//#region src/entities/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Job status enum.
|
|
7
|
+
*/
|
|
8
|
+
declare const JobStatusEnum: _contractspec_lib_schema234.EntityEnumDef;
|
|
9
|
+
/**
|
|
10
|
+
* Job entity - represents a single job execution.
|
|
11
|
+
*/
|
|
12
|
+
declare const JobEntity: _contractspec_lib_schema234.EntitySpec<{
|
|
13
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
14
|
+
type: _contractspec_lib_schema234.EntityScalarField;
|
|
15
|
+
version: _contractspec_lib_schema234.EntityScalarField;
|
|
16
|
+
payload: _contractspec_lib_schema234.EntityScalarField;
|
|
17
|
+
status: _contractspec_lib_schema234.EntityEnumField;
|
|
18
|
+
priority: _contractspec_lib_schema234.EntityScalarField;
|
|
19
|
+
attempts: _contractspec_lib_schema234.EntityScalarField;
|
|
20
|
+
maxRetries: _contractspec_lib_schema234.EntityScalarField;
|
|
21
|
+
lastError: _contractspec_lib_schema234.EntityScalarField;
|
|
22
|
+
lastErrorStack: _contractspec_lib_schema234.EntityScalarField;
|
|
23
|
+
scheduledAt: _contractspec_lib_schema234.EntityScalarField;
|
|
24
|
+
startedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
25
|
+
completedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
26
|
+
timeoutAt: _contractspec_lib_schema234.EntityScalarField;
|
|
27
|
+
dedupeKey: _contractspec_lib_schema234.EntityScalarField;
|
|
28
|
+
tenantId: _contractspec_lib_schema234.EntityScalarField;
|
|
29
|
+
userId: _contractspec_lib_schema234.EntityScalarField;
|
|
30
|
+
traceId: _contractspec_lib_schema234.EntityScalarField;
|
|
31
|
+
metadata: _contractspec_lib_schema234.EntityScalarField;
|
|
32
|
+
result: _contractspec_lib_schema234.EntityScalarField;
|
|
33
|
+
createdAt: _contractspec_lib_schema234.EntityScalarField;
|
|
34
|
+
updatedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
35
|
+
scheduledJob: _contractspec_lib_schema234.EntityRelationField;
|
|
36
|
+
scheduledJobId: _contractspec_lib_schema234.EntityScalarField;
|
|
37
|
+
executions: _contractspec_lib_schema234.EntityRelationField;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* ScheduledJob entity - recurring job definitions.
|
|
41
|
+
*/
|
|
42
|
+
declare const ScheduledJobEntity: _contractspec_lib_schema234.EntitySpec<{
|
|
43
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
44
|
+
name: _contractspec_lib_schema234.EntityScalarField;
|
|
45
|
+
description: _contractspec_lib_schema234.EntityScalarField;
|
|
46
|
+
cronExpression: _contractspec_lib_schema234.EntityScalarField;
|
|
47
|
+
timezone: _contractspec_lib_schema234.EntityScalarField;
|
|
48
|
+
jobType: _contractspec_lib_schema234.EntityScalarField;
|
|
49
|
+
jobVersion: _contractspec_lib_schema234.EntityScalarField;
|
|
50
|
+
payload: _contractspec_lib_schema234.EntityScalarField;
|
|
51
|
+
maxRetries: _contractspec_lib_schema234.EntityScalarField;
|
|
52
|
+
timeoutMs: _contractspec_lib_schema234.EntityScalarField;
|
|
53
|
+
enabled: _contractspec_lib_schema234.EntityScalarField;
|
|
54
|
+
lastRunAt: _contractspec_lib_schema234.EntityScalarField;
|
|
55
|
+
nextRunAt: _contractspec_lib_schema234.EntityScalarField;
|
|
56
|
+
tenantId: _contractspec_lib_schema234.EntityScalarField;
|
|
57
|
+
createdAt: _contractspec_lib_schema234.EntityScalarField;
|
|
58
|
+
updatedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
59
|
+
jobs: _contractspec_lib_schema234.EntityRelationField;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* JobExecution entity - individual execution attempts.
|
|
63
|
+
*/
|
|
64
|
+
declare const JobExecutionEntity: _contractspec_lib_schema234.EntitySpec<{
|
|
65
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
66
|
+
jobId: _contractspec_lib_schema234.EntityScalarField;
|
|
67
|
+
attemptNumber: _contractspec_lib_schema234.EntityScalarField;
|
|
68
|
+
startedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
69
|
+
completedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
70
|
+
durationMs: _contractspec_lib_schema234.EntityScalarField;
|
|
71
|
+
success: _contractspec_lib_schema234.EntityScalarField;
|
|
72
|
+
error: _contractspec_lib_schema234.EntityScalarField;
|
|
73
|
+
errorStack: _contractspec_lib_schema234.EntityScalarField;
|
|
74
|
+
result: _contractspec_lib_schema234.EntityScalarField;
|
|
75
|
+
workerId: _contractspec_lib_schema234.EntityScalarField;
|
|
76
|
+
job: _contractspec_lib_schema234.EntityRelationField;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* All job entities for schema composition.
|
|
80
|
+
*/
|
|
81
|
+
declare const jobEntities: (_contractspec_lib_schema234.EntitySpec<{
|
|
82
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
83
|
+
type: _contractspec_lib_schema234.EntityScalarField;
|
|
84
|
+
version: _contractspec_lib_schema234.EntityScalarField;
|
|
85
|
+
payload: _contractspec_lib_schema234.EntityScalarField;
|
|
86
|
+
status: _contractspec_lib_schema234.EntityEnumField;
|
|
87
|
+
priority: _contractspec_lib_schema234.EntityScalarField;
|
|
88
|
+
attempts: _contractspec_lib_schema234.EntityScalarField;
|
|
89
|
+
maxRetries: _contractspec_lib_schema234.EntityScalarField;
|
|
90
|
+
lastError: _contractspec_lib_schema234.EntityScalarField;
|
|
91
|
+
lastErrorStack: _contractspec_lib_schema234.EntityScalarField;
|
|
92
|
+
scheduledAt: _contractspec_lib_schema234.EntityScalarField;
|
|
93
|
+
startedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
94
|
+
completedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
95
|
+
timeoutAt: _contractspec_lib_schema234.EntityScalarField;
|
|
96
|
+
dedupeKey: _contractspec_lib_schema234.EntityScalarField;
|
|
97
|
+
tenantId: _contractspec_lib_schema234.EntityScalarField;
|
|
98
|
+
userId: _contractspec_lib_schema234.EntityScalarField;
|
|
99
|
+
traceId: _contractspec_lib_schema234.EntityScalarField;
|
|
100
|
+
metadata: _contractspec_lib_schema234.EntityScalarField;
|
|
101
|
+
result: _contractspec_lib_schema234.EntityScalarField;
|
|
102
|
+
createdAt: _contractspec_lib_schema234.EntityScalarField;
|
|
103
|
+
updatedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
104
|
+
scheduledJob: _contractspec_lib_schema234.EntityRelationField;
|
|
105
|
+
scheduledJobId: _contractspec_lib_schema234.EntityScalarField;
|
|
106
|
+
executions: _contractspec_lib_schema234.EntityRelationField;
|
|
107
|
+
}> | _contractspec_lib_schema234.EntitySpec<{
|
|
108
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
109
|
+
name: _contractspec_lib_schema234.EntityScalarField;
|
|
110
|
+
description: _contractspec_lib_schema234.EntityScalarField;
|
|
111
|
+
cronExpression: _contractspec_lib_schema234.EntityScalarField;
|
|
112
|
+
timezone: _contractspec_lib_schema234.EntityScalarField;
|
|
113
|
+
jobType: _contractspec_lib_schema234.EntityScalarField;
|
|
114
|
+
jobVersion: _contractspec_lib_schema234.EntityScalarField;
|
|
115
|
+
payload: _contractspec_lib_schema234.EntityScalarField;
|
|
116
|
+
maxRetries: _contractspec_lib_schema234.EntityScalarField;
|
|
117
|
+
timeoutMs: _contractspec_lib_schema234.EntityScalarField;
|
|
118
|
+
enabled: _contractspec_lib_schema234.EntityScalarField;
|
|
119
|
+
lastRunAt: _contractspec_lib_schema234.EntityScalarField;
|
|
120
|
+
nextRunAt: _contractspec_lib_schema234.EntityScalarField;
|
|
121
|
+
tenantId: _contractspec_lib_schema234.EntityScalarField;
|
|
122
|
+
createdAt: _contractspec_lib_schema234.EntityScalarField;
|
|
123
|
+
updatedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
124
|
+
jobs: _contractspec_lib_schema234.EntityRelationField;
|
|
125
|
+
}> | _contractspec_lib_schema234.EntitySpec<{
|
|
126
|
+
id: _contractspec_lib_schema234.EntityScalarField;
|
|
127
|
+
jobId: _contractspec_lib_schema234.EntityScalarField;
|
|
128
|
+
attemptNumber: _contractspec_lib_schema234.EntityScalarField;
|
|
129
|
+
startedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
130
|
+
completedAt: _contractspec_lib_schema234.EntityScalarField;
|
|
131
|
+
durationMs: _contractspec_lib_schema234.EntityScalarField;
|
|
132
|
+
success: _contractspec_lib_schema234.EntityScalarField;
|
|
133
|
+
error: _contractspec_lib_schema234.EntityScalarField;
|
|
134
|
+
errorStack: _contractspec_lib_schema234.EntityScalarField;
|
|
135
|
+
result: _contractspec_lib_schema234.EntityScalarField;
|
|
136
|
+
workerId: _contractspec_lib_schema234.EntityScalarField;
|
|
137
|
+
job: _contractspec_lib_schema234.EntityRelationField;
|
|
138
|
+
}>)[];
|
|
139
|
+
/**
|
|
140
|
+
* Module schema contribution for jobs.
|
|
141
|
+
*/
|
|
142
|
+
declare const jobsSchemaContribution: ModuleSchemaContribution;
|
|
143
|
+
//#endregion
|
|
144
|
+
export { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution };
|
|
145
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/entities/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWa,cAAA,aAYX,EAAA,2BAAA,CAZwB,aAYxB;AAKF;;;cAAa,uCAAS;MA4FpB,2BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;+DA5FoB;EAAA,cAAA,+CAAA;EAiGT,UAAA,iDAkDX;CAAA,CAAA;;;;cAlDW,gDAAkB;MAkD7B,2BAAA,CAAA;;;;;;;;;;;;0DAlD6B;EAAA,QAAA,+CAAA;EAuDlB,SAAA,+CA+BX;EAAA,SAAA,+CAAA;;;;;;cA/BW,gDAAkB;MA+B7B,2BAAA,CAAA;;;;;2DA/B6B;EAAA,OAAA,+CAAA;EAoClB,KAAA,+CAAiE;EAAA,UAAA,+CAAA;;;;;;;;cAAjE,0CAAW;MAAsD,2BAAA,CAAA;;;;;;;;;;;;;;;;uDAAtD;EAAA,OAAA,+CAAA;;;;;;;;;MAAA,2BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;EAKX,UAAA,+CAIZ;;;;;;;;;;;cAJY,wBAAwB"}
|