@memori.ai/memori-api-client 3.0.0 → 4.0.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/backend/analysis.d.ts +11 -0
  3. package/dist/backend/analysis.js +17 -0
  4. package/dist/backend/analysis.js.map +1 -0
  5. package/dist/backend/analysis.test.d.ts +1 -0
  6. package/dist/backend/analysis.test.js +14 -0
  7. package/dist/backend/analysis.test.js.map +1 -0
  8. package/dist/backend/importExport.d.ts +3 -12
  9. package/dist/backend/importExport.js +0 -12
  10. package/dist/backend/importExport.js.map +1 -1
  11. package/dist/backend/importExport.test.js +10 -2
  12. package/dist/backend/importExport.test.js.map +1 -1
  13. package/dist/backend/process.d.ts +16 -0
  14. package/dist/backend/process.js +22 -0
  15. package/dist/backend/process.js.map +1 -0
  16. package/dist/backend/process.test.d.ts +1 -0
  17. package/dist/backend/process.test.js +14 -0
  18. package/dist/backend/process.test.js.map +1 -0
  19. package/dist/backend.d.ts +44 -20
  20. package/dist/backend.js +6 -0
  21. package/dist/backend.js.map +1 -1
  22. package/dist/index.d.ts +44 -20
  23. package/dist/types.d.ts +46 -12
  24. package/esm/backend/analysis.d.ts +11 -0
  25. package/esm/backend/analysis.js +15 -0
  26. package/esm/backend/analysis.js.map +1 -0
  27. package/esm/backend/analysis.test.d.ts +1 -0
  28. package/esm/backend/analysis.test.js +11 -0
  29. package/esm/backend/analysis.test.js.map +1 -0
  30. package/esm/backend/importExport.d.ts +3 -12
  31. package/esm/backend/importExport.js +0 -12
  32. package/esm/backend/importExport.js.map +1 -1
  33. package/esm/backend/importExport.test.js +10 -2
  34. package/esm/backend/importExport.test.js.map +1 -1
  35. package/esm/backend/process.d.ts +16 -0
  36. package/esm/backend/process.js +20 -0
  37. package/esm/backend/process.js.map +1 -0
  38. package/esm/backend/process.test.d.ts +1 -0
  39. package/esm/backend/process.test.js +11 -0
  40. package/esm/backend/process.test.js.map +1 -0
  41. package/esm/backend.d.ts +44 -20
  42. package/esm/backend.js +6 -0
  43. package/esm/backend.js.map +1 -1
  44. package/esm/index.d.ts +44 -20
  45. package/esm/types.d.ts +46 -12
  46. package/package.json +1 -1
  47. package/src/backend/analysis.test.ts +25 -0
  48. package/src/backend/analysis.ts +64 -0
  49. package/src/backend/importExport.test.ts +14 -4
  50. package/src/backend/importExport.ts +3 -47
  51. package/src/backend/process.test.ts +23 -0
  52. package/src/backend/process.ts +86 -0
  53. package/src/backend.ts +6 -0
  54. package/src/types.ts +150 -27
