@trafficgroup/knex-rel 0.0.25 → 0.0.26

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 (75) hide show
  1. package/.env +5 -0
  2. package/knexfile.ts +5 -5
  3. package/package.json +47 -47
  4. package/src/d.types.ts +7 -7
  5. package/src/dao/user/user.dao.ts +10 -14
  6. package/src/index.ts +8 -19
  7. package/src/interfaces/folder/folder.interfaces.ts +0 -3
  8. package/src/interfaces/study/study.interfaces.ts +0 -3
  9. package/src/interfaces/user/user.interfaces.ts +0 -2
  10. package/src/interfaces/video/video.interfaces.ts +1 -9
  11. package/.claude/settings.local.json +0 -9
  12. package/CLAUDE.md +0 -63
  13. package/dist/KnexConnection.d.ts +0 -17
  14. package/dist/KnexConnection.js +0 -99
  15. package/dist/KnexConnection.js.map +0 -1
  16. package/dist/d.types.d.ts +0 -17
  17. package/dist/d.types.js +0 -3
  18. package/dist/d.types.js.map +0 -1
  19. package/dist/dao/auth/auth.dao.d.ts +0 -13
  20. package/dist/dao/auth/auth.dao.js +0 -82
  21. package/dist/dao/auth/auth.dao.js.map +0 -1
  22. package/dist/dao/folder/folder.dao.d.ts +0 -11
  23. package/dist/dao/folder/folder.dao.js +0 -84
  24. package/dist/dao/folder/folder.dao.js.map +0 -1
  25. package/dist/dao/study/study.dao.d.ts +0 -11
  26. package/dist/dao/study/study.dao.js +0 -84
  27. package/dist/dao/study/study.dao.js.map +0 -1
  28. package/dist/dao/user/user.dao.d.ts +0 -12
  29. package/dist/dao/user/user.dao.js +0 -76
  30. package/dist/dao/user/user.dao.js.map +0 -1
  31. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.d.ts +0 -14
  32. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +0 -87
  33. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +0 -1
  34. package/dist/dao/video/video.dao.d.ts +0 -13
  35. package/dist/dao/video/video.dao.js +0 -88
  36. package/dist/dao/video/video.dao.js.map +0 -1
  37. package/dist/index.d.ts +0 -15
  38. package/dist/index.js +0 -22
  39. package/dist/index.js.map +0 -1
  40. package/dist/interfaces/auth/auth.interfaces.d.ts +0 -11
  41. package/dist/interfaces/auth/auth.interfaces.js +0 -3
  42. package/dist/interfaces/auth/auth.interfaces.js.map +0 -1
  43. package/dist/interfaces/folder/folder.interfaces.d.ts +0 -12
  44. package/dist/interfaces/folder/folder.interfaces.js +0 -3
  45. package/dist/interfaces/folder/folder.interfaces.js.map +0 -1
  46. package/dist/interfaces/study/study.interfaces.d.ts +0 -11
  47. package/dist/interfaces/study/study.interfaces.js +0 -3
  48. package/dist/interfaces/study/study.interfaces.js.map +0 -1
  49. package/dist/interfaces/user/user.interfaces.d.ts +0 -11
  50. package/dist/interfaces/user/user.interfaces.js +0 -3
  51. package/dist/interfaces/user/user.interfaces.js.map +0 -1
  52. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +0 -10
  53. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js +0 -3
  54. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js.map +0 -1
  55. package/dist/interfaces/video/video.interfaces.d.ts +0 -20
  56. package/dist/interfaces/video/video.interfaces.js +0 -3
  57. package/dist/interfaces/video/video.interfaces.js.map +0 -1
  58. package/migrations/20250717173228_migration.ts +0 -9
  59. package/migrations/20250717204731_migration.ts +0 -13
  60. package/migrations/20250722210109_migration.ts +0 -60
  61. package/migrations/20250722211019_migration.ts +0 -15
  62. package/migrations/20250723153852_migration.ts +0 -19
  63. package/migrations/20250723162257_migration.ts +0 -16
  64. package/migrations/20250723171109_migration.ts +0 -16
  65. package/migrations/20250723205331_migration.ts +0 -18
  66. package/migrations/20250724191345_migration.ts +0 -18
  67. package/migrations/20250730180932_migration.ts +0 -22
  68. package/migrations/20250730213625_migration.ts +0 -18
  69. package/src/dao/auth/auth.dao.ts +0 -61
  70. package/src/dao/folder/folder.dao.ts +0 -66
  71. package/src/dao/study/study.dao.ts +0 -66
  72. package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +0 -65
  73. package/src/dao/video/video.dao.ts +0 -71
  74. package/src/interfaces/auth/auth.interfaces.ts +0 -11
  75. package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +0 -10
