vovk-hello-world 0.0.43 → 0.0.45

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/index.d.mts CHANGED
@@ -4,6 +4,7 @@ import * as zod0 from "zod";
4
4
  import * as zod_v4_core0 from "zod/v4/core";
5
5
  import * as vovk_mjs_client_types0 from "vovk/mjs/client/types";
6
6
  import * as openapi3_ts_oas310 from "openapi3-ts/oas31";
7
+ import openapi from "./openapi.json";
7
8
 
8
9
  //#region tmp_prebundle/schema.d.ts
9
10
  declare const schema: {
@@ -102,12 +103,12 @@ declare const schema: {
102
103
  additionalProperties: boolean;
103
104
  };
104
105
  };
105
- path: string;
106
- httpMethod: string;
107
- openapi: {
106
+ operationObject: {
108
107
  summary: string;
109
108
  description: string;
110
109
  };
110
+ path: string;
111
+ httpMethod: string;
111
112
  };
112
113
  };
113
114
  };
@@ -132,12 +133,12 @@ declare const schema: {
132
133
  additionalProperties: boolean;
133
134
  };
134
135
  };
135
- path: string;
136
- httpMethod: string;
137
- openapi: {
136
+ operationObject: {
138
137
  summary: string;
139
138
  description: string;
140
139
  };
140
+ path: string;
141
+ httpMethod: string;
141
142
  };
142
143
  };
143
144
  };
@@ -157,7 +158,7 @@ declare const schema: {
157
158
  getSpec: {
158
159
  path: string;
159
160
  httpMethod: string;
160
- openapi: {
161
+ operationObject: {
161
162
  summary: string;
162
163
  description: string;
163
164
  };
@@ -168,12 +169,29 @@ declare const schema: {
168
169
  };
169
170
  };
170
171
  meta: {
172
+ $schema: string;
171
173
  config: {
172
174
  libs: {};
175
+ generatorConfig: {
176
+ origin: string;
177
+ imports: {
178
+ validateOnClient: string;
179
+ };
180
+ openAPIObject: {
181
+ info: {
182
+ title: string;
183
+ description: string;
184
+ license: {
185
+ name: string;
186
+ url: string;
187
+ };
188
+ version: string;
189
+ };
190
+ };
191
+ segments: {};
192
+ };
173
193
  $schema: string;
174
194
  };
175
- $schema: string;
176
- apiRoot: string;
177
195
  };
178
196
  };
179
197
  //#endregion
@@ -218,7 +236,7 @@ declare const UserRPC: {
218
236
  };
219
237
  isRPC?: boolean;
220
238
  } & {
221
- schema: vovk0.VovkHandlerSchema;
239
+ schema: Omit<vovk0.VovkHandlerSchema, "httpMethod" | "path"> & Partial<vovk0.VovkHandlerSchema>;
222
240
  wrapper?: ((req: vovk0.VovkRequest<any, any, any>, params: {
223
241
  id: string;
224
242
  }) => Promise<{
@@ -305,7 +323,9 @@ declare const UserRPC: {
305
323
  }, {
306
324
  apiRoot?: string;
307
325
  disableClientValidation?: boolean;
308
- validateOnClient?: vovk0.VovkValidateOnClient<unknown> | undefined;
326
+ validateOnClient?: vovk0.VovkValidateOnClient<unknown> | Promise<{
327
+ validateOnClient: vovk0.VovkValidateOnClient<unknown>;
328
+ }> | undefined;
309
329
  interpretAs?: string;
310
330
  init?: RequestInit;
311
331
  }, unknown>;
@@ -326,7 +346,7 @@ declare const StreamRPC: {
326
346
  };
327
347
  isRPC?: boolean;
328
348
  } & {
329
- schema: vovk0.VovkHandlerSchema;
349
+ schema: Omit<vovk0.VovkHandlerSchema, "httpMethod" | "path"> & Partial<vovk0.VovkHandlerSchema>;
330
350
  wrapper?: ((req: vovk0.VovkRequest<any, any, any>, params: undefined) => AsyncGenerator<{
331
351
  message: string;
332
352
  }, void, unknown>) | undefined;
@@ -377,13 +397,15 @@ declare const StreamRPC: {
377
397
  }, {
378
398
  apiRoot?: string;
379
399
  disableClientValidation?: boolean;
380
- validateOnClient?: vovk0.VovkValidateOnClient<unknown> | undefined;
400
+ validateOnClient?: vovk0.VovkValidateOnClient<unknown> | Promise<{
401
+ validateOnClient: vovk0.VovkValidateOnClient<unknown>;
402
+ }> | undefined;
381
403
  interpretAs?: string;
382
404
  init?: RequestInit;
383
405
  }, unknown>;
384
406
  };
385
407
  declare const OpenApiRPC: {
386
- getSpec: () => Promise<openapi3_ts_oas310.OpenAPIObject>;
408
+ getSpec: () => openapi3_ts_oas310.OpenAPIObject;
387
409
  };
388
410
  //#endregion
389
- export { OpenApiRPC, StreamRPC, UserRPC, schema };
411
+ export { OpenApiRPC, StreamRPC, UserRPC, openapi, schema };
package/index.mjs CHANGED
@@ -1,16 +1,33 @@
1
- import { createRPC, fetcher } from "vovk";
2
- import { validateOnClient } from "vovk-ajv";
1
+ import { createRPC } from "vovk";
3
2
 
4
3
  //#region .vovk-schema/_meta.json
4
+ var $schema$2 = "https://vovk.dev/api/schema/v3/meta.json";
5
5
  var config = {
6
6
  "libs": {},
7
- "$schema": "https://vovk.dev/api/spec/v3/config.json"
7
+ "generatorConfig": {
8
+ "origin": "http://localhost:3000",
9
+ "imports": { "validateOnClient": "vovk-ajv" },
10
+ "openAPIObject": { "info": {
11
+ "title": "\"Hello World\" app API",
12
+ "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.",
13
+ "license": {
14
+ "name": "MIT",
15
+ "url": "https://opensource.org/licenses/MIT"
16
+ },
17
+ "version": "1.0.0"
18
+ } },
19
+ "segments": {}
20
+ },
21
+ "$schema": "https://vovk.dev/api/schema/v3/config.json"
22
+ };
23
+ var _meta_default = {
24
+ $schema: $schema$2,
25
+ config
8
26
  };
9
- var _meta_default = { config };
10
27
 
11
28
  //#endregion
12
29
  //#region .vovk-schema/root.json
13
- var $schema$1 = "https://vovk.dev/api/spec/v3/segment.json";
30
+ var $schema$1 = "https://vovk.dev/api/schema/v3/segment.json";
14
31
  var emitSchema$1 = true;
15
32
  var segmentName$1 = "";
16
33
  var segmentType$1 = "segment";
@@ -82,7 +99,7 @@ var controllers$1 = {
82
99
  "examples": ["123e4567-e89b-12d3-a456-426614174000"],
83
100
  "type": "string",
84
101
  "format": "uuid",
85
- "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)$"
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)$"
86
103
  } },
