@cratis/arc 21.2.0 → 21.3.1
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/ObservableQueryConnection.js +24 -4
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventQueryConnection.js +24 -2
- package/dist/cjs/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.d.ts +2 -0
- package/dist/esm/queries/ObservableQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.js +24 -4
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ServerSentEventQueryConnection.d.ts +2 -0
- package/dist/esm/queries/ServerSentEventQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/ServerSentEventQueryConnection.js +24 -2
- package/dist/esm/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection_with_a_reconnect_policy.d.ts +25 -0
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection_with_a_reconnect_policy.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection_with_a_reconnect_policy.js +45 -0
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection_with_a_reconnect_policy.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.js +44 -0
- package/dist/esm/queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.js +43 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/ObservableQueryConnection.ts +28 -4
- package/queries/ServerSentEventQueryConnection.ts +26 -2
- package/queries/for_ObservableQueryConnection/given/an_observable_query_connection_with_a_reconnect_policy.ts +72 -0
- package/queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts +57 -0
- package/queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminates_without_reconnecting.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { given } from '../../../given';
|
|
2
|
+
import { an_observable_query_connection_with_a_reconnect_policy } from '../given/an_observable_query_connection_with_a_reconnect_policy';
|
|
3
|
+
import { WebSocketMessageType } from '../../WebSocketMessage';
|
|
4
|
+
describe('when receiving unauthorized it terminates without reconnecting', given(an_observable_query_connection_with_a_reconnect_policy, context => {
|
|
5
|
+
const unauthorizedResult = {
|
|
6
|
+
data: null,
|
|
7
|
+
isSuccess: false,
|
|
8
|
+
isAuthorized: false,
|
|
9
|
+
isValid: true,
|
|
10
|
+
hasExceptions: false,
|
|
11
|
+
validationResults: [],
|
|
12
|
+
exceptionMessages: [],
|
|
13
|
+
exceptionStackTrace: '',
|
|
14
|
+
paging: { page: 0, size: 0, totalItems: 0, totalPages: 0 }
|
|
15
|
+
};
|
|
16
|
+
let receivedResults = [];
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
receivedResults = [];
|
|
19
|
+
context.connection.connect((data) => {
|
|
20
|
+
receivedResults.push(data);
|
|
21
|
+
});
|
|
22
|
+
context.simulateMessage({
|
|
23
|
+
type: WebSocketMessageType.Data,
|
|
24
|
+
data: unauthorizedResult
|
|
25
|
+
});
|
|
26
|
+
context.simulateClose();
|
|
27
|
+
});
|
|
28
|
+
it('should deliver the unauthorized result', () => {
|
|
29
|
+
receivedResults.should.have.lengthOf(1);
|
|
30
|
+
});
|
|
31
|
+
it('should deliver it as not authorized', () => {
|
|
32
|
+
receivedResults[0].isAuthorized.should.be.false;
|
|
33
|
+
});
|
|
34
|
+
it('should not schedule a reconnect', () => {
|
|
35
|
+
context.schedule.called.should.be.false;
|
|
36
|
+
});
|
|
37
|
+
it('should cancel any pending reconnect', () => {
|
|
38
|
+
context.cancel.called.should.be.true;
|
|
39
|
+
});
|
|
40
|
+
it('should close the socket', () => {
|
|
41
|
+
context.fakeWebSocket.close.called.should.be.true;
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
44
|
+
//# sourceMappingURL=terminates_without_reconnecting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminates_without_reconnecting.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,sDAAsD,EAAE,MAAM,iEAAiE,CAAC;AAEzI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,QAAQ,CAAC,gEAAgE,EAAE,KAAK,CAAC,sDAAsD,EAAE,OAAO,CAAC,EAAE;IAC/I,MAAM,kBAAkB,GAAG;QACvB,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE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IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QAC/B,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminates_without_reconnecting.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { ServerSentEventQueryConnection } from '../../ServerSentEventQueryConnection';
|
|
3
|
+
describe('when receiving unauthorized it terminates without reconnecting', () => {
|
|
4
|
+
const unauthorizedResult = {
|
|
5
|
+
data: null,
|
|
6
|
+
isSuccess: false,
|
|
7
|
+
isAuthorized: false,
|
|
8
|
+
isValid: true,
|
|
9
|
+
hasExceptions: false,
|
|
10
|
+
validationResults: [],
|
|
11
|
+
exceptionMessages: [],
|
|
12
|
+
exceptionStackTrace: '',
|
|
13
|
+
paging: { page: 0, size: 0, totalItems: 0, totalPages: 0 }
|
|
14
|
+
};
|
|
15
|
+
let fakeEventSource;
|
|
16
|
+
let closeStub;
|
|
17
|
+
let constructedCount;
|
|
18
|
+
let connection;
|
|
19
|
+
let receivedResults;
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
closeStub = sinon.stub();
|
|
22
|
+
constructedCount = 0;
|
|
23
|
+
fakeEventSource = { onmessage: null, onerror: null, close: closeStub };
|
|
24
|
+
globalThis['EventSource'] = function () {
|
|
25
|
+
constructedCount++;
|
|
26
|
+
return fakeEventSource;
|
|
27
|
+
};
|
|
28
|
+
receivedResults = [];
|
|
29
|
+
connection = new ServerSentEventQueryConnection(new URL('http://localhost/api/queries/latest'));
|
|
30
|
+
connection.connect((result) => receivedResults.push(result));
|
|
31
|
+
fakeEventSource['onmessage']({ data: JSON.stringify(unauthorizedResult) });
|
|
32
|
+
connection.connect(() => { });
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
delete globalThis['EventSource'];
|
|
36
|
+
sinon.restore();
|
|
37
|
+
});
|
|
38
|
+
it('should deliver the unauthorized result', () => receivedResults.length.should.equal(1));
|
|
39
|
+
it('should deliver it as not authorized', () => receivedResults[0].isAuthorized.should.be.false);
|
|
40
|
+
it('should close the event source', () => closeStub.calledOnce.should.be.true);
|
|
41
|
+
it('should not re-establish the stream', () => constructedCount.should.equal(1));
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=terminates_without_reconnecting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminates_without_reconnecting.js","sourceRoot":"","sources":["../../../../../queries/for_ServerSentEventQueryConnection/when_receiving_unauthorized/terminates_without_reconnecting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAQtF,QAAQ,CAAC,gEAAgE,EAAE,GAAG,EAAE;IAC5E,MAAM,kBAAkB,GAAG;QACvB,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;KAC7D,CAAC;IAEF,IAAI,eAAwC,CAAC;IAC7C,IAAI,SAA0B,CAAC;IAC/B,IAAI,gBAAwB,CAAC;IAC7B,IAAI,UAAoD,CAAC;IACzD,IAAI,eAAwC,CAAC;IAE7C,UAAU,CAAC,GA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