@sdflc/backend-helpers 1.0.22 → 1.0.23

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.
@@ -23,10 +23,10 @@ var database_1 = require("./database");
23
23
  var createApiContext = function (args) {
24
24
  var _a = args || {}, cores = _a.cores, req = _a.req, getCoreContext = _a.getCoreContext, extendContext = _a.extendContext, inRequestId = _a.requestId;
25
25
  var keys = Object.keys(cores || {});
26
- var requestId = inRequestId || uuid_1.v4();
26
+ var requestId = inRequestId || (0, uuid_1.v4)();
27
27
  var coreContext = typeof getCoreContext === 'function' ? getCoreContext({ req: req }) : {};
28
28
  var context = keys.reduce(function (acc, key) {
29
- acc[lodash_1.camelCase(key)] = new cores[key](__assign(__assign({}, coreContext), { requestId: requestId }));
29
+ acc[(0, lodash_1.camelCase)(key)] = new cores[key](__assign(__assign({}, coreContext), { requestId: requestId }));
30
30
  return acc;
31
31
  }, {});
32
32
  context.requestId = requestId;
@@ -53,14 +53,14 @@ var createContextDefault = function (args) {
53
53
  var referer = req.headers['referer'];
54
54
  var ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
55
55
  var acceptLanguage = req.headers['accept-language'];
56
- var languages = utils_1.extractLanguages(acceptLanguage);
56
+ var languages = (0, utils_1.extractLanguages)(acceptLanguage);
57
57
  var requestedLang = req.query['lang'];
58
- var requestId = uuid_1.v4();
58
+ var requestId = (0, uuid_1.v4)();
59
59
  var db = new database_1.Database({
60
60
  knexConfig: knexConfig,
61
61
  dbSchema: dbSchema,
62
62
  });
63
- return exports.createApiContext({
63
+ return (0, exports.createApiContext)({
64
64
  cores: cores,
65
65
  req: req,
66
66
  requestId: requestId,
@@ -0,0 +1,9 @@
1
+ import { AppBaseCoreInterface, BaseCoreActionsInterface } from './interfaces';
2
+ import { BaseCore } from './baseCore';
3
+ declare class AppBaseCore extends BaseCore {
4
+ private gwSpace;
5
+ private interserviceApiKey?;
6
+ constructor(props: AppBaseCoreInterface);
7
+ authenticate(params: any, opt?: BaseCoreActionsInterface): Promise<(string | boolean)[]>;
8
+ }
9
+ export { AppBaseCore };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.AppBaseCore = void 0;
55
+ var baseCore_1 = require("./baseCore");
56
+ var AppBaseCore = /** @class */ (function (_super) {
57
+ __extends(AppBaseCore, _super);
58
+ function AppBaseCore(props) {
59
+ var _this = _super.call(this, props) || this;
60
+ _this.gwSpace = props.gwSpace;
61
+ _this.interserviceApiKey = props.interserviceApiKey;
62
+ return _this;
63
+ }
64
+ AppBaseCore.prototype.authenticate = function (params, opt) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var context, space;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ context = this.context;
71
+ return [4 /*yield*/, this.gwSpace.get(context.spaceId || '')];
72
+ case 1:
73
+ space = _a.sent();
74
+ if (!space) {
75
+ return [2 /*return*/, [false, 'Space Not Found']];
76
+ }
77
+ context.space = space;
78
+ if (this.interserviceApiKey && context.apiKey === this.interserviceApiKey) {
79
+ return [2 /*return*/, [true, '']];
80
+ }
81
+ else if (space.apiKey && space.apiKey !== context.apiKey) {
82
+ return [2 /*return*/, [false, 'API Key is invalid']];
83
+ }
84
+ return [2 /*return*/, [true, '']];
85
+ }
86
+ });
87
+ });
88
+ };
89
+ return AppBaseCore;
90
+ }(baseCore_1.BaseCore));
91
+ exports.AppBaseCore = AppBaseCore;
package/build/baseCore.js CHANGED
@@ -46,16 +46,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
49
  Object.defineProperty(exports, "__esModule", { value: true });
53
50
  exports.BaseCore = void 0;
54
51
  var api_helpers_1 = require("@sdflc/api-helpers");
55
52
  var utils_1 = require("@sdflc/utils");
56
53
  var utils_2 = require("./utils");
57
- var constants_1 = __importDefault(require("./constants"));
58
- var ACCESS_RIGHTS = constants_1.default.ACCESS_RIGHTS;
59
54
  var defaultAfterAndBefore = function (params, opt) {
60
55
  return params;
61
56
  };
