@memori.ai/memori-api-client 6.0.4 → 6.0.6
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.
- package/CHANGELOG.md +19 -0
- package/dist/apiFetcher.d.ts +7 -0
- package/dist/apiFetcher.js +21 -1
- package/dist/apiFetcher.js.map +1 -1
- package/dist/backend/importExport.d.ts +1 -1
- package/dist/backend/importExport.js +5 -11
- package/dist/backend/importExport.js.map +1 -1
- package/dist/backend.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/esm/apiFetcher.d.ts +7 -0
- package/esm/apiFetcher.js +19 -0
- package/esm/apiFetcher.js.map +1 -1
- package/esm/backend/importExport.d.ts +1 -1
- package/esm/backend/importExport.js +6 -12
- package/esm/backend/importExport.js.map +1 -1
- package/esm/backend.d.ts +2 -2
- package/esm/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/apiFetcher.ts +36 -0
- package/src/backend/importExport.ts +9 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [6.0.6](https://github.com/memori-ai/memori-api-client/compare/v6.0.5...v6.0.6) (2025-03-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* introduce apiBinaryFetcher for handling binary responses in API calls ([3f9b037](https://github.com/memori-ai/memori-api-client/commit/3f9b03721b2548568846228db20eb094e2818a38))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update apiBinaryFetcher to be an async function ([4d4a674](https://github.com/memori-ai/memori-api-client/commit/4d4a6740e26e8b5312c030027dc9413ec710153f))
|
|
14
|
+
|
|
15
|
+
## [6.0.5](https://github.com/memori-ai/memori-api-client/compare/v6.0.4...v6.0.5) (2025-03-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Changes
|
|
19
|
+
|
|
20
|
+
* streamline apiFetcher usage for binary data handling in import/export functions ([6adc72a](https://github.com/memori-ai/memori-api-client/commit/6adc72a8293ef4ecc0cccc00c74fe3ee9e69164e))
|
|
21
|
+
|
|
3
22
|
## [6.0.4](https://github.com/memori-ai/memori-api-client/compare/v6.0.3...v6.0.4) (2025-03-25)
|
|
4
23
|
|
|
5
24
|
|
package/dist/apiFetcher.d.ts
CHANGED
|
@@ -5,3 +5,10 @@ export declare const apiFetcher: (path: string, opts: {
|
|
|
5
5
|
headers?: object;
|
|
6
6
|
text?: boolean;
|
|
7
7
|
}) => Promise<any>;
|
|
8
|
+
export declare const apiBinaryFetcher: (path: string, opts: {
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
body?: object;
|
|
12
|
+
headers?: object;
|
|
13
|
+
responseType?: 'arrayBuffer' | 'blob';
|
|
14
|
+
}) => Promise<Blob | ArrayBuffer>;
|
package/dist/apiFetcher.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apiFetcher = void 0;
|
|
3
|
+
exports.apiBinaryFetcher = exports.apiFetcher = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
6
6
|
const apiFetcher = (path, opts) => (0, cross_fetch_1.default)(`${opts.apiUrl}${path}`, {
|
|
@@ -14,4 +14,24 @@ const apiFetcher = (path, opts) => (0, cross_fetch_1.default)(`${opts.apiUrl}${p
|
|
|
14
14
|
},
|
|
15
15
|
}).then(res => ((opts === null || opts === void 0 ? void 0 : opts.text) ? res.text() : res.json()));
|
|
16
16
|
exports.apiFetcher = apiFetcher;
|
|
17
|
+
const apiBinaryFetcher = async (path, opts) => {
|
|
18
|
+
const responseType = (opts === null || opts === void 0 ? void 0 : opts.responseType) || 'arrayBuffer';
|
|
19
|
+
return (0, cross_fetch_1.default)(`${opts.apiUrl}${path}`, {
|
|
20
|
+
method: opts.method || 'GET',
|
|
21
|
+
body: (opts === null || opts === void 0 ? void 0 : opts.body) ? JSON.stringify(opts.body) : undefined,
|
|
22
|
+
mode: 'cors',
|
|
23
|
+
credentials: 'include',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
Accept: 'application/octet-stream, application/zip',
|
|
27
|
+
...opts === null || opts === void 0 ? void 0 : opts.headers,
|
|
28
|
+
},
|
|
29
|
+
}).then(async (res) => {
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw new Error(`API responded with status: ${res.status}`);
|
|
32
|
+
}
|
|
33
|
+
return responseType === 'blob' ? res.blob() : res.arrayBuffer();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.apiBinaryFetcher = apiBinaryFetcher;
|
|
17
37
|
//# sourceMappingURL=apiFetcher.js.map
|
package/dist/apiFetcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiFetcher.js","sourceRoot":"","sources":["../src/apiFetcher.ts"],"names":[],"mappings":";;;;AAAA,sEAA+C;AAExC,MAAM,UAAU,GAAG,CACxB,IAAY,EACZ,IAMC,EACD,EAAE,CACF,IAAA,qBAAK,EAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,EAAE;IAC7B,GAAG,IAAI;IACP,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;IACxD,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE;QAEP,cAAc,EAAE,kBAAkB;QAClC,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO;KACjB;CACF,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAA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,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;QAC5B,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACxD,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,2CAA2C;YACnD,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO;SACjB;KACF,CAAC,CAAC,IAAI,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;QAClB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;SAC7D;QAGD,OAAO,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,gBAAgB,oBA8B3B"}
|
|
@@ -17,6 +17,6 @@ declare const _default: (apiUrl: string) => {
|
|
|
17
17
|
}>;
|
|
18
18
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: CsvSpecs, password?: string) => Promise<string>;
|
|
19
19
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: JSONLSpecs, password?: string) => Promise<string>;
|
|
20
|
-
exportMemori: (authToken: string, memoriID: string, password?: string) => Promise<ArrayBuffer>;
|
|
20
|
+
exportMemori: (authToken: string, memoriID: string, password?: string) => Promise<Blob | ArrayBuffer>;
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
@@ -61,20 +61,14 @@ exports.default = (apiUrl) => ({
|
|
|
61
61
|
text: true,
|
|
62
62
|
}),
|
|
63
63
|
exportMemori: async (authToken, memoriID, password) => {
|
|
64
|
-
|
|
64
|
+
return (0, apiFetcher_1.apiBinaryFetcher)(`/ImportExport/ExportMemori/${authToken}/${memoriID}`, {
|
|
65
|
+
apiUrl,
|
|
65
66
|
method: 'POST',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Accept: 'application/octet-stream, application/zip',
|
|
67
|
+
body: {
|
|
68
|
+
password: password || '',
|
|
69
69
|
},
|
|
70
|
-
|
|
71
|
-
password,
|
|
72
|
-
}),
|
|
70
|
+
responseType: 'arrayBuffer',
|
|
73
71
|
});
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
throw new Error(`API responded with status: ${response.status}`);
|
|
76
|
-
}
|
|
77
|
-
return response.arrayBuffer();
|
|
78
72
|
},
|
|
79
73
|
});
|
|
80
74
|
//# sourceMappingURL=importExport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importExport.js","sourceRoot":"","sources":["../../src/backend/importExport.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"importExport.js","sourceRoot":"","sources":["../../src/backend/importExport.ts"],"names":[],"mappings":";;AAQA,8CAA6D;AAQ7D,kBAAe,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;IAQlC,SAAS,EAAE,KAAK,EACd,SAAiB,EACjB,QAAgB,EAChB,IAAc,EACd,MAAsC,EACtC,EAAE,CACF,IAAA,uBAAU,EAAC,2BAA2B,SAAS,IAAI,QAAQ,EAAE,EAAE;QAC7D,MAAM;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,IAAI;YACJ,GAAG,MAAM;SACV;KACF,CAIA;IASH,SAAS,EAAE,KAAK,EACd,SAAiB,EACjB,QAAgB,EAChB,IAAc,EACd,MAAsC,EACtC,EAAE,CACF,IAAA,uBAAU,EAAC,2BAA2B,SAAS,IAAI,QAAQ,EAAE,EAAE;QAC7D,MAAM;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,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AE;YACJ,UAAU;YACV,QAAQ;SACT;QACD,IAAI,EAAE,IAAI;KACX,CAAoB;IAEvB,YAAY,EAAE,KAAK,EACjB,SAAiB,EACjB,QAAgB,EAChB,QAAiB,EACjB,EAAE;QACF,OAAO,IAAA,6BAAgB,EAAC,8BAA8B,SAAS,IAAI,QAAQ,EAAE,EAAE;YAC7E,MAAM;YACN,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,QAAQ,EAAE,QAAQ,IAAI,EAAE;aACzB;YACD,YAAY,EAAE,aAAa;SAC5B,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/dist/backend.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare const backendAPI: (apiUrl: string) => {
|
|
|
79
79
|
}>;
|
|
80
80
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
81
81
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
82
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
82
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
83
83
|
getTenantNotifications: (tenantID: string) => Promise<import("./types").ResponseSpec & {
|
|
84
84
|
notifications: import("./types").Notification[];
|
|
85
85
|
}>;
|
|
@@ -452,7 +452,7 @@ declare const backendAPI: (apiUrl: string) => {
|
|
|
452
452
|
}>;
|
|
453
453
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
454
454
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
455
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
455
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
456
456
|
};
|
|
457
457
|
process: {
|
|
458
458
|
getProcesses: <T = import("./types").ProcessStatus>(authToken: string, processType?: "Import" | "Analysis" | undefined) => Promise<import("./types").ResponseSpec & {
|
package/dist/index.d.ts
CHANGED
|
@@ -799,7 +799,7 @@ declare const api: (backendEndpoint?: string, engineEndpoint?: string) => {
|
|
|
799
799
|
}>;
|
|
800
800
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
801
801
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
802
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
802
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
803
803
|
getTenantNotifications: (tenantID: string) => Promise<import("./types").ResponseSpec & {
|
|
804
804
|
notifications: import("./types").Notification[];
|
|
805
805
|
}>;
|
|
@@ -1172,7 +1172,7 @@ declare const api: (backendEndpoint?: string, engineEndpoint?: string) => {
|
|
|
1172
1172
|
}>;
|
|
1173
1173
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
1174
1174
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
1175
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
1175
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
1176
1176
|
};
|
|
1177
1177
|
process: {
|
|
1178
1178
|
getProcesses: <T = import("./types").ProcessStatus>(authToken: string, processType?: "Import" | "Analysis" | undefined) => Promise<import("./types").ResponseSpec & {
|
package/esm/apiFetcher.d.ts
CHANGED
|
@@ -5,3 +5,10 @@ export declare const apiFetcher: (path: string, opts: {
|
|
|
5
5
|
headers?: object;
|
|
6
6
|
text?: boolean;
|
|
7
7
|
}) => Promise<any>;
|
|
8
|
+
export declare const apiBinaryFetcher: (path: string, opts: {
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
body?: object;
|
|
12
|
+
headers?: object;
|
|
13
|
+
responseType?: 'arrayBuffer' | 'blob';
|
|
14
|
+
}) => Promise<Blob | ArrayBuffer>;
|
package/esm/apiFetcher.js
CHANGED
|
@@ -9,4 +9,23 @@ export const apiFetcher = (path, opts) => fetch(`${opts.apiUrl}${path}`, {
|
|
|
9
9
|
...opts === null || opts === void 0 ? void 0 : opts.headers,
|
|
10
10
|
},
|
|
11
11
|
}).then(res => ((opts === null || opts === void 0 ? void 0 : opts.text) ? res.text() : res.json()));
|
|
12
|
+
export const apiBinaryFetcher = async (path, opts) => {
|
|
13
|
+
const responseType = (opts === null || opts === void 0 ? void 0 : opts.responseType) || 'arrayBuffer';
|
|
14
|
+
return fetch(`${opts.apiUrl}${path}`, {
|
|
15
|
+
method: opts.method || 'GET',
|
|
16
|
+
body: (opts === null || opts === void 0 ? void 0 : opts.body) ? JSON.stringify(opts.body) : undefined,
|
|
17
|
+
mode: 'cors',
|
|
18
|
+
credentials: 'include',
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
Accept: 'application/octet-stream, application/zip',
|
|
22
|
+
...opts === null || opts === void 0 ? void 0 : opts.headers,
|
|
23
|
+
},
|
|
24
|
+
}).then(async (res) => {
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
throw new Error(`API responded with status: ${res.status}`);
|
|
27
|
+
}
|
|
28
|
+
return responseType === 'blob' ? res.blob() : res.arrayBuffer();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
12
31
|
//# sourceMappingURL=apiFetcher.js.map
|
package/esm/apiFetcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiFetcher.js","sourceRoot":"","sources":["../src/apiFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAY,EACZ,IAMC,EACD,EAAE,CACF,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,EAAE;IAC7B,GAAG,IAAI;IACP,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;IACxD,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE;QAEP,cAAc,EAAE,kBAAkB;QAClC,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO;KACjB;CACF,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"apiFetcher.js","sourceRoot":"","sources":["../src/apiFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAY,EACZ,IAMC,EACD,EAAE,CACF,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,EAAE;IAC7B,GAAG,IAAI;IACP,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC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AC7D;QAGD,OAAO,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -17,6 +17,6 @@ declare const _default: (apiUrl: string) => {
|
|
|
17
17
|
}>;
|
|
18
18
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: CsvSpecs, password?: string) => Promise<string>;
|
|
19
19
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: JSONLSpecs, password?: string) => Promise<string>;
|
|
20
|
-
exportMemori: (authToken: string, memoriID: string, password?: string) => Promise<ArrayBuffer>;
|
|
20
|
+
exportMemori: (authToken: string, memoriID: string, password?: string) => Promise<Blob | ArrayBuffer>;
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { apiFetcher } from '../apiFetcher';
|
|
1
|
+
import { apiBinaryFetcher, apiFetcher } from '../apiFetcher';
|
|
2
2
|
export default (apiUrl) => ({
|
|
3
3
|
importCSV: async (authToken, memoriID, rows, params) => apiFetcher(`/ImportExport/ImportCSV/${authToken}/${memoriID}`, {
|
|
4
4
|
apiUrl,
|
|
@@ -59,20 +59,14 @@ export default (apiUrl) => ({
|
|
|
59
59
|
text: true,
|
|
60
60
|
}),
|
|
61
61
|
exportMemori: async (authToken, memoriID, password) => {
|
|
62
|
-
|
|
62
|
+
return apiBinaryFetcher(`/ImportExport/ExportMemori/${authToken}/${memoriID}`, {
|
|
63
|
+
apiUrl,
|
|
63
64
|
method: 'POST',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Accept: 'application/octet-stream, application/zip',
|
|
65
|
+
body: {
|
|
66
|
+
password: password || '',
|
|
67
67
|
},
|
|
68
|
-
|
|
69
|
-
password,
|
|
70
|
-
}),
|
|
68
|
+
responseType: 'arrayBuffer',
|
|
71
69
|
});
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw new Error(`API responded with status: ${response.status}`);
|
|
74
|
-
}
|
|
75
|
-
return response.arrayBuffer();
|
|
76
70
|
},
|
|
77
71
|
});
|
|
78
72
|
//# sourceMappingURL=importExport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importExport.js","sourceRoot":"","sources":["../../src/backend/importExport.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"importExport.js","sourceRoot":"","sources":["../../src/backend/importExport.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQ7D,eAAe,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;IAQlC,SAAS,EAAE,KAAK,EACd,SAAiB,EACjB,QAAgB,EAChB,IAAc,EACd,MAAsC,EACtC,EAAE,CACF,UAAU,CAAC,2BAA2B,SAAS,IAAI,QAAQ,EAAE,EAAE;QAC7D,MAAM;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,IAAI;YACJ,GAAG,MAAM;SACV;KACF,CAIA;IASH,SAAS,EAAE,KAAK,EACd,SAAiB,EACjB,QAAgB,EAChB,IAAc,EACd,MAAsC,EACtC,EAAE,CACF,UAAU,CAAC,2BAA2B,SAAS,IAAI,QAAQ,EAAE,EAAE;QAC7D,MAAM;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,IAAI;YACJ,GAAG,MAAM;SACV;KACF,CAIA;IASH,gBAAgB,EAAE,KAAK,EACrB,SAAiB,EACjB,QAAgB,EAChB,IAAc,EACd,MAAsC,EACtC,EAAE,CACF,UAAU,CAAC,kCAAkC,SAAS,IAAI,QAAQ,EAAE,EAAE;QACpE,MAAM;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,IAAI;YACJ,GAAG,MAAM;SACV;KACF,CAIA;IASH,sBAAsB,E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AC5B,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/esm/backend.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare const backendAPI: (apiUrl: string) => {
|
|
|
79
79
|
}>;
|
|
80
80
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
81
81
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
82
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
82
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
83
83
|
getTenantNotifications: (tenantID: string) => Promise<import("./types").ResponseSpec & {
|
|
84
84
|
notifications: import("./types").Notification[];
|
|
85
85
|
}>;
|
|
@@ -452,7 +452,7 @@ declare const backendAPI: (apiUrl: string) => {
|
|
|
452
452
|
}>;
|
|
453
453
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
454
454
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
455
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
455
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
456
456
|
};
|
|
457
457
|
process: {
|
|
458
458
|
getProcesses: <T = import("./types").ProcessStatus>(authToken: string, processType?: "Import" | "Analysis" | undefined) => Promise<import("./types").ResponseSpec & {
|
package/esm/index.d.ts
CHANGED
|
@@ -799,7 +799,7 @@ declare const api: (backendEndpoint?: string, engineEndpoint?: string) => {
|
|
|
799
799
|
}>;
|
|
800
800
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
801
801
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
802
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
802
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
803
803
|
getTenantNotifications: (tenantID: string) => Promise<import("./types").ResponseSpec & {
|
|
804
804
|
notifications: import("./types").Notification[];
|
|
805
805
|
}>;
|
|
@@ -1172,7 +1172,7 @@ declare const api: (backendEndpoint?: string, engineEndpoint?: string) => {
|
|
|
1172
1172
|
}>;
|
|
1173
1173
|
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
1174
1174
|
exportJSONL: (authToken: string, memoriID: string, jsonlSpecs: import("./types").JSONLSpecs, password?: string | undefined) => Promise<string>;
|
|
1175
|
-
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<ArrayBuffer>;
|
|
1175
|
+
exportMemori: (authToken: string, memoriID: string, password?: string | undefined) => Promise<Blob | ArrayBuffer>;
|
|
1176
1176
|
};
|
|
1177
1177
|
process: {
|
|
1178
1178
|
getProcesses: <T = import("./types").ProcessStatus>(authToken: string, processType?: "Import" | "Analysis" | undefined) => Promise<import("./types").ResponseSpec & {
|
package/package.json
CHANGED
package/src/apiFetcher.ts
CHANGED
|
@@ -21,3 +21,39 @@ export const apiFetcher = (
|
|
|
21
21
|
...opts?.headers,
|
|
22
22
|
},
|
|
23
23
|
}).then(res => (opts?.text ? res.text() : res.json()));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A specialized API fetcher for handling binary responses
|
|
27
|
+
* Use this function when you need to download files or process binary data
|
|
28
|
+
*/
|
|
29
|
+
export const apiBinaryFetcher = async (
|
|
30
|
+
path: string,
|
|
31
|
+
opts: {
|
|
32
|
+
apiUrl: string;
|
|
33
|
+
method?: string;
|
|
34
|
+
body?: object;
|
|
35
|
+
headers?: object;
|
|
36
|
+
responseType?: 'arrayBuffer' | 'blob'; // Types of binary responses
|
|
37
|
+
}
|
|
38
|
+
) => {
|
|
39
|
+
const responseType = opts?.responseType || 'arrayBuffer';
|
|
40
|
+
|
|
41
|
+
return fetch(`${opts.apiUrl}${path}`, {
|
|
42
|
+
method: opts.method || 'GET',
|
|
43
|
+
body: opts?.body ? JSON.stringify(opts.body) : undefined,
|
|
44
|
+
mode: 'cors',
|
|
45
|
+
credentials: 'include',
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
Accept: 'application/octet-stream, application/zip',
|
|
49
|
+
...opts?.headers,
|
|
50
|
+
},
|
|
51
|
+
}).then(async res => {
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
throw new Error(`API responded with status: ${res.status}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Return the appropriate binary format
|
|
57
|
+
return responseType === 'blob' ? res.blob() : res.arrayBuffer();
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
JSONLSpecs,
|
|
7
7
|
ImportMemoriParams,
|
|
8
8
|
} from '../types';
|
|
9
|
-
import { apiFetcher } from '../apiFetcher';
|
|
9
|
+
import { apiBinaryFetcher, apiFetcher } from '../apiFetcher';
|
|
10
10
|
|
|
11
11
|
/************************
|
|
12
12
|
* *
|
|
@@ -195,32 +195,18 @@ export default (apiUrl: string) => ({
|
|
|
195
195
|
text: true,
|
|
196
196
|
}) as Promise<string>,
|
|
197
197
|
|
|
198
|
-
// Updated exportMemori function for the API repository
|
|
199
198
|
exportMemori: async (
|
|
200
199
|
authToken: string,
|
|
201
200
|
memoriID: string,
|
|
202
201
|
password?: string
|
|
203
202
|
) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
body: JSON.stringify({
|
|
214
|
-
password,
|
|
215
|
-
}),
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
if (!response.ok) {
|
|
220
|
-
throw new Error(`API responded with status: ${response.status}`);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Return the binary data as ArrayBuffer
|
|
224
|
-
return response.arrayBuffer();
|
|
203
|
+
return apiBinaryFetcher(`/ImportExport/ExportMemori/${authToken}/${memoriID}`, {
|
|
204
|
+
apiUrl,
|
|
205
|
+
method: 'POST',
|
|
206
|
+
body: {
|
|
207
|
+
password: password || '',
|
|
208
|
+
},
|
|
209
|
+
responseType: 'arrayBuffer',
|
|
210
|
+
});
|
|
225
211
|
},
|
|
226
212
|
});
|