@86d-app/products 0.0.4 → 0.0.13

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 (196) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/AGENTS.md +41 -41
  3. package/README.md +266 -5
  4. package/dist/__tests__/controllers.test.d.ts +2 -0
  5. package/dist/__tests__/controllers.test.d.ts.map +1 -0
  6. package/dist/__tests__/endpoint-security.test.d.ts +2 -0
  7. package/dist/__tests__/endpoint-security.test.d.ts.map +1 -0
  8. package/dist/__tests__/service-impl.test.d.ts +2 -0
  9. package/dist/__tests__/service-impl.test.d.ts.map +1 -0
  10. package/dist/__tests__/state.test.d.ts +2 -0
  11. package/dist/__tests__/state.test.d.ts.map +1 -0
  12. package/dist/admin/components/categories-admin.d.ts +2 -0
  13. package/dist/admin/components/categories-admin.d.ts.map +1 -0
  14. package/dist/admin/components/category-form.d.ts +7 -0
  15. package/dist/admin/components/category-form.d.ts.map +1 -0
  16. package/dist/admin/components/category-list.d.ts +7 -0
  17. package/dist/admin/components/category-list.d.ts.map +1 -0
  18. package/dist/admin/components/collections-admin.d.ts +2 -0
  19. package/dist/admin/components/collections-admin.d.ts.map +1 -0
  20. package/dist/admin/components/index.d.ts +9 -0
  21. package/dist/admin/components/index.d.ts.map +1 -0
  22. package/dist/admin/components/product-detail.d.ts +7 -0
  23. package/dist/admin/components/product-detail.d.ts.map +1 -0
  24. package/dist/admin/components/product-edit.d.ts +6 -0
  25. package/dist/admin/components/product-edit.d.ts.map +1 -0
  26. package/dist/admin/components/product-form.d.ts +7 -0
  27. package/dist/admin/components/product-form.d.ts.map +1 -0
  28. package/dist/admin/components/product-list.d.ts +2 -0
  29. package/dist/admin/components/product-list.d.ts.map +1 -0
  30. package/dist/admin/components/product-new.d.ts +2 -0
  31. package/dist/admin/components/product-new.d.ts.map +1 -0
  32. package/dist/admin/endpoints/add-collection-product.d.ts +15 -0
  33. package/dist/admin/endpoints/add-collection-product.d.ts.map +1 -0
  34. package/dist/admin/endpoints/bulk-action.d.ts +17 -0
  35. package/dist/admin/endpoints/bulk-action.d.ts.map +1 -0
  36. package/dist/admin/endpoints/create-category.d.ts +23 -0
  37. package/dist/admin/endpoints/create-category.d.ts.map +1 -0
  38. package/dist/admin/endpoints/create-collection.d.ts +22 -0
  39. package/dist/admin/endpoints/create-collection.d.ts.map +1 -0
  40. package/dist/admin/endpoints/create-product.d.ts +44 -0
  41. package/dist/admin/endpoints/create-product.d.ts.map +1 -0
  42. package/dist/admin/endpoints/create-variant.d.ts +35 -0
  43. package/dist/admin/endpoints/create-variant.d.ts.map +1 -0
  44. package/dist/admin/endpoints/delete-category.d.ts +18 -0
  45. package/dist/admin/endpoints/delete-category.d.ts.map +1 -0
  46. package/dist/admin/endpoints/delete-collection.d.ts +8 -0
  47. package/dist/admin/endpoints/delete-collection.d.ts.map +1 -0
  48. package/dist/admin/endpoints/delete-product.d.ts +18 -0
  49. package/dist/admin/endpoints/delete-product.d.ts.map +1 -0
  50. package/dist/admin/endpoints/delete-variant.d.ts +18 -0
  51. package/dist/admin/endpoints/delete-variant.d.ts.map +1 -0
  52. package/dist/admin/endpoints/get-product.d.ts +16 -0
  53. package/dist/admin/endpoints/get-product.d.ts.map +1 -0
  54. package/dist/admin/endpoints/import-products.d.ts +36 -0
  55. package/dist/admin/endpoints/import-products.d.ts.map +1 -0
  56. package/dist/admin/endpoints/index.d.ts +418 -0
  57. package/dist/admin/endpoints/index.d.ts.map +1 -0
  58. package/dist/admin/endpoints/list-categories.d.ts +11 -0
  59. package/dist/admin/endpoints/list-categories.d.ts.map +1 -0
  60. package/dist/admin/endpoints/list-collections.d.ts +11 -0
  61. package/dist/admin/endpoints/list-collections.d.ts.map +1 -0
  62. package/dist/admin/endpoints/list-products.d.ts +27 -0
  63. package/dist/admin/endpoints/list-products.d.ts.map +1 -0
  64. package/dist/admin/endpoints/remove-collection-product.d.ts +9 -0
  65. package/dist/admin/endpoints/remove-collection-product.d.ts.map +1 -0
  66. package/dist/admin/endpoints/update-category.d.ts +26 -0
  67. package/dist/admin/endpoints/update-category.d.ts.map +1 -0
  68. package/dist/admin/endpoints/update-collection.d.ts +19 -0
  69. package/dist/admin/endpoints/update-collection.d.ts.map +1 -0
  70. package/dist/admin/endpoints/update-product.d.ts +47 -0
  71. package/dist/admin/endpoints/update-product.d.ts.map +1 -0
  72. package/dist/admin/endpoints/update-variant.d.ts +35 -0
  73. package/dist/admin/endpoints/update-variant.d.ts.map +1 -0
  74. package/dist/controllers.d.ts +130 -0
  75. package/dist/controllers.d.ts.map +1 -0
  76. package/dist/index.d.ts +20 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/markdown.d.ts +6 -0
  79. package/dist/markdown.d.ts.map +1 -0
  80. package/dist/schema.d.ts +351 -0
  81. package/dist/schema.d.ts.map +1 -0
  82. package/dist/service-impl.d.ts +4 -0
  83. package/dist/service-impl.d.ts.map +1 -0
  84. package/dist/service.d.ts +280 -0
  85. package/dist/service.d.ts.map +1 -0
  86. package/dist/state.d.ts +38 -0
  87. package/dist/state.d.ts.map +1 -0
  88. package/dist/store/components/_hooks.d.ts +88 -0
  89. package/dist/store/components/_hooks.d.ts.map +1 -0
  90. package/dist/store/components/_types.d.ts +70 -0
  91. package/dist/store/components/_types.d.ts.map +1 -0
  92. package/dist/store/components/_utils.d.ts +5 -0
  93. package/dist/store/components/_utils.d.ts.map +1 -0
  94. package/dist/store/components/back-in-stock-notify.d.ts +8 -0
  95. package/dist/store/components/back-in-stock-notify.d.ts.map +1 -0
  96. package/dist/store/components/collection-card.d.ts +6 -0
  97. package/dist/store/components/collection-card.d.ts.map +1 -0
  98. package/dist/store/components/collection-detail.d.ts +6 -0
  99. package/dist/store/components/collection-detail.d.ts.map +1 -0
  100. package/dist/store/components/collection-grid.d.ts +6 -0
  101. package/dist/store/components/collection-grid.d.ts.map +1 -0
  102. package/dist/store/components/featured-products.d.ts +6 -0
  103. package/dist/store/components/featured-products.d.ts.map +1 -0
  104. package/dist/store/components/filter-chip.d.ts +6 -0
  105. package/dist/store/components/filter-chip.d.ts.map +1 -0
  106. package/dist/store/components/index.d.ts +37 -0
  107. package/dist/store/components/index.d.ts.map +1 -0
  108. package/dist/store/components/product-card.d.ts +7 -0
  109. package/dist/store/components/product-card.d.ts.map +1 -0
  110. package/dist/store/components/product-detail.d.ts +6 -0
  111. package/dist/store/components/product-detail.d.ts.map +1 -0
  112. package/dist/store/components/product-listing.d.ts +7 -0
  113. package/dist/store/components/product-listing.d.ts.map +1 -0
  114. package/dist/store/components/product-qa-section.d.ts +5 -0
  115. package/dist/store/components/product-qa-section.d.ts.map +1 -0
  116. package/dist/store/components/product-reviews-section.d.ts +5 -0
  117. package/dist/store/components/product-reviews-section.d.ts.map +1 -0
  118. package/dist/store/components/recently-viewed.d.ts +12 -0
  119. package/dist/store/components/recently-viewed.d.ts.map +1 -0
  120. package/dist/store/components/recommended-products.d.ts +7 -0
  121. package/dist/store/components/recommended-products.d.ts.map +1 -0
  122. package/dist/store/components/related-products.d.ts +7 -0
  123. package/dist/store/components/related-products.d.ts.map +1 -0
  124. package/dist/store/components/star-display.d.ts +6 -0
  125. package/dist/store/components/star-display.d.ts.map +1 -0
  126. package/dist/store/components/star-picker.d.ts +6 -0
  127. package/dist/store/components/star-picker.d.ts.map +1 -0
  128. package/dist/store/components/stock-badge.d.ts +5 -0
  129. package/dist/store/components/stock-badge.d.ts.map +1 -0
  130. package/dist/store/endpoints/get-category.d.ts +22 -0
  131. package/dist/store/endpoints/get-category.d.ts.map +1 -0
  132. package/dist/store/endpoints/get-collection.d.ts +17 -0
  133. package/dist/store/endpoints/get-collection.d.ts.map +1 -0
  134. package/dist/store/endpoints/get-featured.d.ts +10 -0
  135. package/dist/store/endpoints/get-featured.d.ts.map +1 -0
  136. package/dist/store/endpoints/get-product.d.ts +17 -0
  137. package/dist/store/endpoints/get-product.d.ts.map +1 -0
  138. package/dist/store/endpoints/get-related.d.ts +11 -0
  139. package/dist/store/endpoints/get-related.d.ts.map +1 -0
  140. package/dist/store/endpoints/index.d.ts +129 -0
  141. package/dist/store/endpoints/index.d.ts.map +1 -0
  142. package/dist/store/endpoints/list-categories.d.ts +6 -0
  143. package/dist/store/endpoints/list-categories.d.ts.map +1 -0
  144. package/dist/store/endpoints/list-collections.d.ts +10 -0
  145. package/dist/store/endpoints/list-collections.d.ts.map +1 -0
  146. package/dist/store/endpoints/list-products.d.ts +26 -0
  147. package/dist/store/endpoints/list-products.d.ts.map +1 -0
  148. package/dist/store/endpoints/search-products.d.ts +11 -0
  149. package/dist/store/endpoints/search-products.d.ts.map +1 -0
  150. package/dist/store/endpoints/store-search.d.ts +18 -0
  151. package/dist/store/endpoints/store-search.d.ts.map +1 -0
  152. package/package.json +3 -3
  153. package/src/__tests__/endpoint-security.test.ts +457 -0
  154. package/src/__tests__/service-impl.test.ts +1745 -0
  155. package/src/admin/endpoints/create-category.ts +5 -2
  156. package/src/admin/endpoints/create-collection.ts +1 -1
  157. package/src/admin/endpoints/create-product.ts +5 -2
  158. package/src/admin/endpoints/delete-category.ts +1 -1
  159. package/src/admin/endpoints/delete-collection.ts +1 -1
  160. package/src/admin/endpoints/delete-product.ts +1 -1
  161. package/src/admin/endpoints/delete-variant.ts +1 -1
  162. package/src/admin/endpoints/list-categories.ts +1 -1
  163. package/src/admin/endpoints/list-collections.ts +1 -1
  164. package/src/admin/endpoints/list-products.ts +1 -1
  165. package/src/admin/endpoints/remove-collection-product.ts +1 -1
  166. package/src/admin/endpoints/update-category.ts +5 -2
  167. package/src/admin/endpoints/update-collection.ts +1 -1
  168. package/src/admin/endpoints/update-product.ts +5 -2
  169. package/src/admin/endpoints/update-variant.ts +1 -1
  170. package/src/service-impl.ts +1139 -0
  171. package/src/service.ts +312 -0
  172. package/src/store/components/_hooks.ts +81 -0
  173. package/src/store/components/_utils.ts +8 -0
  174. package/src/store/components/collection-detail.tsx +21 -1
  175. package/src/store/components/collection-grid.tsx +5 -1
  176. package/src/store/components/featured-products.tsx +5 -1
  177. package/src/store/components/index.tsx +2 -0
  178. package/src/store/components/product-card.mdx +1 -1
  179. package/src/store/components/product-card.tsx +25 -5
  180. package/src/store/components/product-detail.mdx +2 -0
  181. package/src/store/components/product-detail.tsx +55 -8
  182. package/src/store/components/product-listing.tsx +25 -4
  183. package/src/store/components/product-qa-section.mdx +21 -0
  184. package/src/store/components/product-qa-section.tsx +503 -0
  185. package/src/store/components/recommended-products.mdx +6 -0
  186. package/src/store/components/recommended-products.tsx +119 -0
  187. package/src/store/endpoints/get-category.ts +2 -2
  188. package/src/store/endpoints/get-collection.ts +1 -1
  189. package/src/store/endpoints/get-featured.ts +1 -1
  190. package/src/store/endpoints/get-product.ts +1 -1
  191. package/src/store/endpoints/get-related.ts +2 -2
  192. package/src/store/endpoints/list-collections.ts +3 -3
  193. package/src/store/endpoints/list-products.ts +9 -9
  194. package/src/store/endpoints/search-products.ts +4 -6
  195. package/src/store/endpoints/store-search.ts +1 -1
  196. package/COMPONENTS.md +0 -231
