@cratis/arc 20.60.0 → 20.60.2

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.
Files changed (140) hide show
  1. package/dist/cjs/queries/HubConnectionKeepAlive.js +24 -4
  2. package/dist/cjs/queries/HubConnectionKeepAlive.js.map +1 -1
  3. package/dist/cjs/queries/NullObservableQueryConnection.js +7 -2
  4. package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -1
  5. package/dist/cjs/queries/ObservableQueryFor.js +11 -1
  6. package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
  7. package/dist/cjs/queries/QueryFor.js +1 -21
  8. package/dist/cjs/queries/QueryFor.js.map +1 -1
  9. package/dist/cjs/queries/QueryInstanceCache.js +35 -12
  10. package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
  11. package/dist/cjs/queries/QueryResult.js +30 -0
  12. package/dist/cjs/queries/QueryResult.js.map +1 -1
  13. package/dist/cjs/queries/ServerSentEventHubConnection.js +38 -10
  14. package/dist/cjs/queries/ServerSentEventHubConnection.js.map +1 -1
  15. package/dist/cjs/queries/WebSocketHubConnection.js.map +1 -1
  16. package/dist/cjs/queries/index.js +2 -0
  17. package/dist/cjs/queries/index.js.map +1 -1
  18. package/dist/cjs/queries/reconcileQueryData.js +84 -0
  19. package/dist/cjs/queries/reconcileQueryData.js.map +1 -0
  20. package/dist/esm/queries/HubConnectionKeepAlive.d.ts +5 -3
  21. package/dist/esm/queries/HubConnectionKeepAlive.d.ts.map +1 -1
  22. package/dist/esm/queries/HubConnectionKeepAlive.js +24 -4
  23. package/dist/esm/queries/HubConnectionKeepAlive.js.map +1 -1
  24. package/dist/esm/queries/NullObservableQueryConnection.d.ts +3 -1
  25. package/dist/esm/queries/NullObservableQueryConnection.d.ts.map +1 -1
  26. package/dist/esm/queries/NullObservableQueryConnection.js +7 -2
  27. package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -1
  28. package/dist/esm/queries/ObservableQueryFor.d.ts +2 -0
  29. package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -1
  30. package/dist/esm/queries/ObservableQueryFor.js +11 -1
  31. package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
  32. package/dist/esm/queries/QueryFor.d.ts.map +1 -1
  33. package/dist/esm/queries/QueryFor.js +1 -21
  34. package/dist/esm/queries/QueryFor.js.map +1 -1
  35. package/dist/esm/queries/QueryInstanceCache.d.ts +1 -0
  36. package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -1
  37. package/dist/esm/queries/QueryInstanceCache.js +35 -12
  38. package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
  39. package/dist/esm/queries/QueryResult.d.ts +5 -0
  40. package/dist/esm/queries/QueryResult.d.ts.map +1 -1
  41. package/dist/esm/queries/QueryResult.js +30 -0
  42. package/dist/esm/queries/QueryResult.js.map +1 -1
  43. package/dist/esm/queries/ServerSentEventHubConnection.d.ts +1 -0
  44. package/dist/esm/queries/ServerSentEventHubConnection.d.ts.map +1 -1
  45. package/dist/esm/queries/ServerSentEventHubConnection.js +38 -10
  46. package/dist/esm/queries/ServerSentEventHubConnection.js.map +1 -1
  47. package/dist/esm/queries/WebSocketHubConnection.d.ts +1 -0
  48. package/dist/esm/queries/WebSocketHubConnection.d.ts.map +1 -1
  49. package/dist/esm/queries/WebSocketHubConnection.js.map +1 -1
  50. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_running.d.ts +2 -0
  51. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_running.d.ts.map +1 -0
  52. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_running.js +37 -0
  53. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_running.js.map +1 -0
  54. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_stopped.d.ts +2 -0
  55. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_stopped.d.ts.map +1 -0
  56. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_stopped.js +22 -0
  57. package/dist/esm/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_stopped.js.map +1 -0
  58. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_with_validator.d.ts +23 -0
  59. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_with_validator.d.ts.map +1 -0
  60. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_with_validator.js +28 -0
  61. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_with_validator.js.map +1 -0
  62. package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.d.ts +2 -0
  63. package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.d.ts.map +1 -0
  64. package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.js +21 -0
  65. package/dist/esm/queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.js.map +1 -0
  66. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.d.ts +2 -0
  67. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.d.ts.map +1 -0
  68. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.js +18 -0
  69. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.js.map +1 -0
  70. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.d.ts +2 -0
  71. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.d.ts.map +1 -0
  72. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.js +21 -0
  73. package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.js.map +1 -0
  74. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.d.ts +2 -0
  75. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.d.ts.map +1 -0
  76. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.js +32 -0
  77. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.js.map +1 -0
  78. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.d.ts +2 -0
  79. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.d.ts.map +1 -0
  80. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.js +22 -0
  81. package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.js.map +1 -0
  82. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.d.ts +2 -0
  83. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.d.ts.map +1 -0
  84. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.js +39 -0
  85. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.js.map +1 -0
  86. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.d.ts +2 -0
  87. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.d.ts.map +1 -0
  88. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.js +28 -0
  89. package/dist/esm/queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.js.map +1 -0
  90. package/dist/esm/queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.d.ts +2 -0
  91. package/dist/esm/queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.d.ts.map +1 -0
  92. package/dist/esm/queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.js +36 -0
  93. package/dist/esm/queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.js.map +1 -0
  94. package/dist/esm/queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.d.ts +2 -0
  95. package/dist/esm/queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.d.ts.map +1 -0
  96. package/dist/esm/queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.js +20 -0
  97. package/dist/esm/queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.js.map +1 -0
  98. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.d.ts +2 -0
  99. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.d.ts.map +1 -0
  100. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.js +15 -0
  101. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.js.map +1 -0
  102. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.d.ts +2 -0
  103. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.d.ts.map +1 -0
  104. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.js +20 -0
  105. package/dist/esm/queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.js.map +1 -0
  106. package/dist/esm/queries/index.d.ts +1 -0
  107. package/dist/esm/queries/index.d.ts.map +1 -1
  108. package/dist/esm/queries/index.js +1 -0
  109. package/dist/esm/queries/index.js.map +1 -1
  110. package/dist/esm/queries/reconcileQueryData.d.ts +2 -0
  111. package/dist/esm/queries/reconcileQueryData.d.ts.map +1 -0
  112. package/dist/esm/queries/reconcileQueryData.js +82 -0
  113. package/dist/esm/queries/reconcileQueryData.js.map +1 -0
  114. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  115. package/package.json +1 -1
  116. package/queries/HubConnectionKeepAlive.ts +30 -3
  117. package/queries/NullObservableQueryConnection.ts +5 -2
  118. package/queries/ObservableQueryFor.ts +15 -1
  119. package/queries/QueryFor.ts +1 -21
  120. package/queries/QueryInstanceCache.ts +61 -17
  121. package/queries/QueryResult.ts +34 -0
  122. package/queries/ServerSentEventHubConnection.ts +45 -10
  123. package/queries/WebSocketHubConnection.ts +6 -0
  124. package/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_running.ts +50 -0
  125. package/queries/for_HubConnectionKeepAlive/when_reconfiguring/while_stopped.ts +28 -0
  126. package/queries/for_ObservableQueryFor/given/an_observable_query_with_validator.ts +41 -0
  127. package/queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.ts +30 -0
  128. package/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.ts +26 -0
  129. package/queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.ts +32 -0
  130. package/queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.ts +43 -0
  131. package/queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.ts +34 -0
  132. package/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.ts +4 -4
  133. package/queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.ts +64 -0
  134. package/queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.ts +50 -0
  135. package/queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.ts +46 -0
  136. package/queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.ts +26 -0
  137. package/queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.ts +22 -0
  138. package/queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.ts +31 -0
  139. package/queries/index.ts +1 -0
  140. package/queries/reconcileQueryData.ts +98 -0
