@lightdash-tools/mcp 0.7.0 → 0.9.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 +113 -170
- package/dist/audit/server-persona.d.ts +10 -0
- package/dist/audit/server-persona.js +19 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +69 -19
- package/dist/auth/oauth-broker/pending-store.js +52 -26
- package/dist/auth/oauth-broker/pending-store.test.d.ts +5 -0
- package/dist/auth/oauth-broker/pending-store.test.js +109 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -2
- package/dist/auth/oauth-broker/routes.js +25 -20
- package/dist/auth/oauth-broker/routes.test.js +33 -28
- package/dist/auth/request-state-key.d.ts +19 -0
- package/dist/auth/request-state-key.js +49 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +0 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +0 -19
- package/dist/auth/resource-server/www-authenticate.test.js +12 -8
- package/dist/bin.js +30 -2
- package/dist/config/env.d.ts +5 -8
- package/dist/config/env.js +6 -9
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +8 -5
- package/dist/config/load-mcp-config.test.js +7 -0
- package/dist/config/normalize-url.test.js +16 -7
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +19 -23
- package/dist/config/runtime.test.js +23 -9
- package/dist/config/test-mcp-http-config.js +1 -1
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.js +46 -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 +150 -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 +398 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +283 -0
- package/dist/destructive/request-state.d.ts +12 -0
- package/dist/destructive/request-state.js +41 -0
- package/dist/destructive/types.d.ts +65 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/available-projects.d.ts +37 -0
- package/dist/governance/available-projects.js +132 -0
- package/dist/governance/available-projects.test.d.ts +4 -0
- package/dist/governance/available-projects.test.js +107 -0
- package/dist/governance/client-capabilities-cache.d.ts +44 -0
- package/dist/governance/client-capabilities-cache.js +142 -0
- package/dist/governance/client-capabilities-cache.test.d.ts +1 -0
- package/dist/governance/client-capabilities-cache.test.js +148 -0
- package/dist/governance/mcp-client-session.d.ts +10 -0
- package/dist/governance/mcp-client-session.js +31 -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-scope.d.ts +24 -0
- package/dist/governance/project-scope.js +71 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +80 -0
- package/dist/governance/promote-allowlist.d.ts +18 -0
- package/dist/governance/promote-allowlist.js +66 -0
- package/dist/governance/promote-allowlist.test.d.ts +4 -0
- package/dist/governance/promote-allowlist.test.js +87 -0
- package/dist/http.integration.test.js +151 -262
- package/dist/http.test.js +0 -12
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +3 -1
- package/dist/personas/ai-agent-ops/v1/index.d.ts +8 -0
- package/dist/personas/ai-agent-ops/v1/index.js +41 -0
- package/dist/personas/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/personas/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +52 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +8 -0
- package/dist/personas/content-developer/v1/prompts.js +157 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +231 -0
- package/dist/personas/content-developer/v1/resources/playbooks/chart-types.md +123 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +22 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +105 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +103 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +63 -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 +38 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +162 -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 +36 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +67 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +35 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +49 -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 +4 -0
- package/dist/personas/index.js +31 -10
- package/dist/personas/index.test.js +92 -26
- package/dist/personas/lib/playbook-resources.d.ts +80 -0
- package/dist/personas/lib/playbook-resources.js +169 -0
- package/dist/personas/organization-audit/v1/index.js +2 -2
- package/dist/personas/organization-audit/v1/prompts.js +79 -66
- package/dist/personas/organization-audit/v1/prompts.test.js +4 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +21 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +19 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +69 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +14 -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 +30 -0
- package/dist/personas/semantic-layer/v1/index.js +2 -2
- package/dist/personas/semantic-layer/v1/prompts.js +56 -67
- 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 +60 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +71 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +79 -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 +1 -1
- 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 +54 -0
- package/dist/policy/content-reader.d.ts +28 -0
- package/dist/policy/content-reader.js +67 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +23 -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 +202 -0
- package/dist/policy/preview-ledger.d.ts +82 -0
- package/dist/policy/preview-ledger.js +165 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +393 -0
- package/dist/policy/result-limits.d.ts +32 -0
- package/dist/policy/result-limits.js +106 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +37 -0
- package/dist/server/capabilities.js +3 -1
- package/dist/server/capabilities.test.js +5 -1
- package/dist/server/server.js +16 -1
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.d.ts +1 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +150 -0
- package/dist/tools/ai-agents/agents.d.ts +7 -0
- package/dist/tools/ai-agents/agents.js +32 -0
- package/dist/tools/ai-agents/agents.test.d.ts +1 -0
- package/dist/tools/ai-agents/agents.test.js +176 -0
- package/dist/tools/ai-agents/discovery.d.ts +9 -0
- package/dist/tools/ai-agents/discovery.js +73 -0
- package/dist/tools/ai-agents/evaluations.d.ts +14 -0
- package/dist/tools/ai-agents/evaluations.js +177 -0
- package/dist/tools/ai-agents/helpers.d.ts +64 -0
- package/dist/tools/ai-agents/helpers.js +323 -0
- package/dist/tools/ai-agents/threads.d.ts +7 -0
- package/dist/tools/ai-agents/threads.js +40 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/lib/api-errors.d.ts +2 -0
- package/dist/tools/lib/api-errors.js +5 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- 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 +13 -0
- package/dist/tools/project/developer-content-preview.js +291 -0
- package/dist/tools/project/developer-content-shared.d.ts +24 -0
- package/dist/tools/project/developer-content-shared.js +50 -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 +38 -0
- package/dist/tools/project/developer-content.js +589 -0
- package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
- package/dist/tools/project/developer-get-chart-as-code.js +39 -0
- package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
- package/dist/tools/project/developer-get-chart-as-code.test.js +70 -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 +52 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +44 -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 +4 -1
- package/dist/tools/project/projects.js +68 -6
- package/dist/tools/project/projects.test.js +77 -1
- 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/reader-export-chart-image.d.ts +6 -0
- package/dist/tools/project/reader-export-chart-image.js +78 -0
- package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
- package/dist/tools/project/reader-export-chart-image.test.js +149 -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 +104 -0
- package/dist/tools/query/query-ledger.d.ts +41 -0
- package/dist/tools/query/query-ledger.js +92 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +75 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +57 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +53 -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 +187 -3
- package/dist/tools/registry.js +89 -7
- package/dist/tools/shared.d.ts +52 -10
- package/dist/tools/shared.js +127 -41
- package/dist/tools/shared.test.js +103 -3
- package/dist/transports/streamable-http.js +47 -198
- package/dist/transports/streamable-http.test.js +21 -9
- package/package.json +5 -5
- package/dist/personas/organization-audit/v1/resources/playbook.d.ts +0 -11
- package/dist/personas/organization-audit/v1/resources/playbook.js +0 -40
- package/dist/personas/organization-audit/v1/resources/playbook.md +0 -52
- package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +0 -12
- package/dist/personas/semantic-layer/v1/resources/playbook.js +0 -42
- package/dist/personas/semantic-layer/v1/resources/playbook.md +0 -153
- package/dist/transports/http-request-utils.d.ts +0 -2
- package/dist/transports/http-request-utils.js +0 -13
- package/dist/transports/session-store.d.ts +0 -40
- package/dist/transports/session-store.js +0 -88
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{transports/session-store.test.d.ts → destructive/capability.test.d.ts} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat form schemas and message builders for elicitation-gated mutations
|
|
3
|
+
* (ADR-0015 soft-delete, ADR-0017 dashboard promote).
|
|
4
|
+
*/
|
|
5
|
+
import type { ConfirmationTarget } from './types.js';
|
|
6
|
+
export type DeleteConfirmFormContent = {
|
|
7
|
+
decision: 'confirm_delete' | 'do_not_delete';
|
|
8
|
+
confirmationText: string;
|
|
9
|
+
};
|
|
10
|
+
export type PromoteConfirmFormContent = {
|
|
11
|
+
decision: 'confirm_promote' | 'do_not_promote';
|
|
12
|
+
confirmationText: string;
|
|
13
|
+
};
|
|
14
|
+
/** Flat JSON Schema for form-mode elicitation (primitives only). */
|
|
15
|
+
export declare const DELETE_CONFIRM_FORM_SCHEMA: {
|
|
16
|
+
type: "object";
|
|
17
|
+
properties: {
|
|
18
|
+
decision: {
|
|
19
|
+
type: "string";
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
enum: string[];
|
|
23
|
+
enumNames: string[];
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
confirmationText: {
|
|
27
|
+
type: "string";
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
export declare const PROMOTE_CONFIRM_FORM_SCHEMA: {
|
|
35
|
+
type: "object";
|
|
36
|
+
properties: {
|
|
37
|
+
decision: {
|
|
38
|
+
type: "string";
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
enum: string[];
|
|
42
|
+
enumNames: string[];
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
confirmationText: {
|
|
46
|
+
type: "string";
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
required: string[];
|
|
52
|
+
};
|
|
53
|
+
export type ConfirmFormSchema = typeof DELETE_CONFIRM_FORM_SCHEMA | typeof PROMOTE_CONFIRM_FORM_SCHEMA;
|
|
54
|
+
export declare function normalizeResourceName(name: string): string;
|
|
55
|
+
export declare function buildDeleteConfirmationMessage(target: ConfirmationTarget): string;
|
|
56
|
+
export declare function buildPromoteConfirmationMessage(target: ConfirmationTarget): string;
|
|
57
|
+
export declare function isAcceptedDeleteForm(content: DeleteConfirmFormContent | undefined, expectedName: string): content is DeleteConfirmFormContent;
|
|
58
|
+
export declare function isAcceptedPromoteForm(content: PromoteConfirmFormContent | undefined, expectedName: string): content is PromoteConfirmFormContent;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Flat form schemas and message builders for elicitation-gated mutations
|
|
4
|
+
* (ADR-0015 soft-delete, ADR-0017 dashboard promote).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PROMOTE_CONFIRM_FORM_SCHEMA = exports.DELETE_CONFIRM_FORM_SCHEMA = void 0;
|
|
8
|
+
exports.normalizeResourceName = normalizeResourceName;
|
|
9
|
+
exports.buildDeleteConfirmationMessage = buildDeleteConfirmationMessage;
|
|
10
|
+
exports.buildPromoteConfirmationMessage = buildPromoteConfirmationMessage;
|
|
11
|
+
exports.isAcceptedDeleteForm = isAcceptedDeleteForm;
|
|
12
|
+
exports.isAcceptedPromoteForm = isAcceptedPromoteForm;
|
|
13
|
+
/** Flat JSON Schema for form-mode elicitation (primitives only). */
|
|
14
|
+
exports.DELETE_CONFIRM_FORM_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
decision: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
title: 'Delete resource?',
|
|
20
|
+
description: 'This soft-deletes the specified Lightdash resource (restorable from trash).',
|
|
21
|
+
enum: ['confirm_delete', 'do_not_delete'],
|
|
22
|
+
enumNames: ['Delete (soft-delete)', 'Keep resource'],
|
|
23
|
+
default: 'do_not_delete',
|
|
24
|
+
},
|
|
25
|
+
confirmationText: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
title: 'Type the resource name',
|
|
28
|
+
description: 'Enter the exact resource name shown in the message.',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
// Mutable `string[]` required by MCP form elicitation schema typing.
|
|
32
|
+
required: ['decision', 'confirmationText'],
|
|
33
|
+
};
|
|
34
|
+
exports.PROMOTE_CONFIRM_FORM_SCHEMA = {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
decision: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
title: 'Promote dashboard?',
|
|
40
|
+
description: 'This promotes the dashboard (and nested charts/spaces/data apps) to the configured upstream project.',
|
|
41
|
+
enum: ['confirm_promote', 'do_not_promote'],
|
|
42
|
+
enumNames: ['Promote to upstream', 'Do not promote'],
|
|
43
|
+
default: 'do_not_promote',
|
|
44
|
+
},
|
|
45
|
+
confirmationText: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
title: 'Type the dashboard name',
|
|
48
|
+
description: 'Enter the exact dashboard name shown in the message.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ['decision', 'confirmationText'],
|
|
52
|
+
};
|
|
53
|
+
function normalizeResourceName(name) {
|
|
54
|
+
return name.trim().replace(/\s+/g, ' ');
|
|
55
|
+
}
|
|
56
|
+
function appendTargetLines(lines, target) {
|
|
57
|
+
var _a;
|
|
58
|
+
lines.push(`Name: ${target.resourceName}`);
|
|
59
|
+
lines.push(`${target.resourceType === 'chart' ? 'Chart' : 'Dashboard'} UUID/slug: ${target.resourceId}`);
|
|
60
|
+
lines.push(`Project UUID: ${target.projectUuid}`);
|
|
61
|
+
if (target.location) {
|
|
62
|
+
lines.push(`Space: ${target.location}`);
|
|
63
|
+
}
|
|
64
|
+
if (target.updatedAt) {
|
|
65
|
+
lines.push(`Updated at: ${target.updatedAt}`);
|
|
66
|
+
}
|
|
67
|
+
for (const detail of (_a = target.details) !== null && _a !== void 0 ? _a : []) {
|
|
68
|
+
lines.push(detail);
|
|
69
|
+
}
|
|
70
|
+
for (const consequence of target.consequences) {
|
|
71
|
+
lines.push(consequence);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function buildDeleteConfirmationMessage(target) {
|
|
75
|
+
const lines = [`Confirm soft-deletion of this Lightdash ${target.resourceType}.`];
|
|
76
|
+
appendTargetLines(lines, target);
|
|
77
|
+
lines.push('Type the exact resource name to confirm. Soft-deleted items can be restored from trash.');
|
|
78
|
+
return lines.join('\n');
|
|
79
|
+
}
|
|
80
|
+
function buildPromoteConfirmationMessage(target) {
|
|
81
|
+
const lines = [
|
|
82
|
+
'Confirm promotion of this Lightdash dashboard to its configured upstream project.',
|
|
83
|
+
];
|
|
84
|
+
appendTargetLines(lines, target);
|
|
85
|
+
lines.push('Type the exact dashboard name to confirm. Nested charts, spaces, and data apps may be created or overwritten upstream.');
|
|
86
|
+
return lines.join('\n');
|
|
87
|
+
}
|
|
88
|
+
function isAcceptedConfirmForm(content, acceptDecision, expectedName) {
|
|
89
|
+
if (!content || content.decision !== acceptDecision) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return normalizeResourceName(content.confirmationText) === normalizeResourceName(expectedName);
|
|
93
|
+
}
|
|
94
|
+
function isAcceptedDeleteForm(content, expectedName) {
|
|
95
|
+
return isAcceptedConfirmForm(content, 'confirm_delete', expectedName);
|
|
96
|
+
}
|
|
97
|
+
function isAcceptedPromoteForm(content, expectedName) {
|
|
98
|
+
return isAcceptedConfirmForm(content, 'confirm_promote', expectedName);
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const confirmation_js_1 = require("./confirmation.js");
|
|
5
|
+
const target = {
|
|
6
|
+
operation: 'delete',
|
|
7
|
+
resourceType: 'chart',
|
|
8
|
+
resourceId: 'chart-1',
|
|
9
|
+
resourceName: 'Revenue KPI',
|
|
10
|
+
projectUuid: '11111111-1111-1111-1111-111111111111',
|
|
11
|
+
location: 'Finance',
|
|
12
|
+
updatedAt: '2026-08-01T00:00:00.000Z',
|
|
13
|
+
consequences: ['Hidden from normal lists.', 'Restorable from trash.'],
|
|
14
|
+
};
|
|
15
|
+
const promoteTarget = {
|
|
16
|
+
operation: 'promote',
|
|
17
|
+
resourceType: 'dashboard',
|
|
18
|
+
resourceId: 'dash-1',
|
|
19
|
+
resourceName: 'Exec Overview',
|
|
20
|
+
projectUuid: '11111111-1111-1111-1111-111111111111',
|
|
21
|
+
location: 'Executive',
|
|
22
|
+
updatedAt: '2026-08-01T00:00:00.000Z',
|
|
23
|
+
details: ['Charts: 2 create, 1 update'],
|
|
24
|
+
consequences: ['Nested charts may be overwritten upstream.'],
|
|
25
|
+
};
|
|
26
|
+
(0, vitest_1.describe)('normalizeResourceName', () => {
|
|
27
|
+
(0, vitest_1.it)('trims and collapses internal whitespace', () => {
|
|
28
|
+
(0, vitest_1.expect)((0, confirmation_js_1.normalizeResourceName)(' Revenue KPI ')).toBe('Revenue KPI');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
(0, vitest_1.describe)('buildDeleteConfirmationMessage', () => {
|
|
32
|
+
(0, vitest_1.it)('includes identity fields and consequences', () => {
|
|
33
|
+
const message = (0, confirmation_js_1.buildDeleteConfirmationMessage)(target);
|
|
34
|
+
(0, vitest_1.expect)(message).toContain('Confirm soft-deletion of this Lightdash chart.');
|
|
35
|
+
(0, vitest_1.expect)(message).toContain('Name: Revenue KPI');
|
|
36
|
+
(0, vitest_1.expect)(message).toContain('Chart UUID/slug: chart-1');
|
|
37
|
+
(0, vitest_1.expect)(message).toContain('Project UUID: 11111111-1111-1111-1111-111111111111');
|
|
38
|
+
(0, vitest_1.expect)(message).toContain('Space: Finance');
|
|
39
|
+
(0, vitest_1.expect)(message).toContain('Updated at: 2026-08-01T00:00:00.000Z');
|
|
40
|
+
(0, vitest_1.expect)(message).toContain('Hidden from normal lists.');
|
|
41
|
+
(0, vitest_1.expect)(message).toContain('Type the exact resource name to confirm');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
(0, vitest_1.describe)('isAcceptedDeleteForm', () => {
|
|
45
|
+
(0, vitest_1.it)('rejects missing content', () => {
|
|
46
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedDeleteForm)(undefined, 'Revenue KPI')).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)('rejects decline decisions', () => {
|
|
49
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedDeleteForm)({ decision: 'do_not_delete', confirmationText: 'Revenue KPI' }, 'Revenue KPI')).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.it)('rejects mismatched confirmation text', () => {
|
|
52
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedDeleteForm)({ decision: 'confirm_delete', confirmationText: 'Wrong Name' }, 'Revenue KPI')).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.it)('accepts confirm_delete with normalized matching name', () => {
|
|
55
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedDeleteForm)({ decision: 'confirm_delete', confirmationText: ' Revenue KPI ' }, 'Revenue KPI')).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.describe)('buildPromoteConfirmationMessage', () => {
|
|
59
|
+
(0, vitest_1.it)('includes promoteDiff details and upstream consequences', () => {
|
|
60
|
+
const message = (0, confirmation_js_1.buildPromoteConfirmationMessage)(promoteTarget);
|
|
61
|
+
(0, vitest_1.expect)(message).toContain('Confirm promotion of this Lightdash dashboard');
|
|
62
|
+
(0, vitest_1.expect)(message).toContain('Name: Exec Overview');
|
|
63
|
+
(0, vitest_1.expect)(message).toContain('Charts: 2 create, 1 update');
|
|
64
|
+
(0, vitest_1.expect)(message).toContain('Nested charts may be overwritten upstream.');
|
|
65
|
+
(0, vitest_1.expect)(message).toContain('Type the exact dashboard name to confirm');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.describe)('isAcceptedPromoteForm', () => {
|
|
69
|
+
(0, vitest_1.it)('rejects decline decisions', () => {
|
|
70
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedPromoteForm)({ decision: 'do_not_promote', confirmationText: 'Exec Overview' }, 'Exec Overview')).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.it)('accepts confirm_promote with matching name', () => {
|
|
73
|
+
(0, vitest_1.expect)((0, confirmation_js_1.isAcceptedPromoteForm)({ decision: 'confirm_promote', confirmationText: 'Exec Overview' }, 'Exec Overview')).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard promote operation (ADR-0017) — elicitation-gated cross-project release.
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../server/request-context.js';
|
|
5
|
+
import type { DashboardPromoteDiffResults } from '@lightdash-tools/client';
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
|
+
export declare function summarizePromotionChanges(diff: DashboardPromoteDiffResults): string[];
|
|
8
|
+
export declare function registerPromoteDashboard(server: McpServer, contextProvider: McpContextProvider): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dashboard promote operation (ADR-0017) — elicitation-gated cross-project release.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.summarizePromotionChanges = summarizePromotionChanges;
|
|
7
|
+
exports.registerPromoteDashboard = registerPromoteDashboard;
|
|
8
|
+
const common_1 = require("@lightdash-tools/common");
|
|
9
|
+
const promote_allowlist_js_1 = require("../governance/promote-allowlist.js");
|
|
10
|
+
const schema_fields_js_1 = require("../tools/lib/schema-fields.js");
|
|
11
|
+
const confirmation_js_1 = require("./confirmation.js");
|
|
12
|
+
const precondition_js_1 = require("./precondition.js");
|
|
13
|
+
const register_destructive_tool_js_1 = require("./register-destructive-tool.js");
|
|
14
|
+
const types_js_1 = require("./types.js");
|
|
15
|
+
/** OpenAPI PromotionAction is only create | update | no changes. */
|
|
16
|
+
function countActions(rows) {
|
|
17
|
+
var _a;
|
|
18
|
+
const counts = {
|
|
19
|
+
create: 0,
|
|
20
|
+
update: 0,
|
|
21
|
+
'no changes': 0,
|
|
22
|
+
};
|
|
23
|
+
for (const row of rows !== null && rows !== void 0 ? rows : []) {
|
|
24
|
+
counts[row.action] = ((_a = counts[row.action]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
25
|
+
}
|
|
26
|
+
return counts;
|
|
27
|
+
}
|
|
28
|
+
function formatActionCounts(label, counts) {
|
|
29
|
+
const parts = Object.entries(counts)
|
|
30
|
+
.filter(([, n]) => n > 0)
|
|
31
|
+
.map(([action, n]) => `${n} ${action}`);
|
|
32
|
+
if (parts.length === 0) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return `${label}: ${parts.join(', ')}`;
|
|
36
|
+
}
|
|
37
|
+
function summarizePromotionChanges(diff) {
|
|
38
|
+
const lines = [];
|
|
39
|
+
const chartLine = formatActionCounts('Charts', countActions(diff.charts));
|
|
40
|
+
const dashboardLine = formatActionCounts('Dashboards', countActions(diff.dashboards));
|
|
41
|
+
const spaceLine = formatActionCounts('Spaces', countActions(diff.spaces));
|
|
42
|
+
const sqlLine = formatActionCounts('SQL charts', countActions(diff.sqlCharts));
|
|
43
|
+
const appLine = formatActionCounts('Data apps', countActions(diff.dataApps));
|
|
44
|
+
for (const line of [dashboardLine, chartLine, spaceLine, sqlLine, appLine]) {
|
|
45
|
+
if (line) {
|
|
46
|
+
lines.push(line);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (lines.length === 0) {
|
|
50
|
+
lines.push('Promotion diff: no chart/dashboard/space changes reported.');
|
|
51
|
+
}
|
|
52
|
+
return lines;
|
|
53
|
+
}
|
|
54
|
+
function toDashboardSlice(dashboard) {
|
|
55
|
+
return {
|
|
56
|
+
uuid: dashboard.uuid,
|
|
57
|
+
slug: dashboard.slug,
|
|
58
|
+
name: dashboard.name,
|
|
59
|
+
projectUuid: dashboard.projectUuid,
|
|
60
|
+
spaceName: dashboard.spaceName,
|
|
61
|
+
spaceUuid: dashboard.spaceUuid,
|
|
62
|
+
updatedAt: dashboard.updatedAt,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function buildPromoteSpec() {
|
|
66
|
+
return {
|
|
67
|
+
operationId: 'content-governance.dashboards.promote',
|
|
68
|
+
resourceType: 'dashboard',
|
|
69
|
+
async resolveTarget(args, ctx) {
|
|
70
|
+
const client = ctx.lightdashClient;
|
|
71
|
+
const [dashboard, promoteDiff, project] = await Promise.all([
|
|
72
|
+
client.v2.dashboards.getDashboard(args.projectUuid, args.resourceId),
|
|
73
|
+
client.v1.dashboards.getDashboardPromoteDiff(args.resourceId, {
|
|
74
|
+
projectUuid: args.projectUuid,
|
|
75
|
+
}),
|
|
76
|
+
client.v1.projects.getProject(args.projectUuid),
|
|
77
|
+
]);
|
|
78
|
+
(0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
79
|
+
upstreamProjectUuid: project.upstreamProjectUuid,
|
|
80
|
+
promoteDiff,
|
|
81
|
+
});
|
|
82
|
+
return { dashboard: toDashboardSlice(dashboard), promoteDiff };
|
|
83
|
+
},
|
|
84
|
+
summarizeTarget(snapshot) {
|
|
85
|
+
var _a;
|
|
86
|
+
return {
|
|
87
|
+
operation: 'promote',
|
|
88
|
+
resourceType: 'dashboard',
|
|
89
|
+
resourceId: (_a = snapshot.dashboard.uuid) !== null && _a !== void 0 ? _a : snapshot.dashboard.slug,
|
|
90
|
+
resourceName: snapshot.dashboard.name,
|
|
91
|
+
projectUuid: snapshot.dashboard.projectUuid,
|
|
92
|
+
location: snapshot.dashboard.spaceName,
|
|
93
|
+
updatedAt: snapshot.dashboard.updatedAt,
|
|
94
|
+
details: summarizePromotionChanges(snapshot.promoteDiff),
|
|
95
|
+
consequences: [
|
|
96
|
+
'Upstream is the project configured under Data Ops (not chosen via tool args).',
|
|
97
|
+
'Nested charts, spaces, and data apps may be created or overwritten upstream.',
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
getPrecondition(snapshot) {
|
|
102
|
+
var _a;
|
|
103
|
+
const resourceId = (_a = snapshot.dashboard.uuid) !== null && _a !== void 0 ? _a : snapshot.dashboard.slug;
|
|
104
|
+
return {
|
|
105
|
+
resourceType: 'dashboard',
|
|
106
|
+
resourceId,
|
|
107
|
+
projectUuid: snapshot.dashboard.projectUuid,
|
|
108
|
+
digest: (0, precondition_js_1.hashPreconditionMaterial)({
|
|
109
|
+
name: snapshot.dashboard.name,
|
|
110
|
+
updatedAt: snapshot.dashboard.updatedAt,
|
|
111
|
+
spaceUuid: snapshot.dashboard.spaceUuid,
|
|
112
|
+
promoteDiff: snapshot.promoteDiff,
|
|
113
|
+
}),
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
async execute(args, _snapshot, ctx) {
|
|
117
|
+
const promoted = await ctx.lightdashClient.v1.dashboards.promoteDashboard(args.resourceId, {
|
|
118
|
+
projectUuid: args.projectUuid,
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
upstream: {
|
|
122
|
+
uuid: promoted.uuid,
|
|
123
|
+
slug: promoted.slug,
|
|
124
|
+
name: promoted.name,
|
|
125
|
+
projectUuid: promoted.projectUuid,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function registerPromoteDashboard(server, contextProvider) {
|
|
132
|
+
(0, register_destructive_tool_js_1.registerElicitationGatedTool)(server, 'promote_dashboard', contextProvider, {
|
|
133
|
+
options: {
|
|
134
|
+
title: 'Promote Lightdash dashboard',
|
|
135
|
+
description: 'Promote a dashboard (and nested charts) to its configured upstream project after form elicitation. Requires a client that supports form elicitation. Inspect impact first with get_dashboard_promote_diff.',
|
|
136
|
+
annotations: common_1.WRITE_DESTRUCTIVE,
|
|
137
|
+
resourceIdField: (0, schema_fields_js_1.uuidOrSlugField)('Dashboard UUID or slug'),
|
|
138
|
+
resourceIdArgName: 'dashboardUuidOrSlug',
|
|
139
|
+
idempotentHint: false,
|
|
140
|
+
},
|
|
141
|
+
spec: buildPromoteSpec(),
|
|
142
|
+
form: {
|
|
143
|
+
inputKey: types_js_1.CONFIRM_PROMOTE_INPUT_KEY,
|
|
144
|
+
formSchema: confirmation_js_1.PROMOTE_CONFIRM_FORM_SCHEMA,
|
|
145
|
+
buildMessage: confirmation_js_1.buildPromoteConfirmationMessage,
|
|
146
|
+
isAcceptedForm: confirmation_js_1.isAcceptedPromoteForm,
|
|
147
|
+
},
|
|
148
|
+
labels: register_destructive_tool_js_1.PROMOTE_GATE_LABELS,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared soft-delete operation specs for charts and dashboards (ADR-0015).
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../server/request-context.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export declare function registerDeleteChart(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
|
+
export declare function registerDeleteDashboard(server: McpServer, contextProvider: McpContextProvider): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared soft-delete operation specs for charts and dashboards (ADR-0015).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerDeleteChart = registerDeleteChart;
|
|
7
|
+
exports.registerDeleteDashboard = registerDeleteDashboard;
|
|
8
|
+
const common_1 = require("@lightdash-tools/common");
|
|
9
|
+
const api_errors_js_1 = require("../tools/lib/api-errors.js");
|
|
10
|
+
const schema_fields_js_1 = require("../tools/lib/schema-fields.js");
|
|
11
|
+
const precondition_js_1 = require("./precondition.js");
|
|
12
|
+
const register_destructive_tool_js_1 = require("./register-destructive-tool.js");
|
|
13
|
+
function toSoftDeleteSnapshot(resource) {
|
|
14
|
+
return {
|
|
15
|
+
uuid: resource.uuid,
|
|
16
|
+
slug: resource.slug,
|
|
17
|
+
name: resource.name,
|
|
18
|
+
projectUuid: resource.projectUuid,
|
|
19
|
+
spaceName: resource.spaceName,
|
|
20
|
+
spaceUuid: resource.spaceUuid,
|
|
21
|
+
updatedAt: resource.updatedAt,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function buildSoftDeleteSpec(config) {
|
|
25
|
+
const noun = config.resourceType;
|
|
26
|
+
return {
|
|
27
|
+
operationId: config.operationId,
|
|
28
|
+
resourceType: config.resourceType,
|
|
29
|
+
async resolveTarget(args, ctx) {
|
|
30
|
+
return config.get(ctx.lightdashClient, args.projectUuid, args.resourceId);
|
|
31
|
+
},
|
|
32
|
+
summarizeTarget(snapshot) {
|
|
33
|
+
var _a;
|
|
34
|
+
return {
|
|
35
|
+
operation: 'delete',
|
|
36
|
+
resourceType: config.resourceType,
|
|
37
|
+
resourceId: (_a = snapshot.uuid) !== null && _a !== void 0 ? _a : snapshot.slug,
|
|
38
|
+
resourceName: snapshot.name,
|
|
39
|
+
projectUuid: snapshot.projectUuid,
|
|
40
|
+
location: snapshot.spaceName,
|
|
41
|
+
updatedAt: snapshot.updatedAt,
|
|
42
|
+
consequences: [
|
|
43
|
+
`The ${noun} will be soft-deleted and hidden from normal lists.`,
|
|
44
|
+
'It can be restored from deleted content until permanently purged.',
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
getPrecondition(snapshot) {
|
|
49
|
+
var _a;
|
|
50
|
+
return (0, precondition_js_1.buildContentPrecondition)({
|
|
51
|
+
resourceType: config.resourceType,
|
|
52
|
+
resourceId: (_a = snapshot.uuid) !== null && _a !== void 0 ? _a : snapshot.slug,
|
|
53
|
+
projectUuid: snapshot.projectUuid,
|
|
54
|
+
name: snapshot.name,
|
|
55
|
+
updatedAt: snapshot.updatedAt,
|
|
56
|
+
spaceUuid: snapshot.spaceUuid,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
async execute(args, _snapshot, ctx) {
|
|
60
|
+
try {
|
|
61
|
+
await config.del(ctx.lightdashClient, args.projectUuid, args.resourceId);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if ((0, api_errors_js_1.isNotFoundError)(err)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function registerContentSoftDeleteTool(server, contextProvider, config) {
|
|
73
|
+
(0, register_destructive_tool_js_1.registerDestructiveDeleteTool)(server, config.shortName, {
|
|
74
|
+
title: config.title,
|
|
75
|
+
description: config.description,
|
|
76
|
+
annotations: common_1.WRITE_DESTRUCTIVE,
|
|
77
|
+
resourceIdField: (0, schema_fields_js_1.uuidOrSlugField)(config.resourceIdLabel),
|
|
78
|
+
resourceIdArgName: config.resourceIdArgName,
|
|
79
|
+
}, contextProvider, buildSoftDeleteSpec(config));
|
|
80
|
+
}
|
|
81
|
+
function registerDeleteChart(server, contextProvider) {
|
|
82
|
+
registerContentSoftDeleteTool(server, contextProvider, {
|
|
83
|
+
shortName: 'delete_chart',
|
|
84
|
+
title: 'Soft-delete Lightdash chart',
|
|
85
|
+
description: 'Soft-delete a saved chart after form elicitation confirmation (restorable from trash). Requires a client that supports form elicitation.',
|
|
86
|
+
operationId: 'content-governance.charts.delete',
|
|
87
|
+
resourceType: 'chart',
|
|
88
|
+
resourceIdArgName: 'chartUuidOrSlug',
|
|
89
|
+
resourceIdLabel: 'Chart UUID or slug',
|
|
90
|
+
get: async (client, projectUuid, id) => toSoftDeleteSnapshot(await client.v2.charts.getSavedChart(projectUuid, id)),
|
|
91
|
+
del: (client, projectUuid, id) => client.v2.charts.deleteSavedChart(projectUuid, id),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function registerDeleteDashboard(server, contextProvider) {
|
|
95
|
+
registerContentSoftDeleteTool(server, contextProvider, {
|
|
96
|
+
shortName: 'delete_dashboard',
|
|
97
|
+
title: 'Soft-delete Lightdash dashboard',
|
|
98
|
+
description: 'Soft-delete a dashboard after form elicitation confirmation (restorable from trash). Requires a client that supports form elicitation.',
|
|
99
|
+
operationId: 'content-governance.dashboards.delete',
|
|
100
|
+
resourceType: 'dashboard',
|
|
101
|
+
resourceIdArgName: 'dashboardUuidOrSlug',
|
|
102
|
+
resourceIdLabel: 'Dashboard UUID or slug',
|
|
103
|
+
get: async (client, projectUuid, id) => toSoftDeleteSnapshot(await client.v2.dashboards.getDashboard(projectUuid, id)),
|
|
104
|
+
del: (client, projectUuid, id) => client.v2.dashboards.deleteDashboard(projectUuid, id),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|