@sdflc/backend-helpers 1.0.79 → 1.0.81

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 (37) hide show
  1. package/build/BaseCore.js +496 -600
  2. package/build/BaseGateway.js +331 -377
  3. package/build/DataCache.js +16 -19
  4. package/build/Database.js +55 -74
  5. package/build/DbMigratorAndSeeder.js +88 -114
  6. package/build/RedisDataLoader.js +153 -184
  7. package/build/apiContext.js +35 -33
  8. package/build/baseController.js +9 -16
  9. package/build/commonValidators.js +22 -31
  10. package/build/configBulder.js +5 -1
  11. package/build/dbHelpers.js +19 -29
  12. package/build/dbSeeder.js +11 -20
  13. package/build/dbTableHelpers.js +10 -10
  14. package/build/downloadHelpers.js +15 -25
  15. package/build/esm/BaseCore.js +496 -600
  16. package/build/esm/BaseGateway.js +331 -377
  17. package/build/esm/DataCache.js +16 -19
  18. package/build/esm/Database.js +55 -74
  19. package/build/esm/DbMigratorAndSeeder.js +88 -114
  20. package/build/esm/RedisDataLoader.js +153 -184
  21. package/build/esm/apiContext.js +35 -33
  22. package/build/esm/baseController.js +9 -16
  23. package/build/esm/commonValidators.js +22 -31
  24. package/build/esm/configBulder.js +5 -1
  25. package/build/esm/dbHelpers.js +19 -29
  26. package/build/esm/dbSeeder.js +11 -20
  27. package/build/esm/dbTableHelpers.js +10 -10
  28. package/build/esm/downloadHelpers.js +15 -25
  29. package/build/esm/knexConfigBuilder.js +17 -7
  30. package/build/esm/passwordHelpers.js +7 -16
  31. package/build/esm/resolversHelpers.js +11 -4
  32. package/build/esm/userToken.js +2 -2
  33. package/build/knexConfigBuilder.js +17 -7
  34. package/build/passwordHelpers.js +7 -16
  35. package/build/resolversHelpers.js +11 -4
  36. package/build/userToken.js +2 -2
  37. package/package.json +4 -5
@@ -1,30 +1,21 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.checkPassword = exports.getSaltAndHash = void 0;
16
7
  const bcrypt_1 = __importDefault(require("bcrypt"));
17
- const getSaltAndHash = (password_1, ...args_1) => __awaiter(void 0, [password_1, ...args_1], void 0, function* (password, saltRounds = 10) {
18
- const salt = yield bcrypt_1.default.genSalt(saltRounds);
19
- const hash = yield bcrypt_1.default.hash(password, salt);
8
+ const getSaltAndHash = async (password, saltRounds = 10) => {
9
+ const salt = await bcrypt_1.default.genSalt(saltRounds);
10
+ const hash = await bcrypt_1.default.hash(password, salt);
20
11
  return {
21
12
  salt,
22
13
  hash,
23
14
  };
24
- });
15
+ };
25
16
  exports.getSaltAndHash = getSaltAndHash;
26
- const checkPassword = (password, hashedPassword) => __awaiter(void 0, void 0, void 0, function* () {
27
- const isCorrect = yield bcrypt_1.default.compare(password, hashedPassword);
17
+ const checkPassword = async (password, hashedPassword) => {
18
+ const isCorrect = await bcrypt_1.default.compare(password, hashedPassword);
28
19
  return isCorrect;
29
- });
20
+ };
30
21
  exports.checkPassword = checkPassword;
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildDefaultResolvers = void 0;
4
4
  const buildDefaultResolvers = (args) => {
5
5
  const { prefix, core, query, mutation, types, disableList, disableGet, disableGetMany, disableCreate, disableCreateMany, disableUpdate, disableUpdateMany, disableSet, disableRemove, disableRemoveMany, } = args || {};
6
- const Query = Object.assign({}, (query || {}));
7
- const Mutation = Object.assign({}, (mutation || {}));
6
+ const Query = {
7
+ ...(query || {}),
8
+ };
9
+ const Mutation = {
10
+ ...(mutation || {}),
11
+ };
8
12
  const coreToUse = core || `${prefix}Core`;
9
13
  if (disableList !== true) {
10
14
  Query[`${prefix}List`] = (parent, args, context) => {
@@ -56,7 +60,10 @@ const buildDefaultResolvers = (args) => {
56
60
  return context.cores[coreToUse].removeMany(args);
57
61
  };
58
62
  }
59
- return Object.assign({ Query,
60
- Mutation }, (types || {}));
63
+ return {
64
+ Query,
65
+ Mutation,
66
+ ...(types || {}),
67
+ };
61
68
  };
62
69
  exports.buildDefaultResolvers = buildDefaultResolvers;
@@ -42,7 +42,7 @@ const createUserToken = (params, secret, opt) => {
42
42
  issuer: issuer || defaultIssuer,
43
43
  jwtid: jwtid || (0, uuid_1.v4)(),
44
44
  subject: params.userId,
45
- noTimestamp: noTimestamp !== null && noTimestamp !== void 0 ? noTimestamp : false,
45
+ noTimestamp: noTimestamp ?? false,
46
46
  header,
47
47
  keyid,
48
48
  expiresIn: expiresIn && !isNaN(expiresIn) ? expiresIn : undefined,
@@ -68,7 +68,7 @@ const verifyUserToken = (token, secret, args) => {
68
68
  clockTimestamp,
69
69
  nonce,
70
70
  });
71
- if ((obj === null || obj === void 0 ? void 0 : obj.fingerprint) && obj.fingerprint != fingerprint) {
71
+ if (obj?.fingerprint && obj.fingerprint != fingerprint) {
72
72
  return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.UNAUTHORIZED, null, 'User unauthenticated');
73
73
  }
74
74
  return api_helpers_1.OpResult.ok(obj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.79",
3
+ "version": "1.0.81",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -11,12 +11,11 @@
11
11
  },
12
12
  "main": "./build/index.js",
13
13
  "module": "./build/esm/index.js",
14
- "types": "build/index.d.ts",
14
+ "types": "./build/index.d.ts",
15
15
  "files": [
16
16
  "build/**/*"
17
17
  ],
18
18
  "scripts": {
19
- "build1": "rimraf ./build && tsc",
20
19
  "build": "rimraf ./build && tsc && tsc -p tsconfig.esm.json",
21
20
  "lint": "ESLINT_USE_FLAT_CONFIG=true eslint .",
22
21
  "test": "echo No Tests Available Yet",
@@ -58,8 +57,8 @@
58
57
  "typescript": "^5.7.3"
59
58
  },
60
59
  "dependencies": {
61
- "@sdflc/api-helpers": "^1.1.12",
62
- "@sdflc/utils": "^1.0.23",
60
+ "@sdflc/api-helpers": "^1.1.13",
61
+ "@sdflc/utils": "^1.0.24",
63
62
  "bcrypt": "^5.1.1",
64
63
  "bluebird": "^3.7.2",
65
64
  "check-types": "^11.2.3",