@instockng/api-client 1.0.7 → 1.0.8

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 (66) hide show
  1. package/dist/apps/backend/src/http-app.js +28 -0
  2. package/dist/apps/backend/src/lib/brand-response.d.ts +1 -1
  3. package/dist/apps/backend/src/lib/cart-helpers.d.ts +13 -11
  4. package/dist/apps/backend/src/lib/cart-helpers.js +28 -0
  5. package/dist/apps/backend/src/lib/cart-response.d.ts +5 -5
  6. package/dist/apps/backend/src/lib/clerk.js +23 -0
  7. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +6 -4
  8. package/dist/apps/backend/src/lib/discount-code-response.d.ts +2 -2
  9. package/dist/apps/backend/src/lib/meta-capi.d.ts +5 -0
  10. package/dist/apps/backend/src/lib/meta-capi.js +33 -2
  11. package/dist/apps/backend/src/lib/order-recovery.d.ts +30 -24
  12. package/dist/apps/backend/src/lib/order-response.d.ts +9 -7
  13. package/dist/apps/backend/src/lib/product-response.d.ts +4 -4
  14. package/dist/apps/backend/src/lib/sentry.d.ts +48 -0
  15. package/dist/apps/backend/src/lib/sentry.js +180 -0
  16. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +18 -4
  17. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +10 -10
  18. package/dist/apps/backend/src/routes/admin/brands.d.ts +4 -4
  19. package/dist/apps/backend/src/routes/admin/customers.d.ts +9 -7
  20. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +23 -15
  21. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +10 -10
  22. package/dist/apps/backend/src/routes/admin/inventory.js +10 -0
  23. package/dist/apps/backend/src/routes/admin/orders.d.ts +54 -42
  24. package/dist/apps/backend/src/routes/admin/orders.js +25 -0
  25. package/dist/apps/backend/src/routes/admin/products.d.ts +12 -12
  26. package/dist/apps/backend/src/routes/admin/products.js +34 -15
  27. package/dist/apps/backend/src/routes/admin/stats.d.ts +9 -7
  28. package/dist/apps/backend/src/routes/admin/variants.d.ts +5 -5
  29. package/dist/apps/backend/src/routes/admin/variants.js +42 -18
  30. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +7 -7
  31. package/dist/apps/backend/src/routes/public/brands.d.ts +1 -1
  32. package/dist/apps/backend/src/routes/public/carts.d.ts +49 -47
  33. package/dist/apps/backend/src/routes/public/carts.js +148 -1
  34. package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +2 -0
  35. package/dist/apps/backend/src/routes/public/delivery-zones.js +2 -0
  36. package/dist/apps/backend/src/routes/public/orders.d.ts +18 -14
  37. package/dist/apps/backend/src/routes/public/orders.js +24 -0
  38. package/dist/apps/backend/src/routes/public/products.d.ts +6 -6
  39. package/dist/apps/backend/src/types/index.d.ts +1 -0
  40. package/dist/apps/backend/src/validators/delivery-zone.d.ts +4 -0
  41. package/dist/apps/backend/src/validators/delivery-zone.js +4 -0
  42. package/dist/apps/backend/src/validators/discount-code.d.ts +3 -3
  43. package/dist/apps/backend/src/validators/order.d.ts +3 -1
  44. package/dist/apps/backend/src/validators/order.js +3 -1
  45. package/dist/packages/api-client/src/fetchers/brands.d.ts +1 -1
  46. package/dist/packages/api-client/src/fetchers/carts.d.ts +49 -47
  47. package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +2 -0
  48. package/dist/packages/api-client/src/fetchers/orders.d.ts +18 -14
  49. package/dist/packages/api-client/src/fetchers/products.d.ts +6 -6
  50. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +10 -10
  51. package/dist/packages/api-client/src/hooks/admin/brands.d.ts +4 -4
  52. package/dist/packages/api-client/src/hooks/admin/customers.d.ts +9 -7
  53. package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +23 -15
  54. package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +10 -10
  55. package/dist/packages/api-client/src/hooks/admin/orders.d.ts +54 -42
  56. package/dist/packages/api-client/src/hooks/admin/products.d.ts +6 -6
  57. package/dist/packages/api-client/src/hooks/admin/stats.d.ts +9 -7
  58. package/dist/packages/api-client/src/hooks/admin/variants.d.ts +5 -5
  59. package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +7 -7
  60. package/dist/packages/api-client/src/hooks/public/brands.d.ts +1 -1
  61. package/dist/packages/api-client/src/hooks/public/carts.d.ts +49 -47
  62. package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +2 -0
  63. package/dist/packages/api-client/src/hooks/public/orders.d.ts +18 -14
  64. package/dist/packages/api-client/src/hooks/public/products.d.ts +6 -6
  65. package/dist/packages/api-client/src/rpc-client.d.ts +219 -187
  66. package/package.json +1 -1
