@sdflc/backend-helpers 1.0.61 → 1.0.62

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.
Files changed (2) hide show
  1. package/build/BaseCore.js +13 -4
  2. package/package.json +1 -1
package/build/BaseCore.js CHANGED
@@ -19,6 +19,9 @@ const userToken_1 = require("./userToken");
19
19
  const defaultValidate = ( /*args: any, opt?: BaseCoreActionsInterface*/) => {
20
20
  return [true, {}];
21
21
  };
22
+ const defaultMutationValidate = ( /*args: any, opt?: BaseCoreActionsInterface*/) => {
23
+ return [true, {}];
24
+ };
22
25
  const defaultValidators = {
23
26
  list: defaultValidate,
24
27
  get: commonValidators_1.validateGet,
@@ -263,8 +266,11 @@ class BaseCore {
263
266
  accessRights: [utils_1.ACCESS_RIGHTS.GET],
264
267
  action: (args, opt) => __awaiter(this, void 0, void 0, function* () {
265
268
  var _d;
266
- const id2use = this.beforeGet(args, opt);
267
- const item = yield ((_d = this.getContext().gateways[this.config.gatewayName]) === null || _d === void 0 ? void 0 : _d.get(id2use));
269
+ const args2use = yield this.beforeGet(args, opt);
270
+ if ((args2use === null || args2use === void 0 ? void 0 : args2use.id) == null) {
271
+ return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, '', []);
272
+ }
273
+ const item = yield ((_d = this.getContext().gateways[this.config.gatewayName]) === null || _d === void 0 ? void 0 : _d.get(args2use === null || args2use === void 0 ? void 0 : args2use.id));
268
274
  const result = yield this.afterGet(item, opt);
269
275
  if (!result) {
270
276
  return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, '', []);
@@ -285,8 +291,11 @@ class BaseCore {
285
291
  accessRights: [utils_1.ACCESS_RIGHTS.GET],
286
292
  action: (args, opt) => __awaiter(this, void 0, void 0, function* () {
287
293
  var _d;
288
- const ids2use = this.beforeGetMany(args, opt);
289
- const items = yield ((_d = this.getContext().gateways[this.config.gatewayName]) === null || _d === void 0 ? void 0 : _d.getMany(ids2use));
294
+ const args2use = yield this.beforeGetMany(args, opt);
295
+ if (!Array.isArray(args2use === null || args2use === void 0 ? void 0 : args2use.ids)) {
296
+ return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, '', []);
297
+ }
298
+ const items = yield ((_d = this.getContext().gateways[this.config.gatewayName]) === null || _d === void 0 ? void 0 : _d.getMany(args2use.ids));
290
299
  const result = yield this.afterGetMany(items, opt);
291
300
  return this.success(result);
292
301
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",