@adatechnology/content-module 0.3.0 → 0.4.0
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 +40 -0
- package/dist/index.cjs +1933 -338
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +787 -34
- package/dist/index.d.ts +787 -34
- package/dist/index.js +1897 -304
- package/dist/index.js.map +1 -1
- package/dist/migrations/0002_community.sql +44 -0
- package/dist/migrations/meta/0002_snapshot.json +813 -0
- package/dist/migrations/meta/_journal.json +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -92,6 +92,46 @@ Respostas públicas saem com `Cache-Control` (`config.publicCacheControl`, padr
|
|
|
92
92
|
`public, max-age=60, s-maxage=300, stale-while-revalidate=600`). Post de outra empresa responde 404
|
|
93
93
|
em toda rota, nunca 403.
|
|
94
94
|
|
|
95
|
+
## Posts da comunidade
|
|
96
|
+
|
|
97
|
+
Hóspedes escrevem; a equipe modera. Sem `providers.communityAuthor`, nada disso existe (use case, rota, tabela de rotas
|
|
98
|
+
igual à de antes). A porta `CommunityAuthorPort` (`resolveAuthor({ headers })` e `checkEligibility`) é chamada em **toda**
|
|
99
|
+
requisição `/community/*`: sem sessão 401, sem elegibilidade 403. O upload de foto também exige `imageStorage`.
|
|
100
|
+
|
|
101
|
+
| Método | Caminho | Escopo | `operationId` |
|
|
102
|
+
| ---------------- | ------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------- |
|
|
103
|
+
| GET/POST | `/community/posts` | sessão do hóspede | `listOwnCommunityPosts`, `createCommunityPost` |
|
|
104
|
+
| GET/PATCH/DELETE | `/community/posts/:id` | sessão do hóspede | `getOwnCommunityPost`, `updateOwnCommunityPost`, `deleteOwnCommunityPost` |
|
|
105
|
+
| POST | `/community/posts/:id/submit` | sessão do hóspede | `submitCommunityPost` (`{ termsAccepted: true }`) |
|
|
106
|
+
| POST | `/community/images` | sessão do hóspede | `uploadCommunityImage` |
|
|
107
|
+
| POST | `/public/posts/:id/reports` | público | `createPostReport` (202; só post da comunidade no ar) |
|
|
108
|
+
| POST | `/posts/:id/approve`, `/reject`, `/unpublish-community` | admin | `approveCommunityPost`, `rejectCommunityPost`, `unpublishCommunityPost` |
|
|
109
|
+
| POST | `/posts/moderation` | admin | `moderateCommunityPostsInBulk` (resumo por item) |
|
|
110
|
+
| GET/PUT | `/settings` | admin | `getContentSettings`, `updateContentSettings` |
|
|
111
|
+
| GET | `/reports`, POST `/reports/:id/resolve` | admin | `listPostReports`, `resolvePostReport` |
|
|
112
|
+
|
|
113
|
+
`GET /public/posts?origin=staff|community|all` (padrão `staff`) e `GET /posts?origin=` filtram a origem. Respostas da
|
|
114
|
+
comunidade saem com `Cache-Control: no-store`. No OpenAPI elas aparecem como `public` sem bloco de segurança (limite do
|
|
115
|
+
`module-http`); o `summary` diz que exigem a sessão do hóspede.
|
|
116
|
+
|
|
117
|
+
Ganchos (`hooks`): `onPostChanged`, `onCommunityPostSubmitted`, `onCommunityPostReviewed`, `onPostReported`.
|
|
118
|
+
|
|
119
|
+
**Limite de taxa é do app.** O módulo exporta `CONTENT_RATE_LIMITED_OPERATIONS` (`createCommunityPost`,
|
|
120
|
+
`updateOwnCommunityPost`, `submitCommunityPost`, `uploadCommunityImage`, `createPostReport`); o app envolve esses
|
|
121
|
+
handlers na tabela (por IP e, nas de autoria, por conta). `Retry-After` também é do app; o 429 do limite diário do módulo
|
|
122
|
+
leva `retryAfterSeconds` em `publicDetails`.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { CONTENT_RATE_LIMITED_OPERATIONS, createContentRoutes } from '@adatechnology/content-module'
|
|
126
|
+
|
|
127
|
+
const limited = new Set<string>(CONTENT_RATE_LIMITED_OPERATIONS)
|
|
128
|
+
const routes = createContentRoutes({ module, publicCompanyResolver }).map((route) =>
|
|
129
|
+
limited.has(route.operationId)
|
|
130
|
+
? { ...route, handler: async (context) => ((await limiter.allow(context.ip)) ? route.handler(context) : tooMany()) }
|
|
131
|
+
: route,
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
95
135
|
## Agendamento, modelos e recorrência
|
|
96
136
|
|
|
97
137
|
- **`publishDue({ now? })`** (`module.useCases.publishDue`): o host chama num intervalo. Marca como
|