@memori.ai/memori-api-client 0.1.1 → 0.2.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/README.md CHANGED
@@ -20,7 +20,7 @@ npm install @memori.ai/memori-api-client
20
20
 
21
21
  Every method has JSDoc annotations with usage and description and typings information.
22
22
 
23
- See an example [here](https://github.com/memori-ai/examples/blob/main/ts-sdk/index.ts).
23
+ See examples for [Node (TypeScript)](https://github.com/memori-ai/examples/blob/main/ts-sdk/index.ts) and [React](https://github.com/memori-ai/examples/blob/main/react-ts-with-api-client/src/App.tsx).
24
24
 
25
25
  ```ts
26
26
  import memoriApiClient from '@memori.ai/memori-api-client';
@@ -52,8 +52,25 @@ memori.constants.allowedMediaTypes; // list of allowed media types in asset uplo
52
52
  memori.constants.anonTag; // tag for anonymous users
53
53
  ```
54
54
 
55
+ ### Asset
56
+
57
+ There is a helper method parsing media urls from the DB, handling different cases
58
+
59
+ ```ts
60
+ const memori = memoriApiClient('https://backend.memori.ai');
61
+
62
+ memori.asset.getResourceUrl({
63
+ type: 'avatar',
64
+ resourceURI: '768b9654-e781-4c3c-81fa-ae1529d1bfbe.png',
65
+ mediaType: 'image/png',
66
+ sessionId: 'be2e4a44-890b-483b-a26a-f6e122f36e2b',
67
+ });
68
+ ```
69
+
55
70
  ### TTS
56
71
 
72
+ > Experimental
73
+
57
74
  Bundled with this client there is a TTS utility that can be used to synthesize text to speech.
58
75
 
59
76
  ```ts
@@ -79,6 +96,8 @@ speech.stopSpeaking();
79
96
 
80
97
  ### STT
81
98
 
99
+ > Experimental
100
+
82
101
  There is also a speech recognition utility.
83
102
 
84
103
  ```ts
@@ -94,21 +113,6 @@ speech.isRecognizing();
94
113
  speech.stopRecognizing();
95
114
  ```
96
115
 
97
- ### Asset
98
-
99
- There is a helper method parsing media urls from the DB, handling different cases
100
-
101
- ```ts
102
- const memori = memoriApiClient('https://backend.memori.ai');
103
-
104
- memori.asset.getResourceUrl({
105
- type: 'avatar',
106
- resourceURI: '768b9654-e781-4c3c-81fa-ae1529d1bfbe.png',
107
- mediaType: 'image/png',
108
- sessionId: 'be2e4a44-890b-483b-a26a-f6e122f36e2b',
109
- });
110
- ```
111
-
112
116
  ## Development
113
117
 
114
118
  To run TSDX, use:
@@ -71,7 +71,9 @@ declare const _default: (apiUrl: string) => {
71
71
  * @param memori - The Memori object
72
72
  * @returns The created Memori object
73
73
  */
74
- updateMemori: (authToken: string, memori: Memori) => Promise<ResponseSpec & {
74
+ updateMemori: (authToken: string, memori: Partial<Memori> & {
75
+ memoriID: string;
76
+ }) => Promise<ResponseSpec & {
75
77
  memori: Memori;
76
78
  }>;
77
79
  /**
package/dist/backend.d.ts CHANGED
@@ -103,7 +103,9 @@ declare const backendAPI: (apiUrl: string) => {
103
103
  createMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
104
104
  memori: import("./types").Memori;
105
105
  }>;
106
- updateMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
106
+ updateMemori: (authToken: string, memori: Partial<import("./types").Memori> & {
107
+ memoriID: string;
108
+ }) => Promise<import("./types").ResponseSpec & {
107
109
  memori: import("./types").Memori;
108
110
  }>;
109
111
  deleteMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec>;
@@ -165,7 +167,9 @@ declare const backendAPI: (apiUrl: string) => {
165
167
  createMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
166
168
  memori: import("./types").Memori;
167
169
  }>;
168
- updateMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
170
+ updateMemori: (authToken: string, memori: Partial<import("./types").Memori> & {
171
+ memoriID: string;
172
+ }) => Promise<import("./types").ResponseSpec & {
169
173
  memori: import("./types").Memori;
170
174
  }>;
171
175
  deleteMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec>;
@@ -0,0 +1,32 @@
1
+ import { ResponseSpec } from '../types';
2
+ declare const _default: (apiUrl: string) => {
3
+ /**
4
+ * Gets a list of currently known context variables.
5
+ * @param {string} sessionId The session ID
6
+ */
7
+ getContextVars: (sessionId: string) => Promise<ResponseSpec & {
8
+ [variable: string]: string[];
9
+ }>;
10
+ /**
11
+ * Gets a list of currently known context variable names.
12
+ * @param {string} sessionId The session ID
13
+ */
14
+ getContextVarNames: (sessionId: string) => Promise<ResponseSpec & {
15
+ contextVarNames: string[];
16
+ }>;
17
+ /**
18
+ * /memori/v2/ContextVarValues/{strSessionID}/{contextVarName}
19
+ * @param {string} sessionId The session ID
20
+ * @param {string} contextVarName The name of the context variable
21
+ */
22
+ getContextVarValues: (sessionId: string, contextVarName: string) => Promise<ResponseSpec & {
23
+ contextVarName: string;
24
+ contextVarValues: string[];
25
+ }>;
26
+ };
27
+ /****************************
28
+ * *
29
+ * ContextVars *
30
+ * *
31
+ ****************************/
32
+ export default _default;
package/dist/engine.d.ts CHANGED
@@ -1,4 +1,26 @@
1
1
  declare const _default: (apiUrl: string) => {
2
+ getContextVars: (sessionId: string) => Promise<import("./types").ResponseSpec & {
3
+ [variable: string]: string[];
4
+ }>;
5
+ getContextVarNames: (sessionId: string) => Promise<import("./types").ResponseSpec & {
6
+ contextVarNames: string[];
7
+ }>;
8
+ getContextVarValues: (sessionId: string, contextVarName: string) => Promise<import("./types").ResponseSpec & {
9
+ contextVarName: string;
10
+ contextVarValues: string[];
11
+ }>;
12
+ contextVars: {
13
+ getContextVars: (sessionId: string) => Promise<import("./types").ResponseSpec & {
14
+ [variable: string]: string[];
15
+ }>;
16
+ getContextVarNames: (sessionId: string) => Promise<import("./types").ResponseSpec & {
17
+ contextVarNames: string[];
18
+ }>;
19
+ getContextVarValues: (sessionId: string, contextVarName: string) => Promise<import("./types").ResponseSpec & {
20
+ contextVarName: string;
21
+ contextVarValues: string[];
22
+ }>;
23
+ };
2
24
  getUnansweredQuestions: (sessionId: string) => Promise<import("./types").ResponseSpec & {
3
25
  unansweredQuestions: import("./types").UnansweredQuestion[];
4
26
  }>;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,28 @@ declare const api: (hostname?: string | undefined) => {
12
12
  asset: {
13
13
  getResourceUrl: ({ type, resourceURI, sessionID, baseURL, }: import("./helpers/asset").ResourceURLParams) => string;
14
14
  };
15
+ getContextVars: (sessionId: string) => Promise<import("./types").ResponseSpec & {
16
+ [variable: string]: string[];
17
+ }>;
18
+ getContextVarNames: (sessionId: string) => Promise<import("./types").ResponseSpec & {
19
+ contextVarNames: string[];
20
+ }>;
21
+ getContextVarValues: (sessionId: string, contextVarName: string) => Promise<import("./types").ResponseSpec & {
22
+ contextVarName: string;
23
+ contextVarValues: string[];
24
+ }>;
25
+ contextVars: {
26
+ getContextVars: (sessionId: string) => Promise<import("./types").ResponseSpec & {
27
+ [variable: string]: string[];
28
+ }>;
29
+ getContextVarNames: (sessionId: string) => Promise<import("./types").ResponseSpec & {
30
+ contextVarNames: string[];
31
+ }>;
32
+ getContextVarValues: (sessionId: string, contextVarName: string) => Promise<import("./types").ResponseSpec & {
33
+ contextVarName: string;
34
+ contextVarValues: string[];
35
+ }>;
36
+ };
15
37
  getUnansweredQuestions: (sessionId: string) => Promise<import("./types").ResponseSpec & {
16
38
  unansweredQuestions: import("./types").UnansweredQuestion[];
17
39
  }>;
@@ -391,7 +413,9 @@ declare const api: (hostname?: string | undefined) => {
391
413
  createMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
392
414
  memori: import("./types").Memori;
393
415
  }>;
394
- updateMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
416
+ updateMemori: (authToken: string, memori: Partial<import("./types").Memori> & {
417
+ memoriID: string;
418
+ }) => Promise<import("./types").ResponseSpec & {
395
419
  memori: import("./types").Memori;
396
420
  }>;
397
421
  deleteMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec>;
@@ -453,7 +477,9 @@ declare const api: (hostname?: string | undefined) => {
453
477
  createMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
454
478
  memori: import("./types").Memori;
455
479
  }>;
456
- updateMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec & {
480
+ updateMemori: (authToken: string, memori: Partial<import("./types").Memori> & {
481
+ memoriID: string;
482
+ }) => Promise<import("./types").ResponseSpec & {
457
483
  memori: import("./types").Memori;
458
484
  }>;
459
485
  deleteMemori: (authToken: string, memori: import("./types").Memori) => Promise<import("./types").ResponseSpec>;
@@ -3132,6 +3132,107 @@ var unansweredQuestions = (function (apiUrl) {
3132
3132
  };
3133
3133
  });
3134
3134
 
3135
+ /****************************
3136
+ * *
3137
+ * ContextVars *
3138
+ * *
3139
+ ****************************/
3140
+
3141
+ var contextVars = (function (apiUrl) {
3142
+ return {
3143
+ /**
3144
+ * Gets a list of currently known context variables.
3145
+ * @param {string} sessionId The session ID
3146
+ */
3147
+ getContextVars: function () {
3148
+ var _getContextVars = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
3149
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3150
+ while (1) {
3151
+ switch (_context.prev = _context.next) {
3152
+ case 0:
3153
+ return _context.abrupt("return", apiFetcher("/ContextVars/" + sessionId, {
3154
+ method: 'GET',
3155
+ apiUrl: apiUrl
3156
+ }));
3157
+
3158
+ case 1:
3159
+ case "end":
3160
+ return _context.stop();
3161
+ }
3162
+ }
3163
+ }, _callee);
3164
+ }));
3165
+
3166
+ function getContextVars(_x) {
3167
+ return _getContextVars.apply(this, arguments);
3168
+ }
3169
+
3170
+ return getContextVars;
3171
+ }(),
3172
+
3173
+ /**
3174
+ * Gets a list of currently known context variable names.
3175
+ * @param {string} sessionId The session ID
3176
+ */
3177
+ getContextVarNames: function () {
3178
+ var _getContextVarNames = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId) {
3179
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3180
+ while (1) {
3181
+ switch (_context2.prev = _context2.next) {
3182
+ case 0:
3183
+ return _context2.abrupt("return", apiFetcher("/ContextVarNames/" + sessionId, {
3184
+ method: 'GET',
3185
+ apiUrl: apiUrl
3186
+ }));
3187
+
3188
+ case 1:
3189
+ case "end":
3190
+ return _context2.stop();
3191
+ }
3192
+ }
3193
+ }, _callee2);
3194
+ }));
3195
+
3196
+ function getContextVarNames(_x2) {
3197
+ return _getContextVarNames.apply(this, arguments);
3198
+ }
3199
+
3200
+ return getContextVarNames;
3201
+ }(),
3202
+
3203
+ /**
3204
+ * /memori/v2/ContextVarValues/{strSessionID}/{contextVarName}
3205
+ * @param {string} sessionId The session ID
3206
+ * @param {string} contextVarName The name of the context variable
3207
+ */
3208
+ getContextVarValues: function () {
3209
+ var _getContextVarValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, contextVarName) {
3210
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3211
+ while (1) {
3212
+ switch (_context3.prev = _context3.next) {
3213
+ case 0:
3214
+ return _context3.abrupt("return", apiFetcher("/ContextVarValues/" + sessionId + "/" + contextVarName, {
3215
+ method: 'GET',
3216
+ apiUrl: apiUrl
3217
+ }));
3218
+
3219
+ case 1:
3220
+ case "end":
3221
+ return _context3.stop();
3222
+ }
3223
+ }
3224
+ }, _callee3);
3225
+ }));
3226
+
3227
+ function getContextVarValues(_x3, _x4) {
3228
+ return _getContextVarValues.apply(this, arguments);
3229
+ }
3230
+
3231
+ return getContextVarValues;
3232
+ }()
3233
+ };
3234
+ });
3235
+
3135
3236
  var engine = (function (apiUrl) {
3136
3237
  return _extends({
3137
3238
  correlationPairs: correlationPairs(apiUrl)
@@ -3161,7 +3262,9 @@ var engine = (function (apiUrl) {
3161
3262
  stats: stats(apiUrl)
3162
3263
  }, stats(apiUrl), {
3163
3264
  unansweredQuestions: unansweredQuestions(apiUrl)
3164
- }, unansweredQuestions(apiUrl));
3265
+ }, unansweredQuestions(apiUrl), {
3266
+ contextVars: contextVars(apiUrl)
3267
+ }, contextVars(apiUrl));
3165
3268
  });
3166
3269
 
3167
3270
  var allowedMediaTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'text/plain', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/pdf', 'video/mp4', 'video/avi', 'audio/mpeg3', 'audio/wav', 'audio/mpeg', 'video/mpeg', 'model/gltf-binary'];
@@ -3246,6 +3349,10 @@ var getCultureCodeByLanguage = function getCultureCodeByLanguage(lang) {
3246
3349
 
3247
3350
  return voice;
3248
3351
  };
3352
+ /**
3353
+ * EXPERIMENTAL
3354
+ */
3355
+
3249
3356
 
3250
3357
  var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
3251
3358
  if (DEBUG === void 0) {
@@ -3253,7 +3360,6 @@ var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
3253
3360
  }
3254
3361
 
3255
3362
  return function (lang, voiceType) {
3256
- speechSdk.Recognizer.enableTelemetry(false);
3257
3363
  var speechConfig = speechSdk.SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'eastus');
3258
3364
  var speechSynthesizer;
3259
3365
  var audioDestination;