@@ -0,0 +1,23 @@
1
+ import memori from '../index';
2
+
3
+ const client = memori('https://backend-staging.memori.ai');
4
+
5
+ describe('backend/process api', () => {
6
+ it('works on process apis', async () => {
7
+ expect(
8
+ await client.backend.process.getProcessStatus(
9
+ '768b9654-e781-4c3c-81fa-ae1529d1bfbe',
10
+ 'be2e4a44-890b-483b-a26a-f6e122f36e2b'
11
+ )
12
+ ).not.toBeNull();
13
+ });
14
+
15
+ it('works on process apis with shorthand version', async () => {
16
+ expect(
17
+ await client.backend.getProcessStatus(
18
+ '768b9654-e781-4c3c-81fa-ae1529d1bfbe',
19
+ 'be2e4a44-890b-483b-a26a-f6e122f36e2b'
20
+ )
21
+ ).not.toBeNull();
22
+ });
23
+ });
@@ -0,0 +1,86 @@
1
+ import { ResponseSpec, ProcessStatus } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ export default (apiUrl: string) => ({
5
+ /**
6
+ * Gets a list of processes started by the currently logged in User.
7
+ * @param {string} authToken - The login token.
8
+ * @param {string=} processType - Optional filter for Process type
9
+ */
10
+ getProcesses: async <T = ProcessStatus>(
11
+ authToken: string,
12
+ processType?: ProcessStatus['processType']
13
+ ) =>
14
+ apiFetcher(
15
+ `/Processes/${authToken}${processType ? `/${processType}` : ''}`,
16
+ {
17
+ apiUrl,
18
+ method: 'GET',
19
+ }
20
+ ) as Promise<
21
+ ResponseSpec & {
22
+ processes: T[];
23
+ }
24
+ >,
25
+
26
+ /**
27
+ * Gets a list of processes for the specified Memori.
28
+ * @param {string} authToken - The login token.
29
+ * @param {string} memoriID - The Memori ID
30
+ * @param {string=} processType - Optional filter for Process type
31
+ */
32
+ getMemoriProcesses: async <T = ProcessStatus>(
33
+ authToken: string,
34
+ memoriID: string,
35
+ processType?: ProcessStatus['processType']
36
+ ) =>
37
+ apiFetcher(
38
+ `/MemoriProcesses/${authToken}/${memoriID}${
39
+ processType ? `/${processType}` : ''
40
+ }`,
41
+ {
42
+ apiUrl,
43
+ method: 'GET',
44
+ }
45
+ ) as Promise<
46
+ ResponseSpec & {
47
+ processes: T[];
48
+ }
49
+ >,
50
+
51
+ /**
52
+ * Gets the status of an process.
53
+ * @param {string} authToken - The login token.
54
+ * @param {string} processID The process ID
55
+ */
56
+ getProcessStatus: async <T = ProcessStatus>(
57
+ authToken: string,
58
+ processID: string
59
+ ) =>
60
+ apiFetcher(`/ProcessStatus/${authToken}/${processID}`, {
61
+ apiUrl,
62
+ method: 'GET',
63
+ }) as Promise<
64
+ ResponseSpec & {
65
+ status: T;
66
+ }
67
+ >,
68
+
69
+ /**
70
+ * Interrupts an ongoing process.
71
+ * @param {string} authToken - The login token.
72
+ * @param {string} processID The process ID
73
+ */
74
+ stopProcess: async <T = ProcessStatus>(
75
+ authToken: string,
76
+ processID: string
77
+ ) =>
78
+ apiFetcher(`/StopProcess/${authToken}/${processID}`, {
79
+ apiUrl,
80
+ method: 'POST',
81
+ }) as Promise<
82
+ ResponseSpec & {
83
+ status: T;
84
+ }
85
+ >,
86
+ });
package/src/backend.ts CHANGED
@@ -6,6 +6,8 @@ import invitation from './backend/invitation';
6
6
  import consumptionLogs from './backend/consumptionLogs';
7
7
  import notifications from './backend/notifications';
8
8
  import importExport from './backend/importExport';
9
+ import process from './backend/process';
10
+ import analysis from './backend/analysis';
9
11
 
