@lightdash/cli 0.1377.3 → 0.1378.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- import { ProjectType, type CreateProjectResult } from '@lightdash/common';
1
+ import { ProjectType, type ApiCreateProjectResults } from '@lightdash/common';
2
2
  type CreateProjectOptions = {
3
3
  name: string;
4
4
  projectDir: string;
@@ -9,5 +9,5 @@ type CreateProjectOptions = {
9
9
  startOfWeek?: number;
10
10
  upstreamProjectUuid?: string;
11
11
  };
12
- export declare const createProject: (options: CreateProjectOptions) => Promise<undefined | CreateProjectResult>;
12
+ export declare const createProject: (options: CreateProjectOptions) => Promise<ApiCreateProjectResults | undefined>;
13
13
  export {};
@@ -54,30 +54,6 @@ const askPermissionToStoreWarehouseCredentials = async () => {
54
54
  }
55
55
  return savedAnswer;
56
56
  };
57
- const pollJobStatus = async (jobId, maxAttempts = 30, interval = 3000) => {
58
- let attempts = 0;
59
- while (attempts < maxAttempts) {
60
- // eslint-disable-next-line no-await-in-loop
61
- const jobResult = await (0, apiClient_1.lightdashApi)({
62
- method: 'GET',
63
- url: `/api/v1/schedulers/job/${jobId}/status`,
64
- body: undefined,
65
- });
66
- if (jobResult.status === common_1.SchedulerJobStatus.ERROR) {
67
- console.error(styles.error('Project creation failed'));
68
- return jobResult;
69
- }
70
- if (jobResult.status === common_1.SchedulerJobStatus.COMPLETED) {
71
- return jobResult;
72
- }
73
- attempts += 1;
74
- // eslint-disable-next-line no-await-in-loop
75
- await new Promise((resolve) => {
76
- setTimeout(resolve, interval);
77
- });
78
- }
79
- throw new Error('Job polling exceeded maximum attempts');
80
- };
81
57
  const createProject = async (options) => {
82
58
  const dbtVersion = await (0, getDbtVersion_1.getSupportedDbtVersion)();
83
59
  const absoluteProjectPath = path_1.default.resolve(options.projectDir);
@@ -112,7 +88,7 @@ const createProject = async (options) => {
112
88
  }
113
89
  spinner?.start();
114
90
  }
115
- const payload = {
91
+ const project = {
116
92
  name: options.name,
117
93
  type: options.type,
118
94
  warehouseConnection: {
@@ -128,24 +104,10 @@ const createProject = async (options) => {
128
104
  upstreamProjectUuid: options.upstreamProjectUuid,
129
105
  dbtVersion,
130
106
  };
131
- const scheduleProjectCreationJob = await (0, apiClient_1.lightdashApi)({
107
+ return (0, apiClient_1.lightdashApi)({
132
108
  method: 'POST',
133
109
  url: `/api/v1/org/projects`,
134
- body: JSON.stringify(payload),
135
- });
136
- const jobResult = await pollJobStatus(scheduleProjectCreationJob.jobId);
137
- const projectUuid = jobResult.details?.projectUuid;
138
- if (!projectUuid) {
139
- throw new Error('Project creation failed');
140
- }
141
- const project = await (0, apiClient_1.lightdashApi)({
142
- method: 'GET',
143
- url: `/api/v1/projects/${projectUuid}`,
144
- body: undefined,
110
+ body: JSON.stringify(project),
145
111
  });
146
- return {
147
- project,
148
- hasContentCopy: jobResult.details?.hasContentCopy ?? false,
149
- };
150
112
  };
151
113
  exports.createProject = createProject;
@@ -24,7 +24,7 @@ export declare const lightdashApi: <T extends string | boolean | unknown[] | imp
24
24
  jobId: string;
25
25
  } | Pick<import("@lightdash/common").SshKeyPair, "publicKey"> | import("@lightdash/common").MostPopularAndRecentlyUpdated | Record<string, number> | Record<string, import("@lightdash/common").DbtExposure> | {
26
26
  [dashboardTileUuid: string]: import("@lightdash/common").Comment[];
27
- } | import("@lightdash/common").ApiResolveComment | import("@lightdash/common").ApiSuccessEmpty | import("@lightdash/common").DashboardSummary | import("@lightdash/common").CatalogMetadata | import("@lightdash/common").CatalogAnalytics | import("@lightdash/common").PromotionChanges | import("@lightdash/common").WarehouseTableSchema | import("@lightdash/common").TogglePinnedItemInfo | import("@lightdash/common").KnexPaginatedData<import("@lightdash/common").OrganizationMemberProfile[]> | import("@lightdash/common").SqlChart | {
27
+ } | import("@lightdash/common").ApiResolveComment | import("@lightdash/common").ApiSuccessEmpty | import("@lightdash/common").ApiCreateProjectResults | import("@lightdash/common").DashboardSummary | import("@lightdash/common").CatalogMetadata | import("@lightdash/common").CatalogAnalytics | import("@lightdash/common").PromotionChanges | import("@lightdash/common").WarehouseTableSchema | import("@lightdash/common").TogglePinnedItemInfo | import("@lightdash/common").KnexPaginatedData<import("@lightdash/common").OrganizationMemberProfile[]> | import("@lightdash/common").SqlChart | {
28
28
  savedSqlUuid: string;
29
29
  slug: string;
30
30
  } | {
@@ -49,8 +49,6 @@ export declare const lightdashApi: <T extends string | boolean | unknown[] | imp
49
49
  owner: string;
50
50
  } | import("@lightdash/common").KnexPaginatedData<import("@lightdash/common").ApiMetricsCatalogResults> | import("@lightdash/common").KnexPaginatedData<import("@lightdash/common").Group[] | import("@lightdash/common").GroupWithMembers[]> | {
51
51
  tagUuid: string;
52
- } | {
53
- jobId: string;
54
52
  } | null | undefined>({ method, url, body, }: LightdashApiProps) => Promise<T>;
55
53
  export declare const checkLightdashVersion: () => Promise<void>;
56
54
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.1377.3",
3
+ "version": "0.1378.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "lightdash": "dist/index.js"
@@ -11,8 +11,8 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "@actions/core": "^1.11.1",
14
- "@lightdash/common": "^0.1377.3",
15
- "@lightdash/warehouses": "^0.1377.3",
14
+ "@lightdash/common": "^0.1378.0",
15
+ "@lightdash/warehouses": "^0.1378.0",
16
16
  "@types/columnify": "^1.5.1",
17
17
  "ajv": "^8.11.0",
18
18
  "ajv-formats": "^2.1.1",