Skip to content

Commit

Permalink
Merge pull request #11 from ryan-timothy-albert/speakeasy-sdk-regen-1…
Browse files Browse the repository at this point in the history
…721145847

chore: 🐝 Update SDK - Generate FINANCE 0.1.0
  • Loading branch information
ryan-timothy-albert committed Aug 24, 2024
2 parents bc3e659 + b01f5d9 commit 635ea9f
Show file tree
Hide file tree
Showing 64 changed files with 2,214 additions and 884 deletions.
8 changes: 4 additions & 4 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ speakeasyVersion: 1.378.0
sources:
source1:
sourceNamespace: source-1
sourceRevisionDigest: sha256:b10f42b98e93f276d95389485343c2098b4f4971499b2a3a75a1ccd4874e8407
sourceRevisionDigest: sha256:429d7585fe3e0d880661c3f9df4fcb1705c94bf4bf705fd516aaa2a030a93dd1
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
tags:
- latest
Expand All @@ -17,9 +17,9 @@ targets:
finance:
source: source1
sourceNamespace: source-1
sourceRevisionDigest: sha256:7888ff64b55debf12a4956f902014ac3b3915c2121d71e54dc098efe1baea462
sourceBlobDigest: sha256:9aca1349a1b742af9714ce27e0b65a5a7a8e4672a57e9aba3580b520cbc83427
outLocation: finance
sourceRevisionDigest: sha256:429d7585fe3e0d880661c3f9df4fcb1705c94bf4bf705fd516aaa2a030a93dd1
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
outLocation: ./finance
lending:
source: source1
sourceNamespace: source-1
Expand Down
2 changes: 2 additions & 0 deletions finance/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/funcs
/core.*
/models
/models/errors
/types
Expand Down
26 changes: 21 additions & 5 deletions finance/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,61 @@ id: 5b68364e-620c-4c04-8117-a75f11dd6079
management:
docChecksum: 1bdb7a6f8bf3995d4b40475228403253
docVersion: 1.0.0
speakeasyVersion: 1.326.0
generationVersion: 2.359.0
releaseVersion: 0.0.3
configChecksum: faccd0b9715040230ee64732c925d97e
speakeasyVersion: 1.378.0
generationVersion: 2.404.3
releaseVersion: 0.1.0
configChecksum: c77aaece2b35f042875d813684c7a3a2
repoURL: https://github.com/ryan-timothy-albert/sample-ts-monorepo.git
repoSubDirectory: finance
installationURL: https://gitpkg.now.sh/ryan-timothy-albert/sample-ts-monorepo/finance
published: true
features:
typescript:
additionalDependencies: 0.1.0
core: 3.11.0
core: 3.14.1
defaultEnabledRetries: 0.1.0
envVarSecurityUsage: 0.1.1
globalSecurityCallbacks: 0.1.0
globalServerURLs: 2.82.4
responseFormat: 0.2.3
retries: 2.83.0
sdkHooks: 0.1.0
generatedFiles:
- src/funcs/petsListPets.ts
- src/funcs/petsCreatePets.ts
- src/funcs/petsShowPetById.ts
- src/sdk/pets.ts
- src/sdk/sdk.ts
- .eslintrc.cjs
- .npmignore
- FUNCTIONS.md
- RUNTIMES.md
- jsr.json
- package.json
- src/core.ts
- src/index.ts
- src/lib/base64.ts
- src/lib/config.ts
- src/lib/dlv.ts
- src/lib/encodings.ts
- src/lib/http.ts
- src/lib/is-plain-object.ts
- src/lib/logger.ts
- src/lib/matchers.ts
- src/lib/primitives.ts
- src/lib/retries.ts
- src/lib/schemas.ts
- src/lib/sdks.ts
- src/lib/security.ts
- src/lib/url.ts
- src/sdk/index.ts
- src/models/errors/httpclienterrors.ts
- src/models/errors/sdkerror.ts
- src/models/errors/sdkvalidationerror.ts
- src/types/blobs.ts
- src/types/constdatetime.ts
- src/types/enums.ts
- src/types/fp.ts
- src/types/index.ts
- src/types/operations.ts
- src/types/rfcdate.ts
Expand All @@ -63,9 +77,11 @@ generatedFiles:
- docs/models/components/pet.md
- docs/models/components/errort.md
- docs/sdks/financesdk/README.md
- docs/lib/utils/retryconfig.md
- docs/sdks/pets/README.md
- USAGE.md
- .gitattributes
- src/hooks/hooks.ts
- src/hooks/types.ts
- src/hooks/index.ts
- CONTRIBUTING.md
2 changes: 1 addition & 1 deletion finance/.speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
typescript:
version: 0.0.3
version: 0.1.0
additionalDependencies:
dependencies: {}
devDependencies: {}
Expand Down
26 changes: 26 additions & 0 deletions finance/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing to This Repository

Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements.

