@s2-dev/streamstore 0.15.8 → 0.15.11

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.
Files changed (93) hide show
  1. package/bin/mcp-server.js +74 -50
  2. package/bin/mcp-server.js.map +15 -14
  3. package/dist/commonjs/funcs/basinsListBasins.js +3 -0
  4. package/dist/commonjs/funcs/basinsListBasins.js.map +1 -1
  5. package/dist/commonjs/funcs/streamsListStreams.js +3 -0
  6. package/dist/commonjs/funcs/streamsListStreams.js.map +1 -1
  7. package/dist/commonjs/lib/config.d.ts +3 -3
  8. package/dist/commonjs/lib/config.js +3 -3
  9. package/dist/commonjs/lib/config.js.map +1 -1
  10. package/dist/commonjs/lib/encodings.d.ts.map +1 -1
  11. package/dist/commonjs/lib/event-streams.d.ts +1 -1
  12. package/dist/commonjs/lib/event-streams.d.ts.map +1 -1
  13. package/dist/commonjs/lib/event-streams.js +23 -32
  14. package/dist/commonjs/lib/event-streams.js.map +1 -1
  15. package/dist/commonjs/lib/security.d.ts.map +1 -1
  16. package/dist/commonjs/lib/security.js.map +1 -1
  17. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  18. package/dist/commonjs/mcp-server/mcp-server.js.map +1 -1
  19. package/dist/commonjs/mcp-server/server.js +1 -1
  20. package/dist/commonjs/mcp-server/server.js.map +1 -1
  21. package/dist/commonjs/models/components/index.d.ts +1 -0
  22. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  23. package/dist/commonjs/models/components/index.js +1 -0
  24. package/dist/commonjs/models/components/index.js.map +1 -1
  25. package/dist/commonjs/models/components/infiniteretention.d.ts +25 -0
  26. package/dist/commonjs/models/components/infiniteretention.d.ts.map +1 -0
  27. package/dist/commonjs/models/components/infiniteretention.js +65 -0
  28. package/dist/commonjs/models/components/infiniteretention.js.map +1 -0
  29. package/dist/commonjs/models/components/metric.d.ts +15 -15
  30. package/dist/commonjs/models/components/metric.d.ts.map +1 -1
  31. package/dist/commonjs/models/components/metric.js +18 -20
  32. package/dist/commonjs/models/components/metric.js.map +1 -1
  33. package/dist/commonjs/models/components/retentionpolicy.d.ts +37 -6
  34. package/dist/commonjs/models/components/retentionpolicy.d.ts.map +1 -1
  35. package/dist/commonjs/models/components/retentionpolicy.js +36 -3
  36. package/dist/commonjs/models/components/retentionpolicy.js.map +1 -1
  37. package/dist/commonjs/models/operations/read.d.ts +3 -0
  38. package/dist/commonjs/models/operations/read.d.ts.map +1 -1
  39. package/dist/commonjs/models/operations/read.js.map +1 -1
  40. package/dist/esm/funcs/basinsListBasins.js +3 -0
  41. package/dist/esm/funcs/basinsListBasins.js.map +1 -1
  42. package/dist/esm/funcs/streamsListStreams.js +3 -0
  43. package/dist/esm/funcs/streamsListStreams.js.map +1 -1
  44. package/dist/esm/lib/config.d.ts +3 -3
  45. package/dist/esm/lib/config.js +3 -3
  46. package/dist/esm/lib/config.js.map +1 -1
  47. package/dist/esm/lib/encodings.d.ts.map +1 -1
  48. package/dist/esm/lib/event-streams.d.ts +1 -1
  49. package/dist/esm/lib/event-streams.d.ts.map +1 -1
  50. package/dist/esm/lib/event-streams.js +23 -32
  51. package/dist/esm/lib/event-streams.js.map +1 -1
  52. package/dist/esm/lib/security.d.ts.map +1 -1
  53. package/dist/esm/lib/security.js.map +1 -1
  54. package/dist/esm/mcp-server/mcp-server.js +1 -1
  55. package/dist/esm/mcp-server/mcp-server.js.map +1 -1
  56. package/dist/esm/mcp-server/server.js +1 -1
  57. package/dist/esm/mcp-server/server.js.map +1 -1
  58. package/dist/esm/models/components/index.d.ts +1 -0
  59. package/dist/esm/models/components/index.d.ts.map +1 -1
  60. package/dist/esm/models/components/index.js +1 -0
  61. package/dist/esm/models/components/index.js.map +1 -1
  62. package/dist/esm/models/components/infiniteretention.d.ts +25 -0
  63. package/dist/esm/models/components/infiniteretention.d.ts.map +1 -0
  64. package/dist/esm/models/components/infiniteretention.js +27 -0
  65. package/dist/esm/models/components/infiniteretention.js.map +1 -0
  66. package/dist/esm/models/components/metric.d.ts +15 -15
  67. package/dist/esm/models/components/metric.d.ts.map +1 -1
  68. package/dist/esm/models/components/metric.js +15 -17
  69. package/dist/esm/models/components/metric.js.map +1 -1
  70. package/dist/esm/models/components/retentionpolicy.d.ts +37 -6
  71. package/dist/esm/models/components/retentionpolicy.d.ts.map +1 -1
  72. package/dist/esm/models/components/retentionpolicy.js +33 -2
  73. package/dist/esm/models/components/retentionpolicy.js.map +1 -1
  74. package/dist/esm/models/operations/read.d.ts +3 -0
  75. package/dist/esm/models/operations/read.d.ts.map +1 -1
  76. package/dist/esm/models/operations/read.js.map +1 -1
  77. package/examples/accessTokensListAccessTokens.example.ts +1 -1
  78. package/examples/package-lock.json +3 -3
  79. package/jsr.json +1 -1
  80. package/package.json +3 -3
  81. package/src/funcs/basinsListBasins.ts +3 -0
  82. package/src/funcs/streamsListStreams.ts +3 -0
  83. package/src/lib/config.ts +3 -3
  84. package/src/lib/event-streams.ts +21 -33
  85. package/src/lib/security.ts +4 -1
  86. package/src/mcp-server/mcp-server.ts +1 -1
  87. package/src/mcp-server/server.ts +1 -1
  88. package/src/models/components/index.ts +1 -0
  89. package/src/models/components/infiniteretention.ts +58 -0
  90. package/src/models/components/metric.ts +28 -25
  91. package/src/models/components/retentionpolicy.ts +68 -6
  92. package/src/models/operations/read.ts +3 -0
  93. package/temp/example.ts +5 -0
