@restorecommerce/facade 0.3.7 → 0.3.10

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/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.10](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.3.9...@restorecommerce/facade@0.3.10) (2022-03-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **facade:** set target scope if it exists ([0597107](https://github.com/restorecommerce/libs/commit/0597107001e68fcbe19a51a8621e603e9a7610ad))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.3.9](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.3.8...@restorecommerce/facade@0.3.9) (2022-03-14)
18
+
19
+ **Note:** Version bump only for package @restorecommerce/facade
20
+
21
+
22
+
23
+
24
+
25
+ ## [0.3.8](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.3.7...@restorecommerce/facade@0.3.8) (2022-03-14)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **facade:** check if buffer field is actually a buffer ([d0930dc](https://github.com/restorecommerce/libs/commit/d0930dcd979d0a2acc101890517e43c7f7d6e2df))
31
+
32
+
33
+
34
+
35
+
6
36
  ## [0.3.7](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.3.6...@restorecommerce/facade@0.3.7) (2022-03-14)
7
37
 
8
38
 
@@ -178,11 +178,12 @@ const getGQLResolverFunctions = (service, key, serviceKey, grpcClientConfig) =>
178
178
  return obj;
179
179
  }
180
180
  obj[methodName] = async (args, context) => {
181
- var _a;
181
+ var _a, _b;
182
182
  const client = context[key].client;
183
183
  const service = client[serviceKey];
184
184
  try {
185
185
  const converted = await (0, exports.recursiveUploadToBuffer)(args.input, typing.input);
186
+ const scope = (_a = args === null || args === void 0 ? void 0 : args.input) === null || _a === void 0 ? void 0 : _a.scope;
186
187
  let req = typing.processor.fromPartial(converted);
187
188
  // convert enum strings to integers
188
189
  req = (0, utils_1.convertEnumToInt)(typing, req);
@@ -192,13 +193,13 @@ const getGQLResolverFunctions = (service, key, serviceKey, grpcClientConfig) =>
192
193
  if (authToken && authToken.startsWith('Bearer ')) {
193
194
  req.subject.token = authToken.split(' ')[1];
194
195
  }
195
- if (req.scope) {
196
- req.subject.scope = req.scope;
196
+ if (scope) {
197
+ req.subject.scope = scope;
197
198
  }
198
199
  }
199
200
  let realMethod = method.name;
200
201
  if (Mutate.indexOf(method.name) > -1) {
201
- const mode = (_a = args === null || args === void 0 ? void 0 : args.input) === null || _a === void 0 ? void 0 : _a.mode;
202
+ const mode = (_b = args === null || args === void 0 ? void 0 : args.input) === null || _b === void 0 ? void 0 : _b.mode;
202
203
  if (!mode) {
203
204
  throw new Error('Please specify mode');
204
205
  }
@@ -212,7 +213,6 @@ const getGQLResolverFunctions = (service, key, serviceKey, grpcClientConfig) =>
212
213
  realMethod = 'Upsert';
213
214
  }
214
215
  }
215
- console.log(outputTyping);
216
216
  const rawResult = await service[realMethod](req);
217
217
  const result = (0, exports.recursiveBufferToValue)(rawResult, outputTyping.output);
218
218
  const bufferFields = (0, utils_1.getKeys)(grpcClientConfig === null || grpcClientConfig === void 0 ? void 0 : grpcClientConfig.bufferFields);
@@ -2,7 +2,7 @@ import { TypingData } from './registry';
2
2
  export declare const capitalizeProtoName: (name: string) => string;
3
3
  export declare const convertyCamelToSnakeCase: (entity: string) => string;
4
4
  export declare const getKeys: (obj: any) => string[];
5
- export declare const decodeBufferFields: (items: any, bufferFields: string[]) => any;
5
+ export declare const decodeBufferFields: (items: any[], bufferFields: string[]) => any;
6
6
  /**
7
7
  * converts enum string values to integers reading from the inputTyping
8
8
  * @param TypingData input typing
@@ -36,7 +36,7 @@ const decodeBufferFields = (items, bufferFields) => {
36
36
  if (item && item.payload) {
37
37
  const existingBufferFields = _.intersection(Object.keys(item.payload), bufferFields);
38
38
  for (let bufferField of existingBufferFields) {
39
- if (item.payload[bufferField] && item.payload[bufferField].value) {
39
+ if (item.payload[bufferField] && item.payload[bufferField].value && item.payload[bufferField].value instanceof Buffer) {
40
40
  item.payload[bufferField].value = JSON.parse(item.payload[bufferField].value.toString());
41
41
  }
42
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restorecommerce/facade",
3
- "version": "0.3.7",
3
+ "version": "0.3.10",
4
4
  "description": "Facade for Restorecommerce microservices",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -108,5 +108,5 @@
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
111
- "gitHead": "3d7eb8d6f7751810202df1c02893625f432f4569"
111
+ "gitHead": "8bffdc70c928f7a76b006e952a16c9b3f79dcd9a"
112
112
  }