@gennext/lb-infra 0.2.2 → 0.2.3

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 (68) hide show
  1. package/README.md +116 -18
  2. package/dist/base/applications/base.application.d.ts +12 -21
  3. package/dist/base/applications/base.application.d.ts.map +1 -1
  4. package/dist/base/applications/base.application.js +25 -27
  5. package/dist/base/applications/base.application.js.map +1 -1
  6. package/dist/base/hono/hono-adapter.d.ts +10 -0
  7. package/dist/base/hono/hono-adapter.d.ts.map +1 -0
  8. package/dist/base/hono/hono-adapter.js +27 -0
  9. package/dist/base/hono/hono-adapter.js.map +1 -0
  10. package/dist/base/models/base.model.d.ts +2 -1
  11. package/dist/base/models/base.model.d.ts.map +1 -1
  12. package/dist/base/models/base.model.js +2 -1
  13. package/dist/base/models/base.model.js.map +1 -1
  14. package/dist/base/models/column-defs.d.ts +2 -2
  15. package/dist/base/models/decorators.d.ts +15 -0
  16. package/dist/base/models/decorators.d.ts.map +1 -0
  17. package/dist/base/models/decorators.js +19 -0
  18. package/dist/base/models/decorators.js.map +1 -0
  19. package/dist/base/models/index.d.ts +2 -0
  20. package/dist/base/models/index.d.ts.map +1 -1
  21. package/dist/base/models/index.js +2 -0
  22. package/dist/base/models/index.js.map +1 -1
  23. package/dist/base/models/model.helper.d.ts +7 -0
  24. package/dist/base/models/model.helper.d.ts.map +1 -0
  25. package/dist/base/models/model.helper.js +16 -0
  26. package/dist/base/models/model.helper.js.map +1 -0
  27. package/dist/base/repository/default-crud.repository.d.ts +3 -3
  28. package/dist/base/repository/default-crud.repository.d.ts.map +1 -1
  29. package/dist/base/repository/default-crud.repository.js +20 -17
  30. package/dist/base/repository/default-crud.repository.js.map +1 -1
  31. package/dist/base/repository/filter.builder.d.ts +7 -0
  32. package/dist/base/repository/filter.builder.d.ts.map +1 -0
  33. package/dist/base/repository/filter.builder.js +74 -0
  34. package/dist/base/repository/filter.builder.js.map +1 -0
  35. package/dist/base/repository/readable.repository.d.ts +10 -8
  36. package/dist/base/repository/readable.repository.d.ts.map +1 -1
  37. package/dist/base/repository/readable.repository.js +26 -19
  38. package/dist/base/repository/readable.repository.js.map +1 -1
  39. package/dist/base/repository/soft-deletable.repository.d.ts +3 -2
  40. package/dist/base/repository/soft-deletable.repository.d.ts.map +1 -1
  41. package/dist/base/repository/soft-deletable.repository.js +26 -15
  42. package/dist/base/repository/soft-deletable.repository.js.map +1 -1
  43. package/dist/boot/base/base-artifact-booter.d.ts +3 -0
  44. package/dist/boot/base/base-artifact-booter.d.ts.map +1 -1
  45. package/dist/boot/base/base-artifact-booter.js +3 -0
  46. package/dist/boot/base/base-artifact-booter.js.map +1 -1
  47. package/dist/boot/boot.mixin.d.ts.map +1 -1
  48. package/dist/boot/boot.mixin.js +10 -4
  49. package/dist/boot/boot.mixin.js.map +1 -1
  50. package/dist/boot/booters/controller.booter.d.ts.map +1 -1
  51. package/dist/boot/booters/controller.booter.js +5 -1
  52. package/dist/boot/booters/controller.booter.js.map +1 -1
  53. package/dist/common/constants.d.ts +2 -0
  54. package/dist/common/constants.d.ts.map +1 -1
  55. package/dist/common/constants.js +2 -0
  56. package/dist/common/constants.js.map +1 -1
  57. package/dist/helpers/logger/config.d.ts.map +1 -1
  58. package/dist/helpers/logger/config.js +1 -2
  59. package/dist/helpers/logger/config.js.map +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +2 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/utilities/migration.utility.d.ts +13 -0
  65. package/dist/utilities/migration.utility.d.ts.map +1 -1
  66. package/dist/utilities/migration.utility.js +39 -0
  67. package/dist/utilities/migration.utility.js.map +1 -1
  68. package/package.json +9 -1
package/README.md CHANGED
@@ -7,12 +7,16 @@ Hạ tầng Backend Hybrid chuẩn Gennex: Kết hợp sức mạnh kiến trúc
7
7
  ## 🏗 1. Tổng quan kiến trúc & Cài đặt
8
8
 
9
9
  ### 1.1 Hybrid Platform
10
+
10
11
  Thư viện cung cấp hai lộ trình phát triển:
