@instockng/api-client 1.0.6 → 1.0.7

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 (176) hide show
  1. package/dist/apps/backend/src/generated/zod/index.d.ts +1114 -0
  2. package/dist/apps/backend/src/generated/zod/index.js +670 -0
  3. package/dist/apps/backend/src/http-app.d.ts +40 -0
  4. package/dist/apps/backend/src/http-app.js +106 -0
  5. package/dist/apps/backend/src/lib/brand-response.d.ts +14 -0
  6. package/dist/apps/backend/src/lib/brand-response.js +8 -0
  7. package/dist/apps/backend/src/lib/cart-helpers.d.ts +280 -0
  8. package/dist/apps/backend/src/lib/cart-helpers.js +93 -0
  9. package/dist/apps/backend/src/lib/cart-recovery.d.ts +30 -0
  10. package/dist/apps/backend/src/lib/cart-recovery.js +147 -0
  11. package/dist/apps/backend/src/lib/cart-response.d.ts +121 -0
  12. package/dist/apps/backend/src/lib/cart-response.js +150 -0
  13. package/dist/apps/backend/src/lib/clerk.d.ts +18 -0
  14. package/dist/apps/backend/src/lib/clerk.js +167 -0
  15. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +62 -0
  16. package/dist/apps/backend/src/lib/delivery-zone-response.js +24 -0
  17. package/dist/apps/backend/src/lib/discount-code-response.d.ts +42 -0
  18. package/dist/apps/backend/src/lib/discount-code-response.js +19 -0
  19. package/dist/apps/backend/src/lib/discount.d.ts +20 -0
  20. package/dist/apps/backend/src/lib/discount.js +35 -0
  21. package/dist/apps/backend/src/lib/inventory.d.ts +26 -0
  22. package/dist/apps/backend/src/lib/inventory.js +160 -0
  23. package/dist/apps/backend/src/lib/meta-capi.d.ts +48 -0
  24. package/dist/apps/backend/src/lib/meta-capi.js +120 -0
  25. package/dist/apps/backend/src/lib/openapi.d.ts +36 -0
  26. package/dist/apps/backend/src/lib/openapi.js +69 -0
  27. package/dist/apps/backend/src/lib/order-recovery.d.ts +453 -0
  28. package/dist/apps/backend/src/lib/order-recovery.js +378 -0
  29. package/dist/apps/backend/src/lib/order-response.d.ts +136 -0
  30. package/dist/apps/backend/src/lib/order-response.js +61 -0
  31. package/dist/apps/backend/src/lib/pricing.d.ts +39 -0
  32. package/dist/apps/backend/src/lib/pricing.js +62 -0
  33. package/dist/apps/backend/src/lib/prisma.d.ts +9 -0
  34. package/dist/apps/backend/src/lib/prisma.js +30 -0
  35. package/dist/apps/backend/src/lib/product-response.d.ts +82 -0
  36. package/dist/apps/backend/src/lib/product-response.js +29 -0
  37. package/dist/apps/backend/src/lib/utils.d.ts +32 -0
  38. package/dist/apps/backend/src/lib/utils.js +63 -0
  39. package/dist/apps/backend/src/middleware/clerk-auth.d.ts +8 -0
  40. package/dist/apps/backend/src/middleware/clerk-auth.js +89 -0
  41. package/dist/apps/backend/src/middleware/cors.d.ts +8 -0
  42. package/dist/apps/backend/src/middleware/cors.js +11 -0
  43. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +62 -0
  44. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +166 -0
  45. package/dist/apps/backend/src/notifications/producers/order-notification.d.ts +9 -0
  46. package/dist/apps/backend/src/notifications/producers/order-notification.js +18 -0
  47. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.d.ts +10 -0
  48. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.js +11 -0
  49. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +605 -0
  50. package/dist/apps/backend/src/routes/admin/abandoned-carts.js +194 -0
  51. package/dist/apps/backend/src/routes/admin/brands.d.ts +175 -0
  52. package/dist/apps/backend/src/routes/admin/brands.js +118 -0
  53. package/dist/apps/backend/src/routes/admin/customers.d.ts +306 -0
  54. package/dist/apps/backend/src/routes/admin/customers.js +39 -0
  55. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +438 -0
  56. package/dist/apps/backend/src/routes/admin/delivery-zones.js +300 -0
  57. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +478 -0
  58. package/dist/apps/backend/src/routes/admin/discount-codes.js +418 -0
  59. package/dist/apps/backend/src/routes/admin/inventory.d.ts +273 -0
  60. package/dist/apps/backend/src/routes/admin/inventory.js +189 -0
  61. package/dist/apps/backend/src/routes/admin/orders.d.ts +1768 -0
  62. package/dist/apps/backend/src/routes/admin/orders.js +527 -0
  63. package/dist/apps/backend/src/routes/admin/products.d.ts +860 -0
  64. package/dist/apps/backend/src/routes/admin/products.js +107 -0
  65. package/dist/apps/backend/src/routes/admin/stats.d.ts +288 -0
  66. package/dist/apps/backend/src/routes/admin/stats.js +55 -0
  67. package/dist/apps/backend/src/routes/admin/variants.d.ts +239 -0
  68. package/dist/apps/backend/src/routes/admin/variants.js +173 -0
  69. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +373 -0
  70. package/dist/apps/backend/src/routes/admin/warehouses.js +123 -0
  71. package/dist/apps/backend/src/routes/public/brands.d.ts +40 -0
  72. package/dist/apps/backend/src/routes/public/brands.js +38 -0
  73. package/dist/apps/backend/src/routes/public/carts.d.ts +2655 -0
  74. package/dist/apps/backend/src/routes/public/carts.js +631 -0
  75. package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +35 -0
  76. package/dist/apps/backend/src/routes/public/delivery-zones.js +62 -0
  77. package/dist/apps/backend/src/routes/public/orders.d.ts +605 -0
  78. package/dist/apps/backend/src/routes/public/orders.js +160 -0
  79. package/dist/apps/backend/src/routes/public/products.d.ts +449 -0
  80. package/dist/apps/backend/src/routes/public/products.js +133 -0
  81. package/dist/apps/backend/src/types/index.d.ts +42 -0
  82. package/dist/apps/backend/src/types/index.js +2 -0
  83. package/dist/apps/backend/src/validators/brand.d.ts +17 -0
  84. package/dist/apps/backend/src/validators/brand.js +15 -0
  85. package/dist/apps/backend/src/validators/delivery-zone.d.ts +31 -0
  86. package/dist/apps/backend/src/validators/delivery-zone.js +51 -0
  87. package/dist/apps/backend/src/validators/discount-code.d.ts +74 -0
  88. package/dist/apps/backend/src/validators/discount-code.js +50 -0
  89. package/dist/apps/backend/src/validators/inventory.d.ts +20 -0
  90. package/dist/apps/backend/src/validators/inventory.js +15 -0
  91. package/dist/apps/backend/src/validators/order.d.ts +56 -0
  92. package/dist/apps/backend/src/validators/order.js +60 -0
  93. package/dist/apps/backend/src/validators/product.d.ts +18 -0
  94. package/dist/apps/backend/src/validators/product.js +19 -0
  95. package/dist/apps/backend/src/validators/variant.d.ts +19 -0
  96. package/dist/apps/backend/src/validators/variant.js +19 -0
  97. package/dist/apps/backend/src/validators/warehouse.d.ts +15 -0
  98. package/dist/apps/backend/src/validators/warehouse.js +15 -0
  99. package/dist/fetchers/orders.d.ts +258 -1
  100. package/dist/hooks/admin/orders.d.ts +285 -3
  101. package/dist/hooks/admin/orders.js +7 -4
  102. package/dist/hooks/public/orders.d.ts +258 -1
  103. package/dist/packages/api-client/src/backend-types.d.ts +10 -0
  104. package/dist/packages/api-client/src/backend-types.js +10 -0
  105. package/dist/packages/api-client/src/client.d.ts +20 -0
  106. package/dist/packages/api-client/src/client.js +40 -0
  107. package/dist/packages/api-client/src/enum-types.d.ts +8 -0
  108. package/dist/packages/api-client/src/enum-types.js +5 -0
  109. package/dist/packages/api-client/src/fetchers/brands.d.ts +25 -0
  110. package/dist/packages/api-client/src/fetchers/brands.js +26 -0
  111. package/dist/packages/api-client/src/fetchers/carts.d.ts +2335 -0
  112. package/dist/packages/api-client/src/fetchers/carts.js +174 -0
  113. package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +28 -0
  114. package/dist/packages/api-client/src/fetchers/delivery-zones.js +26 -0
  115. package/dist/packages/api-client/src/fetchers/index.d.ts +22 -0
  116. package/dist/packages/api-client/src/fetchers/index.js +22 -0
  117. package/dist/packages/api-client/src/fetchers/orders.d.ts +540 -0
  118. package/dist/packages/api-client/src/fetchers/orders.js +44 -0
  119. package/dist/packages/api-client/src/fetchers/products.d.ts +386 -0
  120. package/dist/packages/api-client/src/fetchers/products.js +42 -0
  121. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +535 -0
  122. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.js +83 -0
  123. package/dist/packages/api-client/src/hooks/admin/brands.d.ts +79 -0
  124. package/dist/packages/api-client/src/hooks/admin/brands.js +108 -0
  125. package/dist/packages/api-client/src/hooks/admin/customers.d.ts +278 -0
  126. package/dist/packages/api-client/src/hooks/admin/customers.js +26 -0
  127. package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +270 -0
  128. package/dist/packages/api-client/src/hooks/admin/delivery-zones.js +176 -0
  129. package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +299 -0
  130. package/dist/packages/api-client/src/hooks/admin/discount-codes.js +165 -0
  131. package/dist/packages/api-client/src/hooks/admin/index.d.ts +16 -0
  132. package/dist/packages/api-client/src/hooks/admin/index.js +16 -0
  133. package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +224 -0
  134. package/dist/packages/api-client/src/hooks/admin/inventory.js +107 -0
  135. package/dist/packages/api-client/src/hooks/admin/orders.d.ts +1662 -0
  136. package/dist/packages/api-client/src/hooks/admin/orders.js +178 -0
  137. package/dist/packages/api-client/src/hooks/admin/products.d.ts +374 -0
  138. package/dist/packages/api-client/src/hooks/admin/products.js +89 -0
  139. package/dist/packages/api-client/src/hooks/admin/stats.d.ts +277 -0
  140. package/dist/packages/api-client/src/hooks/admin/stats.js +25 -0
  141. package/dist/packages/api-client/src/hooks/admin/variants.d.ts +115 -0
  142. package/dist/packages/api-client/src/hooks/admin/variants.js +127 -0
  143. package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +277 -0
  144. package/dist/packages/api-client/src/hooks/admin/warehouses.js +108 -0
  145. package/dist/packages/api-client/src/hooks/public/brands.d.ts +33 -0
  146. package/dist/packages/api-client/src/hooks/public/brands.js +30 -0
  147. package/dist/packages/api-client/src/hooks/public/carts.d.ts +2405 -0
  148. package/dist/packages/api-client/src/hooks/public/carts.js +213 -0
  149. package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +34 -0
  150. package/dist/packages/api-client/src/hooks/public/delivery-zones.js +28 -0
  151. package/dist/packages/api-client/src/hooks/public/index.d.ts +10 -0
  152. package/dist/packages/api-client/src/hooks/public/index.js +10 -0
  153. package/dist/packages/api-client/src/hooks/public/orders.d.ts +559 -0
  154. package/dist/packages/api-client/src/hooks/public/orders.js +50 -0
  155. package/dist/packages/api-client/src/hooks/public/products.d.ts +398 -0
  156. package/dist/packages/api-client/src/hooks/public/products.js +47 -0
  157. package/dist/packages/api-client/src/hooks/use-query-unwrapped.d.ts +20 -0
  158. package/dist/packages/api-client/src/hooks/use-query-unwrapped.js +22 -0
  159. package/dist/packages/api-client/src/hooks/useApiConfig.d.ts +12 -0
  160. package/dist/packages/api-client/src/hooks/useApiConfig.js +14 -0
  161. package/dist/packages/api-client/src/index.d.ts +20 -0
  162. package/dist/packages/api-client/src/index.js +25 -0
  163. package/dist/packages/api-client/src/provider.d.ts +36 -0
  164. package/dist/packages/api-client/src/provider.js +54 -0
  165. package/dist/packages/api-client/src/rpc-client.d.ts +9607 -0
  166. package/dist/packages/api-client/src/rpc-client.js +78 -0
  167. package/dist/packages/api-client/src/rpc-types.d.ts +76 -0
  168. package/dist/packages/api-client/src/rpc-types.js +7 -0
  169. package/dist/packages/api-client/src/types.d.ts +34 -0
  170. package/dist/packages/api-client/src/types.js +16 -0
  171. package/dist/packages/api-client/src/utils/query-keys.d.ts +106 -0
  172. package/dist/packages/api-client/src/utils/query-keys.js +108 -0
  173. package/dist/rpc-client.d.ts +891 -319
  174. package/dist/utils/query-keys.d.ts +1 -1
  175. package/dist/utils/query-keys.js +1 -1
  176. package/package.json +1 -1
