Skip to content

Complete the management API functions and add application components - #139

Open
brionmario wants to merge 1 commit into
thunder-id:mainfrom
brionmario:feat-management-api-functions
Open

brionmario wants to merge 1 commit into
thunder-id:mainfrom
brionmario:feat-management-api-functions

Conversation

@brionmario

@brionmario brionmario commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Purpose

Make the management API usable from apps that already own a data layer, and cover all of it. The ThunderID Console fetches with TanStack Query, so it needs the SDK's management calls as plain functions it can put inside its own queryFn/mutationFn, with its own cache keys and invalidation. Its lists then feed the SDK's Base* admin components through their render props.

The per-resource hooks (useGetUsers, useCreateGroup, ...) duplicated what any data library already does and had no real users outside the SDK's own components, so they are no longer public. The connected admin components (UserList, GroupMembers, ...) keep working unchanged for apps without a data layer.

Approach

  • API functions are the public surface. They live in @thunderid/javascript and are re-exported through browser, react and vue. Each takes a ManagementRequestConfig (baseUrl, url, fetcher).

  • useManagementRequestConfig(collection) (React, Vue, Next.js) returns the provider's base URL, the endpoint override for that collection, and the fetcher. A call therefore uses the same transport as the components: the server action in Next.js, the module's proxy in Nuxt. In React the config is memoized, so it can sit in a dependency list.

  • Internal data layer. The connected components inline their queries and mutations on the generic useResourceQuery/useResourceMutation/useManagementEndpoint. Query keys and invalidation are the same as the removed hooks had, and no per-resource hook files remain.

  • Administration flows. administrationMode: 'flow' (default 'native') runs the administration flow the server configures for these operations:

    • user, group, role and application deletion
    • group member removal and role assignment removal (one run per item)
    • role permission removal
    • client secret regeneration

    The flow is resolved from /server-config/flow and /flows?flowType=ADMINISTRATION. When no flow is configured, the call goes direct. A configured but missing flow, or a refused or incomplete step, throws AdministrationFlowError carrying the step's error.

  • New functions:

    • users: getUserUsages, updateUserCredentials
    • user types: getUserType, createUserType, updateUserType, deleteUserType
    • agent types: getAgentType, updateAgentType
    • applications: previewCimdDocument, regenerateClientSecret, regenerateFlowSecret
    • agents: regenerateAgentSecret
    • getUserTypes is now re-exported from react and vue too.
  • Full coverage of the management API. Every identity resource has list, get, create, update and delete:

    • applications, users, groups, roles, agents, user types and agent types
    • organization units, by id or by handle path (getOrganizationUnitByPath), with their child units, users, groups and roles
    • resource servers, with their resources and actions

    Users and applications gain sharing policies and overlay rules. Suspend, unsuspend and unlock run only through their administration flows (runAccountLifecycleFlow) and fail with a documented error when no flow is configured.

  • Configuration resources. Connections, flows, notification templates, design themes (*DesignTheme*, since createTheme already exists) and layouts, translations, server configuration, gateways, variables and secrets, configuration versions, and import and export. A secret's value is write-only.

  • Application components. ApplicationList, ApplicationCreate and ApplicationDetails for React, Vue, Next.js and Nuxt, each with a Base variant and a custom render. The list shows a translated status column when the server returns one. Their strings (admin.applications.*) are in every bundled locale. The OAuth form helpers they share (getApplicationOAuthConfig, parseRedirectUris, toCreateApplicationRequest, ...) live in @thunderid/javascript, one per file. Application writes leave out the read-only status.

  • Server side. The Node management client gains an applications group, and the Next.js and Nuxt relay allowlist accepts the applications collection. CIMD preview is a direct server call and stays off the relay allowlist.

  • Server error codes. ThunderIDAPIError.serverError carries the server's error envelope (code, message, description with params), so an app can show the server's translated error.

  • Secret regeneration: regenerateClientSecret refuses an application without an OAuth client (regenerateClientSecret-ValidationError-001), rather than returning a secret it never saved. regenerateAgentSecret restates the agent's delegated flag, derived from its grant types, because the server doesn't store it. It also leaves the display-only ouHandle out of the update.

  • One function per file: each administration flow function (runAdministrationFlow, executeAdministrationFlow, resolveAdministrationFlowId, ...) has its own module under api/management/administration/, and the playground data layers are split the same way.

  • Display data: getRoles, getRole, getUserTypes and getAgentTypes now send include=display, like the other getters, so organization unit handles resolve.

  • Nuxt: the module auto-imported composables that @thunderid/vue no longer exports, which would fail an app's build. It now auto-imports useGrantedPermissions and useManagementRequestConfig. A test checks that every auto-imported name is exported.

  • Better Auth: the adapter moves to Better Auth 1.7.13, which fixes GHSA-965c-763c-88jm and GHSA-r4xp-prcw-77qf, the two advisories failing pnpm audit. That release drops accountIssuer, so the provider config leaves it out; a discovery provider uses the discovered issuer anyway. It now sets requireIdTokenVerification, so the provider isn't registered when discovery can't supply the issuer and keys to verify ID tokens.

  • Playgrounds: the React, Vue, Nuxt and Next.js playgrounds now demonstrate the API functions with a small local data helper.

