@lightdash/cli 0.2118.1 → 0.2120.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.
@@ -1,4 +1,5 @@
1
1
  import { CreateProjectTableConfiguration, ProjectType, type ApiCreateProjectResults } from '@lightdash/common';
2
+ export declare const resolveOrganizationCredentialsName: (name: string) => Promise<string>;
2
3
  type CreateProjectOptions = {
3
4
  name: string;
4
5
  projectDir: string;
@@ -11,6 +12,7 @@ type CreateProjectOptions = {
11
12
  tableConfiguration?: CreateProjectTableConfiguration;
12
13
  copyContent?: boolean;
13
14
  warehouseCredentials?: boolean;
15
+ organizationCredentials?: string;
14
16
  };
15
17
  export declare const createProject: (options: CreateProjectOptions) => Promise<ApiCreateProjectResults | undefined>;
16
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/handlers/createProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,+BAA+B,EAE/B,WAAW,EAEX,KAAK,uBAAuB,EAE/B,MAAM,mBAAmB,CAAC;AA2D3B,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,+BAA+B,CAAC;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,aAAa,YACb,oBAAoB,KAC9B,OAAO,CAAC,uBAAuB,GAAG,SAAS,CA8F7C,CAAC"}
1
+ {"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/handlers/createProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,+BAA+B,EAE/B,WAAW,EAEX,KAAK,uBAAuB,EAG/B,MAAM,mBAAmB,CAAC;AA2D3B,eAAO,MAAM,kCAAkC,SACrC,MAAM,KACb,OAAO,CAAC,MAAM,CAyChB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,+BAA+B,CAAC;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,aAAa,YACb,oBAAoB,KAC9B,OAAO,CAAC,uBAAuB,GAAG,SAAS,CA2H7C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createProject = void 0;
3
+ exports.createProject = exports.resolveOrganizationCredentialsName = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@lightdash/common");
6
6
  const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
@@ -56,14 +56,61 @@ const askPermissionToStoreWarehouseCredentials = async () => {
56
56
  }
57
57
  return savedAnswer;
58
58
  };
59
+ const resolveOrganizationCredentialsName = async (name) => {
60
+ globalState_1.default.debug(`> Resolving organization warehouse credentials: ${name}`);
61
+ try {
62
+ const credentialsList = await (0, apiClient_1.lightdashApi)({
63
+ method: 'GET',
64
+ url: '/api/v1/org/warehouse-credentials?summary=true',
65
+ body: undefined,
66
+ });
67
+ const credential = credentialsList.find((cred) => cred.name === name);
68
+ if (!credential) {
69
+ const availableNames = credentialsList.length > 0
70
+ ? credentialsList
71
+ .map((c) => ` - ${c.name} (${c.warehouseType})`)
72
+ .join('\n')
73
+ : ' (none available)';
74
+ throw new Error(`Organization warehouse credentials "${name}" not found.\n\nAvailable credentials:\n${availableNames}`);
75
+ }
76
+ globalState_1.default.debug(`> Resolved "${name}" to UUID: ${credential.organizationWarehouseCredentialsUuid}`);
77
+ return credential.organizationWarehouseCredentialsUuid;
78
+ }
79
+ catch (error) {
80
+ if (error instanceof Error) {
81
+ throw error;
82
+ }
83
+ throw new Error('Failed to resolve organization warehouse credentials. This may be an Enterprise Edition feature that is not available.');
84
+ }
85
+ };
86
+ exports.resolveOrganizationCredentialsName = resolveOrganizationCredentialsName;
59
87
  const createProject = async (options) => {
60
88
  await (0, apiClient_1.checkProjectCreationPermission)(options.upstreamProjectUuid, options.type);
89
+ // Resolve organization credentials early before doing any heavy work
90
+ let organizationWarehouseCredentialsUuid;
91
+ if (options.organizationCredentials) {
92
+ organizationWarehouseCredentialsUuid =
93
+ await (0, exports.resolveOrganizationCredentialsName)(options.organizationCredentials);
94
+ }
61
95
  const dbtVersion = await (0, getDbtVersion_1.getDbtVersion)();
62
96
  const absoluteProjectPath = path_1.default.resolve(options.projectDir);
63
97
  const context = await (0, context_1.getDbtContext)({ projectDir: absoluteProjectPath });
64
98
  let targetName;
65
99
  let credentials;
66
- if (options.warehouseCredentials === false) {
100
+ // If using organization credentials, don't load warehouse credentials from profiles
101
+ if (organizationWarehouseCredentialsUuid) {
102
+ globalState_1.default.debug(`> Using organization warehouse credentials: ${options.organizationCredentials}`);
103
+ // Still need to get target name for dbt connection
104
+ globalState_1.default.debug(`> Using profiles dir ${options.profilesDir} and profile ${options.profile || context.profileName}`);
105
+ targetName = await (0, getDbtProfileTargetName_1.default)({
106
+ isDbtCloudCLI: dbtVersion.isDbtCloudCLI,
107
+ profilesDir: options.profilesDir,
108
+ profile: options.profile || context.profileName,
109
+ target: options.target,
110
+ });
111
+ globalState_1.default.debug(`> Using target name ${targetName}`);
112
+ }
113
+ else if (options.warehouseCredentials === false) {
67
114
  globalState_1.default.debug('> Creating project without warehouse credentials');
68
115
  }
69
116
  else {
@@ -119,6 +166,7 @@ const createProject = async (options) => {
119
166
  dbtVersion: dbtVersion.versionOption,
120
167
  tableConfiguration: options.tableConfiguration,
121
168
  copyContent: options.copyContent,
169
+ organizationWarehouseCredentialsUuid,
122
170
  };
123
171
  return (0, apiClient_1.lightdashApi)({
124
172
  method: 'POST',
@@ -10,6 +10,7 @@ type DeployHandlerOptions = DbtCompileOptions & {
10
10
  ignoreErrors: boolean;
11
11
  startOfWeek?: number;
12
12
  warehouseCredentials?: boolean;
13
+ organizationCredentials?: string;
13
14
  };
14
15
  type DeployArgs = DeployHandlerOptions & {
15
16
  projectUuid: string;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/handlers/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EACP,YAAY,EAOf,MAAM,mBAAmB,CAAC;AAc3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,KAAK,oBAAoB,GAAG,iBAAiB,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,KAAK,UAAU,GAAG,oBAAoB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAkCF,eAAO,MAAM,MAAM,aACL,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,WAC3B,UAAU,KACpB,OAAO,CAAC,IAAI,CA2Cd,CAAC;AAwFF,eAAO,MAAM,aAAa,oBAA2B,oBAAoB,kBA8DxE,CAAC"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/handlers/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EACP,YAAY,EAOf,MAAM,mBAAmB,CAAC;AAiB3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,KAAK,oBAAoB,GAAG,iBAAiB,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,KAAK,UAAU,GAAG,oBAAoB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAkCF,eAAO,MAAM,MAAM,aACL,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,WAC3B,UAAU,KACpB,OAAO,CAAC,IAAI,CA2Cd,CAAC;AAwFF,eAAO,MAAM,aAAa,oBAA2B,oBAAoB,kBA+ExE,CAAC"}
@@ -149,6 +149,16 @@ const deployHandler = async (originalOptions) => {
149
149
  options.skipDbtCompile = true;
150
150
  options.skipWarehouseCatalog = true;
151
151
  }
152
+ // Resolve organization credentials early before doing any heavy work
153
+ if (options.organizationCredentials) {
154
+ try {
155
+ await (0, createProject_1.resolveOrganizationCredentialsName)(options.organizationCredentials);
156
+ }
157
+ catch (error) {
158
+ console.error(styles.error(error instanceof Error ? error.message : 'Unknown error'));
159
+ process.exit(1);
160
+ }
161
+ }
152
162
  const dbtVersion = await (0, getDbtVersion_1.getDbtVersion)();
153
163
  await (0, apiClient_1.checkLightdashVersion)();
154
164
  const executionId = (0, uuid_1.v4)();
@@ -11,6 +11,7 @@ type PreviewHandlerOptions = DbtCompileOptions & {
11
11
  ignoreErrors: boolean;
12
12
  tableConfiguration: CreateProjectTableConfiguration;
13
13
  skipCopyContent?: boolean;
14
+ organizationCredentials?: string;
14
15
  };
15
16
  type StopPreviewHandlerOptions = {
16
17
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/handlers/preview.ts"],"names":[],"mappings":"AACA,OAAO,EACH,+BAA+B,EAGlC,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,KAAK,qBAAqB,GAAG,iBAAiB,GAAG;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAyEF,eAAO,MAAM,cAAc,YACd,qBAAqB,KAC/B,OAAO,CAAC,IAAI,CA4Ld,CAAC;AAEF,eAAO,MAAM,mBAAmB,YACnB,qBAAqB,KAC/B,OAAO,CAAC,IAAI,CAwHd,CAAC;AAEF,eAAO,MAAM,kBAAkB,YAClB,yBAAyB,KACnC,OAAO,CAAC,IAAI,CA0Cd,CAAC"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/handlers/preview.ts"],"names":[],"mappings":"AACA,OAAO,EACH,+BAA+B,EAGlC,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,KAAK,qBAAqB,GAAG,iBAAiB,GAAG;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAyEF,eAAO,MAAM,cAAc,YACd,qBAAqB,KAC/B,OAAO,CAAC,IAAI,CA4Ld,CAAC;AAEF,eAAO,MAAM,mBAAmB,YACnB,qBAAqB,KAC/B,OAAO,CAAC,IAAI,CAwHd,CAAC;AAEF,eAAO,MAAM,kBAAkB,YAClB,yBAAyB,KACnC,OAAO,CAAC,IAAI,CA0Cd,CAAC"}
package/dist/index.js CHANGED
@@ -182,6 +182,7 @@ commander_1.program
182
182
  .option('--ignore-errors', 'Allows deploy with errors on compile', false)
183
183
  .option('--table-configuration <prod|all>', `If set to 'prod' it will copy the table configuration from prod project`, 'all')
184
184
  .option('--skip-copy-content', 'Skip copying content from the source project', false)
185
+ .option('--organization-credentials <name>', 'Use organization warehouse credentials with the specified name (Enterprise Edition feature)')
185
186
  .action(preview_1.previewHandler);
186
187
  commander_1.program
187
188
  .command('start-preview')
@@ -263,6 +264,7 @@ commander_1.program
263
264
  .option('--skip-warehouse-catalog', 'Skip fetch warehouse catalog and use types in yml', false)
264
265
  .option('--use-dbt-list [true|false]', 'Use `dbt list` instead of `dbt compile` to generate dbt manifest.json', parseUseDbtListOption, true)
265
266
  .option('--no-warehouse-credentials', 'Create project without warehouse credentials. Skips dbt compile + warehouse catalog')
267
+ .option('--organization-credentials <name>', 'Use organization warehouse credentials with the specified name (Enterprise Edition feature)')
266
268
  .action(deploy_1.deployHandler);
267
269
  commander_1.program
268
270
  .command('refresh')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.2118.1",
3
+ "version": "0.2120.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "lightdash": "dist/index.js"
@@ -33,8 +33,8 @@
33
33
  "parse-node-version": "^2.0.0",
34
34
  "unique-names-generator": "^4.7.1",
35
35
  "uuid": "^11.0.3",
36
- "@lightdash/common": "0.2118.1",
37
- "@lightdash/warehouses": "0.2118.1"
36
+ "@lightdash/common": "0.2120.0",
37
+ "@lightdash/warehouses": "0.2120.0"
38
38
  },
39
39
  "description": "Lightdash CLI tool",
40
40
  "devDependencies": {