@memori.ai/memori-api-client 1.0.0 → 1.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/dist/types.d.ts CHANGED
@@ -123,25 +123,29 @@ export declare type User = {
123
123
  admin?: boolean;
124
124
  superAdmin?: boolean;
125
125
  verificationCode?: string;
126
+ dontSendInvitationEmail?: boolean;
126
127
  flowID?: string;
127
128
  newsletterSubscribed?: boolean;
128
129
  maxMemori?: number;
129
- maxCompletions?: number;
130
+ numMemori?: number;
130
131
  canCreateMemori?: boolean;
131
132
  canAccessAPI?: boolean;
132
133
  canRunSnippets?: boolean;
133
134
  canEditIntegrations?: boolean;
134
135
  canEditDynamicIntents?: boolean;
135
136
  canEditMemoriChaining?: boolean;
137
+ monthSessions?: number;
138
+ monthValidSessions?: number;
136
139
  maxFreeSessions?: number;
137
140
  nonFreeSessionCost?: number;
141
+ monthCompletions?: number;
142
+ maxCompletions?: number;
138
143
  creationTimestamp?: string;
139
144
  lastChangeTimestamp?: string;
140
145
  referral?: string;
141
146
  couponCode?: string;
142
147
  paying?: boolean;
143
148
  notificationPrefs?: NotificationPrefs[];
144
- dontSendInvitationEmail?: boolean;
145
149
  };