## How to Report Issues

If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes:

- A clear and descriptive title
- Steps to reproduce the issue
- Expected and actual behavior
- Any relevant logs, screenshots, or error messages
- Information about your environment (e.g., operating system, software versions)
- For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed

## Issue Triage and Upstream Fixes

We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code.

## Contact

If you have any questions or need further assistance, please feel free to reach out by opening an issue.

Thank you for your understanding and cooperation!

The Maintainers
102 changes: 102 additions & 0 deletions finance/FUNCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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 { FinanceSDKCore } from "ryan-finance/core.js";
import { petsListPets } from "ryan-finance/funcs/petsListPets.js";
import { SDKValidationError } from "ryan-finance/models/errors/sdkvalidationerror.js";

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

async function run() {
const res = await petsListPets(financeSDK, {});

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).
105 changes: 105 additions & 0 deletions finance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,111 @@ const sdk = new FinanceSDK({ httpClient });
```
<!-- End Custom HTTP Client [http-client] -->

<!-- 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>

- [petsCreatePets](docs/sdks/pets/README.md#createpets)
- [petsListPets](docs/sdks/pets/README.md#listpets)
- [petsShowPetById](docs/sdks/pets/README.md#showpetbyid)


</details>
<!-- End Standalone functions [standalone-funcs] -->

<!-- Start Retries [retries] -->
## Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
```typescript
import { FinanceSDK } from "ryan-finance";

const financeSDK = new FinanceSDK();

async function run() {
const result = await financeSDK.pets.listPets(
{},
{
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
}
);

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

run();

```

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
```typescript
import { FinanceSDK } from "ryan-finance";

const financeSDK = new FinanceSDK({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});

async function run() {
const result = await financeSDK.pets.listPets({});

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

run();

```
<!-- End Retries [retries] -->

<!-- Start Debugging [debug] -->
## Debugging

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.
```typescript
import { FinanceSDK } from "ryan-finance";

const sdk = new FinanceSDK({ debugLogger: console });
```
<!-- End Debugging [debug] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

# Development
Expand Down
10 changes: 9 additions & 1 deletion finance/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ Based on:
### Generated
- [typescript v0.0.3] finance
### Releases
- [NPM v0.0.3] https://www.npmjs.com/package/ryan-finance/v/0.0.3 - finance
- [NPM v0.0.3] https://www.npmjs.com/package/ryan-finance/v/0.0.3 - finance

## 2024-08-24 01:14:59
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.378.0 (2.404.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.1.0] finance
2 changes: 1 addition & 1 deletion finance/RUNTIMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This SDK is intended to be used in JavaScript runtimes that support the following features:

* [Web Fetch API][web-fetch]
* [Web Streams API](web-streams) and in particular `ReadableStream`
* [Web Streams API][web-streams] and in particular `ReadableStream`
* [Async iterables][async-iter] using `Symbol.asyncIterator`

[web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Expand Down
Loading

0 comments on commit 635ea9f

Please sign in to comment.