@edge-base/core 0.1.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/context.d.ts +36 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +60 -0
- package/dist/context.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/field-ops.d.ts +43 -0
- package/dist/field-ops.d.ts.map +1 -0
- package/dist/field-ops.js +61 -0
- package/dist/field-ops.js.map +1 -0
- package/dist/functions.d.ts +50 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +56 -0
- package/dist/functions.js.map +1 -0
- package/dist/generated/api-core.d.ts +503 -0
- package/dist/generated/api-core.d.ts.map +1 -0
- package/dist/generated/api-core.js +496 -0
- package/dist/generated/api-core.js.map +1 -0
- package/dist/generated/client-wrappers.d.ts +120 -0
- package/dist/generated/client-wrappers.d.ts.map +1 -0
- package/dist/generated/client-wrappers.js +219 -0
- package/dist/generated/client-wrappers.js.map +1 -0
- package/dist/http.d.ts +57 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +198 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/mime.d.ts +15 -0
- package/dist/mime.d.ts.map +1 -0
- package/dist/mime.js +84 -0
- package/dist/mime.js.map +1 -0
- package/dist/storage.d.ts +246 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +460 -0
- package/dist/storage.js.map +1 -0
- package/dist/table.d.ts +322 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +734 -0
- package/dist/table.js.map +1 -0
- package/dist/transport-adapter.d.ts +37 -0
- package/dist/transport-adapter.d.ts.map +1 -0
- package/dist/transport-adapter.js +70 -0
- package/dist/transport-adapter.js.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @edge-base/core — Shared modules used by both Client and Admin SDKs.
|
|
3
|
+
*: Core 모듈 (Client + Admin 공통)
|
|
4
|
+
*
|
|
5
|
+
* Modules: HttpClient, TableRef, StorageClient, FieldOps, Context, Errors, Types
|
|
6
|
+
*/
|
|
7
|
+
// HTTP
|
|
8
|
+
export { HttpClient } from './http.js';
|
|
9
|
+
// Table
|
|
10
|
+
export { TableRef, DocRef, DbRef, OrBuilder } from './table.js';
|
|
11
|
+
// Storage
|
|
12
|
+
export { StorageClient, StorageBucket, ResumableUploadError } from './storage.js';
|
|
13
|
+
// MIME
|
|
14
|
+
export { getMimeType } from './mime.js';
|
|
15
|
+
// Field Operations
|
|
16
|
+
export { increment, deleteField } from './field-ops.js';
|
|
17
|
+
// Context
|
|
18
|
+
export { ContextManager } from './context.js';
|
|
19
|
+
// Functions
|
|
20
|
+
export { FunctionsClient } from './functions.js';
|
|
21
|
+
// Generated Core
|
|
22
|
+
export { DefaultDbApi, ApiPaths } from './generated/api-core.js';
|
|
23
|
+
export { GeneratedAuthMethods, GeneratedStorageMethods, GeneratedAnalyticsMethods, } from './generated/client-wrappers.js';
|
|
24
|
+
// Transport Adapter
|
|
25
|
+
export { HttpClientAdapter, PublicHttpClientAdapter } from './transport-adapter.js';
|
|
26
|
+
// Errors
|
|
27
|
+
export { EdgeBaseError } from './errors.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO;AACP,OAAO,EAAE,UAAU,EAA0B,MAAM,WAAW,CAAC;AAE/D,QAAQ;AACR,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAkF,MAAM,YAAY,CAAC;AAEhJ,UAAU;AACV,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAwV,MAAM,cAAc,CAAC;AAExa,OAAO;AACP,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExD,UAAU;AACV,OAAO,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAEjE,YAAY;AACZ,OAAO,EAAE,eAAe,EAA4B,MAAM,gBAAgB,CAAC;AAE3E,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAA2C,MAAM,yBAAyB,CAAC;AAC1G,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AAExC,oBAAoB;AACpB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEpF,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/mime.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight MIME type detection from file extension.
|
|
3
|
+
* No external dependencies — covers ~50 common types.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Detect MIME type from a file key (path/name) based on its extension.
|
|
7
|
+
* Returns `'application/octet-stream'` if the extension is unknown.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* getMimeType('photo.jpg') // 'image/jpeg'
|
|
11
|
+
* getMimeType('docs/readme.md') // 'text/markdown'
|
|
12
|
+
* getMimeType('data.xyz') // 'application/octet-stream'
|
|
13
|
+
*/
|
|
14
|
+
export declare function getMimeType(key: string): string;
|
|
15
|
+
//# sourceMappingURL=mime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../src/mime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwEH;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/C"}
|
package/dist/mime.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight MIME type detection from file extension.
|
|
3
|
+
* No external dependencies — covers ~50 common types.
|
|
4
|
+
*/
|
|
5
|
+
const MIME_TYPES = {
|
|
6
|
+
// Images
|
|
7
|
+
jpg: 'image/jpeg',
|
|
8
|
+
jpeg: 'image/jpeg',
|
|
9
|
+
png: 'image/png',
|
|
10
|
+
gif: 'image/gif',
|
|
11
|
+
webp: 'image/webp',
|
|
12
|
+
svg: 'image/svg+xml',
|
|
13
|
+
ico: 'image/x-icon',
|
|
14
|
+
avif: 'image/avif',
|
|
15
|
+
bmp: 'image/bmp',
|
|
16
|
+
tiff: 'image/tiff',
|
|
17
|
+
tif: 'image/tiff',
|
|
18
|
+
// Video
|
|
19
|
+
mp4: 'video/mp4',
|
|
20
|
+
webm: 'video/webm',
|
|
21
|
+
mov: 'video/quicktime',
|
|
22
|
+
avi: 'video/x-msvideo',
|
|
23
|
+
mkv: 'video/x-matroska',
|
|
24
|
+
// Audio
|
|
25
|
+
mp3: 'audio/mpeg',
|
|
26
|
+
wav: 'audio/wav',
|
|
27
|
+
ogg: 'audio/ogg',
|
|
28
|
+
aac: 'audio/aac',
|
|
29
|
+
flac: 'audio/flac',
|
|
30
|
+
m4a: 'audio/mp4',
|
|
31
|
+
// Documents
|
|
32
|
+
pdf: 'application/pdf',
|
|
33
|
+
doc: 'application/msword',
|
|
34
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
35
|
+
xls: 'application/vnd.ms-excel',
|
|
36
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
37
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
38
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
39
|
+
// Text
|
|
40
|
+
txt: 'text/plain',
|
|
41
|
+
html: 'text/html',
|
|
42
|
+
htm: 'text/html',
|
|
43
|
+
css: 'text/css',
|
|
44
|
+
js: 'application/javascript',
|
|
45
|
+
mjs: 'application/javascript',
|
|
46
|
+
ts: 'application/typescript',
|
|
47
|
+
json: 'application/json',
|
|
48
|
+
xml: 'application/xml',
|
|
49
|
+
csv: 'text/csv',
|
|
50
|
+
md: 'text/markdown',
|
|
51
|
+
yaml: 'application/yaml',
|
|
52
|
+
yml: 'application/yaml',
|
|
53
|
+
// Archives
|
|
54
|
+
zip: 'application/zip',
|
|
55
|
+
gz: 'application/gzip',
|
|
56
|
+
tar: 'application/x-tar',
|
|
57
|
+
'7z': 'application/x-7z-compressed',
|
|
58
|
+
rar: 'application/vnd.rar',
|
|
59
|
+
// Fonts
|
|
60
|
+
woff: 'font/woff',
|
|
61
|
+
woff2: 'font/woff2',
|
|
62
|
+
ttf: 'font/ttf',
|
|
63
|
+
otf: 'font/otf',
|
|
64
|
+
// Other
|
|
65
|
+
wasm: 'application/wasm',
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Detect MIME type from a file key (path/name) based on its extension.
|
|
69
|
+
* Returns `'application/octet-stream'` if the extension is unknown.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* getMimeType('photo.jpg') // 'image/jpeg'
|
|
73
|
+
* getMimeType('docs/readme.md') // 'text/markdown'
|
|
74
|
+
* getMimeType('data.xyz') // 'application/octet-stream'
|
|
75
|
+
*/
|
|
76
|
+
export function getMimeType(key) {
|
|
77
|
+
const dotIndex = key.lastIndexOf('.');
|
|
78
|
+
if (dotIndex === -1 || dotIndex === key.length - 1) {
|
|
79
|
+
return 'application/octet-stream';
|
|
80
|
+
}
|
|
81
|
+
const ext = key.substring(dotIndex + 1).toLowerCase();
|
|
82
|
+
return MIME_TYPES[ext] || 'application/octet-stream';
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=mime.js.map
|
package/dist/mime.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime.js","sourceRoot":"","sources":["../src/mime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,GAA2B;IACzC,SAAS;IACT,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,YAAY;IAEjB,QAAQ;IACR,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,kBAAkB;IAEvB,QAAQ;IACR,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAEhB,YAAY;IACZ,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,yEAAyE;IAC/E,GAAG,EAAE,0BAA0B;IAC/B,IAAI,EAAE,mEAAmE;IACzE,GAAG,EAAE,+BAA+B;IACpC,IAAI,EAAE,2EAA2E;IAEjF,OAAO;IACP,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,wBAAwB;IAC5B,GAAG,EAAE,wBAAwB;IAC7B,EAAE,EAAE,wBAAwB;IAC5B,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,kBAAkB;IAEvB,WAAW;IACX,GAAG,EAAE,iBAAiB;IACtB,EAAE,EAAE,kBAAkB;IACtB,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,6BAA6B;IACnC,GAAG,EAAE,qBAAqB;IAE1B,QAAQ;IACR,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,YAAY;IACnB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IAEf,QAAQ;IACR,IAAI,EAAE,kBAAkB;CACzB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,QAAQ,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,OAAO,0BAA0B,CAAC;IACpC,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,0BAA0B,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage SDK — R2 File Storage client (M7, M17)
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // Upload
|
|
6
|
+
* const meta = await client.storage.bucket('avatars').upload('user-123.jpg', file);
|
|
7
|
+
*
|
|
8
|
+
* // Download
|
|
9
|
+
* const blob = await client.storage.bucket('avatars').download('user-123.jpg');
|
|
10
|
+
*
|
|
11
|
+
* // Signed URL
|
|
12
|
+
* const url = await client.storage.bucket('documents').createSignedUrl('report.pdf', { expiresIn: '1h' });
|
|
13
|
+
*
|
|
14
|
+
* // Resume upload (M17)
|
|
15
|
+
* try { await bucket.upload('large.zip', file); }
|
|
16
|
+
* catch (e) { if (e instanceof ResumableUploadError) await bucket.resumeUpload(e.key, e.uploadId); }
|
|
17
|
+
*/
|
|
18
|
+
import type { HttpClient } from './http.js';
|
|
19
|
+
import type { GeneratedDbApi } from './generated/api-core.js';
|
|
20
|
+
/**
|
|
21
|
+
* An upload Promise with a `.cancel()` method.
|
|
22
|
+
* Awaitable like a regular Promise; call `.cancel()` to abort the upload.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const task = bucket.upload('video.mp4', largeFile);
|
|
26
|
+
* cancelButton.onclick = () => task.cancel();
|
|
27
|
+
* const result = await task;
|
|
28
|
+
*/
|
|
29
|
+
export type UploadTask<T> = Promise<T> & {
|
|
30
|
+
cancel: () => void;
|
|
31
|
+
};
|
|
32
|
+
export interface FileInfo {
|
|
33
|
+
key: string;
|
|
34
|
+
size: number;
|
|
35
|
+
contentType: string;
|
|
36
|
+
etag: string;
|
|
37
|
+
uploadedAt: string;
|
|
38
|
+
uploadedBy: string | null;
|
|
39
|
+
customMetadata: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
export type FileMetadata = FileInfo;
|
|
42
|
+
export interface FileListResult {
|
|
43
|
+
files: FileInfo[];
|
|
44
|
+
cursor: string | null;
|
|
45
|
+
truncated: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface UploadOptions {
|
|
48
|
+
contentType?: string;
|
|
49
|
+
customMetadata?: Record<string, string>;
|
|
50
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}
|
|
53
|
+
export interface UploadProgress {
|
|
54
|
+
loaded: number;
|
|
55
|
+
total: number;
|
|
56
|
+
percent: number;
|
|
57
|
+
}
|
|
58
|
+
export interface DownloadOptions {
|
|
59
|
+
as?: 'blob' | 'arraybuffer' | 'stream' | 'text';
|
|
60
|
+
}
|
|
61
|
+
export interface SignedUrlOptions {
|
|
62
|
+
expiresIn?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SignedUploadUrlOptions {
|
|
65
|
+
expiresIn?: string;
|
|
66
|
+
maxFileSize?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface SignedUrlResult {
|
|
69
|
+
key: string;
|
|
70
|
+
url: string;
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
}
|
|
73
|
+
export interface DeleteManyResult {
|
|
74
|
+
deleted: string[];
|
|
75
|
+
failed: Array<{
|
|
76
|
+
key: string;
|
|
77
|
+
error: string;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
export interface SignedUploadUrlResult {
|
|
81
|
+
url: string;
|
|
82
|
+
expiresAt: string;
|
|
83
|
+
maxFileSize: string | null;
|
|
84
|
+
uploadedBy: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface ListOptions {
|
|
87
|
+
prefix?: string;
|
|
88
|
+
cursor?: string;
|
|
89
|
+
limit?: number;
|
|
90
|
+
}
|
|
91
|
+
export type StringFormat = 'raw' | 'base64' | 'base64url' | 'data_url';
|
|
92
|
+
/** M17: Resumable upload part info */
|
|
93
|
+
export interface UploadPartInfo {
|
|
94
|
+
partNumber: number;
|
|
95
|
+
etag: string;
|
|
96
|
+
}
|
|
97
|
+
/** M17: Upload parts query result */
|
|
98
|
+
export interface UploadPartsResult {
|
|
99
|
+
uploadId: string;
|
|
100
|
+
key: string;
|
|
101
|
+
parts: UploadPartInfo[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* M17: Error thrown when a multipart upload fails but can be resumed.
|
|
105
|
+
* Contains the uploadId and key needed to call resumeUpload().
|
|
106
|
+
*/
|
|
107
|
+
export declare class ResumableUploadError extends Error {
|
|
108
|
+
readonly key: string;
|
|
109
|
+
readonly uploadId: string;
|
|
110
|
+
readonly completedParts: UploadPartInfo[];
|
|
111
|
+
readonly failedPartNumber: number;
|
|
112
|
+
constructor(key: string, uploadId: string, completedParts: UploadPartInfo[], failedPartNumber: number, message: string);
|
|
113
|
+
}
|
|
114
|
+
export declare class StorageBucket {
|
|
115
|
+
private httpClient;
|
|
116
|
+
private bucketName;
|
|
117
|
+
private core?;
|
|
118
|
+
constructor(httpClient: HttpClient, bucketName: string, core?: GeneratedDbApi | undefined);
|
|
119
|
+
/**
|
|
120
|
+
* Upload a file (File, Blob, ArrayBuffer, or Uint8Array).
|
|
121
|
+
*
|
|
122
|
+
* Returns an `UploadTask` — awaitable like a regular Promise, but also
|
|
123
|
+
* exposes a `.cancel()` method to abort the upload mid-flight.
|
|
124
|
+
*
|
|
125
|
+
* `contentType` is auto-detected from the file extension when omitted.
|
|
126
|
+
*/
|
|
127
|
+
upload(key: string, data: File | Blob | ArrayBuffer | Uint8Array, options?: UploadOptions): UploadTask<FileInfo>;
|
|
128
|
+
/** Internal upload logic (separated from upload() for UploadTask wrapping). */
|
|
129
|
+
private _doUpload;
|
|
130
|
+
/**
|
|
131
|
+
* Upload a string in various formats.
|
|
132
|
+
* Returns an `UploadTask` with `.cancel()` support.
|
|
133
|
+
*
|
|
134
|
+
* Content type is auto-detected: data_url header > raw → text/plain > file extension.
|
|
135
|
+
*/
|
|
136
|
+
uploadString(key: string, value: string, format?: StringFormat, options?: UploadOptions): UploadTask<FileInfo>;
|
|
137
|
+
/**
|
|
138
|
+
* Download a file.
|
|
139
|
+
*
|
|
140
|
+
* NOTE: Direct HTTP — requires raw Response for blob/arraybuffer/stream conversion.
|
|
141
|
+
* Generated core's downloadFile() returns parsed JSON via transport adapter,
|
|
142
|
+
* which cannot provide raw Response access needed here.
|
|
143
|
+
*/
|
|
144
|
+
download(key: string, options?: DownloadOptions): Promise<Blob | ArrayBuffer | ReadableStream | string>;
|
|
145
|
+
/**
|
|
146
|
+
* Get the public URL of a file (synchronous, just URL calculation).
|
|
147
|
+
*/
|
|
148
|
+
getUrl(key: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Create a signed download URL with expiration.
|
|
151
|
+
*/
|
|
152
|
+
createSignedUrl(key: string, options?: SignedUrlOptions): Promise<string>;
|
|
153
|
+
/**
|
|
154
|
+
* Create signed download URLs for multiple files in a single request.
|
|
155
|
+
*/
|
|
156
|
+
createSignedUrls(keys: string[], options?: SignedUrlOptions): Promise<SignedUrlResult[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Create a signed upload URL for direct R2 upload.
|
|
159
|
+
*/
|
|
160
|
+
createSignedUploadUrl(key: string, options?: SignedUploadUrlOptions): Promise<SignedUploadUrlResult>;
|
|
161
|
+
/**
|
|
162
|
+
* Get file metadata.
|
|
163
|
+
*/
|
|
164
|
+
getMetadata(key: string): Promise<FileMetadata>;
|
|
165
|
+
/**
|
|
166
|
+
* Update file metadata (custom metadata, content type).
|
|
167
|
+
*/
|
|
168
|
+
updateMetadata(key: string, metadata: {
|
|
169
|
+
customMetadata?: Record<string, string>;
|
|
170
|
+
contentType?: string;
|
|
171
|
+
}): Promise<FileMetadata>;
|
|
172
|
+
/**
|
|
173
|
+
* Check if a file exists.
|
|
174
|
+
*
|
|
175
|
+
* NOTE: Direct HTTP — uses HEAD request. Generated core has no HEAD method support;
|
|
176
|
+
* headRaw() is the only way to check existence without downloading the file.
|
|
177
|
+
*/
|
|
178
|
+
exists(key: string): Promise<boolean>;
|
|
179
|
+
/**
|
|
180
|
+
* Delete a file.
|
|
181
|
+
*/
|
|
182
|
+
delete(key: string): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Delete multiple files in a single request.
|
|
185
|
+
*/
|
|
186
|
+
deleteMany(keys: string[]): Promise<DeleteManyResult>;
|
|
187
|
+
/**
|
|
188
|
+
* List files in the bucket.
|
|
189
|
+
*
|
|
190
|
+
* NOTE: Direct HTTP — generated listFiles(bucket) accepts no query params,
|
|
191
|
+
* but this method needs prefix/cursor/limit filtering. Codegen limitation.
|
|
192
|
+
*/
|
|
193
|
+
list(options?: ListOptions): Promise<FileListResult>;
|
|
194
|
+
private base64ToBytes;
|
|
195
|
+
/** NOTE: Direct HTTP — FormData upload requires raw fetch for multipart/form-data boundary handling. */
|
|
196
|
+
private uploadFormData;
|
|
197
|
+
private multipartUpload;
|
|
198
|
+
/**
|
|
199
|
+
* Start a multipart upload and return the upload ID so callers can resume it later.
|
|
200
|
+
*/
|
|
201
|
+
initiateResumableUpload(key: string, contentType?: string): Promise<string>;
|
|
202
|
+
/**
|
|
203
|
+
* M17: Get uploaded parts for an in-progress multipart upload.
|
|
204
|
+
* Use this to check which parts have been uploaded before calling resumeUpload().
|
|
205
|
+
*
|
|
206
|
+
* NOTE: Direct HTTP — generated getUploadParts(bucket, uploadId) accepts no query params,
|
|
207
|
+
* but this method needs { key } query parameter. Codegen limitation.
|
|
208
|
+
*/
|
|
209
|
+
getUploadParts(key: string, uploadId: string): Promise<UploadPartsResult>;
|
|
210
|
+
/**
|
|
211
|
+
* M17: Resume a previously failed multipart upload.
|
|
212
|
+
* Queries the server for completed parts, then uploads only the remaining chunks.
|
|
213
|
+
* Returns an `UploadTask` with `.cancel()` support.
|
|
214
|
+
*/
|
|
215
|
+
resumeUpload(key: string, uploadId: string, data: File | Blob | ArrayBuffer | Uint8Array, options?: UploadOptions): UploadTask<FileInfo>;
|
|
216
|
+
/** Internal resume upload logic. */
|
|
217
|
+
private _doResumeUpload;
|
|
218
|
+
}
|
|
219
|
+
export declare class StorageClient {
|
|
220
|
+
private httpClient;
|
|
221
|
+
private core?;
|
|
222
|
+
constructor(httpClient: HttpClient, core?: GeneratedDbApi | undefined);
|
|
223
|
+
/**
|
|
224
|
+
* Get a bucket reference.
|
|
225
|
+
* @example
|
|
226
|
+
* const avatarsBucket = client.storage.bucket('avatars');
|
|
227
|
+
*/
|
|
228
|
+
bucket(name: string): StorageBucket;
|
|
229
|
+
/**
|
|
230
|
+
* Convenience: get public URL for a file without creating a bucket reference.
|
|
231
|
+
* @example
|
|
232
|
+
* const url = admin.storage.getUrl('avatars', 'profile.png');
|
|
233
|
+
*/
|
|
234
|
+
getUrl(bucketName: string, key: string): string;
|
|
235
|
+
/**
|
|
236
|
+
* Convenience: upload a file without creating a bucket reference.
|
|
237
|
+
* @example
|
|
238
|
+
* await admin.storage.upload('avatars', 'profile.png', blob);
|
|
239
|
+
*/
|
|
240
|
+
upload(bucketName: string, key: string, data: File | Blob | ArrayBuffer | Uint8Array, options?: UploadOptions): UploadTask<FileInfo>;
|
|
241
|
+
/**
|
|
242
|
+
* Convenience: delete a file without creating a bucket reference.
|
|
243
|
+
*/
|
|
244
|
+
delete(bucketName: string, key: string): Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB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