-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e601b3
commit 8038b49
Showing
10 changed files
with
146 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from '@jest/globals' | ||
import { StorageClient } from '../storage/StorageClient' | ||
import { CHINOOK_DATABASE_URL } from '../../../test/shared' | ||
|
||
|
||
const storage = new StorageClient(CHINOOK_DATABASE_URL) | ||
|
||
describe('StorageClient', () => { | ||
it('should be able to create a bucket', async () => { | ||
expect(storage).toBeDefined() | ||
|
||
const bucket = await storage.createBucket('test-bucket') | ||
|
||
expect(bucket).toBeDefined() | ||
}) | ||
}) | ||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Fetch } from '../utils/fetch' | ||
|
||
|
||
export interface SQLiteCloudClientConfig { | ||
connectionString: string | ||
global?: { | ||
fetch?: Fetch | ||
headers?: Record<string, string> | ||
} | ||
} | ||
|
||
export interface WebliteResponse { | ||
data: any, // TODO: type this | ||
error: SQLiteCloudError | null | ||
} | ||
export interface Weblite { | ||
upload(dbName: string, file: File | Buffer | Blob | string, opts: UploadOptions): Promise<WebliteResponse> | ||
download(dbName: string): Promise<WebliteResponse> | ||
delete(dbName: string): Promise<WebliteResponse> | ||
listDatabases(): Promise<WebliteResponse> | ||
create(dbName: string): Promise<WebliteResponse> | ||
} | ||
|
||
|
||
/** | ||
* StorageResponse | ||
* @param data - The data returned from the operation. | ||
* @param error - The error that occurred. | ||
*/ | ||
interface StorageResponse { | ||
data: any | ||
error: any | ||
} | ||
|
||
/** | ||
* Storage | ||
* @param createBucket - Create a bucket. | ||
* @param getBucket - Get a bucket. | ||
* @param deleteBucket - Delete a bucket. | ||
* @param listBuckets - List all buckets. | ||
* @param upload - Upload a file. | ||
* @param download - Download a file. | ||
* @param remove - Remove a file. | ||
* @param list - List all files in a bucket. | ||
*/ | ||
interface Storage { | ||
createBucket(bucket: string): Promise<StorageResponse> | ||
getBucket(bucket: string): Promise<StorageResponse> | ||
deleteBucket(bucket: string): Promise<StorageResponse> | ||
listBuckets(): Promise<StorageResponse> | ||
upload(bucket: string, pathname: string, file: File | Buffer | Blob | string, options: { headers?: Record<string, string> }): Promise<StorageResponse> | ||
download(bucket: string, pathname: string): Promise<StorageResponse> | ||
remove(bucket: string, pathName: string): Promise<StorageResponse> | ||
listBucketContents(bucket: string): Promise<StorageResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters