@cratis/arc 18.1.2 → 18.1.3
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/Globals.ts +4 -0
- package/commands/Command.ts +2 -2
- package/commands/for_Command/given/a_command.ts +5 -0
- package/commands/for_Command/when_constructing_command.ts +43 -0
- package/commands/for_Command/when_constructing_command_with_globals_api_base_path.ts +27 -0
- package/commands/for_Command/when_constructing_command_with_globals_origin.ts +27 -0
- package/commands/for_Command/when_executing/with_microservice_header.ts +3 -11
- package/commands/for_Command/when_executing/with_missing_required_property.ts +4 -11
- package/dist/cjs/Globals.d.ts +2 -0
- package/dist/cjs/Globals.d.ts.map +1 -1
- package/dist/cjs/Globals.js +2 -0
- package/dist/cjs/Globals.js.map +1 -1
- package/dist/cjs/commands/Command.js +2 -2
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/identity/IdentityProvider.d.ts +4 -0
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js +13 -1
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryFor.js +2 -2
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
- package/dist/cjs/queries/QueryFor.js +2 -2
- package/dist/cjs/queries/QueryFor.js.map +1 -1
- package/dist/esm/Globals.d.ts +2 -0
- package/dist/esm/Globals.d.ts.map +1 -1
- package/dist/esm/Globals.js +2 -0
- package/dist/esm/Globals.js.map +1 -1
- package/dist/esm/commands/Command.js +2 -2
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/identity/IdentityProvider.d.ts +4 -0
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.js +13 -1
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js +2 -2
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
- package/dist/esm/queries/QueryFor.js +2 -2
- package/dist/esm/queries/QueryFor.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/identity/IdentityProvider.ts +23 -1
- package/identity/for_IdentityProvider/given/an_identity_provider.ts +27 -0
- package/identity/for_IdentityProvider/when_refreshing/with_api_base_path_set.ts +30 -0
- package/identity/for_IdentityProvider/when_refreshing/with_globals_api_base_path.ts +36 -0
- package/identity/for_IdentityProvider/when_refreshing/without_api_base_path.ts +35 -0
- package/identity/for_IdentityProvider/when_setting_api_base_path.ts +21 -0
- package/identity/for_IdentityProvider/when_setting_origin.ts +21 -0
- package/package.json +1 -1
- package/queries/ObservableQueryFor.ts +2 -2
- package/queries/QueryFor.ts +2 -2
- package/queries/for_ObservableQueryFor/when_constructing.ts +12 -0
- package/queries/for_ObservableQueryFor/when_constructing_with_globals_api_base_path.ts +27 -0
- package/queries/for_ObservableQueryFor/when_constructing_with_globals_origin.ts +27 -0
- package/queries/for_QueryFor/when_constructing.ts +12 -0
- package/queries/for_QueryFor/when_constructing_with_globals_api_base_path.ts +27 -0
- package/queries/for_QueryFor/when_constructing_with_globals_origin.ts +27 -0
- package/queries/for_QueryFor/when_performing/with_query_without_required_parameters.ts +5 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { IdentityProvider } from '../IdentityProvider';
|
|
5
|
+
import { an_identity_provider } from './given/an_identity_provider';
|
|
6
|
+
import { given } from '../../given';
|
|
7
|
+
|
|
8
|
+
describe('when setting origin', given(an_identity_provider, () => {
|
|
9
|
+
let origin: string;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
origin = 'https://example.com';
|
|
13
|
+
IdentityProvider.setOrigin(origin);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
IdentityProvider.setOrigin('');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should set the origin', () => IdentityProvider.origin.should.equal(origin));
|
|
21
|
+
}));
|
package/package.json
CHANGED
|
@@ -49,8 +49,8 @@ export abstract class ObservableQueryFor<TDataType, TParameters = object> implem
|
|
|
49
49
|
this.sorting = Sorting.none;
|
|
50
50
|
this.paging = Paging.noPaging;
|
|
51
51
|
this._microservice = Globals.microservice ?? '';
|
|
52
|
-
this._apiBasePath = '';
|
|
53
|
-
this._origin = '';
|
|
52
|
+
this._apiBasePath = Globals.apiBasePath ?? '';
|
|
53
|
+
this._origin = Globals.origin ?? '';
|
|
54
54
|
this._httpHeadersCallback = () => ({});
|
|
55
55
|
}
|
|
56
56
|
|
package/queries/QueryFor.ts
CHANGED
|
@@ -42,8 +42,8 @@ export abstract class QueryFor<TDataType, TParameters = object> implements IQuer
|
|
|
42
42
|
this.sorting = Sorting.none;
|
|
43
43
|
this.paging = Paging.noPaging;
|
|
44
44
|
this._microservice = Globals.microservice ?? '';
|
|
45
|
-
this._apiBasePath = '';
|
|
46
|
-
this._origin = '';
|
|
45
|
+
this._apiBasePath = Globals.apiBasePath ?? '';
|
|
46
|
+
this._origin = Globals.origin ?? '';
|
|
47
47
|
this._httpHeadersCallback = () => ({});
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -10,16 +10,28 @@ import { Globals } from '../../Globals';
|
|
|
10
10
|
|
|
11
11
|
describe('when constructing', given(an_observable_query_for, context => {
|
|
12
12
|
let originalMicroservice: string | undefined;
|
|
13
|
+
let originalApiBasePath: string | undefined;
|
|
14
|
+
let originalOrigin: string | undefined;
|
|
13
15
|
|
|
14
16
|
beforeEach(() => {
|
|
15
17
|
originalMicroservice = Globals.microservice;
|
|
18
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
19
|
+
originalOrigin = Globals.origin;
|
|
16
20
|
Globals.microservice = 'test-microservice';
|
|
21
|
+
Globals.apiBasePath = '/test-api';
|
|
22
|
+
Globals.origin = 'http://test-origin';
|
|
17
23
|
});
|
|
18
24
|
|
|
19
25
|
afterEach(() => {
|
|
20
26
|
if (originalMicroservice !== undefined) {
|
|
21
27
|
Globals.microservice = originalMicroservice;
|
|
22
28
|
}
|
|
29
|
+
if (originalApiBasePath !== undefined) {
|
|
30
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
31
|
+
}
|
|
32
|
+
if (originalOrigin !== undefined) {
|
|
33
|
+
Globals.origin = originalOrigin;
|
|
34
|
+
}
|
|
23
35
|
});
|
|
24
36
|
|
|
25
37
|
it('should set sorting to none', () => context.query.sorting.should.equal(Sorting.none));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { an_observable_query_for } from './given/an_observable_query_for';
|
|
5
|
+
import { given } from '../../given';
|
|
6
|
+
import { Globals } from '../../Globals';
|
|
7
|
+
import { TestObservableQuery } from './given/TestQueries';
|
|
8
|
+
|
|
9
|
+
describe('when constructing with globals api base path', given(an_observable_query_for, () => {
|
|
10
|
+
let originalApiBasePath: string | undefined;
|
|
11
|
+
let query: TestObservableQuery;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
15
|
+
Globals.apiBasePath = '/custom/api';
|
|
16
|
+
query = new TestObservableQuery();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
if (originalApiBasePath !== undefined) {
|
|
21
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
it('should initialize with globals api base path', () => (query as any)._apiBasePath.should.equal('/custom/api'));
|
|
27
|
+
}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { an_observable_query_for } from './given/an_observable_query_for';
|
|
5
|
+
import { given } from '../../given';
|
|
6
|
+
import { Globals } from '../../Globals';
|
|
7
|
+
import { TestObservableQuery } from './given/TestQueries';
|
|
8
|
+
|
|
9
|
+
describe('when constructing with globals origin', given(an_observable_query_for, () => {
|
|
10
|
+
let originalOrigin: string | undefined;
|
|
11
|
+
let query: TestObservableQuery;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
originalOrigin = Globals.origin;
|
|
15
|
+
Globals.origin = 'https://example.com';
|
|
16
|
+
query = new TestObservableQuery();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
if (originalOrigin !== undefined) {
|
|
21
|
+
Globals.origin = originalOrigin;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
it('should initialize with globals origin', () => (query as any)._origin.should.equal('https://example.com'));
|
|
27
|
+
}));
|
|
@@ -9,16 +9,28 @@ import { Globals } from '../../Globals';
|
|
|
9
9
|
|
|
10
10
|
describe('when constructing', given(a_query_for, context => {
|
|
11
11
|
let originalMicroservice: string | undefined;
|
|
12
|
+
let originalApiBasePath: string | undefined;
|
|
13
|
+
let originalOrigin: string | undefined;
|
|
12
14
|
|
|
13
15
|
beforeEach(() => {
|
|
14
16
|
originalMicroservice = Globals.microservice;
|
|
17
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
18
|
+
originalOrigin = Globals.origin;
|
|
15
19
|
Globals.microservice = 'test-microservice';
|
|
20
|
+
Globals.apiBasePath = '/test-api';
|
|
21
|
+
Globals.origin = 'http://test-origin';
|
|
16
22
|
});
|
|
17
23
|
|
|
18
24
|
afterEach(() => {
|
|
19
25
|
if (originalMicroservice !== undefined) {
|
|
20
26
|
Globals.microservice = originalMicroservice;
|
|
21
27
|
}
|
|
28
|
+
if (originalApiBasePath !== undefined) {
|
|
29
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
30
|
+
}
|
|
31
|
+
if (originalOrigin !== undefined) {
|
|
32
|
+
Globals.origin = originalOrigin;
|
|
33
|
+
}
|
|
22
34
|
});
|
|
23
35
|
|
|
24
36
|
it('should set sorting to none', () => context.query.sorting.should.equal(Sorting.none));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_query_for } from './given/a_query_for';
|
|
5
|
+
import { given } from '../../given';
|
|
6
|
+
import { Globals } from '../../Globals';
|
|
7
|
+
import { TestQueryFor } from './given/TestQueries';
|
|
8
|
+
|
|
9
|
+
describe('when constructing with globals api base path', given(a_query_for, () => {
|
|
10
|
+
let originalApiBasePath: string | undefined;
|
|
11
|
+
let query: TestQueryFor;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
15
|
+
Globals.apiBasePath = '/custom/api';
|
|
16
|
+
query = new TestQueryFor();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
if (originalApiBasePath !== undefined) {
|
|
21
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
it('should initialize with globals api base path', () => (query as any)._apiBasePath.should.equal('/custom/api'));
|
|
27
|
+
}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_query_for } from './given/a_query_for';
|
|
5
|
+
import { given } from '../../given';
|
|
6
|
+
import { Globals } from '../../Globals';
|
|
7
|
+
import { TestQueryFor } from './given/TestQueries';
|
|
8
|
+
|
|
9
|
+
describe('when constructing with globals origin', given(a_query_for, () => {
|
|
10
|
+
let originalOrigin: string | undefined;
|
|
11
|
+
let query: TestQueryFor;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
originalOrigin = Globals.origin;
|
|
15
|
+
Globals.origin = 'https://example.com';
|
|
16
|
+
query = new TestQueryFor();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
if (originalOrigin !== undefined) {
|
|
21
|
+
Globals.origin = originalOrigin;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
it('should initialize with globals origin', () => (query as any)._origin.should.equal('https://example.com'));
|
|
27
|
+
}));
|
|
@@ -28,7 +28,10 @@ describe('with query without required parameters', given(a_query_for, context =>
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
beforeEach(async () => {
|
|
31
|
-
// Setup fetch mock
|
|
31
|
+
// Setup fetch mock - restore any existing stub first
|
|
32
|
+
if ((global.fetch as sinon.SinonStub)?.restore) {
|
|
33
|
+
(global.fetch as sinon.SinonStub).restore();
|
|
34
|
+
}
|
|
32
35
|
fetchStub = sinon.stub(global, 'fetch');
|
|
33
36
|
fetchStub.resolves({
|
|
34
37
|
json: sinon.stub().resolves(mockResponse),
|
|
@@ -43,7 +46,7 @@ describe('with query without required parameters', given(a_query_for, context =>
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
afterEach(() => {
|
|
46
|
-
fetchStub
|
|
49
|
+
fetchStub?.restore();
|
|
47
50
|
});
|
|
48
51
|
|
|
49
52
|
it('should return successful result', () => {
|