@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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/middleware/storeOwnership.js +3 -22
- package/dist/middleware/storeValidationMiddleware.js +39 -16
- package/dist/schemas/admin/admin-schema.d.ts +2 -2
- package/dist/schemas/ai-moderation/ai-moderation-schema.d.ts +2 -2
- package/dist/schemas/index.d.ts +0 -26
- package/dist/schemas/index.js +3 -121
- package/dist/schemas/store/storefront-config-schema.d.ts +1320 -0
- package/dist/schemas/store/storefront-config-schema.js +109 -0
- package/dist/utils/subdomain.d.ts +1 -1
- package/dist/utils/subdomain.js +15 -10
- package/package.json +1 -1
- package/src/index.ts +0 -3
- package/src/middleware/storeOwnership.ts +3 -21
- package/src/middleware/storeValidationMiddleware.ts +50 -17
- package/src/schemas/index.ts +5 -189
- package/src/utils/subdomain.ts +15 -11
- package/nul +0 -8
- package/src/schemas/compliance/compliance-schema.ts +0 -927
- package/src/schemas/compliance/kyc-schema.ts +0 -649
- package/src/schemas/customer/customer-schema.ts +0 -576
- package/src/schemas/inventory/inventory-tables.ts +0 -1927
- package/src/schemas/inventory/lot-tables.ts +0 -799
- package/src/schemas/order/order-schema.ts +0 -1400
- package/src/schemas/product/discount-relations.ts +0 -44
- package/src/schemas/product/discount-schema.ts +0 -464
- package/src/schemas/product/product-relations.ts +0 -187
- package/src/schemas/product/product-schema.ts +0 -955
- package/src/schemas/store/ethiopian_business_api.md.resolved +0 -212
- package/src/schemas/store/store-audit-schema.ts +0 -1257
- package/src/schemas/store/store-schema.ts +0 -661
- package/src/schemas/store/store-settings-schema.ts +0 -231
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { createId } from "@paralleldrive/cuid2";
|
|
2
|
-
import { relations } from "drizzle-orm";
|
|
3
|
-
import {
|
|
4
|
-
boolean,
|
|
5
|
-
decimal,
|
|
6
|
-
index,
|
|
7
|
-
jsonb,
|
|
8
|
-
pgTable,
|
|
9
|
-
text,
|
|
10
|
-
timestamp,
|
|
11
|
-
unique,
|
|
12
|
-
varchar,
|
|
13
|
-
} from "drizzle-orm/pg-core";
|
|
14
|
-
import { stores } from "./store-schema";
|
|
15
|
-
|
|
16
|
-
export const storeSettings = pgTable(
|
|
17
|
-
"store_settings",
|
|
18
|
-
{
|
|
19
|
-
id: text("id")
|
|
20
|
-
.primaryKey()
|
|
21
|
-
.$defaultFn(() => createId()),
|
|
22
|
-
storeId: text("store_id")
|
|
23
|
-
.notNull()
|
|
24
|
-
.references(() => stores.id, { onDelete: "cascade" }),
|
|
25
|
-
|
|
26
|
-
storeCountry: varchar("store_country", { length: 100 })
|
|
27
|
-
.notNull()
|
|
28
|
-
.default("Ethiopia"),
|
|
29
|
-
|
|
30
|
-
storeCurrency: varchar("store_currency", { length: 3 })
|
|
31
|
-
.notNull()
|
|
32
|
-
.default("ETB"),
|
|
33
|
-
|
|
34
|
-
storeLanguage: varchar("store_language", { length: 10 })
|
|
35
|
-
.notNull()
|
|
36
|
-
.default("en"),
|
|
37
|
-
|
|
38
|
-
supportedLanguages: jsonb("supported_languages")
|
|
39
|
-
.$type<string[]>()
|
|
40
|
-
.notNull()
|
|
41
|
-
.default(["en"]),
|
|
42
|
-
|
|
43
|
-
supportedCurrencies: jsonb("supported_currencies")
|
|
44
|
-
.$type<string[]>()
|
|
45
|
-
.notNull()
|
|
46
|
-
.default(["ETB"]),
|
|
47
|
-
|
|
48
|
-
localizationSettings: jsonb("localization_settings")
|
|
49
|
-
.$type<{
|
|
50
|
-
dateFormat?: string;
|
|
51
|
-
timeFormat?: string;
|
|
52
|
-
numberFormat?: string;
|
|
53
|
-
firstDayOfWeek?: number;
|
|
54
|
-
weightUnit?: "kg" | "lb";
|
|
55
|
-
dimensionUnit?: "cm" | "inch";
|
|
56
|
-
}>()
|
|
57
|
-
.default({
|
|
58
|
-
dateFormat: "DD/MM/YYYY",
|
|
59
|
-
timeFormat: "HH:mm",
|
|
60
|
-
numberFormat: "1,234.56",
|
|
61
|
-
firstDayOfWeek: 0,
|
|
62
|
-
weightUnit: "kg",
|
|
63
|
-
dimensionUnit: "cm",
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
generalSettings: jsonb("general_settings")
|
|
67
|
-
.$type<{
|
|
68
|
-
autoApplyTax?: boolean;
|
|
69
|
-
pricesIncludeTax?: boolean;
|
|
70
|
-
enableMultiCurrency?: boolean;
|
|
71
|
-
enableMultiLanguage?: boolean;
|
|
72
|
-
currencyDisplayFormat?: "symbol" | "code" | "both";
|
|
73
|
-
}>()
|
|
74
|
-
.default({
|
|
75
|
-
autoApplyTax: true,
|
|
76
|
-
pricesIncludeTax: false,
|
|
77
|
-
enableMultiCurrency: false,
|
|
78
|
-
enableMultiLanguage: false,
|
|
79
|
-
currencyDisplayFormat: "symbol",
|
|
80
|
-
}),
|
|
81
|
-
|
|
82
|
-
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
83
|
-
|
|
84
|
-
createdAt: timestamp("created_at", { withTimezone: true })
|
|
85
|
-
.defaultNow()
|
|
86
|
-
.notNull(),
|
|
87
|
-
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
88
|
-
.defaultNow()
|
|
89
|
-
.notNull(),
|
|
90
|
-
},
|
|
91
|
-
(table) => ({
|
|
92
|
-
storeIdIndex: index("idx_store_settings_store_id").on(table.storeId),
|
|
93
|
-
storeIdUnique: unique("idx_store_settings_store_unique").on(table.storeId),
|
|
94
|
-
countryIndex: index("idx_store_settings_country").on(table.storeCountry),
|
|
95
|
-
}),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
export const marketRegions = pgTable(
|
|
99
|
-
"market_regions",
|
|
100
|
-
{
|
|
101
|
-
id: text("id")
|
|
102
|
-
.primaryKey()
|
|
103
|
-
.$defaultFn(() => createId()),
|
|
104
|
-
storeId: text("store_id")
|
|
105
|
-
.notNull()
|
|
106
|
-
.references(() => stores.id, { onDelete: "cascade" }),
|
|
107
|
-
|
|
108
|
-
regionName: varchar("region_name", { length: 100 }).notNull(),
|
|
109
|
-
regionCode: varchar("region_code", { length: 10 }).notNull(),
|
|
110
|
-
|
|
111
|
-
country: varchar("country", { length: 100 }).notNull().default("Ethiopia"),
|
|
112
|
-
countryCode: varchar("country_code", { length: 2 })
|
|
113
|
-
.notNull()
|
|
114
|
-
.default("ET"),
|
|
115
|
-
|
|
116
|
-
currency: varchar("currency", { length: 3 }).notNull().default("ETB"),
|
|
117
|
-
language: varchar("language", { length: 10 }).notNull().default("en"),
|
|
118
|
-
|
|
119
|
-
taxEnabled: boolean("tax_enabled").notNull().default(true),
|
|
120
|
-
taxPercentage: decimal("tax_percentage", { precision: 5, scale: 2 })
|
|
121
|
-
.notNull()
|
|
122
|
-
.default("15.00"),
|
|
123
|
-
|
|
124
|
-
taxName: varchar("tax_name", { length: 50 }).default("VAT"),
|
|
125
|
-
|
|
126
|
-
taxConfiguration: jsonb("tax_configuration")
|
|
127
|
-
.$type<{
|
|
128
|
-
taxType?: "VAT" | "GST" | "SALES_TAX" | "CUSTOM";
|
|
129
|
-
taxNumber?: string;
|
|
130
|
-
taxRegistrationDate?: string;
|
|
131
|
-
includeTaxInPrice?: boolean;
|
|
132
|
-
compoundTax?: boolean;
|
|
133
|
-
exemptCategories?: string[];
|
|
134
|
-
reducedRates?: Array<{
|
|
135
|
-
categoryId: string;
|
|
136
|
-
categoryName: string;
|
|
137
|
-
rate: number;
|
|
138
|
-
}>;
|
|
139
|
-
}>()
|
|
140
|
-
.default({
|
|
141
|
-
taxType: "VAT",
|
|
142
|
-
includeTaxInPrice: false,
|
|
143
|
-
compoundTax: false,
|
|
144
|
-
exemptCategories: [],
|
|
145
|
-
reducedRates: [],
|
|
146
|
-
}),
|
|
147
|
-
|
|
148
|
-
isDefault: boolean("is_default").notNull().default(false),
|
|
149
|
-
isActive: boolean("is_active").notNull().default(true),
|
|
150
|
-
|
|
151
|
-
shippingSettings: jsonb("shipping_settings")
|
|
152
|
-
.$type<{
|
|
153
|
-
enableShipping?: boolean;
|
|
154
|
-
freeShippingThreshold?: number;
|
|
155
|
-
defaultShippingRate?: number;
|
|
156
|
-
shippingZones?: Array<{
|
|
157
|
-
name: string;
|
|
158
|
-
rate: number;
|
|
159
|
-
estimatedDays: number;
|
|
160
|
-
}>;
|
|
161
|
-
}>()
|
|
162
|
-
.default({
|
|
163
|
-
enableShipping: true,
|
|
164
|
-
freeShippingThreshold: 0,
|
|
165
|
-
defaultShippingRate: 0,
|
|
166
|
-
shippingZones: [],
|
|
167
|
-
}),
|
|
168
|
-
|
|
169
|
-
paymentSettings: jsonb("payment_settings")
|
|
170
|
-
.$type<{
|
|
171
|
-
enabledPaymentMethods?: string[];
|
|
172
|
-
preferredPaymentMethod?: string;
|
|
173
|
-
paymentProcessingFee?: number;
|
|
174
|
-
}>()
|
|
175
|
-
.default({
|
|
176
|
-
enabledPaymentMethods: ["cash", "card"],
|
|
177
|
-
preferredPaymentMethod: "cash",
|
|
178
|
-
paymentProcessingFee: 0,
|
|
179
|
-
}),
|
|
180
|
-
|
|
181
|
-
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
182
|
-
|
|
183
|
-
createdAt: timestamp("created_at", { withTimezone: true })
|
|
184
|
-
.defaultNow()
|
|
185
|
-
.notNull(),
|
|
186
|
-
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
187
|
-
.defaultNow()
|
|
188
|
-
.notNull(),
|
|
189
|
-
},
|
|
190
|
-
(table) => ({
|
|
191
|
-
storeIdIndex: index("idx_market_regions_store_id").on(table.storeId),
|
|
192
|
-
regionCodeIndex: index("idx_market_regions_code").on(
|
|
193
|
-
table.storeId,
|
|
194
|
-
table.regionCode,
|
|
195
|
-
),
|
|
196
|
-
defaultIndex: index("idx_market_regions_default").on(
|
|
197
|
-
table.storeId,
|
|
198
|
-
table.isDefault,
|
|
199
|
-
),
|
|
200
|
-
activeIndex: index("idx_market_regions_active").on(
|
|
201
|
-
table.storeId,
|
|
202
|
-
table.isActive,
|
|
203
|
-
),
|
|
204
|
-
uniqueRegionCode: unique("idx_market_regions_unique_code").on(
|
|
205
|
-
table.storeId,
|
|
206
|
-
table.regionCode,
|
|
207
|
-
),
|
|
208
|
-
}),
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
export const storeSettingsRelations = relations(storeSettings, ({ one, many }) => ({
|
|
212
|
-
store: one(stores, {
|
|
213
|
-
fields: [storeSettings.storeId],
|
|
214
|
-
references: [stores.id],
|
|
215
|
-
}),
|
|
216
|
-
}));
|
|
217
|
-
|
|
218
|
-
export const marketRegionsRelations = relations(marketRegions, ({ one }) => ({
|
|
219
|
-
store: one(stores, {
|
|
220
|
-
fields: [marketRegions.storeId],
|
|
221
|
-
references: [stores.id],
|
|
222
|
-
}),
|
|
223
|
-
}));
|
|
224
|
-
|
|
225
|
-
export const storesRelationsExtended = relations(stores, ({ one, many }) => ({
|
|
226
|
-
settings: one(storeSettings, {
|
|
227
|
-
fields: [stores.id],
|
|
228
|
-
references: [storeSettings.storeId],
|
|
229
|
-
}),
|
|
230
|
-
marketRegions: many(marketRegions),
|
|
231
|
-
}));
|