package/.env ADDED
@@ -0,0 +1,5 @@
1
+ PG_DB=trafficgroup
2
+ PG_USER=postgres
3
+ PG_PASSWORD=DGp$I%9xb42s$A
4
+ PG_HOST=trafficgroup-db.c2j4keo04gcg.us-east-1.rds.amazonaws.com
5
+ PG_PORT=5432
package/knexfile.ts CHANGED
@@ -5,11 +5,11 @@ const config: { [key: string]: Knex.Config } = {
5
5
  development: {
6
6
  client: "postgresql",
7
7
  connection: {
8
- database: process.env.SQL_DB_NAME,
9
- user: process.env.SQL_USER,
10
- password: process.env.SQL_PASSWORD,
11
- host: process.env.SQL_HOST,
12
- port: !!process.env.SQL_PORT ? +process.env.SQL_PORT : 54323,
8
+ database: process.env.PG_DB,
9
+ user: process.env.PG_USER,
10
+ password: process.env.PG_PASSWORD,
11
+ host: process.env.PG_HOST,
12
+ port: !!process.env.PG_PORT ? +process.env.PG_PORT : 54323,
13
13
  ssl: { rejectUnauthorized: false },
14
14
  },
15
15
  pool: {
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@trafficgroup/knex-rel",
3
- "version": "0.0.25",
4
- "description": "Knex Module",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "format": "prettier --write .",
9
- "build": "tsc",
10
- "clean": "rimraf dist && npm run format && npm run build",
11
- "npm:publish": "npm run clean && npm publish",
12
- "migrate:create": "knex migrate:make migration -x ts",
13
- "migrate:deploy": "knex migrate:latest",
14
- "seed:create": "knex seed:make seed -x ts",
15
- "seed:run": "knex seed:run"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/thetrafficgroup/knex-rel.git"
20
- },
21
- "author": "Genium, Inc",
22
- "license": "ISC",
23
- "bugs": {
24
- "url": "https://github.com/thetrafficgroup/knex-rel/issues"
25
- },
26
- "homepage": "https://github.com/thetrafficgroup/knex-rel#readme",
27
- "devDependencies": {
28
- "@eslint/js": "^9.23.0",
29
- "@types/dotenv": "^6.1.1",
30
- "@types/lodash": "^4.17.20",
31
- "@types/node": "^22.13.13",
32
- "eslint": "^9.23.0",
33
- "globals": "^16.0.0",
34
- "prettier": "^3.5.3",
35
- "rimraf": "^6.0.1",
36
- "ts-node": "^10.9.2",
37
- "typescript": "^5.8.2",
38
- "typescript-eslint": "^8.28.0"
39
- },
40
- "dependencies": {
41
- "dotenv": "^16.4.7",
42
- "knex": "^3.1.0",
43
- "lodash": "^4.17.21",
44
- "pg": "^8.14.1",
45
- "uuid": "^11.1.0"
46
- }
47
- }
1
+ {
2
+ "name": "@trafficgroup/knex-rel",
3
+ "version": "0.0.26",
4
+ "description": "Knex Module",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "format": "prettier --write .",
9
+ "build": "tsc",
10
+ "clean": "rimraf dist && npm run format && npm run build",
11
+ "npm:publish": "npm run clean && npm publish",
12
+ "migrate:create": "knex migrate:make migration -x ts",
13
+ "migrate:deploy": "knex migrate:latest",
14
+ "seed:create": "knex seed:make seed -x ts",
15
+ "seed:run": "knex seed:run"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/tms-world/knex-module.git"
20
+ },
21
+ "author": "Genium, Inc",
22
+ "license": "ISC",
23
+ "bugs": {
24
+ "url": "https://github.com/tms-world/knex-module/issues"
25
+ },
26
+ "homepage": "https://github.com/tms-world/knex-module#readme",
27
+ "devDependencies": {
28
+ "@eslint/js": "^9.23.0",
29
+ "@types/dotenv": "^6.1.1",
30
+ "@types/lodash": "^4.17.16",
31
+ "@types/node": "^22.13.13",
32
+ "eslint": "^9.23.0",
33
+ "globals": "^16.0.0",
34
+ "prettier": "^3.5.3",
35
+ "rimraf": "^6.0.1",
36
+ "ts-node": "^10.9.2",
37
+ "typescript": "^5.8.2",
38
+ "typescript-eslint": "^8.28.0"
39
+ },
40
+ "dependencies": {
41
+ "dotenv": "^16.4.7",
42
+ "knex": "^3.1.0",
43
+ "lodash": "^4.17.21",
44
+ "pg": "^8.14.1",
45
+ "uuid": "^11.1.0"
46
+ }
47
+ }
package/src/d.types.ts CHANGED
@@ -6,13 +6,13 @@ export interface IDataPaginator<T> {
6
6
  count: number;
7
7
  totalCount: number;
8
8
  totalPages: number;
9
- }
9
+ }
10
10
 
