Skip to content

Commit

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

chore: 🐝 Update SDK - Generate THIRD-TARGET 0.2.0
  • Loading branch information
ryan-timothy-albert authored Sep 3, 2024
2 parents 4cf3cf3 + b8a4ee0 commit a60de5a
Show file tree
Hide file tree
Showing 69 changed files with 2,389 additions and 968 deletions.
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
speakeasyVersion: 1.320.0
speakeasyVersion: 1.386.0
sources:
petstore:
sourceNamespace: petstore
sourceRevisionDigest: sha256:4a8c53aa372a12ba7286627d4aedfa8519b22e90f5078986354eccac2517b323
sourceBlobDigest: sha256:c98884351f4dbd0082c2aab44206c8b17385357097608a34ba00ed234d451247
sourceRevisionDigest: sha256:b23d2e4295b237e0a0c3dd7f974793d6673f9b1e245251a175f02a8bb69787be
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
tags:
- latest
- main
Expand All @@ -23,8 +23,8 @@ targets:
third-target:
source: petstore
sourceNamespace: petstore
sourceRevisionDigest: sha256:4a8c53aa372a12ba7286627d4aedfa8519b22e90f5078986354eccac2517b323
sourceBlobDigest: sha256:c98884351f4dbd0082c2aab44206c8b17385357097608a34ba00ed234d451247
sourceRevisionDigest: sha256:b23d2e4295b237e0a0c3dd7f974793d6673f9b1e245251a175f02a8bb69787be
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
outLocation: ts
workflow:
workflowVersion: 1.0.0
Expand Down
6 changes: 6 additions & 0 deletions ts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/funcs
/core.*
/esm
/dist
/.tshy
/.tshy-*
/models
/models/errors
/types
Expand Down
2 changes: 2 additions & 0 deletions ts/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@

/.eslintrc.js
/cjs
/.tshy
/.tshy-*
26 changes: 21 additions & 5 deletions ts/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,62 @@ id: f4be10ce-8651-4157-98c6-d75e2342372f
management:
docChecksum: 1bdb7a6f8bf3995d4b40475228403253
docVersion: 1.0.0
speakeasyVersion: 1.320.0
generationVersion: 2.354.1
releaseVersion: 0.1.3
configChecksum: 1552f23964d9ccd2f55c761daa8183c5
speakeasyVersion: 1.386.0
generationVersion: 2.407.2
releaseVersion: 0.2.0
configChecksum: 27613f0fb383aea1039a3e8685c9adbd
repoURL: https://github.com/ryan-timothy-albert/multi-sdk-sample.git
repoSubDirectory: ts
installationURL: https://gitpkg.now.sh/ryan-timothy-albert/multi-sdk-sample/ts
published: true
features:
typescript:
additionalDependencies: 0.1.0
core: 3.10.2
core: 3.14.2
defaultEnabledRetries: 0.1.0
envVarSecurityUsage: 0.1.1
flattening: 2.81.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 @@ -67,9 +81,11 @@ generatedFiles:
- docs/models/components/pet.md
- docs/models/components/httpmetadata.md
- docs/sdks/ryts/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
3 changes: 2 additions & 1 deletion ts/.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.1.3
version: 0.2.0
additionalDependencies:
dependencies: {}
devDependencies: {}
Expand All @@ -33,6 +33,7 @@ typescript:
inputModelSuffix: input
maxMethodParams: 4
methodArguments: require-security-and-request
moduleFormat: commonjs
outputModelSuffix: output
packageName: ryan-test-1
responseFormat: envelope-http
Expand Down
26 changes: 26 additions & 0 deletions ts/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 ts/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 { RyTsCore } from "ryan-test-1/core.js";
import { petsListPets } from "ryan-test-1/funcs/petsListPets.js";
import { SDKValidationError } from "ryan-test-1/models/errors/sdkvalidationerror.js";

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

async function run() {
const res = await petsListPets(ryTs);

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).
Loading

0 comments on commit a60de5a

Please sign in to comment.