@snail-js/api 0.1.28 → 1.0.0
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 +21 -0
- package/README.md +125 -605
- package/dist/adapter/plain.d.ts +12 -0
- package/dist/adapter/plain.d.ts.map +1 -0
- package/dist/adapter/react.d.ts +14 -0
- package/dist/adapter/react.d.ts.map +1 -0
- package/dist/adapter/registry.d.ts +16 -0
- package/dist/adapter/registry.d.ts.map +1 -0
- package/dist/adapter/vue.d.ts +15 -0
- package/dist/adapter/vue.d.ts.map +1 -0
- package/dist/chunks/custom-UchOSg_s.js +466 -0
- package/dist/chunks/custom-UchOSg_s.js.map +1 -0
- package/dist/chunks/download-lBC7oOTT.js +160 -0
- package/dist/chunks/download-lBC7oOTT.js.map +1 -0
- package/dist/chunks/object-Ct0w-h4i.js +74 -0
- package/dist/chunks/object-Ct0w-h4i.js.map +1 -0
- package/dist/chunks/plugin-D3RDffDG.js +742 -0
- package/dist/chunks/plugin-D3RDffDG.js.map +1 -0
- package/dist/chunks/react-C1em-gxy.js +62 -0
- package/dist/chunks/react-C1em-gxy.js.map +1 -0
- package/dist/chunks/request-qeRhihEF.js +40 -0
- package/dist/chunks/request-qeRhihEF.js.map +1 -0
- package/dist/chunks/response-D-ubkAFl.js +127 -0
- package/dist/chunks/response-D-ubkAFl.js.map +1 -0
- package/dist/chunks/use-download-FAjtdJ58.js +1816 -0
- package/dist/chunks/use-download-FAjtdJ58.js.map +1 -0
- package/dist/chunks/vue-Dd9EhkQ3.js +34 -0
- package/dist/chunks/vue-Dd9EhkQ3.js.map +1 -0
- package/dist/core/args.d.ts +54 -0
- package/dist/core/args.d.ts.map +1 -0
- package/dist/core/connection.d.ts +15 -0
- package/dist/core/connection.d.ts.map +1 -0
- package/dist/core/context.d.ts +124 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/http-stream.d.ts +28 -0
- package/dist/core/http-stream.d.ts.map +1 -0
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/metadata.d.ts +92 -0
- package/dist/core/metadata.d.ts.map +1 -0
- package/dist/core/metadata.keys.d.ts +41 -0
- package/dist/core/metadata.keys.d.ts.map +1 -0
- package/dist/core/method.d.ts +177 -0
- package/dist/core/method.d.ts.map +1 -0
- package/dist/core/plugin-manager.d.ts +106 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin.d.ts +113 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/reconnect.d.ts +22 -0
- package/dist/core/reconnect.d.ts.map +1 -0
- package/dist/core/resolve-stream.d.ts +45 -0
- package/dist/core/resolve-stream.d.ts.map +1 -0
- package/dist/core/resolve.d.ts +50 -0
- package/dist/core/resolve.d.ts.map +1 -0
- package/dist/core/response.d.ts +60 -0
- package/dist/core/response.d.ts.map +1 -0
- package/dist/core/server.d.ts +132 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/sse.d.ts +27 -0
- package/dist/core/sse.d.ts.map +1 -0
- package/dist/core/state-bag.d.ts +36 -0
- package/dist/core/state-bag.d.ts.map +1 -0
- package/dist/core/websocket.d.ts +29 -0
- package/dist/core/websocket.d.ts.map +1 -0
- package/dist/decorators/api.d.ts +24 -4
- package/dist/decorators/api.d.ts.map +1 -0
- package/dist/decorators/args.d.ts +77 -14
- package/dist/decorators/args.d.ts.map +1 -0
- package/dist/decorators/custom.d.ts +81 -0
- package/dist/decorators/custom.d.ts.map +1 -0
- package/dist/decorators/header.d.ts +22 -0
- package/dist/decorators/header.d.ts.map +1 -0
- package/dist/decorators/index.d.ts +17 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/methods.d.ts +33 -0
- package/dist/decorators/methods.d.ts.map +1 -0
- package/dist/decorators/progress.d.ts +24 -6
- package/dist/decorators/progress.d.ts.map +1 -0
- package/dist/decorators/server.d.ts +28 -7
- package/dist/decorators/server.d.ts.map +1 -0
- package/dist/decorators/stream.d.ts +113 -0
- package/dist/decorators/stream.d.ts.map +1 -0
- package/dist/default/options.d.ts +19 -0
- package/dist/default/options.d.ts.map +1 -0
- package/dist/error/base.d.ts +20 -0
- package/dist/error/base.d.ts.map +1 -0
- package/dist/error/decorator.d.ts +14 -0
- package/dist/error/decorator.d.ts.map +1 -0
- package/dist/error/hook.d.ts +14 -0
- package/dist/error/hook.d.ts.map +1 -0
- package/dist/error/index.d.ts +8 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/options.d.ts +12 -0
- package/dist/error/options.d.ts.map +1 -0
- package/dist/error/plugin.d.ts +11 -0
- package/dist/error/plugin.d.ts.map +1 -0
- package/dist/error/request.d.ts +29 -0
- package/dist/error/request.d.ts.map +1 -0
- package/dist/error/response.d.ts +36 -0
- package/dist/error/response.d.ts.map +1 -0
- package/dist/index.d.ts +56 -11
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2034 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/en.d.ts +5 -0
- package/dist/locale/en.d.ts.map +1 -0
- package/dist/locale/index.d.ts +57 -0
- package/dist/locale/index.d.ts.map +1 -0
- package/dist/locale/types.d.ts +11 -0
- package/dist/locale/types.d.ts.map +1 -0
- package/dist/locale/zh.d.ts +5 -0
- package/dist/locale/zh.d.ts.map +1 -0
- package/dist/plugins/cache/adapters/indexeddb.d.ts +52 -0
- package/dist/plugins/cache/adapters/indexeddb.d.ts.map +1 -0
- package/dist/plugins/cache/adapters/memory.d.ts +60 -0
- package/dist/plugins/cache/adapters/memory.d.ts.map +1 -0
- package/dist/plugins/cache/adapters/web-storage.d.ts +43 -0
- package/dist/plugins/cache/adapters/web-storage.d.ts.map +1 -0
- package/dist/plugins/cache/decorators.d.ts +62 -0
- package/dist/plugins/cache/decorators.d.ts.map +1 -0
- package/dist/plugins/cache/index.d.ts +41 -0
- package/dist/plugins/cache/index.d.ts.map +1 -0
- package/dist/plugins/cache/key.d.ts +48 -0
- package/dist/plugins/cache/key.d.ts.map +1 -0
- package/dist/plugins/cache/manager.d.ts +124 -0
- package/dist/plugins/cache/manager.d.ts.map +1 -0
- package/dist/plugins/cache/plugin.d.ts +64 -0
- package/dist/plugins/cache/plugin.d.ts.map +1 -0
- package/dist/plugins/cache/type.d.ts +116 -0
- package/dist/plugins/cache/type.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +75 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +2265 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/interceptor/decorators.d.ts +44 -0
- package/dist/plugins/interceptor/decorators.d.ts.map +1 -0
- package/dist/plugins/interceptor/index.d.ts +31 -0
- package/dist/plugins/interceptor/index.d.ts.map +1 -0
- package/dist/plugins/interceptor/manager.d.ts +27 -0
- package/dist/plugins/interceptor/manager.d.ts.map +1 -0
- package/dist/plugins/interceptor/plugin.d.ts +65 -0
- package/dist/plugins/interceptor/plugin.d.ts.map +1 -0
- package/dist/plugins/interceptor/type.d.ts +45 -0
- package/dist/plugins/interceptor/type.d.ts.map +1 -0
- package/dist/plugins/pool/index.d.ts +26 -0
- package/dist/plugins/pool/index.d.ts.map +1 -0
- package/dist/plugins/pool/plugin.d.ts +83 -0
- package/dist/plugins/pool/plugin.d.ts.map +1 -0
- package/dist/plugins/pool/scheduler.d.ts +153 -0
- package/dist/plugins/pool/scheduler.d.ts.map +1 -0
- package/dist/plugins/pool/type.d.ts +38 -0
- package/dist/plugins/pool/type.d.ts.map +1 -0
- package/dist/plugins/react/index.d.ts +20 -0
- package/dist/plugins/react/index.d.ts.map +1 -0
- package/dist/plugins/react/index.js +145 -0
- package/dist/plugins/react/index.js.map +1 -0
- package/dist/plugins/react/plugin.d.ts +33 -0
- package/dist/plugins/react/plugin.d.ts.map +1 -0
- package/dist/plugins/react/type.d.ts +32 -0
- package/dist/plugins/react/type.d.ts.map +1 -0
- package/dist/plugins/transform/decorators.d.ts +54 -0
- package/dist/plugins/transform/decorators.d.ts.map +1 -0
- package/dist/plugins/transform/hydrate.d.ts +47 -0
- package/dist/plugins/transform/hydrate.d.ts.map +1 -0
- package/dist/plugins/transform/index.d.ts +41 -0
- package/dist/plugins/transform/index.d.ts.map +1 -0
- package/dist/plugins/transform/plugin.d.ts +20 -0
- package/dist/plugins/transform/plugin.d.ts.map +1 -0
- package/dist/plugins/transform/type.d.ts +67 -0
- package/dist/plugins/transform/type.d.ts.map +1 -0
- package/dist/plugins/validate/decorators.d.ts +24 -0
- package/dist/plugins/validate/decorators.d.ts.map +1 -0
- package/dist/plugins/validate/index.d.ts +40 -0
- package/dist/plugins/validate/index.d.ts.map +1 -0
- package/dist/plugins/validate/plugin.d.ts +13 -0
- package/dist/plugins/validate/plugin.d.ts.map +1 -0
- package/dist/plugins/validate/type.d.ts +54 -0
- package/dist/plugins/validate/type.d.ts.map +1 -0
- package/dist/plugins/version/decorators.d.ts +22 -0
- package/dist/plugins/version/decorators.d.ts.map +1 -0
- package/dist/plugins/version/index.d.ts +23 -0
- package/dist/plugins/version/index.d.ts.map +1 -0
- package/dist/plugins/version/plugin.d.ts +13 -0
- package/dist/plugins/version/plugin.d.ts.map +1 -0
- package/dist/plugins/version/type.d.ts +47 -0
- package/dist/plugins/version/type.d.ts.map +1 -0
- package/dist/plugins/vue/index.d.ts +21 -0
- package/dist/plugins/vue/index.d.ts.map +1 -0
- package/dist/plugins/vue/index.js +114 -0
- package/dist/plugins/vue/index.js.map +1 -0
- package/dist/plugins/vue/plugin.d.ts +15 -0
- package/dist/plugins/vue/plugin.d.ts.map +1 -0
- package/dist/plugins/vue/type.d.ts +34 -0
- package/dist/plugins/vue/type.d.ts.map +1 -0
- package/dist/strategies/index.d.ts +2 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +29 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/plain.d.ts +2 -0
- package/dist/strategies/plain.d.ts.map +1 -0
- package/dist/strategies/plain.js +23 -0
- package/dist/strategies/plain.js.map +1 -0
- package/dist/strategies/react.d.ts +2 -0
- package/dist/strategies/react.d.ts.map +1 -0
- package/dist/strategies/react.js +30 -0
- package/dist/strategies/react.js.map +1 -0
- package/dist/strategies/shared/adapter.d.ts +23 -0
- package/dist/strategies/shared/adapter.d.ts.map +1 -0
- package/dist/strategies/shared/dom.d.ts +53 -0
- package/dist/strategies/shared/dom.d.ts.map +1 -0
- package/dist/strategies/shared/error.d.ts +30 -0
- package/dist/strategies/shared/error.d.ts.map +1 -0
- package/dist/strategies/shared/method.d.ts +51 -0
- package/dist/strategies/shared/method.d.ts.map +1 -0
- package/dist/strategies/shared/public.d.ts +33 -0
- package/dist/strategies/shared/public.d.ts.map +1 -0
- package/dist/strategies/shared/queue.d.ts +30 -0
- package/dist/strategies/shared/queue.d.ts.map +1 -0
- package/dist/strategies/shared/retry.d.ts +51 -0
- package/dist/strategies/shared/retry.d.ts.map +1 -0
- package/dist/strategies/shared/state.d.ts +117 -0
- package/dist/strategies/shared/state.d.ts.map +1 -0
- package/dist/strategies/shared/timing.d.ts +53 -0
- package/dist/strategies/shared/timing.d.ts.map +1 -0
- package/dist/strategies/shared/watcher.d.ts +37 -0
- package/dist/strategies/shared/watcher.d.ts.map +1 -0
- package/dist/strategies/use-auto-request.d.ts +77 -0
- package/dist/strategies/use-auto-request.d.ts.map +1 -0
- package/dist/strategies/use-download.d.ts +103 -0
- package/dist/strategies/use-download.d.ts.map +1 -0
- package/dist/strategies/use-fetcher.d.ts +52 -0
- package/dist/strategies/use-fetcher.d.ts.map +1 -0
- package/dist/strategies/use-pagination.d.ts +101 -0
- package/dist/strategies/use-pagination.d.ts.map +1 -0
- package/dist/strategies/use-request.d.ts +50 -0
- package/dist/strategies/use-request.d.ts.map +1 -0
- package/dist/strategies/use-retriable-request.d.ts +46 -0
- package/dist/strategies/use-retriable-request.d.ts.map +1 -0
- package/dist/strategies/use-sse.d.ts +103 -0
- package/dist/strategies/use-sse.d.ts.map +1 -0
- package/dist/strategies/use-token-auth.d.ts +88 -0
- package/dist/strategies/use-token-auth.d.ts.map +1 -0
- package/dist/strategies/use-uploader.d.ts +88 -0
- package/dist/strategies/use-uploader.d.ts.map +1 -0
- package/dist/strategies/use-watcher.d.ts +69 -0
- package/dist/strategies/use-watcher.d.ts.map +1 -0
- package/dist/typings/adapter.d.ts +61 -0
- package/dist/typings/adapter.d.ts.map +1 -0
- package/dist/typings/api.d.ts +122 -0
- package/dist/typings/api.d.ts.map +1 -0
- package/dist/typings/args.d.ts +51 -0
- package/dist/typings/args.d.ts.map +1 -0
- package/dist/typings/index.d.ts +8 -12
- package/dist/typings/index.d.ts.map +1 -0
- package/dist/typings/meta.d.ts +44 -0
- package/dist/typings/meta.d.ts.map +1 -0
- package/dist/typings/plugin.d.ts +114 -0
- package/dist/typings/plugin.d.ts.map +1 -0
- package/dist/typings/response.d.ts +118 -0
- package/dist/typings/response.d.ts.map +1 -0
- package/dist/typings/server.d.ts +83 -0
- package/dist/typings/server.d.ts.map +1 -0
- package/dist/typings/stream.d.ts +150 -0
- package/dist/typings/stream.d.ts.map +1 -0
- package/dist/utils/download.d.ts +97 -0
- package/dist/utils/download.d.ts.map +1 -0
- package/dist/utils/emitter.d.ts +36 -0
- package/dist/utils/emitter.d.ts.map +1 -0
- package/dist/utils/index.d.ts +6 -1
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/is.d.ts +22 -0
- package/dist/utils/is.d.ts.map +1 -0
- package/dist/utils/object.d.ts +44 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/url.d.ts +44 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/package.json +90 -27
- package/README_EN.md +0 -607
- package/dist/cache/index.d.ts +0 -9
- package/dist/cache/indexDBCache.d.ts +0 -13
- package/dist/cache/localstorageCache.d.ts +0 -10
- package/dist/cache/memoryCache.d.ts +0 -11
- package/dist/core/index.d.ts +0 -4
- package/dist/core/snailApi.d.ts +0 -22
- package/dist/core/snailMethod.d.ts +0 -49
- package/dist/core/snailServer.d.ts +0 -35
- package/dist/core/snailSse.d.ts +0 -20
- package/dist/decorators/cache.d.ts +0 -15
- package/dist/decorators/method.d.ts +0 -38
- package/dist/decorators/sse.d.ts +0 -30
- package/dist/decorators/strategy.d.ts +0 -10
- package/dist/decorators/versioning.d.ts +0 -16
- package/dist/eventEmmit/index.d.ts +0 -1
- package/dist/eventEmmit/snail.event.d.ts +0 -10
- package/dist/snail-api.js +0 -4871
- package/dist/snail-api.umd.cjs +0 -4875
- package/dist/strategies/jwtStrategy.d.ts +0 -4
- package/dist/typings/api.option.d.ts +0 -10
- package/dist/typings/apiProxy.d.ts +0 -8
- package/dist/typings/cache.management.option.d.ts +0 -25
- package/dist/typings/cache.type.d.ts +0 -23
- package/dist/typings/content.type.d.ts +0 -5
- package/dist/typings/request.body.d.ts +0 -3
- package/dist/typings/response.data.d.ts +0 -13
- package/dist/typings/snail.event.d.ts +0 -6
- package/dist/typings/snail.method.d.ts +0 -14
- package/dist/typings/snail.option.d.ts +0 -16
- package/dist/typings/sse.d.ts +0 -15
- package/dist/typings/strategy.d.ts +0 -5
- package/dist/typings/versioning.option.d.ts +0 -30
- package/dist/utils/function.d.ts +0 -31
- package/dist/versioning/index.d.ts +0 -1
- package/dist/versioning/versioning.d.ts +0 -12
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SpecialResponseData, StandardResponseData, ResponseJsonData } from "./response.data";
|
|
2
|
-
import { MethodProxy } from "./snail.method";
|
|
3
|
-
export type StandardResponseWithoutData = Omit<StandardResponseData, "data">;
|
|
4
|
-
export type ApiProxy<T extends object, RT extends StandardResponseWithoutData | ResponseJsonData, DK extends string = "data"> = {
|
|
5
|
-
[K in keyof T]: T[K] extends (...args: infer A) => any ? <RD = unknown>() => MethodProxy<RD extends SpecialResponseData ? RD : RT & {
|
|
6
|
-
[KK in DK]: RD;
|
|
7
|
-
}, A extends any[] ? A : []> : T[K];
|
|
8
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AdapterConstructor } from "./cache.type";
|
|
2
|
-
export declare enum CacheType {
|
|
3
|
-
Memory = 0,
|
|
4
|
-
IndexDB = 1,
|
|
5
|
-
LocalStorage = 2,
|
|
6
|
-
Custom = 3
|
|
7
|
-
}
|
|
8
|
-
export type MemoryCacheOption = {
|
|
9
|
-
type: CacheType.Memory;
|
|
10
|
-
} & CacheCommonOption;
|
|
11
|
-
export type IndexDBCacheOption = {
|
|
12
|
-
type: CacheType.IndexDB;
|
|
13
|
-
} & CacheCommonOption;
|
|
14
|
-
export type LocalStorageCacheOption = {
|
|
15
|
-
type: CacheType.LocalStorage;
|
|
16
|
-
} & CacheCommonOption;
|
|
17
|
-
export type CustomCacheOption = {
|
|
18
|
-
type: CacheType.Custom;
|
|
19
|
-
adapter: AdapterConstructor;
|
|
20
|
-
options?: any;
|
|
21
|
-
} & CacheCommonOption;
|
|
22
|
-
export interface CacheCommonOption {
|
|
23
|
-
ttl?: number;
|
|
24
|
-
}
|
|
25
|
-
export type CacheManagementOption = MemoryCacheOption | IndexDBCacheOption | LocalStorageCacheOption | CustomCacheOption;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import MemoryCache from "../cache/memoryCache";
|
|
2
|
-
import LocalStorageCache from "../cache/localstorageCache";
|
|
3
|
-
import IndexDBCache from "../cache/indexDBCache";
|
|
4
|
-
export interface CacheSetData<T = any> {
|
|
5
|
-
data: T;
|
|
6
|
-
exp: number;
|
|
7
|
-
}
|
|
8
|
-
export type CacheGetData<T = any> = {
|
|
9
|
-
error: null;
|
|
10
|
-
data: T;
|
|
11
|
-
} | {
|
|
12
|
-
error: Error | Event;
|
|
13
|
-
data: null;
|
|
14
|
-
};
|
|
15
|
-
export type CacheStorage = MemoryCache | LocalStorageCache | IndexDBCache | CacheStorageAdapter;
|
|
16
|
-
export declare abstract class CacheStorageAdapter {
|
|
17
|
-
abstract get<T = any>(key: string): Promise<CacheGetData<T>>;
|
|
18
|
-
abstract set<T = any>(key: string, value: CacheSetData<T>): Promise<boolean>;
|
|
19
|
-
abstract delete(key: string): Promise<boolean>;
|
|
20
|
-
abstract clear(): Promise<boolean>;
|
|
21
|
-
abstract keys(): Promise<string[]>;
|
|
22
|
-
}
|
|
23
|
-
export type AdapterConstructor = new (options?: any) => CacheStorageAdapter;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface PaginationData<T> {
|
|
2
|
-
total: number;
|
|
3
|
-
page: number;
|
|
4
|
-
records: T[];
|
|
5
|
-
}
|
|
6
|
-
export type ResponseJsonData = Record<string, any> | object;
|
|
7
|
-
export type SpecialResponseData = string | ArrayBuffer | Blob | FormData;
|
|
8
|
-
export type StandardResponseData<T = any> = {
|
|
9
|
-
code: number;
|
|
10
|
-
message: string;
|
|
11
|
-
data: T;
|
|
12
|
-
};
|
|
13
|
-
export type ResponseData = ResponseJsonData | StandardResponseData | SpecialResponseData;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from "axios";
|
|
2
|
-
export type SnailSuccessListener<T = any> = (data?: T) => void;
|
|
3
|
-
export type SnailErrorListener<T = any, ErrorData = any> = (response?: AxiosResponse<T> | Error | ErrorData) => void;
|
|
4
|
-
export type SnailHitCacheListener<T = any> = (cacheData?: T) => void;
|
|
5
|
-
export type SnailFinishListener<T = any> = (data?: T) => void;
|
|
6
|
-
export type SnailEventListener<T = any, ErrorData = any> = SnailSuccessListener<T> | SnailErrorListener<T, ErrorData> | SnailHitCacheListener<T> | SnailFinishListener<T>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, Method, AxiosResponse } from "axios";
|
|
2
|
-
import { ResponseData, ResponseJsonData, SpecialResponseData } from "./response.data";
|
|
3
|
-
import { SnailMethod } from "../core";
|
|
4
|
-
export interface MethodSendOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
adapter?: AxiosRequestConfig["adapter"];
|
|
7
|
-
}
|
|
8
|
-
export interface MethodOption extends MethodSendOptions {
|
|
9
|
-
method: Method;
|
|
10
|
-
path: string;
|
|
11
|
-
}
|
|
12
|
-
export interface MethodProxy<RD extends ResponseData = ResponseJsonData, ArgsType extends any[] = []> extends SnailMethod<RD> {
|
|
13
|
-
send: (...args: ArgsType) => Promise<RD extends SpecialResponseData ? AxiosResponse<RD> : RD>;
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CacheManagementOption } from "./cache.management.option";
|
|
2
|
-
import { Method } from "axios";
|
|
3
|
-
export type CacheForType = "All" | "all" | Method | Method[];
|
|
4
|
-
export declare class SnailServerStatusCodeRuleOptions {
|
|
5
|
-
key?: string;
|
|
6
|
-
rule: (status: number) => boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface SnailOption {
|
|
9
|
-
name?: string;
|
|
10
|
-
baseURL?: string;
|
|
11
|
-
cacheManage?: CacheManagementOption;
|
|
12
|
-
cacheFor?: CacheForType;
|
|
13
|
-
enableLog?: boolean;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
serverStatusCodeRule?: SnailServerStatusCodeRuleOptions;
|
|
16
|
-
}
|
package/dist/typings/sse.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type SseProxy<T extends object> = {
|
|
2
|
-
[K in keyof T]: T[K] extends (...args: infer A) => any ? () => () => {
|
|
3
|
-
close: () => void;
|
|
4
|
-
eventSource: EventSource;
|
|
5
|
-
} : T[K];
|
|
6
|
-
};
|
|
7
|
-
export declare class SseEventListener {
|
|
8
|
-
eventName: string;
|
|
9
|
-
emit: (event: any) => any;
|
|
10
|
-
options: boolean | AddEventListenerOptions;
|
|
11
|
-
}
|
|
12
|
-
export declare class SseOptions {
|
|
13
|
-
withCredentials?: boolean;
|
|
14
|
-
version?: string;
|
|
15
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
-
export declare class Strategy {
|
|
3
|
-
applyRequest?(request: AxiosRequestConfig): AxiosRequestConfig | Promise<AxiosRequestConfig>;
|
|
4
|
-
applyResponse?(response: AxiosResponse): AxiosResponse | Promise<AxiosResponse>;
|
|
5
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare enum VersioningType {
|
|
2
|
-
Uri = 0,
|
|
3
|
-
Header = 1,
|
|
4
|
-
Query = 2,
|
|
5
|
-
Custom = 3
|
|
6
|
-
}
|
|
7
|
-
interface VersioningCommonOption {
|
|
8
|
-
defaultVersion: string;
|
|
9
|
-
}
|
|
10
|
-
export interface VersioningUriOption extends VersioningCommonOption {
|
|
11
|
-
type: VersioningType.Uri;
|
|
12
|
-
prefix?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface VersioningHeaderOption extends VersioningCommonOption {
|
|
15
|
-
type: VersioningType.Header;
|
|
16
|
-
header?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface VersioningQueryOption extends VersioningCommonOption {
|
|
19
|
-
type: VersioningType.Query;
|
|
20
|
-
key?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface VersioningCustomOption extends VersioningCommonOption {
|
|
23
|
-
type: VersioningType.Custom;
|
|
24
|
-
extractor: (requestOptions: unknown) => {
|
|
25
|
-
type: VersioningType;
|
|
26
|
-
result: string | Record<string, any>;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export type VersioningOption = VersioningUriOption | VersioningHeaderOption | VersioningQueryOption | VersioningCustomOption;
|
|
30
|
-
export {};
|
package/dist/utils/function.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
-
import { Strategy } from "../typings";
|
|
3
|
-
export declare function generateCacheKey(methodName: string, version: string | undefined, request: AxiosRequestConfig): Promise<string>;
|
|
4
|
-
export declare function generateShortUniqueHash(str: string): Promise<string>;
|
|
5
|
-
export declare function recordToString(record: Record<string, any>): string;
|
|
6
|
-
export declare function replacePlaceholders(route: string, values: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}): string;
|
|
9
|
-
export declare const resolveUrl: (url?: string) => string;
|
|
10
|
-
export declare function applyStrategies<T extends "request">(data: AxiosRequestConfig, strategies: Array<new () => Strategy>, type: T): Promise<AxiosRequestConfig>;
|
|
11
|
-
export declare function applyStrategies<T extends "response">(data: AxiosResponse, strategies: Array<new () => Strategy>, type: T): Promise<AxiosResponse>;
|
|
12
|
-
/**
|
|
13
|
-
* 一个无用函数,避免tsc报错
|
|
14
|
-
*/
|
|
15
|
-
export declare const SnailPass: (...args: any) => void;
|
|
16
|
-
interface IJson {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
}
|
|
19
|
-
interface IArgs {
|
|
20
|
-
params: IJson;
|
|
21
|
-
data: IJson;
|
|
22
|
-
querys: IJson;
|
|
23
|
-
}
|
|
24
|
-
export declare const buildRequestArgs: (target: any, propertyKey: string, args: any[]) => IArgs;
|
|
25
|
-
/**
|
|
26
|
-
* 判断响应的数据类型是否为 application/json
|
|
27
|
-
* @param {AxiosResponse} response - Axios 的响应对象
|
|
28
|
-
* @returns {boolean} - 如果响应的数据类型是 application/json 则返回 true,否则返回 false
|
|
29
|
-
*/
|
|
30
|
-
export declare function isSpecialResponse(response: AxiosResponse): boolean;
|
|
31
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './versioning';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { VersioningType, VersioningOption } from "../typings";
|
|
2
|
-
export interface VersioningResult {
|
|
3
|
-
type: VersioningType;
|
|
4
|
-
result: string | Record<string, any>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param version 版本号
|
|
9
|
-
* @param serverInstance 当前Server的实例
|
|
10
|
-
* @returns serverInstance上未配置版本管理器返回undefined, 否则返回版本管理器的结果
|
|
11
|
-
*/
|
|
12
|
-
export declare function applyVersioning(version: string, versioning: VersioningOption): VersioningResult | undefined;
|