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/VovkApp.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.VovkApp = void 0;
|
|
8
|
-
const types_1 = require("./types");
|
|
9
|
-
const HttpException_1 = require("./HttpException");
|
|
10
|
-
const StreamJSONResponse_1 = require("./StreamJSONResponse");
|
|
11
|
-
const reqQuery_1 = __importDefault(require("./utils/reqQuery"));
|
|
12
|
-
const reqMeta_1 = __importDefault(require("./utils/reqMeta"));
|
|
13
|
-
const reqForm_1 = __importDefault(require("./utils/reqForm"));
|
|
14
|
-
class VovkApp {
|
|
15
|
-
static getHeadersFromOptions(options) {
|
|
16
|
-
if (!options)
|
|
17
|
-
return {};
|
|
18
|
-
const corsHeaders = {
|
|
19
|
-
'Access-Control-Allow-Origin': '*',
|
|
20
|
-
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
|
|
21
|
-
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
22
|
-
};
|
|
23
|
-
const headers = {
|
|
24
|
-
...(options.cors ? corsHeaders : {}),
|
|
25
|
-
...(options.headers ?? {}),
|
|
26
|
-
};
|
|
27
|
-
return headers;
|
|
28
|
-
}
|
|
29
|
-
routes = {
|
|
30
|
-
GET: new Map(),
|
|
31
|
-
POST: new Map(),
|
|
32
|
-
PUT: new Map(),
|
|
33
|
-
PATCH: new Map(),
|
|
34
|
-
DELETE: new Map(),
|
|
35
|
-
HEAD: new Map(),
|
|
36
|
-
OPTIONS: new Map(),
|
|
37
|
-
};
|
|
38
|
-
GET = async (req, data) => this.#callMethod(types_1.HttpMethod.GET, req, await data.params);
|
|
39
|
-
POST = async (req, data) => this.#callMethod(types_1.HttpMethod.POST, req, await data.params);
|
|
40
|
-
PUT = async (req, data) => this.#callMethod(types_1.HttpMethod.PUT, req, await data.params);
|
|
41
|
-
PATCH = async (req, data) => this.#callMethod(types_1.HttpMethod.PATCH, req, await data.params);
|
|
42
|
-
DELETE = async (req, data) => this.#callMethod(types_1.HttpMethod.DELETE, req, await data.params);
|
|
43
|
-
HEAD = async (req, data) => this.#callMethod(types_1.HttpMethod.HEAD, req, await data.params);
|
|
44
|
-
OPTIONS = async (req, data) => this.#callMethod(types_1.HttpMethod.OPTIONS, req, await data.params);
|
|
45
|
-
respond = (status, body, options) => {
|
|
46
|
-
return new Response(JSON.stringify(body), {
|
|
47
|
-
status,
|
|
48
|
-
headers: {
|
|
49
|
-
'Content-Type': 'application/json',
|
|
50
|
-
..._a.getHeadersFromOptions(options),
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
#respondWithError = (statusCode, message, options, cause) => {
|
|
55
|
-
return this.respond(statusCode, {
|
|
56
|
-
cause,
|
|
57
|
-
statusCode,
|
|
58
|
-
message,
|
|
59
|
-
isError: true,
|
|
60
|
-
}, options);
|
|
61
|
-
};
|
|
62
|
-
#callMethod = async (httpMethod, req, params) => {
|
|
63
|
-
const controllers = this.routes[httpMethod];
|
|
64
|
-
const methodParams = {};
|
|
65
|
-
const path = params[Object.keys(params)[0]];
|
|
66
|
-
const handlers = {};
|
|
67
|
-
controllers.forEach((staticMethods, controller) => {
|
|
68
|
-
const prefix = controller._prefix ?? '';
|
|
69
|
-
if (!controller._activated) {
|
|
70
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.INTERNAL_SERVER_ERROR, `Controller "${controller.name}" found but not activated`);
|
|
71
|
-
}
|
|
72
|
-
Object.entries(staticMethods).forEach(([path, staticMethod]) => {
|
|
73
|
-
const fullPath = [prefix, path].filter(Boolean).join('/');
|
|
74
|
-
handlers[fullPath] = { staticMethod, controller };
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
const getHandler = () => {
|
|
78
|
-
if (Object.keys(params).length === 0) {
|
|
79
|
-
return handlers[''];
|
|
80
|
-
}
|
|
81
|
-
const allMethodKeys = Object.keys(handlers);
|
|
82
|
-
let methodKeys = [];
|
|
83
|
-
methodKeys = allMethodKeys
|
|
84
|
-
// First, try to match literal routes exactly.
|
|
85
|
-
.filter((p) => {
|
|
86
|
-
if (p.includes(':'))
|
|
87
|
-
return false; // Skip parameterized paths
|
|
88
|
-
return p === path.join('/');
|
|
89
|
-
});
|
|
90
|
-
if (!methodKeys.length) {
|
|
91
|
-
methodKeys = allMethodKeys.filter((p) => {
|
|
92
|
-
const routeSegments = p.split('/');
|
|
93
|
-
if (routeSegments.length !== path.length)
|
|
94
|
-
return false;
|
|
95
|
-
for (let i = 0; i < routeSegments.length; i++) {
|
|
96
|
-
const routeSegment = routeSegments[i];
|
|
97
|
-
const pathSegment = path[i];
|
|
98
|
-
if (routeSegment.startsWith(':')) {
|
|
99
|
-
const parameter = routeSegment.slice(1);
|
|
100
|
-
if (parameter in methodParams) {
|
|
101
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.INTERNAL_SERVER_ERROR, `Duplicate parameter "${parameter}"`);
|
|
102
|
-
}
|
|
103
|
-
// If it's a parameterized segment, capture the parameter value.
|
|
104
|
-
methodParams[parameter] = pathSegment;
|
|
105
|
-
}
|
|
106
|
-
else if (routeSegment !== pathSegment) {
|
|
107
|
-
// If it's a literal segment and it does not match the corresponding path segment, return false.
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return true;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (methodKeys.length > 1) {
|
|
115
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.INTERNAL_SERVER_ERROR, `Conflicting routes found: ${methodKeys.join(', ')}`);
|
|
116
|
-
}
|
|
117
|
-
const [methodKey] = methodKeys;
|
|
118
|
-
if (methodKey) {
|
|
119
|
-
return handlers[methodKey];
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
};
|
|
123
|
-
const handler = getHandler();
|
|
124
|
-
if (!handler) {
|
|
125
|
-
return this.#respondWithError(types_1.HttpStatus.NOT_FOUND, `Route ${path.join('/')} is not found`);
|
|
126
|
-
}
|
|
127
|
-
const { staticMethod, controller } = handler;
|
|
128
|
-
req.vovk = {
|
|
129
|
-
body: () => req.json(),
|
|
130
|
-
query: () => (0, reqQuery_1.default)(req),
|
|
131
|
-
meta: (meta) => (0, reqMeta_1.default)(req, meta),
|
|
132
|
-
form: () => (0, reqForm_1.default)(req),
|
|
133
|
-
};
|
|
134
|
-
try {
|
|
135
|
-
const result = await staticMethod.call(controller, req, methodParams);
|
|
136
|
-
const isIterator = typeof result === 'object' &&
|
|
137
|
-
!!result &&
|
|
138
|
-
((Reflect.has(result, Symbol.iterator) &&
|
|
139
|
-
typeof result[Symbol.iterator] === 'function') ||
|
|
140
|
-
(Reflect.has(result, Symbol.asyncIterator) &&
|
|
141
|
-
typeof result[Symbol.asyncIterator] === 'function'));
|
|
142
|
-
if (isIterator && !(result instanceof Array)) {
|
|
143
|
-
const streamResponse = new StreamJSONResponse_1.StreamJSONResponse({
|
|
144
|
-
headers: {
|
|
145
|
-
...StreamJSONResponse_1.StreamJSONResponse.defaultHeaders,
|
|
146
|
-
..._a.getHeadersFromOptions(staticMethod._options),
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
void (async () => {
|
|
150
|
-
try {
|
|
151
|
-
for await (const chunk of result) {
|
|
152
|
-
streamResponse.send(chunk);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (e) {
|
|
156
|
-
return streamResponse.throw(e);
|
|
157
|
-
}
|
|
158
|
-
return streamResponse.close();
|
|
159
|
-
})();
|
|
160
|
-
return streamResponse;
|
|
161
|
-
}
|
|
162
|
-
if (result instanceof Response) {
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
return this.respond(200, result ?? null, staticMethod._options);
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
const err = e;
|
|
169
|
-
try {
|
|
170
|
-
await controller._onError?.(err, req);
|
|
171
|
-
}
|
|
172
|
-
catch (onErrorError) {
|
|
173
|
-
// eslint-disable-next-line no-console
|
|
174
|
-
console.error(onErrorError);
|
|
175
|
-
}
|
|
176
|
-
if (err.message !== 'NEXT_REDIRECT' && err.message !== 'NEXT_NOT_FOUND') {
|
|
177
|
-
const statusCode = err.statusCode ?? types_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
178
|
-
return this.#respondWithError(statusCode, err.message, staticMethod._options, err.cause);
|
|
179
|
-
}
|
|
180
|
-
throw e; // if NEXT_REDIRECT or NEXT_NOT_FOUND, rethrow it
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
exports.VovkApp = VovkApp;
|
|
185
|
-
_a = VovkApp;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type VovkControllerSchema, type KnownAny } from '../types';
|
|
2
|
-
import { type VovkClientOptions, type VovkClient, type VovkDefaultFetcherOptions } from './types';
|
|
3
|
-
export declare const ARRAY_QUERY_KEY = "_vovkarr";
|
|
4
|
-
export declare const clientizeController: <T, OPTS extends Record<string, KnownAny> = VovkDefaultFetcherOptions>(controllerSchema: VovkControllerSchema, segmentName?: string, options?: VovkClientOptions<OPTS>) => VovkClient<T, OPTS>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.clientizeController = exports.ARRAY_QUERY_KEY = void 0;
|
|
7
|
-
const defaultFetcher_1 = __importDefault(require("./defaultFetcher"));
|
|
8
|
-
const defaultHandler_1 = require("./defaultHandler");
|
|
9
|
-
const defaultStreamHandler_1 = require("./defaultStreamHandler");
|
|
10
|
-
// TODO Ugly workaround. Need your ideas how to distinguish between array and non-array query params
|
|
11
|
-
exports.ARRAY_QUERY_KEY = '_vovkarr';
|
|
12
|
-
const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
|
|
13
|
-
const getHandlerPath = (endpoint, params, query) => {
|
|
14
|
-
let result = endpoint;
|
|
15
|
-
for (const [key, value] of Object.entries(params ?? {})) {
|
|
16
|
-
result = result.replace(`:${key}`, value);
|
|
17
|
-
}
|
|
18
|
-
const searchParams = new URLSearchParams();
|
|
19
|
-
let hasQuery = false;
|
|
20
|
-
const arrayKeys = [];
|
|
21
|
-
for (const [key, value] of Object.entries(query ?? {})) {
|
|
22
|
-
if (typeof value === 'undefined')
|
|
23
|
-
continue;
|
|
24
|
-
if (value instanceof Array) {
|
|
25
|
-
arrayKeys.push(key);
|
|
26
|
-
for (const val of value) {
|
|
27
|
-
searchParams.append(key, val);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
searchParams.set(key, value);
|
|
32
|
-
}
|
|
33
|
-
hasQuery = true;
|
|
34
|
-
}
|
|
35
|
-
if (arrayKeys.length) {
|
|
36
|
-
searchParams.set(exports.ARRAY_QUERY_KEY, arrayKeys.join(','));
|
|
37
|
-
}
|
|
38
|
-
return `${result}${hasQuery ? '?' : ''}${searchParams.toString()}`;
|
|
39
|
-
};
|
|
40
|
-
const clientizeController = (controllerSchema, segmentName, options) => {
|
|
41
|
-
const schema = controllerSchema;
|
|
42
|
-
const client = {};
|
|
43
|
-
if (!schema)
|
|
44
|
-
throw new Error(`Unable to clientize. Controller schema is not provided`);
|
|
45
|
-
if (!schema.handlers)
|
|
46
|
-
throw new Error(`Unable to clientize. No schema for controller ${String(schema?.controllerName)} provided`);
|
|
47
|
-
const controllerPrefix = trimPath(schema.prefix ?? '');
|
|
48
|
-
const { fetcher: settingsFetcher = defaultFetcher_1.default } = options ?? {};
|
|
49
|
-
for (const [staticMethodName, { path, httpMethod, validation }] of Object.entries(schema.handlers)) {
|
|
50
|
-
const getEndpoint = ({ apiRoot, params, query, }) => {
|
|
51
|
-
const mainPrefix = (apiRoot.startsWith('http://') || apiRoot.startsWith('https://') || apiRoot.startsWith('/') ? '' : '/') +
|
|
52
|
-
(apiRoot.endsWith('/') ? apiRoot : `${apiRoot}/`) +
|
|
53
|
-
(segmentName ? `${segmentName}/` : '');
|
|
54
|
-
return mainPrefix + getHandlerPath([controllerPrefix, path].filter(Boolean).join('/'), params, query);
|
|
55
|
-
};
|
|
56
|
-
const handler = (input = {}) => {
|
|
57
|
-
const fetcher = input.fetcher ?? settingsFetcher;
|
|
58
|
-
const validate = async ({ body, query, endpoint }) => {
|
|
59
|
-
await (input.validateOnClient ?? options?.validateOnClient)?.({ body, query, endpoint }, validation ?? {});
|
|
60
|
-
};
|
|
61
|
-
const internalOptions = {
|
|
62
|
-
name: staticMethodName,
|
|
63
|
-
httpMethod,
|
|
64
|
-
getEndpoint,
|
|
65
|
-
validate,
|
|
66
|
-
defaultHandler: defaultHandler_1.defaultHandler,
|
|
67
|
-
defaultStreamHandler: defaultStreamHandler_1.defaultStreamHandler,
|
|
68
|
-
};
|
|
69
|
-
const internalInput = {
|
|
70
|
-
...options?.defaultOptions,
|
|
71
|
-
...input,
|
|
72
|
-
body: input.body ?? null,
|
|
73
|
-
query: input.query ?? {},
|
|
74
|
-
params: input.params ?? {},
|
|
75
|
-
// TS workaround
|
|
76
|
-
fetcher: undefined,
|
|
77
|
-
validateOnClient: undefined,
|
|
78
|
-
};
|
|
79
|
-
delete internalInput.fetcher;
|
|
80
|
-
delete internalInput.validateOnClient;
|
|
81
|
-
if (!fetcher)
|
|
82
|
-
throw new Error('Fetcher is not provided');
|
|
83
|
-
const fetcherPromise = fetcher(internalOptions, internalInput);
|
|
84
|
-
if (!(fetcherPromise instanceof Promise))
|
|
85
|
-
return Promise.resolve(fetcherPromise);
|
|
86
|
-
return input.transform ? fetcherPromise.then(input.transform) : fetcherPromise;
|
|
87
|
-
};
|
|
88
|
-
// @ts-expect-error TODO
|
|
89
|
-
client[staticMethodName] = handler;
|
|
90
|
-
}
|
|
91
|
-
return client;
|
|
92
|
-
};
|
|
93
|
-
exports.clientizeController = clientizeController;
|
package/client/defaultFetcher.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const HttpException_1 = require("../HttpException");
|
|
6
|
-
exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at the defaultFetcher';
|
|
7
|
-
// defaultFetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
|
|
8
|
-
// For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
|
|
9
|
-
const defaultFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, { params, query, body, apiRoot = '/api', ...options }) => {
|
|
10
|
-
const endpoint = getEndpoint({ apiRoot, params, query });
|
|
11
|
-
if (!options.disableClientValidation) {
|
|
12
|
-
try {
|
|
13
|
-
await validate({ body, query, endpoint });
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
// if HttpException is thrown, rethrow it
|
|
17
|
-
if (e instanceof HttpException_1.HttpException)
|
|
18
|
-
throw e;
|
|
19
|
-
// otherwise, throw HttpException with status 0
|
|
20
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const init = {
|
|
24
|
-
method: httpMethod,
|
|
25
|
-
...options,
|
|
26
|
-
};
|
|
27
|
-
if (body instanceof FormData) {
|
|
28
|
-
init.body = body;
|
|
29
|
-
}
|
|
30
|
-
else if (body) {
|
|
31
|
-
init.body = JSON.stringify(body);
|
|
32
|
-
}
|
|
33
|
-
let response;
|
|
34
|
-
try {
|
|
35
|
-
response = await fetch(endpoint, init);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
// handle network errors
|
|
39
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e?.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
40
|
-
}
|
|
41
|
-
if (response.headers.get('content-type')?.includes('application/json')) {
|
|
42
|
-
return defaultHandler(response);
|
|
43
|
-
}
|
|
44
|
-
if (response.headers.get('x-vovk-stream') === 'true') {
|
|
45
|
-
return defaultStreamHandler(response);
|
|
46
|
-
}
|
|
47
|
-
return response;
|
|
48
|
-
};
|
|
49
|
-
exports.default = defaultFetcher;
|
package/client/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { clientizeController } from './clientizeController';
|
|
2
|
-
import type { VovkClientFetcher, VovkClientOptions, VovkDefaultFetcherOptions } from './types';
|
|
3
|
-
export { clientizeController };
|
|
4
|
-
export type { VovkClientFetcher, VovkClientOptions, VovkDefaultFetcherOptions };
|
package/client/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clientizeController = void 0;
|
|
4
|
-
const clientizeController_1 = require("./clientizeController");
|
|
5
|
-
Object.defineProperty(exports, "clientizeController", { enumerable: true, get: function () { return clientizeController_1.clientizeController; } });
|
package/client/types.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type { KnownAny, HttpMethod, ControllerStaticMethod, VovkControllerBody, VovkControllerQuery, VovkControllerParams } from '../types';
|
|
2
|
-
import type { StreamJSONResponse } from '../StreamJSONResponse';
|
|
3
|
-
import type { NextResponse } from 'next/server';
|
|
4
|
-
export type StaticMethodInput<T extends ControllerStaticMethod> = (VovkControllerBody<T> extends undefined | void ? {
|
|
5
|
-
body?: undefined;
|
|
6
|
-
} : VovkControllerBody<T> extends null ? {
|
|
7
|
-
body?: null;
|
|
8
|
-
} : {
|
|
9
|
-
body: VovkControllerBody<T>;
|
|
10
|
-
}) & (VovkControllerQuery<T> extends undefined | void ? {
|
|
11
|
-
query?: undefined;
|
|
12
|
-
} : {
|
|
13
|
-
query: VovkControllerQuery<T>;
|
|
14
|
-
}) & (VovkControllerParams<T> extends undefined | void ? {
|
|
15
|
-
params?: undefined;
|
|
16
|
-
} : {
|
|
17
|
-
params: VovkControllerParams<T>;
|
|
18
|
-
});
|
|
19
|
-
type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
|
|
20
|
-
export type StreamAsyncIterator<T> = {
|
|
21
|
-
status: number;
|
|
22
|
-
[Symbol.dispose](): Promise<void> | void;
|
|
23
|
-
[Symbol.asyncDispose](): Promise<void> | void;
|
|
24
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
25
|
-
cancel: () => Promise<void> | void;
|
|
26
|
-
};
|
|
27
|
-
type StaticMethodReturn<T extends ControllerStaticMethod> = ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>> ? U : ReturnType<T> extends Response | Promise<Response> ? Awaited<ReturnType<T>> : ReturnType<T>;
|
|
28
|
-
type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
29
|
-
type ClientMethod<T extends (...args: KnownAny[]) => void | object | StreamJSONResponse<STREAM> | Promise<StreamJSONResponse<STREAM>>, OPTS extends Record<string, KnownAny>, STREAM extends KnownAny = unknown> = <R>(options: (StaticMethodInput<T> extends {
|
|
30
|
-
body?: undefined | null;
|
|
31
|
-
query?: undefined;
|
|
32
|
-
params?: undefined;
|
|
33
|
-
} ? unknown : Parameters<T>[0] extends void ? StaticMethodInput<T>['params'] extends object ? {
|
|
34
|
-
params: StaticMethodInput<T>['params'];
|
|
35
|
-
} : unknown : StaticMethodInput<T>) & (Partial<OPTS & {
|
|
36
|
-
transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>) => R;
|
|
37
|
-
}>)) => ReturnType<T> extends Promise<StreamJSONResponse<infer U>> | StreamJSONResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<StreamAsyncIterator<U>> : R extends object ? Promise<R> : StaticMethodReturnPromise<T>;
|
|
38
|
-
type OmitNever<T> = {
|
|
39
|
-
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
40
|
-
};
|
|
41
|
-
type VovkClientWithNever<T, OPTS extends {
|
|
42
|
-
[key: string]: KnownAny;
|
|
43
|
-
}> = {
|
|
44
|
-
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], OPTS> : never;
|
|
45
|
-
};
|
|
46
|
-
export type VovkClient<T, OPTS extends {
|
|
47
|
-
[key: string]: KnownAny;
|
|
48
|
-
}> = OmitNever<VovkClientWithNever<T, OPTS>>;
|
|
49
|
-
export type VovkClientFetcher<OPTS extends Record<string, KnownAny> = Record<string, never>, T = KnownAny> = (options: {
|
|
50
|
-
name: keyof T;
|
|
51
|
-
httpMethod: HttpMethod;
|
|
52
|
-
getEndpoint: (data: {
|
|
53
|
-
apiRoot: string;
|
|
54
|
-
params: {
|
|
55
|
-
[key: string]: string;
|
|
56
|
-
};
|
|
57
|
-
query: {
|
|
58
|
-
[key: string]: string;
|
|
59
|
-
};
|
|
60
|
-
}) => string;
|
|
61
|
-
validate: (input: {
|
|
62
|
-
body?: unknown;
|
|
63
|
-
query?: unknown;
|
|
64
|
-
endpoint: string;
|
|
65
|
-
}) => void | Promise<void>;
|
|
66
|
-
defaultStreamHandler: (response: Response) => Promise<StreamAsyncIterator<unknown>>;
|
|
67
|
-
defaultHandler: (response: Response) => Promise<unknown>;
|
|
68
|
-
}, input: {
|
|
69
|
-
body: unknown;
|
|
70
|
-
query: {
|
|
71
|
-
[key: string]: string;
|
|
72
|
-
};
|
|
73
|
-
params: {
|
|
74
|
-
[key: string]: string;
|
|
75
|
-
};
|
|
76
|
-
} & OPTS) => KnownAny;
|
|
77
|
-
export interface VovkDefaultFetcherOptions extends Omit<RequestInit, 'body' | 'method'> {
|
|
78
|
-
reactNative?: {
|
|
79
|
-
textStreaming: boolean;
|
|
80
|
-
};
|
|
81
|
-
apiRoot?: string;
|
|
82
|
-
segmentName?: string;
|
|
83
|
-
disableClientValidation?: boolean;
|
|
84
|
-
validateOnClient?: VovkValidateOnClient;
|
|
85
|
-
fetcher?: VovkClientFetcher;
|
|
86
|
-
}
|
|
87
|
-
export type VovkValidateOnClient = (input: {
|
|
88
|
-
body?: unknown;
|
|
89
|
-
query?: unknown;
|
|
90
|
-
endpoint: string;
|
|
91
|
-
}, validators: {
|
|
92
|
-
body?: unknown;
|
|
93
|
-
query?: unknown;
|
|
94
|
-
}) => void | Promise<void>;
|
|
95
|
-
export type VovkClientOptions<OPTS extends Record<string, KnownAny> = Record<string, never>> = {
|
|
96
|
-
fetcher?: VovkClientFetcher<OPTS>;
|
|
97
|
-
validateOnClient?: VovkValidateOnClient;
|
|
98
|
-
defaultOptions?: Partial<OPTS>;
|
|
99
|
-
};
|
|
100
|
-
export {};
|
package/createDecorator.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HandlerSchema, KnownAny, VovkController, VovkRequest } from './types';
|
|
2
|
-
type Next = () => Promise<unknown>;
|
|
3
|
-
export declare function createDecorator<ARGS extends unknown[], REQUEST = VovkRequest>(handler: null | ((this: VovkController, req: REQUEST, next: Next, ...args: ARGS) => unknown), initHandler?: (this: VovkController, ...args: ARGS) => Omit<HandlerSchema, 'path' | 'httpMethod'> | ((handlerSchema: HandlerSchema | null) => Omit<HandlerSchema, 'path' | 'httpMethod'>) | null | undefined): (...args: ARGS) => (target: KnownAny, propertyKey: string) => void;
|
|
4
|
-
export {};
|
package/createVovkApp.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createVovkApp = createVovkApp;
|
|
7
|
-
const VovkApp_1 = require("./VovkApp");
|
|
8
|
-
const types_1 = require("./types");
|
|
9
|
-
const getSchema_1 = __importDefault(require("./utils/getSchema"));
|
|
10
|
-
const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
|
|
11
|
-
const isClass = (func) => typeof func === 'function' && /class/.test(func.toString());
|
|
12
|
-
const toKebabCase = (str) => str
|
|
13
|
-
.replace(/([A-Z])/g, '-$1')
|
|
14
|
-
.toLowerCase()
|
|
15
|
-
.replace(/^-/, '');
|
|
16
|
-
function createVovkApp() {
|
|
17
|
-
const vovkApp = new VovkApp_1.VovkApp();
|
|
18
|
-
const createHTTPDecorator = (httpMethod) => {
|
|
19
|
-
const assignSchema = (controller, propertyKey, path, options) => {
|
|
20
|
-
if (typeof window !== 'undefined') {
|
|
21
|
-
throw new Error('Decorators are intended for server-side use only. You have probably imported a controller on the client-side.');
|
|
22
|
-
}
|
|
23
|
-
if (!isClass(controller)) {
|
|
24
|
-
let decoratorName = httpMethod.toLowerCase();
|
|
25
|
-
if (decoratorName === 'delete')
|
|
26
|
-
decoratorName = 'del';
|
|
27
|
-
throw new Error(`Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}.`);
|
|
28
|
-
}
|
|
29
|
-
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
30
|
-
vovkApp.routes[httpMethod].set(controller, methods);
|
|
31
|
-
controller._handlers = {
|
|
32
|
-
...controller._handlers,
|
|
33
|
-
[propertyKey]: {
|
|
34
|
-
...(controller._handlers ?? {})[propertyKey],
|
|
35
|
-
path,
|
|
36
|
-
httpMethod,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const originalMethod = controller[propertyKey];
|
|
40
|
-
originalMethod._controller = controller;
|
|
41
|
-
originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
|
|
42
|
-
methods[path] = controller[propertyKey];
|
|
43
|
-
methods[path]._options = options;
|
|
44
|
-
};
|
|
45
|
-
function decoratorCreator(givenPath = '', options) {
|
|
46
|
-
const path = trimPath(givenPath);
|
|
47
|
-
function decorator(givenTarget, propertyKey) {
|
|
48
|
-
const target = givenTarget;
|
|
49
|
-
assignSchema(target, propertyKey, path, options);
|
|
50
|
-
}
|
|
51
|
-
return decorator;
|
|
52
|
-
}
|
|
53
|
-
const auto = (options) => {
|
|
54
|
-
function decorator(givenTarget, propertyKey) {
|
|
55
|
-
const controller = givenTarget;
|
|
56
|
-
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
57
|
-
vovkApp.routes[httpMethod].set(controller, methods);
|
|
58
|
-
controller._handlers = {
|
|
59
|
-
...controller._handlers,
|
|
60
|
-
[propertyKey]: {
|
|
61
|
-
...(controller._handlers ?? {})[propertyKey],
|
|
62
|
-
httpMethod,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
assignSchema(controller, propertyKey, toKebabCase(propertyKey), options);
|
|
66
|
-
}
|
|
67
|
-
return decorator;
|
|
68
|
-
};
|
|
69
|
-
const enhancedDecoratorCreator = decoratorCreator;
|
|
70
|
-
enhancedDecoratorCreator.auto = auto;
|
|
71
|
-
return enhancedDecoratorCreator;
|
|
72
|
-
};
|
|
73
|
-
const prefix = (givenPath = '') => {
|
|
74
|
-
const path = trimPath(givenPath);
|
|
75
|
-
return (givenTarget) => {
|
|
76
|
-
const controller = givenTarget;
|
|
77
|
-
controller._prefix = path;
|
|
78
|
-
return givenTarget;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
const initVovk = (options) => {
|
|
82
|
-
for (const [controllerName, controller] of Object.entries(options.controllers)) {
|
|
83
|
-
controller._controllerName = controllerName;
|
|
84
|
-
controller._activated = true;
|
|
85
|
-
controller._onError = options?.onError;
|
|
86
|
-
}
|
|
87
|
-
async function GET_DEV(req, data) {
|
|
88
|
-
const params = await data.params;
|
|
89
|
-
if (params[Object.keys(params)[0]]?.[0] === '_schema_') {
|
|
90
|
-
// Wait for schema to be set (it can be set after decorators are called with another setTimeout)
|
|
91
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
92
|
-
const schema = (0, getSchema_1.default)(options);
|
|
93
|
-
return vovkApp.respond(200, { schema });
|
|
94
|
-
}
|
|
95
|
-
return vovkApp.GET(req, data);
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
GET: process.env.NODE_ENV === 'development' ? GET_DEV : vovkApp.GET,
|
|
99
|
-
POST: vovkApp.POST,
|
|
100
|
-
PUT: vovkApp.PUT,
|
|
101
|
-
PATCH: vovkApp.PATCH,
|
|
102
|
-
DELETE: vovkApp.DELETE,
|
|
103
|
-
HEAD: vovkApp.HEAD,
|
|
104
|
-
OPTIONS: vovkApp.OPTIONS,
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
return {
|
|
108
|
-
get: createHTTPDecorator(types_1.HttpMethod.GET),
|
|
109
|
-
post: createHTTPDecorator(types_1.HttpMethod.POST),
|
|
110
|
-
put: createHTTPDecorator(types_1.HttpMethod.PUT),
|
|
111
|
-
patch: createHTTPDecorator(types_1.HttpMethod.PATCH),
|
|
112
|
-
del: createHTTPDecorator(types_1.HttpMethod.DELETE),
|
|
113
|
-
head: createHTTPDecorator(types_1.HttpMethod.HEAD),
|
|
114
|
-
options: createHTTPDecorator(types_1.HttpMethod.OPTIONS),
|
|
115
|
-
prefix,
|
|
116
|
-
initVovk,
|
|
117
|
-
};
|
|
118
|
-
}
|
package/index.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createVovkApp } from './createVovkApp';
|
|
2
|
-
import { HttpStatus as HttpStatus, HttpMethod as HttpMethod, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkSchema } from './types';
|
|
3
|
-
import type { VovkClientOptions as VovkClientOptions, VovkClientFetcher as VovkClientFetcher, VovkDefaultFetcherOptions as VovkDefaultFetcherOptions, VovkValidateOnClient as VovkValidateOnClient } from './client/types';
|
|
4
|
-
import { HttpException } from './HttpException';
|
|
5
|
-
import { createDecorator } from './createDecorator';
|
|
6
|
-
import { StreamJSONResponse } from './StreamJSONResponse';
|
|
7
|
-
import { worker } from './worker';
|
|
8
|
-
import { generateStaticAPI } from './utils/generateStaticAPI';
|
|
9
|
-
export { type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkSchema, type VovkErrorResponse, type VovkRequest, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkClientOptions, StreamJSONResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, worker, generateStaticAPI, };
|
|
10
|
-
export declare const get: {
|
|
11
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
12
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
13
|
-
}, post: {
|
|
14
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
15
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
16
|
-
}, put: {
|
|
17
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
18
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
19
|
-
}, patch: {
|
|
20
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
21
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
22
|
-
}, del: {
|
|
23
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
24
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
25
|
-
}, head: {
|
|
26
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
27
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
28
|
-
}, options: {
|
|
29
|
-
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void>;
|
|
30
|
-
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: import("./types").KnownAny, propertyKey: string) => void;
|
|
31
|
-
}, prefix: (givenPath?: string) => (givenTarget: import("./types").KnownAny) => any, initVovk: (options: {
|
|
32
|
-
segmentName?: string;
|
|
33
|
-
controllers: Record<string, import("./types").StaticClass>;
|
|
34
|
-
workers?: Record<string, import("./types").StaticClass>;
|
|
35
|
-
exposeValidation?: boolean;
|
|
36
|
-
emitSchema?: boolean;
|
|
37
|
-
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
38
|
-
}) => {
|
|
39
|
-
GET: (req: VovkRequest, data: {
|
|
40
|
-
params: Promise<Record<string, string[]>>;
|
|
41
|
-
}) => Promise<Response>;
|
|
42
|
-
POST: (req: VovkRequest, data: {
|
|
43
|
-
params: Promise<Record<string, string[]>>;
|
|
44
|
-
}) => Promise<Response>;
|
|
45
|
-
PUT: (req: VovkRequest, data: {
|
|
46
|
-
params: Promise<Record<string, string[]>>;
|
|
47
|
-
}) => Promise<Response>;
|
|
48
|
-
PATCH: (req: VovkRequest, data: {
|
|
49
|
-
params: Promise<Record<string, string[]>>;
|
|
50
|
-
}) => Promise<Response>;
|
|
51
|
-
DELETE: (req: VovkRequest, data: {
|
|
52
|
-
params: Promise<Record<string, string[]>>;
|
|
53
|
-
}) => Promise<Response>;
|
|
54
|
-
HEAD: (req: VovkRequest, data: {
|
|
55
|
-
params: Promise<Record<string, string[]>>;
|
|
56
|
-
}) => Promise<Response>;
|
|
57
|
-
OPTIONS: (req: VovkRequest, data: {
|
|
58
|
-
params: Promise<Record<string, string[]>>;
|
|
59
|
-
}) => Promise<Response>;
|
|
60
|
-
};
|