@qikdev/sdk 0.1.166 → 0.1.169

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 (74) hide show
  1. package/dist/main.js +1 -1
  2. package/dist/sdk.js +2 -0
  3. package/dist/sdk.js.LICENSE.txt +8 -0
  4. package/package.json +12 -2
  5. package/.gitlab-ci.yml +0 -24
  6. package/.husky/pre-commit +0 -5
  7. package/eslint.config.js +0 -6
  8. package/jsdoc.conf +0 -10
  9. package/public/docs/access.html +0 -3826
  10. package/public/docs/api.html +0 -1356
  11. package/public/docs/auth.html +0 -2180
  12. package/public/docs/cache.html +0 -351
  13. package/public/docs/content.html +0 -2560
  14. package/public/docs/files.html +0 -779
  15. package/public/docs/filter.html +0 -1355
  16. package/public/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  17. package/public/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  18. package/public/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  19. package/public/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  20. package/public/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  21. package/public/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  22. package/public/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  23. package/public/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  24. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  25. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
  26. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  27. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  28. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  29. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  30. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
  31. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  32. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  33. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  34. package/public/docs/index.html +0 -96
  35. package/public/docs/qik.access.js.html +0 -790
  36. package/public/docs/qik.api.js.html +0 -511
  37. package/public/docs/qik.auth.js.html +0 -1006
  38. package/public/docs/qik.cache.js.html +0 -131
  39. package/public/docs/qik.content.js.html +0 -918
  40. package/public/docs/qik.core.js.html +0 -301
  41. package/public/docs/qik.files.js.html +0 -219
  42. package/public/docs/qik.filter.js.html +0 -611
  43. package/public/docs/qik.socket.js.html +0 -416
  44. package/public/docs/qik.system.js.html +0 -117
  45. package/public/docs/qik.utils.js.html +0 -1467
  46. package/public/docs/scripts/collapse.js +0 -20
  47. package/public/docs/scripts/linenumber.js +0 -25
  48. package/public/docs/scripts/nav.js +0 -12
  49. package/public/docs/scripts/polyfill.js +0 -4
  50. package/public/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  51. package/public/docs/scripts/prettify/lang-css.js +0 -2
  52. package/public/docs/scripts/prettify/prettify.js +0 -28
  53. package/public/docs/scripts/search.js +0 -83
  54. package/public/docs/socket.html +0 -810
  55. package/public/docs/styles/jsdoc.css +0 -765
  56. package/public/docs/styles/prettify.css +0 -79
  57. package/public/docs/system.html +0 -197
  58. package/src/api/qik.access.js +0 -825
  59. package/src/api/qik.api.js +0 -431
  60. package/src/api/qik.auth.js +0 -881
  61. package/src/api/qik.cache.js +0 -63
  62. package/src/api/qik.content.js +0 -839
  63. package/src/api/qik.core.js +0 -245
  64. package/src/api/qik.files.js +0 -186
  65. package/src/api/qik.filter.js +0 -543
  66. package/src/api/qik.geo.js +0 -895
  67. package/src/api/qik.socket.js +0 -358
  68. package/src/api/qik.system.js +0 -49
  69. package/src/api/qik.utils.js +0 -1412
  70. package/src/index.js +0 -20
  71. package/src/version.js +0 -1
  72. package/test/index.spec.js +0 -41
  73. package/test/mocha.opts +0 -0
  74. package/yarn-error.log +0 -3598
