autosync_backend2 1.2.92 → 1.2.97
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 +11 -9
- package/dist/index.js +72 -34
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -683,16 +683,16 @@ export declare const app: Elysia<"", {
|
|
|
683
683
|
type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
|
|
684
684
|
oldId?: number | null | undefined;
|
|
685
685
|
description?: string | null | undefined;
|
|
686
|
+
oen?: string | null | undefined;
|
|
686
687
|
productId?: string | null | undefined;
|
|
687
688
|
barCode?: string | null | undefined;
|
|
688
|
-
oen?: string | null | undefined;
|
|
689
689
|
alias?: string | null | undefined;
|
|
690
690
|
quantityUnit?: number | undefined;
|
|
691
691
|
name: string;
|
|
692
|
+
partNumber: string;
|
|
692
693
|
supplierId: string;
|
|
693
694
|
priceSell: number;
|
|
694
695
|
priceBuy: number;
|
|
695
|
-
partNumber: string;
|
|
696
696
|
};
|
|
697
697
|
params: {};
|
|
698
698
|
query: unknown;
|
|
@@ -708,13 +708,13 @@ export declare const app: Elysia<"", {
|
|
|
708
708
|
deletedAt: string | null;
|
|
709
709
|
oldId: number | null;
|
|
710
710
|
description: string | null;
|
|
711
|
+
partNumber: string;
|
|
712
|
+
oen: string | null;
|
|
711
713
|
supplierId: string;
|
|
712
714
|
productId: string | null;
|
|
713
715
|
priceSell: number;
|
|
714
716
|
priceBuy: number;
|
|
715
717
|
barCode: string | null;
|
|
716
|
-
oen: string | null;
|
|
717
|
-
partNumber: string;
|
|
718
718
|
alias: string | null;
|
|
719
719
|
quantityUnit: number;
|
|
720
720
|
};
|
|
@@ -739,16 +739,16 @@ export declare const app: Elysia<"", {
|
|
|
739
739
|
type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
|
|
740
740
|
oldId?: number | null | undefined;
|
|
741
741
|
description?: string | null | undefined;
|
|
742
|
+
oen?: string | null | undefined;
|
|
742
743
|
productId?: string | null | undefined;
|
|
743
744
|
barCode?: string | null | undefined;
|
|
744
|
-
oen?: string | null | undefined;
|
|
745
745
|
alias?: string | null | undefined;
|
|
746
746
|
quantityUnit?: number | undefined;
|
|
747
747
|
name: string;
|
|
748
|
+
partNumber: string;
|
|
748
749
|
supplierId: string;
|
|
749
750
|
priceSell: number;
|
|
750
751
|
priceBuy: number;
|
|
751
|
-
partNumber: string;
|
|
752
752
|
}[];
|
|
753
753
|
params: {};
|
|
754
754
|
query: unknown;
|
|
@@ -816,13 +816,13 @@ export declare const app: Elysia<"", {
|
|
|
816
816
|
companyId?: string | undefined;
|
|
817
817
|
oldId?: number | null | undefined;
|
|
818
818
|
description?: string | null | undefined;
|
|
819
|
+
partNumber?: string | undefined;
|
|
820
|
+
oen?: string | null | undefined;
|
|
819
821
|
supplierId?: string | undefined;
|
|
820
822
|
productId?: string | null | undefined;
|
|
821
823
|
priceSell?: number | undefined;
|
|
822
824
|
priceBuy?: number | undefined;
|
|
823
825
|
barCode?: string | null | undefined;
|
|
824
|
-
oen?: string | null | undefined;
|
|
825
|
-
partNumber?: string | undefined;
|
|
826
826
|
alias?: string | null | undefined;
|
|
827
827
|
quantityUnit?: number | undefined;
|
|
828
828
|
};
|
|
@@ -3206,6 +3206,7 @@ export declare const app: Elysia<"", {
|
|
|
3206
3206
|
generate: {
|
|
3207
3207
|
post: {
|
|
3208
3208
|
body: {
|
|
3209
|
+
note?: string | undefined;
|
|
3209
3210
|
carCount?: number | undefined;
|
|
3210
3211
|
companyId: string;
|
|
3211
3212
|
billingPlanId: string;
|
|
@@ -11845,7 +11846,8 @@ export declare const app: Elysia<"", {
|
|
|
11845
11846
|
body: unknown;
|
|
11846
11847
|
params: {};
|
|
11847
11848
|
query: {
|
|
11848
|
-
workOrderId?: string |
|
|
11849
|
+
workOrderId?: string | undefined;
|
|
11850
|
+
isWorkOrderId?: boolean | undefined;
|
|
11849
11851
|
pagination: {
|
|
11850
11852
|
size: number;
|
|
11851
11853
|
page: number;
|
package/dist/index.js
CHANGED
|
@@ -197574,7 +197574,7 @@ var require_umd = __commonJS((exports, module) => {
|
|
|
197574
197574
|
other = fromValue(other);
|
|
197575
197575
|
return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
|
|
197576
197576
|
};
|
|
197577
|
-
LongPrototype.or = function
|
|
197577
|
+
LongPrototype.or = function or3(other) {
|
|
197578
197578
|
if (!isLong(other))
|
|
197579
197579
|
other = fromValue(other);
|
|
197580
197580
|
return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
|
|
@@ -277517,7 +277517,12 @@ var techdocSupplierTable = techdocSchema.table("supplier", {
|
|
|
277517
277517
|
});
|
|
277518
277518
|
var techdocProductTable = techdocSchema.table("product", {
|
|
277519
277519
|
...base_schema_helper_default,
|
|
277520
|
-
name: varchar().notNull()
|
|
277520
|
+
name: varchar().notNull(),
|
|
277521
|
+
partNumber: varchar().notNull(),
|
|
277522
|
+
oen: varchar(),
|
|
277523
|
+
description: text(),
|
|
277524
|
+
supplierId: uuid5().notNull(),
|
|
277525
|
+
pictureList: varchar().array().notNull().default([])
|
|
277521
277526
|
});
|
|
277522
277527
|
var techdocProductCategoryTable = techdocSchema.table("product_category", {
|
|
277523
277528
|
...base_schema_helper_default,
|
|
@@ -278758,7 +278763,8 @@ var CompanyInvoiceLogic;
|
|
|
278758
278763
|
carCount,
|
|
278759
278764
|
status: "PENDING",
|
|
278760
278765
|
issuedAt: issuedAt.toISOString(),
|
|
278761
|
-
dueAt: dueAt.toISOString()
|
|
278766
|
+
dueAt: dueAt.toISOString(),
|
|
278767
|
+
note: body.note
|
|
278762
278768
|
}).returning();
|
|
278763
278769
|
return invoice;
|
|
278764
278770
|
};
|
|
@@ -278817,7 +278823,8 @@ var CompanyInvoiceModel;
|
|
|
278817
278823
|
companyId: t.String({ format: "uuid" }),
|
|
278818
278824
|
billingPlanId: t.String({ format: "uuid" }),
|
|
278819
278825
|
periodStart: t.String({ format: "date" }),
|
|
278820
|
-
carCount: t.Optional(t.Integer({ minimum: 0 }))
|
|
278826
|
+
carCount: t.Optional(t.Integer({ minimum: 0 })),
|
|
278827
|
+
note: t.Optional(t.String())
|
|
278821
278828
|
});
|
|
278822
278829
|
})(CompanyInvoiceModel ||= {});
|
|
278823
278830
|
var model_default6 = CompanyInvoiceModel;
|
|
@@ -282386,25 +282393,26 @@ class Pocket {
|
|
|
282386
282393
|
return response;
|
|
282387
282394
|
}
|
|
282388
282395
|
async checkLocalToken() {
|
|
282396
|
+
console.log("[Pocket] Checking local token...");
|
|
282389
282397
|
if (this.token) {
|
|
282398
|
+
console.log("[Pocket] Token is present in instance.");
|
|
282390
282399
|
return;
|
|
282391
282400
|
}
|
|
282392
282401
|
const raw = await redis_client_default.get(CACHE_KEY);
|
|
282402
|
+
console.log("[Pocket] Fetched raw token from redis:", raw);
|
|
282393
282403
|
const cached4 = raw ? JSON.parse(raw) : null;
|
|
282394
|
-
const isExpired = cached4 ? Date.now() >= cached4.expires_in * 1000
|
|
282404
|
+
const isExpired = cached4 ? Date.now() >= cached4.expires_in * 1000 : true;
|
|
282405
|
+
console.log(`[Pocket] Token cached: ${!!cached4}, expired: ${isExpired}`);
|
|
282395
282406
|
if (cached4 && !isExpired) {
|
|
282396
282407
|
this.token = cached4;
|
|
282408
|
+
console.log("[Pocket] Using valid cached token.");
|
|
282397
282409
|
return;
|
|
282398
282410
|
}
|
|
282399
|
-
|
|
282400
|
-
const refreshed = await this.getTokenByRefresh(cached4.refresh_token);
|
|
282401
|
-
this.token = refreshed;
|
|
282402
|
-
await redis_client_default.set(CACHE_KEY, JSON.stringify(refreshed));
|
|
282403
|
-
return;
|
|
282404
|
-
}
|
|
282411
|
+
console.log("[Pocket] No valid token available, requesting new token.");
|
|
282405
282412
|
const newToken = await this.getToken();
|
|
282406
282413
|
this.token = newToken;
|
|
282407
282414
|
await redis_client_default.set(CACHE_KEY, JSON.stringify(newToken));
|
|
282415
|
+
console.log("[Pocket] Obtained new token and updated cache.");
|
|
282408
282416
|
}
|
|
282409
282417
|
async getToken() {
|
|
282410
282418
|
const response = await this.makeOAuthRequest("token", {
|
|
@@ -282435,18 +282443,30 @@ class Pocket {
|
|
|
282435
282443
|
return response;
|
|
282436
282444
|
}
|
|
282437
282445
|
async createInvoice(input) {
|
|
282446
|
+
console.log("[Pocket] Creating invoice with input:", input);
|
|
282438
282447
|
await this.checkLocalToken();
|
|
282439
|
-
|
|
282440
|
-
|
|
282441
|
-
|
|
282442
|
-
|
|
282443
|
-
|
|
282444
|
-
|
|
282445
|
-
|
|
282446
|
-
|
|
282447
|
-
|
|
282448
|
-
|
|
282449
|
-
|
|
282448
|
+
console.log("[Pocket] Sending request to generate invoice:", {
|
|
282449
|
+
url: this.getMerchantUrl("v2/invoicing/generate-invoice"),
|
|
282450
|
+
token: this.token?.access_token ? "[hidden]" : undefined,
|
|
282451
|
+
terminalId: this.terminalId
|
|
282452
|
+
});
|
|
282453
|
+
try {
|
|
282454
|
+
const response = await distribution_default.post(this.getMerchantUrl("v2/invoicing/generate-invoice"), {
|
|
282455
|
+
headers: {
|
|
282456
|
+
Authorization: `Bearer ${this.token?.access_token}`
|
|
282457
|
+
},
|
|
282458
|
+
json: {
|
|
282459
|
+
...input,
|
|
282460
|
+
terminalId: this.terminalId,
|
|
282461
|
+
channel: "pos"
|
|
282462
|
+
}
|
|
282463
|
+
}).json();
|
|
282464
|
+
console.log("[Pocket] Generated invoice response:", response);
|
|
282465
|
+
return response;
|
|
282466
|
+
} catch (error3) {
|
|
282467
|
+
console.error("[Pocket] Error generating invoice:", error3);
|
|
282468
|
+
throw error3;
|
|
282469
|
+
}
|
|
282450
282470
|
}
|
|
282451
282471
|
async checkInvoice(orderNumber) {
|
|
282452
282472
|
await this.checkLocalToken();
|
|
@@ -282464,7 +282484,7 @@ class Pocket {
|
|
|
282464
282484
|
}
|
|
282465
282485
|
|
|
282466
282486
|
// src/routes/crm/cpOrder/payment/gateways/index.ts
|
|
282467
|
-
var CALLBACK_URL = env_default.NODE_ENV === "production" ? "https://
|
|
282487
|
+
var CALLBACK_URL = env_default.NODE_ENV === "production" ? "https://api.autosync.mn/api/crm/cp-order/payment" : "http://202.70.40.82:3000/api/crm/cp-order/payment";
|
|
282468
282488
|
|
|
282469
282489
|
class PaymentGateway {
|
|
282470
282490
|
token = undefined;
|
|
@@ -283228,6 +283248,19 @@ var CrmCpOrderPaymentLogic;
|
|
|
283228
283248
|
return status("Internal Server Error", "\u0421\u0435\u0440\u0432\u0435\u0440 \u0430\u043B\u0434\u0430\u0430 \u0433\u0430\u0440\u043B\u0430\u0430");
|
|
283229
283249
|
}
|
|
283230
283250
|
};
|
|
283251
|
+
CrmCpOrderPaymentLogic.getPocketData = async (query) => {
|
|
283252
|
+
const filter = and(eq(crmCpOrderTable.companyId, query.companyId).if(query.companyId), eq(crmCpOrderPaymentTable.state, "PAID"), eq(sql3`DATE(${crmCpOrderPaymentTable.createdAt})`, query.date).if(query.date), eq(crmCpOrderPaymentTable.paymentChannel, "POCKET"));
|
|
283253
|
+
const [payments, total] = await Promise.all([
|
|
283254
|
+
db_default.select().from(crmCpOrderPaymentTable).innerJoin(crmCpOrderTable, eq(crmCpOrderTable.id, crmCpOrderPaymentTable.cpOrderId)).where(filter),
|
|
283255
|
+
db_default.select({
|
|
283256
|
+
total: sum(crmCpOrderPaymentTable.amount)
|
|
283257
|
+
}).from(crmCpOrderPaymentTable).innerJoin(crmCpOrderTable, eq(crmCpOrderTable.id, crmCpOrderPaymentTable.cpOrderId)).where(filter)
|
|
283258
|
+
]);
|
|
283259
|
+
return {
|
|
283260
|
+
payments,
|
|
283261
|
+
totalAmount: total[0]?.total ?? 0
|
|
283262
|
+
};
|
|
283263
|
+
};
|
|
283231
283264
|
})(CrmCpOrderPaymentLogic ||= {});
|
|
283232
283265
|
var getPaymentInfo = async (type, user2) => {
|
|
283233
283266
|
const cacheKey = `crm_payment:${user2.companyId}:${type}:${user2.branchId ?? "null"}`;
|
|
@@ -284037,6 +284070,10 @@ var CrmCpOrderPaymentModel;
|
|
|
284037
284070
|
CrmCpOrderPaymentModel.wsBody = t.Object({
|
|
284038
284071
|
state: t.UnionEnum(["PENDING", "PAID", "CANCELED"])
|
|
284039
284072
|
});
|
|
284073
|
+
CrmCpOrderPaymentModel.getPocketData = t.Partial(t.Object({
|
|
284074
|
+
companyId: t.String({ format: "uuid" }),
|
|
284075
|
+
date: t.String({ format: "date" })
|
|
284076
|
+
}));
|
|
284040
284077
|
})(CrmCpOrderPaymentModel ||= {});
|
|
284041
284078
|
var model_default13 = CrmCpOrderPaymentModel;
|
|
284042
284079
|
|
|
@@ -285579,12 +285616,12 @@ var model_default24 = InspectionFieldGroupModel;
|
|
|
285579
285616
|
var fieldGroupRoutes = new Elysia({
|
|
285580
285617
|
prefix: "/field-group",
|
|
285581
285618
|
tags: ["InspectionFieldGroup"]
|
|
285582
|
-
}).use(better_auth_default).
|
|
285583
|
-
userKind: "ADMIN"
|
|
285584
|
-
}).get("/", async ({ query }) => logic_default26.select(query), {
|
|
285619
|
+
}).use(better_auth_default).get("/", async ({ query }) => logic_default26.select(query), {
|
|
285585
285620
|
query: model_default24.select,
|
|
285586
285621
|
userKind: undefined,
|
|
285587
285622
|
auth: true
|
|
285623
|
+
}).guard({
|
|
285624
|
+
userKind: "ADMIN"
|
|
285588
285625
|
}).post("/", async ({ body }) => logic_default26.create(body), {
|
|
285589
285626
|
body: model_default24.create
|
|
285590
285627
|
}).guard({
|
|
@@ -285690,7 +285727,7 @@ var fieldResult_default = fieldResultRoutes;
|
|
|
285690
285727
|
var InspectionLogic;
|
|
285691
285728
|
((InspectionLogic) => {
|
|
285692
285729
|
InspectionLogic.select = async (query, user2) => {
|
|
285693
|
-
const filter = and(eq(inspectionTable.machineId, query.machineId).if(query.machineId), eq(inspectionTable.templateId, query.templateId).if(query.templateId), eq(inspectionTable.state, query.state).if(query.state), eq(inspectionTable.stateResult, query.stateResult).if(query.stateResult), gte(inspectionTable.createdAt, query.startDate).if(query.startDate), lte(inspectionTable.createdAt, query.endDate).if(query.endDate), eq(inspectionTable.id, query.id).if(query.id),
|
|
285730
|
+
const filter = and(eq(inspectionTable.machineId, query.machineId).if(query.machineId), eq(inspectionTable.templateId, query.templateId).if(query.templateId), eq(inspectionTable.state, query.state).if(query.state), eq(inspectionTable.stateResult, query.stateResult).if(query.stateResult), gte(inspectionTable.createdAt, query.startDate).if(query.startDate), lte(inspectionTable.createdAt, query.endDate).if(query.endDate), eq(inspectionTable.id, query.id).if(query.id), eq(companyMachineTable.companyId, user2.companyId));
|
|
285694
285731
|
const baseQuery = db_default.select({
|
|
285695
285732
|
inspection: inspectionTable,
|
|
285696
285733
|
machine: companyMachineTable,
|
|
@@ -286516,8 +286553,8 @@ var pm_default = pmRoutes;
|
|
|
286516
286553
|
// src/routes/fleet/work-order/logic.ts
|
|
286517
286554
|
var WorkOrderLogic;
|
|
286518
286555
|
((WorkOrderLogic) => {
|
|
286519
|
-
WorkOrderLogic.select = async (query) => {
|
|
286520
|
-
const filter = softDeletedFilter(workOrderTable);
|
|
286556
|
+
WorkOrderLogic.select = async (query, user2) => {
|
|
286557
|
+
const filter = and(softDeletedFilter(workOrderTable), eq(companyMachineTable.companyId, user2.companyId));
|
|
286521
286558
|
const baseQuery = db_default.select({
|
|
286522
286559
|
wo: workOrderTable,
|
|
286523
286560
|
machine: companyMachineTable,
|
|
@@ -286555,8 +286592,8 @@ var model_default37 = WorkOrderModel;
|
|
|
286555
286592
|
// src/routes/fleet/work-order/task/logic.ts
|
|
286556
286593
|
var WorkOrderTaskLogic;
|
|
286557
286594
|
((WorkOrderTaskLogic) => {
|
|
286558
|
-
WorkOrderTaskLogic.select = async (query) => {
|
|
286559
|
-
const filter = and(softDeletedFilter(workOrderTaskTable), eq(workOrderTaskTable.workOrderId, query.workOrderId).if(query.workOrderId), isNull2(workOrderTaskTable.workOrderId).if(query.workOrderId ===
|
|
286595
|
+
WorkOrderTaskLogic.select = async (query, user2) => {
|
|
286596
|
+
const filter = and(softDeletedFilter(workOrderTaskTable), eq(workOrderTaskTable.workOrderId, query.workOrderId).if(query.workOrderId), isNull2(workOrderTaskTable.workOrderId).if(query.isWorkOrderId === false), isNotNull(workOrderTaskTable.workOrderId).if(query.isWorkOrderId === true), eq(companyMachineTable.companyId, user2.companyId));
|
|
286560
286597
|
const companyServiceKind = alias(companyServiceKindTable, "companyServiceKind");
|
|
286561
286598
|
const baseQuery = db_default.select({
|
|
286562
286599
|
task: workOrderTaskTable,
|
|
@@ -286598,7 +286635,8 @@ var WorkOrderTaskModel;
|
|
|
286598
286635
|
WorkOrderTaskModel.select = t.Composite([
|
|
286599
286636
|
PaginationSchema,
|
|
286600
286637
|
t.Partial(t.Object({
|
|
286601
|
-
workOrderId: t.
|
|
286638
|
+
workOrderId: t.String({ format: "uuid" }),
|
|
286639
|
+
isWorkOrderId: t.Boolean()
|
|
286602
286640
|
}))
|
|
286603
286641
|
]);
|
|
286604
286642
|
})(WorkOrderTaskModel ||= {});
|
|
@@ -286608,7 +286646,7 @@ var model_default38 = WorkOrderTaskModel;
|
|
|
286608
286646
|
var workOrderTaskRoutes = new Elysia({
|
|
286609
286647
|
prefix: "/task",
|
|
286610
286648
|
tags: ["WorkOrderTask"]
|
|
286611
|
-
}).use(better_auth_default).guard({ auth: true }).get("/", async ({ query }) => logic_default40.select(query), {
|
|
286649
|
+
}).use(better_auth_default).guard({ auth: true }).get("/", async ({ query, user: user2 }) => logic_default40.select(query, user2), {
|
|
286612
286650
|
query: model_default38.select
|
|
286613
286651
|
}).post("/", async ({ body }) => logic_default40.create(body), {
|
|
286614
286652
|
body: model_default38.create
|
|
@@ -286623,7 +286661,7 @@ var task_default = workOrderTaskRoutes;
|
|
|
286623
286661
|
var workOrderRoutes = new Elysia({
|
|
286624
286662
|
prefix: "/work-order",
|
|
286625
286663
|
tags: ["WorkOrder"]
|
|
286626
|
-
}).use(better_auth_default).use(task_default).guard({ auth: true }).get("/", async ({ query }) => logic_default39.select(query), {
|
|
286664
|
+
}).use(better_auth_default).use(task_default).guard({ auth: true }).get("/", async ({ query, user: user2 }) => logic_default39.select(query, user2), {
|
|
286627
286665
|
query: model_default37.select
|
|
286628
286666
|
}).post("/", async ({ body }) => logic_default39.create(body), {
|
|
286629
286667
|
body: model_default37.create
|