@qikdev/sdk 1.0.2 → 1.0.5

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/{docs/access.html → access.html} +353 -20
  3. package/dist/api.html +444 -0
  4. package/dist/{docs/auth.html → auth.html} +14 -14
  5. package/dist/cache.html +351 -0
  6. package/dist/{docs/content.html → content.html} +46 -21
  7. package/dist/{docs/files.html → files.html} +147 -6
  8. package/dist/{docs/filter.html → filter.html} +9 -9
  9. package/dist/geo.html +1029 -0
  10. package/dist/global.html +240 -0
  11. package/dist/index.html +96 -0
  12. package/dist/main.js +2 -3
  13. package/dist/module-QikStorage-CookieStorageAdapter.html +407 -0
  14. package/dist/module-QikStorage-LocalStorageAdapter.html +193 -0
  15. package/dist/module-QikStorage-StorageAdapter.html +977 -0
  16. package/dist/module-QikStorage.html +433 -0
  17. package/dist/qik.access.js.html +904 -0
  18. package/dist/qik.api.js.html +409 -0
  19. package/dist/{docs/qik.auth.js.html → qik.auth.js.html} +142 -104
  20. package/dist/qik.cache.js.html +125 -0
  21. package/dist/qik.content.js.html +967 -0
  22. package/dist/qik.core.js.html +322 -0
  23. package/dist/qik.files.js.html +249 -0
  24. package/dist/{docs/qik.filter.js.html → qik.filter.js.html} +3 -3
  25. package/dist/qik.geo.js.html +963 -0
  26. package/dist/{docs/qik.socket.js.html → qik.socket.js.html} +53 -12
  27. package/dist/qik.storage.js.html +375 -0
  28. package/dist/qik.system.js.html +117 -0
  29. package/dist/qik.utils.js.html +1548 -0
  30. package/dist/{docs/socket.html → socket.html} +7 -7
  31. package/dist/{docs/styles → styles}/jsdoc.css +2 -2
  32. package/dist/system.html +197 -0
  33. package/dist/utils.html +4422 -0
  34. package/package.json +2 -2
  35. package/src/api/qik.filter.js +1 -1
  36. package/src/api/qik.geo.js +1 -1
  37. package/src/api/qik.socket.js +18 -12
  38. package/src/api/qik.utils.js +6 -0
  39. package/src/version.js +1 -1
  40. package/dist/docs/api.html +0 -1356
  41. package/dist/docs/cache.html +0 -351
  42. package/dist/docs/index.html +0 -96
  43. package/dist/docs/qik.access.js.html +0 -790
  44. package/dist/docs/qik.api.js.html +0 -511
  45. package/dist/docs/qik.cache.js.html +0 -131
  46. package/dist/docs/qik.content.js.html +0 -918
  47. package/dist/docs/qik.core.js.html +0 -301
  48. package/dist/docs/qik.files.js.html +0 -219
  49. package/dist/docs/qik.system.js.html +0 -117
  50. package/dist/docs/qik.utils.js.html +0 -1467
  51. package/dist/docs/system.html +0 -197
  52. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.eot +0 -0
  53. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.ttf +0 -0
  54. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.woff +0 -0
  55. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.woff2 +0 -0
  56. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.eot +0 -0
  57. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.ttf +0 -0
  58. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.woff +0 -0
  59. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.woff2 +0 -0
  60. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  61. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  62. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  63. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  64. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  65. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  66. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  67. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  68. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  69. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  70. /package/dist/{docs/scripts → scripts}/collapse.js +0 -0
  71. /package/dist/{docs/scripts → scripts}/linenumber.js +0 -0
  72. /package/dist/{docs/scripts → scripts}/nav.js +0 -0
  73. /package/dist/{docs/scripts → scripts}/polyfill.js +0 -0
  74. /package/dist/{docs/scripts → scripts}/prettify/Apache-License-2.0.txt +0 -0
  75. /package/dist/{docs/scripts → scripts}/prettify/lang-css.js +0 -0
  76. /package/dist/{docs/scripts → scripts}/prettify/prettify.js +0 -0
  77. /package/dist/{docs/scripts → scripts}/search.js +0 -0
  78. /package/dist/{docs/styles → styles}/prettify.css +0 -0