12
+
11
13
  - **Hono Path (Modern):** Cho các service yêu cầu tốc độ cao, hỗ trợ OpenAPI native qua Zod.
12
14
  - **LoopBack Path (Standard):** Cho các ứng dụng phức tạp cần DI (Dependency Injection) và tính tương thích ngược.
13
15
 
14
16
  ### 1.2 Cấu trúc Export (Sub-paths)
17
+
15
18
  Được cấu hình trong `package.json`, giúp developer import sạch sẽ:
19
+
16
20
  - `@gennext/lb-infra`: Entry chính (Hono, Drizzle, Utilities).
17
21
  - `@gennext/lb-infra/lb-core`: LoopBack Core (Binding, Context, Metadata).
18
22
  - `@gennext/lb-infra/lb-rest`: LoopBack Rest (Decorators, Sequence).
@@ -21,7 +25,9 @@ Thư viện cung cấp hai lộ trình phát triển:
21
25
  - `@gennext/lb-infra/grpc`: gRPC component.
22
26
 
23
27
  ### 1.3 Pin Dependencies (Không cần cài thêm)
28
+
24
29
  Thư viện đã đóng gói sẵn và re-export các "vũ khí" sau:
30
+
25
31
  - **Framework:** `Hono`, `@hono/zod-openapi`, `zod`.
26
32
  - **Database:** `Drizzle ORM` (core + pg), `pg` (node-postgres).
27
33
  - **Utilities:** `axios`, `lodash`, `dayjs` (thông qua `date.utility`).
@@ -31,22 +37,27 @@ Thư viện đã đóng gói sẵn và re-export các "vũ khí" sau:
31
37
  ## 🚀 2. Application Kernel
32
38
 
33
39
  ### 2.1 Khởi tạo với `BaseApplication`
40
+
34
41
  Mọi ứng dụng phải kế thừa từ class này.
35
42
 
36
43
  **Interface `IApplicationConfigs`:**
44
+
37
45
  - `port`: (Bắt buộc) Cổng chạy server.
38
46
  - `host?`: Hostname (Mặc định `0.0.0.0`).
39
47
  - `path?`: `{ base: string, isStrict?: boolean }` - Prefix cho API.
40
48
  - `debug?`: `{ shouldShowRoutes?: boolean }` - In ra danh sách route khi startup.
41
49
 
42
50
  **Vòng đời (Lifecycle) trong `start()`:**
51
+
43
52
  1. `preConfigure()`: Thiết lập biến môi trường, kết nối DB sớm.
44
53
  2. `setupMiddlewares()`: Đăng ký Logger, CORS, v.v.
45
54
  3. `boot()`: Tự động đăng ký Controllers/Services (khi dùng `bootMixin`).
46
55
  4. `postConfigure()`: Chạy các tác vụ sau khi server đã lắng nghe.
47
56
 
48
57
  ### 2.2 Dependency Injection (DI)
58
+
49
59
  Hệ thống sử dụng Map-based Binding:
60
+
50
61
  - **Bind:** `app.bind({ key: 'services.UserService' }).toClass(UserService)`
51
62
  - **Get:** `const service = app.get<UserService>({ key: 'services.UserService' })`
52
63
  - **Namespaces:** Nên dùng `BindingNamespaces.SERVICE`, `.CONTROLLER`, `.REPOSITORY`, `.DATASOURCE`.
@@ -56,9 +67,11 @@ Hệ thống sử dụng Map-based Binding:
56
67
  ## 🪵 3. Hệ thống Logger & Context
57
68
 
58
69
  ### 3.1 Logger nâng cao
70
+
59
71
  Được xây dựng trên Winston, hỗ trợ ghi log đa kênh.
60
72
 
61
73
  **Các Method:**
74
+
62
75
  - `debug(msg, ...args)`: ⚠️ Chỉ hoạt động nếu `NODE_ENV` là local/dev/alpha... **VÀ** biến `DEBUG=true`.
63
76
  - `withScope(scope)`: Gắn prefix cho log.
64
77
  - `for(method)`: Child logger cho từng hàm cụ thể (có cache để tối ưu).
@@ -68,7 +81,9 @@ Gửi log qua socket UDP (ví dụ đến Logstash/Graylog).
68
81
  Cấu hình qua `IDgramTransportOptions`: `host`, `port`, `levels` (các mức log muốn gửi đi).
69
82
 
70
83
  ### 3.2 RequestContext & HttpAccessLogger
84
+
71
85
  Dùng để theo vết request ID xuyên suốt các tầng.
86
+
72
87
  - **Tự động hóa:** Middleware tự lấy `x-request-id` từ header hoặc tự sinh mới.
73
88
  - **Data Masking:** Tự động ẩn thông tin nhạy cảm trong log: `authorization`, `cookie`, `session`, `password`.
74
89
 
