@tmscloud/tbt-knex 0.0.1
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/dist/KnexConnection.d.ts +17 -0
- package/dist/KnexConnection.js +81 -0
- package/dist/KnexConnection.js.map +1 -0
- package/dist/d.types.d.ts +16 -0
- package/dist/d.types.js +3 -0
- package/dist/d.types.js.map +1 -0
- package/dist/dao/driver-tracking/driver-tracking.dao.d.ts +42 -0
- package/dist/dao/driver-tracking/driver-tracking.dao.js +329 -0
- package/dist/dao/driver-tracking/driver-tracking.dao.js.map +1 -0
- package/dist/dao/gps-location/gps-location.dao.d.ts +76 -0
- package/dist/dao/gps-location/gps-location.dao.js +364 -0
- package/dist/dao/gps-location/gps-location.dao.js.map +1 -0
- package/dist/dao/role/role.dao.d.ts +38 -0
- package/dist/dao/role/role.dao.js +146 -0
- package/dist/dao/role/role.dao.js.map +1 -0
- package/dist/dao/route/route.dao.d.ts +38 -0
- package/dist/dao/route/route.dao.js +167 -0
- package/dist/dao/route/route.dao.js.map +1 -0
- package/dist/dao/route-assignment/route-assignment.dao.d.ts +58 -0
- package/dist/dao/route-assignment/route-assignment.dao.js +330 -0
- package/dist/dao/route-assignment/route-assignment.dao.js.map +1 -0
- package/dist/dao/sundays-package-version/sundays-package-version.dao.d.ts +11 -0
- package/dist/dao/sundays-package-version/sundays-package-version.dao.js +88 -0
- package/dist/dao/sundays-package-version/sundays-package-version.dao.js.map +1 -0
- package/dist/dao/trip/trip.dao.d.ts +102 -0
- package/dist/dao/trip/trip.dao.js +502 -0
- package/dist/dao/trip/trip.dao.js.map +1 -0
- package/dist/dao/user/user.dao.d.ts +74 -0
- package/dist/dao/user/user.dao.js +287 -0
- package/dist/dao/user/user.dao.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/driver-tracking/driver-tracking.interfaces.d.ts +102 -0
- package/dist/interfaces/driver-tracking/driver-tracking.interfaces.js +3 -0
- package/dist/interfaces/driver-tracking/driver-tracking.interfaces.js.map +1 -0
- package/dist/interfaces/gps-location/gps-location.interfaces.d.ts +30 -0
- package/dist/interfaces/gps-location/gps-location.interfaces.js +3 -0
- package/dist/interfaces/gps-location/gps-location.interfaces.js.map +1 -0
- package/dist/interfaces/role/role.interfaces.d.ts +8 -0
- package/dist/interfaces/role/role.interfaces.js +3 -0
- package/dist/interfaces/role/role.interfaces.js.map +1 -0
- package/dist/interfaces/route/route.interfaces.d.ts +23 -0
- package/dist/interfaces/route/route.interfaces.js +3 -0
- package/dist/interfaces/route/route.interfaces.js.map +1 -0
- package/dist/interfaces/route-assignment/route-assignment.interfaces.d.ts +18 -0
- package/dist/interfaces/route-assignment/route-assignment.interfaces.js +3 -0
- package/dist/interfaces/route-assignment/route-assignment.interfaces.js.map +1 -0
- package/dist/interfaces/sundays-package-version/sundays-package-version.interfaces.d.ts +6 -0
- package/dist/interfaces/sundays-package-version/sundays-package-version.interfaces.js +3 -0
- package/dist/interfaces/sundays-package-version/sundays-package-version.interfaces.js.map +1 -0
- package/dist/interfaces/trip/trip.interfaces.d.ts +46 -0
- package/dist/interfaces/trip/trip.interfaces.js +3 -0
- package/dist/interfaces/trip/trip.interfaces.js.map +1 -0
- package/dist/interfaces/user/user.interfaces.d.ts +25 -0
- package/dist/interfaces/user/user.interfaces.js +3 -0
- package/dist/interfaces/user/user.interfaces.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,167 @@
|
|
|
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.RouteDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class RouteDAO {
|
|
18
|
+
get knex() {
|
|
19
|
+
if (!this._knex) {
|
|
20
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
21
|
+
}
|
|
22
|
+
return this._knex;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse JSON fields from database
|
|
26
|
+
*/
|
|
27
|
+
parseRouteJson(route) {
|
|
28
|
+
return Object.assign(Object.assign({}, route), { geojson: typeof route.geojson === "string"
|
|
29
|
+
? JSON.parse(route.geojson)
|
|
30
|
+
: route.geojson, custom_instructions: typeof route.custom_instructions === "string"
|
|
31
|
+
? JSON.parse(route.custom_instructions)
|
|
32
|
+
: route.custom_instructions });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get all routes with pagination
|
|
36
|
+
*/
|
|
37
|
+
getAll() {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|
|
39
|
+
const offset = (page - 1) * limit;
|
|
40
|
+
// Get paginated data
|
|
41
|
+
const rawData = yield this.knex("routes")
|
|
42
|
+
.select("*")
|
|
43
|
+
.where("is_active", true)
|
|
44
|
+
.limit(limit)
|
|
45
|
+
.offset(offset)
|
|
46
|
+
.orderBy("created_at", "desc");
|
|
47
|
+
// Parse JSON fields
|
|
48
|
+
const data = rawData.map((route) => this.parseRouteJson(route));
|
|
49
|
+
// Get total count separately
|
|
50
|
+
const totalCountResult = yield this.knex("routes")
|
|
51
|
+
.where("is_active", true)
|
|
52
|
+
.count("* as count")
|
|
53
|
+
.first();
|
|
54
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
55
|
+
const count = data.length;
|
|
56
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
data,
|
|
60
|
+
page,
|
|
61
|
+
limit,
|
|
62
|
+
count,
|
|
63
|
+
totalCount,
|
|
64
|
+
totalPages,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get route by ID
|
|
70
|
+
*/
|
|
71
|
+
getById(id) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const result = yield this.knex("routes")
|
|
74
|
+
.select("*")
|
|
75
|
+
.where("id", id)
|
|
76
|
+
.first();
|
|
77
|
+
return result ? this.parseRouteJson(result) : null;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get route by UUID
|
|
82
|
+
*/
|
|
83
|
+
getByUuid(uuid) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const result = yield this.knex("routes")
|
|
86
|
+
.select("*")
|
|
87
|
+
.where("uuid", uuid)
|
|
88
|
+
.first();
|
|
89
|
+
return result ? this.parseRouteJson(result) : null;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a new route
|
|
94
|
+
*/
|
|
95
|
+
create(data) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const [result] = yield this.knex("routes")
|
|
98
|
+
.insert({
|
|
99
|
+
name: data.name,
|
|
100
|
+
description: data.description,
|
|
101
|
+
geojson: JSON.stringify(data.geojson),
|
|
102
|
+
custom_instructions: data.custom_instructions
|
|
103
|
+
? JSON.stringify(data.custom_instructions)
|
|
104
|
+
: null,
|
|
105
|
+
distance: data.distance,
|
|
106
|
+
estimated_duration: data.estimated_duration,
|
|
107
|
+
is_active: data.is_active !== undefined ? data.is_active : true,
|
|
108
|
+
})
|
|
109
|
+
.returning("*");
|
|
110
|
+
return this.parseRouteJson(result);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Update a route by ID
|
|
115
|
+
*/
|
|
116
|
+
update(id, data) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const updateData = {};
|
|
119
|
+
if (data.name !== undefined)
|
|
120
|
+
updateData.name = data.name;
|
|
121
|
+
if (data.description !== undefined)
|
|
122
|
+
updateData.description = data.description;
|
|
123
|
+
if (data.geojson !== undefined)
|
|
124
|
+
updateData.geojson = JSON.stringify(data.geojson);
|
|
125
|
+
if (data.custom_instructions !== undefined) {
|
|
126
|
+
updateData.custom_instructions = data.custom_instructions
|
|
127
|
+
? JSON.stringify(data.custom_instructions)
|
|
128
|
+
: null;
|
|
129
|
+
}
|
|
130
|
+
if (data.distance !== undefined)
|
|
131
|
+
updateData.distance = data.distance;
|
|
132
|
+
if (data.estimated_duration !== undefined)
|
|
133
|
+
updateData.estimated_duration = data.estimated_duration;
|
|
134
|
+
if (data.is_active !== undefined)
|
|
135
|
+
updateData.is_active = data.is_active;
|
|
136
|
+
updateData.updated_at = new Date();
|
|
137
|
+
const [result] = yield this.knex("routes")
|
|
138
|
+
.where("id", id)
|
|
139
|
+
.update(updateData)
|
|
140
|
+
.returning("*");
|
|
141
|
+
return result ? this.parseRouteJson(result) : null;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delete a route by ID (soft delete by setting is_active to false)
|
|
146
|
+
*/
|
|
147
|
+
delete(id) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const result = yield this.knex("routes").where("id", id).update({
|
|
150
|
+
is_active: false,
|
|
151
|
+
updated_at: new Date(),
|
|
152
|
+
});
|
|
153
|
+
return result > 0;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Hard delete a route by ID
|
|
158
|
+
*/
|
|
159
|
+
hardDelete(id) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const result = yield this.knex("routes").where("id", id).delete();
|
|
162
|
+
return result > 0;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.RouteDAO = RouteDAO;
|
|
167
|
+
//# sourceMappingURL=route.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.dao.js","sourceRoot":"","sources":["../../../src/dao/route/route.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAI/C,MAAa,QAAQ;IAGnB,IAAY,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,wBAAW,CAAC,aAAa,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,KAAU;QAC/B,uCACK,KAAK,KACR,OAAO,EACL,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;gBAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;gBAC3B,CAAC,CAAC,KAAK,CAAC,OAAO,EACnB,mBAAmB,EACjB,OAAO,KAAK,CAAC,mBAAmB,KAAK,QAAQ;gBAC3C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC;gBACvC,CAAC,CAAC,KAAK,CAAC,mBAAmB,IAC/B;IACJ,CAAC;IAED;;OAEG;IACG,MAAM;6DACV,OAAe,CAAC,EAChB,QAAgB,EAAE;YAElB,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK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C,EAAU;;YACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;gBAC9D,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,IAAI,IAAI,EAAE;aACvB,CAAC,CAAC;YAEH,OAAO,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KAAA;IAED;;OAEG;IACG,UAAU,CAAC,EAAU;;YACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;YAElE,OAAO,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KAAA;CACF;AApKD,4BAoKC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IRouteAssignment } from "../../interfaces/route-assignment/route-assignment.interfaces";
|
|
2
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
3
|
+
export declare class RouteAssignmentDAO implements IBaseDAO<IRouteAssignment> {
|
|
4
|
+
private _knex?;
|
|
5
|
+
private get knex();
|
|
6
|
+
/**
|
|
7
|
+
* Parse JSON fields from database
|
|
8
|
+
*/
|
|
9
|
+
private parseAssignmentJson;
|
|
10
|
+
/**
|
|
11
|
+
* Base query with all joins
|
|
12
|
+
*/
|
|
13
|
+
private baseQuery;
|
|
14
|
+
/**
|
|
15
|
+
* Get all assignments with pagination
|
|
16
|
+
*/
|
|
17
|
+
getAll(page?: number, limit?: number): Promise<IDataPaginator<IRouteAssignment>>;
|
|
18
|
+
/**
|
|
19
|
+
* Get assignment by ID
|
|
20
|
+
*/
|
|
21
|
+
getById(id: number): Promise<IRouteAssignment | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Get assignment by UUID
|
|
24
|
+
*/
|
|
25
|
+
getByUuid(uuid: string): Promise<IRouteAssignment | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get assignments by user ID
|
|
28
|
+
*/
|
|
29
|
+
getByUserId(userId: number, page?: number, limit?: number): Promise<IDataPaginator<IRouteAssignment>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get assignments by route ID
|
|
32
|
+
*/
|
|
33
|
+
getByRouteId(routeId: number, page?: number, limit?: number): Promise<IDataPaginator<IRouteAssignment>>;
|
|
34
|
+
/**
|
|
35
|
+
* Get active assignments for a user
|
|
36
|
+
*/
|
|
37
|
+
getActiveByUserId(userId: number): Promise<IRouteAssignment[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get assignments by status
|
|
40
|
+
*/
|
|
41
|
+
getByStatus(status: string, page?: number, limit?: number): Promise<IDataPaginator<IRouteAssignment>>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a new assignment
|
|
44
|
+
*/
|
|
45
|
+
create(data: IRouteAssignment): Promise<IRouteAssignment>;
|
|
46
|
+
/**
|
|
47
|
+
* Update an assignment by ID
|
|
48
|
+
*/
|
|
49
|
+
update(id: number, data: Partial<IRouteAssignment>): Promise<IRouteAssignment | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete an assignment by ID
|
|
52
|
+
*/
|
|
53
|
+
delete(id: number): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a user has an active assignment for a specific route
|
|
56
|
+
*/
|
|
57
|
+
hasActiveAssignment(userId: number, routeId: number): Promise<boolean>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
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.RouteAssignmentDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class RouteAssignmentDAO {
|
|
18
|
+
get knex() {
|
|
19
|
+
if (!this._knex) {
|
|
20
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
21
|
+
}
|
|
22
|
+
return this._knex;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse JSON fields from database
|
|
26
|
+
*/
|
|
27
|
+
parseAssignmentJson(assignment) {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
// Parse route JSON if present
|
|
30
|
+
if (assignment.route && typeof assignment.route === "string") {
|
|
31
|
+
assignment.route = JSON.parse(assignment.route);
|
|
32
|
+
}
|
|
33
|
+
if (((_a = assignment.route) === null || _a === void 0 ? void 0 : _a.geojson) &&
|
|
34
|
+
typeof assignment.route.geojson === "string") {
|
|
35
|
+
assignment.route.geojson = JSON.parse(assignment.route.geojson);
|
|
36
|
+
}
|
|
37
|
+
if (((_b = assignment.route) === null || _b === void 0 ? void 0 : _b.custom_instructions) &&
|
|
38
|
+
typeof assignment.route.custom_instructions === "string") {
|
|
39
|
+
assignment.route.custom_instructions = JSON.parse(assignment.route.custom_instructions);
|
|
40
|
+
}
|
|
41
|
+
// Parse user JSON if present
|
|
42
|
+
if (assignment.user && typeof assignment.user === "string") {
|
|
43
|
+
assignment.user = JSON.parse(assignment.user);
|
|
44
|
+
}
|
|
45
|
+
if (((_c = assignment.user) === null || _c === void 0 ? void 0 : _c.role) && typeof assignment.user.role === "string") {
|
|
46
|
+
assignment.user.role = JSON.parse(assignment.user.role);
|
|
47
|
+
}
|
|
48
|
+
// Parse assigner JSON if present
|
|
49
|
+
if (assignment.assigner && typeof assignment.assigner === "string") {
|
|
50
|
+
assignment.assigner = JSON.parse(assignment.assigner);
|
|
51
|
+
}
|
|
52
|
+
if (((_d = assignment.assigner) === null || _d === void 0 ? void 0 : _d.role) &&
|
|
53
|
+
typeof assignment.assigner.role === "string") {
|
|
54
|
+
assignment.assigner.role = JSON.parse(assignment.assigner.role);
|
|
55
|
+
}
|
|
56
|
+
return assignment;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Base query with all joins
|
|
60
|
+
*/
|
|
61
|
+
baseQuery() {
|
|
62
|
+
return this.knex("route_assignments as ra")
|
|
63
|
+
.leftJoin("routes as r", "ra.route_id", "r.id")
|
|
64
|
+
.leftJoin("users as u", "ra.user_id", "u.id")
|
|
65
|
+
.leftJoin("roles as ur", "u.role_id", "ur.id")
|
|
66
|
+
.leftJoin("users as assignedBy", "ra.assigned_by", "assignedBy.id")
|
|
67
|
+
.leftJoin("roles as ar", "assignedBy.role_id", "ar.id")
|
|
68
|
+
.select("ra.*", this.knex.raw("to_jsonb(r.*) as route"), this.knex.raw(`jsonb_build_object(
|
|
69
|
+
'id', u.id,
|
|
70
|
+
'uuid', u.uuid,
|
|
71
|
+
'email', u.email,
|
|
72
|
+
'username', u.username,
|
|
73
|
+
'first_name', u.first_name,
|
|
74
|
+
'last_name', u.last_name,
|
|
75
|
+
'role_id', u.role_id,
|
|
76
|
+
'is_active', u.is_active,
|
|
77
|
+
'role', to_jsonb(ur.*)
|
|
78
|
+
) as user`), this.knex.raw(`jsonb_build_object(
|
|
79
|
+
'id', "assignedBy".id,
|
|
80
|
+
'uuid', "assignedBy".uuid,
|
|
81
|
+
'email', "assignedBy".email,
|
|
82
|
+
'username', "assignedBy".username,
|
|
83
|
+
'first_name', "assignedBy".first_name,
|
|
84
|
+
'last_name', "assignedBy".last_name,
|
|
85
|
+
'role_id', "assignedBy".role_id,
|
|
86
|
+
'is_active', "assignedBy".is_active,
|
|
87
|
+
'role', to_jsonb(ar.*)
|
|
88
|
+
) as assigner`));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get all assignments with pagination
|
|
92
|
+
*/
|
|
93
|
+
getAll() {
|
|
94
|
+
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|
|
95
|
+
const offset = (page - 1) * limit;
|
|
96
|
+
// Get paginated data
|
|
97
|
+
const rawData = yield this.baseQuery()
|
|
98
|
+
.limit(limit)
|
|
99
|
+
.offset(offset)
|
|
100
|
+
.orderBy("ra.created_at", "desc");
|
|
101
|
+
// Parse JSON fields
|
|
102
|
+
const data = rawData.map((assignment) => this.parseAssignmentJson(assignment));
|
|
103
|
+
// Get total count
|
|
104
|
+
const totalCountResult = yield this.knex("route_assignments")
|
|
105
|
+
.count("* as count")
|
|
106
|
+
.first();
|
|
107
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
108
|
+
const count = data.length;
|
|
109
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
data,
|
|
113
|
+
page,
|
|
114
|
+
limit,
|
|
115
|
+
count,
|
|
116
|
+
totalCount,
|
|
117
|
+
totalPages,
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get assignment by ID
|
|
123
|
+
*/
|
|
124
|
+
getById(id) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const result = yield this.baseQuery().where("ra.id", id).first();
|
|
127
|
+
return result ? this.parseAssignmentJson(result) : null;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get assignment by UUID
|
|
132
|
+
*/
|
|
133
|
+
getByUuid(uuid) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const result = yield this.baseQuery().where("ra.uuid", uuid).first();
|
|
136
|
+
return result ? this.parseAssignmentJson(result) : null;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get assignments by user ID
|
|
141
|
+
*/
|
|
142
|
+
getByUserId(userId_1) {
|
|
143
|
+
return __awaiter(this, arguments, void 0, function* (userId, page = 1, limit = 10) {
|
|
144
|
+
const offset = (page - 1) * limit;
|
|
145
|
+
// Get paginated data
|
|
146
|
+
const rawData = yield this.baseQuery()
|
|
147
|
+
.where("ra.user_id", userId)
|
|
148
|
+
.limit(limit)
|
|
149
|
+
.offset(offset)
|
|
150
|
+
.orderBy("ra.start_date", "desc");
|
|
151
|
+
// Parse JSON fields
|
|
152
|
+
const data = rawData.map((assignment) => this.parseAssignmentJson(assignment));
|
|
153
|
+
// Get total count
|
|
154
|
+
const totalCountResult = yield this.knex("route_assignments")
|
|
155
|
+
.where("user_id", userId)
|
|
156
|
+
.count("* as count")
|
|
157
|
+
.first();
|
|
158
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
159
|
+
const count = data.length;
|
|
160
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
data,
|
|
164
|
+
page,
|
|
165
|
+
limit,
|
|
166
|
+
count,
|
|
167
|
+
totalCount,
|
|
168
|
+
totalPages,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get assignments by route ID
|
|
174
|
+
*/
|
|
175
|
+
getByRouteId(routeId_1) {
|
|
176
|
+
return __awaiter(this, arguments, void 0, function* (routeId, page = 1, limit = 10) {
|
|
177
|
+
const offset = (page - 1) * limit;
|
|
178
|
+
// Get paginated data
|
|
179
|
+
const rawData = yield this.baseQuery()
|
|
180
|
+
.where("ra.route_id", routeId)
|
|
181
|
+
.limit(limit)
|
|
182
|
+
.offset(offset)
|
|
183
|
+
.orderBy("ra.start_date", "desc");
|
|
184
|
+
// Parse JSON fields
|
|
185
|
+
const data = rawData.map((assignment) => this.parseAssignmentJson(assignment));
|
|
186
|
+
// Get total count
|
|
187
|
+
const totalCountResult = yield this.knex("route_assignments")
|
|
188
|
+
.where("route_id", routeId)
|
|
189
|
+
.count("* as count")
|
|
190
|
+
.first();
|
|
191
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
192
|
+
const count = data.length;
|
|
193
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
data,
|
|
197
|
+
page,
|
|
198
|
+
limit,
|
|
199
|
+
count,
|
|
200
|
+
totalCount,
|
|
201
|
+
totalPages,
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get active assignments for a user
|
|
207
|
+
*/
|
|
208
|
+
getActiveByUserId(userId) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const rawData = yield this.baseQuery()
|
|
211
|
+
.where("ra.user_id", userId)
|
|
212
|
+
.where("ra.status", "active")
|
|
213
|
+
.where("ra.start_date", "<=", new Date())
|
|
214
|
+
.where(function () {
|
|
215
|
+
this.whereNull("ra.end_date").orWhere("ra.end_date", ">=", new Date());
|
|
216
|
+
})
|
|
217
|
+
.orderBy("ra.start_date", "desc");
|
|
218
|
+
return rawData.map((assignment) => this.parseAssignmentJson(assignment));
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get assignments by status
|
|
223
|
+
*/
|
|
224
|
+
getByStatus(status_1) {
|
|
225
|
+
return __awaiter(this, arguments, void 0, function* (status, page = 1, limit = 10) {
|
|
226
|
+
const offset = (page - 1) * limit;
|
|
227
|
+
// Get paginated data
|
|
228
|
+
const rawData = yield this.baseQuery()
|
|
229
|
+
.where("ra.status", status)
|
|
230
|
+
.limit(limit)
|
|
231
|
+
.offset(offset)
|
|
232
|
+
.orderBy("ra.created_at", "desc");
|
|
233
|
+
// Parse JSON fields
|
|
234
|
+
const data = rawData.map((assignment) => this.parseAssignmentJson(assignment));
|
|
235
|
+
// Get total count
|
|
236
|
+
const totalCountResult = yield this.knex("route_assignments")
|
|
237
|
+
.where("status", status)
|
|
238
|
+
.count("* as count")
|
|
239
|
+
.first();
|
|
240
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
241
|
+
const count = data.length;
|
|
242
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
243
|
+
return {
|
|
244
|
+
success: true,
|
|
245
|
+
data,
|
|
246
|
+
page,
|
|
247
|
+
limit,
|
|
248
|
+
count,
|
|
249
|
+
totalCount,
|
|
250
|
+
totalPages,
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Create a new assignment
|
|
256
|
+
*/
|
|
257
|
+
create(data) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
const [result] = yield this.knex("route_assignments")
|
|
260
|
+
.insert({
|
|
261
|
+
route_id: data.route_id,
|
|
262
|
+
user_id: data.user_id,
|
|
263
|
+
assigned_by: data.assigned_by,
|
|
264
|
+
start_date: data.start_date,
|
|
265
|
+
end_date: data.end_date,
|
|
266
|
+
status: data.status || "active",
|
|
267
|
+
notes: data.notes,
|
|
268
|
+
})
|
|
269
|
+
.returning("*");
|
|
270
|
+
// Fetch with joins
|
|
271
|
+
return this.getById(result.id);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Update an assignment by ID
|
|
276
|
+
*/
|
|
277
|
+
update(id, data) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
const updateData = {};
|
|
280
|
+
if (data.route_id !== undefined)
|
|
281
|
+
updateData.route_id = data.route_id;
|
|
282
|
+
if (data.user_id !== undefined)
|
|
283
|
+
updateData.user_id = data.user_id;
|
|
284
|
+
if (data.start_date !== undefined)
|
|
285
|
+
updateData.start_date = data.start_date;
|
|
286
|
+
if (data.end_date !== undefined)
|
|
287
|
+
updateData.end_date = data.end_date;
|
|
288
|
+
if (data.status !== undefined)
|
|
289
|
+
updateData.status = data.status;
|
|
290
|
+
if (data.notes !== undefined)
|
|
291
|
+
updateData.notes = data.notes;
|
|
292
|
+
updateData.updated_at = new Date();
|
|
293
|
+
const [result] = yield this.knex("route_assignments")
|
|
294
|
+
.where("id", id)
|
|
295
|
+
.update(updateData)
|
|
296
|
+
.returning("*");
|
|
297
|
+
return result ? this.getById(result.id) : null;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Delete an assignment by ID
|
|
302
|
+
*/
|
|
303
|
+
delete(id) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
const result = yield this.knex("route_assignments")
|
|
306
|
+
.where("id", id)
|
|
307
|
+
.delete();
|
|
308
|
+
return result > 0;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Check if a user has an active assignment for a specific route
|
|
313
|
+
*/
|
|
314
|
+
hasActiveAssignment(userId, routeId) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
const result = yield this.knex("route_assignments")
|
|
317
|
+
.where("user_id", userId)
|
|
318
|
+
.where("route_id", routeId)
|
|
319
|
+
.where("status", "active")
|
|
320
|
+
.where("start_date", "<=", new Date())
|
|
321
|
+
.where(function () {
|
|
322
|
+
this.whereNull("end_date").orWhere("end_date", ">=", new Date());
|
|
323
|
+
})
|
|
324
|
+
.first();
|
|
325
|
+
return !!result;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.RouteAssignmentDAO = RouteAssignmentDAO;
|
|
330
|
+
//# sourceMappingURL=route-assignment.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-assignment.dao.js","sourceRoot":"","sources":["../../../src/dao/route-assignment/route-assignment.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAI/C,MAAa,kBAAkB;IAG7B,IAAY,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,wBAAW,CAAC,aAAa,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,UAAe;;QACzC,8BAA8B;QAC9B,IAAI,UAAU,CAAC,KAAK,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC7D,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,IACE,CAAA,MAAA,UAAU,CAAC,KAAK,0CAAE,OAAO;YACzB,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,EAC5C,CAAC;YACD,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClE,CAAC;QACD,IACE,CAAA,MAAA,UAAU,CAAC,KAAK,0CAAE,mBAAmB;YACrC,OAAO,UAAU,CAAC,KAAK,CAAC,mBAAmB,KAAK,QAAQ,EACxD,CAAC;YACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAC/C,UAAU,CAAC,KAAK,CAAC,mBAAmB,CACrC,CAAC;QACJ,CAAC;QAED,6BAA6B;QAC7B,IAAI,UAAU,CAAC,IAAI,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC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,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KAAA;IAED;;OAEG;IACG,mBAAmB,CAAC,MAAc,EAAE,OAAe;;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC;iBAChD,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC;iBACxB,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;iBACzB,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;iBACrC,KAAK,CAAC;gBACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YACnE,CAAC,CAAC;iBACD,KAAK,EAAE,CAAC;YAEX,OAAO,CAAC,CAAC,MAAM,CAAC;QAClB,CAAC;KAAA;CACF;AAjXD,gDAiXC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
2
|
+
import { ISundaysPackageVersion } from "../../interfaces/sundays-package-version/sundays-package-version.interfaces";
|
|
3
|
+
export declare class SundaysPackageVersionDAO implements IBaseDAO<ISundaysPackageVersion> {
|
|
4
|
+
private _knex;
|
|
5
|
+
create(item: ISundaysPackageVersion): Promise<ISundaysPackageVersion>;
|
|
6
|
+
getById(id: number): Promise<ISundaysPackageVersion | null>;
|
|
7
|
+
update(id: number, item: Partial<ISundaysPackageVersion>): Promise<ISundaysPackageVersion | null>;
|
|
8
|
+
delete(id: number): Promise<boolean>;
|
|
9
|
+
getAll(page: number, limit: number): Promise<IDataPaginator<ISundaysPackageVersion>>;
|
|
10
|
+
getLatestVersion(): Promise<ISundaysPackageVersion | null>;
|
|
11
|
+
}
|