10
12
  const backendAPI = (apiUrl: string) => ({
11
13
  asset: asset(apiUrl),
@@ -16,6 +18,8 @@ const backendAPI = (apiUrl: string) => ({
16
18
  consumptionLogs: consumptionLogs(apiUrl),
17
19
  notifications: notifications(apiUrl),
18
20
  importExport: importExport(apiUrl),
21
+ process: process(apiUrl),
22
+ analysis: analysis(apiUrl),
19
23
  ...asset(apiUrl),
20
24
  ...memori(apiUrl),
21
25
  ...user(apiUrl),
@@ -24,6 +28,8 @@ const backendAPI = (apiUrl: string) => ({
24
28
  ...consumptionLogs(apiUrl),
25
29
  ...notifications(apiUrl),
26
30
  ...importExport(apiUrl),
31
+ ...process(apiUrl),
32
+ ...analysis(apiUrl),
27
33
  });
28
34
 
29
35
  export default backendAPI;
package/src/types.ts CHANGED
@@ -165,13 +165,12 @@ export declare type User = {
165
165
  newsletterSubscribed?: boolean;
166
166
  maxMemori?: number;
167
167
  numMemori?: number;
168
- canCreateMemori?: boolean;
169
- canAccessAPI?: boolean;
170
- canRunSnippets?: boolean;
171
- canEditIntegrations?: boolean;
172
- canEditDynamicIntents?: boolean;
173
- canEditMemoriChaining?: boolean;
168
+ enableMemoriCreation?: boolean;
169
+ enableBoardOfExperts?: boolean;
170
+ enableDCMIntegration?: boolean;
174
171
  enableBadges?: boolean;
172
+ enableVirtualSpaces?: boolean;
173
+ enableDeepThought?: boolean;
175
174
  monthSessions?: number;
176
175
  monthValidSessions?: number;
177
176
  maxFreeSessions?: number;
@@ -290,6 +289,7 @@ export type TenantBase = {
290
289
  name?: string;
291
290
  description?: string;
292
291
  logoURL?: string;
292
+ adminEmail?: string;
293
293
  /**
294
294
  * Additional Tenant names.
295
295
  * Usually host names, e.g. app.memorytwin.com.
@@ -1033,12 +1033,65 @@ export interface ImportWarning {
1033
1033
  }[];
1034
1034
  }
1035
1035
 
1036
- export interface ImportResponse {
1036
+ export interface AnalysisParams {
1037
+ query: string;
1038
+ }
1039
+
1040
+ export interface AnalysisWarning {
1037
1041
  /**
1038
1042
  * @type {string}
1039
- * Import process ID.
1043
+ * Type of warning.
1044
+ * Currently supported types are:
1045
+ * - Error: an error occurred while performing analysis
1040
1046
  */
1041
- importID: string;
1047
+ warningType: 'Error' | string;
1048
+ /**
1049
+ * @type {string=}
1050
+ * When WarningType is Error reports the text of the error.
1051
+ */
1052
+ text?: string;
1053
+ }
1054
+
1055
+ export interface AnalysisWarning {
1056
+ /**
1057
+ * @type {string}
1058
+ * Type of warning.
1059
+ * Currently supported types are:
1060
+ * - Error: an error occurred while performing analysis
1061
+ */
1062
+ warningType: 'Error' | string;
1063
+ /**
1064
+ * @type {string=}
1065
+ * When WarningType is Error reports the text of the error.
1066
+ */
1067
+ text?: string;
1068
+ }
1069
+
1070
+ export interface ProcessStatus {
1071
+ /**
1072
+ * @type {string}
1073
+ * Process ID.
1074
+ */
1075
+ processID: string;
1076
+ /**
1077
+ * @type {string}
1078
+ * ID of the Memori object this process refers to.
1079
+ */
1080
+ memoriID: string;
1081
+ /**
1082
+ * @type {string}
1083
+ * Name of the user that started the process.
1084
+ */
1085
+ processUserName: string;
1086
+ /**
1087
+ * @type {string}
1088
+ * Process type.
1089
+ * Can be one of the following:
1090
+ *
1091
+ * - Import: for file import processes
1092
+ * - Analysis: for Deep Thought user/query analysis processes
1093
+ */
1094
+ processType: 'Import' | 'Analysis';
1042
1095
  /**
1043
1096
  * @type {string}
1044
1097
  * minLength: 1
@@ -1067,28 +1120,11 @@ export interface ImportResponse {
1067
1120
  * Progress of the Import process as a fraction of 1.
1068
1121
  */
1069
1122
  progress: number;
1070
- /**
1071
- * @type {string}
1072
- * Import type. Can be one of the following:
1073
- * - CSV: for tabular documents
1074
- * - TXT: for text documents
1075
- */
1076
- importType: 'CSV' | 'TXT';
1077
- /**
1078
- * @type {number}
1079
- * Size of the imported document in characters.
1080
- */
1081
- importSize: number;
1082
- /**
1083
- * @type {string?}
1084
- * Name of this import, if set when the Import process was requested.
1085
- */
1086
- importName?: string;
1087
1123
  /**
1088
1124
  * @type {string?}
1089
1125
  * Original parameters of the Import process request, as a JSON structure, excluding the document rows.
1090
1126
  */
1091
- importSpecsJSON?: string;
1127
+ processSpecsJSON?: string;
1092
1128
  /**
1093
1129
  * @type {string=}
1094
1130
  * Timestamp of start of the Import process. Null until the Import process is in Starting status.
@@ -1104,7 +1140,28 @@ export interface ImportResponse {
1104
1140
  * Estimated time required to complete the Import process, in seconds.
1105
1141
  */
1106
1142
  eta?: number;
1143
+ creationTimestamp?: string;
1144
+ lastChangeTimestamp?: string;
1145
+ }
1107
1146
 
1147
+ export interface ImportStatus extends ProcessStatus {
1148
+ /**
1149
+ * @type {string}
1150
+ * Import type. Can be one of the following:
1151
+ * - CSV: for tabular documents
1152
+ * - TXT: for text documents
1153
+ */
1154
+ importType: 'CSV' | 'TXT';
1155
+ /**
1156
+ * @type {number}
1157
+ * Size of the imported document in characters.
1158
+ */
1159
+ importSize: number;
1160
+ /**
1161
+ * @type {string?}
1162
+ * Name of this import, if set when the Import process was requested.
1163
+ */
1164
+ importName?: string;
1108
1165
  /**
1109
1166
  * @type {number=}
1110
1167
  * Number of Imported Memory objects so far.
@@ -1120,6 +1177,72 @@ export interface ImportResponse {
1120
1177
  importWarnings?: ImportWarning[];
1121
1178
  }
1122
1179
 
1180
+ export interface AnalysisStatus extends ProcessStatus {
1181
+ /**
1182
+ * @type {string}
1183
+ * Analysis type. Can be one of the following:
1184
+ * - UserQuery: for Deep Thought User/query Match analysis
1185
+ */
1186
+ analysisType: 'UserQuery';
1187
+ /**
1188
+ * @type {string}
1189
+ * Query to be used in the analysis. Used when AnalysisType is UserQuery.
1190
+ */
1191
+ query?: string;
1192
+ /**
1193
+ * @type {number=}
1194
+ * Number of Import Warning objects
1195
+ */
1196
+ analysisWarningsCount?: number;
1197
+ /**
1198
+ * @type {AnalysisWarning[]=}
1199
+ * List of Import Warning objects. May be empty.
1200
+ */
1201
+ analysisWarnings?: AnalysisWarning[];
1202
+ }
1203
+
1204
+ export interface UserQueryMatch {
1205
+ /**
1206
+ * @type {string}
1207
+ * Match ID. Unique and assigned by the system.
1208
+ */
1209
+ userQueryMatchID: string;
1210
+ /**
1211
+ * @type {string}
1212
+ * ID of the Analysis object this match refers to.
1213
+ */
1214
+ analysisID: string;
1215
+ /**
1216
+ * @type {string}
1217
+ * ID of the Memori object this match refers to.
1218
+ */
1219
+ memoriID: string;
1220
+ /**
1221
+ * @type {string}
1222
+ * ID of the corresponding User object on the Engine.
1223
+ */
1224
+ engineUserID: string;
1225
+ /**
1226
+ * @type {string}
1227
+ * User name.
1228
+ */
1229
+ userName: string;
1230
+ /**
1231
+ * @type {string}
1232
+ * User's Tenant name.
1233
+ */
1234
+ userTenantName: string;
1235
+ /**
1236
+ * @type {string}
1237
+ * User's e-mail.
1238
+ */
1239
+ userEmail: string;
1240
+ /**
1241
+ * @type {number}
1242
+ * Match level between the Analysis query and this User. Value is between 0 and 1, with 0.0 meaning no match and 1.0 meaning perfect match.
1243
+ */
1244
+ match: number;
1245
+ }
1123
1246
  export interface Badge {
1124
1247
  badgeID?: string;
1125
1248
  date?: string;