Skip to content

Commit

Permalink
Merge pull request #387 from vscheuber/main
Browse files Browse the repository at this point in the history
Improvements in journey and service import
  • Loading branch information
vscheuber committed May 2, 2024
2 parents 9fa4856 + 269f53e commit 4e511ec
Show file tree
Hide file tree
Showing 27 changed files with 6,729 additions and 123 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
]
},
"dependencies": {
"@rockcarver/frodo-lib": "2.0.0-77",
"@rockcarver/frodo-lib": "2.0.0-79",
"chokidar": "^3.5.3",
"cli-progress": "^3.11.2",
"cli-table3": "^0.6.3",
Expand Down
13 changes: 8 additions & 5 deletions src/cli/service/service-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ServiceImportOptions {
debug?: boolean;
curlirize?: boolean;
global?: boolean;
realm?: boolean;
currentRealm?: boolean;
}

program
Expand Down Expand Up @@ -53,13 +53,16 @@ program
)
)
.addOption(
new Option('-g, --global', 'Import service(s) as global service(s).')
new Option(
'-g, --global',
'Import service(s) as global service(s).'
).default(false)
)
.addOption(
new Option(
'-r, --current-realm',
'Import service(s) into the current realm.'
)
'Import service(s) into the current realm. Use this flag if you exported a service from one realm and are importing into another realm.'
).default(false)
)
.action(
async (
Expand All @@ -81,7 +84,7 @@ program

const clean = options.clean ?? false;
const globalConfig = options.global ?? false;
const realmConfig = options.realm ?? false;
const realmConfig = globalConfig ? false : options.currentRealm ?? false;

// import by id
if (options.serviceId && options.file && (await getTokens())) {
Expand Down
46 changes: 24 additions & 22 deletions src/ops/AdminOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const GENERIC_EXTENSION_ATTRIBUTES = JSON.parse(
fs.readFileSync(
path.resolve(
__dirname,
'./templates/cloud/GenericExtensionAttributesTemplate.json'
'./templates/GenericExtensionAttributesTemplate.json'
),
'utf8'
)
Expand Down Expand Up @@ -906,32 +906,33 @@ export async function hideGenericExtensionAttributes(
try {
const response = await readConfigEntity('managed');
const managed = cloneDeep(response);
const propertyNames = Object.keys(GENERIC_EXTENSION_ATTRIBUTES);
const updatedObjects = managed.objects.map((object) => {
// ignore all other objects
if (object.name !== getCurrentRealmManagedUser()) {
return object;
}
propertyNames.forEach((name) => {
for (const property of Object.keys(
cloneDeep(GENERIC_EXTENSION_ATTRIBUTES)
)) {
if (
isEqualJson(
GENERIC_EXTENSION_ATTRIBUTES[name],
object.schema.properties[name],
['viewable', 'usageDescription']
GENERIC_EXTENSION_ATTRIBUTES[property],
object.schema.properties[property],
['viewable', 'usageDescription', 'searchable']
) ||
includeCustomized
) {
if (object.schema.properties[name].viewable) {
printMessage(`${name}: hide`);
if (object.schema.properties[property].viewable) {
printMessage(`${property}: hide`);
// eslint-disable-next-line no-param-reassign
object.schema.properties[name].viewable = false;
object.schema.properties[property].viewable = false;
} else {
printMessage(`${name}: ignore (already hidden)`);
printMessage(`${property}: ignore (already hidden)`);
}
} else {
printMessage(`${name}: skip (customized)`);
printMessage(`${property}: skip (customized)`);
}
});
}
return object;
});
managed.objects = updatedObjects;
Expand All @@ -955,32 +956,33 @@ export async function showGenericExtensionAttributes(
try {
const response = await readConfigEntity('managed');
const managed = cloneDeep(response);
const propertyNames = Object.keys(GENERIC_EXTENSION_ATTRIBUTES);
const updatedObjects = managed.objects.map((object) => {
// ignore all other objects
if (object.name !== getCurrentRealmManagedUser()) {
return object;
}
propertyNames.forEach((name) => {
for (const property of Object.keys(
cloneDeep(GENERIC_EXTENSION_ATTRIBUTES)
)) {
if (
isEqualJson(
GENERIC_EXTENSION_ATTRIBUTES[name],
object.schema.properties[name],
GENERIC_EXTENSION_ATTRIBUTES[property],
object.schema.properties[property],
['viewable', 'usageDescription']
) ||
includeCustomized
) {
if (!object.schema.properties[name].viewable) {
printMessage(`${name}: show`);
if (!object.schema.properties[property].viewable) {
printMessage(`${property}: show`);
// eslint-disable-next-line no-param-reassign
object.schema.properties[name].viewable = true;
object.schema.properties[property].viewable = true;
} else {
printMessage(`${name}: ignore (already showing)`);
printMessage(`${property}: ignore (already showing)`);
}
} else {
printMessage(`${name}: skip (customized)`);
printMessage(`${property}: skip (customized)`);
}
});
}
return object;
});
managed.objects = updatedObjects;
Expand Down
7 changes: 6 additions & 1 deletion src/ops/JourneyOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,12 @@ export async function importFirstJourneyFromFile(
0,
`Importing ${journeyId}...`
);
stopProgressIndicator(importSpinnerId, `${importError}`, 'fail');
stopProgressIndicator(
importSpinnerId,
`Error importing ${journeyId}`,
'fail'
);
printError(importError);
}
} else {
stopProgressIndicator(depSpinnerId, `Unresolved dependencies:`, 'fail');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"frIndexedDate1": {
"description": "Generic Indexed Date 1",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Date 1",
"type": "string",
"usageDescription": "",
Expand All @@ -11,6 +12,7 @@
"frIndexedDate2": {
"description": "Generic Indexed Date 2",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Date 2",
"type": "string",
"usageDescription": "",
Expand All @@ -20,6 +22,7 @@
"frIndexedDate3": {
"description": "Generic Indexed Date 3",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Date 3",
"type": "string",
"usageDescription": "",
Expand All @@ -29,6 +32,7 @@
"frIndexedDate4": {
"description": "Generic Indexed Date 4",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Date 4",
"type": "string",
"usageDescription": "",
Expand All @@ -38,6 +42,7 @@
"frIndexedDate5": {
"description": "Generic Indexed Date 5",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Date 5",
"type": "string",
"usageDescription": "",
Expand All @@ -47,6 +52,7 @@
"frIndexedInteger1": {
"description": "Generic Indexed Integer 1",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Integer 1",
"type": "number",
"usageDescription": "",
Expand All @@ -56,6 +62,7 @@
"frIndexedInteger2": {
"description": "Generic Indexed Integer 2",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Integer 2",
"type": "number",
"usageDescription": "",
Expand All @@ -65,6 +72,7 @@
"frIndexedInteger3": {
"description": "Generic Indexed Integer 3",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Integer 3",
"type": "number",
"usageDescription": "",
Expand All @@ -74,6 +82,7 @@
"frIndexedInteger4": {
"description": "Generic Indexed Integer 4",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Integer 4",
"type": "number",
"usageDescription": "",
Expand All @@ -83,6 +92,7 @@
"frIndexedInteger5": {
"description": "Generic Indexed Integer 5",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed Integer 5",
"type": "number",
"usageDescription": "",
Expand All @@ -95,6 +105,7 @@
"items": {
"type": "string"
},
"searchable": true,
"title": "Generic Indexed Multivalue 1",
"type": "array",
"usageDescription": "",
Expand All @@ -107,6 +118,7 @@
"items": {
"type": "string"
},
"searchable": true,
"title": "Generic Indexed Multivalue 2",
"type": "array",
"usageDescription": "",
Expand All @@ -119,6 +131,7 @@
"items": {
"type": "string"
},
"searchable": true,
"title": "Generic Indexed Multivalue 3",
"type": "array",
"usageDescription": "",
Expand All @@ -131,6 +144,7 @@
"items": {
"type": "string"
},
"searchable": true,
"title": "Generic Indexed Multivalue 4",
"type": "array",
"usageDescription": "",
Expand All @@ -143,6 +157,7 @@
"items": {
"type": "string"
},
"searchable": true,
"title": "Generic Indexed Multivalue 5",
"type": "array",
"usageDescription": "",
Expand All @@ -152,6 +167,7 @@
"frIndexedString1": {
"description": "Generic Indexed String 1",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed String 1",
"type": "string",
"usageDescription": "",
Expand All @@ -161,6 +177,7 @@
"frIndexedString2": {
"description": "Generic Indexed String 2",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed String 2",
"type": "string",
"usageDescription": "",
Expand All @@ -170,6 +187,7 @@
"frIndexedString3": {
"description": "Generic Indexed String 3",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed String 3",
"type": "string",
"usageDescription": "",
Expand All @@ -179,6 +197,7 @@
"frIndexedString4": {
"description": "Generic Indexed String 4",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed String 4",
"type": "string",
"usageDescription": "",
Expand All @@ -188,6 +207,7 @@
"frIndexedString5": {
"description": "Generic Indexed String 5",
"isPersonal": false,
"searchable": true,
"title": "Generic Indexed String 5",
"type": "string",
"usageDescription": "",
Expand Down
6 changes: 5 additions & 1 deletion test/client_cli/en/__snapshots__/service-import.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Options:
from. Ignored with -A.
--flush-cache Flush token cache.
-g, --global Import service(s) as global service(s).
(default: false)
-h, --help Help
-i, --service-id <service-id> Service id. If specified, -a and -A are
ignored.
Expand All @@ -58,7 +59,10 @@ Options:
admin login flow of Identity Cloud and handle
MFA (choices: "classic", "cloud", "forgeops")
--no-cache Disable token cache for this operation.
-r, --current-realm Import service(s) into the current realm.
-r, --current-realm Import service(s) into the current realm. Use
this flag if you exported a service from one
realm and are importing into another realm.
(default: false)
--sa-id <sa-id> Service account id.
--sa-jwk-file <file> File containing the JSON Web Key (JWK)
associated with the the service account.
Expand Down
28 changes: 14 additions & 14 deletions test/e2e/mocks/github_584874290/recording.har

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions test/e2e/mocks/npmjs_1455397529/recording.har

Large diffs are not rendered by default.

Loading

0 comments on commit 4e511ec

Please sign in to comment.