@moogodev/client 0.0.0-stage → 0.1.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/dist/client.d.ts +155 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +546 -0
- package/dist/errors.d.ts +84 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +246 -0
- package/dist/esm/client.d.ts +155 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +541 -0
- package/dist/esm/errors.d.ts +84 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +220 -0
- package/dist/esm/index.d.ts +35 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/types.d.ts +183 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.mjs +35 -0
- package/dist/types.d.ts +183 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/package.json +43 -3
- package/src/client.ts +720 -0
- package/src/errors.ts +259 -0
- package/src/index.test.ts +277 -0
- package/src/index.ts +91 -0
- package/src/types.ts +206 -0
- package/tsconfig.json +23 -0
- package/vitest.config.ts +9 -0
- package/README.md +0 -3
package/dist/errors.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Error classes for Moogo client.
|
|
4
|
+
* All errors follow the API error codes.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UnauthorizedError = exports.InvalidMethodError = exports.InvalidExpiresInError = exports.InvalidBodyError = exports.RateLimitedError = exports.CredentialLimitError = exports.BucketNotFoundError = exports.NotFoundError = exports.LinkExpiredError = exports.ProjectPausedError = exports.QuotaExceededError = exports.UnsupportedMediaTypeError = exports.ObjectTooLargeError = exports.BodyTooLargeError = exports.InvalidOrderError = exports.InvalidCursorError = exports.InvalidBucketError = exports.KeyTakenError = exports.KeyTooLongError = exports.InvalidKeyError = exports.MissingKeyError = exports.MoogoError = void 0;
|
|
8
|
+
exports.createErrorFromResponse = createErrorFromResponse;
|
|
9
|
+
class MoogoError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
status;
|
|
12
|
+
detail;
|
|
13
|
+
constructor(code, message, status, detail) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'MoogoError';
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.detail = detail;
|
|
19
|
+
Object.setPrototypeOf(this, MoogoError.prototype);
|
|
20
|
+
}
|
|
21
|
+
static fromResponse(response, data) {
|
|
22
|
+
const error = data?.error;
|
|
23
|
+
if (error) {
|
|
24
|
+
return new MoogoError(error.code, error.message, response.status, error.detail);
|
|
25
|
+
}
|
|
26
|
+
return new MoogoError('unknown_error', `HTTP ${response.status}: ${response.statusText}`, response.status);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.MoogoError = MoogoError;
|
|
30
|
+
/** 400 - Missing or invalid object key */
|
|
31
|
+
class MissingKeyError extends MoogoError {
|
|
32
|
+
constructor(detail) {
|
|
33
|
+
super('missing_key', 'No object key in the path', 400, detail);
|
|
34
|
+
this.name = 'MissingKeyError';
|
|
35
|
+
Object.setPrototypeOf(this, MissingKeyError.prototype);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MissingKeyError = MissingKeyError;
|
|
39
|
+
class InvalidKeyError extends MoogoError {
|
|
40
|
+
constructor(detail) {
|
|
41
|
+
super('invalid_key', 'Key contains invalid characters', 400, detail);
|
|
42
|
+
this.name = 'InvalidKeyError';
|
|
43
|
+
Object.setPrototypeOf(this, InvalidKeyError.prototype);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.InvalidKeyError = InvalidKeyError;
|
|
47
|
+
class KeyTooLongError extends MoogoError {
|
|
48
|
+
constructor(detail) {
|
|
49
|
+
super('key_too_long', 'Object key exceeds maximum length', 400, detail);
|
|
50
|
+
this.name = 'KeyTooLongError';
|
|
51
|
+
Object.setPrototypeOf(this, KeyTooLongError.prototype);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.KeyTooLongError = KeyTooLongError;
|
|
55
|
+
class KeyTakenError extends MoogoError {
|
|
56
|
+
constructor(detail) {
|
|
57
|
+
super('key_taken', 'An object with that key already exists', 409, detail);
|
|
58
|
+
this.name = 'KeyTakenError';
|
|
59
|
+
Object.setPrototypeOf(this, KeyTakenError.prototype);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.KeyTakenError = KeyTakenError;
|
|
63
|
+
class InvalidBucketError extends MoogoError {
|
|
64
|
+
constructor(detail) {
|
|
65
|
+
super('invalid_bucket', 'Bucket name is not allowed or invalid', 400, detail);
|
|
66
|
+
this.name = 'InvalidBucketError';
|
|
67
|
+
Object.setPrototypeOf(this, InvalidBucketError.prototype);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.InvalidBucketError = InvalidBucketError;
|
|
71
|
+
class InvalidCursorError extends MoogoError {
|
|
72
|
+
constructor(detail) {
|
|
73
|
+
super('invalid_cursor', 'Cursor is malformed or belongs to a different listing', 400, detail);
|
|
74
|
+
this.name = 'InvalidCursorError';
|
|
75
|
+
Object.setPrototypeOf(this, InvalidCursorError.prototype);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.InvalidCursorError = InvalidCursorError;
|
|
79
|
+
class InvalidOrderError extends MoogoError {
|
|
80
|
+
constructor(detail) {
|
|
81
|
+
super('invalid_order', 'Unknown order or direction', 400, detail);
|
|
82
|
+
this.name = 'InvalidOrderError';
|
|
83
|
+
Object.setPrototypeOf(this, InvalidOrderError.prototype);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.InvalidOrderError = InvalidOrderError;
|
|
87
|
+
class BodyTooLargeError extends MoogoError {
|
|
88
|
+
constructor(detail) {
|
|
89
|
+
super('body_too_large', 'Request body exceeded the JSON or upload cap', 413, detail);
|
|
90
|
+
this.name = 'BodyTooLargeError';
|
|
91
|
+
Object.setPrototypeOf(this, BodyTooLargeError.prototype);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.BodyTooLargeError = BodyTooLargeError;
|
|
95
|
+
class ObjectTooLargeError extends MoogoError {
|
|
96
|
+
constructor(detail) {
|
|
97
|
+
super('object_too_large', 'Object over the bucket max size', 413, detail);
|
|
98
|
+
this.name = 'ObjectTooLargeError';
|
|
99
|
+
Object.setPrototypeOf(this, ObjectTooLargeError.prototype);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ObjectTooLargeError = ObjectTooLargeError;
|
|
103
|
+
class UnsupportedMediaTypeError extends MoogoError {
|
|
104
|
+
constructor(detail) {
|
|
105
|
+
super('unsupported_media_type', 'Wrong Content-Type', 415, detail);
|
|
106
|
+
this.name = 'UnsupportedMediaTypeError';
|
|
107
|
+
Object.setPrototypeOf(this, UnsupportedMediaTypeError.prototype);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
|
111
|
+
class QuotaExceededError extends MoogoError {
|
|
112
|
+
constructor(detail) {
|
|
113
|
+
super('quota_exceeded', 'Project or bucket storage would go over quota', 409, detail);
|
|
114
|
+
this.name = 'QuotaExceededError';
|
|
115
|
+
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.QuotaExceededError = QuotaExceededError;
|
|
119
|
+
class ProjectPausedError extends MoogoError {
|
|
120
|
+
constructor(detail) {
|
|
121
|
+
super('project_paused', 'Project is paused', 403, detail);
|
|
122
|
+
this.name = 'ProjectPausedError';
|
|
123
|
+
Object.setPrototypeOf(this, ProjectPausedError.prototype);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.ProjectPausedError = ProjectPausedError;
|
|
127
|
+
class LinkExpiredError extends MoogoError {
|
|
128
|
+
constructor(detail) {
|
|
129
|
+
super('link_expired', 'Signed URL expired', 403, detail);
|
|
130
|
+
this.name = 'LinkExpiredError';
|
|
131
|
+
Object.setPrototypeOf(this, LinkExpiredError.prototype);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.LinkExpiredError = LinkExpiredError;
|
|
135
|
+
class NotFoundError extends MoogoError {
|
|
136
|
+
constructor(detail) {
|
|
137
|
+
super('not_found', 'Bucket/object missing or not published', 404, detail);
|
|
138
|
+
this.name = 'NotFoundError';
|
|
139
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.NotFoundError = NotFoundError;
|
|
143
|
+
class BucketNotFoundError extends MoogoError {
|
|
144
|
+
constructor(detail) {
|
|
145
|
+
super('bucket_not_found', 'Bucket does not exist', 404, detail);
|
|
146
|
+
this.name = 'BucketNotFoundError';
|
|
147
|
+
Object.setPrototypeOf(this, BucketNotFoundError.prototype);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.BucketNotFoundError = BucketNotFoundError;
|
|
151
|
+
class CredentialLimitError extends MoogoError {
|
|
152
|
+
constructor(detail) {
|
|
153
|
+
super('credential_limit', 'Too many storage credentials', 409, detail);
|
|
154
|
+
this.name = 'CredentialLimitError';
|
|
155
|
+
Object.setPrototypeOf(this, CredentialLimitError.prototype);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.CredentialLimitError = CredentialLimitError;
|
|
159
|
+
class RateLimitedError extends MoogoError {
|
|
160
|
+
retryAfter;
|
|
161
|
+
resetAt;
|
|
162
|
+
constructor(retryAfter, resetAt, detail) {
|
|
163
|
+
super('rate_limited', 'Too many requests', 429, detail);
|
|
164
|
+
this.name = 'RateLimitedError';
|
|
165
|
+
this.retryAfter = retryAfter;
|
|
166
|
+
this.resetAt = resetAt;
|
|
167
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
168
|
+
}
|
|
169
|
+
static fromResponse(response, data) {
|
|
170
|
+
const retryAfter = parseInt(response.headers.get('Retry-After') || '1', 10);
|
|
171
|
+
const resetAt = response.headers.get('X-RateLimit-Reset')
|
|
172
|
+
? parseInt(response.headers.get('X-RateLimit-Reset'), 10)
|
|
173
|
+
: null;
|
|
174
|
+
return new RateLimitedError(retryAfter, resetAt, data?.error?.detail);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.RateLimitedError = RateLimitedError;
|
|
178
|
+
class InvalidBodyError extends MoogoError {
|
|
179
|
+
constructor(detail) {
|
|
180
|
+
super('invalid_body', 'Malformed JSON or missing required fields', 400, detail);
|
|
181
|
+
this.name = 'InvalidBodyError';
|
|
182
|
+
Object.setPrototypeOf(this, InvalidBodyError.prototype);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.InvalidBodyError = InvalidBodyError;
|
|
186
|
+
class InvalidExpiresInError extends MoogoError {
|
|
187
|
+
constructor(detail) {
|
|
188
|
+
super('invalid_expires_in', 'expires_in is outside the 60-604800 second range', 400, detail);
|
|
189
|
+
this.name = 'InvalidExpiresInError';
|
|
190
|
+
Object.setPrototypeOf(this, InvalidExpiresInError.prototype);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.InvalidExpiresInError = InvalidExpiresInError;
|
|
194
|
+
class InvalidMethodError extends MoogoError {
|
|
195
|
+
constructor(detail) {
|
|
196
|
+
super('invalid_method', 'A signed URL was requested with a method other than GET or PUT', 400, detail);
|
|
197
|
+
this.name = 'InvalidMethodError';
|
|
198
|
+
Object.setPrototypeOf(this, InvalidMethodError.prototype);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.InvalidMethodError = InvalidMethodError;
|
|
202
|
+
class UnauthorizedError extends MoogoError {
|
|
203
|
+
constructor(detail) {
|
|
204
|
+
super('unauthorized', 'Authentication required', 401, detail);
|
|
205
|
+
this.name = 'UnauthorizedError';
|
|
206
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
210
|
+
/** Map error codes to error classes */
|
|
211
|
+
const errorMap = {
|
|
212
|
+
missing_key: MissingKeyError,
|
|
213
|
+
invalid_key: InvalidKeyError,
|
|
214
|
+
key_too_long: KeyTooLongError,
|
|
215
|
+
key_taken: KeyTakenError,
|
|
216
|
+
invalid_bucket: InvalidBucketError,
|
|
217
|
+
invalid_cursor: InvalidCursorError,
|
|
218
|
+
invalid_order: InvalidOrderError,
|
|
219
|
+
body_too_large: BodyTooLargeError,
|
|
220
|
+
object_too_large: ObjectTooLargeError,
|
|
221
|
+
unsupported_media_type: UnsupportedMediaTypeError,
|
|
222
|
+
quota_exceeded: QuotaExceededError,
|
|
223
|
+
project_paused: ProjectPausedError,
|
|
224
|
+
link_expired: LinkExpiredError,
|
|
225
|
+
not_found: NotFoundError,
|
|
226
|
+
bucket_not_found: BucketNotFoundError,
|
|
227
|
+
credential_limit: CredentialLimitError,
|
|
228
|
+
invalid_body: InvalidBodyError,
|
|
229
|
+
invalid_expires_in: InvalidExpiresInError,
|
|
230
|
+
invalid_method: InvalidMethodError,
|
|
231
|
+
unauthorized: UnauthorizedError,
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Create a typed error from an API response.
|
|
235
|
+
* Falls back to generic MoogoError for unknown codes.
|
|
236
|
+
*/
|
|
237
|
+
function createErrorFromResponse(response, data) {
|
|
238
|
+
if (response.status === 429) {
|
|
239
|
+
return RateLimitedError.fromResponse(response, data);
|
|
240
|
+
}
|
|
241
|
+
const errorCode = data?.error?.code;
|
|
242
|
+
if (errorCode && errorMap[errorCode]) {
|
|
243
|
+
return new errorMap[errorCode](data.error.detail);
|
|
244
|
+
}
|
|
245
|
+
return MoogoError.fromResponse(response, data);
|
|
246
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moogo JavaScript/TypeScript Client
|
|
3
|
+
* Official client for Moogo object storage API.
|
|
4
|
+
*/
|
|
5
|
+
import type { ClientConfig, Bucket, CreateBucketRequest, UpdateBucketRequest, BucketInfoResponse, ObjectResponse, UploadResponse, ListObjectsQuery, ListObjectsResponse, PresignedUrlRequest, PresignedUrlResponse, SignedUploadResponse, StorageCredential, CreateCredentialRequest, CreateCredentialResponse, RotateCredentialResponse } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Moogo client for object storage operations.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { MoogoClient } from '@moogodev/client';
|
|
12
|
+
*
|
|
13
|
+
* const client = new MoogoClient({
|
|
14
|
+
* baseUrl: 'https://api.moogo.dev',
|
|
15
|
+
* projectId: 'your-project-id',
|
|
16
|
+
* accessKeyId: 'your-access-key',
|
|
17
|
+
* secretKey: 'your-secret-key',
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Upload a file
|
|
21
|
+
* const response = await client.upload('avatars/user.png', fileBlob, {
|
|
22
|
+
* contentType: 'image/png',
|
|
23
|
+
* cacheControl: 'public, max-age=31536000, immutable',
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // List objects
|
|
27
|
+
* const { objects, nextCursor } = await client.listObjects({ prefix: 'avatars/' });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class MoogoClient {
|
|
31
|
+
private readonly baseUrl;
|
|
32
|
+
private readonly projectId;
|
|
33
|
+
private readonly accessKeyId;
|
|
34
|
+
private readonly secretKey;
|
|
35
|
+
private readonly fetchImpl;
|
|
36
|
+
private readonly timeout;
|
|
37
|
+
constructor(config: ClientConfig);
|
|
38
|
+
/** Build the bucket catalog path */
|
|
39
|
+
private getCatalogPath;
|
|
40
|
+
/** Build the credentials path */
|
|
41
|
+
private getCredentialsPath;
|
|
42
|
+
/** Create authorization header using AWS Signature V4-like scheme */
|
|
43
|
+
private createAuthHeader;
|
|
44
|
+
private hashBody;
|
|
45
|
+
private hashString;
|
|
46
|
+
private getSigningKey;
|
|
47
|
+
private hmacSha256;
|
|
48
|
+
/** Execute a request with auth and error handling */
|
|
49
|
+
private request;
|
|
50
|
+
/** List all buckets in the project */
|
|
51
|
+
listBuckets(): Promise<Bucket[]>;
|
|
52
|
+
/** Get bucket info including usage stats */
|
|
53
|
+
getBucketInfo(bucketId: string): Promise<BucketInfoResponse>;
|
|
54
|
+
/** Create a new bucket */
|
|
55
|
+
createBucket(request: CreateBucketRequest): Promise<Bucket>;
|
|
56
|
+
/** Update bucket settings */
|
|
57
|
+
updateBucket(bucketId: string, request: UpdateBucketRequest): Promise<Bucket>;
|
|
58
|
+
/** Delete a bucket and all its objects */
|
|
59
|
+
deleteBucket(bucketId: string): Promise<void>;
|
|
60
|
+
/** Toggle bucket public/private (fans out to all objects) */
|
|
61
|
+
setBucketPublic(bucketId: string, isPublic: boolean): Promise<Bucket>;
|
|
62
|
+
/**
|
|
63
|
+
* Upload an object to a bucket.
|
|
64
|
+
*
|
|
65
|
+
* @param key - Object key (path within bucket)
|
|
66
|
+
* @param data - File data (Blob, File, Uint8Array, ReadableStream, or string)
|
|
67
|
+
* @param options - Upload options
|
|
68
|
+
*/
|
|
69
|
+
upload(key: string, data: Blob | File | Uint8Array | ReadableStream<Uint8Array> | string, options?: {
|
|
70
|
+
bucket?: string;
|
|
71
|
+
contentType?: string;
|
|
72
|
+
cacheControl?: string;
|
|
73
|
+
onProgress?: (loaded: number, total: number) => void;
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
}): Promise<UploadResponse>;
|
|
76
|
+
/** Wrap a Blob with progress tracking */
|
|
77
|
+
private wrapWithProgress;
|
|
78
|
+
/** Download an object */
|
|
79
|
+
download(key: string, options?: {
|
|
80
|
+
bucket?: string;
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
range?: {
|
|
83
|
+
start: number;
|
|
84
|
+
end?: number;
|
|
85
|
+
};
|
|
86
|
+
}): Promise<Response>;
|
|
87
|
+
/** Download object as blob */
|
|
88
|
+
downloadBlob(key: string, options?: Parameters<typeof this.download>[1]): Promise<Blob>;
|
|
89
|
+
/** Download object as text */
|
|
90
|
+
downloadText(key: string, options?: Parameters<typeof this.download>[1]): Promise<string>;
|
|
91
|
+
/** Download object as ArrayBuffer */
|
|
92
|
+
downloadArrayBuffer(key: string, options?: Parameters<typeof this.download>[1]): Promise<ArrayBuffer>;
|
|
93
|
+
/** Get object metadata (HEAD request) */
|
|
94
|
+
headObject(key: string, options?: {
|
|
95
|
+
bucket?: string;
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
headers: Headers;
|
|
99
|
+
exists: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/** Delete an object */
|
|
102
|
+
deleteObject(key: string, options?: {
|
|
103
|
+
bucket?: string;
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
}): Promise<void>;
|
|
106
|
+
/** List objects in a bucket */
|
|
107
|
+
listObjects(query?: ListObjectsQuery): Promise<ListObjectsResponse>;
|
|
108
|
+
/** Get a presigned URL for an object */
|
|
109
|
+
getPresignedUrl(key: string, request: PresignedUrlRequest, options?: {
|
|
110
|
+
bucket?: string;
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
}): Promise<PresignedUrlResponse>;
|
|
113
|
+
/** Create a signed upload URL (returns upload URL + object metadata) */
|
|
114
|
+
createSignedUpload(key: string, request: PresignedUrlRequest & {
|
|
115
|
+
content_type?: string;
|
|
116
|
+
}, options?: {
|
|
117
|
+
bucket?: string;
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
}): Promise<SignedUploadResponse>;
|
|
120
|
+
/** Update object metadata (visibility, key) */
|
|
121
|
+
updateObject(key: string, updates: {
|
|
122
|
+
is_public?: boolean;
|
|
123
|
+
new_key?: string;
|
|
124
|
+
}, options?: {
|
|
125
|
+
bucket?: string;
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
}): Promise<ObjectResponse>;
|
|
128
|
+
/** List storage credentials */
|
|
129
|
+
listCredentials(): Promise<StorageCredential[]>;
|
|
130
|
+
/** Create a new storage credential */
|
|
131
|
+
createCredential(request: CreateCredentialRequest): Promise<CreateCredentialResponse>;
|
|
132
|
+
/** Rotate a credential (generates new secret) */
|
|
133
|
+
rotateCredential(credentialId: string): Promise<RotateCredentialResponse>;
|
|
134
|
+
/** Revoke a credential */
|
|
135
|
+
revokeCredential(credentialId: string): Promise<void>;
|
|
136
|
+
/** Get the public URL for an object (if published) */
|
|
137
|
+
getPublicUrl(key: string, publicUrlBase?: string): string;
|
|
138
|
+
/** Get the authenticated download URL for an object */
|
|
139
|
+
getAuthenticatedUrl(key: string): string;
|
|
140
|
+
/** Check if an object exists (efficient HEAD) */
|
|
141
|
+
objectExists(key: string, options?: {
|
|
142
|
+
bucket?: string;
|
|
143
|
+
}): Promise<boolean>;
|
|
144
|
+
/** Get object size without downloading */
|
|
145
|
+
getObjectSize(key: string, options?: {
|
|
146
|
+
bucket?: string;
|
|
147
|
+
}): Promise<number | null>;
|
|
148
|
+
/** Get object ETag */
|
|
149
|
+
getObjectETag(key: string, options?: {
|
|
150
|
+
bucket?: string;
|
|
151
|
+
}): Promise<string | null>;
|
|
152
|
+
}
|
|
153
|
+
/** Convenience function to create a client from environment variables */
|
|
154
|
+
export declare function createClientFromEnv(env?: Record<string, string | undefined>): MoogoClient;
|
|
155
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,m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