@trafficgroup/knex-rel 0.0.26 → 0.0.27

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 (93) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/CLAUDE.md +63 -0
  3. package/dist/KnexConnection.d.ts +17 -0
  4. package/dist/KnexConnection.js +99 -0
  5. package/dist/KnexConnection.js.map +1 -0
  6. package/dist/d.types.d.ts +17 -0
  7. package/dist/d.types.js +3 -0
  8. package/dist/d.types.js.map +1 -0
  9. package/dist/dao/auth/auth.dao.d.ts +13 -0
  10. package/dist/dao/auth/auth.dao.js +82 -0
  11. package/dist/dao/auth/auth.dao.js.map +1 -0
  12. package/dist/dao/chat/chat.dao.d.ts +13 -0
  13. package/dist/dao/chat/chat.dao.js +138 -0
  14. package/dist/dao/chat/chat.dao.js.map +1 -0
  15. package/dist/dao/folder/folder.dao.d.ts +11 -0
  16. package/dist/dao/folder/folder.dao.js +84 -0
  17. package/dist/dao/folder/folder.dao.js.map +1 -0
  18. package/dist/dao/message/message.dao.d.ts +13 -0
  19. package/dist/dao/message/message.dao.js +118 -0
  20. package/dist/dao/message/message.dao.js.map +1 -0
  21. package/dist/dao/study/study.dao.d.ts +11 -0
  22. package/dist/dao/study/study.dao.js +84 -0
  23. package/dist/dao/study/study.dao.js.map +1 -0
  24. package/dist/dao/user/user.dao.d.ts +12 -0
  25. package/dist/dao/user/user.dao.js +76 -0
  26. package/dist/dao/user/user.dao.js.map +1 -0
  27. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.d.ts +14 -0
  28. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +87 -0
  29. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -0
  30. package/dist/dao/video/video.dao.d.ts +13 -0
  31. package/dist/dao/video/video.dao.js +88 -0
  32. package/dist/dao/video/video.dao.js.map +1 -0
  33. package/dist/index.d.ts +19 -0
  34. package/dist/index.js +26 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/interfaces/auth/auth.interfaces.d.ts +11 -0
  37. package/dist/interfaces/auth/auth.interfaces.js +3 -0
  38. package/dist/interfaces/auth/auth.interfaces.js.map +1 -0
  39. package/dist/interfaces/chat/chat.interfaces.d.ts +18 -0
  40. package/dist/interfaces/chat/chat.interfaces.js +3 -0
  41. package/dist/interfaces/chat/chat.interfaces.js.map +1 -0
  42. package/dist/interfaces/folder/folder.interfaces.d.ts +12 -0
  43. package/dist/interfaces/folder/folder.interfaces.js +3 -0
  44. package/dist/interfaces/folder/folder.interfaces.js.map +1 -0
  45. package/dist/interfaces/message/message.interfaces.d.ts +16 -0
  46. package/dist/interfaces/message/message.interfaces.js +3 -0
  47. package/dist/interfaces/message/message.interfaces.js.map +1 -0
  48. package/dist/interfaces/study/study.interfaces.d.ts +11 -0
  49. package/dist/interfaces/study/study.interfaces.js +3 -0
  50. package/dist/interfaces/study/study.interfaces.js.map +1 -0
  51. package/dist/interfaces/user/user.interfaces.d.ts +11 -0
  52. package/dist/interfaces/user/user.interfaces.js +3 -0
  53. package/dist/interfaces/user/user.interfaces.js.map +1 -0
  54. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +10 -0
  55. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js +3 -0
  56. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js.map +1 -0
  57. package/dist/interfaces/video/video.interfaces.d.ts +20 -0
  58. package/dist/interfaces/video/video.interfaces.js +3 -0
  59. package/dist/interfaces/video/video.interfaces.js.map +1 -0
  60. package/knexfile.ts +5 -5
  61. package/migrations/20250717173228_migration.ts +9 -0
  62. package/migrations/20250717204731_migration.ts +13 -0
  63. package/migrations/20250722210109_migration.ts +60 -0
  64. package/migrations/20250722211019_migration.ts +15 -0
  65. package/migrations/20250723153852_migration.ts +19 -0
  66. package/migrations/20250723162257_migration.ts +16 -0
  67. package/migrations/20250723171109_migration.ts +16 -0
  68. package/migrations/20250723205331_migration.ts +18 -0
  69. package/migrations/20250724191345_migration.ts +18 -0
  70. package/migrations/20250730180932_migration.ts +22 -0
  71. package/migrations/20250730213625_migration.ts +18 -0
  72. package/migrations/20250804124509_migration.ts +43 -0
  73. package/migrations/20250804132053_migration.ts +18 -0
  74. package/package.json +47 -47
  75. package/src/d.types.ts +7 -7
  76. package/src/dao/auth/auth.dao.ts +61 -0
  77. package/src/dao/chat/chat.dao.ts +124 -0
  78. package/src/dao/folder/folder.dao.ts +66 -0
  79. package/src/dao/message/message.dao.ts +102 -0
  80. package/src/dao/study/study.dao.ts +66 -0
  81. package/src/dao/user/user.dao.ts +14 -10
  82. package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +65 -0
  83. package/src/dao/video/video.dao.ts +71 -0
  84. package/src/index.ts +23 -8
  85. package/src/interfaces/auth/auth.interfaces.ts +11 -0
  86. package/src/interfaces/chat/chat.interfaces.ts +20 -0
  87. package/src/interfaces/folder/folder.interfaces.ts +3 -0
  88. package/src/interfaces/message/message.interfaces.ts +18 -0
  89. package/src/interfaces/study/study.interfaces.ts +3 -0
  90. package/src/interfaces/user/user.interfaces.ts +2 -0
  91. package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +10 -0
  92. package/src/interfaces/video/video.interfaces.ts +9 -1
  93. package/.env +0 -5
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run migrate:*)",
5
+ "Bash(mkdir:*)"
6
+ ],
7
+ "deny": []
8
+ }
9
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,63 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is `@trafficgroup/knex-rel` - a TypeScript-based Knex.js module for database operations with PostgreSQL. It provides a standardized data access layer with DAOs (Data Access Objects) and interfaces for various entities.
8
+
9
+ ## Development Commands
10
+
11
+ ### Building and Formatting
12
+ - `npm run build` - Compile TypeScript to JavaScript in dist/
13
+ - `npm run format` - Format code with Prettier
14
+ - `npm run clean` - Clean dist/, format, and rebuild
15
+ - `npm test` - Run Jest tests
16
+
17
+ ### Database Operations
18
+ - `npm run migrate:create` - Create a new TypeScript migration file
19
+ - `npm run migrate:deploy` - Run all pending migrations
20
+ - `npm run seed:create` - Create a new TypeScript seed file
21
+ - `npm run seed:run` - Execute all seed files
22
+
23
+ ### Publishing
24
+ - `npm run npm:publish` - Clean, build, and publish to npm
25
+
26
+ ## Architecture
27
+
28
+ ### Core Components
29
+
30
+ **KnexManager** (`src/KnexConnection.ts`): Singleton connection manager
31
+ - `connect(config?, connections?)` - Establish database connection
32
+ - `getConnection()` - Get active connection instance
33
+ - `disconnect()` - Close connection and cleanup
34
+
35
+ **DAO Pattern**: All data access follows the `IBaseDAO<T>` interface with standard CRUD operations:
36
+ - `create(item)`, `getById(id)`, `getByUuid(uuid)`, `getAll(page, limit)`, `update(id, item)`, `delete(id)`
37
+ - Returns `IDataPaginator<T>` for paginated results
38
+
39
+ **AuthDAO Additional Methods**:
40
+ - `getByUserId(userId: number)` - Find auth record by user ID
41
+ - `getByEmailToken(emailToken: string)` - Find auth record by email verification/reset token
42
+
43
+ ### Entity Structure
44
+
45
+ Each entity has:
46
+ - Interface in `src/interfaces/[entity]/[entity].interfaces.ts`
47
+ - DAO implementation in `src/dao/[entity]/[entity].dao.ts`
48
+
49
+ Current entities: User, Study, Folder, Video
50
+
51
+ ### Database Configuration
52
+
53
+ Environment variables (for development):
54
+ - `SQL_HOST`, `SQL_USER`, `SQL_PASSWORD`, `SQL_DB_NAME`, `SQL_PORT`
55
+
56
+ Environment variables (for staging/production):
57
+ - `PG_HOST`, `PG_USER`, `PG_PASSWORD`, `PG_DB`, `PG_PORT`
58
+
59
+ Knex configuration supports development, staging, and production environments in `knexfile.ts`.
60
+
61
+ ### Migrations
62
+
63
+ Located in `migrations/` directory. Use TypeScript format with timestamp prefixes. Database uses `knex_migrations` table for tracking.
@@ -0,0 +1,17 @@
1
+ import { Knex } from "knex";
2
+ declare class KnexManager {
3
+ private static knexInstance;
4
+ /**
5
+ * Open a new connection. Reuse the already existing one if there's any.
6
+ */
7
+ static connect(config?: Knex.Config, connections?: number): Promise<Knex<any, unknown[]>>;
8
+ /**
9
+ * Devuelve la conexión activa.
10
+ */
11
+ static getConnection(): Knex<any, unknown[]>;
12
+ /**
13
+ * Cierra la conexión y destruye la instancia.
14
+ */
15
+ static disconnect(): Promise<void>;
16
+ }
17
+ export default KnexManager;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const knex_1 = require("knex");
13
+ class KnexManager {
14
+ /**
15
+ * Open a new connection. Reuse the already existing one if there's any.
16
+ */
17
+ static connect(config, connections) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ if (!KnexManager.knexInstance) {
20
+ const testConfig = {
21
+ client: "pg",
22
+ connection: {
23
+ host: process.env.SQL_HOST,
24
+ user: process.env.SQL_USER,
25
+ password: process.env.SQL_PASSWORD,
26
+ database: process.env.SQL_DB_NAME,
27
+ charset: "utf8mb4",
28
+ port: Number(process.env.SQL_PORT) || 5432,
29
+ ssl: { rejectUnauthorized: false },
30
+ },
31
+ pool: {
32
+ min: 1,
33
+ max: connections || 15,
34
+ idleTimeoutMillis: 20000,
35
+ acquireTimeoutMillis: 30000,
36
+ },
37
+ migrations: {
38
+ tableName: "knex_migrations",
39
+ },
40
+ };
41
+ KnexManager.knexInstance = (0, knex_1.knex)(config || {
42
+ client: "pg",
43
+ connection: {
44
+ host: process.env.SQL_HOST,
45
+ user: process.env.SQL_USER,
46
+ password: process.env.SQL_PASSWORD,
47
+ database: process.env.SQL_DB_NAME,
48
+ charset: "utf8mb4",
49
+ port: Number(process.env.SQL_PORT) || 5432,
50
+ ssl: { rejectUnauthorized: false },
51
+ },
52
+ pool: {
53
+ min: 1,
54
+ max: connections || 15,
55
+ idleTimeoutMillis: 20000,
56
+ acquireTimeoutMillis: 30000,
57
+ },
58
+ migrations: {
59
+ tableName: "knex_migrations",
60
+ },
61
+ });
62
+ try {
63
+ yield KnexManager.knexInstance.raw("SELECT 1");
64
+ console.info(`Knex connection established`);
65
+ }
66
+ catch (error) {
67
+ console.error(`Failed to establish Knex connection:`, error);
68
+ KnexManager.knexInstance = null;
69
+ throw error;
70
+ }
71
+ }
72
+ return KnexManager.knexInstance;
73
+ });
74
+ }
75
+ /**
76
+ * Devuelve la conexión activa.
77
+ */
78
+ static getConnection() {
79
+ if (!KnexManager.knexInstance) {
80
+ throw new Error("Knex connection has not been established. Call connect() first.");
81
+ }
82
+ return KnexManager.knexInstance;
83
+ }
84
+ /**
85
+ * Cierra la conexión y destruye la instancia.
86
+ */
87
+ static disconnect() {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ if (KnexManager.knexInstance) {
90
+ yield KnexManager.knexInstance.destroy();
91
+ KnexManager.knexInstance = null;
92
+ console.info(`Knex connection closed`);
93
+ }
94
+ });
95
+ }
96
+ }
97
+ KnexManager.knexInstance = null;
98
+ exports.default = KnexManager;
99
+ //# sourceMappingURL=KnexConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnexConnection.js","sourceRoot":"","sources":["../src/KnexConnection.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAAkC;AAElC,MAAM,WAAW;IAGf;;OAEG;IACH,MAAM,CAAO,OAAO,CAClB,MAAoB,EACpB,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AG,EAAE,WAAW,IAAI,EAAE;wBACtB,iBAAiB,EAAE,KAAK;wBACxB,oBAAoB,EAAE,KAAK;qBAC5B;oBACD,UAAU,EAAE;wBACV,SAAS,EAAE,iBAAiB;qBAC7B;iBACF,CACF,CAAC;gBACF,IAAI,CAAC;oBACH,MAAM,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC/C,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;gBAC9C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;oBAC7D,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC;oBAChC,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,WAAW,CAAC,YAAY,CAAC;QAClC,CAAC;KAAA;IAED;;OAEG;IACH,MAAM,CAAC,aAAa;QAClB,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,YAAY,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,MAAM,CAAO,UAAU;;YACrB,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC7B,MAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBACzC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC;gBAChC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;KAAA;;AAxFc,wBAAY,GAAgC,IAAI,CAAC;AA2FlE,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface IDataPaginator<T> {
2
+ success: boolean;
3
+ data: T[];
4
+ page: number;
5
+ limit: number;
6
+ count: number;
7
+ totalCount: number;
8
+ totalPages: number;
9
+ }
10
+ export interface IBaseDAO<T> {
11
+ create(item: T): Promise<T>;
12
+ getById(id: number): Promise<T | null>;
13
+ getByUuid(uuid: string): Promise<T | null>;
14
+ getAll(page: number, limit: number, entityId?: any | null): Promise<IDataPaginator<T>>;
15
+ update(id: number, item: T): Promise<T | null>;
16
+ delete(id: number): Promise<boolean>;
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=d.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d.types.js","sourceRoot":"","sources":["../src/d.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { IBaseDAO, IDataPaginator } from "../../d.types";
2
+ import { IAuth } from "../../interfaces/auth/auth.interfaces";
3
+ export declare class AuthDAO implements IBaseDAO<IAuth> {
4
+ private _knex;
5
+ create(item: IAuth): Promise<IAuth>;
6
+ getById(id: number): Promise<IAuth | null>;
7
+ getByUuid(uuid: string): Promise<IAuth | null>;
8
+ getByUserId(userId: number): Promise<IAuth | null>;
9
+ getByEmailToken(emailToken: string): Promise<IAuth | null>;
10
+ update(id: number, item: Partial<IAuth>): Promise<IAuth | null>;
11
+ delete(id: number): Promise<boolean>;
12
+ getAll(page: number, limit: number): Promise<IDataPaginator<IAuth>>;
13
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AuthDAO = void 0;
16
+ const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
17
+ class AuthDAO {
18
+ constructor() {
19
+ this._knex = KnexConnection_1.default.getConnection();
20
+ }
21
+ create(item) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [createdAuth] = yield this._knex("auth").insert(item).returning("*");
24
+ return createdAuth;
25
+ });
26
+ }
27
+ getById(id) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const auth = yield this._knex("auth").where({ id }).first();
30
+ return auth || null;
31
+ });
32
+ }
33
+ getByUuid(uuid) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ // Auth table doesn't have uuid, so we'll return null or throw error
36
+ return null;
37
+ });
38
+ }
39
+ getByUserId(userId) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const auth = yield this._knex("auth").where({ userId }).first();
42
+ return auth || null;
43
+ });
44
+ }
45
+ getByEmailToken(emailToken) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const auth = yield this._knex("auth").where({ emailToken }).first();
48
+ return auth || null;
49
+ });
50
+ }
51
+ update(id, item) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const [updatedAuth] = yield this._knex("auth").where({ id }).update(item).returning("*");
54
+ return updatedAuth || null;
55
+ });
56
+ }
57
+ delete(id) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const result = yield this._knex("auth").where({ id }).del();
60
+ return result > 0;
61
+ });
62
+ }
63
+ getAll(page, limit) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const offset = (page - 1) * limit;
66
+ const [countResult] = yield this._knex("auth").count("* as count");
67
+ const totalCount = +countResult.count;
68
+ const auths = yield this._knex("auth").limit(limit).offset(offset);
69
+ return {
70
+ success: true,
71
+ data: auths,
72
+ page,
73
+ limit,
74
+ count: auths.length,
75
+ totalCount,
76
+ totalPages: Math.ceil(totalCount / limit),
77
+ };
78
+ });
79
+ }
80
+ }
81
+ exports.AuthDAO = AuthDAO;
82
+ //# sourceMappingURL=auth.dao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.dao.js","sourceRoot":"","sources":["../../../src/dao/auth/auth.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,OAAO;IAApB;QACY,UAAK,GAAyB,wBAAW,CAAC,aAAa,EAAE,CAAC;IAsDtE,CAAC;IApDS,MAAM,CAAC,IAAW;;YACpB,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC3E,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;IAEK,OAAO,CAAC,EAAU;;YACpB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YAC5D,OAAO,IAAI,IAAI,IAAI,CAAC;QACxB,CAAC;KAAA;IAEK,SAAS,CAAC,IAAY;;YACxB,oEAAoE;YACpE,OAAO,IAAI,CAAC;QAChB,CAAC;KAAA;IAEK,WAAW,CAAC,MAAc;;YAC5B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YAChE,OAAO,IAAI,IAAI,IAAI,CAAC;QACxB,CAAC;KAAA;IAEK,eAAe,CAAC,UAAkB;;YACpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YACpE,OAAO,IAAI,IAAI,IAAI,CAAC;QACxB,CAAC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Chat, IChatCreate, IChatUpdate } from '../../interfaces/chat/chat.interfaces';
3
+ export declare class ChatDAO implements IBaseDAO<IChat> {
4
+ private _knex;
5
+ create(item: IChatCreate): Promise<IChat>;
6
+ getById(id: number): Promise<IChat | null>;
7
+ getByUuid(uuid: string): Promise<IChat | null>;
8
+ getAll(page?: number, limit?: number): Promise<IDataPaginator<IChat>>;
9
+ update(id: number, item: IChatUpdate): Promise<IChat | null>;
10
+ delete(id: number): Promise<boolean>;
11
+ getByUserId(userId: number, page?: number, limit?: number): Promise<IDataPaginator<IChat>>;
12
+ getActiveByUserId(userId: number, page?: number, limit?: number): Promise<IDataPaginator<IChat>>;
13
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ChatDAO = void 0;
16
+ const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
17
+ class ChatDAO {
18
+ constructor() {
19
+ this._knex = KnexConnection_1.default.getConnection();
20
+ }
21
+ create(item) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [result] = yield this._knex('chat')
24
+ .insert(item)
25
+ .returning('*');
26
+ return result;
27
+ });
28
+ }
29
+ getById(id) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const result = yield this._knex('chat')
32
+ .where('id', id)
33
+ .first();
34
+ return result || null;
35
+ });
36
+ }
37
+ getByUuid(uuid) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const result = yield this._knex('chat')
40
+ .where('uuid', uuid)
41
+ .first();
42
+ return result || null;
43
+ });
44
+ }
45
+ getAll() {
46
+ return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
47
+ const offset = (page - 1) * limit;
48
+ const [results, [{ count }]] = yield Promise.all([
49
+ this._knex('chat')
50
+ .orderBy('created_at', 'desc')
51
+ .limit(limit)
52
+ .offset(offset),
53
+ this._knex('chat').count('* as count')
54
+ ]);
55
+ const totalCount = parseInt(count);
56
+ return {
57
+ success: true,
58
+ data: results,
59
+ page,
60
+ limit,
61
+ count: results.length,
62
+ totalCount,
63
+ totalPages: Math.ceil(totalCount / limit)
64
+ };
65
+ });
66
+ }
67
+ update(id, item) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ const [result] = yield this._knex('chat')
70
+ .where('id', id)
71
+ .update(Object.assign(Object.assign({}, item), { updated_at: new Date() }))
72
+ .returning('*');
73
+ return result || null;
74
+ });
75
+ }
76
+ delete(id) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const result = yield this._knex('chat')
79
+ .where('id', id)
80
+ .delete();
81
+ return result > 0;
82
+ });
83
+ }
84
+ getByUserId(userId_1) {
85
+ return __awaiter(this, arguments, void 0, function* (userId, page = 1, limit = 10) {
86
+ const offset = (page - 1) * limit;
87
+ const [results, [{ count }]] = yield Promise.all([
88
+ this._knex('chat')
89
+ .where('userId', userId)
90
+ .orderBy('created_at', 'desc')
91
+ .limit(limit)
92
+ .offset(offset),
93
+ this._knex('chat')
94
+ .where('userId', userId)
95
+ .count('* as count')
96
+ ]);
97
+ const totalCount = parseInt(count);
98
+ return {
99
+ success: true,
100
+ data: results,
101
+ page,
102
+ limit,
103
+ count: results.length,
104
+ totalCount,
105
+ totalPages: Math.ceil(totalCount / limit)
106
+ };
107
+ });
108
+ }
109
+ getActiveByUserId(userId_1) {
110
+ return __awaiter(this, arguments, void 0, function* (userId, page = 1, limit = 10) {
111
+ const offset = (page - 1) * limit;
112
+ const [results, [{ count }]] = yield Promise.all([
113
+ this._knex('chat')
114
+ .where('userId', userId)
115
+ .where('status', 'active')
116
+ .orderBy('created_at', 'desc')
117
+ .limit(limit)
118
+ .offset(offset),
119
+ this._knex('chat')
120
+ .where('userId', userId)
121
+ .where('status', 'active')
122
+ .count('* as count')
123
+ ]);
124
+ const totalCount = parseInt(count);
125
+ return {
126
+ success: true,
127
+ data: results,
128
+ page,
129
+ limit,
130
+ count: results.length,
131
+ totalCount,
132
+ totalPages: Math.ceil(totalCount / limit)
133
+ };
134
+ });
135
+ }
136
+ }
137
+ exports.ChatDAO = ChatDAO;
138
+ //# sourceMappingURL=chat.dao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.dao.js","sourceRoot":"","sources":["../../../src/dao/chat/chat.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,OAAO;IAApB;QACU,UAAK,GAAyB,wBAAW,CAAC,aAAa,EAAE,CAAC;IAqHpE,CAAC;IAnHO,MAAM,CAAC,IAAiB;;YAC5B,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;iBACtC,MAAM,CAAC,IAAI,CAAC;iBACZ,SAAS,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;IAEK,OAAO,CAAC,EAAU;;YACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;iBACpC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;iBACf,KAAK,EAAE,CAAC;YACX,OAAO,MAAM,IAAI,IAAI,CAAC;QACxB,CAAC;KAAA;IAEK,SAAS,CAAC,IAAY;;YAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAA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E,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC/C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;qBACf,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;qBACvB,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;qBACzB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;qBAC7B,KAAK,CAAC,KAAK,CAAC;qBACZ,MAAM,CAAC,MAAM,CAAC;gBACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;qBACf,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;qBACvB,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;qBACzB,KAAK,CAAC,YAAY,CAAC;aACvB,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAe,CAAC,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC1C,CAAC;QACJ,CAAC;KAAA;CACF;AAtHD,0BAsHC"}
@@ -0,0 +1,11 @@
1
+ import { IBaseDAO, IDataPaginator } from "../../d.types";
2
+ import { IFolder } from "../../interfaces/folder/folder.interfaces";
3
+ export declare class FolderDAO implements IBaseDAO<IFolder> {
4
+ private _knex;
5
+ create(item: IFolder): Promise<IFolder>;
6
+ getById(id: number): Promise<IFolder | null>;
7
+ getByUuid(uuid: string): Promise<IFolder | null>;
8
+ update(id: number, item: Partial<IFolder>): Promise<IFolder | null>;
9
+ delete(id: number): Promise<boolean>;
10
+ getAll(page: number, limit: number, studyId?: number | null): Promise<IDataPaginator<IFolder>>;
11
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FolderDAO = void 0;
16
+ const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
17
+ class FolderDAO {
18
+ constructor() {
19
+ this._knex = KnexConnection_1.default.getConnection();
20
+ }
21
+ create(item) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [createdFolder] = yield this._knex("folders").insert(item).returning("*");
24
+ return createdFolder;
25
+ });
26
+ }
27
+ getById(id) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const folder = yield this._knex("folders as f")
30
+ .innerJoin("study as s", "f.studyId", "s.id")
31
+ .select("f.*", this._knex.raw("to_jsonb(s.*) as study"))
32
+ .where("f.id", id)
33
+ .first();
34
+ return folder || null;
35
+ });
36
+ }
37
+ getByUuid(uuid) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const folder = yield this._knex("folders as f")
40
+ .innerJoin("study as s", "f.studyId", "s.id")
41
+ .select("f.*", this._knex.raw("to_jsonb(s.*) as study"))
42
+ .where("f.uuid", uuid)
43
+ .first();
44
+ return folder || null;
45
+ });
46
+ }
47
+ update(id, item) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const [updatedFolder] = yield this._knex("folders").where({ id }).update(item).returning("*");
50
+ return updatedFolder || null;
51
+ });
52
+ }
53
+ delete(id) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const result = yield this._knex("folders").where({ id }).del();
56
+ return result > 0;
57
+ });
58
+ }
59
+ getAll(page, limit, studyId) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const offset = (page - 1) * limit;
62
+ const query = this._knex("folders as f")
63
+ .innerJoin("study as s", "f.studyId", "s.id")
64
+ .select("f.*", this._knex.raw("to_jsonb(s.*) as study"));
65
+ if (studyId !== undefined && studyId !== null) {
66
+ query.where("f.studyId", studyId);
67
+ }
68
+ const [countResult] = yield query.clone().clearSelect().count("* as count");
69
+ const totalCount = +countResult.count;
70
+ const folders = yield query.clone().limit(limit).offset(offset);
71
+ return {
72
+ success: true,
73
+ data: folders,
74
+ page,
75
+ limit,
76
+ count: folders.length,
77
+ totalCount,
78
+ totalPages: Math.ceil(totalCount / limit),
79
+ };
80
+ });
81
+ }
82
+ }
83
+ exports.FolderDAO = FolderDAO;
84
+ //# sourceMappingURL=folder.dao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.dao.js","sourceRoot":"","sources":["../../../src/dao/folder/folder.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,SAAS;IAAtB;QACY,UAAK,GAAyB,wBAAW,CAAC,aAAa,EAAE,CAAC;IA2DtE,CAAC;IAzDS,MAAM,CAAC,IAAa;;YACtB,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAChF,OAAO,aAAa,CAAC;QACzB,CAAC;KAAA;IAEK,OAAO,CAAC,EAAU;;YACpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;iBAC1C,SAAS,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC;iBAC5C,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAA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W,EAAE,MAAM,CAAC;iBAC5C,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC;YAC7D,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC5C,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACtC,CAAC;YAED,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC5E,MAAM,UAAU,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC;YACtC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEhE,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC5C,CAAC;QACN,CAAC;KAAA;CACJ;AA5DD,8BA4DC"}
@@ -0,0 +1,13 @@
1
+ import { IBaseDAO, IDataPaginator } from "../../d.types";
2
+ import { IMessage, IMessageCreate, IMessageUpdate } from '../../interfaces/message/message.interfaces';
3
+ export declare class MessageDAO implements IBaseDAO<IMessage> {
4
+ private _knex;
5
+ create(item: IMessageCreate): Promise<IMessage>;
6
+ getById(id: number): Promise<IMessage | null>;
7
+ getByUuid(uuid: string): Promise<IMessage | null>;
8
+ getAll(page?: number, limit?: number): Promise<IDataPaginator<IMessage>>;
9
+ update(id: number, item: IMessageUpdate): Promise<IMessage | null>;
10
+ delete(id: number): Promise<boolean>;
11
+ getByChatId(chatId: number, page?: number, limit?: number): Promise<IDataPaginator<IMessage>>;
12
+ getLatestMessages(chatId: number, limit?: number): Promise<IMessage[]>;
13
+ }