@lightdash-tools/mcp 0.5.0 → 0.7.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.
Files changed (271) hide show
  1. package/README.md +133 -58
  2. package/dist/audit/audit.d.ts +5 -0
  3. package/dist/{audit.js → audit/audit.js} +1 -2
  4. package/dist/audit/tool-audit-context.d.ts +6 -0
  5. package/dist/audit/tool-audit-context.js +12 -0
  6. package/dist/audit/tool-audit-context.test.d.ts +1 -0
  7. package/dist/audit/tool-audit-context.test.js +19 -0
  8. package/dist/auth/auth-mode.d.ts +4 -0
  9. package/dist/auth/auth-mode.js +6 -0
  10. package/dist/auth/bearer.d.ts +3 -0
  11. package/dist/auth/bearer.js +13 -0
  12. package/dist/auth/lightdash-oauth-upstream-contract.d.ts +22 -0
  13. package/dist/auth/lightdash-oauth-upstream-contract.js +36 -0
  14. package/dist/auth/lightdash-oauth-upstream-contract.test.d.ts +1 -0
  15. package/dist/auth/lightdash-oauth-upstream-contract.test.js +56 -0
  16. package/dist/auth/oauth-broker/as-metadata.d.ts +14 -0
  17. package/dist/auth/oauth-broker/as-metadata.js +20 -0
  18. package/dist/auth/oauth-broker/lightdash-token.d.ts +20 -0
  19. package/dist/auth/oauth-broker/lightdash-token.js +76 -0
  20. package/dist/auth/oauth-broker/pending-store.d.ts +76 -0
  21. package/dist/auth/oauth-broker/pending-store.js +124 -0
  22. package/dist/auth/oauth-broker/pkce.d.ts +2 -0
  23. package/dist/auth/oauth-broker/pkce.js +17 -0
  24. package/dist/auth/oauth-broker/routes.d.ts +9 -0
  25. package/dist/auth/oauth-broker/routes.js +447 -0
  26. package/dist/auth/oauth-broker/routes.test.d.ts +1 -0
  27. package/dist/auth/oauth-broker/routes.test.js +237 -0
  28. package/dist/auth/providers/bearer-context-provider.d.ts +24 -0
  29. package/dist/auth/providers/bearer-context-provider.js +52 -0
  30. package/dist/auth/providers/env-context-provider.d.ts +13 -0
  31. package/dist/auth/providers/env-context-provider.js +19 -0
  32. package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +23 -0
  33. package/dist/auth/resource-server/lightdash-oauth-middleware.js +115 -0
  34. package/dist/auth/resource-server/lightdash-oauth-middleware.test.d.ts +1 -0
  35. package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +202 -0
  36. package/dist/auth/resource-server/lightdash-token-validation.d.ts +14 -0
  37. package/dist/auth/resource-server/lightdash-token-validation.js +82 -0
  38. package/dist/auth/resource-server/lightdash-token-validation.test.d.ts +1 -0
  39. package/dist/auth/resource-server/lightdash-token-validation.test.js +177 -0
  40. package/dist/auth/resource-server/oauth-protected-resource.d.ts +25 -0
  41. package/dist/auth/resource-server/oauth-protected-resource.js +67 -0
  42. package/dist/auth/resource-server/shared-key-middleware.d.ts +13 -0
  43. package/dist/auth/resource-server/shared-key-middleware.js +24 -0
  44. package/dist/auth/resource-server/token-scopes.d.ts +15 -0
  45. package/dist/auth/resource-server/token-scopes.js +76 -0
  46. package/dist/auth/resource-server/token-scopes.test.d.ts +1 -0
  47. package/dist/auth/resource-server/token-scopes.test.js +51 -0
  48. package/dist/auth/resource-server/token-validation-cache.d.ts +15 -0
  49. package/dist/auth/resource-server/token-validation-cache.js +44 -0
  50. package/dist/auth/resource-server/token-validation-cache.test.d.ts +1 -0
  51. package/dist/auth/resource-server/token-validation-cache.test.js +41 -0
  52. package/dist/auth/resource-server/token-validation-error.d.ts +6 -0
  53. package/dist/auth/resource-server/token-validation-error.js +13 -0
  54. package/dist/auth/resource-server/www-authenticate.d.ts +8 -0
  55. package/dist/auth/resource-server/www-authenticate.js +24 -0
  56. package/dist/auth/resource-server/www-authenticate.test.d.ts +1 -0
  57. package/dist/auth/resource-server/www-authenticate.test.js +64 -0
  58. package/dist/auth/token-hash.d.ts +2 -0
  59. package/dist/auth/token-hash.js +8 -0
  60. package/dist/bin.d.ts +0 -4
  61. package/dist/bin.js +41 -33
  62. package/dist/config/env.d.ts +50 -0
  63. package/dist/config/env.js +53 -0
  64. package/dist/config/load-mcp-config.d.ts +30 -0
  65. package/dist/config/load-mcp-config.js +282 -0
  66. package/dist/config/load-mcp-config.test.d.ts +1 -0
  67. package/dist/config/load-mcp-config.test.js +195 -0
  68. package/dist/config/normalize-url.d.ts +13 -0
  69. package/dist/config/normalize-url.js +52 -0
  70. package/dist/config/normalize-url.test.d.ts +1 -0
  71. package/dist/config/normalize-url.test.js +41 -0
  72. package/dist/config/public-url.d.ts +3 -0
  73. package/dist/config/public-url.js +10 -0
  74. package/dist/config/runtime.d.ts +15 -0
  75. package/dist/config/runtime.js +48 -0
  76. package/dist/config/runtime.test.d.ts +1 -0
  77. package/dist/config/runtime.test.js +69 -0
  78. package/dist/config/test-mcp-http-config.d.ts +3 -0
  79. package/dist/config/test-mcp-http-config.js +7 -0
  80. package/dist/governance/project-pin.d.ts +14 -0
  81. package/dist/governance/project-pin.js +44 -0
  82. package/dist/governance/project-pin.test.d.ts +1 -0
  83. package/dist/governance/project-pin.test.js +35 -0
  84. package/dist/http.d.ts +1 -2
  85. package/dist/http.integration.test.d.ts +1 -0
  86. package/dist/http.integration.test.js +688 -0
  87. package/dist/http.js +3 -170
  88. package/dist/http.test.d.ts +4 -0
  89. package/dist/http.test.js +131 -0
  90. package/dist/index.d.ts +2 -0
  91. package/dist/index.integration.test.js +73 -30
  92. package/dist/index.js +28 -27
  93. package/dist/index.test.js +3 -3
  94. package/dist/logging/structured.d.ts +27 -0
  95. package/dist/logging/structured.js +32 -0
  96. package/dist/logging/structured.test.d.ts +1 -0
  97. package/dist/logging/structured.test.js +33 -0
  98. package/dist/personas/index.d.ts +19 -0
  99. package/dist/personas/index.js +57 -0
  100. package/dist/personas/index.test.d.ts +1 -0
  101. package/dist/personas/index.test.js +58 -0
  102. package/dist/personas/organization-audit/v1/index.d.ts +8 -0
  103. package/dist/personas/organization-audit/v1/index.js +42 -0
  104. package/dist/personas/organization-audit/v1/prompts.d.ts +5 -0
  105. package/dist/personas/organization-audit/v1/prompts.js +111 -0
  106. package/dist/personas/organization-audit/v1/prompts.test.d.ts +4 -0
  107. package/dist/personas/organization-audit/v1/prompts.test.js +25 -0
  108. package/dist/personas/organization-audit/v1/resources/playbook.d.ts +11 -0
  109. package/dist/personas/organization-audit/v1/resources/playbook.js +40 -0
  110. package/dist/personas/organization-audit/v1/resources/playbook.md +52 -0
  111. package/dist/personas/semantic-layer/v1/index.d.ts +8 -0
  112. package/dist/personas/semantic-layer/v1/index.js +32 -0
  113. package/dist/personas/semantic-layer/v1/prompts.d.ts +5 -0
  114. package/dist/personas/semantic-layer/v1/prompts.js +107 -0
  115. package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +12 -0
  116. package/dist/personas/semantic-layer/v1/resources/playbook.js +42 -0
  117. package/dist/personas/semantic-layer/v1/resources/playbook.md +153 -0
  118. package/dist/personas/types.d.ts +19 -0
  119. package/dist/personas/types.js +5 -0
  120. package/dist/protocol-contract.test.d.ts +1 -0
  121. package/dist/protocol-contract.test.js +42 -0
  122. package/dist/server/capabilities.d.ts +15 -0
  123. package/dist/server/capabilities.js +19 -0
  124. package/dist/server/capabilities.test.d.ts +1 -0
  125. package/dist/server/capabilities.test.js +39 -0
  126. package/dist/server/errors.test.d.ts +1 -0
  127. package/dist/server/errors.test.js +53 -0
  128. package/dist/server/request-context.d.ts +13 -0
  129. package/dist/server/request-context.js +2 -0
  130. package/dist/server/server.d.ts +4 -0
  131. package/dist/server/server.js +17 -0
  132. package/dist/server/server.test.d.ts +1 -0
  133. package/dist/server/server.test.js +15 -0
  134. package/dist/server/version.d.ts +1 -0
  135. package/dist/server/version.js +7 -0
  136. package/dist/server/version.test.d.ts +1 -0
  137. package/dist/server/version.test.js +9 -0
  138. package/dist/stdio.process.test.d.ts +1 -0
  139. package/dist/stdio.process.test.js +126 -0
  140. package/dist/tools/index.d.ts +2 -4
  141. package/dist/tools/index.js +4 -30
  142. package/dist/tools/index.test.d.ts +1 -0
  143. package/dist/tools/index.test.js +72 -0
  144. package/dist/tools/lib/api-errors.d.ts +9 -0
  145. package/dist/tools/lib/api-errors.js +22 -0
  146. package/dist/tools/lib/api-shape.d.ts +16 -0
  147. package/dist/tools/lib/api-shape.js +47 -0
  148. package/dist/tools/lib/assert-safe.d.ts +13 -0
  149. package/dist/tools/lib/assert-safe.js +21 -0
  150. package/dist/tools/lib/assert-safe.test.d.ts +4 -0
  151. package/dist/tools/lib/assert-safe.test.js +32 -0
  152. package/dist/tools/lib/concurrency.d.ts +4 -0
  153. package/dist/tools/lib/concurrency.js +24 -0
  154. package/dist/tools/lib/contracts.d.ts +34 -0
  155. package/dist/tools/lib/contracts.js +30 -0
  156. package/dist/tools/lib/redaction.d.ts +107 -0
  157. package/dist/tools/lib/redaction.js +299 -0
  158. package/dist/tools/lib/redaction.test.d.ts +4 -0
  159. package/dist/tools/lib/redaction.test.js +216 -0
  160. package/dist/tools/lib/register-org-audit.d.ts +9 -0
  161. package/dist/tools/lib/register-org-audit.js +20 -0
  162. package/dist/tools/lib/schema-fields.d.ts +9 -0
  163. package/dist/tools/lib/schema-fields.js +19 -0
  164. package/dist/tools/organization/binding.d.ts +14 -0
  165. package/dist/tools/organization/binding.js +31 -0
  166. package/dist/tools/organization/invariants.test.d.ts +4 -0
  167. package/dist/tools/organization/invariants.test.js +28 -0
  168. package/dist/tools/organization/inventory.d.ts +10 -0
  169. package/dist/tools/organization/inventory.js +189 -0
  170. package/dist/tools/organization/roles.d.ts +10 -0
  171. package/dist/tools/organization/roles.js +213 -0
  172. package/dist/tools/project/content.d.ts +9 -0
  173. package/dist/tools/project/content.js +192 -0
  174. package/dist/tools/project/projects.d.ts +7 -0
  175. package/dist/tools/project/projects.js +42 -0
  176. package/dist/tools/project/projects.test.d.ts +1 -0
  177. package/dist/tools/project/projects.test.js +117 -0
  178. package/dist/tools/project/schedulers.d.ts +7 -0
  179. package/dist/tools/project/schedulers.js +115 -0
  180. package/dist/tools/registry.d.ts +104 -0
  181. package/dist/tools/registry.js +59 -0
  182. package/dist/tools/semantic/explore-helpers.d.ts +56 -0
  183. package/dist/tools/semantic/explore-helpers.js +115 -0
  184. package/dist/tools/semantic/explore-helpers.test.d.ts +1 -0
  185. package/dist/tools/semantic/explore-helpers.test.js +170 -0
  186. package/dist/tools/semantic/explores.d.ts +9 -0
  187. package/dist/tools/semantic/explores.js +80 -0
  188. package/dist/tools/semantic/metrics.d.ts +7 -0
  189. package/dist/tools/semantic/metrics.js +53 -0
  190. package/dist/tools/semantic/query.d.ts +6 -0
  191. package/dist/tools/semantic/query.js +42 -0
  192. package/dist/tools/semantic/schema-fields.d.ts +3 -0
  193. package/dist/tools/semantic/schema-fields.js +7 -0
  194. package/dist/tools/shared.d.ts +26 -13
  195. package/dist/tools/shared.js +112 -157
  196. package/dist/tools/shared.test.js +132 -183
  197. package/dist/tools/space/access.d.ts +66 -0
  198. package/dist/tools/space/access.js +322 -0
  199. package/dist/tools/space/access.test.d.ts +4 -0
  200. package/dist/tools/space/access.test.js +90 -0
  201. package/dist/transports/http-body.d.ts +5 -0
  202. package/dist/transports/http-body.js +50 -0
  203. package/dist/transports/http-request-utils.d.ts +2 -0
  204. package/dist/transports/http-request-utils.js +13 -0
  205. package/dist/transports/http-response.d.ts +6 -0
  206. package/dist/transports/http-response.js +56 -0
  207. package/dist/transports/session-store.d.ts +40 -0
  208. package/dist/transports/session-store.js +88 -0
  209. package/dist/transports/session-store.test.d.ts +1 -0
  210. package/dist/transports/session-store.test.js +111 -0
  211. package/dist/transports/streamable-http.d.ts +9 -0
  212. package/dist/transports/streamable-http.js +454 -0
  213. package/dist/transports/streamable-http.test.d.ts +1 -0
  214. package/dist/transports/streamable-http.test.js +95 -0
  215. package/package.json +25 -10
  216. package/dist/audit.d.ts +0 -6
  217. package/dist/config.d.ts +0 -47
  218. package/dist/config.js +0 -82
  219. package/dist/tools/ai-agents.d.ts +0 -6
  220. package/dist/tools/ai-agents.js +0 -388
  221. package/dist/tools/charts.d.ts +0 -6
  222. package/dist/tools/charts.js +0 -55
  223. package/dist/tools/content.d.ts +0 -6
  224. package/dist/tools/content.js +0 -37
  225. package/dist/tools/dashboards.d.ts +0 -6
  226. package/dist/tools/dashboards.js +0 -28
  227. package/dist/tools/explores.d.ts +0 -6
  228. package/dist/tools/explores.js +0 -65
  229. package/dist/tools/groups.d.ts +0 -6
  230. package/dist/tools/groups.js +0 -121
  231. package/dist/tools/metrics.d.ts +0 -6
  232. package/dist/tools/metrics.js +0 -45
  233. package/dist/tools/projects.d.ts +0 -6
  234. package/dist/tools/projects.js +0 -58
  235. package/dist/tools/query.d.ts +0 -6
  236. package/dist/tools/query.js +0 -34
  237. package/dist/tools/schedulers.d.ts +0 -6
  238. package/dist/tools/schedulers.js +0 -45
  239. package/dist/tools/spaces.d.ts +0 -6
  240. package/dist/tools/spaces.js +0 -128
  241. package/dist/tools/tags.d.ts +0 -6
  242. package/dist/tools/tags.js +0 -28
  243. package/dist/tools/users.d.ts +0 -6
  244. package/dist/tools/users.js +0 -50
  245. package/src/audit.ts +0 -6
  246. package/src/bin.ts +0 -58
  247. package/src/config.ts +0 -83
  248. package/src/errors.ts +0 -27
  249. package/src/http.ts +0 -187
  250. package/src/index.integration.test.ts +0 -57
  251. package/src/index.test.ts +0 -8
  252. package/src/index.ts +0 -31
  253. package/src/tools/ai-agents.ts +0 -759
  254. package/src/tools/charts.ts +0 -85
  255. package/src/tools/content.ts +0 -44
  256. package/src/tools/dashboards.ts +0 -25
  257. package/src/tools/explores.ts +0 -98
  258. package/src/tools/groups.ts +0 -180
  259. package/src/tools/index.ts +0 -35
  260. package/src/tools/metrics.ts +0 -42
  261. package/src/tools/projects.ts +0 -74
  262. package/src/tools/query.ts +0 -47
  263. package/src/tools/schedulers.ts +0 -42
  264. package/src/tools/shared.test.ts +0 -365
  265. package/src/tools/shared.ts +0 -274
  266. package/src/tools/spaces.ts +0 -217
  267. package/src/tools/tags.ts +0 -25
  268. package/src/tools/users.ts +0 -64
  269. package/tsconfig.json +0 -13
  270. /package/dist/{errors.d.ts → server/errors.d.ts} +0 -0
  271. /package/dist/{errors.js → server/errors.js} +0 -0
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /**
3
+ * Redaction helpers for MCP tool response sensitivity (ADR-0011).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING = exports.EMAIL_REDACTED_WARNING = exports.CREDENTIALS_OMITTED_WARNING = void 0;
7
+ exports.emailRedactionWarnings = emailRedactionWarnings;
8
+ exports.destinationRedactionWarnings = destinationRedactionWarnings;
9
+ exports.redactEmail = redactEmail;
10
+ exports.maybeRedactEmail = maybeRedactEmail;
11
+ exports.redactDestination = redactDestination;
12
+ exports.sanitizeSchedulerTarget = sanitizeSchedulerTarget;
13
+ exports.normalizeScheduler = normalizeScheduler;
14
+ exports.toProjectSummary = toProjectSummary;
15
+ exports.toProjectMemberAccessSummary = toProjectMemberAccessSummary;
16
+ exports.toOrgMemberSummary = toOrgMemberSummary;
17
+ exports.toGroupSummary = toGroupSummary;
18
+ exports.CREDENTIALS_OMITTED_WARNING = {
19
+ code: 'REDACTED',
20
+ message: 'Connection credentials and contact overrides omitted; not available via MCP (use client/CLI)',
21
+ };
22
+ exports.EMAIL_REDACTED_WARNING = {
23
+ code: 'REDACTED',
24
+ message: 'Email addresses redacted; pass includeEmail=true to reveal',
25
+ };
26
+ exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING = {
27
+ code: 'REDACTED',
28
+ message: 'Scheduler destinations redacted by default',
29
+ };
30
+ /** Warnings when emails are masked (empty when includeEmail is true). */
31
+ function emailRedactionWarnings(includeEmail) {
32
+ return includeEmail ? [] : [exports.EMAIL_REDACTED_WARNING];
33
+ }
34
+ /** Warnings when scheduler destinations are masked. */
35
+ function destinationRedactionWarnings(revealDestinations) {
36
+ return revealDestinations ? [] : [exports.SCHEDULER_DESTINATIONS_REDACTED_WARNING];
37
+ }
38
+ const SENSITIVE_TARGET_KEYS = new Set([
39
+ 'recipient',
40
+ 'channel',
41
+ 'email',
42
+ 'value',
43
+ 'webhook',
44
+ 'googleChatWebhook',
45
+ 'slackChannelName',
46
+ 'slackChannelId',
47
+ ]);
48
+ function splitEmail(email) {
49
+ const at = email.lastIndexOf('@');
50
+ if (at <= 0 || at === email.length - 1)
51
+ return undefined;
52
+ return { local: email.slice(0, at), domain: email.slice(at + 1).toLowerCase() };
53
+ }
54
+ /** Redact an email to `a***@domain` form. */
55
+ function redactEmail(email, allowedDomains) {
56
+ const parts = splitEmail(email);
57
+ if (!parts) {
58
+ return { email: '***', domain: 'unknown', isExternalDomain: true };
59
+ }
60
+ const local = parts.local;
61
+ const maskedLocal = local.length <= 1 ? '*' : `${local[0]}***`;
62
+ const allowed = new Set((allowedDomains !== null && allowedDomains !== void 0 ? allowedDomains : []).map((d) => d.toLowerCase()));
63
+ const isExternalDomain = allowed.size > 0 ? !allowed.has(parts.domain) : false;
64
+ return {
65
+ email: `${maskedLocal}@${parts.domain}`,
66
+ domain: parts.domain,
67
+ isExternalDomain,
68
+ };
69
+ }
70
+ /** Optionally keep full email when includeEmail is true. */
71
+ function maybeRedactEmail(email, includeEmail, allowedDomains) {
72
+ if (email == null || email === '')
73
+ return undefined;
74
+ if (includeEmail)
75
+ return email;
76
+ return redactEmail(email, allowedDomains);
77
+ }
78
+ const DESTINATION_FIELDS = [
79
+ { key: 'webhook', destinationType: 'ms_teams_webhook' },
80
+ { key: 'googleChatWebhook', destinationType: 'google_chat_webhook' },
81
+ {
82
+ key: 'channel',
83
+ destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'slack_channel'); },
84
+ },
85
+ {
86
+ key: 'recipient',
87
+ destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'email'); },
88
+ },
89
+ { key: 'email', destinationType: 'email' },
90
+ {
91
+ key: 'value',
92
+ destinationType: (target) => { var _a; return String((_a = target.type) !== null && _a !== void 0 ? _a : 'unknown'); },
93
+ },
94
+ ];
95
+ function stringField(target, key) {
96
+ // eslint-disable-next-line security/detect-object-injection -- key from fixed DESTINATION_FIELDS
97
+ const value = target[key];
98
+ return typeof value === 'string' && value ? value : undefined;
99
+ }
100
+ function extractRawDestination(target) {
101
+ var _a;
102
+ for (const field of DESTINATION_FIELDS) {
103
+ const raw = stringField(target, field.key);
104
+ if (!raw)
105
+ continue;
106
+ const destinationType = typeof field.destinationType === 'function'
107
+ ? field.destinationType(target)
108
+ : field.destinationType;
109
+ return { destinationType, raw };
110
+ }
111
+ return { destinationType: String((_a = target.type) !== null && _a !== void 0 ? _a : 'unknown'), raw: '' };
112
+ }
113
+ /** Redact a scheduler destination string (email, slack, or webhook URL). */
114
+ function redactDestination(destinationType, raw, allowedDomains) {
115
+ if (destinationType === 'email' || raw.includes('@')) {
116
+ const redacted = redactEmail(raw, allowedDomains);
117
+ return {
118
+ destinationType: destinationType || 'email',
119
+ redactedDestination: redacted.email,
120
+ domain: redacted.domain,
121
+ isExternalDomain: redacted.isExternalDomain,
122
+ };
123
+ }
124
+ if (raw.startsWith('http://') || raw.startsWith('https://')) {
125
+ try {
126
+ const url = new URL(raw);
127
+ return {
128
+ destinationType,
129
+ redactedDestination: `${url.protocol}//${url.host}/***`,
130
+ domain: url.host,
131
+ isExternalDomain: true,
132
+ };
133
+ }
134
+ catch (_a) {
135
+ // fall through
136
+ }
137
+ }
138
+ const visible = raw.length <= 4 ? '****' : `${raw.slice(0, 2)}***${raw.slice(-2)}`;
139
+ return {
140
+ destinationType,
141
+ redactedDestination: visible,
142
+ };
143
+ }
144
+ /** Strip sensitive destination fields from a scheduler target; never spread raw secrets. */
145
+ function sanitizeSchedulerTarget(target, revealDestinations, allowedEmailDomains) {
146
+ var _a;
147
+ const { destinationType, raw } = extractRawDestination(target);
148
+ const safe = { type: (_a = target.type) !== null && _a !== void 0 ? _a : destinationType };
149
+ if (typeof target.schedulerUuid === 'string')
150
+ safe.schedulerUuid = target.schedulerUuid;
151
+ if (typeof target.schedulerTargetUuid === 'string') {
152
+ safe.schedulerTargetUuid = target.schedulerTargetUuid;
153
+ }
154
+ if (revealDestinations) {
155
+ for (const key of SENSITIVE_TARGET_KEYS) {
156
+ // eslint-disable-next-line security/detect-object-injection -- fixed allowlist set
157
+ if (key in target)
158
+ safe[key] = target[key];
159
+ }
160
+ return safe;
161
+ }
162
+ if (!raw) {
163
+ return Object.assign(Object.assign({}, safe), { destinationType, redactedDestination: '***' });
164
+ }
165
+ return Object.assign(Object.assign({}, safe), redactDestination(destinationType, raw, allowedEmailDomains));
166
+ }
167
+ /** Normalize scheduler metadata with destination redaction by default. */
168
+ function normalizeScheduler(raw, revealDestinations, allowedEmailDomains) {
169
+ var _a, _b;
170
+ const targets = Array.isArray(raw.targets) ? raw.targets : [];
171
+ const normalizedTargets = targets.map((t) => {
172
+ if (!t || typeof t !== 'object')
173
+ return t;
174
+ return sanitizeSchedulerTarget(t, revealDestinations, allowedEmailDomains);
175
+ });
176
+ return {
177
+ schedulerUuid: (_a = raw.schedulerUuid) !== null && _a !== void 0 ? _a : raw.uuid,
178
+ name: raw.name,
179
+ enabled: raw.enabled,
180
+ cron: raw.cron,
181
+ format: raw.format,
182
+ createdBy: raw.createdBy,
183
+ createdByUserUuid: (_b = raw.createdByUserUuid) !== null && _b !== void 0 ? _b : (typeof raw.createdBy === 'string' ? raw.createdBy : undefined),
184
+ savedChartUuid: raw.savedChartUuid,
185
+ dashboardUuid: raw.dashboardUuid,
186
+ latestRun: sanitizeLatestRun(raw.latestRun),
187
+ targets: normalizedTargets,
188
+ };
189
+ }
190
+ /** Strip PII / opaque details from scheduler latestRun payloads. */
191
+ function sanitizeLatestRun(latestRun) {
192
+ if (!latestRun || typeof latestRun !== 'object')
193
+ return undefined;
194
+ const run = latestRun;
195
+ return {
196
+ runId: run.runId,
197
+ schedulerUuid: run.schedulerUuid,
198
+ runStatus: run.runStatus,
199
+ status: run.status,
200
+ scheduledTime: run.scheduledTime,
201
+ createdAt: run.createdAt,
202
+ createdByUserUuid: run.createdByUserUuid,
203
+ resourceType: run.resourceType,
204
+ resourceUuid: run.resourceUuid,
205
+ format: run.format,
206
+ };
207
+ }
208
+ function readString(record, key) {
209
+ // eslint-disable-next-line security/detect-object-injection -- fixed allowlist keys at call sites
210
+ const value = record[key];
211
+ return typeof value === 'string' ? value : undefined;
212
+ }
213
+ function readStringOrNull(record, key) {
214
+ // eslint-disable-next-line security/detect-object-injection -- fixed allowlist keys at call sites
215
+ const value = record[key];
216
+ if (value === null)
217
+ return null;
218
+ return typeof value === 'string' ? value : undefined;
219
+ }
220
+ function asEntityRecord(value) {
221
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
222
+ return value;
223
+ }
224
+ return {};
225
+ }
226
+ function warehouseTypeFrom(record) {
227
+ const direct = readString(record, 'warehouseType');
228
+ if (direct !== undefined)
229
+ return direct;
230
+ return readString(asEntityRecord(record.warehouseConnection), 'type');
231
+ }
232
+ /**
233
+ * Shape project / organization-project payloads to metadata only.
234
+ * Never returns warehouseConnection, dbtConnection, or schedulerFailureContactOverride.
235
+ */
236
+ function toProjectSummary(project) {
237
+ var _a, _b;
238
+ const record = asEntityRecord(project);
239
+ const type = readString(record, 'type');
240
+ const organizationUuid = readString(record, 'organizationUuid');
241
+ const upstreamProjectUuid = readStringOrNull(record, 'upstreamProjectUuid');
242
+ const createdByUserUuid = readStringOrNull(record, 'createdByUserUuid');
243
+ const createdAt = readString(record, 'createdAt');
244
+ const warehouseType = warehouseTypeFrom(record);
245
+ const provisioningSource = readStringOrNull(record, 'provisioningSource');
246
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ projectUuid: (_a = readString(record, 'projectUuid')) !== null && _a !== void 0 ? _a : '', name: (_b = readString(record, 'name')) !== null && _b !== void 0 ? _b : '' }, (type !== undefined ? { type } : {})), (organizationUuid !== undefined ? { organizationUuid } : {})), (upstreamProjectUuid !== undefined ? { upstreamProjectUuid } : {})), (createdByUserUuid !== undefined ? { createdByUserUuid } : {})), (createdAt !== undefined ? { createdAt } : {})), (warehouseType !== undefined ? { warehouseType } : {})), (provisioningSource !== undefined ? { provisioningSource } : {}));
247
+ }
248
+ /** Map a project member profile with default email redaction. */
249
+ function toProjectMemberAccessSummary(member, includeEmail, allowedEmailDomains) {
250
+ var _a, _b, _c, _d, _e;
251
+ const record = asEntityRecord(member);
252
+ const roleUuid = readString(record, 'roleUuid');
253
+ return Object.assign({ userUuid: (_a = readString(record, 'userUuid')) !== null && _a !== void 0 ? _a : '', projectUuid: (_b = readString(record, 'projectUuid')) !== null && _b !== void 0 ? _b : '', firstName: (_c = readString(record, 'firstName')) !== null && _c !== void 0 ? _c : '', lastName: (_d = readString(record, 'lastName')) !== null && _d !== void 0 ? _d : '', role: (_e = readString(record, 'role')) !== null && _e !== void 0 ? _e : '', email: maybeRedactEmail(readString(record, 'email'), includeEmail, allowedEmailDomains) }, (roleUuid !== undefined ? { roleUuid } : {}));
254
+ }
255
+ /** Map an organization member with default email redaction. */
256
+ function toOrgMemberSummary(member, includeEmail, allowedEmailDomains) {
257
+ var _a, _b, _c;
258
+ const record = asEntityRecord(member);
259
+ return {
260
+ userUuid: (_a = readString(record, 'userUuid')) !== null && _a !== void 0 ? _a : '',
261
+ organizationUuid: readString(record, 'organizationUuid'),
262
+ firstName: (_b = readString(record, 'firstName')) !== null && _b !== void 0 ? _b : '',
263
+ lastName: (_c = readString(record, 'lastName')) !== null && _c !== void 0 ? _c : '',
264
+ email: maybeRedactEmail(readString(record, 'email'), includeEmail, allowedEmailDomains),
265
+ isActive: typeof record.isActive === 'boolean' ? record.isActive : undefined,
266
+ isInviteExpired: typeof record.isInviteExpired === 'boolean' ? record.isInviteExpired : undefined,
267
+ role: readString(record, 'role'),
268
+ roleUuid: readString(record, 'roleUuid'),
269
+ };
270
+ }
271
+ /** Allowlist group metadata; redact member emails when members are present. */
272
+ function toGroupSummary(group, includeEmail, allowedEmailDomains) {
273
+ var _a, _b;
274
+ const record = asEntityRecord(group);
275
+ const summary = {
276
+ uuid: (_a = readString(record, 'uuid')) !== null && _a !== void 0 ? _a : '',
277
+ name: (_b = readString(record, 'name')) !== null && _b !== void 0 ? _b : '',
278
+ organizationUuid: readString(record, 'organizationUuid'),
279
+ createdAt: readString(record, 'createdAt'),
280
+ updatedAt: readString(record, 'updatedAt'),
281
+ createdByUserUuid: readStringOrNull(record, 'createdByUserUuid'),
282
+ };
283
+ if (Array.isArray(record.memberUuids)) {
284
+ summary.memberUuids = record.memberUuids.filter((u) => typeof u === 'string');
285
+ }
286
+ if (Array.isArray(record.members)) {
287
+ summary.members = record.members.map((m) => {
288
+ var _a, _b, _c;
289
+ const member = asEntityRecord(m);
290
+ return {
291
+ userUuid: (_a = readString(member, 'userUuid')) !== null && _a !== void 0 ? _a : '',
292
+ firstName: (_b = readString(member, 'firstName')) !== null && _b !== void 0 ? _b : '',
293
+ lastName: (_c = readString(member, 'lastName')) !== null && _c !== void 0 ? _c : '',
294
+ email: maybeRedactEmail(readString(member, 'email'), includeEmail, allowedEmailDomains),
295
+ };
296
+ });
297
+ }
298
+ return summary;
299
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Redaction unit tests.
3
+ */
4
+ export {};
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ /**
3
+ * Redaction unit tests.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const vitest_1 = require("vitest");
7
+ const redaction_js_1 = require("./redaction.js");
8
+ (0, vitest_1.describe)('organization-audit redaction', () => {
9
+ (0, vitest_1.it)('redacts email local-part', () => {
10
+ (0, vitest_1.expect)((0, redaction_js_1.redactEmail)('alice@example.com')).toEqual({
11
+ email: 'a***@example.com',
12
+ domain: 'example.com',
13
+ isExternalDomain: false,
14
+ });
15
+ });
16
+ (0, vitest_1.it)('marks external domains when allowlist provided', () => {
17
+ (0, vitest_1.expect)((0, redaction_js_1.redactEmail)('bob@evil.example', ['example.com']).isExternalDomain).toBe(true);
18
+ });
19
+ (0, vitest_1.it)('returns full email when includeEmail is true', () => {
20
+ (0, vitest_1.expect)((0, redaction_js_1.maybeRedactEmail)('alice@example.com', true)).toBe('alice@example.com');
21
+ });
22
+ (0, vitest_1.it)('redacts non-email destinations', () => {
23
+ const result = (0, redaction_js_1.redactDestination)('slack_channel', 'C0123456789');
24
+ (0, vitest_1.expect)(result.redactedDestination).toMatch(/^C0/);
25
+ (0, vitest_1.expect)(result.redactedDestination).not.toBe('C0123456789');
26
+ });
27
+ (0, vitest_1.it)('strips webhook secrets when revealDestinations is false', () => {
28
+ const sanitized = (0, redaction_js_1.sanitizeSchedulerTarget)({
29
+ type: 'ms_teams',
30
+ webhook: 'https://outlook.office.com/webhook/secret-token',
31
+ }, false);
32
+ (0, vitest_1.expect)(sanitized).not.toHaveProperty('webhook');
33
+ (0, vitest_1.expect)(String(sanitized.redactedDestination)).toContain('outlook.office.com');
34
+ (0, vitest_1.expect)(String(sanitized.redactedDestination)).not.toContain('secret-token');
35
+ });
36
+ (0, vitest_1.it)('does not spread raw google chat webhook URLs', () => {
37
+ const normalized = (0, redaction_js_1.normalizeScheduler)({
38
+ schedulerUuid: 's1',
39
+ targets: [
40
+ {
41
+ type: 'google_chat',
42
+ googleChatWebhook: 'https://chat.googleapis.com/v1/spaces/AAA/messages?key=secret',
43
+ },
44
+ ],
45
+ }, false);
46
+ const target = normalized.targets[0];
47
+ (0, vitest_1.expect)(target).not.toHaveProperty('googleChatWebhook');
48
+ (0, vitest_1.expect)(JSON.stringify(normalized)).not.toContain('secret');
49
+ });
50
+ (0, vitest_1.it)('strips latestRun PII and opaque details', () => {
51
+ const normalized = (0, redaction_js_1.normalizeScheduler)({
52
+ schedulerUuid: 's1',
53
+ targets: [],
54
+ latestRun: {
55
+ runId: 'r1',
56
+ createdByUserName: 'Alice Admin',
57
+ createdByUserUuid: 'u1',
58
+ details: { recipient: 'secret@evil.example' },
59
+ runStatus: 'completed',
60
+ },
61
+ }, false);
62
+ const latestRun = normalized.latestRun;
63
+ (0, vitest_1.expect)(latestRun).not.toHaveProperty('createdByUserName');
64
+ (0, vitest_1.expect)(latestRun).not.toHaveProperty('details');
65
+ (0, vitest_1.expect)(latestRun.createdByUserUuid).toBe('u1');
66
+ });
67
+ });
68
+ (0, vitest_1.describe)('toProjectSummary', () => {
69
+ (0, vitest_1.it)('omits warehouse, dbt, and contact override fields', () => {
70
+ const summary = (0, redaction_js_1.toProjectSummary)({
71
+ projectUuid: 'p1',
72
+ name: 'Prod',
73
+ type: 'DEFAULT',
74
+ organizationUuid: 'o1',
75
+ createdByUserUuid: 'u1',
76
+ createdByUserName: 'Alice',
77
+ warehouseType: 'bigquery',
78
+ warehouseConnection: {
79
+ type: 'bigquery',
80
+ password: 'warehouse-secret',
81
+ },
82
+ dbtConnection: {
83
+ type: 'github',
84
+ personal_access_token: 'ghp_secret_token',
85
+ },
86
+ schedulerFailureContactOverride: 'ops@example.com',
87
+ });
88
+ (0, vitest_1.expect)(summary).toEqual({
89
+ projectUuid: 'p1',
90
+ name: 'Prod',
91
+ type: 'DEFAULT',
92
+ organizationUuid: 'o1',
93
+ createdByUserUuid: 'u1',
94
+ warehouseType: 'bigquery',
95
+ });
96
+ (0, vitest_1.expect)(summary).not.toHaveProperty('warehouseConnection');
97
+ (0, vitest_1.expect)(summary).not.toHaveProperty('dbtConnection');
98
+ (0, vitest_1.expect)(summary).not.toHaveProperty('schedulerFailureContactOverride');
99
+ (0, vitest_1.expect)(summary).not.toHaveProperty('createdByUserName');
100
+ (0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('secret');
101
+ (0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('ops@example.com');
102
+ });
103
+ (0, vitest_1.it)('falls back to warehouseConnection.type when warehouseType is absent', () => {
104
+ const summary = (0, redaction_js_1.toProjectSummary)({
105
+ projectUuid: 'p2',
106
+ name: 'Pinned',
107
+ type: 'DEFAULT',
108
+ warehouseConnection: { type: 'snowflake', password: 'nope' },
109
+ dbtConnection: { type: 'none' },
110
+ });
111
+ (0, vitest_1.expect)(summary.warehouseType).toBe('snowflake');
112
+ (0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('nope');
113
+ });
114
+ });
115
+ (0, vitest_1.describe)('toProjectMemberAccessSummary', () => {
116
+ (0, vitest_1.it)('redacts email by default and keeps names', () => {
117
+ const row = (0, redaction_js_1.toProjectMemberAccessSummary)({
118
+ userUuid: 'u1',
119
+ projectUuid: 'p1',
120
+ firstName: 'Ada',
121
+ lastName: 'Lovelace',
122
+ email: 'ada@example.com',
123
+ role: 'editor',
124
+ roleUuid: 'r1',
125
+ }, false);
126
+ (0, vitest_1.expect)(row.firstName).toBe('Ada');
127
+ (0, vitest_1.expect)(row.lastName).toBe('Lovelace');
128
+ (0, vitest_1.expect)(row.email).toEqual({
129
+ email: 'a***@example.com',
130
+ domain: 'example.com',
131
+ isExternalDomain: false,
132
+ });
133
+ (0, vitest_1.expect)(JSON.stringify(row)).not.toContain('ada@example.com');
134
+ });
135
+ (0, vitest_1.it)('returns full email when includeEmail is true', () => {
136
+ const row = (0, redaction_js_1.toProjectMemberAccessSummary)({
137
+ userUuid: 'u1',
138
+ projectUuid: 'p1',
139
+ firstName: 'Ada',
140
+ lastName: 'Lovelace',
141
+ email: 'ada@example.com',
142
+ role: 'viewer',
143
+ }, true);
144
+ (0, vitest_1.expect)(row.email).toBe('ada@example.com');
145
+ });
146
+ });
147
+ (0, vitest_1.describe)('toGroupSummary', () => {
148
+ (0, vitest_1.it)('allowlists group fields and redacts member emails', () => {
149
+ const summary = (0, redaction_js_1.toGroupSummary)({
150
+ uuid: 'g1',
151
+ name: 'Admins',
152
+ organizationUuid: 'o1',
153
+ createdAt: '2026-01-01',
154
+ updatedAt: '2026-01-02',
155
+ createdByUserUuid: 'u0',
156
+ updatedByUserUuid: 'u9',
157
+ memberUuids: ['u1'],
158
+ members: [
159
+ {
160
+ userUuid: 'u1',
161
+ firstName: 'Ada',
162
+ lastName: 'Lovelace',
163
+ email: 'ada@example.com',
164
+ },
165
+ ],
166
+ unexpectedSecret: 'should-drop',
167
+ }, false, ['example.com']);
168
+ (0, vitest_1.expect)(summary).toEqual({
169
+ uuid: 'g1',
170
+ name: 'Admins',
171
+ organizationUuid: 'o1',
172
+ createdAt: '2026-01-01',
173
+ updatedAt: '2026-01-02',
174
+ createdByUserUuid: 'u0',
175
+ memberUuids: ['u1'],
176
+ members: [
177
+ {
178
+ userUuid: 'u1',
179
+ firstName: 'Ada',
180
+ lastName: 'Lovelace',
181
+ email: {
182
+ email: 'a***@example.com',
183
+ domain: 'example.com',
184
+ isExternalDomain: false,
185
+ },
186
+ },
187
+ ],
188
+ });
189
+ (0, vitest_1.expect)(summary).not.toHaveProperty('updatedByUserUuid');
190
+ (0, vitest_1.expect)(summary).not.toHaveProperty('unexpectedSecret');
191
+ });
192
+ });
193
+ (0, vitest_1.describe)('toOrgMemberSummary', () => {
194
+ (0, vitest_1.it)('redacts email and drops avatar fields', () => {
195
+ const row = (0, redaction_js_1.toOrgMemberSummary)({
196
+ userUuid: 'u1',
197
+ organizationUuid: 'o1',
198
+ firstName: 'Ada',
199
+ lastName: 'Lovelace',
200
+ email: 'ada@evil.example',
201
+ isActive: true,
202
+ isInviteExpired: false,
203
+ role: 'admin',
204
+ roleUuid: 'r1',
205
+ avatarUrl: 'https://example.com/a.png',
206
+ avatarGradient: 'g',
207
+ }, false, ['example.com']);
208
+ (0, vitest_1.expect)(row.email).toEqual({
209
+ email: 'a***@evil.example',
210
+ domain: 'evil.example',
211
+ isExternalDomain: true,
212
+ });
213
+ (0, vitest_1.expect)(row).not.toHaveProperty('avatarUrl');
214
+ (0, vitest_1.expect)(JSON.stringify(row)).not.toContain('ada@evil.example');
215
+ });
216
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared registration helper for organization-audit tools.
3
+ */
4
+ import type { ToolHandler, ToolOptions } from '../shared.js';
5
+ import type { McpServer } from '@modelcontextprotocol/server';
6
+ /** Register a GET read-only org-audit tool after safety asserts. */
7
+ export declare function registerOrgAuditTool(server: McpServer, shortName: string, options: Omit<ToolOptions, 'annotations'> & {
8
+ annotations?: ToolOptions['annotations'];
9
+ }, handler: ToolHandler): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Shared registration helper for organization-audit tools.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerOrgAuditTool = registerOrgAuditTool;
7
+ const common_1 = require("@lightdash-tools/common");
8
+ const shared_js_1 = require("../shared.js");
9
+ const assert_safe_js_1 = require("./assert-safe.js");
10
+ /** Register a GET read-only org-audit tool after safety asserts. */
11
+ function registerOrgAuditTool(server, shortName, options, handler) {
12
+ var _a;
13
+ const annotations = (_a = options.annotations) !== null && _a !== void 0 ? _a : common_1.READ_ONLY_DEFAULT;
14
+ (0, assert_safe_js_1.assertOrganizationAuditToolSafe)({
15
+ shortName,
16
+ annotations,
17
+ httpMethod: 'GET',
18
+ });
19
+ (0, shared_js_1.registerToolSafe)(server, shortName, Object.assign(Object.assign({}, options), { annotations }), handler);
20
+ }
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const PROJECT_UUID_DESC = "Project UUID";
3
+ export declare const projectUuidField: () => z.ZodString;
4
+ /** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
5
+ export declare const uuidOrSlugField: (description?: string) => z.ZodString;
6
+ /** Opt-in full email addresses in MCP responses (default redacted). */
7
+ export declare const includeEmailField: () => z.ZodOptional<z.ZodBoolean>;
8
+ /** Domains treated as internal when classifying redacted emails. */
9
+ export declare const allowedEmailDomainsField: () => z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allowedEmailDomainsField = exports.includeEmailField = exports.uuidOrSlugField = exports.projectUuidField = exports.PROJECT_UUID_DESC = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PROJECT_UUID_DESC = 'Project UUID';
6
+ const projectUuidField = () => zod_1.z.string().describe(exports.PROJECT_UUID_DESC);
7
+ exports.projectUuidField = projectUuidField;
8
+ /** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
9
+ const uuidOrSlugField = (description = 'UUID or slug') => zod_1.z.string().describe(description);
10
+ exports.uuidOrSlugField = uuidOrSlugField;
11
+ /** Opt-in full email addresses in MCP responses (default redacted). */
12
+ const includeEmailField = () => zod_1.z.boolean().optional().describe('Return full emails when true (default false)');
13
+ exports.includeEmailField = includeEmailField;
14
+ /** Domains treated as internal when classifying redacted emails. */
15
+ const allowedEmailDomainsField = () => zod_1.z
16
+ .array(zod_1.z.string())
17
+ .optional()
18
+ .describe('Domains treated as internal when classifying redacted emails');
19
+ exports.allowedEmailDomainsField = allowedEmailDomainsField;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Session organization binding for organization-audit tools.
3
+ */
4
+ import type { LightdashClient } from '@lightdash-tools/client';
5
+ export type SessionOrganization = {
6
+ organizationUuid: string;
7
+ organizationName?: string;
8
+ currentUserUuid: string;
9
+ currentUserOrganizationRole?: string;
10
+ currentUserRoleUuid?: string;
11
+ auditVisibility: 'organization_admin' | 'partial' | 'unknown';
12
+ };
13
+ /** Resolve authenticated org/user for the current session. */
14
+ export declare function resolveSessionOrganization(client: LightdashClient): Promise<SessionOrganization>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Session organization binding for organization-audit tools.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveSessionOrganization = resolveSessionOrganization;
7
+ /** Resolve authenticated org/user for the current session. */
8
+ async function resolveSessionOrganization(client) {
9
+ var _a;
10
+ const user = await client.v1.users.getAuthenticatedUser();
11
+ const organizationUuid = user.organizationUuid;
12
+ if (!organizationUuid) {
13
+ throw new Error('Authenticated user has no organizationUuid');
14
+ }
15
+ const role = user.role;
16
+ let auditVisibility = 'unknown';
17
+ if (role === 'admin') {
18
+ auditVisibility = 'organization_admin';
19
+ }
20
+ else if (role) {
21
+ auditVisibility = 'partial';
22
+ }
23
+ return {
24
+ organizationUuid,
25
+ organizationName: user.organizationName,
26
+ currentUserUuid: user.userUuid,
27
+ currentUserOrganizationRole: role,
28
+ currentUserRoleUuid: (_a = user.roleUuid) !== null && _a !== void 0 ? _a : undefined,
29
+ auditVisibility,
30
+ };
31
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Persona safety invariant: all org-audit tools register as read-only GET.
3
+ */
4
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Persona safety invariant: all org-audit tools register as read-only GET.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const common_1 = require("@lightdash-tools/common");
7
+ const vitest_1 = require("vitest");
8
+ const index_js_1 = require("../../personas/organization-audit/v1/index.js");
9
+ const registry_js_1 = require("../registry.js");
10
+ const shared_js_1 = require("../shared.js");
11
+ (0, vitest_1.describe)('organization-audit safety invariants', () => {
12
+ (0, vitest_1.it)('registers only readOnlyHint tools for the allowlist', () => {
13
+ const annotationsByName = new Map();
14
+ const mockServer = {
15
+ registerTool: vitest_1.vi.fn((name, options) => {
16
+ annotationsByName.set(name, options.annotations);
17
+ }),
18
+ };
19
+ const mockCtx = { getContext: async () => ({ lightdashClient: {} }) };
20
+ (0, registry_js_1.registerToolsByIds)(mockServer, mockCtx, index_js_1.ORGANIZATION_AUDIT_TOOL_IDS);
21
+ (0, vitest_1.expect)(annotationsByName.size).toBe(index_js_1.ORGANIZATION_AUDIT_TOOL_IDS.length);
22
+ for (const id of index_js_1.ORGANIZATION_AUDIT_TOOL_IDS) {
23
+ const annotations = annotationsByName.get(`${shared_js_1.TOOL_PREFIX}${id}`);
24
+ (0, vitest_1.expect)(annotations === null || annotations === void 0 ? void 0 : annotations.readOnlyHint).toBe(true);
25
+ (0, vitest_1.expect)(annotations).toMatchObject(common_1.READ_ONLY_DEFAULT);
26
+ }
27
+ });
28
+ });