@memori.ai/memori-api-client 0.1.0 → 0.2.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.
@@ -1,5 +1,5 @@
1
1
  import fetch$1 from 'cross-fetch';
2
- import { Recognizer, SpeechConfig, SpeakerAudioDestination, AudioConfig, SpeechSynthesizer, SpeechRecognizer, ResultReason, CancellationReason } from 'microsoft-cognitiveservices-speech-sdk';
2
+ import { SpeechConfig, SpeakerAudioDestination, AudioConfig, SpeechSynthesizer, SpeechRecognizer, ResultReason, CancellationReason } from 'microsoft-cognitiveservices-speech-sdk';
3
3
 
4
4
  function _regeneratorRuntime() {
5
5
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -403,7 +403,7 @@ var getApiUrl = function getApiUrl(hostname) {
403
403
  return hostname ? new URL(hostname.startsWith('http') ? hostname : "https://" + hostname).origin.replace('http://', 'https://') : 'https://backend.memori.ai';
404
404
  };
405
405
 
406
- var fetcher = function fetcher(path, opts) {
406
+ var apiFetcher = function apiFetcher(path, opts) {
407
407
  return fetch$1("" + opts.apiUrl + path, _extends({}, opts, {
408
408
  body: opts != null && opts.body ? JSON.stringify(opts.body) : undefined,
409
409
  mode: 'cors',
@@ -416,10 +416,6 @@ var fetcher = function fetcher(path, opts) {
416
416
  return res.json();
417
417
  });
418
418
  };
419
- var devFetcher = function devFetcher(data) {
420
- return Promise.resolve(data);
421
- };
422
- var apiFetcher = process.env.CI === 'true' || process.env.NODE_ENV === 'test' ? devFetcher : fetcher;
423
419
 
424
420
  var memori = (function (apiUrl) {
425
421
  return {
@@ -2181,137 +2177,6 @@ var media = (function (apiUrl) {
2181
2177
  };
2182
2178
  });
2183
2179
 
2184
- /******************
2185
- * *
2186
- * Memori *
2187
- * *
2188
- ******************/
2189
-
2190
- var memori$1 = (function (apiUrl) {
2191
- return {
2192
- /**
2193
- * Registration of a new Memori object.
2194
- * @param {Memori} memori - The Memori object
2195
- */
2196
- postMemori: function () {
2197
- var _postMemori = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(memori) {
2198
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2199
- while (1) {
2200
- switch (_context.prev = _context.next) {
2201
- case 0:
2202
- return _context.abrupt("return", apiFetcher("/Memori", {
2203
- method: 'POST',
2204
- apiUrl: apiUrl,
2205
- body: memori
2206
- }));
2207
-
2208
- case 1:
2209
- case "end":
2210
- return _context.stop();
2211
- }
2212
- }
2213
- }, _callee);
2214
- }));
2215
-
2216
- function postMemori(_x) {
2217
- return _postMemori.apply(this, arguments);
2218
- }
2219
-
2220
- return postMemori;
2221
- }(),
2222
-
2223
- /**
2224
- * Updates an existing Memori object.
2225
- * @param {Memori} memori - The Memori object
2226
- */
2227
- patchMemori: function () {
2228
- var _patchMemori = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(memori) {
2229
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2230
- while (1) {
2231
- switch (_context2.prev = _context2.next) {
2232
- case 0:
2233
- return _context2.abrupt("return", apiFetcher("/Memori/" + memori.memoriID, {
2234
- method: 'PATCH',
2235
- apiUrl: apiUrl,
2236
- body: memori
2237
- }));
2238
-
2239
- case 1:
2240
- case "end":
2241
- return _context2.stop();
2242
- }
2243
- }
2244
- }, _callee2);
2245
- }));
2246
-
2247
- function patchMemori(_x2) {
2248
- return _patchMemori.apply(this, arguments);
2249
- }
2250
-
2251
- return patchMemori;
2252
- }(),
2253
-
2254
- /**
2255
- * Deletes an existing Memori object.
2256
- * @param {string} memoriId The Memori object ID
2257
- */
2258
- deleteMemori: function () {
2259
- var _deleteMemori = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(memoriId) {
2260
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2261
- while (1) {
2262
- switch (_context3.prev = _context3.next) {
2263
- case 0:
2264
- return _context3.abrupt("return", apiFetcher("/Memori/" + memoriId, {
2265
- method: 'DELETE',
2266
- apiUrl: apiUrl
2267
- }));
2268
-
2269
- case 1:
2270
- case "end":
2271
- return _context3.stop();
2272
- }
2273
- }
2274
- }, _callee3);
2275
- }));
2276
-
2277
- function deleteMemori(_x3) {
2278
- return _deleteMemori.apply(this, arguments);
2279
- }
2280
-
2281
- return deleteMemori;
2282
- }(),
2283
-
2284
- /**
2285
- * Lists Memori objects, with optional filtering.
2286
- */
2287
- postSearchMemori: function () {
2288
- var _postSearchMemori = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
2289
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2290
- while (1) {
2291
- switch (_context4.prev = _context4.next) {
2292
- case 0:
2293
- return _context4.abrupt("return", apiFetcher("/SearchMemori", {
2294
- method: 'GET',
2295
- apiUrl: apiUrl
2296
- }));
2297
-
2298
- case 1:
2299
- case "end":
2300
- return _context4.stop();
2301
- }
2302
- }
2303
- }, _callee4);
2304
- }));
2305
-
2306
- function postSearchMemori() {
2307
- return _postSearchMemori.apply(this, arguments);
2308
- }
2309
-
2310
- return postSearchMemori;
2311
- }()
2312
- };
2313
- });
2314
-
2315
2180
  /********************
2316
2181
  * *
2317
2182
  * Memories *
@@ -3261,24 +3126,25 @@ var unansweredQuestions = (function (apiUrl) {
3261
3126
  };
3262
3127
  });
3263
3128
 
3264
- /********************
3265
- * *
3266
- * WebHooks *
3267
- * *
3268
- ********************/
3129
+ /****************************
3130
+ * *
3131
+ * ContextVars *
3132
+ * *
3133
+ ****************************/
3269
3134
 
