@trafficgroup/knex-rel 0.0.26 → 0.0.28

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 (94) 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 +20 -0
  31. package/dist/dao/video/video.dao.js +124 -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/migrations/20250804164518_migration.ts +17 -0
  75. package/package.json +47 -47
  76. package/src/d.types.ts +7 -7
  77. package/src/dao/auth/auth.dao.ts +61 -0
  78. package/src/dao/chat/chat.dao.ts +124 -0
  79. package/src/dao/folder/folder.dao.ts +66 -0
  80. package/src/dao/message/message.dao.ts +102 -0
  81. package/src/dao/study/study.dao.ts +66 -0
  82. package/src/dao/user/user.dao.ts +14 -10
  83. package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +65 -0
  84. package/src/dao/video/video.dao.ts +120 -0
  85. package/src/index.ts +23 -8
  86. package/src/interfaces/auth/auth.interfaces.ts +11 -0
  87. package/src/interfaces/chat/chat.interfaces.ts +20 -0
  88. package/src/interfaces/folder/folder.interfaces.ts +3 -0
  89. package/src/interfaces/message/message.interfaces.ts +18 -0
  90. package/src/interfaces/study/study.interfaces.ts +3 -0
  91. package/src/interfaces/user/user.interfaces.ts +2 -0
  92. package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +10 -0
  93. package/src/interfaces/video/video.interfaces.ts +9 -1
  94. package/.env +0 -5