@@ -0,0 +1,21 @@
1
+ import { an_observable_query_with_validator } from '../given/an_observable_query_with_validator';
2
+ import { given } from '../../../given';
3
+ describe('when performing with client validation failing', given(an_observable_query_with_validator, context => {
4
+ let result;
5
+ beforeEach(async () => {
6
+ result = await context.query.perform({ minAge: -5 });
7
+ });
8
+ it('should not be success', () => {
9
+ result.isSuccess.should.be.false;
10
+ });
11
+ it('should not be valid', () => {
12
+ result.isValid.should.be.false;
13
+ });
14
+ it('should have validation results', () => {
15
+ result.validationResults.should.not.be.empty;
16
+ });
17
+ it('should have error for minAge', () => {
18
+ result.validationResults.some(_ => _.members.includes('minAge')).should.be.true;
19
+ });
20
+ }));
21
+ //# sourceMappingURL=with_client_validation_failing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_client_validation_failing.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_performing/with_client_validation_failing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AAEjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,QAAQ,CAAC,gDAAgD,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IAC3G,IAAI,MAA2B,CAAC;IAEhC,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;IACpF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_client_validation_failing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_client_validation_failing.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { an_observable_query_with_validator } from '../given/an_observable_query_with_validator';
2
+ import { given } from '../../../given';
3
+ describe('when subscribing with client validation failing', given(an_observable_query_with_validator, context => {
4
+ let result;
5
+ beforeEach(() => {
6
+ context.query.subscribe(_ => result = _, { minAge: -5 });
7
+ });
8
+ it('should push a result to the subscriber', () => {
9
+ result.should.not.be.undefined;
10
+ });
11
+ it('should not be valid', () => {
12
+ result.isValid.should.be.false;
13
+ });
14
+ it('should have error for minAge', () => {
15
+ result.validationResults.some(_ => _.members.includes('minAge')).should.be.true;
16
+ });
17
+ }));
18
+ //# sourceMappingURL=with_client_validation_failing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_client_validation_failing.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_subscribing/with_client_validation_failing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AAEjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,QAAQ,CAAC,iDAAiD,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IAC5G,IAAI,MAA2B,CAAC;IAEhC,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;IACpF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_client_validation_passing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_client_validation_passing.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { an_observable_query_with_validator } from '../given/an_observable_query_with_validator';
2
+ import { given } from '../../../given';
3
+ import * as sinon from 'sinon';
4
+ describe('when subscribing with client validation passing', given(an_observable_query_with_validator, context => {
5
+ let callback;
6
+ let subscription;
7
+ beforeEach(() => {
8
+ context.query.setOrigin('https://example.com');
9
+ callback = sinon.stub();
10
+ subscription = context.query.subscribe(callback, { minAge: 18 });
11
+ });
12
+ afterEach(() => {
13
+ if (subscription) {
14
+ subscription.unsubscribe();
15
+ }
16
+ });
17
+ it('should not call callback immediately', () => {
18
+ callback.called.should.be.false;
19
+ });
20
+ }));
21
+ //# sourceMappingURL=with_client_validation_passing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_client_validation_passing.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_subscribing/with_client_validation_passing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,QAAQ,CAAC,iDAAiD,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IAC5G,IAAI,QAAyB,CAAC;IAC9B,IAAI,YAAiD,CAAC;IAEtD,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QAC/C,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAExB,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,YAAY,EAAE,CAAC;YACf,YAAY,CAAC,WAAW,EAAE,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC,CAAC;IAIH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACpC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_a_partially_changed_result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_a_partially_changed_result.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_a_partially_changed_result.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import sinon from 'sinon';
2
+ import { QueryInstanceCache } from '../../QueryInstanceCache';
3
+ import { QueryResultWithState } from '../../QueryResultWithState';
4
+ describe('when a re-delivered snapshot changed only one of its items', () => {
5
+ const key = 'MyQuery::';
6
+ let cache;
7
+ let listener;
8
+ let stored;
9
+ const first = QueryResultWithState.empty([
10
+ { id: 'a', name: 'First' },
11
+ { id: 'b', name: 'Second' }
12
+ ]);
13
+ const second = QueryResultWithState.empty([
14
+ { id: 'a', name: 'First' },
15
+ { id: 'b', name: 'Second changed' }
16
+ ]);
17
+ beforeEach(() => {
18
+ cache = new QueryInstanceCache();
19
+ cache.getOrCreate(key, () => ({}));
20
+ listener = sinon.stub();
21
+ cache.addListener(key, listener);
22
+ cache.setLastResult(key, first);
23
+ cache.setLastResult(key, second);
24
+ stored = cache.getLastResult(key);
25
+ });
26
+ afterEach(() => sinon.restore());
27
+ it('should notify for both results', () => listener.calledTwice.should.be.true);
28
+ it('should keep the reference of the unchanged item', () => stored.data[0].should.equal(first.data[0]));
29
+ it('should take the new reference for the changed item', () => stored.data[1].should.equal(second.data[1]));
30
+ it('should carry the changed value', () => stored.data[1].name.should.equal('Second changed'));
31
+ });
32
+ //# sourceMappingURL=with_a_partially_changed_result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_a_partially_changed_result.js","sourceRoot":"","sources":["../../../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C,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAChF,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxG,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACnG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_a_re_delivered_identical_result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_a_re_delivered_identical_result.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import sinon from 'sinon';
2
+ import { QueryInstanceCache } from '../../QueryInstanceCache';
3
+ import { QueryResultWithState } from '../../QueryResultWithState';
4
+ describe('when the server re-delivers an identical snapshot after re-subscribing', () => {
5
+ const key = 'MyQuery::';
6
+ let cache;
7
+ let listener;
8
+ const first = QueryResultWithState.empty([{ id: 'a', name: 'First' }]);
9
+ const second = QueryResultWithState.empty([{ id: 'a', name: 'First' }]);
10
+ beforeEach(() => {
11
+ cache = new QueryInstanceCache();
12
+ cache.getOrCreate(key, () => ({}));
13
+ listener = sinon.stub();
14
+ cache.addListener(key, listener);
15
+ cache.setLastResult(key, first);
16
+ cache.setLastResult(key, second);
17
+ });
18
+ afterEach(() => sinon.restore());
19
+ it('should notify only for the first result', () => listener.calledOnce.should.be.true);
20
+ it('should keep holding the original data reference', () => cache.getLastResult(key).data.should.equal(first.data));
21
+ });
22
+ //# sourceMappingURL=with_a_re_delivered_identical_result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_a_re_delivered_identical_result.js","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_a_re_delivered_identical_result.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,QAAQ,CAAC,wEAAwE,EAAE,GAAG,EAAE;IACpF,MAAM,GAAG,GAAG,WAAW,CAAC;IACxB,IAAI,KAAyB,CAAC;IAC9B,IAAI,QAAyB,CAAC;IAE9B,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAS,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAG/E,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAS,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAEhF,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACjC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAEjC,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAChC,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjC,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACxF,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAS,GAAG,CAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACjI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=does_not_reconnect_at_the_assumed_threshold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"does_not_reconnect_at_the_assumed_threshold.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
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
+ const ASSUMED_KEEP_ALIVE_MS = 500;
6
+ const SERVER_KEEP_ALIVE_MS = 2000;
7
+ describe('when the server advertises a longer keep-alive interval than the client assumed', given(a_server_sent_event_hub_connection, context => {
8
+ let clock;
9
+ beforeEach(() => {
10
+ clock = sinon.useFakeTimers();
11
+ context.setup();
12
+ const { ServerSentEventHubConnection } = require('../../ServerSentEventHubConnection');
13
+ context.connection = new ServerSentEventHubConnection('http://localhost/.cratis/queries/sse', 'http://localhost/.cratis/queries/sse/subscribe', 'http://localhost/.cratis/queries/sse/unsubscribe', '', ASSUMED_KEEP_ALIVE_MS, 15000, context.policy);
14
+ context.connection.subscribe('q1', { queryName: 'MyQuery' }, sinon.stub());
15
+ context.simulateOpen();
16
+ context.simulateMessage({
17
+ type: HubMessageType.Connected,
18
+ payload: 'conn-123',
19
+ keepAliveIntervalMs: SERVER_KEEP_ALIVE_MS
20
+ });
21
+ });
22
+ afterEach(() => {
23
+ clock.restore();
24
+ sinon.restore();
25
+ });
26
+ describe('and the assumed threshold elapses', () => {
27
+ beforeEach(() => {
28
+ clock.tick(ASSUMED_KEEP_ALIVE_MS * 2 + 1);
29
+ });
30
+ it('should not schedule a reconnect', () => context.policy.schedule.called.should.be.false);
31
+ });
32
+ describe('and the advertised threshold elapses', () => {
33
+ beforeEach(() => {
34
+ clock.tick(SERVER_KEEP_ALIVE_MS * 2 + 1);
35
+ });
36
+ it('should schedule a reconnect', () => context.policy.schedule.calledOnce.should.be.true);
37
+ });
38
+ }));
39
+ //# sourceMappingURL=does_not_reconnect_at_the_assumed_threshold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"does_not_reconnect_at_the_assumed_threshold.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_server_advertises_a_longer_keep_alive_interval/does_not_reconnect_at_the_assumed_threshold.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,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,QAAQ,CAAC,iFAAiF,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,E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U,CAAC,GAAG,EAAE;YAEZ,KAAK,CAAC,IAAI,CAAC,oBAAoB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAE,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACpH,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=never_reconnects_from_idle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"never_reconnects_from_idle.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
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
+ const ASSUMED_KEEP_ALIVE_MS = 500;
6
+ describe('when the server reports that keep-alive is disabled', given(a_server_sent_event_hub_connection, context => {
7
+ let clock;
8
+ beforeEach(() => {
9
+ clock = sinon.useFakeTimers();
10
+ context.setup();
11
+ const { ServerSentEventHubConnection } = require('../../ServerSentEventHubConnection');
12
+ context.connection = new ServerSentEventHubConnection('http://localhost/.cratis/queries/sse', 'http://localhost/.cratis/queries/sse/subscribe', 'http://localhost/.cratis/queries/sse/unsubscribe', '', ASSUMED_KEEP_ALIVE_MS, 15000, context.policy);
13
+ context.connection.subscribe('q1', { queryName: 'MyQuery' }, sinon.stub());
14
+ context.simulateOpen();
15
+ context.simulateMessage({
16
+ type: HubMessageType.Connected,
17
+ payload: 'conn-123',
18
+ keepAliveIntervalMs: 0
19
+ });
20
+ clock.tick(ASSUMED_KEEP_ALIVE_MS * 20);
21
+ });
22
+ afterEach(() => {
23
+ clock.restore();
24
+ sinon.restore();
25
+ });
26
+ it('should never schedule a reconnect from inactivity', () => context.policy.schedule.called.should.be.false);
27
+ }));
28
+ //# sourceMappingURL=never_reconnects_from_idle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"never_reconnects_from_idle.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventHubConnection/when_server_reports_keep_alive_disabled/never_reconnects_from_idle.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,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,QAAQ,CAAC,qDAAqD,EAAE,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,EAAE;IAChH,IAAI,KAA4B,CAAC;IAEjC,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,EAAE,CAAC;QAGhB,MAAM,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;QACvF,OAAO,CAAC,UAAU,GAAG,IAAI,4BAA4B,CACjD,sCAAsC,EACtC,gDAAgD,EAChD,kDAAkD,EAClD,EAAE,EACF,qBAAqB,EACrB,KAAK,EACL,OAAO,CAAC,MAAM,CACjB,CAAC;QAEF,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;QAEvB,OAAO,CAAC,eAAe,CAAC;YACpB,IAAI,EAAE,cAAc,CAAC,SAAS;YAC9B,OAAO,EAAE,UAAU;YACnB,mBAAmB,EAAE,CAAC;SACzB,CAAC,CAAC;QAIH,KAAK,CAAC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE,CAAE,OAAO,CAAC,MAAM,CAAC,QAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACvI,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reuses_the_surviving_items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuses_the_surviving_items.d.ts","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { reconcileQueryData } from '../../reconcileQueryData';
2
+ describe('when reconciling a snapshot with an item added', () => {
3
+ const previous = [
4
+ { id: 'a', name: 'First' },
5
+ { id: 'b', name: 'Second' }
6
+ ];
7
+ const next = [
8
+ { id: 'a', name: 'First' },
9
+ { id: 'b', name: 'Second' },
10
+ { id: 'c', name: 'Third' }
11
+ ];
12
+ const result = reconcileQueryData(previous, next);
13
+ it('should return a new collection', () => result.should.not.equal(previous));
14
+ it('should have the new length', () => result.length.should.equal(3));
15
+ it('should keep the references of the surviving items', () => {
16
+ result[0].should.equal(previous[0]);
17
+ result[1].should.equal(previous[1]);
18
+ });
19
+ it('should take the new reference for the added item', () => result[2].should.equal(next[2]));
20
+ });
21
+ describe('when reconciling a snapshot with an item removed', () => {
22
+ const previous = [
23
+ { id: 'a', name: 'First' },
24
+ { id: 'b', name: 'Second' },
25
+ { id: 'c', name: 'Third' }
26
+ ];
27
+ const next = [
28
+ { id: 'a', name: 'First' },
29
+ { id: 'c', name: 'Third' }
30
+ ];
31
+ const result = reconcileQueryData(previous, next);
32
+ it('should have the new length', () => result.length.should.equal(2));
33
+ it('should keep the reference of the item that stayed in place', () => result[0].should.equal(previous[0]));
34
+ it('should keep the reference of the item that shifted position', () => result[1].should.equal(previous[2]));
35
+ });
36
+ //# sourceMappingURL=reuses_the_surviving_items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuses_the_surviving_items.js","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_items_are_added_or_removed/reuses_the_surviving_items.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC5D,MAAM,QAAQ,GAAG;QACb,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC9B,CAAC;IAEF,MAAM,IAAI,GAAG;QACT,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;KAC7B,CAAC;IAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAElD,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9E,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,EAAE,CAAC,mDAAmD,EAA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,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=only_the_changed_item_gets_a_new_reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only_the_changed_item_gets_a_new_reference.d.ts","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { reconcileQueryData } from '../../reconcileQueryData';
2
+ describe('when reconciling a snapshot in which a single item changed', () => {
3
+ const previous = [
4
+ { id: 'a', name: 'First' },
5
+ { id: 'b', name: 'Second' },
6
+ { id: 'c', name: 'Third' }
7
+ ];
8
+ const next = [
9
+ { id: 'a', name: 'First' },
10
+ { id: 'b', name: 'Second changed' },
11
+ { id: 'c', name: 'Third' }
12
+ ];
13
+ const result = reconcileQueryData(previous, next);
14
+ it('should return a new collection', () => result.should.not.equal(previous));
15
+ it('should keep the reference of the first unchanged item', () => result[0].should.equal(previous[0]));
16
+ it('should keep the reference of the last unchanged item', () => result[2].should.equal(previous[2]));
17
+ it('should take the new reference for the changed item', () => result[1].should.equal(next[1]));
18
+ it('should carry the changed value', () => result[1].name.should.equal('Second changed'));
19
+ });
20
+ //# sourceMappingURL=only_the_changed_item_gets_a_new_reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only_the_changed_item_gets_a_new_reference.js","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_one_item_changed/only_the_changed_item_gets_a_new_reference.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAQ,CAAC,4DAA4D,EAAE,GAAG,EAAE;IACxE,MAAM,QAAQ,GAAG;QACb,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,O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.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserves_all_references.d.ts","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { reconcileQueryData } from '../../reconcileQueryData';
2
+ describe('when reconciling a re-delivered snapshot that did not change', () => {
3
+ const previous = [
4
+ { id: 'a', name: 'First' },
5
+ { id: 'b', name: 'Second' }
6
+ ];
7
+ const next = [
8
+ { id: 'a', name: 'First' },
9
+ { id: 'b', name: 'Second' }
10
+ ];
11
+ const result = reconcileQueryData(previous, next);
12
+ it('should return the previous collection itself', () => result.should.equal(previous));
13
+ it('should not adopt any of the new references', () => result.forEach((item, index) => item.should.equal(previous[index])));
14
+ });
15
+ //# sourceMappingURL=preserves_all_references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserves_all_references.js","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_reconciling_an_unchanged_collection/preserves_all_references.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAQ,CAAC,8DAA8D,EAAE,GAAG,EAAE;IAC1E,MAAM,QAAQ,GAAG;QACb,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC9B,CAAC;IAGF,MAAM,IAAI,GAAG;QACT,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC9B,CAAC;IAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAElD,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxF,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAChI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=compares_by_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compares_by_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { reconcileQueryData } from '../../reconcileQueryData';
2
+ describe('when reconciling a single object that did not change', () => {
3
+ const previous = { id: 'a', name: 'First' };
4
+ const next = { id: 'a', name: 'First' };
5
+ const result = reconcileQueryData(previous, next);
6
+ it('should return the previous object', () => result.should.equal(previous));
7
+ });
8
+ describe('when reconciling a single object that changed', () => {
9
+ const previous = { id: 'a', name: 'First' };
10
+ const next = { id: 'a', name: 'Changed' };
11
+ const result = reconcileQueryData(previous, next);
12
+ it('should return the new object', () => result.should.equal(next));
13
+ });
14
+ describe('when reconciling items that carry no identity', () => {
15
+ const previous = [{ name: 'First' }, { name: 'Second' }];
16
+ const next = [{ name: 'First' }, { name: 'Second' }];
17
+ const result = reconcileQueryData(previous, next);
18
+ it('should fall back to positional matching and preserve the collection', () => result.should.equal(previous));
19
+ });
20
+ //# sourceMappingURL=compares_by_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compares_by_value.js","sourceRoot":"","sources":["../../../../../queries/for_reconcileQueryData/when_reconciling_non_collection_payloads/compares_by_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAQ,CAAC,sDAAsD,EAAE,GA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,QAAQ,CAAC,CAAC,CAAC;AACnH,CAAC,CAAC,CAAC"}
@@ -32,6 +32,7 @@ export * from './ObservableQuerySubscription';
32
32
  export * from './WebSocketMessage';
