Skip to content

Build: Upgrade @hey-api/openapi-ts to 0.97#22735

Merged
leekelleher merged 7 commits into
release/18.0from
v18/feature/heyapi-0.97
May 7, 2026
Merged

Build: Upgrade @hey-api/openapi-ts to 0.97#22735
leekelleher merged 7 commits into
release/18.0from
v18/feature/heyapi-0.97

Conversation

@iOvergaard
Copy link
Copy Markdown
Contributor

Summary

Upgrades @hey-api/openapi-ts from 0.85 → 0.97 across the backoffice client, the standalone Login app, and the UmbracoExtension project template, regenerating all SDK output against the new generator.

  • Backoffice client (Umbraco.Web.UI.Client/src/packages/core): bumped to ^0.97.0 and regenerated. The new generator's byTags strategy with a class container preserves the existing {Tag}Service.{operation}() call shape we already use across the codebase.
  • Login app (Umbraco.Web.UI.Login): bumped to ^0.97.0 and regenerated.
  • Extension template (templates/UmbracoExtension/Client): bumped to ^0.97.0, simplified the plugin config to override only responseStyle: 'fields' (everything else is hey-api defaults), regenerated the pre-bundled SDK against the canonical Umbraco.Extension scaffold, and switched the entrypoint to wire the generated client through UMB_AUTH_CONTEXT.configureClient() so extensions inherit the same auth callback and default response interceptors (401 retry, error notifications) as the core backoffice. The standalone hey-api.ts runtime config file is no longer needed and has been removed. dashboard.element.ts updated to the new function-export call shape and the renamed Iuser schema type.
  • Interceptor fix (api-interceptor.controller.ts): #createResponse previously fell back to status: 0 when no upstream Response was provided, which throws RangeError from the Response constructor. Reordered the signature to #createResponse(body, originalResponse?, fallbackStatus = 500) so synthesized responses get a sensible status. Existing call sites (which all pass an originalResponse) are unchanged.

Test plan

  • npm run build and npm run lint succeed in src/Umbraco.Web.UI.Client
  • npm run build succeeds in src/Umbraco.Web.UI.Login
  • Backoffice loads and authenticated Management API calls work (token refresh + 401 retry interceptors still fire)
  • Document validation flow exercises DocumentService.putUmbracoManagementApiV1['1DocumentByIdValidate1'][1] (document-validation.server.data-source.ts) without runtime errors
  • Scaffold a fresh extension via dotnet new umbraco-extension --include-example true, run npm install + npm run generate-client, verify the regenerated SDK is byte-identical to the template's pre-bundled output (apart from the user-supplied name substitutions)
  • Verify the example dashboard's three buttons (whoAmI, whatsTheTimeMrWolf, whatsMyName) work end-to-end against a running host

Follow-ups uncovered while regenerating

Not part of this PR but flagging for the team:

  1. Scaffolded host projects fail to build with error CS9137: The 'interceptors' feature is not enabled from the .NET 10 OpenAPI source generator. Adding <InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces> to the host csproj fixes it — probably belongs in the CMS targets so every scaffolded host gets it for free.
  2. If users follow common conventions and place the extension project nested inside the host directory, the host's default **/*.cs Compile glob picks up the extension's sources and produces duplicate-type warnings. Worth either documenting the recommended layout or excluding the extension dir explicitly.

🤖 Generated with Claude Code

iOvergaard and others added 4 commits May 6, 2026 15:47
Default to a 500 fallback status when no upstream Response is provided
to #createResponse, preventing a RangeError from the Response constructor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… 0.97

- Bumps @hey-api/openapi-ts to ^0.97.0 in the extension template.
- Simplifies the generate-openapi.js plugin config: spread @hey-api defaults
  and only override @hey-api/sdk with responseStyle: 'fields' so call sites
  keep the { data, error } destructuring shape. Removes the redundant
  @hey-api/client-fetch redeclaration that triggered duplicate-plugin warnings.
- Drops the hey-api.ts runtime config file in favour of wiring the generated
  client through UMB_AUTH_CONTEXT.configureClient() from the entrypoint, so
  extensions inherit the same auth callback and default response interceptors
  (401 retry, error notifications) as the core backoffice.
- Regenerates the pre-bundled SDK against the template's canonical
  Umbraco.Extension scaffold so it matches what `npm run generate-client`
  produces on first run; default hey-api output is flat function exports.
