@gennext/lb-infra 0.1.1 → 0.1.4

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 (85) hide show
  1. package/dist/base/index.d.ts +2 -0
  2. package/dist/base/index.d.ts.map +1 -1
  3. package/dist/base/index.js +2 -0
  4. package/dist/base/index.js.map +1 -1
  5. package/dist/base/migration/index.d.ts +3 -0
  6. package/dist/base/migration/index.d.ts.map +1 -0
  7. package/dist/base/migration/index.js +19 -0
  8. package/dist/base/migration/index.js.map +1 -0
  9. package/dist/base/migration/migration.interface.d.ts +5 -0
  10. package/dist/base/migration/migration.interface.d.ts.map +1 -0
  11. package/dist/base/migration/migration.interface.js +3 -0
  12. package/dist/base/migration/migration.interface.js.map +1 -0
  13. package/dist/base/migration/migration.service.d.ts +9 -0
  14. package/dist/base/migration/migration.service.d.ts.map +1 -0
  15. package/dist/base/migration/migration.service.js +146 -0
  16. package/dist/base/migration/migration.service.js.map +1 -0
  17. package/dist/base/models/base.model.d.ts +12 -6
  18. package/dist/base/models/base.model.d.ts.map +1 -1
  19. package/dist/base/models/base.model.js +10 -6
  20. package/dist/base/models/base.model.js.map +1 -1
  21. package/dist/base/models/index.d.ts +1 -0
  22. package/dist/base/models/index.d.ts.map +1 -1
  23. package/dist/base/models/index.js +1 -0
  24. package/dist/base/models/index.js.map +1 -1
  25. package/dist/base/models/migration.model.d.ts +12 -0
  26. package/dist/base/models/migration.model.d.ts.map +1 -0
  27. package/dist/base/models/migration.model.js +46 -0
  28. package/dist/base/models/migration.model.js.map +1 -0
  29. package/dist/base/repository/index.d.ts +3 -0
  30. package/dist/base/repository/index.d.ts.map +1 -0
  31. package/dist/base/repository/index.js +19 -0
  32. package/dist/base/repository/index.js.map +1 -0
  33. package/dist/base/repository/migration.repository.d.ts +6 -0
  34. package/dist/base/repository/migration.repository.d.ts.map +1 -0
  35. package/dist/base/repository/migration.repository.js +29 -0
  36. package/dist/base/repository/migration.repository.js.map +1 -0
  37. package/dist/base/repository/soft-delete.repository.d.ts +40 -0
  38. package/dist/base/repository/soft-delete.repository.d.ts.map +1 -0
  39. package/dist/base/repository/soft-delete.repository.js +74 -0
  40. package/dist/base/repository/soft-delete.repository.js.map +1 -0
  41. package/dist/helpers/migrate/type.d.ts +10 -0
  42. package/dist/helpers/migrate/type.d.ts.map +1 -0
  43. package/dist/helpers/migrate/type.js +3 -0
  44. package/dist/helpers/migrate/type.js.map +1 -0
  45. package/dist/utilities/axios.utility.d.ts +14 -0
  46. package/dist/utilities/axios.utility.d.ts.map +1 -0
  47. package/dist/utilities/axios.utility.js +122 -0
  48. package/dist/utilities/axios.utility.js.map +1 -0
  49. package/dist/utilities/index.d.ts +5 -0
  50. package/dist/utilities/index.d.ts.map +1 -1
  51. package/dist/utilities/index.js +28 -0
  52. package/dist/utilities/index.js.map +1 -1
  53. package/dist/utilities/lb-filter.utility.d.ts +5 -0
  54. package/dist/utilities/lb-filter.utility.d.ts.map +1 -0
  55. package/dist/utilities/lb-filter.utility.js +9 -0
  56. package/dist/utilities/lb-filter.utility.js.map +1 -0
  57. package/dist/utilities/migrate-helper.d.ts +10 -0
  58. package/dist/utilities/migrate-helper.d.ts.map +1 -0
  59. package/dist/utilities/migrate-helper.js +45 -0
  60. package/dist/utilities/migrate-helper.js.map +1 -0
  61. package/dist/utilities/migration-engine.d.ts +16 -0
  62. package/dist/utilities/migration-engine.d.ts.map +1 -0
  63. package/dist/utilities/migration-engine.js +40 -0
  64. package/dist/utilities/migration-engine.js.map +1 -0
  65. package/dist/utilities/migration.utility.d.ts +7 -0
  66. package/dist/utilities/migration.utility.d.ts.map +1 -0
  67. package/dist/utilities/migration.utility.js +23 -0
  68. package/dist/utilities/migration.utility.js.map +1 -0
  69. package/dist/utilities/model.utility.d.ts +44 -23
  70. package/dist/utilities/model.utility.d.ts.map +1 -1
  71. package/dist/utilities/model.utility.js +56 -37
  72. package/dist/utilities/model.utility.js.map +1 -1
  73. package/dist/validators/base.schema.d.ts +5 -6
  74. package/dist/validators/base.schema.d.ts.map +1 -1
  75. package/dist/validators/base.schema.js +5 -6
  76. package/dist/validators/base.schema.js.map +1 -1
  77. package/dist/validators/common.schema.d.ts +0 -44
  78. package/dist/validators/common.schema.d.ts.map +1 -1
  79. package/dist/validators/common.schema.js +1 -48
  80. package/dist/validators/common.schema.js.map +1 -1
  81. package/dist/validators/index.d.ts +2 -2
  82. package/dist/validators/index.d.ts.map +1 -1
  83. package/dist/validators/index.js +1 -8
  84. package/dist/validators/index.js.map +1 -1
  85. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"soft-delete.repository.js","sourceRoot":"","sources":["../../../src/base/repository/soft-delete.repository.ts"],"names":[],"mappings":";;;AAAA,qDAS8B;AAE9B;;GAEG;AACH,MAAa,oBAIX,SAAQ,kCAAuC;IAC/C,YAAY,WAA6C,EAAE,UAA8B;QACvF,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,IAAI,CAAC,MAAkB,EAAE,OAAiB;QACvD,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,OAAO,CAAC,MAAkB,EAAE,OAAiB;QAC1D,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,KAAK,CAAC,KAAgB,EAAE,OAAiB;QACtD,MAAM,aAAa,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC7C,CAA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0 +1,10 @@
