@spica-devkit/storage 0.0.0-PLACEHOLDER

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,2 @@
1
+ export * from "./storage";
2
+ export * from "./interface";
@@ -0,0 +1,34 @@
1
+ interface InitializeOptions {
2
+ publicUrl?: string;
3
+ }
4
+ export interface ApikeyInitialization extends InitializeOptions {
5
+ apikey: string;
6
+ }
7
+ export interface IdentityInitialization extends InitializeOptions {
8
+ identity: string;
9
+ }
10
+ export interface InitializationResult {
11
+ authorization: string;
12
+ publicUrl: string;
13
+ }
14
+ export interface IndexResult<T> {
15
+ meta: {
16
+ total: number;
17
+ };
18
+ data: T[];
19
+ }
20
+ export interface StorageObject {
21
+ _id: string;
22
+ name: string;
23
+ url: string;
24
+ content: {
25
+ type: string;
26
+ size: number;
27
+ };
28
+ }
29
+ export interface BufferWithMeta {
30
+ data: any;
31
+ name: string;
32
+ contentType: string;
33
+ }
34
+ export {};
@@ -0,0 +1,16 @@
1
+ import { StorageObject, BufferWithMeta, IndexResult, ApikeyInitialization, IdentityInitialization } from "./interface";
2
+ export declare function initialize(options: ApikeyInitialization | IdentityInitialization): void;
3
+ export declare function insert(object: File | BufferWithMeta, onUploadProgress?: (progress: ProgressEvent) => void): Promise<StorageObject>;
4
+ export declare function insertMany(objects: FileList | (File | BufferWithMeta)[], onUploadProgress?: (progress: ProgressEvent) => void): Promise<StorageObject[]>;
5
+ export declare function get(id: string): Promise<StorageObject>;
6
+ export declare function download(id: string, options?: {
7
+ headers?: any;
8
+ onDownloadProgress?: (progress: ProgressEvent) => void;
9
+ }): Promise<unknown>;
10
+ export declare function getAll(queryParams?: {
11
+ limit?: number;
12
+ skip?: number;
13
+ sort?: object;
14
+ }): Promise<IndexResult<StorageObject>>;
15
+ export declare function update(id: string, object: File | BufferWithMeta, onUploadProgress?: (progress: ProgressEvent) => void): Promise<StorageObject>;
16
+ export declare function remove(id: string): any;
@@ -0,0 +1,5 @@
1
+ import { BufferWithMeta } from "./interface";
2
+ export declare function fileToBuffer(file: File): Promise<any>;
3
+ export declare function preparePostBody(objects: FileList | (BufferWithMeta | File)[]): Promise<ArrayBufferLike>;
4
+ export declare function preparePutBody(object: File | BufferWithMeta): Promise<ArrayBufferLike>;
5
+ export declare function jsonToArrayBuffer(body: object): ArrayBufferLike;
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@spica-devkit/storage",
3
+ "license": "AGPLv3",
4
+ "version": "0.0.0-PLACEHOLDER",
5
+ "description": "Storage package for Spica.",
6
+ "author": "spica",
7
+ "keywords": [
8
+ "spica",
9
+ "devkit"
10
+ ],
11
+ "main": "dist/index",
12
+ "module": "dist/index.mjs",
13
+ "types": "dist/index.d.ts",
14
+ "typings": "dist/index.d.ts",
15
+ "sideEffects": false,
16
+ "dependencies": {
17
+ "bson": "^4.2.2",
18
+ "axios": "^0.21.1"
19
+ }
20
+ }