Skip to content

Commit 1bbf695

Browse files
chore: 🐝 Update SDK - Generate (#91)
# SDK update Based on: - OpenAPI Doc - Speakeasy CLI 1.335.0 (2.370.2) https://github.com/speakeasy-api/speakeasy ## OpenAPI Change Summary ## TYPESCRIPT CHANGELOG ## nameOverrides: 2.81.2 - 2024-03-25 ### 🐛 Bug Fixes - x-speakeasy-name-overrides being missed when used under an allOf *(commit by [@ThomasRooney](https://github.com/ThomasRooney))* ## core: 3.11.6 - 2024-07-09 ### 🐛 Bug Fixes - Use 0666 file mode for writing configuration and lock files *(commit by [@bflad](https://github.com/bflad))* ## examples: 2.81.4 - 2024-04-30 ### 🎨 Code Style Changes - Remove unnecessary semicolon *(commit by [@AshGodfrey](https://github.com/AshGodfrey))* ## constsAndDefaults: 0.1.5 - 2024-03-01 ### 🐛 Bug Fixes - null enums are coerced into null consts *(commit by [@disintegrator](https://github.com/disintegrator))* ## serverIDs: 2.81.2 - 2023-10-23 ### 🐛 Bug Fixes - support both x-speakeasy-server-id and server variables *(commit by [@ThomasRooney](https://github.com/ThomasRooney))* ## defaultEnabledRetries: 0.1.0 - 2024-07-11 ### 🐝 New Features - always allow users to pass a retry policy when calling an SDK methods *(commit by [@disintegrator](https://github.com/disintegrator))* ## unions: 2.85.5 - 2024-05-16 ### 🐛 Bug Fixes - fixed handling of circular union references *(commit by [@TristanSpeakEasy](https://github.com/tristanspeakeasy))* ## openEnums: 0.1.1 - 2024-06-27 ### 🐛 Bug Fixes - add missing imports for open enums in TS *(commit by [@disintegrator](https://github.com/disintegrator))* ## globalServerURLs: 2.82.4 - 2024-03-06 ### 🔧 Chores - expand server selection test coverage *(commit by [@2ynn](https://github.com/2ynn))* ## responseFormat: 0.2.3 - 2024-03-27 ### 🐛 Bug Fixes - flat response format to work when operations contain empty responses *(commit by [@disintegrator](https://github.com/disintegrator))* ## retries: 2.83.0 - 2024-02-12 ### 🐝 New Features - read retry-after header in typescriptv2 *(commit by [@ryan-timothy-albert](https://github.com/ryan-timothy-albert))* ## globalSecurity: 2.82.9 - 2024-04-01 ### 🐛 Bug Fixes - TSv2 security compilation *(commit by [@chase-crumbaugh](https://github.com/chase-crumbaugh))* Co-authored-by: speakeasybot <[email protected]>
1 parent 804a361 commit 1bbf695

File tree

10 files changed

+107
-69
lines changed

10 files changed

+107
-69
lines changed

.speakeasy/gen.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ id: f42cb8e6-e2ce-4565-b975-5a9f38b94d5a
33
management:
44
docChecksum: 3f2fbf3f00965b046a501b0642259d4e
55
docVersion: 1.0.39
6-
speakeasyVersion: 1.330.0
7-
generationVersion: 2.361.10
8-
releaseVersion: 0.12.0
9-
configChecksum: d7fea18f81ca96b0f79ee5eb84463306
6+
speakeasyVersion: 1.335.0
7+
generationVersion: 2.370.2
8+
releaseVersion: 0.13.0
9+
configChecksum: 42aa478608bdf1332898ea475f2c41ad
1010
repoURL: https://github.com/Unstructured-IO/unstructured-js-client.git
1111
repoSubDirectory: .
1212
installationURL: https://github.com/Unstructured-IO/unstructured-js-client
@@ -15,7 +15,8 @@ features:
1515
typescript:
1616
additionalDependencies: 0.1.0
1717
constsAndDefaults: 0.1.5
18-
core: 3.11.5
18+
core: 3.11.6
19+
defaultEnabledRetries: 0.1.0
1920
examples: 2.81.4
2021
globalSecurity: 2.82.9
2122
globalSecurityCallbacks: 0.1.0

.speakeasy/workflow.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
speakeasyVersion: 1.330.0
1+
speakeasyVersion: 1.335.0
22
sources:
33
my-source:
44
sourceNamespace: my-source
5-
sourceRevisionDigest: sha256:a6a17fc122fce52ae3601b08bffe8294b5d355d1b5370390192536c856f475da
6-
sourceBlobDigest: sha256:c85052e891c341ae0a33a0bc0e21498d897649af7c1d1fa7638da4a857eb4d49
5+
sourceRevisionDigest: sha256:1320eaa3fcc76a80f0eb1ae5b1911b76e3bf7027c01415145bfbd6bee3e3f853
6+
sourceBlobDigest: sha256:f079320c7561160783552dcc1331f166de988922dd9bdb108df9625279ca3002
77
tags:
88
- latest
99
- main
1010
targets:
1111
unstructed-typescript:
1212
source: my-source
1313
sourceNamespace: my-source
14-
sourceRevisionDigest: sha256:a6a17fc122fce52ae3601b08bffe8294b5d355d1b5370390192536c856f475da
15-
sourceBlobDigest: sha256:c85052e891c341ae0a33a0bc0e21498d897649af7c1d1fa7638da4a857eb4d49
14+
sourceRevisionDigest: sha256:1320eaa3fcc76a80f0eb1ae5b1911b76e3bf7027c01415145bfbd6bee3e3f853
15+
sourceBlobDigest: sha256:f079320c7561160783552dcc1331f166de988922dd9bdb108df9625279ca3002
1616
outLocation: /github/workspace/repo
1717
workflow:
1818
workflowVersion: 1.0.0

RELEASES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,14 @@ Based on:
364364
### Generated
365365
- [typescript v0.12.0] .
366366
### Releases
367-
- [NPM v0.12.0] https://www.npmjs.com/package/unstructured-client/v/0.12.0 - .
367+
- [NPM v0.12.0] https://www.npmjs.com/package/unstructured-client/v/0.12.0 - .
368+
369+
## 2024-07-13 00:24:00
370+
### Changes
371+
Based on:
372+
- OpenAPI Doc
373+
- Speakeasy CLI 1.335.0 (2.370.2) https://github.com/speakeasy-api/speakeasy
374+
### Generated
375+
- [typescript v0.13.0] .
376+
### Releases
377+
- [NPM v0.13.0] https://www.npmjs.com/package/unstructured-client/v/0.13.0 - .

gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ generation:
1010
auth:
1111
oAuth2ClientCredentialsEnabled: false
1212
typescript:
13-
version: 0.12.0
13+
version: 0.13.0
1414
additionalDependencies:
1515
dependencies:
1616
async: ^3.2.5

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{
44
"name": "unstructured-client",
5-
"version": "0.12.0",
5+
"version": "0.13.0",
66
"exports": {
77
".": "./src/index.ts",
88
"./sdk/models/errors": "./src/sdk/models/errors/index.ts",

package-lock.json

Lines changed: 2 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unstructured-client",
3-
"version": "0.12.0",
3+
"version": "0.13.0",
44
"author": "Unstructured",
55
"main": "./index.js",
66
"sideEffects": false,
@@ -20,7 +20,6 @@
2020
"devDependencies": {
2121
"@types/async": "^3.2.24",
2222
"@types/jest": "^29.5.12",
23-
"@types/jsonpath": "^0.2.4",
2423
"@typescript-eslint/eslint-plugin": "^7.7.1",
2524
"@typescript-eslint/parser": "^7.7.1",
2625
"eslint": "^8.57.0",

src/lib/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export type SDKOptions = {
4242
* Allows overriding the default retry config used by the SDK
4343
*/
4444
retryConfig?: RetryConfig;
45+
timeoutMs?: number;
4546
};
4647

4748
export function serverURLFromOptions(options: SDKOptions): URL | null {
@@ -61,7 +62,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
6162
export const SDK_METADATA = {
6263
language: "typescript",
6364
openapiDocVersion: "1.0.39",
64-
sdkVersion: "0.12.0",
65-
genVersion: "2.361.10",
66-
userAgent: "speakeasy-sdk/typescript 0.12.0 2.361.10 1.0.39 unstructured-client",
65+
sdkVersion: "0.13.0",
66+
genVersion: "2.370.2",
67+
userAgent: "speakeasy-sdk/typescript 0.13.0 2.370.2 1.0.39 unstructured-client",
6768
} as const;

src/lib/sdks.ts

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http.js";
66
import { SecurityState, resolveSecurity, resolveGlobalSecurity } from "./security.js";
7+
import { retry, RetryConfig } from "./retries.js";
78
import { pathToFunc } from "./url.js";
89
import { encodeForm } from "./encodings.js";
910
import { stringToBase64 } from "./base64.js";
@@ -12,6 +13,24 @@ import { SDKHooks } from "../hooks/hooks.js";
1213
import { HookContext } from "../hooks/types.js";
1314

1415
export type RequestOptions = {
16+
/**
17+
* Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If
18+
* `fetchOptions.signal` is set then it will take precedence over this option.
19+
*/
20+
timeoutMs?: number;
21+
/**
22+
* Set or override a retry policy on HTTP calls.
23+
*/
24+
retries?: RetryConfig;
25+
/**
26+
* Specifies the status codes which should be retried using the given retry policy.
27+
*/
28+
retryCodes?: string[];
29+
/**
30+
* Sets various request options on the `fetch` call made by an SDK method.
31+
*
32+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request}
33+
*/
1534
fetchOptions?: Omit<RequestInit, "method" | "body">;
1635
};
1736

@@ -24,6 +43,7 @@ type RequestConfig = {
2443
headers?: HeadersInit;
2544
security?: SecurityState | null;
2645
uaHeader?: string;
46+
timeoutMs?: number;
2747
};
2848

2949
const gt: unknown = typeof globalThis === "undefined" ? null : globalThis;
@@ -119,10 +139,20 @@ export class ClientSDK {
119139
headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent);
120140
}
121141

142+
let fetchOptions = options?.fetchOptions;
143+
if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
144+
const timeoutSignal = AbortSignal.timeout(conf.timeoutMs);
145+
if (!fetchOptions) {
146+
fetchOptions = { signal: timeoutSignal };
147+
} else {
148+
fetchOptions.signal = timeoutSignal;
149+
}
150+
}
151+
122152
const input = this.hooks$.beforeCreateRequest(context, {
123153
url: reqURL,
124154
options: {
125-
...options?.fetchOptions,
155+
...fetchOptions,
126156
body: conf.body ?? null,
127157
headers,
128158
method,
@@ -133,27 +163,40 @@ export class ClientSDK {
133163
}
134164

135165
protected async do$(
136-
req: Request,
166+
request: Request,
137167
options: {
138168
context: HookContext;
139169
errorCodes: number | string | (number | string)[];
170+
retryConfig?: RetryConfig | undefined;
171+
retryCodes?: string[] | undefined;
140172
}
141173
): Promise<Response> {
142174
const { context, errorCodes } = options;
143-
144-
let response = await this.client.request(await this.hooks$.beforeRequest(context, req));
145-
146-
if (matchStatusCode(response, errorCodes)) {
147-
const result = await this.hooks$.afterError(context, response, null);
148-
if (result.error) {
149-
throw result.error;
150-
}
151-
response = result.response || response;
152-
} else {
153-
response = await this.hooks$.afterSuccess(context, response);
154-
}
155-
156-
return response;
175+
const retryConfig = options.retryConfig || { strategy: "none" };
176+
const retryCodes = options.retryCodes || [];
177+
178+
return retry(
179+
async () => {
180+
const req = request.clone();
181+
182+
let response = await this.client.request(
183+
await this.hooks$.beforeRequest(context, req)
184+
);
185+
186+
if (matchStatusCode(response, errorCodes)) {
187+
const result = await this.hooks$.afterError(context, response, null);
188+
if (result.error) {
189+
throw result.error;
190+
}
191+
response = result.response || response;
192+
} else {
193+
response = await this.hooks$.afterSuccess(context, response);
194+
}
195+
196+
return response;
197+
},
198+
{ config: retryConfig, statusCodes: retryCodes }
199+
);
157200
}
158201

159202
protected matcher<Result>(): ResponseMatcher<Result> {

src/sdk/general.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SDKHooks } from "../hooks/hooks.js";
66
import { SDKOptions, serverURLFromOptions } from "../lib/config.js";
77
import { encodeSimple as encodeSimple$ } from "../lib/encodings.js";
88
import { HTTPClient } from "../lib/http.js";
9-
import * as retries$ from "../lib/retries.js";
109
import * as schemas$ from "../lib/schemas.js";
1110
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
1211
import * as errors from "./models/errors/index.js";
@@ -48,7 +47,7 @@ export class General extends ClientSDK {
4847
*/
4948
async partition(
5049
request: operations.PartitionRequest,
51-
options?: RequestOptions & { retries?: retries$.RetryConfig }
50+
options?: RequestOptions
5251
): Promise<operations.PartitionResponse> {
5352
const input$ = request;
5453

@@ -228,29 +227,27 @@ export class General extends ClientSDK {
228227
headers: headers$,
229228
query: query$,
230229
body: body$,
230+
timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1,
231231
},
232232
options
233233
);
234234

235-
const retryConfig = options?.retries ||
236-
this.options$.retryConfig || {
237-
strategy: "backoff",
238-
backoff: {
239-
initialInterval: 500,
240-
maxInterval: 60000,
241-
exponent: 1.5,
242-
maxElapsedTime: 900000,
235+
const response = await this.do$(request$, {
236+
context,
237+
errorCodes: ["422", "4XX", "5XX"],
238+
retryConfig: options?.retries ||
239+
this.options$.retryConfig || {
240+
strategy: "backoff",
241+
backoff: {
242+
initialInterval: 500,
243+
maxInterval: 60000,
244+
exponent: 1.5,
245+
maxElapsedTime: 900000,
246+
},
247+
retryConnectionErrors: true,
243248
},
244-
retryConnectionErrors: true,
245-
};
246-
247-
const response = await retries$.retry(
248-
() => {
249-
const cloned = request$.clone();
250-
return this.do$(cloned, { context, errorCodes: ["422", "4XX", "5XX"] });
251-
},
252-
{ config: retryConfig, statusCodes: ["5xx"] }
253-
);
249+
retryCodes: options?.retryCodes || ["5xx"],
250+
});
254251

255252
const responseFields$ = {
256253
ContentType: response.headers.get("content-type") ?? "application/octet-stream",

0 commit comments

Comments
 (0)