tiny-oss 0.5.0 → 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/README.md +459 -52
- package/UPGRADING.md +151 -0
- package/dist/aws.d.ts +208 -0
- package/dist/azure.d.ts +204 -0
- package/dist/cos.d.ts +208 -0
- package/dist/index.d.ts +209 -0
- package/dist/obs.d.ts +208 -0
- package/dist/protocol.d.ts +271 -0
- package/dist/tiny-oss.aws.es.js +1052 -0
- package/dist/tiny-oss.aws.es.js.map +1 -0
- package/dist/tiny-oss.azure.es.js +882 -0
- package/dist/tiny-oss.azure.es.js.map +1 -0
- package/dist/tiny-oss.cos.es.js +984 -0
- package/dist/tiny-oss.cos.es.js.map +1 -0
- package/dist/tiny-oss.es.js +965 -0
- package/dist/tiny-oss.es.js.map +1 -0
- package/dist/tiny-oss.obs.es.js +1048 -0
- package/dist/tiny-oss.obs.es.js.map +1 -0
- package/dist/tiny-oss.protocol.es.js +588 -0
- package/dist/tiny-oss.protocol.es.js.map +1 -0
- package/package.json +78 -64
- package/dist/tiny-oss.js +0 -1642
- package/dist/tiny-oss.js.map +0 -1
- package/dist/tiny-oss.min.js +0 -35
- package/dist/tiny-oss.min.js.map +0 -1
- package/es/TinyOSS.js +0 -209
- package/es/index.js +0 -1
- package/es/utils/ajax.js +0 -61
- package/es/utils/index.js +0 -188
- package/lib/TinyOSS.js +0 -218
- package/lib/index.js +0 -3
- package/lib/utils/ajax.js +0 -66
- package/lib/utils/index.js +0 -203
- package/types/index.d.ts +0 -89
- package/vendor/digest.js +0 -390
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bind client options to an operation function, so callers don't have to
|
|
5
|
+
* repeat the credentials on every call. The returned function keeps the
|
|
6
|
+
* operation's original signature minus the leading options argument.
|
|
7
|
+
*
|
|
8
|
+
* Unlike a client object factory, this never references operations it
|
|
9
|
+
* isn't given, so tree shaking keeps working: importing `put` plus
|
|
10
|
+
* `bindOptions` still excludes the multipart code from the bundle.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { put, bindOptions } from 'tiny-oss';
|
|
14
|
+
* const upload = bindOptions(put, { accessKeyId, accessKeySecret, region, bucket });
|
|
15
|
+
* upload('hello.txt', blob);
|
|
16
|
+
*/
|
|
17
|
+
export declare function bindOptions<O, A extends unknown[], R>(operation: (options: O, ...args: A) => R, options: O): (...args: A) => R;
|
|
18
|
+
/**
|
|
19
|
+
* Abort a multipart upload.
|
|
20
|
+
*
|
|
21
|
+
* @param protocol provider protocol (OSS or COS)
|
|
22
|
+
*/
|
|
23
|
+
export declare function createAbortMultipartUpload(protocol: Protocol): (options: Options, objectName: string, uploadId: string, multipartOptions?: MultipartOptions) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Complete a multipart upload.
|
|
26
|
+
*
|
|
27
|
+
* @param protocol provider protocol (OSS or COS)
|
|
28
|
+
*/
|
|
29
|
+
export declare function createCompleteMultipartUpload(protocol: Protocol): (options: Options, objectName: string, uploadId: string, parts: PartInfo[], multipartOptions?: MultipartOptions) => Promise<CompleteMultipartUploadResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize a multipart upload.
|
|
32
|
+
*
|
|
33
|
+
* @param protocol provider protocol (OSS or COS)
|
|
34
|
+
*/
|
|
35
|
+
export declare function createInitMultipartUpload(protocol: Protocol): (options: Options, objectName: string, multipartOptions?: MultipartOptions) => Promise<InitMultipartUploadResult>;
|
|
36
|
+
/**
|
|
37
|
+
* List parts of a multipart upload.
|
|
38
|
+
*
|
|
39
|
+
* @param protocol provider protocol (OSS or COS)
|
|
40
|
+
*/
|
|
41
|
+
export declare function createListParts(protocol: Protocol): (options: Options, objectName: string, uploadId: string, query?: ListQuery, multipartOptions?: MultipartOptions) => Promise<ListPartsResult>;
|
|
42
|
+
/**
|
|
43
|
+
* List multipart uploads.
|
|
44
|
+
*
|
|
45
|
+
* The marker query key is provider-specific: OSS uses `marker`, COS uses
|
|
46
|
+
* `key-marker` (the protocol carries the right key).
|
|
47
|
+
*
|
|
48
|
+
* @param protocol provider protocol (OSS or COS)
|
|
49
|
+
*/
|
|
50
|
+
export declare function createListUploads(protocol: Protocol): (options: Options, query?: ListUploadsQuery, multipartOptions?: MultipartOptions) => Promise<ListUploadsResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Multipart upload with full workflow support.
|
|
53
|
+
*
|
|
54
|
+
* @param protocol provider protocol (OSS or COS)
|
|
55
|
+
* @param deps the protocol-bound multipart primitives
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMultipartUpload(protocol: Protocol, deps: MultipartUploadDeps): (options: Options, objectName: string, file: BlobLike | string, multipartOptions?: MultipartUploadOptions) => Promise<CompleteMultipartUploadResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Put an object.
|
|
60
|
+
*
|
|
61
|
+
* @param protocol provider protocol (OSS or COS)
|
|
62
|
+
*/
|
|
63
|
+
export declare function createPut(protocol: Protocol): (options: Options, objectName: string, data: BlobLike | string, putOptions?: PutOptions) => Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* Put a symlink. Only OSS supports symlinks; COS has no such API, so
|
|
66
|
+
* the operation rejects on protocols that do not support it (and the
|
|
67
|
+
* COS entry point does not export it).
|
|
68
|
+
*
|
|
69
|
+
* @param protocol provider protocol (OSS or COS)
|
|
70
|
+
*/
|
|
71
|
+
export declare function createPutSymlink(protocol: Protocol): (options: Options, objectName: string, targetObjectName: string) => Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Upload a part in a multipart upload.
|
|
74
|
+
*
|
|
75
|
+
* @param protocol provider protocol (OSS or COS)
|
|
76
|
+
*/
|
|
77
|
+
export declare function createUploadPart(protocol: Protocol): (options: Options, objectName: string, uploadId: string, partNo: number, data: BlobLike | string, start: number, end: number, multipartOptions?: MultipartOptions) => Promise<UploadPartResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Upload a part by copying from an existing object.
|
|
80
|
+
*
|
|
81
|
+
* @param protocol provider protocol (OSS or COS)
|
|
82
|
+
*/
|
|
83
|
+
export declare function createUploadPartCopy(protocol: Protocol): (options: Options, objectName: string, uploadId: string, partNo: number, range: string, sourceData: SourceData, copyOptions?: UploadPartCopyOptions) => Promise<UploadPartCopyResult>;
|
|
84
|
+
/** Total payload size in bytes, for transports that need it. Shared by every provider. */
|
|
85
|
+
export declare function dataSize(data: any): number | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Validate and fill in defaults for client options. The result is a
|
|
88
|
+
* plain object, so the functional API can be tree-shaken independently
|
|
89
|
+
* of the TinyOSS class. Shared by every provider; providers may pass
|
|
90
|
+
* their own defaults (e.g. OBS region 'cn-north-4').
|
|
91
|
+
*/
|
|
92
|
+
export declare function normalizeOptions(options?: Options, defaults?: Record<string, any>): Options;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve the per-request timeout, honoring a per-request override and
|
|
95
|
+
* tolerating string timeouts. Shared by every provider.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveTimeout(options: Options, fallback?: number): number | undefined;
|
|
98
|
+
export interface Checkpoint {
|
|
99
|
+
file: BlobLike | string;
|
|
100
|
+
name: string;
|
|
101
|
+
uploadId: string;
|
|
102
|
+
partSize: number;
|
|
103
|
+
parts: PartInfo[];
|
|
104
|
+
doneParts: PartInfo[];
|
|
105
|
+
}
|
|
106
|
+
export interface CompleteMultipartUploadResult {
|
|
107
|
+
name: string;
|
|
108
|
+
etag: string;
|
|
109
|
+
bucket?: string;
|
|
110
|
+
res?: any;
|
|
111
|
+
}
|
|
112
|
+
export interface InitMultipartUploadResult {
|
|
113
|
+
name: string;
|
|
114
|
+
uploadId: string;
|
|
115
|
+
res?: any;
|
|
116
|
+
}
|
|
117
|
+
export interface ListPartsResult {
|
|
118
|
+
isTruncated: boolean;
|
|
119
|
+
nextPartNumberMarker: number;
|
|
120
|
+
parts: Part[];
|
|
121
|
+
res?: any;
|
|
122
|
+
}
|
|
123
|
+
export interface ListQuery {
|
|
124
|
+
"max-parts"?: number;
|
|
125
|
+
"part-number-marker"?: number;
|
|
126
|
+
}
|
|
127
|
+
export interface ListUploadsQuery {
|
|
128
|
+
prefix?: string;
|
|
129
|
+
marker?: string;
|
|
130
|
+
"max-uploads"?: number;
|
|
131
|
+
"upload-id-marker"?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface ListUploadsResult {
|
|
134
|
+
uploads: UploadInfo[];
|
|
135
|
+
isTruncated: boolean;
|
|
136
|
+
nextKeyMarker?: string;
|
|
137
|
+
nextUploadIdMarker?: string;
|
|
138
|
+
res?: any;
|
|
139
|
+
}
|
|
140
|
+
export interface MultipartOptions {
|
|
141
|
+
timeout?: number;
|
|
142
|
+
headers?: Record<string, any>;
|
|
143
|
+
}
|
|
144
|
+
/** The multipart primitives multipartUpload drives, injected by the entry point. */
|
|
145
|
+
export interface MultipartUploadDeps {
|
|
146
|
+
initMultipartUpload: (options: Options, objectName: string, multipartOptions?: MultipartOptions) => Promise<InitMultipartUploadResult>;
|
|
147
|
+
uploadPart: (options: Options, objectName: string, uploadId: string, partNo: number, data: BlobLike | string, start: number, end: number, multipartOptions?: MultipartOptions) => Promise<UploadPartResult>;
|
|
148
|
+
completeMultipartUpload: (options: Options, objectName: string, uploadId: string, parts: PartInfo[], multipartOptions?: MultipartOptions) => Promise<CompleteMultipartUploadResult>;
|
|
149
|
+
}
|
|
150
|
+
export interface MultipartUploadOptions extends MultipartOptions {
|
|
151
|
+
parallel?: number;
|
|
152
|
+
partSize?: number;
|
|
153
|
+
checkpoint?: Checkpoint;
|
|
154
|
+
progress?: (percentage: number, checkpoint: Checkpoint, res?: any) => void;
|
|
155
|
+
meta?: Record<string, any>;
|
|
156
|
+
mime?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface ObjectCallback {
|
|
159
|
+
url: string;
|
|
160
|
+
host?: string;
|
|
161
|
+
body: string;
|
|
162
|
+
contentType?: string;
|
|
163
|
+
customValue?: object;
|
|
164
|
+
headers?: object;
|
|
165
|
+
}
|
|
166
|
+
export interface Options {
|
|
167
|
+
accessKeyId: string;
|
|
168
|
+
accessKeySecret: string;
|
|
169
|
+
stsToken?: string;
|
|
170
|
+
bucket?: string;
|
|
171
|
+
endpoint?: string;
|
|
172
|
+
region?: string;
|
|
173
|
+
internal?: boolean;
|
|
174
|
+
secure?: boolean;
|
|
175
|
+
timeout?: string | number;
|
|
176
|
+
cname?: boolean;
|
|
177
|
+
pathStyle?: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface Part {
|
|
180
|
+
PartNumber: number;
|
|
181
|
+
LastModified: string;
|
|
182
|
+
ETag: string;
|
|
183
|
+
Size: number;
|
|
184
|
+
}
|
|
185
|
+
export interface PartInfo {
|
|
186
|
+
number: number;
|
|
187
|
+
etag: string;
|
|
188
|
+
}
|
|
189
|
+
export interface Progress {
|
|
190
|
+
loaded: number;
|
|
191
|
+
total: number;
|
|
192
|
+
lengthComputable: boolean;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Provider-specific behavior collected in one table. Every operation is a
|
|
196
|
+
* factory over a protocol, so `src/index.ts` binds the OSS protocol and
|
|
197
|
+
* `src/cos/index.ts` binds the COS protocol; bundlers tree-shake the
|
|
198
|
+
* unused signer out of each entry.
|
|
199
|
+
*/
|
|
200
|
+
export interface Protocol {
|
|
201
|
+
/** Sign and send a single request through the configured transport. */
|
|
202
|
+
request: (options: Options, params: RequestParams) => Promise<any>;
|
|
203
|
+
/** Object metadata header prefix, e.g. 'x-oss-meta-' or 'x-cos-meta-'. */
|
|
204
|
+
metaPrefix: string;
|
|
205
|
+
/** Copy source header for uploadPartCopy. */
|
|
206
|
+
copySourceHeader: string;
|
|
207
|
+
/** Copy source range header for uploadPartCopy. */
|
|
208
|
+
copySourceRangeHeader: string;
|
|
209
|
+
/** listUploads marker query key: OSS 'marker', COS 'key-marker'. */
|
|
210
|
+
listUploadsMarkerKey: string;
|
|
211
|
+
/** Whether the provider has a symlink API (only OSS does). */
|
|
212
|
+
supportsSymlink: boolean;
|
|
213
|
+
/** Build a signed URL for download (or upload). */
|
|
214
|
+
signUrl: (options: Options, objectName: string, urlOptions?: SignatureUrlOptions) => string;
|
|
215
|
+
}
|
|
216
|
+
export interface PutOptions {
|
|
217
|
+
onprogress?: (e: Progress) => any;
|
|
218
|
+
}
|
|
219
|
+
/** Per-request parameters, shared by every provider's request implementation. */
|
|
220
|
+
export interface RequestParams {
|
|
221
|
+
verb: string;
|
|
222
|
+
objectName: string;
|
|
223
|
+
contentMd5?: string;
|
|
224
|
+
headers?: Record<string, any>;
|
|
225
|
+
subResource?: Record<string, any>;
|
|
226
|
+
data?: any;
|
|
227
|
+
timeout?: number;
|
|
228
|
+
onprogress?: (e: Progress) => any;
|
|
229
|
+
}
|
|
230
|
+
export interface ResponseHeaderType {
|
|
231
|
+
"content-type"?: string;
|
|
232
|
+
"content-disposition"?: string;
|
|
233
|
+
"cache-control"?: string;
|
|
234
|
+
"content-encoding"?: string;
|
|
235
|
+
"content-language"?: string;
|
|
236
|
+
}
|
|
237
|
+
export interface SignatureUrlOptions {
|
|
238
|
+
expires?: number;
|
|
239
|
+
method?: HTTPMethods;
|
|
240
|
+
"Content-Type"?: string;
|
|
241
|
+
process?: string;
|
|
242
|
+
response?: ResponseHeaderType;
|
|
243
|
+
callback?: ObjectCallback;
|
|
244
|
+
[key: string]: any;
|
|
245
|
+
}
|
|
246
|
+
export interface SourceData {
|
|
247
|
+
sourceKey: string;
|
|
248
|
+
sourceBucket?: string;
|
|
249
|
+
}
|
|
250
|
+
export interface UploadInfo {
|
|
251
|
+
uploadId: string;
|
|
252
|
+
name: string;
|
|
253
|
+
initiated: string;
|
|
254
|
+
}
|
|
255
|
+
export interface UploadPartCopyOptions extends MultipartOptions {
|
|
256
|
+
headers?: Record<string, any>;
|
|
257
|
+
}
|
|
258
|
+
export interface UploadPartCopyResult {
|
|
259
|
+
etag: string;
|
|
260
|
+
lastModified: string;
|
|
261
|
+
res?: any;
|
|
262
|
+
}
|
|
263
|
+
export interface UploadPartResult {
|
|
264
|
+
name: string;
|
|
265
|
+
etag: string;
|
|
266
|
+
res?: any;
|
|
267
|
+
}
|
|
268
|
+
export type BlobLike = Blob | ArrayBuffer | Uint8Array;
|
|
269
|
+
export type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT";
|
|
270
|
+
|
|
271
|
+
export {};
|