quidproquo-core 0.0.56 → 0.0.58
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.
|
@@ -2,13 +2,13 @@ export declare enum NetworkActionType {
|
|
|
2
2
|
Request = "@quidproquo-core/Network/Request"
|
|
3
3
|
}
|
|
4
4
|
export type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'PATCH';
|
|
5
|
-
export type
|
|
5
|
+
export type ResponseType = 'binary' | 'json';
|
|
6
6
|
export interface HTTPRequestOptions<T> {
|
|
7
7
|
basePath?: string;
|
|
8
8
|
params?: Record<string, string>;
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
10
|
body?: T;
|
|
11
|
-
responseType
|
|
11
|
+
responseType?: ResponseType;
|
|
12
12
|
}
|
|
13
13
|
export interface HTTPNetworkResponse<T> {
|
|
14
14
|
data: T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action, ActionProcessor, ActionRequester } from '../../types/Action';
|
|
2
|
-
import { NetworkActionType, HTTPNetworkResponse, HTTPMethod,
|
|
2
|
+
import { NetworkActionType, HTTPNetworkResponse, HTTPMethod, ResponseType } from './NetworkActionType';
|
|
3
3
|
export interface NetworkRequestActionPayload<T> {
|
|
4
4
|
url: string;
|
|
5
5
|
method: HTTPMethod;
|
|
@@ -7,7 +7,7 @@ export interface NetworkRequestActionPayload<T> {
|
|
|
7
7
|
basePath?: string;
|
|
8
8
|
params?: Record<string, string>;
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
|
-
responseType:
|
|
10
|
+
responseType: ResponseType;
|
|
11
11
|
}
|
|
12
12
|
export interface NetworkRequestAction<T> extends Action<NetworkRequestActionPayload<T>> {
|
|
13
13
|
type: NetworkActionType.Request;
|
package/lib/qpqRuntime.js
CHANGED
|
@@ -18,9 +18,17 @@ function processAction(action, actionProcessors, session) {
|
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
// Special action ~ batch - needs access to the processAction / actionProcessor context
|
|
20
20
|
if (action.type === SystemActionType_1.SystemActionType.Batch) {
|
|
21
|
-
|
|
21
|
+
const batchRes = yield Promise.all(action.payload.actions.map((a) => {
|
|
22
22
|
return a ? processAction(a, actionProcessors, session) : null;
|
|
23
|
-
}))
|
|
23
|
+
}));
|
|
24
|
+
// If there was an error, throw that error back
|
|
25
|
+
const erroredBatchItem = batchRes.find((br) => (0, actionLogic_1.isErroredActionResult)(br));
|
|
26
|
+
if (erroredBatchItem) {
|
|
27
|
+
const error = (0, actionLogic_1.resolveActionResultError)(erroredBatchItem);
|
|
28
|
+
return (0, actionLogic_1.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, error.errorText, error.errorStack);
|
|
29
|
+
}
|
|
30
|
+
// unwrap the values
|
|
31
|
+
return (0, actionLogic_1.actionResult)(batchRes.map((br) => (0, actionLogic_1.resolveActionResult)(br)));
|
|
24
32
|
}
|
|
25
33
|
const processor = actionProcessors === null || actionProcessors === void 0 ? void 0 : actionProcessors[action === null || action === void 0 ? void 0 : action.type];
|
|
26
34
|
if (!processor) {
|