integreat 0.8.0-alpha.77 → 0.8.0-alpha.78

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/index.js CHANGED
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "transformers", { enumerable: true, get: function
15
15
  var middleware_1 = require("./middleware");
16
16
  Object.defineProperty(exports, "middleware", { enumerable: true, get: function () { return middleware_1.default; } });
17
17
  exports.default = {
18
- version: '0.8.0-alpha.76',
18
+ version: '0.8.0-alpha.77',
19
19
  create: create_1.default,
20
20
  mergeDefinitions: mergeDefinitions_1.default,
21
21
  mergeResources: mergeResources_1.default,
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.populateActionAfterMapping = exports.prepareActionForMapping = void 0;
4
+ const is_1 = require("./is");
4
5
  function prepareActionForMapping(action, _isRequest = false) {
5
6
  return action;
6
7
  }
7
8
  exports.prepareActionForMapping = prepareActionForMapping;
8
- const setStatus = (response) => ({
9
+ const isResponseObject = (response) => (0, is_1.isObject)(response) && Object.keys(response).length > 0;
10
+ const setStatus = (response, originalStatus = null) => ({
9
11
  ...response,
10
- status: response.status || (response.error ? 'error' : null),
12
+ status: response.status === undefined
13
+ ? response.error && (!originalStatus || originalStatus === 'ok')
14
+ ? 'error'
15
+ : originalStatus
16
+ : response.status,
11
17
  });
12
18
  function populateActionAfterMapping(action, mappedAction) {
13
19
  if (!mappedAction) {
@@ -18,7 +24,9 @@ function populateActionAfterMapping(action, mappedAction) {
18
24
  return {
19
25
  type: type || action.type,
20
26
  payload: payload || action.payload,
21
- ...(response && { response: setStatus(response) }),
27
+ ...(isResponseObject(response) && {
28
+ response: setStatus(response, action.response?.status),
29
+ }),
22
30
  meta: meta || action.meta,
23
31
  };
24
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mappingHelpers.js","sourceRoot":"","sources":["../../src/utils/mappingHelpers.ts"],"names":[],"mappings":";;;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,MAAM,SAAS,GAAG,CAChB,QAA2B,EAC3B,iBAAgC,IAAI,EAC1B,EAAE,CAAC,CAAC;IACd,GAAG,QAAQ;IACX,MAAM,EACJ,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC3B,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,IAAI,cAAc,KAAK,IAAI,CAAC;YAC9D,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,cAAc;QAClB,CAAC,CAAC,QAAQ,CAAC,MAAM;CACtB,CAAC,CAAA;AAEF,SAAgB,0BAA0B,CACxC,MAAc,EACd,YAA8B;IAE9B,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,MAAM,CAAA;KACd;IACD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAA;IAC5C,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAA;IACzD,OAAO;QACL,IAAI,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI;QACzB,OAAO,EAAE,OAAO,IAAI,MAAM,CAAC,OAAO;QAClC,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI;YAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;SACvD,CAAC;QACF,IAAI,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI;KAC1B,CAAA;AACH,CAAC;AAjBD,gEAiBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integreat",
3
- "version": "0.8.0-alpha.77",
3
+ "version": "0.8.0-alpha.78",
4
4
  "description": "Node.js integration layer",
5
5
  "author": "Kjell-Morten Bratsberg Thorsen <kjellmorten@integreat.io> (https://integreat.io/)",
6
6
  "license": "ISC",