@memori.ai/memori-api-client 6.6.0 → 6.6.2

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 (63) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/dist/backend/asset.d.ts +3 -0
  3. package/dist/backend/asset.js +11 -0
  4. package/dist/backend/asset.js.map +1 -1
  5. package/dist/backend/tenant.d.ts +2 -2
  6. package/dist/backend/tenant.js +2 -2
  7. package/dist/backend/tenant.js.map +1 -1
  8. package/dist/backend/tenant.test.js +2 -2
  9. package/dist/backend/tenant.test.js.map +1 -1
  10. package/dist/backend/trustedApplication.d.ts +17 -0
  11. package/dist/backend/trustedApplication.js +26 -0
  12. package/dist/backend/trustedApplication.js.map +1 -0
  13. package/dist/backend/trustedApplication.test.d.ts +1 -0
  14. package/dist/backend/trustedApplication.test.js +14 -0
  15. package/dist/backend/trustedApplication.test.js.map +1 -0
  16. package/dist/backend/userPwl.d.ts +36 -0
  17. package/dist/backend/userPwl.js +53 -0
  18. package/dist/backend/userPwl.js.map +1 -0
  19. package/dist/backend.d.ts +104 -4
  20. package/dist/backend.js +6 -0
  21. package/dist/backend.js.map +1 -1
  22. package/dist/engine/chatLogs.d.ts +3 -0
  23. package/dist/engine/chatLogs.js +4 -0
  24. package/dist/engine/chatLogs.js.map +1 -1
  25. package/dist/engine.d.ts +6 -0
  26. package/dist/index.d.ts +110 -4
  27. package/dist/types.d.ts +17 -1
  28. package/esm/backend/asset.d.ts +3 -0
  29. package/esm/backend/asset.js +11 -0
  30. package/esm/backend/asset.js.map +1 -1
  31. package/esm/backend/tenant.d.ts +2 -2
  32. package/esm/backend/tenant.js +2 -2
  33. package/esm/backend/tenant.js.map +1 -1
  34. package/esm/backend/tenant.test.js +2 -2
  35. package/esm/backend/tenant.test.js.map +1 -1
  36. package/esm/backend/trustedApplication.d.ts +17 -0
  37. package/esm/backend/trustedApplication.js +24 -0
  38. package/esm/backend/trustedApplication.js.map +1 -0
  39. package/esm/backend/trustedApplication.test.d.ts +1 -0
  40. package/esm/backend/trustedApplication.test.js +11 -0
  41. package/esm/backend/trustedApplication.test.js.map +1 -0
  42. package/esm/backend/userPwl.d.ts +36 -0
  43. package/esm/backend/userPwl.js +51 -0
  44. package/esm/backend/userPwl.js.map +1 -0
  45. package/esm/backend.d.ts +104 -4
  46. package/esm/backend.js +6 -0
  47. package/esm/backend.js.map +1 -1
  48. package/esm/engine/chatLogs.d.ts +3 -0
  49. package/esm/engine/chatLogs.js +4 -0
  50. package/esm/engine/chatLogs.js.map +1 -1
  51. package/esm/engine.d.ts +6 -0
  52. package/esm/index.d.ts +110 -4
  53. package/esm/types.d.ts +17 -1
  54. package/package.json +1 -1
  55. package/src/backend/asset.ts +34 -0
  56. package/src/backend/tenant.test.ts +4 -2
  57. package/src/backend/tenant.ts +4 -4
  58. package/src/backend/trustedApplication.test.ts +21 -0
  59. package/src/backend/trustedApplication.ts +64 -0
  60. package/src/backend/userPwl.ts +155 -0
  61. package/src/backend.ts +6 -0
  62. package/src/engine/chatLogs.ts +27 -0
  63. package/src/types.ts +18 -1
