autosync_backend2 1.1.61 → 1.1.63
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 +40 -1
- package/dist/index.js +37 -22
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -5135,6 +5135,45 @@ export declare const app: Elysia<"", {
|
|
5135
5135
|
};
|
5136
5136
|
};
|
5137
5137
|
};
|
5138
|
+
} & {
|
5139
|
+
customer: {
|
5140
|
+
post: {
|
5141
|
+
body: {
|
5142
|
+
email?: string | null | undefined;
|
5143
|
+
companyId?: string | null | undefined;
|
5144
|
+
firstname?: string | null | undefined;
|
5145
|
+
lastname?: string | null | undefined;
|
5146
|
+
regNum?: string | null | undefined;
|
5147
|
+
phoneNumber: string;
|
5148
|
+
};
|
5149
|
+
params: {};
|
5150
|
+
query: unknown;
|
5151
|
+
headers: unknown;
|
5152
|
+
response: {
|
5153
|
+
200: {
|
5154
|
+
id: string;
|
5155
|
+
email: string | null;
|
5156
|
+
createdAt: string;
|
5157
|
+
updatedAt: string;
|
5158
|
+
companyId: string | null;
|
5159
|
+
deletedAt: string | null;
|
5160
|
+
firstname: string | null;
|
5161
|
+
lastname: string | null;
|
5162
|
+
phoneNumber: string;
|
5163
|
+
regNum: string | null;
|
5164
|
+
};
|
5165
|
+
422: {
|
5166
|
+
type: "validation";
|
5167
|
+
on: string;
|
5168
|
+
summary?: string;
|
5169
|
+
message?: string;
|
5170
|
+
found?: unknown;
|
5171
|
+
property?: string;
|
5172
|
+
expected?: string;
|
5173
|
+
};
|
5174
|
+
};
|
5175
|
+
};
|
5176
|
+
};
|
5138
5177
|
} & {
|
5139
5178
|
customer: {
|
5140
5179
|
":id": {
|
@@ -5705,7 +5744,7 @@ export declare const app: Elysia<"", {
|
|
5705
5744
|
query: {
|
5706
5745
|
search?: string | undefined;
|
5707
5746
|
licensePlate?: string | undefined;
|
5708
|
-
status?:
|
5747
|
+
status?: "CREATED" | "APPROVED" | "CANCELLED" | undefined;
|
5709
5748
|
pagination: {
|
5710
5749
|
size: number;
|
5711
5750
|
page: number;
|
package/dist/index.js
CHANGED
@@ -102848,7 +102848,7 @@ var mirror = (schema, property, instruction) => {
|
|
102848
102848
|
if (v += `if(${key}===undefined`, instruction.unionKeys[key])
|
102849
102849
|
v += `||x${prop}===undefined`;
|
102850
102850
|
let shouldQuestion = prop.charCodeAt(0) !== 63 && schema.type !== "array";
|
102851
|
-
v += `)delete x${shouldQuestion ? "?" : ""}${prop}
|
102851
|
+
v += `)delete x${shouldQuestion ? prop.charCodeAt(0) === 91 ? "?." : "?" : ""}${prop}
|
102852
102852
|
`;
|
102853
102853
|
}
|
102854
102854
|
return `${v}return x`;
|
@@ -103309,9 +103309,9 @@ var getSchemaValidator = (s, { models = {}, dynamic = false, modules, normalize
|
|
103309
103309
|
try {
|
103310
103310
|
compiled.Clean = createMirror(schema, { TypeCompiler, sanitize: sanitize2?.(), modules });
|
103311
103311
|
} catch (error2) {
|
103312
|
-
console.warn("Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues"), console.
|
103312
|
+
console.warn("Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues"), console.dir(schema, { depth: null }), compiled.Clean = createCleaner(schema);
|
103313
103313
|
}
|
103314
|
-
else
|
103314
|
+
else if (normalize === "typebox")
|
103315
103315
|
compiled.Clean = createCleaner(schema);
|
103316
103316
|
return compiled.parse = (v) => {
|
103317
103317
|
try {
|
@@ -103427,8 +103427,8 @@ var coercePrimitiveRoot = () => {
|
|
103427
103427
|
_coercePrimitiveRoot = [{ from: t.Number(), to: (options) => t.Numeric(options), rootOnly: true }, { from: t.Boolean(), to: (options) => t.BooleanString(options), rootOnly: true }];
|
103428
103428
|
return _coercePrimitiveRoot;
|
103429
103429
|
};
|
103430
|
-
var getCookieValidator = ({ validator, modules, defaultConfig = {}, config, dynamic, models, validators, sanitize: sanitize2 }) => {
|
103431
|
-
let cookieValidator = getSchemaValidator(validator, { modules, dynamic, models, additionalProperties: true, coerce: true, additionalCoerce: stringToStructureCoercions(), validators, sanitize: sanitize2 });
|
103430
|
+
var getCookieValidator = ({ validator, modules, defaultConfig = {}, config, dynamic, normalize = false, models, validators, sanitize: sanitize2 }) => {
|
103431
|
+
let cookieValidator = getSchemaValidator(validator, { modules, dynamic, models, normalize, additionalProperties: true, coerce: true, additionalCoerce: stringToStructureCoercions(), validators, sanitize: sanitize2 });
|
103432
103432
|
if (cookieValidator)
|
103433
103433
|
cookieValidator.config = mergeCookie(cookieValidator.config, config);
|
103434
103434
|
else
|
@@ -104073,7 +104073,7 @@ c=transformed}`;
|
|
104073
104073
|
}
|
104074
104074
|
}
|
104075
104075
|
if (validator.cookie) {
|
104076
|
-
let cookieValidator = getCookieValidator({ modules: app.definitions.typebox, validator: validator.cookie, defaultConfig: app.config.cookie, dynamic: !!app.config.aot, config: validator.cookie?.config ?? {}, models: app.definitions.type });
|
104076
|
+
let cookieValidator = getCookieValidator({ modules: app.definitions.typebox, validator: validator.cookie, defaultConfig: app.config.cookie, dynamic: !!app.config.aot, config: validator.cookie?.config ?? {}, normalize: app.config.normalize, models: app.definitions.type });
|
104077
104077
|
if (fnLiteral += `const cookieValue={}
|
104078
104078
|
for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
|
104079
104079
|
`, cookieValidator.hasDefault)
|
@@ -104371,7 +104371,7 @@ var composeGeneralHandler = (app) => {
|
|
104371
104371
|
`;
|
104372
104372
|
let afterResponse = `c.error=notFound
|
104373
104373
|
`;
|
104374
|
-
if (app.event.afterResponse?.length) {
|
104374
|
+
if (app.event.afterResponse?.length && !app.event.error) {
|
104375
104375
|
let prefix = app.event.afterResponse.some(isAsync) ? "async" : "";
|
104376
104376
|
afterResponse += `
|
104377
104377
|
setImmediate(${prefix}()=>{`;
|
@@ -104499,8 +104499,7 @@ error.message=error.response}`, adapter.declare)
|
|
104499
104499
|
`;
|
104500
104500
|
if (fnLiteral += "if(skipGlobal!==true){", hasReturn(handler)) {
|
104501
104501
|
fnLiteral += `_r=${response}
|
104502
|
-
if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${adapter.mapResponseContext})
|
104503
|
-
if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
|
104502
|
+
if(_r!==undefined){if(_r instanceof Response){` + afterResponse() + `return mapResponse(_r,set${adapter.mapResponseContext})}if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
|
104504
104503
|
error.message = error.response}if(set.status===200||!set.status)set.status=error.status
|
104505
104504
|
`;
|
104506
104505
|
let mapResponseReporter2 = report("mapResponse", { total: hooks.mapResponse?.length, name: "context" });
|
@@ -104510,7 +104509,7 @@ error.message = error.response}if(set.status===200||!set.status)set.status=error
|
|
104510
104509
|
fnLiteral += `context.response=_r_r=${isAsyncName(mapResponse3) ? "await " : ""}onMapResponse[${i22}](context)
|
104511
104510
|
`, endUnit();
|
104512
104511
|
}
|
104513
|
-
mapResponseReporter2.resolve(), fnLiteral += `return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`;
|
104512
|
+
mapResponseReporter2.resolve(), fnLiteral += afterResponse() + `return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`;
|
104514
104513
|
} else
|
104515
104514
|
fnLiteral += response;
|
104516
104515
|
fnLiteral += "}";
|
@@ -105462,7 +105461,7 @@ class Elysia {
|
|
105462
105461
|
let instanceValidator = this.validator.getCandidate(), cloned = { body: localHook?.body ?? instanceValidator?.body, headers: localHook?.headers ?? instanceValidator?.headers, params: localHook?.params ?? instanceValidator?.params, query: localHook?.query ?? instanceValidator?.query, cookie: localHook?.cookie ?? instanceValidator?.cookie, response: localHook?.response ?? instanceValidator?.response }, shouldPrecompile = this.config.precompile === true || typeof this.config.precompile === "object" && this.config.precompile.compose === true, createValidator = () => {
|
105463
105462
|
let models = this.definitions.type, dynamic = !this.config.aot, normalize = this.config.normalize, modules = this.definitions.typebox, sanitize2 = () => this.config.sanitize, cookieValidator = () => {
|
105464
105463
|
if (cloned.cookie || standaloneValidators.find((x2) => x2.cookie))
|
105465
|
-
return getCookieValidator({ modules, validator: cloned.cookie, defaultConfig: this.config.cookie, config: cloned.cookie?.config ?? {}, dynamic, models, validators: standaloneValidators.map((x2) => x2.cookie), sanitize: sanitize2 });
|
105464
|
+
return getCookieValidator({ modules, validator: cloned.cookie, defaultConfig: this.config.cookie, normalize, config: cloned.cookie?.config ?? {}, dynamic, models, validators: standaloneValidators.map((x2) => x2.cookie), sanitize: sanitize2 });
|
105466
105465
|
};
|
105467
105466
|
return shouldPrecompile ? { body: getSchemaValidator(cloned.body, { modules, dynamic, models, normalize, additionalCoerce: coercePrimitiveRoot(), validators: standaloneValidators.map((x2) => x2.body), sanitize: sanitize2 }), headers: getSchemaValidator(cloned.headers, { modules, dynamic, models, additionalProperties: true, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.headers), sanitize: sanitize2 }), params: getSchemaValidator(cloned.params, { modules, dynamic, models, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.params), sanitize: sanitize2 }), query: getSchemaValidator(cloned.query, { modules, dynamic, models, normalize, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.query), sanitize: sanitize2 }), cookie: cookieValidator(), response: getResponseSchemaValidator(cloned.response, { modules, dynamic, models, normalize, validators: standaloneValidators.map((x2) => x2.response), sanitize: sanitize2 }) } : { createBody() {
|
105468
105467
|
if (this.body)
|
@@ -105471,15 +105470,15 @@ class Elysia {
|
|
105471
105470
|
}, createHeaders() {
|
105472
105471
|
if (this.headers)
|
105473
105472
|
return this.headers;
|
105474
|
-
return this.headers = getSchemaValidator(cloned.headers, { modules, dynamic, models, additionalProperties: !normalize, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.headers), sanitize: sanitize2 });
|
105473
|
+
return this.headers = getSchemaValidator(cloned.headers, { modules, dynamic, models, normalize, additionalProperties: !normalize, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.headers), sanitize: sanitize2 });
|
105475
105474
|
}, createParams() {
|
105476
105475
|
if (this.params)
|
105477
105476
|
return this.params;
|
105478
|
-
return this.params = getSchemaValidator(cloned.params, { modules, dynamic, models, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.params), sanitize: sanitize2 });
|
105477
|
+
return this.params = getSchemaValidator(cloned.params, { modules, dynamic, models, normalize, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.params), sanitize: sanitize2 });
|
105479
105478
|
}, createQuery() {
|
105480
105479
|
if (this.query)
|
105481
105480
|
return this.query;
|
105482
|
-
return this.query = getSchemaValidator(cloned.query, { modules, dynamic, models, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.query), sanitize: sanitize2 });
|
105481
|
+
return this.query = getSchemaValidator(cloned.query, { modules, dynamic, models, normalize, coerce: true, additionalCoerce: stringToStructureCoercions(), validators: standaloneValidators.map((x2) => x2.query), sanitize: sanitize2 });
|
105483
105482
|
}, createCookie() {
|
105484
105483
|
if (this.cookie)
|
105485
105484
|
return this.cookie;
|
@@ -151971,6 +151970,11 @@ var logic_default5 = CrmCpOrderItemLogic;
|
|
151971
151970
|
// src/routes/crm/customer/logic.ts
|
151972
151971
|
var CrmCustomerLogic;
|
151973
151972
|
((CrmCustomerLogic) => {
|
151973
|
+
CrmCustomerLogic.create = async (body) => {
|
151974
|
+
const [result] = await db_default.insert(crmCustomerTable).values(body).returning();
|
151975
|
+
await redis_client_default.set(`crm_customer:${body.phoneNumber}`, result);
|
151976
|
+
return result;
|
151977
|
+
};
|
151974
151978
|
CrmCustomerLogic.findOrCreate = async (body, tdb = db_default) => {
|
151975
151979
|
const cachedCustomer = await redis_client_default.get(`crm_customer:${body.phoneNumber}`);
|
151976
151980
|
if (cachedCustomer) {
|
@@ -154215,7 +154219,8 @@ var CrmVehicleLogic;
|
|
154215
154219
|
CrmVehicleLogic.create = async (body, user2) => {
|
154216
154220
|
const vehicle = await CrmVehicleLogic.findOrCreate(body);
|
154217
154221
|
await db_default.update(crmVehicleTable).set({
|
154218
|
-
companyId: user2.companyId
|
154222
|
+
companyId: user2.companyId,
|
154223
|
+
deletedAt: null
|
154219
154224
|
});
|
154220
154225
|
return vehicle;
|
154221
154226
|
};
|
@@ -155171,14 +155176,20 @@ var CrmCpOrderLogic;
|
|
155171
155176
|
await db_default.delete(crmCpOrderTable).where(and(eq(crmCpOrderTable.id, id), eq(crmCpOrderTable.companyId, user2.companyId)));
|
155172
155177
|
};
|
155173
155178
|
CrmCpOrderLogic.selectPayments = async (id) => {
|
155174
|
-
const [
|
155175
|
-
|
155176
|
-
|
155177
|
-
|
155179
|
+
const [totalAmounts, packageAmounts, payments, appliedDiscounts] = await Promise.all([
|
155180
|
+
logic_default5.selectAmountTotal(id),
|
155181
|
+
logic_default7.selectAmountTotal(id),
|
155182
|
+
logic_default10.selectByCpOrderId(id),
|
155183
|
+
logic_default11.selectAppliesByCpOrderId(id)
|
155184
|
+
]);
|
155178
155185
|
const totalAppliedDiscount = appliedDiscounts.map((i2) => i2.apply.valueApplied).reduce((a12, b) => a12 + b, 0);
|
155186
|
+
const totalAmount = totalAmounts[0];
|
155187
|
+
const packageAmount = packageAmounts[0];
|
155188
|
+
console.log(totalAmount, packageAmount);
|
155189
|
+
const ta = ((totalAmount?.amount ?? 0) + (packageAmount?.amount ?? 0)) * (totalAmount?.isNoat ? 1.1 : 1);
|
155179
155190
|
return {
|
155180
155191
|
payments,
|
155181
|
-
totalAmount:
|
155192
|
+
totalAmount: ta,
|
155182
155193
|
paidAmount: payments.map((p) => p.state === "PAID" ? p.amount : 0).reduce((a12, b) => a12 + b, 0),
|
155183
155194
|
totalAppliedDiscount,
|
155184
155195
|
discounts: appliedDiscounts
|
@@ -155723,6 +155734,8 @@ var customerRoutes = new Elysia({
|
|
155723
155734
|
tags: ["CrmCustomer"]
|
155724
155735
|
}).use(better_auth_default).guard({ auth: true }).get("/", async ({ query, user: user2 }) => logic_default6.select(query, user2), {
|
155725
155736
|
query: model_default9.select
|
155737
|
+
}).post("/", async ({ body }) => logic_default6.create(body), {
|
155738
|
+
body: model_default9.create
|
155726
155739
|
}).put("/:id", async ({ body, params: { id } }) => logic_default6.update(id, body), {
|
155727
155740
|
body: model_default9.update
|
155728
155741
|
});
|
@@ -155853,7 +155866,7 @@ var CrmInspectionLogic;
|
|
155853
155866
|
((CrmInspectionLogic) => {
|
155854
155867
|
CrmInspectionLogic.getFilter = (query, user2) => {
|
155855
155868
|
const ilikeSearch = `%${query.search}%`;
|
155856
|
-
return and(softDeletedFilter(crmInspectionTable), eq(crmInspectionTable.companyId, user2.companyId), eq(crmInspectionTable.branchId, user2.branchId).if(user2.kind === "CUSTOMER"), or(ilike(crmInspectionTable.licensePlate, ilikeSearch), ilike(crmInspectionTable.description, ilikeSearch))?.if(!!query.search), eq(crmInspectionTable.status, query.status).if(query.status), ilike(crmInspectionTable.licensePlate, `%${query.licensePlate}%`).if(query.licensePlate));
|
155869
|
+
return and(softDeletedFilter(crmInspectionTable), eq(crmInspectionTable.companyId, user2.companyId), eq(crmInspectionTable.branchId, user2.branchId).if(user2.kind === "CUSTOMER"), or(ilike(crmInspectionTable.licensePlate, ilikeSearch), ilike(crmInspectionTable.description, ilikeSearch))?.if(!!query.search), eq(crmInspectionTable.status, query.status ?? "CREATED").if(query.status), ilike(crmInspectionTable.licensePlate, `%${query.licensePlate}%`).if(query.licensePlate));
|
155857
155870
|
};
|
155858
155871
|
CrmInspectionLogic.select = async (query, user2) => {
|
155859
155872
|
const baseQuery = db_default.select({
|
@@ -155987,7 +156000,9 @@ var CrmInspectionModel;
|
|
155987
156000
|
CrmInspectionModel.select = t.Composite([
|
155988
156001
|
t.Partial(t.Object({
|
155989
156002
|
search: t.String(),
|
155990
|
-
status: t.
|
156003
|
+
status: t.UnionEnum(crmInspectionTable.status.enumValues, {
|
156004
|
+
default: undefined
|
156005
|
+
}),
|
155991
156006
|
licensePlate: t.String()
|
155992
156007
|
})),
|
155993
156008
|
PaginationSchema
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "autosync_backend2",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.63",
|
4
4
|
"module": "src/index.ts",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"better-auth": "^1.3.7",
|
31
31
|
"drizzle-orm": "^0.44.4",
|
32
32
|
"drizzle-typebox": "^0.3.3",
|
33
|
-
"elysia": "1.3.
|
33
|
+
"elysia": "1.3.13",
|
34
34
|
"exceljs": "^4.4.0",
|
35
35
|
"fast-xml-parser": "^5.2.5",
|
36
36
|
"generate-password": "^1.7.1",
|