-
Notifications
You must be signed in to change notification settings - Fork 1
fix(CTT-164): abstract member polling into swappable transport layer #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Connect Widget AI Context | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `@mxenabled/connect-widget` is a UI-only library for the Connect Widget, built with React and TypeScript. It provides the visual components and state management for the widget but relies on an external API and configuration provided by the consuming application to function. | ||
|
|
||
| The library uses `ConnectWidget` as the main entry point and `ApiProvider` to inject the necessary API callbacks. | ||
|
|
||
| **Core Technologies:** | ||
|
|
||
| - **UI Framework:** React | ||
| - **Language:** TypeScript | ||
| - **State Management:** Redux Toolkit | ||
| - **Build Tool:** Vite | ||
| - **Testing:** Vitest | ||
| - **(Old. Do not introduce more usage) Component Library:** Kyper UI (`@kyper/*`) | ||
|
|
||
| ## Building and Running | ||
|
|
||
| The project relies on standard npm scripts for development, building, and testing: | ||
|
|
||
| - **Install Dependencies:** `npm install` | ||
| - **Development Build (Watch Mode):** `npm run dev` | ||
| - **Production Build:** `npm run build` | ||
| - **Run Tests:** `npm run test` | ||
| - **Watch Tests:** `npm run watch` | ||
| - **Lint Code:** `npm run lint` | ||
| - **Link locally:** Use `npm link` in the root and then `npm link @mxenabled/connect-widget` in the consuming application to test local changes. | ||
|
|
||
| ## Development Conventions | ||
|
|
||
| This repository has strict architectural, styling, and testing standards defined in the Architecture Decision Records (`architectureDecisionRecords/`). All new code must conform to these ADRs. | ||
|
|
||
| ### Architecture & Design | ||
|
|
||
| - **Architecture Decision Records (ADRs):** Any significant technical choices should be documented as an ADR. Pull requests with new code that does not adhere to the agreed-upon ADRs will not be approved (exceptions for urgent hotfixes). | ||
| - **Styling:** The project uses **CSS Modules** for styling. Do not use Tailwind CSS or other global CSS frameworks unless specifically working on existing legacy code that hasn't been migrated. | ||
|
|
||
| ### Testing | ||
|
|
||
| - **Frameworks:** Use **Vitest** for unit and integration testing. **MSW (Mock Service Worker)** is the standard for API mocking in tests. **Cypress** is the standard for end-to-end tests. | ||
| - **Philosophy:** Prefer integration tests over unit tests. Mock as little as possible. The primary goal of testing is to ensure that the frontend works properly with the backend and to provide confidence to deploy without manual testing. | ||
|
|
||
| ### Git & Version Control | ||
|
|
||
| - **Conventional Commits:** All commit messages must follow the Conventional Commits specification to trigger semantic versioning releases properly. | ||
| - You can use `npx cz` (Commitizen) to launch interactive prompts for formatting your commit message. | ||
| - `fix:` triggers a PATCH bump | ||
| - `feat:` triggers a MINOR bump | ||
| - `BREAKING CHANGE:` footer triggers a MAJOR bump. | ||
|
|
||
| ## Project Structure Highlights | ||
|
|
||
| - `src/`: Contains all the source code for the widget. | ||
| - `components/`: React components. | ||
| - `redux/`: Redux actions, reducers, selectors, and store configuration. | ||
| - `context/`: React context providers (like `ApiContext`). | ||
| - `hooks/`: Custom React hooks. | ||
| - `views/`: Higher-level view components. | ||
| - `docs/`: Extensive documentation on analytics, API requirements, client config, and user features. | ||
| - `architectureDecisionRecords/`: Documentation of core engineering decisions (ADRs). |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { Observable, defer, interval, of } from 'rxjs' | ||
codingLogan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { catchError, map, mergeMap, exhaustMap } from 'rxjs/operators' | ||
| import type { ApiContextTypes } from 'src/context/ApiContext' | ||
|
|
||
| type MemberUpdateApi = Required<Pick<ApiContextTypes, 'loadMemberByGuid' | 'loadJob'>> | ||
|
|
||
| export interface MemberUpdate { | ||
| member?: MemberResponseType | ||
| job?: JobResponseType | ||
| } | ||
|
|
||
| export interface MemberUpdateTransportOptions { | ||
| pollingInterval?: number | ||
| clientLocale?: string | ||
| } | ||
|
|
||
| export function createMemberUpdateTransport( | ||
| api: MemberUpdateApi, | ||
| memberGuid: string, | ||
| options: MemberUpdateTransportOptions = {}, | ||
| ): Observable<MemberUpdate | Error> { | ||
| const pollingInterval = options.pollingInterval || 3000 | ||
| const clientLocale = options.clientLocale || 'en' | ||
|
|
||
| return interval(pollingInterval).pipe( | ||
| exhaustMap(() => | ||
| defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe( | ||
| mergeMap((member: MemberResponseType) => | ||
| defer(() => | ||
| api.loadJob((member as { most_recent_job_guid: string }).most_recent_job_guid), | ||
| ).pipe(map((job: JobResponseType) => ({ member, job }))), | ||
| ), | ||
| catchError((error) => of(error)), | ||
| ), | ||
| ), | ||
| ) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.