@vocollege/app 0.0.58 → 0.0.60

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 (102) hide show
  1. package/dist/{types.d.ts → global.d.ts} +4 -0
  2. package/dist/{types.js → global.js} +0 -0
  3. package/dist/index.d.ts +3 -2
  4. package/dist/index.js +9 -3
  5. package/dist/interceptor.js +14 -9
  6. package/dist/modules/Services/I18n/I18n.js +1 -1
  7. package/dist/modules/Services/I18n/strings.json +515 -25
  8. package/dist/modules/Services/Vapor/Vapor.js +3 -1
  9. package/dist/modules/VoApi/GraphClient.d.ts +3 -2
  10. package/dist/modules/VoApi/GraphClient.js +51 -13
  11. package/dist/modules/VoApi/VoApi.d.ts +4 -1
  12. package/dist/modules/VoApi/VoApi.js +18 -2
  13. package/dist/modules/VoApi/graphql.d.ts +5 -0
  14. package/dist/modules/VoApi/graphql.js +12 -3
  15. package/dist/modules/VoApi/index.js +5 -1
  16. package/dist/modules/VoApi/mutations/acl.js +5 -5
  17. package/dist/modules/VoApi/mutations/applications.d.ts +3 -0
  18. package/dist/modules/VoApi/mutations/applications.js +12 -0
  19. package/dist/modules/VoApi/mutations/articles.js +3 -3
  20. package/dist/modules/VoApi/mutations/books.d.ts +3 -0
  21. package/dist/modules/VoApi/mutations/books.js +12 -0
  22. package/dist/modules/VoApi/mutations/cards.js +3 -3
  23. package/dist/modules/VoApi/mutations/events.js +3 -3
  24. package/dist/modules/VoApi/mutations/navigation.js +3 -3
  25. package/dist/modules/VoApi/mutations/pages.js +3 -3
  26. package/dist/modules/VoApi/mutations/queues.js +3 -3
  27. package/dist/modules/VoApi/mutations/sections.js +3 -3
  28. package/dist/modules/VoApi/mutations/settings.js +1 -1
  29. package/dist/modules/VoApi/mutations/users.js +3 -3
  30. package/dist/modules/VoApi/mutations/vodocs.js +9 -9
  31. package/dist/modules/VoApi/mutations/vogroups.d.ts +1 -0
  32. package/dist/modules/VoApi/mutations/vogroups.js +10 -9
  33. package/dist/modules/VoApi/queries/acl.js +4 -4
  34. package/dist/modules/VoApi/queries/applications.d.ts +2 -0
  35. package/dist/modules/VoApi/queries/applications.js +11 -0
  36. package/dist/modules/VoApi/queries/articles.js +2 -2
  37. package/dist/modules/VoApi/queries/books.d.ts +4 -0
  38. package/dist/modules/VoApi/queries/books.js +13 -0
  39. package/dist/modules/VoApi/queries/cards.js +2 -2
  40. package/dist/modules/VoApi/queries/events.js +2 -2
  41. package/dist/modules/VoApi/queries/help.d.ts +1 -0
  42. package/dist/modules/VoApi/queries/help.js +11 -0
  43. package/dist/modules/VoApi/queries/navigation.js +4 -4
  44. package/dist/modules/VoApi/queries/pages.js +2 -2
  45. package/dist/modules/VoApi/queries/queues.js +2 -2
  46. package/dist/modules/VoApi/queries/search.d.ts +2 -0
  47. package/dist/modules/VoApi/queries/search.js +5 -3
  48. package/dist/modules/VoApi/queries/sections.js +2 -2
  49. package/dist/modules/VoApi/queries/settings.js +1 -1
  50. package/dist/modules/VoApi/queries/users.d.ts +1 -0
  51. package/dist/modules/VoApi/queries/users.js +5 -4
  52. package/dist/modules/VoApi/queries/vodocs.js +3 -3
  53. package/dist/modules/VoApi/queries/vogroups.js +7 -7
  54. package/dist/modules/VoApp.d.ts +1 -0
  55. package/dist/modules/VoApp.js +17 -0
  56. package/dist/modules/VoAuth.d.ts +2 -1
  57. package/dist/modules/VoAuth.js +119 -38
  58. package/dist/modules/VoBase.js +2 -2
  59. package/dist/modules/VoConfig.js +9 -0
  60. package/dist/modules/VoDocs/VoDocs.js +7 -2
  61. package/dist/modules/VoGroups.d.ts +7 -0
  62. package/dist/modules/VoGroups.js +40 -0
  63. package/dist/modules/VoHelpers.d.ts +36 -1
  64. package/dist/modules/VoHelpers.js +320 -48
  65. package/dist/modules/VoRouter.js +10 -2
  66. package/dist/modules/VoUtils_REMOVE.js +9 -5
  67. package/package.json +17 -9
  68. package/src/global.ts +44 -0
  69. package/src/index.ts +3 -2
  70. package/src/interceptor.ts +15 -8
  71. package/src/modules/Services/I18n/strings.json +514 -24
  72. package/src/modules/Services/Vapor/Vapor.ts +2 -1
  73. package/src/modules/VoApi/GraphClient.ts +66 -8
  74. package/src/modules/VoApi/VoApi.ts +23 -3
  75. package/src/modules/VoApi/graphql.ts +5 -0
  76. package/src/modules/VoApi/mutations/applications.ts +27 -0
  77. package/src/modules/VoApi/mutations/books.ts +27 -0
  78. package/src/modules/VoApi/mutations/users.ts +5 -0
  79. package/src/modules/VoApi/mutations/vodocs.ts +2 -0
  80. package/src/modules/VoApi/mutations/vogroups.ts +21 -7
  81. package/src/modules/VoApi/queries/applications.ts +71 -0
  82. package/src/modules/VoApi/queries/articles.ts +1 -1
  83. package/src/modules/VoApi/queries/books.ts +113 -0
  84. package/src/modules/VoApi/queries/cards.ts +14 -1
  85. package/src/modules/VoApi/queries/events.ts +1 -1
  86. package/src/modules/VoApi/queries/help.ts +12 -0
  87. package/src/modules/VoApi/queries/navigation.ts +3 -4
  88. package/src/modules/VoApi/queries/pages.ts +1 -1
  89. package/src/modules/VoApi/queries/queues.ts +18 -1
  90. package/src/modules/VoApi/queries/search.ts +98 -1
  91. package/src/modules/VoApi/queries/sections.ts +1 -1
  92. package/src/modules/VoApi/queries/users.ts +74 -8
  93. package/src/modules/VoApi/queries/vodocs.ts +8 -4
  94. package/src/modules/VoApi/queries/vogroups.ts +40 -11
  95. package/src/modules/VoApp.ts +25 -8
  96. package/src/modules/VoAuth.ts +134 -37
  97. package/src/modules/VoConfig.ts +11 -0
  98. package/src/modules/VoDocs/VoDocs.ts +5 -0
  99. package/src/modules/VoGroups.ts +34 -0
  100. package/src/modules/VoHelpers.ts +254 -42
  101. package/src/modules/VoRouter.ts +10 -3
  102. package/src/types.ts +0 -38
