@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.
- package/.claude/settings.local.json +2 -5
- package/CLAUDE.md +11 -2
- package/dist/constants/folder.constants.d.ts +2 -2
- package/dist/constants/folder.constants.js +15 -6
- package/dist/constants/folder.constants.js.map +1 -1
- package/dist/constants/study.constants.d.ts +2 -2
- package/dist/constants/study.constants.js +11 -6
- package/dist/constants/study.constants.js.map +1 -1
- package/dist/constants/video.constants.d.ts +2 -2
- package/dist/constants/video.constants.js +9 -5
- package/dist/constants/video.constants.js.map +1 -1
- package/dist/dao/VideoMinuteResultDAO.d.ts +1 -1
- package/dist/dao/VideoMinuteResultDAO.js +29 -23
- package/dist/dao/VideoMinuteResultDAO.js.map +1 -1
- package/dist/dao/auth/auth.dao.js +4 -1
- package/dist/dao/auth/auth.dao.js.map +1 -1
- package/dist/dao/batch/batch.dao.d.ts +10 -0
- package/dist/dao/batch/batch.dao.js +51 -14
- package/dist/dao/batch/batch.dao.js.map +1 -1
- package/dist/dao/camera/camera.dao.js +10 -7
- package/dist/dao/camera/camera.dao.js.map +1 -1
- package/dist/dao/chat/chat.dao.d.ts +1 -1
- package/dist/dao/chat/chat.dao.js +27 -40
- package/dist/dao/chat/chat.dao.js.map +1 -1
- package/dist/dao/folder/folder.dao.js +18 -7
- package/dist/dao/folder/folder.dao.js.map +1 -1
- package/dist/dao/location/location.dao.js +16 -9
- package/dist/dao/location/location.dao.js.map +1 -1
- package/dist/dao/message/message.dao.d.ts +1 -1
- package/dist/dao/message/message.dao.js +18 -26
- package/dist/dao/message/message.dao.js.map +1 -1
- package/dist/dao/report-configuration/report-configuration.dao.js +32 -31
- package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
- package/dist/dao/study/study.dao.d.ts +1 -8
- package/dist/dao/study/study.dao.js +15 -20
- package/dist/dao/study/study.dao.js.map +1 -1
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.d.ts +2 -2
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.js +26 -26
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.js.map +1 -1
- package/dist/dao/user/user.dao.js +4 -1
- package/dist/dao/user/user.dao.js.map +1 -1
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +26 -8
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
- package/dist/dao/video/video.dao.js +30 -28
- package/dist/dao/video/video.dao.js.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces/batch/batch.interfaces.d.ts +1 -1
- package/dist/interfaces/camera/camera.interfaces.d.ts +1 -1
- package/dist/interfaces/chat/chat.interfaces.d.ts +3 -3
- package/dist/interfaces/folder/folder.interfaces.d.ts +1 -1
- package/dist/interfaces/message/message.interfaces.d.ts +2 -2
- package/dist/interfaces/study/study.interfaces.d.ts +8 -2
- package/dist/interfaces/user/user.interfaces.d.ts +1 -1
- package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +1 -1
- package/dist/interfaces/video/video.interfaces.d.ts +2 -2
- package/migrations/20250717160737_migration.ts +1 -1
- package/migrations/20250717160908_migration.ts +5 -2
- package/migrations/20250717161310_migration.ts +1 -1
- package/migrations/20250717161406_migration.ts +3 -3
- package/migrations/20250717162431_migration.ts +1 -1
- package/migrations/20250717173228_migration.ts +2 -2
- package/migrations/20250717204731_migration.ts +1 -1
- package/migrations/20250722210109_migration.ts +8 -4
- package/migrations/20250722211019_migration.ts +1 -1
- package/migrations/20250723153852_migration.ts +13 -10
- package/migrations/20250723162257_migration.ts +4 -7
- package/migrations/20250723171109_migration.ts +4 -7
- package/migrations/20250723205331_migration.ts +6 -9
- package/migrations/20250724191345_migration.ts +8 -11
- package/migrations/20250730180932_migration.ts +14 -13
- package/migrations/20250730213625_migration.ts +8 -11
- package/migrations/20250804124509_migration.ts +26 -21
- package/migrations/20250804132053_migration.ts +5 -8
- package/migrations/20250804164518_migration.ts +7 -7
- package/migrations/20250823223016_migration.ts +32 -21
- package/migrations/20250910015452_migration.ts +18 -6
- package/migrations/20250911000000_migration.ts +18 -4
- package/migrations/20250917144153_migration.ts +14 -7
- package/migrations/20250930200521_migration.ts +8 -4
- package/migrations/20251010143500_migration.ts +27 -6
- package/migrations/20251020225758_migration.ts +51 -15
- package/migrations/20251112120000_migration.ts +10 -2
- package/migrations/20251112120200_migration.ts +19 -7
- package/migrations/20251112120300_migration.ts +7 -2
- package/migrations/20260109140000_migration.ts +7 -2
- package/package.json +1 -1
- package/src/constants/folder.constants.ts +17 -8
- package/src/constants/study.constants.ts +12 -7
- package/src/constants/video.constants.ts +11 -7
- package/src/d.types.ts +18 -14
- package/src/dao/VideoMinuteResultDAO.ts +83 -52
- package/src/dao/auth/auth.dao.ts +58 -55
- package/src/dao/batch/batch.dao.ts +145 -100
- package/src/dao/camera/camera.dao.ts +124 -121
- package/src/dao/chat/chat.dao.ts +45 -45
- package/src/dao/folder/folder.dao.ts +105 -90
- package/src/dao/location/location.dao.ts +109 -87
- package/src/dao/message/message.dao.ts +32 -32
- package/src/dao/reconciliation-log/reconciliation-log.dao.ts +1 -1
- package/src/dao/report-configuration/report-configuration.dao.ts +370 -342
- package/src/dao/study/study.dao.ts +94 -83
- package/src/dao/systemConfiguration/SystemConfigurationDAO.ts +41 -35
- package/src/dao/user/user.dao.ts +52 -50
- package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +80 -48
- package/src/dao/video/video.dao.ts +396 -345
- package/src/entities/BaseEntity.ts +1 -1
- package/src/index.ts +43 -29
- package/src/interfaces/auth/auth.interfaces.ts +10 -10
- package/src/interfaces/batch/batch.interfaces.ts +1 -1
- package/src/interfaces/camera/camera.interfaces.ts +9 -9
- package/src/interfaces/chat/chat.interfaces.ts +4 -4
- package/src/interfaces/folder/folder.interfaces.ts +2 -2
- package/src/interfaces/location/location.interfaces.ts +7 -7
- package/src/interfaces/message/message.interfaces.ts +3 -3
- package/src/interfaces/report-configuration/report-configuration.interfaces.ts +16 -16
- package/src/interfaces/study/study.interfaces.ts +10 -3
- package/src/interfaces/user/user.interfaces.ts +9 -9
- package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +9 -9
- 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 {
|
|
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(
|
|
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(
|
|
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(
|
|
33
|
-
.orderBy(
|
|
32
|
+
this._knex("message")
|
|
33
|
+
.orderBy("created_at", "asc")
|
|
34
34
|
.limit(limit)
|
|
35
35
|
.offset(offset),
|
|
36
|
-
this._knex(
|
|
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(
|
|
53
|
-
.where(
|
|
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(
|
|
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(
|
|
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(
|
|
74
|
-
.where(
|
|
75
|
-
.orderBy(
|
|
75
|
+
this._knex("message")
|
|
76
|
+
.where("chatId", chatId)
|
|
77
|
+
.orderBy("created_at", "asc")
|
|
76
78
|
.limit(limit)
|
|
77
79
|
.offset(offset),
|
|
78
|
-
this._knex(
|
|
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(
|
|
97
|
-
.where(
|
|
98
|
-
.orderBy(
|
|
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({
|