@lightdash/cli 2.573.3 → 2.574.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 (65) hide show
  1. package/README.md +31 -0
  2. package/dist/.tsbuildinfo.build +1 -1
  3. package/dist/agentConnections/agentTokenProvider.d.ts.map +1 -1
  4. package/dist/agentConnections/agentTokenProvider.js +5 -4
  5. package/dist/agentConnections/responseValidation.d.ts +3 -0
  6. package/dist/agentConnections/responseValidation.d.ts.map +1 -0
  7. package/dist/agentConnections/responseValidation.js +12 -0
  8. package/dist/agentConnections/schema.d.ts.map +1 -1
  9. package/dist/agentConnections/schema.js +70 -4
  10. package/dist/agentConnections/serverError.d.ts +5 -0
  11. package/dist/agentConnections/serverError.d.ts.map +1 -0
  12. package/dist/agentConnections/serverError.js +38 -0
  13. package/dist/agentConnections/statusResponse.d.ts.map +1 -1
  14. package/dist/agentConnections/statusResponse.js +19 -11
  15. package/dist/agentConnections/store.d.ts.map +1 -1
  16. package/dist/agentConnections/store.js +6 -32
  17. package/dist/agentConnections/warehouseStatus.d.ts.map +1 -1
  18. package/dist/agentConnections/warehouseStatus.js +4 -26
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +2 -0
  21. package/dist/connectionErrors.fixture.d.ts +2 -0
  22. package/dist/connectionErrors.fixture.d.ts.map +1 -0
  23. package/dist/connectionErrors.fixture.js +38 -0
  24. package/dist/dbt/targets/Databricks/oauth.d.ts.map +1 -1
  25. package/dist/dbt/targets/Databricks/oauth.js +3 -3
  26. package/dist/errorHandler.fixture.d.ts +2 -0
  27. package/dist/errorHandler.fixture.d.ts.map +1 -0
  28. package/dist/errorHandler.fixture.js +48 -0
  29. package/dist/handlers/agentConnectionConnect.d.ts.map +1 -1
  30. package/dist/handlers/agentConnectionConnect.js +18 -8
  31. package/dist/handlers/agentConnectionStatus.d.ts.map +1 -1
  32. package/dist/handlers/agentConnectionStatus.js +5 -1
  33. package/dist/handlers/agentRevoke.d.ts.map +1 -1
  34. package/dist/handlers/agentRevoke.js +5 -0
  35. package/dist/handlers/apps/appCodeFiles.d.ts.map +1 -1
  36. package/dist/handlers/apps/appCodeFiles.js +4 -1
  37. package/dist/handlers/apps/appsDownload.d.ts.map +1 -1
  38. package/dist/handlers/apps/appsDownload.js +22 -6
  39. package/dist/handlers/asyncQuery.d.ts +1 -0
  40. package/dist/handlers/asyncQuery.d.ts.map +1 -1
  41. package/dist/handlers/asyncQuery.js +15 -0
  42. package/dist/handlers/compile.d.ts.map +1 -1
  43. package/dist/handlers/compile.js +3 -1
  44. package/dist/handlers/dbt/apiClient.d.ts +1 -0
  45. package/dist/handlers/dbt/apiClient.d.ts.map +1 -1
  46. package/dist/handlers/dbt/apiClient.js +68 -17
  47. package/dist/handlers/deploy.d.ts.map +1 -1
  48. package/dist/handlers/deploy.js +10 -0
  49. package/dist/handlers/download.d.ts.map +1 -1
  50. package/dist/handlers/download.js +31 -8
  51. package/dist/handlers/getProject.d.ts.map +1 -1
  52. package/dist/handlers/getProject.js +10 -1
  53. package/dist/handlers/homepagesAsCode.d.ts.map +1 -1
  54. package/dist/handlers/homepagesAsCode.js +4 -1
  55. package/dist/handlers/runChart.d.ts.map +1 -1
  56. package/dist/handlers/runChart.js +8 -2
  57. package/dist/handlers/spacesAsCode.d.ts.map +1 -1
  58. package/dist/handlers/spacesAsCode.js +16 -3
  59. package/dist/handlers/sql.d.ts.map +1 -1
  60. package/dist/handlers/sql.js +3 -2
  61. package/dist/handlers/timestampConversion.d.ts.map +1 -1
  62. package/dist/handlers/timestampConversion.js +6 -0
  63. package/dist/ordinaryError.main.json +20 -0
  64. package/dist/outputUnchanged.main.json +30 -0
  65. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"agentTokenProvider.d.ts","sourceRoot":"","sources":["../../src/agentConnections/agentTokenProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU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,MAAM,GAAG,IAAW,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAgK9B;IACK,iBAAiB,CACnB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,OAAO,aAAa,EAAE,kBAAkB,EACnD,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAAC,mBAAmB,CAAC,CA0B9B;CACJ"}
