-
Notifications
You must be signed in to change notification settings - Fork 1k
refactor(sdk): remove dead code and de-duplicate SDK/CLI helpers #1766
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||||
| import type { FetchResponse } from 'openapi-fetch' | ||||||||||
|
|
||||||||||
| import { ApiClient, components, handleApiError } from './api' | ||||||||||
| import { | ||||||||||
| ClientFactory, | ||||||||||
|
|
@@ -100,6 +102,23 @@ function convertSecretInfo( | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Convert a response returning a single secret into {@link SecretInfo}, | ||||||||||
| * throwing for error responses and empty bodies. | ||||||||||
| */ | ||||||||||
| function secretInfoFromResponse(res: FetchResponse<any, any, any>): SecretInfo { | ||||||||||
| const err = handleApiError(res, SecretError) | ||||||||||
| if (err) { | ||||||||||
| throw err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!res.data) { | ||||||||||
| throw new Error('Response data is missing') | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. T-57/T-58 — one base class per domain, and prefer the specific error over a generic one: secret failures must be
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| return convertSecretInfo(res.data) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Paginator for listing secrets. | ||||||||||
| * | ||||||||||
|
|
@@ -182,16 +201,7 @@ export class Secret extends ClientFactory { | |||||||||
| signal: config.getSignal(apiOpts?.requestTimeoutMs, apiOpts?.signal), | ||||||||||
| }) | ||||||||||
|
|
||||||||||
| const err = handleApiError(res, SecretError) | ||||||||||
| if (err) { | ||||||||||
| throw err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!res.data) { | ||||||||||
| throw new Error('Response data is missing') | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return convertSecretInfo(res.data) | ||||||||||
| return secretInfoFromResponse(res) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -230,16 +240,7 @@ export class Secret extends ClientFactory { | |||||||||
| throw new SecretNotFoundError(`Secret ${secret} not found`) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const err = handleApiError(res, SecretError) | ||||||||||
| if (err) { | ||||||||||
| throw err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!res.data) { | ||||||||||
| throw new Error('Response data is missing') | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return convertSecretInfo(res.data) | ||||||||||
| return secretInfoFromResponse(res) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -272,16 +273,7 @@ export class Secret extends ClientFactory { | |||||||||
| throw new SecretNotFoundError(`Secret ${secret} not found`) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const err = handleApiError(res, SecretError) | ||||||||||
| if (err) { | ||||||||||
| throw err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!res.data) { | ||||||||||
| throw new Error('Response data is missing') | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return convertSecretInfo(res.data) | ||||||||||
| return secretInfoFromResponse(res) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T-1/T-11 — the Python mirror of this helper takes the named
Operationalias fromsignature.py, so the JS side should have the same named type rather than a third inline copy of'read' | 'write'(the other copy is insignature.ts). Exportexport type Operation = 'read' | 'write'fromsrc/sandbox/signature.ts, use it ingetSignature, and reference it here so both SDKs write the vocabulary down once.