146
150
  export declare type IntegrationResource = {
147
151
  name: string;
@@ -801,34 +805,26 @@ export declare type CustomWord = {
801
805
  lastChangeTimestamp: string;
802
806
  lastChangeSessionID: string;
803
807
  };
804
- export declare type ImportWarning = {
805
- warningType: 'Existing Similar Memory' | 'Internal Error';
806
- rowNumber?: number;
807
- csvRow: string;
808
- text?: string;
809
- similarTexts?: {
810
- text: string;
811
- similarityLevel: 'HIGH' | 'MEDIUM' | 'LOW';
812
- }[];
813
- };
814
- export declare type ImportReponse = {
815
- importID: string;
816
- importedMemories?: number;
817
- importWarnings?: ImportWarning[];
818
- };
819
- export declare type ImportCSVParams = {
820
- includedRows?: number[];
808
+ export interface ImportCSVParams {
821
809
  hasHeaders?: boolean;
822
810
  headerNames?: string[];
823
- forceImport?: boolean;
824
811
  questionColumnName: string;
825
812
  answerColumnName: string;
826
813
  contextVarsToMatchColumnName?: string;
827
814
  contextVarsToSetColumnName?: string;
828
815
  csvSeparator?: string;
829
816
  questionTitleVariantsSeparator?: string;
830
- };
831
- export declare type ExportCSVParams = {
817
+ }
818
+ export interface ImportTxtParams {
819
+ newLinesPerParagraphs?: number;
820
+ }
821
+ export interface ImportParams {
822
+ includedRows?: number[];
823
+ forceImport?: boolean;
824
+ csvSpecs?: ImportCSVParams;
825
+ txtSpecs?: ImportTxtParams;
826
+ }
827
+ export interface ExportCSVParams {
832
828
  newLine: '\n' | '\r\n';
833
829
  hasHeaders?: boolean;
834
830
  questionColumnName: string;
@@ -837,4 +833,65 @@ export declare type ExportCSVParams = {
837
833
  contextVarsToSetColumnName?: string;
838
834
  csvSeparator?: string;
839
835
  questionTitleVariantsSeparator?: string;
840
- };
836
+ }
837
+ export interface ImportWarning {
838
+ warningType: 'Existing Similar Memory' | 'Internal Error';
839
+ rowNumber?: number;
840
+ row: string;
841
+ text?: string;
842
+ similarTexts?: {
843
+ text: string;
844
+ similarityLevel: 'HIGH' | 'MEDIUM' | 'LOW';
845
+ }[];
846
+ }
847
+ export interface ImportReponse {
848
+ importID: string;
849
+ status: {
850
+ /**
851
+ * @type {string}
852
+ * minLength: 1
853
+ * Current status of the Import process (starting, running etc.).
854
+ * May be one of the following:
855
+ * - Starting: the Import process is preparing to start, but has not started yet. Will advance to Running automatically.
856
+ * - Running: the Import process has been started and is actively processing Memory objects.
857
+ * - Stopped: the Import process has been stopped manually, not all Memory objects may have been processed.
858
+ * - Completed: the Import process finished successfully, all the Memory objects have been processed.
859
+ * - Failed: the Import process terminated due to an unexpected error, not all Memory objects may have been processed.
860
+ */
861
+ status: 'Starting' | 'Running' | 'Stopped' | 'Completed' | 'Failed';
862
+ /**
863
+ * @type {string=}
864
+ * If the Status is Failed, reports the error that caused the Import process to fail. Null otherwise.
865
+ */
866
+ error?: string;
867
+ /**
868
+ * @type {number}
869
+ * Progress of the Import process as a fraction of 1.
870
+ */
871
+ progress: number;
872
+ /**
873
+ * @type {string=}
874
+ * Timestamp of start of the Import process. Null until the Import process is in Starting status.
875
+ */
876
+ begin?: string;
877
+ /**
878
+ * @type {string=}
879
+ * Timestamp of end of the Import process. Null until the Import process is in Starting or Running status.
880
+ */
881
+ end?: string;
882
+ /**
883
+ * @type {number=}
884
+ * Estimated time required to complete the Import process, in seconds.
885
+ */
886
+ eta?: number;
887
+ /**
888
+ * @type {number=}
889
+ * Number of Imported Memory objects so far.
890
+ */
891
+ importedMemories?: number;
892
+ /**
893
+ * List of Import Warning objects. May be empty.
894
+ */
895
+ importWarnings?: ImportWarning[];
896
+ };
897
+ }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.2.0",
3
3
  "name": "@memori.ai/memori-api-client",
4
4
  "description": "React library to integrate a Memori in your app or website",
5
5
  "license": "Apache-2.0",
@@ -58,12 +58,62 @@ export default (apiUrl: string) => ({
58
58
  }
59
59
  >,
60
60
 
61
+ /**
62
+ * Gets a list of Memori objects owned by the specified user.
63
+ * @param {string} tenantName - The name of the tenant
64
+ * @param {string} userID - The user name
65
+ * @param {string=} authToken - The login token
66
+ * @returns A list of Memori objects
67
+ */
68
+ getUserByIDMemoriList: (
69
+ tenantName: string,
70
+ userID: string,
71
+ authToken?: string
72
+ ) =>
73
+ apiFetcher(
74
+ `/UserMemoriByID/${tenantName}/${userID}${
75
+ authToken ? `/${authToken}` : ''
76
+ }`,
77
+ {
78
+ apiUrl,
79
+ }
80
+ ) as Promise<
81
+ ResponseSpec & {
82
+ memori: Memori[];
83
+ }
84
+ >,
85
+
86
+ /**
87
+ * Gets a list of Memori objects owned by the specified user.
88
+ * @param {string} tenantName - The name of the tenant
89
+ * @param {string} userName - The user name
90
+ * @param {string=} authToken - The login token
91
+ * @returns A list of Memori objects
92
+ */
93
+ getUserMemoriList: (
94
+ tenantName: string,
95
+ userName: string,
96
+ authToken?: string
97
+ ) =>
98
+ apiFetcher(
99
+ `/UserMemori/${tenantName}/${userName}${
100
+ authToken ? `/${authToken}` : ''
101
+ }`,
102
+ {
103
+ apiUrl,
104
+ }
105
+ ) as Promise<
106
+ ResponseSpec & {
107
+ memori: Memori[];
108
+ }
109
+ >,
110
+
61
111
  /**
62
112
  * Gets a list of Memori objects for the currently logged in User.
63
113
  * @param authToken - The login token
64
114
  * @returns A list of Memori objects
65
115
  */
66
- getUserMemoriList: (authToken: string) =>
116
+ getMemoriList: (authToken: string) =>
67
117
  apiFetcher(`/Memori/${authToken}`, {
68
118
  apiUrl,
69
119
  }) as Promise<
@@ -7,7 +7,7 @@ export default (apiUrl: string) => ({
7
7
  * @param user - The user object
8
8
  * @returns The created user object
9
9
  */
10
- userSignIn: (user: User) =>
10
+ userSignUp: (user: User) =>
11
11
  apiFetcher('/User', {
12
12
  apiUrl,
13
13
  body: user,
@@ -19,7 +19,7 @@ export default (apiUrl: string) => ({
19
19
  * @param user - The user object
20
20
  * @returns The created user object
21
21
  */
22
- userConfirmSignIn: (user: User) =>
22
+ userConfirmSignUp: (user: User) =>
23
23
  apiFetcher('/UserConfirm', {
24
24
  apiUrl,
25
25
  body: user,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  ResponseSpec,
3
3
  ImportReponse,
4
- ImportCSVParams,
5
4
  ExportCSVParams,
5
+ ImportParams,
6
6
  } from '../types';
7
7
  import { apiFetcher } from '../apiFetcher';
8
8
 
@@ -16,19 +16,55 @@ export default (apiUrl: string) => ({
16
16
  /**
17
17
  * Imports memories from a CSV file.
18
18
  * @param {string} sessionId The session ID
19
- * @param {string[]} csvRows Rows of the CSV file.
20
- * @param {ImportCSVParams} params The specifications and content of the CSV file
19
+ * @param {string[]} rows Rows of the CSV file.
20
+ * @param {ImportParams} params The specifications and content of the CSV file
21
21
  */
22
- importCSV: async (
22
+ importCSV: async (sessionId: string, rows: string[], params: ImportParams) =>
23
+ apiFetcher(`/ImportExport/ImportCSV/${sessionId}`, {
24
+ method: 'POST',
25
+ apiUrl,
26
+ body: {
27
+ rows,
28
+ ...params,
29
+ },
30
+ }) as Promise<ResponseSpec & ImportReponse>,
31
+
32
+ /**
33
+ * Gets the status of an ongoing Import process.
34
+ * @param {string} importID The import process ID
35
+ */
36
+ importStatus: async (importID: string) =>
37
+ apiFetcher(`/ImportExport/ImportStatus/${importID}`, {
38
+ method: 'GET',
39
+ apiUrl,
40
+ }) as Promise<ResponseSpec & ImportReponse>,
41
+
42
+ /**
43
+ * Interrupts an ongoing Import process.
44
+ * @param {string} importID The import process ID
45
+ */
46
+ stopImport: async (importID: string) =>
47
+ apiFetcher(`/ImportExport/StopImport/${importID}`, {
48
+ method: 'POST',
49
+ apiUrl,
50
+ }) as Promise<ResponseSpec & ImportReponse>,
51
+
52
+ /**
53
+ * Imports memories from a TXT file.
54
+ * @param {string} sessionId The session ID
55
+ * @param {string[]} rows Rows of the TXT file.
56
+ * @param {ImportCSVParams} params The specifications and content of the TXT file
57
+ */
58
+ importTXT: async (
23
59
  sessionId: string,
24
- csvRows: string[],
25
- params: ImportCSVParams
60
+ rows: string[],
61
+ params: Omit<ImportParams, 'csvSpecs'>
26
62
  ) =>
27
- apiFetcher(`/ImportExport/ImportCSV/${sessionId}`, {
63
+ apiFetcher(`/ImportExport/ImportTXT/${sessionId}`, {
28
64
  method: 'POST',
29
65
  apiUrl,
30
66
  body: {
31
- csvRows,
67
+ rows,
32
68
  ...params,
33
69
  },
34
70
  }) as Promise<ResponseSpec & ImportReponse>,
@@ -1,6 +1,5 @@
1
1
  export const getApiUrl = (hostname?: string) =>
2
2
  hostname
3
- ? new URL(
4
- hostname.startsWith('http') ? hostname : `https://${hostname}`
5
- ).origin.replace('http://', 'https://')
3
+ ? new URL(hostname.startsWith('http') ? hostname : `https://${hostname}`)
4
+ .origin
6
5
  : 'https://backend.memori.ai';
package/src/types.ts CHANGED
@@ -125,25 +125,29 @@ export declare type User = {
125
125
  admin?: boolean;
126
126
  superAdmin?: boolean;
127
127
  verificationCode?: string;
128
+ dontSendInvitationEmail?: boolean;
128
129
  flowID?: string;
129
130
  newsletterSubscribed?: boolean;
130
131
  maxMemori?: number;
131
- maxCompletions?: number;
132
+ numMemori?: number;
132
133
  canCreateMemori?: boolean;
133
134
  canAccessAPI?: boolean;
134
135
  canRunSnippets?: boolean;
135
136
  canEditIntegrations?: boolean;
136
137
  canEditDynamicIntents?: boolean;
137
138
  canEditMemoriChaining?: boolean;
139
+ monthSessions?: number;
140
+ monthValidSessions?: number;
138
141
  maxFreeSessions?: number;
139
142
  nonFreeSessionCost?: number;
143
+ monthCompletions?: number;
144
+ maxCompletions?: number;
140
145
  creationTimestamp?: string;
141
146
  lastChangeTimestamp?: string;
142
147
  referral?: string;
143
148
  couponCode?: string;
144
149
  paying?: boolean;
145
150
  notificationPrefs?: NotificationPrefs[];
146
- dontSendInvitationEmail?: boolean;
147
151
  };
148
152
 
149
153
  export declare type IntegrationResource = {
@@ -840,37 +844,28 @@ export type CustomWord = {
840
844
  lastChangeSessionID: string;
841
845
  };
842
846
 
843
- export type ImportWarning = {
844
- warningType: 'Existing Similar Memory' | 'Internal Error';
845
- rowNumber?: number;
846
- csvRow: string;
847
- text?: string;
848
- similarTexts?: {
849
- text: string;
850
- similarityLevel: 'HIGH' | 'MEDIUM' | 'LOW';
851
- }[];
852
- };
853
-
854
- export type ImportReponse = {
855
- importID: string;
856
- importedMemories?: number;
857
- importWarnings?: ImportWarning[];
858
- };
859
-
860
- export type ImportCSVParams = {
861
- includedRows?: number[];
847
+ export interface ImportCSVParams {
862
848
  hasHeaders?: boolean;
863
849
  headerNames?: string[];
864
- forceImport?: boolean;
865
850
  questionColumnName: string;
866
851
  answerColumnName: string;
867
852
  contextVarsToMatchColumnName?: string;
868
853
  contextVarsToSetColumnName?: string;
869
854
  csvSeparator?: string;
870
855
  questionTitleVariantsSeparator?: string;
871
- };
856
+ }
872
857
 
873
- export type ExportCSVParams = {
858
+ export interface ImportTxtParams {
859
+ newLinesPerParagraphs?: number;
860
+ }
861
+
862
+ export interface ImportParams {
863
+ includedRows?: number[];
864
+ forceImport?: boolean;
865
+ csvSpecs?: ImportCSVParams;
866
+ txtSpecs?: ImportTxtParams;
867
+ }
868
+ export interface ExportCSVParams {
874
869
  newLine: '\n' | '\r\n';
875
870
  hasHeaders?: boolean;
876
871
  questionColumnName: string;
@@ -879,4 +874,68 @@ export type ExportCSVParams = {
879
874
  contextVarsToSetColumnName?: string;
880
875
  csvSeparator?: string;
881
876
  questionTitleVariantsSeparator?: string;
882
- };
877
+ }
878
+
879
+ export interface ImportWarning {
880
+ warningType: 'Existing Similar Memory' | 'Internal Error';
881
+ rowNumber?: number;
882
+ row: string;
883
+ text?: string;
884
+ similarTexts?: {
885
+ text: string;
886
+ similarityLevel: 'HIGH' | 'MEDIUM' | 'LOW';
887
+ }[];
888
+ }
889
+
890
+ export interface ImportReponse {
891
+ importID: string;
892
+ status: {
893
+ /**
894
+ * @type {string}
895
+ * minLength: 1
896
+ * Current status of the Import process (starting, running etc.).
897
+ * May be one of the following:
898
+ * - Starting: the Import process is preparing to start, but has not started yet. Will advance to Running automatically.
899
+ * - Running: the Import process has been started and is actively processing Memory objects.
900
+ * - Stopped: the Import process has been stopped manually, not all Memory objects may have been processed.
901
+ * - Completed: the Import process finished successfully, all the Memory objects have been processed.
902
+ * - Failed: the Import process terminated due to an unexpected error, not all Memory objects may have been processed.
903
+ */
904
+ status: 'Starting' | 'Running' | 'Stopped' | 'Completed' | 'Failed';
905
+ /**
906
+ * @type {string=}
907
+ * If the Status is Failed, reports the error that caused the Import process to fail. Null otherwise.
908
+ */
909
+ error?: string;
910
+ /**
911
+ * @type {number}
912
+ * Progress of the Import process as a fraction of 1.
913
+ */
914
+ progress: number;
915
+ /**
916
+ * @type {string=}
917
+ * Timestamp of start of the Import process. Null until the Import process is in Starting status.
918
+ */
919
+ begin?: string;
920
+ /**
921
+ * @type {string=}
922
+ * Timestamp of end of the Import process. Null until the Import process is in Starting or Running status.
923
+ */
924
+ end?: string;
925
+ /**
926
+ * @type {number=}
927
+ * Estimated time required to complete the Import process, in seconds.
928
+ */
929
+ eta?: number;
930
+
931
+ /**
932
+ * @type {number=}
933
+ * Number of Imported Memory objects so far.
934
+ */
935
+ importedMemories?: number;
936
+ /**
937
+ * List of Import Warning objects. May be empty.
938
+ */
939
+ importWarnings?: ImportWarning[];
940
+ };
941
+ }