@lssm/lib.contracts 0.0.0-canary-20251217062943 → 0.0.0-canary-20251217072406

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/app-config/app-config.feature.js +53 -1
  2. package/dist/app-config/contracts.d.ts +50 -50
  3. package/dist/app-config/contracts.js +396 -1
  4. package/dist/app-config/docs/app-config.docblock.js +22 -220
  5. package/dist/app-config/events.js +168 -1
  6. package/dist/app-config/index.js +8 -1
  7. package/dist/app-config/lifecycle-contracts.js +441 -1
  8. package/dist/app-config/runtime.js +617 -1
  9. package/dist/app-config/spec.js +36 -1
  10. package/dist/app-config/validation.js +538 -1
  11. package/dist/capabilities/docs/capabilities.docblock.js +22 -1
  12. package/dist/capabilities/openbanking.js +92 -1
  13. package/dist/capabilities.js +50 -1
  14. package/dist/client/index.js +9 -1
  15. package/dist/client/react/drivers/rn-reusables.js +21 -1
  16. package/dist/client/react/drivers/shadcn.js +11 -1
  17. package/dist/client/react/feature-render.js +43 -1
  18. package/dist/client/react/form-render.js +298 -1
  19. package/dist/client/react/index.js +8 -1
  20. package/dist/contract-registry/index.js +3 -1
  21. package/dist/contract-registry/schemas.js +61 -1
  22. package/dist/contracts-adapter-hydration.js +41 -1
  23. package/dist/contracts-adapter-input.js +77 -1
  24. package/dist/data-views/docs/data-views.docblock.js +22 -1
  25. package/dist/data-views/query-generator.js +48 -1
  26. package/dist/data-views/runtime.js +39 -1
  27. package/dist/data-views.js +35 -1
  28. package/dist/docs/PUBLISHING.docblock.js +17 -76
  29. package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
  30. package/dist/docs/index.js +33 -1
  31. package/dist/docs/meta.docs.js +15 -2
  32. package/dist/docs/presentations.js +77 -1
  33. package/dist/docs/registry.js +51 -1
  34. package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
  35. package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
  36. package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
  37. package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
  38. package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
  39. package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
  40. package/dist/docs/tech/contracts/README.docblock.js +21 -1
  41. package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
  42. package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
  43. package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
  44. package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
  45. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
  46. package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
  47. package/dist/docs/tech/contracts/tests.docblock.js +21 -132
  48. package/dist/docs/tech/contracts/themes.docblock.js +21 -1
  49. package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
  50. package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
  51. package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
  52. package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
  53. package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
  54. package/dist/docs/tech/schema/README.docblock.js +21 -262
  55. package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
  56. package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
  57. package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
  58. package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
  59. package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
  60. package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
  61. package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
  62. package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
  63. package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
  64. package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
  65. package/dist/docs/tech/templates/runtime.docblock.js +21 -1
  66. package/dist/docs/tech/vscode-extension.docblock.js +37 -3
  67. package/dist/docs/tech/workflows/overview.docblock.js +21 -1
  68. package/dist/docs/tech-contracts.docs.js +19 -2
  69. package/dist/events.js +12 -1
  70. package/dist/experiments/docs/experiments.docblock.js +22 -128
  71. package/dist/experiments/evaluator.js +101 -1
  72. package/dist/experiments/spec.js +33 -1
  73. package/dist/features.js +68 -1
  74. package/dist/forms/docs/forms.docblock.js +22 -1
  75. package/dist/forms.js +119 -1
  76. package/dist/index.js +107 -1
  77. package/dist/install.js +40 -1
  78. package/dist/integrations/contracts.d.ts +102 -102
  79. package/dist/integrations/contracts.js +388 -1
  80. package/dist/integrations/docs/integrations.docblock.js +95 -1
  81. package/dist/integrations/health.js +69 -1
  82. package/dist/integrations/index.js +23 -1
  83. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  84. package/dist/integrations/openbanking/contracts/accounts.js +237 -1
  85. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  86. package/dist/integrations/openbanking/contracts/balances.js +167 -1
  87. package/dist/integrations/openbanking/contracts/index.js +12 -1
  88. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  89. package/dist/integrations/openbanking/contracts/transactions.js +218 -1
  90. package/dist/integrations/openbanking/guards.js +32 -1
  91. package/dist/integrations/openbanking/models.d.ts +55 -55
  92. package/dist/integrations/openbanking/models.js +242 -1
  93. package/dist/integrations/openbanking/openbanking.feature.js +68 -1
  94. package/dist/integrations/openbanking/telemetry.js +39 -1
  95. package/dist/integrations/providers/elevenlabs.js +56 -1
  96. package/dist/integrations/providers/gcs-storage.js +79 -1
  97. package/dist/integrations/providers/gmail.js +91 -1
  98. package/dist/integrations/providers/google-calendar.js +70 -1
  99. package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
  100. package/dist/integrations/providers/impls/gcs-storage.js +88 -1
  101. package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
  102. package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
  103. package/dist/integrations/providers/impls/google-calendar.js +154 -1
  104. package/dist/integrations/providers/impls/index.js +16 -1
  105. package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
  106. package/dist/integrations/providers/impls/mistral-llm.js +247 -1
  107. package/dist/integrations/providers/impls/postmark-email.js +55 -1
  108. package/dist/integrations/providers/impls/powens-client.js +171 -1
  109. package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
  110. package/dist/integrations/providers/impls/provider-factory.js +142 -1
  111. package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
  112. package/dist/integrations/providers/impls/stripe-payments.js +202 -1
  113. package/dist/integrations/providers/impls/twilio-sms.js +58 -1
  114. package/dist/integrations/providers/index.js +13 -1
  115. package/dist/integrations/providers/mistral.js +72 -1
  116. package/dist/integrations/providers/postmark.js +72 -1
  117. package/dist/integrations/providers/powens.js +120 -1
  118. package/dist/integrations/providers/qdrant.js +77 -1
  119. package/dist/integrations/providers/registry.js +34 -1
  120. package/dist/integrations/providers/stripe.js +87 -1
  121. package/dist/integrations/providers/twilio-sms.js +65 -1
  122. package/dist/integrations/runtime.js +186 -1
  123. package/dist/integrations/secrets/aws-secret-manager.js +231 -1
  124. package/dist/integrations/secrets/env-secret-provider.js +81 -1
  125. package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
  126. package/dist/integrations/secrets/index.js +8 -1
  127. package/dist/integrations/secrets/manager.js +103 -1
  128. package/dist/integrations/secrets/provider.js +58 -1
  129. package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
  130. package/dist/integrations/spec.js +39 -1
  131. package/dist/jobs/define-job.js +16 -1
  132. package/dist/jobs/gcp-cloud-tasks.js +53 -1
  133. package/dist/jobs/gcp-pubsub.js +39 -1
  134. package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
  135. package/dist/jobs/handlers/index.js +12 -1
  136. package/dist/jobs/handlers/ping-handler.js +15 -1
  137. package/dist/jobs/handlers/storage-document-handler.js +14 -1
  138. package/dist/jobs/index.js +4 -1
  139. package/dist/jobs/memory-queue.js +71 -1
  140. package/dist/jobs/queue.js +33 -1
  141. package/dist/jobs/scaleway-sqs-queue.js +153 -1
  142. package/dist/jsonschema.d.ts +3 -3
  143. package/dist/jsonschema.js +32 -1
  144. package/dist/knowledge/contracts.d.ts +66 -66
  145. package/dist/knowledge/contracts.js +317 -1
  146. package/dist/knowledge/docs/knowledge.docblock.js +22 -138
  147. package/dist/knowledge/index.js +10 -1
  148. package/dist/knowledge/ingestion/document-processor.js +54 -1
  149. package/dist/knowledge/ingestion/embedding-service.js +25 -1
  150. package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
  151. package/dist/knowledge/ingestion/index.js +7 -1
  152. package/dist/knowledge/ingestion/storage-adapter.js +26 -1
  153. package/dist/knowledge/ingestion/vector-indexer.js +32 -1
  154. package/dist/knowledge/query/index.js +3 -1
  155. package/dist/knowledge/query/service.js +64 -2
  156. package/dist/knowledge/runtime.js +49 -1
  157. package/dist/knowledge/spaces/email-threads.js +38 -1
  158. package/dist/knowledge/spaces/financial-docs.js +38 -1
  159. package/dist/knowledge/spaces/financial-overview.js +42 -1
  160. package/dist/knowledge/spaces/index.js +8 -1
  161. package/dist/knowledge/spaces/product-canon.js +38 -1
  162. package/dist/knowledge/spaces/support-faq.js +41 -1
  163. package/dist/knowledge/spaces/uploaded-docs.js +38 -1
  164. package/dist/knowledge/spec.js +39 -1
  165. package/dist/llm/exporters.js +541 -8
  166. package/dist/llm/index.js +4 -1
  167. package/dist/llm/prompts.js +246 -56
  168. package/dist/markdown.js +116 -3
  169. package/dist/migrations.js +33 -1
  170. package/dist/onboarding-base.d.ts +29 -29
  171. package/dist/onboarding-base.js +196 -1
  172. package/dist/openapi.js +75 -1
  173. package/dist/openbanking/docs/openbanking.docblock.js +22 -109
  174. package/dist/ownership.js +40 -1
  175. package/dist/policy/docs/policy.docblock.js +22 -1
  176. package/dist/policy/engine.js +223 -1
  177. package/dist/policy/opa-adapter.js +71 -1
  178. package/dist/policy/spec.js +33 -1
  179. package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
  180. package/dist/presentations.backcompat.js +47 -1
  181. package/dist/presentations.d.ts +3 -3
  182. package/dist/presentations.js +66 -1
  183. package/dist/presentations.v2.js +278 -6
  184. package/dist/prompt.js +10 -1
  185. package/dist/promptRegistry.js +34 -1
  186. package/dist/regenerator/docs/regenerator.docblock.js +22 -184
  187. package/dist/regenerator/executor.js +86 -1
  188. package/dist/regenerator/index.js +6 -1
  189. package/dist/regenerator/service.js +92 -1
  190. package/dist/regenerator/sinks.js +32 -1
  191. package/dist/regenerator/utils.js +51 -1
  192. package/dist/registry.js +208 -1
  193. package/dist/resources.js +47 -1
  194. package/dist/schema/dist/EnumType.js +2 -1
  195. package/dist/schema/dist/FieldType.js +49 -1
  196. package/dist/schema/dist/ScalarTypeEnum.js +236 -1
  197. package/dist/schema/dist/SchemaModel.js +39 -1
  198. package/dist/schema/dist/entity/defineEntity.js +1 -1
  199. package/dist/schema/dist/entity/index.js +2 -1
  200. package/dist/schema/dist/entity/types.js +1 -1
  201. package/dist/schema/dist/index.js +6 -1
  202. package/dist/schema-to-markdown.js +214 -10
  203. package/dist/server/graphql-pothos.js +128 -1
  204. package/dist/server/index.js +10 -1
  205. package/dist/server/mcp/createMcpServer.js +28 -1
  206. package/dist/server/mcp/registerPresentations.js +151 -1
  207. package/dist/server/mcp/registerPrompts.js +36 -2
  208. package/dist/server/mcp/registerResources.js +35 -1
  209. package/dist/server/mcp/registerTools.js +22 -1
  210. package/dist/server/provider-mcp.js +3 -1
  211. package/dist/server/rest-elysia.js +20 -1
  212. package/dist/server/rest-express.js +39 -1
  213. package/dist/server/rest-generic.js +125 -1
  214. package/dist/server/rest-next-app.js +38 -1
  215. package/dist/server/rest-next-mcp.js +45 -1
  216. package/dist/server/rest-next-pages.js +25 -1
  217. package/dist/spec.js +35 -1
  218. package/dist/telemetry/anomaly.js +48 -1
  219. package/dist/telemetry/docs/telemetry.docblock.js +22 -139
  220. package/dist/telemetry/index.js +5 -1
  221. package/dist/telemetry/spec.js +69 -1
  222. package/dist/telemetry/tracker.js +76 -1
  223. package/dist/tests/index.js +4 -1
  224. package/dist/tests/runner.js +150 -1
  225. package/dist/tests/spec.js +33 -1
  226. package/dist/themes.js +39 -1
  227. package/dist/workflow/adapters/db-adapter.js +83 -1
  228. package/dist/workflow/adapters/file-adapter.js +11 -1
  229. package/dist/workflow/adapters/index.js +5 -1
  230. package/dist/workflow/adapters/memory-store.js +58 -1
  231. package/dist/workflow/expression.js +98 -1
  232. package/dist/workflow/index.js +9 -1
  233. package/dist/workflow/runner.js +337 -1
  234. package/dist/workflow/sla-monitor.js +47 -1
  235. package/dist/workflow/spec.js +32 -1
  236. package/dist/workflow/validation.js +175 -1
  237. package/package.json +11 -4
