@cratis/arc 23.19.1 → 23.20.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/commands/CommandResult.ts +5 -0
- package/commands/ICommandResult.ts +3 -0
- package/commands/for_CommandResult/when_receiving_a_mapped_failure.ts +32 -0
- package/dist/cjs/commands/CommandResult.d.ts +2 -0
- package/dist/cjs/commands/CommandResult.d.ts.map +1 -1
- package/dist/cjs/commands/CommandResult.js +2 -0
- package/dist/cjs/commands/CommandResult.js.map +1 -1
- package/dist/cjs/commands/ICommandResult.d.ts +1 -0
- package/dist/cjs/commands/ICommandResult.d.ts.map +1 -1
- package/dist/cjs/queries/IQueryResult.d.ts +1 -0
- package/dist/cjs/queries/IQueryResult.d.ts.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.d.ts.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.js +2 -2
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
- package/dist/cjs/queries/QueryResult.d.ts +2 -0
- package/dist/cjs/queries/QueryResult.d.ts.map +1 -1
- package/dist/cjs/queries/QueryResult.js +2 -0
- package/dist/cjs/queries/QueryResult.js.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.d.ts +2 -1
- package/dist/cjs/queries/QueryResultWithState.d.ts.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.js +5 -2
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/commands/CommandResult.d.ts +2 -0
- package/dist/esm/commands/CommandResult.d.ts.map +1 -1
- package/dist/esm/commands/CommandResult.js +2 -0
- package/dist/esm/commands/CommandResult.js.map +1 -1
- package/dist/esm/commands/ICommandResult.d.ts +1 -0
- package/dist/esm/commands/ICommandResult.d.ts.map +1 -1
- package/dist/esm/commands/for_CommandResult/when_receiving_a_mapped_failure.d.ts +2 -0
- package/dist/esm/commands/for_CommandResult/when_receiving_a_mapped_failure.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandResult/when_receiving_a_mapped_failure.js +24 -0
- package/dist/esm/commands/for_CommandResult/when_receiving_a_mapped_failure.js.map +1 -0
- package/dist/esm/queries/IQueryResult.d.ts +1 -0
- package/dist/esm/queries/IQueryResult.d.ts.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.js +2 -2
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/queries/QueryResult.d.ts +2 -0
- package/dist/esm/queries/QueryResult.d.ts.map +1 -1
- package/dist/esm/queries/QueryResult.js +2 -0
- package/dist/esm/queries/QueryResult.js.map +1 -1
- package/dist/esm/queries/QueryResultWithState.d.ts +2 -1
- package/dist/esm/queries/QueryResultWithState.d.ts.map +1 -1
- package/dist/esm/queries/QueryResultWithState.js +5 -2
- package/dist/esm/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.js +25 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.js.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_receiving_a_mapped_failure.d.ts +2 -0
- package/dist/esm/queries/for_QueryResult/when_receiving_a_mapped_failure.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryResult/when_receiving_a_mapped_failure.js +37 -0
- package/dist/esm/queries/for_QueryResult/when_receiving_a_mapped_failure.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/IQueryResult.ts +3 -0
- package/queries/QueryInstanceCache.ts +2 -0
- package/queries/QueryResult.ts +5 -0
- package/queries/QueryResultWithState.ts +3 -0
- package/queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.ts +30 -0
- package/queries/for_QueryResult/when_receiving_a_mapped_failure.ts +45 -0
|
@@ -19,6 +19,7 @@ import { PagingInfo } from './PagingInfo.js';
|
|
|
19
19
|
isReady;
|
|
20
20
|
authorizationFailureReason;
|
|
21
21
|
isRetryable;
|
|
22
|
+
errorCode;
|
|
22
23
|
/**
|
|
23
24
|
* Creates a settled empty state, such as the state returned by a disabled query.
|
|
24
25
|
* @param defaultValue The query's empty data value.
|
|
@@ -49,7 +50,8 @@ import { PagingInfo } from './PagingInfo.js';
|
|
|
49
50
|
* @param {ChangeSet<unknown> | undefined} changeSet Optional change set from the server describing the delta since the last update.
|
|
50
51
|
* @param {boolean} isReady Whether the query has produced a result. Defaults to true so existing constructor calls
|
|
51
52
|
* represent settled synthetic states; {@link initial} explicitly uses false because no server result exists yet.
|
|
52
|
-
|
|
53
|
+
* @param {string | undefined} errorCode Optional stable public failure code.
|
|
54
|
+
*/ constructor(data, paging, isSuccess, isAuthorized, isValid, validationResults, hasExceptions, exceptionMessages, exceptionStackTrace, isPerforming, changeSet, isReady = true, authorizationFailureReason = '', isRetryable = false, errorCode){
|
|
53
55
|
this.data = data;
|
|
54
56
|
this.paging = paging;
|
|
55
57
|
this.isSuccess = isSuccess;
|
|
@@ -64,6 +66,7 @@ import { PagingInfo } from './PagingInfo.js';
|
|
|
64
66
|
this.isReady = isReady;
|
|
65
67
|
this.authorizationFailureReason = authorizationFailureReason;
|
|
66
68
|
this.isRetryable = isRetryable;
|
|
69
|
+
this.errorCode = errorCode;
|
|
67
70
|
}
|
|
68
71
|
/** @inheritdoc */ get hasData() {
|
|
69
72
|
if (Array.isArray(this.data)) {
|
|
@@ -77,7 +80,7 @@ import { PagingInfo } from './PagingInfo.js';
|
|
|
77
80
|
* @param isPerforming Whether or not the query is performing.
|
|
78
81
|
* @returns A new {@link QueryResultWithState<TDataType>}
|
|
79
82
|
*/ static fromQueryResult(queryResult, isPerforming) {
|
|
80
|
-
return new QueryResultWithState(queryResult.data, queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming, queryResult.changeSet, queryResult.isReady ?? true, queryResult.authorizationFailureReason ?? '', queryResult.isRetryable ?? false);
|
|
83
|
+
return new QueryResultWithState(queryResult.data, queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming, queryResult.changeSet, queryResult.isReady ?? true, queryResult.authorizationFailureReason ?? '', queryResult.isRetryable ?? false, queryResult.errorCode);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult.js';\nimport { IQueryResult } from './IQueryResult.js';\nimport { PagingInfo } from './PagingInfo.js';\nimport { ChangeSet } from './ChangeSet.js';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n /**\n * Creates a settled empty state, such as the state returned by a disabled query.\n * @param defaultValue The query's empty data value.\n * @returns A ready state that is not performing.\n */\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false,\n undefined,\n true,\n );\n }\n\n /**\n * Creates the local initial state before any server result has been received. This state is not ready because\n * no result exists yet; its performing state independently describes the active client request.\n * @param defaultValue The query's initial data value.\n * @returns A not-ready state that is performing.\n */\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true,\n undefined,\n false,\n );\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n * @param {ChangeSet<unknown> | undefined} changeSet Optional change set from the server describing the delta since the last update.\n * @param {boolean} isReady Whether the query has produced a result. Defaults to true so existing constructor calls\n * represent settled synthetic states; {@link initial} explicitly uses false because no server result exists yet.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean,\n readonly changeSet?: ChangeSet<unknown>,\n readonly isReady: boolean = true,\n readonly authorizationFailureReason: string = '',\n readonly isRetryable: boolean = false,\n ) {}\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from an {@link IQueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(\n queryResult: IQueryResult<TDataType>,\n isPerforming: boolean,\n ) {\n return new QueryResultWithState<TDataType>(\n queryResult.data,\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming,\n queryResult.changeSet,\n queryResult.isReady ?? true,\n queryResult.authorizationFailureReason ?? '',\n queryResult.isRetryable ?? false,\n );\n }\n}\n"],"names":["QueryResultWithState","empty","defaultValue","PagingInfo","noPaging","undefined","initial","
|
|
1
|
+
{"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult.js';\nimport { IQueryResult } from './IQueryResult.js';\nimport { PagingInfo } from './PagingInfo.js';\nimport { ChangeSet } from './ChangeSet.js';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n /**\n * Creates a settled empty state, such as the state returned by a disabled query.\n * @param defaultValue The query's empty data value.\n * @returns A ready state that is not performing.\n */\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false,\n undefined,\n true,\n );\n }\n\n /**\n * Creates the local initial state before any server result has been received. This state is not ready because\n * no result exists yet; its performing state independently describes the active client request.\n * @param defaultValue The query's initial data value.\n * @returns A not-ready state that is performing.\n */\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true,\n undefined,\n false,\n );\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n * @param {ChangeSet<unknown> | undefined} changeSet Optional change set from the server describing the delta since the last update.\n * @param {boolean} isReady Whether the query has produced a result. Defaults to true so existing constructor calls\n * represent settled synthetic states; {@link initial} explicitly uses false because no server result exists yet.\n * @param {string | undefined} errorCode Optional stable public failure code.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean,\n readonly changeSet?: ChangeSet<unknown>,\n readonly isReady: boolean = true,\n readonly authorizationFailureReason: string = '',\n readonly isRetryable: boolean = false,\n readonly errorCode?: string,\n ) {}\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from an {@link IQueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(\n queryResult: IQueryResult<TDataType>,\n isPerforming: boolean,\n ) {\n return new QueryResultWithState<TDataType>(\n queryResult.data,\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming,\n queryResult.changeSet,\n queryResult.isReady ?? true,\n queryResult.authorizationFailureReason ?? '',\n queryResult.isRetryable ?? false,\n queryResult.errorCode,\n );\n }\n}\n"],"names":["QueryResultWithState","empty","defaultValue","PagingInfo","noPaging","undefined","initial","isAuthorized","isValid","validationResults","hasExceptions","isReady","authorizationFailureReason","isRetryable","data","paging","isSuccess","exceptionMessages","exceptionStackTrace","isPerforming","changeSet","errorCode","hasData","Array","isArray","length","fromQueryResult","queryResult"],"mappings":";;AAAA;AACA;AAOA;;AAEC,IACM,MAAMA,oBAAAA,CAAAA;;;;;;;;;;;;;;;;AACT;;;;QAKA,OAAOC,KAAAA,CAAiBC,YAAuB,EAAmC;AAC9E,QAAA,OAAO,IAAIF,oBAAAA,CACPE,YAAAA,EACAC,UAAAA,CAAWC,QAAQ,EACnB,IAAA,EACA,IAAA,EACA,IAAA,EACA,EAAE,EACF,KAAA,EACA,EAAE,EACF,EAAA,EACA,OACAC,SAAAA,EACA,IAAA,CAAA;AAER,IAAA;AAEA;;;;;QAMA,OAAOC,OAAAA,CAAmBJ,YAAuB,EAAmC;AAChF,QAAA,OAAO,IAAIF,oBAAAA,CACPE,YAAAA,EACAC,UAAAA,CAAWC,QAAQ,EACnB,IAAA,EACA,IAAA,EACA,IAAA,EACA,EAAE,EACF,KAAA,EACA,EAAE,EACF,EAAA,EACA,MACAC,SAAAA,EACA,KAAA,CAAA;AAER,IAAA;AAEA;;;;;;;;;;;;;;;;QAiBA,WAAA,CACI,IAAwB,EACxB,MAA2B,EAC3B,SAA2B,EAClBE,YAAqB,EACrBC,OAAgB,EAChBC,iBAAqC,EACrCC,aAAsB,EAC/B,iBAAoC,EACpC,mBAAoC,EACpC,YAA8B,EAC9B,SAAuC,EAC9BC,OAAAA,GAAmB,IAAI,EAChC,0BAASC,GAAqC,EAAE,EACvCC,cAAuB,KAAK,EACrC,SAA2B,CAC7B;aAfWC,IAAAA,GAAAA,IAAAA;aACAC,MAAAA,GAAAA,MAAAA;aACAC,SAAAA,GAAAA,SAAAA;aACAT,YAAAA,GAAAA,YAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,iBAAAA,GAAAA,iBAAAA;aACAC,aAAAA,GAAAA,aAAAA;aACAO,iBAAAA,GAAAA,iBAAAA;aACAC,mBAAAA,GAAAA,mBAAAA;aACAC,YAAAA,GAAAA,YAAAA;aACAC,SAAAA,GAAAA,SAAAA;aACAT,OAAAA,GAAAA,OAAAA;aACAC,0BAAAA,GAAAA,0BAAAA;aACAC,WAAAA,GAAAA,WAAAA;aACAQ,SAAAA,GAAAA,SAAAA;AACV,IAAA;uBAGH,IAAIC,OAAAA,GAAmB;AACnB,QAAA,IAAIC,MAAMC,OAAO,CAAC,IAAI,CAACV,IAAI,CAAA,EAAG;AAC1B,YAAA,OAAO,IAAI,CAACA,IAAI,CAACW,MAAM,GAAG,CAAA;AAC9B,QAAA;AACA,QAAA,OAAO,CAAC,CAAC,IAAI,CAACX,IAAI;AACtB,IAAA;AAEA;;;;;AAKC,QACD,OAAOY,eAAAA,CACHC,WAAoC,EACpCR,YAAqB,EACvB;QACE,OAAO,IAAInB,qBACP2B,WAAAA,CAAYb,IAAI,EAChBa,WAAAA,CAAYZ,MAAM,EAClBY,WAAAA,CAAYX,SAAS,EACrBW,WAAAA,CAAYpB,YAAY,EACxBoB,WAAAA,CAAYnB,OAAO,EACnBmB,WAAAA,CAAYlB,iBAAiB,EAC7BkB,WAAAA,CAAYjB,aAAa,EACzBiB,YAAYV,iBAAiB,EAC7BU,YAAYT,mBAAmB,EAC/BC,cACAQ,WAAAA,CAAYP,SAAS,EACrBO,WAAAA,CAAYhB,OAAO,IAAI,IAAA,EACvBgB,WAAAA,CAAYf,0BAA0B,IAAI,EAAA,EAC1Ce,YAAYd,WAAW,IAAI,KAAA,EAC3Bc,WAAAA,CAAYN,SAAS,CAAA;AAE7B,IAAA;AACJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_only_error_code_changed.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import { PagingInfo } from '../../PagingInfo.js';
|
|
4
|
+
import { QueryInstanceCache } from '../../QueryInstanceCache.js';
|
|
5
|
+
import { QueryResultWithState } from '../../QueryResultWithState.js';
|
|
6
|
+
describe('when setting the last result with only the error code changed', () => {
|
|
7
|
+
it('should retain the code when data is reconciled and notify when it clears', () => {
|
|
8
|
+
const cache = new QueryInstanceCache();
|
|
9
|
+
const key = 'MyQuery::';
|
|
10
|
+
const listener = sinon.stub();
|
|
11
|
+
const state = (code) => new QueryResultWithState(['a'], PagingInfo.noPaging, false, true, true, [], true, ['An unexpected error occurred.'], '', false, undefined, true, '', false, code);
|
|
12
|
+
cache.getOrCreate(key, () => ({}));
|
|
13
|
+
cache.addListener(key, listener);
|
|
14
|
+
cache.setLastResult(key, state());
|
|
15
|
+
listener.resetHistory();
|
|
16
|
+
cache.setLastResult(key, state('namespace_closing'));
|
|
17
|
+
listener.calledOnce.should.be.true;
|
|
18
|
+
listener.firstCall.args[0].errorCode.should.equal('namespace_closing');
|
|
19
|
+
listener.resetHistory();
|
|
20
|
+
cache.setLastResult(key, state());
|
|
21
|
+
listener.calledOnce.should.be.true;
|
|
22
|
+
expect(listener.firstCall.args[0].errorCode).to.be.undefined;
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=with_only_error_code_changed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_only_error_code_changed.js","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_only_error_code_changed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,E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MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACnC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IACjE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_receiving_a_mapped_failure.d.ts","sourceRoot":"","sources":["../../../../queries/for_QueryResult/when_receiving_a_mapped_failure.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { QueryResult } from '../QueryResult.js';
|
|
3
|
+
import { QueryResultWithState } from '../QueryResultWithState.js';
|
|
4
|
+
import { PagingInfo } from '../PagingInfo.js';
|
|
5
|
+
describe('when receiving a mapped query failure', () => {
|
|
6
|
+
const serverResult = {
|
|
7
|
+
data: {},
|
|
8
|
+
isSuccess: false,
|
|
9
|
+
isAuthorized: true,
|
|
10
|
+
isValid: true,
|
|
11
|
+
hasExceptions: true,
|
|
12
|
+
validationResults: [],
|
|
13
|
+
exceptionMessages: ['An unexpected error occurred.'],
|
|
14
|
+
exceptionStackTrace: '',
|
|
15
|
+
paging: { page: 0, size: 0, totalItems: 0, totalPages: 0 },
|
|
16
|
+
};
|
|
17
|
+
it('should preserve the code through deserialization and state conversion', () => {
|
|
18
|
+
const result = new QueryResult({ ...serverResult, errorCode: 'namespace_recovery_required' }, Object, false);
|
|
19
|
+
const state = QueryResultWithState.fromQueryResult(result, false);
|
|
20
|
+
result.errorCode.should.equal('namespace_recovery_required');
|
|
21
|
+
state.errorCode.should.equal(result.errorCode);
|
|
22
|
+
state.isRetryable.should.be.false;
|
|
23
|
+
});
|
|
24
|
+
it('should tolerate an older server without a code', () => expect(new QueryResult(serverResult, Object, false).errorCode).to.be.undefined);
|
|
25
|
+
it('should keep every existing positional constructor argument', () => {
|
|
26
|
+
const state = new QueryResultWithState({}, PagingInfo.noPaging, false, false, true, [], false, [], '', false, undefined, false, 'denied', true);
|
|
27
|
+
state.isReady.should.be.false;
|
|
28
|
+
state.authorizationFailureReason.should.equal('denied');
|
|
29
|
+
state.isRetryable.should.be.true;
|
|
30
|
+
expect(state.errorCode).to.be.undefined;
|
|
31
|
+
});
|
|
32
|
+
it('should clear the code when a later successful result arrives', () => {
|
|
33
|
+
const result = new QueryResult({ ...serverResult, isSuccess: true, hasExceptions: false, exceptionMessages: [] }, Object, false);
|
|
34
|
+
expect(QueryResultWithState.fromQueryResult(result, false).errorCode).to.be.undefined;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=when_receiving_a_mapped_failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_receiving_a_mapped_failure.js","sourceRoot":"","sources":["../../../../queries/for_QueryResult/when_receiving_a_mapped_failure.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACnD,MAAM,YAAY,GAAG;QACjB,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,IAAI;QACnB,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,CAAC,+BAA+B,CAAC;QACpD,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,EAAE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