@qlever-llc/trellis 0.7.0-rc.5 → 0.7.0
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/README.md +9 -8
- package/esm/_dnt.shims.d.ts +1 -2
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/auth/browser/login.d.ts +10 -2
- package/esm/auth/browser/login.d.ts.map +1 -1
- package/esm/auth/browser/login.js +37 -21
- package/esm/auth/browser.d.ts +4 -3
- package/esm/auth/browser.d.ts.map +1 -1
- package/esm/auth/browser.js +3 -2
- package/esm/auth/device_activation.d.ts +16 -4
- package/esm/auth/device_activation.d.ts.map +1 -1
- package/esm/auth/device_activation.js +37 -13
- package/esm/auth/mod.d.ts +4 -4
- package/esm/auth/mod.d.ts.map +1 -1
- package/esm/auth/mod.js +4 -4
- package/esm/auth/protocol.d.ts +330 -65
- package/esm/auth/protocol.d.ts.map +1 -1
- package/esm/auth/protocol.js +278 -206
- package/esm/auth/schemas.d.ts +67 -2
- package/esm/auth/schemas.d.ts.map +1 -1
- package/esm/auth/schemas.js +30 -5
- package/esm/auth/session_auth.d.ts +2 -3
- package/esm/auth/session_auth.d.ts.map +1 -1
- package/esm/auth/session_auth.js +24 -10
- package/esm/auth.d.ts +3 -0
- package/esm/auth.d.ts.map +1 -0
- package/esm/auth.js +2 -0
- package/esm/browser.d.ts +6 -0
- package/esm/browser.d.ts.map +1 -0
- package/esm/browser.js +5 -0
- package/esm/client.d.ts.map +1 -0
- package/esm/client_connect.d.ts +53 -0
- package/esm/client_connect.d.ts.map +1 -0
- package/esm/client_connect.js +338 -0
- package/esm/codec.d.ts.map +1 -0
- package/esm/contract.d.ts +20 -0
- package/esm/contract.d.ts.map +1 -0
- package/esm/contract.js +1 -0
- package/esm/contract_support/canonical.d.ts.map +1 -0
- package/esm/contract_support/mod.d.ts +622 -0
- package/esm/contract_support/mod.d.ts.map +1 -0
- package/esm/contract_support/mod.js +968 -0
- package/esm/contract_support/protocol.d.ts.map +1 -0
- package/esm/contract_support/protocol.js +145 -0
- package/esm/contract_support/runtime.d.ts +75 -0
- package/esm/contract_support/runtime.d.ts.map +1 -0
- package/esm/contract_support/schema_pointers.d.ts.map +1 -0
- package/esm/contracts.d.ts +5 -0
- package/esm/contracts.d.ts.map +1 -0
- package/esm/contracts.js +3 -0
- package/esm/device.d.ts +48 -0
- package/esm/device.d.ts.map +1 -0
- package/esm/device.js +288 -0
- package/esm/env.d.ts +2 -0
- package/esm/env.d.ts.map +1 -0
- package/esm/env.js +1 -0
- package/esm/errors/AuthError.d.ts +30 -0
- package/esm/errors/AuthError.d.ts.map +1 -0
- package/esm/errors/AuthError.js +76 -0
- package/esm/errors/KVError.d.ts.map +1 -0
- package/esm/errors/RemoteError.d.ts +53 -0
- package/esm/errors/RemoteError.d.ts.map +1 -0
- package/esm/errors/RemoteError.js +80 -0
- package/esm/errors/StoreError.d.ts.map +1 -0
- package/esm/errors/TransferError.d.ts.map +1 -0
- package/esm/errors/TrellisError.d.ts.map +1 -0
- package/esm/errors/ValidationError.d.ts.map +1 -0
- package/esm/errors/index.d.ts +178 -0
- package/esm/errors/index.d.ts.map +1 -0
- package/esm/errors/index.js +118 -0
- package/esm/globals.d.ts.map +1 -0
- package/esm/health.d.ts +5 -0
- package/esm/health.d.ts.map +1 -0
- package/esm/health.js +3 -0
- package/esm/helpers.d.ts +10 -0
- package/esm/helpers.d.ts.map +1 -0
- package/esm/helpers.js +38 -0
- package/esm/host/deno.d.ts +3 -0
- package/esm/host/deno.d.ts.map +1 -0
- package/esm/host/deno.js +2 -0
- package/esm/host/mod.d.ts +3 -0
- package/esm/host/mod.d.ts.map +1 -0
- package/esm/host/mod.js +2 -0
- package/esm/host/node.d.ts +3 -0
- package/esm/host/node.d.ts.map +1 -0
- package/esm/host/node.js +2 -0
- package/esm/index.d.ts +29 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +15 -0
- package/esm/kv.d.ts.map +1 -0
- package/esm/models/trellis/TrellisError.d.ts +20 -0
- package/esm/models/trellis/TrellisError.d.ts.map +1 -0
- package/esm/models/trellis/TrellisError.js +15 -0
- package/esm/operations.d.ts +103 -0
- package/esm/operations.d.ts.map +1 -0
- package/esm/operations.js +229 -0
- package/esm/runtime_transport.d.ts +21 -0
- package/esm/runtime_transport.d.ts.map +1 -0
- package/esm/runtime_transport.js +50 -0
- package/esm/sdk/core.d.ts +3 -0
- package/esm/sdk/core.d.ts.map +1 -0
- package/esm/sdk/core.js +2 -0
- package/esm/server/deno.d.ts +1 -1
- package/esm/server/deno.d.ts.map +1 -1
- package/esm/server/health.d.ts +78 -9
- package/esm/server/health.d.ts.map +1 -1
- package/esm/server/health.js +196 -11
- package/esm/server/health_rpc.d.ts +2 -1
- package/esm/server/health_rpc.d.ts.map +1 -1
- package/esm/server/health_rpc.js +6 -4
- package/esm/server/health_schemas.d.ts +51 -0
- package/esm/server/health_schemas.d.ts.map +1 -1
- package/esm/server/health_schemas.js +39 -3
- package/esm/server/mod.d.ts +7 -10
- package/esm/server/mod.d.ts.map +1 -1
- package/esm/server/mod.js +6 -7
- package/esm/server/node.d.ts +1 -1
- package/esm/server/node.d.ts.map +1 -1
- package/esm/server/service.d.ts +65 -13
- package/esm/server/service.d.ts.map +1 -1
- package/esm/server/service.js +299 -54
- package/esm/server/transfer.d.ts +21 -5
- package/esm/server/transfer.d.ts.map +1 -1
- package/esm/server/transfer.js +210 -25
- package/esm/server.d.ts +40 -0
- package/esm/server.d.ts.map +1 -0
- package/esm/server.js +807 -0
- package/esm/server_logger.d.ts.map +1 -0
- package/esm/store.d.ts +60 -0
- package/esm/store.d.ts.map +1 -0
- package/esm/store.js +371 -0
- package/esm/tasks.d.ts.map +1 -0
- package/esm/tracing.d.ts +5 -0
- package/esm/tracing.d.ts.map +1 -0
- package/esm/tracing.js +7 -0
- package/esm/transfer.d.ts +114 -0
- package/esm/transfer.d.ts.map +1 -0
- package/esm/transfer.js +353 -0
- package/esm/trellis.d.ts +314 -0
- package/esm/trellis.d.ts.map +1 -0
- package/esm/trellis.js +1049 -0
- package/package.json +32 -55
- package/script/generated/js/sdks/trellis-core/api.d.ts.map +1 -0
- package/script/generated/js/sdks/trellis-core/api.js +42 -0
- package/script/generated/js/sdks/trellis-core/contract.d.ts +8 -0
- package/script/generated/js/sdks/trellis-core/contract.d.ts.map +1 -0
- package/script/generated/js/sdks/trellis-core/contract.js +62 -0
- package/script/generated/js/sdks/trellis-core/mod.d.ts +6 -0
- package/script/generated/js/sdks/trellis-core/mod.d.ts.map +1 -0
- package/script/generated/js/sdks/trellis-core/mod.js +29 -0
- package/script/generated/js/sdks/trellis-core/schemas.d.ts +1237 -0
- package/script/generated/js/sdks/trellis-core/schemas.d.ts.map +1 -0
- package/script/generated/js/sdks/trellis-core/schemas.js +32 -0
- package/script/generated/js/sdks/trellis-core/types.d.ts +198 -0
- package/script/generated/js/sdks/trellis-core/types.d.ts.map +1 -0
- package/script/generated/js/sdks/trellis-core/types.js +5 -0
- package/script/js/packages/trellis/auth/browser/login.d.ts +35 -0
- package/script/js/packages/trellis/auth/browser/login.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/browser/login.js +117 -0
- package/script/js/packages/trellis/auth/browser/portal.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/browser/portal.js +40 -0
- package/script/js/packages/trellis/auth/browser/session.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/browser/session.js +79 -0
- package/script/js/packages/trellis/auth/browser/storage.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/browser.d.ts +13 -0
- package/script/js/packages/trellis/auth/browser.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/browser.js +52 -0
- package/script/js/packages/trellis/auth/device_activation.d.ts +206 -0
- package/script/js/packages/trellis/auth/device_activation.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/device_activation.js +357 -0
- package/script/js/packages/trellis/auth/keys.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/keys.js +56 -0
- package/script/js/packages/trellis/auth/mod.d.ts +18 -0
- package/script/js/packages/trellis/auth/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/mod.js +217 -0
- package/script/js/packages/trellis/auth/proof.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/proof.js +48 -0
- package/script/js/packages/trellis/auth/protocol.d.ts +1580 -0
- package/script/js/packages/trellis/auth/protocol.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/protocol.js +808 -0
- package/script/js/packages/trellis/auth/schemas.d.ts +158 -0
- package/script/js/packages/trellis/auth/schemas.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/schemas.js +92 -0
- package/script/js/packages/trellis/auth/session_auth.d.ts +19 -0
- package/script/js/packages/trellis/auth/session_auth.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/session_auth.js +59 -0
- package/script/js/packages/trellis/auth/trellis_id.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/trellis_id.js +8 -0
- package/script/js/packages/trellis/auth/types.d.ts.map +1 -0
- package/script/js/packages/trellis/auth/utils.d.ts.map +1 -0
- package/script/js/packages/trellis/auth.d.ts +2 -0
- package/script/js/packages/trellis/auth.d.ts.map +1 -0
- package/script/js/packages/trellis/auth.js +17 -0
- package/script/js/packages/trellis/client.d.ts.map +1 -0
- package/script/js/packages/trellis/client.js +67 -0
- package/script/js/packages/trellis/client_connect.d.ts +53 -0
- package/script/js/packages/trellis/client_connect.d.ts.map +1 -0
- package/script/js/packages/trellis/client_connect.js +342 -0
- package/script/js/packages/trellis/codec.d.ts.map +1 -0
- package/script/js/packages/trellis/codec.js +80 -0
- package/script/js/packages/trellis/contract.d.ts +20 -0
- package/script/js/packages/trellis/contract.d.ts.map +1 -0
- package/script/js/packages/trellis/contract.js +9 -0
- package/script/js/packages/trellis/contract_support/canonical.d.ts.map +1 -0
- package/script/js/packages/trellis/contract_support/mod.d.ts +622 -0
- package/script/js/packages/trellis/contract_support/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/contract_support/mod.js +1001 -0
- package/script/js/packages/trellis/contract_support/protocol.d.ts.map +1 -0
- package/script/js/packages/trellis/contract_support/protocol.js +151 -0
- package/script/js/packages/trellis/contract_support/runtime.d.ts +75 -0
- package/script/js/packages/trellis/contract_support/runtime.d.ts.map +1 -0
- package/script/js/packages/trellis/contract_support/schema_pointers.d.ts.map +1 -0
- package/script/js/packages/trellis/contracts.d.ts +4 -0
- package/script/js/packages/trellis/contracts.d.ts.map +1 -0
- package/script/js/packages/trellis/contracts.js +24 -0
- package/script/js/packages/trellis/device.d.ts +48 -0
- package/script/js/packages/trellis/device.d.ts.map +1 -0
- package/script/js/packages/trellis/device.js +292 -0
- package/script/js/packages/trellis/errors/AuthError.d.ts +30 -0
- package/script/js/packages/trellis/errors/AuthError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/AuthError.js +83 -0
- package/script/js/packages/trellis/errors/KVError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/KVError.js +53 -0
- package/script/js/packages/trellis/errors/RemoteError.d.ts +53 -0
- package/script/js/packages/trellis/errors/RemoteError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/RemoteError.js +87 -0
- package/script/js/packages/trellis/errors/StoreError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/StoreError.js +48 -0
- package/script/js/packages/trellis/errors/TransferError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/TransferError.js +48 -0
- package/script/js/packages/trellis/errors/TrellisError.d.ts +16 -0
- package/script/js/packages/trellis/errors/TrellisError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/TrellisError.js +19 -0
- package/script/js/packages/trellis/errors/ValidationError.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/ValidationError.js +84 -0
- package/script/js/packages/trellis/errors/index.d.ts +177 -0
- package/script/js/packages/trellis/errors/index.d.ts.map +1 -0
- package/script/js/packages/trellis/errors/index.js +136 -0
- package/script/js/packages/trellis/globals.d.ts.map +1 -0
- package/script/js/packages/trellis/health.d.ts +4 -0
- package/script/js/packages/trellis/health.d.ts.map +1 -0
- package/script/js/packages/trellis/health.js +18 -0
- package/script/js/packages/trellis/helpers.d.ts +10 -0
- package/script/js/packages/trellis/helpers.d.ts.map +1 -0
- package/script/js/packages/trellis/helpers.js +44 -0
- package/script/js/packages/trellis/index.d.ts +28 -0
- package/script/js/packages/trellis/index.d.ts.map +1 -0
- package/script/js/packages/trellis/index.js +81 -0
- package/script/js/packages/trellis/kv.d.ts.map +1 -0
- package/script/js/packages/trellis/kv.js +383 -0
- package/script/js/packages/trellis/models/trellis/TrellisError.d.ts +20 -0
- package/script/js/packages/trellis/models/trellis/TrellisError.d.ts.map +1 -0
- package/script/js/packages/trellis/models/trellis/TrellisError.js +21 -0
- package/script/js/packages/trellis/npm/src/_dnt.polyfills.d.ts +18 -0
- package/script/js/packages/trellis/npm/src/_dnt.polyfills.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/_dnt.shims.d.ts +5 -0
- package/script/js/packages/trellis/npm/src/_dnt.shims.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/_dnt.shims.js +65 -0
- package/script/js/packages/trellis/npm/src/auth/browser/login.d.ts +35 -0
- package/script/js/packages/trellis/npm/src/auth/browser/login.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/browser/login.js +117 -0
- package/script/js/packages/trellis/npm/src/auth/browser/portal.d.ts +11 -0
- package/script/js/packages/trellis/npm/src/auth/browser/portal.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/browser/portal.js +40 -0
- package/script/js/packages/trellis/npm/src/auth/browser/session.d.ts +19 -0
- package/script/js/packages/trellis/npm/src/auth/browser/session.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/browser/session.js +79 -0
- package/script/js/packages/trellis/npm/src/auth/browser/storage.d.ts +12 -0
- package/script/js/packages/trellis/npm/src/auth/browser/storage.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/browser/storage.js +67 -0
- package/script/js/packages/trellis/npm/src/auth/browser.d.ts +14 -0
- package/script/js/packages/trellis/npm/src/auth/browser.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/browser.js +53 -0
- package/script/js/packages/trellis/npm/src/auth/device_activation.d.ts +206 -0
- package/script/js/packages/trellis/npm/src/auth/device_activation.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/device_activation.js +357 -0
- package/script/js/packages/trellis/npm/src/auth/keys.d.ts +5 -0
- package/script/js/packages/trellis/npm/src/auth/keys.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/keys.js +56 -0
- package/script/js/packages/trellis/npm/src/auth/mod.d.ts +18 -0
- package/script/js/packages/trellis/npm/src/auth/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/mod.js +217 -0
- package/script/js/packages/trellis/npm/src/auth/proof.d.ts +9 -0
- package/script/js/packages/trellis/npm/src/auth/proof.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/proof.js +48 -0
- package/script/js/packages/trellis/npm/src/auth/protocol.d.ts +1580 -0
- package/script/js/packages/trellis/npm/src/auth/protocol.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/protocol.js +808 -0
- package/script/js/packages/trellis/npm/src/auth/schemas.d.ts +158 -0
- package/script/js/packages/trellis/npm/src/auth/schemas.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/schemas.js +92 -0
- package/script/js/packages/trellis/npm/src/auth/session_auth.d.ts +19 -0
- package/script/js/packages/trellis/npm/src/auth/session_auth.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/session_auth.js +59 -0
- package/script/js/packages/trellis/npm/src/auth/trellis_id.d.ts +2 -0
- package/script/js/packages/trellis/npm/src/auth/trellis_id.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/trellis_id.js +8 -0
- package/script/js/packages/trellis/npm/src/auth/types.d.ts +8 -0
- package/script/js/packages/trellis/npm/src/auth/types.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/types.js +2 -0
- package/script/js/packages/trellis/npm/src/auth/utils.d.ts +11 -0
- package/script/js/packages/trellis/npm/src/auth/utils.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth/utils.js +77 -0
- package/script/js/packages/trellis/npm/src/auth.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/auth.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/auth.js +18 -0
- package/script/js/packages/trellis/npm/src/browser.d.ts +6 -0
- package/script/js/packages/trellis/npm/src/browser.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/browser.js +21 -0
- package/script/js/packages/trellis/npm/src/client.d.ts +33 -0
- package/script/js/packages/trellis/npm/src/client.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/client.js +67 -0
- package/script/js/packages/trellis/npm/src/client_connect.d.ts +53 -0
- package/script/js/packages/trellis/npm/src/client_connect.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/client_connect.js +366 -0
- package/script/js/packages/trellis/npm/src/codec.d.ts +13 -0
- package/script/js/packages/trellis/npm/src/codec.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/codec.js +80 -0
- package/script/js/packages/trellis/npm/src/contract.d.ts +20 -0
- package/script/js/packages/trellis/npm/src/contract.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract.js +9 -0
- package/script/js/packages/trellis/npm/src/contract_support/canonical.d.ts +14 -0
- package/script/js/packages/trellis/npm/src/contract_support/canonical.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract_support/canonical.js +144 -0
- package/script/js/packages/trellis/npm/src/contract_support/mod.d.ts +622 -0
- package/script/js/packages/trellis/npm/src/contract_support/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract_support/mod.js +1001 -0
- package/script/js/packages/trellis/npm/src/contract_support/protocol.d.ts +335 -0
- package/script/js/packages/trellis/npm/src/contract_support/protocol.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract_support/protocol.js +151 -0
- package/script/js/packages/trellis/npm/src/contract_support/runtime.d.ts +75 -0
- package/script/js/packages/trellis/npm/src/contract_support/runtime.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract_support/runtime.js +13 -0
- package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.d.ts +18 -0
- package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contract_support/schema_pointers.js +63 -0
- package/script/js/packages/trellis/npm/src/contracts.d.ts +5 -0
- package/script/js/packages/trellis/npm/src/contracts.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/contracts.js +25 -0
- package/script/js/packages/trellis/npm/src/device.d.ts +48 -0
- package/script/js/packages/trellis/npm/src/device.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/device.js +292 -0
- package/script/js/packages/trellis/npm/src/env.d.ts +2 -0
- package/script/js/packages/trellis/npm/src/env.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/env.js +5 -0
- package/script/js/packages/trellis/npm/src/errors/AuthError.d.ts +30 -0
- package/script/js/packages/trellis/npm/src/errors/AuthError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/AuthError.js +83 -0
- package/script/js/packages/trellis/npm/src/errors/KVError.d.ts +31 -0
- package/script/js/packages/trellis/npm/src/errors/KVError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/KVError.js +53 -0
- package/script/js/packages/trellis/npm/src/errors/RemoteError.d.ts +53 -0
- package/script/js/packages/trellis/npm/src/errors/RemoteError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/RemoteError.js +87 -0
- package/script/js/packages/trellis/npm/src/errors/StoreError.d.ts +22 -0
- package/script/js/packages/trellis/npm/src/errors/StoreError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/StoreError.js +48 -0
- package/script/js/packages/trellis/npm/src/errors/TransferError.d.ts +22 -0
- package/script/js/packages/trellis/npm/src/errors/TransferError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/TransferError.js +48 -0
- package/script/js/packages/trellis/npm/src/errors/TrellisError.d.ts +16 -0
- package/script/js/packages/trellis/npm/src/errors/TrellisError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/TrellisError.js +19 -0
- package/script/js/packages/trellis/npm/src/errors/ValidationError.d.ts +51 -0
- package/script/js/packages/trellis/npm/src/errors/ValidationError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/ValidationError.js +84 -0
- package/script/js/packages/trellis/npm/src/errors/index.d.ts +178 -0
- package/script/js/packages/trellis/npm/src/errors/index.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/errors/index.js +137 -0
- package/script/js/packages/trellis/npm/src/globals.d.ts +10 -0
- package/script/js/packages/trellis/npm/src/globals.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/globals.js +19 -0
- package/script/js/packages/trellis/npm/src/health.d.ts +5 -0
- package/script/js/packages/trellis/npm/src/health.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/health.js +19 -0
- package/script/js/packages/trellis/npm/src/helpers.d.ts +10 -0
- package/script/js/packages/trellis/npm/src/helpers.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/helpers.js +44 -0
- package/script/js/packages/trellis/npm/src/host/deno.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/host/deno.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/host/deno.js +18 -0
- package/script/js/packages/trellis/npm/src/host/mod.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/host/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/host/mod.js +18 -0
- package/script/js/packages/trellis/npm/src/host/node.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/host/node.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/host/node.js +18 -0
- package/script/js/packages/trellis/npm/src/index.d.ts +29 -0
- package/script/js/packages/trellis/npm/src/index.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/index.js +82 -0
- package/script/js/packages/trellis/npm/src/kv.d.ts +72 -0
- package/script/js/packages/trellis/npm/src/kv.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/kv.js +383 -0
- package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.d.ts +20 -0
- package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/models/trellis/TrellisError.js +21 -0
- package/script/js/packages/trellis/npm/src/operations.d.ts +103 -0
- package/script/js/packages/trellis/npm/src/operations.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/operations.js +235 -0
- package/script/js/packages/trellis/npm/src/runtime_transport.d.ts +21 -0
- package/script/js/packages/trellis/npm/src/runtime_transport.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/runtime_transport.js +77 -0
- package/script/js/packages/trellis/npm/src/sdk/core.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/sdk/core.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/sdk/core.js +20 -0
- package/script/js/packages/trellis/npm/src/server/deno.d.ts +2 -0
- package/script/js/packages/trellis/npm/src/server/deno.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/deno.js +6 -0
- package/script/js/packages/trellis/npm/src/server/health.d.ts +161 -0
- package/script/js/packages/trellis/npm/src/server/health.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/health.js +291 -0
- package/script/js/packages/trellis/npm/src/server/health_rpc.d.ts +17 -0
- package/script/js/packages/trellis/npm/src/server/health_rpc.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/health_rpc.js +28 -0
- package/script/js/packages/trellis/npm/src/server/health_schemas.d.ts +71 -0
- package/script/js/packages/trellis/npm/src/server/health_schemas.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/health_schemas.js +57 -0
- package/script/js/packages/trellis/npm/src/server/mod.d.ts +15 -0
- package/script/js/packages/trellis/npm/src/server/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/mod.js +39 -0
- package/script/js/packages/trellis/npm/src/server/node.d.ts +2 -0
- package/script/js/packages/trellis/npm/src/server/node.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/node.js +6 -0
- package/script/js/packages/trellis/npm/src/server/runtime.d.ts +16 -0
- package/script/js/packages/trellis/npm/src/server/runtime.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/runtime.js +2 -0
- package/script/js/packages/trellis/npm/src/server/service.d.ts +205 -0
- package/script/js/packages/trellis/npm/src/server/service.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/service.js +654 -0
- package/script/js/packages/trellis/npm/src/server/subscription.d.ts +99 -0
- package/script/js/packages/trellis/npm/src/server/subscription.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/subscription.js +29 -0
- package/script/js/packages/trellis/npm/src/server/transfer.d.ts +57 -0
- package/script/js/packages/trellis/npm/src/server/transfer.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server/transfer.js +607 -0
- package/script/js/packages/trellis/npm/src/server.d.ts +40 -0
- package/script/js/packages/trellis/npm/src/server.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server.js +811 -0
- package/script/js/packages/trellis/npm/src/server_logger.d.ts +3 -0
- package/script/js/packages/trellis/npm/src/server_logger.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/server_logger.js +10 -0
- package/script/js/packages/trellis/npm/src/store.d.ts +60 -0
- package/script/js/packages/trellis/npm/src/store.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/store.js +377 -0
- package/script/js/packages/trellis/npm/src/tasks.d.ts +11 -0
- package/script/js/packages/trellis/npm/src/tasks.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/tasks.js +45 -0
- package/script/js/packages/trellis/npm/src/telemetry/carrier.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/core.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/env.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/env.js +36 -0
- package/script/js/packages/trellis/npm/src/telemetry/init.d.ts +4 -0
- package/script/js/packages/trellis/npm/src/telemetry/init.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/init.js +11 -0
- package/script/js/packages/trellis/npm/src/telemetry/mod.d.ts +10 -0
- package/script/js/packages/trellis/npm/src/telemetry/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/mod.js +26 -0
- package/script/js/packages/trellis/npm/src/telemetry/nats.d.ts +7 -0
- package/script/js/packages/trellis/npm/src/telemetry/nats.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/result.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/runtime.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/runtime.js +60 -0
- package/script/js/packages/trellis/npm/src/telemetry/trace.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/trace.js +31 -0
- package/script/js/packages/trellis/npm/src/telemetry/trellis.d.ts +2 -0
- package/script/js/packages/trellis/npm/src/telemetry/trellis.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/telemetry/trellis.js +7 -0
- package/script/js/packages/trellis/npm/src/tracing.d.ts +5 -0
- package/script/js/packages/trellis/npm/src/tracing.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/tracing.js +49 -0
- package/script/js/packages/trellis/npm/src/transfer.d.ts +114 -0
- package/script/js/packages/trellis/npm/src/transfer.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/transfer.js +363 -0
- package/script/js/packages/trellis/npm/src/trellis.d.ts +314 -0
- package/script/js/packages/trellis/npm/src/trellis.d.ts.map +1 -0
- package/script/js/packages/trellis/npm/src/trellis.js +1062 -0
- package/script/js/packages/trellis/operations.d.ts +103 -0
- package/script/js/packages/trellis/operations.d.ts.map +1 -0
- package/script/js/packages/trellis/operations.js +235 -0
- package/script/js/packages/trellis/runtime_transport.d.ts +21 -0
- package/script/js/packages/trellis/runtime_transport.d.ts.map +1 -0
- package/script/js/packages/trellis/runtime_transport.js +53 -0
- package/script/js/packages/trellis/sdk/core.d.ts +3 -0
- package/script/js/packages/trellis/sdk/core.d.ts.map +1 -0
- package/script/js/packages/trellis/sdk/core.js +20 -0
- package/script/js/packages/trellis/server/health.d.ts +170 -0
- package/script/js/packages/trellis/server/health.d.ts.map +1 -0
- package/script/js/packages/trellis/server/health.js +267 -0
- package/script/js/packages/trellis/server/health_schemas.d.ts +71 -0
- package/script/js/packages/trellis/server/health_schemas.d.ts.map +1 -0
- package/script/js/packages/trellis/server/health_schemas.js +57 -0
- package/script/js/packages/trellis/store.d.ts +60 -0
- package/script/js/packages/trellis/store.d.ts.map +1 -0
- package/script/js/packages/trellis/store.js +377 -0
- package/script/js/packages/trellis/tasks.d.ts.map +1 -0
- package/script/js/packages/trellis/tasks.js +45 -0
- package/script/js/packages/trellis/telemetry/carrier.d.ts +9 -0
- package/script/js/packages/trellis/telemetry/carrier.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/carrier.js +25 -0
- package/script/js/packages/trellis/telemetry/core.d.ts +8 -0
- package/script/js/packages/trellis/telemetry/core.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/core.js +24 -0
- package/script/js/packages/trellis/telemetry/env.d.ts +2 -0
- package/script/js/packages/trellis/telemetry/env.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/init.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/init.js +11 -0
- package/script/js/packages/trellis/telemetry/mod.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/mod.js +26 -0
- package/script/js/packages/trellis/telemetry/nats.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/nats.js +9 -0
- package/script/js/packages/trellis/telemetry/result.d.ts +2 -0
- package/script/js/packages/trellis/telemetry/result.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/result.js +21 -0
- package/script/js/packages/trellis/telemetry/runtime.d.ts +2 -0
- package/script/js/packages/trellis/telemetry/runtime.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/runtime.js +60 -0
- package/script/js/packages/trellis/telemetry/trace.d.ts +5 -0
- package/script/js/packages/trellis/telemetry/trace.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/trace.js +31 -0
- package/script/js/packages/trellis/telemetry/trellis.d.ts.map +1 -0
- package/script/js/packages/trellis/telemetry/trellis.js +7 -0
- package/script/js/packages/trellis/tracing.d.ts +4 -0
- package/script/js/packages/trellis/tracing.d.ts.map +1 -0
- package/script/js/packages/trellis/tracing.js +46 -0
- package/script/js/packages/trellis/transfer.d.ts +114 -0
- package/script/js/packages/trellis/transfer.d.ts.map +1 -0
- package/script/js/packages/trellis/transfer.js +363 -0
- package/script/js/packages/trellis/trellis.d.ts +314 -0
- package/script/js/packages/trellis/trellis.d.ts.map +1 -0
- package/script/js/packages/trellis/trellis.js +1062 -0
- package/esm/contracts/canonical.d.ts.map +0 -1
- package/esm/contracts/mod.d.ts +0 -482
- package/esm/contracts/mod.d.ts.map +0 -1
- package/esm/contracts/mod.js +0 -558
- package/esm/contracts/protocol.d.ts.map +0 -1
- package/esm/contracts/protocol.js +0 -145
- package/esm/contracts/runtime.d.ts +0 -48
- package/esm/contracts/runtime.d.ts.map +0 -1
- package/esm/contracts/schema_pointers.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts +0 -12
- package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/_dnt.polyfills.js +0 -15
- package/esm/trellis/_sdk/activity/api.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/api.js +0 -43
- package/esm/trellis/_sdk/activity/contract.d.ts +0 -8
- package/esm/trellis/_sdk/activity/contract.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/contract.js +0 -59
- package/esm/trellis/_sdk/activity/mod.d.ts +0 -7
- package/esm/trellis/_sdk/activity/mod.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/mod.js +0 -5
- package/esm/trellis/_sdk/activity/package.json +0 -3
- package/esm/trellis/_sdk/activity/schemas.d.ts +0 -607
- package/esm/trellis/_sdk/activity/schemas.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/schemas.js +0 -33
- package/esm/trellis/_sdk/activity/types.d.ts +0 -96
- package/esm/trellis/_sdk/activity/types.d.ts.map +0 -1
- package/esm/trellis/_sdk/activity/types.js +0 -3
- package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts +0 -12
- package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/_dnt.polyfills.js +0 -15
- package/esm/trellis/_sdk/auth/api.d.ts +0 -10
- package/esm/trellis/_sdk/auth/api.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/api.js +0 -376
- package/esm/trellis/_sdk/auth/contract.d.ts +0 -28
- package/esm/trellis/_sdk/auth/contract.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/contract.js +0 -83
- package/esm/trellis/_sdk/auth/mod.d.ts +0 -7
- package/esm/trellis/_sdk/auth/mod.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/mod.js +0 -5
- package/esm/trellis/_sdk/auth/package.json +0 -3
- package/esm/trellis/_sdk/auth/schemas.d.ts +0 -10110
- package/esm/trellis/_sdk/auth/schemas.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/schemas.js +0 -325
- package/esm/trellis/_sdk/auth/types.d.ts +0 -1382
- package/esm/trellis/_sdk/auth/types.d.ts.map +0 -1
- package/esm/trellis/_sdk/auth/types.js +0 -3
- package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts +0 -12
- package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/_dnt.polyfills.js +0 -15
- package/esm/trellis/_sdk/core/api.d.ts +0 -10
- package/esm/trellis/_sdk/core/api.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/api.js +0 -36
- package/esm/trellis/_sdk/core/contract.d.ts +0 -8
- package/esm/trellis/_sdk/core/contract.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/contract.js +0 -59
- package/esm/trellis/_sdk/core/mod.d.ts +0 -7
- package/esm/trellis/_sdk/core/mod.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/mod.js +0 -5
- package/esm/trellis/_sdk/core/package.json +0 -3
- package/esm/trellis/_sdk/core/schemas.d.ts +0 -1266
- package/esm/trellis/_sdk/core/schemas.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/schemas.js +0 -28
- package/esm/trellis/_sdk/core/types.d.ts +0 -193
- package/esm/trellis/_sdk/core/types.d.ts.map +0 -1
- package/esm/trellis/_sdk/core/types.js +0 -3
- package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts +0 -12
- package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/_dnt.polyfills.js +0 -15
- package/esm/trellis/_sdk/state/api.d.ts +0 -10
- package/esm/trellis/_sdk/state/api.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/api.js +0 -71
- package/esm/trellis/_sdk/state/contract.d.ts +0 -8
- package/esm/trellis/_sdk/state/contract.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/contract.js +0 -59
- package/esm/trellis/_sdk/state/mod.d.ts +0 -7
- package/esm/trellis/_sdk/state/mod.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/mod.js +0 -5
- package/esm/trellis/_sdk/state/package.json +0 -3
- package/esm/trellis/_sdk/state/schemas.d.ts +0 -1437
- package/esm/trellis/_sdk/state/schemas.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/schemas.js +0 -62
- package/esm/trellis/_sdk/state/types.d.ts +0 -206
- package/esm/trellis/_sdk/state/types.d.ts.map +0 -1
- package/esm/trellis/_sdk/state/types.js +0 -3
- package/esm/trellis/auth/browser.d.ts +0 -3
- package/esm/trellis/auth/browser.d.ts.map +0 -1
- package/esm/trellis/auth/browser.js +0 -2
- package/esm/trellis/auth.d.ts +0 -3
- package/esm/trellis/auth.d.ts.map +0 -1
- package/esm/trellis/auth.js +0 -2
- package/esm/trellis/browser.d.ts +0 -6
- package/esm/trellis/browser.d.ts.map +0 -1
- package/esm/trellis/browser.js +0 -5
- package/esm/trellis/client.d.ts.map +0 -1
- package/esm/trellis/client_connect.d.ts +0 -53
- package/esm/trellis/client_connect.d.ts.map +0 -1
- package/esm/trellis/client_connect.js +0 -300
- package/esm/trellis/codec.d.ts.map +0 -1
- package/esm/trellis/contract.d.ts +0 -20
- package/esm/trellis/contract.d.ts.map +0 -1
- package/esm/trellis/contract.js +0 -4
- package/esm/trellis/contracts.d.ts +0 -5
- package/esm/trellis/contracts.d.ts.map +0 -1
- package/esm/trellis/contracts.js +0 -3
- package/esm/trellis/device.d.ts +0 -41
- package/esm/trellis/device.d.ts.map +0 -1
- package/esm/trellis/device.js +0 -209
- package/esm/trellis/env.d.ts +0 -2
- package/esm/trellis/env.d.ts.map +0 -1
- package/esm/trellis/env.js +0 -1
- package/esm/trellis/errors/AuthError.d.ts +0 -30
- package/esm/trellis/errors/AuthError.d.ts.map +0 -1
- package/esm/trellis/errors/AuthError.js +0 -76
- package/esm/trellis/errors/KVError.d.ts.map +0 -1
- package/esm/trellis/errors/RemoteError.d.ts +0 -47
- package/esm/trellis/errors/RemoteError.d.ts.map +0 -1
- package/esm/trellis/errors/RemoteError.js +0 -80
- package/esm/trellis/errors/StoreError.d.ts.map +0 -1
- package/esm/trellis/errors/TransferError.d.ts.map +0 -1
- package/esm/trellis/errors/TrellisError.d.ts.map +0 -1
- package/esm/trellis/errors/ValidationError.d.ts.map +0 -1
- package/esm/trellis/errors/index.d.ts +0 -47
- package/esm/trellis/errors/index.d.ts.map +0 -1
- package/esm/trellis/errors/index.js +0 -35
- package/esm/trellis/globals.d.ts.map +0 -1
- package/esm/trellis/helpers.d.ts +0 -13
- package/esm/trellis/helpers.d.ts.map +0 -1
- package/esm/trellis/helpers.js +0 -48
- package/esm/trellis/index.d.ts +0 -25
- package/esm/trellis/index.d.ts.map +0 -1
- package/esm/trellis/index.js +0 -13
- package/esm/trellis/kv.d.ts.map +0 -1
- package/esm/trellis/models/trellis/TrellisError.d.ts +0 -57
- package/esm/trellis/models/trellis/TrellisError.d.ts.map +0 -1
- package/esm/trellis/models/trellis/TrellisError.js +0 -20
- package/esm/trellis/operations.d.ts +0 -81
- package/esm/trellis/operations.d.ts.map +0 -1
- package/esm/trellis/operations.js +0 -206
- package/esm/trellis/runtime_transport.d.ts +0 -12
- package/esm/trellis/runtime_transport.d.ts.map +0 -1
- package/esm/trellis/runtime_transport.js +0 -35
- package/esm/trellis/sdk/activity.d.ts +0 -3
- package/esm/trellis/sdk/activity.d.ts.map +0 -1
- package/esm/trellis/sdk/activity.js +0 -2
- package/esm/trellis/sdk/auth.d.ts +0 -4
- package/esm/trellis/sdk/auth.d.ts.map +0 -1
- package/esm/trellis/sdk/auth.js +0 -3
- package/esm/trellis/sdk/core.d.ts +0 -4
- package/esm/trellis/sdk/core.d.ts.map +0 -1
- package/esm/trellis/sdk/core.js +0 -3
- package/esm/trellis/sdk/state.d.ts +0 -4
- package/esm/trellis/sdk/state.d.ts.map +0 -1
- package/esm/trellis/sdk/state.js +0 -3
- package/esm/trellis/server/deno.d.ts +0 -3
- package/esm/trellis/server/deno.d.ts.map +0 -1
- package/esm/trellis/server/deno.js +0 -2
- package/esm/trellis/server/health.d.ts +0 -5
- package/esm/trellis/server/health.d.ts.map +0 -1
- package/esm/trellis/server/health.js +0 -3
- package/esm/trellis/server/mod.d.ts +0 -3
- package/esm/trellis/server/mod.d.ts.map +0 -1
- package/esm/trellis/server/mod.js +0 -2
- package/esm/trellis/server/node.d.ts +0 -3
- package/esm/trellis/server/node.d.ts.map +0 -1
- package/esm/trellis/server/node.js +0 -2
- package/esm/trellis/server/runtime.d.ts +0 -4
- package/esm/trellis/server/runtime.d.ts.map +0 -1
- package/esm/trellis/server/runtime.js +0 -2
- package/esm/trellis/server.d.ts +0 -21
- package/esm/trellis/server.d.ts.map +0 -1
- package/esm/trellis/server.js +0 -536
- package/esm/trellis/server_logger.d.ts.map +0 -1
- package/esm/trellis/store.d.ts +0 -51
- package/esm/trellis/store.d.ts.map +0 -1
- package/esm/trellis/store.js +0 -310
- package/esm/trellis/tasks.d.ts.map +0 -1
- package/esm/trellis/tracing.d.ts +0 -5
- package/esm/trellis/tracing.d.ts.map +0 -1
- package/esm/trellis/tracing.js +0 -7
- package/esm/trellis/transfer.d.ts +0 -118
- package/esm/trellis/transfer.d.ts.map +0 -1
- package/esm/trellis/transfer.js +0 -357
- package/esm/trellis/trellis.d.ts +0 -210
- package/esm/trellis/trellis.d.ts.map +0 -1
- package/esm/trellis/trellis.js +0 -935
- package/script/auth/browser/login.d.ts +0 -27
- package/script/auth/browser/login.d.ts.map +0 -1
- package/script/auth/browser/login.js +0 -100
- package/script/auth/browser/portal.d.ts.map +0 -1
- package/script/auth/browser/portal.js +0 -40
- package/script/auth/browser/session.d.ts.map +0 -1
- package/script/auth/browser/session.js +0 -79
- package/script/auth/browser/storage.d.ts.map +0 -1
- package/script/auth/browser.d.ts +0 -13
- package/script/auth/browser.d.ts.map +0 -1
- package/script/auth/browser.js +0 -46
- package/script/auth/device_activation.d.ts +0 -194
- package/script/auth/device_activation.d.ts.map +0 -1
- package/script/auth/device_activation.js +0 -333
- package/script/auth/keys.d.ts.map +0 -1
- package/script/auth/keys.js +0 -56
- package/script/auth/mod.d.ts +0 -18
- package/script/auth/mod.d.ts.map +0 -1
- package/script/auth/mod.js +0 -180
- package/script/auth/proof.d.ts.map +0 -1
- package/script/auth/proof.js +0 -48
- package/script/auth/protocol.d.ts +0 -1315
- package/script/auth/protocol.d.ts.map +0 -1
- package/script/auth/protocol.js +0 -735
- package/script/auth/schemas.d.ts +0 -93
- package/script/auth/schemas.d.ts.map +0 -1
- package/script/auth/schemas.js +0 -67
- package/script/auth/session_auth.d.ts +0 -20
- package/script/auth/session_auth.d.ts.map +0 -1
- package/script/auth/session_auth.js +0 -45
- package/script/auth/trellis_id.d.ts.map +0 -1
- package/script/auth/trellis_id.js +0 -8
- package/script/auth/types.d.ts.map +0 -1
- package/script/auth/utils.d.ts.map +0 -1
- package/script/contracts/canonical.d.ts.map +0 -1
- package/script/contracts/mod.d.ts +0 -482
- package/script/contracts/mod.d.ts.map +0 -1
- package/script/contracts/mod.js +0 -583
- package/script/contracts/protocol.d.ts.map +0 -1
- package/script/contracts/protocol.js +0 -151
- package/script/contracts/runtime.d.ts +0 -48
- package/script/contracts/runtime.d.ts.map +0 -1
- package/script/contracts/schema_pointers.d.ts.map +0 -1
- package/script/telemetry/carrier.d.ts.map +0 -1
- package/script/telemetry/core.d.ts.map +0 -1
- package/script/telemetry/env.d.ts.map +0 -1
- package/script/telemetry/init.d.ts.map +0 -1
- package/script/telemetry/init.js +0 -11
- package/script/telemetry/mod.d.ts.map +0 -1
- package/script/telemetry/mod.js +0 -26
- package/script/telemetry/nats.d.ts.map +0 -1
- package/script/telemetry/result.d.ts.map +0 -1
- package/script/telemetry/runtime.d.ts.map +0 -1
- package/script/telemetry/runtime.js +0 -60
- package/script/telemetry/trace.d.ts.map +0 -1
- package/script/telemetry/trace.js +0 -31
- package/script/telemetry/trellis.d.ts.map +0 -1
- package/script/telemetry/trellis.js +0 -7
- package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts +0 -12
- package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/api.d.ts +0 -10
- package/script/trellis/_sdk/activity/api.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/api.js +0 -46
- package/script/trellis/_sdk/activity/contract.d.ts +0 -8
- package/script/trellis/_sdk/activity/contract.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/contract.js +0 -62
- package/script/trellis/_sdk/activity/mod.d.ts +0 -7
- package/script/trellis/_sdk/activity/mod.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/mod.js +0 -30
- package/script/trellis/_sdk/activity/package.json +0 -3
- package/script/trellis/_sdk/activity/schemas.d.ts +0 -607
- package/script/trellis/_sdk/activity/schemas.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/schemas.js +0 -36
- package/script/trellis/_sdk/activity/types.d.ts +0 -96
- package/script/trellis/_sdk/activity/types.d.ts.map +0 -1
- package/script/trellis/_sdk/activity/types.js +0 -6
- package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts +0 -12
- package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/_dnt.polyfills.js +0 -16
- package/script/trellis/_sdk/auth/api.d.ts +0 -10
- package/script/trellis/_sdk/auth/api.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/api.js +0 -379
- package/script/trellis/_sdk/auth/contract.d.ts +0 -28
- package/script/trellis/_sdk/auth/contract.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/contract.js +0 -86
- package/script/trellis/_sdk/auth/mod.d.ts +0 -7
- package/script/trellis/_sdk/auth/mod.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/mod.js +0 -31
- package/script/trellis/_sdk/auth/package.json +0 -3
- package/script/trellis/_sdk/auth/schemas.d.ts +0 -10110
- package/script/trellis/_sdk/auth/schemas.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/schemas.js +0 -328
- package/script/trellis/_sdk/auth/types.d.ts +0 -1382
- package/script/trellis/_sdk/auth/types.d.ts.map +0 -1
- package/script/trellis/_sdk/auth/types.js +0 -6
- package/script/trellis/_sdk/core/_dnt.polyfills.d.ts +0 -12
- package/script/trellis/_sdk/core/_dnt.polyfills.d.ts.map +0 -1
- package/script/trellis/_sdk/core/_dnt.polyfills.js +0 -16
- package/script/trellis/_sdk/core/api.d.ts +0 -10
- package/script/trellis/_sdk/core/api.d.ts.map +0 -1
- package/script/trellis/_sdk/core/api.js +0 -39
- package/script/trellis/_sdk/core/contract.d.ts +0 -8
- package/script/trellis/_sdk/core/contract.d.ts.map +0 -1
- package/script/trellis/_sdk/core/contract.js +0 -62
- package/script/trellis/_sdk/core/mod.d.ts +0 -7
- package/script/trellis/_sdk/core/mod.d.ts.map +0 -1
- package/script/trellis/_sdk/core/mod.js +0 -30
- package/script/trellis/_sdk/core/package.json +0 -3
- package/script/trellis/_sdk/core/schemas.d.ts +0 -1266
- package/script/trellis/_sdk/core/schemas.d.ts.map +0 -1
- package/script/trellis/_sdk/core/schemas.js +0 -31
- package/script/trellis/_sdk/core/types.d.ts +0 -193
- package/script/trellis/_sdk/core/types.d.ts.map +0 -1
- package/script/trellis/_sdk/core/types.js +0 -6
- package/script/trellis/_sdk/state/_dnt.polyfills.d.ts +0 -12
- package/script/trellis/_sdk/state/_dnt.polyfills.d.ts.map +0 -1
- package/script/trellis/_sdk/state/_dnt.polyfills.js +0 -16
- package/script/trellis/_sdk/state/api.d.ts +0 -10
- package/script/trellis/_sdk/state/api.d.ts.map +0 -1
- package/script/trellis/_sdk/state/api.js +0 -74
- package/script/trellis/_sdk/state/contract.d.ts +0 -8
- package/script/trellis/_sdk/state/contract.d.ts.map +0 -1
- package/script/trellis/_sdk/state/contract.js +0 -62
- package/script/trellis/_sdk/state/mod.d.ts +0 -7
- package/script/trellis/_sdk/state/mod.d.ts.map +0 -1
- package/script/trellis/_sdk/state/mod.js +0 -30
- package/script/trellis/_sdk/state/package.json +0 -3
- package/script/trellis/_sdk/state/schemas.d.ts +0 -1437
- package/script/trellis/_sdk/state/schemas.d.ts.map +0 -1
- package/script/trellis/_sdk/state/schemas.js +0 -65
- package/script/trellis/_sdk/state/types.d.ts +0 -206
- package/script/trellis/_sdk/state/types.d.ts.map +0 -1
- package/script/trellis/_sdk/state/types.js +0 -6
- package/script/trellis/auth.d.ts +0 -2
- package/script/trellis/auth.d.ts.map +0 -1
- package/script/trellis/auth.js +0 -17
- package/script/trellis/client.d.ts.map +0 -1
- package/script/trellis/client.js +0 -67
- package/script/trellis/client_connect.d.ts +0 -53
- package/script/trellis/client_connect.d.ts.map +0 -1
- package/script/trellis/client_connect.js +0 -304
- package/script/trellis/codec.d.ts.map +0 -1
- package/script/trellis/codec.js +0 -80
- package/script/trellis/contract.d.ts +0 -20
- package/script/trellis/contract.d.ts.map +0 -1
- package/script/trellis/contract.js +0 -7
- package/script/trellis/contracts.d.ts +0 -4
- package/script/trellis/contracts.d.ts.map +0 -1
- package/script/trellis/contracts.js +0 -20
- package/script/trellis/device.d.ts +0 -41
- package/script/trellis/device.d.ts.map +0 -1
- package/script/trellis/device.js +0 -213
- package/script/trellis/errors/AuthError.d.ts +0 -30
- package/script/trellis/errors/AuthError.d.ts.map +0 -1
- package/script/trellis/errors/AuthError.js +0 -83
- package/script/trellis/errors/KVError.d.ts.map +0 -1
- package/script/trellis/errors/KVError.js +0 -53
- package/script/trellis/errors/RemoteError.d.ts +0 -47
- package/script/trellis/errors/RemoteError.d.ts.map +0 -1
- package/script/trellis/errors/RemoteError.js +0 -87
- package/script/trellis/errors/StoreError.d.ts.map +0 -1
- package/script/trellis/errors/StoreError.js +0 -48
- package/script/trellis/errors/TransferError.d.ts.map +0 -1
- package/script/trellis/errors/TransferError.js +0 -48
- package/script/trellis/errors/TrellisError.d.ts +0 -16
- package/script/trellis/errors/TrellisError.d.ts.map +0 -1
- package/script/trellis/errors/TrellisError.js +0 -19
- package/script/trellis/errors/ValidationError.d.ts.map +0 -1
- package/script/trellis/errors/ValidationError.js +0 -84
- package/script/trellis/errors/index.d.ts +0 -46
- package/script/trellis/errors/index.d.ts.map +0 -1
- package/script/trellis/errors/index.js +0 -52
- package/script/trellis/globals.d.ts.map +0 -1
- package/script/trellis/helpers.d.ts +0 -12
- package/script/trellis/helpers.d.ts.map +0 -1
- package/script/trellis/helpers.js +0 -54
- package/script/trellis/index.d.ts +0 -24
- package/script/trellis/index.d.ts.map +0 -1
- package/script/trellis/index.js +0 -70
- package/script/trellis/kv.d.ts.map +0 -1
- package/script/trellis/kv.js +0 -383
- package/script/trellis/models/trellis/TrellisError.d.ts +0 -57
- package/script/trellis/models/trellis/TrellisError.d.ts.map +0 -1
- package/script/trellis/models/trellis/TrellisError.js +0 -26
- package/script/trellis/operations.d.ts +0 -81
- package/script/trellis/operations.d.ts.map +0 -1
- package/script/trellis/operations.js +0 -212
- package/script/trellis/runtime_transport.d.ts +0 -12
- package/script/trellis/runtime_transport.d.ts.map +0 -1
- package/script/trellis/runtime_transport.js +0 -37
- package/script/trellis/sdk/core.d.ts +0 -3
- package/script/trellis/sdk/core.d.ts.map +0 -1
- package/script/trellis/sdk/core.js +0 -20
- package/script/trellis/store.d.ts +0 -51
- package/script/trellis/store.d.ts.map +0 -1
- package/script/trellis/store.js +0 -316
- package/script/trellis/tasks.d.ts.map +0 -1
- package/script/trellis/tasks.js +0 -45
- package/script/trellis/tracing.d.ts +0 -4
- package/script/trellis/tracing.d.ts.map +0 -1
- package/script/trellis/tracing.js +0 -46
- package/script/trellis/transfer.d.ts +0 -118
- package/script/trellis/transfer.d.ts.map +0 -1
- package/script/trellis/transfer.js +0 -367
- package/script/trellis/trellis.d.ts +0 -210
- package/script/trellis/trellis.d.ts.map +0 -1
- package/script/trellis/trellis.js +0 -948
- /package/esm/{trellis/client.d.ts → client.d.ts} +0 -0
- /package/esm/{trellis/client.js → client.js} +0 -0
- /package/esm/{trellis/codec.d.ts → codec.d.ts} +0 -0
- /package/esm/{trellis/codec.js → codec.js} +0 -0
- /package/esm/{contracts → contract_support}/canonical.d.ts +0 -0
- /package/esm/{contracts → contract_support}/canonical.js +0 -0
- /package/esm/{contracts → contract_support}/protocol.d.ts +0 -0
- /package/esm/{contracts → contract_support}/runtime.js +0 -0
- /package/esm/{contracts → contract_support}/schema_pointers.d.ts +0 -0
- /package/esm/{contracts → contract_support}/schema_pointers.js +0 -0
- /package/esm/{trellis/errors → errors}/KVError.d.ts +0 -0
- /package/esm/{trellis/errors → errors}/KVError.js +0 -0
- /package/esm/{trellis/errors → errors}/StoreError.d.ts +0 -0
- /package/esm/{trellis/errors → errors}/StoreError.js +0 -0
- /package/esm/{trellis/errors → errors}/TransferError.d.ts +0 -0
- /package/esm/{trellis/errors → errors}/TransferError.js +0 -0
- /package/esm/{trellis/errors → errors}/TrellisError.d.ts +0 -0
- /package/esm/{trellis/errors → errors}/TrellisError.js +0 -0
- /package/esm/{trellis/errors → errors}/ValidationError.d.ts +0 -0
- /package/esm/{trellis/errors → errors}/ValidationError.js +0 -0
- /package/esm/{trellis/globals.d.ts → globals.d.ts} +0 -0
- /package/esm/{trellis/globals.js → globals.js} +0 -0
- /package/esm/{trellis/kv.d.ts → kv.d.ts} +0 -0
- /package/esm/{trellis/kv.js → kv.js} +0 -0
- /package/esm/{trellis/server_logger.d.ts → server_logger.d.ts} +0 -0
- /package/esm/{trellis/server_logger.js → server_logger.js} +0 -0
- /package/esm/{trellis/tasks.d.ts → tasks.d.ts} +0 -0
- /package/esm/{trellis/tasks.js → tasks.js} +0 -0
- /package/{esm/trellis/_sdk/activity → script/generated/js/sdks/trellis-core}/api.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/browser/portal.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/browser/session.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/browser/storage.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/browser/storage.js +0 -0
- /package/script/{auth → js/packages/trellis/auth}/keys.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/proof.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/trellis_id.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/types.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/types.js +0 -0
- /package/script/{auth → js/packages/trellis/auth}/utils.d.ts +0 -0
- /package/script/{auth → js/packages/trellis/auth}/utils.js +0 -0
- /package/script/{trellis → js/packages/trellis}/client.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/codec.d.ts +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/canonical.d.ts +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/canonical.js +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/protocol.d.ts +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/runtime.js +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/schema_pointers.d.ts +0 -0
- /package/script/{contracts → js/packages/trellis/contract_support}/schema_pointers.js +0 -0
- /package/script/{trellis → js/packages/trellis}/errors/KVError.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/errors/StoreError.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/errors/TransferError.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/errors/ValidationError.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/globals.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/globals.js +0 -0
- /package/script/{trellis → js/packages/trellis}/kv.d.ts +0 -0
- /package/script/{trellis/_sdk/activity → js/packages/trellis/npm/src}/_dnt.polyfills.js +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/carrier.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/carrier.js +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/core.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/core.js +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/env.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/nats.js +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/result.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/result.js +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/runtime.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/npm/src/telemetry}/trace.d.ts +0 -0
- /package/script/{trellis → js/packages/trellis}/tasks.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/telemetry}/env.js +0 -0
- /package/script/{telemetry → js/packages/trellis/telemetry}/init.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/telemetry}/mod.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/telemetry}/nats.d.ts +0 -0
- /package/script/{telemetry → js/packages/trellis/telemetry}/trellis.d.ts +0 -0
|
@@ -0,0 +1,1062 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Trellis_instances, _Trellis_log, _Trellis_tasks, _Trellis_hasExplicitApi, _Trellis_noResponderMaxRetries, _Trellis_noResponderRetryMs, _Trellis_authBypassMethods, _Trellis_operationStore, _Trellis_unknownApiError, _Trellis_handleRPC, _Trellis_processRPCMessage, _Trellis_respondWithError, _Trellis_startEphemeralEvent, _Trellis_handleDurableEvent, _Trellis_parseEventMessage, _Trellis_escapeSubjectToken, _Trellis_createProof, _Trellis_requestJson, _Trellis_watchJson;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Trellis = exports.DurableOperationRecordSchema = void 0;
|
|
16
|
+
exports.safeJson = safeJson;
|
|
17
|
+
exports.base64urlEncode = base64urlEncode;
|
|
18
|
+
exports.base64urlDecode = base64urlDecode;
|
|
19
|
+
exports.toArrayBuffer = toArrayBuffer;
|
|
20
|
+
exports.sha256 = sha256;
|
|
21
|
+
exports.buildProofInput = buildProofInput;
|
|
22
|
+
exports.isResultLike = isResultLike;
|
|
23
|
+
exports.buildRuntimeOperationSnapshot = buildRuntimeOperationSnapshot;
|
|
24
|
+
exports.isTerminalRuntimeOperationSnapshot = isTerminalRuntimeOperationSnapshot;
|
|
25
|
+
const jetstream_1 = require("@nats-io/jetstream");
|
|
26
|
+
const nats_core_1 = require("@nats-io/nats-core");
|
|
27
|
+
const result_1 = require("@qlever-llc/result");
|
|
28
|
+
const tracing_js_1 = require("./tracing.js");
|
|
29
|
+
const typebox_1 = require("typebox");
|
|
30
|
+
const value_1 = require("typebox/value");
|
|
31
|
+
const ulid_1 = require("ulid");
|
|
32
|
+
const codec_js_1 = require("./codec.js");
|
|
33
|
+
const index_js_1 = require("./errors/index.js");
|
|
34
|
+
const RemoteError_js_1 = require("./errors/RemoteError.js");
|
|
35
|
+
const globals_js_1 = require("./globals.js");
|
|
36
|
+
const kv_js_1 = require("./kv.js");
|
|
37
|
+
const TrellisError_js_1 = require("./models/trellis/TrellisError.js");
|
|
38
|
+
const operations_js_1 = require("./operations.js");
|
|
39
|
+
const transfer_js_1 = require("./transfer.js");
|
|
40
|
+
const tasks_js_1 = require("./tasks.js");
|
|
41
|
+
/**
|
|
42
|
+
* Safely extract JSON from a NATS message.
|
|
43
|
+
* The .json() method can throw if the message data is not valid JSON.
|
|
44
|
+
*/
|
|
45
|
+
function safeJson(msg) {
|
|
46
|
+
return result_1.Result.try(() => msg.json());
|
|
47
|
+
}
|
|
48
|
+
function encodeRuntimeSchema(schema, data) {
|
|
49
|
+
return (0, codec_js_1.encodeSchema)(schema, data);
|
|
50
|
+
}
|
|
51
|
+
function parseRuntimeSchema(schema, data) {
|
|
52
|
+
return (0, codec_js_1.parseUnknownSchema)(schema, data);
|
|
53
|
+
}
|
|
54
|
+
function base64urlEncode(data) {
|
|
55
|
+
const b64 = btoa(String.fromCharCode(...data));
|
|
56
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
57
|
+
}
|
|
58
|
+
function base64urlDecode(s) {
|
|
59
|
+
const normalized = s.replace(/-/g, "+").replace(/_/g, "/");
|
|
60
|
+
const padLen = (4 - (normalized.length % 4)) % 4;
|
|
61
|
+
const padded = normalized + "=".repeat(padLen);
|
|
62
|
+
const bin = atob(padded);
|
|
63
|
+
const out = new Uint8Array(bin.length);
|
|
64
|
+
for (let i = 0; i < bin.length; i++)
|
|
65
|
+
out[i] = bin.charCodeAt(i);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
function toArrayBuffer(data) {
|
|
69
|
+
const buf = data.buffer;
|
|
70
|
+
if (buf instanceof ArrayBuffer) {
|
|
71
|
+
return buf.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
72
|
+
}
|
|
73
|
+
const copy = new Uint8Array(data.byteLength);
|
|
74
|
+
copy.set(data);
|
|
75
|
+
return copy.buffer;
|
|
76
|
+
}
|
|
77
|
+
async function sha256(data) {
|
|
78
|
+
const digest = await crypto.subtle.digest("SHA-256", toArrayBuffer(data));
|
|
79
|
+
return new Uint8Array(digest);
|
|
80
|
+
}
|
|
81
|
+
function buildProofInput(sessionKey, subject, payloadHash) {
|
|
82
|
+
const enc = new TextEncoder();
|
|
83
|
+
const sessionKeyBytes = enc.encode(sessionKey);
|
|
84
|
+
const subjectBytes = enc.encode(subject);
|
|
85
|
+
const buf = new Uint8Array(4 +
|
|
86
|
+
sessionKeyBytes.length +
|
|
87
|
+
4 +
|
|
88
|
+
subjectBytes.length +
|
|
89
|
+
4 +
|
|
90
|
+
payloadHash.length);
|
|
91
|
+
const view = new DataView(buf.buffer);
|
|
92
|
+
let offset = 0;
|
|
93
|
+
view.setUint32(offset, sessionKeyBytes.length);
|
|
94
|
+
offset += 4;
|
|
95
|
+
buf.set(sessionKeyBytes, offset);
|
|
96
|
+
offset += sessionKeyBytes.length;
|
|
97
|
+
view.setUint32(offset, subjectBytes.length);
|
|
98
|
+
offset += 4;
|
|
99
|
+
buf.set(subjectBytes, offset);
|
|
100
|
+
offset += subjectBytes.length;
|
|
101
|
+
view.setUint32(offset, payloadHash.length);
|
|
102
|
+
offset += 4;
|
|
103
|
+
buf.set(payloadHash, offset);
|
|
104
|
+
return buf;
|
|
105
|
+
}
|
|
106
|
+
function isResultLike(value) {
|
|
107
|
+
return value instanceof result_1.Result;
|
|
108
|
+
}
|
|
109
|
+
const DurableOperationSnapshotSchema = typebox_1.Type.Object({
|
|
110
|
+
id: typebox_1.Type.String(),
|
|
111
|
+
service: typebox_1.Type.String(),
|
|
112
|
+
operation: typebox_1.Type.String(),
|
|
113
|
+
revision: typebox_1.Type.Number(),
|
|
114
|
+
state: typebox_1.Type.Union([
|
|
115
|
+
typebox_1.Type.Literal("pending"),
|
|
116
|
+
typebox_1.Type.Literal("running"),
|
|
117
|
+
typebox_1.Type.Literal("completed"),
|
|
118
|
+
typebox_1.Type.Literal("failed"),
|
|
119
|
+
typebox_1.Type.Literal("cancelled"),
|
|
120
|
+
]),
|
|
121
|
+
createdAt: typebox_1.Type.String(),
|
|
122
|
+
updatedAt: typebox_1.Type.String(),
|
|
123
|
+
completedAt: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
124
|
+
progress: typebox_1.Type.Optional(typebox_1.Type.Any()),
|
|
125
|
+
transfer: typebox_1.Type.Optional(typebox_1.Type.Object({
|
|
126
|
+
chunkIndex: typebox_1.Type.Number(),
|
|
127
|
+
chunkBytes: typebox_1.Type.Number(),
|
|
128
|
+
transferredBytes: typebox_1.Type.Number(),
|
|
129
|
+
})),
|
|
130
|
+
output: typebox_1.Type.Optional(typebox_1.Type.Any()),
|
|
131
|
+
error: typebox_1.Type.Optional(typebox_1.Type.Object({
|
|
132
|
+
type: typebox_1.Type.String(),
|
|
133
|
+
message: typebox_1.Type.String(),
|
|
134
|
+
})),
|
|
135
|
+
});
|
|
136
|
+
exports.DurableOperationRecordSchema = typebox_1.Type.Object({
|
|
137
|
+
ownerSessionKey: typebox_1.Type.String(),
|
|
138
|
+
sequence: typebox_1.Type.Number(),
|
|
139
|
+
snapshot: DurableOperationSnapshotSchema,
|
|
140
|
+
});
|
|
141
|
+
function buildRuntimeOperationSnapshot(runtime, state, patch) {
|
|
142
|
+
const updatedAt = new Date().toISOString();
|
|
143
|
+
const completedAt = state === "completed" || state === "failed" || state === "cancelled"
|
|
144
|
+
? (patch?.completedAt ?? updatedAt)
|
|
145
|
+
: patch?.completedAt;
|
|
146
|
+
return {
|
|
147
|
+
id: runtime.id,
|
|
148
|
+
service: runtime.service,
|
|
149
|
+
operation: runtime.operation,
|
|
150
|
+
revision: patch?.revision ?? runtime.snapshot.revision + 1,
|
|
151
|
+
state,
|
|
152
|
+
createdAt: patch?.createdAt ?? runtime.snapshot.createdAt,
|
|
153
|
+
updatedAt,
|
|
154
|
+
...(completedAt ? { completedAt } : {}),
|
|
155
|
+
...(patch?.progress !== undefined
|
|
156
|
+
? { progress: patch.progress }
|
|
157
|
+
: runtime.snapshot.progress !== undefined
|
|
158
|
+
? { progress: runtime.snapshot.progress }
|
|
159
|
+
: {}),
|
|
160
|
+
...(patch?.transfer !== undefined
|
|
161
|
+
? { transfer: patch.transfer }
|
|
162
|
+
: runtime.snapshot.transfer !== undefined
|
|
163
|
+
? { transfer: runtime.snapshot.transfer }
|
|
164
|
+
: {}),
|
|
165
|
+
...(patch?.output !== undefined
|
|
166
|
+
? { output: patch.output }
|
|
167
|
+
: runtime.snapshot.output !== undefined
|
|
168
|
+
? { output: runtime.snapshot.output }
|
|
169
|
+
: {}),
|
|
170
|
+
...(patch?.error
|
|
171
|
+
? { error: patch.error }
|
|
172
|
+
: runtime.snapshot.error
|
|
173
|
+
? { error: runtime.snapshot.error }
|
|
174
|
+
: {}),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function isRuntimeOperationSnapshot(value) {
|
|
178
|
+
return !!value && typeof value === "object" &&
|
|
179
|
+
typeof value.id === "string" &&
|
|
180
|
+
typeof value.service === "string" &&
|
|
181
|
+
typeof value.operation === "string" &&
|
|
182
|
+
typeof value.revision === "number" &&
|
|
183
|
+
typeof value.state === "string" &&
|
|
184
|
+
typeof value.createdAt === "string" &&
|
|
185
|
+
typeof value.updatedAt === "string";
|
|
186
|
+
}
|
|
187
|
+
function isTerminalRuntimeOperationSnapshot(value) {
|
|
188
|
+
return isRuntimeOperationSnapshot(value) && (value.state === "completed" || value.state === "failed" ||
|
|
189
|
+
value.state === "cancelled");
|
|
190
|
+
}
|
|
191
|
+
const NATS_SUBJECT_TOKEN_FORBIDDEN = /[\u0000\s.*>~]/gu;
|
|
192
|
+
const DEFAULT_NO_RESPONDER_MAX_RETRIES = 2;
|
|
193
|
+
const DEFAULT_NO_RESPONDER_RETRY_MS = 200;
|
|
194
|
+
const DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS = 3;
|
|
195
|
+
const DEFAULT_AUTH_VALIDATE_SESSION_RETRY_MS = 25;
|
|
196
|
+
const EMPTY_TRELLIS_API = {
|
|
197
|
+
rpc: {},
|
|
198
|
+
operations: {},
|
|
199
|
+
events: {},
|
|
200
|
+
subjects: {},
|
|
201
|
+
};
|
|
202
|
+
function isTransientAuthValidateSessionError(error) {
|
|
203
|
+
if (error instanceof index_js_1.AuthError) {
|
|
204
|
+
return error.reason === "session_not_found";
|
|
205
|
+
}
|
|
206
|
+
if (error instanceof RemoteError_js_1.RemoteError &&
|
|
207
|
+
error.remoteError.type === "AuthError") {
|
|
208
|
+
const reason = Reflect.get(error.remoteError, "reason");
|
|
209
|
+
return typeof reason === "string" && reason === "session_not_found";
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
function isDeclaredRpcError(errorNames, type) {
|
|
214
|
+
return !!errorNames?.includes(type);
|
|
215
|
+
}
|
|
216
|
+
function isRuntimeRpcErrorDesc(value) {
|
|
217
|
+
return !!value && typeof value === "object" &&
|
|
218
|
+
typeof Reflect.get(value, "type") === "string" &&
|
|
219
|
+
typeof Reflect.get(value, "fromSerializable") === "function";
|
|
220
|
+
}
|
|
221
|
+
function reconstructDeclaredRpcError(errorNames, runtimeErrors, data, json) {
|
|
222
|
+
if (!isDeclaredRpcError(errorNames, data.type)) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
const runtimeError = (0, index_js_1.getBuiltinRpcError)(data.type) ??
|
|
226
|
+
runtimeErrors?.find((candidate) => candidate.type === data.type);
|
|
227
|
+
if (!runtimeError) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const parsed = runtimeError.schema
|
|
231
|
+
? parseRuntimeSchema(runtimeError.schema, json).take()
|
|
232
|
+
: data;
|
|
233
|
+
if ((0, result_1.isErr)(parsed)) {
|
|
234
|
+
return parsed.error instanceof index_js_1.ValidationError ||
|
|
235
|
+
parsed.error instanceof index_js_1.UnexpectedError
|
|
236
|
+
? parsed.error
|
|
237
|
+
: new index_js_1.UnexpectedError({ cause: parsed.error });
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const reconstructed = runtimeError.fromSerializable(parsed);
|
|
241
|
+
if (reconstructed instanceof result_1.BaseError) {
|
|
242
|
+
return reconstructed;
|
|
243
|
+
}
|
|
244
|
+
return new index_js_1.UnexpectedError({
|
|
245
|
+
cause: new Error(`RPC error '${data.type}' reconstructed to a non-Trellis error instance`),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
catch (cause) {
|
|
249
|
+
return new index_js_1.UnexpectedError({ cause });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function sleep(ms) {
|
|
253
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
254
|
+
}
|
|
255
|
+
class Trellis {
|
|
256
|
+
constructor(name, // Must be unique for a service
|
|
257
|
+
nats, auth, opts) {
|
|
258
|
+
_Trellis_instances.add(this);
|
|
259
|
+
Object.defineProperty(this, "name", {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
configurable: true,
|
|
262
|
+
writable: true,
|
|
263
|
+
value: void 0
|
|
264
|
+
});
|
|
265
|
+
Object.defineProperty(this, "timeout", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
configurable: true,
|
|
268
|
+
writable: true,
|
|
269
|
+
value: void 0
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(this, "stream", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
configurable: true,
|
|
274
|
+
writable: true,
|
|
275
|
+
value: void 0
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(this, "nats", {
|
|
278
|
+
enumerable: true,
|
|
279
|
+
configurable: true,
|
|
280
|
+
writable: true,
|
|
281
|
+
value: void 0
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(this, "js", {
|
|
284
|
+
enumerable: true,
|
|
285
|
+
configurable: true,
|
|
286
|
+
writable: true,
|
|
287
|
+
value: void 0
|
|
288
|
+
});
|
|
289
|
+
Object.defineProperty(this, "auth", {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
configurable: true,
|
|
292
|
+
writable: true,
|
|
293
|
+
value: void 0
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(this, "api", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
configurable: true,
|
|
298
|
+
writable: true,
|
|
299
|
+
value: void 0
|
|
300
|
+
});
|
|
301
|
+
_Trellis_log.set(this, void 0);
|
|
302
|
+
_Trellis_tasks.set(this, void 0);
|
|
303
|
+
_Trellis_hasExplicitApi.set(this, void 0);
|
|
304
|
+
_Trellis_noResponderMaxRetries.set(this, void 0);
|
|
305
|
+
_Trellis_noResponderRetryMs.set(this, void 0);
|
|
306
|
+
_Trellis_authBypassMethods.set(this, void 0);
|
|
307
|
+
_Trellis_operationStore.set(this, void 0);
|
|
308
|
+
const api = opts?.api;
|
|
309
|
+
this.name = name;
|
|
310
|
+
this.nats = nats;
|
|
311
|
+
this.js = (0, jetstream_1.jetstream)(this.nats);
|
|
312
|
+
this.auth = auth;
|
|
313
|
+
this.api = (api ?? EMPTY_TRELLIS_API);
|
|
314
|
+
__classPrivateFieldSet(this, _Trellis_log, (opts?.log ?? globals_js_1.logger).child({ lib: "trellis" }), "f");
|
|
315
|
+
this.timeout = opts?.timeout ?? 3000;
|
|
316
|
+
this.stream = opts?.stream ?? "trellis";
|
|
317
|
+
__classPrivateFieldSet(this, _Trellis_hasExplicitApi, api !== undefined, "f");
|
|
318
|
+
__classPrivateFieldSet(this, _Trellis_noResponderMaxRetries, opts?.noResponderRetry?.maxAttempts ??
|
|
319
|
+
DEFAULT_NO_RESPONDER_MAX_RETRIES, "f");
|
|
320
|
+
__classPrivateFieldSet(this, _Trellis_noResponderRetryMs, opts?.noResponderRetry?.baseDelayMs ??
|
|
321
|
+
DEFAULT_NO_RESPONDER_RETRY_MS, "f");
|
|
322
|
+
__classPrivateFieldSet(this, _Trellis_authBypassMethods, new Set(opts?.authBypassMethods ?? []), "f");
|
|
323
|
+
__classPrivateFieldSet(this, _Trellis_tasks, new tasks_js_1.TrellisTasks({ log: __classPrivateFieldGet(this, _Trellis_log, "f") }), "f");
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Returns the underlying NATS connection.
|
|
327
|
+
*/
|
|
328
|
+
get natsConnection() {
|
|
329
|
+
return this.nats;
|
|
330
|
+
}
|
|
331
|
+
async operationStoreHandle() {
|
|
332
|
+
if (!__classPrivateFieldGet(this, _Trellis_operationStore, "f")) {
|
|
333
|
+
const bucket = `trellis_operations_${this.auth.sessionKey.slice(0, 16)}`;
|
|
334
|
+
__classPrivateFieldSet(this, _Trellis_operationStore, (async () => {
|
|
335
|
+
const result = await kv_js_1.TypedKV.open(this.nats, bucket, exports.DurableOperationRecordSchema, {
|
|
336
|
+
history: 5,
|
|
337
|
+
ttl: 0,
|
|
338
|
+
});
|
|
339
|
+
const value = result.take();
|
|
340
|
+
if ((0, result_1.isErr)(value)) {
|
|
341
|
+
throw value.error;
|
|
342
|
+
}
|
|
343
|
+
return value;
|
|
344
|
+
})(), "f");
|
|
345
|
+
}
|
|
346
|
+
return __classPrivateFieldGet(this, _Trellis_operationStore, "f");
|
|
347
|
+
}
|
|
348
|
+
async loadOperationRecord(operationId) {
|
|
349
|
+
const store = await this.operationStoreHandle();
|
|
350
|
+
const entry = await store.get(operationId);
|
|
351
|
+
const value = entry.take();
|
|
352
|
+
if ((0, result_1.isErr)(value)) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
return value.value;
|
|
356
|
+
}
|
|
357
|
+
async saveOperationRecord(runtime) {
|
|
358
|
+
const store = await this.operationStoreHandle();
|
|
359
|
+
const record = {
|
|
360
|
+
ownerSessionKey: runtime.ownerSessionKey,
|
|
361
|
+
sequence: runtime.sequence,
|
|
362
|
+
snapshot: runtime.snapshot,
|
|
363
|
+
};
|
|
364
|
+
await store.put(runtime.id, record);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Makes an authenticated request to a Trellis RPC method.
|
|
368
|
+
*
|
|
369
|
+
* @template M The specific RPC method being called.
|
|
370
|
+
* @param method The name of the RPC method to call.
|
|
371
|
+
* @param input The input data for the method, conforming to its schema.
|
|
372
|
+
* @param opts Optional request-specific options.
|
|
373
|
+
* @returns A promise that resolves with a `Result` containing either the method's
|
|
374
|
+
* output or an error.
|
|
375
|
+
* @returns A `Result` object:
|
|
376
|
+
* ok: A validated reponse of method M
|
|
377
|
+
* err: declared RPC errors | RemoteError | ValidationError | UnexpectedError
|
|
378
|
+
*/
|
|
379
|
+
async request(method, input, opts) {
|
|
380
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").trace({ method: String(method) }, `Calling ${method.toString()}.`);
|
|
381
|
+
const methodName = method;
|
|
382
|
+
const ctx = this.api["rpc"][methodName];
|
|
383
|
+
if (!ctx) {
|
|
384
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
385
|
+
cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "RPC method", method.toString()),
|
|
386
|
+
context: { method: method.toString() },
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
const msg = encodeRuntimeSchema(ctx.input, input).take();
|
|
390
|
+
if ((0, result_1.isErr)(msg)) {
|
|
391
|
+
return msg;
|
|
392
|
+
}
|
|
393
|
+
const subject = this.template(ctx.subject, input).take();
|
|
394
|
+
if ((0, result_1.isErr)(subject)) {
|
|
395
|
+
return subject;
|
|
396
|
+
}
|
|
397
|
+
// Start a client span for this RPC request
|
|
398
|
+
const span = (0, tracing_js_1.startClientSpan)(method, subject);
|
|
399
|
+
const attempt = async () => {
|
|
400
|
+
const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, msg);
|
|
401
|
+
const headers = (0, nats_core_1.headers)();
|
|
402
|
+
headers.set("session-key", this.auth.sessionKey);
|
|
403
|
+
headers.set("proof", proof);
|
|
404
|
+
// Inject trace context into NATS headers for propagation
|
|
405
|
+
(0, tracing_js_1.injectTraceContext)((0, tracing_js_1.createNatsHeaderCarrier)(headers), span);
|
|
406
|
+
// Attempt request with retry for transient "no responders" errors
|
|
407
|
+
const requestWithRetry = async () => {
|
|
408
|
+
for (let retry = 0; retry <= __classPrivateFieldGet(this, _Trellis_noResponderMaxRetries, "f"); retry++) {
|
|
409
|
+
const result = await result_1.AsyncResult.try(() => this.nats.request(subject, msg, {
|
|
410
|
+
headers,
|
|
411
|
+
timeout: opts?.timeout ?? this.timeout,
|
|
412
|
+
}));
|
|
413
|
+
if (result.isOk()) {
|
|
414
|
+
return (0, result_1.ok)((await result).take());
|
|
415
|
+
}
|
|
416
|
+
const cause = result.error.cause;
|
|
417
|
+
const message = cause instanceof Error
|
|
418
|
+
? cause.message
|
|
419
|
+
: String(cause);
|
|
420
|
+
const isNoResponders = message.includes("no responders");
|
|
421
|
+
// If it's a no-responders error and we have retries left, retry
|
|
422
|
+
if (isNoResponders && retry < __classPrivateFieldGet(this, _Trellis_noResponderMaxRetries, "f")) {
|
|
423
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").debug({ method, subject, retry }, "No responders, retrying...");
|
|
424
|
+
await new Promise((r) => setTimeout(r, __classPrivateFieldGet(this, _Trellis_noResponderRetryMs, "f") * (retry + 1)));
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
// Final attempt failed or non-retryable error
|
|
428
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").warn({ method, subject, error: message }, "NATS request failed");
|
|
429
|
+
const isNatsPermission = message.includes("Permissions Violation");
|
|
430
|
+
const reason = isNatsPermission
|
|
431
|
+
? `Permission denied. You need one of these capabilities: ${ctx.callerCapabilities.join(", ")}`
|
|
432
|
+
: message;
|
|
433
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
434
|
+
cause,
|
|
435
|
+
context: {
|
|
436
|
+
method,
|
|
437
|
+
subject,
|
|
438
|
+
reason,
|
|
439
|
+
requiredCapabilities: ctx.callerCapabilities,
|
|
440
|
+
noResponders: isNoResponders,
|
|
441
|
+
},
|
|
442
|
+
}));
|
|
443
|
+
}
|
|
444
|
+
// Should be unreachable, but TypeScript needs explicit return
|
|
445
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
446
|
+
context: { method, subject, reason: "retry loop exhausted" },
|
|
447
|
+
}));
|
|
448
|
+
};
|
|
449
|
+
const msgResult = await requestWithRetry();
|
|
450
|
+
const m = msgResult.take();
|
|
451
|
+
if ((0, result_1.isErr)(m)) {
|
|
452
|
+
return m;
|
|
453
|
+
}
|
|
454
|
+
if (m.headers?.get("status") === "error") {
|
|
455
|
+
const json = safeJson(m).take();
|
|
456
|
+
if ((0, result_1.isErr)(json)) {
|
|
457
|
+
return json;
|
|
458
|
+
}
|
|
459
|
+
const errorData = (0, codec_js_1.parse)(TrellisError_js_1.TrellisErrorDataSchema, json).take();
|
|
460
|
+
if ((0, result_1.isErr)(errorData)) {
|
|
461
|
+
return errorData;
|
|
462
|
+
}
|
|
463
|
+
const declaredErrorTypes = Array.isArray(ctx.declaredErrorTypes)
|
|
464
|
+
? ctx.declaredErrorTypes.filter((value) => typeof value === "string")
|
|
465
|
+
: ctx.errors;
|
|
466
|
+
const runtimeErrors = Array.isArray(ctx.runtimeErrors)
|
|
467
|
+
? ctx.runtimeErrors.filter(isRuntimeRpcErrorDesc)
|
|
468
|
+
: undefined;
|
|
469
|
+
const reconstructed = reconstructDeclaredRpcError(declaredErrorTypes, runtimeErrors, errorData, json);
|
|
470
|
+
if (reconstructed) {
|
|
471
|
+
return (0, result_1.err)(reconstructed);
|
|
472
|
+
}
|
|
473
|
+
return (0, result_1.err)(new RemoteError_js_1.RemoteError({ error: errorData }));
|
|
474
|
+
}
|
|
475
|
+
const json = safeJson(m).take();
|
|
476
|
+
if ((0, result_1.isErr)(json)) {
|
|
477
|
+
return json;
|
|
478
|
+
}
|
|
479
|
+
const outputResult = parseRuntimeSchema(ctx.output, json).take();
|
|
480
|
+
if ((0, result_1.isErr)(outputResult)) {
|
|
481
|
+
return (0, result_1.err)(outputResult.error);
|
|
482
|
+
}
|
|
483
|
+
return (0, result_1.ok)(outputResult);
|
|
484
|
+
};
|
|
485
|
+
return (0, tracing_js_1.withSpanAsync)(span, async () => {
|
|
486
|
+
try {
|
|
487
|
+
const result = await attempt();
|
|
488
|
+
const value = result.take();
|
|
489
|
+
if ((0, result_1.isErr)(value)) {
|
|
490
|
+
span.setStatus({
|
|
491
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
492
|
+
message: value.error.message,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
span.setStatus({ code: tracing_js_1.SpanStatusCode.OK });
|
|
497
|
+
}
|
|
498
|
+
return result;
|
|
499
|
+
}
|
|
500
|
+
catch (cause) {
|
|
501
|
+
const unexpected = new index_js_1.UnexpectedError({ cause });
|
|
502
|
+
span.setStatus({
|
|
503
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
504
|
+
message: unexpected.message,
|
|
505
|
+
});
|
|
506
|
+
span.recordException(unexpected);
|
|
507
|
+
return (0, result_1.err)(unexpected);
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
span.end();
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
async requestOrThrow(method, input, opts) {
|
|
515
|
+
const result = await this.request(method, input, opts);
|
|
516
|
+
const value = result.take();
|
|
517
|
+
if ((0, result_1.isErr)(value)) {
|
|
518
|
+
throw value.error;
|
|
519
|
+
}
|
|
520
|
+
return value;
|
|
521
|
+
}
|
|
522
|
+
operation(operation) {
|
|
523
|
+
const descriptor = this.api["operations"]?.[operation];
|
|
524
|
+
if (!descriptor) {
|
|
525
|
+
throw __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "operation", operation.toString());
|
|
526
|
+
}
|
|
527
|
+
const transport = {
|
|
528
|
+
requestJson: (subject, body) => __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_requestJson).call(this, subject, body),
|
|
529
|
+
watchJson: (subject, body) => __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_watchJson).call(this, subject, body),
|
|
530
|
+
putTransfer: async (grant, body) => {
|
|
531
|
+
const handle = (0, transfer_js_1.createTransferHandle)(this.nats, this.auth, this.timeout, grant);
|
|
532
|
+
if (!(handle instanceof Object) || !("put" in handle)) {
|
|
533
|
+
return (0, result_1.err)(new index_js_1.TransferError({
|
|
534
|
+
operation: "transfer",
|
|
535
|
+
context: { reason: "invalid_operation_transfer_grant" },
|
|
536
|
+
}));
|
|
537
|
+
}
|
|
538
|
+
return await handle.put(body);
|
|
539
|
+
},
|
|
540
|
+
};
|
|
541
|
+
return new operations_js_1.OperationInvoker(transport, descriptor);
|
|
542
|
+
}
|
|
543
|
+
/*
|
|
544
|
+
* Mount a handler to process requests made to a specific Trellis API
|
|
545
|
+
*/
|
|
546
|
+
async mount(method, fn) {
|
|
547
|
+
const methodName = method;
|
|
548
|
+
const ctx = this.api["rpc"][methodName];
|
|
549
|
+
if (!ctx) {
|
|
550
|
+
throw __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "RPC method", method.toString());
|
|
551
|
+
}
|
|
552
|
+
const task = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_handleRPC).call(this, methodName, fn);
|
|
553
|
+
__classPrivateFieldGet(this, _Trellis_tasks, "f").add(methodName, task);
|
|
554
|
+
}
|
|
555
|
+
respondWithError(msg, error) {
|
|
556
|
+
__classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_respondWithError).call(this, msg, error);
|
|
557
|
+
}
|
|
558
|
+
async publish(event, data) {
|
|
559
|
+
const eventName = event;
|
|
560
|
+
const ctx = this.api["events"][eventName];
|
|
561
|
+
if (!ctx) {
|
|
562
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
563
|
+
cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "event", event.toString()),
|
|
564
|
+
context: { event: event.toString() },
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
const subject = this.template(ctx.subject, data).take();
|
|
568
|
+
if ((0, result_1.isErr)(subject)) {
|
|
569
|
+
globals_js_1.logger.error({ err: subject.error }, "Failed to template event.");
|
|
570
|
+
return subject;
|
|
571
|
+
}
|
|
572
|
+
const payload = {
|
|
573
|
+
...data,
|
|
574
|
+
header: {
|
|
575
|
+
id: (0, ulid_1.ulid)(),
|
|
576
|
+
time: new Date().toISOString(),
|
|
577
|
+
},
|
|
578
|
+
};
|
|
579
|
+
const msg = (0, codec_js_1.encodeSchema)(ctx.event, payload).take();
|
|
580
|
+
if ((0, result_1.isErr)(msg)) {
|
|
581
|
+
globals_js_1.logger.error({ err: msg.error }, "Failed to encode event.");
|
|
582
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({ cause: msg.error }));
|
|
583
|
+
}
|
|
584
|
+
globals_js_1.logger.trace({ subject }, `Publishing ${event.toString()} event.`);
|
|
585
|
+
await this.js.publish(subject, msg);
|
|
586
|
+
return (0, result_1.ok)(undefined);
|
|
587
|
+
}
|
|
588
|
+
async event(event, subjectData, fn, opts) {
|
|
589
|
+
const eventName = event;
|
|
590
|
+
const ctx = this.api["events"][eventName];
|
|
591
|
+
if (!ctx) {
|
|
592
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
593
|
+
cause: __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_unknownApiError).call(this, "event", event.toString()),
|
|
594
|
+
context: { event: event.toString() },
|
|
595
|
+
}));
|
|
596
|
+
}
|
|
597
|
+
const subject = this.template(ctx.subject, subjectData, true).take();
|
|
598
|
+
if ((0, result_1.isErr)(subject))
|
|
599
|
+
return subject;
|
|
600
|
+
if (opts?.mode === "ephemeral") {
|
|
601
|
+
return __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_startEphemeralEvent).call(this, eventName, ctx, subject, fn, opts.signal);
|
|
602
|
+
}
|
|
603
|
+
const jsm = await (0, jetstream_1.jetstreamManager)(this.nats);
|
|
604
|
+
const consumerName = opts?.durableName ??
|
|
605
|
+
`${this.name}-${event.replaceAll(".", "_")}`;
|
|
606
|
+
const addResult = await result_1.AsyncResult.try(() => jsm.consumers.add(this.stream, {
|
|
607
|
+
durable_name: consumerName,
|
|
608
|
+
ack_policy: "explicit",
|
|
609
|
+
deliver_policy: opts?.replay === "new" ? "new" : "all",
|
|
610
|
+
filter_subjects: [subject],
|
|
611
|
+
}));
|
|
612
|
+
// If add failed (consumer already exists), try to get existing consumer info
|
|
613
|
+
const consumerInfoResult = addResult.isOk()
|
|
614
|
+
? addResult
|
|
615
|
+
: await result_1.AsyncResult.try(() => jsm.consumers.info(this.stream, consumerName));
|
|
616
|
+
const info = consumerInfoResult.take();
|
|
617
|
+
if ((0, result_1.isErr)(info))
|
|
618
|
+
return info;
|
|
619
|
+
const consumer = this.js.consumers.getConsumerFromInfo(info);
|
|
620
|
+
const messages = await consumer.consume();
|
|
621
|
+
if (opts?.signal) {
|
|
622
|
+
if (opts.signal.aborted) {
|
|
623
|
+
messages.stop();
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
opts.signal.addEventListener("abort", () => messages.stop(), {
|
|
627
|
+
once: true,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
__classPrivateFieldGet(this, _Trellis_tasks, "f").add(`event:${eventName}:${(0, ulid_1.ulid)()}`, __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_handleDurableEvent).call(this, eventName, ctx, messages, fn));
|
|
632
|
+
return (0, result_1.ok)(undefined);
|
|
633
|
+
}
|
|
634
|
+
wait() {
|
|
635
|
+
return __classPrivateFieldGet(this, _Trellis_tasks, "f").wait();
|
|
636
|
+
}
|
|
637
|
+
// FIXME: If are validating things twice in most cases...
|
|
638
|
+
template(subject, data, allowWildcards = false) {
|
|
639
|
+
// Find all template placeholders and check if values exist
|
|
640
|
+
const placeholders = subject.match(/\{([^}]+)\}/g) || [];
|
|
641
|
+
for (const placeholder of placeholders) {
|
|
642
|
+
const key = placeholder.slice(1, -1); // Remove { and }
|
|
643
|
+
const value = value_1.Pointer.Get(data, key);
|
|
644
|
+
if ((value === undefined || value === null) && !allowWildcards) {
|
|
645
|
+
return (0, result_1.err)(new index_js_1.ValidationError({
|
|
646
|
+
errors: [
|
|
647
|
+
{
|
|
648
|
+
path: key,
|
|
649
|
+
message: "Missing required data for subject template",
|
|
650
|
+
},
|
|
651
|
+
],
|
|
652
|
+
context: { key },
|
|
653
|
+
}));
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const result = subject.replace(/\{([^}]+)\}/g, (_, key) => {
|
|
657
|
+
const value = value_1.Pointer.Get(data, key);
|
|
658
|
+
if (allowWildcards && value === "*") {
|
|
659
|
+
return "*";
|
|
660
|
+
}
|
|
661
|
+
if (allowWildcards && (value === undefined || value === null)) {
|
|
662
|
+
return "*";
|
|
663
|
+
}
|
|
664
|
+
return __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_escapeSubjectToken).call(this, `${value}`);
|
|
665
|
+
});
|
|
666
|
+
return (0, result_1.ok)(result);
|
|
667
|
+
}
|
|
668
|
+
async requestAuthValidate(input) {
|
|
669
|
+
const request = this.request.bind(this);
|
|
670
|
+
const result = await request("Auth.ValidateRequest", input);
|
|
671
|
+
return result;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
exports.Trellis = Trellis;
|
|
675
|
+
_Trellis_log = new WeakMap(), _Trellis_tasks = new WeakMap(), _Trellis_hasExplicitApi = new WeakMap(), _Trellis_noResponderMaxRetries = new WeakMap(), _Trellis_noResponderRetryMs = new WeakMap(), _Trellis_authBypassMethods = new WeakMap(), _Trellis_operationStore = new WeakMap(), _Trellis_instances = new WeakSet(), _Trellis_unknownApiError = function _Trellis_unknownApiError(kind, name) {
|
|
676
|
+
const base = `Unknown ${kind} '${name}'.`;
|
|
677
|
+
if (__classPrivateFieldGet(this, _Trellis_hasExplicitApi, "f")) {
|
|
678
|
+
return new Error(`${base} Did you forget to include its API module?`);
|
|
679
|
+
}
|
|
680
|
+
return new Error(`${base} No API surface was provided. Pass opts.api, use createClient(contract, ...), or await createCoreClient(...) instead.`);
|
|
681
|
+
}, _Trellis_handleRPC = function _Trellis_handleRPC(method, fn, subjectData = {}) {
|
|
682
|
+
// Get API details
|
|
683
|
+
const ctx = this.api["rpc"][method];
|
|
684
|
+
const subject = this.template(ctx.subject, subjectData, true).take();
|
|
685
|
+
if ((0, result_1.isErr)(subject)) {
|
|
686
|
+
return result_1.AsyncResult.lift(subject);
|
|
687
|
+
}
|
|
688
|
+
const handlerTrellis = this;
|
|
689
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").info({ method: String(method) }, `Mounting ${method.toString()} RPC handler`);
|
|
690
|
+
const sub = this.nats.subscribe(subject);
|
|
691
|
+
return result_1.AsyncResult.try(async () => {
|
|
692
|
+
for await (const msg of sub) {
|
|
693
|
+
const resultPromise = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_processRPCMessage).call(this, method, ctx, msg, fn, handlerTrellis);
|
|
694
|
+
const result = resultPromise.take();
|
|
695
|
+
if ((0, result_1.isErr)(result)) {
|
|
696
|
+
__classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_respondWithError).call(this, msg, result.error);
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
msg.respond(result);
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
}, _Trellis_processRPCMessage = async function _Trellis_processRPCMessage(method, ctx, msg, fn, handlerTrellis) {
|
|
703
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").debug({ method: String(method), subject: msg.subject }, "Processing RPC message");
|
|
704
|
+
// Extract trace context from incoming NATS headers
|
|
705
|
+
const parentContext = (0, tracing_js_1.extractTraceContext)((0, tracing_js_1.createNatsHeaderCarrier)({
|
|
706
|
+
get: (k) => msg.headers?.get(k) ?? undefined,
|
|
707
|
+
set: () => { }, // Server doesn't need to set headers on incoming messages
|
|
708
|
+
}));
|
|
709
|
+
// Start a server span for this RPC handler
|
|
710
|
+
const span = (0, tracing_js_1.startServerSpan)(method, msg.subject, parentContext);
|
|
711
|
+
// Execute the handler within the span's context
|
|
712
|
+
return (0, tracing_js_1.withSpanAsync)(span, async () => {
|
|
713
|
+
const execute = async () => {
|
|
714
|
+
const jsonData = safeJson(msg).take();
|
|
715
|
+
if ((0, result_1.isErr)(jsonData)) {
|
|
716
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").warn({ method, error: jsonData.error.message }, "Failed to parse JSON");
|
|
717
|
+
span.setStatus({
|
|
718
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
719
|
+
message: "Failed to parse JSON",
|
|
720
|
+
});
|
|
721
|
+
return jsonData;
|
|
722
|
+
}
|
|
723
|
+
const parsedInput = parseRuntimeSchema(ctx.input, jsonData).take();
|
|
724
|
+
if ((0, result_1.isErr)(parsedInput)) {
|
|
725
|
+
span.setStatus({
|
|
726
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
727
|
+
message: "Input validation failed",
|
|
728
|
+
});
|
|
729
|
+
return parsedInput;
|
|
730
|
+
}
|
|
731
|
+
let caller;
|
|
732
|
+
const callerSessionKey = msg.headers?.get("session-key") ?? "";
|
|
733
|
+
const authRequired = ctx.authRequired ?? true;
|
|
734
|
+
if (!authRequired || __classPrivateFieldGet(this, _Trellis_authBypassMethods, "f").has(method)) {
|
|
735
|
+
caller = {
|
|
736
|
+
type: "service",
|
|
737
|
+
id: "system",
|
|
738
|
+
active: true,
|
|
739
|
+
name: "System",
|
|
740
|
+
capabilities: ["service"],
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
const sessionKey = msg.headers?.get("session-key");
|
|
745
|
+
const proof = msg.headers?.get("proof");
|
|
746
|
+
if (!sessionKey) {
|
|
747
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").warn({ method }, "Missing session-key header");
|
|
748
|
+
span.setStatus({
|
|
749
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
750
|
+
message: "Missing session-key",
|
|
751
|
+
});
|
|
752
|
+
return (0, result_1.err)(new index_js_1.AuthError({ reason: "missing_session_key" }));
|
|
753
|
+
}
|
|
754
|
+
if (!proof) {
|
|
755
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").warn({ method }, "Missing proof in request");
|
|
756
|
+
span.setStatus({
|
|
757
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
758
|
+
message: "Missing proof",
|
|
759
|
+
});
|
|
760
|
+
return (0, result_1.err)(new index_js_1.AuthError({ reason: "missing_proof" }));
|
|
761
|
+
}
|
|
762
|
+
// Verify proof signature locally using the raw request bytes we received.
|
|
763
|
+
const payloadBytes = msg.data ?? new Uint8Array();
|
|
764
|
+
const payloadHash = await sha256(payloadBytes);
|
|
765
|
+
const proofInput = buildProofInput(sessionKey, msg.subject, payloadHash);
|
|
766
|
+
const digest = await sha256(proofInput);
|
|
767
|
+
const verifyResult = await result_1.AsyncResult.try(async () => {
|
|
768
|
+
const publicKeyRaw = base64urlDecode(sessionKey);
|
|
769
|
+
const pub = await crypto.subtle.importKey("raw", toArrayBuffer(publicKeyRaw), { name: "Ed25519" }, true, ["verify"]);
|
|
770
|
+
return crypto.subtle.verify({ name: "Ed25519" }, pub, toArrayBuffer(base64urlDecode(proof)), toArrayBuffer(digest));
|
|
771
|
+
});
|
|
772
|
+
const signatureOk = verifyResult.isOk() &&
|
|
773
|
+
(await verifyResult).take() === true;
|
|
774
|
+
if (!signatureOk) {
|
|
775
|
+
span.setStatus({
|
|
776
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
777
|
+
message: "Invalid signature",
|
|
778
|
+
});
|
|
779
|
+
return (0, result_1.err)(new index_js_1.AuthError({
|
|
780
|
+
reason: "invalid_signature",
|
|
781
|
+
context: { sessionKey },
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
784
|
+
let auth;
|
|
785
|
+
for (let attempt = 0; attempt < DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS; attempt++) {
|
|
786
|
+
const authResult = await this.requestAuthValidate({
|
|
787
|
+
sessionKey,
|
|
788
|
+
proof,
|
|
789
|
+
subject: msg.subject,
|
|
790
|
+
payloadHash: base64urlEncode(payloadHash),
|
|
791
|
+
capabilities: [...ctx.callerCapabilities],
|
|
792
|
+
});
|
|
793
|
+
const authValue = authResult.take();
|
|
794
|
+
if (!(0, result_1.isErr)(authValue)) {
|
|
795
|
+
auth = authValue;
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
const authError = authValue.error;
|
|
799
|
+
if (!isTransientAuthValidateSessionError(authError) ||
|
|
800
|
+
attempt === DEFAULT_AUTH_VALIDATE_SESSION_RETRY_ATTEMPTS - 1) {
|
|
801
|
+
auth = authError;
|
|
802
|
+
break;
|
|
803
|
+
}
|
|
804
|
+
await sleep(DEFAULT_AUTH_VALIDATE_SESSION_RETRY_MS * (attempt + 1));
|
|
805
|
+
}
|
|
806
|
+
if (!auth) {
|
|
807
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({
|
|
808
|
+
context: { reason: "missing_auth_validate_result" },
|
|
809
|
+
}));
|
|
810
|
+
}
|
|
811
|
+
if (auth instanceof Error) {
|
|
812
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").warn({
|
|
813
|
+
method,
|
|
814
|
+
error: auth.message,
|
|
815
|
+
errorType: auth.name,
|
|
816
|
+
remoteError: auth instanceof RemoteError_js_1.RemoteError
|
|
817
|
+
? auth.toSerializable()
|
|
818
|
+
: undefined,
|
|
819
|
+
}, "Auth.ValidateRequest failed");
|
|
820
|
+
span.setStatus({
|
|
821
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
822
|
+
message: "Auth.ValidateRequest failed",
|
|
823
|
+
});
|
|
824
|
+
if (auth instanceof result_1.BaseError) {
|
|
825
|
+
return (0, result_1.err)(auth);
|
|
826
|
+
}
|
|
827
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({ cause: auth }));
|
|
828
|
+
}
|
|
829
|
+
if (!auth.allowed) {
|
|
830
|
+
span.setStatus({
|
|
831
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
832
|
+
message: "Insufficient permissions",
|
|
833
|
+
});
|
|
834
|
+
return (0, result_1.err)(new index_js_1.AuthError({
|
|
835
|
+
reason: "insufficient_permissions",
|
|
836
|
+
context: {
|
|
837
|
+
requiredCapabilities: ctx.callerCapabilities,
|
|
838
|
+
userCapabilities: auth.caller.capabilities,
|
|
839
|
+
},
|
|
840
|
+
}));
|
|
841
|
+
}
|
|
842
|
+
if (typeof msg.reply !== "string" ||
|
|
843
|
+
!msg.reply.startsWith(`${auth.inboxPrefix}.`)) {
|
|
844
|
+
span.setStatus({
|
|
845
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
846
|
+
message: "Reply subject mismatch",
|
|
847
|
+
});
|
|
848
|
+
return (0, result_1.err)(new index_js_1.AuthError({
|
|
849
|
+
reason: "reply_subject_mismatch",
|
|
850
|
+
context: { expected: auth.inboxPrefix, actual: msg.reply },
|
|
851
|
+
}));
|
|
852
|
+
}
|
|
853
|
+
caller = auth.caller;
|
|
854
|
+
}
|
|
855
|
+
span.setAttribute("auth.caller.type", caller.type);
|
|
856
|
+
if (caller.type === "user") {
|
|
857
|
+
span.setAttribute("user.id", caller.id);
|
|
858
|
+
span.setAttribute("user.origin", caller.origin);
|
|
859
|
+
}
|
|
860
|
+
if (caller.type === "service") {
|
|
861
|
+
span.setAttribute("service.id", caller.id);
|
|
862
|
+
}
|
|
863
|
+
if (caller.type === "device") {
|
|
864
|
+
span.setAttribute("device.id", caller.deviceId);
|
|
865
|
+
span.setAttribute("device.profile_id", caller.profileId);
|
|
866
|
+
}
|
|
867
|
+
const invokeHandler = fn;
|
|
868
|
+
const handlerResultWrapped = await result_1.AsyncResult.try(async () => await Promise.resolve(invokeHandler(parsedInput, {
|
|
869
|
+
caller,
|
|
870
|
+
sessionKey: callerSessionKey,
|
|
871
|
+
}, handlerTrellis)));
|
|
872
|
+
if (handlerResultWrapped.isErr()) {
|
|
873
|
+
const error = handlerResultWrapped.error.withContext({ method });
|
|
874
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({
|
|
875
|
+
method,
|
|
876
|
+
error: error.message,
|
|
877
|
+
cause: error.cause instanceof Error
|
|
878
|
+
? { message: error.cause.message, stack: error.cause.stack }
|
|
879
|
+
: error.cause,
|
|
880
|
+
}, "Handler threw unexpectedly.");
|
|
881
|
+
span.setStatus({
|
|
882
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
883
|
+
message: error.message,
|
|
884
|
+
});
|
|
885
|
+
span.recordException(error);
|
|
886
|
+
return (0, result_1.err)(error);
|
|
887
|
+
}
|
|
888
|
+
const handlerResult = (await handlerResultWrapped).take();
|
|
889
|
+
const handlerOutcome = handlerResult.take();
|
|
890
|
+
if ((0, result_1.isErr)(handlerOutcome)) {
|
|
891
|
+
const handlerError = handlerOutcome.error;
|
|
892
|
+
const error = handlerError instanceof result_1.BaseError &&
|
|
893
|
+
!(handlerError instanceof RemoteError_js_1.RemoteError)
|
|
894
|
+
? handlerError
|
|
895
|
+
: new index_js_1.UnexpectedError({ cause: handlerError });
|
|
896
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({
|
|
897
|
+
method,
|
|
898
|
+
error: error.message,
|
|
899
|
+
errorType: error.name,
|
|
900
|
+
cause: error.cause instanceof Error
|
|
901
|
+
? { message: error.cause.message, stack: error.cause.stack }
|
|
902
|
+
: error.cause,
|
|
903
|
+
}, "Handler returned error.");
|
|
904
|
+
span.setStatus({
|
|
905
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
906
|
+
message: error.message,
|
|
907
|
+
});
|
|
908
|
+
return (0, result_1.err)(error);
|
|
909
|
+
}
|
|
910
|
+
const encoded = (0, codec_js_1.encodeSchema)(ctx.output, handlerOutcome).take();
|
|
911
|
+
if ((0, result_1.isErr)(encoded)) {
|
|
912
|
+
span.setStatus({
|
|
913
|
+
code: tracing_js_1.SpanStatusCode.ERROR,
|
|
914
|
+
message: "Output encoding failed",
|
|
915
|
+
});
|
|
916
|
+
return encoded;
|
|
917
|
+
}
|
|
918
|
+
span.setStatus({ code: tracing_js_1.SpanStatusCode.OK });
|
|
919
|
+
return (0, result_1.ok)(encoded);
|
|
920
|
+
};
|
|
921
|
+
const result = await execute();
|
|
922
|
+
span.end();
|
|
923
|
+
return result;
|
|
924
|
+
});
|
|
925
|
+
}, _Trellis_respondWithError = function _Trellis_respondWithError(msg, error) {
|
|
926
|
+
const trellisError = error instanceof result_1.BaseError &&
|
|
927
|
+
!(error instanceof RemoteError_js_1.RemoteError)
|
|
928
|
+
? error
|
|
929
|
+
: new index_js_1.UnexpectedError({ cause: error });
|
|
930
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({ error: trellisError.toSerializable() }, "RPC error");
|
|
931
|
+
const errorData = trellisError.toSerializable();
|
|
932
|
+
const hdrs = (0, nats_core_1.headers)();
|
|
933
|
+
hdrs.set("status", "error");
|
|
934
|
+
const serialized = result_1.Result.try(() => JSON.stringify(errorData));
|
|
935
|
+
if (serialized.isErr()) {
|
|
936
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({ error: serialized.error }, "Failed to serialize error response");
|
|
937
|
+
msg.respond('{"type":"UnexpectedError","message":"Failed to serialize error"}', { headers: hdrs });
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
msg.respond(serialized.take(), { headers: hdrs });
|
|
941
|
+
}, _Trellis_startEphemeralEvent = function _Trellis_startEphemeralEvent(event, ctx, subject, fn, signal) {
|
|
942
|
+
const sub = this.nats.subscribe(subject);
|
|
943
|
+
if (signal) {
|
|
944
|
+
if (signal.aborted) {
|
|
945
|
+
sub.unsubscribe();
|
|
946
|
+
return (0, result_1.ok)(undefined);
|
|
947
|
+
}
|
|
948
|
+
signal.addEventListener("abort", () => sub.unsubscribe(), { once: true });
|
|
949
|
+
}
|
|
950
|
+
const task = result_1.AsyncResult.try(async () => {
|
|
951
|
+
for await (const msg of sub) {
|
|
952
|
+
const parsedEvent = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_parseEventMessage).call(this, event, ctx, msg);
|
|
953
|
+
const m = parsedEvent.take();
|
|
954
|
+
if ((0, result_1.isErr)(m)) {
|
|
955
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({ error: m.error }, "Event validation failed");
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
const handlerResult = await result_1.AsyncResult.lift(fn(m));
|
|
959
|
+
if (handlerResult.isErr()) {
|
|
960
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({
|
|
961
|
+
error: handlerResult.error.toSerializable(),
|
|
962
|
+
event,
|
|
963
|
+
subject: msg.subject,
|
|
964
|
+
}, "Event handler failed");
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
__classPrivateFieldGet(this, _Trellis_tasks, "f").add(`event:${event}:${(0, ulid_1.ulid)()}`, task);
|
|
969
|
+
return (0, result_1.ok)(undefined);
|
|
970
|
+
}, _Trellis_handleDurableEvent = function _Trellis_handleDurableEvent(event, ctx, messages, fn) {
|
|
971
|
+
return result_1.AsyncResult.try(async () => {
|
|
972
|
+
for await (const msg of messages) {
|
|
973
|
+
const parsedEvent = __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_parseEventMessage).call(this, event, ctx, msg);
|
|
974
|
+
const m = parsedEvent.take();
|
|
975
|
+
if ((0, result_1.isErr)(m)) {
|
|
976
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({ error: m.error }, "Event validation failed");
|
|
977
|
+
msg.term();
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
const handlerResult = await result_1.AsyncResult.lift(fn(m));
|
|
981
|
+
if (handlerResult.isErr()) {
|
|
982
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({
|
|
983
|
+
error: handlerResult.error.toSerializable(),
|
|
984
|
+
event,
|
|
985
|
+
subject: msg.subject,
|
|
986
|
+
}, "Event handler failed");
|
|
987
|
+
msg.nak();
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
msg.ack();
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}, _Trellis_parseEventMessage = function _Trellis_parseEventMessage(event, ctx, msg) {
|
|
994
|
+
const jsonData = result_1.Result.try(() => msg.json());
|
|
995
|
+
const json = jsonData.take();
|
|
996
|
+
if ((0, result_1.isErr)(json)) {
|
|
997
|
+
__classPrivateFieldGet(this, _Trellis_log, "f").error({ error: json.error, event, subject: msg.subject }, "Event parse failed");
|
|
998
|
+
return json;
|
|
999
|
+
}
|
|
1000
|
+
return parseRuntimeSchema(ctx.event, json);
|
|
1001
|
+
}, _Trellis_escapeSubjectToken = function _Trellis_escapeSubjectToken(token) {
|
|
1002
|
+
const out = token.replace(NATS_SUBJECT_TOKEN_FORBIDDEN, (ch) => `~${ch.codePointAt(0).toString(16).toUpperCase()}~`);
|
|
1003
|
+
// Protect stapRet with $ due to NATS internal use of it
|
|
1004
|
+
if (out.length === 0 || out.startsWith("$")) {
|
|
1005
|
+
return `_${out}`;
|
|
1006
|
+
}
|
|
1007
|
+
return out;
|
|
1008
|
+
}, _Trellis_createProof = async function _Trellis_createProof(subject, payload) {
|
|
1009
|
+
const payloadBytes = new TextEncoder().encode(payload);
|
|
1010
|
+
const payloadHash = await sha256(payloadBytes);
|
|
1011
|
+
const input = buildProofInput(this.auth.sessionKey, subject, payloadHash);
|
|
1012
|
+
const digest = await sha256(input);
|
|
1013
|
+
const sigBytes = await this.auth.sign(digest);
|
|
1014
|
+
return base64urlEncode(sigBytes);
|
|
1015
|
+
}, _Trellis_requestJson = async function _Trellis_requestJson(subject, body) {
|
|
1016
|
+
const payload = JSON.stringify(body);
|
|
1017
|
+
const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, payload);
|
|
1018
|
+
const headers = (0, nats_core_1.headers)();
|
|
1019
|
+
headers.set("session-key", this.auth.sessionKey);
|
|
1020
|
+
headers.set("proof", proof);
|
|
1021
|
+
const response = await result_1.AsyncResult.try(() => this.nats.request(subject, payload, {
|
|
1022
|
+
timeout: this.timeout,
|
|
1023
|
+
headers,
|
|
1024
|
+
})).take();
|
|
1025
|
+
if ((0, result_1.isErr)(response)) {
|
|
1026
|
+
return response;
|
|
1027
|
+
}
|
|
1028
|
+
return safeJson(response);
|
|
1029
|
+
}, _Trellis_watchJson = async function _Trellis_watchJson(subject, body) {
|
|
1030
|
+
const payload = JSON.stringify(body);
|
|
1031
|
+
const proof = await __classPrivateFieldGet(this, _Trellis_instances, "m", _Trellis_createProof).call(this, subject, payload);
|
|
1032
|
+
const headers = (0, nats_core_1.headers)();
|
|
1033
|
+
headers.set("session-key", this.auth.sessionKey);
|
|
1034
|
+
headers.set("proof", proof);
|
|
1035
|
+
const inbox = (0, nats_core_1.createInbox)(`_INBOX.${this.auth.sessionKey.slice(0, 16)}`);
|
|
1036
|
+
const sub = this.nats.subscribe(inbox);
|
|
1037
|
+
try {
|
|
1038
|
+
this.nats.publish(subject, payload, {
|
|
1039
|
+
headers,
|
|
1040
|
+
reply: inbox,
|
|
1041
|
+
});
|
|
1042
|
+
await this.nats.flush();
|
|
1043
|
+
}
|
|
1044
|
+
catch (cause) {
|
|
1045
|
+
sub.unsubscribe();
|
|
1046
|
+
return (0, result_1.err)(new index_js_1.UnexpectedError({ cause }));
|
|
1047
|
+
}
|
|
1048
|
+
return (0, result_1.ok)((async function* () {
|
|
1049
|
+
try {
|
|
1050
|
+
for await (const msg of sub) {
|
|
1051
|
+
if (msg.headers?.get("status") === "error") {
|
|
1052
|
+
yield (0, result_1.err)(new index_js_1.UnexpectedError({ cause: new Error(msg.string()) }));
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
yield safeJson(msg);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
finally {
|
|
1059
|
+
sub.unsubscribe();
|
|
1060
|
+
}
|
|
1061
|
+
})());
|
|
1062
|
+
};
|