@axova/shared 1.0.2 → 1.1.0
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 +1 -0
- package/dist/index.js +2 -0
- package/dist/lib/db.d.ts +34406 -1
- package/dist/lib/db.js +21 -1
- package/dist/middleware/storeOwnership.js +22 -3
- package/dist/middleware/storeValidationMiddleware.js +16 -39
- package/dist/schemas/admin/admin-schema.d.ts +2 -2
- package/dist/schemas/ai-moderation/ai-moderation-schema.d.ts +6 -6
- package/dist/schemas/common/common-schemas.d.ts +71 -71
- package/dist/schemas/compliance/compliance-schema.d.ts +20 -20
- package/dist/schemas/compliance/kyc-schema.d.ts +8 -8
- package/dist/schemas/customer/customer-schema.d.ts +18 -18
- package/dist/schemas/index.d.ts +28 -0
- package/dist/schemas/index.js +134 -3
- package/dist/schemas/inventory/inventory-tables.d.ts +188 -188
- package/dist/schemas/inventory/lot-tables.d.ts +102 -102
- package/dist/schemas/order/cart-schema.d.ts +2865 -0
- package/dist/schemas/order/cart-schema.js +396 -0
- package/dist/schemas/order/order-schema.d.ts +19 -19
- package/dist/schemas/order/order-schema.js +8 -2
- package/dist/schemas/product/discount-schema.d.ts +3 -3
- package/dist/schemas/product/product-schema.d.ts +3 -3
- package/dist/schemas/store/store-audit-schema.d.ts +20 -20
- package/dist/schemas/store/store-schema.d.ts +182 -2
- package/dist/schemas/store/store-schema.js +19 -0
- package/dist/schemas/store/storefront-config-schema.d.ts +434 -823
- package/dist/schemas/store/storefront-config-schema.js +35 -62
- package/dist/utils/subdomain.d.ts +1 -1
- package/dist/utils/subdomain.js +10 -15
- package/package.json +1 -1
- package/src/configs/index.ts +654 -654
- package/src/index.ts +26 -23
- package/src/interfaces/customer-events.ts +106 -106
- package/src/interfaces/inventory-events.ts +545 -545
- package/src/interfaces/inventory-types.ts +1004 -1004
- package/src/interfaces/order-events.ts +381 -381
- package/src/lib/auditLogger.ts +1117 -1117
- package/src/lib/authOrganization.ts +153 -153
- package/src/lib/db.ts +84 -64
- package/src/middleware/serviceAuth.ts +328 -328
- package/src/middleware/storeOwnership.ts +199 -181
- package/src/middleware/storeValidationMiddleware.ts +17 -50
- package/src/middleware/userAuth.ts +248 -248
- package/src/schemas/admin/admin-schema.ts +208 -208
- package/src/schemas/ai-moderation/ai-moderation-schema.ts +180 -180
- package/src/schemas/common/common-schemas.ts +108 -108
- package/src/schemas/compliance/compliance-schema.ts +927 -0
- package/src/schemas/compliance/kyc-schema.ts +649 -0
- package/src/schemas/customer/customer-schema.ts +576 -0
- package/src/schemas/index.ts +202 -3
- package/src/schemas/inventory/inventory-tables.ts +1927 -0
- package/src/schemas/inventory/lot-tables.ts +799 -0
- package/src/schemas/order/cart-schema.ts +652 -0
- package/src/schemas/order/order-schema.ts +1406 -0
- package/src/schemas/product/discount-relations.ts +44 -0
- package/src/schemas/product/discount-schema.ts +464 -0
- package/src/schemas/product/product-relations.ts +187 -0
- package/src/schemas/product/product-schema.ts +955 -0
- package/src/schemas/store/ethiopian_business_api.md.resolved +212 -0
- package/src/schemas/store/store-audit-schema.ts +1257 -0
- package/src/schemas/store/store-schema.ts +682 -0
- package/src/schemas/store/store-settings-schema.ts +231 -0
- package/src/schemas/store/storefront-config-schema.ts +382 -0
- package/src/schemas/types.ts +67 -67
- package/src/types/events.ts +646 -646
- package/src/utils/errorHandler.ts +44 -44
- package/src/utils/subdomain.ts +19 -23
- package/tsconfig.json +21 -21
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.storefrontConfigsRelations = exports.storefrontConfigs = void 0;
|
|
4
4
|
const cuid2_1 = require("@paralleldrive/cuid2");
|
|
5
5
|
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
6
|
const pg_core_1 = require("drizzle-orm/pg-core");
|
|
7
7
|
const store_schema_1 = require("./store-schema");
|
|
8
|
+
/**
|
|
9
|
+
* Storefront Configuration Schema
|
|
10
|
+
* Stores all visual, layout, and content configurations for multi-tenant storefronts
|
|
11
|
+
*/
|
|
8
12
|
exports.storefrontConfigs = (0, pg_core_1.pgTable)("storefront_configs", {
|
|
9
13
|
id: (0, pg_core_1.text)("id")
|
|
10
14
|
.primaryKey()
|
|
@@ -12,96 +16,65 @@ exports.storefrontConfigs = (0, pg_core_1.pgTable)("storefront_configs", {
|
|
|
12
16
|
storeId: (0, pg_core_1.text)("store_id")
|
|
13
17
|
.notNull()
|
|
14
18
|
.references(() => store_schema_1.stores.id, { onDelete: "cascade" }),
|
|
15
|
-
//
|
|
16
|
-
|
|
19
|
+
// Configuration type and version
|
|
20
|
+
configType: (0, pg_core_1.varchar)("config_type", { length: 50 })
|
|
17
21
|
.notNull()
|
|
18
|
-
.default("
|
|
22
|
+
.default("default")
|
|
19
23
|
.$type(),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.$type()
|
|
23
|
-
.default({
|
|
24
|
-
branding: { completed: false },
|
|
25
|
-
layout: { completed: false },
|
|
26
|
-
pages: { completed: false },
|
|
27
|
-
localization: { completed: false },
|
|
28
|
-
theme: { completed: false },
|
|
29
|
-
seo: { completed: false },
|
|
30
|
-
}),
|
|
24
|
+
version: (0, pg_core_1.integer)("version").notNull().default(1),
|
|
25
|
+
isActive: (0, pg_core_1.boolean)("is_active").notNull().default(true),
|
|
31
26
|
// Branding Configuration
|
|
32
27
|
branding: (0, pg_core_1.jsonb)("branding")
|
|
33
28
|
.$type()
|
|
34
|
-
.
|
|
29
|
+
.default({}),
|
|
35
30
|
// Layout Configuration
|
|
36
31
|
layout: (0, pg_core_1.jsonb)("layout")
|
|
37
32
|
.$type()
|
|
38
|
-
.
|
|
39
|
-
// Pages Configuration
|
|
33
|
+
.default({}),
|
|
34
|
+
// Pages Content Configuration
|
|
40
35
|
pages: (0, pg_core_1.jsonb)("pages")
|
|
41
36
|
.$type()
|
|
42
|
-
.
|
|
37
|
+
.default({}),
|
|
38
|
+
// Promotions & Popups Configuration
|
|
39
|
+
promotions: (0, pg_core_1.jsonb)("promotions")
|
|
40
|
+
.$type()
|
|
41
|
+
.default({}),
|
|
43
42
|
// Localization Configuration
|
|
44
43
|
localization: (0, pg_core_1.jsonb)("localization")
|
|
45
44
|
.$type()
|
|
46
|
-
.
|
|
47
|
-
//
|
|
48
|
-
|
|
45
|
+
.default({}),
|
|
46
|
+
// Character Limits & Validation Rules
|
|
47
|
+
validationRules: (0, pg_core_1.jsonb)("validation_rules")
|
|
49
48
|
.$type()
|
|
50
|
-
.default({
|
|
51
|
-
|
|
52
|
-
radius: 8,
|
|
53
|
-
animations: true,
|
|
54
|
-
transitions: true,
|
|
55
|
-
effects: {
|
|
56
|
-
blur: true,
|
|
57
|
-
shadows: true,
|
|
58
|
-
gradients: true,
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
// SEO Configuration
|
|
49
|
+
.default({}),
|
|
50
|
+
// SEO & Meta Configuration
|
|
62
51
|
seo: (0, pg_core_1.jsonb)("seo")
|
|
63
52
|
.$type()
|
|
64
53
|
.default({}),
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
.$type()
|
|
68
|
-
.default({
|
|
69
|
-
homeHero: {
|
|
70
|
-
badgeTextMax: 48,
|
|
71
|
-
titleMax: 64,
|
|
72
|
-
subtitleMax: 160,
|
|
73
|
-
newsletterPlaceholderMax: 48,
|
|
74
|
-
newsletterButtonTextMax: 24,
|
|
75
|
-
trustedByTextMax: 48,
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
// Advanced Features
|
|
79
|
-
features: (0, pg_core_1.jsonb)("features")
|
|
54
|
+
// Custom Scripts & Integrations
|
|
55
|
+
integrations: (0, pg_core_1.jsonb)("integrations")
|
|
80
56
|
.$type()
|
|
81
57
|
.default({}),
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
lastEditedBy: (0, pg_core_1.text)("last_edited_by"),
|
|
58
|
+
// Additional metadata
|
|
59
|
+
metadata: (0, pg_core_1.jsonb)("metadata").$type().default({}),
|
|
60
|
+
// Audit fields
|
|
61
|
+
createdBy: (0, pg_core_1.text)("created_by"),
|
|
62
|
+
updatedBy: (0, pg_core_1.text)("updated_by"),
|
|
88
63
|
publishedAt: (0, pg_core_1.timestamp)("published_at", { withTimezone: true }),
|
|
89
|
-
publishedBy: (0, pg_core_1.text)("published_by"),
|
|
90
64
|
createdAt: (0, pg_core_1.timestamp)("created_at", { withTimezone: true })
|
|
91
65
|
.defaultNow()
|
|
92
66
|
.notNull(),
|
|
93
67
|
updatedAt: (0, pg_core_1.timestamp)("updated_at", { withTimezone: true })
|
|
94
68
|
.defaultNow()
|
|
95
69
|
.notNull(),
|
|
70
|
+
deletedAt: (0, pg_core_1.timestamp)("deleted_at", { withTimezone: true }),
|
|
96
71
|
}, (table) => ({
|
|
97
72
|
storeIdIndex: (0, pg_core_1.index)("idx_storefront_configs_store_id").on(table.storeId),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
setupProgressIndex: (0, pg_core_1.index)("idx_storefront_configs_setup_progress").on(table.setupProgress),
|
|
101
|
-
versionIndex: (0, pg_core_1.index)("idx_storefront_configs_version").on(table.version),
|
|
102
|
-
isDraftIndex: (0, pg_core_1.index)("idx_storefront_configs_draft").on(table.isDraft),
|
|
73
|
+
activeIndex: (0, pg_core_1.index)("idx_storefront_configs_active").on(table.storeId, table.isActive),
|
|
74
|
+
typeIndex: (0, pg_core_1.index)("idx_storefront_configs_type").on(table.configType),
|
|
103
75
|
}));
|
|
104
|
-
|
|
76
|
+
// Relations
|
|
77
|
+
exports.storefrontConfigsRelations = (0, drizzle_orm_1.relations)(exports.storefrontConfigs, ({ one }) => ({
|
|
105
78
|
store: one(store_schema_1.stores, {
|
|
106
79
|
fields: [exports.storefrontConfigs.storeId],
|
|
107
80
|
references: [store_schema_1.stores.id],
|
package/dist/utils/subdomain.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSubdomainAvailable = void 0;
|
|
4
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
5
|
+
const db_1 = require("../lib/db");
|
|
6
|
+
const store_schema_1 = require("../schemas/store/store-schema");
|
|
4
7
|
/**
|
|
5
|
-
* Checks if a subdomain is available
|
|
8
|
+
* Checks if a subdomain is available.
|
|
6
9
|
* @param subdomain The subdomain to check.
|
|
7
10
|
* @returns {Promise<boolean>} True if available, false if taken.
|
|
8
11
|
*/
|
|
9
12
|
const isSubdomainAvailable = async (subdomain) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return data.available;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
console.error('Failed to check subdomain availability:', error);
|
|
21
|
-
}
|
|
22
|
-
// Default to unavailable on error to be safe
|
|
23
|
-
return false;
|
|
13
|
+
const existingStore = await db_1.db
|
|
14
|
+
.select()
|
|
15
|
+
.from(store_schema_1.stores)
|
|
16
|
+
.where((0, drizzle_orm_1.eq)(store_schema_1.stores.subdomain, subdomain))
|
|
17
|
+
.limit(1);
|
|
18
|
+
return existingStore.length === 0;
|
|
24
19
|
};
|
|
25
20
|
exports.isSubdomainAvailable = isSubdomainAvailable;
|