@instockng/api-client 1.0.11 → 1.0.12

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 (169) hide show
  1. package/package.json +2 -2
  2. package/dist/apps/backend/src/http-app.d.ts +0 -40
  3. package/dist/apps/backend/src/http-app.js +0 -134
  4. package/dist/apps/backend/src/lib/brand-response.d.ts +0 -16
  5. package/dist/apps/backend/src/lib/brand-response.js +0 -8
  6. package/dist/apps/backend/src/lib/cart-helpers.d.ts +0 -286
  7. package/dist/apps/backend/src/lib/cart-helpers.js +0 -121
  8. package/dist/apps/backend/src/lib/cart-recovery.d.ts +0 -30
  9. package/dist/apps/backend/src/lib/cart-recovery.js +0 -147
  10. package/dist/apps/backend/src/lib/cart-response.d.ts +0 -123
  11. package/dist/apps/backend/src/lib/cart-response.js +0 -150
  12. package/dist/apps/backend/src/lib/clerk.d.ts +0 -18
  13. package/dist/apps/backend/src/lib/clerk.js +0 -190
  14. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +0 -66
  15. package/dist/apps/backend/src/lib/delivery-zone-response.js +0 -24
  16. package/dist/apps/backend/src/lib/discount-code-response.d.ts +0 -44
  17. package/dist/apps/backend/src/lib/discount-code-response.js +0 -19
  18. package/dist/apps/backend/src/lib/discount.d.ts +0 -20
  19. package/dist/apps/backend/src/lib/discount.js +0 -35
  20. package/dist/apps/backend/src/lib/inventory.d.ts +0 -26
  21. package/dist/apps/backend/src/lib/inventory.js +0 -160
  22. package/dist/apps/backend/src/lib/meta-capi.d.ts +0 -53
  23. package/dist/apps/backend/src/lib/meta-capi.js +0 -151
  24. package/dist/apps/backend/src/lib/openapi.d.ts +0 -36
  25. package/dist/apps/backend/src/lib/openapi.js +0 -69
  26. package/dist/apps/backend/src/lib/order-recovery.d.ts +0 -465
  27. package/dist/apps/backend/src/lib/order-recovery.js +0 -378
  28. package/dist/apps/backend/src/lib/order-response.d.ts +0 -140
  29. package/dist/apps/backend/src/lib/order-response.js +0 -61
  30. package/dist/apps/backend/src/lib/pricing.d.ts +0 -39
  31. package/dist/apps/backend/src/lib/pricing.js +0 -62
  32. package/dist/apps/backend/src/lib/prisma.d.ts +0 -9
  33. package/dist/apps/backend/src/lib/prisma.js +0 -30
  34. package/dist/apps/backend/src/lib/product-response.d.ts +0 -84
  35. package/dist/apps/backend/src/lib/product-response.js +0 -29
  36. package/dist/apps/backend/src/lib/sentry.d.ts +0 -48
  37. package/dist/apps/backend/src/lib/sentry.js +0 -180
  38. package/dist/apps/backend/src/lib/utils.d.ts +0 -32
  39. package/dist/apps/backend/src/lib/utils.js +0 -63
  40. package/dist/apps/backend/src/middleware/clerk-auth.d.ts +0 -8
  41. package/dist/apps/backend/src/middleware/clerk-auth.js +0 -89
  42. package/dist/apps/backend/src/middleware/cors.d.ts +0 -8
  43. package/dist/apps/backend/src/middleware/cors.js +0 -11
  44. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +0 -62
  45. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +0 -180
  46. package/dist/apps/backend/src/notifications/producers/order-notification.d.ts +0 -9
  47. package/dist/apps/backend/src/notifications/producers/order-notification.js +0 -18
  48. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.d.ts +0 -10
  49. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.js +0 -11
  50. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +0 -609
  51. package/dist/apps/backend/src/routes/admin/abandoned-carts.js +0 -194
  52. package/dist/apps/backend/src/routes/admin/brands.d.ts +0 -183
  53. package/dist/apps/backend/src/routes/admin/brands.js +0 -118
  54. package/dist/apps/backend/src/routes/admin/customers.d.ts +0 -310
  55. package/dist/apps/backend/src/routes/admin/customers.js +0 -39
  56. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +0 -454
  57. package/dist/apps/backend/src/routes/admin/delivery-zones.js +0 -300
  58. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +0 -488
  59. package/dist/apps/backend/src/routes/admin/discount-codes.js +0 -418
  60. package/dist/apps/backend/src/routes/admin/inventory.d.ts +0 -273
  61. package/dist/apps/backend/src/routes/admin/inventory.js +0 -199
  62. package/dist/apps/backend/src/routes/admin/orders.d.ts +0 -1792
  63. package/dist/apps/backend/src/routes/admin/orders.js +0 -552
  64. package/dist/apps/backend/src/routes/admin/products.d.ts +0 -868
  65. package/dist/apps/backend/src/routes/admin/products.js +0 -126
  66. package/dist/apps/backend/src/routes/admin/stats.d.ts +0 -292
  67. package/dist/apps/backend/src/routes/admin/stats.js +0 -55
  68. package/dist/apps/backend/src/routes/admin/variants.d.ts +0 -239
  69. package/dist/apps/backend/src/routes/admin/variants.js +0 -197
  70. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +0 -375
  71. package/dist/apps/backend/src/routes/admin/warehouses.js +0 -123
  72. package/dist/apps/backend/src/routes/public/brands.d.ts +0 -41
  73. package/dist/apps/backend/src/routes/public/brands.js +0 -39
  74. package/dist/apps/backend/src/routes/public/carts.d.ts +0 -2675
  75. package/dist/apps/backend/src/routes/public/carts.js +0 -778
  76. package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +0 -37
  77. package/dist/apps/backend/src/routes/public/delivery-zones.js +0 -64
  78. package/dist/apps/backend/src/routes/public/orders.d.ts +0 -613
  79. package/dist/apps/backend/src/routes/public/orders.js +0 -184
  80. package/dist/apps/backend/src/routes/public/products.d.ts +0 -453
  81. package/dist/apps/backend/src/routes/public/products.js +0 -133
  82. package/dist/apps/backend/src/types/index.d.ts +0 -43
  83. package/dist/apps/backend/src/types/index.js +0 -2
  84. package/dist/apps/backend/src/validators/brand.d.ts +0 -21
  85. package/dist/apps/backend/src/validators/brand.js +0 -19
  86. package/dist/apps/backend/src/validators/delivery-zone.d.ts +0 -35
  87. package/dist/apps/backend/src/validators/delivery-zone.js +0 -55
  88. package/dist/apps/backend/src/validators/discount-code.d.ts +0 -74
  89. package/dist/apps/backend/src/validators/discount-code.js +0 -50
  90. package/dist/apps/backend/src/validators/inventory.d.ts +0 -20
  91. package/dist/apps/backend/src/validators/inventory.js +0 -15
  92. package/dist/apps/backend/src/validators/order.d.ts +0 -58
  93. package/dist/apps/backend/src/validators/order.js +0 -62
  94. package/dist/apps/backend/src/validators/product.d.ts +0 -18
  95. package/dist/apps/backend/src/validators/product.js +0 -19
  96. package/dist/apps/backend/src/validators/variant.d.ts +0 -19
  97. package/dist/apps/backend/src/validators/variant.js +0 -19
  98. package/dist/apps/backend/src/validators/warehouse.d.ts +0 -15
  99. package/dist/apps/backend/src/validators/warehouse.js +0 -15
  100. /package/dist/{packages/api-client/src/backend-types.d.ts → backend-types.d.ts} +0 -0
  101. /package/dist/{packages/api-client/src/backend-types.js → backend-types.js} +0 -0
  102. /package/dist/{packages/api-client/src/client.d.ts → client.d.ts} +0 -0
  103. /package/dist/{packages/api-client/src/client.js → client.js} +0 -0
  104. /package/dist/{packages/api-client/src/enum-types.d.ts → enum-types.d.ts} +0 -0
  105. /package/dist/{packages/api-client/src/enum-types.js → enum-types.js} +0 -0
  106. /package/dist/{packages/api-client/src/fetchers → fetchers}/brands.d.ts +0 -0
  107. /package/dist/{packages/api-client/src/fetchers → fetchers}/brands.js +0 -0
  108. /package/dist/{packages/api-client/src/fetchers → fetchers}/carts.d.ts +0 -0
  109. /package/dist/{packages/api-client/src/fetchers → fetchers}/carts.js +0 -0
  110. /package/dist/{packages/api-client/src/fetchers → fetchers}/delivery-zones.d.ts +0 -0
  111. /package/dist/{packages/api-client/src/fetchers → fetchers}/delivery-zones.js +0 -0
  112. /package/dist/{packages/api-client/src/fetchers → fetchers}/index.d.ts +0 -0
  113. /package/dist/{packages/api-client/src/fetchers → fetchers}/index.js +0 -0
  114. /package/dist/{packages/api-client/src/fetchers → fetchers}/orders.d.ts +0 -0
  115. /package/dist/{packages/api-client/src/fetchers → fetchers}/orders.js +0 -0
  116. /package/dist/{packages/api-client/src/fetchers → fetchers}/products.d.ts +0 -0
  117. /package/dist/{packages/api-client/src/fetchers → fetchers}/products.js +0 -0
  118. /package/dist/{packages/api-client/src/hooks → hooks}/admin/abandoned-carts.d.ts +0 -0
  119. /package/dist/{packages/api-client/src/hooks → hooks}/admin/abandoned-carts.js +0 -0
  120. /package/dist/{packages/api-client/src/hooks → hooks}/admin/brands.d.ts +0 -0
  121. /package/dist/{packages/api-client/src/hooks → hooks}/admin/brands.js +0 -0
  122. /package/dist/{packages/api-client/src/hooks → hooks}/admin/customers.d.ts +0 -0
  123. /package/dist/{packages/api-client/src/hooks → hooks}/admin/customers.js +0 -0
  124. /package/dist/{packages/api-client/src/hooks → hooks}/admin/delivery-zones.d.ts +0 -0
  125. /package/dist/{packages/api-client/src/hooks → hooks}/admin/delivery-zones.js +0 -0
  126. /package/dist/{packages/api-client/src/hooks → hooks}/admin/discount-codes.d.ts +0 -0
  127. /package/dist/{packages/api-client/src/hooks → hooks}/admin/discount-codes.js +0 -0
  128. /package/dist/{packages/api-client/src/hooks → hooks}/admin/index.d.ts +0 -0
  129. /package/dist/{packages/api-client/src/hooks → hooks}/admin/index.js +0 -0
  130. /package/dist/{packages/api-client/src/hooks → hooks}/admin/inventory.d.ts +0 -0
  131. /package/dist/{packages/api-client/src/hooks → hooks}/admin/inventory.js +0 -0
  132. /package/dist/{packages/api-client/src/hooks → hooks}/admin/orders.d.ts +0 -0
  133. /package/dist/{packages/api-client/src/hooks → hooks}/admin/orders.js +0 -0
  134. /package/dist/{packages/api-client/src/hooks → hooks}/admin/products.d.ts +0 -0
  135. /package/dist/{packages/api-client/src/hooks → hooks}/admin/products.js +0 -0
  136. /package/dist/{packages/api-client/src/hooks → hooks}/admin/stats.d.ts +0 -0
  137. /package/dist/{packages/api-client/src/hooks → hooks}/admin/stats.js +0 -0
  138. /package/dist/{packages/api-client/src/hooks → hooks}/admin/variants.d.ts +0 -0
  139. /package/dist/{packages/api-client/src/hooks → hooks}/admin/variants.js +0 -0
  140. /package/dist/{packages/api-client/src/hooks → hooks}/admin/warehouses.d.ts +0 -0
  141. /package/dist/{packages/api-client/src/hooks → hooks}/admin/warehouses.js +0 -0
  142. /package/dist/{packages/api-client/src/hooks → hooks}/public/brands.d.ts +0 -0
  143. /package/dist/{packages/api-client/src/hooks → hooks}/public/brands.js +0 -0
  144. /package/dist/{packages/api-client/src/hooks → hooks}/public/carts.d.ts +0 -0
  145. /package/dist/{packages/api-client/src/hooks → hooks}/public/carts.js +0 -0
  146. /package/dist/{packages/api-client/src/hooks → hooks}/public/delivery-zones.d.ts +0 -0
  147. /package/dist/{packages/api-client/src/hooks → hooks}/public/delivery-zones.js +0 -0
  148. /package/dist/{packages/api-client/src/hooks → hooks}/public/index.d.ts +0 -0
  149. /package/dist/{packages/api-client/src/hooks → hooks}/public/index.js +0 -0
  150. /package/dist/{packages/api-client/src/hooks → hooks}/public/orders.d.ts +0 -0
  151. /package/dist/{packages/api-client/src/hooks → hooks}/public/orders.js +0 -0
  152. /package/dist/{packages/api-client/src/hooks → hooks}/public/products.d.ts +0 -0
  153. /package/dist/{packages/api-client/src/hooks → hooks}/public/products.js +0 -0
  154. /package/dist/{packages/api-client/src/hooks → hooks}/use-query-unwrapped.d.ts +0 -0
  155. /package/dist/{packages/api-client/src/hooks → hooks}/use-query-unwrapped.js +0 -0
  156. /package/dist/{packages/api-client/src/hooks → hooks}/useApiConfig.d.ts +0 -0
  157. /package/dist/{packages/api-client/src/hooks → hooks}/useApiConfig.js +0 -0
  158. /package/dist/{packages/api-client/src/index.d.ts → index.d.ts} +0 -0
  159. /package/dist/{packages/api-client/src/index.js → index.js} +0 -0
  160. /package/dist/{packages/api-client/src/provider.d.ts → provider.d.ts} +0 -0
  161. /package/dist/{packages/api-client/src/provider.js → provider.js} +0 -0
  162. /package/dist/{packages/api-client/src/rpc-client.d.ts → rpc-client.d.ts} +0 -0
  163. /package/dist/{packages/api-client/src/rpc-client.js → rpc-client.js} +0 -0
  164. /package/dist/{packages/api-client/src/rpc-types.d.ts → rpc-types.d.ts} +0 -0
  165. /package/dist/{packages/api-client/src/rpc-types.js → rpc-types.js} +0 -0
  166. /package/dist/{packages/api-client/src/types.d.ts → types.d.ts} +0 -0
  167. /package/dist/{packages/api-client/src/types.js → types.js} +0 -0
  168. /package/dist/{packages/api-client/src/utils → utils}/query-keys.d.ts +0 -0
  169. /package/dist/{packages/api-client/src/utils → utils}/query-keys.js +0 -0
