@gennext/lb-infra 0.0.11 → 0.0.17

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 (131) hide show
  1. package/README.md +67 -102
  2. package/dist/base/base.helper.d.ts +4 -2
  3. package/dist/base/base.helper.d.ts.map +1 -1
  4. package/dist/base/base.helper.js +8 -2
  5. package/dist/base/base.helper.js.map +1 -1
  6. package/dist/base/datasources/base.datasource.d.ts +2 -2
  7. package/dist/base/datasources/base.datasource.d.ts.map +1 -1
  8. package/dist/base/datasources/base.datasource.js.map +1 -1
  9. package/dist/base/models/base.model.d.ts +10 -0
  10. package/dist/base/models/base.model.d.ts.map +1 -1
  11. package/dist/base/models/base.model.js +10 -3
  12. package/dist/base/models/base.model.js.map +1 -1
  13. package/dist/datasources/redis/connector.d.ts +1 -1
  14. package/dist/datasources/redis/connector.d.ts.map +1 -1
  15. package/dist/datasources/redis/connector.js +8 -4
  16. package/dist/datasources/redis/connector.js.map +1 -1
  17. package/dist/datasources/redis/types.d.ts +1 -1
  18. package/dist/datasources/redis/types.d.ts.map +1 -1
  19. package/dist/helpers/logger/application-logger.d.ts +0 -3
  20. package/dist/helpers/logger/application-logger.d.ts.map +1 -1
  21. package/dist/helpers/logger/application-logger.js +7 -31
  22. package/dist/helpers/logger/application-logger.js.map +1 -1
  23. package/dist/helpers/logger/common/types.d.ts +0 -7
  24. package/dist/helpers/logger/common/types.d.ts.map +1 -1
  25. package/dist/helpers/logger/common/types.js +1 -10
  26. package/dist/helpers/logger/common/types.js.map +1 -1
  27. package/dist/helpers/logger/config-merger.d.ts +27 -0
  28. package/dist/helpers/logger/config-merger.d.ts.map +1 -0
  29. package/dist/helpers/logger/config-merger.js +55 -0
  30. package/dist/helpers/logger/config-merger.js.map +1 -0
  31. package/dist/helpers/logger/config.d.ts +9 -11
  32. package/dist/helpers/logger/config.d.ts.map +1 -1
  33. package/dist/helpers/logger/config.js +18 -30
  34. package/dist/helpers/logger/config.js.map +1 -1
  35. package/dist/helpers/logger/default-logger.d.ts.map +1 -1
  36. package/dist/helpers/logger/default-logger.js +3 -5
  37. package/dist/helpers/logger/default-logger.js.map +1 -1
  38. package/dist/helpers/logger/enhanced-factory.d.ts +3 -3
  39. package/dist/helpers/logger/enhanced-factory.d.ts.map +1 -1
  40. package/dist/helpers/logger/enhanced-factory.js +10 -7
  41. package/dist/helpers/logger/enhanced-factory.js.map +1 -1
  42. package/dist/helpers/logger/factory.d.ts +1 -37
  43. package/dist/helpers/logger/factory.d.ts.map +1 -1
  44. package/dist/helpers/logger/factory.js +11 -86
  45. package/dist/helpers/logger/factory.js.map +1 -1
  46. package/dist/helpers/logger/http/access-logger.d.ts +14 -5
  47. package/dist/helpers/logger/http/access-logger.d.ts.map +1 -1
  48. package/dist/helpers/logger/http/access-logger.js +186 -157
  49. package/dist/helpers/logger/http/access-logger.js.map +1 -1
  50. package/dist/helpers/logger/http/index.d.ts +1 -1
  51. package/dist/helpers/logger/http/index.d.ts.map +1 -1
  52. package/dist/helpers/logger/http/index.js +1 -1
  53. package/dist/helpers/logger/http/index.js.map +1 -1
  54. package/dist/helpers/logger/http/request-context.d.ts +10 -6
  55. package/dist/helpers/logger/http/request-context.d.ts.map +1 -1
  56. package/dist/helpers/logger/http/request-context.js +32 -22
  57. package/dist/helpers/logger/http/request-context.js.map +1 -1
  58. package/dist/helpers/logger/http/request-id-manager.d.ts +13 -8
  59. package/dist/helpers/logger/http/request-id-manager.d.ts.map +1 -1
  60. package/dist/helpers/logger/http/request-id-manager.js +24 -70
  61. package/dist/helpers/logger/http/request-id-manager.js.map +1 -1
  62. package/dist/helpers/logger/http/types.d.ts +3 -3
  63. package/dist/helpers/logger/http/types.d.ts.map +1 -1
  64. package/dist/helpers/logger/index.d.ts +4 -3
  65. package/dist/helpers/logger/index.d.ts.map +1 -1
  66. package/dist/helpers/logger/index.js +4 -3
  67. package/dist/helpers/logger/index.js.map +1 -1
  68. package/dist/helpers/logger/transports/dgram.transport.d.ts +0 -1
  69. package/dist/helpers/logger/transports/dgram.transport.d.ts.map +1 -1
  70. package/dist/helpers/logger/transports/dgram.transport.js +2 -2
  71. package/dist/helpers/logger/transports/dgram.transport.js.map +1 -1
  72. package/dist/helpers/redis/default.helper.d.ts.map +1 -1
  73. package/dist/helpers/redis/default.helper.js +19 -17
  74. package/dist/helpers/redis/default.helper.js.map +1 -1
  75. package/dist/helpers/redis/index.d.ts.map +1 -1
  76. package/dist/helpers/redis/index.js.map +1 -1
  77. package/dist/helpers/redis/redis-cluster.helper.js +2 -2
  78. package/dist/helpers/redis/redis-cluster.helper.js.map +1 -1
  79. package/dist/helpers/redis/redis.helper.d.ts +34 -0
  80. package/dist/helpers/redis/redis.helper.d.ts.map +1 -1
  81. package/dist/helpers/redis/redis.helper.js +34 -0
  82. package/dist/helpers/redis/redis.helper.js.map +1 -1
  83. package/dist/utilities/crypto.utility.d.ts +28 -0
  84. package/dist/utilities/crypto.utility.d.ts.map +1 -1
  85. package/dist/utilities/crypto.utility.js +28 -0
  86. package/dist/utilities/crypto.utility.js.map +1 -1
  87. package/dist/utilities/date.utility.d.ts +57 -0
  88. package/dist/utilities/date.utility.d.ts.map +1 -1
  89. package/dist/utilities/date.utility.js +58 -16
  90. package/dist/utilities/date.utility.js.map +1 -1
  91. package/dist/utilities/error.utility.d.ts +63 -0
  92. package/dist/utilities/error.utility.d.ts.map +1 -1
  93. package/dist/utilities/error.utility.js +82 -4
  94. package/dist/utilities/error.utility.js.map +1 -1
  95. package/dist/utilities/lodash.utility.d.ts +1 -0
  96. package/dist/utilities/lodash.utility.d.ts.map +1 -1
  97. package/dist/utilities/lodash.utility.js +3 -1
  98. package/dist/utilities/lodash.utility.js.map +1 -1
  99. package/dist/utilities/model.utility.d.ts +15 -0
  100. package/dist/utilities/model.utility.d.ts.map +1 -1
  101. package/dist/utilities/model.utility.js +15 -2
  102. package/dist/utilities/model.utility.js.map +1 -1
  103. package/dist/utilities/module.utility.d.ts +8 -0
  104. package/dist/utilities/module.utility.d.ts.map +1 -1
  105. package/dist/utilities/module.utility.js +10 -2
  106. package/dist/utilities/module.utility.js.map +1 -1
  107. package/dist/utilities/parse.utility.d.ts +59 -0
  108. package/dist/utilities/parse.utility.d.ts.map +1 -1
  109. package/dist/utilities/parse.utility.js +76 -15
  110. package/dist/utilities/parse.utility.js.map +1 -1
  111. package/dist/utilities/performance.utility.d.ts +13 -0
  112. package/dist/utilities/performance.utility.d.ts.map +1 -1
  113. package/dist/utilities/performance.utility.js +15 -2
  114. package/dist/utilities/performance.utility.js.map +1 -1
  115. package/dist/utilities/promise.utility.d.ts +18 -18
  116. package/dist/utilities/promise.utility.d.ts.map +1 -1
  117. package/dist/utilities/promise.utility.js +16 -17
  118. package/dist/utilities/promise.utility.js.map +1 -1
  119. package/dist/utilities/query.utility.d.ts +24 -3
  120. package/dist/utilities/query.utility.d.ts.map +1 -1
  121. package/dist/utilities/query.utility.js +29 -7
  122. package/dist/utilities/query.utility.js.map +1 -1
  123. package/dist/utilities/request.utility.d.ts +36 -3
  124. package/dist/utilities/request.utility.d.ts.map +1 -1
  125. package/dist/utilities/request.utility.js +38 -8
  126. package/dist/utilities/request.utility.js.map +1 -1
  127. package/dist/utilities/url.utility.d.ts +16 -0
  128. package/dist/utilities/url.utility.d.ts.map +1 -1
  129. package/dist/utilities/url.utility.js +16 -0
  130. package/dist/utilities/url.utility.js.map +1 -1
  131. package/package.json +2 -1
