@lssm/lib.contracts 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217073102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-config/app-config.feature.js +53 -1
- package/dist/app-config/contracts.d.ts +50 -50
- package/dist/app-config/contracts.js +396 -1
- package/dist/app-config/docs/app-config.docblock.js +22 -220
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/events.js +168 -1
- package/dist/app-config/index.js +8 -1
- package/dist/app-config/lifecycle-contracts.d.ts +80 -80
- package/dist/app-config/lifecycle-contracts.js +441 -1
- package/dist/app-config/runtime.js +617 -1
- package/dist/app-config/spec.js +36 -1
- package/dist/app-config/validation.js +538 -1
- package/dist/capabilities/docs/capabilities.docblock.js +22 -1
- package/dist/capabilities/openbanking.js +92 -1
- package/dist/capabilities.js +50 -1
- package/dist/client/index.js +9 -1
- package/dist/client/react/drivers/rn-reusables.js +21 -1
- package/dist/client/react/drivers/shadcn.js +11 -1
- package/dist/client/react/feature-render.js +43 -1
- package/dist/client/react/form-render.js +298 -1
- package/dist/client/react/index.js +8 -1
- package/dist/contract-registry/index.js +3 -1
- package/dist/contract-registry/schemas.js +61 -1
- package/dist/contracts-adapter-hydration.js +41 -1
- package/dist/contracts-adapter-input.js +77 -1
- package/dist/data-views/docs/data-views.docblock.js +22 -1
- package/dist/data-views/query-generator.js +48 -1
- package/dist/data-views/runtime.js +39 -1
- package/dist/data-views.js +35 -1
- package/dist/docs/PUBLISHING.docblock.js +17 -76
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
- package/dist/docs/index.js +33 -1
- package/dist/docs/meta.docs.js +15 -2
- package/dist/docs/presentations.js +77 -1
- package/dist/docs/registry.js +51 -1
- package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
- package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
- package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
- package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
- package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
- package/dist/docs/tech/contracts/README.docblock.js +21 -1
- package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
- package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
- package/dist/docs/tech/contracts/tests.docblock.js +21 -132
- package/dist/docs/tech/contracts/themes.docblock.js +21 -1
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
- package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
- package/dist/docs/tech/schema/README.docblock.js +21 -262
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
- package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
- package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
- package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
- package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
- package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
- package/dist/docs/tech/templates/runtime.docblock.js +21 -1
- package/dist/docs/tech/vscode-extension.docblock.js +37 -3
- package/dist/docs/tech/workflows/overview.docblock.js +21 -1
- package/dist/docs/tech-contracts.docs.js +19 -2
- package/dist/events.js +12 -1
- package/dist/experiments/docs/experiments.docblock.js +22 -128
- package/dist/experiments/evaluator.js +101 -1
- package/dist/experiments/spec.js +33 -1
- package/dist/features.js +68 -1
- package/dist/forms/docs/forms.docblock.js +22 -1
- package/dist/forms.js +119 -1
- package/dist/index.js +107 -1
- package/dist/install.js +40 -1
- package/dist/integrations/contracts.d.ts +102 -102
- package/dist/integrations/contracts.js +388 -1
- package/dist/integrations/docs/integrations.docblock.js +95 -1
- package/dist/integrations/health.js +69 -1
- package/dist/integrations/index.js +23 -1
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/accounts.js +237 -1
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/balances.js +167 -1
- package/dist/integrations/openbanking/contracts/index.js +12 -1
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/contracts/transactions.js +218 -1
- package/dist/integrations/openbanking/guards.js +32 -1
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/openbanking/models.js +242 -1
- package/dist/integrations/openbanking/openbanking.feature.js +68 -1
- package/dist/integrations/openbanking/telemetry.js +39 -1
- package/dist/integrations/providers/elevenlabs.js +56 -1
- package/dist/integrations/providers/gcs-storage.js +79 -1
- package/dist/integrations/providers/gmail.js +91 -1
- package/dist/integrations/providers/google-calendar.js +70 -1
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
- package/dist/integrations/providers/impls/gcs-storage.js +88 -1
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
- package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
- package/dist/integrations/providers/impls/google-calendar.js +154 -1
- package/dist/integrations/providers/impls/index.js +16 -1
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
- package/dist/integrations/providers/impls/mistral-llm.js +247 -1
- package/dist/integrations/providers/impls/postmark-email.js +55 -1
- package/dist/integrations/providers/impls/powens-client.js +171 -1
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
- package/dist/integrations/providers/impls/provider-factory.js +142 -1
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
- package/dist/integrations/providers/impls/stripe-payments.js +202 -1
- package/dist/integrations/providers/impls/twilio-sms.js +58 -1
- package/dist/integrations/providers/index.js +13 -1
- package/dist/integrations/providers/mistral.js +72 -1
- package/dist/integrations/providers/postmark.js +72 -1
- package/dist/integrations/providers/powens.js +120 -1
- package/dist/integrations/providers/qdrant.js +77 -1
- package/dist/integrations/providers/registry.js +34 -1
- package/dist/integrations/providers/stripe.js +87 -1
- package/dist/integrations/providers/twilio-sms.js +65 -1
- package/dist/integrations/runtime.js +186 -1
- package/dist/integrations/secrets/aws-secret-manager.js +231 -1
- package/dist/integrations/secrets/env-secret-provider.js +81 -1
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
- package/dist/integrations/secrets/index.js +8 -1
- package/dist/integrations/secrets/manager.js +103 -1
- package/dist/integrations/secrets/provider.js +58 -1
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
- package/dist/integrations/spec.js +39 -1
- package/dist/jobs/define-job.js +16 -1
- package/dist/jobs/gcp-cloud-tasks.js +53 -1
- package/dist/jobs/gcp-pubsub.js +39 -1
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
- package/dist/jobs/handlers/index.js +12 -1
- package/dist/jobs/handlers/ping-handler.js +15 -1
- package/dist/jobs/handlers/storage-document-handler.js +14 -1
- package/dist/jobs/index.js +4 -1
- package/dist/jobs/memory-queue.js +71 -1
- package/dist/jobs/queue.js +33 -1
- package/dist/jobs/scaleway-sqs-queue.js +153 -1
- package/dist/jsonschema.d.ts +3 -3
- package/dist/jsonschema.js +32 -1
- package/dist/knowledge/contracts.d.ts +66 -66
- package/dist/knowledge/contracts.js +317 -1
- package/dist/knowledge/docs/knowledge.docblock.js +22 -138
- package/dist/knowledge/index.js +10 -1
- package/dist/knowledge/ingestion/document-processor.js +54 -1
- package/dist/knowledge/ingestion/embedding-service.js +25 -1
- package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
- package/dist/knowledge/ingestion/index.js +7 -1
- package/dist/knowledge/ingestion/storage-adapter.js +26 -1
- package/dist/knowledge/ingestion/vector-indexer.js +32 -1
- package/dist/knowledge/query/index.js +3 -1
- package/dist/knowledge/query/service.js +64 -2
- package/dist/knowledge/runtime.js +49 -1
- package/dist/knowledge/spaces/email-threads.js +38 -1
- package/dist/knowledge/spaces/financial-docs.js +38 -1
- package/dist/knowledge/spaces/financial-overview.js +42 -1
- package/dist/knowledge/spaces/index.js +8 -1
- package/dist/knowledge/spaces/product-canon.js +38 -1
- package/dist/knowledge/spaces/support-faq.js +41 -1
- package/dist/knowledge/spaces/uploaded-docs.js +38 -1
- package/dist/knowledge/spec.js +39 -1
- package/dist/llm/exporters.js +541 -8
- package/dist/llm/index.js +4 -1
- package/dist/llm/prompts.js +246 -56
- package/dist/markdown.js +116 -3
- package/dist/migrations.js +33 -1
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/onboarding-base.js +196 -1
- package/dist/openapi.js +75 -1
- package/dist/openbanking/docs/openbanking.docblock.js +22 -109
- package/dist/ownership.js +40 -1
- package/dist/policy/docs/policy.docblock.js +22 -1
- package/dist/policy/engine.js +223 -1
- package/dist/policy/opa-adapter.js +71 -1
- package/dist/policy/spec.js +33 -1
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
- package/dist/presentations.backcompat.js +47 -1
- package/dist/presentations.d.ts +3 -3
- package/dist/presentations.js +66 -1
- package/dist/presentations.v2.js +278 -6
- package/dist/prompt.js +10 -1
- package/dist/promptRegistry.js +34 -1
- package/dist/regenerator/docs/regenerator.docblock.js +22 -184
- package/dist/regenerator/executor.js +86 -1
- package/dist/regenerator/index.js +6 -1
- package/dist/regenerator/service.js +92 -1
- package/dist/regenerator/sinks.js +32 -1
- package/dist/regenerator/utils.js +51 -1
- package/dist/registry.js +208 -1
- package/dist/resources.js +47 -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 +1 -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/dist/schema-to-markdown.js +214 -10
- package/dist/server/graphql-pothos.js +128 -1
- package/dist/server/index.js +10 -1
- package/dist/server/mcp/createMcpServer.js +28 -1
- package/dist/server/mcp/registerPresentations.js +151 -1
- package/dist/server/mcp/registerPrompts.js +36 -2
- package/dist/server/mcp/registerResources.js +35 -1
- package/dist/server/mcp/registerTools.js +22 -1
- package/dist/server/provider-mcp.js +3 -1
- package/dist/server/rest-elysia.js +20 -1
- package/dist/server/rest-express.js +39 -1
- package/dist/server/rest-generic.js +125 -1
- package/dist/server/rest-next-app.js +38 -1
- package/dist/server/rest-next-mcp.js +45 -1
- package/dist/server/rest-next-pages.js +25 -1
- package/dist/spec.js +35 -1
- package/dist/telemetry/anomaly.js +48 -1
- package/dist/telemetry/docs/telemetry.docblock.js +22 -139
- package/dist/telemetry/index.js +5 -1
- package/dist/telemetry/spec.js +69 -1
- package/dist/telemetry/tracker.js +76 -1
- package/dist/tests/index.js +4 -1
- package/dist/tests/runner.js +150 -1
- package/dist/tests/spec.js +33 -1
- package/dist/themes.js +39 -1
- package/dist/workflow/adapters/db-adapter.js +83 -1
- package/dist/workflow/adapters/file-adapter.js +11 -1
- package/dist/workflow/adapters/index.js +5 -1
- package/dist/workflow/adapters/memory-store.js +58 -1
- package/dist/workflow/expression.js +98 -1
- package/dist/workflow/index.js +9 -1
- package/dist/workflow/runner.js +337 -1
- package/dist/workflow/sla-monitor.js +47 -1
- package/dist/workflow/spec.js +32 -1
- package/dist/workflow/validation.js +175 -1
- package/package.json +11 -4
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
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 };
|
package/dist/jobs/define-job.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
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
|
|
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 };
|
package/dist/jobs/gcp-pubsub.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
import{DEFAULT_RETRY_POLICY
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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 };
|
package/dist/jobs/index.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{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
|
|
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 };
|
package/dist/jobs/queue.js
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
import"zod";
|
|
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
|
|
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 };
|
package/dist/jsonschema.d.ts
CHANGED
|
@@ -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
|
|
4
|
+
import * as _lssm_lib_schema100 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<
|
|
10
|
-
output: z.core.ZodStandardJSONSchemaPayload<
|
|
9
|
+
input: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema100.TopLevelZodFromModel<_lssm_lib_schema100.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema100.AnyFieldType | _lssm_lib_schema100.AnyEnumType>>> | null;
|
|
10
|
+
output: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema100.TopLevelZodFromModel<_lssm_lib_schema100.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema100.AnyFieldType | _lssm_lib_schema100.AnyEnumType>>> | null;
|
|
11
11
|
meta: {
|
|
12
12
|
name: string;
|
|
13
13
|
version: number;
|
package/dist/jsonschema.js
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import
|
|
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 };
|