Skip to content

Commit

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

chore: 🐝 Update SDK - Generate THIRD-TARGET 0.3.0
  • Loading branch information
ryan-timothy-albert authored Sep 3, 2024
2 parents a60de5a + f1a963d commit 5319611
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
speakeasyVersion: 1.386.0
speakeasyVersion: 1.389.1
sources:
petstore:
sourceNamespace: petstore
sourceRevisionDigest: sha256:b23d2e4295b237e0a0c3dd7f974793d6673f9b1e245251a175f02a8bb69787be
sourceRevisionDigest: sha256:145cb6c7453343c769be7b7c98ee52ce2263365b0f18d89584458e36079d9647
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
tags:
- latest
Expand All @@ -23,7 +23,7 @@ targets:
third-target:
source: petstore
sourceNamespace: petstore
sourceRevisionDigest: sha256:b23d2e4295b237e0a0c3dd7f974793d6673f9b1e245251a175f02a8bb69787be
sourceRevisionDigest: sha256:145cb6c7453343c769be7b7c98ee52ce2263365b0f18d89584458e36079d9647
sourceBlobDigest: sha256:7c35756702030633a8d2ebb1d378d34f883126319b06edcd798ac7bb2fddb189
outLocation: ts
workflow:
Expand Down
12 changes: 7 additions & 5 deletions ts/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ id: f4be10ce-8651-4157-98c6-d75e2342372f
management:
docChecksum: 1bdb7a6f8bf3995d4b40475228403253
docVersion: 1.0.0
speakeasyVersion: 1.386.0
generationVersion: 2.407.2
releaseVersion: 0.2.0
configChecksum: 27613f0fb383aea1039a3e8685c9adbd
speakeasyVersion: 1.389.1
generationVersion: 2.409.0
releaseVersion: 0.3.0
configChecksum: faaa20b2350ac2b25e59b50425d3b460
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.14.2
core: 3.16.0
defaultEnabledRetries: 0.1.0
envVarSecurityUsage: 0.1.1
flattening: 2.81.1
Expand All @@ -41,6 +41,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 @@ -62,6 +63,7 @@ generatedFiles:
- src/types/index.ts
- src/types/operations.ts
- src/types/rfcdate.ts
- src/types/streams.ts
- tsconfig.json
- src/models/operations/listpets.ts
- src/models/operations/createpets.ts
Expand Down
2 changes: 1 addition & 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.2.0
version: 0.3.0
additionalDependencies:
dependencies: {}
devDependencies: {}
Expand Down
12 changes: 11 additions & 1 deletion ts/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ Based on:
### Generated
- [typescript v0.2.0] ts
### Releases
- [NPM v0.2.0] https://www.npmjs.com/package/ryan-test-1/v/0.2.0 - ts
- [NPM v0.2.0] https://www.npmjs.com/package/ryan-test-1/v/0.2.0 - ts

## 2024-09-03 20:28:30
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.389.1 (2.409.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.3.0] ts
### Releases
- [NPM v0.3.0] https://www.npmjs.com/package/ryan-test-1/v/0.3.0 - ts
2 changes: 1 addition & 1 deletion ts/jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "ryan-test-1",
"version": "0.2.0",
"version": "0.3.0",
"exports": {
".": "./src/index.ts",
"./models/errors": "./src/models/errors/index.ts",
Expand Down
22 changes: 20 additions & 2 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ryan-test-1",
"version": "0.2.0",
"version": "0.3.0",
"author": "ryantimalbert",
"main": "./index.js",
"sideEffects": false,
Expand All @@ -18,6 +18,7 @@
"zod": ">= 3"
},
"devDependencies": {
"@types/node": "^18.19.3",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"eslint": "^8.57.0",
Expand Down
1 change: 1 addition & 0 deletions ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

export * from "./sdk/sdk.js";
export * from "./lib/config.js";
export * as files from "./lib/files.js";
6 changes: 3 additions & 3 deletions ts/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
export const SDK_METADATA = {
language: "typescript",
openapiDocVersion: "1.0.0",
sdkVersion: "0.2.0",
genVersion: "2.407.2",
userAgent: "speakeasy-sdk/typescript 0.2.0 2.407.2 1.0.0 ryan-test-1",
sdkVersion: "0.3.0",
genVersion: "2.409.0",
userAgent: "speakeasy-sdk/typescript 0.3.0 2.409.0 1.0.0 ryan-test-1",
} as const;
58 changes: 58 additions & 0 deletions ts/src/lib/files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/

import { Readable } from "stream";
import { createReadStream } from "fs";
import { readFile } from "fs/promises";

export function toStream(filePath: string): ReadableStream<Uint8Array> {
return Readable.toWeb(
createReadStream(filePath),
) as ReadableStream<Uint8Array>;
}

export async function toByteArray(filePath: string): Promise<Buffer> {
return readFile(filePath);
}

export async function toString(filePath: string): Promise<string> {
return readFile(filePath, "utf8");
}

/**
* Consumes a stream and returns a concatenated array buffer. Useful in
* situations where we need to read the whole file because it forms part of a
* larger payload containing other fields, and we can't modify the underlying
* request structure.
*/
export async function readableStreamToArrayBuffer(
readable: ReadableStream<Uint8Array>,
): Promise<ArrayBuffer> {
const reader = readable.getReader();
const chunks: Uint8Array[] = [];

let totalLength = 0;
let done = false;

while (!done) {
const { value, done: doneReading } = await reader.read();

if (doneReading) {
done = true;
} else {
chunks.push(value);
totalLength += value.length;
}
}

const concatenatedChunks = new Uint8Array(totalLength);
let offset = 0;

for (const chunk of chunks) {
concatenatedChunks.set(chunk, offset);
offset += chunk.length;
}

return concatenatedChunks.buffer;
}
12 changes: 12 additions & 0 deletions ts/src/lib/sdks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ export class ClientSDK {
}
}

if (conf.body instanceof ReadableStream) {
if (!fetchOptions) {
fetchOptions = {
// @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769
duplex: "half",
};
} else {
// @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769
fetchOptions.duplex = "half";
}
}

let input;
try {
input = this.hooks$.beforeCreateRequest(context, {
Expand Down
21 changes: 21 additions & 0 deletions ts/src/types/streams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/

export function isReadableStream<T = Uint8Array>(
val: unknown,
): val is ReadableStream<T> {
if (typeof val !== "object" || val === null) {
return false;
}

// Check for the presence of methods specific to ReadableStream
const stream = val as ReadableStream<Uint8Array>;

// ReadableStream has methods like getReader, cancel, and tee
return (
typeof stream.getReader === "function" &&
typeof stream.cancel === "function" &&
typeof stream.tee === "function"
);
}

0 comments on commit 5319611

Please sign in to comment.