@lightdash-tools/mcp 0.23.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/profiles/semantic-layer/v1/prompts.js +3 -3
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +6 -3
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +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/tools/semantic/explore-helpers.d.ts +6 -0
- package/dist/tools/semantic/explore-helpers.js +43 -0
- package/dist/tools/semantic/explore-helpers.test.js +17 -0
- package/dist/tools/semantic/query.js +9 -19
- package/dist/tools/semantic/query.test.js +71 -0
- package/dist/transports/streamable-http.js +33 -7
- package/package.json +13 -9
|
@@ -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);
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rename tools over a real MCP client on the content-developer profile (ADR-0036).
|
|
4
|
+
* The Lightdash client is a hand-written fake that records rename reads and writes.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const client_1 = require("@modelcontextprotocol/client");
|
|
8
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
9
|
+
const vitest_1 = require("vitest");
|
|
10
|
+
const preview_ledger_js_1 = require("../../policy/preview-ledger.js");
|
|
11
|
+
const index_js_1 = require("../../profiles/index.js");
|
|
12
|
+
const server_js_1 = require("../../server/server.js");
|
|
13
|
+
const PROJECT = '11111111-1111-4111-8111-111111111111';
|
|
14
|
+
const CHART = '22222222-2222-4222-8222-222222222222';
|
|
15
|
+
const OTHER_CHART = '44444444-4444-4444-8444-444444444444';
|
|
16
|
+
const DASHBOARD = '33333333-3333-4333-8333-333333333333';
|
|
17
|
+
const UPDATED_AT = '2026-10-01T00:00:00.000Z';
|
|
18
|
+
const FIELDS = { orders: ['orders_status'], customers: ['customers_region'] };
|
|
19
|
+
function createUpstream() {
|
|
20
|
+
return {
|
|
21
|
+
chartUpdatedAt: UPDATED_AT,
|
|
22
|
+
impactChartUuids: [CHART],
|
|
23
|
+
fieldLists: [],
|
|
24
|
+
previews: [],
|
|
25
|
+
writes: [],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function fakeLightdash(up) {
|
|
29
|
+
return {
|
|
30
|
+
v1: {
|
|
31
|
+
rename: {
|
|
32
|
+
listChartFields: async (_projectUuid, chartUuid) => {
|
|
33
|
+
up.fieldLists.push(`chart:${chartUuid}`);
|
|
34
|
+
return { fields: FIELDS };
|
|
35
|
+
},
|
|
36
|
+
listDashboardFields: async (_projectUuid, dashboardUuid) => {
|
|
37
|
+
up.fieldLists.push(`dashboard:${dashboardUuid}`);
|
|
38
|
+
return { fields: FIELDS };
|
|
39
|
+
},
|
|
40
|
+
previewRename: async (_projectUuid, body) => {
|
|
41
|
+
up.previews.push(body);
|
|
42
|
+
return {
|
|
43
|
+
alerts: [],
|
|
44
|
+
charts: up.impactChartUuids.map((uuid) => ({ name: 'Orders', uuid })),
|
|
45
|
+
dashboardSchedulers: [],
|
|
46
|
+
dashboards: [{ name: 'Sales', uuid: DASHBOARD }],
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
renameChart: async (_projectUuid, chartUuid, body) => {
|
|
50
|
+
up.writes.push({ endpoint: `rename/chart/${chartUuid}`, body });
|
|
51
|
+
return {};
|
|
52
|
+
},
|
|
53
|
+
renameDashboardFilter: async (_projectUuid, dashboardUuid, body) => {
|
|
54
|
+
up.writes.push({ endpoint: `rename/dashboard/${dashboardUuid}`, body });
|
|
55
|
+
return {};
|
|
56
|
+
},
|
|
57
|
+
renameResources: async (_projectUuid, body) => {
|
|
58
|
+
up.writes.push({ endpoint: 'rename', body });
|
|
59
|
+
return { jobId: 'job-9' };
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
v2: {
|
|
64
|
+
charts: {
|
|
65
|
+
getSavedChart: async (_projectUuid, chartUuid) => ({
|
|
66
|
+
uuid: chartUuid,
|
|
67
|
+
updatedAt: up.chartUpdatedAt,
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
dashboards: {
|
|
71
|
+
getDashboard: async (_projectUuid, dashboardUuid) => ({
|
|
72
|
+
uuid: dashboardUuid,
|
|
73
|
+
updatedAt: UPDATED_AT,
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function connect(up) {
|
|
80
|
+
const contextProvider = {
|
|
81
|
+
getContext: async () => ({
|
|
82
|
+
lightdashClient: fakeLightdash(up),
|
|
83
|
+
auth: { mode: 'env' },
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
const server = (0, server_js_1.createLightdashMcpServer)(contextProvider, {
|
|
87
|
+
profile: (0, index_js_1.getProfile)('content-developer'),
|
|
88
|
+
});
|
|
89
|
+
const [serverTransport, clientTransport] = server_1.InMemoryTransport.createLinkedPair();
|
|
90
|
+
await server.connect(serverTransport);
|
|
91
|
+
const client = new client_1.Client({ name: 'developer-rename-test', version: '0.0.0' });
|
|
92
|
+
await client.connect(clientTransport);
|
|
93
|
+
return { server, client };
|
|
94
|
+
}
|
|
95
|
+
(0, vitest_1.describe)('content-developer rename tools', () => {
|
|
96
|
+
let up;
|
|
97
|
+
let session;
|
|
98
|
+
async function call(tool, args) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
const result = await session.client.callTool({
|
|
101
|
+
name: `lightdash_${tool}`,
|
|
102
|
+
arguments: Object.assign({ projectUuid: PROJECT }, args),
|
|
103
|
+
});
|
|
104
|
+
const structured = ((_a = result.structuredContent) !== null && _a !== void 0 ? _a : {});
|
|
105
|
+
return {
|
|
106
|
+
isError: result.isError === true,
|
|
107
|
+
data: (_b = structured.data) !== null && _b !== void 0 ? _b : {},
|
|
108
|
+
error: structured.error,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function confirm(preview) {
|
|
112
|
+
const confirmed = await call('confirm_preview', {
|
|
113
|
+
previewToken: preview.data.previewToken,
|
|
114
|
+
resourceKind: 'rename',
|
|
115
|
+
resourceKey: preview.data.resourceKey,
|
|
116
|
+
});
|
|
117
|
+
(0, vitest_1.expect)(confirmed.data.status).toBe('validated');
|
|
118
|
+
return String(confirmed.data.previewToken);
|
|
119
|
+
}
|
|
120
|
+
const chartRename = {
|
|
121
|
+
chartUuid: CHART,
|
|
122
|
+
type: 'field',
|
|
123
|
+
from: 'customers_old',
|
|
124
|
+
to: 'customers_region',
|
|
125
|
+
};
|
|
126
|
+
const projectRename = { type: 'field', from: 'orders_old', to: 'orders_status', model: 'orders' };
|
|
127
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
128
|
+
(0, preview_ledger_js_1.resetPreviewLedgerForTests)();
|
|
129
|
+
up = createUpstream();
|
|
130
|
+
session = await connect(up);
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.afterEach)(async () => {
|
|
133
|
+
await session.client.close().catch(() => undefined);
|
|
134
|
+
await session.server.close().catch(() => undefined);
|
|
135
|
+
});
|
|
136
|
+
(0, vitest_1.it)('lists the chart dropdown, including joined tables', async () => {
|
|
137
|
+
const listed = await call('list_rename_fields', { target: 'chart', chartUuid: CHART });
|
|
138
|
+
(0, vitest_1.expect)(listed.data).toEqual({ fields: FIELDS });
|
|
139
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([`chart:${CHART}`]);
|
|
140
|
+
});
|
|
141
|
+
(0, vitest_1.it)('renames a chart field to a joined-table id after confirm, without the project preview', async () => {
|
|
142
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'chart' }, chartRename));
|
|
143
|
+
(0, vitest_1.expect)(preview.data).toMatchObject({
|
|
144
|
+
resourceKind: 'rename',
|
|
145
|
+
resourceKey: CHART,
|
|
146
|
+
status: 'draft',
|
|
147
|
+
fields: FIELDS,
|
|
148
|
+
});
|
|
149
|
+
(0, vitest_1.expect)(preview.data.previewToken).toEqual(vitest_1.expect.any(String));
|
|
150
|
+
const applied = await call('rename_chart', Object.assign({ previewToken: await confirm(preview) }, chartRename));
|
|
151
|
+
(0, vitest_1.expect)(applied.data).toEqual({ applied: true, next: 'Run validate_chart on the saved chart.' });
|
|
152
|
+
(0, vitest_1.expect)(up.writes).toEqual([
|
|
153
|
+
{
|
|
154
|
+
endpoint: `rename/chart/${CHART}`,
|
|
155
|
+
body: { type: 'field', from: 'customers_old', to: 'customers_region' },
|
|
156
|
+
},
|
|
157
|
+
]);
|
|
158
|
+
(0, vitest_1.expect)(up.previews).toEqual([]);
|
|
159
|
+
});
|
|
160
|
+
(0, vitest_1.it)('rejects a new field id outside the dropdown before minting a token', async () => {
|
|
161
|
+
var _a;
|
|
162
|
+
const preview = await call('preview_rename', Object.assign(Object.assign({ scope: 'chart' }, chartRename), { to: 'customers_missing' }));
|
|
163
|
+
(0, vitest_1.expect)((_a = preview.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_FIELD_UNLISTED');
|
|
164
|
+
(0, vitest_1.expect)(preview.data.previewToken).toBeUndefined();
|
|
165
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([`chart:${CHART}`]);
|
|
166
|
+
});
|
|
167
|
+
(0, vitest_1.it)('previews a chart model rename without loading the dropdown', async () => {
|
|
168
|
+
const preview = await call('preview_rename', {
|
|
169
|
+
scope: 'chart',
|
|
170
|
+
chartUuid: CHART,
|
|
171
|
+
type: 'model',
|
|
172
|
+
from: 'orders',
|
|
173
|
+
to: 'orders_v2',
|
|
174
|
+
});
|
|
175
|
+
(0, vitest_1.expect)(preview.data).toMatchObject({ resourceKind: 'rename', status: 'draft' });
|
|
176
|
+
(0, vitest_1.expect)(preview.data).not.toHaveProperty('fields');
|
|
177
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([]);
|
|
178
|
+
});
|
|
179
|
+
(0, vitest_1.it)('rejects an empty or unchanged rename before minting a token', async () => {
|
|
180
|
+
var _a;
|
|
181
|
+
const empty = await call('preview_rename', Object.assign(Object.assign({ scope: 'chart' }, chartRename), { from: '' }));
|
|
182
|
+
(0, vitest_1.expect)(empty.isError).toBe(true);
|
|
183
|
+
(0, vitest_1.expect)(empty.data.previewToken).toBeUndefined();
|
|
184
|
+
const unchanged = await call('preview_rename', Object.assign(Object.assign({ scope: 'chart' }, chartRename), { from: 'customers_region' }));
|
|
185
|
+
(0, vitest_1.expect)((_a = unchanged.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_UNCHANGED');
|
|
186
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([]);
|
|
187
|
+
});
|
|
188
|
+
(0, vitest_1.it)('requires model for a project field rename', async () => {
|
|
189
|
+
var _a;
|
|
190
|
+
const preview = await call('preview_rename', Object.assign(Object.assign({ scope: 'project' }, projectRename), { model: undefined }));
|
|
191
|
+
(0, vitest_1.expect)((_a = preview.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_TARGET');
|
|
192
|
+
(0, vitest_1.expect)(up.previews).toEqual([]);
|
|
193
|
+
});
|
|
194
|
+
(0, vitest_1.it)('rejects a project field id that is not prefixed by the explore name', async () => {
|
|
195
|
+
var _a;
|
|
196
|
+
const preview = await call('preview_rename', Object.assign(Object.assign({ scope: 'project' }, projectRename), { from: 'status' }));
|
|
197
|
+
(0, vitest_1.expect)((_a = preview.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_TARGET');
|
|
198
|
+
(0, vitest_1.expect)(up.previews).toEqual([]);
|
|
199
|
+
});
|
|
200
|
+
(0, vitest_1.it)('rejects a rename name that would be compiled as a pattern', async () => {
|
|
201
|
+
var _a;
|
|
202
|
+
const preview = await call('preview_rename', Object.assign(Object.assign({ scope: 'chart' }, chartRename), { from: '.*' }));
|
|
203
|
+
(0, vitest_1.expect)((_a = preview.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_TARGET');
|
|
204
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([]);
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)('does not post with an unconfirmed draft token', async () => {
|
|
207
|
+
var _a;
|
|
208
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'chart' }, chartRename));
|
|
209
|
+
const applied = await call('rename_chart', Object.assign({ previewToken: preview.data.previewToken }, chartRename));
|
|
210
|
+
(0, vitest_1.expect)((_a = applied.error) === null || _a === void 0 ? void 0 : _a.code).toBe('PREVIEW_NOT_VALIDATED');
|
|
211
|
+
(0, vitest_1.expect)(up.writes).toEqual([]);
|
|
212
|
+
});
|
|
213
|
+
(0, vitest_1.it)('fails closed with PREVIEW_STALE when the chart changed after preview', async () => {
|
|
214
|
+
var _a;
|
|
215
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'chart' }, chartRename));
|
|
216
|
+
const previewToken = await confirm(preview);
|
|
217
|
+
up.chartUpdatedAt = '2026-10-02T00:00:00.000Z';
|
|
218
|
+
const applied = await call('rename_chart', Object.assign({ previewToken }, chartRename));
|
|
219
|
+
(0, vitest_1.expect)((_a = applied.error) === null || _a === void 0 ? void 0 : _a.code).toBe('PREVIEW_STALE');
|
|
220
|
+
(0, vitest_1.expect)(up.writes).toEqual([]);
|
|
221
|
+
});
|
|
222
|
+
(0, vitest_1.it)('unlocks only the rename that was previewed', async () => {
|
|
223
|
+
var _a, _b;
|
|
224
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'chart' }, chartRename));
|
|
225
|
+
const previewToken = await confirm(preview);
|
|
226
|
+
const otherTarget = await call('rename_chart', Object.assign(Object.assign({ previewToken }, chartRename), { to: 'orders_status' }));
|
|
227
|
+
(0, vitest_1.expect)((_a = otherTarget.error) === null || _a === void 0 ? void 0 : _a.code).toBe('PREVIEW_STALE');
|
|
228
|
+
const otherTool = await call('rename_project', Object.assign({ previewToken }, projectRename));
|
|
229
|
+
(0, vitest_1.expect)((_b = otherTool.error) === null || _b === void 0 ? void 0 : _b.code).toBe('PREVIEW_STALE');
|
|
230
|
+
(0, vitest_1.expect)(up.writes).toEqual([]);
|
|
231
|
+
});
|
|
232
|
+
(0, vitest_1.it)('rejects dryRun on apply and does not post', async () => {
|
|
233
|
+
var _a;
|
|
234
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'chart' }, chartRename));
|
|
235
|
+
const applied = await call('rename_chart', Object.assign(Object.assign({ previewToken: await confirm(preview) }, chartRename), { dryRun: true }));
|
|
236
|
+
(0, vitest_1.expect)((_a = applied.error) === null || _a === void 0 ? void 0 : _a.code).toBe('RENAME_DRY_RUN');
|
|
237
|
+
(0, vitest_1.expect)(up.writes).toEqual([]);
|
|
238
|
+
});
|
|
239
|
+
(0, vitest_1.it)('renames a dashboard filter after confirm', async () => {
|
|
240
|
+
const rename = {
|
|
241
|
+
dashboardUuid: DASHBOARD,
|
|
242
|
+
type: 'field',
|
|
243
|
+
from: 'orders_old',
|
|
244
|
+
to: 'orders_status',
|
|
245
|
+
};
|
|
246
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'dashboard-filter' }, rename));
|
|
247
|
+
(0, vitest_1.expect)(preview.data.resourceKey).toBe(DASHBOARD);
|
|
248
|
+
const applied = await call('rename_dashboard_filter', Object.assign({ previewToken: await confirm(preview) }, rename));
|
|
249
|
+
(0, vitest_1.expect)(applied.data).toEqual({
|
|
250
|
+
applied: true,
|
|
251
|
+
next: 'Run validate_dashboard on the saved dashboard.',
|
|
252
|
+
});
|
|
253
|
+
(0, vitest_1.expect)(up.writes).toEqual([
|
|
254
|
+
{
|
|
255
|
+
endpoint: `rename/dashboard/${DASHBOARD}`,
|
|
256
|
+
body: { type: 'field', from: 'orders_old', to: 'orders_status' },
|
|
257
|
+
},
|
|
258
|
+
]);
|
|
259
|
+
(0, vitest_1.expect)(up.fieldLists).toEqual([`dashboard:${DASHBOARD}`]);
|
|
260
|
+
(0, vitest_1.expect)(up.previews).toEqual([]);
|
|
261
|
+
});
|
|
262
|
+
(0, vitest_1.it)('rechecks the project uuid lists, posts once, and returns jobId without polling', async () => {
|
|
263
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'project' }, projectRename));
|
|
264
|
+
(0, vitest_1.expect)(preview.data).toMatchObject({
|
|
265
|
+
resourceKey: 'project:field:orders:orders_old:orders_status',
|
|
266
|
+
impact: { alerts: [], charts: [CHART], dashboardSchedulers: [], dashboards: [DASHBOARD] },
|
|
267
|
+
});
|
|
268
|
+
const applied = await call('rename_project', Object.assign({ previewToken: await confirm(preview) }, projectRename));
|
|
269
|
+
(0, vitest_1.expect)(applied.data.jobId).toBe('job-9');
|
|
270
|
+
(0, vitest_1.expect)(applied.data.next).toContain('lightdash download');
|
|
271
|
+
const dryRunBody = {
|
|
272
|
+
type: 'field',
|
|
273
|
+
from: 'orders_old',
|
|
274
|
+
to: 'orders_status',
|
|
275
|
+
model: 'orders',
|
|
276
|
+
dryRun: true,
|
|
277
|
+
};
|
|
278
|
+
(0, vitest_1.expect)(up.previews).toEqual([dryRunBody, dryRunBody]);
|
|
279
|
+
(0, vitest_1.expect)(up.writes).toEqual([
|
|
280
|
+
{
|
|
281
|
+
endpoint: 'rename',
|
|
282
|
+
body: { type: 'field', from: 'old', to: 'status', model: 'orders' },
|
|
283
|
+
},
|
|
284
|
+
]);
|
|
285
|
+
});
|
|
286
|
+
(0, vitest_1.it)('returns PREVIEW_STALE and does not post when the project uuid list changed', async () => {
|
|
287
|
+
var _a;
|
|
288
|
+
const preview = await call('preview_rename', Object.assign({ scope: 'project' }, projectRename));
|
|
289
|
+
const previewToken = await confirm(preview);
|
|
290
|
+
up.impactChartUuids = [CHART, OTHER_CHART];
|
|
291
|
+
const applied = await call('rename_project', Object.assign({ previewToken }, projectRename));
|
|
292
|
+
(0, vitest_1.expect)((_a = applied.error) === null || _a === void 0 ? void 0 : _a.code).toBe('PREVIEW_STALE');
|
|
293
|
+
(0, vitest_1.expect)(up.previews).toHaveLength(2);
|
|
294
|
+
(0, vitest_1.expect)(up.writes).toEqual([]);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
@@ -181,12 +181,18 @@ function toReaderDashboard(dashboard, includeTiles) {
|
|
|
181
181
|
function registerSearchContent(server, contextProvider) {
|
|
182
182
|
(0, content_reader_js_1.registerContentReaderTool)(server, 'search_content', {
|
|
183
183
|
title: 'Search content',
|
|
184
|
-
description: 'Search charts, dashboards, spaces,
|
|
184
|
+
description: 'Search charts, dashboards, spaces, data apps, and documents in the resolved project',
|
|
185
185
|
safety: content_reader_js_1.METADATA_SAFETY,
|
|
186
186
|
inputSchema: {
|
|
187
187
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
188
188
|
query: zod_1.z.string().optional(),
|
|
189
|
-
contentTypes: zod_1.z
|
|
189
|
+
contentTypes: zod_1.z
|
|
190
|
+
.array(zod_1.z.enum(['chart', 'dashboard', 'space', 'data_app', 'document']))
|
|
191
|
+
.optional(),
|
|
192
|
+
includePersonalDocuments: zod_1.z
|
|
193
|
+
.boolean()
|
|
194
|
+
.optional()
|
|
195
|
+
.describe("Include the caller's personal documents. Omitted leaves the server default"),
|
|
190
196
|
spaceUuids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
191
197
|
parentSpaceUuid: zod_1.z.string().optional(),
|
|
192
198
|
sortBy: zod_1.z.enum(common_1.CONTENT_SORT_BY_COLUMNS).optional(),
|
|
@@ -204,6 +210,7 @@ function registerSearchContent(server, contextProvider) {
|
|
|
204
210
|
spaceUuids: args.spaceUuids,
|
|
205
211
|
parentSpaceUuid: args.parentSpaceUuid,
|
|
206
212
|
contentTypes: args.contentTypes,
|
|
213
|
+
includePersonalDocuments: args.includePersonalDocuments,
|
|
207
214
|
search: args.query,
|
|
208
215
|
sortBy: args.sortBy,
|
|
209
216
|
sortDirection: args.sortDirection,
|
|
@@ -228,7 +235,7 @@ function registerSearchContent(server, contextProvider) {
|
|
|
228
235
|
function registerListVerifiedContent(server, contextProvider) {
|
|
229
236
|
(0, content_reader_js_1.registerContentReaderTool)(server, 'list_verified_content', {
|
|
230
237
|
title: 'List verified content',
|
|
231
|
-
description: 'List admin-verified charts and
|
|
238
|
+
description: 'List admin-verified charts, dashboards, data apps, and documents in the resolved project (prefer these as trusted seeds)',
|
|
232
239
|
safety: content_reader_js_1.METADATA_SAFETY,
|
|
233
240
|
inputSchema: {
|
|
234
241
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|