@resolveio/server-lib 22.3.18 → 22.3.19
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/.nodemon.json +5 -0
- package/.vscode/settings.json +21 -0
- package/AGENTS.md +189 -0
- package/README.md +22 -0
- package/build_package.sh +5 -0
- package/compileDTS.pl +64 -0
- package/docs/ai-assistant-nightly-eval.md +65 -0
- package/docs/ai-assistant-preflight-checklist.md +23 -0
- package/docs/ai-assistant-report-builder-bridge-playbook.md +115 -0
- package/eslint-plugin-custom/index.js +7 -0
- package/eslint-plugin-custom/rules/no-filter-zero-index.js +44 -0
- package/eslint.config.js +103 -0
- package/gulpfile.js +216 -0
- package/methodAndPublicationListGenerator.py +344 -0
- package/mongodbensurers.js +2 -0
- package/mongostop.js +3 -0
- package/package.json +1 -1
- package/scripts/cleanup-bypassed-callmethod-logs.js +616 -0
- package/settings.development.json +25 -0
- package/settings.development.redacted.json +25 -0
- package/src/.env +12 -0
- package/src/ai/assistant-core-heuristics.ts +379 -0
- package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +185 -0
- package/src/ai/resolveio-platform-intelligence-memory.ts +325 -0
- package/{ai/resolveio-platform-intelligence-types.d.ts → src/ai/resolveio-platform-intelligence-types.ts} +20 -15
- package/src/ai/resolveio-platform-intelligence.ts +462 -0
- package/src/client-server-app.ts +12 -0
- package/src/collections/ai-terminal-conversation.collection.ts +91 -0
- package/src/collections/ai-terminal-issue-report.collection.ts +99 -0
- package/src/collections/ai-terminal-message.collection.ts +77 -0
- package/src/collections/app-setting.collection.ts +104 -0
- package/src/collections/app-status.collection.ts +58 -0
- package/src/collections/communication-metric.collection.ts +84 -0
- package/src/collections/counter.collection.ts +56 -0
- package/src/collections/cron-job-history.collection.ts +94 -0
- package/src/collections/cron-job.collection.ts +92 -0
- package/src/collections/customer-notification.collection.ts +131 -0
- package/src/collections/customer-portal-password.collection.ts +76 -0
- package/src/collections/email-history.collection.ts +127 -0
- package/src/collections/email-verified.collection.ts +62 -0
- package/src/collections/file.collection.ts +74 -0
- package/src/collections/flag-update.collection.ts +57 -0
- package/src/collections/flag.collection.ts +57 -0
- package/src/collections/log-method-latency.collection.ts +77 -0
- package/src/collections/log-subscription.collection.ts +80 -0
- package/src/collections/log.collection.ts +93 -0
- package/src/collections/logged-in-users.collection.ts +67 -0
- package/src/collections/monitor-cpu.collection.ts +65 -0
- package/src/collections/monitor-function.collection.ts +74 -0
- package/src/collections/monitor-memory.collection.ts +77 -0
- package/src/collections/monitor-mongo.collection.ts +71 -0
- package/src/collections/notification.collection.ts +57 -0
- package/src/collections/openai-usage-ledger.collection.ts +77 -0
- package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
- package/src/collections/report-builder-library.collection.ts +89 -0
- package/src/collections/report-builder-report.collection.ts +184 -0
- package/src/collections/user-group.collection.ts +89 -0
- package/src/collections/user-guide.collection.ts +57 -0
- package/src/collections/user.collection.ts +181 -0
- package/src/cron/cron.ts +117 -0
- package/src/fixtures/cron-jobs.ts +95 -0
- package/src/fixtures/init.ts +35 -0
- package/src/http/auth.ts +764 -0
- package/src/http/health.ts +7 -0
- package/src/http/home.ts +90 -0
- package/src/http/slow-query-publication.ts +49 -0
- package/src/index.ts +1 -0
- package/src/managers/ai-assistant-codex-manager.manager.ts +1131 -0
- package/src/managers/communication-metric.manager.ts +82 -0
- package/src/managers/cron.manager.ts +333 -0
- package/src/managers/customer-notification-content.manager.ts +236 -0
- package/src/managers/diagnostic-manager-bootstrap.ts +165 -0
- package/src/managers/error-auto-fix.manager.ts +2767 -0
- package/src/managers/local-log.manager.ts +113 -0
- package/src/managers/method.manager.ts +1827 -0
- package/src/managers/mongo.manager.ts +4575 -0
- package/src/managers/monitor.manager.ts +507 -0
- package/src/managers/openai-usage-ledger.manager.ts +116 -0
- package/src/managers/slow-query-verifier.manager.ts +3590 -0
- package/src/managers/slow-query.manager.ts +519 -0
- package/src/managers/subscription.manager.ts +3128 -0
- package/src/managers/websocket.manager.ts +746 -0
- package/src/managers/worker-dispatcher.manager.ts +1360 -0
- package/src/managers/worker-server.manager.ts +536 -0
- package/src/methods/accounts.ts +532 -0
- package/src/methods/ai-terminal.ts +22943 -0
- package/src/methods/app-settings.ts +114 -0
- package/src/methods/aws.ts +649 -0
- package/src/methods/collections.ts +641 -0
- package/src/methods/counters.ts +69 -0
- package/src/methods/cron-jobs.ts +2614 -0
- package/src/methods/customer-notifications.ts +458 -0
- package/src/methods/diagnostics.ts +616 -0
- package/src/methods/flag-updates.ts +7 -0
- package/src/methods/flags.ts +7 -0
- package/src/methods/logs.ts +657 -0
- package/src/methods/mongo-explorer.ts +1880 -0
- package/src/methods/monitor.ts +540 -0
- package/src/methods/pdf.ts +1236 -0
- package/src/methods/publications.ts +129 -0
- package/src/methods/report-builder.ts +3300 -0
- package/src/methods/support.ts +335 -0
- package/src/models/ai-terminal-conversation.model.ts +19 -0
- package/src/models/ai-terminal-issue-report.model.ts +21 -0
- package/src/models/ai-terminal-message.model.ts +24 -0
- package/src/models/app-setting.model.ts +17 -0
- package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
- package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
- package/src/models/collection-document.model.ts +24 -0
- package/src/models/communication-metric.model.ts +23 -0
- package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
- package/src/models/cron-job-history.model.ts +16 -0
- package/src/models/cron-job.model.ts +15 -0
- package/src/models/customer-notification.model.ts +28 -0
- package/src/models/customer-portal-password.model.ts +12 -0
- package/src/models/dialog.model.ts +25 -0
- package/{models/email-history.model.js → src/models/email-history.model.ts} +35 -4
- package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
- package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
- package/{models/flag-update.model.d.ts → src/models/flag-update.model.ts} +4 -3
- package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
- package/src/models/log-method-latency.model.ts +11 -0
- package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +11 -9
- package/src/models/log.model.ts +19 -0
- package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
- package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
- package/src/models/method.model.ts +25 -0
- package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
- package/src/models/monitor-function.model.ts +16 -0
- package/src/models/monitor-memory.model.ts +17 -0
- package/src/models/monitor-mongo.model.ts +15 -0
- package/{models/notification.model.d.ts → src/models/notification.model.ts} +6 -4
- package/src/models/openai-usage-ledger.model.ts +16 -0
- package/src/models/pagination.model.ts +35 -0
- package/src/models/permission.model.ts +14 -0
- package/src/models/report-builder-dashboard-builder.model.ts +29 -0
- package/src/models/report-builder-library.model.ts +20 -0
- package/src/models/report-builder-report.model.ts +136 -0
- package/src/models/report-builder.model.ts +68 -0
- package/src/models/select-data-label.model.ts +9 -0
- package/src/models/server-message.model.ts +31 -0
- package/src/models/slow-query-report.model.ts +23 -0
- package/src/models/subscription.model.ts +73 -0
- package/src/models/support-ticket.model.ts +104 -0
- package/src/models/user-group.model.ts +24 -0
- package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
- package/src/models/user.model.ts +96 -0
- package/src/private/images/ResolveIO.png +0 -0
- package/src/publications/ai-terminal.ts +73 -0
- package/src/publications/app-settings.ts +25 -0
- package/src/publications/app-status.ts +13 -0
- package/src/publications/cron-jobs.ts +40 -0
- package/src/publications/customer-notifications.ts +101 -0
- package/src/publications/files.ts +33 -0
- package/src/publications/flags-update.ts +19 -0
- package/src/publications/flags.ts +19 -0
- package/src/publications/logs.ts +163 -0
- package/src/publications/notifications.ts +13 -0
- package/src/publications/report-builder-dashboard-builders.ts +39 -0
- package/src/publications/report-builder-libraries.ts +41 -0
- package/src/publications/report-builder-reports.ts +47 -0
- package/src/publications/super-admin.ts +13 -0
- package/src/publications/user-groups.ts +12 -0
- package/src/publications/user-guides.ts +12 -0
- package/src/resolveio-server-app.ts +617 -0
- package/src/server-app.ts +3354 -0
- package/src/services/codex-client.ts +1223 -0
- package/src/services/openai-client.ts +265 -0
- package/src/types/error-report.ts +26 -0
- package/src/types/js-tiktoken.d.ts +11 -0
- package/src/types/slow-query-report.ts +28 -0
- package/src/util/ai-qa-policy.ts +654 -0
- package/src/util/common.ts +649 -0
- package/src/util/customer-portal-password.ts +183 -0
- package/src/util/error-reporter.ts +332 -0
- package/src/util/error-tracking.ts +79 -0
- package/src/util/report-builder-unwinds.ts +180 -0
- package/src/util/schema-report-builder.ts +448 -0
- package/src/util/slow-query-reporter.ts +216 -0
- package/src/util/subscription-dependency-context.ts +1096 -0
- package/src/util/tokenizer.ts +38 -0
- package/src/workers/codex-runner.worker.ts +142 -0
- package/start_server.sh +5 -0
- package/tests/ai-assistant-corpus-build.ts +484 -0
- package/tests/ai-assistant-corpus-replay-e2e.ts +774 -0
- package/tests/ai-assistant-data-parity-e2e.ts +1989 -0
- package/tests/ai-assistant-eval-triage.ts +831 -0
- package/tests/ai-assistant-openai-e2e.ts +1061 -0
- package/tests/ai-assistant-openai-git-e2e.ts +155 -0
- package/tests/ai-assistant-preflight-matrix.ts +215 -0
- package/tests/ai-assistant-routing-eval.test.ts +560 -0
- package/tests/ai-assistant-snf-live-eval.ts +975 -0
- package/tests/ai-assistant-utils.test.ts +2860 -0
- package/tests/ai-runner-contract.test.ts +60 -0
- package/tests/error-reporter.test.ts +145 -0
- package/tests/report-builder-linking.test.ts +79 -0
- package/tests/resolveio-platform-intelligence.test.ts +352 -0
- package/tests/server-app-cron-owner.test.ts +127 -0
- package/tests/subscription-connect-race.test.ts +158 -0
- package/tests/subscription-dependency-context.test.ts +324 -0
- package/tests/subscription-manager-collection-tracking.test.ts +86 -0
- package/tests/subscription-manager-invalidation.test.ts +86 -0
- package/tsconfig.json +34 -0
- package/ai/assistant-core-heuristics.d.ts +0 -11
- package/ai/assistant-core-heuristics.js +0 -356
- package/ai/assistant-core-heuristics.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +0 -3
- package/ai/resolveio-platform-intelligence-memory-corpus.js +0 -214
- package/ai/resolveio-platform-intelligence-memory-corpus.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory.d.ts +0 -20
- package/ai/resolveio-platform-intelligence-memory.js +0 -341
- package/ai/resolveio-platform-intelligence-memory.js.map +0 -1
- package/ai/resolveio-platform-intelligence-types.js +0 -4
- package/ai/resolveio-platform-intelligence-types.js.map +0 -1
- package/ai/resolveio-platform-intelligence.d.ts +0 -6
- package/ai/resolveio-platform-intelligence.js +0 -463
- package/ai/resolveio-platform-intelligence.js.map +0 -1
- package/client-server-app.d.ts +0 -1
- package/client-server-app.js +0 -68
- package/client-server-app.js.map +0 -1
- package/collections/ai-terminal-conversation.collection.d.ts +0 -2
- package/collections/ai-terminal-conversation.collection.js +0 -140
- package/collections/ai-terminal-conversation.collection.js.map +0 -1
- package/collections/ai-terminal-issue-report.collection.d.ts +0 -2
- package/collections/ai-terminal-issue-report.collection.js +0 -148
- package/collections/ai-terminal-issue-report.collection.js.map +0 -1
- package/collections/ai-terminal-message.collection.d.ts +0 -2
- package/collections/ai-terminal-message.collection.js +0 -121
- package/collections/ai-terminal-message.collection.js.map +0 -1
- package/collections/app-setting.collection.d.ts +0 -3
- package/collections/app-setting.collection.js +0 -103
- package/collections/app-setting.collection.js.map +0 -1
- package/collections/app-status.collection.d.ts +0 -3
- package/collections/app-status.collection.js +0 -57
- package/collections/app-status.collection.js.map +0 -1
- package/collections/communication-metric.collection.d.ts +0 -2
- package/collections/communication-metric.collection.js +0 -133
- package/collections/communication-metric.collection.js.map +0 -1
- package/collections/counter.collection.d.ts +0 -3
- package/collections/counter.collection.js +0 -56
- package/collections/counter.collection.js.map +0 -1
- package/collections/cron-job-history.collection.d.ts +0 -3
- package/collections/cron-job-history.collection.js +0 -137
- package/collections/cron-job-history.collection.js.map +0 -1
- package/collections/cron-job.collection.d.ts +0 -3
- package/collections/cron-job.collection.js +0 -92
- package/collections/cron-job.collection.js.map +0 -1
- package/collections/customer-notification.collection.d.ts +0 -3
- package/collections/customer-notification.collection.js +0 -130
- package/collections/customer-notification.collection.js.map +0 -1
- package/collections/customer-portal-password.collection.d.ts +0 -3
- package/collections/customer-portal-password.collection.js +0 -75
- package/collections/customer-portal-password.collection.js.map +0 -1
- package/collections/email-history.collection.d.ts +0 -3
- package/collections/email-history.collection.js +0 -127
- package/collections/email-history.collection.js.map +0 -1
- package/collections/email-verified.collection.d.ts +0 -3
- package/collections/email-verified.collection.js +0 -62
- package/collections/email-verified.collection.js.map +0 -1
- package/collections/file.collection.d.ts +0 -3
- package/collections/file.collection.js +0 -74
- package/collections/file.collection.js.map +0 -1
- package/collections/flag-update.collection.d.ts +0 -3
- package/collections/flag-update.collection.js +0 -57
- package/collections/flag-update.collection.js.map +0 -1
- package/collections/flag.collection.d.ts +0 -3
- package/collections/flag.collection.js +0 -57
- package/collections/flag.collection.js.map +0 -1
- package/collections/log-method-latency.collection.d.ts +0 -3
- package/collections/log-method-latency.collection.js +0 -77
- package/collections/log-method-latency.collection.js.map +0 -1
- package/collections/log-subscription.collection.d.ts +0 -3
- package/collections/log-subscription.collection.js +0 -80
- package/collections/log-subscription.collection.js.map +0 -1
- package/collections/log.collection.d.ts +0 -3
- package/collections/log.collection.js +0 -93
- package/collections/log.collection.js.map +0 -1
- package/collections/logged-in-users.collection.d.ts +0 -3
- package/collections/logged-in-users.collection.js +0 -67
- package/collections/logged-in-users.collection.js.map +0 -1
- package/collections/monitor-cpu.collection.d.ts +0 -3
- package/collections/monitor-cpu.collection.js +0 -65
- package/collections/monitor-cpu.collection.js.map +0 -1
- package/collections/monitor-function.collection.d.ts +0 -3
- package/collections/monitor-function.collection.js +0 -74
- package/collections/monitor-function.collection.js.map +0 -1
- package/collections/monitor-memory.collection.d.ts +0 -3
- package/collections/monitor-memory.collection.js +0 -77
- package/collections/monitor-memory.collection.js.map +0 -1
- package/collections/monitor-mongo.collection.d.ts +0 -3
- package/collections/monitor-mongo.collection.js +0 -71
- package/collections/monitor-mongo.collection.js.map +0 -1
- package/collections/notification.collection.d.ts +0 -3
- package/collections/notification.collection.js +0 -57
- package/collections/notification.collection.js.map +0 -1
- package/collections/openai-usage-ledger.collection.d.ts +0 -2
- package/collections/openai-usage-ledger.collection.js +0 -124
- package/collections/openai-usage-ledger.collection.js.map +0 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
- package/collections/report-builder-dashboard-builder.collection.js +0 -109
- package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
- package/collections/report-builder-library.collection.d.ts +0 -3
- package/collections/report-builder-library.collection.js +0 -87
- package/collections/report-builder-library.collection.js.map +0 -1
- package/collections/report-builder-report.collection.d.ts +0 -4
- package/collections/report-builder-report.collection.js +0 -184
- package/collections/report-builder-report.collection.js.map +0 -1
- package/collections/user-group.collection.d.ts +0 -4
- package/collections/user-group.collection.js +0 -89
- package/collections/user-group.collection.js.map +0 -1
- package/collections/user-guide.collection.d.ts +0 -3
- package/collections/user-guide.collection.js +0 -57
- package/collections/user-guide.collection.js.map +0 -1
- package/collections/user.collection.d.ts +0 -4
- package/collections/user.collection.js +0 -180
- package/collections/user.collection.js.map +0 -1
- package/cron/cron.d.ts +0 -14
- package/cron/cron.js +0 -216
- package/cron/cron.js.map +0 -1
- package/fixtures/cron-jobs.d.ts +0 -1
- package/fixtures/cron-jobs.js +0 -150
- package/fixtures/cron-jobs.js.map +0 -1
- package/fixtures/init.d.ts +0 -1
- package/fixtures/init.js +0 -91
- package/fixtures/init.js.map +0 -1
- package/http/auth.d.ts +0 -2
- package/http/auth.js +0 -906
- package/http/auth.js.map +0 -1
- package/http/health.d.ts +0 -1
- package/http/health.js +0 -11
- package/http/health.js.map +0 -1
- package/http/home.d.ts +0 -1
- package/http/home.js +0 -134
- package/http/home.js.map +0 -1
- package/http/slow-query-publication.d.ts +0 -2
- package/http/slow-query-publication.js +0 -99
- package/http/slow-query-publication.js.map +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -19
- package/index.js.map +0 -1
- package/managers/ai-assistant-codex-manager.manager.d.ts +0 -67
- package/managers/ai-assistant-codex-manager.manager.js +0 -1113
- package/managers/ai-assistant-codex-manager.manager.js.map +0 -1
- package/managers/communication-metric.manager.d.ts +0 -16
- package/managers/communication-metric.manager.js +0 -134
- package/managers/communication-metric.manager.js.map +0 -1
- package/managers/cron.manager.d.ts +0 -20
- package/managers/cron.manager.js +0 -534
- package/managers/cron.manager.js.map +0 -1
- package/managers/customer-notification-content.manager.d.ts +0 -55
- package/managers/customer-notification-content.manager.js +0 -158
- package/managers/customer-notification-content.manager.js.map +0 -1
- package/managers/diagnostic-manager-bootstrap.d.ts +0 -9
- package/managers/diagnostic-manager-bootstrap.js +0 -260
- package/managers/diagnostic-manager-bootstrap.js.map +0 -1
- package/managers/error-auto-fix.manager.d.ts +0 -149
- package/managers/error-auto-fix.manager.js +0 -3064
- package/managers/error-auto-fix.manager.js.map +0 -1
- package/managers/local-log.manager.d.ts +0 -18
- package/managers/local-log.manager.js +0 -88
- package/managers/local-log.manager.js.map +0 -1
- package/managers/method.manager.d.ts +0 -83
- package/managers/method.manager.js +0 -1941
- package/managers/method.manager.js.map +0 -1
- package/managers/mongo.manager.d.ts +0 -224
- package/managers/mongo.manager.js +0 -5000
- package/managers/mongo.manager.js.map +0 -1
- package/managers/monitor.manager.d.ts +0 -70
- package/managers/monitor.manager.js +0 -550
- package/managers/monitor.manager.js.map +0 -1
- package/managers/openai-usage-ledger.manager.d.ts +0 -15
- package/managers/openai-usage-ledger.manager.js +0 -144
- package/managers/openai-usage-ledger.manager.js.map +0 -1
- package/managers/slow-query-verifier.manager.d.ts +0 -144
- package/managers/slow-query-verifier.manager.js +0 -3857
- package/managers/slow-query-verifier.manager.js.map +0 -1
- package/managers/slow-query.manager.d.ts +0 -28
- package/managers/slow-query.manager.js +0 -468
- package/managers/slow-query.manager.js.map +0 -1
- package/managers/subscription.manager.d.ts +0 -169
- package/managers/subscription.manager.js +0 -3434
- package/managers/subscription.manager.js.map +0 -1
- package/managers/websocket.manager.d.ts +0 -73
- package/managers/websocket.manager.js +0 -673
- package/managers/websocket.manager.js.map +0 -1
- package/managers/worker-dispatcher.manager.d.ts +0 -120
- package/managers/worker-dispatcher.manager.js +0 -1266
- package/managers/worker-dispatcher.manager.js.map +0 -1
- package/managers/worker-server.manager.d.ts +0 -35
- package/managers/worker-server.manager.js +0 -582
- package/managers/worker-server.manager.js.map +0 -1
- package/methods/accounts.d.ts +0 -2
- package/methods/accounts.js +0 -624
- package/methods/accounts.js.map +0 -1
- package/methods/ai-terminal.d.ts +0 -322
- package/methods/ai-terminal.js +0 -22699
- package/methods/ai-terminal.js.map +0 -1
- package/methods/app-settings.d.ts +0 -2
- package/methods/app-settings.js +0 -169
- package/methods/app-settings.js.map +0 -1
- package/methods/aws.d.ts +0 -2
- package/methods/aws.js +0 -877
- package/methods/aws.js.map +0 -1
- package/methods/collections.d.ts +0 -2
- package/methods/collections.js +0 -719
- package/methods/collections.js.map +0 -1
- package/methods/counters.d.ts +0 -2
- package/methods/counters.js +0 -113
- package/methods/counters.js.map +0 -1
- package/methods/cron-jobs.d.ts +0 -2
- package/methods/cron-jobs.js +0 -2475
- package/methods/cron-jobs.js.map +0 -1
- package/methods/customer-notifications.d.ts +0 -2
- package/methods/customer-notifications.js +0 -528
- package/methods/customer-notifications.js.map +0 -1
- package/methods/diagnostics.d.ts +0 -2
- package/methods/diagnostics.js +0 -703
- package/methods/diagnostics.js.map +0 -1
- package/methods/flag-updates.d.ts +0 -2
- package/methods/flag-updates.js +0 -8
- package/methods/flag-updates.js.map +0 -1
- package/methods/flags.d.ts +0 -2
- package/methods/flags.js +0 -8
- package/methods/flags.js.map +0 -1
- package/methods/logs.d.ts +0 -2
- package/methods/logs.js +0 -751
- package/methods/logs.js.map +0 -1
- package/methods/mongo-explorer.d.ts +0 -2
- package/methods/mongo-explorer.js +0 -1808
- package/methods/mongo-explorer.js.map +0 -1
- package/methods/monitor.d.ts +0 -2
- package/methods/monitor.js +0 -543
- package/methods/monitor.js.map +0 -1
- package/methods/pdf.d.ts +0 -2
- package/methods/pdf.js +0 -1216
- package/methods/pdf.js.map +0 -1
- package/methods/publications.d.ts +0 -1
- package/methods/publications.js +0 -183
- package/methods/publications.js.map +0 -1
- package/methods/report-builder.d.ts +0 -2
- package/methods/report-builder.js +0 -3094
- package/methods/report-builder.js.map +0 -1
- package/methods/support.d.ts +0 -2
- package/methods/support.js +0 -430
- package/methods/support.js.map +0 -1
- package/models/ai-terminal-conversation.model.d.ts +0 -17
- package/models/ai-terminal-conversation.model.js +0 -4
- package/models/ai-terminal-conversation.model.js.map +0 -1
- package/models/ai-terminal-issue-report.model.d.ts +0 -19
- package/models/ai-terminal-issue-report.model.js +0 -4
- package/models/ai-terminal-issue-report.model.js.map +0 -1
- package/models/ai-terminal-message.model.d.ts +0 -22
- package/models/ai-terminal-message.model.js +0 -4
- package/models/ai-terminal-message.model.js.map +0 -1
- package/models/app-setting.model.d.ts +0 -16
- package/models/app-setting.model.js +0 -4
- package/models/app-setting.model.js.map +0 -1
- package/models/app-status.model.js +0 -4
- package/models/app-status.model.js.map +0 -1
- package/models/billing-logged-in-users.model.js +0 -4
- package/models/billing-logged-in-users.model.js.map +0 -1
- package/models/collection-document.model.d.ts +0 -21
- package/models/collection-document.model.js +0 -4
- package/models/collection-document.model.js.map +0 -1
- package/models/communication-metric.model.d.ts +0 -20
- package/models/communication-metric.model.js +0 -4
- package/models/communication-metric.model.js.map +0 -1
- package/models/counter.model.js +0 -4
- package/models/counter.model.js.map +0 -1
- package/models/cron-job-history.model.d.ts +0 -15
- package/models/cron-job-history.model.js +0 -4
- package/models/cron-job-history.model.js.map +0 -1
- package/models/cron-job.model.d.ts +0 -14
- package/models/cron-job.model.js +0 -4
- package/models/cron-job.model.js.map +0 -1
- package/models/customer-notification.model.d.ts +0 -26
- package/models/customer-notification.model.js +0 -4
- package/models/customer-notification.model.js.map +0 -1
- package/models/customer-portal-password.model.d.ts +0 -11
- package/models/customer-portal-password.model.js +0 -4
- package/models/customer-portal-password.model.js.map +0 -1
- package/models/dialog.model.d.ts +0 -23
- package/models/dialog.model.js +0 -4
- package/models/dialog.model.js.map +0 -1
- package/models/email-history.model.d.ts +0 -31
- package/models/email-history.model.js.map +0 -1
- package/models/email-verified.model.js +0 -4
- package/models/email-verified.model.js.map +0 -1
- package/models/file.model.js +0 -4
- package/models/file.model.js.map +0 -1
- package/models/flag-update.model.js +0 -4
- package/models/flag-update.model.js.map +0 -1
- package/models/flag.model.js +0 -4
- package/models/flag.model.js.map +0 -1
- package/models/log-method-latency.model.d.ts +0 -10
- package/models/log-method-latency.model.js +0 -4
- package/models/log-method-latency.model.js.map +0 -1
- package/models/log-subscription.model.js +0 -4
- package/models/log-subscription.model.js.map +0 -1
- package/models/log.model.d.ts +0 -17
- package/models/log.model.js +0 -4
- package/models/log.model.js.map +0 -1
- package/models/logged-in-users.model.js +0 -4
- package/models/logged-in-users.model.js.map +0 -1
- package/models/method-response.model.js +0 -4
- package/models/method-response.model.js.map +0 -1
- package/models/method.model.d.ts +0 -26
- package/models/method.model.js +0 -4
- package/models/method.model.js.map +0 -1
- package/models/monitor-cpu.model.js +0 -4
- package/models/monitor-cpu.model.js.map +0 -1
- package/models/monitor-function.model.d.ts +0 -14
- package/models/monitor-function.model.js +0 -4
- package/models/monitor-function.model.js.map +0 -1
- package/models/monitor-memory.model.d.ts +0 -15
- package/models/monitor-memory.model.js +0 -4
- package/models/monitor-memory.model.js.map +0 -1
- package/models/monitor-mongo.model.d.ts +0 -13
- package/models/monitor-mongo.model.js +0 -4
- package/models/monitor-mongo.model.js.map +0 -1
- package/models/notification.model.js +0 -4
- package/models/notification.model.js.map +0 -1
- package/models/openai-usage-ledger.model.d.ts +0 -15
- package/models/openai-usage-ledger.model.js +0 -4
- package/models/openai-usage-ledger.model.js.map +0 -1
- package/models/pagination.model.d.ts +0 -11
- package/models/pagination.model.js +0 -28
- package/models/pagination.model.js.map +0 -1
- package/models/permission.model.d.ts +0 -12
- package/models/permission.model.js +0 -4
- package/models/permission.model.js.map +0 -1
- package/models/report-builder-dashboard-builder.model.d.ts +0 -25
- package/models/report-builder-dashboard-builder.model.js +0 -4
- package/models/report-builder-dashboard-builder.model.js.map +0 -1
- package/models/report-builder-library.model.d.ts +0 -17
- package/models/report-builder-library.model.js +0 -4
- package/models/report-builder-library.model.js.map +0 -1
- package/models/report-builder-report.model.d.ts +0 -121
- package/models/report-builder-report.model.js +0 -4
- package/models/report-builder-report.model.js.map +0 -1
- package/models/report-builder.model.d.ts +0 -61
- package/models/report-builder.model.js +0 -4
- package/models/report-builder.model.js.map +0 -1
- package/models/select-data-label.model.d.ts +0 -9
- package/models/select-data-label.model.js +0 -4
- package/models/select-data-label.model.js.map +0 -1
- package/models/server-message.model.d.ts +0 -32
- package/models/server-message.model.js +0 -4
- package/models/server-message.model.js.map +0 -1
- package/models/slow-query-report.model.d.ts +0 -23
- package/models/slow-query-report.model.js +0 -4
- package/models/slow-query-report.model.js.map +0 -1
- package/models/subscription.model.d.ts +0 -31
- package/models/subscription.model.js +0 -4
- package/models/subscription.model.js.map +0 -1
- package/models/support-ticket.model.d.ts +0 -87
- package/models/support-ticket.model.js +0 -4
- package/models/support-ticket.model.js.map +0 -1
- package/models/user-group.model.d.ts +0 -20
- package/models/user-group.model.js +0 -4
- package/models/user-group.model.js.map +0 -1
- package/models/user-guide.model.js +0 -4
- package/models/user-guide.model.js.map +0 -1
- package/models/user.model.d.ts +0 -84
- package/models/user.model.js +0 -4
- package/models/user.model.js.map +0 -1
- package/private/images/ResolveIO.png +0 -0
- package/public_api.js +0 -112
- package/public_api.js.map +0 -1
- package/publications/ai-terminal.d.ts +0 -1
- package/publications/ai-terminal.js +0 -122
- package/publications/ai-terminal.js.map +0 -1
- package/publications/app-settings.d.ts +0 -2
- package/publications/app-settings.js +0 -28
- package/publications/app-settings.js.map +0 -1
- package/publications/app-status.d.ts +0 -2
- package/publications/app-status.js +0 -16
- package/publications/app-status.js.map +0 -1
- package/publications/cron-jobs.d.ts +0 -2
- package/publications/cron-jobs.js +0 -88
- package/publications/cron-jobs.js.map +0 -1
- package/publications/customer-notifications.d.ts +0 -2
- package/publications/customer-notifications.js +0 -161
- package/publications/customer-notifications.js.map +0 -1
- package/publications/files.d.ts +0 -2
- package/publications/files.js +0 -36
- package/publications/files.js.map +0 -1
- package/publications/flags-update.d.ts +0 -2
- package/publications/flags-update.js +0 -22
- package/publications/flags-update.js.map +0 -1
- package/publications/flags.d.ts +0 -2
- package/publications/flags.js +0 -22
- package/publications/flags.js.map +0 -1
- package/publications/logs.d.ts +0 -2
- package/publications/logs.js +0 -164
- package/publications/logs.js.map +0 -1
- package/publications/notifications.d.ts +0 -2
- package/publications/notifications.js +0 -16
- package/publications/notifications.js.map +0 -1
- package/publications/report-builder-dashboard-builders.d.ts +0 -2
- package/publications/report-builder-dashboard-builders.js +0 -42
- package/publications/report-builder-dashboard-builders.js.map +0 -1
- package/publications/report-builder-libraries.d.ts +0 -2
- package/publications/report-builder-libraries.js +0 -90
- package/publications/report-builder-libraries.js.map +0 -1
- package/publications/report-builder-reports.d.ts +0 -2
- package/publications/report-builder-reports.js +0 -50
- package/publications/report-builder-reports.js.map +0 -1
- package/publications/super-admin.d.ts +0 -2
- package/publications/super-admin.js +0 -16
- package/publications/super-admin.js.map +0 -1
- package/publications/user-groups.d.ts +0 -1
- package/publications/user-groups.js +0 -16
- package/publications/user-groups.js.map +0 -1
- package/publications/user-guides.d.ts +0 -1
- package/publications/user-guides.js +0 -16
- package/publications/user-guides.js.map +0 -1
- package/resolveio-server-app.d.ts +0 -70
- package/resolveio-server-app.js +0 -801
- package/resolveio-server-app.js.map +0 -1
- package/server-app.d.ts +0 -228
- package/server-app.js +0 -3566
- package/server-app.js.map +0 -1
- package/services/codex-client.d.ts +0 -126
- package/services/codex-client.js +0 -1622
- package/services/codex-client.js.map +0 -1
- package/services/openai-client.d.ts +0 -46
- package/services/openai-client.js +0 -318
- package/services/openai-client.js.map +0 -1
- package/types/error-report.d.ts +0 -25
- package/types/error-report.js +0 -4
- package/types/error-report.js.map +0 -1
- package/types/slow-query-report.d.ts +0 -27
- package/types/slow-query-report.js +0 -6
- package/types/slow-query-report.js.map +0 -1
- package/util/ai-qa-policy.d.ts +0 -94
- package/util/ai-qa-policy.js +0 -505
- package/util/ai-qa-policy.js.map +0 -1
- package/util/common.d.ts +0 -31
- package/util/common.js +0 -683
- package/util/common.js.map +0 -1
- package/util/customer-portal-password.d.ts +0 -13
- package/util/customer-portal-password.js +0 -209
- package/util/customer-portal-password.js.map +0 -1
- package/util/error-reporter.d.ts +0 -52
- package/util/error-reporter.js +0 -326
- package/util/error-reporter.js.map +0 -1
- package/util/error-tracking.d.ts +0 -13
- package/util/error-tracking.js +0 -120
- package/util/error-tracking.js.map +0 -1
- package/util/report-builder-unwinds.d.ts +0 -15
- package/util/report-builder-unwinds.js +0 -156
- package/util/report-builder-unwinds.js.map +0 -1
- package/util/schema-report-builder.d.ts +0 -6
- package/util/schema-report-builder.js +0 -481
- package/util/schema-report-builder.js.map +0 -1
- package/util/slow-query-reporter.d.ts +0 -28
- package/util/slow-query-reporter.js +0 -226
- package/util/slow-query-reporter.js.map +0 -1
- package/util/subscription-dependency-context.d.ts +0 -34
- package/util/subscription-dependency-context.js +0 -1283
- package/util/subscription-dependency-context.js.map +0 -1
- package/util/tokenizer.d.ts +0 -5
- package/util/tokenizer.js +0 -41
- package/util/tokenizer.js.map +0 -1
- package/workers/codex-runner.worker.d.ts +0 -1
- package/workers/codex-runner.worker.js +0 -192
- package/workers/codex-runner.worker.js.map +0 -1
- /package/{private → src/private}/email-templates/enrollment.html +0 -0
- /package/{private → src/private}/email-templates/forgot-password.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket.html +0 -0
- /package/{public_api.d.ts → src/public_api.ts} +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export function normalizeLookupField(path: string) {
|
|
2
|
+
if (!path) {
|
|
3
|
+
return path;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let cleaned = path.replace(/\.\$/g, '');
|
|
7
|
+
cleaned = cleaned.replace(/^[^\.]*\(.*?Lookup.*?\)\.?/, '');
|
|
8
|
+
|
|
9
|
+
return cleaned;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function buildSafeSizeExpression(sourceExpr: string) {
|
|
13
|
+
return {$size: {$cond: [{$isArray: sourceExpr}, sourceExpr, []]}};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ensureLookupLocalKeyUnwinds(options: {query: any[]; sizes: string[]; lookupLocalKey: string; lookupAs?: string}) {
|
|
17
|
+
const {query, sizes, lookupLocalKey, lookupAs = ''} = options || {};
|
|
18
|
+
|
|
19
|
+
if (!lookupLocalKey || typeof lookupLocalKey !== 'string') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!query || !Array.isArray(query) || !sizes || !Array.isArray(sizes)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let unwindPathSeed = lookupLocalKey;
|
|
28
|
+
|
|
29
|
+
// Some lookup local keys are stored without `.$` even when sourced from array paths.
|
|
30
|
+
// Infer the array segment from lookup alias and synthesize the unwind marker.
|
|
31
|
+
if (!unwindPathSeed.includes('.$') && typeof lookupAs === 'string' && lookupAs.includes('.$.')) {
|
|
32
|
+
const inferredArrayPrefix = lookupAs.split('.$.')[0];
|
|
33
|
+
if (inferredArrayPrefix) {
|
|
34
|
+
if (unwindPathSeed.startsWith(inferredArrayPrefix + '.')) {
|
|
35
|
+
unwindPathSeed = inferredArrayPrefix + '.$.' + unwindPathSeed.substring(inferredArrayPrefix.length + 1);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
unwindPathSeed = inferredArrayPrefix + '.$';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!unwindPathSeed.includes('.$')) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const fieldData = unwindPathSeed.split('.$');
|
|
48
|
+
let fieldPath = '';
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < fieldData.length - 1; i++) {
|
|
51
|
+
fieldPath += fieldData[i];
|
|
52
|
+
const sizeKey = fieldPath.replace(/\./g, '_');
|
|
53
|
+
if (!sizes.includes(sizeKey)) {
|
|
54
|
+
sizes.push(sizeKey);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!query.some(a => a && a.$addFields && Object.keys(a.$addFields).includes('size_' + sizeKey))) {
|
|
58
|
+
const sourceExpr = '$' + fieldPath;
|
|
59
|
+
query.push({$addFields: {['size_' + sizeKey]: buildSafeSizeExpression(sourceExpr)}});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const unwindPath = '$' + fieldPath;
|
|
63
|
+
if (!query.some(a => a && a.$unwind && a.$unwind.path === unwindPath)) {
|
|
64
|
+
query.push({'$unwind': {path: unwindPath, preserveNullAndEmptyArrays: true}});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function applyLinkFieldUnwinds(options: {
|
|
70
|
+
query: any[];
|
|
71
|
+
sizes: string[];
|
|
72
|
+
fieldsLink: any[];
|
|
73
|
+
selectedFields?: any[];
|
|
74
|
+
filterArrayFields?: any[];
|
|
75
|
+
groupsRow?: any[];
|
|
76
|
+
}) {
|
|
77
|
+
const {query, sizes, fieldsLink, selectedFields = [], filterArrayFields = [], groupsRow = []} = options || {};
|
|
78
|
+
|
|
79
|
+
if (!query || !Array.isArray(query) || !sizes || !Array.isArray(sizes) || !Array.isArray(fieldsLink) || !fieldsLink.length) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const leafByPath = new Map<string, any>();
|
|
84
|
+
|
|
85
|
+
(selectedFields || []).forEach(field => {
|
|
86
|
+
if (field?.fieldPath && !leafByPath.has(field.fieldPath)) {
|
|
87
|
+
leafByPath.set(field.fieldPath, field);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
(filterArrayFields || []).forEach(field => {
|
|
92
|
+
if (field?.fieldPath && !leafByPath.has(field.fieldPath)) {
|
|
93
|
+
leafByPath.set(field.fieldPath, field);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
(groupsRow || []).forEach(group => {
|
|
98
|
+
if (group?.treeItem?.fieldPath && !leafByPath.has(group.treeItem.fieldPath)) {
|
|
99
|
+
leafByPath.set(group.treeItem.fieldPath, group.treeItem);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const hasUnwindPath = (unwindPath: string) => {
|
|
104
|
+
return query.some(a => a && a.$unwind && a.$unwind.path === unwindPath);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const ensureUnwindsForPath = (targetPath: string) => {
|
|
108
|
+
if (!targetPath || typeof targetPath !== 'string' || !targetPath.includes('.$')) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const leaf = leafByPath.get(targetPath);
|
|
113
|
+
|
|
114
|
+
const fieldData = targetPath.split('.$');
|
|
115
|
+
let fieldPath = '';
|
|
116
|
+
|
|
117
|
+
for (let i = 0; i < fieldData.length - 1; i++) {
|
|
118
|
+
fieldPath += fieldData[i];
|
|
119
|
+
|
|
120
|
+
const lastSegment = fieldPath.split('.$')[fieldPath.split('.$').length - 1];
|
|
121
|
+
const hasLookup = (lastSegment || '').includes('(Lookup') || (leaf?.lookup_as && fieldPath === leaf.lookup_as);
|
|
122
|
+
|
|
123
|
+
if (hasLookup && leaf?.lookup_collection && leaf?.lookup_as) {
|
|
124
|
+
ensureLookupLocalKeyUnwinds({
|
|
125
|
+
query,
|
|
126
|
+
sizes,
|
|
127
|
+
lookupLocalKey: leaf.lookup_local_key || '',
|
|
128
|
+
lookupAs: leaf.lookup_as || ''
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const lookupAsRaw = leaf.lookup_as || '';
|
|
132
|
+
const lookupAs = lookupAsRaw.replace(/\.\$/g, '');
|
|
133
|
+
const hasLookupStage = query.some(a => a && a.$lookup && a.$lookup.as === lookupAs);
|
|
134
|
+
|
|
135
|
+
if (!hasLookupStage) {
|
|
136
|
+
query.push({$lookup: {
|
|
137
|
+
from: leaf.lookup_collection,
|
|
138
|
+
localField: normalizeLookupField(leaf.lookup_local_key || ''),
|
|
139
|
+
foreignField: normalizeLookupField(leaf.lookup_foreign_key || ''),
|
|
140
|
+
as: lookupAs
|
|
141
|
+
}});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const sizeKey = lookupAsRaw.replace(/\.\$\./g, '_').replace(/\./g, '_');
|
|
145
|
+
if (!query.some(a => a && a.$addFields && Object.keys(a.$addFields).includes('size_' + sizeKey))) {
|
|
146
|
+
sizes.push(sizeKey);
|
|
147
|
+
const sourceExpr = '$' + lookupAs;
|
|
148
|
+
query.push({$addFields: {['size_' + sizeKey]: buildSafeSizeExpression(sourceExpr)}});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const unwindPath = '$' + lookupAs;
|
|
152
|
+
if (!hasUnwindPath(unwindPath)) {
|
|
153
|
+
query.push({'$unwind': {path: unwindPath, preserveNullAndEmptyArrays: true}});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const sizeKey = fieldPath.replace(/\.\$\./g, '.').replace(/\./g, '_');
|
|
158
|
+
if (!query.some(a => a && a.$addFields && Object.keys(a.$addFields).includes('size_' + sizeKey))) {
|
|
159
|
+
sizes.push(sizeKey);
|
|
160
|
+
const sourceExpr = '$' + fieldPath.replace(/\.\$\./g, '.');
|
|
161
|
+
query.push({$addFields: {['size_' + sizeKey]: buildSafeSizeExpression(sourceExpr)}});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const unwindPath = '$' + fieldPath.replace(/\.\$\./g, '.');
|
|
165
|
+
if (!hasUnwindPath(unwindPath)) {
|
|
166
|
+
query.push({'$unwind': {path: unwindPath, preserveNullAndEmptyArrays: true}});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fieldPath += '.$';
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
(fieldsLink || [])
|
|
175
|
+
.filter(a => a && a.field_first && a.field_second)
|
|
176
|
+
.forEach(link => {
|
|
177
|
+
ensureUnwindsForPath(link.field_first);
|
|
178
|
+
ensureUnwindsForPath(link.field_second);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { CollectionTree } from '../models/report-builder.model';
|
|
2
|
+
import { ResolveIOServer } from '../resolveio-server-app';
|
|
3
|
+
import { toTitleCase } from './common';
|
|
4
|
+
|
|
5
|
+
function assertLookupCollection(collectionName: string, referringField?: string) {
|
|
6
|
+
let collectionModel = ResolveIOServer.getMongoManager().collection(collectionName);
|
|
7
|
+
|
|
8
|
+
if (!collectionModel) {
|
|
9
|
+
let context = referringField ? ` referenced by '${referringField}'` : '';
|
|
10
|
+
throw new Error(`Report Builder: collection '${collectionName}'${context} is not registered.`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!collectionModel.useRB || !collectionModel.rbSchema) {
|
|
14
|
+
let context = referringField ? ` referenced by '${referringField}'` : '';
|
|
15
|
+
throw new Error(`Report Builder: collection '${collectionName}'${context} is not configured for Report Builder.`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return collectionModel;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getReportLookupSchemas(collection_root: string) {
|
|
22
|
+
let lookupTrees: CollectionTree[] = [];
|
|
23
|
+
let processedCollections = new Set<string>();
|
|
24
|
+
let pendingCollections: Array<{ name: string; isRoot: boolean; referringField?: string }> = [{ name: collection_root, isRoot: true }];
|
|
25
|
+
|
|
26
|
+
while (pendingCollections.length) {
|
|
27
|
+
let current = pendingCollections.shift();
|
|
28
|
+
|
|
29
|
+
if (!current) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (processedCollections.has(current.name)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let collectionModel = assertLookupCollection(current.name, current.referringField);
|
|
38
|
+
let schemaObj = collectionModel.rbSchema;
|
|
39
|
+
|
|
40
|
+
lookupTrees.push({ collection_name: current.name, tree: schemaObj, is_root: current.isRoot });
|
|
41
|
+
processedCollections.add(current.name);
|
|
42
|
+
|
|
43
|
+
Object.keys(schemaObj).forEach(field => {
|
|
44
|
+
if (schemaObj[field].lookup_collection && !processedCollections.has(schemaObj[field].lookup_collection)) {
|
|
45
|
+
pendingCollections.push({
|
|
46
|
+
name: schemaObj[field].lookup_collection,
|
|
47
|
+
isRoot: false,
|
|
48
|
+
referringField: `${current.name}.${field}`
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return lookupTrees;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function buildTree(current_root, schemaTree, lookup?) {
|
|
58
|
+
let res = [];
|
|
59
|
+
|
|
60
|
+
Object.keys(schemaTree).filter(a => a !== '__v').forEach(key => {
|
|
61
|
+
// Object.keys(schemaTree).filter(a => a !== '__v').forEach(key => {
|
|
62
|
+
if (!lookup || (lookup && !schemaTree[key].lookup_collection)) {
|
|
63
|
+
let treeItemSplit = key.split('.');
|
|
64
|
+
|
|
65
|
+
// debugger;
|
|
66
|
+
|
|
67
|
+
if (treeItemSplit.length === 1) {
|
|
68
|
+
if (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {
|
|
69
|
+
res.push({
|
|
70
|
+
collection_name: current_root,
|
|
71
|
+
columnName: toTitleCase(key.replace(/\_/g, ' ')),
|
|
72
|
+
fieldName: key,
|
|
73
|
+
fieldType: schemaTree[key].rbType,
|
|
74
|
+
fieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),
|
|
75
|
+
distinctFieldValues: [],
|
|
76
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
77
|
+
fieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
78
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
79
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
80
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
81
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
82
|
+
text: toTitleCase(key.replace(/\_/g, ' ')),
|
|
83
|
+
value: key,
|
|
84
|
+
isLeaf: true,
|
|
85
|
+
isActive: false,
|
|
86
|
+
isSelected: false,
|
|
87
|
+
depth: 0,
|
|
88
|
+
leafValueType: '',
|
|
89
|
+
leafValueTypes: getLeafValueTypes(schemaTree[key], key),
|
|
90
|
+
leafFormatType: '',
|
|
91
|
+
leafFormatTypes: getLeafFormatTypes(schemaTree[key], key)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
res.push({
|
|
96
|
+
collection_name: current_root,
|
|
97
|
+
columnName: toTitleCase(key.replace(/\_/g, ' ')),
|
|
98
|
+
fieldName: key,
|
|
99
|
+
fieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,
|
|
100
|
+
fieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),
|
|
101
|
+
distinctFieldValues: [],
|
|
102
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
103
|
+
fieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
104
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
105
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
106
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
107
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
108
|
+
text: toTitleCase(key.replace(/\_/g, ' ')),
|
|
109
|
+
value: key,
|
|
110
|
+
isLeaf: false,
|
|
111
|
+
isActive: false,
|
|
112
|
+
isSelected: false,
|
|
113
|
+
depth: 0,
|
|
114
|
+
leafValueType: '',
|
|
115
|
+
leafFormatType: '',
|
|
116
|
+
children: []
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
res = res.sort((a, b) => a.fieldName.localeCompare(b.fieldName));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
let child = null;
|
|
124
|
+
|
|
125
|
+
treeItemSplit.forEach((layer, index) => {
|
|
126
|
+
if (!child) {
|
|
127
|
+
child = res.find(a => a.fieldName === layer);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (child.children.find(a => a.fieldName === layer)) {
|
|
131
|
+
child = child.children.find(a => a.fieldName === layer);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {
|
|
135
|
+
child.children.push({
|
|
136
|
+
collection_name: current_root,
|
|
137
|
+
columnName: toTitleCase(key.replace(/\_/g, ' ')),
|
|
138
|
+
fieldName: layer,
|
|
139
|
+
fieldType: schemaTree[key].rbType,
|
|
140
|
+
fieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),
|
|
141
|
+
distinctFieldValues: [],
|
|
142
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
143
|
+
fieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
144
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
145
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
146
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
147
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
148
|
+
text: toTitleCase(layer.replace(/\_/g, ' ')),
|
|
149
|
+
value: layer,
|
|
150
|
+
isLeaf: true,
|
|
151
|
+
isActive: false,
|
|
152
|
+
isSelected: false,
|
|
153
|
+
depth: index,
|
|
154
|
+
leafValueType: '',
|
|
155
|
+
leafValueTypes: getLeafValueTypes(schemaTree[key], key),
|
|
156
|
+
leafFormatType: '',
|
|
157
|
+
leafFormatTypes: getLeafFormatTypes(schemaTree[key], key)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
child.children.push({
|
|
162
|
+
collection_name: current_root,
|
|
163
|
+
columnName: toTitleCase(key.replace(/\_/g, ' ')),
|
|
164
|
+
fieldName: layer,
|
|
165
|
+
fieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,
|
|
166
|
+
fieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),
|
|
167
|
+
distinctFieldValues: [],
|
|
168
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
169
|
+
fieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
170
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
171
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
172
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
173
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
174
|
+
text: toTitleCase(layer.replace(/\_/g, ' ')),
|
|
175
|
+
value: layer,
|
|
176
|
+
isLeaf: false,
|
|
177
|
+
isActive: false,
|
|
178
|
+
isSelected: false,
|
|
179
|
+
depth: index,
|
|
180
|
+
leafValueType: '',
|
|
181
|
+
leafFormatType: '',
|
|
182
|
+
children: []
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
child.children = child.children.sort((a, b) => a.fieldName.localeCompare(b.fieldName));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return res;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// eslint-disable-next-line no-unused-vars
|
|
198
|
+
export function getLeafValueTypes(schemaTree, fieldPath) {
|
|
199
|
+
let leafTypes = [];
|
|
200
|
+
|
|
201
|
+
if (schemaTree.rbType === 'String') {
|
|
202
|
+
leafTypes = [
|
|
203
|
+
{
|
|
204
|
+
text: 'As Value',
|
|
205
|
+
value: 'Value'
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
text: 'Unique',
|
|
209
|
+
value: 'Unique'
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
text: 'As Count',
|
|
213
|
+
value: 'Count'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
text: 'First',
|
|
217
|
+
value: 'First'
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
text: 'Last',
|
|
221
|
+
value: 'Last'
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
else if (schemaTree.rbType === 'Number') {
|
|
226
|
+
leafTypes = [
|
|
227
|
+
{
|
|
228
|
+
text: 'As Value',
|
|
229
|
+
value: 'Value'
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
text: 'Unique',
|
|
233
|
+
value: 'Unique'
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
text: 'As Average',
|
|
237
|
+
value: 'Average'
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
text: 'As Count',
|
|
241
|
+
value: 'Count'
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
text: 'As Sum',
|
|
245
|
+
value: 'Sum'
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
text: 'Minimum',
|
|
249
|
+
value: 'Minimum'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
text: 'Maximum',
|
|
253
|
+
value: 'Maximum'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
text: 'First',
|
|
257
|
+
value: 'First'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
text: 'Last',
|
|
261
|
+
value: 'Last'
|
|
262
|
+
}
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
else if (schemaTree.rbType === 'Boolean') {
|
|
266
|
+
leafTypes = [
|
|
267
|
+
{
|
|
268
|
+
text: 'As Value',
|
|
269
|
+
value: 'Value'
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
text: 'Unique',
|
|
273
|
+
value: 'Unique'
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
text: 'As Count',
|
|
277
|
+
value: 'Count'
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
text: 'First',
|
|
281
|
+
value: 'First'
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
text: 'Last',
|
|
285
|
+
value: 'Last'
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
else if (schemaTree.rbType === 'Date') {
|
|
290
|
+
leafTypes = [
|
|
291
|
+
{
|
|
292
|
+
text: 'As Value',
|
|
293
|
+
value: 'Value'
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
text: 'Unique',
|
|
297
|
+
value: 'Unique'
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
text: 'As Count',
|
|
301
|
+
value: 'Count'
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
text: 'Minimum',
|
|
305
|
+
value: 'Minimum'
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
text: 'Maximum',
|
|
309
|
+
value: 'Maximum'
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
text: 'First',
|
|
313
|
+
value: 'First'
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
text: 'Last',
|
|
317
|
+
value: 'Last'
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
return leafTypes;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// eslint-disable-next-line no-unused-vars
|
|
325
|
+
export function getLeafFormatTypes(schemaTree, fieldPath) {
|
|
326
|
+
let leafTypes = [];
|
|
327
|
+
|
|
328
|
+
if (schemaTree.rbType === 'String') {
|
|
329
|
+
leafTypes = [
|
|
330
|
+
{
|
|
331
|
+
text: 'As Text',
|
|
332
|
+
value: 'String'
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
text: 'As Number',
|
|
336
|
+
value: 'Number'
|
|
337
|
+
}
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
else if (schemaTree.rbType === 'Number') {
|
|
341
|
+
leafTypes = [
|
|
342
|
+
{
|
|
343
|
+
text: 'As Number',
|
|
344
|
+
value: 'Number'
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
text: 'As Currency',
|
|
348
|
+
value: 'Currency'
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
text: 'As Text',
|
|
352
|
+
value: 'String'
|
|
353
|
+
}
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
else if (schemaTree.rbType === 'Boolean') {
|
|
357
|
+
leafTypes = [
|
|
358
|
+
{
|
|
359
|
+
text: 'As Number',
|
|
360
|
+
value: 'Number'
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
text: 'As Boolean (True/False)',
|
|
364
|
+
value: 'Boolean'
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
text: 'As Text (Yes/No)',
|
|
368
|
+
value: 'String'
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
text: 'As Number (1/0)',
|
|
372
|
+
value: 'Boolean_Number'
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
else if (schemaTree.rbType === 'Date') {
|
|
377
|
+
leafTypes = [
|
|
378
|
+
{
|
|
379
|
+
text: 'As Number',
|
|
380
|
+
value: 'Number'
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
text: 'As Date (Short Format)',
|
|
384
|
+
value: 'Date'
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
text: 'As Time (Short Format)',
|
|
388
|
+
value: 'Time'
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
text: 'As Date/Time (Short Format)',
|
|
392
|
+
value: 'DateTime'
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
text: 'As Date (Long Format)',
|
|
396
|
+
value: 'Date_long'
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
text: 'As Date/Time (Long Format)',
|
|
400
|
+
value: 'DateTime_long'
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
text: 'As Timestamp (MS since 1970)',
|
|
404
|
+
value: 'Timestamp'
|
|
405
|
+
}
|
|
406
|
+
];
|
|
407
|
+
}
|
|
408
|
+
return leafTypes;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
export async function mongoCommand(commandstr: string, collection: string, field?: any) {
|
|
416
|
+
let tmpObj;
|
|
417
|
+
try {
|
|
418
|
+
// Count the number of non-empty fields in a given collection:
|
|
419
|
+
if (commandstr === 'count') {
|
|
420
|
+
let obj = {
|
|
421
|
+
count: collection,
|
|
422
|
+
query: {}
|
|
423
|
+
};
|
|
424
|
+
obj.query[field] = {$ne: null};
|
|
425
|
+
tmpObj = await ResolveIOServer.getMainDB().command(obj);
|
|
426
|
+
}
|
|
427
|
+
// Get all distinct values in a given field.
|
|
428
|
+
else if (commandstr === 'distinct') {
|
|
429
|
+
let obj = {
|
|
430
|
+
distinct: collection,
|
|
431
|
+
query: {},
|
|
432
|
+
key: field,
|
|
433
|
+
};
|
|
434
|
+
tmpObj = await ResolveIOServer.getMainDB().command(obj);
|
|
435
|
+
}
|
|
436
|
+
else if (commandstr === 'listIndexes') {
|
|
437
|
+
// tmpObj = await this.mainDb.db[collection].getIndexes();
|
|
438
|
+
// let obj = { 'listIndexes': collection };
|
|
439
|
+
// tmpObj = await this.mainDb.db.getIndexes(obj);
|
|
440
|
+
}
|
|
441
|
+
} catch {
|
|
442
|
+
// console.log('----------- mongoCommand err: ', err);
|
|
443
|
+
return -1;
|
|
444
|
+
}
|
|
445
|
+
if (tmpObj) {
|
|
446
|
+
return tmpObj.values;
|
|
447
|
+
}
|
|
448
|
+
}
|