@hed-hog/catalog 0.0.278 → 0.0.279
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/README.md +115 -7
- package/hedhog/frontend/app/[resource]/page.tsx.ejs +217 -265
- package/hedhog/frontend/app/_components/catalog-resource-form-sheet.tsx.ejs +964 -0
- package/hedhog/frontend/app/_lib/catalog-resources.tsx.ejs +736 -151
- package/hedhog/frontend/app/dashboard/page.tsx.ejs +5 -9
- package/package.json +5 -5
- package/hedhog/frontend/app/_components/catalog-nav.tsx.ejs +0 -85
package/README.md
CHANGED
|
@@ -166,27 +166,134 @@ O módulo `@hed-hog/catalog` é responsável pela gestão centralizada dos recur
|
|
|
166
166
|
|
|
167
167
|
## 7. Banco de dados (tabelas YAML)
|
|
168
168
|
|
|
169
|
-
###
|
|
169
|
+
### catalog_product
|
|
170
170
|
|
|
171
171
|
- **Finalidade:** Armazena os produtos do catálogo.
|
|
172
172
|
- **Colunas principais:**
|
|
173
173
|
- `id` (PK)
|
|
174
174
|
- `brand_id` (FK para `catalog_brand`, nullable)
|
|
175
175
|
- `category_id` (FK para `category`)
|
|
176
|
+
- `primary_content_id` (FK para `content`, nullable)
|
|
176
177
|
- `slug` (varchar 255, único)
|
|
177
178
|
- `name` (varchar 255)
|
|
178
179
|
- `short_description` (varchar 500, nullable)
|
|
179
180
|
- `description` (text, nullable)
|
|
181
|
+
- `model_name` (varchar 255, nullable)
|
|
182
|
+
- `sku` (varchar 120, nullable)
|
|
183
|
+
- `gtin` (varchar 120, nullable)
|
|
180
184
|
- `status` (enum: `draft`, `published`, `archived`, default `draft`)
|
|
181
185
|
- `comparison_status` (enum: `draft`, `ready`, `disabled`, default `draft`)
|
|
186
|
+
- `release_date` (datetime, nullable)
|
|
187
|
+
- `spec_snapshot_json` (json, nullable)
|
|
188
|
+
- `comparison_snapshot_json` (json, nullable)
|
|
182
189
|
- `is_active` (boolean, default `true`)
|
|
183
190
|
- `created_at`, `updated_at` (timestamps)
|
|
184
191
|
- **Defaults:** Conforme descrito acima.
|
|
185
|
-
- **Nulabilidade:** Campos como `brand_id`, `short_description`, `description` são opcionais.
|
|
186
|
-
- **Integridade:** FK para `catalog_brand`, `category
|
|
192
|
+
- **Nulabilidade:** Campos como `brand_id`, `primary_content_id`, `short_description`, `description`, `model_name`, `sku`, `gtin`, `release_date`, `spec_snapshot_json`, `comparison_snapshot_json` são opcionais.
|
|
193
|
+
- **Integridade:** FK para `catalog_brand`, `category`, `content`.
|
|
187
194
|
- **Índices:**
|
|
188
195
|
- Único em `slug`
|
|
189
|
-
- Índices em `category_id` + `status`, `brand_id` + `status`, `is_active`
|
|
196
|
+
- Índices em `category_id` + `status`, `brand_id` + `status`, `primary_content_id`, `is_active`
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### catalog_product_image
|
|
201
|
+
|
|
202
|
+
- **Finalidade:** Armazena imagens associadas a produtos.
|
|
203
|
+
- **Colunas principais:**
|
|
204
|
+
- `id` (PK)
|
|
205
|
+
- `product_id` (FK para `catalog_product`)
|
|
206
|
+
- `file_id` (FK para `file`)
|
|
207
|
+
- `role` (enum: `primary`, `gallery`, `thumbnail`, `lifestyle`, `technical`, default `gallery`)
|
|
208
|
+
- `sort_order` (int, default 0)
|
|
209
|
+
- `is_primary` (boolean, default false)
|
|
210
|
+
- `alt_text` (varchar 255, nullable)
|
|
211
|
+
- `created_at`, `updated_at` (timestamps)
|
|
212
|
+
- **Defaults:** Conforme descrito acima.
|
|
213
|
+
- **Nulabilidade:** `alt_text` é opcional.
|
|
214
|
+
- **Integridade:** FK para `catalog_product` e `file`.
|
|
215
|
+
- **Índices:**
|
|
216
|
+
- Índices em `product_id` + `sort_order`, `product_id` + `is_primary`, `file_id`
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
### catalog_brand
|
|
221
|
+
|
|
222
|
+
- **Finalidade:** Armazena marcas do catálogo.
|
|
223
|
+
- **Colunas principais:**
|
|
224
|
+
- `id` (PK)
|
|
225
|
+
- `slug` (varchar 255, único)
|
|
226
|
+
- `name` (varchar 255)
|
|
227
|
+
- `normalized_name` (varchar 255)
|
|
228
|
+
- `logo_file_id` (FK para `file`, nullable)
|
|
229
|
+
- `status` (enum: `active`, `inactive`, default `active`)
|
|
230
|
+
- `website_url` (varchar 500, nullable)
|
|
231
|
+
- `created_at`, `updated_at` (timestamps)
|
|
232
|
+
- **Defaults:** Conforme descrito acima.
|
|
233
|
+
- **Nulabilidade:** `logo_file_id` e `website_url` são opcionais.
|
|
234
|
+
- **Integridade:** FK para `file`.
|
|
235
|
+
- **Índices:**
|
|
236
|
+
- Único em `slug`
|
|
237
|
+
- Índices em `normalized_name`, `logo_file_id`, `status`
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### catalog_offer
|
|
242
|
+
|
|
243
|
+
- **Finalidade:** Armazena ofertas vinculadas a produtos e comerciantes.
|
|
244
|
+
- **Colunas principais:**
|
|
245
|
+
- `id` (PK)
|
|
246
|
+
- `product_id` (FK para `catalog_product`)
|
|
247
|
+
- `merchant_id` (FK para `catalog_merchant`)
|
|
248
|
+
- `affiliate_program_id` (FK para `catalog_affiliate_program`, nullable)
|
|
249
|
+
- `site_id` (FK para `catalog_site`, nullable)
|
|
250
|
+
- `external_offer_id` (varchar 255)
|
|
251
|
+
- `title` (varchar 255)
|
|
252
|
+
- `price_amount` (decimal 14,2)
|
|
253
|
+
- `price_currency` (varchar 3)
|
|
254
|
+
- `original_price_amount` (decimal 14,2, nullable)
|
|
255
|
+
- `installment_json` (json, nullable)
|
|
256
|
+
- `availability_status` (enum: `in_stock`, `out_of_stock`, `pre_order`, `unknown`, default `unknown`)
|
|
257
|
+
- `affiliate_url` (varchar 500, nullable)
|
|
258
|
+
- `deep_link_url` (varchar 500, nullable)
|
|
259
|
+
- `priority_score` (int, default 0)
|
|
260
|
+
- `is_featured` (boolean, default false)
|
|
261
|
+
- `valid_from` (datetime, nullable)
|
|
262
|
+
- `valid_until` (datetime, nullable)
|
|
263
|
+
- `last_seen_at` (datetime, nullable)
|
|
264
|
+
- `created_at`, `updated_at` (timestamps)
|
|
265
|
+
- **Defaults:** Conforme descrito acima.
|
|
266
|
+
- **Nulabilidade:** Campos como `affiliate_program_id`, `site_id`, `original_price_amount`, `installment_json`, `affiliate_url`, `deep_link_url`, `valid_from`, `valid_until`, `last_seen_at` são opcionais.
|
|
267
|
+
- **Integridade:** FK para `catalog_product`, `catalog_merchant`, `catalog_affiliate_program`, `catalog_site`.
|
|
268
|
+
- **Índices:**
|
|
269
|
+
- Único em `product_id`, `merchant_id`, `external_offer_id`
|
|
270
|
+
- Índices em `product_id`, `availability_status`, `price_amount`
|
|
271
|
+
- Índices em `site_id`, `is_featured`
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### catalog_affiliate_program
|
|
276
|
+
|
|
277
|
+
- **Finalidade:** Armazena programas de afiliados vinculados a comerciantes.
|
|
278
|
+
- **Colunas principais:**
|
|
279
|
+
- `id` (PK)
|
|
280
|
+
- `merchant_id` (FK para `catalog_merchant`, nullable)
|
|
281
|
+
- `slug` (varchar 255, único)
|
|
282
|
+
- `name` (varchar 255)
|
|
283
|
+
- `network_type` (enum: `amazon`, `mercado_livre`, `aliexpress`, `kabum`, `direct`, `network`, default `direct`)
|
|
284
|
+
- `tracking_template` (text, nullable)
|
|
285
|
+
- `commission_type` (enum: `percentage`, `fixed`, default `percentage`)
|
|
286
|
+
- `default_commission_value` (decimal 8,2, default 0)
|
|
287
|
+
- `status` (enum: `active`, `inactive`, default `active`)
|
|
288
|
+
- `created_at`, `updated_at` (timestamps)
|
|
289
|
+
- **Defaults:** Conforme descrito acima.
|
|
290
|
+
- **Nulabilidade:** `merchant_id` e `tracking_template` são opcionais.
|
|
291
|
+
- **Integridade:** FK para `catalog_merchant`.
|
|
292
|
+
- **Índices:**
|
|
293
|
+
- Único em `slug`
|
|
294
|
+
- Índices em `merchant_id`, `status`
|
|
295
|
+
|
|
296
|
+
---
|
|
190
297
|
|
|
191
298
|
*(Outras tabelas seguem padrão similar, com chaves primárias, estrangeiras, enums e índices conforme arquivos YAML fornecidos.)*
|
|
192
299
|
|
|
@@ -194,11 +301,12 @@ O módulo `@hed-hog/catalog` é responsável pela gestão centralizada dos recur
|
|
|
194
301
|
|
|
195
302
|
- O módulo suporta múltiplos recursos configurados dinamicamente via `catalogResourceMap`.
|
|
196
303
|
- Campos de busca e filtro são configurados por recurso para permitir consultas eficientes.
|
|
197
|
-
- Campos booleanos e numéricos são normalizados automaticamente no payload.
|
|
198
|
-
- Exclusão e atualização verificam existência prévia do registro.
|
|
304
|
+
- Campos booleanos e numéricos são normalizados automaticamente no payload (ex: strings `"true"`, `"false"` e números em string são convertidos).
|
|
305
|
+
- Exclusão e atualização verificam existência prévia do registro, retornando erro 404 se não encontrado.
|
|
199
306
|
- Estatísticas incluem contagem total e contagem por status ativo quando aplicável.
|
|
200
307
|
- Imagens de produtos são ordenadas por `sort_order` e podem ter uma imagem primária.
|
|
201
|
-
- O sistema suporta múltiplos idiomas via parâmetro `locale
|
|
308
|
+
- O sistema suporta múltiplos idiomas via parâmetro `locale` (header `Accept-Language`).
|
|
309
|
+
- Autorização é restrita a usuários com papéis `admin` e `admin-catalog`.
|
|
202
310
|
|
|
203
311
|
## 9. Guia rápido de uso (exemplos)
|
|
204
312
|
|