@axova/shared 1.0.1 → 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 (31) 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 -28
  8. package/dist/schemas/index.js +3 -125
  9. package/dist/utils/subdomain.d.ts +1 -1
  10. package/dist/utils/subdomain.js +15 -10
  11. package/package.json +1 -1
  12. package/src/index.ts +0 -3
  13. package/src/middleware/storeOwnership.ts +3 -21
  14. package/src/middleware/storeValidationMiddleware.ts +50 -17
  15. package/src/schemas/index.ts +5 -194
  16. package/src/utils/subdomain.ts +15 -11
  17. package/src/schemas/compliance/compliance-schema.ts +0 -927
  18. package/src/schemas/compliance/kyc-schema.ts +0 -649
  19. package/src/schemas/customer/customer-schema.ts +0 -576
  20. package/src/schemas/inventory/inventory-tables.ts +0 -1927
  21. package/src/schemas/inventory/lot-tables.ts +0 -799
  22. package/src/schemas/order/order-schema.ts +0 -1400
  23. package/src/schemas/product/discount-relations.ts +0 -44
  24. package/src/schemas/product/discount-schema.ts +0 -464
  25. package/src/schemas/product/product-relations.ts +0 -187
  26. package/src/schemas/product/product-schema.ts +0 -955
  27. package/src/schemas/store/ethiopian_business_api.md.resolved +0 -212
  28. package/src/schemas/store/store-audit-schema.ts +0 -1257
  29. package/src/schemas/store/store-schema.ts +0 -661
  30. package/src/schemas/store/store-settings-schema.ts +0 -231
  31. package/src/schemas/store/storefront-config-schema.ts +0 -604
