@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,543 +0,0 @@
1
- /**
2
- * @name filter
3
- * @classdesc Provides functions helpful for interacting with the filtering system
4
- * @class
5
- */
6
-
7
-
8
-
9
- ///////////////////////
10
-
11
- var service = {};
12
-
13
-
14
- ///////////////////////
15
-
16
-
17
- function isEmpty(value) {
18
- if (value === 0) {
19
- return false;
20
- }
21
-
22
- var empty = typeof value === 'undefined' || value === null || String(value).trim() === '';
23
-
24
- if (empty) {
25
- return true;
26
- }
27
-
28
- //If it's a string of undefined or null then treat it as empty also
29
- if (value === 'undefined' || value === 'null') {
30
- return true;
31
- }
32
-
33
- return false;
34
- }
35
-
36
- function compactFunction(val) {
37
- return !isEmpty(val)
38
- }
39
-
40
-
41
- ///////////////////////
42
-
43
- service.cleanKey = function(key) {
44
- key = String(key).split('|')[0];
45
-
46
- if (key[0] == '.') {
47
- key = key.slice(1);
48
- }
49
-
50
- return key;
51
- }
52
-
53
- ///////////////////////
54
-
55
- /**
56
- * @description Check if an object is a valid filter
57
- * @alias filter.isValidFilter
58
- * @param {Object} filter The filter block to check
59
- * @example
60
- * // Missing a 'key'
61
- * const invalidFilter = sdk.filter.isValidFilter({comparator:'in', values:['Red', 'Green', 'Blue']})
62
- * // returns false
63
- *
64
- * const validFilter = sdk.filter.isValidFilter({key:'favoriteColor', comparator:'in', values:['Red', 'Green', 'Blue']})
65
- * // returns true
66
- */
67
- service.isValidFilter = function(filter) {
68
- if (!filter) {
69
- return false;
70
- }
71
-
72
- ///////////////////////////
73
-
74
- //If the filter has nested filters consider it valid
75
- //if it has valid child filters
76
- if (filter.operator) {
77
- if (!filter.filters || !filter.filters.length) {
78
- return false;
79
- }
80
-
81
- return filter.filters.some(service.isValidFilter);
82
- }
83
-
84
- // ///////////////////////////
85
-
86
- // //Get the comparator for the filter
87
- // var comparator = hash[filter.comparator];
88
- // if (!comparator) {
89
- // //No comparator was specified for the filter
90
- // return false;
91
- // }
92
-
93
- ///////////////////////////
94
-
95
- var key = service.cleanKey(filter.key);
96
- if (!key) {
97
- //No key has been specified for the filter
98
- return false;
99
- }
100
-
101
- // if(filter.comparator.inputType === 'none') {
102
- // console.log('COMPARATOR IS EMPTY')
103
- // return true;
104
- // }
105
-
106
-
107
- switch (filter.comparator) {
108
- case 'empty':
109
- case 'notempty':
110
- case 'datetoday':
111
- case 'datenottoday':
112
- case 'datebeforetoday':
113
- case 'dateaftertoday':
114
- case 'dateweektoday':
115
- case 'datemonthtoday':
116
- case 'datebeforenow':
117
- case 'dateafternow':
118
- case 'datethisweek':
119
- case 'datethismonth':
120
- return true;
121
- break;
122
- }
123
-
124
-
125
-
126
- var multiValues = (filter.values || []).filter(compactFunction);
127
-
128
-
129
-
130
- return !isEmpty(filter.value) || !isEmpty(filter.value2) || multiValues.length;
131
- // ///////////////////////////
132
-
133
- // switch (filter.inputType) {
134
- // case 'none':
135
- // //If we are checking empty/notempty
136
- // //the filter is always valid without any extra parameters
137
- // return true;
138
- // break;
139
- // case 'range':
140
- // //If we are filtering a number range
141
- // //we need the start and end of the range
142
- // if (!filter.value || isNaN(filter.value)) {
143
- // return false;
144
- // }
145
-
146
- // if (!filter.value2 || isNaN(filter.value2)) {
147
- // return false;
148
- // }
149
- // break;
150
- // case 'daterange':
151
- // if (!filter.value || !parseDate(filter.value)) {
152
- // return false;
153
- // }
154
-
155
- // if (!filter.value2 || !parseDate(filter.value2)) {
156
- // return false;
157
- // }
158
- // break;
159
- // case 'array':
160
- // if (!filter.values || !filter.values.length) {
161
- // return false;
162
- // }
163
- // break;
164
- // default:
165
- // // if (filter.dataType == 'boolean') {
166
- // // //Check if they provided a valid boolean value to the filter
167
- // // return validBooleans[String(filter.value).toLowerCase()];
168
- // // } else {
169
- // // //The filter has not been provided with a value
170
- // if (isEmpty(filter.value)) {
171
- // return false;
172
- // }
173
- // // }
174
- // break;
175
- // }
176
-
177
- ///////////////////////////
178
-
179
- //If we got this far then the information
180
- //provided to the filter is enough to run it
181
- return true;
182
-
183
- }
184
-
185
- ////////////////////////////////////////////////
186
-
187
- /**
188
- *
189
- * @description Returns an array of all active filters
190
- * @alias filter.activeFilters
191
- * @param {Object} filterConfiguration A filter configuration object
192
- * @example
193
- *
194
- * const filterConfiguration = {
195
- * "operator": "and",
196
- * "filters": [
197
- * {
198
- * "operator": "and",
199
- * "filters": [
200
- * {
201
- * "key": "formData.person.firstName",
202
- * "comparator": "startswith",
203
- * "value": "c"
204
- * },
205
- * {
206
- * "key": "invalid no comparator",
207
- * "value": "e"
208
- * }
209
- * {
210
- * "key": "formData.person.lastName",
211
- * "comparator": "endswith",
212
- * "value": "e"
213
- * }
214
- * ]
215
- * }
216
- * ]
217
- * }
218
- *
219
- * const activeFilters = sdk.filter.activeFilters(filterConfiguration);
220
- *
221
- * const returns = [
222
- * {
223
- * "key": "formData.person.firstName",
224
- * "comparator": "startswith",
225
- * "value": "c"
226
- * },
227
- * {
228
- * "key": "formData.person.lastName",
229
- * "comparator": "endswith",
230
- * "value": "e"
231
- * }]
232
- *
233
- */
234
- service.activeFilters = function(filterConfiguration) {
235
- var memo = [];
236
-
237
- retrieveActiveFilter(filterConfiguration, memo);
238
-
239
- return memo;
240
-
241
- ////////////////////////////
242
-
243
- function retrieveActiveFilter(filterBlock, memo) {
244
- if (!filterBlock) {
245
- return;
246
- }
247
-
248
- var isValid = service.isValidFilter(filterBlock);
249
-
250
- if (isValid) {
251
- memo.push(filterBlock);
252
- }
253
-
254
- if (filterBlock.filters && filterBlock.filters.length) {
255
- filterBlock.filters.forEach(function(b) {
256
- retrieveActiveFilter(b, memo);
257
- })
258
- }
259
- }
260
- }
261
-
262
- ////////////////////////////////////////////////
263
-
264
-
265
- /**
266
- *
267
- * @description Returns an array of all keys that are being actively filtered on
268
- * @alias filter.activeFilterKeys
269
- * @param {Object} filterConfiguration A filter configuration object
270
- * @example
271
- *
272
- * const filterConfiguration = {
273
- * "operator": "and",
274
- * "filters": [
275
- * {
276
- * "operator": "and",
277
- * "filters": [
278
- * {
279
- * "key": "formData.person.firstName",
280
- * "comparator": "startswith",
281
- * "value": "c"
282
- * },
283
- * {
284
- * "key": "invalid no comparator",
285
- * "value": "e"
286
- * }
287
- * {
288
- * "key": "formData.person.lastName",
289
- * "comparator": "endswith",
290
- * "value": "e"
291
- * }
292
- * ]
293
- * }
294
- * ]
295
- * }
296
- *
297
- * const activeFilters = sdk.filter.activeFilterKeys(filterConfiguration);
298
- * // Returns ['formData.person.firstName', 'formData.person.lastName']
299
- *
300
- */
301
- service.activeFilterKeys = function(filterConfiguration, options) {
302
- options = options || {}
303
-
304
- var activeFilters = service.activeFilters(filterConfiguration);
305
- var value = activeFilters
306
- .filter(function(entry) {
307
- //Ignore all the wrapping entries
308
- return !entry.operator;
309
- })
310
- .reduce(function(set, filter) {
311
- var rootKey = service.cleanKey(filter.key);
312
- if (options.trimArrayDelimeters !== false) {
313
- rootKey = rootKey.split('[]').join('');
314
- }
315
- set[rootKey] = true;
316
- return set;
317
- }, {});
318
-
319
- var keys = Object.keys(value);
320
-
321
- return keys;
322
- };
323
-
324
-
325
- /**
326
- *
327
- * @description Returns an array of all comparators that are being actively filtered
328
- * @alias filter.activeFilterKeys
329
- * @param {Object} filterConfiguration A filter configuration object
330
- * @example
331
- *
332
- * const filterConfiguration = {
333
- * "operator": "and",
334
- * "filters": [
335
- * {
336
- * "operator": "and",
337
- * "filters": [
338
- * {
339
- * "key": "formData.person.firstName",
340
- * "comparator": "startswith",
341
- * "value": "c"
342
- * },
343
- * {
344
- * "key": "invalid no comparator",
345
- * "value": "e"
346
- * }
347
- * {
348
- * "key": "formData.person.lastName",
349
- * "comparator": "endswith",
350
- * "value": "e"
351
- * }
352
- * ]
353
- * }
354
- * ]
355
- * }
356
- *
357
- * const activeFilters = sdk.filter.activeFilterKeys(filterConfiguration);
358
- * // Returns ['startswith', 'endswith']
359
- *
360
- */
361
- service.activeFilterComparators = function(filterConfiguration) {
362
- var comparators = service.activeFilters(filterConfiguration)
363
- .filter(function(entry) {
364
- //Ignore all the wrapping entries
365
- return !entry.operator;
366
- })
367
- .reduce(function(set, filter) {
368
- set[filter.comparator] = true;
369
- return set;
370
- }, {})
371
-
372
- return Object.keys(comparators);
373
- }
374
-
375
- /**
376
- *
377
- * @description Returns an array of all comparators that are being actively filtered
378
- * @alias filter.activeFilterOperators
379
- * @param {Object} filterConfiguration A filter configuration object
380
- * @example
381
- *
382
- * const filterConfiguration = {
383
- * "operator": "and",
384
- * "filters": [
385
- * {
386
- * "operator": "nor",
387
- * "filters": [
388
- * {
389
- * "key": "formData.person.firstName",
390
- * "comparator": "startswith",
391
- * "value": "c"
392
- * },
393
- * {
394
- * "key": "invalid no comparator",
395
- * "value": "e"
396
- * }
397
- * {
398
- * "key": "formData.person.lastName",
399
- * "comparator": "endswith",
400
- * "value": "e"
401
- * }
402
- * ]
403
- * }
404
- * ]
405
- * }
406
- *
407
- * const activeFilterOperators = sdk.filter.activeFilterOperators(filterConfiguration);
408
- * // Returns ['and', 'nor']
409
- *
410
- */
411
- service.activeFilterOperators = function(filterConfiguration) {
412
- var operators = service.activeFilters(filterConfiguration)
413
- .filter(function(entry) {
414
- return entry.operator;
415
- })
416
- .reduce(function(set, filter) {
417
- set[filter.operator] = true;
418
- return set;
419
- }, {})
420
-
421
- return Object.keys(operators);
422
- }
423
-
424
-
425
- /**
426
- *
427
- * @description Returns an array of all values that are being actively used by a filter
428
- * @alias filter.activeFilterValues
429
- * @param {Object} filterConfiguration A filter configuration object
430
- * @example
431
- *
432
- * const filterConfiguration = {
433
- * "operator": "and",
434
- * "filters": [
435
- * {
436
- * "operator": "nor",
437
- * "filters": [
438
- * {
439
- * "key": "formData.person.firstName",
440
- * "comparator": "startswith",
441
- * "value": "c"
442
- * },
443
- * {
444
- * "key": "invalid no comparator",
445
- * "value": "e"
446
- * }
447
- * {
448
- * "key": "formData.person.lastName",
449
- * "comparator": "endswith",
450
- * "value": "a"
451
- * }
452
- * ]
453
- * }
454
- * ]
455
- * }
456
- *
457
- * const activeFilterValues = sdk.filter.activeFilterValues(filterConfiguration);
458
- * // Returns ['c', 'a']
459
- *
460
- */
461
- service.activeFilterValues = function(filterConfiguration, options) {
462
-
463
- options = options || {};
464
-
465
- var activeFilters = service.activeFilters(filterConfiguration);
466
-
467
- function mapValue(v) {
468
- if (!v) {
469
- return;
470
- }
471
-
472
- return v._id || v.id || v.title || v.name || v;
473
- }
474
-
475
- var values = activeFilters
476
- .filter(function(entry) {
477
- //Ignore all the wrapping entries
478
- return !entry.operator;
479
- })
480
- .reduce(function(set, filter) {
481
- set = [...set, ...(filter.values || []).map(mapValue), mapValue(filter.value), mapValue(filter.value2)];
482
- return set;
483
- }, [])
484
- .filter(compactFunction);
485
-
486
-
487
-
488
- return values;
489
- }
490
-
491
-
492
- /**
493
- *
494
- * @description Returns an string representation of a filter configuration.
495
- * Often used to check if a user has changed the filter in any way, the string only takes into consideration active valid filters
496
- * @alias filter.filterChangeString
497
- * @param {Object} filterConfiguration A filter configuration object
498
- * @example
499
- *
500
- * const filterConfiguration = {
501
- * "operator": "and",
502
- * "filters": [
503
- * {
504
- * "operator": "nor",
505
- * "filters": [
506
- * {
507
- * "key": "formData.person.firstName",
508
- * "comparator": "startswith",
509
- * "value": "c"
510
- * },
511
- * {
512
- * "key": "invalid no comparator",
513
- * "value": "e"
514
- * }
515
- * {
516
- * "key": "formData.person.lastName",
517
- * "comparator": "endswith",
518
- * "value": "a"
519
- * }
520
- * ]
521
- * }
522
- * ]
523
- * }
524
- *
525
- * // Watch this string for changes
526
- * const changeString = sdk.filter.filterChangeString(filterConfiguration);
527
- */
528
- service.filterChangeString = function(config) {
529
-
530
- var activeFilters = service.activeFilters(config);
531
- return JSON.stringify(activeFilters);
532
- // const string = [
533
- // service.activeFilterKeys(config).join(', '),
534
- // service.activeFilterValues(config).join(', '),
535
- // service.activeFilterComparators(config).join(', '),
536
- // service.activeFilterOperators(config).join(', '),
537
- // ]
538
- // return string.filter(compactFunction).join(', ');
539
- };
540
-
541
- ///////////////////////
542
-
543
- export default service;