@axova/shared 1.0.0 → 1.0.2

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.
Files changed (33) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -2
  3. package/dist/middleware/storeOwnership.js +3 -22
  4. package/dist/middleware/storeValidationMiddleware.js +39 -16
  5. package/dist/schemas/admin/admin-schema.d.ts +2 -2
  6. package/dist/schemas/ai-moderation/ai-moderation-schema.d.ts +2 -2
  7. package/dist/schemas/index.d.ts +0 -26
  8. package/dist/schemas/index.js +3 -121
  9. package/dist/schemas/store/storefront-config-schema.d.ts +1320 -0
  10. package/dist/schemas/store/storefront-config-schema.js +109 -0
  11. package/dist/utils/subdomain.d.ts +1 -1
  12. package/dist/utils/subdomain.js +15 -10
  13. package/package.json +1 -1
  14. package/src/index.ts +0 -3
  15. package/src/middleware/storeOwnership.ts +3 -21
  16. package/src/middleware/storeValidationMiddleware.ts +50 -17
  17. package/src/schemas/index.ts +5 -189
  18. package/src/utils/subdomain.ts +15 -11
  19. package/nul +0 -8
  20. package/src/schemas/compliance/compliance-schema.ts +0 -927
  21. package/src/schemas/compliance/kyc-schema.ts +0 -649
  22. package/src/schemas/customer/customer-schema.ts +0 -576
  23. package/src/schemas/inventory/inventory-tables.ts +0 -1927
  24. package/src/schemas/inventory/lot-tables.ts +0 -799
  25. package/src/schemas/order/order-schema.ts +0 -1400
  26. package/src/schemas/product/discount-relations.ts +0 -44
  27. package/src/schemas/product/discount-schema.ts +0 -464
  28. package/src/schemas/product/product-relations.ts +0 -187
  29. package/src/schemas/product/product-schema.ts +0 -955
  30. package/src/schemas/store/ethiopian_business_api.md.resolved +0 -212
  31. package/src/schemas/store/store-audit-schema.ts +0 -1257
  32. package/src/schemas/store/store-schema.ts +0 -661
  33. package/src/schemas/store/store-settings-schema.ts +0 -231
