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