vovk-hello-world 0.0.43 → 0.0.44

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,18 @@ declare const schema: {
168
169
  };
169
170
  };
170
171
  meta: {
172
+ $schema: string;
171
173
  config: {
172
174
  libs: {};
175
+ generatorConfig: {
176
+ imports: {
177
+ validateOnClient: string;
178
+ };
179
+ origin: string;
180
+ segments: {};
181
+ };
173
182
  $schema: string;
174
183
  };
175
- $schema: string;
176
- apiRoot: string;
177
184
  };
178
185
  };
179
186
  //#endregion
@@ -218,7 +225,7 @@ declare const UserRPC: {
218
225
  };
219
226
  isRPC?: boolean;
220
227
  } & {
221
- schema: vovk0.VovkHandlerSchema;
228
+ schema: Omit<vovk0.VovkHandlerSchema, "httpMethod" | "path"> & Partial<vovk0.VovkHandlerSchema>;
222
229
  wrapper?: ((req: vovk0.VovkRequest<any, any, any>, params: {
223
230
  id: string;
224
231
  }) => Promise<{
@@ -305,7 +312,9 @@ declare const UserRPC: {
305
312
  }, {
306
313
  apiRoot?: string;
307
314
  disableClientValidation?: boolean;
308
- validateOnClient?: vovk0.VovkValidateOnClient<unknown> | undefined;
315
+ validateOnClient?: vovk0.VovkValidateOnClient<unknown> | Promise<{
316
+ validateOnClient: vovk0.VovkValidateOnClient<unknown>;
317
+ }> | undefined;
309
318
  interpretAs?: string;
310
319
  init?: RequestInit;
311
320
  }, unknown>;
@@ -326,7 +335,7 @@ declare const StreamRPC: {
326
335
  };
327
336
  isRPC?: boolean;
328
337
  } & {
329
- schema: vovk0.VovkHandlerSchema;
338
+ schema: Omit<vovk0.VovkHandlerSchema, "httpMethod" | "path"> & Partial<vovk0.VovkHandlerSchema>;
330
339
  wrapper?: ((req: vovk0.VovkRequest<any, any, any>, params: undefined) => AsyncGenerator<{
331
340
  message: string;
332
341
  }, void, unknown>) | undefined;
@@ -377,13 +386,15 @@ declare const StreamRPC: {
377
386
  }, {
378
387
  apiRoot?: string;
379
388
  disableClientValidation?: boolean;
380
- validateOnClient?: vovk0.VovkValidateOnClient<unknown> | undefined;
389
+ validateOnClient?: vovk0.VovkValidateOnClient<unknown> | Promise<{
390
+ validateOnClient: vovk0.VovkValidateOnClient<unknown>;
391
+ }> | undefined;
381
392
  interpretAs?: string;
382
393
  init?: RequestInit;
383
394
  }, unknown>;
384
395
  };
385
396
  declare const OpenApiRPC: {
386
- getSpec: () => Promise<openapi3_ts_oas310.OpenAPIObject>;
397
+ getSpec: () => openapi3_ts_oas310.OpenAPIObject;
387
398
  };
388
399
  //#endregion
389
- export { OpenApiRPC, StreamRPC, UserRPC, schema };
400
+ export { OpenApiRPC, StreamRPC, UserRPC, openapi, schema };
package/index.mjs CHANGED
@@ -1,16 +1,24 @@
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
+ "imports": { "validateOnClient": "vovk-ajv" },
9
+ "origin": "",
10
+ "segments": {}
11
+ },
12
+ "$schema": "https://vovk.dev/api/schema/v3/config.json"
13
+ };
14
+ var _meta_default = {
15
+ $schema: $schema$2,
16
+ config
8
17
  };
9
- var _meta_default = { config };
10
18
 
11
19
  //#endregion
12
20
  //#region .vovk-schema/root.json
13
- var $schema$1 = "https://vovk.dev/api/spec/v3/segment.json";
21
+ var $schema$1 = "https://vovk.dev/api/schema/v3/segment.json";
14
22
  var emitSchema$1 = true;
15
23
  var segmentName$1 = "";
16
24
  var segmentType$1 = "segment";
@@ -82,7 +90,7 @@ var controllers$1 = {
82
90
  "examples": ["123e4567-e89b-12d3-a456-426614174000"],
83
91
  "type": "string",
84
92
  "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)$"
93
+ "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
94
  } },
87
95
  "required": ["id"],
88
96
  "additionalProperties": false
@@ -99,12 +107,12 @@ var controllers$1 = {
99
107
  "additionalProperties": false
100
108
  }
101
109
  },
102
- "path": "{id}",
103
- "httpMethod": "POST",
104
- "openapi": {
110
+ "operationObject": {
105
111
  "summary": "Update user",
106
112
  "description": "Update user by ID"
107
- }
113
+ },
114
+ "path": "{id}",
115
+ "httpMethod": "POST"
108
116
  } }
109
117
  },
110
118
  "StreamRPC": {
@@ -123,12 +131,12 @@ var controllers$1 = {
123
131
  "required": ["message"],
124
132
  "additionalProperties": false
125
133
  } },
