@steamsets/client-ts 0.34.1 → 0.34.3
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/README.md +2 -0
- package/funcs/statsSubscribe.d.ts +20 -0
- package/funcs/statsSubscribe.d.ts.map +1 -0
- package/funcs/statsSubscribe.js +128 -0
- package/funcs/statsSubscribe.js.map +1 -0
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/models/components/eventstatsheartbeatdata.d.ts +10 -0
- package/models/components/eventstatsheartbeatdata.d.ts.map +1 -0
- package/models/components/eventstatsheartbeatdata.js +50 -0
- package/models/components/eventstatsheartbeatdata.js.map +1 -0
- package/models/components/eventstatsupdateddata.d.ts +13 -0
- package/models/components/eventstatsupdateddata.d.ts.map +1 -0
- package/models/components/eventstatsupdateddata.js +51 -0
- package/models/components/eventstatsupdateddata.js.map +1 -0
- package/models/components/index.d.ts +2 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +2 -0
- package/models/components/index.js.map +1 -1
- package/models/components/v1appbadge.d.ts +12 -0
- package/models/components/v1appbadge.d.ts.map +1 -1
- package/models/components/v1appbadge.js +3 -0
- package/models/components/v1appbadge.js.map +1 -1
- package/models/operations/index.d.ts +1 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +1 -0
- package/models/operations/index.js.map +1 -1
- package/models/operations/statssubscribe.d.ts +81 -0
- package/models/operations/statssubscribe.d.ts.map +1 -0
- package/models/operations/statssubscribe.js +140 -0
- package/models/operations/statssubscribe.js.map +1 -0
- package/package.json +1 -1
- package/sdk/stats.d.ts +8 -0
- package/sdk/stats.d.ts.map +1 -1
- package/sdk/stats.js +10 -1
- package/sdk/stats.js.map +1 -1
- package/src/funcs/statsSubscribe.ts +168 -0
- package/src/lib/config.ts +3 -3
- package/src/models/components/eventstatsheartbeatdata.ts +31 -0
- package/src/models/components/eventstatsupdateddata.ts +33 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/components/v1appbadge.ts +15 -0
- package/src/models/operations/index.ts +1 -0
- package/src/models/operations/statssubscribe.ts +228 -0
- package/src/sdk/stats.ts +18 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { EventStream } from "../../lib/event-streams.js";
|
|
7
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
9
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
|
+
import * as components from "../components/index.js";
|
|
11
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
12
|
+
|
|
13
|
+
export type EventStatsUpdated = {
|
|
14
|
+
data: components.EventStatsUpdatedData;
|
|
15
|
+
/**
|
|
16
|
+
* The event name.
|
|
17
|
+
*/
|
|
18
|
+
event: "stats-updated";
|
|
19
|
+
/**
|
|
20
|
+
* The event ID.
|
|
21
|
+
*/
|
|
22
|
+
id?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The retry time in milliseconds.
|
|
25
|
+
*/
|
|
26
|
+
retry?: number | undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type EventStatsSnapshot = {
|
|
30
|
+
data: components.V1Stats;
|
|
31
|
+
/**
|
|
32
|
+
* The event name.
|
|
33
|
+
*/
|
|
34
|
+
event: "stats-snapshot";
|
|
35
|
+
/**
|
|
36
|
+
* The event ID.
|
|
37
|
+
*/
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The retry time in milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
retry?: number | undefined;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type EventStatsHeartbeat = {
|
|
46
|
+
data: components.EventStatsHeartbeatData;
|
|
47
|
+
/**
|
|
48
|
+
* The event name.
|
|
49
|
+
*/
|
|
50
|
+
event: "stats-heartbeat";
|
|
51
|
+
/**
|
|
52
|
+
* The event ID.
|
|
53
|
+
*/
|
|
54
|
+
id?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The retry time in milliseconds.
|
|
57
|
+
*/
|
|
58
|
+
retry?: number | undefined;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Each oneOf object in the array represents one possible Server Sent Events (SSE) message, serialized as UTF-8 text according to the SSE specification.
|
|
63
|
+
*/
|
|
64
|
+
export type StatsSubscribeServerSentEvents =
|
|
65
|
+
| EventStatsHeartbeat
|
|
66
|
+
| EventStatsSnapshot
|
|
67
|
+
| EventStatsUpdated;
|
|
68
|
+
|
|
69
|
+
export type StatsSubscribeResponse = {
|
|
70
|
+
httpMeta: components.HTTPMetadata;
|
|
71
|
+
/**
|
|
72
|
+
* OK
|
|
73
|
+
*/
|
|
74
|
+
serverSentEvents?:
|
|
75
|
+
| EventStream<EventStatsHeartbeat | EventStatsSnapshot | EventStatsUpdated>
|
|
76
|
+
| undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Error
|
|
79
|
+
*/
|
|
80
|
+
errorModel?: components.ErrorModel | undefined;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** @internal */
|
|
84
|
+
export const EventStatsUpdated$inboundSchema: z.ZodType<
|
|
85
|
+
EventStatsUpdated,
|
|
86
|
+
z.ZodTypeDef,
|
|
87
|
+
unknown
|
|
88
|
+
> = z.object({
|
|
89
|
+
data: z.string().transform((v, ctx) => {
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(v);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
|
|
94
|
+
return z.NEVER;
|
|
95
|
+
}
|
|
96
|
+
}).pipe(components.EventStatsUpdatedData$inboundSchema),
|
|
97
|
+
event: z.literal("stats-updated"),
|
|
98
|
+
id: z.string().optional(),
|
|
99
|
+
retry: z.number().int().optional(),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export function eventStatsUpdatedFromJSON(
|
|
103
|
+
jsonString: string,
|
|
104
|
+
): SafeParseResult<EventStatsUpdated, SDKValidationError> {
|
|
105
|
+
return safeParse(
|
|
106
|
+
jsonString,
|
|
107
|
+
(x) => EventStatsUpdated$inboundSchema.parse(JSON.parse(x)),
|
|
108
|
+
`Failed to parse 'EventStatsUpdated' from JSON`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @internal */
|
|
113
|
+
export const EventStatsSnapshot$inboundSchema: z.ZodType<
|
|
114
|
+
EventStatsSnapshot,
|
|
115
|
+
z.ZodTypeDef,
|
|
116
|
+
unknown
|
|
117
|
+
> = z.object({
|
|
118
|
+
data: z.string().transform((v, ctx) => {
|
|
119
|
+
try {
|
|
120
|
+
return JSON.parse(v);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
|
|
123
|
+
return z.NEVER;
|
|
124
|
+
}
|
|
125
|
+
}).pipe(components.V1Stats$inboundSchema),
|
|
126
|
+
event: z.literal("stats-snapshot"),
|
|
127
|
+
id: z.string().optional(),
|
|
128
|
+
retry: z.number().int().optional(),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export function eventStatsSnapshotFromJSON(
|
|
132
|
+
jsonString: string,
|
|
133
|
+
): SafeParseResult<EventStatsSnapshot, SDKValidationError> {
|
|
134
|
+
return safeParse(
|
|
135
|
+
jsonString,
|
|
136
|
+
(x) => EventStatsSnapshot$inboundSchema.parse(JSON.parse(x)),
|
|
137
|
+
`Failed to parse 'EventStatsSnapshot' from JSON`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @internal */
|
|
142
|
+
export const EventStatsHeartbeat$inboundSchema: z.ZodType<
|
|
143
|
+
EventStatsHeartbeat,
|
|
144
|
+
z.ZodTypeDef,
|
|
145
|
+
unknown
|
|
146
|
+
> = z.object({
|
|
147
|
+
data: z.string().transform((v, ctx) => {
|
|
148
|
+
try {
|
|
149
|
+
return JSON.parse(v);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
|
|
152
|
+
return z.NEVER;
|
|
153
|
+
}
|
|
154
|
+
}).pipe(components.EventStatsHeartbeatData$inboundSchema),
|
|
155
|
+
event: z.literal("stats-heartbeat"),
|
|
156
|
+
id: z.string().optional(),
|
|
157
|
+
retry: z.number().int().optional(),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export function eventStatsHeartbeatFromJSON(
|
|
161
|
+
jsonString: string,
|
|
162
|
+
): SafeParseResult<EventStatsHeartbeat, SDKValidationError> {
|
|
163
|
+
return safeParse(
|
|
164
|
+
jsonString,
|
|
165
|
+
(x) => EventStatsHeartbeat$inboundSchema.parse(JSON.parse(x)),
|
|
166
|
+
`Failed to parse 'EventStatsHeartbeat' from JSON`,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** @internal */
|
|
171
|
+
export const StatsSubscribeServerSentEvents$inboundSchema: z.ZodType<
|
|
172
|
+
StatsSubscribeServerSentEvents,
|
|
173
|
+
z.ZodTypeDef,
|
|
174
|
+
unknown
|
|
175
|
+
> = z.union([
|
|
176
|
+
z.lazy(() => EventStatsHeartbeat$inboundSchema),
|
|
177
|
+
z.lazy(() => EventStatsSnapshot$inboundSchema),
|
|
178
|
+
z.lazy(() => EventStatsUpdated$inboundSchema),
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
export function statsSubscribeServerSentEventsFromJSON(
|
|
182
|
+
jsonString: string,
|
|
183
|
+
): SafeParseResult<StatsSubscribeServerSentEvents, SDKValidationError> {
|
|
184
|
+
return safeParse(
|
|
185
|
+
jsonString,
|
|
186
|
+
(x) => StatsSubscribeServerSentEvents$inboundSchema.parse(JSON.parse(x)),
|
|
187
|
+
`Failed to parse 'StatsSubscribeServerSentEvents' from JSON`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** @internal */
|
|
192
|
+
export const StatsSubscribeResponse$inboundSchema: z.ZodType<
|
|
193
|
+
StatsSubscribeResponse,
|
|
194
|
+
z.ZodTypeDef,
|
|
195
|
+
unknown
|
|
196
|
+
> = z.object({
|
|
197
|
+
HttpMeta: components.HTTPMetadata$inboundSchema,
|
|
198
|
+
"Server Sent Events": z.instanceof(ReadableStream<Uint8Array>)
|
|
199
|
+
.transform(stream => {
|
|
200
|
+
return new EventStream(stream, rawEvent => {
|
|
201
|
+
return {
|
|
202
|
+
done: false,
|
|
203
|
+
value: z.union([
|
|
204
|
+
z.lazy(() => EventStatsHeartbeat$inboundSchema),
|
|
205
|
+
z.lazy(() => EventStatsSnapshot$inboundSchema),
|
|
206
|
+
z.lazy(() => EventStatsUpdated$inboundSchema),
|
|
207
|
+
]).parse(rawEvent),
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
}).optional(),
|
|
211
|
+
ErrorModel: components.ErrorModel$inboundSchema.optional(),
|
|
212
|
+
}).transform((v) => {
|
|
213
|
+
return remap$(v, {
|
|
214
|
+
"HttpMeta": "httpMeta",
|
|
215
|
+
"Server Sent Events": "serverSentEvents",
|
|
216
|
+
"ErrorModel": "errorModel",
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
export function statsSubscribeResponseFromJSON(
|
|
221
|
+
jsonString: string,
|
|
222
|
+
): SafeParseResult<StatsSubscribeResponse, SDKValidationError> {
|
|
223
|
+
return safeParse(
|
|
224
|
+
jsonString,
|
|
225
|
+
(x) => StatsSubscribeResponse$inboundSchema.parse(JSON.parse(x)),
|
|
226
|
+
`Failed to parse 'StatsSubscribeResponse' from JSON`,
|
|
227
|
+
);
|
|
228
|
+
}
|
package/src/sdk/stats.ts
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { statsGet } from "../funcs/statsGet.js";
|
|
6
|
+
import {
|
|
7
|
+
statsSubscribe,
|
|
8
|
+
SubscribeAcceptEnum,
|
|
9
|
+
} from "../funcs/statsSubscribe.js";
|
|
6
10
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
7
11
|
import * as operations from "../models/operations/index.js";
|
|
8
12
|
import { unwrapAsync } from "../types/fp.js";
|
|
9
13
|
|
|
14
|
+
export { SubscribeAcceptEnum } from "../funcs/statsSubscribe.js";
|
|
15
|
+
|
|
10
16
|
export class Stats extends ClientSDK {
|
|
11
17
|
/**
|
|
12
18
|
* Get platform statistics
|
|
@@ -19,4 +25,16 @@ export class Stats extends ClientSDK {
|
|
|
19
25
|
options,
|
|
20
26
|
));
|
|
21
27
|
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Server-sent-events stream of platform stats. Emits a snapshot, then deltas as the queues commit them.
|
|
31
|
+
*/
|
|
32
|
+
async subscribe(
|
|
33
|
+
options?: RequestOptions & { acceptHeaderOverride?: SubscribeAcceptEnum },
|
|
34
|
+
): Promise<operations.StatsSubscribeResponse> {
|
|
35
|
+
return unwrapAsync(statsSubscribe(
|
|
36
|
+
this,
|
|
37
|
+
options,
|
|
38
|
+
));
|
|
39
|
+
}
|
|
22
40
|
}
|