feat(callbacks): add Community Apps alpha contracts#52
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (9)
📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThis PR adds Community Apps launch callback infrastructure including a complete type system for installed-app management, SHA256-based app hashing, client-side iframe bridge communication, and updated public APIs for both client and server modules with supporting tests and documentation. ChangesCommunity Apps Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #52 +/- ##
==========================================
- Coverage 99.08% 92.36% -6.72%
==========================================
Files 3 6 +3
Lines 109 131 +22
Branches 30 36 +6
==========================================
+ Hits 108 121 +13
- Misses 1 10 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/client.ts (1)
24-52:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRe-export the new theme/base contract types from the client entrypoint.
The client subpath still omits
CommunityAppsInstalledAppsBase,CommunityAppsThemeColorMode,CommunityAppsThemeVariables, andCommunityAppsThemePayload. That leaves the new Community Apps surface only partially consumable from@unraid/shared-callbacks/client, which defeats the alpha contract for downstream consumers.Proposed fix
import type { CallbackConfig, QueryPayloads, SendPayloads, @@ CommunityAppsInstalledAppsAlgorithm, CommunityAppsInstalledAppsMode, CommunityAppsInstalledAppHash, CommunityAppsInstalledAppStatusMap, + CommunityAppsInstalledAppsBase, CommunityAppsInstalledAppsBatch, CommunityAppsInstalledAppsLookup, CommunityAppsInstalledApps, + CommunityAppsThemeColorMode, + CommunityAppsThemeVariables, + CommunityAppsThemePayload, CommunityAppsInstalledAppStatusRequest, CommunityAppsInstalledAppStatusResponse, CommunityAppsInstallActionType, @@ export type { CallbackConfig, QueryPayloads, SendPayloads, @@ CommunityAppsInstalledAppsAlgorithm, CommunityAppsInstalledAppsMode, CommunityAppsInstalledAppHash, CommunityAppsInstalledAppStatusMap, + CommunityAppsInstalledAppsBase, CommunityAppsInstalledAppsBatch, CommunityAppsInstalledAppsLookup, CommunityAppsInstalledApps, + CommunityAppsThemeColorMode, + CommunityAppsThemeVariables, + CommunityAppsThemePayload, CommunityAppsInstalledAppStatusRequest, CommunityAppsInstalledAppStatusResponse, CommunityAppsInstallActionType,Also applies to: 215-272
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/client.ts` around lines 24 - 52, The client entrypoint export list is missing several new Community Apps contract types — add CommunityAppsInstalledAppsBase, CommunityAppsThemeColorMode, CommunityAppsThemeVariables, and CommunityAppsThemePayload to the exported symbols alongside the existing CommunityApps and CommunityAppsLaunch entries; update both export blocks that export CommunityApps-related types (the earlier block that includes CommunityApps, CommunityAppsLaunch, etc. and the later similar export block) so the full Community Apps surface is re-exported from the client entrypoint (ensure you reference the exact type names: CommunityAppsInstalledAppsBase, CommunityAppsThemeColorMode, CommunityAppsThemeVariables, CommunityAppsThemePayload).src/server.ts (1)
23-51:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMirror the missing Community Apps theme/base exports on the server entrypoint.
@unraid/shared-callbacks/serverhas the same gap as the client entry:CommunityAppsInstalledAppsBase,CommunityAppsThemeColorMode,CommunityAppsThemeVariables, andCommunityAppsThemePayloadare defined insrc/types.tsbut never surfaced here. That leaves the shared server contract incomplete for downstream users.Proposed fix
import type { CallbackConfig, QueryPayloads, SendPayloads, @@ CommunityAppsInstalledAppsAlgorithm, CommunityAppsInstalledAppsMode, CommunityAppsInstalledAppHash, CommunityAppsInstalledAppStatusMap, + CommunityAppsInstalledAppsBase, CommunityAppsInstalledAppsBatch, CommunityAppsInstalledAppsLookup, CommunityAppsInstalledApps, + CommunityAppsThemeColorMode, + CommunityAppsThemeVariables, + CommunityAppsThemePayload, CommunityAppsInstalledAppStatusRequest, CommunityAppsInstalledAppStatusResponse, CommunityAppsInstallActionType, @@ export type { CallbackConfig, QueryPayloads, SendPayloads, @@ CommunityAppsInstalledAppsAlgorithm, CommunityAppsInstalledAppsMode, CommunityAppsInstalledAppHash, CommunityAppsInstalledAppStatusMap, + CommunityAppsInstalledAppsBase, CommunityAppsInstalledAppsBatch, CommunityAppsInstalledAppsLookup, CommunityAppsInstalledApps, + CommunityAppsThemeColorMode, + CommunityAppsThemeVariables, + CommunityAppsThemePayload, CommunityAppsInstalledAppStatusRequest, CommunityAppsInstalledAppStatusResponse, CommunityAppsInstallActionType,Also applies to: 111-166
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server.ts` around lines 23 - 51, Export the missing Community Apps type symbols from the server entrypoint so the shared server contract matches the client: add CommunityAppsInstalledAppsBase, CommunityAppsThemeColorMode, CommunityAppsThemeVariables, and CommunityAppsThemePayload to the export lists in src/server.ts (the same places where CommunityAppsInstalledApps, CommunityAppsInstallRequest, CommunityAppsLaunch, etc. are exported) and ensure the duplicate export blocks (the later block covering lines ~111-166) also include these four types so both export groups surface them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/post-me.d.ts`:
- Around line 1-16: Update the post-me declarations to match post-me@0.4.5:
extend the WindowMessenger type to include the instance methods
addMessageListener(listener: MessageListener): ListenerRemover and
postMessage(message: any, transfer?: Transferable[]): void in addition to the
constructor, and change ParentHandshake to the generic signature used
upstream—accept messenger: Messenger, localMethods?: M0 with M0 extends
MethodsType, and return Promise<Connection> (rather than constraining messenger
to WindowMessenger, using Record<string, ...>, or returning { close: () => void
}); use the exact type names Messenger, MethodsType, M0, and Connection from the
upstream definitions so callers get correct typings.
---
Outside diff comments:
In `@src/client.ts`:
- Around line 24-52: The client entrypoint export list is missing several new
Community Apps contract types — add CommunityAppsInstalledAppsBase,
CommunityAppsThemeColorMode, CommunityAppsThemeVariables, and
CommunityAppsThemePayload to the exported symbols alongside the existing
CommunityApps and CommunityAppsLaunch entries; update both export blocks that
export CommunityApps-related types (the earlier block that includes
CommunityApps, CommunityAppsLaunch, etc. and the later similar export block) so
the full Community Apps surface is re-exported from the client entrypoint
(ensure you reference the exact type names: CommunityAppsInstalledAppsBase,
CommunityAppsThemeColorMode, CommunityAppsThemeVariables,
CommunityAppsThemePayload).
In `@src/server.ts`:
- Around line 23-51: Export the missing Community Apps type symbols from the
server entrypoint so the shared server contract matches the client: add
CommunityAppsInstalledAppsBase, CommunityAppsThemeColorMode,
CommunityAppsThemeVariables, and CommunityAppsThemePayload to the export lists
in src/server.ts (the same places where CommunityAppsInstalledApps,
CommunityAppsInstallRequest, CommunityAppsLaunch, etc. are exported) and ensure
the duplicate export blocks (the later block covering lines ~111-166) also
include these four types so both export groups surface them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1be91ddd-900d-4c5b-ba92-137d7eb8941f
⛔ Files ignored due to path filters (9)
dist/client.d.tsis excluded by!**/dist/**dist/client.jsis excluded by!**/dist/**dist/community-apps-client.d.tsis excluded by!**/dist/**dist/community-apps.d.tsis excluded by!**/dist/**dist/index.jsis excluded by!**/dist/**dist/server.d.tsis excluded by!**/dist/**dist/server.jsis excluded by!**/dist/**dist/types.d.tsis excluded by!**/dist/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
README.mdpackage.jsonsrc/__tests__/server.test.tssrc/client.tssrc/community-apps-client.tssrc/community-apps.tssrc/post-me.d.tssrc/server.tssrc/types.tstsconfig.json
| declare module "post-me" { | ||
| export class WindowMessenger { | ||
| constructor(options: { | ||
| localWindow?: Window; | ||
| remoteWindow: Window; | ||
| remoteOrigin: string; | ||
| }); | ||
| } | ||
|
|
||
| export function ParentHandshake( | ||
| messenger: WindowMessenger, | ||
| localMethods?: Record<string, (...args: any[]) => any>, | ||
| maxAttempts?: number, | ||
| attemptsInterval?: number | ||
| ): Promise<{ close: () => void }>; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What is the API signature for WindowMessenger and ParentHandshake in post-me version 0.4.5?
💡 Result:
WindowMessenger (post-me v0.4.5) Constructor signature: export declare class WindowMessenger implements Messenger constructor({ localWindow, remoteWindow, remoteOrigin, }): void Supported instance methods (from the WindowMessenger type docs): - addMessageListener(listener: MessageListener): ListenerRemover - postMessage(message: any, transfer?: Transferable[]): void [1] ParentHandshake (post-me v0.4.5) Function signature: export declare function ParentHandshake( messenger: Messenger, localMethods?: M0, maxAttempts?: number, attemptsInterval?: number): Promise; [2]
Citations:
- 1: https://alesgenova.github.io/post-me/post-me.windowmessenger.html
- 2: https://alesgenova.github.io/post-me/post-me.parenthandshake.html
Align src/post-me.d.ts with post-me@0.4.5 types.
WindowMessengeris missing documented instance methods:addMessageListener(listener: MessageListener): ListenerRemoverandpostMessage(message: any, transfer?: Transferable[]): void(only the constructor is declared).ParentHandshakesignature doesn’t matchpost-me@0.4.5: it should returnPromise<Connection>and usemessenger: MessengerpluslocalMethods?: M0withM0 extends MethodsType; the current declaration narrowsmessengertoWindowMessenger, typeslocalMethodsasRecord<string, (...args: any[]) => any>, and returnsPromise<{ close: () => void }>instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/post-me.d.ts` around lines 1 - 16, Update the post-me declarations to
match post-me@0.4.5: extend the WindowMessenger type to include the instance
methods addMessageListener(listener: MessageListener): ListenerRemover and
postMessage(message: any, transfer?: Transferable[]): void in addition to the
constructor, and change ParentHandshake to the generic signature used
upstream—accept messenger: Messenger, localMethods?: M0 with M0 extends
MethodsType, and return Promise<Connection> (rather than constraining messenger
to WindowMessenger, using Record<string, ...>, or returning { close: () => void
}); use the exact type names Messenger, MethodsType, M0, and Connection from the
upstream definitions so callers get correct typings.
- Add a typed communityApps action for Unraid OS to launch Community Apps inside an iframe. - Before, callback payloads only modeled account, license, and OS update actions. - That left CA iframe launches without a shared contract for server context, install targets, or theme/path preferences. - Add CommunityAppsLaunch to the UPC action union with server data and optional install URL customization fields. - Export the new action type through client and server entrypoints and cover server round-trip generation/parsing. - Regenerate package declaration files so consumers can type against the new contract.
- Add an explicit installedApps payload block for Community Apps launches. - Before, the launch action had no contract for installed-state exposure. - That made it unclear how Core should represent optional installed app matching without weakening the privacy boundary. - Model installed app fingerprints as an optional enabled:true block with algorithm, salt, and keys. - Keep the field omitted unless a user opts into local installed-state badges.
- Replace the flat installed app fingerprint list with a compact status map. - Before, callbacks could only say that a hash was present, so CA could not distinguish currently installed apps from previously installed apps. - Variable-length hash strings also risked wasting URL space in hash-based iframe launches. - Add numeric installed app status codes and fixed sha256-128 app fingerprints encoded as 22-character base64url keys. - Export the status enum through client and server entrypoints so Core can build payloads without hardcoding status values.
- Add lookup mode for Community Apps installed app status payloads. - Before, status context had to be carried as a launch-time app map when CA needed installed-state UI. - That exposed more installed-app information than necessary and could grow callback URLs. - Add fixed-length salted app hash helpers and a post-me parent bridge for visible-app status lookups. - Keep batch maps available while making lookup mode the preferred privacy-preserving integration.
Purpose of the change - Add the remaining Community Apps iframe contracts needed by CA/Core integration. Previous behavior - Shared callbacks only described installed-app status lookup for Community Apps. - The package subpath exports only declared import/type conditions, which left some dev tooling unable to resolve @unraid/shared-callbacks/client. Why that was a problem - CA and Core need a typed postMessage install request path, richer theme payloads, and explicit install review responses before this can be consumed outside local links. - Resolver failures blocked vue-tsc in consumers using the linked package. What the new change accomplishes - Adds typed Community Apps install bridge actions, requests, and responses. - Allows structured light/dark/shared theme payloads while preserving simple color mode strings. - Exports the new types from client and server entrypoints. - Adds default package export targets for Node/tooling compatibility. How it works - Extends CommunityAppsLaunch with optional installAction and structured theme payloads. - Adds requestInstall to the Community Apps host bridge method contract. - Rebuilds dist declarations and bundles from the source types.
8dbae71 to
2f90748
Compare
Summary
requestInstallhost bridge method and install response shape for Core iframe integration@unraid/shared-callbacks/clientresolves in stricter dev toolingAlpha release path
alpha, notmain.alphadist-tag.@unraid/shared-callbacks@alphawithout affecting the stablelatestpackage.Supersedes
codex/community-apps-launch-actionplus the remaining alpha contract updates.Verification
pnpm run buildpnpm test -- --run src/__tests__/server.test.ts@unraid/shared-callbacks/clientresolves from the CA worker linked packagevue-tscpasses against this linked branchSummary by CodeRabbit
New Features
Documentation
Chores
Tests