33
33
  export * from './QueryTransportMethod';
34
34
  export * from './QueryInstanceCache';
35
+ export * from './reconcileQueryData';
35
36
  export * from './IQueryProvider';
36
37
  export * from './QueryProvider';
37
38
  export * from './QueryValidator';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../queries/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,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cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,OAAO,eAAe,CAAC"}
@@ -24,6 +24,7 @@ export { ObservableQuerySubscription } from './ObservableQuerySubscription.js';
24
24
  export { WebSocketMessageType } from './WebSocketMessage.js';
25
25
  export { QueryTransportMethod } from './QueryTransportMethod.js';
26
26
  export { QueryInstanceCache } from './QueryInstanceCache.js';
27
+ export { reconcileQueryData } from './reconcileQueryData.js';
27
28
  export { IQueryProvider } from './IQueryProvider.js';
28
29
  export { QueryProvider } from './QueryProvider.js';
29
30
  export { QueryValidator } from './QueryValidator.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../queries/index.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport * from './ChangeSet';\nexport * from './IChangeStreamFor';\nexport * from './IQuery';\nexport * from './IQueryFor';\nexport * from './Paging';\nexport * from './Sorting';\nexport * from './SortDirection';\nexport * from './SortingActions';\nexport * from './SortingActionsForQuery';\nexport * from './SortingActionsForObservableQuery';\nexport * from './QueryFor';\nexport * from './QueryHttpMethod';\nexport * from './QueryHttpMethodResolver';\nexport * from './QueryHttpRequest';\nexport * from './QueryResult';\nexport * from './QueryResultWithState';\nexport * from './IObservableQueryFor';\nexport * from './ObservableQueryFor';\nexport * from './IObservableQueryConnection';\nexport * from './IObservableQueryHubConnection';\nexport * from './IReconnectPolicy';\nexport * from './ReconnectPolicy';\nexport * from './HubConnectionKeepAlive';\nexport * from './ObservableQueryConnection';\nexport * from './ObservableQueryConnectionFactory';\nexport * from './ObservableQueryConnectionPool';\nexport * from './ServerSentEventQueryConnection';\nexport * from './ServerSentEventHubConnection';\nexport * from './WebSocketHubConnection';\nexport * from './ObservableQueryMultiplexer';\nexport * from './ObservableQuerySubscription';\nexport * from './WebSocketMessage';\nexport * from './QueryTransportMethod';\nexport * from './QueryInstanceCache';\nexport * from './IQueryProvider';\nexport * from './QueryProvider';\nexport * from './QueryValidator';\nexport * from './IObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnosticsSnapshot';\nimport '../validation';"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA"}
