@fuzdev/fuz_app 0.8.0 → 0.10.0
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/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +1 -6
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +1 -1
- package/dist/http/jsonrpc.d.ts +197 -13
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +90 -10
- package/dist/http/jsonrpc_errors.d.ts +46 -34
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +57 -33
- package/dist/http/jsonrpc_helpers.d.ts +56 -0
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -0
- package/dist/http/jsonrpc_helpers.js +138 -0
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +1 -1
- package/dist/ui/AdminOverview.svelte +33 -33
- package/dist/ui/ColumnLayout.svelte +6 -6
- package/dist/ui/Datatable.svelte +14 -14
- package/dist/ui/OpenSignupToggle.svelte +1 -1
- package/dist/ui/SurfaceExplorer.svelte +1 -5
- package/dist/ui/SurfaceExplorer.svelte.d.ts +3 -3
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.d.ts +9 -9
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +5 -5
- package/dist/ui/sidebar_state.svelte.d.ts +5 -5
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,eAAe,EAA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BAAgB,CA4DxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,eAAe,EACrB,OAAO,gBAAgB,EACvB,SAAS,aAAa,EACtB,aAAa,MAAM,KACjB,MAkBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,eAAe,EACrB,UAAU,UAAU,GAAG,SAAS,EAChC,SAAS,aAAa,KACpB,MAyBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,KAAG,MACU,CAAC"}
|
|
@@ -257,18 +257,13 @@ export const generate_phase_handlers = (spec, executor, imports) => {
|
|
|
257
257
|
// Backend types file is in server/ subdirectory, so needs different relative paths
|
|
258
258
|
const path_prefix = executor === 'frontend' ? './' : '../';
|
|
259
259
|
imports.add_type(`${path_prefix}action_event.js`, 'ActionEvent');
|
|
260
|
-
// Add environment type import
|
|
261
|
-
const environment_type = executor === 'frontend' ? 'Frontend' : 'Backend';
|
|
262
|
-
const environment_module = executor === 'frontend' ? './frontend.svelte.js' : './backend.js';
|
|
263
|
-
imports.add_type(environment_module, environment_type);
|
|
264
260
|
// Generate handler definitions for each phase
|
|
265
261
|
const phase_handlers = phases
|
|
266
262
|
.map((phase) => {
|
|
267
263
|
// Pass imports to get_handler_return_type so it can add necessary imports
|
|
268
264
|
const return_type = get_handler_return_type(spec, phase, imports, path_prefix);
|
|
269
|
-
// Use the new type parameter approach
|
|
270
265
|
return `${phase}?: (
|
|
271
|
-
action_event: ActionEvent<'${method}',
|
|
266
|
+
action_event: ActionEvent<'${method}', '${phase}', 'handling'>
|
|
272
267
|
) => ${return_type}`;
|
|
273
268
|
})
|
|
274
269
|
.join(';\n\t\t');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK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,EAAE,MAAM,EACb,GAAG,EAAE,aAAa,KACd,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC;CACvB;AAED,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;CACZ;AAkDD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAoOtF,CAAC"}
|
|
@@ -17,7 +17,7 @@ import {} from '../http/route_spec.js';
|
|
|
17
17
|
import { get_request_context, has_role } from '../auth/request_context.js';
|
|
18
18
|
import { CREDENTIAL_TYPE_KEY } from '../hono_context.js';
|
|
19
19
|
import { is_null_schema } from '../http/schema_helpers.js';
|
|
20
|
-
import { JSONRPC_VERSION, JsonrpcRequest } from '../http/jsonrpc.js';
|
|
20
|
+
import { JSONRPC_VERSION, JsonrpcRequest, } from '../http/jsonrpc.js';
|
|
21
21
|
import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES, } from '../http/jsonrpc_errors.js';
|
|
22
22
|
/**
|
|
23
23
|
* Format a JSON-RPC error response.
|
package/dist/http/jsonrpc.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON-RPC 2.0 envelope schemas for
|
|
2
|
+
* JSON-RPC 2.0 envelope schemas for RPC dispatch and SAES transport.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* MCP extensions, notification types) remain in zzz.
|
|
4
|
+
* MCP-superset: includes optional `_meta` and `progressToken` fields
|
|
5
|
+
* on params and results. These are `optional()` so consumers that
|
|
6
|
+
* don't use MCP are unaffected.
|
|
8
7
|
*
|
|
9
8
|
* Following MCP, params and result are object-only (no positional arrays).
|
|
10
9
|
*
|
|
@@ -20,30 +19,101 @@ export type JsonrpcRequestId = z.infer<typeof JsonrpcRequestId>;
|
|
|
20
19
|
/** A JSON-RPC method name. */
|
|
21
20
|
export declare const JsonrpcMethod: z.ZodString;
|
|
22
21
|
export type JsonrpcMethod = z.infer<typeof JsonrpcMethod>;
|
|
23
|
-
/**
|
|
24
|
-
export declare const
|
|
22
|
+
/** A progress token, used to associate progress notifications with the original request. */
|
|
23
|
+
export declare const JsonrpcProgressToken: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
24
|
+
export type JsonrpcProgressToken = z.infer<typeof JsonrpcProgressToken>;
|
|
25
|
+
/** MCP metadata object — loose to allow additional properties and `.extend`. */
|
|
26
|
+
export declare const JsonrpcMcpMeta: z.ZodObject<{}, z.core.$loose>;
|
|
27
|
+
export type JsonrpcMcpMeta = z.infer<typeof JsonrpcMcpMeta>;
|
|
28
|
+
/** Request params metadata — extends MCP meta with optional progress token. */
|
|
29
|
+
export declare const JsonrpcRequestParamsMeta: z.ZodObject<{
|
|
30
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
31
|
+
}, z.core.$loose>;
|
|
32
|
+
export type JsonrpcRequestParamsMeta = z.infer<typeof JsonrpcRequestParamsMeta>;
|
|
33
|
+
/** Request params — loose object with optional MCP metadata. */
|
|
34
|
+
export declare const JsonrpcRequestParams: z.ZodObject<{
|
|
35
|
+
_meta: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
37
|
+
}, z.core.$loose>>;
|
|
38
|
+
}, z.core.$loose>;
|
|
25
39
|
export type JsonrpcRequestParams = z.infer<typeof JsonrpcRequestParams>;
|
|
26
|
-
/**
|
|
27
|
-
export declare const
|
|
40
|
+
/** Notification params — loose object with optional MCP metadata. */
|
|
41
|
+
export declare const JsonrpcNotificationParams: z.ZodObject<{
|
|
42
|
+
/**
|
|
43
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
44
|
+
* additional metadata to their notifications.
|
|
45
|
+
*/
|
|
46
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
47
|
+
}, z.core.$loose>;
|
|
48
|
+
export type JsonrpcNotificationParams = z.infer<typeof JsonrpcNotificationParams>;
|
|
49
|
+
/** Result — loose object with optional MCP metadata. */
|
|
50
|
+
export declare const JsonrpcResult: z.ZodObject<{
|
|
51
|
+
/**
|
|
52
|
+
* Reserved by the protocol to allow clients and servers
|
|
53
|
+
* to attach additional metadata to their responses.
|
|
54
|
+
*/
|
|
55
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
56
|
+
}, z.core.$loose>;
|
|
28
57
|
export type JsonrpcResult = z.infer<typeof JsonrpcResult>;
|
|
29
58
|
/** A request that expects a response. */
|
|
30
59
|
export declare const JsonrpcRequest: z.ZodObject<{
|
|
31
60
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
32
61
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
33
62
|
method: z.ZodString;
|
|
34
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
_meta: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
66
|
+
}, z.core.$loose>>;
|
|
67
|
+
}, z.core.$loose>>;
|
|
35
68
|
}, z.core.$loose>;
|
|
36
69
|
export type JsonrpcRequest = z.infer<typeof JsonrpcRequest>;
|
|
70
|
+
/** A notification which does not expect a response. */
|
|
71
|
+
export declare const JsonrpcNotification: z.ZodObject<{
|
|
72
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
73
|
+
method: z.ZodString;
|
|
74
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
/**
|
|
76
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
77
|
+
* additional metadata to their notifications.
|
|
78
|
+
*/
|
|
79
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
80
|
+
}, z.core.$loose>>;
|
|
81
|
+
}, z.core.$loose>;
|
|
82
|
+
export type JsonrpcNotification = z.infer<typeof JsonrpcNotification>;
|
|
37
83
|
/** A successful (non-error) response to a request. */
|
|
38
84
|
export declare const JsonrpcResponse: z.ZodObject<{
|
|
39
85
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
40
86
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
41
|
-
result: z.ZodObject<{
|
|
87
|
+
result: z.ZodObject<{
|
|
88
|
+
/**
|
|
89
|
+
* Reserved by the protocol to allow clients and servers
|
|
90
|
+
* to attach additional metadata to their responses.
|
|
91
|
+
*/
|
|
92
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
93
|
+
}, z.core.$loose>;
|
|
42
94
|
}, z.core.$loose>;
|
|
43
95
|
export type JsonrpcResponse = z.infer<typeof JsonrpcResponse>;
|
|
96
|
+
export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
97
|
+
export declare const JSONRPC_INVALID_REQUEST = -32600;
|
|
98
|
+
export declare const JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
99
|
+
export declare const JSONRPC_INVALID_PARAMS = -32602;
|
|
100
|
+
export declare const JSONRPC_INTERNAL_ERROR = -32603;
|
|
101
|
+
/** Start of the server-defined error code range (-32000). */
|
|
102
|
+
export declare const JSONRPC_SERVER_ERROR_START = -32000;
|
|
103
|
+
/** End of the server-defined error code range (-32099). */
|
|
104
|
+
export declare const JSONRPC_SERVER_ERROR_END = -32099;
|
|
105
|
+
/** A server-defined error code in the -32000 to -32099 range. */
|
|
106
|
+
export declare const JsonrpcServerErrorCode: z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">;
|
|
107
|
+
export type JsonrpcServerErrorCode = z.infer<typeof JsonrpcServerErrorCode>;
|
|
108
|
+
/**
|
|
109
|
+
* A valid JSON-RPC error code — one of the 5 standard codes or
|
|
110
|
+
* a server-defined code in the -32000 to -32099 range.
|
|
111
|
+
*/
|
|
112
|
+
export declare const JsonrpcErrorCode: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
113
|
+
export type JsonrpcErrorCode = z.infer<typeof JsonrpcErrorCode>;
|
|
44
114
|
/** Error object within a JSON-RPC error response. */
|
|
45
115
|
export declare const JsonrpcErrorObject: z.ZodObject<{
|
|
46
|
-
code: z.ZodNumber
|
|
116
|
+
code: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
47
117
|
message: z.ZodString;
|
|
48
118
|
data: z.ZodOptional<z.ZodUnknown>;
|
|
49
119
|
}, z.core.$loose>;
|
|
@@ -53,10 +123,124 @@ export declare const JsonrpcErrorResponse: z.ZodObject<{
|
|
|
53
123
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
54
124
|
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
55
125
|
error: z.ZodObject<{
|
|
56
|
-
code: z.ZodNumber
|
|
126
|
+
code: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
57
127
|
message: z.ZodString;
|
|
58
128
|
data: z.ZodOptional<z.ZodUnknown>;
|
|
59
129
|
}, z.core.$loose>;
|
|
60
130
|
}, z.core.$loose>;
|
|
61
131
|
export type JsonrpcErrorResponse = z.infer<typeof JsonrpcErrorResponse>;
|
|
132
|
+
/** A successful response or an error response. */
|
|
133
|
+
export declare const JsonrpcResponseOrError: z.ZodUnion<readonly [z.ZodObject<{
|
|
134
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
135
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
136
|
+
result: z.ZodObject<{
|
|
137
|
+
/**
|
|
138
|
+
* Reserved by the protocol to allow clients and servers
|
|
139
|
+
* to attach additional metadata to their responses.
|
|
140
|
+
*/
|
|
141
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
142
|
+
}, z.core.$loose>;
|
|
143
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
144
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
145
|
+
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
146
|
+
error: z.ZodObject<{
|
|
147
|
+
code: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
148
|
+
message: z.ZodString;
|
|
149
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
150
|
+
}, z.core.$loose>;
|
|
151
|
+
}, z.core.$loose>]>;
|
|
152
|
+
export type JsonrpcResponseOrError = z.infer<typeof JsonrpcResponseOrError>;
|
|
153
|
+
/** Any valid JSON-RPC message (request, notification, response, or error response). */
|
|
154
|
+
export declare const JsonrpcMessage: z.ZodUnion<readonly [z.ZodObject<{
|
|
155
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
156
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
157
|
+
method: z.ZodString;
|
|
158
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
_meta: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
161
|
+
}, z.core.$loose>>;
|
|
162
|
+
}, z.core.$loose>>;
|
|
163
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
164
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
165
|
+
method: z.ZodString;
|
|
166
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
167
|
+
/**
|
|
168
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
169
|
+
* additional metadata to their notifications.
|
|
170
|
+
*/
|
|
171
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
172
|
+
}, z.core.$loose>>;
|
|
173
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
174
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
175
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
176
|
+
result: z.ZodObject<{
|
|
177
|
+
/**
|
|
178
|
+
* Reserved by the protocol to allow clients and servers
|
|
179
|
+
* to attach additional metadata to their responses.
|
|
180
|
+
*/
|
|
181
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
182
|
+
}, z.core.$loose>;
|
|
183
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
184
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
185
|
+
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
186
|
+
error: z.ZodObject<{
|
|
187
|
+
code: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
188
|
+
message: z.ZodString;
|
|
189
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
190
|
+
}, z.core.$loose>;
|
|
191
|
+
}, z.core.$loose>]>;
|
|
192
|
+
export type JsonrpcMessage = z.infer<typeof JsonrpcMessage>;
|
|
193
|
+
/** Messages a client can send to a server (request or notification). */
|
|
194
|
+
export declare const JsonrpcMessageFromClientToServer: z.ZodUnion<readonly [z.ZodObject<{
|
|
195
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
196
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
197
|
+
method: z.ZodString;
|
|
198
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
199
|
+
_meta: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
201
|
+
}, z.core.$loose>>;
|
|
202
|
+
}, z.core.$loose>>;
|
|
203
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
204
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
205
|
+
method: z.ZodString;
|
|
206
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
207
|
+
/**
|
|
208
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
209
|
+
* additional metadata to their notifications.
|
|
210
|
+
*/
|
|
211
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
212
|
+
}, z.core.$loose>>;
|
|
213
|
+
}, z.core.$loose>]>;
|
|
214
|
+
export type JsonrpcMessageFromClientToServer = z.infer<typeof JsonrpcMessageFromClientToServer>;
|
|
215
|
+
/** Messages a server can send to a client (notification, response, or error response). */
|
|
216
|
+
export declare const JsonrpcMessageFromServerToClient: z.ZodUnion<readonly [z.ZodObject<{
|
|
217
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
218
|
+
method: z.ZodString;
|
|
219
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
220
|
+
/**
|
|
221
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
222
|
+
* additional metadata to their notifications.
|
|
223
|
+
*/
|
|
224
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
225
|
+
}, z.core.$loose>>;
|
|
226
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
227
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
228
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
229
|
+
result: z.ZodObject<{
|
|
230
|
+
/**
|
|
231
|
+
* Reserved by the protocol to allow clients and servers
|
|
232
|
+
* to attach additional metadata to their responses.
|
|
233
|
+
*/
|
|
234
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
235
|
+
}, z.core.$loose>;
|
|
236
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
237
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
238
|
+
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
239
|
+
error: z.ZodObject<{
|
|
240
|
+
code: z.ZodUnion<readonly [z.ZodLiteral<-32700>, z.ZodLiteral<-32600>, z.ZodLiteral<-32601>, z.ZodLiteral<-32602>, z.ZodLiteral<-32603>, z.core.$ZodBranded<z.ZodNumber, "JsonrpcServerErrorCode", "out">]>;
|
|
241
|
+
message: z.ZodString;
|
|
242
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
243
|
+
}, z.core.$loose>;
|
|
244
|
+
}, z.core.$loose>]>;
|
|
245
|
+
export type JsonrpcMessageFromServerToClient = z.infer<typeof JsonrpcMessageFromServerToClient>;
|
|
62
246
|
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"../src/lib/","s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BAI7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,mDAAmD;AACnD,eAAO,MAAM,oBAAoB;;;;;;;;iBAI/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,kDAAkD;AAClD,eAAO,MAAM,sBAAsB;;;;QAtFlC;;;WAGG;;;;;;;;;;;mBAmFkF,CAAC;AACvF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,uFAAuF;AACvF,eAAO,MAAM,cAAc;;;;;;;;;;;;;QApG1B;;;WAGG;;;;;;;QAOH;;;WAGG;;;;;;;;;;;mBA4FF,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,wEAAwE;AACxE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;QA7G5C;;;WAGG;;;mBA0G0F,CAAC;AAC/F,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAEhG,0FAA0F;AAC1F,eAAO,MAAM,gCAAgC;;;;QAjH5C;;;WAGG;;;;;;;QAOH;;;WAGG;;;;;;;;;;;mBAwGF,CAAC;AACH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
package/dist/http/jsonrpc.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON-RPC 2.0 envelope schemas for
|
|
2
|
+
* JSON-RPC 2.0 envelope schemas for RPC dispatch and SAES transport.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* MCP extensions, notification types) remain in zzz.
|
|
4
|
+
* MCP-superset: includes optional `_meta` and `progressToken` fields
|
|
5
|
+
* on params and results. These are `optional()` so consumers that
|
|
6
|
+
* don't use MCP are unaffected.
|
|
8
7
|
*
|
|
9
8
|
* Following MCP, params and result are object-only (no positional arrays).
|
|
10
9
|
*
|
|
@@ -18,10 +17,39 @@ export const JSONRPC_VERSION = '2.0';
|
|
|
18
17
|
export const JsonrpcRequestId = z.union([z.string(), z.number()]);
|
|
19
18
|
/** A JSON-RPC method name. */
|
|
20
19
|
export const JsonrpcMethod = z.string();
|
|
21
|
-
/**
|
|
22
|
-
export const
|
|
23
|
-
/**
|
|
24
|
-
export const
|
|
20
|
+
/** A progress token, used to associate progress notifications with the original request. */
|
|
21
|
+
export const JsonrpcProgressToken = z.union([z.string(), z.number()]);
|
|
22
|
+
/** MCP metadata object — loose to allow additional properties and `.extend`. */
|
|
23
|
+
export const JsonrpcMcpMeta = z.looseObject({});
|
|
24
|
+
/** Request params metadata — extends MCP meta with optional progress token. */
|
|
25
|
+
export const JsonrpcRequestParamsMeta = JsonrpcMcpMeta.extend({
|
|
26
|
+
/**
|
|
27
|
+
* If specified, the caller is requesting out-of-band progress notifications
|
|
28
|
+
* for this request. The value is an opaque token attached to subsequent
|
|
29
|
+
* notifications. The receiver is not obligated to provide these notifications.
|
|
30
|
+
*/
|
|
31
|
+
progressToken: JsonrpcProgressToken.optional(),
|
|
32
|
+
});
|
|
33
|
+
/** Request params — loose object with optional MCP metadata. */
|
|
34
|
+
export const JsonrpcRequestParams = z.looseObject({
|
|
35
|
+
_meta: JsonrpcRequestParamsMeta.optional(),
|
|
36
|
+
});
|
|
37
|
+
/** Notification params — loose object with optional MCP metadata. */
|
|
38
|
+
export const JsonrpcNotificationParams = z.looseObject({
|
|
39
|
+
/**
|
|
40
|
+
* Reserved by MCP to allow clients and servers to attach
|
|
41
|
+
* additional metadata to their notifications.
|
|
42
|
+
*/
|
|
43
|
+
_meta: JsonrpcMcpMeta.optional(),
|
|
44
|
+
});
|
|
45
|
+
/** Result — loose object with optional MCP metadata. */
|
|
46
|
+
export const JsonrpcResult = z.looseObject({
|
|
47
|
+
/**
|
|
48
|
+
* Reserved by the protocol to allow clients and servers
|
|
49
|
+
* to attach additional metadata to their responses.
|
|
50
|
+
*/
|
|
51
|
+
_meta: JsonrpcMcpMeta.optional(),
|
|
52
|
+
});
|
|
25
53
|
/** A request that expects a response. */
|
|
26
54
|
export const JsonrpcRequest = z.looseObject({
|
|
27
55
|
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
@@ -29,15 +57,50 @@ export const JsonrpcRequest = z.looseObject({
|
|
|
29
57
|
method: JsonrpcMethod,
|
|
30
58
|
params: JsonrpcRequestParams.optional(),
|
|
31
59
|
});
|
|
60
|
+
/** A notification which does not expect a response. */
|
|
61
|
+
export const JsonrpcNotification = z.looseObject({
|
|
62
|
+
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
63
|
+
method: JsonrpcMethod,
|
|
64
|
+
params: JsonrpcNotificationParams.optional(),
|
|
65
|
+
});
|
|
32
66
|
/** A successful (non-error) response to a request. */
|
|
33
67
|
export const JsonrpcResponse = z.looseObject({
|
|
34
68
|
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
35
69
|
id: JsonrpcRequestId,
|
|
36
70
|
result: JsonrpcResult,
|
|
37
71
|
});
|
|
72
|
+
// --- Error code schemas ---
|
|
73
|
+
// Standard JSON-RPC error codes — https://www.jsonrpc.org/specification
|
|
74
|
+
export const JSONRPC_PARSE_ERROR = -32700;
|
|
75
|
+
export const JSONRPC_INVALID_REQUEST = -32600;
|
|
76
|
+
export const JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
77
|
+
export const JSONRPC_INVALID_PARAMS = -32602;
|
|
78
|
+
export const JSONRPC_INTERNAL_ERROR = -32603;
|
|
79
|
+
/** Start of the server-defined error code range (-32000). */
|
|
80
|
+
export const JSONRPC_SERVER_ERROR_START = -32000;
|
|
81
|
+
/** End of the server-defined error code range (-32099). */
|
|
82
|
+
export const JSONRPC_SERVER_ERROR_END = -32099;
|
|
83
|
+
/** A server-defined error code in the -32000 to -32099 range. */
|
|
84
|
+
export const JsonrpcServerErrorCode = z
|
|
85
|
+
.number()
|
|
86
|
+
.gte(JSONRPC_SERVER_ERROR_END)
|
|
87
|
+
.lte(JSONRPC_SERVER_ERROR_START)
|
|
88
|
+
.brand('JsonrpcServerErrorCode');
|
|
89
|
+
/**
|
|
90
|
+
* A valid JSON-RPC error code — one of the 5 standard codes or
|
|
91
|
+
* a server-defined code in the -32000 to -32099 range.
|
|
92
|
+
*/
|
|
93
|
+
export const JsonrpcErrorCode = z.union([
|
|
94
|
+
z.literal(JSONRPC_PARSE_ERROR),
|
|
95
|
+
z.literal(JSONRPC_INVALID_REQUEST),
|
|
96
|
+
z.literal(JSONRPC_METHOD_NOT_FOUND),
|
|
97
|
+
z.literal(JSONRPC_INVALID_PARAMS),
|
|
98
|
+
z.literal(JSONRPC_INTERNAL_ERROR),
|
|
99
|
+
JsonrpcServerErrorCode,
|
|
100
|
+
]);
|
|
38
101
|
/** Error object within a JSON-RPC error response. */
|
|
39
102
|
export const JsonrpcErrorObject = z.looseObject({
|
|
40
|
-
code:
|
|
103
|
+
code: JsonrpcErrorCode,
|
|
41
104
|
message: z.string(),
|
|
42
105
|
data: z.unknown().optional(),
|
|
43
106
|
});
|
|
@@ -47,3 +110,20 @@ export const JsonrpcErrorResponse = z.looseObject({
|
|
|
47
110
|
id: JsonrpcRequestId.nullable(),
|
|
48
111
|
error: JsonrpcErrorObject,
|
|
49
112
|
});
|
|
113
|
+
/** A successful response or an error response. */
|
|
114
|
+
export const JsonrpcResponseOrError = z.union([JsonrpcResponse, JsonrpcErrorResponse]);
|
|
115
|
+
/** Any valid JSON-RPC message (request, notification, response, or error response). */
|
|
116
|
+
export const JsonrpcMessage = z.union([
|
|
117
|
+
JsonrpcRequest,
|
|
118
|
+
JsonrpcNotification,
|
|
119
|
+
JsonrpcResponse,
|
|
120
|
+
JsonrpcErrorResponse,
|
|
121
|
+
]);
|
|
122
|
+
/** Messages a client can send to a server (request or notification). */
|
|
123
|
+
export const JsonrpcMessageFromClientToServer = z.union([JsonrpcRequest, JsonrpcNotification]);
|
|
124
|
+
/** Messages a server can send to a client (notification, response, or error response). */
|
|
125
|
+
export const JsonrpcMessageFromServerToClient = z.union([
|
|
126
|
+
JsonrpcNotification,
|
|
127
|
+
JsonrpcResponse,
|
|
128
|
+
JsonrpcErrorResponse,
|
|
129
|
+
]);
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides error types, named constructors, and HTTP status mapping
|
|
5
5
|
* for the throw/catch error pattern used by `apply_route_specs`.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Core error codes (5 standard + 8 general application). Domain-specific
|
|
7
|
+
* codes stay in consumers — add by casting `as JsonrpcErrorCode`.
|
|
8
|
+
*
|
|
9
|
+
* `JsonrpcErrorCode` and `JsonrpcErrorObject` types are Zod-inferred
|
|
10
|
+
* from `jsonrpc.ts` — this module re-uses those as the single source
|
|
11
|
+
* of truth.
|
|
10
12
|
*
|
|
11
13
|
* Complementary to `error_schemas.ts`: that module is declarative
|
|
12
14
|
* (Zod schemas for surface introspection), this one is runtime
|
|
@@ -14,16 +16,7 @@
|
|
|
14
16
|
*
|
|
15
17
|
* @module
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
export type JsonrpcErrorCode = number & {
|
|
19
|
-
readonly __brand: 'JsonrpcErrorCode';
|
|
20
|
-
};
|
|
21
|
-
/** JSON-RPC error response object — code, message, and optional data. */
|
|
22
|
-
export interface JsonrpcErrorJson {
|
|
23
|
-
code: JsonrpcErrorCode;
|
|
24
|
-
message: string;
|
|
25
|
-
data?: unknown;
|
|
26
|
-
}
|
|
19
|
+
import { type JsonrpcErrorCode, type JsonrpcErrorObject } from './jsonrpc.js';
|
|
27
20
|
/** Names of standard and general application JSON-RPC error codes. */
|
|
28
21
|
export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_found' | 'invalid_params' | 'internal_error' | 'unauthenticated' | 'forbidden' | 'not_found' | 'conflict' | 'validation_error' | 'rate_limited' | 'service_unavailable' | 'timeout';
|
|
29
22
|
/**
|
|
@@ -34,15 +27,10 @@ export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_f
|
|
|
34
27
|
* -32099 range reserved by the JSON-RPC spec.
|
|
35
28
|
*/
|
|
36
29
|
export declare const JSONRPC_ERROR_CODES: {
|
|
37
|
-
/** -32700 */
|
|
38
30
|
readonly parse_error: JsonrpcErrorCode;
|
|
39
|
-
/** -32600 */
|
|
40
31
|
readonly invalid_request: JsonrpcErrorCode;
|
|
41
|
-
/** -32601 */
|
|
42
32
|
readonly method_not_found: JsonrpcErrorCode;
|
|
43
|
-
/** -32602 */
|
|
44
33
|
readonly invalid_params: JsonrpcErrorCode;
|
|
45
|
-
/** -32603 */
|
|
46
34
|
readonly internal_error: JsonrpcErrorCode;
|
|
47
35
|
/**
|
|
48
36
|
* Same as HTTP 401 "unauthorized", but correctly named.
|
|
@@ -67,26 +55,26 @@ export declare const JSONRPC_ERROR_CODES: {
|
|
|
67
55
|
readonly timeout: JsonrpcErrorCode;
|
|
68
56
|
};
|
|
69
57
|
/**
|
|
70
|
-
* Named constructors for `
|
|
58
|
+
* Named constructors for `JsonrpcErrorObject` values.
|
|
71
59
|
*
|
|
72
|
-
* Each function creates a JSON-RPC error
|
|
60
|
+
* Each function creates a JSON-RPC error object with the correct
|
|
73
61
|
* code and a sensible default message. Used by the catch layer in
|
|
74
62
|
* `apply_route_specs` to build response bodies.
|
|
75
63
|
*/
|
|
76
64
|
export declare const jsonrpc_error_messages: {
|
|
77
|
-
readonly parse_error: (data?: unknown) =>
|
|
78
|
-
readonly invalid_request: (data?: unknown) =>
|
|
79
|
-
readonly method_not_found: (method?: string, data?: unknown) =>
|
|
80
|
-
readonly invalid_params: (message?: string, data?: unknown) =>
|
|
81
|
-
readonly internal_error: (message?: string, data?: unknown) =>
|
|
82
|
-
readonly unauthenticated: (message?: string, data?: unknown) =>
|
|
83
|
-
readonly forbidden: (message?: string, data?: unknown) =>
|
|
84
|
-
readonly not_found: (resource?: string, data?: unknown) =>
|
|
85
|
-
readonly conflict: (message?: string, data?: unknown) =>
|
|
86
|
-
readonly validation_error: (message?: string, data?: unknown) =>
|
|
87
|
-
readonly rate_limited: (message?: string, data?: unknown) =>
|
|
88
|
-
readonly service_unavailable: (message?: string, data?: unknown) =>
|
|
89
|
-
readonly timeout: (message?: string, data?: unknown) =>
|
|
65
|
+
readonly parse_error: (data?: unknown) => JsonrpcErrorObject;
|
|
66
|
+
readonly invalid_request: (data?: unknown) => JsonrpcErrorObject;
|
|
67
|
+
readonly method_not_found: (method?: string, data?: unknown) => JsonrpcErrorObject;
|
|
68
|
+
readonly invalid_params: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
69
|
+
readonly internal_error: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
70
|
+
readonly unauthenticated: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
71
|
+
readonly forbidden: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
72
|
+
readonly not_found: (resource?: string, data?: unknown) => JsonrpcErrorObject;
|
|
73
|
+
readonly conflict: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
74
|
+
readonly validation_error: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
75
|
+
readonly rate_limited: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
76
|
+
readonly service_unavailable: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
77
|
+
readonly timeout: (message?: string, data?: unknown) => JsonrpcErrorObject;
|
|
90
78
|
};
|
|
91
79
|
/**
|
|
92
80
|
* Error class carrying a JSON-RPC error code — thrown by handlers,
|
|
@@ -119,6 +107,21 @@ export declare const jsonrpc_errors: {
|
|
|
119
107
|
readonly service_unavailable: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
|
|
120
108
|
readonly timeout: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
|
|
121
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Maps JSON-RPC error codes to HTTP status codes.
|
|
112
|
+
*
|
|
113
|
+
* Extensible — consumers with domain-specific error codes can spread
|
|
114
|
+
* this into their own mapping object.
|
|
115
|
+
*/
|
|
116
|
+
export declare const JSONRPC_ERROR_CODE_TO_HTTP_STATUS: Record<number, number>;
|
|
117
|
+
/**
|
|
118
|
+
* Maps HTTP status codes to JSON-RPC error codes (reverse mapping).
|
|
119
|
+
*
|
|
120
|
+
* When multiple error codes map to the same HTTP status (e.g. parse_error
|
|
121
|
+
* and invalid_request both map to 400), the last one wins. Use for
|
|
122
|
+
* best-effort HTTP → JSON-RPC translation.
|
|
123
|
+
*/
|
|
124
|
+
export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Record<number, JsonrpcErrorCode>;
|
|
122
125
|
/**
|
|
123
126
|
* Map a JSON-RPC error code to an HTTP status code.
|
|
124
127
|
*
|
|
@@ -129,4 +132,13 @@ export declare const jsonrpc_errors: {
|
|
|
129
132
|
* @returns the corresponding HTTP status code
|
|
130
133
|
*/
|
|
131
134
|
export declare const jsonrpc_error_code_to_http_status: (code: JsonrpcErrorCode) => number;
|
|
135
|
+
/**
|
|
136
|
+
* Map an HTTP status code to a JSON-RPC error code.
|
|
137
|
+
*
|
|
138
|
+
* Returns `internal_error` (-32603) for unrecognized status codes.
|
|
139
|
+
*
|
|
140
|
+
* @param status - the HTTP status code
|
|
141
|
+
* @returns the corresponding JSON-RPC error code
|
|
142
|
+
*/
|
|
143
|
+
export declare const http_status_to_jsonrpc_error_code: (status: number) => JsonrpcErrorCode;
|
|
132
144
|
//# sourceMappingURL=jsonrpc_errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAMN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAEtB,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GACzB,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,UAAU,GACV,kBAAkB,GAClB,cAAc,GACd,qBAAqB,GACrB,SAAS,CAAC;AAEb;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;0BAEK,gBAAgB;8BACR,gBAAgB;+BACd,gBAAgB;6BACpB,gBAAgB;6BAChB,gBAAgB;IAG1D;;;;OAIG;8BACwB,gBAAgB;IAC3C;;;OAGG;wBACkB,gBAAgB;wBAChB,gBAAgB;uBACjB,gBAAgB;IACpC;;;OAGG;+BACyB,gBAAgB;2BACpB,gBAAgB;kCACT,gBAAgB;sBAC5B,gBAAgB;CAC2B,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;kCACb,OAAO,KAAG,kBAAkB;sCAMxB,OAAO,KAAG,kBAAkB;yCAMzB,MAAM,SAAS,OAAO,KAAG,kBAAkB;wCAM5C,MAAM,SAAS,OAAO,KAAG,kBAAkB;wCAO5D,MAAM,SACR,OAAO,KACZ,kBAAkB;yCAMM,MAAM,SAA6B,OAAO,KAAG,kBAAkB;mCAMrE,MAAM,SAAuB,OAAO,KAAG,kBAAkB;oCAMvD,MAAM,SAAS,OAAO,KAAG,kBAAkB;kCAM9C,MAAM,SAAsB,OAAO,KAAG,kBAAkB;0CAMhD,MAAM,SAA8B,OAAO,KAAG,kBAAkB;sCAMpE,MAAM,SAA0B,OAAO,KAAG,kBAA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