@rockcarver/frodo-lib 0.13.2-0 → 0.14.1
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 +33 -1
- package/cjs/api/ApiTypes.js.map +1 -1
- package/cjs/api/ThemeApi.js +132 -40
- package/cjs/api/ThemeApi.js.map +1 -1
- package/cjs/api/ThemeApi.test.js.map +1 -0
- package/cjs/index.js +5 -1
- package/cjs/index.js.map +1 -1
- package/cjs/ops/JourneyOps.js +260 -237
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/ThemeOps.js +103 -84
- package/cjs/ops/ThemeOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +21 -5
- package/cjs/ops/utils/Console.js.map +1 -1
- package/cjs/storage/SessionStorage.js +6 -0
- package/cjs/storage/SessionStorage.js.map +1 -1
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +2 -1
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
- package/esm/api/ThemeApi.mjs +129 -41
- package/esm/api/ThemeApi.test.mjs +903 -0
- package/esm/index.mjs +2 -1
- package/esm/ops/JourneyOps.mjs +259 -236
- package/esm/ops/ThemeOps.mjs +44 -34
- package/esm/ops/utils/Console.mjs +18 -4
- package/esm/storage/SessionStorage.mjs +6 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +2 -2
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
- package/package.json +1 -1
- package/types/api/ApiTypes.d.ts +5 -1
- package/types/api/ApiTypes.d.ts.map +1 -1
- package/types/api/ThemeApi.d.ts +28 -26
- package/types/api/ThemeApi.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/ThemeOps.d.ts +5 -0
- package/types/ops/ThemeOps.d.ts.map +1 -1
- package/types/ops/utils/Console.d.ts +11 -4
- package/types/ops/utils/Console.d.ts.map +1 -1
- package/types/storage/SessionStorage.d.ts +6 -0
- package/types/storage/SessionStorage.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
|
@@ -1648,7 +1648,7 @@
|
|
|
1648
1648
|
"topBarTextColor": "#69788b"
|
|
1649
1649
|
},
|
|
1650
1650
|
{
|
|
1651
|
-
"_id": "
|
|
1651
|
+
"_id": "d6636b33-111b-40f2-870d-f4dcb7281e43",
|
|
1652
1652
|
"accountFooter": "<div class=\"d-flex justify-content-center py-4 w-100\"><span class=\"pr-1\">© 2021</span>\n<a href=\"#\"target=\"_blank\"class=\"text-body\">My Company, Inc</a><a href=\"#\"target=\"_blank\"style=\"color:#0000ee\"class=\"pl-3 text-body\">Privacy Policy</a><a href=\"#\"target=\"_blank\"style=\"color:#0000ee\"class=\"pl-3 text-body\">Terms & Conditions</a></div>",
|
|
1653
1653
|
"accountFooterEnabled": false,
|
|
1654
1654
|
"accountPageSections": {
|
package/package.json
CHANGED
package/types/api/ApiTypes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface ObjectSkeletonInterface {
|
|
2
2
|
_id: string;
|
|
3
3
|
_rev?: number;
|
|
4
|
-
[k: string]: string | number | ObjectSkeletonInterface;
|
|
4
|
+
[k: string]: string | number | boolean | string[] | ObjectSkeletonInterface;
|
|
5
5
|
}
|
|
6
6
|
export interface UiConfigInterface {
|
|
7
7
|
categories: string;
|
|
@@ -50,6 +50,10 @@ export declare type ThemeSkeleton = ObjectSkeletonInterface & {
|
|
|
50
50
|
isDefault: boolean;
|
|
51
51
|
linkedTrees: string[];
|
|
52
52
|
};
|
|
53
|
+
export declare type UiThemeRealmObject = ObjectSkeletonInterface & {
|
|
54
|
+
name: string;
|
|
55
|
+
realm: Map<string, ThemeSkeleton[]>;
|
|
56
|
+
};
|
|
53
57
|
export declare enum ScriptLanguage {
|
|
54
58
|
GROOVY = "GROOVY",
|
|
55
59
|
JAVASCRIPT = "JAVASCRIPT"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/ApiTypes.ts"],"names":[],"mappings":"AAAA,UAAU,uBAAuB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/api/ApiTypes.ts"],"names":[],"mappings":"AAAA,UAAU,uBAAuB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,uBAAuB,CAAC;CAC7E;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC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["interface ObjectSkeletonInterface {\n _id: string;\n _rev?: number;\n [k: string]: string | number | boolean | string[] | ObjectSkeletonInterface;\n}\n\nexport interface UiConfigInterface {\n categories: string;\n}\n\nexport interface NodeRefSkeletonInterface {\n connections: Record<string, string>;\n displayName: string;\n nodeType: string;\n x: number;\n y: number;\n}\n\nexport interface InnerNodeRefSkeletonInterface {\n _id: string;\n displayName: string;\n nodeType: string;\n}\n\nexport type TreeSkeleton = ObjectSkeletonInterface & {\n entryNodeId: string;\n nodes: Record<string, NodeRefSkeletonInterface>;\n identityResource?: string;\n uiConfig?: UiConfigInterface;\n enabled?: boolean;\n};\n\nexport type AmServiceType = ObjectSkeletonInterface & {\n name: string;\n};\n\nexport type NodeSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n nodes?: InnerNodeRefSkeletonInterface[];\n tree?: string;\n identityResource?: string;\n};\n\nexport type SocialIdpSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n enabled: boolean;\n};\n\nexport type EmailTemplateSkeleton = ObjectSkeletonInterface & {\n defaultLocale?: string;\n displayName?: string;\n enabled?: boolean;\n from: string;\n subject: Record<string, string>;\n};\n\nexport type ThemeSkeleton = ObjectSkeletonInterface & {\n name: string;\n isDefault: boolean;\n linkedTrees: string[];\n};\n\nexport type UiThemeRealmObject = ObjectSkeletonInterface & {\n name: string;\n realm: Map<string, ThemeSkeleton[]>;\n};\n\nexport enum ScriptLanguage {\n GROOVY = 'GROOVY',\n JAVASCRIPT = 'JAVASCRIPT',\n}\n\nexport enum ScriptContext {\n OAUTH2_ACCESS_TOKEN_MODIFICATION = 'OAUTH2_ACCESS_TOKEN_MODIFICATION',\n AUTHENTICATION_CLIENT_SIDE = 'AUTHENTICATION_CLIENT_SIDE',\n AUTHENTICATION_TREE_DECISION_NODE = 'AUTHENTICATION_TREE_DECISION_NODE',\n AUTHENTICATION_SERVER_SIDE = 'AUTHENTICATION_SERVER_SIDE',\n SOCIAL_IDP_PROFILE_TRANSFORMATION = 'SOCIAL_IDP_PROFILE_TRANSFORMATION',\n OAUTH2_VALIDATE_SCOPE = 'OAUTH2_VALIDATE_SCOPE',\n CONFIG_PROVIDER_NODE = 'CONFIG_PROVIDER_NODE',\n OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER = 'OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER',\n OAUTH2_EVALUATE_SCOPE = 'OAUTH2_EVALUATE_SCOPE',\n POLICY_CONDITION = 'POLICY_CONDITION',\n OIDC_CLAIMS = 'OIDC_CLAIMS',\n SAML2_IDP_ADAPTER = 'SAML2_IDP_ADAPTER',\n SAML2_IDP_ATTRIBUTE_MAPPER = 'SAML2_IDP_ATTRIBUTE_MAPPER',\n OAUTH2_MAY_ACT = 'OAUTH2_MAY_ACT',\n}\n\nexport type ScriptSkeleton = ObjectSkeletonInterface & {\n name: string;\n description: string;\n isDefault: boolean;\n script: string;\n language: ScriptLanguage;\n context: ScriptContext;\n createdBy: string;\n creationDate: number;\n lastModifiedBy: string;\n lastModifiedDate: number;\n};\n\nexport enum Saml2ProiderLocation {\n HOSTED = 'hosted',\n REMOTE = 'remote',\n}\n\nexport type Saml2ProviderSkeleton = ObjectSkeletonInterface & {\n entityId: string;\n entityLocation: Saml2ProiderLocation;\n serviceProvider: unknown;\n identityProvider: unknown;\n attributeQueryProvider: unknown;\n xacmlPolicyEnforcementPoint: unknown;\n};\n\nexport type CircleOfTrustSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n status: string;\n trustedProviders: string[];\n};\n"]}
|
package/types/api/ThemeApi.d.ts
CHANGED
|
@@ -1,54 +1,56 @@
|
|
|
1
|
+
import { ThemeSkeleton } from './ApiTypes';
|
|
2
|
+
export declare const THEMEREALM_ID = "ui/themerealm";
|
|
1
3
|
/**
|
|
2
4
|
* Get all themes
|
|
3
|
-
* @returns {Promise} a promise that resolves to an array of themes
|
|
5
|
+
* @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
|
|
4
6
|
*/
|
|
5
|
-
export declare function getThemes(): Promise<
|
|
7
|
+
export declare function getThemes(): Promise<ThemeSkeleton[]>;
|
|
6
8
|
/**
|
|
7
9
|
* Get theme by id
|
|
8
|
-
* @param {
|
|
9
|
-
* @returns {Promise} a promise that resolves to
|
|
10
|
+
* @param {string} themeId theme id
|
|
11
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
10
12
|
*/
|
|
11
|
-
export declare function getTheme(themeId:
|
|
13
|
+
export declare function getTheme(themeId: string): Promise<ThemeSkeleton>;
|
|
12
14
|
/**
|
|
13
15
|
* Get theme by name
|
|
14
|
-
* @param {
|
|
15
|
-
* @returns {Promise} a promise that resolves to
|
|
16
|
+
* @param {string} themeName theme name
|
|
17
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
16
18
|
*/
|
|
17
|
-
export declare function getThemeByName(themeName:
|
|
19
|
+
export declare function getThemeByName(themeName: string): Promise<ThemeSkeleton>;
|
|
18
20
|
/**
|
|
19
21
|
* Put theme by id
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @returns {Promise} a promise that resolves to a
|
|
22
|
+
* @param {string} themeId theme id
|
|
23
|
+
* @param {ThemeSkeleton} themeData theme object
|
|
24
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
23
25
|
*/
|
|
24
|
-
export declare function putTheme(themeId:
|
|
26
|
+
export declare function putTheme(themeId: string, themeData: ThemeSkeleton): Promise<ThemeSkeleton>;
|
|
25
27
|
/**
|
|
26
28
|
* Put theme by name
|
|
27
29
|
* @param {String} themeName theme name
|
|
28
|
-
* @param {
|
|
29
|
-
* @returns {Promise} a promise that resolves to a
|
|
30
|
+
* @param {ThemeSkeleton} themeData theme object
|
|
31
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
30
32
|
*/
|
|
31
|
-
export declare function putThemeByName(themeName:
|
|
33
|
+
export declare function putThemeByName(themeName: string, themeData: ThemeSkeleton): Promise<ThemeSkeleton>;
|
|
32
34
|
/**
|
|
33
35
|
* Put all themes
|
|
34
|
-
* @param {
|
|
35
|
-
* @returns {Promise} a promise that resolves to a themes object
|
|
36
|
+
* @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms
|
|
37
|
+
* @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object
|
|
36
38
|
*/
|
|
37
|
-
export declare function putThemes(
|
|
39
|
+
export declare function putThemes(themeMap: Map<string, ThemeSkeleton>): Promise<Map<string, ThemeSkeleton>>;
|
|
38
40
|
/**
|
|
39
41
|
* Delete theme by id
|
|
40
|
-
* @param {
|
|
41
|
-
* @returns {Promise} a promise that resolves to a themes object
|
|
42
|
+
* @param {string} themeId theme id
|
|
43
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
|
|
42
44
|
*/
|
|
43
|
-
export declare function deleteTheme(themeId:
|
|
45
|
+
export declare function deleteTheme(themeId: string): Promise<ThemeSkeleton>;
|
|
44
46
|
/**
|
|
45
47
|
* Delete theme by name
|
|
46
|
-
* @param {
|
|
47
|
-
* @returns {Promise} a promise that resolves to a themes object
|
|
48
|
+
* @param {string} themeName theme name
|
|
49
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
|
|
48
50
|
*/
|
|
49
|
-
export declare function deleteThemeByName(themeName:
|
|
51
|
+
export declare function deleteThemeByName(themeName: string): Promise<ThemeSkeleton>;
|
|
50
52
|
/**
|
|
51
53
|
* Delete all themes
|
|
52
|
-
* @returns {Promise} a promise that resolves to an array of themes
|
|
54
|
+
* @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
|
|
53
55
|
*/
|
|
54
|
-
export declare function deleteThemes(): Promise<
|
|
56
|
+
export declare function deleteThemes(): Promise<ThemeSkeleton[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/ThemeApi.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,wBAAsB,SAAS,iBAG9B;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,KAAA,gBAGrC;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,SAAS,KAAA,gBAG7C;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,OAAO,KAAA,EAAE,SAAS,KAAA,gBAmBhD;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,gBAmBxD;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,aAAa,KAAA,gBAmC5C;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,KAAA,gBAQxC;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,KAAA,gBAQhD;AAED;;;GAGG;AACH,wBAAsB,YAAY,iBAIjC","file":"ThemeApi.d.ts","sourcesContent":["import { getConfigEntity, putConfigEntity } from './IdmConfigApi';\nimport { getCurrentRealmName } from './utils/ApiUtils';\n\nconst THEMEREALM_ID = 'ui/themerealm';\n\n/**\n * Get realm themes\n * @param {Object} themes object containing themes\n * @returns {Object} array of theme pertaining to the current realm\n */\nfunction getRealmThemes(themes) {\n return themes.realm[getCurrentRealmName()]\n ? themes.realm[getCurrentRealmName()]\n : [];\n}\n\n/**\n * Get all themes\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getThemes() {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes);\n}\n\n/**\n * Get theme by id\n * @param {String} themeId theme id\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getTheme(themeId) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes).filter((theme) => theme._id === themeId);\n}\n\n/**\n * Get theme by name\n * @param {String} themeName theme name\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getThemeByName(themeName) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes).filter((theme) => theme.name === themeName);\n}\n\n/**\n * Put theme by id\n * @param {String} themeId theme id\n * @param {Object} themeData theme object\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putTheme(themeId, themeData) {\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {Object} themeData theme object\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putThemeByName(themeName, themeData) {\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Put all themes\n * @param {Object} allThemesData themes object containing all themes for all realms\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putThemes(allThemesData) {\n const data = allThemesData;\n const themes = await getConfigEntity(THEMEREALM_ID);\n const allThemeIDs = Object.keys(data);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes(themes).map((theme) => {\n if (data[theme._id]) {\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (data[theme._id].isDefault) defaultThemeId = theme._id;\n return data[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n // remember the id of the last default theme\n if (data[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(data[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n // eslint-disable-next-line no-param-reassign\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete theme by id\n * @param {String} themeId theme id\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function deleteTheme(themeId) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const finalThemes = realmThemes.filter((theme) => theme._id !== themeId);\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeId} not found`);\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete theme by name\n * @param {String} themeName theme name\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName(themeName) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const finalThemes = realmThemes.filter((theme) => theme.name !== themeName);\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeName} not found`);\n themes.realm[getCurrentRealmName()] = finalThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete all themes\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function deleteThemes() {\n const themes = await getConfigEntity(THEMEREALM_ID);\n themes.realm[getCurrentRealmName()] = [];\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/ThemeApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,YAAY,CAAC;AAK/D,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAc7C;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAG1D;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAUtE;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAYxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,aAAa,CAAC,CA4BxB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,aAAa,CAAC,CA4BxB;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CA4CrC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAyBzE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CA0BxB;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAc7D","file":"ThemeApi.d.ts","sourcesContent":["import { ThemeSkeleton, UiThemeRealmObject } from './ApiTypes';\nimport { getConfigEntity, putConfigEntity } from './IdmConfigApi';\nimport { getCurrentRealmName } from './utils/ApiUtils';\nimport { debug } from '../ops/utils/Console';\n\nexport const THEMEREALM_ID = 'ui/themerealm';\n\n/**\n * Get realm themes\n * @param {UiThemeRealmObject} themes object containing themes\n * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm\n */\nfunction getRealmThemes(themes: UiThemeRealmObject): ThemeSkeleton[] {\n if (themes.realm && themes.realm[getCurrentRealmName()]) {\n return themes.realm[getCurrentRealmName()];\n }\n return [];\n}\n\n/**\n * Get all themes\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function getThemes(): Promise<ThemeSkeleton[]> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes);\n}\n\n/**\n * Get theme by id\n * @param {string} themeId theme id\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getTheme(themeId: string): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const found = getRealmThemes(themes).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with id \"${themeId}\" found!`);\n }\n throw new Error(`Theme with id \"${themeId}\" not found!`);\n}\n\n/**\n * Get theme by name\n * @param {string} themeName theme name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getThemeByName(\n themeName: string\n): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const found = getRealmThemes(themes).filter(\n (theme) => theme.name === themeName\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with the name \"${themeName}\" found!`);\n }\n throw new Error(`Theme \"${themeName}\" not found!`);\n}\n\n/**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putTheme(\n themeId: string,\n themeData: ThemeSkeleton\n): Promise<ThemeSkeleton> {\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n const found = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with id \"${themeId}\" found!`);\n }\n throw new Error(`Theme with id \"${themeId}\" not saved!`);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putThemeByName(\n themeName: string,\n themeData: ThemeSkeleton\n): Promise<ThemeSkeleton> {\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][getCurrentRealmName()] = realmThemes;\n const found = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => theme.name === themeName);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes \"${themeName}\" found!`);\n }\n throw new Error(`Theme \"${themeName}\" not saved!`);\n}\n\n/**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\nexport async function putThemes(\n themeMap: Map<string, ThemeSkeleton>\n): Promise<Map<string, ThemeSkeleton>> {\n debug(`ThemeApi.putThemes: start`);\n const themes = await getConfigEntity(THEMEREALM_ID);\n const allThemeIDs = Object.keys(themeMap);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes(themes).map((theme) => {\n if (themeMap[theme._id]) {\n debug(`Update theme: ${theme._id} - ${theme.name}`);\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;\n return themeMap[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n debug(`Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`);\n // remember the id of the last default theme\n if (themeMap[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(themeMap[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n // eslint-disable-next-line no-param-reassign\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n const updatedThemes = new Map(\n getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).map(\n (theme) => [theme._id, theme]\n )\n );\n debug(updatedThemes);\n debug(`ThemeApi.putThemes: finished`);\n return updatedThemes;\n}\n\n/**\n * Delete theme by id\n * @param {string} themeId theme id\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteTheme(themeId: string): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme._id !== themeId) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeId} not found`);\n themes.realm[getCurrentRealmName()] = realmThemes;\n const undeletedThemes = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) \"${undeletedThemes.map(\n (theme) => theme._id\n )}\" not deleted!`\n );\n}\n\n/**\n * Delete theme by name\n * @param {string} themeName theme name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName(\n themeName: string\n): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme.name !== themeName) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeName} not found`);\n themes.realm[getCurrentRealmName()] = finalThemes;\n // return putConfigEntity(THEMEREALM_ID, themes);\n const undeletedThemes = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) \"${undeletedThemes.map(\n (theme) => theme._id\n )}\" not deleted!`\n );\n}\n\n/**\n * Delete all themes\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function deleteThemes(): Promise<ThemeSkeleton[]> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = themes.realm[getCurrentRealmName()];\n if (!realmThemes)\n throw new Error(\n `No theme configuration found for realm \"${getCurrentRealmName()}\"`\n );\n const deletedThemes: ThemeSkeleton[] = [];\n for (const theme of realmThemes) {\n deletedThemes.push(theme);\n }\n themes.realm[getCurrentRealmName()] = [];\n await putConfigEntity(THEMEREALM_ID, themes);\n return deletedThemes;\n}\n"]}
|
package/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * as TreeRaw from './api/TreeApi';
|
|
|
5
5
|
export * as StartupRaw from './api/StartupApi';
|
|
6
6
|
export * as SecretsRaw from './api/SecretsApi';
|
|
7
7
|
export * as VariablesRaw from './api/VariablesApi';
|
|
8
|
+
export * as ThemeRaw from './api/ThemeApi';
|
|
8
9
|
export * as Types from './ops/OpsTypes';
|
|
9
10
|
export * as Admin from './ops/AdminOps';
|
|
10
11
|
export * as Authenticate from './ops/AuthenticateOps';
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAaA,wBAAgB,UAAU,WAEzB;AAGD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAaA,wBAAgB,UAAU,WAEzB;AAGD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAG9C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAIlD,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC","file":"index.d.ts","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport Color from 'colors';\n\nColor.enable();\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')\n);\n\nexport function getVersion() {\n return `v${pkg.version}`;\n}\n\n// Api Layer\nexport * as TypesRaw from './api/ApiTypes';\nexport * as NodeRaw from './api/NodeApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as StartupRaw from './api/StartupApi';\nexport * as SecretsRaw from './api/SecretsApi';\nexport * as VariablesRaw from './api/VariablesApi';\nexport * as ThemeRaw from './api/ThemeApi';\n\n// Ops Layer\nexport * as Types from './ops/OpsTypes';\nexport * as Admin from './ops/AdminOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Log from './ops/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Node from './ops/NodeOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Secrets from './ops/SecretsOps';\nexport * as Startup from './ops/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Variables from './ops/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './storage/SessionStorage';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\n"]}
|