@rockcarver/frodo-cli 2.0.0-23 → 2.0.0-25
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/CHANGELOG.md +9 -1
- package/esm/cli/admin/admin-train-auto-access-model.js +33 -0
- package/esm/cli/admin/admin-train-auto-access-model.js.map +1 -0
- package/esm/cli/admin/admin.js +3 -0
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +4 -4
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +33 -39
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +17 -16
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +3 -3
- package/esm/ops/JourneyOps.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0-24] - 2023-10-15
|
|
11
|
+
|
|
12
|
+
## [2.0.0-23] - 2023-10-14
|
|
13
|
+
|
|
10
14
|
## [2.0.0-22] - 2023-10-12
|
|
11
15
|
|
|
12
16
|
## [2.0.0-21] - 2023-10-11
|
|
@@ -1359,7 +1363,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1359
1363
|
- Fixed problem with adding connection profiles
|
|
1360
1364
|
- Miscellaneous bug fixes
|
|
1361
1365
|
|
|
1362
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1366
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-24...HEAD
|
|
1367
|
+
|
|
1368
|
+
[2.0.0-24]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-23...v2.0.0-24
|
|
1369
|
+
|
|
1370
|
+
[2.0.0-23]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-22...v2.0.0-23
|
|
1363
1371
|
|
|
1364
1372
|
[2.0.0-22]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-21...v2.0.0-22
|
|
1365
1373
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { printMessage } from '../../utils/Console.js';
|
|
4
|
+
import { FrodoCommand } from '../FrodoCommand.js';
|
|
5
|
+
const {
|
|
6
|
+
getTokens
|
|
7
|
+
} = frodo.login;
|
|
8
|
+
const {
|
|
9
|
+
trainAA
|
|
10
|
+
} = frodo.admin;
|
|
11
|
+
const program = new FrodoCommand('frodo admin train-auto-access-model');
|
|
12
|
+
program.description('Train Auto Access model.').addOption(new Option('--api-key <key>', 'API key to authenticate to training journey.').default('')).addOption(new Option('--api-secret <secret>', 'API secret to authenticate to training journey.').default('')).addOption(new Option('--usernames [usernames]', 'Comma-delimited list of custom usernames.').default('')).addOption(new Option('--user-agents [usernames]', 'Comma-delimited list of custom user agents.').default('')).addOption(new Option('--ip-addresses [usernames]', 'Comma-delimited list of custom IP addresses.').default('')).action(
|
|
13
|
+
// implement command logic inside action handler
|
|
14
|
+
async (host, realm, user, password, options, command) => {
|
|
15
|
+
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
16
|
+
if (await getTokens()) {
|
|
17
|
+
printMessage(`Training Auto Access model in realm "${state.getRealm()}"...`);
|
|
18
|
+
try {
|
|
19
|
+
await trainAA(options.apiKey, options.apiSecret, options.usernames.split(','), options.userAgents.split(','), options.ipAddresses.split(','), 100);
|
|
20
|
+
printMessage(`Done.`);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
printMessage(error, 'error');
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// end command logic inside action handler
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
program.parse();
|
|
33
|
+
//# sourceMappingURL=admin-train-auto-access-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-train-auto-access-model.js","names":["frodo","state","Option","printMessage","FrodoCommand","getTokens","login","trainAA","admin","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","apiKey","apiSecret","usernames","split","userAgents","ipAddresses","error","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-train-auto-access-model.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand.js';\n\nconst { getTokens } = frodo.login;\nconst { trainAA } = frodo.admin;\n\nconst program = new FrodoCommand('frodo admin train-auto-access-model');\n\nprogram\n .description('Train Auto Access model.')\n .addOption(\n new Option(\n '--api-key <key>',\n 'API key to authenticate to training journey.'\n ).default('')\n )\n .addOption(\n new Option(\n '--api-secret <secret>',\n 'API secret to authenticate to training journey.'\n ).default('')\n )\n .addOption(\n new Option(\n '--usernames [usernames]',\n 'Comma-delimited list of custom usernames.'\n ).default('')\n )\n .addOption(\n new Option(\n '--user-agents [usernames]',\n 'Comma-delimited list of custom user agents.'\n ).default('')\n )\n .addOption(\n new Option(\n '--ip-addresses [usernames]',\n 'Comma-delimited list of custom IP addresses.'\n ).default('')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Training Auto Access model in realm \"${state.getRealm()}\"...`\n );\n try {\n await trainAA(\n options.apiKey,\n options.apiSecret,\n options.usernames.split(','),\n options.userAgents.split(','),\n options.ipAddresses.split(','),\n 100\n );\n printMessage(`Done.`);\n } catch (error) {\n printMessage(error, 'error');\n process.exitCode = 1;\n }\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,oBAAoB;AAEjD,MAAM;EAAEC;AAAU,CAAC,GAAGL,KAAK,CAACM,KAAK;AACjC,MAAM;EAAEC;AAAQ,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAE/B,MAAMC,OAAO,GAAG,IAAIL,YAAY,CAAC,qCAAqC,CAAC;AAEvEK,OAAO,CACJC,WAAW,CAAC,0BAA0B,CAAC,CACvCC,SAAS,CACR,IAAIT,MAAM,CACR,iBAAiB,EACjB,8CACF,CAAC,CAACU,OAAO,CAAC,EAAE,CACd,CAAC,CACAD,SAAS,CACR,IAAIT,MAAM,CACR,uBAAuB,EACvB,iDACF,CAAC,CAACU,OAAO,CAAC,EAAE,CACd,CAAC,CACAD,SAAS,CACR,IAAIT,MAAM,CACR,yBAAyB,EACzB,2CACF,CAAC,CAACU,OAAO,CAAC,EAAE,CACd,CAAC,CACAD,SAAS,CACR,IAAIT,MAAM,CACR,2BAA2B,EAC3B,6CACF,CAAC,CAACU,OAAO,CAAC,EAAE,CACd,CAAC,CACAD,SAAS,CACR,IAAIT,MAAM,CACR,4BAA4B,EAC5B,8CACF,CAAC,CAACU,OAAO,CAAC,EAAE,CACd,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMd,SAAS,CAAC,CAAC,EAAE;IACrBF,YAAY,CACT,wCAAuCF,KAAK,CAACoB,QAAQ,CAAC,CAAE,MAC3D,CAAC;IACD,IAAI;MACF,MAAMd,OAAO,CACXW,OAAO,CAACI,MAAM,EACdJ,OAAO,CAACK,SAAS,EACjBL,OAAO,CAACM,SAAS,CAACC,KAAK,CAAC,GAAG,CAAC,EAC5BP,OAAO,CAACQ,UAAU,CAACD,KAAK,CAAC,GAAG,CAAC,EAC7BP,OAAO,CAACS,WAAW,CAACF,KAAK,CAAC,GAAG,CAAC,EAC9B,GACF,CAAC;MACDtB,YAAY,CAAE,OAAM,CAAC;IACvB,CAAC,CAAC,OAAOyB,KAAK,EAAE;MACdzB,YAAY,CAACyB,KAAK,EAAE,OAAO,CAAC;MAC5BC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHrB,OAAO,CAACsB,KAAK,CAAC,CAAC"}
|
package/esm/cli/admin/admin.js
CHANGED
|
@@ -17,6 +17,9 @@ export default function setup() {
|
|
|
17
17
|
program.command('hide-generic-extension-attributes', 'Hide generic extension attributes.');
|
|
18
18
|
program.command('show-generic-extension-attributes', 'Show generic extension attributes.');
|
|
19
19
|
program.command('repair-org-model', 'Repair org model.');
|
|
20
|
+
|
|
21
|
+
// program.command('train-auto-access-model', 'Train Auto Access model.');
|
|
22
|
+
|
|
20
23
|
return program;
|
|
21
24
|
}
|
|
22
25
|
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","names":["path","fileURLToPath","FrodoStubCommand","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["../../../src/cli/admin/admin.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { FrodoStubCommand } from '../FrodoCommand';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command('federation', 'Manage admin federation configuration.');\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n return program;\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,SAASC,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,SAAS,GAAGH,IAAI,CAACI,OAAO,CAACH,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAAC,OAAO,CAAC,CAC1CQ,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CAAC,YAAY,EAAE,wCAAwC,CAAC;EAEvEH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC
|
|
1
|
+
{"version":3,"file":"admin.js","names":["path","fileURLToPath","FrodoStubCommand","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["../../../src/cli/admin/admin.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { FrodoStubCommand } from '../FrodoCommand';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command('federation', 'Manage admin federation configuration.');\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n // program.command('train-auto-access-model', 'Train Auto Access model.');\n\n return program;\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,SAASC,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,SAAS,GAAGH,IAAI,CAACI,OAAO,CAACH,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAAC,OAAO,CAAC,CAC1CQ,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CAAC,YAAY,EAAE,wCAAwC,CAAC;EAEvEH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;;EAExD;;EAEA,OAAOH,OAAO;AAChB"}
|
|
@@ -14,25 +14,25 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
// import by id
|
|
15
15
|
if (options.file && options.cotId && (await getTokens())) {
|
|
16
16
|
verboseMessage(`Importing circle of trust "${options.cotId}" into realm "${state.getRealm()}"...`);
|
|
17
|
-
const outcome = importCircleOfTrustFromFile(options.cotId, options.file);
|
|
17
|
+
const outcome = await importCircleOfTrustFromFile(options.cotId, options.file);
|
|
18
18
|
if (!outcome) process.exitCode = 1;
|
|
19
19
|
}
|
|
20
20
|
// --all -a
|
|
21
21
|
else if (options.all && options.file && (await getTokens())) {
|
|
22
22
|
verboseMessage(`Importing all circles of trust from a single file (${options.file})...`);
|
|
23
|
-
const outcome = importCirclesOfTrustFromFile(options.file);
|
|
23
|
+
const outcome = await importCirclesOfTrustFromFile(options.file);
|
|
24
24
|
if (!outcome) process.exitCode = 1;
|
|
25
25
|
}
|
|
26
26
|
// --all-separate -A
|
|
27
27
|
else if (options.allSeparate && !options.file && (await getTokens())) {
|
|
28
28
|
verboseMessage('Importing all circles of trust from separate files (*.saml.json) in current directory...');
|
|
29
|
-
const outcome = importCirclesOfTrustFromFiles();
|
|
29
|
+
const outcome = await importCirclesOfTrustFromFiles();
|
|
30
30
|
if (!outcome) process.exitCode = 1;
|
|
31
31
|
}
|
|
32
32
|
// import first from file
|
|
33
33
|
else if (options.file && (await getTokens())) {
|
|
34
34
|
verboseMessage(`Importing first circle of trust from file "${options.file}" into realm "${state.getRealm()}"...`);
|
|
35
|
-
const outcome = importFirstCircleOfTrustFromFile(options.file);
|
|
35
|
+
const outcome = await importFirstCircleOfTrustFromFile(options.file);
|
|
36
36
|
if (!outcome) process.exitCode = 1;
|
|
37
37
|
}
|
|
38
38
|
// unrecognized combination of options or no options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saml-cot-import.js","names":["frodo","state","Option","importCircleOfTrustFromFile","importCirclesOfTrustFromFile","importCirclesOfTrustFromFiles","importFirstCircleOfTrustFromFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","cotId","getRealm","outcome","process","exitCode","all","allSeparate","help","parse"],"sources":["../../../src/cli/saml/saml-cot-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importCircleOfTrustFromFile,\n importCirclesOfTrustFromFile,\n importCirclesOfTrustFromFiles,\n importFirstCircleOfTrustFromFile,\n} from '../../ops/CirclesOfTrustOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo saml cot import');\n\nprogram\n .description('Import SAML circles of trust.')\n .addOption(\n new Option(\n '-i, --cot-id <cot-id>',\n 'Circle of trust id. If specified, only one circle of trust is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the circle(s) of trust from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all circles of trust from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all circles of trust from separate files (*.cot.saml.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement program logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by id\n if (options.file && options.cotId && (await getTokens())) {\n verboseMessage(\n `Importing circle of trust \"${\n options.cotId\n }\" into realm \"${state.getRealm()}\"...`\n );\n const outcome = importCircleOfTrustFromFile(\n options.cotId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all circles of trust from a single file (${options.file})...`\n );\n const outcome = importCirclesOfTrustFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all circles of trust from separate files (*.saml.json) in current directory...'\n );\n const outcome = importCirclesOfTrustFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first circle of trust from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n const outcome = importFirstCircleOfTrustFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end program logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,gCAAgC,QAC3B,6BAA6B;AACpC,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGV,KAAK,CAACW,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,uBAAuB,CAAC;AAEzDG,OAAO,CACJC,WAAW,CAAC,+BAA+B,CAAC,CAC5CC,SAAS,CACR,IAAIZ,MAAM,CACR,uBAAuB,EACvB,+GACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,yDACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,WAAW,EACX,gEACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,oBAAoB,EACpB,oHACF,CACF,CAAC,CACAa,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,IAAI,IAAIH,OAAO,CAACI,KAAK,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IACxDF,cAAc,CACX,8BACCY,OAAO,CAACI,KACT,iBAAgBvB,KAAK,CAACwB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACD,MAAMC,OAAO,
|
|
1
|
+
{"version":3,"file":"saml-cot-import.js","names":["frodo","state","Option","importCircleOfTrustFromFile","importCirclesOfTrustFromFile","importCirclesOfTrustFromFiles","importFirstCircleOfTrustFromFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","cotId","getRealm","outcome","process","exitCode","all","allSeparate","help","parse"],"sources":["../../../src/cli/saml/saml-cot-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importCircleOfTrustFromFile,\n importCirclesOfTrustFromFile,\n importCirclesOfTrustFromFiles,\n importFirstCircleOfTrustFromFile,\n} from '../../ops/CirclesOfTrustOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo saml cot import');\n\nprogram\n .description('Import SAML circles of trust.')\n .addOption(\n new Option(\n '-i, --cot-id <cot-id>',\n 'Circle of trust id. If specified, only one circle of trust is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the circle(s) of trust from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all circles of trust from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all circles of trust from separate files (*.cot.saml.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement program logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by id\n if (options.file && options.cotId && (await getTokens())) {\n verboseMessage(\n `Importing circle of trust \"${\n options.cotId\n }\" into realm \"${state.getRealm()}\"...`\n );\n const outcome = await importCircleOfTrustFromFile(\n options.cotId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all circles of trust from a single file (${options.file})...`\n );\n const outcome = await importCirclesOfTrustFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all circles of trust from separate files (*.saml.json) in current directory...'\n );\n const outcome = await importCirclesOfTrustFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first circle of trust from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n const outcome = await importFirstCircleOfTrustFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end program logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,gCAAgC,QAC3B,6BAA6B;AACpC,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGV,KAAK,CAACW,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,uBAAuB,CAAC;AAEzDG,OAAO,CACJC,WAAW,CAAC,+BAA+B,CAAC,CAC5CC,SAAS,CACR,IAAIZ,MAAM,CACR,uBAAuB,EACvB,+GACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,yDACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,WAAW,EACX,gEACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,oBAAoB,EACpB,oHACF,CACF,CAAC,CACAa,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,IAAI,IAAIH,OAAO,CAACI,KAAK,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IACxDF,cAAc,CACX,8BACCY,OAAO,CAACI,KACT,iBAAgBvB,KAAK,CAACwB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACD,MAAMC,OAAO,GAAG,MAAMvB,2BAA2B,CAC/CiB,OAAO,CAACI,KAAK,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CircleOfTrustFromFile(cotId, file) {
|
|
|
166
166
|
let outcome = false;
|
|
167
167
|
const filePath = getFilePath(file);
|
|
168
168
|
showSpinner(`Importing circle of trust ${cotId} from ${filePath}...`);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
});
|
|
169
|
+
try {
|
|
170
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
171
|
+
const fileData = JSON.parse(data);
|
|
172
|
+
await importCircleOfTrust(cotId, fileData);
|
|
173
|
+
outcome = true;
|
|
174
|
+
succeedSpinner(`Imported circle of trust ${cotId} from ${filePath}.`);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
var _error$response;
|
|
177
|
+
failSpinner(`Error importing circle of trust ${cotId} from ${filePath}.`);
|
|
178
|
+
printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
|
|
179
|
+
}
|
|
182
180
|
return outcome;
|
|
183
181
|
}
|
|
184
182
|
|
|
@@ -190,19 +188,17 @@ export async function importFirstCircleOfTrustFromFile(file) {
|
|
|
190
188
|
let outcome = false;
|
|
191
189
|
const filePath = getFilePath(file);
|
|
192
190
|
showSpinner(`Importing first circle of trust from ${filePath}...`);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
});
|
|
191
|
+
try {
|
|
192
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
193
|
+
const fileData = JSON.parse(data);
|
|
194
|
+
await importFirstCircleOfTrust(fileData);
|
|
195
|
+
outcome = true;
|
|
196
|
+
succeedSpinner(`Imported first circle of trust from ${filePath}.`);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
var _error$response2;
|
|
199
|
+
failSpinner(`Error importing first circle of trust from ${filePath}.`);
|
|
200
|
+
printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
|
|
201
|
+
}
|
|
206
202
|
return outcome;
|
|
207
203
|
}
|
|
208
204
|
|
|
@@ -214,19 +210,17 @@ export async function importCirclesOfTrustFromFile(file) {
|
|
|
214
210
|
let outcome = false;
|
|
215
211
|
const filePath = getFilePath(file);
|
|
216
212
|
showSpinner(`Importing circles of trust from ${filePath}...`);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
});
|
|
213
|
+
try {
|
|
214
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
215
|
+
const fileData = JSON.parse(data);
|
|
216
|
+
await importCirclesOfTrust(fileData);
|
|
217
|
+
outcome = true;
|
|
218
|
+
succeedSpinner(`Imported circles of trust from ${filePath}.`);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
var _error$response3;
|
|
221
|
+
failSpinner(`Error importing circles of trust from ${filePath}.`);
|
|
222
|
+
printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
|
|
223
|
+
}
|
|
230
224
|
return outcome;
|
|
231
225
|
}
|
|
232
226
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CirclesOfTrustOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readCirclesOfTrust","exportCircleOfTrust","exportCirclesOfTrust","importCircleOfTrust","importCirclesOfTrust","importFirstCircleOfTrust","saml2","circlesOfTrust","getOneLineDescription","cotObj","description","_id","getTableHeaderMd","markdown","getTableRowMd","row","status","trustedProviders","map","provider","split","join","listCirclesOfTrust","long","outcome","cotList","error","sort","a","b","localeCompare","forEach","cot","table","push","toString","exportCircleOfTrustToFile","cotId","file","fileName","filePath","exportData","message","exportCirclesOfTrustToFile","getRealm","exportCirclesOfTrustToFiles","errors","cots","length","name","importCircleOfTrustFromFile","readFile","err","data","fileData","JSON","parse","_error$response","response","importFirstCircleOfTrustFromFile","_error$response2","importCirclesOfTrustFromFile","_error$response3","importCirclesOfTrustFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","saml"],"sources":["../../src/ops/CirclesOfTrustOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type CircleOfTrustSkeleton } from '@rockcarver/frodo-lib/types/api/CirclesOfTrustApi';\nimport { type CirclesOfTrustExportInterface } from '@rockcarver/frodo-lib/types/ops/CirclesOfTrustOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readCirclesOfTrust,\n exportCircleOfTrust,\n exportCirclesOfTrust,\n importCircleOfTrust,\n importCirclesOfTrust,\n importFirstCircleOfTrust,\n} = frodo.saml2.circlesOfTrust;\n\n/**\n * Get a one-line description of the circle of trust object\n * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string {\n const description = `[${cotObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Trusted Providers |\\n';\n markdown += '| ------- | ------ | ----------------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the circle of trust in markdown\n * @param {SocialIdpSkeleton} cotObj circle of trust object to describe\n * @returns {string} a table-row of the circle of trust in markdown\n */\nexport function getTableRowMd(cotObj: CircleOfTrustSkeleton): string {\n const row = `| ${cotObj._id} | ${\n cotObj.status === 'active'\n ? ':white_check_mark: `active`'\n : ':o: `inactive`'\n } | ${cotObj.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('<br>')} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false): Promise<boolean> {\n let outcome = false;\n let cotList = [];\n try {\n cotList = await readCirclesOfTrust();\n } catch (error) {\n printMessage(`readCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n outcome = true;\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString());\n outcome = true;\n }\n return outcome;\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrustToFile(\n cotId: string,\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: begin`);\n showSpinner(`Exporting ${cotId}...`);\n try {\n let fileName = getTypedFilename(cotId, 'cot.saml');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCircleOfTrust(cotId);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${cotId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${cotId}: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: begin`);\n showSpinner(`Exporting all circles of trust...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}CirclesOfTrust`,\n 'cot.saml'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCirclesOfTrust();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all circles of trust to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting circles of trust: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles(): Promise<boolean> {\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: begin`);\n const errors = [];\n try {\n const cots: CircleOfTrustSkeleton[] = await readCirclesOfTrust();\n createProgressBar(cots.length, 'Exporting circles of trust...');\n for (const cot of cots) {\n const file = getTypedFilename(cot._id, 'cot.saml');\n try {\n const exportData: CirclesOfTrustExportInterface =\n await exportCircleOfTrust(cot._id);\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${cot.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${cot.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting circles of trust to files`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrustFromFile(\n cotId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circle of trust ${cotId} from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importCircleOfTrust(cotId, fileData);\n outcome = true;\n succeedSpinner(`Imported circle of trust ${cotId} from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circle of trust ${cotId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing first circle of trust from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importFirstCircleOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported first circle of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing first circle of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circles of trust from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importCirclesOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported circles of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circles of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.cot.saml.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing circles of trust...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: CirclesOfTrustExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.saml.cot).length;\n total += count;\n await importCirclesOfTrust(fileData);\n updateProgressBar(`Imported ${count} circles of trust from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing circles of trust from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Imported ${total} circles of trust from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing circles of trust from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGjB,KAAK,CAACkB,KAAK;AACtE,MAAM;EACJC,kBAAkB;EAClBC,mBAAmB;EACnBC,oBAAoB;EACpBC,mBAAmB;EACnBC,oBAAoB;EACpBC;AACF,CAAC,GAAGxB,KAAK,CAACyB,KAAK,CAACC,cAAc;;AAE9B;AACA;AACA;AACA;AACA;AAC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C,KAAK4D,MAAM,CAACE,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"CirclesOfTrustOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readCirclesOfTrust","exportCircleOfTrust","exportCirclesOfTrust","importCircleOfTrust","importCirclesOfTrust","importFirstCircleOfTrust","saml2","circlesOfTrust","getOneLineDescription","cotObj","description","_id","getTableHeaderMd","markdown","getTableRowMd","row","status","trustedProviders","map","provider","split","join","listCirclesOfTrust","long","outcome","cotList","error","sort","a","b","localeCompare","forEach","cot","table","push","toString","exportCircleOfTrustToFile","cotId","file","fileName","filePath","exportData","message","exportCirclesOfTrustToFile","getRealm","exportCirclesOfTrustToFiles","errors","cots","length","name","importCircleOfTrustFromFile","data","readFileSync","fileData","JSON","parse","_error$response","response","importFirstCircleOfTrustFromFile","_error$response2","importCirclesOfTrustFromFile","_error$response3","importCirclesOfTrustFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","saml"],"sources":["../../src/ops/CirclesOfTrustOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type CircleOfTrustSkeleton } from '@rockcarver/frodo-lib/types/api/CirclesOfTrustApi';\nimport { type CirclesOfTrustExportInterface } from '@rockcarver/frodo-lib/types/ops/CirclesOfTrustOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readCirclesOfTrust,\n exportCircleOfTrust,\n exportCirclesOfTrust,\n importCircleOfTrust,\n importCirclesOfTrust,\n importFirstCircleOfTrust,\n} = frodo.saml2.circlesOfTrust;\n\n/**\n * Get a one-line description of the circle of trust object\n * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string {\n const description = `[${cotObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Trusted Providers |\\n';\n markdown += '| ------- | ------ | ----------------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the circle of trust in markdown\n * @param {SocialIdpSkeleton} cotObj circle of trust object to describe\n * @returns {string} a table-row of the circle of trust in markdown\n */\nexport function getTableRowMd(cotObj: CircleOfTrustSkeleton): string {\n const row = `| ${cotObj._id} | ${\n cotObj.status === 'active'\n ? ':white_check_mark: `active`'\n : ':o: `inactive`'\n } | ${cotObj.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('<br>')} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false): Promise<boolean> {\n let outcome = false;\n let cotList = [];\n try {\n cotList = await readCirclesOfTrust();\n } catch (error) {\n printMessage(`readCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n outcome = true;\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString());\n outcome = true;\n }\n return outcome;\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrustToFile(\n cotId: string,\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: begin`);\n showSpinner(`Exporting ${cotId}...`);\n try {\n let fileName = getTypedFilename(cotId, 'cot.saml');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCircleOfTrust(cotId);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${cotId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${cotId}: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: begin`);\n showSpinner(`Exporting all circles of trust...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}CirclesOfTrust`,\n 'cot.saml'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCirclesOfTrust();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all circles of trust to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting circles of trust: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles(): Promise<boolean> {\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: begin`);\n const errors = [];\n try {\n const cots: CircleOfTrustSkeleton[] = await readCirclesOfTrust();\n createProgressBar(cots.length, 'Exporting circles of trust...');\n for (const cot of cots) {\n const file = getTypedFilename(cot._id, 'cot.saml');\n try {\n const exportData: CirclesOfTrustExportInterface =\n await exportCircleOfTrust(cot._id);\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${cot.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${cot.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting circles of trust to files`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrustFromFile(\n cotId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circle of trust ${cotId} from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCircleOfTrust(cotId, fileData);\n outcome = true;\n succeedSpinner(`Imported circle of trust ${cotId} from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circle of trust ${cotId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing first circle of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstCircleOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported first circle of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing first circle of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circles of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCirclesOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported circles of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circles of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.cot.saml.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing circles of trust...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: CirclesOfTrustExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.saml.cot).length;\n total += count;\n await importCirclesOfTrust(fileData);\n updateProgressBar(`Imported ${count} circles of trust from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing circles of trust from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Imported ${total} circles of trust from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing circles of trust from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;A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AAE,OAAO,CAAC;EAC9B;EACAxC,YAAY,CAAE,0DAAyD,CAAC;EACxE,OAAO,CAAC,KAAK4D,MAAM,CAACE,MAAM;AAC5B"}
|
|
@@ -180,7 +180,6 @@ export async function exportEmailTemplatesToFiles() {
|
|
|
180
180
|
* @param {boolean} raw import raw data file lacking frodo export envelop
|
|
181
181
|
*/
|
|
182
182
|
export async function importEmailTemplateFromFile(templateId, file, raw = false) {
|
|
183
|
-
// eslint-disable-next-line no-param-reassign
|
|
184
183
|
templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');
|
|
185
184
|
const filePath = getFilePath(file);
|
|
186
185
|
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
@@ -188,7 +187,7 @@ export async function importEmailTemplateFromFile(templateId, file, raw = false)
|
|
|
188
187
|
const fileData = JSON.parse(data);
|
|
189
188
|
if (raw || validateImport(fileData.meta)) {
|
|
190
189
|
createProgressIndicator('determinate', 1, `Importing ${templateId}`);
|
|
191
|
-
if (fileData.emailTemplate[templateId] || raw &&
|
|
190
|
+
if (fileData.emailTemplate && fileData.emailTemplate[templateId] || raw && getTemplateIdFromFileName(file) === templateId) {
|
|
192
191
|
try {
|
|
193
192
|
const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
|
|
194
193
|
await updateEmailTemplate(templateId, emailTemplateData);
|
|
@@ -242,11 +241,13 @@ export async function importEmailTemplatesFromFile(file) {
|
|
|
242
241
|
* @param {string} file file name
|
|
243
242
|
* @returns {string} email template id/name
|
|
244
243
|
*/
|
|
245
|
-
function
|
|
246
|
-
debugMessage(`cli.EmailTemplateOps.
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
|
|
244
|
+
function getTemplateIdFromFileName(file) {
|
|
245
|
+
debugMessage(`cli.EmailTemplateOps.getTemplateIdFromFileName: file=${file}`);
|
|
246
|
+
const basename = path.basename(file);
|
|
247
|
+
const keys = basename.split('-');
|
|
248
|
+
if (keys[0] !== EMAIL_TEMPLATE_TYPE || keys.length <= 1) throw new Error(`Filename does not indicate a raw email template: ${file}`);
|
|
249
|
+
const templateId = keys[1].split('.')[0];
|
|
250
|
+
debugMessage(`cli.EmailTemplateOps.getTemplateIdFromFileName: templateId=${templateId}`);
|
|
250
251
|
return templateId;
|
|
251
252
|
}
|
|
252
253
|
|
|
@@ -285,7 +286,7 @@ export async function importEmailTemplatesFromFiles(raw = false) {
|
|
|
285
286
|
let errors = 0;
|
|
286
287
|
if (raw) {
|
|
287
288
|
total++;
|
|
288
|
-
const templateId =
|
|
289
|
+
const templateId = getTemplateIdFromFileName(file);
|
|
289
290
|
try {
|
|
290
291
|
const templateData = s2sConvert(fileData);
|
|
291
292
|
await updateEmailTemplate(templateId, templateData);
|
|
@@ -328,18 +329,18 @@ export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
|
328
329
|
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
329
330
|
if (err) throw err;
|
|
330
331
|
const fileData = JSON.parse(data);
|
|
331
|
-
if (raw
|
|
332
|
+
if (raw || validateImport(fileData.meta)) {
|
|
332
333
|
showSpinner(`Importing first email template`);
|
|
333
334
|
if (raw) {
|
|
334
|
-
const templateId = readEmailTemplateIdFromFile(file);
|
|
335
335
|
try {
|
|
336
|
+
const templateId = getTemplateIdFromFileName(file);
|
|
336
337
|
const templateData = s2sConvert(fileData);
|
|
337
338
|
await updateEmailTemplate(templateId, templateData);
|
|
338
339
|
succeedSpinner(`Imported ${templateId}`);
|
|
339
|
-
} catch (
|
|
340
|
-
var
|
|
341
|
-
failSpinner(`Error importing ${
|
|
342
|
-
printMessage((
|
|
340
|
+
} catch (error) {
|
|
341
|
+
var _error$response;
|
|
342
|
+
failSpinner(`Error importing email template: ${error}`);
|
|
343
|
+
printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
|
|
343
344
|
}
|
|
344
345
|
} else {
|
|
345
346
|
for (const id in fileData.emailTemplate) {
|
|
@@ -348,9 +349,9 @@ export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
|
348
349
|
await updateEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
|
|
349
350
|
succeedSpinner(`Imported ${id}`);
|
|
350
351
|
} catch (updateEmailTemplateError) {
|
|
351
|
-
var
|
|
352
|
+
var _updateEmailTemplateE2;
|
|
352
353
|
failSpinner(`Error importing ${id}`);
|
|
353
|
-
printMessage((
|
|
354
|
+
printMessage((_updateEmailTemplateE2 = updateEmailTemplateError.response) === null || _updateEmailTemplateE2 === void 0 ? void 0 : _updateEmailTemplateE2.data, 'error');
|
|
354
355
|
}
|
|
355
356
|
break;
|
|
356
357
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailTemplateOps.js","names":["frodo","fs","path","createProgressIndicator","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressIndicator","succeedSpinner","updateProgressIndicator","getTypedFilename","saveJsonToFile","cloneDeep","wordwrap","validateImport","getFilePath","getWorkingDirectory","utils","EMAIL_TEMPLATE_TYPE","readEmailTemplates","readEmailTemplate","updateEmailTemplate","email","template","EMAIL_TEMPLATE_FILE_TYPE","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","filePath","templateData","fileData","err","exportEmailTemplatesToFile","templates","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","emailTemplateData","s2sConvert","updateEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","response","readEmailTemplateIdFromFile","basename","substring","indexOf","html","convertedData","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","map","total","totalErrors","readFileSync","errors","_updateEmailTemplateE","importFirstEmailTemplateFromFile","_updateEmailTemplateE2","_updateEmailTemplateE3"],"sources":["../../src/ops/EmailTemplateOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/ops/EmailTemplateOps';\nimport fs from 'fs';\nimport path from 'path';\n\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressIndicator,\n succeedSpinner,\n updateProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst { validateImport, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n EMAIL_TEMPLATE_TYPE,\n readEmailTemplates,\n readEmailTemplate,\n updateEmailTemplate,\n} = frodo.email.template;\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = await readEmailTemplates();\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n const filePath = getFilePath(fileName, true);\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await readEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${filePath}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n const filePath = getFilePath(fileName, true);\n try {\n const fileData = getFileDataTemplate();\n const templates = await readEmailTemplates();\n createProgressIndicator(\n 'determinate',\n templates.length,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n `${templates.length} templates exported to ${filePath}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const templates = await readEmailTemplates();\n createProgressIndicator(\n 'determinate',\n templates.length,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, getFilePath(fileName, true));\n }\n stopProgressIndicator(`${templates.length} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const filePath = getFilePath(file);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n fileData.emailTemplate[templateId] ||\n (raw && fileData._id === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? s2sConvert(fileData)\n : fileData.emailTemplate[templateId];\n await updateEmailTemplate(templateId, emailTemplateData);\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (updateEmailTemplateError) {\n stopProgressIndicator(`${updateEmailTemplateError}`);\n printMessage(updateEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${filePath}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${filePath}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await updateEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (updateEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction readEmailTemplateIdFromFile(file: string) {\n debugMessage(\n `cli.EmailTemplateOps.readEmailTemplateIdFromFile: file=${file}`\n );\n const fileName = path.basename(file);\n const templateId = fileName.substring(14, fileName.indexOf('.'));\n debugMessage(\n `cli.EmailTemplateOps.readEmailTemplateIdFromFile: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Convert template for s2s purposes (software-to-saas migration)\n * @param {EmailTemplateSkeleton} templateData template object\n * @returns {EmailTemplateSkeleton} converted template object\n */\nfunction s2sConvert(\n templateData: EmailTemplateSkeleton\n): EmailTemplateSkeleton {\n if (templateData.message && !templateData.html) {\n const convertedData = cloneDeep(templateData);\n convertedData.html = cloneDeep(templateData.message);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);\n debugMessage(templateData);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);\n debugMessage(convertedData);\n return convertedData;\n }\n return templateData;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) =>\n raw\n ? name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n : name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n )\n .map((name) => getFilePath(name));\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = readEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await updateEmailTemplate(templateId, templateData);\n } catch (updateEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError, 'error');\n printMessage(updateEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await updateEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (updateEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n showSpinner(`Importing first email template`);\n if (raw) {\n const templateId = readEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await updateEmailTemplate(templateId, templateData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (updateEmailTemplateError) {\n failSpinner(`Error importing ${templateId}`);\n printMessage(updateEmailTemplateError.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await updateEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (updateEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(updateEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,qBAAqB,EACrBC,cAAc,EACdC,uBAAuB,QAClB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAM;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;AACxE,MAAM;EACJC,mBAAmB;EACnBC,kBAAkB;EAClBC,iBAAiB;EACjBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,KAAK,CAACC,QAAQ;AAExB,MAAMC,wBAAwB,GAAG,gBAAgB;AAEjD,MAAMC,sBAAsB,GAAG,IAAIC,MAAM,CAAE,GAAER,mBAAoB,GAAE,EAAE,GAAG,CAAC;;AAEzE;AACA,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AACK,QAAQ,cAAAsB,sBAAA,uBAAjCA,sBAAA,CAAmChC,IAAI,EAAE,OAAO,CAAC;YAChE;YACA;UACF;QACF;MACF;IACF,CAAC,MAAM;MACL7E,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"EmailTemplateOps.js","names":["frodo","fs","path","createProgressIndicator","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressIndicator","succeedSpinner","updateProgressIndicator","getTypedFilename","saveJsonToFile","cloneDeep","wordwrap","validateImport","getFilePath","getWorkingDirectory","utils","EMAIL_TEMPLATE_TYPE","readEmailTemplates","readEmailTemplate","updateEmailTemplate","email","template","EMAIL_TEMPLATE_FILE_TYPE","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","filePath","templateData","fileData","err","exportEmailTemplatesToFile","templates","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","getTemplateIdFromFileName","emailTemplateData","s2sConvert","updateEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","response","basename","Error","html","convertedData","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","map","total","totalErrors","readFileSync","errors","_updateEmailTemplateE","importFirstEmailTemplateFromFile","_error$response","_updateEmailTemplateE2"],"sources":["../../src/ops/EmailTemplateOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/ops/EmailTemplateOps';\nimport fs from 'fs';\nimport path from 'path';\n\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressIndicator,\n succeedSpinner,\n updateProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst { validateImport, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n EMAIL_TEMPLATE_TYPE,\n readEmailTemplates,\n readEmailTemplate,\n updateEmailTemplate,\n} = frodo.email.template;\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = await readEmailTemplates();\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n const filePath = getFilePath(fileName, true);\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await readEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${filePath}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n const filePath = getFilePath(fileName, true);\n try {\n const fileData = getFileDataTemplate();\n const templates = await readEmailTemplates();\n createProgressIndicator(\n 'determinate',\n templates.length,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n `${templates.length} templates exported to ${filePath}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const templates = await readEmailTemplates();\n createProgressIndicator(\n 'determinate',\n templates.length,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, getFilePath(fileName, true));\n }\n stopProgressIndicator(`${templates.length} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const filePath = getFilePath(file);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n (fileData.emailTemplate && fileData.emailTemplate[templateId]) ||\n (raw && getTemplateIdFromFileName(file) === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? s2sConvert(fileData)\n : fileData.emailTemplate[templateId];\n await updateEmailTemplate(templateId, emailTemplateData);\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (updateEmailTemplateError) {\n stopProgressIndicator(`${updateEmailTemplateError}`);\n printMessage(updateEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${filePath}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${filePath}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await updateEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (updateEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction getTemplateIdFromFileName(file: string) {\n debugMessage(`cli.EmailTemplateOps.getTemplateIdFromFileName: file=${file}`);\n const basename = path.basename(file);\n const keys = basename.split('-');\n if (keys[0] !== EMAIL_TEMPLATE_TYPE || keys.length <= 1)\n throw new Error(`Filename does not indicate a raw email template: ${file}`);\n const templateId = keys[1].split('.')[0];\n debugMessage(\n `cli.EmailTemplateOps.getTemplateIdFromFileName: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Convert template for s2s purposes (software-to-saas migration)\n * @param {EmailTemplateSkeleton} templateData template object\n * @returns {EmailTemplateSkeleton} converted template object\n */\nfunction s2sConvert(\n templateData: EmailTemplateSkeleton\n): EmailTemplateSkeleton {\n if (templateData.message && !templateData.html) {\n const convertedData = cloneDeep(templateData);\n convertedData.html = cloneDeep(templateData.message);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);\n debugMessage(templateData);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);\n debugMessage(convertedData);\n return convertedData;\n }\n return templateData;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) =>\n raw\n ? name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n : name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n )\n .map((name) => getFilePath(name));\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = getTemplateIdFromFileName(file);\n try {\n const templateData = s2sConvert(fileData);\n await updateEmailTemplate(templateId, templateData);\n } catch (updateEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError, 'error');\n printMessage(updateEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await updateEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (updateEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(updateEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n showSpinner(`Importing first email template`);\n if (raw) {\n try {\n const templateId = getTemplateIdFromFileName(file);\n const templateData = s2sConvert(fileData);\n await updateEmailTemplate(templateId, templateData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (error) {\n failSpinner(`Error importing email template: ${error}`);\n printMessage(error.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await updateEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (updateEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(updateEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,qBAAqB,EACrBC,cAAc,EACdC,uBAAuB,QAClB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAM;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;AACxE,MAAM;EACJC,mBAAmB;EACnBC,kBAAkB;EAClBC,iBAAiB;EACjBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,KAAK,CAACC,QAAQ;AAExB,MAAMC,wBAAwB,GAAG,gBAAgB;AAEjD,MAAMC,sBAAsB,GAAG,IAAIC,MAAM,CAAE,GAAER,mBAAoB,GAAE,EAAE,GAAG,CAAC;;AAEzE;AACA,SAASS,mBAAmBA,CAAA,EAAG;EAC7B,OAAO;IACLC,IAAI,EAAE,CAAC,CAAC;IACRC,aAAa,EAAE,CAAC;EAClB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,WAAkC,EAC1B;EACR,MAAMC,WAAW,GAAI,IAAGD,WAAW,CAACE,GAAG,CAACC,KAAK,CAAC,GA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AAE,OAAO,CAAC;YAChE;YACA;UACF;QACF;MACF;IACF,CAAC,MAAM;MACL7E,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -91,7 +91,7 @@ export async function listJourneys(long = false, analyze = false) {
|
|
|
91
91
|
*/
|
|
92
92
|
export async function exportJourneyToFile(journeyId, file, options) {
|
|
93
93
|
debugMessage(`exportJourneyToFile: start`);
|
|
94
|
-
const verbose = state.
|
|
94
|
+
const verbose = state.getVerbose();
|
|
95
95
|
if (!file) {
|
|
96
96
|
file = getTypedFilename(journeyId, 'journey');
|
|
97
97
|
}
|
|
@@ -165,7 +165,7 @@ export async function exportJourneysToFiles(options) {
|
|
|
165
165
|
* @param {TreeImportOptions} options import options
|
|
166
166
|
*/
|
|
167
167
|
export async function importJourneyFromFile(journeyId, file, options) {
|
|
168
|
-
const verbose = state.
|
|
168
|
+
const verbose = state.getVerbose();
|
|
169
169
|
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
170
170
|
if (err) throw err;
|
|
171
171
|
let journeyData = JSON.parse(data);
|
|
@@ -216,7 +216,7 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
216
216
|
* @param {TreeImportOptions} options import options
|
|
217
217
|
*/
|
|
218
218
|
export async function importFirstJourneyFromFile(file, options) {
|
|
219
|
-
const verbose = state.
|
|
219
|
+
const verbose = state.getVerbose();
|
|
220
220
|
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
221
221
|
if (err) throw err;
|
|
222
222
|
let journeyData = cloneDeep(JSON.parse(data));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","getFilePath","getWorkingDirectory","utils","readJourneys","exportJourney","createMultiTreeExportTemplate","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","options","verbose","getDebug","filePath","fileData","exportJourneysToFile","trees","length","exportData","meta","exportJourneysToFiles","fileName","importJourneyFromFile","readFile","err","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","Object","keys","then","catch","importError","importFirstJourneyFromFile","treeId","hasOwnProperty","call","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","readFileSync","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","entries","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n saveJsonToFile,\n getRealmString,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n createMultiTreeExportTemplate,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n showSpinner('Retrieving details of all journeys...');\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n succeedSpinner('Retrieved details of all journeys.');\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n failSpinner('Error retrieving details of all journeys.');\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n options: TreeExportOptions\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getDebug();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n const filePath = getFilePath(file, true);\n if (!verbose) showSpinner(`${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose) showSpinner(`${journeyId}`);\n saveJsonToFile(fileData, filePath);\n succeedSpinner(\n `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (error) {\n if (verbose) showSpinner(`${journeyId}`);\n failSpinner(`Error exporting journey ${journeyId}: ${error}`);\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n const filePath = getFilePath(file, true);\n const trees = await readJourneys();\n const fileData: MultiTreeExportInterface = createMultiTreeExportTemplate();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n try {\n const exportData = await exportJourney(tree._id, options);\n delete exportData.meta;\n fileData.trees[tree._id] = exportData;\n } catch (error) {\n printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');\n }\n }\n saveJsonToFile(fileData, filePath);\n stopProgressBar(`Exported to ${filePath}`);\n}\n\n/**\n * Export all journeys to separate files\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n options: TreeExportOptions\n): Promise<void> {\n const trees = await readJourneys();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n const fileName = getTypedFilename(`${tree._id}`, 'journey');\n try {\n const exportData: SingleTreeExportInterface = await exportJourney(\n tree._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(fileName, true));\n } catch (error) {\n // do we need to report status here?\n }\n }\n stopProgressBar('Done');\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${journeyId} not found!`);\n }\n });\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n showSpinner(`Importing...`);\n failSpinner(`No journeys found!`);\n }\n // end dependency resolution for single tree import\n });\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n fs.readFile(getFilePath(file), 'utf8', (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n importJourneys(fileData.trees, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n });\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.journey.json'))\n .map((name) => getFilePath(name));\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(\n allJourneysData.trees as MultiTreeExportInterface,\n options\n );\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAYpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AACrD,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AACnD,OAAO,KAAKC,GAAG,MAAM,UAAU;AAC/B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAM;EACJC,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGzB,KAAK,CAAC0B,KAAK;AACf,MAAM;EACJC,YAAY;EACZC,aAAa;EACbC,6BAA6B;EAC7BC,mBAAmB;EACnBC,cAAc;EACdC,aAAa;EACbC,kBAAkB;EAClBC,UAAU;EACVC,wBAAwB;EACxBC,wBAAwB,EAAEC;AAC5B,CAAC,GAAGrC,KAAK,CAACsC,KAAK,CAACC,OAAO;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,IAAI,GAAG,KAAK,EACZC,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,MAC3C,GAAE,EACH,MACF,CAAC;IACDxE,YAAY,CAACS,KAAK,CAAC0J,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IAC9C,KAAK,MAAMR,kBAAkB,IAAIrE,MAAM,CAACgC,MAAM,CAACtC,WAAW,CAAC0E,aAAa,CAAC,EAAE;MACzE1J,YAAY,CAAE,GAAES,KAAK,CAAC2J,aAAa,CAACT,kBAAkB,CAAE,EAAC,EAAE,MAAM,CAAC;IACpE;EACF;;EAEA;EACA,IAAIrE,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAAM,EAAE;IACrDxE,YAAY,CACT,8BACCsF,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAC5C,GAAE,EACH,MACF,CAAC;IACDxE,YAAY,CAACK,cAAc,CAAC8J,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACvD,KAAK,MAAMN,OAAO,IAAIvE,MAAM,CAACgC,MAAM,CAACtC,WAAW,CAAC4E,cAAc,CAAC,EAAE;MAC/D5J,YAAY,CAAE,GAAEK,cAAc,CAAC+J,aAAa,CAACP,OAAO,CAAE,EAAC,EAAE,MAAM,CAAC;IAClE;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","getFilePath","getWorkingDirectory","utils","readJourneys","exportJourney","createMultiTreeExportTemplate","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","options","verbose","getVerbose","filePath","fileData","exportJourneysToFile","trees","length","exportData","meta","exportJourneysToFiles","fileName","importJourneyFromFile","readFile","err","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","Object","keys","then","catch","importError","importFirstJourneyFromFile","treeId","hasOwnProperty","call","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","readFileSync","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","entries","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n saveJsonToFile,\n getRealmString,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n createMultiTreeExportTemplate,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n showSpinner('Retrieving details of all journeys...');\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n succeedSpinner('Retrieved details of all journeys.');\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n failSpinner('Error retrieving details of all journeys.');\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n options: TreeExportOptions\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getVerbose();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n const filePath = getFilePath(file, true);\n if (!verbose) showSpinner(`${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose) showSpinner(`${journeyId}`);\n saveJsonToFile(fileData, filePath);\n succeedSpinner(\n `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (error) {\n if (verbose) showSpinner(`${journeyId}`);\n failSpinner(`Error exporting journey ${journeyId}: ${error}`);\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n const filePath = getFilePath(file, true);\n const trees = await readJourneys();\n const fileData: MultiTreeExportInterface = createMultiTreeExportTemplate();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n try {\n const exportData = await exportJourney(tree._id, options);\n delete exportData.meta;\n fileData.trees[tree._id] = exportData;\n } catch (error) {\n printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');\n }\n }\n saveJsonToFile(fileData, filePath);\n stopProgressBar(`Exported to ${filePath}`);\n}\n\n/**\n * Export all journeys to separate files\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n options: TreeExportOptions\n): Promise<void> {\n const trees = await readJourneys();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n const fileName = getTypedFilename(`${tree._id}`, 'journey');\n try {\n const exportData: SingleTreeExportInterface = await exportJourney(\n tree._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(fileName, true));\n } catch (error) {\n // do we need to report status here?\n }\n }\n stopProgressBar('Done');\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${journeyId} not found!`);\n }\n });\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n showSpinner(`Importing...`);\n failSpinner(`No journeys found!`);\n }\n // end dependency resolution for single tree import\n });\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n fs.readFile(getFilePath(file), 'utf8', (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n importJourneys(fileData.trees, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n });\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.journey.json'))\n .map((name) => getFilePath(name));\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(\n allJourneysData.trees as MultiTreeExportInterface,\n options\n );\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }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,CAAE,EAAC,EAAE,MAAM,CAAC;IACpE;EACF;;EAEA;EACA,IAAIrE,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAAM,EAAE;IACrDxE,YAAY,CACT,8BACCsF,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAC5C,GAAE,EACH,MACF,CAAC;IACDxE,YAAY,CAACK,cAAc,CAAC8J,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACvD,KAAK,MAAMN,OAAO,IAAIvE,MAAM,CAACgC,MAAM,CAACtC,WAAW,CAAC4E,cAAc,CAAC,EAAE;MAC/D5J,YAAY,CAAE,GAAEK,cAAc,CAAC+J,aAAa,CAACP,OAAO,CAAE,EAAC,EAAE,MAAM,CAAC;IAClE;EACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
|
|
6
6
|
"keywords": [
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"@rockcarver/frodo-lib": "2.0.0-
|
|
110
|
+
"@rockcarver/frodo-lib": "2.0.0-43",
|
|
111
111
|
"chokidar": "^3.5.3",
|
|
112
112
|
"cli-progress": "^3.11.2",
|
|
113
113
|
"cli-table3": "^0.6.3",
|