@kevisual/api 0.0.29 → 0.0.31

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/api",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "",
5
5
  "main": "mod.ts",
6
6
  "scripts": {
@@ -74,11 +74,26 @@ export class QueryResources {
74
74
  return adapter({
75
75
  url: url.toString(),
76
76
  headers: { ...this.header(opts?.headers, false) },
77
+ params: {
78
+ hash: hash,
79
+ },
77
80
  isPostFile: true,
78
81
  method: 'POST',
79
82
  body: formData,
80
83
  });
81
84
  }
85
+ async createFolder(folderpath: string, opts?: DataOpts): Promise<Result<any>> {
86
+ const filepath = folderpath.endsWith('/') ? `${folderpath}keep.txt` : `${folderpath}/keep.txt`;
87
+ return this.uploadFile(filepath, '文件夹占位,其他文件不存在,文件夹不存在,如果有其他文件夹,删除当前文件夹占位文件即可', opts);
88
+ }
89
+ async deleteFile(filepath: string, opts?: DataOpts): Promise<Result<any>> {
90
+ const url = `${this.prefix}${filepath}`;
91
+ return adapter({
92
+ url,
93
+ method: 'DELETE' as any,
94
+ headers: this.header(opts?.headers),
95
+ });
96
+ }
82
97
  }
83
98
 
84
99
  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
+ };