autosync_backend2 1.1.18 → 1.1.19

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
@@ -365,29 +365,30 @@ declare const app: Elysia<"", {
365
365
  amount: import("@sinclair/typebox").TNumber;
366
366
  }>;
367
367
  readonly "CrmCpOrderPaymentModel.storepay": import("@sinclair/typebox").TObject<{
368
- state: import("@sinclair/typebox").TEnum<{
369
- NOT_PAID: "NOT_PAID";
370
- PENDING: "PENDING";
371
- FAILED: "FAILED";
372
- EXPIRED: "EXPIRED";
373
- PAID: "PAID";
374
- DECLINED: "DECLINED";
375
- CANCELED: "CANCELED";
376
- REFUNDING: "REFUNDING";
377
- REFUNDED: "REFUNDED";
378
- }>;
379
368
  cpOrderId: import("@sinclair/typebox").TString;
380
369
  paymentPackageId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
381
- paymentMethod: import("@sinclair/typebox").TEnum<{
382
- CASH: "CASH";
383
- BANK_TRANSFER: "BANK_TRANSFER";
384
- POS_TERMINAL: "POS_TERMINAL";
385
- PAYMENT_PACKAGE: "PAYMENT_PACKAGE";
386
- }>;
387
- paymentChannel: import("@sinclair/typebox").TString;
388
370
  amount: import("@sinclair/typebox").TNumber;
389
371
  phone: import("@sinclair/typebox").TNumber;
390
372
  }>;
373
+ readonly "CrmCpOrderPaymentModel.createPaymentInfo": import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
374
+ branchId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
375
+ companyId: import("@sinclair/typebox").TString;
376
+ }>, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
377
+ type: import("@sinclair/typebox").TLiteral<"StorePay">;
378
+ sub: import("@sinclair/typebox").TObject<{
379
+ username: import("@sinclair/typebox").TString;
380
+ password: import("@sinclair/typebox").TString;
381
+ appUserName: import("@sinclair/typebox").TString;
382
+ appPassword: import("@sinclair/typebox").TString;
383
+ storeId: import("@sinclair/typebox").TString;
384
+ }>;
385
+ }>, import("@sinclair/typebox").TObject<{
386
+ type: import("@sinclair/typebox").TLiteral<"UbPay">;
387
+ sub: import("@sinclair/typebox").TObject<{
388
+ username: import("@sinclair/typebox").TString;
389
+ password: import("@sinclair/typebox").TString;
390
+ }>;
391
+ }>]>]>;
391
392
  readonly "CrmCpOrderModel.create": import("@sinclair/typebox").TObject<{
392
393
  phone: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
393
394
  vin: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -3535,10 +3536,7 @@ declare const app: Elysia<"", {
3535
3536
  body: {
3536
3537
  paymentPackageId?: string | null | undefined;
3537
3538
  phone: number;
3538
- state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
3539
3539
  cpOrderId: string;
3540
- paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
3541
- paymentChannel: string;
3542
3540
  amount: number;
3543
3541
  };
3544
3542
  params: {};
@@ -3572,6 +3570,157 @@ declare const app: Elysia<"", {
3572
3570
  };
3573
3571
  };
3574
3572
  };
