autosync_backend2 1.2.18 → 1.2.20

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
@@ -5002,6 +5002,7 @@ export declare const app: Elysia<"", {
5002
5002
  headers: unknown;
5003
5003
  response: {
5004
5004
  200: {
5005
+ id: string;
5005
5006
  licensePlate: string | null;
5006
5007
  yearImported: number | null;
5007
5008
  yearManufactured: number | null;
@@ -6411,6 +6412,70 @@ export declare const app: Elysia<"", {
6411
6412
  };
6412
6413
  };
6413
6414
  };
6415
+ } & {
6416
+ inspection: {
6417
+ admin: {
6418
+ get: {
6419
+ body: {};
6420
+ params: {};
6421
+ query: {
6422
+ companyId?: string | undefined;
6423
+ pagination: {
6424
+ size: number;
6425
+ page: number;
6426
+ };
6427
+ };
6428
+ headers: {};
6429
+ response: {
6430
+ 200: {
6431
+ totalCount: number;
6432
+ totalPage: number;
6433
+ result: {
6434
+ company: {
6435
+ id: string;
6436
+ name: string;
6437
+ serviceName: string;
6438
+ logoUrl: string;
6439
+ } | null;
6440
+ vehicle: {
6441
+ licensePlate: string | null;
6442
+ vin: string | null;
6443
+ model: string | null;
6444
+ };
6445
+ employee: {
6446
+ firstname: string;
6447
+ lastname: string;
6448
+ } | null;
6449
+ inspection: {
6450
+ inspection: {
6451
+ type: string;
6452
+ values: {
6453
+ description: string;
6454
+ question: string;
6455
+ answer: string;
6456
+ }[];
6457
+ }[] | null;
6458
+ createdAt: string;
6459
+ expireAt: Date;
6460
+ status: "CREATED" | "APPROVED" | "CANCELLED";
6461
+ };
6462
+ totalCount: number;
6463
+ }[];
6464
+ };
6465
+ 401: "Session not found";
6466
+ 422: {
6467
+ type: "validation";
6468
+ on: string;
6469
+ summary?: string;
6470
+ message?: string;
6471
+ found?: unknown;
6472
+ property?: string;
6473
+ expected?: string;
6474
+ };
6475
+ };
6476
+ };
6477
+ };
6478
+ };
6414
6479
  } & {
6415
6480
  inspection: {
6416
6481
  ":id": {
@@ -7369,6 +7434,543 @@ export declare const app: Elysia<"", {
7369
7434
  product: {};
7370
7435
  };
7371
7436
  };
7437
+ } & {
7438
+ api: {
7439
+ fleet: {
7440
+ inspection: {
7441
+ "field-group": {};
7442
+ } & {
7443
+ "field-group": {
7444
+ get: {
7445
+ body: {};
7446
+ params: {};
7447
+ query: {
7448
+ name?: string | undefined;
7449
+ code?: string | undefined;
7450
+ pagination: {
7451
+ size: number;
7452
+ page: number;
7453
+ };
7454
+ };
7455
+ headers: {};
7456
+ response: {
7457
+ 200: {
7458
+ totalCount: number;
7459
+ totalPage: number;
7460
+ result: {
7461
+ totalCount: number;
7462
+ code: string | null;
7463
+ name: string;
7464
+ description: string | null;
7465
+ id: string;
7466
+ createdAt: string;
7467
+ updatedAt: string;
7468
+ deletedAt: string | null;
7469
+ oldId: number | null;
7470
+ }[];
7471
+ };
7472
+ 401: "Session not found";
7473
+ 422: {
7474
+ type: "validation";
7475
+ on: string;
7476
+ summary?: string;
7477
+ message?: string;
7478
+ found?: unknown;
7479
+ property?: string;
7480
+ expected?: string;
7481
+ };
7482
+ };
7483
+ };
7484
+ };
7485
+ } & {
7486
+ "field-group": {
7487
+ post: {
7488
+ body: {
7489
+ code?: string | null | undefined;
7490
+ oldId?: number | null | undefined;
7491
+ description?: string | null | undefined;
7492
+ name: string;
7493
+ };
7494
+ params: {};
7495
+ query: unknown;
7496
+ headers: unknown;
7497
+ response: {
7498
+ 422: {
7499
+ type: "validation";
7500
+ on: string;
7501
+ summary?: string;
7502
+ message?: string;
7503
+ found?: unknown;
7504
+ property?: string;
7505
+ expected?: string;
7506
+ };
7507
+ };
7508
+ };
7509
+ };
7510
+ } & {
7511
+ "field-group": {
7512
+ ":id": {
7513
+ put: {
7514
+ body: {
7515
+ name?: string | undefined;
7516
+ code?: string | null | undefined;
7517
+ oldId?: number | null | undefined;
7518
+ description?: string | null | undefined;
7519
+ };
7520
+ params: {
7521
+ id: string;
7522
+ };
7523
+ query: unknown;
7524
+ headers: unknown;
7525
+ response: {
7526
+ 422: {
7527
+ type: "validation";
7528
+ on: string;
7529
+ summary?: string;
7530
+ message?: string;
7531
+ found?: unknown;
7532
+ property?: string;
7533
+ expected?: string;
7534
+ };
7535
+ };
7536
+ };
7537
+ };
7538
+ };
7539
+ } & {
7540
+ "field-group": {
7541
+ ":id": {
7542
+ delete: {
7543
+ body: unknown;
7544
+ params: {
7545
+ id: string;
7546
+ };
7547
+ query: unknown;
7548
+ headers: unknown;
7549
+ response: {
7550
+ 422: {
7551
+ type: "validation";
7552
+ on: string;
7553
+ summary?: string;
7554
+ message?: string;
7555
+ found?: unknown;
7556
+ property?: string;
7557
+ expected?: string;
7558
+ };
7559
+ };
7560
+ };
7561
+ };
7562
+ };
7563
+ } & {
7564
+ "field-group": {
7565
+ ":id": {
7566
+ field: {
7567
+ get: {
7568
+ body: unknown;
7569
+ params: {
7570
+ id: string;
7571
+ };
7572
+ query: unknown;
7573
+ headers: unknown;
7574
+ response: {
7575
+ 200: {
7576
+ groupId: string;
7577
+ code: string | null;
7578
+ description: string | null;
7579
+ version: string | null;
7580
+ isActive: boolean;
7581
+ metadata: unknown;
7582
+ required: boolean;
7583
+ fieldGroup: string | null;
7584
+ sortIndex: number | null;
7585
+ id: string;
7586
+ createdAt: string;
7587
+ updatedAt: string;
7588
+ deletedAt: string | null;
7589
+ oldId: number | null;
7590
+ }[];
7591
+ 422: {
7592
+ type: "validation";
7593
+ on: string;
7594
+ summary?: string;
7595
+ message?: string;
7596
+ found?: unknown;
7597
+ property?: string;
7598
+ expected?: string;
7599
+ };
7600
+ };
7601
+ };
7602
+ };
7603
+ };
7604
+ };
7605
+ };
7606
+ } & {
7607
+ inspection: {
7608
+ field: {};
7609
+ } & {
7610
+ field: {
7611
+ post: {
7612
+ body: {
7613
+ required?: boolean | undefined;
7614
+ code?: string | null | undefined;
7615
+ oldId?: number | null | undefined;
7616
+ isActive?: boolean | undefined;
7617
+ description?: string | null | undefined;
7618
+ version?: string | null | undefined;
7619
+ metadata?: import("drizzle-typebox").Json | undefined;
7620
+ fieldGroup?: string | null | undefined;
7621
+ sortIndex?: number | null | undefined;
7622
+ groupId: string;
7623
+ };
7624
+ params: {};
7625
+ query: unknown;
7626
+ headers: unknown;
7627
+ response: {
7628
+ 422: {
7629
+ type: "validation";
7630
+ on: string;
7631
+ summary?: string;
7632
+ message?: string;
7633
+ found?: unknown;
7634
+ property?: string;
7635
+ expected?: string;
7636
+ };
7637
+ };
7638
+ };
7639
+ };
7640
+ } & {
7641
+ field: {
7642
+ ":id": {
7643
+ put: {
7644
+ body: {
7645
+ required?: boolean | undefined;
7646
+ code?: string | null | undefined;
7647
+ oldId?: number | null | undefined;
7648
+ isActive?: boolean | undefined;
7649
+ description?: string | null | undefined;
7650
+ version?: string | null | undefined;
7651
+ metadata?: import("drizzle-typebox").Json | undefined;
7652
+ fieldGroup?: string | null | undefined;
7653
+ sortIndex?: number | null | undefined;
7654
+ groupId: string;
7655
+ };
7656
+ params: {
7657
+ id: string;
7658
+ };
7659
+ query: unknown;
7660
+ headers: unknown;
7661
+ response: {
7662
+ 422: {
7663
+ type: "validation";
7664
+ on: string;
7665
+ summary?: string;
7666
+ message?: string;
7667
+ found?: unknown;
7668
+ property?: string;
7669
+ expected?: string;
7670
+ };
7671
+ };
7672
+ };
7673
+ };
7674
+ };
7675
+ } & {
7676
+ field: {
7677
+ ":id": {
7678
+ delete: {
7679
+ body: unknown;
7680
+ params: {
7681
+ id: string;
7682
+ };
7683
+ query: unknown;
7684
+ headers: unknown;
7685
+ response: {
7686
+ 422: {
7687
+ type: "validation";
7688
+ on: string;
7689
+ summary?: string;
7690
+ message?: string;
7691
+ found?: unknown;
7692
+ property?: string;
7693
+ expected?: string;
7694
+ };
7695
+ };
7696
+ };
7697
+ };
7698
+ };
7699
+ };
7700
+ } & {
7701
+ inspection: {
7702
+ template: {};
7703
+ } & {
7704
+ template: {
7705
+ get: {
7706
+ body: unknown;
7707
+ params: {};
7708
+ query: {
7709
+ pagination: {
7710
+ size: number;
7711
+ page: number;
7712
+ };
7713
+ };
7714
+ headers: unknown;
7715
+ response: {
7716
+ 200: {
7717
+ totalCount: number;
7718
+ totalPage: number;
7719
+ result: Omit<{
7720
+ totalCount: number;
7721
+ companyId: string | null;
7722
+ name: string;
7723
+ description: string | null;
7724
+ version: string | null;
7725
+ isActive: boolean;
7726
+ id: string;
7727
+ createdAt: string;
7728
+ updatedAt: string;
7729
+ deletedAt: string | null;
7730
+ oldId: number | null;
7731
+ }, "totalCount">[];
7732
+ };
7733
+ 422: {
7734
+ type: "validation";
7735
+ on: string;
7736
+ summary?: string;
7737
+ message?: string;
7738
+ found?: unknown;
7739
+ property?: string;
7740
+ expected?: string;
7741
+ };
7742
+ };
7743
+ };
7744
+ };
7745
+ } & {
7746
+ template: {
7747
+ post: {
7748
+ body: {
7749
+ companyId?: string | null | undefined;
7750
+ oldId?: number | null | undefined;
7751
+ isActive?: boolean | undefined;
7752
+ description?: string | null | undefined;
7753
+ version?: string | null | undefined;
7754
+ name: string;
7755
+ };
7756
+ params: {};
7757
+ query: unknown;
7758
+ headers: unknown;
7759
+ response: {
7760
+ 422: {
7761
+ type: "validation";
7762
+ on: string;
7763
+ summary?: string;
7764
+ message?: string;
7765
+ found?: unknown;
7766
+ property?: string;
7767
+ expected?: string;
7768
+ };
7769
+ };
7770
+ };
7771
+ };
7772
+ } & {
7773
+ template: {
7774
+ ":id": {
7775
+ get: {
7776
+ body: unknown;
7777
+ params: {
7778
+ id: string;
7779
+ };
7780
+ query: unknown;
7781
+ headers: unknown;
7782
+ response: {
7783
+ 200: {
7784
+ companyId: string | null;
7785
+ name: string;
7786
+ description: string | null;
7787
+ version: string | null;
7788
+ isActive: boolean;
7789
+ id: string;
7790
+ createdAt: string;
7791
+ updatedAt: string;
7792
+ deletedAt: string | null;
7793
+ oldId: number | null;
7794
+ };
7795
+ 404: "Үзлэгийн загвар олдсонгүй.";
7796
+ 422: {
7797
+ type: "validation";
7798
+ on: string;
7799
+ summary?: string;
7800
+ message?: string;
7801
+ found?: unknown;
7802
+ property?: string;
7803
+ expected?: string;
7804
+ };
7805
+ };
7806
+ };
7807
+ };
7808
+ };
7809
+ } & {
7810
+ template: {
7811
+ ":id": {
7812
+ put: {
7813
+ body: {
7814
+ name?: string | undefined;
7815
+ companyId?: string | null | undefined;
7816
+ oldId?: number | null | undefined;
7817
+ isActive?: boolean | undefined;
7818
+ description?: string | null | undefined;
7819
+ version?: string | null | undefined;
7820
+ };
7821
+ params: {
7822
+ id: string;
7823
+ };
7824
+ query: unknown;
7825
+ headers: unknown;
7826
+ response: {
7827
+ 404: "Үзлэгийн загвар олдсонгүй.";
7828
+ 422: {
7829
+ type: "validation";
7830
+ on: string;
7831
+ summary?: string;
7832
+ message?: string;
7833
+ found?: unknown;
7834
+ property?: string;
7835
+ expected?: string;
7836
+ };
7837
+ };
7838
+ };
7839
+ };
7840
+ };
7841
+ } & {
7842
+ template: {
7843
+ ":id": {
7844
+ delete: {
7845
+ body: unknown;
7846
+ params: {
7847
+ id: string;
7848
+ };
7849
+ query: unknown;
7850
+ headers: unknown;
7851
+ response: {
7852
+ 422: {
7853
+ type: "validation";
7854
+ on: string;
7855
+ summary?: string;
7856
+ message?: string;
7857
+ found?: unknown;
7858
+ property?: string;
7859
+ expected?: string;
7860
+ };
7861
+ };
7862
+ };
7863
+ };
7864
+ };
7865
+ } & {
7866
+ template: {
7867
+ ":id": {
7868
+ field: {
7869
+ get: {
7870
+ body: unknown;
7871
+ params: {
7872
+ id: string;
7873
+ };
7874
+ query: unknown;
7875
+ headers: unknown;
7876
+ response: {
7877
+ 200: {
7878
+ templateId: string;
7879
+ fieldGroupId: string | null;
7880
+ fieldGroup: string | null;
7881
+ fieldId: string;
7882
+ code: string | null;
7883
+ description: string | null;
7884
+ fieldType: "BOOLEAN" | "NUMERIC" | "TEXT" | "DATE" | "RATE" | "MULTI_CHOICE";
7885
+ required: boolean;
7886
+ metadata: unknown;
7887
+ sortIndex: number | null;
7888
+ id: string;
7889
+ createdAt: string;
7890
+ updatedAt: string;
7891
+ deletedAt: string | null;
7892
+ oldId: number | null;
7893
+ }[];
7894
+ 422: {
7895
+ type: "validation";
7896
+ on: string;
7897
+ summary?: string;
7898
+ message?: string;
7899
+ found?: unknown;
7900
+ property?: string;
7901
+ expected?: string;
7902
+ };
7903
+ };
7904
+ };
7905
+ };
7906
+ };
7907
+ };
7908
+ } & {
7909
+ template: {
7910
+ ":id": {
7911
+ field: {
7912
+ post: {
7913
+ body: {
7914
+ required?: boolean | undefined;
7915
+ code?: string | null | undefined;
7916
+ oldId?: number | null | undefined;
7917
+ description?: string | null | undefined;
7918
+ metadata?: import("drizzle-typebox").Json | undefined;
7919
+ fieldGroup?: string | null | undefined;
7920
+ sortIndex?: number | null | undefined;
7921
+ fieldGroupId?: string | null | undefined;
7922
+ fieldId: string;
7923
+ fieldType: "BOOLEAN" | "NUMERIC" | "TEXT" | "DATE" | "RATE" | "MULTI_CHOICE";
7924
+ };
7925
+ params: {
7926
+ id: string;
7927
+ };
7928
+ query: unknown;
7929
+ headers: unknown;
7930
+ response: {
7931
+ 422: {
7932
+ type: "validation";
7933
+ on: string;
7934
+ summary?: string;
7935
+ message?: string;
7936
+ found?: unknown;
7937
+ property?: string;
7938
+ expected?: string;
7939
+ };
7940
+ };
7941
+ };
7942
+ };
7943
+ };
7944
+ };
7945
+ } & {
7946
+ template: {
7947
+ field: {
7948
+ ":id": {
7949
+ delete: {
7950
+ body: unknown;
7951
+ params: {
7952
+ id: string;
7953
+ };
7954
+ query: unknown;
7955
+ headers: unknown;
7956
+ response: {
7957
+ 422: {
7958
+ type: "validation";
7959
+ on: string;
7960
+ summary?: string;
7961
+ message?: string;
7962
+ found?: unknown;
7963
+ property?: string;
7964
+ expected?: string;
7965
+ };
7966
+ };
7967
+ };
7968
+ };
7969
+ };
7970
+ };
7971
+ };
7972
+ };
7973
+ };
7372
7974
  }, {
7373
7975
  derive: {};
7374
7976
  resolve: {};
package/dist/index.js CHANGED
@@ -146707,6 +146707,10 @@ var updateConditions = {
146707
146707
  optional: () => true,
146708
146708
  nullable: (column) => !column.notNull
146709
146709
  };
146710
+ var createInsertSchema = (entity, refine4) => {
146711
+ const columns = getColumns(entity);
146712
+ return handleColumns(columns, refine4 ?? {}, insertConditions);
146713
+ };
146710
146714
  function createSchemaFactory(options) {
146711
146715
  const createSelectSchema = (entity, refine4) => {
146712
146716
  if (isPgEnum2(entity)) {
@@ -146715,7 +146719,7 @@ function createSchemaFactory(options) {
146715
146719
  const columns = getColumns(entity);
146716
146720
  return handleColumns(columns, refine4 ?? {}, selectConditions, options);
146717
146721
  };
146718
- const createInsertSchema = (entity, refine4) => {
146722
+ const createInsertSchema2 = (entity, refine4) => {
146719
146723
  const columns = getColumns(entity);
146720
146724
  return handleColumns(columns, refine4 ?? {}, insertConditions, options);
146721
146725
  };
@@ -146723,18 +146727,18 @@ function createSchemaFactory(options) {
146723
146727
  const columns = getColumns(entity);
146724
146728
  return handleColumns(columns, refine4 ?? {}, updateConditions, options);
146725
146729
  };
146726
- return { createSelectSchema, createInsertSchema, createUpdateSchema };
146730
+ return { createSelectSchema, createInsertSchema: createInsertSchema2, createUpdateSchema };
146727
146731
  }
146728
146732
 
146729
146733
  // src/lib/validation-factory.ts
146730
- var { createSelectSchema, createUpdateSchema, createInsertSchema } = createSchemaFactory({
146734
+ var { createSelectSchema, createUpdateSchema, createInsertSchema: createInsertSchema2 } = createSchemaFactory({
146731
146735
  typeboxInstance: t
146732
146736
  });
146733
146737
 
146734
146738
  // src/routes/company/account/model.ts
146735
146739
  var CompanyAccountModel;
146736
146740
  ((CompanyAccountModel) => {
146737
- const createSchema = createInsertSchema(companyAccountTable);
146741
+ const createSchema = createInsertSchema2(companyAccountTable);
146738
146742
  const updateSchema = createUpdateSchema(companyAccountTable);
146739
146743
  const selectSchema = createSelectSchema(companyAccountTable);
146740
146744
  CompanyAccountModel.create = OmitBaseSchema(createSchema);
@@ -146789,7 +146793,7 @@ var logic_default2 = CompanyBranchLogic;
146789
146793
  var phoneRegex = /^\d{8}$/;
146790
146794
  var CompanyBranchModel;
146791
146795
  ((CompanyBranchModel) => {
146792
- const createSchema = createInsertSchema(companyBranchTable, {
146796
+ const createSchema = createInsertSchema2(companyBranchTable, {
146793
146797
  phone: (schema4) => t.RegExp(phoneRegex, { ...schema4 }),
146794
146798
  email: (schema4) => t.String({ ...schema4, format: "email" }),
146795
146799
  merchantId: (schema4) => t.Optional(schema4)
@@ -146831,7 +146835,7 @@ var branch_default = branchRoutes;
146831
146835
  // src/routes/company/company/model.ts
146832
146836
  var CompanyCompanyModel;
146833
146837
  ((CompanyCompanyModel) => {
146834
- const createSchema = createInsertSchema(companyCompanyTable);
146838
+ const createSchema = createInsertSchema2(companyCompanyTable);
146835
146839
  const updateSchema = createUpdateSchema(companyCompanyTable);
146836
146840
  const selectSchema = createSelectSchema(companyCompanyTable, {
146837
146841
  phone: t.RegExp(/^\d{8}$/),
@@ -146880,7 +146884,7 @@ var company_default = companyRoutes;
146880
146884
  // src/routes/company/employee/model.ts
146881
146885
  var CompanyEmployeeModel;
146882
146886
  ((CompanyEmployeeModel) => {
146883
- const createSchema = createInsertSchema(companyEmployeeTable);
146887
+ const createSchema = createInsertSchema2(companyEmployeeTable);
146884
146888
  const updateSchema = createUpdateSchema(companyEmployeeTable);
146885
146889
  const selectSchema = createSelectSchema(companyEmployeeTable, {
146886
146890
  phone: t.RegExp(/^\d{8}$/),
@@ -146960,7 +146964,7 @@ var employee_default = companyRoutes2;
146960
146964
  // src/routes/company/package/model.ts
146961
146965
  var CompanyPackageModel;
146962
146966
  ((CompanyPackageModel) => {
146963
- const createSchema = createInsertSchema(companyPackageTable);
146967
+ const createSchema = createInsertSchema2(companyPackageTable);
146964
146968
  const updateSchema = createUpdateSchema(companyPackageTable);
146965
146969
  CompanyPackageModel.create = OmitBaseSchema(createSchema);
146966
146970
  CompanyPackageModel.update = OmitBaseSchema(updateSchema);
@@ -147041,7 +147045,7 @@ var logic_default4 = CompanyServiceKindLogic;
147041
147045
  // src/routes/company/serviceKind/model.ts
147042
147046
  var CompanyServiceKindModel;
147043
147047
  ((CompanyServiceKindModel) => {
147044
- const createSchema = createInsertSchema(companyServiceKindTable);
147048
+ const createSchema = createInsertSchema2(companyServiceKindTable);
147045
147049
  const updateSchema = createUpdateSchema(companyServiceKindTable);
147046
147050
  const selectSchema = createSelectSchema(companyServiceKindTable);
147047
147051
  CompanyServiceKindModel.create = t.Omit(OmitBaseSchema(createSchema), ["companyId"]);
@@ -150110,7 +150114,12 @@ var CrmVehicleLogic;
150110
150114
  yearImport: new Date(atutData.imported_date).getFullYear(),
150111
150115
  engineCode: atutData.engine_model_name
150112
150116
  };
150113
- const [result] = await tdb.insert(crmVehicleTable).values(insertData).returning();
150117
+ const [result] = await tdb.insert(crmVehicleTable).values(insertData).onConflictDoUpdate({
150118
+ target: crmVehicleTable.vin,
150119
+ set: {
150120
+ licensePlate: insertData.licensePlate
150121
+ }
150122
+ }).returning();
150114
150123
  return result;
150115
150124
  };
150116
150125
  CrmVehicleLogic.select = async (query, user2) => {
@@ -150142,7 +150151,7 @@ var CrmVehicleLogic;
150142
150151
  return vehicle;
150143
150152
  };
150144
150153
  CrmVehicleLogic.update = async (id, body, user2) => {
150145
- const [result] = await db_default.update(crmVehicleTable).set(body).where(and(eq(crmVehicleTable.id, id), eq(crmVehicleTable.companyId, user2.companyId), softDeletedFilter(crmVehicleTable))).returning();
150154
+ const [result] = await db_default.update(crmVehicleTable).set(body).where(and(eq(crmVehicleTable.id, id), or(eq(crmVehicleTable.companyId, user2.companyId), isNull2(crmVehicleTable.companyId)), softDeletedFilter(crmVehicleTable))).returning();
150146
150155
  if (!result) {
150147
150156
  return status("Not Found", "\u0422\u044D\u044D\u0432\u0440\u0438\u0439\u043D \u0445\u044D\u0440\u044D\u0433\u0441\u044D\u043B \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
150148
150157
  }
@@ -151470,7 +151479,7 @@ var logic_default15 = CrmCpOrderItemEmployeeLogic;
151470
151479
  // src/routes/crm/cpOrder/item/employee/model.ts
151471
151480
  var CrmCpOrderItemEmployeeModel;
151472
151481
  ((CrmCpOrderItemEmployeeModel) => {
151473
- const createSchema = createInsertSchema(crmCpOrderItemEmployeeTable);
151482
+ const createSchema = createInsertSchema2(crmCpOrderItemEmployeeTable);
151474
151483
  const updateSchema = createUpdateSchema(crmCpOrderItemEmployeeTable);
151475
151484
  CrmCpOrderItemEmployeeModel.create = OmitBaseSchema(createSchema);
151476
151485
  CrmCpOrderItemEmployeeModel.update = t.Pick(OmitBaseSchema(updateSchema), ["amount"]);
@@ -151500,7 +151509,7 @@ var employee_default2 = employeeRoutes;
151500
151509
  // src/routes/crm/cpOrder/item/model.ts
151501
151510
  var CrmCpOrderItemModel;
151502
151511
  ((CrmCpOrderItemModel) => {
151503
- const createSchema = createInsertSchema(crmCpOrderItemTable);
151512
+ const createSchema = createInsertSchema2(crmCpOrderItemTable);
151504
151513
  const updateSchema = createUpdateSchema(crmCpOrderItemTable);
151505
151514
  CrmCpOrderItemModel.create = t.Composite([
151506
151515
  t.Pick(OmitBaseSchema(createSchema), [
@@ -151619,7 +151628,7 @@ var model_default9 = CrmCpOrderModel;
151619
151628
  // src/routes/crm/cpOrder/payment/model.ts
151620
151629
  var CrmCpOrderPaymentModel;
151621
151630
  ((CrmCpOrderPaymentModel) => {
151622
- const createSchema = createInsertSchema(crmCpOrderPaymentTable);
151631
+ const createSchema = createInsertSchema2(crmCpOrderPaymentTable);
151623
151632
  CrmCpOrderPaymentModel.create = t.Omit(OmitBaseSchema(createSchema), ["invoiceNumber"]);
151624
151633
  CrmCpOrderPaymentModel.storepay = t.Composite([
151625
151634
  t.Omit(CrmCpOrderPaymentModel.create, ["paymentMethod", "paymentChannel", "state"]),
@@ -151756,7 +151765,7 @@ var cpOrder_default = cpOrderRoutes;
151756
151765
  // src/routes/crm/customer/model.ts
151757
151766
  var CrmCustomerModel;
151758
151767
  ((CrmCustomerModel) => {
151759
- const createSchema = createInsertSchema(crmCustomerTable);
151768
+ const createSchema = createInsertSchema2(crmCustomerTable);
151760
151769
  CrmCustomerModel.create = OmitBaseSchema(createSchema);
151761
151770
  const updateSchema = createUpdateSchema(crmCustomerTable);
151762
151771
  CrmCustomerModel.update = OmitBaseSchema(updateSchema);
@@ -151866,7 +151875,7 @@ var dashboard_default = dashboardRoutes;
151866
151875
  // src/routes/crm/discount/model.ts
151867
151876
  var DiscountModel;
151868
151877
  ((DiscountModel) => {
151869
- const createSchema = createInsertSchema(crmDiscountTable);
151878
+ const createSchema = createInsertSchema2(crmDiscountTable);
151870
151879
  const updateSchema = createUpdateSchema(crmDiscountTable);
151871
151880
  DiscountModel.create = OmitBaseSchema(createSchema);
151872
151881
  DiscountModel.update = OmitBaseSchema(updateSchema);
@@ -151927,7 +151936,7 @@ var DiscountModel;
151927
151936
  ], {
151928
151937
  description: "Condition value based on the condition type selected"
151929
151938
  });
151930
- const createConditionSchema = createInsertSchema(crmDiscountConditionTable);
151939
+ const createConditionSchema = createInsertSchema2(crmDiscountConditionTable);
151931
151940
  const updateConditionSchema = createUpdateSchema(crmDiscountConditionTable);
151932
151941
  DiscountModel.createCondition = t.Composite([
151933
151942
  OmitBaseSchema(createConditionSchema),
@@ -151941,7 +151950,7 @@ var DiscountModel;
151941
151950
  conditionValue: ConditionValueUnion
151942
151951
  }))
151943
151952
  ]);
151944
- const createApplySchema = createInsertSchema(crmDiscountApplyTable);
151953
+ const createApplySchema = createInsertSchema2(crmDiscountApplyTable);
151945
151954
  DiscountModel.createApply = t.Omit(OmitBaseSchema(createApplySchema), [
151946
151955
  "authUserId",
151947
151956
  "employeeId"
@@ -152138,6 +152147,41 @@ var CrmInspectionLogic;
152138
152147
  }).from(crmInspectionTable).where(eq(crmInspectionTable.licensePlate, licensePlate)).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)).orderBy(desc(crmInspectionTable.createdAt));
152139
152148
  return inspections;
152140
152149
  };
152150
+ CrmInspectionLogic.selectAdmin = async (query) => {
152151
+ const baseQuery = db_default.select({
152152
+ company: {
152153
+ id: companyCompanyTable.id,
152154
+ name: companyCompanyTable.name,
152155
+ serviceName: companyCompanyTable.serviceName,
152156
+ logoUrl: companyCompanyTable.logoUrl
152157
+ },
152158
+ vehicle: {
152159
+ licensePlate: crmVehicleTable.licensePlate,
152160
+ vin: crmVehicleTable.vin,
152161
+ model: techdocVehicleKindTable.name
152162
+ },
152163
+ employee: {
152164
+ firstname: companyEmployeeTable.firstname,
152165
+ lastname: companyEmployeeTable.lastname
152166
+ },
152167
+ inspection: {
152168
+ inspection: crmInspectionTable.inspection,
152169
+ createdAt: crmInspectionTable.createdAt,
152170
+ expireAt: crmInspectionTable.expireAt,
152171
+ status: crmInspectionTable.status
152172
+ },
152173
+ totalCount: totalCountSql
152174
+ }).from(crmInspectionTable).where(eq(crmInspectionTable.companyId, query.companyId).if(query.companyId)).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)).orderBy(desc(crmInspectionTable.createdAt)).$dynamic();
152175
+ const result = await pagination_helper_default(baseQuery, query.pagination);
152176
+ const content = {
152177
+ totalCount: result[0]?.totalCount ?? 0,
152178
+ totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
152179
+ };
152180
+ return {
152181
+ result,
152182
+ ...content
152183
+ };
152184
+ };
152141
152185
  })(CrmInspectionLogic ||= {});
152142
152186
  var logic_default17 = CrmInspectionLogic;
152143
152187
 
@@ -152170,6 +152214,12 @@ var CrmInspectionModel;
152170
152214
  CrmInspectionModel.selectUbCab = t.Object({
152171
152215
  licensePlate: t.String()
152172
152216
  });
152217
+ CrmInspectionModel.selectAdmin = t.Composite([
152218
+ t.Partial(t.Object({
152219
+ companyId: t.String({ format: "uuid" })
152220
+ })),
152221
+ PaginationSchema
152222
+ ]);
152173
152223
  })(CrmInspectionModel ||= {});
152174
152224
  var model_default13 = CrmInspectionModel;
152175
152225
 
@@ -152184,6 +152234,9 @@ var inspectionRoutes = new Elysia({
152184
152234
  query: model_default13.select
152185
152235
  }).post("/", async ({ body, user: user2 }) => logic_default17.create(body, user2), {
152186
152236
  body: model_default13.create
152237
+ }).get("/admin", async ({ query }) => logic_default17.selectAdmin(query), {
152238
+ query: model_default13.selectAdmin,
152239
+ userKind: "ADMIN"
152187
152240
  }).guard({
152188
152241
  params: IdSchema
152189
152242
  }).get("/:id", async ({ params: { id }, user: user2 }) => logic_default17.getById(id, user2)).post("/:id", async ({ params: { id }, user: user2 }) => logic_default17.approve(id, user2)).put("/:id", async ({ params: { id }, user: user2 }) => logic_default17.cancel(id, user2)).post("/:id/service-order", async ({ params: { id }, user: user2 }) => logic_default17.createCpOrder(id, user2));
@@ -152676,7 +152729,7 @@ var reports_default = reportsRoutes;
152676
152729
  // src/routes/crm/spPackage/model.ts
152677
152730
  var CrmSpPackageModel;
152678
152731
  ((CrmSpPackageModel) => {
152679
- const createSchema = createInsertSchema(crmSpPackageTable);
152732
+ const createSchema = createInsertSchema2(crmSpPackageTable);
152680
152733
  const updateSchema = createUpdateSchema(crmSpPackageTable);
152681
152734
  const selectSchema = createSelectSchema(crmSpPackageTable);
152682
152735
  CrmSpPackageModel.create = t.Omit(OmitBaseSchema(createSchema), ["companyId"]);
@@ -152737,7 +152790,7 @@ var logic_default19 = CrmSpPackageProductLogic;
152737
152790
  // src/routes/crm/spPackage/product/model.ts
152738
152791
  var CrmSpPackageProductModel;
152739
152792
  ((CrmSpPackageProductModel) => {
152740
- const createSchema = createInsertSchema(crmSpPackageProductTable);
152793
+ const createSchema = createInsertSchema2(crmSpPackageProductTable);
152741
152794
  const updateSchema = createUpdateSchema(crmSpPackageProductTable);
152742
152795
  const selectSchema = createSelectSchema(crmSpPackageProductTable);
152743
152796
  CrmSpPackageProductModel.create = t.Omit(OmitBaseSchema(createSchema), ["priceTotal"]);
@@ -152810,7 +152863,7 @@ var logic_default20 = CrmSpPackageServiceLogic;
152810
152863
  // src/routes/crm/spPackage/service/model.ts
152811
152864
  var CrmSpPackageServiceModel;
152812
152865
  ((CrmSpPackageServiceModel) => {
152813
- const createSchema = createInsertSchema(crmSpPackageServiceTable);
152866
+ const createSchema = createInsertSchema2(crmSpPackageServiceTable);
152814
152867
  const updateSchema = createUpdateSchema(crmSpPackageServiceTable);
152815
152868
  const selectSchema = createSelectSchema(crmSpPackageServiceTable);
152816
152869
  CrmSpPackageServiceModel.create = OmitBaseSchema(createSchema);
@@ -152894,6 +152947,7 @@ var vehicleRoutes = new Elysia({
152894
152947
  })
152895
152948
  }).post("/get", async ({ body }) => {
152896
152949
  const res = await db_default.select({
152950
+ id: crmVehicleTable.id,
152897
152951
  licensePlate: crmVehicleTable.licensePlate,
152898
152952
  yearImported: crmVehicleTable.yearImport,
152899
152953
  yearManufactured: crmVehicleTable.yearManufacture,
@@ -153198,7 +153252,7 @@ var logic_default21 = PermissionLogic;
153198
153252
  // src/routes/permission/model.ts
153199
153253
  var PermissionModel;
153200
153254
  ((PermissionModel) => {
153201
- const createSchema = createInsertSchema(permissionGroupTable);
153255
+ const createSchema = createInsertSchema2(permissionGroupTable);
153202
153256
  const updateSchema = createUpdateSchema(permissionGroupTable);
153203
153257
  PermissionModel.create = OmitBaseSchema(createSchema);
153204
153258
  PermissionModel.update = OmitBaseSchema(updateSchema);
@@ -153302,7 +153356,7 @@ var TechdocSupplierModel;
153302
153356
  byCompany: t.Boolean()
153303
153357
  }))
153304
153358
  ]);
153305
- const createSchema = createInsertSchema(techdocSupplierTable);
153359
+ const createSchema = createInsertSchema2(techdocSupplierTable);
153306
153360
  TechdocSupplierModel.create = OmitBaseSchema(createSchema);
153307
153361
  const updateSchema = createUpdateSchema(techdocSupplierTable);
153308
153362
  TechdocSupplierModel.update = OmitBaseSchema(updateSchema);
@@ -153549,7 +153603,7 @@ var logic_default23 = UserLogic;
153549
153603
 
153550
153604
  // src/routes/user/schema.ts
153551
153605
  var select = createSelectSchema(user);
153552
- var create2 = createInsertSchema(user);
153606
+ var create2 = createInsertSchema2(user);
153553
153607
  var update = createUpdateSchema(user);
153554
153608
  var selectUserSchema = t.Composite([
153555
153609
  PaginationSchema,
@@ -153624,7 +153678,7 @@ var user_default2 = userRoutes;
153624
153678
  // src/routes/warehouse/product/model.ts
153625
153679
  var WarehouseProductModel;
153626
153680
  ((WarehouseProductModel) => {
153627
- const createSchema = createInsertSchema(warehouseProductTable);
153681
+ const createSchema = createInsertSchema2(warehouseProductTable);
153628
153682
  const updateSchema = createUpdateSchema(warehouseProductTable);
153629
153683
  WarehouseProductModel.create = t.Omit(OmitBaseSchema(createSchema), ["companyId"]);
153630
153684
  WarehouseProductModel.update = OmitBaseSchema(updateSchema);
@@ -153648,7 +153702,7 @@ var model_default22 = WarehouseProductModel;
153648
153702
  // src/routes/warehouse/item/model.ts
153649
153703
  var WarehouseItemModel;
153650
153704
  ((WarehouseItemModel) => {
153651
- const createSchema = createInsertSchema(warehouseItemTable);
153705
+ const createSchema = createInsertSchema2(warehouseItemTable);
153652
153706
  const updateSchema = createUpdateSchema(warehouseItemTable);
153653
153707
  WarehouseItemModel.create = OmitBaseSchema(createSchema);
153654
153708
  WarehouseItemModel.update = t.Composite([
@@ -153692,7 +153746,7 @@ var WarehouseItemModel;
153692
153746
  maxQuantity: t.Number({ minimum: 0 })
153693
153747
  }))
153694
153748
  ]);
153695
- const createTransactionSchema = createInsertSchema(warehouseItemTransactionTable);
153749
+ const createTransactionSchema = createInsertSchema2(warehouseItemTransactionTable);
153696
153750
  const transactionDetails = t.Pick(createTransactionSchema, [
153697
153751
  "transactionType",
153698
153752
  "transactionKind",
@@ -153795,7 +153849,7 @@ var logic_default24 = WarehouseWarehouseLogic;
153795
153849
  // src/routes/warehouse/warehouse/model.ts
153796
153850
  var WarehouseWarehouseModel;
153797
153851
  ((WarehouseWarehouseModel) => {
153798
- const createSchema = createInsertSchema(warehouseWarehouseTable);
153852
+ const createSchema = createInsertSchema2(warehouseWarehouseTable);
153799
153853
  const updateSchema = createUpdateSchema(warehouseWarehouseTable);
153800
153854
  WarehouseWarehouseModel.create = t.Omit(OmitBaseSchema(createSchema), ["companyId"]);
153801
153855
  WarehouseWarehouseModel.update = t.Omit(OmitBaseSchema(updateSchema), [
@@ -153832,10 +153886,228 @@ var warehouseSchemaRoutes = new Elysia({
153832
153886
  }).use(product_default3).use(warehouse_default).use(item_default3);
153833
153887
  var warehouse_default2 = warehouseSchemaRoutes;
153834
153888
 
153889
+ // src/routes/fleet/inspection/field/logic.ts
153890
+ var InspectionFieldLogic;
153891
+ ((InspectionFieldLogic) => {
153892
+ InspectionFieldLogic.select = async (groupId) => {
153893
+ const result = await db_default.select().from(inspectionFieldTable).where(eq(inspectionFieldTable.groupId, groupId));
153894
+ return result;
153895
+ };
153896
+ InspectionFieldLogic.create = async (body) => {
153897
+ await db_default.insert(inspectionFieldTable).values(body);
153898
+ };
153899
+ InspectionFieldLogic.update = async (id, body) => {
153900
+ await db_default.update(inspectionFieldTable).set(body).where(eq(inspectionFieldTable.id, id));
153901
+ };
153902
+ InspectionFieldLogic.remove = async (id) => {
153903
+ await db_default.update(inspectionFieldTable).set({
153904
+ deletedAt: sql3`now()`
153905
+ }).where(eq(inspectionFieldTable.id, id));
153906
+ };
153907
+ })(InspectionFieldLogic ||= {});
153908
+ var logic_default25 = InspectionFieldLogic;
153909
+
153910
+ // src/routes/fleet/inspection/field/model.ts
153911
+ var InspectionFieldModel;
153912
+ ((InspectionFieldModel) => {
153913
+ const createSchema = createInsertSchema(inspectionFieldTable);
153914
+ const updateSchema = createInsertSchema(inspectionFieldTable);
153915
+ InspectionFieldModel.create = OmitBaseSchema(createSchema);
153916
+ InspectionFieldModel.update = OmitBaseSchema(updateSchema);
153917
+ })(InspectionFieldModel ||= {});
153918
+ var model_default25 = InspectionFieldModel;
153919
+
153920
+ // src/routes/fleet/inspection/field/index.ts
153921
+ var fieldRoutes = new Elysia({
153922
+ prefix: "/field",
153923
+ tags: ["InspectionField"]
153924
+ }).use(better_auth_default).guard({
153925
+ userKind: "ADMIN"
153926
+ }).post("/", async ({ body }) => logic_default25.create(body), {
153927
+ body: model_default25.create
153928
+ }).guard({
153929
+ params: IdSchema
153930
+ }).put("/:id", async ({ body, params: { id } }) => logic_default25.update(id, body), {
153931
+ body: model_default25.update
153932
+ }).delete("/:id", async ({ params: { id } }) => logic_default25.remove(id));
153933
+ var field_default = fieldRoutes;
153934
+
153935
+ // src/routes/fleet/inspection/fieldGroup/logic.ts
153936
+ var InspectionFieldGroupLogic;
153937
+ ((InspectionFieldGroupLogic) => {
153938
+ InspectionFieldGroupLogic.select = async (query) => {
153939
+ const filter = and(softDeletedFilter(inspectionFieldGroupTable), ilike(inspectionFieldGroupTable.name, `%${query.name}%`).if(query.name), ilike(inspectionFieldGroupTable.code, `%${query.code}%`).if(query.code));
153940
+ const columns = getTableColumns(inspectionFieldGroupTable);
153941
+ const baseQuery = db_default.select({
153942
+ ...columns,
153943
+ totalCount: totalCountSql
153944
+ }).from(inspectionFieldGroupTable).where(filter).$dynamic();
153945
+ const result = await pagination_helper_default(baseQuery, query.pagination);
153946
+ const content = {
153947
+ totalCount: result[0]?.totalCount ?? 0,
153948
+ totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
153949
+ };
153950
+ return {
153951
+ result,
153952
+ ...content
153953
+ };
153954
+ };
153955
+ InspectionFieldGroupLogic.create = async (body) => {
153956
+ await db_default.insert(inspectionFieldGroupTable).values(body);
153957
+ };
153958
+ InspectionFieldGroupLogic.update = async (id, body) => {
153959
+ await db_default.update(inspectionFieldGroupTable).set(body).where(eq(inspectionFieldGroupTable.id, id));
153960
+ };
153961
+ InspectionFieldGroupLogic.remove = async (id) => {
153962
+ await db_default.update(inspectionFieldGroupTable).set({
153963
+ deletedAt: sql3`now`
153964
+ }).where(eq(inspectionFieldGroupTable.id, id));
153965
+ };
153966
+ })(InspectionFieldGroupLogic ||= {});
153967
+ var logic_default26 = InspectionFieldGroupLogic;
153968
+
153969
+ // src/routes/fleet/inspection/fieldGroup/model.ts
153970
+ var InspectionFieldGroupModel;
153971
+ ((InspectionFieldGroupModel) => {
153972
+ const createSchema = createInsertSchema2(inspectionFieldGroupTable);
153973
+ const updateSchema = createUpdateSchema(inspectionFieldGroupTable);
153974
+ InspectionFieldGroupModel.create = OmitBaseSchema(createSchema);
153975
+ InspectionFieldGroupModel.update = OmitBaseSchema(updateSchema);
153976
+ InspectionFieldGroupModel.select = t.Composite([
153977
+ t.Partial(t.Object({
153978
+ name: t.String(),
153979
+ code: t.String()
153980
+ })),
153981
+ PaginationSchema
153982
+ ]);
153983
+ })(InspectionFieldGroupModel ||= {});
153984
+ var model_default26 = InspectionFieldGroupModel;
153985
+
153986
+ // src/routes/fleet/inspection/fieldGroup/index.ts
153987
+ var fieldGroupRoutes = new Elysia({
153988
+ prefix: "/field-group",
153989
+ tags: ["InspectionFieldGroup"]
153990
+ }).use(better_auth_default).guard({
153991
+ userKind: "ADMIN"
153992
+ }).get("/", async ({ query }) => logic_default26.select(query), {
153993
+ query: model_default26.select,
153994
+ userKind: undefined,
153995
+ auth: true
153996
+ }).post("/", async ({ body }) => logic_default26.create(body), {
153997
+ body: model_default26.create
153998
+ }).guard({
153999
+ params: IdSchema
154000
+ }).put("/:id", async ({ body, params: { id } }) => logic_default26.update(id, body), {
154001
+ body: model_default26.update
154002
+ }).delete("/:id", async ({ params: { id } }) => logic_default26.remove(id)).get("/:id/field", async ({ params: { id } }) => logic_default25.select(id));
154003
+ var fieldGroup_default = fieldGroupRoutes;
154004
+
154005
+ // src/routes/fleet/inspection/template/logic.ts
154006
+ var InspectionTemplateLogic;
154007
+ ((InspectionTemplateLogic) => {
154008
+ InspectionTemplateLogic.select = async (query, user2) => {
154009
+ const filter = or(eq(inspectionTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN"), isNull2(inspectionTemplateTable.companyId));
154010
+ const columns = getTableColumns(inspectionTemplateTable);
154011
+ const baseQuery = db_default.select({
154012
+ ...columns,
154013
+ totalCount: totalCountSql
154014
+ }).from(inspectionTemplateTable).where(filter).orderBy(desc(inspectionTemplateTable.createdAt)).$dynamic();
154015
+ const result = await pagination_helper_default(baseQuery, query.pagination);
154016
+ return getPaginationContent(result, query.pagination.size);
154017
+ };
154018
+ InspectionTemplateLogic.selectById = async (id, user2) => {
154019
+ const filter = and(eq(inspectionTemplateTable.id, id), softDeletedFilter(inspectionTemplateTable), or(eq(inspectionTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN"), isNull2(inspectionTemplateTable.companyId)));
154020
+ const [result] = await db_default.select().from(inspectionTemplateTable).where(filter).limit(1);
154021
+ if (!result) {
154022
+ return status("Not Found", "\u04AE\u0437\u043B\u044D\u0433\u0438\u0439\u043D \u0437\u0430\u0433\u0432\u0430\u0440 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
154023
+ }
154024
+ return result;
154025
+ };
154026
+ InspectionTemplateLogic.create = async (body, user2) => {
154027
+ await db_default.insert(inspectionTemplateTable).values({
154028
+ ...body,
154029
+ companyId: user2.kind !== "ADMIN" ? user2.companyId : body.companyId
154030
+ });
154031
+ };
154032
+ InspectionTemplateLogic.update = async (id, body, user2) => {
154033
+ const [res] = await db_default.update(inspectionTemplateTable).set(body).where(and(eq(inspectionTemplateTable.id, id), eq(inspectionTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN"))).returning({
154034
+ id: inspectionTemplateTable.id
154035
+ });
154036
+ if (!res) {
154037
+ return status("Not Found", "\u04AE\u0437\u043B\u044D\u0433\u0438\u0439\u043D \u0437\u0430\u0433\u0432\u0430\u0440 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
154038
+ }
154039
+ };
154040
+ InspectionTemplateLogic.remove = async (id, user2) => {
154041
+ await db_default.update(inspectionTemplateTable).set({
154042
+ deletedAt: sql3`now()`
154043
+ }).where(and(eq(inspectionTemplateTable.id, id), eq(inspectionTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")));
154044
+ };
154045
+ InspectionTemplateLogic.selectField = async (templateId) => {
154046
+ const result = await db_default.select().from(inspectionTemplateFieldTable).where(and(eq(inspectionTemplateFieldTable.templateId, templateId), softDeletedFilter(inspectionTemplateFieldTable)));
154047
+ return result;
154048
+ };
154049
+ InspectionTemplateLogic.addField = async (templateId, body) => {
154050
+ await db_default.insert(inspectionTemplateFieldTable).values({
154051
+ ...body,
154052
+ templateId
154053
+ });
154054
+ };
154055
+ InspectionTemplateLogic.removeField = async (id) => {
154056
+ await db_default.update(inspectionTemplateFieldTable).set({
154057
+ deletedAt: sql3`now()`
154058
+ }).where(eq(inspectionTemplateFieldTable.id, id));
154059
+ };
154060
+ })(InspectionTemplateLogic ||= {});
154061
+ var logic_default27 = InspectionTemplateLogic;
154062
+
154063
+ // src/routes/fleet/inspection/template/model.ts
154064
+ var InspectionTemplateModel;
154065
+ ((InspectionTemplateModel) => {
154066
+ const createSchema = createInsertSchema(inspectionTemplateTable);
154067
+ const updateSchema = createUpdateSchema(inspectionTemplateTable);
154068
+ const createFieldSchema = createInsertSchema(inspectionTemplateFieldTable);
154069
+ InspectionTemplateModel.create = OmitBaseSchema(createSchema);
154070
+ InspectionTemplateModel.update = OmitBaseSchema(updateSchema);
154071
+ InspectionTemplateModel.select = t.Composite([PaginationSchema]);
154072
+ InspectionTemplateModel.createField = t.Omit(OmitBaseSchema(createFieldSchema), [
154073
+ "templateId"
154074
+ ]);
154075
+ })(InspectionTemplateModel ||= {});
154076
+ var model_default27 = InspectionTemplateModel;
154077
+
154078
+ // src/routes/fleet/inspection/template/index.ts
154079
+ var templateRoutes = new Elysia({
154080
+ prefix: "/template",
154081
+ tags: ["InspectionTemplate"]
154082
+ }).use(better_auth_default).guard({
154083
+ userKind: "COMPANY_ADMIN"
154084
+ }).get("/", async ({ query, user: user2 }) => logic_default27.select(query, user2), {
154085
+ query: model_default27.select
154086
+ }).post("/", async ({ body, user: user2 }) => logic_default27.create(body, user2), {
154087
+ body: model_default27.create
154088
+ }).guard({
154089
+ params: IdSchema
154090
+ }).get("/:id", async ({ params: { id }, user: user2 }) => logic_default27.selectById(id, user2)).put("/:id", async ({ body, params: { id }, user: user2 }) => logic_default27.update(id, body, user2), {
154091
+ body: model_default27.update
154092
+ }).delete("/:id", async ({ params: { id }, user: user2 }) => logic_default27.remove(id, user2)).get("/:id/field", async ({ params: { id } }) => logic_default27.selectField(id)).post("/:id/field", async ({ body, params: { id } }) => logic_default27.addField(id, body), {
154093
+ body: model_default27.createField
154094
+ }).delete("/field/:id", async ({ params: { id } }) => logic_default27.removeField(id));
154095
+ var template_default = templateRoutes;
154096
+
154097
+ // src/routes/fleet/inspection/index.ts
154098
+ var inspectionRoutes2 = new Elysia({
154099
+ prefix: "/inspection"
154100
+ }).use(fieldGroup_default).use(field_default).use(template_default);
154101
+ var inspection_default2 = inspectionRoutes2;
154102
+
154103
+ // src/routes/fleet/index.ts
154104
+ var fleetRoutes = new Elysia({ prefix: "/fleet" }).use(inspection_default2);
154105
+ var fleet_default = fleetRoutes;
154106
+
153835
154107
  // src/routes/index.ts
153836
154108
  var router2 = new Elysia({
153837
154109
  prefix: "/api"
153838
- }).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default);
154110
+ }).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default).use(fleet_default);
153839
154111
  var routes_default = router2;
153840
154112
 
153841
154113
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.18",
3
+ "version": "1.2.20",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",