@ruan-cat/utils 2.0.1 → 3.0.1

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/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  import { OptionalKeysOf } from 'type-fest';
2
- import { Options } from 'unplugin-vue-router';
3
- import { RequiredPick } from 'type-plus';
4
- import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
5
- import { UseAxiosOptions, UseAxiosReturn } from '@vueuse/integrations/useAxios';
6
- export { UseAxiosOptions } from '@vueuse/integrations/useAxios';
7
2
 
8
3
  /**
9
4
  * rmmv特征基类
@@ -116,28 +111,6 @@ type Conditions = Condition[];
116
111
  declare function isConditionsEvery(conditions: Condition[]): boolean;
117
112
  declare function isConditionsSome(conditions: Condition[]): boolean;
118
113
 
119
- type GetRouteName = NonNullable<Options["getRouteName"]>;
120
- /**
121
- * 自主生成路由名称
122
- * @description
123
- * 对插件自动生成的路由名称,很不满意,不好看,容易引起阅读歧义。
124
- *
125
- * 故自定义。
126
- *
127
- * unplugin-vue-router 插件的 getRouteName 配置项
128
- *
129
- * FIXME: https://github.com/vitejs/vite/issues/5370
130
- *
131
- * 该函数设计出来是为了解决这个问题
132
- *
133
- * 在vite符号链接未解决时,应该直接使用js文件,如下:
134
- * import { getRouteName } from "@ruan-cat/utils/dist/index.js";
135
- *
136
- * 若已经彻底解决,请直接试图用来自符号链接的ts文件,如下:
137
- * import { getRouteName } from "@ruan-cat/utils";
138
- */
139
- declare const getRouteName: GetRouteName;
140
-
141
114
  /** 创建简单的异步任务 */
142
115
  declare function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T): (...args: any) => Promise<ReturnType<T>>;
143
116
  type SimpleAsyncTask = ReturnType<typeof generateSimpleAsyncTask>;
@@ -190,96 +163,6 @@ declare function executePromiseTasks(config: TasksConfig,
190
163
  */
191
164
  lastParams?: any): Promise<any>;
192
165
 
193
- /** 拓展的类型参数 用于约束必填的字段 */
194
- type KeyAxiosRequestConfig<D = any> = keyof AxiosRequestConfig<D>;
195
- /** 填写key值的帮助类型 */
196
- type KeyHelper<K extends KeyAxiosRequestConfig> = K;
197
- type RemoveUrl<T extends KeyAxiosRequestConfig> = Exclude<T, "url">;
198
- /**
199
- * 创建 AxiosRequestConfig 的各种变种类型
200
- * @description
201
- * 目前需要给 AxiosRequestConfig 添加必填属性
202
- *
203
- * 故需要本工具创建各种变种类型
204
- *
205
- * @example CreateAxiosRequestConfig<"url", D>
206
- */
207
- type CreateAxiosRequestConfig<K extends keyof Target, D = any, Target = AxiosRequestConfig<D>> = RequiredPick<Target, K>;
208
- /** 拓展K泛型后的类型 */
209
- interface StrictUseAxiosReturn<T,
210
- /**
211
- * 拓展的类型参数 用于约束必填的字段
212
- * @description
213
- * 这里不需要提供默认的取值
214
- */
215
- K extends KeyAxiosRequestConfig<D>, R, D> extends UseAxiosReturn<T, R, D> {
216
- /**
217
- * Manually call the axios request
218
- */
219
- execute: (url?: string | CreateAxiosRequestConfig<K, D>, config?: CreateAxiosRequestConfig<K, D>) => Promise<StrictUseAxiosReturn<T, K, R, D>>;
220
- }
221
- declare module "@vueuse/integrations/useAxios" {
222
- /**
223
- * 拓展类型参数后的 useAxios 函数
224
- * @description
225
- * 在我们的封装中 使用本类型
226
- */
227
- function useAxios<T = any,
228
- /** 拓展的类型参数 用于约束必填的字段 */
229
- K extends KeyAxiosRequestConfig<D> = "url", R = AxiosResponse<T>, D = any>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, K, R, D> & Promise<StrictUseAxiosReturn<T, K, R, D>>;
230
- }
231
- /** 包装器的参数 */
232
- interface UseAxiosWrapperParams<
233
- /**
234
- * 业务数据类型
235
- * @description
236
- * 必须先填写业务类型
237
- */
238
- T = any,
239
- /**
240
- * AxiosRequestConfig 默认必填的字段
241
- * @description
242
- * 用于约束其他类型的字段
243
- *
244
- * 然后才能填写必传的参数类型
245
- *
246
- * 默认为 必填url请求地址的 config 请求配置
247
- */
248
- K extends KeyAxiosRequestConfig<D> = "url",
249
- /**
250
- * UseAxiosOptions 的派生类型
251
- */
252
- UseAxiosOptionsLike extends UseAxiosOptions = UseAxiosOptions,
253
- /**
254
- * AxiosRequestConfig 用的类型
255
- * @description
256
- * 最后才可以传递此类型
257
- */
258
- D = any> {
259
- /**
260
- * axios的配置类型
261
- * @description
262
- * 默认为 必填url请求地址的 config 请求配置
263
- */
264
- config: CreateAxiosRequestConfig<K, D>;
265
- /**
266
- * axios实例
267
- * @description
268
- * 对于包装器函数而言 必须传递有意义的请求实例
269
- */
270
- instance: AxiosInstance;
271
- /** useAxios 的选项配置 */
272
- options: UseAxiosOptionsLike;
273
- }
274
- /**
275
- * useAxios 的包装函数
276
- * @description
277
- * 其本质是对 useAxios 函数的封装,仅仅是包装了参数层
278
- *
279
- * 预期设计成一个万能的 通用的请求函数
280
- */
281
- declare function useAxiosWrapper<T, K extends KeyAxiosRequestConfig, D = any>(params: UseAxiosWrapperParams): StrictUseAxiosReturn<T, K, AxiosResponse<T, any>, D> & Promise<StrictUseAxiosReturn<T, K, AxiosResponse<T, any>, D>>;
282
-
283
166
  /**
284
167
  * pnpm-workspace.yaml 文件的类型声明
285
168
  * @description
@@ -317,4 +200,4 @@ type Prettify<T> = {
317
200
  */
318
201
  type ToNumberLike<T extends number> = T | `${T}`;
319
202
 
320
- export { type AttributePromptTool, type BaseTask, type Condition, type Conditions, type CreateAxiosRequestConfig, type FunctionKeys, type HandleStrategy, type KeyAxiosRequestConfig, type KeyHelper, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type RemoveUrl, RmmvClass, type SimpleAsyncTask, type SingleTasks, type StrictUseAxiosReturn, type Task, type TaskType, type TasksConfig, type ToNumberLike, type UseAxiosWrapperParams, defaultHandleStrategy, type defaultHandleStrategy_FuncationName, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, getRouteName, initFlag, isConditionsEvery, isConditionsSome, rmmvClassExpandTools, runPromiseByConcurrency, runPromiseByQueue, taskTypes, useAxiosWrapper };
203
+ export { type AttributePromptTool, type BaseTask, type Condition, type Conditions, type FunctionKeys, type HandleStrategy, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, RmmvClass, type SimpleAsyncTask, type SingleTasks, type Task, type TaskType, type TasksConfig, type ToNumberLike, defaultHandleStrategy, type defaultHandleStrategy_FuncationName, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, initFlag, isConditionsEvery, isConditionsSome, rmmvClassExpandTools, runPromiseByConcurrency, runPromiseByQueue, taskTypes };