-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Update dotnet new umbraco-extension template with newer @hey-api/openapi-ts #19825
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
iOvergaard
merged 12 commits into
umbraco:main
from
warrenbuckley:extension-template-npm-updates
Aug 20, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6ac7ae7
Updated hey-api as the client-fetch is bundled as part of @hey-api/op…
warrenbuckley b3e60be
Regenerated a new package-lock.json file
warrenbuckley c9e1345
Fix typescript issue
warrenbuckley fba8302
Merge branch 'main' into extension-template-npm-updates
warrenbuckley 1237899
Update templates/UmbracoExtension/Client/package.json
warrenbuckley f9ac340
Updated client dependencies
warrenbuckley 0acbf82
Explicitly remove package-lock.json as it will be out of sync due to …
warrenbuckley dda5472
Merge branch 'main' into extension-template-npm-updates
warrenbuckley 1e41a3f
Merge branch 'main' into extension-template-npm-updates
warrenbuckley 6a5588e
Regenerated Hey API client that now ships client rather than dependancy
warrenbuckley eeb341d
Merge branch 'extension-template-npm-updates' of https://github.com/w…
warrenbuckley 717a993
Vite and Hey-API were already out of date (updated to the very latest)
warrenbuckley 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
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
199 changes: 199 additions & 0 deletions
199
templates/UmbracoExtension/Client/src/api/client/client.gen.ts
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,199 @@ | ||
| // This file is auto-generated by @hey-api/openapi-ts | ||
|
|
||
| import type { Client, Config, ResolvedRequestOptions } from './types.gen'; | ||
| import { | ||
| buildUrl, | ||
| createConfig, | ||
| createInterceptors, | ||
| getParseAs, | ||
| mergeConfigs, | ||
| mergeHeaders, | ||
| setAuthParams, | ||
| } from './utils.gen'; | ||
|
|
||
| type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { | ||
| body?: any; | ||
| headers: ReturnType<typeof mergeHeaders>; | ||
| }; | ||
|
|
||
| export const createClient = (config: Config = {}): Client => { | ||
| let _config = mergeConfigs(createConfig(), config); | ||
|
|
||
| const getConfig = (): Config => ({ ..._config }); | ||
|
|
||
| const setConfig = (config: Config): Config => { | ||
| _config = mergeConfigs(_config, config); | ||
| return getConfig(); | ||
| }; | ||
|
|
||
| const interceptors = createInterceptors< | ||
| Request, | ||
| Response, | ||
| unknown, | ||
| ResolvedRequestOptions | ||
| >(); | ||
|
|
||
| const request: Client['request'] = async (options) => { | ||
| const opts = { | ||
| ..._config, | ||
| ...options, | ||
| fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, | ||
| headers: mergeHeaders(_config.headers, options.headers), | ||
| serializedBody: undefined, | ||
| }; | ||
|
|
||
| if (opts.security) { | ||
| await setAuthParams({ | ||
| ...opts, | ||
| security: opts.security, | ||
| }); | ||
| } | ||
|
|
||
| if (opts.requestValidator) { | ||
| await opts.requestValidator(opts); | ||
| } | ||
|
|
||
| if (opts.body && opts.bodySerializer) { | ||
| opts.serializedBody = opts.bodySerializer(opts.body); | ||
| } | ||
|
|
||
| // remove Content-Type header if body is empty to avoid sending invalid requests | ||
| if (opts.serializedBody === undefined || opts.serializedBody === '') { | ||
| opts.headers.delete('Content-Type'); | ||
| } | ||
|
|
||
| const url = buildUrl(opts); | ||
| const requestInit: ReqInit = { | ||
| redirect: 'follow', | ||
| ...opts, | ||
| body: opts.serializedBody, | ||
| }; | ||
|
|
||
| let request = new Request(url, requestInit); | ||
|
|
||
| for (const fn of interceptors.request._fns) { | ||
| if (fn) { | ||
| request = await fn(request, opts); | ||
| } | ||
| } | ||
|
|
||
| // fetch must be assigned here, otherwise it would throw the error: | ||
| // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation | ||
| const _fetch = opts.fetch!; | ||
| let response = await _fetch(request); | ||
|
|
||
| for (const fn of interceptors.response._fns) { | ||
| if (fn) { | ||
| response = await fn(response, request, opts); | ||
| } | ||
| } | ||
|
|
||
| const result = { | ||
| request, | ||
| response, | ||
| }; | ||
|
|
||
| if (response.ok) { | ||
| if ( | ||
| response.status === 204 || | ||
| response.headers.get('Content-Length') === '0' | ||
| ) { | ||
| return opts.responseStyle === 'data' | ||
| ? {} | ||
| : { | ||
| data: {}, | ||
| ...result, | ||
| }; | ||
| } | ||
|
|
||
| const parseAs = | ||
| (opts.parseAs === 'auto' | ||
| ? getParseAs(response.headers.get('Content-Type')) | ||
| : opts.parseAs) ?? 'json'; | ||
|
|
||
| let data: any; | ||
| switch (parseAs) { | ||
| case 'arrayBuffer': | ||
| case 'blob': | ||
| case 'formData': | ||
| case 'json': | ||
| case 'text': | ||
| data = await response[parseAs](); | ||
| break; | ||
| case 'stream': | ||
| return opts.responseStyle === 'data' | ||
| ? response.body | ||
| : { | ||
| data: response.body, | ||
| ...result, | ||
| }; | ||
| } | ||
|
|
||
| if (parseAs === 'json') { | ||
| if (opts.responseValidator) { | ||
| await opts.responseValidator(data); | ||
| } | ||
|
|
||
| if (opts.responseTransformer) { | ||
| data = await opts.responseTransformer(data); | ||
| } | ||
| } | ||
|
|
||
| return opts.responseStyle === 'data' | ||
| ? data | ||
| : { | ||
| data, | ||
| ...result, | ||
| }; | ||
| } | ||
|
|
||
| const textError = await response.text(); | ||
| let jsonError: unknown; | ||
|
|
||
| try { | ||
| jsonError = JSON.parse(textError); | ||
| } catch { | ||
| // noop | ||
| } | ||
|
|
||
| const error = jsonError ?? textError; | ||
| let finalError = error; | ||
|
|
||
| for (const fn of interceptors.error._fns) { | ||
| if (fn) { | ||
| finalError = (await fn(error, response, request, opts)) as string; | ||
| } | ||
| } | ||
|
|
||
| finalError = finalError || ({} as string); | ||
|
|
||
| if (opts.throwOnError) { | ||
| throw finalError; | ||
| } | ||
|
|
||
| // TODO: we probably want to return error and improve types | ||
| return opts.responseStyle === 'data' | ||
| ? undefined | ||
| : { | ||
| error: finalError, | ||
| ...result, | ||
| }; | ||
| }; | ||
|
|
||
| return { | ||
| buildUrl, | ||
| connect: (options) => request({ ...options, method: 'CONNECT' }), | ||
| delete: (options) => request({ ...options, method: 'DELETE' }), | ||
| get: (options) => request({ ...options, method: 'GET' }), | ||
| getConfig, | ||
| head: (options) => request({ ...options, method: 'HEAD' }), | ||
| interceptors, | ||
| options: (options) => request({ ...options, method: 'OPTIONS' }), | ||
| patch: (options) => request({ ...options, method: 'PATCH' }), | ||
| post: (options) => request({ ...options, method: 'POST' }), | ||
| put: (options) => request({ ...options, method: 'PUT' }), | ||
| request, | ||
| setConfig, | ||
| trace: (options) => request({ ...options, method: 'TRACE' }), | ||
| }; | ||
| }; |
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,25 @@ | ||
| // This file is auto-generated by @hey-api/openapi-ts | ||
|
|
||
| export type { Auth } from '../core/auth.gen'; | ||
| export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; | ||
| export { | ||
| formDataBodySerializer, | ||
| jsonBodySerializer, | ||
| urlSearchParamsBodySerializer, | ||
| } from '../core/bodySerializer.gen'; | ||
| export { buildClientParams } from '../core/params.gen'; | ||
| export { createClient } from './client.gen'; | ||
| export type { | ||
| Client, | ||
| ClientOptions, | ||
| Config, | ||
| CreateClientConfig, | ||
| Options, | ||
| OptionsLegacyParser, | ||
| RequestOptions, | ||
| RequestResult, | ||
| ResolvedRequestOptions, | ||
| ResponseStyle, | ||
| TDataShape, | ||
| } from './types.gen'; | ||
| export { createConfig, mergeHeaders } from './utils.gen'; |
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.