@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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -0
  3. package/dist/_virtual/rolldown_runtime.js +36 -0
  4. package/dist/contracts/index.d.ts +547 -0
  5. package/dist/contracts/index.d.ts.map +1 -0
  6. package/dist/contracts/index.js +482 -0
  7. package/dist/contracts/index.js.map +1 -0
  8. package/dist/entities/index.d.ts +145 -0
  9. package/dist/entities/index.d.ts.map +1 -0
  10. package/dist/entities/index.js +198 -0
  11. package/dist/entities/index.js.map +1 -0
  12. package/dist/events.d.ts +388 -0
  13. package/dist/events.d.ts.map +1 -0
  14. package/dist/events.js +353 -0
  15. package/dist/events.js.map +1 -0
  16. package/dist/handlers/gmail-sync-handler.d.ts +10 -0
  17. package/dist/handlers/gmail-sync-handler.d.ts.map +1 -0
  18. package/dist/handlers/gmail-sync-handler.js +10 -0
  19. package/dist/handlers/gmail-sync-handler.js.map +1 -0
  20. package/dist/handlers/index.d.ts +10 -0
  21. package/dist/handlers/index.d.ts.map +1 -0
  22. package/dist/handlers/index.js +13 -0
  23. package/dist/handlers/index.js.map +1 -0
  24. package/dist/handlers/ping-job.d.ts +11 -0
  25. package/dist/handlers/ping-job.d.ts.map +1 -0
  26. package/dist/handlers/ping-job.js +14 -0
  27. package/dist/handlers/ping-job.js.map +1 -0
  28. package/dist/handlers/storage-document-handler.d.ts +13 -0
  29. package/dist/handlers/storage-document-handler.d.ts.map +1 -0
  30. package/dist/handlers/storage-document-handler.js +15 -0
  31. package/dist/handlers/storage-document-handler.js.map +1 -0
  32. package/dist/index.d.ts +25 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +67 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/jobs.feature.d.ts +12 -0
  37. package/dist/jobs.feature.d.ts.map +1 -0
  38. package/dist/jobs.feature.js +103 -0
  39. package/dist/jobs.feature.js.map +1 -0
  40. package/dist/queue/gcp-cloud-tasks.d.ts +42 -0
  41. package/dist/queue/gcp-cloud-tasks.d.ts.map +1 -0
  42. package/dist/queue/gcp-cloud-tasks.js +61 -0
  43. package/dist/queue/gcp-cloud-tasks.js.map +1 -0
  44. package/dist/queue/gcp-pubsub.d.ts +26 -0
  45. package/dist/queue/gcp-pubsub.d.ts.map +1 -0
  46. package/dist/queue/gcp-pubsub.js +47 -0
  47. package/dist/queue/gcp-pubsub.js.map +1 -0
  48. package/dist/queue/index.d.ts +16 -0
  49. package/dist/queue/index.d.ts.map +1 -0
  50. package/dist/queue/index.js +23 -0
  51. package/dist/queue/index.js.map +1 -0
  52. package/dist/queue/memory-queue.d.ts +35 -0
  53. package/dist/queue/memory-queue.d.ts.map +1 -0
  54. package/dist/queue/memory-queue.js +140 -0
  55. package/dist/queue/memory-queue.js.map +1 -0
  56. package/dist/queue/register-defined-job.d.ts +8 -0
  57. package/dist/queue/register-defined-job.d.ts.map +1 -0
  58. package/dist/queue/register-defined-job.js +16 -0
  59. package/dist/queue/register-defined-job.js.map +1 -0
  60. package/dist/queue/scaleway-sqs-queue.d.ts +39 -0
  61. package/dist/queue/scaleway-sqs-queue.d.ts.map +1 -0
  62. package/dist/queue/scaleway-sqs-queue.js +175 -0
  63. package/dist/queue/scaleway-sqs-queue.js.map +1 -0
  64. package/dist/queue/types.d.ts +8 -0
  65. package/dist/queue/types.d.ts.map +1 -0
  66. package/dist/queue/types.js +12 -0
  67. package/dist/queue/types.js.map +1 -0
  68. package/dist/scheduler/index.d.ts +93 -0
  69. package/dist/scheduler/index.d.ts.map +1 -0
  70. package/dist/scheduler/index.js +146 -0
  71. package/dist/scheduler/index.js.map +1 -0
  72. package/package.json +90 -0
