Skip to content

Commit

Permalink
chore: 🐝 Update SDK - Generate 0.16.0 (#107)
Browse files Browse the repository at this point in the history
# SDK update
Based on:
- OpenAPI Doc  
- Speakeasy CLI 1.390.7 (2.409.8)
https://github.com/speakeasy-api/speakeasy
## OpenAPI Change Summary


```
β”œβ”€β”¬Info
β”‚ └──[πŸ”€] version (4:14)
β”œβ”€β”¬Components
β”‚ └─┬partition_parameters
β”‚   β”œβ”€β”€[βž•] properties (264:17)
β”‚   └─┬strategy
β”‚     β”œβ”€β”€[πŸ”€] description (188:34)
β”‚     └──[πŸ”€] default (189:30)❌ 
└─┬Extensions
  └──[πŸ”€] x-speakeasy-retries (319:22)
```

| Document Element | Total Changes | Breaking Changes |
|------------------|---------------|------------------|
| info             | 1             | 0                |
| components       | 3             | 1                |

Co-authored-by: speakeasybot <[email protected]>
  • Loading branch information
github-actions[bot] and speakeasybot authored Sep 6, 2024
1 parent 6dbe6e4 commit f8a3dbe
Show file tree
Hide file tree
Showing 34 changed files with 515 additions and 100 deletions.
23 changes: 14 additions & 9 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
lockVersion: 2.0.0
id: f42cb8e6-e2ce-4565-b975-5a9f38b94d5a
management:
docChecksum: f9968a9b4e176b25982c5fe01966841c
docVersion: 1.0.44
speakeasyVersion: 1.360.0
generationVersion: 2.392.0
releaseVersion: 0.15.1
configChecksum: 35a1f8ef21905c725838c160f1fe7332
docChecksum: 07648fa4a81409d493b04f9a0210053a
docVersion: 1.0.48
speakeasyVersion: 1.390.7
generationVersion: 2.409.8
releaseVersion: 0.16.0
configChecksum: 7d3a89591f1ead1b1ef84078be25d23c
repoURL: https://github.com/Unstructured-IO/unstructured-js-client.git
repoSubDirectory: .
installationURL: https://github.com/Unstructured-IO/unstructured-js-client
published: true
features:
typescript:
additionalDependencies: 0.1.0
constsAndDefaults: 0.1.6
core: 3.13.0
constsAndDefaults: 0.1.11
core: 3.16.1
defaultEnabledRetries: 0.1.0
envVarSecurityUsage: 0.1.1
examples: 2.81.4
Expand All @@ -29,13 +29,15 @@ features:
retries: 2.83.0
sdkHooks: 0.1.0
serverIDs: 2.81.2
unions: 2.85.6
unions: 2.85.7
uploadStreams: 0.1.0
generatedFiles:
- src/funcs/generalPartition.ts
- src/sdk/general.ts
- src/sdk/sdk.ts
- .eslintrc.cjs
- .npmignore
- FUNCTIONS.md
- RUNTIMES.md
- jsr.json
- package.json
Expand All @@ -45,6 +47,7 @@ generatedFiles:
- src/lib/config.ts
- src/lib/dlv.ts
- src/lib/encodings.ts
- src/lib/files.ts
- src/lib/http.ts
- src/lib/is-plain-object.ts
- src/lib/logger.ts
Expand All @@ -60,11 +63,13 @@ generatedFiles:
- src/sdk/models/errors/sdkerror.ts
- src/sdk/models/errors/sdkvalidationerror.ts
- src/sdk/types/blobs.ts
- src/sdk/types/constdatetime.ts
- src/sdk/types/enums.ts
- src/sdk/types/fp.ts
- src/sdk/types/index.ts
- src/sdk/types/operations.ts
- src/sdk/types/rfcdate.ts
- src/sdk/types/streams.ts
- tsconfig.json
- src/sdk/models/operations/partition.ts
- src/sdk/models/errors/httpvalidationerror.ts
Expand Down
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
speakeasyVersion: 1.360.0
speakeasyVersion: 1.390.7
sources:
my-source:
sourceNamespace: my-source
sourceRevisionDigest: sha256:b83979814670834969e52df50f6ab136c2e4e7e9b52d14e3fc0969190799f822
sourceBlobDigest: sha256:73c84df69bf357471186697b8e9e28eac25dfda253e7729366a9e7e391d56267
sourceRevisionDigest: sha256:38f3672383baa94018f7d826c034bf0f3e25ee8ed46d70c4633fc9661441c14b
sourceBlobDigest: sha256:108f49adb0607b20fc4d54949d36599c08c87c2d19e0a40e4bd5a2b91d9ac3e3
tags:
- latest
- main
targets:
unstructed-typescript:
source: my-source
sourceNamespace: my-source
sourceRevisionDigest: sha256:b83979814670834969e52df50f6ab136c2e4e7e9b52d14e3fc0969190799f822
sourceBlobDigest: sha256:73c84df69bf357471186697b8e9e28eac25dfda253e7729366a9e7e391d56267
sourceRevisionDigest: sha256:38f3672383baa94018f7d826c034bf0f3e25ee8ed46d70c4633fc9661441c14b
sourceBlobDigest: sha256:108f49adb0607b20fc4d54949d36599c08c87c2d19e0a40e4bd5a2b91d9ac3e3
outLocation: /github/workspace/repo
workflow:
workflowVersion: 1.0.0
Expand Down
114 changes: 114 additions & 0 deletions FUNCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Standalone Functions

> [!NOTE]
> This section is useful if you are using a bundler and targetting browsers and
> runtimes where the size of an application affects performance and load times.
Every method in this SDK is also available as a standalone function. This
alternative API is suitable when targetting the browser or serverless runtimes
and using a bundler to build your application since all unused functionality
will be tree-shaken away. This includes code for unused methods, Zod schemas,
encoding helpers and response handlers. The result is dramatically smaller
impact on the application's final bundle size which grows very slowly as you use
more and more functionality from this SDK.

Calling methods through the main SDK class remains a valid and generally more
more ergonomic option. Standalone functions represent an optimisation for a
specific category of applications.

## Example

```typescript
import { openAsBlob } from "node:fs";
import { UnstructuredClientCore } from "unstructured-client/core.js";
import { generalPartition } from "unstructured-client/funcs/generalPartition.js";
import { SDKValidationError } from "unstructured-client/sdk/models/errors/sdkvalidationerror.js";
import { ChunkingStrategy, Strategy } from "unstructured-client/sdk/models/shared";

// Use `UnstructuredClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unstructuredClient = new UnstructuredClientCore();

async function run() {
const res = await generalPartition(unstructuredClient, {
partitionParameters: {
files: await openAsBlob("./sample-file"),
chunkingStrategy: ChunkingStrategy.Basic,
splitPdfPageRange: [
1,
10,
],
strategy: Strategy.HiRes,
},
});

switch (true) {
case res.ok:
// The success case will be handled outside of the switch block
break;
case res.error instanceof SDKValidationError:
// Pretty-print validation errors.
return console.log(res.error.pretty());
case res.error instanceof Error:
return console.log(res.error);
default:
// TypeScript's type checking will fail on the following line if the above
// cases were not exhaustive.
res.error satisfies never;
throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error);
}


const { value: result } = res;

// Handle the result
console.log(result)
}

