vovk-hello-world 0.0.46 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -11
- package/index.cjs +384 -407
- package/index.d.cts +239 -44
- package/index.d.mts +239 -44
- package/index.mjs +382 -406
- package/package.json +2 -59
- package/openapi.cjs +0 -264
- package/openapi.d.cts +0 -2
- package/schema.cjs +0 -199
- package/schema.d.cts +0 -190
package/index.mjs
CHANGED
|
@@ -1,44 +1,337 @@
|
|
|
1
1
|
import { createRPC } from "vovk";
|
|
2
2
|
|
|
3
|
-
//#region .vovk-schema/
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
//#region .vovk-schema/root.json
|
|
4
|
+
var root_default = {
|
|
5
|
+
$schema: "https://vovk.dev/api/schema/v3/segment.json",
|
|
6
|
+
emitSchema: true,
|
|
7
|
+
segmentName: "",
|
|
8
|
+
segmentType: "segment",
|
|
9
|
+
controllers: {
|
|
10
|
+
"UserRPC": {
|
|
11
|
+
"rpcModuleName": "UserRPC",
|
|
12
|
+
"originalControllerName": "UserController",
|
|
13
|
+
"prefix": "users",
|
|
14
|
+
"handlers": { "updateUser": {
|
|
15
|
+
"validation": {
|
|
16
|
+
"body": {
|
|
17
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
18
|
+
"description": "User data object",
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"email": {
|
|
22
|
+
"description": "User email",
|
|
23
|
+
"examples": ["john@example.com", "jane@example.com"],
|
|
24
|
+
"type": "string",
|
|
25
|
+
"format": "email",
|
|
26
|
+
"pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
|
|
27
|
+
},
|
|
28
|
+
"profile": {
|
|
29
|
+
"description": "User profile object",
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"name": {
|
|
33
|
+
"description": "User full name",
|
|
34
|
+
"examples": ["John Doe", "Jane Smith"],
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"age": {
|
|
38
|
+
"description": "User age",
|
|
39
|
+
"examples": [25, 30],
|
|
40
|
+
"type": "integer",
|
|
41
|
+
"minimum": 16,
|
|
42
|
+
"maximum": 120
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"required": ["name", "age"],
|
|
46
|
+
"additionalProperties": false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": ["email", "profile"],
|
|
50
|
+
"additionalProperties": false
|
|
51
|
+
},
|
|
52
|
+
"query": {
|
|
53
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
54
|
+
"description": "Query parameters",
|
|
55
|
+
"type": "object",
|
|
56
|
+
"properties": { "notify": {
|
|
57
|
+
"description": "Notification type",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"enum": [
|
|
60
|
+
"email",
|
|
61
|
+
"push",
|
|
62
|
+
"none"
|
|
63
|
+
]
|
|
64
|
+
} },
|
|
65
|
+
"required": ["notify"],
|
|
66
|
+
"additionalProperties": false
|
|
67
|
+
},
|
|
68
|
+
"params": {
|
|
69
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
70
|
+
"description": "Path parameters",
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": { "id": {
|
|
73
|
+
"description": "User ID",
|
|
74
|
+
"examples": ["123e4567-e89b-12d3-a456-426614174000"],
|
|
75
|
+
"type": "string",
|
|
76
|
+
"format": "uuid",
|
|
77
|
+
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
78
|
+
} },
|
|
79
|
+
"required": ["id"],
|
|
80
|
+
"additionalProperties": false
|
|
81
|
+
},
|
|
82
|
+
"output": {
|
|
83
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
84
|
+
"description": "Response object",
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": { "success": {
|
|
87
|
+
"description": "Success status",
|
|
88
|
+
"type": "boolean"
|
|
89
|
+
} },
|
|
90
|
+
"required": ["success"],
|
|
91
|
+
"additionalProperties": false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"operationObject": {
|
|
95
|
+
"summary": "Update user",
|
|
96
|
+
"description": "Update user by ID"
|
|
97
|
+
},
|
|
98
|
+
"path": "{id}",
|
|
99
|
+
"httpMethod": "POST"
|
|
100
|
+
} }
|
|
101
|
+
},
|
|
102
|
+
"StreamRPC": {
|
|
103
|
+
"rpcModuleName": "StreamRPC",
|
|
104
|
+
"originalControllerName": "StreamController",
|
|
105
|
+
"prefix": "streams",
|
|
106
|
+
"handlers": { "streamTokens": {
|
|
107
|
+
"validation": { "iteration": {
|
|
108
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
109
|
+
"description": "Streamed token object",
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": { "message": {
|
|
112
|
+
"description": "Message from the token",
|
|
113
|
+
"type": "string"
|
|
114
|
+
} },
|
|
115
|
+
"required": ["message"],
|
|
116
|
+
"additionalProperties": false
|
|
117
|
+
} },
|
|
118
|
+
"operationObject": {
|
|
119
|
+
"summary": "Stream tokens",
|
|
120
|
+
"description": "Stream tokens to the client"
|
|
121
|
+
},
|
|
122
|
+
"path": "tokens",
|
|
123
|
+
"httpMethod": "GET"
|
|
124
|
+
} }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
22
127
|
};
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region .vovk-schema/static.json
|
|
131
|
+
var static_default = {
|
|
132
|
+
$schema: "https://vovk.dev/api/schema/v3/segment.json",
|
|
133
|
+
emitSchema: true,
|
|
134
|
+
segmentName: "static",
|
|
135
|
+
segmentType: "segment",
|
|
136
|
+
controllers: { "OpenApiRPC": {
|
|
137
|
+
"rpcModuleName": "OpenApiRPC",
|
|
138
|
+
"originalControllerName": "OpenApiController",
|
|
139
|
+
"prefix": "",
|
|
140
|
+
"handlers": { "getSpec": {
|
|
141
|
+
"path": "openapi.json",
|
|
142
|
+
"httpMethod": "GET",
|
|
143
|
+
"operationObject": {
|
|
144
|
+
"summary": "OpenAPI spec",
|
|
145
|
+
"description": "Get the OpenAPI spec for the \"Hello World\" app API"
|
|
146
|
+
}
|
|
147
|
+
} }
|
|
148
|
+
} }
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region .vovk-schema/_meta.json
|
|
23
153
|
var _meta_default = {
|
|
24
|
-
$schema:
|
|
25
|
-
config
|
|
154
|
+
$schema: "https://vovk.dev/api/schema/v3/meta.json",
|
|
155
|
+
config: {
|
|
156
|
+
"libs": {},
|
|
157
|
+
"outputConfig": {
|
|
158
|
+
"imports": { "validateOnClient": "vovk-ajv" },
|
|
159
|
+
"openAPIObject": { "info": {
|
|
160
|
+
"title": "\"Hello World\" app API",
|
|
161
|
+
"description": "API for \"Hello World\" app hosted at https://hello-world.vovk.dev/. Source code is available on Github https://github.com/finom/vovk-hello-world.",
|
|
162
|
+
"license": {
|
|
163
|
+
"name": "MIT",
|
|
164
|
+
"url": "https://opensource.org/licenses/MIT"
|
|
165
|
+
},
|
|
166
|
+
"version": "1.0.0"
|
|
167
|
+
} },
|
|
168
|
+
"origin": "",
|
|
169
|
+
"segments": {}
|
|
170
|
+
},
|
|
171
|
+
"$schema": "https://vovk.dev/api/schema/v3/config.json"
|
|
172
|
+
}
|
|
26
173
|
};
|
|
27
174
|
|
|
28
175
|
//#endregion
|
|
29
|
-
//#region
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
176
|
+
//#region tmp_prebundle/schema.ts
|
|
177
|
+
const segments = {
|
|
178
|
+
"": root_default,
|
|
179
|
+
"static": static_default
|
|
180
|
+
};
|
|
181
|
+
const schema = {
|
|
182
|
+
$schema: "https://vovk.dev/api/schema/v3/schema.json",
|
|
183
|
+
segments,
|
|
184
|
+
meta: _meta_default
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region tmp_prebundle/openapi.json
|
|
189
|
+
var openapi_default = {
|
|
190
|
+
openapi: "3.1.0",
|
|
191
|
+
info: {},
|
|
192
|
+
components: { "schemas": {
|
|
193
|
+
"HttpStatus": {
|
|
194
|
+
"type": "integer",
|
|
195
|
+
"description": "HTTP status code",
|
|
196
|
+
"enum": [
|
|
197
|
+
100,
|
|
198
|
+
101,
|
|
199
|
+
102,
|
|
200
|
+
103,
|
|
201
|
+
200,
|
|
202
|
+
201,
|
|
203
|
+
202,
|
|
204
|
+
203,
|
|
205
|
+
204,
|
|
206
|
+
205,
|
|
207
|
+
206,
|
|
208
|
+
300,
|
|
209
|
+
301,
|
|
210
|
+
302,
|
|
211
|
+
303,
|
|
212
|
+
304,
|
|
213
|
+
307,
|
|
214
|
+
308,
|
|
215
|
+
400,
|
|
216
|
+
401,
|
|
217
|
+
402,
|
|
218
|
+
403,
|
|
219
|
+
404,
|
|
220
|
+
405,
|
|
221
|
+
406,
|
|
222
|
+
407,
|
|
223
|
+
408,
|
|
224
|
+
409,
|
|
225
|
+
410,
|
|
226
|
+
411,
|
|
227
|
+
412,
|
|
228
|
+
413,
|
|
229
|
+
414,
|
|
230
|
+
415,
|
|
231
|
+
416,
|
|
232
|
+
417,
|
|
233
|
+
418,
|
|
234
|
+
421,
|
|
235
|
+
422,
|
|
236
|
+
424,
|
|
237
|
+
428,
|
|
238
|
+
429,
|
|
239
|
+
500,
|
|
240
|
+
501,
|
|
241
|
+
502,
|
|
242
|
+
503,
|
|
243
|
+
504,
|
|
244
|
+
505
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
"VovkErrorResponse": {
|
|
248
|
+
"type": "object",
|
|
249
|
+
"description": "Vovk error response",
|
|
250
|
+
"properties": {
|
|
251
|
+
"cause": { "description": "Error cause of any shape" },
|
|
252
|
+
"statusCode": { "$ref": "#/components/schemas/HttpStatus" },
|
|
253
|
+
"message": {
|
|
254
|
+
"type": "string",
|
|
255
|
+
"description": "Error message"
|
|
256
|
+
},
|
|
257
|
+
"isError": {
|
|
258
|
+
"type": "boolean",
|
|
259
|
+
"const": true,
|
|
260
|
+
"description": "Indicates that this object represents an error"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"required": [
|
|
264
|
+
"statusCode",
|
|
265
|
+
"message",
|
|
266
|
+
"isError"
|
|
267
|
+
],
|
|
268
|
+
"additionalProperties": false
|
|
269
|
+
}
|
|
270
|
+
} },
|
|
271
|
+
paths: {
|
|
272
|
+
"/api/users/{id}": { "post": {
|
|
273
|
+
"summary": "Update user",
|
|
274
|
+
"description": "Update user by ID",
|
|
275
|
+
"x-codeSamples": [
|
|
276
|
+
{
|
|
277
|
+
"label": "TypeScript RPC",
|
|
278
|
+
"lang": "typescript",
|
|
279
|
+
"source": "import { UserRPC } from 'vovk-client';\n\nconst response = await UserRPC.updateUser({\n body: {\n // -----\n // User data object\n // -----\n // User email\n email: \"john@example.com\",\n // User profile object\n profile: {\n // User full name\n name: \"John Doe\",\n // User age\n age: 25\n }\n },\n query: {\n // -----\n // Query parameters\n // -----\n // Notification type\n notify: \"email\"\n },\n params: {\n // -----\n // Path parameters\n // -----\n // User ID\n id: \"123e4567-e89b-12d3-a456-426614174000\"\n },\n});\n\nconsole.log(response); \n/* \n{\n // -----\n // Response object\n // -----\n // Success status\n success: true\n}\n*/"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"label": "Python RPC",
|
|
283
|
+
"lang": "python",
|
|
284
|
+
"source": "from vovk_client import UserRPC\n\nresponse = UserRPC.update_user(\n body={\n # -----\n # User data object\n # -----\n # User email\n \"email\": \"john@example.com\",\n # User profile object\n \"profile\": {\n # User full name\n \"name\": \"John Doe\",\n # User age\n \"age\": 25\n }\n },\n query={\n # -----\n # Query parameters\n # -----\n # Notification type\n \"notify\": \"email\"\n },\n params={\n # -----\n # Path parameters\n # -----\n # User ID\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n)\n\nprint(response)\n{\n # -----\n # Response object\n # -----\n # Success status\n \"success\": true\n}"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"label": "Rust RPC",
|
|
288
|
+
"lang": "rust",
|
|
289
|
+
"source": "use vovk_client::user_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\npub fn main() {\n let response = user_rpc::update_user(\n from_value(json!({\n // -----\n // User data object\n // -----\n // User email\n \"email\": \"john@example.com\",\n // User profile object\n \"profile\": {\n // User full name\n \"name\": \"John Doe\",\n // User age\n \"age\": 25\n }\n })).unwrap(), /* body */ \n from_value(json!({\n // -----\n // Query parameters\n // -----\n // Notification type\n \"notify\": \"email\"\n })).unwrap(), /* query */ \n from_value(json!({\n // -----\n // Path parameters\n // -----\n // User ID\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n })).unwrap(), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n\nmatch response {\n Ok(output) => println!(\"{:?}\", output),\n /* \n output {\n // -----\n // Response object\n // -----\n // Success status\n success: true\n } \n */\n Err(e) => println!(\"error: {:?}\", e),\n }\n}"
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
"parameters": [{
|
|
293
|
+
"name": "notify",
|
|
294
|
+
"in": "query",
|
|
295
|
+
"required": true,
|
|
296
|
+
"schema": {
|
|
297
|
+
"description": "Notification type",
|
|
298
|
+
"type": "string",
|
|
299
|
+
"enum": [
|
|
300
|
+
"email",
|
|
301
|
+
"push",
|
|
302
|
+
"none"
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
"name": "id",
|
|
307
|
+
"in": "path",
|
|
308
|
+
"required": true,
|
|
309
|
+
"schema": {
|
|
310
|
+
"description": "User ID",
|
|
311
|
+
"examples": ["123e4567-e89b-12d3-a456-426614174000"],
|
|
312
|
+
"type": "string",
|
|
313
|
+
"format": "uuid",
|
|
314
|
+
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
315
|
+
}
|
|
316
|
+
}],
|
|
317
|
+
"responses": { "200": {
|
|
318
|
+
"description": "Response object",
|
|
319
|
+
"content": { "application/json": { "schema": {
|
|
320
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
321
|
+
"description": "Response object",
|
|
322
|
+
"type": "object",
|
|
323
|
+
"properties": { "success": {
|
|
324
|
+
"description": "Success status",
|
|
325
|
+
"type": "boolean"
|
|
326
|
+
} },
|
|
327
|
+
"required": ["success"],
|
|
328
|
+
"additionalProperties": false
|
|
329
|
+
} } }
|
|
330
|
+
} },
|
|
331
|
+
"requestBody": {
|
|
332
|
+
"description": "User data object",
|
|
333
|
+
"required": true,
|
|
334
|
+
"content": { "application/json": { "schema": {
|
|
42
335
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
43
336
|
"description": "User data object",
|
|
44
337
|
"type": "object",
|
|
@@ -73,399 +366,82 @@ var controllers$1 = {
|
|
|
73
366
|
},
|
|
74
367
|
"required": ["email", "profile"],
|
|
75
368
|
"additionalProperties": false
|
|
369
|
+
} } }
|
|
370
|
+
}
|
|
371
|
+
} },
|
|
372
|
+
"/api/streams/tokens": { "get": {
|
|
373
|
+
"summary": "Stream tokens",
|
|
374
|
+
"description": "Stream tokens to the client",
|
|
375
|
+
"x-codeSamples": [
|
|
376
|
+
{
|
|
377
|
+
"label": "TypeScript RPC",
|
|
378
|
+
"lang": "typescript",
|
|
379
|
+
"source": "import { StreamRPC } from 'vovk-client';\n\nusing response = await StreamRPC.streamTokens();\n\nfor await (const item of response) {\n console.log(item); \n /*\n {\n // -----\n // Streamed token object\n // -----\n // Message from the token\n message: \"string\"\n }\n */\n}"
|
|
76
380
|
},
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"properties": { "notify": {
|
|
82
|
-
"description": "Notification type",
|
|
83
|
-
"type": "string",
|
|
84
|
-
"enum": [
|
|
85
|
-
"email",
|
|
86
|
-
"push",
|
|
87
|
-
"none"
|
|
88
|
-
]
|
|
89
|
-
} },
|
|
90
|
-
"required": ["notify"],
|
|
91
|
-
"additionalProperties": false
|
|
381
|
+
{
|
|
382
|
+
"label": "Python RPC",
|
|
383
|
+
"lang": "python",
|
|
384
|
+
"source": "from vovk_client import StreamRPC\n\nresponse = StreamRPC.stream_tokens()\n\nfor i, item in enumerate(response):\n print(f\"iteration #{i}:\\n {item}\")\n # iteration #0:\n {\n # -----\n # Streamed token object\n # -----\n # Message from the token\n \"message\": \"string\"\n }"
|
|
92
385
|
},
|
|
93
|
-
|
|
386
|
+
{
|
|
387
|
+
"label": "Rust RPC",
|
|
388
|
+
"lang": "rust",
|
|
389
|
+
"source": "use vovk_client::stream_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\npub fn main() {\n let response = stream_rpc::stream_tokens(\n (), /* body */ \n (), /* query */ \n (), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n\nmatch response {\n Ok(stream) => {\n for (i, item) in stream.enumerate() {\n println!(\"#{}: {:?}\", i, item);\n /*\n #0: iteration {\n // -----\n // Streamed token object\n // -----\n // Message from the token\n message: \"string\"\n }\n */\n }\n },\n Err(e) => println!(\"Error initiating stream: {:?}\", e),\n }\n}"
|
|
390
|
+
}
|
|
391
|
+
],
|
|
392
|
+
"responses": { "200": {
|
|
393
|
+
"description": "Streamed token object",
|
|
394
|
+
"content": { "application/jsonl": { "schema": {
|
|
94
395
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
95
|
-
"description": "
|
|
396
|
+
"description": "Streamed token object",
|
|
96
397
|
"type": "object",
|
|
97
|
-
"properties": { "
|
|
98
|
-
"description": "
|
|
99
|
-
"
|
|
100
|
-
"type": "string",
|
|
101
|
-
"format": "uuid",
|
|
102
|
-
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
398
|
+
"properties": { "message": {
|
|
399
|
+
"description": "Message from the token",
|
|
400
|
+
"type": "string"
|
|
103
401
|
} },
|
|
104
|
-
"required": ["
|
|
105
|
-
"additionalProperties": false
|
|
402
|
+
"required": ["message"],
|
|
403
|
+
"additionalProperties": false,
|
|
404
|
+
"examples": ["{\"message\":\"string\"}\n{\"message\":\"string\"}\n{\"message\":\"string\"}"]
|
|
405
|
+
} } }
|
|
406
|
+
} }
|
|
407
|
+
} },
|
|
408
|
+
"/api/static/openapi.json": { "get": {
|
|
409
|
+
"summary": "OpenAPI spec",
|
|
410
|
+
"description": "Get the OpenAPI spec for the \"Hello World\" app API",
|
|
411
|
+
"x-codeSamples": [
|
|
412
|
+
{
|
|
413
|
+
"label": "TypeScript RPC",
|
|
414
|
+
"lang": "typescript",
|
|
415
|
+
"source": "import { OpenApiRPC } from 'vovk-client';\n\nconst response = await OpenApiRPC.getSpec();"
|
|
106
416
|
},
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
"additionalProperties": false
|
|
417
|
+
{
|
|
418
|
+
"label": "Python RPC",
|
|
419
|
+
"lang": "python",
|
|
420
|
+
"source": "from vovk_client import OpenApiRPC\n\nresponse = OpenApiRPC.get_spec()"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"label": "Rust RPC",
|
|
424
|
+
"lang": "rust",
|
|
425
|
+
"source": "use vovk_client::open_api_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\npub fn main() {\n let response = open_api_rpc::get_spec(\n (), /* body */ \n (), /* query */ \n (), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n}"
|
|
117
426
|
}
|
|
118
|
-
|
|
119
|
-
"operationObject": {
|
|
120
|
-
"summary": "Update user",
|
|
121
|
-
"description": "Update user by ID"
|
|
122
|
-
},
|
|
123
|
-
"path": "{id}",
|
|
124
|
-
"httpMethod": "POST"
|
|
125
|
-
} }
|
|
126
|
-
},
|
|
127
|
-
"StreamRPC": {
|
|
128
|
-
"rpcModuleName": "StreamRPC",
|
|
129
|
-
"originalControllerName": "StreamController",
|
|
130
|
-
"prefix": "streams",
|
|
131
|
-
"handlers": { "streamTokens": {
|
|
132
|
-
"validation": { "iteration": {
|
|
133
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
134
|
-
"description": "Streamed token object",
|
|
135
|
-
"type": "object",
|
|
136
|
-
"properties": { "message": {
|
|
137
|
-
"description": "Message from the token",
|
|
138
|
-
"type": "string"
|
|
139
|
-
} },
|
|
140
|
-
"required": ["message"],
|
|
141
|
-
"additionalProperties": false
|
|
142
|
-
} },
|
|
143
|
-
"operationObject": {
|
|
144
|
-
"summary": "Stream tokens",
|
|
145
|
-
"description": "Stream tokens to the client"
|
|
146
|
-
},
|
|
147
|
-
"path": "tokens",
|
|
148
|
-
"httpMethod": "GET"
|
|
427
|
+
]
|
|
149
428
|
} }
|
|
150
429
|
}
|
|
151
430
|
};
|
|
152
|
-
var root_default = {
|
|
153
|
-
$schema: $schema$1,
|
|
154
|
-
emitSchema: emitSchema$1,
|
|
155
|
-
segmentName: segmentName$1,
|
|
156
|
-
segmentType: segmentType$1,
|
|
157
|
-
controllers: controllers$1
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region .vovk-schema/static.json
|
|
162
|
-
var $schema = "https://vovk.dev/api/schema/v3/segment.json";
|
|
163
|
-
var emitSchema = true;
|
|
164
|
-
var segmentName = "static";
|
|
165
|
-
var segmentType = "segment";
|
|
166
|
-
var controllers = { "OpenApiRPC": {
|
|
167
|
-
"rpcModuleName": "OpenApiRPC",
|
|
168
|
-
"originalControllerName": "OpenApiController",
|
|
169
|
-
"prefix": "openapi",
|
|
170
|
-
"handlers": { "getSpec": {
|
|
171
|
-
"path": "spec.json",
|
|
172
|
-
"httpMethod": "GET",
|
|
173
|
-
"operationObject": {
|
|
174
|
-
"summary": "OpenAPI spec",
|
|
175
|
-
"description": "Get the OpenAPI spec for the \"Hello World\" app API"
|
|
176
|
-
}
|
|
177
|
-
} }
|
|
178
|
-
} };
|
|
179
|
-
var static_default = {
|
|
180
|
-
$schema,
|
|
181
|
-
emitSchema,
|
|
182
|
-
segmentName,
|
|
183
|
-
segmentType,
|
|
184
|
-
controllers
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region tmp_prebundle/schema.ts
|
|
189
|
-
const segments = {
|
|
190
|
-
"": root_default,
|
|
191
|
-
"static": static_default
|
|
192
|
-
};
|
|
193
|
-
const schema = {
|
|
194
|
-
$schema: "https://vovk.dev/api/schema/v3/schema.json",
|
|
195
|
-
segments,
|
|
196
|
-
meta: { ..._meta_default }
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region tmp_prebundle/openapi.json
|
|
201
|
-
var info = {
|
|
202
|
-
"title": "\"Hello World\" app API",
|
|
203
|
-
"version": "1.0.0",
|
|
204
|
-
"description": "API for \"Hello World\" app hosted at https://vovk-hello-world.vercel.app/. Source code is available on Github https://github.com/finom/vovk-hello-world.",
|
|
205
|
-
"license": {
|
|
206
|
-
"name": "MIT",
|
|
207
|
-
"url": "https://opensource.org/licenses/MIT"
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
var openapi = "3.1.0";
|
|
211
|
-
var components = { "schemas": {
|
|
212
|
-
"HttpStatus": {
|
|
213
|
-
"type": "integer",
|
|
214
|
-
"description": "HTTP status code",
|
|
215
|
-
"enum": [
|
|
216
|
-
100,
|
|
217
|
-
101,
|
|
218
|
-
102,
|
|
219
|
-
103,
|
|
220
|
-
200,
|
|
221
|
-
201,
|
|
222
|
-
202,
|
|
223
|
-
203,
|
|
224
|
-
204,
|
|
225
|
-
205,
|
|
226
|
-
206,
|
|
227
|
-
300,
|
|
228
|
-
301,
|
|
229
|
-
302,
|
|
230
|
-
303,
|
|
231
|
-
304,
|
|
232
|
-
307,
|
|
233
|
-
308,
|
|
234
|
-
400,
|
|
235
|
-
401,
|
|
236
|
-
402,
|
|
237
|
-
403,
|
|
238
|
-
404,
|
|
239
|
-
405,
|
|
240
|
-
406,
|
|
241
|
-
407,
|
|
242
|
-
408,
|
|
243
|
-
409,
|
|
244
|
-
410,
|
|
245
|
-
411,
|
|
246
|
-
412,
|
|
247
|
-
413,
|
|
248
|
-
414,
|
|
249
|
-
415,
|
|
250
|
-
416,
|
|
251
|
-
417,
|
|
252
|
-
418,
|
|
253
|
-
421,
|
|
254
|
-
422,
|
|
255
|
-
424,
|
|
256
|
-
428,
|
|
257
|
-
429,
|
|
258
|
-
500,
|
|
259
|
-
501,
|
|
260
|
-
502,
|
|
261
|
-
503,
|
|
262
|
-
504,
|
|
263
|
-
505
|
|
264
|
-
]
|
|
265
|
-
},
|
|
266
|
-
"VovkErrorResponse": {
|
|
267
|
-
"type": "object",
|
|
268
|
-
"description": "Vovk error response",
|
|
269
|
-
"properties": {
|
|
270
|
-
"cause": { "description": "Error cause of any shape" },
|
|
271
|
-
"statusCode": { "$ref": "#/components/schemas/HttpStatus" },
|
|
272
|
-
"message": {
|
|
273
|
-
"type": "string",
|
|
274
|
-
"description": "Error message"
|
|
275
|
-
},
|
|
276
|
-
"isError": {
|
|
277
|
-
"type": "boolean",
|
|
278
|
-
"const": true,
|
|
279
|
-
"description": "Indicates that this object represents an error"
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"required": [
|
|
283
|
-
"statusCode",
|
|
284
|
-
"message",
|
|
285
|
-
"isError"
|
|
286
|
-
],
|
|
287
|
-
"additionalProperties": false
|
|
288
|
-
}
|
|
289
|
-
} };
|
|
290
|
-
var paths = {
|
|
291
|
-
"/api/users/{id}": { "post": {
|
|
292
|
-
"summary": "Update user",
|
|
293
|
-
"description": "Update user by ID",
|
|
294
|
-
"x-codeSamples": [
|
|
295
|
-
{
|
|
296
|
-
"label": "TypeScript RPC",
|
|
297
|
-
"lang": "typescript",
|
|
298
|
-
"source": "import { UserRPC } from 'vovk-client';\n\nconst response = await UserRPC.updateUser({\n body: {\n // User email\n email: \"john@example.com\",\n // User profile object\n profile: {\n // User full name\n name: \"John Doe\",\n // User age\n age: 25\n }\n },\n query: {\n // Notification type\n notify: \"email\"\n },\n params: {\n // User ID\n id: \"123e4567-e89b-12d3-a456-426614174000\"\n },\n});\n\nconsole.log(response); \n/* \n{\n // -----\n // Response object\n // -----\n // Success status\n success: true\n}\n*/"
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
"label": "Python RPC",
|
|
302
|
-
"lang": "python",
|
|
303
|
-
"source": "from vovk_client import UserRPC\n\nresponse = UserRPC.update_user(\n body={\n # User email\n \"email\": \"john@example.com\",\n # User profile object\n \"profile\": {\n # User full name\n \"name\": \"John Doe\",\n # User age\n \"age\": 25\n }\n },\n query={\n # Notification type\n \"notify\": \"email\"\n },\n params={\n # User ID\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n)\n\nprint(response)\n{\n # -----\n # Response object\n # -----\n # Success status\n \"success\": true\n}"
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
"label": "Rust RPC",
|
|
307
|
-
"lang": "rust",
|
|
308
|
-
"source": "use vovk_client::user_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\n\npub fn main() {\n let response = user_rpc::update_user(\n from_value(json!({\n // User email\n \"email\": \"john@example.com\",\n // User profile object\n \"profile\": {\n // User full name\n \"name\": \"John Doe\",\n // User age\n \"age\": 25\n }\n })).unwrap(), /* body */ \n from_value(json!({\n // Notification type\n \"notify\": \"email\"\n })).unwrap(), /* query */ \n from_value(json!({\n // User ID\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n })).unwrap(), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n\nmatch response {\n Ok(output) => println!(\"{:?}\", output),\n /* \n output {\n // Success status\n success: true\n } \n */\n Err(e) => println!(\"error: {:?}\", e),\n }\n}"
|
|
309
|
-
}
|
|
310
|
-
],
|
|
311
|
-
"parameters": [{
|
|
312
|
-
"name": "notify",
|
|
313
|
-
"in": "query",
|
|
314
|
-
"required": true,
|
|
315
|
-
"schema": {
|
|
316
|
-
"description": "Notification type",
|
|
317
|
-
"type": "string",
|
|
318
|
-
"enum": [
|
|
319
|
-
"email",
|
|
320
|
-
"push",
|
|
321
|
-
"none"
|
|
322
|
-
]
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
"name": "id",
|
|
326
|
-
"in": "path",
|
|
327
|
-
"required": true,
|
|
328
|
-
"schema": {
|
|
329
|
-
"description": "User ID",
|
|
330
|
-
"examples": ["123e4567-e89b-12d3-a456-426614174000"],
|
|
331
|
-
"type": "string",
|
|
332
|
-
"format": "uuid",
|
|
333
|
-
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
334
|
-
}
|
|
335
|
-
}],
|
|
336
|
-
"responses": { "200": {
|
|
337
|
-
"description": "Response object",
|
|
338
|
-
"content": { "application/json": { "schema": {
|
|
339
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
340
|
-
"description": "Response object",
|
|
341
|
-
"type": "object",
|
|
342
|
-
"properties": { "success": {
|
|
343
|
-
"description": "Success status",
|
|
344
|
-
"type": "boolean"
|
|
345
|
-
} },
|
|
346
|
-
"required": ["success"],
|
|
347
|
-
"additionalProperties": false
|
|
348
|
-
} } }
|
|
349
|
-
} },
|
|
350
|
-
"requestBody": {
|
|
351
|
-
"description": "User data object",
|
|
352
|
-
"required": true,
|
|
353
|
-
"content": { "application/json": { "schema": {
|
|
354
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
355
|
-
"description": "User data object",
|
|
356
|
-
"type": "object",
|
|
357
|
-
"properties": {
|
|
358
|
-
"email": {
|
|
359
|
-
"description": "User email",
|
|
360
|
-
"examples": ["john@example.com", "jane@example.com"],
|
|
361
|
-
"type": "string",
|
|
362
|
-
"format": "email",
|
|
363
|
-
"pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
|
|
364
|
-
},
|
|
365
|
-
"profile": {
|
|
366
|
-
"description": "User profile object",
|
|
367
|
-
"type": "object",
|
|
368
|
-
"properties": {
|
|
369
|
-
"name": {
|
|
370
|
-
"description": "User full name",
|
|
371
|
-
"examples": ["John Doe", "Jane Smith"],
|
|
372
|
-
"type": "string"
|
|
373
|
-
},
|
|
374
|
-
"age": {
|
|
375
|
-
"description": "User age",
|
|
376
|
-
"examples": [25, 30],
|
|
377
|
-
"type": "integer",
|
|
378
|
-
"minimum": 16,
|
|
379
|
-
"maximum": 120
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
"required": ["name", "age"],
|
|
383
|
-
"additionalProperties": false
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
"required": ["email", "profile"],
|
|
387
|
-
"additionalProperties": false
|
|
388
|
-
} } }
|
|
389
|
-
}
|
|
390
|
-
} },
|
|
391
|
-
"/api/streams/tokens": { "get": {
|
|
392
|
-
"summary": "Stream tokens",
|
|
393
|
-
"description": "Stream tokens to the client",
|
|
394
|
-
"x-codeSamples": [
|
|
395
|
-
{
|
|
396
|
-
"label": "TypeScript RPC",
|
|
397
|
-
"lang": "typescript",
|
|
398
|
-
"source": "import { StreamRPC } from 'vovk-client';\n\nusing response = await StreamRPC.streamTokens();\n\nfor await (const item of response) {\n console.log(item); \n /*\n {\n // Message from the token\n message: \"string\"\n }\n */\n}"
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
"label": "Python RPC",
|
|
402
|
-
"lang": "python",
|
|
403
|
-
"source": "from vovk_client import StreamRPC\n\nresponse = StreamRPC.stream_tokens()\n\nfor i, item in enumerate(response):\n print(f\"iteration #{i}:\\n {item}\")\n # iteration #0:\n {\n # Message from the token\n \"message\": \"string\"\n }"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
"label": "Rust RPC",
|
|
407
|
-
"lang": "rust",
|
|
408
|
-
"source": "use vovk_client::stream_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\n\npub fn main() {\n let response = stream_rpc::stream_tokens(\n (), /* body */ \n (), /* query */ \n (), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n\nmatch response {\n Ok(stream) => {\n for (i, item) in stream.enumerate() {\n println!(\"#{}: {:?}\", i, item);\n /*\n #0: iteration {\n // Message from the token\n message: \"string\"\n }\n */\n }\n },\n Err(e) => println!(\"Error initiating stream: {:?}\", e),\n }\n}"
|
|
409
|
-
}
|
|
410
|
-
],
|
|
411
|
-
"responses": { "200": {
|
|
412
|
-
"description": "Streamed token object",
|
|
413
|
-
"content": { "application/jsonl": { "schema": {
|
|
414
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
415
|
-
"description": "Streamed token object",
|
|
416
|
-
"type": "object",
|
|
417
|
-
"properties": { "message": {
|
|
418
|
-
"description": "Message from the token",
|
|
419
|
-
"type": "string"
|
|
420
|
-
} },
|
|
421
|
-
"required": ["message"],
|
|
422
|
-
"additionalProperties": false,
|
|
423
|
-
"examples": ["{\"message\":\"string\"}\n{\"message\":\"string\"}\n{\"message\":\"string\"}"]
|
|
424
|
-
} } }
|
|
425
|
-
} }
|
|
426
|
-
} },
|
|
427
|
-
"/api/static/openapi/spec.json": { "get": {
|
|
428
|
-
"summary": "OpenAPI spec",
|
|
429
|
-
"description": "Get the OpenAPI spec for the \"Hello World\" app API",
|
|
430
|
-
"x-codeSamples": [
|
|
431
|
-
{
|
|
432
|
-
"label": "TypeScript RPC",
|
|
433
|
-
"lang": "typescript",
|
|
434
|
-
"source": "import { OpenApiRPC } from 'vovk-client';\n\nconst response = await OpenApiRPC.getSpec();"
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
"label": "Python RPC",
|
|
438
|
-
"lang": "python",
|
|
439
|
-
"source": "from vovk_client import OpenApiRPC\n\nresponse = OpenApiRPC.get_spec()"
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
"label": "Rust RPC",
|
|
443
|
-
"lang": "rust",
|
|
444
|
-
"source": "use vovk_client::open_api_rpc;\nuse serde_json::{ \n from_value, \n json \n};\n\n\npub fn main() {\n let response = open_api_rpc::get_spec(\n (), /* body */ \n (), /* query */ \n (), /* params */ \n None, /* headers (HashMap) */ \n None, /* api_root */\n false, /* disable_client_validation */\n );\n}"
|
|
445
|
-
}
|
|
446
|
-
]
|
|
447
|
-
} }
|
|
448
|
-
};
|
|
449
|
-
var openapi_default = {
|
|
450
|
-
info,
|
|
451
|
-
openapi,
|
|
452
|
-
components,
|
|
453
|
-
paths
|
|
454
|
-
};
|
|
455
431
|
|
|
456
432
|
//#endregion
|
|
457
433
|
//#region tmp_prebundle/index.ts
|
|
458
434
|
const UserRPC = createRPC(schema, "", "UserRPC", import("vovk"), {
|
|
459
435
|
validateOnClient: import("vovk-ajv"),
|
|
460
|
-
apiRoot: "
|
|
436
|
+
apiRoot: "https://hello-world.vovk.dev/api"
|
|
461
437
|
});
|
|
462
438
|
const StreamRPC = createRPC(schema, "", "StreamRPC", import("vovk"), {
|
|
463
439
|
validateOnClient: import("vovk-ajv"),
|
|
464
|
-
apiRoot: "
|
|
440
|
+
apiRoot: "https://hello-world.vovk.dev/api"
|
|
465
441
|
});
|
|
466
442
|
const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", import("vovk"), {
|
|
467
443
|
validateOnClient: import("vovk-ajv"),
|
|
468
|
-
apiRoot: "
|
|
444
|
+
apiRoot: "https://hello-world.vovk.dev/api"
|
|
469
445
|
});
|
|
470
446
|
|
|
471
447
|
//#endregion
|