Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 5a31650

Browse files
chore: docs + methods
1 parent 046c6e6 commit 5a31650

File tree

9 files changed

+93
-32
lines changed

9 files changed

+93
-32
lines changed

.speakeasy/gen.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ id: 2d20490e-9921-47d5-9711-d3c4b91c8cfa
33
management:
44
docChecksum: bbcb28d2548a56b38ad64847eb7a88d2
55
docVersion: 1.0.0
6-
speakeasyVersion: 1.484.1
7-
generationVersion: 2.503.2
8-
releaseVersion: 0.2.17
9-
configChecksum: 220a5abcbf94f9e343d247580db0d79b
6+
speakeasyVersion: 1.486.0
7+
generationVersion: 2.505.0
8+
releaseVersion: 0.3.1
9+
configChecksum: 4a66bdf60a97497ae0e2e3985a19a6ea
1010
repoURL: https://github.com/s2-streamstore/s2-sdk-typescript.git
1111
installationURL: https://github.com/s2-streamstore/s2-sdk-typescript
1212
published: true
1313
features:
1414
typescript:
1515
acceptHeaders: 2.81.2
1616
additionalDependencies: 0.1.0
17-
core: 3.18.22
17+
core: 3.19.0
1818
defaultEnabledRetries: 0.1.0
1919
devContainers: 2.90.0
2020
enumUnions: 0.1.0

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ generation:
1616
oAuth2ClientCredentialsEnabled: true
1717
oAuth2PasswordEnabled: true
1818
typescript:
19-
version: 0.2.17
19+
version: 0.3.1
2020
additionalDependencies:
2121
dependencies:
2222
uuid: ^9.0.1

.speakeasy/workflow.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
speakeasyVersion: 1.484.1
1+
speakeasyVersion: 1.486.0
22
sources:
33
S2 API:
44
sourceNamespace: s-2-api
5-
sourceRevisionDigest: sha256:448a206cc01c74de7c0ca8c59c935b356b29e320715d548978d02cfafd9feed4
5+
sourceRevisionDigest: sha256:d4fc6ea07af52c1783bb9171e22c9abf7de0909abda18316ebd42f4809e31ef2
66
sourceBlobDigest: sha256:eda67f586b78ceb1300a3662669e008175f0667b68ff804d4de23fcab20998d1
77
tags:
88
- latest
@@ -11,10 +11,10 @@ targets:
1111
streamstore:
1212
source: S2 API
1313
sourceNamespace: s-2-api
14-
sourceRevisionDigest: sha256:448a206cc01c74de7c0ca8c59c935b356b29e320715d548978d02cfafd9feed4
14+
sourceRevisionDigest: sha256:d4fc6ea07af52c1783bb9171e22c9abf7de0909abda18316ebd42f4809e31ef2
1515
sourceBlobDigest: sha256:eda67f586b78ceb1300a3662669e008175f0667b68ff804d4de23fcab20998d1
1616
codeSamplesNamespace: s-2-api-typescript-code-samples
17-
codeSamplesRevisionDigest: sha256:5615d0689deba52dd5e6ae379589ebd086858029d7a36e133089763f73d61ddc
17+
codeSamplesRevisionDigest: sha256:0122b1b27af865f5ca17e1900a90a3f2cbff5047995ee8ce729f3ce03a58b9b8
1818
workflow:
1919
workflowVersion: 1.0.0
2020
speakeasyVersion: latest

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ S2 API: Serverless API for streaming data backed by object storage.
2323
* [streamstore](#streamstore)
2424
* [SDK Installation](#sdk-installation)
2525
* [Requirements](#requirements)
26+
* [SDK Recommended Usage](#sdk-recommended-usage)
2627
* [SDK Example Usage](#sdk-example-usage)
2728
* [Authentication](#authentication)
2829
* [Available Resources and Operations](#available-resources-and-operations)
@@ -79,6 +80,24 @@ yarn add @s2-dev/streamstore zod
7980
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
8081
<!-- End Requirements [requirements] -->
8182

83+
## SDK Recommended Usage
84+
85+
The `S2Client` class provides a lot of convenience over the generated methods and is the recommended way to interact with the SDK. If you need finer control over the internal functions, you may use [Generated functions](#available-resources-and-operations)
86+
or [Standalone functions](#standalone-functions).
87+
88+
```typescript
89+
import { ReadRequest, S2Client } from "@s2-dev/streamstore";
90+
91+
const s2 = new S2Client("<AUTH_TOKEN>");
92+
93+
async function run() {
94+
await s2.account.createBasin("my-favorite-basin");
95+
await s2.account.basin("my-favorite-basin").stream("test").append({ appendInput: { records: [{ body: "hello" }] } });
96+
}
97+
98+
run();
99+
```
100+
82101
<!-- Start SDK Example Usage [usage] -->
83102
## SDK Example Usage
84103

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{
44
"name": "@s2-dev/streamstore",
5-
"version": "0.2.17",
5+
"version": "0.3.1",
66
"exports": {
77
".": "./src/index.ts",
88
"./models/errors": "./src/models/errors/index.ts",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@s2-dev/streamstore",
3-
"version": "0.2.17",
3+
"version": "0.3.1",
44
"author": "Speakeasy",
55
"main": "./index.js",
66
"sideEffects": false,

src/index.extras.ts

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
import { accountDeleteBasin } from "./funcs/accountDeleteBasin";
22
import { RequestOptions } from "./lib/sdks";
3-
import { BasinConfig, BasinInfo, CheckTailResponse, CreateBasinRequest, CreateStreamRequest, StreamConfig, StreamInfo } from "./models/components";
3+
import { AppendOutput, BasinConfig, BasinInfo, CheckTailResponse, CreateBasinRequest, CreateStreamRequest, Output, ReadResponse, StreamConfig, StreamInfo } from "./models/components";
44
import { NotFoundError } from "./models/errors";
5-
import {
5+
import {
66
GetBasinConfigRequest,
77
ListBasinsRequest,
88
ListBasinsResponse,
99
ListStreamsRequest,
1010
ListStreamsResponse,
1111
ReconfigureBasinRequest,
1212
CreateBasinRequest as CreateBasinRequestInner,
13-
CreateStreamRequest as CreateStreamRequestInner
13+
CreateStreamRequest as CreateStreamRequestInner,
14+
ReadRequest as ReadRequestInner,
15+
AppendRequest as AppendRequestInner,
1416
} from "./models/operations";
1517
import { PageIterator } from "./types";
1618

17-
import { Stream as InnerStream } from "./sdk/stream";
19+
import { Stream as InnerStream, ReadAcceptEnum } from "./sdk/stream";
1820
import { Basin as InnerBasin } from "./sdk/basin";
1921
import { Account as InnerAccount } from "./sdk/account";
2022

2123
import { v4 } from 'uuid';
2224
import { basinDeleteStream } from "./funcs/basinDeleteStream";
25+
import { EventStream } from "./lib/event-streams";
26+
27+
export type ReadRequest = Omit<ReadRequestInner, 'stream'>;
28+
export type AppendRequest = Omit<AppendRequestInner, 'stream'>;
29+
export type {
30+
GetBasinConfigRequest,
31+
ListBasinsRequest,
32+
ListBasinsResponse,
33+
ListStreamsRequest,
34+
ListStreamsResponse,
35+
ReconfigureBasinRequest,
36+
} from "./models/operations";
37+
export type { BasinConfig, BasinInfo, CheckTailResponse, CreateBasinRequest, CreateStreamRequest, Output, ReadResponse, StreamConfig, StreamInfo } from "./models/components";
2338

2439
export function genS2RequestToken(): string {
2540
return v4().replace(/-/g, '');
@@ -45,9 +60,11 @@ export class S2Client {
4560
class S2Account {
4661
private _account: InnerAccount;
4762
private requestOptions: RequestOptions;
63+
private authToken: string;
4864

4965
constructor(authToken: string) {
5066
this._account = new InnerAccount({ bearerAuth: authToken });
67+
this.authToken = authToken;
5168
this.requestOptions = {
5269
timeoutMs: 3000,
5370
retries: {
@@ -64,9 +81,10 @@ class S2Account {
6481
};
6582
}
6683

67-
/**
68-
* List basins.
69-
*/
84+
basin(basinName: string): S2Basin {
85+
return new S2Basin(this.authToken, basinName);
86+
}
87+
7088
async listBasins(
7189
request?: ListBasinsRequest,
7290
): Promise<PageIterator<ListBasinsResponse, { cursor: string }>> {
@@ -132,7 +150,7 @@ class S2Basin {
132150
}
133151

134152
stream(streamName: string): Stream {
135-
return (this._stream ??= new Stream(streamName, this.basinName));
153+
return (this._stream ??= new Stream(this.basinName, streamName));
136154
}
137155

138156
async listStreams(
@@ -151,13 +169,13 @@ class S2Basin {
151169

152170
async createStream(
153171
stream: string,
154-
request: CreateStreamRequest,
172+
request?: CreateStreamRequest,
155173
): Promise<StreamInfo | undefined> {
156174
const basinURL = `${this.basinName}.${this.basinURLSuffx}`;
157175
const _request: CreateStreamRequestInner = {
158176
stream,
159177
s2RequestToken: genS2RequestToken(),
160-
createStreamRequest: request,
178+
createStreamRequest: request ?? {},
161179
};
162180

163181
return (
@@ -170,7 +188,7 @@ class S2Basin {
170188
const response = await basinDeleteStream(this._basin, { stream }, { serverURL: basinURL, ...this.requestOptions });
171189
if (if_exists && response instanceof NotFoundError) return;
172190
if (response.error) throw new Error(response.error.message);
173-
return;
191+
return;
174192
}
175193

176194
async reconfigureStream(stream: string, config: StreamConfig): Promise<StreamConfig | undefined> {
@@ -184,15 +202,16 @@ class S2Basin {
184202
}
185203
}
186204

205+
187206
class Stream {
188207
private _stream: InnerStream;
189-
private streamName: string;
190208
private basinName: string;
209+
private streamName: string;
191210
private readonly basinURLSuffx = 'b.aws.s2.dev/v1alpha';
192211

193-
constructor(streamName: string, basinName: string) {
194-
this.streamName = streamName;
212+
constructor(basinName: string, streamName: string) {
195213
this.basinName = basinName;
214+
this.streamName = streamName;
196215
this._stream = new InnerStream();
197216
}
198217

@@ -201,4 +220,28 @@ class Stream {
201220
return (await this._stream.checkTail({ stream: this.streamName }, { serverURL: basinURL }))
202221
.checkTailResponse;
203222
}
223+
224+
async read(
225+
request: ReadRequest,
226+
stream?: boolean
227+
): Promise<EventStream<ReadResponse> | Output | undefined> {
228+
const basinURL = `${this.basinName}.${this.basinURLSuffx}`;
229+
return (await this._stream.read(
230+
{ ...request, stream: this.streamName },
231+
stream
232+
? { serverURL: basinURL, acceptHeaderOverride: ReadAcceptEnum.textEventStream }
233+
: { serverURL: basinURL }
234+
))
235+
.readResponse;
236+
}
237+
238+
async append(
239+
request: AppendRequest,
240+
): Promise<AppendOutput | undefined> {
241+
const basinURL = `${this.basinName}.${this.basinURLSuffx}`;
242+
return (await this._stream.append(
243+
{ ...request, stream: this.streamName },
244+
{ serverURL: basinURL }
245+
)).appendOutput;
246+
}
204247
}

src/lib/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
5454
export const SDK_METADATA = {
5555
language: "typescript",
5656
openapiDocVersion: "1.0.0",
57-
sdkVersion: "0.2.17",
58-
genVersion: "2.503.2",
59-
userAgent:
60-
"speakeasy-sdk/typescript 0.2.17 2.503.2 1.0.0 @s2-dev/streamstore",
57+
sdkVersion: "0.3.1",
58+
genVersion: "2.505.0",
59+
userAgent: "speakeasy-sdk/typescript 0.3.1 2.505.0 1.0.0 @s2-dev/streamstore",
6160
} as const;

0 commit comments

Comments
 (0)