@lightdash/cli 0.1374.2 → 0.1375.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,4 @@
|
|
1
|
-
import { ProjectType, type
|
1
|
+
import { ProjectType, type CreateProjectResult } 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<
|
12
|
+
export declare const createProject: (options: CreateProjectOptions) => Promise<undefined | CreateProjectResult>;
|
13
13
|
export {};
|
@@ -54,6 +54,30 @@ 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
|
+
};
|
57
81
|
const createProject = async (options) => {
|
58
82
|
const dbtVersion = await (0, getDbtVersion_1.getSupportedDbtVersion)();
|
59
83
|
const absoluteProjectPath = path_1.default.resolve(options.projectDir);
|
@@ -88,7 +112,7 @@ const createProject = async (options) => {
|
|
88
112
|
}
|
89
113
|
spinner?.start();
|
90
114
|
}
|
91
|
-
const
|
115
|
+
const payload = {
|
92
116
|
name: options.name,
|
93
117
|
type: options.type,
|
94
118
|
warehouseConnection: {
|
@@ -104,10 +128,24 @@ const createProject = async (options) => {
|
|
104
128
|
upstreamProjectUuid: options.upstreamProjectUuid,
|
105
129
|
dbtVersion,
|
106
130
|
};
|
107
|
-
|
131
|
+
const scheduleProjectCreationJob = await (0, apiClient_1.lightdashApi)({
|
108
132
|
method: 'POST',
|
109
133
|
url: `/api/v1/org/projects`,
|
110
|
-
body: JSON.stringify(
|
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,
|
111
145
|
});
|
146
|
+
return {
|
147
|
+
project,
|
148
|
+
hasContentCopy: jobResult.details?.hasContentCopy ?? false,
|
149
|
+
};
|
112
150
|
};
|
113
151
|
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").
|
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 | {
|
28
28
|
savedSqlUuid: string;
|
29
29
|
slug: string;
|
30
30
|
} | {
|
@@ -49,6 +49,8 @@ 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;
|
52
54
|
} | null | undefined>({ method, url, body, }: LightdashApiProps) => Promise<T>;
|
53
55
|
export declare const checkLightdashVersion: () => Promise<void>;
|
54
56
|
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lightdash/cli",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.1375.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.
|
15
|
-
"@lightdash/warehouses": "^0.
|
14
|
+
"@lightdash/common": "^0.1375.0",
|
15
|
+
"@lightdash/warehouses": "^0.1375.0",
|
16
16
|
"@types/columnify": "^1.5.1",
|
17
17
|
"ajv": "^8.11.0",
|
18
18
|
"ajv-formats": "^2.1.1",
|