@cratis/arc 22.0.1 → 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 +9 -4
- 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 +6 -6
- package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js +9 -4
- 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/given/TestQueries.d.ts +17 -0
- package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.d.ts.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.js +34 -0
- package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.d.ts +2 -1
- package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.d.ts.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.js +3 -1
- package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.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_receiving_a_result/and_the_model_has_a_calendar_collection.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.js +52 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.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 +54 -26
- 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/given/TestQueries.ts +30 -1
- package/queries/for_ObservableQueryFor/given/an_observable_query_for.ts +3 -0
- package/queries/for_ObservableQueryFor/when_performing/with_a_not_ready_result.ts +46 -0
- package/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.ts +76 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a_server_sent_event_hub_connection.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAKlF,MAAM,OAAO,kCAAkC;IAC3C,UAAU,CAAgC;IAC1C,eAAe,CAMb;IACF,MAAM,CAAgD;IACtD,SAAS,CAAmB;IAE5B;QACI,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAOD,KAAK;QACD,IAAI,CAAC,eAAe,GAAG;YACnB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;YACnB,UAAU,EAAE,CAAC;SAChB,CAAC;QAGF,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,MAAM,oBAAoB,GAAG;YACzB,MAAM,
|
|
1
|
+
{"version":3,"file":"a_server_sent_event_hub_connection.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAKlF,MAAM,OAAO,kCAAkC;IAC3C,UAAU,CAAgC;IAC1C,eAAe,CAMb;IACF,YAAY,CAAsC;IAClD,MAAM,CAAgD;IACtD,SAAS,CAAmB;IAE5B;QACI,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AI,EAAE;YACnB,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE;SACvB,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,IAAI,4BAA4B,CAC9C,sCAAsC,EACtC,gDAAgD,EAChD,kDAAkD,EAClD,EAAE,EACF,SAAS,EACT,SAAS,EACT,IAAI,CAAC,MAAM,CACd,CAAC;IACN,CAAC;IAED,YAAY;QACR,IAAI,CAAC,eAAe,CAAC,UAAU,GAAG,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;IACpC,CAAC;IAED,eAAe,CAAC,OAAgC;QAC5C,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAChB,CAAC,CAAC;IACvB,CAAC;IAED,aAAa;QACT,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IACrC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignores_connected_and_error_callbacks.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
3
|
+
import { given } from '../../../given';
|
|
4
|
+
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
5
|
+
describe('when a retired EventSource fires connected and error callbacks', given(a_server_sent_event_hub_connection, (context) => {
|
|
6
|
+
let staleMessage;
|
|
7
|
+
let staleError;
|
|
8
|
+
let currentSource;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
context.setup();
|
|
11
|
+
sinon.stub(console, 'warn');
|
|
12
|
+
context.connection.subscribe('q1', { queryName: 'MyQuery' }, sinon.stub());
|
|
13
|
+
context.simulateOpen();
|
|
14
|
+
context.simulateMessage({
|
|
15
|
+
type: HubMessageType.Connected,
|
|
16
|
+
payload: 'connection-a',
|
|
17
|
+
});
|
|
18
|
+
const retiredSource = context.eventSources[0];
|
|
19
|
+
staleMessage = retiredSource.onmessage;
|
|
20
|
+
staleError = retiredSource.onerror;
|
|
21
|
+
staleError();
|
|
22
|
+
const reconnect = context.policy.schedule.firstCall
|
|
23
|
+
.args[0];
|
|
24
|
+
reconnect();
|
|
25
|
+
currentSource = context.eventSources[1];
|
|
26
|
+
context.simulateOpen();
|
|
27
|
+
context.simulateMessage({
|
|
28
|
+
type: HubMessageType.Connected,
|
|
29
|
+
payload: 'connection-b',
|
|
30
|
+
});
|
|
31
|
+
staleMessage({
|
|
32
|
+
data: JSON.stringify({
|
|
33
|
+
type: HubMessageType.Connected,
|
|
34
|
+
payload: 'stale-connection',
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
staleError();
|
|
38
|
+
});
|
|
39
|
+
afterEach(() => sinon.restore());
|
|
40
|
+
it('should not send another subscription for stale connected', () => context.fetchStub.callCount.should.equal(2));
|
|
41
|
+
it('should keep the current EventSource open', () => currentSource.close.called.should.be.false);
|
|
42
|
+
it('should not schedule another reconnect for stale error', () => context.policy.schedule.calledOnce.should.be.true);
|
|
43
|
+
}));
|
|
44
|
+
//# sourceMappingURL=ignores_connected_and_error_callbacks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignores_connected_and_error_callbacks.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_a_retired_event_source_fires/ignores_connected_and_error_callbacks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,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AE,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjC,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE,CAChE,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE,CAChD,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAChD,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE,CAC5D,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_query_is_replaced.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_deferred_promise } from '../given/a_deferred_promise';
|
|
3
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
4
|
+
import { given } from '../../../given';
|
|
5
|
+
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
6
|
+
describe('when a query is replaced while its subscribe request is in flight and the connection changes', given(a_server_sent_event_hub_connection, (context) => {
|
|
7
|
+
const queryId = 'q1';
|
|
8
|
+
const replacementRequest = { queryName: 'ReplacementQuery' };
|
|
9
|
+
let clock;
|
|
10
|
+
let originalCallback;
|
|
11
|
+
let replacementCallback;
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
context.setup();
|
|
14
|
+
clock = sinon.useFakeTimers({ toFake: ['setTimeout'] });
|
|
15
|
+
sinon.stub(console, 'warn');
|
|
16
|
+
const firstSubscribe = new a_deferred_promise();
|
|
17
|
+
context.fetchStub.onFirstCall().returns(firstSubscribe.promise);
|
|
18
|
+
originalCallback = sinon.stub();
|
|
19
|
+
replacementCallback = sinon.stub();
|
|
20
|
+
context.connection.subscribe(queryId, { queryName: 'OriginalQuery' }, originalCallback);
|
|
21
|
+
context.simulateOpen();
|
|
22
|
+
context.simulateMessage({
|
|
23
|
+
type: HubMessageType.Connected,
|
|
24
|
+
payload: 'connection-a',
|
|
25
|
+
supportsSubscriptionRevisions: true,
|
|
26
|
+
});
|
|
27
|
+
context.connection.subscribe(queryId, replacementRequest, replacementCallback);
|
|
28
|
+
context.simulateMessage({
|
|
29
|
+
type: HubMessageType.Connected,
|
|
30
|
+
payload: 'connection-b',
|
|
31
|
+
supportsSubscriptionRevisions: true,
|
|
32
|
+
});
|
|
33
|
+
firstSubscribe.resolve({ ok: false, status: 404 });
|
|
34
|
+
await Promise.resolve();
|
|
35
|
+
clock.tick(1000);
|
|
36
|
+
await Promise.resolve();
|
|
37
|
+
context.simulateMessage({
|
|
38
|
+
type: HubMessageType.QueryResult,
|
|
39
|
+
queryId,
|
|
40
|
+
revision: getSubscribeBody(2).revision,
|
|
41
|
+
payload: { isSuccess: true },
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
clock.restore();
|
|
46
|
+
sinon.restore();
|
|
47
|
+
});
|
|
48
|
+
it('should send only the replacement on connection B', () => {
|
|
49
|
+
const body = getSubscribeBody(2);
|
|
50
|
+
body.connectionId.should.equal('connection-b');
|
|
51
|
+
body.queryId.should.equal(queryId);
|
|
52
|
+
body.request.should.deep.equal(replacementRequest);
|
|
53
|
+
body.revision.should.be.greaterThan(0);
|
|
54
|
+
});
|
|
55
|
+
it('should not retry the obsolete subscription', () => context.fetchStub.callCount.should.equal(3));
|
|
56
|
+
it('should notify only the replacement callback', () => {
|
|
57
|
+
originalCallback.called.should.equal(false);
|
|
58
|
+
replacementCallback.calledOnce.should.equal(true);
|
|
59
|
+
});
|
|
60
|
+
it('should not reconnect', () => context.policy.schedule.called.should.be.false);
|
|
61
|
+
it('should retain one active subscription', () => context.connection.queryCount.should.equal(1));
|
|
62
|
+
function getSubscribeBody(callIndex) {
|
|
63
|
+
const rawBody = context.fetchStub.getCall(callIndex).args[1].body;
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(rawBody);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw new Error('Expected a valid subscribe request body', {
|
|
69
|
+
cause: error,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
//# sourceMappingURL=and_the_query_is_replaced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_query_is_replaced.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_replaced.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,CACJ,8FAA8F,EAC9F,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC;IACrB,MAAM,kBAAkB,GAAG,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAC7D,IAAI,KAA4B,CAAC;IACjC,IAAI,gBAAiC,CAAC;IACtC,IAAI,mBAAoC,CAAC;IAEzC,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,KAAK,EAAE,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,GAAG,EAAE,CAC7C,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnD,SAAS,gBAAgB,CAAC,SAAiB;QAMvC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC;QAC5E,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAKxB,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,EAAE;gBACvD,KAAK,EAAE,KAAK;aACf,CAAC,CAAC;QACP,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_query_is_unsubscribed.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_deferred_promise } from '../given/a_deferred_promise';
|
|
3
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
4
|
+
import { given } from '../../../given';
|
|
5
|
+
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
6
|
+
const subscribeUrl = 'http://localhost/.cratis/queries/sse/subscribe';
|
|
7
|
+
describe('when a query is unsubscribed while its subscribe request is in flight and the connection changes', given(a_server_sent_event_hub_connection, (context) => {
|
|
8
|
+
let clock;
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
context.setup();
|
|
11
|
+
clock = sinon.useFakeTimers({ toFake: ['setTimeout'] });
|
|
12
|
+
sinon.stub(console, 'warn');
|
|
13
|
+
const firstSubscribe = new a_deferred_promise();
|
|
14
|
+
context.fetchStub.onFirstCall().returns(firstSubscribe.promise);
|
|
15
|
+
context.connection.subscribe('removed-query', { queryName: 'RemovedQuery' }, sinon.stub());
|
|
16
|
+
context.simulateOpen();
|
|
17
|
+
context.simulateMessage({
|
|
18
|
+
type: HubMessageType.Connected,
|
|
19
|
+
payload: 'connection-a',
|
|
20
|
+
supportsSubscriptionRevisions: true,
|
|
21
|
+
});
|
|
22
|
+
context.connection.subscribe('active-query', { queryName: 'ActiveQuery' }, sinon.stub());
|
|
23
|
+
context.connection.unsubscribe('removed-query');
|
|
24
|
+
context.simulateMessage({
|
|
25
|
+
type: HubMessageType.Connected,
|
|
26
|
+
payload: 'connection-b',
|
|
27
|
+
supportsSubscriptionRevisions: true,
|
|
28
|
+
});
|
|
29
|
+
firstSubscribe.resolve({ ok: false, status: 404 });
|
|
30
|
+
await Promise.resolve();
|
|
31
|
+
clock.tick(1000);
|
|
32
|
+
await Promise.resolve();
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
clock.restore();
|
|
36
|
+
sinon.restore();
|
|
37
|
+
});
|
|
38
|
+
it('should not subscribe the removed query on connection B', () => {
|
|
39
|
+
const removedQueryCalls = context.fetchStub
|
|
40
|
+
.getCalls()
|
|
41
|
+
.filter((call) => call.args[0] === subscribeUrl)
|
|
42
|
+
.filter((call) => call.args[1].body.includes('"queryId":"removed-query"'));
|
|
43
|
+
removedQueryCalls.length.should.equal(1);
|
|
44
|
+
const body = parseBody(removedQueryCalls[0].args[1].body);
|
|
45
|
+
body.connectionId.should.equal('connection-a');
|
|
46
|
+
body.queryId.should.equal('removed-query');
|
|
47
|
+
body.request.should.deep.equal({ queryName: 'RemovedQuery' });
|
|
48
|
+
body.revision.should.be.greaterThan(0);
|
|
49
|
+
});
|
|
50
|
+
it('should subscribe the remaining query on connection B', () => {
|
|
51
|
+
const activeQueryBodies = context.fetchStub
|
|
52
|
+
.getCalls()
|
|
53
|
+
.filter((call) => call.args[0] === subscribeUrl)
|
|
54
|
+
.map((call) => parseBody(call.args[1].body))
|
|
55
|
+
.filter((body) => body.queryId === 'active-query');
|
|
56
|
+
activeQueryBodies
|
|
57
|
+
.map((body) => body.connectionId)
|
|
58
|
+
.should.deep.equal(['connection-a', 'connection-b']);
|
|
59
|
+
activeQueryBodies[0].revision.should.equal(activeQueryBodies[1].revision);
|
|
60
|
+
});
|
|
61
|
+
it('should not reconnect', () => context.policy.schedule.called.should.be.false);
|
|
62
|
+
it('should retain only the remaining subscription', () => context.connection.queryCount.should.equal(1));
|
|
63
|
+
function parseBody(rawBody) {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(rawBody);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw new Error('Expected a valid subscribe request body', {
|
|
69
|
+
cause: error,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
//# sourceMappingURL=and_the_query_is_unsubscribed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_query_is_unsubscribed.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_query_is_unsubscribed.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,YAAY,GAAG,gDAAgD,CAAC;AAEtE,QAAQ,CACJ,kGAAkG,EAClG,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,IAAI,KAA4B,CAAC;IAEjC,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,KAAK,EAA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E,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC,CAAC;aACrD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,cAAc,CAAC,CAAC;QACvD,iBAAiB;aACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;aAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QACzD,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAC3B,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAEzE,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE,CACrD,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnD,SAAS,SAAS,CAAC,OAAe;QAM9B,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,EAAE;gBACvD,KAAK,EAAE,KAAK;aACf,CAAC,CAAC;QACP,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_stale_request_is_rejected.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_deferred_promise } from '../given/a_deferred_promise';
|
|
3
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
4
|
+
import { given } from '../../../given';
|
|
5
|
+
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
6
|
+
describe('when the connection changes while a subscribe request is in flight and the stale request is rejected', given(a_server_sent_event_hub_connection, (context) => {
|
|
7
|
+
const queryId = 'q1';
|
|
8
|
+
const request = { queryName: 'MyQuery' };
|
|
9
|
+
let clock;
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
context.setup();
|
|
12
|
+
clock = sinon.useFakeTimers({ toFake: ['setTimeout'] });
|
|
13
|
+
sinon.stub(console, 'warn');
|
|
14
|
+
const firstSubscribe = new a_deferred_promise();
|
|
15
|
+
context.fetchStub.onFirstCall().returns(firstSubscribe.promise);
|
|
16
|
+
context.connection.subscribe(queryId, request, sinon.stub());
|
|
17
|
+
context.simulateOpen();
|
|
18
|
+
context.simulateMessage({
|
|
19
|
+
type: HubMessageType.Connected,
|
|
20
|
+
payload: 'connection-a',
|
|
21
|
+
supportsSubscriptionRevisions: true,
|
|
22
|
+
});
|
|
23
|
+
context.simulateMessage({
|
|
24
|
+
type: HubMessageType.Connected,
|
|
25
|
+
payload: 'connection-b',
|
|
26
|
+
supportsSubscriptionRevisions: true,
|
|
27
|
+
});
|
|
28
|
+
firstSubscribe.reject(new Error('Connection A failed'));
|
|
29
|
+
await Promise.resolve();
|
|
30
|
+
await Promise.resolve();
|
|
31
|
+
clock.tick(1000);
|
|
32
|
+
await Promise.resolve();
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
clock.restore();
|
|
36
|
+
sinon.restore();
|
|
37
|
+
});
|
|
38
|
+
it('should send the active subscription on connection B', () => {
|
|
39
|
+
const body = parseBody(context.fetchStub.getCall(1).args[1].body);
|
|
40
|
+
body.connectionId.should.equal('connection-b');
|
|
41
|
+
body.queryId.should.equal(queryId);
|
|
42
|
+
body.request.should.deep.equal(request);
|
|
43
|
+
body.revision.should.be.greaterThan(0);
|
|
44
|
+
});
|
|
45
|
+
it('should not retry the obsolete connection A request', () => context.fetchStub.callCount.should.equal(2));
|
|
46
|
+
it('should not reconnect', () => context.policy.schedule.called.should.be.false);
|
|
47
|
+
it('should retain the active subscription', () => context.connection.queryCount.should.equal(1));
|
|
48
|
+
function parseBody(rawBody) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(rawBody);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error('Expected a valid subscribe request body', {
|
|
54
|
+
cause: error,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
//# sourceMappingURL=and_the_stale_request_is_rejected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_stale_request_is_rejected.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_is_rejected.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,CACJ,sGAAsG,EACtG,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC;IACrB,MAAM,OAAO,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IACzC,IAAI,KAA4B,CAAC;IAEjC,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAA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erSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_deferred_promise } from '../given/a_deferred_promise';
|
|
3
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
4
|
+
import { given } from '../../../given';
|
|
5
|
+
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
6
|
+
describe('when the connection changes while a subscribe request is in flight and the stale request returns non-OK', given(a_server_sent_event_hub_connection, (context) => {
|
|
7
|
+
const queryId = 'q1';
|
|
8
|
+
const request = { queryName: 'MyQuery' };
|
|
9
|
+
let clock;
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
context.setup();
|
|
12
|
+
clock = sinon.useFakeTimers({ toFake: ['setTimeout'] });
|
|
13
|
+
sinon.stub(console, 'warn');
|
|
14
|
+
const firstSubscribe = new a_deferred_promise();
|
|
15
|
+
context.fetchStub.onFirstCall().returns(firstSubscribe.promise);
|
|
16
|
+
context.connection.subscribe(queryId, request, sinon.stub());
|
|
17
|
+
context.simulateOpen();
|
|
18
|
+
context.simulateMessage({
|
|
19
|
+
type: HubMessageType.Connected,
|
|
20
|
+
payload: 'connection-a',
|
|
21
|
+
supportsSubscriptionRevisions: true,
|
|
22
|
+
});
|
|
23
|
+
context.simulateMessage({
|
|
24
|
+
type: HubMessageType.Connected,
|
|
25
|
+
payload: 'connection-b',
|
|
26
|
+
supportsSubscriptionRevisions: true,
|
|
27
|
+
});
|
|
28
|
+
firstSubscribe.resolve({ ok: false, status: 404 });
|
|
29
|
+
await Promise.resolve();
|
|
30
|
+
clock.tick(1000);
|
|
31
|
+
await Promise.resolve();
|
|
32
|
+
});
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
clock.restore();
|
|
35
|
+
sinon.restore();
|
|
36
|
+
});
|
|
37
|
+
it('should send the active subscription on connection B', () => {
|
|
38
|
+
const body = parseBody(context.fetchStub.getCall(1).args[1].body);
|
|
39
|
+
body.connectionId.should.equal('connection-b');
|
|
40
|
+
body.queryId.should.equal(queryId);
|
|
41
|
+
body.request.should.deep.equal(request);
|
|
42
|
+
body.revision.should.be.greaterThan(0);
|
|
43
|
+
});
|
|
44
|
+
it('should not retry the obsolete connection A request', () => context.fetchStub.callCount.should.equal(2));
|
|
45
|
+
it('should not reconnect', () => context.policy.schedule.called.should.be.false);
|
|
46
|
+
it('should retain the active subscription', () => context.connection.queryCount.should.equal(1));
|
|
47
|
+
function parseBody(rawBody) {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(rawBody);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error('Expected a valid subscribe request body', {
|
|
53
|
+
cause: error,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
//# sourceMappingURL=and_the_stale_request_returns_non_ok.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_the_stale_request_returns_non_ok.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_connection_changes_while_subscribe_is_in_flight/and_the_stale_request_returns_non_ok.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,CACJ,yGAAyG,EACzG,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC;IACrB,MAAM,OAAO,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IACzC,IAAI,KAA4B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 -2,17 +2,20 @@ import sinon from 'sinon';
|
|
|
2
2
|
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
3
3
|
import { given } from '../../../given';
|
|
4
4
|
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
5
|
-
describe('when disposing the hub connection', given(a_server_sent_event_hub_connection, context => {
|
|
5
|
+
describe('when disposing the hub connection', given(a_server_sent_event_hub_connection, (context) => {
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
context.setup();
|
|
8
8
|
context.connection.subscribe('q1', { queryName: 'MyQuery' }, sinon.stub());
|
|
9
9
|
context.simulateOpen();
|
|
10
|
-
context.simulateMessage({
|
|
10
|
+
context.simulateMessage({
|
|
11
|
+
type: HubMessageType.Connected,
|
|
12
|
+
payload: 'conn-1',
|
|
13
|
+
});
|
|
11
14
|
context.connection.dispose();
|
|
12
15
|
});
|
|
13
16
|
afterEach(() => sinon.restore());
|
|
14
17
|
it('should close the EventSource', () => context.fakeEventSource.close.calledOnce.should.be.true);
|
|
15
|
-
it('should cancel the reconnect policy', () => context.policy.cancel.
|
|
18
|
+
it('should cancel the reconnect policy', () => context.policy.cancel.called.should.equal(true));
|
|
16
19
|
it('should report zero active subscriptions', () => context.connection.queryCount.should.equal(0));
|
|
17
20
|
describe('when an error event fires after dispose', () => {
|
|
18
21
|
beforeEach(() => {
|
package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleans_up_resources.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,
|
|
1
|
+
{"version":3,"file":"cleans_up_resources.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,QAAQ,CACJ,mCAAmC,EACnC,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,OAAO,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,CAAC,eAAe,CAAC;YACpB,IAAI,EAAE,cAAc,CAAC,SAAS;YAC9B,OAAO,EAAE,QAAQ;SACpB,CAAC,CAAC;QACH,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE,CACpC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7D,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE,CACzC,OAAO,CAAC,MAAM,CAAC,MAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAC/C,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnD,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACrD,UAAU,CAAC,GAAG,EAAE;YACX,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,KAAK,EAAE,CAAC;YACrD,OAAO,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACtC,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -2,7 +2,7 @@ import sinon from 'sinon';
|
|
|
2
2
|
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
3
3
|
import { given } from '../../../given';
|
|
4
4
|
import { HubMessageType } from '../../WebSocketHubConnection';
|
|
5
|
-
describe('when receiving unauthorized for a subscribed query', given(a_server_sent_event_hub_connection, context => {
|
|
5
|
+
describe('when receiving unauthorized for a subscribed query', given(a_server_sent_event_hub_connection, (context) => {
|
|
6
6
|
let callback;
|
|
7
7
|
let receivedResult;
|
|
8
8
|
const queryId = 'q-auth-1';
|
|
@@ -12,21 +12,38 @@ describe('when receiving unauthorized for a subscribed query', given(a_server_se
|
|
|
12
12
|
callback = sinon.stub();
|
|
13
13
|
context.connection.subscribe(queryId, { queryName: 'SecureQuery' }, callback);
|
|
14
14
|
context.simulateOpen();
|
|
15
|
-
context.simulateMessage({
|
|
16
|
-
|
|
15
|
+
context.simulateMessage({
|
|
16
|
+
type: HubMessageType.Connected,
|
|
17
|
+
payload: connectionId,
|
|
18
|
+
supportsSubscriptionRevisions: true,
|
|
19
|
+
});
|
|
20
|
+
const body = getSubscribeBody();
|
|
21
|
+
context.simulateMessage({
|
|
22
|
+
type: HubMessageType.Unauthorized,
|
|
23
|
+
queryId,
|
|
24
|
+
revision: body.revision,
|
|
25
|
+
});
|
|
17
26
|
receivedResult = callback.firstCall?.args[0];
|
|
18
27
|
});
|
|
19
28
|
afterEach(() => {
|
|
20
29
|
sinon.restore();
|
|
21
30
|
});
|
|
31
|
+
function getSubscribeBody() {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(context.fetchStub.firstCall.args[1].body);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new Error('Expected a valid subscribe body', { cause: error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
22
39
|
it('should invoke the subscriber callback', () => {
|
|
23
|
-
callback.calledOnce.should.
|
|
40
|
+
callback.calledOnce.should.equal(true);
|
|
24
41
|
});
|
|
25
42
|
it('should report isAuthorized as false', () => {
|
|
26
|
-
receivedResult.isAuthorized.should.
|
|
43
|
+
receivedResult.isAuthorized.should.equal(false);
|
|
27
44
|
});
|
|
28
45
|
it('should report isSuccess as false', () => {
|
|
29
|
-
receivedResult.isSuccess.should.
|
|
46
|
+
receivedResult.isSuccess.should.equal(false);
|
|
30
47
|
});
|
|
31
48
|
it('should remove the subscription', () => {
|
|
32
49
|
context.connection.queryCount.should.equal(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifies_subscriber_and_removes_subscription.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,QAAQ,
|
|
1
|
+
{"version":3,"file":"notifies_subscriber_and_removes_subscription.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_receiving_unauthorized/notifies_subscriber_and_removes_subscription.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,QAAQ,CACJ,oDAAoD,EACpD,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;IAClD,IAAI,QAAyB,CAAC;IAC9B,IAAI,cAAgD,CAAC;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC;IAC3B,MAAM,YAAY,GAAG,UAAU,CAAC;IAEhC,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAExB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC9E,OAAO,CAAC,YAAY,EAAE,CAAC;QAGvB,OAAO,CAAC,eAAe,CAAC;YACpB,IAAI,EAAE,cAAc,CAAC,SAAS;YAC9B,OAAO,EAAE,YAAY;YACrB,6BAA6B,EAAE,IAAI;SACtC,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAC;QAGhC,OAAO,CAAC,eAAe,CAAC;YACpB,IAAI,EAAE,cAAc,CAAC,YAAY;YACjC,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;SAC1B,CAAC,CAAC;QAEH,cAAc,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAE5B,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,SAAS,gBAAgB;QACrB,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAc,CAEnE,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,CAAC;IACL,CAAC;IAED,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,cAAe,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QACxC,cAAe,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -8,7 +8,11 @@ describe('when connection errors', given(a_server_sent_event_hub_connection, con
|
|
|
8
8
|
context.setup();
|
|
9
9
|
context.connection.subscribe(queryId, { queryName: 'MyQuery' }, sinon.stub());
|
|
10
10
|
context.simulateOpen();
|
|
11
|
-
context.simulateMessage({
|
|
11
|
+
context.simulateMessage({
|
|
12
|
+
type: HubMessageType.Connected,
|
|
13
|
+
payload: 'conn-1',
|
|
14
|
+
supportsSubscriptionRevisions: true,
|
|
15
|
+
});
|
|
12
16
|
context.simulateError();
|
|
13
17
|
});
|
|
14
18
|
afterEach(() => sinon.restore());
|
|
@@ -24,9 +28,7 @@ describe('when connection errors', given(a_server_sent_event_hub_connection, con
|
|
|
24
28
|
newEventSourceCreated = true;
|
|
25
29
|
return context.fakeEventSource;
|
|
26
30
|
};
|
|
27
|
-
FakeClass
|
|
28
|
-
FakeClass['OPEN'] = 1;
|
|
29
|
-
FakeClass['CLOSED'] = 2;
|
|
31
|
+
Object.assign(FakeClass, { CONNECTING: 0, OPEN: 1, CLOSED: 2 });
|
|
30
32
|
globalThis['EventSource'] = FakeClass;
|
|
31
33
|
const reconnectCallback = context.policy.schedule.getCall(0).args[0];
|
|
32
34
|
reconnectCallback();
|
|
@@ -40,7 +42,20 @@ describe('when connection errors', given(a_server_sent_event_hub_connection, con
|
|
|
40
42
|
context.fetchStub.resetHistory();
|
|
41
43
|
context.simulateMessage({ type: HubMessageType.Connected, payload: 'conn-2' });
|
|
42
44
|
});
|
|
43
|
-
it('should re-subscribe all active queries', () => context.fetchStub.calledOnce.should.
|
|
45
|
+
it('should re-subscribe all active queries', () => context.fetchStub.calledOnce.should.equal(true));
|
|
46
|
+
it('should reset to legacy mode until the new connection advertises capabilities', () => {
|
|
47
|
+
const rawBody = context.fetchStub.firstCall.args[1].body;
|
|
48
|
+
let body;
|
|
49
|
+
try {
|
|
50
|
+
body = JSON.parse(rawBody);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error('Expected a valid subscribe request body', {
|
|
54
|
+
cause: error,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
(body.revision === undefined).should.equal(true);
|
|
58
|
+
});
|
|
44
59
|
});
|
|
45
60
|
}));
|
|
46
61
|
//# sourceMappingURL=after_error.js.map
|
package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"after_error.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,QAAQ,CAAC,wBAAwB,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IACnF,MAAM,OAAO,GAAG,IAAI,CAAC;IAErB,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9E,OAAO,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"after_error.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,QAAQ,CAAC,wBAAwB,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IACnF,MAAM,OAAO,GAAG,IAAI,CAAC;IAErB,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,IAAI,EAA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AAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_an_immediate_open_wins_the_backoff_race.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { a_server_sent_event_hub_connection } from '../given/a_server_sent_event_hub_connection';
|
|
3
|
+
import { given } from '../../../given';
|
|
4
|
+
describe('when an immediate SSE open wins a pending backoff race', given(a_server_sent_event_hub_connection, (context) => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
context.setup();
|
|
7
|
+
sinon.stub(console, 'warn');
|
|
8
|
+
context.connection.subscribe('query-a', { queryName: 'QueryA' }, sinon.stub());
|
|
9
|
+
context.simulateError();
|
|
10
|
+
const delayedReconnect = context.policy.schedule.firstCall
|
|
11
|
+
.args[0];
|
|
12
|
+
context.connection.subscribe('query-b', { queryName: 'QueryB' }, sinon.stub());
|
|
13
|
+
delayedReconnect();
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => sinon.restore());
|
|
16
|
+
it('should create only the retired and immediate event sources', () => context.eventSources.length.should.equal(2));
|
|
17
|
+
it('should cancel the pending backoff when the immediate open wins', () => context.policy.cancel.called.should.equal(true));
|
|
18
|
+
it('should leave the immediate source connecting', () => context.eventSources[1].readyState.should.equal(EventSource.CONNECTING));
|
|
19
|
+
}));
|
|
20
|
+
//# sourceMappingURL=and_an_immediate_open_wins_the_backoff_race.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_an_immediate_open_wins_the_backoff_race.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_reconnecting/and_an_immediate_open_wins_the_backoff_race.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kCAAkC,EAAE,M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CAAC,CAAC;AACjF,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignores_messages_from_the_retired_generation.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_replacing_a_subscription/ignores_messages_from_the_retired_generation.ts"],"names":[],"mappings":""}
|