@@ -1,133 +0,0 @@
1
- import { Hono } from 'hono';
2
- import { zValidator } from '@hono/zod-validator';
3
- import { z } from 'zod';
4
- import { getPrismaClient } from '../../lib/prisma';
5
- import { getTotalInventoryForVariant } from '../../lib/inventory';
6
- import { formatProductResponse, PRODUCT_INCLUDE_FULL_PUBLIC } from '../../lib/product-response';
7
- const app = new Hono()
8
- // GET single product by slug with variants (including availability)
9
- .get('/product/:slug', zValidator('param', z.object({
10
- slug: z.string(),
11
- })), async (c) => {
12
- try {
13
- const { slug } = c.req.valid('param');
14
- const prisma = getPrismaClient(c.env.DATABASE_URL);
15
- // Fetch product and its active variants
16
- const product = await prisma.product.findFirst({
17
- where: {
18
- slug,
19
- isActive: true,
20
- deletedAt: null,
21
- },
22
- include: PRODUCT_INCLUDE_FULL_PUBLIC,
23
- });
24
- if (!product) {
25
- return c.json({
26
- error: { code: 'PRODUCT_NOT_FOUND', message: 'Product not found' },
27
- }, 404);
28
- }
29
- // Attach availability info for each variant
30
- const variantsWithAvailability = [];
31
- for (const variant of product.variants) {
32
- if (!variant.trackInventory) {
33
- variantsWithAvailability.push({
34
- ...variant,
35
- availability: {
36
- available: true,
37
- trackInventory: false,
38
- totalInventory: null,
39
- },
40
- });
41
- }
42
- else {
43
- const totalInventory = await getTotalInventoryForVariant(prisma, variant.id);
44
- variantsWithAvailability.push({
45
- ...variant,
46
- availability: {
47
- available: totalInventory > 0,
48
- trackInventory: true,
49
- totalInventory,
50
- },
51
- });
52
- }
53
- }
54
- const data = {
55
- ...product,
56
- variants: variantsWithAvailability,
57
- };
58
- return c.json(formatProductResponse(data), 200);
59
- }
60
- catch (error) {
61
- console.error('Get product error:', error);
62
- return c.json({
63
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve product' },
64
- }, 500);
65
- }
66
- })
67
- // GET products by brand with variants (including availability)
68
- .get('/:brandId', zValidator('param', z.object({
69
- brandId: z.uuid(),
70
- })), async (c) => {
71
- try {
72
- const { brandId } = c.req.valid('param');
73
- const prisma = getPrismaClient(c.env.DATABASE_URL);
74
- // Validate brand exists
75
- const brand = await prisma.brand.findFirst({
76
- where: { id: brandId, deletedAt: null },
77
- });
78
- if (!brand) {
79
- return c.json({
80
- error: { code: 'BRAND_NOT_FOUND', message: 'Brand not found' },
81
- }, 404);
82
- }
83
- // Fetch products and their active variants for the brand
84
- const products = await prisma.product.findMany({
85
- where: {
86
- brandId,
87
- isActive: true,
88
- deletedAt: null,
89
- },
90
- include: PRODUCT_INCLUDE_FULL_PUBLIC,
91
- });
92
- // Attach availability info for each variant
93
- const data = [];
94
- for (const product of products) {
95
- const variantsWithAvailability = [];
96
- for (const variant of product.variants) {
97
- if (!variant.trackInventory) {
98
- variantsWithAvailability.push({
99
- ...variant,
100
- availability: {
101
- available: true,
102
- trackInventory: false,
103
- totalInventory: null,
104
- },
105
- });
106
- }
107
- else {
108
- const totalInventory = await getTotalInventoryForVariant(prisma, variant.id);
109
- variantsWithAvailability.push({
110
- ...variant,
111
- availability: {
112
- available: totalInventory > 0,
113
- trackInventory: true,
114
- totalInventory,
115
- },
116
- });
117
- }
118
- }
119
- data.push({
120
- ...product,
121
- variants: variantsWithAvailability,
122
- });
123
- }
124
- return c.json(data.map(formatProductResponse), 200);
125
- }
126
- catch (error) {
127
- console.error('Get products with variants error:', error);
128
- return c.json({
129
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve products' },
130
- }, 500);
131
- }
132
- });
133
- export default app;
@@ -1,43 +0,0 @@
1
- export interface Env {
2
- DATABASE_URL: string;
3
- CLERK_PUBLISHABLE_KEY: string;
4
- CLERK_SECRET_KEY: string;
5
- API_KEY: string;
6
- TWILIO_ACCOUNT_SID?: string;
7
- TWILIO_AUTH_TOKEN?: string;
8
- TWILIO_WHATSAPP_FROM?: string;
9
- WHATSAPP_TEMPLATE_ORDER_CONFIRMATION?: string;
10
- WHATSAPP_TEMPLATE_ORDER_SHIPPED?: string;
11
- WHATSAPP_TEMPLATE_ORDER_DELIVERED?: string;
12
- WHATSAPP_TEMPLATE_ORDER_CANCELLED?: string;
13
- WHATSAPP_TEMPLATE_CART_RECOVERY?: string;
14
- RESEND_API_KEY?: string;
15
- EMAIL_FROM?: string;
16
- META_CAPI_ACCESS_TOKEN?: string;
17
- SENTRY_DSN?: string;
18
- FRONTEND_URL: string;
19
- ALLOWED_ORIGINS: string;
20
- ENVIRONMENT: string;
21
- WHATSAPP_QUEUE?: Queue;
22
- EMAIL_QUEUE?: Queue;
23
- META_CAPI_QUEUE?: Queue;
24
- }
25
- export interface AppContext {
26
- Bindings: Env;
27
- Variables: {
28
- user?: {
29
- id: string;
30
- email: string;
31
- name?: string;
32
- };
33
- dbUser?: {
34
- id: string;
35
- clerkId: string;
36
- email: string;
37
- name: string | null;
38
- role: string;
39
- createdAt: Date;
40
- deletedAt: Date | null;
41
- };
42
- };
43
- }
@@ -1,2 +0,0 @@
1
- /// <reference types="@cloudflare/workers-types" />
2
- export {};
@@ -1,21 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createBrandSchema: z.ZodObject<{
3
- name: z.ZodString;
4
- logoUrl: z.ZodOptional<z.ZodURL>;
5
- siteUrl: z.ZodURL;
6
- domain: z.ZodString;
7
- metaPixelId: z.ZodOptional<z.ZodString>;
8
- paystackPublicKey: z.ZodOptional<z.ZodString>;
9
- paystackSecretKey: z.ZodOptional<z.ZodString>;
10
- }, z.core.$strip>;
11
- export type CreateBrandInput = z.infer<typeof createBrandSchema>;
12
- export declare const updateBrandSchema: z.ZodObject<{
13
- name: z.ZodOptional<z.ZodString>;
14
- logoUrl: z.ZodOptional<z.ZodURL>;
15
- siteUrl: z.ZodOptional<z.ZodURL>;
16
- domain: z.ZodOptional<z.ZodString>;
17
- metaPixelId: z.ZodOptional<z.ZodString>;
18
- paystackPublicKey: z.ZodOptional<z.ZodString>;
19
- paystackSecretKey: z.ZodOptional<z.ZodString>;
20
- }, z.core.$strip>;
21
- export type UpdateBrandInput = z.infer<typeof updateBrandSchema>;
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- export const createBrandSchema = z.object({
3
- name: z.string().min(1),
4
- logoUrl: z.url().optional(),
5
- siteUrl: z.url(),
6
- domain: z.string().min(1),
7
- metaPixelId: z.string().optional(),
8
- paystackPublicKey: z.string().optional(),
9
- paystackSecretKey: z.string().optional(),
10
- });
11
- export const updateBrandSchema = z.object({
12
- name: z.string().min(1).optional(),
13
- logoUrl: z.url().optional(),
14
- siteUrl: z.url().optional(),
15
- domain: z.string().min(1).optional(),
16
- metaPixelId: z.string().optional(),
17
- paystackPublicKey: z.string().optional(),
18
- paystackSecretKey: z.string().optional(),
19
- });
@@ -1,35 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createStateSchema: z.ZodObject<{
3
- name: z.ZodString;
4
- isActive: z.ZodOptional<z.ZodBoolean>;
5
- }, z.core.$strip>;
6
- export declare const updateStateSchema: z.ZodObject<{
7
- name: z.ZodOptional<z.ZodString>;
8
- isActive: z.ZodOptional<z.ZodBoolean>;
9
- }, z.core.$strip>;
10
- export declare const createDeliveryZoneSchema: z.ZodObject<{
11
- stateId: z.ZodUUID;
12
- brandId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
13
- name: z.ZodString;
14
- deliveryCost: z.ZodNumber;
15
- freeShippingThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
- allowCOD: z.ZodOptional<z.ZodBoolean>;
17
- allowOnline: z.ZodOptional<z.ZodBoolean>;
18
- waybillOnly: z.ZodOptional<z.ZodBoolean>;
19
- estimatedDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
20
- noteTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
- noteContent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
- isActive: z.ZodOptional<z.ZodBoolean>;
23
- }, z.core.$strip>;
24
- export declare const updateDeliveryZoneSchema: z.ZodObject<{
25
- name: z.ZodOptional<z.ZodString>;
26
- deliveryCost: z.ZodOptional<z.ZodNumber>;
27
- freeShippingThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
28
- allowCOD: z.ZodOptional<z.ZodBoolean>;
29
- allowOnline: z.ZodOptional<z.ZodBoolean>;
30
- waybillOnly: z.ZodOptional<z.ZodBoolean>;
31
- estimatedDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
32
- noteTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
- noteContent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
- isActive: z.ZodOptional<z.ZodBoolean>;
35
- }, z.core.$strip>;
@@ -1,55 +0,0 @@
1
- import { z } from 'zod';
2
- export const createStateSchema = z.object({
3
- name: z.string().min(1),
4
- isActive: z.boolean().optional(),
5
- });
6
- export const updateStateSchema = z.object({
7
- name: z.string().min(1).optional(),
8
- isActive: z.boolean().optional(),
9
- });
10
- export const createDeliveryZoneSchema = z
11
- .object({
12
- stateId: z.uuid(),
13
- brandId: z.uuid().nullable().optional(),
14
- name: z.string().min(1),
15
- deliveryCost: z.number().nonnegative(),
16
- freeShippingThreshold: z.number().nonnegative().nullable().optional(),
17
- allowCOD: z.boolean().optional(),
18
- allowOnline: z.boolean().optional(),
19
- waybillOnly: z.boolean().optional(),
20
- estimatedDays: z.number().int().positive().nullable().optional(),
21
- noteTitle: z.string().nullable().optional(),
22
- noteContent: z.string().nullable().optional(),
23
- isActive: z.boolean().optional(),
24
- })
25
- .refine((data) => {
26
- // If waybillOnly is true, allowCOD must be false
27
- if (data.waybillOnly && data.allowCOD !== false) {
28
- return false;
29
- }
30
- return true;
31
- }, {
32
- message: 'When waybillOnly is true, allowCOD must be false',
33
- });
34
- export const updateDeliveryZoneSchema = z
35
- .object({
36
- name: z.string().min(1).optional(),
37
- deliveryCost: z.number().nonnegative().optional(),
38
- freeShippingThreshold: z.number().nonnegative().nullable().optional(),
39
- allowCOD: z.boolean().optional(),
40
- allowOnline: z.boolean().optional(),
41
- waybillOnly: z.boolean().optional(),
42
- estimatedDays: z.number().int().positive().nullable().optional(),
43
- noteTitle: z.string().nullable().optional(),
44
- noteContent: z.string().nullable().optional(),
45
- isActive: z.boolean().optional(),
46
- })
47
- .refine((data) => {
48
- // If waybillOnly is being set to true, allowCOD must be false
49
- if (data.waybillOnly && data.allowCOD !== false && data.allowCOD !== undefined) {
50
- return false;
51
- }
52
- return true;
53
- }, {
54
- message: 'When waybillOnly is true, allowCOD must be false',
55
- });
@@ -1,74 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createDiscountCodeSchema: z.ZodObject<{
3
- code: z.ZodString;
4
- brandId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
- type: z.ZodEnum<{
6
- fixed: "fixed";
7
- percentage: "percentage";
8
- }>;
9
- value: z.ZodNumber;
10
- description: z.ZodOptional<z.ZodString>;
11
- category: z.ZodDefault<z.ZodEnum<{
12
- manual: "manual";
13
- recovery: "recovery";
14
- influencer: "influencer";
15
- seasonal: "seasonal";
16
- referral: "referral";
17
- }>>;
18
- minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
19
- maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
20
- usageLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
- perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
22
- validFrom: z.ZodOptional<z.ZodString>;
23
- validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
- isActive: z.ZodDefault<z.ZodBoolean>;
25
- isAutoApply: z.ZodDefault<z.ZodBoolean>;
26
- }, z.core.$strip>;
27
- export declare const updateDiscountCodeSchema: z.ZodObject<{
28
- code: z.ZodOptional<z.ZodString>;
29
- type: z.ZodOptional<z.ZodEnum<{
30
- fixed: "fixed";
31
- percentage: "percentage";
32
- }>>;
33
- value: z.ZodOptional<z.ZodNumber>;
34
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
- category: z.ZodOptional<z.ZodEnum<{
36
- manual: "manual";
37
- recovery: "recovery";
38
- influencer: "influencer";
39
- seasonal: "seasonal";
40
- referral: "referral";
41
- }>>;
42
- minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
43
- maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
- usageLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
45
- perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
46
- validFrom: z.ZodOptional<z.ZodString>;
47
- validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
- isActive: z.ZodOptional<z.ZodBoolean>;
49
- isAutoApply: z.ZodOptional<z.ZodBoolean>;
50
- }, z.core.$strip>;
51
- export declare const bulkGenerateCodesSchema: z.ZodObject<{
52
- prefix: z.ZodString;
53
- count: z.ZodNumber;
54
- brandId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
- type: z.ZodEnum<{
56
- fixed: "fixed";
57
- percentage: "percentage";
58
- }>;
59
- value: z.ZodNumber;
60
- description: z.ZodOptional<z.ZodString>;
61
- category: z.ZodDefault<z.ZodEnum<{
62
- manual: "manual";
63
- recovery: "recovery";
64
- influencer: "influencer";
65
- seasonal: "seasonal";
66
- referral: "referral";
67
- }>>;
68
- minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
69
- maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
70
- perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
71
- validFrom: z.ZodOptional<z.ZodString>;
72
- validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
- isActive: z.ZodDefault<z.ZodBoolean>;
74
- }, z.core.$strip>;
@@ -1,50 +0,0 @@
1
- import { z } from 'zod';
2
- // Create discount code schema
3
- export const createDiscountCodeSchema = z.object({
4
- code: z.string().min(1).max(50).regex(/^[A-Z0-9-]+$/, 'Code must contain only uppercase letters, numbers, and hyphens'),
5
- brandId: z.string().uuid().nullable().optional(),
6
- type: z.enum(['percentage', 'fixed']),
7
- value: z.number().positive(), // Percentage (e.g., 10.00 for 10%) or fixed amount in Naira
8
- description: z.string().min(1).max(500).optional(),
9
- category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).default('manual'),
10
- minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
11
- maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
12
- usageLimit: z.number().int().positive().nullable().optional(),
13
- perCustomerLimit: z.number().int().positive().nullable().optional(),
14
- validFrom: z.string().datetime().optional(),
15
- validUntil: z.string().datetime().nullable().optional(),
16
- isActive: z.boolean().default(true),
17
- isAutoApply: z.boolean().default(false),
18
- });
19
- // Update discount code schema (all fields optional)
20
- export const updateDiscountCodeSchema = z.object({
21
- code: z.string().min(1).max(50).regex(/^[A-Z0-9-]+$/).optional(),
22
- type: z.enum(['percentage', 'fixed']).optional(),
23
- value: z.number().positive().optional(), // Percentage or fixed amount in Naira
24
- description: z.string().min(1).max(500).nullable().optional(),
25
- category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).optional(),
26
- minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
27
- maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
28
- usageLimit: z.number().int().positive().nullable().optional(),
29
- perCustomerLimit: z.number().int().positive().nullable().optional(),
30
- validFrom: z.string().datetime().optional(),
31
- validUntil: z.string().datetime().nullable().optional(),
32
- isActive: z.boolean().optional(),
33
- isAutoApply: z.boolean().optional(),
34
- });
35
- // Bulk generate discount codes schema
36
- export const bulkGenerateCodesSchema = z.object({
37
- prefix: z.string().min(1).max(20).regex(/^[A-Z0-9-]+$/),
38
- count: z.number().int().positive().max(1000), // Max 1000 codes at once
39
- brandId: z.string().uuid().nullable().optional(),
40
- type: z.enum(['percentage', 'fixed']),
41
- value: z.number().positive(), // Percentage or fixed amount in Naira
42
- description: z.string().min(1).max(500).optional(),
43
- category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).default('manual'),
44
- minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
45
- maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
46
- perCustomerLimit: z.number().int().positive().nullable().optional(),
47
- validFrom: z.string().datetime().optional(),
48
- validUntil: z.string().datetime().nullable().optional(),
49
- isActive: z.boolean().default(true),
50
- });
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const adjustInventorySchema: z.ZodObject<{
3
- variantId: z.ZodUUID;
4
- warehouseId: z.ZodUUID;
5
- quantity: z.ZodNumber;
6
- type: z.ZodEnum<{
7
- restock: "restock";
8
- adjustment: "adjustment";
9
- damaged: "damaged";
10
- initial: "initial";
11
- }>;
12
- reason: z.ZodOptional<z.ZodString>;
13
- }, z.core.$strip>;
14
- export declare const transferInventorySchema: z.ZodObject<{
15
- variantId: z.ZodUUID;
16
- fromWarehouseId: z.ZodUUID;
17
- toWarehouseId: z.ZodUUID;
18
- quantity: z.ZodNumber;
19
- reason: z.ZodOptional<z.ZodString>;
20
- }, z.core.$strip>;
@@ -1,15 +0,0 @@
1
- import { z } from 'zod';
2
- export const adjustInventorySchema = z.object({
3
- variantId: z.uuid(),
4
- warehouseId: z.uuid(),
5
- quantity: z.number().int(),
6
- type: z.enum(['restock', 'adjustment', 'damaged', 'initial']),
7
- reason: z.string().optional(),
8
- });
9
- export const transferInventorySchema = z.object({
10
- variantId: z.uuid(),
11
- fromWarehouseId: z.uuid(),
12
- toWarehouseId: z.uuid(),
13
- quantity: z.number().int().positive(),
14
- reason: z.string().optional(),
15
- });
@@ -1,58 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createOrderSchema: z.ZodObject<{
3
- brandSlug: z.ZodString;
4
- firstName: z.ZodString;
5
- lastName: z.ZodString;
6
- email: z.ZodOptional<z.ZodString>;
7
- phone: z.ZodString;
8
- address: z.ZodString;
9
- city: z.ZodString;
10
- deliveryZoneId: z.ZodString;
11
- deliveryCharge: z.ZodNumber;
12
- items: z.ZodArray<z.ZodObject<{
13
- sku: z.ZodString;
14
- quantity: z.ZodNumber;
15
- }, z.core.$strip>>;
16
- discount: z.ZodOptional<z.ZodNumber>;
17
- paymentMethod: z.ZodOptional<z.ZodString>;
18
- paystackReference: z.ZodOptional<z.ZodString>;
19
- }, z.core.$strip>;
20
- export declare const updateOrderSchema: z.ZodObject<{
21
- brandSlug: z.ZodOptional<z.ZodString>;
22
- firstName: z.ZodOptional<z.ZodString>;
23
- lastName: z.ZodOptional<z.ZodString>;
24
- email: z.ZodOptional<z.ZodString>;
25
- phone: z.ZodOptional<z.ZodString>;
26
- address: z.ZodOptional<z.ZodString>;
27
- city: z.ZodOptional<z.ZodString>;
28
- deliveryZoneId: z.ZodOptional<z.ZodString>;
29
- deliveryCharge: z.ZodOptional<z.ZodNumber>;
30
- discount: z.ZodOptional<z.ZodNumber>;
31
- paymentMethod: z.ZodOptional<z.ZodString>;
32
- paystackReference: z.ZodOptional<z.ZodString>;
33
- items: z.ZodOptional<z.ZodArray<z.ZodObject<{
34
- sku: z.ZodString;
35
- quantity: z.ZodNumber;
36
- }, z.core.$strip>>>;
37
- }, z.core.$strip>;
38
- export declare const updateOrderStatusSchema: z.ZodObject<{
39
- status: z.ZodString;
40
- cancellationReason: z.ZodOptional<z.ZodString>;
41
- prospectReason: z.ZodOptional<z.ZodString>;
42
- prospectNote: z.ZodOptional<z.ZodString>;
43
- warehouses: z.ZodOptional<z.ZodArray<z.ZodObject<{
44
- orderItemId: z.ZodUUID;
45
- warehouseId: z.ZodUUID;
46
- }, z.core.$strip>>>;
47
- }, z.core.$strip>;
48
- export declare const orderFiltersSchema: z.ZodObject<{
49
- brandId: z.ZodOptional<z.ZodUUID>;
50
- status: z.ZodOptional<z.ZodString>;
51
- paymentMethod: z.ZodOptional<z.ZodString>;
52
- warehouseId: z.ZodOptional<z.ZodUUID>;
53
- search: z.ZodOptional<z.ZodString>;
54
- startDate: z.ZodOptional<z.ZodString>;
55
- endDate: z.ZodOptional<z.ZodString>;
56
- page: z.ZodOptional<z.ZodNumber>;
57
- limit: z.ZodOptional<z.ZodNumber>;
58
- }, z.core.$strip>;
@@ -1,62 +0,0 @@
1
- import { z } from 'zod';
2
- // Order creation schema (public API)
3
- export const createOrderSchema = z.object({
4
- brandSlug: z.string().min(1),
5
- firstName: z.string().min(1),
6
- lastName: z.string().min(1),
7
- email: z.string().email().optional(),
8
- phone: z.string().min(1),
9
- address: z.string().min(1),
10
- city: z.string().min(1),
11
- deliveryZoneId: z.string().uuid(),
12
- deliveryCharge: z.number().nonnegative(),
13
- items: z.array(z.object({
14
- sku: z.string().min(1),
15
- quantity: z.number().int().positive(),
16
- })).min(1),
17
- discount: z.number().nonnegative().optional(),
18
- paymentMethod: z.string().optional(),
19
- paystackReference: z.string().optional(),
20
- });
21
- // Update order schema (admin API)
22
- export const updateOrderSchema = z.object({
23
- brandSlug: z.string().min(1).optional(),
24
- firstName: z.string().min(1).optional(),
25
- lastName: z.string().min(1).optional(),
26
- email: z.string().email().optional(),
27
- phone: z.string().min(1).optional(),
28
- address: z.string().min(1).optional(),
29
- city: z.string().min(1).optional(),
30
- deliveryZoneId: z.string().uuid().optional(),
31
- deliveryCharge: z.number().nonnegative().optional(),
32
- discount: z.number().nonnegative().optional(),
33
- paymentMethod: z.string().optional(),
34
- paystackReference: z.string().optional(),
35
- items: z.array(z.object({
36
- sku: z.string().min(1),
37
- quantity: z.number().int().positive(),
38
- })).optional(),
39
- });
40
- // Update order status schema
41
- export const updateOrderStatusSchema = z.object({
42
- status: z.string(),
43
- cancellationReason: z.string().optional(),
44
- prospectReason: z.string().optional(),
45
- prospectNote: z.string().optional(),
46
- warehouses: z.array(z.object({
47
- orderItemId: z.uuid(),
48
- warehouseId: z.uuid(),
49
- })).optional(), // Required when status is 'shipped'
50
- });
51
- // Order filter schema
52
- export const orderFiltersSchema = z.object({
53
- brandId: z.uuid().optional(),
54
- status: z.string().optional(),
55
- paymentMethod: z.string().optional(),
56
- warehouseId: z.uuid().optional(),
57
- search: z.string().optional(), // Search by order number, customer name, phone
58
- startDate: z.string().optional(),
59
- endDate: z.string().optional(),
60
- page: z.number().int().positive().optional(),
61
- limit: z.number().int().positive().max(100).optional(),
62
- });
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createProductSchema: z.ZodObject<{
3
- brandId: z.ZodString;
4
- name: z.ZodString;
5
- slug: z.ZodString;
6
- description: z.ZodOptional<z.ZodString>;
7
- thumbnailUrl: z.ZodOptional<z.ZodString>;
8
- quantityDiscounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
9
- isActive: z.ZodOptional<z.ZodBoolean>;
10
- }, z.core.$strip>;
11
- export declare const updateProductSchema: z.ZodObject<{
12
- name: z.ZodOptional<z.ZodString>;
13
- slug: z.ZodOptional<z.ZodString>;
14
- description: z.ZodOptional<z.ZodString>;
15
- thumbnailUrl: z.ZodOptional<z.ZodString>;
16
- quantityDiscounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
17
- isActive: z.ZodOptional<z.ZodBoolean>;
18
- }, z.core.$strip>;
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- const quantityDiscountsSchema = z.record(z.string().regex(/^\d+$/, 'Quantity must be a number'), z.number().int().min(0).max(100, 'Discount must be between 0 and 100')).optional();
3
- export const createProductSchema = z.object({
4
- brandId: z.string().uuid(),
5
- name: z.string().min(1),
6
- slug: z.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must be lowercase letters, numbers, and hyphens only'),
7
- description: z.string().optional(),
8
- thumbnailUrl: z.string().url().optional(),
9
- quantityDiscounts: quantityDiscountsSchema,
10
- isActive: z.boolean().optional(),
11
- });
12
- export const updateProductSchema = z.object({
13
- name: z.string().min(1).optional(),
14
- slug: z.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must be lowercase letters, numbers, and hyphens only').optional(),
15
- description: z.string().optional(),
16
- thumbnailUrl: z.string().url().optional(),
17
- quantityDiscounts: quantityDiscountsSchema,
18
- isActive: z.boolean().optional(),
19
- });
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const createVariantSchema: z.ZodObject<{
3
- sku: z.ZodString;
4
- name: z.ZodOptional<z.ZodString>;
5
- thumbnailUrl: z.ZodOptional<z.ZodURL>;
6
- price: z.ZodNumber;
7
- trackInventory: z.ZodOptional<z.ZodBoolean>;
8
- lowStockThreshold: z.ZodOptional<z.ZodNumber>;
9
- isActive: z.ZodOptional<z.ZodBoolean>;
10
- }, z.core.$strip>;
11
- export declare const updateVariantSchema: z.ZodObject<{
12
- sku: z.ZodOptional<z.ZodString>;
13
- name: z.ZodOptional<z.ZodString>;
14
- thumbnailUrl: z.ZodOptional<z.ZodString>;
15
- price: z.ZodOptional<z.ZodNumber>;
16
- trackInventory: z.ZodOptional<z.ZodBoolean>;
17
- lowStockThreshold: z.ZodOptional<z.ZodNumber>;
18
- isActive: z.ZodOptional<z.ZodBoolean>;
19
- }, z.core.$strip>;