@lightdash-tools/common 0.9.0 → 0.12.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/dist/audit.d.ts +3 -2
- package/dist/audit.js +1 -1
- package/dist/audit.test.js +4 -4
- package/dist/operations/ai-agents.js +26 -30
- package/dist/operations/cli-content.js +6 -8
- package/dist/operations/client-coverage.d.ts +1 -0
- package/dist/operations/client-coverage.js +2 -0
- package/dist/operations/content-developer.js +3 -3
- package/dist/operations/content-governance.js +1 -1
- package/dist/operations/content-reader.js +3 -2
- package/dist/operations/data-analyst.d.ts +5 -0
- package/dist/operations/data-analyst.js +23 -0
- package/dist/operations/index.d.ts +2 -1
- package/dist/operations/index.js +4 -1
- package/dist/operations/organization-audit.js +1 -1
- package/dist/operations/registry.d.ts +5 -5
- package/dist/operations/registry.js +35 -9
- package/dist/operations/registry.test.js +23 -46
- package/dist/operations/semantic-layer.js +8 -7
- package/dist/operations/types.d.ts +10 -6
- package/dist/operations/types.js +22 -14
- package/dist/operations/types.test.js +14 -5
- package/dist/operations/users.js +3 -5
- package/package.json +1 -1
- package/src/audit.test.ts +4 -4
- package/src/audit.ts +5 -3
- package/src/operations/ai-agents.ts +28 -32
- package/src/operations/cli-content.ts +7 -10
- package/src/operations/client-coverage.ts +3 -0
- package/src/operations/content-developer.ts +5 -5
- package/src/operations/content-governance.ts +3 -3
- package/src/operations/content-reader.ts +6 -5
- package/src/operations/data-analyst.ts +27 -0
- package/src/operations/index.ts +3 -1
- package/src/operations/organization-audit.ts +2 -2
- package/src/operations/registry.test.ts +31 -53
- package/src/operations/registry.ts +42 -12
- package/src/operations/semantic-layer.ts +9 -8
- package/src/operations/types.test.ts +34 -6
- package/src/operations/types.ts +41 -33
- package/src/operations/users.ts +4 -7
|
@@ -6,6 +6,7 @@ const cli_content_1 = require("./cli-content");
|
|
|
6
6
|
const content_developer_1 = require("./content-developer");
|
|
7
7
|
const content_governance_1 = require("./content-governance");
|
|
8
8
|
const content_reader_1 = require("./content-reader");
|
|
9
|
+
const data_analyst_1 = require("./data-analyst");
|
|
9
10
|
const organization_audit_1 = require("./organization-audit");
|
|
10
11
|
const registry_1 = require("./registry");
|
|
11
12
|
const semantic_layer_1 = require("./semantic-layer");
|
|
@@ -31,13 +32,7 @@ const P0_OPERATION_IDS = [
|
|
|
31
32
|
'ai-agents.project.evaluations.run',
|
|
32
33
|
'ai-agents.project.evaluations.runs.list',
|
|
33
34
|
];
|
|
34
|
-
const ALL_PROFILES = [
|
|
35
|
-
'ai-agent-ops',
|
|
36
|
-
'core-lifecycle',
|
|
37
|
-
'evaluations',
|
|
38
|
-
'conversations',
|
|
39
|
-
'discovery-readonly',
|
|
40
|
-
];
|
|
35
|
+
const ALL_PROFILES = [...types_1.PROFILE_IDS];
|
|
41
36
|
function requiredFields(operation) {
|
|
42
37
|
var _a;
|
|
43
38
|
const agentExposure = (_a = operation.agentExposure) !== null && _a !== void 0 ? _a : 'agent';
|
|
@@ -78,9 +73,11 @@ function requiredFields(operation) {
|
|
|
78
73
|
content_reader_1.CONTENT_READER_OPERATIONS.length +
|
|
79
74
|
content_developer_1.CONTENT_DEVELOPER_OPERATIONS.length +
|
|
80
75
|
content_governance_1.CONTENT_GOVERNANCE_OPERATIONS.length +
|
|
76
|
+
data_analyst_1.DATA_ANALYST_OPERATIONS.length +
|
|
81
77
|
cli_content_1.CLI_CONTENT_OPERATIONS.length);
|
|
82
78
|
});
|
|
83
79
|
(0, vitest_1.it)('includes required descriptor fields on every operation', () => {
|
|
80
|
+
var _a;
|
|
84
81
|
for (const operation of (0, registry_1.listOperations)()) {
|
|
85
82
|
for (const field of requiredFields(operation)) {
|
|
86
83
|
(0, vitest_1.expect)(field).toBeTruthy();
|
|
@@ -88,7 +85,13 @@ function requiredFields(operation) {
|
|
|
88
85
|
if (operation.agentExposure === 'agent') {
|
|
89
86
|
(0, vitest_1.expect)(operation.mcp !== undefined || operation.cli !== undefined).toBe(true);
|
|
90
87
|
}
|
|
91
|
-
(
|
|
88
|
+
const mcpExposed = ((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true;
|
|
89
|
+
if (mcpExposed) {
|
|
90
|
+
(0, vitest_1.expect)(operation.profiles.length).toBeGreaterThan(0);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
(0, vitest_1.expect)(operation.profiles).toEqual([]);
|
|
94
|
+
}
|
|
92
95
|
(0, vitest_1.expect)(operation.http.path.startsWith('/api/v1/') || operation.http.path.startsWith('/api/v2/')).toBe(true);
|
|
93
96
|
}
|
|
94
97
|
});
|
|
@@ -107,7 +110,7 @@ function requiredFields(operation) {
|
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
});
|
|
110
|
-
(0, vitest_1.it)('exposes profile filters for all
|
|
113
|
+
(0, vitest_1.it)('exposes profile filters for all serving profiles', () => {
|
|
111
114
|
for (const profile of ALL_PROFILES) {
|
|
112
115
|
const operations = (0, registry_1.getOperationsByProfile)(profile);
|
|
113
116
|
(0, vitest_1.expect)(operations.length).toBeGreaterThan(0);
|
|
@@ -116,23 +119,18 @@ function requiredFields(operation) {
|
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
});
|
|
119
|
-
(0, vitest_1.it)('
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'ai-agents.project.agents.delete',
|
|
126
|
-
];
|
|
127
|
-
for (const id of crudIds) {
|
|
128
|
-
const operation = (0, registry_1.getOperation)(id);
|
|
129
|
-
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.profiles).toContain('core-lifecycle');
|
|
122
|
+
(0, vitest_1.it)('listMcpToolNamesByProfile matches exposed ops per profile', () => {
|
|
123
|
+
for (const profile of ALL_PROFILES) {
|
|
124
|
+
const toolNames = (0, registry_1.listMcpToolNamesByProfile)(profile);
|
|
125
|
+
const exposedOps = (0, registry_1.getOperationsByProfile)(profile).filter((operation) => { var _a; return ((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true; });
|
|
126
|
+
(0, vitest_1.expect)(toolNames).toHaveLength(exposedOps.length);
|
|
127
|
+
(0, vitest_1.expect)(new Set(toolNames).size).toBe(toolNames.length);
|
|
130
128
|
}
|
|
131
129
|
});
|
|
132
|
-
(0, vitest_1.it)('maps
|
|
130
|
+
(0, vitest_1.it)('maps exposed ai-agent-ops tools to ai-agent-ops profile only', () => {
|
|
133
131
|
var _a, _b;
|
|
134
|
-
(0, vitest_1.expect)((_a = (0, registry_1.getOperation)('ai-agents.project.
|
|
135
|
-
(0, vitest_1.expect)((_b = (0, registry_1.getOperation)('ai-agents.project.
|
|
132
|
+
(0, vitest_1.expect)((_a = (0, registry_1.getOperation)('ai-agents.project.agents.list')) === null || _a === void 0 ? void 0 : _a.profiles).toEqual(['ai-agent-ops']);
|
|
133
|
+
(0, vitest_1.expect)((_b = (0, registry_1.getOperation)('ai-agents.project.agents.create')) === null || _b === void 0 ? void 0 : _b.profiles).toEqual([]);
|
|
136
134
|
});
|
|
137
135
|
(0, vitest_1.it)('documents multi-step workflow for thread start', () => {
|
|
138
136
|
var _a, _b;
|
|
@@ -150,25 +148,9 @@ function requiredFields(operation) {
|
|
|
150
148
|
(0, vitest_1.expect)((_b = (_a = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.path).toContain('/messages');
|
|
151
149
|
(0, vitest_1.expect)((_d = (_c = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.path).toContain('/generate');
|
|
152
150
|
});
|
|
153
|
-
(0, vitest_1.it)('maps evaluation lifecycle operations to evaluations profile', () => {
|
|
154
|
-
var _a;
|
|
155
|
-
const evalIds = [
|
|
156
|
-
'ai-agents.project.evaluations.create',
|
|
157
|
-
'ai-agents.project.evaluations.append',
|
|
158
|
-
'ai-agents.project.evaluations.run',
|
|
159
|
-
'ai-agents.project.evaluations.runs.list',
|
|
160
|
-
];
|
|
161
|
-
for (const id of evalIds) {
|
|
162
|
-
(0, vitest_1.expect)((_a = (0, registry_1.getOperation)(id)) === null || _a === void 0 ? void 0 : _a.profiles).toContain('evaluations');
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
151
|
(0, vitest_1.it)('returns undefined for unknown operation id', () => {
|
|
166
152
|
(0, vitest_1.expect)((0, registry_1.getOperation)('ai-agents.unknown.operation')).toBeUndefined();
|
|
167
153
|
});
|
|
168
|
-
(0, vitest_1.it)('filters operations by profile with empty result for unknown profile usage', () => {
|
|
169
|
-
const ops = (0, registry_1.getOperationsByProfile)('core-lifecycle');
|
|
170
|
-
(0, vitest_1.expect)(ops.every((op) => op.profiles.includes('core-lifecycle'))).toBe(true);
|
|
171
|
-
});
|
|
172
154
|
(0, vitest_1.it)('registers users.members.delete as client-only', () => {
|
|
173
155
|
const operation = (0, registry_1.getOperation)('users.members.delete');
|
|
174
156
|
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.agentExposure).toBe('client-only');
|
|
@@ -176,6 +158,7 @@ function requiredFields(operation) {
|
|
|
176
158
|
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.cli).toBeUndefined();
|
|
177
159
|
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.bannedMcpToolName).toBe('delete_member');
|
|
178
160
|
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.http.path).toBe('/api/v1/org/user/{userUuid}');
|
|
161
|
+
(0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.profiles).toEqual([]);
|
|
179
162
|
});
|
|
180
163
|
(0, vitest_1.it)('excludes client-only operations from profile discovery catalogs', () => {
|
|
181
164
|
for (const profile of ALL_PROFILES) {
|
|
@@ -184,12 +167,6 @@ function requiredFields(operation) {
|
|
|
184
167
|
}
|
|
185
168
|
}
|
|
186
169
|
(0, vitest_1.expect)((0, registry_1.getOperation)('users.members.delete')).toBeDefined();
|
|
187
|
-
(0, vitest_1.expect)((0, registry_1.getOperationsByProfile)('discovery-readonly').some((op) => op.id === 'users.members.delete')).toBe(false);
|
|
188
|
-
});
|
|
189
|
-
(0, vitest_1.it)('keeps discovery-readonly profile operations read-only', () => {
|
|
190
|
-
for (const operation of (0, registry_1.getOperationsByProfile)('discovery-readonly')) {
|
|
191
|
-
(0, vitest_1.expect)(operation.authorization.safetyImpact).toBe('read');
|
|
192
|
-
}
|
|
193
170
|
});
|
|
194
171
|
(0, vitest_1.it)('never exposes client-only operations on MCP', () => {
|
|
195
172
|
for (const operation of (0, registry_1.listOperations)()) {
|
|
@@ -218,7 +195,7 @@ function requiredFields(operation) {
|
|
|
218
195
|
},
|
|
219
196
|
cli: { commandPath: 'test' },
|
|
220
197
|
agentExposure: 'agent',
|
|
221
|
-
profiles: ['
|
|
198
|
+
profiles: ['semantic-layer'],
|
|
222
199
|
})).toThrow(/authorization\.safetyImpact/);
|
|
223
200
|
});
|
|
224
201
|
});
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SEMANTIC_LAYER_OPERATIONS = void 0;
|
|
7
7
|
const safety_1 = require("../safety");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
|
-
const PROFILE_SEMANTIC = 'semantic-
|
|
9
|
+
const PROFILE_SEMANTIC = 'semantic-layer';
|
|
10
|
+
const PROFILE_DATA_ANALYST = 'data-analyst';
|
|
10
11
|
const API_V1 = '/api/v1';
|
|
11
12
|
const listProjects = (0, types_1.defineOperation)({
|
|
12
13
|
id: 'semantic.projects.list',
|
|
@@ -34,7 +35,7 @@ const getProject = (0, types_1.defineOperation)({
|
|
|
34
35
|
taskSupport: { exposed: true, taskEligible: false },
|
|
35
36
|
},
|
|
36
37
|
cli: { commandPath: 'projects get' },
|
|
37
|
-
profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer'],
|
|
38
|
+
profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer', PROFILE_DATA_ANALYST],
|
|
38
39
|
});
|
|
39
40
|
const listExplores = (0, types_1.defineOperation)({
|
|
40
41
|
id: 'semantic.explores.list',
|
|
@@ -48,7 +49,7 @@ const listExplores = (0, types_1.defineOperation)({
|
|
|
48
49
|
taskSupport: { exposed: true, taskEligible: false },
|
|
49
50
|
},
|
|
50
51
|
cli: { commandPath: 'projects explores list' },
|
|
51
|
-
profiles: [PROFILE_SEMANTIC],
|
|
52
|
+
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
52
53
|
});
|
|
53
54
|
const getExplore = (0, types_1.defineOperation)({
|
|
54
55
|
id: 'semantic.explores.get',
|
|
@@ -62,7 +63,7 @@ const getExplore = (0, types_1.defineOperation)({
|
|
|
62
63
|
taskSupport: { exposed: true, taskEligible: false },
|
|
63
64
|
},
|
|
64
65
|
cli: { commandPath: 'projects explores get' },
|
|
65
|
-
profiles: [PROFILE_SEMANTIC],
|
|
66
|
+
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
66
67
|
});
|
|
67
68
|
const listDimensions = (0, types_1.defineOperation)({
|
|
68
69
|
id: 'semantic.explores.list_dimensions',
|
|
@@ -76,7 +77,7 @@ const listDimensions = (0, types_1.defineOperation)({
|
|
|
76
77
|
taskSupport: { exposed: true, taskEligible: false },
|
|
77
78
|
},
|
|
78
79
|
cli: { commandPath: 'projects explores dimensions' },
|
|
79
|
-
profiles: [PROFILE_SEMANTIC],
|
|
80
|
+
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
80
81
|
});
|
|
81
82
|
const getFieldLineage = (0, types_1.defineOperation)({
|
|
82
83
|
id: 'semantic.explores.get_field_lineage',
|
|
@@ -104,7 +105,7 @@ const listMetrics = (0, types_1.defineOperation)({
|
|
|
104
105
|
taskSupport: { exposed: true, taskEligible: false },
|
|
105
106
|
},
|
|
106
107
|
cli: { commandPath: 'metrics list' },
|
|
107
|
-
profiles: [PROFILE_SEMANTIC],
|
|
108
|
+
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
108
109
|
});
|
|
109
110
|
const getMetric = (0, types_1.defineOperation)({
|
|
110
111
|
id: 'semantic.metrics.get',
|
|
@@ -138,7 +139,7 @@ const compileQuery = (0, types_1.defineOperation)({
|
|
|
138
139
|
taskSupport: { exposed: true, taskEligible: false },
|
|
139
140
|
},
|
|
140
141
|
cli: { commandPath: 'query compile' },
|
|
141
|
-
profiles: [PROFILE_SEMANTIC],
|
|
142
|
+
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
142
143
|
});
|
|
143
144
|
/** Semantic-layer operations registered in the shared operation catalog. */
|
|
144
145
|
exports.SEMANTIC_LAYER_OPERATIONS = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared typed operation catalog (ADR-0013).
|
|
2
|
+
* Shared typed operation catalog (ADR-0013 / ADR-0006).
|
|
3
3
|
* Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
|
|
4
4
|
*/
|
|
5
5
|
import type { SafetyImpact, ToolAnnotations } from '../safety';
|
|
@@ -8,10 +8,10 @@ export type { SafetyImpact };
|
|
|
8
8
|
export type AgentExposure = 'agent' | 'client-only';
|
|
9
9
|
/** HTTP verbs supported by registered operations. */
|
|
10
10
|
export type HttpMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export type
|
|
11
|
+
/** Runtime list of every MCP serving profile id (ADR-0006; fixed mounts / stdio). */
|
|
12
|
+
export declare const PROFILE_IDS: readonly ["ai-agent-ops", "content-developer", "content-governance", "content-reader", "data-analyst", "organization-audit", "semantic-layer"];
|
|
13
|
+
/** MCP serving profile ids aligned to fixed HTTP mounts / stdio subcommands (ADR-0006). */
|
|
14
|
+
export type ProfileId = (typeof PROFILE_IDS)[number];
|
|
15
15
|
/**
|
|
16
16
|
* MCP response sensitivity class (ADR-0011).
|
|
17
17
|
* Documents which redaction class handlers must apply; does not auto-redact.
|
|
@@ -62,7 +62,11 @@ export type OperationDescriptor = {
|
|
|
62
62
|
* Defaults to `none` when omitted from `defineOperation` input.
|
|
63
63
|
*/
|
|
64
64
|
sensitivity: SensitivityClass;
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* MCP mounts that expose this op when `mcp.taskSupport.exposed` is true (ADR-0006).
|
|
67
|
+
* Empty when the op is not MCP-exposed (CLI-only / reserved / client-only).
|
|
68
|
+
*/
|
|
69
|
+
profiles: readonly ProfileId[];
|
|
66
70
|
/** `agent` (default) = may appear on MCP and/or CLI; `client-only` = typed client only. */
|
|
67
71
|
agentExposure: AgentExposure;
|
|
68
72
|
/** Present when the operation is registered (or reserved) as an MCP tool. */
|
package/dist/operations/types.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Shared typed operation catalog (ADR-0013).
|
|
3
|
+
* Shared typed operation catalog (ADR-0013 / ADR-0006).
|
|
4
4
|
* Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PROFILE_IDS = void 0;
|
|
7
8
|
exports.defineOperation = defineOperation;
|
|
8
|
-
|
|
9
|
+
/** Runtime list of every MCP serving profile id (ADR-0006; fixed mounts / stdio). */
|
|
10
|
+
exports.PROFILE_IDS = [
|
|
9
11
|
'ai-agent-ops',
|
|
10
12
|
'content-developer',
|
|
11
13
|
'content-governance',
|
|
12
14
|
'content-reader',
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'semantic-discovery',
|
|
19
|
-
]);
|
|
15
|
+
'data-analyst',
|
|
16
|
+
'organization-audit',
|
|
17
|
+
'semantic-layer',
|
|
18
|
+
];
|
|
19
|
+
const VALID_PROFILES = new Set(exports.PROFILE_IDS);
|
|
20
20
|
const VALID_SENSITIVITY = new Set([
|
|
21
21
|
'none',
|
|
22
22
|
'pii.email',
|
|
@@ -45,15 +45,23 @@ function validateIdempotentHint(annotations, impact, id) {
|
|
|
45
45
|
throw new Error(`Operation '${id}': destructive operations must not set mcp.annotations.idempotentHint = true`);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function validateProfiles(
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
function validateProfiles(input) {
|
|
49
|
+
const { id, profiles, mcp } = input;
|
|
50
|
+
const mcpExposed = (mcp === null || mcp === void 0 ? void 0 : mcp.taskSupport.exposed) === true;
|
|
51
|
+
if (mcpExposed && profiles.length === 0) {
|
|
52
|
+
throw new Error(`Operation '${id}' must declare at least one profile when mcp.taskSupport.exposed is true`);
|
|
53
|
+
}
|
|
54
|
+
if (new Set(profiles).size !== profiles.length) {
|
|
55
|
+
throw new Error(`Operation '${id}' has duplicate profiles: ${profiles.join(', ')}`);
|
|
51
56
|
}
|
|
52
57
|
for (const profile of profiles) {
|
|
53
58
|
if (!VALID_PROFILES.has(profile)) {
|
|
54
|
-
throw new Error(`Operation '${id}' has unknown
|
|
59
|
+
throw new Error(`Operation '${id}' has unknown profile '${profile}'`);
|
|
55
60
|
}
|
|
56
61
|
}
|
|
62
|
+
if (!mcpExposed && profiles.length > 0) {
|
|
63
|
+
throw new Error(`Operation '${id}' must use empty profiles when not MCP-exposed (got ${profiles.join(', ')})`);
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
function validateClientOnlyOperation(input) {
|
|
59
67
|
var _a;
|
|
@@ -89,7 +97,7 @@ function defineOperation(input) {
|
|
|
89
97
|
if (!VALID_SENSITIVITY.has(sensitivity)) {
|
|
90
98
|
throw new Error(`Operation '${input.id}' has unknown sensitivity '${String(sensitivity)}'`);
|
|
91
99
|
}
|
|
92
|
-
validateProfiles(input
|
|
100
|
+
validateProfiles(input);
|
|
93
101
|
const agentExposure = (_b = input.agentExposure) !== null && _b !== void 0 ? _b : 'agent';
|
|
94
102
|
if (agentExposure === 'client-only') {
|
|
95
103
|
return validateClientOnlyOperation(Object.assign(Object.assign({}, input), { sensitivity }));
|
|
@@ -31,7 +31,7 @@ const baseDescriptor = {
|
|
|
31
31
|
},
|
|
32
32
|
cli: { commandPath: 'test op' },
|
|
33
33
|
agentExposure: 'agent',
|
|
34
|
-
profiles: ['
|
|
34
|
+
profiles: ['semantic-layer'],
|
|
35
35
|
};
|
|
36
36
|
(0, vitest_1.describe)('defineOperation', () => {
|
|
37
37
|
(0, vitest_1.it)('accepts a valid read descriptor', () => {
|
|
@@ -53,19 +53,28 @@ const baseDescriptor = {
|
|
|
53
53
|
(0, vitest_1.it)('allows agent ops with cli only', () => {
|
|
54
54
|
const { mcp: _mcp } = baseDescriptor, rest = __rest(baseDescriptor, ["mcp"]);
|
|
55
55
|
void _mcp;
|
|
56
|
-
(0, vitest_1.expect)((0, types_1.defineOperation)(rest).mcp).toBeUndefined();
|
|
56
|
+
(0, vitest_1.expect)((0, types_1.defineOperation)(Object.assign(Object.assign({}, rest), { profiles: [] })).mcp).toBeUndefined();
|
|
57
57
|
});
|
|
58
58
|
(0, vitest_1.it)('rejects agent ops with neither mcp nor cli', () => {
|
|
59
59
|
const { mcp: _mcp, cli: _cli } = baseDescriptor, rest = __rest(baseDescriptor, ["mcp", "cli"]);
|
|
60
60
|
void _mcp;
|
|
61
61
|
void _cli;
|
|
62
|
-
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(rest)).toThrow(/require mcp and\/or cli/);
|
|
62
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, rest), { profiles: [] }))).toThrow(/require mcp and\/or cli/);
|
|
63
63
|
});
|
|
64
64
|
(0, vitest_1.it)('rejects empty id', () => {
|
|
65
65
|
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { id: ' ' }))).toThrow(/id/);
|
|
66
66
|
});
|
|
67
67
|
(0, vitest_1.it)('rejects unknown profile', () => {
|
|
68
|
-
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { profiles: ['unknown-profile'] }))).toThrow(/unknown
|
|
68
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { profiles: ['unknown-profile'] }))).toThrow(/unknown profile/);
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.it)('rejects empty profiles when MCP-exposed', () => {
|
|
71
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { profiles: [] }))).toThrow(/at least one profile/);
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.it)('rejects duplicate profiles', () => {
|
|
74
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { profiles: ['semantic-layer', 'semantic-layer'] }))).toThrow(/duplicate profiles/);
|
|
75
|
+
});
|
|
76
|
+
(0, vitest_1.it)('rejects non-empty profiles when not MCP-exposed', () => {
|
|
77
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { mcp: Object.assign(Object.assign({}, baseDescriptor.mcp), { taskSupport: { exposed: false, taskEligible: false } }), profiles: ['semantic-layer'] }))).toThrow(/empty profiles/);
|
|
69
78
|
});
|
|
70
79
|
(0, vitest_1.it)('allows read operation with idempotentHint false (transient execution)', () => {
|
|
71
80
|
var _a;
|
|
@@ -83,7 +92,7 @@ const baseDescriptor = {
|
|
|
83
92
|
authorization: { safetyImpact: 'write-destructive' },
|
|
84
93
|
agentExposure: 'client-only',
|
|
85
94
|
bannedMcpToolName: 'delete_test',
|
|
86
|
-
profiles: [
|
|
95
|
+
profiles: [],
|
|
87
96
|
});
|
|
88
97
|
(0, vitest_1.expect)(op.agentExposure).toBe('client-only');
|
|
89
98
|
(0, vitest_1.expect)(op.bannedMcpToolName).toBe('delete_test');
|
package/dist/operations/users.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.USER_OPERATIONS = void 0;
|
|
7
7
|
const safety_1 = require("../safety");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
|
-
const PROFILE_DISCOVERY = 'discovery-readonly';
|
|
10
|
-
const PROFILE_CORE_LIFECYCLE = 'core-lifecycle';
|
|
11
9
|
const API_V1 = '/api/v1';
|
|
12
10
|
const MEMBERS_PATH = `${API_V1}/org/users`;
|
|
13
11
|
const MEMBER_PATH = `${MEMBERS_PATH}/{userUuid}`;
|
|
@@ -24,7 +22,7 @@ const membersList = (0, types_1.defineOperation)({
|
|
|
24
22
|
taskSupport: { exposed: false, taskEligible: false },
|
|
25
23
|
},
|
|
26
24
|
cli: { commandPath: 'users list' },
|
|
27
|
-
profiles: [
|
|
25
|
+
profiles: [],
|
|
28
26
|
});
|
|
29
27
|
const membersGet = (0, types_1.defineOperation)({
|
|
30
28
|
id: 'users.members.get',
|
|
@@ -38,7 +36,7 @@ const membersGet = (0, types_1.defineOperation)({
|
|
|
38
36
|
taskSupport: { exposed: false, taskEligible: false },
|
|
39
37
|
},
|
|
40
38
|
cli: { commandPath: 'users get' },
|
|
41
|
-
profiles: [
|
|
39
|
+
profiles: [],
|
|
42
40
|
});
|
|
43
41
|
const membersDelete = (0, types_1.defineOperation)({
|
|
44
42
|
id: 'users.members.delete',
|
|
@@ -48,7 +46,7 @@ const membersDelete = (0, types_1.defineOperation)({
|
|
|
48
46
|
sensitivity: 'none',
|
|
49
47
|
agentExposure: 'client-only',
|
|
50
48
|
bannedMcpToolName: 'delete_member',
|
|
51
|
-
profiles: [
|
|
49
|
+
profiles: [],
|
|
52
50
|
});
|
|
53
51
|
/** Organization member operations registered in the shared operation catalog. */
|
|
54
52
|
exports.USER_OPERATIONS = [
|
package/package.json
CHANGED
package/src/audit.test.ts
CHANGED
|
@@ -40,13 +40,13 @@ describe('audit', () => {
|
|
|
40
40
|
status: 'blocked',
|
|
41
41
|
startMs: Date.now() - 5,
|
|
42
42
|
projectUuids: [],
|
|
43
|
-
|
|
43
|
+
profileId: 'semantic-layer',
|
|
44
44
|
});
|
|
45
45
|
expect(entry.channel).toBe('audit');
|
|
46
46
|
expect(entry.severity).toBe('WARNING');
|
|
47
47
|
expect(entry.message).toBe('demo_tool blocked');
|
|
48
48
|
expect(entry.projectUuids).toBeUndefined();
|
|
49
|
-
expect(entry.
|
|
49
|
+
expect(entry.profileId).toBe('semantic-layer');
|
|
50
50
|
expect(entry.sessionId).toBe(getSessionId());
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -73,7 +73,7 @@ describe('audit', () => {
|
|
|
73
73
|
tokenHash: 'abc123',
|
|
74
74
|
subject: 'user-uuid',
|
|
75
75
|
clientSessionId: 'mcp-session-1',
|
|
76
|
-
|
|
76
|
+
profileId: 'semantic-layer',
|
|
77
77
|
}),
|
|
78
78
|
);
|
|
79
79
|
|
|
@@ -90,7 +90,7 @@ describe('audit', () => {
|
|
|
90
90
|
expect(parsed.tokenHash).toBe('abc123');
|
|
91
91
|
expect(parsed.subject).toBe('user-uuid');
|
|
92
92
|
expect(parsed.clientSessionId).toBe('mcp-session-1');
|
|
93
|
-
expect(parsed.
|
|
93
|
+
expect(parsed.profileId).toBe('semantic-layer');
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
it('logAuditEntry appends to a file when initAuditLog receives a path', async () => {
|
package/src/audit.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { randomUUID } from 'node:crypto';
|
|
11
11
|
import { createWriteStream, type WriteStream } from 'node:fs';
|
|
12
12
|
|
|
13
|
+
import type { ProfileId } from './operations/types';
|
|
14
|
+
|
|
13
15
|
export type AuditStatus =
|
|
14
16
|
| 'blocked'
|
|
15
17
|
| 'confirmation_cancelled'
|
|
@@ -41,7 +43,7 @@ export type AuditLogEntry = {
|
|
|
41
43
|
/** Lightdash user UUID when the call runs under OAuth bearer auth. */
|
|
42
44
|
subject?: string;
|
|
43
45
|
clientSessionId?: string;
|
|
44
|
-
|
|
46
|
+
profileId?: ProfileId;
|
|
45
47
|
status: AuditStatus;
|
|
46
48
|
durationMs: number;
|
|
47
49
|
};
|
|
@@ -55,7 +57,7 @@ export type BuildAuditLogEntryInput = {
|
|
|
55
57
|
tokenHash?: string;
|
|
56
58
|
subject?: string;
|
|
57
59
|
clientSessionId?: string;
|
|
58
|
-
|
|
60
|
+
profileId?: ProfileId;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
/** Unique ID for the current process lifetime. Generated once at module load. */
|
|
@@ -107,7 +109,7 @@ export function buildAuditLogEntry(input: BuildAuditLogEntryInput): AuditLogEntr
|
|
|
107
109
|
tokenHash: input.tokenHash,
|
|
108
110
|
subject: input.subject,
|
|
109
111
|
clientSessionId: input.clientSessionId,
|
|
110
|
-
|
|
112
|
+
profileId: input.profileId,
|
|
111
113
|
status: input.status,
|
|
112
114
|
durationMs: Date.now() - input.startMs,
|
|
113
115
|
};
|