diff --git a/helm/values.yaml b/helm/values.yaml index ca3b057..bcf1ecf 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -12,8 +12,8 @@ app: enabled: true spec: exposedModule: "./OneCXThemeModule" - description: "OneCX Theme Module" - note: "OneCX Theme UI module auto import via MF operator" + description: "OneCX Theme" + note: "OneCX Theme UI auto import via MF operator" # Permission permission: enabled: true @@ -21,19 +21,19 @@ app: permissions: THEME: CREATE: Create theme - EDIT: Edit theme DELETE: Delete theme + EDIT: Edit theme SAVE: Update and save theme + SEARCH: Search theme + VIEW: View mode for theme IMPORT: Import theme EXPORT: Export theme - VIEW: View mode for theme - SEARCH: Search theme # Keycloak keycloak: client: enabled: true spec: kcConfig: - clientId: "onecx-theme-ui" + clientId: "onecx-theme-ui" # PIPE Config diff --git a/package-lock.json b/package-lock.json index a841db1..5366080 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,11 +23,11 @@ "@ngneat/falso": "^6.4.0", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", - "@onecx/accelerator": "^4.1.2", - "@onecx/integration-interface": "^4.1.2", - "@onecx/keycloak-auth": "^4.1.2", - "@onecx/portal-integration-angular": "^4.1.2", - "@onecx/portal-layout-styles": "^4.1.2", + "@onecx/accelerator": "^4.9.0", + "@onecx/integration-interface": "^4.9.0", + "@onecx/keycloak-auth": "^4.9.0", + "@onecx/portal-integration-angular": "^4.9.0", + "@onecx/portal-layout-styles": "^4.9.0", "file-saver": "^2.0.5", "i18n-iso-countries": "^7.6.0", "ngx-color": "^8.0.3", @@ -63,7 +63,7 @@ "@svgr/webpack": "^7.0.0", "@swc-node/register": "^1.6.5", "@swc/cli": "~0.1.63", - "@swc/core": "^1.3.56", + "@swc/core": "^1.4.2", "@swc/helpers": "0.5.3", "@types/jasmine": "~3.10.0", "@types/node": "18.16.3", @@ -79,7 +79,7 @@ "eslint-plugin-import": "2.29.1", "eslint-plugin-jsx-a11y": "6.7.1", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-storybook": "^0.6.12", + "eslint-plugin-storybook": "^0.8.0", "husky": "^8.0.3", "jasmine-core": "~4.0.0", "jasmine-spec-reporter": "^7.0.0", @@ -6613,18 +6613,18 @@ } }, "node_modules/@onecx/accelerator": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@onecx/accelerator/-/accelerator-4.1.2.tgz", - "integrity": "sha512-PujQII1motqpXwPUN0H+x6aN3BkHkmQBbQTkv+be+xlAnZD2qu7Y1gtDTfrESyj5FXBLvGw7+vIM7Bmf0NpPtA==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@onecx/accelerator/-/accelerator-4.9.0.tgz", + "integrity": "sha512-fZtAPrwW6tH0lFTaLXmgHolf01pf4mnL8nVcYBPJjRU4tQuNR/HVj6msBMcG/1a5aJNDHGfsmuXbrUdbMslvpg==", "peerDependencies": { "rxjs": "7.8.1", "tslib": "^2.3.0" } }, "node_modules/@onecx/integration-interface": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@onecx/integration-interface/-/integration-interface-4.1.2.tgz", - "integrity": "sha512-XED3fNOiD+dnVEDSz8haGvfgaNVCeQjn9ECAftTJ4SZ+laD5dkdv0uI21UH9ZpTTt6jUUtfNhHZZ8wChNcYdRg==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@onecx/integration-interface/-/integration-interface-4.9.0.tgz", + "integrity": "sha512-PjNph0hn8VlVTLY3b0ZQ/M/yCxvWbQ3XqK/xc7FC+8NNT0uvfLPNShsFvOzkUKH60D68BEoF112tJFoTC5d4uA==", "peerDependencies": { "@onecx/accelerator": "~4", "rxjs": "7.8.1", @@ -6632,9 +6632,9 @@ } }, "node_modules/@onecx/keycloak-auth": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@onecx/keycloak-auth/-/keycloak-auth-4.1.2.tgz", - "integrity": "sha512-pXrz/KHudCHVhIKqX31D3qeu513jErsqEAMmCix48MpcG/ZfFIibbLU0SAZtzp7uCIa+KcQL5MJhbsWMHb1vZA==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@onecx/keycloak-auth/-/keycloak-auth-4.9.0.tgz", + "integrity": "sha512-VbhgIahqiwEZwLHBiVCWKgnGt5TCQP+fX5TfotjtvvXYdVeEcoRIIKBy/QBHk7Aj4OqUeWpU1dkoLWWJnOsjqA==", "dependencies": { "tslib": "^2.3.0" }, @@ -6648,9 +6648,9 @@ } }, "node_modules/@onecx/portal-integration-angular": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@onecx/portal-integration-angular/-/portal-integration-angular-4.1.2.tgz", - "integrity": "sha512-dtGK9bqeDIf9RTqevQfr05Fxzfutr8xtP2nbYblAuKW4/D6xonUl6f0DS4ij40fW9745k+3MFg99FXA635fFqw==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@onecx/portal-integration-angular/-/portal-integration-angular-4.9.0.tgz", + "integrity": "sha512-wMLfyCOhYy5wbPP1bzEBu56czfz5Meds98lq0I77fLJIQZV2L19dU7MYYH7Fum7EgYbSG4AMTt9Fh6UkKHBMcg==", "dependencies": { "tslib": "^2.3.0" }, @@ -6669,6 +6669,7 @@ "@ngrx/store": "^15.4.0", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", + "@onecx/accelerator": "~4", "@onecx/integration-interface": "~4", "chart.js": "^4.4.0", "d3-scale-chromatic": "^3.0.0", @@ -6680,9 +6681,9 @@ } }, "node_modules/@onecx/portal-layout-styles": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@onecx/portal-layout-styles/-/portal-layout-styles-4.1.2.tgz", - "integrity": "sha512-9rDqAkbJyN3OmBEuSXZuHL6VmVuZJkTyNOW3VGHuIsy0dBrbPiqToQ6E8aNdz78FztG3RXSceyhq/Ot05IXaOQ==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@onecx/portal-layout-styles/-/portal-layout-styles-4.9.0.tgz", + "integrity": "sha512-7/KnGiQXb15Q7Y9Lgai5xX1rrvK6tnLAEZ7q5lWDZRgl1Z2UY4f1A00yNrKAUOoF0r+lV+frLSC8bDCKhNplrQ==", "peerDependencies": { "tslib": "^2.5.0" } @@ -9500,13 +9501,13 @@ } }, "node_modules/@swc/core": { - "version": "1.3.96", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.96.tgz", - "integrity": "sha512-zwE3TLgoZwJfQygdv2SdCK9mRLYluwDOM53I+dT6Z5ZvrgVENmY3txvWDvduzkV+/8IuvrRbVezMpxcojadRdQ==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.4.4.tgz", + "integrity": "sha512-P88AHGWM8xPY3Tjj5360V6vqKCS5UfsyffPJVnr7BKSr45rlG4/pjEGGmFYQjg6ztgPyrGLYz1jSyzajTqTVIA==", "dev": true, "hasInstallScript": true, "dependencies": { - "@swc/counter": "^0.1.1", + "@swc/counter": "^0.1.2", "@swc/types": "^0.1.5" }, "engines": { @@ -9517,16 +9518,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.96", - "@swc/core-darwin-x64": "1.3.96", - "@swc/core-linux-arm-gnueabihf": "1.3.96", - "@swc/core-linux-arm64-gnu": "1.3.96", - "@swc/core-linux-arm64-musl": "1.3.96", - "@swc/core-linux-x64-gnu": "1.3.96", - "@swc/core-linux-x64-musl": "1.3.96", - "@swc/core-win32-arm64-msvc": "1.3.96", - "@swc/core-win32-ia32-msvc": "1.3.96", - "@swc/core-win32-x64-msvc": "1.3.96" + "@swc/core-darwin-arm64": "1.4.4", + "@swc/core-darwin-x64": "1.4.4", + "@swc/core-linux-arm-gnueabihf": "1.4.4", + "@swc/core-linux-arm64-gnu": "1.4.4", + "@swc/core-linux-arm64-musl": "1.4.4", + "@swc/core-linux-x64-gnu": "1.4.4", + "@swc/core-linux-x64-musl": "1.4.4", + "@swc/core-win32-arm64-msvc": "1.4.4", + "@swc/core-win32-ia32-msvc": "1.4.4", + "@swc/core-win32-x64-msvc": "1.4.4" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -9537,10 +9538,90 @@ } } }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.4.4.tgz", + "integrity": "sha512-goSHS8yvDgha93RHIV2Vn50neYasqbc4K1g/nKOV6T8kiKVv4w/rmqNJu9Aa0mPGVJtjcr0NvX6bBwE0T4HIzg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.4.4.tgz", + "integrity": "sha512-PLfgL355qsl5c5kUPsFGITgVXoaqjp9sCd0Y5Z5uN7RtSOvwIX28e23eCxj02dOr7OBr8sq6qBlEMDV03T24Iw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.4.4.tgz", + "integrity": "sha512-BVEZVOGnaZvEcHm//KyYzhte46vdF67wLVtmQEXPAlrkRgZ3b/JSySeLXqeocAcOANWb1/SPHlEmPK5azP+JvQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.4.4.tgz", + "integrity": "sha512-ZbOJfVbCjVMKdfvvJDOTpa3tGqU6tfxng1CDjA62RUcqa7sRbovrjSiw6mq5/4EoOF4zK8CtPIG+TlxKPapnuw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.4.4.tgz", + "integrity": "sha512-+Gjo1W4tY/4kgEe5h22iuCWkpKcPMccXwYaSLNvgBCBQADB0zKFfF0lNf7y6U+81NFEjhRsdwXMsRGZtgTpUrg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.96", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.96.tgz", - "integrity": "sha512-USdaZu8lTIkm4Yf9cogct/j5eqtdZqTgcTib4I+NloUW0E/hySou3eSyp3V2UAA1qyuC72ld1otXuyKBna0YKQ==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.4.4.tgz", + "integrity": "sha512-PR/VbGm0LEkhpm5qClovZWhE/jYoQSyIeyPh8XY39uUI1u2yEfuz5UCW2sJJIWOvNiAfu7+TjW+9H/I7zBBDJA==", "cpu": [ "x64" ], @@ -9554,9 +9635,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.96", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.96.tgz", - "integrity": "sha512-QYErutd+G2SNaCinUVobfL7jWWjGTI0QEoQ6hqTp7PxCJS/dmKmj3C5ZkvxRYcq7XcZt7ovrYCTwPTHzt6lZBg==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.4.4.tgz", + "integrity": "sha512-poT9zub4CyVcH1cxwGdrGiZD3urfOaYs/Kd52ve3ymPPeQZq7qQwKqAB/9NxoSiJDaSzJv5OwTEfgaBYCyw0iw==", "cpu": [ "x64" ], @@ -9569,6 +9650,54 @@ "node": ">=10" } }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.4.4.tgz", + "integrity": "sha512-29V5/fBd6XXFb7J/ri9ZeSS/GTqXfSWa3BiE0zTNbASpQbEXf+YPYiAtO6c1HqNyQobKB9ni+w7sa8KkAGhHXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.4.4.tgz", + "integrity": "sha512-2lKEGEjpBOq0z4Nk0tFP9wxVwxgz7FonmjCkzJ95GBb5KNvMrgQQrGNGX6L0hoBo/a1kE752I6V5pOaMyIq5xQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.4.4.tgz", + "integrity": "sha512-xuN0oJhAewga8jNJkT5Wx25RPVnIEMZCYf4irqA5jiK6GckOdcXB8jvEJhggOxnJSW8RDsAtY5q+zw5kNkU+eA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/counter": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", @@ -15876,18 +16005,18 @@ } }, "node_modules/eslint-plugin-storybook": { - "version": "0.6.15", - "resolved": "https://registry.npmjs.org/eslint-plugin-storybook/-/eslint-plugin-storybook-0.6.15.tgz", - "integrity": "sha512-lAGqVAJGob47Griu29KXYowI4G7KwMoJDOkEip8ujikuDLxU+oWJ1l0WL6F2oDO4QiyUFXvtDkEkISMOPzo+7w==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-storybook/-/eslint-plugin-storybook-0.8.0.tgz", + "integrity": "sha512-CZeVO5EzmPY7qghO2t64oaFM+8FTaD4uzOEjHKp516exyTKo+skKAL9GI3QALS2BXhyALJjNtwbmr1XinGE8bA==", "dev": true, "dependencies": { "@storybook/csf": "^0.0.1", - "@typescript-eslint/utils": "^5.45.0", - "requireindex": "^1.1.0", + "@typescript-eslint/utils": "^5.62.0", + "requireindex": "^1.2.0", "ts-dedent": "^2.2.0" }, "engines": { - "node": "12.x || 14.x || >= 16" + "node": ">= 18" }, "peerDependencies": { "eslint": ">=6" diff --git a/package.json b/package.json index 9e8e229..122c261 100644 --- a/package.json +++ b/package.json @@ -49,11 +49,11 @@ "@ngneat/falso": "^6.4.0", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", - "@onecx/accelerator": "^4.1.2", - "@onecx/integration-interface": "^4.1.2", - "@onecx/keycloak-auth": "^4.1.2", - "@onecx/portal-integration-angular": "^4.1.2", - "@onecx/portal-layout-styles": "^4.1.2", + "@onecx/accelerator": "^4.9.0", + "@onecx/integration-interface": "^4.9.0", + "@onecx/keycloak-auth": "^4.9.0", + "@onecx/portal-integration-angular": "^4.9.0", + "@onecx/portal-layout-styles": "^4.9.0", "file-saver": "^2.0.5", "i18n-iso-countries": "^7.6.0", "ngx-color": "^8.0.3", @@ -89,7 +89,7 @@ "@svgr/webpack": "^7.0.0", "@swc-node/register": "^1.6.5", "@swc/cli": "~0.1.63", - "@swc/core": "^1.3.56", + "@swc/core": "^1.4.2", "@swc/helpers": "0.5.3", "@types/jasmine": "~3.10.0", "@types/node": "18.16.3", @@ -105,7 +105,7 @@ "eslint-plugin-import": "2.29.1", "eslint-plugin-jsx-a11y": "6.7.1", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-storybook": "^0.6.12", + "eslint-plugin-storybook": "^0.8.0", "husky": "^8.0.3", "jasmine-core": "~4.0.0", "jasmine-spec-reporter": "^7.0.0", diff --git a/scripts/load-permissions.sh b/scripts/load-permissions.sh new file mode 100755 index 0000000..d2ddc48 --- /dev/null +++ b/scripts/load-permissions.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# relative paths to values.yaml and Chart.yaml +values_file="helm/values.yaml" +chart_file="helm/Chart.yaml" + +array=() + +if [ ! -f "$values_file" ]; then + echo "\"$values_file\" cannot be found - execute this script from product root directory" + exit 1 +fi +if [ ! -f "$chart_file" ]; then + echo "\"$chart_file\" cannot be found - execute this script from product root directory" + exit 1 +fi + +extract_app_id_and_product_name() { + app_id=$(sed -n '2 s/^name: \([^ ]*\).*/\1/p' "$chart_file") + app_name=$(sed -n '4 s/description: //p' "$chart_file") + product_name=$(echo "$app_id" | sed 's/-ui$//') + echo "=> app id: $app_id" + echo "=> app name: $app_name" + echo "=> product name: $product_name" +} + +find_permissions() { + while IFS= read -r line; do + if [[ "$line" == *"permissions:"* ]]; then + permissions_spaces=$(echo "$line" | grep -oE '^[[:space:]]*' | wc -c) + + while IFS= read -r next_line; do + next_spaces=$(echo "$next_line" | grep -oE '^[[:space:]]*' | wc -c) + + if (( next_spaces <= permissions_spaces )); then + break + fi + if (( next_spaces == permissions_spaces + 2 )); then + current_key=$(echo "$next_line" | tr -d ':' | tr -d ' ') + elif (( next_spaces == permissions_spaces + 4 )); then + value=$(echo "$next_line" | awk -F ':' '{print $1}' | tr -d ' ') + description=$(echo "$next_line" | awk -F ':' '{$1=""; print $0}' | sed 's/^ *//') + echo -e "Key: $current_key \t Value: $value \t Description: $description" + array+=( "{\"resource\":\"$current_key\",\"action\":\"$value\",\"description\":\"$description\"}" ) + fi + done < <(sed -n "/permissions:/,/^$/p" "$values_file" | tail -n +2) + break + fi + done < "$values_file" +} + +create_json() { + permissions_json="{" + permissions_json+="\"name\": \"$app_name\"," + permissions_json+="\"description\": \"local permission import\"," + permissions_json+="\"permissions\":[" + + for ((i = 0; i < ${#array[@]}; i++)); do + permissions_json+="${array[i]}" + if ((i < ${#array[@]} - 1)); then + permissions_json+="," + fi + done + + permissions_json+="]" + permissions_json+="}" +} + +send_permission_to_svc() { + echo "=> send permissions to service" + curl -v -X PUT -H "Content-Type: application/json" -d "$permissions_json" \ + http://onecx-permission-svc/operator/v1/$product_name/$app_id +} + +extract_app_id_and_product_name +find_permissions +create_json +send_permission_to_svc +exit 0 \ No newline at end of file