Skip to content

Commit

Permalink
fix: definition
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Sep 4, 2024
1 parent 98ff4ce commit 384eb70
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ startUpload(options: uploadOption) => Promise<{ id: string; }>

**Returns:** <code>Promise&lt;{ id: string; }&gt;</code>

**Since:** 1.0.0
**Since:** 0.0.1

--------------------

Expand All @@ -162,7 +162,7 @@ removeUpload(options: { id: string; }) => Promise<void>
| ------------- | ---------------------------- |
| **`options`** | <code>{ id: string; }</code> |

**Since:** 1.0.0
**Since:** 0.0.1

--------------------

Expand All @@ -180,7 +180,7 @@ addListener(eventName: "events", listenerFunc: (state: UploadEvent) => void) =>

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

**Since:** 1.0.0
**Since:** 0.0.1

--------------------

Expand All @@ -192,14 +192,14 @@ addListener(eventName: "events", listenerFunc: (state: UploadEvent) => void) =>

| Prop | Type | Default | Since |
| ----------------------- | --------------------------------------- | ------------------------ | ----- |
| **`filePath`** | <code>string</code> | | 1.0.0 |
| **`serverUrl`** | <code>string</code> | | 1.0.0 |
| **`notificationTitle`** | <code>number</code> | <code>'Uploading'</code> | 1.0.0 |
| **`headers`** | <code>{ [key: string]: string; }</code> | | 1.0.0 |
| **`method`** | <code>'PUT' \| 'POST'</code> | <code>'POST'</code> | 1.0.0 |
| **`mimeType`** | <code>string</code> | | 1.0.0 |
| **`parameters`** | <code>{ [key: string]: string; }</code> | | 1.0.0 |
| **`maxRetries`** | <code>number</code> | | 1.0.0 |
| **`filePath`** | <code>string</code> | | 0.0.1 |
| **`serverUrl`** | <code>string</code> | | 0.0.1 |
| **`notificationTitle`** | <code>number</code> | <code>'Uploading'</code> | 0.0.1 |
| **`headers`** | <code>{ [key: string]: string; }</code> | | 0.0.1 |
| **`method`** | <code>'PUT' \| 'POST'</code> | <code>'POST'</code> | 0.0.1 |
| **`mimeType`** | <code>string</code> | | 0.0.1 |
| **`parameters`** | <code>{ [key: string]: string; }</code> | | 0.0.1 |
| **`maxRetries`** | <code>number</code> | | 0.0.1 |


#### PluginListenerHandle
Expand All @@ -213,9 +213,9 @@ addListener(eventName: "events", listenerFunc: (state: UploadEvent) => void) =>

| Prop | Type | Description | Default | Since |
| ------------- | ----------------------------------------------------------------------- | -------------------------------------------- | ----------------------------------------------------- | ----- |
| **`name`** | <code>'uploading' \| 'completed' \| 'failed'</code> | Current status of upload, between 0 and 100. | | 1.0.0 |
| **`payload`** | <code>{ percent?: number; error?: string; statusCode?: number; }</code> | | <code>{ percent: 0, error: '', statusCode: 0 }</code> | 1.0.0 |
| **`id`** | <code>string</code> | | | 1.0.0 |
| **`name`** | <code>'uploading' \| 'completed' \| 'failed'</code> | Current status of upload, between 0 and 100. | | 0.0.1 |
| **`payload`** | <code>{ percent?: number; error?: string; statusCode?: number; }</code> | | <code>{ percent: 0, error: '', statusCode: 0 }</code> | 0.0.1 |
| **`id`** | <code>string</code> | | | 0.0.1 |

</docgen-api>

Expand Down
34 changes: 17 additions & 17 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ import type { PluginListenerHandle } from "@capacitor/core";

export interface uploadOption {
/**
* @since 1.0.0
* @since 0.0.1
* @description The file path of the file to upload
*/
filePath: string;
/**
* @since 1.0.0
* @since 0.0.1
* @description The url of the server
*/
serverUrl: string;
/**
* @since 1.0.0
* @since 0.0.1
* @default 'Uploading'
* @description The title of the notification
* Android only
*/
notificationTitle?: number;
/**
* @since 1.0.0
* @since 0.0.1
* @description The headers to send with the request
*/
headers: {
[key: string]: string;
};
/**
* @since 1.0.0
* @since 0.0.1
* @description The method to use for the request
* @default 'POST'
*/
method?: "PUT" | "POST";
/**
* @since 1.0.0
* @since 0.0.1
* @description The mime type to use for the request
*/
mimeType?: string;
/**
* @since 1.0.0
* @since 0.0.1
* @description The parameters to send with the request
*/
parameters?: { [key: string]: string };
/**
* @since 1.0.0
* @since 0.0.1
* @description The maximum number of retries
*/
maxRetries?: number;
Expand All @@ -51,55 +51,55 @@ export interface UploadEvent {
/**
* Current status of upload, between 0 and 100.
*
* @since 1.0.0
* @since 0.0.1
*/
name: "uploading" | "completed" | "failed";
/**
* @since 1.0.0
* @since 0.0.1
* @description The payload of the event
* @default { percent: 0, error: '', statusCode: 0 }
*/
payload: {
/**
* @since 1.0.0
* @since 0.0.1
* @description The percent of the upload
*/
percent?: number;
/**
* @since 1.0.0
* @since 0.0.1
* @description The error of the upload
*/
error?: string;
/**
* @since 1.0.0
* @since 0.0.1
* @description The status code of the upload
*/
statusCode?: number;
};
/**
* @since 1.0.0
* @since 0.0.1
* @description The id of the upload
*/
id: string;
}

export interface UploaderPlugin {
/**
* @since 1.0.0
* @since 0.0.1
* @description Start the upload
* @param options uploadOption
* @returns { id: string }
*/
startUpload(options: uploadOption): Promise<{ id: string }>;
/**
* @since 1.0.0
* @since 0.0.1
* @description Remove the upload
* @param options
* @returns { void }
*/
removeUpload(options: { id: string }): Promise<void>;
/**
* @since 1.0.0
* @since 0.0.1
* @description Add a listener for the upload events
* @param eventName
* @param listenerFunc
Expand Down

0 comments on commit 384eb70

Please sign in to comment.