@kevisual/oss 0.0.12 → 0.0.13

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.
@@ -1,38 +1,217 @@
1
- import { O as OssBase } from '../index-BGsBfWH-.js';
2
- export { b as ListDirectoryObject, L as ListFileObject, c as ListObjectResult, d as OssBaseOperation, a as OssBaseOptions, e as OssService, S as StatObjectResult, U as UploadedObjectInfo } from '../index-BGsBfWH-.js';
3
- export { ConfigOssService } from './config.js';
4
- import * as stream from 'stream';
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { Client, ItemBucketMetadata } from 'minio';
5
4
  import { ServerResponse } from 'node:http';
6
- import 'minio';
7
- import 'minio/dist/esm/internal/type.mjs';
8
5
 
6
+ export type UploadedObjectInfo = {
7
+ etag: string;
8
+ lastModified?: Date;
9
+ size?: number;
10
+ versionId: string;
11
+ metadata?: ItemBucketMetadata;
12
+ };
13
+ export type StatObjectResult = {
14
+ size: number;
15
+ etag: string;
16
+ lastModified: Date;
17
+ metaData: ItemBucketMetadata;
18
+ versionId?: string | null;
19
+ };
20
+ export type ListFileObject = {
21
+ name: string;
22
+ size: number;
23
+ lastModified: Date;
24
+ etag: string;
25
+ };
26
+ export type ListDirectoryObject = {
27
+ prefix: string;
28
+ size: number;
29
+ };
30
+ export type ListObjectResult = ListFileObject | ListDirectoryObject;
31
+ export interface OssBaseOperation {
32
+ prefix: string;
33
+ setPrefix(prefix: string): void;
34
+ /**
35
+ * 获取对象
36
+ * @param objectName 对象名
37
+ */
38
+ getObject(objectName: string): Promise<any>;
39
+ /**
40
+ * 上传对象
41
+ * @param objectName 对象名
42
+ * @param data 数据
43
+ */
44
+ putObject(objectName: string, data: Buffer | string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
45
+ /**
46
+ * 上传文件
47
+ * @param objectName 对象名
48
+ * @param filePath 文件路径
49
+ */
50
+ fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
51
+ /**
52
+ * 获取对象信息
53
+ * @param objectName 对象名
54
+ */
55
+ statObject(objectName: string): Promise<StatObjectResult>;
56
+ /**
57
+ * 删除对象
58
+ * @param objectName 对象名
59
+ */
60
+ deleteObject(objectName: string): Promise<any>;
61
+ /**
62
+ * 列出对象
63
+ * @param objectName 对象名
64
+ * @param opts 选项
65
+ * @param opts.recursive 是否递归
66
+ * @param opts.startAfter 开始位置
67
+ */
68
+ listObjects(objectName: string, opts?: {
69
+ /**
70
+ * 是否递归
71
+ */
72
+ recursive?: boolean;
73
+ /**
74
+ * 开始位置
75
+ */
76
+ startAfter?: string;
77
+ }): Promise<ListObjectResult[]>;
78
+ /**
79
+ * 复制对象
80
+ * @param sourceObject 源对象
81
+ * @param targetObject 目标对象
82
+ */
83
+ copyObject: Client["copyObject"];
84
+ }
85
+ export interface OssService extends OssBaseOperation {
86
+ owner: string;
87
+ }
88
+ export type OssBaseOptions<T = {
89
+ [key: string]: any;
90
+ }> = {
91
+ /**
92
+ * 已经初始化好的minio client
93
+ */
94
+ client: Client;
95
+ /**
96
+ * 桶名
97
+ */
98
+ bucketName: string;
99
+ /**
100
+ * 前缀
101
+ */
102
+ prefix?: string;
103
+ } & T;
104
+ export declare class OssBase implements OssBaseOperation {
105
+ client?: Client;
106
+ bucketName: string;
107
+ prefix: string;
108
+ /**
109
+ * 计算字符串或者对象的的md5值
110
+ */
111
+ hash: (str: string | Buffer | Object) => string;
112
+ constructor(opts: OssBaseOptions);
113
+ setPrefix(prefix: string): void;
114
+ getObject(objectName: string): Promise<import("stream").Readable>;
115
+ getJson(objectName: string): Promise<Record<string, any>>;
116
+ /**
117
+ * 上传文件, 当是流的时候,中断之后的etag会变,所以传递的时候不要嵌套async await,例如 busboy 监听文件流内部的时候,不要用check
118
+ * @param objectName
119
+ * @param data
120
+ * @param metaData
121
+ * @param options 如果文件本身存在,则复制原有的meta的内容
122
+ * @returns
123
+ */
124
+ putObject(objectName: string, data: Buffer | string | Object, metaData?: ItemBucketMetadata, opts?: {
125
+ check?: boolean;
126
+ isStream?: boolean;
127
+ size?: number;
128
+ }): Promise<import("node_modules/minio/dist/main/internal/type.js").UploadedObjectInfo>;
129
+ deleteObject(objectName: string): Promise<void>;
130
+ listObjects<IS_FILE = false>(objectName: string, opts?: {
131
+ recursive?: boolean;
132
+ startAfter?: string;
133
+ }): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
134
+ fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<any>;
135
+ /**
136
+ * 获取完整的对象名称
137
+ * @param objectName
138
+ * @returns
139
+ */
140
+ getObjectName(objectName: string): Promise<string>;
141
+ statObject(objectName: string, checkFile?: boolean): Promise<import("minio").BucketItemStat>;
142
+ /**
143
+ * 检查文件hash是否一致
144
+ * @param objectName
145
+ * @param hash
146
+ * @returns
147
+ */
148
+ checkObjectHash(objectName: string, hash: string, meta?: ItemBucketMetadata): Promise<{
149
+ success: boolean;
150
+ metaData: ItemBucketMetadata | null;
151
+ obj: any;
152
+ equalMeta?: boolean;
153
+ }>;
154
+ getMetadata(pathname: string, meta?: ItemBucketMetadata): ItemBucketMetadata;
155
+ copyObject(sourceObject: any, targetObject: any): Promise<import("node_modules/minio/dist/main/internal/type.js").CopyObjectResult>;
156
+ replaceObject(objectName: string, meta: {
157
+ [key: string]: string;
158
+ }): Promise<import("node_modules/minio/dist/main/internal/type.js").CopyObjectResult>;
159
+ static create<T extends OssBase, U>(this: new (opts: OssBaseOptions<U>) => T, opts: OssBaseOptions<U>): T;
160
+ static fromBase<T extends OssBase, U>(this: new (opts: OssBaseOptions<U>) => T, createOpts: {
161
+ oss: OssBase;
162
+ opts: Partial<OssBaseOptions<U>>;
163
+ }): T;
164
+ }
165
+ export declare class ConfigOssService extends OssBase implements OssService {
166
+ owner: string;
167
+ constructor(opts: OssBaseOptions<{
168
+ owner: string;
169
+ }>);
170
+ listAllFile(): Promise<ListFileObject[]>;
171
+ listAll(): Promise<ListObjectResult[]>;
172
+ configMap: Map<string, any>;
173
+ keys: string[];
174
+ getAllConfigJson(): Promise<ListFileObject[]>;
175
+ isEndWithJson(string: string): boolean;
176
+ putJsonObject(key: string, data: any): Promise<import("node_modules/minio/dist/main/internal/type.js").UploadedObjectInfo>;
177
+ getObjectList(objectNameList: string[]): Promise<Map<string, Record<string, any>>>;
178
+ getList(): Promise<{
179
+ list: {
180
+ key: string;
181
+ name: string;
182
+ size: number;
183
+ lastModified: Date;
184
+ etag: string;
185
+ }[];
186
+ keys: string[];
187
+ keyEtagMap: Map<string, string>;
188
+ }>;
189
+ }
9
190
  /**
10
191
  * 过滤 metaData 中的 key, 去除 password, accesskey, secretkey,
11
192
  * 并返回过滤后的 metaData
12
193
  * @param metaData
13
194
  * @returns
14
195
  */
15
- declare const filterMetaDataKeys: (metaData: Record<string, string>, clearKeys?: string[]) => Record<string, string>;
16
- type SendObjectOptions = {
17
- res: ServerResponse;
18
- client: OssBase;
19
- objectName: string;
20
- isDownload?: boolean;
196
+ export declare const filterMetaDataKeys: (metaData: Record<string, string>, clearKeys?: string[]) => Record<string, string>;
197
+ export type SendObjectOptions = {
198
+ res: ServerResponse;
199
+ client: OssBase;
200
+ objectName: string;
201
+ isDownload?: boolean;
21
202
  };
22
- declare const NotFoundFile: (res: ServerResponse, msg?: string, code?: number) => void;
23
- declare const sendObject: ({ res, objectName, client, isDownload }: SendObjectOptions) => Promise<void>;
24
- declare const downloadObject: ({ objectName, client, filePath }: Pick<SendObjectOptions, "objectName" | "client"> & {
25
- filePath: string;
26
- }) => Promise<stream.Readable>;
27
-
203
+ export declare const NotFoundFile: (res: ServerResponse, msg?: string, code?: number) => void;
204
+ export declare const sendObject: ({ res, objectName, client, isDownload }: SendObjectOptions) => Promise<void>;
205
+ export declare const downloadObject: ({ objectName, client, filePath }: Pick<SendObjectOptions, "objectName" | "client"> & {
206
+ filePath: string;
207
+ }) => Promise<import("stream").Readable>;
28
208
  /**
29
209
  * 计算字符串的md5值
30
210
  * @param str
31
211
  * @returns
32
212
  */
33
- declare const hash: (str: string | Buffer | Object) => string;
34
- declare const hashSringify: (str: Object) => string;
35
-
36
- declare const getContentType: (filePath: string) => any;
213
+ export declare const hash: (str: string | Buffer | Object) => string;
214
+ export declare const hashSringify: (str: Object) => string;
215
+ export declare const getContentType: (filePath: string) => any;
37
216
 
38
- export { NotFoundFile, OssBase, downloadObject, filterMetaDataKeys, getContentType, hash, hashSringify, sendObject };
217
+ export {};