autosync_backend2 1.1.8 → 1.1.11
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 +78 -23
- package/dist/index.js +61 -20
- package/package.json +60 -60
package/dist/index.d.ts
CHANGED
|
@@ -327,6 +327,15 @@ declare const app: Elysia<"", {
|
|
|
327
327
|
page: import("@sinclair/typebox").TInteger;
|
|
328
328
|
size: import("@sinclair/typebox").TInteger;
|
|
329
329
|
}>;
|
|
330
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
331
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
332
|
+
phone: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
333
|
+
orderId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
334
|
+
state: import("@sinclair/typebox").TOptional<import("elysia/dist/type-system/types").TUnionEnum<["CREATED", "PROGRESSING", "COMPLETE"]>>;
|
|
335
|
+
vin: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
336
|
+
licensePlate: import("@sinclair/typebox").TOptional<import("elysia/dist/type-system/types").TTransform<import("@sinclair/typebox").TString, string>>;
|
|
337
|
+
timeCompleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
338
|
+
model: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
330
339
|
}>;
|
|
331
340
|
readonly "CrmSpPackageServiceModel.create": import("@sinclair/typebox").TObject<{
|
|
332
341
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
|
|
@@ -344,13 +353,7 @@ declare const app: Elysia<"", {
|
|
|
344
353
|
}>;
|
|
345
354
|
readonly "CrmSpPackageServiceModel.update": import("@sinclair/typebox").TObject<{
|
|
346
355
|
quantity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
347
|
-
state: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
|
348
|
-
CREATED: "CREATED";
|
|
349
|
-
COMPLETE: "COMPLETE";
|
|
350
|
-
PROGRESSING: "PROGRESSING";
|
|
351
|
-
}>>;
|
|
352
356
|
priceUnit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
353
|
-
timeCompleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TDate, import("@sinclair/typebox").TNull]>>;
|
|
354
357
|
}> & import("@sinclair/typebox").TObject<{
|
|
355
358
|
quantity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
356
359
|
priceTotal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -379,11 +382,6 @@ declare const app: Elysia<"", {
|
|
|
379
382
|
}>;
|
|
380
383
|
readonly "CrmSpPackageProductModel.update": import("@sinclair/typebox").TObject<{
|
|
381
384
|
quantity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
382
|
-
state: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
|
383
|
-
CREATED: "CREATED";
|
|
384
|
-
COMPLETE: "COMPLETE";
|
|
385
|
-
PROGRESSING: "PROGRESSING";
|
|
386
|
-
}>>;
|
|
387
385
|
priceUnit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
388
386
|
}> & import("@sinclair/typebox").TObject<{
|
|
389
387
|
quantity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
@@ -3065,6 +3063,15 @@ declare const app: Elysia<"", {
|
|
|
3065
3063
|
body: unknown;
|
|
3066
3064
|
params: {};
|
|
3067
3065
|
query: {
|
|
3066
|
+
id?: string | undefined;
|
|
3067
|
+
createdAt?: string | undefined;
|
|
3068
|
+
phone?: string | undefined;
|
|
3069
|
+
orderId?: string | undefined;
|
|
3070
|
+
state?: "CREATED" | "COMPLETE" | "PROGRESSING" | undefined;
|
|
3071
|
+
vin?: string | undefined;
|
|
3072
|
+
licensePlate?: string | undefined;
|
|
3073
|
+
timeCompleted?: string | undefined;
|
|
3074
|
+
model?: string | undefined;
|
|
3068
3075
|
pagination: {
|
|
3069
3076
|
size: number;
|
|
3070
3077
|
page: number;
|
|
@@ -3082,6 +3089,8 @@ declare const app: Elysia<"", {
|
|
|
3082
3089
|
customerId: string | null;
|
|
3083
3090
|
vehicleId: string;
|
|
3084
3091
|
orderId: string;
|
|
3092
|
+
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3093
|
+
timeCompleted: Date | null;
|
|
3085
3094
|
id: string;
|
|
3086
3095
|
createdAt: string;
|
|
3087
3096
|
updatedAt: string;
|
|
@@ -3121,6 +3130,7 @@ declare const app: Elysia<"", {
|
|
|
3121
3130
|
updatedAt: string;
|
|
3122
3131
|
deletedAt: string | null;
|
|
3123
3132
|
} | null;
|
|
3133
|
+
isDeleteAble: unknown;
|
|
3124
3134
|
}[];
|
|
3125
3135
|
};
|
|
3126
3136
|
422: {
|
|
@@ -3155,9 +3165,11 @@ declare const app: Elysia<"", {
|
|
|
3155
3165
|
companyId: string;
|
|
3156
3166
|
deletedAt: string | null;
|
|
3157
3167
|
orderId: string;
|
|
3168
|
+
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3158
3169
|
customerId: string | null;
|
|
3159
3170
|
vehicleId: string;
|
|
3160
3171
|
companyBranchId: string;
|
|
3172
|
+
timeCompleted: Date | null;
|
|
3161
3173
|
};
|
|
3162
3174
|
502: string;
|
|
3163
3175
|
400: "Машины дугаар болон VIN хоёроос нэгийг нь оруулна уу." | "Машины VIN оруулсан бол машины төрөл оруулна уу.";
|
|
@@ -3202,6 +3214,61 @@ declare const app: Elysia<"", {
|
|
|
3202
3214
|
};
|
|
3203
3215
|
};
|
|
3204
3216
|
};
|
|
3217
|
+
} & {
|
|
3218
|
+
"cp-order": {
|
|
3219
|
+
":id": {
|
|
3220
|
+
complete: {
|
|
3221
|
+
post: {
|
|
3222
|
+
body: unknown;
|
|
3223
|
+
params: {
|
|
3224
|
+
id: string;
|
|
3225
|
+
};
|
|
3226
|
+
query: unknown;
|
|
3227
|
+
headers: unknown;
|
|
3228
|
+
response: {
|
|
3229
|
+
200: undefined;
|
|
3230
|
+
404: "Засвар үйлчилгээ олдсонгүй.";
|
|
3231
|
+
422: {
|
|
3232
|
+
type: "validation";
|
|
3233
|
+
on: string;
|
|
3234
|
+
summary?: string;
|
|
3235
|
+
message?: string;
|
|
3236
|
+
found?: unknown;
|
|
3237
|
+
property?: string;
|
|
3238
|
+
expected?: string;
|
|
3239
|
+
};
|
|
3240
|
+
};
|
|
3241
|
+
};
|
|
3242
|
+
};
|
|
3243
|
+
};
|
|
3244
|
+
};
|
|
3245
|
+
} & {
|
|
3246
|
+
"cp-order": {
|
|
3247
|
+
":id": {
|
|
3248
|
+
delete: {
|
|
3249
|
+
body: unknown;
|
|
3250
|
+
params: {
|
|
3251
|
+
id: string;
|
|
3252
|
+
};
|
|
3253
|
+
query: unknown;
|
|
3254
|
+
headers: unknown;
|
|
3255
|
+
response: {
|
|
3256
|
+
200: undefined;
|
|
3257
|
+
404: "Засвар үйлчилгээ олдсонгүй.";
|
|
3258
|
+
400: "Үйлчилгээ хоосон биш байна.";
|
|
3259
|
+
422: {
|
|
3260
|
+
type: "validation";
|
|
3261
|
+
on: string;
|
|
3262
|
+
summary?: string;
|
|
3263
|
+
message?: string;
|
|
3264
|
+
found?: unknown;
|
|
3265
|
+
property?: string;
|
|
3266
|
+
expected?: string;
|
|
3267
|
+
};
|
|
3268
|
+
};
|
|
3269
|
+
};
|
|
3270
|
+
};
|
|
3271
|
+
};
|
|
3205
3272
|
} & {
|
|
3206
3273
|
"cp-order": {
|
|
3207
3274
|
service: {};
|
|
@@ -3223,8 +3290,6 @@ declare const app: Elysia<"", {
|
|
|
3223
3290
|
priceUnit: number;
|
|
3224
3291
|
priceTotal: number;
|
|
3225
3292
|
name: string | null;
|
|
3226
|
-
timeCompleted: Date | null;
|
|
3227
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3228
3293
|
id: string;
|
|
3229
3294
|
createdAt: string;
|
|
3230
3295
|
updatedAt: string;
|
|
@@ -3264,13 +3329,11 @@ declare const app: Elysia<"", {
|
|
|
3264
3329
|
updatedAt: string;
|
|
3265
3330
|
deletedAt: string | null;
|
|
3266
3331
|
quantity: number;
|
|
3267
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3268
3332
|
priceTotal: number;
|
|
3269
3333
|
priceUnit: number;
|
|
3270
3334
|
cpOrderId: string;
|
|
3271
3335
|
cpOrderSpPackageId: string | null;
|
|
3272
3336
|
companyServiceKindId: string;
|
|
3273
|
-
timeCompleted: Date | null;
|
|
3274
3337
|
};
|
|
3275
3338
|
404: "Үйлчилгээний төрөл олдсонгүй.";
|
|
3276
3339
|
422: {
|
|
@@ -3291,9 +3354,7 @@ declare const app: Elysia<"", {
|
|
|
3291
3354
|
put: {
|
|
3292
3355
|
body: {
|
|
3293
3356
|
quantity?: number | undefined;
|
|
3294
|
-
state?: "CREATED" | "COMPLETE" | "PROGRESSING" | undefined;
|
|
3295
3357
|
priceUnit?: number | undefined;
|
|
3296
|
-
timeCompleted?: Date | null | undefined;
|
|
3297
3358
|
};
|
|
3298
3359
|
params: {
|
|
3299
3360
|
id: string;
|
|
@@ -3309,8 +3370,6 @@ declare const app: Elysia<"", {
|
|
|
3309
3370
|
priceUnit: number;
|
|
3310
3371
|
priceTotal: number;
|
|
3311
3372
|
name: string | null;
|
|
3312
|
-
timeCompleted: Date | null;
|
|
3313
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3314
3373
|
id: string;
|
|
3315
3374
|
createdAt: string;
|
|
3316
3375
|
updatedAt: string;
|
|
@@ -3377,7 +3436,6 @@ declare const app: Elysia<"", {
|
|
|
3377
3436
|
priceUnit: number;
|
|
3378
3437
|
priceTotal: number;
|
|
3379
3438
|
name: string | null;
|
|
3380
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3381
3439
|
id: string;
|
|
3382
3440
|
createdAt: string;
|
|
3383
3441
|
updatedAt: string;
|
|
@@ -3417,7 +3475,6 @@ declare const app: Elysia<"", {
|
|
|
3417
3475
|
updatedAt: string;
|
|
3418
3476
|
deletedAt: string | null;
|
|
3419
3477
|
quantity: number;
|
|
3420
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3421
3478
|
priceTotal: number;
|
|
3422
3479
|
priceUnit: number;
|
|
3423
3480
|
companyProductId: string;
|
|
@@ -3443,7 +3500,6 @@ declare const app: Elysia<"", {
|
|
|
3443
3500
|
put: {
|
|
3444
3501
|
body: {
|
|
3445
3502
|
quantity?: number | undefined;
|
|
3446
|
-
state?: "CREATED" | "COMPLETE" | "PROGRESSING" | undefined;
|
|
3447
3503
|
priceUnit?: number | undefined;
|
|
3448
3504
|
};
|
|
3449
3505
|
params: {
|
|
@@ -3460,7 +3516,6 @@ declare const app: Elysia<"", {
|
|
|
3460
3516
|
priceUnit: number;
|
|
3461
3517
|
priceTotal: number;
|
|
3462
3518
|
name: string | null;
|
|
3463
|
-
state: "CREATED" | "COMPLETE" | "PROGRESSING";
|
|
3464
3519
|
id: string;
|
|
3465
3520
|
createdAt: string;
|
|
3466
3521
|
updatedAt: string;
|
package/dist/index.js
CHANGED
|
@@ -137862,13 +137862,22 @@ var crmSpPackageProductTable = crmSchema.table("sp_package_product", {
|
|
|
137862
137862
|
priceUnit: numeric({ mode: "number" }).notNull(),
|
|
137863
137863
|
priceTotal: numeric({ mode: "number" }).notNull().$onUpdateFn(() => sql3`${crmSpPackageProductTable.priceUnit} * ${crmSpPackageProductTable.quantity}`).$defaultFn(() => sql3`${crmSpPackageProductTable.priceUnit} * ${crmSpPackageProductTable.quantity}`)
|
|
137864
137864
|
}, (t2) => [unique().on(t2.spPackageId, t2.companyProductId)]);
|
|
137865
|
+
var crmCpOrderStateEnum = pgEnum("cp_order_state", [
|
|
137866
|
+
"CREATED",
|
|
137867
|
+
"PROGRESSING",
|
|
137868
|
+
"COMPLETE"
|
|
137869
|
+
]);
|
|
137865
137870
|
var crmCpOrderTable = crmSchema.table("cp_order", {
|
|
137866
137871
|
...base_schema_helper_default,
|
|
137867
137872
|
companyId: uuid().notNull(),
|
|
137868
137873
|
companyBranchId: uuid().notNull(),
|
|
137869
137874
|
customerId: uuid(),
|
|
137870
137875
|
vehicleId: uuid().notNull(),
|
|
137871
|
-
orderId: varchar().notNull()
|
|
137876
|
+
orderId: varchar().notNull(),
|
|
137877
|
+
state: crmCpOrderStateEnum("state").notNull().default("CREATED"),
|
|
137878
|
+
timeCompleted: timestamp({
|
|
137879
|
+
withTimezone: true
|
|
137880
|
+
})
|
|
137872
137881
|
});
|
|
137873
137882
|
var crmCpOrderSpPackageTable = crmSchema.table("cp_order_sp_package", {
|
|
137874
137883
|
...base_schema_helper_default,
|
|
@@ -137880,11 +137889,6 @@ var crmCpOrderSpPackageTable = crmSchema.table("cp_order_sp_package", {
|
|
|
137880
137889
|
name: varchar().notNull(),
|
|
137881
137890
|
description: varchar()
|
|
137882
137891
|
});
|
|
137883
|
-
var crmCpOrderStateEnum = pgEnum("cp_order_state", [
|
|
137884
|
-
"CREATED",
|
|
137885
|
-
"PROGRESSING",
|
|
137886
|
-
"COMPLETE"
|
|
137887
|
-
]);
|
|
137888
137892
|
var crmCpOrderServiceTable = crmSchema.table("cp_order_service", {
|
|
137889
137893
|
...base_schema_helper_default,
|
|
137890
137894
|
cpOrderId: uuid().notNull(),
|
|
@@ -137893,11 +137897,7 @@ var crmCpOrderServiceTable = crmSchema.table("cp_order_service", {
|
|
|
137893
137897
|
quantity: integer().notNull(),
|
|
137894
137898
|
priceUnit: numeric({ mode: "number" }).notNull(),
|
|
137895
137899
|
priceTotal: numeric({ mode: "number" }).notNull().$defaultFn(() => sql3`${crmCpOrderServiceTable.priceUnit} * ${crmCpOrderServiceTable.quantity}`).$onUpdateFn(() => sql3`${crmCpOrderServiceTable.priceUnit} * ${crmCpOrderServiceTable.quantity}`),
|
|
137896
|
-
name: varchar()
|
|
137897
|
-
timeCompleted: timestamp({
|
|
137898
|
-
withTimezone: true
|
|
137899
|
-
}),
|
|
137900
|
-
state: crmCpOrderStateEnum("state").notNull().default("CREATED")
|
|
137900
|
+
name: varchar()
|
|
137901
137901
|
}, (t2) => [unique().on(t2.cpOrderId, t2.companyServiceKindId)]);
|
|
137902
137902
|
var crmCpOrderProductTable = crmSchema.table("cp_order_product", {
|
|
137903
137903
|
...base_schema_helper_default,
|
|
@@ -137907,8 +137907,7 @@ var crmCpOrderProductTable = crmSchema.table("cp_order_product", {
|
|
|
137907
137907
|
quantity: integer().notNull(),
|
|
137908
137908
|
priceUnit: numeric({ mode: "number" }).notNull(),
|
|
137909
137909
|
priceTotal: numeric({ mode: "number" }).notNull().$defaultFn(() => sql3`${crmCpOrderProductTable.priceUnit} * ${crmCpOrderProductTable.quantity}`).$onUpdateFn(() => sql3`${crmCpOrderProductTable.priceUnit} * ${crmCpOrderProductTable.quantity}`),
|
|
137910
|
-
name: varchar()
|
|
137911
|
-
state: crmCpOrderStateEnum("state").notNull().default("CREATED")
|
|
137910
|
+
name: varchar()
|
|
137912
137911
|
}, (t2) => [unique().on(t2.cpOrderId, t2.companyProductId)]);
|
|
137913
137912
|
// src/lib/db/schema/techdoc.schema.ts
|
|
137914
137913
|
var techdocSchema = pgSchema("techdoc");
|
|
@@ -143444,13 +143443,17 @@ var logic_default9 = CrmCpOrderServiceLogic;
|
|
|
143444
143443
|
var CrmCpOrderLogic;
|
|
143445
143444
|
((CrmCpOrderLogic) => {
|
|
143446
143445
|
CrmCpOrderLogic.select = async (query, user2) => {
|
|
143447
|
-
const filter = and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"));
|
|
143446
|
+
const filter = and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), eq(crmCpOrderTable.state, query.state ?? "CREATED").if(query.state), eq(crmCpOrderTable.id, query.id ?? "").if(query.id), softDeletedFilter(crmCpOrderTable), like(crmCpOrderTable.orderId, query.orderId ?? "").if(query.orderId), ilike(techdocVehicleKindTable.name, sql3`%${query.model}%`).if(query.model), eq(crmVehicleTable.createdAt, query.createdAt ?? "").if(query.createdAt), like(crmVehicleTable.licensePlate, sql3`${query.licensePlate}%`).if(query.licensePlate), ilike(crmVehicleTable.vin, sql3`%${query.vin}%`).if(query.vin), like(crmCustomerTable.phoneNumber, sql3`${query.phone}%`).if(query.phone));
|
|
143448
143447
|
const baseQuery = db_default.select({
|
|
143449
143448
|
totalCount: totalCountSql,
|
|
143450
143449
|
order: crmCpOrderTable,
|
|
143451
143450
|
vehicle: crmVehicleTable,
|
|
143452
|
-
customer: crmCustomerTable
|
|
143453
|
-
|
|
143451
|
+
customer: crmCustomerTable,
|
|
143452
|
+
isDeleteAble: sql3`(
|
|
143453
|
+
(select count(*) from ${crmCpOrderProductTable} where ${crmCpOrderProductTable.cpOrderId} = ${crmCpOrderTable.id} and ${crmCpOrderProductTable.deletedAt} is null)
|
|
143454
|
+
+ (select count(*) from ${crmCpOrderServiceTable} where ${crmCpOrderServiceTable.cpOrderId} = ${crmCpOrderTable.id} and ${crmCpOrderServiceTable.deletedAt} is null)
|
|
143455
|
+
) = 0`.as("is_delete_able")
|
|
143456
|
+
}).from(crmCpOrderTable).innerJoin(crmVehicleTable, eq(crmVehicleTable.id, crmCpOrderTable.vehicleId)).leftJoin(crmCustomerTable, eq(crmCustomerTable.id, crmCpOrderTable.customerId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).where(filter).$dynamic();
|
|
143454
143457
|
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
143455
143458
|
const content = {
|
|
143456
143459
|
totalCount: result[0].totalCount,
|
|
@@ -143497,9 +143500,9 @@ var CrmCpOrderLogic;
|
|
|
143497
143500
|
}).from(crmCpOrderTable).where(and(ilike(crmCpOrderTable.orderId, `${formatted}%`), eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId))).orderBy(desc(crmCpOrderTable.orderId)).limit(1);
|
|
143498
143501
|
if (latest) {
|
|
143499
143502
|
const count2 = +latest.orderId.split("-")[1] + 1;
|
|
143500
|
-
return `${formatted}-${count2.toString().padStart(
|
|
143503
|
+
return `${formatted}-${count2.toString().padStart(3, "0")}`;
|
|
143501
143504
|
}
|
|
143502
|
-
return `${formatted}-
|
|
143505
|
+
return `${formatted}-001`;
|
|
143503
143506
|
};
|
|
143504
143507
|
CrmCpOrderLogic.addPackage = async ({ spPackageId, cpOrderId, quantity }, user2) => {
|
|
143505
143508
|
const spPackage = await logic_default4.selectById(spPackageId);
|
|
@@ -143543,6 +143546,29 @@ var CrmCpOrderLogic;
|
|
|
143543
143546
|
}
|
|
143544
143547
|
});
|
|
143545
143548
|
};
|
|
143549
|
+
CrmCpOrderLogic.complete = async (id, user2) => {
|
|
143550
|
+
const [order] = await db_default.update(crmCpOrderTable).set({
|
|
143551
|
+
state: "COMPLETE",
|
|
143552
|
+
timeCompleted: nowSql_helper_default
|
|
143553
|
+
}).where(and(eq(crmCpOrderTable.id, id), eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"))).returning();
|
|
143554
|
+
if (!order) {
|
|
143555
|
+
return status("Not Found", "\u0417\u0430\u0441\u0432\u0430\u0440 \u04AF\u0439\u043B\u0447\u0438\u043B\u0433\u044D\u044D \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
|
|
143556
|
+
}
|
|
143557
|
+
};
|
|
143558
|
+
CrmCpOrderLogic.remove = async (id, user2) => {
|
|
143559
|
+
const order = await db_default.select().from(crmCpOrderTable).where(and(eq(crmCpOrderTable.id, id), eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"))).leftJoin(crmCpOrderProductTable, eq(crmCpOrderProductTable.cpOrderId, crmCpOrderTable.id)).leftJoin(crmCpOrderServiceTable, eq(crmCpOrderServiceTable.cpOrderId, crmCpOrderTable.id));
|
|
143560
|
+
if (order.length === 0) {
|
|
143561
|
+
return status("Not Found", "\u0417\u0430\u0441\u0432\u0430\u0440 \u04AF\u0439\u043B\u0447\u0438\u043B\u0433\u044D\u044D \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
|
|
143562
|
+
}
|
|
143563
|
+
const products = order.map((i2) => i2.cp_order_product).filter((i2) => Boolean(i2));
|
|
143564
|
+
const services = order.map((i2) => i2.cp_order_service).filter((i2) => Boolean(i2));
|
|
143565
|
+
if (products.length + services.length > 0) {
|
|
143566
|
+
return status("Bad Request", "\u04AE\u0439\u043B\u0447\u0438\u043B\u0433\u044D\u044D \u0445\u043E\u043E\u0441\u043E\u043D \u0431\u0438\u0448 \u0431\u0430\u0439\u043D\u0430.");
|
|
143567
|
+
}
|
|
143568
|
+
await db_default.update(crmCpOrderTable).set({
|
|
143569
|
+
deletedAt: nowSql_helper_default
|
|
143570
|
+
}).where(eq(crmCpOrderTable.id, id));
|
|
143571
|
+
};
|
|
143546
143572
|
})(CrmCpOrderLogic ||= {});
|
|
143547
143573
|
var logic_default10 = CrmCpOrderLogic;
|
|
143548
143574
|
|
|
@@ -143563,7 +143589,20 @@ var CrmCpOrderModel;
|
|
|
143563
143589
|
cpOrderId: t.String({ format: "uuid" }),
|
|
143564
143590
|
quantity: t.Number({ minimum: 1 })
|
|
143565
143591
|
});
|
|
143566
|
-
CrmCpOrderModel.select = t.Composite([
|
|
143592
|
+
CrmCpOrderModel.select = t.Composite([
|
|
143593
|
+
PaginationSchema,
|
|
143594
|
+
t.Partial(t.Object({
|
|
143595
|
+
state: t.UnionEnum(crmCpOrderStateEnum.enumValues),
|
|
143596
|
+
id: t.String({ format: "uuid" }),
|
|
143597
|
+
model: t.String(),
|
|
143598
|
+
phone: t.String(),
|
|
143599
|
+
createdAt: t.String({ format: "date" }),
|
|
143600
|
+
timeCompleted: t.String({ format: "date" }),
|
|
143601
|
+
vin: t.String(),
|
|
143602
|
+
orderId: t.String(),
|
|
143603
|
+
licensePlate: t.Transform(t.String()).Decode((value) => value.toUpperCase()).Encode((value) => value)
|
|
143604
|
+
}))
|
|
143605
|
+
]);
|
|
143567
143606
|
})(CrmCpOrderModel ||= {});
|
|
143568
143607
|
var model_default5 = CrmCpOrderModel;
|
|
143569
143608
|
|
|
@@ -143669,7 +143708,9 @@ var cpOrderRoutes = new Elysia({
|
|
|
143669
143708
|
body: "CrmCpOrderModel.create"
|
|
143670
143709
|
}).post("/package", async ({ body, user: user2 }) => logic_default10.addPackage(body, user2), {
|
|
143671
143710
|
body: "CrmCpOrderModel.addPackage"
|
|
143672
|
-
}).
|
|
143711
|
+
}).guard({
|
|
143712
|
+
params: IdSchema
|
|
143713
|
+
}).post("/:id/complete", async ({ user: user2, params: { id } }) => logic_default10.complete(id, user2)).delete("/:id", async ({ user: user2, params: { id } }) => logic_default10.remove(id, user2)).use(service_default).use(product_default);
|
|
143673
143714
|
var cpOrder_default = cpOrderRoutes;
|
|
143674
143715
|
|
|
143675
143716
|
// src/routes/crm/spPackage/model.ts
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
"name": "autosync_backend2",
|
|
3
|
+
"version": "1.1.11",
|
|
4
|
+
"module": "src/index.ts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"dev": "bun run --watch src/index.ts",
|
|
11
|
+
"build": "bun build --target=bun ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
|
|
12
|
+
"build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json",
|
|
13
|
+
"db:migrate": "bunx --bun drizzle-kit migrate",
|
|
14
|
+
"db:generate": "bunx --bun drizzle-kit generate",
|
|
15
|
+
"biome:check": "bunx biome check --write",
|
|
16
|
+
"email": "email dev --dir src/lib/emails",
|
|
17
|
+
"prepare": "husky"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@bogeychan/elysia-logger": "^0.1.8",
|
|
21
|
+
"@elysiajs/cors": "^1.3.3",
|
|
22
|
+
"@elysiajs/eden": "^1.3.2",
|
|
23
|
+
"@elysiajs/swagger": "^1.3.0",
|
|
24
|
+
"@react-email/components": "^0.0.41",
|
|
25
|
+
"@sinclair/typebox": "^0.34.35",
|
|
26
|
+
"@upstash/redis": "^1.35.0",
|
|
27
|
+
"better-auth": "^1.2.9",
|
|
28
|
+
"drizzle-orm": "^0.44.2",
|
|
29
|
+
"drizzle-typebox": "^0.3.3",
|
|
30
|
+
"elysia": "^1.3.5",
|
|
31
|
+
"exceljs": "^4.4.0",
|
|
32
|
+
"fast-xml-parser": "^5.2.5",
|
|
33
|
+
"generate-password": "^1.7.1",
|
|
34
|
+
"nodemailer": "^7.0.3",
|
|
35
|
+
"pg": "^8.16.1",
|
|
36
|
+
"pino": "^9.7.0",
|
|
37
|
+
"pino-pretty": "^13.0.0",
|
|
38
|
+
"react": "^19.1.0",
|
|
39
|
+
"react-dom": "^19.1.0",
|
|
40
|
+
"xlsx": "^0.18.5"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "1.9.4",
|
|
44
|
+
"@types/nodemailer": "^6.4.17",
|
|
45
|
+
"@types/pg": "^8.15.4",
|
|
46
|
+
"@types/react": "^19.1.8",
|
|
47
|
+
"@types/react-dom": "^19.1.6",
|
|
48
|
+
"bun-types": "latest",
|
|
49
|
+
"drizzle-kit": "^0.31.1",
|
|
50
|
+
"husky": "^9.1.7",
|
|
51
|
+
"react-email": "^4.0.16"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist/*.js",
|
|
55
|
+
"dist/*.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/Suld-United/autosync_back_2.git"
|
|
60
|
+
},
|
|
61
|
+
"packageManager": "pnpm@10.6.3+sha512.bb45e34d50a9a76e858a95837301bfb6bd6d35aea2c5d52094fa497a467c43f5c440103ce2511e9e0a2f89c3d6071baac3358fc68ac6fb75e2ceb3d2736065e6"
|
|
62
62
|
}
|