autosync_backend2 1.2.29 → 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 +162 -11
- package/dist/index.d.ts +14 -14
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Autosync v2
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
149
|
+
# Build and push to ECR
|
|
150
|
+
make build
|
|
151
|
+
|
|
152
|
+
# Build production image
|
|
153
|
+
make build_prod
|
|
17
154
|
```
|
|
18
155
|
|
|
19
|
-
|
|
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
|
-
|
|
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;
|
package/dist/index.js
CHANGED
|
@@ -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,
|