@memori.ai/memori-api-client 2.7.0 → 3.0.1
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 +20 -0
- package/README.md +7 -12
- package/dist/backend/user.d.ts +3 -0
- package/dist/backend/user.js +3 -0
- package/dist/backend/user.js.map +1 -1
- package/dist/backend.d.ts +6 -0
- package/dist/client.test.js +1 -1
- package/dist/client.test.js.map +1 -1
- package/dist/engine/knownFacts.test.js +1 -1
- package/dist/engine/knownFacts.test.js.map +1 -1
- package/dist/engine/topics.d.ts +23 -0
- package/dist/engine/topics.js +26 -0
- package/dist/engine/topics.js.map +1 -0
- package/dist/engine/topics.test.d.ts +1 -0
- package/dist/engine/topics.test.js +14 -0
- package/dist/engine/topics.test.js.map +1 -0
- package/dist/engine/user.d.ts +23 -0
- package/dist/engine/user.js +26 -0
- package/dist/engine/user.js.map +1 -0
- package/dist/engine/user.test.d.ts +1 -0
- package/dist/engine/user.test.js +14 -0
- package/dist/engine/user.test.js.map +1 -0
- package/dist/engine.d.ts +80 -12
- package/dist/engine.js +6 -3
- package/dist/engine.js.map +1 -1
- package/dist/helpers/asset.js +1 -1
- package/dist/helpers/asset.js.map +1 -1
- package/dist/index.d.ts +86 -12
- package/dist/types.d.ts +44 -16
- package/esm/backend/user.d.ts +3 -0
- package/esm/backend/user.js +3 -0
- package/esm/backend/user.js.map +1 -1
- package/esm/backend.d.ts +6 -0
- package/esm/client.test.js +1 -1
- package/esm/client.test.js.map +1 -1
- package/esm/engine/knownFacts.test.js +1 -1
- package/esm/engine/knownFacts.test.js.map +1 -1
- package/esm/engine/topics.d.ts +23 -0
- package/esm/engine/topics.js +24 -0
- package/esm/engine/topics.js.map +1 -0
- package/esm/engine/topics.test.d.ts +1 -0
- package/esm/engine/topics.test.js +11 -0
- package/esm/engine/topics.test.js.map +1 -0
- package/esm/engine/user.d.ts +23 -0
- package/esm/engine/user.js +24 -0
- package/esm/engine/user.js.map +1 -0
- package/esm/engine/user.test.d.ts +1 -0
- package/esm/engine/user.test.js +11 -0
- package/esm/engine/user.test.js.map +1 -0
- package/esm/engine.d.ts +80 -12
- package/esm/engine.js +6 -3
- package/esm/engine.js.map +1 -1
- package/esm/helpers/asset.js +1 -1
- package/esm/helpers/asset.js.map +1 -1
- package/esm/index.d.ts +86 -12
- package/esm/types.d.ts +44 -16
- package/package.json +1 -1
- package/src/backend/user.ts +14 -0
- package/src/client.test.ts +1 -1
- package/src/engine/knownFacts.test.ts +1 -2
- package/src/engine/topics.test.ts +17 -0
- package/src/engine/topics.ts +124 -0
- package/src/engine/{promptedQuestions.test.ts → user.test.ts} +5 -5
- package/src/engine/user.ts +124 -0
- package/src/engine.ts +6 -3
- package/src/helpers/asset.ts +2 -2
- package/src/types.ts +84 -16
- package/src/engine/promptedQuestions.ts +0 -63
package/esm/index.d.ts
CHANGED
|
@@ -9,6 +9,86 @@ declare const api: (hostname?: string) => {
|
|
|
9
9
|
asset: {
|
|
10
10
|
getResourceUrl: ({ type, resourceURI, sessionID, baseURL, }: import("./helpers/asset").ResourceURLParams) => string;
|
|
11
11
|
};
|
|
12
|
+
getTopics: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
13
|
+
count: number;
|
|
14
|
+
topics: import("./types").Topic[];
|
|
15
|
+
}>;
|
|
16
|
+
getTopicsPaginated: (sessionId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
17
|
+
count: number;
|
|
18
|
+
topics: import("./types").Topic[];
|
|
19
|
+
}>;
|
|
20
|
+
getTopic: (sessionId: string, topicID: string) => Promise<import("./types").ResponseSpec & {
|
|
21
|
+
topic: import("./types").Topic;
|
|
22
|
+
}>;
|
|
23
|
+
getTopicUsers: (sessionId: string, topicId: string) => Promise<import("./types").ResponseSpec & {
|
|
24
|
+
count: number;
|
|
25
|
+
users: import("./types").MemoriUser[];
|
|
26
|
+
}>;
|
|
27
|
+
getTopicUsersPaginated: (sessionId: string, topicId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
28
|
+
count: number;
|
|
29
|
+
users: import("./types").MemoriUser[];
|
|
30
|
+
}>;
|
|
31
|
+
topics: {
|
|
32
|
+
getTopics: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
33
|
+
count: number;
|
|
34
|
+
topics: import("./types").Topic[];
|
|
35
|
+
}>;
|
|
36
|
+
getTopicsPaginated: (sessionId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
37
|
+
count: number;
|
|
38
|
+
topics: import("./types").Topic[];
|
|
39
|
+
}>;
|
|
40
|
+
getTopic: (sessionId: string, topicID: string) => Promise<import("./types").ResponseSpec & {
|
|
41
|
+
topic: import("./types").Topic;
|
|
42
|
+
}>;
|
|
43
|
+
getTopicUsers: (sessionId: string, topicId: string) => Promise<import("./types").ResponseSpec & {
|
|
44
|
+
count: number;
|
|
45
|
+
users: import("./types").MemoriUser[];
|
|
46
|
+
}>;
|
|
47
|
+
getTopicUsersPaginated: (sessionId: string, topicId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
48
|
+
count: number;
|
|
49
|
+
users: import("./types").MemoriUser[];
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
getMemoriUsers: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
53
|
+
count: number;
|
|
54
|
+
users: import("./types").MemoriUser[];
|
|
55
|
+
}>;
|
|
56
|
+
getMemoriUsersPaginated: (sessionId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
57
|
+
count: number;
|
|
58
|
+
users: import("./types").MemoriUser[];
|
|
59
|
+
}>;
|
|
60
|
+
getMemoriUser: (sessionId: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
61
|
+
user: import("./types").MemoriUser;
|
|
62
|
+
}>;
|
|
63
|
+
getMemoriUserTopics: (sessionId: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
64
|
+
count: number;
|
|
65
|
+
topics: import("./types").Topic[];
|
|
66
|
+
}>;
|
|
67
|
+
getMemoriUserTopicsPaginated: (sessionId: string, userID: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
68
|
+
count: number;
|
|
69
|
+
topics: import("./types").Topic[];
|
|
70
|
+
}>;
|
|
71
|
+
user: {
|
|
72
|
+
getMemoriUsers: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
73
|
+
count: number;
|
|
74
|
+
users: import("./types").MemoriUser[];
|
|
75
|
+
}>;
|
|
76
|
+
getMemoriUsersPaginated: (sessionId: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
77
|
+
count: number;
|
|
78
|
+
users: import("./types").MemoriUser[];
|
|
79
|
+
}>;
|
|
80
|
+
getMemoriUser: (sessionId: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
81
|
+
user: import("./types").MemoriUser;
|
|
82
|
+
}>;
|
|
83
|
+
getMemoriUserTopics: (sessionId: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
84
|
+
count: number;
|
|
85
|
+
topics: import("./types").Topic[];
|
|
86
|
+
}>;
|
|
87
|
+
getMemoriUserTopicsPaginated: (sessionId: string, userID: string, from: number, howMany: number) => Promise<import("./types").ResponseSpec & {
|
|
88
|
+
count: number;
|
|
89
|
+
topics: import("./types").Topic[];
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
12
92
|
getKnownFacts: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
13
93
|
count: number;
|
|
14
94
|
knownFacts: import("./types").KnownFact[];
|
|
@@ -243,18 +323,6 @@ declare const api: (hostname?: string) => {
|
|
|
243
323
|
postRandom: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
244
324
|
postHints: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
245
325
|
};
|
|
246
|
-
getPromptedQuestions: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
247
|
-
getPromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
248
|
-
patchPromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
249
|
-
deletePromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
250
|
-
postPromptedQuestion: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
251
|
-
promptedQuestions: {
|
|
252
|
-
getPromptedQuestions: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
253
|
-
getPromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
254
|
-
patchPromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
255
|
-
deletePromptedQuestion: (sessionId: string, promptId: string) => Promise<import("./types").ResponseSpec>;
|
|
256
|
-
postPromptedQuestion: (sessionId: string) => Promise<import("./types").ResponseSpec>;
|
|
257
|
-
};
|
|
258
326
|
getPeople: (sessionId: string) => Promise<import("./types").ResponseSpec & {
|
|
259
327
|
people: import("./types").Person[];
|
|
260
328
|
}>;
|
|
@@ -629,6 +697,9 @@ declare const api: (hostname?: string) => {
|
|
|
629
697
|
flowID?: string | undefined;
|
|
630
698
|
}>;
|
|
631
699
|
userLogout: (authToken: string) => Promise<import("./types").ResponseSpec>;
|
|
700
|
+
getCurrentUser: (authToken: string) => Promise<import("./types").ResponseSpec & {
|
|
701
|
+
user: import("./types").User;
|
|
702
|
+
}>;
|
|
632
703
|
getUser: (authToken: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
633
704
|
user: import("./types").User;
|
|
634
705
|
}>;
|
|
@@ -803,6 +874,9 @@ declare const api: (hostname?: string) => {
|
|
|
803
874
|
flowID?: string | undefined;
|
|
804
875
|
}>;
|
|
805
876
|
userLogout: (authToken: string) => Promise<import("./types").ResponseSpec>;
|
|
877
|
+
getCurrentUser: (authToken: string) => Promise<import("./types").ResponseSpec & {
|
|
878
|
+
user: import("./types").User;
|
|
879
|
+
}>;
|
|
806
880
|
getUser: (authToken: string, userID: string) => Promise<import("./types").ResponseSpec & {
|
|
807
881
|
user: import("./types").User;
|
|
808
882
|
}>;
|
package/esm/types.d.ts
CHANGED
|
@@ -54,16 +54,19 @@ export declare type Memori = {
|
|
|
54
54
|
disableR5Loop?: boolean;
|
|
55
55
|
ageRestriction?: number;
|
|
56
56
|
nsfw?: boolean;
|
|
57
|
-
enableBoardOfExperts?: boolean;
|
|
58
57
|
enableCompletions?: boolean;
|
|
59
58
|
completionDescription?: string;
|
|
60
|
-
completionProvider?: '-' | 'OpenAI';
|
|
59
|
+
completionProvider?: '-' | 'Mistral' | 'OpenAI';
|
|
61
60
|
completionProviderConfig?: string;
|
|
62
61
|
enableDeepThought?: boolean;
|
|
62
|
+
enableBoardOfExperts?: boolean;
|
|
63
63
|
disableCompletionMediaExtraction?: boolean;
|
|
64
64
|
chainingMemoriID?: string;
|
|
65
65
|
chainingBaseURL?: string;
|
|
66
66
|
chainingPassword?: string;
|
|
67
|
+
dcmUser?: string;
|
|
68
|
+
dcmSecret?: string;
|
|
69
|
+
dcmAppContext?: string;
|
|
67
70
|
properties?: [{
|
|
68
71
|
[key: string]: string;
|
|
69
72
|
}];
|
|
@@ -105,13 +108,12 @@ export declare type User = {
|
|
|
105
108
|
newsletterSubscribed?: boolean;
|
|
106
109
|
maxMemori?: number;
|
|
107
110
|
numMemori?: number;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
canEditIntegrations?: boolean;
|
|
112
|
-
canEditDynamicIntents?: boolean;
|
|
113
|
-
canEditMemoriChaining?: boolean;
|
|
111
|
+
enableMemoriCreation?: boolean;
|
|
112
|
+
enableBoardOfExperts?: boolean;
|
|
113
|
+
enableDCMIntegration?: boolean;
|
|
114
114
|
enableBadges?: boolean;
|
|
115
|
+
enableVirtualSpaces?: boolean;
|
|
116
|
+
enableDeepThought?: boolean;
|
|
115
117
|
monthSessions?: number;
|
|
116
118
|
monthValidSessions?: number;
|
|
117
119
|
maxFreeSessions?: number;
|
|
@@ -124,7 +126,7 @@ export declare type User = {
|
|
|
124
126
|
lastChangeTimestamp?: string;
|
|
125
127
|
referral?: string;
|
|
126
128
|
couponCode?: string;
|
|
127
|
-
defaultCompletionProvider?: '-' | 'OpenAI';
|
|
129
|
+
defaultCompletionProvider?: '-' | 'Mistral' | 'OpenAI';
|
|
128
130
|
defaultCompletionProviderConfig?: string;
|
|
129
131
|
paying?: boolean;
|
|
130
132
|
notificationPrefs?: NotificationPrefs[];
|
|
@@ -132,6 +134,8 @@ export declare type User = {
|
|
|
132
134
|
age?: number;
|
|
133
135
|
tnCAndPPAccepted?: boolean;
|
|
134
136
|
tnCAndPPAcceptanceDate?: string;
|
|
137
|
+
pAndCUAccepted?: boolean;
|
|
138
|
+
pAndCUAcceptanceDate?: string;
|
|
135
139
|
avatarURL?: string;
|
|
136
140
|
avatar3DURL?: string;
|
|
137
141
|
avatar3DURLType?: string;
|
|
@@ -192,13 +196,13 @@ export type TenantConfig = {
|
|
|
192
196
|
name: string;
|
|
193
197
|
showNewUser: boolean;
|
|
194
198
|
requirePosition: boolean;
|
|
195
|
-
feedbackURL?: string;
|
|
196
199
|
};
|
|
197
200
|
export type TenantBase = {
|
|
198
201
|
tenantID?: string;
|
|
199
202
|
name?: string;
|
|
200
203
|
description?: string;
|
|
201
204
|
logoURL?: string;
|
|
205
|
+
aliases?: string[];
|
|
202
206
|
adminCount?: number;
|
|
203
207
|
userCount?: number;
|
|
204
208
|
memoriCount?: number;
|
|
@@ -211,15 +215,19 @@ export type TenantBase = {
|
|
|
211
215
|
maxFreeSessions?: number;
|
|
212
216
|
maxFreeSessionsPerUser?: number;
|
|
213
217
|
nonFreeSessionCost?: number;
|
|
218
|
+
maxImportSize?: number;
|
|
219
|
+
maxImportSizePerUser?: number;
|
|
214
220
|
maxCompletions?: number;
|
|
215
221
|
maxCompletionsPerUser?: number;
|
|
222
|
+
defaultCompletionProvider?: '-' | 'Mistral' | 'OpenAI';
|
|
223
|
+
defaultCompletionProviderConfig?: string;
|
|
216
224
|
paying?: boolean;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
225
|
+
enableUserMemoriCreation?: boolean;
|
|
226
|
+
enableBoardOfExperts?: boolean;
|
|
227
|
+
enableDCMIntegration?: boolean;
|
|
228
|
+
enableBadges?: boolean;
|
|
229
|
+
enableVirtualSpaces?: boolean;
|
|
230
|
+
enableDeepThought?: boolean;
|
|
223
231
|
creationTimestamp?: string;
|
|
224
232
|
lastChangeTimestamp?: string;
|
|
225
233
|
};
|
|
@@ -706,3 +714,23 @@ export interface KnownFact {
|
|
|
706
714
|
lastChangeTimestamp?: string;
|
|
707
715
|
lastChangeSessionID?: string;
|
|
708
716
|
}
|
|
717
|
+
export interface MemoriUser {
|
|
718
|
+
userID: string;
|
|
719
|
+
email: string;
|
|
720
|
+
userName: string;
|
|
721
|
+
tenantName: string;
|
|
722
|
+
disableDeepThought: boolean;
|
|
723
|
+
creationTimestamp: string;
|
|
724
|
+
creationSessionID: string;
|
|
725
|
+
lastChangeTimestamp: string;
|
|
726
|
+
lastChangeSessionID: string;
|
|
727
|
+
}
|
|
728
|
+
export interface Topic {
|
|
729
|
+
topicID: string;
|
|
730
|
+
name: string;
|
|
731
|
+
weight: number;
|
|
732
|
+
creationTimestamp: string;
|
|
733
|
+
creationSessionID: string;
|
|
734
|
+
lastChangeTimestamp: string;
|
|
735
|
+
lastChangeSessionID: string;
|
|
736
|
+
}
|
package/package.json
CHANGED
package/src/backend/user.ts
CHANGED
|
@@ -50,6 +50,20 @@ export default (apiUrl: string) => ({
|
|
|
50
50
|
method: 'POST',
|
|
51
51
|
}) as Promise<ResponseSpec>,
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Gets the details of the currently logged in User object.
|
|
55
|
+
* @param authToken - The login token
|
|
56
|
+
* @returns The user object
|
|
57
|
+
*/
|
|
58
|
+
getCurrentUser: (authToken: string) =>
|
|
59
|
+
apiFetcher(`/User/${authToken}`, {
|
|
60
|
+
apiUrl,
|
|
61
|
+
}) as Promise<
|
|
62
|
+
ResponseSpec & {
|
|
63
|
+
user: User;
|
|
64
|
+
}
|
|
65
|
+
>,
|
|
66
|
+
|
|
53
67
|
/**
|
|
54
68
|
* Gets the details of a User object.
|
|
55
69
|
* @param authToken - The login token
|
package/src/client.test.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import memori from '../index';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const client = memori('https://backend-staging.memori.ai');
|
|
3
|
+
const client = memori('https://backend.memori.ai');
|
|
5
4
|
|
|
6
5
|
describe('engine/knownFacts api', () => {
|
|
7
6
|
it('works on knownFacts apis', async () => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import memori from '../index';
|
|
2
|
+
|
|
3
|
+
const client = memori('https://backend.memori.ai');
|
|
4
|
+
|
|
5
|
+
describe('engine/topics api', () => {
|
|
6
|
+
it('works on topics apis', async () => {
|
|
7
|
+
expect(
|
|
8
|
+
await client.topics.getTopics('768b9654-e781-4c3c-81fa-ae1529d1bfbe')
|
|
9
|
+
).not.toBeNull();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('works on topics apis with shorthand version', async () => {
|
|
13
|
+
expect(
|
|
14
|
+
await client.getTopics('768b9654-e781-4c3c-81fa-ae1529d1bfbe')
|
|
15
|
+
).not.toBeNull();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ResponseSpec, MemoriUser, Topic } from '../types';
|
|
2
|
+
import { apiFetcher } from '../apiFetcher';
|
|
3
|
+
|
|
4
|
+
/****************
|
|
5
|
+
* *
|
|
6
|
+
* Topics *
|
|
7
|
+
* *
|
|
8
|
+
****************/
|
|
9
|
+
|
|
10
|
+
export default (apiUrl: string) => ({
|
|
11
|
+
/**
|
|
12
|
+
* Lists all Topic objects.
|
|
13
|
+
* @param {string} sessionId The session ID
|
|
14
|
+
*/
|
|
15
|
+
getTopics: async (sessionId: string) =>
|
|
16
|
+
apiFetcher(`/Topics/${sessionId}`, {
|
|
17
|
+
method: 'GET',
|
|
18
|
+
apiUrl,
|
|
19
|
+
}) as Promise<
|
|
20
|
+
ResponseSpec & {
|
|
21
|
+
/**
|
|
22
|
+
* Total number of MemoriUser objects.
|
|
23
|
+
*/
|
|
24
|
+
count: number;
|
|
25
|
+
/**
|
|
26
|
+
* List of MemoriUser objects. May be empty.
|
|
27
|
+
*/
|
|
28
|
+
topics: Topic[];
|
|
29
|
+
}
|
|
30
|
+
>,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Lists Topic objects with pagination.
|
|
34
|
+
* @param {string} sessionId The session ID
|
|
35
|
+
* @param {number} from The 0-based index of the first Topics object to list
|
|
36
|
+
* @param {number} howMany The number of the Topics objects to list
|
|
37
|
+
*/
|
|
38
|
+
getTopicsPaginated: async (
|
|
39
|
+
sessionId: string,
|
|
40
|
+
from: number,
|
|
41
|
+
howMany: number
|
|
42
|
+
) =>
|
|
43
|
+
apiFetcher(`/Topics/${sessionId}/${from}/${howMany}`, {
|
|
44
|
+
method: 'GET',
|
|
45
|
+
apiUrl,
|
|
46
|
+
}) as Promise<
|
|
47
|
+
ResponseSpec & {
|
|
48
|
+
/**
|
|
49
|
+
* Total number of Topic objects.
|
|
50
|
+
*/
|
|
51
|
+
count: number;
|
|
52
|
+
/**
|
|
53
|
+
* List of Topic objects. May be empty.
|
|
54
|
+
*/
|
|
55
|
+
topics: Topic[];
|
|
56
|
+
}
|
|
57
|
+
>,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Gets the details of a Topic object.
|
|
61
|
+
* @param {string} sessionId The session ID
|
|
62
|
+
* @param {string} topicID The Topic object ID
|
|
63
|
+
*/
|
|
64
|
+
getTopic: async (sessionId: string, topicID: string) =>
|
|
65
|
+
apiFetcher(`/Topic/${sessionId}/${topicID}`, {
|
|
66
|
+
method: 'GET',
|
|
67
|
+
apiUrl,
|
|
68
|
+
}) as Promise<
|
|
69
|
+
ResponseSpec & {
|
|
70
|
+
topic: Topic;
|
|
71
|
+
}
|
|
72
|
+
>,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Lists all MemoriUser objects referencing a specified Topic object.
|
|
76
|
+
* @param {string} sessionId The session ID
|
|
77
|
+
* @param {string} topicId The Topic object ID
|
|
78
|
+
*/
|
|
79
|
+
getTopicUsers: async (sessionId: string, topicId: string) =>
|
|
80
|
+
apiFetcher(`/TopicUsers/${sessionId}/${topicId}`, {
|
|
81
|
+
method: 'GET',
|
|
82
|
+
apiUrl,
|
|
83
|
+
}) as Promise<
|
|
84
|
+
ResponseSpec & {
|
|
85
|
+
/**
|
|
86
|
+
* Total number of MemoriUser objects.
|
|
87
|
+
*/
|
|
88
|
+
count: number;
|
|
89
|
+
/**
|
|
90
|
+
* List of MemoriUser objects. May be empty.
|
|
91
|
+
*/
|
|
92
|
+
users: MemoriUser[];
|
|
93
|
+
}
|
|
94
|
+
>,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Lists all MemoriUser objects referencing a specified Topic object, with pagination.
|
|
98
|
+
* @param {string} sessionId The session ID
|
|
99
|
+
* @param {string} topicId The Topic object ID
|
|
100
|
+
* @param {number} from The 0-based index of the first MemoriUser object to list
|
|
101
|
+
* @param {number} howMany The number of the MemoriUser objects to list
|
|
102
|
+
*/
|
|
103
|
+
getTopicUsersPaginated: async (
|
|
104
|
+
sessionId: string,
|
|
105
|
+
topicId: string,
|
|
106
|
+
from: number,
|
|
107
|
+
howMany: number
|
|
108
|
+
) =>
|
|
109
|
+
apiFetcher(`/TopicUsers/${sessionId}/${topicId}/${from}/${howMany}`, {
|
|
110
|
+
method: 'GET',
|
|
111
|
+
apiUrl,
|
|
112
|
+
}) as Promise<
|
|
113
|
+
ResponseSpec & {
|
|
114
|
+
/**
|
|
115
|
+
* Total number of MemoriUser objects.
|
|
116
|
+
*/
|
|
117
|
+
count: number;
|
|
118
|
+
/**
|
|
119
|
+
* List of MemoriUser objects. May be empty.
|
|
120
|
+
*/
|
|
121
|
+
users: MemoriUser[];
|
|
122
|
+
}
|
|
123
|
+
>,
|
|
124
|
+
});
|
|
@@ -2,19 +2,19 @@ import memori from '../index';
|
|
|
2
2
|
|
|
3
3
|
const client = memori('https://backend.memori.ai');
|
|
4
4
|
|
|
5
|
-
describe('engine/
|
|
6
|
-
it('works on
|
|
5
|
+
describe('engine/user api', () => {
|
|
6
|
+
it('works on user apis', async () => {
|
|
7
7
|
expect(
|
|
8
|
-
await client.
|
|
8
|
+
await client.user.getMemoriUser(
|
|
9
9
|
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
10
10
|
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
|
|
11
11
|
)
|
|
12
12
|
).not.toBeNull();
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('works on
|
|
15
|
+
it('works on user apis with shorthand version', async () => {
|
|
16
16
|
expect(
|
|
17
|
-
await client.
|
|
17
|
+
await client.getMemoriUser(
|
|
18
18
|
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
|
|
19
19
|
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
|
|
20
20
|
)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ResponseSpec, MemoriUser, Topic } from '../types';
|
|
2
|
+
import { apiFetcher } from '../apiFetcher';
|
|
3
|
+
|
|
4
|
+
/****************
|
|
5
|
+
* *
|
|
6
|
+
* User *
|
|
7
|
+
* *
|
|
8
|
+
****************/
|
|
9
|
+
|
|
10
|
+
export default (apiUrl: string) => ({
|
|
11
|
+
/**
|
|
12
|
+
* Lists all User objects associated with the Memori of the current session.
|
|
13
|
+
* @param {string} sessionId The session ID
|
|
14
|
+
*/
|
|
15
|
+
getMemoriUsers: async (sessionId: string) =>
|
|
16
|
+
apiFetcher(`/Users/${sessionId}`, {
|
|
17
|
+
method: 'GET',
|
|
18
|
+
apiUrl,
|
|
19
|
+
}) as Promise<
|
|
20
|
+
ResponseSpec & {
|
|
21
|
+
/**
|
|
22
|
+
* Total number of MemoriUser objects.
|
|
23
|
+
*/
|
|
24
|
+
count: number;
|
|
25
|
+
/**
|
|
26
|
+
* List of MemoriUser objects. May be empty.
|
|
27
|
+
*/
|
|
28
|
+
users: MemoriUser[];
|
|
29
|
+
}
|
|
30
|
+
>,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Lists all MemoriUser objects associated with the Memori of the current session, with pagination.
|
|
34
|
+
* @param {string} sessionId The session ID
|
|
35
|
+
* @param {number} from The 0-based index of the first MemoriUser object to list
|
|
36
|
+
* @param {number} howMany The number of the MemoriUser objects to list
|
|
37
|
+
*/
|
|
38
|
+
getMemoriUsersPaginated: async (
|
|
39
|
+
sessionId: string,
|
|
40
|
+
from: number,
|
|
41
|
+
howMany: number
|
|
42
|
+
) =>
|
|
43
|
+
apiFetcher(`/Users/${sessionId}/${from}/${howMany}`, {
|
|
44
|
+
method: 'GET',
|
|
45
|
+
apiUrl,
|
|
46
|
+
}) as Promise<
|
|
47
|
+
ResponseSpec & {
|
|
48
|
+
/**
|
|
49
|
+
* Total number of MemoriUser objects.
|
|
50
|
+
*/
|
|
51
|
+
count: number;
|
|
52
|
+
/**
|
|
53
|
+
* List of MemoriUser objects. May be empty.
|
|
54
|
+
*/
|
|
55
|
+
users: MemoriUser[];
|
|
56
|
+
}
|
|
57
|
+
>,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Gets the details of a User object.
|
|
61
|
+
* @param {string} sessionId The session ID
|
|
62
|
+
* @param {string} userID The User object ID
|
|
63
|
+
*/
|
|
64
|
+
getMemoriUser: async (sessionId: string, userID: string) =>
|
|
65
|
+
apiFetcher(`/User/${sessionId}/${userID}`, {
|
|
66
|
+
method: 'GET',
|
|
67
|
+
apiUrl,
|
|
68
|
+
}) as Promise<
|
|
69
|
+
ResponseSpec & {
|
|
70
|
+
user: MemoriUser;
|
|
71
|
+
}
|
|
72
|
+
>,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Lists all Topic objects referenced by a specified MemoriUser object.
|
|
76
|
+
* @param {string} sessionId The session ID
|
|
77
|
+
* @param {string} userID The User object ID
|
|
78
|
+
*/
|
|
79
|
+
getMemoriUserTopics: async (sessionId: string, userID: string) =>
|
|
80
|
+
apiFetcher(`/UserTopics/${sessionId}/${userID}`, {
|
|
81
|
+
method: 'GET',
|
|
82
|
+
apiUrl,
|
|
83
|
+
}) as Promise<
|
|
84
|
+
ResponseSpec & {
|
|
85
|
+
/**
|
|
86
|
+
* Total number of Topic objects.
|
|
87
|
+
*/
|
|
88
|
+
count: number;
|
|
89
|
+
/**
|
|
90
|
+
* List of Topic objects. May be empty.
|
|
91
|
+
*/
|
|
92
|
+
topics: Topic[];
|
|
93
|
+
}
|
|
94
|
+
>,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Lists all Topic objects referenced by a specified MemoriUser object, with pagination.
|
|
98
|
+
* @param {string} sessionId The session ID
|
|
99
|
+
* @param {string} userID The User object ID
|
|
100
|
+
* @param {number} from The 0-based index of the first Topics object to list
|
|
101
|
+
* @param {number} howMany The number of the Topics objects to list
|
|
102
|
+
*/
|
|
103
|
+
getMemoriUserTopicsPaginated: async (
|
|
104
|
+
sessionId: string,
|
|
105
|
+
userID: string,
|
|
106
|
+
from: number,
|
|
107
|
+
howMany: number
|
|
108
|
+
) =>
|
|
109
|
+
apiFetcher(`/UserTopics/${sessionId}/${userID}/${from}/${howMany}`, {
|
|
110
|
+
method: 'GET',
|
|
111
|
+
apiUrl,
|
|
112
|
+
}) as Promise<
|
|
113
|
+
ResponseSpec & {
|
|
114
|
+
/**
|
|
115
|
+
* Total number of Topic objects.
|
|
116
|
+
*/
|
|
117
|
+
count: number;
|
|
118
|
+
/**
|
|
119
|
+
* List of Topic objects. May be empty.
|
|
120
|
+
*/
|
|
121
|
+
topics: Topic[];
|
|
122
|
+
}
|
|
123
|
+
>,
|
|
124
|
+
});
|
package/src/engine.ts
CHANGED
|
@@ -6,7 +6,6 @@ import media from './engine/media';
|
|
|
6
6
|
import memories from './engine/memories';
|
|
7
7
|
import nlp from './engine/nlp';
|
|
8
8
|
import people from './engine/people';
|
|
9
|
-
import promptedQuestions from './engine/promptedQuestions';
|
|
10
9
|
import search from './engine/search';
|
|
11
10
|
import session from './engine/session';
|
|
12
11
|
import stats from './engine/stats';
|
|
@@ -16,6 +15,8 @@ import customDictionary from './engine/customDictionary';
|
|
|
16
15
|
import chatLogs from './engine/chatLogs';
|
|
17
16
|
import expertReferences from './engine/expertReferences';
|
|
18
17
|
import knownFacts from './engine/knownFacts';
|
|
18
|
+
import user from './engine/user';
|
|
19
|
+
import topics from './engine/topics';
|
|
19
20
|
|
|
20
21
|
export default (apiUrl: string) => ({
|
|
21
22
|
correlationPairs: correlationPairs(apiUrl),
|
|
@@ -34,8 +35,6 @@ export default (apiUrl: string) => ({
|
|
|
34
35
|
...nlp(apiUrl),
|
|
35
36
|
people: people(apiUrl),
|
|
36
37
|
...people(apiUrl),
|
|
37
|
-
promptedQuestions: promptedQuestions(apiUrl),
|
|
38
|
-
...promptedQuestions(apiUrl),
|
|
39
38
|
search: search(apiUrl),
|
|
40
39
|
...search(apiUrl),
|
|
41
40
|
session: session(apiUrl),
|
|
@@ -54,4 +53,8 @@ export default (apiUrl: string) => ({
|
|
|
54
53
|
...expertReferences(apiUrl),
|
|
55
54
|
knownFacts: knownFacts(apiUrl),
|
|
56
55
|
...knownFacts(apiUrl),
|
|
56
|
+
user: user(apiUrl),
|
|
57
|
+
...user(apiUrl),
|
|
58
|
+
topics: topics(apiUrl),
|
|
59
|
+
...topics(apiUrl),
|
|
57
60
|
});
|
package/src/helpers/asset.ts
CHANGED
|
@@ -13,14 +13,14 @@ export default (apiUrl: string) => ({
|
|
|
13
13
|
* @param {string=} params.type - wheather is the avatar or the cover
|
|
14
14
|
* @param {string=} params.resourceURI - the resource URI
|
|
15
15
|
* @param {string=} params.sessionID - the session ID, required for memory media attachments
|
|
16
|
-
* @param {string=} params.baseURL - the base URL for default static assets (defaults to https://
|
|
16
|
+
* @param {string=} params.baseURL - the base URL for default static assets (defaults to https://aisuru.com)
|
|
17
17
|
* @returns {string}
|
|
18
18
|
*/
|
|
19
19
|
getResourceUrl: ({
|
|
20
20
|
type,
|
|
21
21
|
resourceURI,
|
|
22
22
|
sessionID,
|
|
23
|
-
baseURL = 'https://
|
|
23
|
+
baseURL = 'https://aisuru.com',
|
|
24
24
|
}: ResourceURLParams): string => {
|
|
25
25
|
let defaultUri =
|
|
26
26
|
type === 'cover'
|