vovk 3.0.0-draft.46 → 3.0.0-draft.460
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 +82 -0
- package/cjs/utils/createStandardValidation.js +34 -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 +77 -0
- package/cjs/utils/withValidationLibrary.js +124 -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 +82 -0
- package/mjs/utils/createStandardValidation.js +34 -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 +77 -0
- package/mjs/utils/withValidationLibrary.js +124 -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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetcher = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
4
|
+
exports.createFetcher = createFetcher;
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const HttpException_1 = require("../HttpException");
|
|
7
|
+
exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at default fetcher';
|
|
8
|
+
function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onError, } = {}) {
|
|
9
|
+
// fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
|
|
10
|
+
// For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
|
|
11
|
+
const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler, schema }, inputOptions) => {
|
|
12
|
+
let response = null;
|
|
13
|
+
let respData = null;
|
|
14
|
+
let requestInit = null;
|
|
15
|
+
try {
|
|
16
|
+
const { meta, apiRoot, disableClientValidation, init, interpretAs } = inputOptions;
|
|
17
|
+
let { body, query, params } = inputOptions;
|
|
18
|
+
const endpoint = getEndpoint({ apiRoot, params, query });
|
|
19
|
+
const unusedParams = Array.from(new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
|
|
20
|
+
if (unusedParams.length) {
|
|
21
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(', ')} in ${endpoint}`, {
|
|
22
|
+
body,
|
|
23
|
+
query,
|
|
24
|
+
params,
|
|
25
|
+
endpoint,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (!disableClientValidation) {
|
|
29
|
+
try {
|
|
30
|
+
({ body, query, params } = (await validate(inputOptions, { endpoint })) ?? { body, query, params });
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
// if HttpException is thrown, rethrow it
|
|
34
|
+
if (e instanceof HttpException_1.HttpException)
|
|
35
|
+
throw e;
|
|
36
|
+
// otherwise, throw HttpException with status 0
|
|
37
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE, {
|
|
38
|
+
body,
|
|
39
|
+
query,
|
|
40
|
+
params,
|
|
41
|
+
endpoint,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
requestInit = {
|
|
46
|
+
method: httpMethod,
|
|
47
|
+
...init,
|
|
48
|
+
headers: {
|
|
49
|
+
accept: 'application/jsonl, application/json',
|
|
50
|
+
...(body instanceof FormData ? {} : { 'content-type': 'application/json' }),
|
|
51
|
+
...(meta ? { 'x-meta': JSON.stringify(meta) } : {}),
|
|
52
|
+
...init?.headers,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
if (body instanceof FormData) {
|
|
56
|
+
requestInit.body = body;
|
|
57
|
+
}
|
|
58
|
+
else if (body) {
|
|
59
|
+
requestInit.body = JSON.stringify(body);
|
|
60
|
+
}
|
|
61
|
+
const abortController = new AbortController();
|
|
62
|
+
requestInit.signal = abortController.signal;
|
|
63
|
+
requestInit = prepareRequestInit ? await prepareRequestInit(requestInit, inputOptions) : requestInit;
|
|
64
|
+
try {
|
|
65
|
+
response = await fetch(endpoint, requestInit);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// handle network errors
|
|
69
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, (e?.message ?? exports.DEFAULT_ERROR_MESSAGE) + ' ' + endpoint, {
|
|
70
|
+
body,
|
|
71
|
+
query,
|
|
72
|
+
params,
|
|
73
|
+
endpoint,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const contentType = interpretAs ?? response.headers.get('content-type');
|
|
77
|
+
if (contentType?.startsWith('application/jsonl')) {
|
|
78
|
+
respData = defaultStreamHandler({ response, abortController, schema });
|
|
79
|
+
}
|
|
80
|
+
else if (contentType?.startsWith('application/json')) {
|
|
81
|
+
respData = await defaultHandler({ response, schema });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
respData = response;
|
|
85
|
+
}
|
|
86
|
+
respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
|
|
87
|
+
await onSuccess?.(respData, inputOptions, response, requestInit);
|
|
88
|
+
return [respData, response];
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
await onError?.(error, inputOptions, response, requestInit, respData);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return newFetcher;
|
|
96
|
+
}
|
|
97
|
+
exports.fetcher = createFetcher();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.progressive = exports.createFetcher = exports.fetcher = exports.createRPC = void 0;
|
|
4
|
+
var createRPC_1 = require("./createRPC");
|
|
5
|
+
Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return createRPC_1.createRPC; } });
|
|
6
|
+
var fetcher_1 = require("./fetcher");
|
|
7
|
+
Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return fetcher_1.fetcher; } });
|
|
8
|
+
Object.defineProperty(exports, "createFetcher", { enumerable: true, get: function () { return fetcher_1.createFetcher; } });
|
|
9
|
+
var progressive_1 = require("./progressive");
|
|
10
|
+
Object.defineProperty(exports, "progressive", { enumerable: true, get: function () { return progressive_1.progressive; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VovkStreamAsyncIterable } from './types';
|
|
2
|
+
import type { KnownAny, VovkYieldType } from '../types';
|
|
3
|
+
type UnionToIntersection<U> = (U extends KnownAny ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
4
|
+
type PromisifyProperties<T> = {
|
|
5
|
+
[K in keyof T]: Promise<T[K]>;
|
|
6
|
+
};
|
|
7
|
+
type TransformUnionToPromises<T> = PromisifyProperties<UnionToIntersection<T>>;
|
|
8
|
+
export declare function progressive<T extends (...args: KnownAny[]) => Promise<VovkStreamAsyncIterable<KnownAny>>>(fn: T, ...args: undefined extends Parameters<T>[0] ? [arg?: Parameters<T>[0]] : [arg: Parameters<T>[0]]): TransformUnionToPromises<VovkYieldType<T>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.progressive = progressive;
|
|
4
|
+
function progressive(fn, ...args) {
|
|
5
|
+
const [arg] = args;
|
|
6
|
+
const reg = {};
|
|
7
|
+
void fn(arg)
|
|
8
|
+
.then(async (result) => {
|
|
9
|
+
for await (const item of result) {
|
|
10
|
+
for (const [key, value] of Object.entries(item)) {
|
|
11
|
+
if (key in reg) {
|
|
12
|
+
if (!reg[key].isSettled) {
|
|
13
|
+
reg[key].isSettled = true;
|
|
14
|
+
reg[key].resolve(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
19
|
+
reg[key] = { resolve, reject, promise, isSettled: true };
|
|
20
|
+
reg[key].resolve(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
Object.keys(reg).forEach((key) => {
|
|
25
|
+
if (reg[key].isSettled)
|
|
26
|
+
return;
|
|
27
|
+
reg[key].isSettled = true;
|
|
28
|
+
reg[key].reject(new Error(`The connection was closed without sending a value for "${key}"`));
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
})
|
|
32
|
+
.catch((error) => {
|
|
33
|
+
Object.keys(reg).forEach((key) => {
|
|
34
|
+
if (reg[key].isSettled)
|
|
35
|
+
return;
|
|
36
|
+
reg[key].isSettled = true;
|
|
37
|
+
reg[key].reject(error);
|
|
38
|
+
});
|
|
39
|
+
return error;
|
|
40
|
+
});
|
|
41
|
+
return new Proxy({}, {
|
|
42
|
+
get(_target, prop) {
|
|
43
|
+
if (prop in reg) {
|
|
44
|
+
return reg[prop].promise;
|
|
45
|
+
}
|
|
46
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
47
|
+
reg[prop] = { resolve, reject, promise, isSettled: false };
|
|
48
|
+
return promise;
|
|
49
|
+
},
|
|
50
|
+
ownKeys: () => {
|
|
51
|
+
throw new Error('Getting own keys is not possible as they are dynamically created');
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { NextResponse } from 'next/server';
|
|
2
|
+
import type { KnownAny, HttpMethod, ControllerStaticMethod, VovkHandlerSchema, VovkControllerSchema, VovkSegmentSchema, VovkSchema, VovkRequest, Prettify, IsEmptyObject } from '../types';
|
|
3
|
+
import type { JSONLinesResponse } from '../JSONLinesResponse';
|
|
4
|
+
import type { defaultStreamHandler } from './defaultStreamHandler';
|
|
5
|
+
import type { defaultHandler } from './defaultHandler';
|
|
6
|
+
type OmitNullable<T> = {
|
|
7
|
+
[K in keyof T as T[K] extends null | undefined ? never : K]: T[K];
|
|
8
|
+
};
|
|
9
|
+
type Empty = {};
|
|
10
|
+
export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => KnownAny) & {
|
|
11
|
+
__types?: {
|
|
12
|
+
isForm: boolean;
|
|
13
|
+
};
|
|
14
|
+
}> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer TBody, infer TQuery, infer TParams> ? (TBody extends Record<KnownAny, KnownAny> ? {
|
|
15
|
+
body: T['__types'] extends {
|
|
16
|
+
isForm: true;
|
|
17
|
+
} ? FormData : TBody;
|
|
18
|
+
} : Empty) & (TQuery extends Record<KnownAny, KnownAny> ? {
|
|
19
|
+
query: TQuery;
|
|
20
|
+
} : Empty) & (TParams extends Record<KnownAny, KnownAny> ? {
|
|
21
|
+
params: TParams;
|
|
22
|
+
} : Empty) & {
|
|
23
|
+
meta?: {
|
|
24
|
+
[key: string]: KnownAny;
|
|
25
|
+
};
|
|
26
|
+
} : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
|
|
27
|
+
params: Parameters<T>[1];
|
|
28
|
+
} : Empty)>;
|
|
29
|
+
type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
|
|
30
|
+
export type VovkStreamAsyncIterable<T> = {
|
|
31
|
+
status: number;
|
|
32
|
+
asPromise: () => Promise<T[]>;
|
|
33
|
+
[Symbol.dispose](): Promise<void> | void;
|
|
34
|
+
[Symbol.asyncDispose](): Promise<void> | void;
|
|
35
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
36
|
+
onIterate: (cb: (data: T, i: number) => void) => () => void;
|
|
37
|
+
abortController: AbortController;
|
|
38
|
+
};
|
|
39
|
+
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>;
|
|
40
|
+
type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
41
|
+
type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration, R, F extends VovkFetcherOptions<KnownAny>> = Partial<TFetcherOptions & {
|
|
42
|
+
transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>, resp: Response) => R;
|
|
43
|
+
fetcher: VovkFetcher<F>;
|
|
44
|
+
}>;
|
|
45
|
+
export type ClientMethodReturn<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TStreamIteration, R> = ReturnType<T> extends Promise<JSONLinesResponse<infer U>> | JSONLinesResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<VovkStreamAsyncIterable<U>> : R extends object ? Promise<Awaited<R>> : StaticMethodReturnPromise<T>;
|
|
46
|
+
export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>) & {
|
|
47
|
+
__types?: {
|
|
48
|
+
body: KnownAny;
|
|
49
|
+
query: KnownAny;
|
|
50
|
+
params: KnownAny;
|
|
51
|
+
output: KnownAny;
|
|
52
|
+
iteration: KnownAny;
|
|
53
|
+
isForm: boolean;
|
|
54
|
+
};
|
|
55
|
+
}, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options?: Prettify<StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R> : <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R>) & {
|
|
56
|
+
isRPC: true;
|
|
57
|
+
schema: VovkHandlerSchema;
|
|
58
|
+
controllerSchema: VovkControllerSchema;
|
|
59
|
+
segmentSchema: VovkSegmentSchema;
|
|
60
|
+
fullSchema: VovkSchema;
|
|
61
|
+
path: string;
|
|
62
|
+
apiRoot: string;
|
|
63
|
+
queryKey: (key?: unknown[]) => unknown[];
|
|
64
|
+
__types: T['__types'];
|
|
65
|
+
};
|
|
66
|
+
type OmitNever<T> = {
|
|
67
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
68
|
+
};
|
|
69
|
+
type VovkClientWithNever<T, TFetcherOptions extends {
|
|
70
|
+
[key: string]: KnownAny;
|
|
71
|
+
}> = {
|
|
72
|
+
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], TFetcherOptions> : never;
|
|
73
|
+
};
|
|
74
|
+
export type VovkRPCModule<T, TFetcherOptions extends {
|
|
75
|
+
[key: string]: KnownAny;
|
|
76
|
+
}> = OmitNever<VovkClientWithNever<T, TFetcherOptions>>;
|
|
77
|
+
export type VovkFetcher<TFetcherOptions> = (options: {
|
|
78
|
+
name: string;
|
|
79
|
+
httpMethod: HttpMethod;
|
|
80
|
+
getEndpoint: (data: {
|
|
81
|
+
apiRoot: string | undefined;
|
|
82
|
+
params: unknown;
|
|
83
|
+
query: unknown;
|
|
84
|
+
}) => string;
|
|
85
|
+
validate: (inputOptions: {
|
|
86
|
+
body?: unknown;
|
|
87
|
+
query?: unknown;
|
|
88
|
+
params?: unknown;
|
|
89
|
+
meta?: unknown;
|
|
90
|
+
} & TFetcherOptions, meta: {
|
|
91
|
+
endpoint: string;
|
|
92
|
+
}) => KnownAny | Promise<KnownAny>;
|
|
93
|
+
defaultStreamHandler: typeof defaultStreamHandler;
|
|
94
|
+
defaultHandler: typeof defaultHandler;
|
|
95
|
+
schema: VovkHandlerSchema;
|
|
96
|
+
}, input: {
|
|
97
|
+
body?: unknown;
|
|
98
|
+
query?: unknown;
|
|
99
|
+
params?: unknown;
|
|
100
|
+
meta?: unknown;
|
|
101
|
+
} & TFetcherOptions) => Promise<[KnownAny, Response]>;
|
|
102
|
+
export type VovkFetcherOptions<T> = T & {
|
|
103
|
+
apiRoot?: string;
|
|
104
|
+
disableClientValidation?: boolean;
|
|
105
|
+
validateOnClient?: VovkValidateOnClient<T> | Promise<{
|
|
106
|
+
validateOnClient: VovkValidateOnClient<T>;
|
|
107
|
+
}>;
|
|
108
|
+
interpretAs?: string;
|
|
109
|
+
init?: RequestInit;
|
|
110
|
+
};
|
|
111
|
+
export type VovkValidateOnClient<TFetcherOptions> = (input: {
|
|
112
|
+
body?: unknown;
|
|
113
|
+
query?: unknown;
|
|
114
|
+
params?: unknown;
|
|
115
|
+
meta?: unknown;
|
|
116
|
+
} & TFetcherOptions, validation: Omit<Exclude<VovkHandlerSchema['validation'], undefined>, 'output' | 'iteration'>, meta: {
|
|
117
|
+
fullSchema: VovkSchema;
|
|
118
|
+
endpoint: string;
|
|
119
|
+
}) => KnownAny | Promise<KnownAny>;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
import { type KnownAny, type DecoratorOptions, type VovkRequest, type StaticClass } from './types';
|
|
3
|
+
export declare function createVovkApp(): {
|
|
4
|
+
get: {
|
|
5
|
+
(givenPath?: string | undefined, options?: DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
6
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
7
|
+
};
|
|
8
|
+
post: {
|
|
9
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
10
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
11
|
+
};
|
|
12
|
+
put: {
|
|
13
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
14
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
15
|
+
};
|
|
16
|
+
patch: {
|
|
17
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
18
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
19
|
+
};
|
|
20
|
+
del: {
|
|
21
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
22
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
23
|
+
};
|
|
24
|
+
head: {
|
|
25
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
26
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
27
|
+
};
|
|
28
|
+
options: {
|
|
29
|
+
(givenPath?: string | undefined, options?: Omit<DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
30
|
+
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
31
|
+
};
|
|
32
|
+
prefix: (givenPath?: string) => (givenTarget: KnownAny) => any;
|
|
33
|
+
initSegment: (options: {
|
|
34
|
+
segmentName?: string;
|
|
35
|
+
controllers: Record<string, StaticClass>;
|
|
36
|
+
exposeValidation?: boolean;
|
|
37
|
+
emitSchema?: boolean;
|
|
38
|
+
forceApiRoot?: string;
|
|
39
|
+
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
40
|
+
onSuccess?: (resp: unknown, req: VovkRequest) => void | Promise<void>;
|
|
41
|
+
onBefore?: (req: VovkRequest) => void | Promise<void>;
|
|
42
|
+
}) => {
|
|
43
|
+
GET: (req: NextRequest, data: {
|
|
44
|
+
params: Promise<Record<string, string[]>>;
|
|
45
|
+
}) => Promise<Response>;
|
|
46
|
+
POST: (req: NextRequest, data: {
|
|
47
|
+
params: Promise<Record<string, string[]>>;
|
|
48
|
+
}) => Promise<Response>;
|
|
49
|
+
PUT: (req: NextRequest, data: {
|
|
50
|
+
params: Promise<Record<string, string[]>>;
|
|
51
|
+
}) => Promise<Response>;
|
|
52
|
+
PATCH: (req: NextRequest, data: {
|
|
53
|
+
params: Promise<Record<string, string[]>>;
|
|
54
|
+
}) => Promise<Response>;
|
|
55
|
+
DELETE: (req: NextRequest, data: {
|
|
56
|
+
params: Promise<Record<string, string[]>>;
|
|
57
|
+
}) => Promise<Response>;
|
|
58
|
+
HEAD: (req: NextRequest, data: {
|
|
59
|
+
params: Promise<Record<string, string[]>>;
|
|
60
|
+
}) => Promise<Response>;
|
|
61
|
+
OPTIONS: (req: NextRequest, data: {
|
|
62
|
+
params: Promise<Record<string, string[]>>;
|
|
63
|
+
}) => Promise<Response>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
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-z0-9])([A-Z])/g, '$1-$2') // Add hyphen between lowercase/digit and uppercase
|
|
14
|
+
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2') // Add hyphen between uppercase letters if the second one is followed by a lowercase
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/^-/, ''); // Remove leading hyphen
|
|
17
|
+
const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovkApp, }) => {
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
throw new Error('HTTP decorators can be used on server-side only. You have probably imported a controller on the client-side.');
|
|
20
|
+
}
|
|
21
|
+
if (!isClass(controller)) {
|
|
22
|
+
let decoratorName = httpMethod.toLowerCase();
|
|
23
|
+
if (decoratorName === 'delete')
|
|
24
|
+
decoratorName = 'del';
|
|
25
|
+
throw new Error(`Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}().`);
|
|
26
|
+
}
|
|
27
|
+
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
28
|
+
vovkApp.routes[httpMethod].set(controller, methods);
|
|
29
|
+
if (options?.cors) {
|
|
30
|
+
const optionsMethods = vovkApp.routes.OPTIONS.get(controller) ?? {};
|
|
31
|
+
optionsMethods[path] = (() => { });
|
|
32
|
+
optionsMethods[path]._options = options;
|
|
33
|
+
vovkApp.routes.OPTIONS.set(controller, optionsMethods);
|
|
34
|
+
}
|
|
35
|
+
const originalMethod = controller[propertyKey];
|
|
36
|
+
originalMethod._controller = controller;
|
|
37
|
+
originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
|
|
38
|
+
const schema = originalMethod._sourceMethod._getSchema?.(controller);
|
|
39
|
+
// TODO: Some of these assignments probably not needed anymore
|
|
40
|
+
originalMethod.schema = schema;
|
|
41
|
+
originalMethod.fn = originalMethod._sourceMethod?.fn;
|
|
42
|
+
originalMethod.models = originalMethod._sourceMethod?.models;
|
|
43
|
+
originalMethod._sourceMethod.wrapper = originalMethod;
|
|
44
|
+
controller._handlers = {
|
|
45
|
+
...controller._handlers,
|
|
46
|
+
[propertyKey]: {
|
|
47
|
+
...schema,
|
|
48
|
+
...(controller._handlers ?? {})[propertyKey],
|
|
49
|
+
path,
|
|
50
|
+
httpMethod,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
methods[path] = originalMethod;
|
|
54
|
+
methods[path]._options = options;
|
|
55
|
+
controller._handlersMetadata = {
|
|
56
|
+
...controller._handlersMetadata,
|
|
57
|
+
[propertyKey]: {
|
|
58
|
+
...(controller._handlersMetadata ?? {})[propertyKey],
|
|
59
|
+
staticParams: options?.staticParams,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
function createVovkApp() {
|
|
64
|
+
const vovkApp = new VovkApp_1.VovkApp();
|
|
65
|
+
function createHTTPDecorator(httpMethod) {
|
|
66
|
+
function decoratorCreator(givenPath = '', options) {
|
|
67
|
+
const path = trimPath(givenPath);
|
|
68
|
+
function decorator(givenTarget, propertyKey) {
|
|
69
|
+
const controller = givenTarget;
|
|
70
|
+
assignSchema({ controller, propertyKey, path, options, httpMethod, vovkApp });
|
|
71
|
+
}
|
|
72
|
+
return decorator;
|
|
73
|
+
}
|
|
74
|
+
const auto = (options) => {
|
|
75
|
+
function decorator(givenTarget, propertyKey) {
|
|
76
|
+
const controller = givenTarget;
|
|
77
|
+
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
78
|
+
vovkApp.routes[httpMethod].set(controller, methods);
|
|
79
|
+
controller._handlers = {
|
|
80
|
+
...controller._handlers,
|
|
81
|
+
[propertyKey]: {
|
|
82
|
+
...(controller._handlers ?? {})[propertyKey],
|
|
83
|
+
httpMethod,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const properties = Object.keys(controller._handlers[propertyKey]?.validation?.params?.properties ?? {});
|
|
87
|
+
const kebab = toKebabCase(propertyKey); // 🥙
|
|
88
|
+
const path = properties.length ? `${kebab}/${properties.map((prop) => `{${prop}}`).join('/')}` : kebab;
|
|
89
|
+
assignSchema({ controller, propertyKey, path, options, httpMethod, vovkApp });
|
|
90
|
+
}
|
|
91
|
+
return decorator;
|
|
92
|
+
};
|
|
93
|
+
const enhancedDecoratorCreator = decoratorCreator;
|
|
94
|
+
enhancedDecoratorCreator.auto = auto;
|
|
95
|
+
return enhancedDecoratorCreator;
|
|
96
|
+
}
|
|
97
|
+
const prefix = (givenPath = '') => {
|
|
98
|
+
const path = trimPath(givenPath);
|
|
99
|
+
return (givenTarget) => {
|
|
100
|
+
const controller = givenTarget;
|
|
101
|
+
controller._prefix = path;
|
|
102
|
+
return givenTarget;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const initSegment = (options) => {
|
|
106
|
+
options.segmentName = trimPath(options.segmentName ?? '');
|
|
107
|
+
for (const [rpcModuleName, controller] of Object.entries(options.controllers ?? {})) {
|
|
108
|
+
controller._rpcModuleName = rpcModuleName;
|
|
109
|
+
controller._onError = options?.onError;
|
|
110
|
+
controller._onSuccess = options?.onSuccess;
|
|
111
|
+
controller._onBefore = options?.onBefore;
|
|
112
|
+
}
|
|
113
|
+
async function GET_DEV(req, data) {
|
|
114
|
+
const params = await data.params;
|
|
115
|
+
if (params[Object.keys(params)[0]]?.[0] === '_schema_') {
|
|
116
|
+
const schema = await (0, getSchema_1.default)(options);
|
|
117
|
+
return vovkApp.respond({
|
|
118
|
+
req: req,
|
|
119
|
+
statusCode: 200,
|
|
120
|
+
responseBody: { schema },
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return vovkApp.GET(req, data);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
GET: process.env.NODE_ENV === 'development' ? GET_DEV : vovkApp.GET,
|
|
127
|
+
POST: vovkApp.POST,
|
|
128
|
+
PUT: vovkApp.PUT,
|
|
129
|
+
PATCH: vovkApp.PATCH,
|
|
130
|
+
DELETE: vovkApp.DELETE,
|
|
131
|
+
HEAD: vovkApp.HEAD,
|
|
132
|
+
OPTIONS: vovkApp.OPTIONS,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
get: createHTTPDecorator(types_1.HttpMethod.GET),
|
|
137
|
+
post: createHTTPDecorator(types_1.HttpMethod.POST),
|
|
138
|
+
put: createHTTPDecorator(types_1.HttpMethod.PUT),
|
|
139
|
+
patch: createHTTPDecorator(types_1.HttpMethod.PATCH),
|
|
140
|
+
del: createHTTPDecorator(types_1.HttpMethod.DELETE),
|
|
141
|
+
head: createHTTPDecorator(types_1.HttpMethod.HEAD),
|
|
142
|
+
options: createHTTPDecorator(types_1.HttpMethod.OPTIONS),
|
|
143
|
+
prefix,
|
|
144
|
+
initSegment,
|
|
145
|
+
};
|
|
146
|
+
}
|
package/mjs/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createVovkApp } from './createVovkApp';
|
|
2
|
+
import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkPackageJson, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
|
|
3
|
+
import { type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client';
|
|
4
|
+
import { operation, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi';
|
|
5
|
+
import { HttpException } from './HttpException';
|
|
6
|
+
import { createDecorator } from './utils/createDecorator';
|
|
7
|
+
import { JSONLinesResponse } from './JSONLinesResponse';
|
|
8
|
+
import { generateStaticAPI } from './utils/generateStaticAPI';
|
|
9
|
+
import { withValidationLibrary } from './utils/withValidationLibrary';
|
|
10
|
+
import { createStandardValidation } from './utils/createStandardValidation';
|
|
11
|
+
import { multitenant } from './utils/multitenant';
|
|
12
|
+
import { createLLMTools } from './utils/createLLMTools';
|
|
13
|
+
import { createCodeSamples } from './utils/createCodeSamples';
|
|
14
|
+
import { createValidateOnClient } from './utils/createValidateOnClient';
|
|
15
|
+
import { resolveGeneratorConfigValues } from './utils/resolveGeneratorConfigValues';
|
|
16
|
+
export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkGeneratorConfig, type VovkPackageJson, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
|
|
17
|
+
export declare const get: {
|
|
18
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
19
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
20
|
+
}, post: {
|
|
21
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
22
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
23
|
+
}, put: {
|
|
24
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
25
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
26
|
+
}, patch: {
|
|
27
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
28
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
29
|
+
}, del: {
|
|
30
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
31
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
32
|
+
}, head: {
|
|
33
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
34
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
35
|
+
}, options: {
|
|
36
|
+
(givenPath?: string | undefined, options?: Omit<import("./types").DecoratorOptions, "staticParams"> | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
37
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
38
|
+
}, prefix: (givenPath?: string) => (givenTarget: KnownAny) => any, initSegment: (options: {
|
|
39
|
+
segmentName?: string;
|
|
40
|
+
controllers: Record<string, import("./types").StaticClass>;
|
|
41
|
+
exposeValidation?: boolean;
|
|
42
|
+
emitSchema?: boolean;
|
|
43
|
+
forceApiRoot?: string;
|
|
44
|
+
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
45
|
+
onSuccess?: (resp: unknown, req: VovkRequest) => void | Promise<void>;
|
|
46
|
+
onBefore?: (req: VovkRequest) => void | Promise<void>;
|
|
47
|
+
}) => {
|
|
48
|
+
GET: (req: import("next/server").NextRequest, data: {
|
|
49
|
+
params: Promise<Record<string, string[]>>;
|
|
50
|
+
}) => Promise<Response>;
|
|
51
|
+
POST: (req: import("next/server").NextRequest, data: {
|
|
52
|
+
params: Promise<Record<string, string[]>>;
|
|
53
|
+
}) => Promise<Response>;
|
|
54
|
+
PUT: (req: import("next/server").NextRequest, data: {
|
|
55
|
+
params: Promise<Record<string, string[]>>;
|
|
56
|
+
}) => Promise<Response>;
|
|
57
|
+
PATCH: (req: import("next/server").NextRequest, data: {
|
|
58
|
+
params: Promise<Record<string, string[]>>;
|
|
59
|
+
}) => Promise<Response>;
|
|
60
|
+
DELETE: (req: import("next/server").NextRequest, data: {
|
|
61
|
+
params: Promise<Record<string, string[]>>;
|
|
62
|
+
}) => Promise<Response>;
|
|
63
|
+
HEAD: (req: import("next/server").NextRequest, data: {
|
|
64
|
+
params: Promise<Record<string, string[]>>;
|
|
65
|
+
}) => Promise<Response>;
|
|
66
|
+
OPTIONS: (req: import("next/server").NextRequest, data: {
|
|
67
|
+
params: Promise<Record<string, string[]>>;
|
|
68
|
+
}) => Promise<Response>;
|
|
69
|
+
};
|
package/mjs/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.initSegment = exports.prefix = exports.options = exports.head = exports.del = exports.patch = exports.put = exports.post = exports.get = exports.resolveGeneratorConfigValues = exports.vovkSchemaToOpenAPI = exports.openAPIToVovkSchema = exports.operation = exports.progressive = exports.createValidateOnClient = exports.createCodeSamples = exports.createLLMTools = exports.multitenant = exports.createStandardValidation = exports.withValidationLibrary = exports.generateStaticAPI = exports.createFetcher = exports.fetcher = exports.createRPC = exports.createDecorator = exports.createVovkApp = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.JSONLinesResponse = exports.VovkSchemaIdEnum = 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
|
+
Object.defineProperty(exports, "VovkSchemaIdEnum", { enumerable: true, get: function () { return types_1.VovkSchemaIdEnum; } });
|
|
11
|
+
const client_1 = require("./client");
|
|
12
|
+
Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return client_1.createRPC; } });
|
|
13
|
+
Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return client_1.fetcher; } });
|
|
14
|
+
Object.defineProperty(exports, "createFetcher", { enumerable: true, get: function () { return client_1.createFetcher; } });
|
|
15
|
+
Object.defineProperty(exports, "progressive", { enumerable: true, get: function () { return client_1.progressive; } });
|
|
16
|
+
const openapi_1 = require("./openapi");
|
|
17
|
+
Object.defineProperty(exports, "operation", { enumerable: true, get: function () { return openapi_1.operation; } });
|
|
18
|
+
Object.defineProperty(exports, "openAPIToVovkSchema", { enumerable: true, get: function () { return openapi_1.openAPIToVovkSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "vovkSchemaToOpenAPI", { enumerable: true, get: function () { return openapi_1.vovkSchemaToOpenAPI; } });
|
|
20
|
+
const HttpException_1 = require("./HttpException");
|
|
21
|
+
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1.HttpException; } });
|
|
22
|
+
const createDecorator_1 = require("./utils/createDecorator");
|
|
23
|
+
Object.defineProperty(exports, "createDecorator", { enumerable: true, get: function () { return createDecorator_1.createDecorator; } });
|
|
24
|
+
const JSONLinesResponse_1 = require("./JSONLinesResponse");
|
|
25
|
+
Object.defineProperty(exports, "JSONLinesResponse", { enumerable: true, get: function () { return JSONLinesResponse_1.JSONLinesResponse; } });
|
|
26
|
+
const generateStaticAPI_1 = require("./utils/generateStaticAPI");
|
|
27
|
+
Object.defineProperty(exports, "generateStaticAPI", { enumerable: true, get: function () { return generateStaticAPI_1.generateStaticAPI; } });
|
|
28
|
+
const withValidationLibrary_1 = require("./utils/withValidationLibrary");
|
|
29
|
+
Object.defineProperty(exports, "withValidationLibrary", { enumerable: true, get: function () { return withValidationLibrary_1.withValidationLibrary; } });
|
|
30
|
+
const createStandardValidation_1 = require("./utils/createStandardValidation");
|
|
31
|
+
Object.defineProperty(exports, "createStandardValidation", { enumerable: true, get: function () { return createStandardValidation_1.createStandardValidation; } });
|
|
32
|
+
const multitenant_1 = require("./utils/multitenant");
|
|
33
|
+
Object.defineProperty(exports, "multitenant", { enumerable: true, get: function () { return multitenant_1.multitenant; } });
|
|
34
|
+
const createLLMTools_1 = require("./utils/createLLMTools");
|
|
35
|
+
Object.defineProperty(exports, "createLLMTools", { enumerable: true, get: function () { return createLLMTools_1.createLLMTools; } });
|
|
36
|
+
const createCodeSamples_1 = require("./utils/createCodeSamples");
|
|
37
|
+
Object.defineProperty(exports, "createCodeSamples", { enumerable: true, get: function () { return createCodeSamples_1.createCodeSamples; } });
|
|
38
|
+
const createValidateOnClient_1 = require("./utils/createValidateOnClient");
|
|
39
|
+
Object.defineProperty(exports, "createValidateOnClient", { enumerable: true, get: function () { return createValidateOnClient_1.createValidateOnClient; } });
|
|
40
|
+
const resolveGeneratorConfigValues_1 = require("./utils/resolveGeneratorConfigValues");
|
|
41
|
+
Object.defineProperty(exports, "resolveGeneratorConfigValues", { enumerable: true, get: function () { return resolveGeneratorConfigValues_1.resolveGeneratorConfigValues; } });
|
|
42
|
+
_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.initSegment = _a.initSegment;
|