@omnizap-system/omnizap 2.5.12
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/.clusterfuzzlite/Dockerfile +10 -0
- package/.env.example +907 -0
- package/.github/codeql/codeql-config.yml +10 -0
- package/.github/dependabot.yml +35 -0
- package/.github/workflows/ci.yml +73 -0
- package/.github/workflows/codeql.yml +106 -0
- package/.github/workflows/db-migration-check.yml +98 -0
- package/.github/workflows/dependency-review.yml +22 -0
- package/.github/workflows/deploy.yml +95 -0
- package/.github/workflows/release.yml +106 -0
- package/.github/workflows/security-attest-provenance.yml +51 -0
- package/.github/workflows/security-gitleaks.yml +34 -0
- package/.github/workflows/security-runner-hardening.yml +31 -0
- package/.github/workflows/security-scorecard.yml +44 -0
- package/.github/workflows/security-zap-baseline.yml +44 -0
- package/.github/workflows/security-zap-full-scan.yml +43 -0
- package/.github/workflows/security-zizmor.yml +36 -0
- package/.github/workflows/wiki-sync.yml +44 -0
- package/.gitleaks.toml +15 -0
- package/.prettierrc +34 -0
- package/CODE_OF_CONDUCT.md +114 -0
- package/LICENSE +56 -0
- package/README.md +110 -0
- package/SECURITY.md +110 -0
- package/app/config/index.js +4 -0
- package/app/configParts/adminIdentity.js +92 -0
- package/app/configParts/baileysConfig.js +1818 -0
- package/app/configParts/groupUtils.js +692 -0
- package/app/configParts/loggerConfig.js +394 -0
- package/app/configParts/messagePersistenceService.js +305 -0
- package/app/connection/baileysCompatibility.test.js +40 -0
- package/app/connection/baileysDbAuthState.js +344 -0
- package/app/connection/socketController.js +2243 -0
- package/app/controllers/messageController.js +7 -0
- package/app/controllers/messagePipeline/commandMiddleware.js +146 -0
- package/app/controllers/messagePipeline/conversationMiddleware.js +183 -0
- package/app/controllers/messagePipeline/messagePipelineMiddlewares.test.js +522 -0
- package/app/controllers/messagePipeline/postProcessingMiddleware.js +41 -0
- package/app/controllers/messagePipeline/preProcessingMiddlewares.js +166 -0
- package/app/controllers/messageProcessingPipeline.js +699 -0
- package/app/modules/adminModule/AGENT.md +4056 -0
- package/app/modules/adminModule/adminAiHelpService.js +56 -0
- package/app/modules/adminModule/adminConfigRuntime.js +177 -0
- package/app/modules/adminModule/commandConfig.json +7122 -0
- package/app/modules/adminModule/groupCommandHandlers.js +1823 -0
- package/app/modules/adminModule/groupCommandHandlers.test.js +350 -0
- package/app/modules/adminModule/groupEventHandlers.js +399 -0
- package/app/modules/aiModule/AGENT.md +547 -0
- package/app/modules/aiModule/aiAiHelpService.js +14 -0
- package/app/modules/aiModule/aiConfigRuntime.js +135 -0
- package/app/modules/aiModule/catCommand.js +967 -0
- package/app/modules/aiModule/commandConfig.json +981 -0
- package/app/modules/analyticsModule/messageAnalysisEventRepository.js +83 -0
- package/app/modules/gameModule/AGENT.md +196 -0
- package/app/modules/gameModule/commandConfig.json +366 -0
- package/app/modules/gameModule/diceCommand.js +42 -0
- package/app/modules/gameModule/gameAiHelpService.js +14 -0
- package/app/modules/gameModule/gameConfigRuntime.js +68 -0
- package/app/modules/menuModule/AGENT.md +205 -0
- package/app/modules/menuModule/commandConfig.json +366 -0
- package/app/modules/menuModule/common.js +316 -0
- package/app/modules/menuModule/menuAiHelpService.js +14 -0
- package/app/modules/menuModule/menuConfigRuntime.js +68 -0
- package/app/modules/menuModule/menus.js +66 -0
- package/app/modules/playModule/AGENT.md +321 -0
- package/app/modules/playModule/commandConfig.json +584 -0
- package/app/modules/playModule/playAiHelpService.js +14 -0
- package/app/modules/playModule/playCommand.js +1417 -0
- package/app/modules/playModule/playConfigRuntime.js +68 -0
- package/app/modules/quoteModule/AGENT.md +199 -0
- package/app/modules/quoteModule/commandConfig.json +366 -0
- package/app/modules/quoteModule/quoteAiHelpService.js +14 -0
- package/app/modules/quoteModule/quoteCommand.js +842 -0
- package/app/modules/quoteModule/quoteConfigRuntime.js +68 -0
- package/app/modules/rpgPokemonModule/AGENT.md +229 -0
- package/app/modules/rpgPokemonModule/commandConfig.json +386 -0
- package/app/modules/rpgPokemonModule/rpgBattleCanvasRenderer.js +795 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.js +2110 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.test.js +770 -0
- package/app/modules/rpgPokemonModule/rpgEvolutionUtils.js +22 -0
- package/app/modules/rpgPokemonModule/rpgPokemonAiHelpService.js +14 -0
- package/app/modules/rpgPokemonModule/rpgPokemonCommand.js +174 -0
- package/app/modules/rpgPokemonModule/rpgPokemonConfigRuntime.js +68 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.js +192 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.test.js +93 -0
- package/app/modules/rpgPokemonModule/rpgPokemonEvolution.test.js +46 -0
- package/app/modules/rpgPokemonModule/rpgPokemonMessages.js +746 -0
- package/app/modules/rpgPokemonModule/rpgPokemonRepository.js +1847 -0
- package/app/modules/rpgPokemonModule/rpgPokemonService.js +6839 -0
- package/app/modules/rpgPokemonModule/rpgProfileCanvasRenderer.js +354 -0
- package/app/modules/statsModule/AGENT.md +320 -0
- package/app/modules/statsModule/commandConfig.json +540 -0
- package/app/modules/statsModule/globalRankingCommand.js +64 -0
- package/app/modules/statsModule/rankingCommand.js +41 -0
- package/app/modules/statsModule/rankingCommon.js +1305 -0
- package/app/modules/statsModule/statsAiHelpService.js +14 -0
- package/app/modules/statsModule/statsConfigRuntime.js +68 -0
- package/app/modules/stickerModule/AGENT.md +692 -0
- package/app/modules/stickerModule/addStickerMetadata.js +239 -0
- package/app/modules/stickerModule/commandConfig.json +1216 -0
- package/app/modules/stickerModule/convertToWebp.js +367 -0
- package/app/modules/stickerModule/stickerAiHelpService.js +14 -0
- package/app/modules/stickerModule/stickerCommand.js +446 -0
- package/app/modules/stickerModule/stickerConfigRuntime.js +68 -0
- package/app/modules/stickerModule/stickerConvertCommand.js +159 -0
- package/app/modules/stickerModule/stickerTextCommand.js +653 -0
- package/app/modules/stickerPackModule/AGENT.md +215 -0
- package/app/modules/stickerPackModule/autoPackCollectorRuntime.js +20 -0
- package/app/modules/stickerPackModule/autoPackCollectorService.js +357 -0
- package/app/modules/stickerPackModule/commandConfig.json +387 -0
- package/app/modules/stickerPackModule/domainEventOutboxRepository.js +227 -0
- package/app/modules/stickerPackModule/domainEvents.js +52 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.js +429 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.test.js +75 -0
- package/app/modules/stickerPackModule/semanticThemeClusterService.js +544 -0
- package/app/modules/stickerPackModule/stickerAssetClassificationRepository.js +400 -0
- package/app/modules/stickerPackModule/stickerAssetRepository.js +400 -0
- package/app/modules/stickerPackModule/stickerAssetReprocessQueueRepository.js +175 -0
- package/app/modules/stickerPackModule/stickerAutoPackByTagsRuntime.js +3702 -0
- package/app/modules/stickerPackModule/stickerClassificationBackgroundRuntime.js +559 -0
- package/app/modules/stickerPackModule/stickerClassificationService.js +557 -0
- package/app/modules/stickerPackModule/stickerDedicatedTaskWorkerRuntime.js +249 -0
- package/app/modules/stickerPackModule/stickerDomainEventBus.js +65 -0
- package/app/modules/stickerPackModule/stickerDomainEventConsumerRuntime.js +208 -0
- package/app/modules/stickerPackModule/stickerMarketplaceDriftService.js +99 -0
- package/app/modules/stickerPackModule/stickerObjectStorageService.js +285 -0
- package/app/modules/stickerPackModule/stickerPackAiHelpService.js +14 -0
- package/app/modules/stickerPackModule/stickerPackCommandHandlers.js +1148 -0
- package/app/modules/stickerPackModule/stickerPackConfigRuntime.js +68 -0
- package/app/modules/stickerPackModule/stickerPackEngagementRepository.js +152 -0
- package/app/modules/stickerPackModule/stickerPackErrors.js +30 -0
- package/app/modules/stickerPackModule/stickerPackInteractionEventRepository.js +101 -0
- package/app/modules/stickerPackModule/stickerPackItemRepository.js +432 -0
- package/app/modules/stickerPackModule/stickerPackMarketplaceService.js +313 -0
- package/app/modules/stickerPackModule/stickerPackMessageService.js +268 -0
- package/app/modules/stickerPackModule/stickerPackRepository.js +450 -0
- package/app/modules/stickerPackModule/stickerPackScoreSnapshotRepository.js +179 -0
- package/app/modules/stickerPackModule/stickerPackScoreSnapshotRuntime.js +271 -0
- package/app/modules/stickerPackModule/stickerPackService.js +733 -0
- package/app/modules/stickerPackModule/stickerPackServiceRuntime.js +32 -0
- package/app/modules/stickerPackModule/stickerPackUtils.js +107 -0
- package/app/modules/stickerPackModule/stickerStorageService.js +559 -0
- package/app/modules/stickerPackModule/stickerWorkerPipelineRuntime.js +242 -0
- package/app/modules/stickerPackModule/stickerWorkerTaskQueueRepository.js +242 -0
- package/app/modules/systemMetricsModule/AGENT.md +193 -0
- package/app/modules/systemMetricsModule/commandConfig.json +344 -0
- package/app/modules/systemMetricsModule/pingCommand.js +399 -0
- package/app/modules/systemMetricsModule/systemMetricsAiHelpService.js +14 -0
- package/app/modules/systemMetricsModule/systemMetricsConfigRuntime.js +68 -0
- package/app/modules/tiktokModule/AGENT.md +196 -0
- package/app/modules/tiktokModule/commandConfig.json +366 -0
- package/app/modules/tiktokModule/tiktokAiHelpService.js +14 -0
- package/app/modules/tiktokModule/tiktokCommand.js +716 -0
- package/app/modules/tiktokModule/tiktokConfigRuntime.js +68 -0
- package/app/modules/userModule/AGENT.md +200 -0
- package/app/modules/userModule/commandConfig.json +386 -0
- package/app/modules/userModule/userAiHelpService.js +14 -0
- package/app/modules/userModule/userCommand.js +1155 -0
- package/app/modules/userModule/userConfigRuntime.js +68 -0
- package/app/modules/waifuPicsModule/AGENT.md +431 -0
- package/app/modules/waifuPicsModule/commandConfig.json +780 -0
- package/app/modules/waifuPicsModule/waifuPicsAiHelpService.js +14 -0
- package/app/modules/waifuPicsModule/waifuPicsCommand.js +586 -0
- package/app/modules/waifuPicsModule/waifuPicsConfigRuntime.js +68 -0
- package/app/observability/metrics.js +766 -0
- package/app/services/ai/aiHelpResponseCacheRepository.js +280 -0
- package/app/services/ai/aiLearningRepository.js +400 -0
- package/app/services/ai/commandConfigEnrichmentRepository.js +769 -0
- package/app/services/ai/commandConfigEnrichmentService.js +452 -0
- package/app/services/ai/commandConfigValidationService.js +443 -0
- package/app/services/ai/commandToolBuilderService.js +192 -0
- package/app/services/ai/conversationRouterService.js +516 -0
- package/app/services/ai/geminiService.js +115 -0
- package/app/services/ai/geminiService.test.js +87 -0
- package/app/services/ai/globalModuleAiHelpService.js +1412 -0
- package/app/services/ai/globalToolCallingService.js +203 -0
- package/app/services/ai/messageCommandExecutionService.js +391 -0
- package/app/services/ai/moduleAiHelpCoreService.js +1099 -0
- package/app/services/ai/moduleAiHelpWrapperFactory.js +65 -0
- package/app/services/ai/moduleCommandConfigRuntimeService.js +113 -0
- package/app/services/ai/moduleToolExecutorService.js +464 -0
- package/app/services/ai/moduleToolRegistryService.js +178 -0
- package/app/services/ai/toolCandidateSelectorService.js +781 -0
- package/app/services/auth/googleWebLinkService.js +80 -0
- package/app/services/auth/whatsappLoginLinkService.js +230 -0
- package/app/services/external/pokeApiService.js +398 -0
- package/app/services/group/groupMetadataService.js +311 -0
- package/app/services/infra/dbWriteQueue.js +874 -0
- package/app/services/infra/featureFlagService.js +131 -0
- package/app/services/infra/queueUtils.js +55 -0
- package/app/services/messaging/captchaService.js +491 -0
- package/app/services/messaging/messagePersistenceService.js +1 -0
- package/app/services/messaging/newsBroadcastService.js +347 -0
- package/app/services/sticker/stickerFocusService.js +347 -0
- package/app/services/sticker/stickerFocusService.test.js +43 -0
- package/app/store/aiPromptStore.js +38 -0
- package/app/store/conversationSessionStore.js +131 -0
- package/app/store/groupConfigStore.js +58 -0
- package/app/store/premiumUserStore.js +54 -0
- package/app/utils/antiLink/antiLinkModule.js +700 -0
- package/app/utils/http/getImageBufferModule.js +18 -0
- package/app/utils/json/jsonSanitizer.js +113 -0
- package/app/utils/json/jsonSanitizer.test.js +40 -0
- package/app/utils/systemMetrics/systemMetricsModule.js +88 -0
- package/app/workers/aiLearningWorker.js +605 -0
- package/app/workers/commandConfigEnrichmentWorker.js +242 -0
- package/database/index.js +2075 -0
- package/database/init.js +151 -0
- package/database/migrations/.gitkeep +0 -0
- package/database/migrations/20260307_d0_hardening_down.sql +64 -0
- package/database/migrations/20260307_d0_hardening_up.sql +79 -0
- package/database/migrations/20260307_d1_terms_acceptance_down.sql +11 -0
- package/database/migrations/20260307_d1_terms_acceptance_up.sql +37 -0
- package/database/migrations/20260307_d2_auth_hardening_down.sql +75 -0
- package/database/migrations/20260307_d2_auth_hardening_up.sql +100 -0
- package/database/migrations/20260314_d7_canonical_sender_down.sql +53 -0
- package/database/migrations/20260314_d7_canonical_sender_up.sql +114 -0
- package/database/migrations/20260406_d30_security_analytics_down.sql +95 -0
- package/database/migrations/20260406_d30_security_analytics_up.sql +292 -0
- package/database/migrations/20260407_d31_web_google_session_token_hardening_down.sql +2 -0
- package/database/migrations/20260407_d31_web_google_session_token_hardening_up.sql +17 -0
- package/database/migrations/20260408_d32_ai_help_response_cache_down.sql +1 -0
- package/database/migrations/20260408_d32_ai_help_response_cache_up.sql +22 -0
- package/database/migrations/20260409_d33_ai_learning_tables_down.sql +4 -0
- package/database/migrations/20260409_d33_ai_learning_tables_up.sql +52 -0
- package/database/migrations/20260410_d34_command_config_enrichment_down.sql +3 -0
- package/database/migrations/20260410_d34_command_config_enrichment_up.sql +48 -0
- package/database/schema.sql +1186 -0
- package/docker-compose.yml +104 -0
- package/docs/audits/stickerCatalogController-out-of-scope.md +103 -0
- package/docs/audits/stickerCatalogController-symbols.md +58 -0
- package/docs/compliance/acceptable-use-policy-2026-03-07.md +35 -0
- package/docs/compliance/dpa-b2b-standard-2026-03-07.md +80 -0
- package/docs/compliance/monthly-compliance-checklist-2026-03-07.md +88 -0
- package/docs/compliance/notice-and-takedown-policy-2026-03-07.md +34 -0
- package/docs/compliance/privacy-policy-2026-03-07.md +75 -0
- package/docs/compliance/subprocessors-inventory-2026-03-07.md +16 -0
- package/docs/database/production-db-evolution-runbook-2026q1.md +365 -0
- package/docs/security/dsar-lgpd-runbook-2026-03-07.md +86 -0
- package/docs/security/incident-response-lgpd-anpd-runbook-2026-03-07.md +77 -0
- package/docs/security/network-hardening-runbook-2026-03-07.md +137 -0
- package/docs/seo/omnizap-seo-playbook-br-2026-02-28.md +238 -0
- package/docs/seo/satellite-page-template.md +116 -0
- package/docs/seo/satellite-pages-phase1.json +364 -0
- package/docs/wiki/Home.md +120 -0
- package/docs/wiki/pair-extraordinaire-2026-03-08.md +3 -0
- package/docs/wiki/recent-changes-2026-03-08.md +47 -0
- package/ecosystem.prod.config.cjs +135 -0
- package/eslint.config.js +89 -0
- package/index.js +488 -0
- package/ml/clip_classifier/Dockerfile +18 -0
- package/ml/clip_classifier/README.md +118 -0
- package/ml/clip_classifier/adaptive_scoring.py +40 -0
- package/ml/clip_classifier/classifier.py +654 -0
- package/ml/clip_classifier/embedding_store.py +481 -0
- package/ml/clip_classifier/env_loader.py +15 -0
- package/ml/clip_classifier/llm_label_expander.py +144 -0
- package/ml/clip_classifier/main.py +213 -0
- package/ml/clip_classifier/requirements.txt +10 -0
- package/ml/clip_classifier/similarity_engine.py +74 -0
- package/new-logo.png +0 -0
- package/observability/alert-rules.yml +60 -0
- package/observability/grafana/dashboards/omnizap-mysql.json +136 -0
- package/observability/grafana/dashboards/omnizap-overview.json +170 -0
- package/observability/grafana/provisioning/dashboards/dashboards.yml +11 -0
- package/observability/grafana/provisioning/datasources/datasources.yml +15 -0
- package/observability/loki-config.yml +38 -0
- package/observability/mysql-setup.sql +46 -0
- package/observability/prometheus.yml +35 -0
- package/observability/promtail-config.yml +84 -0
- package/observability/sticker-catalog-slo.md +83 -0
- package/observability/sticker-scale-hardening-rollout.md +128 -0
- package/package.json +144 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/assets/css/commands-react.input.css +71 -0
- package/public/assets/css/create-pack-react.input.css +31 -0
- package/public/assets/css/home-react.input.css +106 -0
- package/public/assets/css/login-react.input.css +58 -0
- package/public/assets/css/stickers-react.input.css +18 -0
- package/public/assets/css/terms-react.input.css +115 -0
- package/public/assets/css/user-react.input.css +57 -0
- package/public/assets/images/brand-icon-192.png +0 -0
- package/public/assets/images/brand-logo-128.webp +0 -0
- package/public/assets/images/hero-banner-1280.jpg +0 -0
- package/public/comandos/commands-catalog.json +4517 -0
- package/public/css/api-docs.css +161 -0
- package/public/css/stickers-admin.css +1288 -0
- package/public/css/styles.css +679 -0
- package/public/css/systemadm/admin.css +474 -0
- package/public/css/systemadm/base.css +73 -0
- package/public/css/systemadm/components.css +662 -0
- package/public/css/systemadm/layout.css +229 -0
- package/public/css/systemadm/tokens.css +56 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/js/apps/apiDocsApp.js +235 -0
- package/public/js/apps/commandsReactApp.js +528 -0
- package/public/js/apps/createPackApp.js +1646 -0
- package/public/js/apps/homeReactApp.js +942 -0
- package/public/js/apps/loginReactApp.js +496 -0
- package/public/js/apps/stickersAdminApp.js +1753 -0
- package/public/js/apps/stickersApp.js +3797 -0
- package/public/js/apps/termsReactApp.js +528 -0
- package/public/js/apps/userApp.js +2540 -0
- package/public/js/apps/userProfile/actions.js +66 -0
- package/public/js/apps/userReactApp.js +547 -0
- package/public/js/catalog.js +950 -0
- package/public/pages/api-docs.html +40 -0
- package/public/pages/aup.html +158 -0
- package/public/pages/comandos.html +41 -0
- package/public/pages/dpa.html +227 -0
- package/public/pages/home.html +45 -0
- package/public/pages/licenca.html +182 -0
- package/public/pages/login.html +40 -0
- package/public/pages/notice-and-takedown.html +234 -0
- package/public/pages/politica-de-privacidade.html +251 -0
- package/public/pages/seo-bot-whatsapp-para-grupo.html +350 -0
- package/public/pages/seo-bot-whatsapp-sem-programar.html +350 -0
- package/public/pages/seo-como-automatizar-avisos-no-whatsapp.html +350 -0
- package/public/pages/seo-como-criar-comandos-whatsapp.html +350 -0
- package/public/pages/seo-como-evitar-spam-no-whatsapp.html +350 -0
- package/public/pages/seo-como-moderar-grupo-whatsapp.html +350 -0
- package/public/pages/seo-como-organizar-comunidade-whatsapp.html +350 -0
- package/public/pages/seo-melhor-bot-whatsapp-para-grupos.html +350 -0
- package/public/pages/stickers-admin.html +31 -0
- package/public/pages/stickers-create.html +41 -0
- package/public/pages/stickers.html +45 -0
- package/public/pages/suboperadores.html +237 -0
- package/public/pages/termos-de-uso-texto-integral.html +241 -0
- package/public/pages/termos-de-uso.html +41 -0
- package/public/pages/user-password-reset.html +32 -0
- package/public/pages/user-systemadm.html +508 -0
- package/public/pages/user.html +39 -0
- package/public/robots.txt +9 -0
- package/public/site.webmanifest +24 -0
- package/public/sitemap.xml +98 -0
- package/schemas/command-config.schema.json +582 -0
- package/scripts/baileys-compat-smoke.mjs +12 -0
- package/scripts/cache-bust.mjs +142 -0
- package/scripts/deploy.sh +916 -0
- package/scripts/email-broadcast-terms-update.mjs +170 -0
- package/scripts/enrich-command-discovery-fields.mjs +286 -0
- package/scripts/generate-command-config-schema.mjs +273 -0
- package/scripts/generate-commands-catalog.mjs +308 -0
- package/scripts/generate-module-agents.mjs +631 -0
- package/scripts/generate-seo-satellite-pages.mjs +400 -0
- package/scripts/github-deploy-notify.mjs +174 -0
- package/scripts/github-release-notify.mjs +219 -0
- package/scripts/release.sh +599 -0
- package/scripts/run-codeql-local.sh +116 -0
- package/scripts/run-prettier-all.mjs +25 -0
- package/scripts/security-smoketest.mjs +581 -0
- package/scripts/sticker-catalog-loadtest.mjs +210 -0
- package/scripts/sticker-worker-task.mjs +119 -0
- package/scripts/sync-readme-snapshot.mjs +133 -0
- package/scripts/validate-command-config-schema.mjs +130 -0
- package/scripts/validate-command-configs.mjs +15 -0
- package/scripts/wiki-sync.sh +191 -0
- package/server/auth/googleWebAuth/googleWebAuthRuntime.js +62 -0
- package/server/auth/googleWebAuth/googleWebAuthService.js +807 -0
- package/server/auth/jwt/webJwtService.js +147 -0
- package/server/auth/stickerCatalogAuthContext.js +165 -0
- package/server/auth/termsAcceptance/termsAcceptanceHandler.js +189 -0
- package/server/auth/userPassword/index.js +14 -0
- package/server/auth/userPassword/userPasswordAuthService.js +422 -0
- package/server/auth/userPassword/userPasswordCrypto.js +199 -0
- package/server/auth/userPassword/userPasswordCrypto.test.js +76 -0
- package/server/auth/userPassword/userPasswordRecoveryService.js +728 -0
- package/server/auth/validation/authSchemas.js +236 -0
- package/server/auth/webAccount/webAccountHandlers.js +1434 -0
- package/server/controllers/admin/adminBanService.js +138 -0
- package/server/controllers/admin/adminPanelHandlers.js +2083 -0
- package/server/controllers/admin/stickerCatalogAdminContext.js +17 -0
- package/server/controllers/admin/systemAdminController.js +201 -0
- package/server/controllers/email/emailAutomationController.js +239 -0
- package/server/controllers/metricsController.js +21 -0
- package/server/controllers/seo/stickerCatalogSeoContext.js +514 -0
- package/server/controllers/sticker/nonCatalogHandlers.js +303 -0
- package/server/controllers/sticker/stickerCatalogController.js +4700 -0
- package/server/controllers/system/contactController.js +115 -0
- package/server/controllers/system/githubController.js +137 -0
- package/server/controllers/system/stickerCatalogSystemContext.js +758 -0
- package/server/controllers/system/storageController.js +154 -0
- package/server/controllers/system/systemController.js +135 -0
- package/server/controllers/system/systemMetricsController.js +156 -0
- package/server/controllers/system/visitController.js +90 -0
- package/server/controllers/userController.js +145 -0
- package/server/email/emailAutomationRuntime.js +225 -0
- package/server/email/emailAutomationService.js +125 -0
- package/server/email/emailOutboxRepository.js +282 -0
- package/server/email/emailTemplateService.js +480 -0
- package/server/email/emailTransportService.js +156 -0
- package/server/http/clientIp.js +95 -0
- package/server/http/httpRequestUtils.js +262 -0
- package/server/http/httpRequestUtils.test.js +80 -0
- package/server/http/httpServer.js +180 -0
- package/server/http/requestContext.js +20 -0
- package/server/http/siteRoutingUtils.js +87 -0
- package/server/index.js +1 -0
- package/server/middleware/cachePolicy.js +26 -0
- package/server/middleware/cachePolicyHelpers.js +1 -0
- package/server/middleware/endpointRateLimit.js +181 -0
- package/server/middleware/rateLimit.js +70 -0
- package/server/middleware/requireAdminAuth.js +48 -0
- package/server/middleware/securityHeaders.js +97 -0
- package/server/routes/admin/systemAdminRouter.js +64 -0
- package/server/routes/email/emailAutomationRouter.js +46 -0
- package/server/routes/health/healthRouter.js +41 -0
- package/server/routes/indexRouter.js +234 -0
- package/server/routes/metrics/metricsRouter.js +58 -0
- package/server/routes/static/staticPageRouter.js +134 -0
- package/server/routes/sticker/catalogHandlers/catalogAdminHttp.js +105 -0
- package/server/routes/sticker/catalogHandlers/catalogAuthHttp.js +77 -0
- package/server/routes/sticker/catalogHandlers/catalogPublicHttp.js +120 -0
- package/server/routes/sticker/catalogHandlers/catalogUploadHttp.js +83 -0
- package/server/routes/sticker/catalogRouter.js +77 -0
- package/server/routes/sticker/stickerApiRouter.js +84 -0
- package/server/routes/sticker/stickerDataRouter.js +145 -0
- package/server/routes/sticker/stickerSiteRouter.js +43 -0
- package/server/routes/user/userApiPaths.js +66 -0
- package/server/routes/user/userRouter.js +65 -0
- package/server/utils/safePath.js +26 -0
- package/utils/logger/loggerModule.js +35 -0
- package/vite.config.mjs +38 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const parseCliArgs = (argv = []) => {
|
|
7
|
+
const args = new Map();
|
|
8
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
9
|
+
const token = argv[index];
|
|
10
|
+
if (!token.startsWith('--')) continue;
|
|
11
|
+
const next = argv[index + 1];
|
|
12
|
+
if (!next || next.startsWith('--')) {
|
|
13
|
+
args.set(token, true);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
args.set(token, next);
|
|
17
|
+
index += 1;
|
|
18
|
+
}
|
|
19
|
+
return args;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const LEGACY_PRE_CONDICOES_REQUIRED = ['requer_grupo', 'requer_admin', 'requer_admin_principal', 'requer_google_login', 'requer_nsfw', 'requer_midia', 'requer_mensagem_respondida'];
|
|
23
|
+
|
|
24
|
+
const V2_REQUIREMENTS_REQUIRED = ['require_group', 'require_group_admin', 'require_bot_owner', 'require_google_login', 'require_nsfw_enabled', 'require_media', 'require_reply_message'];
|
|
25
|
+
|
|
26
|
+
const booleanPropsFrom = (keys = []) => Object.fromEntries(keys.map((key) => [key, { type: 'boolean' }]));
|
|
27
|
+
|
|
28
|
+
const LEGACY_ARGUMENT_SCHEMA = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
required: ['nome', 'tipo', 'obrigatorio'],
|
|
31
|
+
properties: {
|
|
32
|
+
nome: { type: 'string' },
|
|
33
|
+
tipo: { type: 'string' },
|
|
34
|
+
obrigatorio: { type: 'boolean' },
|
|
35
|
+
validacao: { type: ['string', 'null'] },
|
|
36
|
+
default: {},
|
|
37
|
+
},
|
|
38
|
+
additionalProperties: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const V2_ARGUMENT_SCHEMA = {
|
|
42
|
+
type: 'object',
|
|
43
|
+
required: ['name', 'type', 'required'],
|
|
44
|
+
properties: {
|
|
45
|
+
name: { type: 'string' },
|
|
46
|
+
type: { type: 'string' },
|
|
47
|
+
required: { type: 'boolean' },
|
|
48
|
+
default: {},
|
|
49
|
+
enum: {
|
|
50
|
+
type: ['array', 'null'],
|
|
51
|
+
items: { type: ['string', 'number', 'boolean'] },
|
|
52
|
+
},
|
|
53
|
+
description: { type: ['string', 'null'] },
|
|
54
|
+
validation: { type: ['string', 'null'] },
|
|
55
|
+
position: { type: ['integer', 'null'] },
|
|
56
|
+
},
|
|
57
|
+
additionalProperties: true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const LEGACY_PRE_CONDICOES_SCHEMA = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
required: LEGACY_PRE_CONDICOES_REQUIRED,
|
|
63
|
+
properties: booleanPropsFrom(LEGACY_PRE_CONDICOES_REQUIRED),
|
|
64
|
+
additionalProperties: true,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const V2_REQUIREMENTS_SCHEMA = {
|
|
68
|
+
type: 'object',
|
|
69
|
+
required: V2_REQUIREMENTS_REQUIRED,
|
|
70
|
+
properties: {
|
|
71
|
+
...booleanPropsFrom(V2_REQUIREMENTS_REQUIRED),
|
|
72
|
+
legacy: LEGACY_PRE_CONDICOES_SCHEMA,
|
|
73
|
+
},
|
|
74
|
+
additionalProperties: true,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const PLAN_LIMIT_ENTRY_SCHEMA = {
|
|
78
|
+
type: 'object',
|
|
79
|
+
required: ['max', 'janela_ms', 'escopo'],
|
|
80
|
+
properties: {
|
|
81
|
+
max: { type: ['integer', 'null'] },
|
|
82
|
+
janela_ms: { type: ['integer', 'null'] },
|
|
83
|
+
escopo: { type: 'string' },
|
|
84
|
+
},
|
|
85
|
+
additionalProperties: true,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const PLAN_LIMITS_SCHEMA = {
|
|
89
|
+
type: 'object',
|
|
90
|
+
required: ['comum', 'premium'],
|
|
91
|
+
properties: {
|
|
92
|
+
comum: PLAN_LIMIT_ENTRY_SCHEMA,
|
|
93
|
+
premium: PLAN_LIMIT_ENTRY_SCHEMA,
|
|
94
|
+
},
|
|
95
|
+
additionalProperties: true,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const ACCESS_SCHEMA = {
|
|
99
|
+
type: 'object',
|
|
100
|
+
required: ['premium_only', 'allowed_plans'],
|
|
101
|
+
properties: {
|
|
102
|
+
premium_only: { type: 'boolean' },
|
|
103
|
+
allowed_plans: {
|
|
104
|
+
type: 'array',
|
|
105
|
+
items: { type: 'string' },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
additionalProperties: true,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const COMMAND_HANDLER_SCHEMA = {
|
|
112
|
+
type: 'object',
|
|
113
|
+
required: ['file', 'method'],
|
|
114
|
+
properties: {
|
|
115
|
+
file: { type: 'string' },
|
|
116
|
+
method: { type: 'string' },
|
|
117
|
+
command_case: { type: ['string', 'null'] },
|
|
118
|
+
},
|
|
119
|
+
additionalProperties: true,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const COMMAND_SCHEMA = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
required: ['name', 'aliases', 'metodos_de_uso', 'argumentos', 'categoria', 'enabled', 'pre_condicoes', 'id', 'description', 'usage', 'permission', 'contexts', 'collected_data', 'requirements', 'arguments', 'dependencies', 'side_effects', 'docs', 'behavior', 'limits', 'observability', 'privacy', 'discovery', 'access', 'plan_limits', 'version', 'stability', 'deprecated', 'risk_level', 'handler'],
|
|
125
|
+
properties: {
|
|
126
|
+
name: { type: 'string' },
|
|
127
|
+
aliases: {
|
|
128
|
+
type: 'array',
|
|
129
|
+
items: { type: 'string' },
|
|
130
|
+
},
|
|
131
|
+
metodos_de_uso: {
|
|
132
|
+
type: 'array',
|
|
133
|
+
items: { type: 'string' },
|
|
134
|
+
},
|
|
135
|
+
argumentos: {
|
|
136
|
+
type: 'array',
|
|
137
|
+
items: LEGACY_ARGUMENT_SCHEMA,
|
|
138
|
+
},
|
|
139
|
+
categoria: { type: 'string' },
|
|
140
|
+
enabled: { type: 'boolean' },
|
|
141
|
+
pre_condicoes: LEGACY_PRE_CONDICOES_SCHEMA,
|
|
142
|
+
|
|
143
|
+
id: { type: 'string' },
|
|
144
|
+
description: { type: 'string' },
|
|
145
|
+
usage: {
|
|
146
|
+
type: 'array',
|
|
147
|
+
items: { type: 'string' },
|
|
148
|
+
},
|
|
149
|
+
permission: { type: 'string' },
|
|
150
|
+
contexts: {
|
|
151
|
+
type: 'array',
|
|
152
|
+
items: { type: 'string' },
|
|
153
|
+
},
|
|
154
|
+
collected_data: {
|
|
155
|
+
type: 'array',
|
|
156
|
+
items: { type: 'string' },
|
|
157
|
+
},
|
|
158
|
+
requirements: V2_REQUIREMENTS_SCHEMA,
|
|
159
|
+
arguments: {
|
|
160
|
+
type: 'array',
|
|
161
|
+
items: V2_ARGUMENT_SCHEMA,
|
|
162
|
+
},
|
|
163
|
+
dependencies: {
|
|
164
|
+
type: 'array',
|
|
165
|
+
items: { type: 'string' },
|
|
166
|
+
},
|
|
167
|
+
side_effects: {
|
|
168
|
+
type: 'array',
|
|
169
|
+
items: { type: 'string' },
|
|
170
|
+
},
|
|
171
|
+
docs: { type: 'object' },
|
|
172
|
+
behavior: { type: 'object' },
|
|
173
|
+
limits: { type: 'object' },
|
|
174
|
+
observability: { type: 'object' },
|
|
175
|
+
privacy: { type: 'object' },
|
|
176
|
+
discovery: { type: 'object' },
|
|
177
|
+
access: ACCESS_SCHEMA,
|
|
178
|
+
plan_limits: PLAN_LIMITS_SCHEMA,
|
|
179
|
+
version: { type: 'string' },
|
|
180
|
+
stability: { type: 'string' },
|
|
181
|
+
deprecated: { type: 'boolean' },
|
|
182
|
+
replaced_by: { type: ['string', 'null'] },
|
|
183
|
+
risk_level: { type: 'string' },
|
|
184
|
+
handler: COMMAND_HANDLER_SCHEMA,
|
|
185
|
+
},
|
|
186
|
+
additionalProperties: true,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const COMMAND_CONFIG_SCHEMA = {
|
|
190
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
191
|
+
$id: 'https://omnizap.shop/schemas/command-config.schema.json',
|
|
192
|
+
title: 'OmniZap Command Config Schema (v2)',
|
|
193
|
+
description: 'Schema padrão para arquivos app/modules/*/commandConfig.json.',
|
|
194
|
+
type: 'object',
|
|
195
|
+
required: ['schema_version', 'module', 'enabled', 'source_files', 'defaults', 'commands'],
|
|
196
|
+
properties: {
|
|
197
|
+
schema_version: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
pattern: '^2\\.',
|
|
200
|
+
},
|
|
201
|
+
module: { type: 'string' },
|
|
202
|
+
enabled: { type: 'boolean' },
|
|
203
|
+
source_files: {
|
|
204
|
+
type: 'array',
|
|
205
|
+
minItems: 1,
|
|
206
|
+
items: { type: 'string' },
|
|
207
|
+
},
|
|
208
|
+
defaults: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
required: ['command', 'requirements'],
|
|
211
|
+
properties: {
|
|
212
|
+
inheritance_mode: { type: ['string', 'null'] },
|
|
213
|
+
compatibility_mode: { type: ['string', 'null'] },
|
|
214
|
+
legacy_field_aliases: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
additionalProperties: { type: 'string' },
|
|
217
|
+
},
|
|
218
|
+
command: {
|
|
219
|
+
type: 'object',
|
|
220
|
+
required: ['enabled', 'category', 'version', 'stability', 'deprecated', 'risk_level'],
|
|
221
|
+
properties: {
|
|
222
|
+
enabled: { type: 'boolean' },
|
|
223
|
+
category: { type: 'string' },
|
|
224
|
+
version: { type: 'string' },
|
|
225
|
+
stability: { type: 'string' },
|
|
226
|
+
deprecated: { type: 'boolean' },
|
|
227
|
+
replaced_by: { type: ['string', 'null'] },
|
|
228
|
+
risk_level: { type: 'string' },
|
|
229
|
+
},
|
|
230
|
+
additionalProperties: true,
|
|
231
|
+
},
|
|
232
|
+
requirements: V2_REQUIREMENTS_SCHEMA,
|
|
233
|
+
pre_condicoes: LEGACY_PRE_CONDICOES_SCHEMA,
|
|
234
|
+
responses: { type: 'object' },
|
|
235
|
+
respostas_padrao: { type: 'object' },
|
|
236
|
+
access: ACCESS_SCHEMA,
|
|
237
|
+
plan_limits: PLAN_LIMITS_SCHEMA,
|
|
238
|
+
limite_uso_por_plano: PLAN_LIMITS_SCHEMA,
|
|
239
|
+
},
|
|
240
|
+
additionalProperties: true,
|
|
241
|
+
},
|
|
242
|
+
commands: {
|
|
243
|
+
type: 'array',
|
|
244
|
+
minItems: 1,
|
|
245
|
+
items: COMMAND_SCHEMA,
|
|
246
|
+
},
|
|
247
|
+
textos: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
additionalProperties: { type: ['string', 'number', 'boolean', 'null'] },
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
additionalProperties: true,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const args = parseCliArgs(process.argv.slice(2));
|
|
256
|
+
const outputPath = path.resolve(String(args.get('--out') || path.join(process.cwd(), 'schemas', 'command-config.schema.json')));
|
|
257
|
+
const printStdout = Boolean(args.get('--stdout'));
|
|
258
|
+
|
|
259
|
+
const run = async () => {
|
|
260
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
261
|
+
await fs.writeFile(outputPath, `${JSON.stringify(COMMAND_CONFIG_SCHEMA, null, 2)}\n`, 'utf8');
|
|
262
|
+
|
|
263
|
+
if (printStdout) {
|
|
264
|
+
process.stdout.write(`${JSON.stringify(COMMAND_CONFIG_SCHEMA, null, 2)}\n`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
console.log(`[command-config-schema] generated: ${path.relative(process.cwd(), outputPath)}`);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
run().catch((error) => {
|
|
271
|
+
console.error('[command-config-schema] failed:', error?.message || error);
|
|
272
|
+
process.exit(1);
|
|
273
|
+
});
|
|
@@ -0,0 +1,308 @@
|
|
|
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
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const repoRoot = path.resolve(__dirname, '..');
|
|
10
|
+
const modulesRoot = path.join(repoRoot, 'app', 'modules');
|
|
11
|
+
const outputPath = path.join(repoRoot, 'public', 'comandos', 'commands-catalog.json');
|
|
12
|
+
|
|
13
|
+
const CATEGORY_META = {
|
|
14
|
+
admin: { label: 'Moderação e Admin', icon: '🛡️' },
|
|
15
|
+
figurinhas: { label: 'Figurinhas', icon: '🎨' },
|
|
16
|
+
midia: { label: 'Mídia', icon: '🎵' },
|
|
17
|
+
ia: { label: 'Inteligência Artificial', icon: '🤖' },
|
|
18
|
+
anime: { label: 'Anime e Imagens', icon: '🖼️' },
|
|
19
|
+
jogos: { label: 'Jogos e Diversão', icon: '🎮' },
|
|
20
|
+
estatisticas: { label: 'Estatísticas', icon: '📊' },
|
|
21
|
+
menu: { label: 'Menu e Navegação', icon: '📚' },
|
|
22
|
+
sistema: { label: 'Sistema', icon: '🧰' },
|
|
23
|
+
usuario: { label: 'Perfil de Usuário', icon: '👤' },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const CATEGORY_ORDER = ['admin', 'figurinhas', 'midia', 'ia', 'jogos', 'estatisticas', 'anime', 'usuario', 'menu', 'sistema'];
|
|
27
|
+
|
|
28
|
+
const normalizeText = (value) =>
|
|
29
|
+
String(value || '')
|
|
30
|
+
.trim()
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.normalize('NFD')
|
|
33
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
34
|
+
.replace(/\s+/g, ' ');
|
|
35
|
+
|
|
36
|
+
const ensureArray = (value) => (Array.isArray(value) ? value.filter(Boolean) : []);
|
|
37
|
+
|
|
38
|
+
const unique = (values = []) => {
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const value of values) {
|
|
41
|
+
const raw = String(value || '').trim();
|
|
42
|
+
if (!raw || out.includes(raw)) continue;
|
|
43
|
+
out.push(raw);
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const normalizeCategoryKey = (value) => normalizeText(value).replace(/\s+/g, '_') || 'outros';
|
|
49
|
+
|
|
50
|
+
const resolveCategoryMeta = (key) => {
|
|
51
|
+
const meta = CATEGORY_META[key] || null;
|
|
52
|
+
if (meta) return meta;
|
|
53
|
+
|
|
54
|
+
const label = key
|
|
55
|
+
.split('_')
|
|
56
|
+
.map((token) => token.charAt(0).toUpperCase() + token.slice(1))
|
|
57
|
+
.join(' ');
|
|
58
|
+
return { label, icon: '🧩' };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const deepMerge = (target, source) => {
|
|
62
|
+
if (!source) return target;
|
|
63
|
+
const output = { ...target };
|
|
64
|
+
for (const key in source) {
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
66
|
+
if (source[key] !== null && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
67
|
+
output[key] = deepMerge(target[key] || {}, source[key]);
|
|
68
|
+
} else {
|
|
69
|
+
output[key] = source[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return output;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const listModuleConfigs = async () => {
|
|
77
|
+
const dirs = await fs.readdir(modulesRoot, { withFileTypes: true });
|
|
78
|
+
const configs = [];
|
|
79
|
+
|
|
80
|
+
for (const dir of dirs) {
|
|
81
|
+
if (!dir.isDirectory()) continue;
|
|
82
|
+
const moduleDir = path.join(modulesRoot, dir.name);
|
|
83
|
+
const configPath = path.join(moduleDir, 'commandConfig.json');
|
|
84
|
+
try {
|
|
85
|
+
await fs.access(configPath);
|
|
86
|
+
configs.push({ moduleDirName: dir.name, configPath });
|
|
87
|
+
} catch {
|
|
88
|
+
// ignore modules sem commandConfig
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return configs.sort((left, right) => left.moduleDirName.localeCompare(right.moduleDirName));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const sanitizeCommand = ({ command: rawCommand, moduleDefaults, moduleDirName, moduleName }) => {
|
|
96
|
+
// Merge overrides from module defaults
|
|
97
|
+
const command = deepMerge(moduleDefaults?.command || {}, rawCommand);
|
|
98
|
+
|
|
99
|
+
const commandName = String(command?.name || '').trim();
|
|
100
|
+
if (!commandName) return null;
|
|
101
|
+
|
|
102
|
+
const category = normalizeCategoryKey(command?.categoria || command?.category);
|
|
103
|
+
const aliases = unique(ensureArray(command?.aliases).map((alias) => String(alias)));
|
|
104
|
+
|
|
105
|
+
// Usage methods & docs
|
|
106
|
+
const usageMethods = unique(ensureArray(command?.metodos_de_uso || command?.usage || command?.docs?.usage_examples).map((method) => String(method).replaceAll('<prefix>', '/').trim()));
|
|
107
|
+
const usageVariants = deepMerge(moduleDefaults?.responses || {}, command?.docs?.usage_variants || command?.mensagens_uso || {});
|
|
108
|
+
|
|
109
|
+
const normalizedUsageVariants = Object.entries(usageVariants).reduce((acc, [variantKey, methods]) => {
|
|
110
|
+
const normalizedVariantKey = String(variantKey || '').trim();
|
|
111
|
+
const normalizedMethods = unique(ensureArray(methods).map((method) => String(method).replaceAll('<prefix>', '/').trim()));
|
|
112
|
+
if (normalizedVariantKey && normalizedMethods.length) {
|
|
113
|
+
acc[normalizedVariantKey] = normalizedMethods;
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
}, {});
|
|
117
|
+
|
|
118
|
+
// Requirements (Requirements merged with defaults)
|
|
119
|
+
const req = deepMerge(moduleDefaults?.requirements || moduleDefaults?.pre_condicoes || {}, command?.requirements || command?.pre_condicoes || {});
|
|
120
|
+
const requirements = {
|
|
121
|
+
group: Boolean(req.require_group ?? req.requer_grupo),
|
|
122
|
+
admin: Boolean(req.require_group_admin ?? req.requer_admin),
|
|
123
|
+
owner: Boolean(req.require_bot_owner ?? req.requer_admin_principal),
|
|
124
|
+
google_login: Boolean(req.require_google_login ?? req.requer_google_login),
|
|
125
|
+
nsfw: Boolean(req.require_nsfw_enabled ?? req.requer_nsfw),
|
|
126
|
+
media: Boolean(req.require_media ?? req.requer_midia),
|
|
127
|
+
reply: Boolean(req.require_reply_message ?? req.requer_mensagem_respondida),
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Access & Premium
|
|
131
|
+
const acc = deepMerge(moduleDefaults?.access || moduleDefaults?.acesso || {}, command?.access || command?.acesso || {});
|
|
132
|
+
const premium = Boolean(acc.premium_only ?? acc.somente_premium);
|
|
133
|
+
const allowedPlans = unique(ensureArray(acc.allowed_plans || acc.planos_permitidos));
|
|
134
|
+
|
|
135
|
+
// Rate Limits
|
|
136
|
+
const rl = deepMerge(moduleDefaults?.rate_limit || {}, command?.limits?.rate_limit || command?.rate_limit || {});
|
|
137
|
+
const rateLimit = rl.max ? { max: rl.max, window_ms: rl.janela_ms || rl.window_ms, scope: rl.escopo || rl.scope } : null;
|
|
138
|
+
|
|
139
|
+
// Discovery
|
|
140
|
+
const disc = deepMerge(moduleDefaults?.discovery || {}, command?.discovery || {});
|
|
141
|
+
const keywords = unique([...ensureArray(command?.capability_keywords), ...ensureArray(disc.keywords)]);
|
|
142
|
+
const userPhrasings = unique([...ensureArray(command?.user_phrasings), ...ensureArray(disc.user_phrasings)]);
|
|
143
|
+
|
|
144
|
+
// Arguments
|
|
145
|
+
const rawArgs = command?.arguments || command?.argumentos || [];
|
|
146
|
+
const args = ensureArray(rawArgs)
|
|
147
|
+
.map((arg) => ({
|
|
148
|
+
name: String(arg.name || arg.nome || '').trim(),
|
|
149
|
+
type: String(arg.type || arg.tipo || 'string').trim(),
|
|
150
|
+
required: Boolean(arg.required ?? arg.obrigatorio),
|
|
151
|
+
description: String(arg.description || arg.descricao || '').trim(),
|
|
152
|
+
default: arg.default ?? null,
|
|
153
|
+
validation: arg.validation || arg.validacao || null,
|
|
154
|
+
}))
|
|
155
|
+
.filter((a) => a.name);
|
|
156
|
+
|
|
157
|
+
// Advanced Info (New Fields)
|
|
158
|
+
const collectedData = unique([...ensureArray(moduleDefaults?.privacy?.data_categories), ...ensureArray(command?.privacy?.data_categories), ...ensureArray(command?.informacoes_coletadas), ...ensureArray(command?.collected_data)]);
|
|
159
|
+
const dependencies = unique([...ensureArray(moduleDefaults?.dependencies), ...ensureArray(command?.dependencies), ...ensureArray(command?.dependencias_externas)]);
|
|
160
|
+
const sideEffects = unique([...ensureArray(command?.efeitos_colaterais), ...ensureArray(command?.side_effects)]);
|
|
161
|
+
|
|
162
|
+
const responses = deepMerge(moduleDefaults?.responses || moduleDefaults?.respostas_padrao || {}, command?.responses || command?.respostas_padrao || {});
|
|
163
|
+
|
|
164
|
+
const observability = deepMerge(moduleDefaults?.observability || {}, command?.observability || {});
|
|
165
|
+
const privacy = deepMerge(moduleDefaults?.privacy || {}, command?.privacy || {});
|
|
166
|
+
const behavior = deepMerge(moduleDefaults?.behavior || {}, command?.behavior || {});
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
key: `${moduleDirName}:${commandName}`,
|
|
170
|
+
name: commandName,
|
|
171
|
+
id: command?.id || `${moduleDirName}.${commandName}`,
|
|
172
|
+
aliases,
|
|
173
|
+
module: moduleDirName,
|
|
174
|
+
module_label: moduleName,
|
|
175
|
+
category,
|
|
176
|
+
category_label: resolveCategoryMeta(category).label,
|
|
177
|
+
descricao: String(command?.description || command?.descricao || '').trim(),
|
|
178
|
+
requirements,
|
|
179
|
+
premium,
|
|
180
|
+
allowed_plans: allowedPlans,
|
|
181
|
+
rate_limit: rateLimit,
|
|
182
|
+
local_de_uso: unique(ensureArray(command?.contexts || command?.local_de_uso).map((item) => String(item).trim())),
|
|
183
|
+
subcomandos: unique(ensureArray(command?.subcomandos).map((item) => String(item).trim())),
|
|
184
|
+
metodos_de_uso: usageMethods,
|
|
185
|
+
mensagens_uso: normalizedUsageVariants,
|
|
186
|
+
arguments: args,
|
|
187
|
+
responses,
|
|
188
|
+
technical: {
|
|
189
|
+
collected_data: collectedData,
|
|
190
|
+
dependencies,
|
|
191
|
+
side_effects: sideEffects,
|
|
192
|
+
behavior,
|
|
193
|
+
handler: command?.handler || null,
|
|
194
|
+
risk_level: String(command?.risk_level || 'low'),
|
|
195
|
+
stability: String(command?.stability || 'stable'),
|
|
196
|
+
version: String(command?.version || '1.0.0'),
|
|
197
|
+
},
|
|
198
|
+
observability: {
|
|
199
|
+
event_name: observability.event_name || null,
|
|
200
|
+
analytics_event: observability.analytics_event || observability.evento_analytics || null,
|
|
201
|
+
tags: unique([...ensureArray(observability.tags), ...ensureArray(observability.tags_log)]),
|
|
202
|
+
},
|
|
203
|
+
privacy: {
|
|
204
|
+
retention: privacy.retention_policy || privacy.retencao || null,
|
|
205
|
+
legal_basis: privacy.legal_basis || privacy.base_legal || null,
|
|
206
|
+
},
|
|
207
|
+
discovery: {
|
|
208
|
+
keywords,
|
|
209
|
+
user_phrasings: userPhrasings,
|
|
210
|
+
priority: Number(command?.suggestion_priority || disc.suggestion_priority || 0),
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const buildCatalog = async () => {
|
|
216
|
+
const moduleConfigs = await listModuleConfigs();
|
|
217
|
+
const commands = [];
|
|
218
|
+
const modules = [];
|
|
219
|
+
|
|
220
|
+
for (const { moduleDirName, configPath } of moduleConfigs) {
|
|
221
|
+
const raw = await fs.readFile(configPath, 'utf8');
|
|
222
|
+
const parsed = JSON.parse(raw);
|
|
223
|
+
const moduleName = String(parsed?.module || moduleDirName).trim() || moduleDirName;
|
|
224
|
+
const moduleDefaults = parsed?.defaults || {};
|
|
225
|
+
const entries = ensureArray(parsed?.commands);
|
|
226
|
+
|
|
227
|
+
const moduleCommands = [];
|
|
228
|
+
for (const entry of entries) {
|
|
229
|
+
if (!entry || entry.enabled === false) continue;
|
|
230
|
+
const sanitized = sanitizeCommand({ command: entry, moduleDefaults, moduleDirName, moduleName });
|
|
231
|
+
if (!sanitized) continue;
|
|
232
|
+
moduleCommands.push(sanitized);
|
|
233
|
+
commands.push(sanitized);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
modules.push({
|
|
237
|
+
key: moduleDirName,
|
|
238
|
+
label: moduleName,
|
|
239
|
+
source_file: path.relative(repoRoot, configPath),
|
|
240
|
+
enabled: parsed?.enabled !== false,
|
|
241
|
+
command_count: moduleCommands.length,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const categoryMap = new Map();
|
|
246
|
+
for (const command of commands) {
|
|
247
|
+
if (!categoryMap.has(command.category)) {
|
|
248
|
+
const categoryMeta = resolveCategoryMeta(command.category);
|
|
249
|
+
categoryMap.set(command.category, {
|
|
250
|
+
key: command.category,
|
|
251
|
+
label: categoryMeta.label,
|
|
252
|
+
icon: categoryMeta.icon,
|
|
253
|
+
command_count: 0,
|
|
254
|
+
modules: new Set(),
|
|
255
|
+
commands: [],
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
const category = categoryMap.get(command.category);
|
|
259
|
+
category.command_count += 1;
|
|
260
|
+
category.modules.add(command.module);
|
|
261
|
+
category.commands.push(command);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const knownOrderMap = new Map(CATEGORY_ORDER.map((key, index) => [key, index]));
|
|
265
|
+
const categories = Array.from(categoryMap.values())
|
|
266
|
+
.sort((left, right) => {
|
|
267
|
+
const leftOrder = knownOrderMap.has(left.key) ? knownOrderMap.get(left.key) : 999;
|
|
268
|
+
const rightOrder = knownOrderMap.has(right.key) ? knownOrderMap.get(right.key) : 999;
|
|
269
|
+
if (leftOrder !== rightOrder) return leftOrder - rightOrder;
|
|
270
|
+
if (left.command_count !== right.command_count) return right.command_count - left.command_count;
|
|
271
|
+
return left.label.localeCompare(right.label, 'pt-BR');
|
|
272
|
+
})
|
|
273
|
+
.map((category) => ({
|
|
274
|
+
...category,
|
|
275
|
+
modules: Array.from(category.modules).sort((left, right) => left.localeCompare(right, 'pt-BR')),
|
|
276
|
+
commands: category.commands.sort((left, right) => left.name.localeCompare(right.name, 'pt-BR')),
|
|
277
|
+
}));
|
|
278
|
+
|
|
279
|
+
const sortedModules = modules.sort((left, right) => {
|
|
280
|
+
if (left.command_count !== right.command_count) return right.command_count - left.command_count;
|
|
281
|
+
return left.label.localeCompare(right.label, 'pt-BR');
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
schema_version: '3.0.0',
|
|
286
|
+
generated_at: new Date().toISOString(),
|
|
287
|
+
totals: {
|
|
288
|
+
modules: sortedModules.length,
|
|
289
|
+
categories: categories.length,
|
|
290
|
+
commands: commands.length,
|
|
291
|
+
},
|
|
292
|
+
modules: sortedModules,
|
|
293
|
+
categories,
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const writeCatalog = async () => {
|
|
298
|
+
const payload = await buildCatalog();
|
|
299
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
300
|
+
await fs.writeFile(outputPath, `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
|
|
301
|
+
|
|
302
|
+
console.log(`Catalogo de comandos atualizado: ${path.relative(repoRoot, outputPath)} (${payload.totals.commands} comandos)`);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
writeCatalog().catch((error) => {
|
|
306
|
+
console.error('Falha ao gerar catalogo de comandos:', error);
|
|
307
|
+
process.exitCode = 1;
|
|
308
|
+
});
|