11
11
  export interface IBaseDAO<T> {
12
- create(item: T): Promise<T>;
13
- getById(id: number): Promise<T | null>;
14
- getByUuid(uuid: string): Promise<T | null>;
15
- getAll(page: number, limit: number, entityId?: any | null): Promise<IDataPaginator<T>>;
16
- update(id: number, item: T): Promise<T | null>;
17
- delete(id: number): Promise<boolean>;
12
+ create(item: T): Promise<T>;
13
+ getById(id: number): Promise<T | null>;
14
+ getByUuid(uuid: string): Promise<T | null>;
15
+ getAll(): Promise<IDataPaginator<T>>;
16
+ update(id: number, item: T): Promise<T | null>;
17
+ delete(id: number): Promise<boolean>;
18
18
  }
@@ -7,42 +7,38 @@ export class UserDAO implements IBaseDAO<IUser> {
7
7
  private _knex: Knex<any, unknown[]> = KnexManager.getConnection();
8
8
 
9
9
  async create(item: IUser): Promise<IUser> {
10
- const [createdUser] = await this._knex("users").insert(item).returning("*");
10
+ const [createdUser] = await this._knex("user").insert(item).returning("*");
11
11
  return createdUser;
12
12
  }
13
13
 
14
14
  async getById(id: number): Promise<IUser | null> {
15
- const user = await this._knex("users").where({ id }).first();
15
+ const user = await this._knex("user").where({ id }).first();
16
16
  return user || null;
17
17
  }
18
18
 
19
19
  async getByUuid(uuid: string): Promise<IUser | null> {
20
- const user = await this._knex("users").where({ uuid }).first();
21
- return user || null;
22
- }
23
-
24
-
25
- async getByEmail(email: string): Promise<IUser | null> {
26
- const user = await this._knex("users").where({ email }).first();
20
+ const user = await this._knex("user").where({ uuid }).first();
27
21
  return user || null;
28
22
  }
29
23
 
30
24
  async update(id: number, item: Partial<IUser>): Promise<IUser | null> {
31
- const [updatedUser] = await this._knex("users").where({ id }).update(item).returning("*");
25
+ const [updatedUser] = await this._knex("user").where({ id }).update(item).returning("*");
32
26
  return updatedUser || null;
33
27
  }
34
28
 
35
29
  async delete(id: number): Promise<boolean> {
36
- const result = await this._knex("users").where({ id }).del();
30
+ const result = await this._knex("user").where({ id }).del();
37
31
  return result > 0;
38
32
  }
39
33
 
40
- async getAll(page: number, limit: number): Promise<IDataPaginator<IUser>> {
34
+ async getAll(): Promise<IDataPaginator<IUser>> {
35
+ const page = 1; // Default to first page
36
+ const limit = 10; // Default limit
41
37
  const offset = (page - 1) * limit;
42
38
 
43
- const [countResult] = await this._knex("users").count("* as count");
39
+ const [countResult] = await this._knex("user").count("* as count");
44
40
  const totalCount = +countResult.count;
45
- const users = await this._knex("users").limit(limit).offset(offset);
41
+ const users = await this._knex("user").limit(limit).offset(offset);
46
42
 
47
43
  return {
48
44
  success: true,
package/src/index.ts CHANGED
@@ -1,19 +1,8 @@
1
- // DAOs
2
- export { UserDAO } from "./dao/user/user.dao";
3
- export { StudyDAO } from "./dao/study/study.dao";
4
- export { FolderDAO } from "./dao/folder/folder.dao";
5
- export { VideoDAO } from "./dao/video/video.dao";
6
- export { AuthDAO } from "./dao/auth/auth.dao";
7
- export { UserPushNotificationTokenDAO } from "./dao/user-push-notification-token/user-push-notification-token.dao";
8
-
9
- // Interfaces
10
- export { IDataPaginator } from "./d.types";
11
- export { IUser } from "./interfaces/user/user.interfaces";
12
- export { IStudy } from "./interfaces/study/study.interfaces";
13
- export { IFolder } from "./interfaces/folder/folder.interfaces";
14
- export { IVideo } from "./interfaces/video/video.interfaces";
15
- export { IAuth } from "./interfaces/auth/auth.interfaces";
16
- export { IUserPushNotificationToken } from "./interfaces/user-push-notification-token/user-push-notification-token.interfaces";
17
-
18
- import KnexManager from "./KnexConnection";
19
- export { KnexManager };
1
+ // DAOs
2
+ export { UserDAO } from "./dao/user/user.dao";
3
+
4
+ // Interfaces
5
+ export { IUser } from "./interfaces/user/user.interfaces";
6
+
7
+ import KnexManager from "./KnexConnection";
8
+ export { KnexManager };
@@ -1,5 +1,3 @@
1
- import type { IStudy } from "../study/study.interfaces";
2
-
3
1
  export interface IFolder {
4
2
  id: number;
5
3
  uuid: string;
@@ -9,5 +7,4 @@ export interface IFolder {
9
7
  studyId: number; // study.id
10
8
  created_at: string;
11
9
  updated_at: string;
12
- study?: IStudy;
13
10
  }
@@ -1,5 +1,3 @@
1
- import type { IUser } from "../user/user.interfaces";
2
-
3
1
  export interface IStudy {
4
2
  id: number;
5
3
  uuid: string;
@@ -8,5 +6,4 @@ export interface IStudy {
8
6
  status: 'COMPLETE' | 'IN PROGRESS' | 'FAILED';
9
7
  created_at: string;
10
8
  updated_at: string;
11
- user?: IUser;
12
9
  }
@@ -4,8 +4,6 @@ export interface IUser {
4
4
  email: string;
5
5
  nombre: string;
6
6
  role: 'ADMIN' | 'USER';
7
- profilePhoto?: string;
8
- company?: string;
9
7
  created_at: string;
10
8
  updated_at: string;
11
9
  }
@@ -1,21 +1,13 @@
1
- import type { IFolder } from "../folder/folder.interfaces";
2
-
3
1
  export interface IVideo {
4
2
  id: number;
5
3
  uuid: string;
6
4
  folderId: number;
7
- name: string;
8
5
  videoLocation: string;
9
- videoOutputLocation: string | null;
10
- generateVideoOutput: boolean;
11
6
  videoRate: number;
12
7
  videoType: 'TMC' | 'ATR' | 'JUNCTION' | 'ROUNDABOUT' | 'PATHWAY';
13
8
  metadata: Record<string, any>;
14
- status: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'PENDING';
15
- progress: number;
16
- remainingTime: string;
9
+ status: 'QUEUE' | 'PROCESSING' | 'COMPLETED' | 'FAILED';
17
10
  results: Record<string, any>;
18
11
  created_at: string;
19
12
  updated_at: string;
20
- folder?: IFolder;
21
13
  }
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm run migrate:*)",
5
- "Bash(mkdir:*)"
6
- ],
7
- "deny": []
8
- }
9
- }
package/CLAUDE.md DELETED
@@ -1,63 +0,0 @@
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.
@@ -1,17 +0,0 @@
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;
@@ -1,99 +0,0 @@
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
@@ -1 +0,0 @@
1
- {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"}
package/dist/d.types.d.ts DELETED
@@ -1,17 +0,0 @@
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
- }
package/dist/d.types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=d.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"d.types.js","sourceRoot":"","sources":["../src/d.types.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
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
- }
@@ -1,82 +0,0 @@
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
@@ -1 +0,0 @@
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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
@@ -1,11 +0,0 @@
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
- }