- Updates dashboard.element.ts call sites to match the new SDK shape and
  renames the user model usage to Iuser to follow the new schema.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 6, 2026 14:28
@claude
Copy link
Copy Markdown

claude Bot commented May 6, 2026

Claude finished @iOvergaard's task in 6m 19s —— View job


PR Review

Target: origin/v18/dev · Based on commit: f8fb31f7
Skipped: 49 noise files (*.gen.ts, package-lock.json) out of 59 total

Upgrades @hey-api/openapi-ts from 0.85 → 0.97 across the backoffice client, Login app, and extension template, regenerating all SDK output. Includes an interceptor bugfix and a template architecture improvement to wire auth via configureClient().

  • Other changes: The OptionsLegacyParser type is no longer exported from client/index.ts. The generated barrel (backend-api/index.ts) now explicitly exports _1DocumentByIdValidate1 and PutUmbracoManagementApiV1 (previously re-exported indirectly via export *). Extension template generates function-based SDK exports instead of class-based.

Important

  • src/Umbraco.Web.UI.Client/src/packages/core/backend-api/index.ts:4: The generated barrel now explicitly exports _1DocumentByIdValidate1 and PutUmbracoManagementApiV1 into the public API surface of @umbraco-cms/backoffice/external/backend-api. These names are implementation details produced by the generator's encoding of the /v1.1/ path segment — _1DocumentByIdValidate1 particularly looks like a private symbol (leading underscore) but isn't, and will appear in IDE autocomplete for external plugin developers. The consumer at document-validation.server.data-source.ts:90 uses DocumentService.putUmbracoManagementApiV1['1DocumentByIdValidate1'][1] where [1] accesses a static method whose JavaScript identifier is literally the number 1 — valid but completely non-discoverable through IDE tooling and fragile under generator naming strategy changes. Consider tracking upstream with hey-api to improve identifier generation for dotted version paths, or renaming the OpenAPI path's version tag to eliminate the collision. Fix this →

Suggestions

  • src/Umbraco.Web.UI.Client/src/apps/installer/user/installer-user.element.ts:70-101: The autocomplete attribute additions (name, email, new-password) are correct and improve UX, but are unrelated to the API upgrade. Bundling unrelated changes makes it harder to isolate regressions and understand the scope of the PR.

  • templates/UmbracoExtension/Client/src/entrypoints/entrypoint.ts:15: authContext?.configureClient(client) silently skips auth setup if the context is unavailable (returns undefined). An extension developer whose client isn't being configured will see unexpected 401 errors with no obvious cause. A console.warn when authContext is falsy would help with debugging.

  • src/Umbraco.Web.UI.Client/src/packages/core/package.json: Missing newline at end of file (EOF newline removed in the diff).


Approved with Suggestions for improvement

Good to go — the upgrade is clean, the interceptor fix is correct, and the template auth wiring is a genuine improvement. The public export of _1DocumentByIdValidate1 / PutUmbracoManagementApiV1 and the [1] accessor ergonomics are worth tracking, but are a generator limitation rather than a mistake in this PR. Please carefully consider the suggestions above before merging.

…-generated

So GitHub diffs collapse the regenerated *.gen.ts files in PRs, matching what
we already do for the backoffice client and Login app SDKs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@iOvergaard iOvergaard added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code release/18.0.0 labels May 6, 2026
@claude claude Bot added the area/frontend label May 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades @hey-api/openapi-ts (0.85 → 0.97) across the backoffice client, the Login app, and the UmbracoExtension template, regenerating the generated TypeScript SDK/runtime output to match the new generator behavior. It also includes a small runtime fix in the backoffice API interceptor and a minor UX improvement in the installer user form.

Changes:

  • Bump @hey-api/openapi-ts to ^0.97.0 and regenerate SDK/runtime output for the backoffice client, Login app, and extension template.
  • Update the extension template to configure the generated client via UMB_AUTH_CONTEXT.configureClient() and remove the old runtime config file.
  • Fix UmbApiInterceptorController.#createResponse to safely synthesize Response objects when no upstream Response exists; add autocomplete attributes to installer user inputs.

Reviewed changes