@@ -77,12 +92,15 @@ Dùng để theo vết request ID xuyên suốt các tầng.
77
92
  ## 🗄️ 4. Data Layer (Drizzle ORM)
78
93
 
79
94
  ### 4.1 Schema Helpers (`column-defs.ts`)
95
+
80
96
  Giúp định nghĩa bảng chuẩn Gennex:
97
+
81
98
  - `generateIdColumnDefs()`: Cột `id` (Serial hoặc UUID).
82
99
  - `generateTzColumnDefs()`: Cột `created_at`, `modified_at` tự động cập nhật.
83
100
  - `generateSoftDeleteColumnDefs()`: Cột `deleted_at`.
84
101
 
85
102
  ### 4.2 Tầng Repository (Tiering)
103
+
86
104
  - **ReadableRepository**: Tìm kiếm cơ bản.
87
105
  - **DefaultCRUDRepository**: Thao tác Thêm/Sửa/Xóa.
88
106
  - **SoftDeletableRepository**: 💡 Tự động thêm điều kiện `deleted_at IS NULL` vào mọi câu query.
@@ -94,9 +112,11 @@ Giúp định nghĩa bảng chuẩn Gennex:
94
112
  ## ⚡ 5. Redis & Caching
95
113
 
96
114
  ### 5.1 RedisManager
115
+
97
116
  Quản lý tập trung các instance Redis. Hỗ trợ cả **Standalone** và **Cluster mode**.
98
117
 
99
118
  ### 5.2 DefaultRedisHelper API
119
+
100
120
  - `set({ key, value, options: { ttl } })`: Lưu object (tự serialize JSON).
101
121
  - `getObject({ key })`: Lấy và tự parse JSON.
102
122
  - `publish({ topics, payload, useCompress })`: Pub/Sub có hỗ trợ nén zlib để tiết kiệm băng thông.
@@ -106,6 +126,7 @@ Quản lý tập trung các instance Redis. Hỗ trợ cả **Standalone** và *
106
126
  ## 🌐 6. HTTP Layer (Hono + OpenAPI)
107
127
 
108
128
  ### 6.1 BaseController
129
+
109
130
  Sử dụng `bindRoute` để có được sự hỗ trợ tuyệt đối từ TypeScript và tự sinh Swagger.
110
131
 
111
132
  ```typescript
@@ -114,13 +135,13 @@ this.bindRoute({
114
135
  path: '/:id',
115
136
  method: 'get',
116
137
  request: { params: zod.object({ id: zod.string() }) },
117
- responses: { 200: jsonResponse({ schema: UserSchema, description: 'User info' }) }
118
- }
138
+ responses: { 200: jsonResponse({ schema: UserSchema, description: 'User info' }) },
139
+ },
119
140
  }).to({
120
- handler: async (c) => {
141
+ handler: async c => {
121
142
  const id = c.req.param('id');
122
143
  // ... logic
123
- }
144
+ },
124
145
  });
125
146
  ```
126
147
 