@@ -13,34 +13,37 @@ export class EventStream<T extends ServerEvent<unknown>>
13
13
  extends ReadableStream<T>
14
14
  {
15
15
  constructor(
16
- stream: ReadableStream<Uint8Array>,
16
+ responseBody: ReadableStream<Uint8Array>,
17
17
  parse: (x: ServerEvent<string>) => IteratorResult<T, undefined>,
18
18
  ) {
19
- const reader = stream.getReader();
19
+ const upstream = responseBody.getReader();
20
20
  let buffer: Uint8Array = new Uint8Array();
21
21
  super({
22
- async pull(controller) {
22
+ async pull(downstream) {
23
23
  try {
24
24
  while (true) {
25
- const r = await reader.read();
26
- if (r.done) return controller.close();
27
- buffer = concatBuffer(buffer, r.value);
28
- for (const { chunk, remainder } of chunks(buffer)) {
29
- buffer = remainder;
30
- const item = parseChunk(chunk, parse);
31
- if (item?.value) controller.enqueue(item.value);
32
- if (item?.done) {
33
- await reader.cancel("done");
34
- return controller.close();
35
- }
25
+ const match = findBoundary(buffer);
26
+ if (!match) {
27
+ const chunk = await upstream.read();
28
+ if (chunk.done) return downstream.close();
29
+ buffer = concatBuffer(buffer, chunk.value);
30
+ continue;
31
+ }
32
+ const message = buffer.slice(0, match.index);
33
+ buffer = buffer.slice(match.index + match.length);
34
+ const item = parseMessage(message, parse);
35
+ if (item?.value) return downstream.enqueue(item.value);
36
+ if (item?.done) {
37
+ await upstream.cancel("done");
38
+ return downstream.close();
36
39
  }
37
40
  }
38
41
  } catch (e) {
39
- await reader.cancel(e);
40
- controller.error(e);
42
+ downstream.error(e);
43
+ await upstream.cancel(e);
41
44
  }
42
45
  },
43
- cancel: reason => reader.cancel(reason),
46
+ cancel: reason => upstream.cancel(reason),
44
47
  });
45
48
  }
46
49
 
@@ -105,22 +108,7 @@ function findBoundary(
105
108
  return null;
106
109
  }
107
110
 
108
- function* chunks(
109
- remainder: Uint8Array,
110
- ): Generator<{ chunk: Uint8Array; remainder: Uint8Array }> {
111
- while (true) {
112
- const match = findBoundary(remainder);
113
- if (!match) {
114
- yield { chunk: new Uint8Array(), remainder };
115
- return;
116
- }
117
- const chunk = remainder.slice(0, match.index);
118
- remainder = remainder.slice(match.index + match.length);
119
- yield { chunk, remainder };
120
- }
121
- }
122
-
123
- function parseChunk<T extends ServerEvent<unknown>>(
111
+ function parseMessage<T extends ServerEvent<unknown>>(
124
112
  chunk: Uint8Array,
125
113
  parse: (x: ServerEvent<string>) => IteratorResult<T, undefined>,
126
114
  ) {
@@ -84,7 +84,10 @@ type SecurityInputOAuth2 = {
84
84
  type SecurityInputOAuth2ClientCredentials = {
85
85
  type: "oauth2:client_credentials";
86
86
  value:
87
- | { clientID?: string | undefined; clientSecret?: string | undefined }
87
+ | {
88
+ clientID?: string | undefined;
89
+ clientSecret?: string | undefined;
90
+ }
88
91
  | null
89
92
  | string
90
93
  | undefined;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.15.8",
22
+ currentVersion: "0.15.11",
23
23
  },
24
24
  });
25
25
 
@@ -45,7 +45,7 @@ export function createMCPServer(deps: {
45
45
  }) {
46
46
  const server = new McpServer({
47
47
  name: "S2",
48
- version: "0.15.8",
48
+ version: "0.15.11",
49
49
  });
50
50
 
51
51
  const client = new S2Core({
@@ -21,6 +21,7 @@ export * from "./createstreamrequest.js";
21
21
  export * from "./deleteonemptyconfig.js";
22
22
  export * from "./deleteonemptyreconfiguration.js";
23
23
  export * from "./gauge.js";
24
+ export * from "./infiniteretention.js";
24
25
  export * from "./issueaccesstokenresponse.js";
25
26
  export * from "./label.js";
26
27
  export * from "./listaccesstokensresponse.js";
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+
10
+ export type InfiniteRetention = {};
11
+
12
+ /** @internal */
13
+ export const InfiniteRetention$inboundSchema: z.ZodType<
14
+ InfiniteRetention,
15
+ z.ZodTypeDef,
16
+ unknown
17
+ > = z.object({});
18
+
19
+ /** @internal */
20
+ export type InfiniteRetention$Outbound = {};
21
+
22
+ /** @internal */
23
+ export const InfiniteRetention$outboundSchema: z.ZodType<
24
+ InfiniteRetention$Outbound,
25
+ z.ZodTypeDef,
26
+ InfiniteRetention
27
+ > = z.object({});
28
+
29
+ /**
30
+ * @internal
31
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
32
+ */
33
+ export namespace InfiniteRetention$ {
34
+ /** @deprecated use `InfiniteRetention$inboundSchema` instead. */
35
+ export const inboundSchema = InfiniteRetention$inboundSchema;
36
+ /** @deprecated use `InfiniteRetention$outboundSchema` instead. */
37
+ export const outboundSchema = InfiniteRetention$outboundSchema;
38
+ /** @deprecated use `InfiniteRetention$Outbound` instead. */
39
+ export type Outbound = InfiniteRetention$Outbound;
40
+ }
41
+
42
+ export function infiniteRetentionToJSON(
43
+ infiniteRetention: InfiniteRetention,
44
+ ): string {
45
+ return JSON.stringify(
46
+ InfiniteRetention$outboundSchema.parse(infiniteRetention),
47
+ );
48
+ }
49
+
50
+ export function infiniteRetentionFromJSON(
51
+ jsonString: string,
52
+ ): SafeParseResult<InfiniteRetention, SDKValidationError> {
53
+ return safeParse(
54
+ jsonString,
55
+ (x) => InfiniteRetention$inboundSchema.parse(JSON.parse(x)),
56
+ `Failed to parse 'InfiniteRetention' from JSON`,
57
+ );
58
+ }
@@ -51,7 +51,7 @@ export type Three = {
51
51
  * @remarks
52
52
  * bucket.
53
53
  */
54
- export type Two = {
54
+ export type Metric2 = {
55
55
  accumulation: Accumulation;
56
56
  };
57
57
 
@@ -62,7 +62,7 @@ export type Metric1 = {
62
62
  scalar: Scalar;
63
63
  };
64
64
 
65
- export type Metric = Metric1 | Two | Three | Four;
65
+ export type Metric = Metric1 | Metric2 | Three | Four;
66
66
 
67
67
  /** @internal */
68
68
  export const Four$inboundSchema: z.ZodType<Four, z.ZodTypeDef, unknown> = z
@@ -156,46 +156,49 @@ export function threeFromJSON(
156
156
  }
157
157
 
158
158
  /** @internal */
159
- export const Two$inboundSchema: z.ZodType<Two, z.ZodTypeDef, unknown> = z
160
- .object({
159
+ export const Metric2$inboundSchema: z.ZodType<Metric2, z.ZodTypeDef, unknown> =
160
+ z.object({
161
161
  accumulation: Accumulation$inboundSchema,
162
162
  });
163
163
 
164
164
  /** @internal */
165
- export type Two$Outbound = {
165
+ export type Metric2$Outbound = {
166
166
  accumulation: Accumulation$Outbound;
167
167
  };
168
168
 
169
169
  /** @internal */
170
- export const Two$outboundSchema: z.ZodType<Two$Outbound, z.ZodTypeDef, Two> = z
171
- .object({
172
- accumulation: Accumulation$outboundSchema,
173
- });
170
+ export const Metric2$outboundSchema: z.ZodType<
171
+ Metric2$Outbound,
172
+ z.ZodTypeDef,
173
+ Metric2
174
+ > = z.object({
175
+ accumulation: Accumulation$outboundSchema,
176
+ });
174
177
 
175
178
  /**
176
179
  * @internal
177
180
  * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
178
181
  */
179
- export namespace Two$ {
180
- /** @deprecated use `Two$inboundSchema` instead. */
181
- export const inboundSchema = Two$inboundSchema;
182
- /** @deprecated use `Two$outboundSchema` instead. */
183
- export const outboundSchema = Two$outboundSchema;
184
- /** @deprecated use `Two$Outbound` instead. */
185
- export type Outbound = Two$Outbound;
182
+ export namespace Metric2$ {
183
+ /** @deprecated use `Metric2$inboundSchema` instead. */
184
+ export const inboundSchema = Metric2$inboundSchema;
185
+ /** @deprecated use `Metric2$outboundSchema` instead. */
186
+ export const outboundSchema = Metric2$outboundSchema;
187
+ /** @deprecated use `Metric2$Outbound` instead. */
188
+ export type Outbound = Metric2$Outbound;
186
189
  }
187
190
 
188
- export function twoToJSON(two: Two): string {
189
- return JSON.stringify(Two$outboundSchema.parse(two));
191
+ export function metric2ToJSON(metric2: Metric2): string {
192
+ return JSON.stringify(Metric2$outboundSchema.parse(metric2));
190
193
  }
191
194
 
192
- export function twoFromJSON(
195
+ export function metric2FromJSON(
193
196
  jsonString: string,
194
- ): SafeParseResult<Two, SDKValidationError> {
197
+ ): SafeParseResult<Metric2, SDKValidationError> {
195
198
  return safeParse(
196
199
  jsonString,
197
- (x) => Two$inboundSchema.parse(JSON.parse(x)),
198
- `Failed to parse 'Two' from JSON`,
200
+ (x) => Metric2$inboundSchema.parse(JSON.parse(x)),
201
+ `Failed to parse 'Metric2' from JSON`,
199
202
  );
200
203
  }
201
204
 
@@ -250,7 +253,7 @@ export function metric1FromJSON(
250
253
  export const Metric$inboundSchema: z.ZodType<Metric, z.ZodTypeDef, unknown> = z
251
254
  .union([
252
255
  z.lazy(() => Metric1$inboundSchema),
253
- z.lazy(() => Two$inboundSchema),
256
+ z.lazy(() => Metric2$inboundSchema),
254
257
  z.lazy(() => Three$inboundSchema),
255
258
  z.lazy(() => Four$inboundSchema),
256
259
  ]);
@@ -258,7 +261,7 @@ export const Metric$inboundSchema: z.ZodType<Metric, z.ZodTypeDef, unknown> = z
258
261
  /** @internal */
259
262
  export type Metric$Outbound =
260
263
  | Metric1$Outbound
261
- | Two$Outbound
264
+ | Metric2$Outbound
262
265
  | Three$Outbound
263
266
  | Four$Outbound;
264
267
 
@@ -269,7 +272,7 @@ export const Metric$outboundSchema: z.ZodType<
269
272
  Metric
270
273
  > = z.union([
271
274
  z.lazy(() => Metric1$outboundSchema),
272
- z.lazy(() => Two$outboundSchema),
275
+ z.lazy(() => Metric2$outboundSchema),
273
276
  z.lazy(() => Three$outboundSchema),
274
277
  z.lazy(() => Four$outboundSchema),
275
278
  ]);
@@ -6,24 +6,83 @@ import * as z from "zod";
6
6
  import { safeParse } from "../../lib/schemas.js";
7
7
  import { Result as SafeParseResult } from "../../types/fp.js";
8
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ InfiniteRetention,
11
+ InfiniteRetention$inboundSchema,
12
+ InfiniteRetention$Outbound,
13
+ InfiniteRetention$outboundSchema,
14
+ } from "./infiniteretention.js";
15
+
16
+ /**
17
+ * Retain records unless explicitly trimmed.
18
+ */
19
+ export type Two = {
20
+ infinite: InfiniteRetention;
21
+ };
9
22
 
10
23
  /**
11
24
  * Age in seconds for automatic trimming of records older than this threshold.
12
25
  *
13
26
  * @remarks
14
- * If this is set to 0, the stream will have infinite retention.
27
+ * This must be set to a value greater than 0 seconds.
28
+ * (While S2 is in public preview, this is capped at 28 days. Let us know if you'd like the cap removed.)
15
29
  */
16
30
  export type One = {
17
31
  /**
18
32
  * Age in seconds for automatic trimming of records older than this threshold.
19
33
  *
20
34
  * @remarks
21
- * If this is set to 0, the stream will have infinite retention.
35
+ * This must be set to a value greater than 0 seconds.
36
+ * (While S2 is in public preview, this is capped at 28 days. Let us know if you'd like the cap removed.)
22
37
  */
23
38
  age: number;
24
39
  };
25
40
 
26
- export type RetentionPolicy = One;
41
+ export type RetentionPolicy = One | Two;
42
+
43
+ /** @internal */
44
+ export const Two$inboundSchema: z.ZodType<Two, z.ZodTypeDef, unknown> = z
45
+ .object({
46
+ infinite: InfiniteRetention$inboundSchema,
47
+ });
48
+
49
+ /** @internal */
50
+ export type Two$Outbound = {
51
+ infinite: InfiniteRetention$Outbound;
52
+ };
53
+
54
+ /** @internal */
55
+ export const Two$outboundSchema: z.ZodType<Two$Outbound, z.ZodTypeDef, Two> = z
56
+ .object({
57
+ infinite: InfiniteRetention$outboundSchema,
58
+ });
59
+
60
+ /**
61
+ * @internal
62
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
63
+ */
64
+ export namespace Two$ {
65
+ /** @deprecated use `Two$inboundSchema` instead. */
66
+ export const inboundSchema = Two$inboundSchema;
67
+ /** @deprecated use `Two$outboundSchema` instead. */
68
+ export const outboundSchema = Two$outboundSchema;
69
+ /** @deprecated use `Two$Outbound` instead. */
70
+ export type Outbound = Two$Outbound;
71
+ }
72
+
73
+ export function twoToJSON(two: Two): string {
74
+ return JSON.stringify(Two$outboundSchema.parse(two));
75
+ }
76
+
77
+ export function twoFromJSON(
78
+ jsonString: string,
79
+ ): SafeParseResult<Two, SDKValidationError> {
80
+ return safeParse(
81
+ jsonString,
82
+ (x) => Two$inboundSchema.parse(JSON.parse(x)),
83
+ `Failed to parse 'Two' from JSON`,
84
+ );
85
+ }
27
86
 
28
87
  /** @internal */
29
88
  export const One$inboundSchema: z.ZodType<One, z.ZodTypeDef, unknown> = z
@@ -74,17 +133,20 @@ export const RetentionPolicy$inboundSchema: z.ZodType<
74
133
  RetentionPolicy,
75
134
  z.ZodTypeDef,
76
135
  unknown
77
- > = z.lazy(() => One$inboundSchema);
136
+ > = z.union([z.lazy(() => One$inboundSchema), z.lazy(() => Two$inboundSchema)]);
78
137
 
79
138
  /** @internal */
80
- export type RetentionPolicy$Outbound = One$Outbound;
139
+ export type RetentionPolicy$Outbound = One$Outbound | Two$Outbound;
81
140
 
82
141
  /** @internal */
83
142
  export const RetentionPolicy$outboundSchema: z.ZodType<
84
143
  RetentionPolicy$Outbound,
85
144
  z.ZodTypeDef,
86
145
  RetentionPolicy
87
- > = z.lazy(() => One$outboundSchema);
146
+ > = z.union([
147
+ z.lazy(() => One$outboundSchema),
148
+ z.lazy(() => Two$outboundSchema),
149
+ ]);
88
150
 
89
151
  /**
90
152
  * @internal
@@ -65,6 +65,9 @@ export type ReadRequest = {
65
65
  until?: number | undefined;
66
66
  /**
67
67
  * Clamp the start position at the tail position.
68
+ *
69
+ * @remarks
70
+ * If set, the read will start at the tail of the stream if the requested position is greater than it.
68
71
  */
69
72
  clamp?: boolean | undefined;
70
73
  /**
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ const value: EventStream<components.ReadEvent> = ;