@trafficgroup/knex-rel 0.1.17 → 0.1.19
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 +5 -2
- package/CLAUDE.md +2 -11
- package/dist/constants/folder.constants.d.ts +2 -2
- package/dist/constants/folder.constants.js +6 -15
- package/dist/constants/folder.constants.js.map +1 -1
- package/dist/constants/study.constants.d.ts +10 -0
- package/dist/constants/study.constants.js +18 -0
- package/dist/constants/study.constants.js.map +1 -0
- package/dist/constants/video.constants.d.ts +2 -2
- package/dist/constants/video.constants.js +5 -9
- package/dist/constants/video.constants.js.map +1 -1
- package/dist/dao/VideoMinuteResultDAO.d.ts +1 -1
- package/dist/dao/VideoMinuteResultDAO.js +23 -29
- package/dist/dao/VideoMinuteResultDAO.js.map +1 -1
- package/dist/dao/auth/auth.dao.js +1 -4
- package/dist/dao/auth/auth.dao.js.map +1 -1
- package/dist/dao/batch/batch.dao.js +14 -13
- package/dist/dao/batch/batch.dao.js.map +1 -1
- package/dist/dao/camera/camera.dao.js +7 -10
- 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 +40 -27
- package/dist/dao/chat/chat.dao.js.map +1 -1
- package/dist/dao/folder/folder.dao.js +7 -18
- package/dist/dao/folder/folder.dao.js.map +1 -1
- package/dist/dao/location/location.dao.js +9 -16
- 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 +26 -18
- package/dist/dao/message/message.dao.js.map +1 -1
- package/dist/dao/reconciliation-log/reconciliation-log.dao.d.ts +6 -0
- package/dist/dao/reconciliation-log/reconciliation-log.dao.js +39 -0
- package/dist/dao/reconciliation-log/reconciliation-log.dao.js.map +1 -0
- package/dist/dao/report-configuration/report-configuration.dao.js +31 -32
- package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
- package/dist/dao/study/study.dao.d.ts +8 -1
- package/dist/dao/study/study.dao.js +20 -11
- 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 +1 -4
- package/dist/dao/user/user.dao.js.map +1 -1
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +8 -26
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
- package/dist/dao/video/video.dao.js +28 -30
- package/dist/dao/video/video.dao.js.map +1 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.js +6 -1
- 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/reconciliation-log/reconciliation-log.interfaces.d.ts +15 -0
- package/dist/interfaces/reconciliation-log/reconciliation-log.interfaces.js +3 -0
- package/dist/interfaces/reconciliation-log/reconciliation-log.interfaces.js.map +1 -0
- package/dist/interfaces/study/study.interfaces.d.ts +2 -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 +2 -5
- 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 +4 -8
- package/migrations/20250722211019_migration.ts +1 -1
- package/migrations/20250723153852_migration.ts +10 -13
- package/migrations/20250723162257_migration.ts +7 -4
- package/migrations/20250723171109_migration.ts +7 -4
- package/migrations/20250723205331_migration.ts +9 -6
- package/migrations/20250724191345_migration.ts +11 -8
- package/migrations/20250730180932_migration.ts +13 -14
- package/migrations/20250730213625_migration.ts +11 -8
- package/migrations/20250804124509_migration.ts +21 -26
- package/migrations/20250804132053_migration.ts +8 -5
- package/migrations/20250804164518_migration.ts +7 -7
- package/migrations/20250823223016_migration.ts +21 -32
- package/migrations/20250910015452_migration.ts +6 -18
- package/migrations/20250911000000_migration.ts +4 -18
- package/migrations/20250917144153_migration.ts +7 -14
- package/migrations/20250930200521_migration.ts +4 -8
- package/migrations/20251010143500_migration.ts +6 -27
- package/migrations/20251020225758_migration.ts +15 -51
- package/migrations/20251112120000_migration.ts +2 -10
- package/migrations/20251112120200_migration.ts +7 -19
- package/migrations/20251112120300_migration.ts +2 -7
- package/migrations/20260109140000_migration.ts +2 -7
- package/migrations/20260209140000_migration.ts +27 -0
- package/package.json +1 -1
- package/src/constants/folder.constants.ts +8 -17
- package/src/constants/study.constants.ts +17 -0
- package/src/constants/video.constants.ts +7 -11
- package/src/d.types.ts +14 -18
- package/src/dao/VideoMinuteResultDAO.ts +52 -83
- package/src/dao/auth/auth.dao.ts +55 -58
- package/src/dao/batch/batch.dao.ts +98 -101
- package/src/dao/camera/camera.dao.ts +121 -124
- package/src/dao/chat/chat.dao.ts +45 -45
- package/src/dao/folder/folder.dao.ts +90 -105
- package/src/dao/location/location.dao.ts +87 -109
- package/src/dao/message/message.dao.ts +32 -32
- package/src/dao/reconciliation-log/reconciliation-log.dao.ts +26 -0
- package/src/dao/report-configuration/report-configuration.dao.ts +342 -370
- package/src/dao/study/study.dao.ts +84 -88
- package/src/dao/systemConfiguration/SystemConfigurationDAO.ts +35 -41
- package/src/dao/user/user.dao.ts +50 -52
- package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +48 -80
- package/src/dao/video/video.dao.ts +345 -396
- package/src/entities/BaseEntity.ts +1 -1
- package/src/index.ts +31 -37
- 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/reconciliation-log/reconciliation-log.interfaces.ts +15 -0
- package/src/interfaces/report-configuration/report-configuration.interfaces.ts +16 -16
- package/src/interfaces/study/study.interfaces.ts +3 -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 {
|
|
4
|
-
IMessage,
|
|
5
|
-
IMessageCreate,
|
|
6
|
-
IMessageUpdate,
|
|
7
|
-
} from "../../interfaces/message/message.interfaces";
|
|
3
|
+
import { IMessage, IMessageCreate, IMessageUpdate } from '../../interfaces/message/message.interfaces';
|
|
8
4
|
import KnexManager from "../../KnexConnection";
|
|
9
5
|
|
|
10
6
|
export class MessageDAO implements IBaseDAO<IMessage> {
|
|
11
7
|
private _knex: Knex<any, unknown[]> = KnexManager.getConnection();
|
|
12
8
|
|
|
13
9
|
async create(item: IMessageCreate): Promise<IMessage> {
|
|
14
|
-
const [result] = await this._knex(
|
|
10
|
+
const [result] = await this._knex('message')
|
|
11
|
+
.insert(item)
|
|
12
|
+
.returning('*');
|
|
15
13
|
return result;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
async getById(id: number): Promise<IMessage | null> {
|
|
19
|
-
const result = await this._knex(
|
|
17
|
+
const result = await this._knex('message')
|
|
18
|
+
.where('id', id)
|
|
19
|
+
.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(
|
|
63
|
+
const result = await this._knex('message')
|
|
64
|
+
.where('id', id)
|
|
65
|
+
.delete();
|
|
64
66
|
return result > 0;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
async getByChatId(
|
|
68
|
-
chatId: number,
|
|
69
|
-
page = 1,
|
|
70
|
-
limit = 50,
|
|
71
|
-
): Promise<IDataPaginator<IMessage>> {
|
|
69
|
+
async getByChatId(chatId: number, page = 1, limit = 50): Promise<IDataPaginator<IMessage>> {
|
|
72
70
|
const offset = (page - 1) * limit;
|
|
73
|
-
|
|
71
|
+
|
|
74
72
|
const [results, [{ count }]] = await Promise.all([
|
|
75
|
-
this._knex(
|
|
76
|
-
.where(
|
|
77
|
-
.orderBy(
|
|
73
|
+
this._knex('message')
|
|
74
|
+
.where('chatId', chatId)
|
|
75
|
+
.orderBy('created_at', 'asc')
|
|
78
76
|
.limit(limit)
|
|
79
77
|
.offset(offset),
|
|
80
|
-
this._knex(
|
|
78
|
+
this._knex('message')
|
|
79
|
+
.where('chatId', chatId)
|
|
80
|
+
.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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Knex } from "knex";
|
|
2
|
+
import { IReconciliationLog } from "../../interfaces/reconciliation-log/reconciliation-log.interfaces";
|
|
3
|
+
import KnexManager from "../../KnexConnection";
|
|
4
|
+
|
|
5
|
+
export class ReconciliationLogDAO {
|
|
6
|
+
private _knex: Knex<any, unknown[]> = KnexManager.getConnection();
|
|
7
|
+
|
|
8
|
+
async create(
|
|
9
|
+
item: Omit<IReconciliationLog, "id">
|
|
10
|
+
): Promise<IReconciliationLog> {
|
|
11
|
+
const [created] = await this._knex("reconciliation_log")
|
|
12
|
+
.insert({
|
|
13
|
+
...item,
|
|
14
|
+
errors: JSON.stringify(item.errors),
|
|
15
|
+
})
|
|
16
|
+
.returning("*");
|
|
17
|
+
return created;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async getLastRun(): Promise<IReconciliationLog | null> {
|
|
21
|
+
const record = await this._knex("reconciliation_log")
|
|
22
|
+
.orderBy("startedAt", "desc")
|
|
23
|
+
.first();
|
|
24
|
+
return record || null;
|
|
25
|
+
}
|
|
26
|
+
}
|