@qlever-llc/trellis 0.10.2 → 0.10.3-rc.4
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/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/auth/browser/login.d.ts +3 -3
- package/esm/auth/browser/login.d.ts.map +1 -1
- package/esm/auth/browser/portal.d.ts +5 -5
- package/esm/auth/browser/portal.d.ts.map +1 -1
- package/esm/auth/browser/session.d.ts.map +1 -1
- package/esm/auth/browser/storage.d.ts.map +1 -1
- package/esm/auth/browser.d.ts +8 -7
- package/esm/auth/browser.d.ts.map +1 -1
- package/esm/auth/browser.js +1 -0
- package/esm/auth/device_activation.d.ts +3 -3
- package/esm/auth/device_activation.d.ts.map +1 -1
- package/esm/auth/keys.d.ts.map +1 -1
- package/esm/auth/mod.d.ts +9 -9
- package/esm/auth/mod.d.ts.map +1 -1
- package/esm/auth/proof.d.ts.map +1 -1
- package/esm/auth/protocol.d.ts +245 -5
- package/esm/auth/protocol.d.ts.map +1 -1
- package/esm/auth/protocol.js +1 -1
- package/esm/auth/schemas.d.ts.map +1 -1
- package/esm/auth/session_auth.d.ts.map +1 -1
- package/esm/auth/time.d.ts.map +1 -1
- package/esm/auth/trellis_id.d.ts.map +1 -1
- package/esm/auth/types.d.ts +1 -1
- package/esm/auth/types.d.ts.map +1 -1
- package/esm/auth/utils.d.ts.map +1 -1
- package/esm/auth.d.ts +2 -1
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +1 -0
- package/esm/browser.d.ts.map +1 -0
- package/esm/client.d.ts +6 -6
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +1 -1
- package/esm/client_connect.d.ts +8 -8
- package/esm/client_connect.d.ts.map +1 -1
- package/esm/client_connect.js +4 -3
- package/esm/codec.d.ts +2 -2
- package/esm/codec.d.ts.map +1 -1
- package/esm/connection.d.ts +1 -1
- package/esm/connection.d.ts.map +1 -1
- package/esm/contract.d.ts +2 -2
- package/esm/contract.d.ts.map +1 -1
- package/esm/contract_support/canonical.d.ts.map +1 -1
- package/esm/contract_support/mod.d.ts +13 -13
- package/esm/contract_support/mod.d.ts.map +1 -1
- package/esm/contract_support/protocol.d.ts.map +1 -1
- package/esm/contract_support/runtime.d.ts +1 -1
- package/esm/contract_support/runtime.d.ts.map +1 -1
- package/esm/contract_support/schema_pointers.d.ts.map +1 -1
- package/esm/contracts.d.ts +4 -3
- package/esm/contracts.d.ts.map +1 -1
- package/esm/contracts.js +1 -0
- package/esm/device/deno.d.ts.map +1 -0
- package/esm/device.d.ts +9 -8
- package/esm/device.d.ts.map +1 -1
- package/esm/device.js +1 -0
- package/esm/env.d.ts.map +1 -0
- package/esm/errors/AuthError.d.ts +1 -1
- package/esm/errors/AuthError.d.ts.map +1 -1
- package/esm/errors/KVError.d.ts +1 -1
- package/esm/errors/KVError.d.ts.map +1 -1
- package/esm/errors/OperationLifecycleError.d.ts +1 -1
- package/esm/errors/OperationLifecycleError.d.ts.map +1 -1
- package/esm/errors/RemoteError.d.ts +10 -10
- package/esm/errors/RemoteError.d.ts.map +1 -1
- package/esm/errors/StoreError.d.ts +1 -1
- package/esm/errors/StoreError.d.ts.map +1 -1
- package/esm/errors/TransferError.d.ts +1 -1
- package/esm/errors/TransferError.d.ts.map +1 -1
- package/esm/errors/TransportError.d.ts +1 -1
- package/esm/errors/TransportError.d.ts.map +1 -1
- package/esm/errors/TrellisError.d.ts.map +1 -1
- package/esm/errors/ValidationError.d.ts +1 -1
- package/esm/errors/ValidationError.d.ts.map +1 -1
- package/esm/errors/index.d.ts +33 -32
- package/esm/errors/index.d.ts.map +1 -1
- package/esm/errors/index.js +1 -0
- package/esm/generate.d.ts.map +1 -0
- package/esm/{npm/src/generate.js → generate.js} +1 -0
- package/esm/generated-sdk/auth/api.d.ts +604 -3
- package/esm/generated-sdk/auth/api.d.ts.map +1 -1
- package/esm/generated-sdk/auth/api.js +4 -1
- package/esm/generated-sdk/auth/client.d.ts +8 -0
- package/esm/generated-sdk/auth/client.d.ts.map +1 -1
- package/esm/generated-sdk/auth/contract.d.ts +600 -2
- package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
- package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
- package/esm/generated-sdk/auth/owned_api.d.ts +601 -2
- package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/auth/types.d.ts.map +1 -1
- package/esm/generated-sdk/health/api.d.ts +14 -2
- package/esm/generated-sdk/health/api.d.ts.map +1 -1
- package/esm/generated-sdk/health/client.d.ts.map +1 -1
- package/esm/generated-sdk/health/contract.d.ts +14 -2
- package/esm/generated-sdk/health/contract.d.ts.map +1 -1
- package/esm/generated-sdk/health/mod.d.ts.map +1 -1
- package/esm/generated-sdk/health/owned_api.d.ts +15 -2
- package/esm/generated-sdk/health/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/health/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/health/types.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/api.d.ts +105 -2
- package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/contract.d.ts +105 -2
- package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/owned_api.d.ts +106 -2
- package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
- package/esm/generated-sdk/state/api.d.ts +64 -2
- package/esm/generated-sdk/state/api.d.ts.map +1 -1
- package/esm/generated-sdk/state/client.d.ts.map +1 -1
- package/esm/generated-sdk/state/contract.d.ts +64 -2
- package/esm/generated-sdk/state/contract.d.ts.map +1 -1
- package/esm/generated-sdk/state/mod.d.ts.map +1 -1
- package/esm/generated-sdk/state/owned_api.d.ts +65 -2
- package/esm/generated-sdk/state/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/state/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/state/types.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/api.d.ts +44 -3
- package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/api.js +4 -1
- package/esm/generated-sdk/trellis-core/client.d.ts +14 -2
- package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/contract.d.ts +40 -2
- package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/owned_api.d.ts +41 -2
- package/esm/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/esm/globals.d.ts.map +1 -1
- package/esm/health.d.ts +4 -3
- package/esm/health.d.ts.map +1 -1
- package/esm/health.js +1 -0
- package/esm/helpers.d.ts.map +1 -1
- package/esm/host/mod.d.ts.map +1 -0
- package/esm/host/node.d.ts.map +1 -0
- package/esm/index.d.ts +33 -32
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/jobs.d.ts.map +1 -1
- package/esm/kv.d.ts +1 -1
- package/esm/kv.d.ts.map +1 -1
- package/esm/models/auth/rpc/Logout.d.ts.map +1 -1
- package/esm/models/trellis/Page.d.ts +1 -1
- package/esm/models/trellis/Page.d.ts.map +1 -1
- package/esm/models/trellis/State.d.ts +1 -1
- package/esm/models/trellis/State.d.ts.map +1 -1
- package/esm/models/trellis/TrellisError.d.ts.map +1 -1
- package/esm/models/trellis/rpc/StateDelete.d.ts.map +1 -1
- package/esm/models/trellis/rpc/StateGet.d.ts +1 -1
- package/esm/models/trellis/rpc/StateGet.d.ts.map +1 -1
- package/esm/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/esm/models/trellis/rpc/StatePut.d.ts +1 -1
- package/esm/models/trellis/rpc/StatePut.d.ts.map +1 -1
- package/esm/operations.d.ts +4 -4
- package/esm/operations.d.ts.map +1 -1
- package/esm/runtime_transport.d.ts.map +1 -1
- package/esm/runtime_transport.js +2 -1
- package/esm/sdk/auth.d.ts +2 -0
- package/esm/sdk/auth.d.ts.map +1 -0
- package/esm/sdk/auth.js +1 -0
- package/esm/sdk/core.d.ts +2 -0
- package/esm/sdk/core.d.ts.map +1 -0
- package/esm/sdk/core.js +1 -0
- package/esm/sdk/health.d.ts +2 -0
- package/esm/sdk/health.d.ts.map +1 -0
- package/esm/sdk/health.js +1 -0
- package/esm/sdk/jobs.d.ts +2 -0
- package/esm/sdk/jobs.d.ts.map +1 -0
- package/esm/sdk/jobs.js +1 -0
- package/esm/sdk/state.d.ts +2 -0
- package/esm/sdk/state.d.ts.map +1 -0
- package/esm/sdk/state.js +1 -0
- package/esm/server/health.d.ts +2 -11
- package/esm/server/health.d.ts.map +1 -1
- package/esm/server/health.js +12 -11
- package/{script/npm/src → esm}/server/health_rpc.d.ts +1 -1
- package/esm/server/health_rpc.d.ts.map +1 -0
- package/esm/server/health_schemas.d.ts.map +1 -1
- package/esm/server/internal_jobs/active-job.d.ts.map +1 -0
- package/esm/server/internal_jobs/bindings.d.ts.map +1 -0
- package/esm/server/internal_jobs/cancellation-registry.d.ts.map +1 -0
- package/esm/server/internal_jobs/heartbeat.d.ts.map +1 -0
- package/esm/server/internal_jobs/job-manager.d.ts.map +1 -0
- package/esm/server/internal_jobs/projection.d.ts.map +1 -0
- package/esm/server/internal_jobs/runtime-worker.d.ts.map +1 -0
- package/esm/server/internal_jobs/types.d.ts.map +1 -0
- package/esm/server/runtime.d.ts.map +1 -0
- package/{script/npm/src → esm}/server/service.d.ts +4 -4
- package/esm/server/service.d.ts.map +1 -0
- package/esm/{npm/src/server → server}/service.js +3 -3
- package/esm/{npm/src/server → server}/subscription.d.ts +1 -1
- package/esm/server/subscription.d.ts.map +1 -0
- package/esm/server/transfer.d.ts.map +1 -0
- package/esm/server.d.ts.map +1 -0
- package/esm/server_logger.d.ts.map +1 -0
- package/esm/service/deno.d.ts.map +1 -0
- package/esm/service/mod.d.ts.map +1 -0
- package/esm/service/node.d.ts.map +1 -0
- package/esm/service/outbox_inbox.d.ts.map +1 -0
- package/esm/store.d.ts +2 -2
- package/esm/store.d.ts.map +1 -1
- package/esm/tasks.d.ts +1 -1
- package/esm/tasks.d.ts.map +1 -1
- package/esm/telemetry/carrier.d.ts.map +1 -1
- package/esm/telemetry/core.d.ts.map +1 -1
- package/esm/telemetry/env.d.ts.map +1 -1
- package/esm/telemetry/env.js +3 -2
- package/esm/telemetry/mod.d.ts +9 -9
- package/esm/telemetry/mod.d.ts.map +1 -1
- package/esm/telemetry/nats.d.ts +1 -1
- package/esm/telemetry/nats.d.ts.map +1 -1
- package/esm/telemetry/result.d.ts.map +1 -1
- package/esm/telemetry/trace.d.ts.map +1 -1
- package/esm/telemetry/trellis.d.ts +1 -1
- package/esm/telemetry/trellis.d.ts.map +1 -1
- package/esm/tracing.d.ts +3 -2
- package/esm/tracing.d.ts.map +1 -1
- package/esm/tracing.js +3 -0
- package/esm/transfer.d.ts +1 -1
- package/esm/transfer.d.ts.map +1 -1
- package/esm/trellis.d.ts +13 -13
- package/esm/trellis.d.ts.map +1 -1
- package/package.json +28 -28
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/auth/browser/login.d.ts +3 -3
- package/script/auth/browser/login.d.ts.map +1 -1
- package/script/auth/browser/login.js +12 -12
- package/script/auth/browser/portal.d.ts +5 -5
- package/script/auth/browser/portal.d.ts.map +1 -1
- package/script/auth/browser/portal.js +3 -3
- package/script/auth/browser/session.d.ts.map +1 -1
- package/script/auth/browser/session.js +21 -21
- package/script/auth/browser/storage.d.ts.map +1 -1
- package/script/auth/browser.d.ts +8 -7
- package/script/auth/browser.d.ts.map +1 -1
- package/script/auth/browser.js +47 -46
- package/script/auth/device_activation.d.ts +3 -3
- package/script/auth/device_activation.d.ts.map +1 -1
- package/script/auth/device_activation.js +36 -36
- package/script/auth/keys.d.ts.map +1 -1
- package/script/auth/keys.js +6 -6
- package/script/auth/mod.d.ts +9 -9
- package/script/auth/mod.d.ts.map +1 -1
- package/script/auth/mod.js +232 -232
- package/script/auth/proof.d.ts.map +1 -1
- package/script/auth/proof.js +13 -13
- package/script/auth/protocol.d.ts +245 -5
- package/script/auth/protocol.d.ts.map +1 -1
- package/script/auth/protocol.js +29 -29
- package/script/auth/schemas.d.ts.map +1 -1
- package/script/auth/session_auth.d.ts.map +1 -1
- package/script/auth/session_auth.js +15 -15
- package/script/auth/time.d.ts.map +1 -1
- package/script/auth/trellis_id.d.ts.map +1 -1
- package/script/auth/trellis_id.js +3 -3
- package/script/auth/types.d.ts +1 -1
- package/script/auth/types.d.ts.map +1 -1
- package/script/auth/utils.d.ts.map +1 -1
- package/script/auth.d.ts +2 -1
- package/script/auth.d.ts.map +1 -1
- package/script/auth.js +1 -0
- package/script/browser.d.ts.map +1 -0
- package/script/client.d.ts +6 -6
- package/script/client.d.ts.map +1 -1
- package/script/client.js +6 -6
- package/script/client_connect.d.ts +8 -8
- package/script/client_connect.d.ts.map +1 -1
- package/script/client_connect.js +88 -54
- package/script/codec.d.ts +2 -2
- package/script/codec.d.ts.map +1 -1
- package/script/codec.js +15 -15
- package/script/connection.d.ts +1 -1
- package/script/connection.d.ts.map +1 -1
- package/script/connection.js +2 -2
- package/script/contract.d.ts +2 -2
- package/script/contract.d.ts.map +1 -1
- package/script/contract.js +5 -5
- package/script/contract_support/canonical.d.ts.map +1 -1
- package/script/contract_support/mod.d.ts +13 -13
- package/script/contract_support/mod.d.ts.map +1 -1
- package/script/contract_support/mod.js +64 -64
- package/script/contract_support/protocol.d.ts.map +1 -1
- package/script/contract_support/runtime.d.ts +1 -1
- package/script/contract_support/runtime.d.ts.map +1 -1
- package/script/contract_support/schema_pointers.d.ts.map +1 -1
- package/script/contracts.d.ts +4 -3
- package/script/contracts.d.ts.map +1 -1
- package/script/contracts.js +6 -5
- package/script/device/deno.d.ts.map +1 -0
- package/script/device.d.ts +9 -8
- package/script/device.d.ts.map +1 -1
- package/script/device.js +41 -40
- package/script/env.d.ts.map +1 -0
- package/script/errors/AuthError.d.ts +1 -1
- package/script/errors/AuthError.d.ts.map +1 -1
- package/script/errors/AuthError.js +2 -2
- package/script/errors/KVError.d.ts +1 -1
- package/script/errors/KVError.d.ts.map +1 -1
- package/script/errors/KVError.js +2 -2
- package/script/errors/OperationLifecycleError.d.ts +1 -1
- package/script/errors/OperationLifecycleError.d.ts.map +1 -1
- package/script/errors/OperationLifecycleError.js +4 -4
- package/script/errors/RemoteError.d.ts +10 -10
- package/script/errors/RemoteError.d.ts.map +1 -1
- package/script/errors/RemoteError.js +7 -7
- package/script/errors/StoreError.d.ts +1 -1
- package/script/errors/StoreError.d.ts.map +1 -1
- package/script/errors/StoreError.js +2 -2
- package/script/errors/TransferError.d.ts +1 -1
- package/script/errors/TransferError.d.ts.map +1 -1
- package/script/errors/TransferError.js +2 -2
- package/script/errors/TransportError.d.ts +1 -1
- package/script/errors/TransportError.d.ts.map +1 -1
- package/script/errors/TransportError.js +2 -2
- package/script/errors/TrellisError.d.ts.map +1 -1
- package/script/errors/ValidationError.d.ts +1 -1
- package/script/errors/ValidationError.d.ts.map +1 -1
- package/script/errors/ValidationError.js +2 -2
- package/script/errors/index.d.ts +33 -32
- package/script/errors/index.d.ts.map +1 -1
- package/script/errors/index.js +84 -83
- package/script/generate.d.ts.map +1 -0
- package/script/{npm/src/generate.js → generate.js} +1 -0
- package/script/generated-sdk/auth/api.d.ts +604 -3
- package/script/generated-sdk/auth/api.d.ts.map +1 -1
- package/script/generated-sdk/auth/api.js +4 -1
- package/script/generated-sdk/auth/client.d.ts +8 -0
- package/script/generated-sdk/auth/client.d.ts.map +1 -1
- package/script/generated-sdk/auth/contract.d.ts +600 -1
- package/script/generated-sdk/auth/contract.d.ts.map +1 -1
- package/script/generated-sdk/auth/mod.d.ts.map +1 -1
- package/script/generated-sdk/auth/owned_api.d.ts +601 -2
- package/script/generated-sdk/auth/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/auth/owned_api.js +144 -144
- package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/script/generated-sdk/auth/types.d.ts.map +1 -1
- package/script/generated-sdk/health/api.d.ts +14 -2
- package/script/generated-sdk/health/api.d.ts.map +1 -1
- package/script/generated-sdk/health/client.d.ts.map +1 -1
- package/script/generated-sdk/health/contract.d.ts +14 -1
- package/script/generated-sdk/health/contract.d.ts.map +1 -1
- package/script/generated-sdk/health/mod.d.ts.map +1 -1
- package/script/generated-sdk/health/owned_api.d.ts +15 -2
- package/script/generated-sdk/health/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/health/owned_api.js +2 -2
- package/script/generated-sdk/health/schemas.d.ts.map +1 -1
- package/script/generated-sdk/health/types.d.ts.map +1 -1
- package/script/generated-sdk/jobs/api.d.ts +105 -2
- package/script/generated-sdk/jobs/api.d.ts.map +1 -1
- package/script/generated-sdk/jobs/api.js +7 -7
- package/script/generated-sdk/jobs/client.d.ts.map +1 -1
- package/script/generated-sdk/jobs/contract.d.ts +105 -1
- package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
- package/script/generated-sdk/jobs/owned_api.d.ts +106 -2
- package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/jobs/owned_api.js +24 -24
- package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/script/generated-sdk/jobs/types.d.ts.map +1 -1
- package/script/generated-sdk/jobs/types.js +2 -2
- package/script/generated-sdk/state/api.d.ts +64 -2
- package/script/generated-sdk/state/api.d.ts.map +1 -1
- package/script/generated-sdk/state/api.js +2 -2
- package/script/generated-sdk/state/client.d.ts.map +1 -1
- package/script/generated-sdk/state/contract.d.ts +64 -1
- package/script/generated-sdk/state/contract.d.ts.map +1 -1
- package/script/generated-sdk/state/mod.d.ts.map +1 -1
- package/script/generated-sdk/state/owned_api.d.ts +65 -2
- package/script/generated-sdk/state/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/state/owned_api.js +15 -15
- package/script/generated-sdk/state/schemas.d.ts.map +1 -1
- package/script/generated-sdk/state/types.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/api.d.ts +44 -3
- package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/api.js +4 -1
- package/script/generated-sdk/trellis-core/client.d.ts +14 -2
- package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/contract.d.ts +40 -1
- package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/owned_api.d.ts +41 -2
- package/script/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/owned_api.js +9 -9
- package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/script/globals.d.ts.map +1 -1
- package/script/health.d.ts +4 -3
- package/script/health.d.ts.map +1 -1
- package/script/health.js +16 -15
- package/script/helpers.d.ts.map +1 -1
- package/script/host/mod.d.ts.map +1 -0
- package/script/host/node.d.ts.map +1 -0
- package/script/index.d.ts +33 -32
- package/script/index.d.ts.map +1 -1
- package/script/index.js +86 -85
- package/script/jobs.d.ts.map +1 -1
- package/script/jobs.js +3 -3
- package/script/kv.d.ts +1 -1
- package/script/kv.d.ts.map +1 -1
- package/script/kv.js +22 -22
- package/script/models/auth/rpc/Logout.d.ts.map +1 -1
- package/script/models/trellis/Page.d.ts +1 -1
- package/script/models/trellis/Page.d.ts.map +1 -1
- package/script/models/trellis/Page.js +3 -3
- package/script/models/trellis/State.d.ts +1 -1
- package/script/models/trellis/State.d.ts.map +1 -1
- package/script/models/trellis/TrellisError.d.ts.map +1 -1
- package/script/models/trellis/rpc/StateDelete.d.ts.map +1 -1
- package/script/models/trellis/rpc/StateGet.d.ts +1 -1
- package/script/models/trellis/rpc/StateGet.d.ts.map +1 -1
- package/script/models/trellis/rpc/StateGet.js +3 -3
- package/script/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/script/models/trellis/rpc/StateList.js +3 -3
- package/script/models/trellis/rpc/StatePut.d.ts +1 -1
- package/script/models/trellis/rpc/StatePut.d.ts.map +1 -1
- package/script/models/trellis/rpc/StatePut.js +5 -5
- package/script/operations.d.ts +4 -4
- package/script/operations.d.ts.map +1 -1
- package/script/operations.js +16 -16
- package/script/runtime_transport.d.ts.map +1 -1
- package/script/runtime_transport.js +2 -1
- package/script/sdk/auth.d.ts +2 -0
- package/script/sdk/auth.d.ts.map +1 -0
- package/script/{npm/src/sdk → sdk}/auth.js +1 -1
- package/script/sdk/core.d.ts +2 -0
- package/script/sdk/core.d.ts.map +1 -0
- package/script/{npm/src/sdk/health.js → sdk/core.js} +1 -1
- package/script/sdk/health.d.ts +2 -0
- package/script/sdk/health.d.ts.map +1 -0
- package/script/sdk/health.js +17 -0
- package/script/sdk/jobs.d.ts +2 -0
- package/script/sdk/jobs.d.ts.map +1 -0
- package/script/{npm/src/sdk → sdk}/jobs.js +1 -1
- package/script/sdk/state.d.ts +2 -0
- package/script/sdk/state.d.ts.map +1 -0
- package/script/{npm/src/sdk → sdk}/state.js +1 -1
- package/script/server/health.d.ts +2 -11
- package/script/server/health.d.ts.map +1 -1
- package/script/server/health.js +45 -11
- package/{esm/npm/src → script}/server/health_rpc.d.ts +1 -1
- package/script/server/health_rpc.d.ts.map +1 -0
- package/script/server/health_schemas.d.ts.map +1 -1
- package/script/server/internal_jobs/active-job.d.ts.map +1 -0
- package/script/server/internal_jobs/bindings.d.ts.map +1 -0
- package/script/server/internal_jobs/cancellation-registry.d.ts.map +1 -0
- package/script/server/internal_jobs/heartbeat.d.ts.map +1 -0
- package/script/server/internal_jobs/job-manager.d.ts.map +1 -0
- package/script/server/internal_jobs/projection.d.ts.map +1 -0
- package/script/server/internal_jobs/runtime-worker.d.ts.map +1 -0
- package/script/server/internal_jobs/types.d.ts.map +1 -0
- package/script/server/runtime.d.ts.map +1 -0
- package/{esm/npm/src → script}/server/service.d.ts +4 -4
- package/script/server/service.d.ts.map +1 -0
- package/script/{npm/src/server → server}/service.js +19 -19
- package/script/{npm/src/server → server}/subscription.d.ts +1 -1
- package/script/server/subscription.d.ts.map +1 -0
- package/script/server/transfer.d.ts.map +1 -0
- package/script/server.d.ts.map +1 -0
- package/script/server_logger.d.ts.map +1 -0
- package/script/service/deno.d.ts.map +1 -0
- package/script/service/mod.d.ts.map +1 -0
- package/script/service/node.d.ts.map +1 -0
- package/script/service/outbox_inbox.d.ts.map +1 -0
- package/script/store.d.ts +2 -2
- package/script/store.d.ts.map +1 -1
- package/script/store.js +20 -20
- package/script/tasks.d.ts +1 -1
- package/script/tasks.d.ts.map +1 -1
- package/script/tasks.js +2 -2
- package/script/telemetry/carrier.d.ts.map +1 -1
- package/script/telemetry/core.d.ts.map +1 -1
- package/script/telemetry/env.d.ts.map +1 -1
- package/script/telemetry/env.js +36 -2
- package/script/telemetry/mod.d.ts +9 -9
- package/script/telemetry/mod.d.ts.map +1 -1
- package/script/telemetry/mod.js +23 -23
- package/script/telemetry/nats.d.ts +1 -1
- package/script/telemetry/nats.d.ts.map +1 -1
- package/script/telemetry/result.d.ts.map +1 -1
- package/script/telemetry/trace.d.ts.map +1 -1
- package/script/telemetry/trace.js +2 -2
- package/script/telemetry/trellis.d.ts +1 -1
- package/script/telemetry/trellis.d.ts.map +1 -1
- package/script/telemetry/trellis.js +4 -4
- package/script/tracing.d.ts +3 -2
- package/script/tracing.d.ts.map +1 -1
- package/script/tracing.js +19 -16
- package/script/transfer.d.ts +1 -1
- package/script/transfer.d.ts.map +1 -1
- package/script/transfer.js +26 -26
- package/script/trellis.d.ts +13 -13
- package/script/trellis.d.ts.map +1 -1
- package/script/trellis.js +127 -127
- package/src/auth/protocol.ts +1 -1
- package/src/generate.ts +1 -0
- package/src/sdk/_generated/auth/api.ts +3 -0
- package/src/sdk/_generated/auth/client.ts +5 -1
- package/src/sdk/_generated/auth/contract.ts +1 -1
- package/src/sdk/_generated/auth/owned_api.ts +2 -2
- package/src/sdk/_generated/auth/types.ts +1 -1
- package/src/sdk/_generated/core/api.ts +3 -0
- package/src/sdk/_generated/core/client.ts +7 -2
- package/src/sdk/_generated/core/contract.ts +1 -1
- package/src/sdk/_generated/core/owned_api.ts +2 -2
- package/src/sdk/_generated/core/types.ts +1 -1
- package/src/sdk/_generated/health/client.ts +1 -1
- package/src/sdk/_generated/health/contract.ts +1 -1
- package/src/sdk/_generated/health/owned_api.ts +2 -2
- package/src/sdk/_generated/jobs/api.ts +3 -3
- package/src/sdk/_generated/jobs/client.ts +4 -4
- package/src/sdk/_generated/jobs/contract.ts +1 -1
- package/src/sdk/_generated/jobs/owned_api.ts +2 -2
- package/src/sdk/_generated/jobs/types.ts +2 -2
- package/src/sdk/_generated/state/api.ts +1 -1
- package/src/sdk/_generated/state/client.ts +2 -2
- package/src/sdk/_generated/state/contract.ts +1 -1
- package/src/sdk/_generated/state/owned_api.ts +2 -2
- package/src/sdk/_generated/state/types.ts +1 -1
- package/src/server/health.ts +2 -2
- package/src/server/health_rpc.ts +1 -1
- package/src/server/service.ts +5 -5
- package/src/server/subscription.ts +1 -4
- package/esm/npm/src/_dnt.polyfills.d.ts.map +0 -1
- package/esm/npm/src/_dnt.shims.d.ts.map +0 -1
- package/esm/npm/src/auth/browser/login.d.ts +0 -34
- package/esm/npm/src/auth/browser/login.d.ts.map +0 -1
- package/esm/npm/src/auth/browser/login.js +0 -141
- package/esm/npm/src/auth/browser/portal.d.ts +0 -11
- package/esm/npm/src/auth/browser/portal.d.ts.map +0 -1
- package/esm/npm/src/auth/browser/portal.js +0 -37
- package/esm/npm/src/auth/browser/session.d.ts +0 -29
- package/esm/npm/src/auth/browser/session.d.ts.map +0 -1
- package/esm/npm/src/auth/browser/session.js +0 -109
- package/esm/npm/src/auth/browser/storage.d.ts +0 -17
- package/esm/npm/src/auth/browser/storage.d.ts.map +0 -1
- package/esm/npm/src/auth/browser/storage.js +0 -73
- package/esm/npm/src/auth/browser.d.ts +0 -14
- package/esm/npm/src/auth/browser.d.ts.map +0 -1
- package/esm/npm/src/auth/browser.js +0 -12
- package/esm/npm/src/auth/device_activation.d.ts +0 -146
- package/esm/npm/src/auth/device_activation.d.ts.map +0 -1
- package/esm/npm/src/auth/device_activation.js +0 -369
- package/esm/npm/src/auth/keys.d.ts +0 -8
- package/esm/npm/src/auth/keys.d.ts.map +0 -1
- package/esm/npm/src/auth/keys.js +0 -70
- package/esm/npm/src/auth/mod.d.ts +0 -19
- package/esm/npm/src/auth/mod.d.ts.map +0 -1
- package/esm/npm/src/auth/mod.js +0 -18
- package/esm/npm/src/auth/proof.d.ts +0 -11
- package/esm/npm/src/auth/proof.d.ts.map +0 -1
- package/esm/npm/src/auth/proof.js +0 -49
- package/esm/npm/src/auth/protocol.d.ts +0 -3108
- package/esm/npm/src/auth/protocol.d.ts.map +0 -1
- package/esm/npm/src/auth/protocol.js +0 -1329
- package/esm/npm/src/auth/schemas.d.ts +0 -163
- package/esm/npm/src/auth/schemas.d.ts.map +0 -1
- package/esm/npm/src/auth/schemas.js +0 -89
- package/esm/npm/src/auth/session_auth.d.ts +0 -26
- package/esm/npm/src/auth/session_auth.d.ts.map +0 -1
- package/esm/npm/src/auth/session_auth.js +0 -70
- package/esm/npm/src/auth/time.d.ts +0 -7
- package/esm/npm/src/auth/time.d.ts.map +0 -1
- package/esm/npm/src/auth/time.js +0 -7
- package/esm/npm/src/auth/trellis_id.d.ts +0 -2
- package/esm/npm/src/auth/trellis_id.d.ts.map +0 -1
- package/esm/npm/src/auth/trellis_id.js +0 -5
- package/esm/npm/src/auth/types.d.ts +0 -4
- package/esm/npm/src/auth/types.d.ts.map +0 -1
- package/esm/npm/src/auth/types.js +0 -1
- package/esm/npm/src/auth/utils.d.ts +0 -11
- package/esm/npm/src/auth/utils.d.ts.map +0 -1
- package/esm/npm/src/auth/utils.js +0 -69
- package/esm/npm/src/auth.d.ts +0 -3
- package/esm/npm/src/auth.d.ts.map +0 -1
- package/esm/npm/src/auth.js +0 -2
- package/esm/npm/src/browser.d.ts.map +0 -1
- package/esm/npm/src/client.d.ts +0 -60
- package/esm/npm/src/client.d.ts.map +0 -1
- package/esm/npm/src/client.js +0 -39
- package/esm/npm/src/client_connect.d.ts +0 -87
- package/esm/npm/src/client_connect.d.ts.map +0 -1
- package/esm/npm/src/client_connect.js +0 -839
- package/esm/npm/src/codec.d.ts +0 -13
- package/esm/npm/src/codec.d.ts.map +0 -1
- package/esm/npm/src/codec.js +0 -73
- package/esm/npm/src/connection.d.ts +0 -91
- package/esm/npm/src/connection.d.ts.map +0 -1
- package/esm/npm/src/connection.js +0 -305
- package/esm/npm/src/contract.d.ts +0 -23
- package/esm/npm/src/contract.d.ts.map +0 -1
- package/esm/npm/src/contract.js +0 -1
- package/esm/npm/src/contract_support/canonical.d.ts +0 -14
- package/esm/npm/src/contract_support/canonical.d.ts.map +0 -1
- package/esm/npm/src/contract_support/canonical.js +0 -190
- package/esm/npm/src/contract_support/mod.d.ts +0 -1188
- package/esm/npm/src/contract_support/mod.d.ts.map +0 -1
- package/esm/npm/src/contract_support/mod.js +0 -2182
- package/esm/npm/src/contract_support/protocol.d.ts +0 -384
- package/esm/npm/src/contract_support/protocol.d.ts.map +0 -1
- package/esm/npm/src/contract_support/protocol.js +0 -164
- package/esm/npm/src/contract_support/runtime.d.ts +0 -84
- package/esm/npm/src/contract_support/runtime.d.ts.map +0 -1
- package/esm/npm/src/contract_support/runtime.js +0 -9
- package/esm/npm/src/contract_support/schema_pointers.d.ts +0 -18
- package/esm/npm/src/contract_support/schema_pointers.d.ts.map +0 -1
- package/esm/npm/src/contract_support/schema_pointers.js +0 -79
- package/esm/npm/src/contracts.d.ts +0 -5
- package/esm/npm/src/contracts.d.ts.map +0 -1
- package/esm/npm/src/contracts.js +0 -3
- package/esm/npm/src/device/deno.d.ts.map +0 -1
- package/esm/npm/src/device.d.ts +0 -150
- package/esm/npm/src/device.d.ts.map +0 -1
- package/esm/npm/src/device.js +0 -549
- package/esm/npm/src/env.d.ts.map +0 -1
- package/esm/npm/src/errors/AuthError.d.ts +0 -31
- package/esm/npm/src/errors/AuthError.d.ts.map +0 -1
- package/esm/npm/src/errors/AuthError.js +0 -79
- package/esm/npm/src/errors/KVError.d.ts +0 -31
- package/esm/npm/src/errors/KVError.d.ts.map +0 -1
- package/esm/npm/src/errors/KVError.js +0 -46
- package/esm/npm/src/errors/OperationLifecycleError.d.ts +0 -111
- package/esm/npm/src/errors/OperationLifecycleError.d.ts.map +0 -1
- package/esm/npm/src/errors/OperationLifecycleError.js +0 -207
- package/esm/npm/src/errors/RemoteError.d.ts +0 -55
- package/esm/npm/src/errors/RemoteError.d.ts.map +0 -1
- package/esm/npm/src/errors/RemoteError.js +0 -81
- package/esm/npm/src/errors/StoreError.d.ts +0 -22
- package/esm/npm/src/errors/StoreError.d.ts.map +0 -1
- package/esm/npm/src/errors/StoreError.js +0 -41
- package/esm/npm/src/errors/TransferError.d.ts +0 -22
- package/esm/npm/src/errors/TransferError.d.ts.map +0 -1
- package/esm/npm/src/errors/TransferError.js +0 -41
- package/esm/npm/src/errors/TransportError.d.ts +0 -30
- package/esm/npm/src/errors/TransportError.d.ts.map +0 -1
- package/esm/npm/src/errors/TransportError.js +0 -48
- package/esm/npm/src/errors/TrellisError.d.ts +0 -16
- package/esm/npm/src/errors/TrellisError.d.ts.map +0 -1
- package/esm/npm/src/errors/TrellisError.js +0 -15
- package/esm/npm/src/errors/ValidationError.d.ts +0 -51
- package/esm/npm/src/errors/ValidationError.d.ts.map +0 -1
- package/esm/npm/src/errors/ValidationError.js +0 -77
- package/esm/npm/src/errors/index.d.ts +0 -212
- package/esm/npm/src/errors/index.d.ts.map +0 -1
- package/esm/npm/src/errors/index.js +0 -190
- package/esm/npm/src/generate.d.ts.map +0 -1
- package/esm/npm/src/globals.d.ts +0 -10
- package/esm/npm/src/globals.d.ts.map +0 -1
- package/esm/npm/src/globals.js +0 -16
- package/esm/npm/src/health.d.ts +0 -5
- package/esm/npm/src/health.d.ts.map +0 -1
- package/esm/npm/src/health.js +0 -3
- package/esm/npm/src/helpers.d.ts +0 -10
- package/esm/npm/src/helpers.d.ts.map +0 -1
- package/esm/npm/src/helpers.js +0 -38
- package/esm/npm/src/host/mod.d.ts.map +0 -1
- package/esm/npm/src/host/node.d.ts.map +0 -1
- package/esm/npm/src/index.d.ts +0 -37
- package/esm/npm/src/index.d.ts.map +0 -1
- package/esm/npm/src/index.js +0 -18
- package/esm/npm/src/jobs.d.ts +0 -145
- package/esm/npm/src/jobs.d.ts.map +0 -1
- package/esm/npm/src/jobs.js +0 -220
- package/esm/npm/src/kv.d.ts +0 -82
- package/esm/npm/src/kv.d.ts.map +0 -1
- package/esm/npm/src/kv.js +0 -448
- package/esm/npm/src/models/auth/rpc/Logout.d.ts +0 -8
- package/esm/npm/src/models/auth/rpc/Logout.d.ts.map +0 -1
- package/esm/npm/src/models/auth/rpc/Logout.js +0 -5
- package/esm/npm/src/models/trellis/Page.d.ts +0 -2
- package/esm/npm/src/models/trellis/Page.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/Page.js +0 -1
- package/esm/npm/src/models/trellis/State.d.ts +0 -49
- package/esm/npm/src/models/trellis/State.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/State.js +0 -29
- package/esm/npm/src/models/trellis/TrellisError.d.ts +0 -20
- package/esm/npm/src/models/trellis/TrellisError.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/TrellisError.js +0 -15
- package/esm/npm/src/models/trellis/rpc/StateDelete.d.ts +0 -12
- package/esm/npm/src/models/trellis/rpc/StateDelete.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/rpc/StateDelete.js +0 -9
- package/esm/npm/src/models/trellis/rpc/StateGet.d.ts +0 -38
- package/esm/npm/src/models/trellis/rpc/StateGet.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/rpc/StateGet.js +0 -16
- package/esm/npm/src/models/trellis/rpc/StateList.d.ts +0 -35
- package/esm/npm/src/models/trellis/rpc/StateList.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/rpc/StateList.js +0 -18
- package/esm/npm/src/models/trellis/rpc/StatePut.d.ts +0 -51
- package/esm/npm/src/models/trellis/rpc/StatePut.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/rpc/StatePut.js +0 -26
- package/esm/npm/src/operations.d.ts +0 -171
- package/esm/npm/src/operations.d.ts.map +0 -1
- package/esm/npm/src/operations.js +0 -775
- package/esm/npm/src/runtime_transport.d.ts +0 -25
- package/esm/npm/src/runtime_transport.d.ts.map +0 -1
- package/esm/npm/src/runtime_transport.js +0 -84
- package/esm/npm/src/sdk/auth.d.ts +0 -2
- package/esm/npm/src/sdk/auth.d.ts.map +0 -1
- package/esm/npm/src/sdk/auth.js +0 -1
- package/esm/npm/src/sdk/core.d.ts +0 -2
- package/esm/npm/src/sdk/core.d.ts.map +0 -1
- package/esm/npm/src/sdk/core.js +0 -1
- package/esm/npm/src/sdk/health.d.ts +0 -2
- package/esm/npm/src/sdk/health.d.ts.map +0 -1
- package/esm/npm/src/sdk/health.js +0 -1
- package/esm/npm/src/sdk/jobs.d.ts +0 -2
- package/esm/npm/src/sdk/jobs.d.ts.map +0 -1
- package/esm/npm/src/sdk/jobs.js +0 -1
- package/esm/npm/src/sdk/state.d.ts +0 -2
- package/esm/npm/src/sdk/state.d.ts.map +0 -1
- package/esm/npm/src/sdk/state.js +0 -1
- package/esm/npm/src/server/health.d.ts +0 -161
- package/esm/npm/src/server/health.d.ts.map +0 -1
- package/esm/npm/src/server/health.js +0 -262
- package/esm/npm/src/server/health_rpc.d.ts.map +0 -1
- package/esm/npm/src/server/health_schemas.d.ts +0 -71
- package/esm/npm/src/server/health_schemas.d.ts.map +0 -1
- package/esm/npm/src/server/health_schemas.js +0 -54
- package/esm/npm/src/server/internal_jobs/active-job.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/bindings.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/cancellation-registry.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/heartbeat.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/job-manager.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/projection.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/runtime-worker.d.ts.map +0 -1
- package/esm/npm/src/server/internal_jobs/types.d.ts.map +0 -1
- package/esm/npm/src/server/runtime.d.ts.map +0 -1
- package/esm/npm/src/server/service.d.ts.map +0 -1
- package/esm/npm/src/server/subscription.d.ts.map +0 -1
- package/esm/npm/src/server/transfer.d.ts.map +0 -1
- package/esm/npm/src/server.d.ts.map +0 -1
- package/esm/npm/src/server_logger.d.ts.map +0 -1
- package/esm/npm/src/service/deno.d.ts.map +0 -1
- package/esm/npm/src/service/mod.d.ts.map +0 -1
- package/esm/npm/src/service/node.d.ts.map +0 -1
- package/esm/npm/src/service/outbox_inbox.d.ts.map +0 -1
- package/esm/npm/src/store.d.ts +0 -67
- package/esm/npm/src/store.d.ts.map +0 -1
- package/esm/npm/src/store.js +0 -474
- package/esm/npm/src/tasks.d.ts +0 -11
- package/esm/npm/src/tasks.d.ts.map +0 -1
- package/esm/npm/src/tasks.js +0 -41
- package/esm/npm/src/telemetry/carrier.d.ts +0 -9
- package/esm/npm/src/telemetry/carrier.d.ts.map +0 -1
- package/esm/npm/src/telemetry/carrier.js +0 -20
- package/esm/npm/src/telemetry/core.d.ts +0 -8
- package/esm/npm/src/telemetry/core.d.ts.map +0 -1
- package/esm/npm/src/telemetry/core.js +0 -14
- package/esm/npm/src/telemetry/env.d.ts +0 -2
- package/esm/npm/src/telemetry/env.d.ts.map +0 -1
- package/esm/npm/src/telemetry/env.js +0 -10
- package/esm/npm/src/telemetry/mod.d.ts +0 -10
- package/esm/npm/src/telemetry/mod.d.ts.map +0 -1
- package/esm/npm/src/telemetry/mod.js +0 -6
- package/esm/npm/src/telemetry/nats.d.ts +0 -7
- package/esm/npm/src/telemetry/nats.d.ts.map +0 -1
- package/esm/npm/src/telemetry/nats.js +0 -6
- package/esm/npm/src/telemetry/result.d.ts +0 -2
- package/esm/npm/src/telemetry/result.d.ts.map +0 -1
- package/esm/npm/src/telemetry/result.js +0 -18
- package/esm/npm/src/telemetry/trace.d.ts +0 -5
- package/esm/npm/src/telemetry/trace.d.ts.map +0 -1
- package/esm/npm/src/telemetry/trace.js +0 -26
- package/esm/npm/src/telemetry/trellis.d.ts +0 -2
- package/esm/npm/src/telemetry/trellis.d.ts.map +0 -1
- package/esm/npm/src/telemetry/trellis.js +0 -1
- package/esm/npm/src/tracing.d.ts +0 -5
- package/esm/npm/src/tracing.d.ts.map +0 -1
- package/esm/npm/src/tracing.js +0 -8
- package/esm/npm/src/transfer.d.ts +0 -118
- package/esm/npm/src/transfer.d.ts.map +0 -1
- package/esm/npm/src/transfer.js +0 -407
- package/esm/npm/src/trellis.d.ts +0 -678
- package/esm/npm/src/trellis.d.ts.map +0 -1
- package/esm/npm/src/trellis.js +0 -2284
- package/script/npm/src/_dnt.polyfills.d.ts.map +0 -1
- package/script/npm/src/_dnt.shims.d.ts.map +0 -1
- package/script/npm/src/auth/browser/login.d.ts +0 -34
- package/script/npm/src/auth/browser/login.d.ts.map +0 -1
- package/script/npm/src/auth/browser/login.js +0 -147
- package/script/npm/src/auth/browser/portal.d.ts +0 -11
- package/script/npm/src/auth/browser/portal.d.ts.map +0 -1
- package/script/npm/src/auth/browser/portal.js +0 -44
- package/script/npm/src/auth/browser/session.d.ts +0 -29
- package/script/npm/src/auth/browser/session.d.ts.map +0 -1
- package/script/npm/src/auth/browser/session.js +0 -122
- package/script/npm/src/auth/browser/storage.d.ts +0 -17
- package/script/npm/src/auth/browser/storage.d.ts.map +0 -1
- package/script/npm/src/auth/browser/storage.js +0 -79
- package/script/npm/src/auth/browser.d.ts +0 -14
- package/script/npm/src/auth/browser.d.ts.map +0 -1
- package/script/npm/src/auth/browser.js +0 -53
- package/script/npm/src/auth/device_activation.d.ts +0 -146
- package/script/npm/src/auth/device_activation.d.ts.map +0 -1
- package/script/npm/src/auth/device_activation.js +0 -387
- package/script/npm/src/auth/keys.d.ts +0 -8
- package/script/npm/src/auth/keys.d.ts.map +0 -1
- package/script/npm/src/auth/keys.js +0 -82
- package/script/npm/src/auth/mod.d.ts +0 -19
- package/script/npm/src/auth/mod.d.ts.map +0 -1
- package/script/npm/src/auth/mod.js +0 -248
- package/script/npm/src/auth/proof.d.ts +0 -11
- package/script/npm/src/auth/proof.d.ts.map +0 -1
- package/script/npm/src/auth/proof.js +0 -54
- package/script/npm/src/auth/protocol.d.ts +0 -3108
- package/script/npm/src/auth/protocol.d.ts.map +0 -1
- package/script/npm/src/auth/protocol.js +0 -1335
- package/script/npm/src/auth/schemas.d.ts +0 -163
- package/script/npm/src/auth/schemas.d.ts.map +0 -1
- package/script/npm/src/auth/schemas.js +0 -93
- package/script/npm/src/auth/session_auth.d.ts +0 -26
- package/script/npm/src/auth/session_auth.d.ts.map +0 -1
- package/script/npm/src/auth/session_auth.js +0 -74
- package/script/npm/src/auth/time.d.ts +0 -7
- package/script/npm/src/auth/time.d.ts.map +0 -1
- package/script/npm/src/auth/time.js +0 -11
- package/script/npm/src/auth/trellis_id.d.ts +0 -2
- package/script/npm/src/auth/trellis_id.d.ts.map +0 -1
- package/script/npm/src/auth/trellis_id.js +0 -8
- package/script/npm/src/auth/types.d.ts +0 -4
- package/script/npm/src/auth/types.d.ts.map +0 -1
- package/script/npm/src/auth/types.js +0 -2
- package/script/npm/src/auth/utils.d.ts +0 -11
- package/script/npm/src/auth/utils.d.ts.map +0 -1
- package/script/npm/src/auth/utils.js +0 -78
- package/script/npm/src/auth.d.ts +0 -3
- package/script/npm/src/auth.d.ts.map +0 -1
- package/script/npm/src/auth.js +0 -18
- package/script/npm/src/browser.d.ts.map +0 -1
- package/script/npm/src/client.d.ts +0 -60
- package/script/npm/src/client.d.ts.map +0 -1
- package/script/npm/src/client.js +0 -76
- package/script/npm/src/client_connect.d.ts +0 -87
- package/script/npm/src/client_connect.d.ts.map +0 -1
- package/script/npm/src/client_connect.js +0 -878
- package/script/npm/src/codec.d.ts +0 -13
- package/script/npm/src/codec.d.ts.map +0 -1
- package/script/npm/src/codec.js +0 -80
- package/script/npm/src/connection.d.ts +0 -91
- package/script/npm/src/connection.d.ts.map +0 -1
- package/script/npm/src/connection.js +0 -311
- package/script/npm/src/contract.d.ts +0 -23
- package/script/npm/src/contract.d.ts.map +0 -1
- package/script/npm/src/contract.js +0 -8
- package/script/npm/src/contract_support/canonical.d.ts +0 -14
- package/script/npm/src/contract_support/canonical.d.ts.map +0 -1
- package/script/npm/src/contract_support/canonical.js +0 -199
- package/script/npm/src/contract_support/mod.d.ts +0 -1188
- package/script/npm/src/contract_support/mod.d.ts.map +0 -1
- package/script/npm/src/contract_support/mod.js +0 -2225
- package/script/npm/src/contract_support/protocol.d.ts +0 -384
- package/script/npm/src/contract_support/protocol.d.ts.map +0 -1
- package/script/npm/src/contract_support/protocol.js +0 -171
- package/script/npm/src/contract_support/runtime.d.ts +0 -84
- package/script/npm/src/contract_support/runtime.d.ts.map +0 -1
- package/script/npm/src/contract_support/runtime.js +0 -13
- package/script/npm/src/contract_support/schema_pointers.d.ts +0 -18
- package/script/npm/src/contract_support/schema_pointers.d.ts.map +0 -1
- package/script/npm/src/contract_support/schema_pointers.js +0 -83
- package/script/npm/src/contracts.d.ts +0 -5
- package/script/npm/src/contracts.d.ts.map +0 -1
- package/script/npm/src/contracts.js +0 -24
- package/script/npm/src/device/deno.d.ts.map +0 -1
- package/script/npm/src/device.d.ts +0 -150
- package/script/npm/src/device.d.ts.map +0 -1
- package/script/npm/src/device.js +0 -555
- package/script/npm/src/env.d.ts.map +0 -1
- package/script/npm/src/errors/AuthError.d.ts +0 -31
- package/script/npm/src/errors/AuthError.d.ts.map +0 -1
- package/script/npm/src/errors/AuthError.js +0 -86
- package/script/npm/src/errors/KVError.d.ts +0 -31
- package/script/npm/src/errors/KVError.d.ts.map +0 -1
- package/script/npm/src/errors/KVError.js +0 -53
- package/script/npm/src/errors/OperationLifecycleError.d.ts +0 -111
- package/script/npm/src/errors/OperationLifecycleError.d.ts.map +0 -1
- package/script/npm/src/errors/OperationLifecycleError.js +0 -216
- package/script/npm/src/errors/RemoteError.d.ts +0 -55
- package/script/npm/src/errors/RemoteError.d.ts.map +0 -1
- package/script/npm/src/errors/RemoteError.js +0 -88
- package/script/npm/src/errors/StoreError.d.ts +0 -22
- package/script/npm/src/errors/StoreError.d.ts.map +0 -1
- package/script/npm/src/errors/StoreError.js +0 -48
- package/script/npm/src/errors/TransferError.d.ts +0 -22
- package/script/npm/src/errors/TransferError.d.ts.map +0 -1
- package/script/npm/src/errors/TransferError.js +0 -48
- package/script/npm/src/errors/TransportError.d.ts +0 -30
- package/script/npm/src/errors/TransportError.d.ts.map +0 -1
- package/script/npm/src/errors/TransportError.js +0 -55
- package/script/npm/src/errors/TrellisError.d.ts +0 -16
- package/script/npm/src/errors/TrellisError.d.ts.map +0 -1
- package/script/npm/src/errors/TrellisError.js +0 -19
- package/script/npm/src/errors/ValidationError.d.ts +0 -51
- package/script/npm/src/errors/ValidationError.d.ts.map +0 -1
- package/script/npm/src/errors/ValidationError.js +0 -84
- package/script/npm/src/errors/index.d.ts +0 -212
- package/script/npm/src/errors/index.d.ts.map +0 -1
- package/script/npm/src/errors/index.js +0 -217
- package/script/npm/src/generate.d.ts.map +0 -1
- package/script/npm/src/globals.d.ts +0 -10
- package/script/npm/src/globals.d.ts.map +0 -1
- package/script/npm/src/globals.js +0 -19
- package/script/npm/src/health.d.ts +0 -5
- package/script/npm/src/health.d.ts.map +0 -1
- package/script/npm/src/health.js +0 -19
- package/script/npm/src/helpers.d.ts +0 -10
- package/script/npm/src/helpers.d.ts.map +0 -1
- package/script/npm/src/helpers.js +0 -44
- package/script/npm/src/host/mod.d.ts.map +0 -1
- package/script/npm/src/host/node.d.ts.map +0 -1
- package/script/npm/src/index.d.ts +0 -37
- package/script/npm/src/index.d.ts.map +0 -1
- package/script/npm/src/index.js +0 -98
- package/script/npm/src/jobs.d.ts +0 -145
- package/script/npm/src/jobs.d.ts.map +0 -1
- package/script/npm/src/jobs.js +0 -227
- package/script/npm/src/kv.d.ts +0 -82
- package/script/npm/src/kv.d.ts.map +0 -1
- package/script/npm/src/kv.js +0 -486
- package/script/npm/src/models/auth/rpc/Logout.d.ts +0 -8
- package/script/npm/src/models/auth/rpc/Logout.d.ts.map +0 -1
- package/script/npm/src/models/auth/rpc/Logout.js +0 -11
- package/script/npm/src/models/trellis/Page.d.ts +0 -2
- package/script/npm/src/models/trellis/Page.d.ts.map +0 -1
- package/script/npm/src/models/trellis/Page.js +0 -6
- package/script/npm/src/models/trellis/State.d.ts +0 -49
- package/script/npm/src/models/trellis/State.d.ts.map +0 -1
- package/script/npm/src/models/trellis/State.js +0 -35
- package/script/npm/src/models/trellis/TrellisError.d.ts +0 -20
- package/script/npm/src/models/trellis/TrellisError.d.ts.map +0 -1
- package/script/npm/src/models/trellis/TrellisError.js +0 -21
- package/script/npm/src/models/trellis/rpc/StateDelete.d.ts +0 -12
- package/script/npm/src/models/trellis/rpc/StateDelete.d.ts.map +0 -1
- package/script/npm/src/models/trellis/rpc/StateDelete.js +0 -15
- package/script/npm/src/models/trellis/rpc/StateGet.d.ts +0 -38
- package/script/npm/src/models/trellis/rpc/StateGet.d.ts.map +0 -1
- package/script/npm/src/models/trellis/rpc/StateGet.js +0 -22
- package/script/npm/src/models/trellis/rpc/StateList.d.ts +0 -35
- package/script/npm/src/models/trellis/rpc/StateList.d.ts.map +0 -1
- package/script/npm/src/models/trellis/rpc/StateList.js +0 -24
- package/script/npm/src/models/trellis/rpc/StatePut.d.ts +0 -51
- package/script/npm/src/models/trellis/rpc/StatePut.d.ts.map +0 -1
- package/script/npm/src/models/trellis/rpc/StatePut.js +0 -32
- package/script/npm/src/operations.d.ts +0 -171
- package/script/npm/src/operations.d.ts.map +0 -1
- package/script/npm/src/operations.js +0 -780
- package/script/npm/src/runtime_transport.d.ts +0 -25
- package/script/npm/src/runtime_transport.d.ts.map +0 -1
- package/script/npm/src/runtime_transport.js +0 -122
- package/script/npm/src/sdk/auth.d.ts +0 -2
- package/script/npm/src/sdk/auth.d.ts.map +0 -1
- package/script/npm/src/sdk/core.d.ts +0 -2
- package/script/npm/src/sdk/core.d.ts.map +0 -1
- package/script/npm/src/sdk/core.js +0 -17
- package/script/npm/src/sdk/health.d.ts +0 -2
- package/script/npm/src/sdk/health.d.ts.map +0 -1
- package/script/npm/src/sdk/jobs.d.ts +0 -2
- package/script/npm/src/sdk/jobs.d.ts.map +0 -1
- package/script/npm/src/sdk/state.d.ts +0 -2
- package/script/npm/src/sdk/state.d.ts.map +0 -1
- package/script/npm/src/server/health.d.ts +0 -161
- package/script/npm/src/server/health.d.ts.map +0 -1
- package/script/npm/src/server/health.js +0 -304
- package/script/npm/src/server/health_rpc.d.ts.map +0 -1
- package/script/npm/src/server/health_schemas.d.ts +0 -71
- package/script/npm/src/server/health_schemas.d.ts.map +0 -1
- package/script/npm/src/server/health_schemas.js +0 -57
- package/script/npm/src/server/internal_jobs/active-job.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/bindings.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/cancellation-registry.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/heartbeat.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/job-manager.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/projection.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/runtime-worker.d.ts.map +0 -1
- package/script/npm/src/server/internal_jobs/types.d.ts.map +0 -1
- package/script/npm/src/server/runtime.d.ts.map +0 -1
- package/script/npm/src/server/service.d.ts.map +0 -1
- package/script/npm/src/server/subscription.d.ts.map +0 -1
- package/script/npm/src/server/transfer.d.ts.map +0 -1
- package/script/npm/src/server.d.ts.map +0 -1
- package/script/npm/src/server_logger.d.ts.map +0 -1
- package/script/npm/src/service/deno.d.ts.map +0 -1
- package/script/npm/src/service/mod.d.ts.map +0 -1
- package/script/npm/src/service/node.d.ts.map +0 -1
- package/script/npm/src/service/outbox_inbox.d.ts.map +0 -1
- package/script/npm/src/store.d.ts +0 -67
- package/script/npm/src/store.d.ts.map +0 -1
- package/script/npm/src/store.js +0 -480
- package/script/npm/src/tasks.d.ts +0 -11
- package/script/npm/src/tasks.d.ts.map +0 -1
- package/script/npm/src/tasks.js +0 -45
- package/script/npm/src/telemetry/carrier.d.ts +0 -9
- package/script/npm/src/telemetry/carrier.d.ts.map +0 -1
- package/script/npm/src/telemetry/carrier.js +0 -25
- package/script/npm/src/telemetry/core.d.ts +0 -8
- package/script/npm/src/telemetry/core.d.ts.map +0 -1
- package/script/npm/src/telemetry/core.js +0 -24
- package/script/npm/src/telemetry/env.d.ts +0 -2
- package/script/npm/src/telemetry/env.d.ts.map +0 -1
- package/script/npm/src/telemetry/env.js +0 -46
- package/script/npm/src/telemetry/mod.d.ts +0 -10
- package/script/npm/src/telemetry/mod.d.ts.map +0 -1
- package/script/npm/src/telemetry/mod.js +0 -26
- package/script/npm/src/telemetry/nats.d.ts +0 -7
- package/script/npm/src/telemetry/nats.d.ts.map +0 -1
- package/script/npm/src/telemetry/nats.js +0 -9
- package/script/npm/src/telemetry/result.d.ts +0 -2
- package/script/npm/src/telemetry/result.d.ts.map +0 -1
- package/script/npm/src/telemetry/result.js +0 -21
- package/script/npm/src/telemetry/trace.d.ts +0 -5
- package/script/npm/src/telemetry/trace.d.ts.map +0 -1
- package/script/npm/src/telemetry/trace.js +0 -31
- package/script/npm/src/telemetry/trellis.d.ts +0 -2
- package/script/npm/src/telemetry/trellis.d.ts.map +0 -1
- package/script/npm/src/telemetry/trellis.js +0 -7
- package/script/npm/src/tracing.d.ts +0 -5
- package/script/npm/src/tracing.d.ts.map +0 -1
- package/script/npm/src/tracing.js +0 -27
- package/script/npm/src/transfer.d.ts +0 -118
- package/script/npm/src/transfer.d.ts.map +0 -1
- package/script/npm/src/transfer.js +0 -417
- package/script/npm/src/trellis.d.ts +0 -678
- package/script/npm/src/trellis.d.ts.map +0 -1
- package/script/npm/src/trellis.js +0 -2299
- /package/esm/{npm/src/_dnt.polyfills.d.ts → _dnt.polyfills.d.ts} +0 -0
- /package/esm/{npm/src/_dnt.polyfills.js → _dnt.polyfills.js} +0 -0
- /package/esm/{npm/src/_dnt.shims.d.ts → _dnt.shims.d.ts} +0 -0
- /package/esm/{npm/src/_dnt.shims.js → _dnt.shims.js} +0 -0
- /package/esm/{npm/src/browser.d.ts → browser.d.ts} +0 -0
- /package/esm/{npm/src/browser.js → browser.js} +0 -0
- /package/esm/{npm/src/device → device}/deno.d.ts +0 -0
- /package/esm/{npm/src/device → device}/deno.js +0 -0
- /package/esm/{npm/src/env.d.ts → env.d.ts} +0 -0
- /package/esm/{npm/src/env.js → env.js} +0 -0
- /package/esm/{npm/src/generate.d.ts → generate.d.ts} +0 -0
- /package/esm/{npm/src/host → host}/mod.d.ts +0 -0
- /package/esm/{npm/src/host → host}/mod.js +0 -0
- /package/esm/{npm/src/host → host}/node.d.ts +0 -0
- /package/esm/{npm/src/host → host}/node.js +0 -0
- /package/esm/{npm/src/server → server}/health_rpc.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/active-job.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/active-job.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/bindings.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/bindings.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/cancellation-registry.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/cancellation-registry.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/heartbeat.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/heartbeat.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/job-manager.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/job-manager.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/projection.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/projection.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/runtime-worker.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/runtime-worker.js +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/types.d.ts +0 -0
- /package/esm/{npm/src/server → server}/internal_jobs/types.js +0 -0
- /package/esm/{npm/src/server → server}/runtime.d.ts +0 -0
- /package/esm/{npm/src/server → server}/runtime.js +0 -0
- /package/esm/{npm/src/server → server}/subscription.js +0 -0
- /package/esm/{npm/src/server → server}/transfer.d.ts +0 -0
- /package/esm/{npm/src/server → server}/transfer.js +0 -0
- /package/esm/{npm/src/server.d.ts → server.d.ts} +0 -0
- /package/esm/{npm/src/server.js → server.js} +0 -0
- /package/esm/{npm/src/server_logger.d.ts → server_logger.d.ts} +0 -0
- /package/esm/{npm/src/server_logger.js → server_logger.js} +0 -0
- /package/esm/{npm/src/service → service}/deno.d.ts +0 -0
- /package/esm/{npm/src/service → service}/deno.js +0 -0
- /package/esm/{npm/src/service → service}/mod.d.ts +0 -0
- /package/esm/{npm/src/service → service}/mod.js +0 -0
- /package/esm/{npm/src/service → service}/node.d.ts +0 -0
- /package/esm/{npm/src/service → service}/node.js +0 -0
- /package/esm/{npm/src/service → service}/outbox_inbox.d.ts +0 -0
- /package/esm/{npm/src/service → service}/outbox_inbox.js +0 -0
- /package/script/{npm/src/_dnt.polyfills.d.ts → _dnt.polyfills.d.ts} +0 -0
- /package/script/{npm/src/_dnt.polyfills.js → _dnt.polyfills.js} +0 -0
- /package/script/{npm/src/_dnt.shims.d.ts → _dnt.shims.d.ts} +0 -0
- /package/script/{npm/src/_dnt.shims.js → _dnt.shims.js} +0 -0
- /package/script/{npm/src/browser.d.ts → browser.d.ts} +0 -0
- /package/script/{npm/src/browser.js → browser.js} +0 -0
- /package/script/{npm/src/device → device}/deno.d.ts +0 -0
- /package/script/{npm/src/device → device}/deno.js +0 -0
- /package/script/{npm/src/env.d.ts → env.d.ts} +0 -0
- /package/script/{npm/src/env.js → env.js} +0 -0
- /package/script/{npm/src/generate.d.ts → generate.d.ts} +0 -0
- /package/script/{npm/src/host → host}/mod.d.ts +0 -0
- /package/script/{npm/src/host → host}/mod.js +0 -0
- /package/script/{npm/src/host → host}/node.d.ts +0 -0
- /package/script/{npm/src/host → host}/node.js +0 -0
- /package/script/{npm/src/server → server}/health_rpc.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/active-job.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/active-job.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/bindings.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/bindings.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/cancellation-registry.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/cancellation-registry.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/heartbeat.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/heartbeat.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/job-manager.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/job-manager.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/projection.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/projection.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/runtime-worker.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/runtime-worker.js +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/types.d.ts +0 -0
- /package/script/{npm/src/server → server}/internal_jobs/types.js +0 -0
- /package/script/{npm/src/server → server}/runtime.d.ts +0 -0
- /package/script/{npm/src/server → server}/runtime.js +0 -0
- /package/script/{npm/src/server → server}/subscription.js +0 -0
- /package/script/{npm/src/server → server}/transfer.d.ts +0 -0
- /package/script/{npm/src/server → server}/transfer.js +0 -0
- /package/script/{npm/src/server.d.ts → server.d.ts} +0 -0
- /package/script/{npm/src/server.js → server.js} +0 -0
- /package/script/{npm/src/server_logger.d.ts → server_logger.d.ts} +0 -0
- /package/script/{npm/src/server_logger.js → server_logger.js} +0 -0
- /package/script/{npm/src/service → service}/deno.d.ts +0 -0
- /package/script/{npm/src/service → service}/deno.js +0 -0
- /package/script/{npm/src/service → service}/mod.d.ts +0 -0
- /package/script/{npm/src/service → service}/mod.js +0 -0
- /package/script/{npm/src/service → service}/node.d.ts +0 -0
- /package/script/{npm/src/service → service}/node.js +0 -0
- /package/script/{npm/src/service → service}/outbox_inbox.d.ts +0 -0
- /package/script/{npm/src/service → service}/outbox_inbox.js +0 -0
|
@@ -1,2182 +0,0 @@
|
|
|
1
|
-
import Type from "typebox";
|
|
2
|
-
import { Value } from "typebox/value";
|
|
3
|
-
import { TrellisError } from "../errors/TrellisError.js";
|
|
4
|
-
import { canonicalizeJson, digestJson, isJsonValue, sha256Base64urlSync, } from "./canonical.js";
|
|
5
|
-
import { schema, unwrapSchema, } from "./runtime.js";
|
|
6
|
-
import { assertDataPointersExistAndAreTokenable, getSubschemaAtDataPointer, } from "./schema_pointers.js";
|
|
7
|
-
import { ContractEventConsumersSchema, ContractJobQueueSchema, ContractResourcesSchema, ContractSchemaRefSchema, ContractStateSchema, } from "./protocol.js";
|
|
8
|
-
export { ContractEventConsumerEventSchema, ContractEventConsumerGroupSchema, ContractEventConsumersSchema, ContractJobQueueSchema, ContractJobsSchema, ContractKvResourceSchema, ContractResourceBindingsSchema, ContractResourcesSchema, ContractSchemaRefSchema, ContractStateSchema, ContractStateStoreSchema, ContractStoreResourceSchema, EventConsumerResourceBindingSchema, EventHeaderSchema, InstalledServiceContractSchema, IsoDateSchema, JobsQueueBindingSchema, JobsResourceBindingSchema, KvResourceBindingSchema, PageRequestSchema, PageResponseSchema, StoreResourceBindingSchema, } from "./protocol.js";
|
|
9
|
-
export const CONTRACT_FORMAT_V1 = "trellis.contract.v1";
|
|
10
|
-
export const CATALOG_FORMAT_V1 = "trellis.catalog.v1";
|
|
11
|
-
const NonEmptyStringSchema = Type.String({ minLength: 1 });
|
|
12
|
-
const VersionSchema = Type.String({ pattern: "^v[0-9]+$" });
|
|
13
|
-
const PointerStringSchema = Type.String({ pattern: "^/.*" });
|
|
14
|
-
const CapabilityListSchema = Type.Array(NonEmptyStringSchema);
|
|
15
|
-
const JsonSchemaValueSchema = Type.Union([
|
|
16
|
-
Type.Object({}, { additionalProperties: true }),
|
|
17
|
-
Type.Boolean(),
|
|
18
|
-
]);
|
|
19
|
-
export const ContractDocsSchema = Type.Object({
|
|
20
|
-
summary: Type.Optional(Type.String()),
|
|
21
|
-
markdown: Type.String(),
|
|
22
|
-
});
|
|
23
|
-
export const ContractCapabilityMetadataSchema = Type.Object({
|
|
24
|
-
displayName: NonEmptyStringSchema,
|
|
25
|
-
description: NonEmptyStringSchema,
|
|
26
|
-
consequence: Type.Optional(NonEmptyStringSchema),
|
|
27
|
-
});
|
|
28
|
-
export const ContractCapabilitiesSchema = Type.Record(NonEmptyStringSchema, ContractCapabilityMetadataSchema);
|
|
29
|
-
export const ContractExportsSchema = Type.Object({
|
|
30
|
-
schemas: Type.Optional(Type.Array(NonEmptyStringSchema, { uniqueItems: true })),
|
|
31
|
-
});
|
|
32
|
-
const ContractUseRpcSchema = Type.Object({
|
|
33
|
-
call: Type.Optional(CapabilityListSchema),
|
|
34
|
-
});
|
|
35
|
-
const ContractUsePubSubSchema = Type.Object({
|
|
36
|
-
publish: Type.Optional(CapabilityListSchema),
|
|
37
|
-
subscribe: Type.Optional(CapabilityListSchema),
|
|
38
|
-
});
|
|
39
|
-
const ContractUseFeedSchema = Type.Object({
|
|
40
|
-
subscribe: Type.Optional(CapabilityListSchema),
|
|
41
|
-
});
|
|
42
|
-
const ContractUseSchema = Type.Object({
|
|
43
|
-
contract: NonEmptyStringSchema,
|
|
44
|
-
rpc: Type.Optional(ContractUseRpcSchema),
|
|
45
|
-
operations: Type.Optional(ContractUseRpcSchema),
|
|
46
|
-
events: Type.Optional(ContractUsePubSubSchema),
|
|
47
|
-
feeds: Type.Optional(ContractUseFeedSchema),
|
|
48
|
-
});
|
|
49
|
-
const ContractUsesFlatSchema = Type.Record(NonEmptyStringSchema, ContractUseSchema);
|
|
50
|
-
export const ContractUsesSchema = Type.Object({
|
|
51
|
-
required: Type.Optional(ContractUsesFlatSchema),
|
|
52
|
-
optional: Type.Optional(ContractUsesFlatSchema),
|
|
53
|
-
});
|
|
54
|
-
const ContractErrorDeclSchema = Type.Object({
|
|
55
|
-
type: NonEmptyStringSchema,
|
|
56
|
-
schema: Type.Optional(ContractSchemaRefSchema),
|
|
57
|
-
});
|
|
58
|
-
const ContractErrorRefSchema = Type.Object({
|
|
59
|
-
type: NonEmptyStringSchema,
|
|
60
|
-
});
|
|
61
|
-
const ContractOperationSignalSchema = Type.Object({
|
|
62
|
-
input: ContractSchemaRefSchema,
|
|
63
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
64
|
-
});
|
|
65
|
-
const RpcCapabilitiesSchema = Type.Object({
|
|
66
|
-
call: Type.Optional(CapabilityListSchema),
|
|
67
|
-
});
|
|
68
|
-
const OperationCapabilitiesSchema = Type.Object({
|
|
69
|
-
call: Type.Optional(CapabilityListSchema),
|
|
70
|
-
observe: Type.Optional(CapabilityListSchema),
|
|
71
|
-
cancel: Type.Optional(CapabilityListSchema),
|
|
72
|
-
control: Type.Optional(CapabilityListSchema),
|
|
73
|
-
});
|
|
74
|
-
const PubSubCapabilitiesSchema = Type.Object({
|
|
75
|
-
publish: Type.Optional(CapabilityListSchema),
|
|
76
|
-
subscribe: Type.Optional(CapabilityListSchema),
|
|
77
|
-
});
|
|
78
|
-
const FeedCapabilitiesSchema = Type.Object({
|
|
79
|
-
subscribe: Type.Optional(CapabilityListSchema),
|
|
80
|
-
});
|
|
81
|
-
const RpcTransferSchema = Type.Object({
|
|
82
|
-
direction: Type.Literal("receive"),
|
|
83
|
-
});
|
|
84
|
-
const OperationTransferSchema = Type.Object({
|
|
85
|
-
direction: Type.Literal("send"),
|
|
86
|
-
store: NonEmptyStringSchema,
|
|
87
|
-
key: PointerStringSchema,
|
|
88
|
-
contentType: Type.Optional(PointerStringSchema),
|
|
89
|
-
metadata: Type.Optional(PointerStringSchema),
|
|
90
|
-
expiresInMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
91
|
-
maxBytes: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
92
|
-
});
|
|
93
|
-
const ContractRpcMethodSchema = Type.Object({
|
|
94
|
-
version: VersionSchema,
|
|
95
|
-
subject: NonEmptyStringSchema,
|
|
96
|
-
input: ContractSchemaRefSchema,
|
|
97
|
-
output: ContractSchemaRefSchema,
|
|
98
|
-
capabilities: Type.Optional(RpcCapabilitiesSchema),
|
|
99
|
-
errors: Type.Optional(Type.Array(ContractErrorRefSchema)),
|
|
100
|
-
transfer: Type.Optional(RpcTransferSchema),
|
|
101
|
-
internal: Type.Optional(Type.Boolean()),
|
|
102
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
103
|
-
});
|
|
104
|
-
const ContractOperationSchema = Type.Object({
|
|
105
|
-
version: VersionSchema,
|
|
106
|
-
subject: NonEmptyStringSchema,
|
|
107
|
-
input: ContractSchemaRefSchema,
|
|
108
|
-
progress: Type.Optional(ContractSchemaRefSchema),
|
|
109
|
-
output: ContractSchemaRefSchema,
|
|
110
|
-
transfer: Type.Optional(OperationTransferSchema),
|
|
111
|
-
capabilities: Type.Optional(OperationCapabilitiesSchema),
|
|
112
|
-
signals: Type.Optional(Type.Record(NonEmptyStringSchema, ContractOperationSignalSchema)),
|
|
113
|
-
cancel: Type.Optional(Type.Boolean()),
|
|
114
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
115
|
-
});
|
|
116
|
-
const ContractEventSchema = Type.Object({
|
|
117
|
-
version: VersionSchema,
|
|
118
|
-
subject: NonEmptyStringSchema,
|
|
119
|
-
params: Type.Optional(Type.Array(PointerStringSchema)),
|
|
120
|
-
event: ContractSchemaRefSchema,
|
|
121
|
-
capabilities: Type.Optional(PubSubCapabilitiesSchema),
|
|
122
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
123
|
-
});
|
|
124
|
-
const ContractFeedSchema = Type.Object({
|
|
125
|
-
version: VersionSchema,
|
|
126
|
-
subject: NonEmptyStringSchema,
|
|
127
|
-
input: ContractSchemaRefSchema,
|
|
128
|
-
event: ContractSchemaRefSchema,
|
|
129
|
-
capabilities: Type.Optional(FeedCapabilitiesSchema),
|
|
130
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
131
|
-
});
|
|
132
|
-
export const TrellisContractV1Schema = Type.Object({
|
|
133
|
-
format: Type.Literal(CONTRACT_FORMAT_V1),
|
|
134
|
-
id: NonEmptyStringSchema,
|
|
135
|
-
displayName: NonEmptyStringSchema,
|
|
136
|
-
description: NonEmptyStringSchema,
|
|
137
|
-
docs: Type.Optional(ContractDocsSchema),
|
|
138
|
-
kind: Type.Union([
|
|
139
|
-
Type.Literal("service"),
|
|
140
|
-
Type.Literal("app"),
|
|
141
|
-
Type.Literal("device"),
|
|
142
|
-
Type.Literal("agent"),
|
|
143
|
-
]),
|
|
144
|
-
capabilities: Type.Optional(ContractCapabilitiesSchema),
|
|
145
|
-
schemas: Type.Optional(Type.Record(NonEmptyStringSchema, JsonSchemaValueSchema)),
|
|
146
|
-
exports: Type.Optional(ContractExportsSchema),
|
|
147
|
-
uses: Type.Optional(ContractUsesSchema),
|
|
148
|
-
state: Type.Optional(ContractStateSchema),
|
|
149
|
-
rpc: Type.Optional(Type.Record(NonEmptyStringSchema, ContractRpcMethodSchema)),
|
|
150
|
-
operations: Type.Optional(Type.Record(NonEmptyStringSchema, ContractOperationSchema)),
|
|
151
|
-
events: Type.Optional(Type.Record(NonEmptyStringSchema, ContractEventSchema)),
|
|
152
|
-
feeds: Type.Optional(Type.Record(NonEmptyStringSchema, ContractFeedSchema)),
|
|
153
|
-
errors: Type.Optional(Type.Record(NonEmptyStringSchema, ContractErrorDeclSchema)),
|
|
154
|
-
jobs: Type.Optional(Type.Record(NonEmptyStringSchema, ContractJobQueueSchema)),
|
|
155
|
-
eventConsumers: Type.Optional(ContractEventConsumersSchema),
|
|
156
|
-
resources: Type.Optional(ContractResourcesSchema),
|
|
157
|
-
});
|
|
158
|
-
export const TrellisCatalogV1Schema = Type.Object({
|
|
159
|
-
format: Type.Literal(CATALOG_FORMAT_V1),
|
|
160
|
-
contracts: Type.Array(Type.Object({
|
|
161
|
-
id: NonEmptyStringSchema,
|
|
162
|
-
digest: Type.String({ pattern: "^[A-Za-z0-9_-]+$" }),
|
|
163
|
-
displayName: NonEmptyStringSchema,
|
|
164
|
-
description: NonEmptyStringSchema,
|
|
165
|
-
})),
|
|
166
|
-
});
|
|
167
|
-
const CONTRACT_MODULE_METADATA = Symbol.for("@qlever-llc/trellis/contracts/contract-module");
|
|
168
|
-
export const CONTRACT_JOBS_METADATA = Symbol.for("@qlever-llc/trellis/contracts/jobs");
|
|
169
|
-
export const CONTRACT_KV_METADATA = Symbol.for("@qlever-llc/trellis/contracts/kv");
|
|
170
|
-
export const CONTRACT_STATE_METADATA = Symbol.for("@qlever-llc/trellis/contracts/state");
|
|
171
|
-
const CONTRACT_ERROR_RUNTIME_METADATA = Symbol.for("@qlever-llc/trellis/contracts/error-runtime");
|
|
172
|
-
const RESERVED_DEFINED_ERROR_FIELD_NAMES = new Set([
|
|
173
|
-
"id",
|
|
174
|
-
"type",
|
|
175
|
-
"message",
|
|
176
|
-
"context",
|
|
177
|
-
"traceId",
|
|
178
|
-
"cause",
|
|
179
|
-
]);
|
|
180
|
-
const DEFINED_ERROR_PAYLOAD = Symbol.for("@qlever-llc/trellis/contracts/defined-error-payload");
|
|
181
|
-
function createSchemaRef(_schemas) {
|
|
182
|
-
void _schemas;
|
|
183
|
-
return (schemaName) => ({ schema: schemaName });
|
|
184
|
-
}
|
|
185
|
-
function getContractErrorType(errorClass) {
|
|
186
|
-
const explicitType = Reflect.get(errorClass, "type");
|
|
187
|
-
return typeof explicitType === "string" ? explicitType : errorClass.name;
|
|
188
|
-
}
|
|
189
|
-
function isSerializableErrorData(value) {
|
|
190
|
-
return !!value && typeof value === "object" &&
|
|
191
|
-
typeof value.id === "string" &&
|
|
192
|
-
typeof value.type === "string" &&
|
|
193
|
-
typeof value.message === "string";
|
|
194
|
-
}
|
|
195
|
-
function isErrorClass(value) {
|
|
196
|
-
return typeof value === "function" &&
|
|
197
|
-
typeof Reflect.get(value, "name") === "string" &&
|
|
198
|
-
typeof Reflect.get(value, "fromSerializable") === "function" &&
|
|
199
|
-
typeof Reflect.get(value, "schema") === "object";
|
|
200
|
-
}
|
|
201
|
-
function assertNoReservedDefinedErrorFieldNames(fields) {
|
|
202
|
-
for (const fieldName of Object.keys(fields)) {
|
|
203
|
-
if (RESERVED_DEFINED_ERROR_FIELD_NAMES.has(fieldName)) {
|
|
204
|
-
throw new Error(`Defined error field '${fieldName}' is reserved`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function createDefinedErrorSchema(type, fields) {
|
|
209
|
-
return Type.Object({
|
|
210
|
-
id: Type.String(),
|
|
211
|
-
type: Type.Literal(type),
|
|
212
|
-
message: Type.String(),
|
|
213
|
-
...fields,
|
|
214
|
-
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
215
|
-
traceId: Type.Optional(Type.String()),
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function definedErrorPayloadFieldNames(fields) {
|
|
219
|
-
return Object.keys(fields);
|
|
220
|
-
}
|
|
221
|
-
function pickDefinedErrorPayload(fieldNames, source) {
|
|
222
|
-
return Object.fromEntries(fieldNames.map((fieldName) => [fieldName, source[fieldName]]));
|
|
223
|
-
}
|
|
224
|
-
function definedErrorBaseOptions(options) {
|
|
225
|
-
const baseOptions = {};
|
|
226
|
-
if (options.cause !== undefined) {
|
|
227
|
-
baseOptions.cause = options.cause;
|
|
228
|
-
}
|
|
229
|
-
if (options.context !== undefined) {
|
|
230
|
-
baseOptions.context = options.context;
|
|
231
|
-
}
|
|
232
|
-
if (options.id !== undefined) {
|
|
233
|
-
baseOptions.id = options.id;
|
|
234
|
-
}
|
|
235
|
-
if (options.traceId !== undefined) {
|
|
236
|
-
baseOptions.traceId = options.traceId;
|
|
237
|
-
}
|
|
238
|
-
return baseOptions;
|
|
239
|
-
}
|
|
240
|
-
function attachDefinedErrorPayload(error, payload) {
|
|
241
|
-
error[DEFINED_ERROR_PAYLOAD] = payload;
|
|
242
|
-
return Object.assign(error, payload);
|
|
243
|
-
}
|
|
244
|
-
const TRELLIS_AUTH_CONTRACT_ID = "trellis.auth@v1";
|
|
245
|
-
const TRELLIS_STATE_CONTRACT_ID = "trellis.state@v1";
|
|
246
|
-
const TRELLIS_HEALTH_CONTRACT_ID = "trellis.health@v1";
|
|
247
|
-
const BASELINE_AUTH_RPC_CALL = [
|
|
248
|
-
"Auth.Sessions.Me",
|
|
249
|
-
"Auth.Sessions.Logout",
|
|
250
|
-
];
|
|
251
|
-
const BASELINE_STATE_RPC_CALL = [
|
|
252
|
-
"State.Get",
|
|
253
|
-
"State.Put",
|
|
254
|
-
"State.Delete",
|
|
255
|
-
"State.List",
|
|
256
|
-
];
|
|
257
|
-
const BASELINE_HEALTH_EVENTS_PUBLISH = ["Health.Heartbeat"];
|
|
258
|
-
const UnknownRuntimeSchema = schema(Type.Unknown());
|
|
259
|
-
function typedUnknownRuntimeSchema() {
|
|
260
|
-
return UnknownRuntimeSchema;
|
|
261
|
-
}
|
|
262
|
-
function trellisRpcDesc(name) {
|
|
263
|
-
return {
|
|
264
|
-
subject: rpcSubject(name, "v1"),
|
|
265
|
-
input: typedUnknownRuntimeSchema(),
|
|
266
|
-
output: typedUnknownRuntimeSchema(),
|
|
267
|
-
callerCapabilities: [],
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
function trellisEventDesc(name) {
|
|
271
|
-
return {
|
|
272
|
-
subject: eventSubject(name, "v1", undefined),
|
|
273
|
-
event: typedUnknownRuntimeSchema(),
|
|
274
|
-
publishCapabilities: [],
|
|
275
|
-
subscribeCapabilities: [],
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const BASELINE_AUTH_API = {
|
|
279
|
-
rpc: {
|
|
280
|
-
"Auth.Sessions.Me": trellisRpcDesc("Auth.Sessions.Me"),
|
|
281
|
-
"Auth.Sessions.Logout": trellisRpcDesc("Auth.Sessions.Logout"),
|
|
282
|
-
},
|
|
283
|
-
operations: {},
|
|
284
|
-
events: {},
|
|
285
|
-
feeds: {},
|
|
286
|
-
subjects: {},
|
|
287
|
-
};
|
|
288
|
-
const BASELINE_STATE_API = {
|
|
289
|
-
rpc: {
|
|
290
|
-
"State.Get": trellisRpcDesc("State.Get"),
|
|
291
|
-
"State.Put": trellisRpcDesc("State.Put"),
|
|
292
|
-
"State.Delete": trellisRpcDesc("State.Delete"),
|
|
293
|
-
"State.List": trellisRpcDesc("State.List"),
|
|
294
|
-
},
|
|
295
|
-
operations: {},
|
|
296
|
-
events: {},
|
|
297
|
-
feeds: {},
|
|
298
|
-
subjects: {},
|
|
299
|
-
};
|
|
300
|
-
const BASELINE_HEALTH_API = {
|
|
301
|
-
rpc: {},
|
|
302
|
-
operations: {},
|
|
303
|
-
events: {
|
|
304
|
-
"Health.Heartbeat": trellisEventDesc("Health.Heartbeat"),
|
|
305
|
-
},
|
|
306
|
-
feeds: {},
|
|
307
|
-
subjects: {},
|
|
308
|
-
};
|
|
309
|
-
function createContractRefBuilder(registry) {
|
|
310
|
-
const schemaRef = registry.schemas
|
|
311
|
-
? createSchemaRef(registry.schemas)
|
|
312
|
-
: undefined;
|
|
313
|
-
return {
|
|
314
|
-
schema(schemaName) {
|
|
315
|
-
if (!schemaRef) {
|
|
316
|
-
throw new Error(`Contract builder ref.schema('${schemaName}') requires a schemas registry`);
|
|
317
|
-
}
|
|
318
|
-
return schemaRef(schemaName);
|
|
319
|
-
},
|
|
320
|
-
error(errorName) {
|
|
321
|
-
return errorName;
|
|
322
|
-
},
|
|
323
|
-
capability(capabilityName) {
|
|
324
|
-
return capabilityName;
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function cloneSchema(schemaValue) {
|
|
329
|
-
const cloned = JSON.parse(JSON.stringify(schemaValue));
|
|
330
|
-
if (!isJsonValue(cloned)) {
|
|
331
|
-
throw new Error("Contract schema is not JSON-serializable");
|
|
332
|
-
}
|
|
333
|
-
return cloned;
|
|
334
|
-
}
|
|
335
|
-
function cloneSchemas(schemas) {
|
|
336
|
-
if (!schemas) {
|
|
337
|
-
return undefined;
|
|
338
|
-
}
|
|
339
|
-
return Object.fromEntries(Object.entries(schemas).map(([name, schemaValue]) => [name, cloneSchema(schemaValue)]));
|
|
340
|
-
}
|
|
341
|
-
function cloneContractExports(contractExports) {
|
|
342
|
-
if (!contractExports) {
|
|
343
|
-
return undefined;
|
|
344
|
-
}
|
|
345
|
-
return {
|
|
346
|
-
...(contractExports.schemas
|
|
347
|
-
? { schemas: [...contractExports.schemas] }
|
|
348
|
-
: {}),
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
function getErrorRuntimeSchema(errorDecl) {
|
|
352
|
-
const errorClass = getContractErrorRuntimeClass(errorDecl);
|
|
353
|
-
const runtimeSchema = errorClass
|
|
354
|
-
? Reflect.get(errorClass, "schema")
|
|
355
|
-
: undefined;
|
|
356
|
-
if (!runtimeSchema || typeof runtimeSchema !== "object") {
|
|
357
|
-
return undefined;
|
|
358
|
-
}
|
|
359
|
-
return runtimeSchema;
|
|
360
|
-
}
|
|
361
|
-
function createContractErrorDecl(errorClass) {
|
|
362
|
-
const errorDecl = {
|
|
363
|
-
type: getContractErrorType(errorClass),
|
|
364
|
-
};
|
|
365
|
-
return attachContractErrorRuntimeMetadata(errorDecl, errorClass);
|
|
366
|
-
}
|
|
367
|
-
function normalizeErrorRegistry(errors) {
|
|
368
|
-
if (!errors) {
|
|
369
|
-
return undefined;
|
|
370
|
-
}
|
|
371
|
-
const normalizedEntries = Object.entries(errors).flatMap(([key, value]) => isErrorClass(value) ? [[key, createContractErrorDecl(value)]] : []);
|
|
372
|
-
if (normalizedEntries.length === 0) {
|
|
373
|
-
return undefined;
|
|
374
|
-
}
|
|
375
|
-
return Object.fromEntries(normalizedEntries);
|
|
376
|
-
}
|
|
377
|
-
function getErrorClassRegistry(errors) {
|
|
378
|
-
if (!errors) {
|
|
379
|
-
return undefined;
|
|
380
|
-
}
|
|
381
|
-
const classEntries = Object.entries(errors).flatMap(([key, value]) => isErrorClass(value) ? [[key, value]] : []);
|
|
382
|
-
if (classEntries.length === 0) {
|
|
383
|
-
return undefined;
|
|
384
|
-
}
|
|
385
|
-
return Object.fromEntries(classEntries);
|
|
386
|
-
}
|
|
387
|
-
function findMatchingSchemaName(schemas, targetSchema) {
|
|
388
|
-
if (!schemas) {
|
|
389
|
-
return undefined;
|
|
390
|
-
}
|
|
391
|
-
const targetDigest = digestCanonicalJson(cloneSchema(targetSchema));
|
|
392
|
-
for (const [schemaName, schemaValue] of Object.entries(schemas)) {
|
|
393
|
-
if (schemaValue === targetSchema) {
|
|
394
|
-
return schemaName;
|
|
395
|
-
}
|
|
396
|
-
if (digestCanonicalJson(cloneSchema(schemaValue)) === targetDigest) {
|
|
397
|
-
return schemaName;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return undefined;
|
|
401
|
-
}
|
|
402
|
-
function chooseDerivedErrorSchemaName(schemas, errorName, errorType) {
|
|
403
|
-
const baseNames = [`${errorType}Data`, `${errorName}Data`];
|
|
404
|
-
for (const baseName of baseNames) {
|
|
405
|
-
if (!Object.hasOwn(schemas, baseName)) {
|
|
406
|
-
return baseName;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
let suffix = 2;
|
|
410
|
-
while (true) {
|
|
411
|
-
const candidate = `${errorType}Data${suffix}`;
|
|
412
|
-
if (!Object.hasOwn(schemas, candidate)) {
|
|
413
|
-
return candidate;
|
|
414
|
-
}
|
|
415
|
-
suffix += 1;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
function materializeErrorSchemas(schemas, errors) {
|
|
419
|
-
if (!errors) {
|
|
420
|
-
return schemas;
|
|
421
|
-
}
|
|
422
|
-
let mergedSchemas = schemas;
|
|
423
|
-
for (const [errorName, errorDecl] of Object.entries(errors)) {
|
|
424
|
-
if (errorDecl.schema) {
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
const runtimeSchema = getErrorRuntimeSchema(errorDecl);
|
|
428
|
-
if (!runtimeSchema) {
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
if (findMatchingSchemaName(mergedSchemas, runtimeSchema)) {
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
mergedSchemas = { ...(mergedSchemas ?? {}) };
|
|
435
|
-
const derivedSchemaName = chooseDerivedErrorSchemaName(mergedSchemas, errorName, errorDecl.type);
|
|
436
|
-
mergedSchemas[derivedSchemaName] = runtimeSchema;
|
|
437
|
-
}
|
|
438
|
-
return mergedSchemas;
|
|
439
|
-
}
|
|
440
|
-
function assertSchemaRefExists(schemas, ref, context) {
|
|
441
|
-
if (!schemas || !Object.hasOwn(schemas, ref.schema)) {
|
|
442
|
-
throw new Error(`${context} references unknown schema '${ref.schema}'`);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function assertExportedSchemasExist(schemas, contractExports) {
|
|
446
|
-
for (const schemaName of contractExports?.schemas ?? []) {
|
|
447
|
-
if (!schemas || !Object.hasOwn(schemas, schemaName)) {
|
|
448
|
-
throw new Error(`contract exports reference unknown schema '${schemaName}'`);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function assertRegistryDoesNotDeclareExports(registry) {
|
|
453
|
-
if (Object.hasOwn(registry, "exports")) {
|
|
454
|
-
throw new Error("contract exports must be declared in the callback body, not the registry argument");
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function assertRegistryDoesNotDeclareCapabilities(registry) {
|
|
458
|
-
if (Object.hasOwn(registry, "capabilities")) {
|
|
459
|
-
throw new Error("contract capabilities must be declared in the callback body, not the registry argument");
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
function resolveSchemaRef(schemas, ref, context) {
|
|
463
|
-
assertSchemaRefExists(schemas, ref, context);
|
|
464
|
-
const schema = schemas?.[ref.schema];
|
|
465
|
-
if (!schema) {
|
|
466
|
-
throw new Error(`${context} references missing schema '${ref.schema}'`);
|
|
467
|
-
}
|
|
468
|
-
return cloneSchema(schema);
|
|
469
|
-
}
|
|
470
|
-
function digestCanonicalJson(value) {
|
|
471
|
-
return sha256Base64urlSync(canonicalizeJson(value));
|
|
472
|
-
}
|
|
473
|
-
function sortedUnique(values) {
|
|
474
|
-
return [...new Set(values)].sort();
|
|
475
|
-
}
|
|
476
|
-
/** Return the global capability namespace for a contract id. */
|
|
477
|
-
export function contractCapabilityNamespace(contractId) {
|
|
478
|
-
return contractId.replace(/@v\d+$/, "");
|
|
479
|
-
}
|
|
480
|
-
/** Return the globally qualified name for a contract-local capability. */
|
|
481
|
-
export function globalCapabilityName(contractId, localCapability) {
|
|
482
|
-
assertLocalCapabilityDoesNotDuplicateNamespace(contractId, localCapability);
|
|
483
|
-
return `${contractCapabilityNamespace(contractId)}::${localCapability}`;
|
|
484
|
-
}
|
|
485
|
-
function assertLocalCapabilityDoesNotDuplicateNamespace(contractId, localCapability) {
|
|
486
|
-
for (const prefix of localCapabilityNamespacePrefixes(contractId)) {
|
|
487
|
-
if (localCapability.startsWith(prefix)) {
|
|
488
|
-
throw new Error(`local capability '${localCapability}' must not start with contract namespace prefix '${prefix}'`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
function localCapabilityNamespacePrefixes(contractId) {
|
|
493
|
-
const namespace = contractCapabilityNamespace(contractId);
|
|
494
|
-
const prefixes = [`${namespace}.`];
|
|
495
|
-
const namespaceSegments = namespace.split(".");
|
|
496
|
-
const leaf = namespaceSegments[namespaceSegments.length - 1];
|
|
497
|
-
if (leaf && leaf !== namespace)
|
|
498
|
-
prefixes.push(`${leaf}.`);
|
|
499
|
-
return prefixes;
|
|
500
|
-
}
|
|
501
|
-
function projectCapabilities(capabilities, contractId, declaredCapabilities, context) {
|
|
502
|
-
if (!capabilities) {
|
|
503
|
-
return undefined;
|
|
504
|
-
}
|
|
505
|
-
return sortedUnique(capabilities.map((capability) => {
|
|
506
|
-
if (declaredCapabilities && Object.hasOwn(declaredCapabilities, capability)) {
|
|
507
|
-
return globalCapabilityName(contractId, capability);
|
|
508
|
-
}
|
|
509
|
-
if (capability === "admin" || capability === "service" ||
|
|
510
|
-
capability.includes("::")) {
|
|
511
|
-
return capability;
|
|
512
|
-
}
|
|
513
|
-
throw new Error(`${context} references undeclared local capability '${capability}'`);
|
|
514
|
-
}));
|
|
515
|
-
}
|
|
516
|
-
function emitCapabilities(contractId, capabilities) {
|
|
517
|
-
if (!capabilities) {
|
|
518
|
-
return undefined;
|
|
519
|
-
}
|
|
520
|
-
const entries = Object.entries(capabilities)
|
|
521
|
-
.map(([localCapability, metadata]) => [
|
|
522
|
-
globalCapabilityName(contractId, localCapability),
|
|
523
|
-
{ ...metadata },
|
|
524
|
-
]);
|
|
525
|
-
entries.sort(([left], [right]) => left.localeCompare(right));
|
|
526
|
-
return Object.fromEntries(entries);
|
|
527
|
-
}
|
|
528
|
-
function collectSchemaRef(reachableSchemas, ref) {
|
|
529
|
-
if (ref) {
|
|
530
|
-
reachableSchemas.add(ref.schema);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
function collectReachableSchemaNames(contract) {
|
|
534
|
-
const reachableSchemas = new Set();
|
|
535
|
-
for (const store of Object.values(contract.state ?? {})) {
|
|
536
|
-
collectSchemaRef(reachableSchemas, store.schema);
|
|
537
|
-
for (const accepted of Object.values(store.acceptedVersions ?? {})) {
|
|
538
|
-
collectSchemaRef(reachableSchemas, accepted);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
for (const method of Object.values(contract.rpc ?? {})) {
|
|
542
|
-
collectSchemaRef(reachableSchemas, method.input);
|
|
543
|
-
collectSchemaRef(reachableSchemas, method.output);
|
|
544
|
-
for (const error of method.errors ?? []) {
|
|
545
|
-
const declaration = Object.values(contract.errors ?? {}).find((decl) => decl.type === error.type);
|
|
546
|
-
collectSchemaRef(reachableSchemas, declaration?.schema);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
for (const operation of Object.values(contract.operations ?? {})) {
|
|
550
|
-
collectSchemaRef(reachableSchemas, operation.input);
|
|
551
|
-
collectSchemaRef(reachableSchemas, operation.progress);
|
|
552
|
-
collectSchemaRef(reachableSchemas, operation.output);
|
|
553
|
-
for (const signal of Object.values(operation.signals ?? {})) {
|
|
554
|
-
collectSchemaRef(reachableSchemas, signal.input);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
for (const event of Object.values(contract.events ?? {})) {
|
|
558
|
-
collectSchemaRef(reachableSchemas, event.event);
|
|
559
|
-
}
|
|
560
|
-
for (const feed of Object.values(contract.feeds ?? {})) {
|
|
561
|
-
collectSchemaRef(reachableSchemas, feed.input);
|
|
562
|
-
collectSchemaRef(reachableSchemas, feed.event);
|
|
563
|
-
}
|
|
564
|
-
for (const job of Object.values(contract.jobs ?? {})) {
|
|
565
|
-
collectSchemaRef(reachableSchemas, job.payload);
|
|
566
|
-
collectSchemaRef(reachableSchemas, job.result);
|
|
567
|
-
}
|
|
568
|
-
for (const resource of Object.values(contract.resources?.kv ?? {})) {
|
|
569
|
-
collectSchemaRef(reachableSchemas, resource.schema);
|
|
570
|
-
}
|
|
571
|
-
return reachableSchemas;
|
|
572
|
-
}
|
|
573
|
-
function projectReachableSchemas(contract) {
|
|
574
|
-
const reachableNames = collectReachableSchemaNames(contract);
|
|
575
|
-
if (!contract.schemas || reachableNames.size === 0) {
|
|
576
|
-
return undefined;
|
|
577
|
-
}
|
|
578
|
-
const entries = Object.entries(contract.schemas).filter(([name]) => reachableNames.has(name));
|
|
579
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
580
|
-
}
|
|
581
|
-
function projectRpcDeclaredErrors(contract) {
|
|
582
|
-
if (!contract.errors) {
|
|
583
|
-
return undefined;
|
|
584
|
-
}
|
|
585
|
-
const declaredErrorTypes = new Set();
|
|
586
|
-
for (const method of Object.values(contract.rpc ?? {})) {
|
|
587
|
-
for (const error of method.errors ?? []) {
|
|
588
|
-
declaredErrorTypes.add(error.type);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
const entries = Object.entries(contract.errors).filter(([, error]) => declaredErrorTypes.has(error.type));
|
|
592
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
593
|
-
}
|
|
594
|
-
function projectDigestResources(resources) {
|
|
595
|
-
if (!resources?.kv && !resources?.store) {
|
|
596
|
-
return undefined;
|
|
597
|
-
}
|
|
598
|
-
return {
|
|
599
|
-
...(resources.kv
|
|
600
|
-
? {
|
|
601
|
-
kv: mapValues(resources.kv, omitDocs),
|
|
602
|
-
}
|
|
603
|
-
: {}),
|
|
604
|
-
...(resources.store
|
|
605
|
-
? {
|
|
606
|
-
store: mapValues(resources.store, omitDocs),
|
|
607
|
-
}
|
|
608
|
-
: {}),
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
function projectDigestState(state) {
|
|
612
|
-
return state ? mapValues(state, omitDocs) : undefined;
|
|
613
|
-
}
|
|
614
|
-
function projectDigestJobs(jobs) {
|
|
615
|
-
return jobs ? mapValues(jobs, omitDocs) : undefined;
|
|
616
|
-
}
|
|
617
|
-
function projectDigestEventConsumers(eventConsumers) {
|
|
618
|
-
return eventConsumers ? mapValues(eventConsumers, omitDocs) : undefined;
|
|
619
|
-
}
|
|
620
|
-
function projectDigestUsesFlat(uses) {
|
|
621
|
-
if (!uses) {
|
|
622
|
-
return undefined;
|
|
623
|
-
}
|
|
624
|
-
return Object.fromEntries(Object.entries(uses).map(([alias, use]) => [
|
|
625
|
-
alias,
|
|
626
|
-
{
|
|
627
|
-
contract: use.contract,
|
|
628
|
-
...(use.rpc?.call ? { rpc: { call: sortedUnique(use.rpc.call) } } : {}),
|
|
629
|
-
...(use.operations?.call
|
|
630
|
-
? { operations: { call: sortedUnique(use.operations.call) } }
|
|
631
|
-
: {}),
|
|
632
|
-
...((use.events?.publish || use.events?.subscribe)
|
|
633
|
-
? {
|
|
634
|
-
events: {
|
|
635
|
-
...(use.events.publish
|
|
636
|
-
? { publish: sortedUnique(use.events.publish) }
|
|
637
|
-
: {}),
|
|
638
|
-
...(use.events.subscribe
|
|
639
|
-
? { subscribe: sortedUnique(use.events.subscribe) }
|
|
640
|
-
: {}),
|
|
641
|
-
},
|
|
642
|
-
}
|
|
643
|
-
: {}),
|
|
644
|
-
...(use.feeds?.subscribe
|
|
645
|
-
? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
|
|
646
|
-
: {}),
|
|
647
|
-
},
|
|
648
|
-
]));
|
|
649
|
-
}
|
|
650
|
-
function omitRequiredUseAliases(optional, required) {
|
|
651
|
-
if (!optional) {
|
|
652
|
-
return undefined;
|
|
653
|
-
}
|
|
654
|
-
if (!required) {
|
|
655
|
-
return optional;
|
|
656
|
-
}
|
|
657
|
-
const requiredAliases = new Set(Object.keys(required));
|
|
658
|
-
const entries = Object.entries(optional).filter(([alias]) => !requiredAliases.has(alias));
|
|
659
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
660
|
-
}
|
|
661
|
-
function projectDigestUses(uses) {
|
|
662
|
-
if (!uses) {
|
|
663
|
-
return undefined;
|
|
664
|
-
}
|
|
665
|
-
const required = projectDigestUsesFlat(uses.required);
|
|
666
|
-
const optional = omitRequiredUseAliases(projectDigestUsesFlat(uses.optional), required);
|
|
667
|
-
if (!required && !optional) {
|
|
668
|
-
return undefined;
|
|
669
|
-
}
|
|
670
|
-
return {
|
|
671
|
-
...(required ? { required } : {}),
|
|
672
|
-
...(optional ? { optional } : {}),
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
function projectDigestRpc(rpc) {
|
|
676
|
-
if (!rpc) {
|
|
677
|
-
return undefined;
|
|
678
|
-
}
|
|
679
|
-
return Object.fromEntries(Object.entries(rpc).map(([name, method]) => {
|
|
680
|
-
const projected = omitDocs(method);
|
|
681
|
-
return [
|
|
682
|
-
name,
|
|
683
|
-
{
|
|
684
|
-
...projected,
|
|
685
|
-
...(method.capabilities?.call
|
|
686
|
-
? { capabilities: { call: sortedUnique(method.capabilities.call) } }
|
|
687
|
-
: {}),
|
|
688
|
-
...(method.errors
|
|
689
|
-
? {
|
|
690
|
-
errors: sortedUnique(method.errors.map((error) => error.type))
|
|
691
|
-
.map((type) => ({ type })),
|
|
692
|
-
}
|
|
693
|
-
: {}),
|
|
694
|
-
},
|
|
695
|
-
];
|
|
696
|
-
}));
|
|
697
|
-
}
|
|
698
|
-
function projectDigestOperations(operations) {
|
|
699
|
-
if (!operations) {
|
|
700
|
-
return undefined;
|
|
701
|
-
}
|
|
702
|
-
return Object.fromEntries(Object.entries(operations).map(([name, operation]) => {
|
|
703
|
-
const projected = omitDocs(operation);
|
|
704
|
-
return [
|
|
705
|
-
name,
|
|
706
|
-
{
|
|
707
|
-
...projected,
|
|
708
|
-
...(operation.signals
|
|
709
|
-
? {
|
|
710
|
-
signals: mapValues(operation.signals, omitDocs),
|
|
711
|
-
}
|
|
712
|
-
: {}),
|
|
713
|
-
...((operation.capabilities?.call ||
|
|
714
|
-
operation.capabilities?.observe ||
|
|
715
|
-
operation.capabilities?.cancel || operation.capabilities?.control)
|
|
716
|
-
? {
|
|
717
|
-
capabilities: {
|
|
718
|
-
...(operation.capabilities.call
|
|
719
|
-
? { call: sortedUnique(operation.capabilities.call) }
|
|
720
|
-
: {}),
|
|
721
|
-
...(operation.capabilities.observe
|
|
722
|
-
? { observe: sortedUnique(operation.capabilities.observe) }
|
|
723
|
-
: {}),
|
|
724
|
-
...(operation.capabilities.cancel
|
|
725
|
-
? { cancel: sortedUnique(operation.capabilities.cancel) }
|
|
726
|
-
: {}),
|
|
727
|
-
...(operation.capabilities.control
|
|
728
|
-
? { control: sortedUnique(operation.capabilities.control) }
|
|
729
|
-
: {}),
|
|
730
|
-
},
|
|
731
|
-
}
|
|
732
|
-
: {}),
|
|
733
|
-
},
|
|
734
|
-
];
|
|
735
|
-
}));
|
|
736
|
-
}
|
|
737
|
-
function projectDigestEvents(events) {
|
|
738
|
-
if (!events) {
|
|
739
|
-
return undefined;
|
|
740
|
-
}
|
|
741
|
-
return Object.fromEntries(Object.entries(events).map(([name, event]) => {
|
|
742
|
-
const projected = omitDocs(event);
|
|
743
|
-
return [
|
|
744
|
-
name,
|
|
745
|
-
{
|
|
746
|
-
...projected,
|
|
747
|
-
...((event.capabilities?.publish || event.capabilities?.subscribe)
|
|
748
|
-
? {
|
|
749
|
-
capabilities: {
|
|
750
|
-
...(event.capabilities.publish
|
|
751
|
-
? { publish: sortedUnique(event.capabilities.publish) }
|
|
752
|
-
: {}),
|
|
753
|
-
...(event.capabilities.subscribe
|
|
754
|
-
? { subscribe: sortedUnique(event.capabilities.subscribe) }
|
|
755
|
-
: {}),
|
|
756
|
-
},
|
|
757
|
-
}
|
|
758
|
-
: {}),
|
|
759
|
-
},
|
|
760
|
-
];
|
|
761
|
-
}));
|
|
762
|
-
}
|
|
763
|
-
function projectDigestFeeds(feeds) {
|
|
764
|
-
if (!feeds) {
|
|
765
|
-
return undefined;
|
|
766
|
-
}
|
|
767
|
-
return Object.fromEntries(Object.entries(feeds).map(([name, feed]) => {
|
|
768
|
-
const projected = omitDocs(feed);
|
|
769
|
-
return [
|
|
770
|
-
name,
|
|
771
|
-
{
|
|
772
|
-
...projected,
|
|
773
|
-
...(feed.capabilities?.subscribe
|
|
774
|
-
? {
|
|
775
|
-
capabilities: {
|
|
776
|
-
subscribe: sortedUnique(feed.capabilities.subscribe),
|
|
777
|
-
},
|
|
778
|
-
}
|
|
779
|
-
: {}),
|
|
780
|
-
},
|
|
781
|
-
];
|
|
782
|
-
}));
|
|
783
|
-
}
|
|
784
|
-
function mapValues(values, map) {
|
|
785
|
-
if (!values)
|
|
786
|
-
return undefined;
|
|
787
|
-
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, map(value)]));
|
|
788
|
-
}
|
|
789
|
-
function omitDocs(value) {
|
|
790
|
-
const projected = { ...value };
|
|
791
|
-
delete projected.docs;
|
|
792
|
-
return projected;
|
|
793
|
-
}
|
|
794
|
-
function contractDocs(docs) {
|
|
795
|
-
if (!docs)
|
|
796
|
-
return undefined;
|
|
797
|
-
return {
|
|
798
|
-
...(docs.summary !== undefined ? { summary: docs.summary } : {}),
|
|
799
|
-
markdown: docs.markdown,
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function schemaRef(ref) {
|
|
803
|
-
return { schema: ref.schema };
|
|
804
|
-
}
|
|
805
|
-
function capabilityMetadata(metadata) {
|
|
806
|
-
return {
|
|
807
|
-
displayName: metadata.displayName,
|
|
808
|
-
description: metadata.description,
|
|
809
|
-
...(metadata.consequence ? { consequence: metadata.consequence } : {}),
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
function useRpc(use) {
|
|
813
|
-
if (!use)
|
|
814
|
-
return undefined;
|
|
815
|
-
return {
|
|
816
|
-
...(use.call ? { call: [...use.call] } : {}),
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function usePubSub(use) {
|
|
820
|
-
if (!use)
|
|
821
|
-
return undefined;
|
|
822
|
-
return {
|
|
823
|
-
...(use.publish ? { publish: [...use.publish] } : {}),
|
|
824
|
-
...(use.subscribe ? { subscribe: [...use.subscribe] } : {}),
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
function contractUse(use) {
|
|
828
|
-
return {
|
|
829
|
-
contract: use.contract,
|
|
830
|
-
...(use.rpc ? { rpc: useRpc(use.rpc) } : {}),
|
|
831
|
-
...(use.operations ? { operations: useRpc(use.operations) } : {}),
|
|
832
|
-
...(use.events ? { events: usePubSub(use.events) } : {}),
|
|
833
|
-
...(use.feeds
|
|
834
|
-
? {
|
|
835
|
-
feeds: {
|
|
836
|
-
...(use.feeds.subscribe
|
|
837
|
-
? { subscribe: [...use.feeds.subscribe] }
|
|
838
|
-
: {}),
|
|
839
|
-
},
|
|
840
|
-
}
|
|
841
|
-
: {}),
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
function contractUses(uses) {
|
|
845
|
-
if (!uses)
|
|
846
|
-
return undefined;
|
|
847
|
-
return {
|
|
848
|
-
...(uses.required
|
|
849
|
-
? { required: mapValues(uses.required, contractUse) }
|
|
850
|
-
: {}),
|
|
851
|
-
...(uses.optional
|
|
852
|
-
? { optional: mapValues(uses.optional, contractUse) }
|
|
853
|
-
: {}),
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
function stateStore(store) {
|
|
857
|
-
return {
|
|
858
|
-
kind: store.kind,
|
|
859
|
-
schema: schemaRef(store.schema),
|
|
860
|
-
...(store.stateVersion ? { stateVersion: store.stateVersion } : {}),
|
|
861
|
-
...(store.acceptedVersions
|
|
862
|
-
? { acceptedVersions: mapValues(store.acceptedVersions, schemaRef) }
|
|
863
|
-
: {}),
|
|
864
|
-
...(store.docs ? { docs: contractDocs(store.docs) } : {}),
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
function rpcMethod(method) {
|
|
868
|
-
return {
|
|
869
|
-
version: method.version,
|
|
870
|
-
subject: method.subject,
|
|
871
|
-
input: schemaRef(method.input),
|
|
872
|
-
output: schemaRef(method.output),
|
|
873
|
-
...(method.transfer
|
|
874
|
-
? { transfer: { direction: method.transfer.direction } }
|
|
875
|
-
: {}),
|
|
876
|
-
...(method.capabilities?.call
|
|
877
|
-
? { capabilities: { call: [...method.capabilities.call] } }
|
|
878
|
-
: {}),
|
|
879
|
-
...(method.errors
|
|
880
|
-
? { errors: method.errors.map((error) => ({ type: error.type })) }
|
|
881
|
-
: {}),
|
|
882
|
-
...(method.docs ? { docs: contractDocs(method.docs) } : {}),
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
function operation(operation) {
|
|
886
|
-
return {
|
|
887
|
-
version: operation.version,
|
|
888
|
-
subject: operation.subject,
|
|
889
|
-
input: schemaRef(operation.input),
|
|
890
|
-
...(operation.progress ? { progress: schemaRef(operation.progress) } : {}),
|
|
891
|
-
output: schemaRef(operation.output),
|
|
892
|
-
...(operation.transfer
|
|
893
|
-
? {
|
|
894
|
-
transfer: {
|
|
895
|
-
direction: operation.transfer.direction,
|
|
896
|
-
store: operation.transfer.store,
|
|
897
|
-
key: operation.transfer.key,
|
|
898
|
-
...(operation.transfer.contentType
|
|
899
|
-
? { contentType: operation.transfer.contentType }
|
|
900
|
-
: {}),
|
|
901
|
-
...(operation.transfer.metadata
|
|
902
|
-
? { metadata: operation.transfer.metadata }
|
|
903
|
-
: {}),
|
|
904
|
-
...(operation.transfer.expiresInMs !== undefined
|
|
905
|
-
? { expiresInMs: operation.transfer.expiresInMs }
|
|
906
|
-
: {}),
|
|
907
|
-
...(operation.transfer.maxBytes !== undefined
|
|
908
|
-
? { maxBytes: operation.transfer.maxBytes }
|
|
909
|
-
: {}),
|
|
910
|
-
},
|
|
911
|
-
}
|
|
912
|
-
: {}),
|
|
913
|
-
...(operation.capabilities
|
|
914
|
-
? {
|
|
915
|
-
capabilities: {
|
|
916
|
-
...(operation.capabilities.call
|
|
917
|
-
? { call: [...operation.capabilities.call] }
|
|
918
|
-
: {}),
|
|
919
|
-
...(operation.capabilities.observe
|
|
920
|
-
? { observe: [...operation.capabilities.observe] }
|
|
921
|
-
: {}),
|
|
922
|
-
...(operation.capabilities.cancel
|
|
923
|
-
? { cancel: [...operation.capabilities.cancel] }
|
|
924
|
-
: {}),
|
|
925
|
-
...(operation.capabilities.control
|
|
926
|
-
? { control: [...operation.capabilities.control] }
|
|
927
|
-
: {}),
|
|
928
|
-
},
|
|
929
|
-
}
|
|
930
|
-
: {}),
|
|
931
|
-
...(operation.signals
|
|
932
|
-
? {
|
|
933
|
-
signals: mapValues(operation.signals, (signal) => ({
|
|
934
|
-
input: schemaRef(signal.input),
|
|
935
|
-
...(signal.docs ? { docs: contractDocs(signal.docs) } : {}),
|
|
936
|
-
})),
|
|
937
|
-
}
|
|
938
|
-
: {}),
|
|
939
|
-
...(operation.cancel !== undefined ? { cancel: operation.cancel } : {}),
|
|
940
|
-
...(operation.docs ? { docs: contractDocs(operation.docs) } : {}),
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function event(event) {
|
|
944
|
-
return {
|
|
945
|
-
version: event.version,
|
|
946
|
-
subject: event.subject,
|
|
947
|
-
...(event.params ? { params: [...event.params] } : {}),
|
|
948
|
-
event: schemaRef(event.event),
|
|
949
|
-
...(event.capabilities
|
|
950
|
-
? {
|
|
951
|
-
capabilities: {
|
|
952
|
-
...(event.capabilities.publish
|
|
953
|
-
? { publish: [...event.capabilities.publish] }
|
|
954
|
-
: {}),
|
|
955
|
-
...(event.capabilities.subscribe
|
|
956
|
-
? { subscribe: [...event.capabilities.subscribe] }
|
|
957
|
-
: {}),
|
|
958
|
-
},
|
|
959
|
-
}
|
|
960
|
-
: {}),
|
|
961
|
-
...(event.docs ? { docs: contractDocs(event.docs) } : {}),
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
function feed(feed) {
|
|
965
|
-
return {
|
|
966
|
-
version: feed.version,
|
|
967
|
-
subject: feed.subject,
|
|
968
|
-
input: schemaRef(feed.input),
|
|
969
|
-
event: schemaRef(feed.event),
|
|
970
|
-
...(feed.capabilities?.subscribe
|
|
971
|
-
? { capabilities: { subscribe: [...feed.capabilities.subscribe] } }
|
|
972
|
-
: {}),
|
|
973
|
-
...(feed.docs ? { docs: contractDocs(feed.docs) } : {}),
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
function eventConsumerEvent(event) {
|
|
977
|
-
return { use: event.use, event: event.event };
|
|
978
|
-
}
|
|
979
|
-
function sortEventConsumerEvents(events) {
|
|
980
|
-
return events.map(eventConsumerEvent).sort((left, right) => left.use.localeCompare(right.use) || left.event.localeCompare(right.event));
|
|
981
|
-
}
|
|
982
|
-
function eventConsumerGroup(group) {
|
|
983
|
-
return {
|
|
984
|
-
events: sortEventConsumerEvents(group.events),
|
|
985
|
-
replay: group.replay ?? "new",
|
|
986
|
-
ordering: group.ordering ?? "strict",
|
|
987
|
-
concurrency: group.concurrency ?? 1,
|
|
988
|
-
...(group.ackWaitMs !== undefined ? { ackWaitMs: group.ackWaitMs } : {}),
|
|
989
|
-
...(group.maxDeliver !== undefined ? { maxDeliver: group.maxDeliver } : {}),
|
|
990
|
-
...(group.backoffMs ? { backoffMs: [...group.backoffMs] } : {}),
|
|
991
|
-
...(group.docs ? { docs: contractDocs(group.docs) } : {}),
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
function errorDecl(error) {
|
|
995
|
-
return {
|
|
996
|
-
type: error.type,
|
|
997
|
-
...(error.schema ? { schema: schemaRef(error.schema) } : {}),
|
|
998
|
-
};
|
|
999
|
-
}
|
|
1000
|
-
function jobQueue(queue) {
|
|
1001
|
-
return {
|
|
1002
|
-
payload: schemaRef(queue.payload),
|
|
1003
|
-
...(queue.result ? { result: schemaRef(queue.result) } : {}),
|
|
1004
|
-
...(queue.maxDeliver !== undefined ? { maxDeliver: queue.maxDeliver } : {}),
|
|
1005
|
-
...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
|
|
1006
|
-
...(queue.ackWaitMs !== undefined ? { ackWaitMs: queue.ackWaitMs } : {}),
|
|
1007
|
-
...(queue.defaultDeadlineMs !== undefined
|
|
1008
|
-
? { defaultDeadlineMs: queue.defaultDeadlineMs }
|
|
1009
|
-
: {}),
|
|
1010
|
-
...(queue.progress !== undefined ? { progress: queue.progress } : {}),
|
|
1011
|
-
...(queue.logs !== undefined ? { logs: queue.logs } : {}),
|
|
1012
|
-
...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
|
|
1013
|
-
...(queue.concurrency !== undefined
|
|
1014
|
-
? { concurrency: queue.concurrency }
|
|
1015
|
-
: {}),
|
|
1016
|
-
...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
function kvResource(resource) {
|
|
1020
|
-
return {
|
|
1021
|
-
purpose: resource.purpose,
|
|
1022
|
-
schema: schemaRef(resource.schema),
|
|
1023
|
-
...(resource.required !== undefined ? { required: resource.required } : {}),
|
|
1024
|
-
...(resource.history !== undefined ? { history: resource.history } : {}),
|
|
1025
|
-
...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
|
|
1026
|
-
...(resource.maxValueBytes !== undefined
|
|
1027
|
-
? { maxValueBytes: resource.maxValueBytes }
|
|
1028
|
-
: {}),
|
|
1029
|
-
...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
function storeResource(resource) {
|
|
1033
|
-
return {
|
|
1034
|
-
purpose: resource.purpose,
|
|
1035
|
-
...(resource.required !== undefined ? { required: resource.required } : {}),
|
|
1036
|
-
...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
|
|
1037
|
-
...(resource.maxObjectBytes !== undefined
|
|
1038
|
-
? { maxObjectBytes: resource.maxObjectBytes }
|
|
1039
|
-
: {}),
|
|
1040
|
-
...(resource.maxTotalBytes !== undefined
|
|
1041
|
-
? { maxTotalBytes: resource.maxTotalBytes }
|
|
1042
|
-
: {}),
|
|
1043
|
-
...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
/**
|
|
1047
|
-
* Return the canonical manifest shape used by Trellis runtimes before
|
|
1048
|
-
* validation, persistence, and digesting.
|
|
1049
|
-
*
|
|
1050
|
-
* This is not the digest projection: human-facing fields such as
|
|
1051
|
-
* `displayName` and `description` are preserved here even though they are not
|
|
1052
|
-
* part of contract identity. Unknown extension fields are intentionally omitted
|
|
1053
|
-
* until the runtime explicitly supports them.
|
|
1054
|
-
*/
|
|
1055
|
-
export function normalizeContractManifest(contract) {
|
|
1056
|
-
return {
|
|
1057
|
-
format: contract.format,
|
|
1058
|
-
id: contract.id,
|
|
1059
|
-
displayName: contract.displayName,
|
|
1060
|
-
description: contract.description,
|
|
1061
|
-
...(contract.docs ? { docs: contractDocs(contract.docs) } : {}),
|
|
1062
|
-
kind: contract.kind,
|
|
1063
|
-
...(contract.capabilities
|
|
1064
|
-
? { capabilities: mapValues(contract.capabilities, capabilityMetadata) }
|
|
1065
|
-
: {}),
|
|
1066
|
-
...(contract.schemas ? { schemas: contract.schemas } : {}),
|
|
1067
|
-
...(contract.exports
|
|
1068
|
-
? {
|
|
1069
|
-
exports: {
|
|
1070
|
-
...(contract.exports.schemas
|
|
1071
|
-
? { schemas: [...contract.exports.schemas] }
|
|
1072
|
-
: {}),
|
|
1073
|
-
},
|
|
1074
|
-
}
|
|
1075
|
-
: {}),
|
|
1076
|
-
...(contract.uses ? { uses: contractUses(contract.uses) } : {}),
|
|
1077
|
-
...(contract.state ? { state: mapValues(contract.state, stateStore) } : {}),
|
|
1078
|
-
...(contract.rpc ? { rpc: mapValues(contract.rpc, rpcMethod) } : {}),
|
|
1079
|
-
...(contract.operations
|
|
1080
|
-
? { operations: mapValues(contract.operations, operation) }
|
|
1081
|
-
: {}),
|
|
1082
|
-
...(contract.events ? { events: mapValues(contract.events, event) } : {}),
|
|
1083
|
-
...(contract.feeds ? { feeds: mapValues(contract.feeds, feed) } : {}),
|
|
1084
|
-
...(contract.jobs ? { jobs: mapValues(contract.jobs, jobQueue) } : {}),
|
|
1085
|
-
...(contract.eventConsumers
|
|
1086
|
-
? {
|
|
1087
|
-
eventConsumers: mapValues(contract.eventConsumers, eventConsumerGroup),
|
|
1088
|
-
}
|
|
1089
|
-
: {}),
|
|
1090
|
-
...(contract.resources
|
|
1091
|
-
? {
|
|
1092
|
-
resources: {
|
|
1093
|
-
...(contract.resources.kv
|
|
1094
|
-
? { kv: mapValues(contract.resources.kv, kvResource) }
|
|
1095
|
-
: {}),
|
|
1096
|
-
...(contract.resources.store
|
|
1097
|
-
? { store: mapValues(contract.resources.store, storeResource) }
|
|
1098
|
-
: {}),
|
|
1099
|
-
},
|
|
1100
|
-
}
|
|
1101
|
-
: {}),
|
|
1102
|
-
...(contract.errors
|
|
1103
|
-
? { errors: mapValues(contract.errors, errorDecl) }
|
|
1104
|
-
: {}),
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Parse untrusted contract JSON into the current Trellis v1 manifest shape.
|
|
1109
|
-
*
|
|
1110
|
-
* Unknown extension fields are accepted for forward compatibility but are not
|
|
1111
|
-
* returned. Callers must use the returned value for persistence and digesting.
|
|
1112
|
-
*/
|
|
1113
|
-
export function parseContractManifest(value) {
|
|
1114
|
-
let parsed;
|
|
1115
|
-
try {
|
|
1116
|
-
parsed = Value.Parse(TrellisContractV1Schema, value);
|
|
1117
|
-
}
|
|
1118
|
-
catch (error) {
|
|
1119
|
-
const details = [...Value.Errors(TrellisContractV1Schema, value)].map((entry) => `${entry.instancePath || "#"}: ${entry.message}`);
|
|
1120
|
-
throw new TypeError(`Invalid contract${details.length > 0 ? `:\n${details.join("\n")}` : ""}`, { cause: error });
|
|
1121
|
-
}
|
|
1122
|
-
const contract = normalizeContractManifest(parsed);
|
|
1123
|
-
assertValidEventConsumers(contract.eventConsumers, contract.uses);
|
|
1124
|
-
return contract;
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* Build the normalized runtime/interface projection used for contract identity.
|
|
1128
|
-
*/
|
|
1129
|
-
export function projectContractDigestManifest(contract) {
|
|
1130
|
-
const schemas = projectReachableSchemas(contract);
|
|
1131
|
-
const errors = projectRpcDeclaredErrors(contract);
|
|
1132
|
-
const state = projectDigestState(contract.state);
|
|
1133
|
-
const resources = projectDigestResources(contract.resources);
|
|
1134
|
-
const jobs = projectDigestJobs(contract.jobs);
|
|
1135
|
-
const eventConsumers = projectDigestEventConsumers(contract.eventConsumers);
|
|
1136
|
-
const uses = projectDigestUses(contract.uses);
|
|
1137
|
-
const rpc = projectDigestRpc(contract.rpc);
|
|
1138
|
-
const operations = projectDigestOperations(contract.operations);
|
|
1139
|
-
const events = projectDigestEvents(contract.events);
|
|
1140
|
-
const feeds = projectDigestFeeds(contract.feeds);
|
|
1141
|
-
return {
|
|
1142
|
-
format: contract.format,
|
|
1143
|
-
id: contract.id,
|
|
1144
|
-
kind: contract.kind,
|
|
1145
|
-
...(contract.capabilities ? { capabilities: contract.capabilities } : {}),
|
|
1146
|
-
...(schemas ? { schemas } : {}),
|
|
1147
|
-
...(state ? { state } : {}),
|
|
1148
|
-
...(uses ? { uses } : {}),
|
|
1149
|
-
...(rpc ? { rpc } : {}),
|
|
1150
|
-
...(operations ? { operations } : {}),
|
|
1151
|
-
...(events ? { events } : {}),
|
|
1152
|
-
...(feeds ? { feeds } : {}),
|
|
1153
|
-
...(errors ? { errors } : {}),
|
|
1154
|
-
...(jobs ? { jobs } : {}),
|
|
1155
|
-
...(eventConsumers ? { eventConsumers } : {}),
|
|
1156
|
-
...(resources ? { resources } : {}),
|
|
1157
|
-
};
|
|
1158
|
-
}
|
|
1159
|
-
/** Compute the v1 contract digest from the normalized digest projection. */
|
|
1160
|
-
export function digestContractManifest(contract) {
|
|
1161
|
-
return digestCanonicalJson(projectContractDigestManifest(normalizeContractManifest(contract)));
|
|
1162
|
-
}
|
|
1163
|
-
function rpcSubject(name, version) {
|
|
1164
|
-
return `rpc.${version}.${name}`;
|
|
1165
|
-
}
|
|
1166
|
-
function operationSubject(name, version) {
|
|
1167
|
-
return `operations.${version}.${name}`;
|
|
1168
|
-
}
|
|
1169
|
-
function feedSubject(name, version) {
|
|
1170
|
-
return `feeds.${version}.${name}`;
|
|
1171
|
-
}
|
|
1172
|
-
function eventSubject(name, version, params) {
|
|
1173
|
-
const suffix = params && params.length > 0
|
|
1174
|
-
? `.${params.map((pointer) => `{${pointer}}`).join(".")}`
|
|
1175
|
-
: "";
|
|
1176
|
-
return `events.${version}.${name}${suffix}`;
|
|
1177
|
-
}
|
|
1178
|
-
function emitResources(resources) {
|
|
1179
|
-
if (!resources?.kv && !resources?.store) {
|
|
1180
|
-
return undefined;
|
|
1181
|
-
}
|
|
1182
|
-
return {
|
|
1183
|
-
...(resources.kv
|
|
1184
|
-
? {
|
|
1185
|
-
kv: Object.fromEntries(Object.entries(resources.kv).map(([alias, resource]) => [
|
|
1186
|
-
alias,
|
|
1187
|
-
{
|
|
1188
|
-
purpose: resource.purpose,
|
|
1189
|
-
schema: { ...resource.schema },
|
|
1190
|
-
required: resource.required ?? true,
|
|
1191
|
-
history: resource.history ?? 1,
|
|
1192
|
-
ttlMs: resource.ttlMs ?? 0,
|
|
1193
|
-
...(resource.maxValueBytes
|
|
1194
|
-
? { maxValueBytes: resource.maxValueBytes }
|
|
1195
|
-
: {}),
|
|
1196
|
-
...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
|
|
1197
|
-
},
|
|
1198
|
-
])),
|
|
1199
|
-
}
|
|
1200
|
-
: {}),
|
|
1201
|
-
...(resources.store
|
|
1202
|
-
? {
|
|
1203
|
-
store: Object.fromEntries(Object.entries(resources.store).map(([alias, resource]) => [
|
|
1204
|
-
alias,
|
|
1205
|
-
{
|
|
1206
|
-
purpose: resource.purpose,
|
|
1207
|
-
required: resource.required ?? true,
|
|
1208
|
-
ttlMs: resource.ttlMs ?? 0,
|
|
1209
|
-
...(resource.maxObjectBytes !== undefined
|
|
1210
|
-
? { maxObjectBytes: resource.maxObjectBytes }
|
|
1211
|
-
: {}),
|
|
1212
|
-
...(resource.maxTotalBytes !== undefined
|
|
1213
|
-
? { maxTotalBytes: resource.maxTotalBytes }
|
|
1214
|
-
: {}),
|
|
1215
|
-
...(resource.docs ? { docs: contractDocs(resource.docs) } : {}),
|
|
1216
|
-
},
|
|
1217
|
-
])),
|
|
1218
|
-
}
|
|
1219
|
-
: {}),
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
function emitJobs(jobs) {
|
|
1223
|
-
if (!jobs) {
|
|
1224
|
-
return undefined;
|
|
1225
|
-
}
|
|
1226
|
-
return Object.fromEntries(Object.entries(jobs).map(([queueType, queue]) => [
|
|
1227
|
-
queueType,
|
|
1228
|
-
{
|
|
1229
|
-
payload: { ...queue.payload },
|
|
1230
|
-
...(queue.result ? { result: { ...queue.result } } : {}),
|
|
1231
|
-
...(queue.maxDeliver !== undefined
|
|
1232
|
-
? { maxDeliver: queue.maxDeliver }
|
|
1233
|
-
: {}),
|
|
1234
|
-
...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
|
|
1235
|
-
...(queue.ackWaitMs !== undefined
|
|
1236
|
-
? { ackWaitMs: queue.ackWaitMs }
|
|
1237
|
-
: {}),
|
|
1238
|
-
...(queue.defaultDeadlineMs !== undefined
|
|
1239
|
-
? { defaultDeadlineMs: queue.defaultDeadlineMs }
|
|
1240
|
-
: {}),
|
|
1241
|
-
...(queue.progress !== undefined ? { progress: queue.progress } : {}),
|
|
1242
|
-
...(queue.logs !== undefined ? { logs: queue.logs } : {}),
|
|
1243
|
-
...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
|
|
1244
|
-
...(queue.concurrency !== undefined
|
|
1245
|
-
? { concurrency: queue.concurrency }
|
|
1246
|
-
: {}),
|
|
1247
|
-
...(queue.docs ? { docs: contractDocs(queue.docs) } : {}),
|
|
1248
|
-
},
|
|
1249
|
-
]));
|
|
1250
|
-
}
|
|
1251
|
-
function emitEventConsumers(eventConsumers) {
|
|
1252
|
-
if (!eventConsumers) {
|
|
1253
|
-
return undefined;
|
|
1254
|
-
}
|
|
1255
|
-
return Object.fromEntries(Object.entries(eventConsumers).map(([groupName, group]) => [
|
|
1256
|
-
groupName,
|
|
1257
|
-
{
|
|
1258
|
-
events: sortEventConsumerEvents(group.events),
|
|
1259
|
-
replay: group.replay ?? "new",
|
|
1260
|
-
ordering: group.ordering ?? "strict",
|
|
1261
|
-
concurrency: group.concurrency ?? 1,
|
|
1262
|
-
...(group.ackWaitMs !== undefined
|
|
1263
|
-
? { ackWaitMs: group.ackWaitMs }
|
|
1264
|
-
: {}),
|
|
1265
|
-
...(group.maxDeliver !== undefined
|
|
1266
|
-
? { maxDeliver: group.maxDeliver }
|
|
1267
|
-
: {}),
|
|
1268
|
-
...(group.backoffMs ? { backoffMs: [...group.backoffMs] } : {}),
|
|
1269
|
-
...(group.docs ? { docs: contractDocs(group.docs) } : {}),
|
|
1270
|
-
},
|
|
1271
|
-
]));
|
|
1272
|
-
}
|
|
1273
|
-
function buildContractJobsMetadata(jobs) {
|
|
1274
|
-
if (!jobs) {
|
|
1275
|
-
return {};
|
|
1276
|
-
}
|
|
1277
|
-
return Object.fromEntries(Object.keys(jobs).map((queueType) => [queueType, {
|
|
1278
|
-
payload: undefined,
|
|
1279
|
-
result: undefined,
|
|
1280
|
-
}]));
|
|
1281
|
-
}
|
|
1282
|
-
function buildContractKvMetadata(resources, schemas) {
|
|
1283
|
-
const kv = resources?.kv;
|
|
1284
|
-
if (!kv) {
|
|
1285
|
-
return {};
|
|
1286
|
-
}
|
|
1287
|
-
const metadata = {};
|
|
1288
|
-
for (const [alias, resource] of Object.entries(kv)) {
|
|
1289
|
-
assertSchemaRefExists(schemas, resource.schema, `kv resource '${alias}'`);
|
|
1290
|
-
const schema = schemas?.[resource.schema.schema];
|
|
1291
|
-
if (!schema) {
|
|
1292
|
-
throw new Error(`kv resource '${alias}' references missing schema '${resource.schema.schema}'`);
|
|
1293
|
-
}
|
|
1294
|
-
metadata[alias] = {
|
|
1295
|
-
required: resource.required ?? true,
|
|
1296
|
-
value: undefined,
|
|
1297
|
-
schema,
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
return metadata;
|
|
1301
|
-
}
|
|
1302
|
-
function buildContractStateMetadata(state, schemas) {
|
|
1303
|
-
if (!state) {
|
|
1304
|
-
return {};
|
|
1305
|
-
}
|
|
1306
|
-
return Object.fromEntries(Object.entries(state).map(([storeName, store]) => [storeName, {
|
|
1307
|
-
kind: store.kind,
|
|
1308
|
-
value: undefined,
|
|
1309
|
-
schema: resolveSchemaRef(schemas, store.schema, `state store '${storeName}'`),
|
|
1310
|
-
stateVersion: store.stateVersion ?? "v1",
|
|
1311
|
-
acceptedVersions: Object.fromEntries(Object.entries(store.acceptedVersions ?? {}).map(([version, schema]) => [
|
|
1312
|
-
version,
|
|
1313
|
-
resolveSchemaRef(schemas, schema, `state store '${storeName}' accepted version '${version}'`),
|
|
1314
|
-
])),
|
|
1315
|
-
}]));
|
|
1316
|
-
}
|
|
1317
|
-
function emitState(state) {
|
|
1318
|
-
if (!state) {
|
|
1319
|
-
return undefined;
|
|
1320
|
-
}
|
|
1321
|
-
return Object.fromEntries(Object.entries(state).map(([storeName, store]) => [
|
|
1322
|
-
storeName,
|
|
1323
|
-
{
|
|
1324
|
-
kind: store.kind,
|
|
1325
|
-
schema: { ...store.schema },
|
|
1326
|
-
...(store.stateVersion === undefined
|
|
1327
|
-
? {}
|
|
1328
|
-
: { stateVersion: store.stateVersion }),
|
|
1329
|
-
...(store.acceptedVersions === undefined
|
|
1330
|
-
? {}
|
|
1331
|
-
: { acceptedVersions: store.acceptedVersions }),
|
|
1332
|
-
...(store.docs ? { docs: contractDocs(store.docs) } : {}),
|
|
1333
|
-
},
|
|
1334
|
-
]));
|
|
1335
|
-
}
|
|
1336
|
-
function emitUsesFlat(uses) {
|
|
1337
|
-
if (!uses) {
|
|
1338
|
-
return undefined;
|
|
1339
|
-
}
|
|
1340
|
-
return Object.fromEntries(Object.entries(uses).map(([alias, use]) => [
|
|
1341
|
-
alias,
|
|
1342
|
-
{
|
|
1343
|
-
contract: use.contract,
|
|
1344
|
-
...(use.rpc?.call ? { rpc: { call: sortedUnique(use.rpc.call) } } : {}),
|
|
1345
|
-
...(use.operations?.call
|
|
1346
|
-
? { operations: { call: sortedUnique(use.operations.call) } }
|
|
1347
|
-
: {}),
|
|
1348
|
-
...((use.events?.publish || use.events?.subscribe)
|
|
1349
|
-
? {
|
|
1350
|
-
events: {
|
|
1351
|
-
...(use.events.publish
|
|
1352
|
-
? { publish: sortedUnique(use.events.publish) }
|
|
1353
|
-
: {}),
|
|
1354
|
-
...(use.events.subscribe
|
|
1355
|
-
? { subscribe: sortedUnique(use.events.subscribe) }
|
|
1356
|
-
: {}),
|
|
1357
|
-
},
|
|
1358
|
-
}
|
|
1359
|
-
: {}),
|
|
1360
|
-
...(use.feeds?.subscribe
|
|
1361
|
-
? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
|
|
1362
|
-
: {}),
|
|
1363
|
-
},
|
|
1364
|
-
]));
|
|
1365
|
-
}
|
|
1366
|
-
function emitUses(uses) {
|
|
1367
|
-
if (!uses) {
|
|
1368
|
-
return undefined;
|
|
1369
|
-
}
|
|
1370
|
-
const required = emitUsesFlat(uses.required);
|
|
1371
|
-
const optional = omitRequiredUseAliases(emitUsesFlat(uses.optional), required);
|
|
1372
|
-
if (!required && !optional) {
|
|
1373
|
-
return undefined;
|
|
1374
|
-
}
|
|
1375
|
-
return {
|
|
1376
|
-
...(required ? { required } : {}),
|
|
1377
|
-
...(optional ? { optional } : {}),
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
function emitContract(source) {
|
|
1381
|
-
const capabilities = emitCapabilities(source.id, source.capabilities);
|
|
1382
|
-
const rpc = source.rpc
|
|
1383
|
-
? Object.fromEntries(Object.entries(source.rpc).map(([name, method]) => {
|
|
1384
|
-
const emitted = {
|
|
1385
|
-
version: method.version,
|
|
1386
|
-
subject: method.subject ?? rpcSubject(name, method.version),
|
|
1387
|
-
input: { ...method.input },
|
|
1388
|
-
output: { ...method.output },
|
|
1389
|
-
};
|
|
1390
|
-
if (method.capabilities?.call) {
|
|
1391
|
-
emitted.capabilities = {
|
|
1392
|
-
call: projectCapabilities(method.capabilities.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
if (method.transfer) {
|
|
1396
|
-
emitted.transfer = { ...method.transfer };
|
|
1397
|
-
}
|
|
1398
|
-
if (method.errors && method.errors.length > 0) {
|
|
1399
|
-
emitted.errors = sortedUnique(method.errors.map((errorName) => source.errors?.[errorName]?.type ?? errorName)).map((type) => ({ type }));
|
|
1400
|
-
}
|
|
1401
|
-
if (method.internal) {
|
|
1402
|
-
emitted.internal = true;
|
|
1403
|
-
}
|
|
1404
|
-
if (method.docs) {
|
|
1405
|
-
emitted.docs = contractDocs(method.docs);
|
|
1406
|
-
}
|
|
1407
|
-
return [name, emitted];
|
|
1408
|
-
}))
|
|
1409
|
-
: undefined;
|
|
1410
|
-
const operations = source.operations
|
|
1411
|
-
? Object.fromEntries(Object.entries(source.operations).map(([name, operation]) => {
|
|
1412
|
-
if (operation.transfer) {
|
|
1413
|
-
const store = source.resources?.store?.[operation.transfer.store];
|
|
1414
|
-
if (!store) {
|
|
1415
|
-
throw new Error(`Operation '${name}' references unknown store resource '${operation.transfer.store}'`);
|
|
1416
|
-
}
|
|
1417
|
-
const inputSchema = resolveSchemaRef(source.schemas, operation.input, `operation '${name}' input`);
|
|
1418
|
-
for (const pointer of [
|
|
1419
|
-
operation.transfer.key,
|
|
1420
|
-
operation.transfer.contentType,
|
|
1421
|
-
operation.transfer.metadata,
|
|
1422
|
-
]) {
|
|
1423
|
-
if (!pointer) {
|
|
1424
|
-
continue;
|
|
1425
|
-
}
|
|
1426
|
-
if (getSubschemaAtDataPointer(inputSchema, pointer) === undefined) {
|
|
1427
|
-
throw new Error(`Invalid transfer pointer '${pointer}' for operation '${name}' (path not found in input schema)`);
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
const emitted = {
|
|
1432
|
-
version: operation.version,
|
|
1433
|
-
subject: operation.subject ??
|
|
1434
|
-
operationSubject(name, operation.version),
|
|
1435
|
-
input: { ...operation.input },
|
|
1436
|
-
output: { ...operation.output },
|
|
1437
|
-
};
|
|
1438
|
-
if (operation.progress) {
|
|
1439
|
-
emitted.progress = { ...operation.progress };
|
|
1440
|
-
}
|
|
1441
|
-
if (operation.transfer) {
|
|
1442
|
-
emitted.transfer = { ...operation.transfer, direction: "send" };
|
|
1443
|
-
}
|
|
1444
|
-
if (operation.capabilities?.call || operation.capabilities?.observe ||
|
|
1445
|
-
operation.capabilities?.cancel || operation.capabilities?.control) {
|
|
1446
|
-
emitted.capabilities = {
|
|
1447
|
-
...(operation.capabilities.call
|
|
1448
|
-
? {
|
|
1449
|
-
call: projectCapabilities(operation.capabilities.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
|
|
1450
|
-
}
|
|
1451
|
-
: {}),
|
|
1452
|
-
...(operation.capabilities.observe
|
|
1453
|
-
? {
|
|
1454
|
-
observe: projectCapabilities(operation.capabilities.observe, source.id, source.capabilities, `operation '${name}' observe capabilities`) ?? [],
|
|
1455
|
-
}
|
|
1456
|
-
: {}),
|
|
1457
|
-
...(operation.capabilities.cancel
|
|
1458
|
-
? {
|
|
1459
|
-
cancel: projectCapabilities(operation.capabilities.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
|
|
1460
|
-
}
|
|
1461
|
-
: {}),
|
|
1462
|
-
...(operation.capabilities.control
|
|
1463
|
-
? {
|
|
1464
|
-
control: projectCapabilities(operation.capabilities.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
|
|
1465
|
-
}
|
|
1466
|
-
: {}),
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
if (operation.signals) {
|
|
1470
|
-
emitted.signals = Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
|
|
1471
|
-
signalName,
|
|
1472
|
-
{
|
|
1473
|
-
input: { ...signal.input },
|
|
1474
|
-
...(signal.docs ? { docs: contractDocs(signal.docs) } : {}),
|
|
1475
|
-
},
|
|
1476
|
-
]));
|
|
1477
|
-
}
|
|
1478
|
-
if (operation.cancel !== undefined) {
|
|
1479
|
-
emitted.cancel = operation.cancel;
|
|
1480
|
-
}
|
|
1481
|
-
if (operation.docs) {
|
|
1482
|
-
emitted.docs = contractDocs(operation.docs);
|
|
1483
|
-
}
|
|
1484
|
-
return [name, emitted];
|
|
1485
|
-
}))
|
|
1486
|
-
: undefined;
|
|
1487
|
-
const events = source.events
|
|
1488
|
-
? Object.fromEntries(Object.entries(source.events).map(([name, event]) => {
|
|
1489
|
-
if (event.params && event.params.length > 0) {
|
|
1490
|
-
assertDataPointersExistAndAreTokenable(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
|
|
1491
|
-
}
|
|
1492
|
-
const emitted = {
|
|
1493
|
-
version: event.version,
|
|
1494
|
-
subject: event.subject ??
|
|
1495
|
-
eventSubject(name, event.version, event.params),
|
|
1496
|
-
event: { ...event.event },
|
|
1497
|
-
};
|
|
1498
|
-
if (event.params && event.params.length > 0) {
|
|
1499
|
-
emitted.params = [...event.params];
|
|
1500
|
-
}
|
|
1501
|
-
if (event.capabilities?.publish || event.capabilities?.subscribe) {
|
|
1502
|
-
emitted.capabilities = {
|
|
1503
|
-
...(event.capabilities.publish
|
|
1504
|
-
? {
|
|
1505
|
-
publish: projectCapabilities(event.capabilities.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
|
|
1506
|
-
}
|
|
1507
|
-
: {}),
|
|
1508
|
-
...(event.capabilities.subscribe
|
|
1509
|
-
? {
|
|
1510
|
-
subscribe: projectCapabilities(event.capabilities.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
|
|
1511
|
-
}
|
|
1512
|
-
: {}),
|
|
1513
|
-
};
|
|
1514
|
-
}
|
|
1515
|
-
if (event.docs) {
|
|
1516
|
-
emitted.docs = contractDocs(event.docs);
|
|
1517
|
-
}
|
|
1518
|
-
return [name, emitted];
|
|
1519
|
-
}))
|
|
1520
|
-
: undefined;
|
|
1521
|
-
const feeds = source.feeds
|
|
1522
|
-
? Object.fromEntries(Object.entries(source.feeds).map(([name, feed]) => {
|
|
1523
|
-
const emitted = {
|
|
1524
|
-
version: feed.version,
|
|
1525
|
-
subject: feed.subject ?? feedSubject(name, feed.version),
|
|
1526
|
-
input: { ...feed.input },
|
|
1527
|
-
event: { ...feed.event },
|
|
1528
|
-
};
|
|
1529
|
-
if (feed.capabilities?.subscribe) {
|
|
1530
|
-
emitted.capabilities = {
|
|
1531
|
-
subscribe: projectCapabilities(feed.capabilities.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
if (feed.docs) {
|
|
1535
|
-
emitted.docs = contractDocs(feed.docs);
|
|
1536
|
-
}
|
|
1537
|
-
return [name, emitted];
|
|
1538
|
-
}))
|
|
1539
|
-
: undefined;
|
|
1540
|
-
const errors = source.errors
|
|
1541
|
-
? Object.fromEntries(Object.entries(source.errors).map(([name, error]) => {
|
|
1542
|
-
const emitted = { type: error.type };
|
|
1543
|
-
const schemaRef = resolveErrorSchemaRef(source.schemas, name, error);
|
|
1544
|
-
if (schemaRef) {
|
|
1545
|
-
emitted.schema = { ...schemaRef };
|
|
1546
|
-
}
|
|
1547
|
-
return [name, emitted];
|
|
1548
|
-
}))
|
|
1549
|
-
: undefined;
|
|
1550
|
-
const jobs = emitJobs(source.jobs);
|
|
1551
|
-
const eventConsumers = emitEventConsumers(source.eventConsumers);
|
|
1552
|
-
const state = emitState(source.state);
|
|
1553
|
-
const resources = emitResources(source.resources);
|
|
1554
|
-
const uses = emitUses(source.uses);
|
|
1555
|
-
assertValidEventConsumers(eventConsumers, uses);
|
|
1556
|
-
return {
|
|
1557
|
-
format: CONTRACT_FORMAT_V1,
|
|
1558
|
-
id: source.id,
|
|
1559
|
-
displayName: source.displayName,
|
|
1560
|
-
description: source.description,
|
|
1561
|
-
...(source.docs ? { docs: contractDocs(source.docs) } : {}),
|
|
1562
|
-
kind: source.kind,
|
|
1563
|
-
...(capabilities ? { capabilities } : {}),
|
|
1564
|
-
...(source.schemas ? { schemas: cloneSchemas(source.schemas) } : {}),
|
|
1565
|
-
...(source.exports
|
|
1566
|
-
? { exports: cloneContractExports(source.exports) }
|
|
1567
|
-
: {}),
|
|
1568
|
-
...(state ? { state } : {}),
|
|
1569
|
-
...(uses ? { uses } : {}),
|
|
1570
|
-
...(rpc ? { rpc } : {}),
|
|
1571
|
-
...(operations ? { operations } : {}),
|
|
1572
|
-
...(events ? { events } : {}),
|
|
1573
|
-
...(feeds ? { feeds } : {}),
|
|
1574
|
-
...(errors ? { errors } : {}),
|
|
1575
|
-
...(jobs ? { jobs } : {}),
|
|
1576
|
-
...(eventConsumers ? { eventConsumers } : {}),
|
|
1577
|
-
...(resources ? { resources } : {}),
|
|
1578
|
-
};
|
|
1579
|
-
}
|
|
1580
|
-
function buildOwnedApi(source) {
|
|
1581
|
-
const localRuntimeErrors = {};
|
|
1582
|
-
for (const [name, errorDecl] of Object.entries(source.errors ?? {})) {
|
|
1583
|
-
const errorClass = getContractErrorRuntimeClass(errorDecl);
|
|
1584
|
-
if (!errorClass) {
|
|
1585
|
-
continue;
|
|
1586
|
-
}
|
|
1587
|
-
const errorSchemaRef = resolveErrorSchemaRef(source.schemas, name, errorDecl);
|
|
1588
|
-
localRuntimeErrors[name] = {
|
|
1589
|
-
type: errorDecl.type,
|
|
1590
|
-
...(errorSchemaRef
|
|
1591
|
-
? {
|
|
1592
|
-
schema: schema(resolveSchemaRef(source.schemas, errorSchemaRef, `error '${name}' schema`)),
|
|
1593
|
-
}
|
|
1594
|
-
: {}),
|
|
1595
|
-
fromSerializable(data) {
|
|
1596
|
-
if (!isSerializableErrorData(data)) {
|
|
1597
|
-
throw new Error(`Transport error '${errorDecl.type}' is missing base error fields`);
|
|
1598
|
-
}
|
|
1599
|
-
return errorClass.fromSerializable(data);
|
|
1600
|
-
},
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
const rpc = {};
|
|
1604
|
-
for (const [name, method] of Object.entries(source.rpc ?? {})) {
|
|
1605
|
-
rpc[name] = {
|
|
1606
|
-
subject: method.subject ?? rpcSubject(name, method.version),
|
|
1607
|
-
input: schema(resolveSchemaRef(source.schemas, method.input, `rpc '${name}' input`)),
|
|
1608
|
-
output: schema(resolveSchemaRef(source.schemas, method.output, `rpc '${name}' output`)),
|
|
1609
|
-
callerCapabilities: projectCapabilities(method.capabilities?.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
|
|
1610
|
-
transfer: method.transfer ? { ...method.transfer } : undefined,
|
|
1611
|
-
authRequired: method.authRequired ?? true,
|
|
1612
|
-
errors: method.errors,
|
|
1613
|
-
declaredErrorTypes: method.errors?.map((errorName) => source.errors?.[errorName]?.type ?? errorName),
|
|
1614
|
-
runtimeErrors: method.errors?.flatMap((errorName) => {
|
|
1615
|
-
const runtimeError = localRuntimeErrors[errorName];
|
|
1616
|
-
return runtimeError ? [runtimeError] : [];
|
|
1617
|
-
}),
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
const operations = Object.fromEntries(Object.entries(source.operations ?? {}).map(([name, operation]) => [
|
|
1621
|
-
name,
|
|
1622
|
-
{
|
|
1623
|
-
subject: operation.subject ?? operationSubject(name, operation.version),
|
|
1624
|
-
input: schema(resolveSchemaRef(source.schemas, operation.input, `operation '${name}' input`)),
|
|
1625
|
-
progress: operation.progress
|
|
1626
|
-
? schema(resolveSchemaRef(source.schemas, operation.progress, `operation '${name}' progress`))
|
|
1627
|
-
: undefined,
|
|
1628
|
-
output: operation.output
|
|
1629
|
-
? schema(resolveSchemaRef(source.schemas, operation.output, `operation '${name}' output`))
|
|
1630
|
-
: undefined,
|
|
1631
|
-
transfer: operation.transfer
|
|
1632
|
-
? { ...operation.transfer, direction: "send" }
|
|
1633
|
-
: undefined,
|
|
1634
|
-
signals: operation.signals
|
|
1635
|
-
? Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
|
|
1636
|
-
signalName,
|
|
1637
|
-
{
|
|
1638
|
-
input: schema(resolveSchemaRef(source.schemas, signal.input, `operation '${name}' signal '${signalName}' input`)),
|
|
1639
|
-
},
|
|
1640
|
-
]))
|
|
1641
|
-
: undefined,
|
|
1642
|
-
callerCapabilities: projectCapabilities(operation.capabilities?.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
|
|
1643
|
-
observeCapabilities: projectCapabilities(operation.capabilities?.observe, source.id, source.capabilities, `operation '${name}' observe capabilities`) ?? [],
|
|
1644
|
-
cancelCapabilities: projectCapabilities(operation.capabilities?.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
|
|
1645
|
-
controlCapabilities: projectCapabilities(operation.capabilities?.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
|
|
1646
|
-
cancel: operation.cancel,
|
|
1647
|
-
},
|
|
1648
|
-
]));
|
|
1649
|
-
const events = Object.fromEntries(Object.entries(source.events ?? {}).map(([name, event]) => {
|
|
1650
|
-
if (event.params && event.params.length > 0) {
|
|
1651
|
-
assertDataPointersExistAndAreTokenable(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
|
|
1652
|
-
}
|
|
1653
|
-
return [
|
|
1654
|
-
name,
|
|
1655
|
-
{
|
|
1656
|
-
subject: event.subject ??
|
|
1657
|
-
eventSubject(name, event.version, event.params),
|
|
1658
|
-
params: event.params,
|
|
1659
|
-
event: schema(resolveSchemaRef(source.schemas, event.event, `event '${name}'`)),
|
|
1660
|
-
publishCapabilities: projectCapabilities(event.capabilities?.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
|
|
1661
|
-
subscribeCapabilities: projectCapabilities(event.capabilities?.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
|
|
1662
|
-
},
|
|
1663
|
-
];
|
|
1664
|
-
}));
|
|
1665
|
-
const feeds = Object.fromEntries(Object.entries(source.feeds ?? {}).map(([name, feed]) => [
|
|
1666
|
-
name,
|
|
1667
|
-
{
|
|
1668
|
-
subject: feed.subject ?? feedSubject(name, feed.version),
|
|
1669
|
-
input: schema(resolveSchemaRef(source.schemas, feed.input, `feed '${name}' input`)),
|
|
1670
|
-
event: schema(resolveSchemaRef(source.schemas, feed.event, `feed '${name}' event`)),
|
|
1671
|
-
subscribeCapabilities: projectCapabilities(feed.capabilities?.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
|
|
1672
|
-
},
|
|
1673
|
-
]));
|
|
1674
|
-
return { rpc, operations, events, feeds, subjects: {} };
|
|
1675
|
-
}
|
|
1676
|
-
function mergeRecord(kind, out, next) {
|
|
1677
|
-
for (const [key, value] of Object.entries(next)) {
|
|
1678
|
-
if (Object.hasOwn(out, key)) {
|
|
1679
|
-
throw new Error(`Duplicate ${kind} key '${key}' while deriving contract API`);
|
|
1680
|
-
}
|
|
1681
|
-
out[key] = value;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
function assertSelectedKeysExist(contractId, kind, keys, api) {
|
|
1685
|
-
if (!keys) {
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
for (const key of keys) {
|
|
1689
|
-
if (!Object.hasOwn(api, key)) {
|
|
1690
|
-
throw new Error(`Contract '${contractId}' does not expose ${kind} key '${key}'`);
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
function assertValidUseSpec(contractId, spec, api) {
|
|
1695
|
-
assertSelectedKeysExist(contractId, "rpc", spec.rpc?.call, api.rpc);
|
|
1696
|
-
assertSelectedKeysExist(contractId, "operations", spec.operations?.call, api.operations);
|
|
1697
|
-
assertSelectedKeysExist(contractId, "events", spec.events?.publish, api.events);
|
|
1698
|
-
assertSelectedKeysExist(contractId, "events", spec.events?.subscribe, api.events);
|
|
1699
|
-
assertSelectedKeysExist(contractId, "feeds", spec.feeds?.subscribe, api.feeds ?? {});
|
|
1700
|
-
}
|
|
1701
|
-
function contractUseByAlias(uses, alias) {
|
|
1702
|
-
return uses?.required?.[alias] ?? uses?.optional?.[alias];
|
|
1703
|
-
}
|
|
1704
|
-
function assertValidEventConsumers(eventConsumers, uses) {
|
|
1705
|
-
if (!eventConsumers) {
|
|
1706
|
-
return;
|
|
1707
|
-
}
|
|
1708
|
-
for (const [groupName, group] of Object.entries(eventConsumers)) {
|
|
1709
|
-
if (group.events.length === 0) {
|
|
1710
|
-
throw new Error(`event consumer group '${groupName}' must declare events`);
|
|
1711
|
-
}
|
|
1712
|
-
if ((group.ordering ?? "strict") === "strict" && group.concurrency !== 1) {
|
|
1713
|
-
throw new Error(`event consumer group '${groupName}' with strict ordering requires concurrency 1`);
|
|
1714
|
-
}
|
|
1715
|
-
for (const eventRef of group.events) {
|
|
1716
|
-
const use = contractUseByAlias(uses, eventRef.use);
|
|
1717
|
-
if (!use) {
|
|
1718
|
-
throw new Error(`event consumer group '${groupName}' references unknown use '${eventRef.use}'`);
|
|
1719
|
-
}
|
|
1720
|
-
if (!use.events?.subscribe?.includes(eventRef.event)) {
|
|
1721
|
-
throw new Error(`event consumer group '${groupName}' references event '${eventRef.event}' that use '${eventRef.use}' does not subscribe to`);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
function attachContractModuleMetadata(value, contractModule) {
|
|
1727
|
-
Object.defineProperty(value, CONTRACT_MODULE_METADATA, {
|
|
1728
|
-
value: contractModule,
|
|
1729
|
-
enumerable: false,
|
|
1730
|
-
});
|
|
1731
|
-
return value;
|
|
1732
|
-
}
|
|
1733
|
-
function attachContractErrorRuntimeMetadata(value, errorClass) {
|
|
1734
|
-
Object.defineProperty(value, CONTRACT_ERROR_RUNTIME_METADATA, {
|
|
1735
|
-
value: errorClass,
|
|
1736
|
-
enumerable: false,
|
|
1737
|
-
});
|
|
1738
|
-
return value;
|
|
1739
|
-
}
|
|
1740
|
-
function getContractErrorRuntimeClass(errorDecl) {
|
|
1741
|
-
const value = Object.getOwnPropertyDescriptor(errorDecl, CONTRACT_ERROR_RUNTIME_METADATA)?.value;
|
|
1742
|
-
if (isErrorClass(value)) {
|
|
1743
|
-
return value;
|
|
1744
|
-
}
|
|
1745
|
-
return undefined;
|
|
1746
|
-
}
|
|
1747
|
-
function resolveErrorSchemaRef(schemas, errorName, errorDecl) {
|
|
1748
|
-
if (errorDecl.schema) {
|
|
1749
|
-
return errorDecl.schema;
|
|
1750
|
-
}
|
|
1751
|
-
const runtimeSchema = getErrorRuntimeSchema(errorDecl);
|
|
1752
|
-
if (!runtimeSchema) {
|
|
1753
|
-
return undefined;
|
|
1754
|
-
}
|
|
1755
|
-
const schemaName = findMatchingSchemaName(schemas, runtimeSchema);
|
|
1756
|
-
if (schemaName) {
|
|
1757
|
-
return { schema: schemaName };
|
|
1758
|
-
}
|
|
1759
|
-
throw new Error(`error '${errorName}' schema must be declared in contract.schemas`);
|
|
1760
|
-
}
|
|
1761
|
-
/**
|
|
1762
|
-
* Define a transportable Trellis error class from a payload-object schema.
|
|
1763
|
-
*
|
|
1764
|
-
* The returned value is a real runtime error class that carries the wire schema
|
|
1765
|
-
* and reconstruction logic needed by `defineServiceContract(...)`.
|
|
1766
|
-
*/
|
|
1767
|
-
export function defineError(options) {
|
|
1768
|
-
var _a;
|
|
1769
|
-
assertNoReservedDefinedErrorFieldNames(options.fields);
|
|
1770
|
-
const errorSchema = createDefinedErrorSchema(options.type, options.fields);
|
|
1771
|
-
const fieldNames = definedErrorPayloadFieldNames(options.fields);
|
|
1772
|
-
class DefinedErrorImpl extends TrellisError {
|
|
1773
|
-
constructor(payload) {
|
|
1774
|
-
const customPayload = pickDefinedErrorPayload(fieldNames, payload);
|
|
1775
|
-
const message = typeof options.message === "function"
|
|
1776
|
-
? options.message(customPayload)
|
|
1777
|
-
: options.message;
|
|
1778
|
-
super(message, definedErrorBaseOptions(payload));
|
|
1779
|
-
Object.defineProperty(this, "name", {
|
|
1780
|
-
enumerable: true,
|
|
1781
|
-
configurable: true,
|
|
1782
|
-
writable: true,
|
|
1783
|
-
value: options.type
|
|
1784
|
-
});
|
|
1785
|
-
Object.defineProperty(this, _a, {
|
|
1786
|
-
enumerable: true,
|
|
1787
|
-
configurable: true,
|
|
1788
|
-
writable: true,
|
|
1789
|
-
value: void 0
|
|
1790
|
-
});
|
|
1791
|
-
this[DEFINED_ERROR_PAYLOAD] = customPayload;
|
|
1792
|
-
Object.assign(this, customPayload);
|
|
1793
|
-
}
|
|
1794
|
-
static fromSerializable(data) {
|
|
1795
|
-
const customPayload = pickDefinedErrorPayload(fieldNames, data);
|
|
1796
|
-
const ErrorCtor = DefinedErrorImpl;
|
|
1797
|
-
const error = new ErrorCtor({
|
|
1798
|
-
...customPayload,
|
|
1799
|
-
id: data.id,
|
|
1800
|
-
context: data.context,
|
|
1801
|
-
traceId: data.traceId,
|
|
1802
|
-
});
|
|
1803
|
-
error[DEFINED_ERROR_PAYLOAD] = customPayload;
|
|
1804
|
-
return Object.assign(error, customPayload);
|
|
1805
|
-
}
|
|
1806
|
-
toSerializable() {
|
|
1807
|
-
return {
|
|
1808
|
-
...this.baseSerializable(),
|
|
1809
|
-
type: this.name,
|
|
1810
|
-
...this[DEFINED_ERROR_PAYLOAD],
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
_a = DEFINED_ERROR_PAYLOAD;
|
|
1815
|
-
Object.defineProperty(DefinedErrorImpl, "type", {
|
|
1816
|
-
enumerable: true,
|
|
1817
|
-
configurable: true,
|
|
1818
|
-
writable: true,
|
|
1819
|
-
value: options.type
|
|
1820
|
-
});
|
|
1821
|
-
Object.defineProperty(DefinedErrorImpl, "schema", {
|
|
1822
|
-
enumerable: true,
|
|
1823
|
-
configurable: true,
|
|
1824
|
-
writable: true,
|
|
1825
|
-
value: errorSchema
|
|
1826
|
-
});
|
|
1827
|
-
// @ts-expect-error TypeScript cannot model the dynamically assigned payload
|
|
1828
|
-
// fields on the generated class instance constructor return type.
|
|
1829
|
-
return DefinedErrorImpl;
|
|
1830
|
-
}
|
|
1831
|
-
function createUseHelper(getContractModule) {
|
|
1832
|
-
return ((spec) => {
|
|
1833
|
-
const contractModule = getContractModule();
|
|
1834
|
-
assertValidUseSpec(contractModule.CONTRACT_ID, spec, contractModule.API.owned);
|
|
1835
|
-
const dependencyUse = {
|
|
1836
|
-
contract: contractModule.CONTRACT_ID,
|
|
1837
|
-
...(spec.rpc?.call ? { rpc: { call: [...spec.rpc.call] } } : {}),
|
|
1838
|
-
...(spec.operations?.call
|
|
1839
|
-
? { operations: { call: [...spec.operations.call] } }
|
|
1840
|
-
: {}),
|
|
1841
|
-
...((spec.events?.publish || spec.events?.subscribe)
|
|
1842
|
-
? {
|
|
1843
|
-
events: {
|
|
1844
|
-
...(spec.events.publish
|
|
1845
|
-
? { publish: [...spec.events.publish] }
|
|
1846
|
-
: {}),
|
|
1847
|
-
...(spec.events.subscribe
|
|
1848
|
-
? { subscribe: [...spec.events.subscribe] }
|
|
1849
|
-
: {}),
|
|
1850
|
-
},
|
|
1851
|
-
}
|
|
1852
|
-
: {}),
|
|
1853
|
-
...(spec.feeds?.subscribe
|
|
1854
|
-
? { feeds: { subscribe: [...spec.feeds.subscribe] } }
|
|
1855
|
-
: {}),
|
|
1856
|
-
};
|
|
1857
|
-
return attachContractModuleMetadata(dependencyUse, contractModule);
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1860
|
-
function getContractModuleFromUse(alias, useValue) {
|
|
1861
|
-
const contractModule = Object.getOwnPropertyDescriptor(useValue, CONTRACT_MODULE_METADATA)?.value;
|
|
1862
|
-
if (!contractModule) {
|
|
1863
|
-
throw new Error(`Contract use '${alias}' must be created with contractModule.use(...) from @qlever-llc/trellis/contracts`);
|
|
1864
|
-
}
|
|
1865
|
-
return contractModule;
|
|
1866
|
-
}
|
|
1867
|
-
function normalizeUseEntries(uses) {
|
|
1868
|
-
if (!uses) {
|
|
1869
|
-
return {
|
|
1870
|
-
manifestUses: undefined,
|
|
1871
|
-
usedApi: { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} },
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
const manifestUses = {};
|
|
1875
|
-
const usedApi = {
|
|
1876
|
-
rpc: {},
|
|
1877
|
-
operations: {},
|
|
1878
|
-
events: {},
|
|
1879
|
-
feeds: {},
|
|
1880
|
-
subjects: {},
|
|
1881
|
-
};
|
|
1882
|
-
for (const [alias, useValue] of Object.entries(uses)) {
|
|
1883
|
-
const contractModule = getContractModuleFromUse(alias, useValue);
|
|
1884
|
-
const rpcCall = useValue.rpc?.call;
|
|
1885
|
-
const operationsCall = useValue.operations?.call;
|
|
1886
|
-
const eventsPublish = useValue.events?.publish;
|
|
1887
|
-
const eventsSubscribe = useValue.events?.subscribe;
|
|
1888
|
-
const feedsSubscribe = useValue.feeds?.subscribe;
|
|
1889
|
-
if (useValue.contract !== contractModule.CONTRACT_ID) {
|
|
1890
|
-
throw new Error(`Contract use '${alias}' references '${useValue.contract}' but module id is '${contractModule.CONTRACT_ID}'`);
|
|
1891
|
-
}
|
|
1892
|
-
assertValidUseSpec(contractModule.CONTRACT_ID, {
|
|
1893
|
-
...(rpcCall ? { rpc: { call: rpcCall } } : {}),
|
|
1894
|
-
...(operationsCall ? { operations: { call: operationsCall } } : {}),
|
|
1895
|
-
...((eventsPublish || eventsSubscribe)
|
|
1896
|
-
? {
|
|
1897
|
-
events: {
|
|
1898
|
-
...(eventsPublish ? { publish: eventsPublish } : {}),
|
|
1899
|
-
...(eventsSubscribe ? { subscribe: eventsSubscribe } : {}),
|
|
1900
|
-
},
|
|
1901
|
-
}
|
|
1902
|
-
: {}),
|
|
1903
|
-
...(feedsSubscribe ? { feeds: { subscribe: feedsSubscribe } } : {}),
|
|
1904
|
-
}, contractModule.API.owned);
|
|
1905
|
-
manifestUses[alias] = {
|
|
1906
|
-
contract: contractModule.CONTRACT_ID,
|
|
1907
|
-
...(rpcCall ? { rpc: { call: [...rpcCall] } } : {}),
|
|
1908
|
-
...(operationsCall ? { operations: { call: [...operationsCall] } } : {}),
|
|
1909
|
-
...((eventsPublish || eventsSubscribe)
|
|
1910
|
-
? {
|
|
1911
|
-
events: {
|
|
1912
|
-
...(eventsPublish ? { publish: [...eventsPublish] } : {}),
|
|
1913
|
-
...(eventsSubscribe ? { subscribe: [...eventsSubscribe] } : {}),
|
|
1914
|
-
},
|
|
1915
|
-
}
|
|
1916
|
-
: {}),
|
|
1917
|
-
...(feedsSubscribe ? { feeds: { subscribe: [...feedsSubscribe] } } : {}),
|
|
1918
|
-
};
|
|
1919
|
-
const rpcKeys = selectedKeys(rpcCall);
|
|
1920
|
-
if (rpcKeys.length > 0) {
|
|
1921
|
-
mergeRecord("rpc", usedApi.rpc, Object.fromEntries(rpcKeys.map((key) => [key, contractModule.API.owned.rpc[key]])));
|
|
1922
|
-
}
|
|
1923
|
-
const operationKeys = selectedKeys(operationsCall);
|
|
1924
|
-
if (operationKeys.length > 0) {
|
|
1925
|
-
mergeRecord("operations", usedApi.operations, Object.fromEntries(operationKeys.map((key) => [key, contractModule.API.owned.operations[key]])));
|
|
1926
|
-
}
|
|
1927
|
-
const eventKeys = new Set([
|
|
1928
|
-
...selectedKeys(eventsPublish),
|
|
1929
|
-
...selectedKeys(eventsSubscribe),
|
|
1930
|
-
]);
|
|
1931
|
-
if (eventKeys.size > 0) {
|
|
1932
|
-
mergeRecord("events", usedApi.events, Object.fromEntries([...eventKeys].map((key) => [key, contractModule.API.owned.events[key]])));
|
|
1933
|
-
}
|
|
1934
|
-
const feedKeys = selectedKeys(feedsSubscribe);
|
|
1935
|
-
if (feedKeys.length > 0) {
|
|
1936
|
-
mergeRecord("feeds", usedApi.feeds ?? {}, Object.fromEntries(feedKeys.map((key) => [key, contractModule.API.owned.feeds?.[key]])));
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
return { manifestUses, usedApi };
|
|
1940
|
-
}
|
|
1941
|
-
function normalizeUses(uses) {
|
|
1942
|
-
if (!uses) {
|
|
1943
|
-
return {
|
|
1944
|
-
manifestUses: undefined,
|
|
1945
|
-
usedApi: emptyApi(),
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
const required = normalizeUseEntries(uses.required);
|
|
1949
|
-
const optional = normalizeUseEntries(omitRequiredUseAliases(uses.optional, uses.required));
|
|
1950
|
-
const usedApi = emptyApi();
|
|
1951
|
-
mergeUseIntoApi(usedApi, required.usedApi);
|
|
1952
|
-
mergeUseIntoApi(usedApi, optional.usedApi);
|
|
1953
|
-
return {
|
|
1954
|
-
manifestUses: {
|
|
1955
|
-
...(required.manifestUses ? { required: required.manifestUses } : {}),
|
|
1956
|
-
...(optional.manifestUses ? { optional: optional.manifestUses } : {}),
|
|
1957
|
-
},
|
|
1958
|
-
usedApi,
|
|
1959
|
-
};
|
|
1960
|
-
}
|
|
1961
|
-
function emptyApi() {
|
|
1962
|
-
return { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} };
|
|
1963
|
-
}
|
|
1964
|
-
function addUniqueStrings(target, values) {
|
|
1965
|
-
for (const value of values) {
|
|
1966
|
-
if (!target.includes(value)) {
|
|
1967
|
-
target.push(value);
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
function mergeUseIntoManifest(manifestUses, alias, use) {
|
|
1972
|
-
const existing = manifestUses[alias];
|
|
1973
|
-
if (!existing) {
|
|
1974
|
-
manifestUses[alias] = use;
|
|
1975
|
-
return;
|
|
1976
|
-
}
|
|
1977
|
-
if (existing.contract !== use.contract) {
|
|
1978
|
-
throw new Error(`Contract use '${alias}' references both '${existing.contract}' and '${use.contract}'`);
|
|
1979
|
-
}
|
|
1980
|
-
const rpcCall = [...(existing.rpc?.call ?? [])];
|
|
1981
|
-
addUniqueStrings(rpcCall, use.rpc?.call ?? []);
|
|
1982
|
-
const operationsCall = [...(existing.operations?.call ?? [])];
|
|
1983
|
-
addUniqueStrings(operationsCall, use.operations?.call ?? []);
|
|
1984
|
-
const eventsPublish = [...(existing.events?.publish ?? [])];
|
|
1985
|
-
addUniqueStrings(eventsPublish, use.events?.publish ?? []);
|
|
1986
|
-
const eventsSubscribe = [...(existing.events?.subscribe ?? [])];
|
|
1987
|
-
addUniqueStrings(eventsSubscribe, use.events?.subscribe ?? []);
|
|
1988
|
-
const feedsSubscribe = [...(existing.feeds?.subscribe ?? [])];
|
|
1989
|
-
addUniqueStrings(feedsSubscribe, use.feeds?.subscribe ?? []);
|
|
1990
|
-
manifestUses[alias] = {
|
|
1991
|
-
contract: existing.contract,
|
|
1992
|
-
...(rpcCall.length > 0 ? { rpc: { call: rpcCall } } : {}),
|
|
1993
|
-
...(operationsCall.length > 0
|
|
1994
|
-
? { operations: { call: operationsCall } }
|
|
1995
|
-
: {}),
|
|
1996
|
-
...((eventsPublish.length > 0 || eventsSubscribe.length > 0)
|
|
1997
|
-
? {
|
|
1998
|
-
events: {
|
|
1999
|
-
...(eventsPublish.length > 0 ? { publish: eventsPublish } : {}),
|
|
2000
|
-
...(eventsSubscribe.length > 0 ? { subscribe: eventsSubscribe } : {}),
|
|
2001
|
-
},
|
|
2002
|
-
}
|
|
2003
|
-
: {}),
|
|
2004
|
-
...(feedsSubscribe.length > 0
|
|
2005
|
-
? { feeds: { subscribe: feedsSubscribe } }
|
|
2006
|
-
: {}),
|
|
2007
|
-
};
|
|
2008
|
-
}
|
|
2009
|
-
function mergeApiAllowDuplicateSubject(kind, out, next) {
|
|
2010
|
-
for (const [key, value] of Object.entries(next)) {
|
|
2011
|
-
const existing = out[key];
|
|
2012
|
-
if (existing !== undefined) {
|
|
2013
|
-
const existingSubject = typeof existing === "object" && existing !== null
|
|
2014
|
-
? existing.subject
|
|
2015
|
-
: undefined;
|
|
2016
|
-
const nextSubject = typeof value === "object" && value !== null
|
|
2017
|
-
? value.subject
|
|
2018
|
-
: undefined;
|
|
2019
|
-
if (typeof existingSubject === "string" && existingSubject === nextSubject) {
|
|
2020
|
-
continue;
|
|
2021
|
-
}
|
|
2022
|
-
throw new Error(`Duplicate ${kind} key '${key}' while deriving contract API`);
|
|
2023
|
-
}
|
|
2024
|
-
out[key] = value;
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
function mergeUseIntoApi(target, api) {
|
|
2028
|
-
mergeApiAllowDuplicateSubject("rpc", target.rpc, api.rpc);
|
|
2029
|
-
mergeApiAllowDuplicateSubject("operations", target.operations, api.operations);
|
|
2030
|
-
mergeApiAllowDuplicateSubject("events", target.events, api.events);
|
|
2031
|
-
mergeApiAllowDuplicateSubject("feeds", target.feeds ?? {}, api.feeds ?? {});
|
|
2032
|
-
mergeApiAllowDuplicateSubject("subjects", target.subjects, api.subjects);
|
|
2033
|
-
}
|
|
2034
|
-
function baselineUse(contract, use, api) {
|
|
2035
|
-
return { manifestUse: { contract, ...use }, api };
|
|
2036
|
-
}
|
|
2037
|
-
function deriveImplicitTrellisUses(source) {
|
|
2038
|
-
const uses = {};
|
|
2039
|
-
if (source.kind === "app" || source.kind === "agent" || source.kind === "device") {
|
|
2040
|
-
uses.auth = baselineUse(TRELLIS_AUTH_CONTRACT_ID, { rpc: { call: [...BASELINE_AUTH_RPC_CALL] } }, BASELINE_AUTH_API);
|
|
2041
|
-
}
|
|
2042
|
-
if (source.state) {
|
|
2043
|
-
uses.state = baselineUse(TRELLIS_STATE_CONTRACT_ID, { rpc: { call: [...BASELINE_STATE_RPC_CALL] } }, BASELINE_STATE_API);
|
|
2044
|
-
}
|
|
2045
|
-
if ((source.kind === "service" || source.kind === "device") &&
|
|
2046
|
-
source.id !== TRELLIS_HEALTH_CONTRACT_ID) {
|
|
2047
|
-
uses.health = baselineUse(TRELLIS_HEALTH_CONTRACT_ID, { events: { publish: [...BASELINE_HEALTH_EVENTS_PUBLISH] } }, BASELINE_HEALTH_API);
|
|
2048
|
-
}
|
|
2049
|
-
return uses;
|
|
2050
|
-
}
|
|
2051
|
-
function normalizeContractUses(source) {
|
|
2052
|
-
const explicit = normalizeUses(source.uses);
|
|
2053
|
-
const usedApi = emptyApi();
|
|
2054
|
-
mergeUseIntoApi(usedApi, explicit.usedApi);
|
|
2055
|
-
const required = {
|
|
2056
|
-
...(explicit.manifestUses?.required ?? {}),
|
|
2057
|
-
};
|
|
2058
|
-
const optional = explicit.manifestUses?.optional
|
|
2059
|
-
? { ...explicit.manifestUses.optional }
|
|
2060
|
-
: undefined;
|
|
2061
|
-
for (const [alias, use] of Object.entries(deriveImplicitTrellisUses(source))) {
|
|
2062
|
-
mergeUseIntoManifest(required, alias, use.manifestUse);
|
|
2063
|
-
mergeUseIntoApi(usedApi, use.api);
|
|
2064
|
-
}
|
|
2065
|
-
return {
|
|
2066
|
-
manifestUses: Object.keys(required).length > 0 ||
|
|
2067
|
-
(optional && Object.keys(optional).length > 0)
|
|
2068
|
-
? {
|
|
2069
|
-
...(Object.keys(required).length > 0 ? { required } : {}),
|
|
2070
|
-
...(optional && Object.keys(optional).length > 0 ? { optional } : {}),
|
|
2071
|
-
}
|
|
2072
|
-
: undefined,
|
|
2073
|
-
usedApi,
|
|
2074
|
-
};
|
|
2075
|
-
}
|
|
2076
|
-
function selectedKeys(keys) {
|
|
2077
|
-
return keys ?? [];
|
|
2078
|
-
}
|
|
2079
|
-
function mergeApiSection(kind, usedEntries, ownedEntries) {
|
|
2080
|
-
const merged = {};
|
|
2081
|
-
mergeRecord(kind, merged, usedEntries);
|
|
2082
|
-
mergeRecord(kind, merged, ownedEntries);
|
|
2083
|
-
return merged;
|
|
2084
|
-
}
|
|
2085
|
-
function mergeDerivedApis(ownedApi, usedApi) {
|
|
2086
|
-
return {
|
|
2087
|
-
rpc: mergeApiSection("rpc", usedApi.rpc, ownedApi.rpc),
|
|
2088
|
-
operations: mergeApiSection("operations", usedApi.operations, ownedApi.operations),
|
|
2089
|
-
events: mergeApiSection("events", usedApi.events, ownedApi.events),
|
|
2090
|
-
feeds: mergeApiSection("feeds", usedApi.feeds ?? {}, ownedApi.feeds ?? {}),
|
|
2091
|
-
subjects: mergeApiSection("subjects", usedApi.subjects, ownedApi.subjects),
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
|
-
function defineContract(registry, build) {
|
|
2095
|
-
assertRegistryDoesNotDeclareExports(registry);
|
|
2096
|
-
assertRegistryDoesNotDeclareCapabilities(registry);
|
|
2097
|
-
const errorClasses = getErrorClassRegistry(registry.errors);
|
|
2098
|
-
const normalizedErrors = normalizeErrorRegistry(registry.errors);
|
|
2099
|
-
const body = build(createContractRefBuilder({
|
|
2100
|
-
...(registry.schemas ? { schemas: registry.schemas } : {}),
|
|
2101
|
-
...(errorClasses ? { errors: errorClasses } : {}),
|
|
2102
|
-
}));
|
|
2103
|
-
const materializedSchemas = materializeErrorSchemas(registry.schemas, normalizedErrors);
|
|
2104
|
-
const source = {
|
|
2105
|
-
...body,
|
|
2106
|
-
...(materializedSchemas ? { schemas: materializedSchemas } : {}),
|
|
2107
|
-
...(normalizedErrors ? { errors: normalizedErrors } : {}),
|
|
2108
|
-
};
|
|
2109
|
-
assertExportedSchemasExist(source.schemas, source.exports);
|
|
2110
|
-
const { manifestUses, usedApi } = normalizeContractUses(source);
|
|
2111
|
-
const emittedSource = {
|
|
2112
|
-
id: source.id,
|
|
2113
|
-
displayName: source.displayName,
|
|
2114
|
-
description: source.description,
|
|
2115
|
-
...(source.docs ? { docs: source.docs } : {}),
|
|
2116
|
-
kind: source.kind,
|
|
2117
|
-
...(source.capabilities ? { capabilities: source.capabilities } : {}),
|
|
2118
|
-
...(source.schemas ? { schemas: source.schemas } : {}),
|
|
2119
|
-
...(source.exports ? { exports: source.exports } : {}),
|
|
2120
|
-
...(source.state ? { state: source.state } : {}),
|
|
2121
|
-
...(manifestUses ? { uses: manifestUses } : {}),
|
|
2122
|
-
...(source.rpc ? { rpc: source.rpc } : {}),
|
|
2123
|
-
...(source.operations ? { operations: source.operations } : {}),
|
|
2124
|
-
...(source.events ? { events: source.events } : {}),
|
|
2125
|
-
...(source.feeds ? { feeds: source.feeds } : {}),
|
|
2126
|
-
...(source.errors ? { errors: source.errors } : {}),
|
|
2127
|
-
...(source.jobs ? { jobs: source.jobs } : {}),
|
|
2128
|
-
...(source.eventConsumers ? { eventConsumers: source.eventConsumers } : {}),
|
|
2129
|
-
...(source.resources ? { resources: source.resources } : {}),
|
|
2130
|
-
};
|
|
2131
|
-
const ownedApi = buildOwnedApi(emittedSource);
|
|
2132
|
-
const trellisApi = mergeDerivedApis(ownedApi, usedApi);
|
|
2133
|
-
const CONTRACT = emitContract(emittedSource);
|
|
2134
|
-
const CONTRACT_DIGEST = digestContractManifest(CONTRACT);
|
|
2135
|
-
let contract;
|
|
2136
|
-
contract = {
|
|
2137
|
-
CONTRACT_ID: source.id,
|
|
2138
|
-
CONTRACT,
|
|
2139
|
-
CONTRACT_DIGEST,
|
|
2140
|
-
API: {
|
|
2141
|
-
owned: ownedApi,
|
|
2142
|
-
used: usedApi,
|
|
2143
|
-
trellis: trellisApi,
|
|
2144
|
-
},
|
|
2145
|
-
use: createUseHelper(() => contract),
|
|
2146
|
-
[CONTRACT_JOBS_METADATA]: buildContractJobsMetadata(source.jobs),
|
|
2147
|
-
[CONTRACT_KV_METADATA]: buildContractKvMetadata(source.resources, source.schemas),
|
|
2148
|
-
[CONTRACT_STATE_METADATA]: buildContractStateMetadata(source.state, source.schemas),
|
|
2149
|
-
};
|
|
2150
|
-
return contract;
|
|
2151
|
-
}
|
|
2152
|
-
export function defineServiceContract(registry, build) {
|
|
2153
|
-
return defineContract(registry, (ref) => ({
|
|
2154
|
-
...build(ref),
|
|
2155
|
-
kind: "service",
|
|
2156
|
-
}));
|
|
2157
|
-
}
|
|
2158
|
-
function defineClientContract(kind, registry, build) {
|
|
2159
|
-
return defineContract(registry, (ref) => ({ ...build(ref), kind }));
|
|
2160
|
-
}
|
|
2161
|
-
export function defineAppContract(...args) {
|
|
2162
|
-
const [registryOrBuild, maybeBuild] = args;
|
|
2163
|
-
if (typeof registryOrBuild === "function") {
|
|
2164
|
-
return defineClientContract("app", {}, () => registryOrBuild());
|
|
2165
|
-
}
|
|
2166
|
-
return defineClientContract("app", registryOrBuild, maybeBuild);
|
|
2167
|
-
}
|
|
2168
|
-
export function defineAgentContract(...args) {
|
|
2169
|
-
const [registryOrBuild, maybeBuild] = args;
|
|
2170
|
-
if (typeof registryOrBuild === "function") {
|
|
2171
|
-
return defineClientContract("agent", {}, () => registryOrBuild());
|
|
2172
|
-
}
|
|
2173
|
-
return defineClientContract("agent", registryOrBuild, maybeBuild);
|
|
2174
|
-
}
|
|
2175
|
-
export function defineDeviceContract(...args) {
|
|
2176
|
-
const [registryOrBuild, maybeBuild] = args;
|
|
2177
|
-
if (typeof registryOrBuild === "function") {
|
|
2178
|
-
return defineClientContract("device", {}, () => registryOrBuild());
|
|
2179
|
-
}
|
|
2180
|
-
return defineClientContract("device", registryOrBuild, maybeBuild);
|
|
2181
|
-
}
|
|
2182
|
-
export { canonicalizeJson, digestJson, isJsonValue, schema, unwrapSchema };
|