[LWM] feat(notifications): split prompt rules into domain packages#18739
Draft
tonykhaov wants to merge 2 commits into
Draft
[LWM] feat(notifications): split prompt rules into domain packages#18739tonykhaov wants to merge 2 commits into
tonykhaov wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modularizes the Notifications Prompt logic by extracting the eligibility/history “domain” contract into domain/entity/notification-prompt, and moving platform-specific adapters and flow/UI primitives into dedicated features/* packages, then wiring Ledger Live Mobile MVVM code to consume these new packages.
Changes:
- Added a new domain entity package (
@domain/entity-notification-prompt) containing schemas, persisted history slice/selectors, and the decision engine (with unit tests). - Added new feature packages for platform adapters (
@features/platform-notification-prompt) and flow primitives (@features/flow-notification-prompt), both with tests. - Updated Ledger Live Mobile Notifications Prompt MVVM code to use the new domain + feature packages and added workspace dependencies.
Reviewed changes
Copilot reviewed 43 out of 45 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds workspace links and dependency graph entries for the new domain/feature packages. |
| features/platform/notification-prompt/tsconfig.json | TypeScript configuration for the new platform adapter package. |
| features/platform/notification-prompt/src/policy/mapFeatureFlagsToNotificationPromptPolicy.ts | Maps feature-flag payloads into the normalized domain NotificationPromptPolicy. |
| features/platform/notification-prompt/src/policy/mapFeatureFlagsToNotificationPromptPolicy.test.ts | Unit tests validating feature-flag → domain policy normalization. |
| features/platform/notification-prompt/src/permissions/mapFirebaseAuthorizationStatusToNotificationPermissionStatus.ts | Platform adapter mapping Firebase authorization statuses into the domain permission status contract. |
| features/platform/notification-prompt/src/permissions/mapFirebaseAuthorizationStatusToNotificationPermissionStatus.test.ts | Unit tests for Firebase status → domain permission status mapping. |
| features/platform/notification-prompt/src/index.ts | Public exports for the platform notification-prompt adapter package. |
| features/platform/notification-prompt/project.json | Nx project target definition for the new package. |
| features/platform/notification-prompt/package.json | Declares the new platform adapter package and its workspace dependencies. |
| features/platform/notification-prompt/jest.config.js | Jest configuration for the platform adapter package. |
| features/flow/notification-prompt/tsconfig.json | TypeScript configuration for the new flow package (React JSX enabled). |
| features/flow/notification-prompt/src/state/slice.ts | Adds the flow slice for drawer open/close and pending intent emission. |
| features/flow/notification-prompt/src/state/slice.test.ts | Unit tests for the flow slice reducers/selectors. |
| features/flow/notification-prompt/src/index.ts | Public exports for flow primitives (provider + slice). |
| features/flow/notification-prompt/src/components/NotificationsPromptProvider/index.tsx | Adds a reusable context provider + hook for flow orchestration. |
| features/flow/notification-prompt/project.json | Nx project target definition for the new flow package. |
| features/flow/notification-prompt/package.json | Declares the new flow package and its dependencies (React + RTK). |
| features/flow/notification-prompt/jest.config.js | Jest configuration for the flow package. |
| domain/entity/notification-prompt/tsconfig.json | TypeScript configuration for the new domain entity package. |
| domain/entity/notification-prompt/src/logic/engine.ts | Implements the domain decision engine (after-action + inactivity) and helper utilities. |
| domain/entity/notification-prompt/src/logic/engine.test.ts | Unit tests covering key decision branches and helper behavior. |
| domain/entity/notification-prompt/src/index.ts | Public exports for the domain entity package (schema, slice, engine, default reducer). |
| domain/entity/notification-prompt/src/data/slice.ts | Adds persisted history slice + selectors for notification prompt state. |
| domain/entity/notification-prompt/src/data/slice.test.ts | Unit tests for the history slice reducers. |
| domain/entity/notification-prompt/src/data/selectors.test.ts | Unit tests for history selectors (including legacy fallback behavior). |
| domain/entity/notification-prompt/src/data/schema.ts | Defines the domain schemas/types for policy, history, targets, sources, and variants. |
| domain/entity/notification-prompt/src/data/schema.test.ts | Unit tests validating schema acceptance/rejection rules. |
| domain/entity/notification-prompt/src/data/schema.mock.ts | Mock factories for policy/history/permission status used in tests. |
| domain/entity/notification-prompt/project.json | Nx project target definition for the new domain package. |
| domain/entity/notification-prompt/package.json | Declares the new domain entity package and its dependencies (RTK + Zod). |
| domain/entity/notification-prompt/jest.config.js | Jest configuration for the domain entity package. |
| apps/ledger-live-mobile/src/mvvm/features/NotificationsPrompt/new/NotificationsPromptProvider.tsx | Switches the mobile provider to reuse the flow package provider/context contract. |
| apps/ledger-live-mobile/src/mvvm/features/NotificationsPrompt/new/notificationsPromptAnalytics.ts | Aligns analytics helpers with the new domain decision types while keeping mobile target typing where needed. |
| apps/ledger-live-mobile/src/mvvm/features/NotificationsPrompt/new/hooks/useNotificationsPromptTriggers.ts | Uses the new platform adapters + domain engine, including normalized policy + permission status mapping. |
| apps/ledger-live-mobile/src/mvvm/features/NotificationsPrompt/new/hooks/useNotificationsPromptDrawerScheduler.ts | Updates types to the new domain NotificationPromptSource. |
| apps/ledger-live-mobile/package.json | Adds workspace dependencies on the new domain + feature notification-prompt packages. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
8ea9c71 to
2c8550e
Compare
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.
✅ Checklist
npx changesetwas attached.📝 Description
Replace this text by a clear and concise description of what this pull request is about and why it is needed. Be sure to explain the problem you're addressing and the solution you're proposing.
For libraries, you can add a code sample of how to use it.
For bug fixes, you can explain the previous behaviour and how it was fixed.
In case of visual features, please attach screenshots or video recordings to demonstrate the changes.
❓ Context
🧐 Checklist for the PR Reviewers