@lssm/lib.jobs 0.0.0-canary-20251217072406 → 0.0.0-canary-20251217073102
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 +1 -42
- package/dist/contracts/dist/capabilities/openbanking.js +1 -88
- package/dist/contracts/dist/client/index.js +1 -5
- package/dist/contracts/dist/client/react/feature-render.js +1 -2
- package/dist/contracts/dist/client/react/form-render.js +1 -4
- package/dist/contracts/dist/client/react/index.js +1 -4
- package/dist/contracts/dist/contract-registry/index.js +1 -1
- package/dist/contracts/dist/contract-registry/schemas.js +1 -60
- package/dist/contracts/dist/docs/PUBLISHING.docblock.js +76 -16
- package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +350 -16
- package/dist/contracts/dist/docs/index.js +1 -29
- package/dist/contracts/dist/docs/presentations.js +1 -71
- package/dist/contracts/dist/docs/registry.js +1 -44
- package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +383 -16
- package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +68 -16
- package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +140 -16
- package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +86 -16
- package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +1 -16
- package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +2 -24
- package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +2 -21
- package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +213 -16
- package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +5 -73
- package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +1 -37
- package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +1 -16
- package/dist/contracts/dist/docs/tech/schema/README.docblock.js +262 -20
- package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +1 -48
- package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +2 -24
- package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +2 -23
- package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +16 -25
- package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +1 -67
- package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +2 -22
- package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +36 -40
- package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +1 -47
- package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +2 -23
- package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +3 -36
- package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +1 -20
- package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +3 -36
- package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +1 -20
- package/dist/contracts/dist/events.js +1 -10
- package/dist/contracts/dist/experiments/evaluator.js +1 -1
- package/dist/contracts/dist/index.js +1 -71
- package/dist/contracts/dist/install.js +1 -2
- package/dist/contracts/dist/integrations/contracts.js +1 -377
- package/dist/contracts/dist/integrations/index.js +1 -18
- package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +1 -228
- package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +1 -159
- package/dist/contracts/dist/integrations/openbanking/contracts/index.js +1 -3
- package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +1 -210
- package/dist/contracts/dist/integrations/openbanking/models.js +1 -242
- package/dist/contracts/dist/integrations/openbanking/telemetry.js +1 -13
- package/dist/contracts/dist/integrations/providers/elevenlabs.js +1 -52
- package/dist/contracts/dist/integrations/providers/gcs-storage.js +1 -75
- package/dist/contracts/dist/integrations/providers/gmail.js +1 -87
- package/dist/contracts/dist/integrations/providers/google-calendar.js +1 -66
- package/dist/contracts/dist/integrations/providers/index.js +1 -11
- package/dist/contracts/dist/integrations/providers/mistral.js +1 -68
- package/dist/contracts/dist/integrations/providers/postmark.js +1 -68
- package/dist/contracts/dist/integrations/providers/powens.js +1 -116
- package/dist/contracts/dist/integrations/providers/qdrant.js +1 -73
- package/dist/contracts/dist/integrations/providers/registry.js +1 -10
- package/dist/contracts/dist/integrations/providers/stripe.js +1 -83
- package/dist/contracts/dist/integrations/providers/twilio-sms.js +1 -61
- package/dist/contracts/dist/jobs/queue.js +1 -33
- package/dist/contracts/dist/jsonschema.js +1 -1
- package/dist/contracts/dist/knowledge/contracts.js +1 -306
- package/dist/contracts/dist/knowledge/index.js +1 -7
- package/dist/contracts/dist/knowledge/spaces/email-threads.js +1 -34
- package/dist/contracts/dist/knowledge/spaces/financial-docs.js +1 -34
- package/dist/contracts/dist/knowledge/spaces/financial-overview.js +1 -38
- package/dist/contracts/dist/knowledge/spaces/index.js +1 -6
- package/dist/contracts/dist/knowledge/spaces/product-canon.js +1 -34
- package/dist/contracts/dist/knowledge/spaces/support-faq.js +1 -37
- package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +1 -34
- package/dist/contracts/dist/llm/exporters.js +1 -19
- package/dist/contracts/dist/llm/index.js +1 -2
- package/dist/contracts/dist/llm/prompts.js +1 -1
- package/dist/contracts/dist/onboarding-base.js +1 -196
- package/dist/contracts/dist/openapi.js +1 -1
- package/dist/contracts/dist/ownership.js +1 -21
- package/dist/contracts/dist/presentations.js +1 -1
- package/dist/contracts/dist/presentations.v2.js +1 -11
- 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 +1 -6
- package/dist/contracts/dist/registry.js +1 -2
- package/dist/contracts/dist/resources.js +1 -1
- package/dist/contracts/dist/schema/dist/EnumType.js +1 -2
- package/dist/contracts/dist/schema/dist/FieldType.js +1 -49
- package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +1 -236
- package/dist/contracts/dist/schema/dist/SchemaModel.js +1 -34
- package/dist/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/contracts/dist/schema/dist/entity/index.js +1 -2
- package/dist/contracts/dist/schema/dist/entity/types.js +1 -1
- package/dist/contracts/dist/schema/dist/index.js +1 -6
- package/dist/contracts/dist/server/graphql-pothos.js +1 -6
- package/dist/contracts/dist/server/index.js +1 -8
- package/dist/contracts/dist/server/mcp/createMcpServer.js +1 -4
- package/dist/contracts/dist/server/mcp/registerPresentations.js +1 -2
- package/dist/contracts/dist/server/mcp/registerPrompts.js +1 -1
- package/dist/contracts/dist/server/mcp/registerResources.js +1 -2
- 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 +1 -34
- 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 +1 -2
- 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 +1 -484
- package/dist/entities/index.d.ts +116 -116
- package/dist/entities/index.js +1 -198
- package/dist/events.js +1 -303
- package/dist/handlers/gmail-sync-handler.js +1 -9
- package/dist/handlers/index.js +1 -12
- package/dist/handlers/ping-job.d.ts +3 -3
- package/dist/handlers/ping-job.js +1 -13
- package/dist/handlers/storage-document-handler.js +1 -14
- package/dist/index.js +1 -18
- package/dist/jobs.feature.js +1 -101
- package/dist/queue/gcp-cloud-tasks.js +1 -61
- package/dist/queue/gcp-pubsub.js +1 -47
- package/dist/queue/index.js +1 -9
- package/dist/queue/memory-queue.js +1 -140
- package/dist/queue/register-defined-job.js +1 -15
- package/dist/queue/scaleway-sqs-queue.js +1 -175
- package/dist/queue/types.js +1 -3
- package/dist/scheduler/index.js +1 -145
- package/dist/schema/dist/EnumType.js +1 -2
- package/dist/schema/dist/FieldType.js +1 -49
- package/dist/schema/dist/ScalarTypeEnum.js +1 -236
- package/dist/schema/dist/SchemaModel.js +1 -39
- package/dist/schema/dist/entity/defineEntity.js +1 -236
- package/dist/schema/dist/entity/index.js +1 -2
- package/dist/schema/dist/entity/types.js +1 -1
- package/dist/schema/dist/index.js +1 -6
- package/package.json +7 -7
package/dist/events.js
CHANGED
|
@@ -1,303 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import{l as e}from"./schema/dist/ScalarTypeEnum.js";import{n as t}from"./schema/dist/SchemaModel.js";import"./schema/dist/index.js";import{e as n}from"./contracts/dist/events.js";import"./contracts/dist/index.js";const r=t({name:`JobEnqueuedEventPayload`,description:`Payload when a job is added to the queue`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},priority:{type:e.Int_unsecure(),isOptional:!1},scheduledAt:{type:e.DateTime(),isOptional:!0},tenantId:{type:e.String_unsecure(),isOptional:!0},enqueuedAt:{type:e.DateTime(),isOptional:!1}}}),i=t({name:`JobStartedEventPayload`,description:`Payload when a job starts processing`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},attempt:{type:e.Int_unsecure(),isOptional:!1},startedAt:{type:e.DateTime(),isOptional:!1}}}),a=t({name:`JobCompletedEventPayload`,description:`Payload when a job completes successfully`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},attempt:{type:e.Int_unsecure(),isOptional:!1},durationMs:{type:e.Int_unsecure(),isOptional:!1},completedAt:{type:e.DateTime(),isOptional:!1}}}),o=t({name:`JobFailedEventPayload`,description:`Payload when a job attempt fails`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},attempt:{type:e.Int_unsecure(),isOptional:!1},error:{type:e.String_unsecure(),isOptional:!1},willRetry:{type:e.Boolean(),isOptional:!1},failedAt:{type:e.DateTime(),isOptional:!1}}}),s=t({name:`JobRetryingEventPayload`,description:`Payload when a job is scheduled for retry`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},attempt:{type:e.Int_unsecure(),isOptional:!1},nextAttemptAt:{type:e.DateTime(),isOptional:!1},backoffMs:{type:e.Int_unsecure(),isOptional:!1}}}),c=t({name:`JobDeadLetteredEventPayload`,description:`Payload when a job is moved to dead letter queue`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},attempts:{type:e.Int_unsecure(),isOptional:!1},lastError:{type:e.String_unsecure(),isOptional:!1},deadLetteredAt:{type:e.DateTime(),isOptional:!1}}}),l=t({name:`JobCancelledEventPayload`,description:`Payload when a job is cancelled`,fields:{jobId:{type:e.String_unsecure(),isOptional:!1},type:{type:e.String_unsecure(),isOptional:!1},cancelledBy:{type:e.String_unsecure(),isOptional:!0},cancelledAt:{type:e.DateTime(),isOptional:!1}}}),u=t({name:`ScheduledJobTriggeredEventPayload`,description:`Payload when a scheduled job is triggered`,fields:{scheduleName:{type:e.String_unsecure(),isOptional:!1},jobId:{type:e.String_unsecure(),isOptional:!1},jobType:{type:e.String_unsecure(),isOptional:!1},triggeredAt:{type:e.DateTime(),isOptional:!1},nextRunAt:{type:e.DateTime(),isOptional:!0}}}),d=n({name:`job.enqueued`,version:1,description:`A job has been added to the queue.`,payload:r}),f=n({name:`job.started`,version:1,description:`A job has started processing.`,payload:i}),p=n({name:`job.completed`,version:1,description:`A job has completed successfully.`,payload:a}),m=n({name:`job.failed`,version:1,description:`A job attempt has failed.`,payload:o}),h=n({name:`job.retrying`,version:1,description:`A job is being scheduled for retry.`,payload:s}),g=n({name:`job.dead_lettered`,version:1,description:`A job has exhausted all retries and moved to dead letter queue.`,payload:c}),_=n({name:`job.cancelled`,version:1,description:`A job has been cancelled.`,payload:l}),v=n({name:`scheduler.job_triggered`,version:1,description:`A scheduled job has been triggered.`,payload:u}),y={JobEnqueuedEvent:d,JobStartedEvent:f,JobCompletedEvent:p,JobFailedEvent:m,JobRetryingEvent:h,JobDeadLetteredEvent:g,JobCancelledEvent:_,ScheduledJobTriggeredEvent:v};export{_ as JobCancelledEvent,p as JobCompletedEvent,g as JobDeadLetteredEvent,d as JobEnqueuedEvent,y as JobEvents,m as JobFailedEvent,h as JobRetryingEvent,f as JobStartedEvent,v as ScheduledJobTriggeredEvent};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function createGmailSyncHandler(adapter) {
|
|
3
|
-
return async (job) => {
|
|
4
|
-
await adapter.syncThreads(job.payload);
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { createGmailSyncHandler };
|
|
1
|
+
function e(e){return async t=>{await e.syncThreads(t.payload)}}export{e as createGmailSyncHandler};
|
package/dist/handlers/index.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import{registerDefinedJob as e}from"../queue/register-defined-job.js";import{PING_JOB_TYPE as t,PingPayloadSchema as n,pingJob as r}from"./ping-job.js";import{createGmailSyncHandler as i}from"./gmail-sync-handler.js";import{createStorageDocumentHandler as a}from"./storage-document-handler.js";function o(t){e(t,r)}export{t as PING_JOB_TYPE,n as PingPayloadSchema,i as createGmailSyncHandler,a as createStorageDocumentHandler,r as pingJob,o as registerAllJobs};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as z
|
|
1
|
+
import * as z 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
|
|
7
|
-
type PingPayload = z
|
|
6
|
+
declare const PingPayloadSchema: z.ZodObject<{}, z.core.$strip>;
|
|
7
|
+
type PingPayload = z.infer<typeof PingPayloadSchema>;
|
|
8
8
|
declare const pingJob: DefinedJob<PingPayload>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { PING_JOB_TYPE, PingPayload, PingPayloadSchema, pingJob };
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import*as e from"zod";const t=`core.ping`,n=e.object({}),r={type:t,schema:n,handler:async(e,t)=>{}};export{t as PING_JOB_TYPE,n as PingPayloadSchema,r as pingJob};
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
function e(e,t){return async n=>{let r=await e.getObject({bucket:n.payload.bucket,key:n.payload.key});if(!r)throw Error(`Object ${n.payload.bucket}/${n.payload.key} not found`);await t.ingestObject(r)}}export{e as createStorageDocumentHandler};
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import { JobCancelledEvent, JobCompletedEvent, JobDeadLetteredEvent, JobEnqueuedEvent, JobEvents, JobFailedEvent, JobRetryingEvent, JobStartedEvent, ScheduledJobTriggeredEvent
|
|
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 };
|
|
1
|
+
import{JobCancelledEvent as e,JobCompletedEvent as t,JobDeadLetteredEvent as n,JobEnqueuedEvent as r,JobEvents as i,JobFailedEvent as a,JobRetryingEvent as o,JobStartedEvent as s,ScheduledJobTriggeredEvent as c}from"./events.js";import{JobEntity as l,JobExecutionEntity as u,JobStatusEnum as d,ScheduledJobEntity as f,jobEntities as p,jobsSchemaContribution as m}from"./entities/index.js";import{e as h,n as g,t as _}from"./contracts/dist/jobs/queue.js";import{MemoryJobQueue as v}from"./queue/memory-queue.js";import{ScalewaySqsJobQueue as y}from"./queue/scaleway-sqs-queue.js";import{GcpCloudTasksQueue as b}from"./queue/gcp-cloud-tasks.js";import{GcpPubSubQueue as x}from"./queue/gcp-pubsub.js";import{registerDefinedJob as S}from"./queue/register-defined-job.js";import"./queue/index.js";import{PING_JOB_TYPE as C,PingPayloadSchema as w,pingJob as T}from"./handlers/ping-job.js";import{createGmailSyncHandler as E}from"./handlers/gmail-sync-handler.js";import{createStorageDocumentHandler as D}from"./handlers/storage-document-handler.js";import{registerAllJobs as O}from"./handlers/index.js";import{JobScheduler as k,createScheduler as A,defineSchedule as j}from"./scheduler/index.js";import{CancelJobContract as M,CreateScheduledJobContract as N,EnqueueJobContract as P,GetJobContract as F,GetQueueStatsContract as I,JobModel as L,ListScheduledJobsContract as R,QueueStatsModel as z,ScheduledJobModel as B,ToggleScheduledJobContract as V}from"./contracts/index.js";import{JobsFeature as H}from"./jobs.feature.js";export{M as CancelJobContract,N as CreateScheduledJobContract,h as DEFAULT_RETRY_POLICY,P as EnqueueJobContract,b as GcpCloudTasksQueue,x as GcpPubSubQueue,F as GetJobContract,I as GetQueueStatsContract,e as JobCancelledEvent,t as JobCompletedEvent,n as JobDeadLetteredEvent,r as JobEnqueuedEvent,l as JobEntity,i as JobEvents,u as JobExecutionEntity,a as JobFailedEvent,L as JobModel,o as JobRetryingEvent,k as JobScheduler,s as JobStartedEvent,d as JobStatusEnum,H as JobsFeature,R as ListScheduledJobsContract,v as MemoryJobQueue,C as PING_JOB_TYPE,w as PingPayloadSchema,z as QueueStatsModel,y as ScalewaySqsJobQueue,f as ScheduledJobEntity,B as ScheduledJobModel,c as ScheduledJobTriggeredEvent,V as ToggleScheduledJobContract,_ as calculateBackoff,E as createGmailSyncHandler,A as createScheduler,D as createStorageDocumentHandler,g as defineJobType,j as defineSchedule,p as jobEntities,m as jobsSchemaContribution,T as pingJob,O as registerAllJobs,S as registerDefinedJob};
|
package/dist/jobs.feature.js
CHANGED
|
@@ -1,101 +1 @@
|
|
|
1
|
-
|
|
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
|
+
const e={meta:{key:`jobs`,title:`Background Jobs`,description:`Background job processing, scheduling, and queue management`,domain:`platform`,owners:[`@platform.jobs`],tags:[`jobs`,`queue`,`background`,`scheduler`],stability:`stable`},operations:[{name:`jobs.enqueue`,version:1},{name:`jobs.cancel`,version:1},{name:`jobs.get`,version:1},{name:`jobs.stats`,version:1},{name:`jobs.schedule.create`,version:1},{name:`jobs.schedule.toggle`,version:1},{name:`jobs.schedule.list`,version:1}],events:[{name:`job.enqueued`,version:1},{name:`job.started`,version:1},{name:`job.completed`,version:1},{name:`job.failed`,version:1},{name:`job.retrying`,version:1},{name:`job.dead_lettered`,version:1},{name:`job.cancelled`,version:1},{name:`scheduler.job_triggered`,version:1}],presentations:[],opToPresentation:[],presentationsTargets:[],capabilities:{provides:[{key:`jobs`,version:1},{key:`scheduler`,version:1}],requires:[]}};export{e as JobsFeature};
|
|
@@ -1,61 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{e}from"../contracts/dist/jobs/queue.js";import"./types.js";import{randomUUID as t}from"node:crypto";var n=class{handlers=new Map;constructor(e){this.options=e}async enqueue(n,r,i={}){let a=new Date,o=i.delaySeconds==null?void 0:{seconds:Math.floor(Date.now()/1e3)+i.delaySeconds},s=Buffer.from(JSON.stringify({id:t(),type:n,payload:r}),`utf-8`);return await this.options.client.createTask({parent:`projects/${this.options.projectId}/locations/${this.options.location}/queues/${this.options.queue}`,task:{httpRequest:{httpMethod:`POST`,url:this.options.resolveUrl(n),body:s,headers:{"Content-Type":`application/json`},oidcToken:this.options.serviceAccountEmail?{serviceAccountEmail:this.options.serviceAccountEmail}:void 0},scheduleTime:o}}),{id:t(),type:n,version:1,payload:r,status:`pending`,priority:i.priority??0,attempts:0,maxRetries:i.maxRetries??e.maxRetries,createdAt:a,updatedAt:a,scheduledAt:i.delaySeconds?new Date(a.getTime()+i.delaySeconds*1e3):a,dedupeKey:i.dedupeKey,tenantId:i.tenantId,userId:i.userId,traceId:i.traceId,metadata:i.metadata}}register(e,t){this.handlers.set(e,t)}start(){}async stop(){this.handlers.clear()}};export{n as GcpCloudTasksQueue};
|
package/dist/queue/gcp-pubsub.js
CHANGED
|
@@ -1,47 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{e}from"../contracts/dist/jobs/queue.js";import"./types.js";import{randomUUID as t}from"node:crypto";var n=class{handlers=new Map;constructor(e){this.options=e}async enqueue(n,r,i={}){let a=new Date;return await this.options.client.topic(this.options.topicName).publishMessage({data:Buffer.from(JSON.stringify({id:t(),type:n,payload:r}),`utf-8`)}),{id:t(),type:n,version:1,payload:r,status:`pending`,priority:i.priority??0,attempts:0,maxRetries:i.maxRetries??e.maxRetries,createdAt:a,updatedAt:a,scheduledAt:i.delaySeconds?new Date(a.getTime()+i.delaySeconds*1e3):a,dedupeKey:i.dedupeKey,tenantId:i.tenantId,userId:i.userId,traceId:i.traceId,metadata:i.metadata}}register(e,t){this.handlers.set(e,t)}start(){}async stop(){this.handlers.clear()}};export{n as GcpPubSubQueue};
|
package/dist/queue/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{e,n as t,t as n}from"../contracts/dist/jobs/queue.js";import"./types.js";import{MemoryJobQueue as r}from"./memory-queue.js";import{ScalewaySqsJobQueue as i}from"./scaleway-sqs-queue.js";import{GcpCloudTasksQueue as a}from"./gcp-cloud-tasks.js";import{GcpPubSubQueue as o}from"./gcp-pubsub.js";import{registerDefinedJob as s}from"./register-defined-job.js";export{e as DEFAULT_RETRY_POLICY,a as GcpCloudTasksQueue,o as GcpPubSubQueue,r as MemoryJobQueue,i as ScalewaySqsJobQueue,n as calculateBackoff,t as defineJobType,s as registerDefinedJob};
|