autosync_backend2 1.1.35 → 1.1.37
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/env.d.ts +2 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +58 -5
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ declare const EnvSchema: import("@sinclair/typebox").TObject<{
|
|
|
8
8
|
SMTP_USER: import("@sinclair/typebox").TString;
|
|
9
9
|
SMTP_PASSWORD: import("@sinclair/typebox").TString;
|
|
10
10
|
ATUT_TOKEN: import("@sinclair/typebox").TString;
|
|
11
|
+
AWS_ACCESS_KEY: import("@sinclair/typebox").TString;
|
|
12
|
+
AWS_SECRET_KEY: import("@sinclair/typebox").TString;
|
|
11
13
|
}>;
|
|
12
14
|
export type env = typeof EnvSchema.static;
|
|
13
15
|
declare let env: env;
|
package/dist/index.d.ts
CHANGED
|
@@ -1420,6 +1420,60 @@ export declare const app: Elysia<"", {
|
|
|
1420
1420
|
};
|
|
1421
1421
|
parser: {};
|
|
1422
1422
|
}, {
|
|
1423
|
+
api: {
|
|
1424
|
+
image: {};
|
|
1425
|
+
} & {
|
|
1426
|
+
image: {
|
|
1427
|
+
post: {
|
|
1428
|
+
body: {
|
|
1429
|
+
image: File;
|
|
1430
|
+
folder: string;
|
|
1431
|
+
};
|
|
1432
|
+
params: {};
|
|
1433
|
+
query: unknown;
|
|
1434
|
+
headers: unknown;
|
|
1435
|
+
response: {
|
|
1436
|
+
200: {
|
|
1437
|
+
path: string;
|
|
1438
|
+
};
|
|
1439
|
+
422: {
|
|
1440
|
+
type: "validation";
|
|
1441
|
+
on: string;
|
|
1442
|
+
summary?: string;
|
|
1443
|
+
message?: string;
|
|
1444
|
+
found?: unknown;
|
|
1445
|
+
property?: string;
|
|
1446
|
+
expected?: string;
|
|
1447
|
+
};
|
|
1448
|
+
};
|
|
1449
|
+
};
|
|
1450
|
+
};
|
|
1451
|
+
} & {
|
|
1452
|
+
image: {
|
|
1453
|
+
get: {
|
|
1454
|
+
body: unknown;
|
|
1455
|
+
params: {};
|
|
1456
|
+
query: {
|
|
1457
|
+
name: string;
|
|
1458
|
+
folder: string;
|
|
1459
|
+
};
|
|
1460
|
+
headers: unknown;
|
|
1461
|
+
response: {
|
|
1462
|
+
200: Response;
|
|
1463
|
+
422: {
|
|
1464
|
+
type: "validation";
|
|
1465
|
+
on: string;
|
|
1466
|
+
summary?: string;
|
|
1467
|
+
message?: string;
|
|
1468
|
+
found?: unknown;
|
|
1469
|
+
property?: string;
|
|
1470
|
+
expected?: string;
|
|
1471
|
+
};
|
|
1472
|
+
};
|
|
1473
|
+
};
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
} & {
|
|
1423
1477
|
api: {
|
|
1424
1478
|
warehouse: {
|
|
1425
1479
|
product: {};
|
|
@@ -5134,6 +5188,52 @@ export declare const app: Elysia<"", {
|
|
|
5134
5188
|
};
|
|
5135
5189
|
};
|
|
5136
5190
|
};
|
|
5191
|
+
} & {
|
|
5192
|
+
vehicleKind: {
|
|
5193
|
+
":id": {
|
|
5194
|
+
put: {
|
|
5195
|
+
body: {
|
|
5196
|
+
name?: string | undefined;
|
|
5197
|
+
description?: string | null | undefined;
|
|
5198
|
+
vehicleKindEnum?: "MAKE" | "MODEL_GROUP" | "MODEL" | undefined;
|
|
5199
|
+
parentId?: string | null | undefined;
|
|
5200
|
+
yearStart?: number | null | undefined;
|
|
5201
|
+
yearEnd?: number | null | undefined;
|
|
5202
|
+
imagePath?: string | null | undefined;
|
|
5203
|
+
};
|
|
5204
|
+
params: {
|
|
5205
|
+
id: string;
|
|
5206
|
+
};
|
|
5207
|
+
query: unknown;
|
|
5208
|
+
headers: unknown;
|
|
5209
|
+
response: {
|
|
5210
|
+
200: {
|
|
5211
|
+
vehicleKindEnum: "MAKE" | "MODEL_GROUP" | "MODEL";
|
|
5212
|
+
parentId: string | null;
|
|
5213
|
+
name: string;
|
|
5214
|
+
description: string | null;
|
|
5215
|
+
yearStart: number | null;
|
|
5216
|
+
yearEnd: number | null;
|
|
5217
|
+
imagePath: string | null;
|
|
5218
|
+
id: string;
|
|
5219
|
+
createdAt: string;
|
|
5220
|
+
updatedAt: string;
|
|
5221
|
+
deletedAt: string | null;
|
|
5222
|
+
};
|
|
5223
|
+
404: "Vehicle kind not found";
|
|
5224
|
+
422: {
|
|
5225
|
+
type: "validation";
|
|
5226
|
+
on: string;
|
|
5227
|
+
summary?: string;
|
|
5228
|
+
message?: string;
|
|
5229
|
+
found?: unknown;
|
|
5230
|
+
property?: string;
|
|
5231
|
+
expected?: string;
|
|
5232
|
+
};
|
|
5233
|
+
};
|
|
5234
|
+
};
|
|
5235
|
+
};
|
|
5236
|
+
};
|
|
5137
5237
|
};
|
|
5138
5238
|
};
|
|
5139
5239
|
}, {
|
package/dist/index.js
CHANGED
|
@@ -112438,13 +112438,16 @@ var EnvSchema = t.Object({
|
|
|
112438
112438
|
UPSTASH_REDIS_REST_TOKEN: t.String(),
|
|
112439
112439
|
SMTP_USER: t.String(),
|
|
112440
112440
|
SMTP_PASSWORD: t.String(),
|
|
112441
|
-
ATUT_TOKEN: t.String()
|
|
112441
|
+
ATUT_TOKEN: t.String(),
|
|
112442
|
+
AWS_ACCESS_KEY: t.String(),
|
|
112443
|
+
AWS_SECRET_KEY: t.String()
|
|
112442
112444
|
});
|
|
112443
112445
|
var env3;
|
|
112444
112446
|
try {
|
|
112445
112447
|
env3 = exports_value2.Parse(EnvSchema, Bun.env);
|
|
112446
112448
|
} catch (err2) {
|
|
112447
112449
|
const _error = err2;
|
|
112450
|
+
console.error(_error);
|
|
112448
112451
|
process.exit(1);
|
|
112449
112452
|
}
|
|
112450
112453
|
var env_default = env3;
|
|
@@ -141319,8 +141322,7 @@ var IdSchema = t.Object({
|
|
|
141319
141322
|
id: t.String({ format: "uuid" })
|
|
141320
141323
|
});
|
|
141321
141324
|
var UuidSchema = t.String({
|
|
141322
|
-
format: "uuid"
|
|
141323
|
-
default: "00000000-0000-0000-0000-000000000000"
|
|
141325
|
+
format: "uuid"
|
|
141324
141326
|
});
|
|
141325
141327
|
var PaginationSchema = t.Object({
|
|
141326
141328
|
pagination: t.Object({
|
|
@@ -143405,6 +143407,13 @@ var TechdocVehicleKindLogic;
|
|
|
143405
143407
|
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
143406
143408
|
return getPaginationContent(result, query.pagination.size);
|
|
143407
143409
|
};
|
|
143410
|
+
TechdocVehicleKindLogic.update = async (id, body) => {
|
|
143411
|
+
const [result] = await db_default.update(techdocVehicleKindTable).set(body).where(eq(techdocVehicleKindTable.id, id)).returning();
|
|
143412
|
+
if (!result) {
|
|
143413
|
+
return status("Not Found", "Vehicle kind not found");
|
|
143414
|
+
}
|
|
143415
|
+
return result;
|
|
143416
|
+
};
|
|
143408
143417
|
TechdocVehicleKindLogic.findOrCreate = async (body, tdb = db_default) => {
|
|
143409
143418
|
const cacheKey = `techdoc_vehicle_kind:${body.vehicleKindEnum}:${body.parentId ?? ""}:${body.name}`;
|
|
143410
143419
|
const cached = await redis_client_default.get(cacheKey);
|
|
@@ -144030,7 +144039,8 @@ var CrmVehicleLogic;
|
|
|
144030
144039
|
"Content-Type": "text/xml",
|
|
144031
144040
|
SOAPAction: "urn:vrs#getVehicleDataByPlateNo"
|
|
144032
144041
|
},
|
|
144033
|
-
retry: 3
|
|
144042
|
+
retry: 3,
|
|
144043
|
+
stringifyJson: (data) => String(data)
|
|
144034
144044
|
}).text();
|
|
144035
144045
|
const parser = new XMLParser;
|
|
144036
144046
|
const parsed = parser.parse(res);
|
|
@@ -145128,6 +145138,9 @@ var CrmCpOrderLogic;
|
|
|
145128
145138
|
if ("code" in vehicle) {
|
|
145129
145139
|
return vehicle;
|
|
145130
145140
|
}
|
|
145141
|
+
if (vehicle.customerId && !customerId) {
|
|
145142
|
+
customerId = vehicle.customerId;
|
|
145143
|
+
}
|
|
145131
145144
|
const orderId = await getOrderId(user2);
|
|
145132
145145
|
const [result] = await db2.insert(crmCpOrderTable).values({
|
|
145133
145146
|
companyId: user2.companyId,
|
|
@@ -146033,6 +146046,8 @@ var TechdocVehicleKindModel;
|
|
|
146033
146046
|
t.Partial(t.Pick(selectSchema, ["vehicleKindEnum", "parentId", "name"])),
|
|
146034
146047
|
PaginationSchema
|
|
146035
146048
|
]);
|
|
146049
|
+
const updateSchema = createUpdateSchema(techdocVehicleKindTable);
|
|
146050
|
+
TechdocVehicleKindModel.update = OmitBaseSchema(updateSchema);
|
|
146036
146051
|
})(TechdocVehicleKindModel ||= {});
|
|
146037
146052
|
var model_default14 = TechdocVehicleKindModel;
|
|
146038
146053
|
|
|
@@ -146044,6 +146059,10 @@ var vehicleKindRoutes = new Elysia({
|
|
|
146044
146059
|
auth: true
|
|
146045
146060
|
}).get("/", async ({ query }) => logic_default5.select(query), {
|
|
146046
146061
|
query: model_default14.select
|
|
146062
|
+
}).put("/:id", async ({ body, params: { id } }) => logic_default5.update(id, body), {
|
|
146063
|
+
body: model_default14.update,
|
|
146064
|
+
params: IdSchema,
|
|
146065
|
+
userKind: "ADMIN"
|
|
146047
146066
|
});
|
|
146048
146067
|
var vehicleKind_default = vehicleKindRoutes;
|
|
146049
146068
|
|
|
@@ -146579,10 +146598,44 @@ var warehouseSchemaRoutes = new Elysia({
|
|
|
146579
146598
|
}).use(product_default2).use(warehouse_default).use(item_default3);
|
|
146580
146599
|
var warehouse_default2 = warehouseSchemaRoutes;
|
|
146581
146600
|
|
|
146601
|
+
// src/routes/image/index.ts
|
|
146602
|
+
var {S3Client } = globalThis.Bun;
|
|
146603
|
+
var s3Client = new S3Client({
|
|
146604
|
+
accessKeyId: env_default.AWS_ACCESS_KEY,
|
|
146605
|
+
secretAccessKey: env_default.AWS_SECRET_KEY,
|
|
146606
|
+
bucket: "autosync-s3",
|
|
146607
|
+
region: "ap-southeast-1"
|
|
146608
|
+
});
|
|
146609
|
+
var imageRoutes = new Elysia({
|
|
146610
|
+
prefix: "/image",
|
|
146611
|
+
tags: ["Image"]
|
|
146612
|
+
}).use(better_auth_default).post("/", async ({ body }) => {
|
|
146613
|
+
await s3Client.write(`/v2/${body.folder}/${body.image.name}`, body.image);
|
|
146614
|
+
const path = new URLSearchParams;
|
|
146615
|
+
path.set("folder", body.folder);
|
|
146616
|
+
path.set("name", body.image.name);
|
|
146617
|
+
return {
|
|
146618
|
+
path: path.toString()
|
|
146619
|
+
};
|
|
146620
|
+
}, {
|
|
146621
|
+
body: t.Object({
|
|
146622
|
+
image: t.File({
|
|
146623
|
+
type: "image/*"
|
|
146624
|
+
}),
|
|
146625
|
+
folder: t.String()
|
|
146626
|
+
}),
|
|
146627
|
+
auth: true
|
|
146628
|
+
}).get("/", ({ query, redirect: redirect2 }) => redirect2(`https://d26gvv87iagx1d.cloudfront.net/${query.folder}/${query.name}`), {
|
|
146629
|
+
query: t.Object({
|
|
146630
|
+
folder: t.String(),
|
|
146631
|
+
name: t.String()
|
|
146632
|
+
})
|
|
146633
|
+
});
|
|
146634
|
+
|
|
146582
146635
|
// src/routes/index.ts
|
|
146583
146636
|
var router2 = new Elysia({
|
|
146584
146637
|
prefix: "/api"
|
|
146585
|
-
}).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default);
|
|
146638
|
+
}).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default);
|
|
146586
146639
|
var routes_default = router2;
|
|
146587
146640
|
|
|
146588
146641
|
// src/index.ts
|