@lightdash/cli 0.1977.1 → 0.1979.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.
@@ -57,11 +57,7 @@ const askPermissionToStoreWarehouseCredentials = async () => {
|
|
57
57
|
return savedAnswer;
|
58
58
|
};
|
59
59
|
const createProject = async (options) => {
|
60
|
-
|
61
|
-
// await checkProjectCreationPermission(
|
62
|
-
// options.upstreamProjectUuid,
|
63
|
-
// options.type,
|
64
|
-
// );
|
60
|
+
await (0, apiClient_1.checkProjectCreationPermission)(options.upstreamProjectUuid, options.type);
|
65
61
|
const dbtVersion = await (0, getDbtVersion_1.getDbtVersion)();
|
66
62
|
const absoluteProjectPath = path_1.default.resolve(options.projectDir);
|
67
63
|
const context = await (0, context_1.getDbtContext)({ projectDir: absoluteProjectPath });
|
@@ -60,15 +60,46 @@ const checkProjectCreationPermission = async (upstreamProjectUuid, projectType)
|
|
60
60
|
if (!user.organizationUuid) {
|
61
61
|
throw new common_1.ForbiddenError(`You don't have permission to create projects.`);
|
62
62
|
}
|
63
|
-
//
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
// Replicates logic from ProjectService.validateProjectCreationPermissions
|
64
|
+
switch (projectType) {
|
65
|
+
case common_1.ProjectType.DEFAULT:
|
66
|
+
if (ability.can('create', (0, ability_1.subject)('Project', {
|
67
|
+
organizationUuid: user.organizationUuid,
|
68
|
+
type: common_1.ProjectType.DEFAULT,
|
69
|
+
}))) {
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
throw new common_1.ForbiddenError("You don't have permission to create projects");
|
73
|
+
case common_1.ProjectType.PREVIEW:
|
74
|
+
if (upstreamProjectUuid) {
|
75
|
+
if (
|
76
|
+
// checks if user has permission to access upstream project
|
77
|
+
ability.cannot('view', (0, ability_1.subject)('Project', {
|
78
|
+
organizationUuid: user.organizationUuid,
|
79
|
+
projectUuid: upstreamProjectUuid,
|
80
|
+
}))) {
|
81
|
+
throw new common_1.ForbiddenError("Unable to create preview project: you don't have permission to access upstream project");
|
82
|
+
}
|
83
|
+
if (
|
84
|
+
// checks if user has permission to create project from an upstream project on a project level
|
85
|
+
ability.can('create', (0, ability_1.subject)('Project', {
|
86
|
+
upstreamProjectUuid,
|
87
|
+
type: common_1.ProjectType.PREVIEW,
|
88
|
+
}))) {
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
if (
|
93
|
+
// checks if user has permission to create project on an organization level
|
94
|
+
ability.can('create', (0, ability_1.subject)('Project', {
|
95
|
+
organizationUuid: user.organizationUuid,
|
96
|
+
type: common_1.ProjectType.PREVIEW,
|
97
|
+
}))) {
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
throw new common_1.ForbiddenError("You don't have permission to create preview projects");
|
101
|
+
default:
|
102
|
+
throw new Error(`Unknown project type: ${projectType}`);
|
72
103
|
}
|
73
104
|
}
|
74
105
|
catch (err) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lightdash/cli",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.1979.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"bin": {
|
6
6
|
"lightdash": "dist/index.js"
|
@@ -32,8 +32,8 @@
|
|
32
32
|
"parse-node-version": "^2.0.0",
|
33
33
|
"unique-names-generator": "^4.7.1",
|
34
34
|
"uuid": "^11.0.3",
|
35
|
-
"@lightdash/common": "0.
|
36
|
-
"@lightdash/warehouses": "0.
|
35
|
+
"@lightdash/common": "0.1979.0",
|
36
|
+
"@lightdash/warehouses": "0.1979.0"
|
37
37
|
},
|
38
38
|
"description": "Lightdash CLI tool",
|
39
39
|
"devDependencies": {
|