@@ -1,194 +1,5 @@
1
- // Export the ACTUAL Drizzle table objects for database operations
2
-
3
- // Export event and Kafka functionality
4
- export {
5
- type AxovaKafkaConfig,
6
- createKafkaInstance,
7
- getKafkaConfigFromEnv,
8
- getKafkaInstance,
9
- } from "../events/kafka";
10
- // Export customer events and configuration
11
- export {
12
- CustomerServiceConfig,
13
- CustomerServiceEvents,
14
- } from "../interfaces/customer-events";
15
-
16
- // Export inventory events and configuration
17
- export { ServiceConfig, ServiceEvents } from "../interfaces/inventory-events";
18
- // Export inventory-specific types
19
- export type {
20
- ABCClassification,
21
- AIRecommendation,
22
- // Automation types
23
- AutomationRule,
24
- AutomationRuleFilter,
25
- BatchFilter,
26
- // Batch tracking types
27
- BatchInfo,
28
- CountItemRequest,
29
- CreateAutomationRuleRequest,
30
- CreateBatchRequest,
31
- CreateCycleCountRequest,
32
- CreateInventoryItemRequest,
33
- CreatePOSLocationRequest,
34
- CreateWarehouseRequest,
35
- // Cycle count types
36
- CycleCount,
37
- CycleCountFilter,
38
- CycleCountItem,
39
- DashboardMetrics,
40
- ExpiryReport,
41
- ForecastData,
42
- InventoryFilter,
43
- InventoryInsight,
44
- // Core types
45
- InventoryItem,
46
- InventoryOverview,
47
- // Insights and analytics types
48
- InventorySnapshot,
49
- LowStockAlert,
50
- // Common operation types
51
- OperationResult,
52
- PaginatedResult,
53
- POSLocation,
54
- QuantityUpdate,
55
- ReorderRecommendation,
56
- StockMovementReport,
57
- StockValuation,
58
- TenantContext,
59
- TransferFilter,
60
- TransferItem,
61
- // Transfer types
62
- TransferRequest,
63
- UpdateInventoryItemRequest,
64
- UserContext,
65
- VelocityAnalysis,
66
- Warehouse,
67
- } from "../interfaces/inventory-types";
68
- export * from "../types/events";
69
- // Admin Management
70
- export * from "./admin/admin-schema";
71
- // AI Moderation
72
- export * from "./ai-moderation/ai-moderation-schema";
73
- // Common Schemas
74
- export * from "./common/common-schemas";
75
- // Compliance Schemas
76
- export * from "./compliance/compliance-schema";
77
- export * from "./compliance/kyc-schema";
78
- export {
79
- storeKyc,
80
- kycVerificationHistory,
81
- kycDocuments,
82
- kycAnalytics,
83
- kycWebhooksLog,
84
- } from "./compliance/kyc-schema";
85
- // Customer Management Schemas
86
- export * from "./customer/customer-schema";
87
- // Customer Schema Exports
88
- export {
89
- customerAddresses,
90
- customerInteractionHistory,
91
- customerNotes,
92
- customerPreferences,
93
- customerReviews,
94
- customerSupportTickets,
95
- customers,
96
- customerVisitHistory,
97
- } from "./customer/customer-schema";
98
- // Core Inventory tables and co-located schemas
99
- export * from "./inventory/inventory-tables";
100
- export {
101
- inventory,
102
- inventoryMovements,
103
- inventoryTransferItems,
104
- inventoryTransfers,
105
- posLocations,
106
- productSuppliers,
107
- purchaseOrderItems,
108
- purchaseOrders,
109
- qualityControls,
110
- qualityTemplates,
111
- supplierQualityRatings,
112
- suppliers,
113
- warehouses,
114
- } from "./inventory/inventory-tables";
115
-
116
- // Lot & Batch Management schemas
117
- export {
118
- alertSeverityEnum,
119
- alertStatusEnum,
120
- alertTypeEnum,
121
- inventoryLotAlerts,
122
- inventoryLotMerges,
123
- inventoryLotMovements,
124
- inventoryLots,
125
- inventoryLotSplits,
126
- lotMovementTypeEnum,
127
- lotStatusEnum,
128
- // Zod Schemas for Lot Operations
129
- LotSchema,
130
- InitializeProductInventorySchema,
131
- CreateLotSchema,
132
- ReserveLotQuantitySchema,
133
- ReleaseLotReservationSchema,
134
- AdjustLotQuantitySchema,
135
- TransferLotSchema,
136
- MergeLotsSchema,
137
- SplitLotSchema,
138
- GetLotsQuerySchema,
139
- GetAvailableLotsSchema,
140
- LotAnalyticsSchema,
141
- } from "./inventory/lot-tables";
142
-
143
- // Order schemas
144
- export {
145
- addressTypeEnum,
146
- discountTypeEnum,
147
- fulfillmentStatusEnum,
148
- orderAddresses,
149
- orderAddressesRelations,
150
- orderDiscounts,
151
- orderDiscountsRelations,
152
- orderFulfillments,
153
- orderFulfillmentsRelations,
154
- orderHistory,
155
- orderHistoryRelations,
156
- orderItems,
157
- orderItemsRelations,
158
- orderNotes,
159
- orderNotesRelations,
160
- orderPayments,
161
- orderPaymentsRelations,
162
- orderPriorityEnum,
163
- orderStatusEnum,
164
- orders,
165
- ordersRelations,
166
- // Enums
167
- orderTypeEnum,
168
- paymentMethodEnum,
169
- paymentStatusEnum,
170
- refundReasonEnum,
171
- } from "./order/order-schema";
172
- export * from "./product/product-relations";
173
- // Product Management Schemas
174
- export * from "./product/product-schema";
175
- export * from "./product/product-relations";
176
- export * from "./product/discount-schema";
177
- export * from "./product/discount-relations";
178
- // Store Management
179
- export * from "./store/store-schema";
180
- export * from "./store/store-settings-schema";
181
- export * from "./store/store-audit-schema";
182
- export * from "./store/storefront-config-schema";
183
- export {
184
- storeSettings,
185
- marketRegions,
186
- storeSettingsRelations,
187
- marketRegionsRelations,
188
- } from "./store/store-settings-schema";
189
- export {
190
- storefrontConfigs,
191
- storefrontConfigRelations,
192
- } from "./store/storefront-config-schema";
193
- // Types
194
- export * from "./types";
1
+ // Schemas have been moved to individual services
2
+ // Each service now maintains its own schemas in their src/[service-name]-schema folder
3
+
4
+ // Common types used across services
5
+ export * from "./types";
@@ -1,19 +1,23 @@
1
- import { eq } from "drizzle-orm";
2
- import { db } from "../lib/db";
3
- import { stores } from "../schemas/store/store-schema";
4
-
5
1
  /**
6
- * Checks if a subdomain is available.
2
+ * Checks if a subdomain is available by calling the store service API.
7
3
  * @param subdomain The subdomain to check.
8
4
  * @returns {Promise<boolean>} True if available, false if taken.
9
5
  */
10
6
  export const isSubdomainAvailable = async (
11
7
  subdomain: string,
12
8
  ): Promise<boolean> => {
13
- const existingStore = await db
14
- .select()
15
- .from(stores)
16
- .where(eq(stores.subdomain, subdomain))
17
- .limit(1);
18
- return existingStore.length === 0;
9
+ const baseUrl = process.env.STORE_SERVICE_URL || "http://localhost:3001";
10
+ const url = `${baseUrl}/api/stores/subdomain/${encodeURIComponent(subdomain)}/check`;
11
+
12
+ try {
13
+ const res = await fetch(url, { method: "GET" });
14
+ if (res.ok) {
15
+ const data = (await res.json()) as { available: boolean };
16
+ return data.available;
17
+ }
18
+ } catch (error) {
19
+ console.error('Failed to check subdomain availability:', error);
20
+ }
21
+ // Default to unavailable on error to be safe
22
+ return false;
19
23
  };