@@ -88,7 +83,7 @@ var BaseCore = /** @class */ (function () {
88
83
  this.doingWhat = props.doingWhat;
89
84
  this.logger = props.logger || new utils_1.Logger({ level: props.logLevel });
90
85
  this.gateways = __assign({ gateway: this.gateway }, (props.gateways || {}));
91
- this.validators = utils_2.setFunctions((props === null || props === void 0 ? void 0 : props.validators) || {}, this.validators);
86
+ this.validators = (0, utils_2.setFunctions)((props === null || props === void 0 ? void 0 : props.validators) || {}, this.validators);
92
87
  this.doAuth = props.doAuth === true;
93
88
  this.requestId = props.requestId || '';
94
89
  }
@@ -137,7 +132,7 @@ var BaseCore = /** @class */ (function () {
137
132
  var _a = this.getDb().isDbError(ex), isDbError = _a[0], dbErrorMsg = _a[1];
138
133
  var isOpResult = typeof ex.getErrorSummary === 'function';
139
134
  var message = isOpResult ? ex.getErrorSummary() : ex.message;
140
- var sysMsg = "An exception has occurred on " + doingWhat + " with message " + message + ":";
135
+ var sysMsg = "An exception has occurred on ".concat(doingWhat, " with message ").concat(message, ":");
141
136
  var msg = '';
142
137
  if (isDbError) {
143
138
  msg = dbErrorMsg;
@@ -147,7 +142,7 @@ var BaseCore = /** @class */ (function () {
147
142
  msg = doingWhat['message'];
148
143
  }
149
144
  else {
150
- msg = "Sorry, something went wrong on " + doingWhat + "." + (isOpResult ? " Reason: " + ex.getErrorSummary() : '');
145
+ msg = "Sorry, something went wrong on ".concat(doingWhat, ".").concat(isOpResult ? " Reason: ".concat(ex.getErrorSummary()) : '');
151
146
  }
152
147
  this.logger.error(sysMsg, ex);
153
148
  }
@@ -256,7 +251,7 @@ var BaseCore = /** @class */ (function () {
256
251
  what = doingWhat;
257
252
  if (doingWhat !== step) {
258
253
  what = {
259
- message: step + " failed on " + doingWhat,
254
+ message: "".concat(step, " failed on ").concat(doingWhat),
260
255
  };
261
256
  }
262
257
  return [2 /*return*/, this.exceptionFailure(ex_1, what)];
@@ -273,14 +268,14 @@ var BaseCore = /** @class */ (function () {
273
268
  return [2 /*return*/, this.runAction({
274
269
  args: args,
275
270
  validate: this.validators.list,
276
- accessRights: [ACCESS_RIGHTS.LIST],
271
+ accessRights: [utils_1.ACCESS_RIGHTS.LIST],
277
272
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
278
273
  var object, items, result;
279
274
  var _a;
280
275
  return __generator(this, function (_b) {
281
276
  switch (_b.label) {
282
277
  case 0:
283
- this.logger.log("Requesting a list for " + this.name + ":", args);
278
+ this.logger.log("Requesting a list for ".concat(this.name, ":"), args);
284
279
  return [4 /*yield*/, this.beforeList(args, opt)];
285
280
  case 1:
286
281
  object = _b.sent();
@@ -309,7 +304,7 @@ var BaseCore = /** @class */ (function () {
309
304
  return [2 /*return*/, this.runAction({
310
305
  args: args,
311
306
  validate: this.validators.get,
312
- accessRights: [ACCESS_RIGHTS.GET],
307
+ accessRights: [utils_1.ACCESS_RIGHTS.GET],
313
308
  action: function (args) { return __awaiter(_this, void 0, void 0, function () {
314
309
  var id, item;
315
310
  var _a;
@@ -317,7 +312,7 @@ var BaseCore = /** @class */ (function () {
317
312
  switch (_b.label) {
318
313
  case 0:
319
314
  id = (args || {}).id;
320
- this.logger.log("Requesting an item for " + this.name + ":", args);
315
+ this.logger.log("Requesting an item for ".concat(this.name, ":"), args);
321
316
  return [4 /*yield*/, ((_a = this.gateway) === null || _a === void 0 ? void 0 : _a.get(id))];
322
317
  case 1:
323
318
  item = _b.sent();
@@ -339,7 +334,7 @@ var BaseCore = /** @class */ (function () {
339
334
  return [2 /*return*/, this.runAction({
340
335
  args: args,
341
336
  validate: this.validators.getMany,
342
- accessRights: [ACCESS_RIGHTS.GET],
337
+ accessRights: [utils_1.ACCESS_RIGHTS.GET],
343
338
  action: function (args) { return __awaiter(_this, void 0, void 0, function () {
344
339
  var ids, items;
345
340
  var _a;
@@ -347,7 +342,7 @@ var BaseCore = /** @class */ (function () {
347
342
  switch (_b.label) {
348
343
  case 0:
349
344
  ids = (args || {}).ids;
350
- this.logger.log("Requesting multiple items for " + this.name + ":", args);
345
+ this.logger.log("Requesting multiple items for ".concat(this.name, ":"), args);
351
346
  return [4 /*yield*/, ((_a = this.gateway) === null || _a === void 0 ? void 0 : _a.getMany(ids))];
352
347
  case 1:
353
348
  items = _b.sent();
@@ -369,7 +364,7 @@ var BaseCore = /** @class */ (function () {
369
364
  return [2 /*return*/, this.runAction({
370
365
  args: args,
371
366
  validate: this.validators.create,
372
- accessRights: [ACCESS_RIGHTS.CREATE],
367
+ accessRights: [utils_1.ACCESS_RIGHTS.CREATE],
373
368
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
374
369
  var params, object, item, result;
375
370
  var _a;
@@ -377,7 +372,7 @@ var BaseCore = /** @class */ (function () {
377
372
  switch (_b.label) {
378
373
  case 0:
379
374
  params = (args || {}).params;
380
- this.logger.log("Requesting creation of an item for " + this.name + ":", args);
375
+ this.logger.log("Requesting creation of an item for ".concat(this.name, ":"), args);
381
376
  return [4 /*yield*/, this.beforeCreate(params, opt)];
382
377
  case 1:
383
378
  object = _b.sent();
@@ -405,7 +400,7 @@ var BaseCore = /** @class */ (function () {
405
400
  return [2 /*return*/, this.runAction({
406
401
  args: args,
407
402
  validate: this.validators.createMany,
408
- accessRights: [ACCESS_RIGHTS.CREATE],
403
+ accessRights: [utils_1.ACCESS_RIGHTS.CREATE],
409
404
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
410
405
  var params, objects, items, result;
411
406
  var _a;
@@ -413,7 +408,7 @@ var BaseCore = /** @class */ (function () {
413
408
  switch (_b.label) {
414
409
  case 0:
415
410
  params = (args || {}).params;
416
- this.logger.log("Requesting creation of multiple items for " + this.name + ":", args);
411
+ this.logger.log("Requesting creation of multiple items for ".concat(this.name, ":"), args);
417
412
  return [4 /*yield*/, this.beforeCreateMany(params, opt)];
418
413
  case 1:
419
414
  objects = _b.sent();
@@ -441,7 +436,7 @@ var BaseCore = /** @class */ (function () {
441
436
  return [2 /*return*/, this.runAction({
442
437
  args: args,
443
438
  validate: this.validators.update,
444
- accessRights: [ACCESS_RIGHTS.UPDATE],
439
+ accessRights: [utils_1.ACCESS_RIGHTS.UPDATE],
445
440
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
446
441
  var _a, where, params, object, item, result;
447
442
  var _b;
@@ -449,7 +444,7 @@ var BaseCore = /** @class */ (function () {
449
444
  switch (_c.label) {
450
445
  case 0:
451
446
  _a = args || {}, where = _a.where, params = _a.params;
452
- this.logger.log("Requesting update of an item for " + this.name + ":", args);
447
+ this.logger.log("Requesting update of an item for ".concat(this.name, ":"), args);
453
448
  return [4 /*yield*/, this.beforeUpdate(params, opt)];
454
449
  case 1:
455
450
  object = _c.sent();
@@ -477,7 +472,7 @@ var BaseCore = /** @class */ (function () {
477
472
  return [2 /*return*/, this.runAction({
478
473
  args: args,
479
474
  validate: this.validators.updateMany,
480
- accessRights: [ACCESS_RIGHTS.UPDATE],
475
+ accessRights: [utils_1.ACCESS_RIGHTS.UPDATE],
481
476
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
482
477
  var params, object, items, result;
483
478
  var _a;
@@ -485,7 +480,7 @@ var BaseCore = /** @class */ (function () {
485
480
  switch (_b.label) {
486
481
  case 0:
487
482
  params = (args || {}).params;
488
- this.logger.log("Requesting update of an item for " + this.name + ":", args);
483
+ this.logger.log("Requesting update of an item for ".concat(this.name, ":"), args);
489
484
  return [4 /*yield*/, this.beforeUpdateMany(params, opt)];
490
485
  case 1:
491
486
  object = _b.sent();
@@ -513,7 +508,7 @@ var BaseCore = /** @class */ (function () {
513
508
  return [2 /*return*/, this.runAction({
514
509
  args: args,
515
510
  validate: this.validators.set,
516
- accessRights: [ACCESS_RIGHTS.CREATE, ACCESS_RIGHTS.UPDATE],
511
+ accessRights: [utils_1.ACCESS_RIGHTS.CREATE, utils_1.ACCESS_RIGHTS.UPDATE],
517
512
  action: function (args, opt /* { setStep, validatedItems, sameRequest } */) { return __awaiter(_this, void 0, void 0, function () {
518
513
  var params, object, items, result;
519
514
  var _a;
@@ -521,7 +516,7 @@ var BaseCore = /** @class */ (function () {
521
516
  switch (_b.label) {
522
517
  case 0:
523
518
  params = (args || {}).params;
524
- this.logger.log("Requesting setting of item(s) for " + this.name + ":", args);
519
+ this.logger.log("Requesting setting of item(s) for ".concat(this.name, ":"), args);
525
520
  return [4 /*yield*/, this.beforeSet(params, opt)];
526
521
  case 1:
527
522
  object = _b.sent();
@@ -549,7 +544,7 @@ var BaseCore = /** @class */ (function () {
549
544
  return [2 /*return*/, this.runAction({
550
545
  args: args,
551
546
  validate: this.validators.remove,
552
- accessRights: [ACCESS_RIGHTS.REMOVE],
547
+ accessRights: [utils_1.ACCESS_RIGHTS.REMOVE],
553
548
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
554
549
  var where, object, items, result;
555
550
  var _a;
@@ -557,7 +552,7 @@ var BaseCore = /** @class */ (function () {
557
552
  switch (_b.label) {
558
553
  case 0:
559
554
  where = (args || {}).where;
560
- this.logger.log("Requesting removal of an item for " + this.name + ":", args);
555
+ this.logger.log("Requesting removal of an item for ".concat(this.name, ":"), args);
561
556
  return [4 /*yield*/, this.beforeRemove(where, opt)];
562
557
  case 1:
563
558
  object = _b.sent();
@@ -585,7 +580,7 @@ var BaseCore = /** @class */ (function () {
585
580
  return [2 /*return*/, this.runAction({
586
581
  args: args,
587
582
  validate: this.validators.removeMany,
588
- accessRights: [ACCESS_RIGHTS.REMOVE],
583
+ accessRights: [utils_1.ACCESS_RIGHTS.REMOVE],
589
584
  action: function (args, opt) { return __awaiter(_this, void 0, void 0, function () {
590
585
  var where, object, items, result;
591
586
  var _a;
@@ -593,7 +588,7 @@ var BaseCore = /** @class */ (function () {
593
588
  switch (_b.label) {
594
589
  case 0:
595
590
  where = (args || {}).where;
596
- this.logger.log("Requesting removal of multiple items for " + this.name + ":", args);
591
+ this.logger.log("Requesting removal of multiple items for ".concat(this.name, ":"), args);
597
592
  return [4 /*yield*/, this.beforeRemoveMany(where, opt)];
598
593
  case 1:
599
594
  object = _b.sent();
@@ -1,5 +1,5 @@
1
1
  import { BaseGatewayInterface, ListArgsInterface } from './interfaces';
2
- import { BaseCore } from '.';
2
+ import { BaseCore } from './baseCore';
3
3
  declare class BaseGateway {
4
4
  protected config: BaseGatewayInterface;
5
5
  protected loader: any;
@@ -14,7 +14,7 @@ declare class BaseGateway {
14
14
  transformOnRemove(args?: any): Promise<any>;
15
15
  getDb(): import("./database").Database;
16
16
  getBuilder(): any;
17
- getIdField(): string;
17
+ getIdField(): any;
18
18
  getCore(): BaseCore;
19
19
  setCore(core: BaseCore): void;
20
20
  get(id: any): Promise<any>;
@@ -51,9 +51,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.BaseGateway = void 0;
54
+ var lodash_1 = require("lodash");
54
55
  var dataCache_1 = require("./dataCache");
55
56
  var constants_1 = __importDefault(require("./constants"));
56
- var lodash_1 = require("lodash");
57
57
  var ID_FIELD = constants_1.default.ID_FIELD;
58
58
  var defaultUpdateRemoveFilter = function (config) { return function (query, params) {
59
59
  var idName = config.idField || ID_FIELD;
@@ -394,7 +394,7 @@ var BaseGateway = /** @class */ (function () {
394
394
  results = [];
395
395
  idField = this.getIdField();
396
396
  return [4 /*yield*/, this.getBuilder()
397
- .insert(lodash_1.castArray(params))
397
+ .insert((0, lodash_1.castArray)(params))
398
398
  .returning(this.returnFields)
399
399
  .onConflict(this.config.setFields || idField)
400
400
  .merge()];
@@ -7,8 +7,9 @@ exports.buildDefaultGatewayProps = void 0;
7
7
  var uuid_1 = require("uuid");
8
8
  var dayjs_1 = __importDefault(require("dayjs"));
9
9
  var lodash_1 = require("lodash");
10
+ var utils_1 = require("@sdflc/utils");
10
11
  var constants_1 = __importDefault(require("./constants"));
11
- var FIELDS = constants_1.default.FIELDS, STATUSES = constants_1.default.STATUSES;
12
+ var FIELDS = constants_1.default.FIELDS;
12
13
  var buildDefaultGatewayProps = function (args) {
13
14
  var config = args.config, tableName = args.tableName, filter = args.filter, updateFilter = args.updateFilter, hasStatus = args.hasStatus, hasRemovedAt = args.hasRemovedAt, hasRemovedAtStr = args.hasRemovedAtStr, setFields = args.setFields, idField = args.idField, activeStatuses = args.activeStatuses, redisClient = args.redisClient, context = args.context, buildKey = args.buildKey, returnFields = args.returnFields;
14
15
  return {
@@ -35,7 +36,7 @@ var buildDefaultGatewayProps = function (args) {
35
36
  cacheTtl: config.cacheTtl,
36
37
  noCache: false,
37
38
  idGenerator: function () {
38
- var id = uuid_1.v4();
39
+ var id = (0, uuid_1.v4)();
39
40
  return id;
40
41
  },
41
42
  insertFormatter: function (args) {
@@ -47,14 +48,14 @@ var buildDefaultGatewayProps = function (args) {
47
48
  updateFilter: function (query, params) {
48
49
  var id = (params || {}).id;
49
50
  if (id) {
50
- query.whereIn(FIELDS.ID, lodash_1.castArray(id));
51
+ query.whereIn(FIELDS.ID, (0, lodash_1.castArray)(id));
51
52
  }
52
53
  if (typeof updateFilter === 'function') {
53
54
  updateFilter(query, params);
54
55
  }
55
56
  },
56
57
  removeFormatter: function () {
57
- var removalTime = dayjs_1.default();
58
+ var removalTime = (0, dayjs_1.default)();
58
59
  var removedAt = removalTime.toDate();
59
60
  var obj = {
60
61
  removedAt: removedAt,
@@ -63,7 +64,7 @@ var buildDefaultGatewayProps = function (args) {
63
64
  obj[FIELDS.REMOVED_AT_STR] = removalTime.format('YYYYMMDDTHHmmssZ');
64
65
  }
65
66
  if (hasStatus === undefined || hasStatus === true) {
66
- obj[FIELDS.STATUS] = STATUSES.REMOVED;
67
+ obj[FIELDS.STATUS] = utils_1.STATUSES.REMOVED;
67
68
  }
68
69
  return obj;
69
70
  },
@@ -77,7 +78,7 @@ var buildDefaultGatewayProps = function (args) {
77
78
  }
78
79
  query = query.whereIn(FIELDS.ID, arr.map(function (item) { return item[FIELDS.ID]; }));
79
80
  if (hasStatus === undefined || hasStatus === true) {
80
- query.where(FIELDS.STATUS, '!=', STATUSES.REMOVED);
81
+ query.where(FIELDS.STATUS, '!=', utils_1.STATUSES.REMOVED);
81
82
  }
82
83
  },
83
84
  returnFields: returnFields || [FIELDS.ID],
@@ -11,7 +11,7 @@ var checkArray = function (arr, validator, prefix) {
11
11
  var itemResult = validator.validateSync(item)[0];
12
12
  if (itemResult) {
13
13
  Object.keys(itemResult.errors).forEach(function (key) {
14
- result.addError((prefix || '') + "[" + idx + "]." + key, itemResult.errors[key].message);
14
+ result.addError("".concat(prefix || '', "[").concat(idx, "].").concat(key), itemResult.errors[key].message);
15
15
  });
16
16
  }
17
17
  });
@@ -17,17 +17,17 @@ var path_1 = require("path");
17
17
  var dotenv_safe_1 = require("dotenv-safe");
18
18
  var buildConfig = function (dirName, opt) {
19
19
  var opt2use = opt || {};
20
- dotenv_safe_1.config({
21
- path: path_1.resolve(dirName, opt2use.envFile || '.env'),
20
+ (0, dotenv_safe_1.config)({
21
+ path: (0, path_1.resolve)(dirName, opt2use.envFile || '.env'),
22
22
  allowEmptyValues: opt2use.allowEmptyValues != null ? opt2use.allowEmptyValues : true,
23
- example: path_1.join(dirName, opt2use.envFileExample || '.env.example'),
23
+ example: (0, path_1.join)(dirName, opt2use.envFileExample || '.env.example'),
24
24
  });
25
25
  var env = Object.assign({ NODE_ENV: opt2use.defaultNodeEnv || 'development' }, process.env);
26
26
  /**
27
27
  * Creates an application settings consisting of environment variables
28
28
  */
29
29
  var envVars = Object.keys(env).reduce(function (acc, key) {
30
- acc[lodash_1.camelCase(key)] = env[key];
30
+ acc[(0, lodash_1.camelCase)(key)] = env[key];
31
31
  return acc;
32
32
  }, {});
33
33
  return __assign(__assign({}, envVars), { nodeEnv: env.NODE_ENV, isProduction: env.NODE_ENV === 'production' });
@@ -1,8 +1,5 @@
1
1
  declare const _default: {
2
- ID_FIELD: string;
2
+ ID_FIELD: any;
3
3
  FIELDS: any;
4
- STATUSES: any;
5
- ACCESS_RIGHTS: any;
6
- VALUE_TYPES: any;
7
4
  };
8
5
  export default _default;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var ID_FIELD = 'id';
4
3
  var FIELDS = {
5
4
  ID: 'id',
6
5
  STATUS: 'status',
@@ -19,39 +18,8 @@ var FIELDS = {
19
18
  ORDER_NO: 'order_no',
20
19
  SPACE_ID: 'space_id',
21
20
  };
22
- var STATUSES = {
23
- TEST: 50,
24
- ACTIVE: 100,
25
- DRAFT: 200,
26
- PENDING: 300,
27
- BLOCKED: 1000,
28
- DISABLED: 5000,
29
- REMOVED: 10000,
30
- };
31
- var ACCESS_RIGHTS = {
32
- LIST: 1,
33
- GET: 2,
34
- CREATE: 4,
35
- UPDATE: 8,
36
- REMOVE: 16,
37
- RUN: 32,
38
- };
39
- var VALUE_TYPES = {
40
- NUMBER: 100,
41
- INTEGER: 101,
42
- FLOAT: 102,
43
- CURRENCY: 103,
44
- BOOLEAN: 200,
45
- STRING: 300,
46
- JSON: 400,
47
- EMAIL: 1001,
48
- PHONE: 1002,
49
- URL: 1003,
50
- };
21
+ var ID_FIELD = FIELDS.ID;
51
22
  exports.default = {
52
23
  ID_FIELD: ID_FIELD,
53
24
  FIELDS: FIELDS,
54
- STATUSES: STATUSES,
55
- ACCESS_RIGHTS: ACCESS_RIGHTS,
56
- VALUE_TYPES: VALUE_TYPES,
57
25
  };
@@ -60,7 +60,7 @@ var DataCache = /** @class */ (function () {
60
60
  this.config = props;
61
61
  this.buildKey = typeof buildKey === 'function' ? buildKey : utils_1.buildKey;
62
62
  this.batchLoaderDefault = this.batchLoaderDefault.bind(this);
63
- this.redisDataLoader = redisClient ? redis_dataloader_1.default({ redis: redisClient }) : null;
63
+ this.redisDataLoader = redisClient ? (0, redis_dataloader_1.default)({ redis: redisClient }) : null;
64
64
  var fn = typeof loaderFn === 'function' ? loaderFn : this.batchLoaderDefault(props);
65
65
  var prefixToUse = (context === null || context === void 0 ? void 0 : context.keyPrefix) || keyPrefix;
66
66
  this.init(fn, prefixToUse, context);
package/build/database.js CHANGED
@@ -51,7 +51,7 @@ var Database = /** @class */ (function () {
51
51
  if (!props.knexConfig) {
52
52
  throw new Error('The Database class expects to have `knexConfig` in its constructor props');
53
53
  }
54
- this.knexHandle = knex_1.default(props.knexConfig);
54
+ this.knexHandle = (0, knex_1.default)(props.knexConfig);
55
55
  this.dbSchema = props.dbSchema || '';
56
56
  this.trx = props.trx;
57
57
  }
@@ -187,7 +187,7 @@ var Database = /** @class */ (function () {
187
187
  if (mapBy) {
188
188
  fnBuildKey_1 = typeof buildKey === 'function' ? buildKey : utils_1.buildKey;
189
189
  dbResults = dbResults.reduce(function (acc, item) {
190
- var key = fnBuildKey_1(item[lodash_1.camelCase(mapBy)]);
190
+ var key = fnBuildKey_1(item[(0, lodash_1.camelCase)(mapBy)]);
191
191
  if (Array.isArray(calculated) && calculated.length > 0) {
192
192
  _this.doCalculated(item, calculated);
193
193
  }
@@ -44,9 +44,9 @@ var bluebird_1 = __importDefault(require("bluebird"));
44
44
  var lodash_1 = require("lodash");
45
45
  var SQLS = {
46
46
  pg: {
47
- listTablesSchema: function (appSettings) { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '" + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + "';\n "; },
47
+ listTablesSchema: function (appSettings) { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '".concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, "';\n "); },
48
48
  listTables: function () { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n "; },
49
- dropTablesSchema: function (appSettings) { return "\n SELECT 'DROP TABLE IF EXISTS " + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + ".' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '" + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + "';\n "; },
49
+ dropTablesSchema: function (appSettings) { return "\n SELECT 'DROP TABLE IF EXISTS ".concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, ".' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '").concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, "';\n "); },
50
50
  dropTables: function () { return "\n SELECT 'DROP TABLE IF EXISTS ' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES';\n "; },
51
51
  },
52
52
  };
@@ -169,7 +169,7 @@ exports.dbReset = dbReset;
169
169
  * to { table1: [], table2: [], table3: []}
170
170
  */
171
171
  var dbTransformSeedsToObject = function (generatedSeedArrays) {
172
- return lodash_1.reduce(generatedSeedArrays, function (acc, cur) {
172
+ return (0, lodash_1.reduce)(generatedSeedArrays, function (acc, cur) {
173
173
  for (var key in cur) {
174
174
  acc[key] = cur[key];
175
175
  }
@@ -65,9 +65,9 @@ var lodash_1 = require("lodash");
65
65
  var utils_1 = require("@sdflc/utils");
66
66
  var SQLS = {
67
67
  pg: {
68
- listTablesSchema: function (appSettings) { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '" + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + "';\n "; },
68
+ listTablesSchema: function (appSettings) { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '".concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, "';\n "); },
69
69
  listTables: function () { return "\n SELECT TABLE_NAME as table_name\n FROM INFORMATION_SCHEMA.TABLES\n "; },
70
- dropTablesSchema: function (appSettings) { return "\n SELECT 'DROP TABLE IF EXISTS " + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + ".' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '" + (appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema) + "';\n "; },
70
+ dropTablesSchema: function (appSettings) { return "\n SELECT 'DROP TABLE IF EXISTS ".concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, ".' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES\n WHERE TABLE_SCHEMA = '").concat(appSettings === null || appSettings === void 0 ? void 0 : appSettings.dbSchema, "';\n "); },
71
71
  dropTables: function () { return "\n SELECT 'DROP TABLE IF EXISTS ' || TABLE_NAME || ';' as cmd\n FROM INFORMATION_SCHEMA.TABLES';\n "; },
72
72
  },
73
73
  };
@@ -91,9 +91,9 @@ var DbMigratorAndSeeder = /** @class */ (function () {
91
91
  _a.sent();
92
92
  _a.label = 3;
93
93
  case 3:
94
- this.logger.log("Ran " + result[1].length + " migration(s)");
94
+ this.logger.log("Ran ".concat(result[1].length, " migration(s)"));
95
95
  version = this.knexHandle.migrate.currentVersion();
96
- this.logger.log("Current version of database: " + version);
96
+ this.logger.log("Current version of database: ".concat(version));
97
97
  return [2 /*return*/];
98
98
  }
99
99
  });
@@ -106,7 +106,7 @@ var DbMigratorAndSeeder = /** @class */ (function () {
106
106
  * to { table1: [], table2: [], table3: []}
107
107
  */
108
108
  DbMigratorAndSeeder.prototype.transformSeedsToObject = function (generatedSeedArrays) {
109
- return lodash_1.reduce(generatedSeedArrays, function (acc, cur) {
109
+ return (0, lodash_1.reduce)(generatedSeedArrays, function (acc, cur) {
110
110
  for (var key in cur) {
111
111
  acc[key] = cur[key];
112
112
  }
@@ -259,11 +259,11 @@ var DbMigratorAndSeeder = /** @class */ (function () {
259
259
  switch (_a.label) {
260
260
  case 0:
261
261
  seedGroups = [];
262
- seedFileNames = lodash_1.flatten(seedFiles);
263
- return [4 /*yield*/, Promise.all(lodash_1.map(seedFileNames, function (filename) { return Promise.resolve().then(function () { return __importStar(require(path_1.default.join(dirname, "./objects/" + filename + ".js"))); }); }))];
262
+ seedFileNames = (0, lodash_1.flatten)(seedFiles);
263
+ return [4 /*yield*/, Promise.all((0, lodash_1.map)(seedFileNames, function (filename) { return Promise.resolve().then(function () { return __importStar(require(path_1.default.join(dirname, "./objects/".concat(filename, ".js")))); }); }))];
264
264
  case 1:
265
265
  seedFnExports = _a.sent();
266
- seedFns = lodash_1.map(seedFnExports, 'default');
266
+ seedFns = (0, lodash_1.map)(seedFnExports, 'default');
267
267
  seedFnsMap = {};
268
268
  for (i = 0; i < seedFileNames.length; i++) {
269
269
  seedFileName = seedFileNames[i];
@@ -274,7 +274,7 @@ var DbMigratorAndSeeder = /** @class */ (function () {
274
274
  var _a;
275
275
  var seedFn = seedFnsMap[filename];
276
276
  var seed = seedFn(seeds);
277
- var filenameCamel = lodash_1.camelCase(filename);
277
+ var filenameCamel = (0, lodash_1.camelCase)(filename);
278
278
  seeds[filenameCamel] = seed;
279
279
  return Object.assign((_a = {}, _a[filenameCamel] = seed, _a), group);
280
280
  }, {}));
@@ -286,7 +286,7 @@ var DbMigratorAndSeeder = /** @class */ (function () {
286
286
  });
287
287
  };
288
288
  DbMigratorAndSeeder.prototype.removeSeedsFromDb = function (seedFiles) {
289
- var tablesToReset = lodash_1.flatten(seedFiles).reverse();
289
+ var tablesToReset = (0, lodash_1.flatten)(seedFiles).reverse();
290
290
  this.logger.log('Deleting records from tables: ', tablesToReset);
291
291
  return this.cleanDb(tablesToReset);
292
292
  };
package/build/dbSeeder.js CHANGED
@@ -68,11 +68,11 @@ var generateSeeds = function (dirname, seedFiles) { return __awaiter(void 0, voi
68
68
  switch (_a.label) {
69
69
  case 0:
70
70
  seedGroups = [];
71
- seedFileNames = lodash_1.flatten(seedFiles);
72
- return [4 /*yield*/, Promise.all(lodash_1.map(seedFileNames, function (filename) { return Promise.resolve().then(function () { return __importStar(require(path_1.default.join(dirname, "./objects/" + filename + ".js"))); }); }))];
71
+ seedFileNames = (0, lodash_1.flatten)(seedFiles);
72
+ return [4 /*yield*/, Promise.all((0, lodash_1.map)(seedFileNames, function (filename) { return Promise.resolve().then(function () { return __importStar(require(path_1.default.join(dirname, "./objects/".concat(filename, ".js")))); }); }))];
73
73
  case 1:
74
74
  seedFnExports = _a.sent();
75
- seedFns = lodash_1.map(seedFnExports, 'default');
75
+ seedFns = (0, lodash_1.map)(seedFnExports, 'default');
76
76
  seedFnsMap = {};
77
77
  for (i = 0; i < seedFileNames.length; i++) {
78
78
  seedFileName = seedFileNames[i];
@@ -83,7 +83,7 @@ var generateSeeds = function (dirname, seedFiles) { return __awaiter(void 0, voi
83
83
  var _a;
84
84
  var seedFn = seedFnsMap[filename];
85
85
  var seed = seedFn(seeds);
86
- var filenameCamel = lodash_1.camelCase(filename);
86
+ var filenameCamel = (0, lodash_1.camelCase)(filename);
87
87
  seeds[filenameCamel] = seed;
88
88
  return Object.assign((_a = {}, _a[filenameCamel] = seed, _a), group);
89
89
  }, {}));
@@ -94,9 +94,9 @@ var generateSeeds = function (dirname, seedFiles) { return __awaiter(void 0, voi
94
94
  });
95
95
  }); };
96
96
  var removeSeedsFromDb = function (seedFiles, knexHandle, config) {
97
- var tablesToReset = lodash_1.flatten(seedFiles).reverse();
97
+ var tablesToReset = (0, lodash_1.flatten)(seedFiles).reverse();
98
98
  console.log('Deleting records from tables: ', tablesToReset);
99
- return dbHelpers_1.dbClean(tablesToReset, knexHandle, config);
99
+ return (0, dbHelpers_1.dbClean)(tablesToReset, knexHandle, config);
100
100
  };
101
101
  var insertRecords = function (seedGroups, knexHandle, config) {
102
102
  var dbSchema = (config || {}).dbSchema;
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dbFieldAddDefaults = exports.defaultFields = exports.addUserId = exports.addSpaceId = exports.addAmount = exports.addOrderNo = void 0;
7
- var constants_1 = __importDefault(require("./constants"));
8
7
  var utils_1 = require("@sdflc/utils");
9
- var FIELDS = constants_1.default.FIELDS, STATUSES = constants_1.default.STATUSES;
8
+ var constants_1 = __importDefault(require("./constants"));
9
+ var FIELDS = constants_1.default.FIELDS;
10
10
  var dbFieldAddDefaults = function (table, opt) {
11
11
  var _a = opt || {}, addUserInfo = _a.addUserInfo, addVersion = _a.addVersion, addStatus = _a.addStatus, skipTimestamps = _a.skipTimestamps, skipRemovedAtStr = _a.skipRemovedAtStr;
12
12
  if (addStatus) {
13
13
  table
14
14
  .integer(FIELDS.STATUS)
15
- .defaultTo(STATUSES.ACTIVE)
15
+ .defaultTo(utils_1.STATUSES.ACTIVE)
16
16
  .comment('The field is used to specify record status: 50 - Test, 100 - Active, 200 - Draft, 300 - Pending, 1000 - Blocked, 5000 - Disabled, 10000 - Removed');
17
17
  }
18
18
  if (addVersion) {
@@ -57,7 +57,7 @@ exports.addAmount = addAmount;
57
57
  var addSpaceId = function (table, opt) {
58
58
  var chain = table.text(FIELDS.SPACE_ID).notNullable().comment('Reference to the space table');
59
59
  if ((opt === null || opt === void 0 ? void 0 : opt.addForeignKey) === true) {
60
- table.foreign(FIELDS.SPACE_ID).references("space." + FIELDS.ID).onUpdate('CASCADE').onDelete('CASCADE');
60
+ table.foreign(FIELDS.SPACE_ID).references("space.".concat(FIELDS.ID)).onUpdate('CASCADE').onDelete('CASCADE');
61
61
  }
62
62
  return chain;
63
63
  };
@@ -65,7 +65,7 @@ exports.addSpaceId = addSpaceId;
65
65
  var addUserId = function (table, opt) {
66
66
  var chain = table.uuid(FIELDS.USER_ID).notNullable().comment('Reference to the user table');
67
67
  if ((opt === null || opt === void 0 ? void 0 : opt.addForeignKey) === true) {
68
- table.foreign(FIELDS.userId).references("user." + FIELDS.ID).onUpdate('CASCADE').onDelete('CASCADE');
68
+ table.foreign(FIELDS.userId).references("user.".concat(FIELDS.ID)).onUpdate('CASCADE').onDelete('CASCADE');
69
69
  }
70
70
  return chain;
71
71
  };
package/build/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { checkArray, createErrorOnCheckError } from './checkItHelpers';
11
11
  export { DataCache } from './dataCache';
12
12
  export { BaseGateway } from './baseGateway';
13
13
  export { BaseCore } from './baseCore';
14
+ export { AppBaseCore } from './appBaseCore';
14
15
  export { createApiContext, createContextDefault } from './apiContext';
15
16
  export { BaseController } from './baseController';
16
17
  export { dbFieldAddDefaults } from './dbTableHelpers';
package/build/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkPassword = exports.getSaltAndHash = exports.buildDefaultGatewayProps = exports.constants = exports.verifyUserToken = exports.createUserToken = exports.buildDefaultResolvers = exports.dbFieldAddDefaults = exports.BaseController = exports.createContextDefault = exports.createApiContext = exports.BaseCore = exports.BaseGateway = exports.DataCache = exports.createErrorOnCheckError = exports.checkArray = exports.createRedisClient = exports.buildKnexConfig = exports.dbSeed = exports.DbMigratorAndSeeder = exports.dbRunMigrations = exports.dbTransformSeedsToObject = exports.dbReset = exports.dbWipe = exports.dbClean = exports.dbListTables = exports.dbCleanTable = exports.Database = exports.buildConfig = void 0;
6
+ exports.checkPassword = exports.getSaltAndHash = exports.buildDefaultGatewayProps = exports.constants = exports.verifyUserToken = exports.createUserToken = exports.buildDefaultResolvers = exports.dbFieldAddDefaults = exports.BaseController = exports.createContextDefault = exports.createApiContext = exports.AppBaseCore = exports.BaseCore = exports.BaseGateway = exports.DataCache = exports.createErrorOnCheckError = exports.checkArray = exports.createRedisClient = exports.buildKnexConfig = exports.dbSeed = exports.DbMigratorAndSeeder = exports.dbRunMigrations = exports.dbTransformSeedsToObject = exports.dbReset = exports.dbWipe = exports.dbClean = exports.dbListTables = exports.dbCleanTable = exports.Database = exports.buildConfig = void 0;
7
7
  var constants_1 = __importDefault(require("./constants"));
8
8
  exports.constants = constants_1.default;
9
9
  var configBulder_1 = require("./configBulder");
@@ -35,6 +35,8 @@ var baseGateway_1 = require("./baseGateway");
35
35
  Object.defineProperty(exports, "BaseGateway", { enumerable: true, get: function () { return baseGateway_1.BaseGateway; } });
36
36
  var baseCore_1 = require("./baseCore");
37
37
  Object.defineProperty(exports, "BaseCore", { enumerable: true, get: function () { return baseCore_1.BaseCore; } });
38
+ var appBaseCore_1 = require("./appBaseCore");
39
+ Object.defineProperty(exports, "AppBaseCore", { enumerable: true, get: function () { return appBaseCore_1.AppBaseCore; } });
38
40
  var apiContext_1 = require("./apiContext");
39
41
  Object.defineProperty(exports, "createApiContext", { enumerable: true, get: function () { return apiContext_1.createApiContext; } });
40
42
  Object.defineProperty(exports, "createContextDefault", { enumerable: true, get: function () { return apiContext_1.createContextDefault; } });
@@ -0,0 +1,6 @@
1
+ import { BaseGateway } from '../baseGateway';
2
+ import { BaseCoreInterface } from './BaseCoreInterface';
3
+ export interface AppBaseCoreInterface extends BaseCoreInterface {
4
+ gwSpace: BaseGateway;
5
+ interserviceApiKey?: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,6 +5,7 @@ export { ListArgsInterface } from './ListArgsInterface';
5
5
  export { SortItemInterface } from './SortItemInterface';
6
6
  export { PaginationInterface } from './PaginationInterface';
7
7
  export { BaseCoreInterface } from './BaseCoreInterface';
8
+ export { AppBaseCoreInterface } from './AppBaseCoreInterface';
8
9
  export { CoreActionInterface } from './CoreActionInterface';
9
10
  export { ApiContextInterface } from './ApiContextInterface';
10
11
  export { DbFieldAddDefaultInterface } from './DbFieldAddDefaultInterface';
@@ -26,14 +26,14 @@ var camelResponse = function (result) {
26
26
  if (!result || result.rows) {
27
27
  return result;
28
28
  }
29
- return utils_1.camelKeys(result);
29
+ return (0, utils_1.camelKeys)(result);
30
30
  };
31
31
  var buildKnexConfig = function (dirName, appConfig) {
32
32
  var dbType = appConfig.dbType, dbHost = appConfig.dbHost, dbPort = appConfig.dbPort, dbName = appConfig.dbName, dbSchema = appConfig.dbSchema, dbUser = appConfig.dbUser, dbPassword = appConfig.dbPassword, debug = appConfig.debug, nodeEnv = appConfig.nodeEnv, migrationsTemplateFileName = appConfig.migrationsTemplateFileName, migrationsFolder = appConfig.migrationsFolder, migrationsTable = appConfig.migrationsTable, useSchemaForMigrationsTable = appConfig.useSchemaForMigrationsTable, seedsFolder = appConfig.seedsFolder, seedsFolderDev = appConfig.seedsFolderDev, seedsFolderProd = appConfig.seedsFolderProd;
33
33
  var sharedConfig = {
34
34
  client: dbType || 'pg',
35
35
  postProcessResponse: camelResponse,
36
- wrapIdentifier: function (value, origImpl) { return (value === '*' ? origImpl(value) : origImpl(lodash_1.snakeCase(value))); },
36
+ wrapIdentifier: function (value, origImpl) { return (value === '*' ? origImpl(value) : origImpl((0, lodash_1.snakeCase)(value))); },
37
37
  connection: {
38
38
  host: dbHost,
39
39
  port: dbPort,
@@ -48,18 +48,18 @@ var buildKnexConfig = function (dirName, appConfig) {
48
48
  stub: path_1.default.join(dirName, migrationsTemplateFileName || defaultMigrationsTemplateFileName),
49
49
  directory: path_1.default.join(dirName, migrationsFolder || defaultMigrationsFolder),
50
50
  tableName: migrationsTable ||
51
- "" + (useSchemaForMigrationsTable ? dbSchema + "." : '') + (migrationsTable || defaultMigrationsTable),
51
+ "".concat(useSchemaForMigrationsTable ? "".concat(dbSchema, ".") : '').concat(migrationsTable || defaultMigrationsTable),
52
52
  }, seeds: {
53
53
  directory: path_1.default.join(dirName, seedsFolderDev || seedsFolder || defaultSeedsFolder),
54
54
  } }),
55
55
  production: __assign(__assign({}, sharedConfig), { debug: debug, migrations: {
56
56
  directory: path_1.default.join(dirName, migrationsFolder || defaultMigrationsFolder),
57
57
  tableName: migrationsTable ||
58
- "" + (useSchemaForMigrationsTable ? dbSchema + "." : '') + (migrationsTable || defaultMigrationsTable),
58
+ "".concat(useSchemaForMigrationsTable ? "".concat(dbSchema, ".") : '').concat(migrationsTable || defaultMigrationsTable),
59
59
  }, seeds: {
60
60
  directory: path_1.default.join(dirName, seedsFolderProd || seedsFolder || defaultSeedsFolder),
61
61
  } }),
62
62
  };
63
- return lodash_1.get(config, nodeEnv);
63
+ return (0, lodash_1.get)(config, nodeEnv);
64
64
  };
65
65
  exports.buildKnexConfig = buildKnexConfig;
@@ -17,56 +17,55 @@ var buildDefaultResolvers = function (args) {
17
17
  var Query = __assign({}, (query || {}));
18
18
  var Mutation = __assign({}, (mutation || {}));
19
19
  if (disableList !== true) {
20
- Query[prefix + "List"] = function (parent, args, context) {
20
+ Query["".concat(prefix, "List")] = function (parent, args, context) {
21
21
  return context[core].list(args);
22
22
  };
23
23
  }
24
24
  if (disableGet !== true) {
25
- Query[prefix + "Get"] = function (parent, args, context) {
25
+ Query["".concat(prefix, "Get")] = function (parent, args, context) {
26
26
  return context[core].get(args);
27
27
  };
28
28
  }
29
29
  if (disableGetMany !== true) {
30
- Query[prefix + "GetMany"] = function (parent, args, context) {
30
+ Query["".concat(prefix, "GetMany")] = function (parent, args, context) {
31
31
  return context[core].getMany(args);
32
32
  };
33
33
  }
34
34
  if (disableCreate !== true) {
35
- Mutation[prefix + "Create"] = function (parent, args, context) {
35
+ Mutation["".concat(prefix, "Create")] = function (parent, args, context) {
36
36
  return context[core].create(args);
37
37
  };
38
38
  }
39
39
  if (disableCreateMany !== true) {
40
- Mutation[prefix + "CreateMany"] = function (parent, args, context) {
40
+ Mutation["".concat(prefix, "CreateMany")] = function (parent, args, context) {
41
41
  return context[core].createMany(args);
42
42
  };
43
43
  }
44
44
  if (disableUpdate !== true) {
45
- Mutation[prefix + "Update"] = function (parent, args, context) {
45
+ Mutation["".concat(prefix, "Update")] = function (parent, args, context) {
46
46
  return context[core].update(args);
47
47
  };
48
48
  }
49
49
  if (disableUpdateMany !== true) {
50
- Mutation[prefix + "UpdateMany"] = function (parent, args, context) {
50
+ Mutation["".concat(prefix, "UpdateMany")] = function (parent, args, context) {
51
51
  return context[core].updateMany(args);
52
52
  };
53
53
  }
54
54
  if (disableSet !== true) {
55
- Mutation[prefix + "Set"] = function (parent, args, context) {
55
+ Mutation["".concat(prefix, "Set")] = function (parent, args, context) {
56
56
  return context[core].set(args);
57
57
  };
58
58
  }
59
59
  if (disableRemove !== true) {
60
- Mutation[prefix + "Remove"] = function (parent, args, context) {
60
+ Mutation["".concat(prefix, "Remove")] = function (parent, args, context) {
61
61
  return context[core].remove(args);
62
62
  };
63
63
  }
64
64
  if (disableRemoveMany !== true) {
65
- Mutation[prefix + "RemoveMany"] = function (parent, args, context) {
65
+ Mutation["".concat(prefix, "RemoveMany")] = function (parent, args, context) {
66
66
  return context[core].removeMany(args);
67
67
  };
68
68
  }
69
- return __assign({ Query: Query,
70
- Mutation: Mutation }, (types || {}));
69
+ return __assign({ Query: Query, Mutation: Mutation }, (types || {}));
71
70
  };
72
71
  exports.buildDefaultResolvers = buildDefaultResolvers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
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",
@@ -25,42 +25,42 @@
25
25
  "peerDependencies": {},
26
26
  "devDependencies": {
27
27
  "@types/bcrypt": "^5.0.0",
28
- "@types/bluebird": "^3.5.35",
29
- "@types/dotenv-safe": "^8.1.1",
30
- "@types/jest": "^26.0.16",
28
+ "@types/bluebird": "^3.5.36",
29
+ "@types/dotenv-safe": "^8.1.2",
30
+ "@types/jest": "^26.0.24",
31
31
  "@types/jsonwebtoken": "^8.5.8",
32
- "@types/lodash": "^4.14.165",
33
- "@types/node": "^14.14.10",
34
- "@types/redis": "^2.8.29",
35
- "@types/uuid": "^8.3.1",
36
- "@typescript-eslint/eslint-plugin": "^4.9.0",
37
- "@typescript-eslint/parser": "^4.11.0",
38
- "eslint": "^7.14.0",
32
+ "@types/lodash": "^4.14.178",
33
+ "@types/node": "^14.18.12",
34
+ "@types/redis": "^2.8.32",
35
+ "@types/uuid": "^8.3.4",
36
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
37
+ "@typescript-eslint/parser": "^4.33.0",
38
+ "eslint": "^7.32.0",
39
39
  "eslint-config-prettier": "^6.15.0",
40
- "eslint-plugin-jest": "^24.1.3",
41
- "eslint-plugin-prettier": "^3.1.4",
42
- "eslint-plugin-react": "^7.21.5",
40
+ "eslint-plugin-jest": "^24.7.0",
41
+ "eslint-plugin-prettier": "^3.4.1",
42
+ "eslint-plugin-react": "^7.28.0",
43
43
  "husky": "^6.0.0",
44
44
  "jest": "^26.6.3",
45
- "prettier": "^2.2.1",
45
+ "prettier": "^2.5.1",
46
46
  "rimraf": "^3.0.2",
47
47
  "run-script-os": "^1.1.3",
48
48
  "ts-jest": "^26.4.4",
49
49
  "ts-node": "^9.0.0",
50
- "typescript": "^4.1.3"
50
+ "typescript": "^4.5.5"
51
51
  },
52
52
  "dependencies": {
53
53
  "@sdflc/api-helpers": "^1.1.7",
54
- "@sdflc/utils": "^1.0.12",
54
+ "@sdflc/utils": "^1.0.18",
55
55
  "bcrypt": "^5.0.1",
56
56
  "bluebird": "^3.7.2",
57
57
  "dataloader": "^2.0.0",
58
58
  "dayjs": "^1.10.7",
59
59
  "dotenv-safe": "^8.2.0",
60
60
  "jsonwebtoken": "^8.5.1",
61
- "knex": "^0.95.6",
61
+ "knex": "^0.95.15",
62
62
  "lodash": "^4.17.20",
63
- "pg": "^8.6.0",
63
+ "pg": "^8.7.3",
64
64
  "redis": "^3.1.2",
65
65
  "redis-dataloader": "^1.0.2",
66
66
  "uuid": "^8.3.2"