Copilot reviewed 57 out of 60 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
templates/UmbracoExtension/Client/src/hey-api.ts Removes the old template runtime config hook for the generated client.
templates/UmbracoExtension/Client/src/entrypoints/entrypoint.ts Wires generated client into UMB_AUTH_CONTEXT during extension initialization.
templates/UmbracoExtension/Client/src/dashboards/dashboard.element.ts Updates example dashboard to new generated SDK function exports and renamed user type.
templates/UmbracoExtension/Client/src/api/types.gen.ts Regenerated template API types for hey-api 0.97 output format.
templates/UmbracoExtension/Client/src/api/sdk.gen.ts Regenerated template SDK (now function exports instead of a service class).
templates/UmbracoExtension/Client/src/api/index.ts Updates template API barrel exports to explicit exports.
templates/UmbracoExtension/Client/src/api/core/utils.gen.ts Regenerated core helper utilities formatting/behavior changes.
templates/UmbracoExtension/Client/src/api/core/types.gen.ts Regenerated core types (notably SSE typing and formatting updates).
templates/UmbracoExtension/Client/src/api/core/serverSentEvents.gen.ts Regenerated SSE implementation; adds line-ending normalization and refactors formatting.
templates/UmbracoExtension/Client/src/api/core/queryKeySerializer.gen.ts Regenerated deterministic query-key serialization helpers.
templates/UmbracoExtension/Client/src/api/core/pathSerializer.gen.ts Regenerated parameter serialization helpers formatting changes.
templates/UmbracoExtension/Client/src/api/core/params.gen.ts Regenerated params builder; expands field mapping capabilities.
templates/UmbracoExtension/Client/src/api/core/bodySerializer.gen.ts Regenerated serializers; tightens BodySerializer typing and adds per-parameter query options.
templates/UmbracoExtension/Client/src/api/core/auth.gen.ts Regenerated auth helpers (minor formatting refactor).
templates/UmbracoExtension/Client/src/api/client/utils.gen.ts Regenerated fetch-client utilities; adds per-parameter query serializer overrides and interceptor typing tweaks.
templates/UmbracoExtension/Client/src/api/client/types.gen.ts Regenerated client types; updates RequestResult/ResolvedRequestOptions typing.
templates/UmbracoExtension/Client/src/api/client/index.ts Removes legacy parser export in template client barrel.
templates/UmbracoExtension/Client/src/api/client/client.gen.ts Regenerated fetch client runtime implementation for hey-api 0.97.
templates/UmbracoExtension/Client/src/api/client.gen.ts Regenerated template client factory/default client instance.
templates/UmbracoExtension/Client/scripts/generate-openapi.js Simplifies plugin config and overrides only responseStyle: 'fields'; filters out default sdk plugin to override config.
templates/UmbracoExtension/Client/package.json Bumps @hey-api/openapi-ts devDependency version.
src/Umbraco.Web.UI.Login/src/api/types.gen.ts Regenerated login API types; makes several request bodies required and adjusts ProblemDetails typing.
src/Umbraco.Web.UI.Login/src/api/sdk.gen.ts Regenerated login SDK functions and Options type signature.
src/Umbraco.Web.UI.Login/src/api/index.ts Switches login API barrel to explicit exports.
src/Umbraco.Web.UI.Login/src/api/core/utils.gen.ts Regenerated login core utilities formatting tweaks.
src/Umbraco.Web.UI.Login/src/api/core/types.gen.ts Regenerated login core types formatting tweaks.
src/Umbraco.Web.UI.Login/src/api/core/serverSentEvents.gen.ts Regenerated login SSE implementation (same changes as template/client).
src/Umbraco.Web.UI.Login/src/api/core/queryKeySerializer.gen.ts Regenerated login query-key serializer formatting tweaks.
src/Umbraco.Web.UI.Login/src/api/core/pathSerializer.gen.ts Regenerated login path serializer formatting tweaks.
src/Umbraco.Web.UI.Login/src/api/core/params.gen.ts Regenerated login params builder enhancements.
src/Umbraco.Web.UI.Login/src/api/core/bodySerializer.gen.ts Regenerated login body/query serializers enhancements.
src/Umbraco.Web.UI.Login/src/api/core/auth.gen.ts Regenerated login auth helper formatting tweaks.
src/Umbraco.Web.UI.Login/src/api/client/utils.gen.ts Regenerated login client utils with query-parameter overrides and interceptor typing updates.
src/Umbraco.Web.UI.Login/src/api/client/types.gen.ts Regenerated login client types (ResolvedRequestOptions, RequestResult updates).
src/Umbraco.Web.UI.Login/src/api/client/index.ts Removes legacy parser export from login client barrel.
src/Umbraco.Web.UI.Login/src/api/client/client.gen.ts Regenerated login fetch-client runtime implementation for hey-api 0.97.
src/Umbraco.Web.UI.Login/package.json Bumps @hey-api/openapi-ts devDependency version.
src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.server.data-source.ts Updates document validation call site to new generated SDK structure for that operation.
src/Umbraco.Web.UI.Client/src/packages/core/resources/api-interceptor.controller.ts Fixes synthesized Response creation to use a sane fallback status when no upstream Response exists.
src/Umbraco.Web.UI.Client/src/packages/core/package.json Bumps @hey-api/openapi-ts devDependency version.
src/Umbraco.Web.UI.Client/src/packages/core/openapi-ts.config.js Updates SDK plugin config to new operations.strategy/byTags + class container configuration.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/index.ts Regenerated backend-api barrel from wildcard exports to explicit exports.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/utils.gen.ts Regenerated backoffice backend-api core utilities formatting tweaks.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/types.gen.ts Regenerated backoffice backend-api core types formatting tweaks.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/serverSentEvents.gen.ts Regenerated backoffice backend-api SSE implementation.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/queryKeySerializer.gen.ts Regenerated backoffice backend-api query-key serializer formatting tweaks.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/pathSerializer.gen.ts Regenerated backoffice backend-api path serializer formatting tweaks.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/params.gen.ts Regenerated backoffice backend-api params builder enhancements.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/bodySerializer.gen.ts Regenerated backoffice backend-api body/query serializers enhancements.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/core/auth.gen.ts Regenerated backoffice backend-api auth helper formatting tweaks.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/client/utils.gen.ts Regenerated backoffice backend-api client utils with query overrides and interceptor typing updates.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/client/types.gen.ts Regenerated backoffice backend-api client types (ResolvedRequestOptions, RequestResult updates).
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/client/index.ts Removes legacy parser export from backend-api client barrel.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/client/client.gen.ts Regenerated backoffice backend-api fetch-client runtime implementation for hey-api 0.97.
src/Umbraco.Web.UI.Client/src/packages/core/backend-api/client.gen.ts Regenerated backoffice backend-api default client creation formatting.
src/Umbraco.Web.UI.Client/src/apps/installer/user/installer-user.element.ts Adds autocomplete hints for name/email/password fields in installer UI.
src/Umbraco.Web.UI.Client/package-lock.json Updates lockfile to the new hey-api dependency tree (includes new Node engine requirements from hey-api packages).
Files not reviewed (2)
  • src/Umbraco.Web.UI.Client/package-lock.json: Language not supported
  • src/Umbraco.Web.UI.Login/package-lock.json: Language not supported