@@ -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
- return c.json({
25
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve products' },
26
- }, 500);
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
- return c.json({
48
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve product' },
49
- }, 500);
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
- return c.json({
66
- error: { code: 'INTERNAL_ERROR', message: 'Failed to create product' },
67
- }, 500);
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
- return c.json({
85
- error: { code: 'INTERNAL_ERROR', message: 'Failed to update product' },
86
- }, 500);
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
- return c.json({
103
- error: { code: 'INTERNAL_ERROR', message: 'Failed to delete product' },
104
- }, 500);
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;
@@ -221,8 +223,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
221
223
  };
222
224
  };
223
225
  };
224
- name: string | null;
225
226
  id: string;
227
+ name: string | null;
226
228
  isActive: boolean;
227
229
  thumbnailUrl: string | null;
228
230
  productId: string;
@@ -234,8 +236,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
234
236
  createdAt: string;
235
237
  updatedAt: string;
236
238
  deletedAt: string;
237
- name: string;
238
239
  id: string;
240
+ name: string;
239
241
  isActive: boolean;
240
242
  address: string | null;
241
243
  city: string | null;
@@ -247,8 +249,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
247
249
  warehouseId: string | null;
248
250
  quantity: number;
249
251
  }[];
250
- id: string;
251
252
  email: string | null;
253
+ id: string;
252
254
  brandId: string;
253
255
  deliveryZoneId: string;
254
256
  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
- return c.json({
44
- error: { code: 'INTERNAL_ERROR', message: 'Failed to search variants' },
45
- }, 500);
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
- return c.json({
69
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve variants' },
70
- }, 500);
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
- return c.json({
92
- error: { code: 'INTERNAL_ERROR', message: 'Failed to create variant' },
93
- }, 500);
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
- return c.json({
113
- error: { code: 'INTERNAL_ERROR', message: 'Failed to update variant' },
114
- }, 500);
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
- return c.json({
153
- error: { code: 'INTERNAL_ERROR', message: 'Failed to retrieve variant inventory' },
154
- }, 500);
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
- return c.json({
169
- error: { code: 'INTERNAL_ERROR', message: 'Failed to delete variant' },
170
- }, 500);
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;
@@ -289,8 +289,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
289
289
  };
290
290
  };
291
291
  };
292
- name: string | null;
293
292
  id: string;
293
+ name: string | null;
294
294
  createdAt: string;
295
295
  updatedAt: string;
296
296
  deletedAt: string;
@@ -308,8 +308,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
308
308
  warehouseId: string;
309
309
  inventoryCount: number;
310
310
  }[];
311
- name: string;
312
311
  id: string;
312
+ name: string;
313
313
  createdAt: string;
314
314
  updatedAt: string;
315
315
  deletedAt: string;
@@ -22,8 +22,8 @@ declare const app: import("hono/hono-base").HonoBase<AppContext, {
22
22
  };
23
23
  };
24
24
  output: {
25
- name: string;
26
25
  id: string;
26
+ name: string;
27
27
  slug: string;
28
28
  logoUrl: string;
29
29
  siteUrl: string;