1
+ export type TMigrationProcess = {
2
+ name: string;
3
+ cleanFn?: Function;
4
+ fn: (application: any) => Promise<any>;
5
+ options?: {
6
+ alwaysRun?: boolean;
7
+ [key: string | symbol]: any;
8
+ };
9
+ };
10
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/helpers/migrate/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,EAAE,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B,CAAC;CACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/helpers/migrate/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ export interface IResponse<T> {
3
+ status: number;
4
+ statusText: string;
5
+ data: T;
6
+ }
7
+ export declare const safeStringifyJson: (value: any) => string | undefined;
8
+ export declare const safeParseJson: <Result = any>(value: string) => Result | undefined;
9
+ export declare const get: <T>(client: AxiosInstance, path: string, config?: AxiosRequestConfig) => Promise<IResponse<T>>;
10
+ export declare const post: <T>(client: AxiosInstance, path: string, body: any, config?: AxiosRequestConfig) => Promise<IResponse<T>>;
11
+ export declare const put: <T>(client: AxiosInstance, path: string, body: any, config?: AxiosRequestConfig) => Promise<IResponse<T>>;
12
+ export declare const patch: <T>(client: AxiosInstance, path: string, body: any, config?: AxiosRequestConfig) => Promise<IResponse<T>>;
13
+ export declare const del: <T>(client: AxiosInstance, path: string, config?: AxiosRequestConfig) => Promise<IResponse<T>>;
14
+ //# sourceMappingURL=axios.utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/axios.utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEtE,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,CAAC,CAAC;CACT;AACD,eAAO,MAAM,iBAAiB,GAAI,OAAO,GAAG,uBAM3C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,GAAG,GAAG,EAAE,OAAO,MAAM,uBAMxD,CAAC;AAgDF,eAAO,MAAM,GAAG,GAAU,CAAC,EACzB,QAAQ,aAAa,EACrB,MAAM,MAAM,EACZ,SAAQ,kBAA0D,KACjE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAStB,CAAC;AAEF,eAAO,MAAM,IAAI,GAAU,CAAC,EAC1B,QAAQ,aAAa,EACrB,MAAM,MAAM,EACZ,MAAM,GAAG,EACT,SAAQ,kBAAgD,KACvD,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAStB,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,CAAC,EACzB,QAAQ,aAAa,EACrB,MAAM,MAAM,EACZ,MAAM,GAAG,EACT,SAAQ,kBAAgD,KACvD,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAStB,CAAC;AAEF,eAAO,MAAM,KAAK,GAAU,CAAC,EAC3B,QAAQ,aAAa,EACrB,MAAM,MAAM,EACZ,MAAM,GAAG,EACT,SAAQ,kBAAgD,KACvD,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAStB,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,CAAC,EACzB,QAAQ,aAAa,EACrB,MAAM,MAAM,EACZ,SAAQ,kBAAgD,KACvD,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAStB,CAAC"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.del = exports.patch = exports.put = exports.post = exports.get = exports.safeParseJson = exports.safeStringifyJson = void 0;
4
+ const helpers_1 = require("../helpers");
5
+ const safeStringifyJson = (value) => {
6
+ try {
7
+ return JSON.stringify(value);
8
+ }
9
+ catch {
10
+ return undefined;
11
+ }
12
+ };
13
+ exports.safeStringifyJson = safeStringifyJson;
14
+ const safeParseJson = (value) => {
15
+ try {
16
+ return JSON.parse(value);
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ };
22
+ exports.safeParseJson = safeParseJson;
23
+ const logger = helpers_1.LoggerFactory.getLogger(['Core']);
24
+ const handleAxiosError = (error) => {
25
+ if (error.config) {
26
+ const { method, url, data, params, headers, baseURL } = error.config;
27
+ let parsedData = data;
28
+ if (typeof data === 'string') {
29
+ parsedData = (0, exports.safeParseJson)(data);
30
+ }
31
+ const logData = {
32
+ method: method?.toUpperCase(),
33
+ fullUrl: `${baseURL || ''}${url}`,
34
+ params,
35
+ data: parsedData,
36
+ contentType: headers?.['Content-Type'],
37
+ };
38
+ logger.error(`Request Failed: ${(0, exports.safeStringifyJson)(logData)}\n`);
39
+ }
40
+ if (error.response) {
41
+ const logDataRes = {
42
+ status: error.response.status,
43
+ data: error.response.data,
44
+ };
45
+ logger.error(`Response Error: ${(0, exports.safeStringifyJson)(logDataRes)}\n`);
46
+ if (error.response.data &&
47
+ typeof error.response.data === 'object' &&
48
+ 'error' in error.response.data) {
49
+ throw error.response.data.error;
50
+ }
51
+ }
52
+ else if (error.request) {
53
+ logger.error(`No Response: ${(0, exports.safeStringifyJson)({
54
+ message: error.message,
55
+ code: error.code,
56
+ })}\n`);
57
+ }
58
+ else {
59
+ logger.error(`Setup Error: ${(0, exports.safeStringifyJson)({ message: error.message })}\n`);
60
+ }
61
+ };
62
+ const get = async (client, path, config = { headers: {}, responseType: 'json' }) => {
63
+ try {
64
+ const resp = await client.get(path, config);
65
+ const { status, statusText, data } = resp;
66
+ return { status, statusText, data };
67
+ }
68
+ catch (error) {
69
+ handleAxiosError(error);
70
+ throw error;
71
+ }
72
+ };
73
+ exports.get = get;
74
+ const post = async (client, path, body, config = { params: {}, headers: {} }) => {
75
+ try {
76
+ const resp = await client.post(path, body, config);
77
+ const { status, statusText, data } = resp;
78
+ return { status, statusText, data };
79
+ }
80
+ catch (error) {
81
+ handleAxiosError(error);
82
+ throw error;
83
+ }
84
+ };
85
+ exports.post = post;
86
+ const put = async (client, path, body, config = { params: {}, headers: {} }) => {
87
+ try {
88
+ const resp = await client.put(path, body, config);
89
+ const { status, statusText, data } = resp;
90
+ return { status, statusText, data };
91
+ }
92
+ catch (error) {
93
+ handleAxiosError(error);
94
+ throw error;
95
+ }
96
+ };
97
+ exports.put = put;
98
+ const patch = async (client, path, body, config = { params: {}, headers: {} }) => {
99
+ try {
100
+ const resp = await client.patch(path, body, config);
101
+ const { status, statusText, data } = resp;
102
+ return { status, statusText, data };
103
+ }
104
+ catch (error) {
105
+ handleAxiosError(error);
106
+ throw error;
107
+ }
108
+ };
109
+ exports.patch = patch;
110
+ const del = async (client, path, config = { params: {}, headers: {} }) => {
111
+ try {
112
+ const resp = await client.delete(path, config);
113
+ const { status, statusText, data } = resp;
114
+ return { status, statusText, data };
115
+ }
116
+ catch (error) {
117
+ handleAxiosError(error);
118
+ throw error;
119
+ }
120
+ };
121
+ exports.del = del;
122
+ //# sourceMappingURL=axios.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.utility.js","sourceRoot":"","sources":["../../src/utilities/axios.utility.ts"],"names":[],"mappings":";;;AAAA,wCAA2C;AAQpC,MAAM,iBAAiB,GAAG,CAAC,KAAU,EAAE,EAAE;IAC9C,IA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,KAAK,GAAG,KAAK,EACxB,MAAqB,EACrB,IAAY,EACZ,IAAS,EACT,SAA6B,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACjC,EAAE;IACzB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAI,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAdW,QAAA,KAAK,SAchB;AAEK,MAAM,GAAG,GAAG,KAAK,EACtB,MAAqB,EACrB,IAAY,EACZ,SAA6B,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACjC,EAAE;IACzB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAbW,QAAA,GAAG,OAad"}
@@ -9,4 +9,9 @@ export * from './promise.utility';
9
9
  export * from './query.utility';
10
10
  export * from './request.utility';
11
11
  export * from './url.utility';
12
+ export * from './migration-engine';
13
+ export * from './migrate-helper';
14
+ export * from './migration.utility';
15
+ export * from './lb-filter.utility';
16
+ export * as AxiosUtility from './axios.utility';
12
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC"}
@@ -10,10 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AxiosUtility = void 0;
17
40
  __exportStar(require("./crypto.utility"), exports);
18
41
  __exportStar(require("./date.utility"), exports);
19
42
  __exportStar(require("./error.utility"), exports);
@@ -25,4 +48,9 @@ __exportStar(require("./promise.utility"), exports);
25
48
  __exportStar(require("./query.utility"), exports);
26
49
  __exportStar(require("./request.utility"), exports);
27
50
  __exportStar(require("./url.utility"), exports);
51
+ __exportStar(require("./migration-engine"), exports);
52
+ __exportStar(require("./migrate-helper"), exports);
53
+ __exportStar(require("./migration.utility"), exports);
54
+ __exportStar(require("./lb-filter.utility"), exports);
55
+ exports.AxiosUtility = __importStar(require("./axios.utility"));
28
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,iDAA+B;AAC/B,kDAAgC;AAChC,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,iDAA+B;AAC/B,kDAAgC;AAChC,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,gEAAgD"}
@@ -0,0 +1,5 @@
1
+ export declare const inferOffsetPagination: (param?: {
2
+ offset?: number;
3
+ skip?: number;
4
+ }) => number | undefined;
5
+ //# sourceMappingURL=lb-filter.utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lb-filter.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/lb-filter.utility.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,QAAQ;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,uBAG/E,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inferOffsetPagination = void 0;
4
+ const inferOffsetPagination = (param) => {
5
+ const { offset, skip } = param ?? {};
6
+ return skip ? skip : offset;
7
+ };
8
+ exports.inferOffsetPagination = inferOffsetPagination;
9
+ //# sourceMappingURL=lb-filter.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lb-filter.utility.js","sourceRoot":"","sources":["../../src/utilities/lb-filter.utility.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,KAA0C,EAAE,EAAE;IAClF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9B,CAAC,CAAC;AAHW,QAAA,qBAAqB,yBAGhC"}
@@ -0,0 +1,10 @@
1
+ import { TMigrationProcess } from './migration-engine';
2
+ /**
3
+ * Common helper to handle the full migration lifecycle in any package.
4
+ *
5
+ * @param application The LoopBack 4 Application instance
6
+ * @param migrationProcesses Array of migration tasks
7
+ * @param args Command line arguments (to detect --rebuild)
8
+ */
9
+ export declare function bootstrapMigration(application: any, migrationProcesses: Array<TMigrationProcess>, args: string[]): Promise<void>;
10
+ //# sourceMappingURL=migrate-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-helper.d.ts","sourceRoot":"","sources":["../../src/utilities/migrate-helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,GAAG,EAChB,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAC5C,IAAI,EAAE,MAAM,EAAE,iBAsCf"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bootstrapMigration = bootstrapMigration;
4
+ const helpers_1 = require("../helpers");
5
+ const migration_engine_1 = require("./migration-engine");
6
+ /**
7
+ * Common helper to handle the full migration lifecycle in any package.
8
+ *
9
+ * @param application The LoopBack 4 Application instance
10
+ * @param migrationProcesses Array of migration tasks
11
+ * @param args Command line arguments (to detect --rebuild)
12
+ */
13
+ async function bootstrapMigration(application, migrationProcesses, args) {
14
+ const logger = helpers_1.LoggerFactory.getLogger(['core:migrate-helper']);
15
+ const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter';
16
+ logger.info(`START Migration schemas with strategy: ${existingSchema}`);
17
+ try {
18
+ // 1. Boot the application to load components, repos, etc.
19
+ await application.boot();
20
+ // 2. If rebuilding, run cleanFn from all processes BEFORE migrateSchema
21
+ if (existingSchema === 'drop') {
22
+ logger.info('Cleaning up dependent objects before schema migration...');
23
+ for (const process of migrationProcesses) {
24
+ if (process.cleanFn) {
25
+ logger.info(`Running cleanFn for: ${process.name}`);
26
+ await process.cleanFn(application);
27
+ }
28
+ }
29
+ }
30
+ // 3. Migrate the schema using LoopBack 4's built-in migration
31
+ await application.migrateSchema({ existingSchema });
32
+ // 4. Run application-specific initializers if any
33
+ if (typeof application.init === 'function') {
34
+ await application.init();
35
+ }
36
+ // 5. Run data migrations (seeding, indexes, etc.)
37
+ await (0, migration_engine_1.runMigrationProcesses)(application, migrationProcesses);
38
+ logger.info('SUCCESS: Full database migration completed');
39
+ }
40
+ catch (err) {
41
+ logger.error(`FATAL: Database migration failed: ${err}`);
42
+ throw err;
43
+ }
44
+ }
45
+ //# sourceMappingURL=migrate-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-helper.js","sourceRoot":"","sources":["../../src/utilities/migrate-helper.ts"],"names":[],"mappings":";;AAUA,gDAyCC;AAnDD,wCAA2C;AAC3C,yDAA8E;AAE9E;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAgB,EAChB,kBAA4C,EAC5C,IAAc;IAEd,MAAM,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAErE,MAAM,CAAC,IAAI,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;IAExE,IAAI,CAAC;QACH,0DAA0D;QAC1D,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QAEzB,wEAAwE;QACxE,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YACxE,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;gBACzC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBACpD,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,8DAA8D;QAC9D,MAAM,WAAW,CAAC,aAAa,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;QAEpD,kDAAkD;QAClD,IAAI,OAAO,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC3C,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QAC3B,CAAC;QAED,kDAAkD;QAClD,MAAM,IAAA,wCAAqB,EAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAE7D,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACzD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type TMigrationProcess = {
2
+ name: string;
3
+ cleanFn?: Function;
4
+ fn: (application: any) => Promise<any>;
5
+ options?: {
6
+ alwaysRun?: boolean;
7
+ [key: string | symbol]: any;
8
+ };
9
+ };
10
+ /**
11
+ * Enhanced Migration Engine to process data migrations.
12
+ * @param application The LoopBack 4 Application instance
13
+ * @param migrationProcesses Array of migration tasks to execute
14
+ */
15
+ export declare const runMigrationProcesses: (application: any, migrationProcesses: Array<TMigrationProcess>) => Promise<void>;
16
+ //# sourceMappingURL=migration-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-engine.d.ts","sourceRoot":"","sources":["../../src/utilities/migration-engine.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,EAAE,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B,CAAC;CACH,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,GAAG,EAChB,oBAAoB,KAAK,CAAC,iBAAiB,CAAC,kBAmC7C,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runMigrationProcesses = void 0;
4
+ const helpers_1 = require("../helpers");
5
+ const base_1 = require("../base");
6
+ /**
7
+ * Enhanced Migration Engine to process data migrations.
8
+ * @param application The LoopBack 4 Application instance
9
+ * @param migrationProcesses Array of migration tasks to execute
10
+ */
11
+ const runMigrationProcesses = async (application, migrationProcesses) => {
12
+ const logger = helpers_1.LoggerFactory.getLogger(['core:migration']);
13
+ logger.info('START Processing database migrations');
14
+ const migrateRepository = await application.getRepository(base_1.MigrationsRepository);
15
+ for (const process of migrationProcesses) {
16
+ try {
17
+ const shouldAlwaysRun = process.options?.alwaysRun ?? false;
18
+ if (!shouldAlwaysRun) {
19
+ const found = await migrateRepository.findOne({ where: { name: process.name } });
20
+ if (found) {
21
+ logger.debug(`Skipping already executed migration: ${process.name}`);
22
+ continue;
23
+ }
24
+ }
25
+ logger.info(`Executing migration: ${process.name}${shouldAlwaysRun ? ' (alwaysRun)' : ''}`);
26
+ await process.fn(application);
27
+ if (!shouldAlwaysRun) {
28
+ await migrateRepository.create({ name: process.name });
29
+ }
30
+ logger.info(`Completed migration: ${process.name}`);
31
+ }
32
+ catch (err) {
33
+ logger.error(`Error executing migration '${process.name}': ${err}`);
34
+ throw err;
35
+ }
36
+ }
37
+ logger.info('FINISH Processing database migrations');
38
+ };
39
+ exports.runMigrationProcesses = runMigrationProcesses;
40
+ //# sourceMappingURL=migration-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-engine.js","sourceRoot":"","sources":["../../src/utilities/migration-engine.ts"],"names":[],"mappings":";;;AAAA,wCAA2C;AAU3C,kCAA+C;AAE/C;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACxC,WAAgB,EAChB,kBAA4C,EAC5C,EAAE;IACF,MAAM,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAEpD,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,2BAAoB,CAAC,CAAC;IAEhF,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC;YAE5D,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjF,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBACrE,SAAS;gBACX,CAAC;YACH,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAE5F,MAAM,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;YAE9B,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,MAAM,iBAAiB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACzD,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC;YACpE,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;AACvD,CAAC,CAAC;AArCW,QAAA,qBAAqB,yBAqChC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Utility to run a migration task with logging.
3
+ * @param name Name of the migration
4
+ * @param runner Async function that performs the migration
5
+ */
6
+ export declare function runMigration<T>(name: string, runner: () => Promise<T>): Promise<T>;
7
+ //# sourceMappingURL=migration.utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/migration.utility.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,cAY3E"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runMigration = runMigration;
4
+ const helpers_1 = require("../helpers");
5
+ /**
6
+ * Utility to run a migration task with logging.
7
+ * @param name Name of the migration
8
+ * @param runner Async function that performs the migration
9
+ */
10
+ async function runMigration(name, runner) {
11
+ const logger = helpers_1.LoggerFactory.getLogger([`migration: ${name}`]);
12
+ logger.info('Running migration...');
13
+ try {
14
+ const result = await runner();
15
+ logger.info('Migration successful');
16
+ return result;
17
+ }
18
+ catch (error) {
19
+ logger.error(`Migration failed: ${error}`);
20
+ throw error;
21
+ }
22
+ }
23
+ //# sourceMappingURL=migration.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.utility.js","sourceRoot":"","sources":["../../src/utilities/migration.utility.ts"],"names":[],"mappings":";;AAOA,oCAYC;AAnBD,wCAA2C;AAE3C;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAAI,IAAY,EAAE,MAAwB;IAC1E,MAAM,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/D,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;QAC3C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,24 +1,45 @@
1
- import { SchemaObject } from '@loopback/rest';
2
- import { BaseEntity, BaseIdEntity } from '../base/models/base.model';
3
- /**
4
- * Extracts the JSON schema of the ID property from a LoopBack entity
5
- * @param entity - The LoopBack entity class (must extend BaseEntity)
6
- * @returns The SchemaObject representing the ID property
7
- * @example
8
- * const schema = getIdSchema(User);
9
- * // { type: 'number', minimum: 1 }
10
- */
11
- export declare const getIdSchema: <E extends BaseEntity>(entity: typeof BaseEntity & {
12
- prototype: E;
13
- }) => SchemaObject;
14
- /**
15
- * Inspects the metadata of a LoopBack entity to determine the ID type
16
- * @param entity - The LoopBack entity class
17
- * @returns 'string' or 'number' (default: 'number')
18
- * @example
19
- * const type = getIdType(User); // 'number'
20
- */
21
- export declare const getIdType: <E extends BaseEntity>(entity: typeof BaseIdEntity & {
22
- prototype: E;
23
- }) => "string" | "number";
1
+ import { RequestBodyObject, SchemaObject } from '@gennext/lb-infra/lb-rest';
2
+ type TModelCtor<T extends object> = Function & {
3
+ prototype: T;
4
+ };
5
+ interface IBaseSchemaOptions {
6
+ title?: string;
7
+ exclude?: string[];
8
+ partial?: boolean | 'deep';
9
+ optional?: string[];
10
+ includeRelations?: boolean;
11
+ }
12
+ interface IRequestBodyOptions extends IBaseSchemaOptions {
13
+ required?: boolean;
14
+ isConvertToArray?: boolean;
15
+ }
16
+ export declare const buildRequestBody: <T extends object>(model: TModelCtor<T>, options?: IRequestBodyOptions) => RequestBodyObject;
17
+ export declare const buildResponse: <T extends object>(model: TModelCtor<T>, options?: IBaseSchemaOptions) => SchemaObject;
18
+ export declare const buildArrayResponse: <T extends object>(model: TModelCtor<T>, options?: IBaseSchemaOptions) => SchemaObject;
19
+ export declare const buildPaginationResponse: <T extends object>(model: TModelCtor<T>, options?: IBaseSchemaOptions) => {
20
+ content: {
21
+ 'application/json': {
22
+ schema: {
23
+ title: string;
24
+ type: string;
25
+ properties: {
26
+ count: {
27
+ type: string;
28
+ };
29
+ offset: {
30
+ type: string;
31
+ };
32
+ limit: {
33
+ type: string;
34
+ };
35
+ data: {
36
+ type: string;
37
+ items: SchemaObject;
38
+ };
39
+ };
40
+ };
41
+ };
42
+ };
43
+ };
44
+ export {};
24
45
  //# sourceMappingURL=model.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/model.utility.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC9C,QAAQ,OAAO,UAAU,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,KAC3C,YAIF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC5C,QAAQ,OAAO,YAAY,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,KAC7C,QAAQ,GAAG,QAoBb,CAAC"}
