vovk-hello-world 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts ADDED
@@ -0,0 +1,373 @@
1
+ import * as vovk0 from "vovk";
2
+ import { VovkClientFetcher } from "vovk";
3
+ import * as _tanstack_react_query8 from "@tanstack/react-query";
4
+ import * as _tanstack_query_core9 from "@tanstack/query-core";
5
+ import * as openapi3_ts_oas3139 from "openapi3-ts/oas31";
6
+
7
+ //#region tmp_ts_rpc/schema.d.ts
8
+ declare const schema: {
9
+ $schema: string;
10
+ segments: {
11
+ '': {
12
+ $schema: string;
13
+ emitSchema: boolean;
14
+ segmentName: string;
15
+ segmentType: string;
16
+ controllers: {
17
+ UserRPC: {
18
+ rpcModuleName: string;
19
+ originalControllerName: string;
20
+ prefix: string;
21
+ handlers: {
22
+ updateUser: {
23
+ validation: {
24
+ body: {
25
+ $schema: string;
26
+ description: string;
27
+ type: string;
28
+ properties: {
29
+ email: {
30
+ description: string;
31
+ examples: string[];
32
+ type: string;
33
+ format: string;
34
+ pattern: string;
35
+ };
36
+ profile: {
37
+ description: string;
38
+ type: string;
39
+ properties: {
40
+ name: {
41
+ description: string;
42
+ examples: string[];
43
+ type: string;
44
+ };
45
+ age: {
46
+ description: string;
47
+ examples: number[];
48
+ type: string;
49
+ minimum: number;
50
+ maximum: number;
51
+ };
52
+ };
53
+ required: string[];
54
+ additionalProperties: boolean;
55
+ };
56
+ };
57
+ required: string[];
58
+ additionalProperties: boolean;
59
+ };
60
+ query: {
61
+ $schema: string;
62
+ description: string;
63
+ type: string;
64
+ properties: {
65
+ notify: {
66
+ description: string;
67
+ type: string;
68
+ enum: string[];
69
+ };
70
+ };
71
+ required: string[];
72
+ additionalProperties: boolean;
73
+ };
74
+ params: {
75
+ $schema: string;
76
+ description: string;
77
+ type: string;
78
+ properties: {
79
+ id: {
80
+ description: string;
81
+ examples: string[];
82
+ type: string;
83
+ format: string;
84
+ pattern: string;
85
+ };
86
+ };
87
+ required: string[];
88
+ additionalProperties: boolean;
89
+ };
90
+ output: {
91
+ $schema: string;
92
+ description: string;
93
+ type: string;
94
+ properties: {
95
+ success: {
96
+ description: string;
97
+ type: string;
98
+ };
99
+ };
100
+ required: string[];
101
+ additionalProperties: boolean;
102
+ };
103
+ };
104
+ path: string;
105
+ httpMethod: string;
106
+ openapi: {
107
+ summary: string;
108
+ description: string;
109
+ };
110
+ };
111
+ };
112
+ };
113
+ StreamRPC: {
114
+ rpcModuleName: string;
115
+ originalControllerName: string;
116
+ prefix: string;
117
+ handlers: {
118
+ streamTokens: {
119
+ validation: {
120
+ iteration: {
121
+ $schema: string;
122
+ description: string;
123
+ type: string;
124
+ properties: {
125
+ message: {
126
+ description: string;
127
+ type: string;
128
+ };
129
+ };
130
+ required: string[];
131
+ additionalProperties: boolean;
132
+ };
133
+ };
134
+ path: string;
135
+ httpMethod: string;
136
+ openapi: {
137
+ summary: string;
138
+ description: string;
139
+ };
140
+ };
141
+ };
142
+ };
143
+ };
144
+ };
145
+ static: {
146
+ $schema: string;
147
+ emitSchema: boolean;
148
+ segmentName: string;
149
+ segmentType: string;
150
+ controllers: {
151
+ OpenApiRPC: {
152
+ rpcModuleName: string;
153
+ originalControllerName: string;
154
+ prefix: string;
155
+ handlers: {
156
+ getSpec: {
157
+ path: string;
158
+ httpMethod: string;
159
+ openapi: {
160
+ summary: string;
161
+ description: string;
162
+ };
163
+ };
164
+ };
165
+ };
166
+ };
167
+ };
168
+ };
169
+ meta: {
170
+ config: {
171
+ $schema: string;
172
+ libs: {};
173
+ };
174
+ $schema: string;
175
+ apiRoot: string;
176
+ };
177
+ };
178
+ //#endregion
179
+ //#region tmp_ts_rpc/index.d.ts
180
+ declare const UserRPC: {
181
+ updateUser: (<R, F extends unknown = vovk0.VovkDefaultFetcherOptions<{
182
+ apiRoot?: string;
183
+ disableClientValidation?: boolean;
184
+ validateOnClient?: vovk0.VovkValidateOnClient;
185
+ interpretAs?: string;
186
+ init?: RequestInit;
187
+ }>>(options: {
188
+ body: {
189
+ email: string;
190
+ profile: {
191
+ name: string;
192
+ age: number;
193
+ };
194
+ };
195
+ query: {
196
+ notify: "email" | "push" | "none";
197
+ };
198
+ params: {
199
+ id: string;
200
+ };
201
+ apiRoot?: string | undefined;
202
+ disableClientValidation?: boolean | undefined;
203
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
204
+ interpretAs?: string | undefined;
205
+ init?: RequestInit | undefined;
206
+ transform?: ((staticMethodReturn: {
207
+ success: true;
208
+ }, resp: Response) => R) | undefined;
209
+ fetcher?: VovkClientFetcher<F> | undefined;
210
+ }) => R extends object ? Promise<Awaited<R>> : Promise<{
211
+ success: true;
212
+ }>) & {
213
+ isRPC: true;
214
+ schema: vovk0.VovkHandlerSchema;
215
+ controllerSchema: vovk0.VovkControllerSchema;
216
+ segmentSchema: vovk0.VovkSegmentSchema;
217
+ fullSchema: vovk0.VovkSchema;
218
+ __types: {
219
+ body: {
220
+ email: string;
221
+ profile: {
222
+ name: string;
223
+ age: number;
224
+ };
225
+ };
226
+ query: {
227
+ notify: "email" | "push" | "none";
228
+ };
229
+ params: {
230
+ id: string;
231
+ };
232
+ output: {
233
+ success: boolean;
234
+ };
235
+ iteration: unknown;
236
+ isForm: false;
237
+ };
238
+ } & {
239
+ useQuery: (input: {
240
+ body: {
241
+ email: string;
242
+ profile: {
243
+ name: string;
244
+ age: number;
245
+ };
246
+ };
247
+ query: {
248
+ notify: "email" | "push" | "none";
249
+ };
250
+ params: {
251
+ id: string;
252
+ };
253
+ apiRoot?: string | undefined;
254
+ disableClientValidation?: boolean | undefined;
255
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
256
+ interpretAs?: string | undefined;
257
+ init?: RequestInit | undefined;
258
+ transform?: ((staticMethodReturn: {
259
+ success: true;
260
+ }, resp: Response) => unknown) | undefined;
261
+ fetcher?: VovkClientFetcher<unknown> | undefined;
262
+ }, options?: Omit<_tanstack_react_query8.UseQueryOptions<Promise<{
263
+ success: true;
264
+ }>, Error, Promise<{
265
+ success: true;
266
+ }>, readonly unknown[]>, "queryFn" | "queryKey"> | undefined, queryClient?: _tanstack_query_core9.QueryClient) => _tanstack_react_query8.UseQueryResult<{
267
+ success: true;
268
+ }, vovk0.HttpException>;
269
+ useMutation: (options?: Omit<_tanstack_react_query8.UseMutationOptions<Promise<{
270
+ success: true;
271
+ }>, Error, void, unknown>, "mutationFn"> | undefined, queryClient?: _tanstack_query_core9.QueryClient) => _tanstack_react_query8.UseMutationResult<{
272
+ success: true;
273
+ }, vovk0.HttpException, {
274
+ body: {
275
+ email: string;
276
+ profile: {
277
+ name: string;
278
+ age: number;
279
+ };
280
+ };
281
+ query: {
282
+ notify: "email" | "push" | "none";
283
+ };
284
+ params: {
285
+ id: string;
286
+ };
287
+ apiRoot?: string | undefined;
288
+ disableClientValidation?: boolean | undefined;
289
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
290
+ interpretAs?: string | undefined;
291
+ init?: RequestInit | undefined;
292
+ transform?: ((staticMethodReturn: {
293
+ success: true;
294
+ }, resp: Response) => unknown) | undefined;
295
+ fetcher?: VovkClientFetcher<unknown> | undefined;
296
+ }, unknown>;
297
+ };
298
+ };
299
+ declare const StreamRPC: {
300
+ streamTokens: (<R, F extends unknown = vovk0.VovkDefaultFetcherOptions<{
301
+ apiRoot?: string;
302
+ disableClientValidation?: boolean;
303
+ validateOnClient?: vovk0.VovkValidateOnClient;
304
+ interpretAs?: string;
305
+ init?: RequestInit;
306
+ }>>(options?: {
307
+ apiRoot?: string | undefined;
308
+ disableClientValidation?: boolean | undefined;
309
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
310
+ interpretAs?: string | undefined;
311
+ init?: RequestInit | undefined;
312
+ transform?: ((staticMethodReturn: AsyncGenerator<{
313
+ message: string;
314
+ }, void, unknown>, resp: Response) => R) | undefined;
315
+ fetcher?: VovkClientFetcher<F> | undefined;
316
+ } | undefined) => Promise<vovk0.VovkStreamAsyncIterable<{
317
+ message: string;
318
+ }>>) & {
319
+ isRPC: true;
320
+ schema: vovk0.VovkHandlerSchema;
321
+ controllerSchema: vovk0.VovkControllerSchema;
322
+ segmentSchema: vovk0.VovkSegmentSchema;
323
+ fullSchema: vovk0.VovkSchema;
324
+ __types: {
325
+ body: unknown;
326
+ query: unknown;
327
+ params: unknown;
328
+ output: unknown;
329
+ iteration: {
330
+ message: string;
331
+ };
332
+ isForm: false;
333
+ };
334
+ } & {
335
+ useQuery: (input?: {
336
+ apiRoot?: string | undefined;
337
+ disableClientValidation?: boolean | undefined;
338
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
339
+ interpretAs?: string | undefined;
340
+ init?: RequestInit | undefined;
341
+ transform?: ((staticMethodReturn: AsyncGenerator<{
342
+ message: string;
343
+ }, void, unknown>, resp: Response) => unknown) | undefined;
344
+ fetcher?: VovkClientFetcher<unknown> | undefined;
345
+ } | undefined, options?: Omit<_tanstack_react_query8.UseQueryOptions<Promise<vovk0.VovkStreamAsyncIterable<{
346
+ message: string;
347
+ }>>, Error, Promise<vovk0.VovkStreamAsyncIterable<{
348
+ message: string;
349
+ }>>, readonly unknown[]>, "queryFn" | "queryKey"> | undefined, queryClient?: _tanstack_query_core9.QueryClient) => _tanstack_react_query8.UseQueryResult<{
350
+ message: string;
351
+ }[], vovk0.HttpException>;
352
+ useMutation: (options?: Omit<_tanstack_react_query8.UseMutationOptions<Promise<vovk0.VovkStreamAsyncIterable<{
353
+ message: string;
354
+ }>>, Error, void, unknown>, "mutationFn"> | undefined, queryClient?: _tanstack_query_core9.QueryClient) => _tanstack_react_query8.UseMutationResult<vovk0.VovkStreamAsyncIterable<{
355
+ message: string;
356
+ }>, vovk0.HttpException, {
357
+ apiRoot?: string | undefined;
358
+ disableClientValidation?: boolean | undefined;
359
+ validateOnClient?: vovk0.VovkValidateOnClient | undefined;
360
+ interpretAs?: string | undefined;
361
+ init?: RequestInit | undefined;
362
+ transform?: ((staticMethodReturn: AsyncGenerator<{
363
+ message: string;
364
+ }, void, unknown>, resp: Response) => unknown) | undefined;
365
+ fetcher?: VovkClientFetcher<unknown> | undefined;
366
+ } | undefined, unknown>;
367
+ };
368
+ };
369
+ declare const OpenApiRPC: {
370
+ getSpec: () => Promise<openapi3_ts_oas3139.OpenAPIObject>;
371
+ };
372
+ //#endregion
373
+ export { OpenApiRPC, StreamRPC, UserRPC, schema };
package/index.mjs ADDED
@@ -0,0 +1,203 @@
1
+ import { fetcher } from "vovk";
2
+ import { createRPC } from "vovk-react-query";
3
+ import { validateOnClient } from "vovk-ajv";
4
+
5
+ //#region .vovk-schema/_meta.json
6
+ var config = {
7
+ "$schema": "https://vovk.dev/api/spec/v3/config.json",
8
+ "libs": {}
9
+ };
10
+ var _meta_default = { config };
11
+
12
+ //#endregion
13
+ //#region .vovk-schema/root.json
14
+ var $schema$1 = "https://vovk.dev/api/spec/v3/segment.json";
15
+ var emitSchema$1 = true;
16
+ var segmentName$1 = "";
17
+ var segmentType$1 = "segment";
18
+ var controllers$1 = {
19
+ "UserRPC": {
20
+ "rpcModuleName": "UserRPC",
21
+ "originalControllerName": "UserController",
22
+ "prefix": "users",
23
+ "handlers": { "updateUser": {
24
+ "validation": {
25
+ "body": {
26
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
27
+ "description": "User data object",
28
+ "type": "object",
29
+ "properties": {
30
+ "email": {
31
+ "description": "User email",
32
+ "examples": ["john@example.com", "jane@example.com"],
33
+ "type": "string",
34
+ "format": "email",
35
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
36
+ },
37
+ "profile": {
38
+ "description": "User profile object",
39
+ "type": "object",
40
+ "properties": {
41
+ "name": {
42
+ "description": "User full name",
43
+ "examples": ["John Doe", "Jane Smith"],
44
+ "type": "string"
45
+ },
46
+ "age": {
47
+ "description": "User age",
48
+ "examples": [25, 30],
49
+ "type": "integer",
50
+ "minimum": 16,
51
+ "maximum": 120
52
+ }
53
+ },
54
+ "required": ["name", "age"],
55
+ "additionalProperties": false
56
+ }
57
+ },
58
+ "required": ["email", "profile"],
59
+ "additionalProperties": false
60
+ },
61
+ "query": {
62
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
63
+ "description": "Query parameters",
64
+ "type": "object",
65
+ "properties": { "notify": {
66
+ "description": "Notification type",
67
+ "type": "string",
68
+ "enum": [
69
+ "email",
70
+ "push",
71
+ "none"
72
+ ]
73
+ } },
74
+ "required": ["notify"],
75
+ "additionalProperties": false
76
+ },
77
+ "params": {
78
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
79
+ "description": "Path parameters",
80
+ "type": "object",
81
+ "properties": { "id": {
82
+ "description": "User ID",
83
+ "examples": ["123e4567-e89b-12d3-a456-426614174000"],
84
+ "type": "string",
85
+ "format": "uuid",
86
+ "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)$"
87
+ } },
88
+ "required": ["id"],
89
+ "additionalProperties": false
90
+ },
91
+ "output": {
92
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
93
+ "description": "Response object",
94
+ "type": "object",
95
+ "properties": { "success": {
96
+ "description": "Success status",
97
+ "type": "boolean"
98
+ } },
99
+ "required": ["success"],
100
+ "additionalProperties": false
101
+ }
102
+ },
103
+ "path": "{id}",
104
+ "httpMethod": "POST",
105
+ "openapi": {
106
+ "summary": "Update user",
107
+ "description": "Update user by ID"
108
+ }
109
+ } }
110
+ },
111
+ "StreamRPC": {
112
+ "rpcModuleName": "StreamRPC",
113
+ "originalControllerName": "StreamController",
114
+ "prefix": "streams",
115
+ "handlers": { "streamTokens": {
116
+ "validation": { "iteration": {
117
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
118
+ "description": "Streamed token object",
119
+ "type": "object",
120
+ "properties": { "message": {
121
+ "description": "Message from the token",
122
+ "type": "string"
123
+ } },
124
+ "required": ["message"],
125
+ "additionalProperties": false
126
+ } },
127
+ "path": "tokens",
128
+ "httpMethod": "GET",
129
+ "openapi": {
130
+ "summary": "Stream tokens",
131
+ "description": "Stream tokens to the client"
132
+ }
133
+ } }
134
+ }
135
+ };
136
+ var root_default = {
137
+ $schema: $schema$1,
138
+ emitSchema: emitSchema$1,
139
+ segmentName: segmentName$1,
140
+ segmentType: segmentType$1,
141
+ controllers: controllers$1
142
+ };
143
+
144
+ //#endregion
145
+ //#region .vovk-schema/static.json
146
+ var $schema = "https://vovk.dev/api/spec/v3/segment.json";
147
+ var emitSchema = true;
148
+ var segmentName = "static";
149
+ var segmentType = "segment";
150
+ var controllers = { "OpenApiRPC": {
151
+ "rpcModuleName": "OpenApiRPC",
152
+ "originalControllerName": "OpenApiController",
153
+ "prefix": "openapi",
154
+ "handlers": { "getSpec": {
155
+ "path": "spec.json",
156
+ "httpMethod": "GET",
157
+ "openapi": {
158
+ "summary": "OpenAPI spec",
159
+ "description": "Get the OpenAPI spec for the \"Hello World\" app API"
160
+ }
161
+ } }
162
+ } };
163
+ var static_default = {
164
+ $schema,
165
+ emitSchema,
166
+ segmentName,
167
+ segmentType,
168
+ controllers
169
+ };
170
+
171
+ //#endregion
172
+ //#region tmp_ts_rpc/schema.ts
173
+ const segments = {
174
+ "": root_default,
175
+ "static": static_default
176
+ };
177
+ const schema = {
178
+ $schema: "https://vovk.dev/api/spec/v3/schema.json",
179
+ segments,
180
+ meta: {
181
+ $schema: "https://vovk.dev/api/spec/v3/meta.json",
182
+ apiRoot: "http://localhost:3000/api",
183
+ ..._meta_default
184
+ }
185
+ };
186
+
187
+ //#endregion
188
+ //#region tmp_ts_rpc/index.ts
189
+ const UserRPC = createRPC(schema, "", "UserRPC", fetcher, {
190
+ validateOnClient,
191
+ apiRoot: "http://localhost:3000/api"
192
+ });
193
+ const StreamRPC = createRPC(schema, "", "StreamRPC", fetcher, {
194
+ validateOnClient,
195
+ apiRoot: "http://localhost:3000/api"
196
+ });
197
+ const OpenApiRPC = createRPC(schema, "static", "OpenApiRPC", fetcher, {
198
+ validateOnClient,
199
+ apiRoot: "http://localhost:3000/api"
200
+ });
201
+
202
+ //#endregion
203
+ export { OpenApiRPC, StreamRPC, UserRPC, schema };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "vovk-hello-world",
3
+ "version": "0.0.1",
4
+ "description": "A showcase for Next.js + Vovk.ts + Zod, demonstrating its capabilities with TypeScript, Rust, and Python RPC.",
5
+ "license": "MIT",
6
+ "main": "./index.cjs",
7
+ "module": "./index.mjs",
8
+ "types": "./index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.mjs",
12
+ "require": "./index.cjs"
13
+ },
14
+ "./schema": {
15
+ "import": "./schema.cjs",
16
+ "require": "./schema.cjs",
17
+ "types": "./schema.d.cts"
18
+ }
19
+ }
20
+ }