arquivos

Manages file uploads, storage, and deletion lifecycle in a Firebase-backed Next.js ERP.

Updated May 13, 2026
One-click install
npx skills add https://github.com/Hinten/next_erp --skill arquivos-hinten
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: arquivos
Source: https://github.com/Hinten/next_erp/tree/main/.claude/skills/arquivos
Command: npx skills add https://github.com/Hinten/next_erp --skill arquivos-hinten

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Handling files in this ERP involves a doc-anchored, content-addressed storage model with Cloud Function cascades and orphan sweeps; doing it by hand leaks orphaned Storage objects or breaks dedup. This Skill teaches the correct helpers, components, and deletion machinery so uploads, thumbnails, and cleanup work without silent data leaks. ## Core Features & Use Cases - Upload helpers: Use uploadProductImage, uploadProductVideo, uploadFile, and uploadFromUrl from @delfrance/storage, all funneled through the create-first, deduplicating putArquivo core. - Reusable UI: Wire PhotoManager and VideoManager into ObjectView forms with staged deletion via prepareForSave: stripMarkedForDeletion. - Deletion lifecycle: Understand the five Cloud Functions (resize trigger, deletion cascade, eager reaper, 48h orphan sweeps) and why you delete the arquivos doc, never the Storage object. - Use Case: When adding file attachments to a new entity like pedidos, follow the §9 recipe to add path builders, ref shapes, UI wiring, and—critically—extend the produto-scoped sweeps so the new files don't become silent orphans. ## Quick Start Ask the AI to add photo upload support to a produto form using the arquivos skill's upload helpers and PhotoManager component.

Frequently Asked Questions about arquivos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I upload a product image in this Firebase ERP?

Call uploadProductImage from @delfrance/storage with storage, db, produtoId, bytes, and contentType. It runs through putArquivo, which writes the anchor doc first, uploads bytes tagged with the doc id, and returns the content-addressed id for building Foto refs.

How do I delete a file from Firebase Storage without orphaning data?

Delete the arquivos Firestore doc, never the Storage object directly. The onArquivoDeleted Cloud Function frees the object and cascades derivatives; deleting the object directly leaves a dangling doc that nothing cleans up.

Why does my product photo show in the editor but break in the list view?

The thumbnail fallback must check document existence, not null ref strings. buildFotoRefs fills all derivative refs optimistically, so a ?? chain always picks the 200px ref even when resizeProductImage never created that document.

Can I reuse the file upload system for entities other than produtos?

Yes, but the orphan sweeps are produto-scoped, so a new entity's files are not auto-reaped. You must extend the path parsing and reference resolution or add an eager trigger modeled on onProdutoMediaChanged, otherwise you create silent orphans.

When should I not use the arquivos file handling system?

Skip it for plain schema-driven CRUD forms, NF-e XML/PDF artifacts stored under pedidos/{id}/nfev4, and freight label PDFs. Those are domain documents with their own storage paths, not arquivos collection entries.