@@ -0,0 +1,64 @@
1
+ import { ResponseSpec, TrustedApplication } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ export default (apiUrl: string) => ({
5
+ /**
6
+ * Creates a new TrustedApplication.
7
+ * Only administrators can create TrustedApplications.
8
+ * @param authToken - The login token
9
+ * @param trustedApplication - The TrustedApplication specifications
10
+ * @returns The created TrustedApplication object
11
+ */
12
+ createTrustedApplication: (authToken: string, trustedApplication: TrustedApplication) =>
13
+ apiFetcher(`/TrustedApplication/${authToken}`, {
14
+ apiUrl,
15
+ body: trustedApplication,
16
+ method: 'POST',
17
+ }) as Promise<ResponseSpec & { trustedApplication: TrustedApplication }>,
18
+
19
+ /**
20
+ * Gets a TrustedApplication by ID.
21
+ * @param authToken - The login token
22
+ * @param trustedApplicationID - The TrustedApplication ID
23
+ * @returns The TrustedApplication object
24
+ */
25
+ getTrustedApplication: (authToken: string, trustedApplicationID: string) =>
26
+ apiFetcher(`/TrustedApplication/${authToken}/${trustedApplicationID}`, {
27
+ apiUrl,
28
+ }) as Promise<ResponseSpec & { trustedApplication: TrustedApplication }>,
29
+
30
+ /**
31
+ * Updates an existing TrustedApplication.
32
+ * @param authToken - The login token
33
+ * @param trustedApplicationID - The TrustedApplication ID
34
+ * @param trustedApplication - The TrustedApplication specifications
35
+ * @returns The updated TrustedApplication object
36
+ */
37
+ updateTrustedApplication: (authToken: string, trustedApplicationID: string, trustedApplication: TrustedApplication) =>
38
+ apiFetcher(`/TrustedApplication/${authToken}/${trustedApplicationID}`, {
39
+ apiUrl,
40
+ method: 'PUT',
41
+ body: trustedApplication,
42
+ }) as Promise<ResponseSpec & { trustedApplication: TrustedApplication }>,
43
+
44
+ /**
45
+ * Deletes a TrustedApplication.
46
+ * @param authToken - The login token
47
+ * @param trustedApplicationID - The TrustedApplication ID
48
+ */
49
+ deleteTrustedApplication: (authToken: string, trustedApplicationID: string) =>
50
+ apiFetcher(`/TrustedApplication/${authToken}/${trustedApplicationID}`, {
51
+ apiUrl,
52
+ method: 'DELETE',
53
+ }) as Promise<ResponseSpec>,
54
+
55
+ /**
56
+ * Lists all TrustedApplications for the current tenant.
57
+ * @param authToken - The login token
58
+ * @returns A list of TrustedApplication objects
59
+ */
60
+ getTrustedApplicationsList: (authToken: string) =>
61
+ apiFetcher(`/TrustedApplications/${authToken}`, {
62
+ apiUrl,
63
+ }) as Promise<ResponseSpec & { trustedApplications: TrustedApplication[] }>,
64
+ });
@@ -0,0 +1,155 @@
1
+ import { ResponseSpec, User, UserFilters } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ export default (apiUrl: string) => ({
5
+ /**
6
+ * Tries a login with the specified credentials and returns a login token if successful.
7
+ * @param user - The user object
8
+ * @returns The logged in user object
9
+ */
10
+ pwlUserLogin: (user: User) =>
11
+ apiFetcher('/PwlLogin', {
12
+ apiUrl,
13
+ body: user,
14
+ method: 'POST',
15
+ }) as Promise<
16
+ ResponseSpec & { user: User; token?: string; flowID?: string }
17
+ >,
18
+
19
+ /**
20
+ * Logs out the user.
21
+ * @param authToken - The login token
22
+ */
23
+ pwlUserLogout: (authToken: string) =>
24
+ apiFetcher(`/PwlLogout/${authToken}`, {
25
+ apiUrl,
26
+ method: 'POST',
27
+ }) as Promise<ResponseSpec>,
28
+
29
+ /**
30
+ * Gets the details of the currently logged in User object.
31
+ * @param authToken - The login token
32
+ * @returns The user object
33
+ */
34
+ pwlGetCurrentUser: (authToken: string) =>
35
+ apiFetcher(`/PwlUser/${authToken}`, {
36
+ apiUrl,
37
+ }) as Promise<
38
+ ResponseSpec & {
39
+ user: User;
40
+ }
41
+ >,
42
+
43
+ /**
44
+ * Gets the details of a User object.
45
+ * @param authToken - The login token
46
+ * @param userID - The user ID
47
+ * @returns The user object
48
+ */
49
+ pwlGetUser: (authToken: string, userID: string) =>
50
+ apiFetcher(`/PwlUser/${authToken}/${userID}`, {
51
+ apiUrl,
52
+ }) as Promise<
53
+ ResponseSpec & {
54
+ user: User;
55
+ }
56
+ >,
57
+
58
+ /**
59
+ * Gets a list of all the existing User objects.
60
+ * @param authToken - The login token
61
+ * @returns A list of User objects
62
+ */
63
+ pwlGetUsersList: (authToken: string) =>
64
+ apiFetcher(`/PwlUsers/${authToken}`, {
65
+ apiUrl,
66
+ }) as Promise<
67
+ ResponseSpec & {
68
+ users: User[];
69
+ }
70
+ >,
71
+
72
+ /**
73
+ * Gets a list of all the existing User objects paginated.
74
+ * @param authToken - The login token
75
+ * @param from - The 0-based index of the first User object to list
76
+ * @param howMany - The number of User objects to list
77
+ * @returns A list of User objects
78
+ */
79
+ pwlGetUsersListPaginated: (authToken: string, filters: UserFilters) =>
80
+ apiFetcher(`/FilterPwlUsers/${authToken}`, {
81
+ apiUrl,
82
+ body: filters,
83
+ method: 'POST',
84
+ }) as Promise<
85
+ ResponseSpec & {
86
+ users: User[];
87
+ count: number;
88
+ }
89
+ >,
90
+
91
+ /**
92
+ * Deletes the currently logged in User.
93
+ * @param {string} authToken - The login token
94
+ * @param {string} userID: The User ID
95
+ */
96
+ pwlDeleteUser: (authToken: string, userID: string) =>
97
+ apiFetcher(`/PwlUser/${authToken}/${userID}`, {
98
+ apiUrl,
99
+ method: 'DELETE',
100
+ }) as Promise<ResponseSpec>,
101
+
102
+ /**
103
+ * Updates the details of a User object.
104
+ * @param authToken - The login token
105
+ * @param userID - The user ID
106
+ * @returns The user object
107
+ */
108
+ pwlUpdateUser: (authToken: string, userID: string, user: User) =>
109
+ apiFetcher(`/PwlUser/${authToken}/${userID}`, {
110
+ apiUrl,
111
+ method: 'PATCH',
112
+ body: user,
113
+ }) as Promise<
114
+ ResponseSpec & {
115
+ user: User;
116
+ }
117
+ >,
118
+
119
+ /**
120
+ * Recovers a User's name and sends it to their configured e-mail.
121
+ * @param {User} user - The user object
122
+ */
123
+ pwlRecoverUsername: (user: User) =>
124
+ apiFetcher(`/RecoverPwlUserName`, {
125
+ apiUrl,
126
+ body: user,
127
+ method: 'POST',
128
+ }) as Promise<ResponseSpec>,
129
+
130
+ /**
131
+ * Registers a new user.
132
+ * @param {User} user - The user object
133
+ */
134
+ pwlCreateUser: (authToken: string, user: Partial<User>) =>
135
+ apiFetcher(`/PwlUser/${authToken}`, {
136
+ apiUrl,
137
+ body: user,
138
+ method: 'POST',
139
+ }) as Promise<ResponseSpec & { user: User }>,
140
+
141
+ /**
142
+ * Tries a login with the specified JWT and returns a login token if successful.
143
+ * @param {object} payload - The payload object
144
+ * @param {string} payload.jwt - The JWT
145
+ * @returns The logged in user object
146
+ */
147
+ pwlLoginWithJWT: (jwt: string) =>
148
+ apiFetcher('/LoginWithJWT', {
149
+ apiUrl,
150
+ body: { jwt },
151
+ method: 'POST',
152
+ }) as Promise<
153
+ ResponseSpec & { user: User; token?: string; flowID?: string }
154
+ >,
155
+ });
package/src/backend.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import memori from './backend/memori';
2
2
  import user from './backend/user';
