autosync_backend2 1.2.7 → 1.2.8

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 CHANGED
@@ -619,7 +619,6 @@ export declare const app: Elysia<"", {
619
619
  supplierId?: string | undefined;
620
620
  productId?: string | undefined;
621
621
  priceSell?: number | undefined;
622
- alias?: string | undefined;
623
622
  ids?: string[] | undefined;
624
623
  pagination: {
625
624
  size: number;
@@ -784,7 +783,6 @@ export declare const app: Elysia<"", {
784
783
  supplierId?: string | undefined;
785
784
  productId?: string | undefined;
786
785
  priceSell?: number | undefined;
787
- alias?: string | undefined;
788
786
  ids?: string[] | undefined;
789
787
  pagination: {
790
788
  size: number;
@@ -1031,12 +1029,7 @@ export declare const app: Elysia<"", {
1031
1029
  supplierId?: string | undefined;
1032
1030
  productId?: string | undefined;
1033
1031
  priceSell?: number | undefined;
1034
- alias?: string | undefined;
1035
1032
  ids?: string[] | undefined;
1036
- pagination: {
1037
- size: number;
1038
- page: number;
1039
- };
1040
1033
  } | undefined;
1041
1034
  warehouseId?: string | undefined;
1042
1035
  safetyStock?: number | undefined;
@@ -1199,7 +1192,6 @@ export declare const app: Elysia<"", {
1199
1192
  supplierId?: string | undefined;
1200
1193
  productId?: string | undefined;
1201
1194
  priceSell?: number | undefined;
1202
- alias?: string | undefined;
1203
1195
  ids?: string[] | undefined;
1204
1196
  } | undefined;
1205
1197
  itemId?: string | undefined;
@@ -5527,7 +5519,10 @@ export declare const app: Elysia<"", {
5527
5519
  query: unknown;
5528
5520
  headers: unknown;
5529
5521
  response: {
5530
- 200: number;
5522
+ 200: {
5523
+ count: number;
5524
+ month: string;
5525
+ }[];
5531
5526
  401: "Session not found";
5532
5527
  };
5533
5528
  };
@@ -5542,7 +5537,10 @@ export declare const app: Elysia<"", {
5542
5537
  query: unknown;
5543
5538
  headers: unknown;
5544
5539
  response: {
5545
- 200: number;
5540
+ 200: {
5541
+ count: number;
5542
+ month: string;
5543
+ }[];
5546
5544
  401: "Session not found";
5547
5545
  };
5548
5546
  };
@@ -5557,7 +5555,10 @@ export declare const app: Elysia<"", {
5557
5555
  query: unknown;
5558
5556
  headers: unknown;
5559
5557
  response: {
5560
- 200: number;
5558
+ 200: {
5559
+ count: number;
5560
+ month: string;
5561
+ }[];
5561
5562
  401: "Session not found";
5562
5563
  };
5563
5564
  };
@@ -5572,7 +5573,10 @@ export declare const app: Elysia<"", {
5572
5573
  query: unknown;
5573
5574
  headers: unknown;
5574
5575
  response: {
5575
- 200: number;
5576
+ 200: {
5577
+ amount: number;
5578
+ month: string;
5579
+ }[];
5576
5580
  401: "Session not found";
5577
5581
  };
5578
5582
  };
@@ -5600,6 +5604,48 @@ export declare const app: Elysia<"", {
5600
5604
  };
5601
5605
  };
5602
5606
  };
5607
+ } & {
5608
+ dashboard: {
5609
+ "most-sold-services": {
5610
+ get: {
5611
+ body: unknown;
5612
+ params: {};
5613
+ query: unknown;
5614
+ headers: unknown;
5615
+ response: {
5616
+ 200: {
5617
+ quantity: number;
5618
+ service: {
5619
+ id: string;
5620
+ name: string;
5621
+ };
5622
+ }[];
5623
+ 401: "Session not found";
5624
+ };
5625
+ };
5626
+ };
5627
+ };
5628
+ } & {
5629
+ dashboard: {
5630
+ "most-sold-vehicles": {
5631
+ get: {
5632
+ body: unknown;
5633
+ params: {};
5634
+ query: unknown;
5635
+ headers: unknown;
5636
+ response: {
5637
+ 200: {
5638
+ quantity: number;
5639
+ vehicleKind: {
5640
+ id: string;
5641
+ name: string;
5642
+ };
5643
+ }[];
5644
+ 401: "Session not found";
5645
+ };
5646
+ };
5647
+ };
5648
+ };
5603
5649
  } & {
5604
5650
  dashboard: {
5605
5651
  "daily-sales": {
@@ -5610,7 +5656,7 @@ export declare const app: Elysia<"", {
5610
5656
  headers: unknown;
5611
5657
  response: {
5612
5658
  200: {
5613
- amount: string | null;
5659
+ amount: number;
5614
5660
  date: string;
5615
5661
  }[];
5616
5662
  401: "Session not found";
@@ -6630,7 +6676,7 @@ export declare const app: Elysia<"", {
6630
6676
  companyBranchId?: string | undefined;
6631
6677
  startDate?: string | undefined;
6632
6678
  endDate?: string | undefined;
6633
- groupBy: "day" | "week" | "month" | "year";
6679
+ groupBy: "month" | "day" | "week" | "year";
6634
6680
  };
6635
6681
  headers: unknown;
6636
6682
  response: {
@@ -6854,7 +6900,7 @@ export declare const app: Elysia<"", {
6854
6900
  companyBranchId?: string | undefined;
6855
6901
  startDate?: string | undefined;
6856
6902
  endDate?: string | undefined;
6857
- groupBy: "day" | "week" | "month" | "year";
6903
+ groupBy: "month" | "day" | "week" | "year";
6858
6904
  };
6859
6905
  headers: unknown;
6860
6906
  response: {
package/dist/index.js CHANGED
@@ -146759,6 +146759,7 @@ var logic_default5 = WarehouseProductLogic;
146759
146759
  var WarehouseItemLogic;
146760
146760
  ((WarehouseItemLogic) => {
146761
146761
  WarehouseItemLogic.select = async (query, user2) => {
146762
+ console.log(query);
146762
146763
  const filter = and(softDeletedFilter(warehouseItemTable).if(query.isActive), isNotNull(warehouseItemTable.deletedAt).if(query.isActive !== undefined && query.isActive === false), ...query.product ? [logic_default5.getFilter(query.product, user2)] : [], eq(warehouseItemTable.safetyStock, query.safetyStock ?? 0).if(query.safetyStock), ilike(warehouseItemTable.shelfNumber, `%${query.shelfNumber}%`).if(query.shelfNumber), eq(warehouseItemTable.warehouseId, query.warehouseId).if(query.warehouseId));
146763
146764
  const baseQuery = db_default.select({
146764
146765
  item: warehouseItemTable,
@@ -151065,48 +151066,69 @@ var customer_default = customerRoutes;
151065
151066
  var CrmDashboardLogic;
151066
151067
  ((CrmDashboardLogic) => {
151067
151068
  CrmDashboardLogic.getCarCount = async (user2) => {
151068
- const [result] = await db_default.select({
151069
- count: sql3`count(distinct ${crmCpOrderTable.vehicleId})`
151070
- }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER")));
151071
- return result?.count ?? 0;
151069
+ const result = await db_default.select({
151070
+ count: sql3`count(distinct ${crmCpOrderTable.vehicleId})`.mapWith(Number),
151071
+ month: sql3`date_trunc('month', ${crmCpOrderTable.createdAt})`.as("month")
151072
+ }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE) - INTERVAL '1 month'`)).groupBy((t2) => t2.month);
151073
+ return result;
151072
151074
  };
151073
151075
  CrmDashboardLogic.getCpOrderCount = async (user2) => {
151074
- const [result] = await db_default.select({
151075
- count: sql3`count(${crmCpOrderTable.id})`
151076
- }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER")));
151077
- return result?.count ?? 0;
151076
+ const result = await db_default.select({
151077
+ count: sql3`count(${crmCpOrderTable.id})`.mapWith(Number),
151078
+ month: sql3`date_trunc('month', ${crmCpOrderTable.createdAt})`.as("month")
151079
+ }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE) - interval '1 month'`)).groupBy((t2) => t2.month);
151080
+ return result;
151078
151081
  };
151079
151082
  CrmDashboardLogic.getCpOrderServiceCount = async (user2) => {
151080
- const [result] = await db_default.select({
151081
- count: sql3`count(${crmCpOrderTable.id})`
151082
- }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), eq(crmCpOrderTable.type, "Service")));
151083
- return result?.count ?? 0;
151083
+ const result = await db_default.select({
151084
+ count: sql3`count(${crmCpOrderTable.id})`.mapWith(Number),
151085
+ month: sql3`date_trunc('month', ${crmCpOrderTable.createdAt})`.as("month")
151086
+ }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), eq(crmCpOrderTable.type, "Service"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE) - interval '1 month'`)).groupBy((t2) => t2.month);
151087
+ return result;
151084
151088
  };
151085
151089
  CrmDashboardLogic.getCpOrderTotalAmount = async (user2) => {
151086
- const [result] = await db_default.select({
151087
- amount: sum(crmCpOrderItemTable.priceTotal)
151088
- }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"))).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id));
151089
- return result.amount ? +result.amount : 0;
151090
+ const result = await db_default.select({
151091
+ amount: sum(crmCpOrderItemTable.priceTotal).mapWith(Number),
151092
+ month: sql3`date_trunc('month', ${crmCpOrderTable.createdAt})`.as("month")
151093
+ }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE) - interval '1 month'`)).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).groupBy((t2) => t2.month);
151094
+ return result;
151090
151095
  };
151091
151096
  CrmDashboardLogic.getMostSelledProduct = async (user2) => {
151092
151097
  const result = await db_default.select({
151093
- quantity: sum(crmCpOrderItemTable.quantity),
151098
+ quantity: sum(crmCpOrderItemTable.quantity).mapWith(Number),
151094
151099
  product: {
151095
151100
  id: warehouseProductTable.id,
151096
151101
  name: warehouseProductTable.name,
151097
151102
  partNumber: warehouseProductTable.partNumber
151098
151103
  }
151099
- }).from(crmCpOrderTable).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).innerJoin(warehouseProductTable, eq(warehouseProductTable.id, crmCpOrderItemTable.companyProductId)).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"))).orderBy((t2) => desc(t2.quantity)).groupBy(warehouseProductTable.id, warehouseProductTable.name, warehouseProductTable.partNumber).limit(5);
151100
- return result.map((i2) => ({
151101
- ...i2,
151102
- quantity: i2.quantity ? +i2.quantity : 0
151103
- }));
151104
+ }).from(crmCpOrderTable).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).innerJoin(warehouseProductTable, eq(warehouseProductTable.id, crmCpOrderItemTable.companyProductId)).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE)`, sql3`${crmCpOrderTable.createdAt} < date_trunc('month', CURRENT_DATE) + interval '1 month'`)).orderBy((t2) => desc(t2.quantity)).groupBy(warehouseProductTable.id, warehouseProductTable.name, warehouseProductTable.partNumber).limit(5);
151105
+ return result;
151106
+ };
151107
+ CrmDashboardLogic.getMostSelledService = async (user2) => {
151108
+ const result = await db_default.select({
151109
+ quantity: sum(crmCpOrderItemTable.quantity).mapWith(Number),
151110
+ service: {
151111
+ id: companyServiceKindTable.id,
151112
+ name: companyServiceKindTable.name
151113
+ }
151114
+ }).from(crmCpOrderTable).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).innerJoin(companyServiceKindTable, eq(companyServiceKindTable.id, crmCpOrderItemTable.companyServiceKindId)).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE)`, sql3`${crmCpOrderTable.createdAt} < date_trunc('month', CURRENT_DATE) + interval '1 month'`)).orderBy((t2) => desc(t2.quantity)).groupBy(companyServiceKindTable.id, companyServiceKindTable.name).limit(5);
151115
+ return result;
151116
+ };
151117
+ CrmDashboardLogic.getMostSelledVehicleKind = async (user2) => {
151118
+ const result = await db_default.select({
151119
+ quantity: count(crmCpOrderTable.id).mapWith(Number),
151120
+ vehicleKind: {
151121
+ id: techdocVehicleKindTable.id,
151122
+ name: techdocVehicleKindTable.name
151123
+ }
151124
+ }).from(crmCpOrderTable).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).innerJoin(crmVehicleTable, eq(crmVehicleTable.id, crmCpOrderTable.vehicleId)).innerJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE)`, sql3`${crmCpOrderTable.createdAt} < date_trunc('month', CURRENT_DATE) + interval '1 month'`)).orderBy((t2) => desc(t2.quantity)).groupBy(techdocVehicleKindTable.id, techdocVehicleKindTable.name).limit(5);
151125
+ return result;
151104
151126
  };
151105
151127
  CrmDashboardLogic.getCpOrderTotalAmountByDay = async (user2) => {
151106
151128
  const result = await db_default.select({
151107
- amount: sum(crmCpOrderItemTable.priceTotal),
151108
- date: sql3`date(${crmCpOrderItemTable.createdAt})`.as("day")
151109
- }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"))).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).groupBy((t2) => t2.date);
151129
+ amount: sum(crmCpOrderItemTable.priceTotal).mapWith(Number),
151130
+ date: sql3`date_trunc('day', CURRENT_DATE)`.as("day")
151131
+ }).from(crmCpOrderTable).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), sql3`${crmCpOrderTable.createdAt} >= date_trunc('month', CURRENT_DATE) - interval '1 month'`)).leftJoin(crmCpOrderItemTable, eq(crmCpOrderItemTable.cpOrderId, crmCpOrderTable.id)).groupBy((t2) => t2.date);
151110
151132
  return result;
151111
151133
  };
151112
151134
  })(CrmDashboardLogic ||= {});
@@ -151118,7 +151140,7 @@ var dashboardRoutes = new Elysia({
151118
151140
  tags: ["CrmDashboard"]
151119
151141
  }).use(better_auth_default).guard({
151120
151142
  auth: true
151121
- }).get("/car-count", async ({ user: user2 }) => logic_default16.getCarCount(user2)).get("/cp-order-count", async ({ user: user2 }) => logic_default16.getCpOrderCount(user2)).get("/cp-order-service-count", async ({ user: user2 }) => logic_default16.getCpOrderServiceCount(user2)).get("/cp-order-total-amount", async ({ user: user2 }) => logic_default16.getCpOrderTotalAmount(user2)).get("/most-sold-products", async ({ user: user2 }) => logic_default16.getMostSelledProduct(user2)).get("/daily-sales", async ({ user: user2 }) => logic_default16.getCpOrderTotalAmountByDay(user2));
151143
+ }).get("/car-count", async ({ user: user2 }) => logic_default16.getCarCount(user2)).get("/cp-order-count", async ({ user: user2 }) => logic_default16.getCpOrderCount(user2)).get("/cp-order-service-count", async ({ user: user2 }) => logic_default16.getCpOrderServiceCount(user2)).get("/cp-order-total-amount", async ({ user: user2 }) => logic_default16.getCpOrderTotalAmount(user2)).get("/most-sold-products", async ({ user: user2 }) => logic_default16.getMostSelledProduct(user2)).get("/most-sold-services", async ({ user: user2 }) => logic_default16.getMostSelledService(user2)).get("/most-sold-vehicles", async ({ user: user2 }) => logic_default16.getMostSelledVehicleKind(user2)).get("/daily-sales", async ({ user: user2 }) => logic_default16.getCpOrderTotalAmountByDay(user2));
151122
151144
  var dashboard_default = dashboardRoutes;
151123
151145
 
151124
151146
  // src/routes/crm/discount/model.ts
@@ -151354,7 +151376,7 @@ var CrmInspectionLogic;
151354
151376
  status: crmInspectionTable.status
151355
151377
  }
151356
151378
  }).from(crmInspectionTable).where(eq(crmInspectionTable.id, inspection.id)).leftJoin(companyCompanyTable, eq(companyCompanyTable.id, crmInspectionTable.companyId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmInspectionTable.vehicleId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmInspectionTable.employeeId));
151357
- distribution_default.post("https://driver-partner-api.dev.ubcabtech.com/v1/webhook/autosync/inspection", {
151379
+ distribution_default.post(env_default.NODE_ENV === "development" ? "https://driver-partner-api.dev.ubcabtech.com/v1/webhook/autosync/inspection" : "https://driver-partner-api.ubcabtech.com/v1/webhook/autosync/inspection", {
151358
151380
  json: result[0],
151359
151381
  retry: 3
151360
151382
  });
@@ -152828,7 +152850,6 @@ var WarehouseProductModel;
152828
152850
  supplierId: t.String({ format: "uuid" }),
152829
152851
  search: t.String(),
152830
152852
  priceSell: t.Number(),
152831
- alias: t.String(),
152832
152853
  productId: t.String({ format: "uuid" }),
152833
152854
  id: t.String({ format: "uuid" }),
152834
152855
  ids: t.Array(t.String({ format: "uuid" })),
@@ -152854,7 +152875,7 @@ var WarehouseItemModel;
152854
152875
  WarehouseItemModel.select = t.Composite([
152855
152876
  PaginationSchema,
152856
152877
  t.Partial(t.Object({
152857
- product: model_default22.select,
152878
+ product: t.Omit(model_default22.select, ["pagination"]),
152858
152879
  shelfNumber: t.String(),
152859
152880
  safetyStock: t.Number(),
152860
152881
  warehouseId: t.String({ format: "uuid" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",