3270
- var webhooks = (function (apiUrl) {
3135
+ var contextVars = (function (apiUrl) {
3271
3136
  return {
3272
3137
  /**
3273
- * Returns test slot values. Currently available test slots are:<ul><li><code>number</code>: integer numbers between 1 and 10</li><li><code>letter</code>: uppercase letters between A and Z</li><li><code>greek_letter</code>: capitalized Greek letters between Alpha and Omega</li></ul>
3138
+ * Gets a list of currently known context variables.
3139
+ * @param {string} sessionId The session ID
3274
3140
  */
3275
- postTestSlot: function () {
3276
- var _postTestSlot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3141
+ getContextVars: function () {
3142
+ var _getContextVars = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
3277
3143
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3278
3144
  while (1) {
3279
3145
  switch (_context.prev = _context.next) {
3280
3146
  case 0:
3281
- return _context.abrupt("return", apiFetcher("/TestSlot", {
3147
+ return _context.abrupt("return", apiFetcher("/ContextVars/" + sessionId, {
3282
3148
  method: 'GET',
3283
3149
  apiUrl: apiUrl
3284
3150
  }));
@@ -3291,27 +3157,24 @@ var webhooks = (function (apiUrl) {
3291
3157
  }, _callee);
3292
3158
  }));
3293
3159
 
3294
- function postTestSlot() {
3295
- return _postTestSlot.apply(this, arguments);
3160
+ function getContextVars(_x) {
3161
+ return _getContextVars.apply(this, arguments);
3296
3162
  }
3297
3163
 
3298
- return postTestSlot;
3164
+ return getContextVars;
3299
3165
  }(),
3300
3166
 
3301
3167
  /**
3302
- * Returns test intent results. Currently available test intents are:<ul><li><code>ECHO</code>: emits the intent utterance as-is.</li><li><code>COMBINE_LETTER_AND_NUMBER</code>: requires a letter slot and a number slot,
3303
- emits the content of the two slots in justaxposition, e.g. "A10".</li><li><code>DATE_RANGE</code>: requires a date slot, emits the date range indicated
3304
- by the date slot in the format "yyyy/MM/dd - yyyy/MM/dd".</li><li><code>AUTOINCREMENT</code>: returns a progressive number that increments by 1
3305
- each time the intent is called.</li><li><code>FIBONACCI</code>: returns the next element of the Fibonacci series, using
3306
- context variables to store the series progression.</li></ul>
3307
- */
3308
- postTestIntent: function () {
3309
- var _postTestIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3168
+ * Gets a list of currently known context variable names.
3169
+ * @param {string} sessionId The session ID
3170
+ */
3171
+ getContextVarNames: function () {
3172
+ var _getContextVarNames = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId) {
3310
3173
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3311
3174
  while (1) {
3312
3175
  switch (_context2.prev = _context2.next) {
3313
3176
  case 0:
3314
- return _context2.abrupt("return", apiFetcher("/TestIntent", {
3177
+ return _context2.abrupt("return", apiFetcher("/ContextVarNames/" + sessionId, {
3315
3178
  method: 'GET',
3316
3179
  apiUrl: apiUrl
3317
3180
  }));
@@ -3324,11 +3187,42 @@ var webhooks = (function (apiUrl) {
3324
3187
  }, _callee2);
3325
3188
  }));
3326
3189
 
3327
- function postTestIntent() {
3328
- return _postTestIntent.apply(this, arguments);
3190
+ function getContextVarNames(_x2) {
3191
+ return _getContextVarNames.apply(this, arguments);
3329
3192
  }
3330
3193
 
3331
- return postTestIntent;
3194
+ return getContextVarNames;
3195
+ }(),
3196
+
3197
+ /**
3198
+ * /memori/v2/ContextVarValues/{strSessionID}/{contextVarName}
3199
+ * @param {string} sessionId The session ID
3200
+ * @param {string} contextVarName The name of the context variable
3201
+ */
3202
+ getContextVarValues: function () {
3203
+ var _getContextVarValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, contextVarName) {
3204
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3205
+ while (1) {
3206
+ switch (_context3.prev = _context3.next) {
3207
+ case 0:
3208
+ return _context3.abrupt("return", apiFetcher("/ContextVarValues/" + sessionId + "/" + contextVarName, {
3209
+ method: 'GET',
3210
+ apiUrl: apiUrl
3211
+ }));
3212
+
3213
+ case 1:
3214
+ case "end":
3215
+ return _context3.stop();
3216
+ }
3217
+ }
3218
+ }, _callee3);
3219
+ }));
3220
+
3221
+ function getContextVarValues(_x3, _x4) {
3222
+ return _getContextVarValues.apply(this, arguments);
3223
+ }
3224
+
3225
+ return getContextVarValues;
3332
3226
  }()
3333
3227
  };
3334
3228
  });
@@ -3347,8 +3241,6 @@ var engine = (function (apiUrl) {
3347
3241
  }, localizationKeys(apiUrl), {
3348
3242
  media: media(apiUrl)
3349
3243
  }, media(apiUrl), {
3350
- memori: memori$1(apiUrl)
3351
- }, memori$1(apiUrl), {
3352
3244
  memories: memories(apiUrl)
3353
3245
  }, memories(apiUrl), {
3354
3246
  nlp: nlp(apiUrl)
@@ -3365,8 +3257,8 @@ var engine = (function (apiUrl) {
3365
3257
  }, stats(apiUrl), {
3366
3258
  unansweredQuestions: unansweredQuestions(apiUrl)
3367
3259
  }, unansweredQuestions(apiUrl), {
3368
- webhooks: webhooks(apiUrl)
3369
- }, webhooks(apiUrl));
3260
+ contextVars: contextVars(apiUrl)
3261
+ }, contextVars(apiUrl));
3370
3262
  });
3371
3263
 
3372
3264
  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'];
@@ -3451,6 +3343,10 @@ var getCultureCodeByLanguage = function getCultureCodeByLanguage(lang) {
3451
3343
 
3452
3344
  return voice;
3453
3345
  };
3346
+ /**
3347
+ * EXPERIMENTAL
3348
+ */
3349
+
3454
3350
 
3455
3351
  var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
3456
3352
  if (DEBUG === void 0) {
@@ -3458,7 +3354,6 @@ var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
3458
3354
  }
3459
3355
 
3460
3356
  return function (lang, voiceType) {
3461
- Recognizer.enableTelemetry(false);
3462
3357
  var speechConfig = SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'eastus');
3463
3358
  var speechSynthesizer;
3464
3359
  var audioDestination;