@rockcarver/frodo-lib 0.16.2-9 → 0.17.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 +222 -1
- package/cjs/api/AgentApi.js +14 -61
- package/cjs/api/AgentApi.js.map +1 -1
- package/cjs/api/AgentApi.test.js.map +1 -1
- package/cjs/api/ApiTypes.js +0 -5
- package/cjs/api/ApiTypes.js.map +1 -1
- package/cjs/api/AuthenticateApi.js +9 -20
- package/cjs/api/AuthenticateApi.js.map +1 -1
- package/cjs/api/AuthenticateApi.test.js.map +1 -0
- package/cjs/api/BaseApi.js +82 -124
- package/cjs/api/BaseApi.js.map +1 -1
- package/cjs/api/CirclesOfTrustApi.js +8 -32
- package/cjs/api/CirclesOfTrustApi.js.map +1 -1
- package/cjs/api/IdmConfigApi.js +9 -34
- package/cjs/api/IdmConfigApi.js.map +1 -1
- package/cjs/api/LogApi.js +8 -31
- package/cjs/api/LogApi.js.map +1 -1
- package/cjs/api/ManagedObjectApi.js +34 -31
- package/cjs/api/ManagedObjectApi.js.map +1 -1
- package/cjs/api/NodeApi.js +10 -41
- package/cjs/api/NodeApi.js.map +1 -1
- package/cjs/api/NodeApi.test.js.map +1 -1
- package/cjs/api/OAuth2ClientApi.js +7 -26
- package/cjs/api/OAuth2ClientApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.js +28 -34
- package/cjs/api/OAuth2OIDCApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
- package/cjs/api/OAuth2ProviderApi.js +5 -15
- package/cjs/api/OAuth2ProviderApi.js.map +1 -1
- package/cjs/api/RealmApi.js +8 -34
- package/cjs/api/RealmApi.js.map +1 -1
- package/cjs/api/Saml2Api.js +16 -67
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +8 -30
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/api/SecretsApi.js +14 -64
- package/cjs/api/SecretsApi.js.map +1 -1
- package/cjs/api/SecretsApi.test.js.map +1 -1
- package/cjs/api/ServerInfoApi.js +6 -21
- package/cjs/api/ServerInfoApi.js.map +1 -1
- package/cjs/api/ServiceApi.js +49 -47
- package/cjs/api/ServiceApi.js.map +1 -1
- package/cjs/api/SocialIdentityProvidersApi.js +9 -36
- package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
- package/cjs/api/StartupApi.js +5 -24
- package/cjs/api/StartupApi.js.map +1 -1
- package/cjs/api/StartupApi.test.js.map +1 -1
- package/cjs/api/TreeApi.js +8 -30
- package/cjs/api/TreeApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -1
- package/cjs/api/VariablesApi.js +9 -37
- package/cjs/api/VariablesApi.js.map +1 -1
- package/cjs/api/VariablesApi.test.js.map +1 -1
- package/cjs/api/utils/ApiUtils.js +47 -57
- package/cjs/api/utils/ApiUtils.js.map +1 -1
- package/cjs/api/utils/ApiUtils.test.js.map +1 -1
- package/cjs/api/utils/Base64.js +5 -15
- package/cjs/api/utils/Base64.js.map +1 -1
- package/cjs/ext/axios-curlirize/curlirize.js +2 -9
- package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
- package/cjs/index.js +30 -89
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AdminOps.js +27 -165
- package/cjs/ops/AdminOps.js.map +1 -1
- package/cjs/ops/AgentOps.js +2 -159
- package/cjs/ops/AgentOps.js.map +1 -1
- package/cjs/ops/AgentOps.test.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +266 -226
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/AuthenticateOps.test.js.map +1 -1
- package/cjs/ops/CirclesOfTrustOps.js +13 -91
- package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.js +220 -136
- package/cjs/ops/ConnectionProfileOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.js +35 -379
- package/cjs/ops/EmailTemplateOps.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
- package/cjs/ops/IdmOps.js +52 -426
- package/cjs/ops/IdmOps.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -1
- package/cjs/ops/IdpOps.js +11 -94
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -1
- package/cjs/ops/JoseOps.js +81 -0
- package/cjs/ops/JoseOps.js.map +1 -0
- package/cjs/ops/JoseOps.test.js.map +1 -0
- package/cjs/ops/JourneyOps.js +139 -370
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/LogOps.js +14 -47
- package/cjs/ops/LogOps.js.map +1 -1
- package/cjs/ops/ManagedObjectOps.js +4 -12
- package/cjs/ops/ManagedObjectOps.js.map +1 -1
- package/cjs/ops/NodeOps.js +9 -67
- package/cjs/ops/NodeOps.js.map +1 -1
- package/cjs/ops/OAuth2ClientOps.js +10 -40
- package/cjs/ops/OAuth2ClientOps.js.map +1 -1
- package/cjs/ops/OpsTypes.js +0 -5
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/OrganizationOps.js +6 -25
- package/cjs/ops/OrganizationOps.js.map +1 -1
- package/cjs/ops/RealmOps.js +0 -19
- package/cjs/ops/RealmOps.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +11 -107
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +26 -73
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/SecretsOps.js +2 -58
- package/cjs/ops/SecretsOps.js.map +1 -1
- package/cjs/ops/ServiceAccountOps.js +61 -0
- package/cjs/ops/ServiceAccountOps.js.map +1 -0
- package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
- package/cjs/ops/ServiceOps.js +55 -101
- package/cjs/ops/ServiceOps.js.map +1 -1
- package/cjs/ops/StartupOps.js +2 -23
- package/cjs/ops/StartupOps.js.map +1 -1
- package/cjs/ops/ThemeOps.js +230 -436
- package/cjs/ops/ThemeOps.js.map +1 -1
- package/cjs/ops/ThemeOps.test.js.map +1 -0
- package/cjs/ops/VariablesOps.js +0 -38
- package/cjs/ops/VariablesOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +29 -62
- package/cjs/ops/utils/Console.js.map +1 -1
- package/cjs/ops/utils/DataProtection.js +13 -47
- package/cjs/ops/utils/DataProtection.js.map +1 -1
- package/cjs/ops/utils/DataProtection.test.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.js +36 -74
- package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.js +27 -43
- package/cjs/ops/utils/OpsUtils.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.js +0 -13
- package/cjs/ops/utils/ValidationUtils.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
- package/cjs/ops/utils/Version.js +2 -12
- package/cjs/ops/utils/Version.js.map +1 -1
- package/cjs/ops/utils/Version.test.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.js +1 -2
- package/cjs/ops/utils/Wordwrap.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
- package/cjs/shared/State.js +239 -0
- package/cjs/shared/State.js.map +1 -0
- package/cjs/shared/State.test.js.map +1 -0
- package/cjs/storage/StaticStorage.js.map +1 -1
- package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +161 -83
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/cjs/utils/AutoSetupPolly.js +79 -0
- package/cjs/utils/AutoSetupPolly.js.map +1 -0
- package/cjs/utils/SetupJest.js +6 -0
- package/cjs/utils/SetupJest.js.map +1 -0
- package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
- package/cjs/utils/snapshotResolve.js.map +1 -0
- package/esm/api/AgentApi.mjs +19 -21
- package/esm/api/AgentApi.test.mjs +6 -15
- package/esm/api/ApiTypes.mjs +0 -5
- package/esm/api/AuthenticateApi.mjs +7 -10
- package/esm/api/AuthenticateApi.test.mjs +39 -0
- package/esm/api/BaseApi.mjs +96 -81
- package/esm/api/CirclesOfTrustApi.mjs +9 -12
- package/esm/api/IdmConfigApi.mjs +11 -12
- package/esm/api/LogApi.mjs +6 -10
- package/esm/api/ManagedObjectApi.mjs +23 -8
- package/esm/api/NodeApi.mjs +13 -15
- package/esm/api/NodeApi.test.mjs +13 -17
- package/esm/api/OAuth2ClientApi.mjs +7 -9
- package/esm/api/OAuth2OIDCApi.mjs +15 -9
- package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
- package/esm/api/OAuth2ProviderApi.mjs +3 -5
- package/esm/api/RealmApi.mjs +10 -13
- package/esm/api/Saml2Api.mjs +25 -29
- package/esm/api/ScriptApi.mjs +9 -11
- package/esm/api/SecretsApi.mjs +21 -24
- package/esm/api/SecretsApi.test.mjs +9 -31
- package/esm/api/ServerInfoApi.mjs +5 -9
- package/esm/api/ServiceApi.mjs +53 -26
- package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
- package/esm/api/StartupApi.mjs +5 -10
- package/esm/api/StartupApi.test.mjs +4 -7
- package/esm/api/TreeApi.mjs +9 -11
- package/esm/api/TreeApi.test.mjs +24 -61
- package/esm/api/VariablesApi.mjs +11 -13
- package/esm/api/VariablesApi.test.mjs +80 -222
- package/esm/api/utils/ApiUtils.mjs +45 -48
- package/esm/api/utils/ApiUtils.test.mjs +33 -32
- package/esm/api/utils/Base64.mjs +5 -9
- package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
- package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
- package/esm/index.mjs +23 -13
- package/esm/ops/AdminOps.mjs +33 -119
- package/esm/ops/AgentOps.mjs +37 -80
- package/esm/ops/AgentOps.test.mjs +5 -45
- package/esm/ops/AuthenticateOps.mjs +242 -175
- package/esm/ops/AuthenticateOps.test.mjs +7 -9
- package/esm/ops/CirclesOfTrustOps.mjs +24 -61
- package/esm/ops/ConnectionProfileOps.mjs +192 -82
- package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
- package/esm/ops/EmailTemplateOps.mjs +18 -276
- package/esm/ops/EmailTemplateOps.test.mjs +19 -44
- package/esm/ops/IdmOps.mjs +30 -327
- package/esm/ops/IdmOps.test.mjs +47 -54
- package/esm/ops/IdpOps.mjs +21 -59
- package/esm/ops/IdpOps.test.mjs +5 -5
- package/esm/ops/JoseOps.mjs +41 -0
- package/esm/ops/JoseOps.test.mjs +137 -0
- package/esm/ops/JourneyOps.mjs +146 -289
- package/esm/ops/JourneyOps.test.mjs +29 -27
- package/esm/ops/LogOps.mjs +15 -25
- package/esm/ops/ManagedObjectOps.mjs +6 -6
- package/esm/ops/NodeOps.mjs +9 -47
- package/esm/ops/OAuth2ClientOps.mjs +13 -19
- package/esm/ops/OpsTypes.mjs +1 -3
- package/esm/ops/OrganizationOps.mjs +7 -14
- package/esm/ops/RealmOps.mjs +4 -7
- package/esm/ops/Saml2Ops.mjs +28 -62
- package/esm/ops/Saml2Ops.test.mjs +20 -23
- package/esm/ops/ScriptOps.mjs +29 -47
- package/esm/ops/SecretsOps.mjs +15 -31
- package/esm/ops/ServiceAccountOps.mjs +41 -0
- package/esm/ops/ServiceAccountOps.test.mjs +51 -0
- package/esm/ops/ServiceOps.mjs +66 -83
- package/esm/ops/StartupOps.mjs +4 -13
- package/esm/ops/ThemeOps.mjs +189 -298
- package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
- package/esm/ops/VariablesOps.mjs +9 -18
- package/esm/ops/utils/Console.mjs +28 -46
- package/esm/ops/utils/DataProtection.mjs +15 -28
- package/esm/ops/utils/DataProtection.test.mjs +8 -8
- package/esm/ops/utils/ExportImportUtils.mjs +34 -43
- package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
- package/esm/ops/utils/OpsUtils.mjs +27 -21
- package/esm/ops/utils/OpsUtils.test.mjs +155 -27
- package/esm/ops/utils/ValidationUtils.mjs +0 -9
- package/esm/ops/utils/Version.mjs +2 -3
- package/esm/ops/utils/Version.test.mjs +0 -2
- package/esm/ops/utils/Wordwrap.mjs +1 -1
- package/esm/ops/utils/Wordwrap.test.mjs +19 -0
- package/esm/shared/State.mjs +164 -0
- package/esm/shared/State.test.mjs +249 -0
- package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +147 -31
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/esm/utils/AutoSetupPolly.mjs +72 -0
- package/esm/utils/SetupJest.mjs +3 -0
- package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
- package/package.json +36 -26
- package/types/api/AgentApi.d.ts.map +1 -1
- package/types/api/ApiTypes.d.ts +15 -16
- package/types/api/ApiTypes.d.ts.map +1 -1
- package/types/api/AuthenticateApi.d.ts +1 -1
- package/types/api/AuthenticateApi.d.ts.map +1 -1
- package/types/api/BaseApi.d.ts +2 -0
- package/types/api/BaseApi.d.ts.map +1 -1
- package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
- package/types/api/IdmConfigApi.d.ts.map +1 -1
- package/types/api/LogApi.d.ts.map +1 -1
- package/types/api/ManagedObjectApi.d.ts +9 -1
- package/types/api/ManagedObjectApi.d.ts.map +1 -1
- package/types/api/NodeApi.d.ts.map +1 -1
- package/types/api/OAuth2ClientApi.d.ts.map +1 -1
- package/types/api/OAuth2OIDCApi.d.ts +4 -2
- package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
- package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
- package/types/api/RealmApi.d.ts.map +1 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/api/SecretsApi.d.ts.map +1 -1
- package/types/api/ServerInfoApi.d.ts.map +1 -1
- package/types/api/ServiceApi.d.ts +14 -7
- package/types/api/ServiceApi.d.ts.map +1 -1
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
- package/types/api/StartupApi.d.ts.map +1 -1
- package/types/api/TreeApi.d.ts.map +1 -1
- package/types/api/VariablesApi.d.ts.map +1 -1
- package/types/api/utils/ApiUtils.d.ts +1 -0
- package/types/api/utils/ApiUtils.d.ts.map +1 -1
- package/types/index.d.ts +11 -5
- package/types/index.d.ts.map +1 -1
- package/types/ops/AuthenticateOps.d.ts +10 -2
- package/types/ops/AuthenticateOps.d.ts.map +1 -1
- package/types/ops/ConnectionProfileOps.d.ts +49 -21
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
- package/types/ops/EmailTemplateOps.d.ts +14 -33
- package/types/ops/EmailTemplateOps.d.ts.map +1 -1
- package/types/ops/IdmOps.d.ts +29 -37
- package/types/ops/IdmOps.d.ts.map +1 -1
- package/types/ops/JoseOps.d.ts +33 -0
- package/types/ops/JoseOps.d.ts.map +1 -0
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/LogOps.d.ts.map +1 -1
- package/types/ops/NodeOps.d.ts.map +1 -1
- package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/OrganizationOps.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/ops/ServiceAccountOps.d.ts +20 -0
- package/types/ops/ServiceAccountOps.d.ts.map +1 -0
- package/types/ops/ServiceOps.d.ts +18 -10
- package/types/ops/ServiceOps.d.ts.map +1 -1
- package/types/ops/ThemeOps.d.ts +35 -50
- package/types/ops/ThemeOps.d.ts.map +1 -1
- package/types/ops/utils/Console.d.ts +1 -1
- package/types/ops/utils/Console.d.ts.map +1 -1
- package/types/ops/utils/DataProtection.d.ts.map +1 -1
- package/types/ops/utils/ExportImportUtils.d.ts +5 -2
- package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
- package/types/ops/utils/OpsUtils.d.ts +6 -0
- package/types/ops/utils/OpsUtils.d.ts.map +1 -1
- package/types/ops/utils/Wordwrap.d.ts.map +1 -1
- package/types/shared/State.d.ts +223 -0
- package/types/shared/State.d.ts.map +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +19 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/types/utils/AutoSetupPolly.d.ts +1 -0
- package/types/utils/AutoSetupPolly.d.ts.map +1 -0
- package/types/utils/SetupJest.d.ts +1 -0
- package/types/utils/SetupJest.d.ts.map +1 -0
- package/types/utils/snapshotResolve.d.ts +1 -0
- package/types/utils/snapshotResolve.d.ts.map +1 -0
- package/cjs/api/EmailTemplateApi.js +0 -73
- package/cjs/api/EmailTemplateApi.js.map +0 -1
- package/cjs/api/ThemeApi.js +0 -367
- package/cjs/api/ThemeApi.js.map +0 -1
- package/cjs/api/ThemeApi.test.js.map +0 -1
- package/cjs/storage/SessionStorage.js +0 -91
- package/cjs/storage/SessionStorage.js.map +0 -1
- package/cjs/test/mocks/snapshotResolve.js.map +0 -1
- package/esm/api/EmailTemplateApi.mjs +0 -34
- package/esm/api/ThemeApi.mjs +0 -271
- package/esm/storage/SessionStorage.mjs +0 -79
- package/types/api/EmailTemplateApi.d.ts +0 -22
- package/types/api/EmailTemplateApi.d.ts.map +0 -1
- package/types/api/ThemeApi.d.ts +0 -56
- package/types/api/ThemeApi.d.ts.map +0 -1
- package/types/storage/SessionStorage.d.ts +0 -71
- package/types/storage/SessionStorage.d.ts.map +0 -1
- package/types/test/mocks/snapshotResolve.d.ts +0 -1
- package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
package/esm/ops/ThemeOps.mjs
CHANGED
|
@@ -1,350 +1,241 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { getConfigEntity, putConfigEntity } from '../api/IdmConfigApi';
|
|
2
|
+
import { getCurrentRealmName } from '../api/utils/ApiUtils';
|
|
3
|
+
import { debugMessage } from '../ops/utils/Console';
|
|
4
|
+
export const THEMEREALM_ID = 'ui/themerealm';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {
|
|
7
|
+
* Get realm themes
|
|
8
|
+
* @param {UiThemeRealmObject} themes object containing themes
|
|
9
|
+
* @returns {ThemeSkeleton[]} array of theme pertaining to the current realm
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
themeList.sort((a, b) => a.name.localeCompare(b.name));
|
|
13
|
-
|
|
14
|
-
if (!long) {
|
|
15
|
-
themeList.forEach(theme => {
|
|
16
|
-
printMessage(`${theme.isDefault ? theme.name['brightCyan'] : theme.name}`, 'data');
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
const table = createTable(['Name'['brightCyan'], 'Id'['brightCyan'], 'Default'['brightCyan']]);
|
|
20
|
-
themeList.forEach(theme => {
|
|
21
|
-
table.push([`${theme.name}`, `${theme._id}`, `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`]);
|
|
22
|
-
});
|
|
23
|
-
printMessage(table.toString(), 'data');
|
|
11
|
+
function getRealmThemes(themes) {
|
|
12
|
+
if (themes.realm && themes.realm[getCurrentRealmName()]) {
|
|
13
|
+
return themes.realm[getCurrentRealmName()];
|
|
24
14
|
}
|
|
15
|
+
return [];
|
|
25
16
|
}
|
|
17
|
+
|
|
26
18
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
* @param {String} file optional export file name
|
|
19
|
+
* Get all themes
|
|
20
|
+
* @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
|
|
30
21
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (file) {
|
|
36
|
-
fileName = file;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
createProgressIndicator(1, `Exporting ${name}`);
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const themeData = await getThemeByName(name);
|
|
43
|
-
updateProgressIndicator(`Writing file ${fileName}`);
|
|
44
|
-
saveToFile('theme', [themeData], '_id', fileName);
|
|
45
|
-
stopProgressIndicator(`Successfully exported theme ${name}.`);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
stopProgressIndicator(`${error.message}`);
|
|
48
|
-
printMessage(`${error.message}`, 'error');
|
|
49
|
-
}
|
|
22
|
+
export async function getThemes() {
|
|
23
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
24
|
+
return getRealmThemes(themes);
|
|
50
25
|
}
|
|
26
|
+
|
|
51
27
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param {
|
|
54
|
-
* @
|
|
28
|
+
* Get theme by id
|
|
29
|
+
* @param {string} themeId theme id
|
|
30
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
55
31
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fileName = file;
|
|
32
|
+
export async function getTheme(themeId) {
|
|
33
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
34
|
+
const found = getRealmThemes(themes).filter(theme => theme._id === themeId);
|
|
35
|
+
if (found.length === 1) {
|
|
36
|
+
return found[0];
|
|
62
37
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const themeData = await getTheme(id);
|
|
68
|
-
updateProgressIndicator(`Writing file ${fileName}`);
|
|
69
|
-
saveToFile('theme', [themeData], '_id', fileName);
|
|
70
|
-
stopProgressIndicator(`Successfully exported theme ${id}.`);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
stopProgressIndicator(`${error.message}`);
|
|
73
|
-
printMessage(`${error.message}`, 'error');
|
|
38
|
+
if (found.length > 1) {
|
|
39
|
+
throw new Error(`Multiple themes with id "${themeId}" found!`);
|
|
74
40
|
}
|
|
41
|
+
throw new Error(`Theme with id "${themeId}" not found!`);
|
|
75
42
|
}
|
|
43
|
+
|
|
76
44
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param {
|
|
45
|
+
* Get theme by name
|
|
46
|
+
* @param {string} themeName theme name
|
|
47
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
79
48
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fileName = file;
|
|
49
|
+
export async function getThemeByName(themeName) {
|
|
50
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
51
|
+
const found = getRealmThemes(themes).filter(theme => theme.name === themeName);
|
|
52
|
+
if (found.length === 1) {
|
|
53
|
+
return found[0];
|
|
86
54
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
createProgressIndicator(allThemesData.length, 'Exporting themes');
|
|
90
|
-
|
|
91
|
-
for (const themeData of allThemesData) {
|
|
92
|
-
updateProgressIndicator(`Exporting theme ${themeData.name}`);
|
|
55
|
+
if (found.length > 1) {
|
|
56
|
+
throw new Error(`Multiple themes with the name "${themeName}" found!`);
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
saveToFile('theme', allThemesData, '_id', fileName);
|
|
96
|
-
stopProgressIndicator(`${allThemesData.length} themes exported to ${fileName}.`);
|
|
58
|
+
throw new Error(`Theme "${themeName}" not found!`);
|
|
97
59
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Export all themes to separate files
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
export async function exportThemesToFiles() {
|
|
103
|
-
const allThemesData = await getThemes();
|
|
104
|
-
createProgressIndicator(allThemesData.length, 'Exporting themes');
|
|
105
60
|
|
|
106
|
-
for (const themeData of allThemesData) {
|
|
107
|
-
updateProgressIndicator(`Writing theme ${themeData.name}`);
|
|
108
|
-
const fileName = getTypedFilename(themeData.name, 'theme');
|
|
109
|
-
saveToFile('theme', themeData, '_id', fileName);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
stopProgressIndicator(`${allThemesData.length} themes exported.`);
|
|
113
|
-
}
|
|
114
61
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {
|
|
117
|
-
* @param {
|
|
62
|
+
* Put theme by id
|
|
63
|
+
* @param {string} themeId theme id
|
|
64
|
+
* @param {ThemeSkeleton} themeData theme object
|
|
65
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
118
66
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
for (const id in themeData.theme) {
|
|
130
|
-
if ({}.hasOwnProperty.call(themeData.theme, id)) {
|
|
131
|
-
if (themeData.theme[id].name === name) {
|
|
132
|
-
found = true;
|
|
133
|
-
updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
await putThemeByName(name, themeData.theme[id]);
|
|
137
|
-
stopProgressIndicator(`Successfully imported theme ${name}.`);
|
|
138
|
-
} catch (error) {
|
|
139
|
-
stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}: ${error.message}`);
|
|
140
|
-
printMessage(`Error importing theme ${themeData.theme[id].name}: ${error.message}`, 'error');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!found) {
|
|
149
|
-
stopProgressIndicator(`Theme ${name} not found!`);
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
printMessage('Import validation failed...', 'error');
|
|
67
|
+
export async function putTheme(themeId, themeData) {
|
|
68
|
+
const data = themeData;
|
|
69
|
+
data._id = themeId;
|
|
70
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
71
|
+
let isNew = true;
|
|
72
|
+
const realmThemes = getRealmThemes(themes).map(theme => {
|
|
73
|
+
if (theme._id === themeId) {
|
|
74
|
+
isNew = false;
|
|
75
|
+
return data;
|
|
153
76
|
}
|
|
77
|
+
// eslint-disable-next-line no-param-reassign
|
|
78
|
+
if (data.isDefault) theme.isDefault = false;
|
|
79
|
+
return theme;
|
|
154
80
|
});
|
|
81
|
+
if (isNew) {
|
|
82
|
+
realmThemes.push(data);
|
|
83
|
+
}
|
|
84
|
+
themes.realm[getCurrentRealmName()] = realmThemes;
|
|
85
|
+
const found = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => theme._id === themeId);
|
|
86
|
+
if (found.length === 1) {
|
|
87
|
+
return found[0];
|
|
88
|
+
}
|
|
89
|
+
if (found.length > 1) {
|
|
90
|
+
throw new Error(`Multiple themes with id "${themeId}" found!`);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Theme with id "${themeId}" not saved!`);
|
|
155
93
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Import theme by uuid from file
|
|
158
|
-
* @param {String} id theme uuid
|
|
159
|
-
* @param {String} file import file name
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
export async function importThemeById(id, file) {
|
|
163
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
164
|
-
if (err) throw err;
|
|
165
|
-
const themeData = JSON.parse(data);
|
|
166
|
-
|
|
167
|
-
if (validateImport(themeData.meta)) {
|
|
168
|
-
createProgressIndicator(1, 'Importing theme...');
|
|
169
|
-
let found = false;
|
|
170
|
-
|
|
171
|
-
for (const themeId in themeData.theme) {
|
|
172
|
-
if ({}.hasOwnProperty.call(themeData.theme, themeId)) {
|
|
173
|
-
if (themeId === id) {
|
|
174
|
-
found = true;
|
|
175
|
-
updateProgressIndicator(`Importing ${themeData.theme[themeId]._id}`);
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
await putTheme(themeId, themeData.theme[themeId]);
|
|
179
|
-
stopProgressIndicator(`Successfully imported theme ${id}.`);
|
|
180
|
-
} catch (error) {
|
|
181
|
-
stopProgressIndicator(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`);
|
|
182
|
-
printMessage(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`, 'error');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
94
|
|
|
190
|
-
if (!found) {
|
|
191
|
-
stopProgressIndicator(`Theme ${id} not found!`);
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
printMessage('Import validation failed...', 'error');
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
95
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @param {String}
|
|
96
|
+
* Put theme by name
|
|
97
|
+
* @param {String} themeName theme name
|
|
98
|
+
* @param {ThemeSkeleton} themeData theme object
|
|
99
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
|
|
201
100
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
for (const id in fileData.theme) {
|
|
212
|
-
if ({}.hasOwnProperty.call(fileData.theme, id)) {
|
|
213
|
-
updateProgressIndicator(`Importing ${fileData.theme[id].name}`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
putThemes(fileData.theme).then(result => {
|
|
218
|
-
if (result == null) {
|
|
219
|
-
stopProgressIndicator(`Error importing ${Object.keys(fileData.theme).length} themes!`);
|
|
220
|
-
printMessage(`Error importing ${Object.keys(fileData.theme).length} themes from ${file}`, 'error');
|
|
221
|
-
} else {
|
|
222
|
-
stopProgressIndicator(`Successfully imported ${Object.keys(fileData.theme).length} themes.`);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
} else {
|
|
226
|
-
printMessage('Import validation failed...', 'error');
|
|
101
|
+
export async function putThemeByName(themeName, themeData) {
|
|
102
|
+
const data = themeData;
|
|
103
|
+
data.name = themeName;
|
|
104
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
105
|
+
let isNew = true;
|
|
106
|
+
const realmThemes = getRealmThemes(themes).map(theme => {
|
|
107
|
+
if (theme.name === themeName) {
|
|
108
|
+
isNew = false;
|
|
109
|
+
return data;
|
|
227
110
|
}
|
|
111
|
+
// eslint-disable-next-line no-param-reassign
|
|
112
|
+
if (data.isDefault) theme.isDefault = false;
|
|
113
|
+
return theme;
|
|
228
114
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* Import themes from separate files
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
export async function importThemesFromFiles() {
|
|
235
|
-
const names = fs.readdirSync('.');
|
|
236
|
-
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.theme.json'));
|
|
237
|
-
createProgressIndicator(jsonFiles.length, 'Importing themes...');
|
|
238
|
-
let fileData = null;
|
|
239
|
-
let count = 0;
|
|
240
|
-
let total = 0;
|
|
241
|
-
let files = 0;
|
|
242
|
-
|
|
243
|
-
for (const file of jsonFiles) {
|
|
244
|
-
const data = fs.readFileSync(file, 'utf8');
|
|
245
|
-
fileData = JSON.parse(data);
|
|
246
|
-
|
|
247
|
-
if (validateImport(fileData.meta)) {
|
|
248
|
-
count = Object.keys(fileData.theme).length; // eslint-disable-next-line no-await-in-loop
|
|
249
|
-
|
|
250
|
-
const result = await putThemes(fileData.theme);
|
|
251
|
-
|
|
252
|
-
if (result == null) {
|
|
253
|
-
printMessage(`Error importing ${count} themes from ${file}`, 'error');
|
|
254
|
-
} else {
|
|
255
|
-
files += 1;
|
|
256
|
-
total += count;
|
|
257
|
-
updateProgressIndicator(`Imported ${count} theme(s) from ${file}`);
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
printMessage(`Validation of ${file} failed!`, 'error');
|
|
261
|
-
}
|
|
115
|
+
if (isNew) {
|
|
116
|
+
realmThemes.push(data);
|
|
262
117
|
}
|
|
263
|
-
|
|
264
|
-
|
|
118
|
+
themes['realm'][getCurrentRealmName()] = realmThemes;
|
|
119
|
+
const found = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => theme.name === themeName);
|
|
120
|
+
if (found.length === 1) {
|
|
121
|
+
return found[0];
|
|
122
|
+
}
|
|
123
|
+
if (found.length > 1) {
|
|
124
|
+
throw new Error(`Multiple themes "${themeName}" found!`);
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Theme "${themeName}" not saved!`);
|
|
265
127
|
}
|
|
128
|
+
|
|
266
129
|
/**
|
|
267
|
-
*
|
|
268
|
-
* @param {
|
|
130
|
+
* Put all themes
|
|
131
|
+
* @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms
|
|
132
|
+
* @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object
|
|
269
133
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}`);
|
|
285
|
-
printMessage(`Error importing theme ${themeData.theme[id].name}`, 'error');
|
|
286
|
-
} else {
|
|
287
|
-
stopProgressIndicator(`Successfully imported theme ${themeData.theme[id].name}`);
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
printMessage('Import validation failed...', 'error');
|
|
134
|
+
export async function putThemes(themeMap) {
|
|
135
|
+
debugMessage(`ThemeApi.putThemes: start`);
|
|
136
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
137
|
+
const allThemeIDs = Object.keys(themeMap);
|
|
138
|
+
const existingThemeIDs = [];
|
|
139
|
+
let defaultThemeId = null;
|
|
140
|
+
// update existing themes
|
|
141
|
+
let realmThemes = getRealmThemes(themes).map(theme => {
|
|
142
|
+
if (themeMap[theme._id]) {
|
|
143
|
+
debugMessage(`Update theme: ${theme._id} - ${theme.name}`);
|
|
144
|
+
existingThemeIDs.push(theme._id);
|
|
145
|
+
// remember the id of the last default theme
|
|
146
|
+
if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;
|
|
147
|
+
return themeMap[theme._id];
|
|
295
148
|
}
|
|
149
|
+
return theme;
|
|
150
|
+
});
|
|
151
|
+
const newThemeIDs = allThemeIDs.filter(id => !existingThemeIDs.includes(id));
|
|
152
|
+
// add new themes
|
|
153
|
+
newThemeIDs.forEach(themeId => {
|
|
154
|
+
debugMessage(`Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`);
|
|
155
|
+
// remember the id of the last default theme
|
|
156
|
+
if (themeMap[themeId].isDefault) defaultThemeId = themeId;
|
|
157
|
+
realmThemes.push(themeMap[themeId]);
|
|
296
158
|
});
|
|
159
|
+
// if we imported a default theme, flag all the other themes as not default
|
|
160
|
+
if (defaultThemeId) {
|
|
161
|
+
realmThemes = realmThemes.map(theme => {
|
|
162
|
+
// eslint-disable-next-line no-param-reassign
|
|
163
|
+
theme.isDefault = theme._id === defaultThemeId;
|
|
164
|
+
return theme;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
themes.realm[getCurrentRealmName()] = realmThemes;
|
|
168
|
+
const updatedThemes = new Map(getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).map(theme => [theme._id, theme]));
|
|
169
|
+
debugMessage(updatedThemes);
|
|
170
|
+
debugMessage(`ThemeApi.putThemes: finished`);
|
|
171
|
+
return updatedThemes;
|
|
297
172
|
}
|
|
173
|
+
|
|
298
174
|
/**
|
|
299
175
|
* Delete theme by id
|
|
300
|
-
* @param {
|
|
176
|
+
* @param {string} themeId theme id
|
|
177
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
|
|
301
178
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
179
|
+
export async function deleteTheme(themeId) {
|
|
180
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
181
|
+
const realmThemes = getRealmThemes(themes);
|
|
182
|
+
const deletedThemes = [];
|
|
183
|
+
const finalThemes = realmThemes.filter(theme => {
|
|
184
|
+
if (theme._id !== themeId) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
deletedThemes.push(theme);
|
|
188
|
+
return false;
|
|
189
|
+
});
|
|
190
|
+
if (realmThemes.length === finalThemes.length) throw new Error(`${themeId} not found`);
|
|
191
|
+
themes.realm[getCurrentRealmName()] = realmThemes;
|
|
192
|
+
const undeletedThemes = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
|
|
193
|
+
if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
|
|
194
|
+
return deletedThemes[0];
|
|
311
195
|
}
|
|
196
|
+
throw new Error(`Theme(s) with id(s) "${undeletedThemes.map(theme => theme._id)}" not deleted!`);
|
|
312
197
|
}
|
|
198
|
+
|
|
313
199
|
/**
|
|
314
200
|
* Delete theme by name
|
|
315
|
-
* @param {
|
|
201
|
+
* @param {string} themeName theme name
|
|
202
|
+
* @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
|
|
316
203
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
204
|
+
export async function deleteThemeByName(themeName) {
|
|
205
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
206
|
+
const realmThemes = getRealmThemes(themes);
|
|
207
|
+
const deletedThemes = [];
|
|
208
|
+
const finalThemes = realmThemes.filter(theme => {
|
|
209
|
+
if (theme.name !== themeName) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
deletedThemes.push(theme);
|
|
213
|
+
return false;
|
|
214
|
+
});
|
|
215
|
+
if (realmThemes.length === finalThemes.length) throw new Error(`${themeName} not found`);
|
|
216
|
+
themes.realm[getCurrentRealmName()] = finalThemes;
|
|
217
|
+
// return putConfigEntity(THEMEREALM_ID, themes);
|
|
218
|
+
const undeletedThemes = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
|
|
219
|
+
if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
|
|
220
|
+
return deletedThemes[0];
|
|
326
221
|
}
|
|
222
|
+
throw new Error(`Theme(s) with id(s) "${undeletedThemes.map(theme => theme._id)}" not deleted!`);
|
|
327
223
|
}
|
|
224
|
+
|
|
328
225
|
/**
|
|
329
226
|
* Delete all themes
|
|
227
|
+
* @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
|
|
330
228
|
*/
|
|
331
|
-
|
|
332
229
|
export async function deleteThemes() {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
stopProgressIndicator(`Error: ${error.message}`, 'fail');
|
|
230
|
+
const themes = await getConfigEntity(THEMEREALM_ID);
|
|
231
|
+
const realmThemes = themes.realm[getCurrentRealmName()];
|
|
232
|
+
if (!realmThemes) throw new Error(`No theme configuration found for realm "${getCurrentRealmName()}"`);
|
|
233
|
+
const deletedThemes = [];
|
|
234
|
+
for (const theme of realmThemes) {
|
|
235
|
+
deletedThemes.push(theme);
|
|
340
236
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
* @deprecated since version 0.14.0
|
|
345
|
-
*/
|
|
346
|
-
|
|
347
|
-
export async function deleteThemesCmd() {
|
|
348
|
-
return deleteThemes();
|
|
237
|
+
themes.realm[getCurrentRealmName()] = [];
|
|
238
|
+
await putConfigEntity(THEMEREALM_ID, themes);
|
|
239
|
+
return deletedThemes;
|
|
349
240
|
}
|
|
350
241
|
//# sourceMappingURL=ThemeOps.js.map
|