@qikdev/sdk 1.0.1 → 1.0.4

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 (82) hide show
  1. package/README.md +1 -1
  2. package/dist/access.html +16371 -0
  3. package/dist/api.html +1503 -0
  4. package/dist/auth.html +8455 -0
  5. package/dist/cache.html +1135 -0
  6. package/dist/content.html +10067 -0
  7. package/dist/files.html +3415 -0
  8. package/dist/filter.html +4973 -0
  9. package/dist/geo.html +3851 -0
  10. package/dist/global.html +328 -0
  11. package/dist/index.html +96 -0
  12. package/dist/main.js +1100 -1126
  13. package/dist/module-QikStorage-CookieStorageAdapter.html +1177 -0
  14. package/dist/module-QikStorage-LocalStorageAdapter.html +329 -0
  15. package/dist/module-QikStorage-StorageAdapter.html +3457 -0
  16. package/dist/module-QikStorage.html +1445 -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} +2 -2
  25. package/dist/qik.geo.js.html +963 -0
  26. package/dist/qik.socket.js.html +451 -0
  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 +1542 -0
  30. package/dist/socket.html +2975 -0
  31. package/dist/{docs/styles → styles}/jsdoc.css +2 -2
  32. package/dist/system.html +523 -0
  33. package/package.json +2 -2
  34. package/src/api/qik.access.js +2 -53
  35. package/src/api/qik.socket.js +51 -10
  36. package/src/version.js +1 -1
  37. package/dist/docs/access.html +0 -3826
  38. package/dist/docs/api.html +0 -1356
  39. package/dist/docs/auth.html +0 -2180
  40. package/dist/docs/cache.html +0 -351
  41. package/dist/docs/content.html +0 -2560
  42. package/dist/docs/files.html +0 -779
  43. package/dist/docs/filter.html +0 -1355
  44. package/dist/docs/index.html +0 -96
  45. package/dist/docs/qik.access.js.html +0 -790
  46. package/dist/docs/qik.api.js.html +0 -511
  47. package/dist/docs/qik.cache.js.html +0 -131
  48. package/dist/docs/qik.content.js.html +0 -918
  49. package/dist/docs/qik.core.js.html +0 -301
  50. package/dist/docs/qik.files.js.html +0 -219
  51. package/dist/docs/qik.socket.js.html +0 -416
  52. package/dist/docs/qik.system.js.html +0 -117
  53. package/dist/docs/qik.utils.js.html +0 -1467
  54. package/dist/docs/socket.html +0 -810
  55. package/dist/docs/system.html +0 -197
  56. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.eot +0 -0
  57. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.ttf +0 -0
  58. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.woff +0 -0
  59. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Bold.woff2 +0 -0
  60. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.eot +0 -0
  61. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.ttf +0 -0
  62. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.woff +0 -0
  63. /package/dist/{docs/fonts → fonts}/Montserrat/Montserrat-Regular.woff2 +0 -0
  64. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  65. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  66. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  67. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  68. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  69. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  70. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  71. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  72. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  73. /package/dist/{docs/fonts → fonts}/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  74. /package/dist/{docs/scripts → scripts}/collapse.js +0 -0
  75. /package/dist/{docs/scripts → scripts}/linenumber.js +0 -0
  76. /package/dist/{docs/scripts → scripts}/nav.js +0 -0
  77. /package/dist/{docs/scripts → scripts}/polyfill.js +0 -0
  78. /package/dist/{docs/scripts → scripts}/prettify/Apache-License-2.0.txt +0 -0
  79. /package/dist/{docs/scripts → scripts}/prettify/lang-css.js +0 -0
  80. /package/dist/{docs/scripts → scripts}/prettify/prettify.js +0 -0
  81. /package/dist/{docs/scripts → scripts}/search.js +0 -0
  82. /package/dist/{docs/styles → styles}/prettify.css +0 -0
