@kaikybrofc/omnizap-system 2.2.1 → 2.2.3
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 +116 -0
- package/app/modules/stickerPackModule/stickerPackCatalogHttp.js +289 -0
- package/package.json +2 -1
- package/scripts/release.sh +17 -0
- package/scripts/sync-readme-snapshot.mjs +71 -0
- package/RELEASE-v2.1.2.md +0 -83
package/README.md
CHANGED
|
@@ -26,6 +26,118 @@ O **OmniZap System** é uma plataforma de automação para WhatsApp usando **Nod
|
|
|
26
26
|
- Termos de uso: https://omnizap.shop/termos-de-uso/
|
|
27
27
|
- Licença: https://omnizap.shop/licenca/
|
|
28
28
|
|
|
29
|
+
## Snapshot dinâmico para README/NPM
|
|
30
|
+
|
|
31
|
+
Use as rotas abaixo para consumir o bloco já renderizado com dados do sistema:
|
|
32
|
+
|
|
33
|
+
- JSON: `GET /api/sticker-packs/readme-summary`
|
|
34
|
+
- Markdown: `GET /api/sticker-packs/readme-markdown`
|
|
35
|
+
|
|
36
|
+
Para atualizar este `README.md` automaticamente com o conteúdo renderizado:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm run readme:sync-snapshot
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Conteúdo incluído no snapshot:
|
|
43
|
+
|
|
44
|
+
- total de usuários (`lid_map`)
|
|
45
|
+
- total de grupos
|
|
46
|
+
- total de packs e stickers
|
|
47
|
+
- total de mensagens registradas
|
|
48
|
+
- tipos de mensagem mais usados
|
|
49
|
+
- lista de comandos disponíveis no menu
|
|
50
|
+
|
|
51
|
+
Atualização em cache: **30 minutos** por padrão (`README_SUMMARY_CACHE_SECONDS=1800`).
|
|
52
|
+
|
|
53
|
+
<!-- README_SNAPSHOT:START -->
|
|
54
|
+
## OmniZap System Snapshot
|
|
55
|
+
|
|
56
|
+
Atualizado em: **2026-02-28T01:11:03.592Z**
|
|
57
|
+
Janela de atualização: **1800 segundos**
|
|
58
|
+
|
|
59
|
+
### Totais do sistema
|
|
60
|
+
- Usuários (lid_map): **5.502**
|
|
61
|
+
- Grupos: **116**
|
|
62
|
+
- Packs: **295**
|
|
63
|
+
- Stickers: **6.313**
|
|
64
|
+
- Mensagens registradas: **438.964**
|
|
65
|
+
|
|
66
|
+
### Tipos de mensagem mais usados (amostra de 25.000 mensagens)
|
|
67
|
+
1. `texto` - **16.530**
|
|
68
|
+
2. `figurinha` - **4.262**
|
|
69
|
+
3. `reacao` - **1.619**
|
|
70
|
+
4. `imagem` - **1.326**
|
|
71
|
+
5. `outros` - **799**
|
|
72
|
+
6. `video` - **245**
|
|
73
|
+
7. `audio` - **213**
|
|
74
|
+
8. `documento` - **6**
|
|
75
|
+
|
|
76
|
+
### Comandos disponíveis
|
|
77
|
+
- `/add @user`
|
|
78
|
+
- `/addmode`
|
|
79
|
+
- `/autorequests`
|
|
80
|
+
- `/autosticker`
|
|
81
|
+
- `/ban @user`
|
|
82
|
+
- `/captcha`
|
|
83
|
+
- `/cat`
|
|
84
|
+
- `/catimg`
|
|
85
|
+
- `/catprompt`
|
|
86
|
+
- `/catprompt reset`
|
|
87
|
+
- `/dado`
|
|
88
|
+
- `/down @user`
|
|
89
|
+
- `/farewell`
|
|
90
|
+
- `/groups`
|
|
91
|
+
- `/info`
|
|
92
|
+
- `/invite`
|
|
93
|
+
- `/join`
|
|
94
|
+
- `/leave`
|
|
95
|
+
- `/menu anime`
|
|
96
|
+
- `/menu figurinhas`
|
|
97
|
+
- `/menu ia`
|
|
98
|
+
- `/menu midia`
|
|
99
|
+
- `/menu quote`
|
|
100
|
+
- `/menu stats`
|
|
101
|
+
- `/menuadm`
|
|
102
|
+
- `/metadata`
|
|
103
|
+
- `/newgroup`
|
|
104
|
+
- `/noticias`
|
|
105
|
+
- `/nsfw`
|
|
106
|
+
- `/pack add`
|
|
107
|
+
- `/pack create "Meu Pack"`
|
|
108
|
+
- `/pack list`
|
|
109
|
+
- `/pack send`
|
|
110
|
+
- `/ping`
|
|
111
|
+
- `/play`
|
|
112
|
+
- `/playvid`
|
|
113
|
+
- `/prefix`
|
|
114
|
+
- `/premium`
|
|
115
|
+
- `/quote`
|
|
116
|
+
- `/ranking`
|
|
117
|
+
- `/rankingglobal`
|
|
118
|
+
- `/requests`
|
|
119
|
+
- `/revoke`
|
|
120
|
+
- `/s`
|
|
121
|
+
- `/semmsg`
|
|
122
|
+
- `/setdesc`
|
|
123
|
+
- `/setgroup`
|
|
124
|
+
- `/setsubject`
|
|
125
|
+
- `/st`
|
|
126
|
+
- `/stb`
|
|
127
|
+
- `/sticker`
|
|
128
|
+
- `/stickertext`
|
|
129
|
+
- `/stickertextblink`
|
|
130
|
+
- `/stickertextwhite`
|
|
131
|
+
- `/stw`
|
|
132
|
+
- `/temp`
|
|
133
|
+
- `/tiktok`
|
|
134
|
+
- `/toimg`
|
|
135
|
+
- `/up @user`
|
|
136
|
+
- `/updaterequests`
|
|
137
|
+
- `/user perfil`
|
|
138
|
+
- `/welcome`
|
|
139
|
+
<!-- README_SNAPSHOT:END -->
|
|
140
|
+
|
|
29
141
|
## Recursos principais
|
|
30
142
|
|
|
31
143
|
- Gerenciamento de grupos (admin, boas-vindas, despedida, anti-link, captcha).
|
|
@@ -132,6 +244,7 @@ Variáveis legadas foram mantidas por compatibilidade (`QUOTE_API_URL`, `WAIFU_A
|
|
|
132
244
|
- `npm run pm2:prod`: sobe com PM2 usando `ecosystem.prod.config.cjs`.
|
|
133
245
|
- `npm run deploy`: deploy automático de `public/` com cache-bust, backup, validação e reload do Nginx.
|
|
134
246
|
- `npm run deploy:dry-run`: simula o deploy sem publicar/recarregar serviços.
|
|
247
|
+
- `npm run readme:sync-snapshot`: sincroniza o bloco dinâmico do README consumindo `/api/sticker-packs/readme-markdown`.
|
|
135
248
|
- `npm run release`: release completo com versão unificada (npmjs + GitHub Packages + GitHub Release) e verificação final.
|
|
136
249
|
- `npm run release:minor`: bump `minor` + deploy + publish do package.
|
|
137
250
|
- `npm run release:major`: bump `major` + deploy + publish do package.
|
|
@@ -238,6 +351,9 @@ Variáveis do fluxo de release (git):
|
|
|
238
351
|
- `RELEASE_GIT_BRANCH` (opcional; vazio usa branch atual)
|
|
239
352
|
- `RELEASE_GIT_PRE_COMMIT_MESSAGE` (default: `chore(release): auto-commit before release`)
|
|
240
353
|
- `RELEASE_GIT_COMMIT_VERSION` (default: `1`) - commita alteração da versão após sucesso
|
|
354
|
+
- `RELEASE_README_SYNC` (default: `1`) - sincroniza bloco dinâmico do README via API antes do commit/tag
|
|
355
|
+
- `RELEASE_README_SYNC_REQUIRED` (default: `0`) - se `1`, falha o release quando a sincronização do README falhar
|
|
356
|
+
- `RELEASE_README_SYNC_COMMAND` (default: `npm run readme:sync-snapshot`) - comando customizável para sincronização
|
|
241
357
|
- `RELEASE_GIT_VERSION_COMMIT_PREFIX` (default: `chore(release): v`)
|
|
242
358
|
- `RELEASE_GIT_TAG_CREATE` (default: `1`) - cria tag `vX.Y.Z` no release
|
|
243
359
|
- `RELEASE_GIT_TAG_PUSH` (default: `1`) - envia a tag para o remoto
|
|
@@ -63,6 +63,16 @@ import {
|
|
|
63
63
|
buildViewerTagAffinity,
|
|
64
64
|
computePackSignals,
|
|
65
65
|
} from './stickerPackMarketplaceService.js';
|
|
66
|
+
import {
|
|
67
|
+
buildAdminMenu,
|
|
68
|
+
buildAiMenu,
|
|
69
|
+
buildAnimeMenu,
|
|
70
|
+
buildMediaMenu,
|
|
71
|
+
buildMenuCaption,
|
|
72
|
+
buildQuoteMenu,
|
|
73
|
+
buildStatsMenu,
|
|
74
|
+
buildStickerMenu,
|
|
75
|
+
} from '../menuModule/common.js';
|
|
66
76
|
import { getMarketplaceDriftSnapshot } from './stickerMarketplaceDriftService.js';
|
|
67
77
|
import { getStickerStorageConfig, readStickerAssetBuffer, saveStickerAssetFromBuffer } from './stickerStorageService.js';
|
|
68
78
|
import { convertToWebp } from '../stickerModule/convertToWebp.js';
|
|
@@ -193,6 +203,9 @@ const MARKETPLACE_GLOBAL_STATS_API_PATH = '/api/marketplace/stats';
|
|
|
193
203
|
const MARKETPLACE_GLOBAL_STATS_CACHE_SECONDS = clampInt(process.env.MARKETPLACE_GLOBAL_STATS_CACHE_SECONDS, 45, 30, 60);
|
|
194
204
|
const HOME_MARKETPLACE_STATS_CACHE_SECONDS = clampInt(process.env.HOME_MARKETPLACE_STATS_CACHE_SECONDS, 45, 10, 300);
|
|
195
205
|
const SYSTEM_SUMMARY_CACHE_SECONDS = clampInt(process.env.SYSTEM_SUMMARY_CACHE_SECONDS, 20, 5, 120);
|
|
206
|
+
const README_SUMMARY_CACHE_SECONDS = clampInt(process.env.README_SUMMARY_CACHE_SECONDS, 60 * 30, 60, 60 * 60 * 6);
|
|
207
|
+
const README_MESSAGE_TYPE_SAMPLE_LIMIT = clampInt(process.env.README_MESSAGE_TYPE_SAMPLE_LIMIT, 25000, 500, 250000);
|
|
208
|
+
const README_COMMAND_PREFIX = String(process.env.README_COMMAND_PREFIX || PACK_COMMAND_PREFIX).trim() || PACK_COMMAND_PREFIX;
|
|
196
209
|
const SITE_CANONICAL_HOST = String(process.env.SITE_CANONICAL_HOST || 'omnizap.shop').trim().toLowerCase() || 'omnizap.shop';
|
|
197
210
|
const SITE_CANONICAL_SCHEME = String(process.env.SITE_CANONICAL_SCHEME || 'https').trim().toLowerCase() === 'http'
|
|
198
211
|
? 'http'
|
|
@@ -283,6 +296,11 @@ const SYSTEM_SUMMARY_CACHE = {
|
|
|
283
296
|
value: null,
|
|
284
297
|
pending: null,
|
|
285
298
|
};
|
|
299
|
+
const README_SUMMARY_CACHE = {
|
|
300
|
+
expiresAt: 0,
|
|
301
|
+
value: null,
|
|
302
|
+
pending: null,
|
|
303
|
+
};
|
|
286
304
|
const SITEMAP_CACHE = {
|
|
287
305
|
expiresAt: 0,
|
|
288
306
|
xml: '',
|
|
@@ -3700,6 +3718,9 @@ const invalidateStickerCatalogDerivedCaches = () => {
|
|
|
3700
3718
|
SYSTEM_SUMMARY_CACHE.expiresAt = 0;
|
|
3701
3719
|
SYSTEM_SUMMARY_CACHE.value = null;
|
|
3702
3720
|
SYSTEM_SUMMARY_CACHE.pending = null;
|
|
3721
|
+
README_SUMMARY_CACHE.expiresAt = 0;
|
|
3722
|
+
README_SUMMARY_CACHE.value = null;
|
|
3723
|
+
README_SUMMARY_CACHE.pending = null;
|
|
3703
3724
|
};
|
|
3704
3725
|
|
|
3705
3726
|
const sendManagedMutationStatus = (req, res, status, extra = {}, statusCode = 200) => {
|
|
@@ -5736,6 +5757,256 @@ const parseMessageTypeFromRaw = (rawMessage) => {
|
|
|
5736
5757
|
}
|
|
5737
5758
|
};
|
|
5738
5759
|
|
|
5760
|
+
const formatPtBrInteger = (value) => Number(value || 0).toLocaleString('pt-BR');
|
|
5761
|
+
|
|
5762
|
+
const extractCommandsFromMenuLine = (line, commandPrefix) => {
|
|
5763
|
+
const normalizedLine = String(line || '').trim();
|
|
5764
|
+
if (!normalizedLine.startsWith('→')) return [];
|
|
5765
|
+
|
|
5766
|
+
const commandParts = normalizedLine
|
|
5767
|
+
.replace(/^→\s*/, '')
|
|
5768
|
+
.split('|')
|
|
5769
|
+
.map((part) => part.trim())
|
|
5770
|
+
.filter((part) => part.startsWith(commandPrefix));
|
|
5771
|
+
|
|
5772
|
+
return commandParts
|
|
5773
|
+
.map((part) => {
|
|
5774
|
+
const normalized = part.replace(/\s{2,}.*/, '').trim();
|
|
5775
|
+
const withoutPrefix = normalized.slice(commandPrefix.length).trim();
|
|
5776
|
+
if (!withoutPrefix) return '';
|
|
5777
|
+
|
|
5778
|
+
const tokens = withoutPrefix.split(/\s+/).filter(Boolean);
|
|
5779
|
+
const selectedTokens = [];
|
|
5780
|
+
for (const token of tokens) {
|
|
5781
|
+
if (!/^[a-z0-9_-]+$/i.test(token)) break;
|
|
5782
|
+
selectedTokens.push(token);
|
|
5783
|
+
}
|
|
5784
|
+
if (!selectedTokens.length) return '';
|
|
5785
|
+
return `${commandPrefix}${selectedTokens.join(' ')}`;
|
|
5786
|
+
})
|
|
5787
|
+
.filter(Boolean);
|
|
5788
|
+
};
|
|
5789
|
+
|
|
5790
|
+
const collectAvailableMenuCommands = (commandPrefix = README_COMMAND_PREFIX) => {
|
|
5791
|
+
const sections = [
|
|
5792
|
+
buildMenuCaption('OmniZap', commandPrefix),
|
|
5793
|
+
buildStickerMenu(commandPrefix),
|
|
5794
|
+
buildMediaMenu(commandPrefix),
|
|
5795
|
+
buildQuoteMenu(commandPrefix),
|
|
5796
|
+
buildAnimeMenu(commandPrefix),
|
|
5797
|
+
buildAiMenu(commandPrefix),
|
|
5798
|
+
buildStatsMenu(commandPrefix),
|
|
5799
|
+
buildAdminMenu(commandPrefix),
|
|
5800
|
+
];
|
|
5801
|
+
|
|
5802
|
+
const commands = new Set();
|
|
5803
|
+
for (const section of sections) {
|
|
5804
|
+
for (const line of String(section || '').split('\n')) {
|
|
5805
|
+
const extracted = extractCommandsFromMenuLine(line, commandPrefix);
|
|
5806
|
+
for (const command of extracted) {
|
|
5807
|
+
commands.add(command);
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
|
|
5812
|
+
return Array.from(commands).sort((left, right) => left.localeCompare(right, 'pt-BR'));
|
|
5813
|
+
};
|
|
5814
|
+
|
|
5815
|
+
const renderReadmeSnapshotMarkdown = ({ generatedAt, totals, topMessageTypes, commands }) => {
|
|
5816
|
+
const typeRows = topMessageTypes.length
|
|
5817
|
+
? topMessageTypes.map((entry) => `| \`${entry.type}\` | ${formatPtBrInteger(entry.total)} |`)
|
|
5818
|
+
: ['| `outros` | 0 |'];
|
|
5819
|
+
|
|
5820
|
+
const commandInline = commands.length ? commands.map((command) => `\`${command}\``).join(' · ') : 'Nenhum comando identificado no menu atual.';
|
|
5821
|
+
|
|
5822
|
+
return [
|
|
5823
|
+
'### Snapshot do Sistema',
|
|
5824
|
+
'',
|
|
5825
|
+
`> Atualizado em \`${generatedAt}\` | cache \`${README_SUMMARY_CACHE_SECONDS}s\``,
|
|
5826
|
+
'',
|
|
5827
|
+
'| Métrica | Valor |',
|
|
5828
|
+
'| --- | ---: |',
|
|
5829
|
+
`| Usuários (lid_map) | ${formatPtBrInteger(totals.total_users)} |`,
|
|
5830
|
+
`| Grupos | ${formatPtBrInteger(totals.total_groups)} |`,
|
|
5831
|
+
`| Packs | ${formatPtBrInteger(totals.total_packs)} |`,
|
|
5832
|
+
`| Stickers | ${formatPtBrInteger(totals.total_stickers)} |`,
|
|
5833
|
+
`| Mensagens registradas | ${formatPtBrInteger(totals.total_messages)} |`,
|
|
5834
|
+
'',
|
|
5835
|
+
`#### Tipos de mensagem mais usados (amostra: ${formatPtBrInteger(totals.message_types_sample_size)})`,
|
|
5836
|
+
'| Tipo | Total |',
|
|
5837
|
+
'| --- | ---: |',
|
|
5838
|
+
...typeRows,
|
|
5839
|
+
'',
|
|
5840
|
+
`<details><summary>Comandos disponíveis (${formatPtBrInteger(commands.length)})</summary>`,
|
|
5841
|
+
'',
|
|
5842
|
+
commandInline,
|
|
5843
|
+
'',
|
|
5844
|
+
'</details>',
|
|
5845
|
+
'',
|
|
5846
|
+
].join('\n');
|
|
5847
|
+
};
|
|
5848
|
+
|
|
5849
|
+
const buildReadmeSummarySnapshot = async () => {
|
|
5850
|
+
const [
|
|
5851
|
+
lidMapTotalsRows,
|
|
5852
|
+
chatsTotalsRows,
|
|
5853
|
+
groupsMetadataTotalsRows,
|
|
5854
|
+
packTotalsRows,
|
|
5855
|
+
stickerTotalsRows,
|
|
5856
|
+
messageTotalsRows,
|
|
5857
|
+
messageTypeRows,
|
|
5858
|
+
] = await Promise.all([
|
|
5859
|
+
executeQuery(`SELECT COUNT(*) AS total_users FROM ${TABLES.LID_MAP}`),
|
|
5860
|
+
executeQuery(
|
|
5861
|
+
`SELECT
|
|
5862
|
+
COUNT(*) AS total_chats,
|
|
5863
|
+
SUM(CASE WHEN id LIKE '%@g.us' THEN 1 ELSE 0 END) AS total_groups
|
|
5864
|
+
FROM ${TABLES.CHATS}`,
|
|
5865
|
+
),
|
|
5866
|
+
executeQuery(`SELECT COUNT(*) AS total_groups FROM ${TABLES.GROUPS_METADATA}`),
|
|
5867
|
+
executeQuery(`SELECT COUNT(*) AS total_packs FROM ${TABLES.STICKER_PACK} WHERE deleted_at IS NULL`),
|
|
5868
|
+
executeQuery(`SELECT COUNT(*) AS total_stickers FROM ${TABLES.STICKER_ASSET}`),
|
|
5869
|
+
executeQuery(`SELECT COUNT(*) AS total_messages FROM ${TABLES.MESSAGES}`),
|
|
5870
|
+
executeQuery(
|
|
5871
|
+
`SELECT raw_message
|
|
5872
|
+
FROM ${TABLES.MESSAGES}
|
|
5873
|
+
WHERE raw_message IS NOT NULL
|
|
5874
|
+
ORDER BY id DESC
|
|
5875
|
+
LIMIT ${README_MESSAGE_TYPE_SAMPLE_LIMIT}`,
|
|
5876
|
+
),
|
|
5877
|
+
]);
|
|
5878
|
+
|
|
5879
|
+
const lidMapTotals = lidMapTotalsRows?.[0] || {};
|
|
5880
|
+
const chatsTotals = chatsTotalsRows?.[0] || {};
|
|
5881
|
+
const groupsMetadataTotals = groupsMetadataTotalsRows?.[0] || {};
|
|
5882
|
+
const packTotals = packTotalsRows?.[0] || {};
|
|
5883
|
+
const stickerTotals = stickerTotalsRows?.[0] || {};
|
|
5884
|
+
const messageTotals = messageTotalsRows?.[0] || {};
|
|
5885
|
+
|
|
5886
|
+
const totalGroupsFromChats = Number(chatsTotals?.total_groups || 0);
|
|
5887
|
+
const totalGroupsFromMetadata = Number(groupsMetadataTotals?.total_groups || 0);
|
|
5888
|
+
const totalGroups = Math.max(totalGroupsFromChats, totalGroupsFromMetadata);
|
|
5889
|
+
const totalMessages = Number(messageTotals?.total_messages || 0);
|
|
5890
|
+
|
|
5891
|
+
const typeCounts = new Map();
|
|
5892
|
+
const sampledMessages = Array.isArray(messageTypeRows) ? messageTypeRows.length : 0;
|
|
5893
|
+
for (const row of messageTypeRows || []) {
|
|
5894
|
+
const type = parseMessageTypeFromRaw(row?.raw_message);
|
|
5895
|
+
typeCounts.set(type, (typeCounts.get(type) || 0) + 1);
|
|
5896
|
+
}
|
|
5897
|
+
const topMessageTypes = Array.from(typeCounts.entries())
|
|
5898
|
+
.map(([type, total]) => ({ type, total: Number(total || 0) }))
|
|
5899
|
+
.sort((left, right) => Number(right.total || 0) - Number(left.total || 0))
|
|
5900
|
+
.slice(0, 8);
|
|
5901
|
+
|
|
5902
|
+
const commands = collectAvailableMenuCommands(README_COMMAND_PREFIX);
|
|
5903
|
+
const generatedAt = new Date().toISOString();
|
|
5904
|
+
|
|
5905
|
+
const totals = {
|
|
5906
|
+
total_users: Number(lidMapTotals?.total_users || 0),
|
|
5907
|
+
total_groups: totalGroups,
|
|
5908
|
+
total_groups_from_chats: totalGroupsFromChats,
|
|
5909
|
+
total_groups_from_metadata: totalGroupsFromMetadata,
|
|
5910
|
+
total_chats: Number(chatsTotals?.total_chats || 0),
|
|
5911
|
+
total_packs: Number(packTotals?.total_packs || 0),
|
|
5912
|
+
total_stickers: Number(stickerTotals?.total_stickers || 0),
|
|
5913
|
+
total_messages: totalMessages,
|
|
5914
|
+
message_types_sample_size: sampledMessages,
|
|
5915
|
+
message_types_total_coverage_percent: totalMessages > 0 ? Number(((sampledMessages / totalMessages) * 100).toFixed(2)) : 0,
|
|
5916
|
+
};
|
|
5917
|
+
|
|
5918
|
+
const markdown = renderReadmeSnapshotMarkdown({
|
|
5919
|
+
generatedAt,
|
|
5920
|
+
totals,
|
|
5921
|
+
topMessageTypes,
|
|
5922
|
+
commands,
|
|
5923
|
+
});
|
|
5924
|
+
|
|
5925
|
+
return {
|
|
5926
|
+
data: {
|
|
5927
|
+
generated_at: generatedAt,
|
|
5928
|
+
cache_seconds: README_SUMMARY_CACHE_SECONDS,
|
|
5929
|
+
command_prefix: README_COMMAND_PREFIX,
|
|
5930
|
+
totals,
|
|
5931
|
+
top_message_types: topMessageTypes,
|
|
5932
|
+
commands,
|
|
5933
|
+
markdown,
|
|
5934
|
+
},
|
|
5935
|
+
};
|
|
5936
|
+
};
|
|
5937
|
+
|
|
5938
|
+
const getReadmeSummaryCached = async () => {
|
|
5939
|
+
const now = Date.now();
|
|
5940
|
+
const hasValue = Boolean(README_SUMMARY_CACHE.value);
|
|
5941
|
+
|
|
5942
|
+
if (hasValue && now < README_SUMMARY_CACHE.expiresAt) {
|
|
5943
|
+
return README_SUMMARY_CACHE.value;
|
|
5944
|
+
}
|
|
5945
|
+
|
|
5946
|
+
if (!README_SUMMARY_CACHE.pending) {
|
|
5947
|
+
README_SUMMARY_CACHE.pending = withTimeout(buildReadmeSummarySnapshot(), 7000)
|
|
5948
|
+
.then((payload) => {
|
|
5949
|
+
README_SUMMARY_CACHE.value = payload;
|
|
5950
|
+
README_SUMMARY_CACHE.expiresAt = Date.now() + README_SUMMARY_CACHE_SECONDS * 1000;
|
|
5951
|
+
return payload;
|
|
5952
|
+
})
|
|
5953
|
+
.finally(() => {
|
|
5954
|
+
README_SUMMARY_CACHE.pending = null;
|
|
5955
|
+
});
|
|
5956
|
+
}
|
|
5957
|
+
|
|
5958
|
+
if (hasValue) return README_SUMMARY_CACHE.value;
|
|
5959
|
+
return README_SUMMARY_CACHE.pending;
|
|
5960
|
+
};
|
|
5961
|
+
|
|
5962
|
+
const handleReadmeSummaryRequest = async (req, res) => {
|
|
5963
|
+
try {
|
|
5964
|
+
const payload = await getReadmeSummaryCached();
|
|
5965
|
+
sendJson(req, res, 200, payload);
|
|
5966
|
+
} catch (error) {
|
|
5967
|
+
logger.warn('Falha ao montar resumo markdown para README.', {
|
|
5968
|
+
action: 'readme_summary_error',
|
|
5969
|
+
error: error?.message,
|
|
5970
|
+
});
|
|
5971
|
+
if (README_SUMMARY_CACHE.value) {
|
|
5972
|
+
sendJson(req, res, 200, {
|
|
5973
|
+
...README_SUMMARY_CACHE.value,
|
|
5974
|
+
meta: {
|
|
5975
|
+
stale: true,
|
|
5976
|
+
error: error?.message || 'fallback_cache',
|
|
5977
|
+
},
|
|
5978
|
+
});
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
sendJson(req, res, 503, { error: 'Resumo markdown indisponível no momento.' });
|
|
5982
|
+
}
|
|
5983
|
+
};
|
|
5984
|
+
|
|
5985
|
+
const handleReadmeMarkdownRequest = async (req, res) => {
|
|
5986
|
+
try {
|
|
5987
|
+
const payload = await getReadmeSummaryCached();
|
|
5988
|
+
const markdown = String(payload?.data?.markdown || '').trim();
|
|
5989
|
+
res.setHeader('X-Robots-Tag', 'noindex, nofollow');
|
|
5990
|
+
res.setHeader('Cache-Control', `public, max-age=${Math.min(README_SUMMARY_CACHE_SECONDS, 300)}`);
|
|
5991
|
+
res.setHeader('X-Cache-Seconds', String(README_SUMMARY_CACHE_SECONDS));
|
|
5992
|
+
sendText(req, res, 200, markdown ? `${markdown}\n` : '', 'text/markdown; charset=utf-8');
|
|
5993
|
+
} catch (error) {
|
|
5994
|
+
logger.warn('Falha ao renderizar markdown para README.', {
|
|
5995
|
+
action: 'readme_markdown_error',
|
|
5996
|
+
error: error?.message,
|
|
5997
|
+
});
|
|
5998
|
+
if (README_SUMMARY_CACHE.value) {
|
|
5999
|
+
const markdown = String(README_SUMMARY_CACHE.value?.data?.markdown || '').trim();
|
|
6000
|
+
res.setHeader('X-Robots-Tag', 'noindex, nofollow');
|
|
6001
|
+
res.setHeader('Cache-Control', `public, max-age=${Math.min(README_SUMMARY_CACHE_SECONDS, 300)}`);
|
|
6002
|
+
res.setHeader('X-Cache-Seconds', String(README_SUMMARY_CACHE_SECONDS));
|
|
6003
|
+
sendText(req, res, 200, markdown ? `${markdown}\n` : '', 'text/markdown; charset=utf-8');
|
|
6004
|
+
return;
|
|
6005
|
+
}
|
|
6006
|
+
sendText(req, res, 503, 'Resumo markdown indisponivel no momento.\n', 'text/plain; charset=utf-8');
|
|
6007
|
+
}
|
|
6008
|
+
};
|
|
6009
|
+
|
|
5739
6010
|
const resolveBotUserCandidates = (activeSocket) => {
|
|
5740
6011
|
const candidates = new Set();
|
|
5741
6012
|
const botJidFromSocket = resolveBotJid(activeSocket?.user?.id);
|
|
@@ -7155,6 +7426,24 @@ const handleCatalogApiRequest = async (req, res, pathname, url) => {
|
|
|
7155
7426
|
return true;
|
|
7156
7427
|
}
|
|
7157
7428
|
|
|
7429
|
+
if (segments.length === 1 && segments[0] === 'readme-summary') {
|
|
7430
|
+
if (!['GET', 'HEAD'].includes(req.method || '')) {
|
|
7431
|
+
sendJson(req, res, 405, { error: 'Metodo nao permitido.' });
|
|
7432
|
+
return true;
|
|
7433
|
+
}
|
|
7434
|
+
await handleReadmeSummaryRequest(req, res);
|
|
7435
|
+
return true;
|
|
7436
|
+
}
|
|
7437
|
+
|
|
7438
|
+
if (segments.length === 1 && segments[0] === 'readme-markdown') {
|
|
7439
|
+
if (!['GET', 'HEAD'].includes(req.method || '')) {
|
|
7440
|
+
sendJson(req, res, 405, { error: 'Metodo nao permitido.' });
|
|
7441
|
+
return true;
|
|
7442
|
+
}
|
|
7443
|
+
await handleReadmeMarkdownRequest(req, res);
|
|
7444
|
+
return true;
|
|
7445
|
+
}
|
|
7446
|
+
|
|
7158
7447
|
if (segments.length === 1 && segments[0] === 'support') {
|
|
7159
7448
|
if (!['GET', 'HEAD'].includes(req.method || '')) {
|
|
7160
7449
|
sendJson(req, res, 405, { error: 'Metodo nao permitido.' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaikybrofc/omnizap-system",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Sistema profissional de automação WhatsApp com tecnologia Baileys",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"pm2:prod": "pm2 start ecosystem.prod.config.cjs",
|
|
59
59
|
"deploy": "bash ./scripts/deploy.sh",
|
|
60
60
|
"deploy:dry-run": "DEPLOY_DRY_RUN=1 bash ./scripts/deploy.sh",
|
|
61
|
+
"readme:sync-snapshot": "node ./scripts/sync-readme-snapshot.mjs",
|
|
61
62
|
"release": "bash ./scripts/release.sh",
|
|
62
63
|
"release:minor": "RELEASE_TYPE=minor bash ./scripts/release.sh",
|
|
63
64
|
"release:major": "RELEASE_TYPE=major bash ./scripts/release.sh",
|
package/scripts/release.sh
CHANGED
|
@@ -28,6 +28,9 @@ RELEASE_GITHUB_RELEASE_INCLUDE_CHANGED_FILES="${RELEASE_GITHUB_RELEASE_INCLUDE_C
|
|
|
28
28
|
RELEASE_GITHUB_RELEASE_MAX_FILES="${RELEASE_GITHUB_RELEASE_MAX_FILES:-300}"
|
|
29
29
|
RELEASE_REQUIRE_DUAL_PUBLISH="${RELEASE_REQUIRE_DUAL_PUBLISH:-1}"
|
|
30
30
|
RELEASE_VERIFY_UNIFIED_VERSION="${RELEASE_VERIFY_UNIFIED_VERSION:-1}"
|
|
31
|
+
RELEASE_README_SYNC="${RELEASE_README_SYNC:-1}"
|
|
32
|
+
RELEASE_README_SYNC_REQUIRED="${RELEASE_README_SYNC_REQUIRED:-0}"
|
|
33
|
+
RELEASE_README_SYNC_COMMAND="${RELEASE_README_SYNC_COMMAND:-npm run readme:sync-snapshot}"
|
|
31
34
|
RELEASE_VERIFY_PRIMARY_REGISTRY="${RELEASE_VERIFY_PRIMARY_REGISTRY:-${DEPLOY_PACKAGE_REGISTRY:-https://npm.pkg.github.com}}"
|
|
32
35
|
RELEASE_VERIFY_SECONDARY_REGISTRY="${RELEASE_VERIFY_SECONDARY_REGISTRY:-${DEPLOY_PACKAGE_SECONDARY_REGISTRY:-https://registry.npmjs.org}}"
|
|
33
36
|
RELEASE_VERIFY_PRIMARY_TOKEN_KEYS="${RELEASE_VERIFY_PRIMARY_TOKEN_KEYS:-DEPLOY_PACKAGE_TOKEN,DEPLOY_GITHUB_TOKEN,GITHUB_TOKEN,GH_TOKEN,NPM_TOKEN,NODE_AUTH_TOKEN}"
|
|
@@ -439,6 +442,20 @@ if ! (
|
|
|
439
442
|
exit 1
|
|
440
443
|
fi
|
|
441
444
|
|
|
445
|
+
if [ "$RELEASE_README_SYNC" = "1" ]; then
|
|
446
|
+
log "Sincronizando bloco dinâmico do README"
|
|
447
|
+
if ! (
|
|
448
|
+
cd "$PROJECT_ROOT" &&
|
|
449
|
+
bash -lc "$RELEASE_README_SYNC_COMMAND"
|
|
450
|
+
); then
|
|
451
|
+
if [ "$RELEASE_README_SYNC_REQUIRED" = "1" ]; then
|
|
452
|
+
printf '[release] Falha ao sincronizar README e RELEASE_README_SYNC_REQUIRED=1.\n' >&2
|
|
453
|
+
exit 1
|
|
454
|
+
fi
|
|
455
|
+
log "Falha ao sincronizar README. Continuando release (RELEASE_README_SYNC_REQUIRED=0)."
|
|
456
|
+
fi
|
|
457
|
+
fi
|
|
458
|
+
|
|
442
459
|
if [ "$RELEASE_GIT_COMMIT_VERSION" = "1" ]; then
|
|
443
460
|
commit_and_push_if_dirty "${RELEASE_GIT_VERSION_COMMIT_PREFIX}${new_version}"
|
|
444
461
|
fi
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
|
|
8
|
+
dotenv.config({ path: '.env' });
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
13
|
+
|
|
14
|
+
const START_MARKER = '<!-- README_SNAPSHOT:START -->';
|
|
15
|
+
const END_MARKER = '<!-- README_SNAPSHOT:END -->';
|
|
16
|
+
|
|
17
|
+
const readmePath = path.resolve(projectRoot, process.env.README_SNAPSHOT_TARGET_PATH || 'README.md');
|
|
18
|
+
const siteOrigin = String(process.env.SITE_ORIGIN || 'https://omnizap.shop').trim().replace(/\/+$/, '');
|
|
19
|
+
const sourceUrl = String(process.env.README_SNAPSHOT_SOURCE_URL || `${siteOrigin}/api/sticker-packs/readme-markdown`).trim();
|
|
20
|
+
const timeoutMs = Math.max(1000, Number(process.env.README_SNAPSHOT_TIMEOUT_MS) || 15000);
|
|
21
|
+
|
|
22
|
+
const escapeRegExp = (value) => String(value || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
23
|
+
|
|
24
|
+
const fetchWithTimeout = async (url, timeout) => {
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch(url, {
|
|
29
|
+
method: 'GET',
|
|
30
|
+
headers: { 'User-Agent': 'omnizap-readme-sync/1.0' },
|
|
31
|
+
signal: controller.signal,
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`HTTP ${response.status} ao buscar snapshot`);
|
|
35
|
+
}
|
|
36
|
+
const content = String(await response.text()).trim();
|
|
37
|
+
if (!content) {
|
|
38
|
+
throw new Error('Snapshot markdown vazio');
|
|
39
|
+
}
|
|
40
|
+
return content;
|
|
41
|
+
} finally {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const syncReadmeSnapshot = async () => {
|
|
47
|
+
const markdown = await fetchWithTimeout(sourceUrl, timeoutMs);
|
|
48
|
+
const readme = await fs.readFile(readmePath, 'utf8');
|
|
49
|
+
|
|
50
|
+
const blockRegex = new RegExp(`${escapeRegExp(START_MARKER)}[\\s\\S]*?${escapeRegExp(END_MARKER)}`, 'm');
|
|
51
|
+
if (!blockRegex.test(readme)) {
|
|
52
|
+
throw new Error(`Marcadores não encontrados em ${path.relative(projectRoot, readmePath)} (${START_MARKER} ... ${END_MARKER})`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const replacement = `${START_MARKER}\n${markdown}\n${END_MARKER}`;
|
|
56
|
+
const nextReadme = readme.replace(blockRegex, replacement);
|
|
57
|
+
|
|
58
|
+
if (nextReadme === readme) {
|
|
59
|
+
console.log('[readme-sync] Snapshot já está atualizado.');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await fs.writeFile(readmePath, nextReadme, 'utf8');
|
|
64
|
+
console.log(`[readme-sync] README atualizado com snapshot de ${sourceUrl}`);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
syncReadmeSnapshot().catch((error) => {
|
|
68
|
+
console.error(`[readme-sync] Falha: ${error?.message || error}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
|
package/RELEASE-v2.1.2.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# v2.1.3
|
|
2
|
-
|
|
3
|
-
Atualiza a versão para `2.1.3` e consolida o ciclo de entregas desde a `v2.1.2`.
|
|
4
|
-
|
|
5
|
-
Período do ciclo: `2026-02-26` a `2026-02-27`
|
|
6
|
-
Comparação base: `v2.1.2..HEAD`
|
|
7
|
-
Escopo: **39 commits** e **71 arquivos alterados**
|
|
8
|
-
|
|
9
|
-
## Destaques
|
|
10
|
-
|
|
11
|
-
- Plataforma web de stickers expandida de ponta a ponta: criação de packs no browser, upload de mídia (imagem/vídeo), fluxo de publicação e dashboard de criador.
|
|
12
|
-
- Marketplace e descoberta evoluídos: categorias, sorting, ranking de criadores, métricas globais, cards/UX mobile e melhorias de navegação.
|
|
13
|
-
- SEO e indexação: `sitemap`, ajustes de páginas SEO por pack e controles de exposição NSFW no catálogo.
|
|
14
|
-
- Classificação inteligente e curadoria automática reforçadas: pipeline CLIP/MobileCLIP/OpenCLIP, fila de reprocessamento, clustering semântico e otimizações do auto-pack por tags.
|
|
15
|
-
- Admin panel consolidado com moderação: gestão de bans e role de moderador, com persistência de sessão Google Web.
|
|
16
|
-
- Backend mais robusto: limpeza segura de órfãos, proteção de mutações, idempotência em uploads/publicação e novos caches para stats/sumários.
|
|
17
|
-
- Runtime e resiliência: reconexão de socket aprimorada, tratamento de rejeições transitórias e ajustes de agendamento em background.
|
|
18
|
-
- Banco e deploy: novas migrations para classificação/engajamento/workers/admin, e ajuste no nome do banco com sufixo por ambiente.
|
|
19
|
-
|
|
20
|
-
## Banco de dados e migrations
|
|
21
|
-
|
|
22
|
-
Este ciclo adiciona migrations estruturais importantes:
|
|
23
|
-
|
|
24
|
-
- `20260226_0011_sticker_asset_classification.sql`
|
|
25
|
-
- `20260226_0012_sticker_pack_engagement.sql`
|
|
26
|
-
- `20260226_0013_sticker_marketplace_intelligence.sql`
|
|
27
|
-
- `20260226_0014_sticker_pack_publish_flow.sql`
|
|
28
|
-
- `20260226_0014_sticker_worker_queues.sql`
|
|
29
|
-
- `20260226_0015_sticker_auto_pack_curation_integrity.sql`
|
|
30
|
-
- `20260226_0016_sticker_web_google_auth_persistence.sql`
|
|
31
|
-
- `20260226_0017_sticker_web_admin_ban.sql`
|
|
32
|
-
- `20260226_0018_sticker_web_admin_moderator.sql`
|
|
33
|
-
- `20260227_0019_sticker_classification_v2_signals.sql`
|
|
34
|
-
- `20260227_0020_semantic_theme_clusters.sql`
|
|
35
|
-
|
|
36
|
-
## Commits incluídos (v2.1.2..HEAD)
|
|
37
|
-
|
|
38
|
-
- `b46a33f` Improve background scheduling, add cached stats and UI/status enhancements
|
|
39
|
-
- `c43decb` Enable semantic clustering and improve auto-pack scheduler
|
|
40
|
-
- `91f2950` Enhance socket reconnection and prioritize complete sticker packs
|
|
41
|
-
- `64f8e73` Improve classification and auto-pack optimization
|
|
42
|
-
- `d11d78b` Appends environment-based suffix to DB name
|
|
43
|
-
- `b8ede5f` Add advanced auto-pack optimization and CLIP classification pipeline
|
|
44
|
-
- `32e169f` Add SEO, sitemap and NSFW gating to sticker catalog
|
|
45
|
-
- `7271a9b` Adds web links for sticker packs and sets auto-packs to unlisted
|
|
46
|
-
- `7cd1151` Ignore transient rejections and force process exit
|
|
47
|
-
- `5072a0e` Add admin moderator role and revamp admin panel UI
|
|
48
|
-
- `84c08dd` Add admin panel and ban management
|
|
49
|
-
- `27b387b` Persist Google web sessions and add client-side Google auth cache
|
|
50
|
-
- `6c07feb` Improve mobile category-chip touch and scroll behavior
|
|
51
|
-
- `c3ca0ea` Improve auto-pack-by-tags curation and pack metadata
|
|
52
|
-
- `3f6c258` Fix mobile discover tabs behavior
|
|
53
|
-
- `831c279` Adds marketplace global stats API and panel
|
|
54
|
-
- `08fdafe` Add catalog sorting, creators ranking and pack UI improvements
|
|
55
|
-
- `082ba82` Add safe pack management, orphan asset cleanup, and UX/network robustness
|
|
56
|
-
- `d928227` Improve marketplace discovery UX
|
|
57
|
-
- `97fe5f4` Bumps stickers app asset version
|
|
58
|
-
- `d2d1843` Adds sticker upload API and improves creator dashboard UX
|
|
59
|
-
- `be5506b` Adds creator pack management endpoints and dashboard UI
|
|
60
|
-
- `589f671` Add creator profile with Google sign-in
|
|
61
|
-
- `122c1e8` Switches CLIP classifier to MobileCLIP/OpenCLIP
|
|
62
|
-
- `7385d30` Allow spaces in pack names and add tag typeahead
|
|
63
|
-
- `2c5589c` Stops trimming input on field change
|
|
64
|
-
- `067b6f9` Add web pack publish flow with Google auth and idempotent uploads
|
|
65
|
-
- `6953768` Allow image/video uploads with WebP conversion
|
|
66
|
-
- `b33c1b8` Add web pack creation and sticker upload UI/API
|
|
67
|
-
- `2b23441` Add reprocess queue, cohesion scoring and ranking
|
|
68
|
-
- `6342d2b` Add marketplace stats endpoint and homepage preview
|
|
69
|
-
- `55cf8b7` Batch-scans and deduplicates catalog listings
|
|
70
|
-
- `7819fe6` Adds automatic sticker pack curation by tags
|
|
71
|
-
- `8ed61bc` Improve API docs and dynamic sidebar/UI for stickers
|
|
72
|
-
- `d0fd86d` Adds support contact API and enhances sticker catalog UI
|
|
73
|
-
- `c5cb106` Improves pack cards and mobile header UX
|
|
74
|
-
- `3da0375` Adds categories filtering and pack engagement tracking
|
|
75
|
-
- `d9bb604` Adds CLIP-based sticker classification
|
|
76
|
-
- `fffc205` Enhances catalog and API docs UI
|
|
77
|
-
|
|
78
|
-
## Notas de atualização
|
|
79
|
-
|
|
80
|
-
- `package.json` atualizado para `2.1.3`.
|
|
81
|
-
- `README.md` atualizado para refletir a versão atual.
|
|
82
|
-
- Recomendado reiniciar o processo de produção após deploy (`pm2 restart ... --update-env`).
|
|
83
|
-
- Atenção para comportamento de nome de banco por ambiente (`DB_NAME` com sufixo `_dev`/`_prod` quando aplicável).
|