@@ -1,22 +1,55 @@
1
1
  import { Request, Response } from '@loopback/rest';
2
2
  import multer from 'multer';
3
- import { IRequestedRemark } from '../common';
3
+ import { IRequestedRemark } from '../common/types';
4
+ /**
5
+ * Parses multipart form data (files) using multer
6
+ * @param opts - Configuration with storage engine, request, and response
7
+ * @returns Promise that resolves to an array of uploaded files
8
+ */
4
9
  export declare const parseMultipartBody: (opts: {
5
10
  storage?: multer.StorageEngine;
6
11
  request: Request;
7
12
  response: Response;
8
13
  }) => Promise<any>;
14
+ /**
15
+ * Extracts schema definition for a LoopBack model class
16
+ * @param ctor - The model class constructor
17
+ * @returns Schema object for the model
18
+ */
9
19
  export declare const getSchemaObject: <T extends object>(ctor?: Function & {
10
20
  prototype: T;
11
21
  }) => import("@loopback/rest").SchemaObject;
22
+ /**
23
+ * Gets the request ID from a LoopBack request object
24
+ * @param opts - Request context
25
+ * @returns Request identifier or 'unknown'
26
+ */
12
27
  export declare const getRequestId: (opts: {
13
28
  request: Request;
14
- }) => undefined;
29
+ }) => string;
30
+ /**
31
+ * Gets the client's forwarded IP address from the request
32
+ * @param opts - Request context
33
+ * @returns IP address string or 'N/A'
34
+ */
15
35
  export declare const getRequestIp: (opts: {
16
36
  request: Request;
17
37
  }) => string;