@@ -7,6 +7,7 @@ const ajv_1 = tslib_1.__importDefault(require("ajv"));
7
7
  const crypto_1 = require("crypto");
8
8
  const apiUrl_1 = require("./apiUrl");
9
9
  const schema_1 = require("./schema");
10
+ const statusResponse_1 = require("./statusResponse");
10
11
  const store_1 = require("./store");
11
12
  const createResponseValidator = () => new ajv_1.default().compile({
12
13
  type: 'object',
@@ -18,14 +19,14 @@ const createResponseValidator = () => new ajv_1.default().compile({
18
19
  'scope',
19
20
  ],
20
21
  properties: {
21
- access_token: { type: 'string', minLength: 1 },
22
- refresh_token: { type: 'string', minLength: 1 },
22
+ access_token: { type: 'string', minLength: 1, maxLength: 16384 },
23
+ refresh_token: { type: 'string', minLength: 1, maxLength: 16384 },
23
24
  token_type: {
24
25
  type: 'string',
25
26
  pattern: '^[Bb][Ee][Aa][Rr][Ee][Rr]$',
26
27
  },
27
28
  expires_in: { type: 'integer', minimum: 1, maximum: 2_147_483_647 },
28
- scope: { type: 'string', minLength: 1 },
29
+ scope: { type: 'string', minLength: 1, maxLength: 16384 },
29
30
  },
30
31
  });
31
32
  let responseValidator = null;
@@ -121,7 +122,7 @@ class AgentTokenProvider {
121
122
  },
122
123
  }, slot);
123
124
  (0, exports.assertUsableSlot)(checked, Date.now());
124
- return checked;
125
+ return { ...checked, lastReported: (0, statusResponse_1.publicConnectionReport)(checked) };
125
126
  }
