vovk 3.0.0-draft.92 → 3.0.0-draft.93
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/dist/VovkApp.js +1 -1
- package/dist/client/createRPC.d.ts +1 -2
- package/dist/client/createRPC.js +4 -3
- package/dist/client/{defaultFetcher.d.ts → fetcher.d.ts} +1 -2
- package/dist/client/{defaultFetcher.js → fetcher.js} +3 -3
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +4 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/dist/VovkApp.js
CHANGED
|
@@ -177,7 +177,7 @@ class VovkApp {
|
|
|
177
177
|
console.error(onErrorError);
|
|
178
178
|
}
|
|
179
179
|
if (err.message !== 'NEXT_REDIRECT' && err.message !== 'NEXT_NOT_FOUND') {
|
|
180
|
-
const statusCode = err.statusCode
|
|
180
|
+
const statusCode = err.statusCode || types_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
181
181
|
return this.#respondWithError(statusCode, err.message, staticMethod._options, err.cause);
|
|
182
182
|
}
|
|
183
183
|
throw e; // if NEXT_REDIRECT or NEXT_NOT_FOUND, rethrow it
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { KnownAny, VovkFullSchema } from '../types';
|
|
2
2
|
import type { VovkClientOptions, VovkClient, VovkDefaultFetcherOptions } from './types';
|
|
3
|
-
declare const createRPC: <T, OPTS extends Record<string, KnownAny> = VovkDefaultFetcherOptions>(fullSchema: VovkFullSchema, segmentName: string, controllerName: string, options?: VovkClientOptions<OPTS>) => VovkClient<T, OPTS>;
|
|
4
|
-
export default createRPC;
|
|
3
|
+
export declare const createRPC: <T, OPTS extends Record<string, KnownAny> = VovkDefaultFetcherOptions>(fullSchema: VovkFullSchema, segmentName: string, controllerName: string, options?: VovkClientOptions<OPTS>) => VovkClient<T, OPTS>;
|
package/dist/client/createRPC.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
exports.createRPC = void 0;
|
|
7
|
+
const fetcher_1 = require("./fetcher");
|
|
7
8
|
const defaultHandler_1 = require("./defaultHandler");
|
|
8
9
|
const defaultStreamHandler_1 = require("./defaultStreamHandler");
|
|
9
10
|
const serializeQuery_1 = __importDefault(require("../utils/serializeQuery"));
|
|
@@ -25,7 +26,7 @@ const createRPC = (fullSchema, segmentName, controllerName, options) => {
|
|
|
25
26
|
if (!controllerSchema)
|
|
26
27
|
throw new Error(`Unable to create RPC object. Controller schema is missing. Check client template.`);
|
|
27
28
|
const controllerPrefix = trimPath(controllerSchema.prefix ?? '');
|
|
28
|
-
const { fetcher: settingsFetcher =
|
|
29
|
+
const { fetcher: settingsFetcher = fetcher_1.fetcher } = options ?? {};
|
|
29
30
|
for (const [staticMethodName, handlerSchema] of Object.entries(controllerSchema.handlers)) {
|
|
30
31
|
const { path, httpMethod, validation } = handlerSchema;
|
|
31
32
|
const getEndpoint = ({ apiRoot, params, query, }) => {
|
|
@@ -81,4 +82,4 @@ const createRPC = (fullSchema, segmentName, controllerName, options) => {
|
|
|
81
82
|
}
|
|
82
83
|
return client;
|
|
83
84
|
};
|
|
84
|
-
exports.
|
|
85
|
+
exports.createRPC = createRPC;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { VovkDefaultFetcherOptions, VovkClientFetcher } from './types';
|
|
2
2
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at the defaultFetcher";
|
|
3
|
-
declare const
|
|
4
|
-
export default defaultFetcher;
|
|
3
|
+
export declare const fetcher: VovkClientFetcher<VovkDefaultFetcherOptions>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
3
|
+
exports.fetcher = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const HttpException_1 = require("../HttpException");
|
|
6
6
|
exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at the defaultFetcher';
|
|
7
7
|
// defaultFetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
|
|
8
8
|
// For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
|
|
9
|
-
const
|
|
9
|
+
const fetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, { params, query, body, apiRoot = '/api', ...options }) => {
|
|
10
10
|
const endpoint = getEndpoint({ apiRoot, params, query });
|
|
11
11
|
if (!options.disableClientValidation) {
|
|
12
12
|
try {
|
|
@@ -57,4 +57,4 @@ const defaultFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandle
|
|
|
57
57
|
}
|
|
58
58
|
return response;
|
|
59
59
|
};
|
|
60
|
-
exports.
|
|
60
|
+
exports.fetcher = fetcher;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createRPC } from './createRPC';
|
|
2
|
+
export { fetcher } from './fetcher';
|
|
2
3
|
export type { VovkClient, VovkClientFetcher, VovkClientOptions, VovkDefaultFetcherOptions, VovkValidateOnClient, VovkStreamAsyncIterable, } from './types';
|
package/dist/client/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createRPC = void 0;
|
|
3
|
+
exports.fetcher = exports.createRPC = void 0;
|
|
7
4
|
var createRPC_1 = require("./createRPC");
|
|
8
|
-
Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return
|
|
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; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createVovkApp } from './createVovkApp';
|
|
2
2
|
import { HttpStatus as HttpStatus, HttpMethod as HttpMethod, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkControllerOutput, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkFullSchema, type VovkConfig, type VovkStrictConfig, type VovkEnv } from './types';
|
|
3
|
-
import { type VovkClient, type VovkClientOptions, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC } from './client';
|
|
3
|
+
import { type VovkClient, type VovkClientOptions, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher } from './client';
|
|
4
4
|
import { HttpException } from './HttpException';
|
|
5
5
|
import { createDecorator } from './createDecorator';
|
|
6
6
|
import { StreamJSONResponse } from './StreamJSONResponse';
|
|
7
7
|
import { generateStaticAPI } from './utils/generateStaticAPI';
|
|
8
8
|
import { setHandlerValidation } from './utils/setHandlerValidation';
|
|
9
|
-
export { type KnownAny, type VovkClient, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkControllerOutput, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkClientOptions, type VovkControllerSchema, type VovkHandlerSchema, type VovkFullSchema, type VovkConfig, type VovkStrictConfig, type VovkEnv, StreamJSONResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, generateStaticAPI, setHandlerValidation, };
|
|
9
|
+
export { type KnownAny, type VovkClient, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkControllerOutput, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkClientOptions, type VovkControllerSchema, type VovkHandlerSchema, type VovkFullSchema, type VovkConfig, type VovkStrictConfig, type VovkEnv, StreamJSONResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, generateStaticAPI, setHandlerValidation, };
|
|
10
10
|
export declare const get: {
|
|
11
11
|
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
12
12
|
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
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.setHandlerValidation = exports.generateStaticAPI = exports.createRPC = exports.createDecorator = exports.createVovkApp = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.StreamJSONResponse = void 0;
|
|
4
|
+
exports.initVovk = exports.prefix = exports.options = exports.head = exports.del = exports.patch = exports.put = exports.post = exports.get = exports.setHandlerValidation = exports.generateStaticAPI = exports.fetcher = exports.createRPC = exports.createDecorator = exports.createVovkApp = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.StreamJSONResponse = void 0;
|
|
5
5
|
const createVovkApp_1 = require("./createVovkApp");
|
|
6
6
|
Object.defineProperty(exports, "createVovkApp", { enumerable: true, get: function () { return createVovkApp_1.createVovkApp; } });
|
|
7
7
|
const types_1 = require("./types");
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function (
|
|
|
9
9
|
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return types_1.HttpMethod; } });
|
|
10
10
|
const client_1 = require("./client");
|
|
11
11
|
Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return client_1.createRPC; } });
|
|
12
|
+
Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return client_1.fetcher; } });
|
|
12
13
|
const HttpException_1 = require("./HttpException");
|
|
13
14
|
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1.HttpException; } });
|
|
14
15
|
const createDecorator_1 = require("./createDecorator");
|
package/package.json
CHANGED