@lightdash-tools/mcp 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +205 -58
- package/dist/audit/audit.d.ts +5 -0
- package/dist/{audit.js → audit/audit.js} +1 -2
- package/dist/audit/tool-audit-context.d.ts +6 -0
- package/dist/audit/tool-audit-context.js +12 -0
- package/dist/audit/tool-audit-context.test.d.ts +1 -0
- package/dist/audit/tool-audit-context.test.js +19 -0
- package/dist/auth/auth-mode.d.ts +4 -0
- package/dist/auth/auth-mode.js +6 -0
- package/dist/auth/bearer.d.ts +3 -0
- package/dist/auth/bearer.js +13 -0
- package/dist/auth/lightdash-oauth-upstream-contract.d.ts +22 -0
- package/dist/auth/lightdash-oauth-upstream-contract.js +36 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.d.ts +1 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.js +56 -0
- package/dist/auth/oauth-broker/as-metadata.d.ts +14 -0
- package/dist/auth/oauth-broker/as-metadata.js +20 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +20 -0
- package/dist/auth/oauth-broker/lightdash-token.js +76 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +127 -0
- package/dist/auth/oauth-broker/pending-store.js +151 -0
- package/dist/auth/oauth-broker/pending-store.test.d.ts +6 -0
- package/dist/auth/oauth-broker/pending-store.test.js +146 -0
- package/dist/auth/oauth-broker/pkce.d.ts +2 -0
- package/dist/auth/oauth-broker/pkce.js +17 -0
- package/dist/auth/oauth-broker/routes.d.ts +13 -0
- package/dist/auth/oauth-broker/routes.js +452 -0
- package/dist/auth/oauth-broker/routes.test.d.ts +1 -0
- package/dist/auth/oauth-broker/routes.test.js +242 -0
- package/dist/auth/providers/bearer-context-provider.d.ts +24 -0
- package/dist/auth/providers/bearer-context-provider.js +52 -0
- package/dist/auth/providers/env-context-provider.d.ts +13 -0
- package/dist/auth/providers/env-context-provider.js +19 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +23 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +115 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +202 -0
- package/dist/auth/resource-server/lightdash-token-validation.d.ts +14 -0
- package/dist/auth/resource-server/lightdash-token-validation.js +82 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.js +177 -0
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +25 -0
- package/dist/auth/resource-server/oauth-protected-resource.js +67 -0
- package/dist/auth/resource-server/shared-key-middleware.d.ts +13 -0
- package/dist/auth/resource-server/shared-key-middleware.js +24 -0
- package/dist/auth/resource-server/token-scopes.d.ts +15 -0
- package/dist/auth/resource-server/token-scopes.js +76 -0
- package/dist/auth/resource-server/token-scopes.test.d.ts +1 -0
- package/dist/auth/resource-server/token-scopes.test.js +51 -0
- package/dist/auth/resource-server/token-validation-cache.d.ts +15 -0
- package/dist/auth/resource-server/token-validation-cache.js +44 -0
- package/dist/auth/resource-server/token-validation-cache.test.d.ts +1 -0
- package/dist/auth/resource-server/token-validation-cache.test.js +41 -0
- package/dist/auth/resource-server/token-validation-error.d.ts +6 -0
- package/dist/auth/resource-server/token-validation-error.js +13 -0
- package/dist/auth/resource-server/www-authenticate.d.ts +8 -0
- package/dist/auth/resource-server/www-authenticate.js +24 -0
- package/dist/auth/resource-server/www-authenticate.test.d.ts +1 -0
- package/dist/auth/resource-server/www-authenticate.test.js +70 -0
- package/dist/auth/token-hash.d.ts +2 -0
- package/dist/auth/token-hash.js +8 -0
- package/dist/bin.d.ts +0 -4
- package/dist/bin.js +62 -33
- package/dist/config/env.d.ts +57 -0
- package/dist/config/env.js +60 -0
- package/dist/config/load-mcp-config.d.ts +30 -0
- package/dist/config/load-mcp-config.js +286 -0
- package/dist/config/load-mcp-config.test.d.ts +1 -0
- package/dist/config/load-mcp-config.test.js +202 -0
- package/dist/config/normalize-url.d.ts +13 -0
- package/dist/config/normalize-url.js +52 -0
- package/dist/config/normalize-url.test.d.ts +1 -0
- package/dist/config/normalize-url.test.js +47 -0
- package/dist/config/public-url.d.ts +3 -0
- package/dist/config/public-url.js +10 -0
- package/dist/config/runtime.d.ts +15 -0
- package/dist/config/runtime.js +48 -0
- package/dist/config/runtime.test.d.ts +1 -0
- package/dist/config/runtime.test.js +69 -0
- package/dist/config/test-mcp-http-config.d.ts +3 -0
- package/dist/config/test-mcp-http-config.js +7 -0
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.d.ts +1 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation-claim.d.ts +21 -0
- package/dist/destructive/confirmation-claim.js +87 -0
- package/dist/destructive/confirmation-claim.test.d.ts +1 -0
- package/dist/destructive/confirmation-claim.test.js +50 -0
- package/dist/destructive/confirmation.d.ts +58 -0
- package/dist/destructive/confirmation.js +99 -0
- package/dist/destructive/confirmation.test.d.ts +1 -0
- package/dist/destructive/confirmation.test.js +75 -0
- package/dist/destructive/content-promote.d.ts +8 -0
- package/dist/destructive/content-promote.js +144 -0
- package/dist/destructive/content-soft-delete.d.ts +7 -0
- package/dist/destructive/content-soft-delete.js +106 -0
- package/dist/destructive/destructive-contract.test.d.ts +1 -0
- package/dist/destructive/destructive-contract.test.js +269 -0
- package/dist/destructive/precondition.d.ts +14 -0
- package/dist/destructive/precondition.js +31 -0
- package/dist/destructive/precondition.test.d.ts +1 -0
- package/dist/destructive/precondition.test.js +72 -0
- package/dist/destructive/promote-contract.test.d.ts +1 -0
- package/dist/destructive/promote-contract.test.js +339 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +301 -0
- package/dist/destructive/request-state.d.ts +16 -0
- package/dist/destructive/request-state.js +76 -0
- package/dist/destructive/types.d.ts +64 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/mcp-client-session.d.ts +9 -0
- package/dist/governance/mcp-client-session.js +30 -0
- package/dist/governance/mcp-client-session.test.d.ts +1 -0
- package/dist/governance/mcp-client-session.test.js +31 -0
- package/dist/governance/project-pin.d.ts +14 -0
- package/dist/governance/project-pin.js +44 -0
- package/dist/governance/project-pin.test.d.ts +1 -0
- package/dist/governance/project-pin.test.js +35 -0
- package/dist/governance/project-scope.d.ts +38 -0
- package/dist/governance/project-scope.js +79 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +103 -0
- package/dist/http.d.ts +1 -2
- package/dist/http.integration.test.d.ts +1 -0
- package/dist/http.integration.test.js +722 -0
- package/dist/http.js +3 -170
- package/dist/http.test.d.ts +4 -0
- package/dist/http.test.js +131 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.integration.test.js +73 -30
- package/dist/index.js +28 -27
- package/dist/index.test.js +3 -3
- package/dist/logging/structured.d.ts +27 -0
- package/dist/logging/structured.js +32 -0
- package/dist/logging/structured.test.d.ts +1 -0
- package/dist/logging/structured.test.js +33 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +51 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +5 -0
- package/dist/personas/content-developer/v1/prompts.js +138 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +75 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +63 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +55 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +44 -0
- package/dist/personas/content-governance/v1/index.d.ts +9 -0
- package/dist/personas/content-governance/v1/index.js +29 -0
- package/dist/personas/content-governance/v1/prompts.d.ts +5 -0
- package/dist/personas/content-governance/v1/prompts.js +87 -0
- package/dist/personas/content-governance/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-governance/v1/prompts.test.js +75 -0
- package/dist/personas/content-governance/v1/resources/playbooks/charts.md +29 -0
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +52 -0
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +48 -0
- package/dist/personas/content-governance/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-governance/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-governance/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-reader/v1/index.d.ts +8 -0
- package/dist/personas/content-reader/v1/index.js +37 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +128 -0
- package/dist/personas/content-reader/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-reader/v1/prompts.test.js +25 -0
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +21 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +40 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +13 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +19 -0
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/content-reader/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-reader/v1/resources/playbooks.js +49 -0
- package/dist/personas/index.d.ts +22 -0
- package/dist/personas/index.js +73 -0
- package/dist/personas/index.test.d.ts +1 -0
- package/dist/personas/index.test.js +109 -0
- package/dist/personas/lib/playbook-resources.d.ts +79 -0
- package/dist/personas/lib/playbook-resources.js +165 -0
- package/dist/personas/organization-audit/v1/index.d.ts +8 -0
- package/dist/personas/organization-audit/v1/index.js +42 -0
- package/dist/personas/organization-audit/v1/prompts.d.ts +5 -0
- package/dist/personas/organization-audit/v1/prompts.js +92 -0
- package/dist/personas/organization-audit/v1/prompts.test.d.ts +4 -0
- package/dist/personas/organization-audit/v1/prompts.test.js +25 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +13 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +36 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.js +41 -0
- package/dist/personas/persona.parity.test.d.ts +1 -0
- package/dist/personas/persona.parity.test.js +26 -0
- package/dist/personas/semantic-layer/v1/index.d.ts +8 -0
- package/dist/personas/semantic-layer/v1/index.js +32 -0
- package/dist/personas/semantic-layer/v1/prompts.d.ts +5 -0
- package/dist/personas/semantic-layer/v1/prompts.js +85 -0
- package/dist/personas/semantic-layer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/semantic-layer/v1/prompts.test.js +19 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +55 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +76 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.d.ts +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +39 -0
- package/dist/personas/types.d.ts +19 -0
- package/dist/personas/types.js +5 -0
- package/dist/policy/content-developer.d.ts +35 -0
- package/dist/policy/content-developer.js +91 -0
- package/dist/policy/content-developer.test.d.ts +4 -0
- package/dist/policy/content-developer.test.js +48 -0
- package/dist/policy/content-reader.d.ts +24 -0
- package/dist/policy/content-reader.js +52 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +22 -0
- package/dist/policy/envelope.d.ts +31 -0
- package/dist/policy/envelope.js +24 -0
- package/dist/policy/preview-ledger-fault.test.d.ts +1 -0
- package/dist/policy/preview-ledger-fault.test.js +527 -0
- package/dist/policy/preview-ledger.d.ts +118 -0
- package/dist/policy/preview-ledger.js +243 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +267 -0
- package/dist/policy/result-limits.d.ts +27 -0
- package/dist/policy/result-limits.js +107 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +28 -0
- package/dist/protocol-contract.test.d.ts +1 -0
- package/dist/protocol-contract.test.js +42 -0
- package/dist/server/capabilities.d.ts +15 -0
- package/dist/server/capabilities.js +19 -0
- package/dist/server/capabilities.test.d.ts +1 -0
- package/dist/server/capabilities.test.js +41 -0
- package/dist/server/errors.test.d.ts +1 -0
- package/dist/server/errors.test.js +53 -0
- package/dist/server/request-context.d.ts +13 -0
- package/dist/server/request-context.js +2 -0
- package/dist/server/server.d.ts +4 -0
- package/dist/server/server.js +28 -0
- package/dist/server/server.test.d.ts +1 -0
- package/dist/server/server.test.js +15 -0
- package/dist/server/version.d.ts +1 -0
- package/dist/server/version.js +7 -0
- package/dist/server/version.test.d.ts +1 -0
- package/dist/server/version.test.js +9 -0
- package/dist/stdio.process.test.d.ts +1 -0
- package/dist/stdio.process.test.js +274 -0
- package/dist/store/config.d.ts +11 -0
- package/dist/store/config.js +50 -0
- package/dist/store/config.test.d.ts +1 -0
- package/dist/store/config.test.js +56 -0
- package/dist/store/create-oauth-broker-store.d.ts +6 -0
- package/dist/store/create-oauth-broker-store.js +16 -0
- package/dist/store/create-preview-store.d.ts +10 -0
- package/dist/store/create-preview-store.js +30 -0
- package/dist/store/create-session-store.d.ts +19 -0
- package/dist/store/create-session-store.js +24 -0
- package/dist/store/in-memory-preview-store.d.ts +17 -0
- package/dist/store/in-memory-preview-store.js +72 -0
- package/dist/store/redis-client.d.ts +11 -0
- package/dist/store/redis-client.js +48 -0
- package/dist/store/redis-oauth-broker-store.d.ts +42 -0
- package/dist/store/redis-oauth-broker-store.js +167 -0
- package/dist/store/redis-oauth-broker-store.test.d.ts +1 -0
- package/dist/store/redis-oauth-broker-store.test.js +80 -0
- package/dist/store/redis-preview-store.d.ts +23 -0
- package/dist/store/redis-preview-store.js +94 -0
- package/dist/store/redis-preview-store.test.d.ts +1 -0
- package/dist/store/redis-preview-store.test.js +39 -0
- package/dist/store/redis-session-index.d.ts +33 -0
- package/dist/store/redis-session-index.js +49 -0
- package/dist/store/types.d.ts +13 -0
- package/dist/store/types.js +8 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.js +4 -30
- package/dist/tools/index.test.d.ts +1 -0
- package/dist/tools/index.test.js +72 -0
- package/dist/tools/lib/api-errors.d.ts +11 -0
- package/dist/tools/lib/api-errors.js +27 -0
- package/dist/tools/lib/api-shape.d.ts +16 -0
- package/dist/tools/lib/api-shape.js +47 -0
- package/dist/tools/lib/assert-safe.d.ts +13 -0
- package/dist/tools/lib/assert-safe.js +21 -0
- package/dist/tools/lib/assert-safe.test.d.ts +4 -0
- package/dist/tools/lib/assert-safe.test.js +32 -0
- package/dist/tools/lib/concurrency.d.ts +4 -0
- package/dist/tools/lib/concurrency.js +24 -0
- package/dist/tools/lib/contracts.d.ts +34 -0
- package/dist/tools/lib/contracts.js +30 -0
- package/dist/tools/lib/redaction.d.ts +107 -0
- package/dist/tools/lib/redaction.js +299 -0
- package/dist/tools/lib/redaction.test.d.ts +4 -0
- package/dist/tools/lib/redaction.test.js +216 -0
- package/dist/tools/lib/register-org-audit.d.ts +9 -0
- package/dist/tools/lib/register-org-audit.js +20 -0
- package/dist/tools/lib/schema-fields.d.ts +9 -0
- package/dist/tools/lib/schema-fields.js +19 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/binding.d.ts +14 -0
- package/dist/tools/organization/binding.js +31 -0
- package/dist/tools/organization/invariants.test.d.ts +4 -0
- package/dist/tools/organization/invariants.test.js +28 -0
- package/dist/tools/organization/inventory.d.ts +10 -0
- package/dist/tools/organization/inventory.js +189 -0
- package/dist/tools/organization/roles.d.ts +10 -0
- package/dist/tools/organization/roles.js +213 -0
- package/dist/tools/project/content.d.ts +9 -0
- package/dist/tools/project/content.js +192 -0
- package/dist/tools/project/delete-chart.d.ts +4 -0
- package/dist/tools/project/delete-chart.js +8 -0
- package/dist/tools/project/delete-dashboard.d.ts +4 -0
- package/dist/tools/project/delete-dashboard.js +8 -0
- package/dist/tools/project/developer-content-preview.d.ts +12 -0
- package/dist/tools/project/developer-content-preview.js +286 -0
- package/dist/tools/project/developer-content-shared.d.ts +18 -0
- package/dist/tools/project/developer-content-shared.js +46 -0
- package/dist/tools/project/developer-content-shared.test.d.ts +1 -0
- package/dist/tools/project/developer-content-shared.test.js +25 -0
- package/dist/tools/project/developer-content.d.ts +39 -0
- package/dist/tools/project/developer-content.js +584 -0
- package/dist/tools/project/developer-helpers.d.ts +180 -0
- package/dist/tools/project/developer-helpers.js +484 -0
- package/dist/tools/project/developer-helpers.test.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +509 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +6 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +42 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +42 -0
- package/dist/tools/project/parameters.d.ts +7 -0
- package/dist/tools/project/parameters.js +74 -0
- package/dist/tools/project/projects.d.ts +10 -0
- package/dist/tools/project/projects.js +102 -0
- package/dist/tools/project/projects.test.d.ts +1 -0
- package/dist/tools/project/projects.test.js +154 -0
- package/dist/tools/project/promote-dashboard.d.ts +4 -0
- package/dist/tools/project/promote-dashboard.js +8 -0
- package/dist/tools/project/reader-content.d.ts +9 -0
- package/dist/tools/project/reader-content.js +208 -0
- package/dist/tools/project/reader-execution.d.ts +7 -0
- package/dist/tools/project/reader-execution.js +214 -0
- package/dist/tools/project/schedulers.d.ts +7 -0
- package/dist/tools/project/schedulers.js +115 -0
- package/dist/tools/project/schemas/chart-upsert.d.ts +33 -0
- package/dist/tools/project/schemas/chart-upsert.js +66 -0
- package/dist/tools/project/schemas/dashboard-tile.d.ts +29 -0
- package/dist/tools/project/schemas/dashboard-tile.js +57 -0
- package/dist/tools/project/schemas/dashboard.d.ts +70 -0
- package/dist/tools/project/schemas/dashboard.js +101 -0
- package/dist/tools/project/schemas/duplicate.d.ts +30 -0
- package/dist/tools/project/schemas/duplicate.js +86 -0
- package/dist/tools/project/schemas/index.d.ts +7 -0
- package/dist/tools/project/schemas/index.js +26 -0
- package/dist/tools/project/schemas/parse-helpers.d.ts +14 -0
- package/dist/tools/project/schemas/parse-helpers.js +34 -0
- package/dist/tools/project/schemas/payload-schemas.test.d.ts +1 -0
- package/dist/tools/project/schemas/payload-schemas.test.js +204 -0
- package/dist/tools/project/spaces.d.ts +7 -0
- package/dist/tools/project/spaces.js +101 -0
- package/dist/tools/query/bounded-saved-query.d.ts +37 -0
- package/dist/tools/query/bounded-saved-query.js +80 -0
- package/dist/tools/query/bounded-saved-query.test.d.ts +4 -0
- package/dist/tools/query/bounded-saved-query.test.js +82 -0
- package/dist/tools/query/chart-source.d.ts +10 -0
- package/dist/tools/query/chart-source.js +36 -0
- package/dist/tools/query/chart-source.test.d.ts +1 -0
- package/dist/tools/query/chart-source.test.js +62 -0
- package/dist/tools/query/filter-overrides.d.ts +34 -0
- package/dist/tools/query/filter-overrides.js +75 -0
- package/dist/tools/query/filter-overrides.test.d.ts +1 -0
- package/dist/tools/query/filter-overrides.test.js +21 -0
- package/dist/tools/query/lifecycle.d.ts +7 -0
- package/dist/tools/query/lifecycle.js +112 -0
- package/dist/tools/query/query-ledger.d.ts +34 -0
- package/dist/tools/query/query-ledger.js +86 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +73 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +59 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +49 -0
- package/dist/tools/query/result-normalizer.d.ts +27 -0
- package/dist/tools/query/result-normalizer.js +133 -0
- package/dist/tools/query/result-normalizer.test.d.ts +1 -0
- package/dist/tools/query/result-normalizer.test.js +41 -0
- package/dist/tools/query/wait-for-async.d.ts +10 -0
- package/dist/tools/query/wait-for-async.js +46 -0
- package/dist/tools/query/wait-for-async.test.d.ts +1 -0
- package/dist/tools/query/wait-for-async.test.js +45 -0
- package/dist/tools/registry.d.ts +225 -0
- package/dist/tools/registry.js +115 -0
- package/dist/tools/semantic/explore-helpers.d.ts +56 -0
- package/dist/tools/semantic/explore-helpers.js +115 -0
- package/dist/tools/semantic/explore-helpers.test.d.ts +1 -0
- package/dist/tools/semantic/explore-helpers.test.js +170 -0
- package/dist/tools/semantic/explores.d.ts +9 -0
- package/dist/tools/semantic/explores.js +80 -0
- package/dist/tools/semantic/metrics.d.ts +7 -0
- package/dist/tools/semantic/metrics.js +53 -0
- package/dist/tools/semantic/query.d.ts +6 -0
- package/dist/tools/semantic/query.js +42 -0
- package/dist/tools/semantic/schema-fields.d.ts +3 -0
- package/dist/tools/semantic/schema-fields.js +7 -0
- package/dist/tools/shared.d.ts +51 -15
- package/dist/tools/shared.js +171 -163
- package/dist/tools/shared.test.js +137 -184
- package/dist/tools/space/access.d.ts +66 -0
- package/dist/tools/space/access.js +322 -0
- package/dist/tools/space/access.test.d.ts +4 -0
- package/dist/tools/space/access.test.js +90 -0
- package/dist/transports/http-body.d.ts +5 -0
- package/dist/transports/http-body.js +50 -0
- package/dist/transports/http-request-utils.d.ts +2 -0
- package/dist/transports/http-request-utils.js +13 -0
- package/dist/transports/http-response.d.ts +6 -0
- package/dist/transports/http-response.js +56 -0
- package/dist/transports/session-store.d.ts +72 -0
- package/dist/transports/session-store.js +143 -0
- package/dist/transports/session-store.test.d.ts +1 -0
- package/dist/transports/session-store.test.js +111 -0
- package/dist/transports/streamable-http.d.ts +9 -0
- package/dist/transports/streamable-http.js +461 -0
- package/dist/transports/streamable-http.test.d.ts +1 -0
- package/dist/transports/streamable-http.test.js +100 -0
- package/package.json +26 -10
- package/dist/audit.d.ts +0 -6
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -82
- package/dist/tools/ai-agents.d.ts +0 -6
- package/dist/tools/ai-agents.js +0 -388
- package/dist/tools/charts.d.ts +0 -6
- package/dist/tools/charts.js +0 -55
- package/dist/tools/content.d.ts +0 -6
- package/dist/tools/content.js +0 -37
- package/dist/tools/dashboards.d.ts +0 -6
- package/dist/tools/dashboards.js +0 -28
- package/dist/tools/explores.d.ts +0 -6
- package/dist/tools/explores.js +0 -65
- package/dist/tools/groups.d.ts +0 -6
- package/dist/tools/groups.js +0 -121
- package/dist/tools/metrics.d.ts +0 -6
- package/dist/tools/metrics.js +0 -45
- package/dist/tools/projects.d.ts +0 -6
- package/dist/tools/projects.js +0 -58
- package/dist/tools/query.d.ts +0 -6
- package/dist/tools/query.js +0 -34
- package/dist/tools/schedulers.d.ts +0 -6
- package/dist/tools/schedulers.js +0 -45
- package/dist/tools/spaces.d.ts +0 -6
- package/dist/tools/spaces.js +0 -128
- package/dist/tools/tags.d.ts +0 -6
- package/dist/tools/tags.js +0 -28
- package/dist/tools/users.d.ts +0 -6
- package/dist/tools/users.js +0 -50
- package/src/audit.ts +0 -6
- package/src/bin.ts +0 -58
- package/src/config.ts +0 -83
- package/src/errors.ts +0 -27
- package/src/http.ts +0 -187
- package/src/index.integration.test.ts +0 -57
- package/src/index.test.ts +0 -8
- package/src/index.ts +0 -31
- package/src/tools/ai-agents.ts +0 -759
- package/src/tools/charts.ts +0 -85
- package/src/tools/content.ts +0 -44
- package/src/tools/dashboards.ts +0 -25
- package/src/tools/explores.ts +0 -98
- package/src/tools/groups.ts +0 -180
- package/src/tools/index.ts +0 -35
- package/src/tools/metrics.ts +0 -42
- package/src/tools/projects.ts +0 -74
- package/src/tools/query.ts +0 -47
- package/src/tools/schedulers.ts +0 -42
- package/src/tools/shared.test.ts +0 -365
- package/src/tools/shared.ts +0 -274
- package/src/tools/spaces.ts +0 -217
- package/src/tools/tags.ts +0 -25
- package/src/tools/users.ts +0 -64
- package/tsconfig.json +0 -13
- /package/dist/{errors.d.ts → server/errors.d.ts} +0 -0
- /package/dist/{errors.js → server/errors.js} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Safety assert unit tests.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const common_1 = require("@lightdash-tools/common");
|
|
7
|
+
const vitest_1 = require("vitest");
|
|
8
|
+
const assert_safe_js_1 = require("./assert-safe.js");
|
|
9
|
+
(0, vitest_1.describe)('assertOrganizationAuditToolSafe', () => {
|
|
10
|
+
(0, vitest_1.it)('accepts read-only GET tools', () => {
|
|
11
|
+
(0, vitest_1.expect)(() => (0, assert_safe_js_1.assertOrganizationAuditToolSafe)({
|
|
12
|
+
shortName: 'list_org_members',
|
|
13
|
+
annotations: common_1.READ_ONLY_DEFAULT,
|
|
14
|
+
httpMethod: 'GET',
|
|
15
|
+
})).not.toThrow();
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('rejects write annotations', () => {
|
|
18
|
+
(0, vitest_1.expect)(() => (0, assert_safe_js_1.assertOrganizationAuditToolSafe)({
|
|
19
|
+
shortName: 'bad',
|
|
20
|
+
annotations: common_1.WRITE_DESTRUCTIVE,
|
|
21
|
+
httpMethod: 'GET',
|
|
22
|
+
})).toThrow(/readOnlyHint/);
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.it)('rejects warehouse query tools', () => {
|
|
25
|
+
(0, vitest_1.expect)(() => (0, assert_safe_js_1.assertOrganizationAuditToolSafe)({
|
|
26
|
+
shortName: 'bad',
|
|
27
|
+
annotations: common_1.READ_ONLY_DEFAULT,
|
|
28
|
+
httpMethod: 'GET',
|
|
29
|
+
executesWarehouseQuery: true,
|
|
30
|
+
})).toThrow(/warehouse/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bounded async pool for organization-audit fan-out.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapWithConcurrency = mapWithConcurrency;
|
|
7
|
+
async function mapWithConcurrency(items, concurrency, mapper) {
|
|
8
|
+
const limit = Math.max(1, concurrency);
|
|
9
|
+
const results = new Array(items.length);
|
|
10
|
+
let next = 0;
|
|
11
|
+
async function worker() {
|
|
12
|
+
for (;;) {
|
|
13
|
+
const index = next;
|
|
14
|
+
next += 1;
|
|
15
|
+
if (index >= items.length)
|
|
16
|
+
return;
|
|
17
|
+
// eslint-disable-next-line security/detect-object-injection -- index from counter
|
|
18
|
+
results[index] = await mapper(items[index], index);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, () => worker());
|
|
22
|
+
await Promise.all(workers);
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared audit contracts for organization-audit MCP tools.
|
|
3
|
+
*/
|
|
4
|
+
export type ApiResolution = {
|
|
5
|
+
capability: string;
|
|
6
|
+
selectedVersion: 'v1' | 'v2';
|
|
7
|
+
method: 'GET';
|
|
8
|
+
pathTemplate: string;
|
|
9
|
+
reason: 'compatibility_override' | 'v2_incomplete' | 'v2_preferred' | 'v2_unavailable';
|
|
10
|
+
};
|
|
11
|
+
export type AuditWarningCode = 'INCOMPLETE_EFFECTIVE_ACCESS' | 'INCONSISTENT_REFERENCE' | 'PARTIAL_VISIBILITY' | 'REDACTED' | 'TRUNCATED' | 'UNSUPPORTED_CAPABILITY' | 'V1_FALLBACK';
|
|
12
|
+
export type AuditWarning = {
|
|
13
|
+
code: AuditWarningCode;
|
|
14
|
+
message: string;
|
|
15
|
+
resourceUuid?: string;
|
|
16
|
+
};
|
|
17
|
+
export type AuditCoverage = {
|
|
18
|
+
observedAt: string;
|
|
19
|
+
organizationUuid: string;
|
|
20
|
+
projectUuids?: string[];
|
|
21
|
+
projectPin?: string;
|
|
22
|
+
apiResolutions: ApiResolution[];
|
|
23
|
+
inaccessibleScopes: Array<{
|
|
24
|
+
scopeType: 'organization' | 'project' | 'resource' | 'space';
|
|
25
|
+
scopeUuid?: string;
|
|
26
|
+
reason: 'forbidden' | 'not_found' | 'unknown' | 'unsupported';
|
|
27
|
+
}>;
|
|
28
|
+
unsupportedCapabilities: string[];
|
|
29
|
+
/** Defaults false — callers must set true only when retrieval is known complete. */
|
|
30
|
+
complete: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare function emptyCoverage(organizationUuid: string, projectPin?: string): AuditCoverage;
|
|
33
|
+
/** Whether a single Knex-style page is the last page. */
|
|
34
|
+
export declare function isPageComplete(returned: number, totalResults?: number, totalPageCount?: number, page?: number): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared audit contracts for organization-audit MCP tools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emptyCoverage = emptyCoverage;
|
|
7
|
+
exports.isPageComplete = isPageComplete;
|
|
8
|
+
function emptyCoverage(organizationUuid, projectPin) {
|
|
9
|
+
return {
|
|
10
|
+
observedAt: new Date().toISOString(),
|
|
11
|
+
organizationUuid,
|
|
12
|
+
projectPin,
|
|
13
|
+
apiResolutions: [],
|
|
14
|
+
inaccessibleScopes: [],
|
|
15
|
+
unsupportedCapabilities: [],
|
|
16
|
+
complete: false,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Whether a single Knex-style page is the last page. */
|
|
20
|
+
function isPageComplete(returned, totalResults, totalPageCount, page) {
|
|
21
|
+
if (typeof totalResults === 'number') {
|
|
22
|
+
return (returned >= totalResults ||
|
|
23
|
+
(typeof page === 'number' && page >= (totalPageCount !== null && totalPageCount !== void 0 ? totalPageCount : Number.POSITIVE_INFINITY)));
|
|
24
|
+
}
|
|
25
|
+
if (typeof totalPageCount === 'number' && typeof page === 'number') {
|
|
26
|
+
return page >= totalPageCount;
|
|
27
|
+
}
|
|
28
|
+
// Unknown totals: single response without pagination metadata is treated incomplete.
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction helpers for MCP tool response sensitivity (ADR-0011).
|
|
3
|
+
*/
|
|
4
|
+
export type RedactedEmail = {
|
|
5
|
+
email: string;
|
|
6
|
+
domain: string;
|
|
7
|
+
isExternalDomain: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** MCP allowlisted project metadata — never includes connection secrets (not OpenAPI ProjectSummary). */
|
|
10
|
+
export type McpProjectSummary = {
|
|
11
|
+
projectUuid: string;
|
|
12
|
+
name: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
organizationUuid?: string;
|
|
15
|
+
upstreamProjectUuid?: string | null;
|
|
16
|
+
createdByUserUuid?: string | null;
|
|
17
|
+
createdAt?: string;
|
|
18
|
+
warehouseType?: string;
|
|
19
|
+
provisioningSource?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/** Allowlisted project direct-access row with optional email redaction. */
|
|
22
|
+
export type ProjectMemberAccessSummary = {
|
|
23
|
+
userUuid: string;
|
|
24
|
+
projectUuid: string;
|
|
25
|
+
firstName: string;
|
|
26
|
+
lastName: string;
|
|
27
|
+
role: string;
|
|
28
|
+
roleUuid?: string;
|
|
29
|
+
email: RedactedEmail | string | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare const CREDENTIALS_OMITTED_WARNING: {
|
|
32
|
+
code: "REDACTED";
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const EMAIL_REDACTED_WARNING: {
|
|
36
|
+
code: "REDACTED";
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const SCHEDULER_DESTINATIONS_REDACTED_WARNING: {
|
|
40
|
+
code: "REDACTED";
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
/** Warnings when emails are masked (empty when includeEmail is true). */
|
|
44
|
+
export declare function emailRedactionWarnings(includeEmail: boolean): Array<{
|
|
45
|
+
code: 'REDACTED';
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** Warnings when scheduler destinations are masked. */
|
|
49
|
+
export declare function destinationRedactionWarnings(revealDestinations: boolean): Array<{
|
|
50
|
+
code: 'REDACTED';
|
|
51
|
+
message: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Allowlisted org-member row with optional email redaction. */
|
|
54
|
+
export type OrgMemberSummary = {
|
|
55
|
+
userUuid: string;
|
|
56
|
+
organizationUuid?: string;
|
|
57
|
+
firstName: string;
|
|
58
|
+
lastName: string;
|
|
59
|
+
email: RedactedEmail | string | undefined;
|
|
60
|
+
isActive?: boolean;
|
|
61
|
+
isInviteExpired?: boolean;
|
|
62
|
+
role?: string;
|
|
63
|
+
roleUuid?: string;
|
|
64
|
+
};
|
|
65
|
+
/** Allowlisted group row; members only when present on the API payload. */
|
|
66
|
+
export type GroupSummary = {
|
|
67
|
+
uuid: string;
|
|
68
|
+
name: string;
|
|
69
|
+
organizationUuid?: string;
|
|
70
|
+
createdAt?: string;
|
|
71
|
+
updatedAt?: string;
|
|
72
|
+
createdByUserUuid?: string | null;
|
|
73
|
+
memberUuids?: string[];
|
|
74
|
+
members?: Array<{
|
|
75
|
+
userUuid: string;
|
|
76
|
+
firstName: string;
|
|
77
|
+
lastName: string;
|
|
78
|
+
email: RedactedEmail | string | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
export type RedactedDestination = {
|
|
82
|
+
destinationType: string;
|
|
83
|
+
redactedDestination: string;
|
|
84
|
+
domain?: string;
|
|
85
|
+
isExternalDomain?: boolean;
|
|
86
|
+
};
|
|
87
|
+
/** Redact an email to `a***@domain` form. */
|
|
88
|
+
export declare function redactEmail(email: string, allowedDomains?: string[]): RedactedEmail;
|
|
89
|
+
/** Optionally keep full email when includeEmail is true. */
|
|
90
|
+
export declare function maybeRedactEmail(email: string | null | undefined, includeEmail: boolean, allowedDomains?: string[]): RedactedEmail | string | undefined;
|
|
91
|
+
/** Redact a scheduler destination string (email, slack, or webhook URL). */
|
|
92
|
+
export declare function redactDestination(destinationType: string, raw: string, allowedDomains?: string[]): RedactedDestination;
|
|
93
|
+
/** Strip sensitive destination fields from a scheduler target; never spread raw secrets. */
|
|
94
|
+
export declare function sanitizeSchedulerTarget(target: Record<string, unknown>, revealDestinations: boolean, allowedEmailDomains?: string[]): Record<string, unknown>;
|
|
95
|
+
/** Normalize scheduler metadata with destination redaction by default. */
|
|
96
|
+
export declare function normalizeScheduler(raw: Record<string, unknown>, revealDestinations: boolean, allowedEmailDomains?: string[]): Record<string, unknown>;
|
|
97
|
+
/**
|
|
98
|
+
* Shape project / organization-project payloads to metadata only.
|
|
99
|
+
* Never returns warehouseConnection, dbtConnection, or schedulerFailureContactOverride.
|
|
100
|
+
*/
|
|
101
|
+
export declare function toProjectSummary(project: unknown): McpProjectSummary;
|
|
102
|
+
/** Map a project member profile with default email redaction. */
|
|
103
|
+
export declare function toProjectMemberAccessSummary(member: unknown, includeEmail: boolean, allowedEmailDomains?: string[]): ProjectMemberAccessSummary;
|
|
104
|
+
/** Map an organization member with default email redaction. */
|
|
105
|
+
export declare function toOrgMemberSummary(member: unknown, includeEmail: boolean, allowedEmailDomains?: string[]): OrgMemberSummary;
|
|
106
|
+
/** Allowlist group metadata; redact member emails when members are present. */
|
|
107
|
+
export declare function toGroupSummary(group: unknown, includeEmail: boolean, allowedEmailDomains?: string[]): GroupSummary;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Redaction helpers for MCP tool response sensitivity (ADR-0011).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING = exports.EMAIL_REDACTED_WARNING = exports.CREDENTIALS_OMITTED_WARNING = void 0;
|
|
7
|
+
exports.emailRedactionWarnings = emailRedactionWarnings;
|
|
8
|
+
exports.destinationRedactionWarnings = destinationRedactionWarnings;
|
|
9
|
+
exports.redactEmail = redactEmail;
|
|
10
|
+
exports.maybeRedactEmail = maybeRedactEmail;
|
|
11
|
+
exports.redactDestination = redactDestination;
|
|
12
|
+
exports.sanitizeSchedulerTarget = sanitizeSchedulerTarget;
|
|
13
|
+
exports.normalizeScheduler = normalizeScheduler;
|
|
14
|
+
exports.toProjectSummary = toProjectSummary;
|
|
15
|
+
exports.toProjectMemberAccessSummary = toProjectMemberAccessSummary;
|
|
16
|
+
exports.toOrgMemberSummary = toOrgMemberSummary;
|
|
17
|
+
exports.toGroupSummary = toGroupSummary;
|
|
18
|
+
exports.CREDENTIALS_OMITTED_WARNING = {
|
|
19
|
+
code: 'REDACTED',
|
|
20
|
+
message: 'Connection credentials and contact overrides omitted; not available via MCP (use client/CLI)',
|
|
21
|
+
};
|
|
22
|
+
exports.EMAIL_REDACTED_WARNING = {
|
|
23
|
+
code: 'REDACTED',
|
|
24
|
+
message: 'Email addresses redacted; pass includeEmail=true to reveal',
|
|
25
|
+
};
|
|
26
|
+
exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING = {
|
|
27
|
+
code: 'REDACTED',
|
|
28
|
+
message: 'Scheduler destinations redacted by default',
|
|
29
|
+
};
|
|
30
|
+
/** Warnings when emails are masked (empty when includeEmail is true). */
|
|
31
|
+
function emailRedactionWarnings(includeEmail) {
|
|
32
|
+
return includeEmail ? [] : [exports.EMAIL_REDACTED_WARNING];
|
|
33
|
+
}
|
|
34
|
+
/** Warnings when scheduler destinations are masked. */
|
|
35
|
+
function destinationRedactionWarnings(revealDestinations) {
|
|
36
|
+
return revealDestinations ? [] : [exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING];
|
|
37
|
+
}
|
|
38
|
+
const SENSITIVE_TARGET_KEYS = new Set([
|
|
39
|
+
'recipient',
|
|
40
|
+
'channel',
|
|
41
|
+
'email',
|
|
42
|
+
'value',
|
|
43
|
+
'webhook',
|
|
44
|
+
'googleChatWebhook',
|
|
45
|
+
'slackChannelName',
|
|
46
|
+
'slackChannelId',
|
|
47
|
+
]);
|
|
48
|
+
function splitEmail(email) {
|
|
49
|
+
const at = email.lastIndexOf('@');
|
|
50
|
+
if (at <= 0 || at === email.length - 1)
|
|
51
|
+
return undefined;
|
|
52
|
+
return { local: email.slice(0, at), domain: email.slice(at + 1).toLowerCase() };
|
|
53
|
+
}
|
|
54
|
+
/** Redact an email to `a***@domain` form. */
|
|
55
|
+
function redactEmail(email, allowedDomains) {
|
|
56
|
+
const parts = splitEmail(email);
|
|
57
|
+
if (!parts) {
|
|
58
|
+
return { email: '***', domain: 'unknown', isExternalDomain: true };
|
|
59
|
+
}
|
|
60
|
+
const local = parts.local;
|
|
61
|
+
const maskedLocal = local.length <= 1 ? '*' : `${local[0]}***`;
|
|
62
|
+
const allowed = new Set((allowedDomains !== null && allowedDomains !== void 0 ? allowedDomains : []).map((d) => d.toLowerCase()));
|
|
63
|
+
const isExternalDomain = allowed.size > 0 ? !allowed.has(parts.domain) : false;
|
|
64
|
+
return {
|
|
65
|
+
email: `${maskedLocal}@${parts.domain}`,
|
|
66
|
+
domain: parts.domain,
|
|
67
|
+
isExternalDomain,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Optionally keep full email when includeEmail is true. */
|
|
71
|
+
function maybeRedactEmail(email, includeEmail, allowedDomains) {
|
|
72
|
+
if (email == null || email === '')
|
|
73
|
+
return undefined;
|
|
74
|
+
if (includeEmail)
|
|
75
|
+
return email;
|
|
76
|
+
return redactEmail(email, allowedDomains);
|
|
77
|
+
}
|
|
78
|
+
const DESTINATION_FIELDS = [
|
|
79
|
+
{ key: 'webhook', destinationType: 'ms_teams_webhook' },
|
|
80
|
+
{ key: 'googleChatWebhook', destinationType: 'google_chat_webhook' },
|
|
81
|
+
{
|
|
82
|
+
key: 'channel',
|
|
83
|
+
destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'slack_channel'); },
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: 'recipient',
|
|
87
|
+
destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'email'); },
|
|
88
|
+
},
|
|
89
|
+
{ key: 'email', destinationType: 'email' },
|
|
90
|
+
{
|
|
91
|
+
key: 'value',
|
|
92
|
+
destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'unknown'); },
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
function stringField(target, key) {
|
|
96
|
+
// eslint-disable-next-line security/detect-object-injection -- key from fixed DESTINATION_FIELDS
|
|
97
|
+
const value = target[key];
|
|
98
|
+
return typeof value === 'string' && value ? value : undefined;
|
|
99
|
+
}
|
|
100
|
+
function extractRawDestination(target) {
|
|
101
|
+
var _a;
|
|
102
|
+
for (const field of DESTINATION_FIELDS) {
|
|
103
|
+
const raw = stringField(target, field.key);
|
|
104
|
+
if (!raw)
|
|
105
|
+
continue;
|
|
106
|
+
const destinationType = typeof field.destinationType === 'function'
|
|
107
|
+
? field.destinationType(target)
|
|
108
|
+
: field.destinationType;
|
|
109
|
+
return { destinationType, raw };
|
|
110
|
+
}
|
|
111
|
+
return { destinationType: String((_a = target.type) !== null && _a !== void 0 ? _a : 'unknown'), raw: '' };
|
|
112
|
+
}
|
|
113
|
+
/** Redact a scheduler destination string (email, slack, or webhook URL). */
|
|
114
|
+
function redactDestination(destinationType, raw, allowedDomains) {
|
|
115
|
+
if (destinationType === 'email' || raw.includes('@')) {
|
|
116
|
+
const redacted = redactEmail(raw, allowedDomains);
|
|
117
|
+
return {
|
|
118
|
+
destinationType: destinationType || 'email',
|
|
119
|
+
redactedDestination: redacted.email,
|
|
120
|
+
domain: redacted.domain,
|
|
121
|
+
isExternalDomain: redacted.isExternalDomain,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (raw.startsWith('http://') || raw.startsWith('https://')) {
|
|
125
|
+
try {
|
|
126
|
+
const url = new URL(raw);
|
|
127
|
+
return {
|
|
128
|
+
destinationType,
|
|
129
|
+
redactedDestination: `${url.protocol}//${url.host}/***`,
|
|
130
|
+
domain: url.host,
|
|
131
|
+
isExternalDomain: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (_a) {
|
|
135
|
+
// fall through
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const visible = raw.length <= 4 ? '****' : `${raw.slice(0, 2)}***${raw.slice(-2)}`;
|
|
139
|
+
return {
|
|
140
|
+
destinationType,
|
|
141
|
+
redactedDestination: visible,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Strip sensitive destination fields from a scheduler target; never spread raw secrets. */
|
|
145
|
+
function sanitizeSchedulerTarget(target, revealDestinations, allowedEmailDomains) {
|
|
146
|
+
var _a;
|
|
147
|
+
const { destinationType, raw } = extractRawDestination(target);
|
|
148
|
+
const safe = { type: (_a = target.type) !== null && _a !== void 0 ? _a : destinationType };
|
|
149
|
+
if (typeof target.schedulerUuid === 'string')
|
|
150
|
+
safe.schedulerUuid = target.schedulerUuid;
|
|
151
|
+
if (typeof target.schedulerTargetUuid === 'string') {
|
|
152
|
+
safe.schedulerTargetUuid = target.schedulerTargetUuid;
|
|
153
|
+
}
|
|
154
|
+
if (revealDestinations) {
|
|
155
|
+
for (const key of SENSITIVE_TARGET_KEYS) {
|
|
156
|
+
// eslint-disable-next-line security/detect-object-injection -- fixed allowlist set
|
|
157
|
+
if (key in target)
|
|
158
|
+
safe[key] = target[key];
|
|
159
|
+
}
|
|
160
|
+
return safe;
|
|
161
|
+
}
|
|
162
|
+
if (!raw) {
|
|
163
|
+
return Object.assign(Object.assign({}, safe), { destinationType, redactedDestination: '***' });
|
|
164
|
+
}
|
|
165
|
+
return Object.assign(Object.assign({}, safe), redactDestination(destinationType, raw, allowedEmailDomains));
|
|
166
|
+
}
|
|
167
|
+
/** Normalize scheduler metadata with destination redaction by default. */
|
|
168
|
+
function normalizeScheduler(raw, revealDestinations, allowedEmailDomains) {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
const targets = Array.isArray(raw.targets) ? raw.targets : [];
|
|
171
|
+
const normalizedTargets = targets.map((t) => {
|
|
172
|
+
if (!t || typeof t !== 'object')
|
|
173
|
+
return t;
|
|
174
|
+
return sanitizeSchedulerTarget(t, revealDestinations, allowedEmailDomains);
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
schedulerUuid: (_a = raw.schedulerUuid) !== null && _a !== void 0 ? _a : raw.uuid,
|
|
178
|
+
name: raw.name,
|
|
179
|
+
enabled: raw.enabled,
|
|
180
|
+
cron: raw.cron,
|
|
181
|
+
format: raw.format,
|
|
182
|
+
createdBy: raw.createdBy,
|
|
183
|
+
createdByUserUuid: (_b = raw.createdByUserUuid) !== null && _b !== void 0 ? _b : (typeof raw.createdBy === 'string' ? raw.createdBy : undefined),
|
|
184
|
+
savedChartUuid: raw.savedChartUuid,
|
|
185
|
+
dashboardUuid: raw.dashboardUuid,
|
|
186
|
+
latestRun: sanitizeLatestRun(raw.latestRun),
|
|
187
|
+
targets: normalizedTargets,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** Strip PII / opaque details from scheduler latestRun payloads. */
|
|
191
|
+
function sanitizeLatestRun(latestRun) {
|
|
192
|
+
if (!latestRun || typeof latestRun !== 'object')
|
|
193
|
+
return undefined;
|
|
194
|
+
const run = latestRun;
|
|
195
|
+
return {
|
|
196
|
+
runId: run.runId,
|
|
197
|
+
schedulerUuid: run.schedulerUuid,
|
|
198
|
+
runStatus: run.runStatus,
|
|
199
|
+
status: run.status,
|
|
200
|
+
scheduledTime: run.scheduledTime,
|
|
201
|
+
createdAt: run.createdAt,
|
|
202
|
+
createdByUserUuid: run.createdByUserUuid,
|
|
203
|
+
resourceType: run.resourceType,
|
|
204
|
+
resourceUuid: run.resourceUuid,
|
|
205
|
+
format: run.format,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function readString(record, key) {
|
|
209
|
+
// eslint-disable-next-line security/detect-object-injection -- fixed allowlist keys at call sites
|
|
210
|
+
const value = record[key];
|
|
211
|
+
return typeof value === 'string' ? value : undefined;
|
|
212
|
+
}
|
|
213
|
+
function readStringOrNull(record, key) {
|
|
214
|
+
// eslint-disable-next-line security/detect-object-injection -- fixed allowlist keys at call sites
|
|
215
|
+
const value = record[key];
|
|
216
|
+
if (value === null)
|
|
217
|
+
return null;
|
|
218
|
+
return typeof value === 'string' ? value : undefined;
|
|
219
|
+
}
|
|
220
|
+
function asEntityRecord(value) {
|
|
221
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
return {};
|
|
225
|
+
}
|
|
226
|
+
function warehouseTypeFrom(record) {
|
|
227
|
+
const direct = readString(record, 'warehouseType');
|
|
228
|
+
if (direct !== undefined)
|
|
229
|
+
return direct;
|
|
230
|
+
return readString(asEntityRecord(record.warehouseConnection), 'type');
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Shape project / organization-project payloads to metadata only.
|
|
234
|
+
* Never returns warehouseConnection, dbtConnection, or schedulerFailureContactOverride.
|
|
235
|
+
*/
|
|
236
|
+
function toProjectSummary(project) {
|
|
237
|
+
var _a, _b;
|
|
238
|
+
const record = asEntityRecord(project);
|
|
239
|
+
const type = readString(record, 'type');
|
|
240
|
+
const organizationUuid = readString(record, 'organizationUuid');
|
|
241
|
+
const upstreamProjectUuid = readStringOrNull(record, 'upstreamProjectUuid');
|
|
242
|
+
const createdByUserUuid = readStringOrNull(record, 'createdByUserUuid');
|
|
243
|
+
const createdAt = readString(record, 'createdAt');
|
|
244
|
+
const warehouseType = warehouseTypeFrom(record);
|
|
245
|
+
const provisioningSource = readStringOrNull(record, 'provisioningSource');
|
|
246
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ projectUuid: (_a = readString(record, 'projectUuid')) !== null && _a !== void 0 ? _a : '', name: (_b = readString(record, 'name')) !== null && _b !== void 0 ? _b : '' }, (type !== undefined ? { type } : {})), (organizationUuid !== undefined ? { organizationUuid } : {})), (upstreamProjectUuid !== undefined ? { upstreamProjectUuid } : {})), (createdByUserUuid !== undefined ? { createdByUserUuid } : {})), (createdAt !== undefined ? { createdAt } : {})), (warehouseType !== undefined ? { warehouseType } : {})), (provisioningSource !== undefined ? { provisioningSource } : {}));
|
|
247
|
+
}
|
|
248
|
+
/** Map a project member profile with default email redaction. */
|
|
249
|
+
function toProjectMemberAccessSummary(member, includeEmail, allowedEmailDomains) {
|
|
250
|
+
var _a, _b, _c, _d, _e;
|
|
251
|
+
const record = asEntityRecord(member);
|
|
252
|
+
const roleUuid = readString(record, 'roleUuid');
|
|
253
|
+
return Object.assign({ userUuid: (_a = readString(record, 'userUuid')) !== null && _a !== void 0 ? _a : '', projectUuid: (_b = readString(record, 'projectUuid')) !== null && _b !== void 0 ? _b : '', firstName: (_c = readString(record, 'firstName')) !== null && _c !== void 0 ? _c : '', lastName: (_d = readString(record, 'lastName')) !== null && _d !== void 0 ? _d : '', role: (_e = readString(record, 'role')) !== null && _e !== void 0 ? _e : '', email: maybeRedactEmail(readString(record, 'email'), includeEmail, allowedEmailDomains) }, (roleUuid !== undefined ? { roleUuid } : {}));
|
|
254
|
+
}
|
|
255
|
+
/** Map an organization member with default email redaction. */
|
|
256
|
+
function toOrgMemberSummary(member, includeEmail, allowedEmailDomains) {
|
|
257
|
+
var _a, _b, _c;
|
|
258
|
+
const record = asEntityRecord(member);
|
|
259
|
+
return {
|
|
260
|
+
userUuid: (_a = readString(record, 'userUuid')) !== null && _a !== void 0 ? _a : '',
|
|
261
|
+
organizationUuid: readString(record, 'organizationUuid'),
|
|
262
|
+
firstName: (_b = readString(record, 'firstName')) !== null && _b !== void 0 ? _b : '',
|
|
263
|
+
lastName: (_c = readString(record, 'lastName')) !== null && _c !== void 0 ? _c : '',
|
|
264
|
+
email: maybeRedactEmail(readString(record, 'email'), includeEmail, allowedEmailDomains),
|
|
265
|
+
isActive: typeof record.isActive === 'boolean' ? record.isActive : undefined,
|
|
266
|
+
isInviteExpired: typeof record.isInviteExpired === 'boolean' ? record.isInviteExpired : undefined,
|
|
267
|
+
role: readString(record, 'role'),
|
|
268
|
+
roleUuid: readString(record, 'roleUuid'),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** Allowlist group metadata; redact member emails when members are present. */
|
|
272
|
+
function toGroupSummary(group, includeEmail, allowedEmailDomains) {
|
|
273
|
+
var _a, _b;
|
|
274
|
+
const record = asEntityRecord(group);
|
|
275
|
+
const summary = {
|
|
276
|
+
uuid: (_a = readString(record, 'uuid')) !== null && _a !== void 0 ? _a : '',
|
|
277
|
+
name: (_b = readString(record, 'name')) !== null && _b !== void 0 ? _b : '',
|
|
278
|
+
organizationUuid: readString(record, 'organizationUuid'),
|
|
279
|
+
createdAt: readString(record, 'createdAt'),
|
|
280
|
+
updatedAt: readString(record, 'updatedAt'),
|
|
281
|
+
createdByUserUuid: readStringOrNull(record, 'createdByUserUuid'),
|
|
282
|
+
};
|
|
283
|
+
if (Array.isArray(record.memberUuids)) {
|
|
284
|
+
summary.memberUuids = record.memberUuids.filter((u) => typeof u === 'string');
|
|
285
|
+
}
|
|
286
|
+
if (Array.isArray(record.members)) {
|
|
287
|
+
summary.members = record.members.map((m) => {
|
|
288
|
+
var _a, _b, _c;
|
|
289
|
+
const member = asEntityRecord(m);
|
|
290
|
+
return {
|
|
291
|
+
userUuid: (_a = readString(member, 'userUuid')) !== null && _a !== void 0 ? _a : '',
|
|
292
|
+
firstName: (_b = readString(member, 'firstName')) !== null && _b !== void 0 ? _b : '',
|
|
293
|
+
lastName: (_c = readString(member, 'lastName')) !== null && _c !== void 0 ? _c : '',
|
|
294
|
+
email: maybeRedactEmail(readString(member, 'email'), includeEmail, allowedEmailDomains),
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return summary;
|
|
299
|
+
}
|