@s2-dev/streamstore 0.3.17 → 0.4.2

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 (219) hide show
  1. package/README.md +53 -1
  2. package/bin/mcp-server.js +50283 -0
  3. package/bin/mcp-server.js.map +347 -0
  4. package/funcs/accountCreateBasin.d.ts +2 -1
  5. package/funcs/accountCreateBasin.d.ts.map +1 -1
  6. package/funcs/accountCreateBasin.js +11 -6
  7. package/funcs/accountCreateBasin.js.map +1 -1
  8. package/funcs/accountDeleteBasin.d.ts +2 -1
  9. package/funcs/accountDeleteBasin.d.ts.map +1 -1
  10. package/funcs/accountDeleteBasin.js +11 -6
  11. package/funcs/accountDeleteBasin.js.map +1 -1
  12. package/funcs/accountGetBasinConfig.d.ts +2 -1
  13. package/funcs/accountGetBasinConfig.d.ts.map +1 -1
  14. package/funcs/accountGetBasinConfig.js +11 -6
  15. package/funcs/accountGetBasinConfig.js.map +1 -1
  16. package/funcs/accountListBasins.d.ts +2 -1
  17. package/funcs/accountListBasins.d.ts.map +1 -1
  18. package/funcs/accountListBasins.js +19 -6
  19. package/funcs/accountListBasins.js.map +1 -1
  20. package/funcs/accountReconfigureBasin.d.ts +2 -1
  21. package/funcs/accountReconfigureBasin.d.ts.map +1 -1
  22. package/funcs/accountReconfigureBasin.js +11 -6
  23. package/funcs/accountReconfigureBasin.js.map +1 -1
  24. package/funcs/basinCreateStream.d.ts +2 -1
  25. package/funcs/basinCreateStream.d.ts.map +1 -1
  26. package/funcs/basinCreateStream.js +11 -6
  27. package/funcs/basinCreateStream.js.map +1 -1
  28. package/funcs/basinDeleteStream.d.ts +2 -1
  29. package/funcs/basinDeleteStream.d.ts.map +1 -1
  30. package/funcs/basinDeleteStream.js +11 -6
  31. package/funcs/basinDeleteStream.js.map +1 -1
  32. package/funcs/basinGetStreamConfig.d.ts +2 -1
  33. package/funcs/basinGetStreamConfig.d.ts.map +1 -1
  34. package/funcs/basinGetStreamConfig.js +11 -6
  35. package/funcs/basinGetStreamConfig.js.map +1 -1
  36. package/funcs/basinListStreams.d.ts +2 -1
  37. package/funcs/basinListStreams.d.ts.map +1 -1
  38. package/funcs/basinListStreams.js +19 -6
  39. package/funcs/basinListStreams.js.map +1 -1
  40. package/funcs/basinReconfigureStream.d.ts +2 -1
  41. package/funcs/basinReconfigureStream.d.ts.map +1 -1
  42. package/funcs/basinReconfigureStream.js +11 -6
  43. package/funcs/basinReconfigureStream.js.map +1 -1
  44. package/funcs/streamAppend.d.ts +2 -1
  45. package/funcs/streamAppend.d.ts.map +1 -1
  46. package/funcs/streamAppend.js +11 -6
  47. package/funcs/streamAppend.js.map +1 -1
  48. package/funcs/streamCheckTail.d.ts +2 -1
  49. package/funcs/streamCheckTail.d.ts.map +1 -1
  50. package/funcs/streamCheckTail.js +11 -6
  51. package/funcs/streamCheckTail.js.map +1 -1
  52. package/funcs/streamRead.d.ts +2 -1
  53. package/funcs/streamRead.d.ts.map +1 -1
  54. package/funcs/streamRead.js +11 -6
  55. package/funcs/streamRead.js.map +1 -1
  56. package/hooks/types.d.ts +1 -0
  57. package/hooks/types.d.ts.map +1 -1
  58. package/jsr.json +1 -1
  59. package/lib/config.d.ts +6 -6
  60. package/lib/config.d.ts.map +1 -1
  61. package/lib/config.js +3 -3
  62. package/lib/config.js.map +1 -1
  63. package/lib/files.js.map +1 -1
  64. package/lib/primitives.d.ts +3 -0
  65. package/lib/primitives.d.ts.map +1 -1
  66. package/lib/primitives.js +7 -0
  67. package/lib/primitives.js.map +1 -1
  68. package/lib/sdks.d.ts +1 -1
  69. package/lib/sdks.d.ts.map +1 -1
  70. package/lib/security.d.ts.map +1 -1
  71. package/lib/security.js.map +1 -1
  72. package/mcp-server/build.d.mts.map +1 -0
  73. package/mcp-server/build.mjs +14 -0
  74. package/mcp-server/build.mjs.map +1 -0
  75. package/mcp-server/cli/start/command.d.ts +2 -0
  76. package/mcp-server/cli/start/command.d.ts.map +1 -0
  77. package/mcp-server/cli/start/command.js +129 -0
  78. package/mcp-server/cli/start/command.js.map +1 -0
  79. package/mcp-server/cli/start/impl.d.ts +17 -0
  80. package/mcp-server/cli/start/impl.d.ts.map +1 -0
  81. package/mcp-server/cli/start/impl.js +102 -0
  82. package/mcp-server/cli/start/impl.js.map +1 -0
  83. package/mcp-server/cli.d.ts +6 -0
  84. package/mcp-server/cli.d.ts.map +1 -0
  85. package/mcp-server/cli.js +10 -0
  86. package/mcp-server/cli.js.map +1 -0
  87. package/mcp-server/console-logger.d.ts +7 -0
  88. package/mcp-server/console-logger.d.ts.map +1 -0
  89. package/mcp-server/console-logger.js +59 -0
  90. package/mcp-server/console-logger.js.map +1 -0
  91. package/mcp-server/mcp-server.d.ts +2 -0
  92. package/mcp-server/mcp-server.d.ts.map +1 -0
  93. package/mcp-server/mcp-server.js +29 -0
  94. package/mcp-server/mcp-server.js.map +1 -0
  95. package/mcp-server/resources.d.ts +27 -0
  96. package/mcp-server/resources.d.ts.map +1 -0
  97. package/mcp-server/resources.js +51 -0
  98. package/mcp-server/resources.js.map +1 -0
  99. package/mcp-server/scopes.d.ts +3 -0
  100. package/mcp-server/scopes.d.ts.map +1 -0
  101. package/mcp-server/scopes.js +11 -0
  102. package/mcp-server/scopes.js.map +1 -0
  103. package/mcp-server/server.d.ts +12 -0
  104. package/mcp-server/server.d.ts.map +1 -0
  105. package/mcp-server/server.js +51 -0
  106. package/mcp-server/server.js.map +1 -0
  107. package/mcp-server/shared.d.ts +7 -0
  108. package/mcp-server/shared.d.ts.map +1 -0
  109. package/mcp-server/shared.js +98 -0
  110. package/mcp-server/shared.js.map +1 -0
  111. package/mcp-server/tools/accountCreateBasin.d.ts +8 -0
  112. package/mcp-server/tools/accountCreateBasin.d.ts.map +1 -0
  113. package/mcp-server/tools/accountCreateBasin.js +63 -0
  114. package/mcp-server/tools/accountCreateBasin.js.map +1 -0
  115. package/mcp-server/tools/accountDeleteBasin.d.ts +8 -0
  116. package/mcp-server/tools/accountDeleteBasin.d.ts.map +1 -0
  117. package/mcp-server/tools/accountDeleteBasin.js +62 -0
  118. package/mcp-server/tools/accountDeleteBasin.js.map +1 -0
  119. package/mcp-server/tools/accountGetBasinConfig.d.ts +8 -0
  120. package/mcp-server/tools/accountGetBasinConfig.d.ts.map +1 -0
  121. package/mcp-server/tools/accountGetBasinConfig.js +63 -0
  122. package/mcp-server/tools/accountGetBasinConfig.js.map +1 -0
  123. package/mcp-server/tools/accountListBasins.d.ts +8 -0
  124. package/mcp-server/tools/accountListBasins.d.ts.map +1 -0
  125. package/mcp-server/tools/accountListBasins.js +63 -0
  126. package/mcp-server/tools/accountListBasins.js.map +1 -0
  127. package/mcp-server/tools/accountReconfigureBasin.d.ts +8 -0
  128. package/mcp-server/tools/accountReconfigureBasin.d.ts.map +1 -0
  129. package/mcp-server/tools/accountReconfigureBasin.js +63 -0
  130. package/mcp-server/tools/accountReconfigureBasin.js.map +1 -0
  131. package/mcp-server/tools/basinCreateStream.d.ts +8 -0
  132. package/mcp-server/tools/basinCreateStream.d.ts.map +1 -0
  133. package/mcp-server/tools/basinCreateStream.js +63 -0
  134. package/mcp-server/tools/basinCreateStream.js.map +1 -0
  135. package/mcp-server/tools/basinDeleteStream.d.ts +8 -0
  136. package/mcp-server/tools/basinDeleteStream.d.ts.map +1 -0
  137. package/mcp-server/tools/basinDeleteStream.js +62 -0
  138. package/mcp-server/tools/basinDeleteStream.js.map +1 -0
  139. package/mcp-server/tools/basinGetStreamConfig.d.ts +8 -0
  140. package/mcp-server/tools/basinGetStreamConfig.d.ts.map +1 -0
  141. package/mcp-server/tools/basinGetStreamConfig.js +63 -0
  142. package/mcp-server/tools/basinGetStreamConfig.js.map +1 -0
  143. package/mcp-server/tools/basinListStreams.d.ts +8 -0
  144. package/mcp-server/tools/basinListStreams.d.ts.map +1 -0
  145. package/mcp-server/tools/basinListStreams.js +63 -0
  146. package/mcp-server/tools/basinListStreams.js.map +1 -0
  147. package/mcp-server/tools/basinReconfigureStream.d.ts +8 -0
  148. package/mcp-server/tools/basinReconfigureStream.d.ts.map +1 -0
  149. package/mcp-server/tools/basinReconfigureStream.js +63 -0
  150. package/mcp-server/tools/basinReconfigureStream.js.map +1 -0
  151. package/mcp-server/tools/streamAppend.d.ts +8 -0
  152. package/mcp-server/tools/streamAppend.d.ts.map +1 -0
  153. package/mcp-server/tools/streamAppend.js +65 -0
  154. package/mcp-server/tools/streamAppend.js.map +1 -0
  155. package/mcp-server/tools/streamCheckTail.d.ts +8 -0
  156. package/mcp-server/tools/streamCheckTail.d.ts.map +1 -0
  157. package/mcp-server/tools/streamCheckTail.js +65 -0
  158. package/mcp-server/tools/streamCheckTail.js.map +1 -0
  159. package/mcp-server/tools/streamRead.d.ts +8 -0
  160. package/mcp-server/tools/streamRead.d.ts.map +1 -0
  161. package/mcp-server/tools/streamRead.js +65 -0
  162. package/mcp-server/tools/streamRead.js.map +1 -0
  163. package/mcp-server/tools.d.ts +25 -0
  164. package/mcp-server/tools.d.ts.map +1 -0
  165. package/mcp-server/tools.js +74 -0
  166. package/mcp-server/tools.js.map +1 -0
  167. package/models/components/endpoints.d.ts +67 -0
  168. package/models/components/endpoints.d.ts.map +1 -0
  169. package/models/components/endpoints.js +126 -0
  170. package/models/components/endpoints.js.map +1 -0
  171. package/package.json +16 -2
  172. package/src/funcs/accountCreateBasin.ts +38 -7
  173. package/src/funcs/accountDeleteBasin.ts +39 -7
  174. package/src/funcs/accountGetBasinConfig.ts +38 -7
  175. package/src/funcs/accountListBasins.ts +49 -7
  176. package/src/funcs/accountReconfigureBasin.ts +38 -7
  177. package/src/funcs/basinCreateStream.ts +38 -7
  178. package/src/funcs/basinDeleteStream.ts +39 -7
  179. package/src/funcs/basinGetStreamConfig.ts +38 -7
  180. package/src/funcs/basinListStreams.ts +49 -7
  181. package/src/funcs/basinReconfigureStream.ts +38 -7
  182. package/src/funcs/streamAppend.ts +38 -7
  183. package/src/funcs/streamCheckTail.ts +38 -7
  184. package/src/funcs/streamRead.ts +38 -7
  185. package/src/hooks/types.ts +1 -0
  186. package/src/lib/config.ts +6 -7
  187. package/src/lib/files.ts +1 -1
  188. package/src/lib/primitives.ts +14 -0
  189. package/src/lib/sdks.ts +1 -1
  190. package/src/lib/security.ts +0 -1
  191. package/src/mcp-server/cli/start/command.ts +98 -0
  192. package/src/mcp-server/cli/start/impl.ts +131 -0
  193. package/src/mcp-server/cli.ts +13 -0
  194. package/src/mcp-server/console-logger.ts +71 -0
  195. package/src/mcp-server/mcp-server.ts +26 -0
  196. package/src/mcp-server/resources.ts +96 -0
  197. package/src/mcp-server/scopes.ts +10 -0
  198. package/src/mcp-server/server.ts +60 -0
  199. package/src/mcp-server/shared.ts +75 -0
  200. package/src/mcp-server/tools/accountCreateBasin.ts +36 -0
  201. package/src/mcp-server/tools/accountDeleteBasin.ts +34 -0
  202. package/src/mcp-server/tools/accountGetBasinConfig.ts +36 -0
  203. package/src/mcp-server/tools/accountListBasins.ts +36 -0
  204. package/src/mcp-server/tools/accountReconfigureBasin.ts +36 -0
  205. package/src/mcp-server/tools/basinCreateStream.ts +36 -0
  206. package/src/mcp-server/tools/basinDeleteStream.ts +34 -0
  207. package/src/mcp-server/tools/basinGetStreamConfig.ts +36 -0
  208. package/src/mcp-server/tools/basinListStreams.ts +36 -0
  209. package/src/mcp-server/tools/basinReconfigureStream.ts +36 -0
  210. package/src/mcp-server/tools/streamAppend.ts +38 -0
  211. package/src/mcp-server/tools/streamCheckTail.ts +38 -0
  212. package/src/mcp-server/tools/streamRead.ts +38 -0
  213. package/src/mcp-server/tools.ts +116 -0
  214. package/src/models/components/endpoints.ts +159 -0
  215. package/src/types/async.ts +68 -0
  216. package/types/async.d.ts +23 -0
  217. package/types/async.d.ts.map +1 -0
  218. package/types/async.js +44 -0
  219. package/types/async.js.map +1 -0
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { streamRead } from "../../funcs/streamRead.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.ReadRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$streamRead: ToolDefinition<typeof args> = {
14
+ name: "stream_read",
15
+ description: `Retrieve records.
16
+
17
+ Retrieve a batch of records, or set \`Accept: text/event-stream\` to stream using server-sent events.`,
18
+ scopes: ["read"],
19
+ args,
20
+ tool: async (client, args, ctx) => {
21
+ const [result, apiCall] = await streamRead(
22
+ client,
23
+ args.request,
24
+ { fetchOptions: { signal: ctx.signal } },
25
+ ).$inspect();
26
+
27
+ if (!result.ok) {
28
+ return {
29
+ content: [{ type: "text", text: result.error.message }],
30
+ isError: true,
31
+ };
32
+ }
33
+
34
+ const value = result.value;
35
+
36
+ return formatResult(value, apiCall);
37
+ },
38
+ };
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
7
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
8
+ import { objectOutputType, ZodRawShape, ZodTypeAny } from "zod";
9
+ import { S2Core } from "../core.js";
10
+ import { ConsoleLogger } from "./console-logger.js";
11
+ import { MCPScope } from "./scopes.js";
12
+ import { isAsyncIterable, isBinaryData, valueToBase64 } from "./shared.js";
13
+
14
+ export type ToolDefinition<Args extends undefined | ZodRawShape = undefined> =
15
+ Args extends ZodRawShape ? {
16
+ name: string;
17
+ description: string;
18
+ scopes?: MCPScope[];
19
+ args: Args;
20
+ tool: (
21
+ client: S2Core,
22
+ args: objectOutputType<Args, ZodTypeAny>,
23
+ extra: RequestHandlerExtra,
24
+ ) => CallToolResult | Promise<CallToolResult>;
25
+ }
26
+ : {
27
+ name: string;
28
+ description: string;
29
+ scopes?: MCPScope[];
30
+ args?: undefined;
31
+ tool: (
32
+ client: S2Core,
33
+ extra: RequestHandlerExtra,
34
+ ) => CallToolResult | Promise<CallToolResult>;
35
+ };
36
+
37
+ export async function formatResult(
38
+ value: unknown,
39
+ init: { response?: Response | undefined },
40
+ ): Promise<CallToolResult> {
41
+ if (typeof value === "undefined") {
42
+ return { content: [] };
43
+ }
44
+
45
+ const { response } = init;
46
+ const contentType = response?.headers.get("content-type") ?? "";
47
+ let content: CallToolResult["content"] = [];
48
+
49
+ if (contentType.search(/\bjson\b/g)) {
50
+ content = [{ type: "text", text: JSON.stringify(value) }];
51
+ } else if (
52
+ contentType.startsWith("text/event-stream")
53
+ && isAsyncIterable(value)
54
+ ) {
55
+ content = await consumeSSE(value);
56
+ } else if (contentType.startsWith("text/") && typeof value === "string") {
57
+ content = [{ type: "text", text: value }];
58
+ } else if (isBinaryData(value) && contentType.startsWith("image/")) {
59
+ const data = await valueToBase64(value);
60
+ content = data == null
61
+ ? []
62
+ : [{ type: "image", data, mimeType: contentType }];
63
+ } else {
64
+ return {
65
+ content: [{
66
+ type: "text",
67
+ text: `Unsupported content type: "${contentType}"`,
68
+ }],
69
+ isError: true,
70
+ };
71
+ }
72
+
73
+ return { content };
74
+ }
75
+
76
+ async function consumeSSE(
77
+ value: AsyncIterable<unknown>,
78
+ ): Promise<CallToolResult["content"]> {
79
+ const content: CallToolResult["content"] = [];
80
+
81
+ for await (const chunk of value) {
82
+ if (typeof chunk === "string") {
83
+ content.push({ type: "text", text: chunk });
84
+ } else {
85
+ content.push({ type: "text", text: JSON.stringify(chunk) });
86
+ }
87
+ }
88
+
89
+ return content;
90
+ }
91
+
92
+ export function createRegisterTool(
93
+ logger: ConsoleLogger,
94
+ server: McpServer,
95
+ sdk: S2Core,
96
+ allowedScopes: Set<MCPScope>,
97
+ ): <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>) => void {
98
+ return <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>): void => {
99
+ const toolScopes = tool.scopes ?? [];
100
+ if (!toolScopes.every((s) => allowedScopes.has(s))) {
101
+ return;
102
+ }
103
+
104
+ if (tool.args) {
105
+ server.tool(tool.name, tool.description, tool.args, async (args, ctx) => {
106
+ return tool.tool(sdk, args, ctx);
107
+ });
108
+ } else {
109
+ server.tool(tool.name, tool.description, async (ctx) => {
110
+ return tool.tool(sdk, ctx);
111
+ });
112
+ }
113
+
114
+ logger.debug("Registered tool", { name: tool.name });
115
+ };
116
+ }
@@ -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
+ };
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ export type APICall =
6
+ | {
7
+ status: "complete";
8
+ request: Request;
9
+ response: Response;
10
+ }
11
+ | {
12
+ status: "request-error";
13
+ request: Request;
14
+ response?: undefined;
15
+ }
16
+ | {
17
+ status: "invalid";
18
+ request?: undefined;
19
+ response?: undefined;
20
+ };
21
+
22
+ export class APIPromise<T> implements Promise<T> {
23
+ readonly #promise: Promise<[T, APICall]>;
24
+ readonly #unwrapped: Promise<T>;
25
+
26
+ readonly [Symbol.toStringTag] = "APIPromise";
27
+
28
+ constructor(p: [T, APICall] | Promise<[T, APICall]>) {
29
+ this.#promise = p instanceof Promise ? p : Promise.resolve(p);
30
+ this.#unwrapped =
31
+ p instanceof Promise
32
+ ? this.#promise.then(([value]) => value)
33
+ : Promise.resolve(p[0]);
34
+ }
35
+
36
+ then<TResult1 = T, TResult2 = never>(
37
+ onfulfilled?:
38
+ | ((value: T) => TResult1 | PromiseLike<TResult1>)
39
+ | null
40
+ | undefined,
41
+ onrejected?:
42
+ | ((reason: any) => TResult2 | PromiseLike<TResult2>)
43
+ | null
44
+ | undefined,
45
+ ): Promise<TResult1 | TResult2> {
46
+ return this.#promise.then(
47
+ onfulfilled ? ([value]) => onfulfilled(value) : void 0,
48
+ onrejected,
49
+ );
50
+ }
51
+
52
+ catch<TResult = never>(
53
+ onrejected?:
54
+ | ((reason: any) => TResult | PromiseLike<TResult>)
55
+ | null
56
+ | undefined,
57
+ ): Promise<T | TResult> {
58
+ return this.#unwrapped.catch(onrejected);
59
+ }
60
+
61
+ finally(onfinally?: (() => void) | null | undefined): Promise<T> {
62
+ return this.#unwrapped.finally(onfinally);
63
+ }
64
+
65
+ $inspect(): Promise<[T, APICall]> {
66
+ return this.#promise;
67
+ }
68
+ }
@@ -0,0 +1,23 @@
1
+ export type APICall = {
2
+ status: "complete";
3
+ request: Request;
4
+ response: Response;
5
+ } | {
6
+ status: "request-error";
7
+ request: Request;
8
+ response?: undefined;
9
+ } | {
10
+ status: "invalid";
11
+ request?: undefined;
12
+ response?: undefined;
13
+ };
14
+ export declare class APIPromise<T> implements Promise<T> {
15
+ #private;
16
+ readonly [Symbol.toStringTag] = "APIPromise";
17
+ constructor(p: [T, APICall] | Promise<[T, APICall]>);
18
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
19
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
20
+ finally(onfinally?: (() => void) | null | undefined): Promise<T>;
21
+ $inspect(): Promise<[T, APICall]>;
22
+ }
23
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/types/async.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GACf;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,GACD;IACE,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GACD;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEN,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;;IAI9C,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB;gBAEjC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAQnD,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EACjC,WAAW,CAAC,EACR,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAChD,IAAI,GACJ,SAAS,EACb,UAAU,CAAC,EACP,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GACnD,IAAI,GACJ,SAAS,GACZ,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAO/B,KAAK,CAAC,OAAO,GAAG,KAAK,EACnB,UAAU,CAAC,EACP,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GACjD,IAAI,GACJ,SAAS,GACZ,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;IAIvB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhE,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAGlC"}
package/types/async.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
6
+ if (kind === "m") throw new TypeError("Private method is not writable");
7
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _APIPromise_promise, _APIPromise_unwrapped, _a;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.APIPromise = void 0;
19
+ class APIPromise {
20
+ constructor(p) {
21
+ _APIPromise_promise.set(this, void 0);
22
+ _APIPromise_unwrapped.set(this, void 0);
23
+ this[_a] = "APIPromise";
24
+ __classPrivateFieldSet(this, _APIPromise_promise, p instanceof Promise ? p : Promise.resolve(p), "f");
25
+ __classPrivateFieldSet(this, _APIPromise_unwrapped, p instanceof Promise
26
+ ? __classPrivateFieldGet(this, _APIPromise_promise, "f").then(([value]) => value)
27
+ : Promise.resolve(p[0]), "f");
28
+ }
29
+ then(onfulfilled, onrejected) {
30
+ return __classPrivateFieldGet(this, _APIPromise_promise, "f").then(onfulfilled ? ([value]) => onfulfilled(value) : void 0, onrejected);
31
+ }
32
+ catch(onrejected) {
33
+ return __classPrivateFieldGet(this, _APIPromise_unwrapped, "f").catch(onrejected);
34
+ }
35
+ finally(onfinally) {
36
+ return __classPrivateFieldGet(this, _APIPromise_unwrapped, "f").finally(onfinally);
37
+ }
38
+ $inspect() {
39
+ return __classPrivateFieldGet(this, _APIPromise_promise, "f");
40
+ }
41
+ }
42
+ exports.APIPromise = APIPromise;
43
+ _APIPromise_promise = new WeakMap(), _APIPromise_unwrapped = new WeakMap(), _a = Symbol.toStringTag;
44
+ //# sourceMappingURL=async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../src/types/async.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;AAmBH,MAAa,UAAU;IAMrB,YAAY,CAAuC;QAL1C,sCAAgC;QAChC,wCAAuB;QAEvB,QAAoB,GAAG,YAAY,CAAC;QAG3C,uBAAA,IAAI,uBAAY,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAA,CAAC;QAC9D,uBAAA,IAAI,yBACF,CAAC,YAAY,OAAO;YAClB,CAAC,CAAC,uBAAA,IAAI,2BAAS,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;YACxC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC;IAC9B,CAAC;IAED,IAAI,CACF,WAGa,EACb,UAGa;QAEb,OAAO,uBAAA,IAAI,2BAAS,CAAC,IAAI,CACvB,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EACtD,UAAU,CACX,CAAC;IACJ,CAAC;IAED,KAAK,CACH,UAGa;QAEb,OAAO,uBAAA,IAAI,6BAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,CAAC,SAA2C;QACjD,OAAO,uBAAA,IAAI,6BAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ;QACN,OAAO,uBAAA,IAAI,2BAAS,CAAC;IACvB,CAAC;CACF;AA9CD,gCA8CC;iFA1CW,MAAM,CAAC,WAAW"}