@trafficgroup/knex-rel 0.1.19 → 0.1.21

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 (121) hide show
  1. package/.claude/settings.local.json +2 -5
  2. package/CLAUDE.md +11 -2
  3. package/dist/constants/folder.constants.d.ts +2 -2
  4. package/dist/constants/folder.constants.js +15 -6
  5. package/dist/constants/folder.constants.js.map +1 -1
  6. package/dist/constants/study.constants.d.ts +2 -2
  7. package/dist/constants/study.constants.js +11 -6
  8. package/dist/constants/study.constants.js.map +1 -1
  9. package/dist/constants/video.constants.d.ts +2 -2
  10. package/dist/constants/video.constants.js +9 -5
  11. package/dist/constants/video.constants.js.map +1 -1
  12. package/dist/dao/VideoMinuteResultDAO.d.ts +1 -1
  13. package/dist/dao/VideoMinuteResultDAO.js +29 -23
  14. package/dist/dao/VideoMinuteResultDAO.js.map +1 -1
  15. package/dist/dao/auth/auth.dao.js +4 -1
  16. package/dist/dao/auth/auth.dao.js.map +1 -1
  17. package/dist/dao/batch/batch.dao.d.ts +10 -0
  18. package/dist/dao/batch/batch.dao.js +51 -14
  19. package/dist/dao/batch/batch.dao.js.map +1 -1
  20. package/dist/dao/camera/camera.dao.js +10 -7
  21. package/dist/dao/camera/camera.dao.js.map +1 -1
  22. package/dist/dao/chat/chat.dao.d.ts +1 -1
  23. package/dist/dao/chat/chat.dao.js +27 -40
  24. package/dist/dao/chat/chat.dao.js.map +1 -1
  25. package/dist/dao/folder/folder.dao.js +18 -7
  26. package/dist/dao/folder/folder.dao.js.map +1 -1
  27. package/dist/dao/location/location.dao.js +16 -9
  28. package/dist/dao/location/location.dao.js.map +1 -1
  29. package/dist/dao/message/message.dao.d.ts +1 -1
  30. package/dist/dao/message/message.dao.js +18 -26
  31. package/dist/dao/message/message.dao.js.map +1 -1
  32. package/dist/dao/report-configuration/report-configuration.dao.js +32 -31
  33. package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
  34. package/dist/dao/study/study.dao.d.ts +1 -8
  35. package/dist/dao/study/study.dao.js +15 -20
  36. package/dist/dao/study/study.dao.js.map +1 -1
  37. package/dist/dao/systemConfiguration/SystemConfigurationDAO.d.ts +2 -2
  38. package/dist/dao/systemConfiguration/SystemConfigurationDAO.js +26 -26
  39. package/dist/dao/systemConfiguration/SystemConfigurationDAO.js.map +1 -1
  40. package/dist/dao/user/user.dao.js +4 -1
  41. package/dist/dao/user/user.dao.js.map +1 -1
  42. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +26 -8
  43. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
  44. package/dist/dao/video/video.dao.js +30 -28
  45. package/dist/dao/video/video.dao.js.map +1 -1
  46. package/dist/index.d.ts +9 -10
  47. package/dist/index.js +4 -4
  48. package/dist/index.js.map +1 -1
  49. package/dist/interfaces/batch/batch.interfaces.d.ts +1 -1
  50. package/dist/interfaces/camera/camera.interfaces.d.ts +1 -1
  51. package/dist/interfaces/chat/chat.interfaces.d.ts +3 -3
  52. package/dist/interfaces/folder/folder.interfaces.d.ts +1 -1
  53. package/dist/interfaces/message/message.interfaces.d.ts +2 -2
  54. package/dist/interfaces/study/study.interfaces.d.ts +8 -2
  55. package/dist/interfaces/user/user.interfaces.d.ts +1 -1
  56. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +1 -1
  57. package/dist/interfaces/video/video.interfaces.d.ts +2 -2
  58. package/migrations/20250717160737_migration.ts +1 -1
  59. package/migrations/20250717160908_migration.ts +5 -2
  60. package/migrations/20250717161310_migration.ts +1 -1
  61. package/migrations/20250717161406_migration.ts +3 -3
  62. package/migrations/20250717162431_migration.ts +1 -1
  63. package/migrations/20250717173228_migration.ts +2 -2
  64. package/migrations/20250717204731_migration.ts +1 -1
  65. package/migrations/20250722210109_migration.ts +8 -4
  66. package/migrations/20250722211019_migration.ts +1 -1
  67. package/migrations/20250723153852_migration.ts +13 -10
  68. package/migrations/20250723162257_migration.ts +4 -7
  69. package/migrations/20250723171109_migration.ts +4 -7
  70. package/migrations/20250723205331_migration.ts +6 -9
  71. package/migrations/20250724191345_migration.ts +8 -11
  72. package/migrations/20250730180932_migration.ts +14 -13
  73. package/migrations/20250730213625_migration.ts +8 -11
  74. package/migrations/20250804124509_migration.ts +26 -21
  75. package/migrations/20250804132053_migration.ts +5 -8
  76. package/migrations/20250804164518_migration.ts +7 -7
  77. package/migrations/20250823223016_migration.ts +32 -21
  78. package/migrations/20250910015452_migration.ts +18 -6
  79. package/migrations/20250911000000_migration.ts +18 -4
  80. package/migrations/20250917144153_migration.ts +14 -7
  81. package/migrations/20250930200521_migration.ts +8 -4
  82. package/migrations/20251010143500_migration.ts +27 -6
  83. package/migrations/20251020225758_migration.ts +51 -15
  84. package/migrations/20251112120000_migration.ts +10 -2
  85. package/migrations/20251112120200_migration.ts +19 -7
  86. package/migrations/20251112120300_migration.ts +7 -2
  87. package/migrations/20260109140000_migration.ts +7 -2
  88. package/package.json +1 -1
  89. package/src/constants/folder.constants.ts +17 -8
  90. package/src/constants/study.constants.ts +12 -7
  91. package/src/constants/video.constants.ts +11 -7
  92. package/src/d.types.ts +18 -14
  93. package/src/dao/VideoMinuteResultDAO.ts +83 -52
  94. package/src/dao/auth/auth.dao.ts +58 -55
  95. package/src/dao/batch/batch.dao.ts +145 -100
  96. package/src/dao/camera/camera.dao.ts +124 -121
  97. package/src/dao/chat/chat.dao.ts +45 -45
  98. package/src/dao/folder/folder.dao.ts +105 -90
  99. package/src/dao/location/location.dao.ts +109 -87
  100. package/src/dao/message/message.dao.ts +32 -32
  101. package/src/dao/reconciliation-log/reconciliation-log.dao.ts +1 -1
  102. package/src/dao/report-configuration/report-configuration.dao.ts +370 -342
  103. package/src/dao/study/study.dao.ts +94 -83
  104. package/src/dao/systemConfiguration/SystemConfigurationDAO.ts +41 -35
  105. package/src/dao/user/user.dao.ts +52 -50
  106. package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +80 -48
  107. package/src/dao/video/video.dao.ts +396 -345
  108. package/src/entities/BaseEntity.ts +1 -1
  109. package/src/index.ts +43 -29
  110. package/src/interfaces/auth/auth.interfaces.ts +10 -10
  111. package/src/interfaces/batch/batch.interfaces.ts +1 -1
  112. package/src/interfaces/camera/camera.interfaces.ts +9 -9
  113. package/src/interfaces/chat/chat.interfaces.ts +4 -4
  114. package/src/interfaces/folder/folder.interfaces.ts +2 -2
  115. package/src/interfaces/location/location.interfaces.ts +7 -7
  116. package/src/interfaces/message/message.interfaces.ts +3 -3
  117. package/src/interfaces/report-configuration/report-configuration.interfaces.ts +16 -16
  118. package/src/interfaces/study/study.interfaces.ts +10 -3
  119. package/src/interfaces/user/user.interfaces.ts +9 -9
  120. package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +9 -9
  121. package/src/interfaces/video/video.interfaces.ts +34 -34
