vovk 3.0.0-draft.46 → 3.0.0-draft.461
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/LICENSE +1 -1
- package/README.md +8 -96
- package/bin/index.mjs +8 -0
- package/cjs/JSONLinesResponse.d.ts +19 -0
- package/cjs/JSONLinesResponse.js +95 -0
- package/{VovkApp.d.ts → cjs/VovkApp.d.ts} +14 -8
- package/cjs/VovkApp.js +304 -0
- package/cjs/client/createRPC.d.ts +5 -0
- package/cjs/client/createRPC.js +116 -0
- package/cjs/client/defaultHandler.d.ts +6 -0
- package/{client → cjs/client}/defaultHandler.js +9 -2
- package/cjs/client/defaultStreamHandler.d.ts +9 -0
- package/{client → cjs/client}/defaultStreamHandler.js +49 -26
- package/cjs/client/fetcher.d.ts +18 -0
- package/cjs/client/fetcher.js +97 -0
- package/cjs/client/index.d.ts +4 -0
- package/cjs/client/index.js +10 -0
- package/cjs/client/progressive.d.ts +9 -0
- package/cjs/client/progressive.js +54 -0
- package/cjs/client/types.d.ts +120 -0
- package/{createVovkApp.d.ts → cjs/createVovkApp.d.ts} +19 -16
- package/cjs/createVovkApp.js +146 -0
- package/cjs/index.d.ts +69 -0
- package/cjs/index.js +42 -0
- package/cjs/openapi/error.d.ts +2 -0
- package/cjs/openapi/error.js +100 -0
- package/cjs/openapi/index.d.ts +8 -0
- package/cjs/openapi/index.js +21 -0
- package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
- package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
- package/cjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
- package/cjs/openapi/openAPIToVovkSchema/index.js +141 -0
- package/cjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
- package/cjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
- package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +8 -0
- package/cjs/openapi/vovkSchemaToOpenAPI.js +238 -0
- package/cjs/types.d.ts +466 -0
- package/{types.js → cjs/types.js} +14 -2
- package/cjs/utils/camelCase.d.ts +6 -0
- package/cjs/utils/camelCase.js +37 -0
- package/cjs/utils/createCodeSamples.d.ts +20 -0
- package/cjs/utils/createCodeSamples.js +279 -0
- package/cjs/utils/createDecorator.d.ts +6 -0
- package/{createDecorator.js → cjs/utils/createDecorator.js} +24 -14
- package/cjs/utils/createLLMTools.d.ts +50 -0
- package/cjs/utils/createLLMTools.js +168 -0
- package/cjs/utils/createStandardValidation.d.ts +83 -0
- package/cjs/utils/createStandardValidation.js +35 -0
- package/cjs/utils/createValidateOnClient.d.ts +7 -0
- package/cjs/utils/createValidateOnClient.js +19 -0
- package/cjs/utils/deepExtend.d.ts +54 -0
- package/cjs/utils/deepExtend.js +134 -0
- package/{utils → cjs/utils}/generateStaticAPI.d.ts +2 -2
- package/cjs/utils/generateStaticAPI.js +30 -0
- package/cjs/utils/getJSONSchemaExample.d.ts +11 -0
- package/cjs/utils/getJSONSchemaExample.js +264 -0
- package/cjs/utils/getJSONSchemaSample.d.ts +2 -0
- package/cjs/utils/getJSONSchemaSample.js +167 -0
- package/cjs/utils/getSampleFromObject.d.ts +9 -0
- package/cjs/utils/getSampleFromObject.js +41 -0
- package/cjs/utils/getSchema.d.ts +21 -0
- package/cjs/utils/getSchema.js +38 -0
- package/cjs/utils/multitenant.d.ts +24 -0
- package/cjs/utils/multitenant.js +131 -0
- package/cjs/utils/parseQuery.d.ts +25 -0
- package/cjs/utils/parseQuery.js +156 -0
- package/cjs/utils/reqForm.d.ts +2 -0
- package/cjs/utils/reqForm.js +33 -0
- package/cjs/utils/reqMeta.d.ts +2 -0
- package/cjs/utils/reqQuery.d.ts +2 -0
- package/cjs/utils/reqQuery.js +10 -0
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +18 -0
- package/cjs/utils/resolveGeneratorConfigValues.js +82 -0
- package/cjs/utils/serializeQuery.d.ts +13 -0
- package/cjs/utils/serializeQuery.js +65 -0
- package/cjs/utils/setHandlerSchema.d.ts +4 -0
- package/cjs/utils/setHandlerSchema.js +15 -0
- package/cjs/utils/upperFirst.d.ts +1 -0
- package/cjs/utils/upperFirst.js +6 -0
- package/cjs/utils/withValidationLibrary.d.ts +78 -0
- package/cjs/utils/withValidationLibrary.js +133 -0
- package/mjs/HttpException.d.ts +7 -0
- package/mjs/HttpException.js +15 -0
- package/mjs/JSONLinesResponse.d.ts +19 -0
- package/mjs/JSONLinesResponse.js +95 -0
- package/mjs/VovkApp.d.ts +34 -0
- package/mjs/VovkApp.js +304 -0
- package/mjs/client/createRPC.d.ts +5 -0
- package/mjs/client/createRPC.js +116 -0
- package/mjs/client/defaultHandler.d.ts +6 -0
- package/mjs/client/defaultHandler.js +29 -0
- package/mjs/client/defaultStreamHandler.d.ts +9 -0
- package/mjs/client/defaultStreamHandler.js +105 -0
- package/mjs/client/fetcher.d.ts +18 -0
- package/mjs/client/fetcher.js +97 -0
- package/mjs/client/index.d.ts +4 -0
- package/mjs/client/index.js +10 -0
- package/mjs/client/progressive.d.ts +9 -0
- package/mjs/client/progressive.js +54 -0
- package/mjs/client/types.d.ts +120 -0
- package/mjs/createVovkApp.d.ts +65 -0
- package/mjs/createVovkApp.js +146 -0
- package/mjs/index.d.ts +69 -0
- package/mjs/index.js +42 -0
- package/mjs/openapi/error.d.ts +2 -0
- package/mjs/openapi/error.js +100 -0
- package/mjs/openapi/index.d.ts +8 -0
- package/mjs/openapi/index.js +21 -0
- package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
- package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
- package/mjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
- package/mjs/openapi/openAPIToVovkSchema/index.js +141 -0
- package/mjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
- package/mjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
- package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +8 -0
- package/mjs/openapi/vovkSchemaToOpenAPI.js +238 -0
- package/mjs/types.d.ts +466 -0
- package/mjs/types.js +77 -0
- package/mjs/utils/camelCase.d.ts +6 -0
- package/mjs/utils/camelCase.js +37 -0
- package/mjs/utils/createCodeSamples.d.ts +20 -0
- package/mjs/utils/createCodeSamples.js +279 -0
- package/mjs/utils/createDecorator.d.ts +6 -0
- package/mjs/utils/createDecorator.js +48 -0
- package/mjs/utils/createLLMTools.d.ts +50 -0
- package/mjs/utils/createLLMTools.js +168 -0
- package/mjs/utils/createStandardValidation.d.ts +83 -0
- package/mjs/utils/createStandardValidation.js +35 -0
- package/mjs/utils/createValidateOnClient.d.ts +7 -0
- package/mjs/utils/createValidateOnClient.js +19 -0
- package/mjs/utils/deepExtend.d.ts +54 -0
- package/mjs/utils/deepExtend.js +134 -0
- package/mjs/utils/generateStaticAPI.d.ts +4 -0
- package/mjs/utils/generateStaticAPI.js +30 -0
- package/mjs/utils/getJSONSchemaExample.d.ts +11 -0
- package/mjs/utils/getJSONSchemaExample.js +264 -0
- package/mjs/utils/getJSONSchemaSample.d.ts +2 -0
- package/mjs/utils/getJSONSchemaSample.js +167 -0
- package/mjs/utils/getSampleFromObject.d.ts +9 -0
- package/mjs/utils/getSampleFromObject.js +41 -0
- package/mjs/utils/getSchema.d.ts +21 -0
- package/mjs/utils/getSchema.js +38 -0
- package/mjs/utils/multitenant.d.ts +24 -0
- package/mjs/utils/multitenant.js +131 -0
- package/mjs/utils/parseQuery.d.ts +25 -0
- package/mjs/utils/parseQuery.js +156 -0
- package/mjs/utils/reqForm.d.ts +2 -0
- package/mjs/utils/reqForm.js +33 -0
- package/mjs/utils/reqMeta.d.ts +2 -0
- package/mjs/utils/reqMeta.js +13 -0
- package/mjs/utils/reqQuery.d.ts +2 -0
- package/mjs/utils/reqQuery.js +10 -0
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +18 -0
- package/mjs/utils/resolveGeneratorConfigValues.js +82 -0
- package/mjs/utils/serializeQuery.d.ts +13 -0
- package/mjs/utils/serializeQuery.js +65 -0
- package/mjs/utils/setHandlerSchema.d.ts +4 -0
- package/mjs/utils/setHandlerSchema.js +15 -0
- package/mjs/utils/shim.d.ts +1 -0
- package/mjs/utils/shim.js +18 -0
- package/mjs/utils/upperFirst.d.ts +1 -0
- package/mjs/utils/upperFirst.js +6 -0
- package/mjs/utils/withValidationLibrary.d.ts +78 -0
- package/mjs/utils/withValidationLibrary.js +133 -0
- package/package.json +28 -6
- package/.npmignore +0 -2
- package/StreamJSONResponse.d.ts +0 -17
- package/StreamJSONResponse.js +0 -54
- package/VovkApp.js +0 -185
- package/client/clientizeController.d.ts +0 -4
- package/client/clientizeController.js +0 -93
- package/client/defaultFetcher.d.ts +0 -4
- package/client/defaultFetcher.js +0 -49
- package/client/defaultHandler.d.ts +0 -2
- package/client/defaultStreamHandler.d.ts +0 -4
- package/client/index.d.ts +0 -4
- package/client/index.js +0 -5
- package/client/types.d.ts +0 -100
- package/createDecorator.d.ts +0 -4
- package/createVovkApp.js +0 -118
- package/index.d.ts +0 -60
- package/index.js +0 -20
- package/types.d.ts +0 -157
- package/utils/generateStaticAPI.js +0 -18
- package/utils/getSchema.d.ts +0 -8
- package/utils/getSchema.js +0 -38
- package/utils/reqForm.d.ts +0 -3
- package/utils/reqForm.js +0 -13
- package/utils/reqMeta.d.ts +0 -3
- package/utils/reqQuery.d.ts +0 -3
- package/utils/reqQuery.js +0 -25
- package/utils/setClientValidatorsForHandler.d.ts +0 -5
- package/utils/setClientValidatorsForHandler.js +0 -25
- package/worker/index.d.ts +0 -3
- package/worker/index.js +0 -7
- package/worker/promisifyWorker.d.ts +0 -2
- package/worker/promisifyWorker.js +0 -141
- package/worker/types.d.ts +0 -31
- package/worker/worker.d.ts +0 -1
- package/worker/worker.js +0 -43
- /package/{HttpException.d.ts → cjs/HttpException.d.ts} +0 -0
- /package/{HttpException.js → cjs/HttpException.js} +0 -0
- /package/{client → cjs/client}/types.js +0 -0
- /package/{utils → cjs/utils}/reqMeta.js +0 -0
- /package/{utils → cjs/utils}/shim.d.ts +0 -0
- /package/{utils → cjs/utils}/shim.js +0 -0
- /package/{worker → mjs/client}/types.js +0 -0
package/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.initVovk = exports.prefix = exports.options = exports.head = exports.del = exports.patch = exports.put = exports.post = exports.get = exports.generateStaticAPI = exports.worker = exports.createDecorator = exports.createVovkApp = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.StreamJSONResponse = void 0;
|
|
5
|
-
const createVovkApp_1 = require("./createVovkApp");
|
|
6
|
-
Object.defineProperty(exports, "createVovkApp", { enumerable: true, get: function () { return createVovkApp_1.createVovkApp; } });
|
|
7
|
-
const types_1 = require("./types");
|
|
8
|
-
Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return types_1.HttpStatus; } });
|
|
9
|
-
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return types_1.HttpMethod; } });
|
|
10
|
-
const HttpException_1 = require("./HttpException");
|
|
11
|
-
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1.HttpException; } });
|
|
12
|
-
const createDecorator_1 = require("./createDecorator");
|
|
13
|
-
Object.defineProperty(exports, "createDecorator", { enumerable: true, get: function () { return createDecorator_1.createDecorator; } });
|
|
14
|
-
const StreamJSONResponse_1 = require("./StreamJSONResponse");
|
|
15
|
-
Object.defineProperty(exports, "StreamJSONResponse", { enumerable: true, get: function () { return StreamJSONResponse_1.StreamJSONResponse; } });
|
|
16
|
-
const worker_1 = require("./worker");
|
|
17
|
-
Object.defineProperty(exports, "worker", { enumerable: true, get: function () { return worker_1.worker; } });
|
|
18
|
-
const generateStaticAPI_1 = require("./utils/generateStaticAPI");
|
|
19
|
-
Object.defineProperty(exports, "generateStaticAPI", { enumerable: true, get: function () { return generateStaticAPI_1.generateStaticAPI; } });
|
|
20
|
-
_a = (0, createVovkApp_1.createVovkApp)(), exports.get = _a.get, exports.post = _a.post, exports.put = _a.put, exports.patch = _a.patch, exports.del = _a.del, exports.head = _a.head, exports.options = _a.options, exports.prefix = _a.prefix, exports.initVovk = _a.initVovk;
|
package/types.d.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { NextRequest } from 'next/server';
|
|
2
|
-
import type { StreamJSONResponse } from './StreamJSONResponse';
|
|
3
|
-
import { StreamAsyncIterator } from './client/types';
|
|
4
|
-
export type KnownAny = any;
|
|
5
|
-
export type StaticClass = Function;
|
|
6
|
-
export type HandlerSchema = {
|
|
7
|
-
path: string;
|
|
8
|
-
httpMethod: HttpMethod;
|
|
9
|
-
validation?: {
|
|
10
|
-
query?: KnownAny;
|
|
11
|
-
body?: KnownAny;
|
|
12
|
-
};
|
|
13
|
-
custom?: Record<string, KnownAny>;
|
|
14
|
-
};
|
|
15
|
-
export type VovkControllerSchema = {
|
|
16
|
-
controllerName: string;
|
|
17
|
-
originalControllerName: string;
|
|
18
|
-
prefix?: string;
|
|
19
|
-
handlers: Record<string, HandlerSchema>;
|
|
20
|
-
};
|
|
21
|
-
export type VovkWorkerSchema = {
|
|
22
|
-
workerName: string;
|
|
23
|
-
originalWorkerName: string;
|
|
24
|
-
handlers: Record<string, {
|
|
25
|
-
isGenerator?: true;
|
|
26
|
-
}>;
|
|
27
|
-
};
|
|
28
|
-
export type VovkSchema = {
|
|
29
|
-
emitSchema: boolean;
|
|
30
|
-
segmentName: string;
|
|
31
|
-
workers: Record<string, VovkWorkerSchema>;
|
|
32
|
-
controllers: Record<string, VovkControllerSchema>;
|
|
33
|
-
};
|
|
34
|
-
export type VovkErrorResponse = {
|
|
35
|
-
cause?: unknown;
|
|
36
|
-
statusCode: HttpStatus;
|
|
37
|
-
message: string;
|
|
38
|
-
isError: true;
|
|
39
|
-
};
|
|
40
|
-
export type VovkControllerInternal = {
|
|
41
|
-
_controllerName?: VovkControllerSchema['controllerName'];
|
|
42
|
-
_prefix?: VovkControllerSchema['prefix'];
|
|
43
|
-
_handlers: VovkControllerSchema['handlers'];
|
|
44
|
-
_activated?: true;
|
|
45
|
-
_onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
46
|
-
};
|
|
47
|
-
export type VovkController = StaticClass & VovkControllerInternal & {
|
|
48
|
-
[key: string]: unknown;
|
|
49
|
-
};
|
|
50
|
-
export type VovkWorker = StaticClass & {
|
|
51
|
-
_handlers: VovkWorkerSchema['handlers'];
|
|
52
|
-
[key: string]: unknown;
|
|
53
|
-
};
|
|
54
|
-
export type DecoratorOptions = {
|
|
55
|
-
cors?: boolean;
|
|
56
|
-
headers?: Record<string, string>;
|
|
57
|
-
};
|
|
58
|
-
export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
|
|
59
|
-
_options?: DecoratorOptions;
|
|
60
|
-
};
|
|
61
|
-
export interface VovkRequest<BODY = undefined, QUERY extends object | undefined = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
|
|
62
|
-
json: () => Promise<BODY>;
|
|
63
|
-
nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
|
|
64
|
-
searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
|
|
65
|
-
get: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends readonly (infer ITEM)[] ? ITEM : QUERY[KEY];
|
|
66
|
-
getAll: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends KnownAny[] ? QUERY[KEY] : QUERY[KEY][];
|
|
67
|
-
entries: () => IterableIterator<[keyof QUERY, QUERY[keyof QUERY]]>;
|
|
68
|
-
forEach: (callbackfn: (value: QUERY[keyof QUERY], key: keyof QUERY, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
|
|
69
|
-
keys: () => IterableIterator<keyof QUERY>;
|
|
70
|
-
values: () => IterableIterator<QUERY[keyof QUERY]>;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
vovk: {
|
|
74
|
-
body: () => Promise<BODY>;
|
|
75
|
-
query: () => QUERY;
|
|
76
|
-
meta: <T = Record<KnownAny, KnownAny>>(meta?: T | null) => T;
|
|
77
|
-
form: <T = KnownAny>() => Promise<T>;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny> = VovkRequest<undefined, Record<string, string | string[]>>, PARAMS extends {
|
|
81
|
-
[key: string]: string;
|
|
82
|
-
} = KnownAny> = ((req: REQ, params: PARAMS) => unknown) & {
|
|
83
|
-
_controller?: VovkController;
|
|
84
|
-
};
|
|
85
|
-
export type VovkControllerBody<T extends (...args: KnownAny) => KnownAny> = Awaited<ReturnType<Parameters<T>[0]['vovk']['body']>>;
|
|
86
|
-
export type VovkControllerQuery<T extends (...args: KnownAny) => KnownAny> = ReturnType<Parameters<T>[0]['vovk']['query']>;
|
|
87
|
-
export type VovkControllerParams<T extends (...args: KnownAny) => KnownAny> = Parameters<T>[1];
|
|
88
|
-
export type VovkControllerYieldType<T extends (req: VovkRequest<KnownAny, KnownAny>) => KnownAny> = T extends (...args: KnownAny[]) => AsyncGenerator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Generator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Promise<StreamJSONResponse<infer Y>> | StreamJSONResponse<infer Y> ? Y : never;
|
|
89
|
-
export type VovkBody<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['body'];
|
|
90
|
-
export type VovkQuery<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['query'];
|
|
91
|
-
export type VovkParams<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['params'];
|
|
92
|
-
export type VovkYieldType<T extends (...args: KnownAny[]) => unknown> = T extends (...args: KnownAny[]) => Promise<StreamAsyncIterator<infer Y>> ? Y : never;
|
|
93
|
-
export type VovkReturnType<T extends (...args: KnownAny) => unknown> = Awaited<ReturnType<T>>;
|
|
94
|
-
export type StreamAbortMessage = {
|
|
95
|
-
isError: true;
|
|
96
|
-
reason: KnownAny;
|
|
97
|
-
};
|
|
98
|
-
export declare enum HttpMethod {
|
|
99
|
-
GET = "GET",
|
|
100
|
-
POST = "POST",
|
|
101
|
-
PUT = "PUT",
|
|
102
|
-
PATCH = "PATCH",
|
|
103
|
-
DELETE = "DELETE",
|
|
104
|
-
HEAD = "HEAD",
|
|
105
|
-
OPTIONS = "OPTIONS"
|
|
106
|
-
}
|
|
107
|
-
export declare enum HttpStatus {
|
|
108
|
-
NULL = 0,
|
|
109
|
-
CONTINUE = 100,
|
|
110
|
-
SWITCHING_PROTOCOLS = 101,
|
|
111
|
-
PROCESSING = 102,
|
|
112
|
-
EARLYHINTS = 103,
|
|
113
|
-
OK = 200,
|
|
114
|
-
CREATED = 201,
|
|
115
|
-
ACCEPTED = 202,
|
|
116
|
-
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
117
|
-
NO_CONTENT = 204,
|
|
118
|
-
RESET_CONTENT = 205,
|
|
119
|
-
PARTIAL_CONTENT = 206,
|
|
120
|
-
AMBIGUOUS = 300,
|
|
121
|
-
MOVED_PERMANENTLY = 301,
|
|
122
|
-
FOUND = 302,
|
|
123
|
-
SEE_OTHER = 303,
|
|
124
|
-
NOT_MODIFIED = 304,
|
|
125
|
-
TEMPORARY_REDIRECT = 307,
|
|
126
|
-
PERMANENT_REDIRECT = 308,
|
|
127
|
-
BAD_REQUEST = 400,
|
|
128
|
-
UNAUTHORIZED = 401,
|
|
129
|
-
PAYMENT_REQUIRED = 402,
|
|
130
|
-
FORBIDDEN = 403,
|
|
131
|
-
NOT_FOUND = 404,
|
|
132
|
-
METHOD_NOT_ALLOWED = 405,
|
|
133
|
-
NOT_ACCEPTABLE = 406,
|
|
134
|
-
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
135
|
-
REQUEST_TIMEOUT = 408,
|
|
136
|
-
CONFLICT = 409,
|
|
137
|
-
GONE = 410,
|
|
138
|
-
LENGTH_REQUIRED = 411,
|
|
139
|
-
PRECONDITION_FAILED = 412,
|
|
140
|
-
PAYLOAD_TOO_LARGE = 413,
|
|
141
|
-
URI_TOO_LONG = 414,
|
|
142
|
-
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
143
|
-
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
144
|
-
EXPECTATION_FAILED = 417,
|
|
145
|
-
I_AM_A_TEAPOT = 418,
|
|
146
|
-
MISDIRECTED = 421,
|
|
147
|
-
UNPROCESSABLE_ENTITY = 422,
|
|
148
|
-
FAILED_DEPENDENCY = 424,
|
|
149
|
-
PRECONDITION_REQUIRED = 428,
|
|
150
|
-
TOO_MANY_REQUESTS = 429,
|
|
151
|
-
INTERNAL_SERVER_ERROR = 500,
|
|
152
|
-
NOT_IMPLEMENTED = 501,
|
|
153
|
-
BAD_GATEWAY = 502,
|
|
154
|
-
SERVICE_UNAVAILABLE = 503,
|
|
155
|
-
GATEWAY_TIMEOUT = 504,
|
|
156
|
-
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
157
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateStaticAPI = generateStaticAPI;
|
|
4
|
-
function generateStaticAPI(c, slug = 'vovk') {
|
|
5
|
-
const controllers = c;
|
|
6
|
-
return [
|
|
7
|
-
{ [slug]: ['_schema_'] },
|
|
8
|
-
...Object.values(controllers)
|
|
9
|
-
.map((controller) => {
|
|
10
|
-
const handlers = controller._handlers;
|
|
11
|
-
const splitPrefix = controller._prefix?.split('/') ?? [];
|
|
12
|
-
return Object.values(handlers).map((handler) => {
|
|
13
|
-
return { [slug]: [...splitPrefix, ...handler.path.split('/')].filter(Boolean) };
|
|
14
|
-
});
|
|
15
|
-
})
|
|
16
|
-
.flat(),
|
|
17
|
-
];
|
|
18
|
-
}
|
package/utils/getSchema.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VovkSchema as VovkSchema, StaticClass as StaticClass } from '../types';
|
|
2
|
-
export default function getSchema(options: {
|
|
3
|
-
emitSchema?: boolean;
|
|
4
|
-
segmentName?: string;
|
|
5
|
-
controllers: Record<string, StaticClass>;
|
|
6
|
-
workers?: Record<string, StaticClass>;
|
|
7
|
-
exposeValidation?: boolean;
|
|
8
|
-
}): VovkSchema;
|
package/utils/getSchema.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getSchema;
|
|
4
|
-
function getSchema(options) {
|
|
5
|
-
const exposeValidation = options?.exposeValidation ?? true;
|
|
6
|
-
const emitSchema = options.emitSchema ?? true;
|
|
7
|
-
const schema = {
|
|
8
|
-
emitSchema,
|
|
9
|
-
segmentName: options.segmentName ?? '',
|
|
10
|
-
controllers: {},
|
|
11
|
-
workers: {},
|
|
12
|
-
};
|
|
13
|
-
if (!emitSchema)
|
|
14
|
-
return schema;
|
|
15
|
-
for (const [controllerName, controller] of Object.entries(options.controllers)) {
|
|
16
|
-
schema.controllers[controllerName] = {
|
|
17
|
-
controllerName: controllerName,
|
|
18
|
-
originalControllerName: controller.name,
|
|
19
|
-
prefix: controller._prefix ?? '',
|
|
20
|
-
handlers: {
|
|
21
|
-
...(exposeValidation
|
|
22
|
-
? controller._handlers
|
|
23
|
-
: Object.fromEntries(Object.entries(controller._handlers ?? {}).map(([key, value]) => [
|
|
24
|
-
key,
|
|
25
|
-
{ ...value, validation: undefined },
|
|
26
|
-
]))),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
for (const [workerName, worker] of Object.entries(options.workers ?? {})) {
|
|
31
|
-
schema.workers[workerName] = {
|
|
32
|
-
workerName,
|
|
33
|
-
originalWorkerName: worker.name,
|
|
34
|
-
handlers: { ...worker._handlers },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return schema;
|
|
38
|
-
}
|
package/utils/reqForm.d.ts
DELETED
package/utils/reqForm.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = reqForm;
|
|
4
|
-
const formMap = new WeakMap();
|
|
5
|
-
async function reqForm(req) {
|
|
6
|
-
if (formMap.has(req)) {
|
|
7
|
-
return formMap.get(req);
|
|
8
|
-
}
|
|
9
|
-
const body = await req.formData();
|
|
10
|
-
const formData = Object.fromEntries(body.entries());
|
|
11
|
-
formMap.set(req, formData);
|
|
12
|
-
return formData;
|
|
13
|
-
}
|
package/utils/reqMeta.d.ts
DELETED
package/utils/reqQuery.d.ts
DELETED
package/utils/reqQuery.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = reqQuery;
|
|
4
|
-
const clientizeController_1 = require("../client/clientizeController");
|
|
5
|
-
function reqQuery(req) {
|
|
6
|
-
const queryArr = req.nextUrl.searchParams.get(clientizeController_1.ARRAY_QUERY_KEY)?.split(',') ?? null;
|
|
7
|
-
const entries = [...req.nextUrl.searchParams.entries()];
|
|
8
|
-
const query = entries.reduce((acc, [key, value]) => {
|
|
9
|
-
if (key === clientizeController_1.ARRAY_QUERY_KEY)
|
|
10
|
-
return acc;
|
|
11
|
-
if (queryArr?.includes(key)) {
|
|
12
|
-
if (!(key in acc)) {
|
|
13
|
-
acc[key] = [value];
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
acc[key].push(value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
acc[key] = value;
|
|
21
|
-
}
|
|
22
|
-
return acc;
|
|
23
|
-
}, {});
|
|
24
|
-
return query;
|
|
25
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = setClientValidatorsForHandler;
|
|
4
|
-
function setClientValidatorsForHandler(h, validation) {
|
|
5
|
-
return new Promise((resolve) => {
|
|
6
|
-
setTimeout(() => {
|
|
7
|
-
const controller = h._controller;
|
|
8
|
-
if (!controller) {
|
|
9
|
-
throw new Error('Error setting client validators. Controller not found. Did you forget to use an HTTP decorator?');
|
|
10
|
-
}
|
|
11
|
-
const handlerName = Object.getOwnPropertyNames(controller).find((key) => controller[key]._sourceMethod === h);
|
|
12
|
-
if (!handlerName) {
|
|
13
|
-
throw new Error('Error setting client validators. Handler not found.');
|
|
14
|
-
}
|
|
15
|
-
controller._handlers = {
|
|
16
|
-
...controller._handlers,
|
|
17
|
-
[handlerName]: {
|
|
18
|
-
...controller._handlers[handlerName],
|
|
19
|
-
validation,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
resolve();
|
|
23
|
-
}, 0);
|
|
24
|
-
});
|
|
25
|
-
}
|
package/worker/index.d.ts
DELETED
package/worker/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promisifyWorker = exports.worker = void 0;
|
|
4
|
-
const worker_1 = require("./worker");
|
|
5
|
-
Object.defineProperty(exports, "worker", { enumerable: true, get: function () { return worker_1.worker; } });
|
|
6
|
-
const promisifyWorker_1 = require("./promisifyWorker");
|
|
7
|
-
Object.defineProperty(exports, "promisifyWorker", { enumerable: true, get: function () { return promisifyWorker_1.promisifyWorker; } });
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promisifyWorker = promisifyWorker;
|
|
4
|
-
function promisifyWorker(currentWorker, workerSchema) {
|
|
5
|
-
if (!workerSchema)
|
|
6
|
-
throw new Error('Worker schema is not provided');
|
|
7
|
-
const schema = workerSchema;
|
|
8
|
-
const instance = {
|
|
9
|
-
worker: currentWorker,
|
|
10
|
-
};
|
|
11
|
-
let callsKey = 0;
|
|
12
|
-
instance.terminate = () => {
|
|
13
|
-
if (instance._isTerminated)
|
|
14
|
-
return;
|
|
15
|
-
instance._isTerminated = true;
|
|
16
|
-
instance.worker?.terminate();
|
|
17
|
-
instance.worker = null;
|
|
18
|
-
};
|
|
19
|
-
instance.employ = (worker) => {
|
|
20
|
-
if (instance._isTerminated)
|
|
21
|
-
return instance;
|
|
22
|
-
instance._isTerminated = true;
|
|
23
|
-
instance.worker = worker;
|
|
24
|
-
return instance;
|
|
25
|
-
};
|
|
26
|
-
instance.fork = (worker) => promisifyWorker(worker, schema);
|
|
27
|
-
for (const methodName of Object.keys(schema.handlers)) {
|
|
28
|
-
const { isGenerator } = schema.handlers[methodName];
|
|
29
|
-
if (isGenerator) {
|
|
30
|
-
const method = (...args) => {
|
|
31
|
-
const key = callsKey;
|
|
32
|
-
callsKey += 1;
|
|
33
|
-
return {
|
|
34
|
-
async *[Symbol.asyncIterator]() {
|
|
35
|
-
if (!instance.worker) {
|
|
36
|
-
throw new Error('Worker is not provided or terminated');
|
|
37
|
-
}
|
|
38
|
-
const w = instance.worker;
|
|
39
|
-
const messageQueue = [];
|
|
40
|
-
let messageResolver = null;
|
|
41
|
-
const onMessage = (e) => {
|
|
42
|
-
const { methodName: m, key: k } = e.data;
|
|
43
|
-
if (k !== key || m !== methodName) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (messageResolver) {
|
|
47
|
-
messageResolver(e.data);
|
|
48
|
-
messageResolver = null;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
messageQueue.push(e.data);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const onError = (e) => {
|
|
55
|
-
if (messageResolver) {
|
|
56
|
-
messageResolver({ error: e.error });
|
|
57
|
-
messageResolver = null;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
messageQueue.push({ error: e.error });
|
|
61
|
-
}
|
|
62
|
-
w.removeEventListener('message', onMessage);
|
|
63
|
-
w.removeEventListener('error', onError);
|
|
64
|
-
throw e.error;
|
|
65
|
-
};
|
|
66
|
-
w.addEventListener('message', onMessage);
|
|
67
|
-
w.addEventListener('error', onError);
|
|
68
|
-
w.postMessage({ key, args, methodName });
|
|
69
|
-
try {
|
|
70
|
-
while (true) {
|
|
71
|
-
let message = null;
|
|
72
|
-
if (messageQueue.length > 0) {
|
|
73
|
-
message = messageQueue.shift();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
message = await new Promise((resolve) => {
|
|
77
|
-
messageResolver = resolve;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const { result, error, done } = message;
|
|
81
|
-
if (error) {
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
if (done) {
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
yield result;
|
|
88
|
-
}
|
|
89
|
-
w.removeEventListener('message', onMessage);
|
|
90
|
-
w.removeEventListener('error', onError);
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
w.removeEventListener('message', onMessage);
|
|
94
|
-
w.removeEventListener('error', onError);
|
|
95
|
-
throw e;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
// @ts-expect-error TODO
|
|
101
|
-
instance[methodName] = method;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const method = (...args) => {
|
|
105
|
-
if (!instance.worker) {
|
|
106
|
-
throw new Error('Worker is not provided or terminated');
|
|
107
|
-
}
|
|
108
|
-
const w = instance.worker;
|
|
109
|
-
return new Promise((resolve, reject) => {
|
|
110
|
-
const key = callsKey;
|
|
111
|
-
callsKey += 1;
|
|
112
|
-
const onError = (e) => {
|
|
113
|
-
w.removeEventListener('message', onMessage);
|
|
114
|
-
w.removeEventListener('error', onError);
|
|
115
|
-
reject(e);
|
|
116
|
-
};
|
|
117
|
-
const onMessage = (e) => {
|
|
118
|
-
const { result, error, key: k, methodName: m } = e.data;
|
|
119
|
-
if (k !== key || m !== methodName) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
w.removeEventListener('message', onMessage);
|
|
123
|
-
w.removeEventListener('error', onError);
|
|
124
|
-
if (error) {
|
|
125
|
-
reject(error);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
resolve(result);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
w.addEventListener('message', onMessage);
|
|
132
|
-
w.addEventListener('error', onError);
|
|
133
|
-
w.postMessage({ key, args, methodName });
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
// @ts-expect-error TODO
|
|
137
|
-
instance[methodName] = method;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return instance;
|
|
141
|
-
}
|
package/worker/types.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { KnownAny } from '../types';
|
|
2
|
-
type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
|
|
3
|
-
type ToAsyncGenerator<T> = T extends AsyncGenerator<unknown, unknown, unknown> ? T : T extends Generator<infer U, unknown, unknown> ? AsyncGenerator<U, unknown, unknown> : AsyncGenerator<T, unknown, unknown>;
|
|
4
|
-
type ToProperReturnType<T> = T extends Generator<unknown, unknown, unknown> | AsyncGenerator<unknown, unknown, unknown> ? ToAsyncGenerator<T> : ToPromise<T>;
|
|
5
|
-
type OmitNever<T> = {
|
|
6
|
-
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
7
|
-
};
|
|
8
|
-
export type WorkerPromiseInstanceWithNever<T> = {
|
|
9
|
-
[K in keyof T]: T[K] extends (...args: KnownAny[]) => KnownAny ? (...args: Parameters<T[K]>) => ToProperReturnType<ReturnType<T[K]>> : never;
|
|
10
|
-
};
|
|
11
|
-
export type WorkerPromiseInstance<T> = OmitNever<WorkerPromiseInstanceWithNever<T>> & {
|
|
12
|
-
terminate: () => void;
|
|
13
|
-
employ: (w: Worker) => WorkerPromiseInstance<T>;
|
|
14
|
-
fork: (w: Worker) => WorkerPromiseInstance<T>;
|
|
15
|
-
worker: Worker | null;
|
|
16
|
-
_isTerminated?: true;
|
|
17
|
-
[Symbol.dispose]: () => void;
|
|
18
|
-
};
|
|
19
|
-
export interface WorkerInput {
|
|
20
|
-
methodName: string;
|
|
21
|
-
args: unknown[];
|
|
22
|
-
key: number;
|
|
23
|
-
}
|
|
24
|
-
export interface WorkerOutput {
|
|
25
|
-
methodName: string;
|
|
26
|
-
result?: unknown;
|
|
27
|
-
error?: unknown;
|
|
28
|
-
done?: true;
|
|
29
|
-
key: number;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
package/worker/worker.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function worker(): (t: object) => void;
|
package/worker/worker.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.worker = worker;
|
|
4
|
-
function worker() {
|
|
5
|
-
return (t) => {
|
|
6
|
-
const target = t;
|
|
7
|
-
target._handlers = {};
|
|
8
|
-
for (const key of Object.getOwnPropertyNames(target)) {
|
|
9
|
-
const member = target[key];
|
|
10
|
-
if (typeof member === 'function') {
|
|
11
|
-
const prototype = Object.getPrototypeOf(member);
|
|
12
|
-
const isGenerator = prototype === Object.getPrototypeOf(function* () { }) ||
|
|
13
|
-
prototype === Object.getPrototypeOf(async function* () { });
|
|
14
|
-
target._handlers[key] = {};
|
|
15
|
-
if (isGenerator) {
|
|
16
|
-
target._handlers[key].isGenerator = true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (typeof self === 'undefined')
|
|
21
|
-
return; // no-op in non-worker environment
|
|
22
|
-
const w = self;
|
|
23
|
-
w.onmessage = async (evt) => {
|
|
24
|
-
const { methodName, args, key } = evt.data;
|
|
25
|
-
try {
|
|
26
|
-
const result = await target[methodName](...args);
|
|
27
|
-
if (result && typeof result === 'object' && 'next' in result && typeof result.next === 'function') {
|
|
28
|
-
const iterable = result;
|
|
29
|
-
for await (const result of iterable) {
|
|
30
|
-
w.postMessage({ result, key, methodName });
|
|
31
|
-
}
|
|
32
|
-
w.postMessage({ done: true, key, methodName });
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
w.postMessage({ result, key, methodName });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
w.postMessage({ error: e, key, methodName });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|