38
+ /**
39
+ * Extracts the requested remark from the request metadata
40
+ * @param opts - Request context
41
+ * @returns IRequestedRemark object or undefined
42
+ */
18
43
  export declare const getRequestRemark: (opts: {
19
44
  request: Request;
20
45
  }) => IRequestedRemark | undefined;
21
- export declare const genHTTPRequestId: () => string;
46
+ /**
47
+ * Generates or validates a unique HTTP request identifier
48
+ * Uses current date prefix combined with UUID
49
+ * @param id - Existing ID to validate (optional)
50
+ * @returns Validated or newly generated request ID
51
+ * @example
52
+ * genHTTPRequestId() // "20240413-..."
53
+ */
54
+ export declare const genHTTPRequestId: (id?: string) => string;
22
55
  //# sourceMappingURL=request.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/request.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAqB,MAAM,gBAAgB,CAAC;AACtE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,eAAO,MAAM,kBAAkB,GAAI,MAAM;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,iBAeA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AAO,MAAM,gBAAgB,GAAI,MAAM;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAG,gBAAgB,GAAG,SAEhF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,WAW3C,CAAC"}
@@ -8,7 +8,11 @@ const rest_1 = require("@loopback/rest");
8
8
  const multer_1 = __importDefault(require("multer"));
