autosync_backend2 1.2.96 → 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 +9 -8
- package/dist/index.js +56 -35
- 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;
|
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();
|
|
@@ -283228,8 +283248,8 @@ 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
|
};
|
|
283231
|
-
CrmCpOrderPaymentLogic.getPocketData = async (
|
|
283232
|
-
const filter = and(eq(crmCpOrderTable.companyId,
|
|
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"));
|
|
283233
283253
|
const [payments, total] = await Promise.all([
|
|
283234
283254
|
db_default.select().from(crmCpOrderPaymentTable).innerJoin(crmCpOrderTable, eq(crmCpOrderTable.id, crmCpOrderPaymentTable.cpOrderId)).where(filter),
|
|
283235
283255
|
db_default.select({
|
|
@@ -284051,7 +284071,8 @@ var CrmCpOrderPaymentModel;
|
|
|
284051
284071
|
state: t.UnionEnum(["PENDING", "PAID", "CANCELED"])
|
|
284052
284072
|
});
|
|
284053
284073
|
CrmCpOrderPaymentModel.getPocketData = t.Partial(t.Object({
|
|
284054
|
-
companyId: t.String({ format: "uuid" })
|
|
284074
|
+
companyId: t.String({ format: "uuid" }),
|
|
284075
|
+
date: t.String({ format: "date" })
|
|
284055
284076
|
}));
|
|
284056
284077
|
})(CrmCpOrderPaymentModel ||= {});
|
|
284057
284078
|
var model_default13 = CrmCpOrderPaymentModel;
|
|
@@ -285595,12 +285616,12 @@ var model_default24 = InspectionFieldGroupModel;
|
|
|
285595
285616
|
var fieldGroupRoutes = new Elysia({
|
|
285596
285617
|
prefix: "/field-group",
|
|
285597
285618
|
tags: ["InspectionFieldGroup"]
|
|
285598
|
-
}).use(better_auth_default).
|
|
285599
|
-
userKind: "ADMIN"
|
|
285600
|
-
}).get("/", async ({ query }) => logic_default26.select(query), {
|
|
285619
|
+
}).use(better_auth_default).get("/", async ({ query }) => logic_default26.select(query), {
|
|
285601
285620
|
query: model_default24.select,
|
|
285602
285621
|
userKind: undefined,
|
|
285603
285622
|
auth: true
|
|
285623
|
+
}).guard({
|
|
285624
|
+
userKind: "ADMIN"
|
|
285604
285625
|
}).post("/", async ({ body }) => logic_default26.create(body), {
|
|
285605
285626
|
body: model_default24.create
|
|
285606
285627
|
}).guard({
|
|
@@ -285706,7 +285727,7 @@ var fieldResult_default = fieldResultRoutes;
|
|
|
285706
285727
|
var InspectionLogic;
|
|
285707
285728
|
((InspectionLogic) => {
|
|
285708
285729
|
InspectionLogic.select = async (query, user2) => {
|
|
285709
|
-
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));
|
|
285710
285731
|
const baseQuery = db_default.select({
|
|
285711
285732
|
inspection: inspectionTable,
|
|
285712
285733
|
machine: companyMachineTable,
|
|
@@ -286532,8 +286553,8 @@ var pm_default = pmRoutes;
|
|
|
286532
286553
|
// src/routes/fleet/work-order/logic.ts
|
|
286533
286554
|
var WorkOrderLogic;
|
|
286534
286555
|
((WorkOrderLogic) => {
|
|
286535
|
-
WorkOrderLogic.select = async (query) => {
|
|
286536
|
-
const filter = softDeletedFilter(workOrderTable);
|
|
286556
|
+
WorkOrderLogic.select = async (query, user2) => {
|
|
286557
|
+
const filter = and(softDeletedFilter(workOrderTable), eq(companyMachineTable.companyId, user2.companyId));
|
|
286537
286558
|
const baseQuery = db_default.select({
|
|
286538
286559
|
wo: workOrderTable,
|
|
286539
286560
|
machine: companyMachineTable,
|
|
@@ -286571,8 +286592,8 @@ var model_default37 = WorkOrderModel;
|
|
|
286571
286592
|
// src/routes/fleet/work-order/task/logic.ts
|
|
286572
286593
|
var WorkOrderTaskLogic;
|
|
286573
286594
|
((WorkOrderTaskLogic) => {
|
|
286574
|
-
WorkOrderTaskLogic.select = async (query) => {
|
|
286575
|
-
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));
|
|
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));
|
|
286576
286597
|
const companyServiceKind = alias(companyServiceKindTable, "companyServiceKind");
|
|
286577
286598
|
const baseQuery = db_default.select({
|
|
286578
286599
|
task: workOrderTaskTable,
|
|
@@ -286625,7 +286646,7 @@ var model_default38 = WorkOrderTaskModel;
|
|
|
286625
286646
|
var workOrderTaskRoutes = new Elysia({
|
|
286626
286647
|
prefix: "/task",
|
|
286627
286648
|
tags: ["WorkOrderTask"]
|
|
286628
|
-
}).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), {
|
|
286629
286650
|
query: model_default38.select
|
|
286630
286651
|
}).post("/", async ({ body }) => logic_default40.create(body), {
|
|
286631
286652
|
body: model_default38.create
|
|
@@ -286640,7 +286661,7 @@ var task_default = workOrderTaskRoutes;
|
|
|
286640
286661
|
var workOrderRoutes = new Elysia({
|
|
286641
286662
|
prefix: "/work-order",
|
|
286642
286663
|
tags: ["WorkOrder"]
|
|
286643
|
-
}).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), {
|
|
286644
286665
|
query: model_default37.select
|
|
286645
286666
|
}).post("/", async ({ body }) => logic_default39.create(body), {
|
|
286646
286667
|
body: model_default37.create
|