@memori.ai/memori-api-client 2.1.5 → 2.2.0
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 +7 -0
- package/dist/backend/importExport.d.ts +20 -0
- package/dist/backend/importExport.js +43 -0
- package/dist/backend/importExport.js.map +1 -0
- package/dist/backend/importExport.test.d.ts +1 -0
- package/dist/backend/importExport.test.js +14 -0
- package/dist/backend/importExport.test.js.map +1 -0
- package/dist/backend.d.ts +34 -0
- package/dist/backend.js +3 -0
- package/dist/backend.js.map +1 -1
- package/dist/engine.d.ts +0 -34
- package/dist/engine.js +0 -3
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +34 -34
- package/dist/types.d.ts +30 -18
- package/esm/backend/importExport.d.ts +20 -0
- package/esm/backend/importExport.js +41 -0
- package/esm/backend/importExport.js.map +1 -0
- package/esm/backend/importExport.test.d.ts +1 -0
- package/esm/backend/importExport.test.js +11 -0
- package/esm/backend/importExport.test.js.map +1 -0
- package/esm/backend.d.ts +34 -0
- package/esm/backend.js +3 -0
- package/esm/backend.js.map +1 -1
- package/esm/engine.d.ts +0 -34
- package/esm/engine.js +0 -3
- package/esm/engine.js.map +1 -1
- package/esm/index.d.ts +34 -34
- package/esm/types.d.ts +30 -18
- package/package.json +1 -1
- package/src/backend/importExport.test.ts +23 -0
- package/src/backend/importExport.ts +135 -0
- package/src/backend.ts +3 -0
- package/src/engine.ts +0 -3
- package/src/types.ts +68 -18
- package/src/engine/importExport.test.ts +0 -38
- package/src/engine/importExport.ts +0 -115
package/esm/engine.d.ts
CHANGED
|
@@ -389,40 +389,6 @@ declare const _default: (apiUrl: string) => {
|
|
|
389
389
|
intentSlotID: string;
|
|
390
390
|
}>;
|
|
391
391
|
};
|
|
392
|
-
importCSV: (sessionId: string, rows: string[], params: import("./types").ImportParams) => Promise<import("./types").ResponseSpec & {
|
|
393
|
-
status: import("./types").ImportResponse;
|
|
394
|
-
}>;
|
|
395
|
-
importProcesses: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
396
|
-
importProcesses: import("./types").ImportResponse[];
|
|
397
|
-
}>;
|
|
398
|
-
importStatus: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
399
|
-
status: import("./types").ImportResponse;
|
|
400
|
-
}>;
|
|
401
|
-
stopImport: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
402
|
-
status: import("./types").ImportResponse;
|
|
403
|
-
}>;
|
|
404
|
-
importTXT: (sessionId: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
405
|
-
status: import("./types").ImportResponse;
|
|
406
|
-
}>;
|
|
407
|
-
exportCSV: (sessionID: string, params: import("./types").ExportCSVParams) => Promise<string>;
|
|
408
|
-
importExport: {
|
|
409
|
-
importCSV: (sessionId: string, rows: string[], params: import("./types").ImportParams) => Promise<import("./types").ResponseSpec & {
|
|
410
|
-
status: import("./types").ImportResponse;
|
|
411
|
-
}>;
|
|
412
|
-
importProcesses: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
413
|
-
importProcesses: import("./types").ImportResponse[];
|
|
414
|
-
}>;
|
|
415
|
-
importStatus: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
416
|
-
status: import("./types").ImportResponse;
|
|
417
|
-
}>;
|
|
418
|
-
stopImport: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
419
|
-
status: import("./types").ImportResponse;
|
|
420
|
-
}>;
|
|
421
|
-
importTXT: (sessionId: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
422
|
-
status: import("./types").ImportResponse;
|
|
423
|
-
}>;
|
|
424
|
-
exportCSV: (sessionID: string, params: import("./types").ExportCSVParams) => Promise<string>;
|
|
425
|
-
};
|
|
426
392
|
postTextEnteredEvent: ({ sessionId, text, }: {
|
|
427
393
|
sessionId: string;
|
|
428
394
|
text: string;
|
package/esm/engine.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import correlationPairs from './engine/correlationPairs';
|
|
2
2
|
import dialog from './engine/dialog';
|
|
3
|
-
import importExport from './engine/importExport';
|
|
4
3
|
import intents from './engine/intents';
|
|
5
4
|
import localizationKeys from './engine/localizationKeys';
|
|
6
5
|
import media from './engine/media';
|
|
@@ -20,8 +19,6 @@ export default (apiUrl) => ({
|
|
|
20
19
|
...correlationPairs(apiUrl),
|
|
21
20
|
dialog: dialog(apiUrl),
|
|
22
21
|
...dialog(apiUrl),
|
|
23
|
-
importExport: importExport(apiUrl),
|
|
24
|
-
...importExport(apiUrl),
|
|
25
22
|
intents: intents(apiUrl),
|
|
26
23
|
...intents(apiUrl),
|
|
27
24
|
localizationKeys: localizationKeys(apiUrl),
|
package/esm/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,mBAAmB,MAAM,8BAA8B,CAAC;AAC/D,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,eAAe,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;IAClC,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAC1C,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IACtB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC;IACxB,GAAG,OAAO,CAAC,MAAM,CAAC;IAClB,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAC1C,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;IACpB,GAAG,KAAK,CAAC,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;IAC1B,GAAG,QAAQ,CAAC,MAAM,CAAC;IACnB,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAChB,GAAG,GAAG,CAAC,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IACtB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjB,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAC5C,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IACtB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC;IACxB,GAAG,OAAO,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;IACpB,GAAG,KAAK,CAAC,MAAM,CAAC;IAChB,mBAAmB,EAAE,mBAAmB,CAAC,MAAM,CAAC;IAChD,GAAG,mBAAmB,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IAChC,GAAG,WAAW,CAAC,MAAM,CAAC;IACtB,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAC1C,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;IAC1B,GAAG,QAAQ,CAAC,MAAM,CAAC;CACpB,CAAC,CAAC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -394,40 +394,6 @@ declare const api: (hostname?: string) => {
|
|
|
394
394
|
intentSlotID: string;
|
|
395
395
|
}>;
|
|
396
396
|
};
|
|
397
|
-
importCSV: (sessionId: string, rows: string[], params: import("./types").ImportParams) => Promise<import("./types").ResponseSpec & {
|
|
398
|
-
status: import("./types").ImportResponse;
|
|
399
|
-
}>;
|
|
400
|
-
importProcesses: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
401
|
-
importProcesses: import("./types").ImportResponse[];
|
|
402
|
-
}>;
|
|
403
|
-
importStatus: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
404
|
-
status: import("./types").ImportResponse;
|
|
405
|
-
}>;
|
|
406
|
-
stopImport: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
407
|
-
status: import("./types").ImportResponse;
|
|
408
|
-
}>;
|
|
409
|
-
importTXT: (sessionId: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
410
|
-
status: import("./types").ImportResponse;
|
|
411
|
-
}>;
|
|
412
|
-
exportCSV: (sessionID: string, params: import("./types").ExportCSVParams) => Promise<string>;
|
|
413
|
-
importExport: {
|
|
414
|
-
importCSV: (sessionId: string, rows: string[], params: import("./types").ImportParams) => Promise<import("./types").ResponseSpec & {
|
|
415
|
-
status: import("./types").ImportResponse;
|
|
416
|
-
}>;
|
|
417
|
-
importProcesses: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
418
|
-
importProcesses: import("./types").ImportResponse[];
|
|
419
|
-
}>;
|
|
420
|
-
importStatus: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
421
|
-
status: import("./types").ImportResponse;
|
|
422
|
-
}>;
|
|
423
|
-
stopImport: (importID: string) => Promise<import("./types").ResponseSpec & {
|
|
424
|
-
status: import("./types").ImportResponse;
|
|
425
|
-
}>;
|
|
426
|
-
importTXT: (sessionId: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
427
|
-
status: import("./types").ImportResponse;
|
|
428
|
-
}>;
|
|
429
|
-
exportCSV: (sessionID: string, params: import("./types").ExportCSVParams) => Promise<string>;
|
|
430
|
-
};
|
|
431
397
|
postTextEnteredEvent: ({ sessionId, text, }: {
|
|
432
398
|
sessionId: string;
|
|
433
399
|
text: string;
|
|
@@ -503,6 +469,22 @@ declare const api: (hostname?: string) => {
|
|
|
503
469
|
deleteCorrelationPair: (sessionId: string, pairId: string) => Promise<import("./types").ResponseSpec>;
|
|
504
470
|
};
|
|
505
471
|
backend: {
|
|
472
|
+
importCSV: (authToken: string, memoriID: string, rows: string[], params: Omit<import("./types").ImportParams, "txtSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
473
|
+
status: import("./types").ImportResponse;
|
|
474
|
+
}>;
|
|
475
|
+
importTXT: (authToken: string, memoriID: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
476
|
+
status: import("./types").ImportResponse;
|
|
477
|
+
}>;
|
|
478
|
+
importProcesses: (authToken: string) => Promise<import("./types").ResponseSpec & {
|
|
479
|
+
importProcesses: import("./types").ImportResponse[];
|
|
480
|
+
}>;
|
|
481
|
+
importStatus: (authToken: string, importID: string) => Promise<import("./types").ResponseSpec & {
|
|
482
|
+
status: import("./types").ImportResponse;
|
|
483
|
+
}>;
|
|
484
|
+
stopImport: (authToken: string, importID: string) => Promise<import("./types").ResponseSpec & {
|
|
485
|
+
status: import("./types").ImportResponse;
|
|
486
|
+
}>;
|
|
487
|
+
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
506
488
|
getTenantNotifications: (tenantID: string) => Promise<import("./types").ResponseSpec & {
|
|
507
489
|
notifications: import("./types").Notification[];
|
|
508
490
|
}>;
|
|
@@ -845,6 +827,24 @@ declare const api: (hostname?: string) => {
|
|
|
845
827
|
notifications: import("./types").Notification[];
|
|
846
828
|
}>;
|
|
847
829
|
};
|
|
830
|
+
importExport: {
|
|
831
|
+
importCSV: (authToken: string, memoriID: string, rows: string[], params: Omit<import("./types").ImportParams, "txtSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
832
|
+
status: import("./types").ImportResponse;
|
|
833
|
+
}>;
|
|
834
|
+
importTXT: (authToken: string, memoriID: string, rows: string[], params: Omit<import("./types").ImportParams, "csvSpecs">) => Promise<import("./types").ResponseSpec & {
|
|
835
|
+
status: import("./types").ImportResponse;
|
|
836
|
+
}>;
|
|
837
|
+
importProcesses: (authToken: string) => Promise<import("./types").ResponseSpec & {
|
|
838
|
+
importProcesses: import("./types").ImportResponse[];
|
|
839
|
+
}>;
|
|
840
|
+
importStatus: (authToken: string, importID: string) => Promise<import("./types").ResponseSpec & {
|
|
841
|
+
status: import("./types").ImportResponse;
|
|
842
|
+
}>;
|
|
843
|
+
stopImport: (authToken: string, importID: string) => Promise<import("./types").ResponseSpec & {
|
|
844
|
+
status: import("./types").ImportResponse;
|
|
845
|
+
}>;
|
|
846
|
+
exportCSV: (authToken: string, memoriID: string, csvSpecs: import("./types").CsvSpecs, password?: string | undefined) => Promise<string>;
|
|
847
|
+
};
|
|
848
848
|
};
|
|
849
849
|
};
|
|
850
850
|
export default api;
|
package/esm/types.d.ts
CHANGED
|
@@ -227,6 +227,12 @@ export declare type OpenSession = {
|
|
|
227
227
|
initialQuestion?: string;
|
|
228
228
|
forceCloseSessions?: boolean;
|
|
229
229
|
birthDate?: string;
|
|
230
|
+
additionalInfo?: {
|
|
231
|
+
userID?: string;
|
|
232
|
+
email?: string;
|
|
233
|
+
language?: string;
|
|
234
|
+
referral?: string;
|
|
235
|
+
};
|
|
230
236
|
};
|
|
231
237
|
export declare type MemoriSession = {
|
|
232
238
|
sessionID: string;
|
|
@@ -587,7 +593,8 @@ export type CustomWord = {
|
|
|
587
593
|
lastChangeTimestamp: string;
|
|
588
594
|
lastChangeSessionID: string;
|
|
589
595
|
};
|
|
590
|
-
export interface
|
|
596
|
+
export interface CsvSpecs {
|
|
597
|
+
newLine: '\n' | '\r\n';
|
|
591
598
|
hasHeaders?: boolean;
|
|
592
599
|
headerNames?: string[];
|
|
593
600
|
questionColumnName: string;
|
|
@@ -597,34 +604,25 @@ export interface ImportCSVParams {
|
|
|
597
604
|
csvSeparator?: string;
|
|
598
605
|
questionTitleVariantsSeparator?: string;
|
|
599
606
|
}
|
|
600
|
-
export interface
|
|
601
|
-
|
|
607
|
+
export interface TxtSpecs {
|
|
608
|
+
granularity?: 'LOW' | 'MEDIUM' | 'HIGH';
|
|
609
|
+
attachSource?: boolean;
|
|
610
|
+
sourceAttachmentTitle?: string;
|
|
611
|
+
questionsGenerationInstructions?: string;
|
|
602
612
|
}
|
|
603
613
|
export interface ImportParams {
|
|
604
|
-
includedRows?: number[];
|
|
605
614
|
forceImport?: boolean;
|
|
606
|
-
csvSpecs?:
|
|
607
|
-
txtSpecs?:
|
|
615
|
+
csvSpecs?: CsvSpecs;
|
|
616
|
+
txtSpecs?: TxtSpecs;
|
|
608
617
|
conclusive?: boolean;
|
|
609
618
|
notPickable?: boolean;
|
|
610
619
|
contextVarsToSet?: {
|
|
611
620
|
[key: string]: string;
|
|
612
621
|
};
|
|
613
622
|
}
|
|
614
|
-
export interface ExportCSVParams {
|
|
615
|
-
newLine: '\n' | '\r\n';
|
|
616
|
-
hasHeaders?: boolean;
|
|
617
|
-
questionColumnName: string;
|
|
618
|
-
answerColumnName: string;
|
|
619
|
-
contextVarsToMatchColumnName?: string;
|
|
620
|
-
contextVarsToSetColumnName?: string;
|
|
621
|
-
csvSeparator?: string;
|
|
622
|
-
questionTitleVariantsSeparator?: string;
|
|
623
|
-
}
|
|
624
623
|
export interface ImportWarning {
|
|
625
624
|
warningType: 'Existing Similar Memory' | 'Internal Error';
|
|
626
625
|
rowNumber?: number;
|
|
627
|
-
row: string;
|
|
628
626
|
text?: string;
|
|
629
627
|
similarTexts?: {
|
|
630
628
|
text: string;
|
|
@@ -633,12 +631,26 @@ export interface ImportWarning {
|
|
|
633
631
|
}
|
|
634
632
|
export interface ImportResponse {
|
|
635
633
|
importID: string;
|
|
636
|
-
status: 'Starting' | 'Running' | 'Stopped' | 'Completed' | 'Failed';
|
|
634
|
+
status: 'Pending' | 'Starting' | 'Running' | 'Stopped' | 'Completed' | 'Failed';
|
|
637
635
|
error?: string;
|
|
638
636
|
progress: number;
|
|
637
|
+
importType: 'CSV' | 'TXT';
|
|
638
|
+
importSize: number;
|
|
639
639
|
begin?: string;
|
|
640
640
|
end?: string;
|
|
641
641
|
eta?: number;
|
|
642
642
|
importedMemories?: number;
|
|
643
643
|
importWarnings?: ImportWarning[];
|
|
644
644
|
}
|
|
645
|
+
export interface Badge {
|
|
646
|
+
badgeID?: string;
|
|
647
|
+
date?: string;
|
|
648
|
+
name?: string;
|
|
649
|
+
description?: string;
|
|
650
|
+
imageURL?: string;
|
|
651
|
+
tags?: string[];
|
|
652
|
+
issuerName?: string;
|
|
653
|
+
issuerDescription?: string;
|
|
654
|
+
issuerEmail?: string;
|
|
655
|
+
issuerURL?: string;
|
|
656
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import memori from '../index';
|
|
2
|
+
|
|
3
|
+
const client = memori('https://backend-staging.memori.ai');
|
|
4
|
+
|
|
5
|
+
describe('backend/importexport api', () => {
|
|
6
|
+
it('works on importexport apis', async () => {
|
|
7
|
+
expect(
|
|
8
|
+
await client.backend.importExport.importStatus(
|
|
9
|
+
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
10
|
+
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
|
|
11
|
+
)
|
|
12
|
+
).not.toBeNull();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('works on importexport apis with shorthand version', async () => {
|
|
16
|
+
expect(
|
|
17
|
+
await client.backend.importStatus(
|
|
18
|
+
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
19
|
+
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
|
|
20
|
+
)
|
|
21
|
+
).not.toBeNull();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ResponseSpec,
|
|
3
|
+
ImportParams,
|
|
4
|
+
ImportResponse,
|
|
5
|
+
CsvSpecs,
|
|
6
|
+
} from '../types';
|
|
7
|
+
import { apiFetcher } from '../apiFetcher';
|
|
8
|
+
|
|
9
|
+
/************************
|
|
10
|
+
* *
|
|
11
|
+
* ImportExport *
|
|
12
|
+
* *
|
|
13
|
+
************************/
|
|
14
|
+
|
|
15
|
+
export default (apiUrl: string) => ({
|
|
16
|
+
/**
|
|
17
|
+
* Starts an Import process for memories from a CSV file.
|
|
18
|
+
* @param {string} authToken - The login token.
|
|
19
|
+
* @param {string} memoriID - The ID of the Memori object.
|
|
20
|
+
* @param {string[]} rows Rows of the CSV file.
|
|
21
|
+
* @param {ImportParams} params The specifications and content of the CSV file
|
|
22
|
+
*/
|
|
23
|
+
importCSV: async (
|
|
24
|
+
authToken: string,
|
|
25
|
+
memoriID: string,
|
|
26
|
+
rows: string[],
|
|
27
|
+
params: Omit<ImportParams, 'txtSpecs'>
|
|
28
|
+
) =>
|
|
29
|
+
apiFetcher(`/ImportExport/ImportCSV/${authToken}/${memoriID}`, {
|
|
30
|
+
apiUrl,
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: {
|
|
33
|
+
rows,
|
|
34
|
+
...params,
|
|
35
|
+
},
|
|
36
|
+
}) as Promise<
|
|
37
|
+
ResponseSpec & {
|
|
38
|
+
status: ImportResponse;
|
|
39
|
+
}
|
|
40
|
+
>,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Starts an Import process for memories from a TXT file.
|
|
44
|
+
* @param {string} authToken - The login token.
|
|
45
|
+
* @param {string} memoriID - The ID of the Memori object.
|
|
46
|
+
* @param {string[]} rows Rows of the TXT file.
|
|
47
|
+
* @param {ImportParams} params The specifications and content of the TXT file
|
|
48
|
+
*/
|
|
49
|
+
importTXT: async (
|
|
50
|
+
authToken: string,
|
|
51
|
+
memoriID: string,
|
|
52
|
+
rows: string[],
|
|
53
|
+
params: Omit<ImportParams, 'csvSpecs'>
|
|
54
|
+
) =>
|
|
55
|
+
apiFetcher(`/ImportExport/ImportTXT/${authToken}/${memoriID}`, {
|
|
56
|
+
apiUrl,
|
|
57
|
+
method: 'POST',
|
|
58
|
+
body: {
|
|
59
|
+
rows,
|
|
60
|
+
...params,
|
|
61
|
+
},
|
|
62
|
+
}) as Promise<
|
|
63
|
+
ResponseSpec & {
|
|
64
|
+
status: ImportResponse;
|
|
65
|
+
}
|
|
66
|
+
>,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets a list of Import processes started by the currently logged in User.
|
|
70
|
+
* @param {string} authToken - The login token.
|
|
71
|
+
*/
|
|
72
|
+
importProcesses: async (authToken: string) =>
|
|
73
|
+
apiFetcher(`/ImportExport/ImportProcesses/${authToken}`, {
|
|
74
|
+
apiUrl,
|
|
75
|
+
method: 'GET',
|
|
76
|
+
}) as Promise<
|
|
77
|
+
ResponseSpec & {
|
|
78
|
+
importProcesses: ImportResponse[];
|
|
79
|
+
}
|
|
80
|
+
>,
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Gets the status of an Import process.
|
|
84
|
+
* @param {string} authToken - The login token.
|
|
85
|
+
* @param {string} importID The import process ID
|
|
86
|
+
*/
|
|
87
|
+
importStatus: async (authToken: string, importID: string) =>
|
|
88
|
+
apiFetcher(`/ImportExport/ImportStatus/${authToken}/${importID}`, {
|
|
89
|
+
apiUrl,
|
|
90
|
+
method: 'GET',
|
|
91
|
+
}) as Promise<
|
|
92
|
+
ResponseSpec & {
|
|
93
|
+
status: ImportResponse;
|
|
94
|
+
}
|
|
95
|
+
>,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Interrupts an ongoing Import process.
|
|
99
|
+
* @param {string} authToken - The login token.
|
|
100
|
+
* @param {string} importID The import process ID
|
|
101
|
+
*/
|
|
102
|
+
stopImport: async (authToken: string, importID: string) =>
|
|
103
|
+
apiFetcher(`/ImportExport/StopImport/${authToken}/${importID}`, {
|
|
104
|
+
apiUrl,
|
|
105
|
+
method: 'POST',
|
|
106
|
+
}) as Promise<
|
|
107
|
+
ResponseSpec & {
|
|
108
|
+
status: ImportResponse;
|
|
109
|
+
}
|
|
110
|
+
>,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Exports contents of a Memori object to a CSV file.
|
|
114
|
+
* @param {string} authToken - The login token.
|
|
115
|
+
* @param {string} memoriID - The ID of the Memori object.
|
|
116
|
+
* @param {CsvSpecs} csvSpecs - The specifications of the CSV file
|
|
117
|
+
* @param {string=} password - Memori password, if its privacy model is set to Secret.
|
|
118
|
+
* @returns The CSV file content
|
|
119
|
+
*/
|
|
120
|
+
exportCSV: async (
|
|
121
|
+
authToken: string,
|
|
122
|
+
memoriID: string,
|
|
123
|
+
csvSpecs: CsvSpecs,
|
|
124
|
+
password?: string
|
|
125
|
+
) =>
|
|
126
|
+
apiFetcher(`/ImportExport/ExportCSV/${authToken}/${memoriID}`, {
|
|
127
|
+
apiUrl,
|
|
128
|
+
method: 'POST',
|
|
129
|
+
body: {
|
|
130
|
+
csvSpecs,
|
|
131
|
+
password,
|
|
132
|
+
},
|
|
133
|
+
text: true,
|
|
134
|
+
}) as Promise<string>,
|
|
135
|
+
});
|
package/src/backend.ts
CHANGED
|
@@ -5,6 +5,7 @@ import asset from './backend/asset';
|
|
|
5
5
|
import invitation from './backend/invitation';
|
|
6
6
|
import consumptionLogs from './backend/consumptionLogs';
|
|
7
7
|
import notifications from './backend/notifications';
|
|
8
|
+
import importExport from './backend/importExport';
|
|
8
9
|
|
|
9
10
|
const backendAPI = (apiUrl: string) => ({
|
|
10
11
|
asset: asset(apiUrl),
|
|
@@ -14,6 +15,7 @@ const backendAPI = (apiUrl: string) => ({
|
|
|
14
15
|
invitation: invitation(apiUrl),
|
|
15
16
|
consumptionLogs: consumptionLogs(apiUrl),
|
|
16
17
|
notifications: notifications(apiUrl),
|
|
18
|
+
importExport: importExport(apiUrl),
|
|
17
19
|
...asset(apiUrl),
|
|
18
20
|
...memori(apiUrl),
|
|
19
21
|
...user(apiUrl),
|
|
@@ -21,6 +23,7 @@ const backendAPI = (apiUrl: string) => ({
|
|
|
21
23
|
...invitation(apiUrl),
|
|
22
24
|
...consumptionLogs(apiUrl),
|
|
23
25
|
...notifications(apiUrl),
|
|
26
|
+
...importExport(apiUrl),
|
|
24
27
|
});
|
|
25
28
|
|
|
26
29
|
export default backendAPI;
|
package/src/engine.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import correlationPairs from './engine/correlationPairs';
|
|
2
2
|
import dialog from './engine/dialog';
|
|
3
|
-
import importExport from './engine/importExport';
|
|
4
3
|
import intents from './engine/intents';
|
|
5
4
|
import localizationKeys from './engine/localizationKeys';
|
|
6
5
|
import media from './engine/media';
|
|
@@ -21,8 +20,6 @@ export default (apiUrl: string) => ({
|
|
|
21
20
|
...correlationPairs(apiUrl),
|
|
22
21
|
dialog: dialog(apiUrl),
|
|
23
22
|
...dialog(apiUrl),
|
|
24
|
-
importExport: importExport(apiUrl),
|
|
25
|
-
...importExport(apiUrl),
|
|
26
23
|
intents: intents(apiUrl),
|
|
27
24
|
...intents(apiUrl),
|
|
28
25
|
localizationKeys: localizationKeys(apiUrl),
|
package/src/types.ts
CHANGED
|
@@ -280,6 +280,12 @@ export declare type OpenSession = {
|
|
|
280
280
|
initialQuestion?: string;
|
|
281
281
|
forceCloseSessions?: boolean;
|
|
282
282
|
birthDate?: string;
|
|
283
|
+
additionalInfo?: {
|
|
284
|
+
userID?: string;
|
|
285
|
+
email?: string;
|
|
286
|
+
language?: string;
|
|
287
|
+
referral?: string;
|
|
288
|
+
};
|
|
283
289
|
};
|
|
284
290
|
|
|
285
291
|
export declare type MemoriSession = {
|
|
@@ -862,7 +868,8 @@ export type CustomWord = {
|
|
|
862
868
|
lastChangeSessionID: string;
|
|
863
869
|
};
|
|
864
870
|
|
|
865
|
-
export interface
|
|
871
|
+
export interface CsvSpecs {
|
|
872
|
+
newLine: '\n' | '\r\n';
|
|
866
873
|
hasHeaders?: boolean;
|
|
867
874
|
headerNames?: string[];
|
|
868
875
|
questionColumnName: string;
|
|
@@ -873,36 +880,48 @@ export interface ImportCSVParams {
|
|
|
873
880
|
questionTitleVariantsSeparator?: string;
|
|
874
881
|
}
|
|
875
882
|
|
|
876
|
-
export interface
|
|
877
|
-
|
|
883
|
+
export interface TxtSpecs {
|
|
884
|
+
/**
|
|
885
|
+
* @type {string=}
|
|
886
|
+
* Proportion between the text size and the number of question-answers generated. If not specified it is assumed as MEDIUM.
|
|
887
|
+
* Must be one of:
|
|
888
|
+
* - LOW: generates ~10 questions every 10K characters
|
|
889
|
+
* - MEDIUM: generates ~20 questions every 10K characters
|
|
890
|
+
* - HIGH: generates ~30 questions every 10K characters
|
|
891
|
+
*/
|
|
892
|
+
granularity?: 'LOW' | 'MEDIUM' | 'HIGH';
|
|
893
|
+
/**
|
|
894
|
+
* @type {boolean=}
|
|
895
|
+
* If True, for every question-answer the excerpt of the original text from which they have been generated is included as an attachment.
|
|
896
|
+
* If not specified it is assumed as False.
|
|
897
|
+
*/
|
|
898
|
+
attachSource?: boolean;
|
|
899
|
+
/**
|
|
900
|
+
* @type {string=}
|
|
901
|
+
* Title of the source attachment, when enabled with AttachSource. If not specified it will have no title.
|
|
902
|
+
*/
|
|
903
|
+
sourceAttachmentTitle?: string;
|
|
904
|
+
/**
|
|
905
|
+
* @type {string=}
|
|
906
|
+
* If specified, these instructions are provided as part of the completion prompt to the generative AI when generating questions from the document.
|
|
907
|
+
*/
|
|
908
|
+
questionsGenerationInstructions?: string;
|
|
878
909
|
}
|
|
879
910
|
|
|
880
911
|
export interface ImportParams {
|
|
881
|
-
includedRows?: number[];
|
|
882
912
|
forceImport?: boolean;
|
|
883
|
-
csvSpecs?:
|
|
884
|
-
txtSpecs?:
|
|
913
|
+
csvSpecs?: CsvSpecs;
|
|
914
|
+
txtSpecs?: TxtSpecs;
|
|
885
915
|
conclusive?: boolean;
|
|
886
916
|
notPickable?: boolean;
|
|
887
917
|
contextVarsToSet?: {
|
|
888
918
|
[key: string]: string;
|
|
889
919
|
};
|
|
890
920
|
}
|
|
891
|
-
export interface ExportCSVParams {
|
|
892
|
-
newLine: '\n' | '\r\n';
|
|
893
|
-
hasHeaders?: boolean;
|
|
894
|
-
questionColumnName: string;
|
|
895
|
-
answerColumnName: string;
|
|
896
|
-
contextVarsToMatchColumnName?: string;
|
|
897
|
-
contextVarsToSetColumnName?: string;
|
|
898
|
-
csvSeparator?: string;
|
|
899
|
-
questionTitleVariantsSeparator?: string;
|
|
900
|
-
}
|
|
901
921
|
|
|
902
922
|
export interface ImportWarning {
|
|
903
923
|
warningType: 'Existing Similar Memory' | 'Internal Error';
|
|
904
924
|
rowNumber?: number;
|
|
905
|
-
row: string;
|
|
906
925
|
text?: string;
|
|
907
926
|
similarTexts?: {
|
|
908
927
|
text: string;
|
|
@@ -927,7 +946,13 @@ export interface ImportResponse {
|
|
|
927
946
|
* - Completed: the Import process finished successfully, all the Memory objects have been processed.
|
|
928
947
|
* - Failed: the Import process terminated due to an unexpected error, not all Memory objects may have been processed.
|
|
929
948
|
*/
|
|
930
|
-
status:
|
|
949
|
+
status:
|
|
950
|
+
| 'Pending'
|
|
951
|
+
| 'Starting'
|
|
952
|
+
| 'Running'
|
|
953
|
+
| 'Stopped'
|
|
954
|
+
| 'Completed'
|
|
955
|
+
| 'Failed';
|
|
931
956
|
/**
|
|
932
957
|
* @type {string=}
|
|
933
958
|
* If the Status is Failed, reports the error that caused the Import process to fail. Null otherwise.
|
|
@@ -938,6 +963,18 @@ export interface ImportResponse {
|
|
|
938
963
|
* Progress of the Import process as a fraction of 1.
|
|
939
964
|
*/
|
|
940
965
|
progress: number;
|
|
966
|
+
/**
|
|
967
|
+
* @type {string}
|
|
968
|
+
* Import type. Can be one of the following:
|
|
969
|
+
* - CSV: for tabular documents
|
|
970
|
+
* - TXT: for text documents
|
|
971
|
+
*/
|
|
972
|
+
importType: 'CSV' | 'TXT';
|
|
973
|
+
/**
|
|
974
|
+
* @type {number}
|
|
975
|
+
* Size of the imported document in characters.
|
|
976
|
+
*/
|
|
977
|
+
importSize: number;
|
|
941
978
|
/**
|
|
942
979
|
* @type {string=}
|
|
943
980
|
* Timestamp of start of the Import process. Null until the Import process is in Starting status.
|
|
@@ -964,3 +1001,16 @@ export interface ImportResponse {
|
|
|
964
1001
|
*/
|
|
965
1002
|
importWarnings?: ImportWarning[];
|
|
966
1003
|
}
|
|
1004
|
+
|
|
1005
|
+
export interface Badge {
|
|
1006
|
+
badgeID?: string;
|
|
1007
|
+
date?: string;
|
|
1008
|
+
name?: string;
|
|
1009
|
+
description?: string;
|
|
1010
|
+
imageURL?: string;
|
|
1011
|
+
tags?: string[];
|
|
1012
|
+
issuerName?: string;
|
|
1013
|
+
issuerDescription?: string;
|
|
1014
|
+
issuerEmail?: string;
|
|
1015
|
+
issuerURL?: string;
|
|
1016
|
+
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ImportParams } from '../../src/types';
|
|
2
|
-
import memori from '../index';
|
|
3
|
-
|
|
4
|
-
const client = memori('https://backend.memori.ai');
|
|
5
|
-
|
|
6
|
-
describe('engine/importExport api', () => {
|
|
7
|
-
const importCsvParams: ImportParams = {
|
|
8
|
-
includedRows: [0, 1],
|
|
9
|
-
forceImport: false,
|
|
10
|
-
csvSpecs: {
|
|
11
|
-
hasHeaders: false,
|
|
12
|
-
questionColumnName: 'Title',
|
|
13
|
-
answerColumnName: 'Answers',
|
|
14
|
-
csvSeparator: ',',
|
|
15
|
-
questionTitleVariantsSeparator: '|',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('works on import apis', async () => {
|
|
20
|
-
expect(
|
|
21
|
-
await client.importExport.importCSV(
|
|
22
|
-
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
23
|
-
['Title,Answers', 'Chi sei?,Sono un Memori'],
|
|
24
|
-
importCsvParams
|
|
25
|
-
)
|
|
26
|
-
).not.toBeNull();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('works on import apis with shorthand version', async () => {
|
|
30
|
-
expect(
|
|
31
|
-
await client.importCSV(
|
|
32
|
-
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
33
|
-
['Title,Answers', 'Chi sei?,Sono un Memori'],
|
|
34
|
-
importCsvParams
|
|
35
|
-
)
|
|
36
|
-
).not.toBeNull();
|
|
37
|
-
});
|
|
38
|
-
});
|