@lightdash-tools/common 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/argument-validation.js +20 -2
- package/dist/argument-validation.test.js +22 -0
- package/dist/audit.d.ts +29 -9
- package/dist/audit.js +53 -9
- package/dist/audit.test.js +51 -24
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- 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 +118 -30
- package/dist/operations/cli-content.d.ts +5 -0
- package/dist/operations/cli-content.js +71 -0
- package/dist/operations/client-coverage.d.ts +119 -0
- package/dist/operations/client-coverage.js +137 -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 +471 -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 +197 -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 +39 -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 +64 -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 +8 -2
- package/dist/safety.js +22 -4
- package/dist/safety.test.js +29 -6
- 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.test.ts +70 -30
- package/src/audit.ts +88 -12
- package/src/env.ts +1 -1
- package/src/index.ts +5 -9
- package/src/operations/agent-safe.ts +2 -12
- package/src/operations/ai-agents.ts +123 -31
- package/src/operations/cli-content.ts +79 -0
- package/src/operations/client-coverage.test.ts +23 -0
- package/src/operations/client-coverage.ts +153 -0
- package/src/operations/content-developer.ts +501 -0
- package/src/operations/content-governance.ts +110 -0
- package/src/operations/content-reader.ts +212 -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 +41 -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 +112 -47
- package/src/operations/users.ts +9 -11
- package/src/safety.test.ts +32 -6
- package/src/safety.ts +26 -4
- package/src/types/index.ts +13 -0
package/src/operations/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared typed operation
|
|
2
|
+
* Shared typed operation catalog (ADR-0013).
|
|
3
3
|
* Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -17,7 +17,22 @@ export type HttpMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
|
17
17
|
* Capability profiles group operations for selective exposure (CLI profiles, MCP subsets).
|
|
18
18
|
*/
|
|
19
19
|
export type CapabilityProfile =
|
|
20
|
-
|
|
20
|
+
| 'ai-agent-ops'
|
|
21
|
+
| 'content-developer'
|
|
22
|
+
| 'content-governance'
|
|
23
|
+
| 'content-reader'
|
|
24
|
+
| 'conversations'
|
|
25
|
+
| 'core-lifecycle'
|
|
26
|
+
| 'discovery-readonly'
|
|
27
|
+
| 'evaluations'
|
|
28
|
+
| 'org-audit-readonly'
|
|
29
|
+
| 'semantic-discovery';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* MCP response sensitivity class (ADR-0011).
|
|
33
|
+
* Documents which redaction class handlers must apply; does not auto-redact.
|
|
34
|
+
*/
|
|
35
|
+
export type SensitivityClass = 'none' | 'pii.email' | 'secret.connection' | 'secret.destination';
|
|
21
36
|
|
|
22
37
|
/** MCP task semantics for an operation. */
|
|
23
38
|
export type McpTaskSupport = {
|
|
@@ -36,7 +51,7 @@ export type OperationAuthorization = {
|
|
|
36
51
|
|
|
37
52
|
export type OperationHttp = {
|
|
38
53
|
method: HttpMethod;
|
|
39
|
-
/** OpenAPI-style path template (includes `/api/v1` prefix). */
|
|
54
|
+
/** OpenAPI-style path template (includes `/api/v1` or `/api/v2` prefix). */
|
|
40
55
|
path: string;
|
|
41
56
|
};
|
|
42
57
|
|
|
@@ -65,20 +80,51 @@ export type OperationDescriptor = {
|
|
|
65
80
|
summary: string;
|
|
66
81
|
http: OperationHttp;
|
|
67
82
|
authorization: OperationAuthorization;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Response sensitivity class for agent surfaces (ADR-0011).
|
|
85
|
+
* Defaults to `none` when omitted from `defineOperation` input.
|
|
86
|
+
*/
|
|
87
|
+
sensitivity: SensitivityClass;
|
|
72
88
|
profiles: readonly CapabilityProfile[];
|
|
89
|
+
/** `agent` (default) = may appear on MCP and/or CLI; `client-only` = typed client only. */
|
|
90
|
+
agentExposure: AgentExposure;
|
|
91
|
+
/** Present when the operation is registered (or reserved) as an MCP tool. */
|
|
92
|
+
mcp?: OperationMcp;
|
|
93
|
+
/** Present when a real CLI command exists (`commandPath` must match Commander). */
|
|
94
|
+
cli?: OperationCli;
|
|
95
|
+
/** Irrecoverable denylist name for client-only ops (sans `lightdash_` prefix). */
|
|
96
|
+
bannedMcpToolName?: string;
|
|
73
97
|
/** When set, documents the ordered client-side HTTP steps behind this operation. */
|
|
74
98
|
workflow?: readonly OperationWorkflowStep[];
|
|
75
99
|
};
|
|
76
100
|
|
|
101
|
+
/** Input to `defineOperation` before defaults are applied. */
|
|
102
|
+
export type OperationDefinitionInput = Omit<
|
|
103
|
+
OperationDescriptor,
|
|
104
|
+
'agentExposure' | 'sensitivity'
|
|
105
|
+
> & {
|
|
106
|
+
agentExposure?: AgentExposure;
|
|
107
|
+
sensitivity?: SensitivityClass;
|
|
108
|
+
};
|
|
109
|
+
|
|
77
110
|
const VALID_PROFILES = new Set<CapabilityProfile>([
|
|
111
|
+
'ai-agent-ops',
|
|
112
|
+
'content-developer',
|
|
113
|
+
'content-governance',
|
|
114
|
+
'content-reader',
|
|
78
115
|
'conversations',
|
|
79
116
|
'core-lifecycle',
|
|
80
117
|
'discovery-readonly',
|
|
81
118
|
'evaluations',
|
|
119
|
+
'org-audit-readonly',
|
|
120
|
+
'semantic-discovery',
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
const VALID_SENSITIVITY = new Set<SensitivityClass>([
|
|
124
|
+
'none',
|
|
125
|
+
'pii.email',
|
|
126
|
+
'secret.connection',
|
|
127
|
+
'secret.destination',
|
|
82
128
|
]);
|
|
83
129
|
|
|
84
130
|
function assertNonEmpty(value: string, field: string): void {
|
|
@@ -105,11 +151,6 @@ function validateIdempotentHint(
|
|
|
105
151
|
impact: SafetyImpact,
|
|
106
152
|
id: string,
|
|
107
153
|
): void {
|
|
108
|
-
if (impact === 'read' && annotations.idempotentHint !== true) {
|
|
109
|
-
throw new Error(
|
|
110
|
-
`Operation '${id}': read operations must set mcp.annotations.idempotentHint = true`,
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
154
|
if (impact === 'write-destructive' && annotations.idempotentHint === true) {
|
|
114
155
|
throw new Error(
|
|
115
156
|
`Operation '${id}': destructive operations must not set mcp.annotations.idempotentHint = true`,
|
|
@@ -117,52 +158,76 @@ function validateIdempotentHint(
|
|
|
117
158
|
}
|
|
118
159
|
}
|
|
119
160
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
assertNonEmpty(descriptor.summary, 'summary');
|
|
129
|
-
assertNonEmpty(descriptor.http.path, 'http.path');
|
|
130
|
-
|
|
131
|
-
const agentExposure = descriptor.agentExposure ?? 'agent';
|
|
132
|
-
|
|
133
|
-
if (agentExposure === 'agent') {
|
|
134
|
-
assertNonEmpty(descriptor.mcp.toolName, 'mcp.toolName');
|
|
135
|
-
assertNonEmpty(descriptor.cli.commandPath, 'cli.commandPath');
|
|
161
|
+
function validateProfiles(id: string, profiles: readonly CapabilityProfile[]): void {
|
|
162
|
+
if (profiles.length === 0) {
|
|
163
|
+
throw new Error(`Operation '${id}' must declare at least one capability profile`);
|
|
164
|
+
}
|
|
165
|
+
for (const profile of profiles) {
|
|
166
|
+
if (!VALID_PROFILES.has(profile)) {
|
|
167
|
+
throw new Error(`Operation '${id}' has unknown capability profile '${profile}'`);
|
|
168
|
+
}
|
|
136
169
|
}
|
|
170
|
+
}
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
function validateClientOnlyOperation(input: OperationDefinitionInput): OperationDescriptor {
|
|
173
|
+
if (input.mcp !== undefined || input.cli !== undefined) {
|
|
139
174
|
throw new Error(
|
|
140
|
-
`Operation '${
|
|
175
|
+
`Operation '${input.id}': client-only operations must omit mcp and cli metadata`,
|
|
141
176
|
);
|
|
142
177
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
throw new Error(`Operation '${descriptor.id}' must declare at least one capability profile`);
|
|
178
|
+
if (input.bannedMcpToolName !== undefined && input.bannedMcpToolName.trim().length === 0) {
|
|
179
|
+
throw new Error(`Operation '${input.id}': bannedMcpToolName must be non-empty when set`);
|
|
146
180
|
}
|
|
181
|
+
return {
|
|
182
|
+
...input,
|
|
183
|
+
agentExposure: 'client-only',
|
|
184
|
+
sensitivity: input.sensitivity ?? 'none',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
147
187
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
188
|
+
function validateAgentMcp(input: OperationDefinitionInput): void {
|
|
189
|
+
if (input.mcp === undefined) {
|
|
190
|
+
return;
|
|
152
191
|
}
|
|
153
|
-
|
|
154
|
-
const expectedImpact = expectedImpactFromAnnotations(
|
|
155
|
-
if (
|
|
192
|
+
assertNonEmpty(input.mcp.toolName, 'mcp.toolName');
|
|
193
|
+
const expectedImpact = expectedImpactFromAnnotations(input.mcp.annotations);
|
|
194
|
+
if (input.authorization.safetyImpact !== expectedImpact) {
|
|
156
195
|
throw new Error(
|
|
157
|
-
`Operation '${
|
|
196
|
+
`Operation '${input.id}': authorization.safetyImpact is '${input.authorization.safetyImpact}' but MCP annotations imply '${expectedImpact}'`,
|
|
158
197
|
);
|
|
159
198
|
}
|
|
199
|
+
validateIdempotentHint(input.mcp.annotations, input.authorization.safetyImpact, input.id);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Defines a typed operation descriptor with catalog consistency checks (ADR-0013).
|
|
204
|
+
* Agent ops require at least one of `mcp` or `cli`. Client-only ops omit both.
|
|
205
|
+
*/
|
|
206
|
+
export function defineOperation(input: OperationDefinitionInput): OperationDescriptor {
|
|
207
|
+
assertNonEmpty(input.id, 'id');
|
|
208
|
+
assertNonEmpty(input.summary, 'summary');
|
|
209
|
+
assertNonEmpty(input.http.path, 'http.path');
|
|
210
|
+
|
|
211
|
+
const sensitivity = input.sensitivity ?? 'none';
|
|
212
|
+
if (!VALID_SENSITIVITY.has(sensitivity)) {
|
|
213
|
+
throw new Error(`Operation '${input.id}' has unknown sensitivity '${String(sensitivity)}'`);
|
|
214
|
+
}
|
|
160
215
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
216
|
+
validateProfiles(input.id, input.profiles);
|
|
217
|
+
|
|
218
|
+
const agentExposure = input.agentExposure ?? 'agent';
|
|
219
|
+
if (agentExposure === 'client-only') {
|
|
220
|
+
return validateClientOnlyOperation({ ...input, sensitivity });
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (input.mcp === undefined && input.cli === undefined) {
|
|
224
|
+
throw new Error(`Operation '${input.id}': agent operations require mcp and/or cli metadata`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
validateAgentMcp(input);
|
|
228
|
+
if (input.cli !== undefined) {
|
|
229
|
+
assertNonEmpty(input.cli.commandPath, 'cli.commandPath');
|
|
230
|
+
}
|
|
166
231
|
|
|
167
|
-
return { ...
|
|
232
|
+
return { ...input, agentExposure: 'agent', sensitivity };
|
|
168
233
|
}
|
package/src/operations/users.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Organization member operations in the shared operation
|
|
2
|
+
* Organization member operations in the shared operation catalog.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { READ_ONLY_DEFAULT
|
|
5
|
+
import { READ_ONLY_DEFAULT } from '../safety';
|
|
6
6
|
|
|
7
7
|
import { defineOperation } from './types';
|
|
8
8
|
|
|
@@ -21,10 +21,11 @@ const membersList = defineOperation({
|
|
|
21
21
|
summary: 'List organization members (one page)',
|
|
22
22
|
http: { method: 'GET', path: MEMBERS_PATH },
|
|
23
23
|
authorization: { safetyImpact: 'read' },
|
|
24
|
+
sensitivity: 'pii.email',
|
|
24
25
|
mcp: {
|
|
25
26
|
toolName: 'list_organization_members',
|
|
26
27
|
annotations: READ_ONLY_DEFAULT,
|
|
27
|
-
taskSupport: { exposed:
|
|
28
|
+
taskSupport: { exposed: false, taskEligible: false },
|
|
28
29
|
},
|
|
29
30
|
cli: { commandPath: 'users list' },
|
|
30
31
|
profiles: [PROFILE_DISCOVERY],
|
|
@@ -35,10 +36,11 @@ const membersGet = defineOperation({
|
|
|
35
36
|
summary: 'Get an organization member by UUID',
|
|
36
37
|
http: { method: 'GET', path: MEMBER_PATH },
|
|
37
38
|
authorization: { safetyImpact: 'read' },
|
|
39
|
+
sensitivity: 'pii.email',
|
|
38
40
|
mcp: {
|
|
39
41
|
toolName: 'get_member',
|
|
40
42
|
annotations: READ_ONLY_DEFAULT,
|
|
41
|
-
taskSupport: { exposed:
|
|
43
|
+
taskSupport: { exposed: false, taskEligible: false },
|
|
42
44
|
},
|
|
43
45
|
cli: { commandPath: 'users get' },
|
|
44
46
|
profiles: [PROFILE_DISCOVERY],
|
|
@@ -49,17 +51,13 @@ const membersDelete = defineOperation({
|
|
|
49
51
|
summary: 'Permanently remove a user from the organization (irrecoverable; client-only)',
|
|
50
52
|
http: { method: 'DELETE', path: DELETE_MEMBER_PATH },
|
|
51
53
|
authorization: { safetyImpact: 'write-destructive' },
|
|
52
|
-
|
|
53
|
-
toolName: 'delete_member',
|
|
54
|
-
annotations: WRITE_DESTRUCTIVE,
|
|
55
|
-
taskSupport: { exposed: false, taskEligible: false },
|
|
56
|
-
},
|
|
57
|
-
cli: { commandPath: '' },
|
|
54
|
+
sensitivity: 'none',
|
|
58
55
|
agentExposure: 'client-only',
|
|
56
|
+
bannedMcpToolName: 'delete_member',
|
|
59
57
|
profiles: [PROFILE_CORE_LIFECYCLE],
|
|
60
58
|
});
|
|
61
59
|
|
|
62
|
-
/** Organization member operations registered in the shared operation
|
|
60
|
+
/** Organization member operations registered in the shared operation catalog. */
|
|
63
61
|
export const USER_OPERATIONS: readonly OperationDescriptor[] = [
|
|
64
62
|
membersList,
|
|
65
63
|
membersGet,
|
package/src/safety.test.ts
CHANGED
|
@@ -213,36 +213,62 @@ describe('Safety Logic', () => {
|
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
describe('getAllowedProjectUuidsFromEnv', () => {
|
|
216
|
-
const originalEnv = process.env.
|
|
216
|
+
const originalEnv = process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS;
|
|
217
|
+
const originalLegacy = process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
217
218
|
|
|
218
219
|
afterEach(() => {
|
|
219
|
-
|
|
220
|
+
if (originalEnv === undefined) {
|
|
221
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS;
|
|
222
|
+
} else {
|
|
223
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = originalEnv;
|
|
224
|
+
}
|
|
225
|
+
if (originalLegacy === undefined) {
|
|
226
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
227
|
+
} else {
|
|
228
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS = originalLegacy;
|
|
229
|
+
}
|
|
220
230
|
});
|
|
221
231
|
|
|
222
232
|
it('should return empty array when env is not set', () => {
|
|
233
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS;
|
|
223
234
|
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
224
235
|
expect(getAllowedProjectUuidsFromEnv()).toEqual([]);
|
|
225
236
|
});
|
|
226
237
|
|
|
227
238
|
it('should parse a single UUID', () => {
|
|
228
|
-
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS
|
|
239
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
240
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = 'uuid-a';
|
|
229
241
|
expect(getAllowedProjectUuidsFromEnv()).toEqual(['uuid-a']);
|
|
230
242
|
});
|
|
231
243
|
|
|
232
244
|
it('should parse comma-separated UUIDs', () => {
|
|
233
|
-
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS
|
|
245
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
246
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = 'uuid-a,uuid-b,uuid-c';
|
|
234
247
|
expect(getAllowedProjectUuidsFromEnv()).toEqual(['uuid-a', 'uuid-b', 'uuid-c']);
|
|
235
248
|
});
|
|
236
249
|
|
|
237
250
|
it('should trim whitespace around UUIDs', () => {
|
|
238
|
-
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS
|
|
251
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
252
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = ' uuid-a , uuid-b ';
|
|
239
253
|
expect(getAllowedProjectUuidsFromEnv()).toEqual(['uuid-a', 'uuid-b']);
|
|
240
254
|
});
|
|
241
255
|
|
|
242
256
|
it('should filter out empty entries', () => {
|
|
243
|
-
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS
|
|
257
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
258
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = 'uuid-a,,uuid-b';
|
|
244
259
|
expect(getAllowedProjectUuidsFromEnv()).toEqual(['uuid-a', 'uuid-b']);
|
|
245
260
|
});
|
|
261
|
+
|
|
262
|
+
it('should reject removed LIGHTDASH_TOOLS_ALLOWED_PROJECTS', () => {
|
|
263
|
+
delete process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS;
|
|
264
|
+
process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS = 'uuid-a';
|
|
265
|
+
expect(() => getAllowedProjectUuidsFromEnv()).toThrow(
|
|
266
|
+
/LIGHTDASH_TOOLS_ALLOWED_PROJECTS is no longer supported/,
|
|
267
|
+
);
|
|
268
|
+
expect(() => getAllowedProjectUuidsFromEnv()).toThrow(
|
|
269
|
+
/LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS/,
|
|
270
|
+
);
|
|
271
|
+
});
|
|
246
272
|
});
|
|
247
273
|
|
|
248
274
|
describe('isProjectAllowed', () => {
|
package/src/safety.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { extractProjectUuidsFromToolArgs } from './agentops/extract-yaml-project';
|
|
2
|
-
import {
|
|
2
|
+
import { ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS, ENV_LIGHTDASH_TOOLS_SAFETY_MODE } from './env';
|
|
3
|
+
|
|
4
|
+
/** Removed allowlist env — fail closed if still set. */
|
|
5
|
+
const ENV_ALLOWED_PROJECTS_REMOVED = 'LIGHTDASH_TOOLS_ALLOWED_PROJECTS';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Semantic impact classification for operations (RFC Phase 0).
|
|
@@ -48,6 +51,17 @@ export const READ_ONLY_DEFAULT: ToolAnnotations = {
|
|
|
48
51
|
idempotentHint: true,
|
|
49
52
|
};
|
|
50
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Preset: read-only but non-idempotent (transient warehouse execution).
|
|
56
|
+
* Used by content-reader saved-chart/tile runs (ADR-0012).
|
|
57
|
+
*/
|
|
58
|
+
export const READ_ONLY_TRANSIENT: ToolAnnotations = {
|
|
59
|
+
readOnlyHint: true,
|
|
60
|
+
openWorldHint: false,
|
|
61
|
+
destructiveHint: false,
|
|
62
|
+
idempotentHint: false,
|
|
63
|
+
};
|
|
64
|
+
|
|
51
65
|
/**
|
|
52
66
|
* Legacy preset: write, non-destructive, idempotent (e.g. upsert by slug).
|
|
53
67
|
* Prefer {@link WRITE_NONDESTRUCTIVE} for new tools; idempotent behavior is not implied by safety mode.
|
|
@@ -139,14 +153,22 @@ export function getSafetyModeFromEnv(): SafetyMode {
|
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
/**
|
|
142
|
-
* Parses allowed project UUIDs from the
|
|
156
|
+
* Parses allowed project UUIDs from the LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS environment
|
|
143
157
|
* variable (comma-separated). Returns an empty array when the variable is unset, meaning
|
|
144
158
|
* all projects are allowed.
|
|
145
159
|
*
|
|
146
|
-
*
|
|
160
|
+
* Throws if the removed name LIGHTDASH_TOOLS_ALLOWED_PROJECTS is still set.
|
|
161
|
+
* Note: CLI `--projects` takes priority over this env var.
|
|
147
162
|
*/
|
|
148
163
|
export function getAllowedProjectUuidsFromEnv(): string[] {
|
|
149
|
-
const
|
|
164
|
+
const legacy = process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECTS;
|
|
165
|
+
if (legacy !== undefined && legacy.trim() !== '') {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`${ENV_ALLOWED_PROJECTS_REMOVED} is no longer supported. ` +
|
|
168
|
+
`Use ${ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS} instead.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const raw = process.env.LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS ?? '';
|
|
150
172
|
return raw
|
|
151
173
|
.split(',')
|
|
152
174
|
.map((s) => s.trim())
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
|
|
11
|
+
export * from './lightdash-api';
|
|
12
|
+
export { CONTENT_SORT_BY_COLUMNS } from './v2/content';
|
|
13
|
+
export type { components, operations, paths } from './generated/openapi-types';
|