@@ -1,22 +1,22 @@
1
1
  import { Knex } from "knex";
2
2
  import { IBaseDAO, IDataPaginator } from "../../d.types";
3
- import { IMessage, IMessageCreate, IMessageUpdate } from '../../interfaces/message/message.interfaces';
3
+ import {
4
+ IMessage,
5
+ IMessageCreate,
6
+ IMessageUpdate,
7
+ } from "../../interfaces/message/message.interfaces";
4
8
  import KnexManager from "../../KnexConnection";
5
9
 
6
10
  export class MessageDAO implements IBaseDAO<IMessage> {
7
11
  private _knex: Knex<any, unknown[]> = KnexManager.getConnection();
8
12
 
9
13
  async create(item: IMessageCreate): Promise<IMessage> {
10
- const [result] = await this._knex('message')
11
- .insert(item)
12
- .returning('*');
14
+ const [result] = await this._knex("message").insert(item).returning("*");
13
15
  return result;
14
16
  }
15
17
 
16
18
  async getById(id: number): Promise<IMessage | null> {
17
- const result = await this._knex('message')
18
- .where('id', id)
19
- .first();
19
+ const result = await this._knex("message").where("id", id).first();
20
20
  return result || null;
21
21
  }
22
22
 
@@ -27,13 +27,13 @@ export class MessageDAO implements IBaseDAO<IMessage> {
27
27
 
28
28
  async getAll(page = 1, limit = 10): Promise<IDataPaginator<IMessage>> {
29
29
  const offset = (page - 1) * limit;
30
-
30
+
31
31
  const [results, [{ count }]] = await Promise.all([
32
- this._knex('message')
33
- .orderBy('created_at', 'asc')
32
+ this._knex("message")
33
+ .orderBy("created_at", "asc")
34
34
  .limit(limit)
35
35
  .offset(offset),
36
- this._knex('message').count('* as count')
36
+ this._knex("message").count("* as count"),
37
37
  ]);
38
38
 
39
39
  const totalCount = parseInt(count as string);
@@ -44,40 +44,40 @@ export class MessageDAO implements IBaseDAO<IMessage> {
44
44
  limit,
45
45
  count: results.length,
46
46
  totalCount,
47
- totalPages: Math.ceil(totalCount / limit)
47
+ totalPages: Math.ceil(totalCount / limit),
48
48
  };
49
49
  }
50
50
 
51
51
  async update(id: number, item: IMessageUpdate): Promise<IMessage | null> {
52
- const [result] = await this._knex('message')
53
- .where('id', id)
52
+ const [result] = await this._knex("message")
53
+ .where("id", id)
54
54
  .update({
55
55
  ...item,
56
- updated_at: new Date()
56
+ updated_at: new Date(),
57
57
  })
58
- .returning('*');
58
+ .returning("*");
59
59
  return result || null;
60
60
  }
61
61
 
62
62
  async delete(id: number): Promise<boolean> {
63
- const result = await this._knex('message')
64
- .where('id', id)
65
- .delete();
63
+ const result = await this._knex("message").where("id", id).delete();
66
64
  return result > 0;
67
65
  }
68
66
 
69
- async getByChatId(chatId: number, page = 1, limit = 50): Promise<IDataPaginator<IMessage>> {
67
+ async getByChatId(
68
+ chatId: number,
69
+ page = 1,
70
+ limit = 50,
71
+ ): Promise<IDataPaginator<IMessage>> {
70
72
  const offset = (page - 1) * limit;
71
-
73
+
72
74
  const [results, [{ count }]] = await Promise.all([
73
- this._knex('message')
74
- .where('chatId', chatId)
75
- .orderBy('created_at', 'asc')
75
+ this._knex("message")
76
+ .where("chatId", chatId)
77
+ .orderBy("created_at", "asc")
76
78
  .limit(limit)
77
79
  .offset(offset),
78
- this._knex('message')
79
- .where('chatId', chatId)
80
- .count('* as count')
80
+ this._knex("message").where("chatId", chatId).count("* as count"),
81
81
  ]);
82
82
 
83
83
  const totalCount = parseInt(count as string);
@@ -88,15 +88,15 @@ export class MessageDAO implements IBaseDAO<IMessage> {
88
88
  limit,
89
89
  count: results.length,
90
90
  totalCount,
91
- totalPages: Math.ceil(totalCount / limit)
91
+ totalPages: Math.ceil(totalCount / limit),
92
92
  };
93
93
  }
94
94
 
95
95
  async getLatestMessages(chatId: number, limit = 50): Promise<IMessage[]> {
96
- return await this._knex('message')
97
- .where('chatId', chatId)
98
- .orderBy('created_at', 'desc')
96
+ return await this._knex("message")
97
+ .where("chatId", chatId)
98
+ .orderBy("created_at", "desc")
99
99
  .limit(limit)
100
100
  .then((messages: IMessage[]) => messages.reverse());
101
101
  }
102
- }
102
+ }
@@ -6,7 +6,7 @@ export class ReconciliationLogDAO {
6
6
  private _knex: Knex<any, unknown[]> = KnexManager.getConnection();
7
7
 
8
8
  async create(
9
- item: Omit<IReconciliationLog, "id">
9
+ item: Omit<IReconciliationLog, "id">,
10
10
  ): Promise<IReconciliationLog> {
11
11
  const [created] = await this._knex("reconciliation_log")
12
12
  .insert({