@@ -1,301 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>qik.core.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.core.js</h1>
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
- <section>
44
- <article>
45
- <pre class="prettyprint source linenums"><code>// if (process.browser) {
46
-
47
- import QikAPI from './qik.api.js';
48
- import QikAuth from './qik.auth.js';
49
- import QikUtils from './qik.utils.js';
50
- import QikFilter from './qik.filter.js';
51
- import QikFiles from './qik.files.js';
52
- import QikCache from './qik.cache.js';
53
- import QikAccess from './qik.access.js';
54
- import QikContent from './qik.content.js';
55
- import QikSystem from './qik.system.js';
56
- import QikSocket from './qik.socket.js';
57
- import { EventDispatcher } from './qik.utils.js';
58
-
59
- ///////////////////////////////////////
60
-
61
- /**
62
- * Creates a new QikCore instance including all of the default sub modules
63
- * @alias qik
64
- * @constructor
65
- * @param {Object} options
66
- * @param {String} options.apiURL The remote URL of the Qik API you want to connect to. Options are 'staging', 'production' or you may set a specific URL eg. 'https://api.qik.io' (do not include trailing slash). If no value is provided, will default to 'production'.
67
- * @param {String} options.applicationToken When running as a static application, (for example a website) you may set the application's access token before you initialize the Qik instance here.
68
- * @example
69
- *
70
- * //Import the Qik package
71
- * import Qik from '@qikdev/sdk';
72
- *
73
- * //Create a new Qik instance
74
- * var qik = new Qik();
75
- *
76
- * //Request the current user session endpoint from the Qik API
77
- * qik.api.get('/session').then(function(res) {
78
- * console.log('User session is ', res.data);
79
- * })
80
- * .catch(function(err) {
81
- * console.log('There was an error', err);
82
- * });
83
- *
84
- * //Use the QikAsset package to generate an image url
85
- * var link = qik.asset.imageUrl('5ca3d64dd2bb085eb9d450db', 1920, 1080)
86
- */
87
-
88
- import { version } from '../version.js';
89
-
90
- export default function(options) {
91
- if (!options) {
92
- options = {
93
- // apiURL,
94
- // applicationToken,
95
- // api:{}
96
- }
97
- }
98
-
99
- ///////////////////////////////////////
100
-
101
- if (!options.apiURL || !options.apiURL.length) {
102
- options.apiURL = 'staging';
103
- }
104
-
105
- ///////////////////////////////////////
106
-
107
- switch (String(options.apiURL).toLowerCase()) {
108
- case 'production':
109
- options.apiURL = 'https://api.qik.dev';
110
- break;
111
- case 'staging':
112
- options.apiURL = 'https://api.staging.qik.dev';
113
- break;
114
- case 'local':
115
- options.apiURL = 'http://api.qik.localhost:4001';
116
- break;
117
- }
118
-
119
- ///////////////////////////////////////
120
-
121
- const core = Object.assign(options, {
122
- //Other options
123
- // domain:'',
124
- version,
125
- global:{},
126
- })
127
-
128
-
129
- ///////////////////////////////////////
130
-
131
- /**
132
- * Provides a cache service, used for creating, clearing
133
- * and storing API requests and other information in memory
134
- * @type {QikCache}
135
- */
136
- const cache = QikCache;
137
- Object.defineProperty(core, 'cache', {
138
- value: cache,
139
- writable: false,
140
- });
141
-
142
- ///////////////////////////////////////
143
-
144
- /**
145
- * Provides helper functions for working
146
- * with Qik data
147
- * @type {QikUtils}
148
- */
149
- const utils = QikUtils;
150
- Object.defineProperty(core, 'utils', {
151
- value: utils,
152
- writable: false,
153
- });
154
-
155
- ///////////////////////////////////////
156
-
157
- /**
158
- * Provides helper functions for working
159
- * with Qik filters
160
- * @type {QikFilter}
161
- */
162
- const filter = QikFilter;
163
- Object.defineProperty(core, 'filter', {
164
- value: filter,
165
- writable: false,
166
- });
167
-
168
-
169
-
170
- ///////////////////////////////////////
171
-
172
- /**
173
- * Provides helper functions for working
174
- * with Qik files
175
- * @type {QikFiles}
176
- */
177
- const files = new QikFiles(core);
178
- Object.defineProperty(core, 'files', {
179
- value: files,
180
- writable: false,
181
- });
182
-
183
- ///////////////////////////////////////
184
-
185
- //Create a new global dispatcher so we can trigger events
186
- const dispatcher = new EventDispatcher();
187
- dispatcher.bootstrap(core);
188
-
189
- //Set the function
190
- core.error = function(err) {
191
- //Dispatch an error event
192
- return core.dispatch('error', utils.errorMessage(err));
193
- }
194
-
195
- //And enable notifications with a short message
196
- core.notify = function(message, options) {
197
- return core.dispatch('notification', { message, options });
198
- }
199
-
200
- ///////////////////////////////////////
201
-
202
- /**
203
- * The default service for interacting with
204
- * the Qik REST API, it's a wrapper around the axios library
205
- * that works in conjunction with the other Qik modules
206
- * @type {QikAPI}
207
- */
208
- const api = new QikAPI(core);
209
- Object.defineProperty(core, 'api', {
210
- value: api,
211
- writable: false,
212
- });
213
-
214
- /**
215
- * The default service for managing authentication
216
- * handles automatic refreshing of access tokens, and provides login, logout
217
- * and other user/application specific functionality
218
- * @type {QikAuth}
219
- */
220
- const auth = new QikAuth(core);
221
- Object.defineProperty(core, 'auth', {
222
- value: auth,
223
- writable: false,
224
- });
225
-
226
- /**
227
- * The default service for connecting, subscribing and unsubscribing sockets
228
- * @type {QikSocket}
229
- */
230
- const socket = new QikSocket(core);
231
- Object.defineProperty(core, 'socket', {
232
- value: socket,
233
- writable: false,
234
- });
235
-
236
- ///////////////////////////////////////
237
-
238
- /**
239
- * A helper service for understanding a user's access permissions
240
- * @type {QikAccess}
241
- */
242
- const access = new QikAccess(core);
243
- Object.defineProperty(core, 'access', {
244
- value: access,
245
- writable: false,
246
- });
247
-
248
- ///////////////////////////////////////
249
-
250
- /**
251
- * A helper service for content create, update, read and delete operations.
252
- * @type {QikContent}
253
- */
254
- const system = new QikSystem(core);
255
- Object.defineProperty(core, 'system', {
256
- value: system,
257
- writable: false,
258
- });
259
-
260
-
261
- ///////////////////////////////////////
262
-
263
- /**
264
- * A helper service for content create, update, read and delete operations.
265
- * @type {QikContent}
266
- */
267
- const content = new QikContent(core);
268
- Object.defineProperty(core, 'content', {
269
- value: content,
270
- writable: false,
271
- });
272
-
273
- ///////////////////////////////////////
274
-
275
- return core;
276
-
277
- }</code></pre>
278
- </article>
279
- </section>
280
-
281
-
282
-
283
-
284
-
285
-
286
- </div>
287
-
288
- <br class="clear">
289
-
290
- <footer>
291
- 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.
292
- </footer>
293
-
294
- <script>prettyPrint();</script>
295
- <script src="scripts/polyfill.js"></script>
296
- <script src="scripts/linenumber.js"></script>
297
-
298
-
299
-
300
- </body>
301
- </html>
@@ -1,219 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>qik.files.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.files.js</h1>
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
- <section>
44
- <article>
45
- <pre class="prettyprint source linenums"><code>
46
- /**
47
- * Creates a new Files Module instance.
48
- * This module provides a number of helper functions for interacting with binary file and media content via the REST API
49
- * @alias files
50
- * @constructor
51
- * @hideconstructor
52
- * @param {QikCore} 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.
53
- */
54
- export default function(qik) {
55
-
56
-
57
- ///////////////////////
58
-
59
- var service = {};
60
-
61
- ///////////////////////
62
-
63
- /**
64
- *
65
- * Get a valid download url for a specified record
66
- * @alias files.downloadUrl
67
- * @param {String} type The type or definition of the item we want to generate the url for
68
- * @param {(Object|String)} id The id or object with an _id property that we want to generate the url for
69
- * @param {Object} params Additional parameters and options for the url
70
- * @example
71
- * const url = sdk.files.downloadUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
72
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&amp;h=100&amp;download=true
73
- *
74
- * const url = sdk.files.downloadUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
75
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&amp;h=100&amp;download=true
76
- */
77
- service.downloadUrl = function(type, id, params, options) {
78
- options = options || {}
79
- params = params || {}
80
- params.download = true;
81
- id = qik.utils.id(id);
82
- return qik.api.generateEndpointURL(`/${type}/${id}`, params, options);
83
- }
84
-
85
- /**
86
- *
87
- * Get a valid media url for a specified image, video or audio item
88
- * @alias files.mediaUrl
89
- * @param {String} type The type or definition of the item we want to generate the url for
90
- * @param {(Object|String)} id The id or object with an _id property that we want to generate the url for
91
- * @param {Object} params Additional parameters and options for the url
92
- * @example
93
- * const url = sdk.files.mediaUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
94
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&amp;h=100&amp;download=true
95
- *
96
- * const url = sdk.files.mediaUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
97
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&amp;h=100&amp;download=true
98
- */
99
- service.mediaUrl = function(type, id, params, options) {
100
- options = options || {}
101
- params = params || {}
102
- id = qik.utils.id(id);
103
- return qik.api.generateEndpointURL(`/${type}/${id}`, params, options);
104
- }
105
-
106
- ///////////////////////
107
-
108
- /**
109
- *
110
- * Convert bytes to a human readable file size
111
- * @alias files.filesize
112
- * @param {Integer} bytes The number of bytes
113
- * @example
114
- * const size = sdk.files.filesize(1500);
115
- * // 1.5kb
116
- */
117
- service.filesize = function(bytes, decimals) {
118
- if(bytes == 0) return '0 Bytes';
119
- var k = 1024,
120
- dm = decimals || 2,
121
- sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
122
- i = Math.floor(Math.log(bytes) / Math.log(k));
123
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
124
- }
125
-
126
- ///////////////////////
127
-
128
- /**
129
- *
130
- * Get the basic primitive type of a file from it's mime type value
131
- * @alias files.getBinaryTypeFromMime
132
- * @param {String} fileMime The mime type of the file
133
- * @example
134
- * const type = sdk.files.getBinaryTypeFromMime('image/svg+xml');
135
- * // 'image'
136
- *
137
- * const type = sdk.files.getBinaryTypeFromMime('video/webm');
138
- * // 'video'
139
- */
140
- service.getBinaryTypeFromMime = function(fileMime) {
141
-
142
- if (!fileMime) {
143
- return 'file';
144
- }
145
-
146
- ////////////////////////////////
147
-
148
- switch (fileMime) {
149
- case 'image/jpeg':
150
- case 'image/png':
151
- case 'image/gif':
152
- case 'image/bmp':
153
- case 'image/tiff':
154
- case 'image/svg+xml':
155
- return 'image';
156
- break;
157
- case 'video/mp4':
158
- case 'video/quicktime':
159
- case 'video/ogg':
160
- case 'video/webm':
161
- return 'video'
162
- break;
163
- case 'audio/aac':
164
- case 'audio/aiff':
165
- case 'audio/mp3':
166
- case 'audio/x-m4a':
167
- case 'audio/mpeg':
168
- case 'audio/ogg':
169
- case 'audio/wav':
170
- case 'audio/webm':
171
- return 'audio'
172
- break;
173
- default:
174
- //See if we can guess it from the first part of the mimetype
175
- var prefix = fileMime.split('/')[0];
176
- switch (prefix) {
177
- case 'image':
178
- case 'video':
179
- case 'audio':
180
- return prefix;
181
- break;
182
- default:
183
- return 'file';
184
- break;
185
- }
186
- break;
187
- }
188
- }
189
-
190
- ////////////////////////////////
191
-
192
- return service;
193
-
194
- }
195
- </code></pre>
196
- </article>
197
- </section>
198
-
199
-
200
-
201
-
202
-
203
-
204
- </div>
205
-
206
- <br class="clear">
207
-
208
- <footer>
209
- 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.
210
- </footer>
211
-
212
- <script>prettyPrint();</script>
213
- <script src="scripts/polyfill.js"></script>
214
- <script src="scripts/linenumber.js"></script>
215
-
216
-
217
-
218
- </body>
219
- </html>