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 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
- Back-end meta-framework for <a href="https://nextjs.org/docs/app">Next.js</a>
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 [![npm version](https://badge.fury.io/js/vovk.svg)](https://www.npmjs.com/package/vovk)
17
16
 
18
- The main library with [zero dependencies](https://bundlephobia.com/result?p=vovk) that's going to be used in production. It provides a wrapper for Next.js API routes, internal RPC API, utilities and types.
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/).
@@ -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>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
7
- onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
8
- onError?: (error: HttpException, options: VovkFetcherOptions<T>, response: Response | null, init: RequestInit | null, respData: unknown | null) => void | Promise<void>;
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;
@@ -83,12 +83,14 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
83
83
  else {
84
84
  respData = response;
85
85
  }
86
- respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
87
- await onSuccess?.(respData, inputOptions, response, requestInit);
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
- tsdownBuildOptions?: Parameters<typeof import('tsdown') extends {
350
- build: infer T;
351
- } ? T : never>[0];
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;
@@ -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>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
7
- onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
8
- onError?: (error: HttpException, options: VovkFetcherOptions<T>, response: Response | null, init: RequestInit | null, respData: unknown | null) => void | Promise<void>;
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;
@@ -83,12 +83,14 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
83
83
  else {
84
84
  respData = response;
85
85
  }
86
- respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
87
- await onSuccess?.(respData, inputOptions, response, requestInit);
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
- tsdownBuildOptions?: Parameters<typeof import('tsdown') extends {
350
- build: infer T;
351
- } ? T : never>[0];
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.461",
3
+ "version": "3.0.0-draft.462",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",