9
9
  const uuid_1 = require("uuid");
10
10
  const lodash_utility_1 = require("./lodash.utility");
11
- // -------------------------------------------------------------------------
11
+ /**
12
+ * Parses multipart form data (files) using multer
13
+ * @param opts - Configuration with storage engine, request, and response
14
+ * @returns Promise that resolves to an array of uploaded files
15
+ */
12
16
  const parseMultipartBody = (opts) => {
13
17
  const { storage: cStorage, request, response } = opts;
14
18
  const storage = cStorage ?? multer_1.default.memoryStorage();
@@ -24,28 +28,54 @@ const parseMultipartBody = (opts) => {
24
28
  });
25
29
  };
26
30
  exports.parseMultipartBody = parseMultipartBody;
27
- // -------------------------------------------------------------------------
31
+ /**
32
+ * Extracts schema definition for a LoopBack model class
33
+ * @param ctor - The model class constructor
34
+ * @returns Schema object for the model
35
+ */
28
36
  const getSchemaObject = (ctor) => {
29
37
  return ctor ? (0, rest_1.getModelSchemaRef)(ctor).definitions[ctor.name] : {};
30
38
  };
31
39
  exports.getSchemaObject = getSchemaObject;
32
- // -------------------------------------------------------------------------
40
+ /**
41
+ * Gets the request ID from a LoopBack request object
42
+ * @param opts - Request context
43
+ * @returns Request identifier or 'unknown'
44
+ */
33
45
  const getRequestId = (opts) => {
34
- return (0, lodash_utility_1.get)(opts.request, 'requestId');
46
+ return (0, lodash_utility_1.get)(opts.request, 'requestId') || 'unknown';
35
47
  };
36
48
  exports.getRequestId = getRequestId;
37
- // -------------------------------------------------------------------------
49
+ /**
50
+ * Gets the client's forwarded IP address from the request
51
+ * @param opts - Request context
52
+ * @returns IP address string or 'N/A'
53
+ */
38
54
  const getRequestIp = (opts) => {
39
55
  return (0, lodash_utility_1.get)(opts.request, 'requestForwardedIp') ?? 'N/A';
40
56
  };
41
57
  exports.getRequestIp = getRequestIp;
42
- // -------------------------------------------------------------------------
58
+ /**
59
+ * Extracts the requested remark from the request metadata
60
+ * @param opts - Request context
61
+ * @returns IRequestedRemark object or undefined
62
+ */
43
63
  const getRequestRemark = (opts) => {
44
64
  return (0, lodash_utility_1.get)(opts.request, 'requestedRemark');
45
65
  };
46
66
  exports.getRequestRemark = getRequestRemark;