@@ -6,17 +6,17 @@ export const listProducts = createStoreEndpoint(
6
6
  method: "GET",
7
7
  query: z
8
8
  .object({
9
- page: z.string().optional(),
10
- limit: z.string().optional(),
11
- category: z.string().optional(),
12
- featured: z.string().optional(),
13
- search: z.string().optional(),
9
+ page: z.string().max(10).optional(),
10
+ limit: z.string().max(10).optional(),
11
+ category: z.string().max(200).optional(),
12
+ featured: z.string().max(10).optional(),
13
+ search: z.string().max(500).optional(),
14
14
  sort: z.enum(["name", "price", "createdAt", "updatedAt"]).optional(),
15
15
  order: z.enum(["asc", "desc"]).optional(),
16
- minPrice: z.string().optional(),
17
- maxPrice: z.string().optional(),
18
- inStock: z.string().optional(),
19
- tag: z.string().optional(),
16
+ minPrice: z.string().max(20).optional(),
17
+ maxPrice: z.string().max(20).optional(),
18
+ inStock: z.string().max(10).optional(),
19
+ tag: z.string().max(200).optional(),
20
20
  })
21
21
  .optional(),
22
22
  },
@@ -1,18 +1,16 @@
1
- import { createStoreEndpoint, z } from "@86d-app/core";
1
+ import { createStoreEndpoint, sanitizeText, z } from "@86d-app/core";
2
2
 
