doover-js 0.11.0 → 0.13.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 +106 -0
- package/dist/apis/_args.js +5 -5
- package/dist/apis/agents-api.d.ts +4 -4
- package/dist/apis/agents-api.js +2 -2
- package/dist/apis/aggregates-api.d.ts +4 -4
- package/dist/apis/aggregates-api.js +5 -5
- package/dist/apis/alarms-api.d.ts +2 -2
- package/dist/apis/alarms-api.js +3 -3
- package/dist/apis/channels-api.d.ts +3 -3
- package/dist/apis/channels-api.js +6 -6
- package/dist/apis/connections-api.d.ts +2 -2
- package/dist/apis/connections-api.js +6 -6
- package/dist/apis/messages-api.d.ts +4 -4
- package/dist/apis/messages-api.js +11 -11
- package/dist/apis/notifications-api.d.ts +2 -2
- package/dist/apis/notifications-api.js +4 -4
- package/dist/apis/organisations-api.d.ts +2 -2
- package/dist/apis/permissions-api.d.ts +2 -2
- package/dist/apis/permissions-api.js +3 -3
- package/dist/apis/processors-api.d.ts +2 -2
- package/dist/apis/turn-api.d.ts +2 -2
- package/dist/apis/users-api.d.ts +2 -2
- package/dist/auth/auth-store.d.ts +1 -1
- package/dist/auth/build-auth.d.ts +3 -3
- package/dist/auth/build-auth.js +8 -8
- package/dist/auth/cookie-auth.d.ts +1 -1
- package/dist/auth/cookie-auth.js +2 -2
- package/dist/auth/doover-auth.d.ts +2 -2
- package/dist/auth/doover-token-auth.d.ts +3 -3
- package/dist/auth/doover-token-auth.js +13 -13
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.js +15 -0
- package/dist/client/data-client.d.ts +17 -14
- package/dist/client/doover-client.d.ts +9 -7
- package/dist/client/doover-client.js +44 -42
- package/dist/client/errors.d.ts +2 -2
- package/dist/client/errors.js +4 -4
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +12 -0
- package/dist/client/local-agent-client.d.ts +3 -3
- package/dist/client/local-agent-client.js +19 -19
- package/dist/client/multiplex-client.d.ts +5 -5
- package/dist/client/multiplex-client.js +25 -25
- package/dist/client/multiplex-gateway.d.ts +3 -3
- package/dist/client/multiplex-merge.d.ts +1 -1
- package/dist/client/network-status.d.ts +17 -0
- package/dist/client/network-status.js +70 -0
- package/dist/client/offline-cache.d.ts +9 -4
- package/dist/client/offline-cache.js +34 -22
- package/dist/client/provenance.d.ts +1 -1
- package/dist/client/request-options.d.ts +1 -1
- package/dist/client/singleton.d.ts +2 -2
- package/dist/client/singleton.js +2 -2
- package/dist/client/status-tracker.d.ts +1 -1
- package/dist/esm/apis/_args.d.ts +16 -0
- package/dist/esm/apis/_args.js +27 -0
- package/dist/esm/apis/agents-api.d.ts +196 -0
- package/dist/esm/apis/agents-api.js +327 -0
- package/dist/esm/apis/aggregates-api.d.ts +67 -0
- package/dist/esm/apis/aggregates-api.js +64 -0
- package/dist/esm/apis/alarms-api.d.ts +48 -0
- package/dist/esm/apis/alarms-api.js +75 -0
- package/dist/esm/apis/channels-api.d.ts +83 -0
- package/dist/esm/apis/channels-api.js +65 -0
- package/dist/esm/apis/connections-api.d.ts +45 -0
- package/dist/esm/apis/connections-api.js +44 -0
- package/dist/esm/apis/messages-api.d.ts +128 -0
- package/dist/esm/apis/messages-api.js +179 -0
- package/dist/esm/apis/notifications-api.d.ts +94 -0
- package/dist/esm/apis/notifications-api.js +153 -0
- package/dist/esm/apis/organisations-api.d.ts +26 -0
- package/dist/esm/apis/organisations-api.js +41 -0
- package/dist/esm/apis/permissions-api.d.ts +17 -0
- package/dist/esm/apis/permissions-api.js +23 -0
- package/dist/esm/apis/processors-api.d.ts +56 -0
- package/dist/esm/apis/processors-api.js +97 -0
- package/dist/esm/apis/turn-api.d.ts +7 -0
- package/dist/esm/apis/turn-api.js +8 -0
- package/dist/esm/apis/users-api.d.ts +8 -0
- package/dist/esm/apis/users-api.js +9 -0
- package/dist/esm/auth/auth-profile.d.ts +45 -0
- package/dist/esm/auth/auth-profile.js +68 -0
- package/dist/esm/auth/auth-store.d.ts +14 -0
- package/dist/esm/auth/build-auth.d.ts +38 -0
- package/dist/esm/auth/build-auth.js +92 -0
- package/dist/esm/auth/cookie-auth.d.ts +91 -0
- package/dist/esm/auth/cookie-auth.js +196 -0
- package/dist/esm/auth/doover-auth.d.ts +52 -0
- package/dist/esm/auth/doover-auth.js +28 -0
- package/dist/esm/auth/doover-token-auth.d.ts +39 -0
- package/dist/esm/auth/doover-token-auth.js +217 -0
- package/dist/esm/auth/errors.d.ts +3 -0
- package/dist/esm/auth/errors.js +6 -0
- package/dist/esm/auth/index.d.ts +10 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/jwt.d.ts +6 -0
- package/dist/esm/auth/jwt.js +26 -0
- package/dist/esm/client/capabilities.d.ts +10 -0
- package/dist/esm/client/capabilities.js +42 -0
- package/dist/esm/client/data-client.d.ts +107 -0
- package/dist/esm/client/doover-client.d.ts +48 -0
- package/dist/esm/client/doover-client.js +96 -0
- package/dist/esm/client/errors.d.ts +32 -0
- package/dist/esm/client/errors.js +64 -0
- package/dist/esm/client/index.d.ts +6 -0
- package/dist/esm/client/index.js +3 -0
- package/dist/esm/client/local-agent-client.d.ts +65 -0
- package/dist/esm/client/local-agent-client.js +225 -0
- package/dist/esm/client/multiplex-client.d.ts +165 -0
- package/dist/esm/client/multiplex-client.js +842 -0
- package/dist/esm/client/multiplex-gateway.d.ts +49 -0
- package/dist/esm/client/multiplex-gateway.js +110 -0
- package/dist/esm/client/multiplex-merge.d.ts +12 -0
- package/dist/esm/client/multiplex-merge.js +38 -0
- package/dist/esm/client/network-status.d.ts +17 -0
- package/dist/esm/client/network-status.js +66 -0
- package/dist/esm/client/offline-cache.d.ts +167 -0
- package/dist/esm/client/offline-cache.js +769 -0
- package/dist/esm/client/provenance.d.ts +60 -0
- package/dist/esm/client/provenance.js +108 -0
- package/dist/esm/client/request-options.d.ts +23 -0
- package/dist/esm/client/request-options.js +23 -0
- package/dist/esm/client/singleton.d.ts +26 -0
- package/dist/esm/client/singleton.js +54 -0
- package/dist/esm/client/stats.d.ts +79 -0
- package/dist/esm/client/stats.js +155 -0
- package/dist/esm/client/status-tracker.d.ts +24 -0
- package/dist/esm/client/status-tracker.js +86 -0
- package/dist/esm/gateway/gateway-client.d.ts +86 -0
- package/dist/esm/gateway/gateway-client.js +463 -0
- package/dist/esm/gateway/index.d.ts +3 -0
- package/dist/esm/gateway/index.js +1 -0
- package/dist/esm/gateway/types.d.ts +142 -0
- package/dist/esm/http/errors.d.ts +19 -0
- package/dist/esm/http/errors.js +22 -0
- package/dist/esm/http/index.d.ts +3 -0
- package/dist/esm/http/index.js +2 -0
- package/dist/esm/http/rest-client.d.ts +64 -0
- package/dist/esm/http/rest-client.js +181 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/node/config-manager.d.ts +34 -0
- package/dist/esm/node/config-manager.js +140 -0
- package/dist/esm/node/index.d.ts +1 -0
- package/dist/esm/node/index.js +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react/context.d.ts +23 -0
- package/dist/esm/react/context.js +28 -0
- package/dist/esm/react/index.d.ts +38 -0
- package/dist/esm/react/index.js +21 -0
- package/dist/esm/react/messageRangeStore.d.ts +93 -0
- package/dist/esm/react/messageRangeStore.js +140 -0
- package/dist/esm/react/sharedQueryClient.d.ts +21 -0
- package/dist/esm/react/sharedQueryClient.js +35 -0
- package/dist/esm/react/useAgentChannel.d.ts +8 -0
- package/dist/esm/react/useAgentChannel.js +9 -0
- package/dist/esm/react/useAgentConnections.d.ts +8 -0
- package/dist/esm/react/useAgentConnections.js +20 -0
- package/dist/esm/react/useAgentTokenState.d.ts +70 -0
- package/dist/esm/react/useAgentTokenState.js +127 -0
- package/dist/esm/react/useChannelAggregate.d.ts +64 -0
- package/dist/esm/react/useChannelAggregate.js +77 -0
- package/dist/esm/react/useChannelMessage.d.ts +45 -0
- package/dist/esm/react/useChannelMessage.js +79 -0
- package/dist/esm/react/useChannelMessages.d.ts +83 -0
- package/dist/esm/react/useChannelMessages.js +214 -0
- package/dist/esm/react/useChannelSubscription.d.ts +27 -0
- package/dist/esm/react/useChannelSubscription.js +30 -0
- package/dist/esm/react/useClientStatus.d.ts +10 -0
- package/dist/esm/react/useClientStatus.js +19 -0
- package/dist/esm/react/useConnectionState.d.ts +26 -0
- package/dist/esm/react/useConnectionState.js +45 -0
- package/dist/esm/react/useDeviceMap.d.ts +109 -0
- package/dist/esm/react/useDeviceMap.js +59 -0
- package/dist/esm/react/useInvocationLogs.d.ts +23 -0
- package/dist/esm/react/useInvocationLogs.js +37 -0
- package/dist/esm/react/useMultiAgentAggregates.d.ts +38 -0
- package/dist/esm/react/useMultiAgentAggregates.js +104 -0
- package/dist/esm/react/useMultiAgentChannelMessages.d.ts +79 -0
- package/dist/esm/react/useMultiAgentChannelMessages.js +169 -0
- package/dist/esm/react/useOfflineStatus.d.ts +8 -0
- package/dist/esm/react/useOfflineStatus.js +37 -0
- package/dist/esm/react/useSendMessage.d.ts +16 -0
- package/dist/esm/react/useSendMessage.js +26 -0
- package/dist/esm/react/useSendRpc.d.ts +68 -0
- package/dist/esm/react/useSendRpc.js +164 -0
- package/dist/esm/react/useTurnCredentials.d.ts +12 -0
- package/dist/esm/react/useTurnCredentials.js +22 -0
- package/dist/esm/react/useUpdateAggregate.d.ts +27 -0
- package/dist/esm/react/useUpdateAggregate.js +39 -0
- package/dist/esm/react/useUpdateMessage.d.ts +38 -0
- package/dist/esm/react/useUpdateMessage.js +36 -0
- package/dist/esm/refine/index.d.ts +72 -0
- package/dist/esm/refine/index.js +215 -0
- package/dist/esm/rpc/errors.d.ts +10 -0
- package/dist/esm/rpc/errors.js +19 -0
- package/dist/esm/rpc/index.d.ts +3 -0
- package/dist/esm/rpc/index.js +2 -0
- package/dist/esm/rpc/rpc-dispatcher.d.ts +41 -0
- package/dist/esm/rpc/rpc-dispatcher.js +141 -0
- package/dist/esm/types/audit.d.ts +53 -0
- package/dist/esm/types/audit.js +11 -0
- package/dist/esm/types/batch.d.ts +85 -0
- package/dist/esm/types/batch.js +42 -0
- package/dist/esm/types/common.d.ts +250 -0
- package/dist/esm/types/connection.d.ts +72 -0
- package/dist/esm/types/connection.js +7 -0
- package/dist/esm/types/index.d.ts +9 -0
- package/dist/esm/types/openapi.d.ts +195 -0
- package/dist/esm/types/provenance.d.ts +45 -0
- package/dist/esm/types/viewer.d.ts +122 -0
- package/dist/esm/utils/snowflake.d.ts +21 -0
- package/dist/esm/utils/snowflake.js +33 -0
- package/dist/esm/viewer/doover-data-provider.d.ts +90 -0
- package/dist/esm/viewer/doover-data-provider.js +189 -0
- package/dist/esm/viewer/path-parsing.d.ts +5 -0
- package/dist/esm/viewer/path-parsing.js +35 -0
- package/dist/gateway/gateway-client.d.ts +5 -5
- package/dist/gateway/gateway-client.js +5 -5
- package/dist/gateway/index.d.ts +3 -0
- package/dist/gateway/index.js +5 -0
- package/dist/gateway/types.d.ts +1 -1
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.js +9 -0
- package/dist/http/rest-client.d.ts +5 -3
- package/dist/http/rest-client.js +2 -2
- package/dist/index.d.ts +64 -62
- package/dist/index.js +92 -89
- package/dist/node/config-manager.d.ts +2 -2
- package/dist/node/config-manager.js +5 -5
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +2 -2
- package/dist/react/context.d.ts +1 -1
- package/dist/react/index.d.ts +38 -38
- package/dist/react/index.js +59 -59
- package/dist/react/messageRangeStore.d.ts +1 -1
- package/dist/react/useAgentChannel.d.ts +3 -3
- package/dist/react/useAgentChannel.js +2 -2
- package/dist/react/useAgentConnections.d.ts +1 -1
- package/dist/react/useAgentConnections.js +2 -2
- package/dist/react/useAgentTokenState.d.ts +3 -3
- package/dist/react/useAgentTokenState.js +8 -8
- package/dist/react/useChannelAggregate.d.ts +3 -3
- package/dist/react/useChannelAggregate.js +8 -8
- package/dist/react/useChannelMessage.d.ts +2 -2
- package/dist/react/useChannelMessage.js +4 -4
- package/dist/react/useChannelMessages.d.ts +3 -3
- package/dist/react/useChannelMessages.js +10 -10
- package/dist/react/useChannelSubscription.d.ts +2 -2
- package/dist/react/useChannelSubscription.js +2 -2
- package/dist/react/useClientStatus.d.ts +1 -1
- package/dist/react/useClientStatus.js +2 -2
- package/dist/react/useConnectionState.js +2 -2
- package/dist/react/useDeviceMap.js +2 -2
- package/dist/react/useInvocationLogs.d.ts +1 -1
- package/dist/react/useInvocationLogs.js +2 -2
- package/dist/react/useMultiAgentAggregates.d.ts +1 -1
- package/dist/react/useMultiAgentAggregates.js +5 -5
- package/dist/react/useMultiAgentChannelMessages.d.ts +1 -1
- package/dist/react/useMultiAgentChannelMessages.js +2 -2
- package/dist/react/useOfflineStatus.d.ts +2 -2
- package/dist/react/useOfflineStatus.js +31 -17
- package/dist/react/useSendMessage.d.ts +2 -2
- package/dist/react/useSendMessage.js +2 -2
- package/dist/react/useSendRpc.d.ts +2 -2
- package/dist/react/useSendRpc.js +2 -2
- package/dist/react/useTurnCredentials.d.ts +2 -2
- package/dist/react/useTurnCredentials.js +2 -2
- package/dist/react/useUpdateAggregate.d.ts +3 -3
- package/dist/react/useUpdateAggregate.js +4 -4
- package/dist/react/useUpdateMessage.d.ts +2 -2
- package/dist/react/useUpdateMessage.js +2 -2
- package/dist/refine/index.d.ts +1 -1
- package/dist/rpc/errors.d.ts +1 -1
- package/dist/rpc/index.d.ts +3 -0
- package/dist/rpc/index.js +7 -0
- package/dist/rpc/rpc-dispatcher.d.ts +4 -4
- package/dist/rpc/rpc-dispatcher.js +2 -2
- package/dist/types/common.d.ts +1 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +2 -0
- package/dist/types/openapi.d.ts +1 -1
- package/dist/types/viewer.d.ts +2 -2
- package/dist/viewer/doover-data-provider.d.ts +10 -10
- package/dist/viewer/doover-data-provider.js +25 -25
- package/dist/viewer/path-parsing.d.ts +1 -1
- package/package.json +795 -8
- package/dist/test/api-args.test.js +0 -48
- package/dist/test/api-overloads.test.d.ts +0 -9
- package/dist/test/api-overloads.test.js +0 -330
- package/dist/test/apis.test.js +0 -408
- package/dist/test/auth.test.js +0 -708
- package/dist/test/batch-apis.test.js +0 -183
- package/dist/test/capabilities.test.js +0 -27
- package/dist/test/config-manager.test.js +0 -160
- package/dist/test/data-client-errors.test.js +0 -24
- package/dist/test/data-client-shape.test.js +0 -28
- package/dist/test/doover-client-dataclient.test.d.ts +0 -1
- package/dist/test/doover-client-dataclient.test.js +0 -58
- package/dist/test/doover-client-provenance.test.d.ts +0 -1
- package/dist/test/doover-client-provenance.test.js +0 -32
- package/dist/test/doover-client.test.d.ts +0 -1
- package/dist/test/doover-client.test.js +0 -42
- package/dist/test/doover-data-provider.test.d.ts +0 -1
- package/dist/test/doover-data-provider.test.js +0 -657
- package/dist/test/exports.test.d.ts +0 -1
- package/dist/test/exports.test.js +0 -80
- package/dist/test/gateway-client.test.d.ts +0 -1
- package/dist/test/gateway-client.test.js +0 -474
- package/dist/test/gateway-provenance.test.d.ts +0 -1
- package/dist/test/gateway-provenance.test.js +0 -29
- package/dist/test/gateway-subscriptions.test.d.ts +0 -1
- package/dist/test/gateway-subscriptions.test.js +0 -95
- package/dist/test/helpers.d.ts +0 -32
- package/dist/test/helpers.js +0 -115
- package/dist/test/local-agent-client.test.d.ts +0 -1
- package/dist/test/local-agent-client.test.js +0 -202
- package/dist/test/message-range-store.test.d.ts +0 -1
- package/dist/test/message-range-store.test.js +0 -183
- package/dist/test/multiplex-capabilities.test.d.ts +0 -1
- package/dist/test/multiplex-capabilities.test.js +0 -37
- package/dist/test/multiplex-conflicts.test.d.ts +0 -1
- package/dist/test/multiplex-conflicts.test.js +0 -35
- package/dist/test/multiplex-gateway.test.d.ts +0 -1
- package/dist/test/multiplex-gateway.test.js +0 -103
- package/dist/test/multiplex-merge.test.d.ts +0 -1
- package/dist/test/multiplex-merge.test.js +0 -19
- package/dist/test/multiplex-noncore.test.d.ts +0 -1
- package/dist/test/multiplex-noncore.test.js +0 -82
- package/dist/test/multiplex-passthrough.test.d.ts +0 -1
- package/dist/test/multiplex-passthrough.test.js +0 -35
- package/dist/test/multiplex-reads.test.d.ts +0 -1
- package/dist/test/multiplex-reads.test.js +0 -87
- package/dist/test/multiplex-registry.test.d.ts +0 -1
- package/dist/test/multiplex-registry.test.js +0 -81
- package/dist/test/multiplex-routing.test.d.ts +0 -1
- package/dist/test/multiplex-routing.test.js +0 -45
- package/dist/test/multiplex-status.test.d.ts +0 -1
- package/dist/test/multiplex-status.test.js +0 -63
- package/dist/test/multiplex-writes.test.d.ts +0 -1
- package/dist/test/multiplex-writes.test.js +0 -93
- package/dist/test/offline-cache.test.d.ts +0 -1
- package/dist/test/offline-cache.test.js +0 -289
- package/dist/test/provenance-regression.test.d.ts +0 -1
- package/dist/test/provenance-regression.test.js +0 -45
- package/dist/test/provenance-stamper.test.d.ts +0 -1
- package/dist/test/provenance-stamper.test.js +0 -41
- package/dist/test/provenance-type.test.d.ts +0 -1
- package/dist/test/provenance-type.test.js +0 -15
- package/dist/test/react-channel-messages-forward.test.d.ts +0 -1
- package/dist/test/react-channel-messages-forward.test.js +0 -139
- package/dist/test/react-channel-messages-range.test.d.ts +0 -1
- package/dist/test/react-channel-messages-range.test.js +0 -109
- package/dist/test/react-client-status.test.d.ts +0 -1
- package/dist/test/react-client-status.test.js +0 -35
- package/dist/test/react-dataclient.test.d.ts +0 -1
- package/dist/test/react-dataclient.test.js +0 -28
- package/dist/test/react-exports.test.d.ts +0 -1
- package/dist/test/react-exports.test.js +0 -46
- package/dist/test/react-multiagent-messages.test.d.ts +0 -1
- package/dist/test/react-multiagent-messages.test.js +0 -113
- package/dist/test/react-sources-option.test.d.ts +0 -1
- package/dist/test/react-sources-option.test.js +0 -41
- package/dist/test/react.test.d.ts +0 -1
- package/dist/test/react.test.js +0 -482
- package/dist/test/refine.test.d.ts +0 -1
- package/dist/test/refine.test.js +0 -71
- package/dist/test/rest-client.test.d.ts +0 -1
- package/dist/test/rest-client.test.js +0 -197
- package/dist/test/rpc-dispatcher.test.d.ts +0 -1
- package/dist/test/rpc-dispatcher.test.js +0 -251
- package/dist/test/singleton.test.d.ts +0 -1
- package/dist/test/singleton.test.js +0 -62
- package/dist/test/stats-rpc.test.d.ts +0 -1
- package/dist/test/stats-rpc.test.js +0 -69
- package/dist/test/status-tracker.test.d.ts +0 -1
- package/dist/test/status-tracker.test.js +0 -85
- package/dist/test/users-api.test.d.ts +0 -1
- package/dist/test/users-api.test.js +0 -19
- package/dist/test/utils.test.d.ts +0 -1
- package/dist/test/utils.test.js +0 -64
- /package/dist/{test/api-args.test.d.ts → esm/auth/auth-store.js} +0 -0
- /package/dist/{test/apis.test.d.ts → esm/client/data-client.js} +0 -0
- /package/dist/{test/auth.test.d.ts → esm/gateway/types.js} +0 -0
- /package/dist/{test/batch-apis.test.d.ts → esm/types/common.js} +0 -0
- /package/dist/{test/capabilities.test.d.ts → esm/types/index.js} +0 -0
- /package/dist/{test/config-manager.test.d.ts → esm/types/openapi.js} +0 -0
- /package/dist/{test/data-client-errors.test.d.ts → esm/types/provenance.js} +0 -0
- /package/dist/{test/data-client-shape.test.d.ts → esm/types/viewer.js} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DooverApiError } from "../http/errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a `DataClient` method is called whose backing capability the
|
|
4
|
+
* client does not advertise. Extends `DooverApiError` so existing
|
|
5
|
+
* `instanceof DooverApiError` error handling catches it; the HTTP-ish fields
|
|
6
|
+
* are placeholders since no request was made.
|
|
7
|
+
*/
|
|
8
|
+
export class UnsupportedCapabilityError extends DooverApiError {
|
|
9
|
+
constructor(capability, clientId) {
|
|
10
|
+
super({
|
|
11
|
+
status: 0,
|
|
12
|
+
body: { capability, clientId },
|
|
13
|
+
url: "",
|
|
14
|
+
method: "",
|
|
15
|
+
message: `Capability "${capability}" is not supported` +
|
|
16
|
+
(clientId ? ` by client "${clientId}"` : "") + ".",
|
|
17
|
+
});
|
|
18
|
+
this.name = "UnsupportedCapabilityError";
|
|
19
|
+
this.capability = capability;
|
|
20
|
+
this.clientId = clientId;
|
|
21
|
+
Object.setPrototypeOf(this, UnsupportedCapabilityError.prototype);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Thrown by `MultiplexClient` when a write cannot be routed to a single
|
|
26
|
+
* member — more than one enabled member owns the targeted agent and has the
|
|
27
|
+
* write capability, and the call was not `sources`-scoped to one of them.
|
|
28
|
+
*/
|
|
29
|
+
export class AmbiguousWriteError extends DooverApiError {
|
|
30
|
+
constructor(capability, candidateSourceIds) {
|
|
31
|
+
super({
|
|
32
|
+
status: 0,
|
|
33
|
+
body: { capability, candidateSourceIds },
|
|
34
|
+
url: "",
|
|
35
|
+
method: "",
|
|
36
|
+
message: `Ambiguous write for "${capability}": ${candidateSourceIds.length} ` +
|
|
37
|
+
`members are eligible (${candidateSourceIds.join(", ")}). ` +
|
|
38
|
+
`Scope the call with { sources: [<one-id>] }.`,
|
|
39
|
+
});
|
|
40
|
+
this.name = "AmbiguousWriteError";
|
|
41
|
+
this.capability = capability;
|
|
42
|
+
this.candidateSourceIds = candidateSourceIds;
|
|
43
|
+
Object.setPrototypeOf(this, AmbiguousWriteError.prototype);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Thrown by offline-aware clients when a network-only operation is attempted
|
|
48
|
+
* while offline, or when an offline read has no usable cached value.
|
|
49
|
+
*/
|
|
50
|
+
export class DooverOfflineError extends DooverApiError {
|
|
51
|
+
constructor(operation, message, cacheKey) {
|
|
52
|
+
super({
|
|
53
|
+
status: 0,
|
|
54
|
+
body: { operation, cacheKey },
|
|
55
|
+
url: "",
|
|
56
|
+
method: "",
|
|
57
|
+
message: message ?? `Operation "${operation}" is unavailable while offline.`,
|
|
58
|
+
});
|
|
59
|
+
this.name = "DooverOfflineError";
|
|
60
|
+
this.operation = operation;
|
|
61
|
+
this.cacheKey = cacheKey;
|
|
62
|
+
Object.setPrototypeOf(this, DooverOfflineError.prototype);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DooverClient } from "./doover-client.js";
|
|
2
|
+
export { getDooverClient, peekDooverClient, resetDooverClient } from "./singleton.js";
|
|
3
|
+
export type { DooverClientConfig } from "../http/rest-client.js";
|
|
4
|
+
export type * from "./data-client.js";
|
|
5
|
+
export { browserNetworkStatus, createNetworkStatusStore } from "./network-status.js";
|
|
6
|
+
export type { NetworkStatusSource, NetworkStatusSnapshot } from "./network-status.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type DooverClientConfig } from "../http/rest-client.js";
|
|
2
|
+
import type { Capability } from "./capabilities.js";
|
|
3
|
+
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client.js";
|
|
4
|
+
export interface LocalAgentClientConfig {
|
|
5
|
+
/** Base URL of the local agent's REST API, e.g. "http://192.168.0.7:49100". */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Base URL of the local agent's WebSocket gateway. Defaults to `baseUrl`
|
|
8
|
+
* with http(s)→ws(s). */
|
|
9
|
+
wssUrl?: string;
|
|
10
|
+
fetchImpl?: typeof fetch;
|
|
11
|
+
webSocketImpl?: typeof WebSocket;
|
|
12
|
+
webSocketFactory?: DooverClientConfig["webSocketFactory"];
|
|
13
|
+
disableBrowserLifecycleHooks?: boolean;
|
|
14
|
+
/** Stable source id. Defaults to `local:<host>:<port>` derived from baseUrl. */
|
|
15
|
+
sourceId?: string;
|
|
16
|
+
sourceLabel?: string;
|
|
17
|
+
/** Reserved for a future LAN auth blob — ignored in v1. */
|
|
18
|
+
auth?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare class LocalAgentClient implements DataClient {
|
|
21
|
+
readonly agents: AgentsApiLike;
|
|
22
|
+
readonly channels: ChannelsApiLike;
|
|
23
|
+
readonly messages: MessagesApiLike;
|
|
24
|
+
readonly aggregates: AggregatesApiLike;
|
|
25
|
+
readonly alarms: AlarmsApiLike;
|
|
26
|
+
readonly connections: ConnectionsApiLike;
|
|
27
|
+
readonly notifications: NotificationsApiLike;
|
|
28
|
+
readonly permissions: PermissionsApiLike;
|
|
29
|
+
readonly processors: ProcessorsApiLike;
|
|
30
|
+
readonly turn: TurnApiLike;
|
|
31
|
+
readonly users: UsersApiLike;
|
|
32
|
+
readonly gateway: GatewayClientLike;
|
|
33
|
+
readonly rpc: RpcDispatcherLike;
|
|
34
|
+
private readonly identity;
|
|
35
|
+
private readonly capSet;
|
|
36
|
+
private readonly rest;
|
|
37
|
+
private readonly gatewayImpl;
|
|
38
|
+
private readonly statusTracker;
|
|
39
|
+
/** Resolved device-agent id list; null until first resolution. */
|
|
40
|
+
private resolvedScope;
|
|
41
|
+
private scopeResolving;
|
|
42
|
+
constructor(config: LocalAgentClientConfig);
|
|
43
|
+
getCapabilities(): ReadonlySet<Capability>;
|
|
44
|
+
supports(cap: Capability): boolean;
|
|
45
|
+
getAgentScope(): Promise<AgentScope>;
|
|
46
|
+
getKnownAgentScope(): AgentScope | "unknown";
|
|
47
|
+
isConnected(): boolean;
|
|
48
|
+
getStatus(): DataClientStatus;
|
|
49
|
+
onStatusChange(listener: (status: DataClientStatus) => void): () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Wraps a real (provenance-wrapped) subclient so only `allowed` method names
|
|
52
|
+
* pass through; any other method call throws `UnsupportedCapabilityError`.
|
|
53
|
+
*
|
|
54
|
+
* Typing `real` as `WrappedSubclient<T>` and `allowed` as
|
|
55
|
+
* `ReadonlyArray<keyof WrappedSubclient<T> & string>` ensures the compiler
|
|
56
|
+
* catches typos in the allowed-method list at the call site.
|
|
57
|
+
*/
|
|
58
|
+
private gatedSubclient;
|
|
59
|
+
/**
|
|
60
|
+
* Builds a Proxy that throws `UnsupportedCapabilityError` (mapped via
|
|
61
|
+
* METHOD_TO_CAPABILITY) for every method call. Used for subclients with no
|
|
62
|
+
* advertised methods.
|
|
63
|
+
*/
|
|
64
|
+
private unsupportedSubclient;
|
|
65
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { AgentsApi } from "../apis/agents-api.js";
|
|
2
|
+
import { AggregatesApi } from "../apis/aggregates-api.js";
|
|
3
|
+
import { ChannelsApi } from "../apis/channels-api.js";
|
|
4
|
+
import { MessagesApi } from "../apis/messages-api.js";
|
|
5
|
+
import { GatewayClient } from "../gateway/gateway-client.js";
|
|
6
|
+
import { RestClient } from "../http/rest-client.js";
|
|
7
|
+
import { UnsupportedCapabilityError } from "./errors.js";
|
|
8
|
+
import { ProvenanceStamper, wrapSubclient } from "./provenance.js";
|
|
9
|
+
import { ClientStatusTracker } from "./status-tracker.js";
|
|
10
|
+
const LOCAL_CAPABILITIES = [
|
|
11
|
+
"agents.list",
|
|
12
|
+
"channels.list",
|
|
13
|
+
"channels.get",
|
|
14
|
+
"aggregates.get",
|
|
15
|
+
"aggregates.put",
|
|
16
|
+
"aggregates.patch",
|
|
17
|
+
"messages.list",
|
|
18
|
+
"messages.post",
|
|
19
|
+
"messages.put",
|
|
20
|
+
"gateway.subscribe",
|
|
21
|
+
"gateway.realtime",
|
|
22
|
+
"gateway.oneShot",
|
|
23
|
+
];
|
|
24
|
+
function deriveSourceId(baseUrl) {
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(baseUrl);
|
|
27
|
+
return `local:${u.hostname}${u.port ? `:${u.port}` : ""}`;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return `local:${baseUrl}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function httpToWs(url) {
|
|
34
|
+
return url.replace(/^http/i, "ws");
|
|
35
|
+
}
|
|
36
|
+
export class LocalAgentClient {
|
|
37
|
+
constructor(config) {
|
|
38
|
+
/** Resolved device-agent id list; null until first resolution. */
|
|
39
|
+
this.resolvedScope = null;
|
|
40
|
+
this.scopeResolving = null;
|
|
41
|
+
const sourceId = config.sourceId ?? deriveSourceId(config.baseUrl);
|
|
42
|
+
this.identity = {
|
|
43
|
+
id: sourceId,
|
|
44
|
+
kind: "local",
|
|
45
|
+
...(config.sourceLabel ? { label: config.sourceLabel } : {}),
|
|
46
|
+
meta: { baseUrl: config.baseUrl },
|
|
47
|
+
};
|
|
48
|
+
this.capSet = new Set(LOCAL_CAPABILITIES);
|
|
49
|
+
const stamper = new ProvenanceStamper(this.identity);
|
|
50
|
+
// RestClient / GatewayClient expect a DooverClientConfig — give them one
|
|
51
|
+
// with the local URLs, no auth, no org/sharing headers.
|
|
52
|
+
const restConfig = {
|
|
53
|
+
dataRestUrl: config.baseUrl,
|
|
54
|
+
controlApiUrl: config.baseUrl,
|
|
55
|
+
dataWssUrl: config.wssUrl ?? httpToWs(config.baseUrl),
|
|
56
|
+
organisationId: null,
|
|
57
|
+
sharing: "none",
|
|
58
|
+
fetchImpl: config.fetchImpl,
|
|
59
|
+
webSocketImpl: config.webSocketImpl,
|
|
60
|
+
webSocketFactory: config.webSocketFactory,
|
|
61
|
+
disableBrowserLifecycleHooks: config.disableBrowserLifecycleHooks,
|
|
62
|
+
};
|
|
63
|
+
this.rest = new RestClient(restConfig); // no auth arg
|
|
64
|
+
this.gatewayImpl = new GatewayClient(restConfig); // no auth arg
|
|
65
|
+
this.gatewayImpl.setProvenanceHook((value, ctx) => stamper.stampGatewayEvent(value, ctx));
|
|
66
|
+
this.gateway = this.gatewayImpl;
|
|
67
|
+
// Real subclients for advertised methods, gated so only allowed methods pass;
|
|
68
|
+
// all others throw UnsupportedCapabilityError.
|
|
69
|
+
const realAgents = wrapSubclient(new AgentsApi(this.rest, config.baseUrl), "agents", stamper);
|
|
70
|
+
const realChannels = wrapSubclient(new ChannelsApi(this.rest), "channels", stamper);
|
|
71
|
+
const realMessages = wrapSubclient(new MessagesApi(this.rest), "messages", stamper);
|
|
72
|
+
const realAggregates = wrapSubclient(new AggregatesApi(this.rest), "aggregates", stamper);
|
|
73
|
+
this.agents = this.gatedSubclient("agents", realAgents, ["listAgents"]);
|
|
74
|
+
this.channels = this.gatedSubclient("channels", realChannels, ["listChannels", "getChannel"]);
|
|
75
|
+
this.aggregates = this.gatedSubclient("aggregates", realAggregates, ["getAggregate", "putAggregate", "patchAggregate"]);
|
|
76
|
+
this.messages = this.gatedSubclient("messages", realMessages, ["listMessages", "postMessage", "putMessage", "patchMessage", "createMultipartPayload"]);
|
|
77
|
+
// Never-advertised subclients: always throw.
|
|
78
|
+
this.alarms = this.unsupportedSubclient("alarms");
|
|
79
|
+
this.connections = this.unsupportedSubclient("connections");
|
|
80
|
+
this.notifications = this.unsupportedSubclient("notifications");
|
|
81
|
+
this.permissions = this.unsupportedSubclient("permissions");
|
|
82
|
+
this.processors = this.unsupportedSubclient("processors");
|
|
83
|
+
this.turn = this.unsupportedSubclient("turn");
|
|
84
|
+
this.users = this.unsupportedSubclient("users");
|
|
85
|
+
this.rpc = this.unsupportedSubclient("rpc");
|
|
86
|
+
this.statusTracker = new ClientStatusTracker(this.identity.id, this.gateway, () => this.getKnownAgentScope());
|
|
87
|
+
// Resolve the device id on (re)connect so routing is precise before the
|
|
88
|
+
// first agent-scoped request; invalidate the cache on each new session.
|
|
89
|
+
this.gatewayImpl.on("ready", () => {
|
|
90
|
+
this.resolvedScope = null;
|
|
91
|
+
void this.getAgentScope();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// --- capabilities ---
|
|
95
|
+
getCapabilities() { return this.capSet; }
|
|
96
|
+
supports(cap) { return this.capSet.has(cap); }
|
|
97
|
+
// --- agent scope ---
|
|
98
|
+
getAgentScope() {
|
|
99
|
+
if (this.resolvedScope)
|
|
100
|
+
return Promise.resolve({ mode: "list", agentIds: this.resolvedScope });
|
|
101
|
+
if (this.scopeResolving)
|
|
102
|
+
return this.scopeResolving;
|
|
103
|
+
this.scopeResolving = (async () => {
|
|
104
|
+
let scope = { mode: "list", agentIds: [] };
|
|
105
|
+
try {
|
|
106
|
+
const res = await this.agents.listAgents();
|
|
107
|
+
const rawAgents = res?.agents ?? [];
|
|
108
|
+
const first = rawAgents[0];
|
|
109
|
+
const id = first?.id;
|
|
110
|
+
this.resolvedScope = id ? [String(id)] : [];
|
|
111
|
+
scope = { mode: "list", agentIds: this.resolvedScope };
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Don't cache on error — leave resolvedScope null so the next caller
|
|
115
|
+
// retries. Storing [] would permanently pin scope to no agents after a
|
|
116
|
+
// transient first-call failure (network unreachable, 503, etc.).
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
this.scopeResolving = null;
|
|
120
|
+
this.statusTracker.notifyScopeChanged();
|
|
121
|
+
}
|
|
122
|
+
return scope;
|
|
123
|
+
})();
|
|
124
|
+
return this.scopeResolving;
|
|
125
|
+
}
|
|
126
|
+
getKnownAgentScope() {
|
|
127
|
+
return this.resolvedScope ? { mode: "list", agentIds: this.resolvedScope } : "unknown";
|
|
128
|
+
}
|
|
129
|
+
// --- status ---
|
|
130
|
+
isConnected() { return this.gateway.isConnected(); }
|
|
131
|
+
getStatus() { return this.statusTracker.getStatus(); }
|
|
132
|
+
onStatusChange(listener) {
|
|
133
|
+
return this.statusTracker.onChange(listener);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Wraps a real (provenance-wrapped) subclient so only `allowed` method names
|
|
137
|
+
* pass through; any other method call throws `UnsupportedCapabilityError`.
|
|
138
|
+
*
|
|
139
|
+
* Typing `real` as `WrappedSubclient<T>` and `allowed` as
|
|
140
|
+
* `ReadonlyArray<keyof WrappedSubclient<T> & string>` ensures the compiler
|
|
141
|
+
* catches typos in the allowed-method list at the call site.
|
|
142
|
+
*/
|
|
143
|
+
gatedSubclient(name, real, allowed) {
|
|
144
|
+
const allowSet = new Set(allowed);
|
|
145
|
+
const clientId = this.identity.id;
|
|
146
|
+
return new Proxy(real, {
|
|
147
|
+
get(target, prop, receiver) {
|
|
148
|
+
if (typeof prop !== "string")
|
|
149
|
+
return Reflect.get(target, prop, receiver);
|
|
150
|
+
if (allowSet.has(prop))
|
|
151
|
+
return Reflect.get(target, prop, receiver);
|
|
152
|
+
return () => {
|
|
153
|
+
const cap = METHOD_TO_CAPABILITY[`${name}.${prop}`] ?? guessCapability(name);
|
|
154
|
+
return Promise.reject(new UnsupportedCapabilityError(cap, clientId));
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Builds a Proxy that throws `UnsupportedCapabilityError` (mapped via
|
|
161
|
+
* METHOD_TO_CAPABILITY) for every method call. Used for subclients with no
|
|
162
|
+
* advertised methods.
|
|
163
|
+
*/
|
|
164
|
+
unsupportedSubclient(name) {
|
|
165
|
+
const clientId = this.identity.id;
|
|
166
|
+
return new Proxy({}, {
|
|
167
|
+
get(_t, prop) {
|
|
168
|
+
if (typeof prop !== "string")
|
|
169
|
+
return undefined;
|
|
170
|
+
return () => {
|
|
171
|
+
const cap = METHOD_TO_CAPABILITY[`${name}.${prop}`] ?? guessCapability(name);
|
|
172
|
+
return Promise.reject(new UnsupportedCapabilityError(cap, clientId));
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const METHOD_TO_CAPABILITY = {
|
|
179
|
+
"agents.listAgents": "agents.list",
|
|
180
|
+
"agents.getMultiAgentMessages": "agents.multiAgentMessages",
|
|
181
|
+
"agents.getMultiAgentAggregates": "agents.multiAgentAggregates",
|
|
182
|
+
"agents.getTokenState": "agents.tokenRead",
|
|
183
|
+
"agents.setTokenPolicy": "agents.tokenManage",
|
|
184
|
+
"agents.setAuthLock": "agents.tokenManage",
|
|
185
|
+
"agents.revokeAllTokens": "agents.tokenManage",
|
|
186
|
+
"agents.setRevocationFloor": "agents.tokenManage",
|
|
187
|
+
"agents.createAdhocToken": "agents.tokenManage",
|
|
188
|
+
"agents.createDeviceToken": "agents.tokenManage",
|
|
189
|
+
"channels.listChannels": "channels.list",
|
|
190
|
+
"channels.getChannel": "channels.get",
|
|
191
|
+
"channels.createChannel": "channels.create",
|
|
192
|
+
"channels.putChannel": "channels.create",
|
|
193
|
+
"channels.archiveChannel": "channels.archive",
|
|
194
|
+
"channels.unarchiveChannel": "channels.archive",
|
|
195
|
+
"channels.listDataSeries": "channels.dataSeries",
|
|
196
|
+
"aggregates.getAggregate": "aggregates.get",
|
|
197
|
+
"aggregates.putAggregate": "aggregates.put",
|
|
198
|
+
"aggregates.patchAggregate": "aggregates.patch",
|
|
199
|
+
"aggregates.getAggregateAttachment": "aggregates.attachment",
|
|
200
|
+
"messages.listMessages": "messages.list",
|
|
201
|
+
"messages.postMessage": "messages.post",
|
|
202
|
+
"messages.getMessage": "messages.get",
|
|
203
|
+
"messages.putMessage": "messages.put",
|
|
204
|
+
"messages.patchMessage": "messages.put",
|
|
205
|
+
"messages.deleteMessage": "messages.delete",
|
|
206
|
+
"messages.getMessageAttachment": "messages.attachment",
|
|
207
|
+
"messages.getTimeseries": "messages.timeseries",
|
|
208
|
+
"messages.getInvocationLogs": "messages.invocationLogs",
|
|
209
|
+
"rpc.send": "rpc.send",
|
|
210
|
+
"users.getMe": "users.me",
|
|
211
|
+
"turn.createTurnToken": "turn.credentials",
|
|
212
|
+
};
|
|
213
|
+
function guessCapability(subclient) {
|
|
214
|
+
switch (subclient) {
|
|
215
|
+
case "alarms": return "alarms.read";
|
|
216
|
+
case "connections": return "connections.read";
|
|
217
|
+
case "notifications": return "notifications.read";
|
|
218
|
+
case "permissions": return "permissions.read";
|
|
219
|
+
case "processors": return "processors.read";
|
|
220
|
+
case "turn": return "turn.credentials";
|
|
221
|
+
case "users": return "users.me";
|
|
222
|
+
case "rpc": return "rpc.send";
|
|
223
|
+
default: return "channels.get";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { Capability } from "./capabilities.js";
|
|
2
|
+
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client.js";
|
|
3
|
+
export type { DataClient } from "./data-client.js";
|
|
4
|
+
export type { AgentScope } from "./data-client.js";
|
|
5
|
+
export type { DataClientStatus } from "./data-client.js";
|
|
6
|
+
export interface MultiplexConflict {
|
|
7
|
+
method: string;
|
|
8
|
+
agentId: string;
|
|
9
|
+
channelName: string;
|
|
10
|
+
/** All owning members that returned a value (in member order). */
|
|
11
|
+
sourceIds: string[];
|
|
12
|
+
/** The values, parallel to `sourceIds`. The chosen one is index 0. */
|
|
13
|
+
values: unknown[];
|
|
14
|
+
at: number;
|
|
15
|
+
}
|
|
16
|
+
/** A serialisable description of a source. */
|
|
17
|
+
export interface SourceDescriptor {
|
|
18
|
+
id: string;
|
|
19
|
+
kind: string;
|
|
20
|
+
params?: Record<string, unknown>;
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RegisteredSource {
|
|
24
|
+
descriptor: SourceDescriptor;
|
|
25
|
+
client?: DataClient;
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface MultiplexClientOptions {
|
|
29
|
+
factory: (descriptor: SourceDescriptor) => DataClient | Promise<DataClient>;
|
|
30
|
+
register?: SourceDescriptor[];
|
|
31
|
+
enable?: string[];
|
|
32
|
+
enableAll?: boolean;
|
|
33
|
+
disconnectOnDisable?: boolean;
|
|
34
|
+
clientId?: string;
|
|
35
|
+
}
|
|
36
|
+
type MuxEvent = "change" | "conflict";
|
|
37
|
+
export declare class MultiplexClient implements DataClient {
|
|
38
|
+
readonly agents: AgentsApiLike;
|
|
39
|
+
readonly channels: ChannelsApiLike;
|
|
40
|
+
readonly messages: MessagesApiLike;
|
|
41
|
+
readonly aggregates: AggregatesApiLike;
|
|
42
|
+
readonly alarms: AlarmsApiLike;
|
|
43
|
+
readonly connections: ConnectionsApiLike;
|
|
44
|
+
readonly notifications: NotificationsApiLike;
|
|
45
|
+
readonly permissions: PermissionsApiLike;
|
|
46
|
+
readonly processors: ProcessorsApiLike;
|
|
47
|
+
readonly turn: TurnApiLike;
|
|
48
|
+
readonly users: UsersApiLike;
|
|
49
|
+
readonly gateway: GatewayClientLike;
|
|
50
|
+
readonly rpc: RpcDispatcherLike;
|
|
51
|
+
private readonly registry;
|
|
52
|
+
private readonly factory;
|
|
53
|
+
private readonly disconnectOnDisable;
|
|
54
|
+
private readonly clientId;
|
|
55
|
+
private readonly eventListeners;
|
|
56
|
+
private capabilitiesCache;
|
|
57
|
+
private lastConflicts;
|
|
58
|
+
private readonly maxConflicts;
|
|
59
|
+
private readonly statusListeners;
|
|
60
|
+
/** sourceId → member unsubscribe fn for its onStatusChange. */
|
|
61
|
+
private readonly memberStatusUnsubs;
|
|
62
|
+
constructor(options: MultiplexClientOptions);
|
|
63
|
+
registerSource(descriptor: SourceDescriptor): void;
|
|
64
|
+
setActiveSources(idsOrDescriptors: Array<string | SourceDescriptor>): void;
|
|
65
|
+
enableSource(id: string, opts?: {
|
|
66
|
+
silent?: boolean;
|
|
67
|
+
}): void;
|
|
68
|
+
disableSource(id: string, opts?: {
|
|
69
|
+
silent?: boolean;
|
|
70
|
+
}): void;
|
|
71
|
+
removeSource(id: string): void;
|
|
72
|
+
getActiveSources(): readonly RegisteredSource[];
|
|
73
|
+
getRegisteredSources(): readonly RegisteredSource[];
|
|
74
|
+
/** Enabled members that have a built `client`. */
|
|
75
|
+
protected enabledClients(): Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
src: RegisteredSource;
|
|
78
|
+
client: DataClient;
|
|
79
|
+
}>;
|
|
80
|
+
on(event: MuxEvent, handler: (...args: unknown[]) => void): void;
|
|
81
|
+
off(event: MuxEvent, handler: (...args: unknown[]) => void): void;
|
|
82
|
+
protected emit(event: MuxEvent, ...args: unknown[]): void;
|
|
83
|
+
private invalidateCapabilities;
|
|
84
|
+
private attachMemberListeners;
|
|
85
|
+
private detachMemberListeners;
|
|
86
|
+
private makeCompositeGateway;
|
|
87
|
+
/** Resolve the optional `{ sources?: string[] }` bag from a method's trailing
|
|
88
|
+
* arg: returns the candidate members, narrowed to `sources` if given (each
|
|
89
|
+
* must be enabled), still capability-filtered by the caller. The bag is the
|
|
90
|
+
* LAST argument if it is a plain object with a `sources` array. */
|
|
91
|
+
private splitSourcesOption;
|
|
92
|
+
private candidates;
|
|
93
|
+
/** Extract the agent id from the first positional arg (string or identifier object). */
|
|
94
|
+
private extractAgentId;
|
|
95
|
+
/** Throw if no enabled member supports `cap` at all (regardless of agent). */
|
|
96
|
+
private assertSomeMemberSupports;
|
|
97
|
+
private isNotFound;
|
|
98
|
+
private requiredMessagesCapability;
|
|
99
|
+
private unsupportedMethod;
|
|
100
|
+
/**
|
|
101
|
+
* Route a cross-agent batch mutation.
|
|
102
|
+
*
|
|
103
|
+
* A batch can name agents served by different members, so unlike
|
|
104
|
+
* `routedWrite` there is no single target. Each item is resolved to its own
|
|
105
|
+
* member using the same rules (unsupported and ambiguous both throw), the
|
|
106
|
+
* batch is split into one sub-batch per member, and results are stitched
|
|
107
|
+
* back into the caller's original item order.
|
|
108
|
+
*
|
|
109
|
+
* Resolution happens for every item up front so an unroutable item fails
|
|
110
|
+
* the whole call before any member is written to, rather than leaving a
|
|
111
|
+
* half-applied batch behind.
|
|
112
|
+
*/
|
|
113
|
+
private routedBatchWrite;
|
|
114
|
+
private guessNonCoreCap;
|
|
115
|
+
protected recordConflict(method: string, agentId: string, channelName: string, values: Array<{
|
|
116
|
+
value: unknown;
|
|
117
|
+
id: string;
|
|
118
|
+
}>): void;
|
|
119
|
+
getLastConflicts(): readonly MultiplexConflict[];
|
|
120
|
+
/**
|
|
121
|
+
* Returns a method that routes a write to exactly one member:
|
|
122
|
+
* (a) `{ sources: [oneId] }` scoping → that member;
|
|
123
|
+
* (b) else the single enabled member that owns the targeted agent and has `cap`;
|
|
124
|
+
* (c) else `UnsupportedCapabilityError` (none) or `AmbiguousWriteError` (>1).
|
|
125
|
+
* The targeted agent id is `args[0]` (string form) or `args[0].agentId` (identifier form).
|
|
126
|
+
* Writes are never fanned out.
|
|
127
|
+
*/
|
|
128
|
+
private routedWrite;
|
|
129
|
+
/** Agent-scoped "first success" — used by messages.getTimeseries / getInvocationLogs. */
|
|
130
|
+
private makeFanoutFirst;
|
|
131
|
+
/** Used by messages.getMessageAttachment — returns the first member that yields a Blob. */
|
|
132
|
+
private makeBlobFanout;
|
|
133
|
+
private makeChannelsFacade;
|
|
134
|
+
private makeAggregatesFacade;
|
|
135
|
+
private makeMessagesFacade;
|
|
136
|
+
private makeAgentsFacade;
|
|
137
|
+
private makeReadFacade;
|
|
138
|
+
private makeRpcFacade;
|
|
139
|
+
getCapabilities(): ReadonlySet<Capability>;
|
|
140
|
+
supports(cap: Capability): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Enabled members eligible for a request targeting `agentId`: those whose
|
|
143
|
+
* scope is `{ mode: "all" }` (the cloud — no enumeration), those whose list
|
|
144
|
+
* contains `agentId`, and those whose scope is still `"unknown"` (included
|
|
145
|
+
* optimistically; their scope settles for the next call). If `agentId` is
|
|
146
|
+
* undefined, all enabled members are eligible.
|
|
147
|
+
*/
|
|
148
|
+
protected membersForAgent(agentId?: string): Array<{
|
|
149
|
+
id: string;
|
|
150
|
+
src: RegisteredSource;
|
|
151
|
+
client: DataClient;
|
|
152
|
+
}>;
|
|
153
|
+
/** Members (enabled) that both own `agentId` and advertise `cap`. */
|
|
154
|
+
protected membersForAgentWithCapability(agentId: string | undefined, cap: Capability): {
|
|
155
|
+
id: string;
|
|
156
|
+
src: RegisteredSource;
|
|
157
|
+
client: DataClient;
|
|
158
|
+
}[];
|
|
159
|
+
getAgentScope(): Promise<AgentScope>;
|
|
160
|
+
getKnownAgentScope(): AgentScope | "unknown";
|
|
161
|
+
isConnected(): boolean;
|
|
162
|
+
getStatus(): DataClientStatus;
|
|
163
|
+
onStatusChange(listener: (status: DataClientStatus) => void): () => void;
|
|
164
|
+
private emitStatus;
|
|
165
|
+
}
|