@s2-dev/streamstore 0.5.2 → 0.7.1
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/bin/mcp-server.js +136 -69
- package/bin/mcp-server.js.map +15 -14
- package/dist/commonjs/index.extras.d.ts.map +1 -1
- package/dist/commonjs/index.extras.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/mcp-server/cli/start/command.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/cli/start/command.js +9 -0
- package/dist/commonjs/mcp-server/cli/start/command.js.map +1 -1
- package/dist/commonjs/mcp-server/cli/start/impl.d.ts +1 -0
- package/dist/commonjs/mcp-server/cli/start/impl.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/cli/start/impl.js +2 -0
- package/dist/commonjs/mcp-server/cli/start/impl.js.map +1 -1
- package/dist/commonjs/mcp-server/extensions.d.ts +9 -0
- package/dist/commonjs/mcp-server/extensions.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/extensions.js +6 -0
- package/dist/commonjs/mcp-server/extensions.js.map +1 -0
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/resources.d.ts +9 -4
- package/dist/commonjs/mcp-server/resources.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/resources.js +36 -9
- package/dist/commonjs/mcp-server/resources.js.map +1 -1
- package/dist/commonjs/mcp-server/server.d.ts +1 -0
- package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/server.js +8 -2
- package/dist/commonjs/mcp-server/server.js.map +1 -1
- package/dist/commonjs/mcp-server/tools.d.ts +1 -1
- package/dist/commonjs/mcp-server/tools.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/tools.js +4 -1
- package/dist/commonjs/mcp-server/tools.js.map +1 -1
- package/dist/commonjs/models/components/basininfo.d.ts +2 -6
- package/dist/commonjs/models/components/basininfo.d.ts.map +1 -1
- package/dist/commonjs/models/components/basininfo.js +3 -4
- package/dist/commonjs/models/components/basininfo.js.map +1 -1
- package/dist/commonjs/models/components/basinscope.d.ts +34 -0
- package/dist/commonjs/models/components/basinscope.d.ts.map +1 -0
- package/dist/commonjs/models/components/basinscope.js +64 -0
- package/dist/commonjs/models/components/basinscope.js.map +1 -0
- package/dist/commonjs/models/components/createbasinrequest.d.ts +6 -3
- package/dist/commonjs/models/components/createbasinrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/createbasinrequest.js +3 -3
- package/dist/commonjs/models/components/createbasinrequest.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +1 -1
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +1 -1
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/readresponse.d.ts +108 -16
- package/dist/commonjs/models/components/readresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/readresponse.js +106 -22
- package/dist/commonjs/models/components/readresponse.js.map +1 -1
- package/dist/esm/index.extras.d.ts.map +1 -1
- package/dist/esm/index.extras.js.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/mcp-server/cli/start/command.d.ts.map +1 -1
- package/dist/esm/mcp-server/cli/start/command.js +9 -0
- package/dist/esm/mcp-server/cli/start/command.js.map +1 -1
- package/dist/esm/mcp-server/cli/start/impl.d.ts +1 -0
- package/dist/esm/mcp-server/cli/start/impl.d.ts.map +1 -1
- package/dist/esm/mcp-server/cli/start/impl.js +2 -0
- package/dist/esm/mcp-server/cli/start/impl.js.map +1 -1
- package/dist/esm/mcp-server/extensions.d.ts +9 -0
- package/dist/esm/mcp-server/extensions.d.ts.map +1 -0
- package/dist/esm/mcp-server/extensions.js +5 -0
- package/dist/esm/mcp-server/extensions.js.map +1 -0
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/resources.d.ts +9 -4
- package/dist/esm/mcp-server/resources.d.ts.map +1 -1
- package/dist/esm/mcp-server/resources.js +34 -9
- package/dist/esm/mcp-server/resources.js.map +1 -1
- package/dist/esm/mcp-server/server.d.ts +1 -0
- package/dist/esm/mcp-server/server.d.ts.map +1 -1
- package/dist/esm/mcp-server/server.js +8 -2
- package/dist/esm/mcp-server/server.js.map +1 -1
- package/dist/esm/mcp-server/tools.d.ts +1 -1
- package/dist/esm/mcp-server/tools.d.ts.map +1 -1
- package/dist/esm/mcp-server/tools.js +4 -1
- package/dist/esm/mcp-server/tools.js.map +1 -1
- package/dist/esm/models/components/basininfo.d.ts +2 -6
- package/dist/esm/models/components/basininfo.d.ts.map +1 -1
- package/dist/esm/models/components/basininfo.js +3 -4
- package/dist/esm/models/components/basininfo.js.map +1 -1
- package/dist/esm/models/components/basinscope.d.ts +34 -0
- package/dist/esm/models/components/basinscope.d.ts.map +1 -0
- package/dist/esm/models/components/basinscope.js +28 -0
- package/dist/esm/models/components/basinscope.js.map +1 -0
- package/dist/esm/models/components/createbasinrequest.d.ts +6 -3
- package/dist/esm/models/components/createbasinrequest.d.ts.map +1 -1
- package/dist/esm/models/components/createbasinrequest.js +3 -3
- package/dist/esm/models/components/createbasinrequest.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +1 -1
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +1 -1
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/readresponse.d.ts +108 -16
- package/dist/esm/models/components/readresponse.d.ts.map +1 -1
- package/dist/esm/models/components/readresponse.js +101 -19
- package/dist/esm/models/components/readresponse.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/index.extras.ts +2 -2
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/cli/start/command.ts +9 -0
- package/src/mcp-server/cli/start/impl.ts +3 -0
- package/src/mcp-server/extensions.ts +13 -0
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/resources.ts +75 -14
- package/src/mcp-server/server.ts +25 -2
- package/src/mcp-server/tools.ts +5 -0
- package/src/models/components/basininfo.ts +8 -10
- package/src/models/components/basinscope.ts +37 -0
- package/src/models/components/createbasinrequest.ts +12 -10
- package/src/models/components/index.ts +1 -1
- package/src/models/components/readresponse.ts +170 -48
- package/dist/commonjs/models/components/assignment.d.ts +0 -90
- package/dist/commonjs/models/components/assignment.d.ts.map +0 -1
- package/dist/commonjs/models/components/assignment.js +0 -127
- package/dist/commonjs/models/components/assignment.js.map +0 -1
- package/dist/esm/models/components/assignment.d.ts +0 -90
- package/dist/esm/models/components/assignment.d.ts.map +0 -1
- package/dist/esm/models/components/assignment.js +0 -85
- package/dist/esm/models/components/assignment.js.map +0 -1
- package/src/models/components/assignment.ts +0 -174
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
McpServer,
|
|
7
|
+
ResourceMetadata,
|
|
8
|
+
ResourceTemplate,
|
|
9
|
+
} from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
10
|
import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
7
11
|
import { Variables } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
|
8
12
|
import { ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
|
9
13
|
import { S2Core } from "../core.js";
|
|
10
|
-
import {
|
|
14
|
+
import { ConsoleLogger } from "./console-logger.js";
|
|
11
15
|
import { MCPScope } from "./scopes.js";
|
|
12
16
|
import { isAsyncIterable, isBinaryData, valueToBase64 } from "./shared.js";
|
|
13
17
|
|
|
@@ -19,7 +23,8 @@ export type ReadResourceCallback = (
|
|
|
19
23
|
|
|
20
24
|
export type ResourceDefinition = {
|
|
21
25
|
name: string;
|
|
22
|
-
description
|
|
26
|
+
description?: string;
|
|
27
|
+
metadata?: ResourceMetadata;
|
|
23
28
|
scopes?: MCPScope[];
|
|
24
29
|
resource: string;
|
|
25
30
|
read: ReadResourceCallback;
|
|
@@ -35,30 +40,27 @@ export type ReadResourceTemplateCallback = (
|
|
|
35
40
|
export type ResourceTemplateDefinition = {
|
|
36
41
|
name: string;
|
|
37
42
|
description: string;
|
|
43
|
+
metadata?: ResourceMetadata;
|
|
38
44
|
scopes?: MCPScope[];
|
|
39
45
|
resource: ResourceTemplate;
|
|
40
46
|
read: ReadResourceTemplateCallback;
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
export async function formatResult(
|
|
44
|
-
|
|
50
|
+
value: unknown,
|
|
45
51
|
uri: URL,
|
|
46
|
-
init: { response?: Response | undefined },
|
|
52
|
+
init: { mimeType?: string | undefined; response?: Response | undefined },
|
|
47
53
|
): Promise<ReadResourceResult> {
|
|
48
|
-
if (!result.ok) {
|
|
49
|
-
throw result.error;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const { value } = result;
|
|
53
54
|
if (typeof value === "undefined") {
|
|
54
55
|
return { contents: [] };
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
const { response } = init;
|
|
58
|
-
const mimeType = response?.headers.get("content-type") ?? "";
|
|
59
58
|
let contents: ReadResourceResult["contents"] = [];
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
const mimeType = init.mimeType ?? init.response?.headers.get("content-type")
|
|
61
|
+
?? "";
|
|
62
|
+
|
|
63
|
+
if (mimeType.search(/\bjson\b/g) !== -1) {
|
|
62
64
|
contents = [{ uri: uri.toString(), mimeType, text: JSON.stringify(value) }];
|
|
63
65
|
} else if (
|
|
64
66
|
mimeType.startsWith("text/event-stream")
|
|
@@ -71,7 +73,10 @@ export async function formatResult(
|
|
|
71
73
|
text: await stringifySSEToJSON(value),
|
|
72
74
|
},
|
|
73
75
|
];
|
|
74
|
-
} else if (
|
|
76
|
+
} else if (
|
|
77
|
+
(mimeType.startsWith("text/") || mimeType.startsWith("application/"))
|
|
78
|
+
&& typeof value === "string"
|
|
79
|
+
) {
|
|
75
80
|
contents = [{ uri: uri.toString(), mimeType, text: value }];
|
|
76
81
|
} else if (isBinaryData(value)) {
|
|
77
82
|
const blob = await valueToBase64(value);
|
|
@@ -94,3 +99,59 @@ async function stringifySSEToJSON(
|
|
|
94
99
|
|
|
95
100
|
return JSON.stringify(payloads);
|
|
96
101
|
}
|
|
102
|
+
|
|
103
|
+
export function createRegisterResource(
|
|
104
|
+
logger: ConsoleLogger,
|
|
105
|
+
server: McpServer,
|
|
106
|
+
sdk: S2Core,
|
|
107
|
+
allowedScopes: Set<MCPScope>,
|
|
108
|
+
): (resource: ResourceDefinition) => void {
|
|
109
|
+
return (resource: ResourceDefinition): void => {
|
|
110
|
+
const scopes = resource.scopes ?? [];
|
|
111
|
+
if (!scopes.every((s: MCPScope) => allowedScopes.has(s))) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const metadata: ResourceMetadata = {
|
|
116
|
+
...resource.metadata,
|
|
117
|
+
description: resource.description,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
server.resource(
|
|
121
|
+
resource.name,
|
|
122
|
+
resource.resource,
|
|
123
|
+
metadata,
|
|
124
|
+
async (uri, ctx) => resource.read(sdk, uri, ctx),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
logger.debug("Registered resource", { name: resource.name });
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function createRegisterResourceTemplate(
|
|
132
|
+
logger: ConsoleLogger,
|
|
133
|
+
server: McpServer,
|
|
134
|
+
sdk: S2Core,
|
|
135
|
+
allowedScopes: Set<MCPScope>,
|
|
136
|
+
): (resource: ResourceTemplateDefinition) => void {
|
|
137
|
+
return (resource: ResourceTemplateDefinition): void => {
|
|
138
|
+
const scopes = resource.scopes ?? [];
|
|
139
|
+
if (!scopes.every((s: MCPScope) => allowedScopes.has(s))) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const metadata: ResourceMetadata = {
|
|
144
|
+
...resource.metadata,
|
|
145
|
+
description: resource.description,
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
server.resource(
|
|
149
|
+
resource.name,
|
|
150
|
+
resource.resource,
|
|
151
|
+
metadata,
|
|
152
|
+
async (uri, vars, ctx) => resource.read(sdk, uri, vars, ctx),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
logger.debug("Registered resource template", { name: resource.name });
|
|
156
|
+
};
|
|
157
|
+
}
|
package/src/mcp-server/server.ts
CHANGED
|
@@ -6,6 +6,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
6
6
|
import { S2Core } from "../core.js";
|
|
7
7
|
import { SDKOptions } from "../lib/config.js";
|
|
8
8
|
import type { ConsoleLogger } from "./console-logger.js";
|
|
9
|
+
import {
|
|
10
|
+
createRegisterResource,
|
|
11
|
+
createRegisterResourceTemplate,
|
|
12
|
+
} from "./resources.js";
|
|
9
13
|
import { MCPScope, mcpScopes } from "./scopes.js";
|
|
10
14
|
import { createRegisterTool } from "./tools.js";
|
|
11
15
|
import { tool$accountCreateBasin } from "./tools/accountCreateBasin.js";
|
|
@@ -24,6 +28,7 @@ import { tool$streamRead } from "./tools/streamRead.js";
|
|
|
24
28
|
|
|
25
29
|
export function createMCPServer(deps: {
|
|
26
30
|
logger: ConsoleLogger;
|
|
31
|
+
allowedTools?: string[] | undefined;
|
|
27
32
|
scopes?: MCPScope[] | undefined;
|
|
28
33
|
serverURL?: string | undefined;
|
|
29
34
|
bearerAuth?: SDKOptions["bearerAuth"] | undefined;
|
|
@@ -31,7 +36,7 @@ export function createMCPServer(deps: {
|
|
|
31
36
|
}) {
|
|
32
37
|
const server = new McpServer({
|
|
33
38
|
name: "S2",
|
|
34
|
-
version: "0.
|
|
39
|
+
version: "0.7.1",
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
const client = new S2Core({
|
|
@@ -39,8 +44,26 @@ export function createMCPServer(deps: {
|
|
|
39
44
|
serverURL: deps.serverURL,
|
|
40
45
|
serverIdx: deps.serverIdx,
|
|
41
46
|
});
|
|
47
|
+
|
|
42
48
|
const scopes = new Set(deps.scopes ?? mcpScopes);
|
|
43
|
-
|
|
49
|
+
|
|
50
|
+
const allowedTools = deps.allowedTools && new Set(deps.allowedTools);
|
|
51
|
+
const tool = createRegisterTool(
|
|
52
|
+
deps.logger,
|
|
53
|
+
server,
|
|
54
|
+
client,
|
|
55
|
+
scopes,
|
|
56
|
+
allowedTools,
|
|
57
|
+
);
|
|
58
|
+
const resource = createRegisterResource(deps.logger, server, client, scopes);
|
|
59
|
+
const resourceTemplate = createRegisterResourceTemplate(
|
|
60
|
+
deps.logger,
|
|
61
|
+
server,
|
|
62
|
+
client,
|
|
63
|
+
scopes,
|
|
64
|
+
);
|
|
65
|
+
const register = { tool, resource, resourceTemplate };
|
|
66
|
+
void register; // suppress unused warnings
|
|
44
67
|
|
|
45
68
|
tool(tool$accountListBasins);
|
|
46
69
|
tool(tool$accountGetBasinConfig);
|
package/src/mcp-server/tools.ts
CHANGED
|
@@ -94,8 +94,13 @@ export function createRegisterTool(
|
|
|
94
94
|
server: McpServer,
|
|
95
95
|
sdk: S2Core,
|
|
96
96
|
allowedScopes: Set<MCPScope>,
|
|
97
|
+
allowedTools?: Set<string>,
|
|
97
98
|
): <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>) => void {
|
|
98
99
|
return <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>): void => {
|
|
100
|
+
if (allowedTools && !allowedTools.has(tool.name)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
const toolScopes = tool.scopes ?? [];
|
|
100
105
|
if (!toolScopes.every((s) => allowedScopes.has(s))) {
|
|
101
106
|
return;
|
|
@@ -6,6 +6,11 @@ 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
|
+
BasinScope,
|
|
11
|
+
BasinScope$inboundSchema,
|
|
12
|
+
BasinScope$outboundSchema,
|
|
13
|
+
} from "./basinscope.js";
|
|
9
14
|
import {
|
|
10
15
|
BasinState,
|
|
11
16
|
BasinState$inboundSchema,
|
|
@@ -16,10 +21,6 @@ import {
|
|
|
16
21
|
* Basin information.
|
|
17
22
|
*/
|
|
18
23
|
export type BasinInfo = {
|
|
19
|
-
/**
|
|
20
|
-
* Cell assignment.
|
|
21
|
-
*/
|
|
22
|
-
cell: string;
|
|
23
24
|
/**
|
|
24
25
|
* Basin name.
|
|
25
26
|
*/
|
|
@@ -27,7 +28,7 @@ export type BasinInfo = {
|
|
|
27
28
|
/**
|
|
28
29
|
* Basin scope.
|
|
29
30
|
*/
|
|
30
|
-
scope:
|
|
31
|
+
scope: BasinScope;
|
|
31
32
|
/**
|
|
32
33
|
* Current state of the basin.
|
|
33
34
|
*/
|
|
@@ -40,15 +41,13 @@ export const BasinInfo$inboundSchema: z.ZodType<
|
|
|
40
41
|
z.ZodTypeDef,
|
|
41
42
|
unknown
|
|
42
43
|
> = z.object({
|
|
43
|
-
cell: z.string(),
|
|
44
44
|
name: z.string(),
|
|
45
|
-
scope:
|
|
45
|
+
scope: BasinScope$inboundSchema,
|
|
46
46
|
state: BasinState$inboundSchema,
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
/** @internal */
|
|
50
50
|
export type BasinInfo$Outbound = {
|
|
51
|
-
cell: string;
|
|
52
51
|
name: string;
|
|
53
52
|
scope: string;
|
|
54
53
|
state: string;
|
|
@@ -60,9 +59,8 @@ export const BasinInfo$outboundSchema: z.ZodType<
|
|
|
60
59
|
z.ZodTypeDef,
|
|
61
60
|
BasinInfo
|
|
62
61
|
> = z.object({
|
|
63
|
-
cell: z.string(),
|
|
64
62
|
name: z.string(),
|
|
65
|
-
scope:
|
|
63
|
+
scope: BasinScope$outboundSchema,
|
|
66
64
|
state: BasinState$outboundSchema,
|
|
67
65
|
});
|
|
68
66
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Basin scope.
|
|
10
|
+
*/
|
|
11
|
+
export const BasinScope = {
|
|
12
|
+
Unspecified: "unspecified",
|
|
13
|
+
AwsUsEast1: "aws:us-east-1",
|
|
14
|
+
} as const;
|
|
15
|
+
/**
|
|
16
|
+
* Basin scope.
|
|
17
|
+
*/
|
|
18
|
+
export type BasinScope = ClosedEnum<typeof BasinScope>;
|
|
19
|
+
|
|
20
|
+
/** @internal */
|
|
21
|
+
export const BasinScope$inboundSchema: z.ZodNativeEnum<typeof BasinScope> = z
|
|
22
|
+
.nativeEnum(BasinScope);
|
|
23
|
+
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const BasinScope$outboundSchema: z.ZodNativeEnum<typeof BasinScope> =
|
|
26
|
+
BasinScope$inboundSchema;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
31
|
+
*/
|
|
32
|
+
export namespace BasinScope$ {
|
|
33
|
+
/** @deprecated use `BasinScope$inboundSchema` instead. */
|
|
34
|
+
export const inboundSchema = BasinScope$inboundSchema;
|
|
35
|
+
/** @deprecated use `BasinScope$outboundSchema` instead. */
|
|
36
|
+
export const outboundSchema = BasinScope$outboundSchema;
|
|
37
|
+
}
|
|
@@ -6,25 +6,27 @@ 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
|
-
Assignment,
|
|
11
|
-
Assignment$inboundSchema,
|
|
12
|
-
Assignment$Outbound,
|
|
13
|
-
Assignment$outboundSchema,
|
|
14
|
-
} from "./assignment.js";
|
|
15
9
|
import {
|
|
16
10
|
BasinConfig,
|
|
17
11
|
BasinConfig$inboundSchema,
|
|
18
12
|
BasinConfig$Outbound,
|
|
19
13
|
BasinConfig$outboundSchema,
|
|
20
14
|
} from "./basinconfig.js";
|
|
15
|
+
import {
|
|
16
|
+
BasinScope,
|
|
17
|
+
BasinScope$inboundSchema,
|
|
18
|
+
BasinScope$outboundSchema,
|
|
19
|
+
} from "./basinscope.js";
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Create basin request.
|
|
24
23
|
*/
|
|
25
24
|
export type CreateBasinRequest = {
|
|
26
|
-
assignment?: Assignment | null | undefined;
|
|
27
25
|
config?: BasinConfig | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Basin scope.
|
|
28
|
+
*/
|
|
29
|
+
scope?: BasinScope | undefined;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
/** @internal */
|
|
@@ -33,14 +35,14 @@ export const CreateBasinRequest$inboundSchema: z.ZodType<
|
|
|
33
35
|
z.ZodTypeDef,
|
|
34
36
|
unknown
|
|
35
37
|
> = z.object({
|
|
36
|
-
assignment: z.nullable(Assignment$inboundSchema).optional(),
|
|
37
38
|
config: z.nullable(BasinConfig$inboundSchema).optional(),
|
|
39
|
+
scope: BasinScope$inboundSchema.optional(),
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
/** @internal */
|
|
41
43
|
export type CreateBasinRequest$Outbound = {
|
|
42
|
-
assignment?: Assignment$Outbound | null | undefined;
|
|
43
44
|
config?: BasinConfig$Outbound | null | undefined;
|
|
45
|
+
scope?: string | undefined;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
/** @internal */
|
|
@@ -49,8 +51,8 @@ export const CreateBasinRequest$outboundSchema: z.ZodType<
|
|
|
49
51
|
z.ZodTypeDef,
|
|
50
52
|
CreateBasinRequest
|
|
51
53
|
> = z.object({
|
|
52
|
-
assignment: z.nullable(Assignment$outboundSchema).optional(),
|
|
53
54
|
config: z.nullable(BasinConfig$outboundSchema).optional(),
|
|
55
|
+
scope: BasinScope$outboundSchema.optional(),
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
/**
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
export * from "./appendinput.js";
|
|
6
6
|
export * from "./appendoutput.js";
|
|
7
7
|
export * from "./appendrecord.js";
|
|
8
|
-
export * from "./assignment.js";
|
|
9
8
|
export * from "./basinconfig.js";
|
|
10
9
|
export * from "./basininfo.js";
|
|
10
|
+
export * from "./basinscope.js";
|
|
11
11
|
export * from "./basinstate.js";
|
|
12
12
|
export * from "./checktailresponse.js";
|
|
13
13
|
export * from "./createbasinrequest.js";
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
7
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
10
|
import {
|
|
@@ -13,26 +14,131 @@ import {
|
|
|
13
14
|
Output$outboundSchema,
|
|
14
15
|
} from "./output.js";
|
|
15
16
|
|
|
17
|
+
export const ReadResponse3Event = {
|
|
18
|
+
Ping: "ping",
|
|
19
|
+
} as const;
|
|
20
|
+
export type ReadResponse3Event = ClosedEnum<typeof ReadResponse3Event>;
|
|
21
|
+
|
|
22
|
+
export type Ping = {
|
|
23
|
+
event: ReadResponse3Event;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const ReadResponseEvent = {
|
|
27
|
+
Error: "error",
|
|
28
|
+
} as const;
|
|
29
|
+
export type ReadResponseEvent = ClosedEnum<typeof ReadResponseEvent>;
|
|
30
|
+
|
|
16
31
|
export type ErrorT = {
|
|
17
32
|
data: string;
|
|
18
|
-
event:
|
|
33
|
+
event: ReadResponseEvent;
|
|
19
34
|
};
|
|
20
35
|
|
|
21
|
-
export
|
|
36
|
+
export const Event = {
|
|
37
|
+
Message: "message",
|
|
38
|
+
} as const;
|
|
39
|
+
export type Event = ClosedEnum<typeof Event>;
|
|
40
|
+
|
|
41
|
+
export type Message = {
|
|
22
42
|
/**
|
|
23
43
|
* Reply which can be a batch of records, or a sequence number if the request could not be satisfied.
|
|
24
44
|
*/
|
|
25
45
|
data: Output;
|
|
46
|
+
event: Event;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type ReadResponse = Ping | Message | ErrorT;
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
export const ReadResponse3Event$inboundSchema: z.ZodNativeEnum<
|
|
53
|
+
typeof ReadResponse3Event
|
|
54
|
+
> = z.nativeEnum(ReadResponse3Event);
|
|
55
|
+
|
|
56
|
+
/** @internal */
|
|
57
|
+
export const ReadResponse3Event$outboundSchema: z.ZodNativeEnum<
|
|
58
|
+
typeof ReadResponse3Event
|
|
59
|
+
> = ReadResponse3Event$inboundSchema;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
64
|
+
*/
|
|
65
|
+
export namespace ReadResponse3Event$ {
|
|
66
|
+
/** @deprecated use `ReadResponse3Event$inboundSchema` instead. */
|
|
67
|
+
export const inboundSchema = ReadResponse3Event$inboundSchema;
|
|
68
|
+
/** @deprecated use `ReadResponse3Event$outboundSchema` instead. */
|
|
69
|
+
export const outboundSchema = ReadResponse3Event$outboundSchema;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @internal */
|
|
73
|
+
export const Ping$inboundSchema: z.ZodType<Ping, z.ZodTypeDef, unknown> = z
|
|
74
|
+
.object({
|
|
75
|
+
event: ReadResponse3Event$inboundSchema,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** @internal */
|
|
79
|
+
export type Ping$Outbound = {
|
|
26
80
|
event: string;
|
|
27
81
|
};
|
|
28
82
|
|
|
29
|
-
|
|
83
|
+
/** @internal */
|
|
84
|
+
export const Ping$outboundSchema: z.ZodType<Ping$Outbound, z.ZodTypeDef, Ping> =
|
|
85
|
+
z.object({
|
|
86
|
+
event: ReadResponse3Event$outboundSchema,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
92
|
+
*/
|
|
93
|
+
export namespace Ping$ {
|
|
94
|
+
/** @deprecated use `Ping$inboundSchema` instead. */
|
|
95
|
+
export const inboundSchema = Ping$inboundSchema;
|
|
96
|
+
/** @deprecated use `Ping$outboundSchema` instead. */
|
|
97
|
+
export const outboundSchema = Ping$outboundSchema;
|
|
98
|
+
/** @deprecated use `Ping$Outbound` instead. */
|
|
99
|
+
export type Outbound = Ping$Outbound;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function pingToJSON(ping: Ping): string {
|
|
103
|
+
return JSON.stringify(Ping$outboundSchema.parse(ping));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function pingFromJSON(
|
|
107
|
+
jsonString: string,
|
|
108
|
+
): SafeParseResult<Ping, SDKValidationError> {
|
|
109
|
+
return safeParse(
|
|
110
|
+
jsonString,
|
|
111
|
+
(x) => Ping$inboundSchema.parse(JSON.parse(x)),
|
|
112
|
+
`Failed to parse 'Ping' from JSON`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @internal */
|
|
117
|
+
export const ReadResponseEvent$inboundSchema: z.ZodNativeEnum<
|
|
118
|
+
typeof ReadResponseEvent
|
|
119
|
+
> = z.nativeEnum(ReadResponseEvent);
|
|
120
|
+
|
|
121
|
+
/** @internal */
|
|
122
|
+
export const ReadResponseEvent$outboundSchema: z.ZodNativeEnum<
|
|
123
|
+
typeof ReadResponseEvent
|
|
124
|
+
> = ReadResponseEvent$inboundSchema;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @internal
|
|
128
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
129
|
+
*/
|
|
130
|
+
export namespace ReadResponseEvent$ {
|
|
131
|
+
/** @deprecated use `ReadResponseEvent$inboundSchema` instead. */
|
|
132
|
+
export const inboundSchema = ReadResponseEvent$inboundSchema;
|
|
133
|
+
/** @deprecated use `ReadResponseEvent$outboundSchema` instead. */
|
|
134
|
+
export const outboundSchema = ReadResponseEvent$outboundSchema;
|
|
135
|
+
}
|
|
30
136
|
|
|
31
137
|
/** @internal */
|
|
32
138
|
export const ErrorT$inboundSchema: z.ZodType<ErrorT, z.ZodTypeDef, unknown> = z
|
|
33
139
|
.object({
|
|
34
140
|
data: z.string(),
|
|
35
|
-
event:
|
|
141
|
+
event: ReadResponseEvent$inboundSchema,
|
|
36
142
|
});
|
|
37
143
|
|
|
38
144
|
/** @internal */
|
|
@@ -48,7 +154,7 @@ export const ErrorT$outboundSchema: z.ZodType<
|
|
|
48
154
|
ErrorT
|
|
49
155
|
> = z.object({
|
|
50
156
|
data: z.string(),
|
|
51
|
-
event:
|
|
157
|
+
event: ReadResponseEvent$outboundSchema,
|
|
52
158
|
});
|
|
53
159
|
|
|
54
160
|
/**
|
|
@@ -79,69 +185,82 @@ export function errorFromJSON(
|
|
|
79
185
|
}
|
|
80
186
|
|
|
81
187
|
/** @internal */
|
|
82
|
-
export const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
188
|
+
export const Event$inboundSchema: z.ZodNativeEnum<typeof Event> = z.nativeEnum(
|
|
189
|
+
Event,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
/** @internal */
|
|
193
|
+
export const Event$outboundSchema: z.ZodNativeEnum<typeof Event> =
|
|
194
|
+
Event$inboundSchema;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @internal
|
|
198
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
199
|
+
*/
|
|
200
|
+
export namespace Event$ {
|
|
201
|
+
/** @deprecated use `Event$inboundSchema` instead. */
|
|
202
|
+
export const inboundSchema = Event$inboundSchema;
|
|
203
|
+
/** @deprecated use `Event$outboundSchema` instead. */
|
|
204
|
+
export const outboundSchema = Event$outboundSchema;
|
|
205
|
+
}
|
|
100
206
|
|
|
101
207
|
/** @internal */
|
|
102
|
-
export
|
|
208
|
+
export const Message$inboundSchema: z.ZodType<Message, z.ZodTypeDef, unknown> =
|
|
209
|
+
z.object({
|
|
210
|
+
data: z.string().transform((v, ctx) => {
|
|
211
|
+
try {
|
|
212
|
+
return JSON.parse(v);
|
|
213
|
+
} catch (err) {
|
|
214
|
+
ctx.addIssue({
|
|
215
|
+
code: z.ZodIssueCode.custom,
|
|
216
|
+
message: `malformed json: ${err}`,
|
|
217
|
+
});
|
|
218
|
+
return z.NEVER;
|
|
219
|
+
}
|
|
220
|
+
}).pipe(Output$inboundSchema),
|
|
221
|
+
event: Event$inboundSchema,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/** @internal */
|
|
225
|
+
export type Message$Outbound = {
|
|
103
226
|
data: Output$Outbound;
|
|
104
227
|
event: string;
|
|
105
228
|
};
|
|
106
229
|
|
|
107
230
|
/** @internal */
|
|
108
|
-
export const
|
|
109
|
-
|
|
231
|
+
export const Message$outboundSchema: z.ZodType<
|
|
232
|
+
Message$Outbound,
|
|
110
233
|
z.ZodTypeDef,
|
|
111
|
-
|
|
234
|
+
Message
|
|
112
235
|
> = z.object({
|
|
113
236
|
data: Output$outboundSchema,
|
|
114
|
-
event:
|
|
237
|
+
event: Event$outboundSchema,
|
|
115
238
|
});
|
|
116
239
|
|
|
117
240
|
/**
|
|
118
241
|
* @internal
|
|
119
242
|
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
120
243
|
*/
|
|
121
|
-
export namespace
|
|
122
|
-
/** @deprecated use `
|
|
123
|
-
export const inboundSchema =
|
|
124
|
-
/** @deprecated use `
|
|
125
|
-
export const outboundSchema =
|
|
126
|
-
/** @deprecated use `
|
|
127
|
-
export type Outbound =
|
|
244
|
+
export namespace Message$ {
|
|
245
|
+
/** @deprecated use `Message$inboundSchema` instead. */
|
|
246
|
+
export const inboundSchema = Message$inboundSchema;
|
|
247
|
+
/** @deprecated use `Message$outboundSchema` instead. */
|
|
248
|
+
export const outboundSchema = Message$outboundSchema;
|
|
249
|
+
/** @deprecated use `Message$Outbound` instead. */
|
|
250
|
+
export type Outbound = Message$Outbound;
|
|
128
251
|
}
|
|
129
252
|
|
|
130
|
-
export function
|
|
131
|
-
|
|
132
|
-
): string {
|
|
133
|
-
return JSON.stringify(
|
|
134
|
-
ReadResponseOutput$outboundSchema.parse(readResponseOutput),
|
|
135
|
-
);
|
|
253
|
+
export function messageToJSON(message: Message): string {
|
|
254
|
+
return JSON.stringify(Message$outboundSchema.parse(message));
|
|
136
255
|
}
|
|
137
256
|
|
|
138
|
-
export function
|
|
257
|
+
export function messageFromJSON(
|
|
139
258
|
jsonString: string,
|
|
140
|
-
): SafeParseResult<
|
|
259
|
+
): SafeParseResult<Message, SDKValidationError> {
|
|
141
260
|
return safeParse(
|
|
142
261
|
jsonString,
|
|
143
|
-
(x) =>
|
|
144
|
-
`Failed to parse '
|
|
262
|
+
(x) => Message$inboundSchema.parse(JSON.parse(x)),
|
|
263
|
+
`Failed to parse 'Message' from JSON`,
|
|
145
264
|
);
|
|
146
265
|
}
|
|
147
266
|
|
|
@@ -151,13 +270,15 @@ export const ReadResponse$inboundSchema: z.ZodType<
|
|
|
151
270
|
z.ZodTypeDef,
|
|
152
271
|
unknown
|
|
153
272
|
> = z.union([
|
|
154
|
-
z.lazy(() =>
|
|
273
|
+
z.lazy(() => Ping$inboundSchema),
|
|
274
|
+
z.lazy(() => Message$inboundSchema),
|
|
155
275
|
z.lazy(() => ErrorT$inboundSchema),
|
|
156
276
|
]);
|
|
157
277
|
|
|
158
278
|
/** @internal */
|
|
159
279
|
export type ReadResponse$Outbound =
|
|
160
|
-
|
|
|
280
|
+
| Ping$Outbound
|
|
281
|
+
| Message$Outbound
|
|
161
282
|
| ErrorT$Outbound;
|
|
162
283
|
|
|
163
284
|
/** @internal */
|
|
@@ -166,7 +287,8 @@ export const ReadResponse$outboundSchema: z.ZodType<
|
|
|
166
287
|
z.ZodTypeDef,
|
|
167
288
|
ReadResponse
|
|
168
289
|
> = z.union([
|
|
169
|
-
z.lazy(() =>
|
|
290
|
+
z.lazy(() => Ping$outboundSchema),
|
|
291
|
+
z.lazy(() => Message$outboundSchema),
|
|
170
292
|
z.lazy(() => ErrorT$outboundSchema),
|
|
171
293
|
]);
|
|
172
294
|
|