@lssm/lib.jobs 0.0.0-canary-20251217062943 → 0.0.0-canary-20251217072406
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/_virtual/rolldown_runtime.js +42 -1
- package/dist/contracts/dist/capabilities/openbanking.js +88 -1
- package/dist/contracts/dist/client/index.js +5 -1
- package/dist/contracts/dist/client/react/feature-render.js +2 -1
- package/dist/contracts/dist/client/react/form-render.js +4 -1
- package/dist/contracts/dist/client/react/index.js +4 -1
- package/dist/contracts/dist/contract-registry/index.js +1 -1
- package/dist/contracts/dist/contract-registry/schemas.js +60 -1
- package/dist/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
- package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
- package/dist/contracts/dist/docs/index.js +29 -1
- package/dist/contracts/dist/docs/presentations.js +71 -1
- package/dist/contracts/dist/docs/registry.js +44 -1
- package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
- package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
- package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
- package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
- package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
- package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
- package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
- package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
- package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
- package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
- package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
- package/dist/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
- package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
- package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
- package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
- package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
- package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
- package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
- package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
- package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
- package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
- package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
- package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
- package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
- package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
- package/dist/contracts/dist/events.js +10 -1
- package/dist/contracts/dist/experiments/evaluator.js +1 -1
- package/dist/contracts/dist/index.js +71 -1
- package/dist/contracts/dist/install.js +2 -1
- package/dist/contracts/dist/integrations/contracts.js +377 -1
- package/dist/contracts/dist/integrations/index.js +18 -1
- package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
- package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
- package/dist/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
- package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
- package/dist/contracts/dist/integrations/openbanking/models.js +242 -1
- package/dist/contracts/dist/integrations/openbanking/telemetry.js +13 -1
- package/dist/contracts/dist/integrations/providers/elevenlabs.js +52 -1
- package/dist/contracts/dist/integrations/providers/gcs-storage.js +75 -1
- package/dist/contracts/dist/integrations/providers/gmail.js +87 -1
- package/dist/contracts/dist/integrations/providers/google-calendar.js +66 -1
- package/dist/contracts/dist/integrations/providers/index.js +11 -1
- package/dist/contracts/dist/integrations/providers/mistral.js +68 -1
- package/dist/contracts/dist/integrations/providers/postmark.js +68 -1
- package/dist/contracts/dist/integrations/providers/powens.js +116 -1
- package/dist/contracts/dist/integrations/providers/qdrant.js +73 -1
- package/dist/contracts/dist/integrations/providers/registry.js +10 -1
- package/dist/contracts/dist/integrations/providers/stripe.js +83 -1
- package/dist/contracts/dist/integrations/providers/twilio-sms.js +61 -1
- package/dist/contracts/dist/jobs/queue.js +33 -1
- package/dist/contracts/dist/jsonschema.js +1 -1
- package/dist/contracts/dist/knowledge/contracts.js +306 -1
- package/dist/contracts/dist/knowledge/index.js +7 -1
- package/dist/contracts/dist/knowledge/spaces/email-threads.js +34 -1
- package/dist/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
- package/dist/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
- package/dist/contracts/dist/knowledge/spaces/index.js +6 -1
- package/dist/contracts/dist/knowledge/spaces/product-canon.js +34 -1
- package/dist/contracts/dist/knowledge/spaces/support-faq.js +37 -1
- package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
- package/dist/contracts/dist/llm/exporters.js +19 -1
- package/dist/contracts/dist/llm/index.js +2 -1
- package/dist/contracts/dist/llm/prompts.js +1 -1
- package/dist/contracts/dist/onboarding-base.js +196 -1
- package/dist/contracts/dist/openapi.js +1 -1
- package/dist/contracts/dist/ownership.js +21 -1
- package/dist/contracts/dist/presentations.js +1 -1
- package/dist/contracts/dist/presentations.v2.js +11 -1
- package/dist/contracts/dist/prompt.js +1 -1
- package/dist/contracts/dist/promptRegistry.js +1 -1
- package/dist/contracts/dist/regenerator/index.js +1 -1
- package/dist/contracts/dist/regenerator/service.js +6 -1
- package/dist/contracts/dist/registry.js +2 -1
- package/dist/contracts/dist/resources.js +1 -1
- package/dist/contracts/dist/schema/dist/EnumType.js +2 -1
- package/dist/contracts/dist/schema/dist/FieldType.js +49 -1
- package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/contracts/dist/schema/dist/SchemaModel.js +34 -1
- package/dist/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/contracts/dist/schema/dist/entity/index.js +2 -1
- package/dist/contracts/dist/schema/dist/entity/types.js +1 -1
- package/dist/contracts/dist/schema/dist/index.js +6 -1
- package/dist/contracts/dist/server/graphql-pothos.js +6 -1
- package/dist/contracts/dist/server/index.js +8 -1
- package/dist/contracts/dist/server/mcp/createMcpServer.js +4 -1
- package/dist/contracts/dist/server/mcp/registerPresentations.js +2 -1
- package/dist/contracts/dist/server/mcp/registerPrompts.js +1 -1
- package/dist/contracts/dist/server/mcp/registerResources.js +2 -1
- package/dist/contracts/dist/server/mcp/registerTools.js +1 -1
- package/dist/contracts/dist/server/provider-mcp.js +1 -1
- package/dist/contracts/dist/server/rest-elysia.js +1 -1
- package/dist/contracts/dist/server/rest-express.js +1 -1
- package/dist/contracts/dist/server/rest-generic.js +1 -1
- package/dist/contracts/dist/server/rest-next-app.js +1 -1
- package/dist/contracts/dist/server/rest-next-pages.js +1 -1
- package/dist/contracts/dist/spec.js +34 -1
- package/dist/contracts/dist/telemetry/index.js +1 -1
- package/dist/contracts/dist/telemetry/tracker.js +1 -1
- package/dist/contracts/dist/tests/index.js +1 -1
- package/dist/contracts/dist/tests/runner.js +2 -1
- package/dist/contracts/dist/workflow/index.js +1 -1
- package/dist/contracts/dist/workflow/runner.js +1 -1
- package/dist/contracts/index.d.ts +138 -138
- package/dist/contracts/index.js +484 -1
- package/dist/entities/index.d.ts +116 -116
- package/dist/entities/index.js +198 -1
- package/dist/events.js +303 -1
- package/dist/handlers/gmail-sync-handler.js +9 -1
- package/dist/handlers/index.js +12 -1
- package/dist/handlers/ping-job.d.ts +3 -3
- package/dist/handlers/ping-job.js +13 -1
- package/dist/handlers/storage-document-handler.js +14 -1
- package/dist/index.js +18 -1
- package/dist/jobs.feature.js +101 -1
- package/dist/queue/gcp-cloud-tasks.js +61 -1
- package/dist/queue/gcp-pubsub.js +47 -1
- package/dist/queue/index.js +9 -1
- package/dist/queue/memory-queue.js +140 -1
- package/dist/queue/register-defined-job.js +15 -1
- package/dist/queue/scaleway-sqs-queue.js +175 -1
- package/dist/queue/types.js +3 -1
- package/dist/scheduler/index.js +145 -1
- package/dist/schema/dist/EnumType.js +2 -1
- package/dist/schema/dist/FieldType.js +49 -1
- package/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/schema/dist/SchemaModel.js +39 -1
- package/dist/schema/dist/entity/defineEntity.js +236 -1
- package/dist/schema/dist/entity/index.js +2 -1
- package/dist/schema/dist/entity/types.js +1 -1
- package/dist/schema/dist/index.js +6 -1
- package/package.json +7 -6
package/dist/events.js
CHANGED
|
@@ -1 +1,303 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { ScalarTypeEnum } from "./schema/dist/ScalarTypeEnum.js";
|
|
2
|
+
import { defineSchemaModel } from "./schema/dist/SchemaModel.js";
|
|
3
|
+
import "./schema/dist/index.js";
|
|
4
|
+
import { defineEvent } from "./contracts/dist/events.js";
|
|
5
|
+
import "./contracts/dist/index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/events.ts
|
|
8
|
+
const JobEnqueuedPayload = defineSchemaModel({
|
|
9
|
+
name: "JobEnqueuedEventPayload",
|
|
10
|
+
description: "Payload when a job is added to the queue",
|
|
11
|
+
fields: {
|
|
12
|
+
jobId: {
|
|
13
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
14
|
+
isOptional: false
|
|
15
|
+
},
|
|
16
|
+
type: {
|
|
17
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
18
|
+
isOptional: false
|
|
19
|
+
},
|
|
20
|
+
priority: {
|
|
21
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
22
|
+
isOptional: false
|
|
23
|
+
},
|
|
24
|
+
scheduledAt: {
|
|
25
|
+
type: ScalarTypeEnum.DateTime(),
|
|
26
|
+
isOptional: true
|
|
27
|
+
},
|
|
28
|
+
tenantId: {
|
|
29
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
30
|
+
isOptional: true
|
|
31
|
+
},
|
|
32
|
+
enqueuedAt: {
|
|
33
|
+
type: ScalarTypeEnum.DateTime(),
|
|
34
|
+
isOptional: false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const JobStartedPayload = defineSchemaModel({
|
|
39
|
+
name: "JobStartedEventPayload",
|
|
40
|
+
description: "Payload when a job starts processing",
|
|
41
|
+
fields: {
|
|
42
|
+
jobId: {
|
|
43
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
44
|
+
isOptional: false
|
|
45
|
+
},
|
|
46
|
+
type: {
|
|
47
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
48
|
+
isOptional: false
|
|
49
|
+
},
|
|
50
|
+
attempt: {
|
|
51
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
52
|
+
isOptional: false
|
|
53
|
+
},
|
|
54
|
+
startedAt: {
|
|
55
|
+
type: ScalarTypeEnum.DateTime(),
|
|
56
|
+
isOptional: false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const JobCompletedPayload = defineSchemaModel({
|
|
61
|
+
name: "JobCompletedEventPayload",
|
|
62
|
+
description: "Payload when a job completes successfully",
|
|
63
|
+
fields: {
|
|
64
|
+
jobId: {
|
|
65
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
66
|
+
isOptional: false
|
|
67
|
+
},
|
|
68
|
+
type: {
|
|
69
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
70
|
+
isOptional: false
|
|
71
|
+
},
|
|
72
|
+
attempt: {
|
|
73
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
74
|
+
isOptional: false
|
|
75
|
+
},
|
|
76
|
+
durationMs: {
|
|
77
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
78
|
+
isOptional: false
|
|
79
|
+
},
|
|
80
|
+
completedAt: {
|
|
81
|
+
type: ScalarTypeEnum.DateTime(),
|
|
82
|
+
isOptional: false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const JobFailedPayload = defineSchemaModel({
|
|
87
|
+
name: "JobFailedEventPayload",
|
|
88
|
+
description: "Payload when a job attempt fails",
|
|
89
|
+
fields: {
|
|
90
|
+
jobId: {
|
|
91
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
92
|
+
isOptional: false
|
|
93
|
+
},
|
|
94
|
+
type: {
|
|
95
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
96
|
+
isOptional: false
|
|
97
|
+
},
|
|
98
|
+
attempt: {
|
|
99
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
100
|
+
isOptional: false
|
|
101
|
+
},
|
|
102
|
+
error: {
|
|
103
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
104
|
+
isOptional: false
|
|
105
|
+
},
|
|
106
|
+
willRetry: {
|
|
107
|
+
type: ScalarTypeEnum.Boolean(),
|
|
108
|
+
isOptional: false
|
|
109
|
+
},
|
|
110
|
+
failedAt: {
|
|
111
|
+
type: ScalarTypeEnum.DateTime(),
|
|
112
|
+
isOptional: false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const JobRetryingPayload = defineSchemaModel({
|
|
117
|
+
name: "JobRetryingEventPayload",
|
|
118
|
+
description: "Payload when a job is scheduled for retry",
|
|
119
|
+
fields: {
|
|
120
|
+
jobId: {
|
|
121
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
122
|
+
isOptional: false
|
|
123
|
+
},
|
|
124
|
+
type: {
|
|
125
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
126
|
+
isOptional: false
|
|
127
|
+
},
|
|
128
|
+
attempt: {
|
|
129
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
130
|
+
isOptional: false
|
|
131
|
+
},
|
|
132
|
+
nextAttemptAt: {
|
|
133
|
+
type: ScalarTypeEnum.DateTime(),
|
|
134
|
+
isOptional: false
|
|
135
|
+
},
|
|
136
|
+
backoffMs: {
|
|
137
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
138
|
+
isOptional: false
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
const JobDeadLetteredPayload = defineSchemaModel({
|
|
143
|
+
name: "JobDeadLetteredEventPayload",
|
|
144
|
+
description: "Payload when a job is moved to dead letter queue",
|
|
145
|
+
fields: {
|
|
146
|
+
jobId: {
|
|
147
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
148
|
+
isOptional: false
|
|
149
|
+
},
|
|
150
|
+
type: {
|
|
151
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
152
|
+
isOptional: false
|
|
153
|
+
},
|
|
154
|
+
attempts: {
|
|
155
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
156
|
+
isOptional: false
|
|
157
|
+
},
|
|
158
|
+
lastError: {
|
|
159
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
160
|
+
isOptional: false
|
|
161
|
+
},
|
|
162
|
+
deadLetteredAt: {
|
|
163
|
+
type: ScalarTypeEnum.DateTime(),
|
|
164
|
+
isOptional: false
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const JobCancelledPayload = defineSchemaModel({
|
|
169
|
+
name: "JobCancelledEventPayload",
|
|
170
|
+
description: "Payload when a job is cancelled",
|
|
171
|
+
fields: {
|
|
172
|
+
jobId: {
|
|
173
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
174
|
+
isOptional: false
|
|
175
|
+
},
|
|
176
|
+
type: {
|
|
177
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
178
|
+
isOptional: false
|
|
179
|
+
},
|
|
180
|
+
cancelledBy: {
|
|
181
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
182
|
+
isOptional: true
|
|
183
|
+
},
|
|
184
|
+
cancelledAt: {
|
|
185
|
+
type: ScalarTypeEnum.DateTime(),
|
|
186
|
+
isOptional: false
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const ScheduledJobTriggeredPayload = defineSchemaModel({
|
|
191
|
+
name: "ScheduledJobTriggeredEventPayload",
|
|
192
|
+
description: "Payload when a scheduled job is triggered",
|
|
193
|
+
fields: {
|
|
194
|
+
scheduleName: {
|
|
195
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
196
|
+
isOptional: false
|
|
197
|
+
},
|
|
198
|
+
jobId: {
|
|
199
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
200
|
+
isOptional: false
|
|
201
|
+
},
|
|
202
|
+
jobType: {
|
|
203
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
204
|
+
isOptional: false
|
|
205
|
+
},
|
|
206
|
+
triggeredAt: {
|
|
207
|
+
type: ScalarTypeEnum.DateTime(),
|
|
208
|
+
isOptional: false
|
|
209
|
+
},
|
|
210
|
+
nextRunAt: {
|
|
211
|
+
type: ScalarTypeEnum.DateTime(),
|
|
212
|
+
isOptional: true
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* Emitted when a job is enqueued.
|
|
218
|
+
*/
|
|
219
|
+
const JobEnqueuedEvent = defineEvent({
|
|
220
|
+
name: "job.enqueued",
|
|
221
|
+
version: 1,
|
|
222
|
+
description: "A job has been added to the queue.",
|
|
223
|
+
payload: JobEnqueuedPayload
|
|
224
|
+
});
|
|
225
|
+
/**
|
|
226
|
+
* Emitted when a job starts processing.
|
|
227
|
+
*/
|
|
228
|
+
const JobStartedEvent = defineEvent({
|
|
229
|
+
name: "job.started",
|
|
230
|
+
version: 1,
|
|
231
|
+
description: "A job has started processing.",
|
|
232
|
+
payload: JobStartedPayload
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* Emitted when a job completes successfully.
|
|
236
|
+
*/
|
|
237
|
+
const JobCompletedEvent = defineEvent({
|
|
238
|
+
name: "job.completed",
|
|
239
|
+
version: 1,
|
|
240
|
+
description: "A job has completed successfully.",
|
|
241
|
+
payload: JobCompletedPayload
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* Emitted when a job fails (single attempt).
|
|
245
|
+
*/
|
|
246
|
+
const JobFailedEvent = defineEvent({
|
|
247
|
+
name: "job.failed",
|
|
248
|
+
version: 1,
|
|
249
|
+
description: "A job attempt has failed.",
|
|
250
|
+
payload: JobFailedPayload
|
|
251
|
+
});
|
|
252
|
+
/**
|
|
253
|
+
* Emitted when a job is being retried.
|
|
254
|
+
*/
|
|
255
|
+
const JobRetryingEvent = defineEvent({
|
|
256
|
+
name: "job.retrying",
|
|
257
|
+
version: 1,
|
|
258
|
+
description: "A job is being scheduled for retry.",
|
|
259
|
+
payload: JobRetryingPayload
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* Emitted when a job is moved to dead letter queue.
|
|
263
|
+
*/
|
|
264
|
+
const JobDeadLetteredEvent = defineEvent({
|
|
265
|
+
name: "job.dead_lettered",
|
|
266
|
+
version: 1,
|
|
267
|
+
description: "A job has exhausted all retries and moved to dead letter queue.",
|
|
268
|
+
payload: JobDeadLetteredPayload
|
|
269
|
+
});
|
|
270
|
+
/**
|
|
271
|
+
* Emitted when a job is cancelled.
|
|
272
|
+
*/
|
|
273
|
+
const JobCancelledEvent = defineEvent({
|
|
274
|
+
name: "job.cancelled",
|
|
275
|
+
version: 1,
|
|
276
|
+
description: "A job has been cancelled.",
|
|
277
|
+
payload: JobCancelledPayload
|
|
278
|
+
});
|
|
279
|
+
/**
|
|
280
|
+
* Emitted when a scheduled job is triggered.
|
|
281
|
+
*/
|
|
282
|
+
const ScheduledJobTriggeredEvent = defineEvent({
|
|
283
|
+
name: "scheduler.job_triggered",
|
|
284
|
+
version: 1,
|
|
285
|
+
description: "A scheduled job has been triggered.",
|
|
286
|
+
payload: ScheduledJobTriggeredPayload
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* All job events.
|
|
290
|
+
*/
|
|
291
|
+
const JobEvents = {
|
|
292
|
+
JobEnqueuedEvent,
|
|
293
|
+
JobStartedEvent,
|
|
294
|
+
JobCompletedEvent,
|
|
295
|
+
JobFailedEvent,
|
|
296
|
+
JobRetryingEvent,
|
|
297
|
+
JobDeadLetteredEvent,
|
|
298
|
+
JobCancelledEvent,
|
|
299
|
+
ScheduledJobTriggeredEvent
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
export { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent };
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/handlers/gmail-sync-handler.ts
|
|
2
|
+
function createGmailSyncHandler(adapter) {
|
|
3
|
+
return async (job) => {
|
|
4
|
+
await adapter.syncThreads(job.payload);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createGmailSyncHandler };
|
package/dist/handlers/index.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{registerDefinedJob
|
|
1
|
+
import { registerDefinedJob } from "../queue/register-defined-job.js";
|
|
2
|
+
import { PING_JOB_TYPE, PingPayloadSchema, pingJob } from "./ping-job.js";
|
|
3
|
+
import { createGmailSyncHandler } from "./gmail-sync-handler.js";
|
|
4
|
+
import { createStorageDocumentHandler } from "./storage-document-handler.js";
|
|
5
|
+
|
|
6
|
+
//#region src/handlers/index.ts
|
|
7
|
+
function registerAllJobs(queue) {
|
|
8
|
+
registerDefinedJob(queue, pingJob);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PING_JOB_TYPE, PingPayloadSchema, createGmailSyncHandler, createStorageDocumentHandler, pingJob, registerAllJobs };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
1
|
+
import * as z$1 from "zod";
|
|
2
2
|
import { DefinedJob } from "@lssm/lib.contracts/jobs/define-job";
|
|
3
3
|
|
|
4
4
|
//#region src/handlers/ping-job.d.ts
|
|
5
5
|
declare const PING_JOB_TYPE: "core.ping";
|
|
6
|
-
declare const PingPayloadSchema: z.ZodObject<{}, z.core.$strip>;
|
|
7
|
-
type PingPayload = z.infer<typeof PingPayloadSchema>;
|
|
6
|
+
declare const PingPayloadSchema: z$1.ZodObject<{}, z$1.core.$strip>;
|
|
7
|
+
type PingPayload = z$1.infer<typeof PingPayloadSchema>;
|
|
8
8
|
declare const pingJob: DefinedJob<PingPayload>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { PING_JOB_TYPE, PingPayload, PingPayloadSchema, pingJob };
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import * as z$1 from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/handlers/ping-job.ts
|
|
4
|
+
const PING_JOB_TYPE = "core.ping";
|
|
5
|
+
const PingPayloadSchema = z$1.object({});
|
|
6
|
+
const pingJob = {
|
|
7
|
+
type: PING_JOB_TYPE,
|
|
8
|
+
schema: PingPayloadSchema,
|
|
9
|
+
handler: async (_payload, _job) => {}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { PING_JOB_TYPE, PingPayloadSchema, pingJob };
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/handlers/storage-document-handler.ts
|
|
2
|
+
function createStorageDocumentHandler(storage, adapter) {
|
|
3
|
+
return async (job) => {
|
|
4
|
+
const object = await storage.getObject({
|
|
5
|
+
bucket: job.payload.bucket,
|
|
6
|
+
key: job.payload.key
|
|
7
|
+
});
|
|
8
|
+
if (!object) throw new Error(`Object ${job.payload.bucket}/${job.payload.key} not found`);
|
|
9
|
+
await adapter.ingestObject(object);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createStorageDocumentHandler };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent } from "./events.js";
|
|
2
|
+
import { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution } from "./entities/index.js";
|
|
3
|
+
import { DEFAULT_RETRY_POLICY, calculateBackoff, defineJobType } from "./contracts/dist/jobs/queue.js";
|
|
4
|
+
import { MemoryJobQueue } from "./queue/memory-queue.js";
|
|
5
|
+
import { ScalewaySqsJobQueue } from "./queue/scaleway-sqs-queue.js";
|
|
6
|
+
import { GcpCloudTasksQueue } from "./queue/gcp-cloud-tasks.js";
|
|
7
|
+
import { GcpPubSubQueue } from "./queue/gcp-pubsub.js";
|
|
8
|
+
import { registerDefinedJob } from "./queue/register-defined-job.js";
|
|
9
|
+
import "./queue/index.js";
|
|
10
|
+
import { PING_JOB_TYPE, PingPayloadSchema, pingJob } from "./handlers/ping-job.js";
|
|
11
|
+
import { createGmailSyncHandler } from "./handlers/gmail-sync-handler.js";
|
|
12
|
+
import { createStorageDocumentHandler } from "./handlers/storage-document-handler.js";
|
|
13
|
+
import { registerAllJobs } from "./handlers/index.js";
|
|
14
|
+
import { JobScheduler, createScheduler, defineSchedule } from "./scheduler/index.js";
|
|
15
|
+
import { CancelJobContract, CreateScheduledJobContract, EnqueueJobContract, GetJobContract, GetQueueStatsContract, JobModel, ListScheduledJobsContract, QueueStatsModel, ScheduledJobModel, ToggleScheduledJobContract } from "./contracts/index.js";
|
|
16
|
+
import { JobsFeature } from "./jobs.feature.js";
|
|
17
|
+
|
|
18
|
+
export { CancelJobContract, CreateScheduledJobContract, DEFAULT_RETRY_POLICY, EnqueueJobContract, GcpCloudTasksQueue, GcpPubSubQueue, GetJobContract, GetQueueStatsContract, JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEntity, JobEvents, JobExecutionEntity, JobFailedEvent, JobModel, JobRetryingEvent, JobScheduler, JobStartedEvent, JobStatusEnum, JobsFeature, ListScheduledJobsContract, MemoryJobQueue, PING_JOB_TYPE, PingPayloadSchema, QueueStatsModel, ScalewaySqsJobQueue, ScheduledJobEntity, ScheduledJobModel, ScheduledJobTriggeredEvent, ToggleScheduledJobContract, calculateBackoff, createGmailSyncHandler, createScheduler, createStorageDocumentHandler, defineJobType, defineSchedule, jobEntities, jobsSchemaContribution, pingJob, registerAllJobs, registerDefinedJob };
|
package/dist/jobs.feature.js
CHANGED
|
@@ -1 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/jobs.feature.ts
|
|
2
|
+
/**
|
|
3
|
+
* Jobs feature module that bundles job queue management,
|
|
4
|
+
* background processing, and scheduled task capabilities.
|
|
5
|
+
*/
|
|
6
|
+
const JobsFeature = {
|
|
7
|
+
meta: {
|
|
8
|
+
key: "jobs",
|
|
9
|
+
title: "Background Jobs",
|
|
10
|
+
description: "Background job processing, scheduling, and queue management",
|
|
11
|
+
domain: "platform",
|
|
12
|
+
owners: ["@platform.jobs"],
|
|
13
|
+
tags: [
|
|
14
|
+
"jobs",
|
|
15
|
+
"queue",
|
|
16
|
+
"background",
|
|
17
|
+
"scheduler"
|
|
18
|
+
],
|
|
19
|
+
stability: "stable"
|
|
20
|
+
},
|
|
21
|
+
operations: [
|
|
22
|
+
{
|
|
23
|
+
name: "jobs.enqueue",
|
|
24
|
+
version: 1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "jobs.cancel",
|
|
28
|
+
version: 1
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "jobs.get",
|
|
32
|
+
version: 1
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "jobs.stats",
|
|
36
|
+
version: 1
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "jobs.schedule.create",
|
|
40
|
+
version: 1
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "jobs.schedule.toggle",
|
|
44
|
+
version: 1
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "jobs.schedule.list",
|
|
48
|
+
version: 1
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
events: [
|
|
52
|
+
{
|
|
53
|
+
name: "job.enqueued",
|
|
54
|
+
version: 1
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "job.started",
|
|
58
|
+
version: 1
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "job.completed",
|
|
62
|
+
version: 1
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "job.failed",
|
|
66
|
+
version: 1
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "job.retrying",
|
|
70
|
+
version: 1
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "job.dead_lettered",
|
|
74
|
+
version: 1
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "job.cancelled",
|
|
78
|
+
version: 1
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "scheduler.job_triggered",
|
|
82
|
+
version: 1
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
presentations: [],
|
|
86
|
+
opToPresentation: [],
|
|
87
|
+
presentationsTargets: [],
|
|
88
|
+
capabilities: {
|
|
89
|
+
provides: [{
|
|
90
|
+
key: "jobs",
|
|
91
|
+
version: 1
|
|
92
|
+
}, {
|
|
93
|
+
key: "scheduler",
|
|
94
|
+
version: 1
|
|
95
|
+
}],
|
|
96
|
+
requires: []
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { JobsFeature };
|
|
@@ -1 +1,61 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { DEFAULT_RETRY_POLICY } from "../contracts/dist/jobs/queue.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/queue/gcp-cloud-tasks.ts
|
|
6
|
+
var GcpCloudTasksQueue = class {
|
|
7
|
+
handlers = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
async enqueue(jobType, payload, options = {}) {
|
|
12
|
+
const now = /* @__PURE__ */ new Date();
|
|
13
|
+
const enqueueTime = options.delaySeconds != null ? { seconds: Math.floor(Date.now() / 1e3) + options.delaySeconds } : void 0;
|
|
14
|
+
const body = Buffer.from(JSON.stringify({
|
|
15
|
+
id: randomUUID(),
|
|
16
|
+
type: jobType,
|
|
17
|
+
payload
|
|
18
|
+
}), "utf-8");
|
|
19
|
+
await this.options.client.createTask({
|
|
20
|
+
parent: `projects/${this.options.projectId}/locations/${this.options.location}/queues/${this.options.queue}`,
|
|
21
|
+
task: {
|
|
22
|
+
httpRequest: {
|
|
23
|
+
httpMethod: "POST",
|
|
24
|
+
url: this.options.resolveUrl(jobType),
|
|
25
|
+
body,
|
|
26
|
+
headers: { "Content-Type": "application/json" },
|
|
27
|
+
oidcToken: this.options.serviceAccountEmail ? { serviceAccountEmail: this.options.serviceAccountEmail } : void 0
|
|
28
|
+
},
|
|
29
|
+
scheduleTime: enqueueTime
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
id: randomUUID(),
|
|
34
|
+
type: jobType,
|
|
35
|
+
version: 1,
|
|
36
|
+
payload,
|
|
37
|
+
status: "pending",
|
|
38
|
+
priority: options.priority ?? 0,
|
|
39
|
+
attempts: 0,
|
|
40
|
+
maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
|
|
41
|
+
createdAt: now,
|
|
42
|
+
updatedAt: now,
|
|
43
|
+
scheduledAt: options.delaySeconds ? new Date(now.getTime() + options.delaySeconds * 1e3) : now,
|
|
44
|
+
dedupeKey: options.dedupeKey,
|
|
45
|
+
tenantId: options.tenantId,
|
|
46
|
+
userId: options.userId,
|
|
47
|
+
traceId: options.traceId,
|
|
48
|
+
metadata: options.metadata
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
register(jobType, handler) {
|
|
52
|
+
this.handlers.set(jobType, handler);
|
|
53
|
+
}
|
|
54
|
+
start() {}
|
|
55
|
+
async stop() {
|
|
56
|
+
this.handlers.clear();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { GcpCloudTasksQueue };
|
package/dist/queue/gcp-pubsub.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { DEFAULT_RETRY_POLICY } from "../contracts/dist/jobs/queue.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/queue/gcp-pubsub.ts
|
|
6
|
+
var GcpPubSubQueue = class {
|
|
7
|
+
handlers = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
async enqueue(jobType, payload, options = {}) {
|
|
12
|
+
const now = /* @__PURE__ */ new Date();
|
|
13
|
+
await this.options.client.topic(this.options.topicName).publishMessage({ data: Buffer.from(JSON.stringify({
|
|
14
|
+
id: randomUUID(),
|
|
15
|
+
type: jobType,
|
|
16
|
+
payload
|
|
17
|
+
}), "utf-8") });
|
|
18
|
+
return {
|
|
19
|
+
id: randomUUID(),
|
|
20
|
+
type: jobType,
|
|
21
|
+
version: 1,
|
|
22
|
+
payload,
|
|
23
|
+
status: "pending",
|
|
24
|
+
priority: options.priority ?? 0,
|
|
25
|
+
attempts: 0,
|
|
26
|
+
maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
|
|
27
|
+
createdAt: now,
|
|
28
|
+
updatedAt: now,
|
|
29
|
+
scheduledAt: options.delaySeconds ? new Date(now.getTime() + options.delaySeconds * 1e3) : now,
|
|
30
|
+
dedupeKey: options.dedupeKey,
|
|
31
|
+
tenantId: options.tenantId,
|
|
32
|
+
userId: options.userId,
|
|
33
|
+
traceId: options.traceId,
|
|
34
|
+
metadata: options.metadata
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
register(jobType, handler) {
|
|
38
|
+
this.handlers.set(jobType, handler);
|
|
39
|
+
}
|
|
40
|
+
start() {}
|
|
41
|
+
async stop() {
|
|
42
|
+
this.handlers.clear();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { GcpPubSubQueue };
|
package/dist/queue/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { DEFAULT_RETRY_POLICY, calculateBackoff, defineJobType } from "../contracts/dist/jobs/queue.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
import { MemoryJobQueue } from "./memory-queue.js";
|
|
4
|
+
import { ScalewaySqsJobQueue } from "./scaleway-sqs-queue.js";
|
|
5
|
+
import { GcpCloudTasksQueue } from "./gcp-cloud-tasks.js";
|
|
6
|
+
import { GcpPubSubQueue } from "./gcp-pubsub.js";
|
|
7
|
+
import { registerDefinedJob } from "./register-defined-job.js";
|
|
8
|
+
|
|
9
|
+
export { DEFAULT_RETRY_POLICY, GcpCloudTasksQueue, GcpPubSubQueue, MemoryJobQueue, ScalewaySqsJobQueue, calculateBackoff, defineJobType, registerDefinedJob };
|