From 40f4ffdaee28ad5e7ae3e118edf7b790f5cb1679 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 12:02:32 +0000 Subject: [PATCH 001/178] Initial plan From 190a9d67a7f22b9b83aaa41e63eb5aed4cee6f9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 12:04:43 +0000 Subject: [PATCH 002/178] Fix macOS notarization failures with timestamps and signing improvements Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --- .github/workflows/prod-release.yml | 56 ++++++++++++++++++++++++-- buildScripts/electron-builder-mac.json | 5 ++- buildScripts/entitlements.mac.plist | 2 + 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 09186332..74dfca35 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -170,6 +170,15 @@ jobs: echo "MACOS_CERT_PATH=$CERT_PATH" } >> "$GITHUB_ENV" + - name: Verify certificate details + if: matrix.os == 'macos-latest' + shell: bash + run: | + echo "=== Checking available signing identities ===" + security find-identity -v -p codesigning + echo "" + echo "Note: Should show 'Developer ID Application' not 'Mac App Distribution'" + - name: Package application (macOS) if: matrix.os == 'macos-latest' shell: bash @@ -183,6 +192,8 @@ jobs: SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} DEBUG: electron-builder + CSC_FOR_PULL_REQUEST: true + CSC_IDENTITY_AUTO_DISCOVERY: true run: | node ./buildScripts/package.js --config=${{ matrix.config }} @@ -191,10 +202,47 @@ jobs: shell: bash run: | APP_PATH="build/mac/Power Platform ToolBox.app" - echo "Verifying code signature for: $APP_PATH" - codesign --verify --deep --strict --verbose=2 "$APP_PATH" - spctl --assess --type exec --verbose=4 "$APP_PATH" - echo "✅ macOS code signing verification passed" + + echo "=== Verifying main app signature ===" + codesign --verify --deep --strict --verbose=4 "$APP_PATH" 2>&1 + + echo "" + echo "=== Checking for timestamps on main app ===" + codesign -dvvv "$APP_PATH" 2>&1 | grep -i timestamp || echo "❌ WARNING: NO TIMESTAMP FOUND ON MAIN APP!" + + echo "" + echo "=== Verifying critical nested binaries ===" + # Check helper apps + for helper in "$APP_PATH/Contents/Frameworks/"*.app; do + if [ -d "$helper" ]; then + echo "Checking helper: $(basename "$helper")" + codesign --verify --strict "$helper" 2>&1 || echo "❌ Failed: $helper" + codesign -dvvv "$helper" 2>&1 | grep -i timestamp || echo "❌ No timestamp: $helper" + fi + done + + # Check frameworks + echo "" + echo "=== Checking frameworks ===" + find "$APP_PATH/Contents/Frameworks" -name "*.framework" -type d -maxdepth 1 | while read framework; do + echo "Checking: $(basename "$framework")" + codesign --verify --strict "$framework" 2>&1 || echo "❌ Failed: $framework" + done + + # Check dylibs + echo "" + echo "=== Checking dynamic libraries ===" + find "$APP_PATH" -name "*.dylib" -type f | head -5 | while read dylib; do + echo "Checking: $(basename "$dylib")" + codesign --verify --strict "$dylib" 2>&1 || echo "❌ Failed: $dylib" + done + + echo "" + echo "=== Running spctl assessment ===" + spctl --assess --type exec --verbose=4 "$APP_PATH" 2>&1 + + echo "" + echo "✅ macOS code signing verification complete" - name: Submit macOS notarization request if: matrix.os == 'macos-latest' diff --git a/buildScripts/electron-builder-mac.json b/buildScripts/electron-builder-mac.json index 9af1a120..7eb052f9 100644 --- a/buildScripts/electron-builder-mac.json +++ b/buildScripts/electron-builder-mac.json @@ -21,12 +21,13 @@ "category": "public.app-category.developer-tools", "icon": "icons/icon.icns", "identity": "Developer ID Application", - "gatekeeperAssess": true, + "gatekeeperAssess": false, "hardenedRuntime": true, "entitlements": "./buildScripts/entitlements.mac.plist", "entitlementsInherit": "./buildScripts/entitlements.mac.plist", "type": "distribution", - "notarize": false + "notarize": false, + "signIgnore": [] }, "dmg": { "sign": true diff --git a/buildScripts/entitlements.mac.plist b/buildScripts/entitlements.mac.plist index 603f46df..08264f64 100644 --- a/buildScripts/entitlements.mac.plist +++ b/buildScripts/entitlements.mac.plist @@ -8,6 +8,8 @@ com.apple.security.cs.allow-unsigned-executable-memory + com.apple.security.cs.allow-dyld-environment-variables + com.apple.security.inherit com.apple.security.device.usb From e8401961d829bc0cb6a030eba68bd23333050b55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 12:30:36 +0000 Subject: [PATCH 003/178] Apply macOS notarization fixes to nightly build workflow Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --- .github/workflows/nightly-release.yml | 56 +++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index c42daa80..a73b4d30 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -166,6 +166,15 @@ jobs: echo "MACOS_CERT_PATH=$CERT_PATH" } >> "$GITHUB_ENV" + - name: Verify certificate details + if: matrix.os == 'macos-latest' + shell: bash + run: | + echo "=== Checking available signing identities ===" + security find-identity -v -p codesigning + echo "" + echo "Note: Should show 'Developer ID Application' not 'Mac App Distribution'" + - name: Package application (macOS) if: matrix.os == 'macos-latest' shell: bash @@ -179,6 +188,8 @@ jobs: SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} DEBUG: electron-builder + CSC_FOR_PULL_REQUEST: true + CSC_IDENTITY_AUTO_DISCOVERY: true run: | node ./buildScripts/package.js --config=${{ matrix.config }} @@ -187,10 +198,47 @@ jobs: shell: bash run: | APP_PATH="build/mac/Power Platform ToolBox.app" - echo "Verifying code signature for: $APP_PATH" - codesign --verify --deep --strict --verbose=2 "$APP_PATH" - spctl --assess --type exec --verbose=4 "$APP_PATH" - echo "✅ macOS code signing verification passed" + + echo "=== Verifying main app signature ===" + codesign --verify --deep --strict --verbose=4 "$APP_PATH" 2>&1 + + echo "" + echo "=== Checking for timestamps on main app ===" + codesign -dvvv "$APP_PATH" 2>&1 | grep -i timestamp || echo "❌ WARNING: NO TIMESTAMP FOUND ON MAIN APP!" + + echo "" + echo "=== Verifying critical nested binaries ===" + # Check helper apps + for helper in "$APP_PATH/Contents/Frameworks/"*.app; do + if [ -d "$helper" ]; then + echo "Checking helper: $(basename "$helper")" + codesign --verify --strict "$helper" 2>&1 || echo "❌ Failed: $helper" + codesign -dvvv "$helper" 2>&1 | grep -i timestamp || echo "❌ No timestamp: $helper" + fi + done + + # Check frameworks + echo "" + echo "=== Checking frameworks ===" + find "$APP_PATH/Contents/Frameworks" -name "*.framework" -type d -maxdepth 1 | while read framework; do + echo "Checking: $(basename "$framework")" + codesign --verify --strict "$framework" 2>&1 || echo "❌ Failed: $framework" + done + + # Check dylibs + echo "" + echo "=== Checking dynamic libraries ===" + find "$APP_PATH" -name "*.dylib" -type f | head -5 | while read dylib; do + echo "Checking: $(basename "$dylib")" + codesign --verify --strict "$dylib" 2>&1 || echo "❌ Failed: $dylib" + done + + echo "" + echo "=== Running spctl assessment ===" + spctl --assess --type exec --verbose=4 "$APP_PATH" 2>&1 + + echo "" + echo "✅ macOS code signing verification complete" - name: Submit macOS notarization request if: matrix.os == 'macos-latest' From 69dd2919bb405f191774c991beaee393bddb5b19 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Mon, 9 Feb 2026 10:03:30 -0500 Subject: [PATCH 004/178] chore: add macOS certificate files to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 054572ae..bd1e54d3 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,7 @@ build/ dist/ package-lock.json .vscode/settings.json + +# Any macOS Certificate files +*.cer +*.p12 From bfd701d369223c4db5ab4e4e472a9aaa1e57f3bf Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Mon, 9 Feb 2026 10:25:26 -0500 Subject: [PATCH 005/178] fix: update macOS code signing verification to skip spctl assessment --- .github/workflows/nightly-release.yml | 19 +++++++++---------- .github/workflows/prod-release.yml | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index a73b4d30..77c5ef16 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -198,14 +198,14 @@ jobs: shell: bash run: | APP_PATH="build/mac/Power Platform ToolBox.app" - + echo "=== Verifying main app signature ===" codesign --verify --deep --strict --verbose=4 "$APP_PATH" 2>&1 - + echo "" echo "=== Checking for timestamps on main app ===" codesign -dvvv "$APP_PATH" 2>&1 | grep -i timestamp || echo "❌ WARNING: NO TIMESTAMP FOUND ON MAIN APP!" - + echo "" echo "=== Verifying critical nested binaries ===" # Check helper apps @@ -216,7 +216,7 @@ jobs: codesign -dvvv "$helper" 2>&1 | grep -i timestamp || echo "❌ No timestamp: $helper" fi done - + # Check frameworks echo "" echo "=== Checking frameworks ===" @@ -224,7 +224,7 @@ jobs: echo "Checking: $(basename "$framework")" codesign --verify --strict "$framework" 2>&1 || echo "❌ Failed: $framework" done - + # Check dylibs echo "" echo "=== Checking dynamic libraries ===" @@ -232,12 +232,11 @@ jobs: echo "Checking: $(basename "$dylib")" codesign --verify --strict "$dylib" 2>&1 || echo "❌ Failed: $dylib" done - - echo "" - echo "=== Running spctl assessment ===" - spctl --assess --type exec --verbose=4 "$APP_PATH" 2>&1 - + echo "" + echo "=== Note ===" + echo "Skipping 'spctl --assess' here because it typically reports 'source=Unnotarized Developer ID' until the notarization+stapling job completes." + echo "" echo "✅ macOS code signing verification complete" - name: Submit macOS notarization request diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 74dfca35..63a612f2 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -202,14 +202,14 @@ jobs: shell: bash run: | APP_PATH="build/mac/Power Platform ToolBox.app" - + echo "=== Verifying main app signature ===" codesign --verify --deep --strict --verbose=4 "$APP_PATH" 2>&1 - + echo "" echo "=== Checking for timestamps on main app ===" codesign -dvvv "$APP_PATH" 2>&1 | grep -i timestamp || echo "❌ WARNING: NO TIMESTAMP FOUND ON MAIN APP!" - + echo "" echo "=== Verifying critical nested binaries ===" # Check helper apps @@ -220,7 +220,7 @@ jobs: codesign -dvvv "$helper" 2>&1 | grep -i timestamp || echo "❌ No timestamp: $helper" fi done - + # Check frameworks echo "" echo "=== Checking frameworks ===" @@ -228,7 +228,7 @@ jobs: echo "Checking: $(basename "$framework")" codesign --verify --strict "$framework" 2>&1 || echo "❌ Failed: $framework" done - + # Check dylibs echo "" echo "=== Checking dynamic libraries ===" @@ -236,12 +236,11 @@ jobs: echo "Checking: $(basename "$dylib")" codesign --verify --strict "$dylib" 2>&1 || echo "❌ Failed: $dylib" done - - echo "" - echo "=== Running spctl assessment ===" - spctl --assess --type exec --verbose=4 "$APP_PATH" 2>&1 - + echo "" + echo "=== Note ===" + echo "Skipping 'spctl --assess' here because it typically reports 'source=Unnotarized Developer ID' until the notarization+stapling job completes." + echo "" echo "✅ macOS code signing verification complete" - name: Submit macOS notarization request From af647d5069cfd59f0506b06fb92d517b4f1ec04b Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Mon, 9 Feb 2026 10:47:40 -0500 Subject: [PATCH 006/178] fix: enhance macOS notarization steps to support multiple artifacts and improve error handling --- .github/workflows/nightly-release.yml | 30 ++++++++++++++++----------- .github/workflows/prod-release.yml | 30 ++++++++++++++++----------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 77c5ef16..c6fdbf56 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -412,6 +412,7 @@ jobs: with: name: macos-build path: notarize + merge-multiple: true - name: Locate notarization info id: notarize-info @@ -438,24 +439,29 @@ jobs: - name: Staple macOS artifacts shell: bash run: | - shopt -s nullglob - for file in notarize/build/*.dmg notarize/build/*.pkg notarize/build/*.zip; do - if [[ -f "$file" ]]; then - echo "Stapling $(basename "$file")" - xcrun stapler staple "$file" - fi - done + found=0 + while IFS= read -r -d '' file; do + found=1 + echo "Stapling $(basename "$file")" + xcrun stapler staple "$file" + done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" -o -name "*.zip" \) -print0) + + if [[ "$found" -eq 0 ]]; then + echo "No macOS artifacts found to staple under 'notarize'." >&2 + find notarize -maxdepth 4 -type f || true + exit 1 + fi - name: Upload stapled macOS artifacts uses: actions/upload-artifact@v4 with: name: macos-build path: | - notarize/build/*.dmg - notarize/build/*.pkg - notarize/build/*.zip - notarize/build/*.yml - notarize/build/notarization-info.json + notarize/**/*.dmg + notarize/**/*.pkg + notarize/**/*.zip + notarize/**/*.yml + notarize/**/notarization-info.json retention-days: 30 overwrite: true diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 63a612f2..2d55bf02 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -365,6 +365,7 @@ jobs: with: name: macos-release path: notarize + merge-multiple: true - name: Locate notarization info id: notarize-info @@ -391,24 +392,29 @@ jobs: - name: Staple macOS artifacts shell: bash run: | - shopt -s nullglob - for file in notarize/build/*.dmg notarize/build/*.pkg notarize/build/*.zip; do - if [[ -f "$file" ]]; then - echo "Stapling $(basename "$file")" - xcrun stapler staple "$file" - fi - done + found=0 + while IFS= read -r -d '' file; do + found=1 + echo "Stapling $(basename "$file")" + xcrun stapler staple "$file" + done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" -o -name "*.zip" \) -print0) + + if [[ "$found" -eq 0 ]]; then + echo "No macOS artifacts found to staple under 'notarize'." >&2 + find notarize -maxdepth 4 -type f || true + exit 1 + fi - name: Upload stapled macOS artifacts uses: actions/upload-artifact@v4 with: name: macos-release path: | - notarize/build/*.dmg - notarize/build/*.pkg - notarize/build/*.zip - notarize/build/*.yml - notarize/build/notarization-info.json + notarize/**/*.dmg + notarize/**/*.pkg + notarize/**/*.zip + notarize/**/*.yml + notarize/**/notarization-info.json retention-days: 90 overwrite: true From b4f1a178722ed70bc1bab0e7d365bc0738ac789e Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Mon, 9 Feb 2026 11:05:01 -0500 Subject: [PATCH 007/178] fix: update notarization scripts to support multiple asset types and improve error handling --- .github/workflows/nightly-release.yml | 4 +- .github/workflows/prod-release.yml | 4 +- buildScripts/notarize.js | 138 ++++++++++++++++++++------ 3 files changed, 110 insertions(+), 36 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index c6fdbf56..4bc90156 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -247,7 +247,7 @@ jobs: APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | - node ./buildScripts/notarize.js submit --app="build/mac/Power Platform ToolBox.app" --output="build/notarization-info.json" + node ./buildScripts/notarize.js submit --assets="build/*.dmg,build/*.zip,build/*.pkg" --app="build/mac/Power Platform ToolBox.app" --output="build/notarization-info.json" - name: Cleanup macOS signing certificate if: ${{ always() && matrix.os == 'macos-latest' }} @@ -444,7 +444,7 @@ jobs: found=1 echo "Stapling $(basename "$file")" xcrun stapler staple "$file" - done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" -o -name "*.zip" \) -print0) + done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" \) -print0) if [[ "$found" -eq 0 ]]; then echo "No macOS artifacts found to staple under 'notarize'." >&2 diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 2d55bf02..2635f252 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -251,7 +251,7 @@ jobs: APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | - node ./buildScripts/notarize.js submit --app="build/mac/Power Platform ToolBox.app" --output="build/notarization-info.json" + node ./buildScripts/notarize.js submit --assets="build/*.dmg,build/*.zip,build/*.pkg" --app="build/mac/Power Platform ToolBox.app" --output="build/notarization-info.json" - name: Cleanup macOS signing certificate if: ${{ always() && matrix.os == 'macos-latest' }} @@ -397,7 +397,7 @@ jobs: found=1 echo "Stapling $(basename "$file")" xcrun stapler staple "$file" - done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" -o -name "*.zip" \) -print0) + done < <(find notarize -type f \( -name "*.dmg" -o -name "*.pkg" \) -print0) if [[ "$found" -eq 0 ]]; then echo "No macOS artifacts found to staple under 'notarize'." >&2 diff --git a/buildScripts/notarize.js b/buildScripts/notarize.js index df27af36..2a2f8035 100644 --- a/buildScripts/notarize.js +++ b/buildScripts/notarize.js @@ -51,6 +51,42 @@ const getArg = (name, defaultValue) => { return defaultValue; }; +const splitListArg = (value) => { + if (!value) { + return []; + } + + return value + .split(",") + .map((entry) => entry.trim()) + .filter((entry) => entry.length > 0); +}; + +const escapeRegExp = (text) => { + return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +}; + +const expandWildcardPath = (inputPath) => { + const resolvedPath = path.resolve(inputPath); + + if (!resolvedPath.includes("*")) { + return [resolvedPath]; + } + + const dir = path.dirname(resolvedPath); + const base = path.basename(resolvedPath); + + if (!fs.existsSync(dir)) { + return []; + } + + const pattern = new RegExp(`^${base.split("*").map(escapeRegExp).join(".*")}$`); + return fs + .readdirSync(dir) + .filter((name) => pattern.test(name)) + .map((name) => path.join(dir, name)); +}; + const ensureAppleCreds = () => { const appleId = process.env.APPLE_ID; const applePassword = process.env.APPLE_APP_SPECIFIC_PASSWORD; @@ -104,37 +140,53 @@ const submit = () => { const defaultAppPath = path.resolve("build", "mac", "Power Platform ToolBox.app"); const appPath = path.resolve(getArg("--app", defaultAppPath)); + const assetArg = getArg("--assets", ""); + const assets = splitListArg(assetArg); + const outputPath = path.resolve(getArg("--output", path.resolve("build", "notarization-info.json"))); const bundleId = getArg("--bundle-id", "com.powerplatform.toolbox"); const { appleId, applePassword, teamId } = ensureAppleCreds(); - const { assetPath, cleanup, displayPath } = prepareSubmissionAsset(appPath); - process.stdout.write(`Submitting ${displayPath} for notarization (bundleId: ${bundleId}) without waiting...\n`); + const resolvedAssets = assets.length > 0 ? assets.flatMap(expandWildcardPath) : []; + const targets = resolvedAssets.length > 0 ? resolvedAssets : [appPath]; - let resultRaw; + const submissions = []; + for (const target of targets) { + const { assetPath, cleanup, displayPath } = prepareSubmissionAsset(target); + process.stdout.write(`Submitting ${displayPath} for notarization (bundleId: ${bundleId}) without waiting...\n`); - try { - resultRaw = runNotarytool(["submit", assetPath, "--apple-id", appleId, "--team-id", teamId, "--password", applePassword, "--no-wait", "--output-format", "json"]); - } finally { - if (cleanup) { - cleanup(); + try { + const resultRaw = runNotarytool(["submit", assetPath, "--apple-id", appleId, "--team-id", teamId, "--password", applePassword, "--no-wait", "--output-format", "json"]); + const parsed = JSON.parse(resultRaw); + submissions.push({ + submissionId: parsed.id, + status: parsed.status, + submittedAsset: assetPath, + displayPath, + submittedAt: new Date().toISOString(), + }); + process.stdout.write(`Submitted notarization request. Submission ID: ${parsed.id}\n`); + } finally { + if (cleanup) { + cleanup(); + } } } - const parsed = JSON.parse(resultRaw); - const submissionId = parsed.id; + if (submissions.length === 0) { + throw new Error(`No notarization assets found. assets='${assetArg}' app='${appPath}'`); + } + const info = { - submissionId, + submissionId: submissions[0].submissionId, + submissions, bundleId, - status: parsed.status, appPath, - submittedAsset: assetPath, submittedAt: new Date().toISOString(), }; fs.writeFileSync(outputPath, `${JSON.stringify(info, null, 2)}\n`); - process.stdout.write(`Submitted notarization request. Submission ID: ${submissionId}\n`); }; const loadInfo = (infoPath) => { @@ -145,13 +197,21 @@ const loadInfo = (infoPath) => { const contents = fs.readFileSync(infoPath, "utf8"); const info = JSON.parse(contents); - if (!info.submissionId) { - throw new Error(`Notarization info is missing submissionId: ${infoPath}`); + if (!info.submissionId && (!Array.isArray(info.submissions) || info.submissions.length === 0)) { + throw new Error(`Notarization info is missing submissionId/submissions: ${infoPath}`); } return info; }; +const getSubmissionIds = (info) => { + if (Array.isArray(info.submissions) && info.submissions.length > 0) { + return info.submissions.map((entry) => entry.submissionId).filter(Boolean); + } + + return info.submissionId ? [info.submissionId] : []; +}; + const waitForStatus = async () => { const infoPath = path.resolve(getArg("--info", path.resolve("build", "notarization-info.json"))); const timeoutHours = Number(getArg("--timeout-hours", "12")); @@ -163,33 +223,47 @@ const waitForStatus = async () => { const maxAttempts = Math.max(1, Math.ceil((timeoutHours * 60) / intervalMinutes)); const info = loadInfo(infoPath); + const submissionIds = getSubmissionIds(info); const { appleId, applePassword, teamId } = ensureAppleCreds(); - process.stdout.write(`Waiting for notarization ${info.submissionId} (max ${timeoutHours}h)...\n`); + if (submissionIds.length === 0) { + throw new Error(`No notarization submission IDs found in ${infoPath}`); + } + + process.stdout.write(`Waiting for notarization (${submissionIds.length} submission(s), max ${timeoutHours}h)...\n`); for (let attempt = 1; attempt <= maxAttempts; attempt += 1) { try { - const output = runNotarytool(["log", info.submissionId, "--apple-id", appleId, "--team-id", teamId, "--password", applePassword, "--output-format", "json"]); + let acceptedCount = 0; - const parsed = JSON.parse(output); - const status = parsed.status; + for (const submissionId of submissionIds) { + const output = runNotarytool(["log", submissionId, "--apple-id", appleId, "--team-id", teamId, "--password", applePassword, "--output-format", "json"]); - if (status === "Accepted") { - process.stdout.write(`Notarization ${info.submissionId} accepted.\n`); - return; - } + const parsed = JSON.parse(output); + const status = parsed.status; + + if (status === "Accepted") { + acceptedCount += 1; + continue; + } - if (status === "Invalid") { - const issues = parsed.issues || []; - process.stderr.write(`Notarization ${info.submissionId} was rejected.\n`); - if (issues.length > 0) { - process.stderr.write(`${JSON.stringify(issues, null, 2)}\n`); + if (status === "Invalid") { + const issues = parsed.issues || []; + process.stderr.write(`Notarization ${submissionId} was rejected.\n`); + if (issues.length > 0) { + process.stderr.write(`${JSON.stringify(issues, null, 2)}\n`); + } + throw new Error("Apple rejected the notarization request."); } - throw new Error("Apple rejected the notarization request."); + } + + if (acceptedCount === submissionIds.length) { + process.stdout.write(`Notarization accepted for all submissions (${acceptedCount}/${submissionIds.length}).\n`); + return; } if (attempt === maxAttempts) { - throw new Error(`Timed out waiting for notarization ${info.submissionId} after ${timeoutHours} hours.`); + throw new Error(`Timed out waiting for notarization after ${timeoutHours} hours.`); } const nextDelayMs = intervalMinutes * 60 * 1000; @@ -198,7 +272,7 @@ const waitForStatus = async () => { } catch (error) { if (isLogUnavailableError(error)) { if (attempt === maxAttempts) { - throw new Error(`Timed out waiting for notarization ${info.submissionId} after ${timeoutHours} hours (submission log never became available).`); + throw new Error(`Timed out waiting for notarization after ${timeoutHours} hours (submission log never became available).`); } const nextDelayMs = intervalMinutes * 60 * 1000; From 0a17a657746b6502cb7d3e8b436dadfadac8f503 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Mon, 9 Feb 2026 17:03:38 -0500 Subject: [PATCH 008/178] fix: update version to 1.1.3 in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce4e6c00..a16900c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "powerplatform-toolbox", - "version": "1.1.2", + "version": "1.1.3", "description": "A universal desktop app that contains multiple tools to ease the customization and configuration of Power Platform", "main": "dist/main/index.js", "scripts": { From 47ffa9fd3a3121ebefdce5d0608e2efd08d2970c Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 21:27:10 -0500 Subject: [PATCH 009/178] feat: Associate browser profile with connections - visual tags and profile detection (#355) * Initial plan * Add browser profile support for interactive authentication - Add browserType and browserProfile fields to DataverseConnection interface - Implement browser-specific launch logic in AuthManager - Update add/edit connection modals with browser selection UI - Support Chrome, Edge, Firefox, and Brave browsers - Fallback to default browser if profile not found Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Address code review feedback - use helper functions consistently Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Refactor: Extract browser logic into separate BrowserManager - Create new BrowserManager class for browser detection and profile enumeration - Remove browser-related code from AuthManager - AuthManager now depends on BrowserManager via constructor injection - Add IPC channels for browser detection and profile listing - Update preload script to expose new browser APIs Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Implement dynamic browser profile detection in UI - Replace text input with dropdown for browser profiles - Dynamically detect browser installation on selection - Automatically load and populate browser profiles - Show warning when selected browser is not installed - Support both add and edit connection modals - Add modal-warning CSS for user feedback Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix: Browser profile detection in modals - Expose browser detection APIs in modalPreload.ts - Fix browser type change event to properly trigger profile loading - Set correct initial state for profile dropdown (No profile needed) - Remove premature loadBrowserProfiles() call that ran before DOM ready Fixes: - Profile selector now loads data when browser is selected - Browser detection APIs now available in modal context - Initial dropdown state shows correct message - Warning displays when browser not installed Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Enhance profile detection to show friendly names, support Chrome/Edge only - Read actual profile names from Local State file (e.g., "Person 1", "Work") - Fallback to reading individual Preferences files if Local State unavailable - Remove Firefox and Brave browser support (Chrome and Edge only) - UI now displays profile.name but stores profile.path for --profile-directory - Update both add and edit connection modals Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Move browser settings to separate section available for all auth types - Move browser type and profile selectors out of interactive-only section - Create new "Browser Settings (Optional)" section below Environment selector - Apply browser settings to all authentication types (interactive, clientSecret, usernamePassword, connectionString) - Browser profile used when tools need to open URLs with authentication - Updated both add and edit connection modals - Updated connectionManagement to apply browser settings to all auth types Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fixed style issue and added logos * Add browser profile tag to connection cards in sidebar - Add browserProfileName field to DataverseConnection type - Display browser icon and profile name as tag on connection cards - Tag shows Chrome/Edge icon with friendly profile name (e.g., "My Cool Profile") - Tag positioned next to environment badge - Update form controllers to capture and store profile name - Add CSS styling for connection-browser-tag with browser icon - Browser icons loaded from renderer/icons/logos/ Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix modal hanging issue - improve browser profile name collection - Fix collectFormData to safely handle empty profile selections - Only capture browserProfileName when a profile is actually selected - Add null-safe checks for selectedOptions array access - Prevent attempting to read textContent from empty value options Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Revert "Fix modal hanging issue - improve browser profile name collection" This reverts commit 607fde9bdc171cdaf3039153d6457ff8a3c4d814. * Revert "Add browser profile tag to connection cards in sidebar" This reverts commit e1cab02dfd7401b5555de63bee6e664eea96e4d8. * feat: add browser profile name support in connection forms and UI * Update src/renderer/modules/connectionManagement.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/main/managers/browserManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/main/managers/browserManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/common/types/connection.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/common/ipc/channels.ts | 2 + src/common/types/connection.ts | 11 + src/main/index.ts | 16 +- src/main/managers/authManager.ts | 11 +- src/main/managers/browserManager.ts | 322 ++++++++++++++++++ src/main/modalPreload.ts | 10 +- src/main/preload.ts | 2 + src/renderer/icons/logos/chrome.png | Bin 0 -> 24560 bytes src/renderer/icons/logos/edge.png | Bin 0 -> 38070 bytes .../modals/addConnection/controller.ts | 100 ++++++ src/renderer/modals/addConnection/view.ts | 18 + .../modals/editConnection/controller.ts | 106 ++++++ src/renderer/modals/editConnection/view.ts | 18 + src/renderer/modals/sharedStyles.ts | 13 + src/renderer/modules/connectionManagement.ts | 76 ++++- src/renderer/styles.scss | 49 ++- vite.config.ts | 15 + 17 files changed, 761 insertions(+), 8 deletions(-) create mode 100644 src/main/managers/browserManager.ts create mode 100644 src/renderer/icons/logos/chrome.png create mode 100644 src/renderer/icons/logos/edge.png diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index e38d6b3c..c9e34dea 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -50,6 +50,8 @@ export const CONNECTION_CHANNELS = { TEST_CONNECTION: "test-connection", IS_TOKEN_EXPIRED: "is-connection-token-expired", REFRESH_TOKEN: "refresh-connection-token", + CHECK_BROWSER_INSTALLED: "check-browser-installed", + GET_BROWSER_PROFILES: "get-browser-profiles", } as const; // Tool-related IPC channels diff --git a/src/common/types/connection.ts b/src/common/types/connection.ts index 18b81d29..0547e504 100644 --- a/src/common/types/connection.ts +++ b/src/common/types/connection.ts @@ -7,6 +7,13 @@ */ export type AuthenticationType = "interactive" | "clientSecret" | "usernamePassword" | "connectionString"; +/** + * Browser type for interactive authentication + * + * Note: Firefox and Brave may be added here in the future when BrowserManager supports them. + */ +export type BrowserType = "default" | "chrome" | "edge"; + /** * Dataverse connection configuration * @@ -32,6 +39,10 @@ export interface DataverseConnection { tokenExpiry?: string; // MSAL account identifier for silent token acquisition (used with interactive auth) msalAccountId?: string; + // Browser profile settings for interactive authentication + browserType?: BrowserType; + browserProfile?: string; + browserProfileName?: string; } /** diff --git a/src/main/index.ts b/src/main/index.ts index 3ebaa2c6..d0c11ef1 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -77,6 +77,7 @@ import { import { EntityRelatedMetadataPath, LastUsedToolEntry, LastUsedToolUpdate, ModalWindowMessagePayload, ModalWindowOptions, ToolBoxEvent } from "../common/types"; import { AuthManager } from "./managers/authManager"; import { AutoUpdateManager } from "./managers/autoUpdateManager"; +import { BrowserManager } from "./managers/browserManager"; import { BrowserviewProtocolManager } from "./managers/browserviewProtocolManager"; import { ConnectionsManager } from "./managers/connectionsManager"; import { DataverseManager } from "./managers/dataverseManager"; @@ -106,6 +107,7 @@ class ToolBoxApp { private modalWindowManager: ModalWindowManager | null = null; private api: ToolBoxUtilityManager; private autoUpdateManager: AutoUpdateManager; + private browserManager: BrowserManager; private authManager: AuthManager; private terminalManager: TerminalManager; private dataverseManager: DataverseManager; @@ -133,7 +135,8 @@ class ToolBoxApp { this.toolManager = new ToolManager(path.join(app.getPath("userData"), "tools"), process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY, this.installIdManager); this.browserviewProtocolManager = new BrowserviewProtocolManager(this.toolManager, this.settingsManager); this.autoUpdateManager = new AutoUpdateManager(); - this.authManager = new AuthManager(); + this.browserManager = new BrowserManager(); + this.authManager = new AuthManager(this.browserManager); this.terminalManager = new TerminalManager(); this.dataverseManager = new DataverseManager(this.connectionsManager, this.authManager); @@ -279,6 +282,8 @@ class ToolBoxApp { ipcMain.removeHandler(CONNECTION_CHANNELS.TEST_CONNECTION); ipcMain.removeHandler(CONNECTION_CHANNELS.IS_TOKEN_EXPIRED); ipcMain.removeHandler(CONNECTION_CHANNELS.REFRESH_TOKEN); + ipcMain.removeHandler(CONNECTION_CHANNELS.CHECK_BROWSER_INSTALLED); + ipcMain.removeHandler(CONNECTION_CHANNELS.GET_BROWSER_PROFILES); // Tool handlers ipcMain.removeHandler(TOOL_CHANNELS.GET_ALL_TOOLS); @@ -708,6 +713,15 @@ class ToolBoxApp { } }); + // Browser detection handlers + ipcMain.handle(CONNECTION_CHANNELS.CHECK_BROWSER_INSTALLED, (_, browserType: string) => { + return this.browserManager.isBrowserInstalled(browserType); + }); + + ipcMain.handle(CONNECTION_CHANNELS.GET_BROWSER_PROFILES, (_, browserType: string) => { + return this.browserManager.getBrowserProfiles(browserType); + }); + // Tool handlers ipcMain.handle(TOOL_CHANNELS.GET_ALL_TOOLS, () => { return this.toolManager.getAllTools(); diff --git a/src/main/managers/authManager.ts b/src/main/managers/authManager.ts index 8a93df35..080b3711 100644 --- a/src/main/managers/authManager.ts +++ b/src/main/managers/authManager.ts @@ -1,11 +1,12 @@ import { AccountInfo, ConfidentialClientApplication, LogLevel, PublicClientApplication } from "@azure/msal-node"; -import { BrowserWindow, shell } from "electron"; +import { BrowserWindow } from "electron"; import * as http from "http"; import * as https from "https"; import { EVENT_CHANNELS } from "../../common/ipc/channels"; import { captureMessage, logInfo, logWarn } from "../../common/sentryHelper"; import { DataverseConnection } from "../../common/types"; import { DATAVERSE_API_VERSION } from "../constants"; +import { BrowserManager } from "./browserManager"; /** * Manages authentication for Power Platform connections @@ -18,6 +19,7 @@ export class AuthManager { private activeServer: http.Server | null = null; private activeServerTimeout: NodeJS.Timeout | null = null; private activePort: number | null = null; + private browserManager: BrowserManager; // Authentication timeout duration (5 minutes) private static readonly AUTH_TIMEOUT_MS = 5 * 60 * 1000; @@ -31,7 +33,8 @@ export class AuthManager { "/": "/", }; - constructor() { + constructor(browserManager: BrowserManager) { + this.browserManager = browserManager; // MSAL will be initialized on-demand for interactive auth } @@ -382,8 +385,8 @@ export class AuthManager { server.listen(port, "localhost", () => { logInfo(`Listening for OAuth redirect on ${redirectUri}`); - // Server is ready, now open the browser - shell.openExternal(authCodeUrl).catch((err) => { + // Server is ready, now open the browser with profile support + this.browserManager.openBrowserWithProfile(authCodeUrl, connection).catch((err) => { cleanupAndReject(new Error(`Failed to open browser: ${err.message}`)); }); }); diff --git a/src/main/managers/browserManager.ts b/src/main/managers/browserManager.ts new file mode 100644 index 00000000..a4e82afd --- /dev/null +++ b/src/main/managers/browserManager.ts @@ -0,0 +1,322 @@ +import { spawn, execSync } from "child_process"; +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import { shell } from "electron"; +import { logInfo, logWarn } from "../../common/sentryHelper"; +import { DataverseConnection } from "../../common/types"; + +/** + * Manages browser detection, profile enumeration, and browser launching + */ +export class BrowserManager { + /** + * Check if a specific browser is installed on the system + * @param browserType The type of browser to check (chrome or edge) + * @returns true if browser is installed, false otherwise + */ + public isBrowserInstalled(browserType: string): boolean { + if (!browserType || browserType === "default") { + return true; // Default browser is always available + } + + const platform = process.platform; + let possiblePaths: string[] = []; + + if (browserType === "chrome") { + if (platform === "win32") { + possiblePaths = [ + path.join(process.env.PROGRAMFILES || "C:\\Program Files", "Google\\Chrome\\Application\\chrome.exe"), + path.join(process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)", "Google\\Chrome\\Application\\chrome.exe"), + path.join(process.env.LOCALAPPDATA || "", "Google\\Chrome\\Application\\chrome.exe"), + ]; + } else if (platform === "darwin") { + possiblePaths = ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"]; + } else { + // For Linux, check if command exists + try { + execSync("which google-chrome", { stdio: "ignore" }); + return true; + } catch { + return false; + } + } + } else if (browserType === "edge") { + if (platform === "win32") { + possiblePaths = [ + path.join(process.env.PROGRAMFILES || "C:\\Program Files", "Microsoft\\Edge\\Application\\msedge.exe"), + path.join(process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)", "Microsoft\\Edge\\Application\\msedge.exe"), + ]; + } else if (platform === "darwin") { + possiblePaths = ["/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"]; + } else { + try { + execSync("which microsoft-edge", { stdio: "ignore" }); + return true; + } catch { + return false; + } + } + } + + // Check if any of the paths exist + return possiblePaths.some((p) => fs.existsSync(p)); + } + + /** + * Get list of browser profiles for a specific browser + * @param browserType The type of browser to get profiles for + * @returns Array of profile objects with name and path + */ + public getBrowserProfiles(browserType: string): Array<{ name: string; path: string }> { + if (!browserType || browserType === "default") { + return []; + } + + if (!this.isBrowserInstalled(browserType)) { + return []; + } + + const platform = process.platform; + + try { + if (browserType === "chrome" || browserType === "edge") { + return this.getChromiumProfiles(browserType, platform); + } + } catch (error) { + logWarn(`Failed to get profiles for ${browserType}: ${(error as Error).message}`); + return []; + } + + return []; + } + + /** + * Get Chromium-based browser profiles (Chrome, Edge) + * Returns objects with both display name and directory path + */ + private getChromiumProfiles(browserType: string, platform: string): Array<{ name: string; path: string }> { + let userDataPath = ""; + + if (browserType === "chrome") { + if (platform === "win32") { + userDataPath = path.join(process.env.LOCALAPPDATA || "", "Google\\Chrome\\User Data"); + } else if (platform === "darwin") { + userDataPath = path.join(os.homedir(), "Library/Application Support/Google/Chrome"); + } else { + userDataPath = path.join(os.homedir(), ".config/google-chrome"); + } + } else if (browserType === "edge") { + if (platform === "win32") { + userDataPath = path.join(process.env.LOCALAPPDATA || "", "Microsoft\\Edge\\User Data"); + } else if (platform === "darwin") { + userDataPath = path.join(os.homedir(), "Library/Application Support/Microsoft Edge"); + } else { + userDataPath = path.join(os.homedir(), ".config/microsoft-edge"); + } + } + + if (!fs.existsSync(userDataPath)) { + return []; + } + + const profiles: Array<{ name: string; path: string }> = []; + + try { + // Try to read Local State file to get profile names (preferred method) + const localStatePath = path.join(userDataPath, "Local State"); + if (fs.existsSync(localStatePath)) { + const localStateContent = fs.readFileSync(localStatePath, "utf8"); + const localState = JSON.parse(localStateContent); + + if (localState.profile && localState.profile.info_cache) { + const infoCache = localState.profile.info_cache; + + // Iterate through all profiles in info_cache + for (const profileDir in infoCache) { + if (Object.prototype.hasOwnProperty.call(infoCache, profileDir)) { + const profileInfo = infoCache[profileDir]; + const profileName = profileInfo.name || profileDir; + + // Include Default and Profile X directories + if (profileDir === "Default" || profileDir.startsWith("Profile ")) { + profiles.push({ + name: profileName, + path: profileDir, + }); + } + } + } + } + + // If we found profiles from Local State, return them + if (profiles.length > 0) { + return profiles; + } + } + } catch (error) { + logWarn(`Failed to read Local State file, falling back to directory scan: ${(error as Error).message}`); + } + + // Fallback: Scan directories and try to read individual Preferences files + try { + const entries = fs.readdirSync(userDataPath, { withFileTypes: true }); + + for (const entry of entries) { + if (entry.isDirectory()) { + const dirName = entry.name; + + // Check for Default profile or Profile X directories + if (dirName === "Default" || dirName.startsWith("Profile ")) { + try { + // Try to read the profile name from Preferences file + const preferencesPath = path.join(userDataPath, dirName, "Preferences"); + if (fs.existsSync(preferencesPath)) { + const preferencesContent = fs.readFileSync(preferencesPath, "utf8"); + const preferences = JSON.parse(preferencesContent); + + const profileName = preferences.profile?.name || dirName; + profiles.push({ + name: profileName, + path: dirName, + }); + } else { + // If Preferences doesn't exist, use directory name + profiles.push({ + name: dirName, + path: dirName, + }); + } + } catch { + // If we can't read Preferences, just use directory name + profiles.push({ + name: dirName, + path: dirName, + }); + } + } + } + } + } catch (error) { + logWarn(`Failed to scan browser profile directories: ${(error as Error).message}`); + } + + return profiles; + } + + /** + * Get browser executable path and arguments for launching with a specific profile + * Returns null if browser is not found, which triggers fallback to default browser + */ + private getBrowserLaunchCommand(browserType: string, profileName: string | undefined): { executable: string; args: string[] } | null { + const platform = process.platform; + let executable = ""; + const args: string[] = []; + + // If no browser type specified or set to default, return null for fallback + if (!browserType || browserType === "default") { + return null; + } + + // Determine browser executable path based on platform and browser type + if (browserType === "chrome") { + if (platform === "win32") { + // Try multiple common Chrome installation paths on Windows + const chromePaths = [ + path.join(process.env.PROGRAMFILES || "C:\\Program Files", "Google\\Chrome\\Application\\chrome.exe"), + path.join(process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)", "Google\\Chrome\\Application\\chrome.exe"), + path.join(process.env.LOCALAPPDATA || "", "Google\\Chrome\\Application\\chrome.exe"), + ]; + for (const chromePath of chromePaths) { + if (fs.existsSync(chromePath)) { + executable = chromePath; + break; + } + } + } else if (platform === "darwin") { + executable = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; + } else { + // Linux + executable = "google-chrome"; + } + } else if (browserType === "edge") { + if (platform === "win32") { + const edgePaths = [ + path.join(process.env.PROGRAMFILES || "C:\\Program Files", "Microsoft\\Edge\\Application\\msedge.exe"), + path.join(process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)", "Microsoft\\Edge\\Application\\msedge.exe"), + ]; + for (const edgePath of edgePaths) { + if (fs.existsSync(edgePath)) { + executable = edgePath; + break; + } + } + } else if (platform === "darwin") { + executable = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"; + } else { + // Linux + executable = "microsoft-edge"; + } + } + + // If executable not found or not set, return null for fallback + if (!executable) { + return null; + } + + // Verify executable exists (for absolute paths) + if (path.isAbsolute(executable) && !fs.existsSync(executable)) { + return null; + } + + // Add profile argument if specified + if (profileName) { + // Sanitize profile name to avoid problematic characters in CLI argument + const safeProfileName = profileName.replace(/[^\w\s-]/g, "_"); + // Chrome and Edge use --profile-directory flag + args.push(`--profile-directory=${safeProfileName}`); + } + + return { executable, args }; + } + + /** + * Open URL in browser with optional profile support + * Falls back to default browser if profile browser is not found + */ + public async openBrowserWithProfile(url: string, connection: DataverseConnection): Promise { + const browserType = connection.browserType || "default"; + const profileName = connection.browserProfile; + + // If default browser or no profile specified, use standard shell.openExternal + if (browserType === "default" || !profileName) { + return shell.openExternal(url); + } + + // Try to get browser launch command with profile + const browserCommand = this.getBrowserLaunchCommand(browserType, profileName); + + if (!browserCommand) { + // Browser not found, fallback to default browser + logInfo(`Browser ${browserType} not found, falling back to default browser`); + return shell.openExternal(url); + } + + try { + // Launch browser with profile + const { executable, args } = browserCommand; + const browserArgs = [...args, url]; + + logInfo(`Launching ${browserType} with profile ${profileName}: ${executable} ${browserArgs.join(" ")}`); + + spawn(executable, browserArgs, { + detached: true, + stdio: "ignore", + }).unref(); + } catch (error) { + // If browser launch fails, fallback to default browser + logWarn(`Failed to launch ${browserType} with profile, falling back to default: ${(error as Error).message}`); + return shell.openExternal(url); + } + } +} diff --git a/src/main/modalPreload.ts b/src/main/modalPreload.ts index 18141ec8..1e191702 100644 --- a/src/main/modalPreload.ts +++ b/src/main/modalPreload.ts @@ -1,5 +1,5 @@ import { contextBridge, ipcRenderer } from "electron"; -import { MODAL_WINDOW_CHANNELS } from "../common/ipc/channels"; +import { CONNECTION_CHANNELS, MODAL_WINDOW_CHANNELS } from "../common/ipc/channels"; type ModalMessageHandler = (payload: unknown) => void; const messageHandlers = new Set(); @@ -18,3 +18,11 @@ contextBridge.exposeInMainWorld("modalBridge", { messageHandlers.delete(handler); }, }); + +// Expose browser detection APIs for connection modals +contextBridge.exposeInMainWorld("toolboxAPI", { + connections: { + checkBrowserInstalled: (browserType: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.CHECK_BROWSER_INSTALLED, browserType), + getBrowserProfiles: (browserType: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.GET_BROWSER_PROFILES, browserType), + }, +}); diff --git a/src/main/preload.ts b/src/main/preload.ts index 7045e367..bf8b5a36 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -35,6 +35,8 @@ contextBridge.exposeInMainWorld("toolboxAPI", { isTokenExpired: (connectionId: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.IS_TOKEN_EXPIRED, connectionId), refreshToken: (connectionId: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.REFRESH_TOKEN, connectionId), authenticate: (connectionId: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.SET_ACTIVE_CONNECTION, connectionId), + checkBrowserInstalled: (browserType: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.CHECK_BROWSER_INSTALLED, browserType), + getBrowserProfiles: (browserType: string) => ipcRenderer.invoke(CONNECTION_CHANNELS.GET_BROWSER_PROFILES, browserType), }, // Tools - Only for PPTB UI diff --git a/src/renderer/icons/logos/chrome.png b/src/renderer/icons/logos/chrome.png new file mode 100644 index 0000000000000000000000000000000000000000..1d5437d428247c3713995a6698cef1c2eed0ba02 GIT binary patch literal 24560 zcmXtA1yodB*S-_PC=Jrxh_nKdLntXNA&rD|GaxkxQc9;%igb4hjD#R!&`1s?oznSV z-f#V^#TsVj+;jHX@jUzPvoBFv8cKw>Xm0@kK&Yaur~?2{@J}d!j|;vW_>P=`F9bm)b^tu*VgCEj(Ju>vtb+z?ES$fz2C=`m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zQRDT#nAwo4IlqM+)7zZGDH%JDCb;91dZVW9tJ@<4Y;) z_3h>zT%E9=Kc+ey-!;G37B)|`$tO|adrUr@EnU_q=w%c+mO)VxVYdSANe7+(Hi1t02J8Nj?uJ$8$xD}O@s3*pk2K-80X4}o;(}g|!Lt-avh^oqY;>-2 zZo>E3SwD@~t-*Fiy_Yf1Ek*B4Cs}jE*B{u3+V#L@m=Rik?SUJ6_8kk_Pk-j+X=9XZ zX=J{;_v&Yrl9XBzMI)zFPVAM%K1bzw;ikI~vY^LlC|(53F4XD_VAwEp#OS~LM0%Q1!9oM~YZT&?u( z)o~+dCKo;;ioc+lCgy5lNRBuUP(p5$Rh*WxV^_V%vMC5kblvXVl+}zP@wM4aOD+Zf k&9id(sm>qpbRGr8XIr2+kp9!)YyE(>`V+N^|197C9}9h~m;e9( literal 0 HcmV?d00001 diff --git a/src/renderer/icons/logos/edge.png b/src/renderer/icons/logos/edge.png new file mode 100644 index 0000000000000000000000000000000000000000..feb98376c80861b80af4d215e40709107b5961fb GIT binary patch literal 38070 zcmY&=by(C<*X<0QLr6D*gdm_ucPI!72vX7#qrwnFmkcE!4I?gQRp1-3`(? z+#kO0_uYH{PiL9YG*S+ubj4r(M1U@Q1Wc&-9$M?5vzz&ES?GS65fQ54P5h=4SSme0FeX@}49e z2*d((#I3khj8Oeu}2j4?1M<24Y zce09-tvqgi?Yt-)L@fVH-P%AwI8GwYoWBc(ha~TQg_j1dfpDkiw0is;fl0q*+S7lz4w>vQBB(aElh6mCV1Al|@j>gGfnD{Q;B0 zueqVDZr~U~1fi@kh{1^ZAVo?c6w{eT53y*DP3Q@m_+9o#Q#!;H`+!E1PpK>lZ4_zW z%^XfnN*WbR3c|wLFh#d@vaNQI8ohjG97drF792@UG4HhbDg`ZlR0dBF^&yPNfw3z2 z#<4KVACd+KiRSG49?-C|WYDsL@bKPu>`ZyTOm!!Fz58&Xqgk6JQkq4BfD@XRXD;En zXmaS1+uUWLlk>roUz0EQK9!%L^7pc+&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zW!P0Bu`RGXQD_fTsWmxN+Cb1J3fCo!o?}KL3p@+r!lGx!HtVqu0bVhG-Eq!diDT*M zaicGZn5wLpx|=yp2jjI|$gHHwrmuP1e08y-8pSO$o9o4^c=pkI*t5W1m@deb9Q)1# zggC90+a#a2f}g@s2dO472W>xR*!+{84dvUSHjOs)Q_4pJk8agD&>v@GTO@%mzyKe# ztn$?e^_j$!F(-%++@tXU4=z&lzCvF~8|PX-zLfZN+R+BDVKyV`6t-V&Q6Xd5B%rQs zcsDOer8_>@mAq=QwF>c5pe*wXf4hP5*(kj&$6uC*c#M*5<-J=UYXlNZ{Ay^^cRB71 zKSi?Z4|8ARQ)E4y& { + const select = browserProfileSelect instanceof HTMLSelectElement ? browserProfileSelect : null; + if (!select) { + return { value: "", name: "" }; + } + const value = (select.value || "").trim(); + if (!value) { + return { value: "", name: "" }; + } + const selectedOption = select.options[select.selectedIndex]; + const datasetName = selectedOption?.dataset?.profileName?.trim() || ""; + const fallbackName = selectedOption?.textContent?.trim() || ""; + return { value, name: datasetName || fallbackName }; + }; const updateAuthVisibility = () => { const authType = authTypeSelect?.value || "interactive"; @@ -39,6 +56,67 @@ export function getAddConnectionModalControllerScript(channels: AddConnectionMod if (testButton) testButton.style.display = (authType === "interactive" || authType === "connectionString") ? "none" : "inline-flex"; }; + const loadBrowserProfiles = async () => { + const browserType = browserTypeSelect?.value || "default"; + + // Reset warning + if (browserWarning) browserWarning.style.display = "none"; + + if (browserType === "default") { + // Reset profile dropdown for default browser + if (browserProfileSelect) { + browserProfileSelect.disabled = true; + browserProfileSelect.innerHTML = ''; + } + return; + } + + // Check if browser is installed + const isInstalled = await window.toolboxAPI.connections.checkBrowserInstalled(browserType); + + if (!isInstalled) { + // Show warning + if (browserWarning) browserWarning.style.display = "block"; + if (browserProfileSelect) { + browserProfileSelect.disabled = true; + browserProfileSelect.innerHTML = ''; + } + return; + } + + // Load profiles + if (browserProfileSelect) { + browserProfileSelect.disabled = true; + browserProfileSelect.innerHTML = ''; + } + + try { + const profiles = await window.toolboxAPI.connections.getBrowserProfiles(browserType); + + if (browserProfileSelect) { + if (profiles.length === 0) { + browserProfileSelect.innerHTML = ''; + browserProfileSelect.disabled = true; + } else { + browserProfileSelect.innerHTML = ''; + profiles.forEach(profile => { + const option = document.createElement("option"); + option.value = profile.path; // Use path as value for --profile-directory + option.textContent = profile.name; // Display the friendly name + option.dataset.profileName = profile.name; + browserProfileSelect.appendChild(option); + }); + browserProfileSelect.disabled = false; + } + } + } catch (error) { + if (browserProfileSelect) { + browserProfileSelect.innerHTML = ''; + browserProfileSelect.disabled = true; + } + } + }; + const updateTestFeedback = (message) => { if (!testFeedback) return; if (typeof message === "string" && message.trim().length > 0) { @@ -71,6 +149,14 @@ export function getAddConnectionModalControllerScript(channels: AddConnectionMod usernamePasswordClientId: getInputValue("connection-optional-client-id-up"), usernamePasswordTenantId: getInputValue("connection-tenant-id-up"), connectionString: getInputValue("connection-string-input"), + browserType: getInputValue("connection-browser-type") || "default", + ...(() => { + const selection = getBrowserProfileSelection(); + return { + browserProfile: selection.value, + browserProfileName: selection.name, + }; + })(), }); const setButtonState = (button, isLoading, loadingLabel, defaultLabel) => { @@ -100,6 +186,20 @@ export function getAddConnectionModalControllerScript(channels: AddConnectionMod authTypeSelect?.addEventListener("change", updateAuthVisibility); updateAuthVisibility(); + // Browser type change listener + browserTypeSelect?.addEventListener("change", () => { + loadBrowserProfiles(); + }); + + // Initial load - only load if default browser is selected (to set initial state) + // This ensures the dropdown shows proper initial state + if (browserTypeSelect?.value === "default") { + if (browserProfileSelect) { + browserProfileSelect.disabled = true; + browserProfileSelect.innerHTML = ''; + } + } + addButton?.addEventListener("click", () => { setButtonState(addButton, true, "Adding...", "Add"); modalBridge.send(CHANNELS.submit, collectFormData()); diff --git a/src/renderer/modals/addConnection/view.ts b/src/renderer/modals/addConnection/view.ts index 3a6930a7..045fab89 100644 --- a/src/renderer/modals/addConnection/view.ts +++ b/src/renderer/modals/addConnection/view.ts @@ -47,6 +47,24 @@ export function getAddConnectionModalView(isDarkTheme: boolean): ModalViewTempla +
+ + + +

Choose which browser to use when opening URLs with authentication. Defaults to your system's default browser.

+ + + +

Select a browser profile to use. Profiles will be loaded when you select a browser above.

+
+
+ + + +

Choose which browser to use when opening URLs with authentication. Defaults to your system's default browser.

+ + + +

Select a browser profile to use. Profiles will be loaded when you select a browser above.

+
`; diff --git a/src/renderer/styles.scss b/src/renderer/styles.scss index 1f1f17b5..49079a9f 100644 --- a/src/renderer/styles.scss +++ b/src/renderer/styles.scss @@ -2577,14 +2577,61 @@ body.light-theme .install-button:focus-visible img { .connection-item-footer-pptb { display: flex; + flex-direction: column; justify-content: space-between; - align-items: center; + // align-items: center; + gap: 6px; } .connection-item-meta-left { display: flex; gap: 8px; align-items: center; + margin-top: 2px; +} + +.browser-profile-badge { + display: inline-flex; + align-items: center; + gap: 6px; + // padding: 2px 8px; + // border-radius: 999px; + // border: 1px solid var(--border-color); + background: var(--card-background); + font-size: 11px; + color: var(--text-color); + line-height: 1; +} + +.browser-profile-icon { + width: 14px; + height: 14px; + object-fit: contain; +} + +.browser-profile-icon-fallback { + width: 16px; + height: 16px; + border-radius: 50%; + background: rgba(0, 0, 0, 0.08); + color: var(--text-color); + display: inline-flex; + align-items: center; + justify-content: center; + font-size: 10px; + font-weight: 600; + text-transform: uppercase; +} + +body.dark-theme .browser-profile-icon-fallback { + background: rgba(255, 255, 255, 0.15); +} + +.browser-profile-label { + max-width: 120px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .connection-item-actions-pptb { diff --git a/vite.config.ts b/vite.config.ts index 7f5a40d4..d1ca98bf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -142,6 +142,7 @@ export default defineConfig(({ mode }) => { mkdirSync("dist/renderer/icons", { recursive: true }); mkdirSync("dist/renderer/icons/light", { recursive: true }); mkdirSync("dist/renderer/icons/dark", { recursive: true }); + mkdirSync("dist/renderer/icons/logos", { recursive: true }); } catch (e) { // Directory already exists } @@ -177,6 +178,20 @@ export default defineConfig(({ mode }) => { } catch (e) { console.error(`Failed to copy icons directory:`, e); } + const iconsLogosSourceDir = "src/renderer/icons/logos"; + const iconsLogosTargetDir = "dist/renderer/icons/logos"; + try { + if (existsSync(iconsLogosSourceDir)) { + const iconFiles = readdirSync(iconsLogosSourceDir); + iconFiles.forEach((file: string) => { + const sourcePath = path.join(iconsLogosSourceDir, file); + const targetPath = path.join(iconsLogosTargetDir, file); + copyFileSync(sourcePath, targetPath); + }); + } + } catch (e) { + console.error(`Failed to copy icons directory:`, e); + } // Copy registry.json for fallback when Supabase is not configured const registrySource = "src/main/data/registry.json"; From 9c5f70c900f1b70cd36af37195b22ee3e3fe9ed5 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 21:56:24 -0500 Subject: [PATCH 010/178] Add optional file type filters to saveFile with extension-based auto-derivation (#354) * Initial plan * Add optional filters parameter to saveFile function Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix extension extraction to use path.extname for robust handling Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick --- packages/toolboxAPI.d.ts | 15 ++++++++++++- src/common/types/api.ts | 4 ++-- src/main/index.ts | 4 ++-- src/main/preload.ts | 2 +- src/main/toolPreloadBridge.ts | 2 +- src/main/utilities/filesystem.ts | 38 +++++++++++++++++++++++++------- 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/packages/toolboxAPI.d.ts b/packages/toolboxAPI.d.ts index c9e2a258..ef328439 100644 --- a/packages/toolboxAPI.d.ts +++ b/packages/toolboxAPI.d.ts @@ -262,8 +262,21 @@ declare namespace ToolBoxAPI { /** * Open a save file dialog and write content + * @param defaultPath The suggested file name and path + * @param content The content to save (string or Buffer) + * @param filters Optional file type filters. If not provided, filters are derived from the file extension + * @example + * // Save with custom filters + * await toolboxAPI.fileSystem.saveFile( + * "react-export.json", + * JSON.stringify(data, null, 2), + * [{name: "JSON", extensions: ["json"]}, {name: "Text", extensions: ["txt"]}] + * ); + * + * // Save without filters (auto-derived from extension) + * await toolboxAPI.fileSystem.saveFile("config.xml", xmlContent); */ - saveFile: (defaultPath: string, content: any) => Promise; + saveFile: (defaultPath: string, content: any, filters?: FileDialogFilter[]) => Promise; /** * Open a native dialog to select either a file or a folder and return the chosen path diff --git a/src/common/types/api.ts b/src/common/types/api.ts index 5f535a64..0b332161 100644 --- a/src/common/types/api.ts +++ b/src/common/types/api.ts @@ -3,7 +3,7 @@ * These types define the structure of the toolboxAPI exposed to the renderer */ -import { ModalWindowMessagePayload, ModalWindowOptions, SelectPathOptions, Theme } from "./common"; +import { FileDialogFilter, ModalWindowMessagePayload, ModalWindowOptions, SelectPathOptions, Theme } from "./common"; import { DataverseConnection } from "./connection"; import { DataverseExecuteRequest } from "./dataverse"; import { LastUsedToolEntry, LastUsedToolUpdate, UserSettings } from "./settings"; @@ -51,7 +51,7 @@ export interface FileSystemAPI { readDirectory: (path: string) => Promise>; writeText: (path: string, content: string) => Promise; createDirectory: (path: string) => Promise; - saveFile: (defaultPath: string, content: string | Buffer) => Promise; + saveFile: (defaultPath: string, content: string | Buffer, filters?: FileDialogFilter[]) => Promise; selectPath: (options?: SelectPathOptions) => Promise; } diff --git a/src/main/index.ts b/src/main/index.ts index d0c11ef1..10a46742 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1056,9 +1056,9 @@ class ToolBoxApp { return await createDirectory(dirPath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.SAVE_FILE, async (_, defaultPath: string, content: string | Buffer) => { + ipcMain.handle(FILESYSTEM_CHANNELS.SAVE_FILE, async (_, defaultPath: string, content: string | Buffer, filters?: Array<{ name: string; extensions: string[] }>) => { const { saveFile } = await import("./utilities/filesystem.js"); - return await saveFile(defaultPath, content); + return await saveFile(defaultPath, content, filters); }); ipcMain.handle(FILESYSTEM_CHANNELS.SELECT_PATH, async (_, options) => { diff --git a/src/main/preload.ts b/src/main/preload.ts index bf8b5a36..e4452ea7 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -146,7 +146,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { readDirectory: (path: string) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.READ_DIRECTORY, path), writeText: (path: string, content: string) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.WRITE_TEXT, path, content), createDirectory: (path: string) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.CREATE_DIRECTORY, path), - saveFile: (defaultPath: string, content: unknown) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.SAVE_FILE, defaultPath, content), + saveFile: (defaultPath: string, content: unknown, filters?: Array<{ name: string; extensions: string[] }>) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.SAVE_FILE, defaultPath, content, filters), selectPath: (options?: unknown) => ipcRenderer.invoke(FILESYSTEM_CHANNELS.SELECT_PATH, options), }, diff --git a/src/main/toolPreloadBridge.ts b/src/main/toolPreloadBridge.ts index 611ae17d..626e32d9 100644 --- a/src/main/toolPreloadBridge.ts +++ b/src/main/toolPreloadBridge.ts @@ -221,7 +221,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { readDirectory: (path: string) => ipcInvoke(FILESYSTEM_CHANNELS.READ_DIRECTORY, path), writeText: (path: string, content: string) => ipcInvoke(FILESYSTEM_CHANNELS.WRITE_TEXT, path, content), createDirectory: (path: string) => ipcInvoke(FILESYSTEM_CHANNELS.CREATE_DIRECTORY, path), - saveFile: (defaultPath: string, content: unknown) => ipcInvoke(FILESYSTEM_CHANNELS.SAVE_FILE, defaultPath, content), + saveFile: (defaultPath: string, content: unknown, filters?: Array<{ name: string; extensions: string[] }>) => ipcInvoke(FILESYSTEM_CHANNELS.SAVE_FILE, defaultPath, content, filters), selectPath: (options?: Record) => ipcInvoke(FILESYSTEM_CHANNELS.SELECT_PATH, options), }, diff --git a/src/main/utilities/filesystem.ts b/src/main/utilities/filesystem.ts index 4876085e..fdf20610 100644 --- a/src/main/utilities/filesystem.ts +++ b/src/main/utilities/filesystem.ts @@ -194,16 +194,38 @@ export async function createDirectory(dirPath: string): Promise { * Save file dialog and write content * MOVED FROM utils namespace - no backward compatibility */ -export async function saveFile(defaultPath: string, content: string | Buffer): Promise { +export async function saveFile(defaultPath: string, content: string | Buffer, filters?: Array<{ name: string; extensions: string[] }>): Promise { + // Determine filters to use + let dialogFilters: Array<{ name: string; extensions: string[] }>; + + if (filters && filters.length > 0) { + // Use provided filters + dialogFilters = filters; + } else { + // Try to derive filter from filename extension using path.extname for robust extraction + const ext = path.extname(defaultPath).slice(1).toLowerCase(); // Remove leading dot + if (ext) { + // Create a filter based on the extension + const extensionName = ext.toUpperCase(); + dialogFilters = [ + { name: `${extensionName} Files`, extensions: [ext] }, + { name: "All Files", extensions: ["*"] }, + ]; + } else { + // No extension, use default filters + dialogFilters = [ + { name: "All Files", extensions: ["*"] }, + { name: "Text Files", extensions: ["txt"] }, + { name: "JSON Files", extensions: ["json"] }, + { name: "XML Files", extensions: ["xml"] }, + { name: "CSV Files", extensions: ["csv"] }, + ]; + } + } + const result = await dialog.showSaveDialog({ defaultPath, - filters: [ - { name: "All Files", extensions: ["*"] }, - { name: "Text Files", extensions: ["txt"] }, - { name: "JSON Files", extensions: ["json"] }, - { name: "XML Files", extensions: ["xml"] }, - { name: "CSV Files", extensions: ["csv"] }, - ], + filters: dialogFilters, }); if (result.canceled || !result.filePath) { From 2d65bf8263620708d23e3a6695c28d716ecb0d0d Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:49:18 -0500 Subject: [PATCH 011/178] Signing executables for all platform (#377) * fix: enable recursive file search for notarization in release workflows * feat: add YAML regeneration steps for Windows, Linux, and macOS with correct SHA256 hashes * feat: add repackaging step for portable ZIP with signed EXE in Windows workflows --- .github/workflows/nightly-release.yml | 204 +++++++++++++++++++++++++- .github/workflows/prod-release.yml | 204 +++++++++++++++++++++++++- 2 files changed, 406 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 4bc90156..fb240cd6 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -132,12 +132,117 @@ jobs: certificate-profile-name: ${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }} files-folder: ${{ github.workspace }}/build files-folder-filter: exe,msi - files-folder-recurse: false + files-folder-recurse: true timestamp-rfc3161: http://timestamp.acs.microsoft.com timestamp-digest: SHA256 description: Power Platform ToolBox (Insider) description-url: https://github.com/PowerPlatformToolBox/desktop-app + - name: Repackage portable ZIP with signed EXE (Windows) + if: matrix.os == 'windows-latest' + shell: powershell + run: | + $buildDir = "${{ github.workspace }}/build" + $zipFiles = @(Get-ChildItem "$buildDir/*.zip" -ErrorAction SilentlyContinue) + + if ($zipFiles.Count -eq 0) { + Write-Host "No ZIP artifacts found; skipping repack." + exit 0 + } + + foreach ($zip in $zipFiles) { + Write-Host "Repacking ZIP: $($zip.Name)" + $tempDir = Join-Path $env:RUNNER_TEMP ([Guid]::NewGuid().ToString()) + New-Item -ItemType Directory -Path $tempDir | Out-Null + + Expand-Archive -Path $zip.FullName -DestinationPath $tempDir -Force + + $zipExeFiles = @(Get-ChildItem $tempDir -Recurse -Filter *.exe -ErrorAction SilentlyContinue) + foreach ($zipExe in $zipExeFiles) { + $signedExe = Get-ChildItem $buildDir -Recurse -Filter $zipExe.Name -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($signedExe) { + Copy-Item $signedExe.FullName $zipExe.FullName -Force + Write-Host " Replaced $($zipExe.Name) with signed binary." + } else { + Write-Host " No signed match found for $($zipExe.Name)." + } + } + + Remove-Item $zip.FullName -Force + Compress-Archive -Path (Join-Path $tempDir '*') -DestinationPath $zip.FullName -Force + } + + - name: Regenerate latest.yml with correct SHA256 hashes (Windows) + if: matrix.os == 'windows-latest' + shell: powershell + run: | + $buildDir = "${{ github.workspace }}/build" + $latestYml = Join-Path $buildDir "latest.yml" + + if (Test-Path $latestYml) { + Write-Host "Regenerating latest.yml with correct hashes..." + + # Read the existing YAML to preserve version and other metadata + $ymlContent = Get-Content $latestYml -Raw + + # Extract version from existing YAML + $versionMatch = [regex]::Match($ymlContent, 'version:\s+([^\s]+)') + $version = if ($versionMatch.Success) { $versionMatch.Groups[1].Value } else { "unknown" } + + # Find the main EXE file (look for the installer) + $exeFiles = @(Get-ChildItem "$buildDir/*.exe" -ErrorAction SilentlyContinue) + + if ($exeFiles.Count -gt 0) { + # Sort to get the latest/main installer (NSIS or main app exe) + $mainExe = $exeFiles | Where-Object { $_.Name -match "(NSIS|Setup|Installer)" } | Select-Object -First 1 + if (-not $mainExe) { + $mainExe = $exeFiles[0] # Fallback to first exe + } + + Write-Host "Using EXE: $($mainExe.Name)" + + # Calculate SHA256 hash + $hash = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + $size = $mainExe.Length + + Write-Host "SHA256: $hash" + Write-Host "Size: $size" + + # Create new YAML content with correct hashes + $releaseDate = (Get-Date -u -Format 'yyyy-MM-ddTHH:mm:ss.000Z') + $yml = @{ + version = $version + files = @( + @{ + url = $mainExe.Name + sha512 = $null + sha256 = $hash + size = $size + blockMapSize = $null + } + ) + releaseDate = $releaseDate + } + + $newYmlContent = "version: $version`n" + $newYmlContent += "files:`n" + $newYmlContent += " - url: $($mainExe.Name)`n" + $newYmlContent += " sha512: null`n" + $newYmlContent += " sha256: $hash`n" + $newYmlContent += " size: $size`n" + $newYmlContent += " blockMapSize: null`n" + $newYmlContent += "releaseDate: $releaseDate" + + # Write updated YAML + Set-Content -Path $latestYml -Value $newYmlContent + Write-Host "✅ latest.yml regenerated with correct hashes" + } else { + Write-Host "⚠️ No EXE files found, skipping YAML regeneration" + } + } else { + Write-Host "⚠️ latest.yml not found at $latestYml" + } + - name: Prepare macOS signing certificate if: matrix.os == 'macos-latest' shell: bash @@ -266,6 +371,56 @@ jobs: echo "✅ Quarantine attributes removed" shell: bash + - name: Regenerate latest-linux.yml with correct SHA256 hashes (Linux) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + echo "🔄 Regenerating latest-linux.yml with correct artifact hashes..." + + BUILD_DIR="${{ github.workspace }}/build" + + # Find all YAML files + YML_FILES=$(find "$BUILD_DIR" -name "latest*.yml" -o -name "*-linux.yml") + + if [[ -z "$YML_FILES" ]]; then + echo "⚠️ No YAML files found, skipping regeneration" + exit 0 + fi + + for YML_FILE in $YML_FILES; do + echo "Processing: $YML_FILE" + + # Extract version from existing YAML + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + + # Find the main AppImage file + APP_IMAGE=$(find "$BUILD_DIR" -maxdepth 1 -type f -name "*.AppImage" | head -n 1) + + if [[ -n "$APP_IMAGE" && -f "$APP_IMAGE" ]]; then + echo " Found AppImage: $(basename "$APP_IMAGE")" + + # Calculate SHA256 hash + HASH=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + SIZE=$(stat -c %s "$APP_IMAGE" 2>/dev/null || stat -f %z "$APP_IMAGE" 2>/dev/null) + + echo " SHA256: $HASH" + echo " Size: $SIZE" + + # Create new YAML with correct hashes using printf to avoid YAML parsing issues + printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" \ + "$(basename "$APP_IMAGE")" \ + "$HASH" \ + "$SIZE" \ + "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + echo " ✅ Updated $YML_FILE" + else + echo " ⚠️ No AppImage found in $BUILD_DIR" + fi + done + + echo "✅ Regeneration complete" + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -452,6 +607,53 @@ jobs: exit 1 fi + - name: Regenerate latest-mac.yml with correct SHA256 hashes + shell: bash + run: | + echo "🔄 Regenerating latest-mac.yml with stapled artifact hashes..." + + # Find all YAML files + YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") + + if [[ -z "$YML_FILES" ]]; then + echo "⚠️ No YAML files found, skipping regeneration" + exit 0 + fi + + for YML_FILE in $YML_FILES; do + echo "Processing: $YML_FILE" + + # Extract version from existing YAML + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + + # Find the stapled DMG file in the same directory + DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) + + if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then + echo " Found DMG: $(basename "$DMG_FILE")" + + # Calculate SHA256 hash of the stapled DMG + HASH=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + + echo " SHA256: $HASH" + echo " Size: $SIZE" + + # Create new YAML with correct hashes using printf to avoid YAML parsing issues + printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" \ + "$(basename "$DMG_FILE")" \ + "$HASH" \ + "$SIZE" \ + "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + echo " ✅ Updated $YML_FILE" + else + echo " ⚠️ No DMG found in $(dirname "$YML_FILE")" + fi + done + + echo "✅ Regeneration complete" + - name: Upload stapled macOS artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 2635f252..7dd5ac97 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -136,12 +136,117 @@ jobs: certificate-profile-name: ${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }} files-folder: ${{ github.workspace }}/build files-folder-filter: exe,msi - files-folder-recurse: false + files-folder-recurse: true timestamp-rfc3161: http://timestamp.acs.microsoft.com timestamp-digest: SHA256 description: Power Platform ToolBox description-url: https://github.com/PowerPlatformToolBox/desktop-app + - name: Repackage portable ZIP with signed EXE (Windows) + if: matrix.os == 'windows-latest' + shell: powershell + run: | + $buildDir = "${{ github.workspace }}/build" + $zipFiles = @(Get-ChildItem "$buildDir/*.zip" -ErrorAction SilentlyContinue) + + if ($zipFiles.Count -eq 0) { + Write-Host "No ZIP artifacts found; skipping repack." + exit 0 + } + + foreach ($zip in $zipFiles) { + Write-Host "Repacking ZIP: $($zip.Name)" + $tempDir = Join-Path $env:RUNNER_TEMP ([Guid]::NewGuid().ToString()) + New-Item -ItemType Directory -Path $tempDir | Out-Null + + Expand-Archive -Path $zip.FullName -DestinationPath $tempDir -Force + + $zipExeFiles = @(Get-ChildItem $tempDir -Recurse -Filter *.exe -ErrorAction SilentlyContinue) + foreach ($zipExe in $zipExeFiles) { + $signedExe = Get-ChildItem $buildDir -Recurse -Filter $zipExe.Name -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($signedExe) { + Copy-Item $signedExe.FullName $zipExe.FullName -Force + Write-Host " Replaced $($zipExe.Name) with signed binary." + } else { + Write-Host " No signed match found for $($zipExe.Name)." + } + } + + Remove-Item $zip.FullName -Force + Compress-Archive -Path (Join-Path $tempDir '*') -DestinationPath $zip.FullName -Force + } + + - name: Regenerate latest.yml with correct SHA256 hashes (Windows) + if: matrix.os == 'windows-latest' + shell: powershell + run: | + $buildDir = "${{ github.workspace }}/build" + $latestYml = Join-Path $buildDir "latest.yml" + + if (Test-Path $latestYml) { + Write-Host "Regenerating latest.yml with correct hashes..." + + # Read the existing YAML to preserve version and other metadata + $ymlContent = Get-Content $latestYml -Raw + + # Extract version from existing YAML + $versionMatch = [regex]::Match($ymlContent, 'version:\s+([^\s]+)') + $version = if ($versionMatch.Success) { $versionMatch.Groups[1].Value } else { "unknown" } + + # Find the main EXE file (look for the installer) + $exeFiles = @(Get-ChildItem "$buildDir/*.exe" -ErrorAction SilentlyContinue) + + if ($exeFiles.Count -gt 0) { + # Sort to get the latest/main installer (NSIS or main app exe) + $mainExe = $exeFiles | Where-Object { $_.Name -match "(NSIS|Setup|Installer)" } | Select-Object -First 1 + if (-not $mainExe) { + $mainExe = $exeFiles[0] # Fallback to first exe + } + + Write-Host "Using EXE: $($mainExe.Name)" + + # Calculate SHA256 hash + $hash = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + $size = $mainExe.Length + + Write-Host "SHA256: $hash" + Write-Host "Size: $size" + + # Create new YAML content with correct hashes + $releaseDate = (Get-Date -u -Format 'yyyy-MM-ddTHH:mm:ss.000Z') + $yml = @{ + version = $version + files = @( + @{ + url = $mainExe.Name + sha512 = $null + sha256 = $hash + size = $size + blockMapSize = $null + } + ) + releaseDate = $releaseDate + } + + $newYmlContent = "version: $version`n" + $newYmlContent += "files:`n" + $newYmlContent += " - url: $($mainExe.Name)`n" + $newYmlContent += " sha512: null`n" + $newYmlContent += " sha256: $hash`n" + $newYmlContent += " size: $size`n" + $newYmlContent += " blockMapSize: null`n" + $newYmlContent += "releaseDate: $releaseDate" + + # Write updated YAML + Set-Content -Path $latestYml -Value $newYmlContent + Write-Host "✅ latest.yml regenerated with correct hashes" + } else { + Write-Host "⚠️ No EXE files found, skipping YAML regeneration" + } + } else { + Write-Host "⚠️ latest.yml not found at $latestYml" + } + - name: Prepare macOS signing certificate if: matrix.os == 'macos-latest' shell: bash @@ -270,6 +375,56 @@ jobs: echo "✅ Quarantine attributes removed" shell: bash + - name: Regenerate latest-linux.yml with correct SHA256 hashes (Linux) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + echo "🔄 Regenerating latest-linux.yml with correct artifact hashes..." + + BUILD_DIR="${{ github.workspace }}/build" + + # Find all YAML files + YML_FILES=$(find "$BUILD_DIR" -name "latest*.yml" -o -name "*-linux.yml") + + if [[ -z "$YML_FILES" ]]; then + echo "⚠️ No YAML files found, skipping regeneration" + exit 0 + fi + + for YML_FILE in $YML_FILES; do + echo "Processing: $YML_FILE" + + # Extract version from existing YAML + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + + # Find the main AppImage file + APP_IMAGE=$(find "$BUILD_DIR" -maxdepth 1 -type f -name "*.AppImage" | head -n 1) + + if [[ -n "$APP_IMAGE" && -f "$APP_IMAGE" ]]; then + echo " Found AppImage: $(basename "$APP_IMAGE")" + + # Calculate SHA256 hash + HASH=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + SIZE=$(stat -c %s "$APP_IMAGE" 2>/dev/null || stat -f %z "$APP_IMAGE" 2>/dev/null) + + echo " SHA256: $HASH" + echo " Size: $SIZE" + + # Create new YAML with correct hashes using printf to avoid YAML parsing issues + printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" \ + "$(basename "$APP_IMAGE")" \ + "$HASH" \ + "$SIZE" \ + "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + echo " ✅ Updated $YML_FILE" + else + echo " ⚠️ No AppImage found in $BUILD_DIR" + fi + done + + echo "✅ Regeneration complete" + - name: Upload artifacts (Linux) if: matrix.os == 'ubuntu-latest' uses: actions/upload-artifact@v4 @@ -405,6 +560,53 @@ jobs: exit 1 fi + - name: Regenerate latest-mac.yml with correct SHA256 hashes + shell: bash + run: | + echo "🔄 Regenerating latest-mac.yml with stapled artifact hashes..." + + # Find all YAML files + YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") + + if [[ -z "$YML_FILES" ]]; then + echo "⚠️ No YAML files found, skipping regeneration" + exit 0 + fi + + for YML_FILE in $YML_FILES; do + echo "Processing: $YML_FILE" + + # Extract version from existing YAML + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + + # Find the stapled DMG file in the same directory + DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) + + if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then + echo " Found DMG: $(basename "$DMG_FILE")" + + # Calculate SHA256 hash of the stapled DMG + HASH=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + + echo " SHA256: $HASH" + echo " Size: $SIZE" + + # Create new YAML with correct hashes using printf to avoid YAML parsing issues + printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" \ + "$(basename "$DMG_FILE")" \ + "$HASH" \ + "$SIZE" \ + "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + echo " ✅ Updated $YML_FILE" + else + echo " ⚠️ No DMG found in $(dirname "$YML_FILE")" + fi + done + + echo "✅ Regeneration complete" + - name: Upload stapled macOS artifacts uses: actions/upload-artifact@v4 with: From 83f2c0a585fe0a05135ee6a579f4b81572f9f6fe Mon Sep 17 00:00:00 2001 From: mohsinonxrm Date: Tue, 10 Feb 2026 20:48:14 -0800 Subject: [PATCH 012/178] feat: Added support for Metadata CRUD operations (#356) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Enhance Label structure compliance and add polymorphic lookup support This commit addresses documentation review findings and adds support for polymorphic lookup attributes (Customer/Regarding fields) to complete metadata CRUD operations implementation for issue #319. ## Type Definitions (src/common/types/dataverse.ts) - Added `IsManaged?: boolean` property to LocalizedLabel interface * Microsoft examples show IsManaged included in all attribute/relationship/optionset requests * Properly tracks whether label originates from managed solution - UserLocalizedLabel remains optional in Label interface * Entity creation docs note it as read-only * However, Microsoft's own examples for attributes, relationships, and optionsets include it in POST requests * Implementation follows Microsoft's published examples ## DataverseManager Updates (src/main/managers/dataverseManager.ts) - Updated buildLabel() helper method: * Now creates LocalizedLabel with IsManaged: false property * Includes UserLocalizedLabel property set to same LocalizedLabel instance * Matches Microsoft's published examples for attribute/relationship creation * Example output: { LocalizedLabels: [{ Label: "Text", LanguageCode: 1033, IsManaged: false }], UserLocalizedLabel: { Label: "Text", LanguageCode: 1033, IsManaged: false } } - Added createPolymorphicLookupAttribute() method: * Enables creation of lookup fields that reference multiple entity types (Customer, Regarding scenarios) * Validates presence of non-empty Targets array with entity logical names * Automatically sets AttributeType="Lookup" and AttributeTypeName={ Value: "LookupType" } * Delegates to createAttribute() with proper polymorphic configuration * Returns { AttributeId: string } matching API contract * Comprehensive JSDoc with Customer (account/contact) and custom Regarding examples - Enhanced createRelationship() JSDoc: * Added CascadeConfiguration example with all cascade behaviors (Assign, Delete, Merge, Reparent, Share, Unshare) * Shows proper RemoveLink delete behavior for lookup fields - Enhanced updateRelationship() JSDoc: * Added example demonstrating cascade configuration updates (RemoveLink → Cascade) * Illustrates retrieve-modify-PUT pattern for relationship updates - Added LocalizedLabel to imports from common types ## IPC Infrastructure (src/common/ipc/channels.ts, src/main/index.ts) - Added CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE channel constant * Value: "dataverse.createPolymorphicLookupAttribute" - Registered IPC handler in main process: * Supports both primary and secondary connection targets * Extracts connectionId from WebContents based on connectionTarget parameter * Wraps dataverseManager.createPolymorphicLookupAttribute() with error handling * Proper cleanup with removeHandler() on application quit ## Preload Bridge (src/main/toolPreloadBridge.ts) - Exposed createPolymorphicLookupAttribute in toolboxAPI.dataverse - Exposed createPolymorphicLookupAttribute in window.dataverseAPI - Both accept (entityLogicalName, attributeDefinition, options?, connectionTarget?) parameters - Properly wrapped with ipcInvoke using CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE channel ## Public API Types (packages/dataverseAPI.d.ts) - Added createPolymorphicLookupAttribute method signature to DataverseAPI interface - Comprehensive JSDoc documentation: * Customer lookup example (account/contact on new_order entity) * Multi-entity Regarding example (account/contact/custom entities on new_note) * Documents Targets array requirement * Notes metadata publish requirement * Shows buildLabel() usage in examples - Method signature: (entityLogicalName, attributeDefinition, options?, connectionTarget?) => Promise<{ AttributeId: string }> ## Validation - TypeScript compilation: ✅ No errors - ESLint: ✅ 0 errors (TypeScript version warning acceptable) - All 12 implementation tasks completed - Documentation compliance verified against 5 Microsoft Learn articles ## Microsoft Documentation References - Attribute creation: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-column-definitions-using-web-api - Relationship creation: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-entity-relationships-using-web-api - Option sets: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-optionsets - Polymorphic lookups: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/multitable-lookup - Entity creation: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-entity-definitions-using-web-api Closes #319 metadata CRUD operations (enhancement for polymorphic lookups) * fix: improve metadata CRUD error handling and add comprehensive documentation FIXES (Code Review Issues): 1. **Metadata creation methods now throw descriptive errors on missing headers** - createEntityDefinition, createAttribute, createRelationship, createGlobalOptionSet - Previously returned empty strings silently when OData-EntityId header missing - Now throw explicit errors: "Failed to retrieve MetadataId from response. The OData-EntityId header was missing." - Guides users to identify real issues (network failures, API changes, etc.) 2. **GET_ATTRIBUTE_ODATA_TYPE IPC handler now enforces type safety** - Added runtime enum validation against AttributeMetadataType values - Removed unsafe `as any` cast that bypassed TypeScript's type system - Throws descriptive error listing all valid types when invalid value provided - Example: "Invalid attribute type: 'InvalidType'. Valid types are: String, Integer, Boolean, ..." TECHNICAL DISCOVERY: **Dataverse metadata operations return HTTP 204 No Content with NO response body**: - Standard operations (entity, attribute, relationship, global option set): 204 No Content - Only OData-EntityId header contains the created MetadataId - Empty response body → makeHttpRequest returns `response.data = {}` - Exception: CreateCustomerRelationships action returns 200 OK with JSON body containing AttributeId and RelationshipIds This discovery led to abandoning a proposed "fallback to response body" approach, as responseData["MetadataId"] would always be undefined for metadata operations. DOCUMENTATION IMPROVEMENTS: 1. **execute() method**: Added comprehensive JSDoc with examples for: - CreateCustomerRelationships action (customer lookup creation with 200 OK response) - InsertStatusValue action (status choice column values with StateCode) - UpdateStateValue action (state value metadata updates) - Bound vs unbound actions/functions 2. **queryData() method**: Added examples demonstrating: - Retrieving global option sets by name: `GlobalOptionSetDefinitions(Name='name')` - Retrieving all global option sets with filters - Retrieving by MetadataId 3. **createPolymorphicLookupAttribute()**: Added note about CreateCustomerRelationships alternative 4. **insertOptionValue()**: Added note about InsertStatusValue for status choice columns 5. **createGlobalOptionSet()**: Added retrieval example using queryData() BENEFITS: - **Fail-Fast Approach**: Clear errors replace silent failures, improving debuggability - **Type Safety**: Runtime enum validation prevents invalid API calls - **Complete Coverage**: All metadata operations from Microsoft documentation are supported via existing methods (execute, queryData) - **Developer Guidance**: JSDoc examples show how to use actions like CreateCustomerRelationships, InsertStatusValue, UpdateStateValue - **No New Methods Needed**: Generic execute() and queryData() methods handle all special cases VALIDATION: - ✅ TypeScript compilation passed (pnpm run typecheck) - ✅ Linting passed (pnpm run lint - 0 errors) - ✅ Application builds successfully (pnpm build) - ✅ All 6 file edits applied successfully * feat(dataverse): add whitelist-based header validation for metadata operations Implemented comprehensive security validation for custom headers in metadata operations to prevent header injection attacks and API compliance issues. SECURITY ENHANCEMENTS: - Added validateMetadataHeaders() method with whitelist-based validation - Validates all custom headers against allowed list from Microsoft documentation - Blocks attempts to override protected headers (Authorization, Content-Type, etc.) - Case-insensitive header matching per HTTP specification (RFC 2616) - Detailed error messages showing invalid headers and allowed alternatives ALLOWED CUSTOM HEADERS (per Microsoft Dataverse Web API docs): - MSCRM.SolutionUniqueName: Associates metadata changes with solutions - MSCRM.MergeLabels: Controls label merging behavior (true/false) - Consistency: Forces reading latest version (value: "Strong") - If-Match: Standard HTTP header for optimistic concurrency control - If-None-Match: Standard HTTP header for caching control PROTECTED HEADERS (never allowed in customHeaders): - Authorization, Accept, Content-Type, OData-MaxVersion, OData-Version, Prefer, Content-Length (all controlled by makeHttpRequest) IMPLEMENTATION: - Created ALLOWED_METADATA_HEADERS constant with whitelist (5 headers) - Created PROTECTED_HEADERS constant with blacklist (7 headers) - Integrated validation into buildMetadataHeaders() for automatic coverage - All metadata operations now automatically validated: * createEntityDefinition / updateEntityDefinition * createAttribute / updateAttribute * createRelationship / updateRelationship * createGlobalOptionSet / updateGlobalOptionSet * createPolymorphicLookup BENEFITS: - Prevents header injection attacks and accidental header overrides - Ensures API compliance with Microsoft's documented patterns - Provides clear developer feedback when invalid headers are used - Defense-in-depth validation even for type-safe inputs DOCUMENTATION REFERENCES: Based on thorough review of 6 Microsoft Learn articles covering all metadata operation types (entity, attribute, relationship, option set operations). Changes maintain backward compatibility - all existing code uses valid headers through typed MetadataOperationOptions interface. * fix(types): replace 'any' with MetadataOperationOptions in IPC handlers Improved type safety in metadata operation IPC handlers by replacing all occurrences of 'options?: any' with proper 'options?: MetadataOperationOptions' type annotation. CHANGES: - Added MetadataOperationOptions to type imports from ../common/types - Updated 9 IPC handler signatures to use MetadataOperationOptions: * CREATE_ENTITY_DEFINITION * UPDATE_ENTITY_DEFINITION * CREATE_ATTRIBUTE * UPDATE_ATTRIBUTE * CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE * CREATE_RELATIONSHIP * UPDATE_RELATIONSHIP * CREATE_GLOBAL_OPTION_SET * UPDATE_GLOBAL_OPTION_SET BENEFITS: - Eliminates use of 'any' type, maintaining TypeScript strict mode compliance - Provides IntelliSense and autocomplete for options parameter - Type safety ensures only valid options (solutionUniqueName, mergeLabels, consistencyStrong) can be passed through IPC layer - Consistency with DataverseManager method signatures - Compile-time validation of option properties This change maintains backward compatibility while adding proper type checking for all metadata operation options passed from tools via IPC. * chore: update version to 1.0.19 in package.json * feat(preload): sync metadata CRUD operations with toolPreloadBridge Synchronized preload.ts with toolPreloadBridge.ts to ensure both the main ToolBox UI and tool windows have identical metadata operation APIs available. This maintains API parity and enables future metadata manipulation from the main UI if needed. ADDED METADATA OPERATIONS (22 new methods in dataverse namespace): Metadata Helper Utilities: - buildLabel: Build localized Label objects for metadata operations - getAttributeODataType: Get OData type string for attribute type enums Entity (Table) Metadata CRUD: - createEntityDefinition: Create new entity/table definitions - updateEntityDefinition: Update existing entity definitions (PUT) - deleteEntityDefinition: Delete entity definitions Attribute (Column) Metadata CRUD: - createAttribute: Create new attributes/columns on entities - updateAttribute: Update existing attribute definitions (PUT) - deleteAttribute: Delete attributes from entities - createPolymorphicLookupAttribute: Create multi-table lookup attributes Relationship Metadata CRUD: - createRelationship: Create 1:N, N:N, or polymorphic relationships - updateRelationship: Update existing relationship definitions (PUT) - deleteRelationship: Delete relationships Global Option Set (Choice) Metadata CRUD: - createGlobalOptionSet: Create new global option sets/choices - updateGlobalOptionSet: Update existing global option sets (PUT) - deleteGlobalOptionSet: Delete global option sets Option Value Modification Actions (OData Actions): - insertOptionValue: Insert new option values into option sets - updateOptionValue: Update existing option values (labels, etc.) - deleteOptionValue: Delete option values from option sets - orderOption: Reorder option values within option sets BENEFITS: - API parity between main UI (preload.ts) and tool windows (toolPreloadBridge.ts) - Main ToolBox UI can now perform metadata operations if needed in future - Consistent API surface across all preload contexts - Future-proofing for internal metadata management UI features - All operations support primary/secondary connection targeting IMPLEMENTATION NOTES: - All methods maintain same signatures as toolPreloadBridge.ts - Options parameter uses Record for flexibility - Connection targeting via optional connectionTarget parameter - Validated header whitelisting enforced by DataverseManager layer This synchronization ensures both contexts stay in sync as the metadata API evolves and provides maximum flexibility for future UI enhancements. --------- Co-authored-by: Power-Maverick --- packages/dataverseAPI.d.ts | 640 +++++++++++++++++ packages/package.json | 4 +- src/common/ipc/channels.ts | 25 + src/common/types/dataverse.ts | 87 +++ src/main/index.ts | 347 +++++++++- src/main/managers/dataverseManager.ts | 944 +++++++++++++++++++++++++- src/main/preload.ts | 43 ++ src/main/toolPreloadBridge.ts | 70 ++ 8 files changed, 2155 insertions(+), 5 deletions(-) diff --git a/packages/dataverseAPI.d.ts b/packages/dataverseAPI.d.ts index 6ebfe6fd..26599f5d 100644 --- a/packages/dataverseAPI.d.ts +++ b/packages/dataverseAPI.d.ts @@ -224,6 +224,92 @@ declare namespace DataverseAPI { parameters?: Record; } + /** + * Localized label for metadata display names and descriptions + */ + export interface LocalizedLabel { + "@odata.type"?: "Microsoft.Dynamics.CRM.LocalizedLabel"; + Label: string; + LanguageCode: number; + } + + /** + * Label structure for metadata properties + */ + export interface Label { + "@odata.type"?: "Microsoft.Dynamics.CRM.Label"; + LocalizedLabels: LocalizedLabel[]; + UserLocalizedLabel?: LocalizedLabel; + } + + /** + * Attribute metadata types for Dataverse columns + * Used with getAttributeODataType() to generate full Microsoft.Dynamics.CRM.*AttributeMetadata type strings + */ + export enum AttributeMetadataType { + /** Single-line text field */ + String = "String", + /** Multi-line text field */ + Memo = "Memo", + /** Whole number */ + Integer = "Integer", + /** Big integer (large whole number) */ + BigInt = "BigInt", + /** Decimal number */ + Decimal = "Decimal", + /** Floating point number */ + Double = "Double", + /** Currency field */ + Money = "Money", + /** Yes/No (boolean) field */ + Boolean = "Boolean", + /** Date and time */ + DateTime = "DateTime", + /** Lookup (foreign key reference) */ + Lookup = "Lookup", + /** Choice (option set/picklist) */ + Picklist = "Picklist", + /** Multi-select choice */ + MultiSelectPicklist = "MultiSelectPicklist", + /** State field (active/inactive) */ + State = "State", + /** Status field (status reason) */ + Status = "Status", + /** Owner field */ + Owner = "Owner", + /** Customer field (Account or Contact lookup) */ + Customer = "Customer", + /** File attachment field */ + File = "File", + /** Image field */ + Image = "Image", + /** Unique identifier (GUID) */ + UniqueIdentifier = "UniqueIdentifier", + } + + /** + * Options for metadata CRUD operations + */ + export interface MetadataOperationOptions { + /** + * Associate metadata changes with a specific solution + * Uses MSCRM.SolutionUniqueName header + */ + solutionUniqueName?: string; + + /** + * Preserve existing localized labels during PUT operations + * Uses MSCRM.MergeLabels header (defaults to true for updates) + */ + mergeLabels?: boolean; + + /** + * Force fresh metadata read after create/update operations + * Uses Consistency: Strong header to bypass cache + */ + consistencyStrong?: boolean; + } + /** * Dataverse Web API for CRUD operations, queries, and metadata */ @@ -849,6 +935,560 @@ declare namespace DataverseAPI { * const status = await dataverseAPI.getImportJobStatus(importJobId, 'secondary'); */ getImportJobStatus: (importJobId: string, connectionTarget?: "primary" | "secondary") => Promise>; + + // ======================================== + // Metadata Helper Utilities + // ======================================== + + /** + * Build a Label structure for metadata display names and descriptions + * Helper utility to simplify creating localized labels for metadata operations + * + * @param text - Display text for the label + * @param languageCode - Optional language code (defaults to 1033 for English) + * @returns Label object with properly formatted LocalizedLabels array + * + * @example + * const label = dataverseAPI.buildLabel("Account Name"); + * // Returns: { LocalizedLabels: [{ Label: "Account Name", LanguageCode: 1033 }] } + * + * @example + * // Create label with specific language code + * const frenchLabel = dataverseAPI.buildLabel("Nom du compte", 1036); + */ + buildLabel: (text: string, languageCode?: number) => Label; + + /** + * Get the OData type string for an attribute metadata type + * Converts AttributeMetadataType enum to full Microsoft.Dynamics.CRM type path + * + * @param attributeType - Attribute metadata type enum value + * @returns Full OData type string (e.g., "Microsoft.Dynamics.CRM.StringAttributeMetadata") + * + * @example + * const odataType = dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String); + * // Returns: "Microsoft.Dynamics.CRM.StringAttributeMetadata" + * + * @example + * // Use in attribute definition + * const attributeDef = { + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Integer), + * "SchemaName": "new_priority", + * "DisplayName": dataverseAPI.buildLabel("Priority") + * }; + */ + getAttributeODataType: (attributeType: AttributeMetadataType) => string; + + // ======================================== + // Entity (Table) Metadata CRUD Operations + // ======================================== + + /** + * Create a new entity (table) definition in Dataverse + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param entityDefinition - Entity metadata payload (must include SchemaName, DisplayName, OwnershipType, and at least one Attribute with IsPrimaryName=true) + * @param options - Optional metadata operation options (solution assignment, etc.) + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Object containing the created entity's MetadataId + * + * @example + * // Create a new custom table + * const result = await dataverseAPI.createEntityDefinition({ + * "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata", + * "SchemaName": "new_project", + * "DisplayName": dataverseAPI.buildLabel("Project"), + * "DisplayCollectionName": dataverseAPI.buildLabel("Projects"), + * "Description": dataverseAPI.buildLabel("Project tracking table"), + * "OwnershipType": "UserOwned", + * "HasActivities": true, + * "HasNotes": true, + * "Attributes": [{ + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String), + * "SchemaName": "new_name", + * "RequiredLevel": { "Value": "None" }, + * "MaxLength": 100, + * "FormatName": { "Value": "Text" }, + * "IsPrimaryName": true, + * "DisplayName": dataverseAPI.buildLabel("Project Name"), + * "Description": dataverseAPI.buildLabel("The name of the project") + * }] + * }, { + * solutionUniqueName: "MySolution" + * }); + * + * console.log("Created entity with MetadataId:", result.id); + * + * // IMPORTANT: Publish customizations to make changes active + * await dataverseAPI.publishCustomizations("new_project"); + */ + createEntityDefinition: (entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>; + + /** + * Update an entity (table) definition + * NOTE: Uses PUT method which requires the FULL entity definition (retrieve-modify-PUT pattern) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param entityIdentifier - Entity LogicalName or MetadataId + * @param entityDefinition - Complete entity metadata payload with all properties + * @param options - Optional metadata operation options (mergeLabels defaults to true to preserve translations) + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * // Retrieve-Modify-PUT Pattern for updating entity metadata + * + * // Step 1: Retrieve current entity definition + * const currentDef = await dataverseAPI.getEntityMetadata("new_project", true); + * + * // Step 2: Modify desired properties (must include ALL properties, not just changes) + * currentDef.DisplayName = dataverseAPI.buildLabel("Updated Project Name"); + * currentDef.Description = dataverseAPI.buildLabel("Updated description"); + * + * // Step 3: PUT the entire definition back (mergeLabels=true preserves other language translations) + * await dataverseAPI.updateEntityDefinition("new_project", currentDef, { + * mergeLabels: true, // Preserve existing translations + * solutionUniqueName: "MySolution" + * }); + * + * // Step 4: Publish customizations to activate changes + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Update using MetadataId instead of LogicalName + * await dataverseAPI.updateEntityDefinition( + * "70816501-edb9-4740-a16c-6a5efbc05d84", + * updatedDefinition, + * { mergeLabels: true } + * ); + */ + updateEntityDefinition: (entityIdentifier: string, entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + + /** + * Delete an entity (table) definition + * WARNING: This is a destructive operation that removes the table and all its data + * + * @param entityIdentifier - Entity LogicalName or MetadataId + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * // Delete a custom table (will fail if dependencies exist) + * await dataverseAPI.deleteEntityDefinition("new_project"); + * + * @example + * // Delete using MetadataId + * await dataverseAPI.deleteEntityDefinition("70816501-edb9-4740-a16c-6a5efbc05d84"); + */ + deleteEntityDefinition: (entityIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise; + + // ======================================== + // Attribute (Column) Metadata CRUD Operations + // ======================================== + + /** + * Create a new attribute (column) on an existing entity + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param entityLogicalName - Logical name of the entity to add the attribute to + * @param attributeDefinition - Attribute metadata payload (must include @odata.type, SchemaName, DisplayName) + * @param options - Optional metadata operation options + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Object containing the created attribute's MetadataId + * + * @example + * // Create a text column + * const result = await dataverseAPI.createAttribute("new_project", { + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String), + * "SchemaName": "new_description", + * "DisplayName": dataverseAPI.buildLabel("Description"), + * "Description": dataverseAPI.buildLabel("Project description"), + * "RequiredLevel": { "Value": "None" }, + * "MaxLength": 500, + * "FormatName": { "Value": "Text" } + * }, { + * solutionUniqueName: "MySolution" + * }); + * + * console.log("Created attribute with MetadataId:", result.id); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Create a whole number column + * await dataverseAPI.createAttribute("new_project", { + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Integer), + * "SchemaName": "new_priority", + * "DisplayName": dataverseAPI.buildLabel("Priority"), + * "RequiredLevel": { "Value": "None" }, + * "MinValue": 1, + * "MaxValue": 100 + * }); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Create a choice (picklist) column + * await dataverseAPI.createAttribute("new_project", { + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Picklist), + * "SchemaName": "new_status", + * "DisplayName": dataverseAPI.buildLabel("Status"), + * "RequiredLevel": { "Value": "None" }, + * "OptionSet": { + * "@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata", + * "OptionSetType": "Picklist", + * "Options": [ + * { "Value": 1, "Label": dataverseAPI.buildLabel("Active") }, + * { "Value": 2, "Label": dataverseAPI.buildLabel("On Hold") }, + * { "Value": 3, "Label": dataverseAPI.buildLabel("Completed") } + * ] + * } + * }); + * await dataverseAPI.publishCustomizations("new_project"); + */ + createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>; + + /** + * Update an attribute (column) definition + * NOTE: Uses PUT method which requires the FULL attribute definition (retrieve-modify-PUT pattern) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param entityLogicalName - Logical name of the entity + * @param attributeIdentifier - Attribute LogicalName or MetadataId + * @param attributeDefinition - Complete attribute metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * // Retrieve-Modify-PUT Pattern for updating attribute metadata + * + * // Step 1: Retrieve current attribute definition + * const currentAttr = await dataverseAPI.getEntityRelatedMetadata( + * "new_project", + * "Attributes(LogicalName='new_description')" + * ); + * + * // Step 2: Modify desired properties + * currentAttr.DisplayName = dataverseAPI.buildLabel("Updated Description"); + * currentAttr.MaxLength = 1000; // Increase max length + * + * // Step 3: PUT entire definition back + * await dataverseAPI.updateAttribute( + * "new_project", + * "new_description", + * currentAttr, + * { mergeLabels: true } + * ); + * + * // Step 4: Publish customizations + * await dataverseAPI.publishCustomizations("new_project"); + */ + updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + + /** + * Delete an attribute (column) from an entity + * WARNING: This is a destructive operation that removes the column and all its data + * + * @param entityLogicalName - Logical name of the entity + * @param attributeIdentifier - Attribute LogicalName or MetadataId + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * await dataverseAPI.deleteAttribute("new_project", "new_description"); + * + * @example + * // Delete using MetadataId + * await dataverseAPI.deleteAttribute("new_project", "00aa00aa-bb11-cc22-dd33-44ee44ee44ee"); + */ + deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise; + + /** + * Create a polymorphic lookup attribute (Customer/Regarding field) + * Creates a lookup that can reference multiple entity types + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param entityLogicalName - Logical name of the entity to add the attribute to + * @param attributeDefinition - Lookup attribute metadata with Targets array + * @param options - Optional metadata operation options + * @returns Object containing the created attribute's MetadataId + * @param connectionTarget - Optional connection target ("primary" or "secondary") + * + * @example + * // Create a Customer lookup (Account or Contact) + * const result = await dataverseAPI.createPolymorphicLookupAttribute("new_order", { + * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata", + * "SchemaName": "new_CustomerId", + * "LogicalName": "new_customerid", + * "DisplayName": buildLabel("Customer"), + * "Description": buildLabel("Customer for this order"), + * "RequiredLevel": { Value: "None", CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyrequirementlevelsettings" }, + * "AttributeType": "Lookup", + * "AttributeTypeName": { Value: "LookupType" }, + * "Targets": ["account", "contact"] + * }); + * await dataverseAPI.publishCustomizations(); + */ + createPolymorphicLookupAttribute: ( + entityLogicalName: string, + attributeDefinition: Record, + options?: Record, + connectionTarget?: "primary" | "secondary", + ) => Promise<{ AttributeId: string }>; + + // ======================================== + // Relationship Metadata CRUD Operations + // ======================================== + + /** + * Create a new relationship (1:N or N:N) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param relationshipDefinition - Relationship metadata payload (must include @odata.type for OneToManyRelationshipMetadata or ManyToManyRelationshipMetadata) + * @param options - Optional metadata operation options + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Object containing the created relationship's MetadataId + * + * @example + * // Create 1:N relationship (Project -> Tasks) + * const result = await dataverseAPI.createRelationship({ + * "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata", + * "SchemaName": "new_project_tasks", + * "ReferencedEntity": "new_project", + * "ReferencedAttribute": "new_projectid", + * "ReferencingEntity": "task", + * "CascadeConfiguration": { + * "Assign": "NoCascade", + * "Delete": "RemoveLink", + * "Merge": "NoCascade", + * "Reparent": "NoCascade", + * "Share": "NoCascade", + * "Unshare": "NoCascade" + * }, + * "Lookup": { + * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Lookup), + * "SchemaName": "new_projectid", + * "DisplayName": dataverseAPI.buildLabel("Project"), + * "RequiredLevel": { "Value": "None" } + * } + * }, { + * solutionUniqueName: "MySolution" + * }); + * + * await dataverseAPI.publishCustomizations(); + * + * @example + * // Create N:N relationship (Projects <-> Users) + * await dataverseAPI.createRelationship({ + * "@odata.type": "Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata", + * "SchemaName": "new_project_systemuser", + * "Entity1LogicalName": "new_project", + * "Entity2LogicalName": "systemuser", + * "IntersectEntityName": "new_project_systemuser" + * }); + * await dataverseAPI.publishCustomizations(); + */ + createRelationship: (relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>; + + /** + * Update a relationship definition + * NOTE: Uses PUT method which requires the FULL relationship definition (retrieve-modify-PUT pattern) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param relationshipIdentifier - Relationship SchemaName or MetadataId + * @param relationshipDefinition - Complete relationship metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + */ + updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + + /** + * Delete a relationship + * WARNING: This removes the relationship and any associated lookup columns + * + * @param relationshipIdentifier - Relationship SchemaName or MetadataId + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * await dataverseAPI.deleteRelationship("new_project_tasks"); + */ + deleteRelationship: (relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise; + + // ======================================== + // Global Option Set (Choice) CRUD Operations + // ======================================== + + /** + * Create a new global option set (global choice) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param optionSetDefinition - Global option set metadata payload + * @param options - Optional metadata operation options + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Object containing the created option set's MetadataId + * + * @example + * const result = await dataverseAPI.createGlobalOptionSet({ + * "@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata", + * "Name": "new_projectstatus", + * "DisplayName": dataverseAPI.buildLabel("Project Status"), + * "Description": dataverseAPI.buildLabel("Global choice for project status"), + * "OptionSetType": "Picklist", + * "IsGlobal": true, + * "Options": [ + * { "Value": 1, "Label": dataverseAPI.buildLabel("Active") }, + * { "Value": 2, "Label": dataverseAPI.buildLabel("On Hold") }, + * { "Value": 3, "Label": dataverseAPI.buildLabel("Completed") }, + * { "Value": 4, "Label": dataverseAPI.buildLabel("Cancelled") } + * ] + * }, { + * solutionUniqueName: "MySolution" + * }); + * + * await dataverseAPI.publishCustomizations(); + */ + createGlobalOptionSet: (optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>; + + /** + * Update a global option set definition + * NOTE: Uses PUT method which requires the FULL option set definition (retrieve-modify-PUT pattern) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param optionSetIdentifier - Option set Name or MetadataId + * @param optionSetDefinition - Complete option set metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + */ + updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + + /** + * Delete a global option set + * WARNING: This will fail if any attributes reference this global option set + * + * @param optionSetIdentifier - Option set Name or MetadataId + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * + * @example + * await dataverseAPI.deleteGlobalOptionSet("new_projectstatus"); + */ + deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise; + + // ======================================== + // Option Value Modification Actions + // ======================================== + + /** + * Insert a new option value into a local or global option set + * NOTE: Works for both local option sets (specify EntityLogicalName + AttributeLogicalName) + * and global option sets (specify OptionSetName) + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param params - Parameters for inserting the option value + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Result of the insert operation + * + * @example + * // Insert into local option set on an entity + * await dataverseAPI.insertOptionValue({ + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4, + * Label: dataverseAPI.buildLabel("Critical"), + * Description: dataverseAPI.buildLabel("Highest priority level") + * }); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Insert into global option set + * await dataverseAPI.insertOptionValue({ + * OptionSetName: "new_projectstatus", + * Value: 5, + * Label: dataverseAPI.buildLabel("Archived"), + * SolutionUniqueName: "MySolution" + * }); + * await dataverseAPI.publishCustomizations(); + */ + insertOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => Promise>; + + /** + * Update an existing option value in a local or global option set + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param params - Parameters for updating the option value + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Result of the update operation + * + * @example + * // Update option label in local option set + * await dataverseAPI.updateOptionValue({ + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4, + * Label: dataverseAPI.buildLabel("High Priority"), + * MergeLabels: true // Preserve other language translations + * }); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Update option in global option set + * await dataverseAPI.updateOptionValue({ + * OptionSetName: "new_projectstatus", + * Value: 5, + * Label: dataverseAPI.buildLabel("Closed"), + * MergeLabels: true + * }); + * await dataverseAPI.publishCustomizations(); + */ + updateOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => Promise>; + + /** + * Delete an option value from a local or global option set + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param params - Parameters for deleting the option value + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Result of the delete operation + * + * @example + * // Delete option from local option set + * await dataverseAPI.deleteOptionValue({ + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4 + * }); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Delete option from global option set + * await dataverseAPI.deleteOptionValue({ + * OptionSetName: "new_projectstatus", + * Value: 5 + * }); + * await dataverseAPI.publishCustomizations(); + */ + deleteOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => Promise>; + + /** + * Reorder options in a local or global option set + * NOTE: Metadata changes require explicit publishCustomizations() call to become active + * + * @param params - Parameters for ordering options + * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. + * @returns Result of the order operation + * + * @example + * // Reorder options in local option set + * await dataverseAPI.orderOption({ + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Values: [3, 1, 2, 4] // Reorder by option values + * }); + * await dataverseAPI.publishCustomizations("new_project"); + * + * @example + * // Reorder global option set + * await dataverseAPI.orderOption({ + * OptionSetName: "new_projectstatus", + * Values: [1, 2, 3, 5, 4] + * }); + * await dataverseAPI.publishCustomizations(); + */ + orderOption: (params: Record, connectionTarget?: "primary" | "secondary") => Promise>; } } diff --git a/packages/package.json b/packages/package.json index 6496427e..05edf8a6 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,6 +1,6 @@ { "name": "@pptb/types", - "version": "1.0.19-beta.3", + "version": "1.0.19", "description": "TypeScript type definitions for Power Platform ToolBox API", "main": "index.d.ts", "types": "index.d.ts", @@ -25,4 +25,4 @@ "publish:stable": "pnpm publish --access public --tag latest --no-git-checks", "publish:beta": "pnpm publish --access public --tag beta --no-git-checks" } -} +} \ No newline at end of file diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index c9e34dea..3749a923 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -161,6 +161,31 @@ export const DATAVERSE_CHANNELS = { DISASSOCIATE: "dataverse.disassociate", DEPLOY_SOLUTION: "dataverse.deploySolution", GET_IMPORT_JOB_STATUS: "dataverse.getImportJobStatus", + // Metadata helper utilities + BUILD_LABEL: "dataverse.buildLabel", + GET_ATTRIBUTE_ODATA_TYPE: "dataverse.getAttributeODataType", + // Entity (Table) metadata operations + CREATE_ENTITY_DEFINITION: "dataverse.createEntityDefinition", + UPDATE_ENTITY_DEFINITION: "dataverse.updateEntityDefinition", + DELETE_ENTITY_DEFINITION: "dataverse.deleteEntityDefinition", + // Attribute (Column) metadata operations + CREATE_ATTRIBUTE: "dataverse.createAttribute", + UPDATE_ATTRIBUTE: "dataverse.updateAttribute", + DELETE_ATTRIBUTE: "dataverse.deleteAttribute", + CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE: "dataverse.createPolymorphicLookupAttribute", + // Relationship metadata operations + CREATE_RELATIONSHIP: "dataverse.createRelationship", + UPDATE_RELATIONSHIP: "dataverse.updateRelationship", + DELETE_RELATIONSHIP: "dataverse.deleteRelationship", + // Global option set (choice) metadata operations + CREATE_GLOBAL_OPTION_SET: "dataverse.createGlobalOptionSet", + UPDATE_GLOBAL_OPTION_SET: "dataverse.updateGlobalOptionSet", + DELETE_GLOBAL_OPTION_SET: "dataverse.deleteGlobalOptionSet", + // Option value modification actions + INSERT_OPTION_VALUE: "dataverse.insertOptionValue", + UPDATE_OPTION_VALUE: "dataverse.updateOptionValue", + DELETE_OPTION_VALUE: "dataverse.deleteOptionValue", + ORDER_OPTION: "dataverse.orderOption", } as const; // Event-related IPC channels (from main to renderer) diff --git a/src/common/types/dataverse.ts b/src/common/types/dataverse.ts index c45b6399..974f56f6 100644 --- a/src/common/types/dataverse.ts +++ b/src/common/types/dataverse.ts @@ -78,3 +78,90 @@ export const ENTITY_RELATED_METADATA_BASE_PATHS: ReadonlyArray = P extends EntityRelatedMetadataRecordPath ? Record : { value: Record[] }; + +/** + * Localized label for metadata display names and descriptions + */ +export interface LocalizedLabel { + "@odata.type"?: "Microsoft.Dynamics.CRM.LocalizedLabel"; + Label: string; + LanguageCode: number; + IsManaged?: boolean; +} + +/** + * Label structure for metadata properties + */ +export interface Label { + "@odata.type"?: "Microsoft.Dynamics.CRM.Label"; + LocalizedLabels: LocalizedLabel[]; + UserLocalizedLabel?: LocalizedLabel; +} + +/** + * Attribute metadata types for Dataverse columns + * Maps to Microsoft.Dynamics.CRM.*AttributeMetadata OData types + */ +export enum AttributeMetadataType { + /** Single-line text field */ + String = "String", + /** Multi-line text field */ + Memo = "Memo", + /** Whole number */ + Integer = "Integer", + /** Big integer (large whole number) */ + BigInt = "BigInt", + /** Decimal number */ + Decimal = "Decimal", + /** Floating point number */ + Double = "Double", + /** Currency field */ + Money = "Money", + /** Yes/No (boolean) field */ + Boolean = "Boolean", + /** Date and time */ + DateTime = "DateTime", + /** Lookup (foreign key reference) */ + Lookup = "Lookup", + /** Choice (option set/picklist) */ + Picklist = "Picklist", + /** Multi-select choice */ + MultiSelectPicklist = "MultiSelectPicklist", + /** State field (active/inactive) */ + State = "State", + /** Status field (status reason) */ + Status = "Status", + /** Owner field */ + Owner = "Owner", + /** Customer field (Account or Contact lookup) */ + Customer = "Customer", + /** File attachment field */ + File = "File", + /** Image field */ + Image = "Image", + /** Unique identifier (GUID) */ + UniqueIdentifier = "UniqueIdentifier", +} + +/** + * Options for metadata CRUD operations + */ +export interface MetadataOperationOptions { + /** + * Associate metadata changes with a specific solution + * Uses MSCRM.SolutionUniqueName header + */ + solutionUniqueName?: string; + + /** + * Preserve existing localized labels during PUT operations + * Uses MSCRM.MergeLabels header (defaults to true for updates) + */ + mergeLabels?: boolean; + + /** + * Force fresh metadata read after create/update operations + * Uses Consistency: Strong header to bypass cache + */ + consistencyStrong?: boolean; +} diff --git a/src/main/index.ts b/src/main/index.ts index 10a46742..c86379f2 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -74,7 +74,7 @@ import { UPDATE_CHANNELS, UTIL_CHANNELS, } from "../common/ipc/channels"; -import { EntityRelatedMetadataPath, LastUsedToolEntry, LastUsedToolUpdate, ModalWindowMessagePayload, ModalWindowOptions, ToolBoxEvent } from "../common/types"; +import { AttributeMetadataType, EntityRelatedMetadataPath, LastUsedToolEntry, LastUsedToolUpdate, MetadataOperationOptions, ModalWindowMessagePayload, ModalWindowOptions, ToolBoxEvent } from "../common/types"; import { AuthManager } from "./managers/authManager"; import { AutoUpdateManager } from "./managers/autoUpdateManager"; import { BrowserManager } from "./managers/browserManager"; @@ -397,6 +397,26 @@ class ToolBoxApp { ipcMain.removeHandler(DATAVERSE_CHANNELS.DISASSOCIATE); ipcMain.removeHandler(DATAVERSE_CHANNELS.DEPLOY_SOLUTION); ipcMain.removeHandler(DATAVERSE_CHANNELS.GET_IMPORT_JOB_STATUS); + // Metadata operations + ipcMain.removeHandler(DATAVERSE_CHANNELS.BUILD_LABEL); + ipcMain.removeHandler(DATAVERSE_CHANNELS.GET_ATTRIBUTE_ODATA_TYPE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION); + ipcMain.removeHandler(DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION); + ipcMain.removeHandler(DATAVERSE_CHANNELS.DELETE_ENTITY_DEFINITION); + ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP); + ipcMain.removeHandler(DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP); + ipcMain.removeHandler(DATAVERSE_CHANNELS.DELETE_RELATIONSHIP); + ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET); + ipcMain.removeHandler(DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET); + ipcMain.removeHandler(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET); + ipcMain.removeHandler(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.DELETE_OPTION_VALUE); + ipcMain.removeHandler(DATAVERSE_CHANNELS.ORDER_OPTION); } /** @@ -1501,6 +1521,331 @@ class ToolBoxApp { throw new Error(`Dataverse getImportJobStatus failed: ${(error as Error).message}`); } }); + + // Dataverse Metadata Helper Utilities + ipcMain.handle(DATAVERSE_CHANNELS.BUILD_LABEL, async (event, text: string, languageCode?: number) => { + try { + return this.dataverseManager.buildLabel(text, languageCode); + } catch (error) { + throw new Error(`Build label failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle(DATAVERSE_CHANNELS.GET_ATTRIBUTE_ODATA_TYPE, async (event, attributeType: string) => { + try { + // Validate attributeType is a valid enum value + const validTypes = Object.values(AttributeMetadataType); + if (!validTypes.includes(attributeType as AttributeMetadataType)) { + throw new Error(`Invalid attribute type: "${attributeType}". Valid types are: ${validTypes.join(", ")}`); + } + return this.dataverseManager.getAttributeODataType(attributeType as AttributeMetadataType); + } catch (error) { + throw new Error(`Get attribute OData type failed: ${(error as Error).message}`); + } + }); + + // Entity (Table) Metadata CRUD Operations + ipcMain.handle(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, async (event, entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createEntityDefinition(connectionId, entityDefinition, options); + } catch (error) { + throw new Error(`Create entity definition failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle( + DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION, + async (event, entityIdentifier: string, entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.updateEntityDefinition(connectionId, entityIdentifier, entityDefinition, options); + return { success: true }; + } catch (error) { + throw new Error(`Update entity definition failed: ${(error as Error).message}`); + } + }, + ); + + ipcMain.handle(DATAVERSE_CHANNELS.DELETE_ENTITY_DEFINITION, async (event, entityIdentifier: string, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.deleteEntityDefinition(connectionId, entityIdentifier); + return { success: true }; + } catch (error) { + throw new Error(`Delete entity definition failed: ${(error as Error).message}`); + } + }); + + // Attribute (Column) Metadata CRUD Operations + ipcMain.handle( + DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, + async (event, entityLogicalName: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createAttribute(connectionId, entityLogicalName, attributeDefinition, options); + } catch (error) { + throw new Error(`Create attribute failed: ${(error as Error).message}`); + } + }, + ); + + ipcMain.handle( + DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, + async (event, entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.updateAttribute(connectionId, entityLogicalName, attributeIdentifier, attributeDefinition, options); + return { success: true }; + } catch (error) { + throw new Error(`Update attribute failed: ${(error as Error).message}`); + } + }, + ); + + ipcMain.handle(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, async (event, entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.deleteAttribute(connectionId, entityLogicalName, attributeIdentifier); + return { success: true }; + } catch (error) { + throw new Error(`Delete attribute failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle( + DATAVERSE_CHANNELS.CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE, + async (event, entityLogicalName: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createPolymorphicLookupAttribute(connectionId, entityLogicalName, attributeDefinition, options); + } catch (error) { + throw new Error(`Create polymorphic lookup attribute failed: ${(error as Error).message}`); + } + }, + ); + + // Relationship Metadata CRUD Operations + ipcMain.handle(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, async (event, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createRelationship(connectionId, relationshipDefinition, options); + } catch (error) { + throw new Error(`Create relationship failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle( + DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP, + async (event, relationshipIdentifier: string, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.updateRelationship(connectionId, relationshipIdentifier, relationshipDefinition, options); + return { success: true }; + } catch (error) { + throw new Error(`Update relationship failed: ${(error as Error).message}`); + } + }, + ); + + ipcMain.handle(DATAVERSE_CHANNELS.DELETE_RELATIONSHIP, async (event, relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.deleteRelationship(connectionId, relationshipIdentifier); + return { success: true }; + } catch (error) { + throw new Error(`Delete relationship failed: ${(error as Error).message}`); + } + }); + + // Global Option Set (Choice) CRUD Operations + ipcMain.handle(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, async (event, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createGlobalOptionSet(connectionId, optionSetDefinition, options); + } catch (error) { + throw new Error(`Create global option set failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle( + DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, + async (event, optionSetIdentifier: string, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.updateGlobalOptionSet(connectionId, optionSetIdentifier, optionSetDefinition, options); + return { success: true }; + } catch (error) { + throw new Error(`Update global option set failed: ${(error as Error).message}`); + } + }, + ); + + ipcMain.handle(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, async (event, optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + await this.dataverseManager.deleteGlobalOptionSet(connectionId, optionSetIdentifier); + return { success: true }; + } catch (error) { + throw new Error(`Delete global option set failed: ${(error as Error).message}`); + } + }); + + // Option Value Modification Actions + ipcMain.handle(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE, async (event, params: Record, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.insertOptionValue(connectionId, params); + } catch (error) { + throw new Error(`Insert option value failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE, async (event, params: Record, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.updateOptionValue(connectionId, params); + } catch (error) { + throw new Error(`Update option value failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle(DATAVERSE_CHANNELS.DELETE_OPTION_VALUE, async (event, params: Record, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.deleteOptionValue(connectionId, params); + } catch (error) { + throw new Error(`Delete option value failed: ${(error as Error).message}`); + } + }); + + ipcMain.handle(DATAVERSE_CHANNELS.ORDER_OPTION, async (event, params: Record, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.orderOption(connectionId, params); + } catch (error) { + throw new Error(`Order option failed: ${(error as Error).message}`); + } + }); } /** * Create application menu diff --git a/src/main/managers/dataverseManager.ts b/src/main/managers/dataverseManager.ts index 0f45e2b6..55db107b 100644 --- a/src/main/managers/dataverseManager.ts +++ b/src/main/managers/dataverseManager.ts @@ -1,5 +1,14 @@ import * as https from "https"; -import { DataverseConnection, ENTITY_RELATED_METADATA_BASE_PATHS, EntityRelatedMetadataPath, EntityRelatedMetadataResponse } from "../../common/types"; +import { + DataverseConnection, + ENTITY_RELATED_METADATA_BASE_PATHS, + EntityRelatedMetadataPath, + EntityRelatedMetadataResponse, + AttributeMetadataType, + Label, + LocalizedLabel, + MetadataOperationOptions, +} from "../../common/types"; import { captureMessage } from "../../common/sentryHelper"; import { DATAVERSE_API_VERSION } from "../constants"; import { AuthManager } from "./authManager"; @@ -58,6 +67,116 @@ export class DataverseManager { this.authManager = authManager; } + /** + * Allowed custom headers for metadata operations based on Microsoft Dataverse Web API documentation. + * These headers are validated before being passed to HTTP requests for metadata operations. + * + * Reference documentation: + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/retrieve-metadata-name-metadataid + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-entity-definitions-using-web-api + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-column-definitions-using-web-api + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-entity-relationships-using-web-api + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/multitable-lookup + * - https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/create-update-optionsets + */ + private static readonly ALLOWED_METADATA_HEADERS: ReadonlySet = new Set([ + "mscrm.solutionuniquename", // Associates metadata changes with a specific solution (used in CREATE/UPDATE) + "mscrm.mergelabels", // Controls label merging: "true" (merge) or "false" (replace) in UPDATE operations + "consistency", // Forces reading latest version: "Strong" value (used in GET operations after changes) + "if-match", // Standard HTTP header for optimistic concurrency control + "if-none-match", // Standard HTTP header for caching control (commonly "null" in examples) + ]); + + /** + * Headers that must never be passed as custom headers because they are controlled by makeHttpRequest. + * Attempting to override these headers will result in validation errors. + */ + private static readonly PROTECTED_HEADERS: ReadonlySet = new Set([ + "authorization", + "accept", + "content-type", + "odata-maxversion", + "odata-version", + "prefer", + "content-length", + ]); + + /** + * Validates custom headers for metadata operations against the allowed headers list. + * Case-insensitive matching per HTTP specification (RFC 2616). + * + * @param customHeaders - The custom headers to validate + * @param operationName - Optional name of the operation for more descriptive error messages + * @returns Validated headers object + * @throws Error if any header is not in the allowed list or attempts to override protected headers + * + * @example + * ```typescript + * // Valid headers + * const headers = this.validateMetadataHeaders({ + * "MSCRM.SolutionUniqueName": "examplesolution", + * "MSCRM.MergeLabels": "true" + * }, "updateEntityDefinition"); + * + * // Invalid header - throws error + * this.validateMetadataHeaders({ + * "X-Custom-Header": "value" // Not in allowed list + * }); + * + * // Protected header - throws error + * this.validateMetadataHeaders({ + * "Authorization": "Bearer token" // Protected header + * }); + * ``` + */ + private validateMetadataHeaders(customHeaders: Record | undefined, operationName?: string): Record { + if (!customHeaders || Object.keys(customHeaders).length === 0) { + return {}; + } + + const validatedHeaders: Record = {}; + const invalidHeaders: string[] = []; + const protectedHeaders: string[] = []; + + for (const [headerName, headerValue] of Object.entries(customHeaders)) { + const normalizedHeaderName = headerName.toLowerCase(); + + // Check if attempting to override protected headers + if (DataverseManager.PROTECTED_HEADERS.has(normalizedHeaderName)) { + protectedHeaders.push(headerName); + continue; + } + + // Check if header is in allowed list + if (DataverseManager.ALLOWED_METADATA_HEADERS.has(normalizedHeaderName)) { + validatedHeaders[headerName] = headerValue; + } else { + invalidHeaders.push(headerName); + } + } + + // Build detailed error message if validation failed + if (protectedHeaders.length > 0 || invalidHeaders.length > 0) { + const errorParts: string[] = []; + const operation = operationName ? ` in ${operationName}` : ""; + + if (protectedHeaders.length > 0) { + errorParts.push(`Protected headers cannot be overridden: ${protectedHeaders.join(", ")}`); + } + + if (invalidHeaders.length > 0) { + errorParts.push( + `Invalid headers for metadata operations: ${invalidHeaders.join(", ")}. ` + + `Allowed headers: ${Array.from(DataverseManager.ALLOWED_METADATA_HEADERS).join(", ")}`, + ); + } + + throw new Error(`Header validation failed${operation}. ${errorParts.join(". ")}`); + } + + return validatedHeaders; + } + /** * Build a properly formatted API URL by combining base URL and path * Ensures no double slashes between base URL and path @@ -383,6 +502,94 @@ export class DataverseManager { /** * Execute a Dataverse Web API action or function + * + * This is a generic method that can execute any standard or custom action/function. + * Supports both bound operations (on specific entity records) and unbound operations. + * + * @param connectionId - Connection ID to use + * @param request - Operation request details + * @param request.operationName - Name of the action or function to execute + * @param request.operationType - "action" (POST) or "function" (GET) + * @param request.parameters - Parameters to pass to the operation + * @param request.entityName - (For bound operations) Entity logical name + * @param request.entityId - (For bound operations) Entity record ID + * @returns Response object from the operation + * + * @example + * // CreateCustomerRelationships - Create customer lookup attribute (returns HTTP 200 with body) + * const customerResult = await dataverseManager.execute(connectionId, { + * operationName: "CreateCustomerRelationships", + * operationType: "action", + * parameters: { + * Lookup: { + * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata", + * SchemaName: "new_CustomerId", + * DisplayName: dataverseManager.buildLabel("Customer"), + * RequiredLevel: { Value: "None" }, + * Targets: ["account", "contact"] + * }, + * OneToManyRelationships: [ + * { + * "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata", + * SchemaName: "new_order_customer_account", + * ReferencedEntity: "account", + * ReferencingEntity: "new_order" + * }, + * { + * "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata", + * SchemaName: "new_order_customer_contact", + * ReferencedEntity: "contact", + * ReferencingEntity: "new_order" + * } + * ] + * } + * }); + * // Returns: { AttributeId: "guid", RelationshipIds: ["guid1", "guid2"] } + * + * @example + * // InsertStatusValue - Add status value to status choice column + * await dataverseManager.execute(connectionId, { + * operationName: "InsertStatusValue", + * operationType: "action", + * parameters: { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "statuscode", + * Value: 100000000, + * Label: dataverseManager.buildLabel("Custom Status"), + * StateCode: 0 // Active state + * } + * }); + * + * @example + * // UpdateStateValue - Update state value metadata + * await dataverseManager.execute(connectionId, { + * operationName: "UpdateStateValue", + * operationType: "action", + * parameters: { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "statecode", + * Value: 1, + * Label: dataverseManager.buildLabel("Inactive"), + * DefaultStatus: 2 + * } + * }); + * + * @example + * // Bound action - Execute on specific record + * await dataverseManager.execute(connectionId, { + * entityName: "account", + * entityId: "guid", + * operationName: "CustomAction", + * operationType: "action", + * parameters: { param1: "value" } + * }); + * + * @example + * // Function call - Uses GET with parameters in URL + * const result = await dataverseManager.execute(connectionId, { + * operationName: "WhoAmI", + * operationType: "function" + * }); */ async execute( connectionId: string, @@ -544,7 +751,37 @@ export class DataverseManager { /** * Query data from Dataverse using OData query parameters + * + * This method can query any Dataverse endpoint including entity data, metadata (EntityDefinitions, + * GlobalOptionSetDefinitions, etc.), and system entities. + * + * @param connectionId - Connection ID to use * @param odataQuery - OData query string with parameters like $select, $filter, $orderby, $top, $skip, $expand + * @returns Query result with value array + * + * @example + * // Query entity records + * const accounts = await dataverseManager.queryData(connectionId, + * "accounts?$select=name,accountnumber&$filter=statecode eq 0&$top=10" + * ); + * + * @example + * // Retrieve a global option set by name + * const optionSet = await dataverseManager.queryData(connectionId, + * "GlobalOptionSetDefinitions(Name='new_projectstatus')" + * ); + * + * @example + * // Retrieve all global option sets + * const allOptionSets = await dataverseManager.queryData(connectionId, + * "GlobalOptionSetDefinitions?$select=Name,DisplayName,OptionSetType" + * ); + * + * @example + * // Retrieve global option set by MetadataId + * const optionSetById = await dataverseManager.queryData(connectionId, + * "GlobalOptionSetDefinitions(guid)?$select=Name,Options" + * ); */ async queryData(connectionId: string, odataQuery: string): Promise<{ value: Record[] }> { if (!odataQuery || !odataQuery.trim()) { @@ -569,7 +806,14 @@ export class DataverseManager { /** * Make an HTTP request to Dataverse Web API */ - private makeHttpRequest(url: string, method: string, accessToken: string, body?: Record, preferOptions?: string[]): Promise<{ data: unknown; headers: Record }> { + private makeHttpRequest( + url: string, + method: string, + accessToken: string, + body?: Record, + preferOptions?: string[], + customHeaders?: Record, + ): Promise<{ data: unknown; headers: Record }> { return new Promise((resolve, reject) => { const urlObj = new URL(url); const bodyData = body ? JSON.stringify(body) : undefined; @@ -587,6 +831,8 @@ export class DataverseManager { path: urlObj.pathname + urlObj.search, method: method, headers: { + // Spread custom headers first, then override with required headers to prevent accidental overwrites + ...(customHeaders || {}), Authorization: `Bearer ${accessToken}`, Accept: "application/json", "OData-MaxVersion": "4.0", @@ -1010,4 +1256,698 @@ export class DataverseManager { await this.makeHttpRequest(url, "DELETE", accessToken); } + + // ======================================== + // Metadata Helper Utilities + // ======================================== + + /** + * Build a Label structure for metadata properties + * @param text - Display text for the label + * @param languageCode - Language code (defaults to 1033 for English) + * @returns Label object with LocalizedLabels array + * + * @example + * const label = dataverseManager.buildLabel("Account Name"); + * // Returns: { LocalizedLabels: [{ Label: "Account Name", LanguageCode: 1033, IsManaged: false }], UserLocalizedLabel: { Label: "Account Name", LanguageCode: 1033, IsManaged: false } } + */ + buildLabel(text: string, languageCode: number = 1033): Label { + const localizedLabel: LocalizedLabel = { + "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", + Label: text, + LanguageCode: languageCode, + IsManaged: false, + }; + + return { + "@odata.type": "Microsoft.Dynamics.CRM.Label", + LocalizedLabels: [localizedLabel], + UserLocalizedLabel: localizedLabel, + }; + } + + /** + * Get the OData type string for an attribute metadata type + * @param attributeType - Attribute metadata type enum value + * @returns Full OData type string (e.g., "Microsoft.Dynamics.CRM.StringAttributeMetadata") + * + * @example + * const odataType = dataverseManager.getAttributeODataType(AttributeMetadataType.String); + * // Returns: "Microsoft.Dynamics.CRM.StringAttributeMetadata" + */ + getAttributeODataType(attributeType: AttributeMetadataType): string { + return `Microsoft.Dynamics.CRM.${attributeType}AttributeMetadata`; + } + + /** + * Build custom headers for metadata operations + */ + private buildMetadataHeaders(options?: MetadataOperationOptions): Record { + const headers: Record = {}; + + if (options?.solutionUniqueName) { + headers["MSCRM.SolutionUniqueName"] = options.solutionUniqueName; + } + + if (options?.mergeLabels !== undefined) { + headers["MSCRM.MergeLabels"] = String(options.mergeLabels); + } + + if (options?.consistencyStrong) { + headers["Consistency"] = "Strong"; + } + + // Validate headers against allowed list (defensive programming - ensures type-safe options produce valid headers) + return this.validateMetadataHeaders(headers); + } + + /** + * Detect if a string is a GUID (MetadataId) or a logical name + */ + private isGuid(value: string): boolean { + const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + return guidRegex.test(value); + } + + // ======================================== + // Entity (Table) Metadata CRUD Operations + // ======================================== + + /** + * Create a new entity (table) definition + * @param connectionId - Connection ID to use + * @param entityDefinition - Entity metadata payload (must include SchemaName, DisplayName, OwnershipType, and at least one Attribute with IsPrimaryName=true) + * @param options - Optional metadata operation options + * @returns Object containing the created entity's MetadataId + * + * @example + * const result = await dataverseManager.createEntityDefinition(connectionId, { + * "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata", + * "SchemaName": "new_project", + * "DisplayName": dataverseManager.buildLabel("Project"), + * "OwnershipType": "UserOwned", + * "HasActivities": true, + * "Attributes": [{ + * "@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata", + * "SchemaName": "new_name", + * "IsPrimaryName": true, + * "MaxLength": 100, + * "DisplayName": dataverseManager.buildLabel("Project Name") + * }] + * }, { solutionUniqueName: "MySolution" }); + * + * // Remember to publish customizations after creating metadata + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async createEntityDefinition(connectionId: string, entityDefinition: Record, options?: MetadataOperationOptions): Promise<{ id: string }> { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions`); + const headers = this.buildMetadataHeaders(options); + + const response = await this.makeHttpRequest(url, "POST", accessToken, entityDefinition, undefined, headers); + + // Extract MetadataId from OData-EntityId header + // Metadata operations return 204 No Content with no body, header is the only source + const entityId = response.headers["odata-entityid"]; + if (!entityId) { + throw new Error("Failed to retrieve MetadataId from response. The OData-EntityId header was missing."); + } + return { + id: this.extractIdFromUrl(entityId), + }; + } + + /** + * Update an entity (table) definition + * NOTE: This uses PUT which requires the FULL entity definition (retrieve-modify-PUT pattern) + * @param connectionId - Connection ID to use + * @param entityIdentifier - Entity LogicalName or MetadataId + * @param entityDefinition - Complete entity metadata payload with all properties + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * + * @example + * // Step 1: Retrieve current definition + * const currentDef = await dataverseManager.getEntityMetadata(connectionId, "new_project", true); + * + * // Step 2: Modify desired properties + * currentDef.DisplayName = dataverseManager.buildLabel("Updated Project Name"); + * + * // Step 3: PUT the entire definition back (mergeLabels preserves other language labels) + * await dataverseManager.updateEntityDefinition(connectionId, "new_project", currentDef, { mergeLabels: true }); + * + * // Step 4: Publish customizations + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async updateEntityDefinition(connectionId: string, entityIdentifier: string, entityDefinition: Record, options?: MetadataOperationOptions): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs LogicalName + const isMetadataId = this.isGuid(entityIdentifier); + const identifier = isMetadataId ? entityIdentifier : `LogicalName='${encodeURIComponent(entityIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions(${identifier})`); + + // Default mergeLabels to true for updates to preserve localized labels + const headers = this.buildMetadataHeaders({ + ...options, + mergeLabels: options?.mergeLabels !== undefined ? options.mergeLabels : true, + }); + + await this.makeHttpRequest(url, "PUT", accessToken, entityDefinition, undefined, headers); + } + + /** + * Delete an entity (table) definition + * @param connectionId - Connection ID to use + * @param entityIdentifier - Entity LogicalName or MetadataId + * + * @example + * await dataverseManager.deleteEntityDefinition(connectionId, "new_project"); + */ + async deleteEntityDefinition(connectionId: string, entityIdentifier: string): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs LogicalName + const isMetadataId = this.isGuid(entityIdentifier); + const identifier = isMetadataId ? entityIdentifier : `LogicalName='${encodeURIComponent(entityIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions(${identifier})`); + + await this.makeHttpRequest(url, "DELETE", accessToken); + } + + // ======================================== + // Attribute (Column) Metadata CRUD Operations + // ======================================== + + /** + * Create a new attribute (column) on an existing entity + * @param connectionId - Connection ID to use + * @param entityLogicalName - Logical name of the entity to add the attribute to + * @param attributeDefinition - Attribute metadata payload (must include @odata.type, SchemaName, DisplayName) + * @param options - Optional metadata operation options + * @returns Object containing the created attribute's MetadataId + * + * @example + * const result = await dataverseManager.createAttribute(connectionId, "new_project", { + * "@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata", + * "SchemaName": "new_description", + * "DisplayName": dataverseManager.buildLabel("Description"), + * "MaxLength": 500, + * "FormatName": { "Value": "Text" } + * }, { solutionUniqueName: "MySolution" }); + * + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async createAttribute(connectionId: string, entityLogicalName: string, attributeDefinition: Record, options?: MetadataOperationOptions): Promise<{ id: string }> { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const encodedLogicalName = encodeURIComponent(entityLogicalName); + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions(LogicalName='${encodedLogicalName}')/Attributes`); + const headers = this.buildMetadataHeaders(options); + + const response = await this.makeHttpRequest(url, "POST", accessToken, attributeDefinition, undefined, headers); + + // Extract MetadataId from OData-EntityId header + // Metadata operations return 204 No Content with no body, header is the only source + const entityId = response.headers["odata-entityid"]; + if (!entityId) { + throw new Error("Failed to retrieve attribute MetadataId from response. The OData-EntityId header was missing."); + } + return { + id: this.extractIdFromUrl(entityId), + }; + } + + /** + * Update an attribute (column) definition + * NOTE: This uses PUT which requires the FULL attribute definition (retrieve-modify-PUT pattern) + * @param connectionId - Connection ID to use + * @param entityLogicalName - Logical name of the entity + * @param attributeIdentifier - Attribute LogicalName or MetadataId + * @param attributeDefinition - Complete attribute metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * + * @example + * // Retrieve current attribute definition + * const currentAttr = await dataverseManager.getEntityRelatedMetadata( + * connectionId, "new_project", "Attributes(LogicalName='new_description')" + * ); + * + * // Modify properties + * currentAttr.DisplayName = dataverseManager.buildLabel("Updated Description"); + * + * // PUT entire definition back + * await dataverseManager.updateAttribute(connectionId, "new_project", "new_description", currentAttr, { mergeLabels: true }); + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async updateAttribute( + connectionId: string, + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: MetadataOperationOptions, + ): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const encodedLogicalName = encodeURIComponent(entityLogicalName); + + // Auto-detect MetadataId vs LogicalName + const isMetadataId = this.isGuid(attributeIdentifier); + const identifier = isMetadataId ? attributeIdentifier : `LogicalName='${encodeURIComponent(attributeIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions(LogicalName='${encodedLogicalName}')/Attributes(${identifier})`); + + // Default mergeLabels to true for updates + const headers = this.buildMetadataHeaders({ + ...options, + mergeLabels: options?.mergeLabels !== undefined ? options.mergeLabels : true, + }); + + await this.makeHttpRequest(url, "PUT", accessToken, attributeDefinition, undefined, headers); + } + + /** + * Delete an attribute (column) from an entity + * @param connectionId - Connection ID to use + * @param entityLogicalName - Logical name of the entity + * @param attributeIdentifier - Attribute LogicalName or MetadataId + * + * @example + * await dataverseManager.deleteAttribute(connectionId, "new_project", "new_description"); + */ + async deleteAttribute(connectionId: string, entityLogicalName: string, attributeIdentifier: string): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const encodedLogicalName = encodeURIComponent(entityLogicalName); + + // Auto-detect MetadataId vs LogicalName + const isMetadataId = this.isGuid(attributeIdentifier); + const identifier = isMetadataId ? attributeIdentifier : `LogicalName='${encodeURIComponent(attributeIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/EntityDefinitions(LogicalName='${encodedLogicalName}')/Attributes(${identifier})`); + + await this.makeHttpRequest(url, "DELETE", accessToken); + } + + /** + * Create a polymorphic lookup attribute (Customer/Regarding field) + * Creates a lookup that can reference multiple entity types + * + * NOTE: For customer lookups specifically (account/contact), you can alternatively use the + * CreateCustomerRelationships action via execute() method, which creates both the lookup + * attribute and the relationships in a single operation and returns more detailed response. + * + * @param connectionId - Connection ID to use + * @param entityLogicalName - Logical name of the entity to add the attribute to + * @param attributeDefinition - Lookup attribute metadata with Targets array + * @param options - Optional metadata operation options + * @returns Object containing the created attribute's MetadataId + * + * @example + * // Create a Customer lookup (Account or Contact) + * const result = await dataverseManager.createPolymorphicLookupAttribute(connectionId, "new_order", { + * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata", + * "SchemaName": "new_CustomerId", + * "LogicalName": "new_customerid", + * "DisplayName": dataverseManager.buildLabel("Customer"), + * "Description": dataverseManager.buildLabel("Customer for this order"), + * "RequiredLevel": { Value: "None", CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyrequirementlevelsettings" }, + * "AttributeType": "Lookup", + * "AttributeTypeName": { Value: "LookupType" }, + * "Targets": ["account", "contact"] + * }); + * + * @example + * // Create a Regarding lookup (custom entities) + * const result = await dataverseManager.createPolymorphicLookupAttribute(connectionId, "new_note", { + * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata", + * "SchemaName": "new_RegardingObjectId", + * "LogicalName": "new_regardingobjectid", + * "DisplayName": dataverseManager.buildLabel("Regarding"), + * "Description": dataverseManager.buildLabel("Item this note is about"), + * "RequiredLevel": { Value: "None", CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyrequirementlevelsettings" }, + * "AttributeType": "Lookup", + * "AttributeTypeName": { Value: "LookupType" }, + * "Targets": ["account", "contact", "new_project", "new_task"] + * }, { solutionUniqueName: "MyCustomSolution" }); + */ + async createPolymorphicLookupAttribute( + connectionId: string, + entityLogicalName: string, + attributeDefinition: Record, + options?: MetadataOperationOptions, + ): Promise<{ AttributeId: string }> { + // Validate Targets array is present + if (!attributeDefinition.Targets || !Array.isArray(attributeDefinition.Targets) || attributeDefinition.Targets.length === 0) { + throw new Error("Polymorphic lookup attribute requires a non-empty Targets array with entity logical names"); + } + + // Ensure AttributeType and AttributeTypeName are set correctly + if (!attributeDefinition.AttributeType) { + attributeDefinition.AttributeType = "Lookup"; + } + if (!attributeDefinition.AttributeTypeName) { + attributeDefinition.AttributeTypeName = { Value: "LookupType" }; + } + + // Use the standard createAttribute method (it supports polymorphic lookups) + const result = await this.createAttribute(connectionId, entityLogicalName, attributeDefinition, options); + return { AttributeId: result.id }; + } + + // ======================================== + // Relationship Metadata CRUD Operations + // ======================================== + + /** + * Create a new relationship + * @param connectionId - Connection ID to use + * @param relationshipDefinition - Relationship metadata payload (must include @odata.type for OneToManyRelationshipMetadata or ManyToManyRelationshipMetadata) + * @param options - Optional metadata operation options + * @returns Object containing the created relationship's MetadataId + * + * @example + * // Create 1:N relationship with cascade configuration + * const result = await dataverseManager.createRelationship(connectionId, { + * "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata", + * "SchemaName": "new_project_tasks", + * "ReferencedEntity": "new_project", + * "ReferencedAttribute": "new_projectid", + * "ReferencingEntity": "task", + * "CascadeConfiguration": { + * "Assign": "NoCascade", + * "Delete": "RemoveLink", + * "Merge": "NoCascade", + * "Reparent": "NoCascade", + * "Share": "NoCascade", + * "Unshare": "NoCascade" + * }, + * "Lookup": { + * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata", + * "SchemaName": "new_projectid", + * "DisplayName": dataverseManager.buildLabel("Project") + * } + * }, { solutionUniqueName: "MySolution" }); + * + * await dataverseManager.publishCustomizations(connectionId); + */ + async createRelationship(connectionId: string, relationshipDefinition: Record, options?: MetadataOperationOptions): Promise<{ id: string }> { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/RelationshipDefinitions`); + const headers = this.buildMetadataHeaders(options); + + const response = await this.makeHttpRequest(url, "POST", accessToken, relationshipDefinition, undefined, headers); + + // Extract MetadataId from OData-EntityId header + // Metadata operations return 204 No Content with no body, header is the only source + const entityId = response.headers["odata-entityid"]; + if (!entityId) { + throw new Error("Failed to retrieve relationship MetadataId from response. The OData-EntityId header was missing."); + } + return { + id: this.extractIdFromUrl(entityId), + }; + } + + /** + * Update a relationship definition + * NOTE: This uses PUT which requires the FULL relationship definition (retrieve-modify-PUT pattern) + * @param connectionId - Connection ID to use + * @param relationshipIdentifier - Relationship SchemaName or MetadataId + * @param relationshipDefinition - Complete relationship metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + * + * @example + * // Update cascade configuration on existing relationship + * const existingRel = await dataverseManager.getRelationship(connectionId, "new_project_tasks"); + * existingRel.CascadeConfiguration = { + * "Assign": "NoCascade", + * "Delete": "Cascade", // Changed from RemoveLink to Cascade + * "Merge": "NoCascade", + * "Reparent": "NoCascade", + * "Share": "NoCascade", + * "Unshare": "NoCascade" + * }; + * await dataverseManager.updateRelationship(connectionId, "new_project_tasks", existingRel); + */ + async updateRelationship(connectionId: string, relationshipIdentifier: string, relationshipDefinition: Record, options?: MetadataOperationOptions): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs SchemaName + const isMetadataId = this.isGuid(relationshipIdentifier); + const identifier = isMetadataId ? relationshipIdentifier : `SchemaName='${encodeURIComponent(relationshipIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/RelationshipDefinitions(${identifier})`); + + const headers = this.buildMetadataHeaders({ + ...options, + mergeLabels: options?.mergeLabels !== undefined ? options.mergeLabels : true, + }); + + await this.makeHttpRequest(url, "PUT", accessToken, relationshipDefinition, undefined, headers); + } + + /** + * Delete a relationship + * @param connectionId - Connection ID to use + * @param relationshipIdentifier - Relationship SchemaName or MetadataId + */ + async deleteRelationship(connectionId: string, relationshipIdentifier: string): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs SchemaName + const isMetadataId = this.isGuid(relationshipIdentifier); + const identifier = isMetadataId ? relationshipIdentifier : `SchemaName='${encodeURIComponent(relationshipIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/RelationshipDefinitions(${identifier})`); + + await this.makeHttpRequest(url, "DELETE", accessToken); + } + + // ======================================== + // Global Option Set (Choice) CRUD Operations + // ======================================== + + /** + * Create a new global option set (choice) + * + * NOTE: To retrieve global option sets after creation, use queryData() method with + * "GlobalOptionSetDefinitions" endpoint or use getEntityRelatedMetadata() for options + * associated with specific entities. + * + * @param connectionId - Connection ID to use + * @param optionSetDefinition - Global option set metadata payload + * @param options - Optional metadata operation options + * @returns Object containing the created option set's MetadataId + * + * @example + * const result = await dataverseManager.createGlobalOptionSet(connectionId, { + * "@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata", + * "Name": "new_projectstatus", + * "DisplayName": dataverseManager.buildLabel("Project Status"), + * "OptionSetType": "Picklist", + * "Options": [ + * { "Value": 1, "Label": dataverseManager.buildLabel("Active") }, + * { "Value": 2, "Label": dataverseManager.buildLabel("On Hold") }, + * { "Value": 3, "Label": dataverseManager.buildLabel("Completed") } + * ] + * }, { solutionUniqueName: "MySolution" }); + * + * await dataverseManager.publishCustomizations(connectionId); + * + * // Retrieve the created option set + * const optionSet = await dataverseManager.queryData(connectionId, + * "GlobalOptionSetDefinitions(Name='new_projectstatus')" + * ); + */ + async createGlobalOptionSet(connectionId: string, optionSetDefinition: Record, options?: MetadataOperationOptions): Promise<{ id: string }> { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/GlobalOptionSetDefinitions`); + const headers = this.buildMetadataHeaders(options); + + const response = await this.makeHttpRequest(url, "POST", accessToken, optionSetDefinition, undefined, headers); + + // Extract MetadataId from OData-EntityId header + // Metadata operations return 204 No Content with no body, header is the only source + const entityId = response.headers["odata-entityid"]; + if (!entityId) { + throw new Error("Failed to retrieve global option set MetadataId from response. The OData-EntityId header was missing."); + } + return { + id: this.extractIdFromUrl(entityId), + }; + } + + /** + * Update a global option set definition + * NOTE: This uses PUT which requires the FULL option set definition (retrieve-modify-PUT pattern) + * @param connectionId - Connection ID to use + * @param optionSetIdentifier - Option set Name or MetadataId + * @param optionSetDefinition - Complete option set metadata payload + * @param options - Optional metadata operation options (mergeLabels defaults to true) + */ + async updateGlobalOptionSet(connectionId: string, optionSetIdentifier: string, optionSetDefinition: Record, options?: MetadataOperationOptions): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs Name + const isMetadataId = this.isGuid(optionSetIdentifier); + const identifier = isMetadataId ? optionSetIdentifier : `Name='${encodeURIComponent(optionSetIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/GlobalOptionSetDefinitions(${identifier})`); + + const headers = this.buildMetadataHeaders({ + ...options, + mergeLabels: options?.mergeLabels !== undefined ? options.mergeLabels : true, + }); + + await this.makeHttpRequest(url, "PUT", accessToken, optionSetDefinition, undefined, headers); + } + + /** + * Delete a global option set + * @param connectionId - Connection ID to use + * @param optionSetIdentifier - Option set Name or MetadataId + */ + async deleteGlobalOptionSet(connectionId: string, optionSetIdentifier: string): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + + // Auto-detect MetadataId vs Name + const isMetadataId = this.isGuid(optionSetIdentifier); + const identifier = isMetadataId ? optionSetIdentifier : `Name='${encodeURIComponent(optionSetIdentifier)}'`; + + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/GlobalOptionSetDefinitions(${identifier})`); + + await this.makeHttpRequest(url, "DELETE", accessToken); + } + + // ======================================== + // Option Value Modification Actions + // ======================================== + + /** + * Insert a new option value into a local or global option set + * + * NOTE: This method is for standard choice columns. For Status choice columns (statuscode), + * use the InsertStatusValue action via execute() method instead, which requires additional + * StateCode parameter to associate the status with a state. + * + * Works for both local option sets (specify EntityLogicalName + AttributeLogicalName) + * and global option sets (specify OptionSetName). + * + * @param connectionId - Connection ID to use + * @param params - Parameters for inserting the option value + * @param params.Value - Integer value for the option + * @param params.Label - Label for the option + * @param params.EntityLogicalName - (For local option sets) Entity logical name + * @param params.AttributeLogicalName - (For local option sets) Attribute logical name + * @param params.OptionSetName - (For global option sets) Option set name + * @param params.SolutionUniqueName - Optional solution unique name + * @returns Object containing the new option value + * + * @example + * // Insert into local option set + * await dataverseManager.insertOptionValue(connectionId, { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4, + * Label: dataverseManager.buildLabel("Critical") + * }); + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + * + * @example + * // Insert into global option set + * await dataverseManager.insertOptionValue(connectionId, { + * OptionSetName: "new_projectstatus", + * Value: 4, + * Label: dataverseManager.buildLabel("Cancelled") + * }); + * await dataverseManager.publishCustomizations(connectionId); + */ + async insertOptionValue(connectionId: string, params: Record): Promise> { + return await this.execute(connectionId, { + operationName: "InsertOptionValue", + operationType: "action", + parameters: params, + }); + } + + /** + * Update an existing option value in a local or global option set + * + * @param connectionId - Connection ID to use + * @param params - Parameters for updating the option value + * @param params.Value - Integer value of the option to update + * @param params.Label - New label for the option + * @param params.EntityLogicalName - (For local option sets) Entity logical name + * @param params.AttributeLogicalName - (For local option sets) Attribute logical name + * @param params.OptionSetName - (For global option sets) Option set name + * @param params.MergeLabels - Optional boolean to merge labels (defaults to false) + * + * @example + * await dataverseManager.updateOptionValue(connectionId, { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4, + * Label: buildLabel("High Priority"), + * MergeLabels: true + * }); + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async updateOptionValue(connectionId: string, params: Record): Promise> { + return await this.execute(connectionId, { + operationName: "UpdateOptionValue", + operationType: "action", + parameters: params, + }); + } + + /** + * Delete an option value from a local or global option set + * + * @param connectionId - Connection ID to use + * @param params - Parameters for deleting the option value + * @param params.Value - Integer value of the option to delete + * @param params.EntityLogicalName - (For local option sets) Entity logical name + * @param params.AttributeLogicalName - (For local option sets) Attribute logical name + * @param params.OptionSetName - (For global option sets) Option set name + * + * @example + * await dataverseManager.deleteOptionValue(connectionId, { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Value: 4 + * }); + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async deleteOptionValue(connectionId: string, params: Record): Promise> { + return await this.execute(connectionId, { + operationName: "DeleteOptionValue", + operationType: "action", + parameters: params, + }); + } + + /** + * Reorder options in a local or global option set + * + * @param connectionId - Connection ID to use + * @param params - Parameters for ordering options + * @param params.Values - Array of option values in desired order + * @param params.EntityLogicalName - (For local option sets) Entity logical name + * @param params.AttributeLogicalName - (For local option sets) Attribute logical name + * @param params.OptionSetName - (For global option sets) Option set name + * + * @example + * await dataverseManager.orderOption(connectionId, { + * EntityLogicalName: "new_project", + * AttributeLogicalName: "new_priority", + * Values: [3, 1, 2, 4] // Reorder options by value + * }); + * await dataverseManager.publishCustomizations(connectionId, "new_project"); + */ + async orderOption(connectionId: string, params: Record): Promise> { + return await this.execute(connectionId, { + operationName: "OrderOption", + operationType: "action", + parameters: params, + }); + } } diff --git a/src/main/preload.ts b/src/main/preload.ts index e4452ea7..1b17ac71 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -274,6 +274,49 @@ contextBridge.exposeInMainWorld("toolboxAPI", { connectionTarget?: "primary" | "secondary", ) => ipcRenderer.invoke(DATAVERSE_CHANNELS.DEPLOY_SOLUTION, base64SolutionContent, options, connectionTarget), getImportJobStatus: (importJobId: string, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.GET_IMPORT_JOB_STATUS, importJobId, connectionTarget), + // Metadata helper utilities + buildLabel: (text: string, languageCode?: number) => ipcRenderer.invoke(DATAVERSE_CHANNELS.BUILD_LABEL, text, languageCode), + getAttributeODataType: (attributeType: string) => ipcRenderer.invoke(DATAVERSE_CHANNELS.GET_ATTRIBUTE_ODATA_TYPE, attributeType), + // Entity (Table) metadata operations + createEntityDefinition: (entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, entityDefinition, options, connectionTarget), + updateEntityDefinition: (entityIdentifier: string, entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION, entityIdentifier, entityDefinition, options, connectionTarget), + deleteEntityDefinition: (entityIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.DELETE_ENTITY_DEFINITION, entityIdentifier, connectionTarget), + // Attribute (Column) metadata operations + createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + updateAttribute: ( + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: Record, + connectionTarget?: "primary" | "secondary", + ) => ipcRenderer.invoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), + deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, entityLogicalName, attributeIdentifier, connectionTarget), + createPolymorphicLookupAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + // Relationship metadata operations + createRelationship: (relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, relationshipDefinition, options, connectionTarget), + updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP, relationshipIdentifier, relationshipDefinition, options, connectionTarget), + deleteRelationship: (relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.DELETE_RELATIONSHIP, relationshipIdentifier, connectionTarget), + // Global option set (choice) metadata operations + createGlobalOptionSet: (optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, optionSetDefinition, options, connectionTarget), + updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, optionSetIdentifier, optionSetDefinition, options, connectionTarget), + deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcRenderer.invoke(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, optionSetIdentifier, connectionTarget), + // Option value modification actions + insertOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE, params, connectionTarget), + updateOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE, params, connectionTarget), + deleteOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.DELETE_OPTION_VALUE, params, connectionTarget), + orderOption: (params: Record, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.ORDER_OPTION, params, connectionTarget), }, }); diff --git a/src/main/toolPreloadBridge.ts b/src/main/toolPreloadBridge.ts index 626e32d9..c121b602 100644 --- a/src/main/toolPreloadBridge.ts +++ b/src/main/toolPreloadBridge.ts @@ -196,6 +196,41 @@ contextBridge.exposeInMainWorld("toolboxAPI", { connectionTarget?: "primary" | "secondary", ) => ipcInvoke(DATAVERSE_CHANNELS.DEPLOY_SOLUTION, base64SolutionContent, options, connectionTarget), getImportJobStatus: (importJobId: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_IMPORT_JOB_STATUS, importJobId, connectionTarget), + // Metadata helper utilities + buildLabel: (text: string, languageCode?: number) => ipcInvoke(DATAVERSE_CHANNELS.BUILD_LABEL, text, languageCode), + getAttributeODataType: (attributeType: string) => ipcInvoke(DATAVERSE_CHANNELS.GET_ATTRIBUTE_ODATA_TYPE, attributeType), + // Entity (Table) metadata operations + createEntityDefinition: (entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, entityDefinition, options, connectionTarget), + updateEntityDefinition: (entityIdentifier: string, entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION, entityIdentifier, entityDefinition, options, connectionTarget), + deleteEntityDefinition: (entityIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_ENTITY_DEFINITION, entityIdentifier, connectionTarget), + // Attribute (Column) metadata operations + createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), + deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, entityLogicalName, attributeIdentifier, connectionTarget), + createPolymorphicLookupAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + // Relationship metadata operations + createRelationship: (relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, relationshipDefinition, options, connectionTarget), + updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP, relationshipIdentifier, relationshipDefinition, options, connectionTarget), + deleteRelationship: (relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_RELATIONSHIP, relationshipIdentifier, connectionTarget), + // Global option set (choice) metadata operations + createGlobalOptionSet: (optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, optionSetDefinition, options, connectionTarget), + updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, optionSetIdentifier, optionSetDefinition, options, connectionTarget), + deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, optionSetIdentifier, connectionTarget), + // Option value modification actions + insertOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE, params, connectionTarget), + updateOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE, params, connectionTarget), + deleteOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_OPTION_VALUE, params, connectionTarget), + orderOption: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.ORDER_OPTION, params, connectionTarget), }, // Utils API @@ -317,6 +352,41 @@ contextBridge.exposeInMainWorld("dataverseAPI", { connectionTarget?: "primary" | "secondary", ) => ipcInvoke(DATAVERSE_CHANNELS.DEPLOY_SOLUTION, base64SolutionContent, options, connectionTarget), getImportJobStatus: (importJobId: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_IMPORT_JOB_STATUS, importJobId, connectionTarget), + // Metadata helper utilities + buildLabel: (text: string, languageCode?: number) => ipcInvoke(DATAVERSE_CHANNELS.BUILD_LABEL, text, languageCode), + getAttributeODataType: (attributeType: string) => ipcInvoke(DATAVERSE_CHANNELS.GET_ATTRIBUTE_ODATA_TYPE, attributeType), + // Entity (Table) metadata operations + createEntityDefinition: (entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, entityDefinition, options, connectionTarget), + updateEntityDefinition: (entityIdentifier: string, entityDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION, entityIdentifier, entityDefinition, options, connectionTarget), + deleteEntityDefinition: (entityIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_ENTITY_DEFINITION, entityIdentifier, connectionTarget), + // Attribute (Column) metadata operations + createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), + deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, entityLogicalName, attributeIdentifier, connectionTarget), + createPolymorphicLookupAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_POLYMORPHIC_LOOKUP_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), + // Relationship metadata operations + createRelationship: (relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, relationshipDefinition, options, connectionTarget), + updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP, relationshipIdentifier, relationshipDefinition, options, connectionTarget), + deleteRelationship: (relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_RELATIONSHIP, relationshipIdentifier, connectionTarget), + // Global option set (choice) metadata operations + createGlobalOptionSet: (optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, optionSetDefinition, options, connectionTarget), + updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, optionSetIdentifier, optionSetDefinition, options, connectionTarget), + deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, optionSetIdentifier, connectionTarget), + // Option value modification actions + insertOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE, params, connectionTarget), + updateOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE, params, connectionTarget), + deleteOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_OPTION_VALUE, params, connectionTarget), + orderOption: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.ORDER_OPTION, params, connectionTarget), }); logInfo("[ToolPreloadBridge] Initialized - toolboxAPI and dataverseAPI exposed"); From e05dd2e309b8601b36af18ca6e7bc43ad2f75d53 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:02:40 -0500 Subject: [PATCH 013/178] Fix loading overlay positioning and add manual dismiss button (#379) * Initial plan * Fix loading screen to only block tool panel, not entire window Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Address code review: Fix listener leak and simplify null coalescing Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix IPC listener cleanup: use ipcMain.on instead of once Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix loading overlay bounds calculation and add close button - Get bounds directly from active tool BrowserView instead of renderer - Add getActiveToolBounds() method to ToolWindowManager - Remove rounded corners from overlay container - Add close button to manually dismiss loading overlay - Make overlay window focusable and closable Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Improve close button accessibility and contrast - Add aria-label for screen reader support - Increase background opacity for better contrast (0.1 -> 0.15) - Add visible focus indicator with blue border and shadow - Improve border visibility (0.2 -> 0.3 opacity) Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix overlay positioning and explicitly remove all rounded corners - Use content bounds (screen coordinates) instead of incorrectly adding window bounds to BrowserView bounds - Explicitly set border-radius:0 on overlay-container and close-button - BrowserView bounds are content-relative, overlay BrowserWindow needs screen coordinates Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Address code review feedback: fix shutdown handling, HTML escaping, and error telemetry - Add isMainWindowClosing flag to allow overlay to close during app shutdown - Escape HTML in loading message to prevent injection attacks - Improve error handling with captureException and full context (activeToolId, tags) - Properly destroy overlay window in cleanup - Add close listener on main window to set shutdown flag Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Refine code review fixes: use specific listener reference and clarify HTML escaping - Store closeHandler reference to remove specific listener (not all listeners) - Add comment explaining critical order of HTML entity replacements - Prevent potential issues with removeAllListeners affecting other code Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Polish destroy logic for better clarity and consistency - Move overlayWindow null assignment inside if block for logical consistency - Set closeHandler to null after cleanup for better flow - Clearer separation of window cleanup vs handler cleanup Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --- src/main/index.ts | 29 ++++- .../managers/loadingOverlayWindowManager.ts | 113 +++++++++++++++--- src/main/managers/toolWindowManager.ts | 35 +++++- 3 files changed, 153 insertions(+), 24 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index c86379f2..fcc76400 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -964,10 +964,31 @@ class ToolBoxApp { this.api.copyToClipboard(text); }); - // Show loading handler (overlay window above BrowserViews) - ipcMain.handle(UTIL_CHANNELS.SHOW_LOADING, (_, message: string) => { - if (this.loadingOverlayWindowManager) { - this.loadingOverlayWindowManager.show(message || "Loading..."); + // Show loading handler (overlay window above tool panel area only) + ipcMain.handle(UTIL_CHANNELS.SHOW_LOADING, async (_, message: string) => { + if (this.loadingOverlayWindowManager && this.mainWindow) { + try { + // Get bounds from the active tool's BrowserView directly + const bounds = this.toolWindowManager?.getActiveToolBounds() || undefined; + + // Show overlay with tool panel bounds (or undefined for full window fallback) + this.loadingOverlayWindowManager.show(message || "Loading...", bounds); + } catch (error) { + // Capture bounds retrieval failure for diagnostics, then fall back to full window overlay + captureException(error instanceof Error ? error : new Error(String(error)), { + extra: { + source: "UTIL_CHANNELS.SHOW_LOADING", + context: "Failed to compute active tool bounds for loading overlay; falling back to full-window overlay.", + hasLoadingOverlayWindowManager: !!this.loadingOverlayWindowManager, + hasMainWindow: !!this.mainWindow, + hasToolWindowManager: !!this.toolWindowManager, + activeToolId: this.toolWindowManager?.getActiveToolId() || null, + message, + }, + }); + // On error, show without bounds (full window fallback) + this.loadingOverlayWindowManager.show(message || "Loading..."); + } } else if (this.mainWindow) { // Fallback to legacy in-DOM loading screen if manager not ready this.mainWindow.webContents.send(EVENT_CHANNELS.SHOW_LOADING_SCREEN, message || "Loading..."); diff --git a/src/main/managers/loadingOverlayWindowManager.ts b/src/main/managers/loadingOverlayWindowManager.ts index acfa3cb7..dd098dd8 100644 --- a/src/main/managers/loadingOverlayWindowManager.ts +++ b/src/main/managers/loadingOverlayWindowManager.ts @@ -4,14 +4,20 @@ import { BrowserWindow } from "electron"; * LoadingOverlayWindowManager * * Provides a frameless, transparent, always-on-top window that displays a centered - * loading spinner and message. This window sits above any BrowserView instances, - * solving the issue where an in-DOM loading screen would be obscured by the tool BrowserView. + * loading spinner and message. This window sits above the tool panel area (not the entire window), + * allowing users to still interact with the sidebar, toolbar, and close buttons. + * This solves two issues: + * 1. An in-DOM loading screen would be obscured by the tool BrowserView + * 2. A full-window overlay would block all app interaction, preventing users from closing tools or the app */ export class LoadingOverlayWindowManager { private overlayWindow: BrowserWindow | null = null; private mainWindow: BrowserWindow; private visible = false; private currentMessage = "Loading..."; + private currentBounds: { x: number; y: number; width: number; height: number } | null = null; + private isMainWindowClosing = false; + private closeHandler: ((e: Electron.Event) => void) | null = null; constructor(mainWindow: BrowserWindow) { this.mainWindow = mainWindow; @@ -34,8 +40,8 @@ export class LoadingOverlayWindowManager { movable: false, minimizable: false, maximizable: false, - closable: false, - focusable: false, + closable: true, + focusable: true, show: false, hasShadow: false, backgroundColor: "#00000000", @@ -46,21 +52,48 @@ export class LoadingOverlayWindowManager { }, }); this.overlayWindow.setParentWindow(this.mainWindow); + + // Handle close button click - hide the overlay instead of destroying it + // Allow close during app shutdown to prevent blocking quit + this.closeHandler = (e: Electron.Event) => { + if (!this.isMainWindowClosing) { + e.preventDefault(); + this.hide(); + } + // Otherwise allow close to proceed during shutdown + }; + this.overlayWindow.on("close", this.closeHandler); + this.reloadContent(); this.updateWindowBounds(); } - /** Resize & reposition to cover the main window client area */ + /** Resize & reposition to cover the tool panel area (or entire window as fallback) */ private updateWindowBounds(): void { if (!this.overlayWindow) return; - const bounds = this.mainWindow.getBounds(); - // Cover entire window - this.overlayWindow.setBounds({ - x: bounds.x, - y: bounds.y, - width: bounds.width, - height: bounds.height, - }); + + if (this.currentBounds) { + // BrowserView bounds are relative to window content area (x, y from top-left of content) + // We need to convert to screen coordinates for the overlay BrowserWindow + const contentBounds = this.mainWindow.getContentBounds(); + + // Position overlay in screen coordinates + this.overlayWindow.setBounds({ + x: contentBounds.x + this.currentBounds.x, + y: contentBounds.y + this.currentBounds.y, + width: this.currentBounds.width, + height: this.currentBounds.height, + }); + } else { + // Fallback: cover entire window (legacy behavior) + const bounds = this.mainWindow.getBounds(); + this.overlayWindow.setBounds({ + x: bounds.x, + y: bounds.y, + width: bounds.width, + height: bounds.height, + }); + } } /** Rebuild the HTML with current message */ @@ -72,26 +105,56 @@ export class LoadingOverlayWindowManager { /** Generate overlay HTML */ private generateHTML(message: string): string { + // Escape message to prevent HTML/script injection + const escapedMessage = this.escapeHtml(message); + return ` -
${message}
+
+ +
+
${escapedMessage}
+
`; } - /** Show overlay with optional message */ - show(message?: string): void { + /** + * Escape HTML special characters to prevent injection + * Note: Order of replacements is critical - ampersand must be first to avoid + * double-escaping the ampersands in entities like < and > + */ + private escapeHtml(text: string): string { + return text + .replace(/&/g, "&") // Must be first to avoid double-escaping + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } + + /** + * Show overlay with optional message. + * If bounds are provided, the overlay will only cover that area (typically the tool panel). + * If no bounds provided, it will cover the entire window (fallback for legacy compatibility). + */ + show(message?: string, bounds?: { x: number; y: number; width: number; height: number }): void { this.currentMessage = message || this.currentMessage || "Loading..."; + this.currentBounds = bounds || null; this.reloadContent(); this.updateWindowBounds(); if (this.overlayWindow && !this.visible) { @@ -124,12 +187,24 @@ body { display:flex; align-items:center; justify-content:center; } this.mainWindow.on("restore", () => { if (this.visible) this.show(); }); + this.mainWindow.on("close", () => { + // Mark that main window is closing so overlay can close too + this.isMainWindowClosing = true; + }); this.mainWindow.on("closed", () => this.destroy()); } /** Cleanup */ destroy(): void { - this.overlayWindow = null; + if (this.overlayWindow) { + // Remove the specific close listener to allow destruction + if (this.closeHandler) { + this.overlayWindow.removeListener("close", this.closeHandler); + } + this.overlayWindow.destroy(); + this.overlayWindow = null; + } + this.closeHandler = null; this.visible = false; } } diff --git a/src/main/managers/toolWindowManager.ts b/src/main/managers/toolWindowManager.ts index 8a8efcc5..de8ccb71 100644 --- a/src/main/managers/toolWindowManager.ts +++ b/src/main/managers/toolWindowManager.ts @@ -1,7 +1,7 @@ import { BrowserView, BrowserWindow, ipcMain } from "electron"; import * as path from "path"; import { EVENT_CHANNELS, TOOL_WINDOW_CHANNELS } from "../../common/ipc/channels"; -import { captureMessage, logInfo } from "../../common/sentryHelper"; +import { captureException, captureMessage, logInfo } from "../../common/sentryHelper"; import { LastUsedToolConnectionInfo, Tool } from "../../common/types"; import { ToolBoxEvent } from "../../common/types/events"; import { BrowserviewProtocolManager } from "./browserviewProtocolManager"; @@ -733,6 +733,39 @@ export class ToolWindowManager { return this.activeToolId; } + /** + * Get the bounds of the active tool's BrowserView + * @returns The bounds of the active tool's BrowserView, or null if no tool is active + */ + getActiveToolBounds(): { x: number; y: number; width: number; height: number } | null { + if (!this.activeToolId) { + return null; + } + + const toolView = this.toolViews.get(this.activeToolId); + if (!toolView) { + return null; + } + + try { + return toolView.getBounds(); + } catch (error) { + // Normalize error and capture with full context + const normalizedError = error instanceof Error ? error : new Error(String(error)); + captureException(normalizedError, { + tags: { + component: "ToolWindowManager", + method: "getActiveToolBounds", + }, + extra: { + activeToolId: this.activeToolId, + errorMessage: normalizedError.message, + }, + }); + return null; + } + } + /** * Get the active tool's repository URL * @returns The repository URL of the currently active tool, or null if no tool is active or no repository is defined From 3d6ec9cef8770b013a16cb29cd16175a605deff9 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:06:50 -0500 Subject: [PATCH 014/178] fix: update release date formatting in workflows for consistency (#383) --- .github/workflows/nightly-release.yml | 2 +- .github/workflows/prod-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index fb240cd6..583f3b15 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -209,7 +209,7 @@ jobs: Write-Host "Size: $size" # Create new YAML content with correct hashes - $releaseDate = (Get-Date -u -Format 'yyyy-MM-ddTHH:mm:ss.000Z') + $releaseDate = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.000Z') $yml = @{ version = $version files = @( diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 7dd5ac97..3f977381 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -213,7 +213,7 @@ jobs: Write-Host "Size: $size" # Create new YAML content with correct hashes - $releaseDate = (Get-Date -u -Format 'yyyy-MM-ddTHH:mm:ss.000Z') + $releaseDate = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.000Z') $yml = @{ version = $version files = @( From 79c6112f5ac52280ee38eae610165ecd38f79cf0 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:13:08 -0500 Subject: [PATCH 015/178] fix: clean up toolboxAPI type definitions and improve connection handling (#387) --- packages/toolboxAPI.d.ts | 14 +---- src/main/toolPreloadBridge.ts | 97 ++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 53 deletions(-) diff --git a/packages/toolboxAPI.d.ts b/packages/toolboxAPI.d.ts index ef328439..68106d60 100644 --- a/packages/toolboxAPI.d.ts +++ b/packages/toolboxAPI.d.ts @@ -82,8 +82,6 @@ declare namespace ToolBoxAPI { name: string; url: string; environment: "Dev" | "Test" | "UAT" | "Production"; - clientId?: string; - tenantId?: string; createdAt: string; lastUsedAt?: string; /** @@ -155,16 +153,6 @@ declare namespace ToolBoxAPI { * Get the secondary connection for multi-connection tools */ getSecondaryConnection: () => Promise; - - /** - * Get the secondary connection URL for multi-connection tools - */ - getSecondaryConnectionUrl: () => Promise; - - /** - * Get the secondary connection ID for multi-connection tools - */ - getSecondaryConnectionId: () => Promise; } /** @@ -272,7 +260,7 @@ declare namespace ToolBoxAPI { * JSON.stringify(data, null, 2), * [{name: "JSON", extensions: ["json"]}, {name: "Text", extensions: ["txt"]}] * ); - * + * * // Save without filters (auto-derived from extension) * await toolboxAPI.fileSystem.saveFile("config.xml", xmlContent); */ diff --git a/src/main/toolPreloadBridge.ts b/src/main/toolPreloadBridge.ts index c121b602..3a11b082 100644 --- a/src/main/toolPreloadBridge.ts +++ b/src/main/toolPreloadBridge.ts @@ -95,6 +95,43 @@ function ipcInvoke(channel: string, ...args: unknown[]): Promise { return ipcRenderer.invoke(channel, ...args); } +type ToolSafeConnection = { + id: string; + name: string; + url: string; + environment: "Dev" | "Test" | "UAT" | "Production"; + createdAt?: string; + lastUsedAt?: string; + isActive?: boolean; +}; + +function toToolSafeConnection(connection: unknown): ToolSafeConnection | null { + if (!connection || typeof connection !== "object") { + return null; + } + + const source = connection as Record; + const environment = source.environment; + + if (typeof source.id !== "string" || typeof source.name !== "string" || typeof source.url !== "string") { + return null; + } + + if (environment !== "Dev" && environment !== "Test" && environment !== "UAT" && environment !== "Production") { + return null; + } + + return { + id: source.id, + name: source.name, + url: source.url, + environment, + createdAt: typeof source.createdAt === "string" ? source.createdAt : undefined, + lastUsedAt: typeof source.lastUsedAt === "string" ? source.lastUsedAt : undefined, + isActive: typeof source.isActive === "boolean" ? source.isActive : undefined, + }; +} + // Expose toolboxAPI to the tool window contextBridge.exposeInMainWorld("toolboxAPI", { // Tool Info @@ -106,52 +143,22 @@ contextBridge.exposeInMainWorld("toolboxAPI", { // Connections API connections: { // Get tool's primary connection from context - getConnection: async () => { - await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); - if (!toolContext || typeof toolContext.connectionId !== "string") { - return null; - } - return ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTION_BY_ID, toolContext.connectionId); - }, - getConnectionUrl: async () => { - await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); - return toolContext?.connectionUrl || null; - }, - getConnectionId: async () => { - await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); - return toolContext?.connectionId || null; - }, - // Backward compatibility: getActiveConnection is an alias for getConnection - // Tools call this expecting their own connection, not a global active connection getActiveConnection: async () => { await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); if (!toolContext || typeof toolContext.connectionId !== "string") { return null; } - return ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTION_BY_ID, toolContext.connectionId); + const connection = await ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTION_BY_ID, toolContext.connectionId); + return toToolSafeConnection(connection); }, - getAll: () => ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTIONS), - add: (connection: unknown) => ipcInvoke(CONNECTION_CHANNELS.ADD_CONNECTION, connection), - update: (id: string, updates: unknown) => ipcInvoke(CONNECTION_CHANNELS.UPDATE_CONNECTION, id, updates), - delete: (id: string) => ipcInvoke(CONNECTION_CHANNELS.DELETE_CONNECTION, id), - test: (connection: unknown) => ipcInvoke(CONNECTION_CHANNELS.TEST_CONNECTION, connection), - isTokenExpired: (connectionId: string) => ipcInvoke(CONNECTION_CHANNELS.IS_TOKEN_EXPIRED, connectionId), - refreshToken: (connectionId: string) => ipcInvoke(CONNECTION_CHANNELS.REFRESH_TOKEN, connectionId), // Secondary connection methods for multi-connection tools getSecondaryConnection: async () => { await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); if (!toolContext || typeof toolContext.secondaryConnectionId !== "string") { return null; } - return ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTION_BY_ID, toolContext.secondaryConnectionId); - }, - getSecondaryConnectionUrl: async () => { - await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); - return toolContext?.secondaryConnectionUrl || null; - }, - getSecondaryConnectionId: async () => { - await withTimeout(toolContextReady, TOOL_CONTEXT_TIMEOUT_MS, TOOL_CONTEXT_TIMEOUT_ERROR); - return toolContext?.secondaryConnectionId || null; + const connection = await ipcInvoke(CONNECTION_CHANNELS.GET_CONNECTION_BY_ID, toolContext.secondaryConnectionId); + return toToolSafeConnection(connection); }, }, @@ -208,8 +215,13 @@ contextBridge.exposeInMainWorld("toolboxAPI", { // Attribute (Column) metadata operations createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), - updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => - ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), + updateAttribute: ( + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: Record, + connectionTarget?: "primary" | "secondary", + ) => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, entityLogicalName, attributeIdentifier, connectionTarget), createPolymorphicLookupAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => @@ -225,7 +237,8 @@ contextBridge.exposeInMainWorld("toolboxAPI", { ipcInvoke(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, optionSetDefinition, options, connectionTarget), updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, optionSetIdentifier, optionSetDefinition, options, connectionTarget), - deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, optionSetIdentifier, connectionTarget), + deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => + ipcInvoke(DATAVERSE_CHANNELS.DELETE_GLOBAL_OPTION_SET, optionSetIdentifier, connectionTarget), // Option value modification actions insertOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.INSERT_OPTION_VALUE, params, connectionTarget), updateOptionValue: (params: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_OPTION_VALUE, params, connectionTarget), @@ -273,7 +286,6 @@ contextBridge.exposeInMainWorld("toolboxAPI", { const { toolId, instanceId } = await getToolIdentifiers(); return ipcInvoke(TERMINAL_CHANNELS.GET_TOOL_TERMINALS, toolId, instanceId); }, - listAll: () => ipcInvoke(TERMINAL_CHANNELS.GET_ALL_TERMINALS), setVisibility: (terminalId: string, visible: boolean) => ipcInvoke(TERMINAL_CHANNELS.SET_VISIBILITY, terminalId, visible), }, @@ -364,8 +376,13 @@ contextBridge.exposeInMainWorld("dataverseAPI", { // Attribute (Column) metadata operations createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.CREATE_ATTRIBUTE, entityLogicalName, attributeDefinition, options, connectionTarget), - updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => - ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), + updateAttribute: ( + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: Record, + connectionTarget?: "primary" | "secondary", + ) => ipcInvoke(DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, entityLogicalName, attributeIdentifier, attributeDefinition, options, connectionTarget), deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.DELETE_ATTRIBUTE, entityLogicalName, attributeIdentifier, connectionTarget), createPolymorphicLookupAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: Record, connectionTarget?: "primary" | "secondary") => From 4b27beb8364a6efff118a2932175ed230b86718c Mon Sep 17 00:00:00 2001 From: mohsinonxrm Date: Sat, 14 Feb 2026 18:14:12 -0800 Subject: [PATCH 016/178] feat: add getCSDLDocument API for retrieving OData endpoint (#384) (#385) * feat: add getCSDLDocument API for retrieving OData endpoint (#384) Add new getCSDLDocument() method to DataverseAPI that retrieves the complete CSDL/EDMX metadata document from Dataverse's OData $metadata endpoint. Key Features: - Returns raw XML containing complete schema metadata (entities, attributes, relationships, actions, functions, complex types, enum types) - Supports gzip/deflate compression for optimal transfer (70-80% size reduction) - Automatic decompression handling using Node.js zlib module - Multi-connection support (primary/secondary) for advanced tools - Response size: 1-5MB typical, up to 10MB+ for complex environments Implementation: - Added GET_CSDL_DOCUMENT IPC channel to channels.ts - Implemented getCSDLDocument() in DataverseManager with: - Custom HTTPS request handler (avoids JSON parsing) - Accept-Encoding: gzip, deflate headers - Automatic decompression via zlib.gunzip/inflate - Buffer-based response handling for binary data - Registered IPC handler in index.ts with connection targeting support - Exposed method in toolPreloadBridge.ts and preload.ts - Added comprehensive TypeScript definitions in dataverseAPI.d.ts Use Cases: - Build Dataverse REST Builder (DRB) clone tools - Create intelligent query builders and code generators - Generate TypeScript interfaces from schema - Explore entity relationships and metadata - Validate action/function parameters Naming Rationale: Method named getCSDLDocument() (not getMetadata()) to avoid confusion with existing entity metadata operations like getEntityMetadata() and getAllEntitiesMetadata(). CSDL (Common Schema Definition Language) clearly indicates it returns the OData service document. Related: #384 * fix: expose getCSDLDocument on window.dataverseAPI for direct tool access Fixed issue where getCSDLDocument was only accessible via window.toolboxAPI.dataverse.getCSDLDocument but not directly on window.dataverseAPI.getCSDLDocument like other Dataverse operations. Changes: - Added getCSDLDocument to toolPreloadBridge.ts dataverseAPI namespace - Now consistent with other operations (getSolutions, queryData, etc.) - Tools can call dataverseAPI.getCSDLDocument() directly as expected This ensures getCSDLDocument follows the same exposure pattern as all other Dataverse API methods. * fix: decompress error responses in getCSDLDocument for readable error messages Previously, error responses (non-200 status codes) were converted directly from Buffer to UTF-8 string without checking for compression. Since the request includes 'Accept-Encoding: gzip, deflate' header, Dataverse may return compressed error responses, resulting in garbled error messages. Changes: - Added decompression logic to error response path - Check content-encoding header (gzip/deflate/none) - Decompress error body before converting to string - Added try-catch to handle decompression failures gracefully - Error messages now readable regardless of compression This mirrors the success path's decompression logic and ensures consistent handling of both success and error responses. --- packages/dataverseAPI.d.ts | 50 +++++++++- src/common/ipc/channels.ts | 1 + src/main/index.ts | 132 +++++++++++++++++--------- src/main/managers/dataverseManager.ts | 118 ++++++++++++++++++++--- src/main/preload.ts | 1 + src/main/toolPreloadBridge.ts | 2 + 6 files changed, 242 insertions(+), 62 deletions(-) diff --git a/packages/dataverseAPI.d.ts b/packages/dataverseAPI.d.ts index 26599f5d..17d90488 100644 --- a/packages/dataverseAPI.d.ts +++ b/packages/dataverseAPI.d.ts @@ -958,6 +958,27 @@ declare namespace DataverseAPI { */ buildLabel: (text: string, languageCode?: number) => Label; + /** + * Retrieve the CSDL/EDMX metadata document for the Dataverse environment + * + * Returns the complete OData service document as raw XML containing metadata for: + * - EntityType definitions (tables/entities) + * - Property elements (attributes/columns) + * - NavigationProperty elements (relationships) + * - ComplexType definitions (return types for actions/functions) + * - EnumType definitions (picklist/choice enumerations) + * - Action definitions (OData Actions - POST operations) + * - Function definitions (OData Functions - GET operations) + * - EntityContainer metadata + * + * The response is automatically compressed with gzip during transfer for optimal performance, + * then decompressed and returned as a raw XML string. + * + * @param connectionTarget - Optional connection target for multi-connection tools + * @returns Raw CSDL/EDMX XML document as string (typically 1-5MB) + */ + getCSDLDocument: (connectionTarget?: "primary" | "secondary") => Promise; + /** * Get the OData type string for an attribute metadata type * Converts AttributeMetadataType enum to full Microsoft.Dynamics.CRM type path @@ -1142,7 +1163,12 @@ declare namespace DataverseAPI { * }); * await dataverseAPI.publishCustomizations("new_project"); */ - createAttribute: (entityLogicalName: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>; + createAttribute: ( + entityLogicalName: string, + attributeDefinition: Record, + options?: MetadataOperationOptions, + connectionTarget?: "primary" | "secondary", + ) => Promise<{ id: string }>; /** * Update an attribute (column) definition @@ -1179,7 +1205,13 @@ declare namespace DataverseAPI { * // Step 4: Publish customizations * await dataverseAPI.publishCustomizations("new_project"); */ - updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + updateAttribute: ( + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: MetadataOperationOptions, + connectionTarget?: "primary" | "secondary", + ) => Promise; /** * Delete an attribute (column) from an entity @@ -1295,7 +1327,12 @@ declare namespace DataverseAPI { * @param options - Optional metadata operation options (mergeLabels defaults to true) * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. */ - updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + updateRelationship: ( + relationshipIdentifier: string, + relationshipDefinition: Record, + options?: MetadataOperationOptions, + connectionTarget?: "primary" | "secondary", + ) => Promise; /** * Delete a relationship @@ -1354,7 +1391,12 @@ declare namespace DataverseAPI { * @param options - Optional metadata operation options (mergeLabels defaults to true) * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'. */ - updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise; + updateGlobalOptionSet: ( + optionSetIdentifier: string, + optionSetDefinition: Record, + options?: MetadataOperationOptions, + connectionTarget?: "primary" | "secondary", + ) => Promise; /** * Delete a global option set diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index 3749a923..3e477f64 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -186,6 +186,7 @@ export const DATAVERSE_CHANNELS = { UPDATE_OPTION_VALUE: "dataverse.updateOptionValue", DELETE_OPTION_VALUE: "dataverse.deleteOptionValue", ORDER_OPTION: "dataverse.orderOption", + GET_CSDL_DOCUMENT: "dataverse.getCSDLDocument", } as const; // Event-related IPC channels (from main to renderer) diff --git a/src/main/index.ts b/src/main/index.ts index fcc76400..b967b1f0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -74,7 +74,16 @@ import { UPDATE_CHANNELS, UTIL_CHANNELS, } from "../common/ipc/channels"; -import { AttributeMetadataType, EntityRelatedMetadataPath, LastUsedToolEntry, LastUsedToolUpdate, MetadataOperationOptions, ModalWindowMessagePayload, ModalWindowOptions, ToolBoxEvent } from "../common/types"; +import { + AttributeMetadataType, + EntityRelatedMetadataPath, + LastUsedToolEntry, + LastUsedToolUpdate, + MetadataOperationOptions, + ModalWindowMessagePayload, + ModalWindowOptions, + ToolBoxEvent, +} from "../common/types"; import { AuthManager } from "./managers/authManager"; import { AutoUpdateManager } from "./managers/autoUpdateManager"; import { BrowserManager } from "./managers/browserManager"; @@ -970,7 +979,7 @@ class ToolBoxApp { try { // Get bounds from the active tool's BrowserView directly const bounds = this.toolWindowManager?.getActiveToolBounds() || undefined; - + // Show overlay with tool panel bounds (or undefined for full window fallback) this.loadingOverlayWindowManager.show(message || "Loading...", bounds); } catch (error) { @@ -1543,6 +1552,23 @@ class ToolBoxApp { } }); + // Get CSDL document endpoint + ipcMain.handle(DATAVERSE_CHANNELS.GET_CSDL_DOCUMENT, async (event, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.getCSDLDocument(connectionId); + } catch (error) { + throw new Error(`Get CSDL document failed: ${(error as Error).message}`); + } + }); + // Dataverse Metadata Helper Utilities ipcMain.handle(DATAVERSE_CHANNELS.BUILD_LABEL, async (event, text: string, languageCode?: number) => { try { @@ -1566,21 +1592,24 @@ class ToolBoxApp { }); // Entity (Table) Metadata CRUD Operations - ipcMain.handle(DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, async (event, entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { - try { - const connectionId = - connectionTarget === "secondary" - ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) - : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); - if (!connectionId) { - const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; - throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + ipcMain.handle( + DATAVERSE_CHANNELS.CREATE_ENTITY_DEFINITION, + async (event, entityDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createEntityDefinition(connectionId, entityDefinition, options); + } catch (error) { + throw new Error(`Create entity definition failed: ${(error as Error).message}`); } - return await this.dataverseManager.createEntityDefinition(connectionId, entityDefinition, options); - } catch (error) { - throw new Error(`Create entity definition failed: ${(error as Error).message}`); - } - }); + }, + ); ipcMain.handle( DATAVERSE_CHANNELS.UPDATE_ENTITY_DEFINITION, @@ -1641,7 +1670,14 @@ class ToolBoxApp { ipcMain.handle( DATAVERSE_CHANNELS.UPDATE_ATTRIBUTE, - async (event, entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + async ( + event, + entityLogicalName: string, + attributeIdentifier: string, + attributeDefinition: Record, + options?: MetadataOperationOptions, + connectionTarget?: "primary" | "secondary", + ) => { try { const connectionId = connectionTarget === "secondary" @@ -1696,21 +1732,24 @@ class ToolBoxApp { ); // Relationship Metadata CRUD Operations - ipcMain.handle(DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, async (event, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { - try { - const connectionId = - connectionTarget === "secondary" - ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) - : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); - if (!connectionId) { - const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; - throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + ipcMain.handle( + DATAVERSE_CHANNELS.CREATE_RELATIONSHIP, + async (event, relationshipDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createRelationship(connectionId, relationshipDefinition, options); + } catch (error) { + throw new Error(`Create relationship failed: ${(error as Error).message}`); } - return await this.dataverseManager.createRelationship(connectionId, relationshipDefinition, options); - } catch (error) { - throw new Error(`Create relationship failed: ${(error as Error).message}`); - } - }); + }, + ); ipcMain.handle( DATAVERSE_CHANNELS.UPDATE_RELATIONSHIP, @@ -1750,21 +1789,24 @@ class ToolBoxApp { }); // Global Option Set (Choice) CRUD Operations - ipcMain.handle(DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, async (event, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { - try { - const connectionId = - connectionTarget === "secondary" - ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) - : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); - if (!connectionId) { - const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; - throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + ipcMain.handle( + DATAVERSE_CHANNELS.CREATE_GLOBAL_OPTION_SET, + async (event, optionSetDefinition: Record, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => { + try { + const connectionId = + connectionTarget === "secondary" + ? this.toolWindowManager?.getSecondaryConnectionIdByWebContents(event.sender.id) + : this.toolWindowManager?.getConnectionIdByWebContents(event.sender.id); + if (!connectionId) { + const targetMsg = connectionTarget === "secondary" ? "secondary connection" : "connection"; + throw new Error(`No ${targetMsg} found for this tool instance. Please ensure the tool is connected to an environment.`); + } + return await this.dataverseManager.createGlobalOptionSet(connectionId, optionSetDefinition, options); + } catch (error) { + throw new Error(`Create global option set failed: ${(error as Error).message}`); } - return await this.dataverseManager.createGlobalOptionSet(connectionId, optionSetDefinition, options); - } catch (error) { - throw new Error(`Create global option set failed: ${(error as Error).message}`); - } - }); + }, + ); ipcMain.handle( DATAVERSE_CHANNELS.UPDATE_GLOBAL_OPTION_SET, diff --git a/src/main/managers/dataverseManager.ts b/src/main/managers/dataverseManager.ts index 55db107b..5004127f 100644 --- a/src/main/managers/dataverseManager.ts +++ b/src/main/managers/dataverseManager.ts @@ -1,4 +1,6 @@ import * as https from "https"; +import * as zlib from "zlib"; +import { promisify } from "util"; import { DataverseConnection, ENTITY_RELATED_METADATA_BASE_PATHS, @@ -91,15 +93,7 @@ export class DataverseManager { * Headers that must never be passed as custom headers because they are controlled by makeHttpRequest. * Attempting to override these headers will result in validation errors. */ - private static readonly PROTECTED_HEADERS: ReadonlySet = new Set([ - "authorization", - "accept", - "content-type", - "odata-maxversion", - "odata-version", - "prefer", - "content-length", - ]); + private static readonly PROTECTED_HEADERS: ReadonlySet = new Set(["authorization", "accept", "content-type", "odata-maxversion", "odata-version", "prefer", "content-length"]); /** * Validates custom headers for metadata operations against the allowed headers list. @@ -165,10 +159,7 @@ export class DataverseManager { } if (invalidHeaders.length > 0) { - errorParts.push( - `Invalid headers for metadata operations: ${invalidHeaders.join(", ")}. ` + - `Allowed headers: ${Array.from(DataverseManager.ALLOWED_METADATA_HEADERS).join(", ")}`, - ); + errorParts.push(`Invalid headers for metadata operations: ${invalidHeaders.join(", ")}. ` + `Allowed headers: ${Array.from(DataverseManager.ALLOWED_METADATA_HEADERS).join(", ")}`); } throw new Error(`Header validation failed${operation}. ${errorParts.join(". ")}`); @@ -803,6 +794,107 @@ export class DataverseManager { return response.data as { value: Record[] }; } + /** + * Retrieve CSDL/EDMX metadata document for the Dataverse environment + * + * Returns the complete OData service document containing metadata for all: + * - EntityType definitions (tables/entities) + * - Property elements (attributes/columns) + * - NavigationProperty elements (relationships) + * - ComplexType definitions (return types for actions/functions) + * - EnumType definitions (picklist/choice enumerations) + * - Action definitions (OData Actions - POST operations) + * - Function definitions (OData Functions - GET operations) + * - EntityContainer metadata + * + * NOTE: Returns raw XML (1-5MB typical). Response is compressed with gzip for optimal transfer. + * The response is automatically decompressed and returned as a string. + * + * @param connectionId - Connection ID to use + * @returns Raw CSDL/EDMX XML document as string + * + * @throws Error if connection not found, token expired, or request fails + */ + async getCSDLDocument(connectionId: string): Promise { + const { connection, accessToken } = await this.getConnectionWithToken(connectionId); + const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/$metadata`); + + const gunzipAsync = promisify(zlib.gunzip); + const inflateAsync = promisify(zlib.inflate); + + return new Promise((resolve, reject) => { + const urlObj = new URL(url); + + const options: https.RequestOptions = { + hostname: urlObj.hostname, + port: 443, + path: urlObj.pathname, + method: "GET", + headers: { + Authorization: `Bearer ${accessToken}`, + Accept: "application/xml", + "Accept-Encoding": "gzip, deflate", + }, + }; + + const req = https.request(options, (res) => { + const chunks: Buffer[] = []; + + res.on("data", (chunk: Buffer) => { + chunks.push(chunk); + }); + + res.on("end", async () => { + if (res.statusCode === 200) { + try { + const buffer = Buffer.concat(chunks); + const encoding = res.headers["content-encoding"]; + + let decompressed: Buffer; + if (encoding === "gzip") { + decompressed = await gunzipAsync(buffer); + } else if (encoding === "deflate") { + decompressed = await inflateAsync(buffer); + } else { + decompressed = buffer; + } + + resolve(decompressed.toString("utf-8")); + } catch (error) { + reject(new Error(`Failed to decompress metadata response: ${(error as Error).message}`)); + } + } else { + // Error responses may also be compressed - decompress before reading body + try { + const buffer = Buffer.concat(chunks); + const encoding = res.headers["content-encoding"]; + let decompressed: Buffer; + + if (encoding === "gzip") { + decompressed = await gunzipAsync(buffer); + } else if (encoding === "deflate") { + decompressed = await inflateAsync(buffer); + } else { + decompressed = buffer; + } + + const body = decompressed.toString("utf-8"); + reject(new Error(`Failed to retrieve CSDL document. Status: ${res.statusCode}, Body: ${body}`)); + } catch (decompressError) { + reject(new Error(`Failed to process error response: ${(decompressError as Error).message}`)); + } + } + }); + }); + + req.on("error", (error) => { + reject(new Error(`Metadata request failed: ${error.message}`)); + }); + + req.end(); + }); + } + /** * Make an HTTP request to Dataverse Web API */ diff --git a/src/main/preload.ts b/src/main/preload.ts index 1b17ac71..163f1fe8 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -250,6 +250,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { getEntityRelatedMetadata:

(entityLogicalName: string, relatedPath: P, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.GET_ENTITY_RELATED_METADATA, entityLogicalName, relatedPath, selectColumns, connectionTarget) as Promise>, getSolutions: (selectColumns: string[], connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.GET_SOLUTIONS, selectColumns, connectionTarget), + getCSDLDocument: (connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.GET_CSDL_DOCUMENT, connectionTarget), queryData: (odataQuery: string, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.QUERY_DATA, odataQuery, connectionTarget), publishCustomizations: (tableLogicalName?: string, connectionTarget?: "primary" | "secondary") => ipcRenderer.invoke(DATAVERSE_CHANNELS.PUBLISH_CUSTOMIZATIONS, tableLogicalName, connectionTarget), diff --git a/src/main/toolPreloadBridge.ts b/src/main/toolPreloadBridge.ts index 3a11b082..2834e952 100644 --- a/src/main/toolPreloadBridge.ts +++ b/src/main/toolPreloadBridge.ts @@ -180,6 +180,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { getEntityRelatedMetadata:

(entityLogicalName: string, relatedPath: P, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_ENTITY_RELATED_METADATA, entityLogicalName, relatedPath, selectColumns, connectionTarget) as Promise>, getSolutions: (selectColumns: string[], connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_SOLUTIONS, selectColumns, connectionTarget), + getCSDLDocument: (connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_CSDL_DOCUMENT, connectionTarget), queryData: (odataQuery: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.QUERY_DATA, odataQuery, connectionTarget), publishCustomizations: (tableLogicalName?: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.PUBLISH_CUSTOMIZATIONS, tableLogicalName, connectionTarget), createMultiple: (entityLogicalName: string, records: Record[], connectionTarget?: "primary" | "secondary") => @@ -341,6 +342,7 @@ contextBridge.exposeInMainWorld("dataverseAPI", { getEntityRelatedMetadata:

(entityLogicalName: string, relatedPath: P, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_ENTITY_RELATED_METADATA, entityLogicalName, relatedPath, selectColumns, connectionTarget) as Promise>, getSolutions: (selectColumns: string[], connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_SOLUTIONS, selectColumns, connectionTarget), + getCSDLDocument: (connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.GET_CSDL_DOCUMENT, connectionTarget), queryData: (odataQuery: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.QUERY_DATA, odataQuery, connectionTarget), publishCustomizations: (tableLogicalName?: string, connectionTarget?: "primary" | "secondary") => ipcInvoke(DATAVERSE_CHANNELS.PUBLISH_CUSTOMIZATIONS, tableLogicalName, connectionTarget), createMultiple: (entityLogicalName: string, records: Record[], connectionTarget?: "primary" | "secondary") => From badfdcb8ef6ffae5b2a45ad3ce929b14f6a6d714 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Sat, 14 Feb 2026 21:28:54 -0500 Subject: [PATCH 017/178] File System cleanup (#389) * fix: clean up toolboxAPI type definitions and improve connection handling * fix: implement filesystem access management for tools with user consent model * Fix filesystem access tracking to use instanceId instead of toolId (#390) * Initial plan * fix: track filesystem access per instance instead of per tool This change fixes the issue where closing one instance of a tool would revoke filesystem access for all other instances of the same tool. Changes: - Updated ToolFileSystemAccessManager to use instanceId as key instead of toolId - Added getInstanceIdByWebContents() method to ToolWindowManager - Updated all filesystem IPC handlers to use instanceId - Updated closeTool() to revoke access only for the specific instance This ensures that each tool instance maintains its own filesystem permissions independently, allowing multiple instances of the same tool to run simultaneously without interfering with each other. Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * refactor: eliminate code duplication in toolWindowManager methods Refactor getToolIdByWebContents() to call getInstanceIdByWebContents() and extract the toolId from the result, eliminating duplicated loop logic. Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> --- src/main/index.ts | 99 ++++++++++++++--- .../managers/toolFileSystemAccessManager.ts | 104 ++++++++++++++++++ src/main/managers/toolWindowManager.ts | 39 +++++++ 3 files changed, 229 insertions(+), 13 deletions(-) create mode 100644 src/main/managers/toolFileSystemAccessManager.ts diff --git a/src/main/index.ts b/src/main/index.ts index b967b1f0..38e6ba17 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -97,6 +97,7 @@ import { NotificationWindowManager } from "./managers/notificationWindowManager" import { SettingsManager } from "./managers/settingsManager"; import { TerminalManager } from "./managers/terminalManager"; import { ToolBoxUtilityManager } from "./managers/toolboxUtilityManager"; +import { ToolFileSystemAccessManager } from "./managers/toolFileSystemAccessManager"; import { ToolManager } from "./managers/toolsManager"; import { ToolWindowManager } from "./managers/toolWindowManager"; @@ -120,6 +121,7 @@ class ToolBoxApp { private authManager: AuthManager; private terminalManager: TerminalManager; private dataverseManager: DataverseManager; + private toolFilesystemAccessManager: ToolFileSystemAccessManager; private tokenExpiryCheckInterval: NodeJS.Timeout | null = null; private notifiedExpiredTokens: Set = new Set(); // Track notified expired tokens private menuCreationTimeout: NodeJS.Timeout | null = null; // Debounce timer for menu recreation @@ -148,6 +150,7 @@ class ToolBoxApp { this.authManager = new AuthManager(this.browserManager); this.terminalManager = new TerminalManager(); this.dataverseManager = new DataverseManager(this.connectionsManager, this.authManager); + this.toolFilesystemAccessManager = new ToolFileSystemAccessManager(); this.setupEventListeners(); this.setupIpcHandlers(); @@ -1070,50 +1073,112 @@ class ToolBoxApp { await shell.openExternal(url); }); - // Filesystem handlers - ipcMain.handle(FILESYSTEM_CHANNELS.READ_TEXT, async (_, filePath: string) => { + // Filesystem handlers with access control + ipcMain.handle(FILESYSTEM_CHANNELS.READ_TEXT, async (event, filePath: string) => { + // Validate access if caller is a tool (null instanceId means main window - allow all) + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, filePath); + } + const { readText } = await import("./utilities/filesystem.js"); return await readText(filePath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.READ_BINARY, async (_, filePath: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.READ_BINARY, async (event, filePath: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, filePath); + } + const { readBinary } = await import("./utilities/filesystem.js"); return await readBinary(filePath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.EXISTS, async (_, filePath: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.EXISTS, async (event, filePath: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, filePath); + } + const { exists } = await import("./utilities/filesystem.js"); return await exists(filePath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.STAT, async (_, filePath: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.STAT, async (event, filePath: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, filePath); + } + const { stat } = await import("./utilities/filesystem.js"); return await stat(filePath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.READ_DIRECTORY, async (_, dirPath: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.READ_DIRECTORY, async (event, dirPath: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, dirPath); + } + const { readDirectory } = await import("./utilities/filesystem.js"); return await readDirectory(dirPath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.WRITE_TEXT, async (_, filePath: string, content: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.WRITE_TEXT, async (event, filePath: string, content: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, filePath); + } + const { writeText } = await import("./utilities/filesystem.js"); return await writeText(filePath, content); }); - ipcMain.handle(FILESYSTEM_CHANNELS.CREATE_DIRECTORY, async (_, dirPath: string) => { + ipcMain.handle(FILESYSTEM_CHANNELS.CREATE_DIRECTORY, async (event, dirPath: string) => { + // Validate access if caller is a tool + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.validateAccess(instanceId, dirPath); + } + const { createDirectory } = await import("./utilities/filesystem.js"); return await createDirectory(dirPath); }); - ipcMain.handle(FILESYSTEM_CHANNELS.SAVE_FILE, async (_, defaultPath: string, content: string | Buffer, filters?: Array<{ name: string; extensions: string[] }>) => { + ipcMain.handle(FILESYSTEM_CHANNELS.SAVE_FILE, async (event, defaultPath: string, content: string | Buffer, filters?: Array<{ name: string; extensions: string[] }>) => { const { saveFile } = await import("./utilities/filesystem.js"); - return await saveFile(defaultPath, content, filters); + const selectedPath = await saveFile(defaultPath, content, filters); + + // Grant access to the selected path if a tool called this and user selected a file + if (selectedPath) { + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.grantAccess(instanceId, selectedPath); + } + } + + return selectedPath; }); - ipcMain.handle(FILESYSTEM_CHANNELS.SELECT_PATH, async (_, options) => { + ipcMain.handle(FILESYSTEM_CHANNELS.SELECT_PATH, async (event, options) => { const { selectPath } = await import("./utilities/filesystem.js"); - return await selectPath(options); + const selectedPath = await selectPath(options); + + // Grant access to the selected path if a tool called this and user selected something + if (selectedPath) { + const instanceId = this.toolWindowManager?.getInstanceIdByWebContents(event.sender.id); + if (instanceId) { + this.toolFilesystemAccessManager.grantAccess(instanceId, selectedPath); + } + } + + return selectedPath; }); // Modal BrowserWindow internal channels (modal preload -> main) @@ -2236,7 +2301,15 @@ class ToolBoxApp { }); // Initialize ToolWindowManager for managing tool BrowserViews - this.toolWindowManager = new ToolWindowManager(this.mainWindow, this.browserviewProtocolManager, this.connectionsManager, this.settingsManager, this.toolManager, this.terminalManager); + this.toolWindowManager = new ToolWindowManager( + this.mainWindow, + this.browserviewProtocolManager, + this.connectionsManager, + this.settingsManager, + this.toolManager, + this.terminalManager, + this.toolFilesystemAccessManager, + ); // Set up callback to rebuild menu when active tool changes (debounced to prevent excessive recreation) this.toolWindowManager.setOnActiveToolChanged(() => { diff --git a/src/main/managers/toolFileSystemAccessManager.ts b/src/main/managers/toolFileSystemAccessManager.ts new file mode 100644 index 00000000..50bcddd9 --- /dev/null +++ b/src/main/managers/toolFileSystemAccessManager.ts @@ -0,0 +1,104 @@ +import * as path from "path"; +import { logInfo, logWarn } from "../../common/sentryHelper"; + +/** + * Manages filesystem access permissions for tools + * Implements a user-consent model where tools can only access paths explicitly selected by users + * Similar to VS Code Extension Host security model + * + * Access is tracked per tool instance (instanceId) to support multiple instances of the same tool + */ +export class ToolFileSystemAccessManager { + // Map: instanceId -> Set of allowed absolute paths + private allowedPaths: Map> = new Map(); + + /** + * Grant access to a path for a specific tool instance + * Called automatically when user selects a path via selectPath() or saveFile() + */ + grantAccess(instanceId: string, filePath: string): void { + const resolvedPath = path.resolve(filePath); + + if (!this.allowedPaths.has(instanceId)) { + this.allowedPaths.set(instanceId, new Set()); + } + + this.allowedPaths.get(instanceId)!.add(resolvedPath); + logInfo(`[ToolFilesystemAccess] Granted access to tool instance ${instanceId}: ${resolvedPath}`); + } + + /** + * Check if a tool instance has access to a specific path + * Access is granted if: + * 1. The exact path was user-selected + * 2. The path is a descendant of a user-selected directory + */ + canAccess(instanceId: string, targetPath: string): boolean { + const allowedSet = this.allowedPaths.get(instanceId); + if (!allowedSet || allowedSet.size === 0) { + return false; + } + + const resolvedTarget = path.resolve(targetPath); + + // Check if the target path matches or is within any allowed path + for (const allowedPath of allowedSet) { + // Exact match + if (resolvedTarget === allowedPath) { + return true; + } + + // Check if target is a descendant of allowed directory + // Use path separators to ensure we're checking directory boundaries + const relativePath = path.relative(allowedPath, resolvedTarget); + const isDescendant = !relativePath.startsWith("..") && !path.isAbsolute(relativePath); + + if (isDescendant) { + return true; + } + } + + return false; + } + + /** + * Validate access and throw if denied + */ + validateAccess(instanceId: string, targetPath: string): void { + if (!this.canAccess(instanceId, targetPath)) { + const resolvedPath = path.resolve(targetPath); + logWarn(`[ToolFilesystemAccess] Access denied for tool instance ${instanceId} to path: ${resolvedPath}`); + throw new Error( + `Access denied. This tool does not have permission to access "${resolvedPath}". ` + + `Please use toolboxAPI.fileSystem.selectPath() to grant access to a directory, ` + + `or use toolboxAPI.fileSystem.saveFile() to select where to save files.`, + ); + } + } + + /** + * Revoke all access for a tool instance (called when tool instance is closed) + */ + revokeAllAccess(instanceId: string): void { + const removed = this.allowedPaths.delete(instanceId); + if (removed) { + logInfo(`[ToolFilesystemAccess] Revoked all filesystem access for tool instance: ${instanceId}`); + } + } + + /** + * Get all allowed paths for a tool instance (for debugging/auditing) + */ + getAllowedPaths(instanceId: string): string[] { + const allowedSet = this.allowedPaths.get(instanceId); + return allowedSet ? Array.from(allowedSet) : []; + } + + /** + * Clear all permissions (for testing/cleanup) + */ + clearAll(): void { + this.allowedPaths.clear(); + logInfo("[ToolFilesystemAccess] Cleared all filesystem permissions"); + } +} diff --git a/src/main/managers/toolWindowManager.ts b/src/main/managers/toolWindowManager.ts index de8ccb71..6edaa521 100644 --- a/src/main/managers/toolWindowManager.ts +++ b/src/main/managers/toolWindowManager.ts @@ -8,6 +8,7 @@ import { BrowserviewProtocolManager } from "./browserviewProtocolManager"; import { ConnectionsManager } from "./connectionsManager"; import { SettingsManager } from "./settingsManager"; import { TerminalManager } from "./terminalManager"; +import { ToolFileSystemAccessManager } from "./toolFileSystemAccessManager"; import { ToolManager } from "./toolsManager"; /** @@ -30,6 +31,7 @@ export class ToolWindowManager { private settingsManager: SettingsManager; private toolManager: ToolManager; private terminalManager: TerminalManager; + private toolFilesystemAccessManager: ToolFileSystemAccessManager; /** * Maps tool instanceId (NOT toolId) to BrowserView. * @@ -65,6 +67,7 @@ export class ToolWindowManager { settingsManager: SettingsManager, toolManager: ToolManager, terminalManager: TerminalManager, + toolFilesystemAccessManager: ToolFileSystemAccessManager, ) { this.mainWindow = mainWindow; this.browserviewProtocolManager = browserviewProtocolManager; @@ -72,6 +75,7 @@ export class ToolWindowManager { this.settingsManager = settingsManager; this.toolManager = toolManager; this.terminalManager = terminalManager; + this.toolFilesystemAccessManager = toolFilesystemAccessManager; this.boundsResponseListener = (event, bounds) => { if (bounds && bounds.width > 0 && bounds.height > 0) { @@ -394,6 +398,9 @@ export class ToolWindowManager { // Dispose any terminals created by this tool instance this.terminalManager.closeToolInstanceTerminals(instanceId); + // Revoke filesystem access for this specific tool instance + this.toolFilesystemAccessManager.revokeAllAccess(instanceId); + logInfo(`[ToolWindowManager] Tool instance closed: ${instanceId}`); return true; } catch (error) { @@ -439,6 +446,38 @@ export class ToolWindowManager { return null; } + /** + * Get the instanceId for a tool instance by its WebContents + * This is used for per-instance operations like filesystem access control + * @param webContentsId The ID of the WebContents making the request + * @returns The instanceId or null if not found (null means it's from main window, not a tool) + */ + getInstanceIdByWebContents(webContentsId: number): string | null { + // Find the instance that owns this WebContents + for (const [instanceId, toolView] of this.toolViews.entries()) { + if (toolView.webContents.id === webContentsId) { + return instanceId; + } + } + // Not a tool window - likely the main window + return null; + } + + /** + * Get the toolId for a tool instance by its WebContents + * This is used for tool-scoped operations + * @param webContentsId The ID of the WebContents making the request + * @returns The toolId or null if not found (null means it's from main window, not a tool) + */ + getToolIdByWebContents(webContentsId: number): string | null { + const instanceId = this.getInstanceIdByWebContents(webContentsId); + if (!instanceId) { + return null; + } + // Extract toolId from instanceId (format: toolId-timestamp-random) + return instanceId.split("-").slice(0, -2).join("-"); + } + /** * Update the bounds of the active tool view to match the tool panel area * Bounds are calculated dynamically based on actual DOM element positions From 5d402871a9f5cce98e378daf375668ae265615b7 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Sun, 15 Feb 2026 22:48:15 -0500 Subject: [PATCH 018/178] fix: update force check-in timestamp in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e854ea9b..c9101d10 100644 --- a/README.md +++ b/README.md @@ -258,4 +258,4 @@ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for gui This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! - + From aa7fc24d9b424d102e4f2ca5b8f6d0e41416dfa3 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Sun, 15 Feb 2026 23:11:23 -0500 Subject: [PATCH 019/178] fix: calculate and log SHA256 and SHA512 hashes in release workflows --- .github/workflows/nightly-release.yml | 42 ++++++++++++++++----------- .github/workflows/prod-release.yml | 42 ++++++++++++++++----------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 583f3b15..c685629b 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -201,11 +201,13 @@ jobs: Write-Host "Using EXE: $($mainExe.Name)" - # Calculate SHA256 hash - $hash = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + # Calculate SHA256 and SHA512 hashes + $sha256 = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + $sha512 = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA512).Hash.ToLower() $size = $mainExe.Length - Write-Host "SHA256: $hash" + Write-Host "SHA256: $sha256" + Write-Host "SHA512: $sha512" Write-Host "Size: $size" # Create new YAML content with correct hashes @@ -215,8 +217,8 @@ jobs: files = @( @{ url = $mainExe.Name - sha512 = $null - sha256 = $hash + sha512 = $sha512 + sha256 = $sha256 size = $size blockMapSize = $null } @@ -227,8 +229,8 @@ jobs: $newYmlContent = "version: $version`n" $newYmlContent += "files:`n" $newYmlContent += " - url: $($mainExe.Name)`n" - $newYmlContent += " sha512: null`n" - $newYmlContent += " sha256: $hash`n" + $newYmlContent += " sha512: $sha512`n" + $newYmlContent += " sha256: $sha256`n" $newYmlContent += " size: $size`n" $newYmlContent += " blockMapSize: null`n" $newYmlContent += "releaseDate: $releaseDate" @@ -399,18 +401,21 @@ jobs: if [[ -n "$APP_IMAGE" && -f "$APP_IMAGE" ]]; then echo " Found AppImage: $(basename "$APP_IMAGE")" - # Calculate SHA256 hash - HASH=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + # Calculate SHA256 and SHA512 hashes + HASH256=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + HASH512=$(sha512sum "$APP_IMAGE" | awk '{print $1}') SIZE=$(stat -c %s "$APP_IMAGE" 2>/dev/null || stat -f %z "$APP_IMAGE" 2>/dev/null) - echo " SHA256: $HASH" + echo " SHA256: $HASH256" + echo " SHA512: $HASH512" echo " Size: $SIZE" # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ "$VERSION" \ "$(basename "$APP_IMAGE")" \ - "$HASH" \ + "$HASH512" \ + "$HASH256" \ "$SIZE" \ "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" echo " ✅ Updated $YML_FILE" @@ -632,18 +637,21 @@ jobs: if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then echo " Found DMG: $(basename "$DMG_FILE")" - # Calculate SHA256 hash of the stapled DMG - HASH=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + # Calculate SHA256 and SHA512 hashes of the stapled DMG + HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) - echo " SHA256: $HASH" + echo " SHA256: $HASH256" + echo " SHA512: $HASH512" echo " Size: $SIZE" # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ "$VERSION" \ "$(basename "$DMG_FILE")" \ - "$HASH" \ + "$HASH512" \ + "$HASH256" \ "$SIZE" \ "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" echo " ✅ Updated $YML_FILE" diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 3f977381..095ed43d 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -205,11 +205,13 @@ jobs: Write-Host "Using EXE: $($mainExe.Name)" - # Calculate SHA256 hash - $hash = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + # Calculate SHA256 and SHA512 hashes + $sha256 = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA256).Hash.ToLower() + $sha512 = (Get-FileHash -Path $mainExe.FullName -Algorithm SHA512).Hash.ToLower() $size = $mainExe.Length - Write-Host "SHA256: $hash" + Write-Host "SHA256: $sha256" + Write-Host "SHA512: $sha512" Write-Host "Size: $size" # Create new YAML content with correct hashes @@ -219,8 +221,8 @@ jobs: files = @( @{ url = $mainExe.Name - sha512 = $null - sha256 = $hash + sha512 = $sha512 + sha256 = $sha256 size = $size blockMapSize = $null } @@ -231,8 +233,8 @@ jobs: $newYmlContent = "version: $version`n" $newYmlContent += "files:`n" $newYmlContent += " - url: $($mainExe.Name)`n" - $newYmlContent += " sha512: null`n" - $newYmlContent += " sha256: $hash`n" + $newYmlContent += " sha512: $sha512`n" + $newYmlContent += " sha256: $sha256`n" $newYmlContent += " size: $size`n" $newYmlContent += " blockMapSize: null`n" $newYmlContent += "releaseDate: $releaseDate" @@ -403,18 +405,21 @@ jobs: if [[ -n "$APP_IMAGE" && -f "$APP_IMAGE" ]]; then echo " Found AppImage: $(basename "$APP_IMAGE")" - # Calculate SHA256 hash - HASH=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + # Calculate SHA256 and SHA512 hashes + HASH256=$(sha256sum "$APP_IMAGE" | awk '{print $1}') + HASH512=$(sha512sum "$APP_IMAGE" | awk '{print $1}') SIZE=$(stat -c %s "$APP_IMAGE" 2>/dev/null || stat -f %z "$APP_IMAGE" 2>/dev/null) - echo " SHA256: $HASH" + echo " SHA256: $HASH256" + echo " SHA512: $HASH512" echo " Size: $SIZE" # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ "$VERSION" \ "$(basename "$APP_IMAGE")" \ - "$HASH" \ + "$HASH512" \ + "$HASH256" \ "$SIZE" \ "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" echo " ✅ Updated $YML_FILE" @@ -585,18 +590,21 @@ jobs: if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then echo " Found DMG: $(basename "$DMG_FILE")" - # Calculate SHA256 hash of the stapled DMG - HASH=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + # Calculate SHA256 and SHA512 hashes of the stapled DMG + HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) - echo " SHA256: $HASH" + echo " SHA256: $HASH256" + echo " SHA512: $HASH512" echo " Size: $SIZE" # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: null\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ "$VERSION" \ "$(basename "$DMG_FILE")" \ - "$HASH" \ + "$HASH512" \ + "$HASH256" \ "$SIZE" \ "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" echo " ✅ Updated $YML_FILE" From 397ef022f22830ce589c00e6d5da35d83e232056 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Wed, 18 Feb 2026 16:31:54 -0500 Subject: [PATCH 020/178] chore: update RELEASE_NOTES.md for version 1.1.3 with highlights and fixes --- RELEASE_NOTES.md | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 53bc939b..319b6146 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,45 +1,44 @@ -# Power Platform ToolBox 1.1.2 +# Power Platform ToolBox 1.1.3 ## Highlights -- MSAL-based authentication isolates tokens per connection and validates access with WhoAmI for more reliable sign-in -- Troubleshooting modal runs configuration checks and surfaces Sentry diagnostics to speed up support and debugging -- Tool updates show inline progress and accessible status feedback while tools are updating -- Terminal UI hides the Terminal button when no terminals exist and includes additional terminal reliability improvements -- Tool menu adds dynamic feedback and quick DevTools options for tool developers -- Dataverse API expands with solution deployment/import status helpers and relationship associate/disassociate endpoints -- Windows and macOS release pipelines improve signing/notarization handling for more trustworthy installers +- Hardened tool filesystem sandbox so tools can only access user-selected paths and system directories are blocked +- Connection sign-in supports choosing Chrome/Edge plus a specific browser profile to better isolate sessions per connection +- Signed Windows installers (EXE/MSI) via Azure Trusted Signing and repackaged portable ZIPs with signed binaries +- Release metadata now records correct SHA256 and SHA512 hashes for stronger artifact integrity verification +- macOS release pipeline notarizes and staples DMG/ZIP/PKG artifacts with improved signing verification steps +- Dataverse API adds metadata CRUD operations and a `getCSDLDocument` helper for retrieving the OData CSDL document +- Save dialogs support optional file-type filters with extension-based default filter derivation +- Loading overlay positioning is fixed and includes a manual dismiss button ## Fixes -- Dataverse Functions now format parameters correctly, avoiding invocation failures -- Packaged app avoids `ERR_REQUIRE_ESM` issues by properly handling externalized telemetry dependencies -- Modal dialogs no longer remain always-on-top after closing on Windows 11 -- Connection context menu no longer renders behind BrowserViews -- Settings form populates correctly on app reload and avoids duplicate IPC handler registration on macOS window recreation -- macOS notarization scripts handle missing modules/unavailable submission logs and clarify submission/status output -- Authentication token reuse/refresh reduces unexpected expiry prompts with proactive refresh and expiry detection +- Connections: hardened auth/session isolation to reduce cross-connection token and browser profile leakage +- macOS notarization and stapling no longer skips artifacts and handles unavailable submission logs more reliably +- macOS code signing verification avoids premature `spctl --assess` failures before notarization/stapling completes +- Release workflows regenerate Windows update metadata with correct SHA256/SHA512 after signing +- Tool filesystem reads/writes now enforce explicit user-consent access and reject unsafe/system paths +- Connection and toolbox API handling is more robust for multi-connection scenarios and updated connection fields +- Release workflow date formatting is consistent across jobs and platforms ## Developer & Build -- Telemetry identifiers switch from machine ID to install ID for privacy-safe, stable analytics -- Windows packaging adds ARM64 support, MSI targets, and refactored electron-builder configurations -- macOS signing/notarization workflows add submission/status retrieval steps and improved error handling -- `dataverseAPI` types add `deploySolution`, `getImportJobStatus`, and `associate`/`disassociate` helpers -- `toolboxAPI` adds a `fileSystem` API set (path validation + updated publish/selectPath flows) -- Sentry logging helpers and noise reduction improve production diagnostics signal-to-noise +- `dataverseAPI` types expand with metadata CRUD operations and `getCSDLDocument` +- `toolboxAPI.fileSystem.saveFile` supports filters and derives defaults from filename extensions +- Added `BrowserManager` for browser detection and profile enumeration used by interactive auth flows +- Signing/notarization scripts and workflows improved for multi-artifact pipelines and better diagnostics ## Install -- Windows: Power-Platform-ToolBox-1.1.2-Setup.exe -- macOS: Power-Platform-ToolBox-1.1.2.dmg (drag to Applications) -- Linux: Power-Platform-ToolBox-1.1.2.AppImage (chmod +x, then run) +- Windows: Power-Platform-ToolBox-1.1.3-Setup.exe +- macOS: Power-Platform-ToolBox-1.1.3.dmg (drag to Applications) +- Linux: Power-Platform-ToolBox-1.1.3.AppImage (chmod +x, then run) ## Notes - No manual migration needed; existing settings and connections continue to work. -- You may be prompted to sign in again after upgrading because stored tokens and MSAL instances are cleared on app restart. +- Tool developers: filesystem reads/writes now require `toolboxAPI.fileSystem.selectPath()` or `saveFile()` to grant access. ## Full Changelog -https://github.com/PowerPlatformToolBox/desktop-app/compare/v1.1.1...v1.1.2 +https://github.com/PowerPlatformToolBox/desktop-app/compare/v1.1.2...v1.1.3 From 55167b92ab3e6b940329751fe88aa1165d4478cf Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Wed, 18 Feb 2026 20:48:54 -0500 Subject: [PATCH 021/178] fix: update version to 1.0.20 in package.json --- packages/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/package.json b/packages/package.json index 05edf8a6..982c5738 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,6 +1,6 @@ { "name": "@pptb/types", - "version": "1.0.19", + "version": "1.0.20", "description": "TypeScript type definitions for Power Platform ToolBox API", "main": "index.d.ts", "types": "index.d.ts", @@ -25,4 +25,4 @@ "publish:stable": "pnpm publish --access public --tag latest --no-git-checks", "publish:beta": "pnpm publish --access public --tag beta --no-git-checks" } -} \ No newline at end of file +} From e67b760d3af6f0524e02b02973535e8d656192d5 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 09:20:12 -0500 Subject: [PATCH 022/178] Fix Windows and macOS auto-update downloading wrong architecture installer (#397) * Initial plan * Add Windows multi-architecture support to latest.yml generation Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Apply Windows YAML merge fix to nightly-release workflow Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add standalone script to generate merged Windows latest.yml Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add buildScripts/latest.yml to gitignore and remove example file Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add macOS multi-architecture support to latest-mac.yml generation Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Remove legacy build scripts and add new merge scripts for Windows and macOS - Deleted old merge scripts: merge-macos-latest-yml.sh, merge-windows-latest-yml.sh, test-macos-build.sh, verify-build.sh - Added new merge scripts for Windows and macOS with improved functionality and documentation. - Created README for merge scripts detailing usage and troubleshooting. - Implemented new test and verification scripts for macOS builds to ensure proper packaging and structure. * fix: correct path to verify-build.sh script in build workflow * Update buildScripts/sh/merge-latest-yml.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/prod-release.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/nightly-release.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/nightly-release.yml | 215 +++++++++++++---- .github/workflows/prod-release.yml | 215 +++++++++++++---- .gitignore | 4 + .../sh/README-merge-windows-latest-yml.md | 221 ++++++++++++++++++ buildScripts/sh/merge-latest-yml.sh | 169 ++++++++++++++ buildScripts/sh/merge-macos-latest-yml.sh | 179 ++++++++++++++ buildScripts/{ => sh}/test-macos-build.sh | 0 buildScripts/{ => sh}/verify-build.sh | 0 9 files changed, 918 insertions(+), 87 deletions(-) create mode 100644 buildScripts/sh/README-merge-windows-latest-yml.md create mode 100755 buildScripts/sh/merge-latest-yml.sh create mode 100755 buildScripts/sh/merge-macos-latest-yml.sh rename buildScripts/{ => sh}/test-macos-build.sh (100%) rename buildScripts/{ => sh}/verify-build.sh (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10eaf713..5b43d9bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,6 @@ jobs: - name: Verify build output run: | if [ "$RUNNER_OS" != "Windows" ]; then - bash buildScripts/verify-build.sh + bash buildScripts/sh/verify-build.sh fi shell: bash diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index c685629b..0c667436 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -615,51 +615,94 @@ jobs: - name: Regenerate latest-mac.yml with correct SHA256 hashes shell: bash run: | - echo "🔄 Regenerating latest-mac.yml with stapled artifact hashes..." - - # Find all YAML files - YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") - - if [[ -z "$YML_FILES" ]]; then - echo "⚠️ No YAML files found, skipping regeneration" - exit 0 - fi - - for YML_FILE in $YML_FILES; do - echo "Processing: $YML_FILE" - - # Extract version from existing YAML - VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") - - # Find the stapled DMG file in the same directory - DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) - - if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then - echo " Found DMG: $(basename "$DMG_FILE")" - - # Calculate SHA256 and SHA512 hashes of the stapled DMG - HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') - HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') - SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + echo "🔄 Merging macOS x64 and ARM64 latest-mac.yml files..." + + # Find all DMG files + X64_DMG=$(find notarize -name "*-x64-mac.dmg" -type f | head -n 1) + ARM64_DMG=$(find notarize -name "*-arm64-mac.dmg" -type f | head -n 1) + + if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then + echo "⚠️ One or both macOS DMG files not found. Skipping merge." + echo "X64_DMG: $X64_DMG" + echo "ARM64_DMG: $ARM64_DMG" - echo " SHA256: $HASH256" - echo " SHA512: $HASH512" - echo " Size: $SIZE" - - # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ - "$VERSION" \ - "$(basename "$DMG_FILE")" \ - "$HASH512" \ - "$HASH256" \ - "$SIZE" \ - "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" - echo " ✅ Updated $YML_FILE" - else - echo " ⚠️ No DMG found in $(dirname "$YML_FILE")" - fi + # Fallback to single architecture (original behavior) + YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") + if [[ -n "$YML_FILES" ]]; then + for YML_FILE in $YML_FILES; do + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) + if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then + HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" "$(basename "$DMG_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + fi + done + fi + exit 0 + fi + + echo "Found X64 DMG: $(basename "$X64_DMG")" + echo "Found ARM64 DMG: $(basename "$ARM64_DMG")" + + # Find any existing YAML to extract version + EXISTING_YML=$(find notarize -name "latest*.yml" -o -name "*-mac.yml" | head -n 1) + VERSION=$(awk '/^version:/{print $2; exit}' "$EXISTING_YML" 2>/dev/null || echo "unknown") + + echo "Version: $VERSION" + + # Calculate hashes for x64 + echo "🔐 Calculating hashes for x64 DMG..." + X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') + X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') + X64_SIZE=$(stat -f '%z' "$X64_DMG" 2>/dev/null || stat -c '%s' "$X64_DMG" 2>/dev/null) + + echo " SHA256: $X64_SHA256" + echo " SHA512: $X64_SHA512" + echo " Size: $X64_SIZE" + + # Calculate hashes for ARM64 + echo "🔐 Calculating hashes for ARM64 DMG..." + ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') + ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') + ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG" 2>/dev/null || stat -c '%s' "$ARM64_DMG" 2>/dev/null) + + echo " SHA256: $ARM64_SHA256" + echo " SHA512: $ARM64_SHA512" + echo " Size: $ARM64_SIZE" + + # Create merged YAML with both architectures + MERGED_YML="notarize/latest-mac.yml" + cat > "$MERGED_YML" << EOF + version: $VERSION + files: + - url: $(basename "$X64_DMG") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_DMG") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null + releaseDate: $(date -u +'%Y-%m-%dT%H:%M:%S.000Z') + EOF + + echo "" + echo "✅ Merged latest-mac.yml created:" + cat "$MERGED_YML" + + # Remove any other YAML files in subdirectories to prevent conflicts + find notarize -name "latest*.yml" -o -name "*-mac.yml" | while read yml; do + if [[ "$yml" != "$MERGED_YML" ]]; then + rm -f "$yml" + echo "Removed: $yml" + fi done - + echo "✅ Regeneration complete" - name: Upload stapled macOS artifacts @@ -695,11 +738,97 @@ jobs: - name: Display structure of downloaded files run: ls -R artifacts + - name: Merge Windows latest.yml files + run: | + echo "🔄 Merging Windows x64 and ARM64 latest.yml files..." + + # Find the Windows YAML files + X64_YML=$(find artifacts/windows-x64-build -name "latest.yml" 2>/dev/null || echo "") + ARM64_YML=$(find artifacts/windows-arm64-build -name "latest.yml" 2>/dev/null || echo "") + + if [[ -z "$X64_YML" || -z "$ARM64_YML" ]]; then + echo "⚠️ One or both Windows YAML files not found. Skipping merge." + echo "X64_YML: $X64_YML" + echo "ARM64_YML: $ARM64_YML" + exit 0 + fi + + echo "Found X64 YAML: $X64_YML" + echo "Found ARM64 YAML: $ARM64_YML" + + # Extract version and release date from x64 YAML (should be the same for both) + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$X64_YML" || echo "unknown") + RELEASE_DATE=$(grep -oP 'releaseDate:\s+\K.+' "$X64_YML" || date -u +'%Y-%m-%dT%H:%M:%S.000Z') + + echo "Version: $VERSION" + echo "Release Date: $RELEASE_DATE" + + # Find the EXE files in each artifact directory + X64_EXE=$(find artifacts/windows-x64-build -name "*-x64-win.exe" -type f | head -n 1) + ARM64_EXE=$(find artifacts/windows-arm64-build -name "*-arm64-win.exe" -type f | head -n 1) + + if [[ -z "$X64_EXE" || -z "$ARM64_EXE" ]]; then + echo "❌ Could not find both x64 and ARM64 EXE files" + echo "X64_EXE: $X64_EXE" + echo "ARM64_EXE: $ARM64_EXE" + exit 1 + fi + + echo "Found X64 EXE: $(basename "$X64_EXE")" + echo "Found ARM64 EXE: $(basename "$ARM64_EXE")" + + # Calculate hashes for x64 + X64_SHA256=$(sha256sum "$X64_EXE" | awk '{print $1}') + X64_SHA512=$(sha512sum "$X64_EXE" | awk '{print $1}') + X64_SIZE=$(stat -c %s "$X64_EXE" 2>/dev/null || stat -f %z "$X64_EXE" 2>/dev/null) + + echo "X64 SHA256: $X64_SHA256" + echo "X64 SHA512: $X64_SHA512" + echo "X64 Size: $X64_SIZE" + + # Calculate hashes for ARM64 + ARM64_SHA256=$(sha256sum "$ARM64_EXE" | awk '{print $1}') + ARM64_SHA512=$(sha512sum "$ARM64_EXE" | awk '{print $1}') + ARM64_SIZE=$(stat -c %s "$ARM64_EXE" 2>/dev/null || stat -f %z "$ARM64_EXE" 2>/dev/null) + + echo "ARM64 SHA256: $ARM64_SHA256" + echo "ARM64 SHA512: $ARM64_SHA512" + echo "ARM64 Size: $ARM64_SIZE" + + # Create merged YAML with both architectures + MERGED_YML="artifacts/latest.yml" + cat > "$MERGED_YML" << EOF + version: $VERSION + files: + - url: $(basename "$X64_EXE") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_EXE") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null + releaseDate: $RELEASE_DATE + EOF + + echo "" + echo "✅ Merged latest.yml created:" + cat "$MERGED_YML" + + # Remove the individual YAML files so they don't get uploaded + rm -f "$X64_YML" "$ARM64_YML" + echo "" + echo "✅ Individual YAML files removed" + shell: bash + - name: Prepare release files run: | echo "📦 Preparing release files..." mkdir -p release-files + # Copy all release artifacts (excluding individual Windows YAML files which were removed) find artifacts -type f \( -name "*.AppImage" -o -name "*.dmg" -o -name "*.zip" -o -name "*.exe" -o -name "*.msi" -o -name "*.pkg" -o -name "*.snap" -o -name "*.deb" -o -name "*.rpm" -o -name "latest*.yml" \) -exec cp {} release-files/ \; echo "✅ Release files prepared" diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 095ed43d..c9d84fb0 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -568,51 +568,94 @@ jobs: - name: Regenerate latest-mac.yml with correct SHA256 hashes shell: bash run: | - echo "🔄 Regenerating latest-mac.yml with stapled artifact hashes..." - - # Find all YAML files - YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") - - if [[ -z "$YML_FILES" ]]; then - echo "⚠️ No YAML files found, skipping regeneration" - exit 0 - fi - - for YML_FILE in $YML_FILES; do - echo "Processing: $YML_FILE" - - # Extract version from existing YAML - VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") - - # Find the stapled DMG file in the same directory - DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) - - if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then - echo " Found DMG: $(basename "$DMG_FILE")" - - # Calculate SHA256 and SHA512 hashes of the stapled DMG - HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') - HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') - SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + echo "🔄 Merging macOS x64 and ARM64 latest-mac.yml files..." + + # Find all DMG files + X64_DMG=$(find notarize -name "*-x64-mac.dmg" -type f | head -n 1) + ARM64_DMG=$(find notarize -name "*-arm64-mac.dmg" -type f | head -n 1) + + if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then + echo "⚠️ One or both macOS DMG files not found. Skipping merge." + echo "X64_DMG: $X64_DMG" + echo "ARM64_DMG: $ARM64_DMG" - echo " SHA256: $HASH256" - echo " SHA512: $HASH512" - echo " Size: $SIZE" - - # Create new YAML with correct hashes using printf to avoid YAML parsing issues - printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ - "$VERSION" \ - "$(basename "$DMG_FILE")" \ - "$HASH512" \ - "$HASH256" \ - "$SIZE" \ - "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" - echo " ✅ Updated $YML_FILE" - else - echo " ⚠️ No DMG found in $(dirname "$YML_FILE")" - fi + # Fallback to single architecture (original behavior) + YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") + if [[ -n "$YML_FILES" ]]; then + for YML_FILE in $YML_FILES; do + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") + DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) + if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then + HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" "$(basename "$DMG_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + fi + done + fi + exit 0 + fi + + echo "Found X64 DMG: $(basename "$X64_DMG")" + echo "Found ARM64 DMG: $(basename "$ARM64_DMG")" + + # Find any existing YAML to extract version + EXISTING_YML=$(find notarize -name "latest*.yml" -o -name "*-mac.yml" | head -n 1) + VERSION=$(if [ -n "$EXISTING_YML" ]; then awk '/^version:[[:space:]]*/ {print $2; exit}' "$EXISTING_YML"; fi 2>/dev/null || echo "unknown") + + echo "Version: $VERSION" + + # Calculate hashes for x64 + echo "🔐 Calculating hashes for x64 DMG..." + X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') + X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') + X64_SIZE=$(stat -f '%z' "$X64_DMG" 2>/dev/null || stat -c '%s' "$X64_DMG" 2>/dev/null) + + echo " SHA256: $X64_SHA256" + echo " SHA512: $X64_SHA512" + echo " Size: $X64_SIZE" + + # Calculate hashes for ARM64 + echo "🔐 Calculating hashes for ARM64 DMG..." + ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') + ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') + ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG" 2>/dev/null || stat -c '%s' "$ARM64_DMG" 2>/dev/null) + + echo " SHA256: $ARM64_SHA256" + echo " SHA512: $ARM64_SHA512" + echo " Size: $ARM64_SIZE" + + # Create merged YAML with both architectures + MERGED_YML="notarize/latest-mac.yml" + cat > "$MERGED_YML" << EOF + version: $VERSION + files: + - url: $(basename "$X64_DMG") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_DMG") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null + releaseDate: $(date -u +'%Y-%m-%dT%H:%M:%S.000Z') + EOF + + echo "" + echo "✅ Merged latest-mac.yml created:" + cat "$MERGED_YML" + + # Remove any other YAML files in subdirectories to prevent conflicts + find notarize -name "latest*.yml" -o -name "*-mac.yml" | while read yml; do + if [[ "$yml" != "$MERGED_YML" ]]; then + rm -f "$yml" + echo "Removed: $yml" + fi done - + echo "✅ Regeneration complete" - name: Upload stapled macOS artifacts @@ -652,11 +695,97 @@ jobs: - name: Display structure of downloaded files run: ls -R artifacts + - name: Merge Windows latest.yml files + run: | + echo "🔄 Merging Windows x64 and ARM64 latest.yml files..." + + # Find the Windows YAML files + X64_YML=$(find artifacts/windows-x64-release -name "latest.yml" 2>/dev/null || echo "") + ARM64_YML=$(find artifacts/windows-arm64-release -name "latest.yml" 2>/dev/null || echo "") + + if [[ -z "$X64_YML" || -z "$ARM64_YML" ]]; then + echo "⚠️ One or both Windows YAML files not found. Skipping merge." + echo "X64_YML: $X64_YML" + echo "ARM64_YML: $ARM64_YML" + exit 0 + fi + + echo "Found X64 YAML: $X64_YML" + echo "Found ARM64 YAML: $ARM64_YML" + + # Extract version and release date from x64 YAML (should be the same for both) + VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$X64_YML" || echo "unknown") + RELEASE_DATE=$(grep -oP 'releaseDate:\s+\K.+' "$X64_YML" || date -u +'%Y-%m-%dT%H:%M:%S.000Z') + + echo "Version: $VERSION" + echo "Release Date: $RELEASE_DATE" + + # Find the EXE files in each artifact directory + X64_EXE=$(find artifacts/windows-x64-release -name "*-x64-win.exe" -type f | head -n 1) + ARM64_EXE=$(find artifacts/windows-arm64-release -name "*-arm64-win.exe" -type f | head -n 1) + + if [[ -z "$X64_EXE" || -z "$ARM64_EXE" ]]; then + echo "❌ Could not find both x64 and ARM64 EXE files" + echo "X64_EXE: $X64_EXE" + echo "ARM64_EXE: $ARM64_EXE" + exit 1 + fi + + echo "Found X64 EXE: $(basename "$X64_EXE")" + echo "Found ARM64 EXE: $(basename "$ARM64_EXE")" + + # Calculate hashes for x64 + X64_SHA256=$(sha256sum "$X64_EXE" | awk '{print $1}') + X64_SHA512=$(sha512sum "$X64_EXE" | awk '{print $1}') + X64_SIZE=$(stat -c %s "$X64_EXE" 2>/dev/null || stat -f %z "$X64_EXE" 2>/dev/null) + + echo "X64 SHA256: $X64_SHA256" + echo "X64 SHA512: $X64_SHA512" + echo "X64 Size: $X64_SIZE" + + # Calculate hashes for ARM64 + ARM64_SHA256=$(sha256sum "$ARM64_EXE" | awk '{print $1}') + ARM64_SHA512=$(sha512sum "$ARM64_EXE" | awk '{print $1}') + ARM64_SIZE=$(stat -c %s "$ARM64_EXE" 2>/dev/null || stat -f %z "$ARM64_EXE" 2>/dev/null) + + echo "ARM64 SHA256: $ARM64_SHA256" + echo "ARM64 SHA512: $ARM64_SHA512" + echo "ARM64 Size: $ARM64_SIZE" + + # Create merged YAML with both architectures + MERGED_YML="artifacts/latest.yml" + cat > "$MERGED_YML" << EOF + version: $VERSION + files: + - url: $(basename "$X64_EXE") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_EXE") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null + releaseDate: $RELEASE_DATE + EOF + + echo "" + echo "✅ Merged latest.yml created:" + cat "$MERGED_YML" + + # Remove the individual YAML files so they don't get uploaded + rm -f "$X64_YML" "$ARM64_YML" + echo "" + echo "✅ Individual YAML files removed" + shell: bash + - name: Prepare release files run: | echo "📦 Preparing release files..." mkdir -p release-files + # Copy all release artifacts (excluding individual Windows YAML files which were removed) find artifacts -type f \( -name "*.AppImage" -o -name "*.dmg" -o -name "*.zip" -o -name "*.exe" -o -name "*.msi" -o -name "*.pkg" -o -name "*.snap" -o -name "*.deb" -o -name "*.rpm" -o -name "latest*.yml" \) -exec cp {} release-files/ \; echo "✅ Release files prepared" diff --git a/.gitignore b/.gitignore index bd1e54d3..d9f00490 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,10 @@ dist/ package-lock.json .vscode/settings.json +# Generated YAML files from merge scripts (example outputs) +buildScripts/*/latest.yml +buildScripts/*/latest-mac.yml + # Any macOS Certificate files *.cer *.p12 diff --git a/buildScripts/sh/README-merge-windows-latest-yml.md b/buildScripts/sh/README-merge-windows-latest-yml.md new file mode 100644 index 00000000..01ed16c1 --- /dev/null +++ b/buildScripts/sh/README-merge-windows-latest-yml.md @@ -0,0 +1,221 @@ +# Merge Windows/macOS latest.yml Scripts + +## Purpose + +These scripts generate properly formatted update metadata files containing both x64 and ARM64 installers for electron-updater auto-update functionality. + +Use these when you need to manually fix a GitHub release's update files without re-running the entire build pipeline. + +## The Problem They Solve + +When Windows/macOS x64 and ARM64 builds upload separate YAML files, only one architecture is included in the final update metadata. This causes electron-updater to only see one architecture, leading to users downloading the wrong installer. + +The merged YAML files contain both architectures, allowing electron-updater to automatically select the correct one based on the user's system architecture. + +## Prerequisites + +- `bash` shell (Linux, macOS, WSL, or Git Bash on Windows) +- `curl` (for downloading from GitHub releases) +- `sha256sum` and `sha512sum` (for hash calculation on Linux) +- `shasum` (for hash calculation on macOS) +- `gh` CLI (optional, for uploading to GitHub) + +## Available Scripts + +### Windows: `merge-windows-latest-yml.sh` + +Generates `latest.yml` for Windows updates (EXE installers). + +### macOS: `merge-macos-latest-yml.sh` + +Generates `latest-mac.yml` for macOS updates (DMG installers). + +## Usage + +### Option 1: Download from Existing GitHub Release + +Use this to fix an already-published release (like v1.1.3): + +**Windows:** +```bash +cd buildScripts +./merge-windows-latest-yml.sh 1.1.3 v1.1.3 +gh release upload v1.1.3 latest.yml --clobber +``` + +**macOS:** +```bash +cd buildScripts +./merge-macos-latest-yml.sh 1.1.3 v1.1.3 +gh release upload v1.1.3 latest-mac.yml --clobber +``` + +This will: +1. Download both x64 and ARM64 installers from the v1.1.3 GitHub release +2. Calculate SHA256/SHA512 hashes +3. Generate a merged YAML file in the current directory + +### Option 2: Use Local Build Files + +Use this when you have local build artifacts: + +**Windows:** +```bash +cd buildScripts +./merge-windows-latest-yml.sh 1.1.3 +``` + +**macOS:** +```bash +cd buildScripts +./merge-macos-latest-yml.sh 1.1.3 +``` + +This will look for installer files in the `build/` directory. + +## Output + +The scripts create YAML files in the current directory: + +**Windows (`latest.yml`):** +```yaml +version: 1.1.3 +files: + - url: Power-Platform-ToolBox-1.1.3-x64-win.exe + sha512: + sha256: + size: 83575696 + blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-arm64-win.exe + sha512: + sha256: + size: 86587224 + blockMapSize: null +releaseDate: 2026-02-19T10:54:00.000Z +``` + +**macOS (`latest-mac.yml`):** +```yaml +version: 1.1.3 +files: + - url: Power-Platform-ToolBox-1.1.3-x64-mac.dmg + sha512: + sha256: + size: 110450111 + blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-arm64-mac.dmg + sha512: + sha256: + size: 103969103 + blockMapSize: null +releaseDate: 2026-02-19T10:54:00.000Z +``` + +## Uploading to GitHub Release + +### Using GitHub CLI + +**Windows:** +```bash +gh release upload v1.1.3 latest.yml --clobber +``` + +**macOS:** +```bash +gh release upload v1.1.3 latest-mac.yml --clobber +``` + +The `--clobber` flag replaces the existing file. + +### Using GitHub Web UI + +1. Go to https://github.com/PowerPlatformToolBox/desktop-app/releases/edit/v1.1.3 +2. Scroll to the release assets section +3. Delete the existing `latest.yml` or `latest-mac.yml` file +4. Upload the new file generated by the script + +## Fixing v1.1.3 Release + +To fix the current v1.1.3 release for both platforms: + +**Windows:** +```bash +cd buildScripts +./merge-windows-latest-yml.sh 1.1.3 v1.1.3 +gh release upload v1.1.3 latest.yml --clobber +``` + +**macOS:** +```bash +cd buildScripts +./merge-macos-latest-yml.sh 1.1.3 v1.1.3 +gh release upload v1.1.3 latest-mac.yml --clobber +``` + +After uploading, users who check for updates will receive the correct installer for their architecture. + +## How It Works + +1. **Locates Installers**: Finds or downloads both x64 and ARM64 installers (EXE for Windows, DMG for macOS) +2. **Calculates Hashes**: Computes SHA256 and SHA512 checksums for integrity verification +3. **Generates YAML**: Creates a YAML file with both file entries +4. **Architecture Detection**: electron-updater automatically selects the correct installer + +## Architecture Detection + +The electron-updater library automatically detects the user's architecture: + +**Windows:** +- On x64 systems: `process.arch === "x64"` → downloads `*-x64-win.exe` +- On ARM64 systems: `process.arch === "arm64"` → downloads `*-arm64-win.exe` + +**macOS:** +- On Intel Macs: `process.arch === "x64"` → downloads `*-x64-mac.dmg` +- On Apple Silicon: `process.arch === "arm64"` → downloads `*-arm64-mac.dmg` + +This is done by matching the architecture string in the filename. + +## Troubleshooting + +### "Failed to download x64 installer/DMG" + +The release tag or version doesn't exist on GitHub. Check: +- The release tag is correct (e.g., `v1.1.3` not `1.1.3`) +- The release has been published (not a draft) +- The installers have been uploaded to the release + +### "Could not find x64 installer/DMG in build/ directory" + +When using local files, ensure you've run the build first: + +**Windows:** +```bash +pnpm run build +pnpm run package:win # For x64 +pnpm run package:win-arm64 # For ARM64 +``` + +**macOS:** +```bash +pnpm run build +pnpm run package:mac # Builds both x64 and ARM64 +``` + +### "sha256sum: command not found" (macOS) + +On macOS, use `shasum` which is already included. The scripts handle this automatically. + +If you get errors, you may need to install coreutils: + +```bash +brew install coreutils +``` + +## Related Files + +- `.github/workflows/prod-release.yml` - Production release workflow (automated merge for both Windows and macOS) +- `.github/workflows/nightly-release.yml` - Nightly release workflow (automated merge for both Windows and macOS) + +## Future Enhancements + +Starting with v1.1.4 and later, the GitHub Actions workflows automatically merge both Windows and macOS YAML files, so manual intervention won't be needed for new releases. diff --git a/buildScripts/sh/merge-latest-yml.sh b/buildScripts/sh/merge-latest-yml.sh new file mode 100755 index 00000000..7e7f805e --- /dev/null +++ b/buildScripts/sh/merge-latest-yml.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# +# Merge Windows latest.yml Script +# +# This script generates a merged latest.yml file containing both x64 and ARM64 +# Windows installers for electron-updater auto-update functionality. +# +# Usage: +# ./merge-latest-yml.sh [release-tag] +# +# Examples: +# # Generate for v1.1.3 (downloads from GitHub release) +# ./merge-latest-yml.sh 1.1.3 v1.1.3 +# +# # Generate for local files in build/ directory +# ./merge-latest-yml.sh 1.1.3 +# +# The script will: +# 1. Download or locate both x64 and ARM64 Windows EXE files +# 2. Calculate SHA256 and SHA512 hashes +# 3. Generate a merged latest.yml with both architectures +# +# Output: latest.yml (in current directory) +# + +set -e + +VERSION="${1}" +RELEASE_TAG="${2}" + +if [[ -z "$VERSION" ]]; then + echo "Usage: $0 [release-tag]" + echo "" + echo "Examples:" + echo " $0 1.1.3 v1.1.3 # Download from GitHub release" + echo " $0 1.1.3 # Use local files from build/ directory" + exit 1 +fi + +echo "=== Windows latest.yml Merger ===" +echo "Version: $VERSION" +echo "" + +# Temporary directory for downloads +TEMP_DIR=$(mktemp -d) +trap 'rm -rf "$TEMP_DIR"' EXIT + +# Function to find or download x64 EXE +find_x64_exe() { + if [[ -n "$RELEASE_TAG" ]]; then + echo "📥 Downloading x64 installer from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-x64-win.exe" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-x64-win.exe" + + if curl -sL -f -o "$dest" "$url"; then + echo "$dest" + else + echo "❌ Failed to download x64 installer from $url" >&2 + return 1 + fi + else + echo "🔍 Looking for x64 installer in build/ directory..." >&2 + local exe=$(find build -name "*-x64-win.exe" -type f 2>/dev/null | head -n 1) + if [[ -n "$exe" && -f "$exe" ]]; then + echo "$exe" + else + echo "❌ Could not find x64 installer in build/ directory" >&2 + return 1 + fi + fi +} + +# Function to find or download ARM64 EXE +find_arm64_exe() { + if [[ -n "$RELEASE_TAG" ]]; then + echo "📥 Downloading ARM64 installer from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-arm64-win.exe" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-arm64-win.exe" + + if curl -sL -f -o "$dest" "$url"; then + echo "$dest" + else + echo "❌ Failed to download ARM64 installer from $url" >&2 + return 1 + fi + else + echo "🔍 Looking for ARM64 installer in build/ directory..." >&2 + local exe=$(find build -name "*-arm64-win.exe" -type f 2>/dev/null | head -n 1) + if [[ -n "$exe" && -f "$exe" ]]; then + echo "$exe" + else + echo "❌ Could not find ARM64 installer in build/ directory" >&2 + return 1 + fi + fi +} + +# Find/download the EXE files +X64_EXE=$(find_x64_exe) +ARM64_EXE=$(find_arm64_exe) + +if [[ -z "$X64_EXE" || -z "$ARM64_EXE" ]]; then + echo "❌ Could not find both installers" + exit 1 +fi + +echo "" +echo "✅ Found x64 installer: $(basename "$X64_EXE")" +echo "✅ Found ARM64 installer: $(basename "$ARM64_EXE")" +echo "" + +# Calculate hashes for x64 +echo "🔐 Calculating hashes for x64 installer..." +X64_SHA256=$(sha256sum "$X64_EXE" | awk '{print $1}') +X64_SHA512=$(sha512sum "$X64_EXE" | awk '{print $1}') +X64_SIZE=$(stat -c %s "$X64_EXE" 2>/dev/null || stat -f %z "$X64_EXE" 2>/dev/null) + +echo " SHA256: $X64_SHA256" +echo " SHA512: $X64_SHA512" +echo " Size: $X64_SIZE bytes" +echo "" + +# Calculate hashes for ARM64 +echo "🔐 Calculating hashes for ARM64 installer..." +ARM64_SHA256=$(sha256sum "$ARM64_EXE" | awk '{print $1}') +ARM64_SHA512=$(sha512sum "$ARM64_EXE" | awk '{print $1}') +ARM64_SIZE=$(stat -c %s "$ARM64_EXE" 2>/dev/null || stat -f %z "$ARM64_EXE" 2>/dev/null) + +echo " SHA256: $ARM64_SHA256" +echo " SHA512: $ARM64_SHA512" +echo " Size: $ARM64_SIZE bytes" +echo "" + +# Generate release date in ISO 8601 format +RELEASE_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S.000Z') + +# Create merged latest.yml +OUTPUT_FILE="latest.yml" + +cat > "$OUTPUT_FILE" << EOF +version: $VERSION +files: + - url: $(basename "$X64_EXE") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_EXE") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null +releaseDate: $RELEASE_DATE +EOF + +echo "✅ Merged latest.yml created successfully!" +echo "" +echo "=== Output: $OUTPUT_FILE ===" +cat "$OUTPUT_FILE" +echo "" +echo "=== Next Steps ===" +echo "1. Review the generated latest.yml file above" +echo "2. Upload it to the GitHub release, replacing the existing latest.yml" +echo "" +echo "To upload to GitHub release manually:" +echo " gh release upload $RELEASE_TAG $OUTPUT_FILE --clobber" +echo "" +echo "Or use the GitHub web UI:" +echo " https://github.com/PowerPlatformToolBox/desktop-app/releases/edit/$RELEASE_TAG" diff --git a/buildScripts/sh/merge-macos-latest-yml.sh b/buildScripts/sh/merge-macos-latest-yml.sh new file mode 100755 index 00000000..231c6a7b --- /dev/null +++ b/buildScripts/sh/merge-macos-latest-yml.sh @@ -0,0 +1,179 @@ +#!/bin/bash +# +# Merge macOS latest-mac.yml Script +# +# This script generates a merged latest-mac.yml file containing both x64 and ARM64 +# macOS installers for electron-updater auto-update functionality. +# +# Usage: +# ./merge-macos-latest-yml.sh [release-tag] +# +# Examples: +# # Generate for v1.1.3 (downloads from GitHub release) +# ./merge-macos-latest-yml.sh 1.1.3 v1.1.3 +# +# # Generate for local files in build/ directory +# ./merge-macos-latest-yml.sh 1.1.3 +# +# The script will: +# 1. Download or locate both x64 and ARM64 macOS DMG files +# 2. Calculate SHA256 and SHA512 hashes +# 3. Generate a merged latest-mac.yml with both architectures +# +# Output: latest-mac.yml (in current directory) +# + +set -e + +VERSION="${1}" +RELEASE_TAG="${2}" + +if [[ -z "$VERSION" ]]; then + echo "Usage: $0 [release-tag]" + echo "" + echo "Examples:" + echo " $0 1.1.3 v1.1.3 # Download from GitHub release" + echo " $0 1.1.3 # Use local files from build/ directory" + exit 1 +fi + +echo "=== macOS latest-mac.yml Merger ===" +echo "Version: $VERSION" +echo "" + +# Temporary directory for downloads +TEMP_DIR=$(mktemp -d) +trap 'rm -rf "$TEMP_DIR"' EXIT + +# Function to find or download x64 DMG +find_x64_dmg() { + if [[ -n "$RELEASE_TAG" ]]; then + echo "📥 Downloading x64 DMG from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-x64-mac.dmg" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-x64-mac.dmg" + + if curl -sL -f -o "$dest" "$url"; then + echo "$dest" + else + echo "❌ Failed to download x64 DMG from $url" >&2 + return 1 + fi + else + echo "🔍 Looking for x64 DMG in build/ directory..." >&2 + local dmg=$(find build -name "*-x64-mac.dmg" -type f 2>/dev/null | head -n 1) + if [[ -n "$dmg" && -f "$dmg" ]]; then + echo "$dmg" + else + echo "❌ Could not find x64 DMG in build/ directory" >&2 + return 1 + fi + fi +} + +# Function to find or download ARM64 DMG +find_arm64_dmg() { + if [[ -n "$RELEASE_TAG" ]]; then + echo "📥 Downloading ARM64 DMG from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-arm64-mac.dmg" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-arm64-mac.dmg" + + if curl -sL -f -o "$dest" "$url"; then + echo "$dest" + else + echo "❌ Failed to download ARM64 DMG from $url" >&2 + return 1 + fi + else + echo "🔍 Looking for ARM64 DMG in build/ directory..." >&2 + local dmg=$(find build -name "*-arm64-mac.dmg" -type f 2>/dev/null | head -n 1) + if [[ -n "$dmg" && -f "$dmg" ]]; then + echo "$dmg" + else + echo "❌ Could not find ARM64 DMG in build/ directory" >&2 + return 1 + fi + fi +} + +# Find/download the DMG files +X64_DMG=$(find_x64_dmg) +ARM64_DMG=$(find_arm64_dmg) + +if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then + echo "❌ Could not find both DMG files" + exit 1 +fi + +echo "" +echo "✅ Found x64 DMG: $(basename "$X64_DMG")" +echo "✅ Found ARM64 DMG: $(basename "$ARM64_DMG")" +echo "" + +# Calculate hashes for x64 +echo "🔐 Calculating hashes for x64 DMG..." +X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') +X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') +# Try macOS stat first, then Linux stat +if stat -f '%z' "$X64_DMG" >/dev/null 2>&1; then + X64_SIZE=$(stat -f '%z' "$X64_DMG") +else + X64_SIZE=$(stat -c '%s' "$X64_DMG") +fi + +echo " SHA256: $X64_SHA256" +echo " SHA512: $X64_SHA512" +echo " Size: $X64_SIZE bytes" +echo "" + +# Calculate hashes for ARM64 +echo "🔐 Calculating hashes for ARM64 DMG..." +ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') +ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') +# Try macOS stat first, then Linux stat +if stat -f '%z' "$ARM64_DMG" >/dev/null 2>&1; then + ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG") +else + ARM64_SIZE=$(stat -c '%s' "$ARM64_DMG") +fi + +echo " SHA256: $ARM64_SHA256" +echo " SHA512: $ARM64_SHA512" +echo " Size: $ARM64_SIZE bytes" +echo "" + +# Generate release date in ISO 8601 format +RELEASE_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S.000Z') + +# Create merged latest-mac.yml +OUTPUT_FILE="latest-mac.yml" + +cat > "$OUTPUT_FILE" << EOF +version: $VERSION +files: + - url: $(basename "$X64_DMG") + sha512: $X64_SHA512 + sha256: $X64_SHA256 + size: $X64_SIZE + blockMapSize: null + - url: $(basename "$ARM64_DMG") + sha512: $ARM64_SHA512 + sha256: $ARM64_SHA256 + size: $ARM64_SIZE + blockMapSize: null +releaseDate: $RELEASE_DATE +EOF + +echo "✅ Merged latest-mac.yml created successfully!" +echo "" +echo "=== Output: $OUTPUT_FILE ===" +cat "$OUTPUT_FILE" +echo "" +echo "=== Next Steps ===" +echo "1. Review the generated latest-mac.yml file above" +echo "2. Upload it to the GitHub release, replacing the existing latest-mac.yml" +echo "" +echo "To upload to GitHub release manually:" +echo " gh release upload $RELEASE_TAG $OUTPUT_FILE --clobber" +echo "" +echo "Or use the GitHub web UI:" +echo " https://github.com/PowerPlatformToolBox/desktop-app/releases/edit/$RELEASE_TAG" diff --git a/buildScripts/test-macos-build.sh b/buildScripts/sh/test-macos-build.sh similarity index 100% rename from buildScripts/test-macos-build.sh rename to buildScripts/sh/test-macos-build.sh diff --git a/buildScripts/verify-build.sh b/buildScripts/sh/verify-build.sh similarity index 100% rename from buildScripts/verify-build.sh rename to buildScripts/sh/verify-build.sh From 4114d571061371c5a5ec10d7da2f699ac9a7243c Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Thu, 19 Feb 2026 10:41:09 -0500 Subject: [PATCH 023/178] fix: update macOS release scripts to use ZIP artifacts instead of DMG files --- .github/workflows/nightly-release.yml | 110 ++++++++--------- .github/workflows/prod-release.yml | 110 ++++++++--------- .../sh/README-merge-windows-latest-yml.md | 66 +++++++---- buildScripts/sh/merge-macos-latest-yml.sh | 112 +++++++++--------- 4 files changed, 205 insertions(+), 193 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 0c667436..95721351 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -616,85 +616,85 @@ jobs: shell: bash run: | echo "🔄 Merging macOS x64 and ARM64 latest-mac.yml files..." - - # Find all DMG files - X64_DMG=$(find notarize -name "*-x64-mac.dmg" -type f | head -n 1) - ARM64_DMG=$(find notarize -name "*-arm64-mac.dmg" -type f | head -n 1) - - if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then - echo "⚠️ One or both macOS DMG files not found. Skipping merge." - echo "X64_DMG: $X64_DMG" - echo "ARM64_DMG: $ARM64_DMG" + + # Find all ZIP files (required for mac auto-update) + X64_ZIP=$(find notarize -name "*-x64-mac.zip" -type f | head -n 1) + ARM64_ZIP=$(find notarize -name "*-arm64-mac.zip" -type f | head -n 1) + + if [[ -z "$X64_ZIP" || -z "$ARM64_ZIP" ]]; then + echo "⚠️ One or both macOS ZIP files not found. Skipping merge." + echo "X64_ZIP: $X64_ZIP" + echo "ARM64_ZIP: $ARM64_ZIP" # Fallback to single architecture (original behavior) YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") if [[ -n "$YML_FILES" ]]; then for YML_FILE in $YML_FILES; do VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") - DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) - if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then - HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') - HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') - SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + ZIP_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.zip" | head -n 1) + if [[ -n "$ZIP_FILE" && -f "$ZIP_FILE" ]]; then + HASH256=$(shasum -a 256 "$ZIP_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$ZIP_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$ZIP_FILE" 2>/dev/null || stat -c '%s' "$ZIP_FILE" 2>/dev/null) printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ - "$VERSION" "$(basename "$DMG_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + "$VERSION" "$(basename "$ZIP_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" fi done fi exit 0 fi - - echo "Found X64 DMG: $(basename "$X64_DMG")" - echo "Found ARM64 DMG: $(basename "$ARM64_DMG")" - + + echo "Found X64 ZIP: $(basename "$X64_ZIP")" + echo "Found ARM64 ZIP: $(basename "$ARM64_ZIP")" + # Find any existing YAML to extract version EXISTING_YML=$(find notarize -name "latest*.yml" -o -name "*-mac.yml" | head -n 1) VERSION=$(awk '/^version:/{print $2; exit}' "$EXISTING_YML" 2>/dev/null || echo "unknown") - + echo "Version: $VERSION" - - # Calculate hashes for x64 - echo "🔐 Calculating hashes for x64 DMG..." - X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') - X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') - X64_SIZE=$(stat -f '%z' "$X64_DMG" 2>/dev/null || stat -c '%s' "$X64_DMG" 2>/dev/null) - + + # Calculate hashes for x64 ZIP + echo "🔐 Calculating hashes for x64 ZIP..." + X64_SHA256=$(shasum -a 256 "$X64_ZIP" | awk '{print $1}') + X64_SHA512=$(shasum -a 512 "$X64_ZIP" | awk '{print $1}') + X64_SIZE=$(stat -f '%z' "$X64_ZIP" 2>/dev/null || stat -c '%s' "$X64_ZIP" 2>/dev/null) + echo " SHA256: $X64_SHA256" echo " SHA512: $X64_SHA512" echo " Size: $X64_SIZE" - - # Calculate hashes for ARM64 - echo "🔐 Calculating hashes for ARM64 DMG..." - ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') - ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') - ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG" 2>/dev/null || stat -c '%s' "$ARM64_DMG" 2>/dev/null) - + + # Calculate hashes for ARM64 ZIP + echo "🔐 Calculating hashes for ARM64 ZIP..." + ARM64_SHA256=$(shasum -a 256 "$ARM64_ZIP" | awk '{print $1}') + ARM64_SHA512=$(shasum -a 512 "$ARM64_ZIP" | awk '{print $1}') + ARM64_SIZE=$(stat -f '%z' "$ARM64_ZIP" 2>/dev/null || stat -c '%s' "$ARM64_ZIP" 2>/dev/null) + echo " SHA256: $ARM64_SHA256" echo " SHA512: $ARM64_SHA512" echo " Size: $ARM64_SIZE" - + # Create merged YAML with both architectures MERGED_YML="notarize/latest-mac.yml" cat > "$MERGED_YML" << EOF version: $VERSION files: - - url: $(basename "$X64_DMG") + - url: $(basename "$X64_ZIP") sha512: $X64_SHA512 sha256: $X64_SHA256 size: $X64_SIZE blockMapSize: null - - url: $(basename "$ARM64_DMG") + - url: $(basename "$ARM64_ZIP") sha512: $ARM64_SHA512 sha256: $ARM64_SHA256 size: $ARM64_SIZE blockMapSize: null releaseDate: $(date -u +'%Y-%m-%dT%H:%M:%S.000Z') EOF - + echo "" echo "✅ Merged latest-mac.yml created:" cat "$MERGED_YML" - + # Remove any other YAML files in subdirectories to prevent conflicts find notarize -name "latest*.yml" -o -name "*-mac.yml" | while read yml; do if [[ "$yml" != "$MERGED_YML" ]]; then @@ -702,7 +702,7 @@ jobs: echo "Removed: $yml" fi done - + echo "✅ Regeneration complete" - name: Upload stapled macOS artifacts @@ -741,60 +741,60 @@ jobs: - name: Merge Windows latest.yml files run: | echo "🔄 Merging Windows x64 and ARM64 latest.yml files..." - + # Find the Windows YAML files X64_YML=$(find artifacts/windows-x64-build -name "latest.yml" 2>/dev/null || echo "") ARM64_YML=$(find artifacts/windows-arm64-build -name "latest.yml" 2>/dev/null || echo "") - + if [[ -z "$X64_YML" || -z "$ARM64_YML" ]]; then echo "⚠️ One or both Windows YAML files not found. Skipping merge." echo "X64_YML: $X64_YML" echo "ARM64_YML: $ARM64_YML" exit 0 fi - + echo "Found X64 YAML: $X64_YML" echo "Found ARM64 YAML: $ARM64_YML" - + # Extract version and release date from x64 YAML (should be the same for both) VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$X64_YML" || echo "unknown") RELEASE_DATE=$(grep -oP 'releaseDate:\s+\K.+' "$X64_YML" || date -u +'%Y-%m-%dT%H:%M:%S.000Z') - + echo "Version: $VERSION" echo "Release Date: $RELEASE_DATE" - + # Find the EXE files in each artifact directory X64_EXE=$(find artifacts/windows-x64-build -name "*-x64-win.exe" -type f | head -n 1) ARM64_EXE=$(find artifacts/windows-arm64-build -name "*-arm64-win.exe" -type f | head -n 1) - + if [[ -z "$X64_EXE" || -z "$ARM64_EXE" ]]; then echo "❌ Could not find both x64 and ARM64 EXE files" echo "X64_EXE: $X64_EXE" echo "ARM64_EXE: $ARM64_EXE" exit 1 fi - + echo "Found X64 EXE: $(basename "$X64_EXE")" echo "Found ARM64 EXE: $(basename "$ARM64_EXE")" - + # Calculate hashes for x64 X64_SHA256=$(sha256sum "$X64_EXE" | awk '{print $1}') X64_SHA512=$(sha512sum "$X64_EXE" | awk '{print $1}') X64_SIZE=$(stat -c %s "$X64_EXE" 2>/dev/null || stat -f %z "$X64_EXE" 2>/dev/null) - + echo "X64 SHA256: $X64_SHA256" echo "X64 SHA512: $X64_SHA512" echo "X64 Size: $X64_SIZE" - + # Calculate hashes for ARM64 ARM64_SHA256=$(sha256sum "$ARM64_EXE" | awk '{print $1}') ARM64_SHA512=$(sha512sum "$ARM64_EXE" | awk '{print $1}') ARM64_SIZE=$(stat -c %s "$ARM64_EXE" 2>/dev/null || stat -f %z "$ARM64_EXE" 2>/dev/null) - + echo "ARM64 SHA256: $ARM64_SHA256" echo "ARM64 SHA512: $ARM64_SHA512" echo "ARM64 Size: $ARM64_SIZE" - + # Create merged YAML with both architectures MERGED_YML="artifacts/latest.yml" cat > "$MERGED_YML" << EOF @@ -812,11 +812,11 @@ jobs: blockMapSize: null releaseDate: $RELEASE_DATE EOF - + echo "" echo "✅ Merged latest.yml created:" cat "$MERGED_YML" - + # Remove the individual YAML files so they don't get uploaded rm -f "$X64_YML" "$ARM64_YML" echo "" diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index c9d84fb0..8bf7b2a6 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -569,85 +569,85 @@ jobs: shell: bash run: | echo "🔄 Merging macOS x64 and ARM64 latest-mac.yml files..." - - # Find all DMG files - X64_DMG=$(find notarize -name "*-x64-mac.dmg" -type f | head -n 1) - ARM64_DMG=$(find notarize -name "*-arm64-mac.dmg" -type f | head -n 1) - - if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then - echo "⚠️ One or both macOS DMG files not found. Skipping merge." - echo "X64_DMG: $X64_DMG" - echo "ARM64_DMG: $ARM64_DMG" + + # Find all ZIP files (required for mac auto-update) + X64_ZIP=$(find notarize -name "*-x64-mac.zip" -type f | head -n 1) + ARM64_ZIP=$(find notarize -name "*-arm64-mac.zip" -type f | head -n 1) + + if [[ -z "$X64_ZIP" || -z "$ARM64_ZIP" ]]; then + echo "⚠️ One or both macOS ZIP files not found. Skipping merge." + echo "X64_ZIP: $X64_ZIP" + echo "ARM64_ZIP: $ARM64_ZIP" # Fallback to single architecture (original behavior) YML_FILES=$(find notarize -name "latest*.yml" -o -name "*-mac.yml") if [[ -n "$YML_FILES" ]]; then for YML_FILE in $YML_FILES; do VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$YML_FILE" || echo "unknown") - DMG_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.dmg" | head -n 1) - if [[ -n "$DMG_FILE" && -f "$DMG_FILE" ]]; then - HASH256=$(shasum -a 256 "$DMG_FILE" | awk '{print $1}') - HASH512=$(shasum -a 512 "$DMG_FILE" | awk '{print $1}') - SIZE=$(stat -f '%z' "$DMG_FILE" 2>/dev/null || stat -c '%s' "$DMG_FILE" 2>/dev/null) + ZIP_FILE=$(find "$(dirname "$YML_FILE")" -maxdepth 1 -name "*.zip" | head -n 1) + if [[ -n "$ZIP_FILE" && -f "$ZIP_FILE" ]]; then + HASH256=$(shasum -a 256 "$ZIP_FILE" | awk '{print $1}') + HASH512=$(shasum -a 512 "$ZIP_FILE" | awk '{print $1}') + SIZE=$(stat -f '%z' "$ZIP_FILE" 2>/dev/null || stat -c '%s' "$ZIP_FILE" 2>/dev/null) printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ - "$VERSION" "$(basename "$DMG_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" + "$VERSION" "$(basename "$ZIP_FILE")" "$HASH512" "$HASH256" "$SIZE" "$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" > "$YML_FILE" fi done fi exit 0 fi - - echo "Found X64 DMG: $(basename "$X64_DMG")" - echo "Found ARM64 DMG: $(basename "$ARM64_DMG")" - + + echo "Found X64 ZIP: $(basename "$X64_ZIP")" + echo "Found ARM64 ZIP: $(basename "$ARM64_ZIP")" + # Find any existing YAML to extract version EXISTING_YML=$(find notarize -name "latest*.yml" -o -name "*-mac.yml" | head -n 1) VERSION=$(if [ -n "$EXISTING_YML" ]; then awk '/^version:[[:space:]]*/ {print $2; exit}' "$EXISTING_YML"; fi 2>/dev/null || echo "unknown") - + echo "Version: $VERSION" - - # Calculate hashes for x64 - echo "🔐 Calculating hashes for x64 DMG..." - X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') - X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') - X64_SIZE=$(stat -f '%z' "$X64_DMG" 2>/dev/null || stat -c '%s' "$X64_DMG" 2>/dev/null) - + + # Calculate hashes for x64 ZIP + echo "🔐 Calculating hashes for x64 ZIP..." + X64_SHA256=$(shasum -a 256 "$X64_ZIP" | awk '{print $1}') + X64_SHA512=$(shasum -a 512 "$X64_ZIP" | awk '{print $1}') + X64_SIZE=$(stat -f '%z' "$X64_ZIP" 2>/dev/null || stat -c '%s' "$X64_ZIP" 2>/dev/null) + echo " SHA256: $X64_SHA256" echo " SHA512: $X64_SHA512" echo " Size: $X64_SIZE" - - # Calculate hashes for ARM64 - echo "🔐 Calculating hashes for ARM64 DMG..." - ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') - ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') - ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG" 2>/dev/null || stat -c '%s' "$ARM64_DMG" 2>/dev/null) - + + # Calculate hashes for ARM64 ZIP + echo "🔐 Calculating hashes for ARM64 ZIP..." + ARM64_SHA256=$(shasum -a 256 "$ARM64_ZIP" | awk '{print $1}') + ARM64_SHA512=$(shasum -a 512 "$ARM64_ZIP" | awk '{print $1}') + ARM64_SIZE=$(stat -f '%z' "$ARM64_ZIP" 2>/dev/null || stat -c '%s' "$ARM64_ZIP" 2>/dev/null) + echo " SHA256: $ARM64_SHA256" echo " SHA512: $ARM64_SHA512" echo " Size: $ARM64_SIZE" - + # Create merged YAML with both architectures MERGED_YML="notarize/latest-mac.yml" cat > "$MERGED_YML" << EOF version: $VERSION files: - - url: $(basename "$X64_DMG") + - url: $(basename "$X64_ZIP") sha512: $X64_SHA512 sha256: $X64_SHA256 size: $X64_SIZE blockMapSize: null - - url: $(basename "$ARM64_DMG") + - url: $(basename "$ARM64_ZIP") sha512: $ARM64_SHA512 sha256: $ARM64_SHA256 size: $ARM64_SIZE blockMapSize: null releaseDate: $(date -u +'%Y-%m-%dT%H:%M:%S.000Z') EOF - + echo "" echo "✅ Merged latest-mac.yml created:" cat "$MERGED_YML" - + # Remove any other YAML files in subdirectories to prevent conflicts find notarize -name "latest*.yml" -o -name "*-mac.yml" | while read yml; do if [[ "$yml" != "$MERGED_YML" ]]; then @@ -655,7 +655,7 @@ jobs: echo "Removed: $yml" fi done - + echo "✅ Regeneration complete" - name: Upload stapled macOS artifacts @@ -698,60 +698,60 @@ jobs: - name: Merge Windows latest.yml files run: | echo "🔄 Merging Windows x64 and ARM64 latest.yml files..." - + # Find the Windows YAML files X64_YML=$(find artifacts/windows-x64-release -name "latest.yml" 2>/dev/null || echo "") ARM64_YML=$(find artifacts/windows-arm64-release -name "latest.yml" 2>/dev/null || echo "") - + if [[ -z "$X64_YML" || -z "$ARM64_YML" ]]; then echo "⚠️ One or both Windows YAML files not found. Skipping merge." echo "X64_YML: $X64_YML" echo "ARM64_YML: $ARM64_YML" exit 0 fi - + echo "Found X64 YAML: $X64_YML" echo "Found ARM64 YAML: $ARM64_YML" - + # Extract version and release date from x64 YAML (should be the same for both) VERSION=$(grep -oP 'version:\s+\K[^\s]+' "$X64_YML" || echo "unknown") RELEASE_DATE=$(grep -oP 'releaseDate:\s+\K.+' "$X64_YML" || date -u +'%Y-%m-%dT%H:%M:%S.000Z') - + echo "Version: $VERSION" echo "Release Date: $RELEASE_DATE" - + # Find the EXE files in each artifact directory X64_EXE=$(find artifacts/windows-x64-release -name "*-x64-win.exe" -type f | head -n 1) ARM64_EXE=$(find artifacts/windows-arm64-release -name "*-arm64-win.exe" -type f | head -n 1) - + if [[ -z "$X64_EXE" || -z "$ARM64_EXE" ]]; then echo "❌ Could not find both x64 and ARM64 EXE files" echo "X64_EXE: $X64_EXE" echo "ARM64_EXE: $ARM64_EXE" exit 1 fi - + echo "Found X64 EXE: $(basename "$X64_EXE")" echo "Found ARM64 EXE: $(basename "$ARM64_EXE")" - + # Calculate hashes for x64 X64_SHA256=$(sha256sum "$X64_EXE" | awk '{print $1}') X64_SHA512=$(sha512sum "$X64_EXE" | awk '{print $1}') X64_SIZE=$(stat -c %s "$X64_EXE" 2>/dev/null || stat -f %z "$X64_EXE" 2>/dev/null) - + echo "X64 SHA256: $X64_SHA256" echo "X64 SHA512: $X64_SHA512" echo "X64 Size: $X64_SIZE" - + # Calculate hashes for ARM64 ARM64_SHA256=$(sha256sum "$ARM64_EXE" | awk '{print $1}') ARM64_SHA512=$(sha512sum "$ARM64_EXE" | awk '{print $1}') ARM64_SIZE=$(stat -c %s "$ARM64_EXE" 2>/dev/null || stat -f %z "$ARM64_EXE" 2>/dev/null) - + echo "ARM64 SHA256: $ARM64_SHA256" echo "ARM64 SHA512: $ARM64_SHA512" echo "ARM64 Size: $ARM64_SIZE" - + # Create merged YAML with both architectures MERGED_YML="artifacts/latest.yml" cat > "$MERGED_YML" << EOF @@ -769,11 +769,11 @@ jobs: blockMapSize: null releaseDate: $RELEASE_DATE EOF - + echo "" echo "✅ Merged latest.yml created:" cat "$MERGED_YML" - + # Remove the individual YAML files so they don't get uploaded rm -f "$X64_YML" "$ARM64_YML" echo "" diff --git a/buildScripts/sh/README-merge-windows-latest-yml.md b/buildScripts/sh/README-merge-windows-latest-yml.md index 01ed16c1..5c4594a9 100644 --- a/buildScripts/sh/README-merge-windows-latest-yml.md +++ b/buildScripts/sh/README-merge-windows-latest-yml.md @@ -28,7 +28,7 @@ Generates `latest.yml` for Windows updates (EXE installers). ### macOS: `merge-macos-latest-yml.sh` -Generates `latest-mac.yml` for macOS updates (DMG installers). +Generates `latest-mac.yml` for macOS updates (ZIP artifacts, required by electron-updater). ## Usage @@ -37,6 +37,7 @@ Generates `latest-mac.yml` for macOS updates (DMG installers). Use this to fix an already-published release (like v1.1.3): **Windows:** + ```bash cd buildScripts ./merge-windows-latest-yml.sh 1.1.3 v1.1.3 @@ -44,13 +45,15 @@ gh release upload v1.1.3 latest.yml --clobber ``` **macOS:** + ```bash -cd buildScripts +cd buildScripts/sh ./merge-macos-latest-yml.sh 1.1.3 v1.1.3 gh release upload v1.1.3 latest-mac.yml --clobber ``` This will: + 1. Download both x64 and ARM64 installers from the v1.1.3 GitHub release 2. Calculate SHA256/SHA512 hashes 3. Generate a merged YAML file in the current directory @@ -60,12 +63,14 @@ This will: Use this when you have local build artifacts: **Windows:** + ```bash cd buildScripts ./merge-windows-latest-yml.sh 1.1.3 ``` **macOS:** + ```bash cd buildScripts ./merge-macos-latest-yml.sh 1.1.3 @@ -78,36 +83,38 @@ This will look for installer files in the `build/` directory. The scripts create YAML files in the current directory: **Windows (`latest.yml`):** + ```yaml version: 1.1.3 files: - - url: Power-Platform-ToolBox-1.1.3-x64-win.exe - sha512: - sha256: - size: 83575696 - blockMapSize: null - - url: Power-Platform-ToolBox-1.1.3-arm64-win.exe - sha512: - sha256: - size: 86587224 - blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-x64-win.exe + sha512: + sha256: + size: 83575696 + blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-arm64-win.exe + sha512: + sha256: + size: 86587224 + blockMapSize: null releaseDate: 2026-02-19T10:54:00.000Z ``` **macOS (`latest-mac.yml`):** + ```yaml version: 1.1.3 files: - - url: Power-Platform-ToolBox-1.1.3-x64-mac.dmg - sha512: - sha256: - size: 110450111 - blockMapSize: null - - url: Power-Platform-ToolBox-1.1.3-arm64-mac.dmg - sha512: - sha256: - size: 103969103 - blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-x64-mac.zip + sha512: + sha256: + size: + blockMapSize: null + - url: Power-Platform-ToolBox-1.1.3-arm64-mac.zip + sha512: + sha256: + size: + blockMapSize: null releaseDate: 2026-02-19T10:54:00.000Z ``` @@ -116,11 +123,13 @@ releaseDate: 2026-02-19T10:54:00.000Z ### Using GitHub CLI **Windows:** + ```bash gh release upload v1.1.3 latest.yml --clobber ``` **macOS:** + ```bash gh release upload v1.1.3 latest-mac.yml --clobber ``` @@ -139,6 +148,7 @@ The `--clobber` flag replaces the existing file. To fix the current v1.1.3 release for both platforms: **Windows:** + ```bash cd buildScripts ./merge-windows-latest-yml.sh 1.1.3 v1.1.3 @@ -146,6 +156,7 @@ gh release upload v1.1.3 latest.yml --clobber ``` **macOS:** + ```bash cd buildScripts ./merge-macos-latest-yml.sh 1.1.3 v1.1.3 @@ -156,7 +167,7 @@ After uploading, users who check for updates will receive the correct installer ## How It Works -1. **Locates Installers**: Finds or downloads both x64 and ARM64 installers (EXE for Windows, DMG for macOS) +1. **Locates Installers**: Finds or downloads both x64 and ARM64 installers (EXE for Windows, ZIP for macOS) 2. **Calculates Hashes**: Computes SHA256 and SHA512 checksums for integrity verification 3. **Generates YAML**: Creates a YAML file with both file entries 4. **Architecture Detection**: electron-updater automatically selects the correct installer @@ -166,12 +177,14 @@ After uploading, users who check for updates will receive the correct installer The electron-updater library automatically detects the user's architecture: **Windows:** + - On x64 systems: `process.arch === "x64"` → downloads `*-x64-win.exe` - On ARM64 systems: `process.arch === "arm64"` → downloads `*-arm64-win.exe` **macOS:** -- On Intel Macs: `process.arch === "x64"` → downloads `*-x64-mac.dmg` -- On Apple Silicon: `process.arch === "arm64"` → downloads `*-arm64-mac.dmg` + +- On Intel Macs: `process.arch === "x64"` → downloads `*-x64-mac.zip` +- On Apple Silicon: `process.arch === "arm64"` → downloads `*-arm64-mac.zip` This is done by matching the architecture string in the filename. @@ -180,6 +193,7 @@ This is done by matching the architecture string in the filename. ### "Failed to download x64 installer/DMG" The release tag or version doesn't exist on GitHub. Check: + - The release tag is correct (e.g., `v1.1.3` not `1.1.3`) - The release has been published (not a draft) - The installers have been uploaded to the release @@ -189,6 +203,7 @@ The release tag or version doesn't exist on GitHub. Check: When using local files, ensure you've run the build first: **Windows:** + ```bash pnpm run build pnpm run package:win # For x64 @@ -196,6 +211,7 @@ pnpm run package:win-arm64 # For ARM64 ``` **macOS:** + ```bash pnpm run build pnpm run package:mac # Builds both x64 and ARM64 diff --git a/buildScripts/sh/merge-macos-latest-yml.sh b/buildScripts/sh/merge-macos-latest-yml.sh index 231c6a7b..0ed7cd15 100755 --- a/buildScripts/sh/merge-macos-latest-yml.sh +++ b/buildScripts/sh/merge-macos-latest-yml.sh @@ -3,7 +3,7 @@ # Merge macOS latest-mac.yml Script # # This script generates a merged latest-mac.yml file containing both x64 and ARM64 -# macOS installers for electron-updater auto-update functionality. +# macOS ZIP artifacts for electron-updater auto-update functionality. # # Usage: # ./merge-macos-latest-yml.sh [release-tag] @@ -16,7 +16,7 @@ # ./merge-macos-latest-yml.sh 1.1.3 # # The script will: -# 1. Download or locate both x64 and ARM64 macOS DMG files +# 1. Download or locate both x64 and ARM64 macOS ZIP files # 2. Calculate SHA256 and SHA512 hashes # 3. Generate a merged latest-mac.yml with both architectures # @@ -45,79 +45,79 @@ echo "" TEMP_DIR=$(mktemp -d) trap 'rm -rf "$TEMP_DIR"' EXIT -# Function to find or download x64 DMG -find_x64_dmg() { +# Function to find or download x64 ZIP +find_x64_zip() { if [[ -n "$RELEASE_TAG" ]]; then - echo "📥 Downloading x64 DMG from GitHub release $RELEASE_TAG..." >&2 - local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-x64-mac.dmg" - local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-x64-mac.dmg" + echo "📥 Downloading x64 ZIP from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-x64-mac.zip" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-x64-mac.zip" if curl -sL -f -o "$dest" "$url"; then echo "$dest" else - echo "❌ Failed to download x64 DMG from $url" >&2 + echo "❌ Failed to download x64 ZIP from $url" >&2 return 1 fi else - echo "🔍 Looking for x64 DMG in build/ directory..." >&2 - local dmg=$(find build -name "*-x64-mac.dmg" -type f 2>/dev/null | head -n 1) - if [[ -n "$dmg" && -f "$dmg" ]]; then - echo "$dmg" + echo "🔍 Looking for x64 ZIP in build/ directory..." >&2 + local zip=$(find build -name "*-x64-mac.zip" -type f 2>/dev/null | head -n 1) + if [[ -n "$zip" && -f "$zip" ]]; then + echo "$zip" else - echo "❌ Could not find x64 DMG in build/ directory" >&2 + echo "❌ Could not find x64 ZIP in build/ directory" >&2 return 1 fi fi } -# Function to find or download ARM64 DMG -find_arm64_dmg() { +# Function to find or download ARM64 ZIP +find_arm64_zip() { if [[ -n "$RELEASE_TAG" ]]; then - echo "📥 Downloading ARM64 DMG from GitHub release $RELEASE_TAG..." >&2 - local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-arm64-mac.dmg" - local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-arm64-mac.dmg" + echo "📥 Downloading ARM64 ZIP from GitHub release $RELEASE_TAG..." >&2 + local url="https://github.com/PowerPlatformToolBox/desktop-app/releases/download/${RELEASE_TAG}/Power-Platform-ToolBox-${VERSION}-arm64-mac.zip" + local dest="$TEMP_DIR/Power-Platform-ToolBox-${VERSION}-arm64-mac.zip" if curl -sL -f -o "$dest" "$url"; then echo "$dest" else - echo "❌ Failed to download ARM64 DMG from $url" >&2 + echo "❌ Failed to download ARM64 ZIP from $url" >&2 return 1 fi else - echo "🔍 Looking for ARM64 DMG in build/ directory..." >&2 - local dmg=$(find build -name "*-arm64-mac.dmg" -type f 2>/dev/null | head -n 1) - if [[ -n "$dmg" && -f "$dmg" ]]; then - echo "$dmg" + echo "🔍 Looking for ARM64 ZIP in build/ directory..." >&2 + local zip=$(find build -name "*-arm64-mac.zip" -type f 2>/dev/null | head -n 1) + if [[ -n "$zip" && -f "$zip" ]]; then + echo "$zip" else - echo "❌ Could not find ARM64 DMG in build/ directory" >&2 + echo "❌ Could not find ARM64 ZIP in build/ directory" >&2 return 1 fi fi } -# Find/download the DMG files -X64_DMG=$(find_x64_dmg) -ARM64_DMG=$(find_arm64_dmg) +# Find/download the ZIP files +X64_ZIP=$(find_x64_zip) +ARM64_ZIP=$(find_arm64_zip) -if [[ -z "$X64_DMG" || -z "$ARM64_DMG" ]]; then - echo "❌ Could not find both DMG files" +if [[ -z "$X64_ZIP" || -z "$ARM64_ZIP" ]]; then + echo "❌ Could not find both ZIP files" exit 1 fi echo "" -echo "✅ Found x64 DMG: $(basename "$X64_DMG")" -echo "✅ Found ARM64 DMG: $(basename "$ARM64_DMG")" +echo "✅ Found x64 ZIP: $(basename "$X64_ZIP")" +echo "✅ Found ARM64 ZIP: $(basename "$ARM64_ZIP")" echo "" # Calculate hashes for x64 -echo "🔐 Calculating hashes for x64 DMG..." -X64_SHA256=$(shasum -a 256 "$X64_DMG" | awk '{print $1}') -X64_SHA512=$(shasum -a 512 "$X64_DMG" | awk '{print $1}') +echo "🔐 Calculating hashes for x64 ZIP..." +X64_SHA256=$(shasum -a 256 "$X64_ZIP" | awk '{print $1}') +X64_SHA512=$(shasum -a 512 "$X64_ZIP" | awk '{print $1}') # Try macOS stat first, then Linux stat -if stat -f '%z' "$X64_DMG" >/dev/null 2>&1; then - X64_SIZE=$(stat -f '%z' "$X64_DMG") +if stat -f '%z' "$X64_ZIP" >/dev/null 2>&1; then + X64_SIZE=$(stat -f '%z' "$X64_ZIP") else - X64_SIZE=$(stat -c '%s' "$X64_DMG") + X64_SIZE=$(stat -c '%s' "$X64_ZIP") fi echo " SHA256: $X64_SHA256" @@ -126,14 +126,14 @@ echo " Size: $X64_SIZE bytes" echo "" # Calculate hashes for ARM64 -echo "🔐 Calculating hashes for ARM64 DMG..." -ARM64_SHA256=$(shasum -a 256 "$ARM64_DMG" | awk '{print $1}') -ARM64_SHA512=$(shasum -a 512 "$ARM64_DMG" | awk '{print $1}') +echo "🔐 Calculating hashes for ARM64 ZIP..." +ARM64_SHA256=$(shasum -a 256 "$ARM64_ZIP" | awk '{print $1}') +ARM64_SHA512=$(shasum -a 512 "$ARM64_ZIP" | awk '{print $1}') # Try macOS stat first, then Linux stat -if stat -f '%z' "$ARM64_DMG" >/dev/null 2>&1; then - ARM64_SIZE=$(stat -f '%z' "$ARM64_DMG") +if stat -f '%z' "$ARM64_ZIP" >/dev/null 2>&1; then + ARM64_SIZE=$(stat -f '%z' "$ARM64_ZIP") else - ARM64_SIZE=$(stat -c '%s' "$ARM64_DMG") + ARM64_SIZE=$(stat -c '%s' "$ARM64_ZIP") fi echo " SHA256: $ARM64_SHA256" @@ -147,21 +147,17 @@ RELEASE_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S.000Z') # Create merged latest-mac.yml OUTPUT_FILE="latest-mac.yml" -cat > "$OUTPUT_FILE" << EOF -version: $VERSION -files: - - url: $(basename "$X64_DMG") - sha512: $X64_SHA512 - sha256: $X64_SHA256 - size: $X64_SIZE - blockMapSize: null - - url: $(basename "$ARM64_DMG") - sha512: $ARM64_SHA512 - sha256: $ARM64_SHA256 - size: $ARM64_SIZE - blockMapSize: null -releaseDate: $RELEASE_DATE -EOF +printf "version: %s\nfiles:\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\n - url: %s\n sha512: %s\n sha256: %s\n size: %s\n blockMapSize: null\nreleaseDate: %s\n" \ + "$VERSION" \ + "$(basename "$X64_ZIP")" \ + "$X64_SHA512" \ + "$X64_SHA256" \ + "$X64_SIZE" \ + "$(basename "$ARM64_ZIP")" \ + "$ARM64_SHA512" \ + "$ARM64_SHA256" \ + "$ARM64_SIZE" \ + "$RELEASE_DATE" > "$OUTPUT_FILE" echo "✅ Merged latest-mac.yml created successfully!" echo "" From 4f0e1ee828fcc09ff5bb9ba99fd7ce659b4a4a84 Mon Sep 17 00:00:00 2001 From: LinkeD365 <43988771+LinkeD365@users.noreply.github.com> Date: Sun, 22 Feb 2026 11:58:22 +0000 Subject: [PATCH 024/178] fix: add webresource to entity mapping in DataverseManager (#402) --- src/main/managers/dataverseManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/managers/dataverseManager.ts b/src/main/managers/dataverseManager.ts index 5004127f..e2b08c5b 100644 --- a/src/main/managers/dataverseManager.ts +++ b/src/main/managers/dataverseManager.ts @@ -436,6 +436,7 @@ export class DataverseManager { systemuser: "systemusers", usersettingscollection: "usersettingscollection", principalobjectaccess: "principalobjectaccessset", + webresource: "webresourceset", }; const lowerName = entityLogicalName.toLowerCase(); From 87d8ef97ac4981f2835fba484b6a2096ed5c4dd6 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:20:18 -0500 Subject: [PATCH 025/178] Move marketplace to azure blob (#403) * Add support for bundled SVG icons in tools with backward compatibility (#380) * Initial plan * Add SVG icon support with pptb-webview protocol for bundled icons Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Address code review feedback: fix recent tools icon handling and add HTML escaping Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add comprehensive HTML escaping for XSS prevention in icon URLs Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Improve accessibility and eliminate code duplication in HTML escaping Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add defensive URL validation to prevent JavaScript protocol injection Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix CodeQL warning by blocking vbscript protocol in URL validation Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Remove HTTP(S) icon support, change path to dist/ relative, rename iconUrl to icon Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Update ToolManifest comment to reflect bundled icons only (no HTTP URLs) Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add support for new Supabase 'icon' column with backward compatibility fallback to 'iconurl' Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix CSP error by allowing HTTP(S) URLs for marketplace icon display Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add pptb-webview protocol to CSP img-src to allow local SVG icon loading Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * feat: add SVG icon support and improve icon URL resolution * feat: implement theme-aware SVG icon support with CSS masks and improve icon rendering * refactor: remove tool icon configuration section from README.md --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick * Move tool distribution from GitHub Releases to Azure Blob Storage (#400) * Initial plan * Add Azure Blob Storage support for tool distribution and registry fallback Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Remove hard-coded Azure Blob storage account name; resolve URLs at runtime from AZURE_BLOB_BASE_URL Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Simplify registry.json downloadUrl to filename-only; packages/ prefix added automatically at runtime Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Use per-tool version folder layout in Azure Blob, mirroring GitHub Releases structure Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Read download URL from new 'download' column in Supabase tools table, fall back to 'downloadurl' Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * fix: update Azure Blob Storage migration documentation to reflect new package structure --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick * feat: enhance ToolManager to create tools from installed manifests and improve tool retrieval logic * Update src/main/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Azure Blob test download URL to dedicated test path (#404) * Initial plan * Update test tool download URL to /test/pptb-standard-sample-tool-download-test.tar.gz Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix resolveDownloadUrl to include packages/ prefix for Azure Blob Storage paths (#405) * Initial plan * fix: include packages/ prefix in resolveDownloadUrl for Azure Blob Storage Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix: include `icon` field in `fetchAzureBlobRegistry` tool mapping (#406) * Initial plan * fix: include icon field in fetchAzureBlobRegistry mapping Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Update src/main/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/AZURE_BLOB_MIGRATION.md | 426 ++++++++++++++++++ packages/README.md | 1 + src/common/types/tool.ts | 6 +- src/main/constants.ts | 15 + src/main/data/registry.json | 4 +- src/main/index.ts | 25 +- src/main/managers/modalWindowManager.ts | 2 +- src/main/managers/toolRegistryManager.ts | 141 +++++- src/main/managers/toolsManager.ts | 76 +++- src/renderer/index.html | 6 +- src/renderer/modules/homepageManagement.ts | 32 +- src/renderer/modules/marketplaceManagement.ts | 44 +- src/renderer/modules/themeManagement.ts | 4 +- .../modules/toolsSidebarManagement.ts | 17 +- src/renderer/styles.scss | 17 + src/renderer/styles/homepage.scss | 15 +- src/renderer/types/index.ts | 2 +- src/renderer/utils/toolIconResolver.ts | 142 ++++++ vite.config.ts | 8 + 19 files changed, 883 insertions(+), 100 deletions(-) create mode 100644 docs/AZURE_BLOB_MIGRATION.md create mode 100644 src/renderer/utils/toolIconResolver.ts diff --git a/docs/AZURE_BLOB_MIGRATION.md b/docs/AZURE_BLOB_MIGRATION.md new file mode 100644 index 00000000..bf82e0e8 --- /dev/null +++ b/docs/AZURE_BLOB_MIGRATION.md @@ -0,0 +1,426 @@ +# Azure Blob Storage Migration Strategy + +This document describes the strategy for moving tool distribution from GitHub Releases to Azure Blob Storage and outlines the updated intake process. + +## Overview + +Tool packages (`.tar.gz` archives) were previously hosted as GitHub Release assets on the `pptb-web` repository. They are being migrated to **Azure Blob Storage** to allow easier automation, lower latency, and decoupled storage from GitHub. + +The ToolBox application already fetches tool metadata from **Supabase**. Azure Blob Storage becomes the authoritative location for the binary artifacts (the `.tar.gz` packages) **and** for a remote fallback registry index when Supabase is unreachable. + +--- + +## Azure Blob Container Layout + +All tool assets live in a single public Azure Blob container (anonymous read access on blobs), with each tool version in its own folder — mirroring the GitHub Releases structure: + +``` +.blob.core.windows.net/tools/ +├── registry.json # Remote registry index (fallback after Supabase) +└── packages/ + └── -/ # Per-tool version folder + ├── -.tar.gz # Tool package archive + └── -.svg # Tool icon +``` + +**Example:** + +``` +https://.blob.core.windows.net/tools/registry.json +https://.blob.core.windows.net/tools/packages/pptb-standard-sample-tool-1.0.9/pptb-standard-sample-tool-1.0.9.tar.gz +https://.blob.core.windows.net/tools/packages/pptb-standard-sample-tool-1.0.9/pptb-standard-sample-tool-1.0.9.svg +``` + +--- + +## Configuration + +Set the following environment variable before building the app (add it to your `.env` file or CI/CD pipeline secrets): + +| Variable | Description | Example | +| --------------------- | ------------------------------------------------ | ------------------------------------------------------- | +| `AZURE_BLOB_BASE_URL` | Full URL to the root of the tools blob container | `https://.blob.core.windows.net/tools` | +| `SUPABASE_URL` | Supabase project URL (unchanged) | `https://xyz.supabase.co` | +| `SUPABASE_ANON_KEY` | Supabase anonymous key (unchanged) | `eyJ...` | + +### `.env` example + +```bash +SUPABASE_URL=https://your-project.supabase.co +SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... +AZURE_BLOB_BASE_URL=https://.blob.core.windows.net/tools +``` + +> **Note:** `AZURE_BLOB_BASE_URL` is injected at build time via Vite and is **not** a runtime secret. The container must allow anonymous read access (no SAS token required for downloads). + +--- + +## Registry Fallback Chain + +The ToolBox app resolves the tool registry in the following order: + +``` +1. Supabase (primary) – real-time metadata, analytics, contributor info + ↓ (on failure) +2. Azure Blob registry.json – remote static snapshot (requires AZURE_BLOB_BASE_URL) + ↓ (on failure or not configured) +3. Local registry.json – bundled fallback shipped with the app binary +``` + +The Azure Blob `registry.json` must follow the same schema as the local `src/main/data/registry.json` file (see [Local Registry Schema](#local-registry-schema) below). + +--- + +## Tool Package Format + +Tool packages are `.tar.gz` archives containing the tool's files. The archive is extracted with: + +```sh +tar -xzf -.tar.gz -C +``` + +The extracted directory must contain a `package.json` at its root: + +``` +/ +├── package.json # Required – contains tool metadata (name, version, description, …) +├── index.html # Required – tool entry point +└── ... # Additional assets +``` + +--- + +## Local Registry Schema + +Both `registry.json` (bundled) and the Azure Blob `registry.json` share this schema: + +> **`downloadUrl` convention:** +> +> - Supabase rows should use **absolute** HTTPS URLs. +> - For Azure Blob `registry.json` fallback, you can either: +> - Use **absolute** HTTPS URLs (recommended when `registry.json` is at `.../tools/registry.json` but packages are under `.../tools/packages/...`), or +> - Use just the **filename** (e.g. `my-tool-1.0.0.tar.gz`) _only if_ `AZURE_BLOB_BASE_URL` points at the same prefix used for packages and `registry.json` is also under that prefix. +> +> The app resolves relative filenames by deriving a folder name from the filename (strip `.tar.gz`) and joining it to `AZURE_BLOB_BASE_URL`. + +```json +{ + "version": "1.0", + "updatedAt": "", + "description": "Power Platform ToolBox - Official Tool Registry", + "tools": [ + { + "id": "my-tool-id", + "packageName": "my-tool-npm-package", + "name": "My Tool", + "description": "Tool description", + "authors": ["Author Name"], + "version": "1.0.0", + "downloadUrl": "my-tool-id-1.0.0.tar.gz", + "icon": "icon.png", + "checksum": "sha256:", + "size": 75000, + "publishedAt": "", + "tags": ["dataverse"], + "readme": "https://...", + "minToolboxVersion": "1.0.0", + "repository": "https://github.com/...", + "homepage": "https://...", + "license": "MIT", + "cspExceptions": { + "connect-src": ["https://*.dynamics.com"] + } + } + ] +} +``` + +--- + +## Updated Intake Process + +### Current Process (GitHub Releases) + +``` +User submits tool via web app (pptb-web) + → Review & approval + → convert-tool GitHub Action pre-packages the tool from npm + → Package uploaded as a GitHub Release asset on pptb-web + → Supabase row updated with downloadurl pointing to the GitHub Release asset +``` + +### New Process (Azure Blob Storage) + +``` +User submits tool via web app (pptb-web) + → Review & approval + → convert-tool GitHub Action pre-packages the tool from npm (unchanged) + → Both the .tar.gz and .svg (icon) are uploaded to a per-tool version folder in Azure Blob: + az storage blob upload \ + --account-name \ + --container-name tools \ + --name "packages/-/-.tar.gz" \ + --file "-.tar.gz" \ + --auth-mode login + az storage blob upload \ + --account-name \ + --container-name tools \ + --name "packages/-/-.svg" \ + --file "-.svg" \ + --auth-mode login + → Supabase row updated with downloadurl pointing to the Azure Blob URL: + https://.blob.core.windows.net/tools/packages/-/-.tar.gz + → (Optional) registry.json in the blob container is regenerated to include the new entry +``` + +### Changes to the `convert-tool` GitHub Action + +Replace the GitHub Release upload step with an Azure Blob upload step. The CI/CD pipeline will need the following secrets configured: + +| Secret | Description | +| ------------------------- | ------------------------------------------------------------------------- | +| `AZURE_STORAGE_ACCOUNT` | Storage account name (e.g. ``) | +| `AZURE_STORAGE_CONTAINER` | Container name (e.g. `tools`) | +| `AZURE_CREDENTIALS` | Azure service principal credentials JSON (used with `azure/login` action) | + +**Example workflow snippet (replace the current GitHub Release upload step):** + +```yaml +- name: Login to Azure + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + +- name: Upload tool package and icon to Azure Blob + run: | + FOLDER="${{ env.TOOL_ID }}-${{ env.TOOL_VERSION }}" + az storage blob upload \ + --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \ + --container-name ${{ secrets.AZURE_STORAGE_CONTAINER }} \ + --name "packages/${FOLDER}/${FOLDER}.tar.gz" \ + --file "${FOLDER}.tar.gz" \ + --auth-mode login \ + --overwrite true + az storage blob upload \ + --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \ + --container-name ${{ secrets.AZURE_STORAGE_CONTAINER }} \ + --name "packages/${FOLDER}/${FOLDER}.svg" \ + --file "${FOLDER}.svg" \ + --auth-mode login \ + --overwrite true + +- name: Regenerate Azure Blob registry.json + run: | + # Download current registry.json, add new tool entry, re-upload + az storage blob download \ + --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \ + --container-name ${{ secrets.AZURE_STORAGE_CONTAINER }} \ + --name registry.json --file registry.json --auth-mode login || echo '{"version":"1.0","tools":[]}' > registry.json + node buildScripts/updateRegistry.js "${{ env.TOOL_ID }}" "${{ env.TOOL_VERSION }}" "${{ env.TOOL_METADATA_JSON }}" + az storage blob upload \ + --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \ + --container-name ${{ secrets.AZURE_STORAGE_CONTAINER }} \ + --name registry.json --file registry.json \ + --auth-mode login --overwrite true + +- name: Update Supabase downloadurl + env: + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }} + run: | + FOLDER="${{ env.TOOL_ID }}-${{ env.TOOL_VERSION }}" + node buildScripts/updateSupabase.js \ + "${{ env.TOOL_ID }}" \ + "https://${{ secrets.AZURE_STORAGE_ACCOUNT }}.blob.core.windows.net/${{ secrets.AZURE_STORAGE_CONTAINER }}/${FOLDER}/${FOLDER}.tar.gz" +``` + +--- + +## Azure Blob Storage Setup + +### 1. Create Storage Account and Container + +```bash +# Create resource group (if needed) +az group create --name pptoolbox-rg --location eastus + +# Create storage account +az storage account create \ + --name \ + --resource-group pptoolbox-rg \ + --location eastus \ + --sku Standard_LRS \ + --allow-blob-public-access true + +# Create container with anonymous read access (blobs only) +az storage container create \ + --name tools \ + --account-name \ + --public-access blob \ + --auth-mode login +``` + +### 2. Upload Initial registry.json + +```bash +az storage blob upload \ + --account-name \ + --container-name tools \ + --name registry.json \ + --file src/main/data/registry.json \ + --auth-mode login +``` + +### 3. Configure CORS (if needed for browser-based access) + +```bash +az storage cors add \ + --methods GET HEAD \ + --origins "https://powerplatformtoolbox.com" \ + --services b \ + --account-name +``` + +--- + +## Transition / Rollout Plan + +1. **Create the Azure Blob container** following the setup steps above. +2. **Upload existing tool packages** to their per-tool version folders in the blob container (e.g. `-/-.tar.gz`). +3. **Upload an initial `registry.json`** to the blob container root. +4. **Update Supabase** `downloadurl` column for all tools to point to Azure Blob. +5. **Set `AZURE_BLOB_BASE_URL`** in the app's build environment and redeploy. +6. **Update the `convert-tool` GitHub Action** in `pptb-web` to upload to Azure Blob instead of (or in addition to) GitHub Releases. +7. **Monitor** for any download failures via Sentry before retiring GitHub Release uploads. + +> During the transition period, old GitHub Release URLs remain accessible, and newly installed tools will automatically use the Azure Blob URLs stored in Supabase. + +--- + +## Bulk migration scripts (pptb-web → Azure Blob + Supabase URL update) + +This repo includes two helper scripts to migrate historical assets and then update Supabase to point at the new Azure Blob URLs: + +- PowerShell: [buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1](../buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1) +- SQL: [buildScripts/sql/update-tools-download-and-icon-urls.sql](../buildScripts/sql/update-tools-download-and-icon-urls.sql) + +### 1) Copy all GitHub Release assets into Azure Blob + +This copies matching release assets from `https://github.com/PowerPlatformToolBox/pptb-web/releases` into your `tools` container using the documented layout: + +``` +tools/ + registry.json + packages/ + -/ + -.tar.gz + -.svg +``` + +> Note: some historical GitHub release icon assets are named like `--icon.svg`. The migration script normalizes these into Azure Blob as `packages/-/-.svg` (so the Supabase `iconurl` can be made consistent). + +**Prereqs** + +- Azure CLI installed and logged in: `az login` +- Access to the target storage account + container +- Optional but recommended: set `GITHUB_TOKEN` for higher GitHub API rate limits + +**Run** + +```pwsh +# Optional (recommended): increases GitHub API rate limit +$env:GITHUB_TOKEN = "" + +pwsh ./buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1 ` + -StorageAccount ` + -Container tools +``` + +**Dry run** + +```pwsh +pwsh ./buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1 ` + -StorageAccount ` + -Container tools ` + -WhatIf +``` + +**Overwrite behavior** + +- By default, existing blobs are left as-is. +- To force re-copying, pass `-Overwrite` (the script deletes the destination blob before copying). + +**Registry.json regeneration** + +- By default, the script does NOT modify `registry.json`. +- If you want the script to regenerate and upload `tools/registry.json` from Supabase after copying, pass `-RegenerateRegistryJson` (requires `SUPABASE_URL` + `SUPABASE_ANON_KEY`). + +**Regenerate `registry.json` only (no copy)** + +Use this if you want to retry registry generation/upload without re-copying any GitHub assets: + +```pwsh +$env:SUPABASE_URL = "https://.supabase.co" +$env:SUPABASE_ANON_KEY = "" + +pwsh ./buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1 ` + -StorageAccount ` + -Container tools ` + -OnlyRegenerateRegistryJson +``` + +Dry run: + +```pwsh +pwsh ./buildScripts/powershell/Move-PptbWebReleasesToAzureBlob.ps1 ` + -StorageAccount ` + -Container tools ` + -OnlyRegenerateRegistryJson ` + -WhatIf +``` + +### 2) Update Supabase `tools` table URLs (download + icon) + +The desktop app reads tool metadata from Supabase (table `tools`) and expects these columns: + +- `downloadurl` (full URL to `.tar.gz`) +- `iconurl` (full URL to `.svg`) + +The included SQL script updates both columns by: + +1. Extracting the filename from the existing URL (everything after the final `/`). +2. Deriving the folder from the filename (`-`). +3. Rewriting the URL to: + +``` +https://.blob.core.windows.net/tools/packages/-/ +``` + +**Run** + +1. Open the script: [buildScripts/sql/update-tools-download-and-icon-urls.sql](../buildScripts/sql/update-tools-download-and-icon-urls.sql) +2. Replace the placeholder `https://.blob.core.windows.net/tools` with your real base URL (no trailing slash). +3. Paste into the Supabase SQL editor and run. + +**Notes** + +- The SQL only targets rows that still point at GitHub (or `release-assets.githubusercontent.com`) and skips rows already pointing at `*.blob.core.windows.net`. +- The icon update is limited to `.svg` URLs. + +### Troubleshooting + +- If you see a transient message like "The specified blob does not exist" during the migration copy step, that can occur briefly right after starting a server-side copy. The PowerShell script retries and waits for the copy status to become available. +- If you see an error like "A redirected response (HTTP status code 302) from the copy source is not supported" / `CannotVerifyCopySource`, that is expected with GitHub Release download URLs (they often redirect to a signed, temporary URL). The PowerShell script attempts to resolve redirects and will fall back to downloading locally and uploading to Azure Blob if server-side copy cannot be used. +- If `az storage blob copy start` fails with a message like "The request may be blocked by network rules of storage account", your storage account is restricting access by network. Run the migration from an allowed network, or temporarily allow your public IP in the storage account firewall. + + Inspect current rules: + + ```bash + az storage account show -n -g --query networkRuleSet -o jsonc + ``` + + Temporarily allow a public IP (example): + + ```bash + az storage account network-rule add -n -g --ip-address + ``` diff --git a/packages/README.md b/packages/README.md index ef031e5a..9f6faf49 100644 --- a/packages/README.md +++ b/packages/README.md @@ -18,6 +18,7 @@ TypeScript type definitions for Power Platform ToolBox APIs. - [FetchXML Queries](#fetchxml-queries) - [Metadata Operations](#metadata-operations) - [Execute Actions/Functions](#execute-actionsfunctions) + - [Deploy Solutions](#deploy-solutions) - [API Reference](#api-reference) - [ToolBox API (`window.toolboxAPI`)](#toolbox-api-windowtoolboxapi) - [Connections](#connections-1) diff --git a/src/common/types/tool.ts b/src/common/types/tool.ts index 3edc044d..ee301bc6 100644 --- a/src/common/types/tool.ts +++ b/src/common/types/tool.ts @@ -28,7 +28,7 @@ export interface Tool { publishedAt?: string; createdAt?: string; // ISO date string from created_at field authors?: string[]; - iconUrl?: string; + icon?: string; // Relative path to SVG icon in dist/ folder (e.g., "icon.svg" or "icons/icon.svg") settings?: ToolSettings; localPath?: string; // For local development tools - absolute path to tool directory npmPackageName?: string; // For npm-installed tools - package name in node_modules @@ -54,7 +54,7 @@ export interface ToolRegistryEntry { description: string; authors?: string[]; // full list of contributors version: string; - iconUrl?: string; + icon?: string; // Relative path to SVG icon in dist/ folder (e.g., "icon.svg" or "icons/icon.svg") downloadUrl: string; readmeUrl?: string; // URL or relative path to README file checksum?: string; @@ -82,7 +82,7 @@ export interface ToolManifest { version: string; description: string; authors?: string[]; // contributors list - icon?: string; + icon?: string; // Relative path to SVG icon in dist/ folder (e.g., "icon.svg" or "icons/icon.svg") installPath: string; installedAt: string; source: "registry" | "npm" | "local"; // Track installation source diff --git a/src/main/constants.ts b/src/main/constants.ts index 60928936..ce1b076f 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -22,3 +22,18 @@ export const TOOL_REGISTRY_URL = "https://www.powerplatformtoolbox.com/registry/ */ export const SUPABASE_URL = process.env.SUPABASE_URL || ""; export const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY || ""; + +/** + * Azure Blob Storage Configuration + * Base URL for the Azure Blob container that hosts tool packages and the remote registry. + * The container should be publicly readable (anonymous read access for blobs). + * Set AZURE_BLOB_BASE_URL to the full container URL, e.g.: + * https://.blob.core.windows.net/tools + * + * Expected layout inside the container: + * registry.json – remote registry index (fallback after Supabase) + * packages/-/-.tar.gz – pre-packaged tool archive + * packages/-/icon-light.png – light theme icon for the tool/version + * packages/-/icon-dark.png – dark theme icon for the tool/version + */ +export const AZURE_BLOB_BASE_URL = process.env.AZURE_BLOB_BASE_URL || ""; diff --git a/src/main/data/registry.json b/src/main/data/registry.json index 2ec244fd..9cc2c27b 100644 --- a/src/main/data/registry.json +++ b/src/main/data/registry.json @@ -10,7 +10,7 @@ "description": "Generate Entity Relationship Diagrams for Dataverse", "authors": ["Power Platform ToolBox Team"], "version": "1.0.4", - "downloadUrl": "https://github.com/PowerPlatformToolBox/pptb-web/releases/download/power-maverick-tool-erd-generator-1.0.4/power-maverick-tool-erd-generator-1.0.4.tar.gz", + "downloadUrl": "power-maverick-tool-erd-generator-1.0.4.tar.gz", "icon": "icon.png", "checksum": "sha256:0000000000000000000000000000000000000000000000000000000000000000", "size": 50000, @@ -29,7 +29,7 @@ "description": "A sample HTML tool that showcases various features provided by the ToolBox", "authors": ["Power Maverick"], "version": "1.0.5", - "downloadUrl": "https://github.com/PowerPlatformToolBox/pptb-web/releases/download/pptb-standard-sample-tool-1.0.5/pptb-standard-sample-tool-1.0.5.tar.gz", + "downloadUrl": "pptb-standard-sample-tool-1.0.5.tar.gz", "icon": "icon.png", "checksum": "sha256:0000000000000000000000000000000000000000000000000000000000000000", "size": 75000, diff --git a/src/main/index.ts b/src/main/index.ts index 38e6ba17..bda35fac 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -142,8 +142,14 @@ class ToolBoxApp { this.connectionsManager = new ConnectionsManager(); this.api = new ToolBoxUtilityManager(); - // Pass Supabase credentials from environment variables or use defaults from constants - this.toolManager = new ToolManager(path.join(app.getPath("userData"), "tools"), process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY, this.installIdManager); + // Pass Supabase credentials and Azure Blob base URL from environment variables + this.toolManager = new ToolManager( + path.join(app.getPath("userData"), "tools"), + process.env.SUPABASE_URL, + process.env.SUPABASE_ANON_KEY, + this.installIdManager, + process.env.AZURE_BLOB_BASE_URL, + ); this.browserviewProtocolManager = new BrowserviewProtocolManager(this.toolManager, this.settingsManager); this.autoUpdateManager = new AutoUpdateManager(); this.browserManager = new BrowserManager(); @@ -2520,19 +2526,24 @@ class ToolBoxApp { /** * Check tool download capability - * Tests downloading a sample tool from GitHub releases + * Tests downloading a tool package from Azure Blob Storage (when configured) or + * falls back to checking reachability of the registry endpoint. */ private async checkToolDownload(): Promise<{ success: boolean; message?: string }> { - const TEST_TOOL_DOWNLOAD_URL = "https://github.com/PowerPlatformToolBox/pptb-web/releases/download/pptb-standard-sample-tool-1.0.9/pptb-standard-sample-tool-1.0.9.tar.gz"; + const azureBlobBaseUrl = process.env.AZURE_BLOB_BASE_URL || ""; + const TEST_TOOL_DOWNLOAD_URL = azureBlobBaseUrl + ? `${azureBlobBaseUrl.replace(/\/$/, "")}/test/pptb-standard-sample-tool-download-test.tar.gz` + : "https://github.com/PowerPlatformToolBox/pptb-web/releases/download/test/pptb-standard-sample-tool-download-test.tar.gz"; const tempDir = path.join(app.getPath("temp"), "pptb-download-test"); - const downloadPath = path.join(tempDir, "pptb-standard-sample-tool-1.0.9.tar.gz"); + const downloadPath = path.join(tempDir, "pptb-standard-sample-tool-download-test.tar.gz"); try { if (!fs.existsSync(tempDir)) { fs.mkdirSync(tempDir, { recursive: true }); } - logInfo(`[Troubleshooting] Testing download from GitHub release: ${TEST_TOOL_DOWNLOAD_URL}`); + const downloadSource = azureBlobBaseUrl ? "Azure Blob Storage" : "GitHub release"; + logInfo(`[Troubleshooting] Testing download from ${downloadSource}: ${TEST_TOOL_DOWNLOAD_URL}`); await new Promise((resolve, reject) => { const download = (url: string, redirectDepth = 0) => { @@ -2590,7 +2601,7 @@ class ToolBoxApp { return { success: true, - message: `Successfully downloaded GitHub release asset (${fileSizeMB} MB)`, + message: `Successfully downloaded tool package from ${azureBlobBaseUrl ? "Azure Blob Storage" : "GitHub release"} (${fileSizeMB} MB)`, }; } catch (error) { try { diff --git a/src/main/managers/modalWindowManager.ts b/src/main/managers/modalWindowManager.ts index 2c6b2952..bb43e3e3 100644 --- a/src/main/managers/modalWindowManager.ts +++ b/src/main/managers/modalWindowManager.ts @@ -137,7 +137,7 @@ export class ModalWindowManager { - + `; + + const releaseNotesHtml = buildReleaseNotesHtml(model.releaseNotes, model.version); + + const processSteps = isAvailable + ? [ + { n: "1", text: "The update will download in the background." }, + { n: "2", text: "Once downloaded, you will be prompted to install." }, + { n: "3", text: "The app will restart automatically to apply the update." }, + ] + : [ + { n: "1", text: "Click Restart & Install to apply the update now." }, + { n: "2", text: "The app will close and restart automatically." }, + { n: "3", text: "Any in-progress work in open tools will be lost. Your app settings and connections will be preserved." }, + ]; + + const heroIcon = isAvailable + ? ` + + ` + : ` + + `; + + const stepsHtml = processSteps.map((s) => `

${s.n}${s.text}
`).join("\n"); + + const bannerText = isAvailable ? "This update requires an app restart to take effect. You can choose to download now or be reminded later." : "This update has been downloaded and is ready to install. The app will restart to apply the changes."; + + const footerButtons = isAvailable + ? ` + ` + : ` + `; + + const body = ` +
+
+
${heroIcon}
+
+

${isAvailable ? "Software Update" : "Ready to Install"}

+

${isAvailable ? "Update Available" : "Update Downloaded"}

+ Version ${model.version} +
+ +
+
+ Downloading update… +
+
+
+
+ + + + ${bannerText} +
+
+

What to expect

+ ${stepsHtml} +
+ ${releaseNotesHtml} +
+ +
`; + + return { styles, body }; +} + +function buildReleaseNotesHtml(releaseNotes: string | null | undefined, version: string): string { + if (!releaseNotes) { + return ""; + } + + // releaseNotes from electron-updater can be a string (HTML or plain text) or an array of objects + const rawText = typeof releaseNotes === "string" ? releaseNotes.trim() : ""; + if (!rawText) { + return ""; + } + + // Extract only the ## Highlights section from the markdown-formatted release notes. + // The release notes follow a structured format with sections like ## Highlights, ## Fixes, etc. + const highlightsText = extractHighlightsSection(rawText); + + // Sanitize using an allowlist approach: strip all tags except safe formatting elements, + // and strip all attributes from allowed tags to prevent XSS via event handlers or + // javascript: URLs in the inline data URL modal context. + const ALLOWED_TAGS = new Set(["b", "i", "em", "strong", "ul", "ol", "li", "p", "br", "code", "pre", "span"]); + const sanitize = (html: string) => + html.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>/g, (match, tag: string) => { + if (!ALLOWED_TAGS.has(tag.toLowerCase())) { + return ""; + } + // Keep only the tag name, strip all attributes + const isClosing = match.startsWith("` : `<${tag.toLowerCase()}>`; + }); + + const fullNotesUrl = `https://github.com/PowerPlatformToolBox/desktop-app/releases/tag/v${version}`; + + if (highlightsText) { + // Convert the extracted plain-text bullet list to basic HTML list items + const listItems = highlightsText + .split("\n") + .map((line) => line.replace(/^-\s*/, "").trim()) + .filter((line) => line.length > 0) + .map((line) => `
  • ${sanitize(line)}
  • `) + .join("\n"); + + return ` +
    +

    Highlights

    +
      ${listItems}
    + View full release notes → +
    `; + } + + // Fallback: no structured highlights found — show sanitized raw notes with a link + const sanitizedRaw = sanitize(rawText); + return ` +
    +

    Release Notes

    +
    ${sanitizedRaw}
    + View full release notes → +
    `; +} + +/** + * Extract the content of the "## Highlights" section from markdown-formatted release notes. + * Returns the raw bullet-list text, or an empty string if the section is not found. + */ +function extractHighlightsSection(markdown: string): string { + // Match the ## Highlights section up to the next ## heading or end of string + const match = /^##\s+Highlights\s*\n([\s\S]*?)(?=^##\s|\s*$)/im.exec(markdown); + if (!match) { + return ""; + } + return match[1].trim(); +} diff --git a/src/renderer/modules/autoUpdateManagement.ts b/src/renderer/modules/autoUpdateManagement.ts index 26ea8365..8cb64e15 100644 --- a/src/renderer/modules/autoUpdateManagement.ts +++ b/src/renderer/modules/autoUpdateManagement.ts @@ -3,6 +3,85 @@ * Handles application auto-update UI and status */ +import { getUpdateNotificationModalControllerScript } from "../modals/updateNotification/controller"; +import { getUpdateNotificationModalView } from "../modals/updateNotification/view"; +import { offBrowserWindowModalClosed, offBrowserWindowModalMessage, onBrowserWindowModalClosed, onBrowserWindowModalMessage, sendBrowserWindowModalMessage, showBrowserWindowModal } from "./browserWindowModals"; + +const UPDATE_NOTIFICATION_MODAL_ID = "update-notification"; +const UPDATE_NOTIFICATION_MODAL_CHANNELS = { + download: "update-notification:download", + install: "update-notification:install", + dismiss: "update-notification:dismiss", + openExternal: "update-notification:open-external", +} as const; + +const UPDATE_NOTIFICATION_MODAL_WIDTH = 560; +const UPDATE_NOTIFICATION_MODAL_HEIGHT = 540; + +let updateModalOpen = false; + +/** + * Build and show the update notification modal + */ +async function showUpdateNotificationModal(type: "available" | "downloaded", version: string, releaseNotes?: string | null): Promise { + if (updateModalOpen) { + return; + } + + const isDarkTheme = document.body.classList.contains("dark-theme"); + const currentVersion = (await window.toolboxAPI.getAppVersion().catch(() => "")) as string; + + const { styles, body } = getUpdateNotificationModalView({ + type, + version, + currentVersion, + releaseNotes, + isDarkTheme, + }); + + const script = getUpdateNotificationModalControllerScript({ + type, + channels: UPDATE_NOTIFICATION_MODAL_CHANNELS, + }); + + const html = `${styles}\n${body}\n${script}`.trim(); + + const onMessage = (payload: { channel: string; data?: unknown }) => { + if (!payload) return; + if (payload.channel === UPDATE_NOTIFICATION_MODAL_CHANNELS.download) { + window.toolboxAPI.downloadUpdate().catch(() => undefined); + } else if (payload.channel === UPDATE_NOTIFICATION_MODAL_CHANNELS.install) { + window.toolboxAPI.quitAndInstall(); + } else if (payload.channel === UPDATE_NOTIFICATION_MODAL_CHANNELS.openExternal) { + const url = (payload.data as { url?: string })?.url; + if (url) { + window.toolboxAPI.openExternal(url).catch(() => undefined); + } + } + }; + + const onClosed = () => { + updateModalOpen = false; + offBrowserWindowModalMessage(onMessage); + offBrowserWindowModalClosed(onClosed); + }; + + onBrowserWindowModalMessage(onMessage); + onBrowserWindowModalClosed(onClosed); + + updateModalOpen = true; + try { + await showBrowserWindowModal({ + id: UPDATE_NOTIFICATION_MODAL_ID, + html, + width: UPDATE_NOTIFICATION_MODAL_WIDTH, + height: UPDATE_NOTIFICATION_MODAL_HEIGHT, + }); + } catch (_error) { + onClosed(); + } +} + /** * Update UI elements for check for updates button */ @@ -153,6 +232,7 @@ export function setupAutoUpdateListeners(): void { window.toolboxAPI.onUpdateAvailable((info: any) => { showUpdateStatus(`Update available: Version ${info.version}`, "success"); updateCheckForUpdatesUI("available", `Update available: Version ${info.version}`); + void showUpdateNotificationModal("available", info.version, info.releaseNotes as string | null); }); window.toolboxAPI.onUpdateNotAvailable(() => { @@ -164,12 +244,18 @@ export function setupAutoUpdateListeners(): void { showUpdateProgress(); updateProgress(progress.percent); showUpdateStatus(`Downloading update: ${progress.percent}%`, "info"); + void sendBrowserWindowModalMessage({ channel: "update:progress", data: { percent: progress.percent } }).catch(() => undefined); }); window.toolboxAPI.onUpdateDownloaded((info: any) => { hideUpdateProgress(); showUpdateStatus(`Update downloaded: Version ${info.version}. Restart to install.`, "success"); updateCheckForUpdatesUI("idle"); + if (updateModalOpen) { + void sendBrowserWindowModalMessage({ channel: "update:downloaded", data: { version: info.version } }).catch(() => undefined); + } else { + void showUpdateNotificationModal("downloaded", info.version); + } }); window.toolboxAPI.onUpdateError((error: string) => { From 288d006d0f43bddcb21f4466f96f30ae8e892997 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:07:50 -0500 Subject: [PATCH 028/178] Add global search command palette to activity bar (#409) * Initial plan * Add global search command palette to activity bar Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Enhance global search: launch tools, show marketplace detail, focus settings Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Update src/renderer/index.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/renderer/constants/index.ts | 1 + src/renderer/icons/dark/search.svg | 1 + src/renderer/icons/light/search.svg | 1 + src/renderer/index.html | 30 ++ .../modules/globalSearchManagement.ts | 488 ++++++++++++++++++ src/renderer/modules/initialization.ts | 4 + src/renderer/styles.scss | 273 ++++++++++ 7 files changed, 798 insertions(+) create mode 100644 src/renderer/icons/dark/search.svg create mode 100644 src/renderer/icons/light/search.svg create mode 100644 src/renderer/modules/globalSearchManagement.ts diff --git a/src/renderer/constants/index.ts b/src/renderer/constants/index.ts index fc8ea85c..b7d85434 100644 --- a/src/renderer/constants/index.ts +++ b/src/renderer/constants/index.ts @@ -35,6 +35,7 @@ export const ACTIVITY_BAR_ICONS = [ { id: "tools-icon", file: "tools.svg" }, { id: "connections-icon", file: "connections.svg" }, { id: "marketplace-icon", file: "marketplace.svg" }, + { id: "search-icon", file: "search.svg" }, { id: "debug-icon", file: "debug.svg" }, { id: "settings-icon", file: "settings.svg" }, ] as const; diff --git a/src/renderer/icons/dark/search.svg b/src/renderer/icons/dark/search.svg new file mode 100644 index 00000000..24380900 --- /dev/null +++ b/src/renderer/icons/dark/search.svg @@ -0,0 +1 @@ + diff --git a/src/renderer/icons/light/search.svg b/src/renderer/icons/light/search.svg new file mode 100644 index 00000000..31e3c321 --- /dev/null +++ b/src/renderer/icons/light/search.svg @@ -0,0 +1 @@ + diff --git a/src/renderer/index.html b/src/renderer/index.html index 75c2ecd8..61183502 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -29,6 +29,9 @@ + @@ -801,6 +804,33 @@

    Tool Settings

    + + + diff --git a/src/renderer/modules/globalSearchManagement.ts b/src/renderer/modules/globalSearchManagement.ts new file mode 100644 index 00000000..bdef8374 --- /dev/null +++ b/src/renderer/modules/globalSearchManagement.ts @@ -0,0 +1,488 @@ +/** + * Global Search management module + * Implements a Command Palette-style global search over installed tools, + * marketplace tools, connections, and settings. + */ + +import { captureException, logInfo } from "../../common/sentryHelper"; +import type { DataverseConnection } from "../../common/types/connection"; +import type { Tool } from "../../common/types/tool"; +import type { ToolDetail } from "../types/index"; +import { escapeHtml } from "../utils/toolIconResolver"; +import { getToolLibrary, openToolDetail } from "./marketplaceManagement"; +import { switchSidebar } from "./sidebarManagement"; + +// ── Types ───────────────────────────────────────────────────────────────────── + +type ResultCategory = "installed" | "marketplace" | "connection" | "settings"; + +interface SearchResult { + id: string; + name: string; + description: string; + category: ResultCategory; + iconUrl?: string; + action: () => void; +} + +// ── Module state ────────────────────────────────────────────────────────────── + +let isOpen = false; +let selectedIndex = -1; +let currentResults: SearchResult[] = []; + +// ── Static settings entries ─────────────────────────────────────────────────── + +const SETTINGS_ENTRIES: Array<{ name: string; description: string; focusId?: string }> = [ + { name: "Theme", description: "Change the application theme (light / dark / system)", focusId: "sidebar-theme-select" }, + { name: "Auto Update", description: "Configure automatic updates", focusId: "sidebar-auto-update-check" }, + { name: "Debug Menu", description: "Show or hide the debug / install panel", focusId: "sidebar-show-debug-menu-check" }, + { name: "Terminal Font", description: "Customize the integrated terminal font", focusId: "sidebar-terminal-font-select" }, + { name: "Deprecated Tools", description: "Control visibility of deprecated tools", focusId: "sidebar-deprecated-tools-select" }, + { name: "Tool Display Mode", description: "Choose standard or compact tool display", focusId: "sidebar-tool-display-mode-select" }, + { name: "Connections", description: "Manage Dataverse connections" }, + { name: "Installed Tools", description: "Browse installed tools" }, + { name: "Marketplace", description: "Browse and install tools from the marketplace" }, +]; + +// ── DOM helpers ─────────────────────────────────────────────────────────────── + +function getOverlay(): HTMLElement | null { + return document.getElementById("global-search-overlay"); +} + +function getInput(): HTMLInputElement | null { + return document.getElementById("global-search-input") as HTMLInputElement | null; +} + +function getResultsContainer(): HTMLElement | null { + return document.getElementById("global-search-results"); +} + +// ── Open / close ────────────────────────────────────────────────────────────── + +/** + * Open the global search command palette. + */ +export function openGlobalSearch(): void { + const overlay = getOverlay(); + const input = getInput(); + if (!overlay || !input) return; + + isOpen = true; + selectedIndex = -1; + currentResults = []; + + overlay.style.display = "flex"; + input.value = ""; + + // Sync input icon to current theme + syncInputIconTheme(); + + // Show empty / default state + renderResults([]); + + // Focus the input after the layout pass + requestAnimationFrame(() => { + input.focus(); + }); + + logInfo("Global search opened", {}); +} + +/** + * Close the global search command palette. + */ +export function closeGlobalSearch(): void { + const overlay = getOverlay(); + if (!overlay) return; + + isOpen = false; + selectedIndex = -1; + currentResults = []; + overlay.style.display = "none"; +} + +// ── Theme helpers ───────────────────────────────────────────────────────────── + +function syncInputIconTheme(): void { + const isDark = document.body.classList.contains("dark-theme"); + const icon = document.getElementById("global-search-input-icon") as HTMLImageElement | null; + if (icon) { + icon.src = isDark ? "icons/dark/search.svg" : "icons/light/search.svg"; + } +} + +// ── Settings focus helper ───────────────────────────────────────────────────── + +/** + * Switch to settings sidebar and focus/scroll a specific setting element. + */ +function navigateToSetting(focusId: string | undefined): void { + switchSidebar("settings"); + if (!focusId) return; + + // Wait for sidebar transition then focus/scroll the element + requestAnimationFrame(() => { + const el = document.getElementById(focusId) as HTMLElement | null; + if (!el) return; + el.scrollIntoView({ behavior: "smooth", block: "center" }); + el.focus(); + // Highlight briefly so the user sees the focused setting + el.classList.add("global-search-highlight"); + setTimeout(() => el.classList.remove("global-search-highlight"), 1500); + }); +} + +// ── Search ──────────────────────────────────────────────────────────────────── + +async function runSearch(query: string): Promise { + const q = query.trim().toLowerCase(); + const results: SearchResult[] = []; + + try { + // 1. Installed tools + const installedRaw = await window.toolboxAPI.getAllTools(); + const installedTools = installedRaw as Tool[]; + for (const tool of installedTools) { + if (matches(q, tool.name, tool.description)) { + const toolId = tool.id; + results.push({ + id: `installed:${toolId}`, + name: tool.name, + description: tool.description ?? "", + category: "installed", + action: () => { + closeGlobalSearch(); + // Dynamically import to avoid circular dependency + import("./toolManagement") + .then(({ launchTool }) => launchTool(toolId)) + .catch((err) => { + captureException(err instanceof Error ? err : new Error(String(err)), { + tags: { context: "global_search", action: "launch_tool" }, + level: "warning", + }); + }); + }, + }); + } + } + + // 2. Marketplace tools (already cached in memory) + const libraryTools: ToolDetail[] = getToolLibrary(); + const installedIds = new Set(installedTools.map((t) => t.id)); + for (const tool of libraryTools) { + // Skip tools already shown in installed list + if (installedIds.has(tool.id)) continue; + if (matches(q, tool.name, tool.description)) { + const toolSnapshot = tool; + results.push({ + id: `marketplace:${tool.id}`, + name: tool.name, + description: tool.description ?? "", + category: "marketplace", + action: () => { + closeGlobalSearch(); + openToolDetail(toolSnapshot, false).catch((err) => { + captureException(err instanceof Error ? err : new Error(String(err)), { + tags: { context: "global_search", action: "open_tool_detail" }, + level: "warning", + }); + }); + }, + }); + } + } + + // 3. Connections + const connectionsRaw = await window.toolboxAPI.connections.getAll(); + const connections = connectionsRaw as DataverseConnection[]; + for (const conn of connections) { + if (matches(q, conn.name, conn.url, conn.environment)) { + results.push({ + id: `connection:${conn.id}`, + name: conn.name, + description: `${conn.environment} · ${conn.url}`, + category: "connection", + action: () => { + closeGlobalSearch(); + switchSidebar("connections"); + }, + }); + } + } + + // 4. Settings entries + for (const entry of SETTINGS_ENTRIES) { + if (matches(q, entry.name, entry.description)) { + const focusId = entry.focusId; + const entryName = entry.name; + results.push({ + id: `settings:${entryName}`, + name: entryName, + description: entry.description, + category: "settings", + action: () => { + closeGlobalSearch(); + if (entryName === "Connections") { + switchSidebar("connections"); + } else if (entryName === "Installed Tools") { + switchSidebar("tools"); + } else if (entryName === "Marketplace") { + switchSidebar("marketplace"); + } else { + navigateToSetting(focusId); + } + }, + }); + } + } + } catch (err) { + captureException(err instanceof Error ? err : new Error(String(err)), { + tags: { context: "global_search", action: "run_search" }, + level: "warning", + }); + } + + currentResults = results; + selectedIndex = results.length > 0 ? 0 : -1; + renderResults(results); +} + +function matches(query: string, ...fields: (string | undefined)[]): boolean { + if (!query) return true; + return fields.some((f) => f && f.toLowerCase().includes(query)); +} + +// ── Rendering ───────────────────────────────────────────────────────────────── + +function renderResults(results: SearchResult[]): void { + const container = getResultsContainer(); + if (!container) return; + + if (results.length === 0) { + const input = getInput(); + const query = input?.value.trim() ?? ""; + if (!query) { + container.innerHTML = ` +
    + + Start typing to search tools, connections, and settings… +
    `; + syncEmptyIconTheme(); + } else { + container.innerHTML = ` +
    + + No results for "${escapeHtml(query)}" +
    `; + syncEmptyIconTheme(); + } + return; + } + + // Group results by category + const grouped: Record = { + installed: [], + marketplace: [], + connection: [], + settings: [], + }; + for (const r of results) { + grouped[r.category].push(r); + } + + const sectionOrder: ResultCategory[] = ["installed", "marketplace", "connection", "settings"]; + const sectionLabels: Record = { + installed: "Installed Tools", + marketplace: "Marketplace", + connection: "Connections", + settings: "Settings", + }; + const badgeClasses: Record = { + installed: "badge-installed", + marketplace: "badge-marketplace", + connection: "badge-connection", + settings: "badge-settings", + }; + const actionHints: Record = { + installed: "Launch", + marketplace: "View Details", + connection: "Go to Connections", + settings: "Go to Settings", + }; + + let html = ""; + let globalIdx = 0; + + for (const category of sectionOrder) { + const group = grouped[category]; + if (group.length === 0) continue; + + html += ``; + for (const result of group) { + const isSelected = globalIdx === selectedIndex; + const badgeClass = badgeClasses[result.category]; + const hint = actionHints[result.category]; + html += ` +
    +
    + +
    +
    +
    ${escapeHtml(result.name)}
    +
    ${escapeHtml(result.description)}
    +
    + ${escapeHtml(sectionLabels[result.category])} +
    `; + globalIdx++; + } + html += `
    `; + } + + container.innerHTML = html; + syncEmptyIconTheme(); + + // Attach click listeners + container.querySelectorAll(".global-search-item").forEach((item) => { + item.addEventListener("click", () => { + const idx = parseInt(item.dataset["index"] ?? "-1", 10); + if (idx >= 0 && idx < currentResults.length) { + currentResults[idx]?.action(); + } + }); + }); +} + +function getDefaultIconForCategory(category: ResultCategory): string { + const isDark = document.body.classList.contains("dark-theme"); + const theme = isDark ? "dark" : "light"; + switch (category) { + case "installed": + return `icons/${theme}/tools.svg`; + case "marketplace": + return `icons/${theme}/marketplace.svg`; + case "connection": + return `icons/${theme}/connections.svg`; + case "settings": + return `icons/${theme}/settings.svg`; + } +} + +function syncEmptyIconTheme(): void { + const isDark = document.body.classList.contains("dark-theme"); + const emptyIcon = document.getElementById("global-search-empty-icon") as HTMLImageElement | null; + if (emptyIcon) { + emptyIcon.src = isDark ? "icons/dark/search.svg" : "icons/light/search.svg"; + } +} + +// ── Keyboard navigation ─────────────────────────────────────────────────────── + +function moveSelection(delta: number): void { + if (currentResults.length === 0) return; + + if (selectedIndex === -1) { + selectedIndex = delta > 0 ? 0 : currentResults.length - 1; + } else { + selectedIndex = (selectedIndex + delta + currentResults.length) % currentResults.length; + } + + updateSelectionUI(); +} + +function updateSelectionUI(): void { + const container = getResultsContainer(); + if (!container) return; + + container.querySelectorAll(".global-search-item").forEach((item) => { + const idx = parseInt(item.dataset["index"] ?? "-1", 10); + item.classList.toggle("selected", idx === selectedIndex); + item.setAttribute("aria-selected", String(idx === selectedIndex)); + }); + + // Scroll selected item into view + const selectedEl = container.querySelector(".global-search-item.selected"); + selectedEl?.scrollIntoView({ block: "nearest" }); +} + +function activateSelected(): void { + if (selectedIndex >= 0 && selectedIndex < currentResults.length) { + currentResults[selectedIndex]?.action(); + } +} + +// ── Event binding ───────────────────────────────────────────────────────────── + +/** + * Initialize the global search feature. + * Should be called once during application initialization. + */ +export function initializeGlobalSearch(): void { + // Activity bar search button + const searchBtn = document.getElementById("global-search-btn"); + if (searchBtn && !(searchBtn as HTMLElement & { _pptbBound?: boolean })._pptbBound) { + (searchBtn as HTMLElement & { _pptbBound?: boolean })._pptbBound = true; + searchBtn.addEventListener("click", () => openGlobalSearch()); + } + + // Overlay backdrop click → close + const overlay = getOverlay(); + if (overlay && !(overlay as HTMLElement & { _pptbBound?: boolean })._pptbBound) { + (overlay as HTMLElement & { _pptbBound?: boolean })._pptbBound = true; + overlay.addEventListener("click", (e) => { + if (e.target === overlay) closeGlobalSearch(); + }); + } + + // Search input + const input = getInput(); + if (input && !(input as HTMLElement & { _pptbBound?: boolean })._pptbBound) { + (input as HTMLElement & { _pptbBound?: boolean })._pptbBound = true; + + input.addEventListener("input", () => { + runSearch(input.value).catch((err) => { + captureException(err instanceof Error ? err : new Error(String(err)), { + tags: { context: "global_search", action: "input_search" }, + level: "warning", + }); + }); + }); + + input.addEventListener("keydown", (e: KeyboardEvent) => { + switch (e.key) { + case "ArrowDown": + e.preventDefault(); + moveSelection(1); + break; + case "ArrowUp": + e.preventDefault(); + moveSelection(-1); + break; + case "Enter": + e.preventDefault(); + activateSelected(); + break; + case "Escape": + e.preventDefault(); + closeGlobalSearch(); + break; + } + }); + } + + // Global keyboard shortcut: Ctrl+Shift+P + document.addEventListener("keydown", (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === "P") { + e.preventDefault(); + if (isOpen) { + closeGlobalSearch(); + } else { + openGlobalSearch(); + } + } + }); + + logInfo("Global search initialized", {}); +} + diff --git a/src/renderer/modules/initialization.ts b/src/renderer/modules/initialization.ts index a03b5dd9..30fb3dfa 100644 --- a/src/renderer/modules/initialization.ts +++ b/src/renderer/modules/initialization.ts @@ -69,6 +69,7 @@ import { DEFAULT_TERMINAL_FONT, LOADING_SCREEN_FADE_DURATION } from "../constant import { handleCheckForUpdates, setupAutoUpdateListeners } from "./autoUpdateManagement"; import { initializeBrowserWindowModals } from "./browserWindowModals"; import { handleReauthentication, initializeAddConnectionModalBridge, loadSidebarConnections, openAddConnectionModal, updateFooterConnection } from "./connectionManagement"; +import { initializeGlobalSearch } from "./globalSearchManagement"; import { loadHomepageData, setupHomepageActions } from "./homepageManagement"; import { loadMarketplace, loadToolsLibrary } from "./marketplaceManagement"; import { closeModal, openModal } from "./modalManagement"; @@ -140,6 +141,9 @@ export async function initializeApplication(): Promise { // Set up homepage actions setupHomepageActions(); + // Set up global search command palette + initializeGlobalSearch(); + addBreadcrumb("UI components initialized", "init", "info"); // Load and apply theme settings on startup diff --git a/src/renderer/styles.scss b/src/renderer/styles.scss index 7c62a706..19c4084b 100644 --- a/src/renderer/styles.scss +++ b/src/renderer/styles.scss @@ -4490,3 +4490,276 @@ body.dark-theme .csp-warning ul { .context-menu-item span { flex: 1; } + +/* ============================================================ + Global Search Command Palette + ============================================================ */ + +.global-search-overlay { + position: fixed; + inset: 0; + background: rgba(0, 0, 0, 0.5); + z-index: 9999; + display: flex; + align-items: flex-start; + justify-content: center; + padding-top: 80px; + backdrop-filter: blur(4px); +} + +.global-search-container { + background: var(--bg-color); + border: 1px solid var(--border-color); + border-radius: 8px; + width: 680px; + max-width: calc(100vw - 48px); + max-height: calc(100vh - 160px); + box-shadow: var(--elevation-high); + display: flex; + flex-direction: column; + overflow: hidden; +} + +.global-search-input-wrapper { + display: flex; + align-items: center; + gap: 10px; + padding: 12px 16px; + border-bottom: 1px solid var(--border-color); + background: var(--bg-color); +} + +.global-search-input-icon { + width: 18px; + height: 18px; + opacity: 0.6; + flex-shrink: 0; +} + +.global-search-input { + flex: 1; + background: transparent; + border: none; + outline: none; + font-size: 15px; + color: var(--text-color); + caret-color: var(--accent-color); + font-family: inherit; +} + +.global-search-input::placeholder { + color: var(--text-secondary); +} + +.global-search-kbd { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 2px 6px; + border: 1px solid var(--border-color); + border-radius: 4px; + font-size: 11px; + color: var(--text-secondary); + background: var(--secondary-color); + font-family: inherit; + cursor: default; + flex-shrink: 0; +} + +.global-search-results { + flex: 1; + overflow-y: auto; + max-height: 480px; + padding: 8px 0; +} + +.global-search-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 32px 16px; + color: var(--text-secondary); + font-size: 14px; + gap: 8px; +} + +.global-search-empty-icon { + width: 32px; + height: 32px; + opacity: 0.4; +} + +.global-search-section-label { + padding: 6px 16px 4px; + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--text-secondary); + user-select: none; +} + +.global-search-item { + display: flex; + align-items: center; + gap: 12px; + padding: 8px 16px; + cursor: pointer; + transition: background 0.1s; + border-radius: 0; + outline: none; +} + +.global-search-item:hover, +.global-search-item.selected { + background: var(--activity-item-hover-bg); +} + +.global-search-item.selected { + background: var(--activity-item-active-bg); + border-left: 2px solid var(--accent-color); + padding-left: 14px; +} + +.global-search-item-icon { + width: 24px; + height: 24px; + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + overflow: hidden; +} + +.global-search-item-icon img { + width: 20px; + height: 20px; + object-fit: contain; +} + +.global-search-item-text { + flex: 1; + min-width: 0; +} + +.global-search-item-name { + font-size: 13px; + font-weight: 500; + color: var(--text-color); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.global-search-item-desc { + font-size: 11px; + color: var(--text-secondary); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-top: 1px; +} + +.global-search-item-badge { + display: inline-flex; + align-items: center; + padding: 2px 7px; + border-radius: 10px; + font-size: 10px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.04em; + flex-shrink: 0; +} + +.global-search-item-badge.badge-installed { + background: rgba(16, 124, 16, 0.15); + color: #107c10; +} + +.global-search-item-badge.badge-marketplace { + background: rgba(0, 120, 212, 0.12); + color: #0078d4; +} + +.global-search-item-badge.badge-connection { + background: rgba(255, 140, 0, 0.12); + color: #c87800; +} + +.global-search-item-badge.badge-settings { + background: rgba(102, 102, 102, 0.12); + color: #666; +} + +body.dark-theme .global-search-item-badge.badge-installed { + background: rgba(54, 189, 54, 0.15); + color: #36bd36; +} + +body.dark-theme .global-search-item-badge.badge-marketplace { + background: rgba(0, 180, 255, 0.15); + color: #29b6f6; +} + +body.dark-theme .global-search-item-badge.badge-connection { + background: rgba(255, 180, 60, 0.15); + color: #ffb43a; +} + +body.dark-theme .global-search-item-badge.badge-settings { + background: rgba(180, 180, 180, 0.15); + color: #b4b4b4; +} + +.global-search-footer { + display: flex; + align-items: center; + gap: 16px; + padding: 8px 16px; + border-top: 1px solid var(--border-color); + font-size: 11px; + color: var(--text-secondary); + background: var(--secondary-color); +} + +.global-search-footer kbd { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 1px 5px; + border: 1px solid var(--border-color); + border-radius: 3px; + font-size: 10px; + background: var(--bg-color); + font-family: inherit; + margin-right: 3px; +} + +.global-search-divider { + height: 1px; + background: var(--border-color); + margin: 4px 0; +} + +/* Highlight pulse for focused setting element */ +@keyframes global-search-pulse { + 0% { + outline: 2px solid transparent; + outline-offset: 2px; + } + 30% { + outline: 2px solid var(--accent-color); + outline-offset: 3px; + } + 100% { + outline: 2px solid transparent; + outline-offset: 2px; + } +} + +.global-search-highlight { + animation: global-search-pulse 1.5s ease-out; +} From 5a5eeca20c8c9ee6a3a615d3291902d6c5bbf1b2 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:15:09 -0500 Subject: [PATCH 029/178] Improve tool load time (#410) * Improve tool load time * Update src/renderer/index.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/main/managers/toolRegistryManager.ts | 54 ++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/main/managers/toolRegistryManager.ts b/src/main/managers/toolRegistryManager.ts index 4de4f092..f00b67d1 100644 --- a/src/main/managers/toolRegistryManager.ts +++ b/src/main/managers/toolRegistryManager.ts @@ -123,6 +123,18 @@ export class ToolRegistryManager extends EventEmitter { private installIdManager: InstallIdManager | null = null; private azureBlobBaseUrl: string; + // Registry fetch de-duping + caching + private registryFetchInFlight: Promise | null = null; + private registryCache: { + tools: ToolRegistryEntry[]; + fetchedAtMs: number; + source: "supabase" | "azureBlob" | "local"; + } | null = null; + + // Multiple renderer modules request the registry during startup (homepage stats, marketplace, etc.). + // Keep this short so the marketplace stays fresh, but long enough to prevent thrash. + private static readonly REGISTRY_CACHE_TTL_MS = 30_000; + constructor(toolsDirectory: string, supabaseUrl?: string, supabaseKey?: string, installIdManager?: InstallIdManager, azureBlobBaseUrl?: string) { super(); this.toolsDirectory = toolsDirectory; @@ -161,11 +173,47 @@ export class ToolRegistryManager extends EventEmitter { * Fetch the tool registry from Supabase database or local fallback */ async fetchRegistry(): Promise { - // Use remote/local fallback if Supabase is not configured - if (this.useLocalFallback) { - return this.fetchFallbackRegistry(); + const now = Date.now(); + + // Serve from cache when still fresh + if (this.registryCache && now - this.registryCache.fetchedAtMs < ToolRegistryManager.REGISTRY_CACHE_TTL_MS) { + return this.registryCache.tools; + } + + // If a fetch is already running, await it instead of starting another one. + if (this.registryFetchInFlight) { + return this.registryFetchInFlight; + } + + this.registryFetchInFlight = (async () => { + // Use remote/local fallback if Supabase is not configured + if (this.useLocalFallback) { + const tools = await this.fetchFallbackRegistry(); + this.registryCache = { + tools, + fetchedAtMs: Date.now(), + source: this.azureBlobBaseUrl ? "azureBlob" : "local", + }; + return tools; + } + + const tools = await this.fetchRegistryFromSupabase(); + this.registryCache = { + tools, + fetchedAtMs: Date.now(), + source: "supabase", + }; + return tools; + })(); + + try { + return await this.registryFetchInFlight; + } finally { + this.registryFetchInFlight = null; } + } + private async fetchRegistryFromSupabase(): Promise { try { logInfo(`[ToolRegistry] Fetching registry from Supabase (new schema)`); From 64db72919dff806b593916887815f161e6b80776 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:59:44 -0500 Subject: [PATCH 030/178] Add tool version compatibility checking with proper cache management (#378) * Initial plan * Add version compatibility types and backend logic Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add UI components for tool version compatibility Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add GitHub workflow steps for version sync and @pptb/types publishing Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add comprehensive documentation for tool version compatibility feature Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add implementation checklist for version compatibility feature Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix code review issues: improve version comparison and validation logic Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix documentation to match corrected implementation logic Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix compatibility logic to support forward compatibility as requested - Remove maxAPI restriction - tools built with older APIs work on newer ToolBox - Add MIN_SUPPORTED_API_VERSION check to prevent tools using deprecated APIs - Update documentation with correct examples matching user's requirements - Tool with minAPI="1.0.0", maxAPI="1.0.4" now works on ToolBox v1.0.5 Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * docs: enhance TOOL_VERSION_COMPATIBILITY.md with clearer formatting and examples for version checks * Refactor version logic into VersionManager and correct data flow - Create new VersionManager class to handle all version comparison and compatibility checking - Move compareVersions and isToolSupported functions from toolsManager to VersionManager - Update toolRegistryManager to only read version info from Supabase (not from package.json/npm-shrinkwrap) - Version data (min_api, max_api) is now pre-processed during tool intake and stored in database - Update documentation to reflect corrected data flow - toolsManager now uses VersionManager.isToolSupported() for compatibility checks Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Use app.getVersion() instead of TOOLBOX_VERSION constant and create reusable npm publish workflow - Replace TOOLBOX_VERSION constant with app.getVersion() call in VersionManager - Remove TOOLBOX_VERSION from constants.ts and vite.config.ts - Create standalone publish-npm-types.yml workflow with trusted publishing support - Update prod-release.yml to use reusable workflow for npm publishing - Update nightly-release.yml to use reusable workflow for npm beta publishing - Add id-token: write permission for npm trusted publishing - Add --provenance flag to pnpm publish for supply chain transparency Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix marketplace not showing unsupported tools - add min_api and max_api to Supabase query - Add min_api and max_api columns to Supabase SELECT query in toolRegistryManager - Compute isSupported field in fetchAvailableTools() using VersionManager - Include minAPI, maxAPI, and isSupported fields when mapping to ToolDetail in marketplace - Fix bug where tools with minAPI higher than current ToolBox version were showing as valid Scenario fixed: Tool with minAPI=1.2.2 on ToolBox v1.2.0 now correctly shows as "Not Supported" Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Disable install buttons for unsupported tools in marketplace and modal - Add disabled attribute to install button in standard marketplace view (was only in compact) - Pass isSupported field to tool detail modal view and controller - Disable install button in modal for unsupported tools with helpful tooltip - Add compatibility double-check in modal install handler - Prevent installation attempts for incompatible tools across all UI entry points Fixes: Tool detail modal now prevents installation of unsupported tools Fixes: Standard marketplace view install button now disabled for unsupported tools Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix installed tools not showing compatibility status or preventing launch - Add minAPI and maxAPI fields to createToolFromInstalledManifest - Compute isSupported field using VersionManager.isToolSupported() - Installed tools now correctly display "Not Supported" badge in sidebar - Launch prevention now works for installed tools that become incompatible Fixes scenario: Tool with minAPI=1.0.20, maxAPI=1.0.20 on ToolBox v1.2.0 (MIN_SUPPORTED_API=1.2.0) now shows as "Not Supported" in installed tools section and cannot be launched Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix cached tools not recomputing compatibility after ToolBox version changes - Always recompute isSupported field in getTool() when returning cached tool - Always recompute isSupported field in getAllTools() for cached tools - Ensures tools that become incompatible after ToolBox update are properly detected - Launch prevention now works correctly even for tools loaded before version update Root cause: Cached Tool objects retained old isSupported value computed at load time Fix: Recompute isSupported on every retrieval using current ToolBox version Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add comprehensive logging to VersionManager for debugging compatibility issues - Add console.log statements at each decision point in isToolSupported() - Log minAPI, maxAPI, toolboxVersion, MIN_SUPPORTED_API_VERSION - Log comparison results for version checks - Log final compatibility decision (COMPATIBLE/INCOMPATIBLE) This will help identify why tools with minAPI=1.0.20 are still launching when MIN_SUPPORTED_API_VERSION=1.2.0 and toolbox version=1.2.0 Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add stack trace logging to identify where legacy tool check is called from - Add stack trace to all isToolSupported() calls - Move logging before legacy check to capture ALL calls - This will help identify which code path is calling isToolSupported without version parameters Debug info will show exactly where in the code the second (legacy) call originates from Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix launch prevention by migrating version fields to installed tool manifests ROOT CAUSE IDENTIFIED: Installed tool manifest.json files don't have minAPI/maxAPI fields. When tools load for launch, they read from manifest without version info, causing isToolSupported() to return COMPATIBLE as "legacy tool". SOLUTION: Add manifest migration in loadTool(): - Check if installed manifest is missing version fields - Fetch version info from Supabase registry - Update local manifest.json with minAPI/maxAPI - Tool will now correctly show as INCOMPATIBLE and prevent launch NEW METHODS: - toolRegistryManager.getToolFromRegistry() - fetch tool from Supabase - toolRegistryManager.updateInstalledManifest() - update local manifest CLEANUP: - Removed all debug logging from VersionManager.isToolSupported() This fix ensures all installed tools (even those installed before version checking was implemented) will have their compatibility correctly determined. Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Fix launch prevention by clearing tool cache on uninstall ROOT CAUSE: Tools were remaining in memory cache after uninstall. When reinstalled with updated manifest (including minAPI/maxAPI), the old cached tool object (without version fields) was reused, causing isToolSupported() to be called with undefined values and return COMPATIBLE. FIX: Clear tool from cache when uninstalled. This ensures that on reinstall, the tool is reloaded from the new manifest with correct version information. REVERTED: Previous manifest migration commit (9713490) - was unnecessary and incorrect approach. CLEANUP: Removed all debug logging from VersionManager.isToolSupported() This fix ensures tools properly show "Not Supported" badge and prevent launch when incompatible, even after uninstall/reinstall cycles. Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Added proper fix after copilot wasnt able to fix it :) * Update src/renderer/modals/toolDetail/controller.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: clarify minAPI and maxAPI comments in Tool interface --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Power-Maverick Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-release.yml | 10 + .github/workflows/prod-release.yml | 31 + .github/workflows/publish-npm-types.yml | 52 ++ docs/IMPLEMENTATION_CHECKLIST.md | 429 +++++++++++++ docs/SUPABASE_SCHEMA_UPDATES.md | 467 ++++++++++++++ docs/TOOL_VERSION_COMPATIBILITY.md | 577 ++++++++++++++++++ src/common/ipc/channels.ts | 1 + src/common/types/api.ts | 1 + src/common/types/tool.ts | 13 + src/common/utils/version.ts | 27 + src/main/constants.ts | 8 + src/main/index.ts | 9 + src/main/managers/toolRegistryManager.ts | 24 + src/main/managers/toolsManager.ts | 34 +- src/main/managers/versionManager.ts | 71 +++ src/main/preload.ts | 1 + src/renderer/modals/toolDetail/controller.ts | 9 + src/renderer/modals/toolDetail/view.ts | 3 +- src/renderer/modules/marketplaceManagement.ts | 20 +- src/renderer/modules/toolManagement.ts | 20 + .../modules/toolsSidebarManagement.ts | 11 +- src/renderer/styles.scss | 58 ++ src/renderer/types/index.ts | 3 + src/renderer/utils/toolCompatibility.ts | 81 +++ 24 files changed, 1948 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/publish-npm-types.yml create mode 100644 docs/IMPLEMENTATION_CHECKLIST.md create mode 100644 docs/SUPABASE_SCHEMA_UPDATES.md create mode 100644 docs/TOOL_VERSION_COMPATIBILITY.md create mode 100644 src/common/utils/version.ts create mode 100644 src/main/managers/versionManager.ts create mode 100644 src/renderer/utils/toolCompatibility.ts diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 95721351..550fd5a9 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -885,3 +885,13 @@ jobs: make_latest: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-types-beta: + needs: publish-release + if: needs.check-commits.outputs.should_build == 'true' + uses: ./.github/workflows/publish-npm-types.yml + with: + branch: dev + tag: beta + secrets: inherit + diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 8bf7b2a6..8e7d8aa6 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -39,6 +39,28 @@ jobs: echo "Release notes validation passed for Power Platform ToolBox $CURRENT_VERSION." + - name: Validate @pptb/types version matches ToolBox version + shell: bash + run: | + TOOLBOX_VERSION=$(node -p "require('./package.json').version") + TYPES_VERSION=$(node -p "require('./packages/package.json').version") + + # Extract major.minor.patch from both versions (ignore pre-release tags) + TOOLBOX_BASE=$(echo "$TOOLBOX_VERSION" | cut -d'-' -f1) + TYPES_BASE=$(echo "$TYPES_VERSION" | cut -d'-' -f1) + + if [ "$TOOLBOX_BASE" != "$TYPES_BASE" ]; then + echo "❌ Error: @pptb/types version ($TYPES_VERSION) does not match ToolBox version ($TOOLBOX_VERSION)" + echo "The base version (major.minor.patch) must be identical for stable releases." + echo "" + echo "To fix this:" + echo "1. Update packages/package.json version to match $TOOLBOX_VERSION" + echo "2. Commit the change and push" + exit 1 + fi + + echo "✅ Version validation passed: ToolBox $TOOLBOX_VERSION matches @pptb/types $TYPES_VERSION" + build: needs: preflight if: > @@ -805,3 +827,12 @@ jobs: fail_on_unmatched_files: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-types: + needs: publish-release + uses: ./.github/workflows/publish-npm-types.yml + with: + branch: main + tag: latest + secrets: inherit + diff --git a/.github/workflows/publish-npm-types.yml b/.github/workflows/publish-npm-types.yml new file mode 100644 index 00000000..8fa23296 --- /dev/null +++ b/.github/workflows/publish-npm-types.yml @@ -0,0 +1,52 @@ +name: Publish @pptb/types to npm + +on: + workflow_call: + inputs: + branch: + description: "Branch to checkout" + required: true + type: string + tag: + description: "npm tag (latest or beta)" + required: true + type: string + +permissions: + contents: read + id-token: write # Required for npm trusted publishing + +jobs: + publish-types: + runs-on: ubuntu-latest + + steps: + - name: Checkout branch + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + registry-url: "https://registry.npmjs.org" + + - name: Install pnpm + run: npm install -g pnpm@10.18.3 + + - name: Get version + id: version + run: | + VERSION=$(node -p "require('./packages/package.json').version") + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "📦 Publishing @pptb/types version: $VERSION with tag: ${{ inputs.tag }}" + + - name: Publish @pptb/types to npm + working-directory: ./packages + run: | + echo "Publishing @pptb/types@${{ steps.version.outputs.version }} with tag ${{ inputs.tag }} to npm..." + pnpm publish --access public --tag ${{ inputs.tag }} --no-git-checks --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/docs/IMPLEMENTATION_CHECKLIST.md b/docs/IMPLEMENTATION_CHECKLIST.md new file mode 100644 index 00000000..0229d3a6 --- /dev/null +++ b/docs/IMPLEMENTATION_CHECKLIST.md @@ -0,0 +1,429 @@ +# Implementation Checklist: Tool Version Compatibility Feature + +This document provides a step-by-step checklist for implementing the tool version compatibility feature across all systems and processes. + +## Overview + +This feature allows tools to declare version compatibility requirements, preventing users from installing or using tools that are incompatible with their ToolBox version. + +--- + +## ✅ Phase 1: Application Code (COMPLETED) + +### Backend Changes + +- [x] Add `minAPI` field to `ToolFeatures` interface (`src/common/types/tool.ts`) +- [x] Add `minAPI`, `maxAPI`, and `isSupported` fields to `Tool` interface +- [x] Add `minAPI` and `maxAPI` fields to `ToolManifest` interface +- [x] Add `minAPI` and `maxAPI` fields to `ToolRegistryEntry` interface +- [x] Add `TOOLBOX_VERSION` and `MIN_SUPPORTED_API_VERSION` constants (`src/main/constants.ts`) +- [x] Create `compareVersions()` utility function in `toolsManager.ts` +- [x] Create `isToolSupported()` compatibility check function +- [x] Update `loadToolFromManifest()` to set version fields and compatibility status +- [x] Update `installTool()` to extract `minAPI` from package.json +- [x] Update `installTool()` to extract `maxAPI` from npm-shrinkwrap.json +- [x] Update Supabase schema mappings to include `min_api` and `max_api` +- [x] Update local registry interface to support version fields + +### UI Changes + +- [x] Add version compatibility check in `launchTool()` function +- [x] Show warning notification when launching unsupported tool +- [x] Add `isUnsupported` check in sidebar tool rendering +- [x] Add "Not Supported" badge HTML for sidebar tools +- [x] Add CSS class `unsupported` to unsupported tool items in sidebar +- [x] Add `isUnsupported` check in marketplace tool rendering +- [x] Add "Not Supported" badge HTML for marketplace tools +- [x] Add CSS class `unsupported` to unsupported tool items in marketplace +- [x] Disable install button for unsupported tools in marketplace +- [x] Add CSS styles for `.tool-unsupported-badge` +- [x] Add CSS styles for `.tool-item-pptb.unsupported` +- [x] Add CSS styles for `.marketplace-item-unsupported-badge` +- [x] Add CSS styles for `.marketplace-item-pptb.unsupported` +- [x] Update `ToolDetail` interface to include version fields + +### Build Configuration + +- [x] Update `vite.config.ts` to inject `TOOLBOX_VERSION` at build time +- [x] Verify TypeScript compilation succeeds +- [x] Verify linting passes + +--- + +## ✅ Phase 2: GitHub Workflows (COMPLETED) + +### Stable Release Workflow + +- [x] Add version validation step in `prod-release.yml` preflight job +- [x] Check that @pptb/types version matches ToolBox version +- [x] Add `publish-types` job after `publish-release` +- [x] Setup Node.js with npm registry authentication +- [x] Publish @pptb/types to npm with `latest` tag +- [x] Use `NPM_TOKEN` secret for authentication + +### Nightly Release Workflow + +- [x] Add `publish-types-beta` job after `publish-release` +- [x] Setup Node.js with npm registry authentication +- [x] Publish @pptb/types to npm with `beta` tag +- [x] Use `NPM_TOKEN` secret for authentication + +--- + +## ✅ Phase 3: Documentation (COMPLETED) + +- [x] Create `TOOL_VERSION_COMPATIBILITY.md` with: + - [x] Overview and version compatibility rules + - [x] Guide for tool developers + - [x] Guide for ToolBox maintainers + - [x] Guide for registry administrators + - [x] Technical implementation details + - [x] User experience documentation + - [x] Troubleshooting guide + +- [x] Create `SUPABASE_SCHEMA_UPDATES.md` with: + - [x] Database schema changes + - [x] Migration scripts + - [x] Validation rules + - [x] API changes + - [x] Testing procedures + - [x] Monitoring queries + +- [x] Create this implementation checklist + +--- + +## ⏳ Phase 4: Database Updates (PENDING - EXTERNAL) + +### Supabase Schema Migration + +- [x] Connect to Supabase SQL Editor +- [x] Run schema update script: + ```sql + ALTER TABLE tools + ADD COLUMN IF NOT EXISTS min_api TEXT, + ADD COLUMN IF NOT EXISTS max_api TEXT; + ``` +- [ ] Add column comments: + ```sql + COMMENT ON COLUMN tools.min_api IS 'Minimum ToolBox API version required'; + COMMENT ON COLUMN tools.max_api IS 'Maximum ToolBox API version tested'; + ``` +- [x] Create performance indexes: + ```sql + CREATE INDEX IF NOT EXISTS idx_tools_min_api ON tools(min_api) + WHERE min_api IS NOT NULL; + CREATE INDEX IF NOT EXISTS idx_tools_max_api ON tools(max_api) + WHERE max_api IS NOT NULL; + CREATE INDEX IF NOT EXISTS idx_tools_versions ON tools(min_api, max_api) + WHERE min_api IS NOT NULL AND max_api IS NOT NULL; + ``` +- [x] Verify indexes were created: + ```sql + SELECT indexname, indexdef + FROM pg_indexes + WHERE tablename = 'tools' AND indexname LIKE '%api%'; + ``` +- [x] Test with sample data insertion +- [ ] Document rollback procedure + +### Data Migration Strategy + +- [ ] Decide on strategy for existing tools: + - Option A: Leave as NULL (backward compatible) + - Option B: Set to default version (e.g., "1.0.0") + - Option C: Backfill from tool packages +- [ ] If backfilling, develop extraction script +- [ ] Test backfill script on subset of tools +- [ ] Execute backfill for all tools +- [ ] Verify data quality + +### Monitoring Setup + +- [ ] Create dashboard for version statistics +- [ ] Set up alerts for tools without version info +- [ ] Monitor query performance after migration + +--- + +## ⏳ Phase 5: GitHub Repository Setup (PENDING - EXTERNAL) + +### Repository Secrets + +- [ ] Generate npm access token: + 1. Log into npm account + 2. Navigate to Access Tokens + 3. Generate new "Automation" token + 4. Copy token value +- [ ] Add `NPM_TOKEN` secret to GitHub repository: + 1. Go to repository Settings → Secrets and variables → Actions + 2. Click "New repository secret" + 3. Name: `NPM_TOKEN` + 4. Value: [paste token] + 5. Click "Add secret" +- [ ] Verify token has publish permissions for `@pptb` scope +- [ ] Test token with manual publish (optional) + +### Verify Existing Secrets + +- [ ] Confirm `SUPABASE_URL` is set +- [ ] Confirm `SUPABASE_ANON_KEY` is set +- [ ] Confirm `SENTRY_DSN` is set (optional) +- [ ] Confirm `SENTRY_AUTH_TOKEN` is set (optional) + +--- + +## ⏳ Phase 6: Tool Registry/Intake System (PENDING - EXTERNAL) + +### Update Intake Process + +- [ ] Modify tool submission form to mention version requirements +- [ ] Update submission validation to check for: + - [ ] `features.minAPI` in package.json + - [ ] Valid semver format for minAPI + - [ ] Presence of npm-shrinkwrap.json + - [ ] `@pptb/types` in shrinkwrap dependencies +- [ ] Add extraction logic: + - [ ] Read `package.json` → extract `features.minAPI` + - [ ] Read `npm-shrinkwrap.json` → extract `@pptb/types` version + - [ ] Remove semver prefixes (^, ~) from maxAPI +- [ ] Add validation logic: + - [ ] Validate semver format + - [ ] Check minAPI <= maxAPI if both present + - [ ] Check minAPI >= MIN_SUPPORTED_API_VERSION +- [ ] Update database insert/update to include version fields +- [ ] Test with sample tool submission + +### Update Rejection Criteria + +Add to tool submission guidelines: + +- [ ] Tools must include `features.minAPI` in package.json +- [ ] Tools must include npm-shrinkwrap.json +- [ ] Tools must have `@pptb/types` in devDependencies +- [ ] Version format must be valid semver + +### Update Local Registry + +- [ ] Update `src/main/data/registry.json` with version fields +- [ ] Add minAPI and maxAPI to existing tools +- [ ] Commit updated registry + +--- + +## ⏳ Phase 7: Communication & Rollout (PENDING - EXTERNAL) + +### Tool Developer Communication + +- [ ] Draft announcement email/post +- [ ] Include: + - [ ] Feature overview + - [ ] Why it matters + - [ ] How to update existing tools + - [ ] Link to documentation + - [ ] Migration deadline (if any) +- [ ] Post announcement in: + - [ ] GitHub Discussions + - [ ] Discord/Slack community + - [ ] Developer newsletter + - [ ] Blog post +- [ ] Send direct emails to active tool developers + +### User Communication + +- [ ] Update main documentation/wiki +- [ ] Add section to user guide explaining: + - [ ] What "Not Supported" badge means + - [ ] How to update ToolBox + - [ ] What to do if tool shows as unsupported +- [ ] Create FAQ entries +- [ ] Prepare support team with common questions + +### Release Notes + +- [ ] Add to CHANGELOG.md: + + ```markdown + ## [Version X.Y.Z] - YYYY-MM-DD + + ### Added + + - Tool version compatibility checking + - Visual indicators for unsupported tools + - Automatic @pptb/types publishing in release workflow + + ### Changed + + - Tools now require minimum version specification + - Install button disabled for incompatible tools + ``` + +--- + +## ⏳ Phase 8: Testing & Validation (PENDING) + +### Manual Testing + +- [ ] **Test 1: Tool Installation** + 1. Install a test tool with version info + 2. Verify minAPI and maxAPI are captured in manifest.json + 3. Check tool displays correctly in sidebar + +- [ ] **Test 2: Compatibility Check** + 1. Temporarily modify MIN_SUPPORTED_API_VERSION + 2. Verify tool shows "Not Supported" badge + 3. Attempt to launch tool + 4. Verify warning notification appears + 5. Restore original constant + +- [ ] **Test 3: UI Display** + 1. View tool in sidebar (both compact and standard modes) + 2. View tool in marketplace + 3. Verify badge appears correctly + 4. Verify install button is disabled + 5. Check visual styling (opacity, border) + +- [ ] **Test 4: Legacy Tools** + 1. Install a tool without version info + 2. Verify it's treated as compatible (no badge) + 3. Verify it can be launched normally + +- [ ] **Test 5: Marketplace Filtering** + 1. Browse marketplace with various ToolBox versions + 2. Verify unsupported tools are clearly marked + 3. Verify install button behavior + +### Automated Testing + +- [ ] Write unit tests for `compareVersions()` function +- [ ] Write unit tests for `isToolSupported()` function +- [ ] Test version extraction from package.json +- [ ] Test version extraction from npm-shrinkwrap.json +- [ ] Test database schema with sample data + +### Cross-Platform Testing + +- [ ] Test on Windows 10/11 +- [ ] Test on macOS (Intel) +- [ ] Test on macOS (Apple Silicon) +- [ ] Test on Linux (Ubuntu/Debian) +- [ ] Verify consistent behavior across platforms + +### Workflow Testing + +- [ ] Create test PR to trigger workflows +- [ ] Verify version validation step works +- [ ] Verify @pptb/types publishing works (can use beta channel) +- [ ] Test with intentional version mismatch +- [ ] Verify workflow fails appropriately + +--- + +## ⏳ Phase 9: Monitoring & Iteration (ONGOING) + +### Week 1 After Release + +- [ ] Monitor error logs for version-related issues +- [ ] Track support tickets related to version compatibility +- [ ] Gather user feedback +- [ ] Monitor tool submission issues + +### Week 2-4 After Release + +- [ ] Analyze adoption rate by tool developers +- [ ] Identify tools still missing version info +- [ ] Reach out to developers of popular tools +- [ ] Refine documentation based on feedback + +### Ongoing + +- [ ] Monthly review of version distribution +- [ ] Quarterly review of MIN_SUPPORTED_API_VERSION +- [ ] Track feature requests and improvements +- [ ] Document lessons learned + +--- + +## 🚨 Rollback Plan + +If critical issues are discovered: + +### Application Rollback + +1. Revert PR commits +2. Redeploy previous version +3. Notify users + +### Database Rollback + +1. Backup current data: + ```sql + CREATE TABLE tools_version_backup AS + SELECT id, min_api, max_api FROM tools; + ``` +2. Drop indexes and constraints +3. Remove columns +4. Restore from backup if needed + +### Communication + +- [ ] Post rollback announcement +- [ ] Explain issues encountered +- [ ] Provide timeline for re-implementation +- [ ] Thank community for patience + +--- + +## ✅ Success Criteria + +The feature is considered successfully implemented when: + +- [x] All Phase 1 (Application Code) tasks complete +- [x] All Phase 2 (GitHub Workflows) tasks complete +- [x] All Phase 3 (Documentation) tasks complete +- [ ] All Phase 4 (Database) tasks complete +- [ ] All Phase 5 (GitHub Setup) tasks complete +- [ ] All Phase 6 (Intake System) tasks complete +- [ ] All Phase 7 (Communication) tasks complete +- [ ] All Phase 8 (Testing) tasks complete +- [ ] No critical bugs in production for 2 weeks +- [ ] Positive community feedback +- [ ] At least 50% of active tools updated with version info + +--- + +## Resources + +- **Documentation**: + - `docs/TOOL_VERSION_COMPATIBILITY.md` + - `docs/SUPABASE_SCHEMA_UPDATES.md` +- **Code Changes**: + - `src/common/types/tool.ts` + - `src/main/constants.ts` + - `src/main/managers/toolsManager.ts` + - `src/main/managers/toolRegistryManager.ts` + - `src/renderer/modules/toolManagement.ts` + - `src/renderer/modules/toolsSidebarManagement.ts` + - `src/renderer/modules/marketplaceManagement.ts` + - `src/renderer/styles.scss` + +- **Workflows**: + - `.github/workflows/prod-release.yml` + - `.github/workflows/nightly-release.yml` + +- **External Resources**: + - [Semantic Versioning](https://semver.org/) + - [npm Shrinkwrap Docs](https://docs.npmjs.com/cli/v8/commands/npm-shrinkwrap) + - [Supabase Documentation](https://supabase.com/docs) + +--- + +## Notes + +- This checklist should be reviewed and updated as implementation progresses +- Mark items as complete with timestamps and assignee names +- Document any deviations from the plan +- Keep stakeholders informed of progress + +**Last Updated**: 2026-02-11 +**Status**: Phases 1-3 Complete, Phases 4-9 Pending External Action diff --git a/docs/SUPABASE_SCHEMA_UPDATES.md b/docs/SUPABASE_SCHEMA_UPDATES.md new file mode 100644 index 00000000..e20261af --- /dev/null +++ b/docs/SUPABASE_SCHEMA_UPDATES.md @@ -0,0 +1,467 @@ +# Supabase Database Schema Updates for Tool Version Compatibility + +This document outlines the database schema changes required to support tool version compatibility in the Power Platform ToolBox marketplace. + +## Overview + +The tool version compatibility feature requires storing minimum and maximum API version information for each tool in the registry. This allows the application to determine which tools are compatible with a given ToolBox version. + +--- + +## Schema Changes + +### 1. Add Version Columns to `tools` Table + +Execute the following SQL in your Supabase SQL Editor: + +```sql +-- Add min_api and max_api columns to the tools table +ALTER TABLE tools + ADD COLUMN IF NOT EXISTS min_api TEXT, + ADD COLUMN IF NOT EXISTS max_api TEXT; + +-- Add comments to explain the columns +COMMENT ON COLUMN tools.min_api IS 'Minimum ToolBox API version required by this tool (from package.json features.minAPI)'; +COMMENT ON COLUMN tools.max_api IS 'Maximum ToolBox API version tested with this tool (from npm-shrinkwrap @pptb/types version)'; +``` + +### 2. Create Indexes for Performance + +Add indexes to improve query performance when filtering by version: + +```sql +-- Create indexes on version columns for faster lookups +CREATE INDEX IF NOT EXISTS idx_tools_min_api ON tools(min_api) + WHERE min_api IS NOT NULL; + +CREATE INDEX IF NOT EXISTS idx_tools_max_api ON tools(max_api) + WHERE max_api IS NOT NULL; + +-- Composite index for version range queries +CREATE INDEX IF NOT EXISTS idx_tools_versions ON tools(min_api, max_api) + WHERE min_api IS NOT NULL AND max_api IS NOT NULL; +``` + +### 3. Update Row Level Security (RLS) Policies + +If you have RLS enabled, ensure the new columns are included: + +```sql +-- No changes needed to RLS policies - the columns follow the same access pattern +-- Just verify that SELECT policies allow reading these columns + +-- Example verification query: +SELECT + schemaname, + tablename, + policyname, + permissive, + roles, + cmd, + qual, + with_check +FROM pg_policies +WHERE tablename = 'tools'; +``` + +--- + +## Data Migration + +### Option A: Set Defaults for Existing Tools + +For tools that already exist without version information: + +```sql +-- Option 1: Set to NULL (allows all versions - backward compatible) +-- No action needed - columns default to NULL + +-- Option 2: Set to earliest supported version +UPDATE tools +SET + min_api = '1.0.0', + max_api = '1.1.3' -- Current latest version +WHERE min_api IS NULL; +``` + +**Recommendation:** Leave as NULL for existing tools to maintain backward compatibility. Tools without version info are assumed compatible with all versions. + +### Option B: Backfill from Tool Packages + +If you have access to the tool packages, you can extract the version information: + +```javascript +// Example Node.js script to backfill version data +const { createClient } = require('@supabase/supabase-js'); +const fs = require('fs'); +const path = require('path'); + +const supabase = createClient( + process.env.SUPABASE_URL, + process.env.SUPABASE_SERVICE_ROLE_KEY +); + +async function backfillVersions() { + // Get all tools without version info + const { data: tools, error } = await supabase + .from('tools') + .select('id, packagename') + .is('min_api', null); + + for (const tool of tools) { + try { + // Download and extract tool package + const packageJsonPath = `./temp/${tool.id}/package.json`; + const shrinkwrapPath = `./temp/${tool.id}/npm-shrinkwrap.json`; + + if (fs.existsSync(packageJsonPath)) { + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + const minAPI = packageJson.features?.minAPI; + + let maxAPI = null; + if (fs.existsSync(shrinkwrapPath)) { + const shrinkwrap = JSON.parse(fs.readFileSync(shrinkwrapPath, 'utf-8')); + const typesVersion = shrinkwrap.dependencies?.['@pptb/types']?.version; + maxAPI = typesVersion?.replace(/^\^|~/, ''); + } + + // Update database + await supabase + .from('tools') + .update({ min_api: minAPI, max_api: maxAPI }) + .eq('id', tool.id); + + console.log(`Updated ${tool.id}: minAPI=${minAPI}, maxAPI=${maxAPI}`); + } + } catch (error) { + console.error(`Failed to process ${tool.id}:`, error); + } + } +} + +backfillVersions(); +``` + +--- + +## Validation Rules + +### Database-Level Constraints + +Add check constraints to ensure data quality: + +```sql +-- Ensure versions follow semver format (basic check) +ALTER TABLE tools + ADD CONSTRAINT check_min_api_format + CHECK (min_api IS NULL OR min_api ~ '^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$'); + +ALTER TABLE tools + ADD CONSTRAINT check_max_api_format + CHECK (max_api IS NULL OR max_api ~ '^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$'); + +-- Note: These are basic checks. Full semver validation should happen in application code. +``` + +### Application-Level Validation + +In your tool intake/update API: + +```typescript +interface ToolSubmission { + id: string; + name: string; + version: string; + minAPI?: string; + maxAPI?: string; + // ... other fields +} + +function validateToolVersions(tool: ToolSubmission): string[] { + const errors: string[] = []; + + // Validate minAPI format + if (tool.minAPI && !isValidSemver(tool.minAPI)) { + errors.push('Invalid minAPI format. Must be valid semver (e.g., 1.0.0)'); + } + + // Validate maxAPI format + if (tool.maxAPI && !isValidSemver(tool.maxAPI)) { + errors.push('Invalid maxAPI format. Must be valid semver (e.g., 1.0.0)'); + } + + // Ensure minAPI <= maxAPI if both are provided + if (tool.minAPI && tool.maxAPI) { + if (compareVersions(tool.minAPI, tool.maxAPI) > 0) { + errors.push('minAPI cannot be greater than maxAPI'); + } + } + + return errors; +} +``` + +--- + +## API Changes + +### 1. Update Tool Query + +Update your existing tool query to include the new fields: + +```sql +SELECT + t.id, + t.name, + t.version, + t.description, + t.downloadurl, + t.iconurl, + t.min_api, -- NEW + t.max_api, -- NEW + -- ... other fields +FROM tools t +WHERE t.status = 'active'; +``` + +### 2. Update Tool Insert/Update + +When creating or updating tools: + +```sql +INSERT INTO tools ( + id, + name, + version, + min_api, -- NEW + max_api, -- NEW + -- ... other fields +) VALUES ( + $1, $2, $3, $4, $5, ... +) +ON CONFLICT (id) DO UPDATE SET + name = EXCLUDED.name, + version = EXCLUDED.version, + min_api = EXCLUDED.min_api, -- NEW + max_api = EXCLUDED.max_api, -- NEW + updated_at = NOW(); +``` + +### 3. Add Compatibility Filter Endpoint + +Create a new API endpoint or update existing ones to filter by compatibility: + +```typescript +// Example Supabase Edge Function +export async function getCompatibleTools(toolboxVersion: string) { + const { data, error } = await supabase + .from('tools') + .select('*') + .or(`min_api.is.null,min_api.lte.${toolboxVersion}`) + .or(`max_api.is.null,max_api.gte.${toolboxVersion}`) + .eq('status', 'active'); + + return data; +} +``` + +**Note:** Version comparison in SQL is complex. It's recommended to do filtering in the application layer for semantic versioning. + +--- + +## Testing + +### 1. Verify Schema Changes + +```sql +-- Check columns exist +SELECT + column_name, + data_type, + is_nullable +FROM information_schema.columns +WHERE table_name = 'tools' + AND column_name IN ('min_api', 'max_api'); + +-- Expected output: +-- column_name | data_type | is_nullable +-- min_api | text | YES +-- max_api | text | YES +``` + +### 2. Verify Indexes + +```sql +-- Check indexes exist +SELECT + indexname, + indexdef +FROM pg_indexes +WHERE tablename = 'tools' + AND indexname LIKE '%api%'; + +-- Expected output should include: +-- idx_tools_min_api +-- idx_tools_max_api +-- idx_tools_versions +``` + +### 3. Test Data + +Insert test data to verify the schema: + +```sql +-- Insert test tool with version info +INSERT INTO tools ( + id, + name, + version, + description, + downloadurl, + iconurl, + min_api, + max_api, + status +) VALUES ( + 'test-tool-001', + 'Test Tool', + '1.0.0', + 'A test tool for version compatibility', + 'https://example.com/test-tool.tgz', + 'https://example.com/icon.svg', + '1.0.0', + '1.1.3', + 'active' +); + +-- Verify insertion +SELECT id, name, min_api, max_api FROM tools WHERE id = 'test-tool-001'; + +-- Clean up +DELETE FROM tools WHERE id = 'test-tool-001'; +``` + +--- + +## Monitoring and Analytics + +### Useful Queries + +**1. Tools with version information:** + +```sql +SELECT + COUNT(*) FILTER (WHERE min_api IS NOT NULL) as with_min_api, + COUNT(*) FILTER (WHERE max_api IS NOT NULL) as with_max_api, + COUNT(*) FILTER (WHERE min_api IS NOT NULL AND max_api IS NOT NULL) as with_both, + COUNT(*) as total +FROM tools +WHERE status = 'active'; +``` + +**2. Version distribution:** + +```sql +SELECT + min_api, + COUNT(*) as tool_count +FROM tools +WHERE status = 'active' AND min_api IS NOT NULL +GROUP BY min_api +ORDER BY min_api DESC; +``` + +**3. Tools potentially incompatible with a version:** + +```sql +-- Note: This is a simple string comparison, not proper semver +-- Use this for monitoring only, not for actual compatibility checks +SELECT + id, + name, + version, + min_api, + max_api +FROM tools +WHERE status = 'active' + AND (min_api > '1.0.0' OR max_api < '1.1.3'); +``` + +--- + +## Rollback Plan + +If you need to rollback the changes: + +```sql +-- 1. Drop indexes +DROP INDEX IF EXISTS idx_tools_versions; +DROP INDEX IF EXISTS idx_tools_max_api; +DROP INDEX IF EXISTS idx_tools_min_api; + +-- 2. Drop constraints (if added) +ALTER TABLE tools DROP CONSTRAINT IF EXISTS check_min_api_format; +ALTER TABLE tools DROP CONSTRAINT IF EXISTS check_max_api_format; + +-- 3. Remove columns +ALTER TABLE tools DROP COLUMN IF EXISTS min_api; +ALTER TABLE tools DROP COLUMN IF EXISTS max_api; +``` + +**Warning:** This will permanently delete version data. Create a backup first: + +```sql +-- Backup version data before rollback +CREATE TABLE tools_version_backup AS +SELECT id, min_api, max_api FROM tools; +``` + +--- + +## Support and Troubleshooting + +### Common Issues + +**Issue 1: Column not found** +``` +Error: column "min_api" does not exist +``` +**Solution:** Run the ALTER TABLE command to add the columns. + +**Issue 2: Invalid semver format** +``` +Error: new row violates check constraint "check_min_api_format" +``` +**Solution:** Ensure version strings follow semantic versioning format (X.Y.Z). + +**Issue 3: Performance degradation** +``` +Query taking too long to filter by version +``` +**Solution:** +- Verify indexes are created +- Analyze query plan: `EXPLAIN ANALYZE SELECT ... WHERE min_api ...` +- Consider application-level filtering instead of database + +--- + +## Next Steps + +After completing the database changes: + +1. ✅ Verify schema changes are applied +2. ✅ Test with sample data +3. ✅ Update API endpoints to return new fields +4. ✅ Update tool submission process to capture version data +5. ✅ Monitor tools without version info +6. ✅ Reach out to tool developers for updates +7. ✅ Document version requirements in tool submission guidelines + +--- + +## References + +- [Supabase SQL Editor](https://supabase.com/docs/guides/database/sql-editor) +- [PostgreSQL ALTER TABLE](https://www.postgresql.org/docs/current/sql-altertable.html) +- [PostgreSQL Indexes](https://www.postgresql.org/docs/current/indexes.html) +- [Semantic Versioning Specification](https://semver.org/) diff --git a/docs/TOOL_VERSION_COMPATIBILITY.md b/docs/TOOL_VERSION_COMPATIBILITY.md new file mode 100644 index 00000000..8e5e82ae --- /dev/null +++ b/docs/TOOL_VERSION_COMPATIBILITY.md @@ -0,0 +1,577 @@ +# Tool Version Compatibility System + +This document explains the tool version compatibility feature in Power Platform ToolBox, which ensures that tools are only usable with compatible ToolBox versions. + +## Table of Contents + +1. [Overview](#overview) +2. [Version Compatibility Rules](#version-compatibility-rules) +3. [For Tool Developers](#for-tool-developers) +4. [For ToolBox Maintainers](#for-toolbox-maintainers) +5. [For Tool Registry Administrators](#for-tool-registry-administrators) +6. [Technical Implementation](#technical-implementation) +7. [User Experience](#user-experience) + +--- + +## Overview + +The Tool Version Compatibility System allows tools to specify which versions of Power Platform ToolBox they are compatible with. This prevents users from experiencing issues when: + +- A tool requires newer API features not available in an older ToolBox version +- A tool was built against an older API that may not work with breaking changes in newer versions +- Organizations with restricted update policies cannot use tools requiring newer features + +### Key Concepts + +- **ToolBox Version**: The version of the Power Platform ToolBox application (e.g., `1.1.3`) +- **API Version**: The version of the `@pptb/types` package that defines the tool API surface (matches ToolBox version) +- **Minimum API Version (minAPI)**: The oldest ToolBox version required by the tool +- **Maximum API Version (maxAPI)**: The newest ToolBox version the tool was built and tested against + +--- + +## Version Compatibility Rules + +A tool is considered **compatible** and will be enabled if: + +1. **Minimum API Support Check**: `tool.minAPI >= ToolBox.MIN_SUPPORTED_API_VERSION` + - The tool doesn't require APIs that have been deprecated or removed + - Ensures backward compatibility within supported range + +2. **Minimum Version Check**: `ToolBox.VERSION >= tool.minAPI` + - The current ToolBox must be at least as new as what the tool requires + - Ensures the ToolBox has all APIs the tool needs + +3. **Maximum Version**: The `maxAPI` field is **informational only** + - Tools built with older APIs continue to work on newer ToolBox versions + - Breaking changes are tracked by updating `MIN_SUPPORTED_API_VERSION` on ToolBox side + - This allows forward compatibility by default + +### Examples + +#### Example 1: Tool Works on Newer ToolBox + +**Scenario:** + +- ToolBox installed: `v1.0.5` (MIN_SUPPORTED_API_VERSION = `1.0.2`) +- Tool built against: API `v1.0.4` (from `@pptb/types@1.0.4`) +- Tool declares: `minAPI: "1.0.0"` + +**Result:** ✅ Compatible + +- Tool's minAPI (1.0.0) >= MIN_SUPPORTED_API_VERSION (1.0.2)? → ❌ BUT tool still works because... +- Actually: Tool's minAPI (1.0.0) < MIN_SUPPORTED_API_VERSION (1.0.2) would fail +- Let's correct: minAPI (1.0.3) >= MIN_SUPPORTED_API_VERSION (1.0.2) ✓ +- ToolBox version (1.0.5) >= tool.minAPI (1.0.3) ✓ +- Tool works because ToolBox v1.0.5 is backward compatible with APIs from v1.0.3 + +#### Example 2: Requires Newer ToolBox + +**Scenario:** + +- ToolBox installed: `v1.0.1` (MIN_SUPPORTED_API_VERSION = `1.0.0`) +- Tool built against: API `v1.0.2` +- Tool declares: `minAPI: "1.0.2"` + +**Result:** ❌ Not Compatible + +- Tool's minAPI (1.0.2) >= MIN_SUPPORTED_API_VERSION (1.0.0) ✓ +- ToolBox version (1.0.1) >= tool.minAPI (1.0.2) ✗ +- Tool uses APIs added in v1.0.2 that don't exist in v1.0.1 + +**Action Required:** User must upgrade ToolBox to v1.0.2 or newer + +#### Example 3: Tool Uses Deprecated APIs + +**Scenario:** + +- ToolBox installed: `v1.5.0` (MIN_SUPPORTED_API_VERSION = `1.2.0`) +- Tool built against: API `v1.0.5` +- Tool declares: `minAPI: "1.0.0"` + +**Result:** ❌ Not Compatible + +- Tool's minAPI (1.0.0) >= MIN_SUPPORTED_API_VERSION (1.2.0) ✗ +- Tool uses APIs from v1.0.0 that were removed in breaking change at v1.2.0 + +**Action Required:** Tool developer must update tool to use newer APIs + +#### Example 4: Perfect Compatibility Range + +**Scenario:** + +- ToolBox installed: `v1.0.5` (MIN_SUPPORTED_API_VERSION = `1.0.2`) +- Tool built against: API `v1.0.4` +- Tool declares: `minAPI: "1.0.2"` + +**Result:** ✅ Compatible + +- Tool's minAPI (1.0.2) >= MIN_SUPPORTED_API_VERSION (1.0.2) ✓ +- ToolBox version (1.0.5) >= tool.minAPI (1.0.2) ✓ +- Tool maxAPI (1.0.4) is ignored - tool works on v1.0.5 because no breaking changes + +--- + +## For Tool Developers + +### 1. Specify Minimum API Version + +Add the `minAPI` field to your tool's `package.json`: + +```json +{ + "name": "my-awesome-tool", + "version": "1.0.0", + "features": { + "minAPI": "1.0.12", + "multiConnection": "optional" + } +} +``` + +**How to determine minAPI:** + +- Set it to the version of `@pptb/types` you're developing against +- If you only use stable APIs, you can set it to the oldest version you want to support +- Consider your user base - setting a very recent version may exclude users on older ToolBox + +### 2. Use @pptb/types Package + +Install the appropriate version as a dev dependency: + +```bash +npm install --save-dev @pptb/types@^1.0.12 +``` + +### 3. Create npm-shrinkwrap.json + +After installing dependencies, create a shrinkwrap file: + +```bash +npm shrinkwrap +``` + +This captures the exact `@pptb/types` version used, which becomes the `maxAPI` value. + +### 4. Testing Compatibility + +Before releasing your tool, test it with: + +- The minimum ToolBox version you claim to support (from `minAPI`) +- The latest ToolBox version available +- Any versions in between if there were significant API changes + +### 5. Tool Submission Checklist + +When submitting your tool to the marketplace: + +- [ ] `package.json` includes `features.minAPI` field +- [ ] `npm-shrinkwrap.json` exists and includes `@pptb/types` +- [ ] Tool has been tested with minimum required version +- [ ] Tool has been tested with latest ToolBox version +- [ ] README documents version requirements + +--- + +## For ToolBox Maintainers + +### Version Synchronization + +**Critical Rule:** The ToolBox version and `@pptb/types` version **MUST** be kept in sync. + +When releasing a new ToolBox version: + +1. **Update Package Versions:** + + ```bash + # Update main package.json + npm version patch # or minor/major + + # Update @pptb/types to match + cd packages + npm version patch # Must match main version + cd .. + ``` + +2. **Commit Changes:** + + ```bash + git add package.json packages/package.json + git commit -m "Bump version to X.Y.Z" + ``` + +3. **Release Process (Automated):** + - Push to main branch + - GitHub Actions will: + - Validate versions match + - Build and package ToolBox + - Publish `@pptb/types` to npm + - Create GitHub release + +### Setting Minimum Supported API Version + +In `src/main/constants.ts`: + +```typescript +export const MIN_SUPPORTED_API_VERSION = "1.0.0"; +``` + +**When to Update MIN_SUPPORTED_API_VERSION:** + +Update this value **ONLY** when introducing breaking changes: + +- Removing deprecated APIs +- Changing existing API signatures in incompatible ways +- Renaming APIs +- Changing behavior that breaks existing tools + +**Guidelines:** + +- Set to the version where breaking changes were introduced +- Announce breaking changes well in advance (at least 2 major versions) +- Document what APIs are no longer supported +- Consider user impact - many organizations update slowly +- Tools with minAPI below this version will show as "Not Supported" + +**Example Timeline:** + +1. v1.0.0: Introduce `executeFunction` API +2. v1.1.0: Add new `execute` API, mark `executeFunction` as `@deprecated` +3. v1.2.0: Still support both APIs, warn users +4. v2.0.0: Remove `executeFunction`, set `MIN_SUPPORTED_API_VERSION = "1.1.0"` + +**Important:** Do NOT update MIN_SUPPORTED_API_VERSION for additive changes (new APIs). Tools built with older APIs will continue to work on newer ToolBox versions automatically. + +### API Changes Best Practices + +1. **Non-Breaking Changes (Patch/Minor):** + - Add new optional API methods + - Add new optional parameters to existing methods + - Fix bugs + - Update documentation + +2. **Breaking Changes (Major):** + - Remove deprecated APIs (after warning period) + - Change existing API signatures + - Rename APIs + - Change behavior in incompatible ways + - Announcing deprecated APIs + +3. **Deprecation Process:** + - Mark APIs as `@deprecated` in `@pptb/types` + - Document replacement APIs + - Wait at least 2 major versions before removal + - Update `MIN_SUPPORTED_API_VERSION` when removing + +--- + +## For Tool Registry Administrators + +### Database Schema + +The Supabase `tools` table should include these columns: + +```sql +-- Add to existing tools table +ALTER TABLE tools ADD COLUMN min_api TEXT; +ALTER TABLE tools ADD COLUMN max_api TEXT; + +-- Indexes for performance +CREATE INDEX idx_tools_min_api ON tools(min_api); +CREATE INDEX idx_tools_max_api ON tools(max_api); +``` + +### Tool Intake Process + +When processing a new tool submission or update: + +1. **Extract Version Information:** + - Read `package.json` → get `features.minAPI` + - Read `npm-shrinkwrap.json` → get `dependencies["@pptb/types"].version` + - Validate both values are present and valid semver + +2. **Validate Versions:** + + ```typescript + // Pseudo-code validation + if (!semver.valid(minAPI)) { + reject("Invalid minAPI version format"); + } + if (!semver.valid(maxAPI)) { + reject("Invalid maxAPI version format"); + } + if (semver.gt(minAPI, maxAPI)) { + reject("minAPI cannot be greater than maxAPI"); + } + ``` + +3. **Store in Database:** + + ```sql + INSERT INTO tools (id, name, version, min_api, max_api, ...) + VALUES ($1, $2, $3, $4, $5, ...); + ``` + +4. **Update Local Registry (Backup):** + - Update `src/main/data/registry.json` with new tool + - Include `minAPI` and `maxAPI` fields + - Commit to repository + +### Handling Legacy Tools + +For existing tools without version information: + +- Set `minAPI = null` (assumed compatible) +- Set `maxAPI = null` (assumed compatible) +- Reach out to tool developers to update their submissions +- Add notification in tool detail page about missing version info + +--- + +## Technical Implementation + +### Version Comparison Algorithm + +Located in `src/main/managers/toolsManager.ts`: + +```typescript +function compareVersions(v1: string, v2: string): number { + // Split version into numeric and pre-release parts + const parseVersion = (v: string) => { + const [numericPart, preRelease] = v.split("-"); + const numeric = numericPart.split(".").map((p) => parseInt(p, 10) || 0); + return { numeric, preRelease: preRelease || null }; + }; + + const parsed1 = parseVersion(v1); + const parsed2 = parseVersion(v2); + + // Compare numeric parts + const maxLength = Math.max(parsed1.numeric.length, parsed2.numeric.length); + for (let i = 0; i < maxLength; i++) { + const p1 = parsed1.numeric[i] || 0; + const p2 = parsed2.numeric[i] || 0; + if (p1 < p2) return -1; + if (p1 > p2) return 1; + } + + // If numeric parts are equal, compare pre-release + // Release version (no pre-release) > Pre-release version + if (parsed1.preRelease === null && parsed2.preRelease !== null) return 1; + if (parsed1.preRelease !== null && parsed2.preRelease === null) return -1; + if (parsed1.preRelease !== null && parsed2.preRelease !== null) { + // Simple string comparison for pre-release tags + if (parsed1.preRelease < parsed2.preRelease) return -1; + if (parsed1.preRelease > parsed2.preRelease) return 1; + } + + return 0; +} +``` + +**Note:** This implementation properly handles pre-release versions (e.g., `1.0.0-beta.1 < 1.0.0`). + +### Compatibility Check Logic + +```typescript +function isToolSupported(minAPI?: string, maxAPI?: string): boolean { + // No version constraints = compatible (legacy tools) + if (!minAPI && !maxAPI) return true; + + if (minAPI) { + // Check 1: Tool's minAPI >= MIN_SUPPORTED_API_VERSION + // Ensures tool doesn't use deprecated/removed APIs + if (compareVersions(minAPI, MIN_SUPPORTED_API_VERSION) < 0) { + return false; // Tool uses APIs older than we support + } + + // Check 2: TOOLBOX_VERSION >= tool.minAPI + // Ensures ToolBox has minimum APIs the tool needs + if (compareVersions(TOOLBOX_VERSION, minAPI) < 0) { + return false; // ToolBox is older than tool requires + } + } + + // maxAPI is informational only - tools work on newer versions + // unless breaking changes occur (tracked by MIN_SUPPORTED_API_VERSION) + + return true; +} +``` + +**Key Points:** + +- `maxAPI` does not restrict compatibility - it's for informational purposes only +- Tools built with older APIs continue to work on newer ToolBox versions +- Breaking changes are signaled by updating `MIN_SUPPORTED_API_VERSION` +- This approach maximizes forward compatibility +- Version checking logic is handled by `VersionManager` class + +### Data Flow + +1. **Installation:** + - User clicks "Install" on a tool + - `toolRegistryManager.installTool()` downloads the package + - Reads `minAPI` and `maxAPI` from Supabase tools table (min_api and max_api columns) + - Stores in `manifest.json` as `minAPI` and `maxAPI` + +2. **Loading:** + - `toolsManager.loadTool()` reads manifest + - `loadToolFromManifest()` creates Tool object + - `VersionManager.isToolSupported()` checks compatibility + - Sets `tool.isSupported` boolean + +3. **UI Display:** + - Sidebar and marketplace read `tool.isSupported` + - Unsupported tools get red "Not Supported" badge + - CSS applies visual indicators (opacity, border) + - Launch button disabled with helpful tooltip + +**Note:** Version information (min_api and max_api) is pre-processed during tool intake/submission and stored in Supabase. The ToolBox application reads these values from the database, not from the tool package files. + +--- + +## User Experience + +### Visual Indicators + +**Unsupported Tools:** + +- Red "⚠ Not Supported" badge in top-right corner +- Red left border (3px solid #c50f1f) +- Reduced opacity (70%) +- Disabled install/launch buttons + +**CSS Classes:** + +```scss +.tool-unsupported-badge { + background: #c50f1f; + color: white; + padding: 2px 8px; + border-radius: 3px; +} + +.tool-item-pptb.unsupported { + border-left: 3px solid #c50f1f; + background: rgba(197, 15, 31, 0.05); + opacity: 0.7; +} +``` + +### User Actions + +**Attempting to Launch Unsupported Tool:** + +``` +[Notification] +Title: "Tool Not Supported" +Message: "{ToolName} requires a different version of Power Platform ToolBox. + Please update your ToolBox to use this tool." +Type: Warning +``` + +**In Marketplace:** + +- Install button disabled +- Tooltip: "This tool requires ToolBox version X.Y.Z or higher" +- Tool detail modal shows version requirements + +### Tool Detail Modal + +Shows version compatibility information: + +``` +Minimum ToolBox Version: 1.0.12 +Built with API Version: 1.3.1 +Your ToolBox Version: 1.0.1 + +⚠ This tool requires ToolBox v1.0.12 or newer +→ Update ToolBox to use this tool +``` + +--- + +## Troubleshooting + +### Tool Shows as Unsupported + +**Check 1: ToolBox Version** + +```bash +# In ToolBox settings, check "About" section +Current Version: 1.0.1 +``` + +**Check 2: Tool Requirements** + +- Right-click tool → "Details" +- Look for "Minimum Version" and "API Version" +- Compare with your ToolBox version + +**Solution:** + +- Update ToolBox to the required version +- Or contact tool developer to support older versions + +### Tool Works But Shows Unsupported + +**Possible Causes:** + +1. Tool missing `minAPI` in package.json +2. Tool missing `npm-shrinkwrap.json` +3. Registry data outdated + +**Solution:** + +- Contact tool developer to update submission +- Reinstall tool after developer updates + +### Version Mismatch in Workflow + +**Error in GitHub Actions:** + +``` +❌ Error: @pptb/types version (1.0.10) does not match ToolBox version (1.0.11) +``` + +**Solution:** + +```bash +cd packages +npm version 1.0.11 --no-git-tag-version +git add package.json +git commit -m "Sync @pptb/types version to 1.0.11" +``` + +--- + +## Future Enhancements + +1. **Automatic Updates:** + - Prompt user to update ToolBox when loading unsupported tool + - Direct link to download page + +2. **Version Range Support:** + - Allow tools to specify compatible range: `"minAPI": ">=1.0.0 <2.0.0"` + +3. **API Feature Detection:** + - Instead of version numbers, check for specific API features + - More flexible for backward compatibility + +4. **Tool Migration Assistance:** + - When API changes, provide migration guide + - Automated tool updating scripts + +5. **Registry Analytics:** + - Track which ToolBox versions are most common + - Help tool developers make version support decisions + +--- + +## References + +- [Semantic Versioning](https://semver.org/) +- [npm Shrinkwrap Documentation](https://docs.npmjs.com/cli/v8/commands/npm-shrinkwrap) +- [Power Platform ToolBox API Types](https://www.npmjs.com/package/@pptb/types) diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index 3e477f64..aca34f05 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -137,6 +137,7 @@ export const UPDATE_CHANNELS = { DOWNLOAD_UPDATE: "download-update", QUIT_AND_INSTALL: "quit-and-install", GET_APP_VERSION: "get-app-version", + GET_VERSION_COMPATIBILITY_INFO: "get-version-compatibility-info", } as const; // Dataverse-related IPC channels diff --git a/src/common/types/api.ts b/src/common/types/api.ts index 0b332161..1b34f608 100644 --- a/src/common/types/api.ts +++ b/src/common/types/api.ts @@ -209,6 +209,7 @@ export interface ToolboxAPI { downloadUpdate: () => Promise; quitAndInstall: () => Promise; getAppVersion: () => Promise; + getVersionCompatibilityInfo: () => Promise<{ appVersion: string; minSupportedApiVersion: string }>; onUpdateChecking: (callback: () => void) => void; onUpdateAvailable: (callback: (info: unknown) => void) => void; onUpdateNotAvailable: (callback: () => void) => void; diff --git a/src/common/types/tool.ts b/src/common/types/tool.ts index ee301bc6..196a062b 100644 --- a/src/common/types/tool.ts +++ b/src/common/types/tool.ts @@ -15,6 +15,12 @@ export interface ToolFeatures { * - "none": Single connection only (default behavior) */ multiConnection?: "required" | "optional" | "none"; + /** + * Minimum ToolBox API version required by this tool + * Tool developers should specify this in their package.json + * @example "1.0.12" + */ + minAPI?: string; } /** @@ -43,6 +49,9 @@ export interface Tool { status?: "active" | "deprecated" | "archived"; // Tool lifecycle status repository?: string; website?: string; + minAPI?: string; // Minimum ToolBox API version required + maxAPI?: string; // Maximum ToolBox API version tested + isSupported?: boolean; // Whether this tool is compatible with current ToolBox version } /** @@ -71,6 +80,8 @@ export interface ToolRegistryEntry { status?: "active" | "deprecated" | "archived"; // Tool lifecycle status repository?: string; website?: string; + minAPI?: string; // Minimum ToolBox API version required (from features.minAPI) + maxAPI?: string; // Maximum ToolBox API version tested (from npm-shrinkwrap @pptb/types version) } /** @@ -100,6 +111,8 @@ export interface ToolManifest { website?: string; publishedAt?: string; createdAt?: string; + minAPI?: string; // Minimum ToolBox API version required (from features.minAPI) + maxAPI?: string; // Maximum ToolBox API version tested (from npm-shrinkwrap @pptb/types version) } /** diff --git a/src/common/utils/version.ts b/src/common/utils/version.ts new file mode 100644 index 00000000..86f2d7ca --- /dev/null +++ b/src/common/utils/version.ts @@ -0,0 +1,27 @@ +export function compareVersions(v1: string, v2: string): number { + const parseVersion = (version: string) => { + const [numericPart, preRelease] = version.split("-"); + const numeric = numericPart.split(".").map((part) => parseInt(part, 10) || 0); + return { numeric, preRelease: preRelease || null }; + }; + + const parsed1 = parseVersion(v1); + const parsed2 = parseVersion(v2); + + const maxLength = Math.max(parsed1.numeric.length, parsed2.numeric.length); + for (let i = 0; i < maxLength; i++) { + const p1 = parsed1.numeric[i] || 0; + const p2 = parsed2.numeric[i] || 0; + if (p1 < p2) return -1; + if (p1 > p2) return 1; + } + + if (parsed1.preRelease === null && parsed2.preRelease !== null) return 1; + if (parsed1.preRelease !== null && parsed2.preRelease === null) return -1; + if (parsed1.preRelease !== null && parsed2.preRelease !== null) { + if (parsed1.preRelease < parsed2.preRelease) return -1; + if (parsed1.preRelease > parsed2.preRelease) return 1; + } + + return 0; +} diff --git a/src/main/constants.ts b/src/main/constants.ts index ce1b076f..bec93f64 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -23,6 +23,14 @@ export const TOOL_REGISTRY_URL = "https://www.powerplatformtoolbox.com/registry/ export const SUPABASE_URL = process.env.SUPABASE_URL || ""; export const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY || ""; +/** + * Minimum API version supported by this ToolBox version + * Tools requiring older API versions than this will not be supported + * This represents backwards compatibility - how far back we support + * 1.0.17 - File System breaking change was introduced + */ +export const MIN_SUPPORTED_API_VERSION = "1.0.17"; + /** * Azure Blob Storage Configuration * Base URL for the Azure Blob container that hosts tool packages and the remote registry. diff --git a/src/main/index.ts b/src/main/index.ts index bda35fac..64972c61 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -100,6 +100,7 @@ import { ToolBoxUtilityManager } from "./managers/toolboxUtilityManager"; import { ToolFileSystemAccessManager } from "./managers/toolFileSystemAccessManager"; import { ToolManager } from "./managers/toolsManager"; import { ToolWindowManager } from "./managers/toolWindowManager"; +import { VersionManager } from "./managers/versionManager"; // Constants const MENU_CREATION_DEBOUNCE_MS = 150; // Debounce delay for menu recreation during rapid tool switches @@ -393,6 +394,7 @@ class ToolBoxApp { ipcMain.removeHandler(UPDATE_CHANNELS.DOWNLOAD_UPDATE); ipcMain.removeHandler(UPDATE_CHANNELS.QUIT_AND_INSTALL); ipcMain.removeHandler(UPDATE_CHANNELS.GET_APP_VERSION); + ipcMain.removeHandler(UPDATE_CHANNELS.GET_VERSION_COMPATIBILITY_INFO); // Dataverse handlers ipcMain.removeHandler(DATAVERSE_CHANNELS.CREATE); @@ -1244,6 +1246,13 @@ class ToolBoxApp { return this.autoUpdateManager.getCurrentVersion(); }); + ipcMain.handle(UPDATE_CHANNELS.GET_VERSION_COMPATIBILITY_INFO, () => { + return { + appVersion: this.autoUpdateManager.getCurrentVersion(), + minSupportedApiVersion: VersionManager.getMinSupportedApiVersion(), + }; + }); + // Dataverse API handlers // All handlers automatically get the connectionId from the calling tool's WebContents // For multi-connection tools, an optional connectionTarget parameter can be passed to specify "primary" or "secondary" diff --git a/src/main/managers/toolRegistryManager.ts b/src/main/managers/toolRegistryManager.ts index f00b67d1..55bc7bea 100644 --- a/src/main/managers/toolRegistryManager.ts +++ b/src/main/managers/toolRegistryManager.ts @@ -73,6 +73,8 @@ interface SupabaseTool { status?: string; // Tool lifecycle status: active, deprecated, archived repository?: string; website?: string; + min_api?: string; // Minimum ToolBox API version required + max_api?: string; // Maximum ToolBox API version tested tool_categories?: SupabaseCategoryRow[]; tool_contributors?: SupabaseContributorRow[]; tool_analytics?: SupabaseAnalyticsRow | SupabaseAnalyticsRow[]; // sometimes array depending on RLS / joins @@ -108,6 +110,8 @@ interface LocalRegistryTool { cspExceptions?: CspExceptions; features?: Record; status?: string; // Tool lifecycle status: active, deprecated, archived + minAPI?: string; // Minimum ToolBox API version required + maxAPI?: string; // Maximum ToolBox API version tested } /** @@ -238,6 +242,8 @@ export class ToolRegistryManager extends EventEmitter { "status", "repository", "website", + "min_api", + "max_api", // embedded relations "tool_categories(categories(name))", "tool_contributors(contributors(name,profile_url))", @@ -295,6 +301,8 @@ export class ToolRegistryManager extends EventEmitter { rating, mau, status: (tool.status as "active" | "deprecated" | "archived" | undefined) || "active", + minAPI: tool.min_api, // Include min API version from database + maxAPI: tool.max_api, // Include max API version from database } as ToolRegistryEntry; }); @@ -460,6 +468,8 @@ export class ToolRegistryManager extends EventEmitter { features: tool.features, license: tool.license, status: (tool.status as "active" | "deprecated" | "archived" | undefined) || "active", + minAPI: tool.minAPI, + maxAPI: tool.maxAPI, })); logInfo(`[ToolRegistry] Fetched ${tools.length} tools from local registry`); @@ -609,6 +619,16 @@ export class ToolRegistryManager extends EventEmitter { const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")); + // Extract version information from registry (Supabase) + // These are pre-processed during tool intake and stored in the database + const minAPI: string | undefined = tool.minAPI; // From Supabase tools table (min_api column) + const maxAPI: string | undefined = tool.maxAPI; // From Supabase tools table (max_api column) + + // Log if version info is missing (informational only, tools will still work as legacy) + if (!minAPI && !maxAPI) { + logInfo(`[ToolRegistry] Tool ${toolId} does not have version information in registry. Tool will be treated as compatible with all versions (legacy behavior).`); + } + // Create manifest // Normalize authors list: prefer registry contributors, fallback to package.json author let authors: string[] | undefined = tool.authors; @@ -642,6 +662,8 @@ export class ToolRegistryManager extends EventEmitter { website: tool.website, // Include website URL from registry createdAt: tool.createdAt, publishedAt: tool.publishedAt, + minAPI, // Minimum API version required + maxAPI, // Maximum API version tested (from @pptb/types) }; // Save to manifest file @@ -753,6 +775,8 @@ export class ToolRegistryManager extends EventEmitter { mau: manifestEntry.mau, publishedAt: manifestEntry.publishedAt, createdAt: manifestEntry.createdAt, + minAPI: manifestEntry.minAPI, + maxAPI: manifestEntry.maxAPI, }; } diff --git a/src/main/managers/toolsManager.ts b/src/main/managers/toolsManager.ts index a7d15bcd..889226d8 100644 --- a/src/main/managers/toolsManager.ts +++ b/src/main/managers/toolsManager.ts @@ -7,6 +7,7 @@ import { captureMessage, logInfo } from "../../common/sentryHelper"; import { CspExceptions, Tool, ToolFeatures, ToolManifest } from "../../common/types"; import { InstallIdManager } from "./installIdManager"; import { ToolRegistryManager } from "./toolRegistryManager"; +import { VersionManager } from "./versionManager"; /** * Package.json structure for tool validation @@ -48,6 +49,8 @@ export class ToolManager extends EventEmitter { this.emit("tool:installed", manifest); }); this.registryManager.on("tool:uninstalled", (toolId) => { + // Clear from cache when uninstalled + this.tools.delete(toolId); this.emit("tool:uninstalled", toolId); }); } @@ -73,6 +76,9 @@ export class ToolManager extends EventEmitter { readmeUrl: manifest.readme, publishedAt: manifest.publishedAt, createdAt: manifest.createdAt, + minAPI: manifest.minAPI, + maxAPI: manifest.maxAPI, + isSupported: VersionManager.isToolSupported(manifest.minAPI, manifest.maxAPI), }; const cached = this.analyticsCache.get(tool.id); @@ -140,6 +146,9 @@ export class ToolManager extends EventEmitter { repository: manifest.repository, website: manifest.website, readmeUrl: manifest.readme, + minAPI: manifest.minAPI, + maxAPI: manifest.maxAPI, + isSupported: VersionManager.isToolSupported(manifest.minAPI, manifest.maxAPI), }; const cached = this.analyticsCache.get(tool.id); @@ -192,6 +201,8 @@ export class ToolManager extends EventEmitter { getTool(toolId: string): Tool | undefined { const tool = this.tools.get(toolId); if (tool) { + // Always recompute isSupported in case ToolBox version changed + tool.isSupported = VersionManager.isToolSupported(tool.minAPI, tool.maxAPI); return tool; } @@ -218,13 +229,21 @@ export class ToolManager extends EventEmitter { const installedManifests = this.registryManager.getInstalledToolsSync(); installedManifests.forEach((manifest) => { const loaded = this.tools.get(manifest.id); - toolsById.set(manifest.id, loaded || this.createToolFromInstalledManifest(manifest)); + if (loaded) { + // Always recompute isSupported in case ToolBox version changed + loaded.isSupported = VersionManager.isToolSupported(loaded.minAPI, loaded.maxAPI); + toolsById.set(manifest.id, loaded); + } else { + toolsById.set(manifest.id, this.createToolFromInstalledManifest(manifest)); + } }); // Include any loaded tools that might not be in the registry manifest // (e.g., local dev tools). this.tools.forEach((tool, id) => { if (!toolsById.has(id)) { + // Recompute isSupported for these tools too + tool.isSupported = VersionManager.isToolSupported(tool.minAPI, tool.maxAPI); toolsById.set(id, tool); } }); @@ -251,8 +270,17 @@ export class ToolManager extends EventEmitter { /** * Fetch available tools from registry */ - async fetchAvailableTools() { - return await this.registryManager.fetchRegistry(); + async fetchAvailableTools(): Promise { + const registryTools = await this.registryManager.fetchRegistry(); + + // Convert ToolRegistryEntry[] to Tool[] and add isSupported field + return registryTools.map((registryTool) => { + const tool: Tool = { + ...registryTool, + isSupported: VersionManager.isToolSupported(registryTool.minAPI, registryTool.maxAPI), + }; + return tool; + }); } /** diff --git a/src/main/managers/versionManager.ts b/src/main/managers/versionManager.ts new file mode 100644 index 00000000..490ee42c --- /dev/null +++ b/src/main/managers/versionManager.ts @@ -0,0 +1,71 @@ +import { app } from "electron"; +import { compareVersions } from "../../common/utils/version"; +import { MIN_SUPPORTED_API_VERSION } from "../constants"; + +/** + * Version Manager + * Handles version comparison and compatibility checking for tools + */ +export class VersionManager { + /** + * Check if a tool is compatible with the current ToolBox version + * @param minAPI - Minimum API version required by the tool (from Supabase) + * @param maxAPI - Maximum API version tested by the tool (from Supabase, informational only) + * @returns true if the tool is supported, false otherwise + * + * Compatibility rules: + * 1. If tool has no version constraints (legacy): always compatible + * 2. Tool's minAPI must be >= MIN_SUPPORTED_API_VERSION (doesn't use deprecated APIs) + * 3. Tool's minAPI must be <= current ToolBox version (ToolBox meets minimum requirement) + * 4. maxAPI is informational only - tools built with older APIs continue to work + * unless breaking changes are introduced (tracked by MIN_SUPPORTED_API_VERSION) + */ + static isToolSupported(minAPI?: string, maxAPI?: string): boolean { + const toolboxVersion = VersionManager.getToolBoxVersion(); + + // If no version constraints, assume compatible (legacy tools) + if (!minAPI && !maxAPI) { + return true; + } + + // Check minimum version requirements + if (minAPI) { + // Tool's minAPI must be >= MIN_SUPPORTED_API_VERSION + // This ensures the tool doesn't require APIs that have been deprecated/removed + const minAPIvsMinSupported = compareVersions(minAPI, MIN_SUPPORTED_API_VERSION); + if (minAPIvsMinSupported < 0) { + // Tool requires APIs older than what we support + return false; + } + + // Tool's minAPI must be <= current ToolBox version + // This ensures the current ToolBox has the minimum APIs the tool needs + const toolboxVsMinAPI = compareVersions(toolboxVersion, minAPI); + if (toolboxVsMinAPI < 0) { + // Current ToolBox version is older than what tool requires + return false; + } + } + + // TODO: For future enhancement, if installed ToolBox version is less than the the API tool is built on + // maxAPI is informational only - tools built with older APIs will continue + // to work on newer ToolBox versions unless we introduce breaking changes + // Breaking changes are tracked by updating MIN_SUPPORTED_API_VERSION + + return true; + } + + /** + * Get the current ToolBox version from Electron app + */ + static getToolBoxVersion(): string { + return app.getVersion(); + } + + /** + * Get the minimum supported API version + */ + static getMinSupportedApiVersion(): string { + return MIN_SUPPORTED_API_VERSION; + } +} diff --git a/src/main/preload.ts b/src/main/preload.ts index 163f1fe8..a1af3afd 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -180,6 +180,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { downloadUpdate: () => ipcRenderer.invoke(UPDATE_CHANNELS.DOWNLOAD_UPDATE), quitAndInstall: () => ipcRenderer.invoke(UPDATE_CHANNELS.QUIT_AND_INSTALL), getAppVersion: () => ipcRenderer.invoke(UPDATE_CHANNELS.GET_APP_VERSION), + getVersionCompatibilityInfo: () => ipcRenderer.invoke(UPDATE_CHANNELS.GET_VERSION_COMPATIBILITY_INFO), onUpdateChecking: (callback: () => void) => { ipcRenderer.on(EVENT_CHANNELS.UPDATE_CHECKING, callback); }, diff --git a/src/renderer/modals/toolDetail/controller.ts b/src/renderer/modals/toolDetail/controller.ts index 844601de..a5eb35a5 100644 --- a/src/renderer/modals/toolDetail/controller.ts +++ b/src/renderer/modals/toolDetail/controller.ts @@ -10,6 +10,7 @@ export interface ToolDetailModalState { toolId: string; toolName: string; isInstalled: boolean; + isSupported?: boolean; readmeUrl?: string | null; reviewUrl: string; repositoryUrl?: string | null; @@ -71,6 +72,14 @@ export function getToolDetailModalControllerScript(config: ToolDetailModalContro const handleInstallClick = () => { if (!(installBtn instanceof HTMLButtonElement)) return; if (installBtn.disabled) return; + + // Double-check compatibility + if (CONFIG.state.isSupported === false) { + installBtn.disabled = true; + installBtn.textContent = "Not supported"; + setFeedback("This tool is not compatible with your version of Power Platform ToolBox. Please update your ToolBox to use this tool.", true); + return; + } installBtn.disabled = true; installBtn.textContent = "Installing..."; setFeedback(""); diff --git a/src/renderer/modals/toolDetail/view.ts b/src/renderer/modals/toolDetail/view.ts index 7768e29d..3730b8c8 100644 --- a/src/renderer/modals/toolDetail/view.ts +++ b/src/renderer/modals/toolDetail/view.ts @@ -14,6 +14,7 @@ export interface ToolDetailModalViewModel { metaBadges: string[]; categories: string[]; isInstalled: boolean; + isSupported?: boolean; readmeUrl?: string; isDarkTheme: boolean; repository?: string; @@ -284,7 +285,7 @@ export function getToolDetailModalView(model: ToolDetailModalViewModel): ModalVi

    By ${model.authors}

    ${badgeMarkup || ratingsHtml ? `
    ${badgeMarkup}${ratingsHtml}
    ` : ""}
    - + Installed
    ${linksMarkup} diff --git a/src/renderer/modules/marketplaceManagement.ts b/src/renderer/modules/marketplaceManagement.ts index ed81d056..a48187ae 100644 --- a/src/renderer/modules/marketplaceManagement.ts +++ b/src/renderer/modules/marketplaceManagement.ts @@ -8,6 +8,7 @@ import type { ModalWindowClosedPayload, ModalWindowMessagePayload, Tool } from " import { getToolDetailModalControllerScript } from "../modals/toolDetail/controller"; import { getToolDetailModalView } from "../modals/toolDetail/view"; import type { ToolDetail } from "../types/index"; +import { getUnsupportedBadgeTitle, getUnsupportedRequirement } from "../utils/toolCompatibility"; import { applyToolIconMasks, escapeHtml, generateToolIconHtml, resolveToolIconUrl } from "../utils/toolIconResolver"; import { onBrowserWindowModalClosed, onBrowserWindowModalMessage, sendBrowserWindowModalMessage, showBrowserWindowModal } from "./browserWindowModals"; import { loadSidebarTools } from "./toolsSidebarManagement"; @@ -75,6 +76,9 @@ export async function loadToolsLibrary(): Promise { repository: tool.repository, website: tool.website, createdAt: tool.createdAt, // Use createdAt for new tool detection + minAPI: tool.minAPI, // Include min API version + maxAPI: tool.maxAPI, // Include max API version + isSupported: tool.isSupported, // Include compatibility status }) as ToolDetail, ); @@ -110,6 +114,7 @@ export async function loadMarketplace(): Promise { // Get display mode setting const displayMode = ((await window.toolboxAPI.getSetting("toolDisplayMode")) as string) || "standard"; + const versionInfo = await window.toolboxAPI.getVersionCompatibilityInfo().catch(() => null); // Get filter and sort values const searchInput = document.getElementById("marketplace-search-input") as HTMLInputElement | null; @@ -234,7 +239,10 @@ export async function loadMarketplace(): Promise { // Show all categories for this tool const categoriesHtml = tool.categories && tool.categories.length ? tool.categories.map((t) => `${t}`).join("") : ""; const isDeprecated = tool.status === "deprecated"; + const isUnsupported = tool.isSupported === false; + const unsupportedRequirement = getUnsupportedRequirement(tool, versionInfo); const deprecatedBadgeHtml = isDeprecated ? 'Deprecated' : ""; + const unsupportedBadgeHtml = isUnsupported ? `Not Supported` : ""; const newBadgeHtml = isNewTool ? 'NEW' : ""; const analyticsHtml = `
    ${tool.downloads !== undefined ? `⬇ ${tool.downloads}` : ""} @@ -252,7 +260,7 @@ export async function loadMarketplace(): Promise { if (displayMode === "compact") { // Compact mode: icon, name, version, author only return ` -
    +
    ${toolIconHtml}
    @@ -265,7 +273,7 @@ export async function loadMarketplace(): Promise { ${ isInstalled ? '' - : `` }
    @@ -277,7 +285,7 @@ export async function loadMarketplace(): Promise { // Standard mode: full details return ` -
    +
    ${toolIconHtml}
    @@ -290,7 +298,7 @@ export async function loadMarketplace(): Promise { ${ isInstalled ? '' - : `` }
    @@ -300,7 +308,7 @@ export async function loadMarketplace(): Promise { -
    ${newBadgeHtml}${categoriesHtml}${deprecatedBadgeHtml}
    +
    ${newBadgeHtml}${categoriesHtml}${deprecatedBadgeHtml}${unsupportedBadgeHtml}
    `; }) @@ -609,6 +617,7 @@ function buildToolDetailModalHtml(tool: ToolDetail, isInstalled: boolean): strin metaBadges: metaBadges.map((badge) => escapeHtml(badge)), categories: categories, isInstalled, + isSupported: tool.isSupported, readmeUrl: tool.readmeUrl, isDarkTheme, repository: tool.repository, @@ -622,6 +631,7 @@ function buildToolDetailModalHtml(tool: ToolDetail, isInstalled: boolean): strin toolId: tool.id, toolName: tool.name, isInstalled, + isSupported: tool.isSupported, readmeUrl: tool.readmeUrl || null, reviewUrl: `https://www.powerplatformtoolbox.com/rate-tool?toolId=${encodeURIComponent(tool.id)}`, repositoryUrl: tool.repository || null, diff --git a/src/renderer/modules/toolManagement.ts b/src/renderer/modules/toolManagement.ts index 90476737..5b71b7ed 100644 --- a/src/renderer/modules/toolManagement.ts +++ b/src/renderer/modules/toolManagement.ts @@ -6,6 +6,7 @@ import { captureException, captureMessage, logInfo, logWarn } from "../../common/sentryHelper"; import type { DataverseConnection } from "../../common/types/connection"; import type { OpenTool, SessionData } from "../types/index"; +import { getUnsupportedRequirement, getUnsupportedToolMessage } from "../utils/toolCompatibility"; import { openSelectConnectionModal, openSelectMultiConnectionModal } from "./connectionManagement"; import { openCspExceptionModal } from "./cspExceptionModal"; import { hideHomePage, showHomePage as showDynamicHomePage } from "./homepageManagement"; @@ -95,6 +96,25 @@ export async function launchTool(toolId: string, options?: LaunchToolOptions): P return; } + // Check if tool is supported by current ToolBox version + if (tool.isSupported === false) { + const versionInfo = await window.toolboxAPI.getVersionCompatibilityInfo().catch((error) => { + logWarn("Failed to retrieve version compatibility info for unsupported tool message", { + error: error instanceof Error ? error.message : String(error), + toolId, + }); + return null; + }); + + const unsupportedRequirement = getUnsupportedRequirement(tool, versionInfo); + window.toolboxAPI.utils.showNotification({ + title: "Tool Not Supported", + body: getUnsupportedToolMessage(tool.name, unsupportedRequirement), + type: "warning", + }); + return; + } + // Determine multi-connection mode const multiConnectionMode = tool.features?.multiConnection || "none"; diff --git a/src/renderer/modules/toolsSidebarManagement.ts b/src/renderer/modules/toolsSidebarManagement.ts index e1100b80..2722dd55 100644 --- a/src/renderer/modules/toolsSidebarManagement.ts +++ b/src/renderer/modules/toolsSidebarManagement.ts @@ -5,6 +5,7 @@ import { captureMessage, logInfo } from "../../common/sentryHelper"; import { ToolDetail } from "../types/index"; +import { getUnsupportedBadgeTitle, getUnsupportedRequirement } from "../utils/toolCompatibility"; import { applyToolIconMasks, generateToolIconHtml } from "../utils/toolIconResolver"; import { getToolSourceIconHtml } from "../utils/toolSourceIcon"; import { loadMarketplace, openToolDetail } from "./marketplaceManagement"; @@ -25,6 +26,7 @@ export async function loadSidebarTools(): Promise { const favoriteTools = await window.toolboxAPI.getFavoriteTools(); const deprecatedToolsVisibility = (await window.toolboxAPI.getSetting("deprecatedToolsVisibility")) || "hide-all"; const displayMode = ((await window.toolboxAPI.getSetting("toolDisplayMode")) as string) || "standard"; + const versionInfo = await window.toolboxAPI.getVersionCompatibilityInfo().catch(() => null); if (tools.length === 0) { toolsList.innerHTML = ` @@ -190,6 +192,8 @@ export async function loadSidebarTools(): Promise { const latestVersion = tool.latestVersion; const description = tool.description || ""; const isDeprecated = tool.status === "deprecated"; + const isUnsupported = tool.isSupported === false; + const unsupportedRequirement = getUnsupportedRequirement(tool, versionInfo); // Show up to two categories, with a +N indicator if more remain const categoriesHtml = (() => { if (!tool.categories || !tool.categories.length) return ""; @@ -200,6 +204,7 @@ export async function loadSidebarTools(): Promise { return `${visibleHtml}${moreHtml}`; })(); const deprecatedBadgeHtml = isDeprecated ? '⚠ Deprecated' : ""; + const unsupportedBadgeHtml = isUnsupported ? `⚠ Not Supported` : ""; // Get tool source icon const sourceIconHtml = getToolSourceIconHtml(tool.id); @@ -240,7 +245,7 @@ export async function loadSidebarTools(): Promise { if (displayMode === "compact") { // Compact mode: icon, name, version, author only return ` -
    +
    ${updatingOverlayHtml}
    @@ -271,7 +276,7 @@ export async function loadSidebarTools(): Promise { // Standard mode: full details return ` -
    +
    ${updatingOverlayHtml}
    @@ -309,7 +314,7 @@ export async function loadSidebarTools(): Promise { -
    ${categoriesHtml}${deprecatedBadgeHtml}
    +
    ${categoriesHtml}${deprecatedBadgeHtml}${unsupportedBadgeHtml}
    ${ shouldShowUpdateInfo ? `
    ` diff --git a/src/renderer/styles.scss b/src/renderer/styles.scss index 19c4084b..788a7f9f 100644 --- a/src/renderer/styles.scss +++ b/src/renderer/styles.scss @@ -2180,6 +2180,19 @@ img.tool-item-icon-img { margin-right: 4px; } +.tool-unsupported-badge { + background: #c50f1f; + color: white; + padding: 2px 8px; + border-radius: 3px; + font-size: 10px; + font-weight: 500; + display: inline-flex; + align-items: center; + gap: 4px; + margin-right: 4px; +} + .tool-item-pptb.deprecated { border-left: 3px solid #d83b01; background: rgba(216, 59, 1, 0.05); @@ -2189,6 +2202,16 @@ img.tool-item-icon-img { background: rgba(216, 59, 1, 0.1); } +.tool-item-pptb.unsupported { + border-left: 3px solid #c50f1f; + background: rgba(197, 15, 31, 0.05); + opacity: 0.7; +} + +.tool-item-pptb.unsupported:hover { + background: rgba(197, 15, 31, 0.1); +} + /* Tool updating state */ .tool-item-pptb.tool-item-updating { position: relative; @@ -3446,6 +3469,41 @@ body.dark-theme .modern-markdown code { content: "⚠"; } +.marketplace-item-unsupported-badge { + background: #c50f1f; + color: white; + padding: 2px 8px; + border-radius: 3px; + font-size: 10px; + font-weight: 500; + display: inline-flex; + align-items: center; + gap: 4px; +} + +.marketplace-item-unsupported-badge::before { + content: "⚠"; +} + +.marketplace-item-pptb.deprecated { + border-left: 3px solid #d83b01; + background: rgba(216, 59, 1, 0.05); +} + +.marketplace-item-pptb.deprecated:hover { + background: rgba(216, 59, 1, 0.1); +} + +.marketplace-item-pptb.unsupported { + border-left: 3px solid #c50f1f; + background: rgba(197, 15, 31, 0.05); + opacity: 0.7; +} + +.marketplace-item-pptb.unsupported:hover { + background: rgba(197, 15, 31, 0.1); +} + /* Marketplace item with NEW badge */ .marketplace-item-new-badge { background: linear-gradient(135deg, #6a00ff 0%, #8b00ff 100%); diff --git a/src/renderer/types/index.ts b/src/renderer/types/index.ts index 9db4540c..9815e5e9 100644 --- a/src/renderer/types/index.ts +++ b/src/renderer/types/index.ts @@ -92,4 +92,7 @@ export interface ToolDetail { repository?: string; website?: string; createdAt?: string; // ISO date string from created_at field + minAPI?: string; // Minimum ToolBox API version required + maxAPI?: string; // Maximum ToolBox API version tested + isSupported?: boolean; // Whether this tool is compatible with current ToolBox version } diff --git a/src/renderer/utils/toolCompatibility.ts b/src/renderer/utils/toolCompatibility.ts new file mode 100644 index 00000000..1f9e05c9 --- /dev/null +++ b/src/renderer/utils/toolCompatibility.ts @@ -0,0 +1,81 @@ +import { compareVersions } from "../../common/utils/version"; + +export interface VersionCompatibilityInfo { + appVersion: string; + minSupportedApiVersion: string; +} + +interface ToolVersionLike { + minAPI?: string; + features?: { + minAPI?: string; + }; +} + +export type UnsupportedReason = "toolbox-too-old" | "tool-outdated" | "unknown"; + +export interface UnsupportedRequirement { + reason: UnsupportedReason; + requiredVersion?: string; +} + +export function getUnsupportedRequirement(tool: ToolVersionLike, versionInfo?: VersionCompatibilityInfo | null): UnsupportedRequirement { + const toolMinApi = tool.minAPI || tool.features?.minAPI; + + if (!toolMinApi) { + return { reason: "unknown" }; + } + + if (!versionInfo) { + return { reason: "unknown", requiredVersion: toolMinApi }; + } + + if (compareVersions(toolMinApi, versionInfo.minSupportedApiVersion) < 0) { + return { + reason: "tool-outdated", + requiredVersion: versionInfo.minSupportedApiVersion, + }; + } + + if (compareVersions(versionInfo.appVersion, toolMinApi) < 0) { + return { + reason: "toolbox-too-old", + requiredVersion: toolMinApi, + }; + } + + return { + reason: "unknown", + requiredVersion: toolMinApi, + }; +} + +export function getUnsupportedToolMessage(toolName: string, requirement: UnsupportedRequirement): string { + if (requirement.reason === "tool-outdated") { + return requirement.requiredVersion + ? `${toolName} is built for APIs older than this ToolBox supports (minimum supported API is v${requirement.requiredVersion}). Please update the tool to a newer version or contact the tool author.` + : `${toolName} is built for APIs older than this ToolBox supports. Please update the tool to a newer version or contact the tool author.`; + } + + if (requirement.reason === "toolbox-too-old") { + return requirement.requiredVersion + ? `${toolName} requires Power Platform ToolBox v${requirement.requiredVersion} or later. Please update your ToolBox to use this tool.` + : `${toolName} requires a newer version of Power Platform ToolBox. Please update your ToolBox to use this tool.`; + } + + return `${toolName} is not compatible with this ToolBox version. Please update the tool or contact the tool author.`; +} + +export function getUnsupportedBadgeTitle(requirement: UnsupportedRequirement): string { + if (requirement.reason === "tool-outdated") { + return requirement.requiredVersion + ? `Tool update required (ToolBox supports API v${requirement.requiredVersion}+). Update the tool or contact the author` + : "Tool update required. Update the tool or contact the author"; + } + + if (requirement.reason === "toolbox-too-old") { + return requirement.requiredVersion ? `Requires ToolBox v${requirement.requiredVersion} or later` : "Requires a newer ToolBox version"; + } + + return "Tool is not compatible with this ToolBox version"; +} From 9a33b3492355feecdc19431d05b130472c327851 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Thu, 26 Feb 2026 22:37:30 -0500 Subject: [PATCH 031/178] fix: update permissions for publish-types jobs in release workflows --- .github/workflows/nightly-release.yml | 5 ++++- .github/workflows/prod-release.yml | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 550fd5a9..318b504c 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -887,8 +887,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-types-beta: - needs: publish-release + needs: [publish-release] if: needs.check-commits.outputs.should_build == 'true' + permissions: + contents: read + id-token: write uses: ./.github/workflows/publish-npm-types.yml with: branch: dev diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 8e7d8aa6..41cf33cf 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -44,11 +44,11 @@ jobs: run: | TOOLBOX_VERSION=$(node -p "require('./package.json').version") TYPES_VERSION=$(node -p "require('./packages/package.json').version") - + # Extract major.minor.patch from both versions (ignore pre-release tags) TOOLBOX_BASE=$(echo "$TOOLBOX_VERSION" | cut -d'-' -f1) TYPES_BASE=$(echo "$TYPES_VERSION" | cut -d'-' -f1) - + if [ "$TOOLBOX_BASE" != "$TYPES_BASE" ]; then echo "❌ Error: @pptb/types version ($TYPES_VERSION) does not match ToolBox version ($TOOLBOX_VERSION)" echo "The base version (major.minor.patch) must be identical for stable releases." @@ -58,7 +58,7 @@ jobs: echo "2. Commit the change and push" exit 1 fi - + echo "✅ Version validation passed: ToolBox $TOOLBOX_VERSION matches @pptb/types $TYPES_VERSION" build: @@ -829,10 +829,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-types: - needs: publish-release + needs: [publish-release] + permissions: + contents: read + id-token: write uses: ./.github/workflows/publish-npm-types.yml with: branch: main tag: latest secrets: inherit - From 8bbf5508ab0810604f1abac0e937bb55a44d4e20 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Thu, 26 Feb 2026 22:52:00 -0500 Subject: [PATCH 032/178] fix: replace pnpm with npm for publishing @pptb/types --- .github/workflows/publish-npm-types.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/publish-npm-types.yml b/.github/workflows/publish-npm-types.yml index 8fa23296..6bec1ba3 100644 --- a/.github/workflows/publish-npm-types.yml +++ b/.github/workflows/publish-npm-types.yml @@ -33,9 +33,6 @@ jobs: node-version: "20" registry-url: "https://registry.npmjs.org" - - name: Install pnpm - run: npm install -g pnpm@10.18.3 - - name: Get version id: version run: | @@ -47,6 +44,4 @@ jobs: working-directory: ./packages run: | echo "Publishing @pptb/types@${{ steps.version.outputs.version }} with tag ${{ inputs.tag }} to npm..." - pnpm publish --access public --tag ${{ inputs.tag }} --no-git-checks --provenance - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + npm publish --access public --tag ${{ inputs.tag }} --provenance From b0ca54129c80997249f40d79e10015e1a0aa43c1 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Thu, 26 Feb 2026 22:58:14 -0500 Subject: [PATCH 033/178] fix: update job dependencies and version handling in release workflows --- .github/workflows/nightly-release.yml | 4 ++-- .github/workflows/prod-release.yml | 3 ++- .github/workflows/publish-npm-types.yml | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 318b504c..a9d7e9ae 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -887,7 +887,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-types-beta: - needs: [publish-release] + needs: [check-commits, publish-release, create-release-draft] if: needs.check-commits.outputs.should_build == 'true' permissions: contents: read @@ -896,5 +896,5 @@ jobs: with: branch: dev tag: beta + version: ${{ needs.create-release-draft.outputs.new_version }} secrets: inherit - diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 41cf33cf..395c8f50 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -829,7 +829,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-types: - needs: [publish-release] + needs: [publish-release, create-release-draft] permissions: contents: read id-token: write @@ -837,4 +837,5 @@ jobs: with: branch: main tag: latest + version: ${{ needs.create-release-draft.outputs.version }} secrets: inherit diff --git a/.github/workflows/publish-npm-types.yml b/.github/workflows/publish-npm-types.yml index 6bec1ba3..a0f0f5cb 100644 --- a/.github/workflows/publish-npm-types.yml +++ b/.github/workflows/publish-npm-types.yml @@ -11,6 +11,10 @@ on: description: "npm tag (latest or beta)" required: true type: string + version: + description: "Version to publish for @pptb/types (must match app version)" + required: false + type: string permissions: contents: read @@ -36,10 +40,20 @@ jobs: - name: Get version id: version run: | - VERSION=$(node -p "require('./packages/package.json').version") + if [ -n "${{ inputs.version }}" ]; then + VERSION="${{ inputs.version }}" + else + VERSION=$(node -p "require('./package.json').version") + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT echo "📦 Publishing @pptb/types version: $VERSION with tag: ${{ inputs.tag }}" + - name: Sync @pptb/types version to app version + working-directory: ./packages + run: | + npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version + - name: Publish @pptb/types to npm working-directory: ./packages run: | From be4252d0c7440f9f8a98cb90c2a5f9898d40c08e Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Thu, 26 Feb 2026 23:11:33 -0500 Subject: [PATCH 034/178] fix: update versioning scheme from dev to beta for insider builds --- .github/workflows/nightly-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index a9d7e9ae..eff7e487 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -75,7 +75,7 @@ jobs: run: | CURRENT_VERSION=$(node -p "require('./package.json').version") DATE_TAG=$(date +%Y%m%d) - NEW_VERSION="$CURRENT_VERSION-dev.$DATE_TAG" + NEW_VERSION="$CURRENT_VERSION-beta.$DATE_TAG" echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "📦 Insider version: $NEW_VERSION" @@ -468,7 +468,7 @@ jobs: run: | CURRENT_VERSION=$(node -p "require('./package.json').version") DATE_TAG=$(date +%Y%m%d) - NEW_VERSION="$CURRENT_VERSION-dev.$DATE_TAG" + NEW_VERSION="$CURRENT_VERSION-beta.$DATE_TAG" echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "tag_name=v$NEW_VERSION" >> $GITHUB_OUTPUT echo "release_name=Insider Dev Build - $NEW_VERSION" >> $GITHUB_OUTPUT From f0bf3b07ef268380e09718339ad52e47cc663730 Mon Sep 17 00:00:00 2001 From: LinkeD365 <43988771+LinkeD365@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:38:08 +0000 Subject: [PATCH 035/178] Relationshipdefinitions setname (#415) * fix: add relationshipdefinition to entity metadata mapping in DataverseManager * fix: remove commented-out debug code in DataverseManager * Update src/main/managers/dataverseManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/main/managers/dataverseManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/managers/dataverseManager.ts b/src/main/managers/dataverseManager.ts index e2b08c5b..de829bb9 100644 --- a/src/main/managers/dataverseManager.ts +++ b/src/main/managers/dataverseManager.ts @@ -418,7 +418,6 @@ export class DataverseManager { const { connection, accessToken } = await this.getConnectionWithToken(connectionId); const entitySetName = this.getEntitySetName(entityLogicalName); const url = this.buildApiUrl(connection, `api/data/${DATAVERSE_API_VERSION}/${entitySetName}(${id})`); - await this.makeHttpRequest(url, "DELETE", accessToken); } @@ -437,6 +436,7 @@ export class DataverseManager { usersettingscollection: "usersettingscollection", principalobjectaccess: "principalobjectaccessset", webresource: "webresourceset", + relationshipdefinition: "RelationshipDefinitions", }; const lowerName = entityLogicalName.toLowerCase(); From 02208a6d183d75a8472c730a5939eccff37123e8 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Sat, 28 Feb 2026 21:49:09 -0500 Subject: [PATCH 036/178] fix: add registry URL configuration for npm publishing --- .github/workflows/publish-npm-types.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm-types.yml b/.github/workflows/publish-npm-types.yml index a0f0f5cb..7613a3db 100644 --- a/.github/workflows/publish-npm-types.yml +++ b/.github/workflows/publish-npm-types.yml @@ -35,7 +35,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: "20" - registry-url: "https://registry.npmjs.org" - name: Get version id: version @@ -56,6 +55,9 @@ jobs: - name: Publish @pptb/types to npm working-directory: ./packages + env: + NPM_CONFIG_USERCONFIG: ${{ runner.temp }}/npmrc run: | + printf "registry=https://registry.npmjs.org/\n" > "$NPM_CONFIG_USERCONFIG" echo "Publishing @pptb/types@${{ steps.version.outputs.version }} with tag ${{ inputs.tag }} to npm..." npm publish --access public --tag ${{ inputs.tag }} --provenance From dcc56e65c7ae934803d1a0cbaf301ef7c40304ac Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Sun, 1 Mar 2026 21:18:15 -0500 Subject: [PATCH 037/178] fix: comment out publish-types jobs in release workflows --- .github/workflows/nightly-release.yml | 24 ++++++++++++------------ .github/workflows/prod-release.yml | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index eff7e487..e205b122 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -886,15 +886,15 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish-types-beta: - needs: [check-commits, publish-release, create-release-draft] - if: needs.check-commits.outputs.should_build == 'true' - permissions: - contents: read - id-token: write - uses: ./.github/workflows/publish-npm-types.yml - with: - branch: dev - tag: beta - version: ${{ needs.create-release-draft.outputs.new_version }} - secrets: inherit + # publish-types-beta: + # needs: [check-commits, publish-release, create-release-draft] + # if: needs.check-commits.outputs.should_build == 'true' + # permissions: + # contents: read + # id-token: write + # uses: ./.github/workflows/publish-npm-types.yml + # with: + # branch: dev + # tag: beta + # version: ${{ needs.create-release-draft.outputs.new_version }} + # secrets: inherit diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 395c8f50..3113e1b8 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -828,14 +828,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish-types: - needs: [publish-release, create-release-draft] - permissions: - contents: read - id-token: write - uses: ./.github/workflows/publish-npm-types.yml - with: - branch: main - tag: latest - version: ${{ needs.create-release-draft.outputs.version }} - secrets: inherit + # publish-types: + # needs: [publish-release, create-release-draft] + # permissions: + # contents: read + # id-token: write + # uses: ./.github/workflows/publish-npm-types.yml + # with: + # branch: main + # tag: latest + # version: ${{ needs.create-release-draft.outputs.version }} + # secrets: inherit From 37cf6eb80874c944234cd538c887fb93ec49d124 Mon Sep 17 00:00:00 2001 From: Danish Naglekar <36135520+Power-Maverick@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:25:44 -0500 Subject: [PATCH 038/178] feat: implement custom protocol handler for tool installation via pptb:// links (#419) * feat: implement custom protocol handler for tool installation via pptb:// links * Update src/main/managers/protocolHandlerManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/main/managers/protocolHandlerManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: ensure pptb:// deep links are never dropped on cold launch or early macOS open-url (#420) * Initial plan * fix: move protocol handler early listeners before whenReady() and buffer deep links until renderer ready Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> --- buildScripts/electron-builder-linux.json | 10 +- buildScripts/electron-builder-mac.json | 10 +- buildScripts/electron-builder-win-arm64.json | 10 +- buildScripts/electron-builder-win.json | 10 +- docs/PROTOCOL_HANDLER.md | 414 ++++++++++++++++++ src/common/ipc/channels.ts | 6 + src/common/types/api.ts | 3 + src/main/index.ts | 49 +++ src/main/managers/protocolHandlerManager.ts | 341 +++++++++++++++ src/main/preload.ts | 5 + src/renderer/modules/initialization.ts | 12 +- src/renderer/modules/marketplaceManagement.ts | 79 +++- 12 files changed, 943 insertions(+), 6 deletions(-) create mode 100644 docs/PROTOCOL_HANDLER.md create mode 100644 src/main/managers/protocolHandlerManager.ts diff --git a/buildScripts/electron-builder-linux.json b/buildScripts/electron-builder-linux.json index 43247bf0..a4217d33 100644 --- a/buildScripts/electron-builder-linux.json +++ b/buildScripts/electron-builder-linux.json @@ -11,5 +11,13 @@ ], "category": "Development", "maintainer": "Power Platform ToolBox" - } + }, + "protocols": [ + { + "name": "Power Platform ToolBox Protocol", + "schemes": [ + "pptb" + ] + } + ] } \ No newline at end of file diff --git a/buildScripts/electron-builder-mac.json b/buildScripts/electron-builder-mac.json index 7eb052f9..498106d2 100644 --- a/buildScripts/electron-builder-mac.json +++ b/buildScripts/electron-builder-mac.json @@ -31,5 +31,13 @@ }, "dmg": { "sign": true - } + }, + "protocols": [ + { + "name": "Power Platform ToolBox Protocol", + "schemes": [ + "pptb" + ] + } + ] } \ No newline at end of file diff --git a/buildScripts/electron-builder-win-arm64.json b/buildScripts/electron-builder-win-arm64.json index 937c9207..b314927e 100644 --- a/buildScripts/electron-builder-win-arm64.json +++ b/buildScripts/electron-builder-win-arm64.json @@ -29,5 +29,13 @@ "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, "createStartMenuShortcut": true - } + }, + "protocols": [ + { + "name": "Power Platform ToolBox Protocol", + "schemes": [ + "pptb" + ] + } + ] } \ No newline at end of file diff --git a/buildScripts/electron-builder-win.json b/buildScripts/electron-builder-win.json index 4ad4ea57..6a6c519d 100644 --- a/buildScripts/electron-builder-win.json +++ b/buildScripts/electron-builder-win.json @@ -35,5 +35,13 @@ "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, "createStartMenuShortcut": true - } + }, + "protocols": [ + { + "name": "Power Platform ToolBox Protocol", + "schemes": [ + "pptb" + ] + } + ] } \ No newline at end of file diff --git a/docs/PROTOCOL_HANDLER.md b/docs/PROTOCOL_HANDLER.md new file mode 100644 index 00000000..8602868d --- /dev/null +++ b/docs/PROTOCOL_HANDLER.md @@ -0,0 +1,414 @@ +# Custom Protocol Handler Implementation - `pptb://` + +## Overview + +This document describes the implementation of the `pptb://` custom protocol handler for the Power Platform ToolBox (PPTB) desktop application. This feature enables deep linking from external sources (such as a web-based tool catalog) to trigger tool installations in the desktop app. + +## Architecture + +The implementation follows VS Code's extension architecture pattern with security-first design: + +### Key Components + +1. **ProtocolHandlerManager** (`src/main/managers/protocolHandlerManager.ts`) + - Manages protocol registration and URL parsing + - Implements security validations and rate limiting + - Handles single-instance application locking +2. **IPC Communication** (`src/common/ipc/channels.ts`) + - New event channel: `PROTOCOL_INSTALL_TOOL_REQUEST` + - Enables main → renderer communication for protocol events + +3. **UI Handler** (`src/renderer/modules/marketplaceManagement.ts`) + - `handleProtocolInstallToolRequest()` function + - Shows tool detail modal for user confirmation + - Integrates with existing tool installation flow + +4. **Protocol Registration** (electron-builder configs) + - Windows: `buildScripts/electron-builder-win.json` + - macOS: `buildScripts/electron-builder-mac.json` + - Linux: `buildScripts/electron-builder-linux.json` + +## URL Format + +``` +pptb://install?toolId={toolId}&toolName={toolName} +``` + +### Parameters + +- **`toolId`** (required): Unique identifier of the tool + - Must be alphanumeric with hyphens/underscores only + - Maximum length: 100 characters + - Validation regex: `/^[a-zA-Z0-9_-]+$/` + +- **`toolName`** (optional): Human-readable name of the tool + - URL-encoded automatically (spaces as `%20`, etc.) + - Maximum length: 200 characters + - Used for display purposes only + +### Example URLs + +``` +pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer +pptb://install?toolId=pcf-builder&toolName=PCF%20Component%20Builder +pptb://install?toolId=solution-viewer +``` + +## Security Features + +### 1. URL Validation + +- ✅ Whitelisted actions (only "install" allowed) +- ✅ Strict toolId format validation +- ✅ Length limits on all parameters +- ✅ URL decoding with error handling + +### 2. Rate Limiting + +- **Window**: 5 seconds +- **Max Requests**: 3 per window +- Prevents protocol spam/DOS attacks + +### 3. Input Sanitization + +```typescript +// Only alphanumeric, hyphens, and underscores allowed +const TOOL_ID_REGEX = /^[a-zA-Z0-9_-]+$/; + +// Malicious examples that are BLOCKED: +pptb://install?toolId=../../etc/passwd // ❌ Blocked +pptb://install?toolId= // ❌ Blocked +pptb://install?toolId='; DROP TABLE tools; -- // ❌ Blocked +``` + +### 4. User Confirmation Flow + +1. Protocol URL detected +2. App brought to foreground +3. Tool detail modal shown +4. User must explicitly click "Install" +5. No automatic installation + +### 5. Single Instance Lock + +- Ensures only one app instance runs +- Second instance passes URL to first instance +- Prevents race conditions + +## Platform-Specific Behavior + +### macOS + +- Handled via `app.on('open-url')` event +- Protocol registration in `.plist` file (handled by electron-builder) +- Works when app is not running or already running + +### Windows + +- Registered via Windows Registry during installation +- Handled via `app.on('second-instance')` or command-line args +- Protocol URL passed in command-line arguments + +### Linux + +- Registered in `.desktop` file (AppImage) +- Handled similarly to Windows via command-line args +- May require desktop environment restart to register + +## Implementation Flow + +``` +┌─────────────────┐ +│ Web App/Link │ +│ clicks: │ +│ pptb://install │ +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ OS Protocol │ ◄──── Registered during installation +│ Handler │ (Windows Registry / macOS .plist / Linux .desktop) +└────────┬────────┘ + │ + ▼ +┌─────────────────────────────────────────────────┐ +│ PPTB App (Main Process) │ +│ ProtocolHandlerManager │ +│ ┌─────────────────────────────────────────────┐ │ +│ │ 1. Check single instance lock │ │ +│ │ 2. Parse & validate URL │ │ +│ │ 3. Rate limit check │ │ +│ │ 4. Sanitize toolId │ │ +│ │ 5. Send IPC event to renderer │ │ +│ └─────────────────────────────────────────────┘ │ +└────────┬────────────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────┐ +│ Renderer Process │ +│ marketplaceManagement.ts │ +│ ┌─────────────────────────────────────────────┐ │ +│ │ 1. Fetch tool library │ │ +│ │ 2. Find tool by toolId │ │ +│ │ 3. Check if already installed │ │ +│ │ 4. Show tool detail modal │ │ +│ │ 5. User clicks "Install" │ │ +│ │ 6. Install via installToolFromRegistry() │ │ +│ └─────────────────────────────────────────────┘ │ +└─────────────────────────────────────────────────┘ +``` + +## Testing Instructions + +### Prerequisites + +```bash +pnpm install +pnpm run build +pnpm run package # To create installer +``` + +### Manual Testing + +#### macOS + +```bash +# Test with app running +open "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" + +# Test with app not running +killall "Power Platform ToolBox" +open "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" +``` + +#### Windows (PowerShell) + +```powershell +# Test with app running +Start-Process "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" + +# Test with app not running +taskkill /IM "Power Platform ToolBox.exe" /F +Start-Process "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" +``` + +#### Linux + +```bash +# Test with app running +xdg-open "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" + +# Test with app not running +pkill -f "Power Platform ToolBox" +xdg-open "pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer" +``` + +### Test Cases + +1. **Valid Tool ID** + + ``` + pptb://install?toolId=valid-tool-123&toolName=Test%20Tool + ✅ Should open tool detail modal + ``` + +2. **Invalid Tool ID (Special Characters)** + + ``` + pptb://install?toolId=../../../etc/passwd + ❌ Should be blocked, show error + ``` + +3. **Missing Tool ID** + + ``` + pptb://install?toolName=Test%20Tool + ❌ Should be blocked, show error + ``` + +4. **Non-existent Tool** + + ``` + pptb://install?toolId=nonexistent-tool-xyz + ⚠️ Should show "Tool Not Found" notification + ``` + +5. **Already Installed Tool** + + ``` + pptb://install?toolId=already-installed-tool + ℹ️ Should show "Already Installed" notification + ``` + +6. **Rate Limiting** + + ```bash + # Click protocol link 4 times rapidly + ⚠️ 4th request should be blocked + ``` + +7. **URL Encoding** + ``` + pptb://install?toolId=test-tool&toolName=Test%20Tool%20With%20Spaces + ✅ Should decode correctly + ``` + +### Debugging + +Enable verbose logging by checking Sentry logs: + +```typescript +// In development, check console for: +[ProtocolHandler] Received open-url event: pptb://install?... +[ProtocolHandler] Handling protocol URL: pptb://install?... +[Protocol] Handling install request for tool: {toolId} +``` + +### Integration with Web App + +Example HTML: + +```html + Install in Desktop App +``` + +Example JavaScript: + +```javascript +function installInDesktop(toolId, toolName) { + const url = `pptb://install?toolId=${encodeURIComponent(toolId)}&toolName=${encodeURIComponent(toolName)}`; + window.location.href = url; +} + +// Usage +installInDesktop("dataverse-explorer", "Dataverse Explorer"); +``` + +## Error Handling + +### Graceful Degradation + +1. **Tool Not Found**: Shows notification, doesn't crash +2. **Invalid URL**: Logged to Sentry, silently ignored +3. **Rate Limited**: Logged to Sentry, request dropped +4. **Installation Failure**: Shows error notification with details + +### Monitoring + +All protocol events are logged to Sentry with appropriate tags: + +- `manager: ProtocolHandler` +- `phase: parse_url|handle_callback|protocol_install` +- `trigger: open-url|second-instance|startup` + +## Best Practices & Recommendations + +### For Web Developers + +1. **Always URL-encode parameters**: + + ```javascript + const toolName = "My Tool 2.0 (Beta)"; + const encoded = encodeURIComponent(toolName); + // Result: "My%20Tool%202.0%20%28Beta%29" + ``` + +2. **Provide fallback for browsers without handler**: + + ```javascript + function installTool(toolId, toolName) { + const protocolUrl = `pptb://install?toolId=${toolId}&toolName=${encodeURIComponent(toolName)}`; + + // Try protocol first + window.location.href = protocolUrl; + + // Fallback after 2 seconds if app not installed + setTimeout(() => { + if (confirm("Desktop app not installed. Download now?")) { + window.location.href = "https://github.com/PowerPlatformToolBox/desktop-app/releases"; + } + }, 2000); + } + ``` + +3. **Validate toolId before generating link**: + + ```javascript + const TOOL_ID_REGEX = /^[a-zA-Z0-9_-]+$/; + + if (!TOOL_ID_REGEX.test(toolId)) { + console.error("Invalid toolId format"); + return; + } + ``` + +### For Desktop App Maintainers + +1. **Never auto-install**: Always show confirmation dialog +2. **Log all protocol events**: Essential for debugging +3. **Update rate limits**: If needed based on usage patterns +4. **Monitor Sentry**: Check for blocked malicious attempts + +## Future Enhancements + +### Potential Features + +1. **Multi-action support**: + - `pptb://uninstall?toolId={toolId}` + - `pptb://launch?toolId={toolId}&connectionId={connectionId}` + - `pptb://update?toolId={toolId}` + +2. **Deep linking parameters**: + - `pptb://install?toolId={toolId}&autoStart=true` + - `pptb://install?toolId={toolId}&category={category}` + +3. **Analytics tracking**: + - Track protocol install vs manual install + - Monitor success/failure rates + - A/B test different web flows + +4. **Enhanced security**: + - Token-based authentication + - Time-limited install URLs + - Signed URLs from trusted sources + +## Troubleshooting + +### Protocol Not Registered + +**Symptoms**: Clicking link does nothing or opens browser + +**Solutions**: + +- **Windows**: Reinstall app (protocol registered during install) +- **macOS**: App must be moved to `/Applications` folder +- **Linux**: Run `update-desktop-database` after install + +### App Not Launching + +**Symptoms**: Error message "No application found" + +**Solutions**: + +1. Verify app is installed correctly +2. Check protocol registration: + - **Windows**: Check `HKEY_CLASSES_ROOT\pptb` in Registry + - **macOS**: Check `/Applications/Power Platform ToolBox.app/Contents/Info.plist` + - **Linux**: Check `~/.local/share/applications/*.desktop` + +### Rate Limiting Issues + +**Symptoms**: Protocol clicks not working after multiple attempts + +**Solutions**: + +- Wait 5 seconds between requests +- Restart app to reset rate limiter +- Check Sentry logs for rate limit warnings + +## References + +- [Electron Custom Protocol API](https://www.electronjs.org/docs/latest/api/protocol) +- [Electron App setAsDefaultProtocolClient](https://www.electronjs.org/docs/latest/api/app#appsetasdefaultprotocolclientprotocol-path-args) +- [VS Code URI Handlers](https://code.visualstudio.com/api/references/vscode-api#Uri) +- [Deep Linking Best Practices](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index aca34f05..6871570a 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -190,6 +190,11 @@ export const DATAVERSE_CHANNELS = { GET_CSDL_DOCUMENT: "dataverse.getCSDLDocument", } as const; +// Protocol handler-related IPC channels +export const PROTOCOL_CHANNELS = { + PROTOCOL_INSTALL_TOOL: "protocol:install-tool", +} as const; + // Event-related IPC channels (from main to renderer) export const EVENT_CHANNELS = { TOOLBOX_EVENT: "toolbox-event", @@ -211,6 +216,7 @@ export const EVENT_CHANNELS = { MODAL_WINDOW_MESSAGE: "modal-window:message", TOOL_UPDATE_STARTED: "tool:update-started", TOOL_UPDATE_COMPLETED: "tool:update-completed", + PROTOCOL_INSTALL_TOOL_REQUEST: "protocol:install-tool-request", } as const; // Internal BrowserWindow modal channels (modal content -> main process) diff --git a/src/common/types/api.ts b/src/common/types/api.ts index 1b34f608..9d5b9dba 100644 --- a/src/common/types/api.ts +++ b/src/common/types/api.ts @@ -230,6 +230,9 @@ export interface ToolboxAPI { onToolUpdateStarted: (callback: (toolId: string) => void) => void; onToolUpdateCompleted: (callback: (toolId: string) => void) => void; + // Protocol deep link events + onProtocolInstallToolRequest: (callback: (params: { toolId: string; toolName: string }) => void) => void; + // Dataverse namespace dataverse: DataverseAPI; } diff --git a/src/main/index.ts b/src/main/index.ts index 64972c61..e7eaef1c 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -94,6 +94,7 @@ import { InstallIdManager } from "./managers/installIdManager"; import { LoadingOverlayWindowManager } from "./managers/loadingOverlayWindowManager"; import { ModalWindowManager } from "./managers/modalWindowManager"; import { NotificationWindowManager } from "./managers/notificationWindowManager"; +import { ProtocolHandlerManager } from "./managers/protocolHandlerManager"; import { SettingsManager } from "./managers/settingsManager"; import { TerminalManager } from "./managers/terminalManager"; import { ToolBoxUtilityManager } from "./managers/toolboxUtilityManager"; @@ -112,6 +113,7 @@ class ToolBoxApp { private connectionsManager: ConnectionsManager; private toolManager: ToolManager; private browserviewProtocolManager: BrowserviewProtocolManager; + private protocolHandlerManager: ProtocolHandlerManager; private toolWindowManager: ToolWindowManager | null = null; private notificationWindowManager: NotificationWindowManager | null = null; private loadingOverlayWindowManager: LoadingOverlayWindowManager | null = null; @@ -152,6 +154,7 @@ class ToolBoxApp { process.env.AZURE_BLOB_BASE_URL, ); this.browserviewProtocolManager = new BrowserviewProtocolManager(this.toolManager, this.settingsManager); + this.protocolHandlerManager = new ProtocolHandlerManager(); this.autoUpdateManager = new AutoUpdateManager(); this.browserManager = new BrowserManager(); this.authManager = new AuthManager(this.browserManager); @@ -2876,6 +2879,15 @@ class ToolBoxApp { this.browserviewProtocolManager.registerScheme(); addBreadcrumb("Registered custom protocol scheme", "init", "info"); + // Register deep link protocol handler (pptb://) + this.protocolHandlerManager.registerScheme(); + addBreadcrumb("Registered pptb:// protocol scheme", "init", "info"); + + // Initialize early protocol listeners (single-instance lock, open-url, second-instance) + // MUST be called before app.whenReady() so no deep link is missed. + this.protocolHandlerManager.initialize(); + addBreadcrumb("Protocol handler early listeners registered", "init", "info"); + await app.whenReady(); logCheckpoint("Electron app ready"); @@ -2886,6 +2898,43 @@ class ToolBoxApp { this.createWindow(); logCheckpoint("Main window created"); + // Set up deep link protocol handler callback after the main window exists. + // The callback defers IPC delivery until the renderer has finished loading so + // that protocol URLs captured during startup (buffered in pendingUrls) are + // reliably delivered even on a cold launch via pptb://. + this.protocolHandlerManager.setupProtocolHandler(async (action, params) => { + logInfo(`[ProtocolHandler] Received ${action} request for tool: ${params.toolId}`); + + // Bring app window to focus + if (this.mainWindow) { + if (this.mainWindow.isMinimized()) { + this.mainWindow.restore(); + } + this.mainWindow.focus(); + } + + // Deliver the IPC event to the renderer. If the renderer is still + // loading (e.g. cold launch via protocol URL), defer until it finishes. + if (this.mainWindow) { + const webContents = this.mainWindow.webContents; + const deliver = (): void => { + if (!webContents.isDestroyed()) { + webContents.send(EVENT_CHANNELS.PROTOCOL_INSTALL_TOOL_REQUEST, { + toolId: params.toolId, + toolName: params.toolName, + }); + } + }; + + if (webContents.isLoading()) { + webContents.once("did-finish-load", deliver); + } else { + deliver(); + } + } + }); + addBreadcrumb("Protocol handler callback registered", "init", "info"); + // Load all installed tools from registry try { await this.toolManager.loadAllInstalledTools(); diff --git a/src/main/managers/protocolHandlerManager.ts b/src/main/managers/protocolHandlerManager.ts new file mode 100644 index 00000000..343f6fca --- /dev/null +++ b/src/main/managers/protocolHandlerManager.ts @@ -0,0 +1,341 @@ +import { app } from "electron"; +import { captureException, captureMessage, logInfo } from "../../common/sentryHelper"; + +/** + * Protocol URL structure for tool installation + */ +interface ToolInstallProtocolParams { + toolId: string; + toolName: string; +} + +/** + * Protocol handler action types + */ +export type ProtocolAction = "install"; + +/** + * Protocol handler callback function + */ +type ProtocolHandlerCallback = (action: ProtocolAction, params: ToolInstallProtocolParams) => Promise; + +/** + * ProtocolHandlerManager + * Manages the custom pptb:// protocol for deep linking from web apps + * + * **Security Features**: + * - Validates protocol action (only "install" allowed) + * - Sanitizes and validates toolId (alphanumeric, hyphens, underscores only) + * - Decodes URL-encoded parameters + * - Rate limiting to prevent protocol spam/DOS + * - Blocks malformed or suspicious URLs + * + * **URL Format**: pptb://install?toolId={toolId}&toolName={toolName} + * + * Example: + * pptb://install?toolId=dataverse-explorer&toolName=Dataverse%20Explorer + */ +export class ProtocolHandlerManager { + private static readonly PROTOCOL_SCHEME = "pptb"; + private static readonly ALLOWED_ACTIONS: ProtocolAction[] = ["install"]; + private static readonly TOOL_ID_REGEX = /^[a-zA-Z0-9_-]+$/; + private static readonly MAX_TOOL_ID_LENGTH = 100; + private static readonly MAX_TOOL_NAME_LENGTH = 200; + private static readonly RATE_LIMIT_WINDOW_MS = 5000; // 5 seconds + private static readonly MAX_REQUESTS_PER_WINDOW = 3; + + private protocolCallback: ProtocolHandlerCallback | null = null; + private recentProtocolRequests: number[] = []; + private pendingUrls: string[] = []; + + constructor() { + logInfo("[ProtocolHandler] Initializing protocol handler manager"); + } + + /** + * Register the protocol as a standard protocol scheme + * Must be called BEFORE app.whenReady() + */ + registerScheme(): void { + try { + if (app.isReady()) { + captureMessage("[ProtocolHandler] Warning: registerScheme called after app is ready. This may not work correctly.", "warning"); + } + + // Register the scheme as standard to allow query parameters + app.setAsDefaultProtocolClient(ProtocolHandlerManager.PROTOCOL_SCHEME); + + logInfo(`[ProtocolHandler] Registered ${ProtocolHandlerManager.PROTOCOL_SCHEME}:// as default protocol client`); + } catch (error) { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { manager: "ProtocolHandler", phase: "register_scheme" }, + level: "error", + }); + } + } + + /** + * Initialize early protocol listeners - must be called BEFORE app.whenReady(). + * Acquires the single-instance lock, registers the open-url and second-instance + * event handlers, and buffers any startup protocol URL from process.argv so that + * no deep link is lost before the main window exists. + */ + initialize(): void { + // Acquire the single-instance lock as early as possible so a second launch + // forwards its command line to the first instance and then quits. + const gotTheLock = app.requestSingleInstanceLock(); + if (!gotTheLock) { + logInfo("[ProtocolHandler] Another instance is already running, quitting this instance"); + app.quit(); + return; + } + + // macOS: open-url is emitted before (or around) app.whenReady() – must be + // registered here so we never miss a launch-via-protocol event. + app.on("open-url", (event, url) => { + event.preventDefault(); + logInfo(`[ProtocolHandler] Received open-url event: ${url}`); + this.bufferOrHandle(url, "open-url"); + }); + + // Windows/Linux: a second instance forwards its command line here. + app.on("second-instance", (_event, commandLine) => { + logInfo("[ProtocolHandler] Second instance detected, processing command line"); + const url = commandLine.find((arg) => arg.startsWith(`${ProtocolHandlerManager.PROTOCOL_SCHEME}://`)); + if (url) { + logInfo(`[ProtocolHandler] Processing protocol URL from second instance: ${url}`); + this.bufferOrHandle(url, "second-instance"); + } + }); + + // Windows/Linux first launch via protocol URL: the URL is in process.argv. + if (process.platform === "win32" || process.platform === "linux") { + const protocolUrl = process.argv.find((arg) => arg.startsWith(`${ProtocolHandlerManager.PROTOCOL_SCHEME}://`)); + if (protocolUrl) { + logInfo(`[ProtocolHandler] Buffering protocol URL from startup args: ${protocolUrl}`); + this.pendingUrls.push(protocolUrl); + } + } + + logInfo("[ProtocolHandler] Early protocol listeners registered"); + } + + /** + * Register the protocol handler callback and flush any URLs that were buffered + * before the callback was available. Must be called AFTER the main window has + * been created so that the callback can safely deliver IPC to the renderer. + */ + setupProtocolHandler(callback: ProtocolHandlerCallback): void { + this.protocolCallback = callback; + + // Process any URLs received before the callback was registered. + const buffered = this.pendingUrls.splice(0); + for (const url of buffered) { + logInfo(`[ProtocolHandler] Processing buffered protocol URL: ${url}`); + this.handleProtocolUrl(url).catch((error) => { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { manager: "ProtocolHandler", trigger: "buffered" }, + }); + }); + } + + logInfo("[ProtocolHandler] Protocol handler callback registered"); + } + + /** + * Buffer the URL for later processing, or handle it immediately if the + * callback has already been registered. + */ + private bufferOrHandle(url: string, trigger: string): void { + if (this.protocolCallback) { + this.handleProtocolUrl(url).catch((error) => { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { manager: "ProtocolHandler", trigger }, + }); + }); + } else { + this.pendingUrls.push(url); + } + } + + /** + * Parse and validate protocol URL + * Format: pptb://install?toolId={toolId}&toolName={toolName} + */ + private parseProtocolUrl(urlString: string): { action: ProtocolAction; params: ToolInstallProtocolParams } | null { + try { + // Validate protocol scheme + if (!urlString.startsWith(`${ProtocolHandlerManager.PROTOCOL_SCHEME}://`)) { + captureMessage(`[ProtocolHandler] Invalid protocol scheme: ${urlString}`, "warning"); + return null; + } + + const url = new URL(urlString); + + // Validate action (host part of URL) + const action = url.hostname.toLowerCase(); + if (!ProtocolHandlerManager.ALLOWED_ACTIONS.includes(action as ProtocolAction)) { + captureMessage(`[ProtocolHandler] Invalid action: ${action}`, "warning", { + extra: { allowed: ProtocolHandlerManager.ALLOWED_ACTIONS }, + }); + return null; + } + + // Extract and decode parameters + const toolId = url.searchParams.get("toolId"); + const toolName = url.searchParams.get("toolName"); + + // Validate required parameters + if (!toolId) { + captureMessage("[ProtocolHandler] Missing required parameter: toolId", "warning"); + return null; + } + + // Sanitize and validate toolId + const sanitizedToolId = this.sanitizeToolId(toolId); + if (!sanitizedToolId) { + captureMessage(`[ProtocolHandler] Invalid toolId format: ${toolId}`, "warning"); + return null; + } + + // Sanitize toolName (optional, will be fetched from registry if missing) + const sanitizedToolName = toolName ? this.sanitizeToolName(toolName) : sanitizedToolId; + + return { + action: action as ProtocolAction, + params: { + toolId: sanitizedToolId, + toolName: sanitizedToolName, + }, + }; + } catch (error) { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { manager: "ProtocolHandler", phase: "parse_url" }, + extra: { url: urlString }, + }); + return null; + } + } + + /** + * Sanitize and validate toolId + * Only allows alphanumeric characters, hyphens, and underscores + */ + private sanitizeToolId(toolId: string): string | null { + if (!toolId || typeof toolId !== "string") { + return null; + } + + const trimmed = toolId.trim(); + + // Check length + if (trimmed.length === 0 || trimmed.length > ProtocolHandlerManager.MAX_TOOL_ID_LENGTH) { + return null; + } + + // Validate against regex (only alphanumeric, hyphens, underscores) + if (!ProtocolHandlerManager.TOOL_ID_REGEX.test(trimmed)) { + return null; + } + + return trimmed; + } + + /** + * Sanitize and validate toolName (expects an already-decoded value) + */ + private sanitizeToolName(toolName: string): string { + if (!toolName || typeof toolName !== "string") { + return ""; + } + + // Trim and limit length before escaping + const trimmed = toolName.trim().substring(0, ProtocolHandlerManager.MAX_TOOL_NAME_LENGTH); + + // HTML-encode special characters to prevent HTML/JS injection when rendered in notification HTML + const escaped = trimmed.replace(/[&<>"']/g, (char) => { + switch (char) { + case "&": + return "&"; + case "<": + return "<"; + case ">": + return ">"; + case "\"": + return """; + case "'": + return "'"; + default: + return char; + } + }); + + return escaped; + } + + /** + * Rate limiting check to prevent protocol spam/DOS + */ + private checkRateLimit(): boolean { + const now = Date.now(); + + // Remove old requests outside the window + this.recentProtocolRequests = this.recentProtocolRequests.filter((timestamp) => now - timestamp < ProtocolHandlerManager.RATE_LIMIT_WINDOW_MS); + + // Check if rate limit exceeded + if (this.recentProtocolRequests.length >= ProtocolHandlerManager.MAX_REQUESTS_PER_WINDOW) { + captureMessage("[ProtocolHandler] Rate limit exceeded", "warning", { + extra: { + requestCount: this.recentProtocolRequests.length, + window: ProtocolHandlerManager.RATE_LIMIT_WINDOW_MS, + }, + }); + return false; + } + + // Add current request + this.recentProtocolRequests.push(now); + return true; + } + + /** + * Handle protocol URL and invoke callback + */ + private async handleProtocolUrl(urlString: string): Promise { + logInfo(`[ProtocolHandler] Handling protocol URL: ${urlString}`); + + // Check rate limit + if (!this.checkRateLimit()) { + captureMessage("[ProtocolHandler] Protocol request blocked due to rate limiting", "warning"); + return; + } + + // Parse and validate URL + const parsed = this.parseProtocolUrl(urlString); + if (!parsed) { + captureMessage("[ProtocolHandler] Failed to parse or validate protocol URL", "warning", { + extra: { url: urlString }, + }); + return; + } + + // Invoke callback if registered + if (!this.protocolCallback) { + captureMessage("[ProtocolHandler] No protocol callback registered", "warning"); + return; + } + + try { + await this.protocolCallback(parsed.action, parsed.params); + logInfo(`[ProtocolHandler] Protocol action completed: ${parsed.action} for tool ${parsed.params.toolId}`); + } catch (error) { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { manager: "ProtocolHandler", phase: "handle_callback" }, + extra: { + action: parsed.action, + toolId: parsed.params.toolId, + }, + }); + } + } +} diff --git a/src/main/preload.ts b/src/main/preload.ts index a1af3afd..2a347a02 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -229,6 +229,11 @@ contextBridge.exposeInMainWorld("toolboxAPI", { ipcRenderer.on(EVENT_CHANNELS.TOOL_UPDATE_COMPLETED, (_, toolId) => callback(toolId)); }, + // Protocol deep link events + onProtocolInstallToolRequest: (callback: (params: { toolId: string; toolName: string }) => void) => { + ipcRenderer.on(EVENT_CHANNELS.PROTOCOL_INSTALL_TOOL_REQUEST, (_, params) => callback(params)); + }, + // Dataverse API - Can be called by tools via message routing dataverse: { create: (entityLogicalName: string, record: Record, connectionTarget?: "primary" | "secondary") => diff --git a/src/renderer/modules/initialization.ts b/src/renderer/modules/initialization.ts index 30fb3dfa..d95d2f03 100644 --- a/src/renderer/modules/initialization.ts +++ b/src/renderer/modules/initialization.ts @@ -71,7 +71,7 @@ import { initializeBrowserWindowModals } from "./browserWindowModals"; import { handleReauthentication, initializeAddConnectionModalBridge, loadSidebarConnections, openAddConnectionModal, updateFooterConnection } from "./connectionManagement"; import { initializeGlobalSearch } from "./globalSearchManagement"; import { loadHomepageData, setupHomepageActions } from "./homepageManagement"; -import { loadMarketplace, loadToolsLibrary } from "./marketplaceManagement"; +import { handleProtocolInstallToolRequest, loadMarketplace, loadToolsLibrary } from "./marketplaceManagement"; import { closeModal, openModal } from "./modalManagement"; import { showPPTBNotification } from "./notifications"; import { saveSidebarSettings } from "./settingsManagement"; @@ -683,6 +683,16 @@ function setupApplicationEventListeners(): void { }); }); }); + + // Protocol deep link handler + window.toolboxAPI.onProtocolInstallToolRequest((params: { toolId: string; toolName: string }) => { + handleProtocolInstallToolRequest(params).catch((error) => { + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { phase: "protocol_install" }, + extra: { toolId: params.toolId, toolName: params.toolName }, + }); + }); + }); } /** diff --git a/src/renderer/modules/marketplaceManagement.ts b/src/renderer/modules/marketplaceManagement.ts index a48187ae..6274d3c6 100644 --- a/src/renderer/modules/marketplaceManagement.ts +++ b/src/renderer/modules/marketplaceManagement.ts @@ -3,7 +3,7 @@ * Handles tool library, marketplace UI, and tool installation */ -import { captureMessage, logInfo } from "../../common/sentryHelper"; +import { captureException, captureMessage, logInfo } from "../../common/sentryHelper"; import type { ModalWindowClosedPayload, ModalWindowMessagePayload, Tool } from "../../common/types"; import { getToolDetailModalControllerScript } from "../modals/toolDetail/controller"; import { getToolDetailModalView } from "../modals/toolDetail/view"; @@ -698,3 +698,80 @@ function clearMarketplaceFilters(): void { // Reload the marketplace to reflect the cleared filters loadMarketplace(); } + +/** + * Handle protocol deep link install request + * Called when user clicks pptb://install?toolId={toolId}&toolName={toolName} + * + * @param params - Protocol parameters containing toolId and toolName + */ +export async function handleProtocolInstallToolRequest(params: { toolId: string; toolName: string }): Promise { + logInfo(`[Protocol] Handling install request for tool: ${params.toolId}`); + + try { + // First, fetch tool library to get full tool details + await loadToolsLibrary(); + + // Find the tool in the library + const tool = toolLibrary.find((t) => t.id === params.toolId); + + if (!tool) { + captureMessage(`[Protocol] Tool not found in registry: ${params.toolId}`, "warning", { + extra: { toolId: params.toolId, toolName: params.toolName }, + }); + + window.toolboxAPI.utils.showNotification({ + title: "Tool Not Found", + body: `The tool "${params.toolName}" (${params.toolId}) could not be found in the registry.`, + type: "error", + }); + + return; + } + + // Check if already installed + const installedTools = await window.toolboxAPI.getAllTools(); + const isInstalled = installedTools.some((t) => t.id === params.toolId); + + if (isInstalled) { + logInfo(`[Protocol] Tool ${params.toolId} is already installed`); + + window.toolboxAPI.utils.showNotification({ + title: "Already Installed", + body: `${tool.name} is already installed.`, + type: "info", + }); + + // Switch to marketplace view to show the tool + const marketplaceBtn = document.getElementById("marketplace-btn"); + if (marketplaceBtn) { + marketplaceBtn.click(); + } + + return; + } + + // Show tool detail modal with install option + logInfo(`[Protocol] Opening tool detail modal for ${params.toolId}`); + await openToolDetail(tool, isInstalled); + + // Show notification to guide user + window.toolboxAPI.utils.showNotification({ + title: "Tool Installation", + body: `Click "Install" to add ${tool.name} to your toolbox.`, + type: "info", + }); + } catch (error) { + const errorMessage = formatError(error); + captureException(error instanceof Error ? error : new Error(String(error)), { + tags: { phase: "protocol_install" }, + extra: { toolId: params.toolId, toolName: params.toolName }, + }); + + window.toolboxAPI.utils.showNotification({ + title: "Installation Failed", + body: `Failed to process installation request: ${errorMessage}`, + type: "error", + }); + } +} From 744b6d5cde3787655442c0eab51d2922b163566d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 12:59:38 -0500 Subject: [PATCH 039/178] feat: Show tool details as a tab instead of a modal dialog (#421) * Initial plan * feat: show tool details as a tab instead of a modal dialog - Add HIDE_ALL IPC channel to hide all BrowserViews when showing detail tabs - Add hideToolWindows() IPC handler in ToolWindowManager and expose via preload - Add isDetailTab flag to OpenTool type for distinguishing detail tabs - Add #tool-detail-content-panel div to index.html for inline content rendering - Add openToolDetailTab() function in toolManagement.ts with full tab lifecycle - Modify switchToTool() to handle detail tabs (hide BrowserViews, show panel) - Modify closeTool() to handle detail tabs (no BrowserView to close) - Modify saveSession() to exclude detail tabs from persistence - Replace modal-based openToolDetail() in marketplaceManagement.ts with tab approach - Add renderToolDetailContent() that renders tool details directly in the renderer - Open all links (review, repo, website, README links) via toolboxAPI.openExternal - Add CSS styles for tool-detail-content-panel in styles.scss - Add visual indicator for active tool detail tabs Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * fix: improve type safety for marked library loader and add XSS comment Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * fix: tool detail tab full-width, ' - Details' label, and README loading - Hide tool-panel-content when detail tab is active so the detail panel gets the full available space (not 50/50 split) - Restore tool-panel-content when switching back to a real tool tab - Tab now shows '{Tool Name} - Details' label as requested - Fix README not loading: replace CDN-loaded marked with bundled dependency (cdn.jsdelivr.net was blocked by CSP script-src) - Add https://*.blob.core.windows.net to connect-src in CSP so README files hosted on Azure Blob can be fetched Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * fix: address PR review security and correctness issues in tool detail tab - XSS: configure marked renderer to escape both block and inline raw HTML (html() handles Tokens.HTML + Tokens.Tag) preventing event handler injection - Race condition: loadToolReadme() now checks data-tab-id on the detail panel after async fetch and on error to discard stale results - Fake toolId: detail tab entries use empty string toolId so connections are never persisted under a synthetic tab ID Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> --- package.json | 1 + pnpm-lock.yaml | 10 + src/common/ipc/channels.ts | 1 + src/common/types/api.ts | 1 + src/main/managers/toolWindowManager.ts | 9 + src/main/preload.ts | 1 + src/renderer/index.html | 4 +- src/renderer/modules/marketplaceManagement.ts | 325 +++++++++--------- src/renderer/modules/toolManagement.ts | 190 +++++++++- src/renderer/styles.scss | 211 ++++++++++++ src/renderer/types/index.ts | 1 + 11 files changed, 565 insertions(+), 189 deletions(-) diff --git a/package.json b/package.json index 07ab0816..26ac4bda 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "ansi-to-html": "^0.7.2", "electron-store": "^8.1.0", "electron-updater": "^6.6.2", + "marked": "17.0.3", "uuid": "^13.0.0" }, "build": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cadaefab..07b5b61b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ importers: electron-updater: specifier: ^6.6.2 version: 6.7.3 + marked: + specifier: 17.0.3 + version: 17.0.3 uuid: specifier: ^13.0.0 version: 13.0.0 @@ -2185,6 +2188,11 @@ packages: resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==} engines: {node: '>=12'} + marked@17.0.3: + resolution: {integrity: sha512-jt1v2ObpyOKR8p4XaUJVk3YWRJ5n+i4+rjQopxvV32rSndTJXvIzuUdWWIy/1pFQMkQmvTXawzDNqOH/CUmx6A==} + engines: {node: '>= 20'} + hasBin: true + matcher@3.0.0: resolution: {integrity: sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==} engines: {node: '>=10'} @@ -5414,6 +5422,8 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 + marked@17.0.3: {} + matcher@3.0.0: dependencies: escape-string-regexp: 4.0.0 diff --git a/src/common/ipc/channels.ts b/src/common/ipc/channels.ts index 6871570a..41ce7ead 100644 --- a/src/common/ipc/channels.ts +++ b/src/common/ipc/channels.ts @@ -83,6 +83,7 @@ export const TOOL_WINDOW_CHANNELS = { GET_ACTIVE: "tool-window:get-active", GET_OPEN_TOOLS: "tool-window:get-open-tools", UPDATE_TOOL_CONNECTION: "tool-window:update-tool-connection", + HIDE_ALL: "tool-window:hide-all", } as const; // Terminal-related IPC channels diff --git a/src/common/types/api.ts b/src/common/types/api.ts index 9d5b9dba..f126ac57 100644 --- a/src/common/types/api.ts +++ b/src/common/types/api.ts @@ -148,6 +148,7 @@ export interface ToolboxAPI { launchToolWindow: (instanceId: string, tool: Tool, primaryConnectionId: string | null, secondaryConnectionId?: string | null) => Promise; switchToolWindow: (toolId: string) => Promise; closeToolWindow: (toolId: string) => Promise; + hideToolWindows: () => Promise; getActiveToolWindow: () => Promise; getOpenToolWindows: () => Promise; updateToolConnection: (instanceId: string, primaryConnectionId: string | null, secondaryConnectionId?: string | null) => Promise; diff --git a/src/main/managers/toolWindowManager.ts b/src/main/managers/toolWindowManager.ts index 6edaa521..17ef8e74 100644 --- a/src/main/managers/toolWindowManager.ts +++ b/src/main/managers/toolWindowManager.ts @@ -121,6 +121,7 @@ export class ToolWindowManager { ipcMain.removeHandler(TOOL_WINDOW_CHANNELS.GET_ACTIVE); ipcMain.removeHandler(TOOL_WINDOW_CHANNELS.GET_OPEN_TOOLS); ipcMain.removeHandler(TOOL_WINDOW_CHANNELS.UPDATE_TOOL_CONNECTION); + ipcMain.removeHandler(TOOL_WINDOW_CHANNELS.HIDE_ALL); } /** @@ -162,6 +163,14 @@ export class ToolWindowManager { return this.updateToolConnection(instanceId, primaryConnectionId, secondaryConnectionId); }); + // Hide all tool windows (used when showing tool detail tabs) + ipcMain.handle(TOOL_WINDOW_CHANNELS.HIDE_ALL, async () => { + this.mainWindow.setBrowserView(null); + this.activeToolId = null; + this.invokeActiveToolChangedCallback(); + return true; + }); + // Restore renderer-provided bounds flow ipcMain.on("get-tool-panel-bounds-response", this.boundsResponseListener); diff --git a/src/main/preload.ts b/src/main/preload.ts index 2a347a02..5cdd5a5c 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -54,6 +54,7 @@ contextBridge.exposeInMainWorld("toolboxAPI", { ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.LAUNCH, instanceId, tool, primaryConnectionId, secondaryConnectionId), switchToolWindow: (instanceId: string) => ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.SWITCH, instanceId), closeToolWindow: (instanceId: string) => ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.CLOSE, instanceId), + hideToolWindows: () => ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.HIDE_ALL), getActiveToolWindow: () => ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.GET_ACTIVE), getOpenToolWindows: () => ipcRenderer.invoke(TOOL_WINDOW_CHANNELS.GET_OPEN_TOOLS), updateToolConnection: (instanceId: string, primaryConnectionId: string | null, secondaryConnectionId?: string | null) => diff --git a/src/renderer/index.html b/src/renderer/index.html index 61183502..d838d527 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -5,7 +5,7 @@ Power Platform ToolBox @@ -413,6 +413,8 @@
    + +
    diff --git a/src/renderer/modules/initialization.ts b/src/renderer/modules/initialization.ts index d95d2f03..bbfb4f2e 100644 --- a/src/renderer/modules/initialization.ts +++ b/src/renderer/modules/initialization.ts @@ -65,7 +65,7 @@ if (sentryConfig) { logInfo("[Sentry] Telemetry disabled - no DSN configured"); } -import { DEFAULT_TERMINAL_FONT, LOADING_SCREEN_FADE_DURATION } from "../constants"; +import { DEFAULT_NOTIFICATION_DURATION, DEFAULT_TERMINAL_FONT, LOADING_SCREEN_FADE_DURATION } from "../constants"; import { handleCheckForUpdates, setupAutoUpdateListeners } from "./autoUpdateManagement"; import { initializeBrowserWindowModals } from "./browserWindowModals"; import { handleReauthentication, initializeAddConnectionModalBridge, loadSidebarConnections, openAddConnectionModal, updateFooterConnection } from "./connectionManagement"; @@ -73,7 +73,7 @@ import { initializeGlobalSearch } from "./globalSearchManagement"; import { loadHomepageData, setupHomepageActions } from "./homepageManagement"; import { handleProtocolInstallToolRequest, loadMarketplace, loadToolsLibrary } from "./marketplaceManagement"; import { closeModal, openModal } from "./modalManagement"; -import { showPPTBNotification } from "./notifications"; +import { showPPTBNotification, setDefaultNotificationDuration } from "./notifications"; import { saveSidebarSettings } from "./settingsManagement"; import { switchSidebar } from "./sidebarManagement"; import { handleTerminalClosed, handleTerminalCommandCompleted, handleTerminalCreated, handleTerminalError, handleTerminalOutput, setupTerminalPanel } from "./terminalManagement"; @@ -703,6 +703,7 @@ async function loadInitialSettings(): Promise { applyTheme(settings.theme); applyTerminalFont(settings.terminalFont || DEFAULT_TERMINAL_FONT); applyDebugMenuVisibility(settings.showDebugMenu ?? false); + setDefaultNotificationDuration(settings.notificationDuration ?? DEFAULT_NOTIFICATION_DURATION); } /** @@ -808,7 +809,7 @@ function setupToolboxEventListeners(): void { title: notificationData.title, body: notificationData.body, type: notificationData.type || "info", - duration: notificationData.duration || 5000, + duration: notificationData.duration, }); } diff --git a/src/renderer/modules/notifications.ts b/src/renderer/modules/notifications.ts index 0b381395..d8fdd7a8 100644 --- a/src/renderer/modules/notifications.ts +++ b/src/renderer/modules/notifications.ts @@ -4,6 +4,7 @@ */ import type { NotificationOptions } from "../types/index"; +import { DEFAULT_NOTIFICATION_DURATION } from "../constants"; // Store callbacks for notification actions with their expiry timestamps interface CallbackEntry { @@ -25,6 +26,16 @@ let cleanupIntervalId: ReturnType | null = null; // Flag to track if the notification action listener is already set up let isNotificationActionListenerSetUp = false; +// Default notification display duration (can be overridden by user settings) +let defaultNotificationDuration: number = DEFAULT_NOTIFICATION_DURATION; + +/** + * Update the default notification duration used when no explicit duration is provided + */ +export function setDefaultNotificationDuration(duration: number): void { + defaultNotificationDuration = duration; +} + /** * Clean up expired callbacks to prevent memory leaks * This runs periodically to remove callbacks whose notifications have been dismissed @@ -97,9 +108,11 @@ export function showPPTBNotification(options: NotificationOptions): void { // Store callbacks for later invocation with TTL for automatic cleanup if (options.actions && actions) { - const duration = options.duration || 5000; - // Callback expires after notification duration plus a buffer to handle edge cases - const expiresAt = Date.now() + duration + CALLBACK_TTL_BUFFER_MS; + const duration = options.duration !== undefined ? options.duration : defaultNotificationDuration; + // For persistent notifications (duration === 0), use a very large TTL so callbacks + // remain available until the user explicitly dismisses the notification. + const effectiveDuration = duration === 0 ? Number.MAX_SAFE_INTEGER - Date.now() : duration; + const expiresAt = Date.now() + effectiveDuration + CALLBACK_TTL_BUFFER_MS; actions.forEach((action: { label: string; callback: string }, index: number) => { const originalCallback = options.actions![index].callback; @@ -118,7 +131,7 @@ export function showPPTBNotification(options: NotificationOptions): void { title: options.title, body: options.body, type: options.type || "info", - duration: options.duration || 5000, + duration: options.duration !== undefined ? options.duration : defaultNotificationDuration, actions, }); } diff --git a/src/renderer/modules/settingsManagement.ts b/src/renderer/modules/settingsManagement.ts index 846918f8..4c036e9b 100644 --- a/src/renderer/modules/settingsManagement.ts +++ b/src/renderer/modules/settingsManagement.ts @@ -3,9 +3,10 @@ * Handles user settings UI and persistence */ -import { DEFAULT_TERMINAL_FONT } from "../constants"; +import { DEFAULT_NOTIFICATION_DURATION, DEFAULT_TERMINAL_FONT } from "../constants"; import type { SettingsState } from "../types/index"; import { loadMarketplace } from "./marketplaceManagement"; +import { setDefaultNotificationDuration } from "./notifications"; import { applyDebugMenuVisibility, applyTerminalFont, applyTheme } from "./themeManagement"; import { loadSidebarTools } from "./toolsSidebarManagement"; @@ -24,6 +25,7 @@ export async function loadSidebarSettings(): Promise { const terminalFontSelect = document.getElementById("sidebar-terminal-font-select") as any; // Fluent UI select element const customFontInput = document.getElementById("sidebar-terminal-font-custom") as HTMLInputElement; const customFontContainer = document.getElementById("custom-font-input-container"); + const notificationDurationSelect = document.getElementById("sidebar-notification-duration-select") as HTMLSelectElement | null; if (themeSelect && autoUpdateCheck && showDebugMenuCheck && deprecatedToolsSelect && toolDisplayModeSelect && terminalFontSelect) { const settings = await window.toolboxAPI.getUserSettings(); @@ -36,6 +38,7 @@ export async function loadSidebarSettings(): Promise { deprecatedToolsVisibility: settings.deprecatedToolsVisibility ?? "hide-all", toolDisplayMode: settings.toolDisplayMode ?? "standard", terminalFont: settings.terminalFont || DEFAULT_TERMINAL_FONT, + notificationDuration: settings.notificationDuration ?? DEFAULT_NOTIFICATION_DURATION, }; themeSelect.value = settings.theme; @@ -44,6 +47,10 @@ export async function loadSidebarSettings(): Promise { deprecatedToolsSelect.value = settings.deprecatedToolsVisibility ?? "hide-all"; toolDisplayModeSelect.value = settings.toolDisplayMode ?? "standard"; + if (notificationDurationSelect) { + notificationDurationSelect.value = String(settings.notificationDuration ?? DEFAULT_NOTIFICATION_DURATION); + } + const terminalFont = settings.terminalFont || DEFAULT_TERMINAL_FONT; // Check if the font is a predefined option @@ -82,6 +89,7 @@ export async function saveSidebarSettings(): Promise { const toolDisplayModeSelect = document.getElementById("sidebar-tool-display-mode-select") as any; // Fluent UI select element const terminalFontSelect = document.getElementById("sidebar-terminal-font-select") as any; // Fluent UI select element const customFontInput = document.getElementById("sidebar-terminal-font-custom") as HTMLInputElement; + const notificationDurationSelect = document.getElementById("sidebar-notification-duration-select") as HTMLSelectElement | null; if (!themeSelect || !autoUpdateCheck || !showDebugMenuCheck || !deprecatedToolsSelect || !toolDisplayModeSelect || !terminalFontSelect) return; @@ -92,6 +100,8 @@ export async function saveSidebarSettings(): Promise { terminalFont = customFontInput.value.trim() || DEFAULT_TERMINAL_FONT; } + const notificationDuration = notificationDurationSelect ? Number(notificationDurationSelect.value) : 5000; + const currentSettings = { theme: themeSelect.value, autoUpdate: autoUpdateCheck.checked, @@ -99,6 +109,7 @@ export async function saveSidebarSettings(): Promise { deprecatedToolsVisibility: deprecatedToolsSelect.value, toolDisplayMode: toolDisplayModeSelect.value, terminalFont: terminalFont, + notificationDuration, }; // Only include changed settings in the update @@ -122,6 +133,9 @@ export async function saveSidebarSettings(): Promise { if (currentSettings.terminalFont !== originalSettings.terminalFont) { changedSettings.terminalFont = currentSettings.terminalFont; } + if (currentSettings.notificationDuration !== originalSettings.notificationDuration) { + changedSettings.notificationDuration = currentSettings.notificationDuration; + } // Only save and emit event if something changed if (Object.keys(changedSettings).length > 0) { @@ -131,6 +145,7 @@ export async function saveSidebarSettings(): Promise { applyTheme(currentSettings.theme); applyTerminalFont(currentSettings.terminalFont); applyDebugMenuVisibility(currentSettings.showDebugMenu); + setDefaultNotificationDuration(currentSettings.notificationDuration); // Reload tools list if deprecated tools visibility changed if (changedSettings.deprecatedToolsVisibility !== undefined) { diff --git a/src/renderer/types/index.ts b/src/renderer/types/index.ts index 3138c37a..0db92ec4 100644 --- a/src/renderer/types/index.ts +++ b/src/renderer/types/index.ts @@ -56,6 +56,7 @@ export interface SettingsState { deprecatedToolsVisibility?: string; toolDisplayMode?: string; terminalFont?: string; + notificationDuration?: number; } /** From 5704309e6a1e0917f06455cb1fe064aa6d1c0f9e Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 11:43:13 -0500 Subject: [PATCH 045/178] Add Category and Environment Color to Dataverse connections (#433) * Initial plan * Add Category and Environment Color to connections with two-column modal layout Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Increase add/edit connection modal width to 920px to match select multi-connection modal Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Add categoryColor support and connection grouping by category - Add categoryColor to DataverseConnection and UIConnectionData types - Add categoryColor to ToolSafeConnection in toolPreloadBridge - Add categoryColor to ConnectionFormPayload and buildConnectionFromPayload - Pass category, environmentColor, categoryColor in populate handlers - Group sidebar connections by category with collapsible headers - Add category filter dropdown to sidebar with dynamic population - Update updateToolPanelBorder to support inline environmentColor/categoryColor - Apply environmentColor as inline border style on tool panel - Apply categoryColor as inline border-bottom on active tool tab - Restructure add/edit connection modals: two-col layout with browser settings and auth fields side by side - Add categoryColor color picker to add/edit connection modals - Show environmentColor and categoryColor badges in select/multi-select modals - Add connection-group CSS for grouped sidebar display - Add category-badge and auth-fields-column CSS to sharedStyles - Add category filter section to connections sidebar in index.html Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix HTML escaping in category group rendering and simplify group toggle - Use escapeHtml() for category names in option values and group data attrs - Use closest() to find sibling group-items instead of CSS.escape querySelector Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add categoryColor, env color to tool border, category grouping/filter in sidebar, restructured modal layout, color in select modals Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Apply environmentColor to footer status elements; fix multi-connection gradient border Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * Address code review: escape HTML, fix color sentinel, keyboard a11y for group headers Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> * feat: update default color values for environment and category in add/edit connection modals --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Power-Maverick --- src/common/types/connection.ts | 7 + src/main/toolPreloadBridge.ts | 6 + src/renderer/index.html | 7 + .../modals/addConnection/controller.ts | 54 +++++ src/renderer/modals/addConnection/view.ts | 188 ++++++++++-------- .../modals/editConnection/controller.ts | 86 ++++++++ src/renderer/modals/editConnection/view.ts | 188 ++++++++++-------- .../modals/selectConnection/controller.ts | 8 +- .../selectMultiConnection/controller.ts | 8 +- src/renderer/modals/sharedStyles.ts | 57 ++++++ src/renderer/modules/connectionManagement.ts | 174 ++++++++++++++-- src/renderer/modules/toolManagement.ts | 118 ++++++++--- src/renderer/styles.scss | 56 ++++++ 13 files changed, 759 insertions(+), 198 deletions(-) diff --git a/src/common/types/connection.ts b/src/common/types/connection.ts index 067f4dbf..776ec322 100644 --- a/src/common/types/connection.ts +++ b/src/common/types/connection.ts @@ -43,6 +43,10 @@ export interface DataverseConnection { browserType?: BrowserType; browserProfile?: string; browserProfileName?: string; + // Grouping and visual customization + category?: string; + environmentColor?: string; + categoryColor?: string; } /** @@ -76,6 +80,9 @@ export interface UIConnectionData { browserType?: BrowserType; browserProfile?: string; browserProfileName?: string; + category?: string; + environmentColor?: string; + categoryColor?: string; } /** diff --git a/src/main/toolPreloadBridge.ts b/src/main/toolPreloadBridge.ts index 2834e952..2dfbfca7 100644 --- a/src/main/toolPreloadBridge.ts +++ b/src/main/toolPreloadBridge.ts @@ -103,6 +103,9 @@ type ToolSafeConnection = { createdAt?: string; lastUsedAt?: string; isActive?: boolean; + category?: string; + environmentColor?: string; + categoryColor?: string; }; function toToolSafeConnection(connection: unknown): ToolSafeConnection | null { @@ -129,6 +132,9 @@ function toToolSafeConnection(connection: unknown): ToolSafeConnection | null { createdAt: typeof source.createdAt === "string" ? source.createdAt : undefined, lastUsedAt: typeof source.lastUsedAt === "string" ? source.lastUsedAt : undefined, isActive: typeof source.isActive === "boolean" ? source.isActive : undefined, + category: typeof source.category === "string" ? source.category : undefined, + environmentColor: typeof source.environmentColor === "string" ? source.environmentColor : undefined, + categoryColor: typeof source.categoryColor === "string" ? source.categoryColor : undefined, }; } diff --git a/src/renderer/index.html b/src/renderer/index.html index c95b19f8..30e56388 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -133,6 +133,13 @@
    +
    +
    +
    Category
    + +