@@ -1,212 +0,0 @@
1
- # Ethiopian Business Registration API Documentation
2
-
3
- ## Overview
4
-
5
- The Ethiopian Business Registration API allows store creation and validation using Ethiopian Tax Identification Numbers (TIN). It integrates with the Ethiopian government's e-trade system to automatically fetch and populate business details.
6
-
7
- **Base URL**: `/api/stores`
8
-
9
- ## Authentication
10
-
11
- All endpoints require authentication unless specified otherwise.
12
- - Headers: `X-User-ID: <user_id>`
13
- - Or authenticated session cookies
14
-
15
- ---
16
-
17
- ## 1. Validate TIN
18
-
19
- Validates an Ethiopian TIN and fetches associated business data, including license status.
20
-
21
- - **Endpoint**: `POST /validate-tin`
22
- - **Auth Required**: No (Publicly accessible for check)
23
-
24
- ### Request Body
25
-
26
- ```json
27
- {
28
- "tinNumber": "0069967578"
29
- }
30
- ```
31
-
32
- ### Response (200 OK)
33
-
34
- ```json
35
- {
36
- "success": true,
37
- "message": "TIN validated successfully",
38
- "data": {
39
- "valid": true,
40
- "tin": "0069967578",
41
- "businessData": {
42
- "businessName": "COSHILD TRADING PLC",
43
- "businessNameAmh": "ኮሸልድ ትሬዲንግ ሃላ የተ የግ ማህበር",
44
- "registrationNumber": "BL/AA/2/0022869/2013",
45
- "registrationDate": "2021-03-15T00:00:00.000Z",
46
- "paidUpCapital": 16000000,
47
- "legalCondition": "Private Limited Company",
48
- "tradeNames": ["COSHILD TRADING"]
49
- },
50
- "licenseStatus": {
51
- "hasValidLicense": true,
52
- "allLicensesExpired": false,
53
- "totalLicenses": 1,
54
- "activeLicenses": 1,
55
- "expiredLicenses": 0,
56
- "licensesExpiringSoon": 0
57
- },
58
- "licenses": [
59
- {
60
- "licenseNumber": "BL/AA/14/609/4908051/2013",
61
- "tradeName": "COSHILD TRADING",
62
- "isActive": true,
63
- "isExpired": false,
64
- "daysUntilExpiry": 145,
65
- "renewedTo": "2026-07-07T00:00:00.000Z",
66
- "subGroups": [
67
- {
68
- "code": 46900,
69
- "description": "Non-specialized wholesale trade"
70
- }
71
- ]
72
- }
73
- ],
74
- "associates": [
75
- {
76
- "name": "ABEBE KEBEDE",
77
- "position": "MANAGER",
78
- "mobilePhone": "0911234567"
79
- }
80
- ],
81
- "warnings": []
82
- }
83
- }
84
- ```
85
-
86
- ---
87
-
88
- ## 2. Create Store from TIN
89
-
90
- Creates a new store populated with data fetched from the TIN.
91
-
92
- - **Endpoint**: `POST /from-tin`
93
- - **Auth Required**: Yes
94
-
95
- ### Conditional Validation
96
-
97
- The requirement for location fields depends on `businessType`:
98
-
99
- | Field | Starter (`starter`) | Business Owner (`business_owner`) |
100
- |-------|---------------------|-----------------------------------|
101
- | `region` | Optional | **Required** |
102
- | `subcity` | Optional | **Required** |
103
- | `woreda` | Optional | **Required** |
104
- | `houseNumber` | Optional | **Required** |
105
-
106
- ### Request Body (Business Owner Example)
107
-
108
- ```json
109
- {
110
- "tinNumber": "0069967578",
111
- "businessType": "business_owner",
112
- "storeName": "My Store Name",
113
- "subdomain": "mystore123",
114
- "region": "Addis Ababa",
115
- "subcity": "Bole",
116
- "woreda": "03",
117
- "houseNumber": "123",
118
- "organization": {
119
- "name": "My Org"
120
- }
121
- }
122
- ```
123
-
124
- ### Request Body (Starter Example)
125
-
126
- ```json
127
- {
128
- "tinNumber": "0069967578",
129
- "businessType": "starter",
130
- "storeName": "My Starter Store",
131
- "subdomain": "starterstore",
132
- "organization": {
133
- "name": "My Starter Org"
134
- }
135
- }
136
- ```
137
-
138
- ### Response (201 Created)
139
-
140
- ```json
141
- {
142
- "success": true,
143
- "message": "Store created successfully from TIN",
144
- "data": {
145
- "storeId": "store_cl...",
146
- "storeUrl": "mystore123.myaxova.store",
147
- "subdomain": "mystore123",
148
- "ethiopianBusinessData": {
149
- "tin": "0069967578",
150
- "businessType": "business_owner",
151
- "legalBusinessName": "COSHILD TRADING PLC",
152
- "location": {
153
- "region": "Addis Ababa",
154
- "subcity": "Bole",
155
- "woreda": "03",
156
- "houseNumber": "123"
157
- },
158
- "hasValidLicense": true
159
- }
160
- }
161
- }
162
- ```
163
-
164
- ---
165
-
166
- ## 3. Get TIN Data (Read Only)
167
-
168
- Fetches raw TIN data without creating a store.
169
-
170
- - **Endpoint**: `GET /tin/:tinNumber`
171
- - **Auth Required**: No (Public)
172
-
173
- ### Response
174
-
175
- Returns the same data structure as `data.businessData` in the Validate TIN endpoint, plus full license and associate details.
176
-
177
- ---
178
-
179
- ## Error Codes
180
-
181
- | Code | Message | Description |
182
- |------|---------|-------------|
183
- | 400 | Invalid TIN format | TIN must be exactly 10 digits |
184
- | 400 | Missing required fields | Missing TIN, businessType, etc. |
185
- | 400 | For business_owner type... | Missing required location fields for business owner |
186
- | 409 | Subdomain is already taken | The requested subdomain is invalid |
187
- | 404 | etrade API request failed | TIN not found in government database |
188
- | 500 | Failed to fetch TIN data | External API error or timeout |
189
-
190
- ## Database Schema
191
-
192
- ### `stores` Table Extensions
193
-
194
- | Column | Type | Description |
195
- |--------|------|-------------|
196
- | `tin_number` | varchar(50) | Ethiopian TIN |
197
- | `business_type` | varchar(20) | 'starter' or 'business_owner' |
198
- | `region` | varchar(100) | Region (e.g., Addis Ababa) |
199
- | `subcity` | varchar(100) | Subcity (e.g., Bole) |
200
- | `woreda` | varchar(100) | Woreda/District |
201
- | `house_number` | varchar(50) | House number |
202
- | `trade_names` | jsonb | Array of registered trade names |
203
-
204
- ### `store_business_details` Table Extensions
205
-
206
- | Column | Type | Description |
207
- |--------|------|-------------|
208
- | `legal_business_name_amh` | varchar(255) | Business name in Amharic |
209
- | `registration_date` | timestamp | Initial registration date |
210
- | `paid_up_capital` | numeric(15,2) | Capital in ETB |
211
- | `license_details` | jsonb | Full license history and status |
212
- | `associate_info` | jsonb | Manager and associate details |