@lightdash/cli 2.270.0 → 2.271.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.
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/handlers/contentAsCode/registry.d.ts.map +1 -1
- package/dist/handlers/contentAsCode/registry.js +2 -0
- package/dist/handlers/organizationContent/index.d.ts.map +1 -1
- package/dist/handlers/organizationContent/index.js +19 -0
- package/dist/handlers/organizationContent/userAttributes.d.ts +7 -0
- package/dist/handlers/organizationContent/userAttributes.d.ts.map +1 -0
- package/dist/handlers/organizationContent/userAttributes.js +52 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/handlers/contentAsCode/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,yBAAyB,EACjC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/handlers/contentAsCode/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,yBAAyB,EACjC,MAAM,mBAAmB,CAAC;AAgB3B,MAAM,MAAM,wBAAwB,GAAG;IACnC,IAAI,EAAE,yBAAyB,CAAC;IAChC,YAAY,EAAE,SAAS,yBAAyB,EAAE,CAAC;CACtD,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,SAAS,wBAAwB,EAOtE,CAAC;AAEN,eAAO,MAAM,sBAAsB,EAAE,SAAS,wBAAwB,EAyBrE,CAAC;AAEF,eAAO,MAAM,iCAAiC,cAC/B,SAAS,wBAAwB,EAAE,KAC/C,IAeF,CAAC"}
|
|
@@ -5,12 +5,14 @@ const common_1 = require("@lightdash/common");
|
|
|
5
5
|
const customRoles_1 = require("../organizationContent/customRoles");
|
|
6
6
|
const groups_1 = require("../organizationContent/groups");
|
|
7
7
|
const themes_1 = require("../organizationContent/themes");
|
|
8
|
+
const userAttributes_1 = require("../organizationContent/userAttributes");
|
|
8
9
|
const users_1 = require("../organizationContent/users");
|
|
9
10
|
const projectResources_1 = require("./projectResources");
|
|
10
11
|
exports.ORGANIZATION_CODE_RESOURCES = [
|
|
11
12
|
customRoles_1.CUSTOM_ROLE_CODE_RESOURCE,
|
|
12
13
|
users_1.USER_CODE_RESOURCE,
|
|
13
14
|
groups_1.GROUP_CODE_RESOURCE,
|
|
15
|
+
userAttributes_1.USER_ATTRIBUTE_CODE_RESOURCE,
|
|
14
16
|
themes_1.THEME_CODE_RESOURCE,
|
|
15
17
|
];
|
|
16
18
|
exports.PROJECT_CODE_RESOURCES = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handlers/organizationContent/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handlers/organizationContent/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAqC3C,KAAK,0BAA0B,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAqBF,eAAO,MAAM,4BAA4B,gBAAiB,MAAM,KAAG,MAClC,CAAC;AAElC,eAAO,MAAM,2BAA2B,4BAGrC,0BAA0B,KAAG,OAAO,CAAC,IAAI,CA2G3C,CAAC;AAEF,eAAO,MAAM,yBAAyB,yCAInC,0BAA0B,KAAG,OAAO,CAAC,IAAI,CAoM3C,CAAC"}
|
|
@@ -13,6 +13,7 @@ const contentAsCodePaths_1 = require("../contentAsCodePaths");
|
|
|
13
13
|
const customRoles_1 = require("./customRoles");
|
|
14
14
|
const groups_1 = require("./groups");
|
|
15
15
|
const themes_1 = require("./themes");
|
|
16
|
+
const userAttributes_1 = require("./userAttributes");
|
|
16
17
|
const users_1 = require("./users");
|
|
17
18
|
const createCustomRolePartialUploadError = (message) => new resource_1.CodeResourcePhaseError('custom_role', message);
|
|
18
19
|
const createUserPartialUploadError = (message) => new resource_1.CodeResourcePhaseError('user', message);
|
|
@@ -67,6 +68,11 @@ const downloadOrganizationContent = async ({ customPath, config, }) => {
|
|
|
67
68
|
output.completeItem('service unavailable', 'warning');
|
|
68
69
|
globalState_1.default.debug('> Warning: groups were not downloaded because the group service is not enabled');
|
|
69
70
|
}
|
|
71
|
+
const userAttributesTotal = await output.runItem({
|
|
72
|
+
label: 'User attributes',
|
|
73
|
+
action: () => (0, userAttributes_1.downloadUserAttributes)(organizationUuid, organizationContentPath),
|
|
74
|
+
detail: (total) => `${total} downloaded`,
|
|
75
|
+
});
|
|
70
76
|
const themesTotal = await output.runItem({
|
|
71
77
|
label: 'Themes',
|
|
72
78
|
action: () => (0, themes_1.downloadThemes)(organizationContentPath),
|
|
@@ -86,6 +92,7 @@ const downloadOrganizationContent = async ({ customPath, config, }) => {
|
|
|
86
92
|
usersNum: usersTotal,
|
|
87
93
|
groupsNum: groupsTotal,
|
|
88
94
|
themesNum: themesTotal,
|
|
95
|
+
userAttributesNum: userAttributesTotal,
|
|
89
96
|
timeToCompleted: (Date.now() - start) / 1000,
|
|
90
97
|
},
|
|
91
98
|
});
|
|
@@ -161,6 +168,15 @@ const uploadOrganizationContent = async ({ customPath, config, sendInvites = fal
|
|
|
161
168
|
throw createGroupPartialUploadError(`Processed groups: ${groupSummaryMessage}`);
|
|
162
169
|
}
|
|
163
170
|
output.completeItem(groupSummaryMessage);
|
|
171
|
+
output.startItem('User attributes');
|
|
172
|
+
const userAttributeSummary = await (0, userAttributes_1.uploadUserAttributes)(organizationUuid, organizationContentPath);
|
|
173
|
+
const userAttributeSummaryMessage = (0, userAttributes_1.formatUserAttributeUploadSummary)(userAttributeSummary);
|
|
174
|
+
if (userAttributeSummary.failed > 0) {
|
|
175
|
+
userAttributeSummary.failures.forEach(({ message }) => globalState_1.default.log(styles.error(message)));
|
|
176
|
+
output.prepareForFailureDetails();
|
|
177
|
+
throw new resource_1.CodeResourcePhaseError('user_attribute', `Processed user attributes: ${userAttributeSummaryMessage}`);
|
|
178
|
+
}
|
|
179
|
+
output.completeItem(userAttributeSummaryMessage);
|
|
164
180
|
output.startItem('Themes');
|
|
165
181
|
const themeSummary = await (0, themes_1.uploadThemes)(preparedThemes);
|
|
166
182
|
const themeSummaryMessage = (0, themes_1.formatThemeUploadSummary)(themeSummary);
|
|
@@ -194,6 +210,9 @@ const uploadOrganizationContent = async ({ customPath, config, sendInvites = fal
|
|
|
194
210
|
groupsCreated: groupSummary.created,
|
|
195
211
|
groupsUpdated: groupSummary.updated,
|
|
196
212
|
groupsUnchanged: groupSummary.unchanged,
|
|
213
|
+
userAttributesCreated: userAttributeSummary.created,
|
|
214
|
+
userAttributesUpdated: userAttributeSummary.updated,
|
|
215
|
+
userAttributesUnchanged: userAttributeSummary.unchanged,
|
|
197
216
|
themesCreated: themeSummary.created,
|
|
198
217
|
themesUpdated: themeSummary.updated,
|
|
199
218
|
themesUnchanged: themeSummary.unchanged,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type UserAttributeAsCode } from '@lightdash/common';
|
|
2
|
+
import { type CodeResourceDefinition, type CodeResourceUploadSummary } from '../contentAsCode/resource';
|
|
3
|
+
export declare const USER_ATTRIBUTE_CODE_RESOURCE: CodeResourceDefinition<UserAttributeAsCode>;
|
|
4
|
+
export declare const formatUserAttributeUploadSummary: (summary: CodeResourceUploadSummary) => string;
|
|
5
|
+
export declare const downloadUserAttributes: (organizationUuid: string, organizationContentPath: string) => Promise<number>;
|
|
6
|
+
export declare const uploadUserAttributes: (organizationUuid: string, organizationContentPath: string) => Promise<CodeResourceUploadSummary>;
|
|
7
|
+
//# sourceMappingURL=userAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userAttributes.d.ts","sourceRoot":"","sources":["../../../src/handlers/organizationContent/userAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,mBAAmB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGH,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EACjC,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,4BAA4B,EAAE,sBAAsB,CAAC,mBAAmB,CAkBhF,CAAC;AAEN,eAAO,MAAM,gCAAgC,YAChC,yBAAyB,KACnC,MACmH,CAAC;AAEvH,eAAO,MAAM,sBAAsB,qBACb,MAAM,2BACC,MAAM,KAChC,OAAO,CAAC,MAAM,CAcX,CAAC;AAEP,eAAO,MAAM,oBAAoB,qBACX,MAAM,2BACC,MAAM,KAChC,OAAO,CAAC,yBAAyB,CAc9B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadUserAttributes = exports.downloadUserAttributes = exports.formatUserAttributeUploadSummary = exports.USER_ATTRIBUTE_CODE_RESOURCE = void 0;
|
|
4
|
+
const common_1 = require("@lightdash/common");
|
|
5
|
+
const resource_1 = require("../contentAsCode/resource");
|
|
6
|
+
const apiClient_1 = require("../dbt/apiClient");
|
|
7
|
+
exports.USER_ATTRIBUTE_CODE_RESOURCE = {
|
|
8
|
+
kind: 'user_attribute',
|
|
9
|
+
displayLabel: 'user attribute',
|
|
10
|
+
identityLabel: 'name',
|
|
11
|
+
scope: 'organization',
|
|
12
|
+
folderName: 'user_attributes',
|
|
13
|
+
acceptedExtensions: ['.yml', '.yaml'],
|
|
14
|
+
fileName: {
|
|
15
|
+
strategy: 'uriEncodedIdentity',
|
|
16
|
+
fallbackPrefix: 'user-attribute',
|
|
17
|
+
extension: '.yml',
|
|
18
|
+
},
|
|
19
|
+
dependencies: ['user', 'group'],
|
|
20
|
+
identity: ({ name }) => name,
|
|
21
|
+
displayName: ({ name }) => name,
|
|
22
|
+
parse: common_1.parseUserAttributeAsCode,
|
|
23
|
+
sort: (a, b) => a.name.localeCompare(b.name),
|
|
24
|
+
};
|
|
25
|
+
const formatUserAttributeUploadSummary = (summary) => `${summary.created} created, ${summary.updated} updated, ${summary.unchanged} unchanged, ${summary.failed} failed`;
|
|
26
|
+
exports.formatUserAttributeUploadSummary = formatUserAttributeUploadSummary;
|
|
27
|
+
const downloadUserAttributes = async (organizationUuid, organizationContentPath) => (0, resource_1.downloadCodeResource)({
|
|
28
|
+
definition: exports.USER_ATTRIBUTE_CODE_RESOURCE,
|
|
29
|
+
basePath: organizationContentPath,
|
|
30
|
+
list: async () => {
|
|
31
|
+
const { userAttributes } = await (0, apiClient_1.lightdashApi)({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
url: `/api/v2/orgs/${organizationUuid}/code/userAttributes`,
|
|
34
|
+
body: undefined,
|
|
35
|
+
});
|
|
36
|
+
return userAttributes;
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
exports.downloadUserAttributes = downloadUserAttributes;
|
|
40
|
+
const uploadUserAttributes = async (organizationUuid, organizationContentPath) => (0, resource_1.uploadCodeResource)({
|
|
41
|
+
definition: exports.USER_ATTRIBUTE_CODE_RESOURCE,
|
|
42
|
+
basePath: organizationContentPath,
|
|
43
|
+
upsert: async (document) => {
|
|
44
|
+
const result = await (0, apiClient_1.lightdashApi)({
|
|
45
|
+
method: 'POST',
|
|
46
|
+
url: `/api/v2/orgs/${organizationUuid}/code/userAttributes`,
|
|
47
|
+
body: JSON.stringify(document),
|
|
48
|
+
});
|
|
49
|
+
return result.action;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
exports.uploadUserAttributes = uploadUserAttributes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.271.0",
|
|
4
4
|
"description": "Lightdash CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@actions/core": "1.11.1",
|
|
23
23
|
"@aws-sdk/credential-providers": "3.995.0",
|
|
24
24
|
"@casl/ability": "6.8.0",
|
|
25
|
-
"@lightdash/common": "2.
|
|
26
|
-
"@lightdash/warehouses": "2.
|
|
25
|
+
"@lightdash/common": "2.271.0",
|
|
26
|
+
"@lightdash/warehouses": "2.271.0",
|
|
27
27
|
"@sidvind/better-ajv-errors": "7.0.0",
|
|
28
28
|
"@types/columnify": "1.5.1",
|
|
29
29
|
"ajv": "8.18.0",
|