run();
```

## Result types

Standalone functions differ from SDK methods in that they return a
`Result<Value, Error>` type to capture _known errors_ and document them using
the type system. By avoiding throwing errors, application code maintains clear
control flow and error-handling become part of the regular flow of application
code.

> We use the term "known errors" because standalone functions, and JavaScript
> code in general, can still throw unexpected errors such as `TypeError`s,
> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be
> something this SDK addresses in the future. Nevertheless, there is still a lot
> of benefit from capturing most errors and turning them into values.
The second reason for this style of programming is because these functions will
typically be used in front-end applications where exception throwing is
sometimes discouraged or considered unidiomatic. React and similar ecosystems
and libraries tend to promote this style of programming so that components
render useful content under all states (loading, success, error and so on).

The general pattern when calling standalone functions looks like this:

```typescript
import { Core } from "<sdk-package-name>";
import { fetchSomething } from "<sdk-package-name>/funcs/fetchSomething.js";

const client = new Core();

async function run() {
const result = await fetchSomething(client, { id: "123" });
if (!result.ok) {
// You can throw the error or handle it. It's your choice now.
throw result.error;
}

console.log(result.value);
}

run();
```

Notably, `result.error` above will have an explicit type compared to a try-catch
variation where the error in the catch block can only be of type `unknown` (or
`any` depending on your TypeScript settings).
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,56 @@ client.general.partition({
}};
```
<!-- Start Summary [summary] -->
## Summary
<!-- End Summary [summary] -->
<!-- Start Table of Contents [toc] -->
## Table of Contents
* [SDK Installation](#sdk-installation)
* [Requirements](#requirements)
* [SDK Example Usage](#sdk-example-usage)
* [Available Resources and Operations](#available-resources-and-operations)
* [Standalone functions](#standalone-functions)
* [File uploads](#file-uploads)
* [Retries](#retries)
* [Error Handling](#error-handling)
* [Server Selection](#server-selection)
* [Custom HTTP Client](#custom-http-client)
* [Authentication](#authentication)
* [Debugging](#debugging)
<!-- End Table of Contents [toc] -->
<!-- Start Requirements [requirements] -->
## Requirements
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
<!-- End Requirements [requirements] -->
<!-- Start Standalone functions [standalone-funcs] -->
## Standalone functions
All the methods listed above are available as standalone functions. These
functions are ideal for use in applications running in the browser, serverless
runtimes or other environments where application bundle size is a primary
concern. When using a bundler to build your application, all unused
functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
<details>
<summary>Available standalone functions</summary>
- [generalPartition](docs/sdks/general/README.md#partition)
</details>
<!-- End Standalone functions [standalone-funcs] -->
<!-- Start File uploads [file-upload] -->
## File uploads
Expand Down Expand Up @@ -315,7 +359,9 @@ run();
<!-- Start Debugging [debug] -->
## Debugging
To log HTTP requests and responses, you can pass a logger that matches `console`'s interface as an SDK option.
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches `console`'s interface as an SDK option.
> [!WARNING]
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,14 @@ Based on:
### Generated
- [typescript v0.15.1] .
### Releases
- [NPM v0.15.1] https://www.npmjs.com/package/unstructured-client/v/0.15.1 - .
- [NPM v0.15.1] https://www.npmjs.com/package/unstructured-client/v/0.15.1 - .

## 2024-09-06 00:26:09
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.390.7 (2.409.8) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.16.0] .
### Releases
- [NPM v0.16.0] https://www.npmjs.com/package/unstructured-client/v/0.16.0 - .
26 changes: 1 addition & 25 deletions codeSamples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,4 @@ actions:
x-codeSamples:
- lang: typescript
label: partition
source: |-
import { openAsBlob } from "node:fs";
import { UnstructuredClient } from "unstructured-client";
import { ChunkingStrategy, Strategy } from "unstructured-client/sdk/models/shared";
const unstructuredClient = new UnstructuredClient();
async function run() {
const result = await unstructuredClient.general.partition({
partitionParameters: {
files: await openAsBlob("./sample-file"),
strategy: Strategy.Auto,
chunkingStrategy: ChunkingStrategy.Basic,
splitPdfPageRange: [
1,
10,
],
},
});
// Handle the result
console.log(result)
}
run();
source: "import { openAsBlob } from \"node:fs\";\nimport { UnstructuredClient } from \"unstructured-client\";\nimport { ChunkingStrategy, Strategy } from \"unstructured-client/sdk/models/shared\";\n\nconst unstructuredClient = new UnstructuredClient();\n\nasync function run() {\n const result = await unstructuredClient.general.partition({\n partitionParameters: {\n files: await openAsBlob(\"./sample-file\"),\n strategy: Strategy.Auto,\n chunkingStrategy: ChunkingStrategy.Basic,\n splitPdfPageRange: [\n 1,\n 10,\n ],\n },\n });\n \n // Handle the result\n console.log(result)\n}\n\nrun();"
7 changes: 7 additions & 0 deletions docs/sdk/models/errors/detail.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Detail

## Example Usage

```typescript
import { Detail } from "unstructured-client/sdk/models/errors";

let value: Detail = "<value>";
```

## Supported Types

Expand Down
7 changes: 7 additions & 0 deletions docs/sdk/models/errors/httpvalidationerror.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# HTTPValidationError

## Example Usage

```typescript
import { HTTPValidationError } from "unstructured-client/sdk/models/errors";

// No examples available for this model
```

## Fields

Expand Down
7 changes: 7 additions & 0 deletions docs/sdk/models/errors/servererror.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ServerError

## Example Usage

```typescript
import { ServerError } from "unstructured-client/sdk/models/errors";

// No examples available for this model
```

## Fields

Expand Down
7 changes: 7 additions & 0 deletions docs/sdk/models/operations/partitionrequest.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# PartitionRequest

## Example Usage

```typescript
import { PartitionRequest } from "unstructured-client/sdk/models/operations";

// No examples available for this model
```

## Fields

Expand Down
Loading

0 comments on commit f8a3dbe

Please sign in to comment.