@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,555 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unwrapSchema = exports.schema = exports.isJsonValue = exports.digestJson = exports.canonicalizeJson = exports.CATALOG_FORMAT_V1 = exports.CONTRACT_FORMAT_V1 = exports.StreamResourceBindingSchema = exports.PaginatedSchema = exports.KvResourceBindingSchema = exports.JobsResourceBindingSchema = exports.JobsQueueBindingSchema = exports.IsoDateSchema = exports.InstalledServiceContractSchema = exports.EventHeaderSchema = exports.ContractStreamResourceSchema = exports.ContractSchemaRefSchema = exports.ContractResourcesSchema = exports.ContractResourceBindingsSchema = exports.ContractKvResourceSchema = exports.ContractJobsResourceSchema = exports.ContractJobQueueResourceSchema = void 0;
|
|
4
|
+
exports.defineContract = defineContract;
|
|
5
|
+
const canonical_ts_1 = require("./canonical.ts");
|
|
6
|
+
Object.defineProperty(exports, "canonicalizeJson", { enumerable: true, get: function () { return canonical_ts_1.canonicalizeJson; } });
|
|
7
|
+
Object.defineProperty(exports, "digestJson", { enumerable: true, get: function () { return canonical_ts_1.digestJson; } });
|
|
8
|
+
Object.defineProperty(exports, "isJsonValue", { enumerable: true, get: function () { return canonical_ts_1.isJsonValue; } });
|
|
9
|
+
const runtime_ts_1 = require("./runtime.ts");
|
|
10
|
+
Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return runtime_ts_1.schema; } });
|
|
11
|
+
Object.defineProperty(exports, "unwrapSchema", { enumerable: true, get: function () { return runtime_ts_1.unwrapSchema; } });
|
|
12
|
+
const schema_pointers_ts_1 = require("./schema_pointers.ts");
|
|
13
|
+
var protocol_ts_1 = require("./protocol.ts");
|
|
14
|
+
Object.defineProperty(exports, "ContractJobQueueResourceSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractJobQueueResourceSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "ContractJobsResourceSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractJobsResourceSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "ContractKvResourceSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractKvResourceSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "ContractResourceBindingsSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractResourceBindingsSchema; } });
|
|
18
|
+
Object.defineProperty(exports, "ContractResourcesSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractResourcesSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "ContractSchemaRefSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractSchemaRefSchema; } });
|
|
20
|
+
Object.defineProperty(exports, "ContractStreamResourceSchema", { enumerable: true, get: function () { return protocol_ts_1.ContractStreamResourceSchema; } });
|
|
21
|
+
Object.defineProperty(exports, "EventHeaderSchema", { enumerable: true, get: function () { return protocol_ts_1.EventHeaderSchema; } });
|
|
22
|
+
Object.defineProperty(exports, "InstalledServiceContractSchema", { enumerable: true, get: function () { return protocol_ts_1.InstalledServiceContractSchema; } });
|
|
23
|
+
Object.defineProperty(exports, "IsoDateSchema", { enumerable: true, get: function () { return protocol_ts_1.IsoDateSchema; } });
|
|
24
|
+
Object.defineProperty(exports, "JobsQueueBindingSchema", { enumerable: true, get: function () { return protocol_ts_1.JobsQueueBindingSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "JobsResourceBindingSchema", { enumerable: true, get: function () { return protocol_ts_1.JobsResourceBindingSchema; } });
|
|
26
|
+
Object.defineProperty(exports, "KvResourceBindingSchema", { enumerable: true, get: function () { return protocol_ts_1.KvResourceBindingSchema; } });
|
|
27
|
+
Object.defineProperty(exports, "PaginatedSchema", { enumerable: true, get: function () { return protocol_ts_1.PaginatedSchema; } });
|
|
28
|
+
Object.defineProperty(exports, "StreamResourceBindingSchema", { enumerable: true, get: function () { return protocol_ts_1.StreamResourceBindingSchema; } });
|
|
29
|
+
exports.CONTRACT_FORMAT_V1 = "trellis.contract.v1";
|
|
30
|
+
exports.CATALOG_FORMAT_V1 = "trellis.catalog.v1";
|
|
31
|
+
const CONTRACT_MODULE_METADATA = Symbol.for("@qlever-llc/trellis-contracts/contract-module");
|
|
32
|
+
function cloneSchema(schemaValue) {
|
|
33
|
+
const cloned = JSON.parse(JSON.stringify(schemaValue));
|
|
34
|
+
if (!(0, canonical_ts_1.isJsonValue)(cloned)) {
|
|
35
|
+
throw new Error("Contract schema is not JSON-serializable");
|
|
36
|
+
}
|
|
37
|
+
return cloned;
|
|
38
|
+
}
|
|
39
|
+
function cloneSchemas(schemas) {
|
|
40
|
+
if (!schemas) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return Object.fromEntries(Object.entries(schemas).map(([name, schemaValue]) => [name, cloneSchema(schemaValue)]));
|
|
44
|
+
}
|
|
45
|
+
function assertSchemaRefExists(schemas, ref, context) {
|
|
46
|
+
if (!schemas || !Object.hasOwn(schemas, ref.schema)) {
|
|
47
|
+
throw new Error(`${context} references unknown schema '${ref.schema}'`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveSchemaRef(schemas, ref, context) {
|
|
51
|
+
assertSchemaRefExists(schemas, ref, context);
|
|
52
|
+
return cloneSchema(schemas[ref.schema]);
|
|
53
|
+
}
|
|
54
|
+
function digestCanonicalJson(value) {
|
|
55
|
+
return (0, canonical_ts_1.sha256Base64urlSync)((0, canonical_ts_1.canonicalizeJson)(value));
|
|
56
|
+
}
|
|
57
|
+
function rpcSubject(name, version) {
|
|
58
|
+
return `rpc.${version}.${name}`;
|
|
59
|
+
}
|
|
60
|
+
function operationSubject(name, version) {
|
|
61
|
+
return `operations.${version}.${name}`;
|
|
62
|
+
}
|
|
63
|
+
function eventSubject(name, version, params) {
|
|
64
|
+
const suffix = params && params.length > 0
|
|
65
|
+
? `.${params.map((pointer) => `{${pointer}}`).join(".")}`
|
|
66
|
+
: "";
|
|
67
|
+
return `events.${version}.${name}${suffix}`;
|
|
68
|
+
}
|
|
69
|
+
function emitResources(resources) {
|
|
70
|
+
if (!resources?.kv && !resources?.streams && !resources?.jobs) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...(resources.kv
|
|
75
|
+
? {
|
|
76
|
+
kv: Object.fromEntries(Object.entries(resources.kv).map(([alias, resource]) => [
|
|
77
|
+
alias,
|
|
78
|
+
{
|
|
79
|
+
purpose: resource.purpose,
|
|
80
|
+
required: resource.required ?? true,
|
|
81
|
+
history: resource.history ?? 1,
|
|
82
|
+
ttlMs: resource.ttlMs ?? 0,
|
|
83
|
+
...(resource.maxValueBytes
|
|
84
|
+
? { maxValueBytes: resource.maxValueBytes }
|
|
85
|
+
: {}),
|
|
86
|
+
},
|
|
87
|
+
])),
|
|
88
|
+
}
|
|
89
|
+
: {}),
|
|
90
|
+
...(resources.streams
|
|
91
|
+
? {
|
|
92
|
+
streams: Object.fromEntries(Object.entries(resources.streams).map(([alias, resource]) => [
|
|
93
|
+
alias,
|
|
94
|
+
{
|
|
95
|
+
purpose: resource.purpose,
|
|
96
|
+
required: resource.required ?? true,
|
|
97
|
+
subjects: [...resource.subjects],
|
|
98
|
+
},
|
|
99
|
+
])),
|
|
100
|
+
}
|
|
101
|
+
: {}),
|
|
102
|
+
...(resources.jobs
|
|
103
|
+
? {
|
|
104
|
+
jobs: {
|
|
105
|
+
queues: Object.fromEntries(Object.entries(resources.jobs.queues).map(([queueType, queue]) => [
|
|
106
|
+
queueType,
|
|
107
|
+
{
|
|
108
|
+
payload: { ...queue.payload },
|
|
109
|
+
...(queue.result ? { result: { ...queue.result } } : {}),
|
|
110
|
+
...(queue.maxDeliver !== undefined
|
|
111
|
+
? { maxDeliver: queue.maxDeliver }
|
|
112
|
+
: {}),
|
|
113
|
+
...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
|
|
114
|
+
...(queue.ackWaitMs !== undefined
|
|
115
|
+
? { ackWaitMs: queue.ackWaitMs }
|
|
116
|
+
: {}),
|
|
117
|
+
...(queue.defaultDeadlineMs !== undefined
|
|
118
|
+
? { defaultDeadlineMs: queue.defaultDeadlineMs }
|
|
119
|
+
: {}),
|
|
120
|
+
...(queue.progress !== undefined
|
|
121
|
+
? { progress: queue.progress }
|
|
122
|
+
: {}),
|
|
123
|
+
...(queue.logs !== undefined ? { logs: queue.logs } : {}),
|
|
124
|
+
...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
|
|
125
|
+
...(queue.concurrency !== undefined
|
|
126
|
+
? { concurrency: queue.concurrency }
|
|
127
|
+
: {}),
|
|
128
|
+
},
|
|
129
|
+
])),
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
: {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function emitUses(uses) {
|
|
136
|
+
if (!uses) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
return Object.fromEntries(Object.entries(uses).map(([alias, use]) => [
|
|
140
|
+
alias,
|
|
141
|
+
{
|
|
142
|
+
contract: use.contract,
|
|
143
|
+
...(use.rpc?.call ? { rpc: { call: [...use.rpc.call] } } : {}),
|
|
144
|
+
...(use.operations?.call
|
|
145
|
+
? { operations: { call: [...use.operations.call] } }
|
|
146
|
+
: {}),
|
|
147
|
+
...((use.events?.publish || use.events?.subscribe)
|
|
148
|
+
? {
|
|
149
|
+
events: {
|
|
150
|
+
...(use.events.publish
|
|
151
|
+
? { publish: [...use.events.publish] }
|
|
152
|
+
: {}),
|
|
153
|
+
...(use.events.subscribe
|
|
154
|
+
? { subscribe: [...use.events.subscribe] }
|
|
155
|
+
: {}),
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
: {}),
|
|
159
|
+
...((use.subjects?.publish || use.subjects?.subscribe)
|
|
160
|
+
? {
|
|
161
|
+
subjects: {
|
|
162
|
+
...(use.subjects.publish
|
|
163
|
+
? { publish: [...use.subjects.publish] }
|
|
164
|
+
: {}),
|
|
165
|
+
...(use.subjects.subscribe
|
|
166
|
+
? { subscribe: [...use.subjects.subscribe] }
|
|
167
|
+
: {}),
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
: {}),
|
|
171
|
+
},
|
|
172
|
+
]));
|
|
173
|
+
}
|
|
174
|
+
function emitContract(source) {
|
|
175
|
+
const rpc = source.rpc
|
|
176
|
+
? Object.fromEntries(Object.entries(source.rpc).map(([name, method]) => {
|
|
177
|
+
const emitted = {
|
|
178
|
+
version: method.version,
|
|
179
|
+
subject: method.subject ?? rpcSubject(name, method.version),
|
|
180
|
+
input: { ...method.input },
|
|
181
|
+
output: { ...method.output },
|
|
182
|
+
};
|
|
183
|
+
if (method.capabilities?.call) {
|
|
184
|
+
emitted.capabilities = { call: [...method.capabilities.call] };
|
|
185
|
+
}
|
|
186
|
+
if (method.errors && method.errors.length > 0) {
|
|
187
|
+
emitted.errors = method.errors.map((type) => ({ type }));
|
|
188
|
+
}
|
|
189
|
+
return [name, emitted];
|
|
190
|
+
}))
|
|
191
|
+
: undefined;
|
|
192
|
+
const operations = source.operations
|
|
193
|
+
? Object.fromEntries(Object.entries(source.operations).map(([name, operation]) => {
|
|
194
|
+
const emitted = {
|
|
195
|
+
version: operation.version,
|
|
196
|
+
subject: operation.subject ?? operationSubject(name, operation.version),
|
|
197
|
+
input: { ...operation.input },
|
|
198
|
+
};
|
|
199
|
+
if (operation.progress) {
|
|
200
|
+
emitted.progress = { ...operation.progress };
|
|
201
|
+
}
|
|
202
|
+
if (operation.output) {
|
|
203
|
+
emitted.output = { ...operation.output };
|
|
204
|
+
}
|
|
205
|
+
if (operation.capabilities?.call || operation.capabilities?.read ||
|
|
206
|
+
operation.capabilities?.cancel) {
|
|
207
|
+
emitted.capabilities = {
|
|
208
|
+
...(operation.capabilities.call
|
|
209
|
+
? { call: [...operation.capabilities.call] }
|
|
210
|
+
: {}),
|
|
211
|
+
...(operation.capabilities.read
|
|
212
|
+
? { read: [...operation.capabilities.read] }
|
|
213
|
+
: {}),
|
|
214
|
+
...(operation.capabilities.cancel
|
|
215
|
+
? { cancel: [...operation.capabilities.cancel] }
|
|
216
|
+
: {}),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
if (operation.cancel !== undefined) {
|
|
220
|
+
emitted.cancel = operation.cancel;
|
|
221
|
+
}
|
|
222
|
+
return [name, emitted];
|
|
223
|
+
}))
|
|
224
|
+
: undefined;
|
|
225
|
+
const events = source.events
|
|
226
|
+
? Object.fromEntries(Object.entries(source.events).map(([name, event]) => {
|
|
227
|
+
if (event.params && event.params.length > 0) {
|
|
228
|
+
(0, schema_pointers_ts_1.assertDataPointersExistAndAreTokenable)(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
|
|
229
|
+
}
|
|
230
|
+
const emitted = {
|
|
231
|
+
version: event.version,
|
|
232
|
+
subject: event.subject ??
|
|
233
|
+
eventSubject(name, event.version, event.params),
|
|
234
|
+
event: { ...event.event },
|
|
235
|
+
};
|
|
236
|
+
if (event.params && event.params.length > 0) {
|
|
237
|
+
emitted.params = [...event.params];
|
|
238
|
+
}
|
|
239
|
+
if (event.capabilities?.publish || event.capabilities?.subscribe) {
|
|
240
|
+
emitted.capabilities = {
|
|
241
|
+
...(event.capabilities.publish
|
|
242
|
+
? { publish: [...event.capabilities.publish] }
|
|
243
|
+
: {}),
|
|
244
|
+
...(event.capabilities.subscribe
|
|
245
|
+
? { subscribe: [...event.capabilities.subscribe] }
|
|
246
|
+
: {}),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return [name, emitted];
|
|
250
|
+
}))
|
|
251
|
+
: undefined;
|
|
252
|
+
const subjects = source.subjects
|
|
253
|
+
? Object.fromEntries(Object.entries(source.subjects).map(([name, subject]) => {
|
|
254
|
+
const emitted = {
|
|
255
|
+
subject: subject.subject,
|
|
256
|
+
};
|
|
257
|
+
if (subject.message) {
|
|
258
|
+
emitted.message = { ...subject.message };
|
|
259
|
+
}
|
|
260
|
+
if (subject.capabilities?.publish || subject.capabilities?.subscribe) {
|
|
261
|
+
emitted.capabilities = {
|
|
262
|
+
...(subject.capabilities.publish
|
|
263
|
+
? { publish: [...subject.capabilities.publish] }
|
|
264
|
+
: {}),
|
|
265
|
+
...(subject.capabilities.subscribe
|
|
266
|
+
? { subscribe: [...subject.capabilities.subscribe] }
|
|
267
|
+
: {}),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return [name, emitted];
|
|
271
|
+
}))
|
|
272
|
+
: undefined;
|
|
273
|
+
const errors = source.errors
|
|
274
|
+
? Object.fromEntries(Object.entries(source.errors).map(([name, error]) => {
|
|
275
|
+
const emitted = { type: error.type };
|
|
276
|
+
if (error.schema) {
|
|
277
|
+
emitted.schema = { ...error.schema };
|
|
278
|
+
}
|
|
279
|
+
return [name, emitted];
|
|
280
|
+
}))
|
|
281
|
+
: undefined;
|
|
282
|
+
const resources = emitResources(source.resources);
|
|
283
|
+
const uses = emitUses(source.uses);
|
|
284
|
+
return {
|
|
285
|
+
format: exports.CONTRACT_FORMAT_V1,
|
|
286
|
+
id: source.id,
|
|
287
|
+
displayName: source.displayName,
|
|
288
|
+
description: source.description,
|
|
289
|
+
...(source.schemas ? { schemas: cloneSchemas(source.schemas) } : {}),
|
|
290
|
+
...(uses ? { uses } : {}),
|
|
291
|
+
...(rpc ? { rpc } : {}),
|
|
292
|
+
...(operations ? { operations } : {}),
|
|
293
|
+
...(events ? { events } : {}),
|
|
294
|
+
...(subjects ? { subjects } : {}),
|
|
295
|
+
...(errors ? { errors } : {}),
|
|
296
|
+
...(resources ? { resources } : {}),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function buildOwnedApi(source) {
|
|
300
|
+
const rpc = Object.fromEntries(Object.entries(source.rpc ?? {}).map(([name, method]) => [
|
|
301
|
+
name,
|
|
302
|
+
{
|
|
303
|
+
subject: method.subject ?? rpcSubject(name, method.version),
|
|
304
|
+
input: (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, method.input, `rpc '${name}' input`)),
|
|
305
|
+
output: (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, method.output, `rpc '${name}' output`)),
|
|
306
|
+
callerCapabilities: method.capabilities?.call ?? [],
|
|
307
|
+
authRequired: method.authRequired ?? true,
|
|
308
|
+
errors: method.errors,
|
|
309
|
+
},
|
|
310
|
+
]));
|
|
311
|
+
const operations = Object.fromEntries(Object.entries(source.operations ?? {}).map(([name, operation]) => [
|
|
312
|
+
name,
|
|
313
|
+
{
|
|
314
|
+
subject: operation.subject ?? operationSubject(name, operation.version),
|
|
315
|
+
input: (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, operation.input, `operation '${name}' input`)),
|
|
316
|
+
progress: operation.progress
|
|
317
|
+
? (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, operation.progress, `operation '${name}' progress`))
|
|
318
|
+
: undefined,
|
|
319
|
+
output: operation.output
|
|
320
|
+
? (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, operation.output, `operation '${name}' output`))
|
|
321
|
+
: undefined,
|
|
322
|
+
callerCapabilities: operation.capabilities?.call ?? [],
|
|
323
|
+
readCapabilities: operation.capabilities?.read ?? [],
|
|
324
|
+
cancelCapabilities: operation.capabilities?.cancel ?? [],
|
|
325
|
+
cancel: operation.cancel,
|
|
326
|
+
},
|
|
327
|
+
]));
|
|
328
|
+
const events = Object.fromEntries(Object.entries(source.events ?? {}).map(([name, event]) => {
|
|
329
|
+
if (event.params && event.params.length > 0) {
|
|
330
|
+
(0, schema_pointers_ts_1.assertDataPointersExistAndAreTokenable)(name, resolveSchemaRef(source.schemas, event.event, `event '${name}'`), event.params);
|
|
331
|
+
}
|
|
332
|
+
return [
|
|
333
|
+
name,
|
|
334
|
+
{
|
|
335
|
+
subject: event.subject ??
|
|
336
|
+
eventSubject(name, event.version, event.params),
|
|
337
|
+
params: event.params,
|
|
338
|
+
event: (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, event.event, `event '${name}'`)),
|
|
339
|
+
publishCapabilities: event.capabilities?.publish ?? [],
|
|
340
|
+
subscribeCapabilities: event.capabilities?.subscribe ?? [],
|
|
341
|
+
},
|
|
342
|
+
];
|
|
343
|
+
}));
|
|
344
|
+
const subjects = Object.fromEntries(Object.entries(source.subjects ?? {}).map(([name, subject]) => [
|
|
345
|
+
name,
|
|
346
|
+
{
|
|
347
|
+
subject: subject.subject,
|
|
348
|
+
schema: subject.message
|
|
349
|
+
? (0, runtime_ts_1.schema)(resolveSchemaRef(source.schemas, subject.message, `subject '${name}'`))
|
|
350
|
+
: undefined,
|
|
351
|
+
publishCapabilities: subject.capabilities?.publish ?? [],
|
|
352
|
+
subscribeCapabilities: subject.capabilities?.subscribe ?? [],
|
|
353
|
+
},
|
|
354
|
+
]));
|
|
355
|
+
return { rpc, operations, events, subjects };
|
|
356
|
+
}
|
|
357
|
+
function mergeRecord(kind, out, next) {
|
|
358
|
+
for (const [key, value] of Object.entries(next)) {
|
|
359
|
+
if (Object.hasOwn(out, key)) {
|
|
360
|
+
throw new Error(`Duplicate ${kind} key '${key}' while deriving contract API`);
|
|
361
|
+
}
|
|
362
|
+
out[key] = value;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function assertSelectedKeysExist(contractId, kind, keys, api) {
|
|
366
|
+
if (!keys) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
for (const key of keys) {
|
|
370
|
+
if (!Object.hasOwn(api, key)) {
|
|
371
|
+
throw new Error(`Contract '${contractId}' does not expose ${kind} key '${key}'`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function assertValidUseSpec(contractId, spec, api) {
|
|
376
|
+
assertSelectedKeysExist(contractId, "rpc", spec.rpc?.call, api.rpc);
|
|
377
|
+
assertSelectedKeysExist(contractId, "operations", spec.operations?.call, api.operations);
|
|
378
|
+
assertSelectedKeysExist(contractId, "events", spec.events?.publish, api.events);
|
|
379
|
+
assertSelectedKeysExist(contractId, "events", spec.events?.subscribe, api.events);
|
|
380
|
+
assertSelectedKeysExist(contractId, "subjects", spec.subjects?.publish, api.subjects);
|
|
381
|
+
assertSelectedKeysExist(contractId, "subjects", spec.subjects?.subscribe, api.subjects);
|
|
382
|
+
}
|
|
383
|
+
function attachContractModuleMetadata(value, contractModule) {
|
|
384
|
+
Object.defineProperty(value, CONTRACT_MODULE_METADATA, {
|
|
385
|
+
value: contractModule,
|
|
386
|
+
enumerable: false,
|
|
387
|
+
});
|
|
388
|
+
return value;
|
|
389
|
+
}
|
|
390
|
+
function createUseHelper(getContractModule) {
|
|
391
|
+
return ((spec) => {
|
|
392
|
+
const contractModule = getContractModule();
|
|
393
|
+
assertValidUseSpec(contractModule.CONTRACT_ID, spec, contractModule.API.owned);
|
|
394
|
+
const dependencyUse = {
|
|
395
|
+
contract: contractModule.CONTRACT_ID,
|
|
396
|
+
...(spec.rpc?.call ? { rpc: { call: [...spec.rpc.call] } } : {}),
|
|
397
|
+
...(spec.operations?.call
|
|
398
|
+
? { operations: { call: [...spec.operations.call] } }
|
|
399
|
+
: {}),
|
|
400
|
+
...((spec.events?.publish || spec.events?.subscribe)
|
|
401
|
+
? {
|
|
402
|
+
events: {
|
|
403
|
+
...(spec.events.publish
|
|
404
|
+
? { publish: [...spec.events.publish] }
|
|
405
|
+
: {}),
|
|
406
|
+
...(spec.events.subscribe
|
|
407
|
+
? { subscribe: [...spec.events.subscribe] }
|
|
408
|
+
: {}),
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
: {}),
|
|
412
|
+
...((spec.subjects?.publish || spec.subjects?.subscribe)
|
|
413
|
+
? {
|
|
414
|
+
subjects: {
|
|
415
|
+
...(spec.subjects.publish
|
|
416
|
+
? { publish: [...spec.subjects.publish] }
|
|
417
|
+
: {}),
|
|
418
|
+
...(spec.subjects.subscribe
|
|
419
|
+
? { subscribe: [...spec.subjects.subscribe] }
|
|
420
|
+
: {}),
|
|
421
|
+
},
|
|
422
|
+
}
|
|
423
|
+
: {}),
|
|
424
|
+
};
|
|
425
|
+
return attachContractModuleMetadata(dependencyUse, contractModule);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function getContractModuleFromUse(alias, useValue) {
|
|
429
|
+
const contractModule = useValue[CONTRACT_MODULE_METADATA];
|
|
430
|
+
if (!contractModule) {
|
|
431
|
+
throw new Error(`Contract use '${alias}' must be created with contractModule.use(...) from @qlever-llc/trellis-contracts`);
|
|
432
|
+
}
|
|
433
|
+
return contractModule;
|
|
434
|
+
}
|
|
435
|
+
function normalizeUses(uses) {
|
|
436
|
+
if (!uses) {
|
|
437
|
+
return {
|
|
438
|
+
manifestUses: undefined,
|
|
439
|
+
usedApi: { rpc: {}, operations: {}, events: {}, subjects: {} },
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const manifestUses = {};
|
|
443
|
+
const usedApi = { rpc: {}, operations: {}, events: {}, subjects: {} };
|
|
444
|
+
for (const [alias, useValue] of Object.entries(uses)) {
|
|
445
|
+
const contractModule = getContractModuleFromUse(alias, useValue);
|
|
446
|
+
if (useValue.contract !== contractModule.CONTRACT_ID) {
|
|
447
|
+
throw new Error(`Contract use '${alias}' references '${useValue.contract}' but module id is '${contractModule.CONTRACT_ID}'`);
|
|
448
|
+
}
|
|
449
|
+
assertValidUseSpec(contractModule.CONTRACT_ID, useValue, contractModule.API.owned);
|
|
450
|
+
manifestUses[alias] = {
|
|
451
|
+
contract: contractModule.CONTRACT_ID,
|
|
452
|
+
...(useValue.rpc?.call ? { rpc: { call: [...useValue.rpc.call] } } : {}),
|
|
453
|
+
...(useValue.operations?.call
|
|
454
|
+
? { operations: { call: [...useValue.operations.call] } }
|
|
455
|
+
: {}),
|
|
456
|
+
...((useValue.events?.publish || useValue.events?.subscribe)
|
|
457
|
+
? {
|
|
458
|
+
events: {
|
|
459
|
+
...(useValue.events.publish
|
|
460
|
+
? { publish: [...useValue.events.publish] }
|
|
461
|
+
: {}),
|
|
462
|
+
...(useValue.events.subscribe
|
|
463
|
+
? { subscribe: [...useValue.events.subscribe] }
|
|
464
|
+
: {}),
|
|
465
|
+
},
|
|
466
|
+
}
|
|
467
|
+
: {}),
|
|
468
|
+
...((useValue.subjects?.publish || useValue.subjects?.subscribe)
|
|
469
|
+
? {
|
|
470
|
+
subjects: {
|
|
471
|
+
...(useValue.subjects.publish
|
|
472
|
+
? { publish: [...useValue.subjects.publish] }
|
|
473
|
+
: {}),
|
|
474
|
+
...(useValue.subjects.subscribe
|
|
475
|
+
? { subscribe: [...useValue.subjects.subscribe] }
|
|
476
|
+
: {}),
|
|
477
|
+
},
|
|
478
|
+
}
|
|
479
|
+
: {}),
|
|
480
|
+
};
|
|
481
|
+
const rpcKeys = selectedKeys(useValue.rpc?.call);
|
|
482
|
+
if (rpcKeys.length > 0) {
|
|
483
|
+
mergeRecord("rpc", usedApi.rpc, Object.fromEntries(rpcKeys.map((key) => [key, contractModule.API.owned.rpc[key]])));
|
|
484
|
+
}
|
|
485
|
+
const operationKeys = selectedKeys(useValue.operations?.call);
|
|
486
|
+
if (operationKeys.length > 0) {
|
|
487
|
+
mergeRecord("operations", usedApi.operations, Object.fromEntries(operationKeys.map((key) => [key, contractModule.API.owned.operations[key]])));
|
|
488
|
+
}
|
|
489
|
+
const eventKeys = new Set([
|
|
490
|
+
...selectedKeys(useValue.events?.publish),
|
|
491
|
+
...selectedKeys(useValue.events?.subscribe),
|
|
492
|
+
]);
|
|
493
|
+
if (eventKeys.size > 0) {
|
|
494
|
+
mergeRecord("events", usedApi.events, Object.fromEntries([...eventKeys].map((key) => [key, contractModule.API.owned.events[key]])));
|
|
495
|
+
}
|
|
496
|
+
const subjectKeys = new Set([
|
|
497
|
+
...selectedKeys(useValue.subjects?.publish),
|
|
498
|
+
...selectedKeys(useValue.subjects?.subscribe),
|
|
499
|
+
]);
|
|
500
|
+
if (subjectKeys.size > 0) {
|
|
501
|
+
mergeRecord("subjects", usedApi.subjects, Object.fromEntries([...subjectKeys].map((key) => [key, contractModule.API.owned.subjects[key]])));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return { manifestUses, usedApi };
|
|
505
|
+
}
|
|
506
|
+
function selectedKeys(keys) {
|
|
507
|
+
return keys ?? [];
|
|
508
|
+
}
|
|
509
|
+
function mergeApiSection(kind, usedEntries, ownedEntries) {
|
|
510
|
+
const merged = {};
|
|
511
|
+
mergeRecord(kind, merged, usedEntries);
|
|
512
|
+
mergeRecord(kind, merged, ownedEntries);
|
|
513
|
+
return merged;
|
|
514
|
+
}
|
|
515
|
+
function mergeDerivedApis(ownedApi, usedApi) {
|
|
516
|
+
return {
|
|
517
|
+
rpc: mergeApiSection("rpc", usedApi.rpc, ownedApi.rpc),
|
|
518
|
+
operations: mergeApiSection("operations", usedApi.operations, ownedApi.operations),
|
|
519
|
+
events: mergeApiSection("events", usedApi.events, ownedApi.events),
|
|
520
|
+
subjects: mergeApiSection("subjects", usedApi.subjects, ownedApi.subjects),
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function defineContract(source) {
|
|
524
|
+
const { manifestUses, usedApi } = normalizeUses(source.uses);
|
|
525
|
+
const emittedSource = {
|
|
526
|
+
id: source.id,
|
|
527
|
+
displayName: source.displayName,
|
|
528
|
+
description: source.description,
|
|
529
|
+
...(source.schemas ? { schemas: source.schemas } : {}),
|
|
530
|
+
...(manifestUses ? { uses: manifestUses } : {}),
|
|
531
|
+
...(source.rpc ? { rpc: source.rpc } : {}),
|
|
532
|
+
...(source.operations ? { operations: source.operations } : {}),
|
|
533
|
+
...(source.events ? { events: source.events } : {}),
|
|
534
|
+
...(source.subjects ? { subjects: source.subjects } : {}),
|
|
535
|
+
...(source.errors ? { errors: source.errors } : {}),
|
|
536
|
+
...(source.resources ? { resources: source.resources } : {}),
|
|
537
|
+
};
|
|
538
|
+
const ownedApi = buildOwnedApi(emittedSource);
|
|
539
|
+
const trellisApi = mergeDerivedApis(ownedApi, usedApi);
|
|
540
|
+
const CONTRACT = emitContract(emittedSource);
|
|
541
|
+
const CONTRACT_DIGEST = digestCanonicalJson(CONTRACT);
|
|
542
|
+
let contract;
|
|
543
|
+
contract = {
|
|
544
|
+
CONTRACT_ID: source.id,
|
|
545
|
+
CONTRACT,
|
|
546
|
+
CONTRACT_DIGEST,
|
|
547
|
+
API: {
|
|
548
|
+
owned: ownedApi,
|
|
549
|
+
used: usedApi,
|
|
550
|
+
trellis: trellisApi,
|
|
551
|
+
},
|
|
552
|
+
use: createUseHelper(() => contract),
|
|
553
|
+
};
|
|
554
|
+
return contract;
|
|
555
|
+
}
|