126
127
  async reconnect(locked, slot) {
127
128
  try {
@@ -0,0 +1,3 @@
1
+ export declare const assertConnectionResponse: (valid: boolean) => void;
2
+ export declare const isResponseCount: (value: unknown) => boolean;
3
+ //# sourceMappingURL=responseValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseValidation.d.ts","sourceRoot":"","sources":["../../src/agentConnections/responseValidation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,UAAW,OAAO,KAAG,IAGzD,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,OACyB,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isResponseCount = exports.assertConnectionResponse = void 0;
4
+ const common_1 = require("@lightdash/common");
5
+ const credentials_1 = require("../credentials");
6
+ const assertConnectionResponse = (valid) => {
7
+ if ((0, credentials_1.getAgentConnectionSelection)() !== null && !valid)
8
+ throw new common_1.ParameterError('The server returned an invalid response.');
9
+ };
10
+ exports.assertConnectionResponse = assertConnectionResponse;
11
+ const isResponseCount = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
12
+ exports.isResponseCount = isResponseCount;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/agentConnections/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,MAAM,MAAM,OAAO,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,2BAA2B,GACjC,eAAe,GACf,eAAe,GACf,SAAS,GACT,SAAS,GACT,yBAAyB,GACzB,gBAAgB,GAChB,mBAAmB,GACnB,cAAc,CAAC;AACrB,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG;IACxC,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG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UACd,OAAO,OACT,OAAO,KACb,mBA6HF,CAAC"}
@@ -25,7 +25,7 @@ const canonicalInstanceUrl = (input) => {
25
25
  }
26
26
  };
27
27
  exports.canonicalInstanceUrl = canonicalInstanceUrl;
28
- const text = { type: 'string', minLength: 1 };
28
+ const text = { type: 'string', minLength: 1, maxLength: 16384 };
29
29
  const uuid = { type: 'string', format: 'uuid' };
30
30
  const date = {
31
31
  type: 'string',
@@ -44,7 +44,7 @@ const createSlotValidator = () => {
44
44
  const ajv = new ajv_1.default();
45
45
  (0, ajv_formats_1.default)(ajv);
46
46
  return ajv.compile(object({
47
- instanceUrl: text,
47
+ instanceUrl: { ...text, maxLength: 2048 },
48
48
  organizationUuid: uuid,
49
49
  personUuid: uuid,
50
50
  name: {
@@ -52,7 +52,7 @@ const createSlotValidator = () => {
52
52
  pattern: '^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$',
53
53
  },
54
54
  clientId: { const: 'lightdash-cli' },
55
- resource: text,
55
+ resource: { ...text, maxLength: 2048 },
56
56
  grantUuid: uuid,
57
57
  grantRevision: nullable({ type: 'integer', minimum: 1 }),
58
58
  approvedAt: date,
@@ -65,6 +65,7 @@ const createSlotValidator = () => {
65
65
  scopes: {
66
66
  ...array({
67
67
  type: 'string',
68
+ maxLength: 256,
68
69
  pattern: '^[\\x21\\x23-\\x5B\\x5D-\\x7E]+$',
69
70
  }),
70
71
  minItems: 1,
@@ -179,6 +180,71 @@ const validateSlot = (value, key) => {
179
180
  c.allowed !== (c.reason === null)))
180
181
  throw (0, exports.invalidConnection)();
181
182
  }
182
- return value;
183
+ let refreshState;
184
+ switch (value.refreshState.kind) {
185
+ case 'in_progress':
186
+ refreshState = {
187
+ kind: value.refreshState.kind,
188
+ attemptUuid: value.refreshState.attemptUuid,
189
+ startedAt: value.refreshState.startedAt,
190
+ };
191
+ break;
192
+ case 'reconnect_required':
193
+ refreshState = {
194
+ kind: value.refreshState.kind,
195
+ since: value.refreshState.since,
196
+ };
197
+ break;
198
+ default:
199
+ refreshState = { kind: value.refreshState.kind };
200
+ }
201
+ return {
202
+ instanceUrl: value.instanceUrl,
203
+ organizationUuid: value.organizationUuid,
204
+ personUuid: value.personUuid,
205
+ name: value.name,
206
+ clientId: value.clientId,
207
+ resource: value.resource,
208
+ grantUuid: value.grantUuid,
209
+ grantRevision: value.grantRevision,
210
+ approvedAt: value.approvedAt,
211
+ grantExpiresAt: value.grantExpiresAt,
212
+ tokens: {
213
+ accessToken: value.tokens.accessToken,
214
+ accessTokenExpiresAt: value.tokens.accessTokenExpiresAt,
215
+ refreshToken: value.tokens.refreshToken,
216
+ refreshTokenExpiresAt: value.tokens.refreshTokenExpiresAt,
217
+ scopes: [...value.tokens.scopes],
218
+ generation: value.tokens.generation,
219
+ lastRefreshAttemptUuid: value.tokens.lastRefreshAttemptUuid,
220
+ },
221
+ lastReported: {
222
+ checkedAt: value.lastReported.checkedAt,
223
+ limitsStatus: value.lastReported.limitsStatus,
224
+ approvedProjects: value.lastReported.approvedProjects.map((project) => ({
225
+ projectUuid: project.projectUuid,
226
+ name: project.name,
227
+ approvedCapabilities: [...project.approvedCapabilities],
228
+ })),
229
+ effectiveProjects: value.lastReported.effectiveProjects.map((project) => ({
230
+ projectUuid: project.projectUuid,
231
+ capabilities: project.capabilities.map((action) => ({
232
+ capability: action.capability,
233
+ allowed: action.allowed,
234
+ reason: action.reason,
235
+ })),
236
+ })),
237
+ status: value.lastReported.status,
238
+ lastUsedAt: value.lastReported.lastUsedAt,
239
+ revokedAt: value.lastReported.revokedAt,
240
+ },
241
+ refreshState,
242
+ revokeState: value.revokeState.kind === 'unconfirmed'
243
+ ? {
244
+ kind: value.revokeState.kind,
245
+ attemptedAt: value.revokeState.attemptedAt,
246
+ }
247
+ : { kind: value.revokeState.kind },
248
+ };
183
249
  };
184
250
  exports.validateSlot = validateSlot;
@@ -0,0 +1,5 @@
1
+ export declare class ConnectionServerError extends Error {
2
+ }
3
+ export declare const connectionServerError: (status: number, value: unknown) => ConnectionServerError;
4
+ export declare const checkConnectionErrorEnvelope: (status: number, value: unknown) => void;
5
+ //# sourceMappingURL=serverError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/agentConnections/serverError.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAsB,SAAQ,KAAK;CAAG;AAEnD,eAAO,MAAM,qBAAqB,WACtB,MAAM,SACP,OAAO,KACf,qBA0BF,CAAC;AAEF,eAAO,MAAM,4BAA4B,WAC7B,MAAM,SACP,OAAO,KACf,IAQF,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkConnectionErrorEnvelope = exports.connectionServerError = exports.ConnectionServerError = void 0;
4
+ class ConnectionServerError extends Error {
5
+ }
6
+ exports.ConnectionServerError = ConnectionServerError;
7
+ const connectionServerError = (status, value) => {
8
+ let identifier = null;
9
+ if (typeof value === 'object' && value !== null && 'error' in value) {
10
+ const { error } = value;
11
+ if (typeof error === 'object' && error !== null) {
12
+ let code = null;
13
+ if ('code' in error)
14
+ code = error.code;
15
+ else if ('name' in error)
16
+ code = error.name;
17
+ if (typeof code === 'string' && /^[a-z0-9_.-]{1,64}$/i.test(code))
18
+ identifier = code;
19
+ }
20
+ }
21
+ switch (identifier) {
22
+ case 'agent_connections_unavailable':
23
+ return new ConnectionServerError('Agent connections are not available on this server yet.');
24
+ case 'agent_identity_disabled':
25
+ return new ConnectionServerError('Agent connections are disabled on this server. Ask an administrator to enable agent identity.');
26
+ default:
27
+ return new ConnectionServerError(`The server rejected the agent connection request (status ${status}).`);
28
+ }
29
+ };
30
+ exports.connectionServerError = connectionServerError;
31
+ const checkConnectionErrorEnvelope = (status, value) => {
32
+ if (typeof value === 'object' &&
33
+ value !== null &&
34
+ 'status' in value &&
35
+ value.status === 'error')
36
+ throw (0, exports.connectionServerError)(status, value);
37
+ };
38
+ exports.checkConnectionErrorEnvelope = checkConnectionErrorEnvelope;
@@ -1 +1 @@
1
- {"version":3,"file":"statusResponse.d.ts","sourceRoot":"","sources":["../../src/agentConnections/statusResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EACnC,MAAM,UAAU,CAAC;AAElB,qBAAa,uBAAwB,SAAQ,KAAK;IAC9C,cAEC;CACJ;AACD,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAIrE,CAAC;AACF,eAAO,MAAM,gBAAgB,UAClB,MAAM,WACJ,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,yBAEhD,OAwBF,CAAC;AACF,eAAO,MAAM,sBAAsB,SACzB,mBAAmB,iBACX,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KACrD,mBAAmB,CAAC,cAAc,CA2BnC,CAAC;AACH,eAAO,MAAM,kBAAkB,UACpB,OAAO,QACR,mBAAmB,oBACP,OAAO,iBACV,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KACtD,mBA0EF,CAAC;AACF,eAAO,MAAM,mBAAmB,WACpB,2BAA2B,GAAG,IAAI,KAC3C,MAAM,GAAG,IA0BX,CAAC"}
1
+ {"version":3,"file":"statusResponse.d.ts","sourceRoot":"","sources":["../../src/agentConnections/statusResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EACnC,MAAM,UAAU,CAAC;AAElB,qBAAa,uBAAwB,SAAQ,KAAK;IAC9C,cAEC;CACJ;AACD,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAIrE,CAAC;AACF,eAAO,MAAM,gBAAgB,UAClB,MAAM,WACJ,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,yBAEhD,OAwBF,CAAC;AACF,eAAO,MAAM,sBAAsB,SACzB,mBAAmB,iBACX,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KACrD,mBAAmB,CAAC,cAAc,CAsCnC,CAAC;AACH,eAAO,MAAM,kBAAkB,UACpB,OAAO,QACR,mBAAmB,oBACP,OAAO,iBACV,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KACtD,mBA0EF,CAAC;AACF,eAAO,MAAM,mBAAmB,WACpB,2BAA2B,GAAG,IAAI,KAC3C,MAAM,GAAG,IA0BX,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.statusReasonMessage = exports.connectionResponse = exports.publicConnectionReport = exports.publicTextIsSafe = exports.responseRecord = exports.ConnectionMismatchError = void 0;
4
4
  const common_1 = require("@lightdash/common");
5
+ const util_1 = require("util");
5
6
  const schema_1 = require("./schema");
6
7
  class ConnectionMismatchError extends Error {
7
8
  constructor() {
@@ -42,18 +43,25 @@ const publicConnectionReport = (slot, extraSecrets = []) => ({
42
43
  limitsStatus: slot.lastReported.limitsStatus,
43
44
  lastUsedAt: slot.lastReported.lastUsedAt,
44
45
  revokedAt: slot.lastReported.revokedAt,
45
- approvedProjects: slot.lastReported.approvedProjects.map((project) => ({
46
- projectUuid: project.projectUuid,
47
- name: project.name !== null &&
48
- !(0, exports.publicTextIsSafe)(project.name, [
49
- slot.tokens.accessToken,
50
- slot.tokens.refreshToken,
51
- ...extraSecrets,
52
- ])
46
+ approvedProjects: slot.lastReported.approvedProjects.map((project) => {
47
+ const name = project.name === null
53
48
  ? null
54
- : project.name,
55
- approvedCapabilities: project.approvedCapabilities,
56
- })),
49
+ : (0, util_1.stripVTControlCharacters)(project.name).replace(/[\u0000-\u001f\u007f-\u009f]/g, '');
50
+ const secrets = [
51
+ slot.tokens.accessToken,
52
+ slot.tokens.refreshToken,
53
+ ...extraSecrets,
54
+ ];
55
+ return {
56
+ projectUuid: project.projectUuid,
57
+ name: name === null ||
58
+ !(0, exports.publicTextIsSafe)(project.name, secrets) ||
59
+ !(0, exports.publicTextIsSafe)(name, secrets)
60
+ ? null
61
+ : name,
62
+ approvedCapabilities: [...project.approvedCapabilities],
63
+ };
64
+ }),
57
65
  effectiveProjects: slot.lastReported.effectiveProjects.map((project) => ({
58
66
  projectUuid: project.projectUuid,
59
67
  capabilities: project.capabilities.map((action) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/agentConnections/store.ts"],"names":[],"mappings":"AAWA,OAAO,EAGH,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACf,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,2BAA2B,QAAO,MACsB,CAAC;AA4CtE,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAChE,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,WAAW,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC9D,YAAY,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,YAAY,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,mBAAmB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE,CAAC;AAEF,qBAAa,oBAAoB;aAET,QAAQ,EAAE,MAAM;IADpC,YACoB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CAAC,CAAC,CAqDZ;IAEK,QAAQ,CACV,IAAI,EAAE,mBAAmB,EACzB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,GAC9D,OAAO,CAAC;QAAE,iBAAiB,EAAE,OAAO,CAAA;KAAE,CAAC,CAmBzC;YAEa,MAAM;IAcd,YAAY,CACd,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAKf;IACK,eAAe,CACjB,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,mBAAmB,CAAC,cAAc,CAAC,GAClD,OAAO,CAAC,IAAI,CAAC,CAEf;IACK,cAAc,CAChB,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAEf;IACK,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5C;IACK,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBvE;CACJ"}
@@ -9,6 +9,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
9
9
  const config_1 = require("../config");
10
10
  const configLock_1 = require("./configLock");
11
11
  const schema_1 = require("./schema");
12
+ const statusResponse_1 = require("./statusResponse");
12
13
  const getAgentConnectionsFilePath = () => path_1.default.join(path_1.default.dirname(config_1.configFilePath), 'agent-connections.yaml');
13
14
  exports.getAgentConnectionsFilePath = getAgentConnectionsFilePath;
14
15
  const record = (value) => {
@@ -74,43 +75,16 @@ class AgentConnectionStore {
74
75
  return slot === undefined ? null : (0, schema_1.validateSlot)(slot, key);
75
76
  }
76
77
  async saveUnlocked(slot, commit = {}) {
77
- (0, schema_1.validateSlot)(slot, slot);
78
+ const checked = (0, schema_1.validateSlot)(slot, slot);
78
79
  const root = await this.readRoot();
79
80
  const slots = slotsFor(root, slot, true);
80
81
  if (slots === null)
81
82
  throw (0, schema_1.invalidConnection)();
82
- const existing = own(slots, slot.name);
83
- const previous = existing === undefined ? {} : record(existing);
84
- const merged = {
85
- ...previous,
86
- ...slot,
87
- tokens: {
88
- ...(own(previous, 'tokens') === undefined
89
- ? {}
90
- : record(previous.tokens)),
91
- ...slot.tokens,
92
- },
93
- refreshState: {
94
- ...(own(previous, 'refreshState') === undefined
95
- ? {}
96
- : record(previous.refreshState)),
97
- ...slot.refreshState,
98
- },
99
- revokeState: {
100
- ...(own(previous, 'revokeState') === undefined
101
- ? {}
102
- : record(previous.revokeState)),
103
- ...slot.revokeState,
104
- },
105
- lastReported: {
106
- ...(own(previous, 'lastReported') === undefined
107
- ? {}
108
- : record(previous.lastReported)),
109
- ...slot.lastReported,
110
- },
111
- };
112
83
  Object.defineProperty(slots, slot.name, {
113
- value: merged,
84
+ value: {
85
+ ...checked,
86
+ lastReported: (0, statusResponse_1.publicConnectionReport)(checked),
87
+ },
114
88
  enumerable: true,
115
89
  configurable: true,
116
90
  writable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"warehouseStatus.d.ts","sourceRoot":"","sources":["../../src/agentConnections/warehouseStatus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,KAAK,eAAe,GAAG;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,EACF,kBAAkB,GAClB,oBAAoB,GACpB,eAAe,GACf,IAAI,CAAC;IACX,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,UAA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AAU,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,GAAG,IAAI,CAAC;CACZ,CAAC;AAsDF,MAAM,MAAM,YAAY,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAC1B,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;IACvD,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC5B,CAAC;AACF,eAAO,MAAM,mBAAmB,SACtB,mBAAmB,oBACR,OAAO,uBAAuB,KAChD,OAAO,CAAC,eAAe,CAsHzB,CAAC"}
@@ -62,26 +62,6 @@ const createValidator = () => {
62
62
  });
63
63
  };
64
64
  let validator = null;
65
- const safeLink = (link, slot) => {
66
- const instance = slot.instanceUrl;
67
- if (link !== null &&
68
- [slot.tokens.accessToken, slot.tokens.refreshToken].some((secret) => link.includes(secret) ||
69
- link.includes(encodeURIComponent(secret))))
70
- return null;
71
- if (link === null)
72
- return null;
73
- try {
74
- const url = new URL(link, `${instance}/`);
75
- return url.origin === new URL(instance).origin &&
76
- !url.username &&
77
- !url.password
78
- ? url.href
79
- : null;
80
- }
81
- catch {
82
- return null;
83
- }
84
- };
85
65
  const readWarehouseStatus = async (slot, lightdashRawApi = apiClient_1.lightdashRawApi) => {
86
66
  const limit = (0, p_limit_1.default)(4);
87
67
  const projects = await Promise.all(slot.lastReported.approvedProjects.map((project) => limit(async () => {
@@ -131,10 +111,8 @@ const readWarehouseStatus = async (slot, lightdashRawApi = apiClient_1.lightdash
131
111
  source: 'server',
132
112
  reason: access.refusal.reason,
133
113
  identity: access.identity,
134
- expiresAt: access.expiresAt,
135
- settingsUrl: safeLink(access.refusal.connectUrl, slot) ??
136
- safeLink(access.refusal.settingsUrl, slot) ??
137
- unknown.settingsUrl,
114
+ expiresAt: access.expiresAt?.replace(/[\u0000-\u001f\u007f-\u009f]/g, '') ?? null,
115
+ settingsUrl: unknown.settingsUrl,
138
116
  };
139
117
  if (access.expiresAt !== null &&
140
118
  Date.parse(access.expiresAt) <= Date.now())
@@ -143,7 +121,7 @@ const readWarehouseStatus = async (slot, lightdashRawApi = apiClient_1.lightdash
143
121
  state: 'needs_setup',
144
122
  source: 'server',
145
123
  reason: 'Warehouse sign-in expired.',
146
- expiresAt: access.expiresAt,
124
+ expiresAt: access.expiresAt?.replace(/[\u0000-\u001f\u007f-\u009f]/g, '') ?? null,
147
125
  };
148
126
  const ready = access.identity === 'connected_person' ||
149
127
  access.identity === 'ai_service_account' ||
@@ -160,7 +138,7 @@ const readWarehouseStatus = async (slot, lightdashRawApi = apiClient_1.lightdash
160
138
  state: ready ? 'ready' : 'unknown',
161
139
  source: 'server',
162
140
  identity: access.identity,
163
- expiresAt: access.expiresAt,
141
+ expiresAt: access.expiresAt?.replace(/[\u0000-\u001f\u007f-\u009f]/g, '') ?? null,
164
142
  reason,
165
143
  };
166
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,QAAsC,CAAC;AAElE,MAAM,MAAM,MAAM,GAAG;IACjB,IAAI,CAAC,EAAE;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,OAAO,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC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AO,MAAM,cAAc,aACb,MAAM,oBACE,MAAM,kBAW3B,CAAC;AAEF,eAAO,MAAM,UAAU,YAAmB,MAAM,CAAC,SAAS,CAAC,kBAM1D,CAAC;AAEF,eAAO,MAAM,SAAS,WAAkB,MAAM,CAAC,SAAS,CAAC,kBAMxD,CAAC"}
package/dist/config.js CHANGED
@@ -55,6 +55,8 @@ const getRawConfig = async () => {
55
55
  return raw;
56
56
  }
57
57
  catch (e) {
58
+ if (e instanceof yaml.YAMLException)
59
+ throw new yaml.YAMLException(`Could not parse CLI configuration${e.mark ? ` at line ${e.mark.line + 1}, column ${e.mark.column + 1}` : ''}. Check the syntax of config.yaml.`);
58
60
  if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
59
61
  return {};
60
62
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=connectionErrors.fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectionErrors.fixture.d.ts","sourceRoot":"","sources":["../src/connectionErrors.fixture.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const credentials_1 = require("./credentials");
5
+ const errorHandler_fixture_1 = require("./errorHandler.fixture");
6
+ const globalState_1 = tslib_1.__importDefault(require("./globalState"));
7
+ const agentConnectionConnect_1 = require("./handlers/agentConnectionConnect");
8
+ const agentRevoke_1 = require("./handlers/agentRevoke");
9
+ const agentStatus_1 = require("./handlers/agentStatus");
10
+ const apiClient_1 = require("./handlers/dbt/apiClient");
11
+ const mode = process.argv[2];
12
+ if (mode === 'command') {
13
+ globalState_1.default.setVerbose(true);
14
+ const command = process.argv[3];
15
+ const run = async () => {
16
+ switch (command) {
17
+ case 'connect':
18
+ return (0, agentConnectionConnect_1.agentConnectionConnectHandler)({ verbose: true });
19
+ case 'status':
20
+ return (0, agentStatus_1.agentStatusHandler)({ name: 'default', verbose: true });
21
+ case 'revoke':
22
+ return (0, agentRevoke_1.agentRevokeHandler)({ name: 'default' });
23
+ case 'request':
24
+ return (0, credentials_1.runWithAgentConnectionSelection)('default', () => (0, apiClient_1.lightdashApi)({
25
+ method: 'GET',
26
+ url: '/api/v1/user',
27
+ body: undefined,
28
+ }));
29
+ default:
30
+ return (0, apiClient_1.lightdashApi)({
31
+ method: 'GET',
32
+ url: '/api/v1/org/projects',
33
+ body: undefined,
34
+ });
35
+ }
36
+ };
37
+ void run().catch(errorHandler_fixture_1.errorHandler);
38
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/dbt/targets/Databricks/oauth.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,kCAAkC,mBAAmB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAC7B,MAAM,YACF,MAAM,gBACF,MAAM,GAAG,SAAS,KACjC,OAAO,CAAC,qBAAqB,CAmO/B,CAAC"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/dbt/targets/Databricks/oauth.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,kCAAkC,mBAAmB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAC7B,MAAM,YACF,MAAM,gBACF,MAAM,GAAG,SAAS,KACjC,OAAO,CAAC,qBAAqB,CA6N/B,CAAC"}
@@ -127,7 +127,7 @@ const performDatabricksOAuthFlow = async (host, clientId, clientSecret) => {
127
127
  authSpinner.fail(` Databricks authentication failed`);
128
128
  throw e;
129
129
  }
130
- globalState_1.default.debug(`> Got authorization code ${code.substring(0, 10)}...`);
130
+ globalState_1.default.debug('> Got authorization code [redacted]');
131
131
  // Exchange the authorization code for tokens
132
132
  const tokenUrl = new url_1.URL('/oidc/v1/token', `https://${host}`);
133
133
  // Build token request parameters
@@ -160,8 +160,8 @@ const performDatabricksOAuthFlow = async (host, clientId, clientSecret) => {
160
160
  if (!accessToken || !refreshToken) {
161
161
  throw new common_1.AuthorizationError('No access token or refresh token received from Databricks');
162
162
  }
163
- globalState_1.default.debug(`> OAuth access token: ${accessToken.substring(0, 10)}...`);
164
- globalState_1.default.debug(`> OAuth refresh token: ${refreshToken.substring(0, 10)}...`);
163
+ globalState_1.default.debug('> OAuth access token: [redacted]');
164
+ globalState_1.default.debug('> OAuth refresh token: [redacted]');
165
165
  // Calculate expiration timestamp (current time + expires_in)
166
166
  const expiresAt = Math.floor(Date.now() / 1000) + expiresIn;
167
167
  console.error(`${styles.success('āœ”')} Successfully authenticated with Databricks`);
@@ -0,0 +1,2 @@
1
+ export declare const errorHandler: (err: Error) => never;
2
+ //# sourceMappingURL=errorHandler.fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandler.fixture.d.ts","sourceRoot":"","sources":["../src/errorHandler.fixture.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,QAAS,KAAK,UA0DtC,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorHandler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@lightdash/common");
6
+ const commander_1 = require("commander");
7
+ const credentials_1 = require("./credentials");
8
+ const env_1 = require("./env");
9
+ const error_1 = require("./error");
10
+ const styles = tslib_1.__importStar(require("./styles"));
11
+ const errorHandler = (err) => {
12
+ const errorMessage = (0, common_1.getErrorMessage)(err) || 'An unexpected error occurred';
13
+ console.error(styles.error(errorMessage));
14
+ if (err.name === 'ForbiddenError' || err instanceof common_1.ForbiddenError) {
15
+ const permissionMessage = err.message || "You don't have permission to perform this action";
16
+ if (permissionMessage !== errorMessage) {
17
+ console.error(styles.error(permissionMessage));
18
+ }
19
+ console.error(`\nšŸ’” Contact your Lightdash administrator to request project creation access or if you believe this is incorrect.\n`);
20
+ }
21
+ else if (err.name === 'AuthorizationError' &&
22
+ commander_1.program.opts().agentConnection === undefined &&
23
+ (0, credentials_1.getAgentConnectionSelection)() === null) {
24
+ console.error(`Looks like you did not authenticate or the personal access token expired.${process.env.LIGHTDASH_API_KEY
25
+ ? `\n\nLIGHTDASH_API_KEY is set, and it takes precedence over the token saved by \`lightdash login\`. If you expected your saved login to be used, run ${styles.bold('unset LIGHTDASH_API_KEY')}.`
26
+ : ''}\n\nšŸ‘€ See https://docs.lightdash.com/guides/cli/cli-authentication for help and examples`);
27
+ }
28
+ else if (!(err instanceof common_1.LightdashError)) {
29
+ console.error(err);
30
+ if (err.stack) {
31
+ console.error(err.stack);
32
+ }
33
+ console.error('\nReport this issue with 1-click:\n');
34
+ console.error(` šŸ› https://github.com/lightdash/lightdash/issues/new?assignees=&labels=šŸ›+bug&template=bug_report.md&title=${encodeURIComponent(err.message)}`);
35
+ }
36
+ if (err.message.includes('ENOENT: dbt')) {
37
+ console.error(styles.error(`\n You must have dbt installed to use this command. See https://docs.getdbt.com/docs/core/installation for installation instructions`));
38
+ }
39
+ const diagnosticsHint = (0, error_1.getDiagnosticsHint)();
40
+ if (diagnosticsHint) {
41
+ console.error(diagnosticsHint);
42
+ }
43
+ if (env_1.NODE_VERSION.major !== env_1.OPTIMIZED_NODE_VERSION) {
44
+ console.warn(styles.warning(`āš ļø You are using Node.js version ${process.version}. Lightdash CLI is optimized for v${env_1.OPTIMIZED_NODE_VERSION} so you might experience issues.`));
45
+ }
46
+ process.exit(1);
47
+ };
48
+ exports.errorHandler = errorHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"agentConnectionConnect.d.ts","sourceRoot":"","sources":["../../src/handlers/agentConnectionConnect.ts"],"names":[],"mappings":"AAQA,OAAO,EAEH,KAAK,wBAAwB,EAChC,MAAM,mCAAmC,CAAC;AAyG3C,eAAO,MAAM,6BAA6B,YAC7B,wBAAwB,iBACnB;IAAE,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,KAGnE,OAAO,CAAC,IAAI,CA+Xd,CAAC"}
1
+ {"version":3,"file":"agentConnectionConnect.d.ts","sourceRoot":"","sources":["../../src/handlers/agentConnectionConnect.ts"],"names":[],"mappings":"AAQA,OAAO,EAEH,KAAK,wBAAwB,EAChC,MAAM,mCAAmC,CAAC;AA2G3C,eAAO,MAAM,6BAA6B,YAC7B,wBAAwB,iBACnB;IAAE,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,KAGnE,OAAO,CAAC,IAAI,CA8Yd,CAAC"}