@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.
Files changed (142) hide show
  1. package/dist/_virtual/rolldown_runtime.js +42 -1
  2. package/dist/contracts/dist/capabilities/openbanking.js +88 -1
  3. package/dist/contracts/dist/client/index.js +5 -1
  4. package/dist/contracts/dist/client/react/feature-render.js +2 -1
  5. package/dist/contracts/dist/client/react/form-render.js +4 -1
  6. package/dist/contracts/dist/client/react/index.js +4 -1
  7. package/dist/contracts/dist/contract-registry/index.js +1 -1
  8. package/dist/contracts/dist/contract-registry/schemas.js +60 -1
  9. package/dist/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
  10. package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
  11. package/dist/contracts/dist/docs/index.js +29 -1
  12. package/dist/contracts/dist/docs/presentations.js +71 -1
  13. package/dist/contracts/dist/docs/registry.js +44 -1
  14. package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
  15. package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
  16. package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
  17. package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
  18. package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
  19. package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
  20. package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
  21. package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
  22. package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
  23. package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
  24. package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
  25. package/dist/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
  26. package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
  27. package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
  28. package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
  29. package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
  30. package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
  31. package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
  32. package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
  33. package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
  34. package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
  35. package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
  36. package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
  37. package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
  38. package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
  39. package/dist/contracts/dist/events.js +10 -1
  40. package/dist/contracts/dist/experiments/evaluator.js +1 -1
  41. package/dist/contracts/dist/index.js +71 -1
  42. package/dist/contracts/dist/install.js +2 -1
  43. package/dist/contracts/dist/integrations/contracts.js +377 -1
  44. package/dist/contracts/dist/integrations/index.js +18 -1
  45. package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
  46. package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
  47. package/dist/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
  48. package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
  49. package/dist/contracts/dist/integrations/openbanking/models.js +242 -1
  50. package/dist/contracts/dist/integrations/openbanking/telemetry.js +13 -1
  51. package/dist/contracts/dist/integrations/providers/elevenlabs.js +52 -1
  52. package/dist/contracts/dist/integrations/providers/gcs-storage.js +75 -1
  53. package/dist/contracts/dist/integrations/providers/gmail.js +87 -1
  54. package/dist/contracts/dist/integrations/providers/google-calendar.js +66 -1
  55. package/dist/contracts/dist/integrations/providers/index.js +11 -1
  56. package/dist/contracts/dist/integrations/providers/mistral.js +68 -1
  57. package/dist/contracts/dist/integrations/providers/postmark.js +68 -1
  58. package/dist/contracts/dist/integrations/providers/powens.js +116 -1
  59. package/dist/contracts/dist/integrations/providers/qdrant.js +73 -1
  60. package/dist/contracts/dist/integrations/providers/registry.js +10 -1
  61. package/dist/contracts/dist/integrations/providers/stripe.js +83 -1
  62. package/dist/contracts/dist/integrations/providers/twilio-sms.js +61 -1
  63. package/dist/contracts/dist/jobs/queue.js +33 -1
  64. package/dist/contracts/dist/jsonschema.js +1 -1
  65. package/dist/contracts/dist/knowledge/contracts.js +306 -1
  66. package/dist/contracts/dist/knowledge/index.js +7 -1
  67. package/dist/contracts/dist/knowledge/spaces/email-threads.js +34 -1
  68. package/dist/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
  69. package/dist/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
  70. package/dist/contracts/dist/knowledge/spaces/index.js +6 -1
  71. package/dist/contracts/dist/knowledge/spaces/product-canon.js +34 -1
  72. package/dist/contracts/dist/knowledge/spaces/support-faq.js +37 -1
  73. package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
  74. package/dist/contracts/dist/llm/exporters.js +19 -1
  75. package/dist/contracts/dist/llm/index.js +2 -1
  76. package/dist/contracts/dist/llm/prompts.js +1 -1
  77. package/dist/contracts/dist/onboarding-base.js +196 -1
  78. package/dist/contracts/dist/openapi.js +1 -1
  79. package/dist/contracts/dist/ownership.js +21 -1
  80. package/dist/contracts/dist/presentations.js +1 -1
  81. package/dist/contracts/dist/presentations.v2.js +11 -1
  82. package/dist/contracts/dist/prompt.js +1 -1
  83. package/dist/contracts/dist/promptRegistry.js +1 -1
  84. package/dist/contracts/dist/regenerator/index.js +1 -1
  85. package/dist/contracts/dist/regenerator/service.js +6 -1
  86. package/dist/contracts/dist/registry.js +2 -1
  87. package/dist/contracts/dist/resources.js +1 -1
  88. package/dist/contracts/dist/schema/dist/EnumType.js +2 -1
  89. package/dist/contracts/dist/schema/dist/FieldType.js +49 -1
  90. package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
  91. package/dist/contracts/dist/schema/dist/SchemaModel.js +34 -1
  92. package/dist/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
  93. package/dist/contracts/dist/schema/dist/entity/index.js +2 -1
  94. package/dist/contracts/dist/schema/dist/entity/types.js +1 -1
  95. package/dist/contracts/dist/schema/dist/index.js +6 -1
  96. package/dist/contracts/dist/server/graphql-pothos.js +6 -1
  97. package/dist/contracts/dist/server/index.js +8 -1
  98. package/dist/contracts/dist/server/mcp/createMcpServer.js +4 -1
  99. package/dist/contracts/dist/server/mcp/registerPresentations.js +2 -1
  100. package/dist/contracts/dist/server/mcp/registerPrompts.js +1 -1
  101. package/dist/contracts/dist/server/mcp/registerResources.js +2 -1
  102. package/dist/contracts/dist/server/mcp/registerTools.js +1 -1
  103. package/dist/contracts/dist/server/provider-mcp.js +1 -1
  104. package/dist/contracts/dist/server/rest-elysia.js +1 -1
  105. package/dist/contracts/dist/server/rest-express.js +1 -1
  106. package/dist/contracts/dist/server/rest-generic.js +1 -1
  107. package/dist/contracts/dist/server/rest-next-app.js +1 -1
  108. package/dist/contracts/dist/server/rest-next-pages.js +1 -1
  109. package/dist/contracts/dist/spec.js +34 -1
  110. package/dist/contracts/dist/telemetry/index.js +1 -1
  111. package/dist/contracts/dist/telemetry/tracker.js +1 -1
  112. package/dist/contracts/dist/tests/index.js +1 -1
  113. package/dist/contracts/dist/tests/runner.js +2 -1
  114. package/dist/contracts/dist/workflow/index.js +1 -1
  115. package/dist/contracts/dist/workflow/runner.js +1 -1
  116. package/dist/contracts/index.js +484 -1
  117. package/dist/entities/index.js +198 -1
  118. package/dist/events.js +303 -1
  119. package/dist/handlers/gmail-sync-handler.js +9 -1
  120. package/dist/handlers/index.js +12 -1
  121. package/dist/handlers/ping-job.d.ts +3 -3
  122. package/dist/handlers/ping-job.js +13 -1
  123. package/dist/handlers/storage-document-handler.js +14 -1
  124. package/dist/index.js +18 -1
  125. package/dist/jobs.feature.js +101 -1
  126. package/dist/queue/gcp-cloud-tasks.js +61 -1
  127. package/dist/queue/gcp-pubsub.js +47 -1
  128. package/dist/queue/index.js +9 -1
  129. package/dist/queue/memory-queue.js +140 -1
  130. package/dist/queue/register-defined-job.js +15 -1
  131. package/dist/queue/scaleway-sqs-queue.js +175 -1
  132. package/dist/queue/types.js +3 -1
  133. package/dist/scheduler/index.js +145 -1
  134. package/dist/schema/dist/EnumType.js +2 -1
  135. package/dist/schema/dist/FieldType.js +49 -1
  136. package/dist/schema/dist/ScalarTypeEnum.js +236 -1
  137. package/dist/schema/dist/SchemaModel.js +39 -1
  138. package/dist/schema/dist/entity/defineEntity.js +236 -1
  139. package/dist/schema/dist/entity/index.js +2 -1
  140. package/dist/schema/dist/entity/types.js +1 -1
  141. package/dist/schema/dist/index.js +6 -1
  142. package/package.json +7 -7