@@ -0,0 +1,198 @@
1
+ import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
2
+
3
+ //#region src/entities/index.ts
4
+ /**
5
+ * Job status enum.
6
+ */
7
+ const JobStatusEnum = defineEntityEnum({
8
+ name: "JobStatus",
9
+ values: [
10
+ "PENDING",
11
+ "RUNNING",
12
+ "COMPLETED",
13
+ "FAILED",
14
+ "CANCELLED",
15
+ "DEAD_LETTER"
16
+ ],
17
+ schema: "lssm_jobs",
18
+ description: "Status of a background job."
19
+ });
20
+ /**
21
+ * Job entity - represents a single job execution.
22
+ */
23
+ const JobEntity = defineEntity({
24
+ name: "Job",
25
+ description: "A background job for async processing.",
26
+ schema: "lssm_jobs",
27
+ map: "job",
28
+ fields: {
29
+ id: field.id({ description: "Unique job identifier" }),
30
+ type: field.string({ description: "Job type identifier" }),
31
+ version: field.int({
32
+ default: 1,
33
+ description: "Job type version"
34
+ }),
35
+ payload: field.json({ description: "Job payload data" }),
36
+ status: field.enum("JobStatus", { default: "PENDING" }),
37
+ priority: field.int({
38
+ default: 0,
39
+ description: "Higher = more urgent"
40
+ }),
41
+ attempts: field.int({
42
+ default: 0,
43
+ description: "Number of execution attempts"
44
+ }),
45
+ maxRetries: field.int({
46
+ default: 3,
47
+ description: "Maximum retry attempts"
48
+ }),
49
+ lastError: field.string({
50
+ isOptional: true,
51
+ description: "Last error message"
52
+ }),
53
+ lastErrorStack: field.string({
54
+ isOptional: true,
55
+ description: "Last error stack trace"
56
+ }),
57
+ scheduledAt: field.dateTime({
58
+ isOptional: true,
59
+ description: "When job should be processed"
60
+ }),
61
+ startedAt: field.dateTime({
62
+ isOptional: true,
63
+ description: "When processing started"
64
+ }),
65
+ completedAt: field.dateTime({
66
+ isOptional: true,
67
+ description: "When processing completed"
68
+ }),
69
+ timeoutAt: field.dateTime({
70
+ isOptional: true,
71
+ description: "Job timeout deadline"
72
+ }),
73
+ dedupeKey: field.string({
74
+ isOptional: true,
75
+ description: "Key for deduplication"
76
+ }),
77
+ tenantId: field.string({
78
+ isOptional: true,
79
+ description: "Tenant/org context"
80
+ }),
81
+ userId: field.string({
82
+ isOptional: true,
83
+ description: "User who enqueued"
84
+ }),
85
+ traceId: field.string({
86
+ isOptional: true,
87
+ description: "Distributed trace ID"
88
+ }),
89
+ metadata: field.json({
90
+ isOptional: true,
91
+ description: "Additional metadata"
92
+ }),
93
+ result: field.json({
94
+ isOptional: true,
95
+ description: "Job result data"
96
+ }),
97
+ createdAt: field.createdAt(),
98
+ updatedAt: field.updatedAt(),
99
+ scheduledJob: field.belongsTo("ScheduledJob", ["scheduledJobId"], ["id"]),
100
+ scheduledJobId: field.string({ isOptional: true }),
101
+ executions: field.hasMany("JobExecution")
102
+ },
103
+ indexes: [
104
+ index.on(["status", "scheduledAt"]),
105
+ index.on(["type", "status"]),
106
+ index.on(["tenantId", "status"]),
107
+ index.unique(["dedupeKey"], { name: "job_dedupe_key_unique" })
108
+ ],
109
+ enums: [JobStatusEnum]
110
+ });
111
+ /**
112
+ * ScheduledJob entity - recurring job definitions.
113
+ */
114
+ const ScheduledJobEntity = defineEntity({
115
+ name: "ScheduledJob",
116
+ description: "A scheduled/recurring job definition.",
117
+ schema: "lssm_jobs",
118
+ map: "scheduled_job",
119
+ fields: {
120
+ id: field.id(),
121
+ name: field.string({
122
+ isUnique: true,
123
+ description: "Unique schedule name"
124
+ }),
125
+ description: field.string({ isOptional: true }),
126
+ cronExpression: field.string({ description: "Cron expression for scheduling" }),
127
+ timezone: field.string({
128
+ default: "\"UTC\"",
129
+ description: "Timezone for cron evaluation"
130
+ }),
131
+ jobType: field.string({ description: "Job type to create" }),
132
+ jobVersion: field.int({ default: 1 }),
133
+ payload: field.json({
134
+ isOptional: true,
135
+ description: "Default payload for created jobs"
136
+ }),
137
+ maxRetries: field.int({ default: 3 }),
138
+ timeoutMs: field.int({
139
+ isOptional: true,
140
+ description: "Job timeout in milliseconds"
141
+ }),
142
+ enabled: field.boolean({ default: true }),
143
+ lastRunAt: field.dateTime({ isOptional: true }),
144
+ nextRunAt: field.dateTime({ isOptional: true }),
145
+ tenantId: field.string({ isOptional: true }),
146
+ createdAt: field.createdAt(),
147
+ updatedAt: field.updatedAt(),
148
+ jobs: field.hasMany("Job")
149
+ },
150
+ indexes: [index.on(["enabled", "nextRunAt"])]
151
+ });
152
+ /**
153
+ * JobExecution entity - individual execution attempts.
154
+ */
155
+ const JobExecutionEntity = defineEntity({
156
+ name: "JobExecution",
157
+ description: "A single execution attempt of a job.",
158
+ schema: "lssm_jobs",
159
+ map: "job_execution",
160
+ fields: {
161
+ id: field.id(),
162
+ jobId: field.foreignKey(),
163
+ attemptNumber: field.int({ description: "Which attempt this is" }),
164
+ startedAt: field.dateTime(),
165
+ completedAt: field.dateTime({ isOptional: true }),
166
+ durationMs: field.int({ isOptional: true }),
167
+ success: field.boolean({ isOptional: true }),
168
+ error: field.string({ isOptional: true }),
169
+ errorStack: field.string({ isOptional: true }),
170
+ result: field.json({ isOptional: true }),
171
+ workerId: field.string({
172
+ isOptional: true,
173
+ description: "ID of worker that processed"
174
+ }),
175
+ job: field.belongsTo("Job", ["jobId"], ["id"], { onDelete: "Cascade" })
176
+ },
177
+ indexes: [index.on(["jobId", "attemptNumber"])]
178
+ });
179
+ /**
180
+ * All job entities for schema composition.
181
+ */
182
+ const jobEntities = [
183
+ JobEntity,
184
+ ScheduledJobEntity,
185
+ JobExecutionEntity
186
+ ];
187
+ /**
188
+ * Module schema contribution for jobs.
189
+ */
190
+ const jobsSchemaContribution = {
191
+ moduleId: "@contractspec/lib.jobs",
192
+ entities: jobEntities,
193
+ enums: [JobStatusEnum]
194
+ };
195
+
196
+ //#endregion
197
+ export { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution };
198
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["jobsSchemaContribution: ModuleSchemaContribution"],"sources":["../../src/entities/index.ts"],"sourcesContent":["import {\n defineEntity,\n defineEntityEnum,\n field,\n index,\n} from '@contractspec/lib.schema';\nimport type { ModuleSchemaContribution } from '@contractspec/lib.schema';\n\n/**\n * Job status enum.\n */\nexport const JobStatusEnum = defineEntityEnum({\n name: 'JobStatus',\n values: [\n 'PENDING',\n 'RUNNING',\n 'COMPLETED',\n 'FAILED',\n 'CANCELLED',\n 'DEAD_LETTER',\n ] as const,\n schema: 'lssm_jobs',\n description: 'Status of a background job.',\n});\n\n/**\n * Job entity - represents a single job execution.\n */\nexport const JobEntity = defineEntity({\n name: 'Job',\n description: 'A background job for async processing.',\n schema: 'lssm_jobs',\n map: 'job',\n fields: {\n id: field.id({ description: 'Unique job identifier' }),\n type: field.string({ description: 'Job type identifier' }),\n version: field.int({ default: 1, description: 'Job type version' }),\n payload: field.json({ description: 'Job payload data' }),\n status: field.enum('JobStatus', { default: 'PENDING' }),\n priority: field.int({ default: 0, description: 'Higher = more urgent' }),\n\n // Execution tracking\n attempts: field.int({\n default: 0,\n description: 'Number of execution attempts',\n }),\n maxRetries: field.int({\n default: 3,\n description: 'Maximum retry attempts',\n }),\n lastError: field.string({\n isOptional: true,\n description: 'Last error message',\n }),\n lastErrorStack: field.string({\n isOptional: true,\n description: 'Last error stack trace',\n }),\n\n // Timing\n scheduledAt: field.dateTime({\n isOptional: true,\n description: 'When job should be processed',\n }),\n startedAt: field.dateTime({\n isOptional: true,\n description: 'When processing started',\n }),\n completedAt: field.dateTime({\n isOptional: true,\n description: 'When processing completed',\n }),\n timeoutAt: field.dateTime({\n isOptional: true,\n description: 'Job timeout deadline',\n }),\n\n // Deduplication\n dedupeKey: field.string({\n isOptional: true,\n description: 'Key for deduplication',\n }),\n\n // Context\n tenantId: field.string({\n isOptional: true,\n description: 'Tenant/org context',\n }),\n userId: field.string({\n isOptional: true,\n description: 'User who enqueued',\n }),\n traceId: field.string({\n isOptional: true,\n description: 'Distributed trace ID',\n }),\n\n // Metadata\n metadata: field.json({\n isOptional: true,\n description: 'Additional metadata',\n }),\n result: field.json({ isOptional: true, description: 'Job result data' }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n scheduledJob: field.belongsTo('ScheduledJob', ['scheduledJobId'], ['id']),\n scheduledJobId: field.string({ isOptional: true }),\n executions: field.hasMany('JobExecution'),\n },\n indexes: [\n index.on(['status', 'scheduledAt']),\n index.on(['type', 'status']),\n index.on(['tenantId', 'status']),\n index.unique(['dedupeKey'], { name: 'job_dedupe_key_unique' }),\n ],\n enums: [JobStatusEnum],\n});\n\n/**\n * ScheduledJob entity - recurring job definitions.\n */\nexport const ScheduledJobEntity = defineEntity({\n name: 'ScheduledJob',\n description: 'A scheduled/recurring job definition.',\n schema: 'lssm_jobs',\n map: 'scheduled_job',\n fields: {\n id: field.id(),\n name: field.string({ isUnique: true, description: 'Unique schedule name' }),\n description: field.string({ isOptional: true }),\n\n // Schedule definition\n cronExpression: field.string({\n description: 'Cron expression for scheduling',\n }),\n timezone: field.string({\n default: '\"UTC\"',\n description: 'Timezone for cron evaluation',\n }),\n\n // Job template\n jobType: field.string({ description: 'Job type to create' }),\n jobVersion: field.int({ default: 1 }),\n payload: field.json({\n isOptional: true,\n description: 'Default payload for created jobs',\n }),\n\n // Execution settings\n maxRetries: field.int({ default: 3 }),\n timeoutMs: field.int({\n isOptional: true,\n description: 'Job timeout in milliseconds',\n }),\n\n // State\n enabled: field.boolean({ default: true }),\n lastRunAt: field.dateTime({ isOptional: true }),\n nextRunAt: field.dateTime({ isOptional: true }),\n\n // Context\n tenantId: field.string({ isOptional: true }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n jobs: field.hasMany('Job'),\n },\n indexes: [index.on(['enabled', 'nextRunAt'])],\n});\n\n/**\n * JobExecution entity - individual execution attempts.\n */\nexport const JobExecutionEntity = defineEntity({\n name: 'JobExecution',\n description: 'A single execution attempt of a job.',\n schema: 'lssm_jobs',\n map: 'job_execution',\n fields: {\n id: field.id(),\n jobId: field.foreignKey(),\n attemptNumber: field.int({ description: 'Which attempt this is' }),\n\n // Execution details\n startedAt: field.dateTime(),\n completedAt: field.dateTime({ isOptional: true }),\n durationMs: field.int({ isOptional: true }),\n\n // Result\n success: field.boolean({ isOptional: true }),\n error: field.string({ isOptional: true }),\n errorStack: field.string({ isOptional: true }),\n result: field.json({ isOptional: true }),\n\n // Worker info\n workerId: field.string({\n isOptional: true,\n description: 'ID of worker that processed',\n }),\n\n // Relations\n job: field.belongsTo('Job', ['jobId'], ['id'], { onDelete: 'Cascade' }),\n },\n indexes: [index.on(['jobId', 'attemptNumber'])],\n});\n\n/**\n * All job entities for schema composition.\n */\nexport const jobEntities = [JobEntity, ScheduledJobEntity, JobExecutionEntity];\n\n/**\n * Module schema contribution for jobs.\n */\nexport const jobsSchemaContribution: ModuleSchemaContribution = {\n moduleId: '@contractspec/lib.jobs',\n entities: jobEntities,\n enums: [JobStatusEnum],\n};\n"],"mappings":";;;;;;AAWA,MAAa,gBAAgB,iBAAiB;CAC5C,MAAM;CACN,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACD;CACD,QAAQ;CACR,aAAa;CACd,CAAC;;;;AAKF,MAAa,YAAY,aAAa;CACpC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,GAAG,EAAE,aAAa,yBAAyB,CAAC;EACtD,MAAM,MAAM,OAAO,EAAE,aAAa,uBAAuB,CAAC;EAC1D,SAAS,MAAM,IAAI;GAAE,SAAS;GAAG,aAAa;GAAoB,CAAC;EACnE,SAAS,MAAM,KAAK,EAAE,aAAa,oBAAoB,CAAC;EACxD,QAAQ,MAAM,KAAK,aAAa,EAAE,SAAS,WAAW,CAAC;EACvD,UAAU,MAAM,IAAI;GAAE,SAAS;GAAG,aAAa;GAAwB,CAAC;EAGxE,UAAU,MAAM,IAAI;GAClB,SAAS;GACT,aAAa;GACd,CAAC;EACF,YAAY,MAAM,IAAI;GACpB,SAAS;GACT,aAAa;GACd,CAAC;EACF,WAAW,MAAM,OAAO;GACtB,YAAY;GACZ,aAAa;GACd,CAAC;EACF,gBAAgB,MAAM,OAAO;GAC3B,YAAY;GACZ,aAAa;GACd,CAAC;EAGF,aA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AM,KAAK,EAAE,YAAY,MAAM,CAAC;EAGxC,UAAU,MAAM,OAAO;GACrB,YAAY;GACZ,aAAa;GACd,CAAC;EAGF,KAAK,MAAM,UAAU,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,UAAU,WAAW,CAAC;EACxE;CACD,SAAS,CAAC,MAAM,GAAG,CAAC,SAAS,gBAAgB,CAAC,CAAC;CAChD,CAAC;;;;AAKF,MAAa,cAAc;CAAC;CAAW;CAAoB;CAAmB;;;;AAK9E,MAAaA,yBAAmD;CAC9D,UAAU;CACV,UAAU;CACV,OAAO,CAAC,cAAc;CACvB"}
@@ -0,0 +1,388 @@
1
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
2
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
3
+
4
+ //#region src/events.d.ts
5
+ /**
6
+ * Emitted when a job is enqueued.
7
+ */
8
+ declare const JobEnqueuedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
9
+ jobId: {
10
+ type: _contractspec_lib_schema0.FieldType<string, string>;
11
+ isOptional: false;
12
+ };
13
+ type: {
14
+ type: _contractspec_lib_schema0.FieldType<string, string>;
15
+ isOptional: false;
16
+ };
17
+ priority: {
18
+ type: _contractspec_lib_schema0.FieldType<number, number>;
19
+ isOptional: false;
20
+ };
21
+ scheduledAt: {
22
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
23
+ isOptional: true;
24
+ };
25
+ tenantId: {
26
+ type: _contractspec_lib_schema0.FieldType<string, string>;
27
+ isOptional: true;
28
+ };
29
+ enqueuedAt: {
30
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
31
+ isOptional: false;
32
+ };
33
+ }>>;
34
+ /**
35
+ * Emitted when a job starts processing.
36
+ */
37
+ declare const JobStartedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
38
+ jobId: {
39
+ type: _contractspec_lib_schema0.FieldType<string, string>;
40
+ isOptional: false;
41
+ };
42
+ type: {
43
+ type: _contractspec_lib_schema0.FieldType<string, string>;
44
+ isOptional: false;
45
+ };
46
+ attempt: {
47
+ type: _contractspec_lib_schema0.FieldType<number, number>;
48
+ isOptional: false;
49
+ };
50
+ startedAt: {
51
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
52
+ isOptional: false;
53
+ };
54
+ }>>;
55
+ /**
56
+ * Emitted when a job completes successfully.
57
+ */
58
+ declare const JobCompletedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
59
+ jobId: {
60
+ type: _contractspec_lib_schema0.FieldType<string, string>;
61
+ isOptional: false;
62
+ };
63
+ type: {
64
+ type: _contractspec_lib_schema0.FieldType<string, string>;
65
+ isOptional: false;
66
+ };
67
+ attempt: {
68
+ type: _contractspec_lib_schema0.FieldType<number, number>;
69
+ isOptional: false;
70
+ };
71
+ durationMs: {
72
+ type: _contractspec_lib_schema0.FieldType<number, number>;
73
+ isOptional: false;
74
+ };
75
+ completedAt: {
76
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
77
+ isOptional: false;
78
+ };
79
+ }>>;
80
+ /**
81
+ * Emitted when a job fails (single attempt).
82
+ */
83
+ declare const JobFailedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
84
+ jobId: {
85
+ type: _contractspec_lib_schema0.FieldType<string, string>;
86
+ isOptional: false;
87
+ };
88
+ type: {
89
+ type: _contractspec_lib_schema0.FieldType<string, string>;
90
+ isOptional: false;
91
+ };
92
+ attempt: {
93
+ type: _contractspec_lib_schema0.FieldType<number, number>;
94
+ isOptional: false;
95
+ };
96
+ error: {
97
+ type: _contractspec_lib_schema0.FieldType<string, string>;
98
+ isOptional: false;
99
+ };
100
+ willRetry: {
101
+ type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
102
+ isOptional: false;
103
+ };
104
+ failedAt: {
105
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
106
+ isOptional: false;
107
+ };
108
+ }>>;
109
+ /**
110
+ * Emitted when a job is being retried.
111
+ */
112
+ declare const JobRetryingEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
113
+ jobId: {
114
+ type: _contractspec_lib_schema0.FieldType<string, string>;
115
+ isOptional: false;
116
+ };
117
+ type: {
118
+ type: _contractspec_lib_schema0.FieldType<string, string>;
119
+ isOptional: false;
120
+ };
121
+ attempt: {
122
+ type: _contractspec_lib_schema0.FieldType<number, number>;
123
+ isOptional: false;
124
+ };
125
+ nextAttemptAt: {
126
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
127
+ isOptional: false;
128
+ };
129
+ backoffMs: {
130
+ type: _contractspec_lib_schema0.FieldType<number, number>;
131
+ isOptional: false;
132
+ };
133
+ }>>;
134
+ /**
135
+ * Emitted when a job is moved to dead letter queue.
136
+ */
137
+ declare const JobDeadLetteredEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
138
+ jobId: {
139
+ type: _contractspec_lib_schema0.FieldType<string, string>;
140
+ isOptional: false;
141
+ };
142
+ type: {
143
+ type: _contractspec_lib_schema0.FieldType<string, string>;
144
+ isOptional: false;
145
+ };
146
+ attempts: {
147
+ type: _contractspec_lib_schema0.FieldType<number, number>;
148
+ isOptional: false;
149
+ };
150
+ lastError: {
151
+ type: _contractspec_lib_schema0.FieldType<string, string>;
152
+ isOptional: false;
153
+ };
154
+ deadLetteredAt: {
155
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
156
+ isOptional: false;
157
+ };
158
+ }>>;
159
+ /**
160
+ * Emitted when a job is cancelled.
161
+ */
162
+ declare const JobCancelledEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
163
+ jobId: {
164
+ type: _contractspec_lib_schema0.FieldType<string, string>;
165
+ isOptional: false;
166
+ };
167
+ type: {
168
+ type: _contractspec_lib_schema0.FieldType<string, string>;
169
+ isOptional: false;
170
+ };
171
+ cancelledBy: {
172
+ type: _contractspec_lib_schema0.FieldType<string, string>;
173
+ isOptional: true;
174
+ };
175
+ cancelledAt: {
176
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
177
+ isOptional: false;
178
+ };
179
+ }>>;
180
+ /**
181
+ * Emitted when a scheduled job is triggered.
182
+ */
183
+ declare const ScheduledJobTriggeredEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
184
+ scheduleName: {
185
+ type: _contractspec_lib_schema0.FieldType<string, string>;
186
+ isOptional: false;
187
+ };
188
+ jobId: {
189
+ type: _contractspec_lib_schema0.FieldType<string, string>;
190
+ isOptional: false;
191
+ };
192
+ jobType: {
193
+ type: _contractspec_lib_schema0.FieldType<string, string>;
194
+ isOptional: false;
195
+ };
196
+ triggeredAt: {
197
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
198
+ isOptional: false;
199
+ };
200
+ nextRunAt: {
201
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
202
+ isOptional: true;
203
+ };
204
+ }>>;
205
+ /**
206
+ * All job events.
207
+ */
208
+ declare const JobEvents: {
209
+ JobEnqueuedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
210
+ jobId: {
211
+ type: _contractspec_lib_schema0.FieldType<string, string>;
212
+ isOptional: false;
213
+ };
214
+ type: {
215
+ type: _contractspec_lib_schema0.FieldType<string, string>;
216
+ isOptional: false;
217
+ };
218
+ priority: {
219
+ type: _contractspec_lib_schema0.FieldType<number, number>;
220
+ isOptional: false;
221
+ };
222
+ scheduledAt: {
223
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
224
+ isOptional: true;
225
+ };
226
+ tenantId: {
227
+ type: _contractspec_lib_schema0.FieldType<string, string>;
228
+ isOptional: true;
229
+ };
230
+ enqueuedAt: {
231
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
232
+ isOptional: false;
233
+ };
234
+ }>>;
235
+ JobStartedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
236
+ jobId: {
237
+ type: _contractspec_lib_schema0.FieldType<string, string>;
238
+ isOptional: false;
239
+ };
240
+ type: {
241
+ type: _contractspec_lib_schema0.FieldType<string, string>;
242
+ isOptional: false;
243
+ };
244
+ attempt: {
245
+ type: _contractspec_lib_schema0.FieldType<number, number>;
246
+ isOptional: false;
247
+ };
248
+ startedAt: {
249
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
250
+ isOptional: false;
251
+ };
252
+ }>>;
253
+ JobCompletedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
254
+ jobId: {
255
+ type: _contractspec_lib_schema0.FieldType<string, string>;
256
+ isOptional: false;
257
+ };
258
+ type: {
259
+ type: _contractspec_lib_schema0.FieldType<string, string>;
260
+ isOptional: false;
261
+ };
262
+ attempt: {
263
+ type: _contractspec_lib_schema0.FieldType<number, number>;
264
+ isOptional: false;
265
+ };
266
+ durationMs: {
267
+ type: _contractspec_lib_schema0.FieldType<number, number>;
268
+ isOptional: false;
269
+ };
270
+ completedAt: {
271
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
272
+ isOptional: false;
273
+ };
274
+ }>>;
275
+ JobFailedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
276
+ jobId: {
277
+ type: _contractspec_lib_schema0.FieldType<string, string>;
278
+ isOptional: false;
279
+ };
280
+ type: {
281
+ type: _contractspec_lib_schema0.FieldType<string, string>;
282
+ isOptional: false;
283
+ };
284
+ attempt: {
285
+ type: _contractspec_lib_schema0.FieldType<number, number>;
286
+ isOptional: false;
287
+ };
288
+ error: {
289
+ type: _contractspec_lib_schema0.FieldType<string, string>;
290
+ isOptional: false;
291
+ };
292
+ willRetry: {
293
+ type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
294
+ isOptional: false;
295
+ };
296
+ failedAt: {
297
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
298
+ isOptional: false;
299
+ };
300
+ }>>;
301
+ JobRetryingEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
302
+ jobId: {
303
+ type: _contractspec_lib_schema0.FieldType<string, string>;
304
+ isOptional: false;
305
+ };
306
+ type: {
307
+ type: _contractspec_lib_schema0.FieldType<string, string>;
308
+ isOptional: false;
309
+ };
310
+ attempt: {
311
+ type: _contractspec_lib_schema0.FieldType<number, number>;
312
+ isOptional: false;
313
+ };
314
+ nextAttemptAt: {
315
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
316
+ isOptional: false;
317
+ };
318
+ backoffMs: {
319
+ type: _contractspec_lib_schema0.FieldType<number, number>;
320
+ isOptional: false;
321
+ };
322
+ }>>;
323
+ JobDeadLetteredEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
324
+ jobId: {
325
+ type: _contractspec_lib_schema0.FieldType<string, string>;
326
+ isOptional: false;
327
+ };
328
+ type: {
329
+ type: _contractspec_lib_schema0.FieldType<string, string>;
330
+ isOptional: false;
331
+ };
332
+ attempts: {
333
+ type: _contractspec_lib_schema0.FieldType<number, number>;
334
+ isOptional: false;
335
+ };
336
+ lastError: {
337
+ type: _contractspec_lib_schema0.FieldType<string, string>;
338
+ isOptional: false;
339
+ };
340
+ deadLetteredAt: {
341
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
342
+ isOptional: false;
343
+ };
344
+ }>>;
345
+ JobCancelledEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
346
+ jobId: {
347
+ type: _contractspec_lib_schema0.FieldType<string, string>;
348
+ isOptional: false;
349
+ };
350
+ type: {
351
+ type: _contractspec_lib_schema0.FieldType<string, string>;
352
+ isOptional: false;
353
+ };
354
+ cancelledBy: {
355
+ type: _contractspec_lib_schema0.FieldType<string, string>;
356
+ isOptional: true;
357
+ };
358
+ cancelledAt: {
359
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
360
+ isOptional: false;
361
+ };
362
+ }>>;
363
+ ScheduledJobTriggeredEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
364
+ scheduleName: {
365
+ type: _contractspec_lib_schema0.FieldType<string, string>;
366
+ isOptional: false;
367
+ };
368
+ jobId: {
369
+ type: _contractspec_lib_schema0.FieldType<string, string>;
370
+ isOptional: false;
371
+ };
372
+ jobType: {
373
+ type: _contractspec_lib_schema0.FieldType<string, string>;
374
+ isOptional: false;
375
+ };
376
+ triggeredAt: {
377
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
378
+ isOptional: false;
379
+ };
380
+ nextRunAt: {
381
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
382
+ isOptional: true;
383
+ };
384
+ }>>;
385
+ };
386
+ //#endregion
387
+ export { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent };
388
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"sourcesContent":[],"mappings":";;;;;;;cA0Ga,kBAAgB,4BAAA,CAAA,oCAAA;EAAhB,KAAA,EAAA;IAUX,IAAA,EAAA,yBAAA,CAAA,SAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;6CAV2B,CAAA,MAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;EAAA,CAAA;EAehB,WAAA,EAAA;IAUX,IAAA,qCAAA,KAAA,EAAA,MAAA,CAAA;;;;;;EAV0B,CAAA;EAAA,UAAA,EAAA;IAef,IAAA,qCAUX,KAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;;;;;cAzBW,eAeiB,EAfF,4BAAA,CAAA,SAeE,2BAfF,WAeE,CAAA;EAAA,KAAA,EAAA;IAAA,IAAA,EAL5B,yBAAA,CAAA,SAK4B,CAAA,MAA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