@qikdev/sdk 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qikdev/sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "Promise based Javascript SDK",
6
6
  "main": "./dist/main.js",
@@ -11,7 +11,7 @@
11
11
  "test": "mocha --colors ./test/*.spec.js",
12
12
  "test:watch": "mocha --colors -w ./test/*.spec.js",
13
13
  "test:auth": "yarn build && node test/server.js",
14
- "document": "jsdoc -r . -d public -c jsdoc.conf README.md"
14
+ "document": "jsdoc -d public -c jsdoc.conf README.md"
15
15
  },
16
16
  "exports": {
17
17
  ".": {
@@ -273,6 +273,34 @@ var QikAPI = function (qik) {
273
273
  //Ignore let QikAuth handle it
274
274
  break;
275
275
 
276
+ case 429: {
277
+ // Rate-limited by the server's fairness/concurrency limiter. It
278
+ // sends Retry-After (seconds); honour it — with jitter so a burst
279
+ // of 429s doesn't retry in lockstep and re-trip the limit — and
280
+ // retry a few times rather than surfacing the error. Retry state
281
+ // lives on the request config, NOT the shared retryCount above,
282
+ // because 429s arrive in concurrent bursts that would corrupt a
283
+ // single shared counter.
284
+ var config429 = err.config || {};
285
+ config429.__retry429 = (config429.__retry429 || 0) + 1;
286
+ if (config429.__retry429 <= 3) {
287
+ var retryAfterHeader = parseInt(
288
+ err?.response?.headers?.["retry-after"],
289
+ 10,
290
+ );
291
+ var backoffMs = Number.isFinite(retryAfterHeader)
292
+ ? retryAfterHeader * 1000
293
+ : 800 * config429.__retry429;
294
+ var jitterMs = Math.floor(Math.random() * 500);
295
+ return new Promise(function (resolve, reject) {
296
+ setTimeout(function () {
297
+ return instance.request(config429).then(resolve, reject);
298
+ }, backoffMs + jitterMs);
299
+ });
300
+ }
301
+ break;
302
+ }
303
+
276
304
  case 502:
277
305
  case 504:
278
306
  if (retryCount < 5) {
@@ -325,7 +325,7 @@ service.activeFilterKeys = function(filterConfiguration, options) {
325
325
  /**
326
326
  *
327
327
  * @description Returns an array of all comparators that are being actively filtered
328
- * @alias filter.activeFilterKeys
328
+ * @alias filter.activeFilterComparators
329
329
  * @param {Object} filterConfiguration A filter configuration object
330
330
  * @example
331
331
  *
@@ -85,7 +85,7 @@ export default function(qik) {
85
85
  /**
86
86
  *
87
87
  * Start watching the user's geolocation
88
- * @alias geo.stopWatchPosition
88
+ * @alias geo.watchPosition
89
89
  * @param {Function} callback A function that will be called with updated position data
90
90
  * @example
91
91
  * const result = await sdk.geo.watchPosition(callback)
@@ -4,6 +4,12 @@ import { isBrowser, isNode } from "browser-or-node";
4
4
 
5
5
  ///////////////////////////////////////////////////////////////////////////////
6
6
 
7
+ /**
8
+ * @name utils
9
+ * @classdesc Utility helper functions — id, ids, hashing, parsing, cleaning, and other general-purpose helpers
10
+ * @class
11
+ */
12
+
7
13
  const service = {};
8
14
 
9
15
  ////////////////////////////////////
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "1.0.4";
1
+ export const version = "1.0.6";