autosync_backend2 1.2.18 → 1.2.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/dist/index.d.ts +235 -0
- package/dist/index.js +151 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6411,6 +6411,70 @@ export declare const app: Elysia<"", {
|
|
|
6411
6411
|
};
|
|
6412
6412
|
};
|
|
6413
6413
|
};
|
|
6414
|
+
} & {
|
|
6415
|
+
inspection: {
|
|
6416
|
+
admin: {
|
|
6417
|
+
get: {
|
|
6418
|
+
body: {};
|
|
6419
|
+
params: {};
|
|
6420
|
+
query: {
|
|
6421
|
+
companyId?: string | undefined;
|
|
6422
|
+
pagination: {
|
|
6423
|
+
size: number;
|
|
6424
|
+
page: number;
|
|
6425
|
+
};
|
|
6426
|
+
};
|
|
6427
|
+
headers: {};
|
|
6428
|
+
response: {
|
|
6429
|
+
200: {
|
|
6430
|
+
totalCount: number;
|
|
6431
|
+
totalPage: number;
|
|
6432
|
+
result: {
|
|
6433
|
+
company: {
|
|
6434
|
+
id: string;
|
|
6435
|
+
name: string;
|
|
6436
|
+
serviceName: string;
|
|
6437
|
+
logoUrl: string;
|
|
6438
|
+
} | null;
|
|
6439
|
+
vehicle: {
|
|
6440
|
+
licensePlate: string | null;
|
|
6441
|
+
vin: string | null;
|
|
6442
|
+
model: string | null;
|
|
6443
|
+
};
|
|
6444
|
+
employee: {
|
|
6445
|
+
firstname: string;
|
|
6446
|
+
lastname: string;
|
|
6447
|
+
} | null;
|
|
6448
|
+
inspection: {
|
|
6449
|
+
inspection: {
|
|
6450
|
+
type: string;
|
|
6451
|
+
values: {
|
|
6452
|
+
description: string;
|
|
6453
|
+
question: string;
|
|
6454
|
+
answer: string;
|
|
6455
|
+
}[];
|
|
6456
|
+
}[] | null;
|
|
6457
|
+
createdAt: string;
|
|
6458
|
+
expireAt: Date;
|
|
6459
|
+
status: "CREATED" | "APPROVED" | "CANCELLED";
|
|
6460
|
+
};
|
|
6461
|
+
totalCount: number;
|
|
6462
|
+
}[];
|
|
6463
|
+
};
|
|
6464
|
+
401: "Session not found";
|
|
6465
|
+
422: {
|
|
6466
|
+
type: "validation";
|
|
6467
|
+
on: string;
|
|
6468
|
+
summary?: string;
|
|
6469
|
+
message?: string;
|
|
6470
|
+
found?: unknown;
|
|
6471
|
+
property?: string;
|
|
6472
|
+
expected?: string;
|
|
6473
|
+
};
|
|
6474
|
+
};
|
|
6475
|
+
};
|
|
6476
|
+
};
|
|
6477
|
+
};
|
|
6414
6478
|
} & {
|
|
6415
6479
|
inspection: {
|
|
6416
6480
|
":id": {
|
|
@@ -7369,6 +7433,177 @@ export declare const app: Elysia<"", {
|
|
|
7369
7433
|
product: {};
|
|
7370
7434
|
};
|
|
7371
7435
|
};
|
|
7436
|
+
} & {
|
|
7437
|
+
api: {
|
|
7438
|
+
fleet: {
|
|
7439
|
+
inspection: {
|
|
7440
|
+
"field-group": {};
|
|
7441
|
+
} & {
|
|
7442
|
+
"field-group": {
|
|
7443
|
+
get: {
|
|
7444
|
+
body: {};
|
|
7445
|
+
params: {};
|
|
7446
|
+
query: {
|
|
7447
|
+
name?: string | undefined;
|
|
7448
|
+
code?: string | undefined;
|
|
7449
|
+
pagination: {
|
|
7450
|
+
size: number;
|
|
7451
|
+
page: number;
|
|
7452
|
+
};
|
|
7453
|
+
};
|
|
7454
|
+
headers: {};
|
|
7455
|
+
response: {
|
|
7456
|
+
200: {
|
|
7457
|
+
totalCount: number;
|
|
7458
|
+
totalPage: number;
|
|
7459
|
+
result: {
|
|
7460
|
+
totalCount: number;
|
|
7461
|
+
code: string | null;
|
|
7462
|
+
name: string;
|
|
7463
|
+
description: string | null;
|
|
7464
|
+
id: string;
|
|
7465
|
+
createdAt: string;
|
|
7466
|
+
updatedAt: string;
|
|
7467
|
+
deletedAt: string | null;
|
|
7468
|
+
oldId: number | null;
|
|
7469
|
+
}[];
|
|
7470
|
+
};
|
|
7471
|
+
401: "Session not found";
|
|
7472
|
+
422: {
|
|
7473
|
+
type: "validation";
|
|
7474
|
+
on: string;
|
|
7475
|
+
summary?: string;
|
|
7476
|
+
message?: string;
|
|
7477
|
+
found?: unknown;
|
|
7478
|
+
property?: string;
|
|
7479
|
+
expected?: string;
|
|
7480
|
+
};
|
|
7481
|
+
};
|
|
7482
|
+
};
|
|
7483
|
+
};
|
|
7484
|
+
} & {
|
|
7485
|
+
"field-group": {
|
|
7486
|
+
post: {
|
|
7487
|
+
body: {
|
|
7488
|
+
code?: string | null | undefined;
|
|
7489
|
+
oldId?: number | null | undefined;
|
|
7490
|
+
description?: string | null | undefined;
|
|
7491
|
+
name: string;
|
|
7492
|
+
};
|
|
7493
|
+
params: {};
|
|
7494
|
+
query: unknown;
|
|
7495
|
+
headers: unknown;
|
|
7496
|
+
response: {
|
|
7497
|
+
422: {
|
|
7498
|
+
type: "validation";
|
|
7499
|
+
on: string;
|
|
7500
|
+
summary?: string;
|
|
7501
|
+
message?: string;
|
|
7502
|
+
found?: unknown;
|
|
7503
|
+
property?: string;
|
|
7504
|
+
expected?: string;
|
|
7505
|
+
};
|
|
7506
|
+
};
|
|
7507
|
+
};
|
|
7508
|
+
};
|
|
7509
|
+
} & {
|
|
7510
|
+
"field-group": {
|
|
7511
|
+
":id": {
|
|
7512
|
+
put: {
|
|
7513
|
+
body: {
|
|
7514
|
+
name?: string | undefined;
|
|
7515
|
+
code?: string | null | undefined;
|
|
7516
|
+
oldId?: number | null | undefined;
|
|
7517
|
+
description?: string | null | undefined;
|
|
7518
|
+
};
|
|
7519
|
+
params: {
|
|
7520
|
+
id: string;
|
|
7521
|
+
};
|
|
7522
|
+
query: unknown;
|
|
7523
|
+
headers: unknown;
|
|
7524
|
+
response: {
|
|
7525
|
+
422: {
|
|
7526
|
+
type: "validation";
|
|
7527
|
+
on: string;
|
|
7528
|
+
summary?: string;
|
|
7529
|
+
message?: string;
|
|
7530
|
+
found?: unknown;
|
|
7531
|
+
property?: string;
|
|
7532
|
+
expected?: string;
|
|
7533
|
+
};
|
|
7534
|
+
};
|
|
7535
|
+
};
|
|
7536
|
+
};
|
|
7537
|
+
};
|
|
7538
|
+
} & {
|
|
7539
|
+
"field-group": {
|
|
7540
|
+
":id": {
|
|
7541
|
+
delete: {
|
|
7542
|
+
body: unknown;
|
|
7543
|
+
params: {
|
|
7544
|
+
id: string;
|
|
7545
|
+
};
|
|
7546
|
+
query: unknown;
|
|
7547
|
+
headers: unknown;
|
|
7548
|
+
response: {
|
|
7549
|
+
422: {
|
|
7550
|
+
type: "validation";
|
|
7551
|
+
on: string;
|
|
7552
|
+
summary?: string;
|
|
7553
|
+
message?: string;
|
|
7554
|
+
found?: unknown;
|
|
7555
|
+
property?: string;
|
|
7556
|
+
expected?: string;
|
|
7557
|
+
};
|
|
7558
|
+
};
|
|
7559
|
+
};
|
|
7560
|
+
};
|
|
7561
|
+
};
|
|
7562
|
+
} & {
|
|
7563
|
+
"field-group": {
|
|
7564
|
+
":id": {
|
|
7565
|
+
field: {
|
|
7566
|
+
get: {
|
|
7567
|
+
body: unknown;
|
|
7568
|
+
params: {
|
|
7569
|
+
id: string;
|
|
7570
|
+
};
|
|
7571
|
+
query: unknown;
|
|
7572
|
+
headers: unknown;
|
|
7573
|
+
response: {
|
|
7574
|
+
200: {
|
|
7575
|
+
groupId: string;
|
|
7576
|
+
code: string | null;
|
|
7577
|
+
description: string | null;
|
|
7578
|
+
version: string | null;
|
|
7579
|
+
isActive: boolean;
|
|
7580
|
+
metadata: unknown;
|
|
7581
|
+
required: boolean;
|
|
7582
|
+
fieldGroup: string | null;
|
|
7583
|
+
sortIndex: number | null;
|
|
7584
|
+
id: string;
|
|
7585
|
+
createdAt: string;
|
|
7586
|
+
updatedAt: string;
|
|
7587
|
+
deletedAt: string | null;
|
|
7588
|
+
oldId: number | null;
|
|
7589
|
+
}[];
|
|
7590
|
+
422: {
|
|
7591
|
+
type: "validation";
|
|
7592
|
+
on: string;
|
|
7593
|
+
summary?: string;
|
|
7594
|
+
message?: string;
|
|
7595
|
+
found?: unknown;
|
|
7596
|
+
property?: string;
|
|
7597
|
+
expected?: string;
|
|
7598
|
+
};
|
|
7599
|
+
};
|
|
7600
|
+
};
|
|
7601
|
+
};
|
|
7602
|
+
};
|
|
7603
|
+
};
|
|
7604
|
+
};
|
|
7605
|
+
};
|
|
7606
|
+
};
|
|
7372
7607
|
}, {
|
|
7373
7608
|
derive: {};
|
|
7374
7609
|
resolve: {};
|
package/dist/index.js
CHANGED
|
@@ -150110,7 +150110,12 @@ var CrmVehicleLogic;
|
|
|
150110
150110
|
yearImport: new Date(atutData.imported_date).getFullYear(),
|
|
150111
150111
|
engineCode: atutData.engine_model_name
|
|
150112
150112
|
};
|
|
150113
|
-
const [result] = await tdb.insert(crmVehicleTable).values(insertData).
|
|
150113
|
+
const [result] = await tdb.insert(crmVehicleTable).values(insertData).onConflictDoUpdate({
|
|
150114
|
+
target: crmVehicleTable.vin,
|
|
150115
|
+
set: {
|
|
150116
|
+
licensePlate: insertData.licensePlate
|
|
150117
|
+
}
|
|
150118
|
+
}).returning();
|
|
150114
150119
|
return result;
|
|
150115
150120
|
};
|
|
150116
150121
|
CrmVehicleLogic.select = async (query, user2) => {
|
|
@@ -152138,6 +152143,41 @@ var CrmInspectionLogic;
|
|
|
152138
152143
|
}).from(crmInspectionTable).where(eq(crmInspectionTable.licensePlate, licensePlate)).leftJoin(companyCompanyTable, eq(companyCompanyTable.id, crmInspectionTable.companyId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmInspectionTable.vehicleId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmInspectionTable.employeeId)).orderBy(desc(crmInspectionTable.createdAt));
|
|
152139
152144
|
return inspections;
|
|
152140
152145
|
};
|
|
152146
|
+
CrmInspectionLogic.selectAdmin = async (query) => {
|
|
152147
|
+
const baseQuery = db_default.select({
|
|
152148
|
+
company: {
|
|
152149
|
+
id: companyCompanyTable.id,
|
|
152150
|
+
name: companyCompanyTable.name,
|
|
152151
|
+
serviceName: companyCompanyTable.serviceName,
|
|
152152
|
+
logoUrl: companyCompanyTable.logoUrl
|
|
152153
|
+
},
|
|
152154
|
+
vehicle: {
|
|
152155
|
+
licensePlate: crmVehicleTable.licensePlate,
|
|
152156
|
+
vin: crmVehicleTable.vin,
|
|
152157
|
+
model: techdocVehicleKindTable.name
|
|
152158
|
+
},
|
|
152159
|
+
employee: {
|
|
152160
|
+
firstname: companyEmployeeTable.firstname,
|
|
152161
|
+
lastname: companyEmployeeTable.lastname
|
|
152162
|
+
},
|
|
152163
|
+
inspection: {
|
|
152164
|
+
inspection: crmInspectionTable.inspection,
|
|
152165
|
+
createdAt: crmInspectionTable.createdAt,
|
|
152166
|
+
expireAt: crmInspectionTable.expireAt,
|
|
152167
|
+
status: crmInspectionTable.status
|
|
152168
|
+
},
|
|
152169
|
+
totalCount: totalCountSql
|
|
152170
|
+
}).from(crmInspectionTable).where(eq(crmInspectionTable.companyId, query.companyId).if(query.companyId)).leftJoin(companyCompanyTable, eq(companyCompanyTable.id, crmInspectionTable.companyId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmInspectionTable.vehicleId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmInspectionTable.employeeId)).orderBy(desc(crmInspectionTable.createdAt)).$dynamic();
|
|
152171
|
+
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
152172
|
+
const content = {
|
|
152173
|
+
totalCount: result[0]?.totalCount ?? 0,
|
|
152174
|
+
totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
|
|
152175
|
+
};
|
|
152176
|
+
return {
|
|
152177
|
+
result,
|
|
152178
|
+
...content
|
|
152179
|
+
};
|
|
152180
|
+
};
|
|
152141
152181
|
})(CrmInspectionLogic ||= {});
|
|
152142
152182
|
var logic_default17 = CrmInspectionLogic;
|
|
152143
152183
|
|
|
@@ -152170,6 +152210,12 @@ var CrmInspectionModel;
|
|
|
152170
152210
|
CrmInspectionModel.selectUbCab = t.Object({
|
|
152171
152211
|
licensePlate: t.String()
|
|
152172
152212
|
});
|
|
152213
|
+
CrmInspectionModel.selectAdmin = t.Composite([
|
|
152214
|
+
t.Partial(t.Object({
|
|
152215
|
+
companyId: t.String({ format: "uuid" })
|
|
152216
|
+
})),
|
|
152217
|
+
PaginationSchema
|
|
152218
|
+
]);
|
|
152173
152219
|
})(CrmInspectionModel ||= {});
|
|
152174
152220
|
var model_default13 = CrmInspectionModel;
|
|
152175
152221
|
|
|
@@ -152184,6 +152230,9 @@ var inspectionRoutes = new Elysia({
|
|
|
152184
152230
|
query: model_default13.select
|
|
152185
152231
|
}).post("/", async ({ body, user: user2 }) => logic_default17.create(body, user2), {
|
|
152186
152232
|
body: model_default13.create
|
|
152233
|
+
}).get("/admin", async ({ query }) => logic_default17.selectAdmin(query), {
|
|
152234
|
+
query: model_default13.selectAdmin,
|
|
152235
|
+
userKind: "ADMIN"
|
|
152187
152236
|
}).guard({
|
|
152188
152237
|
params: IdSchema
|
|
152189
152238
|
}).get("/:id", async ({ params: { id }, user: user2 }) => logic_default17.getById(id, user2)).post("/:id", async ({ params: { id }, user: user2 }) => logic_default17.approve(id, user2)).put("/:id", async ({ params: { id }, user: user2 }) => logic_default17.cancel(id, user2)).post("/:id/service-order", async ({ params: { id }, user: user2 }) => logic_default17.createCpOrder(id, user2));
|
|
@@ -153832,10 +153881,110 @@ var warehouseSchemaRoutes = new Elysia({
|
|
|
153832
153881
|
}).use(product_default3).use(warehouse_default).use(item_default3);
|
|
153833
153882
|
var warehouse_default2 = warehouseSchemaRoutes;
|
|
153834
153883
|
|
|
153884
|
+
// src/routes/fleet/inspection/field/logic.ts
|
|
153885
|
+
var InspectionFieldLogic;
|
|
153886
|
+
((InspectionFieldLogic) => {
|
|
153887
|
+
InspectionFieldLogic.select = async (groupId) => {
|
|
153888
|
+
const result = await db_default.select().from(inspectionFieldTable).where(eq(inspectionFieldTable.groupId, groupId));
|
|
153889
|
+
return result;
|
|
153890
|
+
};
|
|
153891
|
+
InspectionFieldLogic.create = async (body) => {
|
|
153892
|
+
await db_default.insert(inspectionFieldTable).values(body);
|
|
153893
|
+
};
|
|
153894
|
+
InspectionFieldLogic.update = async (id, body) => {
|
|
153895
|
+
await db_default.update(inspectionFieldTable).set(body).where(eq(inspectionFieldTable.id, id));
|
|
153896
|
+
};
|
|
153897
|
+
InspectionFieldLogic.remove = async (id) => {
|
|
153898
|
+
await db_default.update(inspectionFieldTable).set({
|
|
153899
|
+
deletedAt: sql3`now()`
|
|
153900
|
+
}).where(eq(inspectionFieldTable.id, id));
|
|
153901
|
+
};
|
|
153902
|
+
})(InspectionFieldLogic ||= {});
|
|
153903
|
+
var logic_default25 = InspectionFieldLogic;
|
|
153904
|
+
|
|
153905
|
+
// src/routes/fleet/inspection/fieldGroup/logic.ts
|
|
153906
|
+
var InspectionFieldGroupLogic;
|
|
153907
|
+
((InspectionFieldGroupLogic) => {
|
|
153908
|
+
InspectionFieldGroupLogic.select = async (query) => {
|
|
153909
|
+
const filter = and(softDeletedFilter(inspectionFieldGroupTable), ilike(inspectionFieldGroupTable.name, `%${query.name}%`).if(query.name), ilike(inspectionFieldGroupTable.code, `%${query.code}%`).if(query.code));
|
|
153910
|
+
const columns = getTableColumns(inspectionFieldGroupTable);
|
|
153911
|
+
const baseQuery = db_default.select({
|
|
153912
|
+
...columns,
|
|
153913
|
+
totalCount: totalCountSql
|
|
153914
|
+
}).from(inspectionFieldGroupTable).where(filter).$dynamic();
|
|
153915
|
+
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
153916
|
+
const content = {
|
|
153917
|
+
totalCount: result[0]?.totalCount ?? 0,
|
|
153918
|
+
totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
|
|
153919
|
+
};
|
|
153920
|
+
return {
|
|
153921
|
+
result,
|
|
153922
|
+
...content
|
|
153923
|
+
};
|
|
153924
|
+
};
|
|
153925
|
+
InspectionFieldGroupLogic.create = async (body) => {
|
|
153926
|
+
await db_default.insert(inspectionFieldGroupTable).values(body);
|
|
153927
|
+
};
|
|
153928
|
+
InspectionFieldGroupLogic.update = async (id, body) => {
|
|
153929
|
+
await db_default.update(inspectionFieldGroupTable).set(body).where(eq(inspectionFieldGroupTable.id, id));
|
|
153930
|
+
};
|
|
153931
|
+
InspectionFieldGroupLogic.remove = async (id) => {
|
|
153932
|
+
await db_default.update(inspectionFieldGroupTable).set({
|
|
153933
|
+
deletedAt: sql3`now`
|
|
153934
|
+
}).where(eq(inspectionFieldGroupTable.id, id));
|
|
153935
|
+
};
|
|
153936
|
+
})(InspectionFieldGroupLogic ||= {});
|
|
153937
|
+
var logic_default26 = InspectionFieldGroupLogic;
|
|
153938
|
+
|
|
153939
|
+
// src/routes/fleet/inspection/fieldGroup/model.ts
|
|
153940
|
+
var InspectionFieldGroupModel;
|
|
153941
|
+
((InspectionFieldGroupModel) => {
|
|
153942
|
+
const createSchema = createInsertSchema(inspectionFieldGroupTable);
|
|
153943
|
+
const updateSchema = createUpdateSchema(inspectionFieldGroupTable);
|
|
153944
|
+
InspectionFieldGroupModel.create = OmitBaseSchema(createSchema);
|
|
153945
|
+
InspectionFieldGroupModel.update = OmitBaseSchema(updateSchema);
|
|
153946
|
+
InspectionFieldGroupModel.select = t.Composite([
|
|
153947
|
+
t.Partial(t.Object({
|
|
153948
|
+
name: t.String(),
|
|
153949
|
+
code: t.String()
|
|
153950
|
+
})),
|
|
153951
|
+
PaginationSchema
|
|
153952
|
+
]);
|
|
153953
|
+
})(InspectionFieldGroupModel ||= {});
|
|
153954
|
+
var model_default25 = InspectionFieldGroupModel;
|
|
153955
|
+
|
|
153956
|
+
// src/routes/fleet/inspection/fieldGroup/index.ts
|
|
153957
|
+
var fieldGroupRoutes = new Elysia({
|
|
153958
|
+
prefix: "/field-group"
|
|
153959
|
+
}).use(better_auth_default).guard({
|
|
153960
|
+
userKind: "ADMIN"
|
|
153961
|
+
}).get("/", async ({ query }) => logic_default26.select(query), {
|
|
153962
|
+
query: model_default25.select,
|
|
153963
|
+
userKind: undefined,
|
|
153964
|
+
auth: true
|
|
153965
|
+
}).post("/", async ({ body }) => logic_default26.create(body), {
|
|
153966
|
+
body: model_default25.create
|
|
153967
|
+
}).guard({
|
|
153968
|
+
params: IdSchema
|
|
153969
|
+
}).put("/:id", async ({ body, params: { id } }) => logic_default26.update(id, body), {
|
|
153970
|
+
body: model_default25.update
|
|
153971
|
+
}).delete("/:id", async ({ params: { id } }) => logic_default26.remove(id)).get("/:id/field", async ({ params: { id } }) => logic_default25.select(id));
|
|
153972
|
+
var fieldGroup_default = fieldGroupRoutes;
|
|
153973
|
+
|
|
153974
|
+
// src/routes/fleet/inspection/index.ts
|
|
153975
|
+
var inspectionRoutes2 = new Elysia({
|
|
153976
|
+
prefix: "/inspection"
|
|
153977
|
+
}).use(fieldGroup_default);
|
|
153978
|
+
var inspection_default2 = inspectionRoutes2;
|
|
153979
|
+
|
|
153980
|
+
// src/routes/fleet/index.ts
|
|
153981
|
+
var fleetRoutes = new Elysia({ prefix: "/fleet" }).use(inspection_default2);
|
|
153982
|
+
var fleet_default = fleetRoutes;
|
|
153983
|
+
|
|
153835
153984
|
// src/routes/index.ts
|
|
153836
153985
|
var router2 = new Elysia({
|
|
153837
153986
|
prefix: "/api"
|
|
153838
|
-
}).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default);
|
|
153987
|
+
}).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default).use(fleet_default);
|
|
153839
153988
|
var routes_default = router2;
|
|
153840
153989
|
|
|
153841
153990
|
// src/index.ts
|