@instockng/api-client 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/backend/src/http-app.js +28 -0
- package/dist/apps/backend/src/lib/brand-response.d.ts +1 -1
- package/dist/apps/backend/src/lib/cart-helpers.d.ts +13 -11
- package/dist/apps/backend/src/lib/cart-helpers.js +28 -0
- package/dist/apps/backend/src/lib/cart-response.d.ts +5 -5
- package/dist/apps/backend/src/lib/clerk.js +23 -0
- package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +6 -4
- package/dist/apps/backend/src/lib/discount-code-response.d.ts +2 -2
- package/dist/apps/backend/src/lib/meta-capi.d.ts +5 -0
- package/dist/apps/backend/src/lib/meta-capi.js +33 -2
- package/dist/apps/backend/src/lib/order-recovery.d.ts +30 -24
- package/dist/apps/backend/src/lib/order-response.d.ts +9 -7
- package/dist/apps/backend/src/lib/product-response.d.ts +4 -4
- package/dist/apps/backend/src/lib/sentry.d.ts +48 -0
- package/dist/apps/backend/src/lib/sentry.js +180 -0
- package/dist/apps/backend/src/lib/utils.d.ts +1 -1
- package/dist/apps/backend/src/lib/utils.js +1 -1
- package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +18 -4
- package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +18 -10
- package/dist/apps/backend/src/routes/admin/brands.d.ts +4 -4
- package/dist/apps/backend/src/routes/admin/customers.d.ts +13 -7
- package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +23 -15
- package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +10 -10
- package/dist/apps/backend/src/routes/admin/inventory.d.ts +4 -0
- package/dist/apps/backend/src/routes/admin/inventory.js +10 -0
- package/dist/apps/backend/src/routes/admin/orders.d.ts +78 -42
- package/dist/apps/backend/src/routes/admin/orders.js +25 -0
- package/dist/apps/backend/src/routes/admin/products.d.ts +28 -12
- package/dist/apps/backend/src/routes/admin/products.js +34 -15
- package/dist/apps/backend/src/routes/admin/stats.d.ts +13 -7
- package/dist/apps/backend/src/routes/admin/variants.d.ts +5 -5
- package/dist/apps/backend/src/routes/admin/variants.js +42 -18
- package/dist/apps/backend/src/routes/admin/warehouses.d.ts +11 -7
- package/dist/apps/backend/src/routes/public/brands.d.ts +1 -1
- package/dist/apps/backend/src/routes/public/carts.d.ts +85 -47
- package/dist/apps/backend/src/routes/public/carts.js +148 -1
- package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +2 -0
- package/dist/apps/backend/src/routes/public/delivery-zones.js +2 -0
- package/dist/apps/backend/src/routes/public/orders.d.ts +26 -14
- package/dist/apps/backend/src/routes/public/orders.js +24 -0
- package/dist/apps/backend/src/routes/public/products.d.ts +14 -6
- package/dist/apps/backend/src/types/index.d.ts +1 -0
- package/dist/apps/backend/src/validators/delivery-zone.d.ts +4 -0
- package/dist/apps/backend/src/validators/delivery-zone.js +4 -0
- package/dist/apps/backend/src/validators/discount-code.d.ts +3 -3
- package/dist/apps/backend/src/validators/order.d.ts +3 -1
- package/dist/apps/backend/src/validators/order.js +3 -1
- package/dist/packages/api-client/src/fetchers/brands.d.ts +1 -1
- package/dist/packages/api-client/src/fetchers/carts.d.ts +85 -47
- package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +2 -0
- package/dist/packages/api-client/src/fetchers/orders.d.ts +26 -14
- package/dist/packages/api-client/src/fetchers/products.d.ts +14 -6
- package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +18 -10
- package/dist/packages/api-client/src/hooks/admin/brands.d.ts +4 -4
- package/dist/packages/api-client/src/hooks/admin/customers.d.ts +13 -7
- package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +23 -15
- package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +10 -10
- package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +4 -0
- package/dist/packages/api-client/src/hooks/admin/orders.d.ts +78 -42
- package/dist/packages/api-client/src/hooks/admin/products.d.ts +14 -6
- package/dist/packages/api-client/src/hooks/admin/stats.d.ts +13 -7
- package/dist/packages/api-client/src/hooks/admin/variants.d.ts +5 -5
- package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +11 -7
- package/dist/packages/api-client/src/hooks/public/brands.d.ts +1 -1
- package/dist/packages/api-client/src/hooks/public/carts.d.ts +85 -47
- package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +2 -0
- package/dist/packages/api-client/src/hooks/public/orders.d.ts +26 -14
- package/dist/packages/api-client/src/hooks/public/products.d.ts +14 -6
- package/dist/packages/api-client/src/rpc-client.d.ts +335 -187
- package/package.json +1 -1
|
@@ -8,8 +8,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
8
8
|
createdAt: string;
|
|
9
9
|
updatedAt: string;
|
|
10
10
|
deletedAt: string;
|
|
11
|
-
name: string;
|
|
12
11
|
id: string;
|
|
12
|
+
name: string;
|
|
13
13
|
slug: string;
|
|
14
14
|
logoUrl: string | null;
|
|
15
15
|
siteUrl: string;
|
|
@@ -21,8 +21,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
21
21
|
updatedAt: string;
|
|
22
22
|
price: number;
|
|
23
23
|
deletedAt: string;
|
|
24
|
-
name: string | null;
|
|
25
24
|
id: string;
|
|
25
|
+
name: string | null;
|
|
26
26
|
isActive: boolean;
|
|
27
27
|
thumbnailUrl: string | null;
|
|
28
28
|
productId: string;
|
|
@@ -30,8 +30,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
30
30
|
trackInventory: boolean;
|
|
31
31
|
lowStockThreshold: number | null;
|
|
32
32
|
}[];
|
|
33
|
-
name: string;
|
|
34
33
|
id: string;
|
|
34
|
+
name: string;
|
|
35
35
|
slug: string;
|
|
36
36
|
createdAt: string;
|
|
37
37
|
updatedAt: string;
|
|
@@ -110,7 +110,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
110
110
|
includes?: boolean;
|
|
111
111
|
flatMap?: boolean;
|
|
112
112
|
flat?: boolean;
|
|
113
|
+
at?: boolean;
|
|
113
114
|
};
|
|
115
|
+
at: never;
|
|
114
116
|
};
|
|
115
117
|
} | {
|
|
116
118
|
[x: number]: string | number | boolean | {
|
|
@@ -183,7 +185,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
183
185
|
includes?: boolean;
|
|
184
186
|
flatMap?: boolean;
|
|
185
187
|
flat?: boolean;
|
|
188
|
+
at?: boolean;
|
|
186
189
|
};
|
|
190
|
+
at: never;
|
|
187
191
|
};
|
|
188
192
|
}[];
|
|
189
193
|
outputFormat: "json";
|
|
@@ -228,8 +232,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
228
232
|
createdAt: string;
|
|
229
233
|
updatedAt: string;
|
|
230
234
|
deletedAt: string;
|
|
231
|
-
name: string;
|
|
232
235
|
id: string;
|
|
236
|
+
name: string;
|
|
233
237
|
slug: string;
|
|
234
238
|
logoUrl: string | null;
|
|
235
239
|
siteUrl: string;
|
|
@@ -241,8 +245,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
241
245
|
updatedAt: string;
|
|
242
246
|
price: number;
|
|
243
247
|
deletedAt: string;
|
|
244
|
-
name: string | null;
|
|
245
248
|
id: string;
|
|
249
|
+
name: string | null;
|
|
246
250
|
isActive: boolean;
|
|
247
251
|
thumbnailUrl: string | null;
|
|
248
252
|
productId: string;
|
|
@@ -250,8 +254,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
250
254
|
trackInventory: boolean;
|
|
251
255
|
lowStockThreshold: number | null;
|
|
252
256
|
}[];
|
|
253
|
-
name: string;
|
|
254
257
|
id: string;
|
|
258
|
+
name: string;
|
|
255
259
|
slug: string;
|
|
256
260
|
createdAt: string;
|
|
257
261
|
updatedAt: string;
|
|
@@ -330,7 +334,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
330
334
|
includes?: boolean;
|
|
331
335
|
flatMap?: boolean;
|
|
332
336
|
flat?: boolean;
|
|
337
|
+
at?: boolean;
|
|
333
338
|
};
|
|
339
|
+
at: never;
|
|
334
340
|
};
|
|
335
341
|
} | {
|
|
336
342
|
[x: number]: string | number | boolean | {
|
|
@@ -403,7 +409,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
403
409
|
includes?: boolean;
|
|
404
410
|
flatMap?: boolean;
|
|
405
411
|
flat?: boolean;
|
|
412
|
+
at?: boolean;
|
|
406
413
|
};
|
|
414
|
+
at: never;
|
|
407
415
|
};
|
|
408
416
|
};
|
|
409
417
|
outputFormat: "json";
|
|
@@ -433,8 +441,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
433
441
|
createdAt: string;
|
|
434
442
|
updatedAt: string;
|
|
435
443
|
deletedAt: string;
|
|
436
|
-
name: string;
|
|
437
444
|
id: string;
|
|
445
|
+
name: string;
|
|
438
446
|
slug: string;
|
|
439
447
|
logoUrl: string | null;
|
|
440
448
|
siteUrl: string;
|
|
@@ -446,8 +454,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
446
454
|
updatedAt: string;
|
|
447
455
|
price: number;
|
|
448
456
|
deletedAt: string;
|
|
449
|
-
name: string | null;
|
|
450
457
|
id: string;
|
|
458
|
+
name: string | null;
|
|
451
459
|
isActive: boolean;
|
|
452
460
|
thumbnailUrl: string | null;
|
|
453
461
|
productId: string;
|
|
@@ -455,8 +463,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
455
463
|
trackInventory: boolean;
|
|
456
464
|
lowStockThreshold: number | null;
|
|
457
465
|
}[];
|
|
458
|
-
name: string;
|
|
459
466
|
id: string;
|
|
467
|
+
name: string;
|
|
460
468
|
slug: string;
|
|
461
469
|
createdAt: string;
|
|
462
470
|
updatedAt: string;
|
|
@@ -535,7 +543,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
535
543
|
includes?: boolean;
|
|
536
544
|
flatMap?: boolean;
|
|
537
545
|
flat?: boolean;
|
|
546
|
+
at?: boolean;
|
|
538
547
|
};
|
|
548
|
+
at: never;
|
|
539
549
|
};
|
|
540
550
|
} | {
|
|
541
551
|
[x: number]: string | number | boolean | {
|
|
@@ -608,7 +618,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
608
618
|
includes?: boolean;
|
|
609
619
|
flatMap?: boolean;
|
|
610
620
|
flat?: boolean;
|
|
621
|
+
at?: boolean;
|
|
611
622
|
};
|
|
623
|
+
at: never;
|
|
612
624
|
};
|
|
613
625
|
};
|
|
614
626
|
outputFormat: "json";
|
|
@@ -638,8 +650,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
638
650
|
createdAt: string;
|
|
639
651
|
updatedAt: string;
|
|
640
652
|
deletedAt: string;
|
|
641
|
-
name: string;
|
|
642
653
|
id: string;
|
|
654
|
+
name: string;
|
|
643
655
|
slug: string;
|
|
644
656
|
logoUrl: string | null;
|
|
645
657
|
siteUrl: string;
|
|
@@ -651,8 +663,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
651
663
|
updatedAt: string;
|
|
652
664
|
price: number;
|
|
653
665
|
deletedAt: string;
|
|
654
|
-
name: string | null;
|
|
655
666
|
id: string;
|
|
667
|
+
name: string | null;
|
|
656
668
|
isActive: boolean;
|
|
657
669
|
thumbnailUrl: string | null;
|
|
658
670
|
productId: string;
|
|
@@ -660,8 +672,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
660
672
|
trackInventory: boolean;
|
|
661
673
|
lowStockThreshold: number | null;
|
|
662
674
|
}[];
|
|
663
|
-
name: string;
|
|
664
675
|
id: string;
|
|
676
|
+
name: string;
|
|
665
677
|
slug: string;
|
|
666
678
|
createdAt: string;
|
|
667
679
|
updatedAt: string;
|
|
@@ -740,7 +752,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
740
752
|
includes?: boolean;
|
|
741
753
|
flatMap?: boolean;
|
|
742
754
|
flat?: boolean;
|
|
755
|
+
at?: boolean;
|
|
743
756
|
};
|
|
757
|
+
at: never;
|
|
744
758
|
};
|
|
745
759
|
} | {
|
|
746
760
|
[x: number]: string | number | boolean | {
|
|
@@ -813,7 +827,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
813
827
|
includes?: boolean;
|
|
814
828
|
flatMap?: boolean;
|
|
815
829
|
flat?: boolean;
|
|
830
|
+
at?: boolean;
|
|
816
831
|
};
|
|
832
|
+
at: never;
|
|
817
833
|
};
|
|
818
834
|
};
|
|
819
835
|
outputFormat: "json";
|
|
@@ -4,6 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { createProductSchema, updateProductSchema } from '../../validators/product';
|
|
5
5
|
import { getPrismaClient } from '../../lib/prisma';
|
|
6
6
|
import { formatProductResponse, PRODUCT_INCLUDE_FULL } from '../../lib/product-response';
|
|
7
|
+
import { captureException } from '../../lib/sentry';
|
|
7
8
|
const app = new Hono()
|
|
8
9
|
// List products with optional brand filter
|
|
9
10
|
.get('/', async (c) => {
|
|
@@ -21,9 +22,12 @@ const app = new Hono()
|
|
|
21
22
|
return c.json(products.map(formatProductResponse));
|
|
22
23
|
}
|
|
23
24
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
26
|
+
level: 'error',
|
|
27
|
+
tags: { error_code: 'PRODUCT_LIST_ERROR', endpoint: 'GET /admin/products' },
|
|
28
|
+
honoContext: c,
|
|
29
|
+
});
|
|
30
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve products' } }, 500);
|
|
27
31
|
}
|
|
28
32
|
})
|
|
29
33
|
// Get single product by id
|
|
@@ -44,9 +48,13 @@ const app = new Hono()
|
|
|
44
48
|
return c.json(formatProductResponse(product));
|
|
45
49
|
}
|
|
46
50
|
catch (error) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
52
|
+
level: 'error',
|
|
53
|
+
tags: { error_code: 'PRODUCT_FETCH_ERROR', endpoint: 'GET /admin/products/:id' },
|
|
54
|
+
extra: { productId: c.req.param('id') },
|
|
55
|
+
honoContext: c,
|
|
56
|
+
});
|
|
57
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve product' } }, 500);
|
|
50
58
|
}
|
|
51
59
|
})
|
|
52
60
|
// Create product
|
|
@@ -62,9 +70,12 @@ const app = new Hono()
|
|
|
62
70
|
}
|
|
63
71
|
catch (error) {
|
|
64
72
|
console.error('Create product error:', error);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
74
|
+
level: 'error',
|
|
75
|
+
tags: { error_code: 'PRODUCT_CREATE_ERROR', endpoint: 'POST /admin/products' },
|
|
76
|
+
honoContext: c,
|
|
77
|
+
});
|
|
78
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to create product' } }, 500);
|
|
68
79
|
}
|
|
69
80
|
})
|
|
70
81
|
// Update product
|
|
@@ -81,9 +92,13 @@ const app = new Hono()
|
|
|
81
92
|
return c.json(formatProductResponse(product));
|
|
82
93
|
}
|
|
83
94
|
catch (error) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
96
|
+
level: 'error',
|
|
97
|
+
tags: { error_code: 'PRODUCT_UPDATE_ERROR', endpoint: 'PATCH /admin/products/:id' },
|
|
98
|
+
extra: { productId: c.req.param('id') },
|
|
99
|
+
honoContext: c,
|
|
100
|
+
});
|
|
101
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to update product' } }, 500);
|
|
87
102
|
}
|
|
88
103
|
})
|
|
89
104
|
// Soft delete product
|
|
@@ -99,9 +114,13 @@ const app = new Hono()
|
|
|
99
114
|
return c.status(204);
|
|
100
115
|
}
|
|
101
116
|
catch (error) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
118
|
+
level: 'error',
|
|
119
|
+
tags: { error_code: 'PRODUCT_DELETE_ERROR', endpoint: 'DELETE /admin/products/:id' },
|
|
120
|
+
extra: { productId: c.req.param('id') },
|
|
121
|
+
honoContext: c,
|
|
122
|
+
});
|
|
123
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to delete product' } }, 500);
|
|
105
124
|
}
|
|
106
125
|
});
|
|
107
126
|
export default app;
|
|
@@ -25,8 +25,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
25
25
|
createdAt: string;
|
|
26
26
|
updatedAt: string;
|
|
27
27
|
deletedAt: string;
|
|
28
|
-
name: string;
|
|
29
28
|
id: string;
|
|
29
|
+
name: string;
|
|
30
30
|
slug: string;
|
|
31
31
|
logoUrl: string | null;
|
|
32
32
|
siteUrl: string;
|
|
@@ -43,18 +43,20 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
43
43
|
createdAt: string;
|
|
44
44
|
updatedAt: string;
|
|
45
45
|
deletedAt: string;
|
|
46
|
-
name: string;
|
|
47
46
|
id: string;
|
|
47
|
+
name: string;
|
|
48
48
|
isActive: boolean;
|
|
49
49
|
};
|
|
50
|
-
name: string;
|
|
51
50
|
id: string;
|
|
51
|
+
name: string;
|
|
52
52
|
brandId: string | null;
|
|
53
53
|
stateId: string;
|
|
54
54
|
allowCOD: boolean;
|
|
55
55
|
allowOnline: boolean;
|
|
56
56
|
waybillOnly: boolean;
|
|
57
57
|
estimatedDays: number | null;
|
|
58
|
+
noteTitle: string | null;
|
|
59
|
+
noteContent: string | null;
|
|
58
60
|
isActive: boolean;
|
|
59
61
|
};
|
|
60
62
|
items: {
|
|
@@ -68,8 +70,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
68
70
|
createdAt: string;
|
|
69
71
|
updatedAt: string;
|
|
70
72
|
deletedAt: string;
|
|
71
|
-
name: string;
|
|
72
73
|
id: string;
|
|
74
|
+
name: string;
|
|
73
75
|
slug: string;
|
|
74
76
|
brandId: string;
|
|
75
77
|
isActive: boolean;
|
|
@@ -145,7 +147,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
145
147
|
includes?: boolean;
|
|
146
148
|
flatMap?: boolean;
|
|
147
149
|
flat?: boolean;
|
|
150
|
+
at?: boolean;
|
|
148
151
|
};
|
|
152
|
+
at: never;
|
|
149
153
|
};
|
|
150
154
|
} | {
|
|
151
155
|
[x: number]: string | number | boolean | {
|
|
@@ -218,11 +222,13 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
218
222
|
includes?: boolean;
|
|
219
223
|
flatMap?: boolean;
|
|
220
224
|
flat?: boolean;
|
|
225
|
+
at?: boolean;
|
|
221
226
|
};
|
|
227
|
+
at: never;
|
|
222
228
|
};
|
|
223
229
|
};
|
|
224
|
-
name: string | null;
|
|
225
230
|
id: string;
|
|
231
|
+
name: string | null;
|
|
226
232
|
isActive: boolean;
|
|
227
233
|
thumbnailUrl: string | null;
|
|
228
234
|
productId: string;
|
|
@@ -234,8 +240,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
234
240
|
createdAt: string;
|
|
235
241
|
updatedAt: string;
|
|
236
242
|
deletedAt: string;
|
|
237
|
-
name: string;
|
|
238
243
|
id: string;
|
|
244
|
+
name: string;
|
|
239
245
|
isActive: boolean;
|
|
240
246
|
address: string | null;
|
|
241
247
|
city: string | null;
|
|
@@ -247,8 +253,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
247
253
|
warehouseId: string | null;
|
|
248
254
|
quantity: number;
|
|
249
255
|
}[];
|
|
250
|
-
id: string;
|
|
251
256
|
email: string | null;
|
|
257
|
+
id: string;
|
|
252
258
|
brandId: string;
|
|
253
259
|
deliveryZoneId: string;
|
|
254
260
|
recoveryAttempts: number;
|
|
@@ -8,8 +8,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
8
8
|
updatedAt: string;
|
|
9
9
|
price: number;
|
|
10
10
|
deletedAt: string;
|
|
11
|
-
name: string | null;
|
|
12
11
|
id: string;
|
|
12
|
+
name: string | null;
|
|
13
13
|
isActive: boolean;
|
|
14
14
|
thumbnailUrl: string | null;
|
|
15
15
|
productId: string;
|
|
@@ -44,8 +44,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
44
44
|
updatedAt: string;
|
|
45
45
|
price: number;
|
|
46
46
|
deletedAt: string;
|
|
47
|
-
name: string | null;
|
|
48
47
|
id: string;
|
|
48
|
+
name: string | null;
|
|
49
49
|
isActive: boolean;
|
|
50
50
|
thumbnailUrl: string | null;
|
|
51
51
|
productId: string;
|
|
@@ -84,8 +84,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
84
84
|
updatedAt: string;
|
|
85
85
|
price: number;
|
|
86
86
|
deletedAt: string;
|
|
87
|
-
name: string | null;
|
|
88
87
|
id: string;
|
|
88
|
+
name: string | null;
|
|
89
89
|
isActive: boolean;
|
|
90
90
|
thumbnailUrl: string | null;
|
|
91
91
|
productId: string;
|
|
@@ -124,8 +124,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
124
124
|
updatedAt: string;
|
|
125
125
|
price: number;
|
|
126
126
|
deletedAt: string;
|
|
127
|
-
name: string | null;
|
|
128
127
|
id: string;
|
|
128
|
+
name: string | null;
|
|
129
129
|
isActive: boolean;
|
|
130
130
|
thumbnailUrl: string | null;
|
|
131
131
|
productId: string;
|
|
@@ -179,8 +179,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
179
179
|
updatedAt: string;
|
|
180
180
|
price: number;
|
|
181
181
|
deletedAt: string;
|
|
182
|
-
name: string | null;
|
|
183
182
|
id: string;
|
|
183
|
+
name: string | null;
|
|
184
184
|
isActive: boolean;
|
|
185
185
|
thumbnailUrl: string | null;
|
|
186
186
|
productId: string;
|
|
@@ -4,6 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { createVariantSchema, updateVariantSchema } from '../../validators/variant';
|
|
5
5
|
import { getPrismaClient } from '../../lib/prisma';
|
|
6
6
|
import { formatProductVariantResponse } from '../../lib/product-response';
|
|
7
|
+
import { captureException } from '../../lib/sentry';
|
|
7
8
|
const app = new Hono()
|
|
8
9
|
// Search variants across all products (for order creation)
|
|
9
10
|
.get('/', async (c) => {
|
|
@@ -40,9 +41,12 @@ const app = new Hono()
|
|
|
40
41
|
return c.json(variants.map(formatProductVariantResponse));
|
|
41
42
|
}
|
|
42
43
|
catch (error) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
45
|
+
level: 'error',
|
|
46
|
+
tags: { error_code: 'VARIANT_SEARCH_ERROR', endpoint: 'GET /admin/variants' },
|
|
47
|
+
honoContext: c,
|
|
48
|
+
});
|
|
49
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to search variants' } }, 500);
|
|
46
50
|
}
|
|
47
51
|
})
|
|
48
52
|
// List variants for a product
|
|
@@ -65,9 +69,13 @@ const app = new Hono()
|
|
|
65
69
|
return c.json(variants.map(formatProductVariantResponse));
|
|
66
70
|
}
|
|
67
71
|
catch (error) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
73
|
+
level: 'error',
|
|
74
|
+
tags: { error_code: 'VARIANT_LIST_ERROR', endpoint: 'GET /admin/variants/products/:productId/variants' },
|
|
75
|
+
extra: { productId: c.req.param('productId') },
|
|
76
|
+
honoContext: c,
|
|
77
|
+
});
|
|
78
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve variants' } }, 500);
|
|
71
79
|
}
|
|
72
80
|
})
|
|
73
81
|
// Create variant for a product
|
|
@@ -88,9 +96,13 @@ const app = new Hono()
|
|
|
88
96
|
return c.json(formatProductVariantResponse(variant), 201);
|
|
89
97
|
}
|
|
90
98
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
100
|
+
level: 'error',
|
|
101
|
+
tags: { error_code: 'VARIANT_CREATE_ERROR', endpoint: 'POST /admin/variants/products/:productId/variants' },
|
|
102
|
+
extra: { productId: c.req.param('productId') },
|
|
103
|
+
honoContext: c,
|
|
104
|
+
});
|
|
105
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to create variant' } }, 500);
|
|
94
106
|
}
|
|
95
107
|
})
|
|
96
108
|
// Update variant
|
|
@@ -109,9 +121,13 @@ const app = new Hono()
|
|
|
109
121
|
return c.json(formatProductVariantResponse(variant));
|
|
110
122
|
}
|
|
111
123
|
catch (error) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
125
|
+
level: 'error',
|
|
126
|
+
tags: { error_code: 'VARIANT_UPDATE_ERROR', endpoint: 'PATCH /admin/variants/:id' },
|
|
127
|
+
extra: { variantId: c.req.param('id') },
|
|
128
|
+
honoContext: c,
|
|
129
|
+
});
|
|
130
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to update variant' } }, 500);
|
|
115
131
|
}
|
|
116
132
|
})
|
|
117
133
|
// Get variant inventory across all warehouses
|
|
@@ -149,9 +165,13 @@ const app = new Hono()
|
|
|
149
165
|
});
|
|
150
166
|
}
|
|
151
167
|
catch (error) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
168
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
169
|
+
level: 'error',
|
|
170
|
+
tags: { error_code: 'VARIANT_INVENTORY_ERROR', endpoint: 'GET /admin/variants/:id/inventory' },
|
|
171
|
+
extra: { variantId: c.req.param('id') },
|
|
172
|
+
honoContext: c,
|
|
173
|
+
});
|
|
174
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve variant inventory' } }, 500);
|
|
155
175
|
}
|
|
156
176
|
})
|
|
157
177
|
// Soft delete variant
|
|
@@ -165,9 +185,13 @@ const app = new Hono()
|
|
|
165
185
|
return c.status(204);
|
|
166
186
|
}
|
|
167
187
|
catch (error) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
188
|
+
captureException(error instanceof Error ? error : new Error(String(error)), {
|
|
189
|
+
level: 'error',
|
|
190
|
+
tags: { error_code: 'VARIANT_DELETE_ERROR', endpoint: 'DELETE /admin/variants/:id' },
|
|
191
|
+
extra: { variantId: c.req.param('id') },
|
|
192
|
+
honoContext: c,
|
|
193
|
+
});
|
|
194
|
+
return c.json({ error: { code: 'INTERNAL_ERROR', message: 'Failed to delete variant' } }, 500);
|
|
171
195
|
}
|
|
172
196
|
});
|
|
173
197
|
export default app;
|
|
@@ -4,8 +4,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
4
4
|
$get: {
|
|
5
5
|
input: {};
|
|
6
6
|
output: {
|
|
7
|
-
name: string;
|
|
8
7
|
id: string;
|
|
8
|
+
name: string;
|
|
9
9
|
createdAt: string;
|
|
10
10
|
updatedAt: string;
|
|
11
11
|
deletedAt: string;
|
|
@@ -33,8 +33,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
33
33
|
$post: {
|
|
34
34
|
input: {};
|
|
35
35
|
output: {
|
|
36
|
-
name: string;
|
|
37
36
|
id: string;
|
|
37
|
+
name: string;
|
|
38
38
|
createdAt: string;
|
|
39
39
|
updatedAt: string;
|
|
40
40
|
deletedAt: string;
|
|
@@ -66,8 +66,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
output: {
|
|
69
|
-
name: string;
|
|
70
69
|
id: string;
|
|
70
|
+
name: string;
|
|
71
71
|
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
73
|
deletedAt: string;
|
|
@@ -122,8 +122,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
122
122
|
variant: {
|
|
123
123
|
product: {
|
|
124
124
|
brand: {
|
|
125
|
-
name: string;
|
|
126
125
|
id: string;
|
|
126
|
+
name: string;
|
|
127
127
|
slug: string;
|
|
128
128
|
logoUrl: string | null;
|
|
129
129
|
siteUrl: string;
|
|
@@ -133,8 +133,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
133
133
|
updatedAt: string;
|
|
134
134
|
deletedAt: string;
|
|
135
135
|
};
|
|
136
|
-
name: string;
|
|
137
136
|
id: string;
|
|
137
|
+
name: string;
|
|
138
138
|
slug: string;
|
|
139
139
|
createdAt: string;
|
|
140
140
|
updatedAt: string;
|
|
@@ -213,7 +213,9 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
213
213
|
includes?: boolean;
|
|
214
214
|
flatMap?: boolean;
|
|
215
215
|
flat?: boolean;
|
|
216
|
+
at?: boolean;
|
|
216
217
|
};
|
|
218
|
+
at: never;
|
|
217
219
|
};
|
|
218
220
|
} | {
|
|
219
221
|
[x: number]: string | number | boolean | {
|
|
@@ -286,11 +288,13 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
286
288
|
includes?: boolean;
|
|
287
289
|
flatMap?: boolean;
|
|
288
290
|
flat?: boolean;
|
|
291
|
+
at?: boolean;
|
|
289
292
|
};
|
|
293
|
+
at: never;
|
|
290
294
|
};
|
|
291
295
|
};
|
|
292
|
-
name: string | null;
|
|
293
296
|
id: string;
|
|
297
|
+
name: string | null;
|
|
294
298
|
createdAt: string;
|
|
295
299
|
updatedAt: string;
|
|
296
300
|
deletedAt: string;
|
|
@@ -308,8 +312,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
|
|
|
308
312
|
warehouseId: string;
|
|
309
313
|
inventoryCount: number;
|
|
310
314
|
}[];
|
|
311
|
-
name: string;
|
|
312
315
|
id: string;
|
|
316
|
+
name: string;
|
|
313
317
|
createdAt: string;
|
|
314
318
|
updatedAt: string;
|
|
315
319
|
deletedAt: string;
|