3
+ import userPwl from './backend/userPwl';
3
4
  import integration from './backend/integration';
4
5
  import asset from './backend/asset';
5
6
  import invitation from './backend/invitation';
@@ -11,11 +12,13 @@ import analysis from './backend/analysis';
11
12
  import completionConfig from './backend/completionConfig';
12
13
  import badge from './backend/badge';
13
14
  import tenant from './backend/tenant';
15
+ import trustedApplication from './backend/trustedApplication';
14
16
 
15
17
  const backendAPI = (apiUrl: string) => ({
16
18
  asset: asset(apiUrl),
17
19
  memori: memori(apiUrl),
18
20
  user: user(apiUrl),
21
+ userPwl: userPwl(apiUrl),
19
22
  integration: integration(apiUrl),
20
23
  invitation: invitation(apiUrl),
21
24
  consumptionLogs: consumptionLogs(apiUrl),
@@ -26,9 +29,11 @@ const backendAPI = (apiUrl: string) => ({
26
29
  completionConfig: completionConfig(apiUrl),
27
30
  badge: badge(apiUrl),
28
31
  tenant: tenant(apiUrl),
32
+ trustedApplication: trustedApplication(apiUrl),
29
33
  ...asset(apiUrl),
30
34
  ...memori(apiUrl),
31
35
  ...user(apiUrl),
36
+ ...userPwl(apiUrl),
32
37
  ...integration(apiUrl),
33
38
  ...invitation(apiUrl),
34
39
  ...consumptionLogs(apiUrl),
@@ -39,6 +44,7 @@ const backendAPI = (apiUrl: string) => ({
39
44
  ...completionConfig(apiUrl),
40
45
  ...badge(apiUrl),
41
46
  ...tenant(apiUrl),
47
+ ...trustedApplication(apiUrl),
42
48
  });
43
49
 
44
50
  export default backendAPI;
@@ -29,6 +29,33 @@ export default (apiUrl: string) => ({
29
29
  }
30
30
  >,
31
31
 
32
+ /**
33
+ * Gets paginated Chat Log objects for the Memori of the current session in a specific date interval.
34
+ * @param {string} sessionId The session ID
35
+ * @param {string} dateFrom The begin of the date interval, in UTC time, in the format yyyyMMddHHmmssfff
36
+ * @param {string} dateTo The end of the date interval, in UTC time, in the format yyyyMMddHHmmssfff
37
+ * @param {number} from The starting index for pagination
38
+ * @param {number} howMany The number of items to retrieve
39
+ */
40
+ getChatLogsPaged: async (
41
+ sessionId: string,
42
+ dateFrom: string,
43
+ dateTo: string,
44
+ from: number,
45
+ howMany: number
46
+ ) =>
47
+ apiFetcher(
48
+ `/ChatLogsPaged/${sessionId}/${dateFrom}/${dateTo}/${from}/${howMany}`,
49
+ {
50
+ method: 'GET',
51
+ apiUrl,
52
+ }
53
+ ) as Promise<
54
+ ResponseSpec & {
55
+ chatLogs: ChatLog[];
56
+ }
57
+ >,
58
+
32
59
  /**
33
60
  * Gets the Chat Log objects for the Memori of the current session created by the current User.
34
61
  * @param {string} sessionId The session ID
package/src/types.ts CHANGED
@@ -558,6 +558,7 @@ export declare type Tenant = {
558
558
  billingDelegation?: boolean;
559
559
  creationTimestamp?: string;
560
560
  lastChangeTimestamp?: string;
561
+ perplexityAPIKey?: string;
561
562
  };
562
563
 
563
564
  export declare type LocalizationKeyContent = {
@@ -630,11 +631,12 @@ export declare type ConsumptionLog = {
630
631
  export declare type Notification = {
631
632
  notificationID: string;
632
633
  timestamp: string;
633
- severity: 'INFO' | 'WARN' | 'ALERT' | 'AWARD' | 'CHATLOG';
634
+ severity: 'INFO' | 'WARN' | 'ALERT' | 'AWARD' | 'CHANGELOG';
634
635
  type: 'BROADCAST' | 'TENANT' | 'USER';
635
636
  tenantID?: string;
636
637
  userID?: string;
637
638
  validFrom?: string;
639
+ userName?: string;
638
640
  validTo?: string;
639
641
  texts: {
640
642
  'it-IT': string;
@@ -882,6 +884,7 @@ export declare type OpenSession = {
882
884
  recoveryTokens?: string[];
883
885
  tag?: string;
884
886
  pin?: string;
887
+ continueFromChatLogID?: string;
885
888
  initialContextVars?: { [key: string]: string };
886
889
  initialQuestion?: string;
887
890
  forceCloseSessions?: boolean;
@@ -1932,3 +1935,17 @@ export declare type MacroFunction = {
1932
1935
  obfuscated?: boolean;
1933
1936
  }[];
1934
1937
  };
1938
+
1939
+ export declare type TrustedApplication = {
1940
+ trustedApplicationID: string;
1941
+ tenantID: string;
1942
+ name: string;
1943
+ description: string;
1944
+ baseUrl: string;
1945
+ authorizationToken: string;
1946
+ isEnabled: boolean;
1947
+ createdByUserID: string;
1948
+ lastModifiedByUserID: string;
1949
+ creationTimestamp: string;
1950
+ lastChangeTimestamp: string;
1951
+ };