vovk 3.0.0-draft.461 → 3.0.0-draft.462
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/README.md +10 -12
- package/cjs/client/fetcher.d.ts +17 -3
- package/cjs/client/fetcher.js +5 -3
- package/cjs/types.d.ts +6 -3
- package/mjs/client/fetcher.d.ts +17 -3
- package/mjs/client/fetcher.js +5 -3
- package/mjs/types.d.ts +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<picture>
|
|
3
|
-
<source width="300" media="(prefers-color-scheme: dark)" srcset="https://vovk.dev/vovk-logo-white.svg">
|
|
4
|
-
<source width="300" media="(prefers-color-scheme: light)" srcset="https://vovk.dev/vovk-logo.svg">
|
|
5
|
-
<img width="300" alt="vovk" src="https://vovk.dev/vovk-logo.svg">
|
|
6
|
-
</picture><br>
|
|
7
|
-
<strong>RESTful + RPC = ♥️</strong>
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
1
|
<p align="center">
|
|
11
|
-
|
|
2
|
+
<a href="https://vovk.dev">
|
|
3
|
+
<picture>
|
|
4
|
+
<source width="300" media="(prefers-color-scheme: dark)" srcset="https://vovk.dev/vovk-logo-white.svg">
|
|
5
|
+
<source width="300" media="(prefers-color-scheme: light)" srcset="https://vovk.dev/vovk-logo.svg">
|
|
6
|
+
<img width="300" alt="vovk" src="https://vovk.dev/vovk-logo.svg">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
<br>
|
|
10
|
+
<strong>Back-end for <a href="https://nextjs.org/">Next.js</a></strong>
|
|
12
11
|
</p>
|
|
13
12
|
|
|
14
13
|
---
|
|
15
14
|
|
|
16
15
|
## vovk [](https://www.npmjs.com/package/vovk)
|
|
17
16
|
|
|
18
|
-
The main library with [
|
|
17
|
+
The main library with [100% self-composition](https://bundlephobia.com/result?p=vovk) that's going to be used in production. It provides a wrapper for Next.js API routes, client-side RPC tooling, utilities and types.
|
|
19
18
|
|
|
20
19
|
```sh
|
|
21
20
|
npm install vovk
|
|
22
21
|
```
|
|
23
22
|
|
|
24
|
-
For more information, please visit the [getting started guide](https://vovk.dev/getting-started) or check out the [Vovk.ts examples](https://vovk-examples.vercel.app/).
|
package/cjs/client/fetcher.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
|
+
import { type VovkHandlerSchema } from '../types';
|
|
2
3
|
import { HttpException } from '../HttpException';
|
|
3
4
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
4
5
|
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
5
6
|
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
6
|
-
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>, info: {
|
|
8
|
+
response: Response;
|
|
9
|
+
init: RequestInit;
|
|
10
|
+
schema: VovkHandlerSchema;
|
|
11
|
+
}) => unknown | Promise<unknown>;
|
|
12
|
+
onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, info: {
|
|
13
|
+
response: Response;
|
|
14
|
+
init: RequestInit;
|
|
15
|
+
schema: VovkHandlerSchema;
|
|
16
|
+
}) => void | Promise<void>;
|
|
17
|
+
onError?: (error: HttpException, options: VovkFetcherOptions<T>, info: {
|
|
18
|
+
response: Response | null;
|
|
19
|
+
init: RequestInit | null;
|
|
20
|
+
respData: unknown | null;
|
|
21
|
+
schema: VovkHandlerSchema;
|
|
22
|
+
}) => void | Promise<void>;
|
|
9
23
|
}): VovkFetcher<VovkFetcherOptions<T>>;
|
|
10
24
|
export declare const fetcher: VovkFetcher<{
|
|
11
25
|
apiRoot?: string;
|
package/cjs/client/fetcher.js
CHANGED
|
@@ -83,12 +83,14 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
|
|
|
83
83
|
else {
|
|
84
84
|
respData = response;
|
|
85
85
|
}
|
|
86
|
-
respData = transformResponse
|
|
87
|
-
|
|
86
|
+
respData = transformResponse
|
|
87
|
+
? await transformResponse(respData, inputOptions, { response, init: requestInit, schema })
|
|
88
|
+
: respData;
|
|
89
|
+
await onSuccess?.(respData, inputOptions, { response, init: requestInit, schema });
|
|
88
90
|
return [respData, response];
|
|
89
91
|
}
|
|
90
92
|
catch (error) {
|
|
91
|
-
await onError?.(error, inputOptions, response, requestInit, respData);
|
|
93
|
+
await onError?.(error, inputOptions, { response, init: requestInit, respData, schema });
|
|
92
94
|
throw error;
|
|
93
95
|
}
|
|
94
96
|
};
|
package/cjs/types.d.ts
CHANGED
|
@@ -346,9 +346,12 @@ type BundleConfig = {
|
|
|
346
346
|
requires?: Record<string, string>;
|
|
347
347
|
prebundleOutDir?: string;
|
|
348
348
|
keepPrebundleDir?: boolean;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
outDir?: string;
|
|
350
|
+
build: (options: {
|
|
351
|
+
outDir: string;
|
|
352
|
+
prebundleDir: string;
|
|
353
|
+
entry: string;
|
|
354
|
+
}) => Promise<void>;
|
|
352
355
|
generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
|
|
353
356
|
} & ({
|
|
354
357
|
excludeSegments?: never;
|
package/mjs/client/fetcher.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
|
+
import { type VovkHandlerSchema } from '../types';
|
|
2
3
|
import { HttpException } from '../HttpException';
|
|
3
4
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
4
5
|
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
5
6
|
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
6
|
-
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>, info: {
|
|
8
|
+
response: Response;
|
|
9
|
+
init: RequestInit;
|
|
10
|
+
schema: VovkHandlerSchema;
|
|
11
|
+
}) => unknown | Promise<unknown>;
|
|
12
|
+
onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, info: {
|
|
13
|
+
response: Response;
|
|
14
|
+
init: RequestInit;
|
|
15
|
+
schema: VovkHandlerSchema;
|
|
16
|
+
}) => void | Promise<void>;
|
|
17
|
+
onError?: (error: HttpException, options: VovkFetcherOptions<T>, info: {
|
|
18
|
+
response: Response | null;
|
|
19
|
+
init: RequestInit | null;
|
|
20
|
+
respData: unknown | null;
|
|
21
|
+
schema: VovkHandlerSchema;
|
|
22
|
+
}) => void | Promise<void>;
|
|
9
23
|
}): VovkFetcher<VovkFetcherOptions<T>>;
|
|
10
24
|
export declare const fetcher: VovkFetcher<{
|
|
11
25
|
apiRoot?: string;
|
package/mjs/client/fetcher.js
CHANGED
|
@@ -83,12 +83,14 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
|
|
|
83
83
|
else {
|
|
84
84
|
respData = response;
|
|
85
85
|
}
|
|
86
|
-
respData = transformResponse
|
|
87
|
-
|
|
86
|
+
respData = transformResponse
|
|
87
|
+
? await transformResponse(respData, inputOptions, { response, init: requestInit, schema })
|
|
88
|
+
: respData;
|
|
89
|
+
await onSuccess?.(respData, inputOptions, { response, init: requestInit, schema });
|
|
88
90
|
return [respData, response];
|
|
89
91
|
}
|
|
90
92
|
catch (error) {
|
|
91
|
-
await onError?.(error, inputOptions, response, requestInit, respData);
|
|
93
|
+
await onError?.(error, inputOptions, { response, init: requestInit, respData, schema });
|
|
92
94
|
throw error;
|
|
93
95
|
}
|
|
94
96
|
};
|
package/mjs/types.d.ts
CHANGED
|
@@ -346,9 +346,12 @@ type BundleConfig = {
|
|
|
346
346
|
requires?: Record<string, string>;
|
|
347
347
|
prebundleOutDir?: string;
|
|
348
348
|
keepPrebundleDir?: boolean;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
outDir?: string;
|
|
350
|
+
build: (options: {
|
|
351
|
+
outDir: string;
|
|
352
|
+
prebundleDir: string;
|
|
353
|
+
entry: string;
|
|
354
|
+
}) => Promise<void>;
|
|
352
355
|
generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
|
|
353
356
|
} & ({
|
|
354
357
|
excludeSegments?: never;
|