@@ -1,511 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>qik.api.js - Documentation</title>
7
-
8
-
9
- <script src="scripts/prettify/prettify.js"></script>
10
- <script src="scripts/prettify/lang-css.js"></script>
11
- <!--[if lt IE 9]>
12
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
- <![endif]-->
14
- <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
- <script src="scripts/nav.js" defer></script>
17
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
- </head>
19
- <body>
20
-
21
- <input type="checkbox" id="nav-trigger" class="nav-trigger" />
22
- <label for="nav-trigger" class="navicon-button x">
23
- <div class="navicon"></div>
24
- </label>
25
-
26
- <label for="nav-trigger" class="overlay"></label>
27
-
28
- <nav >
29
-
30
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="access.html">access</a><ul class='methods'><li data-type='method'><a href="access.html#.actionableScopes">actionableScopes</a></li><li data-type='method'><a href="access.html#.allPermissions">allPermissions</a></li><li data-type='method'><a href="access.html#.allPermissionTypes">allPermissionTypes</a></li><li data-type='method'><a href="access.html#.allUserScopes">allUserScopes</a></li><li data-type='method'><a href="access.html#.canCreate">canCreate</a></li><li data-type='method'><a href="access.html#.canDeleteItem">canDeleteItem</a></li><li data-type='method'><a href="access.html#.canEditItem">canEditItem</a></li><li data-type='method'><a href="access.html#.canEraseItem">canEraseItem</a></li><li data-type='method'><a href="access.html#.canKnowOf">canKnowOf</a></li><li data-type='method'><a href="access.html#.canListItem">canListItem</a></li><li data-type='method'><a href="access.html#.canRestoreItem">canRestoreItem</a></li><li data-type='method'><a href="access.html#.canViewItem">canViewItem</a></li><li data-type='method'><a href="access.html#.checkActionAccess">checkActionAccess</a></li><li data-type='method'><a href="access.html#.getAllDescendants">getAllDescendants</a></li><li data-type='method'><a href="access.html#.has">has</a></li><li data-type='method'><a href="access.html#.hashPermissions">hashPermissions</a></li><li data-type='method'><a href="access.html#.isAdministrator">isAdministrator</a></li><li data-type='method'><a href="access.html#.isOwner">isOwner</a></li></ul></li><li><a href="api.html">api</a><ul class='methods'><li data-type='method'><a href="api.html#.delete">delete</a></li><li data-type='method'><a href="api.html#.generateEndpointURL">generateEndpointURL</a></li><li data-type='method'><a href="api.html#.get">get</a></li><li data-type='method'><a href="api.html#.patch">patch</a></li><li data-type='method'><a href="api.html#.post">post</a></li><li data-type='method'><a href="api.html#.put">put</a></li></ul></li><li><a href="auth.html">auth</a><ul class='methods'><li data-type='method'><a href="auth.html#.changeOrganisation">changeOrganisation</a></li><li data-type='method'><a href="auth.html#.ensureValidToken">ensureValidToken</a></li><li data-type='method'><a href="auth.html#.getCurrentToken">getCurrentToken</a></li><li data-type='method'><a href="auth.html#.getCurrentUser">getCurrentUser</a></li><li data-type='method'><a href="auth.html#.impersonate">impersonate</a></li><li data-type='method'><a href="auth.html#.login">login</a></li><li data-type='method'><a href="auth.html#.logout">logout</a></li><li data-type='method'><a href="auth.html#.retrieveUserFromResetToken">retrieveUserFromResetToken</a></li><li data-type='method'><a href="auth.html#.sendResetPasswordRequest">sendResetPasswordRequest</a></li><li data-type='method'><a href="auth.html#.set">set</a></li><li data-type='method'><a href="auth.html#.sync">sync</a></li><li data-type='method'><a href="auth.html#.updateUserWithToken">updateUserWithToken</a></li></ul></li><li><a href="cache.html">cache</a><ul class='methods'><li data-type='method'><a href="cache.html#.get">get</a></li><li data-type='method'><a href="cache.html#.reset">reset</a></li></ul></li><li><a href="content.html">content</a><ul class='methods'><li data-type='method'><a href="content.html#.create">create</a></li><li data-type='method'><a href="content.html#.delete">delete</a></li><li data-type='method'><a href="content.html#.get">get</a></li><li data-type='method'><a href="content.html#.getFromSlug">getFromSlug</a></li><li data-type='method'><a href="content.html#.glossary">glossary</a></li><li data-type='method'><a href="content.html#.list">list</a></li><li data-type='method'><a href="content.html#.patch">patch</a></li><li data-type='method'><a href="content.html#.restore">restore</a></li><li data-type='method'><a href="content.html#.scopeGlossary">scopeGlossary</a></li><li data-type='method'><a href="content.html#.update">update</a></li><li data-type='method'><a href="content.html#.validateField">validateField</a></li><li data-type='method'><a href="content.html#.variables">variables</a></li></ul></li><li><a href="files.html">files</a><ul class='methods'><li data-type='method'><a href="files.html#.downloadUrl">downloadUrl</a></li><li data-type='method'><a href="files.html#.filesize">filesize</a></li><li data-type='method'><a href="files.html#.getBinaryTypeFromMime">getBinaryTypeFromMime</a></li><li data-type='method'><a href="files.html#.mediaUrl">mediaUrl</a></li></ul></li><li><a href="filter.html">filter</a><ul class='methods'><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterOperators">activeFilterOperators</a></li><li data-type='method'><a href="filter.html#.activeFilters">activeFilters</a></li><li data-type='method'><a href="filter.html#.activeFilterValues">activeFilterValues</a></li><li data-type='method'><a href="filter.html#.filterChangeString">filterChangeString</a></li><li data-type='method'><a href="filter.html#.isValidFilter">isValidFilter</a></li></ul></li><li><a href="socket.html">socket</a><ul class='methods'><li data-type='method'><a href="socket.html#.channel">channel</a></li><li data-type='method'><a href="socket.html#.close">close</a></li><li data-type='method'><a href="socket.html#.connect">connect</a></li><li data-type='method'><a href="socket.html#.reconnect">reconnect</a></li><li data-type='method'><a href="socket.html#.subscribe">subscribe</a></li><li data-type='method'><a href="socket.html#.unsubscribe">unsubscribe</a></li></ul></li><li><a href="system.html">system</a><ul class='methods'><li data-type='method'><a href="system.html#.countries">countries</a></li></ul></li></ul>
31
- </nav>
32
-
33
- <div id="main">
34
-
35
- <h1 class="page-title">qik.api.js</h1>
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
- <section>
44
- <article>
45
- <pre class="prettyprint source linenums"><code>import axios from 'axios';
46
- import qs from 'qs';
47
- import { version } from '../version.js';
48
-
49
- import {
50
- cacheAdapterEnhancer,
51
- throttleAdapterEnhancer,
52
- Cache,
53
- } from 'axios-extensions';
54
-
55
-
56
- function isString(value) {
57
- const type = typeof value
58
- return type === 'string' || (type === 'object' &amp;&amp; value != null &amp;&amp; !Array.isArray(value) &amp;&amp; getTag(value) == '[object String]')
59
- }
60
-
61
-
62
- /**
63
- * Creates a new instance of Axios, with automatic authentication and token refreshing functionality.
64
- * This module provides all the underlying functions for making http requests and interacting with the REST API.
65
- * It is a wrapper around the axios library, a popular promise based javascript request package. The api module is used by most other modules in the SDK and will handle authentication, token refreshing and other headers automatically.
66
- * @alias api
67
- * @constructor
68
- * @hideconstructor
69
- * @param {QikAPI} qik A reference to the parent instance of the QikCore module. This module is usually created by a QikCore instance that passes itself in as the first argument.
70
- */
71
-
72
-
73
- const CancelToken = axios.CancelToken;
74
-
75
- ///////////////////////////////////////
76
-
77
-
78
-
79
- var QikAPI = function(qik) {
80
-
81
- var defaultCache;
82
-
83
- if (typeof window !== 'undefined') {
84
- defaultCache = qik.cache.get('api');
85
- }
86
-
87
- const defaultAdapter = axios.defaults.adapter
88
-
89
- /////////////////////////////////////////////////////
90
-
91
- function getRequestCacheKey(config) {
92
- var key = [
93
- config.method,
94
- config.url,
95
- config.headers?.Authorization,
96
- config.headers.Accept,
97
- JSON.stringify({
98
- params: config.params,
99
- data: config.data,
100
- }),
101
-
102
- ].filter(Boolean).join('-')
103
-
104
- return key;
105
- }
106
-
107
- ///////////////////////////////////////
108
-
109
- const inflightRequests = {};
110
-
111
- let cacheAdapter = function(config) {
112
-
113
- var cacheKey = getRequestCacheKey(config);
114
-
115
- // If there is already an identical request being made
116
- if (!inflightRequests[cacheKey]) {
117
-
118
- // Be more efficient and wait for the existing request
119
- inflightRequests[cacheKey] = new Promise(function(resolve, reject) {
120
- var useCache;
121
- var cachedResponse;
122
-
123
- ///////////////////////////////////////
124
-
125
- switch (String(config.method).toLowerCase()) {
126
- case 'post':
127
- case 'patch':
128
- case 'put':
129
- case 'delete':
130
- //Unless we've specified we want a cache
131
- if (!config.cache) {
132
- //Don't use the cache
133
- config.cache = false;
134
- }
135
- break;
136
- }
137
-
138
- ///////////////////////////////////////
139
-
140
- if (config.cache === false) {
141
- //No cache so make new request
142
- } else {
143
-
144
- //Use the cache specified or the default cache
145
- useCache = config.cache || defaultCache;
146
-
147
- //If there is a cache
148
- if (useCache) {
149
- //If we have the cachedResponse version
150
- cachedResponse = useCache.get(cacheKey);
151
- }
152
- }
153
-
154
- ///////////////////////////////////////
155
-
156
- if (cachedResponse) {
157
- return resolve(cachedResponse);
158
- }
159
-
160
- var copy = Object.assign(config, { adapter: defaultAdapter });
161
-
162
- return axios.request(config)
163
- .then(function(res) {
164
-
165
- delete inflightRequests[cacheKey];
166
- resolve(res);
167
- }, function(err) {
168
-
169
- delete inflightRequests[cacheKey];
170
- reject(err);
171
- });
172
-
173
- })
174
-
175
- }
176
- return inflightRequests[cacheKey];
177
- }
178
-
179
-
180
-
181
-
182
- //////////////////////////////////////////////////////////////////////////////
183
-
184
- const service = createNewAxios(cacheAdapter);
185
-
186
- //////////////////////////////////////////////////////////////////////////////
187
-
188
- /**
189
- *
190
- * Generate an Endpoint URL, complete with authentication.
191
- * this function is helpful for generating authenticated links for the user to open in another window
192
- * @alias api.generateEndpointURL
193
- * @param {String} endpoint The endpoint to generate a url for
194
- * @param {Object} params Extra parameters for the url
195
- * @param {Object} options Additional request configuration
196
- * @param {Object} options.withoutToken Don't append the current user's access token to the url
197
- * @param {Object} options.file Whether the response for this request is expected to be a binary file type
198
- * @example
199
- *
200
- *
201
- * const result = sdk.api.generateEndpointURL('/image/61eca4746971e75c1fc670cf', {
202
- * w:100,
203
- * h:50,
204
- * }, {file:true})
205
- *
206
- * // Would return something similar to:
207
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&amp;h=50&amp;access_token=XXXX...
208
- */
209
- service.generateEndpointURL = function(endpoint, params, options) {
210
- options = options || {}
211
- params = params || {};
212
-
213
- var token;
214
- const apiURL = options.file ? qik.fileAPI || qik.apiURL : qik.apiURL;
215
-
216
- //Append the access token to the url
217
- if (!options.withoutToken) {
218
- delete params.access_token;
219
- token = qik.auth.getCurrentToken();
220
- }
221
-
222
- var stripLeadingTag = endpoint[0] == '/' ? endpoint.slice(1) : endpoint;
223
- var parameterString = qik.utils.mapParameters(params);
224
-
225
- if (token) {
226
- parameterString = parameterString ? `?access_token=${token}&amp;${parameterString}` : `?access_token=${token}`;
227
- } else {
228
- parameterString = parameterString ? `?${parameterString}` : '';
229
- }
230
-
231
-
232
- var url = `${apiURL}${endpoint}${parameterString}`
233
-
234
- return url;
235
- }
236
-
237
- //////////////////////////////////////////////////////////////////////////////
238
-
239
- service.wasCancelled = function(err) {
240
- return axios.isCancel(err);
241
- }
242
-
243
- //////////////////////////////////////////////////////////////////////////////
244
-
245
-
246
- /**
247
- *
248
- * Make a GET request to the API
249
- * @alias api.get
250
- * @param {Object} endpoint The endpoint to request
251
- * @param {Object} options The options to pass to axios for making the request
252
- * @example
253
- *
254
- * const result = await sdk.api.get('/user');
255
- */
256
- var f = function() {}
257
-
258
- /**
259
- *
260
- *
261
- * @alias api.post
262
- * @description Make a POST request to the API
263
- * @param {Object} endpoint The endpoint to request
264
- * @param {Object} body The post body to send with the request
265
- * @param {Object} options The options to pass to axios for making the request
266
- * @example
267
- *
268
- * const result = await sdk.api.post('/login', {username:'', password:''});
269
- */
270
- var f = function() {}
271
-
272
- /**
273
- *
274
- * Make a PUT request to the API
275
- * @alias api.put
276
- * @param {Object} endpoint The endpoint to request
277
- * @param {Object} body The post body to send with the request
278
- * @param {Object} options The options to pass to axios for making the request
279
- * @example
280
- *
281
- * const result = await sdk.api.put('/content/61eca4746971e75c1fc670cf', {title:'A new title'});
282
- */
283
- var f = function() {}
284
-
285
- /**
286
- *
287
- * Make a PATCH request to the API
288
- * @alias api.patch
289
- * @param {Object} endpoint The endpoint to request
290
- * @param {Object} body The post body to send with the request
291
- * @param {Object} options The options to pass to axios for making the request
292
- * @example
293
- *
294
- * const result = await sdk.api.patch('/content/61eca4746971e75c1fc670cf', {title:'A new title'});
295
- */
296
- var f = function() {}
297
-
298
- /**
299
- *
300
- * Make a DELETE request to the API
301
- * @alias api.delete
302
- * @param {Object} endpoint The endpoint to request
303
- * @param {Object} body The post body to send with the request
304
- * @param {Object} options The options to pass to axios for making the request
305
- * @example
306
- *
307
- * const result = await sdk.api.delete('/content/61eca4746971e75c1fc670cf');
308
- */
309
- var f = function() {}
310
-
311
-
312
-
313
-
314
- function createNewAxios(adapter) {
315
-
316
- var instance = axios.create({
317
- paramsSerializer: params => qs.stringify(params, { arrayFormat: 'repeat' }),
318
- adapter,
319
- });
320
-
321
- ///////////////////////////////////////
322
-
323
- instance.defaults.baseURL = qik.apiURL;
324
- instance.defaults.headers.common.Accept = 'application/json';
325
-
326
- /////////////////////////////////////////////////////
327
-
328
- // Add relative date and timezone to every request
329
- instance.interceptors.request.use(function(config) {
330
-
331
- const inflightKey = getRequestCacheKey(config);
332
-
333
- if (config.withoutToken) {
334
- return config;
335
- }
336
-
337
- config.headers['qik-request-date'] = new Date().getTime();
338
- if (Intl) {
339
- config.headers['qik-request-timezone'] = Intl.DateTimeFormat().resolvedOptions().timeZone;
340
- }
341
-
342
- config.headers['qik-api-version'] = version;
343
-
344
- // Include the socket window id in the request
345
- if(qik?.socket?.windowID) {
346
- config.headers['qik-socket-window'] = qik.socket.windowID;
347
- }
348
-
349
-
350
- var token = qik.auth.getCurrentToken();
351
-
352
- if (token) {
353
- config.headers['Authorization'] = `Bearer ${token}`;
354
-
355
- if (config.params &amp;&amp; config.params.access_token) {
356
- delete config.params.access_token;
357
- }
358
- }
359
-
360
- return config;
361
- });
362
-
363
- /////////////////////////////////////////////////////
364
-
365
- let retryCount = 0;
366
-
367
- instance.interceptors.response.use(function(response) {
368
- var config = response.config
369
-
370
- //Get the response status
371
- var status = response.status;
372
- switch (status) {
373
- case 204:
374
- // No content give it another try
375
- if (retryCount &lt; 5) {
376
- retryCount++;
377
- // Wait a second and try again
378
- return new Promise(function(resolve, reject) {
379
- setTimeout(function() {
380
- return instance.request(config).then(resolve, reject);
381
- }, 800);
382
- })
383
- } else {
384
- console.log('Failed after 5 retries')
385
- retryCount = 0;
386
- }
387
- break;
388
- }
389
-
390
- return response;
391
- }, function(err) {
392
-
393
- if (axios.isCancel(err)) {
394
- return Promise.reject(err);
395
- }
396
-
397
- //Get the response status
398
- var status = err?.response?.status || err.status;
399
-
400
- //Check the status
401
- switch (status) {
402
- case 401:
403
- //Ignore let QikAuth handle it
404
- break;
405
-
406
- case 502:
407
- case 504:
408
-
409
- if (retryCount &lt; 5) {
410
- retryCount++;
411
- // Wait a second and try again
412
- return new Promise(function(resolve, reject) {
413
- setTimeout(function() {
414
- return instance.request(err.config).then(resolve, reject);
415
- }, 800);
416
- })
417
- } else {
418
- console.log('Failed after 5 retries')
419
- retryCount = 0;
420
- }
421
- break;
422
- case 404:
423
- //Not found
424
- break;
425
- default:
426
- //Some other error, likely a problem connecting to the server
427
- // console.log('qik.api > connection error', status, err);
428
- break;
429
- }
430
-
431
- /////////////////////////////////////////////////////
432
-
433
- return Promise.reject(err);
434
- })
435
-
436
- return instance;
437
- }
438
-
439
- /////////////////////////////////////////////////////
440
-
441
- function retrieveIDs(data) {
442
-
443
- var dataString;
444
-
445
- if (_isString(data)) {
446
- dataString = data;
447
- } else {
448
- dataString = JSON.stringify(data);
449
- }
450
-
451
- //Find all mongo ids included in the object
452
- var myregexp = /[0-9a-fA-F]{24}/g;
453
- var matches = dataString.match(myregexp);
454
-
455
- //Make sure the matches are unique
456
- return [...new Set(matches)];
457
- }
458
-
459
- ///////////////////////////////////////
460
-
461
- /**
462
- *
463
- * Reference to the underlying axios package (https://www.npmjs.com/package/axios)
464
- * Useful for creating new instances of axios if you want to create http requests to
465
- * external APIs and not send tokens etc..
466
- * @name api.axios
467
- * @example
468
- * const newRequest = await sdk.api.axios.get('https://otherapi.com/content/61eca4746971e75c1fc670cf');
469
- */
470
-
471
- service.CancelToken = CancelToken;
472
- service.axios = axios;
473
-
474
- ///////////////////////////////////////
475
-
476
- return service;
477
- }
478
-
479
-
480
-
481
-
482
- ///////////////////////////////////////
483
- ///////////////////////////////////////
484
- ///////////////////////////////////////
485
-
486
- export { CancelToken as CancelToken };
487
- export default QikAPI;</code></pre>
488
- </article>
489
- </section>
490
-
491
-
492
-
493
-
494
-
495
-
496
- </div>
497
-
498
- <br class="clear">
499
-
500
- <footer>
501
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Thu Sep 28 2023 07:24:39 GMT+1000 (Australian Eastern Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
502
- </footer>
503
-
504
- <script>prettyPrint();</script>
505
- <script src="scripts/polyfill.js"></script>
506
- <script src="scripts/linenumber.js"></script>
507
-
508
-
509
-
510
- </body>
511
- </html>
@@ -1,131 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>qik.cache.js - Documentation</title>
7
-
8
-
9
- <script src="scripts/prettify/prettify.js"></script>
10
- <script src="scripts/prettify/lang-css.js"></script>
11
- <!--[if lt IE 9]>
12
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
- <![endif]-->
14
- <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
- <script src="scripts/nav.js" defer></script>
17
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
- </head>
19
- <body>
20
-
21
- <input type="checkbox" id="nav-trigger" class="nav-trigger" />
22
- <label for="nav-trigger" class="navicon-button x">
23
- <div class="navicon"></div>
24
- </label>
25
-
26
- <label for="nav-trigger" class="overlay"></label>
27
-
28
- <nav >
29
-
30
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="access.html">access</a><ul class='methods'><li data-type='method'><a href="access.html#.actionableScopes">actionableScopes</a></li><li data-type='method'><a href="access.html#.allPermissions">allPermissions</a></li><li data-type='method'><a href="access.html#.allPermissionTypes">allPermissionTypes</a></li><li data-type='method'><a href="access.html#.allUserScopes">allUserScopes</a></li><li data-type='method'><a href="access.html#.canCreate">canCreate</a></li><li data-type='method'><a href="access.html#.canDeleteItem">canDeleteItem</a></li><li data-type='method'><a href="access.html#.canEditItem">canEditItem</a></li><li data-type='method'><a href="access.html#.canEraseItem">canEraseItem</a></li><li data-type='method'><a href="access.html#.canKnowOf">canKnowOf</a></li><li data-type='method'><a href="access.html#.canListItem">canListItem</a></li><li data-type='method'><a href="access.html#.canRestoreItem">canRestoreItem</a></li><li data-type='method'><a href="access.html#.canViewItem">canViewItem</a></li><li data-type='method'><a href="access.html#.checkActionAccess">checkActionAccess</a></li><li data-type='method'><a href="access.html#.getAllDescendants">getAllDescendants</a></li><li data-type='method'><a href="access.html#.has">has</a></li><li data-type='method'><a href="access.html#.hashPermissions">hashPermissions</a></li><li data-type='method'><a href="access.html#.isAdministrator">isAdministrator</a></li><li data-type='method'><a href="access.html#.isOwner">isOwner</a></li></ul></li><li><a href="api.html">api</a><ul class='methods'><li data-type='method'><a href="api.html#.delete">delete</a></li><li data-type='method'><a href="api.html#.generateEndpointURL">generateEndpointURL</a></li><li data-type='method'><a href="api.html#.get">get</a></li><li data-type='method'><a href="api.html#.patch">patch</a></li><li data-type='method'><a href="api.html#.post">post</a></li><li data-type='method'><a href="api.html#.put">put</a></li></ul></li><li><a href="auth.html">auth</a><ul class='methods'><li data-type='method'><a href="auth.html#.changeOrganisation">changeOrganisation</a></li><li data-type='method'><a href="auth.html#.ensureValidToken">ensureValidToken</a></li><li data-type='method'><a href="auth.html#.getCurrentToken">getCurrentToken</a></li><li data-type='method'><a href="auth.html#.getCurrentUser">getCurrentUser</a></li><li data-type='method'><a href="auth.html#.impersonate">impersonate</a></li><li data-type='method'><a href="auth.html#.login">login</a></li><li data-type='method'><a href="auth.html#.logout">logout</a></li><li data-type='method'><a href="auth.html#.retrieveUserFromResetToken">retrieveUserFromResetToken</a></li><li data-type='method'><a href="auth.html#.sendResetPasswordRequest">sendResetPasswordRequest</a></li><li data-type='method'><a href="auth.html#.set">set</a></li><li data-type='method'><a href="auth.html#.sync">sync</a></li><li data-type='method'><a href="auth.html#.updateUserWithToken">updateUserWithToken</a></li></ul></li><li><a href="cache.html">cache</a><ul class='methods'><li data-type='method'><a href="cache.html#.get">get</a></li><li data-type='method'><a href="cache.html#.reset">reset</a></li></ul></li><li><a href="content.html">content</a><ul class='methods'><li data-type='method'><a href="content.html#.create">create</a></li><li data-type='method'><a href="content.html#.delete">delete</a></li><li data-type='method'><a href="content.html#.get">get</a></li><li data-type='method'><a href="content.html#.getFromSlug">getFromSlug</a></li><li data-type='method'><a href="content.html#.glossary">glossary</a></li><li data-type='method'><a href="content.html#.list">list</a></li><li data-type='method'><a href="content.html#.patch">patch</a></li><li data-type='method'><a href="content.html#.restore">restore</a></li><li data-type='method'><a href="content.html#.scopeGlossary">scopeGlossary</a></li><li data-type='method'><a href="content.html#.update">update</a></li><li data-type='method'><a href="content.html#.validateField">validateField</a></li><li data-type='method'><a href="content.html#.variables">variables</a></li></ul></li><li><a href="files.html">files</a><ul class='methods'><li data-type='method'><a href="files.html#.downloadUrl">downloadUrl</a></li><li data-type='method'><a href="files.html#.filesize">filesize</a></li><li data-type='method'><a href="files.html#.getBinaryTypeFromMime">getBinaryTypeFromMime</a></li><li data-type='method'><a href="files.html#.mediaUrl">mediaUrl</a></li></ul></li><li><a href="filter.html">filter</a><ul class='methods'><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterOperators">activeFilterOperators</a></li><li data-type='method'><a href="filter.html#.activeFilters">activeFilters</a></li><li data-type='method'><a href="filter.html#.activeFilterValues">activeFilterValues</a></li><li data-type='method'><a href="filter.html#.filterChangeString">filterChangeString</a></li><li data-type='method'><a href="filter.html#.isValidFilter">isValidFilter</a></li></ul></li><li><a href="socket.html">socket</a><ul class='methods'><li data-type='method'><a href="socket.html#.channel">channel</a></li><li data-type='method'><a href="socket.html#.close">close</a></li><li data-type='method'><a href="socket.html#.connect">connect</a></li><li data-type='method'><a href="socket.html#.reconnect">reconnect</a></li><li data-type='method'><a href="socket.html#.subscribe">subscribe</a></li><li data-type='method'><a href="socket.html#.unsubscribe">unsubscribe</a></li></ul></li><li><a href="system.html">system</a><ul class='methods'><li data-type='method'><a href="system.html#.countries">countries</a></li></ul></li></ul>
31
- </nav>
32
-
33
- <div id="main">
34
-
35
- <h1 class="page-title">qik.cache.js</h1>
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
- <section>
44
- <article>
45
- <pre class="prettyprint source linenums"><code>import _ from 'lodash';
46
-
47
- import {Cache} from 'axios-extensions';
48
-
49
-
50
- ///////////////////////////////////////////////////////////////////////////////
51
-
52
- var caches = {};
53
-
54
-
55
- /**
56
- * @classdesc A static service that provides tools for caching api requests and other information
57
- * @alias cache
58
- * @class
59
- * @hideconstructor
60
- */
61
- var QikCache = {
62
-
63
- ///////////////////////////////////////////////////
64
-
65
-
66
- /**
67
- * A helper function to reset all caches, useful if changing organisation or logging in or out as another user
68
- * @alias cache.reset
69
- */
70
- reset() {
71
- _.each(caches, function(cache, key) {
72
- // console.log(`Reset ${key} cache`, cache);
73
- if(cache.clear) {
74
- cache.clear()
75
- } else if(cache.reset) {
76
- cache.reset()
77
- }
78
-
79
- })
80
- },
81
-
82
- ///////////////////////////////////////////////////
83
-
84
- /**
85
- * A helper function to retrieve a specific cache
86
- * @alias cache.get
87
- * @param {string} key The key for the cache you want to retrieve
88
- * @return {LRUCache} The cache store for the specified key
89
- */
90
- get(key, options) {
91
- options = options || {max:5};
92
-
93
- if (caches[key]) {
94
- return caches[key];
95
- }
96
- caches[key] = new Cache(options)
97
-
98
- // console.log('Created new cache', key);
99
- return caches[key];
100
-
101
- }
102
- }
103
-
104
-
105
- ///////////////////////////////////////////////////////////////////////////////
106
-
107
- export default QikCache;</code></pre>
108
- </article>
109
- </section>
110
-
111
-
112
-
113
-
114
-
115
-
116
- </div>
117
-
118
- <br class="clear">
119
-
120
- <footer>
121
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Thu Sep 28 2023 07:24:39 GMT+1000 (Australian Eastern Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
122
- </footer>
123
-
124
- <script>prettyPrint();</script>
125
- <script src="scripts/polyfill.js"></script>
126
- <script src="scripts/linenumber.js"></script>
127
-
128
-
129
-
130
- </body>
131
- </html>