1
+ {"version":3,"file":"index.js","sources":["../../../queries/index.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport * from './ChangeSet';\nexport * from './IChangeStreamFor';\nexport * from './IQuery';\nexport * from './IQueryFor';\nexport * from './Paging';\nexport * from './Sorting';\nexport * from './SortDirection';\nexport * from './SortingActions';\nexport * from './SortingActionsForQuery';\nexport * from './SortingActionsForObservableQuery';\nexport * from './QueryFor';\nexport * from './QueryHttpMethod';\nexport * from './QueryHttpMethodResolver';\nexport * from './QueryHttpRequest';\nexport * from './QueryResult';\nexport * from './QueryResultWithState';\nexport * from './IObservableQueryFor';\nexport * from './ObservableQueryFor';\nexport * from './IObservableQueryConnection';\nexport * from './IObservableQueryHubConnection';\nexport * from './IReconnectPolicy';\nexport * from './ReconnectPolicy';\nexport * from './HubConnectionKeepAlive';\nexport * from './ObservableQueryConnection';\nexport * from './ObservableQueryConnectionFactory';\nexport * from './ObservableQueryConnectionPool';\nexport * from './ServerSentEventQueryConnection';\nexport * from './ServerSentEventHubConnection';\nexport * from './WebSocketHubConnection';\nexport * from './ObservableQueryMultiplexer';\nexport * from './ObservableQuerySubscription';\nexport * from './WebSocketMessage';\nexport * from './QueryTransportMethod';\nexport * from './QueryInstanceCache';\nexport * from './reconcileQueryData';\nexport * from './IQueryProvider';\nexport * from './QueryProvider';\nexport * from './QueryValidator';\nexport * from './IObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnosticsSnapshot';\nimport '../validation';"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA"}
@@ -0,0 +1,2 @@
1
+ export declare function reconcileQueryData<T>(previous: T, next: T): T;
2
+ //# sourceMappingURL=reconcileQueryData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcileQueryData.d.ts","sourceRoot":"","sources":["../../../queries/reconcileQueryData.ts"],"names":[],"mappings":"AA6CA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAU7D"}
@@ -0,0 +1,82 @@
1
+ import { deepEqual } from '../deepEqual.js';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Resolves the conventional identity of an item so it can be matched against its previous version.
7
+ *
8
+ * Uses the `id` property, the same strategy the server-side change-set computation applies, and
9
+ * reduces concept-style identities (objects with a meaningful `toString()`) to a comparable value.
10
+ * @param {unknown} item The item to resolve identity for.
11
+ * @returns {unknown} The identity value, or `undefined` when the item carries no usable identity.
12
+ */ function getIdentity(item) {
13
+ const id = item?.id;
14
+ if (id === null || id === undefined) {
15
+ return undefined;
16
+ }
17
+ if (typeof id === 'object') {
18
+ const stringValue = id.toString();
19
+ return stringValue !== '[object Object]' ? stringValue : JSON.stringify(id);
20
+ }
21
+ return id;
22
+ }
23
+ /**
24
+ * Reconciles a full payload against the previous one, carrying over the previous object references
25
+ * for every item that did not actually change.
26
+ *
27
+ * Observable queries re-deliver a complete snapshot whenever a subscription is (re-)established.
28
+ * Deserializing that snapshot produces entirely new object references, so consumers that compare by
29
+ * reference — memoized components, effect dependencies — treat every item as changed even when the
30
+ * payload is identical to what they already display. Reconciling restores referential stability:
31
+ * unchanged items keep their previous reference, and when nothing changed at all the previous
32
+ * payload itself is returned so callers can detect "no change" with a single `===`.
33
+ *
34
+ * Items are matched by their `id` when present, falling back to position for identity-less items.
35
+ * @template T The payload type.
36
+ * @param {T} previous The payload currently held.
37
+ * @param {T} next The freshly received payload.
38
+ * @returns {T} `previous` when nothing changed; otherwise the new payload with unchanged items carried over by reference.
39
+ */ function reconcileQueryData(previous, next) {
40
+ if (previous === next) {
41
+ return previous;
42
+ }
43
+ if (Array.isArray(previous) && Array.isArray(next)) {
44
+ return reconcileArray(previous, next);
45
+ }
46
+ return deepEqual(previous, next) ? previous : next;
47
+ }
48
+ /**
49
+ * Reconciles two arrays element by element, preserving previous references for unchanged items.
50
+ * @param {unknown[]} previous The array currently held.
51
+ * @param {unknown[]} next The freshly received array.
52
+ * @returns {unknown[]} `previous` when the arrays are equivalent; otherwise a new array reusing unchanged items.
53
+ */ function reconcileArray(previous, next) {
54
+ const previousByIdentity = new Map();
55
+ for (const item of previous){
56
+ const identity = getIdentity(item);
57
+ // Keep the first occurrence — duplicate identities are not a shape we can reconcile
58
+ // meaningfully, and preferring the first keeps the result deterministic.
59
+ if (identity !== undefined && !previousByIdentity.has(identity)) {
60
+ previousByIdentity.set(identity, item);
61
+ }
62
+ }
63
+ let changed = previous.length !== next.length;
64
+ const reconciled = next.map((item, index)=>{
65
+ const identity = getIdentity(item);
66
+ const candidate = identity !== undefined ? previousByIdentity.get(identity) : previous[index];
67
+ if (candidate !== undefined && deepEqual(candidate, item)) {
68
+ // An unchanged item that moved still leaves the collection changed as a whole, but the
69
+ // item itself keeps its reference so only the ordering re-renders, not its content.
70
+ if (candidate !== previous[index]) {
71
+ changed = true;
72
+ }
73
+ return candidate;
74
+ }
75
+ changed = true;
76
+ return item;
77
+ });
78
+ return changed ? reconciled : previous;
79
+ }
80
+
81
+ export { reconcileQueryData };
82
+ //# sourceMappingURL=reconcileQueryData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcileQueryData.js","sources":["../../../queries/reconcileQueryData.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { deepEqual } from '../deepEqual';\n\n/**\n * Resolves the conventional identity of an item so it can be matched against its previous version.\n *\n * Uses the `id` property, the same strategy the server-side change-set computation applies, and\n * reduces concept-style identities (objects with a meaningful `toString()`) to a comparable value.\n * @param {unknown} item The item to resolve identity for.\n * @returns {unknown} The identity value, or `undefined` when the item carries no usable identity.\n */\nfunction getIdentity(item: unknown): unknown {\n const id = (item as Record<string, unknown>)?.id;\n\n if (id === null || id === undefined) {\n return undefined;\n }\n\n if (typeof id === 'object') {\n const stringValue = id.toString();\n return stringValue !== '[object Object]' ? stringValue : JSON.stringify(id);\n }\n\n return id;\n}\n\n/**\n * Reconciles a full payload against the previous one, carrying over the previous object references\n * for every item that did not actually change.\n *\n * Observable queries re-deliver a complete snapshot whenever a subscription is (re-)established.\n * Deserializing that snapshot produces entirely new object references, so consumers that compare by\n * reference — memoized components, effect dependencies — treat every item as changed even when the\n * payload is identical to what they already display. Reconciling restores referential stability:\n * unchanged items keep their previous reference, and when nothing changed at all the previous\n * payload itself is returned so callers can detect \"no change\" with a single `===`.\n *\n * Items are matched by their `id` when present, falling back to position for identity-less items.\n * @template T The payload type.\n * @param {T} previous The payload currently held.\n * @param {T} next The freshly received payload.\n * @returns {T} `previous` when nothing changed; otherwise the new payload with unchanged items carried over by reference.\n */\nexport function reconcileQueryData<T>(previous: T, next: T): T {\n if (previous === next) {\n return previous;\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return reconcileArray(previous, next) as T;\n }\n\n return deepEqual(previous, next) ? previous : next;\n}\n\n/**\n * Reconciles two arrays element by element, preserving previous references for unchanged items.\n * @param {unknown[]} previous The array currently held.\n * @param {unknown[]} next The freshly received array.\n * @returns {unknown[]} `previous` when the arrays are equivalent; otherwise a new array reusing unchanged items.\n */\nfunction reconcileArray(previous: unknown[], next: unknown[]): unknown[] {\n const previousByIdentity = new Map<unknown, unknown>();\n\n for (const item of previous) {\n const identity = getIdentity(item);\n\n // Keep the first occurrence — duplicate identities are not a shape we can reconcile\n // meaningfully, and preferring the first keeps the result deterministic.\n if (identity !== undefined && !previousByIdentity.has(identity)) {\n previousByIdentity.set(identity, item);\n }\n }\n\n let changed = previous.length !== next.length;\n\n const reconciled = next.map((item, index) => {\n const identity = getIdentity(item);\n const candidate = identity !== undefined ? previousByIdentity.get(identity) : previous[index];\n\n if (candidate !== undefined && deepEqual(candidate, item)) {\n // An unchanged item that moved still leaves the collection changed as a whole, but the\n // item itself keeps its reference so only the ordering re-renders, not its content.\n if (candidate !== previous[index]) {\n changed = true;\n }\n\n return candidate;\n }\n\n changed = true;\n return item;\n });\n\n return changed ? reconciled : previous;\n}\n"],"names":["getIdentity","item","id","undefined","stringValue","toString","JSON","stringify","reconcileQueryData","previous","next","Array","isArray","reconcileArray","deepEqual","previousByIdentity","Map","identity","has","set","changed","length","reconciled","map","index","candidate","get"],"mappings":";;AAAA;AACA;AAIA;;;;;;;IAQA,SAASA,YAAYC,IAAa,EAAA;AAC9B,IAAA,MAAMC,KAAMD,IAAAA,EAAkCC,EAAAA;IAE9C,IAAIA,EAAAA,KAAO,IAAA,IAAQA,EAAAA,KAAOC,SAAAA,EAAW;QACjC,OAAOA,SAAAA;AACX,IAAA;IAEA,IAAI,OAAOD,OAAO,QAAA,EAAU;QACxB,MAAME,WAAAA,GAAcF,GAAGG,QAAQ,EAAA;AAC/B,QAAA,OAAOD,WAAAA,KAAgB,iBAAA,GAAoBA,WAAAA,GAAcE,IAAAA,CAAKC,SAAS,CAACL,EAAAA,CAAAA;AAC5E,IAAA;IAEA,OAAOA,EAAAA;AACX;AAEA;;;;;;;;;;;;;;;;AAgBC,IACM,SAASM,kBAAAA,CAAsBC,QAAW,EAAEC,IAAO,EAAA;AACtD,IAAA,IAAID,aAAaC,IAAAA,EAAM;QACnB,OAAOD,QAAAA;AACX,IAAA;AAEA,IAAA,IAAIE,MAAMC,OAAO,CAACH,aAAaE,KAAAA,CAAMC,OAAO,CAACF,IAAAA,CAAAA,EAAO;AAChD,QAAA,OAAOG,eAAeJ,QAAAA,EAAUC,IAAAA,CAAA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