@@ -0,0 +1,670 @@
1
+ import { z } from 'zod';
2
+ import { Prisma } from '@prisma/client';
3
+ export const transformJsonNull = (v) => {
4
+ if (!v || v === 'DbNull')
5
+ return Prisma.NullTypes.DbNull;
6
+ if (v === 'JsonNull')
7
+ return Prisma.NullTypes.JsonNull;
8
+ return v;
9
+ };
10
+ export const JsonValueSchema = z.lazy(() => z.union([
11
+ z.string(),
12
+ z.number(),
13
+ z.boolean(),
14
+ z.literal(null),
15
+ z.record(z.string(), z.lazy(() => JsonValueSchema.optional())),
16
+ z.array(z.lazy(() => JsonValueSchema)),
17
+ ]));
18
+ export const NullableJsonValue = z
19
+ .union([JsonValueSchema, z.literal('DbNull'), z.literal('JsonNull')])
20
+ .nullable()
21
+ .transform((v) => transformJsonNull(v));
22
+ export const InputJsonValueSchema = z.lazy(() => z.union([
23
+ z.string(),
24
+ z.number(),
25
+ z.boolean(),
26
+ z.object({ toJSON: z.any() }),
27
+ z.record(z.string(), z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),
28
+ z.array(z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),
29
+ ]));
30
+ // DECIMAL
31
+ //------------------------------------------------------
32
+ export const DecimalJsLikeSchema = z.object({
33
+ d: z.array(z.number()),
34
+ e: z.number(),
35
+ s: z.number(),
36
+ toFixed: z.any(),
37
+ });
38
+ export const DECIMAL_STRING_REGEX = /^(?:-?Infinity|NaN|-?(?:0[bB][01]+(?:\.[01]+)?(?:[pP][-+]?\d+)?|0[oO][0-7]+(?:\.[0-7]+)?(?:[pP][-+]?\d+)?|0[xX][\da-fA-F]+(?:\.[\da-fA-F]+)?(?:[pP][-+]?\d+)?|(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?))$/;
39
+ export const isValidDecimalInput = (v) => {
40
+ if (v === undefined || v === null)
41
+ return false;
42
+ return ((typeof v === 'object' && 'd' in v && 'e' in v && 's' in v && 'toFixed' in v) ||
43
+ (typeof v === 'string' && DECIMAL_STRING_REGEX.test(v)) ||
44
+ typeof v === 'number');
45
+ };
46
+ /////////////////////////////////////////
47
+ // ENUMS
48
+ /////////////////////////////////////////
49
+ export const TransactionIsolationLevelSchema = z.enum(['ReadUncommitted', 'ReadCommitted', 'RepeatableRead', 'Serializable']);
50
+ export const BrandScalarFieldEnumSchema = z.enum(['id', 'name', 'slug', 'logoUrl', 'siteUrl', 'domain', 'metaPixelId', 'createdAt', 'updatedAt', 'deletedAt']);
51
+ export const StateScalarFieldEnumSchema = z.enum(['id', 'name', 'isActive', 'createdAt', 'updatedAt', 'deletedAt']);
52
+ export const DeliveryZoneScalarFieldEnumSchema = z.enum(['id', 'stateId', 'brandId', 'name', 'deliveryCost', 'freeShippingThreshold', 'allowCOD', 'allowOnline', 'waybillOnly', 'estimatedDays', 'isActive', 'createdAt', 'updatedAt', 'deletedAt']);
53
+ export const DiscountCodeScalarFieldEnumSchema = z.enum(['id', 'code', 'brandId', 'type', 'value', 'minPurchase', 'maxDiscount', 'usageLimit', 'usageCount', 'perCustomerLimit', 'validFrom', 'validUntil', 'isActive', 'isAutoApply', 'description', 'category', 'createdAt', 'updatedAt', 'createdBy', 'deletedAt']);
54
+ export const DiscountCodeUsageScalarFieldEnumSchema = z.enum(['id', 'discountCodeId', 'orderId', 'customerPhone', 'discountAmount', 'originalAmount', 'createdAt']);
55
+ export const CartScalarFieldEnumSchema = z.enum(['id', 'brandId', 'customerPhone', 'customerFirstName', 'customerLastName', 'expiresAt', 'createdAt', 'updatedAt', 'deliveryZoneId', 'deliveryZoneLockedAt', 'availablePaymentMethods', 'recoveryAttempts', 'lastRecoveryAttemptAt', 'recoveryDiscountCodeId', 'convertedToOrderId', 'wasRecovered', 'appliedDiscountCodeId', 'customerEmail']);
56
+ export const CartItemScalarFieldEnumSchema = z.enum(['id', 'cartId', 'variantId', 'quantity', 'createdAt', 'updatedAt']);
57
+ export const ProductScalarFieldEnumSchema = z.enum(['id', 'brandId', 'name', 'slug', 'description', 'thumbnailUrl', 'quantityDiscounts', 'isActive', 'createdAt', 'updatedAt', 'deletedAt']);
58
+ export const ProductVariantScalarFieldEnumSchema = z.enum(['id', 'productId', 'sku', 'name', 'thumbnailUrl', 'price', 'trackInventory', 'lowStockThreshold', 'isActive', 'createdAt', 'updatedAt', 'deletedAt']);
59
+ export const WarehouseScalarFieldEnumSchema = z.enum(['id', 'name', 'address', 'city', 'state', 'isActive', 'createdAt', 'updatedAt', 'deletedAt']);
60
+ export const WarehouseInventoryScalarFieldEnumSchema = z.enum(['id', 'variantId', 'warehouseId', 'inventoryCount', 'updatedAt']);
61
+ export const InventoryTransactionScalarFieldEnumSchema = z.enum(['id', 'variantId', 'warehouseId', 'type', 'quantity', 'balanceAfter', 'reason', 'orderId', 'userId', 'metadata', 'createdAt']);
62
+ export const OrderScalarFieldEnumSchema = z.enum(['id', 'brandId', 'orderNumber', 'firstName', 'lastName', 'phone', 'address', 'city', 'deliveryZoneId', 'deliveryCharge', 'estimatedDays', 'totalPrice', 'discountCodeId', 'discountAmount', 'paymentMethod', 'paystackReference', 'status', 'cancellationReason', 'createdAt', 'updatedAt', 'deletedAt', 'email', 'lastRecoveryAttemptAt', 'prospectReason', 'prospectSince', 'recoveryAttempts', 'recoveryDiscountCodeId', 'userActionToken', 'wasRecovered']);
63
+ export const OrderItemScalarFieldEnumSchema = z.enum(['id', 'orderId', 'variantId', 'warehouseId', 'priceAtPurchase', 'quantity']);
64
+ export const UserScalarFieldEnumSchema = z.enum(['id', 'clerkId', 'email', 'name', 'role', 'createdAt', 'deletedAt']);
65
+ export const OrderNoteScalarFieldEnumSchema = z.enum(['id', 'orderId', 'note', 'type', 'createdAt', 'createdBy', 'metadata']);
66
+ export const SortOrderSchema = z.enum(['asc', 'desc']);
67
+ export const NullableJsonNullValueInputSchema = z.enum(['DbNull', 'JsonNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.DbNull : value);
68
+ export const QueryModeSchema = z.enum(['default', 'insensitive']);
69
+ export const NullsOrderSchema = z.enum(['first', 'last']);
70
+ export const JsonNullValueFilterSchema = z.enum(['DbNull', 'JsonNull', 'AnyNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.DbNull : value === 'AnyNull' ? Prisma.AnyNull : value);
71
+ export const InventoryTransactionTypeSchema = z.enum(['sale', 'restock', 'adjustment', 'return', 'transfer_in', 'transfer_out', 'damaged', 'initial']);
72
+ export const PaymentMethodSchema = z.enum(['cod', 'online']);
73
+ export const OrderStatusSchema = z.enum(['pending', 'shipped', 'delivered', 'cancelled', 'returned', 'prospect']);
74
+ export const NoteTypeSchema = z.enum(['general', 'status_change', 'prospect_reason', 'delivery_attempt', 'customer_communication', 'internal']);
75
+ export const ProspectReasonSchema = z.enum(['no_answer', 'thinking', 'price_concern', 'will_call_back', 'unclear_commitment', 'payment_issue', 'other']);
76
+ /////////////////////////////////////////
77
+ // MODELS
78
+ /////////////////////////////////////////
79
+ /////////////////////////////////////////
80
+ // BRAND SCHEMA
81
+ /////////////////////////////////////////
82
+ export const BrandSchema = z.object({
83
+ id: z.uuid(),
84
+ name: z.string(),
85
+ slug: z.string(),
86
+ logoUrl: z.string().nullable(),
87
+ siteUrl: z.string(),
88
+ domain: z.string(),
89
+ metaPixelId: z.string().nullable(),
90
+ createdAt: z.coerce.date(),
91
+ updatedAt: z.coerce.date(),
92
+ deletedAt: z.coerce.date().nullable(),
93
+ });
94
+ /////////////////////////////////////////
95
+ // BRAND PARTIAL SCHEMA
96
+ /////////////////////////////////////////
97
+ export const BrandPartialSchema = BrandSchema.partial();
98
+ export const BrandWithRelationsSchema = BrandSchema.merge(z.object({
99
+ carts: z.lazy(() => CartWithRelationsSchema).array(),
100
+ deliveryZones: z.lazy(() => DeliveryZoneWithRelationsSchema).array(),
101
+ discountCodes: z.lazy(() => DiscountCodeWithRelationsSchema).array(),
102
+ orders: z.lazy(() => OrderWithRelationsSchema).array(),
103
+ products: z.lazy(() => ProductWithRelationsSchema).array(),
104
+ }));
105
+ export const BrandPartialWithRelationsSchema = BrandPartialSchema.merge(z.object({
106
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
107
+ deliveryZones: z.lazy(() => DeliveryZonePartialWithRelationsSchema).array(),
108
+ discountCodes: z.lazy(() => DiscountCodePartialWithRelationsSchema).array(),
109
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
110
+ products: z.lazy(() => ProductPartialWithRelationsSchema).array(),
111
+ })).partial();
112
+ export const BrandWithPartialRelationsSchema = BrandSchema.merge(z.object({
113
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
114
+ deliveryZones: z.lazy(() => DeliveryZonePartialWithRelationsSchema).array(),
115
+ discountCodes: z.lazy(() => DiscountCodePartialWithRelationsSchema).array(),
116
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
117
+ products: z.lazy(() => ProductPartialWithRelationsSchema).array(),
118
+ }).partial());
119
+ /////////////////////////////////////////
120
+ // STATE SCHEMA
121
+ /////////////////////////////////////////
122
+ export const StateSchema = z.object({
123
+ id: z.uuid(),
124
+ name: z.string(),
125
+ isActive: z.boolean(),
126
+ createdAt: z.coerce.date(),
127
+ updatedAt: z.coerce.date(),
128
+ deletedAt: z.coerce.date().nullable(),
129
+ });
130
+ /////////////////////////////////////////
131
+ // STATE PARTIAL SCHEMA
132
+ /////////////////////////////////////////
133
+ export const StatePartialSchema = StateSchema.partial();
134
+ export const StateWithRelationsSchema = StateSchema.merge(z.object({
135
+ deliveryZones: z.lazy(() => DeliveryZoneWithRelationsSchema).array(),
136
+ }));
137
+ export const StatePartialWithRelationsSchema = StatePartialSchema.merge(z.object({
138
+ deliveryZones: z.lazy(() => DeliveryZonePartialWithRelationsSchema).array(),
139
+ })).partial();
140
+ export const StateWithPartialRelationsSchema = StateSchema.merge(z.object({
141
+ deliveryZones: z.lazy(() => DeliveryZonePartialWithRelationsSchema).array(),
142
+ }).partial());
143
+ /////////////////////////////////////////
144
+ // DELIVERY ZONE SCHEMA
145
+ /////////////////////////////////////////
146
+ export const DeliveryZoneSchema = z.object({
147
+ id: z.uuid(),
148
+ stateId: z.string(),
149
+ brandId: z.string().nullable(),
150
+ name: z.string(),
151
+ deliveryCost: z.instanceof(Prisma.Decimal, { message: "Field 'deliveryCost' must be a Decimal. Location: ['Models', 'DeliveryZone']" }),
152
+ freeShippingThreshold: z.instanceof(Prisma.Decimal, { message: "Field 'freeShippingThreshold' must be a Decimal. Location: ['Models', 'DeliveryZone']" }).nullable(),
153
+ allowCOD: z.boolean(),
154
+ allowOnline: z.boolean(),
155
+ waybillOnly: z.boolean(),
156
+ estimatedDays: z.number().int().nullable(),
157
+ isActive: z.boolean(),
158
+ createdAt: z.coerce.date(),
159
+ updatedAt: z.coerce.date(),
160
+ deletedAt: z.coerce.date().nullable(),
161
+ });
162
+ /////////////////////////////////////////
163
+ // DELIVERY ZONE PARTIAL SCHEMA
164
+ /////////////////////////////////////////
165
+ export const DeliveryZonePartialSchema = DeliveryZoneSchema.partial();
166
+ export const DeliveryZoneWithRelationsSchema = DeliveryZoneSchema.merge(z.object({
167
+ carts: z.lazy(() => CartWithRelationsSchema).array(),
168
+ brand: z.lazy(() => BrandWithRelationsSchema).nullable(),
169
+ state: z.lazy(() => StateWithRelationsSchema),
170
+ orders: z.lazy(() => OrderWithRelationsSchema).array(),
171
+ }));
172
+ export const DeliveryZonePartialWithRelationsSchema = DeliveryZonePartialSchema.merge(z.object({
173
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
174
+ brand: z.lazy(() => BrandPartialWithRelationsSchema).nullable(),
175
+ state: z.lazy(() => StatePartialWithRelationsSchema),
176
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
177
+ })).partial();
178
+ export const DeliveryZoneWithPartialRelationsSchema = DeliveryZoneSchema.merge(z.object({
179
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
180
+ brand: z.lazy(() => BrandPartialWithRelationsSchema).nullable(),
181
+ state: z.lazy(() => StatePartialWithRelationsSchema),
182
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
183
+ }).partial());
184
+ /////////////////////////////////////////
185
+ // DISCOUNT CODE SCHEMA
186
+ /////////////////////////////////////////
187
+ export const DiscountCodeSchema = z.object({
188
+ id: z.uuid(),
189
+ code: z.string(),
190
+ brandId: z.string().nullable(),
191
+ type: z.string(),
192
+ value: z.instanceof(Prisma.Decimal, { message: "Field 'value' must be a Decimal. Location: ['Models', 'DiscountCode']" }),
193
+ minPurchase: z.instanceof(Prisma.Decimal, { message: "Field 'minPurchase' must be a Decimal. Location: ['Models', 'DiscountCode']" }).nullable(),
194
+ maxDiscount: z.instanceof(Prisma.Decimal, { message: "Field 'maxDiscount' must be a Decimal. Location: ['Models', 'DiscountCode']" }).nullable(),
195
+ usageLimit: z.number().int().nullable(),
196
+ usageCount: z.number().int(),
197
+ perCustomerLimit: z.number().int().nullable(),
198
+ validFrom: z.coerce.date(),
199
+ validUntil: z.coerce.date().nullable(),
200
+ isActive: z.boolean(),
201
+ isAutoApply: z.boolean(),
202
+ description: z.string().nullable(),
203
+ category: z.string(),
204
+ createdAt: z.coerce.date(),
205
+ updatedAt: z.coerce.date(),
206
+ createdBy: z.string().nullable(),
207
+ deletedAt: z.coerce.date().nullable(),
208
+ });
209
+ /////////////////////////////////////////
210
+ // DISCOUNT CODE PARTIAL SCHEMA
211
+ /////////////////////////////////////////
212
+ export const DiscountCodePartialSchema = DiscountCodeSchema.partial();
213
+ export const DiscountCodeWithRelationsSchema = DiscountCodeSchema.merge(z.object({
214
+ appliedToCarts: z.lazy(() => CartWithRelationsSchema).array(),
215
+ carts: z.lazy(() => CartWithRelationsSchema).array(),
216
+ brand: z.lazy(() => BrandWithRelationsSchema).nullable(),
217
+ usageLog: z.lazy(() => DiscountCodeUsageWithRelationsSchema).array(),
218
+ orders: z.lazy(() => OrderWithRelationsSchema).array(),
219
+ Order_Order_recoveryDiscountCodeIdToDiscountCode: z.lazy(() => OrderWithRelationsSchema).nullable(),
220
+ }));
221
+ export const DiscountCodePartialWithRelationsSchema = DiscountCodePartialSchema.merge(z.object({
222
+ appliedToCarts: z.lazy(() => CartPartialWithRelationsSchema).array(),
223
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
224
+ brand: z.lazy(() => BrandPartialWithRelationsSchema).nullable(),
225
+ usageLog: z.lazy(() => DiscountCodeUsagePartialWithRelationsSchema).array(),
226
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
227
+ Order_Order_recoveryDiscountCodeIdToDiscountCode: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
228
+ })).partial();
229
+ export const DiscountCodeWithPartialRelationsSchema = DiscountCodeSchema.merge(z.object({
230
+ appliedToCarts: z.lazy(() => CartPartialWithRelationsSchema).array(),
231
+ carts: z.lazy(() => CartPartialWithRelationsSchema).array(),
232
+ brand: z.lazy(() => BrandPartialWithRelationsSchema).nullable(),
233
+ usageLog: z.lazy(() => DiscountCodeUsagePartialWithRelationsSchema).array(),
234
+ orders: z.lazy(() => OrderPartialWithRelationsSchema).array(),
235
+ Order_Order_recoveryDiscountCodeIdToDiscountCode: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
236
+ }).partial());
237
+ /////////////////////////////////////////
238
+ // DISCOUNT CODE USAGE SCHEMA
239
+ /////////////////////////////////////////
240
+ export const DiscountCodeUsageSchema = z.object({
241
+ id: z.uuid(),
242
+ discountCodeId: z.string(),
243
+ orderId: z.string(),
244
+ customerPhone: z.string(),
245
+ discountAmount: z.instanceof(Prisma.Decimal, { message: "Field 'discountAmount' must be a Decimal. Location: ['Models', 'DiscountCodeUsage']" }),
246
+ originalAmount: z.instanceof(Prisma.Decimal, { message: "Field 'originalAmount' must be a Decimal. Location: ['Models', 'DiscountCodeUsage']" }),
247
+ createdAt: z.coerce.date(),
248
+ });
249
+ /////////////////////////////////////////
250
+ // DISCOUNT CODE USAGE PARTIAL SCHEMA
251
+ /////////////////////////////////////////
252
+ export const DiscountCodeUsagePartialSchema = DiscountCodeUsageSchema.partial();
253
+ export const DiscountCodeUsageWithRelationsSchema = DiscountCodeUsageSchema.merge(z.object({
254
+ discountCode: z.lazy(() => DiscountCodeWithRelationsSchema),
255
+ order: z.lazy(() => OrderWithRelationsSchema),
256
+ }));
257
+ export const DiscountCodeUsagePartialWithRelationsSchema = DiscountCodeUsagePartialSchema.merge(z.object({
258
+ discountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema),
259
+ order: z.lazy(() => OrderPartialWithRelationsSchema),
260
+ })).partial();
261
+ export const DiscountCodeUsageWithPartialRelationsSchema = DiscountCodeUsageSchema.merge(z.object({
262
+ discountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema),
263
+ order: z.lazy(() => OrderPartialWithRelationsSchema),
264
+ }).partial());
265
+ /////////////////////////////////////////
266
+ // CART SCHEMA
267
+ /////////////////////////////////////////
268
+ export const CartSchema = z.object({
269
+ availablePaymentMethods: PaymentMethodSchema.array(),
270
+ id: z.uuid(),
271
+ brandId: z.string(),
272
+ customerPhone: z.string().nullable(),
273
+ customerFirstName: z.string().nullable(),
274
+ customerLastName: z.string().nullable(),
275
+ expiresAt: z.coerce.date(),
276
+ createdAt: z.coerce.date(),
277
+ updatedAt: z.coerce.date(),
278
+ deliveryZoneId: z.string().nullable(),
279
+ deliveryZoneLockedAt: z.coerce.date().nullable(),
280
+ recoveryAttempts: z.number().int(),
281
+ lastRecoveryAttemptAt: z.coerce.date().nullable(),
282
+ recoveryDiscountCodeId: z.string().nullable(),
283
+ convertedToOrderId: z.string().nullable(),
284
+ wasRecovered: z.boolean(),
285
+ appliedDiscountCodeId: z.string().nullable(),
286
+ customerEmail: z.string().nullable(),
287
+ });
288
+ /////////////////////////////////////////
289
+ // CART PARTIAL SCHEMA
290
+ /////////////////////////////////////////
291
+ export const CartPartialSchema = CartSchema.partial();
292
+ export const CartWithRelationsSchema = CartSchema.merge(z.object({
293
+ appliedDiscountCode: z.lazy(() => DiscountCodeWithRelationsSchema).nullable(),
294
+ brand: z.lazy(() => BrandWithRelationsSchema),
295
+ convertedOrder: z.lazy(() => OrderWithRelationsSchema).nullable(),
296
+ deliveryZone: z.lazy(() => DeliveryZoneWithRelationsSchema).nullable(),
297
+ recoveryDiscountCode: z.lazy(() => DiscountCodeWithRelationsSchema).nullable(),
298
+ items: z.lazy(() => CartItemWithRelationsSchema).array(),
299
+ }));
300
+ export const CartPartialWithRelationsSchema = CartPartialSchema.merge(z.object({
301
+ appliedDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
302
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
303
+ convertedOrder: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
304
+ deliveryZone: z.lazy(() => DeliveryZonePartialWithRelationsSchema).nullable(),
305
+ recoveryDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
306
+ items: z.lazy(() => CartItemPartialWithRelationsSchema).array(),
307
+ })).partial();
308
+ export const CartWithPartialRelationsSchema = CartSchema.merge(z.object({
309
+ appliedDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
310
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
311
+ convertedOrder: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
312
+ deliveryZone: z.lazy(() => DeliveryZonePartialWithRelationsSchema).nullable(),
313
+ recoveryDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
314
+ items: z.lazy(() => CartItemPartialWithRelationsSchema).array(),
315
+ }).partial());
316
+ /////////////////////////////////////////
317
+ // CART ITEM SCHEMA
318
+ /////////////////////////////////////////
319
+ export const CartItemSchema = z.object({
320
+ id: z.uuid(),
321
+ cartId: z.string(),
322
+ variantId: z.string(),
323
+ quantity: z.number().int(),
324
+ createdAt: z.coerce.date(),
325
+ updatedAt: z.coerce.date(),
326
+ });
327
+ /////////////////////////////////////////
328
+ // CART ITEM PARTIAL SCHEMA
329
+ /////////////////////////////////////////
330
+ export const CartItemPartialSchema = CartItemSchema.partial();
331
+ export const CartItemWithRelationsSchema = CartItemSchema.merge(z.object({
332
+ cart: z.lazy(() => CartWithRelationsSchema),
333
+ variant: z.lazy(() => ProductVariantWithRelationsSchema),
334
+ }));
335
+ export const CartItemPartialWithRelationsSchema = CartItemPartialSchema.merge(z.object({
336
+ cart: z.lazy(() => CartPartialWithRelationsSchema),
337
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
338
+ })).partial();
339
+ export const CartItemWithPartialRelationsSchema = CartItemSchema.merge(z.object({
340
+ cart: z.lazy(() => CartPartialWithRelationsSchema),
341
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
342
+ }).partial());
343
+ /////////////////////////////////////////
344
+ // PRODUCT SCHEMA
345
+ /////////////////////////////////////////
346
+ export const ProductSchema = z.object({
347
+ id: z.uuid(),
348
+ brandId: z.string(),
349
+ name: z.string(),
350
+ slug: z.string(),
351
+ description: z.string().nullable(),
352
+ thumbnailUrl: z.string().nullable(),
353
+ quantityDiscounts: JsonValueSchema.nullable(),
354
+ isActive: z.boolean(),
355
+ createdAt: z.coerce.date(),
356
+ updatedAt: z.coerce.date(),
357
+ deletedAt: z.coerce.date().nullable(),
358
+ });
359
+ /////////////////////////////////////////
360
+ // PRODUCT PARTIAL SCHEMA
361
+ /////////////////////////////////////////
362
+ export const ProductPartialSchema = ProductSchema.partial();
363
+ export const ProductWithRelationsSchema = ProductSchema.merge(z.object({
364
+ brand: z.lazy(() => BrandWithRelationsSchema),
365
+ variants: z.lazy(() => ProductVariantWithRelationsSchema).array(),
366
+ }));
367
+ export const ProductPartialWithRelationsSchema = ProductPartialSchema.merge(z.object({
368
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
369
+ variants: z.lazy(() => ProductVariantPartialWithRelationsSchema).array(),
370
+ })).partial();
371
+ export const ProductWithPartialRelationsSchema = ProductSchema.merge(z.object({
372
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
373
+ variants: z.lazy(() => ProductVariantPartialWithRelationsSchema).array(),
374
+ }).partial());
375
+ /////////////////////////////////////////
376
+ // PRODUCT VARIANT SCHEMA
377
+ /////////////////////////////////////////
378
+ export const ProductVariantSchema = z.object({
379
+ id: z.uuid(),
380
+ productId: z.string(),
381
+ sku: z.string(),
382
+ name: z.string().nullable(),
383
+ thumbnailUrl: z.string().nullable(),
384
+ price: z.instanceof(Prisma.Decimal, { message: "Field 'price' must be a Decimal. Location: ['Models', 'ProductVariant']" }),
385
+ trackInventory: z.boolean(),
386
+ lowStockThreshold: z.number().int().nullable(),
387
+ isActive: z.boolean(),
388
+ createdAt: z.coerce.date(),
389
+ updatedAt: z.coerce.date(),
390
+ deletedAt: z.coerce.date().nullable(),
391
+ });
392
+ /////////////////////////////////////////
393
+ // PRODUCT VARIANT PARTIAL SCHEMA
394
+ /////////////////////////////////////////
395
+ export const ProductVariantPartialSchema = ProductVariantSchema.partial();
396
+ export const ProductVariantWithRelationsSchema = ProductVariantSchema.merge(z.object({
397
+ cartItems: z.lazy(() => CartItemWithRelationsSchema).array(),
398
+ inventoryTransactions: z.lazy(() => InventoryTransactionWithRelationsSchema).array(),
399
+ orderItems: z.lazy(() => OrderItemWithRelationsSchema).array(),
400
+ product: z.lazy(() => ProductWithRelationsSchema),
401
+ warehouseInventories: z.lazy(() => WarehouseInventoryWithRelationsSchema).array(),
402
+ }));
403
+ export const ProductVariantPartialWithRelationsSchema = ProductVariantPartialSchema.merge(z.object({
404
+ cartItems: z.lazy(() => CartItemPartialWithRelationsSchema).array(),
405
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
406
+ orderItems: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
407
+ product: z.lazy(() => ProductPartialWithRelationsSchema),
408
+ warehouseInventories: z.lazy(() => WarehouseInventoryPartialWithRelationsSchema).array(),
409
+ })).partial();
410
+ export const ProductVariantWithPartialRelationsSchema = ProductVariantSchema.merge(z.object({
411
+ cartItems: z.lazy(() => CartItemPartialWithRelationsSchema).array(),
412
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
413
+ orderItems: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
414
+ product: z.lazy(() => ProductPartialWithRelationsSchema),
415
+ warehouseInventories: z.lazy(() => WarehouseInventoryPartialWithRelationsSchema).array(),
416
+ }).partial());
417
+ /////////////////////////////////////////
418
+ // WAREHOUSE SCHEMA
419
+ /////////////////////////////////////////
420
+ export const WarehouseSchema = z.object({
421
+ id: z.uuid(),
422
+ name: z.string(),
423
+ address: z.string().nullable(),
424
+ city: z.string().nullable(),
425
+ state: z.string().nullable(),
426
+ isActive: z.boolean(),
427
+ createdAt: z.coerce.date(),
428
+ updatedAt: z.coerce.date(),
429
+ deletedAt: z.coerce.date().nullable(),
430
+ });
431
+ /////////////////////////////////////////
432
+ // WAREHOUSE PARTIAL SCHEMA
433
+ /////////////////////////////////////////
434
+ export const WarehousePartialSchema = WarehouseSchema.partial();
435
+ export const WarehouseWithRelationsSchema = WarehouseSchema.merge(z.object({
436
+ inventoryTransactions: z.lazy(() => InventoryTransactionWithRelationsSchema).array(),
437
+ orderItems: z.lazy(() => OrderItemWithRelationsSchema).array(),
438
+ inventories: z.lazy(() => WarehouseInventoryWithRelationsSchema).array(),
439
+ }));
440
+ export const WarehousePartialWithRelationsSchema = WarehousePartialSchema.merge(z.object({
441
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
442
+ orderItems: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
443
+ inventories: z.lazy(() => WarehouseInventoryPartialWithRelationsSchema).array(),
444
+ })).partial();
445
+ export const WarehouseWithPartialRelationsSchema = WarehouseSchema.merge(z.object({
446
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
447
+ orderItems: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
448
+ inventories: z.lazy(() => WarehouseInventoryPartialWithRelationsSchema).array(),
449
+ }).partial());
450
+ /////////////////////////////////////////
451
+ // WAREHOUSE INVENTORY SCHEMA
452
+ /////////////////////////////////////////
453
+ export const WarehouseInventorySchema = z.object({
454
+ id: z.uuid(),
455
+ variantId: z.string(),
456
+ warehouseId: z.string(),
457
+ inventoryCount: z.number().int(),
458
+ updatedAt: z.coerce.date(),
459
+ });
460
+ /////////////////////////////////////////
461
+ // WAREHOUSE INVENTORY PARTIAL SCHEMA
462
+ /////////////////////////////////////////
463
+ export const WarehouseInventoryPartialSchema = WarehouseInventorySchema.partial();
464
+ export const WarehouseInventoryWithRelationsSchema = WarehouseInventorySchema.merge(z.object({
465
+ variant: z.lazy(() => ProductVariantWithRelationsSchema),
466
+ warehouse: z.lazy(() => WarehouseWithRelationsSchema),
467
+ }));
468
+ export const WarehouseInventoryPartialWithRelationsSchema = WarehouseInventoryPartialSchema.merge(z.object({
469
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
470
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema),
471
+ })).partial();
472
+ export const WarehouseInventoryWithPartialRelationsSchema = WarehouseInventorySchema.merge(z.object({
473
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
474
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema),
475
+ }).partial());
476
+ /////////////////////////////////////////
477
+ // INVENTORY TRANSACTION SCHEMA
478
+ /////////////////////////////////////////
479
+ export const InventoryTransactionSchema = z.object({
480
+ type: InventoryTransactionTypeSchema,
481
+ id: z.uuid(),
482
+ variantId: z.string(),
483
+ warehouseId: z.string(),
484
+ quantity: z.number().int(),
485
+ balanceAfter: z.number().int(),
486
+ reason: z.string().nullable(),
487
+ orderId: z.string().nullable(),
488
+ userId: z.string().nullable(),
489
+ metadata: JsonValueSchema.nullable(),
490
+ createdAt: z.coerce.date(),
491
+ });
492
+ /////////////////////////////////////////
493
+ // INVENTORY TRANSACTION PARTIAL SCHEMA
494
+ /////////////////////////////////////////
495
+ export const InventoryTransactionPartialSchema = InventoryTransactionSchema.partial();
496
+ export const InventoryTransactionWithRelationsSchema = InventoryTransactionSchema.merge(z.object({
497
+ order: z.lazy(() => OrderWithRelationsSchema).nullable(),
498
+ user: z.lazy(() => UserWithRelationsSchema).nullable(),
499
+ variant: z.lazy(() => ProductVariantWithRelationsSchema),
500
+ warehouse: z.lazy(() => WarehouseWithRelationsSchema),
501
+ }));
502
+ export const InventoryTransactionPartialWithRelationsSchema = InventoryTransactionPartialSchema.merge(z.object({
503
+ order: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
504
+ user: z.lazy(() => UserPartialWithRelationsSchema).nullable(),
505
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
506
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema),
507
+ })).partial();
508
+ export const InventoryTransactionWithPartialRelationsSchema = InventoryTransactionSchema.merge(z.object({
509
+ order: z.lazy(() => OrderPartialWithRelationsSchema).nullable(),
510
+ user: z.lazy(() => UserPartialWithRelationsSchema).nullable(),
511
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
512
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema),
513
+ }).partial());
514
+ /////////////////////////////////////////
515
+ // ORDER SCHEMA
516
+ /////////////////////////////////////////
517
+ export const OrderSchema = z.object({
518
+ paymentMethod: PaymentMethodSchema,
519
+ status: OrderStatusSchema,
520
+ prospectReason: ProspectReasonSchema.nullable(),
521
+ id: z.uuid(),
522
+ brandId: z.string(),
523
+ orderNumber: z.number().int(),
524
+ firstName: z.string(),
525
+ lastName: z.string(),
526
+ phone: z.string(),
527
+ address: z.string(),
528
+ city: z.string(),
529
+ deliveryZoneId: z.string(),
530
+ deliveryCharge: z.instanceof(Prisma.Decimal, { message: "Field 'deliveryCharge' must be a Decimal. Location: ['Models', 'Order']" }),
531
+ estimatedDays: z.number().int().nullable(),
532
+ totalPrice: z.instanceof(Prisma.Decimal, { message: "Field 'totalPrice' must be a Decimal. Location: ['Models', 'Order']" }),
533
+ discountCodeId: z.string().nullable(),
534
+ discountAmount: z.instanceof(Prisma.Decimal, { message: "Field 'discountAmount' must be a Decimal. Location: ['Models', 'Order']" }).nullable(),
535
+ paystackReference: z.string().nullable(),
536
+ cancellationReason: z.string().nullable(),
537
+ createdAt: z.coerce.date(),
538
+ updatedAt: z.coerce.date(),
539
+ deletedAt: z.coerce.date().nullable(),
540
+ email: z.string().nullable(),
541
+ lastRecoveryAttemptAt: z.coerce.date().nullable(),
542
+ prospectSince: z.coerce.date().nullable(),
543
+ recoveryAttempts: z.number().int(),
544
+ recoveryDiscountCodeId: z.string().nullable(),
545
+ userActionToken: z.uuid(),
546
+ wasRecovered: z.boolean(),
547
+ });
548
+ /////////////////////////////////////////
549
+ // ORDER PARTIAL SCHEMA
550
+ /////////////////////////////////////////
551
+ export const OrderPartialSchema = OrderSchema.partial();
552
+ export const OrderWithRelationsSchema = OrderSchema.merge(z.object({
553
+ recoveredFromCart: z.lazy(() => CartWithRelationsSchema).nullable(),
554
+ discountUsage: z.lazy(() => DiscountCodeUsageWithRelationsSchema).array(),
555
+ inventoryTransactions: z.lazy(() => InventoryTransactionWithRelationsSchema).array(),
556
+ brand: z.lazy(() => BrandWithRelationsSchema),
557
+ deliveryZone: z.lazy(() => DeliveryZoneWithRelationsSchema),
558
+ discountCode: z.lazy(() => DiscountCodeWithRelationsSchema).nullable(),
559
+ recoveryDiscountCode: z.lazy(() => DiscountCodeWithRelationsSchema).nullable(),
560
+ items: z.lazy(() => OrderItemWithRelationsSchema).array(),
561
+ notes: z.lazy(() => OrderNoteWithRelationsSchema).array(),
562
+ }));
563
+ export const OrderPartialWithRelationsSchema = OrderPartialSchema.merge(z.object({
564
+ recoveredFromCart: z.lazy(() => CartPartialWithRelationsSchema).nullable(),
565
+ discountUsage: z.lazy(() => DiscountCodeUsagePartialWithRelationsSchema).array(),
566
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
567
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
568
+ deliveryZone: z.lazy(() => DeliveryZonePartialWithRelationsSchema),
569
+ discountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
570
+ recoveryDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
571
+ items: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
572
+ notes: z.lazy(() => OrderNotePartialWithRelationsSchema).array(),
573
+ })).partial();
574
+ export const OrderWithPartialRelationsSchema = OrderSchema.merge(z.object({
575
+ recoveredFromCart: z.lazy(() => CartPartialWithRelationsSchema).nullable(),
576
+ discountUsage: z.lazy(() => DiscountCodeUsagePartialWithRelationsSchema).array(),
577
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
578
+ brand: z.lazy(() => BrandPartialWithRelationsSchema),
579
+ deliveryZone: z.lazy(() => DeliveryZonePartialWithRelationsSchema),
580
+ discountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
581
+ recoveryDiscountCode: z.lazy(() => DiscountCodePartialWithRelationsSchema).nullable(),
582
+ items: z.lazy(() => OrderItemPartialWithRelationsSchema).array(),
583
+ notes: z.lazy(() => OrderNotePartialWithRelationsSchema).array(),
584
+ }).partial());
585
+ /////////////////////////////////////////
586
+ // ORDER ITEM SCHEMA
587
+ /////////////////////////////////////////
588
+ export const OrderItemSchema = z.object({
589
+ id: z.uuid(),
590
+ orderId: z.string(),
591
+ variantId: z.string(),
592
+ warehouseId: z.string().nullable(),
593
+ priceAtPurchase: z.instanceof(Prisma.Decimal, { message: "Field 'priceAtPurchase' must be a Decimal. Location: ['Models', 'OrderItem']" }),
594
+ quantity: z.number().int(),
595
+ });
596
+ /////////////////////////////////////////
597
+ // ORDER ITEM PARTIAL SCHEMA
598
+ /////////////////////////////////////////
599
+ export const OrderItemPartialSchema = OrderItemSchema.partial();
600
+ export const OrderItemWithRelationsSchema = OrderItemSchema.merge(z.object({
601
+ order: z.lazy(() => OrderWithRelationsSchema),
602
+ variant: z.lazy(() => ProductVariantWithRelationsSchema),
603
+ warehouse: z.lazy(() => WarehouseWithRelationsSchema).nullable(),
604
+ }));
605
+ export const OrderItemPartialWithRelationsSchema = OrderItemPartialSchema.merge(z.object({
606
+ order: z.lazy(() => OrderPartialWithRelationsSchema),
607
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
608
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema).nullable(),
609
+ })).partial();
610
+ export const OrderItemWithPartialRelationsSchema = OrderItemSchema.merge(z.object({
611
+ order: z.lazy(() => OrderPartialWithRelationsSchema),
612
+ variant: z.lazy(() => ProductVariantPartialWithRelationsSchema),
613
+ warehouse: z.lazy(() => WarehousePartialWithRelationsSchema).nullable(),
614
+ }).partial());
615
+ /////////////////////////////////////////
616
+ // USER SCHEMA
617
+ /////////////////////////////////////////
618
+ export const UserSchema = z.object({
619
+ id: z.uuid(),
620
+ clerkId: z.string(),
621
+ email: z.string(),
622
+ name: z.string().nullable(),
623
+ role: z.string(),
624
+ createdAt: z.coerce.date(),
625
+ deletedAt: z.coerce.date().nullable(),
626
+ });
627
+ /////////////////////////////////////////
628
+ // USER PARTIAL SCHEMA
629
+ /////////////////////////////////////////
630
+ export const UserPartialSchema = UserSchema.partial();
631
+ export const UserWithRelationsSchema = UserSchema.merge(z.object({
632
+ inventoryTransactions: z.lazy(() => InventoryTransactionWithRelationsSchema).array(),
633
+ OrderNote: z.lazy(() => OrderNoteWithRelationsSchema).array(),
634
+ }));
635
+ export const UserPartialWithRelationsSchema = UserPartialSchema.merge(z.object({
636
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
637
+ OrderNote: z.lazy(() => OrderNotePartialWithRelationsSchema).array(),
638
+ })).partial();
639
+ export const UserWithPartialRelationsSchema = UserSchema.merge(z.object({
640
+ inventoryTransactions: z.lazy(() => InventoryTransactionPartialWithRelationsSchema).array(),
641
+ OrderNote: z.lazy(() => OrderNotePartialWithRelationsSchema).array(),
642
+ }).partial());
643
+ /////////////////////////////////////////
644
+ // ORDER NOTE SCHEMA
645
+ /////////////////////////////////////////
646
+ export const OrderNoteSchema = z.object({
647
+ type: NoteTypeSchema,
648
+ id: z.uuid(),
649
+ orderId: z.string(),
650
+ note: z.string(),
651
+ createdAt: z.coerce.date(),
652
+ createdBy: z.string().nullable(),
653
+ metadata: JsonValueSchema.nullable(),
654
+ });
655
+ /////////////////////////////////////////
656
+ // ORDER NOTE PARTIAL SCHEMA
657
+ /////////////////////////////////////////
658
+ export const OrderNotePartialSchema = OrderNoteSchema.partial();
659
+ export const OrderNoteWithRelationsSchema = OrderNoteSchema.merge(z.object({
660
+ User: z.lazy(() => UserWithRelationsSchema).nullable(),
661
+ Order: z.lazy(() => OrderWithRelationsSchema),
662
+ }));
663
+ export const OrderNotePartialWithRelationsSchema = OrderNotePartialSchema.merge(z.object({
664
+ User: z.lazy(() => UserPartialWithRelationsSchema).nullable(),
665
+ Order: z.lazy(() => OrderPartialWithRelationsSchema),
666
+ })).partial();
667
+ export const OrderNoteWithPartialRelationsSchema = OrderNoteSchema.merge(z.object({
668
+ User: z.lazy(() => UserPartialWithRelationsSchema).nullable(),
669
+ Order: z.lazy(() => OrderPartialWithRelationsSchema),
670
+ }).partial());