autosync_backend2 1.2.28 → 1.2.30

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/README.md CHANGED
@@ -1,25 +1,176 @@
1
- # Elysia with Bun runtime
1
+ # Autosync v2
2
2
 
3
- ## Getting Started
3
+ A comprehensive business management system built with **Elysia** (TypeScript web framework) and **Bun** runtime. The system provides CRM, inventory management, warehouse operations, fleet management, and company management capabilities.
4
4
 
5
- To get started with this template, simply paste this command into your terminal:
5
+ ## 🚀 Quick Start
6
+
7
+ ### Prerequisites
8
+
9
+ - [Bun](https://bun.sh) runtime (latest version)
10
+ - PostgreSQL database
11
+ - Redis (for caching and sessions)
12
+ - AWS S3 account (for file storage)
13
+ - SMTP credentials (for email)
14
+
15
+ ### Installation
16
+
17
+ 1. **Clone the repository**
18
+ ```bash
19
+ git clone <repository-url>
20
+ cd autosync-v2
21
+ ```
22
+
23
+ 2. **Install dependencies**
24
+ ```bash
25
+ bun install
26
+ ```
27
+
28
+ 3. **Set up environment variables**
29
+
30
+ Create a `.env` file with the following variables:
31
+ ```env
32
+ NODE_ENV=development
33
+ PORT=3000
34
+ BETTER_AUTH_SECRET=your-secret-key
35
+ DATABASE_URL=postgresql://user:password@localhost:5432/autosync
36
+ UPSTASH_REDIS_REST_URL=your-redis-url
37
+ UPSTASH_REDIS_REST_TOKEN=your-redis-token
38
+ SMTP_USER=your-smtp-user
39
+ SMTP_PASSWORD=your-smtp-password
40
+ ATUT_TOKEN=your-atut-token
41
+ AWS_ACCESS_KEY=your-aws-key
42
+ AWS_SECRET_KEY=your-aws-secret
43
+ ```
44
+
45
+ 4. **Run database migrations**
46
+ ```bash
47
+ bun run db:migrate
48
+ ```
49
+
50
+ 5. **Start the development server**
51
+ ```bash
52
+ bun run dev
53
+ ```
54
+
55
+ 6. **Access the application**
56
+ - API: <http://localhost:3000/api>
57
+ - Health Check: <http://localhost:3000/health>
58
+ - Swagger Documentation: <http://localhost:3000/swagger>
59
+
60
+ ## 📚 Documentation
61
+
62
+ - **[API Documentation](./docs/API.md)** - Complete API reference
63
+ - **[Project Structure](./docs/STRUCTURE.md)** - Architecture and code organization
64
+ - **[Project Index](./PROJECT_INDEX.md)** - High-level overview
65
+ - **[Claude Guide](./CLAUDE.md)** - Development guidelines for AI assistants
66
+
67
+ ## 🛠️ Development
68
+
69
+ ### Available Commands
6
70
 
7
71
  ```bash
8
- bun create elysia ./elysia-example
72
+ # Development
73
+ bun run dev # Start development server with auto-reload
74
+ bun run build # Compile TypeScript and generate declarations
75
+
76
+ # Database
77
+ bun run db:generate # Generate migration files from schema changes
78
+ bun run db:migrate # Apply database migrations
79
+
80
+ # Code Quality
81
+ bun run biome:check # Format and lint with auto-fix
82
+
83
+ # Email Development
84
+ bun run email # Start email template development server
85
+
86
+ # Testing
87
+ bun test # Run test suite
88
+ bun test:watch # Run tests in watch mode
9
89
  ```
10
90
 
11
- ## Development
91
+ ### Code Standards
92
+
93
+ - **Indentation**: Tabs
94
+ - **Quotes**: Double quotes
95
+ - **Validation**: TypeBox (not Zod)
96
+ - **Database Naming**: Snake_case
97
+ - **TypeScript Naming**: camelCase
12
98
 
13
- To start the development server run:
99
+ ## 🏗️ Architecture
100
+
101
+ The application follows a **domain-driven architecture** with the following main domains:
102
+
103
+ - **Company Management** - Multi-tenant company management with branches, employees, and service packages
104
+ - **CRM** - Customer relationship management with orders, payments, and service packages
105
+ - **Fleet Management** - Fleet and machine management with preventive maintenance and inspections
106
+ - **Warehouse Management** - Inventory and warehouse operations
107
+ - **Technical Documentation** - Technical documentation for suppliers and vehicle specifications
108
+ - **User & Permissions** - User authentication and role-based access control
109
+
110
+ Each domain follows a consistent pattern:
111
+ - `index.ts` - Route definitions and middleware
112
+ - `model.ts` - TypeBox validation schemas
113
+ - `logic.ts` - Business logic and database operations
114
+
115
+ ## 🗄️ Database
116
+
117
+ The system uses **PostgreSQL** with **Drizzle ORM** and a multi-schema design:
118
+
119
+ - `public` - Core application tables (auth, permissions)
120
+ - `crm` - Customer relationship management
121
+ - `company` - Organization management
122
+ - `warehouse` - Inventory and warehouse operations
123
+ - `techdoc` - Technical documentation
124
+ - `fleet` - Fleet management
125
+
126
+ ## 🔐 Authentication & Authorization
127
+
128
+ - **Authentication**: Better-auth library
129
+ - **Authorization**: Granular permission system with Redis caching
130
+ - **User Kinds**: ADMIN, COMPANY_ADMIN, CUSTOMER, EMPLOYEE
131
+
132
+ ## 📦 Key Technologies
133
+
134
+ - **Runtime**: Bun
135
+ - **Framework**: Elysia
136
+ - **Database**: PostgreSQL with Drizzle ORM
137
+ - **Authentication**: Better-auth
138
+ - **Validation**: TypeBox
139
+ - **Email**: React Email
140
+ - **Storage**: AWS S3
141
+ - **Caching**: Redis (Upstash)
142
+ - **Code Quality**: Biome
143
+
144
+ ## 🐳 Docker
145
+
146
+ ### Build and Deploy
14
147
 
15
148
  ```bash
16
- bun run dev
149
+ # Build and push to ECR
150
+ make build
151
+
152
+ # Build production image
153
+ make build_prod
17
154
  ```
18
155
 
19
- Open <http://localhost:3000/> with your browser to see the result.
156
+ ## 📝 Баазийн бүтэц
157
+
158
+ - [Байгууллага](./src/lib/db/schema/company.md)
159
+ - [Агуулах](./src/lib/db/schema/warehouse.schema.ts)
160
+
161
+ ## 🤝 Contributing
162
+
163
+ 1. Follow the code standards and patterns
164
+ 2. Update documentation when making changes
165
+ 3. Write tests for new features
166
+ 4. Use TypeBox for validation
167
+ 5. Follow the domain-driven structure
168
+
169
+ ## 📄 License
170
+
171
+ [Add your license information here]
20
172
 
21
- ## Баазийн бүтэц
173
+ ---
22
174
 
23
- - [Байгууллага](./src/lib/db/schema/merchant.md)
24
- - [Агуулах](./src/lib/db/schema/inventory.md)
175
+ For detailed documentation, see the [docs](./docs/) directory.
25
176
 
package/dist/index.d.ts CHANGED
@@ -577,7 +577,7 @@ export declare const app: Elysia<"", {
577
577
  body: unknown;
578
578
  params: {};
579
579
  query: {
580
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
580
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
581
581
  id?: string | undefined;
582
582
  search?: string | undefined;
583
583
  supplierId?: string | undefined;
@@ -607,7 +607,7 @@ export declare const app: Elysia<"", {
607
607
  partNumber: string;
608
608
  alias: string | null;
609
609
  companyId: string;
610
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
610
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
611
611
  quantityUnit: number;
612
612
  id: string;
613
613
  createdAt: string;
@@ -645,7 +645,7 @@ export declare const app: Elysia<"", {
645
645
  product: {
646
646
  post: {
647
647
  body: {
648
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
648
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
649
649
  oldId?: number | null | undefined;
650
650
  description?: string | null | undefined;
651
651
  productId?: string | null | undefined;
@@ -664,7 +664,7 @@ export declare const app: Elysia<"", {
664
664
  headers: unknown;
665
665
  response: {
666
666
  200: {
667
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
667
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
668
668
  name: string;
669
669
  id: string;
670
670
  createdAt: string;
@@ -701,7 +701,7 @@ export declare const app: Elysia<"", {
701
701
  many: {
702
702
  post: {
703
703
  body: {
704
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
704
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
705
705
  oldId?: number | null | undefined;
706
706
  description?: string | null | undefined;
707
707
  productId?: string | null | undefined;
@@ -745,7 +745,7 @@ export declare const app: Elysia<"", {
745
745
  body: unknown;
746
746
  params: {};
747
747
  query: {
748
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
748
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
749
749
  id?: string | undefined;
750
750
  search?: string | undefined;
751
751
  supplierId?: string | undefined;
@@ -776,7 +776,7 @@ export declare const app: Elysia<"", {
776
776
  ":id": {
777
777
  put: {
778
778
  body: {
779
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
779
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
780
780
  name?: string | undefined;
781
781
  companyId?: string | undefined;
782
782
  oldId?: number | null | undefined;
@@ -809,7 +809,7 @@ export declare const app: Elysia<"", {
809
809
  partNumber: string;
810
810
  alias: string | null;
811
811
  companyId: string;
812
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
812
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
813
813
  quantityUnit: number;
814
814
  id: string;
815
815
  createdAt: string;
@@ -989,7 +989,7 @@ export declare const app: Elysia<"", {
989
989
  query: {
990
990
  isActive?: boolean | undefined;
991
991
  product?: {
992
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
992
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
993
993
  id?: string | undefined;
994
994
  search?: string | undefined;
995
995
  supplierId?: string | undefined;
@@ -1051,7 +1051,7 @@ export declare const app: Elysia<"", {
1051
1051
  partNumber: string;
1052
1052
  alias: string | null;
1053
1053
  companyId: string;
1054
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
1054
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
1055
1055
  quantityUnit: number;
1056
1056
  id: string;
1057
1057
  createdAt: string;
@@ -1183,7 +1183,7 @@ export declare const app: Elysia<"", {
1183
1183
  userId?: string | undefined;
1184
1184
  orderId?: string | undefined;
1185
1185
  product?: {
1186
- type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | undefined;
1186
+ type?: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей" | undefined;
1187
1187
  id?: string | undefined;
1188
1188
  search?: string | undefined;
1189
1189
  supplierId?: string | undefined;
@@ -1223,7 +1223,7 @@ export declare const app: Elysia<"", {
1223
1223
  partNumber: string;
1224
1224
  alias: string | null;
1225
1225
  companyId: string;
1226
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
1226
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
1227
1227
  quantityUnit: number;
1228
1228
  id: string;
1229
1229
  createdAt: string;
@@ -3163,7 +3163,7 @@ export declare const app: Elysia<"", {
3163
3163
  partNumber: string;
3164
3164
  alias: string | null;
3165
3165
  companyId: string;
3166
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
3166
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
3167
3167
  quantityUnit: number;
3168
3168
  id: string;
3169
3169
  createdAt: string;
@@ -4612,7 +4612,7 @@ export declare const app: Elysia<"", {
4612
4612
  partNumber: string;
4613
4613
  alias: string | null;
4614
4614
  companyId: string;
4615
- type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор";
4615
+ type: "Сэлбэг" | "Тос" | "Дугуй" | "Будаг" | "Аккумлятор" | "Авто гоёл" | "Батерей";
4616
4616
  quantityUnit: number;
4617
4617
  id: string;
4618
4618
  createdAt: string;
@@ -8042,18 +8042,48 @@ export declare const app: Elysia<"", {
8042
8042
  totalCount: number;
8043
8043
  totalPage: number;
8044
8044
  result: Omit<{
8045
+ schedule: {
8046
+ companyId: string;
8047
+ machineId: string;
8048
+ templateId: string;
8049
+ daysInterval: number | null;
8050
+ timeNextDue: Date | null;
8051
+ isActive: boolean;
8052
+ id: string;
8053
+ createdAt: string;
8054
+ updatedAt: string;
8055
+ deletedAt: string | null;
8056
+ oldId: number | null;
8057
+ };
8058
+ machine: {
8059
+ companyId: string | null;
8060
+ machineKindId: string;
8061
+ customerId: string | null;
8062
+ name: string | null;
8063
+ assetCode: string | null;
8064
+ vin: string | null;
8065
+ licensePlate: string | null;
8066
+ color: string | null;
8067
+ engineCc: string | null;
8068
+ cylinder: string | null;
8069
+ gasType: string | null;
8070
+ transmissionType: string | null;
8071
+ vehicleType: string | null;
8072
+ yearManufacture: number | null;
8073
+ yearImport: number | null;
8074
+ steering: string | null;
8075
+ engineCode: string | null;
8076
+ transmissionCode: string | null;
8077
+ driveTrain: string | null;
8078
+ km: number;
8079
+ customData: unknown;
8080
+ id: string;
8081
+ createdAt: string;
8082
+ updatedAt: string;
8083
+ deletedAt: string | null;
8084
+ oldId: number | null;
8085
+ } | null;
8045
8086
  totalCount: number;
8046
- companyId: string;
8047
- machineId: string;
8048
- templateId: string;
8049
- daysInterval: number | null;
8050
- timeNextDue: Date | null;
8051
- isActive: boolean;
8052
- id: string;
8053
- createdAt: string;
8054
- updatedAt: string;
8055
- deletedAt: string | null;
8056
- oldId: number | null;
8057
8087
  }, "totalCount">[];
8058
8088
  };
8059
8089
  401: "Session not found";
@@ -8258,6 +8288,132 @@ export declare const app: Elysia<"", {
8258
8288
  fleet: {
8259
8289
  pm: {
8260
8290
  template: {};
8291
+ } & {
8292
+ template: {
8293
+ product: {};
8294
+ } & {
8295
+ product: {
8296
+ get: {
8297
+ body: unknown;
8298
+ params: {};
8299
+ query: {
8300
+ pagination: {
8301
+ size: number;
8302
+ page: number;
8303
+ };
8304
+ pmTemplateId: string;
8305
+ };
8306
+ headers: unknown;
8307
+ response: {
8308
+ 200: {
8309
+ totalCount: number;
8310
+ totalPage: number;
8311
+ result: Omit<{
8312
+ totalCount: number;
8313
+ pmTemplateId: string;
8314
+ productKindId: string;
8315
+ quantity: number | null;
8316
+ uomId: string;
8317
+ id: string;
8318
+ createdAt: string;
8319
+ updatedAt: string;
8320
+ deletedAt: string | null;
8321
+ oldId: number | null;
8322
+ }, "totalCount">[];
8323
+ };
8324
+ 422: {
8325
+ type: "validation";
8326
+ on: string;
8327
+ summary?: string;
8328
+ message?: string;
8329
+ found?: unknown;
8330
+ property?: string;
8331
+ expected?: string;
8332
+ };
8333
+ };
8334
+ };
8335
+ };
8336
+ } & {
8337
+ product: {
8338
+ post: {
8339
+ body: {
8340
+ oldId?: number | null | undefined;
8341
+ quantity?: number | null | undefined;
8342
+ uomId: string;
8343
+ pmTemplateId: string;
8344
+ productKindId: string;
8345
+ };
8346
+ params: {};
8347
+ query: unknown;
8348
+ headers: unknown;
8349
+ response: {
8350
+ 422: {
8351
+ type: "validation";
8352
+ on: string;
8353
+ summary?: string;
8354
+ message?: string;
8355
+ found?: unknown;
8356
+ property?: string;
8357
+ expected?: string;
8358
+ };
8359
+ };
8360
+ };
8361
+ };
8362
+ } & {
8363
+ product: {
8364
+ ":id": {
8365
+ put: {
8366
+ body: {
8367
+ oldId?: number | null | undefined;
8368
+ quantity?: number | null | undefined;
8369
+ uomId?: string | undefined;
8370
+ pmTemplateId?: string | undefined;
8371
+ productKindId?: string | undefined;
8372
+ };
8373
+ params: {
8374
+ id: string;
8375
+ };
8376
+ query: unknown;
8377
+ headers: unknown;
8378
+ response: {
8379
+ 422: {
8380
+ type: "validation";
8381
+ on: string;
8382
+ summary?: string;
8383
+ message?: string;
8384
+ found?: unknown;
8385
+ property?: string;
8386
+ expected?: string;
8387
+ };
8388
+ };
8389
+ };
8390
+ };
8391
+ };
8392
+ } & {
8393
+ product: {
8394
+ ":id": {
8395
+ delete: {
8396
+ body: unknown;
8397
+ params: {
8398
+ id: string;
8399
+ };
8400
+ query: unknown;
8401
+ headers: unknown;
8402
+ response: {
8403
+ 422: {
8404
+ type: "validation";
8405
+ on: string;
8406
+ summary?: string;
8407
+ message?: string;
8408
+ found?: unknown;
8409
+ property?: string;
8410
+ expected?: string;
8411
+ };
8412
+ };
8413
+ };
8414
+ };
8415
+ };
8416
+ };
8261
8417
  } & {
8262
8418
  template: {
8263
8419
  get: {
package/dist/index.js CHANGED
@@ -142757,7 +142757,7 @@ var companyMachineTable = companySchema.table("machine", {
142757
142757
  customerId: uuid5(),
142758
142758
  name: varchar(),
142759
142759
  assetCode: varchar(),
142760
- vin: varchar().unique(),
142760
+ vin: varchar(),
142761
142761
  licensePlate: varchar(),
142762
142762
  color: varchar(),
142763
142763
  engineCc: varchar(),
@@ -143191,7 +143191,9 @@ var warehouseProductTypeEnum = warehouseSchema.enum("product_type", [
143191
143191
  "\u0422\u043E\u0441",
143192
143192
  "\u0414\u0443\u0433\u0443\u0439",
143193
143193
  "\u0411\u0443\u0434\u0430\u0433",
143194
- "\u0410\u043A\u043A\u0443\u043C\u043B\u044F\u0442\u043E\u0440"
143194
+ "\u0410\u043A\u043A\u0443\u043C\u043B\u044F\u0442\u043E\u0440",
143195
+ "\u0410\u0432\u0442\u043E \u0433\u043E\u0451\u043B",
143196
+ "\u0411\u0430\u0442\u0435\u0440\u0435\u0439"
143195
143197
  ]);
143196
143198
  var warehouseProductTable = warehouseSchema.table("product", {
143197
143199
  ...base_schema_helper_default,
@@ -154274,11 +154276,11 @@ var InspectionScheduleLogic;
154274
154276
  ((InspectionScheduleLogic) => {
154275
154277
  InspectionScheduleLogic.select = async (query, user2) => {
154276
154278
  const filter = and(softDeletedFilter(inspectionScheduleTable), eq(inspectionScheduleTable.companyId, user2.companyId));
154277
- const columns = getTableColumns(inspectionScheduleTable);
154278
154279
  const baseQuery = db_default.select({
154279
- ...columns,
154280
+ schedule: inspectionScheduleTable,
154281
+ machine: companyMachineTable,
154280
154282
  totalCount: totalCountSql
154281
- }).from(inspectionScheduleTable).where(filter).$dynamic();
154283
+ }).from(inspectionScheduleTable).where(filter).leftJoin(companyMachineTable, eq(inspectionScheduleTable.machineId, companyMachineTable.id)).$dynamic();
154282
154284
  const result = await pagination_helper_default(baseQuery, query.pagination);
154283
154285
  return getPaginationContent(result, query.pagination.size);
154284
154286
  };
@@ -154428,7 +154430,7 @@ var inspection_default2 = inspectionRoutes2;
154428
154430
  var MachineLogic;
154429
154431
  ((MachineLogic) => {
154430
154432
  MachineLogic.select = async (query, user2) => {
154431
- const filter = and(or(isNull2(companyMachineTable.companyId), eq(companyMachineTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")));
154433
+ const filter = and(or(isNull2(companyMachineTable.companyId), eq(companyMachineTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")), softDeletedFilter(companyMachineTable));
154432
154434
  const columns = getTableColumns(companyMachineTable);
154433
154435
  const baseQuery = db_default.select({
154434
154436
  ...columns,
@@ -154527,11 +154529,75 @@ var PmTemplateModel;
154527
154529
  })(PmTemplateModel ||= {});
154528
154530
  var model_default31 = PmTemplateModel;
154529
154531
 
154532
+ // src/routes/fleet/pm/template/product/logic.ts
154533
+ var PmTemplateProductLogic;
154534
+ ((PmTemplateProductLogic) => {
154535
+ PmTemplateProductLogic.select = async (query) => {
154536
+ const filter = and(softDeletedFilter(pmTemplateProductTable), eq(pmTemplateProductTable.pmTemplateId, query.pmTemplateId));
154537
+ const columns = getTableColumns(pmTemplateProductTable);
154538
+ const baseQuery = db_default.select({
154539
+ ...columns,
154540
+ totalCount: totalCountSql
154541
+ }).from(pmTemplateProductTable).where(filter).$dynamic();
154542
+ const result = await pagination_helper_default(baseQuery, query.pagination);
154543
+ return getPaginationContent(result, query.pagination.size);
154544
+ };
154545
+ PmTemplateProductLogic.create = async (body) => {
154546
+ await db_default.insert(pmTemplateProductTable).values({
154547
+ ...body
154548
+ });
154549
+ };
154550
+ PmTemplateProductLogic.update = async (id, body) => {
154551
+ await db_default.update(pmTemplateProductTable).set({
154552
+ ...body
154553
+ }).where(and(eq(pmTemplateProductTable.id, id)));
154554
+ };
154555
+ PmTemplateProductLogic.remove = async (id) => {
154556
+ await db_default.update(pmTemplateProductTable).set({
154557
+ deletedAt: nowSql_helper_default
154558
+ }).where(and(eq(pmTemplateProductTable.id, id)));
154559
+ };
154560
+ })(PmTemplateProductLogic ||= {});
154561
+ var logic_default32 = PmTemplateProductLogic;
154562
+
154563
+ // src/routes/fleet/pm/template/product/model.ts
154564
+ var PmTemplateProductModel;
154565
+ ((PmTemplateProductModel) => {
154566
+ const createSchema = createInsertSchema2(pmTemplateProductTable);
154567
+ const updateSchema = createUpdateSchema(pmTemplateProductTable);
154568
+ PmTemplateProductModel.create = OmitBaseSchema(createSchema);
154569
+ PmTemplateProductModel.update = OmitBaseSchema(updateSchema);
154570
+ PmTemplateProductModel.select = t.Composite([
154571
+ PaginationSchema,
154572
+ t.Object({
154573
+ pmTemplateId: t.String({ format: "uuid" })
154574
+ })
154575
+ ]);
154576
+ })(PmTemplateProductModel ||= {});
154577
+ var model_default32 = PmTemplateProductModel;
154578
+
154579
+ // src/routes/fleet/pm/template/product/index.ts
154580
+ var productRoutes4 = new Elysia({
154581
+ prefix: "/product",
154582
+ tags: ["PmTemplateProduct"]
154583
+ }).use(better_auth_default).guard({
154584
+ userKind: "COMPANY_ADMIN"
154585
+ }).get("/", async ({ query }) => logic_default32.select(query), {
154586
+ query: model_default32.select
154587
+ }).post("/", async ({ body }) => logic_default32.create(body), {
154588
+ body: model_default32.create
154589
+ }).guard({
154590
+ params: IdSchema
154591
+ }).put("/:id", async ({ body, params: { id } }) => logic_default32.update(id, body), {
154592
+ body: model_default32.update
154593
+ }).delete("/:id", async ({ params: { id } }) => logic_default32.remove(id));
154594
+ var product_default4 = productRoutes4;
154595
+
154530
154596
  // src/routes/fleet/pm/template/index.ts
154531
154597
  var templateRoutes2 = new Elysia({
154532
154598
  prefix: "/template",
154533
154599
  tags: ["PmTemplate"]
154534
- }).use(better_auth_default).guard({
154600
+ }).use(better_auth_default).use(product_default4).guard({
154535
154601
  userKind: "COMPANY_ADMIN"
154536
154602
  }).get("/", async ({ query, user: user2 }) => logic_default31.select(query, user2), {
154537
154603
  query: model_default31.select
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.28",
3
+ "version": "1.2.30",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",