126
- "path": "tokens",
127
- "httpMethod": "GET",
128
- "openapi": {
134
+ "operationObject": {
129
135
  "summary": "Stream tokens",
130
136
  "description": "Stream tokens to the client"
131
- }
137
+ },
138
+ "path": "tokens",
139
+ "httpMethod": "GET"
132
140
  } }
133
141
  }
134
142
  };
@@ -142,7 +150,7 @@ var root_default = {
142
150
 
143
151
  //#endregion
144
152
  //#region .vovk-schema/static.json
145
- var $schema = "https://vovk.dev/api/spec/v3/segment.json";
153
+ var $schema = "https://vovk.dev/api/schema/v3/segment.json";
146
154
  var emitSchema = true;
147
155
  var segmentName = "static";
148
156
  var segmentType = "segment";
@@ -153,7 +161,7 @@ var controllers = { "OpenApiRPC": {
153
161
  "handlers": { "getSpec": {
154
162
  "path": "spec.json",
155
163
  "httpMethod": "GET",
156
- "openapi": {
164
+ "operationObject": {
157
165
  "summary": "OpenAPI spec",
158
166
  "description": "Get the OpenAPI spec for the \"Hello World\" app API"
159
167
  }
@@ -174,29 +182,274 @@ const segments = {
174
182
  "static": static_default
175
183
  };
176
184
  const schema = {
177
- $schema: "https://vovk.dev/api/spec/v3/schema.json",
185
+ $schema: "https://vovk.dev/api/schema/v3/schema.json",
178
186
  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
187
+ meta: { ..._meta_default }
188
+ };
189
+
190
+ //#endregion
191
+ //#region tmp_prebundle/openapi.json
192
+ var info = {};
193
+ var openapi = "3.1.0";
194
+ var components = { "schemas": {
195
+ "HttpStatus": {
196
+ "type": "integer",
197
+ "description": "HTTP status code",
198
+ "enum": [
199
+ 100,
200
+ 101,
201
+ 102,
202
+ 103,
203
+ 200,
204
+ 201,
205
+ 202,
206
+ 203,
207
+ 204,
208
+ 205,
209
+ 206,
210
+ 300,
211
+ 301,
212
+ 302,
213
+ 303,
214
+ 304,
215
+ 307,
216
+ 308,
217
+ 400,
218
+ 401,
219
+ 402,
220
+ 403,
221
+ 404,
222
+ 405,
223
+ 406,
224
+ 407,
225
+ 408,
226
+ 409,
227
+ 410,
228
+ 411,
229
+ 412,
230
+ 413,
231
+ 414,
232
+ 415,
233
+ 416,
234
+ 417,
235
+ 418,
236
+ 421,
237
+ 422,
238
+ 424,
239
+ 428,
240
+ 429,
241
+ 500,
242
+ 501,
243
+ 502,
244
+ 503,
245
+ 504,
246
+ 505
247
+ ]
248
+ },
249
+ "VovkErrorResponse": {
250
+ "type": "object",
251
+ "description": "Vovk error response",
252
+ "properties": {
253
+ "cause": { "description": "Error cause of any shape" },
254
+ "statusCode": { "$ref": "#/components/schemas/HttpStatus" },
255
+ "message": {
256
+ "type": "string",
257
+ "description": "Error message"
258
+ },
259
+ "isError": {
260
+ "type": "boolean",
261
+ "const": true,
262
+ "description": "Indicates that this object represents an error"
263
+ }
264
+ },
265
+ "required": [
266
+ "statusCode",
267
+ "message",
268
+ "isError"
269
+ ],
270
+ "additionalProperties": false
183
271
  }
272
+ } };
273
+ var paths = {
274
+ "/api/users/{id}": { "post": {
275
+ "summary": "Update user",
276
+ "description": "Update user by ID",
277
+ "x-codeSamples": [
278
+ {
279
+ "label": "TypeScript RPC",
280
+ "lang": "typescript",
281
+ "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*/"
282
+ },
283
+ {
284
+ "label": "Python RPC",
285
+ "lang": "python",
286
+ "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}"
287
+ },
288
+ {
289
+ "label": "Rust RPC",
290
+ "lang": "rust",
291
+ "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}"
292
+ }
293
+ ],
294
+ "parameters": [{
295
+ "name": "notify",
296
+ "in": "query",
297
+ "required": true,
298
+ "schema": {
299
+ "description": "Notification type",
300
+ "type": "string",
301
+ "enum": [
302
+ "email",
303
+ "push",
304
+ "none"
305
+ ]
306
+ }
307
+ }, {
308
+ "name": "id",
309
+ "in": "path",
310
+ "required": true,
311
+ "schema": {
312
+ "description": "User ID",
313
+ "examples": ["123e4567-e89b-12d3-a456-426614174000"],
314
+ "type": "string",
315
+ "format": "uuid",
316
+ "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)$"
317
+ }
318
+ }],
319
+ "responses": { "200": {
320
+ "description": "Response object",
321
+ "content": { "application/json": { "schema": {
322
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
323
+ "description": "Response object",
324
+ "type": "object",
325
+ "properties": { "success": {
326
+ "description": "Success status",
327
+ "type": "boolean"
328
+ } },
329
+ "required": ["success"],
330
+ "additionalProperties": false
331
+ } } }
332
+ } },
333
+ "requestBody": {
334
+ "description": "User data object",
335
+ "required": true,
336
+ "content": { "application/json": { "schema": {
337
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
338
+ "description": "User data object",
339
+ "type": "object",
340
+ "properties": {
341
+ "email": {
342
+ "description": "User email",
343
+ "examples": ["john@example.com", "jane@example.com"],
344
+ "type": "string",
345
+ "format": "email",
346
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
347
+ },
348
+ "profile": {
349
+ "description": "User profile object",
350
+ "type": "object",
351
+ "properties": {
352
+ "name": {
353
+ "description": "User full name",
354
+ "examples": ["John Doe", "Jane Smith"],
355
+ "type": "string"
356
+ },
357
+ "age": {
358
+ "description": "User age",
359
+ "examples": [25, 30],
360
+ "type": "integer",
361
+ "minimum": 16,
362
+ "maximum": 120
363
+ }
364
+ },
365
+ "required": ["name", "age"],
366
+ "additionalProperties": false
367
+ }
368
+ },
369
+ "required": ["email", "profile"],
370
+ "additionalProperties": false
371
+ } } }
372
+ }
373
+ } },
374
+ "/api/streams/tokens": { "get": {
375
+ "summary": "Stream tokens",
376
+ "description": "Stream tokens to the client",
377
+ "x-codeSamples": [
378
+ {
379
+ "label": "TypeScript RPC",
380
+ "lang": "typescript",
381
+ "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}"
382
+ },
383
+ {
384
+ "label": "Python RPC",
385
+ "lang": "python",
386
+ "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 }"
387
+ },
388
+ {
389
+ "label": "Rust RPC",
390
+ "lang": "rust",
391
+ "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}"
392
+ }
393
+ ],
394
+ "responses": { "200": {
395
+ "description": "Streamed token object",
396
+ "content": { "application/jsonl": { "schema": {
397
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
398
+ "description": "Streamed token object",
399
+ "type": "object",
400
+ "properties": { "message": {
401
+ "description": "Message from the token",
402
+ "type": "string"
403
+ } },
404
+ "required": ["message"],
405
+ "additionalProperties": false,
406
+ "examples": ["{\"message\":\"string\"}\n{\"message\":\"string\"}\n{\"message\":\"string\"}"]
407
+ } } }
408
+ } }
409
+ } },
410
+ "/api/static/openapi/spec.json": { "get": {
411
+ "summary": "OpenAPI spec",
412
+ "description": "Get the OpenAPI spec for the \"Hello World\" app API",
413
+ "x-codeSamples": [
414
+ {
415
+ "label": "TypeScript RPC",
416
+ "lang": "typescript",
417
+ "source": "import { OpenApiRPC } from 'vovk-client';\n\nconst response = await OpenApiRPC.getSpec();"
418
+ },
419
+ {
420
+ "label": "Python RPC",
421
+ "lang": "python",
422
+ "source": "from vovk_client import OpenApiRPC\n\nresponse = OpenApiRPC.get_spec()"
423
+ },
424
+ {
425
+ "label": "Rust RPC",
426
+ "lang": "rust",
427
+ "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}"
428
+ }
429
+ ]
430
+ } }
431
+ };
432
+ var openapi_default = {
433
+ info,
434
+ openapi,
435
+ components,
436
+ paths
184
437
  };
185
438
 
186
439
  //#endregion
187
440
  //#region tmp_prebundle/index.ts
188
- const UserRPC = createRPC(schema, "", "UserRPC", fetcher, {
189
- validateOnClient,
190
- apiRoot: "https://vovk-hello-world.vercel.app/api"
441
+ const UserRPC = createRPC(schema, "", "UserRPC", import("vovk"), {
442
+ validateOnClient: import("vovk-ajv"),
443
+ apiRoot: "/api"
191
444
  });
192
- const StreamRPC = createRPC(schema, "", "StreamRPC", fetcher, {
193
- validateOnClient,
194
- apiRoot: "https://vovk-hello-world.vercel.app/api"
445
+ const StreamRPC = createRPC(schema, "", "StreamRPC", import("vovk"), {
446
+ validateOnClient: import("vovk-ajv"),
447
+ apiRoot: "/api"
195
448
  });
196
- const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", fetcher, {
197
- validateOnClient,
198
- apiRoot: "https://vovk-hello-world.vercel.app/api"
449
+ const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", import("vovk"), {
450
+ validateOnClient: import("vovk-ajv"),
451
+ apiRoot: "/api"
199
452
  });
200
453
 
201
454
  //#endregion
202
- export { OpenApiRPC, StreamRPC, UserRPC, schema };
455
+ export { OpenApiRPC, StreamRPC, UserRPC, openapi_default as openapi, schema };