47
- // -------------------------------------------------------------------------
48
- const genHTTPRequestId = () => {
67
+ /**
68
+ * Generates or validates a unique HTTP request identifier
69
+ * Uses current date prefix combined with UUID
70
+ * @param id - Existing ID to validate (optional)
71
+ * @returns Validated or newly generated request ID
72
+ * @example
73
+ * genHTTPRequestId() // "20240413-..."
74
+ */
75
+ const genHTTPRequestId = (id) => {
76
+ if (id && id !== 'unknown') {
77
+ return id;
78
+ }
49
79
  const now = new Date();
50
80
  const prefix = now.getFullYear().toString().padStart(4, '0') +
51
81
  (now.getMonth() + 1).toString().padStart(2, '0') +
@@ -1 +1 @@
1
- {"version":3,"file":"request.utility.js","sourceRoot":"","sources":["../../src/utilities/request.utility.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsE;AACtE,oDAA4B;AAC5B,+BAAoC;AAGpC,qDAAuC;AAEvC,4EAA4E;AACrE,MAAM,kBAAkB,GAAG,CAAC,IAIlC,EAAE,EAAE;IACH,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACtD,MAAM,OAAO,GAAG,QAAQ,IAAI,gBAAM,CAAC,aAAa,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEnC,OAAO,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,GAA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G,CAAC;QAChD,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5C,OAAO,GAAG,MAAM,IAAI,IAAA,SAAM,GAAE,EAAE,CAAC;AACjC,CAAC,CAAC;AAXW,QAAA,gBAAgB,oBAW3B"}
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Serializes an object into a URL search query string
3
+ * Automatically JSON stringifies non-primitive values
4
+ * @param params - Object containing key-value pairs to serialize
5
+ * @returns Encoded URL query string
6
+ * @example
7
+ * stringify({ id: 1, filter: { name: 'john' } })
8
+ * // "id=1&filter=%7B%22name%22%3A%22john%22%7D"
9
+ */
1
10
  export declare const stringify: (params: Record<string | symbol, any>) => string;
11
+ /**
12
+ * Parses a URL query string into a simple key-value object
13
+ * @param searchString - The raw query string (e.g. from window.location.search)
14
+ * @returns Object with key-value pairs from the query string
15
+ * @example
16
+ * parse('id=1&name=john') // { id: '1', name: 'john' }
17
+ */
2
18
  export declare const parse: (searchString: string) => Record<string, any>;
3
19
  //# sourceMappingURL=url.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/url.utility.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,WAiB7D,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,cAAc,MAAM,wBAQzC,CAAC"}
1
+ {"version":3,"file":"url.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/url.utility.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,WAiB7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,cAAc,MAAM,wBAQzC,CAAC"}
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parse = exports.stringify = void 0;
4
+ /**
5
+ * Serializes an object into a URL search query string
6
+ * Automatically JSON stringifies non-primitive values
7
+ * @param params - Object containing key-value pairs to serialize
8
+ * @returns Encoded URL query string
9
+ * @example
10
+ * stringify({ id: 1, filter: { name: 'john' } })
11
+ * // "id=1&filter=%7B%22name%22%3A%22john%22%7D"
12
+ */
4
13
  const stringify = (params) => {
5
14
  const normalizedParams = {};
6
15
  for (const key in params) {
@@ -20,6 +29,13 @@ const stringify = (params) => {
20
29
  return rs.toString();
21
30
  };
22
31
  exports.stringify = stringify;
32
+ /**
33
+ * Parses a URL query string into a simple key-value object
34
+ * @param searchString - The raw query string (e.g. from window.location.search)
35
+ * @returns Object with key-value pairs from the query string
36
+ * @example
37
+ * parse('id=1&name=john') // { id: '1', name: 'john' }
38
+ */
23
39
  const parse = (searchString) => {
24
40
  const rs = {};
25
41
  const searchParams = new URLSearchParams(searchString);
@@ -1 +1 @@
1
- {"version":3,"file":"url.utility.js","sourceRoot":"","sources":["../../src/utilities/url.utility.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,MAAoC,EAAE,EAAE;IAChE,MAAM,gBAAgB,GAAiC,EAAE,CAAC;IAC1D,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,QAAQ,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,gBAAgB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBACpC,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,MAAM;YACR,CAAC;QACH,CAAC;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AACvB,CAAC,CAAC;AAjBW,QAAA,SAAS,aAiBpB;AAEF;;;;;;GAMG;AACI,MAAM,KAAK,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC5C,MAAM,EAAE,GAAwB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC;IACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;QACxC,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AARW,QAAA,KAAK,SAQhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gennext/lb-infra",
3
- "version": "0.0.11",
3
+ "version": "0.0.17",
4
4
  "dependencies": {
5
5
  "@gennext/dev-configs": "^0.0.3",
6
6
  "@loopback/authentication": "^12.0.6",
@@ -118,6 +118,7 @@
118
118
  "clean": "sh ./scripts/clean.sh",
119
119
  "rebuild": "sh ./scripts/rebuild.sh",
120
120
  "eslint": "eslint --report-unused-disable-directives .",
121
+ "eslint:fix": "bun eslint --fix",
121
122
  "test": "TS_NODE_PROJECT=tsconfig.test.json node --require ts-node/register/transpile-only --require tsconfig-paths/register --test \"tests/**/*.test.ts\"",
122
123
  "lint": "bun run eslint && bun run prettier:cli",
123
124
  "lint:fix": "bun run eslint --fix && bun run prettier:fix",