feat(powerbi): migrate to TypeScript and fix embed-token refresh#816
Open
rusko124 wants to merge 2 commits into
Open
feat(powerbi): migrate to TypeScript and fix embed-token refresh#816rusko124 wants to merge 2 commits into
rusko124 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Power BI edge app from a static “vanilla JS + vendor copies” setup to a TypeScript + @screenly/edge-apps build pipeline, and updates the embed-token refresh logic to reschedule refreshes based on token expiration with exponential backoff on failures.
Changes:
- Replaces
static/js/main.jswith a TypeScript entrypoint (src/main.ts) and moves core logic into typed service/util modules. - Fixes token refresh scheduling by using the embed token
expiration(plus a capped interval) and adds exponential backoff for refresh failures. - Introduces unit tests (Bun + happy-dom) for refresh timing utilities and Power BI service behavior; updates build/test/lint scripts accordingly.
Reviewed changes
Copilot reviewed 13 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| edge-apps/powerbi/tsconfig.json | Adds TS config extending the shared edge-apps config. |
| edge-apps/powerbi/static/js/vendor/panic-overlay.min.js | Removes vendored panic-overlay bundle (now imported via bundler). |
| edge-apps/powerbi/static/js/main.js | Removes legacy JS entrypoint (replaced by TS modules). |
| edge-apps/powerbi/src/utils.ts | Adds refresh-interval, refresh-delay, backoff, and embed-type utilities. |
| edge-apps/powerbi/src/utils.test.ts | Adds Bun unit tests for utility timing/type helpers. |
| edge-apps/powerbi/src/utils.lib.ts | Adds constants for refresh/backoff timing behavior. |
| edge-apps/powerbi/src/services.types.ts | Introduces typed contracts for token and error payloads. |
| edge-apps/powerbi/src/services.ts | Adds typed token fetching, refresh loop, and embed initialization logic. |
| edge-apps/powerbi/src/services.test.ts | Adds tests for token fetch, refresh loop scheduling, embed init, and error rendering. |
| edge-apps/powerbi/src/services.lib.ts | Adds embed service singleton + shared error rendering helper. |
| edge-apps/powerbi/src/main.ts | New TS entrypoint wiring panic-overlay + initialization. |
| edge-apps/powerbi/src/globals.d.ts | Adds global screenly typings for the app. |
| edge-apps/powerbi/src/css/style.css | Moves styles into the bundler pipeline and adds error UI styling. |
| edge-apps/powerbi/package.json | Switches to edge-apps-scripts build/lint/type-check and enables Bun tests. |
| edge-apps/powerbi/index.html | Switches to TS module entrypoint. |
| edge-apps/powerbi/bun.lock | Updates lockfile for new tooling/testing dependencies. |
| edge-apps/powerbi/.gitignore | Ignores node_modules/ and dist/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Updated the embed token return to handle null expiration values. - Added eslint-disable comments for functions exceeding max lines in tests. - Cleaned up the index.html by removing duplicate script tag.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Bug fix, Tests
Description
Migrates Power BI app to TypeScript
Adds expiration-aware token refresh
Adds service and utility unit tests
Uses Edge Apps build tooling
Diagram Walkthrough
File Walkthrough
9 files
Add Screenly settings global TypeScript definitionsAdd TypeScript app entrypoint and panic setupExtract embed service and error rendering helpersImplement token retrieval, embedding, and refreshAdd shared Power BI service interfacesDefine refresh and backoff timing constantsAdd refresh timing and embed type utilitiesAdd app layout and error view stylesLoad TypeScript module instead of static scripts2 files
Add Power BI service unit coverageAdd utility timing and URL tests1 files
Remove legacy vanilla JavaScript implementation2 files
Switch scripts to Edge Apps toolchainAdd TypeScript configuration for source build