@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.
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Error classes for Moogo client.
3
+ * All errors follow the API error codes.
4
+ */
5
+ export class MoogoError extends Error {
6
+ code;
7
+ status;
8
+ detail;
9
+ constructor(code, message, status, detail) {
10
+ super(message);
11
+ this.name = 'MoogoError';
12
+ this.code = code;
13
+ this.status = status;
14
+ this.detail = detail;
15
+ Object.setPrototypeOf(this, MoogoError.prototype);
16
+ }
17
+ static fromResponse(response, data) {
18
+ const error = data?.error;
19
+ if (error) {
20
+ return new MoogoError(error.code, error.message, response.status, error.detail);
21
+ }
22
+ return new MoogoError('unknown_error', `HTTP ${response.status}: ${response.statusText}`, response.status);
23
+ }
24
+ }
25
+ /** 400 - Missing or invalid object key */
26
+ export class MissingKeyError extends MoogoError {
27
+ constructor(detail) {
28
+ super('missing_key', 'No object key in the path', 400, detail);
29
+ this.name = 'MissingKeyError';
30
+ Object.setPrototypeOf(this, MissingKeyError.prototype);
31
+ }
32
+ }
33
+ export class InvalidKeyError extends MoogoError {
34
+ constructor(detail) {
35
+ super('invalid_key', 'Key contains invalid characters', 400, detail);
36
+ this.name = 'InvalidKeyError';
37
+ Object.setPrototypeOf(this, InvalidKeyError.prototype);
38
+ }
39
+ }
40
+ export class KeyTooLongError extends MoogoError {
41
+ constructor(detail) {
42
+ super('key_too_long', 'Object key exceeds maximum length', 400, detail);
43
+ this.name = 'KeyTooLongError';
44
+ Object.setPrototypeOf(this, KeyTooLongError.prototype);
45
+ }
46
+ }
47
+ export class KeyTakenError extends MoogoError {
48
+ constructor(detail) {
49
+ super('key_taken', 'An object with that key already exists', 409, detail);
50
+ this.name = 'KeyTakenError';
51
+ Object.setPrototypeOf(this, KeyTakenError.prototype);
52
+ }
53
+ }
54
+ export class InvalidBucketError extends MoogoError {
55
+ constructor(detail) {
56
+ super('invalid_bucket', 'Bucket name is not allowed or invalid', 400, detail);
57
+ this.name = 'InvalidBucketError';
58
+ Object.setPrototypeOf(this, InvalidBucketError.prototype);
59
+ }
60
+ }
61
+ export class InvalidCursorError extends MoogoError {
62
+ constructor(detail) {
63
+ super('invalid_cursor', 'Cursor is malformed or belongs to a different listing', 400, detail);
64
+ this.name = 'InvalidCursorError';
65
+ Object.setPrototypeOf(this, InvalidCursorError.prototype);
66
+ }
67
+ }
68
+ export class InvalidOrderError extends MoogoError {
69
+ constructor(detail) {
70
+ super('invalid_order', 'Unknown order or direction', 400, detail);
71
+ this.name = 'InvalidOrderError';
72
+ Object.setPrototypeOf(this, InvalidOrderError.prototype);
73
+ }
74
+ }
75
+ export class BodyTooLargeError extends MoogoError {
76
+ constructor(detail) {
77
+ super('body_too_large', 'Request body exceeded the JSON or upload cap', 413, detail);
78
+ this.name = 'BodyTooLargeError';
79
+ Object.setPrototypeOf(this, BodyTooLargeError.prototype);
80
+ }
81
+ }
82
+ export class ObjectTooLargeError extends MoogoError {
83
+ constructor(detail) {
84
+ super('object_too_large', 'Object over the bucket max size', 413, detail);
85
+ this.name = 'ObjectTooLargeError';
86
+ Object.setPrototypeOf(this, ObjectTooLargeError.prototype);
87
+ }
88
+ }
89
+ export class UnsupportedMediaTypeError extends MoogoError {
90
+ constructor(detail) {
91
+ super('unsupported_media_type', 'Wrong Content-Type', 415, detail);
92
+ this.name = 'UnsupportedMediaTypeError';
93
+ Object.setPrototypeOf(this, UnsupportedMediaTypeError.prototype);
94
+ }
95
+ }
96
+ export class QuotaExceededError extends MoogoError {
97
+ constructor(detail) {
98
+ super('quota_exceeded', 'Project or bucket storage would go over quota', 409, detail);
99
+ this.name = 'QuotaExceededError';
100
+ Object.setPrototypeOf(this, QuotaExceededError.prototype);
101
+ }
102
+ }
103
+ export class ProjectPausedError extends MoogoError {
104
+ constructor(detail) {
105
+ super('project_paused', 'Project is paused', 403, detail);
106
+ this.name = 'ProjectPausedError';
107
+ Object.setPrototypeOf(this, ProjectPausedError.prototype);
108
+ }
109
+ }
110
+ export class LinkExpiredError extends MoogoError {
111
+ constructor(detail) {
112
+ super('link_expired', 'Signed URL expired', 403, detail);
113
+ this.name = 'LinkExpiredError';
114
+ Object.setPrototypeOf(this, LinkExpiredError.prototype);
115
+ }
116
+ }
117
+ export class NotFoundError extends MoogoError {
118
+ constructor(detail) {
119
+ super('not_found', 'Bucket/object missing or not published', 404, detail);
120
+ this.name = 'NotFoundError';
121
+ Object.setPrototypeOf(this, NotFoundError.prototype);
122
+ }
123
+ }
124
+ export class BucketNotFoundError extends MoogoError {
125
+ constructor(detail) {
126
+ super('bucket_not_found', 'Bucket does not exist', 404, detail);
127
+ this.name = 'BucketNotFoundError';
128
+ Object.setPrototypeOf(this, BucketNotFoundError.prototype);
129
+ }
130
+ }
131
+ export class CredentialLimitError extends MoogoError {
132
+ constructor(detail) {
133
+ super('credential_limit', 'Too many storage credentials', 409, detail);
134
+ this.name = 'CredentialLimitError';
135
+ Object.setPrototypeOf(this, CredentialLimitError.prototype);
136
+ }
137
+ }
138
+ export class RateLimitedError extends MoogoError {
139
+ retryAfter;
140
+ resetAt;
141
+ constructor(retryAfter, resetAt, detail) {
142
+ super('rate_limited', 'Too many requests', 429, detail);
143
+ this.name = 'RateLimitedError';
144
+ this.retryAfter = retryAfter;
145
+ this.resetAt = resetAt;
146
+ Object.setPrototypeOf(this, RateLimitedError.prototype);
147
+ }
148
+ static fromResponse(response, data) {
149
+ const retryAfter = parseInt(response.headers.get('Retry-After') || '1', 10);
150
+ const resetAt = response.headers.get('X-RateLimit-Reset')
151
+ ? parseInt(response.headers.get('X-RateLimit-Reset'), 10)
152
+ : null;
153
+ return new RateLimitedError(retryAfter, resetAt, data?.error?.detail);
154
+ }
155
+ }
156
+ export class InvalidBodyError extends MoogoError {
157
+ constructor(detail) {
158
+ super('invalid_body', 'Malformed JSON or missing required fields', 400, detail);
159
+ this.name = 'InvalidBodyError';
160
+ Object.setPrototypeOf(this, InvalidBodyError.prototype);
161
+ }
162
+ }
163
+ export class InvalidExpiresInError extends MoogoError {
164
+ constructor(detail) {
165
+ super('invalid_expires_in', 'expires_in is outside the 60-604800 second range', 400, detail);
166
+ this.name = 'InvalidExpiresInError';
167
+ Object.setPrototypeOf(this, InvalidExpiresInError.prototype);
168
+ }
169
+ }
170
+ export class InvalidMethodError extends MoogoError {
171
+ constructor(detail) {
172
+ super('invalid_method', 'A signed URL was requested with a method other than GET or PUT', 400, detail);
173
+ this.name = 'InvalidMethodError';
174
+ Object.setPrototypeOf(this, InvalidMethodError.prototype);
175
+ }
176
+ }
177
+ export class UnauthorizedError extends MoogoError {
178
+ constructor(detail) {
179
+ super('unauthorized', 'Authentication required', 401, detail);
180
+ this.name = 'UnauthorizedError';
181
+ Object.setPrototypeOf(this, UnauthorizedError.prototype);
182
+ }
183
+ }
184
+ /** Map error codes to error classes */
185
+ const errorMap = {
186
+ missing_key: MissingKeyError,
187
+ invalid_key: InvalidKeyError,
188
+ key_too_long: KeyTooLongError,
189
+ key_taken: KeyTakenError,
190
+ invalid_bucket: InvalidBucketError,
191
+ invalid_cursor: InvalidCursorError,
192
+ invalid_order: InvalidOrderError,
193
+ body_too_large: BodyTooLargeError,
194
+ object_too_large: ObjectTooLargeError,
195
+ unsupported_media_type: UnsupportedMediaTypeError,
196
+ quota_exceeded: QuotaExceededError,
197
+ project_paused: ProjectPausedError,
198
+ link_expired: LinkExpiredError,
199
+ not_found: NotFoundError,
200
+ bucket_not_found: BucketNotFoundError,
201
+ credential_limit: CredentialLimitError,
202
+ invalid_body: InvalidBodyError,
203
+ invalid_expires_in: InvalidExpiresInError,
204
+ invalid_method: InvalidMethodError,
205
+ unauthorized: UnauthorizedError,
206
+ };
207
+ /**
208
+ * Create a typed error from an API response.
209
+ * Falls back to generic MoogoError for unknown codes.
210
+ */
211
+ export function createErrorFromResponse(response, data) {
212
+ if (response.status === 429) {
213
+ return RateLimitedError.fromResponse(response, data);
214
+ }
215
+ const errorCode = data?.error?.code;
216
+ if (errorCode && errorMap[errorCode]) {
217
+ return new errorMap[errorCode](data.error.detail);
218
+ }
219
+ return MoogoError.fromResponse(response, data);
220
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @moogodev/client - Official JavaScript/TypeScript client for Moogo object storage
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { MoogoClient, createClientFromEnv } from '@moogodev/client';
7
+ *
8
+ * // From environment variables
9
+ * const client = createClientFromEnv();
10
+ *
11
+ * // Or with explicit config
12
+ * const client = new MoogoClient({
13
+ * baseUrl: 'https://api.moogo.dev',
14
+ * projectId: 'your-project-id',
15
+ * accessKeyId: 'your-access-key-id',
16
+ * secretKey: 'your-secret-key',
17
+ * });
18
+ *
19
+ * // Upload a file
20
+ * const response = await client.upload('avatars/user.png', fileBlob, {
21
+ * contentType: 'image/png',
22
+ * cacheControl: 'public, max-age=31536000, immutable',
23
+ * });
24
+ *
25
+ * // List objects
26
+ * const { objects, nextCursor } = await client.listObjects({ prefix: 'avatars/' });
27
+ *
28
+ * // Download
29
+ * const blob = await client.downloadBlob('avatars/user.png');
30
+ * ```
31
+ */
32
+ export type { ClientConfig, ProjectId, BucketId, ObjectKey, ApiError, ApiErrorResponse, ApiSuccessResponse, ObjectBase, ObjectResponse, Bucket, CreateBucketRequest, UpdateBucketRequest, BucketInfoResponse, ListBucketsResponse, UploadResponse, ListObjectsQuery, ListObjectsResponse, PresignedUrlRequest, PresignedUrlResponse, SignedUploadResponse, StorageCredential, ListCredentialsResponse, CreateCredentialRequest, CreateCredentialResponse, RotateCredentialResponse, DeleteResponse, } from './types.js';
33
+ export { MoogoError, MissingKeyError, InvalidKeyError, KeyTooLongError, KeyTakenError, InvalidBucketError, InvalidCursorError, InvalidOrderError, BodyTooLargeError, ObjectTooLargeError, UnsupportedMediaTypeError, QuotaExceededError, ProjectPausedError, LinkExpiredError, NotFoundError, BucketNotFoundError, CredentialLimitError, RateLimitedError, InvalidBodyError, InvalidExpiresInError, InvalidMethodError, UnauthorizedError, createErrorFromResponse, } from './errors.js';
34
+ export { MoogoClient, createClientFromEnv } from './client.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,YAAY,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Type definitions for Moogo object storage API.
3
+ * Matches the API responses from https://moogo.dev
4
+ */
5
+ /** Standard API error envelope */
6
+ export interface ApiError {
7
+ code: string;
8
+ message: string;
9
+ detail?: string;
10
+ }
11
+ export interface ApiErrorResponse {
12
+ error: ApiError;
13
+ }
14
+ /** Successful response wrapper */
15
+ export interface ApiSuccessResponse {
16
+ success: true;
17
+ [key: string]: any;
18
+ }
19
+ /** Project/bucket identifiers */
20
+ export type ProjectId = string;
21
+ export type BucketId = string;
22
+ export type ObjectKey = string;
23
+ /** Base object fields present in all object responses */
24
+ export interface ObjectBase {
25
+ id: string;
26
+ bucket_id: string;
27
+ bucket: string;
28
+ key: string;
29
+ size_bytes: number;
30
+ content_type: string;
31
+ is_public: boolean;
32
+ etag: string;
33
+ url: string;
34
+ preview_url: string;
35
+ public_url: string;
36
+ public_url_base: string;
37
+ url_base: string;
38
+ created_at: string;
39
+ updated_at: string;
40
+ last_modified: string;
41
+ }
42
+ /** Object as returned by upload/list endpoints */
43
+ export interface ObjectResponse extends ObjectBase {
44
+ }
45
+ /** Bucket configuration */
46
+ export interface Bucket {
47
+ id: string;
48
+ name: string;
49
+ object_count: number;
50
+ size_bytes: number;
51
+ created_at: string;
52
+ is_public: boolean;
53
+ allowed_types: string[];
54
+ max_object_size_bytes: number;
55
+ quota_bytes: number;
56
+ }
57
+ /** Bucket creation request */
58
+ export interface CreateBucketRequest {
59
+ name: string;
60
+ allowed_types?: string[];
61
+ max_object_size_bytes?: number;
62
+ quota_bytes?: number;
63
+ }
64
+ /** Bucket update request */
65
+ export interface UpdateBucketRequest {
66
+ is_public?: boolean;
67
+ allowed_types?: string[];
68
+ max_object_size_bytes?: number;
69
+ quota_bytes?: number;
70
+ }
71
+ /** Bucket info response (GET /buckets/{project_id}/{bucket_id}) */
72
+ export interface BucketInfoResponse {
73
+ success: true;
74
+ bucket: Bucket;
75
+ storage_used_bytes: number;
76
+ quota_bytes: number;
77
+ }
78
+ /** List buckets response */
79
+ export interface ListBucketsResponse {
80
+ success: true;
81
+ buckets: Bucket[];
82
+ }
83
+ /** Object upload response */
84
+ export interface UploadResponse {
85
+ success: true;
86
+ object: ObjectResponse;
87
+ storage_used_bytes: number;
88
+ quota_bytes: number;
89
+ }
90
+ /** List objects query parameters */
91
+ export interface ListObjectsQuery {
92
+ bucket?: string;
93
+ prefix?: string;
94
+ search?: string;
95
+ order_by?: 'key' | 'size' | 'created' | 'updated' | 'contenttype';
96
+ order_dir?: 'asc' | 'desc';
97
+ limit?: number;
98
+ cursor?: string;
99
+ }
100
+ /** Paginated object list response */
101
+ export interface ListObjectsResponse {
102
+ success: true;
103
+ objects: ObjectResponse[];
104
+ next_cursor: string | null;
105
+ total: number;
106
+ }
107
+ /** Presigned URL request */
108
+ export interface PresignedUrlRequest {
109
+ method: 'GET' | 'PUT';
110
+ expires_in: number;
111
+ }
112
+ /** Presigned URL response */
113
+ export interface PresignedUrlResponse {
114
+ success: true;
115
+ url: string;
116
+ expires_at: string;
117
+ method: 'GET' | 'PUT';
118
+ }
119
+ /** Signed upload response (POST /bucket/{project_id}/sign-upload) */
120
+ export interface SignedUploadResponse {
121
+ success: true;
122
+ upload_url: string;
123
+ object: ObjectResponse;
124
+ expires_at: string;
125
+ }
126
+ /** Storage credential */
127
+ export interface StorageCredential {
128
+ id: string;
129
+ access_key_id: string;
130
+ secret_key_preview: string;
131
+ label: string;
132
+ created_at: string;
133
+ rotated_at: string | null;
134
+ revoked_at: string | null;
135
+ }
136
+ /** List credentials response */
137
+ export interface ListCredentialsResponse {
138
+ success: true;
139
+ credentials: StorageCredential[];
140
+ }
141
+ /** Create credential request */
142
+ export interface CreateCredentialRequest {
143
+ label: string;
144
+ }
145
+ /** Create credential response (includes secret once) */
146
+ export interface CreateCredentialResponse {
147
+ success: true;
148
+ credential: StorageCredential;
149
+ secret_key: string;
150
+ }
151
+ /** Rotate credential response */
152
+ export interface RotateCredentialResponse {
153
+ success: true;
154
+ credential: StorageCredential;
155
+ secret_key: string;
156
+ }
157
+ /** Generic success response for deletions */
158
+ export interface DeleteResponse {
159
+ success: true;
160
+ }
161
+ /** Configuration for the client */
162
+ export interface ClientConfig {
163
+ /** Base URL of the Moogo API (e.g., "https://api.moogo.dev") */
164
+ baseUrl: string;
165
+ /** Project ID */
166
+ projectId: string;
167
+ /** Access Key ID */
168
+ accessKeyId: string;
169
+ /** Secret Key */
170
+ secretKey: string;
171
+ /** Optional: custom fetch implementation */
172
+ fetch?: typeof fetch;
173
+ /** Optional: default timeout in ms */
174
+ timeout?: number;
175
+ }
176
+ /** Internal: parsed auth header */
177
+ export interface ParsedAuth {
178
+ accessKeyId: string;
179
+ signature: string;
180
+ timestamp: string;
181
+ signedHeaders: string;
182
+ }
183
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kCAAkC;AAClC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,IAAI,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,iCAAiC;AACjC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,yDAAyD;AACzD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,E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 -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for Moogo object storage API.
3
+ * Matches the API responses from https://moogo.dev
4
+ */
5
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @moogodev/client - Official JavaScript/TypeScript client for Moogo object storage
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { MoogoClient, createClientFromEnv } from '@moogodev/client';
7
+ *
8
+ * // From environment variables
9
+ * const client = createClientFromEnv();
10
+ *
11
+ * // Or with explicit config
12
+ * const client = new MoogoClient({
13
+ * baseUrl: 'https://api.moogo.dev',
14
+ * projectId: 'your-project-id',
15
+ * accessKeyId: 'your-access-key-id',
16
+ * secretKey: 'your-secret-key',
17
+ * });
18
+ *
19
+ * // Upload a file
20
+ * const response = await client.upload('avatars/user.png', fileBlob, {
21
+ * contentType: 'image/png',
22
+ * cacheControl: 'public, max-age=31536000, immutable',
23
+ * });
24
+ *
25
+ * // List objects
26
+ * const { objects, nextCursor } = await client.listObjects({ prefix: 'avatars/' });
27
+ *
28
+ * // Download
29
+ * const blob = await client.downloadBlob('avatars/user.png');
30
+ * ```
31
+ */
32
+ export type { ClientConfig, ProjectId, BucketId, ObjectKey, ApiError, ApiErrorResponse, ApiSuccessResponse, ObjectBase, ObjectResponse, Bucket, CreateBucketRequest, UpdateBucketRequest, BucketInfoResponse, ListBucketsResponse, UploadResponse, ListObjectsQuery, ListObjectsResponse, PresignedUrlRequest, PresignedUrlResponse, SignedUploadResponse, StorageCredential, ListCredentialsResponse, CreateCredentialRequest, CreateCredentialResponse, RotateCredentialResponse, DeleteResponse, } from './types.js';
33
+ export { MoogoError, MissingKeyError, InvalidKeyError, KeyTooLongError, KeyTakenError, InvalidBucketError, InvalidCursorError, InvalidOrderError, BodyTooLargeError, ObjectTooLargeError, UnsupportedMediaTypeError, QuotaExceededError, ProjectPausedError, LinkExpiredError, NotFoundError, BucketNotFoundError, CredentialLimitError, RateLimitedError, InvalidBodyError, InvalidExpiresInError, InvalidMethodError, UnauthorizedError, createErrorFromResponse, } from './errors.js';
34
+ export { MoogoClient, createClientFromEnv } from './client.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,YAAY,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * @moogodev/client - Official JavaScript/TypeScript client for Moogo object storage
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { MoogoClient, createClientFromEnv } from '@moogodev/client';
8
+ *
9
+ * // From environment variables
10
+ * const client = createClientFromEnv();
11
+ *
12
+ * // Or with explicit config
13
+ * const client = new MoogoClient({
14
+ * baseUrl: 'https://api.moogo.dev',
15
+ * projectId: 'your-project-id',
16
+ * accessKeyId: 'your-access-key-id',
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
+ * // Download
30
+ * const blob = await client.downloadBlob('avatars/user.png');
31
+ * ```
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.createClientFromEnv = exports.MoogoClient = exports.createErrorFromResponse = 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;
35
+ // Errors
36
+ var errors_js_1 = require("./errors.js");
37
+ Object.defineProperty(exports, "MoogoError", { enumerable: true, get: function () { return errors_js_1.MoogoError; } });
38
+ Object.defineProperty(exports, "MissingKeyError", { enumerable: true, get: function () { return errors_js_1.MissingKeyError; } });
39
+ Object.defineProperty(exports, "InvalidKeyError", { enumerable: true, get: function () { return errors_js_1.InvalidKeyError; } });
40
+ Object.defineProperty(exports, "KeyTooLongError", { enumerable: true, get: function () { return errors_js_1.KeyTooLongError; } });
41
+ Object.defineProperty(exports, "KeyTakenError", { enumerable: true, get: function () { return errors_js_1.KeyTakenError; } });
42
+ Object.defineProperty(exports, "InvalidBucketError", { enumerable: true, get: function () { return errors_js_1.InvalidBucketError; } });
43
+ Object.defineProperty(exports, "InvalidCursorError", { enumerable: true, get: function () { return errors_js_1.InvalidCursorError; } });
44
+ Object.defineProperty(exports, "InvalidOrderError", { enumerable: true, get: function () { return errors_js_1.InvalidOrderError; } });
45
+ Object.defineProperty(exports, "BodyTooLargeError", { enumerable: true, get: function () { return errors_js_1.BodyTooLargeError; } });
46
+ Object.defineProperty(exports, "ObjectTooLargeError", { enumerable: true, get: function () { return errors_js_1.ObjectTooLargeError; } });
47
+ Object.defineProperty(exports, "UnsupportedMediaTypeError", { enumerable: true, get: function () { return errors_js_1.UnsupportedMediaTypeError; } });
48
+ Object.defineProperty(exports, "QuotaExceededError", { enumerable: true, get: function () { return errors_js_1.QuotaExceededError; } });
49
+ Object.defineProperty(exports, "ProjectPausedError", { enumerable: true, get: function () { return errors_js_1.ProjectPausedError; } });
50
+ Object.defineProperty(exports, "LinkExpiredError", { enumerable: true, get: function () { return errors_js_1.LinkExpiredError; } });
51
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
52
+ Object.defineProperty(exports, "BucketNotFoundError", { enumerable: true, get: function () { return errors_js_1.BucketNotFoundError; } });
53
+ Object.defineProperty(exports, "CredentialLimitError", { enumerable: true, get: function () { return errors_js_1.CredentialLimitError; } });
54
+ Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return errors_js_1.RateLimitedError; } });
55
+ Object.defineProperty(exports, "InvalidBodyError", { enumerable: true, get: function () { return errors_js_1.InvalidBodyError; } });
56
+ Object.defineProperty(exports, "InvalidExpiresInError", { enumerable: true, get: function () { return errors_js_1.InvalidExpiresInError; } });
57
+ Object.defineProperty(exports, "InvalidMethodError", { enumerable: true, get: function () { return errors_js_1.InvalidMethodError; } });
58
+ Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return errors_js_1.UnauthorizedError; } });
59
+ Object.defineProperty(exports, "createErrorFromResponse", { enumerable: true, get: function () { return errors_js_1.createErrorFromResponse; } });
60
+ // Client
61
+ var client_js_1 = require("./client.js");
62
+ Object.defineProperty(exports, "MoogoClient", { enumerable: true, get: function () { return client_js_1.MoogoClient; } });
63
+ Object.defineProperty(exports, "createClientFromEnv", { enumerable: true, get: function () { return client_js_1.createClientFromEnv; } });
package/dist/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @moogodev/client - Official JavaScript/TypeScript client for Moogo object storage
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { MoogoClient, createClientFromEnv } from '@moogodev/client';
7
+ *
8
+ * // From environment variables
9
+ * const client = createClientFromEnv();
10
+ *
11
+ * // Or with explicit config
12
+ * const client = new MoogoClient({
13
+ * baseUrl: 'https://api.moogo.dev',
14
+ * projectId: 'your-project-id',
15
+ * accessKeyId: 'your-access-key-id',
16
+ * secretKey: 'your-secret-key',
17
+ * });
18
+ *
19
+ * // Upload a file
20
+ * const response = await client.upload('avatars/user.png', fileBlob, {
21
+ * contentType: 'image/png',
22
+ * cacheControl: 'public, max-age=31536000, immutable',
23
+ * });
24
+ *
25
+ * // List objects
26
+ * const { objects, nextCursor } = await client.listObjects({ prefix: 'avatars/' });
27
+ *
28
+ * // Download
29
+ * const blob = await client.downloadBlob('avatars/user.png');
30
+ * ```
31
+ */
32
+ // Errors
33
+ export { MoogoError, MissingKeyError, InvalidKeyError, KeyTooLongError, KeyTakenError, InvalidBucketError, InvalidCursorError, InvalidOrderError, BodyTooLargeError, ObjectTooLargeError, UnsupportedMediaTypeError, QuotaExceededError, ProjectPausedError, LinkExpiredError, NotFoundError, BucketNotFoundError, CredentialLimitError, RateLimitedError, InvalidBodyError, InvalidExpiresInError, InvalidMethodError, UnauthorizedError, createErrorFromResponse, } from './errors.js';
34
+ // Client
35
+ export { MoogoClient, createClientFromEnv } from './client.js';