@kevisual/api 0.0.29 → 0.0.30
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/package.json
CHANGED
|
@@ -79,6 +79,14 @@ export class QueryResources {
|
|
|
79
79
|
body: formData,
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
+
async deleteFile(filepath: string, opts?: DataOpts): Promise<Result<any>> {
|
|
83
|
+
const url = `${this.prefix}${filepath}`;
|
|
84
|
+
return adapter({
|
|
85
|
+
url,
|
|
86
|
+
method: 'DELETE' as any,
|
|
87
|
+
headers: this.header(opts?.headers),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
export const getContentType = (filename: string): string => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { customAlphabet } from 'nanoid';
|
|
2
|
+
|
|
3
|
+
export const letter = 'abcdefghijklmnopqrstuvwxyz';
|
|
4
|
+
export const number = '0123456789';
|
|
5
|
+
const alphanumeric = `${letter}${number}`;
|
|
6
|
+
export const alphanumericWithDash = `${alphanumeric}-`;
|
|
7
|
+
export const uuid = customAlphabet(letter);
|
|
8
|
+
|
|
9
|
+
export const nanoid = customAlphabet(alphanumeric, 10);
|
|
10
|
+
|
|
11
|
+
export const nanoidWithDash = customAlphabet(alphanumericWithDash, 10);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 创建一个随机的 id,以字母开头的字符串
|
|
15
|
+
* @param number
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export const randomId = (number: number) => {
|
|
19
|
+
const _letter = uuid(1);
|
|
20
|
+
return `${_letter}${nanoid(number)}`;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const randomLetter = (number: number = 8, opts?: { before?: string; after?: string }) => {
|
|
24
|
+
const { before = '', after = '' } = opts || {};
|
|
25
|
+
return `${before}${uuid(number)}${after}`;
|
|
26
|
+
};
|