@voyantjs/ground 0.2.0 → 0.3.0
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/schema-dispatch.d.ts +733 -0
- package/dist/schema-dispatch.d.ts.map +1 -0
- package/dist/schema-dispatch.js +79 -0
- package/dist/schema-operations.d.ts +1368 -0
- package/dist/schema-operations.d.ts.map +1 -0
- package/dist/schema-operations.js +155 -0
- package/dist/schema-operators.d.ts +625 -0
- package/dist/schema-operators.d.ts.map +1 -0
- package/dist/schema-operators.js +62 -0
- package/dist/schema-relations.d.ts +63 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +152 -0
- package/dist/schema-shared.d.ts +12 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +84 -0
- package/dist/schema.d.ts +5 -2796
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -513
- package/dist/service-dispatch-core.d.ts +255 -0
- package/dist/service-dispatch-core.d.ts.map +1 -0
- package/dist/service-dispatch-core.js +171 -0
- package/dist/service-dispatch-ops.d.ts +307 -0
- package/dist/service-dispatch-ops.d.ts.map +1 -0
- package/dist/service-dispatch-ops.js +272 -0
- package/dist/service-resources.d.ts +251 -0
- package/dist/service-resources.d.ts.map +1 -0
- package/dist/service-resources.js +183 -0
- package/dist/service-shared.d.ts +48 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +7 -0
- package/dist/service.d.ts +63 -844
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +63 -628
- package/package.json +6 -6
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CreateGroundDispatchAssignmentInput, CreateGroundDispatchCheckpointInput, CreateGroundDispatchLegInput, CreateGroundDispatchPassengerInput, CreateGroundServiceIncidentInput, GroundDispatchAssignmentListQuery, GroundDispatchCheckpointListQuery, GroundDispatchLegListQuery, GroundDispatchPassengerListQuery, GroundServiceIncidentListQuery, UpdateGroundDispatchAssignmentInput, UpdateGroundDispatchCheckpointInput, UpdateGroundDispatchLegInput, UpdateGroundDispatchPassengerInput, UpdateGroundServiceIncidentInput } from "./service-shared.js";
|
|
3
|
+
export declare function listDispatchAssignments(db: PostgresJsDatabase, query: GroundDispatchAssignmentListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
dispatchId: string;
|
|
7
|
+
operatorId: string | null;
|
|
8
|
+
vehicleId: string | null;
|
|
9
|
+
driverId: string | null;
|
|
10
|
+
assignmentSource: "manual" | "suggested" | "auto";
|
|
11
|
+
assignedAt: Date;
|
|
12
|
+
acceptedAt: Date | null;
|
|
13
|
+
notes: string | null;
|
|
14
|
+
metadata: Record<string, unknown> | null;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
updatedAt: Date;
|
|
17
|
+
}[];
|
|
18
|
+
total: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function getDispatchAssignmentById(db: PostgresJsDatabase, id: string): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
dispatchId: string;
|
|
25
|
+
operatorId: string | null;
|
|
26
|
+
vehicleId: string | null;
|
|
27
|
+
driverId: string | null;
|
|
28
|
+
assignmentSource: "manual" | "suggested" | "auto";
|
|
29
|
+
assignedAt: Date;
|
|
30
|
+
acceptedAt: Date | null;
|
|
31
|
+
notes: string | null;
|
|
32
|
+
metadata: Record<string, unknown> | null;
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
} | null>;
|
|
36
|
+
export declare function createDispatchAssignment(db: PostgresJsDatabase, data: CreateGroundDispatchAssignmentInput): Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
notes: string | null;
|
|
39
|
+
metadata: Record<string, unknown> | null;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date;
|
|
42
|
+
operatorId: string | null;
|
|
43
|
+
vehicleId: string | null;
|
|
44
|
+
driverId: string | null;
|
|
45
|
+
dispatchId: string;
|
|
46
|
+
assignmentSource: "manual" | "suggested" | "auto";
|
|
47
|
+
assignedAt: Date;
|
|
48
|
+
acceptedAt: Date | null;
|
|
49
|
+
} | undefined>;
|
|
50
|
+
export declare function updateDispatchAssignment(db: PostgresJsDatabase, id: string, data: UpdateGroundDispatchAssignmentInput): Promise<{
|
|
51
|
+
id: string;
|
|
52
|
+
dispatchId: string;
|
|
53
|
+
operatorId: string | null;
|
|
54
|
+
vehicleId: string | null;
|
|
55
|
+
driverId: string | null;
|
|
56
|
+
assignmentSource: "manual" | "suggested" | "auto";
|
|
57
|
+
assignedAt: Date;
|
|
58
|
+
acceptedAt: Date | null;
|
|
59
|
+
notes: string | null;
|
|
60
|
+
metadata: Record<string, unknown> | null;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
} | null>;
|
|
64
|
+
export declare function deleteDispatchAssignment(db: PostgresJsDatabase, id: string): Promise<{
|
|
65
|
+
id: string;
|
|
66
|
+
} | null>;
|
|
67
|
+
export declare function listDispatchLegs(db: PostgresJsDatabase, query: GroundDispatchLegListQuery): Promise<{
|
|
68
|
+
data: {
|
|
69
|
+
id: string;
|
|
70
|
+
dispatchId: string;
|
|
71
|
+
sequence: number;
|
|
72
|
+
legType: "pickup" | "stop" | "dropoff" | "deadhead";
|
|
73
|
+
facilityId: string | null;
|
|
74
|
+
addressId: string | null;
|
|
75
|
+
scheduledAt: Date | null;
|
|
76
|
+
actualAt: Date | null;
|
|
77
|
+
notes: string | null;
|
|
78
|
+
metadata: Record<string, unknown> | null;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
updatedAt: Date;
|
|
81
|
+
}[];
|
|
82
|
+
total: number;
|
|
83
|
+
limit: number;
|
|
84
|
+
offset: number;
|
|
85
|
+
}>;
|
|
86
|
+
export declare function getDispatchLegById(db: PostgresJsDatabase, id: string): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
dispatchId: string;
|
|
89
|
+
sequence: number;
|
|
90
|
+
legType: "pickup" | "stop" | "dropoff" | "deadhead";
|
|
91
|
+
facilityId: string | null;
|
|
92
|
+
addressId: string | null;
|
|
93
|
+
scheduledAt: Date | null;
|
|
94
|
+
actualAt: Date | null;
|
|
95
|
+
notes: string | null;
|
|
96
|
+
metadata: Record<string, unknown> | null;
|
|
97
|
+
createdAt: Date;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
} | null>;
|
|
100
|
+
export declare function createDispatchLeg(db: PostgresJsDatabase, data: CreateGroundDispatchLegInput): Promise<{
|
|
101
|
+
id: string;
|
|
102
|
+
notes: string | null;
|
|
103
|
+
metadata: Record<string, unknown> | null;
|
|
104
|
+
createdAt: Date;
|
|
105
|
+
updatedAt: Date;
|
|
106
|
+
facilityId: string | null;
|
|
107
|
+
dispatchId: string;
|
|
108
|
+
addressId: string | null;
|
|
109
|
+
sequence: number;
|
|
110
|
+
legType: "pickup" | "stop" | "dropoff" | "deadhead";
|
|
111
|
+
scheduledAt: Date | null;
|
|
112
|
+
actualAt: Date | null;
|
|
113
|
+
} | undefined>;
|
|
114
|
+
export declare function updateDispatchLeg(db: PostgresJsDatabase, id: string, data: UpdateGroundDispatchLegInput): Promise<{
|
|
115
|
+
id: string;
|
|
116
|
+
dispatchId: string;
|
|
117
|
+
sequence: number;
|
|
118
|
+
legType: "pickup" | "stop" | "dropoff" | "deadhead";
|
|
119
|
+
facilityId: string | null;
|
|
120
|
+
addressId: string | null;
|
|
121
|
+
scheduledAt: Date | null;
|
|
122
|
+
actualAt: Date | null;
|
|
123
|
+
notes: string | null;
|
|
124
|
+
metadata: Record<string, unknown> | null;
|
|
125
|
+
createdAt: Date;
|
|
126
|
+
updatedAt: Date;
|
|
127
|
+
} | null>;
|
|
128
|
+
export declare function deleteDispatchLeg(db: PostgresJsDatabase, id: string): Promise<{
|
|
129
|
+
id: string;
|
|
130
|
+
} | null>;
|
|
131
|
+
export declare function listDispatchPassengers(db: PostgresJsDatabase, query: GroundDispatchPassengerListQuery): Promise<{
|
|
132
|
+
data: {
|
|
133
|
+
id: string;
|
|
134
|
+
dispatchId: string;
|
|
135
|
+
participantId: string | null;
|
|
136
|
+
displayName: string | null;
|
|
137
|
+
seatLabel: string | null;
|
|
138
|
+
notes: string | null;
|
|
139
|
+
createdAt: Date;
|
|
140
|
+
updatedAt: Date;
|
|
141
|
+
}[];
|
|
142
|
+
total: number;
|
|
143
|
+
limit: number;
|
|
144
|
+
offset: number;
|
|
145
|
+
}>;
|
|
146
|
+
export declare function getDispatchPassengerById(db: PostgresJsDatabase, id: string): Promise<{
|
|
147
|
+
id: string;
|
|
148
|
+
dispatchId: string;
|
|
149
|
+
participantId: string | null;
|
|
150
|
+
displayName: string | null;
|
|
151
|
+
seatLabel: string | null;
|
|
152
|
+
notes: string | null;
|
|
153
|
+
createdAt: Date;
|
|
154
|
+
updatedAt: Date;
|
|
155
|
+
} | null>;
|
|
156
|
+
export declare function createDispatchPassenger(db: PostgresJsDatabase, data: CreateGroundDispatchPassengerInput): Promise<{
|
|
157
|
+
id: string;
|
|
158
|
+
notes: string | null;
|
|
159
|
+
createdAt: Date;
|
|
160
|
+
updatedAt: Date;
|
|
161
|
+
dispatchId: string;
|
|
162
|
+
participantId: string | null;
|
|
163
|
+
displayName: string | null;
|
|
164
|
+
seatLabel: string | null;
|
|
165
|
+
} | undefined>;
|
|
166
|
+
export declare function updateDispatchPassenger(db: PostgresJsDatabase, id: string, data: UpdateGroundDispatchPassengerInput): Promise<{
|
|
167
|
+
id: string;
|
|
168
|
+
dispatchId: string;
|
|
169
|
+
participantId: string | null;
|
|
170
|
+
displayName: string | null;
|
|
171
|
+
seatLabel: string | null;
|
|
172
|
+
notes: string | null;
|
|
173
|
+
createdAt: Date;
|
|
174
|
+
updatedAt: Date;
|
|
175
|
+
} | null>;
|
|
176
|
+
export declare function deleteDispatchPassenger(db: PostgresJsDatabase, id: string): Promise<{
|
|
177
|
+
id: string;
|
|
178
|
+
} | null>;
|
|
179
|
+
export declare function listServiceIncidents(db: PostgresJsDatabase, query: GroundServiceIncidentListQuery): Promise<{
|
|
180
|
+
data: {
|
|
181
|
+
id: string;
|
|
182
|
+
dispatchId: string;
|
|
183
|
+
severity: "info" | "warning" | "critical";
|
|
184
|
+
incidentType: string;
|
|
185
|
+
resolutionStatus: "cancelled" | "open" | "mitigated" | "resolved";
|
|
186
|
+
openedAt: Date;
|
|
187
|
+
resolvedAt: Date | null;
|
|
188
|
+
notes: string | null;
|
|
189
|
+
metadata: Record<string, unknown> | null;
|
|
190
|
+
createdAt: Date;
|
|
191
|
+
updatedAt: Date;
|
|
192
|
+
}[];
|
|
193
|
+
total: number;
|
|
194
|
+
limit: number;
|
|
195
|
+
offset: number;
|
|
196
|
+
}>;
|
|
197
|
+
export declare function getServiceIncidentById(db: PostgresJsDatabase, id: string): Promise<{
|
|
198
|
+
id: string;
|
|
199
|
+
dispatchId: string;
|
|
200
|
+
severity: "info" | "warning" | "critical";
|
|
201
|
+
incidentType: string;
|
|
202
|
+
resolutionStatus: "cancelled" | "open" | "mitigated" | "resolved";
|
|
203
|
+
openedAt: Date;
|
|
204
|
+
resolvedAt: Date | null;
|
|
205
|
+
notes: string | null;
|
|
206
|
+
metadata: Record<string, unknown> | null;
|
|
207
|
+
createdAt: Date;
|
|
208
|
+
updatedAt: Date;
|
|
209
|
+
} | null>;
|
|
210
|
+
export declare function createServiceIncident(db: PostgresJsDatabase, data: CreateGroundServiceIncidentInput): Promise<{
|
|
211
|
+
id: string;
|
|
212
|
+
notes: string | null;
|
|
213
|
+
metadata: Record<string, unknown> | null;
|
|
214
|
+
createdAt: Date;
|
|
215
|
+
updatedAt: Date;
|
|
216
|
+
dispatchId: string;
|
|
217
|
+
severity: "info" | "warning" | "critical";
|
|
218
|
+
incidentType: string;
|
|
219
|
+
resolutionStatus: "cancelled" | "open" | "mitigated" | "resolved";
|
|
220
|
+
openedAt: Date;
|
|
221
|
+
resolvedAt: Date | null;
|
|
222
|
+
} | undefined>;
|
|
223
|
+
export declare function updateServiceIncident(db: PostgresJsDatabase, id: string, data: UpdateGroundServiceIncidentInput): Promise<{
|
|
224
|
+
id: string;
|
|
225
|
+
dispatchId: string;
|
|
226
|
+
severity: "info" | "warning" | "critical";
|
|
227
|
+
incidentType: string;
|
|
228
|
+
resolutionStatus: "cancelled" | "open" | "mitigated" | "resolved";
|
|
229
|
+
openedAt: Date;
|
|
230
|
+
resolvedAt: Date | null;
|
|
231
|
+
notes: string | null;
|
|
232
|
+
metadata: Record<string, unknown> | null;
|
|
233
|
+
createdAt: Date;
|
|
234
|
+
updatedAt: Date;
|
|
235
|
+
} | null>;
|
|
236
|
+
export declare function deleteServiceIncident(db: PostgresJsDatabase, id: string): Promise<{
|
|
237
|
+
id: string;
|
|
238
|
+
} | null>;
|
|
239
|
+
export declare function listDispatchCheckpoints(db: PostgresJsDatabase, query: GroundDispatchCheckpointListQuery): Promise<{
|
|
240
|
+
data: {
|
|
241
|
+
id: string;
|
|
242
|
+
dispatchId: string;
|
|
243
|
+
sequence: number;
|
|
244
|
+
checkpointType: string;
|
|
245
|
+
status: "cancelled" | "pending" | "reached" | "missed";
|
|
246
|
+
plannedAt: Date | null;
|
|
247
|
+
actualAt: Date | null;
|
|
248
|
+
facilityId: string | null;
|
|
249
|
+
addressId: string | null;
|
|
250
|
+
notes: string | null;
|
|
251
|
+
metadata: Record<string, unknown> | null;
|
|
252
|
+
createdAt: Date;
|
|
253
|
+
updatedAt: Date;
|
|
254
|
+
}[];
|
|
255
|
+
total: number;
|
|
256
|
+
limit: number;
|
|
257
|
+
offset: number;
|
|
258
|
+
}>;
|
|
259
|
+
export declare function getDispatchCheckpointById(db: PostgresJsDatabase, id: string): Promise<{
|
|
260
|
+
id: string;
|
|
261
|
+
dispatchId: string;
|
|
262
|
+
sequence: number;
|
|
263
|
+
checkpointType: string;
|
|
264
|
+
status: "cancelled" | "pending" | "reached" | "missed";
|
|
265
|
+
plannedAt: Date | null;
|
|
266
|
+
actualAt: Date | null;
|
|
267
|
+
facilityId: string | null;
|
|
268
|
+
addressId: string | null;
|
|
269
|
+
notes: string | null;
|
|
270
|
+
metadata: Record<string, unknown> | null;
|
|
271
|
+
createdAt: Date;
|
|
272
|
+
updatedAt: Date;
|
|
273
|
+
} | null>;
|
|
274
|
+
export declare function createDispatchCheckpoint(db: PostgresJsDatabase, data: CreateGroundDispatchCheckpointInput): Promise<{
|
|
275
|
+
id: string;
|
|
276
|
+
notes: string | null;
|
|
277
|
+
metadata: Record<string, unknown> | null;
|
|
278
|
+
createdAt: Date;
|
|
279
|
+
updatedAt: Date;
|
|
280
|
+
status: "cancelled" | "pending" | "reached" | "missed";
|
|
281
|
+
facilityId: string | null;
|
|
282
|
+
dispatchId: string;
|
|
283
|
+
addressId: string | null;
|
|
284
|
+
sequence: number;
|
|
285
|
+
actualAt: Date | null;
|
|
286
|
+
checkpointType: string;
|
|
287
|
+
plannedAt: Date | null;
|
|
288
|
+
} | undefined>;
|
|
289
|
+
export declare function updateDispatchCheckpoint(db: PostgresJsDatabase, id: string, data: UpdateGroundDispatchCheckpointInput): Promise<{
|
|
290
|
+
id: string;
|
|
291
|
+
dispatchId: string;
|
|
292
|
+
sequence: number;
|
|
293
|
+
checkpointType: string;
|
|
294
|
+
status: "cancelled" | "pending" | "reached" | "missed";
|
|
295
|
+
plannedAt: Date | null;
|
|
296
|
+
actualAt: Date | null;
|
|
297
|
+
facilityId: string | null;
|
|
298
|
+
addressId: string | null;
|
|
299
|
+
notes: string | null;
|
|
300
|
+
metadata: Record<string, unknown> | null;
|
|
301
|
+
createdAt: Date;
|
|
302
|
+
updatedAt: Date;
|
|
303
|
+
} | null>;
|
|
304
|
+
export declare function deleteDispatchCheckpoint(db: PostgresJsDatabase, id: string): Promise<{
|
|
305
|
+
id: string;
|
|
306
|
+
} | null>;
|
|
307
|
+
//# sourceMappingURL=service-dispatch-ops.d.ts.map
|
|
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;;;;;;;;;;;;;;;;;;;GAmBzC;AAED,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;UAOjF;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,mCAAmC;;;;;;;;;;;;;;eAW1C;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,mCAAmC;;;;;;;;;;;;;;UAa1C;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMhF"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { and, asc, desc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { groundDispatchAssignments, groundDispatchCheckpoints, groundDispatchLegs, groundDispatchPassengers, groundServiceIncidents, } from "./schema.js";
|
|
3
|
+
import { paginate, toDateOrNull } from "./service-shared.js";
|
|
4
|
+
export async function listDispatchAssignments(db, query) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (query.dispatchId)
|
|
7
|
+
conditions.push(eq(groundDispatchAssignments.dispatchId, query.dispatchId));
|
|
8
|
+
if (query.operatorId)
|
|
9
|
+
conditions.push(eq(groundDispatchAssignments.operatorId, query.operatorId));
|
|
10
|
+
if (query.vehicleId)
|
|
11
|
+
conditions.push(eq(groundDispatchAssignments.vehicleId, query.vehicleId));
|
|
12
|
+
if (query.driverId)
|
|
13
|
+
conditions.push(eq(groundDispatchAssignments.driverId, query.driverId));
|
|
14
|
+
if (query.assignmentSource) {
|
|
15
|
+
conditions.push(eq(groundDispatchAssignments.assignmentSource, query.assignmentSource));
|
|
16
|
+
}
|
|
17
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
18
|
+
return paginate(db
|
|
19
|
+
.select()
|
|
20
|
+
.from(groundDispatchAssignments)
|
|
21
|
+
.where(where)
|
|
22
|
+
.limit(query.limit)
|
|
23
|
+
.offset(query.offset)
|
|
24
|
+
.orderBy(asc(groundDispatchAssignments.assignedAt)), db.select({ count: sql `count(*)::int` }).from(groundDispatchAssignments).where(where), query.limit, query.offset);
|
|
25
|
+
}
|
|
26
|
+
export async function getDispatchAssignmentById(db, id) {
|
|
27
|
+
const [row] = await db
|
|
28
|
+
.select()
|
|
29
|
+
.from(groundDispatchAssignments)
|
|
30
|
+
.where(eq(groundDispatchAssignments.id, id))
|
|
31
|
+
.limit(1);
|
|
32
|
+
return row ?? null;
|
|
33
|
+
}
|
|
34
|
+
export async function createDispatchAssignment(db, data) {
|
|
35
|
+
const [row] = await db
|
|
36
|
+
.insert(groundDispatchAssignments)
|
|
37
|
+
.values({
|
|
38
|
+
...data,
|
|
39
|
+
assignedAt: toDateOrNull(data.assignedAt) ?? new Date(),
|
|
40
|
+
acceptedAt: toDateOrNull(data.acceptedAt),
|
|
41
|
+
})
|
|
42
|
+
.returning();
|
|
43
|
+
return row;
|
|
44
|
+
}
|
|
45
|
+
export async function updateDispatchAssignment(db, id, data) {
|
|
46
|
+
const [row] = await db
|
|
47
|
+
.update(groundDispatchAssignments)
|
|
48
|
+
.set({
|
|
49
|
+
...data,
|
|
50
|
+
assignedAt: data.assignedAt ? new Date(data.assignedAt) : undefined,
|
|
51
|
+
acceptedAt: data.acceptedAt ? new Date(data.acceptedAt) : undefined,
|
|
52
|
+
updatedAt: new Date(),
|
|
53
|
+
})
|
|
54
|
+
.where(eq(groundDispatchAssignments.id, id))
|
|
55
|
+
.returning();
|
|
56
|
+
return row ?? null;
|
|
57
|
+
}
|
|
58
|
+
export async function deleteDispatchAssignment(db, id) {
|
|
59
|
+
const [row] = await db
|
|
60
|
+
.delete(groundDispatchAssignments)
|
|
61
|
+
.where(eq(groundDispatchAssignments.id, id))
|
|
62
|
+
.returning({ id: groundDispatchAssignments.id });
|
|
63
|
+
return row ?? null;
|
|
64
|
+
}
|
|
65
|
+
export async function listDispatchLegs(db, query) {
|
|
66
|
+
const conditions = [];
|
|
67
|
+
if (query.dispatchId)
|
|
68
|
+
conditions.push(eq(groundDispatchLegs.dispatchId, query.dispatchId));
|
|
69
|
+
if (query.legType)
|
|
70
|
+
conditions.push(eq(groundDispatchLegs.legType, query.legType));
|
|
71
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
72
|
+
return paginate(db
|
|
73
|
+
.select()
|
|
74
|
+
.from(groundDispatchLegs)
|
|
75
|
+
.where(where)
|
|
76
|
+
.limit(query.limit)
|
|
77
|
+
.offset(query.offset)
|
|
78
|
+
.orderBy(asc(groundDispatchLegs.sequence)), db.select({ count: sql `count(*)::int` }).from(groundDispatchLegs).where(where), query.limit, query.offset);
|
|
79
|
+
}
|
|
80
|
+
export async function getDispatchLegById(db, id) {
|
|
81
|
+
const [row] = await db
|
|
82
|
+
.select()
|
|
83
|
+
.from(groundDispatchLegs)
|
|
84
|
+
.where(eq(groundDispatchLegs.id, id))
|
|
85
|
+
.limit(1);
|
|
86
|
+
return row ?? null;
|
|
87
|
+
}
|
|
88
|
+
export async function createDispatchLeg(db, data) {
|
|
89
|
+
const [row] = await db
|
|
90
|
+
.insert(groundDispatchLegs)
|
|
91
|
+
.values({
|
|
92
|
+
...data,
|
|
93
|
+
scheduledAt: toDateOrNull(data.scheduledAt),
|
|
94
|
+
actualAt: toDateOrNull(data.actualAt),
|
|
95
|
+
})
|
|
96
|
+
.returning();
|
|
97
|
+
return row;
|
|
98
|
+
}
|
|
99
|
+
export async function updateDispatchLeg(db, id, data) {
|
|
100
|
+
const [row] = await db
|
|
101
|
+
.update(groundDispatchLegs)
|
|
102
|
+
.set({
|
|
103
|
+
...data,
|
|
104
|
+
scheduledAt: toDateOrNull(data.scheduledAt),
|
|
105
|
+
actualAt: toDateOrNull(data.actualAt),
|
|
106
|
+
updatedAt: new Date(),
|
|
107
|
+
})
|
|
108
|
+
.where(eq(groundDispatchLegs.id, id))
|
|
109
|
+
.returning();
|
|
110
|
+
return row ?? null;
|
|
111
|
+
}
|
|
112
|
+
export async function deleteDispatchLeg(db, id) {
|
|
113
|
+
const [row] = await db
|
|
114
|
+
.delete(groundDispatchLegs)
|
|
115
|
+
.where(eq(groundDispatchLegs.id, id))
|
|
116
|
+
.returning({ id: groundDispatchLegs.id });
|
|
117
|
+
return row ?? null;
|
|
118
|
+
}
|
|
119
|
+
export async function listDispatchPassengers(db, query) {
|
|
120
|
+
const conditions = [];
|
|
121
|
+
if (query.dispatchId)
|
|
122
|
+
conditions.push(eq(groundDispatchPassengers.dispatchId, query.dispatchId));
|
|
123
|
+
if (query.participantId) {
|
|
124
|
+
conditions.push(eq(groundDispatchPassengers.participantId, query.participantId));
|
|
125
|
+
}
|
|
126
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
127
|
+
return paginate(db
|
|
128
|
+
.select()
|
|
129
|
+
.from(groundDispatchPassengers)
|
|
130
|
+
.where(where)
|
|
131
|
+
.limit(query.limit)
|
|
132
|
+
.offset(query.offset)
|
|
133
|
+
.orderBy(asc(groundDispatchPassengers.createdAt)), db.select({ count: sql `count(*)::int` }).from(groundDispatchPassengers).where(where), query.limit, query.offset);
|
|
134
|
+
}
|
|
135
|
+
export async function getDispatchPassengerById(db, id) {
|
|
136
|
+
const [row] = await db
|
|
137
|
+
.select()
|
|
138
|
+
.from(groundDispatchPassengers)
|
|
139
|
+
.where(eq(groundDispatchPassengers.id, id))
|
|
140
|
+
.limit(1);
|
|
141
|
+
return row ?? null;
|
|
142
|
+
}
|
|
143
|
+
export async function createDispatchPassenger(db, data) {
|
|
144
|
+
const [row] = await db.insert(groundDispatchPassengers).values(data).returning();
|
|
145
|
+
return row;
|
|
146
|
+
}
|
|
147
|
+
export async function updateDispatchPassenger(db, id, data) {
|
|
148
|
+
const [row] = await db
|
|
149
|
+
.update(groundDispatchPassengers)
|
|
150
|
+
.set({ ...data, updatedAt: new Date() })
|
|
151
|
+
.where(eq(groundDispatchPassengers.id, id))
|
|
152
|
+
.returning();
|
|
153
|
+
return row ?? null;
|
|
154
|
+
}
|
|
155
|
+
export async function deleteDispatchPassenger(db, id) {
|
|
156
|
+
const [row] = await db
|
|
157
|
+
.delete(groundDispatchPassengers)
|
|
158
|
+
.where(eq(groundDispatchPassengers.id, id))
|
|
159
|
+
.returning({ id: groundDispatchPassengers.id });
|
|
160
|
+
return row ?? null;
|
|
161
|
+
}
|
|
162
|
+
export async function listServiceIncidents(db, query) {
|
|
163
|
+
const conditions = [];
|
|
164
|
+
if (query.dispatchId)
|
|
165
|
+
conditions.push(eq(groundServiceIncidents.dispatchId, query.dispatchId));
|
|
166
|
+
if (query.severity)
|
|
167
|
+
conditions.push(eq(groundServiceIncidents.severity, query.severity));
|
|
168
|
+
if (query.resolutionStatus) {
|
|
169
|
+
conditions.push(eq(groundServiceIncidents.resolutionStatus, query.resolutionStatus));
|
|
170
|
+
}
|
|
171
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
172
|
+
return paginate(db
|
|
173
|
+
.select()
|
|
174
|
+
.from(groundServiceIncidents)
|
|
175
|
+
.where(where)
|
|
176
|
+
.limit(query.limit)
|
|
177
|
+
.offset(query.offset)
|
|
178
|
+
.orderBy(desc(groundServiceIncidents.openedAt)), db.select({ count: sql `count(*)::int` }).from(groundServiceIncidents).where(where), query.limit, query.offset);
|
|
179
|
+
}
|
|
180
|
+
export async function getServiceIncidentById(db, id) {
|
|
181
|
+
const [row] = await db
|
|
182
|
+
.select()
|
|
183
|
+
.from(groundServiceIncidents)
|
|
184
|
+
.where(eq(groundServiceIncidents.id, id))
|
|
185
|
+
.limit(1);
|
|
186
|
+
return row ?? null;
|
|
187
|
+
}
|
|
188
|
+
export async function createServiceIncident(db, data) {
|
|
189
|
+
const [row] = await db
|
|
190
|
+
.insert(groundServiceIncidents)
|
|
191
|
+
.values({
|
|
192
|
+
...data,
|
|
193
|
+
openedAt: toDateOrNull(data.openedAt) ?? new Date(),
|
|
194
|
+
resolvedAt: toDateOrNull(data.resolvedAt),
|
|
195
|
+
})
|
|
196
|
+
.returning();
|
|
197
|
+
return row;
|
|
198
|
+
}
|
|
199
|
+
export async function updateServiceIncident(db, id, data) {
|
|
200
|
+
const [row] = await db
|
|
201
|
+
.update(groundServiceIncidents)
|
|
202
|
+
.set({
|
|
203
|
+
...data,
|
|
204
|
+
openedAt: data.openedAt ? new Date(data.openedAt) : undefined,
|
|
205
|
+
resolvedAt: data.resolvedAt ? new Date(data.resolvedAt) : undefined,
|
|
206
|
+
updatedAt: new Date(),
|
|
207
|
+
})
|
|
208
|
+
.where(eq(groundServiceIncidents.id, id))
|
|
209
|
+
.returning();
|
|
210
|
+
return row ?? null;
|
|
211
|
+
}
|
|
212
|
+
export async function deleteServiceIncident(db, id) {
|
|
213
|
+
const [row] = await db
|
|
214
|
+
.delete(groundServiceIncidents)
|
|
215
|
+
.where(eq(groundServiceIncidents.id, id))
|
|
216
|
+
.returning({ id: groundServiceIncidents.id });
|
|
217
|
+
return row ?? null;
|
|
218
|
+
}
|
|
219
|
+
export async function listDispatchCheckpoints(db, query) {
|
|
220
|
+
const conditions = [];
|
|
221
|
+
if (query.dispatchId)
|
|
222
|
+
conditions.push(eq(groundDispatchCheckpoints.dispatchId, query.dispatchId));
|
|
223
|
+
if (query.status)
|
|
224
|
+
conditions.push(eq(groundDispatchCheckpoints.status, query.status));
|
|
225
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
226
|
+
return paginate(db
|
|
227
|
+
.select()
|
|
228
|
+
.from(groundDispatchCheckpoints)
|
|
229
|
+
.where(where)
|
|
230
|
+
.limit(query.limit)
|
|
231
|
+
.offset(query.offset)
|
|
232
|
+
.orderBy(asc(groundDispatchCheckpoints.sequence)), db.select({ count: sql `count(*)::int` }).from(groundDispatchCheckpoints).where(where), query.limit, query.offset);
|
|
233
|
+
}
|
|
234
|
+
export async function getDispatchCheckpointById(db, id) {
|
|
235
|
+
const [row] = await db
|
|
236
|
+
.select()
|
|
237
|
+
.from(groundDispatchCheckpoints)
|
|
238
|
+
.where(eq(groundDispatchCheckpoints.id, id))
|
|
239
|
+
.limit(1);
|
|
240
|
+
return row ?? null;
|
|
241
|
+
}
|
|
242
|
+
export async function createDispatchCheckpoint(db, data) {
|
|
243
|
+
const [row] = await db
|
|
244
|
+
.insert(groundDispatchCheckpoints)
|
|
245
|
+
.values({
|
|
246
|
+
...data,
|
|
247
|
+
plannedAt: toDateOrNull(data.plannedAt),
|
|
248
|
+
actualAt: toDateOrNull(data.actualAt),
|
|
249
|
+
})
|
|
250
|
+
.returning();
|
|
251
|
+
return row;
|
|
252
|
+
}
|
|
253
|
+
export async function updateDispatchCheckpoint(db, id, data) {
|
|
254
|
+
const [row] = await db
|
|
255
|
+
.update(groundDispatchCheckpoints)
|
|
256
|
+
.set({
|
|
257
|
+
...data,
|
|
258
|
+
plannedAt: toDateOrNull(data.plannedAt),
|
|
259
|
+
actualAt: toDateOrNull(data.actualAt),
|
|
260
|
+
updatedAt: new Date(),
|
|
261
|
+
})
|
|
262
|
+
.where(eq(groundDispatchCheckpoints.id, id))
|
|
263
|
+
.returning();
|
|
264
|
+
return row ?? null;
|
|
265
|
+
}
|
|
266
|
+
export async function deleteDispatchCheckpoint(db, id) {
|
|
267
|
+
const [row] = await db
|
|
268
|
+
.delete(groundDispatchCheckpoints)
|
|
269
|
+
.where(eq(groundDispatchCheckpoints.id, id))
|
|
270
|
+
.returning({ id: groundDispatchCheckpoints.id });
|
|
271
|
+
return row ?? null;
|
|
272
|
+
}
|