@@ -0,0 +1,11 @@
1
+ export interface IAuth {
2
+ id: number;
3
+ userId: number;
4
+ password: string;
5
+ twofaEnabled: boolean;
6
+ twofaSecret: string | null;
7
+ emailToken: string | null;
8
+ emailVerified: boolean;
9
+ created_at: string;
10
+ updated_at: string;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=auth.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/auth/auth.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ export interface IChat {
2
+ id?: number;
3
+ uuid?: string;
4
+ userId: number;
5
+ title: string;
6
+ status?: 'active' | 'archived';
7
+ created_at?: Date;
8
+ updated_at?: Date;
9
+ }
10
+ export interface IChatCreate {
11
+ userId: number;
12
+ title: string;
13
+ status?: 'active' | 'archived';
14
+ }
15
+ export interface IChatUpdate {
16
+ title?: string;
17
+ status?: 'active' | 'archived';
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=chat.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/chat/chat.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { IStudy } from "../study/study.interfaces";
2
+ export interface IFolder {
3
+ id: number;
4
+ uuid: string;
5
+ name: string;
6
+ createdBy: number;
7
+ status: 'UPLOADING' | 'COMPLETE';
8
+ studyId: number;
9
+ created_at: string;
10
+ updated_at: string;
11
+ study?: IStudy;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=folder.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/folder/folder.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ export interface IMessage {
2
+ id?: number;
3
+ chatId: number;
4
+ role: 'user' | 'assistant';
5
+ content: string;
6
+ created_at?: Date;
7
+ updated_at?: Date;
8
+ }
9
+ export interface IMessageCreate {
10
+ chatId: number;
11
+ role: 'user' | 'assistant';
12
+ content: string;
13
+ }
14
+ export interface IMessageUpdate {
15
+ content?: string;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=message.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/message/message.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { IUser } from "../user/user.interfaces";
2
+ export interface IStudy {
3
+ id: number;
4
+ uuid: string;
5
+ name: string;
6
+ createdBy: number;
7
+ status: 'COMPLETE' | 'IN PROGRESS' | 'FAILED';
8
+ created_at: string;
9
+ updated_at: string;
10
+ user?: IUser;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=study.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"study.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/study/study.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export interface IUser {
2
+ id: number;
3
+ uuid: string;
4
+ email: string;
5
+ nombre: string;
6
+ role: 'ADMIN' | 'USER';
7
+ profilePhoto?: string;
8
+ company?: string;
9
+ created_at: string;
10
+ updated_at: string;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/user/user.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export interface IUserPushNotificationToken {
2
+ id: number;
3
+ userId: number;
4
+ token: string;
5
+ available: boolean;
6
+ token_type: 'expo' | 'native';
7
+ device_type?: string;
8
+ created_at: string;
9
+ updated_at: string;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user-push-notification-token.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-push-notification-token.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import type { IFolder } from "../folder/folder.interfaces";
2
+ export interface IVideo {
3
+ id: number;
4
+ uuid: string;
5
+ folderId: number;
6
+ name: string;
7
+ videoLocation: string;
8
+ videoOutputLocation: string | null;
9
+ generateVideoOutput: boolean;
10
+ videoRate: number;
11
+ videoType: 'TMC' | 'ATR' | 'JUNCTION' | 'ROUNDABOUT' | 'PATHWAY';
12
+ metadata: Record<string, any>;
13
+ status: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'PENDING';
14
+ progress: number;
15
+ remainingTime: string;
16
+ results: Record<string, any>;
17
+ created_at: string;
18
+ updated_at: string;
19
+ folder?: IFolder;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=video.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/video/video.interfaces.ts"],"names":[],"mappings":""}
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.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,
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,
13
13
  ssl: { rejectUnauthorized: false },
14
14
  },
15
15
  pool: {
@@ -0,0 +1,9 @@
1
+ import type { Knex } from "knex";
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ await knex.schema.renameTable("user", "users");
5
+ }
6
+
7
+ export async function down(knex: Knex): Promise<void> {
8
+ await knex.schema.renameTable("users", "user");
9
+ }
@@ -0,0 +1,13 @@
1
+ import type { Knex } from "knex";
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ await knex.schema.alterTable("video", (table) => {
5
+ table.string("name").notNullable().defaultTo("unnamed");
6
+ });
7
+ }
8
+
9
+ export async function down(knex: Knex): Promise<void> {
10
+ await knex.schema.alterTable("video", (table) => {
11
+ table.dropColumn("name");
12
+ });
13
+ }
@@ -0,0 +1,60 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ // 1. Crear el tipo ENUM nativo
6
+ await knex.raw(`CREATE TYPE "video_status" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'PENDING');`);
7
+
8
+ // 2. Normalizar los valores existentes
9
+ await knex.raw(`
10
+ UPDATE "video"
11
+ SET "status" = 'QUEUED'
12
+ WHERE "status" = 'QUEUE';
13
+ `);
14
+
15
+ // 3. Crear columna temporal del tipo ENUM
16
+ await knex.raw(`
17
+ ALTER TABLE "video"
18
+ ADD COLUMN "status_tmp" "video_status" DEFAULT 'PENDING';
19
+ `);
20
+
21
+ // 4. Copiar los valores de la columna original a la temporal
22
+ await knex.raw(`
23
+ UPDATE "video"
24
+ SET "status_tmp" = "status"::text::"video_status";
25
+ `);
26
+
27
+ // 5. Eliminar la columna original
28
+ await knex.raw(`
29
+ ALTER TABLE "video"
30
+ DROP COLUMN "status";
31
+ `);
32
+
33
+ // 6. Renombrar la columna temporal
34
+ await knex.raw(`
35
+ ALTER TABLE "video"
36
+ RENAME COLUMN "status_tmp" TO "status";
37
+ `);
38
+
39
+ // 7. Restaurar el default a 'PENDING'
40
+ await knex.raw(`
41
+ ALTER TABLE "video"
42
+ ALTER COLUMN "status" SET DEFAULT 'PENDING';
43
+ `);
44
+
45
+ // 8. Agregar columnas nuevas
46
+ await knex.schema.alterTable("video", (table) => {
47
+ table.integer("progress").notNullable().defaultTo(0);
48
+ table.string("remainingTime", 255).notNullable().defaultTo("0");
49
+ });
50
+ }
51
+
52
+ export async function down(knex: Knex): Promise<void> {
53
+ await knex.schema.alterTable("video", (table) => {
54
+ table.dropColumn("progress");
55
+ table.dropColumn("remainingTime");
56
+ table.specificType("status", "varchar(255)").notNullable().defaultTo("QUEUED").alter();
57
+ });
58
+ await knex.raw('DROP TYPE IF EXISTS "video_status";');
59
+ }
60
+
@@ -0,0 +1,15 @@
1
+ import type { Knex } from "knex";
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ await knex.raw(`
5
+ ALTER TABLE "video"
6
+ ALTER COLUMN "status" SET DEFAULT 'PENDING';
7
+ `);
8
+ }
9
+
10
+ export async function down(knex: Knex): Promise<void> {
11
+ await knex.raw(`
12
+ ALTER TABLE "video"
13
+ ALTER COLUMN "status" SET DEFAULT 'QUEUED';
14
+ `);
15
+ }
@@ -0,0 +1,19 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.createTable('auth', (table) => {
6
+ table.increments('id').primary();
7
+ table.integer('userId').unsigned().notNullable().references('id').inTable('users').onDelete('CASCADE');
8
+ table.string('password', 255).notNullable();
9
+ table.boolean('twofaEnabled').notNullable().defaultTo(false);
10
+ table.string('twofaSecret', 255).nullable();
11
+ table.timestamps(true, true);
12
+ });
13
+ }
14
+
15
+
16
+ export async function down(knex: Knex): Promise<void> {
17
+ await knex.schema.dropTableIfExists('auth');
18
+ }
19
+
@@ -0,0 +1,16 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.alterTable('video', (table) => {
6
+ table.boolean('generateVideoOutput').notNullable().defaultTo(false);
7
+ });
8
+ }
9
+
10
+
11
+ export async function down(knex: Knex): Promise<void> {
12
+ await knex.schema.alterTable('video', (table) => {
13
+ table.dropColumn('generateVideoOutput');
14
+ });
15
+ }
16
+
@@ -0,0 +1,16 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.alterTable('video', (table) => {
6
+ table.string('videoOutputLocation').nullable();
7
+ });
8
+ }
9
+
10
+
11
+ export async function down(knex: Knex): Promise<void> {
12
+ await knex.schema.alterTable('video', (table) => {
13
+ table.dropColumn('videoOutputLocation');
14
+ });
15
+ }
16
+
@@ -0,0 +1,18 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.alterTable('auth', (table) => {
6
+ table.string('emailToken', 255).nullable();
7
+ table.boolean('emailVerified').notNullable().defaultTo(false);
8
+ });
9
+ }
10
+
11
+
12
+ export async function down(knex: Knex): Promise<void> {
13
+ await knex.schema.alterTable('auth', (table) => {
14
+ table.dropColumn('emailToken');
15
+ table.dropColumn('emailVerified');
16
+ });
17
+ }
18
+
@@ -0,0 +1,18 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.alterTable('users', (table) => {
6
+ table.string('profilePhoto').nullable();
7
+ table.string('company').nullable();
8
+ });
9
+ }
10
+
11
+
12
+ export async function down(knex: Knex): Promise<void> {
13
+ await knex.schema.alterTable('users', (table) => {
14
+ table.dropColumn('profilePhoto');
15
+ table.dropColumn('company');
16
+ });
17
+ }
18
+
@@ -0,0 +1,22 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ return knex.schema.createTable('user_push_notification_token', (table) => {
6
+ table.increments('id').primary();
7
+ table.integer('userId').unsigned().notNullable();
8
+ table.string('token').notNullable();
9
+ table.boolean('available').defaultTo(true);
10
+ table.timestamps(true, true);
11
+
12
+ table.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
13
+ table.index(['userId']);
14
+ table.index(['token']);
15
+ });
16
+ }
17
+
18
+
19
+ export async function down(knex: Knex): Promise<void> {
20
+ return knex.schema.dropTable('user_push_notification_token');
21
+ }
22
+
@@ -0,0 +1,18 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ await knex.schema.alterTable('user_push_notification_token', (table) => {
6
+ table.string('token_type').defaultTo('expo').notNullable();
7
+ table.string('device_type');
8
+ });
9
+ }
10
+
11
+
12
+ export async function down(knex: Knex): Promise<void> {
13
+ await knex.schema.alterTable('user_push_notification_token', (table) => {
14
+ table.dropColumn('token_type');
15
+ table.dropColumn('device_type');
16
+ });
17
+ }
18
+
@@ -0,0 +1,43 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ // Create chat table
6
+ await knex.schema.createTable('chat', (table) => {
7
+ table.increments('id').primary();
8
+ table.integer('userId').unsigned().notNullable();
9
+ table.string('title', 255).notNullable();
10
+ table.enum('status', ['active', 'archived']).defaultTo('active');
11
+ table.timestamps(true, true);
12
+
13
+ // Foreign key
14
+ table.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
15
+
16
+ // Indexes
17
+ table.index('userId');
18
+ table.index('status');
19
+ });
20
+
21
+ // Create message table
22
+ await knex.schema.createTable('message', (table) => {
23
+ table.increments('id').primary();
24
+ table.integer('chatId').unsigned().notNullable();
25
+ table.enum('role', ['user', 'assistant']).notNullable();
26
+ table.text('content').notNullable();
27
+ table.timestamps(true, true);
28
+
29
+ // Foreign key
30
+ table.foreign('chatId').references('id').inTable('chat').onDelete('CASCADE');
31
+
32
+ // Indexes
33
+ table.index('chatId');
34
+ table.index('created_at');
35
+ });
36
+ }
37
+
38
+
39
+ export async function down(knex: Knex): Promise<void> {
40
+ await knex.schema.dropTableIfExists('message');
41
+ await knex.schema.dropTableIfExists('chat');
42
+ }
43
+
@@ -0,0 +1,18 @@
1
+ import type { Knex } from "knex";
2
+
3
+
4
+ export async function up(knex: Knex): Promise<void> {
5
+ // Add uuid column to chat table
6
+ await knex.schema.alterTable('chat', (table) => {
7
+ table.uuid('uuid').defaultTo(knex.raw('gen_random_uuid()')).notNullable();
8
+ table.index('uuid');
9
+ });
10
+ }
11
+
12
+
13
+ export async function down(knex: Knex): Promise<void> {
14
+ await knex.schema.alterTable('chat', (table) => {
15
+ table.dropColumn('uuid');
16
+ });
17
+ }
18
+
@@ -0,0 +1,17 @@
1
+ import type { Knex } from "knex";
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ // Add description and type columns to study table
5
+ await knex.schema.alterTable('study', (table) => {
6
+ table.text('description').nullable();
7
+ table.string('type', 50).notNullable().defaultTo('TMC');
8
+ });
9
+ }
10
+
11
+ export async function down(knex: Knex): Promise<void> {
12
+ // Remove description and type columns from study table
13
+ await knex.schema.alterTable('study', (table) => {
14
+ table.dropColumn('description');
15
+ table.dropColumn('type');
16
+ });
17
+ }
package/package.json CHANGED
@@ -1,47 +1,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
- }
1
+ {
2
+ "name": "@trafficgroup/knex-rel",
3
+ "version": "0.0.28",
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
+ }
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(): 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(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>;
18
18
  }