@qlever-llc/trellis 0.8.4 → 0.9.0-rc.10
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 +1 -1
- package/bin/trellis-generate.js +0 -0
- package/esm/auth/browser/login.d.ts.map +1 -1
- package/esm/auth/browser/login.js +46 -3
- package/esm/auth/browser/portal.d.ts.map +1 -1
- package/esm/auth/browser/portal.js +5 -1
- package/esm/auth/browser/session.d.ts +18 -7
- package/esm/auth/browser/session.d.ts.map +1 -1
- package/esm/auth/browser/session.js +47 -11
- package/esm/auth/browser/storage.d.ts +6 -1
- package/esm/auth/browser/storage.d.ts.map +1 -1
- package/esm/auth/browser/storage.js +15 -3
- package/esm/auth/browser.d.ts +2 -2
- package/esm/auth/browser.d.ts.map +1 -1
- package/esm/auth/browser.js +1 -1
- package/esm/auth/device_activation.d.ts +36 -33
- package/esm/auth/device_activation.d.ts.map +1 -1
- package/esm/auth/device_activation.js +26 -22
- package/esm/auth/mod.d.ts +4 -4
- package/esm/auth/mod.d.ts.map +1 -1
- package/esm/auth/mod.js +2 -2
- package/esm/auth/proof.d.ts +3 -1
- package/esm/auth/proof.d.ts.map +1 -1
- package/esm/auth/proof.js +21 -15
- package/esm/auth/protocol.d.ts +2457 -941
- package/esm/auth/protocol.d.ts.map +1 -1
- package/esm/auth/protocol.js +747 -375
- package/esm/auth/schemas.d.ts +25 -4
- package/esm/auth/schemas.d.ts.map +1 -1
- package/esm/auth/schemas.js +14 -4
- package/esm/auth/session_auth.d.ts +1 -1
- package/esm/auth/session_auth.d.ts.map +1 -1
- package/esm/auth/session_auth.js +7 -1
- package/esm/client_connect.d.ts +2 -0
- package/esm/client_connect.d.ts.map +1 -1
- package/esm/client_connect.js +76 -15
- package/esm/contract.d.ts +3 -0
- package/esm/contract.d.ts.map +1 -1
- package/esm/contract_support/mod.d.ts +422 -43
- package/esm/contract_support/mod.d.ts.map +1 -1
- package/esm/contract_support/mod.js +734 -33
- package/esm/contract_support/protocol.d.ts +20 -5
- package/esm/contract_support/protocol.d.ts.map +1 -1
- package/esm/contract_support/protocol.js +18 -10
- package/esm/contract_support/runtime.d.ts +11 -0
- package/esm/contract_support/runtime.d.ts.map +1 -1
- package/esm/contract_support/schema_pointers.d.ts.map +1 -1
- package/esm/contract_support/schema_pointers.js +32 -14
- package/esm/device.d.ts +2 -0
- package/esm/device.d.ts.map +1 -1
- package/esm/device.js +3 -0
- package/esm/errors/AuthError.d.ts +2 -1
- package/esm/errors/AuthError.d.ts.map +1 -1
- package/esm/errors/AuthError.js +8 -3
- package/esm/errors/index.d.ts +4 -4
- package/esm/errors/index.d.ts.map +1 -1
- package/esm/errors/index.js +1 -0
- package/esm/generated-sdk/auth/api.d.ts +27 -9
- package/esm/generated-sdk/auth/api.d.ts.map +1 -1
- package/esm/generated-sdk/auth/api.js +16 -590
- package/esm/generated-sdk/auth/client.d.ts +91 -85
- package/esm/generated-sdk/auth/client.d.ts.map +1 -1
- package/esm/generated-sdk/auth/contract.d.ts +1 -1
- package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
- package/esm/generated-sdk/auth/contract.js +4 -2
- package/esm/generated-sdk/auth/mod.d.ts +1 -0
- package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
- package/esm/generated-sdk/auth/owned_api.d.ts +3 -0
- package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -0
- package/esm/generated-sdk/auth/owned_api.js +594 -0
- package/esm/generated-sdk/auth/schemas.d.ts +9959 -5160
- package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/auth/schemas.js +136 -137
- package/esm/generated-sdk/auth/types.d.ts +2418 -1557
- package/esm/generated-sdk/auth/types.d.ts.map +1 -1
- package/esm/generated-sdk/auth/types.js +1 -1
- package/esm/generated-sdk/health/api.d.ts +24 -9
- package/esm/generated-sdk/health/api.d.ts.map +1 -1
- package/esm/generated-sdk/health/api.js +12 -20
- package/esm/generated-sdk/health/client.d.ts +2 -1
- package/esm/generated-sdk/health/client.d.ts.map +1 -1
- package/esm/generated-sdk/health/contract.d.ts.map +1 -1
- package/esm/generated-sdk/health/contract.js +2 -0
- package/esm/generated-sdk/health/owned_api.d.ts +3 -0
- package/esm/generated-sdk/health/owned_api.d.ts.map +1 -0
- package/esm/generated-sdk/health/owned_api.js +16 -0
- package/esm/generated-sdk/health/types.d.ts +2 -0
- package/esm/generated-sdk/health/types.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/api.d.ts +33 -9
- package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/api.js +22 -87
- package/esm/generated-sdk/jobs/client.d.ts +9 -2
- package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/contract.d.ts +1 -1
- package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/contract.js +4 -2
- package/esm/generated-sdk/jobs/owned_api.d.ts +3 -0
- package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -0
- package/esm/generated-sdk/jobs/owned_api.js +118 -0
- package/esm/generated-sdk/jobs/schemas.d.ts +336 -123
- package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/schemas.js +17 -15
- package/esm/generated-sdk/jobs/types.d.ts +144 -34
- package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
- package/esm/generated-sdk/jobs/types.js +36 -1
- package/esm/generated-sdk/state/api.d.ts +27 -9
- package/esm/generated-sdk/state/api.d.ts.map +1 -1
- package/esm/generated-sdk/state/api.js +16 -71
- package/esm/generated-sdk/state/client.d.ts +4 -2
- package/esm/generated-sdk/state/client.d.ts.map +1 -1
- package/esm/generated-sdk/state/contract.d.ts +1 -1
- package/esm/generated-sdk/state/contract.d.ts.map +1 -1
- package/esm/generated-sdk/state/contract.js +4 -2
- package/esm/generated-sdk/state/owned_api.d.ts +3 -0
- package/esm/generated-sdk/state/owned_api.d.ts.map +1 -0
- package/esm/generated-sdk/state/owned_api.js +66 -0
- package/esm/generated-sdk/state/schemas.d.ts +264 -284
- package/esm/generated-sdk/state/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/state/schemas.js +6 -6
- package/esm/generated-sdk/state/types.d.ts +24 -23
- package/esm/generated-sdk/state/types.d.ts.map +1 -1
- package/esm/generated-sdk/state/types.js +1 -1
- package/esm/generated-sdk/trellis-core/api.d.ts +27 -9
- package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/api.js +16 -39
- package/esm/generated-sdk/trellis-core/client.d.ts +5 -2
- package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/contract.d.ts +1 -1
- package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/contract.js +4 -2
- package/esm/generated-sdk/trellis-core/owned_api.d.ts +3 -0
- package/esm/generated-sdk/trellis-core/owned_api.d.ts.map +1 -0
- package/esm/generated-sdk/trellis-core/owned_api.js +42 -0
- package/esm/generated-sdk/trellis-core/schemas.d.ts +259 -11
- package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/schemas.js +5 -3
- package/esm/generated-sdk/trellis-core/types.d.ts +56 -1
- package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/esm/generated-sdk/trellis-core/types.js +1 -1
- package/esm/helpers.d.ts.map +1 -1
- package/esm/index.d.ts +4 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/jobs.d.ts +10 -1
- package/esm/jobs.d.ts.map +1 -1
- package/esm/jobs.js +16 -1
- package/esm/kv.d.ts.map +1 -1
- package/esm/kv.js +10 -4
- package/esm/models/auth/rpc/Logout.d.ts +4 -4
- package/esm/models/auth/rpc/Logout.d.ts.map +1 -1
- package/esm/models/auth/rpc/Logout.js +2 -2
- package/esm/models/trellis/Page.d.ts +2 -0
- package/esm/models/trellis/Page.d.ts.map +1 -0
- package/esm/models/trellis/Page.js +1 -0
- package/esm/models/trellis/State.d.ts +1 -0
- package/esm/models/trellis/State.d.ts.map +1 -1
- package/esm/models/trellis/State.js +1 -0
- package/esm/models/trellis/rpc/StateList.d.ts +9 -12
- package/esm/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/esm/models/trellis/rpc/StateList.js +16 -18
- package/esm/npm/src/auth/browser/login.d.ts.map +1 -1
- package/esm/npm/src/auth/browser/login.js +46 -3
- package/esm/npm/src/auth/browser/portal.d.ts.map +1 -1
- package/esm/npm/src/auth/browser/portal.js +5 -1
- package/esm/npm/src/auth/browser/session.d.ts +18 -7
- package/esm/npm/src/auth/browser/session.d.ts.map +1 -1
- package/esm/npm/src/auth/browser/session.js +47 -11
- package/esm/npm/src/auth/browser/storage.d.ts +6 -1
- package/esm/npm/src/auth/browser/storage.d.ts.map +1 -1
- package/esm/npm/src/auth/browser/storage.js +15 -3
- package/esm/npm/src/auth/browser.d.ts +2 -2
- package/esm/npm/src/auth/browser.d.ts.map +1 -1
- package/esm/npm/src/auth/browser.js +1 -1
- package/esm/npm/src/auth/device_activation.d.ts +36 -33
- package/esm/npm/src/auth/device_activation.d.ts.map +1 -1
- package/esm/npm/src/auth/device_activation.js +26 -22
- package/esm/npm/src/auth/mod.d.ts +4 -4
- package/esm/npm/src/auth/mod.d.ts.map +1 -1
- package/esm/npm/src/auth/mod.js +2 -2
- package/esm/npm/src/auth/proof.d.ts +3 -1
- package/esm/npm/src/auth/proof.d.ts.map +1 -1
- package/esm/npm/src/auth/proof.js +21 -15
- package/esm/npm/src/auth/protocol.d.ts +2457 -941
- package/esm/npm/src/auth/protocol.d.ts.map +1 -1
- package/esm/npm/src/auth/protocol.js +747 -375
- package/esm/npm/src/auth/schemas.d.ts +25 -4
- package/esm/npm/src/auth/schemas.d.ts.map +1 -1
- package/esm/npm/src/auth/schemas.js +14 -4
- package/esm/npm/src/auth/session_auth.d.ts +1 -1
- package/esm/npm/src/auth/session_auth.d.ts.map +1 -1
- package/esm/npm/src/auth/session_auth.js +7 -1
- package/esm/npm/src/client_connect.d.ts +2 -0
- package/esm/npm/src/client_connect.d.ts.map +1 -1
- package/esm/npm/src/client_connect.js +76 -15
- package/esm/npm/src/contract.d.ts +3 -0
- package/esm/npm/src/contract.d.ts.map +1 -1
- package/esm/npm/src/contract_support/mod.d.ts +422 -43
- package/esm/npm/src/contract_support/mod.d.ts.map +1 -1
- package/esm/npm/src/contract_support/mod.js +734 -33
- package/esm/npm/src/contract_support/protocol.d.ts +20 -5
- package/esm/npm/src/contract_support/protocol.d.ts.map +1 -1
- package/esm/npm/src/contract_support/protocol.js +18 -10
- package/esm/npm/src/contract_support/runtime.d.ts +11 -0
- package/esm/npm/src/contract_support/runtime.d.ts.map +1 -1
- package/esm/npm/src/contract_support/schema_pointers.d.ts.map +1 -1
- package/esm/npm/src/contract_support/schema_pointers.js +32 -14
- package/esm/npm/src/device/deno.d.ts.map +1 -1
- package/esm/npm/src/device/deno.js +6 -0
- package/esm/npm/src/device.d.ts +2 -0
- package/esm/npm/src/device.d.ts.map +1 -1
- package/esm/npm/src/device.js +3 -0
- package/esm/npm/src/errors/AuthError.d.ts +2 -1
- package/esm/npm/src/errors/AuthError.d.ts.map +1 -1
- package/esm/npm/src/errors/AuthError.js +8 -3
- package/esm/npm/src/errors/index.d.ts +4 -4
- package/esm/npm/src/errors/index.d.ts.map +1 -1
- package/esm/npm/src/errors/index.js +1 -0
- package/esm/npm/src/generate.js +39 -26
- package/esm/npm/src/helpers.d.ts.map +1 -1
- package/esm/npm/src/index.d.ts +4 -3
- package/esm/npm/src/index.d.ts.map +1 -1
- package/esm/npm/src/index.js +1 -0
- package/esm/npm/src/jobs.d.ts +10 -1
- package/esm/npm/src/jobs.d.ts.map +1 -1
- package/esm/npm/src/jobs.js +16 -1
- package/esm/npm/src/kv.d.ts.map +1 -1
- package/esm/npm/src/kv.js +10 -4
- package/esm/npm/src/models/auth/rpc/Logout.d.ts +4 -4
- package/esm/npm/src/models/auth/rpc/Logout.d.ts.map +1 -1
- package/esm/npm/src/models/auth/rpc/Logout.js +2 -2
- package/esm/npm/src/models/trellis/Page.d.ts +2 -0
- package/esm/npm/src/models/trellis/Page.d.ts.map +1 -0
- package/esm/npm/src/models/trellis/Page.js +1 -0
- package/esm/npm/src/models/trellis/State.d.ts +1 -0
- package/esm/npm/src/models/trellis/State.d.ts.map +1 -1
- package/esm/npm/src/models/trellis/State.js +1 -0
- package/esm/npm/src/models/trellis/rpc/StateList.d.ts +9 -12
- package/esm/npm/src/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/esm/npm/src/models/trellis/rpc/StateList.js +16 -18
- package/esm/npm/src/operations.d.ts +16 -7
- package/esm/npm/src/operations.d.ts.map +1 -1
- package/esm/npm/src/operations.js +84 -19
- package/esm/npm/src/runtime_transport.d.ts +2 -0
- package/esm/npm/src/runtime_transport.d.ts.map +1 -1
- package/esm/npm/src/runtime_transport.js +1 -0
- package/esm/npm/src/server/internal_jobs/active-job.d.ts +2 -1
- package/esm/npm/src/server/internal_jobs/active-job.d.ts.map +1 -1
- package/esm/npm/src/server/internal_jobs/active-job.js +3 -0
- package/esm/npm/src/server/internal_jobs/job-manager.d.ts +4 -1
- package/esm/npm/src/server/internal_jobs/job-manager.d.ts.map +1 -1
- package/esm/npm/src/server/internal_jobs/job-manager.js +61 -1
- package/esm/npm/src/server/internal_jobs/projection.js +1 -0
- package/esm/npm/src/server/internal_jobs/runtime-worker.d.ts +13 -1
- package/esm/npm/src/server/internal_jobs/runtime-worker.d.ts.map +1 -1
- package/esm/npm/src/server/internal_jobs/runtime-worker.js +73 -13
- package/esm/npm/src/server/internal_jobs/types.d.ts +19 -0
- package/esm/npm/src/server/internal_jobs/types.d.ts.map +1 -1
- package/esm/npm/src/server/internal_jobs/types.js +10 -0
- package/esm/npm/src/server/runtime.d.ts +1 -0
- package/esm/npm/src/server/runtime.d.ts.map +1 -1
- package/esm/npm/src/server/service.d.ts +10 -1
- package/esm/npm/src/server/service.d.ts.map +1 -1
- package/esm/npm/src/server/service.js +210 -64
- package/esm/npm/src/server/transfer.d.ts.map +1 -1
- package/esm/npm/src/server/transfer.js +4 -0
- package/esm/npm/src/server.d.ts.map +1 -1
- package/esm/npm/src/server.js +337 -34
- package/esm/npm/src/store.d.ts +8 -1
- package/esm/npm/src/store.d.ts.map +1 -1
- package/esm/npm/src/store.js +46 -8
- package/esm/npm/src/transfer.d.ts +3 -0
- package/esm/npm/src/transfer.d.ts.map +1 -1
- package/esm/npm/src/transfer.js +20 -30
- package/esm/npm/src/trellis.d.ts +85 -22
- package/esm/npm/src/trellis.d.ts.map +1 -1
- package/esm/npm/src/trellis.js +525 -61
- package/esm/operations.d.ts +16 -7
- package/esm/operations.d.ts.map +1 -1
- package/esm/operations.js +84 -19
- package/esm/runtime_transport.d.ts +2 -0
- package/esm/runtime_transport.d.ts.map +1 -1
- package/esm/runtime_transport.js +1 -0
- package/esm/store.d.ts +8 -1
- package/esm/store.d.ts.map +1 -1
- package/esm/store.js +46 -8
- package/esm/transfer.d.ts +3 -0
- package/esm/transfer.d.ts.map +1 -1
- package/esm/transfer.js +20 -30
- package/esm/trellis.d.ts +85 -22
- package/esm/trellis.d.ts.map +1 -1
- package/esm/trellis.js +525 -61
- package/package.json +6 -3
- package/script/auth/browser/login.d.ts.map +1 -1
- package/script/auth/browser/login.js +46 -3
- package/script/auth/browser/portal.d.ts.map +1 -1
- package/script/auth/browser/portal.js +5 -1
- package/script/auth/browser/session.d.ts +18 -7
- package/script/auth/browser/session.d.ts.map +1 -1
- package/script/auth/browser/session.js +47 -11
- package/script/auth/browser/storage.d.ts +6 -1
- package/script/auth/browser/storage.d.ts.map +1 -1
- package/script/auth/browser/storage.js +15 -3
- package/script/auth/browser.d.ts +2 -2
- package/script/auth/browser.d.ts.map +1 -1
- package/script/auth/browser.js +2 -1
- package/script/auth/device_activation.d.ts +36 -33
- package/script/auth/device_activation.d.ts.map +1 -1
- package/script/auth/device_activation.js +25 -21
- package/script/auth/mod.d.ts +4 -4
- package/script/auth/mod.d.ts.map +1 -1
- package/script/auth/mod.js +132 -137
- package/script/auth/proof.d.ts +3 -1
- package/script/auth/proof.d.ts.map +1 -1
- package/script/auth/proof.js +21 -15
- package/script/auth/protocol.d.ts +2457 -941
- package/script/auth/protocol.d.ts.map +1 -1
- package/script/auth/protocol.js +749 -377
- package/script/auth/schemas.d.ts +25 -4
- package/script/auth/schemas.d.ts.map +1 -1
- package/script/auth/schemas.js +16 -5
- package/script/auth/session_auth.d.ts +1 -1
- package/script/auth/session_auth.d.ts.map +1 -1
- package/script/auth/session_auth.js +7 -1
- package/script/client_connect.d.ts +2 -0
- package/script/client_connect.d.ts.map +1 -1
- package/script/client_connect.js +76 -15
- package/script/contract.d.ts +3 -0
- package/script/contract.d.ts.map +1 -1
- package/script/contract_support/mod.d.ts +422 -43
- package/script/contract_support/mod.d.ts.map +1 -1
- package/script/contract_support/mod.js +757 -51
- package/script/contract_support/protocol.d.ts +20 -5
- package/script/contract_support/protocol.d.ts.map +1 -1
- package/script/contract_support/protocol.js +20 -11
- package/script/contract_support/runtime.d.ts +11 -0
- package/script/contract_support/runtime.d.ts.map +1 -1
- package/script/contract_support/schema_pointers.d.ts.map +1 -1
- package/script/contract_support/schema_pointers.js +32 -14
- package/script/device.d.ts +2 -0
- package/script/device.d.ts.map +1 -1
- package/script/device.js +3 -0
- package/script/errors/AuthError.d.ts +2 -1
- package/script/errors/AuthError.d.ts.map +1 -1
- package/script/errors/AuthError.js +8 -3
- package/script/errors/index.d.ts +4 -4
- package/script/errors/index.d.ts.map +1 -1
- package/script/errors/index.js +1 -0
- package/script/generated-sdk/auth/api.d.ts +27 -9
- package/script/generated-sdk/auth/api.d.ts.map +1 -1
- package/script/generated-sdk/auth/api.js +17 -591
- package/script/generated-sdk/auth/client.d.ts +91 -85
- package/script/generated-sdk/auth/client.d.ts.map +1 -1
- package/script/generated-sdk/auth/contract.d.ts +1 -1
- package/script/generated-sdk/auth/contract.d.ts.map +1 -1
- package/script/generated-sdk/auth/contract.js +4 -2
- package/script/generated-sdk/auth/mod.d.ts +1 -0
- package/script/generated-sdk/auth/mod.d.ts.map +1 -1
- package/script/generated-sdk/auth/owned_api.d.ts +3 -0
- package/script/generated-sdk/auth/owned_api.d.ts.map +1 -0
- package/script/generated-sdk/auth/owned_api.js +597 -0
- package/script/generated-sdk/auth/schemas.d.ts +9959 -5160
- package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
- package/script/generated-sdk/auth/schemas.js +139 -140
- package/script/generated-sdk/auth/types.d.ts +2418 -1557
- package/script/generated-sdk/auth/types.d.ts.map +1 -1
- package/script/generated-sdk/auth/types.js +1 -1
- package/script/generated-sdk/health/api.d.ts +24 -9
- package/script/generated-sdk/health/api.d.ts.map +1 -1
- package/script/generated-sdk/health/api.js +13 -21
- package/script/generated-sdk/health/client.d.ts +2 -1
- package/script/generated-sdk/health/client.d.ts.map +1 -1
- package/script/generated-sdk/health/contract.d.ts.map +1 -1
- package/script/generated-sdk/health/contract.js +2 -0
- package/script/generated-sdk/health/owned_api.d.ts +3 -0
- package/script/generated-sdk/health/owned_api.d.ts.map +1 -0
- package/script/generated-sdk/health/owned_api.js +19 -0
- package/script/generated-sdk/health/types.d.ts +2 -0
- package/script/generated-sdk/health/types.d.ts.map +1 -1
- package/script/generated-sdk/jobs/api.d.ts +33 -9
- package/script/generated-sdk/jobs/api.d.ts.map +1 -1
- package/script/generated-sdk/jobs/api.js +23 -88
- package/script/generated-sdk/jobs/client.d.ts +9 -2
- package/script/generated-sdk/jobs/client.d.ts.map +1 -1
- package/script/generated-sdk/jobs/contract.d.ts +1 -1
- package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
- package/script/generated-sdk/jobs/contract.js +4 -2
- package/script/generated-sdk/jobs/owned_api.d.ts +3 -0
- package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -0
- package/script/generated-sdk/jobs/owned_api.js +154 -0
- package/script/generated-sdk/jobs/schemas.d.ts +336 -123
- package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
- package/script/generated-sdk/jobs/schemas.js +18 -16
- package/script/generated-sdk/jobs/types.d.ts +144 -34
- package/script/generated-sdk/jobs/types.d.ts.map +1 -1
- package/script/generated-sdk/jobs/types.js +38 -2
- package/script/generated-sdk/state/api.d.ts +27 -9
- package/script/generated-sdk/state/api.d.ts.map +1 -1
- package/script/generated-sdk/state/api.js +17 -72
- package/script/generated-sdk/state/client.d.ts +4 -2
- package/script/generated-sdk/state/client.d.ts.map +1 -1
- package/script/generated-sdk/state/contract.d.ts +1 -1
- package/script/generated-sdk/state/contract.d.ts.map +1 -1
- package/script/generated-sdk/state/contract.js +4 -2
- package/script/generated-sdk/state/owned_api.d.ts +3 -0
- package/script/generated-sdk/state/owned_api.d.ts.map +1 -0
- package/script/generated-sdk/state/owned_api.js +69 -0
- package/script/generated-sdk/state/schemas.d.ts +264 -284
- package/script/generated-sdk/state/schemas.d.ts.map +1 -1
- package/script/generated-sdk/state/schemas.js +6 -6
- package/script/generated-sdk/state/types.d.ts +24 -23
- package/script/generated-sdk/state/types.d.ts.map +1 -1
- package/script/generated-sdk/state/types.js +1 -1
- package/script/generated-sdk/trellis-core/api.d.ts +27 -9
- package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/api.js +17 -40
- package/script/generated-sdk/trellis-core/client.d.ts +5 -2
- package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/contract.d.ts +1 -1
- package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/contract.js +4 -2
- package/script/generated-sdk/trellis-core/owned_api.d.ts +3 -0
- package/script/generated-sdk/trellis-core/owned_api.d.ts.map +1 -0
- package/script/generated-sdk/trellis-core/owned_api.js +45 -0
- package/script/generated-sdk/trellis-core/schemas.d.ts +259 -11
- package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/schemas.js +6 -4
- package/script/generated-sdk/trellis-core/types.d.ts +56 -1
- package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
- package/script/generated-sdk/trellis-core/types.js +1 -1
- package/script/helpers.d.ts.map +1 -1
- package/script/index.d.ts +4 -3
- package/script/index.d.ts.map +1 -1
- package/script/index.js +5 -2
- package/script/jobs.d.ts +10 -1
- package/script/jobs.d.ts.map +1 -1
- package/script/jobs.js +17 -2
- package/script/kv.d.ts.map +1 -1
- package/script/kv.js +10 -4
- package/script/models/auth/rpc/Logout.d.ts +4 -4
- package/script/models/auth/rpc/Logout.d.ts.map +1 -1
- package/script/models/auth/rpc/Logout.js +3 -3
- package/script/models/trellis/Page.d.ts +2 -0
- package/script/models/trellis/Page.d.ts.map +1 -0
- package/script/models/trellis/Page.js +6 -0
- package/script/models/trellis/State.d.ts +1 -0
- package/script/models/trellis/State.d.ts.map +1 -1
- package/script/models/trellis/State.js +1 -0
- package/script/models/trellis/rpc/StateList.d.ts +9 -12
- package/script/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/script/models/trellis/rpc/StateList.js +16 -18
- package/script/npm/src/auth/browser/login.d.ts.map +1 -1
- package/script/npm/src/auth/browser/login.js +46 -3
- package/script/npm/src/auth/browser/portal.d.ts.map +1 -1
- package/script/npm/src/auth/browser/portal.js +5 -1
- package/script/npm/src/auth/browser/session.d.ts +18 -7
- package/script/npm/src/auth/browser/session.d.ts.map +1 -1
- package/script/npm/src/auth/browser/session.js +47 -11
- package/script/npm/src/auth/browser/storage.d.ts +6 -1
- package/script/npm/src/auth/browser/storage.d.ts.map +1 -1
- package/script/npm/src/auth/browser/storage.js +15 -3
- package/script/npm/src/auth/browser.d.ts +2 -2
- package/script/npm/src/auth/browser.d.ts.map +1 -1
- package/script/npm/src/auth/browser.js +2 -1
- package/script/npm/src/auth/device_activation.d.ts +36 -33
- package/script/npm/src/auth/device_activation.d.ts.map +1 -1
- package/script/npm/src/auth/device_activation.js +25 -21
- package/script/npm/src/auth/mod.d.ts +4 -4
- package/script/npm/src/auth/mod.d.ts.map +1 -1
- package/script/npm/src/auth/mod.js +132 -137
- package/script/npm/src/auth/proof.d.ts +3 -1
- package/script/npm/src/auth/proof.d.ts.map +1 -1
- package/script/npm/src/auth/proof.js +21 -15
- package/script/npm/src/auth/protocol.d.ts +2457 -941
- package/script/npm/src/auth/protocol.d.ts.map +1 -1
- package/script/npm/src/auth/protocol.js +749 -377
- package/script/npm/src/auth/schemas.d.ts +25 -4
- package/script/npm/src/auth/schemas.d.ts.map +1 -1
- package/script/npm/src/auth/schemas.js +16 -5
- package/script/npm/src/auth/session_auth.d.ts +1 -1
- package/script/npm/src/auth/session_auth.d.ts.map +1 -1
- package/script/npm/src/auth/session_auth.js +7 -1
- package/script/npm/src/client_connect.d.ts +2 -0
- package/script/npm/src/client_connect.d.ts.map +1 -1
- package/script/npm/src/client_connect.js +76 -15
- package/script/npm/src/contract.d.ts +3 -0
- package/script/npm/src/contract.d.ts.map +1 -1
- package/script/npm/src/contract_support/mod.d.ts +422 -43
- package/script/npm/src/contract_support/mod.d.ts.map +1 -1
- package/script/npm/src/contract_support/mod.js +757 -51
- package/script/npm/src/contract_support/protocol.d.ts +20 -5
- package/script/npm/src/contract_support/protocol.d.ts.map +1 -1
- package/script/npm/src/contract_support/protocol.js +20 -11
- package/script/npm/src/contract_support/runtime.d.ts +11 -0
- package/script/npm/src/contract_support/runtime.d.ts.map +1 -1
- package/script/npm/src/contract_support/schema_pointers.d.ts.map +1 -1
- package/script/npm/src/contract_support/schema_pointers.js +32 -14
- package/script/npm/src/device/deno.d.ts.map +1 -1
- package/script/npm/src/device/deno.js +6 -0
- package/script/npm/src/device.d.ts +2 -0
- package/script/npm/src/device.d.ts.map +1 -1
- package/script/npm/src/device.js +3 -0
- package/script/npm/src/errors/AuthError.d.ts +2 -1
- package/script/npm/src/errors/AuthError.d.ts.map +1 -1
- package/script/npm/src/errors/AuthError.js +8 -3
- package/script/npm/src/errors/index.d.ts +4 -4
- package/script/npm/src/errors/index.d.ts.map +1 -1
- package/script/npm/src/errors/index.js +1 -0
- package/script/npm/src/generate.js +39 -59
- package/script/npm/src/helpers.d.ts.map +1 -1
- package/script/npm/src/index.d.ts +4 -3
- package/script/npm/src/index.d.ts.map +1 -1
- package/script/npm/src/index.js +5 -2
- package/script/npm/src/jobs.d.ts +10 -1
- package/script/npm/src/jobs.d.ts.map +1 -1
- package/script/npm/src/jobs.js +17 -2
- package/script/npm/src/kv.d.ts.map +1 -1
- package/script/npm/src/kv.js +10 -4
- package/script/npm/src/models/auth/rpc/Logout.d.ts +4 -4
- package/script/npm/src/models/auth/rpc/Logout.d.ts.map +1 -1
- package/script/npm/src/models/auth/rpc/Logout.js +3 -3
- package/script/npm/src/models/trellis/Page.d.ts +2 -0
- package/script/npm/src/models/trellis/Page.d.ts.map +1 -0
- package/script/npm/src/models/trellis/Page.js +6 -0
- package/script/npm/src/models/trellis/State.d.ts +1 -0
- package/script/npm/src/models/trellis/State.d.ts.map +1 -1
- package/script/npm/src/models/trellis/State.js +1 -0
- package/script/npm/src/models/trellis/rpc/StateList.d.ts +9 -12
- package/script/npm/src/models/trellis/rpc/StateList.d.ts.map +1 -1
- package/script/npm/src/models/trellis/rpc/StateList.js +16 -18
- package/script/npm/src/operations.d.ts +16 -7
- package/script/npm/src/operations.d.ts.map +1 -1
- package/script/npm/src/operations.js +84 -19
- package/script/npm/src/runtime_transport.d.ts +2 -0
- package/script/npm/src/runtime_transport.d.ts.map +1 -1
- package/script/npm/src/runtime_transport.js +2 -1
- package/script/npm/src/server/internal_jobs/active-job.d.ts +2 -1
- package/script/npm/src/server/internal_jobs/active-job.d.ts.map +1 -1
- package/script/npm/src/server/internal_jobs/active-job.js +3 -0
- package/script/npm/src/server/internal_jobs/job-manager.d.ts +4 -1
- package/script/npm/src/server/internal_jobs/job-manager.d.ts.map +1 -1
- package/script/npm/src/server/internal_jobs/job-manager.js +61 -1
- package/script/npm/src/server/internal_jobs/projection.js +1 -0
- package/script/npm/src/server/internal_jobs/runtime-worker.d.ts +13 -1
- package/script/npm/src/server/internal_jobs/runtime-worker.d.ts.map +1 -1
- package/script/npm/src/server/internal_jobs/runtime-worker.js +74 -13
- package/script/npm/src/server/internal_jobs/types.d.ts +19 -0
- package/script/npm/src/server/internal_jobs/types.d.ts.map +1 -1
- package/script/npm/src/server/internal_jobs/types.js +11 -1
- package/script/npm/src/server/runtime.d.ts +1 -0
- package/script/npm/src/server/runtime.d.ts.map +1 -1
- package/script/npm/src/server/service.d.ts +10 -1
- package/script/npm/src/server/service.d.ts.map +1 -1
- package/script/npm/src/server/service.js +208 -62
- package/script/npm/src/server/transfer.d.ts.map +1 -1
- package/script/npm/src/server/transfer.js +4 -0
- package/script/npm/src/server.d.ts.map +1 -1
- package/script/npm/src/server.js +336 -33
- package/script/npm/src/store.d.ts +8 -1
- package/script/npm/src/store.d.ts.map +1 -1
- package/script/npm/src/store.js +46 -8
- package/script/npm/src/transfer.d.ts +3 -0
- package/script/npm/src/transfer.d.ts.map +1 -1
- package/script/npm/src/transfer.js +19 -29
- package/script/npm/src/trellis.d.ts +85 -22
- package/script/npm/src/trellis.d.ts.map +1 -1
- package/script/npm/src/trellis.js +525 -61
- package/script/operations.d.ts +16 -7
- package/script/operations.d.ts.map +1 -1
- package/script/operations.js +84 -19
- package/script/runtime_transport.d.ts +2 -0
- package/script/runtime_transport.d.ts.map +1 -1
- package/script/runtime_transport.js +2 -1
- package/script/store.d.ts +8 -1
- package/script/store.d.ts.map +1 -1
- package/script/store.js +46 -8
- package/script/transfer.d.ts +3 -0
- package/script/transfer.d.ts.map +1 -1
- package/script/transfer.js +19 -29
- package/script/trellis.d.ts +85 -22
- package/script/trellis.d.ts.map +1 -1
- package/script/trellis.js +525 -61
- package/src/_dnt.polyfills.ts +274 -0
- package/src/_dnt.shims.ts +64 -0
- package/src/auth/browser/login.ts +295 -0
- package/src/auth/browser/portal.ts +75 -0
- package/src/auth/browser/session.ts +197 -0
- package/src/auth/browser/storage.ts +105 -0
- package/src/auth/browser.ts +82 -0
- package/src/auth/device_activation.ts +715 -0
- package/src/auth/keys.ts +116 -0
- package/src/auth/mod.ts +298 -0
- package/src/auth/proof.ts +111 -0
- package/src/auth/protocol.ts +1629 -0
- package/src/auth/schemas.ts +145 -0
- package/src/auth/session_auth.ts +167 -0
- package/src/auth/time.ts +15 -0
- package/src/auth/trellis_id.ts +9 -0
- package/src/auth/types.ts +4 -0
- package/src/auth/utils.ts +87 -0
- package/src/auth.ts +2 -0
- package/src/browser.ts +8 -0
- package/src/client.ts +164 -0
- package/src/client_connect.ts +1328 -0
- package/src/codec.ts +107 -0
- package/src/connection.ts +466 -0
- package/src/contract.ts +84 -0
- package/src/contract_support/canonical.ts +217 -0
- package/src/contract_support/mod.ts +5079 -0
- package/src/contract_support/protocol.ts +213 -0
- package/src/contract_support/runtime.ts +129 -0
- package/src/contract_support/schema_pointers.ts +161 -0
- package/src/contracts.ts +9 -0
- package/src/device/deno.ts +941 -0
- package/src/device.ts +989 -0
- package/src/env.ts +1 -0
- package/src/errors/AuthError.ts +82 -0
- package/src/errors/KVError.ts +47 -0
- package/src/errors/RemoteError.ts +111 -0
- package/src/errors/StoreError.ts +43 -0
- package/src/errors/TransferError.ts +43 -0
- package/src/errors/TransportError.ts +48 -0
- package/src/errors/TrellisError.ts +20 -0
- package/src/errors/ValidationError.ts +80 -0
- package/src/errors/index.ts +195 -0
- package/src/generate.ts +329 -0
- package/src/globals.ts +26 -0
- package/src/health.ts +28 -0
- package/src/helpers.ts +63 -0
- package/src/host/mod.ts +9 -0
- package/src/host/node.ts +9 -0
- package/src/index.ts +233 -0
- package/src/jobs.ts +344 -0
- package/src/kv.ts +564 -0
- package/src/models/auth/rpc/Logout.ts +15 -0
- package/src/models/trellis/Page.ts +6 -0
- package/src/models/trellis/State.ts +55 -0
- package/src/models/trellis/TrellisError.ts +21 -0
- package/src/models/trellis/rpc/StateDelete.ts +13 -0
- package/src/models/trellis/rpc/StateGet.ts +25 -0
- package/src/models/trellis/rpc/StateList.ts +26 -0
- package/src/models/trellis/rpc/StatePut.ts +42 -0
- package/src/operations.ts +1508 -0
- package/src/runtime_transport.ts +132 -0
- package/src/sdk/auth.ts +2 -0
- package/src/sdk/core.ts +2 -0
- package/src/sdk/health.ts +2 -0
- package/src/sdk/jobs.ts +2 -0
- package/src/sdk/state.ts +2 -0
- package/src/server/health.ts +379 -0
- package/src/server/health_rpc.ts +51 -0
- package/src/server/health_schemas.ts +61 -0
- package/src/server/internal_jobs/active-job.ts +115 -0
- package/src/server/internal_jobs/bindings.ts +26 -0
- package/src/server/internal_jobs/cancellation-registry.ts +71 -0
- package/src/server/internal_jobs/heartbeat.ts +120 -0
- package/src/server/internal_jobs/job-manager.ts +456 -0
- package/src/server/internal_jobs/projection.ts +48 -0
- package/src/server/internal_jobs/runtime-worker.ts +741 -0
- package/src/server/internal_jobs/types.ts +124 -0
- package/src/server/runtime.ts +27 -0
- package/src/server/service.ts +2377 -0
- package/src/server/subscription.ts +143 -0
- package/src/server/transfer.ts +962 -0
- package/src/server.ts +1725 -0
- package/src/server_logger.ts +10 -0
- package/src/service/deno.ts +18 -0
- package/src/service/mod.ts +68 -0
- package/src/service/node.ts +18 -0
- package/src/store.ts +658 -0
- package/src/tasks.ts +34 -0
- package/src/telemetry/carrier.ts +35 -0
- package/src/telemetry/core.ts +31 -0
- package/src/telemetry/env.ts +23 -0
- package/src/telemetry/mod.ts +26 -0
- package/src/telemetry/nats.ts +15 -0
- package/src/telemetry/result.ts +20 -0
- package/src/telemetry/trace.ts +39 -0
- package/src/telemetry/trellis.ts +1 -0
- package/src/tracing.ts +28 -0
- package/src/transfer.ts +602 -0
- package/src/trellis.ts +3650 -0
- package/esm/models/trellis/Paginate.d.ts +0 -7
- package/esm/models/trellis/Paginate.d.ts.map +0 -1
- package/esm/models/trellis/Paginate.js +0 -5
- package/esm/npm/src/models/trellis/Paginate.d.ts +0 -7
- package/esm/npm/src/models/trellis/Paginate.d.ts.map +0 -1
- package/esm/npm/src/models/trellis/Paginate.js +0 -5
- package/script/models/trellis/Paginate.d.ts +0 -7
- package/script/models/trellis/Paginate.d.ts.map +0 -1
- package/script/models/trellis/Paginate.js +0 -11
- package/script/npm/src/models/trellis/Paginate.d.ts +0 -7
- package/script/npm/src/models/trellis/Paginate.d.ts.map +0 -1
- package/script/npm/src/models/trellis/Paginate.js +0 -11
|
@@ -1,11 +1,157 @@
|
|
|
1
1
|
import Type from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
2
3
|
import { TrellisError } from "../errors/TrellisError.js";
|
|
3
4
|
import { canonicalizeJson, digestJson, isJsonValue, sha256Base64urlSync, } from "./canonical.js";
|
|
4
5
|
import { schema, unwrapSchema, } from "./runtime.js";
|
|
5
6
|
import { assertDataPointersExistAndAreTokenable, getSubschemaAtDataPointer, } from "./schema_pointers.js";
|
|
6
|
-
|
|
7
|
+
import { ContractJobQueueSchema, ContractResourcesSchema, ContractSchemaRefSchema, ContractStateSchema, } from "./protocol.js";
|
|
8
|
+
export { ContractJobQueueSchema, ContractJobsSchema, ContractKvResourceSchema, ContractResourceBindingsSchema, ContractResourcesSchema, ContractSchemaRefSchema, ContractStateSchema, ContractStateStoreSchema, ContractStoreResourceSchema, EventHeaderSchema, InstalledServiceContractSchema, IsoDateSchema, JobsQueueBindingSchema, JobsResourceBindingSchema, KvResourceBindingSchema, PageRequestSchema, PageResponseSchema, StoreResourceBindingSchema, } from "./protocol.js";
|
|
7
9
|
export const CONTRACT_FORMAT_V1 = "trellis.contract.v1";
|
|
8
10
|
export const CATALOG_FORMAT_V1 = "trellis.catalog.v1";
|
|
11
|
+
const NonEmptyStringSchema = Type.String({ minLength: 1 });
|
|
12
|
+
const VersionSchema = Type.String({ pattern: "^v[0-9]+$" });
|
|
13
|
+
const PointerStringSchema = Type.String({ pattern: "^/.*" });
|
|
14
|
+
const CapabilityListSchema = Type.Array(NonEmptyStringSchema);
|
|
15
|
+
const JsonSchemaValueSchema = Type.Union([
|
|
16
|
+
Type.Object({}, { additionalProperties: true }),
|
|
17
|
+
Type.Boolean(),
|
|
18
|
+
]);
|
|
19
|
+
export const ContractCapabilityMetadataSchema = Type.Object({
|
|
20
|
+
displayName: NonEmptyStringSchema,
|
|
21
|
+
description: NonEmptyStringSchema,
|
|
22
|
+
consequence: Type.Optional(NonEmptyStringSchema),
|
|
23
|
+
});
|
|
24
|
+
export const ContractCapabilitiesSchema = Type.Record(NonEmptyStringSchema, ContractCapabilityMetadataSchema);
|
|
25
|
+
export const ContractExportsSchema = Type.Object({
|
|
26
|
+
schemas: Type.Optional(Type.Array(NonEmptyStringSchema, { uniqueItems: true })),
|
|
27
|
+
});
|
|
28
|
+
const ContractUseRpcSchema = Type.Object({
|
|
29
|
+
call: Type.Optional(CapabilityListSchema),
|
|
30
|
+
});
|
|
31
|
+
const ContractUsePubSubSchema = Type.Object({
|
|
32
|
+
publish: Type.Optional(CapabilityListSchema),
|
|
33
|
+
subscribe: Type.Optional(CapabilityListSchema),
|
|
34
|
+
});
|
|
35
|
+
const ContractUseFeedSchema = Type.Object({
|
|
36
|
+
subscribe: Type.Optional(CapabilityListSchema),
|
|
37
|
+
});
|
|
38
|
+
const ContractUseSchema = Type.Object({
|
|
39
|
+
contract: NonEmptyStringSchema,
|
|
40
|
+
rpc: Type.Optional(ContractUseRpcSchema),
|
|
41
|
+
operations: Type.Optional(ContractUseRpcSchema),
|
|
42
|
+
events: Type.Optional(ContractUsePubSubSchema),
|
|
43
|
+
feeds: Type.Optional(ContractUseFeedSchema),
|
|
44
|
+
});
|
|
45
|
+
const ContractUsesFlatSchema = Type.Record(NonEmptyStringSchema, ContractUseSchema);
|
|
46
|
+
export const ContractUsesSchema = Type.Object({
|
|
47
|
+
required: Type.Optional(ContractUsesFlatSchema),
|
|
48
|
+
optional: Type.Optional(ContractUsesFlatSchema),
|
|
49
|
+
});
|
|
50
|
+
const ContractErrorDeclSchema = Type.Object({
|
|
51
|
+
type: NonEmptyStringSchema,
|
|
52
|
+
schema: Type.Optional(ContractSchemaRefSchema),
|
|
53
|
+
});
|
|
54
|
+
const ContractErrorRefSchema = Type.Object({
|
|
55
|
+
type: NonEmptyStringSchema,
|
|
56
|
+
});
|
|
57
|
+
const RpcCapabilitiesSchema = Type.Object({
|
|
58
|
+
call: Type.Optional(CapabilityListSchema),
|
|
59
|
+
});
|
|
60
|
+
const OperationCapabilitiesSchema = Type.Object({
|
|
61
|
+
call: Type.Optional(CapabilityListSchema),
|
|
62
|
+
read: Type.Optional(CapabilityListSchema),
|
|
63
|
+
cancel: Type.Optional(CapabilityListSchema),
|
|
64
|
+
control: Type.Optional(CapabilityListSchema),
|
|
65
|
+
});
|
|
66
|
+
const PubSubCapabilitiesSchema = Type.Object({
|
|
67
|
+
publish: Type.Optional(CapabilityListSchema),
|
|
68
|
+
subscribe: Type.Optional(CapabilityListSchema),
|
|
69
|
+
});
|
|
70
|
+
const FeedCapabilitiesSchema = Type.Object({
|
|
71
|
+
subscribe: Type.Optional(CapabilityListSchema),
|
|
72
|
+
});
|
|
73
|
+
const RpcTransferSchema = Type.Object({
|
|
74
|
+
direction: Type.Literal("receive"),
|
|
75
|
+
});
|
|
76
|
+
const OperationTransferSchema = Type.Object({
|
|
77
|
+
direction: Type.Literal("send"),
|
|
78
|
+
store: NonEmptyStringSchema,
|
|
79
|
+
key: PointerStringSchema,
|
|
80
|
+
contentType: Type.Optional(PointerStringSchema),
|
|
81
|
+
metadata: Type.Optional(PointerStringSchema),
|
|
82
|
+
expiresInMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
83
|
+
maxBytes: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
84
|
+
});
|
|
85
|
+
const ContractRpcMethodSchema = Type.Object({
|
|
86
|
+
version: VersionSchema,
|
|
87
|
+
subject: NonEmptyStringSchema,
|
|
88
|
+
input: ContractSchemaRefSchema,
|
|
89
|
+
output: ContractSchemaRefSchema,
|
|
90
|
+
capabilities: Type.Optional(RpcCapabilitiesSchema),
|
|
91
|
+
errors: Type.Optional(Type.Array(ContractErrorRefSchema)),
|
|
92
|
+
transfer: Type.Optional(RpcTransferSchema),
|
|
93
|
+
});
|
|
94
|
+
const ContractOperationSignalSchema = Type.Object({
|
|
95
|
+
input: ContractSchemaRefSchema,
|
|
96
|
+
});
|
|
97
|
+
const ContractOperationSchema = Type.Object({
|
|
98
|
+
version: VersionSchema,
|
|
99
|
+
subject: NonEmptyStringSchema,
|
|
100
|
+
input: ContractSchemaRefSchema,
|
|
101
|
+
progress: Type.Optional(ContractSchemaRefSchema),
|
|
102
|
+
output: ContractSchemaRefSchema,
|
|
103
|
+
transfer: Type.Optional(OperationTransferSchema),
|
|
104
|
+
capabilities: Type.Optional(OperationCapabilitiesSchema),
|
|
105
|
+
signals: Type.Optional(Type.Record(NonEmptyStringSchema, ContractOperationSignalSchema)),
|
|
106
|
+
cancel: Type.Optional(Type.Boolean()),
|
|
107
|
+
});
|
|
108
|
+
const ContractEventSchema = Type.Object({
|
|
109
|
+
version: VersionSchema,
|
|
110
|
+
subject: NonEmptyStringSchema,
|
|
111
|
+
params: Type.Optional(Type.Array(PointerStringSchema)),
|
|
112
|
+
event: ContractSchemaRefSchema,
|
|
113
|
+
capabilities: Type.Optional(PubSubCapabilitiesSchema),
|
|
114
|
+
});
|
|
115
|
+
const ContractFeedSchema = Type.Object({
|
|
116
|
+
version: VersionSchema,
|
|
117
|
+
subject: NonEmptyStringSchema,
|
|
118
|
+
input: ContractSchemaRefSchema,
|
|
119
|
+
event: ContractSchemaRefSchema,
|
|
120
|
+
capabilities: Type.Optional(FeedCapabilitiesSchema),
|
|
121
|
+
});
|
|
122
|
+
export const TrellisContractV1Schema = Type.Object({
|
|
123
|
+
format: Type.Literal(CONTRACT_FORMAT_V1),
|
|
124
|
+
id: NonEmptyStringSchema,
|
|
125
|
+
displayName: NonEmptyStringSchema,
|
|
126
|
+
description: NonEmptyStringSchema,
|
|
127
|
+
kind: Type.Union([
|
|
128
|
+
Type.Literal("service"),
|
|
129
|
+
Type.Literal("app"),
|
|
130
|
+
Type.Literal("device"),
|
|
131
|
+
Type.Literal("agent"),
|
|
132
|
+
]),
|
|
133
|
+
capabilities: Type.Optional(ContractCapabilitiesSchema),
|
|
134
|
+
schemas: Type.Optional(Type.Record(NonEmptyStringSchema, JsonSchemaValueSchema)),
|
|
135
|
+
exports: Type.Optional(ContractExportsSchema),
|
|
136
|
+
uses: Type.Optional(ContractUsesSchema),
|
|
137
|
+
state: Type.Optional(ContractStateSchema),
|
|
138
|
+
rpc: Type.Optional(Type.Record(NonEmptyStringSchema, ContractRpcMethodSchema)),
|
|
139
|
+
operations: Type.Optional(Type.Record(NonEmptyStringSchema, ContractOperationSchema)),
|
|
140
|
+
events: Type.Optional(Type.Record(NonEmptyStringSchema, ContractEventSchema)),
|
|
141
|
+
feeds: Type.Optional(Type.Record(NonEmptyStringSchema, ContractFeedSchema)),
|
|
142
|
+
errors: Type.Optional(Type.Record(NonEmptyStringSchema, ContractErrorDeclSchema)),
|
|
143
|
+
jobs: Type.Optional(Type.Record(NonEmptyStringSchema, ContractJobQueueSchema)),
|
|
144
|
+
resources: Type.Optional(ContractResourcesSchema),
|
|
145
|
+
});
|
|
146
|
+
export const TrellisCatalogV1Schema = Type.Object({
|
|
147
|
+
format: Type.Literal(CATALOG_FORMAT_V1),
|
|
148
|
+
contracts: Type.Array(Type.Object({
|
|
149
|
+
id: NonEmptyStringSchema,
|
|
150
|
+
digest: Type.String({ pattern: "^[A-Za-z0-9_-]+$" }),
|
|
151
|
+
displayName: NonEmptyStringSchema,
|
|
152
|
+
description: NonEmptyStringSchema,
|
|
153
|
+
})),
|
|
154
|
+
});
|
|
9
155
|
const CONTRACT_MODULE_METADATA = Symbol.for("@qlever-llc/trellis/contracts/contract-module");
|
|
10
156
|
export const CONTRACT_JOBS_METADATA = Symbol.for("@qlever-llc/trellis/contracts/jobs");
|
|
11
157
|
export const CONTRACT_KV_METADATA = Symbol.for("@qlever-llc/trellis/contracts/kv");
|
|
@@ -85,13 +231,18 @@ function attachDefinedErrorPayload(error, payload) {
|
|
|
85
231
|
}
|
|
86
232
|
const TRELLIS_AUTH_CONTRACT_ID = "trellis.auth@v1";
|
|
87
233
|
const TRELLIS_STATE_CONTRACT_ID = "trellis.state@v1";
|
|
88
|
-
const
|
|
234
|
+
const TRELLIS_HEALTH_CONTRACT_ID = "trellis.health@v1";
|
|
235
|
+
const BASELINE_AUTH_RPC_CALL = [
|
|
236
|
+
"Auth.Sessions.Me",
|
|
237
|
+
"Auth.Sessions.Logout",
|
|
238
|
+
];
|
|
89
239
|
const BASELINE_STATE_RPC_CALL = [
|
|
90
240
|
"State.Get",
|
|
91
241
|
"State.Put",
|
|
92
242
|
"State.Delete",
|
|
93
243
|
"State.List",
|
|
94
244
|
];
|
|
245
|
+
const BASELINE_HEALTH_EVENTS_PUBLISH = ["Health.Heartbeat"];
|
|
95
246
|
const UnknownRuntimeSchema = schema(Type.Unknown());
|
|
96
247
|
function typedUnknownRuntimeSchema() {
|
|
97
248
|
return UnknownRuntimeSchema;
|
|
@@ -104,13 +255,22 @@ function trellisRpcDesc(name) {
|
|
|
104
255
|
callerCapabilities: [],
|
|
105
256
|
};
|
|
106
257
|
}
|
|
258
|
+
function trellisEventDesc(name) {
|
|
259
|
+
return {
|
|
260
|
+
subject: eventSubject(name, "v1", undefined),
|
|
261
|
+
event: typedUnknownRuntimeSchema(),
|
|
262
|
+
publishCapabilities: [],
|
|
263
|
+
subscribeCapabilities: [],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
107
266
|
const BASELINE_AUTH_API = {
|
|
108
267
|
rpc: {
|
|
109
|
-
"Auth.Me": trellisRpcDesc("Auth.Me"),
|
|
110
|
-
"Auth.Logout": trellisRpcDesc("Auth.Logout"),
|
|
268
|
+
"Auth.Sessions.Me": trellisRpcDesc("Auth.Sessions.Me"),
|
|
269
|
+
"Auth.Sessions.Logout": trellisRpcDesc("Auth.Sessions.Logout"),
|
|
111
270
|
},
|
|
112
271
|
operations: {},
|
|
113
272
|
events: {},
|
|
273
|
+
feeds: {},
|
|
114
274
|
subjects: {},
|
|
115
275
|
};
|
|
116
276
|
const BASELINE_STATE_API = {
|
|
@@ -122,6 +282,16 @@ const BASELINE_STATE_API = {
|
|
|
122
282
|
},
|
|
123
283
|
operations: {},
|
|
124
284
|
events: {},
|
|
285
|
+
feeds: {},
|
|
286
|
+
subjects: {},
|
|
287
|
+
};
|
|
288
|
+
const BASELINE_HEALTH_API = {
|
|
289
|
+
rpc: {},
|
|
290
|
+
operations: {},
|
|
291
|
+
events: {
|
|
292
|
+
"Health.Heartbeat": trellisEventDesc("Health.Heartbeat"),
|
|
293
|
+
},
|
|
294
|
+
feeds: {},
|
|
125
295
|
subjects: {},
|
|
126
296
|
};
|
|
127
297
|
function createContractRefBuilder(registry) {
|
|
@@ -138,6 +308,9 @@ function createContractRefBuilder(registry) {
|
|
|
138
308
|
error(errorName) {
|
|
139
309
|
return errorName;
|
|
140
310
|
},
|
|
311
|
+
capability(capabilityName) {
|
|
312
|
+
return capabilityName;
|
|
313
|
+
},
|
|
141
314
|
};
|
|
142
315
|
}
|
|
143
316
|
function cloneSchema(schemaValue) {
|
|
@@ -269,9 +442,18 @@ function assertRegistryDoesNotDeclareExports(registry) {
|
|
|
269
442
|
throw new Error("contract exports must be declared in the callback body, not the registry argument");
|
|
270
443
|
}
|
|
271
444
|
}
|
|
445
|
+
function assertRegistryDoesNotDeclareCapabilities(registry) {
|
|
446
|
+
if (Object.hasOwn(registry, "capabilities")) {
|
|
447
|
+
throw new Error("contract capabilities must be declared in the callback body, not the registry argument");
|
|
448
|
+
}
|
|
449
|
+
}
|
|
272
450
|
function resolveSchemaRef(schemas, ref, context) {
|
|
273
451
|
assertSchemaRefExists(schemas, ref, context);
|
|
274
|
-
|
|
452
|
+
const schema = schemas?.[ref.schema];
|
|
453
|
+
if (!schema) {
|
|
454
|
+
throw new Error(`${context} references missing schema '${ref.schema}'`);
|
|
455
|
+
}
|
|
456
|
+
return cloneSchema(schema);
|
|
275
457
|
}
|
|
276
458
|
function digestCanonicalJson(value) {
|
|
277
459
|
return sha256Base64urlSync(canonicalizeJson(value));
|
|
@@ -279,6 +461,41 @@ function digestCanonicalJson(value) {
|
|
|
279
461
|
function sortedUnique(values) {
|
|
280
462
|
return [...new Set(values)].sort();
|
|
281
463
|
}
|
|
464
|
+
/** Return the global capability namespace for a contract id. */
|
|
465
|
+
export function contractCapabilityNamespace(contractId) {
|
|
466
|
+
return contractId.replace(/@v\d+$/, "");
|
|
467
|
+
}
|
|
468
|
+
/** Return the globally qualified name for a contract-local capability. */
|
|
469
|
+
export function globalCapabilityName(contractId, localCapability) {
|
|
470
|
+
return `${contractCapabilityNamespace(contractId)}::${localCapability}`;
|
|
471
|
+
}
|
|
472
|
+
function projectCapabilities(capabilities, contractId, declaredCapabilities, context) {
|
|
473
|
+
if (!capabilities) {
|
|
474
|
+
return undefined;
|
|
475
|
+
}
|
|
476
|
+
return sortedUnique(capabilities.map((capability) => {
|
|
477
|
+
if (declaredCapabilities && Object.hasOwn(declaredCapabilities, capability)) {
|
|
478
|
+
return globalCapabilityName(contractId, capability);
|
|
479
|
+
}
|
|
480
|
+
if (capability === "admin" || capability === "service" ||
|
|
481
|
+
capability.includes("::")) {
|
|
482
|
+
return capability;
|
|
483
|
+
}
|
|
484
|
+
throw new Error(`${context} references undeclared local capability '${capability}'`);
|
|
485
|
+
}));
|
|
486
|
+
}
|
|
487
|
+
function emitCapabilities(contractId, capabilities) {
|
|
488
|
+
if (!capabilities) {
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
const entries = Object.entries(capabilities)
|
|
492
|
+
.map(([localCapability, metadata]) => [
|
|
493
|
+
globalCapabilityName(contractId, localCapability),
|
|
494
|
+
{ ...metadata },
|
|
495
|
+
]);
|
|
496
|
+
entries.sort(([left], [right]) => left.localeCompare(right));
|
|
497
|
+
return Object.fromEntries(entries);
|
|
498
|
+
}
|
|
282
499
|
function collectSchemaRef(reachableSchemas, ref) {
|
|
283
500
|
if (ref) {
|
|
284
501
|
reachableSchemas.add(ref.schema);
|
|
@@ -304,10 +521,17 @@ function collectReachableSchemaNames(contract) {
|
|
|
304
521
|
collectSchemaRef(reachableSchemas, operation.input);
|
|
305
522
|
collectSchemaRef(reachableSchemas, operation.progress);
|
|
306
523
|
collectSchemaRef(reachableSchemas, operation.output);
|
|
524
|
+
for (const signal of Object.values(operation.signals ?? {})) {
|
|
525
|
+
collectSchemaRef(reachableSchemas, signal.input);
|
|
526
|
+
}
|
|
307
527
|
}
|
|
308
528
|
for (const event of Object.values(contract.events ?? {})) {
|
|
309
529
|
collectSchemaRef(reachableSchemas, event.event);
|
|
310
530
|
}
|
|
531
|
+
for (const feed of Object.values(contract.feeds ?? {})) {
|
|
532
|
+
collectSchemaRef(reachableSchemas, feed.input);
|
|
533
|
+
collectSchemaRef(reachableSchemas, feed.event);
|
|
534
|
+
}
|
|
311
535
|
for (const job of Object.values(contract.jobs ?? {})) {
|
|
312
536
|
collectSchemaRef(reachableSchemas, job.payload);
|
|
313
537
|
collectSchemaRef(reachableSchemas, job.result);
|
|
@@ -347,7 +571,7 @@ function projectDigestResources(resources) {
|
|
|
347
571
|
...(resources.store ? { store: resources.store } : {}),
|
|
348
572
|
};
|
|
349
573
|
}
|
|
350
|
-
function
|
|
574
|
+
function projectDigestUsesFlat(uses) {
|
|
351
575
|
if (!uses) {
|
|
352
576
|
return undefined;
|
|
353
577
|
}
|
|
@@ -371,9 +595,37 @@ function projectDigestUses(uses) {
|
|
|
371
595
|
},
|
|
372
596
|
}
|
|
373
597
|
: {}),
|
|
598
|
+
...(use.feeds?.subscribe
|
|
599
|
+
? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
|
|
600
|
+
: {}),
|
|
374
601
|
},
|
|
375
602
|
]));
|
|
376
603
|
}
|
|
604
|
+
function omitRequiredUseAliases(optional, required) {
|
|
605
|
+
if (!optional) {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
if (!required) {
|
|
609
|
+
return optional;
|
|
610
|
+
}
|
|
611
|
+
const requiredAliases = new Set(Object.keys(required));
|
|
612
|
+
const entries = Object.entries(optional).filter(([alias]) => !requiredAliases.has(alias));
|
|
613
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
614
|
+
}
|
|
615
|
+
function projectDigestUses(uses) {
|
|
616
|
+
if (!uses) {
|
|
617
|
+
return undefined;
|
|
618
|
+
}
|
|
619
|
+
const required = projectDigestUsesFlat(uses.required);
|
|
620
|
+
const optional = omitRequiredUseAliases(projectDigestUsesFlat(uses.optional), required);
|
|
621
|
+
if (!required && !optional) {
|
|
622
|
+
return undefined;
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
...(required ? { required } : {}),
|
|
626
|
+
...(optional ? { optional } : {}),
|
|
627
|
+
};
|
|
628
|
+
}
|
|
377
629
|
function projectDigestRpc(rpc) {
|
|
378
630
|
if (!rpc) {
|
|
379
631
|
return undefined;
|
|
@@ -402,7 +654,7 @@ function projectDigestOperations(operations) {
|
|
|
402
654
|
{
|
|
403
655
|
...operation,
|
|
404
656
|
...((operation.capabilities?.call || operation.capabilities?.read ||
|
|
405
|
-
operation.capabilities?.cancel)
|
|
657
|
+
operation.capabilities?.cancel || operation.capabilities?.control)
|
|
406
658
|
? {
|
|
407
659
|
capabilities: {
|
|
408
660
|
...(operation.capabilities.call
|
|
@@ -414,6 +666,9 @@ function projectDigestOperations(operations) {
|
|
|
414
666
|
...(operation.capabilities.cancel
|
|
415
667
|
? { cancel: sortedUnique(operation.capabilities.cancel) }
|
|
416
668
|
: {}),
|
|
669
|
+
...(operation.capabilities.control
|
|
670
|
+
? { control: sortedUnique(operation.capabilities.control) }
|
|
671
|
+
: {}),
|
|
417
672
|
},
|
|
418
673
|
}
|
|
419
674
|
: {}),
|
|
@@ -443,6 +698,314 @@ function projectDigestEvents(events) {
|
|
|
443
698
|
},
|
|
444
699
|
]));
|
|
445
700
|
}
|
|
701
|
+
function projectDigestFeeds(feeds) {
|
|
702
|
+
if (!feeds) {
|
|
703
|
+
return undefined;
|
|
704
|
+
}
|
|
705
|
+
return Object.fromEntries(Object.entries(feeds).map(([name, feed]) => [
|
|
706
|
+
name,
|
|
707
|
+
{
|
|
708
|
+
...feed,
|
|
709
|
+
...(feed.capabilities?.subscribe
|
|
710
|
+
? {
|
|
711
|
+
capabilities: {
|
|
712
|
+
subscribe: sortedUnique(feed.capabilities.subscribe),
|
|
713
|
+
},
|
|
714
|
+
}
|
|
715
|
+
: {}),
|
|
716
|
+
},
|
|
717
|
+
]));
|
|
718
|
+
}
|
|
719
|
+
function mapValues(values, map) {
|
|
720
|
+
if (!values)
|
|
721
|
+
return undefined;
|
|
722
|
+
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, map(value)]));
|
|
723
|
+
}
|
|
724
|
+
function schemaRef(ref) {
|
|
725
|
+
return { schema: ref.schema };
|
|
726
|
+
}
|
|
727
|
+
function capabilityMetadata(metadata) {
|
|
728
|
+
return {
|
|
729
|
+
displayName: metadata.displayName,
|
|
730
|
+
description: metadata.description,
|
|
731
|
+
...(metadata.consequence ? { consequence: metadata.consequence } : {}),
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function useRpc(use) {
|
|
735
|
+
if (!use)
|
|
736
|
+
return undefined;
|
|
737
|
+
return {
|
|
738
|
+
...(use.call ? { call: [...use.call] } : {}),
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function usePubSub(use) {
|
|
742
|
+
if (!use)
|
|
743
|
+
return undefined;
|
|
744
|
+
return {
|
|
745
|
+
...(use.publish ? { publish: [...use.publish] } : {}),
|
|
746
|
+
...(use.subscribe ? { subscribe: [...use.subscribe] } : {}),
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function contractUse(use) {
|
|
750
|
+
return {
|
|
751
|
+
contract: use.contract,
|
|
752
|
+
...(use.rpc ? { rpc: useRpc(use.rpc) } : {}),
|
|
753
|
+
...(use.operations ? { operations: useRpc(use.operations) } : {}),
|
|
754
|
+
...(use.events ? { events: usePubSub(use.events) } : {}),
|
|
755
|
+
...(use.feeds
|
|
756
|
+
? {
|
|
757
|
+
feeds: {
|
|
758
|
+
...(use.feeds.subscribe
|
|
759
|
+
? { subscribe: [...use.feeds.subscribe] }
|
|
760
|
+
: {}),
|
|
761
|
+
},
|
|
762
|
+
}
|
|
763
|
+
: {}),
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
function contractUses(uses) {
|
|
767
|
+
if (!uses)
|
|
768
|
+
return undefined;
|
|
769
|
+
return {
|
|
770
|
+
...(uses.required
|
|
771
|
+
? { required: mapValues(uses.required, contractUse) }
|
|
772
|
+
: {}),
|
|
773
|
+
...(uses.optional
|
|
774
|
+
? { optional: mapValues(uses.optional, contractUse) }
|
|
775
|
+
: {}),
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function stateStore(store) {
|
|
779
|
+
return {
|
|
780
|
+
kind: store.kind,
|
|
781
|
+
schema: schemaRef(store.schema),
|
|
782
|
+
...(store.stateVersion ? { stateVersion: store.stateVersion } : {}),
|
|
783
|
+
...(store.acceptedVersions
|
|
784
|
+
? { acceptedVersions: mapValues(store.acceptedVersions, schemaRef) }
|
|
785
|
+
: {}),
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function rpcMethod(method) {
|
|
789
|
+
return {
|
|
790
|
+
version: method.version,
|
|
791
|
+
subject: method.subject,
|
|
792
|
+
input: schemaRef(method.input),
|
|
793
|
+
output: schemaRef(method.output),
|
|
794
|
+
...(method.transfer
|
|
795
|
+
? { transfer: { direction: method.transfer.direction } }
|
|
796
|
+
: {}),
|
|
797
|
+
...(method.capabilities?.call
|
|
798
|
+
? { capabilities: { call: [...method.capabilities.call] } }
|
|
799
|
+
: {}),
|
|
800
|
+
...(method.errors
|
|
801
|
+
? { errors: method.errors.map((error) => ({ type: error.type })) }
|
|
802
|
+
: {}),
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function operation(operation) {
|
|
806
|
+
return {
|
|
807
|
+
version: operation.version,
|
|
808
|
+
subject: operation.subject,
|
|
809
|
+
input: schemaRef(operation.input),
|
|
810
|
+
...(operation.progress ? { progress: schemaRef(operation.progress) } : {}),
|
|
811
|
+
output: schemaRef(operation.output),
|
|
812
|
+
...(operation.transfer
|
|
813
|
+
? {
|
|
814
|
+
transfer: {
|
|
815
|
+
direction: operation.transfer.direction,
|
|
816
|
+
store: operation.transfer.store,
|
|
817
|
+
key: operation.transfer.key,
|
|
818
|
+
...(operation.transfer.contentType
|
|
819
|
+
? { contentType: operation.transfer.contentType }
|
|
820
|
+
: {}),
|
|
821
|
+
...(operation.transfer.metadata
|
|
822
|
+
? { metadata: operation.transfer.metadata }
|
|
823
|
+
: {}),
|
|
824
|
+
...(operation.transfer.expiresInMs !== undefined
|
|
825
|
+
? { expiresInMs: operation.transfer.expiresInMs }
|
|
826
|
+
: {}),
|
|
827
|
+
...(operation.transfer.maxBytes !== undefined
|
|
828
|
+
? { maxBytes: operation.transfer.maxBytes }
|
|
829
|
+
: {}),
|
|
830
|
+
},
|
|
831
|
+
}
|
|
832
|
+
: {}),
|
|
833
|
+
...(operation.capabilities
|
|
834
|
+
? {
|
|
835
|
+
capabilities: {
|
|
836
|
+
...(operation.capabilities.call
|
|
837
|
+
? { call: [...operation.capabilities.call] }
|
|
838
|
+
: {}),
|
|
839
|
+
...(operation.capabilities.read
|
|
840
|
+
? { read: [...operation.capabilities.read] }
|
|
841
|
+
: {}),
|
|
842
|
+
...(operation.capabilities.cancel
|
|
843
|
+
? { cancel: [...operation.capabilities.cancel] }
|
|
844
|
+
: {}),
|
|
845
|
+
...(operation.capabilities.control
|
|
846
|
+
? { control: [...operation.capabilities.control] }
|
|
847
|
+
: {}),
|
|
848
|
+
},
|
|
849
|
+
}
|
|
850
|
+
: {}),
|
|
851
|
+
...(operation.signals
|
|
852
|
+
? {
|
|
853
|
+
signals: mapValues(operation.signals, (signal) => ({ input: schemaRef(signal.input) })),
|
|
854
|
+
}
|
|
855
|
+
: {}),
|
|
856
|
+
...(operation.cancel !== undefined ? { cancel: operation.cancel } : {}),
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
function event(event) {
|
|
860
|
+
return {
|
|
861
|
+
version: event.version,
|
|
862
|
+
subject: event.subject,
|
|
863
|
+
...(event.params ? { params: [...event.params] } : {}),
|
|
864
|
+
event: schemaRef(event.event),
|
|
865
|
+
...(event.capabilities
|
|
866
|
+
? {
|
|
867
|
+
capabilities: {
|
|
868
|
+
...(event.capabilities.publish
|
|
869
|
+
? { publish: [...event.capabilities.publish] }
|
|
870
|
+
: {}),
|
|
871
|
+
...(event.capabilities.subscribe
|
|
872
|
+
? { subscribe: [...event.capabilities.subscribe] }
|
|
873
|
+
: {}),
|
|
874
|
+
},
|
|
875
|
+
}
|
|
876
|
+
: {}),
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function feed(feed) {
|
|
880
|
+
return {
|
|
881
|
+
version: feed.version,
|
|
882
|
+
subject: feed.subject,
|
|
883
|
+
input: schemaRef(feed.input),
|
|
884
|
+
event: schemaRef(feed.event),
|
|
885
|
+
...(feed.capabilities?.subscribe
|
|
886
|
+
? { capabilities: { subscribe: [...feed.capabilities.subscribe] } }
|
|
887
|
+
: {}),
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
function errorDecl(error) {
|
|
891
|
+
return {
|
|
892
|
+
type: error.type,
|
|
893
|
+
...(error.schema ? { schema: schemaRef(error.schema) } : {}),
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function jobQueue(queue) {
|
|
897
|
+
return {
|
|
898
|
+
payload: schemaRef(queue.payload),
|
|
899
|
+
...(queue.result ? { result: schemaRef(queue.result) } : {}),
|
|
900
|
+
...(queue.maxDeliver !== undefined ? { maxDeliver: queue.maxDeliver } : {}),
|
|
901
|
+
...(queue.backoffMs ? { backoffMs: [...queue.backoffMs] } : {}),
|
|
902
|
+
...(queue.ackWaitMs !== undefined ? { ackWaitMs: queue.ackWaitMs } : {}),
|
|
903
|
+
...(queue.defaultDeadlineMs !== undefined
|
|
904
|
+
? { defaultDeadlineMs: queue.defaultDeadlineMs }
|
|
905
|
+
: {}),
|
|
906
|
+
...(queue.progress !== undefined ? { progress: queue.progress } : {}),
|
|
907
|
+
...(queue.logs !== undefined ? { logs: queue.logs } : {}),
|
|
908
|
+
...(queue.dlq !== undefined ? { dlq: queue.dlq } : {}),
|
|
909
|
+
...(queue.concurrency !== undefined
|
|
910
|
+
? { concurrency: queue.concurrency }
|
|
911
|
+
: {}),
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function kvResource(resource) {
|
|
915
|
+
return {
|
|
916
|
+
purpose: resource.purpose,
|
|
917
|
+
schema: schemaRef(resource.schema),
|
|
918
|
+
...(resource.required !== undefined ? { required: resource.required } : {}),
|
|
919
|
+
...(resource.history !== undefined ? { history: resource.history } : {}),
|
|
920
|
+
...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
|
|
921
|
+
...(resource.maxValueBytes !== undefined
|
|
922
|
+
? { maxValueBytes: resource.maxValueBytes }
|
|
923
|
+
: {}),
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function storeResource(resource) {
|
|
927
|
+
return {
|
|
928
|
+
purpose: resource.purpose,
|
|
929
|
+
...(resource.required !== undefined ? { required: resource.required } : {}),
|
|
930
|
+
...(resource.ttlMs !== undefined ? { ttlMs: resource.ttlMs } : {}),
|
|
931
|
+
...(resource.maxObjectBytes !== undefined
|
|
932
|
+
? { maxObjectBytes: resource.maxObjectBytes }
|
|
933
|
+
: {}),
|
|
934
|
+
...(resource.maxTotalBytes !== undefined
|
|
935
|
+
? { maxTotalBytes: resource.maxTotalBytes }
|
|
936
|
+
: {}),
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Return the canonical manifest shape used by Trellis runtimes before
|
|
941
|
+
* validation, persistence, and digesting.
|
|
942
|
+
*
|
|
943
|
+
* This is not the digest projection: human-facing fields such as
|
|
944
|
+
* `displayName` and `description` are preserved here even though they are not
|
|
945
|
+
* part of contract identity. Unknown extension fields are intentionally omitted
|
|
946
|
+
* until the runtime explicitly supports them.
|
|
947
|
+
*/
|
|
948
|
+
export function normalizeContractManifest(contract) {
|
|
949
|
+
return {
|
|
950
|
+
format: contract.format,
|
|
951
|
+
id: contract.id,
|
|
952
|
+
displayName: contract.displayName,
|
|
953
|
+
description: contract.description,
|
|
954
|
+
kind: contract.kind,
|
|
955
|
+
...(contract.capabilities
|
|
956
|
+
? { capabilities: mapValues(contract.capabilities, capabilityMetadata) }
|
|
957
|
+
: {}),
|
|
958
|
+
...(contract.schemas ? { schemas: contract.schemas } : {}),
|
|
959
|
+
...(contract.exports
|
|
960
|
+
? {
|
|
961
|
+
exports: {
|
|
962
|
+
...(contract.exports.schemas
|
|
963
|
+
? { schemas: [...contract.exports.schemas] }
|
|
964
|
+
: {}),
|
|
965
|
+
},
|
|
966
|
+
}
|
|
967
|
+
: {}),
|
|
968
|
+
...(contract.uses ? { uses: contractUses(contract.uses) } : {}),
|
|
969
|
+
...(contract.state ? { state: mapValues(contract.state, stateStore) } : {}),
|
|
970
|
+
...(contract.rpc ? { rpc: mapValues(contract.rpc, rpcMethod) } : {}),
|
|
971
|
+
...(contract.operations
|
|
972
|
+
? { operations: mapValues(contract.operations, operation) }
|
|
973
|
+
: {}),
|
|
974
|
+
...(contract.events ? { events: mapValues(contract.events, event) } : {}),
|
|
975
|
+
...(contract.feeds ? { feeds: mapValues(contract.feeds, feed) } : {}),
|
|
976
|
+
...(contract.jobs ? { jobs: mapValues(contract.jobs, jobQueue) } : {}),
|
|
977
|
+
...(contract.resources
|
|
978
|
+
? {
|
|
979
|
+
resources: {
|
|
980
|
+
...(contract.resources.kv
|
|
981
|
+
? { kv: mapValues(contract.resources.kv, kvResource) }
|
|
982
|
+
: {}),
|
|
983
|
+
...(contract.resources.store
|
|
984
|
+
? { store: mapValues(contract.resources.store, storeResource) }
|
|
985
|
+
: {}),
|
|
986
|
+
},
|
|
987
|
+
}
|
|
988
|
+
: {}),
|
|
989
|
+
...(contract.errors
|
|
990
|
+
? { errors: mapValues(contract.errors, errorDecl) }
|
|
991
|
+
: {}),
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Parse untrusted contract JSON into the current Trellis v1 manifest shape.
|
|
996
|
+
*
|
|
997
|
+
* Unknown extension fields are accepted for forward compatibility but are not
|
|
998
|
+
* returned. Callers must use the returned value for persistence and digesting.
|
|
999
|
+
*/
|
|
1000
|
+
export function parseContractManifest(value) {
|
|
1001
|
+
try {
|
|
1002
|
+
return normalizeContractManifest(Value.Parse(TrellisContractV1Schema, value));
|
|
1003
|
+
}
|
|
1004
|
+
catch (error) {
|
|
1005
|
+
const details = [...Value.Errors(TrellisContractV1Schema, value)].map((entry) => `${entry.instancePath || "#"}: ${entry.message}`);
|
|
1006
|
+
throw new TypeError(`Invalid contract${details.length > 0 ? `:\n${details.join("\n")}` : ""}`, { cause: error });
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
446
1009
|
/**
|
|
447
1010
|
* Build the normalized runtime/interface projection used for contract identity.
|
|
448
1011
|
*/
|
|
@@ -454,16 +1017,19 @@ export function projectContractDigestManifest(contract) {
|
|
|
454
1017
|
const rpc = projectDigestRpc(contract.rpc);
|
|
455
1018
|
const operations = projectDigestOperations(contract.operations);
|
|
456
1019
|
const events = projectDigestEvents(contract.events);
|
|
1020
|
+
const feeds = projectDigestFeeds(contract.feeds);
|
|
457
1021
|
return {
|
|
458
1022
|
format: contract.format,
|
|
459
1023
|
id: contract.id,
|
|
460
1024
|
kind: contract.kind,
|
|
1025
|
+
...(contract.capabilities ? { capabilities: contract.capabilities } : {}),
|
|
461
1026
|
...(schemas ? { schemas } : {}),
|
|
462
1027
|
...(contract.state ? { state: contract.state } : {}),
|
|
463
1028
|
...(uses ? { uses } : {}),
|
|
464
1029
|
...(rpc ? { rpc } : {}),
|
|
465
1030
|
...(operations ? { operations } : {}),
|
|
466
1031
|
...(events ? { events } : {}),
|
|
1032
|
+
...(feeds ? { feeds } : {}),
|
|
467
1033
|
...(errors ? { errors } : {}),
|
|
468
1034
|
...(contract.jobs ? { jobs: contract.jobs } : {}),
|
|
469
1035
|
...(resources ? { resources } : {}),
|
|
@@ -471,7 +1037,7 @@ export function projectContractDigestManifest(contract) {
|
|
|
471
1037
|
}
|
|
472
1038
|
/** Compute the v1 contract digest from the normalized digest projection. */
|
|
473
1039
|
export function digestContractManifest(contract) {
|
|
474
|
-
return digestCanonicalJson(projectContractDigestManifest(contract));
|
|
1040
|
+
return digestCanonicalJson(projectContractDigestManifest(normalizeContractManifest(contract)));
|
|
475
1041
|
}
|
|
476
1042
|
function rpcSubject(name, version) {
|
|
477
1043
|
return `rpc.${version}.${name}`;
|
|
@@ -479,6 +1045,9 @@ function rpcSubject(name, version) {
|
|
|
479
1045
|
function operationSubject(name, version) {
|
|
480
1046
|
return `operations.${version}.${name}`;
|
|
481
1047
|
}
|
|
1048
|
+
function feedSubject(name, version) {
|
|
1049
|
+
return `feeds.${version}.${name}`;
|
|
1050
|
+
}
|
|
482
1051
|
function eventSubject(name, version, params) {
|
|
483
1052
|
const suffix = params && params.length > 0
|
|
484
1053
|
? `.${params.map((pointer) => `{${pointer}}`).join(".")}`
|
|
@@ -572,10 +1141,14 @@ function buildContractKvMetadata(resources, schemas) {
|
|
|
572
1141
|
const metadata = {};
|
|
573
1142
|
for (const [alias, resource] of Object.entries(kv)) {
|
|
574
1143
|
assertSchemaRefExists(schemas, resource.schema, `kv resource '${alias}'`);
|
|
1144
|
+
const schema = schemas?.[resource.schema.schema];
|
|
1145
|
+
if (!schema) {
|
|
1146
|
+
throw new Error(`kv resource '${alias}' references missing schema '${resource.schema.schema}'`);
|
|
1147
|
+
}
|
|
575
1148
|
metadata[alias] = {
|
|
576
1149
|
required: resource.required ?? true,
|
|
577
1150
|
value: undefined,
|
|
578
|
-
schema
|
|
1151
|
+
schema,
|
|
579
1152
|
};
|
|
580
1153
|
}
|
|
581
1154
|
return metadata;
|
|
@@ -613,7 +1186,7 @@ function emitState(state) {
|
|
|
613
1186
|
},
|
|
614
1187
|
]));
|
|
615
1188
|
}
|
|
616
|
-
function
|
|
1189
|
+
function emitUsesFlat(uses) {
|
|
617
1190
|
if (!uses) {
|
|
618
1191
|
return undefined;
|
|
619
1192
|
}
|
|
@@ -637,10 +1210,28 @@ function emitUses(uses) {
|
|
|
637
1210
|
},
|
|
638
1211
|
}
|
|
639
1212
|
: {}),
|
|
1213
|
+
...(use.feeds?.subscribe
|
|
1214
|
+
? { feeds: { subscribe: sortedUnique(use.feeds.subscribe) } }
|
|
1215
|
+
: {}),
|
|
640
1216
|
},
|
|
641
1217
|
]));
|
|
642
1218
|
}
|
|
1219
|
+
function emitUses(uses) {
|
|
1220
|
+
if (!uses) {
|
|
1221
|
+
return undefined;
|
|
1222
|
+
}
|
|
1223
|
+
const required = emitUsesFlat(uses.required);
|
|
1224
|
+
const optional = omitRequiredUseAliases(emitUsesFlat(uses.optional), required);
|
|
1225
|
+
if (!required && !optional) {
|
|
1226
|
+
return undefined;
|
|
1227
|
+
}
|
|
1228
|
+
return {
|
|
1229
|
+
...(required ? { required } : {}),
|
|
1230
|
+
...(optional ? { optional } : {}),
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
643
1233
|
function emitContract(source) {
|
|
1234
|
+
const capabilities = emitCapabilities(source.id, source.capabilities);
|
|
644
1235
|
const rpc = source.rpc
|
|
645
1236
|
? Object.fromEntries(Object.entries(source.rpc).map(([name, method]) => {
|
|
646
1237
|
const emitted = {
|
|
@@ -651,7 +1242,7 @@ function emitContract(source) {
|
|
|
651
1242
|
};
|
|
652
1243
|
if (method.capabilities?.call) {
|
|
653
1244
|
emitted.capabilities = {
|
|
654
|
-
call:
|
|
1245
|
+
call: projectCapabilities(method.capabilities.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
|
|
655
1246
|
};
|
|
656
1247
|
}
|
|
657
1248
|
if (method.transfer) {
|
|
@@ -698,19 +1289,36 @@ function emitContract(source) {
|
|
|
698
1289
|
emitted.transfer = { ...operation.transfer, direction: "send" };
|
|
699
1290
|
}
|
|
700
1291
|
if (operation.capabilities?.call || operation.capabilities?.read ||
|
|
701
|
-
operation.capabilities?.cancel) {
|
|
1292
|
+
operation.capabilities?.cancel || operation.capabilities?.control) {
|
|
702
1293
|
emitted.capabilities = {
|
|
703
1294
|
...(operation.capabilities.call
|
|
704
|
-
? {
|
|
1295
|
+
? {
|
|
1296
|
+
call: projectCapabilities(operation.capabilities.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
|
|
1297
|
+
}
|
|
705
1298
|
: {}),
|
|
706
1299
|
...(operation.capabilities.read
|
|
707
|
-
? {
|
|
1300
|
+
? {
|
|
1301
|
+
read: projectCapabilities(operation.capabilities.read, source.id, source.capabilities, `operation '${name}' read capabilities`) ?? [],
|
|
1302
|
+
}
|
|
708
1303
|
: {}),
|
|
709
1304
|
...(operation.capabilities.cancel
|
|
710
|
-
? {
|
|
1305
|
+
? {
|
|
1306
|
+
cancel: projectCapabilities(operation.capabilities.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
|
|
1307
|
+
}
|
|
1308
|
+
: {}),
|
|
1309
|
+
...(operation.capabilities.control
|
|
1310
|
+
? {
|
|
1311
|
+
control: projectCapabilities(operation.capabilities.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
|
|
1312
|
+
}
|
|
711
1313
|
: {}),
|
|
712
1314
|
};
|
|
713
1315
|
}
|
|
1316
|
+
if (operation.signals) {
|
|
1317
|
+
emitted.signals = Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
|
|
1318
|
+
signalName,
|
|
1319
|
+
{ input: { ...signal.input } },
|
|
1320
|
+
]));
|
|
1321
|
+
}
|
|
714
1322
|
if (operation.cancel !== undefined) {
|
|
715
1323
|
emitted.cancel = operation.cancel;
|
|
716
1324
|
}
|
|
@@ -734,16 +1342,36 @@ function emitContract(source) {
|
|
|
734
1342
|
if (event.capabilities?.publish || event.capabilities?.subscribe) {
|
|
735
1343
|
emitted.capabilities = {
|
|
736
1344
|
...(event.capabilities.publish
|
|
737
|
-
? {
|
|
1345
|
+
? {
|
|
1346
|
+
publish: projectCapabilities(event.capabilities.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
|
|
1347
|
+
}
|
|
738
1348
|
: {}),
|
|
739
1349
|
...(event.capabilities.subscribe
|
|
740
|
-
? {
|
|
1350
|
+
? {
|
|
1351
|
+
subscribe: projectCapabilities(event.capabilities.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
|
|
1352
|
+
}
|
|
741
1353
|
: {}),
|
|
742
1354
|
};
|
|
743
1355
|
}
|
|
744
1356
|
return [name, emitted];
|
|
745
1357
|
}))
|
|
746
1358
|
: undefined;
|
|
1359
|
+
const feeds = source.feeds
|
|
1360
|
+
? Object.fromEntries(Object.entries(source.feeds).map(([name, feed]) => {
|
|
1361
|
+
const emitted = {
|
|
1362
|
+
version: feed.version,
|
|
1363
|
+
subject: feed.subject ?? feedSubject(name, feed.version),
|
|
1364
|
+
input: { ...feed.input },
|
|
1365
|
+
event: { ...feed.event },
|
|
1366
|
+
};
|
|
1367
|
+
if (feed.capabilities?.subscribe) {
|
|
1368
|
+
emitted.capabilities = {
|
|
1369
|
+
subscribe: projectCapabilities(feed.capabilities.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
return [name, emitted];
|
|
1373
|
+
}))
|
|
1374
|
+
: undefined;
|
|
747
1375
|
const errors = source.errors
|
|
748
1376
|
? Object.fromEntries(Object.entries(source.errors).map(([name, error]) => {
|
|
749
1377
|
const emitted = { type: error.type };
|
|
@@ -764,6 +1392,7 @@ function emitContract(source) {
|
|
|
764
1392
|
displayName: source.displayName,
|
|
765
1393
|
description: source.description,
|
|
766
1394
|
kind: source.kind,
|
|
1395
|
+
...(capabilities ? { capabilities } : {}),
|
|
767
1396
|
...(source.schemas ? { schemas: cloneSchemas(source.schemas) } : {}),
|
|
768
1397
|
...(source.exports
|
|
769
1398
|
? { exports: cloneContractExports(source.exports) }
|
|
@@ -773,6 +1402,7 @@ function emitContract(source) {
|
|
|
773
1402
|
...(rpc ? { rpc } : {}),
|
|
774
1403
|
...(operations ? { operations } : {}),
|
|
775
1404
|
...(events ? { events } : {}),
|
|
1405
|
+
...(feeds ? { feeds } : {}),
|
|
776
1406
|
...(errors ? { errors } : {}),
|
|
777
1407
|
...(jobs ? { jobs } : {}),
|
|
778
1408
|
...(resources ? { resources } : {}),
|
|
@@ -807,7 +1437,7 @@ function buildOwnedApi(source) {
|
|
|
807
1437
|
subject: method.subject ?? rpcSubject(name, method.version),
|
|
808
1438
|
input: schema(resolveSchemaRef(source.schemas, method.input, `rpc '${name}' input`)),
|
|
809
1439
|
output: schema(resolveSchemaRef(source.schemas, method.output, `rpc '${name}' output`)),
|
|
810
|
-
callerCapabilities: method.capabilities?.call ?? [],
|
|
1440
|
+
callerCapabilities: projectCapabilities(method.capabilities?.call, source.id, source.capabilities, `rpc '${name}' call capabilities`) ?? [],
|
|
811
1441
|
transfer: method.transfer ? { ...method.transfer } : undefined,
|
|
812
1442
|
authRequired: method.authRequired ?? true,
|
|
813
1443
|
errors: method.errors,
|
|
@@ -832,9 +1462,18 @@ function buildOwnedApi(source) {
|
|
|
832
1462
|
transfer: operation.transfer
|
|
833
1463
|
? { ...operation.transfer, direction: "send" }
|
|
834
1464
|
: undefined,
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
1465
|
+
signals: operation.signals
|
|
1466
|
+
? Object.fromEntries(Object.entries(operation.signals).map(([signalName, signal]) => [
|
|
1467
|
+
signalName,
|
|
1468
|
+
{
|
|
1469
|
+
input: schema(resolveSchemaRef(source.schemas, signal.input, `operation '${name}' signal '${signalName}' input`)),
|
|
1470
|
+
},
|
|
1471
|
+
]))
|
|
1472
|
+
: undefined,
|
|
1473
|
+
callerCapabilities: projectCapabilities(operation.capabilities?.call, source.id, source.capabilities, `operation '${name}' call capabilities`) ?? [],
|
|
1474
|
+
readCapabilities: projectCapabilities(operation.capabilities?.read, source.id, source.capabilities, `operation '${name}' read capabilities`) ?? [],
|
|
1475
|
+
cancelCapabilities: projectCapabilities(operation.capabilities?.cancel, source.id, source.capabilities, `operation '${name}' cancel capabilities`) ?? [],
|
|
1476
|
+
controlCapabilities: projectCapabilities(operation.capabilities?.control, source.id, source.capabilities, `operation '${name}' control capabilities`) ?? [],
|
|
838
1477
|
cancel: operation.cancel,
|
|
839
1478
|
},
|
|
840
1479
|
]));
|
|
@@ -849,12 +1488,21 @@ function buildOwnedApi(source) {
|
|
|
849
1488
|
eventSubject(name, event.version, event.params),
|
|
850
1489
|
params: event.params,
|
|
851
1490
|
event: schema(resolveSchemaRef(source.schemas, event.event, `event '${name}'`)),
|
|
852
|
-
publishCapabilities: event.capabilities?.publish ?? [],
|
|
853
|
-
subscribeCapabilities: event.capabilities?.subscribe ?? [],
|
|
1491
|
+
publishCapabilities: projectCapabilities(event.capabilities?.publish, source.id, source.capabilities, `event '${name}' publish capabilities`) ?? [],
|
|
1492
|
+
subscribeCapabilities: projectCapabilities(event.capabilities?.subscribe, source.id, source.capabilities, `event '${name}' subscribe capabilities`) ?? [],
|
|
854
1493
|
},
|
|
855
1494
|
];
|
|
856
1495
|
}));
|
|
857
|
-
|
|
1496
|
+
const feeds = Object.fromEntries(Object.entries(source.feeds ?? {}).map(([name, feed]) => [
|
|
1497
|
+
name,
|
|
1498
|
+
{
|
|
1499
|
+
subject: feed.subject ?? feedSubject(name, feed.version),
|
|
1500
|
+
input: schema(resolveSchemaRef(source.schemas, feed.input, `feed '${name}' input`)),
|
|
1501
|
+
event: schema(resolveSchemaRef(source.schemas, feed.event, `feed '${name}' event`)),
|
|
1502
|
+
subscribeCapabilities: projectCapabilities(feed.capabilities?.subscribe, source.id, source.capabilities, `feed '${name}' subscribe capabilities`) ?? [],
|
|
1503
|
+
},
|
|
1504
|
+
]));
|
|
1505
|
+
return { rpc, operations, events, feeds, subjects: {} };
|
|
858
1506
|
}
|
|
859
1507
|
function mergeRecord(kind, out, next) {
|
|
860
1508
|
for (const [key, value] of Object.entries(next)) {
|
|
@@ -879,6 +1527,7 @@ function assertValidUseSpec(contractId, spec, api) {
|
|
|
879
1527
|
assertSelectedKeysExist(contractId, "operations", spec.operations?.call, api.operations);
|
|
880
1528
|
assertSelectedKeysExist(contractId, "events", spec.events?.publish, api.events);
|
|
881
1529
|
assertSelectedKeysExist(contractId, "events", spec.events?.subscribe, api.events);
|
|
1530
|
+
assertSelectedKeysExist(contractId, "feeds", spec.feeds?.subscribe, api.feeds ?? {});
|
|
882
1531
|
}
|
|
883
1532
|
function attachContractModuleMetadata(value, contractModule) {
|
|
884
1533
|
Object.defineProperty(value, CONTRACT_MODULE_METADATA, {
|
|
@@ -1007,6 +1656,9 @@ function createUseHelper(getContractModule) {
|
|
|
1007
1656
|
},
|
|
1008
1657
|
}
|
|
1009
1658
|
: {}),
|
|
1659
|
+
...(spec.feeds?.subscribe
|
|
1660
|
+
? { feeds: { subscribe: [...spec.feeds.subscribe] } }
|
|
1661
|
+
: {}),
|
|
1010
1662
|
};
|
|
1011
1663
|
return attachContractModuleMetadata(dependencyUse, contractModule);
|
|
1012
1664
|
});
|
|
@@ -1018,11 +1670,11 @@ function getContractModuleFromUse(alias, useValue) {
|
|
|
1018
1670
|
}
|
|
1019
1671
|
return contractModule;
|
|
1020
1672
|
}
|
|
1021
|
-
function
|
|
1673
|
+
function normalizeUseEntries(uses) {
|
|
1022
1674
|
if (!uses) {
|
|
1023
1675
|
return {
|
|
1024
1676
|
manifestUses: undefined,
|
|
1025
|
-
usedApi: { rpc: {}, operations: {}, events: {}, subjects: {} },
|
|
1677
|
+
usedApi: { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} },
|
|
1026
1678
|
};
|
|
1027
1679
|
}
|
|
1028
1680
|
const manifestUses = {};
|
|
@@ -1030,6 +1682,7 @@ function normalizeUses(uses) {
|
|
|
1030
1682
|
rpc: {},
|
|
1031
1683
|
operations: {},
|
|
1032
1684
|
events: {},
|
|
1685
|
+
feeds: {},
|
|
1033
1686
|
subjects: {},
|
|
1034
1687
|
};
|
|
1035
1688
|
for (const [alias, useValue] of Object.entries(uses)) {
|
|
@@ -1038,6 +1691,7 @@ function normalizeUses(uses) {
|
|
|
1038
1691
|
const operationsCall = useValue.operations?.call;
|
|
1039
1692
|
const eventsPublish = useValue.events?.publish;
|
|
1040
1693
|
const eventsSubscribe = useValue.events?.subscribe;
|
|
1694
|
+
const feedsSubscribe = useValue.feeds?.subscribe;
|
|
1041
1695
|
if (useValue.contract !== contractModule.CONTRACT_ID) {
|
|
1042
1696
|
throw new Error(`Contract use '${alias}' references '${useValue.contract}' but module id is '${contractModule.CONTRACT_ID}'`);
|
|
1043
1697
|
}
|
|
@@ -1052,6 +1706,7 @@ function normalizeUses(uses) {
|
|
|
1052
1706
|
},
|
|
1053
1707
|
}
|
|
1054
1708
|
: {}),
|
|
1709
|
+
...(feedsSubscribe ? { feeds: { subscribe: feedsSubscribe } } : {}),
|
|
1055
1710
|
}, contractModule.API.owned);
|
|
1056
1711
|
manifestUses[alias] = {
|
|
1057
1712
|
contract: contractModule.CONTRACT_ID,
|
|
@@ -1065,6 +1720,7 @@ function normalizeUses(uses) {
|
|
|
1065
1720
|
},
|
|
1066
1721
|
}
|
|
1067
1722
|
: {}),
|
|
1723
|
+
...(feedsSubscribe ? { feeds: { subscribe: [...feedsSubscribe] } } : {}),
|
|
1068
1724
|
};
|
|
1069
1725
|
const rpcKeys = selectedKeys(rpcCall);
|
|
1070
1726
|
if (rpcKeys.length > 0) {
|
|
@@ -1081,11 +1737,35 @@ function normalizeUses(uses) {
|
|
|
1081
1737
|
if (eventKeys.size > 0) {
|
|
1082
1738
|
mergeRecord("events", usedApi.events, Object.fromEntries([...eventKeys].map((key) => [key, contractModule.API.owned.events[key]])));
|
|
1083
1739
|
}
|
|
1740
|
+
const feedKeys = selectedKeys(feedsSubscribe);
|
|
1741
|
+
if (feedKeys.length > 0) {
|
|
1742
|
+
mergeRecord("feeds", usedApi.feeds ?? {}, Object.fromEntries(feedKeys.map((key) => [key, contractModule.API.owned.feeds?.[key]])));
|
|
1743
|
+
}
|
|
1084
1744
|
}
|
|
1085
1745
|
return { manifestUses, usedApi };
|
|
1086
1746
|
}
|
|
1747
|
+
function normalizeUses(uses) {
|
|
1748
|
+
if (!uses) {
|
|
1749
|
+
return {
|
|
1750
|
+
manifestUses: undefined,
|
|
1751
|
+
usedApi: emptyApi(),
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
const required = normalizeUseEntries(uses.required);
|
|
1755
|
+
const optional = normalizeUseEntries(omitRequiredUseAliases(uses.optional, uses.required));
|
|
1756
|
+
const usedApi = emptyApi();
|
|
1757
|
+
mergeUseIntoApi(usedApi, required.usedApi);
|
|
1758
|
+
mergeUseIntoApi(usedApi, optional.usedApi);
|
|
1759
|
+
return {
|
|
1760
|
+
manifestUses: {
|
|
1761
|
+
...(required.manifestUses ? { required: required.manifestUses } : {}),
|
|
1762
|
+
...(optional.manifestUses ? { optional: optional.manifestUses } : {}),
|
|
1763
|
+
},
|
|
1764
|
+
usedApi,
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1087
1767
|
function emptyApi() {
|
|
1088
|
-
return { rpc: {}, operations: {}, events: {}, subjects: {} };
|
|
1768
|
+
return { rpc: {}, operations: {}, events: {}, feeds: {}, subjects: {} };
|
|
1089
1769
|
}
|
|
1090
1770
|
function addUniqueStrings(target, values) {
|
|
1091
1771
|
for (const value of values) {
|
|
@@ -1111,6 +1791,8 @@ function mergeUseIntoManifest(manifestUses, alias, use) {
|
|
|
1111
1791
|
addUniqueStrings(eventsPublish, use.events?.publish ?? []);
|
|
1112
1792
|
const eventsSubscribe = [...(existing.events?.subscribe ?? [])];
|
|
1113
1793
|
addUniqueStrings(eventsSubscribe, use.events?.subscribe ?? []);
|
|
1794
|
+
const feedsSubscribe = [...(existing.feeds?.subscribe ?? [])];
|
|
1795
|
+
addUniqueStrings(feedsSubscribe, use.feeds?.subscribe ?? []);
|
|
1114
1796
|
manifestUses[alias] = {
|
|
1115
1797
|
contract: existing.contract,
|
|
1116
1798
|
...(rpcCall.length > 0 ? { rpc: { call: rpcCall } } : {}),
|
|
@@ -1125,6 +1807,9 @@ function mergeUseIntoManifest(manifestUses, alias, use) {
|
|
|
1125
1807
|
},
|
|
1126
1808
|
}
|
|
1127
1809
|
: {}),
|
|
1810
|
+
...(feedsSubscribe.length > 0
|
|
1811
|
+
? { feeds: { subscribe: feedsSubscribe } }
|
|
1812
|
+
: {}),
|
|
1128
1813
|
};
|
|
1129
1814
|
}
|
|
1130
1815
|
function mergeApiAllowDuplicateSubject(kind, out, next) {
|
|
@@ -1149,6 +1834,7 @@ function mergeUseIntoApi(target, api) {
|
|
|
1149
1834
|
mergeApiAllowDuplicateSubject("rpc", target.rpc, api.rpc);
|
|
1150
1835
|
mergeApiAllowDuplicateSubject("operations", target.operations, api.operations);
|
|
1151
1836
|
mergeApiAllowDuplicateSubject("events", target.events, api.events);
|
|
1837
|
+
mergeApiAllowDuplicateSubject("feeds", target.feeds ?? {}, api.feeds ?? {});
|
|
1152
1838
|
mergeApiAllowDuplicateSubject("subjects", target.subjects, api.subjects);
|
|
1153
1839
|
}
|
|
1154
1840
|
function baselineUse(contract, use, api) {
|
|
@@ -1162,22 +1848,33 @@ function deriveImplicitTrellisUses(source) {
|
|
|
1162
1848
|
if (source.state) {
|
|
1163
1849
|
uses.state = baselineUse(TRELLIS_STATE_CONTRACT_ID, { rpc: { call: [...BASELINE_STATE_RPC_CALL] } }, BASELINE_STATE_API);
|
|
1164
1850
|
}
|
|
1851
|
+
if ((source.kind === "service" || source.kind === "device") &&
|
|
1852
|
+
source.id !== TRELLIS_HEALTH_CONTRACT_ID) {
|
|
1853
|
+
uses.health = baselineUse(TRELLIS_HEALTH_CONTRACT_ID, { events: { publish: [...BASELINE_HEALTH_EVENTS_PUBLISH] } }, BASELINE_HEALTH_API);
|
|
1854
|
+
}
|
|
1165
1855
|
return uses;
|
|
1166
1856
|
}
|
|
1167
1857
|
function normalizeContractUses(source) {
|
|
1168
1858
|
const explicit = normalizeUses(source.uses);
|
|
1169
|
-
const manifestUses = {
|
|
1170
|
-
...(explicit.manifestUses ?? {}),
|
|
1171
|
-
};
|
|
1172
1859
|
const usedApi = emptyApi();
|
|
1173
1860
|
mergeUseIntoApi(usedApi, explicit.usedApi);
|
|
1861
|
+
const required = {
|
|
1862
|
+
...(explicit.manifestUses?.required ?? {}),
|
|
1863
|
+
};
|
|
1864
|
+
const optional = explicit.manifestUses?.optional
|
|
1865
|
+
? { ...explicit.manifestUses.optional }
|
|
1866
|
+
: undefined;
|
|
1174
1867
|
for (const [alias, use] of Object.entries(deriveImplicitTrellisUses(source))) {
|
|
1175
|
-
mergeUseIntoManifest(
|
|
1868
|
+
mergeUseIntoManifest(required, alias, use.manifestUse);
|
|
1176
1869
|
mergeUseIntoApi(usedApi, use.api);
|
|
1177
1870
|
}
|
|
1178
1871
|
return {
|
|
1179
|
-
manifestUses: Object.keys(
|
|
1180
|
-
|
|
1872
|
+
manifestUses: Object.keys(required).length > 0 ||
|
|
1873
|
+
(optional && Object.keys(optional).length > 0)
|
|
1874
|
+
? {
|
|
1875
|
+
...(Object.keys(required).length > 0 ? { required } : {}),
|
|
1876
|
+
...(optional && Object.keys(optional).length > 0 ? { optional } : {}),
|
|
1877
|
+
}
|
|
1181
1878
|
: undefined,
|
|
1182
1879
|
usedApi,
|
|
1183
1880
|
};
|
|
@@ -1196,11 +1893,13 @@ function mergeDerivedApis(ownedApi, usedApi) {
|
|
|
1196
1893
|
rpc: mergeApiSection("rpc", usedApi.rpc, ownedApi.rpc),
|
|
1197
1894
|
operations: mergeApiSection("operations", usedApi.operations, ownedApi.operations),
|
|
1198
1895
|
events: mergeApiSection("events", usedApi.events, ownedApi.events),
|
|
1896
|
+
feeds: mergeApiSection("feeds", usedApi.feeds ?? {}, ownedApi.feeds ?? {}),
|
|
1199
1897
|
subjects: mergeApiSection("subjects", usedApi.subjects, ownedApi.subjects),
|
|
1200
1898
|
};
|
|
1201
1899
|
}
|
|
1202
1900
|
function defineContract(registry, build) {
|
|
1203
1901
|
assertRegistryDoesNotDeclareExports(registry);
|
|
1902
|
+
assertRegistryDoesNotDeclareCapabilities(registry);
|
|
1204
1903
|
const errorClasses = getErrorClassRegistry(registry.errors);
|
|
1205
1904
|
const normalizedErrors = normalizeErrorRegistry(registry.errors);
|
|
1206
1905
|
const body = build(createContractRefBuilder({
|
|
@@ -1220,6 +1919,7 @@ function defineContract(registry, build) {
|
|
|
1220
1919
|
displayName: source.displayName,
|
|
1221
1920
|
description: source.description,
|
|
1222
1921
|
kind: source.kind,
|
|
1922
|
+
...(source.capabilities ? { capabilities: source.capabilities } : {}),
|
|
1223
1923
|
...(source.schemas ? { schemas: source.schemas } : {}),
|
|
1224
1924
|
...(source.exports ? { exports: source.exports } : {}),
|
|
1225
1925
|
...(source.state ? { state: source.state } : {}),
|
|
@@ -1227,6 +1927,7 @@ function defineContract(registry, build) {
|
|
|
1227
1927
|
...(source.rpc ? { rpc: source.rpc } : {}),
|
|
1228
1928
|
...(source.operations ? { operations: source.operations } : {}),
|
|
1229
1929
|
...(source.events ? { events: source.events } : {}),
|
|
1930
|
+
...(source.feeds ? { feeds: source.feeds } : {}),
|
|
1230
1931
|
...(source.errors ? { errors: source.errors } : {}),
|
|
1231
1932
|
...(source.jobs ? { jobs: source.jobs } : {}),
|
|
1232
1933
|
...(source.resources ? { resources: source.resources } : {}),
|