@@ -1,15 +1,67 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
- to[j] = from[i];
5
- return to;
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
6
57
  };
7
58
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
60
  };
10
61
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.downloadFile = exports.wrapPromise = exports.createSlug2 = exports.getTemporaryId = exports.getError = exports.regexPatterns = exports.encodeQueryData = exports.localStorage = exports.createRandomString = exports.base64Url = void 0;
62
+ exports.convertSvgToImage = exports.getObjValue = exports.getGroupLogotype = exports.reducer = exports.changeObj = exports.parseState = exports.getUserString = exports.getContactName = exports.getImageDescription = exports.getImage = exports.getImageContact = exports.shortenText = exports.orderByField = exports.orderByPosition = exports.downloadFile = exports.wrapPromise = exports.createSlug2 = exports.getTemporaryId = exports.getError = exports.regexPatterns = exports.encodeQueryData = exports.localStorage = exports.createRandomString = exports.base64Url = void 0;
12
63
  var crypto_js_1 = __importDefault(require("crypto-js"));
64
+ var he_1 = __importDefault(require("he"));
13
65
  var base64Url = function (string) {
14
66
  return string
15
67
  .toString(crypto_js_1.default.enc.Base64)
@@ -19,11 +71,13 @@ var base64Url = function (string) {
19
71
  };
20
72
  exports.base64Url = base64Url;
21
73
  var createRandomString = function (num) {
22
- return __spreadArray([], Array(num)).map(function () { return Math.random().toString(36)[2]; }).join("");
74
+ return __spreadArray([], Array(num), true).map(function () { return Math.random().toString(36)[2]; }).join("");
23
75
  };
24
76
  exports.createRandomString = createRandomString;
25
77
  exports.localStorage = {
26
78
  set: function (key, value) {
79
+ if (typeof window === "undefined")
80
+ return false;
27
81
  try {
28
82
  window.localStorage.setItem(key, value);
29
83
  return true;
@@ -34,6 +88,8 @@ exports.localStorage = {
34
88
  }
35
89
  },
36
90
  get: function (key) {
91
+ if (typeof window === "undefined")
92
+ return false;
37
93
  try {
38
94
  var item = window.localStorage.getItem(key);
39
95
  return item;
@@ -66,8 +122,9 @@ exports.regexPatterns = {
66
122
  email: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
67
123
  stringNonDigit: /^[^0-9]+$/,
68
124
  password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/,
69
- cleanName: /(^[A-Za-z]{1,})(\w?)+$/,
125
+ cleanName: /(^[A-Za-z]{1,})(\w|-?)+$/,
70
126
  personalNumber: /^(\d{8})[-]\d{4}$/,
127
+ orgnr: /^(\d{6})[-]\d{4}$/,
71
128
  };
72
129
  var getError = function (error) {
73
130
  var message = "";
@@ -96,7 +153,7 @@ var getError = function (error) {
96
153
  };
97
154
  exports.getError = getError;
98
155
  var getTemporaryId = function () {
99
- return "new_" + Math.random().toString(36).substr(2, 12);
156
+ return "new_".concat(Math.random().toString(36).substr(2, 12));
100
157
  };
101
158
  exports.getTemporaryId = getTemporaryId;
102
159
  var createSlug2 = function (value) {
@@ -148,7 +205,7 @@ var wrapPromise = function (promise) {
148
205
  exports.wrapPromise = wrapPromise;
149
206
  var downloadFile = function (url) {
150
207
  try {
151
- var elId = "file-" + url;
208
+ var elId = "file-".concat(url);
152
209
  // Ensure that an old element is not left in the DOM.
153
210
  var el = document.getElementById(elId);
154
211
  if (el !== null && el.parentNode) {
@@ -171,44 +228,259 @@ var downloadFile = function (url) {
171
228
  }
172
229
  };
173
230
  exports.downloadFile = downloadFile;
174
- // const makeSortString = (function () {
175
- // var translate_re = /[öäåüÖÄÅÜ]/g;
176
- // var translate: { [key: string]: any } = {
177
- // å: "a",
178
- // ä: "a",
179
- // ö: "o",
180
- // ü: "u",
181
- // Å: "A",
182
- // Ä: "A",
183
- // Ö: "O",
184
- // Ü: "U", // probably more to come
185
- // };
186
- // return function (s: any) {
187
- // return s.replace(translate_re, function (match: any) {
188
- // return translate[match];
189
- // });
190
- // };
191
- // })();
192
- // const formatError = (error: string | [any]) => {
193
- // if (typeof error === "string") {
194
- // return error;
195
- // }
196
- // if (error.length === 1) {
197
- // return typeof error[0] === "object" ? error[0].message : error[0];
231
+ var orderByPosition = function (a, b) {
232
+ if (a.position < b.position) {
233
+ return -1;
234
+ }
235
+ if (a.position > b.position) {
236
+ return 1;
237
+ }
238
+ return 0;
239
+ };
240
+ exports.orderByPosition = orderByPosition;
241
+ var orderByField = function (a, b, field) {
242
+ if (a[field] < b[field]) {
243
+ return -1;
244
+ }
245
+ if (a[field] > b[field]) {
246
+ return 1;
247
+ }
248
+ return 0;
249
+ };
250
+ exports.orderByField = orderByField;
251
+ var shortenText = function (str, limit, stripHtml, addEllipsis) {
252
+ if (limit === void 0) { limit = 30; }
253
+ if (stripHtml === void 0) { stripHtml = true; }
254
+ if (addEllipsis === void 0) { addEllipsis = false; }
255
+ var output = "";
256
+ if (stripHtml) {
257
+ output = str.replace(/(<([^>]+)>)/gi, "");
258
+ output = he_1.default.decode(output);
259
+ }
260
+ if (addEllipsis) {
261
+ output += "...";
262
+ }
263
+ return output.substring(0, limit).trim();
264
+ };
265
+ exports.shortenText = shortenText;
266
+ var getImageContact = function (item, width, height) {
267
+ var _a, _b;
268
+ if (width === void 0) { width = 400; }
269
+ if (height === void 0) { height = 400; }
270
+ var entity = item.entity || item;
271
+ return entity.images && entity.images[0] && ((_a = entity.images[0]) === null || _a === void 0 ? void 0 : _a.url)
272
+ ? "".concat((_b = entity.images[0]) === null || _b === void 0 ? void 0 : _b.url, "?d=").concat(width, "x").concat(height)
273
+ : "/images/avatar-user.png";
274
+ };
275
+ exports.getImageContact = getImageContact;
276
+ var getImage = function (item, width, height, field) {
277
+ var _a;
278
+ if (field === void 0) { field = "images"; }
279
+ var entity = (item.images && item.images.length > 0) || !item.entity
280
+ ? item
281
+ : item.entity;
282
+ return entity[field] && entity[field][0]
283
+ ? "".concat((_a = entity[field][0]) === null || _a === void 0 ? void 0 : _a.url, "?d=").concat(width, "x").concat(height)
284
+ : "/images/avatar-content.png";
285
+ };
286
+ exports.getImage = getImage;
287
+ var getImageDescription = function (item, field) {
288
+ var _a;
289
+ if (field === void 0) { field = "images"; }
290
+ var entity = (item.images && item.images.length > 0) || !item.entity
291
+ ? item
292
+ : item.entity;
293
+ return entity[field] && ((_a = entity[field][0]) === null || _a === void 0 ? void 0 : _a.description);
294
+ };
295
+ exports.getImageDescription = getImageDescription;
296
+ var getContactName = function (item) {
297
+ if (!item) {
298
+ return "";
299
+ }
300
+ var name = [];
301
+ if (item.firstname) {
302
+ name.push(item.firstname);
303
+ }
304
+ if (item.lastname) {
305
+ name.push(item.lastname);
306
+ }
307
+ if (name.length === 0) {
308
+ name.push(item.name);
309
+ }
310
+ return name.join(" ");
311
+ };
312
+ exports.getContactName = getContactName;
313
+ var getUserString = function (item) {
314
+ if (!item) {
315
+ return "";
316
+ }
317
+ return "".concat((0, exports.getContactName)(item), " | ").concat(item.email);
318
+ };
319
+ exports.getUserString = getUserString;
320
+ var parseState = function (state, initialState) {
321
+ var newState = {};
322
+ for (var field in initialState) {
323
+ newState[field] = state[field];
324
+ }
325
+ return newState;
326
+ };
327
+ exports.parseState = parseState;
328
+ // This method is copied from
329
+ // https://stackoverflow.com/questions/6393943/convert-javascript-string-in-dot-notation-into-an-object-reference
330
+ //
331
+ // @TODO Maybe this entire logic can be replaced by Array.reduce(),
332
+ // something like this:
333
+ // let data = is.split(".").reduce((o: any, i) => o && o[i], pbj);
334
+ // data = value;
335
+ //
336
+ var changeObj = function (obj, is, value) {
337
+ if (typeof is == "string")
338
+ return (0, exports.changeObj)(obj, is.split("."), value);
339
+ else if (is.length == 1 && value !== undefined)
340
+ return (obj[is[0]] = value);
341
+ else if (is.length == 0)
342
+ return obj;
343
+ else
344
+ return (0, exports.changeObj)(obj[is[0]], is.slice(1), value);
345
+ };
346
+ exports.changeObj = changeObj;
347
+ var reducer = function (state, action) {
348
+ var _a;
349
+ var key = action.key, values = action.values;
350
+ if (!key) {
351
+ return __assign(__assign({}, state), values);
352
+ }
353
+ if (key === "loading") {
354
+ var i = state.loading.indexOf(values);
355
+ var newValues = __spreadArray([], state.loading, true);
356
+ if (i > -1) {
357
+ newValues.splice(i, 1);
358
+ }
359
+ else {
360
+ newValues.push(values);
361
+ }
362
+ return __assign(__assign({}, state), { loading: newValues });
363
+ }
364
+ if (key.indexOf(".") > -1) {
365
+ (0, exports.changeObj)(state, key, values);
366
+ return __assign({}, state);
367
+ }
368
+ return __assign(__assign({}, state), (_a = {}, _a[key] = values, _a));
369
+ };
370
+ exports.reducer = reducer;
371
+ var getGroupLogotype = function (group, logo, output) {
372
+ if (logo === void 0) { logo = "logo2"; }
373
+ if (output === void 0) { output = []; }
374
+ if (group && Array.isArray(group[logo]) && group[logo].length > 0) {
375
+ output.push.apply(output, group[logo]);
376
+ }
377
+ else if (group && group.parentGroups) {
378
+ return group.parentGroups.forEach(function (v) {
379
+ return (0, exports.getGroupLogotype)(v, logo, output);
380
+ });
381
+ }
382
+ return null;
383
+ };
384
+ exports.getGroupLogotype = getGroupLogotype;
385
+ // export const makeId = (length = 10) => {
386
+ // let result = "";
387
+ // let characters =
388
+ // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
389
+ // let charactersLength = characters.length;
390
+ // for (var i = 0; i < length; i++) {
391
+ // result += characters.charAt(Math.floor(Math.random() * charactersLength));
198
392
  // }
199
- // return (
200
- // <ul>
201
- // {error.map((v) => (
202
- // <li>{typeof error[0] === "object" ? error[0].message : error[0]}</li>
203
- // ))}
204
- // </ul>
205
- // );
206
- // };
207
- // export {
208
- // base64Url,
209
- // createRandomString,
210
- // localStorage,
211
- // encodeQueryData,
212
- // regexPatterns,
213
- // getError
393
+ // return result;
214
394
  // };
395
+ var getObjValue = function (obj) {
396
+ var props = [];
397
+ for (var _i = 1; _i < arguments.length; _i++) {
398
+ props[_i - 1] = arguments[_i];
399
+ }
400
+ return (obj &&
401
+ props.reduce(function (result, prop) { return (result == null ? undefined : result[prop]); }, obj));
402
+ };
403
+ exports.getObjValue = getObjValue;
404
+ /**
405
+ * Convert an SVG into an image.
406
+ * @param url
407
+ * @param width
408
+ * @param height
409
+ * @param format
410
+ * @param quality
411
+ * @returns Promise
412
+ *
413
+ * @note Convert logic inpired by
414
+ * https://levelup.gitconnected.com/draw-an-svg-to-canvas-and-download-it-as-image-in-javascript-f7f7713cf81f
415
+ * https://medium.com/@benjamin.black/using-blob-from-svg-text-as-image-source-2a8947af7a8e
416
+ *
417
+ * In this method we could actually assign "url" directly to "image.src" and then
418
+ * extract an image with canvas, but Firefox doesn't support drawing an SVG into
419
+ * canvas if it misses width/height attributes. Read more here:
420
+ * https://stackoverflow.com/questions/28690643/firefox-error-rendering-an-svg-image-to-html5-canvas-with-drawimage
421
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=700533
422
+ */
423
+ var convertSvgToImage = function (url, width, height, format, quality) {
424
+ if (width === void 0) { width = null; }
425
+ if (height === void 0) { height = null; }
426
+ if (format === void 0) { format = "image/png"; }
427
+ if (quality === void 0) { quality = 0.92; }
428
+ return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
429
+ var response, svg, parser, doc, viewBox, canvas_1, inlineSVG, svg64, image64, context_1, image_1, error_1;
430
+ var _a;
431
+ return __generator(this, function (_b) {
432
+ switch (_b.label) {
433
+ case 0:
434
+ _b.trys.push([0, 3, , 4]);
435
+ return [4 /*yield*/, fetch(url)];
436
+ case 1:
437
+ response = _b.sent();
438
+ return [4 /*yield*/, response.text()];
439
+ case 2:
440
+ svg = _b.sent();
441
+ parser = new DOMParser();
442
+ doc = parser.parseFromString(svg, "image/svg+xml");
443
+ viewBox = (_a = doc.documentElement.getAttribute("viewBox")) === null || _a === void 0 ? void 0 : _a.split(" ");
444
+ canvas_1 = document.createElement("canvas");
445
+ if (!width) {
446
+ canvas_1.width = viewBox && viewBox[2] ? parseInt(viewBox[2]) : 100;
447
+ }
448
+ else {
449
+ canvas_1.width = width;
450
+ }
451
+ if (!height && !width) {
452
+ canvas_1.height = viewBox && viewBox[3] ? parseInt(viewBox[3]) : 100;
453
+ }
454
+ else if (!height) {
455
+ canvas_1.height =
456
+ viewBox && viewBox[3]
457
+ ? (parseInt(viewBox[3]) / parseInt(viewBox[2])) * canvas_1.width
458
+ : 100;
459
+ }
460
+ else {
461
+ canvas_1.height = height;
462
+ }
463
+ inlineSVG = doc.getElementsByTagName("svg")[0];
464
+ inlineSVG.setAttribute("width", "".concat(canvas_1.width, "px"));
465
+ inlineSVG.setAttribute("height", "".concat(canvas_1.height, "px"));
466
+ svg64 = btoa(new XMLSerializer().serializeToString(inlineSVG));
467
+ image64 = "data:image/svg+xml;base64," + svg64;
468
+ context_1 = canvas_1.getContext("2d");
469
+ image_1 = new Image();
470
+ image_1.onload = function () {
471
+ context_1 === null || context_1 === void 0 ? void 0 : context_1.drawImage(image_1, 0, 0);
472
+ var result = canvas_1.toDataURL(format, quality);
473
+ resolve(result);
474
+ };
475
+ image_1.src = image64;
476
+ return [3 /*break*/, 4];
477
+ case 3:
478
+ error_1 = _b.sent();
479
+ reject(error_1);
480
+ return [3 /*break*/, 4];
481
+ case 4: return [2 /*return*/];
482
+ }
483
+ });
484
+ }); });
485
+ };
486
+ exports.convertSvgToImage = convertSvgToImage;
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ var js_cookie_1 = __importDefault(require("js-cookie"));
7
+ // Custom.
6
8
  var VoConfig_1 = __importDefault(require("./VoConfig"));
7
9
  var VoRouter = /** @class */ (function () {
8
10
  function VoRouter() {
@@ -25,6 +27,8 @@ var VoRouter = /** @class */ (function () {
25
27
  return params[arg];
26
28
  };
27
29
  VoRouter.prototype.isCurrentRouterProtected = function () {
30
+ if (typeof window === "undefined")
31
+ return false;
28
32
  var currentPath = this.getPath(window.location.pathname, 0);
29
33
  // const routes = VoConfig.getConfigByKey('routes');
30
34
  var routes = this.getRoutes();
@@ -46,9 +50,13 @@ var VoRouter = /** @class */ (function () {
46
50
  var webUrl = [];
47
51
  if (VoConfig_1.default.get.AUTH_BASE_URL) {
48
52
  webUrl.push(VoConfig_1.default.get.AUTH_BASE_URL + "/logout");
49
- if (VoConfig_1.default.get.BASE_URL) {
50
- webUrl.push("?redirect=" + VoConfig_1.default.get.BASE_URL);
53
+ var redirectTo = js_cookie_1.default.get("voapp_redirectTo") || VoConfig_1.default.get.BASE_URL;
54
+ if (redirectTo) {
55
+ webUrl.push("?redirect=".concat(redirectTo));
51
56
  }
57
+ // if (VoConfig.get.BASE_URL) {
58
+ // webUrl.push(`?redirect=${VoConfig.get.BASE_URL}`);
59
+ // }
52
60
  }
53
61
  if (webUrl.length > 0) {
54
62
  window.location.href = webUrl.join("");
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
- to[j] = from[i];
5
- return to;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
6
10
  };
7
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -20,7 +24,7 @@ var base64Url = function (string) {
20
24
  };
21
25
  exports.base64Url = base64Url;
22
26
  var createRandomString = function (num) {
23
- return __spreadArray([], Array(num)).map(function () { return Math.random().toString(36)[2]; }).join("");
27
+ return __spreadArray([], Array(num), true).map(function () { return Math.random().toString(36)[2]; }).join("");
24
28
  };
25
29
  exports.createRandomString = createRandomString;
26
30
  var localStorage = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocollege/app",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -10,30 +10,38 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "devDependencies": {
13
- "@apollo/client": "^3.3.7",
13
+ "@apollo/client": "^3.4.0",
14
14
  "@casl/ability": "^5.2.2",
15
15
  "@casl/react": "^2.2.2",
16
16
  "@types/apollo-upload-client": "^14.1.0",
17
17
  "@types/crypto-js": "^4.0.1",
18
+ "@types/he": "^1.1.2",
19
+ "@types/js-cookie": "^3.0.2",
18
20
  "@types/node": "^14.14.21",
19
- "@types/react": "^17.0.0",
20
- "apollo-upload-client": "^14.1.3",
21
+ "@types/react": "^18.0.9",
22
+ "@types/ws": "^8.2.2",
23
+ "apollo-upload-client": "^16.0.0",
21
24
  "axios": "^0.21.1",
22
25
  "crypto-js": "^4.0.0",
23
26
  "graphql": "^14.0.0 || ^15.0.0",
24
- "react": "^17.0.0",
25
- "react-toastify": "^7.0.3",
27
+ "he": "^1.2.0",
28
+ "js-cookie": "^3.0.1",
29
+ "react": "^18.1.0",
30
+ "react-toastify": "^8.0.0",
26
31
  "typescript": "^4.1.3"
27
32
  },
28
33
  "peerDependencies": {
29
34
  "@apollo/client": "^3.3.7",
30
35
  "@casl/ability": "^5.2.2",
31
36
  "@casl/react": "^2.2.2",
32
- "apollo-upload-client": "^14.1.3",
37
+ "apollo-upload-client": "^16.0.0",
33
38
  "axios": "^0.21.1",
34
39
  "crypto-js": "^4.0.0",
35
40
  "graphql": "^14.0.0 || ^15.0.0",
36
- "react": "^17.0.0",
37
- "react-toastify": "^7.0.3"
41
+ "he": "^1.2.0",
42
+ "js-cookie": "^3.0.1",
43
+ "react": "^18.1.0",
44
+ "react-toastify": "^8.0.0",
45
+ "subscriptions-transport-ws": "^0.11.0"
38
46
  }
39
47
  }
package/src/global.ts ADDED
@@ -0,0 +1,44 @@
1
+ export type AuthStorageConfigType = {
2
+ STATE: string;
3
+ VERIFIER: string;
4
+ REFRESH_TOKEN: string;
5
+ ACCESS_TOKEN: string;
6
+ TOKEN_TYPE: string;
7
+ EXPIRES_IN: string;
8
+ };
9
+ export type AuthConfigType = {
10
+ BASE_URL: string;
11
+ CLIENT_ID?: string;
12
+ LOGIN?: string;
13
+ ENDPOINT?: string;
14
+ STORAGE?: AuthStorageConfigType;
15
+ };
16
+ export type ApiConfigType = {
17
+ BASE_URL: string;
18
+ ENDPOINT?: string;
19
+ GRAPHQL?: string;
20
+ };
21
+ export type AppConfigType = {
22
+ BASE_URL: string;
23
+ AUTH?: string;
24
+ HOME?: string;
25
+ LOGIN?: string;
26
+ };
27
+ export type VoAppType = {
28
+ configure: Function;
29
+ config?: Function;
30
+ auth: any;
31
+ api: any;
32
+ };
33
+ export type VoTokenType = {
34
+ token_type: string;
35
+ access_token: string;
36
+ refresh_token: string;
37
+ expires_in: string;
38
+ };
39
+
40
+ export interface GeneralObject {
41
+ [key: string]: any;
42
+ }
43
+
44
+ export type TypeNullObject = null | GeneralObject;
package/src/index.ts CHANGED
@@ -4,10 +4,11 @@ import VoAuth from "./modules/VoAuth";
4
4
  import VoRouter from "./modules/VoRouter";
5
5
  import VoConfig from "./modules/VoConfig";
6
6
  import VoDocs from "./modules/VoDocs";
7
+ import VoGroups from "./modules/VoGroups";
7
8
  import "./interceptor";
8
- export { VoApi, VoApp, VoAuth, VoRouter, VoConfig, VoDocs };
9
+ export { VoApi, VoApp, VoAuth, VoRouter, VoConfig, VoDocs, VoGroups };
9
10
  export * from "./modules/VoApi";
10
11
  export * from "./modules/VoHelpers";
11
12
  export * from "./modules/Services";
12
- export * from "./types";
13
+ export * from "./global";
13
14
  export default VoApp;
@@ -1,6 +1,7 @@
1
1
  import axios from "axios";
2
2
  import VoAuth from "./modules/VoAuth";
3
3
  import VoRouter from "./modules/VoRouter";
4
+ // import VoApp from "./modules/VoApp";
4
5
  import { toast } from "react-toastify";
5
6
 
6
7
  // Custom.
@@ -38,7 +39,7 @@ import I18n from "./modules/Services/I18n";
38
39
  switch (status) {
39
40
  case 400:
40
41
  case 401:
41
- case 403:
42
+ // case 403:
42
43
  try {
43
44
  await VoAuth.refreshToken();
44
45
  const token: any = VoAuth.getToken();
@@ -68,13 +69,19 @@ import I18n from "./modules/Services/I18n";
68
69
  // console.error("Interceptor", error);
69
70
  // return Promise.reject(error);
70
71
  return new Promise((resolve, reject) => {
71
- if (status && status === 419) {
72
- toast.error(I18n.get.messages.sessionExpired);
73
- setTimeout(() => {
74
- redirect();
75
- }, 5000);
76
- } else {
77
- reject(error);
72
+ switch (status) {
73
+ // case 403:
74
+ // reject(error);
75
+ // break;
76
+ case 419:
77
+ toast.error(I18n.get.messages.sessionExpired);
78
+ setTimeout(() => {
79
+ redirect();
80
+ }, 5000);
81
+ break;
82
+ default:
83
+ reject(error);
84
+ break;
78
85
  }
79
86
  console.error("Interceptor", error);
80
87
  });