@extrahorizon/exh-cli 1.12.0-dev-131-de586fc → 1.12.0-dev-134-0b76e07
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/build/commands/data/schemas/delete.d.ts +1 -2
- package/build/commands/data/schemas/delete.js +3 -3
- package/build/commands/data/schemas/list.d.ts +1 -2
- package/build/commands/data/schemas/list.js +3 -2
- package/build/commands/data/schemas/sync.d.ts +3 -4
- package/build/commands/data/schemas/sync.js +7 -7
- package/build/commands/data/schemas/util/syncSchema.d.ts +2 -3
- package/build/commands/data/schemas/util/syncSchema.js +18 -19
- package/build/commands/dispatchers/sync.d.ts +1 -3
- package/build/commands/dispatchers/sync.js +2 -2
- package/build/commands/localizations/sync.d.ts +1 -3
- package/build/commands/localizations/sync.js +2 -2
- package/build/commands/sync.d.ts +1 -3
- package/build/commands/sync.js +6 -6
- package/build/commands/tasks/delete.d.ts +1 -2
- package/build/commands/tasks/delete.js +2 -2
- package/build/commands/tasks/list.d.ts +1 -2
- package/build/commands/tasks/list.js +3 -2
- package/build/commands/tasks/sync.d.ts +1 -2
- package/build/commands/tasks/sync.js +8 -8
- package/build/commands/tasks/util.d.ts +1 -2
- package/build/commands/tasks/util.js +18 -18
- package/build/commands/templates/delete.d.ts +1 -3
- package/build/commands/templates/delete.js +5 -4
- package/build/commands/templates/get.d.ts +1 -3
- package/build/commands/templates/get.js +3 -2
- package/build/commands/templates/list.d.ts +1 -3
- package/build/commands/templates/list.js +3 -2
- package/build/commands/templates/sync.d.ts +1 -2
- package/build/commands/templates/sync.js +2 -2
- package/build/commands/templates/util/templateService.d.ts +1 -2
- package/build/commands/templates/util/templateService.js +3 -2
- package/build/commands/whoami.d.ts +1 -4
- package/build/commands/whoami.js +3 -3
- package/build/exh.d.ts +1 -0
- package/build/exh.js +8 -1
- package/build/index.js +3 -3
- package/build/repositories/auth.d.ts +3 -4
- package/build/repositories/auth.js +7 -6
- package/build/repositories/dispatchers.d.ts +8 -8
- package/build/repositories/dispatchers.js +15 -14
- package/build/repositories/functions.d.ts +5 -6
- package/build/repositories/functions.js +11 -10
- package/build/repositories/localizations.d.ts +3 -3
- package/build/repositories/localizations.js +5 -4
- package/build/repositories/schemas.d.ts +19 -20
- package/build/repositories/schemas.js +35 -34
- package/build/repositories/user.d.ts +9 -9
- package/build/repositories/user.js +17 -16
- package/build/services/dispatchers.d.ts +1 -2
- package/build/services/dispatchers.js +18 -18
- package/build/services/localizations/index.d.ts +1 -2
- package/build/services/localizations/index.js +2 -2
- package/build/services/localizations/syncLocalizations.d.ts +1 -2
- package/build/services/localizations/syncLocalizations.js +3 -3
- package/package.json +2 -2
|
@@ -2,37 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addGlobalRoleToUser = exports.removePermissionsFromGlobalRole = exports.addPermissionsToGlobalRole = exports.createGlobalRole = exports.findGlobalRoleByName = exports.createUser = exports.isEmailAvailable = exports.findUserByEmail = void 0;
|
|
4
4
|
const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
|
|
5
|
-
|
|
5
|
+
const exh_1 = require("../exh");
|
|
6
|
+
async function findUserByEmail(email) {
|
|
6
7
|
const rql = (0, javascript_sdk_1.rqlBuilder)().eq('email', email).build();
|
|
7
|
-
return await
|
|
8
|
+
return await (0, exh_1.getSdk)().users.findFirst({ rql });
|
|
8
9
|
}
|
|
9
10
|
exports.findUserByEmail = findUserByEmail;
|
|
10
|
-
async function isEmailAvailable(
|
|
11
|
-
const { emailAvailable } = await
|
|
11
|
+
async function isEmailAvailable(email) {
|
|
12
|
+
const { emailAvailable } = await (0, exh_1.getSdk)().users.isEmailAvailable(email);
|
|
12
13
|
return emailAvailable;
|
|
13
14
|
}
|
|
14
15
|
exports.isEmailAvailable = isEmailAvailable;
|
|
15
|
-
async function createUser(
|
|
16
|
-
return await
|
|
16
|
+
async function createUser(data) {
|
|
17
|
+
return await (0, exh_1.getSdk)().users.createAccount(data);
|
|
17
18
|
}
|
|
18
19
|
exports.createUser = createUser;
|
|
19
|
-
async function findGlobalRoleByName(
|
|
20
|
-
return await
|
|
20
|
+
async function findGlobalRoleByName(name) {
|
|
21
|
+
return await (0, exh_1.getSdk)().users.globalRoles.findByName(name);
|
|
21
22
|
}
|
|
22
23
|
exports.findGlobalRoleByName = findGlobalRoleByName;
|
|
23
|
-
async function createGlobalRole(
|
|
24
|
-
return await
|
|
24
|
+
async function createGlobalRole(name, description) {
|
|
25
|
+
return await (0, exh_1.getSdk)().users.globalRoles.create({ name, description });
|
|
25
26
|
}
|
|
26
27
|
exports.createGlobalRole = createGlobalRole;
|
|
27
|
-
async function addPermissionsToGlobalRole(
|
|
28
|
-
return await
|
|
28
|
+
async function addPermissionsToGlobalRole(name, permissions) {
|
|
29
|
+
return await (0, exh_1.getSdk)().users.globalRoles.addPermissions((0, javascript_sdk_1.rqlBuilder)().eq('name', name).build(), { permissions });
|
|
29
30
|
}
|
|
30
31
|
exports.addPermissionsToGlobalRole = addPermissionsToGlobalRole;
|
|
31
|
-
async function removePermissionsFromGlobalRole(
|
|
32
|
-
return await
|
|
32
|
+
async function removePermissionsFromGlobalRole(name, permissions) {
|
|
33
|
+
return await (0, exh_1.getSdk)().users.globalRoles.removePermissions((0, javascript_sdk_1.rqlBuilder)().eq('name', name).build(), { permissions });
|
|
33
34
|
}
|
|
34
35
|
exports.removePermissionsFromGlobalRole = removePermissionsFromGlobalRole;
|
|
35
|
-
async function addGlobalRoleToUser(
|
|
36
|
-
return await
|
|
36
|
+
async function addGlobalRoleToUser(userId, roleId) {
|
|
37
|
+
return await (0, exh_1.getSdk)().users.globalRoles.addToUsers((0, javascript_sdk_1.rqlBuilder)().eq('id', userId).build(), { roles: [roleId] });
|
|
37
38
|
}
|
|
38
39
|
exports.addGlobalRoleToUser = addGlobalRoleToUser;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { OAuth1Client } from '@extrahorizon/javascript-sdk';
|
|
2
1
|
export declare const cliManagedTag = "EXH_CLI_MANAGED";
|
|
3
|
-
export declare function sync(
|
|
2
|
+
export declare function sync(path: string, clean?: boolean): Promise<void>;
|
|
@@ -6,73 +6,73 @@ const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
|
|
|
6
6
|
const chalk_1 = require("chalk");
|
|
7
7
|
const dispatcherRepository = require("../repositories/dispatchers");
|
|
8
8
|
exports.cliManagedTag = 'EXH_CLI_MANAGED';
|
|
9
|
-
async function sync(
|
|
9
|
+
async function sync(path, clean = false) {
|
|
10
10
|
console.log((0, chalk_1.yellow)(`Synchronizing Dispatchers from ${path}`));
|
|
11
11
|
const localDispatchers = await extractDispatchersFromFile(path);
|
|
12
12
|
const rql = (0, javascript_sdk_1.rqlBuilder)().eq('tags', exports.cliManagedTag).build();
|
|
13
|
-
const exhDispatchers = await dispatcherRepository.findAll(
|
|
13
|
+
const exhDispatchers = await dispatcherRepository.findAll(rql);
|
|
14
14
|
validateDispatchers(localDispatchers);
|
|
15
15
|
console.group((0, chalk_1.blue)('Synchronizing Dispatchers:'));
|
|
16
16
|
for (const localDispatcher of localDispatchers) {
|
|
17
17
|
const exhDispatcher = exhDispatchers.find(({ name }) => name === localDispatcher.name);
|
|
18
|
-
await synchronizeDispatcher(
|
|
18
|
+
await synchronizeDispatcher(localDispatcher, exhDispatcher);
|
|
19
19
|
}
|
|
20
20
|
if (clean) {
|
|
21
|
-
await removeDispatchers(
|
|
21
|
+
await removeDispatchers(localDispatchers, exhDispatchers);
|
|
22
22
|
}
|
|
23
23
|
console.groupEnd();
|
|
24
24
|
}
|
|
25
25
|
exports.sync = sync;
|
|
26
|
-
async function synchronizeDispatcher(
|
|
26
|
+
async function synchronizeDispatcher(localDispatcher, exhDispatcher) {
|
|
27
27
|
localDispatcher.tags = localDispatcher.tags || [];
|
|
28
28
|
const hasCliManagedTag = localDispatcher.tags.includes(exports.cliManagedTag);
|
|
29
29
|
if (!hasCliManagedTag) {
|
|
30
30
|
localDispatcher.tags.push(exports.cliManagedTag);
|
|
31
31
|
}
|
|
32
32
|
if (!exhDispatcher) {
|
|
33
|
-
await createDispatcher(
|
|
33
|
+
await createDispatcher(localDispatcher);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
await updateDispatcher(
|
|
36
|
+
await updateDispatcher(localDispatcher, exhDispatcher);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
async function createDispatcher(
|
|
39
|
+
async function createDispatcher(dispatcher) {
|
|
40
40
|
console.group((0, chalk_1.blue)(`Creating Dispatcher: ${dispatcher.name}`));
|
|
41
|
-
await dispatcherRepository.create(
|
|
41
|
+
await dispatcherRepository.create(dispatcher);
|
|
42
42
|
for (const action of dispatcher.actions) {
|
|
43
43
|
console.log((0, chalk_1.green)(`✓ Action: ${action.name}`));
|
|
44
44
|
}
|
|
45
45
|
console.groupEnd();
|
|
46
46
|
console.log((0, chalk_1.green)(`✓ Created Dispatcher: ${dispatcher.name}`));
|
|
47
47
|
}
|
|
48
|
-
async function updateDispatcher(
|
|
48
|
+
async function updateDispatcher(localDispatcher, exhDispatcher) {
|
|
49
49
|
console.group((0, chalk_1.blue)(`Updating Dispatcher: ${localDispatcher.name}`));
|
|
50
|
-
await dispatcherRepository.update(
|
|
51
|
-
await synchronizeActions(
|
|
50
|
+
await dispatcherRepository.update(exhDispatcher.id, localDispatcher);
|
|
51
|
+
await synchronizeActions(localDispatcher, exhDispatcher);
|
|
52
52
|
console.groupEnd();
|
|
53
53
|
console.log((0, chalk_1.green)(`✓ Updated Dispatcher: ${localDispatcher.name}`));
|
|
54
54
|
}
|
|
55
|
-
async function removeDispatchers(
|
|
55
|
+
async function removeDispatchers(localDispatchers, exhDispatchers) {
|
|
56
56
|
for (const exhDispatcher of exhDispatchers) {
|
|
57
57
|
const localDispatcher = localDispatchers.find(({ name }) => name === exhDispatcher.name);
|
|
58
58
|
if (!localDispatcher) {
|
|
59
59
|
console.log((0, chalk_1.blue)(`Deleting Dispatcher: ${exhDispatcher.name}`));
|
|
60
|
-
await dispatcherRepository.remove(
|
|
60
|
+
await dispatcherRepository.remove(exhDispatcher.id);
|
|
61
61
|
console.log((0, chalk_1.green)(`✓ Deleted Dispatcher: ${exhDispatcher.name}`));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async function synchronizeActions(
|
|
65
|
+
async function synchronizeActions(localDispatcher, exhDispatcher) {
|
|
66
66
|
for (const localAction of localDispatcher.actions) {
|
|
67
67
|
const exhAction = exhDispatcher.actions.find(({ name }) => name === localAction.name);
|
|
68
68
|
if (!exhAction) {
|
|
69
69
|
console.log((0, chalk_1.yellow)(`Creating Action: ${localAction.name}`));
|
|
70
|
-
await dispatcherRepository.createAction(
|
|
70
|
+
await dispatcherRepository.createAction(exhDispatcher.id, localAction);
|
|
71
71
|
console.log((0, chalk_1.green)(`✓ Created Action: ${localAction.name}`));
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
74
|
console.log((0, chalk_1.yellow)(`Updating Action: ${localAction.name}`));
|
|
75
|
-
await dispatcherRepository.updateAction(
|
|
75
|
+
await dispatcherRepository.updateAction(exhDispatcher.id, exhAction.id, localAction);
|
|
76
76
|
console.log((0, chalk_1.green)(`✓ Updated Action: ${localAction.name}`));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -80,7 +80,7 @@ async function synchronizeActions(sdk, localDispatcher, exhDispatcher) {
|
|
|
80
80
|
const actionExistsLocally = localDispatcher.actions.find(({ name }) => name === exhAction.name);
|
|
81
81
|
if (!actionExistsLocally) {
|
|
82
82
|
console.group((0, chalk_1.blue)(`Deleting Action: ${exhAction.name}`));
|
|
83
|
-
await dispatcherRepository.removeAction(
|
|
83
|
+
await dispatcherRepository.removeAction(exhDispatcher.id, exhAction.id);
|
|
84
84
|
console.log((0, chalk_1.green)(`✓ Deleted Action: ${exhAction.name}`));
|
|
85
85
|
console.groupEnd();
|
|
86
86
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function sync(sdk: OAuth1Client, path: string): Promise<void>;
|
|
1
|
+
export declare function sync(path: string): Promise<void>;
|
|
@@ -4,7 +4,7 @@ exports.sync = void 0;
|
|
|
4
4
|
const chalk_1 = require("chalk");
|
|
5
5
|
const readFiles_1 = require("./readFiles");
|
|
6
6
|
const syncLocalizations_1 = require("./syncLocalizations");
|
|
7
|
-
async function sync(
|
|
7
|
+
async function sync(path) {
|
|
8
8
|
console.log((0, chalk_1.yellow)(`Synchronizing localizations from ${path}`));
|
|
9
9
|
const localizations = (0, readFiles_1.readFiles)(path);
|
|
10
10
|
if (localizations.length < 1) {
|
|
@@ -12,7 +12,7 @@ async function sync(sdk, path) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
assertDefaultLanguageSetForAll(localizations);
|
|
15
|
-
await (0, syncLocalizations_1.syncLocalizations)(
|
|
15
|
+
await (0, syncLocalizations_1.syncLocalizations)(localizations);
|
|
16
16
|
}
|
|
17
17
|
exports.sync = sync;
|
|
18
18
|
function assertDefaultLanguageSetForAll(localizations) {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { OAuth1Client } from '@extrahorizon/javascript-sdk';
|
|
2
1
|
import { PartialLocalization } from '../../repositories/localizations';
|
|
3
|
-
export declare const syncLocalizations: (
|
|
2
|
+
export declare const syncLocalizations: (localizations: PartialLocalization[]) => Promise<void>;
|
|
@@ -5,16 +5,16 @@ const chalk = require("chalk");
|
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const localizationRepository = require("../../repositories/localizations");
|
|
7
7
|
const chunkSize = 30;
|
|
8
|
-
const syncLocalizations = async (
|
|
8
|
+
const syncLocalizations = async (localizations) => {
|
|
9
9
|
console.log(`${localizations.length} localization(s) to synchronize.`);
|
|
10
10
|
const localizationChunks = (0, lodash_1.chunk)(localizations, chunkSize);
|
|
11
11
|
for (const localizationChunk of localizationChunks) {
|
|
12
|
-
const creationResult = await localizationRepository.create(
|
|
12
|
+
const creationResult = await localizationRepository.create(localizationChunk);
|
|
13
13
|
console.log(`Created ${creationResult.created} localization(s).`);
|
|
14
14
|
if (creationResult.existingIds && creationResult.existingIds.length > 0) {
|
|
15
15
|
const existingKeys = creationResult.existingIds;
|
|
16
16
|
const existingLocalizations = localizationChunk.filter(localization => existingKeys.includes(localization.key));
|
|
17
|
-
const updateResult = await localizationRepository.update(
|
|
17
|
+
const updateResult = await localizationRepository.update(existingLocalizations);
|
|
18
18
|
console.log(`Updated ${updateResult.updated} localization(s).`);
|
|
19
19
|
}
|
|
20
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@extrahorizon/exh-cli",
|
|
3
|
-
"version": "1.12.0-dev-
|
|
3
|
+
"version": "1.12.0-dev-134-0b76e07",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"exports": "./build/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"typescript": "4.5.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@extrahorizon/javascript-sdk": "^8.
|
|
44
|
+
"@extrahorizon/javascript-sdk": "^8.9.0-dev-138-3022f93",
|
|
45
45
|
"ajv": "^8.11.0",
|
|
46
46
|
"archiver": "^7.0.1",
|
|
47
47
|
"chalk": "^4.0.0",
|