87
104
  "required": ["id"],
88
105
  "additionalProperties": false
@@ -99,12 +116,12 @@ var controllers$1 = {
99
116
  "additionalProperties": false
100
117
  }
101
118
  },
102
- "path": "{id}",
103
- "httpMethod": "POST",
104
- "openapi": {
119
+ "operationObject": {
105
120
  "summary": "Update user",
106
121
  "description": "Update user by ID"
107
- }
122
+ },
123
+ "path": "{id}",
124
+ "httpMethod": "POST"
108
125
  } }
109
126
  },
110
127
  "StreamRPC": {
@@ -123,12 +140,12 @@ var controllers$1 = {
123
140
  "required": ["message"],
124
141
  "additionalProperties": false
125
142
  } },
126
- "path": "tokens",
127
- "httpMethod": "GET",
128
- "openapi": {
143
+ "operationObject": {
129
144
  "summary": "Stream tokens",
130
145
  "description": "Stream tokens to the client"
131
- }
146
+ },
147
+ "path": "tokens",
148
+ "httpMethod": "GET"
132
149
  } }
133
150
  }
134
151
  };
@@ -142,7 +159,7 @@ var root_default = {
142
159
 
143
160
  //#endregion
144
161
  //#region .vovk-schema/static.json
145
- var $schema = "https://vovk.dev/api/spec/v3/segment.json";
162
+ var $schema = "https://vovk.dev/api/schema/v3/segment.json";
146
163
  var emitSchema = true;
147
164
  var segmentName = "static";
148
165
  var segmentType = "segment";
@@ -153,7 +170,7 @@ var controllers = { "OpenApiRPC": {
153
170
  "handlers": { "getSpec": {
154
171
  "path": "spec.json",
155
172
  "httpMethod": "GET",
156
- "openapi": {
173
+ "operationObject": {
157
174
  "summary": "OpenAPI spec",
158
175
  "description": "Get the OpenAPI spec for the \"Hello World\" app API"
159
176
  }
@@ -174,29 +191,282 @@ const segments = {
174
191
  "static": static_default
175
192
  };
176
193
  const schema = {
177
- $schema: "https://vovk.dev/api/spec/v3/schema.json",
194
+ $schema: "https://vovk.dev/api/schema/v3/schema.json",
178
195
  segments,
179
- meta: {
180
- $schema: "https://vovk.dev/api/spec/v3/meta.json",
181
- apiRoot: "https://vovk-hello-world.vercel.app/api",
182
- ..._meta_default
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"
183
208
  }
184
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
+ };
185
455
 
186
456
  //#endregion
187
457
  //#region tmp_prebundle/index.ts
188
- const UserRPC = createRPC(schema, "", "UserRPC", fetcher, {
189
- validateOnClient,
190
- apiRoot: "https://vovk-hello-world.vercel.app/api"
458
+ const UserRPC = createRPC(schema, "", "UserRPC", import("vovk"), {
459
+ validateOnClient: import("vovk-ajv"),
460
+ apiRoot: "http://localhost:3000/api"
191
461
  });
192
- const StreamRPC = createRPC(schema, "", "StreamRPC", fetcher, {
193
- validateOnClient,
194
- apiRoot: "https://vovk-hello-world.vercel.app/api"
462
+ const StreamRPC = createRPC(schema, "", "StreamRPC", import("vovk"), {
463
+ validateOnClient: import("vovk-ajv"),
464
+ apiRoot: "http://localhost:3000/api"
195
465
  });
196
- const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", fetcher, {
197
- validateOnClient,
198
- apiRoot: "https://vovk-hello-world.vercel.app/api"
466
+ const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", import("vovk"), {
467
+ validateOnClient: import("vovk-ajv"),
468
+ apiRoot: "http://localhost:3000/api"
199
469
  });
200
470
 
201
471
  //#endregion
202
- export { OpenApiRPC, StreamRPC, UserRPC, schema };
472
+ export { OpenApiRPC, StreamRPC, UserRPC, openapi_default as openapi, schema };