@lightdash-tools/common 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/argument-validation.js +20 -2
- package/dist/argument-validation.test.js +22 -0
- package/dist/audit.d.ts +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +6 -8
- package/dist/operations/agent-safe.d.ts +1 -3
- package/dist/operations/agent-safe.js +2 -9
- package/dist/operations/ai-agents.js +45 -29
- package/dist/operations/cli-content.d.ts +5 -0
- package/dist/operations/cli-content.js +71 -0
- package/dist/operations/client-coverage.d.ts +113 -0
- package/dist/operations/client-coverage.js +130 -0
- package/dist/operations/client-coverage.test.d.ts +1 -0
- package/dist/operations/client-coverage.test.js +22 -0
- package/dist/operations/content-developer.d.ts +2 -0
- package/dist/operations/content-developer.js +457 -0
- package/dist/operations/content-governance.d.ts +7 -0
- package/dist/operations/content-governance.js +98 -0
- package/dist/operations/content-reader.d.ts +2 -0
- package/dist/operations/content-reader.js +183 -0
- package/dist/operations/index.d.ts +10 -3
- package/dist/operations/index.js +20 -2
- package/dist/operations/organization-audit.d.ts +2 -0
- package/dist/operations/organization-audit.js +273 -0
- package/dist/operations/parity.test.js +12 -11
- package/dist/operations/registry.d.ts +9 -1
- package/dist/operations/registry.js +77 -2
- package/dist/operations/registry.test.js +38 -11
- package/dist/operations/semantic-layer.d.ts +6 -0
- package/dist/operations/semantic-layer.js +154 -0
- package/dist/operations/types.d.ts +29 -12
- package/dist/operations/types.js +63 -29
- package/dist/operations/types.test.js +33 -45
- package/dist/operations/users.d.ts +2 -2
- package/dist/operations/users.js +8 -10
- package/dist/safety.d.ts +5 -0
- package/dist/safety.js +11 -1
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +29 -0
- package/package.json +2 -1
- package/src/argument-validation.test.ts +31 -0
- package/src/argument-validation.ts +20 -2
- package/src/audit.ts +12 -1
- package/src/index.ts +5 -9
- package/src/operations/agent-safe.ts +2 -12
- package/src/operations/ai-agents.ts +46 -30
- package/src/operations/cli-content.ts +79 -0
- package/src/operations/client-coverage.test.ts +23 -0
- package/src/operations/client-coverage.ts +147 -0
- package/src/operations/content-developer.ts +485 -0
- package/src/operations/content-governance.ts +110 -0
- package/src/operations/content-reader.ts +197 -0
- package/src/operations/index.ts +25 -2
- package/src/operations/organization-audit.ts +293 -0
- package/src/operations/parity.test.ts +12 -14
- package/src/operations/registry.test.ts +40 -9
- package/src/operations/registry.ts +86 -2
- package/src/operations/semantic-layer.ts +166 -0
- package/src/operations/types.test.ts +38 -76
- package/src/operations/types.ts +110 -47
- package/src/operations/users.ts +9 -11
- package/src/safety.ts +11 -0
- package/src/types/index.ts +13 -0
|
@@ -18,6 +18,7 @@ const baseDescriptor = {
|
|
|
18
18
|
summary: 'Test operation',
|
|
19
19
|
http: { method: 'GET', path: '/api/v1/test' },
|
|
20
20
|
authorization: { safetyImpact: 'read' },
|
|
21
|
+
sensitivity: 'none',
|
|
21
22
|
mcp: {
|
|
22
23
|
toolName: 'test_op',
|
|
23
24
|
annotations: {
|
|
@@ -34,71 +35,58 @@ const baseDescriptor = {
|
|
|
34
35
|
};
|
|
35
36
|
(0, vitest_1.describe)('defineOperation', () => {
|
|
36
37
|
(0, vitest_1.it)('accepts a valid read descriptor', () => {
|
|
37
|
-
(0, vitest_1.expect)((0, types_1.defineOperation)(baseDescriptor)).toEqual(Object.assign(Object.assign({}, baseDescriptor), { agentExposure: 'agent' }));
|
|
38
|
+
(0, vitest_1.expect)((0, types_1.defineOperation)(baseDescriptor)).toEqual(Object.assign(Object.assign({}, baseDescriptor), { agentExposure: 'agent', sensitivity: 'none' }));
|
|
38
39
|
});
|
|
39
|
-
(0, vitest_1.it)('defaults agentExposure to agent', () => {
|
|
40
|
-
const { agentExposure } = baseDescriptor,
|
|
40
|
+
(0, vitest_1.it)('defaults agentExposure to agent and sensitivity to none', () => {
|
|
41
|
+
const { agentExposure, sensitivity } = baseDescriptor, withoutDefaults = __rest(baseDescriptor, ["agentExposure", "sensitivity"]);
|
|
41
42
|
void agentExposure;
|
|
42
|
-
|
|
43
|
+
void sensitivity;
|
|
44
|
+
const op = (0, types_1.defineOperation)(withoutDefaults);
|
|
45
|
+
(0, vitest_1.expect)(op.agentExposure).toBe('agent');
|
|
46
|
+
(0, vitest_1.expect)(op.sensitivity).toBe('none');
|
|
43
47
|
});
|
|
44
|
-
(0, vitest_1.it)('
|
|
45
|
-
|
|
48
|
+
(0, vitest_1.it)('allows agent ops with mcp only', () => {
|
|
49
|
+
const { cli: _cli } = baseDescriptor, rest = __rest(baseDescriptor, ["cli"]);
|
|
50
|
+
void _cli;
|
|
51
|
+
(0, vitest_1.expect)((0, types_1.defineOperation)(rest).cli).toBeUndefined();
|
|
46
52
|
});
|
|
47
|
-
(0, vitest_1.it)('
|
|
48
|
-
|
|
53
|
+
(0, vitest_1.it)('allows agent ops with cli only', () => {
|
|
54
|
+
const { mcp: _mcp } = baseDescriptor, rest = __rest(baseDescriptor, ["mcp"]);
|
|
55
|
+
void _mcp;
|
|
56
|
+
(0, vitest_1.expect)((0, types_1.defineOperation)(rest).mcp).toBeUndefined();
|
|
49
57
|
});
|
|
50
|
-
(0, vitest_1.it)('rejects
|
|
51
|
-
|
|
58
|
+
(0, vitest_1.it)('rejects agent ops with neither mcp nor cli', () => {
|
|
59
|
+
const { mcp: _mcp, cli: _cli } = baseDescriptor, rest = __rest(baseDescriptor, ["mcp", "cli"]);
|
|
60
|
+
void _mcp;
|
|
61
|
+
void _cli;
|
|
62
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(rest)).toThrow(/require mcp and\/or cli/);
|
|
52
63
|
});
|
|
53
|
-
(0, vitest_1.it)('rejects empty
|
|
54
|
-
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), {
|
|
64
|
+
(0, vitest_1.it)('rejects empty id', () => {
|
|
65
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { id: ' ' }))).toThrow(/id/);
|
|
55
66
|
});
|
|
56
67
|
(0, vitest_1.it)('rejects unknown profile', () => {
|
|
57
68
|
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { profiles: ['unknown-profile'] }))).toThrow(/unknown capability profile/);
|
|
58
69
|
});
|
|
59
|
-
(0, vitest_1.it)('
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { authorization: { safetyImpact: 'write-destructive' }, mcp: Object.assign(Object.assign({}, baseDescriptor.mcp), { annotations: {
|
|
64
|
-
readOnlyHint: false,
|
|
65
|
-
destructiveHint: true,
|
|
66
|
-
idempotentHint: true,
|
|
67
|
-
openWorldHint: false,
|
|
68
|
-
} }) }))).toThrow(/destructive operations/);
|
|
70
|
+
(0, vitest_1.it)('allows read operation with idempotentHint false (transient execution)', () => {
|
|
71
|
+
var _a;
|
|
72
|
+
const op = (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { mcp: Object.assign(Object.assign({}, baseDescriptor.mcp), { annotations: Object.assign(Object.assign({}, baseDescriptor.mcp.annotations), { idempotentHint: false }) }) }));
|
|
73
|
+
(0, vitest_1.expect)((_a = op.mcp) === null || _a === void 0 ? void 0 : _a.annotations.idempotentHint).toBe(false);
|
|
69
74
|
});
|
|
70
|
-
(0, vitest_1.it)('rejects client-only operation
|
|
71
|
-
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { agentExposure: 'client-only'
|
|
75
|
+
(0, vitest_1.it)('rejects client-only operation that still has mcp', () => {
|
|
76
|
+
(0, vitest_1.expect)(() => (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { agentExposure: 'client-only' }))).toThrow(/must omit mcp and cli/);
|
|
72
77
|
});
|
|
73
|
-
(0, vitest_1.it)('allows client-only operation
|
|
78
|
+
(0, vitest_1.it)('allows client-only operation with bannedMcpToolName and no mcp/cli', () => {
|
|
74
79
|
const op = (0, types_1.defineOperation)({
|
|
75
80
|
id: 'test.client-only',
|
|
76
81
|
summary: 'Client only delete',
|
|
77
82
|
http: { method: 'DELETE', path: '/api/v1/test/{id}' },
|
|
78
83
|
authorization: { safetyImpact: 'write-destructive' },
|
|
79
|
-
mcp: {
|
|
80
|
-
toolName: '',
|
|
81
|
-
annotations: {
|
|
82
|
-
readOnlyHint: false,
|
|
83
|
-
destructiveHint: true,
|
|
84
|
-
idempotentHint: false,
|
|
85
|
-
openWorldHint: false,
|
|
86
|
-
},
|
|
87
|
-
taskSupport: { exposed: false, taskEligible: false },
|
|
88
|
-
},
|
|
89
|
-
cli: { commandPath: '' },
|
|
90
84
|
agentExposure: 'client-only',
|
|
85
|
+
bannedMcpToolName: 'delete_test',
|
|
91
86
|
profiles: ['discovery-readonly'],
|
|
92
87
|
});
|
|
93
88
|
(0, vitest_1.expect)(op.agentExposure).toBe('client-only');
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const op = (0, types_1.defineOperation)(Object.assign(Object.assign({}, baseDescriptor), { authorization: { safetyImpact: 'external-side-effect' }, mcp: Object.assign(Object.assign({}, baseDescriptor.mcp), { annotations: {
|
|
97
|
-
readOnlyHint: false,
|
|
98
|
-
destructiveHint: false,
|
|
99
|
-
idempotentHint: false,
|
|
100
|
-
openWorldHint: true,
|
|
101
|
-
} }) }));
|
|
102
|
-
(0, vitest_1.expect)(op.authorization.safetyImpact).toBe('external-side-effect');
|
|
89
|
+
(0, vitest_1.expect)(op.bannedMcpToolName).toBe('delete_test');
|
|
90
|
+
(0, vitest_1.expect)(op.sensitivity).toBe('none');
|
|
103
91
|
});
|
|
104
92
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Organization member operations in the shared operation
|
|
2
|
+
* Organization member operations in the shared operation catalog.
|
|
3
3
|
*/
|
|
4
4
|
import type { OperationDescriptor } from './types';
|
|
5
|
-
/** Organization member operations registered in the shared operation
|
|
5
|
+
/** Organization member operations registered in the shared operation catalog. */
|
|
6
6
|
export declare const USER_OPERATIONS: readonly OperationDescriptor[];
|
package/dist/operations/users.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Organization member operations in the shared operation
|
|
3
|
+
* Organization member operations in the shared operation catalog.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.USER_OPERATIONS = void 0;
|
|
@@ -17,10 +17,11 @@ const membersList = (0, types_1.defineOperation)({
|
|
|
17
17
|
summary: 'List organization members (one page)',
|
|
18
18
|
http: { method: 'GET', path: MEMBERS_PATH },
|
|
19
19
|
authorization: { safetyImpact: 'read' },
|
|
20
|
+
sensitivity: 'pii.email',
|
|
20
21
|
mcp: {
|
|
21
22
|
toolName: 'list_organization_members',
|
|
22
23
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
23
|
-
taskSupport: { exposed:
|
|
24
|
+
taskSupport: { exposed: false, taskEligible: false },
|
|
24
25
|
},
|
|
25
26
|
cli: { commandPath: 'users list' },
|
|
26
27
|
profiles: [PROFILE_DISCOVERY],
|
|
@@ -30,10 +31,11 @@ const membersGet = (0, types_1.defineOperation)({
|
|
|
30
31
|
summary: 'Get an organization member by UUID',
|
|
31
32
|
http: { method: 'GET', path: MEMBER_PATH },
|
|
32
33
|
authorization: { safetyImpact: 'read' },
|
|
34
|
+
sensitivity: 'pii.email',
|
|
33
35
|
mcp: {
|
|
34
36
|
toolName: 'get_member',
|
|
35
37
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
36
|
-
taskSupport: { exposed:
|
|
38
|
+
taskSupport: { exposed: false, taskEligible: false },
|
|
37
39
|
},
|
|
38
40
|
cli: { commandPath: 'users get' },
|
|
39
41
|
profiles: [PROFILE_DISCOVERY],
|
|
@@ -43,16 +45,12 @@ const membersDelete = (0, types_1.defineOperation)({
|
|
|
43
45
|
summary: 'Permanently remove a user from the organization (irrecoverable; client-only)',
|
|
44
46
|
http: { method: 'DELETE', path: DELETE_MEMBER_PATH },
|
|
45
47
|
authorization: { safetyImpact: 'write-destructive' },
|
|
46
|
-
|
|
47
|
-
toolName: 'delete_member',
|
|
48
|
-
annotations: safety_1.WRITE_DESTRUCTIVE,
|
|
49
|
-
taskSupport: { exposed: false, taskEligible: false },
|
|
50
|
-
},
|
|
51
|
-
cli: { commandPath: '' },
|
|
48
|
+
sensitivity: 'none',
|
|
52
49
|
agentExposure: 'client-only',
|
|
50
|
+
bannedMcpToolName: 'delete_member',
|
|
53
51
|
profiles: [PROFILE_CORE_LIFECYCLE],
|
|
54
52
|
});
|
|
55
|
-
/** Organization member operations registered in the shared operation
|
|
53
|
+
/** Organization member operations registered in the shared operation catalog. */
|
|
56
54
|
exports.USER_OPERATIONS = [
|
|
57
55
|
membersList,
|
|
58
56
|
membersGet,
|
package/dist/safety.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export type OperationPolicy = {
|
|
|
30
30
|
};
|
|
31
31
|
/** Preset: read-only, non-destructive, idempotent, closed-world. Use for list/get/compile tools. */
|
|
32
32
|
export declare const READ_ONLY_DEFAULT: ToolAnnotations;
|
|
33
|
+
/**
|
|
34
|
+
* Preset: read-only but non-idempotent (transient warehouse execution).
|
|
35
|
+
* Used by content-reader saved-chart/tile runs (ADR-0012).
|
|
36
|
+
*/
|
|
37
|
+
export declare const READ_ONLY_TRANSIENT: ToolAnnotations;
|
|
33
38
|
/**
|
|
34
39
|
* Legacy preset: write, non-destructive, idempotent (e.g. upsert by slug).
|
|
35
40
|
* Prefer {@link WRITE_NONDESTRUCTIVE} for new tools; idempotent behavior is not implied by safety mode.
|
package/dist/safety.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WRITE_DESTRUCTIVE = exports.WRITE_OPEN_WORLD = exports.WRITE_NONDESTRUCTIVE = exports.WRITE_IDEMPOTENT = exports.READ_ONLY_DEFAULT = exports.SafetyMode = void 0;
|
|
3
|
+
exports.WRITE_DESTRUCTIVE = exports.WRITE_OPEN_WORLD = exports.WRITE_NONDESTRUCTIVE = exports.WRITE_IDEMPOTENT = exports.READ_ONLY_TRANSIENT = exports.READ_ONLY_DEFAULT = exports.SafetyMode = void 0;
|
|
4
4
|
exports.isAllowed = isAllowed;
|
|
5
5
|
exports.isOperationAllowed = isOperationAllowed;
|
|
6
6
|
exports.getSafetyModeFromEnv = getSafetyModeFromEnv;
|
|
@@ -28,6 +28,16 @@ exports.READ_ONLY_DEFAULT = {
|
|
|
28
28
|
destructiveHint: false,
|
|
29
29
|
idempotentHint: true,
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Preset: read-only but non-idempotent (transient warehouse execution).
|
|
33
|
+
* Used by content-reader saved-chart/tile runs (ADR-0012).
|
|
34
|
+
*/
|
|
35
|
+
exports.READ_ONLY_TRANSIENT = {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
openWorldHint: false,
|
|
38
|
+
destructiveHint: false,
|
|
39
|
+
idempotentHint: false,
|
|
40
|
+
};
|
|
31
41
|
/**
|
|
32
42
|
* Legacy preset: write, non-destructive, idempotent (e.g. upsert by slug).
|
|
33
43
|
* Prefer {@link WRITE_NONDESTRUCTIVE} for new tools; idempotent behavior is not implied by safety mode.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated public type surface for `@lightdash-tools/common` (ADR-0013).
|
|
3
|
+
*
|
|
4
|
+
* Adding a consumer type:
|
|
5
|
+
* 1. Alias from `generated/openapi-types` in `types/v1/` or `types/v2/` domain modules.
|
|
6
|
+
* 2. Export it from this barrel (via `lightdash-api.ts` or a direct re-export).
|
|
7
|
+
*
|
|
8
|
+
* Outside this package, import types only from `@lightdash-tools/common` — not from nested paths.
|
|
9
|
+
*/
|
|
10
|
+
export * from './lightdash-api';
|
|
11
|
+
export { CONTENT_SORT_BY_COLUMNS } from './v2/content';
|
|
12
|
+
export type { components, operations, paths } from './generated/openapi-types';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Curated public type surface for `@lightdash-tools/common` (ADR-0013).
|
|
4
|
+
*
|
|
5
|
+
* Adding a consumer type:
|
|
6
|
+
* 1. Alias from `generated/openapi-types` in `types/v1/` or `types/v2/` domain modules.
|
|
7
|
+
* 2. Export it from this barrel (via `lightdash-api.ts` or a direct re-export).
|
|
8
|
+
*
|
|
9
|
+
* Outside this package, import types only from `@lightdash-tools/common` — not from nested paths.
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CONTENT_SORT_BY_COLUMNS = void 0;
|
|
27
|
+
__exportStar(require("./lightdash-api"), exports);
|
|
28
|
+
var content_1 = require("./v2/content");
|
|
29
|
+
Object.defineProperty(exports, "CONTENT_SORT_BY_COLUMNS", { enumerable: true, get: function () { return content_1.CONTENT_SORT_BY_COLUMNS; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Shared utilities and types for Lightdash AI.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc",
|
|
28
|
+
"check:client-coverage": "node ../../scripts/check-client-operation-coverage.mjs",
|
|
28
29
|
"generate:operation-registry": "node ../../scripts/generate-operation-registry.mjs",
|
|
29
30
|
"generate:types": "node ../../scripts/openapi-types-url.mjs | xargs -I{} openapi-typescript {} -o src/types/generated/openapi-types.ts && node ../../scripts/fix-openapi-duplicate-operations.mjs && prettier --write src/types/generated/openapi-types.ts"
|
|
30
31
|
}
|
|
@@ -18,12 +18,17 @@ describe('argument-validation', () => {
|
|
|
18
18
|
'agentUuid',
|
|
19
19
|
'artifactUuid',
|
|
20
20
|
'chartUuid',
|
|
21
|
+
'chartUuidOrSlug',
|
|
22
|
+
'contentUuidOrSlug',
|
|
21
23
|
'dashboardUuid',
|
|
24
|
+
'dashboardUuidOrSlug',
|
|
22
25
|
'evalUuid',
|
|
23
26
|
'fingerprint',
|
|
24
27
|
'groupUuid',
|
|
28
|
+
'itemUuids',
|
|
25
29
|
'mcpServerUuid',
|
|
26
30
|
'messageUuid',
|
|
31
|
+
'newSlug',
|
|
27
32
|
'organizationUuid',
|
|
28
33
|
'parentSpaceUuid',
|
|
29
34
|
'project',
|
|
@@ -36,12 +41,18 @@ describe('argument-validation', () => {
|
|
|
36
41
|
'savedQueryUuid',
|
|
37
42
|
'schedulerUuid',
|
|
38
43
|
'slug',
|
|
44
|
+
'sourceChartUuidOrSlug',
|
|
45
|
+
'sourceDashboardUuid',
|
|
39
46
|
'spaceUuid',
|
|
40
47
|
'spaceUuids',
|
|
48
|
+
'targetSpaceUuid',
|
|
41
49
|
'threadUuid',
|
|
50
|
+
'tileUuid',
|
|
42
51
|
'toolCallId',
|
|
43
52
|
'userUuid',
|
|
44
53
|
'versionUuid',
|
|
54
|
+
'versionUuidA',
|
|
55
|
+
'versionUuidB',
|
|
45
56
|
].sort(),
|
|
46
57
|
);
|
|
47
58
|
});
|
|
@@ -210,6 +221,26 @@ describe('argument-validation', () => {
|
|
|
210
221
|
);
|
|
211
222
|
});
|
|
212
223
|
|
|
224
|
+
it('validates chartUuidOrSlug/dashboardUuidOrSlug and itemUuids/targetSpaceUuid', () => {
|
|
225
|
+
expect(() =>
|
|
226
|
+
validateResourceIdsInObject({
|
|
227
|
+
chartUuidOrSlug: 'my-chart',
|
|
228
|
+
dashboardUuidOrSlug: VALID_UUID,
|
|
229
|
+
itemUuids: [VALID_UUID],
|
|
230
|
+
targetSpaceUuid: VALID_UUID,
|
|
231
|
+
}),
|
|
232
|
+
).not.toThrow();
|
|
233
|
+
expect(() => validateResourceIdsInObject({ itemUuids: [VALID_UUID, 'bad-uuid'] })).toThrow(
|
|
234
|
+
'Invalid UUID format',
|
|
235
|
+
);
|
|
236
|
+
expect(() => validateResourceIdsInObject({ targetSpaceUuid: 'bad?' })).toThrow(
|
|
237
|
+
'Invalid UUID format',
|
|
238
|
+
);
|
|
239
|
+
expect(() => validateResourceIdsInObject({ chartUuidOrSlug: 'bad?' })).toThrow(
|
|
240
|
+
'Slug must contain only alphanumeric characters',
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
213
244
|
it('validates spaceUuids and parentSpaceUuid as UUIDs', () => {
|
|
214
245
|
expect(() =>
|
|
215
246
|
validateResourceIdsInObject({
|
|
@@ -25,6 +25,8 @@ export const RESOURCE_ID_KEYS = new Set([
|
|
|
25
25
|
'runUuid',
|
|
26
26
|
'artifactUuid',
|
|
27
27
|
'versionUuid',
|
|
28
|
+
'versionUuidA',
|
|
29
|
+
'versionUuidB',
|
|
28
30
|
'mcpServerUuid',
|
|
29
31
|
'toolCallId',
|
|
30
32
|
'fingerprint',
|
|
@@ -35,15 +37,31 @@ export const RESOURCE_ID_KEYS = new Set([
|
|
|
35
37
|
'spaceUuid',
|
|
36
38
|
'spaceUuids',
|
|
37
39
|
'parentSpaceUuid',
|
|
40
|
+
'targetSpaceUuid',
|
|
41
|
+
'itemUuids',
|
|
38
42
|
'roleUuid',
|
|
39
43
|
'dashboardUuid',
|
|
44
|
+
'dashboardUuidOrSlug',
|
|
45
|
+
'sourceDashboardUuid',
|
|
40
46
|
'schedulerUuid',
|
|
41
47
|
'organizationUuid',
|
|
42
48
|
'chartUuid',
|
|
49
|
+
'chartUuidOrSlug',
|
|
50
|
+
'sourceChartUuidOrSlug',
|
|
51
|
+
'contentUuidOrSlug',
|
|
52
|
+
'tileUuid',
|
|
53
|
+
'newSlug',
|
|
43
54
|
]);
|
|
44
55
|
|
|
45
56
|
/** Keys that accept OpenAPI UuidOrSlug (UUID or slug), not UUID-only. */
|
|
46
|
-
const UUID_OR_SLUG_KEYS = new Set([
|
|
57
|
+
const UUID_OR_SLUG_KEYS = new Set([
|
|
58
|
+
'dashboardUuid',
|
|
59
|
+
'dashboardUuidOrSlug',
|
|
60
|
+
'chartUuid',
|
|
61
|
+
'chartUuidOrSlug',
|
|
62
|
+
'sourceChartUuidOrSlug',
|
|
63
|
+
'contentUuidOrSlug',
|
|
64
|
+
]);
|
|
47
65
|
|
|
48
66
|
export type ArgumentSource = 'body' | 'option' | 'positional';
|
|
49
67
|
|
|
@@ -153,7 +171,7 @@ function validateBySemanticType(
|
|
|
153
171
|
}
|
|
154
172
|
|
|
155
173
|
function validateResourceIdValue(key: string, value: string): void {
|
|
156
|
-
if (key === 'slug') {
|
|
174
|
+
if (key === 'slug' || key === 'newSlug') {
|
|
157
175
|
validateSlug(value);
|
|
158
176
|
return;
|
|
159
177
|
}
|
package/src/audit.ts
CHANGED
|
@@ -13,7 +13,18 @@
|
|
|
13
13
|
import { randomUUID } from 'node:crypto';
|
|
14
14
|
import { createWriteStream, type WriteStream } from 'node:fs';
|
|
15
15
|
|
|
16
|
-
export type AuditStatus =
|
|
16
|
+
export type AuditStatus =
|
|
17
|
+
| 'blocked'
|
|
18
|
+
| 'confirmation_cancelled'
|
|
19
|
+
| 'confirmation_declined'
|
|
20
|
+
| 'confirmation_requested'
|
|
21
|
+
| 'deletion_failed'
|
|
22
|
+
| 'deletion_succeeded'
|
|
23
|
+
| 'error'
|
|
24
|
+
| 'promotion_failed'
|
|
25
|
+
| 'promotion_succeeded'
|
|
26
|
+
| 'resource_changed'
|
|
27
|
+
| 'success';
|
|
17
28
|
|
|
18
29
|
export type AuditLogEntry = {
|
|
19
30
|
timestamp: string;
|
package/src/index.ts
CHANGED
|
@@ -11,13 +11,13 @@ export * from './safety';
|
|
|
11
11
|
// Export input validation
|
|
12
12
|
export * from './input-validation';
|
|
13
13
|
|
|
14
|
-
// Export argument / descriptor validation
|
|
14
|
+
// Export argument / descriptor validation
|
|
15
15
|
export * from './argument-validation';
|
|
16
16
|
|
|
17
|
-
// Export shared typed operation
|
|
17
|
+
// Export shared typed operation catalog (ADR-0013)
|
|
18
18
|
export * from './operations';
|
|
19
19
|
|
|
20
|
-
// Export AgentOps bundle and gate types
|
|
20
|
+
// Export AgentOps bundle and gate types
|
|
21
21
|
export * from './agentops/types';
|
|
22
22
|
export * from './agentops/snapshots';
|
|
23
23
|
export * from './agentops/formatters';
|
|
@@ -29,9 +29,5 @@ export {
|
|
|
29
29
|
// Export audit logger (shared by MCP and CLI)
|
|
30
30
|
export * from './audit';
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
export * from './types
|
|
34
|
-
export { CONTENT_SORT_BY_COLUMNS } from './types/v2/content';
|
|
35
|
-
|
|
36
|
-
// Export raw OpenAPI types for direct use (e.g., by client package)
|
|
37
|
-
export type { paths, components, operations } from './types/generated/openapi-types';
|
|
32
|
+
// Curated Lightdash API types + generated OpenAPI shapes (single public path)
|
|
33
|
+
export * from './types';
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent-safe surface policy helpers (ADR-0004).
|
|
2
|
+
* Agent-safe surface policy helpers (ADR-0004 / ADR-0013).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
/** MCP tool names that must never be registered, derived from client-only registry entries. */
|
|
8
|
-
export function listBannedMcpToolNames(): readonly string[] {
|
|
9
|
-
return listOperations()
|
|
10
|
-
.filter(
|
|
11
|
-
(operation) =>
|
|
12
|
-
operation.agentExposure === 'client-only' && operation.mcp.toolName.trim().length > 0,
|
|
13
|
-
)
|
|
14
|
-
.map((operation) => operation.mcp.toolName);
|
|
15
|
-
}
|
|
5
|
+
import { listBannedMcpToolNames } from './registry';
|
|
16
6
|
|
|
17
7
|
/** Banned MCP tool names (without `lightdash_` prefix) for regression tests. */
|
|
18
8
|
export const IRRECOVERABLE_TOOL_DENYLIST = listBannedMcpToolNames();
|