3
3
  export const searchProducts = createStoreEndpoint(
4
4
  "/products/search",
5
5
  {
6
6
  method: "GET",
7
7
  query: z.object({
8
- q: z.string().min(1).max(500),
9
- limit: z.string().optional(),
8
+ q: z.string().min(1).max(500).transform(sanitizeText),
9
+ limit: z.string().max(10).optional(),
10
10
  }),
11
11
  },
12
12
  async (ctx) => {
13
- const { query } = ctx;
14
- // Call the controller directly
15
13
  const products = await ctx.context.controllers.product.search(ctx);
16
- return { products, query: query.q };
14
+ return { products };
17
15
  },
18
16
  );
@@ -36,7 +36,7 @@ export const storeSearch = createStoreEndpoint(
36
36
  method: "GET",
37
37
  query: z.object({
38
38
  q: z.string().min(0).max(500),
39
- limit: z.string().optional(),
39
+ limit: z.string().max(10).optional(),
40
40
  }),
41
41
  },
42
42
  async (ctx) => {
package/COMPONENTS.md DELETED
@@ -1,231 +0,0 @@
1
- # Products Module — Store Components
2
-
3
- Components exported for use in store MDX templates. Import via the component registry (auto-registered when the module is in `templates/brisa/config.json`).
4
-
5
- ## ProductCard
6
-
7
- Displays a single product card with image, name, price, discount badge, and optional "Add to Cart" button.
8
-
9
- ### Props
10
-
11
- | Prop | Type | Default | Description |
12
- |------|------|---------|-------------|
13
- | `product` | `Product` | — | Product object with id, name, slug, price, images, etc. |
14
- | `showAddToCart` | `boolean` | `true` | Show the "Add to Cart" button |
15
-
16
- ### Usage in MDX
17
-
18
- ```mdx
19
- <ProductCard product={product} />
20
-
21
- <ProductCard product={product} showAddToCart={false} />
22
- ```
23
-
24
- ## FeaturedProducts
25
-
26
- Displays a responsive grid of featured products. Fetches its own data.
27
-
28
- ### Props
29
-
30
- | Prop | Type | Default | Description |
31
- |------|------|---------|-------------|
32
- | `limit` | `number` | — | Max number of featured products to display |
33
- | `title` | `string` | — | Section heading |
34
-
35
- ### Usage in MDX
36
-
37
- ```mdx
38
- <FeaturedProducts />
39
-
40
- <FeaturedProducts limit={4} title="Staff Picks" />
41
- ```
42
-
43
- ## ProductListing
44
-
45
- Full product listing with search, category/price/stock/tag filters, sorting, and pagination. Fetches its own data.
46
-
47
- ### Props
48
-
49
- | Prop | Type | Default | Description |
50
- |------|------|---------|-------------|
51
- | `initialCategory` | `string` | — | Pre-select a category filter |
52
- | `initialSearch` | `string` | — | Pre-fill the search query |
53
- | `pageSize` | `number` | — | Products per page |
54
-
55
- ### Usage in MDX
56
-
57
- ```mdx
58
- <ProductListing />
59
-
60
- <ProductListing initialCategory="shoes" pageSize={12} />
61
- ```
62
-
63
- ## ProductDetail
64
-
65
- Full product detail page with image gallery, variant selector, pricing, inventory status, reviews, and related products. Fetches its own data.
66
-
67
- ### Props
68
-
69
- | Prop | Type | Description |
70
- |------|------|-------------|
71
- | `slug` | `string` | Product slug (from URL) |
72
- | `params` | `Record<string, string>` | Route params (params.slug) |
73
-
74
- ### Usage
75
-
76
- Loaded dynamically by the store catch-all route for `/products/:slug`.
77
-
78
- ## RelatedProducts
79
-
80
- Horizontal grid of related products for a given product. Fetches its own data.
81
-
82
- ### Props
83
-
84
- | Prop | Type | Default | Description |
85
- |------|------|---------|-------------|
86
- | `productId` | `string` | — | Product ID to find related products for |
87
- | `limit` | `number` | — | Max related products to show |
88
- | `title` | `string` | — | Section heading |
89
-
90
- ### Usage in MDX
91
-
92
- ```mdx
93
- <RelatedProducts productId={product.id} />
94
-
95
- <RelatedProducts productId={product.id} limit={4} title="You may also like" />
96
- ```
97
-
98
- ## CollectionCard
99
-
100
- Displays a single collection card with image, name, and description.
101
-
102
- ### Props
103
-
104
- | Prop | Type | Description |
105
- |------|------|-------------|
106
- | `collection` | `CollectionCardData` | Collection object with id, name, slug, description, image |
107
-
108
- ### Usage in MDX
109
-
110
- ```mdx
111
- <CollectionCard collection={collection} />
112
- ```
113
-
114
- ## CollectionGrid
115
-
116
- Grid of collections with optional featured-only filtering. Fetches its own data.
117
-
118
- ### Props
119
-
120
- | Prop | Type | Default | Description |
121
- |------|------|---------|-------------|
122
- | `title` | `string` | — | Section heading |
123
- | `featured` | `boolean` | — | Only show featured collections |
124
-
125
- ### Usage in MDX
126
-
127
- ```mdx
128
- <CollectionGrid />
129
-
130
- <CollectionGrid title="Shop by Category" featured={true} />
131
- ```
132
-
133
- ## CollectionDetail
134
-
135
- Full collection page with image, description, product count, and products grid. Fetches its own data.
136
-
137
- ### Props
138
-
139
- | Prop | Type | Description |
140
- |------|------|-------------|
141
- | `slug` | `string` | Collection slug (from URL) |
142
- | `params` | `Record<string, string>` | Route params (params.slug) |
143
-
144
- ### Usage
145
-
146
- Loaded dynamically by the store catch-all route for `/collections/:slug`.
147
-
148
- ## FilterChip
149
-
150
- Small removable tag displaying an active filter. Used internally by ProductListing.
151
-
152
- ### Props
153
-
154
- | Prop | Type | Description |
155
- |------|------|-------------|
156
- | `label` | `string` | Filter display text |
157
- | `onRemove` | `() => void` | Callback when the chip is dismissed |
158
-
159
- ### Usage in MDX
160
-
161
- ```mdx
162
- <FilterChip label="Shoes" onRemove={handleRemove} />
163
- ```
164
-
165
- ## StarDisplay
166
-
167
- Read-only star rating display.
168
-
169
- ### Props
170
-
171
- | Prop | Type | Default | Description |
172
- |------|------|---------|-------------|
173
- | `rating` | `number` | — | Rating value (0–5) |
174
- | `size` | `"sm" \| "md" \| "lg"` | `"md"` | Star size |
175
-
176
- ### Usage in MDX
177
-
178
- ```mdx
179
- <StarDisplay rating={4.5} />
180
-
181
- <StarDisplay rating={product.averageRating} size="sm" />
182
- ```
183
-
184
- ## StarPicker
185
-
186
- Interactive star rating input for review submission.
187
-
188
- ### Props
189
-
190
- | Prop | Type | Description |
191
- |------|------|-------------|
192
- | `value` | `number` | Current rating value |
193
- | `onChange` | `(n: number) => void` | Callback when user selects a rating |
194
-
195
- ### Usage in MDX
196
-
197
- ```mdx
198
- <StarPicker value={rating} onChange={setRating} />
199
- ```
200
-
201
- ## StockBadge
202
-
203
- Inventory status badge. Shows "Out of stock", "Only X left", or "In stock".
204
-
205
- ### Props
206
-
207
- | Prop | Type | Description |
208
- |------|------|-------------|
209
- | `inventory` | `number` | Available inventory count |
210
-
211
- ### Usage in MDX
212
-
213
- ```mdx
214
- <StockBadge inventory={product.inventory} />
215
- ```
216
-
217
- ## ProductReviewsSection
218
-
219
- Complete review section with rating summary, review list with pagination, and review submission form. Fetches its own data.
220
-
221
- ### Props
222
-
223
- | Prop | Type | Description |
224
- |------|------|-------------|
225
- | `productId` | `string` | Product ID to show reviews for |
226
-
227
- ### Usage in MDX
228
-
229
- ```mdx
230
- <ProductReviewsSection productId={product.id} />
231
- ```