3573
+ } & {
3574
+ payment: {
3575
+ get: {
3576
+ body: unknown;
3577
+ params: {};
3578
+ query: unknown;
3579
+ headers: unknown;
3580
+ response: {
3581
+ 200: {
3582
+ company: {
3583
+ name: string;
3584
+ regNumber: string;
3585
+ phone: string;
3586
+ email: string;
3587
+ serviceName: string;
3588
+ logoUrl: string;
3589
+ province: string | null;
3590
+ district: string | null;
3591
+ khoroo: string | null;
3592
+ street: string | null;
3593
+ socialUrls: string[] | null;
3594
+ ceoName: string | null;
3595
+ webUrl: string | null;
3596
+ googleMapUrl: string | null;
3597
+ isContract: boolean;
3598
+ isNoat: boolean;
3599
+ isNexus: boolean;
3600
+ isActive: boolean;
3601
+ branchCount: number;
3602
+ id: string;
3603
+ createdAt: string;
3604
+ updatedAt: string;
3605
+ deletedAt: string | null;
3606
+ };
3607
+ branch: {
3608
+ name: string;
3609
+ phone: string;
3610
+ logoUrl: string;
3611
+ email: string | null;
3612
+ regNumber: string | null;
3613
+ province: string | null;
3614
+ district: string | null;
3615
+ khoroo: string | null;
3616
+ street: string | null;
3617
+ socialUrls: string[] | null;
3618
+ ceoName: string | null;
3619
+ googleMapUrl: string | null;
3620
+ isNoat: boolean;
3621
+ isActive: boolean;
3622
+ packageId: string;
3623
+ merchantId: string;
3624
+ id: string;
3625
+ createdAt: string;
3626
+ updatedAt: string;
3627
+ deletedAt: string | null;
3628
+ } | null;
3629
+ payment: {
3630
+ accessToken: string | null;
3631
+ refreshToken: string | null;
3632
+ companyId: string;
3633
+ expiresIn: number | null;
3634
+ refreshExpiresIn: number | null;
3635
+ branchId: string | null;
3636
+ type: "StorePay" | "Qpay" | "MinuPos" | "UbPay";
3637
+ sub: unknown;
3638
+ id: string;
3639
+ createdAt: string;
3640
+ updatedAt: string;
3641
+ deletedAt: string | null;
3642
+ };
3643
+ }[];
3644
+ };
3645
+ };
3646
+ };
3647
+ } & {
3648
+ payment: {
3649
+ post: {
3650
+ body: {
3651
+ branchId?: string | undefined;
3652
+ companyId: string;
3653
+ } & ({
3654
+ type: "StorePay";
3655
+ sub: {
3656
+ password: string;
3657
+ username: string;
3658
+ appUserName: string;
3659
+ appPassword: string;
3660
+ storeId: string;
3661
+ };
3662
+ } | {
3663
+ type: "UbPay";
3664
+ sub: {
3665
+ password: string;
3666
+ username: string;
3667
+ };
3668
+ });
3669
+ params: {};
3670
+ query: unknown;
3671
+ headers: unknown;
3672
+ response: {
3673
+ 200: {
3674
+ type: "StorePay" | "Qpay" | "MinuPos" | "UbPay";
3675
+ id: string;
3676
+ sub: unknown;
3677
+ createdAt: string;
3678
+ updatedAt: string;
3679
+ companyId: string;
3680
+ branchId: string | null;
3681
+ accessToken: string | null;
3682
+ refreshToken: string | null;
3683
+ deletedAt: string | null;
3684
+ expiresIn: number | null;
3685
+ refreshExpiresIn: number | null;
3686
+ };
3687
+ 422: {
3688
+ type: "validation";
3689
+ on: string;
3690
+ summary?: string;
3691
+ message?: string;
3692
+ found?: unknown;
3693
+ property?: string;
3694
+ expected?: string;
3695
+ };
3696
+ };
3697
+ };
3698
+ };
3699
+ } & {
3700
+ payment: {
3701
+ ":id": {
3702
+ delete: {
3703
+ body: unknown;
3704
+ params: {
3705
+ id: string;
3706
+ };
3707
+ query: unknown;
3708
+ headers: unknown;
3709
+ response: {
3710
+ 200: void;
3711
+ 422: {
3712
+ type: "validation";
3713
+ on: string;
3714
+ summary?: string;
3715
+ message?: string;
3716
+ found?: unknown;
3717
+ property?: string;
3718
+ expected?: string;
3719
+ };
3720
+ };
3721
+ };
3722
+ };
3723
+ };
3575
3724
  };
3576
3725
  } & {
3577
3726
  "cp-order": {
package/dist/index.js CHANGED
@@ -143975,7 +143975,7 @@ var CrmCpOrderPaymentModel;
143975
143975
  const createSchema = createInsertSchema(crmCpOrderPaymentTable);
143976
143976
  CrmCpOrderPaymentModel.create = t.Omit(OmitBaseSchema(createSchema), ["invoiceNumber"]);
143977
143977
  CrmCpOrderPaymentModel.storepay = t.Composite([
143978
- CrmCpOrderPaymentModel.create,
143978
+ t.Omit(CrmCpOrderPaymentModel.create, ["paymentMethod", "paymentChannel", "state"]),
143979
143979
  t.Object({
143980
143980
  phone: t.Number({
143981
143981
  minimum: 1e7,
@@ -143983,6 +143983,31 @@ var CrmCpOrderPaymentModel;
143983
143983
  })
143984
143984
  })
143985
143985
  ]);
143986
+ CrmCpOrderPaymentModel.createPaymentInfo = t.Intersect([
143987
+ t.Object({
143988
+ branchId: t.Optional(t.String({ format: "uuid" })),
143989
+ companyId: t.String({ format: "uuid" })
143990
+ }),
143991
+ t.Union([
143992
+ t.Object({
143993
+ type: t.Literal("StorePay"),
143994
+ sub: t.Object({
143995
+ username: t.String(),
143996
+ password: t.String(),
143997
+ appUserName: t.String(),
143998
+ appPassword: t.String(),
143999
+ storeId: t.String()
144000
+ })
144001
+ }),
144002
+ t.Object({
144003
+ type: t.Literal("UbPay"),
144004
+ sub: t.Object({
144005
+ username: t.String(),
144006
+ password: t.String()
144007
+ })
144008
+ })
144009
+ ])
144010
+ ]);
143986
144011
  })(CrmCpOrderPaymentModel ||= {});
