Skip to content

feat(module-services): add App State API client - #5214

Merged
odinr merged 2 commits into
mainfrom
feat/app-state-service-client
Aug 7, 2026
Merged

feat(module-services): add App State API client#5214
odinr merged 2 commits into
mainfrom
feat/app-state-service-client

Conversation

@odinr

@odinr odinr commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Why is this change needed?
The App State API (https://appstate.ci.api.fusion-dev.net/openapi/v1.json) has no typed client in @equinor/fusion-framework-module-services. Consumers need a domain client to read and manage per-user/per-app state, consistent with the other service domains already offered by this package.

What is the current behavior?
@equinor/fusion-framework-module-services exposes BookmarksApiClient, ContextApiClient, NotificationApiClient, and PeopleApiClient. There is no App State client and no createAppStateClient factory on ApiProvider.

What is the new behavior?
Adds AppStateApiClient, exposed via a new ./app-state subpath export and ApiProvider.createAppStateClient(). It follows the same versioned-method pattern as bookmarks/context/notification: every method takes an API version ('v1') as its first argument, builds the request with a Zod-validated response selector, and appends ?api-version=1.0 to the request path.

Operations covered:

  • listMyApps, getMyAppState, wipeMyAppState, wipeAllMyState (current user's own state, incl. GDPR full erasure)
  • listAppUsers, getUserAppState, wipeUserAppState, wipeAllAppUsersState (admin operations scoped to an app)

What is the intended behavior or invariant?

  • Every method requires an explicit API version argument, even though the upstream API currently only supports one version — this keeps the client API consistent with sibling domains and future-proofs it if the API introduces v2.
  • The upstream OpenAPI spec does not publish response body schemas, only status-code descriptions, so response types default to unknown unless the caller supplies a TResponse type argument.
  • The two GDPR/bulk-wipe operations (wipeAllMyState, wipeAllAppUsersState) always send the X-Confirm-Wipe: true header the API requires; callers can still add further headers via init.

Does this PR introduce a breaking change?
No. This is a net-new subpath export and a new method on ApiProvider; no existing exports or signatures changed.

Impact assessment:

  • Breaking changes: No
  • Version bump: Minor (see changeset)
  • Consumer impact: New opt-in ./app-state subpath and createAppStateClient() method; no action required for existing consumers
  • Downstream impact: None outside @equinor/fusion-framework-module-services

Review guidance:

  • Compare app-state/* against context/* or bookmarks/* to confirm the versioned pattern (enum, zod schemas, api-version query param, no-separate-export suppression) is followed consistently.
  • client.ts is the main new consumer-facing surface — check method signatures and TSDoc.
  • tests/app-state.test.ts and the added tests/setup.ts msw handlers cover all 8 operations, including the missing-confirmation-header rejection path.

Additional context
Validated locally: tsc -b --force, biome check, fusion-lint lint, and vitest all pass for packages/modules/services.

Related issues
Closes equinor/fusion-core-tasks#1671 (sub-issue of the App State epic, equinor/fusion-core-tasks#538).

Checklist

  • Confirm completion of the self-review checklist
  • Confirm TSDoc captures intent for functions, hooks, components, classes, and named arrow functions
  • Confirm iterator blocks, decision gates, RxJS chains, and complex decisions explain why they exist
  • Confirm React logic and derived values are resolved before markup when applicable
  • Confirm README/docs are updated for user-facing changes
  • Confirm changes to target branch validation
    • Included files validated
    • No new linting warnings
    • Not a duplicate PR (check existing)
  • Confirm adherence to code of conduct

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aadff4a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@equinor/fusion-framework-module-services Minor
@equinor/fusion-framework-dev-portal Major
@equinor/fusion-framework Patch
@equinor/fusion-framework-cli Patch
@equinor/fusion-framework-app Patch
poc-portal Patch
portal-analytics Patch
portal Patch
@equinor/fusion-framework-react-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added 📚 documentation Improvements or additions to documentation 🚀 feature New feature or request 🧬 Modules labels Aug 5, 2026
@odinr
odinr force-pushed the feat/app-state-service-client branch from 5ee901e to 7db2e4a Compare August 5, 2026 10:53
@odinr
odinr marked this pull request as ready for review August 5, 2026 10:53
@odinr
odinr requested a review from a team as a code owner August 5, 2026 10:53
@odinr odinr self-assigned this Aug 5, 2026
@odinr
odinr requested a balanced review from Copilot August 5, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a versioned App State API client to the services module.

Changes:

  • Implements eight user and admin state operations.
  • Adds provider integration and the ./app-state export.
  • Adds tests, documentation, and a minor changeset.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/modules/services/tests/setup.ts Adds App State API mock handlers.
packages/modules/services/tests/app-state.test.ts Tests all App State operations.
packages/modules/services/src/provider.ts Adds the App State client factory.
packages/modules/services/src/app-state/types.ts Defines version utility types.
packages/modules/services/src/app-state/static.ts Defines supported API versions.
packages/modules/services/src/app-state/index.ts Exposes the public subpath API.
packages/modules/services/src/app-state/endpoints/me.delete.ts Implements current-user bulk wipe.
packages/modules/services/src/app-state/endpoints/me-apps.get.ts Implements current-user app listing.
packages/modules/services/src/app-state/endpoints/me-app.get.ts Implements current-user app-state retrieval.
packages/modules/services/src/app-state/endpoints/me-app.delete.ts Implements current-user app-state wipe.
packages/modules/services/src/app-state/endpoints/admin-app.delete.ts Implements administrative app-wide wipe.
packages/modules/services/src/app-state/endpoints/admin-app-users.get.ts Implements administrative user listing.
packages/modules/services/src/app-state/endpoints/admin-app-user.get.ts Implements administrative user-state retrieval.
packages/modules/services/src/app-state/endpoints/admin-app-user.delete.ts Implements administrative user-state wipe.
packages/modules/services/src/app-state/client.ts Defines the consumer-facing client.
packages/modules/services/README.md Documents the new client.
packages/modules/services/package.json Registers the new package subpath.
.changeset/module-services_add-app-state-client.md Records the minor release.
Suppressed comments (1)

packages/modules/services/src/app-state/client.ts:84

  • TMethod does not default to 'json': the constructor requires _method, and the generic default is the union of supported client methods. Remove the stated default so the public API documentation matches the signature.
 * @template TMethod - The client method to use for the request, defaults to 'json'.

Comment thread packages/modules/services/src/app-state/endpoints/me.delete.ts Outdated
Comment thread packages/modules/services/src/app-state/endpoints/admin-app.delete.ts Outdated
Comment thread packages/modules/services/src/app-state/client.ts Outdated
Comment thread .changeset/module-services_add-app-state-client.md Outdated
@github-actions github-actions Bot added the 🐞 bug Something isn't working label Aug 5, 2026
odinr added 2 commits August 7, 2026 11:29
Implements a versioned domain client for the App State API
(https://appstate.ci.api.fusion-dev.net/openapi/v1.json), following the
same versioned-endpoint pattern as bookmarks/context/notification.

- AppStateApiClient exposed via new ./app-state subpath export
- ApiProvider.createAppStateClient() factory method
- 8 operations: list/get/wipe own app state, GDPR full erasure,
  and admin list/get/wipe per-user or per-app state
…TSDoc example

- me.delete.ts / admin-app.delete.ts: merge caller headers via Headers instead of\n  Object.assign shallow-replacing the headers object, so callers can add headers\n  without stripping the mandatory X-Confirm-Wipe header\n- client.ts / changeset: fix TSDoc/example importing HttpClient from the wrong\n  path and constructing it with an unsupported { baseUri } argument\n- client.ts: remove inaccurate "defaults to 'json'" claim on @template TMethod
@odinr
odinr force-pushed the feat/app-state-service-client branch from 42813f6 to aadff4a Compare August 7, 2026 09:29
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 67.13% 3931 / 5855
🔵 Statements 66.87% 4697 / 7024
🔵 Functions 53.54% 1361 / 2542
🔵 Branches 55.77% 2063 / 3699
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/modules/services/src/provider.ts 6.45% 0% 0% 4.54% 85-206, 86-204
packages/modules/services/src/app-state/client.ts 100% 100% 50% 100%
packages/modules/services/src/app-state/index.ts 100% 100% 100% 100%
packages/modules/services/src/app-state/static.ts 100% 100% 100% 100%
packages/modules/services/src/app-state/types.ts 100% 100% 100% 100%
packages/modules/services/src/app-state/endpoints/admin-app-user.delete.ts 91.66% 100% 62.5% 88.88% 68, 84
packages/modules/services/src/app-state/endpoints/admin-app-user.get.ts 91.66% 100% 62.5% 88.88% 67, 83
packages/modules/services/src/app-state/endpoints/admin-app-users.get.ts 91.66% 100% 62.5% 88.88% 66, 82
packages/modules/services/src/app-state/endpoints/admin-app.delete.ts 92.59% 100% 62.5% 90% 70, 86
packages/modules/services/src/app-state/endpoints/me-app.delete.ts 91.66% 100% 62.5% 88.88% 67, 83
packages/modules/services/src/app-state/endpoints/me-app.get.ts 91.66% 100% 62.5% 88.88% 66, 82
packages/modules/services/src/app-state/endpoints/me-apps.get.ts 91.66% 100% 62.5% 88.88% 59, 75
packages/modules/services/src/app-state/endpoints/me.delete.ts 92.59% 100% 62.5% 90% 63, 79
Generated in workflow #15170 for commit aadff4a by the Vitest Coverage Report Action

@odinr
odinr merged commit c9d7bd4 into main Aug 7, 2026
11 checks passed
@odinr
odinr deleted the feat/app-state-service-client branch August 7, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working 📚 documentation Improvements or additions to documentation 🚀 feature New feature or request 🧬 Modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants