@lightdash-tools/mcp 0.24.0 → 0.25.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 +2 -2
- package/dist/auth/oauth-broker/as-metadata.d.ts +1 -0
- package/dist/auth/oauth-broker/as-metadata.js +5 -1
- package/dist/auth/oauth-broker/client-crypto.d.ts +12 -0
- package/dist/auth/oauth-broker/client-crypto.js +80 -0
- package/dist/auth/oauth-broker/client-directory.d.ts +39 -0
- package/dist/auth/oauth-broker/client-directory.js +104 -0
- package/dist/auth/oauth-broker/client-directory.test.d.ts +1 -0
- package/dist/auth/oauth-broker/client-directory.test.js +134 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +8 -0
- package/dist/auth/oauth-broker/lightdash-token.js +72 -8
- package/dist/auth/oauth-broker/mcp-access-token.d.ts +3 -0
- package/dist/auth/oauth-broker/mcp-access-token.js +9 -1
- package/dist/auth/oauth-broker/pending-store.d.ts +16 -4
- package/dist/auth/oauth-broker/pending-store.js +40 -18
- package/dist/auth/oauth-broker/refresh-crypto.d.ts +19 -0
- package/dist/auth/oauth-broker/refresh-crypto.js +70 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.js +40 -0
- package/dist/auth/oauth-broker/refresh-flow.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-flow.test.js +350 -0
- package/dist/auth/oauth-broker/refresh-grant.d.ts +46 -0
- package/dist/auth/oauth-broker/refresh-grant.js +288 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.js +254 -0
- package/dist/auth/oauth-broker/refresh-store.d.ts +61 -0
- package/dist/auth/oauth-broker/refresh-store.js +124 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -4
- package/dist/auth/oauth-broker/routes.js +114 -51
- package/dist/auth/oauth-broker/routes.test.js +48 -0
- package/dist/auth/oauth-broker/stores/client-kv.d.ts +46 -0
- package/dist/auth/oauth-broker/stores/client-kv.js +182 -0
- package/dist/auth/oauth-broker/stores/firestore.d.ts +29 -0
- package/dist/auth/oauth-broker/stores/firestore.js +201 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.js +30 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.js +24 -0
- package/dist/auth/oauth-broker/stores/postgres.d.ts +13 -0
- package/dist/auth/oauth-broker/stores/postgres.js +193 -0
- package/dist/auth/oauth-broker/stores/redis.d.ts +25 -0
- package/dist/auth/oauth-broker/stores/redis.js +337 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/config/env.d.ts +13 -0
- package/dist/config/env.js +14 -1
- package/dist/config/load-mcp-config.d.ts +20 -0
- package/dist/config/load-mcp-config.js +53 -1
- package/dist/config/load-mcp-config.test.js +53 -0
- package/dist/config/oauth-store-key.d.ts +2 -0
- package/dist/config/oauth-store-key.js +17 -0
- package/dist/policy/content-developer.d.ts +4 -1
- package/dist/policy/content-developer.js +7 -3
- package/dist/policy/preview-ledger.d.ts +11 -1
- package/dist/policy/preview-ledger.js +29 -3
- package/dist/policy/rename-rejected.d.ts +9 -0
- package/dist/policy/rename-rejected.js +15 -0
- package/dist/profiles/content-developer/v1/index.js +6 -0
- package/dist/profiles/content-developer/v1/prompt-specs.d.ts +1 -1
- package/dist/profiles/content-developer/v1/resources/playbooks/core.md +15 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/recovery/preview-stale.md +1 -0
- package/dist/profiles/content-reader/v1/prompt-specs.d.ts +1 -1
- package/dist/server/capabilities.d.ts +1 -1
- package/dist/stdio.process.test.js +3 -1
- package/dist/tools/project/content.js +8 -1
- package/dist/tools/project/developer-content.js +1 -1
- package/dist/tools/project/developer-helpers.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +1 -0
- package/dist/tools/project/developer-rename.d.ts +13 -0
- package/dist/tools/project/developer-rename.js +319 -0
- package/dist/tools/project/developer-rename.test.d.ts +5 -0
- package/dist/tools/project/developer-rename.test.js +296 -0
- package/dist/tools/project/reader-content.js +10 -3
- package/dist/tools/project/rename-instruction.d.ts +58 -0
- package/dist/tools/project/rename-instruction.js +104 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +1 -1
- package/dist/tools/query/reader-tool-helpers.js +4 -0
- package/dist/tools/registry.d.ts +1 -1
- package/dist/transports/streamable-http.js +33 -7
- package/package.json +13 -9
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
* ledger). confirm_preview mints a validated token; apply verifies + re-sends proposed.
|
|
7
7
|
*/
|
|
8
8
|
import type { ServerContext } from '@modelcontextprotocol/server';
|
|
9
|
-
export declare const PREVIEW_RESOURCE_KINDS: readonly ["chart", "content-move", "dashboard"];
|
|
9
|
+
export declare const PREVIEW_RESOURCE_KINDS: readonly ["chart", "content-move", "dashboard", "rename"];
|
|
10
10
|
export type PreviewResourceKind = (typeof PREVIEW_RESOURCE_KINDS)[number];
|
|
11
11
|
export type PreviewStatus = 'draft' | 'validated';
|
|
12
|
+
/** Sorted uuid lists from a project rename preview. Apply compares a fresh preview to them. */
|
|
13
|
+
export type RenameImpactBaseline = {
|
|
14
|
+
alerts: readonly string[];
|
|
15
|
+
charts: readonly string[];
|
|
16
|
+
dashboardSchedulers: readonly string[];
|
|
17
|
+
dashboards: readonly string[];
|
|
18
|
+
};
|
|
12
19
|
/** Snapshot identity captured when the preview was issued (for update stale detection). */
|
|
13
20
|
export type PreviewBaseline = {
|
|
14
21
|
updatedAt?: string;
|
|
15
22
|
uuid?: string;
|
|
16
23
|
slug?: string;
|
|
24
|
+
renameImpact?: RenameImpactBaseline;
|
|
17
25
|
};
|
|
18
26
|
/** Compact claims embedded in the HMAC-signed previewToken (no proposed body). */
|
|
19
27
|
export type PreviewTokenClaims = {
|
|
@@ -42,6 +50,8 @@ export declare function resetPreviewLedgerForTests(): void;
|
|
|
42
50
|
/** sha256 hex digest of the stable JSON form of `value` (preview binding hash). */
|
|
43
51
|
export declare function hashPreviewContent(value: unknown): string;
|
|
44
52
|
export declare function uniqueResourceKeys(...keys: Array<string | null | undefined>): string[];
|
|
53
|
+
/** True when both impact snapshots list the same uuids. A missing snapshot is stale. */
|
|
54
|
+
export declare function sameRenameImpact(stored: RenameImpactBaseline | undefined, fresh: RenameImpactBaseline | undefined): boolean;
|
|
45
55
|
/** Mint a draft previewToken (opaque HMAC blob). Does not store proposed on the server. */
|
|
46
56
|
export declare function mintDraftPreviewToken(input: {
|
|
47
57
|
subject: string;
|
|
@@ -11,6 +11,7 @@ exports.EMPTY_SERVER_CONTEXT = exports.DEFAULT_PREVIEW_TTL_MS = exports.PreviewL
|
|
|
11
11
|
exports.resetPreviewLedgerForTests = resetPreviewLedgerForTests;
|
|
12
12
|
exports.hashPreviewContent = hashPreviewContent;
|
|
13
13
|
exports.uniqueResourceKeys = uniqueResourceKeys;
|
|
14
|
+
exports.sameRenameImpact = sameRenameImpact;
|
|
14
15
|
exports.mintDraftPreviewToken = mintDraftPreviewToken;
|
|
15
16
|
exports.confirmPreviewToken = confirmPreviewToken;
|
|
16
17
|
exports.withValidatedPreviewApply = withValidatedPreviewApply;
|
|
@@ -18,7 +19,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
18
19
|
const server_1 = require("@modelcontextprotocol/server");
|
|
19
20
|
const request_state_key_js_1 = require("../auth/request-state-key.js");
|
|
20
21
|
const stable_stringify_js_1 = require("../tools/lib/stable-stringify.js");
|
|
21
|
-
exports.PREVIEW_RESOURCE_KINDS = ['chart', 'content-move', 'dashboard'];
|
|
22
|
+
exports.PREVIEW_RESOURCE_KINDS = ['chart', 'content-move', 'dashboard', 'rename'];
|
|
22
23
|
class PreviewLedgerError extends Error {
|
|
23
24
|
constructor(code, message) {
|
|
24
25
|
super(message);
|
|
@@ -65,9 +66,28 @@ function hashPreviewBinding(proposed, baseline) {
|
|
|
65
66
|
function resourceKeyMatches(claims, resourceKey) {
|
|
66
67
|
return claims.resourceKey === resourceKey || claims.resourceAliases.includes(resourceKey);
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
function sameIds(left, right) {
|
|
70
|
+
if (left.length !== right.length) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return left.every((id, index) => {
|
|
74
|
+
const [counterpart] = right.slice(index, index + 1);
|
|
75
|
+
return id === counterpart;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** True when both impact snapshots list the same uuids. A missing snapshot is stale. */
|
|
79
|
+
function sameRenameImpact(stored, fresh) {
|
|
80
|
+
if (stored == null || fresh == null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return (sameIds(stored.alerts, fresh.alerts) &&
|
|
84
|
+
sameIds(stored.charts, fresh.charts) &&
|
|
85
|
+
sameIds(stored.dashboardSchedulers, fresh.dashboardSchedulers) &&
|
|
86
|
+
sameIds(stored.dashboards, fresh.dashboards));
|
|
87
|
+
}
|
|
88
|
+
/** Update drift, create-target appearance, or a changed project rename impact → PREVIEW_STALE. */
|
|
69
89
|
function assertBaselineStillValid(previewId, claims, currentBaseline) {
|
|
70
|
-
var _a;
|
|
90
|
+
var _a, _b;
|
|
71
91
|
const previewedUpdatedAt = (_a = claims.baseline) === null || _a === void 0 ? void 0 : _a.updatedAt;
|
|
72
92
|
if (previewedUpdatedAt != null &&
|
|
73
93
|
previewedUpdatedAt !== '' &&
|
|
@@ -79,6 +99,12 @@ function assertBaselineStillValid(previewId, claims, currentBaseline) {
|
|
|
79
99
|
((currentBaseline === null || currentBaseline === void 0 ? void 0 : currentBaseline.updatedAt) != null && currentBaseline.updatedAt !== ''))) {
|
|
80
100
|
throw new PreviewLedgerError('PREVIEW_STALE', `Preview '${previewId}' targeted a non-existent resource that now exists; re-run preview -> confirm`);
|
|
81
101
|
}
|
|
102
|
+
const storedImpact = (_b = claims.baseline) === null || _b === void 0 ? void 0 : _b.renameImpact;
|
|
103
|
+
const freshImpact = currentBaseline === null || currentBaseline === void 0 ? void 0 : currentBaseline.renameImpact;
|
|
104
|
+
if ((storedImpact != null || freshImpact != null) &&
|
|
105
|
+
!sameRenameImpact(storedImpact, freshImpact)) {
|
|
106
|
+
throw new PreviewLedgerError('PREVIEW_STALE', `Preview '${previewId}' rename impact changed; re-run preview_rename -> confirm`);
|
|
107
|
+
}
|
|
82
108
|
}
|
|
83
109
|
function resolveServerContext(serverContext) {
|
|
84
110
|
return serverContext !== null && serverContext !== void 0 ? serverContext : exports.EMPTY_SERVER_CONTEXT;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coded rejection for a rename instruction that must not be previewed or posted.
|
|
3
|
+
* Lives next to the content-developer error mapper so policy does not import tools.
|
|
4
|
+
*/
|
|
5
|
+
export type RenameRejectCode = 'RENAME_DRY_RUN' | 'RENAME_FIELD_UNLISTED' | 'RENAME_TARGET' | 'RENAME_UNCHANGED';
|
|
6
|
+
export declare class RenameRejectedError extends Error {
|
|
7
|
+
readonly code: RenameRejectCode;
|
|
8
|
+
constructor(code: RenameRejectCode, message: string);
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Coded rejection for a rename instruction that must not be previewed or posted.
|
|
4
|
+
* Lives next to the content-developer error mapper so policy does not import tools.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RenameRejectedError = void 0;
|
|
8
|
+
class RenameRejectedError extends Error {
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'RenameRejectedError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RenameRejectedError = RenameRejectedError;
|
|
@@ -9,6 +9,7 @@ exports.contentDeveloperProfile = exports.CONTENT_DEVELOPER_PROFILE_PATH = void
|
|
|
9
9
|
const developer_content_preview_js_1 = require("../../../tools/project/developer-content-preview.js");
|
|
10
10
|
const developer_content_js_1 = require("../../../tools/project/developer-content.js");
|
|
11
11
|
const developer_get_chart_as_code_js_1 = require("../../../tools/project/developer-get-chart-as-code.js");
|
|
12
|
+
const developer_rename_js_1 = require("../../../tools/project/developer-rename.js");
|
|
12
13
|
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
13
14
|
const reader_content_js_1 = require("../../../tools/project/reader-content.js");
|
|
14
15
|
const spaces_js_1 = require("../../../tools/project/spaces.js");
|
|
@@ -46,6 +47,11 @@ exports.contentDeveloperProfile = {
|
|
|
46
47
|
developer_content_js_1.removeDashboardTileTool,
|
|
47
48
|
developer_content_js_1.resizeDashboardTileTool,
|
|
48
49
|
developer_content_js_1.moveContentTool,
|
|
50
|
+
developer_rename_js_1.listRenameFieldsTool,
|
|
51
|
+
developer_rename_js_1.previewRenameTool,
|
|
52
|
+
developer_rename_js_1.renameChartTool,
|
|
53
|
+
developer_rename_js_1.renameDashboardFilterTool,
|
|
54
|
+
developer_rename_js_1.renameProjectTool,
|
|
49
55
|
],
|
|
50
56
|
registerPrompts: prompts_js_1.registerContentDeveloperPrompts,
|
|
51
57
|
registerResources: playbooks_js_1.registerContentDeveloperPlaybook,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Pure PromptContextSpec builders for content-developer prompts.
|
|
3
3
|
* Shared by registerContentDeveloperPrompts and budget gates.
|
|
4
4
|
*/
|
|
5
|
-
import type { ContentDeveloperPlaybookTopic } from './resources/playbooks.js';
|
|
6
5
|
import type { PromptContextSpec } from '../../lib/prompt-context.js';
|
|
6
|
+
import type { ContentDeveloperPlaybookTopic } from './resources/playbooks.js';
|
|
7
7
|
/** Topics for create/improve dashboard prompts (shell + design + viz). */
|
|
8
8
|
export declare const DASHBOARD_CHART_TOPIC_IDS: readonly ["dashboards", "dashboard-design", "chart-types"];
|
|
9
9
|
/** Topics for refactor (shell + design). */
|
|
@@ -61,6 +61,9 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
61
61
|
| `create_dashboard` / `update_dashboard` / `duplicate_dashboard` | Dashboard shell then tile updates |
|
|
62
62
|
| `add_dashboard_tile` / `move_dashboard_tile` / `remove_dashboard_tile` / `resize_dashboard_tile` | Tile ops; each needs preview of the **full next tiles array** |
|
|
63
63
|
| `move_content` | Relocate into existing spaces |
|
|
64
|
+
| `list_rename_fields` | Field ids that can replace a missing chart field or dashboard filter target |
|
|
65
|
+
| `preview_rename` | Mint draft `previewToken` for a rename instruction |
|
|
66
|
+
| `rename_chart` / `rename_dashboard_filter` / `rename_project` | Rename writes after confirm. See **Rename a missing field** |
|
|
64
67
|
| `validate_chart` / `validate_dashboard` | Optional post-apply health (`chartUuid` / dashboard UUID) |
|
|
65
68
|
| `compare_chart_versions` / `compare_dashboard_versions` | Drift / refactor |
|
|
66
69
|
|
|
@@ -96,6 +99,7 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
96
99
|
| Update / tile ops | `dashboard` | dashboard UUID (slug is alias) |
|
|
97
100
|
| Duplicate dashboard | `dashboard` | **source** UUID |
|
|
98
101
|
| Content move | `content-move` | preview's `resourceKey` |
|
|
102
|
+
| Rename | `rename` | chart UUID, dashboard UUID, or the project preview's `resourceKey` |
|
|
99
103
|
|
|
100
104
|
**Create-chart gotcha:** omit top-level `slug` on `preview_chart_changes` → preview returns `resourceKey: "new"`, but `create_chart` applies with `resourceKey = args.slug` → binding mismatch. Always pass top-level `slug` (same as `changes.slug`) on create previews.
|
|
101
105
|
|
|
@@ -110,3 +114,14 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
110
114
|
- `create_chart` response: extract UUID from `charts[0].data.uuid` (not a bare chart object).
|
|
111
115
|
- Viz shapes: `lightdash://playbooks/content-developer/chart-types`.
|
|
112
116
|
- PoP: prefer cloned `generationType: periodOverPeriod` metrics; else % of total / rank / windows via `lightdash://playbooks/content-developer/table-calculations`.
|
|
117
|
+
|
|
118
|
+
## Rename a missing field
|
|
119
|
+
|
|
120
|
+
Use rename when a chart or a dashboard filter references a field or model that no longer exists. One field rename rewrites both a missing dimension and a missing sort when they share the field id.
|
|
121
|
+
|
|
122
|
+
1. Call `list_rename_fields` with `target` set to `chart` or `dashboard`. For a field rename, `to` must be an id from that list. The list includes joined tables.
|
|
123
|
+
2. Call `preview_rename` with scope `chart`, `dashboard-filter`, or `project`. A model rename does not load the field list. A project field rename needs `model` set to the explore name and full field ids that start with that name, such as `orders_status` with `model` `orders`. Project scope returns the affected uuid lists as `impact`. `from` and `to` may contain only lowercase letters, digits, and underscores.
|
|
124
|
+
3. Call `confirm_preview` with the draft `previewToken`, `resourceKind: rename`, and the preview `resourceKey`. Apply with the returned validated `previewToken`.
|
|
125
|
+
4. Apply with `rename_chart`, `rename_dashboard_filter`, or `rename_project`. Pass the same target, `type`, `from`, and `to` as the preview, plus `model` for a project rename. Any other value returns `PREVIEW_STALE`.
|
|
126
|
+
5. `rename_project` previews again before it posts. A changed uuid list returns `PREVIEW_STALE`. A matching field list posts the short names (`status`, not `orders_status`) and returns `jobId`. The tool does not poll the job. Pass the same full ids you previewed. The tool strips the explore prefix for the job.
|
|
127
|
+
6. If charts or dashboards as code live in git, run `lightdash download` and commit. A later `lightdash upload` from stale YAML overwrites the rename. Then validate again with `validate_chart` or `validate_dashboard`.
|
|
@@ -19,3 +19,4 @@ Tool error `PREVIEW_STALE` — content hash mismatch, baseline `updatedAt` drift
|
|
|
19
19
|
- Edited proposed fields after preview (hash mismatch).
|
|
20
20
|
- Resource changed under you (`updatedAt` / create appeared).
|
|
21
21
|
- Create-chart preview omitted top-level `slug` → `resourceKey` mismatch at apply.
|
|
22
|
+
- A project rename now affects different charts, dashboards, alerts, or schedulers than `preview_rename` recorded.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Pure PromptContextSpec builders for content-reader prompts.
|
|
3
3
|
* Shared by registerContentReaderPrompts and budget gates.
|
|
4
4
|
*/
|
|
5
|
-
import type { ContentReaderPlaybookTopic } from './resources/playbooks.js';
|
|
6
5
|
import type { PromptContextSpec } from '../../lib/prompt-context.js';
|
|
6
|
+
import type { ContentReaderPlaybookTopic } from './resources/playbooks.js';
|
|
7
7
|
export declare const TOPIC_DISCOVER: "discover";
|
|
8
8
|
export type FindContentPromptArgs = {
|
|
9
9
|
question: string;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Registers MCP capabilities for a profile.
|
|
3
3
|
*/
|
|
4
4
|
import { type PromptContextPolicy } from '../config/prompt-context-policy.js';
|
|
5
|
-
import type { McpContextProvider } from './request-context.js';
|
|
6
5
|
import type { ProfileDefinition } from '../profiles/types.js';
|
|
6
|
+
import type { McpContextProvider } from './request-context.js';
|
|
7
7
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
8
8
|
export type RegisterCapabilitiesOptions = {
|
|
9
9
|
/** Profile to register (defaults to {@link getDefaultProfile}). */
|
|
@@ -18,6 +18,7 @@ const repoRoot = process.cwd();
|
|
|
18
18
|
const binPath = node_path_1.default.join(repoRoot, 'packages/mcp/dist/bin.js');
|
|
19
19
|
const INIT_TIMEOUT_MS = 5000;
|
|
20
20
|
const SEMANTIC_LAYER_TOOL_COUNT = (0, index_js_1.getProfile)('semantic-layer').tools.length;
|
|
21
|
+
const CONTENT_DEVELOPER_TOOL_COUNT = (0, index_js_1.getProfile)('content-developer').tools.length;
|
|
21
22
|
function writeLine(child, message) {
|
|
22
23
|
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
23
24
|
}
|
|
@@ -225,7 +226,8 @@ async function initializeThenListTools(child, getStderr, clientName) {
|
|
|
225
226
|
child = spawned.child;
|
|
226
227
|
const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
|
|
227
228
|
(0, vitest_1.expect)(serverName).toBe('lightdash-mcp-cdev');
|
|
228
|
-
(0, vitest_1.expect)(tools).toHaveLength(
|
|
229
|
+
(0, vitest_1.expect)(tools).toHaveLength(CONTENT_DEVELOPER_TOOL_COUNT);
|
|
230
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_preview_rename')).toBe(true);
|
|
229
231
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_get_chart_as_code')).toBe(true);
|
|
230
232
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_preview_dashboard_changes')).toBe(true);
|
|
231
233
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_move_content')).toBe(true);
|
|
@@ -45,7 +45,13 @@ function registerListContent(server, contextProvider) {
|
|
|
45
45
|
projectUuids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
46
46
|
spaceUuids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
47
47
|
parentSpaceUuid: zod_1.z.string().optional(),
|
|
48
|
-
contentTypes: zod_1.z
|
|
48
|
+
contentTypes: zod_1.z
|
|
49
|
+
.array(zod_1.z.enum(['chart', 'dashboard', 'space', 'data_app', 'document']))
|
|
50
|
+
.optional(),
|
|
51
|
+
includePersonalDocuments: zod_1.z
|
|
52
|
+
.boolean()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Include the caller's personal documents. Omitted leaves the server default"),
|
|
49
55
|
search: zod_1.z.string().optional(),
|
|
50
56
|
sortBy: zod_1.z.enum(common_1.CONTENT_SORT_BY_COLUMNS).optional(),
|
|
51
57
|
sortDirection: zod_1.z.enum(['asc', 'desc']).optional(),
|
|
@@ -65,6 +71,7 @@ function registerListContent(server, contextProvider) {
|
|
|
65
71
|
spaceUuids: args.spaceUuids,
|
|
66
72
|
parentSpaceUuid: args.parentSpaceUuid,
|
|
67
73
|
contentTypes: args.contentTypes,
|
|
74
|
+
includePersonalDocuments: args.includePersonalDocuments,
|
|
68
75
|
search: args.search,
|
|
69
76
|
sortBy: args.sortBy,
|
|
70
77
|
sortDirection: args.sortDirection,
|
|
@@ -93,7 +93,7 @@ function registerValidateDashboard(server, contextProvider) {
|
|
|
93
93
|
function registerConfirmPreview(server, contextProvider) {
|
|
94
94
|
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'confirm_preview', {
|
|
95
95
|
title: 'Confirm preview',
|
|
96
|
-
description: 'Confirm a previewed create/update/duplicate/tile/content-move payload; resourceKind/resourceKey must match the preview exactly. Required unlock before every write tool.',
|
|
96
|
+
description: 'Confirm a previewed create/update/duplicate/tile/content-move/rename payload; resourceKind/resourceKey must match the preview exactly. Required unlock before every write tool.',
|
|
97
97
|
safety: content_developer_js_1.VALIDATE_SAFETY,
|
|
98
98
|
inputSchema: {
|
|
99
99
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
@@ -36,6 +36,7 @@ export type VersionSummary = {
|
|
|
36
36
|
* Providing only one of versionUuidA/versionUuidB is rejected.
|
|
37
37
|
*/
|
|
38
38
|
export declare function resolveCompareVersionIds(history: readonly VersionSummary[], versionUuidA?: string, versionUuidB?: string): [string, string];
|
|
39
|
+
/** Preview/apply move types. `space` and `document` are valid ItemPayload values and stay off this surface. */
|
|
39
40
|
export type MoveContentType = 'chart' | 'dashboard' | 'data_app';
|
|
40
41
|
export type MoveChartSource = 'dbt_explore' | 'sql';
|
|
41
42
|
/** Throws when `contentTypes` (required) or `chartSources` (when provided) don't line up 1:1 with `itemUuids`. */
|
|
@@ -382,6 +382,7 @@ const developer_helpers_js_1 = require("./developer-helpers.js");
|
|
|
382
382
|
});
|
|
383
383
|
(0, vitest_1.it)('rejects unsupported content types', () => {
|
|
384
384
|
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentItemFromSummary)({ uuid: 's1', contentType: 'space' })).toBeNull();
|
|
385
|
+
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentItemFromSummary)({ uuid: 'd1', contentType: 'document' })).toBeNull();
|
|
385
386
|
});
|
|
386
387
|
(0, vitest_1.it)('normalizes null target space and named spaces', () => {
|
|
387
388
|
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentTargetSpaceFromRecord)(null, null)).toEqual({ uuid: null, name: null });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-developer rename tools (ADR-0036).
|
|
3
|
+
*
|
|
4
|
+
* preview_rename mints a previewToken (ADR-0019) over a RenameInstruction. Chart and
|
|
5
|
+
* dashboard scopes bind the saved resource baseline and do not call POST /rename/preview.
|
|
6
|
+
* Project scope calls it and binds the impacted uuid lists. Apply tools rebuild the
|
|
7
|
+
* instruction from their own arguments, so a token unlocks only the rename it previewed.
|
|
8
|
+
*/
|
|
9
|
+
export declare const listRenameFieldsTool: import("../types.js").ToolModule;
|
|
10
|
+
export declare const previewRenameTool: import("../types.js").ToolModule;
|
|
11
|
+
export declare const renameChartTool: import("../types.js").ToolModule;
|
|
12
|
+
export declare const renameDashboardFilterTool: import("../types.js").ToolModule;
|
|
13
|
+
export declare const renameProjectTool: import("../types.js").ToolModule;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content-developer rename tools (ADR-0036).
|
|
4
|
+
*
|
|
5
|
+
* preview_rename mints a previewToken (ADR-0019) over a RenameInstruction. Chart and
|
|
6
|
+
* dashboard scopes bind the saved resource baseline and do not call POST /rename/preview.
|
|
7
|
+
* Project scope calls it and binds the impacted uuid lists. Apply tools rebuild the
|
|
8
|
+
* instruction from their own arguments, so a token unlocks only the rename it previewed.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.renameProjectTool = exports.renameDashboardFilterTool = exports.renameChartTool = exports.previewRenameTool = exports.listRenameFieldsTool = void 0;
|
|
12
|
+
const common_1 = require("@lightdash-tools/common");
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
15
|
+
const content_developer_js_1 = require("../../policy/content-developer.js");
|
|
16
|
+
const preview_ledger_js_1 = require("../../policy/preview-ledger.js");
|
|
17
|
+
const api_shape_js_1 = require("../lib/api-shape.js");
|
|
18
|
+
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
19
|
+
const shared_js_1 = require("../shared.js");
|
|
20
|
+
const types_js_1 = require("../types.js");
|
|
21
|
+
const developer_content_shared_js_1 = require("./developer-content-shared.js");
|
|
22
|
+
const developer_helpers_js_1 = require("./developer-helpers.js");
|
|
23
|
+
const rename_instruction_js_1 = require("./rename-instruction.js");
|
|
24
|
+
const renameTypeSchema = zod_1.z.enum(['field', 'model']);
|
|
25
|
+
const renameNameSchema = zod_1.z.string().min(1);
|
|
26
|
+
const previewTokenField = () => zod_1.z.string().describe('Validated previewToken from preview_rename then confirm_preview');
|
|
27
|
+
const VALIDATE_CHART_NEXT = 'Run validate_chart on the saved chart.';
|
|
28
|
+
const VALIDATE_DASHBOARD_NEXT = 'Run validate_dashboard on the saved dashboard.';
|
|
29
|
+
const PROJECT_NEXT = 'rename_project returns jobId and does not poll. When the job finishes, run validate_chart or validate_dashboard on the previewed uuids. If charts or dashboards as code live in git, run lightdash download and commit before the next lightdash upload.';
|
|
30
|
+
function requireTarget(value, message) {
|
|
31
|
+
if (value == null || value === '') {
|
|
32
|
+
throw new rename_instruction_js_1.RenameRejectedError('RENAME_TARGET', message);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
async function listedFields(type, to, load) {
|
|
37
|
+
if (type !== 'field') {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const { fields } = await load();
|
|
41
|
+
(0, rename_instruction_js_1.assertListedFieldId)(fields, to);
|
|
42
|
+
return fields;
|
|
43
|
+
}
|
|
44
|
+
async function draftChartRename(client, projectUuid, args) {
|
|
45
|
+
const chartUuid = requireTarget(args.chartUuid, 'preview_rename for a chart needs chartUuid');
|
|
46
|
+
const chart = (0, api_shape_js_1.asRecord)(await client.v2.charts.getSavedChart(projectUuid, chartUuid));
|
|
47
|
+
const fields = await listedFields(args.type, args.to, () => client.v1.rename.listChartFields(projectUuid, chartUuid));
|
|
48
|
+
const proposed = {
|
|
49
|
+
scope: 'chart',
|
|
50
|
+
chartUuid,
|
|
51
|
+
type: args.type,
|
|
52
|
+
from: args.from,
|
|
53
|
+
to: args.to,
|
|
54
|
+
};
|
|
55
|
+
return { proposed, resourceKey: chartUuid, baseline: (0, developer_helpers_js_1.baselineFromResource)(chart), fields };
|
|
56
|
+
}
|
|
57
|
+
async function draftDashboardFilterRename(client, projectUuid, args) {
|
|
58
|
+
const dashboardUuid = requireTarget(args.dashboardUuid, 'preview_rename for a dashboard filter needs dashboardUuid');
|
|
59
|
+
const dashboard = (0, api_shape_js_1.asRecord)(await client.v2.dashboards.getDashboard(projectUuid, dashboardUuid));
|
|
60
|
+
const fields = await listedFields(args.type, args.to, () => client.v1.rename.listDashboardFields(projectUuid, dashboardUuid, args.table));
|
|
61
|
+
const proposed = {
|
|
62
|
+
scope: 'dashboard-filter',
|
|
63
|
+
dashboardUuid,
|
|
64
|
+
type: args.type,
|
|
65
|
+
from: args.from,
|
|
66
|
+
to: args.to,
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
proposed,
|
|
70
|
+
resourceKey: dashboardUuid,
|
|
71
|
+
baseline: (0, developer_helpers_js_1.baselineFromResource)(dashboard),
|
|
72
|
+
fields,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function draftProjectRename(client, projectUuid, args) {
|
|
76
|
+
var _a;
|
|
77
|
+
if (args.type === 'field' && args.model == null) {
|
|
78
|
+
throw new rename_instruction_js_1.RenameRejectedError('RENAME_TARGET', 'A project field rename needs model set to the explore name, plus full field ids');
|
|
79
|
+
}
|
|
80
|
+
if (args.model != null) {
|
|
81
|
+
(0, rename_instruction_js_1.assertRenameToken)(args.model, 'model');
|
|
82
|
+
}
|
|
83
|
+
if (args.type === 'field' && args.model != null) {
|
|
84
|
+
(0, rename_instruction_js_1.projectFieldShortName)(args.model, args.from);
|
|
85
|
+
(0, rename_instruction_js_1.projectFieldShortName)(args.model, args.to);
|
|
86
|
+
}
|
|
87
|
+
const proposed = {
|
|
88
|
+
scope: 'project',
|
|
89
|
+
type: args.type,
|
|
90
|
+
from: args.from,
|
|
91
|
+
to: args.to,
|
|
92
|
+
model: (_a = args.model) !== null && _a !== void 0 ? _a : null,
|
|
93
|
+
};
|
|
94
|
+
const impact = (0, rename_instruction_js_1.renameImpactFromChanges)(await client.v1.rename.previewRename(projectUuid, (0, rename_instruction_js_1.projectRenameBody)(proposed, true)));
|
|
95
|
+
return {
|
|
96
|
+
proposed,
|
|
97
|
+
resourceKey: (0, rename_instruction_js_1.projectRenameResourceKey)(proposed),
|
|
98
|
+
baseline: { renameImpact: impact },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function draftRename(client, projectUuid, args) {
|
|
102
|
+
(0, rename_instruction_js_1.assertRenameNamesDiffer)(args.from, args.to);
|
|
103
|
+
switch (args.scope) {
|
|
104
|
+
case 'chart':
|
|
105
|
+
return draftChartRename(client, projectUuid, args);
|
|
106
|
+
case 'dashboard-filter':
|
|
107
|
+
return draftDashboardFilterRename(client, projectUuid, args);
|
|
108
|
+
case 'project':
|
|
109
|
+
return draftProjectRename(client, projectUuid, args);
|
|
110
|
+
default: {
|
|
111
|
+
const unhandled = args.scope;
|
|
112
|
+
throw new rename_instruction_js_1.RenameRejectedError('RENAME_TARGET', `Unknown rename scope '${String(unhandled)}'`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function applied(jobId, next) {
|
|
117
|
+
return Object.assign(Object.assign({ applied: true }, (jobId == null ? {} : { jobId })), { next });
|
|
118
|
+
}
|
|
119
|
+
function registerListRenameFields(server, contextProvider) {
|
|
120
|
+
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'list_rename_fields', {
|
|
121
|
+
title: 'List rename fields',
|
|
122
|
+
description: 'List real field ids that can replace a missing chart field or dashboard filter target. Requires project update permission.',
|
|
123
|
+
safety: content_developer_js_1.DISCOVERY_SAFETY,
|
|
124
|
+
inputSchema: {
|
|
125
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
126
|
+
target: zod_1.z.enum(['chart', 'dashboard']),
|
|
127
|
+
chartUuid: zod_1.z.string().optional(),
|
|
128
|
+
dashboardUuid: zod_1.z.string().optional(),
|
|
129
|
+
table: zod_1.z.string().optional().describe('Dashboard field list table filter'),
|
|
130
|
+
},
|
|
131
|
+
}, (0, developer_content_shared_js_1.wrapDeveloperHandler)(contextProvider, ({ client }) => async (args) => {
|
|
132
|
+
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
133
|
+
const fields = args.target === 'chart'
|
|
134
|
+
? await client.v1.rename.listChartFields(scope.projectUuid, requireTarget(args.chartUuid, 'list_rename_fields for a chart needs chartUuid'))
|
|
135
|
+
: await client.v1.rename.listDashboardFields(scope.projectUuid, requireTarget(args.dashboardUuid, 'list_rename_fields for a dashboard needs dashboardUuid'), args.table);
|
|
136
|
+
return (0, shared_js_1.jsonToolResult)({ data: fields, context: (0, developer_content_shared_js_1.developerContext)(scope) });
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
function registerPreviewRename(server, contextProvider) {
|
|
140
|
+
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'preview_rename', {
|
|
141
|
+
title: 'Preview rename',
|
|
142
|
+
description: 'Mint a previewToken for a rename instruction. Chart and dashboard scopes do not call the project rename preview. Project scope records affected resource uuids. Confirm with resourceKind rename before apply. Does not write a chart version.',
|
|
143
|
+
safety: content_developer_js_1.PREVIEW_SAFETY,
|
|
144
|
+
inputSchema: {
|
|
145
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
146
|
+
scope: zod_1.z.enum(['chart', 'dashboard-filter', 'project']),
|
|
147
|
+
type: renameTypeSchema,
|
|
148
|
+
from: renameNameSchema,
|
|
149
|
+
to: renameNameSchema,
|
|
150
|
+
chartUuid: zod_1.z.string().optional(),
|
|
151
|
+
dashboardUuid: zod_1.z.string().optional(),
|
|
152
|
+
model: zod_1.z
|
|
153
|
+
.string()
|
|
154
|
+
.min(1)
|
|
155
|
+
.optional()
|
|
156
|
+
.describe('Explore name. Required when type is field and scope is project'),
|
|
157
|
+
table: zod_1.z.string().optional().describe('Dashboard field list table filter'),
|
|
158
|
+
},
|
|
159
|
+
}, (0, developer_content_shared_js_1.wrapDeveloperHandler)(contextProvider, ({ client, subject, serverContext }) => async (args) => {
|
|
160
|
+
var _a;
|
|
161
|
+
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
162
|
+
const draft = await draftRename(client, scope.projectUuid, args);
|
|
163
|
+
const entry = await (0, preview_ledger_js_1.mintDraftPreviewToken)({
|
|
164
|
+
subject,
|
|
165
|
+
serverContext,
|
|
166
|
+
projectUuid: scope.projectUuid,
|
|
167
|
+
resourceKind: 'rename',
|
|
168
|
+
resourceKey: draft.resourceKey,
|
|
169
|
+
proposed: draft.proposed,
|
|
170
|
+
baseline: draft.baseline,
|
|
171
|
+
});
|
|
172
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
173
|
+
data: Object.assign(Object.assign({ previewToken: entry.previewToken, previewId: entry.claims.previewId, resourceKind: entry.claims.resourceKind, resourceKey: draft.resourceKey, status: entry.claims.status, contentHash: entry.claims.contentHash, expiresAt: entry.claims.expiresAt }, (draft.fields == null ? {} : { fields: draft.fields })), (((_a = draft.baseline) === null || _a === void 0 ? void 0 : _a.renameImpact) == null
|
|
174
|
+
? {}
|
|
175
|
+
: { impact: draft.baseline.renameImpact })),
|
|
176
|
+
context: (0, developer_content_shared_js_1.developerContext)(scope),
|
|
177
|
+
});
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
function registerRenameChart(server, contextProvider) {
|
|
181
|
+
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'rename_chart', {
|
|
182
|
+
title: 'Rename chart field or model',
|
|
183
|
+
description: 'Apply a confirmed chart rename. Posts once to the chart rename endpoint and does not upsert chart-as-code. Then run validate_chart.',
|
|
184
|
+
safety: content_developer_js_1.WRITE_SAFETY,
|
|
185
|
+
annotations: common_1.WRITE_NONDESTRUCTIVE,
|
|
186
|
+
inputSchema: {
|
|
187
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
188
|
+
previewToken: previewTokenField(),
|
|
189
|
+
chartUuid: zod_1.z.string(),
|
|
190
|
+
type: renameTypeSchema,
|
|
191
|
+
from: renameNameSchema,
|
|
192
|
+
to: renameNameSchema,
|
|
193
|
+
dryRun: zod_1.z.boolean().optional(),
|
|
194
|
+
},
|
|
195
|
+
}, (0, developer_content_shared_js_1.wrapDeveloperHandler)(contextProvider, ({ client, subject, serverContext }) => async (args) => {
|
|
196
|
+
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
197
|
+
(0, rename_instruction_js_1.assertApplyIsNotDryRun)(args.dryRun);
|
|
198
|
+
const chart = (0, api_shape_js_1.asRecord)(await client.v2.charts.getSavedChart(scope.projectUuid, args.chartUuid));
|
|
199
|
+
const proposed = {
|
|
200
|
+
scope: 'chart',
|
|
201
|
+
chartUuid: args.chartUuid,
|
|
202
|
+
type: args.type,
|
|
203
|
+
from: args.from,
|
|
204
|
+
to: args.to,
|
|
205
|
+
};
|
|
206
|
+
const result = await (0, preview_ledger_js_1.withValidatedPreviewApply)({
|
|
207
|
+
previewToken: args.previewToken,
|
|
208
|
+
subject,
|
|
209
|
+
serverContext,
|
|
210
|
+
projectUuid: scope.projectUuid,
|
|
211
|
+
resourceKind: 'rename',
|
|
212
|
+
resourceKey: args.chartUuid,
|
|
213
|
+
proposed,
|
|
214
|
+
currentBaseline: (0, developer_helpers_js_1.baselineFromResource)(chart),
|
|
215
|
+
}, () => client.v1.rename.renameChart(scope.projectUuid, args.chartUuid, {
|
|
216
|
+
type: proposed.type,
|
|
217
|
+
from: proposed.from,
|
|
218
|
+
to: proposed.to,
|
|
219
|
+
}));
|
|
220
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
221
|
+
data: applied(result.jobId, VALIDATE_CHART_NEXT),
|
|
222
|
+
context: (0, developer_content_shared_js_1.developerContext)(scope),
|
|
223
|
+
});
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
function registerRenameDashboardFilter(server, contextProvider) {
|
|
227
|
+
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'rename_dashboard_filter', {
|
|
228
|
+
title: 'Rename dashboard filter',
|
|
229
|
+
description: 'Apply a confirmed dashboard-filter rename. Then run validate_dashboard.',
|
|
230
|
+
safety: content_developer_js_1.WRITE_SAFETY,
|
|
231
|
+
annotations: common_1.WRITE_NONDESTRUCTIVE,
|
|
232
|
+
inputSchema: {
|
|
233
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
234
|
+
previewToken: previewTokenField(),
|
|
235
|
+
dashboardUuid: zod_1.z.string(),
|
|
236
|
+
type: renameTypeSchema,
|
|
237
|
+
from: renameNameSchema,
|
|
238
|
+
to: renameNameSchema,
|
|
239
|
+
dryRun: zod_1.z.boolean().optional(),
|
|
240
|
+
},
|
|
241
|
+
}, (0, developer_content_shared_js_1.wrapDeveloperHandler)(contextProvider, ({ client, subject, serverContext }) => async (args) => {
|
|
242
|
+
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
243
|
+
(0, rename_instruction_js_1.assertApplyIsNotDryRun)(args.dryRun);
|
|
244
|
+
const dashboard = (0, api_shape_js_1.asRecord)(await client.v2.dashboards.getDashboard(scope.projectUuid, args.dashboardUuid));
|
|
245
|
+
const proposed = {
|
|
246
|
+
scope: 'dashboard-filter',
|
|
247
|
+
dashboardUuid: args.dashboardUuid,
|
|
248
|
+
type: args.type,
|
|
249
|
+
from: args.from,
|
|
250
|
+
to: args.to,
|
|
251
|
+
};
|
|
252
|
+
const result = await (0, preview_ledger_js_1.withValidatedPreviewApply)({
|
|
253
|
+
previewToken: args.previewToken,
|
|
254
|
+
subject,
|
|
255
|
+
serverContext,
|
|
256
|
+
projectUuid: scope.projectUuid,
|
|
257
|
+
resourceKind: 'rename',
|
|
258
|
+
resourceKey: args.dashboardUuid,
|
|
259
|
+
proposed,
|
|
260
|
+
currentBaseline: (0, developer_helpers_js_1.baselineFromResource)(dashboard),
|
|
261
|
+
}, () => client.v1.rename.renameDashboardFilter(scope.projectUuid, args.dashboardUuid, {
|
|
262
|
+
type: proposed.type,
|
|
263
|
+
from: proposed.from,
|
|
264
|
+
to: proposed.to,
|
|
265
|
+
}));
|
|
266
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
267
|
+
data: applied(result.jobId, VALIDATE_DASHBOARD_NEXT),
|
|
268
|
+
context: (0, developer_content_shared_js_1.developerContext)(scope),
|
|
269
|
+
});
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
function registerRenameProject(server, contextProvider) {
|
|
273
|
+
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'rename_project', {
|
|
274
|
+
title: 'Rename across the project',
|
|
275
|
+
description: 'Apply a confirmed project rename. Re-checks the preview uuid lists, posts the project rename, and returns jobId without polling. If content as code lives in git, run lightdash download before the next lightdash upload.',
|
|
276
|
+
safety: content_developer_js_1.WRITE_SAFETY,
|
|
277
|
+
annotations: common_1.WRITE_NONDESTRUCTIVE,
|
|
278
|
+
inputSchema: {
|
|
279
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
280
|
+
previewToken: previewTokenField(),
|
|
281
|
+
type: renameTypeSchema,
|
|
282
|
+
from: renameNameSchema,
|
|
283
|
+
to: renameNameSchema,
|
|
284
|
+
model: zod_1.z.string().min(1).optional().describe('Explore name. Required when type is field'),
|
|
285
|
+
dryRun: zod_1.z.boolean().optional(),
|
|
286
|
+
},
|
|
287
|
+
}, (0, developer_content_shared_js_1.wrapDeveloperHandler)(contextProvider, ({ client, subject, serverContext }) => async (args) => {
|
|
288
|
+
var _a;
|
|
289
|
+
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
290
|
+
(0, rename_instruction_js_1.assertApplyIsNotDryRun)(args.dryRun);
|
|
291
|
+
const proposed = {
|
|
292
|
+
scope: 'project',
|
|
293
|
+
type: args.type,
|
|
294
|
+
from: args.from,
|
|
295
|
+
to: args.to,
|
|
296
|
+
model: (_a = args.model) !== null && _a !== void 0 ? _a : null,
|
|
297
|
+
};
|
|
298
|
+
const fresh = (0, rename_instruction_js_1.renameImpactFromChanges)(await client.v1.rename.previewRename(scope.projectUuid, (0, rename_instruction_js_1.projectRenameBody)(proposed, true)));
|
|
299
|
+
const { jobId } = await (0, preview_ledger_js_1.withValidatedPreviewApply)({
|
|
300
|
+
previewToken: args.previewToken,
|
|
301
|
+
subject,
|
|
302
|
+
serverContext,
|
|
303
|
+
projectUuid: scope.projectUuid,
|
|
304
|
+
resourceKind: 'rename',
|
|
305
|
+
resourceKey: (0, rename_instruction_js_1.projectRenameResourceKey)(proposed),
|
|
306
|
+
proposed,
|
|
307
|
+
currentBaseline: { renameImpact: fresh },
|
|
308
|
+
}, () => client.v1.rename.renameResources(scope.projectUuid, (0, rename_instruction_js_1.projectRenameJobBody)(proposed)));
|
|
309
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
310
|
+
data: applied(jobId, PROJECT_NEXT),
|
|
311
|
+
context: (0, developer_content_shared_js_1.developerContext)(scope),
|
|
312
|
+
});
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
exports.listRenameFieldsTool = (0, types_js_1.defineTool)('list_rename_fields', registerListRenameFields);
|
|
316
|
+
exports.previewRenameTool = (0, types_js_1.defineTool)('preview_rename', registerPreviewRename);
|
|
317
|
+
exports.renameChartTool = (0, types_js_1.defineTool)('rename_chart', registerRenameChart);
|
|
318
|
+
exports.renameDashboardFilterTool = (0, types_js_1.defineTool)('rename_dashboard_filter', registerRenameDashboardFilter);
|
|
319
|
+
exports.renameProjectTool = (0, types_js_1.defineTool)('rename_project', registerRenameProject);
|