@qlever-llc/trellis 0.10.22 → 0.11.0-rc.1
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/esm/auth/mod.d.ts +1 -1
- package/esm/auth/mod.d.ts.map +1 -1
- package/esm/auth/mod.js +1 -1
- package/esm/auth/protocol.d.ts +55 -0
- package/esm/auth/protocol.d.ts.map +1 -1
- package/esm/browser.d.ts +3 -3
- package/esm/browser.d.ts.map +1 -1
- package/esm/browser.js +1 -1
- package/esm/client_connect.d.ts +12 -3
- package/esm/client_connect.d.ts.map +1 -1
- package/esm/client_connect.js +112 -7
- package/esm/codec.d.ts +7 -6
- package/esm/codec.d.ts.map +1 -1
- package/esm/codec.js +125 -6
- package/esm/contract_support/canonical.d.ts +3 -0
- package/esm/contract_support/canonical.d.ts.map +1 -1
- package/esm/contract_support/canonical.js +3 -0
- package/esm/contract_support/mod.d.ts +125 -10
- package/esm/contract_support/mod.d.ts.map +1 -1
- package/esm/contract_support/mod.js +159 -5
- package/esm/contract_support/protocol.d.ts +92 -7
- package/esm/contract_support/protocol.d.ts.map +1 -1
- package/esm/contract_support/protocol.js +41 -7
- package/esm/contract_support/runtime.d.ts +4 -1
- package/esm/contract_support/runtime.d.ts.map +1 -1
- package/esm/errors/SchemaValidationError.d.ts +49 -0
- package/esm/errors/SchemaValidationError.d.ts.map +1 -0
- package/esm/errors/SchemaValidationError.js +67 -0
- package/esm/errors/index.d.ts +38 -9
- package/esm/errors/index.d.ts.map +1 -1
- package/esm/errors/index.js +16 -0
- package/esm/generated-sdk/auth/api.d.ts +33 -605
- package/esm/generated-sdk/auth/api.d.ts.map +1 -1
- package/esm/generated-sdk/auth/api.js +6 -1
- package/esm/generated-sdk/auth/client.d.ts +129 -134
- package/esm/generated-sdk/auth/client.d.ts.map +1 -1
- package/esm/generated-sdk/auth/contract.d.ts +2 -601
- package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
- package/esm/generated-sdk/auth/contract.js +310 -93
- package/esm/generated-sdk/auth/mod.d.ts +1 -1
- package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
- package/esm/generated-sdk/auth/owned_api.d.ts +88 -86
- package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/auth/owned_api.js +6 -0
- package/esm/generated-sdk/auth/schemas.d.ts +284 -136
- package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/auth/schemas.js +231 -92
- package/esm/generated-sdk/auth/types.d.ts +565 -89
- package/esm/generated-sdk/auth/types.d.ts.map +1 -1
- package/esm/generated-sdk/auth/types.js +1 -1
- package/esm/generated-sdk/health/api.d.ts +29 -18
- package/esm/generated-sdk/health/api.d.ts.map +1 -1
- package/esm/generated-sdk/health/client.d.ts +7 -21
- package/esm/generated-sdk/health/client.d.ts.map +1 -1
- package/esm/generated-sdk/health/contract.d.ts +2 -15
- package/esm/generated-sdk/health/contract.d.ts.map +1 -1
- package/esm/generated-sdk/health/contract.js +2 -10
- package/esm/generated-sdk/health/mod.d.ts +1 -1
- package/esm/generated-sdk/health/mod.d.ts.map +1 -1
- package/esm/generated-sdk/health/owned_api.d.ts +2 -2
- package/esm/generated-sdk/health/schemas.d.ts +1 -14
- package/esm/generated-sdk/health/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/health/schemas.js +1 -9
- package/esm/generated-sdk/health/types.d.ts +10 -5
- package/esm/generated-sdk/health/types.d.ts.map +1 -1
- package/esm/generated-sdk/health/types.js +1 -2
- package/esm/generated-sdk/jobs/api.d.ts +29 -109
- package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/client.d.ts +21 -33
- package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/contract.d.ts +2 -106
- package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/contract.js +268 -1
- package/esm/generated-sdk/jobs/mod.d.ts +1 -1
- package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/owned_api.d.ts +22 -9
- package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/owned_api.js +20 -1
- package/esm/generated-sdk/jobs/schemas.d.ts +437 -0
- package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/schemas.js +211 -0
- package/esm/generated-sdk/jobs/types.d.ts +195 -12
- package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/types.js +1 -1
- package/esm/generated-sdk/state/api.d.ts +29 -68
- package/esm/generated-sdk/state/api.d.ts.map +1 -1
- package/esm/generated-sdk/state/client.d.ts +17 -31
- package/esm/generated-sdk/state/client.d.ts.map +1 -1
- package/esm/generated-sdk/state/contract.d.ts +1 -64
- package/esm/generated-sdk/state/contract.d.ts.map +1 -1
- package/esm/generated-sdk/state/mod.d.ts +1 -1
- package/esm/generated-sdk/state/mod.d.ts.map +1 -1
- package/esm/generated-sdk/state/owned_api.d.ts +7 -7
- package/esm/generated-sdk/state/types.d.ts +52 -9
- package/esm/generated-sdk/state/types.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/api.d.ts +33 -45
- package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/api.js +6 -1
- package/esm/generated-sdk/trellis-core/client.d.ts +31 -20
- package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/contract.d.ts +2 -41
- package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/contract.js +91 -1
- package/esm/generated-sdk/trellis-core/mod.d.ts +1 -1
- package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/owned_api.d.ts +4 -4
- package/esm/generated-sdk/trellis-core/schemas.d.ts +113 -0
- package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/schemas.js +81 -0
- package/esm/generated-sdk/trellis-core/types.d.ts +54 -7
- package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/types.js +1 -1
- package/esm/health.d.ts +1 -1
- package/esm/health.d.ts.map +1 -1
- package/esm/health.js +1 -1
- package/esm/index.d.ts +4 -4
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -2
- package/esm/jobs.d.ts +69 -3
- package/esm/jobs.d.ts.map +1 -1
- package/esm/jobs.js +92 -3
- package/esm/server/health.d.ts +2 -6
- package/esm/server/health.d.ts.map +1 -1
- package/esm/server/health_schemas.d.ts +0 -8
- package/esm/server/health_schemas.d.ts.map +1 -1
- package/esm/server/health_schemas.js +0 -5
- package/esm/server/internal_jobs/bindings.d.ts +11 -0
- package/esm/server/internal_jobs/bindings.d.ts.map +1 -1
- package/esm/server/internal_jobs/job-manager.d.ts +58 -2
- package/esm/server/internal_jobs/job-manager.d.ts.map +1 -1
- package/esm/server/internal_jobs/job-manager.js +429 -55
- package/esm/server/internal_jobs/key-coordinator.d.ts +269 -0
- package/esm/server/internal_jobs/key-coordinator.d.ts.map +1 -0
- package/esm/server/internal_jobs/key-coordinator.js +677 -0
- package/esm/server/internal_jobs/projection.d.ts.map +1 -1
- package/esm/server/internal_jobs/projection.js +2 -0
- package/esm/server/internal_jobs/runtime-worker.d.ts +5 -1
- package/esm/server/internal_jobs/runtime-worker.d.ts.map +1 -1
- package/esm/server/internal_jobs/runtime-worker.js +14 -2
- package/esm/server/internal_jobs/types.d.ts +5 -5
- package/esm/server/internal_jobs/types.d.ts.map +1 -1
- package/esm/server/internal_jobs/types.js +6 -0
- package/esm/server/runtime.d.ts.map +1 -1
- package/esm/server/service.d.ts +81 -112
- package/esm/server/service.d.ts.map +1 -1
- package/esm/server/service.js +372 -130
- package/esm/server.d.ts +3 -3
- package/esm/server.d.ts.map +1 -1
- package/esm/service/deno.d.ts +1 -1
- package/esm/service/deno.d.ts.map +1 -1
- package/esm/service/drizzle.d.ts +52 -0
- package/esm/service/drizzle.d.ts.map +1 -0
- package/esm/service/drizzle.js +108 -0
- package/esm/service/mod.d.ts +3 -3
- package/esm/service/mod.d.ts.map +1 -1
- package/esm/service/mod.js +2 -2
- package/esm/service/node.d.ts +1 -1
- package/esm/service/node.d.ts.map +1 -1
- package/esm/service/outbox_inbox.d.ts +76 -22
- package/esm/service/outbox_inbox.d.ts.map +1 -1
- package/esm/service/outbox_inbox.js +231 -70
- package/esm/telemetry/metrics.d.ts +55 -0
- package/esm/telemetry/metrics.d.ts.map +1 -1
- package/esm/telemetry/metrics.js +86 -0
- package/esm/telemetry/mod.d.ts +2 -1
- package/esm/telemetry/mod.d.ts.map +1 -1
- package/esm/telemetry/mod.js +1 -1
- package/esm/trellis.d.ts +62 -30
- package/esm/trellis.d.ts.map +1 -1
- package/esm/trellis.js +125 -42
- package/package.json +14 -2
- package/script/auth/mod.d.ts +1 -1
- package/script/auth/mod.d.ts.map +1 -1
- package/script/auth/mod.js +11 -4
- package/script/auth/protocol.d.ts +55 -0
- package/script/auth/protocol.d.ts.map +1 -1
- package/script/browser.d.ts +3 -3
- package/script/browser.d.ts.map +1 -1
- package/script/browser.js +3 -2
- package/script/client_connect.d.ts +12 -3
- package/script/client_connect.d.ts.map +1 -1
- package/script/client_connect.js +111 -6
- package/script/codec.d.ts +7 -6
- package/script/codec.d.ts.map +1 -1
- package/script/codec.js +124 -5
- package/script/contract_support/canonical.d.ts +3 -0
- package/script/contract_support/canonical.d.ts.map +1 -1
- package/script/contract_support/canonical.js +3 -0
- package/script/contract_support/mod.d.ts +125 -10
- package/script/contract_support/mod.d.ts.map +1 -1
- package/script/contract_support/mod.js +165 -5
- package/script/contract_support/protocol.d.ts +92 -7
- package/script/contract_support/protocol.d.ts.map +1 -1
- package/script/contract_support/protocol.js +42 -8
- package/script/contract_support/runtime.d.ts +4 -1
- package/script/contract_support/runtime.d.ts.map +1 -1
- package/script/errors/SchemaValidationError.d.ts +49 -0
- package/script/errors/SchemaValidationError.d.ts.map +1 -0
- package/script/errors/SchemaValidationError.js +74 -0
- package/script/errors/index.d.ts +38 -9
- package/script/errors/index.d.ts.map +1 -1
- package/script/errors/index.js +20 -1
- package/script/generated-sdk/auth/api.d.ts +33 -605
- package/script/generated-sdk/auth/api.d.ts.map +1 -1
- package/script/generated-sdk/auth/api.js +6 -1
- package/script/generated-sdk/auth/client.d.ts +129 -134
- package/script/generated-sdk/auth/client.d.ts.map +1 -1
- package/script/generated-sdk/auth/contract.d.ts +2 -601
- package/script/generated-sdk/auth/contract.d.ts.map +1 -1
- package/script/generated-sdk/auth/contract.js +310 -93
- package/script/generated-sdk/auth/mod.d.ts +1 -1
- package/script/generated-sdk/auth/mod.d.ts.map +1 -1
- package/script/generated-sdk/auth/owned_api.d.ts +88 -86
- package/script/generated-sdk/auth/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/auth/owned_api.js +6 -0
- package/script/generated-sdk/auth/schemas.d.ts +284 -136
- package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/script/generated-sdk/auth/schemas.js +231 -92
- package/script/generated-sdk/auth/types.d.ts +565 -89
- package/script/generated-sdk/auth/types.d.ts.map +1 -1
- package/script/generated-sdk/auth/types.js +1 -1
- package/script/generated-sdk/health/api.d.ts +29 -18
- package/script/generated-sdk/health/api.d.ts.map +1 -1
- package/script/generated-sdk/health/client.d.ts +7 -21
- package/script/generated-sdk/health/client.d.ts.map +1 -1
- package/script/generated-sdk/health/contract.d.ts +2 -15
- package/script/generated-sdk/health/contract.d.ts.map +1 -1
- package/script/generated-sdk/health/contract.js +2 -10
- package/script/generated-sdk/health/mod.d.ts +1 -1
- package/script/generated-sdk/health/mod.d.ts.map +1 -1
- package/script/generated-sdk/health/owned_api.d.ts +2 -2
- package/script/generated-sdk/health/schemas.d.ts +1 -14
- package/script/generated-sdk/health/schemas.d.ts.map +1 -1
- package/script/generated-sdk/health/schemas.js +1 -9
- package/script/generated-sdk/health/types.d.ts +10 -5
- package/script/generated-sdk/health/types.d.ts.map +1 -1
- package/script/generated-sdk/health/types.js +1 -2
- package/script/generated-sdk/jobs/api.d.ts +29 -109
- package/script/generated-sdk/jobs/api.d.ts.map +1 -1
- package/script/generated-sdk/jobs/client.d.ts +21 -33
- package/script/generated-sdk/jobs/client.d.ts.map +1 -1
- package/script/generated-sdk/jobs/contract.d.ts +2 -106
- package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/script/generated-sdk/jobs/contract.js +268 -1
- package/script/generated-sdk/jobs/mod.d.ts +1 -1
- package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
- package/script/generated-sdk/jobs/owned_api.d.ts +22 -9
- package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/jobs/owned_api.js +19 -0
- package/script/generated-sdk/jobs/schemas.d.ts +437 -0
- package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/script/generated-sdk/jobs/schemas.js +212 -1
- package/script/generated-sdk/jobs/types.d.ts +195 -12
- package/script/generated-sdk/jobs/types.d.ts.map +1 -1
- package/script/generated-sdk/jobs/types.js +1 -1
- package/script/generated-sdk/state/api.d.ts +29 -68
- package/script/generated-sdk/state/api.d.ts.map +1 -1
- package/script/generated-sdk/state/client.d.ts +17 -31
- package/script/generated-sdk/state/client.d.ts.map +1 -1
- package/script/generated-sdk/state/contract.d.ts +1 -64
- package/script/generated-sdk/state/contract.d.ts.map +1 -1
- package/script/generated-sdk/state/mod.d.ts +1 -1
- package/script/generated-sdk/state/mod.d.ts.map +1 -1
- package/script/generated-sdk/state/owned_api.d.ts +7 -7
- package/script/generated-sdk/state/types.d.ts +52 -9
- package/script/generated-sdk/state/types.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/api.d.ts +33 -45
- package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/api.js +6 -1
- package/script/generated-sdk/trellis-core/client.d.ts +31 -20
- package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/contract.d.ts +2 -41
- package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/contract.js +91 -1
- package/script/generated-sdk/trellis-core/mod.d.ts +1 -1
- package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/owned_api.d.ts +4 -4
- package/script/generated-sdk/trellis-core/schemas.d.ts +113 -0
- package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/schemas.js +81 -0
- package/script/generated-sdk/trellis-core/types.d.ts +54 -7
- package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/types.js +1 -1
- package/script/health.d.ts +1 -1
- package/script/health.d.ts.map +1 -1
- package/script/health.js +1 -2
- package/script/index.d.ts +4 -4
- package/script/index.d.ts.map +1 -1
- package/script/index.js +2 -2
- package/script/jobs.d.ts +69 -3
- package/script/jobs.d.ts.map +1 -1
- package/script/jobs.js +93 -3
- package/script/server/health.d.ts +2 -6
- package/script/server/health.d.ts.map +1 -1
- package/script/server/health_schemas.d.ts +0 -8
- package/script/server/health_schemas.d.ts.map +1 -1
- package/script/server/health_schemas.js +1 -6
- package/script/server/internal_jobs/bindings.d.ts +11 -0
- package/script/server/internal_jobs/bindings.d.ts.map +1 -1
- package/script/server/internal_jobs/job-manager.d.ts +58 -2
- package/script/server/internal_jobs/job-manager.d.ts.map +1 -1
- package/script/server/internal_jobs/job-manager.js +429 -54
- package/script/server/internal_jobs/key-coordinator.d.ts +269 -0
- package/script/server/internal_jobs/key-coordinator.d.ts.map +1 -0
- package/script/server/internal_jobs/key-coordinator.js +690 -0
- package/script/server/internal_jobs/projection.d.ts.map +1 -1
- package/script/server/internal_jobs/projection.js +2 -0
- package/script/server/internal_jobs/runtime-worker.d.ts +5 -1
- package/script/server/internal_jobs/runtime-worker.d.ts.map +1 -1
- package/script/server/internal_jobs/runtime-worker.js +14 -2
- package/script/server/internal_jobs/types.d.ts +5 -5
- package/script/server/internal_jobs/types.d.ts.map +1 -1
- package/script/server/internal_jobs/types.js +6 -0
- package/script/server/runtime.d.ts.map +1 -1
- package/script/server/service.d.ts +81 -112
- package/script/server/service.d.ts.map +1 -1
- package/script/server/service.js +369 -127
- package/script/server.d.ts +3 -3
- package/script/server.d.ts.map +1 -1
- package/script/service/deno.d.ts +1 -1
- package/script/service/deno.d.ts.map +1 -1
- package/script/service/drizzle.d.ts +52 -0
- package/script/service/drizzle.d.ts.map +1 -0
- package/script/service/drizzle.js +113 -0
- package/script/service/mod.d.ts +3 -3
- package/script/service/mod.d.ts.map +1 -1
- package/script/service/mod.js +4 -3
- package/script/service/node.d.ts +1 -1
- package/script/service/node.d.ts.map +1 -1
- package/script/service/outbox_inbox.d.ts +76 -22
- package/script/service/outbox_inbox.d.ts.map +1 -1
- package/script/service/outbox_inbox.js +233 -70
- package/script/telemetry/metrics.d.ts +55 -0
- package/script/telemetry/metrics.d.ts.map +1 -1
- package/script/telemetry/metrics.js +88 -0
- package/script/telemetry/mod.d.ts +2 -1
- package/script/telemetry/mod.d.ts.map +1 -1
- package/script/telemetry/mod.js +3 -1
- package/script/trellis.d.ts +62 -30
- package/script/trellis.d.ts.map +1 -1
- package/script/trellis.js +124 -41
- package/src/auth/mod.ts +7 -0
- package/src/browser.ts +5 -7
- package/src/client_connect.ts +200 -12
- package/src/codec.ts +186 -11
- package/src/contract_support/canonical.ts +3 -0
- package/src/contract_support/mod.ts +380 -9
- package/src/contract_support/protocol.ts +57 -10
- package/src/contract_support/runtime.ts +7 -0
- package/src/errors/SchemaValidationError.ts +67 -0
- package/src/errors/index.ts +28 -0
- package/src/health.ts +0 -1
- package/src/index.ts +7 -8
- package/src/jobs.ts +138 -1
- package/src/sdk/_generated/auth/api.ts +38 -7
- package/src/sdk/_generated/auth/client.ts +168 -530
- package/src/sdk/_generated/auth/contract.ts +310 -93
- package/src/sdk/_generated/auth/mod.ts +0 -1
- package/src/sdk/_generated/auth/owned_api.ts +92 -86
- package/src/sdk/_generated/auth/schemas.ts +231 -92
- package/src/sdk/_generated/auth/types.ts +1069 -273
- package/src/sdk/_generated/core/api.ts +38 -7
- package/src/sdk/_generated/core/client.ts +47 -73
- package/src/sdk/_generated/core/contract.ts +91 -1
- package/src/sdk/_generated/core/mod.ts +0 -1
- package/src/sdk/_generated/core/owned_api.ts +4 -4
- package/src/sdk/_generated/core/schemas.ts +81 -0
- package/src/sdk/_generated/core/types.ts +79 -15
- package/src/sdk/_generated/health/api.ts +29 -5
- package/src/sdk/_generated/health/client.ts +11 -58
- package/src/sdk/_generated/health/contract.ts +2 -10
- package/src/sdk/_generated/health/mod.ts +0 -1
- package/src/sdk/_generated/health/owned_api.ts +2 -2
- package/src/sdk/_generated/health/schemas.ts +1 -9
- package/src/sdk/_generated/health/types.ts +23 -2
- package/src/sdk/_generated/jobs/api.ts +29 -5
- package/src/sdk/_generated/jobs/client.ts +25 -109
- package/src/sdk/_generated/jobs/contract.ts +269 -1
- package/src/sdk/_generated/jobs/mod.ts +0 -1
- package/src/sdk/_generated/jobs/owned_api.ts +30 -9
- package/src/sdk/_generated/jobs/schemas.ts +213 -0
- package/src/sdk/_generated/jobs/types.ts +252 -18
- package/src/sdk/_generated/state/api.ts +29 -5
- package/src/sdk/_generated/state/client.ts +18 -95
- package/src/sdk/_generated/state/mod.ts +0 -1
- package/src/sdk/_generated/state/owned_api.ts +7 -7
- package/src/sdk/_generated/state/types.ts +91 -15
- package/src/server/health.ts +2 -6
- package/src/server/health_schemas.ts +0 -6
- package/src/server/internal_jobs/bindings.ts +11 -0
- package/src/server/internal_jobs/job-manager.ts +553 -24
- package/src/server/internal_jobs/key-coordinator.ts +1080 -0
- package/src/server/internal_jobs/projection.ts +2 -0
- package/src/server/internal_jobs/runtime-worker.ts +17 -1
- package/src/server/internal_jobs/types.ts +6 -0
- package/src/server/runtime.ts +4 -0
- package/src/server/service.ts +645 -625
- package/src/server.ts +14 -7
- package/src/service/deno.ts +0 -5
- package/src/service/drizzle.ts +184 -0
- package/src/service/mod.ts +17 -7
- package/src/service/node.ts +0 -5
- package/src/service/outbox_inbox.ts +354 -88
- package/src/telemetry/metrics.ts +198 -1
- package/src/telemetry/mod.ts +6 -0
- package/src/trellis.ts +286 -105
|
@@ -194,10 +194,12 @@ export function sha256Bytes(data: Uint8Array): Uint8Array {
|
|
|
194
194
|
return out;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
/** Computes a synchronous SHA-256 digest encoded as base64url. */
|
|
197
198
|
export function sha256Base64urlSync(text: string): string {
|
|
198
199
|
return base64url(sha256Bytes(new TextEncoder().encode(text)));
|
|
199
200
|
}
|
|
200
201
|
|
|
202
|
+
/** Computes a SHA-256 digest encoded as base64url. */
|
|
201
203
|
export async function sha256Base64url(text: string): Promise<string> {
|
|
202
204
|
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
203
205
|
const data = new TextEncoder().encode(text);
|
|
@@ -207,6 +209,7 @@ export async function sha256Base64url(text: string): Promise<string> {
|
|
|
207
209
|
return sha256Base64urlSync(text);
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
/** Canonicalizes JSON and computes its SHA-256 base64url digest. */
|
|
210
213
|
export async function digestJson(value: JsonValue): Promise<{
|
|
211
214
|
canonical: string;
|
|
212
215
|
digest: string;
|
|
@@ -64,6 +64,10 @@ import {
|
|
|
64
64
|
ContractResourcesSchema,
|
|
65
65
|
ContractSchemaRefSchema,
|
|
66
66
|
ContractStateSchema,
|
|
67
|
+
type JobKeyConcurrency,
|
|
68
|
+
JobKeyConcurrencySchema,
|
|
69
|
+
type JobQueueDepth,
|
|
70
|
+
JobQueueDepthSchema,
|
|
67
71
|
} from "./protocol.js";
|
|
68
72
|
|
|
69
73
|
export {
|
|
@@ -80,6 +84,7 @@ export {
|
|
|
80
84
|
ContractJobQueueSchema,
|
|
81
85
|
ContractJobsSchema,
|
|
82
86
|
ContractKvResourceSchema,
|
|
87
|
+
type ContractResourceBindings,
|
|
83
88
|
ContractResourceBindingsSchema,
|
|
84
89
|
ContractResourcesSchema,
|
|
85
90
|
ContractSchemaRefSchema,
|
|
@@ -96,13 +101,19 @@ export {
|
|
|
96
101
|
CursorQuerySchema,
|
|
97
102
|
type EventConsumerResourceBinding,
|
|
98
103
|
EventConsumerResourceBindingSchema,
|
|
99
|
-
type EventHeader,
|
|
100
|
-
EventHeaderSchema,
|
|
101
104
|
type InstalledServiceContract,
|
|
102
105
|
InstalledServiceContractSchema,
|
|
103
106
|
IsoDateSchema,
|
|
107
|
+
type JobKeyConcurrency,
|
|
108
|
+
JobKeyConcurrencySchema,
|
|
109
|
+
type JobQueueDepth,
|
|
110
|
+
JobQueueDepthSchema,
|
|
104
111
|
type JobsQueueBinding,
|
|
105
112
|
JobsQueueBindingSchema,
|
|
113
|
+
type JobsQueueDepthBinding,
|
|
114
|
+
JobsQueueDepthBindingSchema,
|
|
115
|
+
type JobsQueueKeyConcurrencyBinding,
|
|
116
|
+
JobsQueueKeyConcurrencyBindingSchema,
|
|
106
117
|
type JobsResourceBinding,
|
|
107
118
|
JobsResourceBindingSchema,
|
|
108
119
|
type KvResourceBinding,
|
|
@@ -253,6 +264,7 @@ const ContractOperationSchema = Type.Object({
|
|
|
253
264
|
input: ContractSchemaRefSchema,
|
|
254
265
|
progress: Type.Optional(ContractSchemaRefSchema),
|
|
255
266
|
output: ContractSchemaRefSchema,
|
|
267
|
+
errors: Type.Optional(Type.Array(ContractErrorRefSchema)),
|
|
256
268
|
transfer: Type.Optional(OperationTransferSchema),
|
|
257
269
|
capabilities: Type.Optional(OperationCapabilitiesSchema),
|
|
258
270
|
signals: Type.Optional(
|
|
@@ -489,9 +501,9 @@ export type ContractRpcMethod = {
|
|
|
489
501
|
subject: string;
|
|
490
502
|
input: ContractSchemaRef;
|
|
491
503
|
output: ContractSchemaRef;
|
|
504
|
+
errors?: ContractErrorRef[];
|
|
492
505
|
transfer?: { direction: "receive" };
|
|
493
506
|
capabilities?: { call?: Capability[] };
|
|
494
|
-
errors?: ContractErrorRef[];
|
|
495
507
|
internal?: boolean;
|
|
496
508
|
docs?: ContractDocs;
|
|
497
509
|
};
|
|
@@ -507,6 +519,7 @@ export type ContractOperation = {
|
|
|
507
519
|
input: ContractSchemaRef;
|
|
508
520
|
progress?: ContractSchemaRef;
|
|
509
521
|
output: ContractSchemaRef;
|
|
522
|
+
errors?: ContractErrorRef[];
|
|
510
523
|
transfer?: {
|
|
511
524
|
direction: "send";
|
|
512
525
|
store: string;
|
|
@@ -556,6 +569,8 @@ export type ContractJobQueueResource = {
|
|
|
556
569
|
logs?: boolean;
|
|
557
570
|
dlq?: boolean;
|
|
558
571
|
concurrency?: number;
|
|
572
|
+
keyConcurrency?: JobKeyConcurrency;
|
|
573
|
+
queue?: JobQueueDepth;
|
|
559
574
|
docs?: ContractDocs;
|
|
560
575
|
};
|
|
561
576
|
|
|
@@ -895,12 +910,14 @@ export type ContractSourceOperationSignal<
|
|
|
895
910
|
|
|
896
911
|
export type ContractSourceOperation<
|
|
897
912
|
TSchemaName extends string = string,
|
|
913
|
+
TErrorName extends string = string,
|
|
898
914
|
TCapability extends string = Capability,
|
|
899
915
|
> = {
|
|
900
916
|
version: `v${number}`;
|
|
901
917
|
input: ContractSchemaRef<TSchemaName>;
|
|
902
918
|
progress?: ContractSchemaRef<TSchemaName>;
|
|
903
919
|
output: ContractSchemaRef<TSchemaName>;
|
|
920
|
+
errors?: readonly TErrorName[];
|
|
904
921
|
transfer?: {
|
|
905
922
|
direction: "send";
|
|
906
923
|
store: string;
|
|
@@ -962,6 +979,17 @@ export type ContractSourceJobQueue<
|
|
|
962
979
|
logs?: boolean;
|
|
963
980
|
dlq?: boolean;
|
|
964
981
|
concurrency?: number;
|
|
982
|
+
keyConcurrency?: {
|
|
983
|
+
key: readonly string[];
|
|
984
|
+
maxActive?: number;
|
|
985
|
+
heartbeatIntervalMs?: number;
|
|
986
|
+
heartbeatTtlMs?: number;
|
|
987
|
+
stalePolicy?: "fail-stale" | "block";
|
|
988
|
+
};
|
|
989
|
+
queue?: {
|
|
990
|
+
maxQueuedPerKey?: number;
|
|
991
|
+
whenFull?: "reject" | "coalesce" | "replace-oldest";
|
|
992
|
+
};
|
|
965
993
|
docs?: ContractDocs;
|
|
966
994
|
};
|
|
967
995
|
|
|
@@ -1511,6 +1539,9 @@ type ProjectedRpc<
|
|
|
1511
1539
|
type ProjectedOperations<
|
|
1512
1540
|
T,
|
|
1513
1541
|
TSchemas,
|
|
1542
|
+
TId,
|
|
1543
|
+
TCapabilities,
|
|
1544
|
+
TErrors,
|
|
1514
1545
|
> = T extends Readonly<Record<string, ContractSourceOperation>> ? {
|
|
1515
1546
|
[K in keyof T]:
|
|
1516
1547
|
& OperationDesc<
|
|
@@ -1518,11 +1549,92 @@ type ProjectedOperations<
|
|
|
1518
1549
|
ResolveSchemaFromMap<TSchemas, T[K]["progress"]>,
|
|
1519
1550
|
ResolveSchemaFromMap<TSchemas, T[K]["output"]>
|
|
1520
1551
|
>
|
|
1552
|
+
& {
|
|
1553
|
+
subject: ProjectedOperationSubject<K, T[K]>;
|
|
1554
|
+
callerCapabilities: ProjectedOperationCapabilities<
|
|
1555
|
+
T[K],
|
|
1556
|
+
"call",
|
|
1557
|
+
TId,
|
|
1558
|
+
TCapabilities
|
|
1559
|
+
>;
|
|
1560
|
+
observeCapabilities: ProjectedOperationCapabilities<
|
|
1561
|
+
T[K],
|
|
1562
|
+
"observe",
|
|
1563
|
+
TId,
|
|
1564
|
+
TCapabilities
|
|
1565
|
+
>;
|
|
1566
|
+
cancelCapabilities: ProjectedOperationCapabilities<
|
|
1567
|
+
T[K],
|
|
1568
|
+
"cancel",
|
|
1569
|
+
TId,
|
|
1570
|
+
TCapabilities
|
|
1571
|
+
>;
|
|
1572
|
+
controlCapabilities: ProjectedOperationCapabilities<
|
|
1573
|
+
T[K],
|
|
1574
|
+
"control",
|
|
1575
|
+
TId,
|
|
1576
|
+
TCapabilities
|
|
1577
|
+
>;
|
|
1578
|
+
}
|
|
1579
|
+
& {
|
|
1580
|
+
errors?: T[K]["errors"];
|
|
1581
|
+
runtimeErrors?: readonly RuntimeRpcErrorDesc[];
|
|
1582
|
+
declaredErrorTypes?: readonly string[];
|
|
1583
|
+
}
|
|
1521
1584
|
& (T[K]["transfer"] extends undefined ? {}
|
|
1522
|
-
: { transfer: T[K]["transfer"] })
|
|
1585
|
+
: { transfer: T[K]["transfer"] })
|
|
1586
|
+
& (T[K] extends { cancel: infer TCancel extends boolean }
|
|
1587
|
+
? { cancel: TCancel }
|
|
1588
|
+
: {});
|
|
1523
1589
|
}
|
|
1524
1590
|
: {};
|
|
1525
1591
|
|
|
1592
|
+
type ProjectedOperationSubject<TKey, TOperation> = TOperation extends {
|
|
1593
|
+
subject: infer TSubject extends string;
|
|
1594
|
+
} ? TSubject
|
|
1595
|
+
: TOperation extends { version: infer TVersion extends `v${number}` }
|
|
1596
|
+
? `operations.${TVersion}.${Extract<TKey, string>}`
|
|
1597
|
+
: string;
|
|
1598
|
+
|
|
1599
|
+
type ProjectedCapabilityNamespace<TId extends string> = TId extends
|
|
1600
|
+
`${infer TNamespace}@v${number}` ? TNamespace
|
|
1601
|
+
: TId;
|
|
1602
|
+
|
|
1603
|
+
type ProjectedCapability<
|
|
1604
|
+
TCapability,
|
|
1605
|
+
TId,
|
|
1606
|
+
TCapabilities,
|
|
1607
|
+
> = TCapability extends string
|
|
1608
|
+
? TCapability extends PlatformCapability | GlobalCapability ? TCapability
|
|
1609
|
+
: TCapability extends Extract<keyof NonNullable<TCapabilities>, string>
|
|
1610
|
+
? `${ProjectedCapabilityNamespace<Extract<TId, string>>}::${TCapability}`
|
|
1611
|
+
: TCapability
|
|
1612
|
+
: never;
|
|
1613
|
+
|
|
1614
|
+
type ProjectedCapabilityList<
|
|
1615
|
+
TList,
|
|
1616
|
+
TId,
|
|
1617
|
+
TCapabilities,
|
|
1618
|
+
> = TList extends readonly string[] ? {
|
|
1619
|
+
readonly [K in keyof TList]: ProjectedCapability<
|
|
1620
|
+
TList[K],
|
|
1621
|
+
TId,
|
|
1622
|
+
TCapabilities
|
|
1623
|
+
>;
|
|
1624
|
+
}
|
|
1625
|
+
: readonly [];
|
|
1626
|
+
|
|
1627
|
+
type ProjectedOperationCapabilities<
|
|
1628
|
+
TOperation,
|
|
1629
|
+
TKind extends "call" | "observe" | "cancel" | "control",
|
|
1630
|
+
TId,
|
|
1631
|
+
TCapabilities,
|
|
1632
|
+
> = TOperation extends { capabilities: infer TOperationCapabilities }
|
|
1633
|
+
? TOperationCapabilities extends { [K in TKind]?: infer TList }
|
|
1634
|
+
? ProjectedCapabilityList<TList, TId, TCapabilities>
|
|
1635
|
+
: readonly []
|
|
1636
|
+
: readonly [];
|
|
1637
|
+
|
|
1526
1638
|
type ProjectedEvents<
|
|
1527
1639
|
T,
|
|
1528
1640
|
TSchemas,
|
|
@@ -1546,6 +1658,8 @@ type ProjectedFeeds<
|
|
|
1546
1658
|
|
|
1547
1659
|
export type OwnedApiFromSource<
|
|
1548
1660
|
T extends {
|
|
1661
|
+
id?: unknown;
|
|
1662
|
+
capabilities?: unknown;
|
|
1549
1663
|
schemas?: Readonly<Record<string, TSchema>>;
|
|
1550
1664
|
errors?: unknown;
|
|
1551
1665
|
rpc?: unknown;
|
|
@@ -1555,7 +1669,13 @@ export type OwnedApiFromSource<
|
|
|
1555
1669
|
},
|
|
1556
1670
|
> = {
|
|
1557
1671
|
rpc: ProjectedRpc<T["rpc"], T["schemas"], T["errors"]>;
|
|
1558
|
-
operations: ProjectedOperations<
|
|
1672
|
+
operations: ProjectedOperations<
|
|
1673
|
+
T["operations"],
|
|
1674
|
+
T["schemas"],
|
|
1675
|
+
T["id"],
|
|
1676
|
+
T["capabilities"],
|
|
1677
|
+
T["errors"]
|
|
1678
|
+
>;
|
|
1559
1679
|
events: ProjectedEvents<T["events"], T["schemas"]>;
|
|
1560
1680
|
feeds: ProjectedFeeds<T["feeds"], T["schemas"]>;
|
|
1561
1681
|
subjects: {};
|
|
@@ -2547,6 +2667,12 @@ function collectReachableSchemaNames(contract: TrellisContractV1): Set<string> {
|
|
|
2547
2667
|
for (const signal of Object.values(operation.signals ?? {})) {
|
|
2548
2668
|
collectSchemaRef(reachableSchemas, signal.input);
|
|
2549
2669
|
}
|
|
2670
|
+
for (const error of operation.errors ?? []) {
|
|
2671
|
+
const declaration = Object.values(contract.errors ?? {}).find((decl) =>
|
|
2672
|
+
decl.type === error.type
|
|
2673
|
+
);
|
|
2674
|
+
collectSchemaRef(reachableSchemas, declaration?.schema);
|
|
2675
|
+
}
|
|
2550
2676
|
}
|
|
2551
2677
|
|
|
2552
2678
|
for (const event of Object.values(contract.events ?? {})) {
|
|
@@ -2604,6 +2730,26 @@ function projectRpcDeclaredErrors(
|
|
|
2604
2730
|
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
2605
2731
|
}
|
|
2606
2732
|
|
|
2733
|
+
function projectOperationDeclaredErrors(
|
|
2734
|
+
contract: TrellisContractV1,
|
|
2735
|
+
): Record<string, ContractErrorDecl> | undefined {
|
|
2736
|
+
if (!contract.errors) {
|
|
2737
|
+
return undefined;
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
const declaredErrorTypes = new Set<string>();
|
|
2741
|
+
for (const operation of Object.values(contract.operations ?? {})) {
|
|
2742
|
+
for (const error of operation.errors ?? []) {
|
|
2743
|
+
declaredErrorTypes.add(error.type);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
const entries = Object.entries(contract.errors).filter(([, error]) =>
|
|
2748
|
+
declaredErrorTypes.has(error.type)
|
|
2749
|
+
);
|
|
2750
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2607
2753
|
function projectDigestResources(
|
|
2608
2754
|
resources: ContractResources | undefined,
|
|
2609
2755
|
): ContractResources | undefined {
|
|
@@ -2788,6 +2934,12 @@ function projectDigestOperations(
|
|
|
2788
2934
|
},
|
|
2789
2935
|
}
|
|
2790
2936
|
: {}),
|
|
2937
|
+
...(operation.errors
|
|
2938
|
+
? {
|
|
2939
|
+
errors: sortedUnique(operation.errors.map((error) => error.type))
|
|
2940
|
+
.map((type) => ({ type })),
|
|
2941
|
+
}
|
|
2942
|
+
: {}),
|
|
2791
2943
|
} satisfies ContractOperation,
|
|
2792
2944
|
];
|
|
2793
2945
|
}),
|
|
@@ -3032,6 +3184,9 @@ function operation(operation: ContractOperation): ContractOperation {
|
|
|
3032
3184
|
),
|
|
3033
3185
|
}
|
|
3034
3186
|
: {}),
|
|
3187
|
+
...(operation.errors
|
|
3188
|
+
? { errors: operation.errors.map((error) => ({ type: error.type })) }
|
|
3189
|
+
: {}),
|
|
3035
3190
|
...(operation.cancel !== undefined ? { cancel: operation.cancel } : {}),
|
|
3036
3191
|
...(operation.docs ? { docs: contractDocs(operation.docs) } : {}),
|
|
3037
3192
|
};
|
|
@@ -3120,7 +3275,110 @@ function errorDecl(error: ContractErrorDecl): ContractErrorDecl {
|
|
|
3120
3275
|
};
|
|
3121
3276
|
}
|
|
3122
3277
|
|
|
3123
|
-
|
|
3278
|
+
type JobKeyConcurrencyLike = {
|
|
3279
|
+
key: readonly string[];
|
|
3280
|
+
maxActive?: number;
|
|
3281
|
+
heartbeatIntervalMs?: number;
|
|
3282
|
+
heartbeatTtlMs?: number;
|
|
3283
|
+
stalePolicy?: "fail-stale" | "block";
|
|
3284
|
+
};
|
|
3285
|
+
|
|
3286
|
+
type JobQueueDepthLike = {
|
|
3287
|
+
maxQueuedPerKey?: number;
|
|
3288
|
+
whenFull?: "reject" | "coalesce" | "replace-oldest";
|
|
3289
|
+
};
|
|
3290
|
+
|
|
3291
|
+
function assertValidJsonPointerSyntax(
|
|
3292
|
+
queueType: string,
|
|
3293
|
+
pointer: string,
|
|
3294
|
+
): void {
|
|
3295
|
+
if (!pointer.startsWith("/")) {
|
|
3296
|
+
throw new Error(
|
|
3297
|
+
`jobs queue '${queueType}' keyConcurrency.key pointer segment '${pointer}' must start with '/'`,
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
for (let index = 0; index < pointer.length; index += 1) {
|
|
3301
|
+
if (pointer[index] !== "~") continue;
|
|
3302
|
+
const escaped = pointer[index + 1];
|
|
3303
|
+
if (escaped !== "0" && escaped !== "1") {
|
|
3304
|
+
throw new Error(
|
|
3305
|
+
`jobs queue '${queueType}' keyConcurrency.key pointer segment '${pointer}' has invalid JSON Pointer escape at offset ${index}; use '~0' for '~' and '~1' for '/'`,
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3308
|
+
index += 1;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
function assertValidJobKeyConcurrency(
|
|
3313
|
+
queueType: string,
|
|
3314
|
+
keyConcurrency: JobKeyConcurrencyLike | undefined,
|
|
3315
|
+
): void {
|
|
3316
|
+
if (!keyConcurrency) return;
|
|
3317
|
+
if (keyConcurrency.key.length === 0) {
|
|
3318
|
+
throw new Error(
|
|
3319
|
+
`jobs queue '${queueType}' keyConcurrency.key must contain at least one segment`,
|
|
3320
|
+
);
|
|
3321
|
+
}
|
|
3322
|
+
for (const segment of keyConcurrency.key) {
|
|
3323
|
+
if (segment.length === 0) {
|
|
3324
|
+
throw new Error(
|
|
3325
|
+
`jobs queue '${queueType}' keyConcurrency.key segments must be non-empty strings`,
|
|
3326
|
+
);
|
|
3327
|
+
}
|
|
3328
|
+
if (segment.startsWith("/")) {
|
|
3329
|
+
assertValidJsonPointerSyntax(queueType, segment);
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
if (
|
|
3333
|
+
keyConcurrency.heartbeatIntervalMs !== undefined &&
|
|
3334
|
+
keyConcurrency.heartbeatTtlMs !== undefined &&
|
|
3335
|
+
keyConcurrency.heartbeatTtlMs <= keyConcurrency.heartbeatIntervalMs
|
|
3336
|
+
) {
|
|
3337
|
+
throw new Error(
|
|
3338
|
+
`jobs queue '${queueType}' keyConcurrency.heartbeatTtlMs must exceed heartbeatIntervalMs`,
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
function jobKeyConcurrency(
|
|
3344
|
+
queueType: string,
|
|
3345
|
+
keyConcurrency: JobKeyConcurrencyLike | undefined,
|
|
3346
|
+
): JobKeyConcurrency | undefined {
|
|
3347
|
+
assertValidJobKeyConcurrency(queueType, keyConcurrency);
|
|
3348
|
+
if (!keyConcurrency) return undefined;
|
|
3349
|
+
return {
|
|
3350
|
+
key: [...keyConcurrency.key],
|
|
3351
|
+
...(keyConcurrency.maxActive !== undefined
|
|
3352
|
+
? { maxActive: keyConcurrency.maxActive }
|
|
3353
|
+
: {}),
|
|
3354
|
+
...(keyConcurrency.heartbeatIntervalMs !== undefined
|
|
3355
|
+
? { heartbeatIntervalMs: keyConcurrency.heartbeatIntervalMs }
|
|
3356
|
+
: {}),
|
|
3357
|
+
...(keyConcurrency.heartbeatTtlMs !== undefined
|
|
3358
|
+
? { heartbeatTtlMs: keyConcurrency.heartbeatTtlMs }
|
|
3359
|
+
: {}),
|
|
3360
|
+
...(keyConcurrency.stalePolicy !== undefined
|
|
3361
|
+
? { stalePolicy: keyConcurrency.stalePolicy }
|
|
3362
|
+
: {}),
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
function jobQueueDepth(
|
|
3367
|
+
queue: JobQueueDepthLike | undefined,
|
|
3368
|
+
): JobQueueDepth | undefined {
|
|
3369
|
+
if (!queue) return undefined;
|
|
3370
|
+
return {
|
|
3371
|
+
...(queue.maxQueuedPerKey !== undefined
|
|
3372
|
+
? { maxQueuedPerKey: queue.maxQueuedPerKey }
|
|
3373
|
+
: {}),
|
|
3374
|
+
...(queue.whenFull !== undefined ? { whenFull: queue.whenFull } : {}),
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
function jobQueue(
|
|
3379
|
+
queueType: string,
|
|
3380
|
+
queue: ContractJobQueue,
|
|
3381
|
+
): ContractJobQueue {
|
|
3124
3382
|
return {
|
|
3125
3383
|
payload: schemaRef(queue.payload),
|
|
3126
3384
|
...(queue.result ? { result: schemaRef(queue.result) } : {}),
|
|
@@ -3136,6 +3394,10 @@ function jobQueue(queue: ContractJobQueue): ContractJobQueue {
|
|
|
3136
3394
|
...(queue.concurrency !== undefined
|
|
3137
3395
|
? { concurrency: queue.concurrency }
|
|
3138
3396
|
: {}),
|
|
3397
|
+
...(queue.keyConcurrency
|
|
3398
|
+
? { keyConcurrency: jobKeyConcurrency(queueType, queue.keyConcurrency) }
|
|
3399
|
+
: {}),
|
|
3400
|
+
...(queue.queue ? { queue: jobQueueDepth(queue.queue) } : {}),
|
|
3139
3401
|
...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
|
|
3140
3402
|
};
|
|
3141
3403
|
}
|
|
@@ -3209,7 +3471,16 @@ export function normalizeContractManifest(
|
|
|
3209
3471
|
: {}),
|
|
3210
3472
|
...(contract.events ? { events: mapValues(contract.events, event) } : {}),
|
|
3211
3473
|
...(contract.feeds ? { feeds: mapValues(contract.feeds, feed) } : {}),
|
|
3212
|
-
...(contract.jobs
|
|
3474
|
+
...(contract.jobs
|
|
3475
|
+
? {
|
|
3476
|
+
jobs: Object.fromEntries(
|
|
3477
|
+
Object.entries(contract.jobs).map(([queueType, queue]) => [
|
|
3478
|
+
queueType,
|
|
3479
|
+
jobQueue(queueType, queue),
|
|
3480
|
+
]),
|
|
3481
|
+
),
|
|
3482
|
+
}
|
|
3483
|
+
: {}),
|
|
3213
3484
|
...(contract.eventConsumers
|
|
3214
3485
|
? {
|
|
3215
3486
|
eventConsumers: mapValues(
|
|
@@ -3271,7 +3542,12 @@ export function projectContractDigestManifest(
|
|
|
3271
3542
|
contract: TrellisContractV1,
|
|
3272
3543
|
): JsonValue {
|
|
3273
3544
|
const schemas = projectReachableSchemas(contract);
|
|
3274
|
-
const
|
|
3545
|
+
const rpcDeclaredErrors = projectRpcDeclaredErrors(contract);
|
|
3546
|
+
const operationDeclaredErrors = projectOperationDeclaredErrors(contract);
|
|
3547
|
+
const combinedErrors = { ...rpcDeclaredErrors, ...operationDeclaredErrors };
|
|
3548
|
+
const errors = Object.keys(combinedErrors).length > 0
|
|
3549
|
+
? combinedErrors
|
|
3550
|
+
: undefined;
|
|
3275
3551
|
const state = projectDigestState(contract.state);
|
|
3276
3552
|
const resources = projectDigestResources(contract.resources);
|
|
3277
3553
|
const jobs = projectDigestJobs(contract.jobs);
|
|
@@ -3412,6 +3688,12 @@ function emitJobs(
|
|
|
3412
3688
|
...(queue.concurrency !== undefined
|
|
3413
3689
|
? { concurrency: queue.concurrency }
|
|
3414
3690
|
: {}),
|
|
3691
|
+
...(queue.keyConcurrency
|
|
3692
|
+
? {
|
|
3693
|
+
keyConcurrency: jobKeyConcurrency(queueType, queue.keyConcurrency),
|
|
3694
|
+
}
|
|
3695
|
+
: {}),
|
|
3696
|
+
...(queue.queue ? { queue: jobQueueDepth(queue.queue) } : {}),
|
|
3415
3697
|
...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
|
|
3416
3698
|
} satisfies ContractJobQueue,
|
|
3417
3699
|
]),
|
|
@@ -3744,6 +4026,13 @@ function emitContract(source: TrellisContractSource): TrellisContractV1 {
|
|
|
3744
4026
|
if (operation.docs) {
|
|
3745
4027
|
emitted.docs = contractDocs(operation.docs);
|
|
3746
4028
|
}
|
|
4029
|
+
if (operation.errors && operation.errors.length > 0) {
|
|
4030
|
+
emitted.errors = sortedUnique(
|
|
4031
|
+
operation.errors.map((errorName) =>
|
|
4032
|
+
source.errors?.[errorName]?.type ?? errorName
|
|
4033
|
+
),
|
|
4034
|
+
).map((type) => ({ type }));
|
|
4035
|
+
}
|
|
3747
4036
|
return [name, emitted];
|
|
3748
4037
|
}),
|
|
3749
4038
|
)
|
|
@@ -4018,6 +4307,14 @@ function buildOwnedApi(source: TrellisContractSource): ApiShape {
|
|
|
4018
4307
|
`operation '${name}' control capabilities`,
|
|
4019
4308
|
) ?? [],
|
|
4020
4309
|
cancel: operation.cancel,
|
|
4310
|
+
errors: operation.errors,
|
|
4311
|
+
declaredErrorTypes: operation.errors?.map((errorName) =>
|
|
4312
|
+
source.errors?.[errorName]?.type ?? errorName
|
|
4313
|
+
),
|
|
4314
|
+
runtimeErrors: operation.errors?.flatMap((errorName) => {
|
|
4315
|
+
const runtimeError = localRuntimeErrors[errorName];
|
|
4316
|
+
return runtimeError ? [runtimeError] : [];
|
|
4317
|
+
}),
|
|
4021
4318
|
},
|
|
4022
4319
|
]),
|
|
4023
4320
|
) as Record<string, OperationDesc>;
|
|
@@ -4350,6 +4647,73 @@ export function defineError<
|
|
|
4350
4647
|
return DefinedErrorImpl;
|
|
4351
4648
|
}
|
|
4352
4649
|
|
|
4650
|
+
/**
|
|
4651
|
+
* Hints for a single schema validation keyword failure.
|
|
4652
|
+
*
|
|
4653
|
+
* Provides per-keyway UX metadata that a UI can surface when a field-level
|
|
4654
|
+
* validation error occurs for this schema node.
|
|
4655
|
+
*/
|
|
4656
|
+
export type TrellisValidationIssueHint = {
|
|
4657
|
+
code: string;
|
|
4658
|
+
message: string;
|
|
4659
|
+
note?: string;
|
|
4660
|
+
label?: string;
|
|
4661
|
+
i18nKey?: string;
|
|
4662
|
+
severity?: "error" | "warning" | "info";
|
|
4663
|
+
};
|
|
4664
|
+
|
|
4665
|
+
/**
|
|
4666
|
+
* Extension metadata attached to a TypeBox schema node via
|
|
4667
|
+
* `withTrellisValidation`.
|
|
4668
|
+
*
|
|
4669
|
+
* Carries the label, note, uiPath, and per-keyword issue hints that the
|
|
4670
|
+
* runtime uses to produce structured field-level validation errors.
|
|
4671
|
+
*/
|
|
4672
|
+
export type TrellisValidationExtension = {
|
|
4673
|
+
label?: string;
|
|
4674
|
+
note?: string;
|
|
4675
|
+
uiPath?: string;
|
|
4676
|
+
issues?: Record<string, TrellisValidationIssueHint>;
|
|
4677
|
+
};
|
|
4678
|
+
|
|
4679
|
+
/**
|
|
4680
|
+
* Attaches Trellis validation UX metadata to a TypeBox schema node.
|
|
4681
|
+
*
|
|
4682
|
+
* When a request fails schema validation before handler dispatch, the metadata
|
|
4683
|
+
* is used to produce a `SchemaValidationError` with stable field-level issue
|
|
4684
|
+
* information that UIs can use without needing service-specific error handling.
|
|
4685
|
+
*
|
|
4686
|
+
* @template T The schema type.
|
|
4687
|
+
* @param schema The TypeBox schema to annotate.
|
|
4688
|
+
* @param extension The validation extension with labels, notes, and per-keyword issue hints.
|
|
4689
|
+
* @returns The same schema type with `x-trellis-validation` attached.
|
|
4690
|
+
*
|
|
4691
|
+
* @example
|
|
4692
|
+
* ```ts
|
|
4693
|
+
* const MySchema = Type.Object({
|
|
4694
|
+
* name: withTrellisValidation(Type.String({ minLength: 1 }), {
|
|
4695
|
+
* label: "Name",
|
|
4696
|
+
* issues: {
|
|
4697
|
+
* minLength: {
|
|
4698
|
+
* code: "my.name.required",
|
|
4699
|
+
* message: "Enter a name.",
|
|
4700
|
+
* },
|
|
4701
|
+
* },
|
|
4702
|
+
* }),
|
|
4703
|
+
* });
|
|
4704
|
+
* ```
|
|
4705
|
+
*/
|
|
4706
|
+
export function withTrellisValidation<
|
|
4707
|
+
T extends TSchema,
|
|
4708
|
+
>(
|
|
4709
|
+
schema: T,
|
|
4710
|
+
extension: TrellisValidationExtension,
|
|
4711
|
+
): T {
|
|
4712
|
+
const cloned = { ...schema } as Record<string, unknown>;
|
|
4713
|
+
cloned["x-trellis-validation"] = extension;
|
|
4714
|
+
return cloned as T;
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4353
4717
|
function createUseHelper<
|
|
4354
4718
|
TContractId extends string,
|
|
4355
4719
|
TOwnedApi extends TrellisApiLike,
|
|
@@ -5460,4 +5824,11 @@ export type {
|
|
|
5460
5824
|
SerializableErrorData,
|
|
5461
5825
|
TrellisAPI,
|
|
5462
5826
|
};
|
|
5463
|
-
export {
|
|
5827
|
+
export {
|
|
5828
|
+
canonicalizeJson,
|
|
5829
|
+
digestJson,
|
|
5830
|
+
isJsonValue,
|
|
5831
|
+
schema,
|
|
5832
|
+
sha256Base64urlSync,
|
|
5833
|
+
unwrapSchema,
|
|
5834
|
+
};
|
|
@@ -81,6 +81,30 @@ export const ContractStateSchema = Type.Record(
|
|
|
81
81
|
|
|
82
82
|
export type ContractState = Static<typeof ContractStateSchema>;
|
|
83
83
|
|
|
84
|
+
export const JobKeyConcurrencySchema = Type.Object({
|
|
85
|
+
key: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
86
|
+
maxActive: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
87
|
+
heartbeatIntervalMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
88
|
+
heartbeatTtlMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
89
|
+
stalePolicy: Type.Optional(Type.Union([
|
|
90
|
+
Type.Literal("fail-stale"),
|
|
91
|
+
Type.Literal("block"),
|
|
92
|
+
])),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export type JobKeyConcurrency = Static<typeof JobKeyConcurrencySchema>;
|
|
96
|
+
|
|
97
|
+
export const JobQueueDepthSchema = Type.Object({
|
|
98
|
+
maxQueuedPerKey: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
99
|
+
whenFull: Type.Optional(Type.Union([
|
|
100
|
+
Type.Literal("reject"),
|
|
101
|
+
Type.Literal("coalesce"),
|
|
102
|
+
Type.Literal("replace-oldest"),
|
|
103
|
+
])),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export type JobQueueDepth = Static<typeof JobQueueDepthSchema>;
|
|
107
|
+
|
|
84
108
|
export const ContractJobQueueSchema = Type.Object({
|
|
85
109
|
payload: ContractSchemaRefSchema,
|
|
86
110
|
result: Type.Optional(ContractSchemaRefSchema),
|
|
@@ -92,6 +116,8 @@ export const ContractJobQueueSchema = Type.Object({
|
|
|
92
116
|
logs: Type.Optional(Type.Boolean()),
|
|
93
117
|
dlq: Type.Optional(Type.Boolean()),
|
|
94
118
|
concurrency: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
119
|
+
keyConcurrency: Type.Optional(JobKeyConcurrencySchema),
|
|
120
|
+
queue: Type.Optional(JobQueueDepthSchema),
|
|
95
121
|
docs: Type.Optional(ContractDocsSchema),
|
|
96
122
|
});
|
|
97
123
|
|
|
@@ -178,6 +204,34 @@ export const StoreResourceBindingSchema = Type.Object({
|
|
|
178
204
|
|
|
179
205
|
export type StoreResourceBinding = Static<typeof StoreResourceBindingSchema>;
|
|
180
206
|
|
|
207
|
+
export const JobsQueueKeyConcurrencyBindingSchema = Type.Object({
|
|
208
|
+
key: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
209
|
+
maxActive: Type.Integer({ minimum: 1 }),
|
|
210
|
+
heartbeatIntervalMs: Type.Integer({ minimum: 1 }),
|
|
211
|
+
heartbeatTtlMs: Type.Integer({ minimum: 1 }),
|
|
212
|
+
stalePolicy: Type.Union([
|
|
213
|
+
Type.Literal("fail-stale"),
|
|
214
|
+
Type.Literal("block"),
|
|
215
|
+
]),
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
export type JobsQueueKeyConcurrencyBinding = Static<
|
|
219
|
+
typeof JobsQueueKeyConcurrencyBindingSchema
|
|
220
|
+
>;
|
|
221
|
+
|
|
222
|
+
export const JobsQueueDepthBindingSchema = Type.Object({
|
|
223
|
+
maxQueuedPerKey: Type.Integer({ minimum: 0 }),
|
|
224
|
+
whenFull: Type.Union([
|
|
225
|
+
Type.Literal("reject"),
|
|
226
|
+
Type.Literal("coalesce"),
|
|
227
|
+
Type.Literal("replace-oldest"),
|
|
228
|
+
]),
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export type JobsQueueDepthBinding = Static<
|
|
232
|
+
typeof JobsQueueDepthBindingSchema
|
|
233
|
+
>;
|
|
234
|
+
|
|
181
235
|
export const JobsQueueBindingSchema = Type.Object({
|
|
182
236
|
queueType: Type.String({ minLength: 1 }),
|
|
183
237
|
publishPrefix: Type.String({ minLength: 1 }),
|
|
@@ -193,6 +247,8 @@ export const JobsQueueBindingSchema = Type.Object({
|
|
|
193
247
|
logs: Type.Boolean(),
|
|
194
248
|
dlq: Type.Boolean(),
|
|
195
249
|
concurrency: Type.Integer({ minimum: 1 }),
|
|
250
|
+
keyConcurrency: Type.Optional(JobsQueueKeyConcurrencyBindingSchema),
|
|
251
|
+
queue: Type.Optional(JobsQueueDepthBindingSchema),
|
|
196
252
|
});
|
|
197
253
|
|
|
198
254
|
export type JobsQueueBinding = Static<typeof JobsQueueBindingSchema>;
|
|
@@ -257,15 +313,6 @@ export const IsoDateSchema = Type.Codec(
|
|
|
257
313
|
.Decode((value: string) => parseIsoDate(value))
|
|
258
314
|
.Encode((value: Date) => formatIsoDate(value));
|
|
259
315
|
|
|
260
|
-
export const EventHeaderSchema = Type.Object({
|
|
261
|
-
header: Type.Object({
|
|
262
|
-
id: Type.String(),
|
|
263
|
-
time: IsoDateSchema,
|
|
264
|
-
}),
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
export type EventHeader = Static<typeof EventHeaderSchema>;
|
|
268
|
-
|
|
269
316
|
/** Schema for a bounded pagination request. */
|
|
270
317
|
export const PageRequestSchema = Type.Object({
|
|
271
318
|
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
@@ -347,7 +394,7 @@ export function buildPageResponse<T>(
|
|
|
347
394
|
/** Schema for a cursor pagination query. */
|
|
348
395
|
export const CursorQuerySchema = Type.Object({
|
|
349
396
|
cursor: Type.Optional(Type.String({ minLength: 1 })),
|
|
350
|
-
limit: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
397
|
+
limit: Type.Optional(Type.Integer({ minimum: 0, maximum: 500 })),
|
|
351
398
|
});
|
|
352
399
|
|
|
353
400
|
/** Cursor pagination query. */
|