Comment thread templates/UmbracoExtension/Client/src/entrypoints/entrypoint.ts Outdated
Comment thread templates/UmbracoExtension/Client/src/api/client.gen.ts Outdated
Comment thread src/Umbraco.Web.UI.Login/src/api/client/client.gen.ts
Comment thread templates/UmbracoExtension/Client/src/api/client/client.gen.ts
iOvergaard and others added 2 commits May 6, 2026 16:41
- Restores the regenerated SDK's hard-coded baseUrl to https://localhost:44339/
  so the SiteDomain template token in the .template.config still substitutes
  it at scaffold time. The 5443 port leaked in from the local host I used to
  regenerate; that domain is replaced by the user's chosen SiteDomain on
  scaffold.
- Stops marking onInit as `async`. The UmbEntryPointOnInit signature returns
  void; making the hook async is harmless under TS's bivariant void-return
  assignability but is misleading. Kicks the context resolution + client
  configuration off via .then() and logs a warning when UMB_AUTH_CONTEXT is
  not present (instead of silently optional-chaining).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous tweak was based on Copilot's claim that UmbEntryPointOnInit
returns void. The signature does declare void, but the entry-point
initializer in app-entry-point-extension-initializer.ts and
backoffice-entry-point-extension-initializer.ts both `await
moduleInstance.onInit(...)`, so an async onInit is awaited end-to-end.
Reverting to async ensures configureClient runs to completion before any
element in the extension can hit the API client.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@leekelleher leekelleher enabled auto-merge (squash) May 7, 2026 08:31
@leekelleher leekelleher merged commit 4953855 into release/18.0 May 7, 2026
32 checks passed
@leekelleher leekelleher deleted the v18/feature/heyapi-0.97 branch May 7, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/frontend dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code release/18.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants