@s2-dev/streamstore 0.3.2 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/endpoints.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ type Authority = string;
2
+ type BasinName = string;
3
+ /**
4
+ * S2 cloud environment to connect with.
5
+ */
6
+ export declare enum S2Cloud {
7
+ /** S2 running on AWS */
8
+ Aws = "aws"
9
+ }
10
+ /**
11
+ * Endpoint for connecting to an S2 basin.
12
+ */
13
+ export declare enum BasinEndpointKind {
14
+ ParentZone = "ParentZone",
15
+ Direct = "Direct"
16
+ }
17
+ export type BasinEndpoint = {
18
+ kind: BasinEndpointKind.ParentZone;
19
+ authority: Authority;
20
+ } | {
21
+ kind: BasinEndpointKind.Direct;
22
+ authority: Authority;
23
+ };
24
+ /**
25
+ * Endpoints for the S2 environment.
26
+ *
27
+ * You can find the S2 endpoints in our [documentation](https://s2.dev/docs/interface/endpoints)
28
+ */
29
+ export declare class S2Endpoints {
30
+ /** Used by `AccountService` requests */
31
+ account: Authority;
32
+ /** Used by `BasinService` and `StreamService` requests */
33
+ basin: BasinEndpoint;
34
+ constructor(account: Authority, basin: BasinEndpoint);
35
+ /**
36
+ * Get S2 endpoints for the specified cloud.
37
+ */
38
+ static forCloud(cloud: S2Cloud): S2Endpoints;
39
+ /**
40
+ * Get S2 endpoints for the specified cell.
41
+ */
42
+ static forCell(cloud: S2Cloud, cellId: string): S2Endpoints;
43
+ /**
44
+ * Get S2 endpoints from environment variables.
45
+ *
46
+ * The following environment variables are used:
47
+ * - `S2_CLOUD`: Valid S2 cloud name. Defaults to AWS.
48
+ * - `S2_ACCOUNT_ENDPOINT`: Overrides the account endpoint.
49
+ * - `S2_BASIN_ENDPOINT`: Overrides the basin endpoint. The prefix `"{basin}."` indicates the
50
+ * basin endpoint is `ParentZone` else `Direct`.
51
+ */
52
+ static fromEnv(): S2Endpoints;
53
+ }
54
+ /**
55
+ * Client kind for different S2 services
56
+ */
57
+ export type ClientKind = {
58
+ kind: 'Account';
59
+ } | {
60
+ kind: 'Basin';
61
+ basin: BasinName;
62
+ };
63
+ export declare const ClientKind: {
64
+ toAuthority(kind: ClientKind, endpoints: S2Endpoints): Authority;
65
+ };
66
+ export {};
67
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["src/endpoints.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,CAAC;AAGxB,KAAK,SAAS,GAAG,MAAM,CAAC;AAExB;;GAEG;AACH,oBAAY,OAAO;IACf,wBAAwB;IACxB,GAAG,QAAQ;CACd;AAED;;GAEG;AACH,oBAAY,iBAAiB;IACzB,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;CACxB,GAAG;IACA,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;CACxB,CAAC;AASF;;;;GAIG;AACH,qBAAa,WAAW;IACpB,wCAAwC;IACjC,OAAO,EAAE,SAAS,CAAC;IAC1B,0DAA0D;IACnD,KAAK,EAAE,aAAa,CAAC;gBAEhB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa;IAKpD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW;IAW5C;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW;IAW3D;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,IAAI,WAAW;CA8ChC;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAChB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAE1C,eAAO,MAAM,UAAU;sBACD,UAAU,aAAa,WAAW,GAAG,SAAS;CAanE,CAAC"}
package/endpoints.js ADDED
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientKind = exports.S2Endpoints = exports.BasinEndpointKind = exports.S2Cloud = void 0;
4
+ /**
5
+ * S2 cloud environment to connect with.
6
+ */
7
+ var S2Cloud;
8
+ (function (S2Cloud) {
9
+ /** S2 running on AWS */
10
+ S2Cloud["Aws"] = "aws";
11
+ })(S2Cloud || (exports.S2Cloud = S2Cloud = {}));
12
+ /**
13
+ * Endpoint for connecting to an S2 basin.
14
+ */
15
+ var BasinEndpointKind;
16
+ (function (BasinEndpointKind) {
17
+ BasinEndpointKind["ParentZone"] = "ParentZone";
18
+ BasinEndpointKind["Direct"] = "Direct";
19
+ })(BasinEndpointKind || (exports.BasinEndpointKind = BasinEndpointKind = {}));
20
+ class S2EndpointError extends Error {
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = 'S2EndpointError';
24
+ }
25
+ }
26
+ /**
27
+ * Endpoints for the S2 environment.
28
+ *
29
+ * You can find the S2 endpoints in our [documentation](https://s2.dev/docs/interface/endpoints)
30
+ */
31
+ class S2Endpoints {
32
+ constructor(account, basin) {
33
+ this.account = account;
34
+ this.basin = basin;
35
+ }
36
+ /**
37
+ * Get S2 endpoints for the specified cloud.
38
+ */
39
+ static forCloud(cloud) {
40
+ const authority = `${cloud}.s2.dev`;
41
+ return new S2Endpoints(authority, {
42
+ kind: BasinEndpointKind.ParentZone,
43
+ authority: `b.${cloud}.s2.dev`
44
+ });
45
+ }
46
+ /**
47
+ * Get S2 endpoints for the specified cell.
48
+ */
49
+ static forCell(cloud, cellId) {
50
+ const cellEndpoint = `${cellId}.o.${cloud}.s2.dev`;
51
+ return new S2Endpoints(cellEndpoint, {
52
+ kind: BasinEndpointKind.Direct,
53
+ authority: cellEndpoint
54
+ });
55
+ }
56
+ /**
57
+ * Get S2 endpoints from environment variables.
58
+ *
59
+ * The following environment variables are used:
60
+ * - `S2_CLOUD`: Valid S2 cloud name. Defaults to AWS.
61
+ * - `S2_ACCOUNT_ENDPOINT`: Overrides the account endpoint.
62
+ * - `S2_BASIN_ENDPOINT`: Overrides the basin endpoint. The prefix `"{basin}."` indicates the
63
+ * basin endpoint is `ParentZone` else `Direct`.
64
+ */
65
+ static fromEnv() {
66
+ let cloud;
67
+ try {
68
+ const cloudEnv = process.env['S2_CLOUD'] || S2Cloud.Aws;
69
+ if (Object.values(S2Cloud).includes(cloudEnv)) {
70
+ cloud = cloudEnv;
71
+ }
72
+ else {
73
+ throw new S2EndpointError(`Invalid S2_CLOUD: ${cloudEnv}`);
74
+ }
75
+ }
76
+ catch (err) {
77
+ const error = err;
78
+ throw new S2EndpointError(`Invalid S2_CLOUD: ${error.message}`);
79
+ }
80
+ const endpoints = S2Endpoints.forCloud(cloud);
81
+ const accountEndpoint = process.env['S2_ACCOUNT_ENDPOINT'];
82
+ if (accountEndpoint !== undefined) {
83
+ if (typeof accountEndpoint !== 'string') {
84
+ throw new S2EndpointError('Invalid S2_ACCOUNT_ENDPOINT: not string');
85
+ }
86
+ endpoints.account = accountEndpoint;
87
+ }
88
+ const basinEndpoint = process.env['S2_BASIN_ENDPOINT'];
89
+ if (basinEndpoint !== undefined) {
90
+ if (typeof basinEndpoint !== 'string') {
91
+ throw new S2EndpointError('Invalid S2_BASIN_ENDPOINT: not string');
92
+ }
93
+ if (basinEndpoint.startsWith('{basin}.')) {
94
+ const parentZone = basinEndpoint.substring(7);
95
+ endpoints.basin = {
96
+ kind: BasinEndpointKind.ParentZone,
97
+ authority: parentZone
98
+ };
99
+ }
100
+ else {
101
+ endpoints.basin = {
102
+ kind: BasinEndpointKind.Direct,
103
+ authority: basinEndpoint
104
+ };
105
+ }
106
+ }
107
+ return endpoints;
108
+ }
109
+ }
110
+ exports.S2Endpoints = S2Endpoints;
111
+ exports.ClientKind = {
112
+ toAuthority(kind, endpoints) {
113
+ switch (kind.kind) {
114
+ case 'Account':
115
+ return endpoints.account;
116
+ case 'Basin':
117
+ switch (endpoints.basin.kind) {
118
+ case BasinEndpointKind.ParentZone:
119
+ return `${kind.basin}.${endpoints.basin.authority}`;
120
+ case BasinEndpointKind.Direct:
121
+ return endpoints.basin.authority;
122
+ }
123
+ }
124
+ }
125
+ };
126
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["src/endpoints.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,wBAAwB;IACxB,sBAAW,CAAA;AACf,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB;AAED;;GAEG;AACH,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IACzB,8CAAyB,CAAA;IACzB,sCAAiB,CAAA;AACrB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAUD,MAAM,eAAgB,SAAQ,KAAK;IAC/B,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAa,WAAW;IAMpB,YAAY,OAAkB,EAAE,KAAoB;QAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAc;QAC1B,MAAM,SAAS,GAAG,GAAG,KAAK,SAAS,CAAC;QACpC,OAAO,IAAI,WAAW,CAClB,SAAS,EACT;YACI,IAAI,EAAE,iBAAiB,CAAC,UAAU;YAClC,SAAS,EAAE,KAAK,KAAK,SAAS;SACjC,CACJ,CAAC;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAA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AS,EAAE,CAAC;YAC9B,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACpC,MAAM,IAAI,eAAe,CAAC,uCAAuC,CAAC,CAAC;YACvE,CAAC;YAED,IAAI,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvC,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAC9C,SAAS,CAAC,KAAK,GAAG;oBACd,IAAI,EAAE,iBAAiB,CAAC,UAAU;oBAClC,SAAS,EAAE,UAAU;iBACxB,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,SAAS,CAAC,KAAK,GAAG;oBACd,IAAI,EAAE,iBAAiB,CAAC,MAAM;oBAC9B,SAAS,EAAE,aAAa;iBAC3B,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA9FD,kCA8FC;AASY,QAAA,UAAU,GAAG;IACtB,WAAW,CAAC,IAAgB,EAAE,SAAsB;QAChD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,SAAS;gBACV,OAAO,SAAS,CAAC,OAAO,CAAC;YAC7B,KAAK,OAAO;gBACR,QAAQ,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;oBAC3B,KAAK,iBAAiB,CAAC,UAAU;wBAC7B,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;oBACxD,KAAK,iBAAiB,CAAC,MAAM;wBACzB,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC;gBACzC,CAAC;QACT,CAAC;IACL,CAAC;CACJ,CAAC"}
package/index.extras.d.ts CHANGED
@@ -1,25 +1,31 @@
1
1
  import { AppendOutput, BasinConfig, BasinInfo, CheckTailResponse, CreateBasinRequest, CreateStreamRequest, Output, ReadResponse, StreamConfig, StreamInfo } from "./models/components";
2
2
  import { ListBasinsRequest, ListBasinsResponse, ListStreamsRequest, ListStreamsResponse, ReadRequest as ReadRequestInner, AppendRequest as AppendRequestInner } from "./models/operations";
3
3
  import { PageIterator } from "./types";
4
- import { EventStream } from "./lib/event-streams";
4
+ import { S2Endpoints } from "./endpoints";
5
5
  export type ReadRequest = Omit<ReadRequestInner, "stream">;
6
6
  export type AppendRequest = Omit<AppendRequestInner, "stream">;
7
7
  export type { GetBasinConfigRequest, ListBasinsRequest, ListBasinsResponse, ListStreamsRequest, ListStreamsResponse, ReconfigureBasinRequest, } from "./models/operations";
8
8
  export type { BasinConfig, BasinInfo, CheckTailResponse, CreateBasinRequest, CreateStreamRequest, Output, ReadResponse, StreamConfig, StreamInfo, } from "./models/components";
9
- export declare function genS2RequestToken(): string;
9
+ export * from "./endpoints";
10
+ export type S2ClientConfig = {
11
+ authToken?: string;
12
+ requestTimeout?: number;
13
+ endpoints?: S2Endpoints;
14
+ };
10
15
  export declare class S2Client {
11
- private authToken;
16
+ private config;
12
17
  private _account?;
13
18
  get account(): S2Account;
14
19
  private _basin?;
15
20
  basin(basinName: string): S2Basin;
16
- constructor(authToken: string);
21
+ constructor(config?: S2ClientConfig);
17
22
  }
18
23
  declare class S2Account {
19
24
  private _account;
20
- private requestOptions;
21
- private authToken;
22
- constructor(authToken: string);
25
+ private config;
26
+ private readonly accountURLSuffx;
27
+ constructor(config: S2ClientConfig);
28
+ get URL(): string | undefined;
23
29
  basin(basinName: string): S2Basin;
24
30
  listBasins(request?: ListBasinsRequest): Promise<PageIterator<ListBasinsResponse, {
25
31
  cursor: string;
@@ -32,12 +38,12 @@ declare class S2Account {
32
38
  declare class S2Basin {
33
39
  private _basin;
34
40
  private _stream;
35
- private requestOptions;
36
41
  private basinName;
37
- private authToken;
42
+ private config;
43
+ private clientKind;
38
44
  private readonly basinURLSuffx;
39
- private get basinURL();
40
- constructor(authToken: string, basinName: string);
45
+ private get URL();
46
+ constructor(basinName: string, config: S2ClientConfig);
41
47
  stream(streamName: string): Stream;
42
48
  listStreams(request: ListStreamsRequest): Promise<PageIterator<ListStreamsResponse, {
43
49
  cursor: string;
@@ -49,14 +55,16 @@ declare class S2Basin {
49
55
  }
50
56
  declare class Stream {
51
57
  private _stream;
52
- private basinName;
53
58
  private streamName;
59
+ private config;
60
+ private clientKind;
54
61
  private readonly basinURLSuffx;
55
62
  private get basinURL();
56
- constructor(basinName: string, streamName: string, authToken: string);
63
+ constructor(basinName: string, streamName: string, config: S2ClientConfig);
57
64
  checkTail(): Promise<CheckTailResponse | undefined>;
58
- readStream(request: ReadRequest): Promise<EventStream<ReadResponse> | undefined>;
59
- read(request: ReadRequest): Promise<Output | undefined>;
60
65
  append(request: AppendRequest): Promise<AppendOutput | undefined>;
66
+ read(request: ReadRequest): Promise<Output | undefined>;
67
+ readStream(request: ReadRequest): AsyncGenerator<ReadResponse, void, undefined>;
61
68
  }
69
+ export declare function genS2RequestToken(): string;
62
70
  //# sourceMappingURL=index.extras.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.extras.d.ts","sourceRoot":"","sources":["src/index.extras.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEH,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EAInB,WAAW,IAAI,gBAAgB,EAC/B,aAAa,IAAI,kBAAkB,EACtC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,C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AAS,CAAC;IAMnD,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAMjE,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAMtD,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC;CAwCzF;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
package/index.extras.js CHANGED
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.S2Client = void 0;
4
18
  exports.genS2RequestToken = genS2RequestToken;
@@ -9,49 +23,49 @@ const basin_1 = require("./sdk/basin");
9
23
  const account_1 = require("./sdk/account");
10
24
  const uuid_1 = require("uuid");
11
25
  const basinDeleteStream_1 = require("./funcs/basinDeleteStream");
12
- function genS2RequestToken() {
13
- return (0, uuid_1.v4)().replace(/-/g, "");
14
- }
26
+ const endpoints_1 = require("./endpoints");
27
+ __exportStar(require("./endpoints"), exports);
28
+ const defaultS2ClientConfig = {
29
+ requestTimeout: 3000,
30
+ endpoints: endpoints_1.S2Endpoints.forCloud(endpoints_1.S2Cloud.Aws),
31
+ };
15
32
  class S2Client {
16
33
  get account() {
17
- return (this._account ?? (this._account = new S2Account(this.authToken)));
34
+ return (this._account ?? (this._account = new S2Account(this.config)));
18
35
  }
19
36
  basin(basinName) {
20
- return (this._basin ?? (this._basin = new S2Basin(this.authToken, basinName)));
37
+ return (this._basin ?? (this._basin = new S2Basin(basinName, this.config)));
21
38
  }
22
- constructor(authToken) {
23
- this.authToken = authToken;
39
+ constructor(config) {
40
+ this.config = { ...defaultS2ClientConfig, ...config };
24
41
  }
25
42
  }
26
43
  exports.S2Client = S2Client;
27
44
  class S2Account {
28
- constructor(authToken) {
29
- this._account = new account_1.Account({ bearerAuth: authToken });
30
- this.authToken = authToken;
31
- this.requestOptions = {
32
- timeoutMs: 3000,
33
- retries: {
34
- strategy: "backoff",
35
- backoff: {
36
- initialInterval: 100,
37
- maxInterval: 3000,
38
- exponent: 2,
39
- maxElapsedTime: 6000,
40
- },
41
- retryConnectionErrors: true,
42
- },
43
- retryCodes: ["500", "503", "504"],
44
- };
45
+ constructor(config) {
46
+ this.accountURLSuffx = "/v1alpha";
47
+ this._account = new account_1.Account({
48
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
49
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
50
+ });
51
+ this.config = config;
52
+ }
53
+ get URL() {
54
+ if (!this.config.endpoints)
55
+ return undefined;
56
+ return `https://${endpoints_1.ClientKind.toAuthority({ kind: "Account" }, this.config.endpoints)}${this.accountURLSuffx}`;
45
57
  }
46
58
  basin(basinName) {
47
- return new S2Basin(this.authToken, basinName);
59
+ return new S2Basin(basinName, this.config);
48
60
  }
49
61
  async listBasins(request) {
50
- return this._account.listBasins(request ?? {}, this.requestOptions);
62
+ const url = this.URL;
63
+ return this._account.listBasins(request ?? {}, url ? { serverURL: url } : {});
51
64
  }
52
65
  async getBasinConfig(basin) {
53
66
  const _request = { basin };
54
- return (await this._account.getBasinConfig(_request, this.requestOptions)).basinConfig;
67
+ const url = this.URL;
68
+ return (await this._account.getBasinConfig(_request, url ? { serverURL: url } : {})).basinConfig;
55
69
  }
56
70
  async createBasin(basin, request) {
57
71
  const _request = {
@@ -59,10 +73,12 @@ class S2Account {
59
73
  s2RequestToken: genS2RequestToken(),
60
74
  createBasinRequest: request ?? {},
61
75
  };
62
- return (await this._account.createBasin(_request, this.requestOptions)).basinInfo;
76
+ const url = this.URL;
77
+ return (await this._account.createBasin(_request, url ? { serverURL: url } : {})).basinInfo;
63
78
  }
64
79
  async deleteBasin(basin, if_exists) {
65
- const response = await (0, accountDeleteBasin_1.accountDeleteBasin)(this._account, { basin }, this.requestOptions);
80
+ const url = this.URL;
81
+ const response = await (0, accountDeleteBasin_1.accountDeleteBasin)(this._account, { basin }, url ? { serverURL: url } : {});
66
82
  if (if_exists && response.error instanceof errors_1.NotFoundError)
67
83
  return;
68
84
  if (response.error)
@@ -70,42 +86,33 @@ class S2Account {
70
86
  return;
71
87
  }
72
88
  async reconfigureBasin(basin, config) {
89
+ const url = this.URL;
73
90
  const _request = { basin, basinConfig: config };
74
- return (await this._account.reconfigureBasin(_request, this.requestOptions)).basinConfig;
91
+ return (await this._account.reconfigureBasin(_request, url ? { serverURL: url } : {})).basinConfig;
75
92
  }
76
93
  }
77
94
  class S2Basin {
78
- get basinURL() {
79
- return `https://${this.basinName}.${this.basinURLSuffx}`;
80
- }
81
- constructor(authToken, basinName) {
82
- this.basinURLSuffx = "b.aws.s2.dev/v1alpha";
83
- this._basin = new basin_1.Basin({ bearerAuth: authToken });
84
- this.authToken = authToken;
95
+ get URL() {
96
+ return `https://${endpoints_1.ClientKind.toAuthority(this.clientKind, this.config.endpoints ?? endpoints_1.S2Endpoints.forCloud(endpoints_1.S2Cloud.Aws))}${this.basinURLSuffx}`;
97
+ }
98
+ constructor(basinName, config) {
99
+ this.basinURLSuffx = "/v1alpha";
100
+ this._basin = new basin_1.Basin({
101
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
102
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
103
+ });
104
+ this.config = config;
105
+ this.clientKind = { kind: "Basin", basin: basinName };
85
106
  this.basinName = basinName;
86
- this.requestOptions = {
87
- timeoutMs: 3000,
88
- retries: {
89
- strategy: "backoff",
90
- backoff: {
91
- initialInterval: 100,
92
- maxInterval: 3000,
93
- exponent: 2,
94
- maxElapsedTime: 6000,
95
- },
96
- retryConnectionErrors: true,
97
- },
98
- retryCodes: ["500", "503", "504"],
99
- };
100
107
  }
101
108
  stream(streamName) {
102
- return (this._stream ?? (this._stream = new Stream(this.basinName, streamName, this.authToken)));
109
+ return (this._stream ?? (this._stream = new Stream(this.basinName, streamName, this.config)));
103
110
  }
104
111
  async listStreams(request) {
105
- return this._basin.listStreams(request, { serverURL: this.basinURL, ...this.requestOptions });
112
+ return this._basin.listStreams(request, { serverURL: this.URL });
106
113
  }
107
114
  async getStreamConfig(stream) {
108
- return (await this._basin.getStreamConfig({ stream }, { serverURL: this.basinURL, ...this.requestOptions })).streamConfig;
115
+ return (await this._basin.getStreamConfig({ stream }, { serverURL: this.URL })).streamConfig;
109
116
  }
110
117
  async createStream(stream, request) {
111
118
  const _request = {
@@ -113,12 +120,11 @@ class S2Basin {
113
120
  s2RequestToken: genS2RequestToken(),
114
121
  createStreamRequest: request ?? {},
115
122
  };
116
- return (await this._basin.createStream(_request, { serverURL: this.basinURL, ...this.requestOptions })).streamInfo;
123
+ return (await this._basin.createStream(_request, { serverURL: this.URL })).streamInfo;
117
124
  }
118
125
  async deleteStream(stream, if_exists) {
119
126
  const response = await (0, basinDeleteStream_1.basinDeleteStream)(this._basin, { stream }, {
120
- serverURL: this.basinURL,
121
- ...this.requestOptions,
127
+ serverURL: this.URL,
122
128
  });
123
129
  if (if_exists && response instanceof errors_1.NotFoundError)
124
130
  return;
@@ -127,30 +133,70 @@ class S2Basin {
127
133
  return;
128
134
  }
129
135
  async reconfigureStream(stream, config) {
130
- return (await this._basin.reconfigureStream({ stream, streamConfig: config }, { serverURL: this.basinURL, ...this.requestOptions })).streamConfig;
136
+ return (await this._basin.reconfigureStream({ stream, streamConfig: config }, { serverURL: this.URL })).streamConfig;
131
137
  }
132
138
  }
133
139
  class Stream {
134
140
  get basinURL() {
135
- return `https://${this.basinName}.${this.basinURLSuffx}`;
141
+ return `https://${endpoints_1.ClientKind.toAuthority(this.clientKind, this.config.endpoints ?? endpoints_1.S2Endpoints.forCloud(endpoints_1.S2Cloud.Aws))}${this.basinURLSuffx}`;
136
142
  }
137
- constructor(basinName, streamName, authToken) {
138
- this.basinURLSuffx = "b.aws.s2.dev/v1alpha";
139
- this.basinName = basinName;
143
+ constructor(basinName, streamName, config) {
144
+ this.basinURLSuffx = "/v1alpha";
145
+ this.config = config;
146
+ this.clientKind = { kind: "Basin", basin: basinName };
140
147
  this.streamName = streamName;
141
- this._stream = new stream_1.Stream({ bearerAuth: authToken });
148
+ this._stream = new stream_1.Stream({
149
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
150
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
151
+ });
142
152
  }
143
153
  async checkTail() {
144
154
  return (await this._stream.checkTail({ stream: this.streamName }, { serverURL: this.basinURL })).checkTailResponse;
145
155
  }
146
- async readStream(request) {
147
- return (await this._stream.read({ ...request, stream: this.streamName }, { serverURL: this.basinURL, acceptHeaderOverride: stream_1.ReadAcceptEnum.textEventStream })).readResponse;
156
+ async append(request) {
157
+ return (await this._stream.append({ ...request, stream: this.streamName }, { serverURL: this.basinURL })).appendOutput;
148
158
  }
149
159
  async read(request) {
150
160
  return (await this._stream.read({ ...request, stream: this.streamName }, { serverURL: this.basinURL })).output;
151
161
  }
152
- async append(request) {
153
- return (await this._stream.append({ ...request, stream: this.streamName }, { serverURL: this.basinURL })).appendOutput;
162
+ async *readStream(request) {
163
+ let currentRequest = { ...request };
164
+ while (true) {
165
+ let stream;
166
+ try {
167
+ const response = await this._stream.read({ ...currentRequest, stream: this.streamName }, {
168
+ serverURL: this.basinURL,
169
+ timeoutMs: -1, // disable only for streaming
170
+ acceptHeaderOverride: stream_1.ReadAcceptEnum.textEventStream
171
+ });
172
+ stream = response.readResponse;
173
+ if (!stream)
174
+ return;
175
+ for await (const event of stream) {
176
+ yield event;
177
+ if (event.event === 'output') {
178
+ const output = event;
179
+ if ('batch' in output.data) {
180
+ const batch = output.data.batch;
181
+ if (batch.records && batch.records.length > 0) {
182
+ const lastRecord = batch.records[batch.records.length - 1];
183
+ if (lastRecord) {
184
+ currentRequest = { ...currentRequest, startSeqNum: lastRecord.seqNum + 1 };
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ return;
191
+ }
192
+ catch (error) {
193
+ console.error("Error while reading stream", error);
194
+ return;
195
+ }
196
+ }
154
197
  }
155
198
  }
199
+ function genS2RequestToken() {
200
+ return (0, uuid_1.v4)().replace(/-/g, "");
201
+ }
156
202
  //# sourceMappingURL=index.extras.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.extras.js","sourceRoot":"","sources":["src/index.extras.ts"],"names":[],"mappings":";;;AA2DA,8CAEC;AA7DD,mEAAgE;AAchE,4CAAgD;AAehD,yCAAqE;AACrE,uCAAkD;AAClD,2CAAwD;AAExD,+BAA0B;AAC1B,iEAA8D;AAyB9D,SAAgB,iBAAiB;IAC7B,OAAO,IAAA,SAAE,GAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,MAAa,QAAQ;IAGjB,IAAI,OAAO;QACP,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAb,IAAI,CAAC,QAAQ,GAAK,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,CAAC;IAC7D,CAAC;IAGD,KAAK,CAAC,SAAiB;QACnB,OAAO,CAAC,IAAI,CAAC,MAAM,KAAX,IAAI,CAAC,MAAM,GAAK,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,EAAC,CAAC;IACpE,CAAC;IAED,YAAY,SAAiB;QACzB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gBAC/B,IAAI,CAAC,MAAM;oBAAE,OAAO;gBAEpB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC/B,MAAM,KAAK,CAAC;oBAEZ,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAC3B,MAAM,MAAM,GAAG,KAA2B,CAAC;wBAC3C,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;4BACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;4BAChC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gCAC3D,IAAI,UAAU,EAAE,CAAC;oCACb,cAAc,GAAG,EAAE,GAAG,cAAc,EAAE,WAAW,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCAC/E,CAAC;4BACL,CAAC;wBACL,CAAC;oBACL,CAAC;gBACL,CAAC;gBACD,OAAO;YACX,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;gBACnD,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAED,SAAgB,iBAAiB;IAC7B,OAAO,IAAA,SAAE,GAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC"}
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@s2-dev/streamstore",
5
- "version": "0.3.2",
5
+ "version": "0.3.7",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/lib/config.d.ts CHANGED
@@ -27,8 +27,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
27
27
  export declare const SDK_METADATA: {
28
28
  readonly language: "typescript";
29
29
  readonly openapiDocVersion: "1.0.0";
30
- readonly sdkVersion: "0.3.2";
31
- readonly genVersion: "2.505.0";
32
- readonly userAgent: "speakeasy-sdk/typescript 0.3.2 2.505.0 1.0.0 @s2-dev/streamstore";
30
+ readonly sdkVersion: "0.3.7";
31
+ readonly genVersion: "2.506.0";
32
+ readonly userAgent: "speakeasy-sdk/typescript 0.3.7 2.506.0 1.0.0 @s2-dev/streamstore";
33
33
  };
34
34
  //# sourceMappingURL=config.d.ts.map
package/lib/config.js CHANGED
@@ -28,8 +28,8 @@ function serverURLFromOptions(options) {
28
28
  exports.SDK_METADATA = {
29
29
  language: "typescript",
30
30
  openapiDocVersion: "1.0.0",
31
- sdkVersion: "0.3.2",
32
- genVersion: "2.505.0",
33
- userAgent: "speakeasy-sdk/typescript 0.3.2 2.505.0 1.0.0 @s2-dev/streamstore",
31
+ sdkVersion: "0.3.7",
32
+ genVersion: "2.506.0",
33
+ userAgent: "speakeasy-sdk/typescript 0.3.7 2.506.0 1.0.0 @s2-dev/streamstore",
34
34
  };
35
35
  //# sourceMappingURL=config.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s2-dev/streamstore",
3
- "version": "0.3.2",
3
+ "version": "0.3.7",
4
4
  "author": "Speakeasy",
5
5
  "main": "./index.js",
6
6
  "sideEffects": false,
@@ -19,6 +19,7 @@
19
19
  "devDependencies": {
20
20
  "@eslint/js": "^9.19.0",
21
21
  "@types/jsonpath": "^0.2.4",
22
+ "@types/node": "^22.13.1",
22
23
  "@types/uuid": "^9.0.8",
23
24
  "eslint": "^9.19.0",
24
25
  "globals": "^15.14.0",
@@ -0,0 +1,159 @@
1
+ type Authority = string;
2
+
3
+ // Basin Name
4
+ type BasinName = string;
5
+
6
+ /**
7
+ * S2 cloud environment to connect with.
8
+ */
9
+ export enum S2Cloud {
10
+ /** S2 running on AWS */
11
+ Aws = "aws"
12
+ }
13
+
14
+ /**
15
+ * Endpoint for connecting to an S2 basin.
16
+ */
17
+ export enum BasinEndpointKind {
18
+ ParentZone = "ParentZone",
19
+ Direct = "Direct"
20
+ }
21
+
22
+ export type BasinEndpoint = {
23
+ kind: BasinEndpointKind.ParentZone;
24
+ authority: Authority;
25
+ } | {
26
+ kind: BasinEndpointKind.Direct;
27
+ authority: Authority;
28
+ };
29
+
30
+ class S2EndpointError extends Error {
31
+ constructor(message: string) {
32
+ super(message);
33
+ this.name = 'S2EndpointError';
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Endpoints for the S2 environment.
39
+ *
40
+ * You can find the S2 endpoints in our [documentation](https://s2.dev/docs/interface/endpoints)
41
+ */
42
+ export class S2Endpoints {
43
+ /** Used by `AccountService` requests */
44
+ public account: Authority;
45
+ /** Used by `BasinService` and `StreamService` requests */
46
+ public basin: BasinEndpoint;
47
+
48
+ constructor(account: Authority, basin: BasinEndpoint) {
49
+ this.account = account;
50
+ this.basin = basin;
51
+ }
52
+
53
+ /**
54
+ * Get S2 endpoints for the specified cloud.
55
+ */
56
+ static forCloud(cloud: S2Cloud): S2Endpoints {
57
+ const authority = `${cloud}.s2.dev`;
58
+ return new S2Endpoints(
59
+ authority,
60
+ {
61
+ kind: BasinEndpointKind.ParentZone,
62
+ authority: `b.${cloud}.s2.dev`
63
+ }
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Get S2 endpoints for the specified cell.
69
+ */
70
+ static forCell(cloud: S2Cloud, cellId: string): S2Endpoints {
71
+ const cellEndpoint = `${cellId}.o.${cloud}.s2.dev`;
72
+ return new S2Endpoints(
73
+ cellEndpoint,
74
+ {
75
+ kind: BasinEndpointKind.Direct,
76
+ authority: cellEndpoint
77
+ }
78
+ );
79
+ }
80
+
81
+ /**
82
+ * Get S2 endpoints from environment variables.
83
+ *
84
+ * The following environment variables are used:
85
+ * - `S2_CLOUD`: Valid S2 cloud name. Defaults to AWS.
86
+ * - `S2_ACCOUNT_ENDPOINT`: Overrides the account endpoint.
87
+ * - `S2_BASIN_ENDPOINT`: Overrides the basin endpoint. The prefix `"{basin}."` indicates the
88
+ * basin endpoint is `ParentZone` else `Direct`.
89
+ */
90
+ static fromEnv(): S2Endpoints {
91
+ let cloud: S2Cloud;
92
+ try {
93
+ const cloudEnv = process.env['S2_CLOUD'] || S2Cloud.Aws;
94
+ if (Object.values(S2Cloud).includes(cloudEnv as S2Cloud)) {
95
+ cloud = cloudEnv as S2Cloud;
96
+ } else {
97
+ throw new S2EndpointError(`Invalid S2_CLOUD: ${cloudEnv}`);
98
+ }
99
+ } catch (err) {
100
+ const error = err as Error;
101
+ throw new S2EndpointError(`Invalid S2_CLOUD: ${error.message}`);
102
+ }
103
+
104
+ const endpoints = S2Endpoints.forCloud(cloud);
105
+
106
+ const accountEndpoint = process.env['S2_ACCOUNT_ENDPOINT'];
107
+ if (accountEndpoint !== undefined) {
108
+ if (typeof accountEndpoint !== 'string') {
109
+ throw new S2EndpointError('Invalid S2_ACCOUNT_ENDPOINT: not string');
110
+ }
111
+ endpoints.account = accountEndpoint;
112
+ }
113
+
114
+ const basinEndpoint = process.env['S2_BASIN_ENDPOINT'];
115
+ if (basinEndpoint !== undefined) {
116
+ if (typeof basinEndpoint !== 'string') {
117
+ throw new S2EndpointError('Invalid S2_BASIN_ENDPOINT: not string');
118
+ }
119
+
120
+ if (basinEndpoint.startsWith('{basin}.')) {
121
+ const parentZone = basinEndpoint.substring(7);
122
+ endpoints.basin = {
123
+ kind: BasinEndpointKind.ParentZone,
124
+ authority: parentZone
125
+ };
126
+ } else {
127
+ endpoints.basin = {
128
+ kind: BasinEndpointKind.Direct,
129
+ authority: basinEndpoint
130
+ };
131
+ }
132
+ }
133
+
134
+ return endpoints;
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Client kind for different S2 services
140
+ */
141
+ export type ClientKind =
142
+ | { kind: 'Account' }
143
+ | { kind: 'Basin'; basin: BasinName };
144
+
145
+ export const ClientKind = {
146
+ toAuthority(kind: ClientKind, endpoints: S2Endpoints): Authority {
147
+ switch (kind.kind) {
148
+ case 'Account':
149
+ return endpoints.account;
150
+ case 'Basin':
151
+ switch (endpoints.basin.kind) {
152
+ case BasinEndpointKind.ParentZone:
153
+ return `${kind.basin}.${endpoints.basin.authority}`;
154
+ case BasinEndpointKind.Direct:
155
+ return endpoints.basin.authority;
156
+ }
157
+ }
158
+ }
159
+ };
@@ -1,5 +1,4 @@
1
1
  import { accountDeleteBasin } from "./funcs/accountDeleteBasin";
2
- import { RequestOptions } from "./lib/sdks";
3
2
  import {
4
3
  AppendOutput,
5
4
  BasinConfig,
@@ -9,6 +8,7 @@ import {
9
8
  CreateStreamRequest,
10
9
  Output,
11
10
  ReadResponse,
11
+ ReadResponseOutput,
12
12
  StreamConfig,
13
13
  StreamInfo,
14
14
  } from "./models/components";
@@ -34,6 +34,7 @@ import { Account as InnerAccount } from "./sdk/account";
34
34
  import { v4 } from "uuid";
35
35
  import { basinDeleteStream } from "./funcs/basinDeleteStream";
36
36
  import { EventStream } from "./lib/event-streams";
37
+ import { ClientKind, S2Cloud, S2Endpoints } from "./endpoints";
37
38
 
38
39
  export type ReadRequest = Omit<ReadRequestInner, "stream">;
39
40
  export type AppendRequest = Omit<AppendRequestInner, "stream">;
@@ -57,64 +58,71 @@ export type {
57
58
  StreamInfo,
58
59
  } from "./models/components";
59
60
 
60
- export function genS2RequestToken(): string {
61
- return v4().replace(/-/g, "");
62
- }
61
+ export * from "./endpoints";
62
+
63
+ export type S2ClientConfig = {
64
+ authToken?: string;
65
+ requestTimeout?: number;
66
+ endpoints?: S2Endpoints;
67
+ };
68
+
69
+ const defaultS2ClientConfig: S2ClientConfig = {
70
+ requestTimeout: 3000,
71
+ endpoints: S2Endpoints.forCloud(S2Cloud.Aws),
72
+ };
63
73
 
64
74
  export class S2Client {
65
- private authToken: string;
75
+ private config: S2ClientConfig;
66
76
  private _account?: S2Account;
67
77
  get account(): S2Account {
68
- return (this._account ??= new S2Account(this.authToken));
78
+ return (this._account ??= new S2Account(this.config));
69
79
  }
70
80
 
71
81
  private _basin?: S2Basin;
72
82
  basin(basinName: string): S2Basin {
73
- return (this._basin ??= new S2Basin(this.authToken, basinName));
83
+ return (this._basin ??= new S2Basin(basinName, this.config));
74
84
  }
75
85
 
76
- constructor(authToken: string) {
77
- this.authToken = authToken;
86
+ constructor(config?: S2ClientConfig) {
87
+ this.config = { ...defaultS2ClientConfig, ...config };
78
88
  }
79
89
  }
80
90
 
81
91
  class S2Account {
82
92
  private _account: InnerAccount;
83
- private requestOptions: RequestOptions;
84
- private authToken: string;
85
-
86
- constructor(authToken: string) {
87
- this._account = new InnerAccount({ bearerAuth: authToken });
88
- this.authToken = authToken;
89
- this.requestOptions = {
90
- timeoutMs: 3000,
91
- retries: {
92
- strategy: "backoff",
93
- backoff: {
94
- initialInterval: 100,
95
- maxInterval: 3000,
96
- exponent: 2,
97
- maxElapsedTime: 6000,
98
- },
99
- retryConnectionErrors: true,
100
- },
101
- retryCodes: ["500", "503", "504"],
102
- };
93
+ private config: S2ClientConfig;
94
+ private readonly accountURLSuffx = "/v1alpha";
95
+
96
+ constructor(config: S2ClientConfig) {
97
+ this._account = new InnerAccount({
98
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
99
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
100
+ });
101
+ this.config = config;
102
+ }
103
+
104
+ get URL(): string | undefined {
105
+ if (!this.config.endpoints) return undefined;
106
+ return `https://${ClientKind.toAuthority({ kind: "Account" }, this.config.endpoints)}${this.accountURLSuffx}`;
103
107
  }
104
108
 
105
109
  basin(basinName: string): S2Basin {
106
- return new S2Basin(this.authToken, basinName);
110
+ return new S2Basin(basinName, this.config);
107
111
  }
108
112
 
109
113
  async listBasins(
110
114
  request?: ListBasinsRequest
111
115
  ): Promise<PageIterator<ListBasinsResponse, { cursor: string }>> {
112
- return this._account.listBasins(request ?? {}, this.requestOptions);
116
+ const url = this.URL;
117
+ return this._account.listBasins(request ?? {}, url ? { serverURL: url } : {});
113
118
  }
114
119
 
115
120
  async getBasinConfig(basin: string): Promise<BasinConfig | undefined> {
116
121
  const _request: GetBasinConfigRequest = { basin };
117
- return (await this._account.getBasinConfig(_request, this.requestOptions)).basinConfig;
122
+ const url = this.URL;
123
+ return (await this._account.getBasinConfig(_request
124
+ , url ? { serverURL: url } : {}
125
+ )).basinConfig;
118
126
  }
119
127
 
120
128
  async createBasin(basin: string, request?: CreateBasinRequest): Promise<BasinInfo | undefined> {
@@ -123,67 +131,64 @@ class S2Account {
123
131
  s2RequestToken: genS2RequestToken(),
124
132
  createBasinRequest: request ?? {},
125
133
  };
126
- return (await this._account.createBasin(_request, this.requestOptions)).basinInfo;
134
+ const url = this.URL;
135
+ return (await this._account.createBasin(_request,
136
+ url ? { serverURL: url } : {}
137
+ )).basinInfo;
127
138
  }
128
139
 
129
140
  async deleteBasin(basin: string, if_exists?: boolean): Promise<void | undefined> {
130
- const response = await accountDeleteBasin(this._account, { basin }, this.requestOptions);
141
+ const url = this.URL;
142
+ const response = await accountDeleteBasin(this._account, { basin }, url ? { serverURL: url } : {});
131
143
  if (if_exists && response.error instanceof NotFoundError) return;
132
144
  if (response.error) throw new Error(response.error.message);
133
145
  return;
134
146
  }
135
147
 
136
148
  async reconfigureBasin(basin: string, config: BasinConfig): Promise<BasinConfig | undefined> {
149
+ const url = this.URL;
137
150
  const _request: ReconfigureBasinRequest = { basin, basinConfig: config };
138
- return (await this._account.reconfigureBasin(_request, this.requestOptions)).basinConfig;
151
+ return (await this._account.reconfigureBasin(_request
152
+ , url ? { serverURL: url } : {}
153
+ )).basinConfig;
139
154
  }
140
155
  }
141
156
 
142
157
  class S2Basin {
143
158
  private _basin: InnerBasin;
144
159
  private _stream!: Stream;
145
- private requestOptions: RequestOptions;
146
160
  private basinName: string;
147
- private authToken: string;
148
- private readonly basinURLSuffx = "b.aws.s2.dev/v1alpha";
161
+ private config: S2ClientConfig;
162
+ private clientKind: ClientKind;
163
+ private readonly basinURLSuffx = "/v1alpha";
149
164
 
150
- private get basinURL(): string {
151
- return `https://${this.basinName}.${this.basinURLSuffx}`;
165
+ private get URL(): string {
166
+ return `https://${ClientKind.toAuthority(this.clientKind, this.config.endpoints ?? S2Endpoints.forCloud(S2Cloud.Aws))}${this.basinURLSuffx}`;
152
167
  }
153
168
 
154
- constructor(authToken: string, basinName: string) {
155
- this._basin = new InnerBasin({ bearerAuth: authToken });
156
- this.authToken = authToken;
169
+ constructor(basinName: string, config: S2ClientConfig) {
170
+ this._basin = new InnerBasin({
171
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
172
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
173
+ });
174
+ this.config = config;
175
+ this.clientKind = { kind: "Basin" as const, basin: basinName };
157
176
  this.basinName = basinName;
158
- this.requestOptions = {
159
- timeoutMs: 3000,
160
- retries: {
161
- strategy: "backoff",
162
- backoff: {
163
- initialInterval: 100,
164
- maxInterval: 3000,
165
- exponent: 2,
166
- maxElapsedTime: 6000,
167
- },
168
- retryConnectionErrors: true,
169
- },
170
- retryCodes: ["500", "503", "504"],
171
- };
172
177
  }
173
178
 
174
179
  stream(streamName: string): Stream {
175
- return (this._stream ??= new Stream(this.basinName, streamName, this.authToken));
180
+ return (this._stream ??= new Stream(this.basinName, streamName, this.config));
176
181
  }
177
182
 
178
183
  async listStreams(
179
184
  request: ListStreamsRequest
180
185
  ): Promise<PageIterator<ListStreamsResponse, { cursor: string }>> {
181
- return this._basin.listStreams(request, { serverURL: this.basinURL, ...this.requestOptions });
186
+ return this._basin.listStreams(request, { serverURL: this.URL });
182
187
  }
183
188
 
184
189
  async getStreamConfig(stream: string): Promise<StreamConfig | undefined> {
185
190
  return (
186
- await this._basin.getStreamConfig({ stream }, { serverURL: this.basinURL, ...this.requestOptions })
191
+ await this._basin.getStreamConfig({ stream }, { serverURL: this.URL })
187
192
  ).streamConfig;
188
193
  }
189
194
 
@@ -194,14 +199,13 @@ class S2Basin {
194
199
  createStreamRequest: request ?? {},
195
200
  };
196
201
  return (
197
- await this._basin.createStream(_request, { serverURL: this.basinURL, ...this.requestOptions })
202
+ await this._basin.createStream(_request, { serverURL: this.URL })
198
203
  ).streamInfo;
199
204
  }
200
205
 
201
206
  async deleteStream(stream: string, if_exists?: boolean): Promise<void | undefined> {
202
207
  const response = await basinDeleteStream(this._basin, { stream }, {
203
- serverURL: this.basinURL,
204
- ...this.requestOptions,
208
+ serverURL: this.URL,
205
209
  });
206
210
  if (if_exists && response instanceof NotFoundError) return;
207
211
  if (response.error) throw new Error(response.error.message);
@@ -212,7 +216,7 @@ class S2Basin {
212
216
  return (
213
217
  await this._basin.reconfigureStream(
214
218
  { stream, streamConfig: config },
215
- { serverURL: this.basinURL, ...this.requestOptions }
219
+ { serverURL: this.URL }
216
220
  )
217
221
  ).streamConfig;
218
222
  }
@@ -220,18 +224,23 @@ class S2Basin {
220
224
 
221
225
  class Stream {
222
226
  private _stream: InnerStream;
223
- private basinName: string;
224
227
  private streamName: string;
225
- private readonly basinURLSuffx = "b.aws.s2.dev/v1alpha";
228
+ private config: S2ClientConfig;
229
+ private clientKind: ClientKind;
230
+ private readonly basinURLSuffx = "/v1alpha";
226
231
 
227
232
  private get basinURL(): string {
228
- return `https://${this.basinName}.${this.basinURLSuffx}`;
233
+ return `https://${ClientKind.toAuthority(this.clientKind, this.config.endpoints ?? S2Endpoints.forCloud(S2Cloud.Aws))}${this.basinURLSuffx}`;
229
234
  }
230
235
 
231
- constructor(basinName: string, streamName: string, authToken: string) {
232
- this.basinName = basinName;
236
+ constructor(basinName: string, streamName: string, config: S2ClientConfig) {
237
+ this.config = config;
238
+ this.clientKind = { kind: "Basin" as const, basin: basinName };
233
239
  this.streamName = streamName;
234
- this._stream = new InnerStream({ bearerAuth: authToken });
240
+ this._stream = new InnerStream({
241
+ ...(config.authToken !== undefined && { bearerAuth: config.authToken }),
242
+ ...(config.requestTimeout !== undefined && { timeoutMs: config.requestTimeout })
243
+ });
235
244
  }
236
245
 
237
246
  async checkTail(): Promise<CheckTailResponse | undefined> {
@@ -240,13 +249,10 @@ class Stream {
240
249
  ).checkTailResponse;
241
250
  }
242
251
 
243
- async readStream(request: ReadRequest): Promise<EventStream<ReadResponse> | undefined> {
252
+ async append(request: AppendRequest): Promise<AppendOutput | undefined> {
244
253
  return (
245
- await this._stream.read(
246
- { ...request, stream: this.streamName },
247
- { serverURL: this.basinURL, acceptHeaderOverride: ReadAcceptEnum.textEventStream }
248
- )
249
- ).readResponse;
254
+ await this._stream.append({ ...request, stream: this.streamName }, { serverURL: this.basinURL })
255
+ ).appendOutput;
250
256
  }
251
257
 
252
258
  async read(request: ReadRequest): Promise<Output | undefined> {
@@ -255,9 +261,48 @@ class Stream {
255
261
  ).output;
256
262
  }
257
263
 
258
- async append(request: AppendRequest): Promise<AppendOutput | undefined> {
259
- return (
260
- await this._stream.append({ ...request, stream: this.streamName }, { serverURL: this.basinURL })
261
- ).appendOutput;
264
+ async *readStream(request: ReadRequest): AsyncGenerator<ReadResponse, void, undefined> {
265
+ let currentRequest: ReadRequest = { ...request };
266
+
267
+ while (true) {
268
+ let stream: EventStream<ReadResponse> | undefined;
269
+ try {
270
+ const response = await this._stream.read(
271
+ { ...currentRequest, stream: this.streamName },
272
+ {
273
+ serverURL: this.basinURL,
274
+ timeoutMs: -1, // disable only for streaming
275
+ acceptHeaderOverride: ReadAcceptEnum.textEventStream
276
+ }
277
+ );
278
+ stream = response.readResponse;
279
+ if (!stream) return;
280
+
281
+ for await (const event of stream) {
282
+ yield event;
283
+
284
+ if (event.event === 'output') {
285
+ const output = event as ReadResponseOutput;
286
+ if ('batch' in output.data) {
287
+ const batch = output.data.batch;
288
+ if (batch.records && batch.records.length > 0) {
289
+ const lastRecord = batch.records[batch.records.length - 1];
290
+ if (lastRecord) {
291
+ currentRequest = { ...currentRequest, startSeqNum: lastRecord.seqNum + 1 };
292
+ }
293
+ }
294
+ }
295
+ }
296
+ }
297
+ return;
298
+ } catch (error) {
299
+ console.error("Error while reading stream", error);
300
+ return;
301
+ }
302
+ }
262
303
  }
263
304
  }
305
+
306
+ export function genS2RequestToken(): string {
307
+ return v4().replace(/-/g, "");
308
+ }
package/src/lib/config.ts CHANGED
@@ -54,7 +54,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
54
54
  export const SDK_METADATA = {
55
55
  language: "typescript",
56
56
  openapiDocVersion: "1.0.0",
57
- sdkVersion: "0.3.2",
58
- genVersion: "2.505.0",
59
- userAgent: "speakeasy-sdk/typescript 0.3.2 2.505.0 1.0.0 @s2-dev/streamstore",
57
+ sdkVersion: "0.3.7",
58
+ genVersion: "2.506.0",
59
+ userAgent: "speakeasy-sdk/typescript 0.3.7 2.506.0 1.0.0 @s2-dev/streamstore",
60
60
  } as const;