vovk 3.0.0-draft.138 → 3.0.0-draft.140
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/cjs/client/fetcher.js +3 -1
- package/cjs/types.d.ts +15 -16
- package/mjs/client/fetcher.js +3 -1
- package/mjs/types.d.ts +15 -16
- package/package.json +1 -4
package/cjs/client/fetcher.js
CHANGED
|
@@ -11,7 +11,9 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
|
|
|
11
11
|
const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, options) => {
|
|
12
12
|
const { params, query, body, apiRoot = '/api', disableClientValidation, init, interpretAs } = options;
|
|
13
13
|
const endpoint = getEndpoint({ apiRoot, params, query });
|
|
14
|
-
const unusedParams = new URL(endpoint
|
|
14
|
+
const unusedParams = new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname
|
|
15
|
+
.split('/')
|
|
16
|
+
.filter((segment) => segment.startsWith(':'));
|
|
15
17
|
if (unusedParams.length) {
|
|
16
18
|
throw new HttpException_js_1.HttpException(types_js_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(', ')} in ${endpoint}`, {
|
|
17
19
|
body,
|
package/cjs/types.d.ts
CHANGED
|
@@ -3,33 +3,37 @@ import type { OperationObject } from 'openapi3-ts/oas31';
|
|
|
3
3
|
import type { JSONLinesResponse } from './JSONLinesResponse.js';
|
|
4
4
|
import { VovkStreamAsyncIterable } from './client/types.js';
|
|
5
5
|
import type { PackageJson } from 'type-fest';
|
|
6
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
7
6
|
export type KnownAny = any;
|
|
8
7
|
export type StaticClass = Function;
|
|
9
|
-
export type VovkHandlerSchema = {
|
|
8
|
+
export type VovkHandlerSchema<T = KnownAny> = {
|
|
10
9
|
path: string;
|
|
11
10
|
httpMethod: string;
|
|
12
11
|
validation?: {
|
|
13
|
-
query?:
|
|
14
|
-
body?:
|
|
15
|
-
params?:
|
|
16
|
-
output?:
|
|
17
|
-
iteration?:
|
|
12
|
+
query?: T;
|
|
13
|
+
body?: T;
|
|
14
|
+
params?: T;
|
|
15
|
+
output?: T;
|
|
16
|
+
iteration?: T;
|
|
18
17
|
};
|
|
19
18
|
openapi?: OperationObject;
|
|
20
19
|
misc?: Record<string, KnownAny>;
|
|
21
20
|
};
|
|
22
|
-
export type VovkControllerSchema = {
|
|
21
|
+
export type VovkControllerSchema<T = KnownAny> = {
|
|
23
22
|
rpcModuleName: string;
|
|
24
23
|
originalControllerName: string;
|
|
25
24
|
prefix?: string;
|
|
26
|
-
handlers: Record<string, VovkHandlerSchema
|
|
25
|
+
handlers: Record<string, VovkHandlerSchema<T>>;
|
|
27
26
|
};
|
|
28
|
-
export type VovkSegmentSchema = {
|
|
27
|
+
export type VovkSegmentSchema<T = KnownAny> = {
|
|
29
28
|
$schema: typeof VovkSchemaIdEnum.SEGMENT | string;
|
|
30
29
|
emitSchema: boolean;
|
|
31
30
|
segmentName: string;
|
|
32
|
-
controllers: Record<string, VovkControllerSchema
|
|
31
|
+
controllers: Record<string, VovkControllerSchema<T>>;
|
|
32
|
+
};
|
|
33
|
+
export type VovkSchema<T = KnownAny> = {
|
|
34
|
+
$schema: typeof VovkSchemaIdEnum.SCHEMA | string;
|
|
35
|
+
config: Partial<VovkStrictConfig>;
|
|
36
|
+
segments: Record<string, VovkSegmentSchema<T>>;
|
|
33
37
|
};
|
|
34
38
|
export type VovkErrorResponse = {
|
|
35
39
|
cause?: unknown;
|
|
@@ -116,11 +120,6 @@ export type StreamAbortMessage = {
|
|
|
116
120
|
reason: KnownAny;
|
|
117
121
|
};
|
|
118
122
|
export type VovkValidationType = 'body' | 'query' | 'params' | 'output' | 'iteration';
|
|
119
|
-
export type VovkSchema = {
|
|
120
|
-
$schema: typeof VovkSchemaIdEnum.SCHEMA | string;
|
|
121
|
-
config: Partial<VovkStrictConfig>;
|
|
122
|
-
segments: Record<string, VovkSegmentSchema>;
|
|
123
|
-
};
|
|
124
123
|
export declare enum HttpMethod {
|
|
125
124
|
GET = "GET",
|
|
126
125
|
POST = "POST",
|
package/mjs/client/fetcher.js
CHANGED
|
@@ -11,7 +11,9 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
|
|
|
11
11
|
const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, options) => {
|
|
12
12
|
const { params, query, body, apiRoot = '/api', disableClientValidation, init, interpretAs } = options;
|
|
13
13
|
const endpoint = getEndpoint({ apiRoot, params, query });
|
|
14
|
-
const unusedParams = new URL(endpoint
|
|
14
|
+
const unusedParams = new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname
|
|
15
|
+
.split('/')
|
|
16
|
+
.filter((segment) => segment.startsWith(':'));
|
|
15
17
|
if (unusedParams.length) {
|
|
16
18
|
throw new HttpException_js_1.HttpException(types_js_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(', ')} in ${endpoint}`, {
|
|
17
19
|
body,
|
package/mjs/types.d.ts
CHANGED
|
@@ -3,33 +3,37 @@ import type { OperationObject } from 'openapi3-ts/oas31';
|
|
|
3
3
|
import type { JSONLinesResponse } from './JSONLinesResponse.js';
|
|
4
4
|
import { VovkStreamAsyncIterable } from './client/types.js';
|
|
5
5
|
import type { PackageJson } from 'type-fest';
|
|
6
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
7
6
|
export type KnownAny = any;
|
|
8
7
|
export type StaticClass = Function;
|
|
9
|
-
export type VovkHandlerSchema = {
|
|
8
|
+
export type VovkHandlerSchema<T = KnownAny> = {
|
|
10
9
|
path: string;
|
|
11
10
|
httpMethod: string;
|
|
12
11
|
validation?: {
|
|
13
|
-
query?:
|
|
14
|
-
body?:
|
|
15
|
-
params?:
|
|
16
|
-
output?:
|
|
17
|
-
iteration?:
|
|
12
|
+
query?: T;
|
|
13
|
+
body?: T;
|
|
14
|
+
params?: T;
|
|
15
|
+
output?: T;
|
|
16
|
+
iteration?: T;
|
|
18
17
|
};
|
|
19
18
|
openapi?: OperationObject;
|
|
20
19
|
misc?: Record<string, KnownAny>;
|
|
21
20
|
};
|
|
22
|
-
export type VovkControllerSchema = {
|
|
21
|
+
export type VovkControllerSchema<T = KnownAny> = {
|
|
23
22
|
rpcModuleName: string;
|
|
24
23
|
originalControllerName: string;
|
|
25
24
|
prefix?: string;
|
|
26
|
-
handlers: Record<string, VovkHandlerSchema
|
|
25
|
+
handlers: Record<string, VovkHandlerSchema<T>>;
|
|
27
26
|
};
|
|
28
|
-
export type VovkSegmentSchema = {
|
|
27
|
+
export type VovkSegmentSchema<T = KnownAny> = {
|
|
29
28
|
$schema: typeof VovkSchemaIdEnum.SEGMENT | string;
|
|
30
29
|
emitSchema: boolean;
|
|
31
30
|
segmentName: string;
|
|
32
|
-
controllers: Record<string, VovkControllerSchema
|
|
31
|
+
controllers: Record<string, VovkControllerSchema<T>>;
|
|
32
|
+
};
|
|
33
|
+
export type VovkSchema<T = KnownAny> = {
|
|
34
|
+
$schema: typeof VovkSchemaIdEnum.SCHEMA | string;
|
|
35
|
+
config: Partial<VovkStrictConfig>;
|
|
36
|
+
segments: Record<string, VovkSegmentSchema<T>>;
|
|
33
37
|
};
|
|
34
38
|
export type VovkErrorResponse = {
|
|
35
39
|
cause?: unknown;
|
|
@@ -116,11 +120,6 @@ export type StreamAbortMessage = {
|
|
|
116
120
|
reason: KnownAny;
|
|
117
121
|
};
|
|
118
122
|
export type VovkValidationType = 'body' | 'query' | 'params' | 'output' | 'iteration';
|
|
119
|
-
export type VovkSchema = {
|
|
120
|
-
$schema: typeof VovkSchemaIdEnum.SCHEMA | string;
|
|
121
|
-
config: Partial<VovkStrictConfig>;
|
|
122
|
-
segments: Record<string, VovkSegmentSchema>;
|
|
123
|
-
};
|
|
124
123
|
export declare enum HttpMethod {
|
|
125
124
|
GET = "GET",
|
|
126
125
|
POST = "POST",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk",
|
|
3
|
-
"version": "3.0.0-draft.
|
|
3
|
+
"version": "3.0.0-draft.140",
|
|
4
4
|
"main": "./cjs/index.js",
|
|
5
5
|
"module": "./mjs/index.js",
|
|
6
6
|
"types": "./mjs/index.d.ts",
|
|
@@ -35,8 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"openapi3-ts": "*",
|
|
37
37
|
"type-fest": "*"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@types/json-schema": "^7.0.15"
|
|
41
38
|
}
|
|
42
39
|
}
|