mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-06 18:53:05 +00:00
Envio em lote (1 request raw-body por arquivo, fan-out ≤2, até 50 arquivos) e adicionar por link (Instagram/YouTube; extração só pela Graph API da conta própria, senão peça-link) em /campanha/comunicacao/conteudos. Cada peça tem estado próprio (Processando/Pronto/Falhou + Reprocessar), transcrição/texto e catalogação automática revisável; publicar/despublicar preserva arquivo, slug e publishedAt. - collections contentPiece + contentMedia (upload privado no S3) e migration 20260923_032714_add_content_piece (slug único gerado no 1º publish, sourceUrl única, searchText com índice trigram) - pipeline reusa C199 (job after() + reaper + retry condicional, transcrição DeepInfra, ffmpeg/chunk), o classificador de facetas do acervo e o institutionCatalog; curatedFields impede o job de sobrescrever curadoria - gate único canReadCommunicationCatalog (advisor/leader negados); delete só pelo admin; sem Consent novo - UI portada do design aprovado (lista desktop + cards mobile, diálogo de lote com progresso por arquivo, diálogo de link, ficha editável, kill switch); nav/chrome/column-picker/manifest atualizados - instagramFeed expõe mediaUrl; revalidateTag ganha wrapper seguro fora de request (fixtures/scripts) - testes: 2 unit specs, 1 int spec (16 casos) e 7 e2e na vertical - follow-up de engenharia: #1267 (docs/plans/escala-dry-pos-c211.md) Closes #1254
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import 'server-only'
|
|
|
|
import type { Config } from '@/payload-types'
|
|
|
|
import { revalidateTag } from 'next/cache'
|
|
|
|
// Tag vocabulary + revalidation helpers only. This module is imported by
|
|
// collections (afterChange hooks), which payload.config.ts aggregates — so it
|
|
// must NOT import `@payload-config`, or the module graph becomes circular
|
|
// (payload.config → collection → here → payload.config). Config-dependent
|
|
// cached reads live in `documentReads.ts`.
|
|
|
|
type Collection = keyof Config['collections']
|
|
|
|
export const getDocumentCacheTag = <Slug extends Collection>(
|
|
collection: Slug,
|
|
id: string | number,
|
|
) => `document_${collection}:${id}`
|
|
|
|
/**
|
|
* `revalidateTag` throws Next's "static generation store missing" invariant when
|
|
* a Local API write happens OUTSIDE a request scope — e2e fixtures, one-off
|
|
* scripts, seeds. There is no cache to bust in that case, so that one invariant
|
|
* is swallowed; every other failure still propagates (a silently broken
|
|
* revalidation inside a request would be a real bug).
|
|
*/
|
|
const revalidateTagSafely = (tag: string): void => {
|
|
try {
|
|
revalidateTag(tag)
|
|
} catch (error) {
|
|
if (error instanceof Error && error.message.includes('static generation store missing')) return
|
|
throw error
|
|
}
|
|
}
|
|
|
|
export const revalidateDocumentById = <Slug extends Collection>(
|
|
collection: Slug,
|
|
id: string | number,
|
|
) => revalidateTagSafely(getDocumentCacheTag(collection, id))
|
|
|
|
export const getCollectionListingTag = <Slug extends Collection>(collection: Slug) =>
|
|
`${collection}s`
|
|
|
|
const revalidateCollectionListing = <Slug extends Collection>(collection: Slug) =>
|
|
revalidateTagSafely(getCollectionListingTag(collection))
|
|
|
|
export const revalidatePostsListing = () => revalidateCollectionListing('post')
|
|
|
|
export const revalidateShareLinksListing = () => revalidateCollectionListing('shareLink')
|
|
|
|
export const revalidateJinglesListing = () => revalidateCollectionListing('jingle')
|
|
|
|
/** C211 — the content pieces listing tag the public Central (S27) will read. */
|
|
export const revalidateContentPiecesListing = () => revalidateCollectionListing('contentPiece')
|