@memori.ai/memori-api-client 0.1.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 (70) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +188 -0
  3. package/dist/apiFetcher.d.ts +13 -0
  4. package/dist/backend/asset.d.ts +44 -0
  5. package/dist/backend/integration.d.ts +55 -0
  6. package/dist/backend/invitation.d.ts +82 -0
  7. package/dist/backend/memori.d.ts +125 -0
  8. package/dist/backend/user.d.ts +109 -0
  9. package/dist/backend.d.ts +273 -0
  10. package/dist/constants.d.ts +2 -0
  11. package/dist/engine/correlationPairs.d.ts +20 -0
  12. package/dist/engine/dialog.d.ts +88 -0
  13. package/dist/engine/importExport.d.ts +34 -0
  14. package/dist/engine/intents.d.ts +65 -0
  15. package/dist/engine/localizationKeys.d.ts +50 -0
  16. package/dist/engine/media.d.ts +48 -0
  17. package/dist/engine/memori.d.ts +30 -0
  18. package/dist/engine/memories.d.ts +50 -0
  19. package/dist/engine/nlp.d.ts +25 -0
  20. package/dist/engine/people.d.ts +46 -0
  21. package/dist/engine/promptedQuestions.d.ts +37 -0
  22. package/dist/engine/search.d.ts +30 -0
  23. package/dist/engine/session.d.ts +28 -0
  24. package/dist/engine/stats.d.ts +25 -0
  25. package/dist/engine/unansweredQuestions.d.ts +22 -0
  26. package/dist/engine/webhooks.d.ts +21 -0
  27. package/dist/engine.d.ts +297 -0
  28. package/dist/helpers/asset.d.ts +20 -0
  29. package/dist/helpers/getApiUrl.d.ts +1 -0
  30. package/dist/index.d.ts +582 -0
  31. package/dist/index.js +8 -0
  32. package/dist/memori-api-client.cjs.development.js +3666 -0
  33. package/dist/memori-api-client.cjs.development.js.map +1 -0
  34. package/dist/memori-api-client.cjs.production.min.js +2 -0
  35. package/dist/memori-api-client.cjs.production.min.js.map +1 -0
  36. package/dist/memori-api-client.esm.js +3660 -0
  37. package/dist/memori-api-client.esm.js.map +1 -0
  38. package/dist/speech.d.ts +10 -0
  39. package/dist/types.d.ts +410 -0
  40. package/package.json +125 -0
  41. package/src/apiFetcher.ts +29 -0
  42. package/src/backend/asset.ts +86 -0
  43. package/src/backend/integration.ts +98 -0
  44. package/src/backend/invitation.ts +115 -0
  45. package/src/backend/memori.ts +223 -0
  46. package/src/backend/user.ts +186 -0
  47. package/src/backend.ts +20 -0
  48. package/src/constants.ts +21 -0
  49. package/src/engine/correlationPairs.ts +31 -0
  50. package/src/engine/dialog.ts +158 -0
  51. package/src/engine/importExport.ts +43 -0
  52. package/src/engine/intents.ts +116 -0
  53. package/src/engine/localizationKeys.ts +94 -0
  54. package/src/engine/media.ts +79 -0
  55. package/src/engine/memori.ts +51 -0
  56. package/src/engine/memories.ts +89 -0
  57. package/src/engine/nlp.ts +39 -0
  58. package/src/engine/people.ts +82 -0
  59. package/src/engine/promptedQuestions.ts +63 -0
  60. package/src/engine/search.ts +49 -0
  61. package/src/engine/session.ts +49 -0
  62. package/src/engine/stats.ts +44 -0
  63. package/src/engine/unansweredQuestions.ts +38 -0
  64. package/src/engine/webhooks.ts +32 -0
  65. package/src/engine.ts +51 -0
  66. package/src/helpers/asset.ts +52 -0
  67. package/src/helpers/getApiUrl.ts +6 -0
  68. package/src/index.ts +20 -0
  69. package/src/speech.ts +242 -0
  70. package/src/types.ts +440 -0
