@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,213 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from fastapi import FastAPI, File, Form, HTTPException, UploadFile
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
|
|
9
|
+
from classifier import (
|
|
10
|
+
ADAPTIVE_ALPHA,
|
|
11
|
+
AFFINITY_WEIGHT_CAP,
|
|
12
|
+
CLIP_TOP_K,
|
|
13
|
+
DEFAULT_LABELS,
|
|
14
|
+
ENABLE_ADAPTIVE_SCORING,
|
|
15
|
+
ENABLE_LLM_EXPANSION_GATING,
|
|
16
|
+
ENABLE_CLUSTERING,
|
|
17
|
+
ENABLE_EMBEDDING_CACHE,
|
|
18
|
+
ENABLE_LLM_LABEL_EXPANSION,
|
|
19
|
+
ENTROPY_NORMALIZED_THRESHOLD,
|
|
20
|
+
ENTROPY_THRESHOLD,
|
|
21
|
+
LLM_EXPANSION_MAX_ENTROPY_NORMALIZED,
|
|
22
|
+
LLM_EXPANSION_MIN_MARGIN,
|
|
23
|
+
NSFW_THRESHOLD,
|
|
24
|
+
classify_image_bytes,
|
|
25
|
+
get_classifier,
|
|
26
|
+
register_pack_feedback,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
app = FastAPI(
|
|
30
|
+
title="OmniZap MobileCLIP Classifier API",
|
|
31
|
+
description="Classificação de imagens com MobileCLIP (via OpenCLIP) para categorizar stickers/packs.",
|
|
32
|
+
version="2.0.0",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TopLabelEntry(BaseModel):
|
|
37
|
+
label: str
|
|
38
|
+
score: float
|
|
39
|
+
logit: float
|
|
40
|
+
clip_score: float
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class SimilarImageEntry(BaseModel):
|
|
44
|
+
image_hash: str
|
|
45
|
+
asset_id: str | None = None
|
|
46
|
+
similarity: float
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class LlmExpansionPayload(BaseModel):
|
|
50
|
+
subtags: list[str] = Field(default_factory=list)
|
|
51
|
+
style_traits: list[str] = Field(default_factory=list)
|
|
52
|
+
emotions: list[str] = Field(default_factory=list)
|
|
53
|
+
pack_suggestions: list[str] = Field(default_factory=list)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ClassificationResponse(BaseModel):
|
|
57
|
+
category: str
|
|
58
|
+
confidence: float
|
|
59
|
+
all_scores: dict[str, float]
|
|
60
|
+
raw_logits: dict[str, float] = Field(default_factory=dict)
|
|
61
|
+
top_labels: list[TopLabelEntry] = Field(default_factory=list)
|
|
62
|
+
entropy: float
|
|
63
|
+
entropy_top_k: float = 0.0
|
|
64
|
+
entropy_normalized: float = 0.0
|
|
65
|
+
confidence_margin: float
|
|
66
|
+
nsfw_score: float
|
|
67
|
+
is_nsfw: bool
|
|
68
|
+
ambiguous: bool
|
|
69
|
+
affinity_weight: float
|
|
70
|
+
affinity_weight_raw: float = 0.0
|
|
71
|
+
llm_expansion_used: bool = False
|
|
72
|
+
llm_expansion_gate_reason: str = "enabled"
|
|
73
|
+
llm_expansion: LlmExpansionPayload = Field(default_factory=LlmExpansionPayload)
|
|
74
|
+
similar_images: list[SimilarImageEntry] = Field(default_factory=list)
|
|
75
|
+
image_hash: str | None = None
|
|
76
|
+
model: str
|
|
77
|
+
device: str
|
|
78
|
+
labels: list[str]
|
|
79
|
+
filename: str | None = None
|
|
80
|
+
content_type: str | None = None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class FeedbackRequest(BaseModel):
|
|
84
|
+
image_hash: str
|
|
85
|
+
theme: str
|
|
86
|
+
accepted: bool = True
|
|
87
|
+
asset_id: str | None = None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class FeedbackResponse(BaseModel):
|
|
91
|
+
ok: bool
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _parse_labels(raw: str | None) -> list[str] | None:
|
|
95
|
+
if raw is None:
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
value = raw.strip()
|
|
99
|
+
if not value:
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
if value.startswith("["):
|
|
103
|
+
try:
|
|
104
|
+
parsed = json.loads(value)
|
|
105
|
+
except json.JSONDecodeError as error:
|
|
106
|
+
raise HTTPException(status_code=422, detail=f"labels JSON inválido: {error.msg}") from error
|
|
107
|
+
|
|
108
|
+
if not isinstance(parsed, list):
|
|
109
|
+
raise HTTPException(status_code=422, detail="labels JSON deve ser uma lista de strings.")
|
|
110
|
+
return [str(item).strip() for item in parsed if str(item).strip()]
|
|
111
|
+
|
|
112
|
+
return [item.strip() for item in value.split(",") if item.strip()]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@app.get("/health")
|
|
116
|
+
def health() -> dict[str, Any]:
|
|
117
|
+
runtime = get_classifier().runtime_info
|
|
118
|
+
return {
|
|
119
|
+
"ok": True,
|
|
120
|
+
"status": "ready",
|
|
121
|
+
"model": runtime.model_name,
|
|
122
|
+
"device": runtime.device,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@app.get("/labels")
|
|
127
|
+
def labels() -> dict[str, Any]:
|
|
128
|
+
return {
|
|
129
|
+
"ok": True,
|
|
130
|
+
"default_labels": DEFAULT_LABELS,
|
|
131
|
+
"nsfw_threshold": NSFW_THRESHOLD,
|
|
132
|
+
"top_k": CLIP_TOP_K,
|
|
133
|
+
"entropy_threshold": ENTROPY_THRESHOLD,
|
|
134
|
+
"entropy_normalized_threshold": ENTROPY_NORMALIZED_THRESHOLD,
|
|
135
|
+
"adaptive_alpha": ADAPTIVE_ALPHA,
|
|
136
|
+
"affinity_weight_cap": AFFINITY_WEIGHT_CAP,
|
|
137
|
+
"llm_expansion_min_margin": LLM_EXPANSION_MIN_MARGIN,
|
|
138
|
+
"llm_expansion_max_entropy_normalized": LLM_EXPANSION_MAX_ENTROPY_NORMALIZED,
|
|
139
|
+
"features": {
|
|
140
|
+
"embedding_cache": ENABLE_EMBEDDING_CACHE,
|
|
141
|
+
"clustering": ENABLE_CLUSTERING,
|
|
142
|
+
"adaptive_scoring": ENABLE_ADAPTIVE_SCORING,
|
|
143
|
+
"llm_label_expansion": ENABLE_LLM_LABEL_EXPANSION,
|
|
144
|
+
"llm_expansion_gating": ENABLE_LLM_EXPANSION_GATING,
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@app.post("/classify", response_model=ClassificationResponse)
|
|
150
|
+
async def classify(
|
|
151
|
+
file: UploadFile = File(...),
|
|
152
|
+
labels: str | None = Form(None),
|
|
153
|
+
nsfw_threshold: float = Form(NSFW_THRESHOLD),
|
|
154
|
+
asset_id: str | None = Form(None),
|
|
155
|
+
asset_sha256: str | None = Form(None),
|
|
156
|
+
theme: str | None = Form(None),
|
|
157
|
+
similar_threshold: float | None = Form(None),
|
|
158
|
+
similar_limit: int | None = Form(None),
|
|
159
|
+
) -> ClassificationResponse:
|
|
160
|
+
if not file.filename:
|
|
161
|
+
raise HTTPException(status_code=422, detail="Arquivo sem nome.")
|
|
162
|
+
|
|
163
|
+
if file.content_type and not file.content_type.lower().startswith("image/"):
|
|
164
|
+
raise HTTPException(status_code=415, detail=f"Tipo de arquivo não suportado: {file.content_type}")
|
|
165
|
+
|
|
166
|
+
file_bytes = await file.read()
|
|
167
|
+
custom_labels = _parse_labels(labels)
|
|
168
|
+
|
|
169
|
+
try:
|
|
170
|
+
result = classify_image_bytes(
|
|
171
|
+
file_bytes,
|
|
172
|
+
labels=custom_labels,
|
|
173
|
+
nsfw_threshold=nsfw_threshold,
|
|
174
|
+
asset_id=(asset_id or None),
|
|
175
|
+
asset_sha256=(asset_sha256 or None),
|
|
176
|
+
theme=(theme or None),
|
|
177
|
+
similar_threshold=similar_threshold,
|
|
178
|
+
similar_limit=similar_limit,
|
|
179
|
+
)
|
|
180
|
+
except ValueError as error:
|
|
181
|
+
raise HTTPException(status_code=422, detail=str(error)) from error
|
|
182
|
+
except Exception as error:
|
|
183
|
+
raise HTTPException(status_code=500, detail=f"Falha interna na classificação: {error}") from error
|
|
184
|
+
|
|
185
|
+
runtime = get_classifier().runtime_info
|
|
186
|
+
return ClassificationResponse(
|
|
187
|
+
**result,
|
|
188
|
+
model=runtime.model_name,
|
|
189
|
+
device=runtime.device,
|
|
190
|
+
labels=custom_labels or list(DEFAULT_LABELS),
|
|
191
|
+
filename=file.filename,
|
|
192
|
+
content_type=file.content_type,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@app.post("/feedback", response_model=FeedbackResponse)
|
|
197
|
+
def feedback(payload: FeedbackRequest) -> FeedbackResponse:
|
|
198
|
+
if not payload.image_hash.strip():
|
|
199
|
+
raise HTTPException(status_code=422, detail="image_hash é obrigatório.")
|
|
200
|
+
if not payload.theme.strip():
|
|
201
|
+
raise HTTPException(status_code=422, detail="theme é obrigatório.")
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
register_pack_feedback(
|
|
205
|
+
image_hash=payload.image_hash.strip().lower(),
|
|
206
|
+
theme=payload.theme.strip(),
|
|
207
|
+
accepted=bool(payload.accepted),
|
|
208
|
+
asset_id=payload.asset_id,
|
|
209
|
+
)
|
|
210
|
+
except Exception as error:
|
|
211
|
+
raise HTTPException(status_code=500, detail=f"Falha ao registrar feedback: {error}") from error
|
|
212
|
+
|
|
213
|
+
return FeedbackResponse(ok=True)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from embedding_store import EmbeddingStore
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def cosine_similarity_matrix(a: np.ndarray, b: np.ndarray) -> np.ndarray:
|
|
11
|
+
"""Compute pairwise cosine similarity between 2-D arrays."""
|
|
12
|
+
if a.ndim != 2 or b.ndim != 2:
|
|
13
|
+
raise ValueError("cosine_similarity_matrix requires 2-D arrays")
|
|
14
|
+
if a.shape[1] != b.shape[1]:
|
|
15
|
+
raise ValueError("Embedding dimensions must match")
|
|
16
|
+
|
|
17
|
+
a_norm = np.linalg.norm(a, axis=1, keepdims=True)
|
|
18
|
+
b_norm = np.linalg.norm(b, axis=1, keepdims=True)
|
|
19
|
+
|
|
20
|
+
a_safe = a / np.clip(a_norm, 1e-12, None)
|
|
21
|
+
b_safe = b / np.clip(b_norm, 1e-12, None)
|
|
22
|
+
return a_safe @ b_safe.T
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def find_similar_images(
|
|
26
|
+
*,
|
|
27
|
+
store: EmbeddingStore,
|
|
28
|
+
image_embedding: np.ndarray,
|
|
29
|
+
model_name: str,
|
|
30
|
+
threshold: float = 0.85,
|
|
31
|
+
limit: int = 25,
|
|
32
|
+
scan_limit: int = 3000,
|
|
33
|
+
source_image_hash: str | None = None,
|
|
34
|
+
) -> list[dict[str, Any]]:
|
|
35
|
+
"""Find semantically similar images from persisted embedding cache."""
|
|
36
|
+
if image_embedding.ndim != 1:
|
|
37
|
+
image_embedding = image_embedding.reshape(-1)
|
|
38
|
+
|
|
39
|
+
rows = store.list_image_embeddings(model_name=model_name, limit=scan_limit)
|
|
40
|
+
if not rows:
|
|
41
|
+
return []
|
|
42
|
+
|
|
43
|
+
candidates = []
|
|
44
|
+
vectors = []
|
|
45
|
+
for row in rows:
|
|
46
|
+
if source_image_hash and row.image_hash == source_image_hash:
|
|
47
|
+
continue
|
|
48
|
+
if row.embedding.size == 0:
|
|
49
|
+
continue
|
|
50
|
+
candidates.append(row)
|
|
51
|
+
vectors.append(row.embedding)
|
|
52
|
+
|
|
53
|
+
if not vectors:
|
|
54
|
+
return []
|
|
55
|
+
|
|
56
|
+
matrix_a = np.asarray([image_embedding.astype(np.float32)], dtype=np.float32)
|
|
57
|
+
matrix_b = np.asarray(vectors, dtype=np.float32)
|
|
58
|
+
scores = cosine_similarity_matrix(matrix_a, matrix_b).reshape(-1)
|
|
59
|
+
|
|
60
|
+
hits = []
|
|
61
|
+
for idx, score in enumerate(scores.tolist()):
|
|
62
|
+
if float(score) < float(threshold):
|
|
63
|
+
continue
|
|
64
|
+
candidate = candidates[idx]
|
|
65
|
+
hits.append(
|
|
66
|
+
{
|
|
67
|
+
"image_hash": candidate.image_hash,
|
|
68
|
+
"asset_id": candidate.asset_id,
|
|
69
|
+
"similarity": round(float(score), 6),
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
hits.sort(key=lambda entry: float(entry["similarity"]), reverse=True)
|
|
74
|
+
return hits[: max(1, min(int(limit or 25), 100))]
|
package/new-logo.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
groups:
|
|
2
|
+
- name: omnizap-db
|
|
3
|
+
rules:
|
|
4
|
+
- alert: OmniZapDBQueryOver500ms
|
|
5
|
+
expr: increase(omnizap_db_query_over_ms_total{threshold="500"}[5m]) > 0
|
|
6
|
+
for: 2m
|
|
7
|
+
labels:
|
|
8
|
+
severity: warning
|
|
9
|
+
annotations:
|
|
10
|
+
summary: "Query acima de 500ms detectada"
|
|
11
|
+
description: "Uma ou mais queries excederam 500ms nos últimos 5 minutos."
|
|
12
|
+
|
|
13
|
+
- alert: OmniZapLidMapUpsertOver1000ms
|
|
14
|
+
expr: increase(omnizap_db_query_over_ms_total{threshold="1000",table="lid_map"}[5m]) > 0
|
|
15
|
+
for: 2m
|
|
16
|
+
labels:
|
|
17
|
+
severity: critical
|
|
18
|
+
annotations:
|
|
19
|
+
summary: "UPSERT lid_map acima de 1000ms"
|
|
20
|
+
description: "UPSERTs em lid_map excederam 1000ms nos últimos 5 minutos."
|
|
21
|
+
|
|
22
|
+
- alert: OmniZapMySQLLockWaitsHigh
|
|
23
|
+
expr: rate(mysql_global_status_innodb_row_lock_waits[5m]) > 5
|
|
24
|
+
for: 5m
|
|
25
|
+
labels:
|
|
26
|
+
severity: warning
|
|
27
|
+
annotations:
|
|
28
|
+
summary: "Lock waits elevados no InnoDB"
|
|
29
|
+
description: "Taxa de lock waits acima de 5/s nos últimos 5 minutos."
|
|
30
|
+
|
|
31
|
+
- name: omnizap-queues
|
|
32
|
+
rules:
|
|
33
|
+
- alert: OmniZapMessageQueueHigh
|
|
34
|
+
expr: omnizap_queue_depth{queue="messages"} > 2000
|
|
35
|
+
for: 5m
|
|
36
|
+
labels:
|
|
37
|
+
severity: warning
|
|
38
|
+
annotations:
|
|
39
|
+
summary: "Fila de mensagens alta"
|
|
40
|
+
description: "Backlog da fila de mensagens acima de 2000."
|
|
41
|
+
|
|
42
|
+
- name: omnizap-host
|
|
43
|
+
rules:
|
|
44
|
+
- alert: OmniZapDiskUsageHigh
|
|
45
|
+
expr: (1 - (node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes{fstype!~"tmpfs|overlay"})) > 0.80
|
|
46
|
+
for: 10m
|
|
47
|
+
labels:
|
|
48
|
+
severity: critical
|
|
49
|
+
annotations:
|
|
50
|
+
summary: "Disco acima de 80%"
|
|
51
|
+
description: "Uso de disco acima de 80% por 10 minutos."
|
|
52
|
+
|
|
53
|
+
- alert: OmniZapMemoryUsageHigh
|
|
54
|
+
expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) > 0.80
|
|
55
|
+
for: 10m
|
|
56
|
+
labels:
|
|
57
|
+
severity: warning
|
|
58
|
+
annotations:
|
|
59
|
+
summary: "Memória acima de 80%"
|
|
60
|
+
description: "Uso de memória acima de 80% por 10 minutos."
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uid": "omnizap-mysql",
|
|
3
|
+
"title": "OmniZap MySQL",
|
|
4
|
+
"timezone": "browser",
|
|
5
|
+
"schemaVersion": 38,
|
|
6
|
+
"version": 3,
|
|
7
|
+
"refresh": "10s",
|
|
8
|
+
"time": {
|
|
9
|
+
"from": "now-6h",
|
|
10
|
+
"to": "now"
|
|
11
|
+
},
|
|
12
|
+
"tags": ["omnizap", "mysql"],
|
|
13
|
+
"panels": [
|
|
14
|
+
{
|
|
15
|
+
"type": "timeseries",
|
|
16
|
+
"title": "Queries/sec",
|
|
17
|
+
"datasource": "Prometheus",
|
|
18
|
+
"gridPos": { "x": 0, "y": 0, "w": 8, "h": 8 },
|
|
19
|
+
"targets": [
|
|
20
|
+
{
|
|
21
|
+
"expr": "rate(mysql_global_status_queries[5m])",
|
|
22
|
+
"legendFormat": "qps",
|
|
23
|
+
"refId": "A"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "timeseries",
|
|
29
|
+
"title": "Writes/sec",
|
|
30
|
+
"datasource": "Prometheus",
|
|
31
|
+
"gridPos": { "x": 8, "y": 0, "w": 8, "h": 8 },
|
|
32
|
+
"targets": [
|
|
33
|
+
{
|
|
34
|
+
"expr": "sum(rate(mysql_global_status_commands_total{command=~\"insert|update|delete\"}[5m])) or (sum(rate(mysql_global_status_com_insert[5m])) + sum(rate(mysql_global_status_com_update[5m])) + sum(rate(mysql_global_status_com_delete[5m]))) or vector(0)",
|
|
35
|
+
"legendFormat": "writes",
|
|
36
|
+
"refId": "A"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "timeseries",
|
|
42
|
+
"title": "Slow Queries/sec",
|
|
43
|
+
"datasource": "Prometheus",
|
|
44
|
+
"gridPos": { "x": 16, "y": 0, "w": 8, "h": 8 },
|
|
45
|
+
"targets": [
|
|
46
|
+
{
|
|
47
|
+
"expr": "rate(mysql_global_status_slow_queries[5m])",
|
|
48
|
+
"legendFormat": "slow",
|
|
49
|
+
"refId": "A"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "timeseries",
|
|
55
|
+
"title": "InnoDB Row Lock Waits/sec",
|
|
56
|
+
"datasource": "Prometheus",
|
|
57
|
+
"gridPos": { "x": 0, "y": 8, "w": 8, "h": 8 },
|
|
58
|
+
"targets": [
|
|
59
|
+
{
|
|
60
|
+
"expr": "rate(mysql_global_status_innodb_row_lock_waits[5m])",
|
|
61
|
+
"legendFormat": "waits",
|
|
62
|
+
"refId": "A"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "timeseries",
|
|
68
|
+
"title": "InnoDB Row Lock Time (ms/sec)",
|
|
69
|
+
"datasource": "Prometheus",
|
|
70
|
+
"gridPos": { "x": 8, "y": 8, "w": 8, "h": 8 },
|
|
71
|
+
"targets": [
|
|
72
|
+
{
|
|
73
|
+
"expr": "rate(mysql_global_status_innodb_row_lock_time[5m])",
|
|
74
|
+
"legendFormat": "lock_time",
|
|
75
|
+
"refId": "A"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "timeseries",
|
|
81
|
+
"title": "Buffer Pool Hit Ratio",
|
|
82
|
+
"datasource": "Prometheus",
|
|
83
|
+
"gridPos": { "x": 16, "y": 8, "w": 8, "h": 8 },
|
|
84
|
+
"targets": [
|
|
85
|
+
{
|
|
86
|
+
"expr": "1 - (rate(mysql_global_status_innodb_buffer_pool_reads[5m]) / rate(mysql_global_status_innodb_buffer_pool_read_requests[5m]))",
|
|
87
|
+
"legendFormat": "hit_ratio",
|
|
88
|
+
"refId": "A"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "timeseries",
|
|
94
|
+
"title": "InnoDB IO (bytes/sec)",
|
|
95
|
+
"datasource": "Prometheus",
|
|
96
|
+
"gridPos": { "x": 0, "y": 16, "w": 12, "h": 8 },
|
|
97
|
+
"targets": [
|
|
98
|
+
{
|
|
99
|
+
"expr": "rate(mysql_global_status_innodb_data_read[5m])",
|
|
100
|
+
"legendFormat": "read",
|
|
101
|
+
"refId": "A"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"expr": "rate(mysql_global_status_innodb_data_written[5m])",
|
|
105
|
+
"legendFormat": "write",
|
|
106
|
+
"refId": "B"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"type": "timeseries",
|
|
112
|
+
"title": "Table Latency P99 (ms)",
|
|
113
|
+
"datasource": "Prometheus",
|
|
114
|
+
"gridPos": { "x": 12, "y": 16, "w": 12, "h": 8 },
|
|
115
|
+
"targets": [
|
|
116
|
+
{
|
|
117
|
+
"expr": "histogram_quantile(0.99, sum(rate(omnizap_db_query_duration_ms_bucket[5m])) by (le, table))",
|
|
118
|
+
"legendFormat": "{{table}}",
|
|
119
|
+
"refId": "A"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "logs",
|
|
125
|
+
"title": "MySQL Slow Log",
|
|
126
|
+
"datasource": "Loki",
|
|
127
|
+
"gridPos": { "x": 0, "y": 24, "w": 24, "h": 10 },
|
|
128
|
+
"targets": [
|
|
129
|
+
{
|
|
130
|
+
"expr": "{job=\"mysql-slow\"}",
|
|
131
|
+
"refId": "A"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uid": "omnizap-overview",
|
|
3
|
+
"title": "OmniZap Overview",
|
|
4
|
+
"timezone": "browser",
|
|
5
|
+
"schemaVersion": 38,
|
|
6
|
+
"version": 1,
|
|
7
|
+
"refresh": "10s",
|
|
8
|
+
"time": {
|
|
9
|
+
"from": "now-6h",
|
|
10
|
+
"to": "now"
|
|
11
|
+
},
|
|
12
|
+
"tags": ["omnizap", "overview"],
|
|
13
|
+
"panels": [
|
|
14
|
+
{
|
|
15
|
+
"type": "timeseries",
|
|
16
|
+
"title": "Messages/sec",
|
|
17
|
+
"datasource": "Prometheus",
|
|
18
|
+
"gridPos": { "x": 0, "y": 0, "w": 8, "h": 8 },
|
|
19
|
+
"targets": [
|
|
20
|
+
{
|
|
21
|
+
"expr": "rate(omnizap_messages_upsert_messages_total[1m])",
|
|
22
|
+
"legendFormat": "{{type}}",
|
|
23
|
+
"refId": "A"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "timeseries",
|
|
29
|
+
"title": "messages.upsert P99 (ms)",
|
|
30
|
+
"datasource": "Prometheus",
|
|
31
|
+
"gridPos": { "x": 8, "y": 0, "w": 8, "h": 8 },
|
|
32
|
+
"targets": [
|
|
33
|
+
{
|
|
34
|
+
"expr": "histogram_quantile(0.99, sum(rate(omnizap_messages_upsert_duration_ms_bucket[5m])) by (le))",
|
|
35
|
+
"legendFormat": "p99",
|
|
36
|
+
"refId": "A"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "timeseries",
|
|
42
|
+
"title": "Queue Depth",
|
|
43
|
+
"datasource": "Prometheus",
|
|
44
|
+
"gridPos": { "x": 16, "y": 0, "w": 8, "h": 8 },
|
|
45
|
+
"targets": [
|
|
46
|
+
{
|
|
47
|
+
"expr": "omnizap_queue_depth",
|
|
48
|
+
"legendFormat": "{{queue}}",
|
|
49
|
+
"refId": "A"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "timeseries",
|
|
55
|
+
"title": "DB Query P99 by Table (ms)",
|
|
56
|
+
"datasource": "Prometheus",
|
|
57
|
+
"gridPos": { "x": 0, "y": 8, "w": 12, "h": 9 },
|
|
58
|
+
"targets": [
|
|
59
|
+
{
|
|
60
|
+
"expr": "histogram_quantile(0.99, sum(rate(omnizap_db_query_duration_ms_bucket[5m])) by (le, table))",
|
|
61
|
+
"legendFormat": "{{table}}",
|
|
62
|
+
"refId": "A"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "timeseries",
|
|
68
|
+
"title": "DB Errors/s",
|
|
69
|
+
"datasource": "Prometheus",
|
|
70
|
+
"gridPos": { "x": 12, "y": 8, "w": 6, "h": 9 },
|
|
71
|
+
"targets": [
|
|
72
|
+
{
|
|
73
|
+
"expr": "rate(omnizap_errors_total{scope=\"db\"}[5m])",
|
|
74
|
+
"legendFormat": "db",
|
|
75
|
+
"refId": "A"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "timeseries",
|
|
81
|
+
"title": "DB Slow Queries (>=500ms)",
|
|
82
|
+
"datasource": "Prometheus",
|
|
83
|
+
"gridPos": { "x": 18, "y": 8, "w": 6, "h": 9 },
|
|
84
|
+
"targets": [
|
|
85
|
+
{
|
|
86
|
+
"expr": "increase(omnizap_db_query_over_ms_total{threshold=\"500\"}[5m])",
|
|
87
|
+
"legendFormat": "{{table}}",
|
|
88
|
+
"refId": "A"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "timeseries",
|
|
94
|
+
"title": "CPU Usage %",
|
|
95
|
+
"datasource": "Prometheus",
|
|
96
|
+
"gridPos": { "x": 0, "y": 17, "w": 8, "h": 8 },
|
|
97
|
+
"targets": [
|
|
98
|
+
{
|
|
99
|
+
"expr": "100 - (avg(rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)",
|
|
100
|
+
"legendFormat": "cpu",
|
|
101
|
+
"refId": "A"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "timeseries",
|
|
107
|
+
"title": "Memory Usage %",
|
|
108
|
+
"datasource": "Prometheus",
|
|
109
|
+
"gridPos": { "x": 8, "y": 17, "w": 8, "h": 8 },
|
|
110
|
+
"targets": [
|
|
111
|
+
{
|
|
112
|
+
"expr": "(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100",
|
|
113
|
+
"legendFormat": "memory",
|
|
114
|
+
"refId": "A"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"type": "timeseries",
|
|
120
|
+
"title": "Disk Usage %",
|
|
121
|
+
"datasource": "Prometheus",
|
|
122
|
+
"gridPos": { "x": 16, "y": 17, "w": 8, "h": 8 },
|
|
123
|
+
"targets": [
|
|
124
|
+
{
|
|
125
|
+
"expr": "(1 - (node_filesystem_avail_bytes{fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{fstype!~\"tmpfs|overlay\"})) * 100",
|
|
126
|
+
"legendFormat": "{{mountpoint}}",
|
|
127
|
+
"refId": "A"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "timeseries",
|
|
133
|
+
"title": "Writes/sec by Table",
|
|
134
|
+
"datasource": "Prometheus",
|
|
135
|
+
"gridPos": { "x": 0, "y": 25, "w": 12, "h": 8 },
|
|
136
|
+
"targets": [
|
|
137
|
+
{
|
|
138
|
+
"expr": "rate(omnizap_db_write_total[5m])",
|
|
139
|
+
"legendFormat": "{{operation}} {{table}}",
|
|
140
|
+
"refId": "A"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"type": "timeseries",
|
|
146
|
+
"title": "Inserts/Upserts/sec (messages, chats, lid_map)",
|
|
147
|
+
"datasource": "Prometheus",
|
|
148
|
+
"gridPos": { "x": 12, "y": 25, "w": 12, "h": 8 },
|
|
149
|
+
"targets": [
|
|
150
|
+
{
|
|
151
|
+
"expr": "rate(omnizap_db_write_total{operation=~\"insert|upsert\",table=~\"messages|chats|lid_map\"}[5m])",
|
|
152
|
+
"legendFormat": "{{operation}} {{table}}",
|
|
153
|
+
"refId": "A"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "logs",
|
|
159
|
+
"title": "Top Slow Queries (Loki)",
|
|
160
|
+
"datasource": "Loki",
|
|
161
|
+
"gridPos": { "x": 0, "y": 33, "w": 24, "h": 10 },
|
|
162
|
+
"targets": [
|
|
163
|
+
{
|
|
164
|
+
"expr": "{job=\"db-monitor\"} |= \"slow\" | json | line_format \"{{.ts}} {{.durationMs}}ms {{.table}} {{.normalizedSql}}\"",
|
|
165
|
+
"refId": "A"
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|