@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
package/esm/client_connect.js
CHANGED
|
@@ -9,11 +9,12 @@ import { importEd25519PrivateKeyFromSeedBase64url, publicKeyBase64urlFromSeed, s
|
|
|
9
9
|
import { DEFAULT_RUNTIME_MAX_RECONNECT_ATTEMPTS, } from "./runtime_transport.js";
|
|
10
10
|
import { Trellis, } from "./trellis.js";
|
|
11
11
|
import { TransportError } from "./errors/index.js";
|
|
12
|
-
import { AsyncResult, Result, UnexpectedError } from "@qlever-llc/result";
|
|
12
|
+
import { AsyncResult, BaseError, Result, UnexpectedError, } from "@qlever-llc/result";
|
|
13
13
|
import { Type } from "typebox";
|
|
14
14
|
import { Value } from "typebox/value";
|
|
15
15
|
import { bindFlowSig, oauthInitSig, signBytes, } from "./auth/browser/session.js";
|
|
16
16
|
import { observeNatsTrellisConnection, } from "./connection.js";
|
|
17
|
+
import { recordTrellisDuration } from "./telemetry/mod.js";
|
|
17
18
|
function createConnectedClient(args) {
|
|
18
19
|
const trellis = new Trellis(args.name, args.nc, {
|
|
19
20
|
sessionKey: args.sessionKey,
|
|
@@ -25,17 +26,26 @@ function createConnectedClient(args) {
|
|
|
25
26
|
return trellis;
|
|
26
27
|
}
|
|
27
28
|
function clientConnectResult(promise) {
|
|
28
|
-
return AsyncResult.from(promise.then((value) => Result.ok(value), (cause) => Result.err(cause instanceof TransportError
|
|
29
|
+
return AsyncResult.from(promise.then((value) => Result.ok(value), (cause) => Result.err(cause instanceof TransportError ||
|
|
30
|
+
cause instanceof ClientAuthHandledError
|
|
29
31
|
? cause
|
|
30
32
|
: new UnexpectedError({ cause }))));
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Error raised when client authentication was delegated to caller-owned routing.
|
|
34
36
|
*/
|
|
35
|
-
export class ClientAuthHandledError extends
|
|
37
|
+
export class ClientAuthHandledError extends BaseError {
|
|
36
38
|
constructor() {
|
|
37
39
|
super("Client authentication was handled by the caller");
|
|
38
|
-
this
|
|
40
|
+
Object.defineProperty(this, "name", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: "ClientAuthHandledError"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
toSerializable() {
|
|
48
|
+
return this.baseSerializable();
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
const ClientTransportEndpointsSchema = Type.Object({
|
|
@@ -230,6 +240,7 @@ async function resolveClientIdentity(auth) {
|
|
|
230
240
|
};
|
|
231
241
|
}
|
|
232
242
|
async function bindClientFlow(args) {
|
|
243
|
+
const startedAt = performance.now();
|
|
233
244
|
const response = await fetch(`${args.trellisUrl}/auth/flow/${encodeURIComponent(args.flowId)}/bind`, {
|
|
234
245
|
method: "POST",
|
|
235
246
|
headers: { "Content-Type": "application/json" },
|
|
@@ -286,8 +297,14 @@ async function bindClientFlow(args) {
|
|
|
286
297
|
},
|
|
287
298
|
});
|
|
288
299
|
}
|
|
300
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
301
|
+
phase: "bootstrap",
|
|
302
|
+
participantKind: "client",
|
|
303
|
+
outcome: "ok",
|
|
304
|
+
});
|
|
289
305
|
}
|
|
290
306
|
async function fetchClientBootstrap(args) {
|
|
307
|
+
const startedAt = performance.now();
|
|
291
308
|
const response = await fetch(`${args.trellisUrl}/bootstrap/client`, {
|
|
292
309
|
method: "POST",
|
|
293
310
|
headers: { "Content-Type": "application/json" },
|
|
@@ -319,12 +336,27 @@ async function fetchClientBootstrap(args) {
|
|
|
319
336
|
});
|
|
320
337
|
}
|
|
321
338
|
if (Value.Check(ClientBootstrapReadySchema, payload)) {
|
|
339
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
340
|
+
phase: "bootstrap",
|
|
341
|
+
participantKind: "client",
|
|
342
|
+
outcome: "ok",
|
|
343
|
+
});
|
|
322
344
|
return payload;
|
|
323
345
|
}
|
|
324
346
|
if (Value.Check(ClientBootstrapAuthRequiredSchema, payload)) {
|
|
347
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
348
|
+
phase: "bootstrap",
|
|
349
|
+
participantKind: "client",
|
|
350
|
+
outcome: "ok",
|
|
351
|
+
});
|
|
325
352
|
return payload;
|
|
326
353
|
}
|
|
327
354
|
if (Value.Check(ClientBootstrapNotReadySchema, payload)) {
|
|
355
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
356
|
+
phase: "bootstrap",
|
|
357
|
+
participantKind: "client",
|
|
358
|
+
outcome: "ok",
|
|
359
|
+
});
|
|
328
360
|
return payload;
|
|
329
361
|
}
|
|
330
362
|
throw createTransportError({
|
|
@@ -343,6 +375,7 @@ function updateClockOffsetFromServer(args) {
|
|
|
343
375
|
}
|
|
344
376
|
async function fetchClientBootstrapWithRetry(args) {
|
|
345
377
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
378
|
+
const attemptStartedAt = performance.now();
|
|
346
379
|
const requestStartedAtMs = args.deps.now();
|
|
347
380
|
const iat = correctedIatSeconds(requestStartedAtMs, args.offsetState.serverClockOffsetMs);
|
|
348
381
|
const response = await fetchClientBootstrap({
|
|
@@ -352,6 +385,11 @@ async function fetchClientBootstrapWithRetry(args) {
|
|
|
352
385
|
bootstrapSig: await args.identity.bootstrapSig(iat),
|
|
353
386
|
});
|
|
354
387
|
const responseReceivedAtMs = args.deps.now();
|
|
388
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - attemptStartedAt, {
|
|
389
|
+
phase: "bootstrap",
|
|
390
|
+
participantKind: "client",
|
|
391
|
+
outcome: "ok",
|
|
392
|
+
});
|
|
355
393
|
updateClockOffsetFromServer({
|
|
356
394
|
offsetState: args.offsetState,
|
|
357
395
|
requestStartedAtMs,
|
|
@@ -514,6 +552,7 @@ function bootstrapTargetsRequestedContract(bootstrap, args) {
|
|
|
514
552
|
bootstrap.connectInfo.contractDigest === requestedDigest;
|
|
515
553
|
}
|
|
516
554
|
async function buildSessionKeyLoginUrl(args) {
|
|
555
|
+
const startedAt = performance.now();
|
|
517
556
|
const context = authRequestContextRecord(args.context);
|
|
518
557
|
let response = await fetch(`${args.trellisUrl}/auth/requests`, {
|
|
519
558
|
method: "POST",
|
|
@@ -528,6 +567,11 @@ async function buildSessionKeyLoginUrl(args) {
|
|
|
528
567
|
}),
|
|
529
568
|
});
|
|
530
569
|
if (await authStartNeedsManifest(response)) {
|
|
570
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
571
|
+
phase: "bootstrap",
|
|
572
|
+
participantKind: "client",
|
|
573
|
+
outcome: "ok",
|
|
574
|
+
});
|
|
531
575
|
response = await fetch(`${args.trellisUrl}/auth/requests`, {
|
|
532
576
|
method: "POST",
|
|
533
577
|
headers: { "Content-Type": "application/json" },
|
|
@@ -560,6 +604,11 @@ async function buildSessionKeyLoginUrl(args) {
|
|
|
560
604
|
if (payload && typeof payload === "object" &&
|
|
561
605
|
payload.status === "flow_started" &&
|
|
562
606
|
typeof payload.loginUrl === "string") {
|
|
607
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
608
|
+
phase: "bootstrap",
|
|
609
|
+
participantKind: "client",
|
|
610
|
+
outcome: "ok",
|
|
611
|
+
});
|
|
563
612
|
return {
|
|
564
613
|
status: "flow_started",
|
|
565
614
|
loginUrl: payload.loginUrl,
|
|
@@ -567,6 +616,11 @@ async function buildSessionKeyLoginUrl(args) {
|
|
|
567
616
|
}
|
|
568
617
|
if (payload && typeof payload === "object" &&
|
|
569
618
|
payload.status === "bound") {
|
|
619
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - startedAt, {
|
|
620
|
+
phase: "bootstrap",
|
|
621
|
+
participantKind: "client",
|
|
622
|
+
outcome: "ok",
|
|
623
|
+
});
|
|
570
624
|
return { status: "bound" };
|
|
571
625
|
}
|
|
572
626
|
throw createTransportError({
|
|
@@ -596,6 +650,7 @@ async function authStartNeedsManifest(response) {
|
|
|
596
650
|
return (await response.clone().text()).includes("manifest_required");
|
|
597
651
|
}
|
|
598
652
|
export async function connectClientWithDeps(args, deps) {
|
|
653
|
+
const totalStartedAt = performance.now();
|
|
599
654
|
const trellisUrl = normalizeTrellisUrl(args.trellisUrl);
|
|
600
655
|
const identity = await resolveClientIdentity(args.auth);
|
|
601
656
|
const currentUrl = args.auth?.mode === "session_key"
|
|
@@ -640,6 +695,7 @@ export async function connectClientWithDeps(args, deps) {
|
|
|
640
695
|
}
|
|
641
696
|
}
|
|
642
697
|
}
|
|
698
|
+
const initialBootstrapStartedAt = performance.now();
|
|
643
699
|
const initialBootstrap = await fetchClientBootstrapWithRetry({
|
|
644
700
|
trellisUrl,
|
|
645
701
|
sessionKey: identity.sessionKey,
|
|
@@ -647,10 +703,21 @@ export async function connectClientWithDeps(args, deps) {
|
|
|
647
703
|
deps,
|
|
648
704
|
offsetState,
|
|
649
705
|
});
|
|
706
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - initialBootstrapStartedAt, {
|
|
707
|
+
phase: "bootstrap",
|
|
708
|
+
participantKind: "client",
|
|
709
|
+
outcome: "ok",
|
|
710
|
+
});
|
|
711
|
+
const authStartedAt = performance.now();
|
|
650
712
|
const bootstrap = needsReauth(initialBootstrap) ||
|
|
651
713
|
!bootstrapTargetsRequestedContract(initialBootstrap, args)
|
|
652
714
|
? await resolveAuthRequired(args, identity, currentUrl, deps, offsetState)
|
|
653
715
|
: initialBootstrap;
|
|
716
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - authStartedAt, {
|
|
717
|
+
phase: "auth_resolution",
|
|
718
|
+
participantKind: "client",
|
|
719
|
+
outcome: "ok",
|
|
720
|
+
});
|
|
654
721
|
if (bootstrap.status !== "ready") {
|
|
655
722
|
if (bootstrap.status === "not_ready") {
|
|
656
723
|
throw createTransportError({
|
|
@@ -730,12 +797,18 @@ export async function connectClientWithDeps(args, deps) {
|
|
|
730
797
|
});
|
|
731
798
|
let nc;
|
|
732
799
|
try {
|
|
800
|
+
const natsStartedAt = performance.now();
|
|
733
801
|
nc = await transport.connect({
|
|
734
802
|
servers: selectClientRuntimeTransportServers(bootstrap.connectInfo.transports),
|
|
735
803
|
maxReconnectAttempts: DEFAULT_RUNTIME_MAX_RECONNECT_ATTEMPTS,
|
|
736
804
|
inboxPrefix: bootstrap.connectInfo.transport.inboxPrefix,
|
|
737
805
|
authenticator: runtimeAuth.authenticators,
|
|
738
806
|
});
|
|
807
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - natsStartedAt, {
|
|
808
|
+
phase: "nats_connect",
|
|
809
|
+
participantKind: "client",
|
|
810
|
+
outcome: "ok",
|
|
811
|
+
});
|
|
739
812
|
}
|
|
740
813
|
catch (error) {
|
|
741
814
|
runtimeAuth.stop();
|
|
@@ -775,7 +848,7 @@ export async function connectClientWithDeps(args, deps) {
|
|
|
775
848
|
throw new Error("Contract is missing an owned or trellis API view");
|
|
776
849
|
}
|
|
777
850
|
const state = args.contract[CONTRACT_STATE_METADATA];
|
|
778
|
-
|
|
851
|
+
const client = createConnectedClient({
|
|
779
852
|
name: clientOpts.name ?? "client",
|
|
780
853
|
nc,
|
|
781
854
|
connection,
|
|
@@ -791,6 +864,12 @@ export async function connectClientWithDeps(args, deps) {
|
|
|
791
864
|
onSessionNotFound: handleSessionNotFound,
|
|
792
865
|
},
|
|
793
866
|
});
|
|
867
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - totalStartedAt, {
|
|
868
|
+
phase: "total",
|
|
869
|
+
participantKind: "client",
|
|
870
|
+
outcome: "ok",
|
|
871
|
+
});
|
|
872
|
+
return client;
|
|
794
873
|
}
|
|
795
874
|
async function resolveAuthRequired(args, identity, currentUrl, deps, offsetState) {
|
|
796
875
|
const browserAuth = args.auth?.mode === "session_key" ? {} : args.auth ?? {};
|
|
@@ -825,37 +904,63 @@ async function resolveAuthRequired(args, identity, currentUrl, deps, offsetState
|
|
|
825
904
|
context: browserAuth.context,
|
|
826
905
|
});
|
|
827
906
|
if (authStart.status === "bound") {
|
|
828
|
-
|
|
907
|
+
const bootstrapStartedAt = performance.now();
|
|
908
|
+
const bootstrap = await fetchClientBootstrapWithRetry({
|
|
829
909
|
trellisUrl: normalizeTrellisUrl(args.trellisUrl),
|
|
830
910
|
sessionKey: identity.sessionKey,
|
|
831
911
|
identity,
|
|
832
912
|
deps,
|
|
833
913
|
offsetState,
|
|
834
914
|
});
|
|
915
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - bootstrapStartedAt, {
|
|
916
|
+
phase: "bootstrap",
|
|
917
|
+
participantKind: "client",
|
|
918
|
+
outcome: "ok",
|
|
919
|
+
});
|
|
920
|
+
return bootstrap;
|
|
835
921
|
}
|
|
836
922
|
const loginUrl = authStart.loginUrl;
|
|
923
|
+
const continuationStartedAt = performance.now();
|
|
837
924
|
const continuation = await args.onAuthRequired?.({
|
|
838
925
|
loginUrl,
|
|
839
926
|
sessionKey: identity.sessionKey,
|
|
840
927
|
mode: identity.mode,
|
|
841
928
|
});
|
|
929
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - continuationStartedAt, {
|
|
930
|
+
phase: "bootstrap",
|
|
931
|
+
participantKind: "client",
|
|
932
|
+
outcome: "ok",
|
|
933
|
+
});
|
|
842
934
|
if (continuation && continuation.status === "handled") {
|
|
843
935
|
throw new ClientAuthHandledError();
|
|
844
936
|
}
|
|
845
937
|
if (continuation && continuation.status === "bound") {
|
|
938
|
+
const bindStartedAt = performance.now();
|
|
846
939
|
await bindClientFlow({
|
|
847
940
|
trellisUrl: normalizeTrellisUrl(args.trellisUrl),
|
|
848
941
|
sessionKey: identity.sessionKey,
|
|
849
942
|
flowId: continuation.flowId,
|
|
850
943
|
sig: await identity.bindFlowSig(continuation.flowId),
|
|
851
944
|
});
|
|
852
|
-
|
|
945
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - bindStartedAt, {
|
|
946
|
+
phase: "bootstrap",
|
|
947
|
+
participantKind: "client",
|
|
948
|
+
outcome: "ok",
|
|
949
|
+
});
|
|
950
|
+
const bootstrapStartedAt = performance.now();
|
|
951
|
+
const bootstrap = await fetchClientBootstrapWithRetry({
|
|
853
952
|
trellisUrl: normalizeTrellisUrl(args.trellisUrl),
|
|
854
953
|
sessionKey: identity.sessionKey,
|
|
855
954
|
identity,
|
|
856
955
|
deps,
|
|
857
956
|
offsetState,
|
|
858
957
|
});
|
|
958
|
+
recordTrellisDuration("trellis.connect.duration", performance.now() - bootstrapStartedAt, {
|
|
959
|
+
phase: "bootstrap",
|
|
960
|
+
participantKind: "client",
|
|
961
|
+
outcome: "ok",
|
|
962
|
+
});
|
|
963
|
+
return bootstrap;
|
|
859
964
|
}
|
|
860
965
|
if (isBrowserRuntime()) {
|
|
861
966
|
globalThis.location.href = loginUrl;
|
package/esm/codec.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type InferSchemaType, type SchemaLike } from "./contracts.js";
|
|
2
2
|
import { Result } from "@qlever-llc/result";
|
|
3
3
|
import type { StaticDecode, TSchema } from "typebox";
|
|
4
|
-
import { UnexpectedError, ValidationError } from "./errors/index.js";
|
|
4
|
+
import { SchemaValidationError, UnexpectedError, ValidationError } from "./errors/index.js";
|
|
5
5
|
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
6
6
|
[key: string]: JsonValue;
|
|
7
7
|
};
|
|
8
|
-
export declare function parse<T extends TSchema>(schema: T, data: JsonValue): Result<StaticDecode<T>, ValidationError | UnexpectedError>;
|
|
9
|
-
export declare function parseSchema<S extends SchemaLike>(schema: S, data: JsonValue): Result<InferSchemaType<S>, ValidationError | UnexpectedError>;
|
|
10
|
-
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
8
|
+
export declare function parse<T extends TSchema>(schema: T, data: JsonValue): Result<StaticDecode<T>, SchemaValidationError | ValidationError | UnexpectedError>;
|
|
9
|
+
export declare function parseSchema<S extends SchemaLike>(schema: S, data: JsonValue): Result<InferSchemaType<S>, SchemaValidationError | ValidationError | UnexpectedError>;
|
|
10
|
+
/** Parses unknown JSON-compatible data with an arbitrary Trellis schema. */
|
|
11
|
+
export declare function parseUnknownSchema(schema: SchemaLike, data: JsonValue): Result<unknown, SchemaValidationError | ValidationError | UnexpectedError>;
|
|
12
|
+
export declare function encode<T extends TSchema>(schema: T, data: unknown): Result<string, SchemaValidationError | ValidationError | UnexpectedError>;
|
|
13
|
+
export declare function encodeSchema(schema: SchemaLike, data: unknown): Result<string, SchemaValidationError | ValidationError | UnexpectedError>;
|
|
13
14
|
//# sourceMappingURL=codec.d.ts.map
|
package/esm/codec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAwKJ,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EACrC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CACP,YAAY,CAAC,CAAC,CAAC,EACf,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAC1D,CAUA;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CACP,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAC1D,CAaA;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAW5E;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EACtC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAU3E;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC,CAW3E"}
|
package/esm/codec.js
CHANGED
|
@@ -1,7 +1,125 @@
|
|
|
1
1
|
import { unwrapSchema, } from "./contracts.js";
|
|
2
2
|
import { Result } from "@qlever-llc/result";
|
|
3
3
|
import { EncodeError, ParseError, Value } from "typebox/value";
|
|
4
|
-
import { UnexpectedError, ValidationError } from "./errors/index.js";
|
|
4
|
+
import { SchemaValidationError, UnexpectedError, ValidationError, } from "./errors/index.js";
|
|
5
|
+
const X_TRELLIS_VALIDATION = "x-trellis-validation";
|
|
6
|
+
function readTrellisValidationExtension(schema) {
|
|
7
|
+
if (schema === null || schema === undefined || typeof schema !== "object") {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const ext = schema[X_TRELLIS_VALIDATION];
|
|
11
|
+
if (ext === null || ext === undefined || typeof ext !== "object") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return ext;
|
|
15
|
+
}
|
|
16
|
+
function resolveSchemaNode(root, schemaPath) {
|
|
17
|
+
if (!schemaPath.startsWith("#/")) {
|
|
18
|
+
if (schemaPath === "#")
|
|
19
|
+
return root;
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const parts = schemaPath.slice(2).split("/").map(decodeURIComponent);
|
|
23
|
+
let current = root;
|
|
24
|
+
for (const part of parts) {
|
|
25
|
+
if (current === null || current === undefined || typeof current !== "object") {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
current = current[part];
|
|
29
|
+
}
|
|
30
|
+
return current;
|
|
31
|
+
}
|
|
32
|
+
function resolveRequiredErrorNode(root, error) {
|
|
33
|
+
const params = error.params;
|
|
34
|
+
const missingProperty = (params?.missingProperty ??
|
|
35
|
+
params?.requiredProperties?.[0]);
|
|
36
|
+
if (!missingProperty)
|
|
37
|
+
return undefined;
|
|
38
|
+
const objNode = resolveSchemaNode(root, error.schemaPath);
|
|
39
|
+
if (!objNode || typeof objNode !== "object")
|
|
40
|
+
return undefined;
|
|
41
|
+
const properties = objNode.properties;
|
|
42
|
+
if (!properties || typeof properties !== "object")
|
|
43
|
+
return undefined;
|
|
44
|
+
return properties[missingProperty];
|
|
45
|
+
}
|
|
46
|
+
const ALLOWED_HINT_KEYWORDS = new Set([
|
|
47
|
+
"required",
|
|
48
|
+
"minItems",
|
|
49
|
+
"maxItems",
|
|
50
|
+
"minLength",
|
|
51
|
+
"maxLength",
|
|
52
|
+
"minimum",
|
|
53
|
+
"maximum",
|
|
54
|
+
"exclusiveMinimum",
|
|
55
|
+
"exclusiveMaximum",
|
|
56
|
+
"pattern",
|
|
57
|
+
"format",
|
|
58
|
+
"enum",
|
|
59
|
+
"const",
|
|
60
|
+
]);
|
|
61
|
+
function keywordAllowsHint(keyword) {
|
|
62
|
+
return ALLOWED_HINT_KEYWORDS.has(keyword);
|
|
63
|
+
}
|
|
64
|
+
function typeboxIssueToPath(error) {
|
|
65
|
+
if (error.keyword === "required") {
|
|
66
|
+
const params = error.params;
|
|
67
|
+
const missingProperty = (params?.missingProperty ??
|
|
68
|
+
params?.requiredProperties?.[0]);
|
|
69
|
+
if (missingProperty) {
|
|
70
|
+
return error.instancePath
|
|
71
|
+
? `${error.instancePath}/${missingProperty}`
|
|
72
|
+
: `/${missingProperty}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return error.instancePath || error.schemaPath;
|
|
76
|
+
}
|
|
77
|
+
function collectValidationIssues(root, errors) {
|
|
78
|
+
const annotated = [];
|
|
79
|
+
const unannotated = [];
|
|
80
|
+
for (const error of [...errors]) {
|
|
81
|
+
const schemaNode = error.keyword === "required"
|
|
82
|
+
? resolveRequiredErrorNode(root, error)
|
|
83
|
+
: resolveSchemaNode(root, error.schemaPath);
|
|
84
|
+
const extension = schemaNode !== undefined
|
|
85
|
+
? readTrellisValidationExtension(schemaNode)
|
|
86
|
+
: undefined;
|
|
87
|
+
if (extension !== undefined &&
|
|
88
|
+
keywordAllowsHint(error.keyword) &&
|
|
89
|
+
extension.issues?.[error.keyword] !== undefined) {
|
|
90
|
+
const hint = extension.issues[error.keyword];
|
|
91
|
+
if (hint.code !== undefined) {
|
|
92
|
+
annotated.push({
|
|
93
|
+
path: typeboxIssueToPath(error),
|
|
94
|
+
schemaPath: error.schemaPath,
|
|
95
|
+
keyword: error.keyword,
|
|
96
|
+
code: hint.code,
|
|
97
|
+
message: hint.message || error.message,
|
|
98
|
+
label: hint.label ?? extension.label,
|
|
99
|
+
note: hint.note ?? extension.note,
|
|
100
|
+
i18nKey: hint.i18nKey,
|
|
101
|
+
severity: hint.severity ?? "error",
|
|
102
|
+
params: error.params,
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
unannotated.push(error);
|
|
108
|
+
}
|
|
109
|
+
return { annotated, unannotated };
|
|
110
|
+
}
|
|
111
|
+
function buildValidationError(schema, data, errors, cause) {
|
|
112
|
+
const { annotated, unannotated } = collectValidationIssues(schema, errors);
|
|
113
|
+
if (annotated.length > 0 && unannotated.length === 0) {
|
|
114
|
+
return new SchemaValidationError({ issues: annotated, cause });
|
|
115
|
+
}
|
|
116
|
+
return new ValidationError({
|
|
117
|
+
errors: unannotated.length > 0
|
|
118
|
+
? unannotated
|
|
119
|
+
: annotated.map((i) => ({ path: i.path, message: i.message })),
|
|
120
|
+
cause,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
5
123
|
function parseWithSchema(schema, data) {
|
|
6
124
|
return Value.Parse(schema, data);
|
|
7
125
|
}
|
|
@@ -15,7 +133,7 @@ export function parse(schema, data) {
|
|
|
15
133
|
catch (cause) {
|
|
16
134
|
if (cause instanceof ParseError) {
|
|
17
135
|
const errors = Value.Errors(schema, data);
|
|
18
|
-
return Result.err(
|
|
136
|
+
return Result.err(buildValidationError(schema, data, errors, cause));
|
|
19
137
|
}
|
|
20
138
|
return Result.err(new UnexpectedError({ cause }));
|
|
21
139
|
}
|
|
@@ -28,11 +146,12 @@ export function parseSchema(schema, data) {
|
|
|
28
146
|
catch (cause) {
|
|
29
147
|
if (cause instanceof ParseError) {
|
|
30
148
|
const errors = Value.Errors(raw, data);
|
|
31
|
-
return Result.err(
|
|
149
|
+
return Result.err(buildValidationError(raw, data, errors, cause));
|
|
32
150
|
}
|
|
33
151
|
return Result.err(new UnexpectedError({ cause }));
|
|
34
152
|
}
|
|
35
153
|
}
|
|
154
|
+
/** Parses unknown JSON-compatible data with an arbitrary Trellis schema. */
|
|
36
155
|
export function parseUnknownSchema(schema, data) {
|
|
37
156
|
const raw = unwrapSchema(schema);
|
|
38
157
|
try {
|
|
@@ -41,7 +160,7 @@ export function parseUnknownSchema(schema, data) {
|
|
|
41
160
|
catch (cause) {
|
|
42
161
|
if (cause instanceof ParseError) {
|
|
43
162
|
const errors = Value.Errors(raw, data);
|
|
44
|
-
return Result.err(
|
|
163
|
+
return Result.err(buildValidationError(raw, data, errors, cause));
|
|
45
164
|
}
|
|
46
165
|
return Result.err(new UnexpectedError({ cause }));
|
|
47
166
|
}
|
|
@@ -53,7 +172,7 @@ export function encode(schema, data) {
|
|
|
53
172
|
catch (cause) {
|
|
54
173
|
if (cause instanceof EncodeError) {
|
|
55
174
|
const errors = Value.Errors(schema, data);
|
|
56
|
-
return Result.err(
|
|
175
|
+
return Result.err(buildValidationError(schema, data, errors, cause));
|
|
57
176
|
}
|
|
58
177
|
return Result.err(new UnexpectedError({ cause }));
|
|
59
178
|
}
|
|
@@ -66,7 +185,7 @@ export function encodeSchema(schema, data) {
|
|
|
66
185
|
catch (cause) {
|
|
67
186
|
if (cause instanceof EncodeError) {
|
|
68
187
|
const errors = Value.Errors(raw, data);
|
|
69
|
-
return Result.err(
|
|
188
|
+
return Result.err(buildValidationError(raw, data, errors, cause));
|
|
70
189
|
}
|
|
71
190
|
return Result.err(new UnexpectedError({ cause }));
|
|
72
191
|
}
|
|
@@ -5,8 +5,11 @@ export declare function isJsonValue(value: unknown): value is JsonValue;
|
|
|
5
5
|
export declare function canonicalizeJson(value: JsonValue): string;
|
|
6
6
|
export declare function base64url(bytes: Uint8Array): string;
|
|
7
7
|
export declare function sha256Bytes(data: Uint8Array): Uint8Array;
|
|
8
|
+
/** Computes a synchronous SHA-256 digest encoded as base64url. */
|
|
8
9
|
export declare function sha256Base64urlSync(text: string): string;
|
|
10
|
+
/** Computes a SHA-256 digest encoded as base64url. */
|
|
9
11
|
export declare function sha256Base64url(text: string): Promise<string>;
|
|
12
|
+
/** Canonicalizes JSON and computes its SHA-256 base64url digest. */
|
|
10
13
|
export declare function digestJson(value: JsonValue): Promise<{
|
|
11
14
|
canonical: string;
|
|
12
15
|
digest: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/contract_support/canonical.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAiB9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKnD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAsIxD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnE;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAID"}
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/contract_support/canonical.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAiB9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKnD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAsIxD;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,sDAAsD;AACtD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnE;AAED,oEAAoE;AACpE,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAID"}
|
|
@@ -172,9 +172,11 @@ export function sha256Bytes(data) {
|
|
|
172
172
|
}
|
|
173
173
|
return out;
|
|
174
174
|
}
|
|
175
|
+
/** Computes a synchronous SHA-256 digest encoded as base64url. */
|
|
175
176
|
export function sha256Base64urlSync(text) {
|
|
176
177
|
return base64url(sha256Bytes(new TextEncoder().encode(text)));
|
|
177
178
|
}
|
|
179
|
+
/** Computes a SHA-256 digest encoded as base64url. */
|
|
178
180
|
export async function sha256Base64url(text) {
|
|
179
181
|
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
180
182
|
const data = new TextEncoder().encode(text);
|
|
@@ -183,6 +185,7 @@ export async function sha256Base64url(text) {
|
|
|
183
185
|
}
|
|
184
186
|
return sha256Base64urlSync(text);
|
|
185
187
|
}
|
|
188
|
+
/** Canonicalizes JSON and computes its SHA-256 base64url digest. */
|
|
186
189
|
export async function digestJson(value) {
|
|
187
190
|
const canonical = canonicalizeJson(value);
|
|
188
191
|
const digest = await sha256Base64url(canonical);
|