@@ -128,25 +149,28 @@ this.bindRoute({
128
149
 
129
150
  ## 🧰 7. Bộ tiện ích (Utilities Deep Dive)
130
151
 
131
- | Utility | Method tiêu biểu | Mô tả |
132
- | :--- | :--- | :--- |
133
- | **parse** | `getUID()`, `keysToCamel()`, `toBoolean()`, `int()`, `float()` | Xử lý kiểu dữ liệu và format key. |
134
- | **crypto** | `hashPassword()`, `comparePassword()`, `encrypt()`, `decrypt()` | Bảo mật mật khẩu và mã hóa AES. |
135
- | **error** | `getError()`, `ValidationError()`, `NotImplementedError()` | Tạo lỗi chuẩn hóa có Status Code. |
136
- | **model** | `buildRequestBody()`, `buildPaginationResponse()` | Tự động sinh OpenAPI schema từ Model. |
137
- | **promise** | `delay(ms)` | Hàm ngủ async. |
138
- | **axios** | `get()`, `post()`, `put()`, `del()` | Wrapper axios kèm xử lý lỗi chuẩn. |
152
+ | Utility | Method tiêu biểu | Mô tả |
153
+ | :---------- | :-------------------------------------------------------------- | :------------------------------------ |
154
+ | **parse** | `getUID()`, `keysToCamel()`, `toBoolean()`, `int()`, `float()` | Xử lý kiểu dữ liệu và format key. |
155
+ | **crypto** | `hashPassword()`, `comparePassword()`, `encrypt()`, `decrypt()` | Bảo mật mật khẩu và mã hóa AES. |
156
+ | **error** | `getError()`, `ValidationError()`, `NotImplementedError()` | Tạo lỗi chuẩn hóa có Status Code. |
157
+ | **model** | `buildRequestBody()`, `buildPaginationResponse()` | Tự động sinh OpenAPI schema từ Model. |
158
+ | **promise** | `delay(ms)` | Hàm ngủ async. |
159
+ | **axios** | `get()`, `post()`, `put()`, `del()` | Wrapper axios kèm xử lý lỗi chuẩn. |
139
160
 
140
161
  ---
141
162
 
142
163
  ## 🔑 8. Auth & Security
143
164
 
144
165
  ### 8.1 Authentication
166
+
145
167
  - Đăng ký `AuthenticateComponent`.
146
168
  - Hỗ trợ `JwtStrategy` (đọc secret từ `APP_ENV_APPLICATION_SECRET`).
147
169
 
148
170
  ### 8.2 Authorization (Casbin)
171
+
149
172
  ⚠️ Cần cài `casbin`.
173
+
150
174
  - `CasbinDrizzleAdapter`: Lưu Policy vào bảng DB do Drizzle quản lý.
151
175
  - `CasbinEnforcer`: Check quyền bằng cú pháp: `enforcer.enforce(user, object, action)`.
152
176
 
@@ -160,12 +184,14 @@ export const users = pgTable('users', {
160
184
  ...generateIdColumnDefs({ id: { dataType: 'string' } }),
161
185
  email: text('email').notNull().unique(),
162
186
  ...generateTzColumnDefs(),
163
- ...generateSoftDeleteColumnDefs()
187
+ ...generateSoftDeleteColumnDefs(),
164
188
  });
165
189
 
166
190
  // --- 2. Repository ---
167
191
  export class UserRepository extends SoftDeletableRepository<typeof users> {
168
- constructor() { super(users); }
192
+ constructor() {
193
+ super(users);
194
+ }
169
195
  }
170
196
 
171
197
  // --- 3. Controller ---
@@ -176,13 +202,13 @@ export class UserController extends BaseController {
176
202
  configs: {
177
203
  path: '/',
178
204
  method: 'get',
179
- responses: { 200: { description: 'List' } }
180
- }
205
+ responses: { 200: { description: 'List' } },
206
+ },
181
207
  }).to({
182
- handler: async (c) => {
208
+ handler: async c => {
183
209
  const repo = app.get<UserRepository>({ key: 'repositories.UserRepository' });
184
210
  return c.json(await repo.findAll());
185
- }
211
+ },
186
212
  });
187
213
  }
188
214
  }
