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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MultiplexClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const multiplex_merge_js_1 = require("./multiplex-merge.js");
|
|
5
|
+
const batch_js_1 = require("../types/batch.js");
|
|
6
|
+
const errors_js_1 = require("./errors.js");
|
|
7
|
+
const snowflake_js_1 = require("../utils/snowflake.js");
|
|
8
|
+
const multiplex_gateway_js_1 = require("./multiplex-gateway.js");
|
|
9
9
|
/** "<subclient>.<method>" → spec. Drives the generic non-core facades. */
|
|
10
10
|
const NONCORE_METHODS = {
|
|
11
11
|
// alarms
|
|
@@ -246,7 +246,7 @@ class MultiplexClient {
|
|
|
246
246
|
gatewayMembersForAgent: (agentId) => this.membersForAgentWithCapability(agentId, "gateway.subscribe")
|
|
247
247
|
.map(({ id, client }) => ({ id, gateway: client.gateway })),
|
|
248
248
|
};
|
|
249
|
-
return new
|
|
249
|
+
return new multiplex_gateway_js_1.MultiplexGateway(host);
|
|
250
250
|
}
|
|
251
251
|
// ===== helpers =====
|
|
252
252
|
/** Resolve the optional `{ sources?: string[] }` bag from a method's trailing
|
|
@@ -275,7 +275,7 @@ class MultiplexClient {
|
|
|
275
275
|
/** Throw if no enabled member supports `cap` at all (regardless of agent). */
|
|
276
276
|
assertSomeMemberSupports(cap) {
|
|
277
277
|
if (!this.enabledClients().some(({ client }) => client.supports(cap))) {
|
|
278
|
-
throw new
|
|
278
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, this.clientId);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
isNotFound(err) {
|
|
@@ -286,7 +286,7 @@ class MultiplexClient {
|
|
|
286
286
|
return "messages.listHistorical";
|
|
287
287
|
if (params?.before) {
|
|
288
288
|
try {
|
|
289
|
-
const { timestamp: ts } = (0,
|
|
289
|
+
const { timestamp: ts } = (0, snowflake_js_1.extractSnowflakeId)(params.before);
|
|
290
290
|
if (typeof ts === "number" && ts < Date.now() - 24 * 60 * 60 * 1000)
|
|
291
291
|
return "messages.listHistorical";
|
|
292
292
|
}
|
|
@@ -295,7 +295,7 @@ class MultiplexClient {
|
|
|
295
295
|
return "messages.list";
|
|
296
296
|
}
|
|
297
297
|
unsupportedMethod(_method, cap) {
|
|
298
|
-
return () => Promise.reject(new
|
|
298
|
+
return () => Promise.reject(new errors_js_1.UnsupportedCapabilityError(cap, this.clientId));
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
* Route a cross-agent batch mutation.
|
|
@@ -324,13 +324,13 @@ class MultiplexClient {
|
|
|
324
324
|
if (sources && sources.length === 1) {
|
|
325
325
|
const only = members.find((m) => m.id === sources[0]);
|
|
326
326
|
if (!only)
|
|
327
|
-
throw new
|
|
327
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, sources[0]);
|
|
328
328
|
members = [only];
|
|
329
329
|
}
|
|
330
330
|
if (members.length === 0)
|
|
331
|
-
throw new
|
|
331
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, self.clientId);
|
|
332
332
|
if (members.length > 1) {
|
|
333
|
-
throw new
|
|
333
|
+
throw new errors_js_1.AmbiguousWriteError(cap, members.map((m) => m.id));
|
|
334
334
|
}
|
|
335
335
|
const target = members[0];
|
|
336
336
|
const group = groups.get(target.id) ?? {
|
|
@@ -362,7 +362,7 @@ class MultiplexClient {
|
|
|
362
362
|
};
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
|
-
return (0,
|
|
365
|
+
return (0, batch_js_1.mergeBatchResponses)([
|
|
366
366
|
{ items: results, count: results.length, succeeded: 0, failed: 0 },
|
|
367
367
|
]);
|
|
368
368
|
};
|
|
@@ -409,13 +409,13 @@ class MultiplexClient {
|
|
|
409
409
|
if (sources && sources.length === 1) {
|
|
410
410
|
const only = members.find((m) => m.id === sources[0]);
|
|
411
411
|
if (!only)
|
|
412
|
-
throw new
|
|
412
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, sources[0]);
|
|
413
413
|
members = [only];
|
|
414
414
|
}
|
|
415
415
|
if (members.length === 0)
|
|
416
|
-
throw new
|
|
416
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, self.clientId);
|
|
417
417
|
if (members.length > 1)
|
|
418
|
-
throw new
|
|
418
|
+
throw new errors_js_1.AmbiguousWriteError(cap, members.map((m) => m.id));
|
|
419
419
|
const target = members[0];
|
|
420
420
|
const subclient = method.split(".")[0];
|
|
421
421
|
const fnName = method.split(".")[1];
|
|
@@ -432,7 +432,7 @@ class MultiplexClient {
|
|
|
432
432
|
const agentId = self.extractAgentId(args);
|
|
433
433
|
const members = self.candidates(agentId, cap, sources);
|
|
434
434
|
if (members.length === 0)
|
|
435
|
-
throw new
|
|
435
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, self.clientId);
|
|
436
436
|
const subclient = method.split(".")[0];
|
|
437
437
|
const fnName = method.split(".")[1];
|
|
438
438
|
let lastErr;
|
|
@@ -458,7 +458,7 @@ class MultiplexClient {
|
|
|
458
458
|
const agentId = self.extractAgentId(args);
|
|
459
459
|
const members = self.candidates(agentId, cap, sources);
|
|
460
460
|
if (members.length === 0)
|
|
461
|
-
throw new
|
|
461
|
+
throw new errors_js_1.UnsupportedCapabilityError(cap, self.clientId);
|
|
462
462
|
const subclient = method.split(".")[0];
|
|
463
463
|
const fnName = method.split(".")[1];
|
|
464
464
|
let lastErr;
|
|
@@ -485,7 +485,7 @@ class MultiplexClient {
|
|
|
485
485
|
self.assertSomeMemberSupports("channels.list");
|
|
486
486
|
const members = self.candidates(agentId, "channels.list", sources);
|
|
487
487
|
const perMember = await Promise.all(members.map((m) => m.client.channels.listChannels(...args)));
|
|
488
|
-
return (0,
|
|
488
|
+
return (0, multiplex_merge_js_1.dedupeBy)([].concat(...perMember), (c) => c.name);
|
|
489
489
|
},
|
|
490
490
|
async getChannel(agentIdOrId, ...rest) {
|
|
491
491
|
const { args, sources } = self.splitSourcesOption([agentIdOrId, ...rest]);
|
|
@@ -566,7 +566,7 @@ class MultiplexClient {
|
|
|
566
566
|
self.assertSomeMemberSupports(implied);
|
|
567
567
|
const members = self.candidates(agentId, implied, sources);
|
|
568
568
|
const perMember = await Promise.all(members.map((m) => m.client.messages.listMessages(...args)));
|
|
569
|
-
return (0,
|
|
569
|
+
return (0, multiplex_merge_js_1.mergeMessages)(perMember, { order: params?.order ?? "desc", limit: params?.limit });
|
|
570
570
|
},
|
|
571
571
|
async getMessage(agentIdOrId, ...rest) {
|
|
572
572
|
const { args, sources } = self.splitSourcesOption([agentIdOrId, ...rest]);
|
|
@@ -620,7 +620,7 @@ class MultiplexClient {
|
|
|
620
620
|
members = members.filter((m) => allow.has(m.id));
|
|
621
621
|
}
|
|
622
622
|
const responses = await Promise.all(members.map((m) => m.client.agents.listAgents(...args)));
|
|
623
|
-
const merged = (0,
|
|
623
|
+
const merged = (0, multiplex_merge_js_1.dedupeBy)([].concat(...responses.map((r) => (r.agents ?? r.results ?? []))), (a) => a.id);
|
|
624
624
|
return { agents: merged, results: merged, count: merged.length };
|
|
625
625
|
},
|
|
626
626
|
async getMultiAgentMessages(channelName, ...rest) {
|
|
@@ -632,7 +632,7 @@ class MultiplexClient {
|
|
|
632
632
|
members = members.filter((m) => allow.has(m.id));
|
|
633
633
|
}
|
|
634
634
|
const responses = await Promise.all(members.map((m) => m.client.agents.getMultiAgentMessages(...args)));
|
|
635
|
-
const merged = (0,
|
|
635
|
+
const merged = (0, multiplex_merge_js_1.mergeMessages)(responses.map((r) => r.results), { order: "desc" });
|
|
636
636
|
// Union each member's per-agent resume cursors so a paginating caller
|
|
637
637
|
// keeps walking. If one agent lives in two members with different
|
|
638
638
|
// cursors, keep the lexically-highest (newest) — resuming from the
|
|
@@ -660,7 +660,7 @@ class MultiplexClient {
|
|
|
660
660
|
members = members.filter((m) => allow.has(m.id));
|
|
661
661
|
}
|
|
662
662
|
const responses = await Promise.all(members.map((m) => m.client.agents.getMultiAgentAggregates(...args)));
|
|
663
|
-
const merged = (0,
|
|
663
|
+
const merged = (0, multiplex_merge_js_1.dedupeBy)([].concat(...responses.map((r) => r.results)), (a) => a.agent_id);
|
|
664
664
|
return { results: merged, count: merged.length };
|
|
665
665
|
},
|
|
666
666
|
getTokenState: self.makeFanoutFirst("agents.getTokenState", "agents.tokenRead"),
|
|
@@ -683,7 +683,7 @@ class MultiplexClient {
|
|
|
683
683
|
const spec = NONCORE_METHODS[key];
|
|
684
684
|
if (!spec) {
|
|
685
685
|
// Unknown method on a non-core subclient — treat as unsupported (read).
|
|
686
|
-
return () => Promise.reject(new
|
|
686
|
+
return () => Promise.reject(new errors_js_1.UnsupportedCapabilityError(self.guessNonCoreCap(subclientName), self.clientId));
|
|
687
687
|
}
|
|
688
688
|
if (spec.kind === "write-route") {
|
|
689
689
|
return self.routedWrite(key, spec.cap);
|
|
@@ -694,7 +694,7 @@ class MultiplexClient {
|
|
|
694
694
|
const agentId = !spec.agentScoped ? undefined : self.extractAgentId(args);
|
|
695
695
|
let members = self.candidates(agentId, spec.cap, sources);
|
|
696
696
|
if (members.length === 0)
|
|
697
|
-
throw new
|
|
697
|
+
throw new errors_js_1.UnsupportedCapabilityError(spec.cap, self.clientId);
|
|
698
698
|
let lastErr;
|
|
699
699
|
for (const m of members) {
|
|
700
700
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { GatewayClientLike } from "./data-client";
|
|
2
|
-
import type { ChannelRef } from "../types/common";
|
|
3
|
-
import type { WebSocketSession } from "../gateway/types";
|
|
1
|
+
import type { GatewayClientLike } from "./data-client.js";
|
|
2
|
+
import type { ChannelRef } from "../types/common.js";
|
|
3
|
+
import type { WebSocketSession } from "../gateway/types.js";
|
|
4
4
|
/** Minimal view of what MultiplexGateway needs from the owning multiplex. */
|
|
5
5
|
export interface MultiplexGatewayHost {
|
|
6
6
|
/** Enabled members with `gateway.subscribe`. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageStructure } from "../types/common";
|
|
1
|
+
import type { MessageStructure } from "../types/common.js";
|
|
2
2
|
/** Keep the first item for each key; preserve input order otherwise. */
|
|
3
3
|
export declare function dedupeBy<T>(items: T[], keyOf: (item: T) => string): T[];
|
|
4
4
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Network availability is independent of the Doover gateway connection. */
|
|
2
|
+
export interface NetworkStatusSnapshot {
|
|
3
|
+
readonly online: boolean;
|
|
4
|
+
readonly at: number;
|
|
5
|
+
}
|
|
6
|
+
/** Snapshots must retain their identity until the status changes. */
|
|
7
|
+
export interface NetworkStatusSource {
|
|
8
|
+
getSnapshot(): NetworkStatusSnapshot;
|
|
9
|
+
subscribe(listener: () => void): () => void;
|
|
10
|
+
}
|
|
11
|
+
/** A source that native network callbacks can update. */
|
|
12
|
+
export declare function createNetworkStatusStore(initialOnline: boolean): {
|
|
13
|
+
getSnapshot: () => NetworkStatusSnapshot;
|
|
14
|
+
subscribe(listener: () => void): () => void;
|
|
15
|
+
setOnline(online: boolean): void;
|
|
16
|
+
};
|
|
17
|
+
export declare const browserNetworkStatus: NetworkStatusSource;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browserNetworkStatus = void 0;
|
|
4
|
+
exports.createNetworkStatusStore = createNetworkStatusStore;
|
|
5
|
+
/** A source that native network callbacks can update. */
|
|
6
|
+
function createNetworkStatusStore(initialOnline) {
|
|
7
|
+
let snapshot = { online: initialOnline, at: Date.now() };
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
return {
|
|
10
|
+
getSnapshot: () => snapshot,
|
|
11
|
+
subscribe(listener) {
|
|
12
|
+
listeners.add(listener);
|
|
13
|
+
return () => { listeners.delete(listener); };
|
|
14
|
+
},
|
|
15
|
+
setOnline(online) {
|
|
16
|
+
if (online === snapshot.online)
|
|
17
|
+
return;
|
|
18
|
+
snapshot = { online, at: Date.now() };
|
|
19
|
+
listeners.forEach((listener) => listener());
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function readBrowserOnline() {
|
|
24
|
+
const nav = typeof window !== "undefined" ? window.navigator
|
|
25
|
+
: typeof navigator !== "undefined" ? navigator : undefined;
|
|
26
|
+
return typeof nav?.onLine === "boolean" ? nav.onLine : true;
|
|
27
|
+
}
|
|
28
|
+
// Listen only while observed. getSnapshot also refreshes after periods with
|
|
29
|
+
// no subscribers, including initial offline loads. No browser globals at import.
|
|
30
|
+
function createBrowserNetworkStatus() {
|
|
31
|
+
let snapshot = { online: true, at: 0 };
|
|
32
|
+
const listeners = new Set();
|
|
33
|
+
let detach;
|
|
34
|
+
const getSnapshot = () => {
|
|
35
|
+
const online = readBrowserOnline();
|
|
36
|
+
if (online !== snapshot.online)
|
|
37
|
+
snapshot = { online, at: Date.now() };
|
|
38
|
+
return snapshot;
|
|
39
|
+
};
|
|
40
|
+
const refresh = () => {
|
|
41
|
+
getSnapshot();
|
|
42
|
+
// A request may already have read the new snapshot before this event.
|
|
43
|
+
// Still notify mounted consumers; React ignores an unchanged snapshot.
|
|
44
|
+
listeners.forEach((listener) => listener());
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
getSnapshot,
|
|
48
|
+
subscribe(listener) {
|
|
49
|
+
listeners.add(listener);
|
|
50
|
+
if (!detach && typeof window !== "undefined") {
|
|
51
|
+
const target = window;
|
|
52
|
+
target.addEventListener("online", refresh);
|
|
53
|
+
target.addEventListener("offline", refresh);
|
|
54
|
+
detach = () => {
|
|
55
|
+
target.removeEventListener("online", refresh);
|
|
56
|
+
target.removeEventListener("offline", refresh);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
refresh();
|
|
60
|
+
return () => {
|
|
61
|
+
listeners.delete(listener);
|
|
62
|
+
if (!listeners.size) {
|
|
63
|
+
detach?.();
|
|
64
|
+
detach = undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.browserNetworkStatus = createBrowserNetworkStatus();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { type NetworkStatusSource } from "./network-status.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
|
+
import type { Capability } from "./capabilities.js";
|
|
3
4
|
export declare const DEFAULT_OFFLINE_RETENTION_MS: number;
|
|
4
5
|
export type OfflineCacheMode = "read-through" | "network-first" | "cache-first" | "cache-only";
|
|
5
6
|
export interface OfflineReadCacheOptions {
|
|
@@ -83,18 +84,22 @@ export declare class MemoryOfflineStorageAdapter implements OfflineStorageAdapte
|
|
|
83
84
|
deleteBlob(key: string): Promise<void>;
|
|
84
85
|
}
|
|
85
86
|
export interface OfflineDataClientOptions {
|
|
87
|
+
/** Reactive platform signal; defaults to the wrapped client's source. */
|
|
88
|
+
networkStatus?: NetworkStatusSource;
|
|
86
89
|
client: DataClient;
|
|
87
90
|
storage: OfflineStorageAdapter;
|
|
88
91
|
scope: OfflineCacheScope;
|
|
89
92
|
policies?: OfflineChannelPolicy[];
|
|
90
93
|
defaultRetentionMs?: number;
|
|
91
94
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
95
|
+
* Legacy pull-only override. Prefer networkStatus for reactive updates
|
|
96
|
+
* between requests. When omitted, the wrapper reads its network source.
|
|
94
97
|
*/
|
|
95
98
|
isOnline?: () => boolean;
|
|
96
99
|
}
|
|
97
100
|
export declare class OfflineDataClient implements DataClient {
|
|
101
|
+
readonly networkStatus: NetworkStatusSource;
|
|
102
|
+
private unsubscribeNetwork?;
|
|
98
103
|
readonly agents: AgentsApiLike;
|
|
99
104
|
readonly channels: ChannelsApiLike;
|
|
100
105
|
readonly messages: MessagesApiLike;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OfflineDataClient = exports.MemoryOfflineStorageAdapter = exports.DEFAULT_OFFLINE_RETENTION_MS = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const network_status_js_1 = require("./network-status.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
const request_options_js_1 = require("./request-options.js");
|
|
6
7
|
exports.DEFAULT_OFFLINE_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
7
8
|
class MemoryOfflineStorageAdapter {
|
|
8
9
|
constructor() {
|
|
@@ -57,6 +58,7 @@ class OfflineDataClient {
|
|
|
57
58
|
this.offlineStatus = INITIAL_OFFLINE_STATUS;
|
|
58
59
|
this.persistQueue = Promise.resolve();
|
|
59
60
|
this.client = options.client;
|
|
61
|
+
this.networkStatus = options.networkStatus ?? options.client.networkStatus ?? network_status_js_1.browserNetworkStatus;
|
|
60
62
|
this.storage = options.storage;
|
|
61
63
|
this.scope = options.scope;
|
|
62
64
|
this.defaultRetentionMs = options.defaultRetentionMs ?? exports.DEFAULT_OFFLINE_RETENTION_MS;
|
|
@@ -90,19 +92,30 @@ class OfflineDataClient {
|
|
|
90
92
|
return this.policies;
|
|
91
93
|
}
|
|
92
94
|
getOfflineStatus() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
online:
|
|
96
|
-
}
|
|
95
|
+
const online = this.isOnline();
|
|
96
|
+
if (online !== this.offlineStatus.online) {
|
|
97
|
+
this.offlineStatus = { ...this.offlineStatus, online, at: Date.now() };
|
|
98
|
+
}
|
|
99
|
+
return this.offlineStatus;
|
|
97
100
|
}
|
|
98
101
|
onOfflineStatusChange(listener) {
|
|
99
102
|
this.offlineStatusListeners.add(listener);
|
|
103
|
+
if (!this.unsubscribeNetwork) {
|
|
104
|
+
this.unsubscribeNetwork = this.networkStatus.subscribe(() => {
|
|
105
|
+
const status = this.getOfflineStatus();
|
|
106
|
+
this.offlineStatusListeners.forEach((callback) => callback(status));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
100
109
|
let active = true;
|
|
101
110
|
return () => {
|
|
102
111
|
if (!active)
|
|
103
112
|
return;
|
|
104
113
|
active = false;
|
|
105
114
|
this.offlineStatusListeners.delete(listener);
|
|
115
|
+
if (!this.offlineStatusListeners.size) {
|
|
116
|
+
this.unsubscribeNetwork?.();
|
|
117
|
+
this.unsubscribeNetwork = undefined;
|
|
118
|
+
}
|
|
106
119
|
};
|
|
107
120
|
}
|
|
108
121
|
async clearScope(scope = this.scope) {
|
|
@@ -128,7 +141,7 @@ class OfflineDataClient {
|
|
|
128
141
|
const target = this.client.agents;
|
|
129
142
|
return {
|
|
130
143
|
listAgents: ((...rawArgs) => {
|
|
131
|
-
const { args, request } = (0,
|
|
144
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
132
145
|
return this.readCached(() => target.listAgents(...this.withDelegateOptions(args, request)), {
|
|
133
146
|
operation: "agents.listAgents",
|
|
134
147
|
kind: "agents.list",
|
|
@@ -137,7 +150,7 @@ class OfflineDataClient {
|
|
|
137
150
|
});
|
|
138
151
|
}),
|
|
139
152
|
getMultiAgentMessages: ((channelName, ...rest) => {
|
|
140
|
-
const { args, request } = (0,
|
|
153
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)([channelName, ...rest]);
|
|
141
154
|
const params = args[1];
|
|
142
155
|
return this.readCached(() => target.getMultiAgentMessages(...this.withDelegateOptions(args, request)), {
|
|
143
156
|
operation: "agents.getMultiAgentMessages",
|
|
@@ -149,7 +162,7 @@ class OfflineDataClient {
|
|
|
149
162
|
});
|
|
150
163
|
}),
|
|
151
164
|
getMultiAgentAggregates: ((channelName, ...rest) => {
|
|
152
|
-
const { args, request } = (0,
|
|
165
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)([channelName, ...rest]);
|
|
153
166
|
const params = args[1];
|
|
154
167
|
return this.readCached(() => target.getMultiAgentAggregates(...this.withDelegateOptions(args, request)), {
|
|
155
168
|
operation: "agents.getMultiAgentAggregates",
|
|
@@ -166,7 +179,7 @@ class OfflineDataClient {
|
|
|
166
179
|
const target = this.client.channels;
|
|
167
180
|
return {
|
|
168
181
|
listChannels: ((...rawArgs) => {
|
|
169
|
-
const { args, request } = (0,
|
|
182
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
170
183
|
const agentId = extractAgentId(args);
|
|
171
184
|
return this.readCached(() => target.listChannels(...this.withDelegateOptions(args, request)), {
|
|
172
185
|
operation: "channels.listChannels",
|
|
@@ -177,7 +190,7 @@ class OfflineDataClient {
|
|
|
177
190
|
});
|
|
178
191
|
}),
|
|
179
192
|
getChannel: ((...rawArgs) => {
|
|
180
|
-
const { args, request } = (0,
|
|
193
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
181
194
|
const { agentId, channelName } = extractChannelId(args);
|
|
182
195
|
return this.readCached(() => target.getChannel(...this.withDelegateOptions(args, request)), {
|
|
183
196
|
operation: "channels.getChannel",
|
|
@@ -199,7 +212,7 @@ class OfflineDataClient {
|
|
|
199
212
|
const target = this.client.aggregates;
|
|
200
213
|
return {
|
|
201
214
|
getAggregate: ((...rawArgs) => {
|
|
202
|
-
const { args, request } = (0,
|
|
215
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
203
216
|
const { agentId, channelName } = extractChannelId(args);
|
|
204
217
|
return this.readCached(() => target.getAggregate(...this.withDelegateOptions(args, request)), {
|
|
205
218
|
operation: "aggregates.getAggregate",
|
|
@@ -217,7 +230,7 @@ class OfflineDataClient {
|
|
|
217
230
|
patchAggregate: this.offlineGuard("aggregates.patchAggregate", target.patchAggregate.bind(target)),
|
|
218
231
|
batchPatchAggregates: this.offlineGuard("aggregates.batchPatchAggregates", target.batchPatchAggregates.bind(target)),
|
|
219
232
|
getAggregateAttachment: ((...rawArgs) => {
|
|
220
|
-
const { args, request } = (0,
|
|
233
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
221
234
|
const { agentId, channelName } = extractChannelId(args);
|
|
222
235
|
const attachmentId = String(args[2] ?? args[1] ?? "");
|
|
223
236
|
return this.readBlobCached(() => target.getAggregateAttachment(...this.withDelegateOptions(args, request)), {
|
|
@@ -235,7 +248,7 @@ class OfflineDataClient {
|
|
|
235
248
|
const target = this.client.messages;
|
|
236
249
|
return {
|
|
237
250
|
listMessages: ((...rawArgs) => {
|
|
238
|
-
const { args, request } = (0,
|
|
251
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
239
252
|
const { agentId, channelName } = extractChannelId(args);
|
|
240
253
|
return this.readCached(() => target.listMessages(...this.withDelegateOptions(args, request)), {
|
|
241
254
|
operation: "messages.listMessages",
|
|
@@ -249,7 +262,7 @@ class OfflineDataClient {
|
|
|
249
262
|
});
|
|
250
263
|
}),
|
|
251
264
|
getMessage: ((...rawArgs) => {
|
|
252
|
-
const { args, request } = (0,
|
|
265
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
253
266
|
const { agentId, channelName } = extractChannelId(args);
|
|
254
267
|
const messageId = String(args[2] ?? args[1] ?? "");
|
|
255
268
|
return this.readCached(() => target.getMessage(...this.withDelegateOptions(args, request)), {
|
|
@@ -274,7 +287,7 @@ class OfflineDataClient {
|
|
|
274
287
|
batchDeleteMessages: this.offlineGuard("messages.batchDeleteMessages", target.batchDeleteMessages.bind(target)),
|
|
275
288
|
getTimeseries: ((...args) => target.getTimeseries(...args)),
|
|
276
289
|
getMessageAttachment: ((...rawArgs) => {
|
|
277
|
-
const { args, request } = (0,
|
|
290
|
+
const { args, request } = (0, request_options_js_1.splitRequestOptions)(rawArgs);
|
|
278
291
|
const { agentId, channelName } = extractChannelId(args);
|
|
279
292
|
const messageId = String(args[2] ?? args[1] ?? "");
|
|
280
293
|
const attachmentId = String(args[3] ?? args[2] ?? "");
|
|
@@ -351,7 +364,7 @@ class OfflineDataClient {
|
|
|
351
364
|
offlineGuard(operation, fn) {
|
|
352
365
|
return ((...args) => {
|
|
353
366
|
if (!this.isOnline())
|
|
354
|
-
throw new
|
|
367
|
+
throw new errors_js_1.DooverOfflineError(operation);
|
|
355
368
|
return fn(...args);
|
|
356
369
|
});
|
|
357
370
|
}
|
|
@@ -416,7 +429,7 @@ class OfflineDataClient {
|
|
|
416
429
|
isOfflineFallback: !this.isOnline(),
|
|
417
430
|
isExpired: false,
|
|
418
431
|
});
|
|
419
|
-
throw new
|
|
432
|
+
throw new errors_js_1.DooverOfflineError(descriptor.operation, `No cached attachment is available for "${descriptor.operation}" while offline.`, key);
|
|
420
433
|
}
|
|
421
434
|
if (effective.mode === "cache-first") {
|
|
422
435
|
const cached = await this.storage.getBlob?.(key);
|
|
@@ -468,7 +481,7 @@ class OfflineDataClient {
|
|
|
468
481
|
isOfflineFallback: !this.isOnline(),
|
|
469
482
|
isExpired: false,
|
|
470
483
|
});
|
|
471
|
-
throw new
|
|
484
|
+
throw new errors_js_1.DooverOfflineError(operation, `No cached data is available for "${operation}" while offline.`, key);
|
|
472
485
|
}
|
|
473
486
|
async tryReadRecord(key, allowExpired) {
|
|
474
487
|
const record = await this.storage.getJson(key);
|
|
@@ -657,7 +670,7 @@ class OfflineDataClient {
|
|
|
657
670
|
return false;
|
|
658
671
|
}
|
|
659
672
|
withDelegateOptions(args, request) {
|
|
660
|
-
const delegate = (0,
|
|
673
|
+
const delegate = (0, request_options_js_1.delegateRequestOptions)(request);
|
|
661
674
|
return delegate ? [...args, delegate] : args;
|
|
662
675
|
}
|
|
663
676
|
cacheKey(descriptor) {
|
|
@@ -682,8 +695,7 @@ class OfflineDataClient {
|
|
|
682
695
|
isOnline() {
|
|
683
696
|
if (this.isOnlineFn)
|
|
684
697
|
return this.isOnlineFn();
|
|
685
|
-
|
|
686
|
-
return nav?.onLine ?? true;
|
|
698
|
+
return this.networkStatus.getSnapshot().online;
|
|
687
699
|
}
|
|
688
700
|
setOfflineStatus(status) {
|
|
689
701
|
this.offlineStatus = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SourceProvenance } from "../types/provenance";
|
|
1
|
+
import type { SourceProvenance } from "../types/provenance.js";
|
|
2
2
|
/** A stamped value: adds `__source` to plain objects and their array elements.
|
|
3
3
|
* For object values, also adds `__source` to any known nested-object props
|
|
4
4
|
* (aggregate, message) and stamps elements of array-valued props. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DooverClientConfig } from "../http/rest-client";
|
|
2
|
-
import { DooverClient } from "./doover-client";
|
|
1
|
+
import type { DooverClientConfig } from "../http/rest-client.js";
|
|
2
|
+
import { DooverClient } from "./doover-client.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get the process-wide `DooverClient` instance, creating it on first call.
|
|
5
5
|
*
|
package/dist/client/singleton.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getDooverClient = getDooverClient;
|
|
4
4
|
exports.peekDooverClient = peekDooverClient;
|
|
5
5
|
exports.resetDooverClient = resetDooverClient;
|
|
6
|
-
const
|
|
6
|
+
const doover_client_js_1 = require("./doover-client.js");
|
|
7
7
|
const GLOBAL_KEY = "__doover_js_client__";
|
|
8
8
|
function globalBag() {
|
|
9
9
|
return globalThis;
|
|
@@ -32,7 +32,7 @@ function getDooverClient(config) {
|
|
|
32
32
|
}
|
|
33
33
|
return existing;
|
|
34
34
|
}
|
|
35
|
-
const client = new
|
|
35
|
+
const client = new doover_client_js_1.DooverClient(config);
|
|
36
36
|
bag[GLOBAL_KEY] = client;
|
|
37
37
|
return client;
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentScope, DataClientStatus, GatewayClientLike } from "./data-client";
|
|
1
|
+
import type { AgentScope, DataClientStatus, GatewayClientLike } from "./data-client.js";
|
|
2
2
|
/**
|
|
3
3
|
* Tracks a `DataClient`'s realtime status by subscribing to its gateway's
|
|
4
4
|
* `open` / `ready` / `close` / `wssError` events. Emits a fresh
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ChannelIdentifierLike {
|
|
2
|
+
agentId: string;
|
|
3
|
+
channelName: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AgentIdentifierLike {
|
|
6
|
+
agentId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveChannelArgs<TOptions>(args: unknown[]): {
|
|
9
|
+
agentId: string;
|
|
10
|
+
channelName: string;
|
|
11
|
+
options?: TOptions;
|
|
12
|
+
};
|
|
13
|
+
export declare function resolveAgentArgs<TOptions>(args: unknown[]): {
|
|
14
|
+
agentId: string;
|
|
15
|
+
options?: TOptions;
|
|
16
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isDooverRequestOptions } from "../client/request-options.js";
|
|
2
|
+
export function resolveChannelArgs(args) {
|
|
3
|
+
if (typeof args[0] === "string") {
|
|
4
|
+
const options = isDooverRequestOptions(args[2]) ? undefined : args[2];
|
|
5
|
+
return {
|
|
6
|
+
agentId: args[0],
|
|
7
|
+
channelName: args[1],
|
|
8
|
+
options: options,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const id = args[0];
|
|
12
|
+
const options = isDooverRequestOptions(args[1]) ? undefined : args[1];
|
|
13
|
+
return {
|
|
14
|
+
agentId: id.agentId,
|
|
15
|
+
channelName: id.channelName,
|
|
16
|
+
options: options,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function resolveAgentArgs(args) {
|
|
20
|
+
if (typeof args[0] === "string") {
|
|
21
|
+
const options = isDooverRequestOptions(args[1]) ? undefined : args[1];
|
|
22
|
+
return { agentId: args[0], options: options };
|
|
23
|
+
}
|
|
24
|
+
const id = args[0];
|
|
25
|
+
const options = isDooverRequestOptions(args[1]) ? undefined : args[1];
|
|
26
|
+
return { agentId: id.agentId, options: options };
|
|
27
|
+
}
|