@@ -1 +1,39 @@
1
- const e=e=>`${e.key}.v${e.version}`;var t=class{items=new Map;register(t){let n=e(t.meta);if(this.items.has(n))throw Error(`Duplicate IntegrationSpec ${n}`);return this.items.set(n,t),this}list(){return[...this.items.values()]}get(t,n){if(n!=null)return this.items.get(e({key:t,version:n}));let r,i=-1/0;for(let e of this.items.values())e.meta.key===t&&e.meta.version>i&&(i=e.meta.version,r=e);return r}getByCategory(e){return this.list().filter(t=>t.meta.category===e)}};function n(t){return e(t)}export{t as IntegrationSpecRegistry,n as makeIntegrationSpecKey};
1
+ //#region src/integrations/spec.ts
2
+ const integrationKey = (meta) => `${meta.key}.v${meta.version}`;
3
+ var IntegrationSpecRegistry = class {
4
+ items = /* @__PURE__ */ new Map();
5
+ register(spec) {
6
+ const key = integrationKey(spec.meta);
7
+ if (this.items.has(key)) throw new Error(`Duplicate IntegrationSpec ${key}`);
8
+ this.items.set(key, spec);
9
+ return this;
10
+ }
11
+ list() {
12
+ return [...this.items.values()];
13
+ }
14
+ get(key, version) {
15
+ if (version != null) return this.items.get(integrationKey({
16
+ key,
17
+ version
18
+ }));
19
+ let latest;
20
+ let maxVersion = -Infinity;
21
+ for (const spec of this.items.values()) {
22
+ if (spec.meta.key !== key) continue;
23
+ if (spec.meta.version > maxVersion) {
24
+ maxVersion = spec.meta.version;
25
+ latest = spec;
26
+ }
27
+ }
28
+ return latest;
29
+ }
30
+ getByCategory(category) {
31
+ return this.list().filter((spec) => spec.meta.category === category);
32
+ }
33
+ };
34
+ function makeIntegrationSpecKey(meta) {
35
+ return integrationKey(meta);
36
+ }
37
+
38
+ //#endregion
39
+ export { IntegrationSpecRegistry, makeIntegrationSpecKey };
@@ -1 +1,16 @@
1
- function e(e,t){e.register(t.type,async e=>{let n=t.schema.parse(e.payload);await t.handler(n,e)})}export{e as registerDefinedJob};
1
+ //#region src/jobs/define-job.ts
2
+ /**
3
+ * Register a `DefinedJob` on a queue with payload validation.
4
+ *
5
+ * - Parses and validates payload via the job's Zod schema
6
+ * - Invokes the defined handler with the validated payload
7
+ */
8
+ function registerDefinedJob(queue, job) {
9
+ queue.register(job.type, async (queuedJob) => {
10
+ const parsed = job.schema.parse(queuedJob.payload);
11
+ await job.handler(parsed, queuedJob);
12
+ });
13
+ }
14
+
15
+ //#endregion
16
+ export { registerDefinedJob };
@@ -1 +1,53 @@
1
- import{DEFAULT_RETRY_POLICY as e}from"./queue.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=i.delaySeconds==null?void 0:{seconds:Math.floor(Date.now()/1e3)+i.delaySeconds},o=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:o,headers:{"Content-Type":`application/json`},oidcToken:this.options.serviceAccountEmail?{serviceAccountEmail:this.options.serviceAccountEmail}:void 0},scheduleTime:a}}),{id:t(),type:n,version:1,payload:r,status:`pending`,priority:i.priority??0,attempts:0,maxRetries:i.maxRetries??e.maxRetries,createdAt:new Date,updatedAt:new Date}}register(e,t){this.handlers.set(e,t)}start(){}async stop(){this.handlers.clear()}};export{n as GcpCloudTasksQueue};
1
+ import { DEFAULT_RETRY_POLICY } from "./queue.js";
2
+ import { randomUUID } from "node:crypto";
3
+
4
+ //#region src/jobs/gcp-cloud-tasks.ts
5
+ var GcpCloudTasksQueue = class {
6
+ handlers = /* @__PURE__ */ new Map();
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ async enqueue(jobType, payload, options = {}) {
11
+ const enqueueTime = options.delaySeconds != null ? { seconds: Math.floor(Date.now() / 1e3) + options.delaySeconds } : void 0;
12
+ const body = Buffer.from(JSON.stringify({
13
+ id: randomUUID(),
14
+ type: jobType,
15
+ payload
16
+ }), "utf-8");
17
+ await this.options.client.createTask({
18
+ parent: `projects/${this.options.projectId}/locations/${this.options.location}/queues/${this.options.queue}`,
19
+ task: {
20
+ httpRequest: {
21
+ httpMethod: "POST",
22
+ url: this.options.resolveUrl(jobType),
23
+ body,
24
+ headers: { "Content-Type": "application/json" },
25
+ oidcToken: this.options.serviceAccountEmail ? { serviceAccountEmail: this.options.serviceAccountEmail } : void 0
26
+ },
27
+ scheduleTime: enqueueTime
28
+ }
29
+ });
30
+ return {
31
+ id: randomUUID(),
32
+ type: jobType,
33
+ version: 1,
34
+ payload,
35
+ status: "pending",
36
+ priority: options.priority ?? 0,
37
+ attempts: 0,
38
+ maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
39
+ createdAt: /* @__PURE__ */ new Date(),
40
+ updatedAt: /* @__PURE__ */ new Date()
41
+ };
42
+ }
43
+ register(jobType, handler) {
44
+ this.handlers.set(jobType, handler);
45
+ }
46
+ start() {}
47
+ async stop() {
48
+ this.handlers.clear();
49
+ }
50
+ };
51
+
52
+ //#endregion
53
+ export { GcpCloudTasksQueue };
@@ -1 +1,39 @@
1
- import{DEFAULT_RETRY_POLICY as e}from"./queue.js";import{randomUUID as t}from"node:crypto";var n=class{handlers=new Map;constructor(e){this.options=e}async enqueue(n,r,i={}){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:new Date,updatedAt:new Date}}register(e,t){this.handlers.set(e,t)}start(){}async stop(){this.handlers.clear()}};export{n as GcpPubSubQueue};
1
+ import { DEFAULT_RETRY_POLICY } from "./queue.js";
2
+ import { randomUUID } from "node:crypto";
3
+
4
+ //#region src/jobs/gcp-pubsub.ts
5
+ var GcpPubSubQueue = class {
6
+ handlers = /* @__PURE__ */ new Map();
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ async enqueue(jobType, payload, options = {}) {
11
+ await this.options.client.topic(this.options.topicName).publishMessage({ data: Buffer.from(JSON.stringify({
12
+ id: randomUUID(),
13
+ type: jobType,
14
+ payload
15
+ }), "utf-8") });
16
+ return {
17
+ id: randomUUID(),
18
+ type: jobType,
19
+ version: 1,
20
+ payload,
21
+ status: "pending",
22
+ priority: options.priority ?? 0,
23
+ attempts: 0,
24
+ maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
25
+ createdAt: /* @__PURE__ */ new Date(),
26
+ updatedAt: /* @__PURE__ */ new Date()
27
+ };
28
+ }
29
+ register(jobType, handler) {
30
+ this.handlers.set(jobType, handler);
31
+ }
32
+ start() {}
33
+ async stop() {
34
+ this.handlers.clear();
35
+ }
36
+ };
37
+
38
+ //#endregion
39
+ export { GcpPubSubQueue };
@@ -1 +1,9 @@
1
- function e(e){return async t=>{await e.syncThreads(t.payload)}}export{e as createGmailSyncHandler};
1
+ //#region src/jobs/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"../define-job.js";import{createGmailSyncHandler as t}from"./gmail-sync-handler.js";import{PING_JOB_TYPE as n,PingPayloadSchema as r,pingJob as i}from"./ping-handler.js";import{createStorageDocumentHandler as a}from"./storage-document-handler.js";function o(t){e(t,i)}export{n as PING_JOB_TYPE,r as PingPayloadSchema,t as createGmailSyncHandler,a as createStorageDocumentHandler,i as pingJob,o as registerAllJobs};
1
+ import { registerDefinedJob } from "../define-job.js";
2
+ import { createGmailSyncHandler } from "./gmail-sync-handler.js";
3
+ import { PING_JOB_TYPE, PingPayloadSchema, pingJob } from "./ping-handler.js";
4
+ import { createStorageDocumentHandler } from "./storage-document-handler.js";
5
+
6
+ //#region src/jobs/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 +1,15 @@
1
- import*as e from"zod";const t=`core.ping`,n=e.object({}),r={type:t,schema:n,handler:async(e,t)=>{console.log(`[ping] job id=%s attempts=%d`,t.id,t.attempts)}};export{t as PING_JOB_TYPE,n as PingPayloadSchema,r as pingJob};
1
+ import * as z$1 from "zod";
2
+
3
+ //#region src/jobs/handlers/ping-handler.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
+ console.log("[ping] job id=%s attempts=%d", job.id, job.attempts);
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ 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/jobs/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 };
@@ -1 +1,4 @@
1
- import{registerDefinedJob as e}from"./define-job.js";import{DEFAULT_RETRY_POLICY as t,calculateBackoff as n,defineJobType as r}from"./queue.js";export{t as DEFAULT_RETRY_POLICY,n as calculateBackoff,r as defineJobType,e as registerDefinedJob};
1
+ import { registerDefinedJob } from "./define-job.js";
2
+ import { DEFAULT_RETRY_POLICY, calculateBackoff, defineJobType } from "./queue.js";
3
+
4
+ export { DEFAULT_RETRY_POLICY, calculateBackoff, defineJobType, registerDefinedJob };
@@ -1 +1,71 @@
1
- import{DEFAULT_RETRY_POLICY as e}from"./queue.js";import{randomUUID as t}from"node:crypto";var n=class{jobs=[];handlers=new Map;timer;processing=!1;constructor(e=200){this.pollIntervalMs=e}async enqueue(n,r,i={}){let a={id:t(),type:n,version:1,payload:r,status:`pending`,priority:i.priority??0,attempts:0,maxRetries:i.maxRetries??e.maxRetries,createdAt:new Date,updatedAt:new Date};return i.delaySeconds&&(a.updatedAt=new Date(Date.now()+i.delaySeconds*1e3)),this.jobs.push(a),a}register(e,t){this.handlers.set(e,t)}start(){this.timer||=setInterval(()=>{this.processNext()},this.pollIntervalMs)}async stop(){for(this.timer&&=(clearInterval(this.timer),void 0);this.processing;)await new Promise(e=>setTimeout(e,10))}async processNext(){if(this.processing)return;let e=this.jobs.find(e=>e.status===`pending`&&e.updatedAt<=new Date);if(!e)return;let t=this.handlers.get(e.type);if(t){this.processing=!0,e.status=`running`,e.updatedAt=new Date,e.attempts+=1;try{await t(e),e.status=`completed`,e.updatedAt=new Date}catch(t){e.status=`failed`,e.lastError=t instanceof Error?t.message:`Unknown job error`,e.updatedAt=new Date}finally{this.processing=!1}}}};export{n as MemoryJobQueue};
1
+ import { DEFAULT_RETRY_POLICY } from "./queue.js";
2
+ import { randomUUID } from "node:crypto";
3
+
4
+ //#region src/jobs/memory-queue.ts
5
+ var MemoryJobQueue = class {
6
+ jobs = [];
7
+ handlers = /* @__PURE__ */ new Map();
8
+ timer;
9
+ processing = false;
10
+ constructor(pollIntervalMs = 200) {
11
+ this.pollIntervalMs = pollIntervalMs;
12
+ }
13
+ async enqueue(jobType, payload, options = {}) {
14
+ const job = {
15
+ id: randomUUID(),
16
+ type: jobType,
17
+ version: 1,
18
+ payload,
19
+ status: "pending",
20
+ priority: options.priority ?? 0,
21
+ attempts: 0,
22
+ maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
23
+ createdAt: /* @__PURE__ */ new Date(),
24
+ updatedAt: /* @__PURE__ */ new Date()
25
+ };
26
+ if (options.delaySeconds) job.updatedAt = new Date(Date.now() + options.delaySeconds * 1e3);
27
+ this.jobs.push(job);
28
+ return job;
29
+ }
30
+ register(jobType, handler) {
31
+ this.handlers.set(jobType, handler);
32
+ }
33
+ start() {
34
+ if (this.timer) return;
35
+ this.timer = setInterval(() => {
36
+ this.processNext();
37
+ }, this.pollIntervalMs);
38
+ }
39
+ async stop() {
40
+ if (this.timer) {
41
+ clearInterval(this.timer);
42
+ this.timer = void 0;
43
+ }
44
+ while (this.processing) await new Promise((resolve) => setTimeout(resolve, 10));
45
+ }
46
+ async processNext() {
47
+ if (this.processing) return;
48
+ const job = this.jobs.find((j) => j.status === "pending" && j.updatedAt <= /* @__PURE__ */ new Date());
49
+ if (!job) return;
50
+ const handler = this.handlers.get(job.type);
51
+ if (!handler) return;
52
+ this.processing = true;
53
+ job.status = "running";
54
+ job.updatedAt = /* @__PURE__ */ new Date();
55
+ job.attempts += 1;
56
+ try {
57
+ await handler(job);
58
+ job.status = "completed";
59
+ job.updatedAt = /* @__PURE__ */ new Date();
60
+ } catch (error) {
61
+ job.status = "failed";
62
+ job.lastError = error instanceof Error ? error.message : "Unknown job error";
63
+ job.updatedAt = /* @__PURE__ */ new Date();
64
+ } finally {
65
+ this.processing = false;
66
+ }
67
+ }
68
+ };
69
+
70
+ //#endregion
71
+ export { MemoryJobQueue };
@@ -1 +1,33 @@
1
- import"zod";const e={maxRetries:3,initialBackoffMs:1e3,maxBackoffMs:6e4,multiplier:2,jitter:!0};function t(t,n=e){let r=Math.min(n.initialBackoffMs*n.multiplier**(t-1),n.maxBackoffMs);if(n.jitter){let e=.8+Math.random()*.4;return Math.floor(r*e)}return r}function n(e){return e}export{e as DEFAULT_RETRY_POLICY,t as calculateBackoff,n as defineJobType};
1
+ import "zod";
2
+
3
+ //#region src/jobs/queue.ts
4
+ /**
5
+ * Default retry policy.
6
+ */
7
+ const DEFAULT_RETRY_POLICY = {
8
+ maxRetries: 3,
9
+ initialBackoffMs: 1e3,
10
+ maxBackoffMs: 6e4,
11
+ multiplier: 2,
12
+ jitter: true
13
+ };
14
+ /**
15
+ * Calculate backoff delay for a retry attempt.
16
+ */
17
+ function calculateBackoff(attempt, policy = DEFAULT_RETRY_POLICY) {
18
+ const baseDelay = Math.min(policy.initialBackoffMs * Math.pow(policy.multiplier, attempt - 1), policy.maxBackoffMs);
19
+ if (policy.jitter) {
20
+ const jitterFactor = .8 + Math.random() * .4;
21
+ return Math.floor(baseDelay * jitterFactor);
22
+ }
23
+ return baseDelay;
24
+ }
25
+ /**
26
+ * Define a typed job type.
27
+ */
28
+ function defineJobType(def) {
29
+ return def;
30
+ }
31
+
32
+ //#endregion
33
+ export { DEFAULT_RETRY_POLICY, calculateBackoff, defineJobType };
@@ -1 +1,153 @@
1
- import{DEFAULT_RETRY_POLICY as e}from"./queue.js";import{randomUUID as t}from"crypto";import{DeleteMessageCommand as n,ReceiveMessageCommand as r,SQSClient as i,SendMessageCommand as a}from"@aws-sdk/client-sqs";var o=class{sqs;queueUrl;waitTimeSeconds;maxNumberOfMessages;visibilityTimeoutSeconds;handlers=new Map;running=!1;constructor(e){let t=process.env.SCALEWAY_ACCESS_KEY_QUEUE,n=process.env.SCALEWAY_SECRET_KEY_QUEUE;if(!t||!n)throw Error(`Missing SCALEWAY_ACCESS_KEY_QUEUE / SCALEWAY_SECRET_KEY_QUEUE in env`);this.sqs=new i({region:e.region??process.env.SCALEWAY_REGION??`par`,endpoint:`https://sqs.mnq.fr-par.scaleway.com`,credentials:{accessKeyId:t,secretAccessKey:n}}),this.queueUrl=e.queueUrl,this.waitTimeSeconds=e.waitTimeSeconds??20,this.maxNumberOfMessages=e.maxNumberOfMessages??5,this.visibilityTimeoutSeconds=e.visibilityTimeoutSeconds??60}async enqueue(n,r,i={}){let o=t(),s=new Date,c={id:o,type:n,payload:r};return await this.sqs.send(new a({QueueUrl:this.queueUrl,MessageBody:JSON.stringify(c),DelaySeconds:i.delaySeconds??0})),{id:o,type:n,version:1,payload:r,status:`pending`,priority:i.priority??0,attempts:0,maxRetries:i.maxRetries??e.maxRetries,createdAt:s,updatedAt:s}}register(e,t){if(this.handlers.has(e))throw Error(`Handler already registered for job type "${e}"`);this.handlers.set(e,t)}start(){this.running||(this.running=!0,this.pollLoop().catch(e=>{console.error(`[queue] Fatal error in poll loop`,e),process.exit(1)}))}async stop(){this.running=!1}async pollLoop(){for(console.log(`[queue] SQS worker started for queue:`,this.queueUrl);this.running;)try{let t=(await this.sqs.send(new r({QueueUrl:this.queueUrl,MaxNumberOfMessages:this.maxNumberOfMessages,WaitTimeSeconds:this.waitTimeSeconds,VisibilityTimeout:this.visibilityTimeoutSeconds,MessageSystemAttributeNames:[`ApproximateReceiveCount`]}))).Messages??[];if(t.length===0)continue;for(let n of t){if(!n.Body||!n.ReceiptHandle){console.warn(`[queue] Message missing Body or ReceiptHandle`,n.MessageId);continue}let t;try{t=JSON.parse(n.Body)}catch(e){console.error(`[queue] Failed to parse message body (id=${n.MessageId}), deleting`,e),await this.deleteMessage(n.ReceiptHandle);continue}let r=this.handlers.get(t.type);if(!r){console.error(`[queue] No handler registered for type "${t.type}", deleting message`),await this.deleteMessage(n.ReceiptHandle);continue}let i=new Date,a=parseInt(n.Attributes?.ApproximateReceiveCount??`1`,10),o={id:t.id,type:t.type,version:1,payload:t.payload,status:`pending`,priority:0,attempts:a,maxRetries:e.maxRetries,createdAt:i,updatedAt:i};o.status=`running`,o.updatedAt=new Date;try{await r(o),o.status=`completed`,o.updatedAt=new Date,await this.deleteMessage(n.ReceiptHandle)}catch(e){o.status=`failed`,o.lastError=e instanceof Error?e.message:`Unknown job error`,o.updatedAt=new Date,console.error(`[queue] Error while handling job type=${o.type} id=${o.id}`,e)}}}catch(e){e&&typeof e==`object`&&`$response`in e?console.error(`[queue] Error while polling SQS`,e,e.$response):console.error(`[queue] Error while polling SQS`,e),await this.sleep(5e3)}console.log(`[queue] SQS worker stopped`)}async deleteMessage(e){try{await this.sqs.send(new n({QueueUrl:this.queueUrl,ReceiptHandle:e}))}catch(e){console.error(`[queue] Failed to delete message`,e)}}async sleep(e){await new Promise(t=>setTimeout(t,e))}};export{o as ScalewaySqsJobQueue};
1
+ import { DEFAULT_RETRY_POLICY } from "./queue.js";
2
+ import { randomUUID } from "crypto";
3
+ import { DeleteMessageCommand, ReceiveMessageCommand, SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs";
4
+
5
+ //#region src/jobs/scaleway-sqs-queue.ts
6
+ var ScalewaySqsJobQueue = class {
7
+ sqs;
8
+ queueUrl;
9
+ waitTimeSeconds;
10
+ maxNumberOfMessages;
11
+ visibilityTimeoutSeconds;
12
+ handlers = /* @__PURE__ */ new Map();
13
+ running = false;
14
+ constructor(config) {
15
+ const accessKeyId = process.env.SCALEWAY_ACCESS_KEY_QUEUE;
16
+ const secretAccessKey = process.env.SCALEWAY_SECRET_KEY_QUEUE;
17
+ if (!accessKeyId || !secretAccessKey) throw new Error("Missing SCALEWAY_ACCESS_KEY_QUEUE / SCALEWAY_SECRET_KEY_QUEUE in env");
18
+ this.sqs = new SQSClient({
19
+ region: config.region ?? process.env.SCALEWAY_REGION ?? "par",
20
+ endpoint: "https://sqs.mnq.fr-par.scaleway.com",
21
+ credentials: {
22
+ accessKeyId,
23
+ secretAccessKey
24
+ }
25
+ });
26
+ this.queueUrl = config.queueUrl;
27
+ this.waitTimeSeconds = config.waitTimeSeconds ?? 20;
28
+ this.maxNumberOfMessages = config.maxNumberOfMessages ?? 5;
29
+ this.visibilityTimeoutSeconds = config.visibilityTimeoutSeconds ?? 60;
30
+ }
31
+ async enqueue(jobType, payload, options = {}) {
32
+ const id = randomUUID();
33
+ const now = /* @__PURE__ */ new Date();
34
+ const envelope = {
35
+ id,
36
+ type: jobType,
37
+ payload
38
+ };
39
+ await this.sqs.send(new SendMessageCommand({
40
+ QueueUrl: this.queueUrl,
41
+ MessageBody: JSON.stringify(envelope),
42
+ DelaySeconds: options.delaySeconds ?? 0
43
+ }));
44
+ return {
45
+ id,
46
+ type: jobType,
47
+ version: 1,
48
+ payload,
49
+ status: "pending",
50
+ priority: options.priority ?? 0,
51
+ attempts: 0,
52
+ maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY.maxRetries,
53
+ createdAt: now,
54
+ updatedAt: now
55
+ };
56
+ }
57
+ register(jobType, handler) {
58
+ if (this.handlers.has(jobType)) throw new Error(`Handler already registered for job type "${jobType}"`);
59
+ this.handlers.set(jobType, handler);
60
+ }
61
+ start() {
62
+ if (this.running) return;
63
+ this.running = true;
64
+ this.pollLoop().catch((err) => {
65
+ console.error("[queue] Fatal error in poll loop", err);
66
+ process.exit(1);
67
+ });
68
+ }
69
+ async stop() {
70
+ this.running = false;
71
+ }
72
+ async pollLoop() {
73
+ console.log("[queue] SQS worker started for queue:", this.queueUrl);
74
+ while (this.running) try {
75
+ const messages = (await this.sqs.send(new ReceiveMessageCommand({
76
+ QueueUrl: this.queueUrl,
77
+ MaxNumberOfMessages: this.maxNumberOfMessages,
78
+ WaitTimeSeconds: this.waitTimeSeconds,
79
+ VisibilityTimeout: this.visibilityTimeoutSeconds,
80
+ MessageSystemAttributeNames: ["ApproximateReceiveCount"]
81
+ }))).Messages ?? [];
82
+ if (messages.length === 0) continue;
83
+ for (const msg of messages) {
84
+ if (!msg.Body || !msg.ReceiptHandle) {
85
+ console.warn("[queue] Message missing Body or ReceiptHandle", msg.MessageId);
86
+ continue;
87
+ }
88
+ let envelope;
89
+ try {
90
+ envelope = JSON.parse(msg.Body);
91
+ } catch (err) {
92
+ console.error(`[queue] Failed to parse message body (id=${msg.MessageId}), deleting`, err);
93
+ await this.deleteMessage(msg.ReceiptHandle);
94
+ continue;
95
+ }
96
+ const handler = this.handlers.get(envelope.type);
97
+ if (!handler) {
98
+ console.error(`[queue] No handler registered for type "${envelope.type}", deleting message`);
99
+ await this.deleteMessage(msg.ReceiptHandle);
100
+ continue;
101
+ }
102
+ const now = /* @__PURE__ */ new Date();
103
+ const attempts = parseInt(msg.Attributes?.ApproximateReceiveCount ?? "1", 10);
104
+ const job = {
105
+ id: envelope.id,
106
+ type: envelope.type,
107
+ version: 1,
108
+ payload: envelope.payload,
109
+ status: "pending",
110
+ priority: 0,
111
+ attempts,
112
+ maxRetries: DEFAULT_RETRY_POLICY.maxRetries,
113
+ createdAt: now,
114
+ updatedAt: now
115
+ };
116
+ job.status = "running";
117
+ job.updatedAt = /* @__PURE__ */ new Date();
118
+ try {
119
+ await handler(job);
120
+ job.status = "completed";
121
+ job.updatedAt = /* @__PURE__ */ new Date();
122
+ await this.deleteMessage(msg.ReceiptHandle);
123
+ } catch (err) {
124
+ job.status = "failed";
125
+ job.lastError = err instanceof Error ? err.message : "Unknown job error";
126
+ job.updatedAt = /* @__PURE__ */ new Date();
127
+ console.error(`[queue] Error while handling job type=${job.type} id=${job.id}`, err);
128
+ }
129
+ }
130
+ } catch (err) {
131
+ if (!!err && typeof err === "object" && "$response" in err) console.error("[queue] Error while polling SQS", err, err.$response);
132
+ else console.error("[queue] Error while polling SQS", err);
133
+ await this.sleep(5e3);
134
+ }
135
+ console.log("[queue] SQS worker stopped");
136
+ }
137
+ async deleteMessage(receiptHandle) {
138
+ try {
139
+ await this.sqs.send(new DeleteMessageCommand({
140
+ QueueUrl: this.queueUrl,
141
+ ReceiptHandle: receiptHandle
142
+ }));
143
+ } catch (err) {
144
+ console.error("[queue] Failed to delete message", err);
145
+ }
146
+ }
147
+ async sleep(ms) {
148
+ await new Promise((resolve) => setTimeout(resolve, ms));
149
+ }
150
+ };
151
+
152
+ //#endregion
153
+ export { ScalewaySqsJobQueue };
@@ -1,13 +1,13 @@
1
1
  import { Stability, Tag } from "./ownership.js";
2
2
  import { ContractSpec, OpKind } from "./spec.js";
3
3
  import z from "zod";
4
- import * as _lssm_lib_schema84 from "@lssm/lib.schema";
4
+ import * as _lssm_lib_schema0 from "@lssm/lib.schema";
5
5
  import { AnySchemaModel } from "@lssm/lib.schema";
6
6
 
7
7
  //#region src/jsonschema.d.ts
8
8
  declare function jsonSchemaForSpec(spec: ContractSpec<AnySchemaModel, AnySchemaModel>): {
9
- input: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema84.TopLevelZodFromModel<_lssm_lib_schema84.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema84.AnyFieldType | _lssm_lib_schema84.AnyEnumType>>> | null;
10
- output: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema84.TopLevelZodFromModel<_lssm_lib_schema84.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema84.AnyFieldType | _lssm_lib_schema84.AnyEnumType>>> | null;
9
+ input: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema0.TopLevelZodFromModel<_lssm_lib_schema0.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema0.AnyFieldType | _lssm_lib_schema0.AnyEnumType>>> | null;
10
+ output: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema0.TopLevelZodFromModel<_lssm_lib_schema0.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema0.AnyFieldType | _lssm_lib_schema0.AnyEnumType>>> | null;
11
11
  meta: {
12
12
  name: string;
13
13
  version: number;
@@ -1 +1,32 @@
1
- import e from"zod";function t(t){return{input:t.io.input?e.toJSONSchema(t.io.input.getZod()):null,output:t.io.output?e.toJSONSchema(t.io.output.getZod()):null,meta:{name:t.meta.name,version:t.meta.version,kind:t.meta.kind,description:t.meta.description,tags:t.meta.tags??[],stability:t.meta.stability??`stable`}}}function n(e,t){return`/${e.replace(/\./g,`/`)}/v${t}`}function r(e,t){return`${e}.v${t}`}function i(e,t){return`${e.replace(/\./g,`_`)}_v${t}`}export{i as defaultGqlField,r as defaultMcpTool,n as defaultRestPath,t as jsonSchemaForSpec};
1
+ import z from "zod";
2
+
3
+ //#region src/jsonschema.ts
4
+ function jsonSchemaForSpec(spec) {
5
+ return {
6
+ input: spec.io.input ? z.toJSONSchema(spec.io.input.getZod()) : null,
7
+ output: spec.io.output ? z.toJSONSchema(spec.io.output.getZod()) : null,
8
+ meta: {
9
+ name: spec.meta.name,
10
+ version: spec.meta.version,
11
+ kind: spec.meta.kind,
12
+ description: spec.meta.description,
13
+ tags: spec.meta.tags ?? [],
14
+ stability: spec.meta.stability ?? "stable"
15
+ }
16
+ };
17
+ }
18
+ /** Helper to derive default REST path */
19
+ function defaultRestPath(name, version) {
20
+ return `/${name.replace(/\./g, "/")}/v${version}`;
21
+ }
22
+ /** Helper to derive default MCP tool name */
23
+ function defaultMcpTool(name, version) {
24
+ return `${name}.v${version}`;
25
+ }
26
+ /** Helper to derive default GraphQL field name */
27
+ function defaultGqlField(name, version) {
28
+ return `${name.replace(/\./g, "_")}_v${version}`;
29
+ }
30
+
31
+ //#endregion
32
+ export { defaultGqlField, defaultMcpTool, defaultRestPath, jsonSchemaForSpec };