@resolveio/server-lib 22.3.219 → 22.3.221
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 +195 -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 +375 -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-run.collection.ts +117 -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 +134 -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 +131 -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 +818 -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/ai-run-evidence.manager.ts +264 -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 +1857 -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 +112 -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 +29070 -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-run.model.ts +27 -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} +36 -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 +56 -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 +1231 -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 +925 -0
- package/src/util/ai-run-evidence-adapters.ts +8347 -0
- package/src/util/ai-run-evidence-dashboard.ts +323 -0
- package/src/util/ai-run-evidence-eval.ts +1057 -0
- package/src/util/ai-run-evidence.ts +1430 -0
- package/src/util/ai-runner-artifacts.ts +586 -0
- package/src/util/ai-runner-manager-autopilot.ts +961 -0
- package/src/util/ai-runner-manager-policy.ts +5011 -0
- package/src/util/ai-runner-qa-auth.ts +838 -0
- package/src/util/ai-runner-qa-tools.ts +3536 -0
- package/src/util/aicoder-runner-v6.ts +3121 -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/openai-usage-cost.ts +114 -0
- package/src/util/report-builder-unwinds.ts +180 -0
- package/src/util/runner-process-janitor.ts +219 -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/support-runner-v5.ts +10040 -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 +585 -0
- package/tests/ai-assistant-snf-live-eval.ts +975 -0
- package/tests/ai-assistant-utils.test.ts +4834 -0
- package/tests/ai-manager-autopilot-snapshot.test.ts +193 -0
- package/tests/ai-manager-recovery-checkpoint.test.ts +1383 -0
- package/tests/ai-run-eval.test.ts +132 -0
- package/tests/ai-run-evidence.test.ts +3773 -0
- package/tests/ai-runner-contract.test.ts +515 -0
- package/tests/aicoder-runner-v6.test.ts +822 -0
- package/tests/error-reporter.test.ts +145 -0
- package/tests/method-publication-generator.test.ts +46 -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/tests/support-runner-v5.test.ts +3201 -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-run.collection.d.ts +0 -3
- package/collections/ai-run.collection.js +0 -170
- package/collections/ai-run.collection.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 -134
- 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 -188
- 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 -951
- 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/ai-run-evidence.manager.d.ts +0 -36
- package/managers/ai-run-evidence.manager.js +0 -377
- package/managers/ai-run-evidence.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 -84
- package/managers/method.manager.js +0 -1964
- 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 -30
- package/managers/openai-usage-ledger.manager.js +0 -142
- 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 -458
- package/methods/ai-terminal.js +0 -27991
- 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-run.model.d.ts +0 -19
- package/models/ai-run.model.js +0 -4
- package/models/ai-run.model.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 -32
- 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 -30
- 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 -127
- 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 -128
- package/services/codex-client.js +0 -1629
- 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 -124
- package/util/ai-qa-policy.js +0 -736
- package/util/ai-qa-policy.js.map +0 -1
- package/util/ai-run-evidence-adapters.d.ts +0 -109
- package/util/ai-run-evidence-adapters.js +0 -7234
- package/util/ai-run-evidence-adapters.js.map +0 -1
- package/util/ai-run-evidence-dashboard.d.ts +0 -88
- package/util/ai-run-evidence-dashboard.js +0 -343
- package/util/ai-run-evidence-dashboard.js.map +0 -1
- package/util/ai-run-evidence-eval.d.ts +0 -86
- package/util/ai-run-evidence-eval.js +0 -1018
- package/util/ai-run-evidence-eval.js.map +0 -1
- package/util/ai-run-evidence.d.ts +0 -244
- package/util/ai-run-evidence.js +0 -1096
- package/util/ai-run-evidence.js.map +0 -1
- package/util/ai-runner-artifacts.d.ts +0 -82
- package/util/ai-runner-artifacts.js +0 -713
- package/util/ai-runner-artifacts.js.map +0 -1
- package/util/ai-runner-manager-autopilot.d.ts +0 -210
- package/util/ai-runner-manager-autopilot.js +0 -642
- package/util/ai-runner-manager-autopilot.js.map +0 -1
- package/util/ai-runner-manager-policy.d.ts +0 -807
- package/util/ai-runner-manager-policy.js +0 -3501
- package/util/ai-runner-manager-policy.js.map +0 -1
- package/util/ai-runner-qa-auth.d.ts +0 -5
- package/util/ai-runner-qa-auth.js +0 -839
- package/util/ai-runner-qa-auth.js.map +0 -1
- package/util/ai-runner-qa-tools.d.ts +0 -26
- package/util/ai-runner-qa-tools.js +0 -3520
- package/util/ai-runner-qa-tools.js.map +0 -1
- package/util/aicoder-runner-v6.d.ts +0 -426
- package/util/aicoder-runner-v6.js +0 -2464
- package/util/aicoder-runner-v6.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/openai-usage-cost.d.ts +0 -6
- package/util/openai-usage-cost.js +0 -103
- package/util/openai-usage-cost.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/runner-process-janitor.d.ts +0 -27
- package/util/runner-process-janitor.js +0 -208
- package/util/runner-process-janitor.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/support-runner-v5.d.ts +0 -1426
- package/util/support-runner-v5.js +0 -7624
- package/util/support-runner-v5.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
|
@@ -1,1283 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __values = (this && this.__values) || function(o) {
|
|
55
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
56
|
-
if (m) return m.call(o);
|
|
57
|
-
if (o && typeof o.length === "number") return {
|
|
58
|
-
next: function () {
|
|
59
|
-
if (o && i >= o.length) o = void 0;
|
|
60
|
-
return { value: o && o[i++], done: !o };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
-
exports.withDependencyTracking = withDependencyTracking;
|
|
76
|
-
exports.serializeDependencySnapshot = serializeDependencySnapshot;
|
|
77
|
-
exports.deserializeDependencySnapshot = deserializeDependencySnapshot;
|
|
78
|
-
exports.getPublicationContext = getPublicationContext;
|
|
79
|
-
exports.recordDependencyResult = recordDependencyResult;
|
|
80
|
-
exports.recordAggregateDependencies = recordAggregateDependencies;
|
|
81
|
-
var async_hooks_1 = require("async_hooks");
|
|
82
|
-
var common_1 = require("./common");
|
|
83
|
-
var dependencyStorage = new async_hooks_1.AsyncLocalStorage();
|
|
84
|
-
function withDependencyTracking(fn, metadata) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var context, result;
|
|
87
|
-
var _this = this;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
context = {
|
|
92
|
-
dependencies: new Map(),
|
|
93
|
-
filters: new Map(),
|
|
94
|
-
watchAllCollections: new Set(),
|
|
95
|
-
queryMetadata: new Map()
|
|
96
|
-
};
|
|
97
|
-
if (metadata === null || metadata === void 0 ? void 0 : metadata.publication) {
|
|
98
|
-
context.publication = metadata.publication;
|
|
99
|
-
}
|
|
100
|
-
if (Array.isArray(metadata === null || metadata === void 0 ? void 0 : metadata.subscriptionData)) {
|
|
101
|
-
context.subscriptionData = metadata.subscriptionData.slice();
|
|
102
|
-
}
|
|
103
|
-
if (metadata === null || metadata === void 0 ? void 0 : metadata.userId) {
|
|
104
|
-
context.userId = metadata.userId;
|
|
105
|
-
}
|
|
106
|
-
return [4 /*yield*/, dependencyStorage.run(context, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
switch (_a.label) {
|
|
109
|
-
case 0: return [4 /*yield*/, fn()];
|
|
110
|
-
case 1:
|
|
111
|
-
result = _a.sent();
|
|
112
|
-
return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}); })];
|
|
116
|
-
case 1:
|
|
117
|
-
_a.sent();
|
|
118
|
-
return [2 /*return*/, {
|
|
119
|
-
result: result,
|
|
120
|
-
snapshot: {
|
|
121
|
-
dependencies: cloneDependencyMap(context.dependencies),
|
|
122
|
-
filters: cloneFilterMap(context.filters),
|
|
123
|
-
watchAllCollections: new Set(context.watchAllCollections),
|
|
124
|
-
queryMetadata: cloneQueryMetaMap(context.queryMetadata)
|
|
125
|
-
}
|
|
126
|
-
}];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function serializeDependencySnapshot(snapshot) {
|
|
132
|
-
return {
|
|
133
|
-
dependencies: Array.from(snapshot.dependencies.entries()).map(function (_a) {
|
|
134
|
-
var _b = __read(_a, 2), collection = _b[0], ids = _b[1];
|
|
135
|
-
return [collection, Array.from(ids)];
|
|
136
|
-
}),
|
|
137
|
-
filters: Array.from(snapshot.filters.entries()).map(function (_a) {
|
|
138
|
-
var _b = __read(_a, 2), collection = _b[0], filters = _b[1];
|
|
139
|
-
return [collection, (0, common_1.deepCopy)(filters)];
|
|
140
|
-
}),
|
|
141
|
-
watchAllCollections: Array.from(snapshot.watchAllCollections),
|
|
142
|
-
queryMetadata: Array.from(snapshot.queryMetadata.entries()).map(function (_a) {
|
|
143
|
-
var _b = __read(_a, 2), collection = _b[0], meta = _b[1];
|
|
144
|
-
return [collection, (0, common_1.deepCopy)(meta)];
|
|
145
|
-
})
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function deserializeDependencySnapshot(snapshot) {
|
|
149
|
-
return {
|
|
150
|
-
dependencies: new Map(snapshot.dependencies.map(function (_a) {
|
|
151
|
-
var _b = __read(_a, 2), collection = _b[0], ids = _b[1];
|
|
152
|
-
return [collection, new Set(ids)];
|
|
153
|
-
})),
|
|
154
|
-
filters: new Map(snapshot.filters.map(function (_a) {
|
|
155
|
-
var _b = __read(_a, 2), collection = _b[0], filters = _b[1];
|
|
156
|
-
return [collection, (0, common_1.deepCopy)(filters)];
|
|
157
|
-
})),
|
|
158
|
-
watchAllCollections: new Set(snapshot.watchAllCollections),
|
|
159
|
-
queryMetadata: new Map(snapshot.queryMetadata.map(function (_a) {
|
|
160
|
-
var _b = __read(_a, 2), collection = _b[0], meta = _b[1];
|
|
161
|
-
return [collection, (0, common_1.deepCopy)(meta)];
|
|
162
|
-
}))
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function getPublicationContext() {
|
|
166
|
-
var context = dependencyStorage.getStore();
|
|
167
|
-
if (!context) {
|
|
168
|
-
return {};
|
|
169
|
-
}
|
|
170
|
-
var snapshot = {};
|
|
171
|
-
if (context.publication) {
|
|
172
|
-
snapshot.publication = context.publication;
|
|
173
|
-
}
|
|
174
|
-
if (Array.isArray(context.subscriptionData)) {
|
|
175
|
-
snapshot.subscriptionData = context.subscriptionData.slice();
|
|
176
|
-
}
|
|
177
|
-
if (context.userId) {
|
|
178
|
-
snapshot.userId = context.userId;
|
|
179
|
-
}
|
|
180
|
-
return snapshot;
|
|
181
|
-
}
|
|
182
|
-
function recordDependencyResult(collection, result, options) {
|
|
183
|
-
var e_1, _a;
|
|
184
|
-
var context = dependencyStorage.getStore();
|
|
185
|
-
if (!context) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (options === null || options === void 0 ? void 0 : options.filter) {
|
|
189
|
-
var filterList = context.filters.get(collection);
|
|
190
|
-
if (!filterList) {
|
|
191
|
-
filterList = [];
|
|
192
|
-
context.filters.set(collection, filterList);
|
|
193
|
-
}
|
|
194
|
-
filterList.push((0, common_1.deepCopy)(options.filter));
|
|
195
|
-
context.watchAllCollections.delete(collection);
|
|
196
|
-
}
|
|
197
|
-
if (options === null || options === void 0 ? void 0 : options.meta) {
|
|
198
|
-
var metaList = context.queryMetadata.get(collection);
|
|
199
|
-
if (!metaList) {
|
|
200
|
-
metaList = [];
|
|
201
|
-
context.queryMetadata.set(collection, metaList);
|
|
202
|
-
}
|
|
203
|
-
metaList.push((0, common_1.deepCopy)(options.meta));
|
|
204
|
-
}
|
|
205
|
-
var ids = new Set();
|
|
206
|
-
collectIdsFromResult(result, ids);
|
|
207
|
-
if (!ids.size && (options === null || options === void 0 ? void 0 : options.filter)) {
|
|
208
|
-
collectIdsFromFilter(options.filter, ids);
|
|
209
|
-
}
|
|
210
|
-
if (ids.size) {
|
|
211
|
-
context.watchAllCollections.delete(collection);
|
|
212
|
-
var existing = context.dependencies.get(collection);
|
|
213
|
-
if (!existing) {
|
|
214
|
-
existing = new Set();
|
|
215
|
-
context.dependencies.set(collection, existing);
|
|
216
|
-
}
|
|
217
|
-
try {
|
|
218
|
-
for (var ids_1 = __values(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {
|
|
219
|
-
var id = ids_1_1.value;
|
|
220
|
-
existing.add(id);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
224
|
-
finally {
|
|
225
|
-
try {
|
|
226
|
-
if (ids_1_1 && !ids_1_1.done && (_a = ids_1.return)) _a.call(ids_1);
|
|
227
|
-
}
|
|
228
|
-
finally { if (e_1) throw e_1.error; }
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else if (!(options === null || options === void 0 ? void 0 : options.filter)) {
|
|
232
|
-
context.watchAllCollections.add(collection);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function recordAggregateDependencies(collection, pipeline, result) {
|
|
236
|
-
var e_2, _a, e_3, _b, e_4, _c;
|
|
237
|
-
var context = dependencyStorage.getStore();
|
|
238
|
-
if (!context) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
var lookupTargets = extractLookupTargets(pipeline);
|
|
242
|
-
var lookupAliases = new Set(lookupTargets.map(function (target) { return target.as; }).filter(Boolean));
|
|
243
|
-
var matchFilter = sanitizeMatchFilter(extractMatchFilter(pipeline), lookupAliases);
|
|
244
|
-
var meta = extractAggregateMeta(pipeline);
|
|
245
|
-
recordDependencyResult(collection, result, {
|
|
246
|
-
filter: matchFilter || undefined,
|
|
247
|
-
meta: meta
|
|
248
|
-
});
|
|
249
|
-
if (!matchFilter) {
|
|
250
|
-
context.watchAllCollections.add(collection);
|
|
251
|
-
}
|
|
252
|
-
if (shouldWatchAllForAggregatePipeline(pipeline)) {
|
|
253
|
-
context.watchAllCollections.add(collection);
|
|
254
|
-
}
|
|
255
|
-
if (!lookupTargets.length) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
for (var lookupTargets_1 = __values(lookupTargets), lookupTargets_1_1 = lookupTargets_1.next(); !lookupTargets_1_1.done; lookupTargets_1_1 = lookupTargets_1.next()) {
|
|
260
|
-
var target = lookupTargets_1_1.value;
|
|
261
|
-
var nestedValues = [];
|
|
262
|
-
collectLookupValues(result, target.as, nestedValues);
|
|
263
|
-
var rootDocs = Array.isArray(result) ? result : [result];
|
|
264
|
-
var pipelineFilters = [];
|
|
265
|
-
var pipelineUnresolved = false;
|
|
266
|
-
try {
|
|
267
|
-
for (var rootDocs_1 = (e_3 = void 0, __values(rootDocs)), rootDocs_1_1 = rootDocs_1.next(); !rootDocs_1_1.done; rootDocs_1_1 = rootDocs_1.next()) {
|
|
268
|
-
var rootDoc = rootDocs_1_1.value;
|
|
269
|
-
var _d = buildLookupPipelineFilters(rootDoc, target), filtersFromPipeline = _d.filters, unresolved = _d.unresolved;
|
|
270
|
-
if (unresolved) {
|
|
271
|
-
pipelineUnresolved = true;
|
|
272
|
-
}
|
|
273
|
-
if (filtersFromPipeline === null || filtersFromPipeline === void 0 ? void 0 : filtersFromPipeline.length) {
|
|
274
|
-
pipelineFilters.push.apply(pipelineFilters, __spreadArray([], __read(filtersFromPipeline), false));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
279
|
-
finally {
|
|
280
|
-
try {
|
|
281
|
-
if (rootDocs_1_1 && !rootDocs_1_1.done && (_b = rootDocs_1.return)) _b.call(rootDocs_1);
|
|
282
|
-
}
|
|
283
|
-
finally { if (e_3) throw e_3.error; }
|
|
284
|
-
}
|
|
285
|
-
var filter = buildLookupFilter(result, target.localField, target.foreignField);
|
|
286
|
-
var uniquePipelineFilters = dedupeFilters(pipelineFilters);
|
|
287
|
-
if (nestedValues.length) {
|
|
288
|
-
recordDependencyResult(target.from, nestedValues, filter ? { filter: filter } : undefined);
|
|
289
|
-
}
|
|
290
|
-
if (uniquePipelineFilters.length) {
|
|
291
|
-
var pipelineMeta = extractAggregationMetaFromPipeline(target.pipeline);
|
|
292
|
-
try {
|
|
293
|
-
for (var uniquePipelineFilters_1 = (e_4 = void 0, __values(uniquePipelineFilters)), uniquePipelineFilters_1_1 = uniquePipelineFilters_1.next(); !uniquePipelineFilters_1_1.done; uniquePipelineFilters_1_1 = uniquePipelineFilters_1.next()) {
|
|
294
|
-
var pipelineFilter = uniquePipelineFilters_1_1.value;
|
|
295
|
-
recordDependencyResult(target.from, [], { filter: pipelineFilter, meta: pipelineMeta });
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
299
|
-
finally {
|
|
300
|
-
try {
|
|
301
|
-
if (uniquePipelineFilters_1_1 && !uniquePipelineFilters_1_1.done && (_c = uniquePipelineFilters_1.return)) _c.call(uniquePipelineFilters_1);
|
|
302
|
-
}
|
|
303
|
-
finally { if (e_4) throw e_4.error; }
|
|
304
|
-
}
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
if (!nestedValues.length && filter) {
|
|
308
|
-
recordDependencyResult(target.from, [], { filter: filter });
|
|
309
|
-
continue;
|
|
310
|
-
}
|
|
311
|
-
if (!nestedValues.length) {
|
|
312
|
-
if (pipelineUnresolved) {
|
|
313
|
-
context.watchAllCollections.add(target.from);
|
|
314
|
-
}
|
|
315
|
-
else if (!target.pipeline || !target.pipeline.length) {
|
|
316
|
-
context.watchAllCollections.add(target.from);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// Lookup pipeline exists, but we could not derive stable filters/ids.
|
|
320
|
-
context.watchAllCollections.add(target.from);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
326
|
-
finally {
|
|
327
|
-
try {
|
|
328
|
-
if (lookupTargets_1_1 && !lookupTargets_1_1.done && (_a = lookupTargets_1.return)) _a.call(lookupTargets_1);
|
|
329
|
-
}
|
|
330
|
-
finally { if (e_2) throw e_2.error; }
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function shouldWatchAllForAggregatePipeline(pipeline) {
|
|
334
|
-
if (!Array.isArray(pipeline)) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
return pipeline.some(function (stage) { return isCardinalityChangingStage(stage); });
|
|
338
|
-
}
|
|
339
|
-
function isCardinalityChangingStage(stage) {
|
|
340
|
-
if (!stage || typeof stage !== 'object') {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
if (stage.$group && typeof stage.$group === 'object') {
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
if (stage.$count !== undefined) {
|
|
347
|
-
return true;
|
|
348
|
-
}
|
|
349
|
-
if (stage.$facet && typeof stage.$facet === 'object') {
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
352
|
-
if (stage.$bucket && typeof stage.$bucket === 'object') {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
if (stage.$bucketAuto && typeof stage.$bucketAuto === 'object') {
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
if (stage.$sortByCount !== undefined) {
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
function extractLookupTargets(pipeline) {
|
|
364
|
-
var e_5, _a;
|
|
365
|
-
var lookups = [];
|
|
366
|
-
if (!Array.isArray(pipeline)) {
|
|
367
|
-
return lookups;
|
|
368
|
-
}
|
|
369
|
-
try {
|
|
370
|
-
for (var pipeline_1 = __values(pipeline), pipeline_1_1 = pipeline_1.next(); !pipeline_1_1.done; pipeline_1_1 = pipeline_1.next()) {
|
|
371
|
-
var stage = pipeline_1_1.value;
|
|
372
|
-
if (stage && stage.$lookup && typeof stage.$lookup === 'object') {
|
|
373
|
-
var lookup = stage.$lookup;
|
|
374
|
-
if (typeof lookup.from === 'string' && typeof lookup.as === 'string') {
|
|
375
|
-
lookups.push({
|
|
376
|
-
from: lookup.from,
|
|
377
|
-
as: lookup.as,
|
|
378
|
-
localField: typeof lookup.localField === 'string' ? lookup.localField : undefined,
|
|
379
|
-
foreignField: typeof lookup.foreignField === 'string' ? lookup.foreignField : undefined,
|
|
380
|
-
let: lookup.let && typeof lookup.let === 'object' ? lookup.let : undefined,
|
|
381
|
-
pipeline: Array.isArray(lookup.pipeline) ? lookup.pipeline : undefined
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
388
|
-
finally {
|
|
389
|
-
try {
|
|
390
|
-
if (pipeline_1_1 && !pipeline_1_1.done && (_a = pipeline_1.return)) _a.call(pipeline_1);
|
|
391
|
-
}
|
|
392
|
-
finally { if (e_5) throw e_5.error; }
|
|
393
|
-
}
|
|
394
|
-
return lookups;
|
|
395
|
-
}
|
|
396
|
-
function extractMatchFilter(pipeline) {
|
|
397
|
-
var e_6, _a;
|
|
398
|
-
if (!Array.isArray(pipeline)) {
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
var filters = [];
|
|
402
|
-
try {
|
|
403
|
-
for (var pipeline_2 = __values(pipeline), pipeline_2_1 = pipeline_2.next(); !pipeline_2_1.done; pipeline_2_1 = pipeline_2.next()) {
|
|
404
|
-
var stage = pipeline_2_1.value;
|
|
405
|
-
if (stage && stage.$match && typeof stage.$match === 'object') {
|
|
406
|
-
filters.push((0, common_1.deepCopy)(stage.$match));
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
411
|
-
finally {
|
|
412
|
-
try {
|
|
413
|
-
if (pipeline_2_1 && !pipeline_2_1.done && (_a = pipeline_2.return)) _a.call(pipeline_2);
|
|
414
|
-
}
|
|
415
|
-
finally { if (e_6) throw e_6.error; }
|
|
416
|
-
}
|
|
417
|
-
if (!filters.length) {
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
|
-
if (filters.length === 1) {
|
|
421
|
-
return filters[0];
|
|
422
|
-
}
|
|
423
|
-
return { $and: filters };
|
|
424
|
-
}
|
|
425
|
-
function sanitizeMatchFilter(filter, lookupAliases) {
|
|
426
|
-
if (!filter || !(lookupAliases === null || lookupAliases === void 0 ? void 0 : lookupAliases.size)) {
|
|
427
|
-
return filter;
|
|
428
|
-
}
|
|
429
|
-
return sanitizeFilterNode(filter, lookupAliases);
|
|
430
|
-
}
|
|
431
|
-
function sanitizeFilterNode(node, lookupAliases) {
|
|
432
|
-
var e_7, _a;
|
|
433
|
-
if (!node) {
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
if (Array.isArray(node)) {
|
|
437
|
-
var sanitizedArray = node
|
|
438
|
-
.map(function (entry) { return sanitizeFilterNode(entry, lookupAliases); })
|
|
439
|
-
.filter(isMeaningfulFilterNode);
|
|
440
|
-
return sanitizedArray.length ? sanitizedArray : null;
|
|
441
|
-
}
|
|
442
|
-
if (typeof node !== 'object') {
|
|
443
|
-
return node;
|
|
444
|
-
}
|
|
445
|
-
var result = {};
|
|
446
|
-
try {
|
|
447
|
-
for (var _b = __values(Object.entries(node)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
448
|
-
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
449
|
-
if (key === '$and' || key === '$or' || key === '$nor') {
|
|
450
|
-
if (Array.isArray(value)) {
|
|
451
|
-
var sanitizedChildren = value
|
|
452
|
-
.map(function (entry) { return sanitizeFilterNode(entry, lookupAliases); })
|
|
453
|
-
.filter(isMeaningfulFilterNode);
|
|
454
|
-
if (sanitizedChildren.length) {
|
|
455
|
-
result[key] = sanitizedChildren;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
var rootKey = key.split('.')[0];
|
|
461
|
-
if (lookupAliases.has(rootKey)) {
|
|
462
|
-
continue;
|
|
463
|
-
}
|
|
464
|
-
result[key] = value;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
468
|
-
finally {
|
|
469
|
-
try {
|
|
470
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
471
|
-
}
|
|
472
|
-
finally { if (e_7) throw e_7.error; }
|
|
473
|
-
}
|
|
474
|
-
return Object.keys(result).length ? result : null;
|
|
475
|
-
}
|
|
476
|
-
function isMeaningfulFilterNode(node) {
|
|
477
|
-
if (!node) {
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
if (Array.isArray(node)) {
|
|
481
|
-
return node.length > 0;
|
|
482
|
-
}
|
|
483
|
-
if (typeof node !== 'object') {
|
|
484
|
-
return true;
|
|
485
|
-
}
|
|
486
|
-
return Object.keys(node).length > 0;
|
|
487
|
-
}
|
|
488
|
-
function extractAggregateMeta(pipeline) {
|
|
489
|
-
var e_8, _a;
|
|
490
|
-
if (!Array.isArray(pipeline)) {
|
|
491
|
-
return null;
|
|
492
|
-
}
|
|
493
|
-
var limit = undefined;
|
|
494
|
-
var skip = undefined;
|
|
495
|
-
var sort = null;
|
|
496
|
-
try {
|
|
497
|
-
for (var pipeline_3 = __values(pipeline), pipeline_3_1 = pipeline_3.next(); !pipeline_3_1.done; pipeline_3_1 = pipeline_3.next()) {
|
|
498
|
-
var stage = pipeline_3_1.value;
|
|
499
|
-
if ((stage === null || stage === void 0 ? void 0 : stage.$limit) !== undefined && typeof stage.$limit === 'number') {
|
|
500
|
-
limit = stage.$limit;
|
|
501
|
-
}
|
|
502
|
-
else if ((stage === null || stage === void 0 ? void 0 : stage.$skip) !== undefined && typeof stage.$skip === 'number') {
|
|
503
|
-
skip = stage.$skip;
|
|
504
|
-
}
|
|
505
|
-
else if ((stage === null || stage === void 0 ? void 0 : stage.$sort) && typeof stage.$sort === 'object') {
|
|
506
|
-
sort = (0, common_1.deepCopy)(stage.$sort);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
511
|
-
finally {
|
|
512
|
-
try {
|
|
513
|
-
if (pipeline_3_1 && !pipeline_3_1.done && (_a = pipeline_3.return)) _a.call(pipeline_3);
|
|
514
|
-
}
|
|
515
|
-
finally { if (e_8) throw e_8.error; }
|
|
516
|
-
}
|
|
517
|
-
var meta = {};
|
|
518
|
-
if (limit !== undefined) {
|
|
519
|
-
meta.limit = limit;
|
|
520
|
-
}
|
|
521
|
-
if (skip !== undefined) {
|
|
522
|
-
meta.skip = skip;
|
|
523
|
-
}
|
|
524
|
-
if (sort) {
|
|
525
|
-
meta.sort = sort;
|
|
526
|
-
}
|
|
527
|
-
return Object.keys(meta).length ? meta : null;
|
|
528
|
-
}
|
|
529
|
-
function extractAggregationMetaFromPipeline(pipeline) {
|
|
530
|
-
var e_9, _a;
|
|
531
|
-
if (!Array.isArray(pipeline)) {
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
var limit = undefined;
|
|
535
|
-
var skip = undefined;
|
|
536
|
-
var sort = null;
|
|
537
|
-
try {
|
|
538
|
-
for (var pipeline_4 = __values(pipeline), pipeline_4_1 = pipeline_4.next(); !pipeline_4_1.done; pipeline_4_1 = pipeline_4.next()) {
|
|
539
|
-
var stage = pipeline_4_1.value;
|
|
540
|
-
if ((stage === null || stage === void 0 ? void 0 : stage.$limit) !== undefined && typeof stage.$limit === 'number') {
|
|
541
|
-
limit = stage.$limit;
|
|
542
|
-
}
|
|
543
|
-
else if ((stage === null || stage === void 0 ? void 0 : stage.$skip) !== undefined && typeof stage.$skip === 'number') {
|
|
544
|
-
skip = stage.$skip;
|
|
545
|
-
}
|
|
546
|
-
else if ((stage === null || stage === void 0 ? void 0 : stage.$sort) && typeof stage.$sort === 'object') {
|
|
547
|
-
sort = (0, common_1.deepCopy)(stage.$sort);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
552
|
-
finally {
|
|
553
|
-
try {
|
|
554
|
-
if (pipeline_4_1 && !pipeline_4_1.done && (_a = pipeline_4.return)) _a.call(pipeline_4);
|
|
555
|
-
}
|
|
556
|
-
finally { if (e_9) throw e_9.error; }
|
|
557
|
-
}
|
|
558
|
-
var meta = {};
|
|
559
|
-
if (limit !== undefined) {
|
|
560
|
-
meta.limit = limit;
|
|
561
|
-
}
|
|
562
|
-
if (skip !== undefined) {
|
|
563
|
-
meta.skip = skip;
|
|
564
|
-
}
|
|
565
|
-
if (sort) {
|
|
566
|
-
meta.sort = sort;
|
|
567
|
-
}
|
|
568
|
-
return Object.keys(meta).length ? meta : null;
|
|
569
|
-
}
|
|
570
|
-
function collectLookupValues(source, path, output) {
|
|
571
|
-
var e_10, _a;
|
|
572
|
-
if (!source) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
if (Array.isArray(source)) {
|
|
576
|
-
try {
|
|
577
|
-
for (var source_1 = __values(source), source_1_1 = source_1.next(); !source_1_1.done; source_1_1 = source_1.next()) {
|
|
578
|
-
var item = source_1_1.value;
|
|
579
|
-
collectLookupValues(item, path, output);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
583
|
-
finally {
|
|
584
|
-
try {
|
|
585
|
-
if (source_1_1 && !source_1_1.done && (_a = source_1.return)) _a.call(source_1);
|
|
586
|
-
}
|
|
587
|
-
finally { if (e_10) throw e_10.error; }
|
|
588
|
-
}
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
if (typeof source !== 'object') {
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
var pathSegments = path.split('.');
|
|
595
|
-
collectLookupPathValues(source, pathSegments, 0, output);
|
|
596
|
-
}
|
|
597
|
-
function collectLookupPathValues(value, path, index, output) {
|
|
598
|
-
var e_11, _a;
|
|
599
|
-
if (!value) {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
var current = value[path[index]];
|
|
603
|
-
if (current === undefined) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
if (index === path.length - 1) {
|
|
607
|
-
output.push(current);
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if (Array.isArray(current)) {
|
|
611
|
-
try {
|
|
612
|
-
for (var current_1 = __values(current), current_1_1 = current_1.next(); !current_1_1.done; current_1_1 = current_1.next()) {
|
|
613
|
-
var item = current_1_1.value;
|
|
614
|
-
if (item && typeof item === 'object') {
|
|
615
|
-
collectLookupPathValues(item, path, index + 1, output);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
620
|
-
finally {
|
|
621
|
-
try {
|
|
622
|
-
if (current_1_1 && !current_1_1.done && (_a = current_1.return)) _a.call(current_1);
|
|
623
|
-
}
|
|
624
|
-
finally { if (e_11) throw e_11.error; }
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
else if (current && typeof current === 'object') {
|
|
628
|
-
collectLookupPathValues(current, path, index + 1, output);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
function buildLookupFilter(result, localField, foreignField) {
|
|
632
|
-
var _a;
|
|
633
|
-
if (!localField || !foreignField) {
|
|
634
|
-
return null;
|
|
635
|
-
}
|
|
636
|
-
var values = [];
|
|
637
|
-
var segments = localField.split('.');
|
|
638
|
-
collectFieldValues(result, segments, 0, values);
|
|
639
|
-
var uniqueValues = dedupeFilterValues(values);
|
|
640
|
-
if (!uniqueValues.length) {
|
|
641
|
-
return null;
|
|
642
|
-
}
|
|
643
|
-
return _a = {},
|
|
644
|
-
_a[foreignField] = {
|
|
645
|
-
$in: uniqueValues
|
|
646
|
-
},
|
|
647
|
-
_a;
|
|
648
|
-
}
|
|
649
|
-
function collectFieldValues(source, path, index, output) {
|
|
650
|
-
var e_12, _a, e_13, _b;
|
|
651
|
-
if (!source) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
if (Array.isArray(source)) {
|
|
655
|
-
try {
|
|
656
|
-
for (var source_2 = __values(source), source_2_1 = source_2.next(); !source_2_1.done; source_2_1 = source_2.next()) {
|
|
657
|
-
var item = source_2_1.value;
|
|
658
|
-
collectFieldValues(item, path, index, output);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
662
|
-
finally {
|
|
663
|
-
try {
|
|
664
|
-
if (source_2_1 && !source_2_1.done && (_a = source_2.return)) _a.call(source_2);
|
|
665
|
-
}
|
|
666
|
-
finally { if (e_12) throw e_12.error; }
|
|
667
|
-
}
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
if (typeof source !== 'object') {
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
var obj = source;
|
|
674
|
-
var key = path[index];
|
|
675
|
-
var current = obj[key];
|
|
676
|
-
if (current === undefined) {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
if (index === path.length - 1) {
|
|
680
|
-
appendFilterValue(output, current);
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
if (Array.isArray(current)) {
|
|
684
|
-
try {
|
|
685
|
-
for (var current_2 = __values(current), current_2_1 = current_2.next(); !current_2_1.done; current_2_1 = current_2.next()) {
|
|
686
|
-
var item = current_2_1.value;
|
|
687
|
-
collectFieldValues(item, path, index + 1, output);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
691
|
-
finally {
|
|
692
|
-
try {
|
|
693
|
-
if (current_2_1 && !current_2_1.done && (_b = current_2.return)) _b.call(current_2);
|
|
694
|
-
}
|
|
695
|
-
finally { if (e_13) throw e_13.error; }
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
collectFieldValues(current, path, index + 1, output);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
function appendFilterValue(output, value) {
|
|
703
|
-
var e_14, _a;
|
|
704
|
-
if (value === undefined || value === null) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
if (Array.isArray(value)) {
|
|
708
|
-
try {
|
|
709
|
-
for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
710
|
-
var item = value_1_1.value;
|
|
711
|
-
appendFilterValue(output, item);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
715
|
-
finally {
|
|
716
|
-
try {
|
|
717
|
-
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
718
|
-
}
|
|
719
|
-
finally { if (e_14) throw e_14.error; }
|
|
720
|
-
}
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
output.push(value);
|
|
724
|
-
}
|
|
725
|
-
function dedupeFilterValues(values) {
|
|
726
|
-
var e_15, _a;
|
|
727
|
-
var unique = new Map();
|
|
728
|
-
try {
|
|
729
|
-
for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
|
|
730
|
-
var value = values_1_1.value;
|
|
731
|
-
var key = serializeFilterValue(value);
|
|
732
|
-
if (!unique.has(key)) {
|
|
733
|
-
unique.set(key, value);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
738
|
-
finally {
|
|
739
|
-
try {
|
|
740
|
-
if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
|
|
741
|
-
}
|
|
742
|
-
finally { if (e_15) throw e_15.error; }
|
|
743
|
-
}
|
|
744
|
-
return Array.from(unique.values());
|
|
745
|
-
}
|
|
746
|
-
function serializeFilterValue(value) {
|
|
747
|
-
if (value === null || value === undefined) {
|
|
748
|
-
return 'null';
|
|
749
|
-
}
|
|
750
|
-
if (typeof value === 'object') {
|
|
751
|
-
if (typeof value.toHexString === 'function') {
|
|
752
|
-
return value.toHexString();
|
|
753
|
-
}
|
|
754
|
-
if (value instanceof Date) {
|
|
755
|
-
return value.toISOString();
|
|
756
|
-
}
|
|
757
|
-
if (typeof value.toString === 'function' && value.toString !== Object.prototype.toString) {
|
|
758
|
-
return value.toString();
|
|
759
|
-
}
|
|
760
|
-
try {
|
|
761
|
-
return JSON.stringify(value);
|
|
762
|
-
}
|
|
763
|
-
catch (_a) {
|
|
764
|
-
return '[object]';
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return String(value);
|
|
768
|
-
}
|
|
769
|
-
function collectIdsFromResult(source, ids, visited) {
|
|
770
|
-
var e_16, _a, e_17, _b;
|
|
771
|
-
if (visited === void 0) { visited = new WeakSet(); }
|
|
772
|
-
if (!source) {
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
if (Array.isArray(source)) {
|
|
776
|
-
try {
|
|
777
|
-
for (var source_3 = __values(source), source_3_1 = source_3.next(); !source_3_1.done; source_3_1 = source_3.next()) {
|
|
778
|
-
var item = source_3_1.value;
|
|
779
|
-
collectIdsFromResult(item, ids, visited);
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
783
|
-
finally {
|
|
784
|
-
try {
|
|
785
|
-
if (source_3_1 && !source_3_1.done && (_a = source_3.return)) _a.call(source_3);
|
|
786
|
-
}
|
|
787
|
-
finally { if (e_16) throw e_16.error; }
|
|
788
|
-
}
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
if (typeof source !== 'object') {
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
var objectSource = source;
|
|
795
|
-
if (visited.has(objectSource)) {
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
visited.add(objectSource);
|
|
799
|
-
var normalizedId = normalizeId(objectSource._id);
|
|
800
|
-
if (normalizedId) {
|
|
801
|
-
ids.add(normalizedId);
|
|
802
|
-
}
|
|
803
|
-
try {
|
|
804
|
-
for (var _c = __values(Object.values(objectSource)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
805
|
-
var value = _d.value;
|
|
806
|
-
if (value && (typeof value === 'object' || Array.isArray(value))) {
|
|
807
|
-
collectIdsFromResult(value, ids, visited);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
812
|
-
finally {
|
|
813
|
-
try {
|
|
814
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
815
|
-
}
|
|
816
|
-
finally { if (e_17) throw e_17.error; }
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
function collectIdsFromFilter(filter, ids) {
|
|
820
|
-
var e_18, _a, e_19, _b, e_20, _c;
|
|
821
|
-
if (!filter) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
if (Array.isArray(filter)) {
|
|
825
|
-
try {
|
|
826
|
-
for (var filter_1 = __values(filter), filter_1_1 = filter_1.next(); !filter_1_1.done; filter_1_1 = filter_1.next()) {
|
|
827
|
-
var item = filter_1_1.value;
|
|
828
|
-
collectIdsFromFilter(item, ids);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
832
|
-
finally {
|
|
833
|
-
try {
|
|
834
|
-
if (filter_1_1 && !filter_1_1.done && (_a = filter_1.return)) _a.call(filter_1);
|
|
835
|
-
}
|
|
836
|
-
finally { if (e_18) throw e_18.error; }
|
|
837
|
-
}
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
if (typeof filter !== 'object') {
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
var filterObject = filter;
|
|
844
|
-
if (filterObject._id !== undefined) {
|
|
845
|
-
collectIdsFromFilterValue(filterObject._id, ids);
|
|
846
|
-
}
|
|
847
|
-
try {
|
|
848
|
-
for (var _d = __values(Object.entries(filterObject)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
849
|
-
var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
|
|
850
|
-
if (key === '$or' || key === '$and' || key === '$nor') {
|
|
851
|
-
if (Array.isArray(value)) {
|
|
852
|
-
try {
|
|
853
|
-
for (var value_2 = (e_20 = void 0, __values(value)), value_2_1 = value_2.next(); !value_2_1.done; value_2_1 = value_2.next()) {
|
|
854
|
-
var item = value_2_1.value;
|
|
855
|
-
collectIdsFromFilter(item, ids);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
859
|
-
finally {
|
|
860
|
-
try {
|
|
861
|
-
if (value_2_1 && !value_2_1.done && (_c = value_2.return)) _c.call(value_2);
|
|
862
|
-
}
|
|
863
|
-
finally { if (e_20) throw e_20.error; }
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
else if (key !== '_id' && value && typeof value === 'object') {
|
|
868
|
-
collectIdsFromFilter(value, ids);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
873
|
-
finally {
|
|
874
|
-
try {
|
|
875
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
876
|
-
}
|
|
877
|
-
finally { if (e_19) throw e_19.error; }
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
function collectIdsFromFilterValue(value, ids) {
|
|
881
|
-
var e_21, _a, e_22, _b;
|
|
882
|
-
if (value === null || value === undefined) {
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
885
|
-
if (Array.isArray(value)) {
|
|
886
|
-
try {
|
|
887
|
-
for (var value_3 = __values(value), value_3_1 = value_3.next(); !value_3_1.done; value_3_1 = value_3.next()) {
|
|
888
|
-
var item = value_3_1.value;
|
|
889
|
-
collectIdsFromFilterValue(item, ids);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
893
|
-
finally {
|
|
894
|
-
try {
|
|
895
|
-
if (value_3_1 && !value_3_1.done && (_a = value_3.return)) _a.call(value_3);
|
|
896
|
-
}
|
|
897
|
-
finally { if (e_21) throw e_21.error; }
|
|
898
|
-
}
|
|
899
|
-
return;
|
|
900
|
-
}
|
|
901
|
-
if (typeof value === 'object') {
|
|
902
|
-
try {
|
|
903
|
-
for (var _c = __values(Object.entries(value)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
904
|
-
var _e = __read(_d.value, 2), key = _e[0], inner = _e[1];
|
|
905
|
-
if (key === '$in' || key === '$nin' || key === '$all') {
|
|
906
|
-
collectIdsFromFilterValue(inner, ids);
|
|
907
|
-
}
|
|
908
|
-
else if (key === '$eq' || key === '$ne') {
|
|
909
|
-
collectIdsFromFilterValue(inner, ids);
|
|
910
|
-
}
|
|
911
|
-
else if (key === '$or' || key === '$and' || key === '$nor') {
|
|
912
|
-
collectIdsFromFilterValue(inner, ids);
|
|
913
|
-
}
|
|
914
|
-
else {
|
|
915
|
-
collectIdsFromFilterValue(inner, ids);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
920
|
-
finally {
|
|
921
|
-
try {
|
|
922
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
923
|
-
}
|
|
924
|
-
finally { if (e_22) throw e_22.error; }
|
|
925
|
-
}
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
928
|
-
var normalized = normalizeId(value);
|
|
929
|
-
if (normalized) {
|
|
930
|
-
ids.add(normalized);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
function normalizeId(value) {
|
|
934
|
-
if (value === null || value === undefined) {
|
|
935
|
-
return null;
|
|
936
|
-
}
|
|
937
|
-
if (typeof value === 'string') {
|
|
938
|
-
var trimmed = value.trim();
|
|
939
|
-
return trimmed.length ? trimmed : null;
|
|
940
|
-
}
|
|
941
|
-
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
942
|
-
return value.toString();
|
|
943
|
-
}
|
|
944
|
-
if (typeof value === 'object') {
|
|
945
|
-
var objValue = value;
|
|
946
|
-
if (typeof objValue.toHexString === 'function') {
|
|
947
|
-
return objValue.toHexString();
|
|
948
|
-
}
|
|
949
|
-
if (value instanceof Date) {
|
|
950
|
-
return value.toISOString();
|
|
951
|
-
}
|
|
952
|
-
if (typeof objValue.toString === 'function') {
|
|
953
|
-
var str = objValue.toString();
|
|
954
|
-
if (str && str !== '[object Object]') {
|
|
955
|
-
return str;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
return null;
|
|
960
|
-
}
|
|
961
|
-
function cloneDependencyMap(original) {
|
|
962
|
-
var e_23, _a;
|
|
963
|
-
var cloned = new Map();
|
|
964
|
-
try {
|
|
965
|
-
for (var _b = __values(original.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
966
|
-
var _d = __read(_c.value, 2), collection = _d[0], ids = _d[1];
|
|
967
|
-
cloned.set(collection, new Set(ids));
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
971
|
-
finally {
|
|
972
|
-
try {
|
|
973
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
974
|
-
}
|
|
975
|
-
finally { if (e_23) throw e_23.error; }
|
|
976
|
-
}
|
|
977
|
-
return cloned;
|
|
978
|
-
}
|
|
979
|
-
function cloneFilterMap(original) {
|
|
980
|
-
var e_24, _a;
|
|
981
|
-
var cloned = new Map();
|
|
982
|
-
try {
|
|
983
|
-
for (var _b = __values(original.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
984
|
-
var _d = __read(_c.value, 2), collection = _d[0], filters = _d[1];
|
|
985
|
-
cloned.set(collection, filters.map(function (filter) { return (0, common_1.deepCopy)(filter); }));
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
989
|
-
finally {
|
|
990
|
-
try {
|
|
991
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
992
|
-
}
|
|
993
|
-
finally { if (e_24) throw e_24.error; }
|
|
994
|
-
}
|
|
995
|
-
return cloned;
|
|
996
|
-
}
|
|
997
|
-
function cloneQueryMetaMap(original) {
|
|
998
|
-
var e_25, _a;
|
|
999
|
-
var cloned = new Map();
|
|
1000
|
-
try {
|
|
1001
|
-
for (var _b = __values(original.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1002
|
-
var _d = __read(_c.value, 2), collection = _d[0], metaList = _d[1];
|
|
1003
|
-
cloned.set(collection, metaList.map(function (meta) { return (0, common_1.deepCopy)(meta); }));
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
1007
|
-
finally {
|
|
1008
|
-
try {
|
|
1009
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1010
|
-
}
|
|
1011
|
-
finally { if (e_25) throw e_25.error; }
|
|
1012
|
-
}
|
|
1013
|
-
return cloned;
|
|
1014
|
-
}
|
|
1015
|
-
function buildLookupPipelineFilters(rootDoc, target) {
|
|
1016
|
-
var e_26, _a;
|
|
1017
|
-
if (!target.pipeline || !target.pipeline.length) {
|
|
1018
|
-
return { filters: [], unresolved: false };
|
|
1019
|
-
}
|
|
1020
|
-
var matchStages = target.pipeline.map(function (stage) { return ({ stage: stage, base: stage.$match }); }).filter(function (entry) { return entry.base; });
|
|
1021
|
-
if (!matchStages.length) {
|
|
1022
|
-
return buildLookupPipelineFromStack(target.pipeline, [], rootDoc, target.let);
|
|
1023
|
-
}
|
|
1024
|
-
var letValuesResult = resolveLetVariables(rootDoc, target.let);
|
|
1025
|
-
if (!letValuesResult.resolved) {
|
|
1026
|
-
return { filters: [], unresolved: true };
|
|
1027
|
-
}
|
|
1028
|
-
var combinedMatches = [];
|
|
1029
|
-
try {
|
|
1030
|
-
for (var matchStages_1 = __values(matchStages), matchStages_1_1 = matchStages_1.next(); !matchStages_1_1.done; matchStages_1_1 = matchStages_1.next()) {
|
|
1031
|
-
var base = matchStages_1_1.value.base;
|
|
1032
|
-
var substitutionState = { unresolved: false };
|
|
1033
|
-
var substituted = substituteLetVariables(base, letValuesResult.values, rootDoc, substitutionState);
|
|
1034
|
-
if (substitutionState.unresolved || containsUnresolvedLetReference(substituted)) {
|
|
1035
|
-
return { filters: [], unresolved: true };
|
|
1036
|
-
}
|
|
1037
|
-
combinedMatches.push(substituted);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
1041
|
-
finally {
|
|
1042
|
-
try {
|
|
1043
|
-
if (matchStages_1_1 && !matchStages_1_1.done && (_a = matchStages_1.return)) _a.call(matchStages_1);
|
|
1044
|
-
}
|
|
1045
|
-
finally { if (e_26) throw e_26.error; }
|
|
1046
|
-
}
|
|
1047
|
-
if (!combinedMatches.length) {
|
|
1048
|
-
return buildLookupPipelineFromStack(target.pipeline, [], rootDoc, target.let);
|
|
1049
|
-
}
|
|
1050
|
-
if (combinedMatches.length === 1) {
|
|
1051
|
-
return { filters: [combinedMatches[0]], unresolved: false };
|
|
1052
|
-
}
|
|
1053
|
-
return { filters: [{ $and: combinedMatches }], unresolved: false };
|
|
1054
|
-
}
|
|
1055
|
-
function buildLookupPipelineFromStack(pipeline, initialFilters, rootDoc, letMap) {
|
|
1056
|
-
var currentFilters = initialFilters.slice();
|
|
1057
|
-
var unresolved = false;
|
|
1058
|
-
var entries = pipeline.map(function (stage) { return stage ? Object.keys(stage)[0] : null; });
|
|
1059
|
-
for (var i = 0; i < pipeline.length; i++) {
|
|
1060
|
-
var stage = pipeline[i];
|
|
1061
|
-
var stageType = entries[i];
|
|
1062
|
-
if (stageType === '$match' && stage.$match) {
|
|
1063
|
-
var letValuesResult = resolveLetVariables(rootDoc, letMap);
|
|
1064
|
-
if (!letValuesResult.resolved) {
|
|
1065
|
-
unresolved = true;
|
|
1066
|
-
break;
|
|
1067
|
-
}
|
|
1068
|
-
var substitutionState = { unresolved: false };
|
|
1069
|
-
var substituted = substituteLetVariables(stage.$match, letValuesResult.values, rootDoc, substitutionState);
|
|
1070
|
-
if (substitutionState.unresolved || containsUnresolvedLetReference(substituted)) {
|
|
1071
|
-
unresolved = true;
|
|
1072
|
-
break;
|
|
1073
|
-
}
|
|
1074
|
-
currentFilters.push(substituted);
|
|
1075
|
-
}
|
|
1076
|
-
else if (stageType === '$match') {
|
|
1077
|
-
unresolved = true;
|
|
1078
|
-
break;
|
|
1079
|
-
}
|
|
1080
|
-
else if (stageType === '$facet') {
|
|
1081
|
-
unresolved = true;
|
|
1082
|
-
break;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
if (!currentFilters.length) {
|
|
1086
|
-
return { filters: [], unresolved: unresolved };
|
|
1087
|
-
}
|
|
1088
|
-
if (currentFilters.length === 1) {
|
|
1089
|
-
return { filters: currentFilters, unresolved: unresolved };
|
|
1090
|
-
}
|
|
1091
|
-
return { filters: [{ $and: currentFilters }], unresolved: unresolved };
|
|
1092
|
-
}
|
|
1093
|
-
function resolveLetVariables(rootDoc, letMap) {
|
|
1094
|
-
var e_27, _a;
|
|
1095
|
-
if (!letMap || typeof letMap !== 'object') {
|
|
1096
|
-
return { resolved: true, values: {} };
|
|
1097
|
-
}
|
|
1098
|
-
var values = {};
|
|
1099
|
-
try {
|
|
1100
|
-
for (var _b = __values(Object.entries(letMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1101
|
-
var _d = __read(_c.value, 2), key = _d[0], expression = _d[1];
|
|
1102
|
-
var evaluation = evaluateLetExpression(rootDoc, expression);
|
|
1103
|
-
if (!evaluation.resolved) {
|
|
1104
|
-
return { resolved: false, values: null };
|
|
1105
|
-
}
|
|
1106
|
-
values[key] = evaluation.value;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
1110
|
-
finally {
|
|
1111
|
-
try {
|
|
1112
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1113
|
-
}
|
|
1114
|
-
finally { if (e_27) throw e_27.error; }
|
|
1115
|
-
}
|
|
1116
|
-
return { resolved: true, values: values };
|
|
1117
|
-
}
|
|
1118
|
-
function evaluateLetExpression(rootDoc, expression) {
|
|
1119
|
-
if (typeof expression === 'string') {
|
|
1120
|
-
if (expression.startsWith('$$ROOT.')) {
|
|
1121
|
-
var path = expression.slice('$$ROOT.'.length);
|
|
1122
|
-
return { resolved: true, value: getValueByPath(rootDoc, path) };
|
|
1123
|
-
}
|
|
1124
|
-
else if (expression === '$$ROOT') {
|
|
1125
|
-
return { resolved: true, value: rootDoc };
|
|
1126
|
-
}
|
|
1127
|
-
else if (expression.startsWith('$$')) {
|
|
1128
|
-
return { resolved: false, value: null };
|
|
1129
|
-
}
|
|
1130
|
-
else if (expression.startsWith('$')) {
|
|
1131
|
-
var path = expression.slice(1);
|
|
1132
|
-
return { resolved: true, value: getValueByPath(rootDoc, path) };
|
|
1133
|
-
}
|
|
1134
|
-
else {
|
|
1135
|
-
return { resolved: true, value: expression };
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
else if (Array.isArray(expression)) {
|
|
1139
|
-
return { resolved: false, value: null };
|
|
1140
|
-
}
|
|
1141
|
-
else if (expression && typeof expression === 'object') {
|
|
1142
|
-
return { resolved: false, value: null };
|
|
1143
|
-
}
|
|
1144
|
-
return { resolved: true, value: expression };
|
|
1145
|
-
}
|
|
1146
|
-
function substituteLetVariables(node, letValues, rootDoc, state) {
|
|
1147
|
-
var e_28, _a;
|
|
1148
|
-
if (Array.isArray(node)) {
|
|
1149
|
-
return node.map(function (item) { return substituteLetVariables(item, letValues, rootDoc, state); });
|
|
1150
|
-
}
|
|
1151
|
-
if (node && typeof node === 'object') {
|
|
1152
|
-
var output = {};
|
|
1153
|
-
try {
|
|
1154
|
-
for (var _b = __values(Object.entries(node)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1155
|
-
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
1156
|
-
output[key] = substituteLetVariables(value, letValues, rootDoc, state);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1160
|
-
finally {
|
|
1161
|
-
try {
|
|
1162
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1163
|
-
}
|
|
1164
|
-
finally { if (e_28) throw e_28.error; }
|
|
1165
|
-
}
|
|
1166
|
-
return output;
|
|
1167
|
-
}
|
|
1168
|
-
if (typeof node === 'string') {
|
|
1169
|
-
if (node.startsWith('$$ROOT.')) {
|
|
1170
|
-
var path = node.slice('$$ROOT.'.length);
|
|
1171
|
-
return getValueByPath(rootDoc, path);
|
|
1172
|
-
}
|
|
1173
|
-
if (node === '$$ROOT') {
|
|
1174
|
-
return rootDoc;
|
|
1175
|
-
}
|
|
1176
|
-
if (node.startsWith('$$')) {
|
|
1177
|
-
var varName = node.slice(2);
|
|
1178
|
-
if (Object.prototype.hasOwnProperty.call(letValues, varName)) {
|
|
1179
|
-
return letValues[varName];
|
|
1180
|
-
}
|
|
1181
|
-
state.unresolved = true;
|
|
1182
|
-
return node;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
return node;
|
|
1186
|
-
}
|
|
1187
|
-
function containsUnresolvedLetReference(node) {
|
|
1188
|
-
if (typeof node === 'string') {
|
|
1189
|
-
return node.includes('$$');
|
|
1190
|
-
}
|
|
1191
|
-
if (Array.isArray(node)) {
|
|
1192
|
-
return node.some(function (item) { return containsUnresolvedLetReference(item); });
|
|
1193
|
-
}
|
|
1194
|
-
if (node && typeof node === 'object') {
|
|
1195
|
-
return Object.values(node).some(function (value) { return containsUnresolvedLetReference(value); });
|
|
1196
|
-
}
|
|
1197
|
-
return false;
|
|
1198
|
-
}
|
|
1199
|
-
function getValueByPath(source, path) {
|
|
1200
|
-
var e_29, _a;
|
|
1201
|
-
if (!source || !path) {
|
|
1202
|
-
return undefined;
|
|
1203
|
-
}
|
|
1204
|
-
var segments = path.split('.');
|
|
1205
|
-
var current = source;
|
|
1206
|
-
try {
|
|
1207
|
-
for (var segments_1 = __values(segments), segments_1_1 = segments_1.next(); !segments_1_1.done; segments_1_1 = segments_1.next()) {
|
|
1208
|
-
var segment = segments_1_1.value;
|
|
1209
|
-
if (current === null || current === undefined) {
|
|
1210
|
-
return undefined;
|
|
1211
|
-
}
|
|
1212
|
-
if (Array.isArray(current)) {
|
|
1213
|
-
var index = parseInt(segment, 10);
|
|
1214
|
-
if (isNaN(index) || index < 0 || index >= current.length) {
|
|
1215
|
-
return undefined;
|
|
1216
|
-
}
|
|
1217
|
-
current = current[index];
|
|
1218
|
-
}
|
|
1219
|
-
else {
|
|
1220
|
-
current = current[segment];
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
1225
|
-
finally {
|
|
1226
|
-
try {
|
|
1227
|
-
if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
|
|
1228
|
-
}
|
|
1229
|
-
finally { if (e_29) throw e_29.error; }
|
|
1230
|
-
}
|
|
1231
|
-
return current;
|
|
1232
|
-
}
|
|
1233
|
-
function canonicalizeFilter(filter) {
|
|
1234
|
-
return JSON.stringify(sortKeys(filter));
|
|
1235
|
-
}
|
|
1236
|
-
function sortKeys(value) {
|
|
1237
|
-
var e_30, _a;
|
|
1238
|
-
if (Array.isArray(value)) {
|
|
1239
|
-
return value.map(function (item) { return sortKeys(item); });
|
|
1240
|
-
}
|
|
1241
|
-
if (value && typeof value === 'object') {
|
|
1242
|
-
var sorted = {};
|
|
1243
|
-
var keys = Object.keys(value).sort();
|
|
1244
|
-
try {
|
|
1245
|
-
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
1246
|
-
var key = keys_1_1.value;
|
|
1247
|
-
sorted[key] = sortKeys(value[key]);
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
1251
|
-
finally {
|
|
1252
|
-
try {
|
|
1253
|
-
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
1254
|
-
}
|
|
1255
|
-
finally { if (e_30) throw e_30.error; }
|
|
1256
|
-
}
|
|
1257
|
-
return sorted;
|
|
1258
|
-
}
|
|
1259
|
-
return value;
|
|
1260
|
-
}
|
|
1261
|
-
function dedupeFilters(filters) {
|
|
1262
|
-
var e_31, _a;
|
|
1263
|
-
var map = new Map();
|
|
1264
|
-
try {
|
|
1265
|
-
for (var filters_1 = __values(filters), filters_1_1 = filters_1.next(); !filters_1_1.done; filters_1_1 = filters_1.next()) {
|
|
1266
|
-
var filter = filters_1_1.value;
|
|
1267
|
-
var key = canonicalizeFilter(filter);
|
|
1268
|
-
if (!map.has(key)) {
|
|
1269
|
-
map.set(key, filter);
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
1274
|
-
finally {
|
|
1275
|
-
try {
|
|
1276
|
-
if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
|
|
1277
|
-
}
|
|
1278
|
-
finally { if (e_31) throw e_31.error; }
|
|
1279
|
-
}
|
|
1280
|
-
return Array.from(map.values());
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
//# sourceMappingURL=subscription-dependency-context.js.map
|