@maravilla-labs/types 0.1.18 → 0.1.21

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.
Files changed (3) hide show
  1. package/index.d.ts +112 -0
  2. package/index.ts +126 -0
  3. package/package.json +4 -1
package/index.d.ts CHANGED
@@ -94,6 +94,115 @@ export interface DbCollection {
94
94
  export interface Database {
95
95
  [collection: string]: DbCollection;
96
96
  }
97
+ /**
98
+ * Storage metadata for uploaded files
99
+ */
100
+ export interface StorageMetadata {
101
+ /** MIME content type */
102
+ contentType: string;
103
+ /** File size in bytes */
104
+ size: number;
105
+ /** Upload timestamp (Unix timestamp in seconds) */
106
+ uploadedAt: number;
107
+ /** Optional custom tags */
108
+ tags?: Record<string, string>;
109
+ /** Original filename if provided */
110
+ filename?: string;
111
+ /** Checksum/ETag */
112
+ etag?: string;
113
+ }
114
+ /**
115
+ * Storage object information (for list operations)
116
+ */
117
+ export interface StorageObjectInfo {
118
+ /** Object key/path */
119
+ key: string;
120
+ /** Object metadata */
121
+ metadata: StorageMetadata;
122
+ /** Last modified timestamp */
123
+ lastModified: number;
124
+ }
125
+ /**
126
+ * Presigned URL information for uploads/downloads
127
+ */
128
+ export interface PresignedUrl {
129
+ /** The presigned URL */
130
+ url: string;
131
+ /** HTTP method to use (PUT for upload, GET for download) */
132
+ method: string;
133
+ /** Headers that must be included in the request */
134
+ headers: Record<string, string>;
135
+ /** Expiration time in seconds */
136
+ expiresIn: number;
137
+ }
138
+ /**
139
+ * Options for generating upload URLs
140
+ */
141
+ export interface UploadUrlOptions {
142
+ /** Maximum file size in bytes */
143
+ sizeLimit?: number;
144
+ /** Custom metadata tags */
145
+ tags?: Record<string, string>;
146
+ }
147
+ /**
148
+ * Options for listing storage objects
149
+ */
150
+ export interface StorageListOptions {
151
+ /** Key prefix to filter by */
152
+ prefix?: string;
153
+ /** Maximum number of results */
154
+ limit?: number;
155
+ }
156
+ /**
157
+ * Storage service interface
158
+ */
159
+ export interface Storage {
160
+ /**
161
+ * Generate a presigned URL for uploading a file
162
+ * @param key - The storage key/path for the file
163
+ * @param contentType - MIME type of the file
164
+ * @param options - Upload options
165
+ * @returns Presigned URL information
166
+ */
167
+ generateUploadUrl(key: string, contentType: string, options?: UploadUrlOptions): Promise<PresignedUrl>;
168
+ /**
169
+ * Upload data directly (for small files)
170
+ * @param key - The storage key/path for the file
171
+ * @param data - File data (can be ArrayBuffer, Uint8Array, Blob, or string)
172
+ * @param metadata - File metadata
173
+ */
174
+ put(key: string, data: ArrayBuffer | Uint8Array | Blob | string, metadata?: Partial<StorageMetadata>): Promise<void>;
175
+ /**
176
+ * Download a file
177
+ * @param key - The storage key/path for the file
178
+ * @returns File data as ArrayBuffer
179
+ */
180
+ get(key: string): Promise<ArrayBuffer>;
181
+ /**
182
+ * Generate a presigned URL for downloading a file
183
+ * @param key - The storage key/path for the file
184
+ * @param expiresIn - How long the URL should be valid (in seconds)
185
+ * @returns Presigned URL information
186
+ */
187
+ generateDownloadUrl(key: string, expiresIn?: number): Promise<PresignedUrl>;
188
+ /**
189
+ * Delete a file
190
+ * @param key - The storage key/path for the file
191
+ */
192
+ delete(key: string): Promise<void>;
193
+ /**
194
+ * List files with a given prefix
195
+ * @param options - List options
196
+ * @returns List of storage objects
197
+ */
198
+ list(options?: StorageListOptions): Promise<StorageObjectInfo[]>;
199
+ /**
200
+ * Get file metadata without downloading the file
201
+ * @param key - The storage key/path for the file
202
+ * @returns File metadata
203
+ */
204
+ getMetadata(key: string): Promise<StorageMetadata>;
205
+ }
97
206
  /**
98
207
  * Main platform interface available in runtime
99
208
  */
@@ -102,10 +211,13 @@ export interface Platform {
102
211
  kv: KvStore;
103
212
  /** Database instance with dynamic collection access */
104
213
  db: Database;
214
+ /** Storage service instance */
215
+ storage: Storage;
105
216
  /** Legacy aliases for compatibility */
106
217
  env: {
107
218
  KV: KvStore;
108
219
  DB: Database;
220
+ STORAGE: Storage;
109
221
  };
110
222
  }
111
223
  /**
package/index.ts CHANGED
@@ -111,6 +111,129 @@ export interface Database {
111
111
  [collection: string]: DbCollection;
112
112
  }
113
113
 
114
+ // Storage Types
115
+
116
+ /**
117
+ * Storage metadata for uploaded files
118
+ */
119
+ export interface StorageMetadata {
120
+ /** MIME content type */
121
+ contentType: string;
122
+ /** File size in bytes */
123
+ size: number;
124
+ /** Upload timestamp (Unix timestamp in seconds) */
125
+ uploadedAt: number;
126
+ /** Optional custom tags */
127
+ tags?: Record<string, string>;
128
+ /** Original filename if provided */
129
+ filename?: string;
130
+ /** Checksum/ETag */
131
+ etag?: string;
132
+ }
133
+
134
+ /**
135
+ * Storage object information (for list operations)
136
+ */
137
+ export interface StorageObjectInfo {
138
+ /** Object key/path */
139
+ key: string;
140
+ /** Object metadata */
141
+ metadata: StorageMetadata;
142
+ /** Last modified timestamp */
143
+ lastModified: number;
144
+ }
145
+
146
+ /**
147
+ * Presigned URL information for uploads/downloads
148
+ */
149
+ export interface PresignedUrl {
150
+ /** The presigned URL */
151
+ url: string;
152
+ /** HTTP method to use (PUT for upload, GET for download) */
153
+ method: string;
154
+ /** Headers that must be included in the request */
155
+ headers: Record<string, string>;
156
+ /** Expiration time in seconds */
157
+ expiresIn: number;
158
+ }
159
+
160
+ /**
161
+ * Options for generating upload URLs
162
+ */
163
+ export interface UploadUrlOptions {
164
+ /** Maximum file size in bytes */
165
+ sizeLimit?: number;
166
+ /** Custom metadata tags */
167
+ tags?: Record<string, string>;
168
+ }
169
+
170
+ /**
171
+ * Options for listing storage objects
172
+ */
173
+ export interface StorageListOptions {
174
+ /** Key prefix to filter by */
175
+ prefix?: string;
176
+ /** Maximum number of results */
177
+ limit?: number;
178
+ }
179
+
180
+ /**
181
+ * Storage service interface
182
+ */
183
+ export interface Storage {
184
+ /**
185
+ * Generate a presigned URL for uploading a file
186
+ * @param key - The storage key/path for the file
187
+ * @param contentType - MIME type of the file
188
+ * @param options - Upload options
189
+ * @returns Presigned URL information
190
+ */
191
+ generateUploadUrl(key: string, contentType: string, options?: UploadUrlOptions): Promise<PresignedUrl>;
192
+
193
+ /**
194
+ * Upload data directly (for small files)
195
+ * @param key - The storage key/path for the file
196
+ * @param data - File data (can be ArrayBuffer, Uint8Array, Blob, or string)
197
+ * @param metadata - File metadata
198
+ */
199
+ put(key: string, data: ArrayBuffer | Uint8Array | Blob | string, metadata?: Partial<StorageMetadata>): Promise<void>;
200
+
201
+ /**
202
+ * Download a file
203
+ * @param key - The storage key/path for the file
204
+ * @returns File data as ArrayBuffer
205
+ */
206
+ get(key: string): Promise<ArrayBuffer>;
207
+
208
+ /**
209
+ * Generate a presigned URL for downloading a file
210
+ * @param key - The storage key/path for the file
211
+ * @param expiresIn - How long the URL should be valid (in seconds)
212
+ * @returns Presigned URL information
213
+ */
214
+ generateDownloadUrl(key: string, expiresIn?: number): Promise<PresignedUrl>;
215
+
216
+ /**
217
+ * Delete a file
218
+ * @param key - The storage key/path for the file
219
+ */
220
+ delete(key: string): Promise<void>;
221
+
222
+ /**
223
+ * List files with a given prefix
224
+ * @param options - List options
225
+ * @returns List of storage objects
226
+ */
227
+ list(options?: StorageListOptions): Promise<StorageObjectInfo[]>;
228
+
229
+ /**
230
+ * Get file metadata without downloading the file
231
+ * @param key - The storage key/path for the file
232
+ * @returns File metadata
233
+ */
234
+ getMetadata(key: string): Promise<StorageMetadata>;
235
+ }
236
+
114
237
  // Platform Types
115
238
 
116
239
  /**
@@ -121,10 +244,13 @@ export interface Platform {
121
244
  kv: KvStore;
122
245
  /** Database instance with dynamic collection access */
123
246
  db: Database;
247
+ /** Storage service instance */
248
+ storage: Storage;
124
249
  /** Legacy aliases for compatibility */
125
250
  env: {
126
251
  KV: KvStore;
127
252
  DB: Database;
253
+ STORAGE: Storage;
128
254
  };
129
255
  }
130
256
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maravilla-labs/types",
3
- "version": "0.1.18",
3
+ "version": "0.1.21",
4
4
  "description": "TypeScript definitions for Maravilla Runtime platform APIs",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -21,5 +21,8 @@
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "undici-types": "^7.15.0"
24
27
  }
25
28
  }