@@ -197,4 +223,76 @@ export class UserController extends BaseController {
197
223
  - `bun run lint`: Kiểm tra code style các file mới thay đổi.
198
224
 
199
225
  ---
226
+
227
+ ## 11. Biến môi trường
228
+
229
+ | Tên biến | Mô tả | Giá trị mặc định |
230
+ | :------------------------------ | :------------------------------- | :--------------- |
231
+ | `APP_ENV_APPLICATION_NAME` | Tên ứng dụng xuất hiện trong log | `APP` |
232
+ | `APP_ENV_POSTGRES_HOST` | Địa chỉ PostgreSQL | `localhost` |
233
+ | `APP_ENV_POSTGRES_PORT` | Cổng PostgreSQL | `5432` |
234
+ | `APP_ENV_POSTGRES_USERNAME` | Username DB | `postgres` |
235
+ | `APP_ENV_POSTGRES_PASSWORD` | Password DB | `password` |
236
+ | `APP_ENV_POSTGRES_DATABASE` | Tên Database | `postgres` |
237
+ | `APP_ENV_REDIS_DATASOURCE_HOST` | Địa chỉ Redis | `0.0.0.0` |
238
+ | `APP_ENV_REDIS_DATASOURCE_PORT` | Cổng Redis | `6379` |
239
+ | `APP_ENV_LOGGER_FOLDER_PATH` | Đường dẫn lưu file log | `./app_data` |
240
+ | `DEBUG` | Kích hoạt log debug | `false` |
241
+
242
+ ---
243
+
244
+ ## 12. Ví dụ end-to-end: Order Service
245
+
246
+ ```typescript
247
+ // --- 1. Model (order.schema.ts) ---
248
+ export const orders = pgTable('orders', {
249
+ ...generateIdColumnDefs({ id: { dataType: 'string' } }),
250
+ item: text('item').notNull(),
251
+ ...generateTzColumnDefs(),
252
+ });
253
+
254
+ // --- 2. Repository (order.repository.ts) ---
255
+ export class OrderRepository extends DefaultCrudRepository<typeof orders> {
256
+ constructor() {
257
+ super(orders);
258
+ }
259
+ }
260
+
261
+ // --- 3. Service (order.service.ts) ---
262
+ export class OrderService extends BaseService {
263
+ async create(item: string) {
264
+ const repo = this.get<OrderRepository>('repositories.OrderRepository');
265
+ return repo.create({ item });
266
+ }
267
+ }
268
+
269
+ // --- 4. Controller (order.controller.ts) ---
270
+ @controller({ path: '/orders' })
271
+ export class OrderController extends BaseController {
272
+ async binding() {
273
+ this.bindRoute({
274
+ path: '/',
275
+ method: 'post',
276
+ responses: { 200: { description: 'Success' } },
277
+ }).to({
278
+ handler: async c => {
279
+ const service = this.get<OrderService>('services.OrderService');
280
+ return c.json(await service.create('Product A'));
281
+ },
282
+ });
283
+ }
284
+ }
285
+
286
+ // --- 5. Application (main.ts) ---
287
+ class OrderApp extends bootMixin(BaseApplication) {
288
+ getAppInfo() {
289
+ return { name: 'OrderAPI', version: '1.0' };
290
+ }
291
+ }
292
+
293
+ bootStrapApplication(OrderApp, { port: 8080 });
294
+ ```
295
+
296
+ ---
297
+
200
298
  © 2024 Gennex Technology. Toàn quyền bảo lưu.
@@ -1,7 +1,7 @@
1
1
  import type { OpenAPIHono } from '@hono/zod-openapi';
2
- import type { Logger } from '../../helpers';
2
+ import { Application, Binding } from '@loopback/core';
3
3
  import type { ValueOrPromise } from '../../common';
4
- import type { ClassType } from '../../common/types';
4
+ import type { Logger } from '../../helpers';
5
5
  export interface IApplicationConfigs {
6
6
  host?: string;
7
7
  port: number;
@@ -24,10 +24,9 @@ export interface IApplicationInfo {
24
24
  export interface IMiddlewareConfigs {
25
25
  [key: string]: any;
26
26
  }
27
- export declare abstract class BaseApplication {
27
+ export declare abstract class BaseApplication extends Application {
28
28
  protected logger: Logger;
29
- protected server: OpenAPIHono;
30
- protected bindings: Map<string, any>;
29
+ protected honoApp: OpenAPIHono;
31
30
  protected configs: IApplicationConfigs;
32
31
  constructor(configs: IApplicationConfigs);
33
32
  abstract getAppInfo(): ValueOrPromise<IApplicationInfo>;
@@ -35,22 +34,7 @@ export declare abstract class BaseApplication {
35
34
  preConfigure(): ValueOrPromise<void>;
36
35
  setupMiddlewares(): Promise<void>;
37
36
  postConfigure(): ValueOrPromise<void>;
38
- controller(_ControllerClass: new (...args: any[]) => any): void;
39
- repository(_RepositoryClass: new (...args: any[]) => any): void;
40
- dataSource(_DataSourceClass: new (...args: any[]) => any): void;
41
- service(_ServiceClass: new (...args: any[]) => any): void;
42
- component(_ComponentClass: new (...args: any[]) => any): void;
43
- bind<T>(opts: {
44
- key: string;
45
- }): {
46
- toValue: (v: T) => void;
47
- toClass: (c: ClassType<T>) => void;
48
- };
49
- get<T>(opts: {
50
- key: string;
51
- isOptional?: boolean;
52
- }): T;
53
- getServer(): OpenAPIHono;
37
+ getHono(): OpenAPIHono;
54
38
  start(): Promise<void>;
55
39
  stop(): Promise<void>;
56
40
  static(_opts: {
@@ -58,5 +42,12 @@ export declare abstract class BaseApplication {
58
42
  mountPath?: string;
59
43
  }): void;
60
44
  protected applyMiddlewares(_configs: IMiddlewareConfigs): Promise<void>;
45
+ bindCustom<T>(opts: {
46
+ key: string;
47
+ }): Binding<T>;
48
+ getCustom<T>(opts: {
49
+ key: string;
50
+ isOptional?: boolean;
51
+ }): ValueOrPromise<T | undefined>;
61
52
  }
62
53
  //# sourceMappingURL=base.application.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.application.d.ts","sourceRoot":"","sources":["../../../src/base/applications/base.application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5C,KAAK,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACvC,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,8BAAsB,eAAe;IACnC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,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,YAAY,IAAI,cAAc,CAAC,IAAI,CAAC;IAC9B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IACvC,aAAa,IAAI,cAAc,CAAC,IAAI,CAAC;IAErC,OAAO,IAAI,WAAW;IAIP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,MAAM,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;cAE/C,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7E,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAKhD,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,cAAc,CAAC,CAAC,GAAG,SAAS,CAAC;CAMzF"}
@@ -1,42 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseApplication = void 0;
4
+ const core_1 = require("@loopback/core");
4
5
  const helpers_1 = require("../../helpers");
5
- class BaseApplication {
6
+ class BaseApplication extends core_1.Application {
6
7
  constructor(configs) {
8
+ super();
7
9
  this.configs = configs;
8
10
  this.logger = helpers_1.LoggerFactory.getLogger(['Application']);
9
- this.bindings = new Map();
10
11
  const { OpenAPIHono } = require('@hono/zod-openapi');
11
- this.server = new OpenAPIHono();
12
+ this.honoApp = new OpenAPIHono();
12
13
  }
13
14
  staticConfigure() { }
14
15
  preConfigure() { }
15
16
  async setupMiddlewares() { }
16
17
  postConfigure() { }
17
- controller(_ControllerClass) { }
18
- repository(_RepositoryClass) { }
19
- dataSource(_DataSourceClass) { }
20
- service(_ServiceClass) { }
21
- component(_ComponentClass) { }
22
- bind(opts) {
23
- return {
24
- toValue: (v) => {
25
- this.bindings.set(opts.key, v);
26
- },
27
- toClass: (c) => {
28
- this.bindings.set(opts.key, new c());
29
- },
30
- };
31
- }
32
- get(opts) {
33
- if (!this.bindings.has(opts.key) && !opts.isOptional) {
34
- throw new Error(`Binding not found: ${opts.key}`);
35
- }
36
- return this.bindings.get(opts.key);
37
- }
38
- getServer() {
39
- return this.server;
18
+ getHono() {
19
+ return this.honoApp;
40
20
  }
41
21
  async start() {
42
22
  await this.preConfigure();
@@ -44,11 +24,29 @@ class BaseApplication {
44
24
  if (typeof this.boot === 'function') {
45
25
  await this.boot();
46
26
  }
27
+ // Unify Hono and LoopBack routes
28
+ const { HonoAdapter } = require('../hono/hono-adapter');
29
+ const adapter = new HonoAdapter(this);
30
+ await adapter.registerControllers();
47
31
  await this.postConfigure();
48
32
  }
49
- async stop() { }
33
+ async stop() {
34
+ await super.stop();
35
+ }
50
36
  static(_opts) { }
51
37
  async applyMiddlewares(_configs) { }
38
+ // Override bind to return a native Binding while maintaining compatibility if needed
39
+ // Note: LoopBack's bind already exists on Application
40
+ bindCustom(opts) {
41
+ return this.bind(opts.key);
42
+ }
43
+ // Override get to use LoopBack's get
44
+ getCustom(opts) {
45
+ if (opts.isOptional) {
46
+ return this.get(opts.key, { optional: true });
47
+ }
48
+ return this.get(opts.key);
49
+ }
52
50
  }
53
51
  exports.BaseApplication = BaseApplication;
54
52
  //# sourceMappingURL=base.application.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.application.js","sourceRoot":"","sources":["../../../src/base/applications/base.application.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAsB9C,MAAsB,eAAe;IAMnC,YAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GA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T,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,IAAI,OAAQ,IAAY,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7C,MAAO,IAAY,CAAC,IAAI,EAAE,CAAC;QAC7B,CAAC;QACD,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,IAAI,KAAmB,CAAC;IAE9B,MAAM,CAAC,KAAiD,IAAS,CAAC;IAExD,KAAK,CAAC,gBAAgB,CAAC,QAA4B,IAAkB,CAAC;CACjF;AA/DD,0CA+DC"}
1
+ {"version":3,"file":"base.application.js","sourceRoot":"","sources":["../../../src/base/applications/base.application.ts"],"names":[],"mappings":";;;AACA,yCAAsD;AAItD,2CAA8C;AAoB9C,MAAsB,eAAgB,SAAQ,kBAAW;IAKvD,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QACvD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IACnC,CAAC;IAID,eAAe,KAAU,CAAC;IAC1B,YAAY,KAA0B,CAAC;IACvC,KAAK,CAAC,gBAAgB,KAAmB,CAAC;IAC1C,aAAa,KAA0B,CAAC;IAExC,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEQ,KAAK,CAAC,KAAK;QAClB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,IAAI,OAAQ,IAAY,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7C,MAAO,IAAY,CAAC,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,iCAAiC;QACjC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEpC,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,KAAiD,IAAS,CAAC;IAExD,KAAK,CAAC,gBAAgB,CAAC,QAA4B,IAAkB,CAAC;IAEhF,qFAAqF;IACrF,sDAAsD;IACtD,UAAU,CAAI,IAAqB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,qCAAqC;IACrC,SAAS,CAAI,IAA2C;QACtD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AA5DD,0CA4DC"}
@@ -0,0 +1,10 @@
1
+ import { BaseApplication } from '../applications';
2
+ export declare class HonoAdapter {
3
+ private app;
4
+ constructor(app: BaseApplication);
5
+ /**
6
+ * Scans the LoopBack context for controllers and registers them as Hono routes.
7
+ */
8
+ registerControllers(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=hono-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono-adapter.d.ts","sourceRoot":"","sources":["../../../src/base/hono/hono-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,qBAAa,WAAW;IACV,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,eAAe;IAExC;;OAEG;IACG,mBAAmB;CAgB1B"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HonoAdapter = void 0;
4
+ const controllers_1 = require("../controllers");
5
+ class HonoAdapter {
6
+ constructor(app) {
7
+ this.app = app;
8
+ }
9
+ /**
10
+ * Scans the LoopBack context for controllers and registers them as Hono routes.
11
+ */
12
+ async registerControllers() {
13
+ const controllers = this.app.find('controllers.*');
14
+ for (const binding of controllers) {
15
+ const controllerClass = binding.valueConstructor;
16
+ if (!controllerClass) {
17
+ continue;
18
+ }
19
+ const instance = await this.app.get(binding.key);
20
+ if (instance instanceof controllers_1.BaseController) {
21
+ await instance.binding();
22
+ }
23
+ }
24
+ }
25
+ }
26
+ exports.HonoAdapter = HonoAdapter;
27
+ //# sourceMappingURL=hono-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono-adapter.js","sourceRoot":"","sources":["../../../src/base/hono/hono-adapter.ts"],"names":[],"mappings":";;;AACA,gDAAgD;AAEhD,MAAa,WAAW;IACtB,YAAoB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;IAAG,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,mBAAmB;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEnD,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;YAClC,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;YACjD,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEjD,IAAI,QAAQ,YAAY,4BAAc,EAAE,CAAC;gBACvC,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAtBD,kCAsBC"}
@@ -1,11 +1,12 @@
1
1
  import type { TTableSchema } from './drizzle.types';
2
2
  export interface IBaseEntityOptions<S extends TTableSchema> {
3
- name: string;
3
+ name?: string;
4
4
  schema: S;
5
5
  }
6
6
  export declare class BaseEntity<S extends TTableSchema = TTableSchema> {
7
7
  readonly tableName: string;
8
8
  readonly schema: S;
9
+ static TABLE_NAME?: string;
9
10
  constructor(opts: IBaseEntityOptions<S>);
10
11
  }
11
12
  //# sourceMappingURL=base.model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.model.d.ts","sourceRoot":"","sources":["../../../src/base/models/base.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,YAAY;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,CAAC;CACX;AAED,qBAAa,UAAU,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAEP,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAIxC"}
1
+ {"version":3,"file":"base.model.d.ts","sourceRoot":"","sources":["../../../src/base/models/base.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,YAAY;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,CAAC,CAAC;CACX;AAED,qBAAa,UAAU,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnB,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEf,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAKxC"}
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEntity = void 0;
4
4
  class BaseEntity {
5
5
  constructor(opts) {
6
- this.tableName = opts.name;
6
+ const ctor = this.constructor;
7
+ this.tableName = opts.name ?? ctor.TABLE_NAME ?? ctor.name;
7
8
  this.schema = opts.schema;
8
9
  }
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base.model.js","sourceRoot":"","sources":["../../../src/base/models/base.model.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAU;IAIrB,YAAY,IAA2B;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AARD,gCAQC"}
1
+ {"version":3,"file":"base.model.js","sourceRoot":"","sources":["../../../src/base/models/base.model.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAU;IAMrB,YAAY,IAA2B;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAgC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC;QAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AAXD,gCAWC"}
@@ -8,8 +8,8 @@ export declare function generateIdColumnDefs(opts: {
8
8
  id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"id", [string, ...string[]]>>>>;
9
9
  };
10
10
  export declare function generateTzColumnDefs(): {
11
- createdAt: import("drizzle-orm").NotNull<import("drizzle-orm", { with: { "resolution-mode": "import" } }).HasDefault<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"created_at">>>;
12
- modifiedAt: import("drizzle-orm").NotNull<import("drizzle-orm", { with: { "resolution-mode": "import" } }).HasDefault<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"modified_at">>>;
11
+ createdAt: import("drizzle-orm").NotNull<import("drizzle-orm").HasDefault<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"created_at">>>;
12
+ modifiedAt: import("drizzle-orm").NotNull<import("drizzle-orm").HasDefault<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"modified_at">>>;
13
13
  };
14
14
  export declare function generateSoftDeleteColumnDefs(): {
15
15
  deletedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"deleted_at">;
@@ -0,0 +1,15 @@
1
+ import { MetadataAccessor } from '@loopback/metadata';
2
+ export interface IModelMetadata {
3
+ type?: 'entity' | 'model';
4
+ skipMigrate?: boolean;
5
+ settings?: Record<string, any>;
6
+ }
7
+ export declare const MODEL_METADATA: MetadataAccessor<IModelMetadata, ClassDecorator>;
8
+ export declare function model(metadata?: IModelMetadata): ClassDecorator;
9
+ export interface IRepositoryMetadata {
10
+ dataSource?: string | any;
11
+ model?: any;
12
+ }
13
+ export declare const REPOSITORY_METADATA: MetadataAccessor<IRepositoryMetadata, ClassDecorator>;
14
+ export declare function repository(metadata?: IRepositoryMetadata): ClassDecorator;
15
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/base/models/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,kDAE1B,CAAC;AAEF,wBAAgB,KAAK,CAAC,QAAQ,GAAE,cAAmB,GAAG,cAAc,CAInE;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAC1B,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED,eAAO,MAAM,mBAAmB,uDAE/B,CAAC;AAEF,wBAAgB,UAAU,CAAC,QAAQ,GAAE,mBAAwB,GAAG,cAAc,CAI7E"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REPOSITORY_METADATA = exports.MODEL_METADATA = void 0;
4
+ exports.model = model;
5
+ exports.repository = repository;
6
+ const metadata_1 = require("@loopback/metadata");
7
+ exports.MODEL_METADATA = metadata_1.MetadataAccessor.create('gennext:model:metadata');
8
+ function model(metadata = {}) {
9
+ return function (target) {
10
+ Reflect.defineMetadata(exports.MODEL_METADATA.key, metadata, target);
11
+ };
12
+ }
13
+ exports.REPOSITORY_METADATA = metadata_1.MetadataAccessor.create('gennext:repository:metadata');
14
+ function repository(metadata = {}) {
15
+ return function (target) {
16
+ Reflect.defineMetadata(exports.REPOSITORY_METADATA.key, metadata, target);
17
+ };
18
+ }
19
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/base/models/decorators.ts"],"names":[],"mappings":";;;AAYA,sBAIC;AAWD,gCAIC;AA/BD,iDAAsD;AAQzC,QAAA,cAAc,GAAG,2BAAgB,CAAC,MAAM,CACnD,wBAAwB,CACzB,CAAC;AAEF,SAAgB,KAAK,CAAC,WAA2B,EAAE;IACjD,OAAO,UAAU,MAAW;QAC1B,OAAO,CAAC,cAAc,CAAC,sBAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAOY,QAAA,mBAAmB,GAAG,2BAAgB,CAAC,MAAM,CACxD,6BAA6B,CAC9B,CAAC;AAEF,SAAgB,UAAU,CAAC,WAAgC,EAAE;IAC3D,OAAO,UAAU,MAAW;QAC1B,OAAO,CAAC,cAAc,CAAC,2BAAmB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,7 @@
1
1
  export * from './base.model';
2
2
  export * from './column-defs';
3
3
  export * from './drizzle.types';
4
+ export * from './model.helper';
5
+ export * from './decorators';
4
6
  export type TBaseIdEntity = import('./base.model').BaseEntity<any>;
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAE7B,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC"}
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base.model"), exports);
18
18
  __exportStar(require("./column-defs"), exports);
19
19
  __exportStar(require("./drizzle.types"), exports);
20
+ __exportStar(require("./model.helper"), exports);
21
+ __exportStar(require("./decorators"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,gDAA8B;AAC9B,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,gDAA8B;AAC9B,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B"}
@@ -0,0 +1,7 @@
1
+ import { BaseEntity } from './base.model';
2
+ import { TTableSchema } from './drizzle.types';
3
+ /**
4
+ * A helper to define a Gennex Model which is both a Drizzle Table and a LoopBack-compatible Entity.
5
+ */
6
+ export declare function defineModel<S extends TTableSchema>(tableName: string, columns: any): BaseEntity<S>;
7
+ //# sourceMappingURL=model.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.helper.d.ts","sourceRoot":"","sources":["../../../src/base/models/model.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAChD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,GACX,UAAU,CAAC,CAAC,CAAC,CAMf"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineModel = defineModel;
4
+ const pg_core_1 = require("drizzle-orm/pg-core");
5
+ const base_model_1 = require("./base.model");
6
+ /**
7
+ * A helper to define a Gennex Model which is both a Drizzle Table and a LoopBack-compatible Entity.
8
+ */
9
+ function defineModel(tableName, columns) {
10
+ const schema = (0, pg_core_1.pgTable)(tableName, columns);
11
+ return new base_model_1.BaseEntity({
12
+ name: tableName,
13
+ schema,
14
+ });
15
+ }
16
+ //# sourceMappingURL=model.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.helper.js","sourceRoot":"","sources":["../../../src/base/models/model.helper.ts"],"names":[],"mappings":";;AAOA,kCASC;AAhBD,iDAA8C;AAC9C,6CAA0C;AAG1C;;GAEG;AACH,SAAgB,WAAW,CACzB,SAAiB,EACjB,OAAY;IAEZ,MAAM,MAAM,GAAG,IAAA,iBAAO,EAAC,SAAS,EAAE,OAAO,CAAiB,CAAC;IAC3D,OAAO,IAAI,uBAAU,CAAC;QACpB,IAAI,EAAE,SAAS;QACf,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}