@cratis/arc 20.4.1 → 20.5.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/QueryResult.js +1 -1
- package/dist/cjs/queries/QueryResult.js.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.js +3 -3
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
- package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts +2 -0
- package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts.map +1 -0
- package/dist/esm/queries/QueryResult.js +1 -1
- package/dist/esm/queries/QueryResult.js.map +1 -1
- package/dist/esm/queries/QueryResultWithState.js +3 -3
- package/dist/esm/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts +2 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.js +23 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.js.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts +2 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.js +23 -0
- package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.js +9 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.js +9 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.js +25 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.js +25 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.js +9 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.js +9 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.js.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts +2 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.js +9 -0
- package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/QueryResult.ts +1 -1
- package/queries/QueryResultWithState.ts +3 -3
- package/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.ts +29 -0
- package/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.ts +29 -0
- package/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.ts +13 -0
- package/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.ts +13 -0
- package/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.ts +30 -0
- package/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts +30 -0
- package/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.ts +13 -0
- package/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts +13 -0
- package/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.ts +13 -0
package/package.json
CHANGED
package/queries/QueryResult.ts
CHANGED
|
@@ -13,7 +13,7 @@ export class QueryResultWithState<TDataType> implements IQueryResult<TDataType>
|
|
|
13
13
|
|
|
14
14
|
static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {
|
|
15
15
|
return new QueryResultWithState(
|
|
16
|
-
defaultValue,
|
|
16
|
+
defaultValue ?? ([] as unknown as TDataType),
|
|
17
17
|
PagingInfo.noPaging,
|
|
18
18
|
true,
|
|
19
19
|
true,
|
|
@@ -27,7 +27,7 @@ export class QueryResultWithState<TDataType> implements IQueryResult<TDataType>
|
|
|
27
27
|
|
|
28
28
|
static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {
|
|
29
29
|
return new QueryResultWithState(
|
|
30
|
-
defaultValue,
|
|
30
|
+
defaultValue ?? ([] as unknown as TDataType),
|
|
31
31
|
PagingInfo.noPaging,
|
|
32
32
|
true,
|
|
33
33
|
true,
|
|
@@ -81,7 +81,7 @@ export class QueryResultWithState<TDataType> implements IQueryResult<TDataType>
|
|
|
81
81
|
*/
|
|
82
82
|
static fromQueryResult<TDataType>(queryResult: QueryResult<TDataType>, isPerforming: boolean) {
|
|
83
83
|
return new QueryResultWithState<TDataType>(
|
|
84
|
-
queryResult.data,
|
|
84
|
+
queryResult.data ?? ([] as unknown as TDataType),
|
|
85
85
|
queryResult.paging,
|
|
86
86
|
queryResult.isSuccess,
|
|
87
87
|
queryResult.isAuthorized,
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { QueryResult } from '../../QueryResult';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
|
|
8
|
+
describe('when asking has data and it is null for enumerable query', () => {
|
|
9
|
+
const queryResult = new QueryResult<any>({
|
|
10
|
+
isSuccess: true,
|
|
11
|
+
isAuthorized: true,
|
|
12
|
+
isValid: true,
|
|
13
|
+
hasExceptions: false,
|
|
14
|
+
exceptionMessages: [],
|
|
15
|
+
exceptionStackTrace: '',
|
|
16
|
+
paging: {
|
|
17
|
+
totalItems: 0,
|
|
18
|
+
totalPages: 0,
|
|
19
|
+
page: 0,
|
|
20
|
+
size: 0
|
|
21
|
+
},
|
|
22
|
+
validationResults: [],
|
|
23
|
+
data: null
|
|
24
|
+
}, Object, true);
|
|
25
|
+
|
|
26
|
+
it('should consider it to not have data', () => queryResult.hasData.should.be.false);
|
|
27
|
+
it('should have data that is not null', () => (queryResult.data !== null).should.be.true);
|
|
28
|
+
it('should have data that is an empty array', () => queryResult.data.should.deep.equal([]));
|
|
29
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { QueryResult } from '../../QueryResult';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
|
|
8
|
+
describe('when asking has data and it is null for non-enumerable query', () => {
|
|
9
|
+
const queryResult = new QueryResult<any>({
|
|
10
|
+
isSuccess: true,
|
|
11
|
+
isAuthorized: true,
|
|
12
|
+
isValid: true,
|
|
13
|
+
hasExceptions: false,
|
|
14
|
+
exceptionMessages: [],
|
|
15
|
+
exceptionStackTrace: '',
|
|
16
|
+
paging: {
|
|
17
|
+
totalItems: 0,
|
|
18
|
+
totalPages: 0,
|
|
19
|
+
page: 0,
|
|
20
|
+
size: 0
|
|
21
|
+
},
|
|
22
|
+
validationResults: [],
|
|
23
|
+
data: null
|
|
24
|
+
}, Object, false);
|
|
25
|
+
|
|
26
|
+
it('should consider to have data since empty object is truthy', () => queryResult.hasData.should.be.true);
|
|
27
|
+
it('should have data that is not null', () => (queryResult.data !== null).should.be.true);
|
|
28
|
+
it('should have data that is an empty object', () => queryResult.data.should.deep.equal({}));
|
|
29
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { QueryResultWithState } from '../../QueryResultWithState';
|
|
5
|
+
|
|
6
|
+
describe('when creating empty with null default value', () => {
|
|
7
|
+
const result = QueryResultWithState.empty<string[]>(null as unknown as string[]);
|
|
8
|
+
|
|
9
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
10
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
11
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
12
|
+
it('should not be performing', () => result.isPerforming.should.be.false);
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { QueryResultWithState } from '../../QueryResultWithState';
|
|
5
|
+
|
|
6
|
+
describe('when creating empty with undefined default value', () => {
|
|
7
|
+
const result = QueryResultWithState.empty<string[]>(undefined as unknown as string[]);
|
|
8
|
+
|
|
9
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
10
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
11
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
12
|
+
it('should not be performing', () => result.isPerforming.should.be.false);
|
|
13
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { QueryResult } from '../../QueryResult';
|
|
5
|
+
import { QueryResultWithState } from '../../QueryResultWithState';
|
|
6
|
+
|
|
7
|
+
describe('when creating from query result with null data', () => {
|
|
8
|
+
const queryResult = new QueryResult<object>({
|
|
9
|
+
data: null as unknown as object,
|
|
10
|
+
isSuccess: true,
|
|
11
|
+
isAuthorized: true,
|
|
12
|
+
isValid: true,
|
|
13
|
+
hasExceptions: false,
|
|
14
|
+
validationResults: [],
|
|
15
|
+
exceptionMessages: [],
|
|
16
|
+
exceptionStackTrace: '',
|
|
17
|
+
paging: {
|
|
18
|
+
totalItems: 0,
|
|
19
|
+
totalPages: 0,
|
|
20
|
+
page: 0,
|
|
21
|
+
size: 0
|
|
22
|
+
}
|
|
23
|
+
}, Object, true);
|
|
24
|
+
|
|
25
|
+
const result = QueryResultWithState.fromQueryResult(queryResult, false);
|
|
26
|
+
|
|
27
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
28
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
29
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
30
|
+
});
|
package/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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 { QueryResult } from '../../QueryResult';
|
|
5
|
+
import { QueryResultWithState } from '../../QueryResultWithState';
|
|
6
|
+
|
|
7
|
+
describe('when creating from query result with undefined data', () => {
|
|
8
|
+
const queryResult = new QueryResult<object>({
|
|
9
|
+
data: undefined as unknown as object,
|
|
10
|
+
isSuccess: true,
|
|
11
|
+
isAuthorized: true,
|
|
12
|
+
isValid: true,
|
|
13
|
+
hasExceptions: false,
|
|
14
|
+
validationResults: [],
|
|
15
|
+
exceptionMessages: [],
|
|
16
|
+
exceptionStackTrace: '',
|
|
17
|
+
paging: {
|
|
18
|
+
totalItems: 0,
|
|
19
|
+
totalPages: 0,
|
|
20
|
+
page: 0,
|
|
21
|
+
size: 0
|
|
22
|
+
}
|
|
23
|
+
}, Object, true);
|
|
24
|
+
|
|
25
|
+
const result = QueryResultWithState.fromQueryResult(queryResult, false);
|
|
26
|
+
|
|
27
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
28
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
29
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
30
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { QueryResultWithState } from '../../QueryResultWithState';
|
|
5
|
+
|
|
6
|
+
describe('when creating initial with null default value', () => {
|
|
7
|
+
const result = QueryResultWithState.initial<string[]>(null as unknown as string[]);
|
|
8
|
+
|
|
9
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
10
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
11
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
12
|
+
it('should be performing', () => result.isPerforming.should.be.true);
|
|
13
|
+
});
|
package/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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 { QueryResultWithState } from '../../QueryResultWithState';
|
|
5
|
+
|
|
6
|
+
describe('when creating initial with undefined default value', () => {
|
|
7
|
+
const result = QueryResultWithState.initial<string[]>(undefined as unknown as string[]);
|
|
8
|
+
|
|
9
|
+
it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
|
|
10
|
+
it('should have data that is not null', () => (result.data !== null).should.be.true);
|
|
11
|
+
it('should not have data', () => result.hasData.should.be.false);
|
|
12
|
+
it('should be performing', () => result.isPerforming.should.be.true);
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { QueryResultWithState } from '../../QueryResultWithState';
|
|
5
|
+
|
|
6
|
+
describe('when creating initial with valid default value', () => {
|
|
7
|
+
const defaultValue = [{ id: '1', name: 'test' }];
|
|
8
|
+
const result = QueryResultWithState.initial(defaultValue);
|
|
9
|
+
|
|
10
|
+
it('should use the provided default value', () => result.data.should.equal(defaultValue));
|
|
11
|
+
it('should have data', () => result.hasData.should.be.true);
|
|
12
|
+
it('should be performing', () => result.isPerforming.should.be.true);
|
|
13
|
+
});
|