@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.
- package/dist/contracts/index.d.ts +494 -500
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +298 -461
- package/dist/entities/index.d.ts +117 -122
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +170 -193
- package/dist/events.d.ts +297 -303
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +199 -351
- package/dist/handlers/gmail-sync-handler.d.ts +5 -9
- package/dist/handlers/gmail-sync-handler.d.ts.map +1 -1
- package/dist/handlers/gmail-sync-handler.js +8 -8
- package/dist/handlers/index.d.ts +5 -9
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +53 -10
- package/dist/handlers/ping-job.d.ts +6 -10
- package/dist/handlers/ping-job.d.ts.map +1 -1
- package/dist/handlers/ping-job.js +13 -12
- package/dist/handlers/storage-document-handler.d.ts +7 -11
- package/dist/handlers/storage-document-handler.d.ts.map +1 -1
- package/dist/handlers/storage-document-handler.js +15 -13
- package/dist/index.d.ts +7 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1366 -64
- package/dist/jobs.capability.d.ts +2 -7
- package/dist/jobs.capability.d.ts.map +1 -1
- package/dist/jobs.capability.js +29 -33
- package/dist/jobs.feature.d.ts +1 -6
- package/dist/jobs.feature.d.ts.map +1 -1
- package/dist/jobs.feature.js +45 -108
- package/dist/node/contracts/index.js +318 -0
- package/dist/node/entities/index.js +174 -0
- package/dist/node/events.js +200 -0
- package/dist/node/handlers/gmail-sync-handler.js +9 -0
- package/dist/node/handlers/index.js +55 -0
- package/dist/node/handlers/ping-job.js +14 -0
- package/dist/node/handlers/storage-document-handler.js +16 -0
- package/dist/node/index.js +1368 -0
- package/dist/node/jobs.capability.js +28 -0
- package/dist/node/jobs.feature.js +46 -0
- package/dist/node/queue/gcp-cloud-tasks.js +66 -0
- package/dist/node/queue/gcp-pubsub.js +54 -0
- package/dist/node/queue/index.js +478 -0
- package/dist/node/queue/memory-queue.js +160 -0
- package/dist/node/queue/register-defined-job.js +15 -0
- package/dist/node/queue/scaleway-sqs-queue.js +206 -0
- package/dist/node/queue/types.js +10 -0
- package/dist/node/scheduler/index.js +117 -0
- package/dist/queue/gcp-cloud-tasks.d.ts +33 -36
- package/dist/queue/gcp-cloud-tasks.d.ts.map +1 -1
- package/dist/queue/gcp-cloud-tasks.js +65 -59
- package/dist/queue/gcp-pubsub.d.ts +18 -21
- package/dist/queue/gcp-pubsub.d.ts.map +1 -1
- package/dist/queue/gcp-pubsub.js +53 -45
- package/dist/queue/index.d.ts +6 -15
- package/dist/queue/index.d.ts.map +1 -1
- package/dist/queue/index.js +476 -20
- package/dist/queue/memory-queue.d.ts +25 -29
- package/dist/queue/memory-queue.d.ts.map +1 -1
- package/dist/queue/memory-queue.js +159 -138
- package/dist/queue/register-defined-job.d.ts +3 -7
- package/dist/queue/register-defined-job.d.ts.map +1 -1
- package/dist/queue/register-defined-job.js +14 -14
- package/dist/queue/scaleway-sqs-queue.d.ts +31 -35
- package/dist/queue/scaleway-sqs-queue.d.ts.map +1 -1
- package/dist/queue/scaleway-sqs-queue.js +205 -173
- package/dist/queue/types.d.ts +2 -8
- package/dist/queue/types.d.ts.map +1 -1
- package/dist/queue/types.js +11 -12
- package/dist/scheduler/index.d.ts +68 -72
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +113 -141
- package/package.json +176 -50
- package/dist/_virtual/_rolldown/runtime.js +0 -36
- package/dist/contracts/index.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/handlers/gmail-sync-handler.js.map +0 -1
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/ping-job.js.map +0 -1
- package/dist/handlers/storage-document-handler.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jobs.capability.js.map +0 -1
- package/dist/jobs.feature.js.map +0 -1
- package/dist/queue/gcp-cloud-tasks.js.map +0 -1
- package/dist/queue/gcp-pubsub.js.map +0 -1
- package/dist/queue/index.js.map +0 -1
- package/dist/queue/memory-queue.js.map +0 -1
- package/dist/queue/register-defined-job.js.map +0 -1
- package/dist/queue/scaleway-sqs-queue.js.map +0 -1
- package/dist/queue/types.js.map +0 -1
- package/dist/scheduler/index.js.map +0 -1
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region src/jobs.capability.d.ts
|
|
4
|
-
declare const JobsCapability: _contractspec_lib_contracts0.CapabilitySpec;
|
|
5
|
-
declare const SchedulerCapability: _contractspec_lib_contracts0.CapabilitySpec;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { JobsCapability, SchedulerCapability };
|
|
1
|
+
export declare const JobsCapability: import("@contractspec/lib.contracts").CapabilitySpec;
|
|
2
|
+
export declare const SchedulerCapability: import("@contractspec/lib.contracts").CapabilitySpec;
|
|
8
3
|
//# sourceMappingURL=jobs.capability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.capability.d.ts","
|
|
1
|
+
{"version":3,"file":"jobs.capability.d.ts","sourceRoot":"","sources":["../src/jobs.capability.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,sDAUzB,CAAC;AAEH,eAAO,MAAM,mBAAmB,sDAU9B,CAAC"}
|
package/dist/jobs.capability.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { JobsCapability, SchedulerCapability };
|
|
33
|
-
//# sourceMappingURL=jobs.capability.js.map
|
|
1
|
+
// @bun
|
|
2
|
+
// src/jobs.capability.ts
|
|
3
|
+
import { defineCapability, StabilityEnum } from "@contractspec/lib.contracts";
|
|
4
|
+
var JobsCapability = defineCapability({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "jobs",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
kind: "api",
|
|
9
|
+
stability: StabilityEnum.Experimental,
|
|
10
|
+
description: "Background job processing",
|
|
11
|
+
owners: ["@platform.core"],
|
|
12
|
+
tags: ["jobs", "background", "async"]
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var SchedulerCapability = defineCapability({
|
|
16
|
+
meta: {
|
|
17
|
+
key: "scheduler",
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
kind: "api",
|
|
20
|
+
stability: StabilityEnum.Experimental,
|
|
21
|
+
description: "Scheduled job execution",
|
|
22
|
+
owners: ["@platform.core"],
|
|
23
|
+
tags: ["scheduler", "cron", "jobs"]
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
SchedulerCapability,
|
|
28
|
+
JobsCapability
|
|
29
|
+
};
|
package/dist/jobs.feature.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
|
|
2
|
-
|
|
3
|
-
//#region src/jobs.feature.d.ts
|
|
4
1
|
/**
|
|
5
2
|
* Jobs feature module that bundles background job processing,
|
|
6
3
|
* queues, and scheduling capabilities.
|
|
7
4
|
*/
|
|
8
|
-
declare const JobsFeature:
|
|
9
|
-
//#endregion
|
|
10
|
-
export { JobsFeature };
|
|
5
|
+
export declare const JobsFeature: import("@contractspec/lib.contracts").FeatureModuleSpec;
|
|
11
6
|
//# sourceMappingURL=jobs.feature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.feature.d.ts","
|
|
1
|
+
{"version":3,"file":"jobs.feature.d.ts","sourceRoot":"","sources":["../src/jobs.feature.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,WAAW,yDAsDtB,CAAC"}
|
package/dist/jobs.feature.js
CHANGED
|
@@ -1,110 +1,47 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/jobs.feature.ts
|
|
1
3
|
import { defineFeature } from "@contractspec/lib.contracts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
key: "jobs.stats",
|
|
44
|
-
version: "1.0.0"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
key: "jobs.schedule.create",
|
|
48
|
-
version: "1.0.0"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
key: "jobs.schedule.toggle",
|
|
52
|
-
version: "1.0.0"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
key: "jobs.schedule.list",
|
|
56
|
-
version: "1.0.0"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
events: [
|
|
60
|
-
{
|
|
61
|
-
key: "job.enqueued",
|
|
62
|
-
version: "1.0.0"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
key: "job.started",
|
|
66
|
-
version: "1.0.0"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
key: "job.completed",
|
|
70
|
-
version: "1.0.0"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
key: "job.failed",
|
|
74
|
-
version: "1.0.0"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
key: "job.retrying",
|
|
78
|
-
version: "1.0.0"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
key: "job.dead_lettered",
|
|
82
|
-
version: "1.0.0"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
key: "job.cancelled",
|
|
86
|
-
version: "1.0.0"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
key: "scheduler.job_triggered",
|
|
90
|
-
version: "1.0.0"
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
presentations: [],
|
|
94
|
-
opToPresentation: [],
|
|
95
|
-
presentationsTargets: [],
|
|
96
|
-
capabilities: {
|
|
97
|
-
provides: [{
|
|
98
|
-
key: "jobs",
|
|
99
|
-
version: "1.0.0"
|
|
100
|
-
}, {
|
|
101
|
-
key: "scheduler",
|
|
102
|
-
version: "1.0.0"
|
|
103
|
-
}],
|
|
104
|
-
requires: []
|
|
105
|
-
}
|
|
4
|
+
var JobsFeature = defineFeature({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "jobs",
|
|
7
|
+
title: "Background Jobs",
|
|
8
|
+
description: "Background job processing, scheduling, and queue management",
|
|
9
|
+
domain: "platform",
|
|
10
|
+
owners: ["@platform.jobs"],
|
|
11
|
+
tags: ["jobs", "queue", "background", "scheduler"],
|
|
12
|
+
stability: "stable",
|
|
13
|
+
version: "1.0.0"
|
|
14
|
+
},
|
|
15
|
+
operations: [
|
|
16
|
+
{ key: "jobs.enqueue", version: "1.0.0" },
|
|
17
|
+
{ key: "jobs.cancel", version: "1.0.0" },
|
|
18
|
+
{ key: "jobs.get", version: "1.0.0" },
|
|
19
|
+
{ key: "jobs.stats", version: "1.0.0" },
|
|
20
|
+
{ key: "jobs.schedule.create", version: "1.0.0" },
|
|
21
|
+
{ key: "jobs.schedule.toggle", version: "1.0.0" },
|
|
22
|
+
{ key: "jobs.schedule.list", version: "1.0.0" }
|
|
23
|
+
],
|
|
24
|
+
events: [
|
|
25
|
+
{ key: "job.enqueued", version: "1.0.0" },
|
|
26
|
+
{ key: "job.started", version: "1.0.0" },
|
|
27
|
+
{ key: "job.completed", version: "1.0.0" },
|
|
28
|
+
{ key: "job.failed", version: "1.0.0" },
|
|
29
|
+
{ key: "job.retrying", version: "1.0.0" },
|
|
30
|
+
{ key: "job.dead_lettered", version: "1.0.0" },
|
|
31
|
+
{ key: "job.cancelled", version: "1.0.0" },
|
|
32
|
+
{ key: "scheduler.job_triggered", version: "1.0.0" }
|
|
33
|
+
],
|
|
34
|
+
presentations: [],
|
|
35
|
+
opToPresentation: [],
|
|
36
|
+
presentationsTargets: [],
|
|
37
|
+
capabilities: {
|
|
38
|
+
provides: [
|
|
39
|
+
{ key: "jobs", version: "1.0.0" },
|
|
40
|
+
{ key: "scheduler", version: "1.0.0" }
|
|
41
|
+
],
|
|
42
|
+
requires: []
|
|
43
|
+
}
|
|
106
44
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//# sourceMappingURL=jobs.feature.js.map
|
|
45
|
+
export {
|
|
46
|
+
JobsFeature
|
|
47
|
+
};
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// src/contracts/index.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
4
|
+
var OWNERS = ["platform.jobs"];
|
|
5
|
+
var JobModel = defineSchemaModel({
|
|
6
|
+
name: "Job",
|
|
7
|
+
description: "Represents a background job",
|
|
8
|
+
fields: {
|
|
9
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
payload: { type: ScalarTypeEnum.JSON(), isOptional: false },
|
|
13
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
15
|
+
attempts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
16
|
+
maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
17
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
18
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
19
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
20
|
+
startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
21
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
22
|
+
lastError: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var ScheduledJobModel = defineSchemaModel({
|
|
26
|
+
name: "ScheduledJob",
|
|
27
|
+
description: "Represents a scheduled/recurring job",
|
|
28
|
+
fields: {
|
|
29
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
30
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
32
|
+
cronExpression: {
|
|
33
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
34
|
+
isOptional: false
|
|
35
|
+
},
|
|
36
|
+
timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
37
|
+
jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
38
|
+
enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
39
|
+
lastRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
40
|
+
nextRunAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
41
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
var QueueStatsModel = defineSchemaModel({
|
|
45
|
+
name: "QueueStats",
|
|
46
|
+
description: "Job queue statistics",
|
|
47
|
+
fields: {
|
|
48
|
+
pending: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
49
|
+
running: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
50
|
+
completed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
51
|
+
failed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
52
|
+
deadLetter: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var EnqueueJobInput = defineSchemaModel({
|
|
56
|
+
name: "EnqueueJobInput",
|
|
57
|
+
description: "Input for enqueuing a new job",
|
|
58
|
+
fields: {
|
|
59
|
+
type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
60
|
+
payload: { type: ScalarTypeEnum.JSON(), isOptional: false },
|
|
61
|
+
delaySeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
62
|
+
dedupeKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
63
|
+
maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
64
|
+
priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
65
|
+
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
var GetJobInput = defineSchemaModel({
|
|
69
|
+
name: "GetJobInput",
|
|
70
|
+
description: "Input for getting a job by ID",
|
|
71
|
+
fields: {
|
|
72
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
var CancelJobInput = defineSchemaModel({
|
|
76
|
+
name: "CancelJobInput",
|
|
77
|
+
description: "Input for cancelling a job",
|
|
78
|
+
fields: {
|
|
79
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var CancelJobOutput = defineSchemaModel({
|
|
83
|
+
name: "CancelJobOutput",
|
|
84
|
+
description: "Output for cancel job operation",
|
|
85
|
+
fields: {
|
|
86
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
var CreateScheduledJobInput = defineSchemaModel({
|
|
90
|
+
name: "CreateScheduledJobInput",
|
|
91
|
+
description: "Input for creating a scheduled job",
|
|
92
|
+
fields: {
|
|
93
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
94
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
95
|
+
cronExpression: {
|
|
96
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
97
|
+
isOptional: false
|
|
98
|
+
},
|
|
99
|
+
timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
100
|
+
jobType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
101
|
+
payload: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
102
|
+
maxRetries: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
103
|
+
enabled: { type: ScalarTypeEnum.Boolean(), isOptional: true }
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var ListScheduledJobsOutput = defineSchemaModel({
|
|
107
|
+
name: "ListScheduledJobsOutput",
|
|
108
|
+
description: "Output for listing scheduled jobs",
|
|
109
|
+
fields: {
|
|
110
|
+
schedules: { type: ScheduledJobModel, isArray: true, isOptional: false }
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
var ToggleScheduledJobInput = defineSchemaModel({
|
|
114
|
+
name: "ToggleScheduledJobInput",
|
|
115
|
+
description: "Input for toggling a scheduled job",
|
|
116
|
+
fields: {
|
|
117
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
118
|
+
enabled: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var JobEnqueuedPayload = defineSchemaModel({
|
|
122
|
+
name: "JobEnqueuedPayload",
|
|
123
|
+
description: "Payload for job.enqueued event",
|
|
124
|
+
fields: {
|
|
125
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
126
|
+
type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
127
|
+
priority: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
128
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
129
|
+
tenantId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
130
|
+
enqueuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
var JobCancelledPayload = defineSchemaModel({
|
|
134
|
+
name: "JobCancelledPayload",
|
|
135
|
+
description: "Payload for job.cancelled event",
|
|
136
|
+
fields: {
|
|
137
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var EnqueueJobContract = defineCommand({
|
|
141
|
+
meta: {
|
|
142
|
+
key: "jobs.enqueue",
|
|
143
|
+
version: "1.0.0",
|
|
144
|
+
stability: "stable",
|
|
145
|
+
owners: [...OWNERS],
|
|
146
|
+
tags: ["jobs", "enqueue"],
|
|
147
|
+
description: "Enqueue a background job for async processing.",
|
|
148
|
+
goal: "Allow services to offload work to background processing.",
|
|
149
|
+
context: "Called by any service that needs async processing."
|
|
150
|
+
},
|
|
151
|
+
io: {
|
|
152
|
+
input: EnqueueJobInput,
|
|
153
|
+
output: JobModel
|
|
154
|
+
},
|
|
155
|
+
policy: {
|
|
156
|
+
auth: "user"
|
|
157
|
+
},
|
|
158
|
+
sideEffects: {
|
|
159
|
+
emits: [
|
|
160
|
+
{
|
|
161
|
+
key: "job.enqueued",
|
|
162
|
+
version: "1.0.0",
|
|
163
|
+
when: "Job is enqueued",
|
|
164
|
+
payload: JobEnqueuedPayload
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var GetJobContract = defineQuery({
|
|
170
|
+
meta: {
|
|
171
|
+
key: "jobs.get",
|
|
172
|
+
version: "1.0.0",
|
|
173
|
+
stability: "stable",
|
|
174
|
+
owners: [...OWNERS],
|
|
175
|
+
tags: ["jobs", "get"],
|
|
176
|
+
description: "Get a job by ID.",
|
|
177
|
+
goal: "Check job status and result.",
|
|
178
|
+
context: "Called to poll job status or retrieve results."
|
|
179
|
+
},
|
|
180
|
+
io: {
|
|
181
|
+
input: GetJobInput,
|
|
182
|
+
output: JobModel
|
|
183
|
+
},
|
|
184
|
+
policy: {
|
|
185
|
+
auth: "user"
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
var CancelJobContract = defineCommand({
|
|
189
|
+
meta: {
|
|
190
|
+
key: "jobs.cancel",
|
|
191
|
+
version: "1.0.0",
|
|
192
|
+
stability: "stable",
|
|
193
|
+
owners: [...OWNERS],
|
|
194
|
+
tags: ["jobs", "cancel"],
|
|
195
|
+
description: "Cancel a pending job.",
|
|
196
|
+
goal: "Allow cancellation of jobs that are no longer needed.",
|
|
197
|
+
context: "Only pending jobs can be cancelled."
|
|
198
|
+
},
|
|
199
|
+
io: {
|
|
200
|
+
input: CancelJobInput,
|
|
201
|
+
output: CancelJobOutput,
|
|
202
|
+
errors: {
|
|
203
|
+
JOB_NOT_FOUND: {
|
|
204
|
+
description: "Job does not exist",
|
|
205
|
+
http: 404,
|
|
206
|
+
gqlCode: "JOB_NOT_FOUND",
|
|
207
|
+
when: "Job ID is invalid"
|
|
208
|
+
},
|
|
209
|
+
JOB_NOT_PENDING: {
|
|
210
|
+
description: "Job is not in pending state",
|
|
211
|
+
http: 409,
|
|
212
|
+
gqlCode: "JOB_NOT_PENDING",
|
|
213
|
+
when: "Job has already started or completed"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
policy: {
|
|
218
|
+
auth: "user"
|
|
219
|
+
},
|
|
220
|
+
sideEffects: {
|
|
221
|
+
emits: [
|
|
222
|
+
{
|
|
223
|
+
key: "job.cancelled",
|
|
224
|
+
version: "1.0.0",
|
|
225
|
+
when: "Job is cancelled",
|
|
226
|
+
payload: JobCancelledPayload
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
var GetQueueStatsContract = defineQuery({
|
|
232
|
+
meta: {
|
|
233
|
+
key: "jobs.stats",
|
|
234
|
+
version: "1.0.0",
|
|
235
|
+
stability: "stable",
|
|
236
|
+
owners: [...OWNERS],
|
|
237
|
+
tags: ["jobs", "stats", "admin"],
|
|
238
|
+
description: "Get job queue statistics.",
|
|
239
|
+
goal: "Monitor queue health and backlog.",
|
|
240
|
+
context: "Admin dashboard monitoring."
|
|
241
|
+
},
|
|
242
|
+
io: {
|
|
243
|
+
input: null,
|
|
244
|
+
output: QueueStatsModel
|
|
245
|
+
},
|
|
246
|
+
policy: {
|
|
247
|
+
auth: "admin"
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
var CreateScheduledJobContract = defineCommand({
|
|
251
|
+
meta: {
|
|
252
|
+
key: "jobs.schedule.create",
|
|
253
|
+
version: "1.0.0",
|
|
254
|
+
stability: "stable",
|
|
255
|
+
owners: [...OWNERS],
|
|
256
|
+
tags: ["jobs", "schedule", "create"],
|
|
257
|
+
description: "Create a scheduled/recurring job.",
|
|
258
|
+
goal: "Set up recurring background tasks.",
|
|
259
|
+
context: "Admin configuration for periodic tasks."
|
|
260
|
+
},
|
|
261
|
+
io: {
|
|
262
|
+
input: CreateScheduledJobInput,
|
|
263
|
+
output: ScheduledJobModel
|
|
264
|
+
},
|
|
265
|
+
policy: {
|
|
266
|
+
auth: "admin"
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
var ListScheduledJobsContract = defineQuery({
|
|
270
|
+
meta: {
|
|
271
|
+
key: "jobs.schedule.list",
|
|
272
|
+
version: "1.0.0",
|
|
273
|
+
stability: "stable",
|
|
274
|
+
owners: [...OWNERS],
|
|
275
|
+
tags: ["jobs", "schedule", "list"],
|
|
276
|
+
description: "List all scheduled jobs.",
|
|
277
|
+
goal: "View configured recurring tasks.",
|
|
278
|
+
context: "Admin dashboard."
|
|
279
|
+
},
|
|
280
|
+
io: {
|
|
281
|
+
input: null,
|
|
282
|
+
output: ListScheduledJobsOutput
|
|
283
|
+
},
|
|
284
|
+
policy: {
|
|
285
|
+
auth: "admin"
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
var ToggleScheduledJobContract = defineCommand({
|
|
289
|
+
meta: {
|
|
290
|
+
key: "jobs.schedule.toggle",
|
|
291
|
+
version: "1.0.0",
|
|
292
|
+
stability: "stable",
|
|
293
|
+
owners: [...OWNERS],
|
|
294
|
+
tags: ["jobs", "schedule", "toggle"],
|
|
295
|
+
description: "Enable or disable a scheduled job.",
|
|
296
|
+
goal: "Control when recurring tasks run.",
|
|
297
|
+
context: "Admin control over scheduled tasks."
|
|
298
|
+
},
|
|
299
|
+
io: {
|
|
300
|
+
input: ToggleScheduledJobInput,
|
|
301
|
+
output: ScheduledJobModel
|
|
302
|
+
},
|
|
303
|
+
policy: {
|
|
304
|
+
auth: "admin"
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
export {
|
|
308
|
+
ToggleScheduledJobContract,
|
|
309
|
+
ScheduledJobModel,
|
|
310
|
+
QueueStatsModel,
|
|
311
|
+
ListScheduledJobsContract,
|
|
312
|
+
JobModel,
|
|
313
|
+
GetQueueStatsContract,
|
|
314
|
+
GetJobContract,
|
|
315
|
+
EnqueueJobContract,
|
|
316
|
+
CreateScheduledJobContract,
|
|
317
|
+
CancelJobContract
|
|
318
|
+
};
|