@instockng/api-client 1.0.8 → 1.0.10

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 (193) hide show
  1. package/dist/fetchers/brands.d.ts +1 -1
  2. package/dist/fetchers/carts.d.ts +85 -47
  3. package/dist/fetchers/delivery-zones.d.ts +2 -0
  4. package/dist/fetchers/orders.d.ts +26 -14
  5. package/dist/fetchers/products.d.ts +14 -6
  6. package/dist/hooks/admin/abandoned-carts.d.ts +18 -10
  7. package/dist/hooks/admin/brands.d.ts +4 -4
  8. package/dist/hooks/admin/customers.d.ts +13 -7
  9. package/dist/hooks/admin/delivery-zones.d.ts +23 -15
  10. package/dist/hooks/admin/discount-codes.d.ts +10 -10
  11. package/dist/hooks/admin/inventory.d.ts +4 -0
  12. package/dist/hooks/admin/orders.d.ts +78 -42
  13. package/dist/hooks/admin/products.d.ts +14 -6
  14. package/dist/hooks/admin/stats.d.ts +13 -7
  15. package/dist/hooks/admin/variants.d.ts +5 -5
  16. package/dist/hooks/admin/warehouses.d.ts +11 -7
  17. package/dist/hooks/public/brands.d.ts +1 -1
  18. package/dist/hooks/public/carts.d.ts +85 -47
  19. package/dist/hooks/public/delivery-zones.d.ts +2 -0
  20. package/dist/hooks/public/orders.d.ts +26 -14
  21. package/dist/hooks/public/products.d.ts +14 -6
  22. package/dist/rpc-client.d.ts +335 -187
  23. package/package.json +1 -1
  24. package/dist/apps/backend/src/generated/zod/index.d.ts +0 -1114
  25. package/dist/apps/backend/src/generated/zod/index.js +0 -670
  26. package/dist/apps/backend/src/http-app.d.ts +0 -40
  27. package/dist/apps/backend/src/http-app.js +0 -134
  28. package/dist/apps/backend/src/lib/brand-response.d.ts +0 -14
  29. package/dist/apps/backend/src/lib/brand-response.js +0 -8
  30. package/dist/apps/backend/src/lib/cart-helpers.d.ts +0 -282
  31. package/dist/apps/backend/src/lib/cart-helpers.js +0 -121
  32. package/dist/apps/backend/src/lib/cart-recovery.d.ts +0 -30
  33. package/dist/apps/backend/src/lib/cart-recovery.js +0 -147
  34. package/dist/apps/backend/src/lib/cart-response.d.ts +0 -121
  35. package/dist/apps/backend/src/lib/cart-response.js +0 -150
  36. package/dist/apps/backend/src/lib/clerk.d.ts +0 -18
  37. package/dist/apps/backend/src/lib/clerk.js +0 -190
  38. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +0 -64
  39. package/dist/apps/backend/src/lib/delivery-zone-response.js +0 -24
  40. package/dist/apps/backend/src/lib/discount-code-response.d.ts +0 -42
  41. package/dist/apps/backend/src/lib/discount-code-response.js +0 -19
  42. package/dist/apps/backend/src/lib/discount.d.ts +0 -20
  43. package/dist/apps/backend/src/lib/discount.js +0 -35
  44. package/dist/apps/backend/src/lib/inventory.d.ts +0 -26
  45. package/dist/apps/backend/src/lib/inventory.js +0 -160
  46. package/dist/apps/backend/src/lib/meta-capi.d.ts +0 -53
  47. package/dist/apps/backend/src/lib/meta-capi.js +0 -151
  48. package/dist/apps/backend/src/lib/openapi.d.ts +0 -36
  49. package/dist/apps/backend/src/lib/openapi.js +0 -69
  50. package/dist/apps/backend/src/lib/order-recovery.d.ts +0 -459
  51. package/dist/apps/backend/src/lib/order-recovery.js +0 -378
  52. package/dist/apps/backend/src/lib/order-response.d.ts +0 -138
  53. package/dist/apps/backend/src/lib/order-response.js +0 -61
  54. package/dist/apps/backend/src/lib/pricing.d.ts +0 -39
  55. package/dist/apps/backend/src/lib/pricing.js +0 -62
  56. package/dist/apps/backend/src/lib/prisma.d.ts +0 -9
  57. package/dist/apps/backend/src/lib/prisma.js +0 -30
  58. package/dist/apps/backend/src/lib/product-response.d.ts +0 -82
  59. package/dist/apps/backend/src/lib/product-response.js +0 -29
  60. package/dist/apps/backend/src/lib/sentry.d.ts +0 -48
  61. package/dist/apps/backend/src/lib/sentry.js +0 -180
  62. package/dist/apps/backend/src/lib/utils.d.ts +0 -32
  63. package/dist/apps/backend/src/lib/utils.js +0 -63
  64. package/dist/apps/backend/src/middleware/clerk-auth.d.ts +0 -8
  65. package/dist/apps/backend/src/middleware/clerk-auth.js +0 -89
  66. package/dist/apps/backend/src/middleware/cors.d.ts +0 -8
  67. package/dist/apps/backend/src/middleware/cors.js +0 -11
  68. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +0 -62
  69. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +0 -180
  70. package/dist/apps/backend/src/notifications/producers/order-notification.d.ts +0 -9
  71. package/dist/apps/backend/src/notifications/producers/order-notification.js +0 -18
  72. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.d.ts +0 -10
  73. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.js +0 -11
  74. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +0 -605
  75. package/dist/apps/backend/src/routes/admin/abandoned-carts.js +0 -194
  76. package/dist/apps/backend/src/routes/admin/brands.d.ts +0 -175
  77. package/dist/apps/backend/src/routes/admin/brands.js +0 -118
  78. package/dist/apps/backend/src/routes/admin/customers.d.ts +0 -308
  79. package/dist/apps/backend/src/routes/admin/customers.js +0 -39
  80. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +0 -446
  81. package/dist/apps/backend/src/routes/admin/delivery-zones.js +0 -300
  82. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +0 -478
  83. package/dist/apps/backend/src/routes/admin/discount-codes.js +0 -418
  84. package/dist/apps/backend/src/routes/admin/inventory.d.ts +0 -273
  85. package/dist/apps/backend/src/routes/admin/inventory.js +0 -199
  86. package/dist/apps/backend/src/routes/admin/orders.d.ts +0 -1780
  87. package/dist/apps/backend/src/routes/admin/orders.js +0 -552
  88. package/dist/apps/backend/src/routes/admin/products.d.ts +0 -860
  89. package/dist/apps/backend/src/routes/admin/products.js +0 -126
  90. package/dist/apps/backend/src/routes/admin/stats.d.ts +0 -290
  91. package/dist/apps/backend/src/routes/admin/stats.js +0 -55
  92. package/dist/apps/backend/src/routes/admin/variants.d.ts +0 -239
  93. package/dist/apps/backend/src/routes/admin/variants.js +0 -197
  94. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +0 -373
  95. package/dist/apps/backend/src/routes/admin/warehouses.js +0 -123
  96. package/dist/apps/backend/src/routes/public/brands.d.ts +0 -40
  97. package/dist/apps/backend/src/routes/public/brands.js +0 -38
  98. package/dist/apps/backend/src/routes/public/carts.d.ts +0 -2657
  99. package/dist/apps/backend/src/routes/public/carts.js +0 -778
  100. package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +0 -37
  101. package/dist/apps/backend/src/routes/public/delivery-zones.js +0 -64
  102. package/dist/apps/backend/src/routes/public/orders.d.ts +0 -609
  103. package/dist/apps/backend/src/routes/public/orders.js +0 -184
  104. package/dist/apps/backend/src/routes/public/products.d.ts +0 -449
  105. package/dist/apps/backend/src/routes/public/products.js +0 -133
  106. package/dist/apps/backend/src/types/index.d.ts +0 -43
  107. package/dist/apps/backend/src/types/index.js +0 -2
  108. package/dist/apps/backend/src/validators/brand.d.ts +0 -17
  109. package/dist/apps/backend/src/validators/brand.js +0 -15
  110. package/dist/apps/backend/src/validators/delivery-zone.d.ts +0 -35
  111. package/dist/apps/backend/src/validators/delivery-zone.js +0 -55
  112. package/dist/apps/backend/src/validators/discount-code.d.ts +0 -74
  113. package/dist/apps/backend/src/validators/discount-code.js +0 -50
  114. package/dist/apps/backend/src/validators/inventory.d.ts +0 -20
  115. package/dist/apps/backend/src/validators/inventory.js +0 -15
  116. package/dist/apps/backend/src/validators/order.d.ts +0 -58
  117. package/dist/apps/backend/src/validators/order.js +0 -62
  118. package/dist/apps/backend/src/validators/product.d.ts +0 -18
  119. package/dist/apps/backend/src/validators/product.js +0 -19
  120. package/dist/apps/backend/src/validators/variant.d.ts +0 -19
  121. package/dist/apps/backend/src/validators/variant.js +0 -19
  122. package/dist/apps/backend/src/validators/warehouse.d.ts +0 -15
  123. package/dist/apps/backend/src/validators/warehouse.js +0 -15
  124. package/dist/packages/api-client/src/backend-types.d.ts +0 -10
  125. package/dist/packages/api-client/src/backend-types.js +0 -10
  126. package/dist/packages/api-client/src/client.d.ts +0 -20
  127. package/dist/packages/api-client/src/client.js +0 -40
  128. package/dist/packages/api-client/src/enum-types.d.ts +0 -8
  129. package/dist/packages/api-client/src/enum-types.js +0 -5
  130. package/dist/packages/api-client/src/fetchers/brands.d.ts +0 -25
  131. package/dist/packages/api-client/src/fetchers/brands.js +0 -26
  132. package/dist/packages/api-client/src/fetchers/carts.d.ts +0 -2337
  133. package/dist/packages/api-client/src/fetchers/carts.js +0 -174
  134. package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +0 -30
  135. package/dist/packages/api-client/src/fetchers/delivery-zones.js +0 -26
  136. package/dist/packages/api-client/src/fetchers/index.d.ts +0 -22
  137. package/dist/packages/api-client/src/fetchers/index.js +0 -22
  138. package/dist/packages/api-client/src/fetchers/orders.d.ts +0 -544
  139. package/dist/packages/api-client/src/fetchers/orders.js +0 -44
  140. package/dist/packages/api-client/src/fetchers/products.d.ts +0 -386
  141. package/dist/packages/api-client/src/fetchers/products.js +0 -42
  142. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +0 -535
  143. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.js +0 -83
  144. package/dist/packages/api-client/src/hooks/admin/brands.d.ts +0 -79
  145. package/dist/packages/api-client/src/hooks/admin/brands.js +0 -108
  146. package/dist/packages/api-client/src/hooks/admin/customers.d.ts +0 -280
  147. package/dist/packages/api-client/src/hooks/admin/customers.js +0 -26
  148. package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +0 -278
  149. package/dist/packages/api-client/src/hooks/admin/delivery-zones.js +0 -176
  150. package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +0 -299
  151. package/dist/packages/api-client/src/hooks/admin/discount-codes.js +0 -165
  152. package/dist/packages/api-client/src/hooks/admin/index.d.ts +0 -16
  153. package/dist/packages/api-client/src/hooks/admin/index.js +0 -16
  154. package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +0 -224
  155. package/dist/packages/api-client/src/hooks/admin/inventory.js +0 -107
  156. package/dist/packages/api-client/src/hooks/admin/orders.d.ts +0 -1674
  157. package/dist/packages/api-client/src/hooks/admin/orders.js +0 -178
  158. package/dist/packages/api-client/src/hooks/admin/products.d.ts +0 -374
  159. package/dist/packages/api-client/src/hooks/admin/products.js +0 -89
  160. package/dist/packages/api-client/src/hooks/admin/stats.d.ts +0 -279
  161. package/dist/packages/api-client/src/hooks/admin/stats.js +0 -25
  162. package/dist/packages/api-client/src/hooks/admin/variants.d.ts +0 -115
  163. package/dist/packages/api-client/src/hooks/admin/variants.js +0 -127
  164. package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +0 -277
  165. package/dist/packages/api-client/src/hooks/admin/warehouses.js +0 -108
  166. package/dist/packages/api-client/src/hooks/public/brands.d.ts +0 -33
  167. package/dist/packages/api-client/src/hooks/public/brands.js +0 -30
  168. package/dist/packages/api-client/src/hooks/public/carts.d.ts +0 -2407
  169. package/dist/packages/api-client/src/hooks/public/carts.js +0 -213
  170. package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +0 -36
  171. package/dist/packages/api-client/src/hooks/public/delivery-zones.js +0 -28
  172. package/dist/packages/api-client/src/hooks/public/index.d.ts +0 -10
  173. package/dist/packages/api-client/src/hooks/public/index.js +0 -10
  174. package/dist/packages/api-client/src/hooks/public/orders.d.ts +0 -563
  175. package/dist/packages/api-client/src/hooks/public/orders.js +0 -50
  176. package/dist/packages/api-client/src/hooks/public/products.d.ts +0 -398
  177. package/dist/packages/api-client/src/hooks/public/products.js +0 -47
  178. package/dist/packages/api-client/src/hooks/use-query-unwrapped.d.ts +0 -20
  179. package/dist/packages/api-client/src/hooks/use-query-unwrapped.js +0 -22
  180. package/dist/packages/api-client/src/hooks/useApiConfig.d.ts +0 -12
  181. package/dist/packages/api-client/src/hooks/useApiConfig.js +0 -14
  182. package/dist/packages/api-client/src/index.d.ts +0 -20
  183. package/dist/packages/api-client/src/index.js +0 -25
  184. package/dist/packages/api-client/src/provider.d.ts +0 -36
  185. package/dist/packages/api-client/src/provider.js +0 -54
  186. package/dist/packages/api-client/src/rpc-client.d.ts +0 -9639
  187. package/dist/packages/api-client/src/rpc-client.js +0 -78
  188. package/dist/packages/api-client/src/rpc-types.d.ts +0 -76
  189. package/dist/packages/api-client/src/rpc-types.js +0 -7
  190. package/dist/packages/api-client/src/types.d.ts +0 -34
  191. package/dist/packages/api-client/src/types.js +0 -16
  192. package/dist/packages/api-client/src/utils/query-keys.d.ts +0 -106
  193. package/dist/packages/api-client/src/utils/query-keys.js +0 -108
@@ -1,670 +0,0 @@
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());