1
+ {"version":3,"file":"model.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/model.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE/F,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC;AAEhE,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,UAAU,mBAAoB,SAAQ,kBAAkB;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAmBD,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,EAC/C,OAAO,UAAU,CAAC,CAAC,CAAC,EACpB,UAAS,mBAAwB,KAChC,iBAkBF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAC5C,OAAO,UAAU,CAAC,CAAC,CAAC,EACpB,UAAS,kBAAuB,KAC/B,YAIC,CAAC;AAEL,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,EACjD,OAAO,UAAU,CAAC,CAAC,CAAC,EACpB,UAAS,kBAAuB,KAC/B,YAID,CAAC;AAEH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,EACtD,OAAO,UAAU,CAAC,CAAC,CAAC,EACpB,UAAS,kBAAuB;;;;;;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC"}
@@ -1,41 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIdType = exports.getIdSchema = void 0;
4
- const metadata_1 = require("@loopback/metadata");
5
- const rest_1 = require("@loopback/rest");
6
- /**
7
- * Extracts the JSON schema of the ID property from a LoopBack entity
8
- * @param entity - The LoopBack entity class (must extend BaseEntity)
9
- * @returns The SchemaObject representing the ID property
10
- * @example
11
- * const schema = getIdSchema(User);
12
- * // { type: 'number', minimum: 1 }
13
- */
14
- const getIdSchema = (entity) => {
15
- const idProp = entity.getIdProperties()[0];
16
- const modelSchema = (0, rest_1.jsonToSchemaObject)((0, rest_1.getJsonSchema)(entity));
17
- return modelSchema.properties?.[idProp];
3
+ exports.buildPaginationResponse = exports.buildArrayResponse = exports.buildResponse = exports.buildRequestBody = void 0;
4
+ const lb_rest_1 = require("@gennext/lb-infra/lb-rest");
5
+ const buildModelSchema = (model, options = {}) => (0, lb_rest_1.getModelSchemaRef)(model, {
6
+ title: options.title,
7
+ exclude: options.exclude,
8
+ partial: options.partial,
9
+ optional: options.optional,
10
+ includeRelations: options.includeRelations,
11
+ });
12
+ const buildArraySchema = (items) => ({
13
+ type: 'array',
14
+ items,
15
+ });
16
+ const buildRequestBody = (model, options = {}) => {
17
+ const { title = `${model.name} - Request body`, exclude = ['id'], required: isRequired = false, isConvertToArray = false, } = options;
18
+ const schema = isConvertToArray
19
+ ? buildArraySchema(buildModelSchema(model, { title, exclude }))
20
+ : buildModelSchema(model, { title, exclude });
21
+ return {
22
+ required: isRequired,
23
+ content: {
24
+ 'application/json': { schema },
25
+ },
26
+ };
18
27
  };
19
- exports.getIdSchema = getIdSchema;
20
- /**
21
- * Inspects the metadata of a LoopBack entity to determine the ID type
22
- * @param entity - The LoopBack entity class
23
- * @returns 'string' or 'number' (default: 'number')
24
- * @example
25
- * const type = getIdType(User); // 'number'
26
- */
27
- const getIdType = (entity) => {
28
- let idType = 'number';
29
- try {
30
- const idMetadata = metadata_1.MetadataInspector.getPropertyMetadata('loopback:model-properties', entity, 'id');
31
- idType = idMetadata?.type ?? 'number';
32
- }
33
- catch (e) {
34
- console.error("[getIdType] Failed to inspect entity id type! Use 'number' by default | Error: ", e);
35
- idType = 'number';
36
- return idType;
37
- }
38
- return idType;
39
- };
40
- exports.getIdType = getIdType;
28
+ exports.buildRequestBody = buildRequestBody;
29
+ const buildResponse = (model, options = {}) => buildModelSchema(model, {
30
+ title: options.title ?? `${model.name} - Response`,
31
+ ...options,
32
+ });
33
+ exports.buildResponse = buildResponse;
34
+ const buildArrayResponse = (model, options = {}) => ({
35
+ title: options.title ?? `${model.name} - List response`,
36
+ type: 'array',
37
+ items: buildModelSchema(model, options),
38
+ });
39
+ exports.buildArrayResponse = buildArrayResponse;
40
+ const buildPaginationResponse = (model, options = {}) => ({
41
+ content: {
42
+ 'application/json': {
43
+ schema: {
44
+ title: options.title ?? `${model.name} - Pagination response`,
45
+ type: 'object',
46
+ properties: {
47
+ count: { type: 'number' },
48
+ offset: { type: 'number' },
49
+ limit: { type: 'number' },
50
+ data: {
51
+ type: 'array',
52
+ items: buildModelSchema(model, options),
53
+ },
54
+ },
55
+ },
56
+ },
57
+ },
58
+ });
59
+ exports.buildPaginationResponse = buildPaginationResponse;
41
60
  //# sourceMappingURL=model.utility.js.map