@@ -0,0 +1,158 @@
1
+ import { DialogState, Medium, ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /******************
5
+ * *
6
+ * Dialog *
7
+ * *
8
+ ******************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Submits a Text Entered event to the session's Dialog State Machine.
13
+ * @param {object} params
14
+ * @param {string} params.sessionId The session ID
15
+ * @param {string} params.text The text entered by the user
16
+ */
17
+ postTextEnteredEvent: async ({
18
+ sessionId,
19
+ text,
20
+ }: {
21
+ sessionId: string;
22
+ text: string;
23
+ }) =>
24
+ apiFetcher(`/TextEnteredEvent/${sessionId}`, {
25
+ method: 'POST',
26
+ apiUrl,
27
+ body: {
28
+ text,
29
+ },
30
+ }) as Promise<
31
+ ResponseSpec & {
32
+ currentState: DialogState;
33
+ }
34
+ >,
35
+
36
+ /**
37
+ * Submits a Place Changed event to the session's Dialog State Machine.
38
+ * @param {object} params
39
+ * @param {string} params.sessionId - The session ID
40
+ * @param {string} params.placeName - The name of the place
41
+ * @param {number} params.latitude - The latitude of the place
42
+ * @param {number} params.longitude - The longitude of the place
43
+ * @param {number} params.uncertaintyKm - The uncertainty of the place in kilometers
44
+ */
45
+ postPlaceChangedEvent: async ({
46
+ sessionId,
47
+ placeName,
48
+ latitude,
49
+ longitude,
50
+ uncertaintyKm,
51
+ }: {
52
+ sessionId: string;
53
+ placeName: string;
54
+ latitude: number;
55
+ longitude: number;
56
+ uncertaintyKm?: number;
57
+ }) =>
58
+ apiFetcher(`/PlaceChangedEvent/${sessionId}`, {
59
+ method: 'POST',
60
+ apiUrl,
61
+ body: {
62
+ placeName,
63
+ latitude,
64
+ longitude,
65
+ uncertaintyKm,
66
+ },
67
+ }) as Promise<
68
+ ResponseSpec & {
69
+ currentState: DialogState;
70
+ }
71
+ >,
72
+
73
+ /**
74
+ * Submits a Date Changed event to the session's Dialog State Machine.
75
+ * @param {string} sessionId The session ID
76
+ */
77
+ postDateChangedEvent: async (sessionId: string) =>
78
+ apiFetcher(`/DateChangedEvent/${sessionId}`, {
79
+ method: 'POST',
80
+ apiUrl,
81
+ }) as Promise<ResponseSpec>,
82
+
83
+ /**
84
+ * Submits a Tag Changed event to the session's Dialog State Machine.
85
+ * @param {string} sessionId The session ID
86
+ * @param {string} tag The tag to set
87
+ */
88
+ postTagChangedEvent: async (sessionId: string, tag: string) =>
89
+ apiFetcher(`/TagChangedEvent/${sessionId}`, {
90
+ method: 'POST',
91
+ apiUrl,
92
+ body: { tag },
93
+ }) as Promise<
94
+ ResponseSpec & {
95
+ currentState: DialogState;
96
+ }
97
+ >,
98
+
99
+ /**
100
+ * Submits a Timeout event to the session's Dialog State Machine.
101
+ * @param {string} sessionId The session ID
102
+ */
103
+ postTimeoutEvent: async (sessionId: string) =>
104
+ apiFetcher(`/TimeoutEvent/${sessionId}`, {
105
+ method: 'POST',
106
+ apiUrl,
107
+ }) as Promise<
108
+ ResponseSpec & {
109
+ currentState: DialogState;
110
+ }
111
+ >,
112
+
113
+ /**
114
+ * Submits a Medium Selected event to the session's Dialog State Machine.
115
+ * @param {string} sessionId The session ID
116
+ * @param {Medium} medium The medium to set
117
+ */
118
+ postMediumSelectedEvent: async (sessionId: string, medium: Medium) =>
119
+ apiFetcher(`/MediumSelectedEvent/${sessionId}`, {
120
+ method: 'POST',
121
+ apiUrl,
122
+ body: { medium },
123
+ }) as Promise<
124
+ ResponseSpec & {
125
+ currentState: DialogState;
126
+ }
127
+ >,
128
+
129
+ /**
130
+ * Submits a Date Selected event to the session's Dialog State Machine.
131
+ * @param {string} sessionId The session ID
132
+ */
133
+ postDateSelectedEvent: async ({ sessionId }: { sessionId: string }) =>
134
+ apiFetcher(`/DateSelectedEvent/${sessionId}`, {
135
+ method: 'GET',
136
+ apiUrl,
137
+ }) as Promise<ResponseSpec>,
138
+
139
+ /**
140
+ * Submits a Place Selected event to the session's Dialog State Machine.
141
+ * @param {string} sessionId The session ID
142
+ */
143
+ postPlaceSelectedEvent: async ({ sessionId }: { sessionId: string }) =>
144
+ apiFetcher(`/PlaceSelectedEvent/${sessionId}`, {
145
+ method: 'GET',
146
+ apiUrl,
147
+ }) as Promise<ResponseSpec>,
148
+
149
+ /**
150
+ * Submits a Tag Selected event to the session's Dialog State Machine.
151
+ * @param {string} sessionId The session ID
152
+ */
153
+ postTagSelectedEvent: async ({ sessionId }: { sessionId: string }) =>
154
+ apiFetcher(`/TagSelectedEvent/${sessionId}`, {
155
+ method: 'GET',
156
+ apiUrl,
157
+ }) as Promise<ResponseSpec>,
158
+ });
@@ -0,0 +1,43 @@
1
+ import { ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ export interface ImportExportBody {
5
+ csvRows: string[];
6
+ questionColumnName: string;
7
+ answerColumnName: string;
8
+ propertyColumnNames: string[];
9
+ includedRows: number[];
10
+ csvSeparator: string;
11
+ questionTitleVariantsSeparator: string;
12
+ hasHeaders: boolean;
13
+ forceImport: boolean;
14
+ headerNames: string[];
15
+ }
16
+
17
+ export interface ImportExportReponse {
18
+ importID: string;
19
+ importedMemories: number;
20
+ importWarnings?: {
21
+ warningType: string;
22
+ }[];
23
+ }
24
+
25
+ /************************
26
+ * *
27
+ * ImportExport *
28
+ * *
29
+ ************************/
30
+
31
+ export default (apiUrl: string) => ({
32
+ /**
33
+ * Imports memories from a CSV file.
34
+ * @param {string} sessionId The session ID
35
+ * @param {ImportExportBody} csvData The CSV content info to import
36
+ */
37
+ postImportExport: async (sessionId: string, csvData: ImportExportBody) =>
38
+ apiFetcher(`/ImportExport/ImportCSV/${sessionId}`, {
39
+ method: 'POST',
40
+ apiUrl,
41
+ body: csvData,
42
+ }) as Promise<ResponseSpec & ImportExportReponse>,
43
+ });
@@ -0,0 +1,116 @@
1
+ import { ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /*******************
5
+ * *
6
+ * Intents *
7
+ * *
8
+ *******************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Lists all Intent objects.
13
+ * @param {string} sessionId The session ID
14
+ */
15
+ getIntents: async (sessionId: string) =>
16
+ apiFetcher(`/Intents/${sessionId}`, {
17
+ method: 'GET',
18
+ apiUrl,
19
+ }) as Promise<ResponseSpec>,
20
+
21
+ /**
22
+ * Gets the details of an Intent object.
23
+ * @param {string} sessionId The session ID
24
+ * @param {string} intentId The Intent object ID
25
+ */
26
+ getIntent: async (sessionId: string, intentId: string) =>
27
+ apiFetcher(`/Intent/${sessionId}/${intentId}`, {
28
+ method: 'GET',
29
+ apiUrl,
30
+ }) as Promise<ResponseSpec>,
31
+
32
+ /**
33
+ * Updates an existing Intent object.
34
+ * @param {string} sessionId The session ID
35
+ * @param {string} intentId The Intent object ID
36
+ */
37
+ patchIntent: async (sessionId: string, intentId: string) =>
38
+ apiFetcher(`/Intent/${sessionId}/${intentId}`, {
39
+ method: 'GET',
40
+ apiUrl,
41
+ }) as Promise<ResponseSpec>,
42
+
43
+ /**
44
+ * Removes an existing Intent object.
45
+ * @param {string} sessionId The session ID
46
+ * @param {string} intentId The Intent object ID
47
+ */
48
+ deleteIntent: async (sessionId: string, intentId: string) =>
49
+ apiFetcher(`/Intent/${sessionId}/${intentId}`, {
50
+ method: 'GET',
51
+ apiUrl,
52
+ }) as Promise<ResponseSpec>,
53
+
54
+ /**
55
+ * Adds a new Intent object.
56
+ * @param {string} sessionId The session ID
57
+ */
58
+ postIntent: async (sessionId: string) =>
59
+ apiFetcher(`/Intent/${sessionId}`, {
60
+ method: 'GET',
61
+ apiUrl,
62
+ }) as Promise<ResponseSpec>,
63
+
64
+ /**
65
+ * Lists all Intent Slot objects.
66
+ * @param {string} sessionId The session ID
67
+ */
68
+ getIntentSlots: async (sessionId: string) =>
69
+ apiFetcher(`/IntentSlots/${sessionId}`, {
70
+ method: 'GET',
71
+ apiUrl,
72
+ }) as Promise<ResponseSpec>,
73
+
74
+ /**
75
+ * Gets the details of an Intent Slot object.
76
+ * @param {string} sessionId The session ID
77
+ * @param {string} slotId The Intent Slot object ID
78
+ */
79
+ getIntentSlot: async (sessionId: string, slotId: string) =>
80
+ apiFetcher(`/IntentSlot/${sessionId}/${slotId}`, {
81
+ method: 'GET',
82
+ apiUrl,
83
+ }) as Promise<ResponseSpec>,
84
+
85
+ /**
86
+ * Updates an existing Intent Slot object.
87
+ * @param {string} sessionId The session ID
88
+ * @param {string} slotId The Intent Slot object ID
89
+ */
90
+ patchIntentSlot: async (sessionId: string, slotId: string) =>
91
+ apiFetcher(`/IntentSlot/${sessionId}/${slotId}`, {
92
+ method: 'GET',
93
+ apiUrl,
94
+ }) as Promise<ResponseSpec>,
95
+
96
+ /**
97
+ * Removes an existing Intent Slot object.
98
+ * @param {string} sessionId The session ID
99
+ * @param {string} slotId The Intent Slot object ID
100
+ */
101
+ deleteIntentSlot: async (sessionId: string, slotId: string) =>
102
+ apiFetcher(`/IntentSlot/${sessionId}/${slotId}`, {
103
+ method: 'GET',
104
+ apiUrl,
105
+ }) as Promise<ResponseSpec>,
106
+
107
+ /**
108
+ * Adds a new Intent Slot object.
109
+ * @param {string} sessionId The session ID
110
+ */
111
+ postIntentSlot: async (sessionId: string) =>
112
+ apiFetcher(`/IntentSlot/${sessionId}`, {
113
+ method: 'GET',
114
+ apiUrl,
115
+ }) as Promise<ResponseSpec>,
116
+ });
@@ -0,0 +1,94 @@
1
+ import {
2
+ ResponseSpec,
3
+ LocalizationKey,
4
+ LocalizationKeyContent,
5
+ } from '../types';
6
+ import { apiFetcher } from '../apiFetcher';
7
+
8
+ /****************************
9
+ * *
10
+ * LocalizationKeys *
11
+ * *
12
+ ****************************/
13
+
14
+ export default (apiUrl: string) => ({
15
+ /**
16
+ * Lists all Localizaiton Keys.
17
+ * @param {string} sessionId The session ID
18
+ */
19
+ getLocalizationKeys: async (sessionId: string) =>
20
+ apiFetcher(`/LocalizationKeys/${sessionId}`, {
21
+ method: 'GET',
22
+ apiUrl,
23
+ }) as Promise<
24
+ ResponseSpec & {
25
+ localizationKeys: LocalizationKey[];
26
+ }
27
+ >,
28
+
29
+ /**
30
+ * Get an existing Localizaiton Key.
31
+ * @param {string} sessionId The session ID
32
+ * @param {string} key The key of the Localization Key
33
+ */
34
+ getLocalizationKey: async (sessionId: string, key: string) =>
35
+ apiFetcher(`/LocalizationKey/${sessionId}/${key}`, {
36
+ method: 'GET',
37
+ apiUrl,
38
+ }) as Promise<
39
+ ResponseSpec & {
40
+ localizationKey: LocalizationKey;
41
+ }
42
+ >,
43
+
44
+ /**
45
+ * Removes an existing Localizaiton Key. This is only possible if the key is part of
46
+ * a key set, where a key set is a set of keys of a common prefix and an index,
47
+ * e.g.: <code>INPUT_QUIT_1</code>, <code>INPUT_QUIT_2</code> etc.
48
+ * Any index can be specified, the key set will be reordered appropriately.
49
+ * @param {string} sessionId The session ID
50
+ * @param {string} key The key of the Localization Key
51
+ */
52
+ deleteLocalizationKey: async (sessionId: string, key: string) =>
53
+ apiFetcher(`/LocalizationKey/${sessionId}/${key}`, {
54
+ method: 'DELETE',
55
+ apiUrl,
56
+ }) as Promise<ResponseSpec>,
57
+
58
+ /**
59
+ * Add an new Localization Key. This is only possible if the key is part of
60
+ * a key set, where a key set is a set of keys of a common prefix and an index,
61
+ * e.g.: <code>INPUT_QUIT_1</code>, <code>INPUT_QUIT_2</code> etc.
62
+ * Any index can be specified, the key set will be reordered appropriately.
63
+ * @param {string} sessionId The session ID
64
+ * @param {LocalizaitonKeyContent} localizationKey Localization Key
65
+ */
66
+ postLocalizationKey: async (
67
+ sessionId: string,
68
+ localizationKey: LocalizationKeyContent
69
+ ) =>
70
+ apiFetcher(`/LocalizationKey/${sessionId}`, {
71
+ method: 'POST',
72
+ apiUrl,
73
+ body: localizationKey,
74
+ }) as Promise<
75
+ ResponseSpec & {
76
+ localizationKey: LocalizationKey;
77
+ }
78
+ >,
79
+
80
+ /**
81
+ * Updates an existing Localization Key.
82
+ * @param {string} sessionId The session ID
83
+ * @param {LocalizationKey} localizationKey Localization Key
84
+ */
85
+ patchLocalizationKey: async (
86
+ sessionId: string,
87
+ localizationKey: LocalizationKey
88
+ ) =>
89
+ apiFetcher(`/LocalizationKey/${sessionId}`, {
90
+ method: 'PATCH',
91
+ apiUrl,
92
+ body: localizationKey,
93
+ }) as Promise<ResponseSpec>,
94
+ });
@@ -0,0 +1,79 @@
1
+ import { ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /*****************
5
+ * *
6
+ * Media *
7
+ * *
8
+ *****************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Lists all Medium objects of a Memory.
13
+ * @param {string} sessionId The session ID
14
+ * @param {string} memoryId The Memory object ID
15
+ */
16
+ getMedia: async (sessionId: string, memoryId: string) =>
17
+ apiFetcher(`/Media/${sessionId}/${memoryId}`, {
18
+ method: 'GET',
19
+ apiUrl,
20
+ }) as Promise<ResponseSpec>,
21
+
22
+ /**
23
+ * Removes all Medium objects from a Memory.
24
+ * @param {string} sessionId The session ID
25
+ * @param {string} memoryId The Memory object ID
26
+ */
27
+ deleteMedia: async (sessionId: string, memoryId: string) =>
28
+ apiFetcher(`/Media/${sessionId}/${memoryId}`, {
29
+ method: 'DELETE',
30
+ apiUrl,
31
+ }) as Promise<ResponseSpec>,
32
+
33
+ /**
34
+ * Gets the details of a Medium object of a Memory.
35
+ * @param {string} sessionId The session ID
36
+ * @param {string} memoryId The Memory object ID
37
+ * @param {string} mediumId The Medium object ID
38
+ */
39
+ getMedium: async (sessionId: string, memoryId: string, mediumId: string) =>
40
+ apiFetcher(`/Medium/${sessionId}/${memoryId}/${mediumId}`, {
41
+ method: 'GET',
42
+ apiUrl,
43
+ }) as Promise<ResponseSpec>,
44
+
45
+ /**
46
+ * Updates an existing Medium object of a Memory.
47
+ * @param {string} sessionId The session ID
48
+ * @param {string} memoryId The Memory object ID
49
+ * @param {string} mediumId The Medium object ID
50
+ */
51
+ patchMedium: async (sessionId: string, memoryId: string, mediumId: string) =>
52
+ apiFetcher(`/Medium/${sessionId}/${memoryId}/${mediumId}`, {
53
+ method: 'GET',
54
+ apiUrl,
55
+ }) as Promise<ResponseSpec>,
56
+
57
+ /**
58
+ * Removes an existing Medium object from a Memory.
59
+ * @param {string} sessionId The session ID
60
+ * @param {string} memoryId The Memory object ID
61
+ * @param {string} mediumId The Medium object ID
62
+ */
63
+ deleteMedium: (sessionId: string, memoryId: string, mediumId: string) =>
64
+ apiFetcher(`/Medium/${sessionId}/${memoryId}/${mediumId}`, {
65
+ method: 'GET',
66
+ apiUrl,
67
+ }) as Promise<ResponseSpec>,
68
+
69
+ /**
70
+ * Adds a new Medium object to a Memory.
71
+ * @param {string} sessionId The session ID
72
+ * @param {string} memoryId The Memory object ID
73
+ */
74
+ postMedium: async (sessionId: string, memoryId: string) =>
75
+ apiFetcher(`/Medium/${sessionId}/${memoryId}`, {
76
+ method: 'GET',
77
+ apiUrl,
78
+ }) as Promise<ResponseSpec>,
79
+ });
@@ -0,0 +1,51 @@
1
+ import { ResponseSpec, Memori } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /******************
5
+ * *
6
+ * Memori *
7
+ * *
8
+ ******************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Registration of a new Memori object.
13
+ * @param {Memori} memori - The Memori object
14
+ */
15
+ postMemori: async (memori: Partial<Omit<Memori, 'memoriID'>>) =>
16
+ apiFetcher(`/Memori`, {
17
+ method: 'POST',
18
+ apiUrl,
19
+ body: memori,
20
+ }) as Promise<ResponseSpec>,
21
+
22
+ /**
23
+ * Updates an existing Memori object.
24
+ * @param {Memori} memori - The Memori object
25
+ */
26
+ patchMemori: async (memori: Partial<Memori> & { memoriID: string }) =>
27
+ apiFetcher(`/Memori/${memori.memoriID}`, {
28
+ method: 'PATCH',
29
+ apiUrl,
30
+ body: memori,
31
+ }) as Promise<ResponseSpec>,
32
+
33
+ /**
34
+ * Deletes an existing Memori object.
35
+ * @param {string} memoriId The Memori object ID
36
+ */
37
+ deleteMemori: async (memoriId: string) =>
38
+ apiFetcher(`/Memori/${memoriId}`, {
39
+ method: 'DELETE',
40
+ apiUrl,
41
+ }) as Promise<ResponseSpec>,
42
+
43
+ /**
44
+ * Lists Memori objects, with optional filtering.
45
+ */
46
+ postSearchMemori: async () =>
47
+ apiFetcher(`/SearchMemori`, {
48
+ method: 'GET',
49
+ apiUrl,
50
+ }) as Promise<ResponseSpec>,
51
+ });
@@ -0,0 +1,89 @@
1
+ import { Memory, ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /********************
5
+ * *
6
+ * Memories *
7
+ * *
8
+ ********************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Lists all Memory objects.
13
+ * @param {string} sessionId The session ID
14
+ */
15
+ getMemories: async (sessionId: string) =>
16
+ apiFetcher(`/Memories/${sessionId}`, {
17
+ method: 'GET',
18
+ apiUrl,
19
+ }) as Promise<
20
+ ResponseSpec & {
21
+ memories: Memory[];
22
+ }
23
+ >,
24
+
25
+ /**
26
+ * Gets the details of a Memory object.
27
+ * @param {string} sessionId The session ID
28
+ * @param {string} memoryId The Memory object ID
29
+ */
30
+ getMemory: async (sessionId: string, memoryId: string) =>
31
+ apiFetcher(`/Memory/${sessionId}/${memoryId}`, {
32
+ method: 'GET',
33
+ apiUrl,
34
+ }) as Promise<
35
+ ResponseSpec & {
36
+ memory: Memory;
37
+ }
38
+ >,
39
+
40
+ /**
41
+ * Updates an existing Memory object.
42
+ * @param {string} sessionId The session ID
43
+ * @param {Memory} memory The Memory object
44
+ */
45
+ patchMemory: async (sessionId: string, memory: Memory) =>
46
+ apiFetcher(`/Memory/${sessionId}/${memory.memoryID}`, {
47
+ method: 'PATCH',
48
+ apiUrl,
49
+ body: memory,
50
+ }) as Promise<ResponseSpec>,
51
+
52
+ /**
53
+ * Removes an existing Memory object.
54
+ * @param {string} sessionId The session ID
55
+ * @param {string} memoryId The Memory object ID
56
+ */
57
+ deleteMemory: async (sessionId: string, memoryId: string) =>
58
+ apiFetcher(`/Memory/${sessionId}/${memoryId}`, {
59
+ method: 'DELETE',
60
+ apiUrl,
61
+ }) as Promise<ResponseSpec>,
62
+
63
+ /**
64
+ * Adds a new Memory object.
65
+ * @param {string} sessionId The session ID
66
+ * @param {Memory} memory The Memory object
67
+ */
68
+ postMemory: async (sessionId: string, memory: Memory) =>
69
+ apiFetcher(`/Memory/${sessionId}`, {
70
+ method: 'POST',
71
+ apiUrl,
72
+ body: memory,
73
+ }) as Promise<
74
+ ResponseSpec & {
75
+ memoryID: string;
76
+ }
77
+ >,
78
+
79
+ /**
80
+ * Checks if a Memory object is accessible from the specified session.
81
+ * @param {string} sessionId The session ID
82
+ * @param {string} memoryId The Memory object ID
83
+ */
84
+ getMemoryAccess: async (sessionId: string, memoryId: string) =>
85
+ apiFetcher(`/MemoryAccess/${sessionId}/${memoryId}`, {
86
+ method: 'GET',
87
+ apiUrl,
88
+ }) as Promise<ResponseSpec>,
89
+ });
@@ -0,0 +1,39 @@
1
+ import { ResponseSpec } from '../types';
2
+ import { apiFetcher } from '../apiFetcher';
3
+
4
+ /***************
5
+ * *
6
+ * NLP *
7
+ * *
8
+ ***************/
9
+
10
+ export default (apiUrl: string) => ({
11
+ /**
12
+ * Looks up the vector definition for a word.
13
+ * @param {string} sessionId The session ID
14
+ * @param {string} word Word to be looked up
15
+ */
16
+ getWordVector: async (sessionId: string, word: string) =>
17
+ apiFetcher(`/WordVector/${sessionId}/${word}`, {
18
+ method: 'GET',
19
+ apiUrl,
20
+ }) as Promise<ResponseSpec>,
21
+
22
+ /**
23
+ * Tries to guess the language of a sentence by analyzing key word occurrences.
24
+ * @param {string} sessionId The session ID
25
+ * @param {string} text Text to be used for guessing the language.
26
+ */
27
+ guessLanguage: async (sessionId: string, text: string) =>
28
+ apiFetcher(`/GuessLanguage/${sessionId}`, {
29
+ method: 'POST',
30
+ apiUrl,
31
+ body: { text },
32
+ }) as Promise<
33
+ ResponseSpec & {
34
+ languageGuesses: {
35
+ [lang: string]: number;
36
+ };
37
+ }
38
+ >,
39
+ });