@@ -1 +1,198 @@
1
- import{i as e,n as t,r as n,t as r}from"../schema/dist/entity/defineEntity.js";import"../schema/dist/index.js";const i=t({name:`JobStatus`,values:[`PENDING`,`RUNNING`,`COMPLETED`,`FAILED`,`CANCELLED`,`DEAD_LETTER`],schema:`lssm_jobs`,description:`Status of a background job.`}),a=r({name:`Job`,description:`A background job for async processing.`,schema:`lssm_jobs`,map:`job`,fields:{id:n.id({description:`Unique job identifier`}),type:n.string({description:`Job type identifier`}),version:n.int({default:1,description:`Job type version`}),payload:n.json({description:`Job payload data`}),status:n.enum(`JobStatus`,{default:`PENDING`}),priority:n.int({default:0,description:`Higher = more urgent`}),attempts:n.int({default:0,description:`Number of execution attempts`}),maxRetries:n.int({default:3,description:`Maximum retry attempts`}),lastError:n.string({isOptional:!0,description:`Last error message`}),lastErrorStack:n.string({isOptional:!0,description:`Last error stack trace`}),scheduledAt:n.dateTime({isOptional:!0,description:`When job should be processed`}),startedAt:n.dateTime({isOptional:!0,description:`When processing started`}),completedAt:n.dateTime({isOptional:!0,description:`When processing completed`}),timeoutAt:n.dateTime({isOptional:!0,description:`Job timeout deadline`}),dedupeKey:n.string({isOptional:!0,description:`Key for deduplication`}),tenantId:n.string({isOptional:!0,description:`Tenant/org context`}),userId:n.string({isOptional:!0,description:`User who enqueued`}),traceId:n.string({isOptional:!0,description:`Distributed trace ID`}),metadata:n.json({isOptional:!0,description:`Additional metadata`}),result:n.json({isOptional:!0,description:`Job result data`}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),scheduledJob:n.belongsTo(`ScheduledJob`,[`scheduledJobId`],[`id`]),scheduledJobId:n.string({isOptional:!0}),executions:n.hasMany(`JobExecution`)},indexes:[e.on([`status`,`scheduledAt`]),e.on([`type`,`status`]),e.on([`tenantId`,`status`]),e.unique([`dedupeKey`],{name:`job_dedupe_key_unique`})],enums:[i]}),o=r({name:`ScheduledJob`,description:`A scheduled/recurring job definition.`,schema:`lssm_jobs`,map:`scheduled_job`,fields:{id:n.id(),name:n.string({isUnique:!0,description:`Unique schedule name`}),description:n.string({isOptional:!0}),cronExpression:n.string({description:`Cron expression for scheduling`}),timezone:n.string({default:`"UTC"`,description:`Timezone for cron evaluation`}),jobType:n.string({description:`Job type to create`}),jobVersion:n.int({default:1}),payload:n.json({isOptional:!0,description:`Default payload for created jobs`}),maxRetries:n.int({default:3}),timeoutMs:n.int({isOptional:!0,description:`Job timeout in milliseconds`}),enabled:n.boolean({default:!0}),lastRunAt:n.dateTime({isOptional:!0}),nextRunAt:n.dateTime({isOptional:!0}),tenantId:n.string({isOptional:!0}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),jobs:n.hasMany(`Job`)},indexes:[e.on([`enabled`,`nextRunAt`])]}),s=r({name:`JobExecution`,description:`A single execution attempt of a job.`,schema:`lssm_jobs`,map:`job_execution`,fields:{id:n.id(),jobId:n.foreignKey(),attemptNumber:n.int({description:`Which attempt this is`}),startedAt:n.dateTime(),completedAt:n.dateTime({isOptional:!0}),durationMs:n.int({isOptional:!0}),success:n.boolean({isOptional:!0}),error:n.string({isOptional:!0}),errorStack:n.string({isOptional:!0}),result:n.json({isOptional:!0}),workerId:n.string({isOptional:!0,description:`ID of worker that processed`}),job:n.belongsTo(`Job`,[`jobId`],[`id`],{onDelete:`Cascade`})},indexes:[e.on([`jobId`,`attemptNumber`])]}),c=[a,o,s],l={moduleId:`@lssm/lib.jobs`,entities:c,enums:[i]};export{a as JobEntity,s as JobExecutionEntity,i as JobStatusEnum,o as ScheduledJobEntity,c as jobEntities,l as jobsSchemaContribution};
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{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
+ 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
- function e(e){return async t=>{await e.syncThreads(t.payload)}}export{e as createGmailSyncHandler};
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 };
@@ -1 +1,12 @@
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
+ 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 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
+ 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
- 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};
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{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};
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 };