143987
144012
  var model_default8 = CrmCpOrderPaymentModel;
143988
144013
 
@@ -144182,6 +144207,19 @@ class StorePayGateway extends PaymentGateway {
144182
144207
  // src/routes/crm/cpOrder/payment/logic.ts
144183
144208
  var CrmCpOrderPaymentLogic;
144184
144209
  ((CrmCpOrderPaymentLogic) => {
144210
+ CrmCpOrderPaymentLogic.selectPaymentInfo = async () => {
144211
+ const paymentInfos = await db_default.select().from(crmPaymentTable).innerJoin(companyCompanyTable, eq(companyCompanyTable.id, crmPaymentTable.companyId)).leftJoin(companyBranchTable, eq(companyBranchTable.id, crmPaymentTable.branchId));
144212
+ return paymentInfos;
144213
+ };
144214
+ CrmCpOrderPaymentLogic.createPaymentInfo = async (body) => {
144215
+ const [paymentInfo] = await db_default.insert(crmPaymentTable).values({
144216
+ ...body
144217
+ }).returning();
144218
+ return paymentInfo;
144219
+ };
144220
+ CrmCpOrderPaymentLogic.removePaymentInfo = async (id) => {
144221
+ await db_default.delete(crmPaymentTable).where(eq(crmPaymentTable.id, id));
144222
+ };
144185
144223
  CrmCpOrderPaymentLogic.createStorepay = async (body, user2) => {
144186
144224
  const paymentInfo = await getPaymentInfo("StorePay", user2);
144187
144225
  if ("code" in paymentInfo) {
@@ -144196,7 +144234,12 @@ var CrmCpOrderPaymentLogic;
144196
144234
  ]);
144197
144235
  gateway.setToken(paymentInfo);
144198
144236
  gateway.storeId = auth3.storeId;
144199
- const result = await gateway.createInvoice(body);
144237
+ const result = await gateway.createInvoice({
144238
+ ...body,
144239
+ paymentMethod: "POS_TERMINAL",
144240
+ paymentChannel: "STOREPAY",
144241
+ state: "PENDING"
144242
+ });
144200
144243
  return result;
144201
144244
  };
144202
144245
  CrmCpOrderPaymentLogic.checkStorePay = async (id) => {
@@ -144245,7 +144288,13 @@ var logic_default11 = CrmCpOrderPaymentLogic;
144245
144288
  var paymentRoutes = new Elysia({
144246
144289
  prefix: "/payment",
144247
144290
  tags: ["CrmCpOrderPayment"]
144248
- }).use(better_auth_default).model(prefix_model_default("CrmCpOrderPaymentModel", model_default8)).get("/storepay/:id", async ({ params: { id } }) => logic_default11.checkStorePay(id)).guard({ auth: true }).post("/storepay", async ({ body, user: user2 }) => logic_default11.createStorepay(body, user2), { body: "CrmCpOrderPaymentModel.storepay" });
144291
+ }).use(better_auth_default).model(prefix_model_default("CrmCpOrderPaymentModel", model_default8)).get("/storepay/:id", async ({ params: { id } }) => logic_default11.checkStorePay(id)).guard({ auth: true }).post("/storepay", async ({ body, user: user2 }) => logic_default11.createStorepay(body, user2), { body: "CrmCpOrderPaymentModel.storepay" }).guard({
144292
+ userKind: "ADMIN"
144293
+ }).get("/", async () => logic_default11.selectPaymentInfo()).post("/", async ({ body }) => logic_default11.createPaymentInfo(body), {
144294
+ body: "CrmCpOrderPaymentModel.createPaymentInfo"
144295
+ }).delete("/:id", async ({ params: { id } }) => logic_default11.removePaymentInfo(id), {
144296
+ params: IdSchema
144297
+ });
144249
144298
  var payment_default = paymentRoutes;
144250
144299
 
144251
144300
  // src/routes/crm/cpOrder/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",