-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from ryan-timothy-albert/speakeasy-sdk-regen-1…
…725395313 chore: 🐝 Update SDK - Generate THIRD-TARGET 0.3.0
- Loading branch information
Showing
12 changed files
with
140 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
|
||
export * from "./sdk/sdk.js"; | ||
export * from "./lib/config.js"; | ||
export * as files from "./lib/files.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
); | ||
} |