@memori.ai/memori-api-client 3.0.1 → 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 +16 -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 +41 -6
  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 +41 -6
  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 +145 -21
@@ -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
@@ -289,6 +289,7 @@ export type TenantBase = {
289
289
  name?: string;
290
290
  description?: string;
291
291
  logoURL?: string;
292
+ adminEmail?: string;
292
293
  /**
293
294
  * Additional Tenant names.
294
295
  * Usually host names, e.g. app.memorytwin.com.
@@ -1032,12 +1033,65 @@ export interface ImportWarning {
1032
1033
  }[];
1033
1034
  }
1034
1035
 
1035
- export interface ImportResponse {
1036
+ export interface AnalysisParams {
1037
+ query: string;
1038
+ }
1039
+
1040
+ export interface AnalysisWarning {
1041
+ /**
1042
+ * @type {string}
1043
+ * Type of warning.
1044
+ * Currently supported types are:
1045
+ * - Error: an error occurred while performing analysis
1046
+ */
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;
1036
1076
  /**
1037
1077
  * @type {string}
1038
- * Import process ID.
1078
+ * ID of the Memori object this process refers to.
1039
1079
  */
1040
- importID: string;
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';
1041
1095
  /**
1042
1096
  * @type {string}
1043
1097
  * minLength: 1
@@ -1066,28 +1120,11 @@ export interface ImportResponse {
1066
1120
  * Progress of the Import process as a fraction of 1.
1067
1121
  */
1068
1122
  progress: number;
1069
- /**
1070
- * @type {string}
1071
- * Import type. Can be one of the following:
1072
- * - CSV: for tabular documents
1073
- * - TXT: for text documents
1074
- */
1075
- importType: 'CSV' | 'TXT';
1076
- /**
1077
- * @type {number}
1078
- * Size of the imported document in characters.
1079
- */
1080
- importSize: number;
1081
- /**
1082
- * @type {string?}
1083
- * Name of this import, if set when the Import process was requested.
1084
- */
1085
- importName?: string;
1086
1123
  /**
1087
1124
  * @type {string?}
1088
1125
  * Original parameters of the Import process request, as a JSON structure, excluding the document rows.
1089
1126
  */
1090
- importSpecsJSON?: string;
1127
+ processSpecsJSON?: string;
1091
1128
  /**
1092
1129
  * @type {string=}
1093
1130
  * Timestamp of start of the Import process. Null until the Import process is in Starting status.
@@ -1103,7 +1140,28 @@ export interface ImportResponse {
1103
1140
  * Estimated time required to complete the Import process, in seconds.
1104
1141
  */
1105
1142
  eta?: number;
1143
+ creationTimestamp?: string;
1144
+ lastChangeTimestamp?: string;
1145
+ }
1106
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;
1107
1165
  /**
1108
1166
  * @type {number=}
1109
1167
  * Number of Imported Memory objects so far.
@@ -1119,6 +1177,72 @@ export interface ImportResponse {
1119
1177
  importWarnings?: ImportWarning[];
1120
1178
  }
1121
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
+ }
1122
1246
  export interface Badge {
1123
1247
  badgeID?: string;
1124
1248
  date?: string;