Related Issues

Related PRs

SDK parity

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.
  • Cross-SDK parity. Exactly one of parity/prs-raised or parity/prs-not-needed added.
    • If parity/prs-raised, the port links are posted as a reply on the parity check's comment.

Security checks

  • Followed secure coding standards.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🔀 Cross-SDK feature parity, ports raised

This pull request is labelled parity/prs-raised, so the capability it introduces is expected in the other ThunderID SDKs as well.

Ports (DO NOT EDIT)

  • thunder-id/ios-sdks, iOS => #35
  • thunder-id/android-sdks, Android => #43
  • thunder-id/flutter-sdks, Flutter => #54

3 of 3 sibling SDKs accounted for.

Every sibling SDK is accounted for.

The contract is in the SDK development specification.

@brionmario
brionmario force-pushed the feat-management-api-functions branch 2 times, most recently from 106e0c7 to e12badb Compare October 27, 2026 12:57
@brionmario
brionmario force-pushed the feat-management-api-functions branch from e12badb to faed176 Compare October 27, 2026 17:44
@brionmario brionmario added the parity/prs-raised Ports exist in the other SDKs, or are recorded as not applying there label Oct 27, 2026
@brionmario
brionmario force-pushed the feat-management-api-functions branch from faed176 to 4b70f50 Compare October 27, 2026 18:04
brionmario added a commit to brionmario/ios-sdks that referenced this pull request Oct 27, 2026
Brings the iOS SDK's management operations in line with the
JavaScript SDK (thunder-id/javascript-sdks#139) and covers the rest of
the management API:

- An API error carries the server's error envelope as `serverError`.
- Destructive operations take an `administrationMode`; `flow` runs the
  administration flow the server configures, through the new
  `client.administrationFlows` API. Suspend, unsuspend and
  unlock for users, agents and applications run only through their
  flows.
- Every identity resource now has its five operations: user types, agent
  types, organization units (by id and by path, with their child units,
  users, groups and roles) and resource servers with their resources
  and actions.
- User usages and credentials, users by organization unit path, sharing
  policies and overlay rules, client ID metadata document preview, and
  client, flow and agent secret regeneration.
- The server's configuration resources: connections, flows and their
  versions, notification templates, design themes and layouts,
  translations, server configuration, gateways with their variables and
  secrets, server variables and secrets, configuration versions, and
  import and export.
- ApplicationList, ApplicationCreate and ApplicationDetails in SwiftUI,
  with their Base variants and a `content` closure for a custom render.
- Role and type getters request the display data like the others.

Signed-off-by: Brion <info@brionmario.com>
brionmario added a commit to brionmario/android-sdks that referenced this pull request Oct 27, 2026
Brings the Android SDK's management operations in line with the
JavaScript SDK (thunder-id/javascript-sdks#139) and covers the rest of
the management API:

- An API error carries the server's error envelope as `serverError`.
- Destructive operations take an `administrationMode`; `flow` runs the
  administration flow the server configures, through the new
  `client.administration` client. Suspend, unsuspend and
  unlock for users, agents and applications run only through their
  flows.
- Every identity resource now has its five operations: user types, agent
  types, organization units (by id and by path, with their child units,
  users, groups and roles) and resource servers with their resources
  and actions.
- User usages and credentials, users by organization unit path, sharing
  policies and overlay rules, client ID metadata document preview, and
  client, flow and agent secret regeneration.
- The server's configuration resources: connections, flows and their
  versions, notification templates, design themes and layouts,
  translations, server configuration, gateways with their variables and
  secrets, server variables and secrets, configuration versions, and
  import and export.
- ApplicationList, ApplicationCreate and ApplicationDetails in
  Compose, with their Base variants and a `content` lambda for a custom
  render.
- Role and type getters request the display data like the others.

Signed-off-by: Brion <info@brionmario.com>
brionmario added a commit to brionmario/flutter-sdks that referenced this pull request Oct 27, 2026
Brings the Flutter SDK's management operations in line with the
JavaScript SDK (thunder-id/javascript-sdks#139) and covers the rest of
the management API:

- An API error carries the server's error envelope as `serverError`.
- Destructive operations take an `administrationMode`; `flow` runs the
  administration flow the server configures, through the administration
  flow operations on the management client. Suspend, unsuspend and
  unlock for users, agents and applications run only through their
  flows.
- Applications get list, get, create, update and delete, and every
  identity resource now has its five operations: user types, agent
  types, organization units (by id and by path, with their child units,
  users, groups and roles) and resource servers with their resources
  and actions.
- User usages and credentials, users by organization unit path, sharing
  policies and overlay rules, client ID metadata document preview, and
  client, flow and agent secret regeneration.
- The server's configuration resources: connections, flows and their
  versions, notification templates, design themes and layouts,
  translations, server configuration, gateways with their variables and
  secrets, server variables and secrets, configuration versions, and
  import and export.
- ApplicationList, ApplicationCreate and ApplicationDetails widgets,
  with their Base variants and a `builder` for a custom render.
- Role and type getters request the display data like the others.

Signed-off-by: Brion <info@brionmario.com>
Apps that already own a data layer (TanStack Query, SWR, Pinia) call the
management API functions from @thunderid/javascript, re-exported through
browser, react and vue, and cache the results themselves. The per-resource
React hooks and Vue composables (useGetUsers, useCreateGroup, ...) are
removed; the connected admin components fetch through the internal generic
query layer instead. Each exported function lives in its own file.

- useManagementRequestConfig(collection) hands the API functions the
  provider's base URL, endpoint override and fetcher, so a call goes through
  the same transport as the components (the server action in Next.js, the
  module's proxy in Nuxt).
- Every identity resource has full CRUD: applications, users, groups,
  roles, agents, user types, agent types, organization units (by id or by
  handle path) and resource servers with their resources and actions.
  Users and applications gain sharing policies and overlay rules.
- Suspend, unsuspend and unlock run through their administration flows and
  fail with a documented error when no flow is configured.
- The server's configuration resources are covered as well: connections,
  flows, notification templates, design themes and layouts, translations,
  server configuration, gateways, variables and secrets (write-only
  values), configuration versions, and import and export.
- administrationMode: 'flow' runs the administration flow the server
  configures for deletes, member and assignment removal, permission removal
  and secret regeneration, and falls back to the direct call when none is
  configured. A refused step throws AdministrationFlowError.
- Application list, create and details components for React, Vue, Next.js
  and Nuxt, with Base variants, a status column, and translations in every
  bundled locale. The OAuth form helpers they share live in
  @thunderid/javascript.
- The Node management client and the Next.js and Nuxt relay allowlist
  cover applications.
- ThunderIDAPIError carries the server's error envelope as serverError, so
  apps can resolve the server's error codes.
- regenerateClientSecret refuses an application without an OAuth client
  instead of returning a secret it never saved, and regenerateAgentSecret
  restates the agent's delegated flag and leaves display-only fields out
  of the update. Application writes leave out the read-only status.
- getRoles, getRole, getUserTypes and getAgentTypes request the display
  data like the other getters, so organization unit handles resolve.
- Better Auth 1.7.13 for the Better Auth adapter, which fixes
  GHSA-965c-763c-88jm and GHSA-r4xp-prcw-77qf. Its provider config drops
  the `accountIssuer` that version removed and requires verified ID
  tokens.
- The Nuxt module auto-imports useManagementRequestConfig and no longer
  registers composables that do not exist.

Signed-off-by: Brion <info@brionmario.com>
@brionmario
brionmario force-pushed the feat-management-api-functions branch from 4b70f50 to 86e4217 Compare October 27, 2026 20:16
@brionmario brionmario changed the title Expose the management API as functions and keep the data hooks internal Complete the management API functions and add application components Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity/prs-raised Ports exist in the other SDKs, or are recorded as not applying there

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant