orgnote-api 0.11.2 → 0.11.3

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/files-api.ts +25 -0
  2. package/index.ts +1 -25
  3. package/package.json +2 -1
package/files-api.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { Axios } from 'axios';
2
+ import { Stream } from 'stream';
3
+
4
+ // NOTE: patch cause of incorrect generated api (form-data and swaggo)
5
+ export const initFilesApi = (axiosInstance: Axios) => {
6
+ return {
7
+ uploadFile: async (file: File) => {
8
+ const formData = new FormData();
9
+ formData.append('files', file);
10
+ const response = await axiosInstance.post('/files/upload', formData, {
11
+ headers: {
12
+ 'Content-Type': 'multipart/form-data',
13
+ },
14
+ });
15
+ return response.data;
16
+ },
17
+ downloadFile: async (relativeFilePath: string): Promise<Stream> => {
18
+ const downloadedFilePath = `/media/${relativeFilePath}`;
19
+ const stream = await axiosInstance
20
+ .get(downloadedFilePath, { responseType: 'stream' })
21
+ .then((r) => r.data);
22
+ return stream;
23
+ },
24
+ } as const;
25
+ };
package/index.ts CHANGED
@@ -3,29 +3,5 @@ export * from './models';
3
3
  import type * as ast from 'org-mode-ast';
4
4
  export * from './encryption';
5
5
  export * from './tools';
6
+ export * from './files-api';
6
7
  export { ast };
7
- import { Axios } from 'axios';
8
- import { Stream } from 'stream';
9
-
10
- // NOTE: patch cause of incorrect generated api (form-data and swaggo)
11
- export const initFilesApi = (axiosInstance: Axios) => {
12
- return {
13
- uploadFile: async (file: File) => {
14
- const formData = new FormData();
15
- formData.append('files', file);
16
- const response = await axiosInstance.post('/files/upload', formData, {
17
- headers: {
18
- 'Content-Type': 'multipart/form-data',
19
- },
20
- });
21
- return response.data;
22
- },
23
- downloadFile: async (relativeFilePath: string): Promise<Stream> => {
24
- const downloadedFilePath = `/media/${relativeFilePath}`;
25
- const stream = await axiosInstance
26
- .get(downloadedFilePath, { responseType: 'stream' })
27
- .then((r) => r.data);
28
- return stream;
29
- },
30
- } as const;
31
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -20,6 +20,7 @@
20
20
  "files": [
21
21
  "index.ts",
22
22
  "api.ts",
23
+ "files-api.ts",
23
24
  "remote-api/**",
24
25
  "models/**",
25
26
  "encryption/**",