@cratis/arc 22.0.2 → 22.1.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/dist/cjs/queries/ObservableQueryFor.js +6 -1
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.js +6 -6
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
- package/dist/cjs/queries/QueryResult.js +23 -4
- package/dist/cjs/queries/QueryResult.js.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.js +20 -7
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventHubConnection.js +120 -58
- package/dist/cjs/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/cjs/queries/WebSocketHubConnection.js +121 -51
- package/dist/cjs/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/esm/queries/IQueryResult.d.ts +1 -0
- package/dist/esm/queries/IQueryResult.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js +6 -1
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.d.ts +1 -1
- package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.js +6 -6
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/queries/QueryResult.d.ts +2 -0
- package/dist/esm/queries/QueryResult.d.ts.map +1 -1
- package/dist/esm/queries/QueryResult.js +23 -4
- package/dist/esm/queries/QueryResult.js.map +1 -1
- package/dist/esm/queries/QueryResultWithState.d.ts +3 -3
- package/dist/esm/queries/QueryResultWithState.d.ts.map +1 -1
- package/dist/esm/queries/QueryResultWithState.js +20 -7
- package/dist/esm/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/queries/ServerSentEventHubConnection.d.ts +11 -4
- package/dist/esm/queries/ServerSentEventHubConnection.d.ts.map +1 -1
- package/dist/esm/queries/ServerSentEventHubConnection.js +120 -58
- package/dist/esm/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/esm/queries/WebSocketHubConnection.d.ts +13 -2
- package/dist/esm/queries/WebSocketHubConnection.d.ts.map +1 -1
- package/dist/esm/queries/WebSocketHubConnection.js +121 -51
- package/dist/esm/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.js +34 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.js +26 -2
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.js +60 -3
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_web_socket_hub_payload_without_readiness.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_web_socket_hub_payload_without_readiness.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_web_socket_hub_payload_without_readiness.js +83 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_web_socket_hub_payload_without_readiness.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_readiness_changed.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_readiness_changed.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_readiness_changed.js +22 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_readiness_changed.js.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/with_readiness_false.d.ts +2 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/with_readiness_false.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/with_readiness_false.js +17 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/with_readiness_false.js.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/without_readiness.d.ts +2 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/without_readiness.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/without_readiness.js +16 -0
- package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result/without_readiness.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_readiness_false.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_readiness_false.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_readiness_false.js +19 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_readiness_false.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/without_readiness.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/without_readiness.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/without_readiness.js +19 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/without_readiness.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_deferred_promise.d.ts +7 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_deferred_promise.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_deferred_promise.js +12 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_deferred_promise.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts +2 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.js +15 -4
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.js.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.js +44 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.js +74 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.js +74 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.js +59 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.js +58 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.js +6 -3
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.js.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.js +23 -6
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.js.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.js +20 -5
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.js.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.js +20 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.js +68 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.js +38 -13
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.js.map +1 -1
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscription_revisions_are_not_advertised/uses_legacy_protocol.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscription_revisions_are_not_advertised/uses_legacy_protocol.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscription_revisions_are_not_advertised/uses_legacy_protocol.js +54 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscription_revisions_are_not_advertised/uses_legacy_protocol.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.js +18 -4
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.js.map +1 -1
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.js +22 -5
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.js.map +1 -1
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/ignores_a_pending_reconnect_and_stale_socket_callbacks.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/ignores_a_pending_reconnect_and_stale_socket_callbacks.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/ignores_a_pending_reconnect_and_stale_socket_callbacks.js +108 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/ignores_a_pending_reconnect_and_stale_socket_callbacks.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/replaces_a_closing_socket_safely.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/replaces_a_closing_socket_safely.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/replaces_a_closing_socket_safely.js +33 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/replaces_a_closing_socket_safely.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.js +26 -4
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.js.map +1 -1
- package/dist/esm/queries/for_WebSocketHubConnection/when_replacing_a_subscription/ignores_stale_result_unauthorized_and_error.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_replacing_a_subscription/ignores_stale_result_unauthorized_and_error.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_replacing_a_subscription/ignores_stale_result_unauthorized_and_error.js +62 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_replacing_a_subscription/ignores_stale_result_unauthorized_and_error.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.js +18 -5
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.js.map +1 -1
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscription_revisions_are_supported/upgrades_active_subscriptions_to_strict_mode.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscription_revisions_are_supported/upgrades_active_subscriptions_to_strict_mode.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscription_revisions_are_supported/upgrades_active_subscriptions_to_strict_mode.js +56 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscription_revisions_are_supported/upgrades_active_subscriptions_to_strict_mode.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.js +16 -3
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.js.map +1 -1
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/with_revision_support_not_advertised.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/with_revision_support_not_advertised.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/with_revision_support_not_advertised.js +33 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/with_revision_support_not_advertised.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/IQueryResult.ts +10 -0
- package/queries/ObservableQueryFor.ts +44 -16
- package/queries/QueryInstanceCache.ts +42 -19
- package/queries/QueryResult.ts +145 -79
- package/queries/QueryResultWithState.ts +32 -9
- package/queries/ServerSentEventHubConnection.ts +270 -83
- package/queries/WebSocketHubConnection.ts +188 -56
- package/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.ts +46 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.ts +91 -57
- package/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.ts +125 -53
- package/queries/for_ObservableQueryFor/when_subscribing/with_web_socket_hub_payload_without_readiness.ts +107 -0
- package/queries/for_QueryInstanceCache/when_setting_last_result/with_only_readiness_changed.ts +63 -0
- package/queries/for_QueryResult/when_constructing_from_a_server_result/with_readiness_false.ts +25 -0
- package/queries/for_QueryResult/when_constructing_from_a_server_result/without_readiness.ts +24 -0
- package/queries/for_QueryResultWithState/when_creating_from_query_result/with_readiness_false.ts +28 -0
- package/queries/for_QueryResultWithState/when_creating_from_query_result/without_readiness.ts +25 -0
- package/queries/for_ServerSentEventHubConnection/given/a_deferred_promise.ts +15 -0
- package/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.ts +18 -7
- package/queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.ts +59 -0
- package/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.ts +113 -0
- package/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.ts +109 -0
- package/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.ts +81 -0
- package/queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.ts +83 -0
- package/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.ts +30 -21
- package/queries/for_ServerSentEventHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.ts +56 -32
- package/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.ts +23 -6
- package/queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.ts +41 -0
- package/queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.ts +92 -0
- package/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.ts +69 -30
- package/queries/for_ServerSentEventHubConnection/when_subscription_revisions_are_not_advertised/uses_legacy_protocol.ts +69 -0
- package/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.ts +43 -24
- package/queries/for_WebSocketHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.ts +53 -29
- package/queries/for_WebSocketHubConnection/when_reconnecting/ignores_a_pending_reconnect_and_stale_socket_callbacks.ts +131 -0
- package/queries/for_WebSocketHubConnection/when_reconnecting/replaces_a_closing_socket_safely.ts +39 -0
- package/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.ts +72 -36
- package/queries/for_WebSocketHubConnection/when_replacing_a_subscription/ignores_stale_result_unauthorized_and_error.ts +88 -0
- package/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.ts +54 -27
- package/queries/for_WebSocketHubConnection/when_subscription_revisions_are_supported/upgrades_active_subscriptions_to_strict_mode.ts +72 -0
- package/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.ts +43 -18
- package/queries/for_WebSocketHubConnection/when_unsubscribing/with_revision_support_not_advertised.ts +44 -0
|
@@ -5,39 +5,75 @@ import sinon from 'sinon';
|
|
|
5
5
|
import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connection';
|
|
6
6
|
import { given } from '../../../given';
|
|
7
7
|
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
8
|
-
import { ReconnectCallback } from '../../IReconnectPolicy';
|
|
9
|
-
|
|
10
|
-
describe(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
8
|
+
import type { ReconnectCallback } from '../../IReconnectPolicy';
|
|
9
|
+
|
|
10
|
+
describe(
|
|
11
|
+
'when reconnecting after a drop',
|
|
12
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
13
|
+
const queryId = 'q1';
|
|
14
|
+
let callbackStub: sinon.SinonStub;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
callbackStub = sinon.stub();
|
|
18
|
+
context.setup();
|
|
19
|
+
context.connection.subscribe(queryId, { queryName: 'MyQuery' }, callbackStub);
|
|
20
|
+
context.simulateOpen();
|
|
21
|
+
context.simulateMessage({
|
|
22
|
+
type: HubMessageType.Connected,
|
|
23
|
+
supportsSubscriptionRevisions: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Simulate drop and policy-driven reconnect
|
|
27
|
+
context.simulateClose();
|
|
28
|
+
const reconnectCallback = (
|
|
29
|
+
context.policy.schedule as sinon.SinonStub
|
|
30
|
+
).getCall(0).args[0] as ReconnectCallback;
|
|
31
|
+
context.fakeSocket.send.reset();
|
|
32
|
+
(context.policy.reset as sinon.SinonStub).reset();
|
|
33
|
+
reconnectCallback();
|
|
34
|
+
|
|
35
|
+
// The new socket opens in legacy mode, then upgrades when the new handshake arrives.
|
|
36
|
+
context.simulateOpen();
|
|
37
|
+
context.simulateMessage({
|
|
38
|
+
type: HubMessageType.Connected,
|
|
39
|
+
supportsSubscriptionRevisions: true,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterEach(() => sinon.restore());
|
|
44
|
+
|
|
45
|
+
it('should reset to a legacy subscription on the new socket', () => {
|
|
46
|
+
const msg = getSentMessage(0);
|
|
47
|
+
msg.type.should.equal(HubMessageType.Subscribe);
|
|
48
|
+
msg.queryId.should.equal(queryId);
|
|
49
|
+
(msg.revision === undefined).should.equal(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should upgrade the reconnect subscription after the new handshake', () => {
|
|
53
|
+
const msg = getSentMessage(1);
|
|
54
|
+
msg.type.should.equal(HubMessageType.Subscribe);
|
|
55
|
+
msg.queryId.should.equal(queryId);
|
|
56
|
+
(msg.revision ?? 0).should.be.greaterThan(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should reset the reconnect policy on successful open', () => {
|
|
60
|
+
(context.policy.reset as sinon.SinonStub).calledOnce.should.be.true;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
function getSentMessage(index: number): {
|
|
64
|
+
type: HubMessageType;
|
|
65
|
+
queryId: string;
|
|
66
|
+
revision?: number;
|
|
67
|
+
} {
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(context.fakeSocket.send.getCall(index).args[0]) as {
|
|
70
|
+
type: HubMessageType;
|
|
71
|
+
queryId: string;
|
|
72
|
+
revision?: number;
|
|
73
|
+
};
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new Error('Expected a valid hub message', { cause: error });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connection';
|
|
6
|
+
import { given } from '../../../given';
|
|
7
|
+
import { type HubMessage, HubMessageType } from '../../WebSocketHubConnection';
|
|
8
|
+
|
|
9
|
+
describe(
|
|
10
|
+
'when stale frames arrive after a WebSocket subscription is replaced',
|
|
11
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
12
|
+
const queryId = 'query-a';
|
|
13
|
+
let originalCallback: sinon.SinonStub;
|
|
14
|
+
let replacementCallback: sinon.SinonStub;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
context.setup();
|
|
18
|
+
sinon.stub(console, 'warn');
|
|
19
|
+
sinon.stub(console, 'error');
|
|
20
|
+
originalCallback = sinon.stub();
|
|
21
|
+
replacementCallback = sinon.stub();
|
|
22
|
+
|
|
23
|
+
context.connection.subscribe(
|
|
24
|
+
queryId,
|
|
25
|
+
{ queryName: 'Original' },
|
|
26
|
+
originalCallback,
|
|
27
|
+
);
|
|
28
|
+
context.simulateOpen();
|
|
29
|
+
context.simulateMessage({
|
|
30
|
+
type: HubMessageType.Connected,
|
|
31
|
+
supportsSubscriptionRevisions: true,
|
|
32
|
+
});
|
|
33
|
+
const originalRevision = sentMessage(1).revision!;
|
|
34
|
+
|
|
35
|
+
context.connection.subscribe(
|
|
36
|
+
queryId,
|
|
37
|
+
{ queryName: 'Replacement' },
|
|
38
|
+
replacementCallback,
|
|
39
|
+
);
|
|
40
|
+
const replacementRevision = sentMessage(2).revision!;
|
|
41
|
+
|
|
42
|
+
context.simulateMessage({
|
|
43
|
+
type: HubMessageType.QueryResult,
|
|
44
|
+
queryId,
|
|
45
|
+
revision: originalRevision,
|
|
46
|
+
payload: { data: ['stale'] },
|
|
47
|
+
});
|
|
48
|
+
context.simulateMessage({
|
|
49
|
+
type: HubMessageType.Unauthorized,
|
|
50
|
+
queryId,
|
|
51
|
+
revision: originalRevision,
|
|
52
|
+
});
|
|
53
|
+
context.simulateMessage({
|
|
54
|
+
type: HubMessageType.Error,
|
|
55
|
+
queryId,
|
|
56
|
+
revision: originalRevision,
|
|
57
|
+
payload: 'stale',
|
|
58
|
+
});
|
|
59
|
+
context.simulateMessage({
|
|
60
|
+
type: HubMessageType.QueryResult,
|
|
61
|
+
queryId,
|
|
62
|
+
revision: replacementRevision,
|
|
63
|
+
payload: { data: ['current'] },
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
afterEach(() => sinon.restore());
|
|
68
|
+
|
|
69
|
+
it('should not deliver the stale result', () =>
|
|
70
|
+
originalCallback.called.should.be.false);
|
|
71
|
+
it('should deliver the replacement result', () =>
|
|
72
|
+
replacementCallback.calledOnce.should.be.true);
|
|
73
|
+
it('should retain the replacement after stale unauthorized', () =>
|
|
74
|
+
context.connection.queryCount.should.equal(1));
|
|
75
|
+
it('should not log the stale error', () =>
|
|
76
|
+
(console.error as sinon.SinonStub).called.should.be.false);
|
|
77
|
+
|
|
78
|
+
function sentMessage(index: number): HubMessage {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(
|
|
81
|
+
context.fakeSocket.send.getCall(index).args[0],
|
|
82
|
+
) as HubMessage;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw new Error('Expected a valid hub message', { cause: error });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
@@ -6,37 +6,64 @@ import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connectio
|
|
|
6
6
|
import { given } from '../../../given';
|
|
7
7
|
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
8
8
|
|
|
9
|
-
describe(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
describe(
|
|
10
|
+
'when subscribing to a query',
|
|
11
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
12
|
+
const queryId = 'q1';
|
|
13
|
+
const request = { queryName: 'MyQuery', arguments: {} };
|
|
14
|
+
let callback: sinon.SinonStub;
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
callback = sinon.stub();
|
|
18
|
+
context.setup();
|
|
19
|
+
context.connection.subscribe(queryId, request, callback);
|
|
20
|
+
context.simulateOpen();
|
|
21
|
+
});
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
afterEach(() => sinon.restore());
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
it('should open a WebSocket', () =>
|
|
26
|
+
context.WebSocketStub.calledOnce.should.be.true);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
it('should send a legacy subscribe message once the socket opens', () => {
|
|
29
|
+
context.fakeSocket.send.calledOnce.should.equal(true);
|
|
30
|
+
const msg = getSentMessage();
|
|
31
|
+
msg.type.should.equal(HubMessageType.Subscribe);
|
|
32
|
+
msg.queryId.should.equal(queryId);
|
|
33
|
+
(msg.revision === undefined).should.equal(true);
|
|
34
|
+
});
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
function getSentMessage(): {
|
|
37
|
+
type: HubMessageType;
|
|
38
|
+
queryId: string;
|
|
39
|
+
revision?: number;
|
|
40
|
+
} {
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(context.fakeSocket.send.firstCall.args[0]) as {
|
|
43
|
+
type: HubMessageType;
|
|
44
|
+
queryId: string;
|
|
45
|
+
revision?: number;
|
|
46
|
+
};
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error('Expected a valid hub message', { cause: error });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
34
51
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
describe('when a query result message arrives', () => {
|
|
53
|
+
const result = { isSuccess: true, data: [1, 2, 3] };
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
context.simulateMessage({
|
|
57
|
+
type: HubMessageType.QueryResult,
|
|
58
|
+
queryId,
|
|
59
|
+
payload: result,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
38
62
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
it('should invoke the callback with the result', () =>
|
|
64
|
+
callback.calledOnce.should.be.true);
|
|
65
|
+
it('should pass the result payload', () =>
|
|
66
|
+
callback.getCall(0).args[0].should.deep.equal(result));
|
|
67
|
+
});
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { type HubMessage, HubMessageType } from '../../WebSocketHubConnection';
|
|
7
|
+
import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connection';
|
|
8
|
+
|
|
9
|
+
describe(
|
|
10
|
+
'when the WebSocket server advertises subscription revision support',
|
|
11
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
12
|
+
const queryId = 'query-1';
|
|
13
|
+
let callback: sinon.SinonStub;
|
|
14
|
+
let revision: number;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
context.setup();
|
|
18
|
+
callback = sinon.stub();
|
|
19
|
+
context.connection.subscribe(queryId, { queryName: 'MyQuery' }, callback);
|
|
20
|
+
context.simulateOpen();
|
|
21
|
+
|
|
22
|
+
context.simulateMessage({
|
|
23
|
+
type: HubMessageType.Connected,
|
|
24
|
+
supportsSubscriptionRevisions: true,
|
|
25
|
+
});
|
|
26
|
+
const upgradedRevision = sentMessage(1).revision;
|
|
27
|
+
if (upgradedRevision === undefined) {
|
|
28
|
+
throw new Error('Expected the upgraded subscription to carry a revision');
|
|
29
|
+
}
|
|
30
|
+
revision = upgradedRevision;
|
|
31
|
+
|
|
32
|
+
context.simulateMessage({
|
|
33
|
+
type: HubMessageType.QueryResult,
|
|
34
|
+
queryId,
|
|
35
|
+
payload: { data: ['legacy'] },
|
|
36
|
+
});
|
|
37
|
+
context.simulateMessage({
|
|
38
|
+
type: HubMessageType.QueryResult,
|
|
39
|
+
queryId,
|
|
40
|
+
revision,
|
|
41
|
+
payload: { data: ['current'] },
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => sinon.restore());
|
|
46
|
+
|
|
47
|
+
it('should initially subscribe without a revision for older servers', () =>
|
|
48
|
+
(sentMessage(0).revision === undefined).should.equal(true));
|
|
49
|
+
|
|
50
|
+
it('should replace the legacy subscription with its current revision', () => {
|
|
51
|
+
const message = sentMessage(1);
|
|
52
|
+
message.type.should.equal(HubMessageType.Subscribe);
|
|
53
|
+
(message.queryId === queryId).should.equal(true);
|
|
54
|
+
revision.should.be.greaterThan(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should ignore the temporary legacy result and deliver the strict result once', () => {
|
|
58
|
+
callback.calledOnce.should.equal(true);
|
|
59
|
+
callback.firstCall.args[0].should.deep.equal({ data: ['current'] });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function sentMessage(index: number): HubMessage {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(
|
|
65
|
+
context.fakeSocket.send.getCall(index).args[0],
|
|
66
|
+
) as HubMessage;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
throw new Error('Expected a valid hub message', { cause: error });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
@@ -6,25 +6,50 @@ import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connectio
|
|
|
6
6
|
import { given } from '../../../given';
|
|
7
7
|
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
8
8
|
|
|
9
|
-
describe(
|
|
10
|
-
|
|
9
|
+
describe(
|
|
10
|
+
'when unsubscribing the only query',
|
|
11
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
12
|
+
const queryId = 'q1';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
context.setup();
|
|
16
|
+
context.connection.subscribe(queryId, { queryName: 'MyQuery' }, sinon.stub());
|
|
17
|
+
context.simulateOpen();
|
|
18
|
+
context.simulateMessage({
|
|
19
|
+
type: HubMessageType.Connected,
|
|
20
|
+
supportsSubscriptionRevisions: true,
|
|
21
|
+
});
|
|
22
|
+
context.fakeSocket.send.reset();
|
|
23
|
+
context.connection.unsubscribe(queryId);
|
|
24
|
+
});
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
afterEach(() => sinon.restore());
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
it('should send an unsubscribe message', () => {
|
|
29
|
+
context.fakeSocket.send.calledOnce.should.equal(true);
|
|
30
|
+
const msg = getUnsubscribeMessage();
|
|
31
|
+
msg.type.should.equal(HubMessageType.Unsubscribe);
|
|
32
|
+
msg.queryId.should.equal(queryId);
|
|
33
|
+
msg.revision.should.equal(1);
|
|
34
|
+
});
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
it('should close the underlying socket', () =>
|
|
37
|
+
context.fakeSocket.close.calledOnce.should.be.true);
|
|
38
|
+
|
|
39
|
+
function getUnsubscribeMessage(): {
|
|
40
|
+
type: HubMessageType;
|
|
41
|
+
queryId: string;
|
|
42
|
+
revision: number;
|
|
43
|
+
} {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(context.fakeSocket.send.firstCall.args[0]) as {
|
|
46
|
+
type: HubMessageType;
|
|
47
|
+
queryId: string;
|
|
48
|
+
revision: number;
|
|
49
|
+
};
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error('Expected a valid unsubscribe message', { cause: error });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { type HubMessage, HubMessageType } from '../../WebSocketHubConnection';
|
|
7
|
+
import { a_web_socket_hub_connection } from '../given/a_web_socket_hub_connection';
|
|
8
|
+
|
|
9
|
+
describe(
|
|
10
|
+
'when unsubscribing before the WebSocket server advertises revision support',
|
|
11
|
+
given(a_web_socket_hub_connection, (context) => {
|
|
12
|
+
const queryId = 'query-1';
|
|
13
|
+
let message: HubMessage;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
context.setup();
|
|
17
|
+
context.connection.subscribe(queryId, { queryName: 'MyQuery' }, sinon.stub());
|
|
18
|
+
context.simulateOpen();
|
|
19
|
+
context.fakeSocket.send.resetHistory();
|
|
20
|
+
context.connection.unsubscribe(queryId);
|
|
21
|
+
message = sentMessage();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => sinon.restore());
|
|
25
|
+
|
|
26
|
+
it('should send a legacy unsubscribe', () => {
|
|
27
|
+
message.type.should.equal(HubMessageType.Unsubscribe);
|
|
28
|
+
(message.queryId === queryId).should.equal(true);
|
|
29
|
+
(message.revision === undefined).should.equal(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function sentMessage(): HubMessage {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(
|
|
35
|
+
context.fakeSocket.send.firstCall.args[0],
|
|
36
|
+
) as HubMessage;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error('Expected a valid unsubscribe message', {
|
|
39
|
+
cause: error,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
);
|