@lssm/lib.jobs 0.0.0-canary-20251217073102 → 0.0.0-canary-20251217083314
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.js +484 -1
- 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 -7
package/dist/entities/index.js
CHANGED
|
@@ -1 +1,198 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "../schema/dist/entity/defineEntity.js";
|
|
2
|
+
import "../schema/dist/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/entities/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Job status enum.
|
|
7
|
+
*/
|
|
8
|
+
const JobStatusEnum = defineEntityEnum({
|
|
9
|
+
name: "JobStatus",
|
|
10
|
+
values: [
|
|
11
|
+
"PENDING",
|
|
12
|
+
"RUNNING",
|
|
13
|
+
"COMPLETED",
|
|
14
|
+
"FAILED",
|
|
15
|
+
"CANCELLED",
|
|
16
|
+
"DEAD_LETTER"
|
|
17
|
+
],
|
|
18
|
+
schema: "lssm_jobs",
|
|
19
|
+
description: "Status of a background job."
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Job entity - represents a single job execution.
|
|
23
|
+
*/
|
|
24
|
+
const JobEntity = defineEntity({
|
|
25
|
+
name: "Job",
|
|
26
|
+
description: "A background job for async processing.",
|
|
27
|
+
schema: "lssm_jobs",
|
|
28
|
+
map: "job",
|
|
29
|
+
fields: {
|
|
30
|
+
id: field.id({ description: "Unique job identifier" }),
|
|
31
|
+
type: field.string({ description: "Job type identifier" }),
|
|
32
|
+
version: field.int({
|
|
33
|
+
default: 1,
|
|
34
|
+
description: "Job type version"
|
|
35
|
+
}),
|
|
36
|
+
payload: field.json({ description: "Job payload data" }),
|
|
37
|
+
status: field.enum("JobStatus", { default: "PENDING" }),
|
|
38
|
+
priority: field.int({
|
|
39
|
+
default: 0,
|
|
40
|
+
description: "Higher = more urgent"
|
|
41
|
+
}),
|
|
42
|
+
attempts: field.int({
|
|
43
|
+
default: 0,
|
|
44
|
+
description: "Number of execution attempts"
|
|
45
|
+
}),
|
|
46
|
+
maxRetries: field.int({
|
|
47
|
+
default: 3,
|
|
48
|
+
description: "Maximum retry attempts"
|
|
49
|
+
}),
|
|
50
|
+
lastError: field.string({
|
|
51
|
+
isOptional: true,
|
|
52
|
+
description: "Last error message"
|
|
53
|
+
}),
|
|
54
|
+
lastErrorStack: field.string({
|
|
55
|
+
isOptional: true,
|
|
56
|
+
description: "Last error stack trace"
|
|
57
|
+
}),
|
|
58
|
+
scheduledAt: field.dateTime({
|
|
59
|
+
isOptional: true,
|
|
60
|
+
description: "When job should be processed"
|
|
61
|
+
}),
|
|
62
|
+
startedAt: field.dateTime({
|
|
63
|
+
isOptional: true,
|
|
64
|
+
description: "When processing started"
|
|
65
|
+
}),
|
|
66
|
+
completedAt: field.dateTime({
|
|
67
|
+
isOptional: true,
|
|
68
|
+
description: "When processing completed"
|
|
69
|
+
}),
|
|
70
|
+
timeoutAt: field.dateTime({
|
|
71
|
+
isOptional: true,
|
|
72
|
+
description: "Job timeout deadline"
|
|
73
|
+
}),
|
|
74
|
+
dedupeKey: field.string({
|
|
75
|
+
isOptional: true,
|
|
76
|
+
description: "Key for deduplication"
|
|
77
|
+
}),
|
|
78
|
+
tenantId: field.string({
|
|
79
|
+
isOptional: true,
|
|
80
|
+
description: "Tenant/org context"
|
|
81
|
+
}),
|
|
82
|
+
userId: field.string({
|
|
83
|
+
isOptional: true,
|
|
84
|
+
description: "User who enqueued"
|
|
85
|
+
}),
|
|
86
|
+
traceId: field.string({
|
|
87
|
+
isOptional: true,
|
|
88
|
+
description: "Distributed trace ID"
|
|
89
|
+
}),
|
|
90
|
+
metadata: field.json({
|
|
91
|
+
isOptional: true,
|
|
92
|
+
description: "Additional metadata"
|
|
93
|
+
}),
|
|
94
|
+
result: field.json({
|
|
95
|
+
isOptional: true,
|
|
96
|
+
description: "Job result data"
|
|
97
|
+
}),
|
|
98
|
+
createdAt: field.createdAt(),
|
|
99
|
+
updatedAt: field.updatedAt(),
|
|
100
|
+
scheduledJob: field.belongsTo("ScheduledJob", ["scheduledJobId"], ["id"]),
|
|
101
|
+
scheduledJobId: field.string({ isOptional: true }),
|
|
102
|
+
executions: field.hasMany("JobExecution")
|
|
103
|
+
},
|
|
104
|
+
indexes: [
|
|
105
|
+
index.on(["status", "scheduledAt"]),
|
|
106
|
+
index.on(["type", "status"]),
|
|
107
|
+
index.on(["tenantId", "status"]),
|
|
108
|
+
index.unique(["dedupeKey"], { name: "job_dedupe_key_unique" })
|
|
109
|
+
],
|
|
110
|
+
enums: [JobStatusEnum]
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* ScheduledJob entity - recurring job definitions.
|
|
114
|
+
*/
|
|
115
|
+
const ScheduledJobEntity = defineEntity({
|
|
116
|
+
name: "ScheduledJob",
|
|
117
|
+
description: "A scheduled/recurring job definition.",
|
|
118
|
+
schema: "lssm_jobs",
|
|
119
|
+
map: "scheduled_job",
|
|
120
|
+
fields: {
|
|
121
|
+
id: field.id(),
|
|
122
|
+
name: field.string({
|
|
123
|
+
isUnique: true,
|
|
124
|
+
description: "Unique schedule name"
|
|
125
|
+
}),
|
|
126
|
+
description: field.string({ isOptional: true }),
|
|
127
|
+
cronExpression: field.string({ description: "Cron expression for scheduling" }),
|
|
128
|
+
timezone: field.string({
|
|
129
|
+
default: "\"UTC\"",
|
|
130
|
+
description: "Timezone for cron evaluation"
|
|
131
|
+
}),
|
|
132
|
+
jobType: field.string({ description: "Job type to create" }),
|
|
133
|
+
jobVersion: field.int({ default: 1 }),
|
|
134
|
+
payload: field.json({
|
|
135
|
+
isOptional: true,
|
|
136
|
+
description: "Default payload for created jobs"
|
|
137
|
+
}),
|
|
138
|
+
maxRetries: field.int({ default: 3 }),
|
|
139
|
+
timeoutMs: field.int({
|
|
140
|
+
isOptional: true,
|
|
141
|
+
description: "Job timeout in milliseconds"
|
|
142
|
+
}),
|
|
143
|
+
enabled: field.boolean({ default: true }),
|
|
144
|
+
lastRunAt: field.dateTime({ isOptional: true }),
|
|
145
|
+
nextRunAt: field.dateTime({ isOptional: true }),
|
|
146
|
+
tenantId: field.string({ isOptional: true }),
|
|
147
|
+
createdAt: field.createdAt(),
|
|
148
|
+
updatedAt: field.updatedAt(),
|
|
149
|
+
jobs: field.hasMany("Job")
|
|
150
|
+
},
|
|
151
|
+
indexes: [index.on(["enabled", "nextRunAt"])]
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* JobExecution entity - individual execution attempts.
|
|
155
|
+
*/
|
|
156
|
+
const JobExecutionEntity = defineEntity({
|
|
157
|
+
name: "JobExecution",
|
|
158
|
+
description: "A single execution attempt of a job.",
|
|
159
|
+
schema: "lssm_jobs",
|
|
160
|
+
map: "job_execution",
|
|
161
|
+
fields: {
|
|
162
|
+
id: field.id(),
|
|
163
|
+
jobId: field.foreignKey(),
|
|
164
|
+
attemptNumber: field.int({ description: "Which attempt this is" }),
|
|
165
|
+
startedAt: field.dateTime(),
|
|
166
|
+
completedAt: field.dateTime({ isOptional: true }),
|
|
167
|
+
durationMs: field.int({ isOptional: true }),
|
|
168
|
+
success: field.boolean({ isOptional: true }),
|
|
169
|
+
error: field.string({ isOptional: true }),
|
|
170
|
+
errorStack: field.string({ isOptional: true }),
|
|
171
|
+
result: field.json({ isOptional: true }),
|
|
172
|
+
workerId: field.string({
|
|
173
|
+
isOptional: true,
|
|
174
|
+
description: "ID of worker that processed"
|
|
175
|
+
}),
|
|
176
|
+
job: field.belongsTo("Job", ["jobId"], ["id"], { onDelete: "Cascade" })
|
|
177
|
+
},
|
|
178
|
+
indexes: [index.on(["jobId", "attemptNumber"])]
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* All job entities for schema composition.
|
|
182
|
+
*/
|
|
183
|
+
const jobEntities = [
|
|
184
|
+
JobEntity,
|
|
185
|
+
ScheduledJobEntity,
|
|
186
|
+
JobExecutionEntity
|
|
187
|
+
];
|
|
188
|
+
/**
|
|
189
|
+
* Module schema contribution for jobs.
|
|
190
|
+
*/
|
|
191
|
+
const jobsSchemaContribution = {
|
|
192
|
+
moduleId: "@lssm/lib.jobs",
|
|
193
|
+
entities: jobEntities,
|
|
194
|
+
enums: [JobStatusEnum]
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
//#endregion
|
|
198
|
+
export { JobEntity, JobExecutionEntity, JobStatusEnum, ScheduledJobEntity, jobEntities, jobsSchemaContribution };
|
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 };
|