@qlever-llc/trellis 0.5.1 → 0.6.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 +16 -2
- package/esm/_dnt.polyfills.d.ts +11 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +14 -0
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/auth/browser/login.d.ts +27 -0
- package/esm/auth/browser/login.d.ts.map +1 -0
- package/esm/auth/browser/login.js +94 -0
- package/esm/auth/browser/portal.d.ts +11 -0
- package/esm/auth/browser/portal.d.ts.map +1 -0
- package/esm/auth/browser/portal.js +33 -0
- package/esm/auth/browser/session.d.ts +19 -0
- package/esm/auth/browser/session.d.ts.map +1 -0
- package/esm/auth/browser/session.js +65 -0
- package/esm/auth/browser/storage.d.ts +12 -0
- package/esm/auth/browser/storage.d.ts.map +1 -0
- package/esm/auth/browser/storage.js +61 -0
- package/esm/auth/browser.d.ts +13 -0
- package/esm/auth/browser.d.ts.map +1 -0
- package/esm/auth/browser.js +11 -0
- package/esm/auth/keys.d.ts +5 -0
- package/esm/auth/keys.d.ts.map +1 -0
- package/esm/auth/keys.js +50 -0
- package/esm/auth/mod.d.ts +18 -0
- package/esm/auth/mod.d.ts.map +1 -0
- package/esm/auth/mod.js +17 -0
- package/esm/auth/proof.d.ts +9 -0
- package/esm/auth/proof.d.ts.map +1 -0
- package/esm/auth/proof.js +43 -0
- package/esm/auth/protocol.d.ts +1212 -0
- package/esm/auth/protocol.d.ts.map +1 -0
- package/esm/auth/protocol.js +682 -0
- package/esm/auth/schemas.d.ts +93 -0
- package/esm/auth/schemas.d.ts.map +1 -0
- package/esm/auth/schemas.js +64 -0
- package/esm/auth/session_auth.d.ts +20 -0
- package/esm/auth/session_auth.d.ts.map +1 -0
- package/esm/auth/session_auth.js +42 -0
- package/esm/auth/trellis_id.d.ts +2 -0
- package/esm/auth/trellis_id.d.ts.map +1 -0
- package/esm/auth/trellis_id.js +5 -0
- package/esm/auth/types.d.ts +8 -0
- package/esm/auth/types.d.ts.map +1 -0
- package/esm/auth/types.js +1 -0
- package/esm/auth/utils.d.ts +11 -0
- package/esm/auth/utils.d.ts.map +1 -0
- package/esm/auth/utils.js +68 -0
- package/esm/auth/workload_activation.d.ts +192 -0
- package/esm/auth/workload_activation.d.ts.map +1 -0
- package/esm/auth/workload_activation.js +290 -0
- package/esm/contracts/canonical.d.ts +14 -0
- package/esm/contracts/canonical.d.ts.map +1 -0
- package/esm/contracts/canonical.js +135 -0
- package/esm/contracts/mod.d.ts +462 -0
- package/esm/contracts/mod.d.ts.map +1 -0
- package/esm/contracts/mod.js +532 -0
- package/esm/contracts/protocol.d.ts +301 -0
- package/esm/contracts/protocol.d.ts.map +1 -0
- package/esm/contracts/protocol.js +130 -0
- package/esm/contracts/runtime.d.ts +48 -0
- package/esm/contracts/runtime.d.ts.map +1 -0
- package/esm/contracts/runtime.js +9 -0
- package/esm/contracts/schema_pointers.d.ts +18 -0
- package/esm/contracts/schema_pointers.d.ts.map +1 -0
- package/esm/contracts/schema_pointers.js +59 -0
- package/esm/server/deno.d.ts +7 -0
- package/esm/server/deno.d.ts.map +1 -0
- package/esm/server/deno.js +16 -0
- package/esm/server/health.d.ts +92 -0
- package/esm/server/health.d.ts.map +1 -0
- package/esm/server/health.js +74 -0
- package/esm/server/health_rpc.d.ts +16 -0
- package/esm/server/health_rpc.d.ts.map +1 -0
- package/esm/server/health_rpc.js +23 -0
- package/esm/server/health_schemas.d.ts +20 -0
- package/esm/server/health_schemas.d.ts.map +1 -0
- package/esm/server/health_schemas.js +18 -0
- package/esm/server/mod.d.ts +17 -0
- package/esm/server/mod.d.ts.map +1 -0
- package/esm/server/mod.js +17 -0
- package/esm/server/node.d.ts +7 -0
- package/esm/server/node.d.ts.map +1 -0
- package/esm/server/node.js +16 -0
- package/esm/server/runtime.d.ts +16 -0
- package/esm/server/runtime.d.ts.map +1 -0
- package/esm/server/runtime.js +1 -0
- package/esm/server/service.d.ts +121 -0
- package/esm/server/service.d.ts.map +1 -0
- package/esm/server/service.js +256 -0
- package/esm/server/subscription.d.ts +99 -0
- package/esm/server/subscription.d.ts.map +1 -0
- package/esm/server/subscription.js +25 -0
- package/esm/telemetry/carrier.d.ts +9 -0
- package/esm/telemetry/carrier.d.ts.map +1 -0
- package/esm/telemetry/carrier.js +20 -0
- package/esm/telemetry/core.d.ts +8 -0
- package/esm/telemetry/core.d.ts.map +1 -0
- package/esm/telemetry/core.js +14 -0
- package/esm/telemetry/env.d.ts +2 -0
- package/esm/telemetry/env.d.ts.map +1 -0
- package/esm/telemetry/env.js +10 -0
- package/esm/telemetry/mod.d.ts +11 -0
- package/esm/telemetry/mod.d.ts.map +1 -0
- package/esm/telemetry/mod.js +7 -0
- package/esm/telemetry/nats.d.ts +7 -0
- package/esm/telemetry/nats.d.ts.map +1 -0
- package/esm/telemetry/nats.js +6 -0
- package/esm/telemetry/result.d.ts +2 -0
- package/esm/telemetry/result.d.ts.map +1 -0
- package/esm/telemetry/result.js +18 -0
- package/esm/telemetry/runtime.d.ts +2 -0
- package/esm/telemetry/runtime.d.ts.map +1 -0
- package/esm/telemetry/runtime.js +53 -0
- package/esm/telemetry/trace.d.ts +5 -0
- package/esm/telemetry/trace.d.ts.map +1 -0
- package/esm/telemetry/trace.js +26 -0
- package/esm/telemetry/trellis.d.ts +3 -0
- package/esm/telemetry/trellis.d.ts.map +1 -0
- package/esm/telemetry/trellis.js +7 -0
- package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
- package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/_dnt.polyfills.js +15 -0
- package/esm/trellis/_sdk/activity/api.d.ts +10 -0
- package/esm/trellis/_sdk/activity/api.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/api.js +43 -0
- package/esm/trellis/_sdk/activity/contract.d.ts +8 -0
- package/esm/trellis/_sdk/activity/contract.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/contract.js +59 -0
- package/esm/trellis/_sdk/activity/mod.d.ts +7 -0
- package/esm/trellis/_sdk/activity/mod.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/mod.js +5 -0
- package/esm/trellis/_sdk/activity/package.json +3 -0
- package/esm/trellis/_sdk/activity/schemas.d.ts +607 -0
- package/esm/trellis/_sdk/activity/schemas.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/schemas.js +33 -0
- package/esm/trellis/_sdk/activity/types.d.ts +96 -0
- package/esm/trellis/_sdk/activity/types.d.ts.map +1 -0
- package/esm/trellis/_sdk/activity/types.js +3 -0
- package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
- package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/_dnt.polyfills.js +15 -0
- package/esm/trellis/_sdk/auth/api.d.ts +10 -0
- package/esm/trellis/_sdk/auth/api.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/api.js +354 -0
- package/esm/trellis/_sdk/auth/contract.d.ts +28 -0
- package/esm/trellis/_sdk/auth/contract.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/contract.js +83 -0
- package/esm/trellis/_sdk/auth/mod.d.ts +7 -0
- package/esm/trellis/_sdk/auth/mod.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/mod.js +5 -0
- package/esm/trellis/_sdk/auth/package.json +3 -0
- package/esm/trellis/_sdk/auth/schemas.d.ts +8967 -0
- package/esm/trellis/_sdk/auth/schemas.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/schemas.js +306 -0
- package/esm/trellis/_sdk/auth/types.d.ts +1232 -0
- package/esm/trellis/_sdk/auth/types.d.ts.map +1 -0
- package/esm/trellis/_sdk/auth/types.js +3 -0
- package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
- package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/_dnt.polyfills.js +15 -0
- package/esm/trellis/_sdk/core/api.d.ts +10 -0
- package/esm/trellis/_sdk/core/api.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/api.js +36 -0
- package/esm/trellis/_sdk/core/contract.d.ts +8 -0
- package/esm/trellis/_sdk/core/contract.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/contract.js +59 -0
- package/esm/trellis/_sdk/core/mod.d.ts +7 -0
- package/esm/trellis/_sdk/core/mod.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/mod.js +5 -0
- package/esm/trellis/_sdk/core/package.json +3 -0
- package/esm/trellis/_sdk/core/schemas.d.ts +1144 -0
- package/esm/trellis/_sdk/core/schemas.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/schemas.js +28 -0
- package/esm/trellis/_sdk/core/types.d.ts +176 -0
- package/esm/trellis/_sdk/core/types.d.ts.map +1 -0
- package/esm/trellis/_sdk/core/types.js +3 -0
- package/esm/trellis/auth/browser.d.ts +3 -0
- package/esm/trellis/auth/browser.d.ts.map +1 -0
- package/esm/trellis/auth/browser.js +2 -0
- package/esm/trellis/auth.d.ts +3 -0
- package/esm/trellis/auth.d.ts.map +1 -0
- package/esm/trellis/auth.js +2 -0
- package/esm/trellis/browser.d.ts +2 -7
- package/esm/trellis/browser.d.ts.map +1 -1
- package/esm/trellis/browser.js +2 -7
- package/esm/trellis/client.d.ts +6 -4
- package/esm/trellis/client.d.ts.map +1 -1
- package/esm/trellis/client.js +28 -1
- package/esm/trellis/codec.d.ts +4 -3
- package/esm/trellis/codec.d.ts.map +1 -1
- package/esm/trellis/codec.js +15 -2
- package/esm/trellis/contract.d.ts +11 -0
- package/esm/trellis/contract.d.ts.map +1 -0
- package/esm/trellis/contract.js +15 -0
- package/esm/trellis/contracts.d.ts +5 -0
- package/esm/trellis/contracts.d.ts.map +1 -0
- package/esm/trellis/contracts.js +3 -0
- package/esm/trellis/env.d.ts +1 -1
- package/esm/trellis/env.d.ts.map +1 -1
- package/esm/trellis/env.js +1 -1
- package/esm/trellis/errors/AuthError.d.ts +1 -1
- package/esm/trellis/errors/AuthError.d.ts.map +1 -1
- package/esm/trellis/errors/AuthError.js +11 -0
- package/esm/trellis/errors/RemoteError.d.ts +3 -3
- package/esm/trellis/errors/RemoteError.d.ts.map +1 -1
- package/esm/trellis/errors/RemoteError.js +3 -3
- package/esm/trellis/errors/TrellisError.d.ts +1 -1
- package/esm/trellis/errors/TrellisError.js +1 -1
- package/esm/trellis/errors/index.d.ts +2 -1
- package/esm/trellis/errors/index.d.ts.map +1 -1
- package/esm/trellis/errors/index.js +3 -2
- package/esm/trellis/globals.d.ts +9 -1
- package/esm/trellis/globals.d.ts.map +1 -1
- package/esm/trellis/globals.js +16 -8
- package/esm/trellis/helpers.d.ts +2 -1
- package/esm/trellis/helpers.d.ts.map +1 -1
- package/esm/trellis/helpers.js +1 -0
- package/esm/trellis/index.d.ts +13 -5
- package/esm/trellis/index.d.ts.map +1 -1
- package/esm/trellis/index.js +8 -3
- package/esm/trellis/kv.d.ts +10 -7
- package/esm/trellis/kv.d.ts.map +1 -1
- package/esm/trellis/kv.js +57 -34
- package/esm/trellis/models/trellis/TrellisError.d.ts +1 -1
- package/esm/trellis/models/trellis/TrellisError.js +1 -1
- package/esm/trellis/operations.d.ts +81 -0
- package/esm/trellis/operations.d.ts.map +1 -0
- package/esm/trellis/operations.js +206 -0
- package/esm/trellis/sdk/activity.d.ts +3 -0
- package/esm/trellis/sdk/activity.d.ts.map +1 -0
- package/esm/trellis/sdk/activity.js +2 -0
- package/esm/trellis/sdk/auth.d.ts +4 -0
- package/esm/trellis/sdk/auth.d.ts.map +1 -0
- package/esm/trellis/sdk/auth.js +3 -0
- package/esm/trellis/sdk/core.d.ts +4 -0
- package/esm/trellis/sdk/core.d.ts.map +1 -0
- package/esm/trellis/sdk/core.js +3 -0
- package/esm/trellis/server/deno.d.ts +3 -0
- package/esm/trellis/server/deno.d.ts.map +1 -0
- package/esm/trellis/server/deno.js +2 -0
- package/esm/trellis/server/health.d.ts +5 -0
- package/esm/trellis/server/health.d.ts.map +1 -0
- package/esm/trellis/server/health.js +3 -0
- package/esm/trellis/server/mod.d.ts +3 -0
- package/esm/trellis/server/mod.d.ts.map +1 -0
- package/esm/trellis/server/mod.js +2 -0
- package/esm/trellis/server/node.d.ts +3 -0
- package/esm/trellis/server/node.d.ts.map +1 -0
- package/esm/trellis/server/node.js +2 -0
- package/esm/trellis/server/runtime.d.ts +4 -0
- package/esm/trellis/server/runtime.d.ts.map +1 -0
- package/esm/trellis/server/runtime.js +2 -0
- package/esm/trellis/server.d.ts +21 -0
- package/esm/trellis/server.d.ts.map +1 -0
- package/esm/trellis/server.js +536 -0
- package/esm/trellis/server_logger.d.ts +3 -0
- package/esm/trellis/server_logger.d.ts.map +1 -0
- package/esm/trellis/server_logger.js +7 -0
- package/esm/trellis/tasks.d.ts +3 -3
- package/esm/trellis/tasks.d.ts.map +1 -1
- package/esm/trellis/tasks.js +1 -1
- package/esm/trellis/tracing.d.ts +2 -2
- package/esm/trellis/tracing.d.ts.map +1 -1
- package/esm/trellis/tracing.js +2 -2
- package/esm/trellis/trellis.d.ts +167 -78
- package/esm/trellis/trellis.d.ts.map +1 -1
- package/esm/trellis/trellis.js +281 -87
- package/esm/trellis/workload.d.ts +45 -0
- package/esm/trellis/workload.d.ts.map +1 -0
- package/esm/trellis/workload.js +144 -0
- package/package.json +63 -4
- package/script/auth/browser/login.d.ts +27 -0
- package/script/auth/browser/login.d.ts.map +1 -0
- package/script/auth/browser/login.js +100 -0
- package/script/auth/browser/portal.d.ts +11 -0
- package/script/auth/browser/portal.d.ts.map +1 -0
- package/script/auth/browser/portal.js +40 -0
- package/script/auth/browser/session.d.ts +19 -0
- package/script/auth/browser/session.d.ts.map +1 -0
- package/script/auth/browser/session.js +79 -0
- package/script/auth/browser/storage.d.ts +12 -0
- package/script/auth/browser/storage.d.ts.map +1 -0
- package/script/auth/browser/storage.js +67 -0
- package/script/auth/browser.d.ts +13 -0
- package/script/auth/browser.d.ts.map +1 -0
- package/script/auth/browser.js +46 -0
- package/script/auth/keys.d.ts +5 -0
- package/script/auth/keys.d.ts.map +1 -0
- package/script/auth/keys.js +56 -0
- package/script/auth/mod.d.ts +18 -0
- package/script/auth/mod.d.ts.map +1 -0
- package/script/auth/mod.js +172 -0
- package/script/auth/proof.d.ts +9 -0
- package/script/auth/proof.d.ts.map +1 -0
- package/script/auth/proof.js +48 -0
- package/script/auth/protocol.d.ts +1212 -0
- package/script/auth/protocol.d.ts.map +1 -0
- package/script/auth/protocol.js +687 -0
- package/script/auth/schemas.d.ts +93 -0
- package/script/auth/schemas.d.ts.map +1 -0
- package/script/auth/schemas.js +67 -0
- package/script/auth/session_auth.d.ts +20 -0
- package/script/auth/session_auth.d.ts.map +1 -0
- package/script/auth/session_auth.js +45 -0
- package/script/auth/trellis_id.d.ts +2 -0
- package/script/auth/trellis_id.d.ts.map +1 -0
- package/script/auth/trellis_id.js +8 -0
- package/script/auth/types.d.ts +8 -0
- package/script/auth/types.d.ts.map +1 -0
- package/script/auth/utils.d.ts +11 -0
- package/script/auth/utils.d.ts.map +1 -0
- package/script/auth/utils.js +77 -0
- package/script/auth/workload_activation.d.ts +192 -0
- package/script/auth/workload_activation.d.ts.map +1 -0
- package/script/auth/workload_activation.js +308 -0
- package/script/contracts/canonical.d.ts +14 -0
- package/script/contracts/canonical.d.ts.map +1 -0
- package/script/contracts/canonical.js +144 -0
- package/script/contracts/mod.d.ts +462 -0
- package/script/contracts/mod.d.ts.map +1 -0
- package/script/contracts/mod.js +555 -0
- package/script/contracts/protocol.d.ts +301 -0
- package/script/contracts/protocol.d.ts.map +1 -0
- package/script/contracts/protocol.js +136 -0
- package/script/contracts/runtime.d.ts +48 -0
- package/script/contracts/runtime.d.ts.map +1 -0
- package/script/contracts/runtime.js +13 -0
- package/script/contracts/schema_pointers.d.ts +18 -0
- package/script/contracts/schema_pointers.d.ts.map +1 -0
- package/script/contracts/schema_pointers.js +63 -0
- package/script/telemetry/carrier.d.ts +9 -0
- package/script/telemetry/carrier.d.ts.map +1 -0
- package/script/telemetry/carrier.js +25 -0
- package/script/telemetry/core.d.ts +8 -0
- package/script/telemetry/core.d.ts.map +1 -0
- package/script/telemetry/core.js +24 -0
- package/script/telemetry/env.d.ts +2 -0
- package/script/telemetry/env.d.ts.map +1 -0
- package/script/telemetry/env.js +12 -0
- package/script/telemetry/mod.d.ts +11 -0
- package/script/telemetry/mod.d.ts.map +1 -0
- package/script/telemetry/mod.js +29 -0
- package/script/telemetry/nats.d.ts +7 -0
- package/script/telemetry/nats.d.ts.map +1 -0
- package/script/telemetry/nats.js +9 -0
- package/script/telemetry/result.d.ts +2 -0
- package/script/telemetry/result.d.ts.map +1 -0
- package/script/telemetry/result.js +21 -0
- package/script/telemetry/runtime.d.ts +2 -0
- package/script/telemetry/runtime.d.ts.map +1 -0
- package/script/telemetry/runtime.js +79 -0
- package/script/telemetry/trace.d.ts +5 -0
- package/script/telemetry/trace.d.ts.map +1 -0
- package/script/telemetry/trace.js +31 -0
- package/script/telemetry/trellis.d.ts +3 -0
- package/script/telemetry/trellis.d.ts.map +1 -0
- package/script/telemetry/trellis.js +14 -0
- package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
- package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/_dnt.polyfills.js +16 -0
- package/script/trellis/_sdk/activity/api.d.ts +10 -0
- package/script/trellis/_sdk/activity/api.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/api.js +46 -0
- package/script/trellis/_sdk/activity/contract.d.ts +8 -0
- package/script/trellis/_sdk/activity/contract.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/contract.js +62 -0
- package/script/trellis/_sdk/activity/mod.d.ts +7 -0
- package/script/trellis/_sdk/activity/mod.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/mod.js +30 -0
- package/script/trellis/_sdk/activity/package.json +3 -0
- package/script/trellis/_sdk/activity/schemas.d.ts +607 -0
- package/script/trellis/_sdk/activity/schemas.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/schemas.js +36 -0
- package/script/trellis/_sdk/activity/types.d.ts +96 -0
- package/script/trellis/_sdk/activity/types.d.ts.map +1 -0
- package/script/trellis/_sdk/activity/types.js +6 -0
- package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
- package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/_dnt.polyfills.js +16 -0
- package/script/trellis/_sdk/auth/api.d.ts +10 -0
- package/script/trellis/_sdk/auth/api.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/api.js +357 -0
- package/script/trellis/_sdk/auth/contract.d.ts +28 -0
- package/script/trellis/_sdk/auth/contract.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/contract.js +86 -0
- package/script/trellis/_sdk/auth/mod.d.ts +7 -0
- package/script/trellis/_sdk/auth/mod.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/mod.js +31 -0
- package/script/trellis/_sdk/auth/package.json +3 -0
- package/script/trellis/_sdk/auth/schemas.d.ts +8967 -0
- package/script/trellis/_sdk/auth/schemas.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/schemas.js +309 -0
- package/script/trellis/_sdk/auth/types.d.ts +1232 -0
- package/script/trellis/_sdk/auth/types.d.ts.map +1 -0
- package/script/trellis/_sdk/auth/types.js +6 -0
- package/script/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
- package/script/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
- package/script/trellis/_sdk/core/_dnt.polyfills.js +16 -0
- package/script/trellis/_sdk/core/api.d.ts +10 -0
- package/script/trellis/_sdk/core/api.d.ts.map +1 -0
- package/script/trellis/_sdk/core/api.js +39 -0
- package/script/trellis/_sdk/core/contract.d.ts +8 -0
- package/script/trellis/_sdk/core/contract.d.ts.map +1 -0
- package/script/trellis/_sdk/core/contract.js +62 -0
- package/script/trellis/_sdk/core/mod.d.ts +7 -0
- package/script/trellis/_sdk/core/mod.d.ts.map +1 -0
- package/script/trellis/_sdk/core/mod.js +30 -0
- package/script/trellis/_sdk/core/package.json +3 -0
- package/script/trellis/_sdk/core/schemas.d.ts +1144 -0
- package/script/trellis/_sdk/core/schemas.d.ts.map +1 -0
- package/script/trellis/_sdk/core/schemas.js +31 -0
- package/script/trellis/_sdk/core/types.d.ts +176 -0
- package/script/trellis/_sdk/core/types.d.ts.map +1 -0
- package/script/trellis/_sdk/core/types.js +6 -0
- package/script/trellis/auth.d.ts +2 -0
- package/script/trellis/auth.d.ts.map +1 -0
- package/script/trellis/auth.js +17 -0
- package/script/trellis/client.d.ts +8 -6
- package/script/trellis/client.d.ts.map +1 -1
- package/script/trellis/client.js +54 -3
- package/script/trellis/codec.d.ts +5 -4
- package/script/trellis/codec.d.ts.map +1 -1
- package/script/trellis/codec.js +31 -17
- package/script/trellis/contract.d.ts +11 -0
- package/script/trellis/contract.d.ts.map +1 -0
- package/script/trellis/contract.js +18 -0
- package/script/trellis/contracts.d.ts +4 -0
- package/script/trellis/contracts.d.ts.map +1 -0
- package/script/trellis/contracts.js +20 -0
- package/script/trellis/errors/AuthError.d.ts +2 -2
- package/script/trellis/errors/AuthError.d.ts.map +1 -1
- package/script/trellis/errors/AuthError.js +13 -2
- package/script/trellis/errors/KVError.d.ts +1 -1
- package/script/trellis/errors/KVError.d.ts.map +1 -1
- package/script/trellis/errors/KVError.js +2 -2
- package/script/trellis/errors/RemoteError.d.ts +4 -4
- package/script/trellis/errors/RemoteError.d.ts.map +1 -1
- package/script/trellis/errors/RemoteError.js +11 -11
- package/script/trellis/errors/TrellisError.d.ts +1 -1
- package/script/trellis/errors/TrellisError.d.ts.map +1 -1
- package/script/trellis/errors/TrellisError.js +2 -2
- package/script/trellis/errors/ValidationError.d.ts +1 -1
- package/script/trellis/errors/ValidationError.d.ts.map +1 -1
- package/script/trellis/errors/ValidationError.js +2 -2
- package/script/trellis/errors/index.d.ts +14 -14
- package/script/trellis/errors/index.d.ts.map +1 -1
- package/script/trellis/errors/index.js +31 -31
- package/script/trellis/globals.d.ts +9 -1
- package/script/trellis/globals.d.ts.map +1 -1
- package/script/trellis/globals.js +16 -8
- package/script/trellis/helpers.d.ts +1 -1
- package/script/trellis/helpers.d.ts.map +1 -1
- package/script/trellis/index.d.ts +17 -10
- package/script/trellis/index.d.ts.map +1 -1
- package/script/trellis/index.js +57 -22
- package/script/trellis/kv.d.ts +11 -8
- package/script/trellis/kv.d.ts.map +1 -1
- package/script/trellis/kv.js +91 -68
- package/script/trellis/models/trellis/TrellisError.d.ts +1 -1
- package/script/trellis/models/trellis/TrellisError.d.ts.map +1 -1
- package/script/trellis/models/trellis/TrellisError.js +8 -8
- package/script/trellis/operations.d.ts +81 -0
- package/script/trellis/operations.d.ts.map +1 -0
- package/script/trellis/operations.js +212 -0
- package/script/trellis/sdk/core.d.ts +3 -0
- package/script/trellis/sdk/core.d.ts.map +1 -0
- package/script/trellis/sdk/core.js +20 -0
- package/script/trellis/tasks.d.ts +3 -3
- package/script/trellis/tasks.d.ts.map +1 -1
- package/script/trellis/tasks.js +5 -5
- package/script/trellis/tracing.d.ts +2 -3
- package/script/trellis/tracing.d.ts.map +1 -1
- package/script/trellis/tracing.js +17 -20
- package/script/trellis/trellis.d.ts +169 -80
- package/script/trellis/trellis.d.ts.map +1 -1
- package/script/trellis/trellis.js +379 -177
- package/script/trellis/workload.d.ts +45 -0
- package/script/trellis/workload.d.ts.map +1 -0
- package/script/trellis/workload.js +172 -0
- package/script/_dnt.polyfills.d.ts +0 -7
- package/script/_dnt.polyfills.d.ts.map +0 -1
- package/script/trellis/browser.d.ts +0 -11
- package/script/trellis/browser.d.ts.map +0 -1
- package/script/trellis/browser.js +0 -21
- package/script/trellis/env.d.ts +0 -2
- package/script/trellis/env.d.ts.map +0 -1
- package/script/trellis/env.js +0 -5
- /package/script/{_dnt.polyfills.js → auth/types.js} +0 -0
|
@@ -0,0 +1,536 @@
|
|
|
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 _TrellisServer_instances, _TrellisServer_version, _TrellisServer_log, _TrellisServer_operations, _TrellisServer_resolveOperation, _TrellisServer_applyOperationUpdate;
|
|
13
|
+
import { AsyncResult, err, isErr, ok, } from "@qlever-llc/result";
|
|
14
|
+
import { ulid } from "ulid";
|
|
15
|
+
import { parseSchema } from "./codec.js";
|
|
16
|
+
import { AuthError, UnexpectedError, } from "./errors/index.js";
|
|
17
|
+
import { serverLogger } from "./server_logger.js";
|
|
18
|
+
import { base64urlDecode, base64urlEncode, buildProofInput, buildRuntimeOperationSnapshot, isResultLike, isTerminalRuntimeOperationSnapshot, safeJson, sha256, toArrayBuffer, Trellis, } from "./trellis.js";
|
|
19
|
+
export class TrellisServer extends Trellis {
|
|
20
|
+
constructor(name, nats, auth, opts) {
|
|
21
|
+
super(name, nats, auth, { ...opts, log: opts?.log ?? serverLogger });
|
|
22
|
+
_TrellisServer_instances.add(this);
|
|
23
|
+
_TrellisServer_version.set(this, void 0);
|
|
24
|
+
_TrellisServer_log.set(this, void 0);
|
|
25
|
+
_TrellisServer_operations.set(this, new Map());
|
|
26
|
+
Object.defineProperty(this, "operations", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
__classPrivateFieldSet(this, _TrellisServer_version, opts?.version, "f");
|
|
33
|
+
__classPrivateFieldSet(this, _TrellisServer_log, (opts?.log ?? serverLogger).child({ lib: "trellis-server" }), "f");
|
|
34
|
+
this.operations = {
|
|
35
|
+
get: async (operationId) => {
|
|
36
|
+
const runtime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, operationId);
|
|
37
|
+
if (!runtime) {
|
|
38
|
+
return err(new UnexpectedError({
|
|
39
|
+
cause: new Error(`Unknown operation '${operationId}'`),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return ok(runtime.snapshot);
|
|
43
|
+
},
|
|
44
|
+
started: async (operationId) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "running", {
|
|
45
|
+
event: { type: "started" },
|
|
46
|
+
}),
|
|
47
|
+
progress: async (operationId, progress) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "running", {
|
|
48
|
+
patch: { progress },
|
|
49
|
+
event: { type: "progress" },
|
|
50
|
+
}),
|
|
51
|
+
complete: async (operationId, output) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "completed", {
|
|
52
|
+
patch: { output },
|
|
53
|
+
event: { type: "completed" },
|
|
54
|
+
}),
|
|
55
|
+
fail: async (operationId, error) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "failed", {
|
|
56
|
+
patch: { error: { type: error.name, message: error.message } },
|
|
57
|
+
event: { type: "failed" },
|
|
58
|
+
}),
|
|
59
|
+
cancel: async (operationId) => __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_applyOperationUpdate).call(this, operationId, "cancelled", {
|
|
60
|
+
event: { type: "cancelled" },
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static create(name, nats, auth, opts) {
|
|
65
|
+
return new TrellisServer(name, nats, auth, opts);
|
|
66
|
+
}
|
|
67
|
+
operation(operation) {
|
|
68
|
+
const ctx = this.api["operations"]?.[operation];
|
|
69
|
+
if (!ctx) {
|
|
70
|
+
throw new Error(`Unknown operation '${operation.toString()}'. Did you forget to include its API module?`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
handle: async (handler) => {
|
|
74
|
+
const startSubject = ctx.subject;
|
|
75
|
+
const controlSubject = `${ctx.subject}.control`;
|
|
76
|
+
const now = () => new Date().toISOString();
|
|
77
|
+
const publishFrame = async (reply, frame) => {
|
|
78
|
+
await this.nats.publish(reply, JSON.stringify(frame));
|
|
79
|
+
};
|
|
80
|
+
const publishSnapshot = async (reply, snapshot) => {
|
|
81
|
+
await publishFrame(reply, { kind: "snapshot", snapshot });
|
|
82
|
+
};
|
|
83
|
+
const publishEventToWatchers = async (runtime, event) => {
|
|
84
|
+
const frame = { kind: "event", sequence: runtime.sequence, event };
|
|
85
|
+
for (const reply of runtime.watchers) {
|
|
86
|
+
await publishFrame(reply, frame);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const flushWaiters = async (runtime) => {
|
|
90
|
+
const frame = { kind: "snapshot", snapshot: runtime.snapshot };
|
|
91
|
+
for (const reply of runtime.waiters) {
|
|
92
|
+
await publishFrame(reply, frame);
|
|
93
|
+
}
|
|
94
|
+
runtime.waiters.clear();
|
|
95
|
+
};
|
|
96
|
+
const makeOperation = (runtime) => {
|
|
97
|
+
const ensureActive = () => {
|
|
98
|
+
if (runtime.terminal) {
|
|
99
|
+
return err(new UnexpectedError({
|
|
100
|
+
cause: new Error("operation already terminal"),
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
const transition = async (state, patch, event) => {
|
|
106
|
+
runtime.sequence += 1;
|
|
107
|
+
runtime.snapshot = buildRuntimeOperationSnapshot(runtime, state, patch);
|
|
108
|
+
await this.saveOperationRecord(runtime);
|
|
109
|
+
if (event) {
|
|
110
|
+
await publishEventToWatchers(runtime, event);
|
|
111
|
+
}
|
|
112
|
+
return ok(runtime.snapshot);
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
id: runtime.id,
|
|
116
|
+
started: async () => {
|
|
117
|
+
const active = ensureActive();
|
|
118
|
+
if (active)
|
|
119
|
+
return active;
|
|
120
|
+
return transition("running", undefined, {
|
|
121
|
+
type: "started",
|
|
122
|
+
snapshot: buildRuntimeOperationSnapshot(runtime, "running", {
|
|
123
|
+
revision: runtime.snapshot.revision + 1,
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
progress: async (value) => {
|
|
128
|
+
const active = ensureActive();
|
|
129
|
+
if (active)
|
|
130
|
+
return active;
|
|
131
|
+
return transition("running", { progress: value }, {
|
|
132
|
+
type: "progress",
|
|
133
|
+
snapshot: buildRuntimeOperationSnapshot(runtime, "running", {
|
|
134
|
+
revision: runtime.snapshot.revision + 1,
|
|
135
|
+
progress: value,
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
complete: async (value) => {
|
|
140
|
+
const active = ensureActive();
|
|
141
|
+
if (active)
|
|
142
|
+
return active;
|
|
143
|
+
const snapshot = buildRuntimeOperationSnapshot(runtime, "completed", {
|
|
144
|
+
output: value,
|
|
145
|
+
completedAt: now(),
|
|
146
|
+
});
|
|
147
|
+
runtime.sequence += 1;
|
|
148
|
+
runtime.snapshot = snapshot;
|
|
149
|
+
runtime.terminal = true;
|
|
150
|
+
await this.saveOperationRecord(runtime);
|
|
151
|
+
await publishEventToWatchers(runtime, {
|
|
152
|
+
type: "completed",
|
|
153
|
+
snapshot,
|
|
154
|
+
});
|
|
155
|
+
await flushWaiters(runtime);
|
|
156
|
+
return ok(snapshot);
|
|
157
|
+
},
|
|
158
|
+
fail: async (error) => {
|
|
159
|
+
const active = ensureActive();
|
|
160
|
+
if (active)
|
|
161
|
+
return active;
|
|
162
|
+
const snapshot = buildRuntimeOperationSnapshot(runtime, "failed", {
|
|
163
|
+
error: { type: error.name, message: error.message },
|
|
164
|
+
completedAt: now(),
|
|
165
|
+
});
|
|
166
|
+
runtime.sequence += 1;
|
|
167
|
+
runtime.snapshot = snapshot;
|
|
168
|
+
runtime.terminal = true;
|
|
169
|
+
await this.saveOperationRecord(runtime);
|
|
170
|
+
await publishEventToWatchers(runtime, {
|
|
171
|
+
type: "failed",
|
|
172
|
+
snapshot,
|
|
173
|
+
});
|
|
174
|
+
await flushWaiters(runtime);
|
|
175
|
+
return ok(snapshot);
|
|
176
|
+
},
|
|
177
|
+
cancel: async () => {
|
|
178
|
+
const active = ensureActive();
|
|
179
|
+
if (active)
|
|
180
|
+
return active;
|
|
181
|
+
const snapshot = buildRuntimeOperationSnapshot(runtime, "cancelled", {
|
|
182
|
+
completedAt: now(),
|
|
183
|
+
});
|
|
184
|
+
runtime.sequence += 1;
|
|
185
|
+
runtime.snapshot = snapshot;
|
|
186
|
+
runtime.terminal = true;
|
|
187
|
+
await this.saveOperationRecord(runtime);
|
|
188
|
+
await publishEventToWatchers(runtime, {
|
|
189
|
+
type: "cancelled",
|
|
190
|
+
snapshot,
|
|
191
|
+
});
|
|
192
|
+
await flushWaiters(runtime);
|
|
193
|
+
return ok(snapshot);
|
|
194
|
+
},
|
|
195
|
+
attach: async (job) => {
|
|
196
|
+
const waited = await job.wait();
|
|
197
|
+
const waitedValue = waited.take();
|
|
198
|
+
if (isErr(waitedValue)) {
|
|
199
|
+
return err(new UnexpectedError({ cause: waitedValue.error }));
|
|
200
|
+
}
|
|
201
|
+
const finalRuntime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, runtime.id);
|
|
202
|
+
if (!finalRuntime || !finalRuntime.terminal) {
|
|
203
|
+
return err(new UnexpectedError({
|
|
204
|
+
cause: new Error("attached job completed without terminal operation state"),
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
return ok(finalRuntime.snapshot);
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
const authenticate = async (msg, parseInput = true) => {
|
|
212
|
+
const jsonData = safeJson(msg).take();
|
|
213
|
+
if (isErr(jsonData))
|
|
214
|
+
return jsonData;
|
|
215
|
+
let parsedInput;
|
|
216
|
+
if (parseInput) {
|
|
217
|
+
const parsedInputResult = parseSchema(ctx.input, jsonData).take();
|
|
218
|
+
if (isErr(parsedInputResult)) {
|
|
219
|
+
return err(parsedInputResult.error);
|
|
220
|
+
}
|
|
221
|
+
parsedInput = parsedInputResult;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
parsedInput = jsonData;
|
|
225
|
+
}
|
|
226
|
+
const sessionKey = msg.headers?.get("session-key");
|
|
227
|
+
const proof = msg.headers?.get("proof");
|
|
228
|
+
if (!sessionKey) {
|
|
229
|
+
return err(new AuthError({ reason: "missing_session_key" }));
|
|
230
|
+
}
|
|
231
|
+
if (!proof)
|
|
232
|
+
return err(new AuthError({ reason: "missing_proof" }));
|
|
233
|
+
const payloadBytes = msg.data ?? new Uint8Array();
|
|
234
|
+
const payloadHash = await sha256(payloadBytes);
|
|
235
|
+
const proofInput = buildProofInput(sessionKey, msg.subject, payloadHash);
|
|
236
|
+
const digest = await sha256(proofInput);
|
|
237
|
+
const verifyResult = await AsyncResult.try(async () => {
|
|
238
|
+
const publicKeyRaw = base64urlDecode(sessionKey);
|
|
239
|
+
const pub = await crypto.subtle.importKey("raw", toArrayBuffer(publicKeyRaw), { name: "Ed25519" }, true, ["verify"]);
|
|
240
|
+
return crypto.subtle.verify({ name: "Ed25519" }, pub, toArrayBuffer(base64urlDecode(proof)), toArrayBuffer(digest));
|
|
241
|
+
});
|
|
242
|
+
const signatureOk = verifyResult.isOk() &&
|
|
243
|
+
(await verifyResult).take() === true;
|
|
244
|
+
if (!signatureOk) {
|
|
245
|
+
return err(new AuthError({
|
|
246
|
+
reason: "invalid_signature",
|
|
247
|
+
context: { sessionKey },
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
const authResult = await this.requestAuthValidate({
|
|
251
|
+
sessionKey,
|
|
252
|
+
proof,
|
|
253
|
+
subject: msg.subject,
|
|
254
|
+
payloadHash: base64urlEncode(payloadHash),
|
|
255
|
+
capabilities: ctx.callerCapabilities,
|
|
256
|
+
});
|
|
257
|
+
const auth = authResult.take();
|
|
258
|
+
if (isErr(auth)) {
|
|
259
|
+
return err(auth.error);
|
|
260
|
+
}
|
|
261
|
+
if (!auth.allowed) {
|
|
262
|
+
return err(new AuthError({
|
|
263
|
+
reason: "insufficient_permissions",
|
|
264
|
+
context: {
|
|
265
|
+
requiredCapabilities: ctx.callerCapabilities,
|
|
266
|
+
userCapabilities: auth.caller.capabilities,
|
|
267
|
+
},
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
if (typeof msg.reply !== "string" ||
|
|
271
|
+
!msg.reply.startsWith(`${auth.inboxPrefix}.`)) {
|
|
272
|
+
return err(new AuthError({
|
|
273
|
+
reason: "reply_subject_mismatch",
|
|
274
|
+
context: { expected: auth.inboxPrefix, actual: msg.reply },
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
return ok({
|
|
278
|
+
input: parsedInput,
|
|
279
|
+
caller: auth.caller,
|
|
280
|
+
sessionKey,
|
|
281
|
+
auth,
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
__classPrivateFieldGet(this, _TrellisServer_log, "f").info({ operation: String(operation) }, `Mounting ${String(operation)} operation handler`);
|
|
285
|
+
const startSub = this.nats.subscribe(startSubject);
|
|
286
|
+
const controlSub = this.nats.subscribe(controlSubject);
|
|
287
|
+
await this.nats.flush();
|
|
288
|
+
void (async () => {
|
|
289
|
+
for await (const msg of startSub) {
|
|
290
|
+
const validated = await authenticate(msg, true);
|
|
291
|
+
const value = validated.take();
|
|
292
|
+
if (isErr(value)) {
|
|
293
|
+
this.respondWithError(msg, value.error);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const operationId = ulid();
|
|
297
|
+
const createdAt = now();
|
|
298
|
+
const runtime = {
|
|
299
|
+
id: operationId,
|
|
300
|
+
service: this.name,
|
|
301
|
+
operation: String(operation),
|
|
302
|
+
ownerSessionKey: value.sessionKey,
|
|
303
|
+
snapshot: {
|
|
304
|
+
id: operationId,
|
|
305
|
+
service: this.name,
|
|
306
|
+
operation: String(operation),
|
|
307
|
+
revision: 1,
|
|
308
|
+
state: "pending",
|
|
309
|
+
createdAt,
|
|
310
|
+
updatedAt: createdAt,
|
|
311
|
+
},
|
|
312
|
+
sequence: 0,
|
|
313
|
+
terminal: false,
|
|
314
|
+
watchers: new Set(),
|
|
315
|
+
waiters: new Set(),
|
|
316
|
+
};
|
|
317
|
+
__classPrivateFieldGet(this, _TrellisServer_operations, "f").set(operationId, runtime);
|
|
318
|
+
await this.saveOperationRecord(runtime);
|
|
319
|
+
const accepted = {
|
|
320
|
+
kind: "accepted",
|
|
321
|
+
ref: {
|
|
322
|
+
id: operationId,
|
|
323
|
+
service: this.name,
|
|
324
|
+
operation: String(operation),
|
|
325
|
+
},
|
|
326
|
+
snapshot: runtime.snapshot,
|
|
327
|
+
};
|
|
328
|
+
msg.respond(JSON.stringify(accepted));
|
|
329
|
+
void (async () => {
|
|
330
|
+
const op = makeOperation(runtime);
|
|
331
|
+
try {
|
|
332
|
+
const handlerResult = await handler({
|
|
333
|
+
input: value.input,
|
|
334
|
+
op,
|
|
335
|
+
caller: value.caller,
|
|
336
|
+
});
|
|
337
|
+
const handlerOutcome = isResultLike(handlerResult)
|
|
338
|
+
? handlerResult.take()
|
|
339
|
+
: handlerResult;
|
|
340
|
+
if (isErr(handlerOutcome)) {
|
|
341
|
+
await op.fail(handlerOutcome.error);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (isTerminalRuntimeOperationSnapshot(handlerOutcome)) {
|
|
345
|
+
runtime.sequence = handlerOutcome.revision;
|
|
346
|
+
runtime.snapshot = handlerOutcome;
|
|
347
|
+
runtime.terminal = true;
|
|
348
|
+
await this.saveOperationRecord(runtime);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (!runtime.terminal) {
|
|
352
|
+
await op.complete(handlerOutcome);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (cause) {
|
|
356
|
+
await op.fail(new UnexpectedError({ cause }));
|
|
357
|
+
}
|
|
358
|
+
})();
|
|
359
|
+
}
|
|
360
|
+
})();
|
|
361
|
+
void (async () => {
|
|
362
|
+
for await (const msg of controlSub) {
|
|
363
|
+
const validated = await authenticate(msg, false);
|
|
364
|
+
const value = validated.take();
|
|
365
|
+
if (isErr(value)) {
|
|
366
|
+
this.respondWithError(msg, value.error);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const request = safeJson(msg).take();
|
|
370
|
+
if (isErr(request)) {
|
|
371
|
+
this.respondWithError(msg, request.error);
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (!request ||
|
|
375
|
+
typeof request !== "object" ||
|
|
376
|
+
typeof request.action !==
|
|
377
|
+
"string" ||
|
|
378
|
+
typeof request.operationId !==
|
|
379
|
+
"string") {
|
|
380
|
+
this.respondWithError(msg, new UnexpectedError({
|
|
381
|
+
cause: new Error("Invalid operation control request"),
|
|
382
|
+
}));
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const control = request;
|
|
386
|
+
const runtime = __classPrivateFieldGet(this, _TrellisServer_operations, "f").get(control.operationId);
|
|
387
|
+
const durableRecord = runtime
|
|
388
|
+
? null
|
|
389
|
+
: await this.loadOperationRecord(control.operationId);
|
|
390
|
+
if (!runtime && !durableRecord) {
|
|
391
|
+
this.respondWithError(msg, new UnexpectedError({
|
|
392
|
+
cause: new Error(`Unknown operation '${control.operationId}'`),
|
|
393
|
+
}));
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const snapshot = runtime?.snapshot ?? durableRecord.snapshot;
|
|
397
|
+
const ownerSessionKey = runtime?.ownerSessionKey ??
|
|
398
|
+
durableRecord.ownerSessionKey;
|
|
399
|
+
if (ownerSessionKey !== value.sessionKey) {
|
|
400
|
+
this.respondWithError(msg, new AuthError({
|
|
401
|
+
reason: "forbidden",
|
|
402
|
+
context: { ownerSessionKey },
|
|
403
|
+
}));
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
if (control.action === "watch") {
|
|
407
|
+
if (msg.reply) {
|
|
408
|
+
await publishSnapshot(msg.reply, snapshot);
|
|
409
|
+
if (!runtime)
|
|
410
|
+
continue;
|
|
411
|
+
runtime.watchers.add(msg.reply);
|
|
412
|
+
}
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (control.action === "wait") {
|
|
416
|
+
if (snapshot.state === "completed" || snapshot.state === "failed" ||
|
|
417
|
+
snapshot.state === "cancelled") {
|
|
418
|
+
msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
|
|
419
|
+
}
|
|
420
|
+
else if (runtime && msg.reply) {
|
|
421
|
+
runtime.waiters.add(msg.reply);
|
|
422
|
+
}
|
|
423
|
+
else if (msg.reply) {
|
|
424
|
+
this.respondWithError(msg, new UnexpectedError({
|
|
425
|
+
cause: new Error("operation is not running in this process"),
|
|
426
|
+
}));
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
this.respondWithError(msg, new UnexpectedError({
|
|
430
|
+
cause: new Error("missing reply subject for wait request"),
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if (control.action === "get") {
|
|
436
|
+
msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (control.action === "cancel") {
|
|
440
|
+
if (!runtime) {
|
|
441
|
+
msg.respond(JSON.stringify({ kind: "snapshot", snapshot }));
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
runtime.snapshot = {
|
|
445
|
+
...runtime.snapshot,
|
|
446
|
+
revision: runtime.snapshot.revision + 1,
|
|
447
|
+
state: "cancelled",
|
|
448
|
+
updatedAt: now(),
|
|
449
|
+
completedAt: now(),
|
|
450
|
+
};
|
|
451
|
+
runtime.terminal = true;
|
|
452
|
+
runtime.sequence += 1;
|
|
453
|
+
await this.saveOperationRecord(runtime);
|
|
454
|
+
await publishEventToWatchers(runtime, {
|
|
455
|
+
type: "cancelled",
|
|
456
|
+
snapshot: runtime.snapshot,
|
|
457
|
+
});
|
|
458
|
+
await flushWaiters(runtime);
|
|
459
|
+
msg.respond(JSON.stringify({
|
|
460
|
+
kind: "snapshot",
|
|
461
|
+
snapshot: runtime.snapshot,
|
|
462
|
+
}));
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
this.respondWithError(msg, new UnexpectedError({
|
|
466
|
+
cause: new Error(`Unknown operation control action '${control.action}'`),
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
})();
|
|
470
|
+
return Promise.resolve();
|
|
471
|
+
},
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
async stop() {
|
|
475
|
+
if (!this.natsConnection.isClosed()) {
|
|
476
|
+
await this.natsConnection.drain();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
_TrellisServer_version = new WeakMap(), _TrellisServer_log = new WeakMap(), _TrellisServer_operations = new WeakMap(), _TrellisServer_instances = new WeakSet(), _TrellisServer_resolveOperation = async function _TrellisServer_resolveOperation(operationId) {
|
|
481
|
+
const existing = __classPrivateFieldGet(this, _TrellisServer_operations, "f").get(operationId);
|
|
482
|
+
if (existing)
|
|
483
|
+
return existing;
|
|
484
|
+
const durable = await this.loadOperationRecord(operationId);
|
|
485
|
+
if (!durable)
|
|
486
|
+
return null;
|
|
487
|
+
const runtime = {
|
|
488
|
+
id: durable.snapshot.id,
|
|
489
|
+
service: durable.snapshot.service,
|
|
490
|
+
operation: durable.snapshot.operation,
|
|
491
|
+
ownerSessionKey: durable.ownerSessionKey,
|
|
492
|
+
snapshot: durable.snapshot,
|
|
493
|
+
sequence: durable.sequence,
|
|
494
|
+
terminal: durable.snapshot.state === "completed" ||
|
|
495
|
+
durable.snapshot.state === "failed" ||
|
|
496
|
+
durable.snapshot.state === "cancelled",
|
|
497
|
+
watchers: new Set(),
|
|
498
|
+
waiters: new Set(),
|
|
499
|
+
};
|
|
500
|
+
__classPrivateFieldGet(this, _TrellisServer_operations, "f").set(operationId, runtime);
|
|
501
|
+
return runtime;
|
|
502
|
+
}, _TrellisServer_applyOperationUpdate = async function _TrellisServer_applyOperationUpdate(operationId, state, opts) {
|
|
503
|
+
const runtime = await __classPrivateFieldGet(this, _TrellisServer_instances, "m", _TrellisServer_resolveOperation).call(this, operationId);
|
|
504
|
+
if (!runtime) {
|
|
505
|
+
return err(new UnexpectedError({
|
|
506
|
+
cause: new Error(`Unknown operation '${operationId}'`),
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
if (runtime.terminal && state !== "cancelled") {
|
|
510
|
+
return err(new UnexpectedError({ cause: new Error("operation already terminal") }));
|
|
511
|
+
}
|
|
512
|
+
runtime.sequence += 1;
|
|
513
|
+
runtime.snapshot = buildRuntimeOperationSnapshot(runtime, state, opts.patch);
|
|
514
|
+
runtime.terminal = state === "completed" || state === "failed" ||
|
|
515
|
+
state === "cancelled";
|
|
516
|
+
await this.saveOperationRecord(runtime);
|
|
517
|
+
const frame = {
|
|
518
|
+
kind: "event",
|
|
519
|
+
sequence: runtime.sequence,
|
|
520
|
+
event: {
|
|
521
|
+
type: opts.event.type,
|
|
522
|
+
snapshot: runtime.snapshot,
|
|
523
|
+
},
|
|
524
|
+
};
|
|
525
|
+
for (const reply of runtime.watchers) {
|
|
526
|
+
await this.nats.publish(reply, JSON.stringify(frame));
|
|
527
|
+
}
|
|
528
|
+
if (runtime.terminal) {
|
|
529
|
+
const terminalFrame = { kind: "snapshot", snapshot: runtime.snapshot };
|
|
530
|
+
for (const reply of runtime.waiters) {
|
|
531
|
+
await this.nats.publish(reply, JSON.stringify(terminalFrame));
|
|
532
|
+
}
|
|
533
|
+
runtime.waiters.clear();
|
|
534
|
+
}
|
|
535
|
+
return ok(runtime.snapshot);
|
|
536
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server_logger.d.ts","sourceRoot":"","sources":["../../src/trellis/server_logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,eAAO,MAAM,YAAY,EAAE,UAGzB,CAAC"}
|
package/esm/trellis/tasks.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AsyncResult, type BaseError } from "@qlever-llc/
|
|
2
|
-
import type
|
|
1
|
+
import { AsyncResult, type BaseError } from "@qlever-llc/result";
|
|
2
|
+
import { type LoggerLike } from "./globals.js";
|
|
3
3
|
export declare class TrellisTasks {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(opts: {
|
|
6
|
-
log?:
|
|
6
|
+
log?: LoggerLike;
|
|
7
7
|
});
|
|
8
8
|
add<E extends BaseError>(name: string, task: AsyncResult<void, E>): void;
|
|
9
9
|
wait(): AsyncResult<void, BaseError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/trellis/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/trellis/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAU,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvD,qBAAa,YAAY;;gBAKX,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,UAAU,CAAA;KAAE;IAOtC,GAAG,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAejE,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC;CAGrC"}
|
package/esm/trellis/tasks.js
CHANGED
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _TrellisTasks_tasks, _TrellisTasks_log;
|
|
13
|
-
import { AsyncResult, Result } from "@qlever-llc/
|
|
13
|
+
import { AsyncResult, Result } from "@qlever-llc/result";
|
|
14
14
|
import { logger } from "./globals.js";
|
|
15
15
|
export class TrellisTasks {
|
|
16
16
|
constructor(opts) {
|
package/esm/trellis/tracing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
|
-
export type { HeaderCarrier, NatsHeadersLike } from "
|
|
3
|
-
export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "
|
|
2
|
+
export type { HeaderCarrier, NatsHeadersLike } from "../telemetry/mod.js";
|
|
3
|
+
export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "../telemetry/mod.js";
|
|
4
4
|
export declare function initTracing(serviceName: string): void;
|
|
5
5
|
//# sourceMappingURL=tracing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/trellis/tracing.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAE9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/trellis/tracing.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAE9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAC,qBAAqB,EAC3B,OAAO,EACP,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EAAC,gBAAgB,IAAI,SAAS,EAC3C,kBAAkB,EAClB,QAAQ,EACR,cAAc,EAAC,eAAe,EAAE,eAAe,EAC/C,KAAK,EACL,QAAQ,EACR,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAErD"}
|
package/esm/trellis/tracing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Keep this subpath for Trellis-specific tracing convenience without exposing
|
|
2
2
|
// telemetry from the root `@qlever-llc/trellis` package surface.
|
|
3
3
|
import "../_dnt.polyfills.js";
|
|
4
|
-
export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "
|
|
4
|
+
export { configureErrorTraceId, context, createMapCarrier, createNatsHeaderCarrier, extractTraceContext, getActiveSpan, getTrellisTracer as getTracer, injectTraceContext, SpanKind, SpanStatusCode, startClientSpan, startServerSpan, trace, withSpan, withSpanAsync } from "../telemetry/mod.js";
|
|
5
5
|
export function initTracing(serviceName) {
|
|
6
|
-
void import("
|
|
6
|
+
void import("../telemetry/mod.js").then((mod) => mod.initTracing(serviceName));
|
|
7
7
|
}
|