@@ -1,245 +0,0 @@
1
- // if (process.browser) {
2
-
3
- import QikAPI from './qik.api.js';
4
- import QikAuth from './qik.auth.js';
5
- import QikUtils from './qik.utils.js';
6
- import QikFilter from './qik.filter.js';
7
- import QikFiles from './qik.files.js';
8
- import QikCache from './qik.cache.js';
9
- import QikAccess from './qik.access.js';
10
- import QikContent from './qik.content.js';
11
- import QikSystem from './qik.system.js';
12
- import QikGeo from './qik.geo.js';
13
- import QikSocket from './qik.socket.js';
14
- import { EventDispatcher } from './qik.utils.js';
15
-
16
- ///////////////////////////////////////
17
-
18
- /**
19
- * Creates a new QikCore instance including all of the default sub modules
20
- * @alias qik
21
- * @constructor
22
- * @param {Object} options
23
- * @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'.
24
- * @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.
25
- * @example
26
- *
27
- * //Import the Qik package
28
- * import Qik from '@qikdev/sdk';
29
- *
30
- * //Create a new Qik instance
31
- * var qik = new Qik();
32
- *
33
- * //Request the current user session endpoint from the Qik API
34
- * qik.api.get('/session').then(function(res) {
35
- * console.log('User session is ', res.data);
36
- * })
37
- * .catch(function(err) {
38
- * console.log('There was an error', err);
39
- * });
40
- *
41
- * //Use the QikAsset package to generate an image url
42
- * var link = qik.asset.imageUrl('5ca3d64dd2bb085eb9d450db', 1920, 1080)
43
- */
44
-
45
- import { version } from '../version.js';
46
-
47
- export default function(options) {
48
- if (!options) {
49
- options = {
50
- // apiURL,
51
- // applicationToken,
52
- // api:{}
53
- }
54
- }
55
-
56
- ///////////////////////////////////////
57
-
58
- if (!options.apiURL || !options.apiURL.length) {
59
- options.apiURL = 'staging';
60
- }
61
-
62
- ///////////////////////////////////////
63
-
64
- switch (String(options.apiURL).toLowerCase()) {
65
- case 'production':
66
- options.apiURL = 'https://api.qik.dev';
67
- break;
68
- case 'staging':
69
- options.apiURL = 'https://api.staging.qik.dev';
70
- break;
71
- case 'local':
72
- options.apiURL = 'http://api.qik.localhost:4001';
73
- break;
74
- }
75
-
76
- ///////////////////////////////////////
77
-
78
- const core = Object.assign(options, {
79
- //Other options
80
- // domain:'',
81
- version,
82
- })
83
-
84
-
85
- ///////////////////////////////////////
86
-
87
- /**
88
- * Provides a cache service, used for creating, clearing
89
- * and storing API requests and other information in memory
90
- * @type {QikCache}
91
- */
92
- const cache = QikCache;
93
- Object.defineProperty(core, 'cache', {
94
- value: cache,
95
- writable: false,
96
- });
97
-
98
- ///////////////////////////////////////
99
-
100
- /**
101
- * Provides helper functions for working
102
- * with Qik data
103
- * @type {QikUtils}
104
- */
105
- const utils = QikUtils;
106
- Object.defineProperty(core, 'utils', {
107
- value: utils,
108
- writable: false,
109
- });
110
-
111
- ///////////////////////////////////////
112
-
113
- /**
114
- * Provides helper functions for working
115
- * with Qik filters
116
- * @type {QikFilter}
117
- */
118
- const filter = QikFilter;
119
- Object.defineProperty(core, 'filter', {
120
- value: filter,
121
- writable: false,
122
- });
123
-
124
-
125
-
126
- ///////////////////////////////////////
127
-
128
- /**
129
- * Provides helper functions for working
130
- * with Qik files
131
- * @type {QikFiles}
132
- */
133
- const files = new QikFiles(core);
134
- Object.defineProperty(core, 'files', {
135
- value: files,
136
- writable: false,
137
- });
138
-
139
- ///////////////////////////////////////
140
-
141
- //Create a new global dispatcher so we can trigger events
142
- const dispatcher = new EventDispatcher();
143
- dispatcher.bootstrap(core);
144
-
145
- //Set the function
146
- core.error = function(err) {
147
- //Dispatch an error event
148
- return core.dispatch('error', utils.errorMessage(err));
149
- }
150
-
151
- //And enable notifications with a short message
152
- core.notify = function(message, options) {
153
- return core.dispatch('notification', { message, options });
154
- }
155
-
156
- ///////////////////////////////////////
157
-
158
- /**
159
- * The default service for interacting with
160
- * the Qik REST API, it's a wrapper around the axios library
161
- * that works in conjunction with the other Qik modules
162
- * @type {QikAPI}
163
- */
164
- const api = new QikAPI(core);
165
- Object.defineProperty(core, 'api', {
166
- value: api,
167
- writable: false,
168
- });
169
-
170
- /**
171
- * The default service for managing authentication
172
- * handles automatic refreshing of access tokens, and provides login, logout
173
- * and other user/application specific functionality
174
- * @type {QikAuth}
175
- */
176
- const auth = new QikAuth(core);
177
- Object.defineProperty(core, 'auth', {
178
- value: auth,
179
- writable: false,
180
- });
181
-
182
- /**
183
- * The default service for connecting, subscribing and unsubscribing sockets
184
- * @type {QikSocket}
185
- */
186
- const socket = new QikSocket(core);
187
- Object.defineProperty(core, 'socket', {
188
- value: socket,
189
- writable: false,
190
- });
191
-
192
- ///////////////////////////////////////
193
-
194
- /**
195
- * A helper service for understanding a user's access permissions
196
- * @type {QikAccess}
197
- */
198
- const access = new QikAccess(core);
199
- Object.defineProperty(core, 'access', {
200
- value: access,
201
- writable: false,
202
- });
203
-
204
- ///////////////////////////////////////
205
-
206
- /**
207
- * A helper service for system functions and features
208
- * @type {QikSystem}
209
- */
210
- const system = new QikSystem(core);
211
- Object.defineProperty(core, 'system', {
212
- value: system,
213
- writable: false,
214
- });
215
-
216
- ///////////////////////////////////////
217
-
218
- /**
219
- * A helper service for geolocation features
220
- * @type {QikGeo}
221
- */
222
- const geo = new QikGeo(core);
223
- Object.defineProperty(core, 'geo', {
224
- value: geo,
225
- writable: false,
226
- });
227
-
228
-
229
- ///////////////////////////////////////
230
-
231
- /**
232
- * A helper service for content create, update, read and delete operations.
233
- * @type {QikContent}
234
- */
235
- const content = new QikContent(core);
236
- Object.defineProperty(core, 'content', {
237
- value: content,
238
- writable: false,
239
- });
240
-
241
- ///////////////////////////////////////
242
-
243
- return core;
244
-
245
- }
@@ -1,186 +0,0 @@
1
-
2
- /**
3
- * Creates a new Files Module instance.
4
- * This module provides a number of helper functions for interacting with binary file and media content via the REST API
5
- * @alias files
6
- * @constructor
7
- * @hideconstructor
8
- * @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.
9
- */
10
- export default function(qik) {
11
-
12
-
13
- ///////////////////////
14
-
15
- var service = {};
16
-
17
- ///////////////////////
18
-
19
- /**
20
- *
21
- * Get a valid download url for a specified record
22
- * @alias files.downloadUrl
23
- * @param {String} type The type or definition of the item we want to generate the url for
24
- * @param {(Object|String)} id The id or object with an _id property that we want to generate the url for
25
- * @param {Object} params Additional parameters and options for the url
26
- * @param {Object} options Configuration options
27
- * @param {String} options.filename Provide an optional filename for the url
28
- * @param {Boolean} options.withoutToken Don't append an access token to the url
29
- * @example
30
- * const url = sdk.files.downloadUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
31
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
32
- *
33
- * const url = sdk.files.downloadUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
34
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
35
- *
36
- * const url = sdk.files.downloadUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100}, {filename:'image.jpg'});
37
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf/image.jpg?w=100&h=100&download=true
38
- */
39
- service.downloadUrl = function(type, id, params, options) {
40
- options = options || {}
41
- if (!('file' in options)) {
42
- // Default to file api for nuxt rendering
43
- options.file = true;
44
- }
45
-
46
- params = params || {};
47
- params.download = true;
48
- id = qik.utils.id(id);
49
-
50
- let url = `/${type}/${id}`;
51
-
52
- if(options.filename) {
53
- url = `${url}/${options.filename}`;
54
- }
55
-
56
- return qik.api.generateEndpointURL(url, params, options);
57
- }
58
-
59
- /**
60
- *
61
- * Get a valid media url for a specified image, video or audio item
62
- * @alias files.mediaUrl
63
- * @param {String} type The type or definition of the item we want to generate the url for
64
- * @param {(Object|String)} id The id or object with an _id property that we want to generate the url for
65
- * @param {Object} params Additional parameters and options for the url
66
- * @param {Object} options Configuration options
67
- * @param {String} options.filename Provide an optional filename for the url
68
- * @param {Boolean} options.withoutToken Don't append an access token to the url
69
- * @example
70
- * const url = sdk.files.mediaUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
71
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
72
- *
73
- * const url = sdk.files.mediaUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100}, {filename:'image.jpg'});
74
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf/image.jpg?w=100&h=100&download=true
75
- *
76
- * const url = sdk.files.mediaUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
77
- * // https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
78
- */
79
- service.mediaUrl = function(type, id, params, options) {
80
- options = options || {}
81
- if (!('file' in options)) {
82
- // Default to file api for nuxt rendering
83
- options.file = true;
84
- }
85
-
86
- params = params || {};
87
- id = qik.utils.id(id);
88
-
89
- let url = `/${type}/${id}`;
90
-
91
- if(options.filename) {
92
- url = `${url}/${options.filename}`;
93
- }
94
-
95
- return qik.api.generateEndpointURL(url, params, options);
96
- }
97
-
98
- ///////////////////////
99
-
100
- /**
101
- *
102
- * Convert bytes to a human readable file size
103
- * @alias files.filesize
104
- * @param {Integer} bytes The number of bytes
105
- * @example
106
- * const size = sdk.files.filesize(1500);
107
- * // 1.5kb
108
- */
109
- service.filesize = function(bytes, decimals) {
110
- if(bytes == 0) return '0 Bytes';
111
- var k = 1024,
112
- dm = decimals || 2,
113
- sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
114
- i = Math.floor(Math.log(bytes) / Math.log(k));
115
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
116
- }
117
-
118
- ///////////////////////
119
-
120
- /**
121
- *
122
- * Get the basic primitive type of a file from it's mime type value
123
- * @alias files.getBinaryTypeFromMime
124
- * @param {String} fileMime The mime type of the file
125
- * @example
126
- * const type = sdk.files.getBinaryTypeFromMime('image/svg+xml');
127
- * // 'image'
128
- *
129
- * const type = sdk.files.getBinaryTypeFromMime('video/webm');
130
- * // 'video'
131
- */
132
- service.getBinaryTypeFromMime = function(fileMime) {
133
-
134
- if (!fileMime) {
135
- return 'file';
136
- }
137
-
138
- ////////////////////////////////
139
-
140
- switch (fileMime) {
141
- case 'image/jpeg':
142
- case 'image/png':
143
- case 'image/gif':
144
- case 'image/bmp':
145
- case 'image/tiff':
146
- case 'image/svg+xml':
147
- return 'image';
148
- break;
149
- case 'video/mp4':
150
- case 'video/quicktime':
151
- case 'video/ogg':
152
- case 'video/webm':
153
- return 'video'
154
- break;
155
- case 'audio/aac':
156
- case 'audio/aiff':
157
- case 'audio/mp3':
158
- case 'audio/x-m4a':
159
- case 'audio/mpeg':
160
- case 'audio/ogg':
161
- case 'audio/wav':
162
- case 'audio/webm':
163
- return 'audio'
164
- break;
165
- default:
166
- //See if we can guess it from the first part of the mimetype
167
- var prefix = fileMime.split('/')[0];
168
- switch (prefix) {
169
- case 'image':
170
- case 'video':
171
- case 'audio':
172
- return prefix;
173
- break;
174
- default:
175
- return 'file';
176
- break;
177
- }
178
- break;
179
- }
180
- }
181
-
182
- ////////////////////////////////
183
-
184
- return service;
185
-
186
- }