@vocollege/app 0.0.56 → 0.0.59
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.
- package/dist/{types.d.ts → global.d.ts} +4 -0
- package/dist/{types.js → global.js} +0 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -3
- package/dist/interceptor.js +41 -12
- package/dist/modules/Services/I18n/I18n.js +1 -1
- package/dist/modules/Services/I18n/strings.json +716 -21
- package/dist/modules/Services/Vapor/Vapor.js +15 -7
- package/dist/modules/VoApi/GraphClient.d.ts +3 -2
- package/dist/modules/VoApi/GraphClient.js +57 -14
- package/dist/modules/VoApi/VoApi.d.ts +4 -1
- package/dist/modules/VoApi/VoApi.js +20 -2
- package/dist/modules/VoApi/graphql.d.ts +32 -0
- package/dist/modules/VoApi/graphql.js +57 -0
- package/dist/modules/VoApi/index.d.ts +1 -21
- package/dist/modules/VoApi/index.js +7 -31
- package/dist/modules/VoApi/mutations/acl.js +5 -5
- package/dist/modules/VoApi/mutations/applications.d.ts +3 -0
- package/dist/modules/VoApi/mutations/applications.js +12 -0
- package/dist/modules/VoApi/mutations/articles.js +3 -3
- package/dist/modules/VoApi/mutations/books.d.ts +3 -0
- package/dist/modules/VoApi/mutations/books.js +12 -0
- package/dist/modules/VoApi/mutations/cards.d.ts +3 -0
- package/dist/modules/VoApi/mutations/cards.js +12 -0
- package/dist/modules/VoApi/mutations/events.d.ts +3 -0
- package/dist/modules/VoApi/mutations/events.js +12 -0
- package/dist/modules/VoApi/mutations/navigation.js +3 -3
- package/dist/modules/VoApi/mutations/pages.js +3 -3
- package/dist/modules/VoApi/mutations/queues.js +3 -3
- package/dist/modules/VoApi/mutations/sections.d.ts +3 -0
- package/dist/modules/VoApi/mutations/sections.js +12 -0
- package/dist/modules/VoApi/mutations/settings.js +1 -1
- package/dist/modules/VoApi/mutations/users.js +3 -3
- package/dist/modules/VoApi/mutations/vodocs.js +9 -9
- package/dist/modules/VoApi/mutations/vogroups.d.ts +1 -0
- package/dist/modules/VoApi/mutations/vogroups.js +10 -9
- package/dist/modules/VoApi/queries/acl.js +4 -4
- package/dist/modules/VoApi/queries/applications.d.ts +2 -0
- package/dist/modules/VoApi/queries/applications.js +11 -0
- package/dist/modules/VoApi/queries/articles.js +2 -2
- package/dist/modules/VoApi/queries/books.d.ts +4 -0
- package/dist/modules/VoApi/queries/books.js +13 -0
- package/dist/modules/VoApi/queries/cards.d.ts +2 -0
- package/dist/modules/VoApi/queries/cards.js +11 -0
- package/dist/modules/VoApi/queries/events.d.ts +2 -0
- package/dist/modules/VoApi/queries/events.js +11 -0
- package/dist/modules/VoApi/queries/help.d.ts +1 -0
- package/dist/modules/VoApi/queries/help.js +11 -0
- package/dist/modules/VoApi/queries/navigation.js +4 -4
- package/dist/modules/VoApi/queries/pages.js +2 -2
- package/dist/modules/VoApi/queries/queues.js +2 -2
- package/dist/modules/VoApi/queries/search.d.ts +2 -0
- package/dist/modules/VoApi/queries/search.js +5 -3
- package/dist/modules/VoApi/queries/sections.d.ts +2 -0
- package/dist/modules/VoApi/queries/sections.js +11 -0
- package/dist/modules/VoApi/queries/settings.js +1 -1
- package/dist/modules/VoApi/queries/users.d.ts +1 -0
- package/dist/modules/VoApi/queries/users.js +5 -4
- package/dist/modules/VoApi/queries/vodocs.js +3 -3
- package/dist/modules/VoApi/queries/vogroups.d.ts +1 -0
- package/dist/modules/VoApi/queries/vogroups.js +9 -8
- package/dist/modules/VoApp.d.ts +1 -0
- package/dist/modules/VoApp.js +17 -0
- package/dist/modules/VoAuth.d.ts +2 -1
- package/dist/modules/VoAuth.js +126 -42
- package/dist/modules/VoBase.js +2 -2
- package/dist/modules/VoConfig.js +10 -0
- package/dist/modules/VoDocs/VoDocs.d.ts +1 -2
- package/dist/modules/VoDocs/VoDocs.js +12 -44
- package/dist/modules/VoGroups.d.ts +7 -0
- package/dist/modules/VoGroups.js +39 -0
- package/dist/modules/VoHelpers.d.ts +38 -1
- package/dist/modules/VoHelpers.js +348 -51
- package/dist/modules/VoRouter.js +10 -2
- package/dist/modules/{VoUtils.d.ts → VoUtils_REMOVE.d.ts} +1 -1
- package/dist/modules/{VoUtils.js → VoUtils_REMOVE.js} +16 -12
- package/package.json +17 -8
- package/src/global.ts +44 -0
- package/src/index.ts +3 -2
- package/src/interceptor.ts +39 -8
- package/src/modules/Services/I18n/strings.json +718 -22
- package/src/modules/Services/Vapor/Vapor.ts +14 -15
- package/src/modules/VoApi/GraphClient.ts +87 -24
- package/src/modules/VoApi/VoApi.ts +23 -3
- package/src/modules/VoApi/graphql.ts +47 -0
- package/src/modules/VoApi/index.ts +1 -37
- package/src/modules/VoApi/mutations/applications.ts +27 -0
- package/src/modules/VoApi/mutations/books.ts +27 -0
- package/src/modules/VoApi/mutations/cards.ts +27 -0
- package/src/modules/VoApi/mutations/events.ts +27 -0
- package/src/modules/VoApi/mutations/queues.ts +9 -1
- package/src/modules/VoApi/mutations/sections.ts +27 -0
- package/src/modules/VoApi/mutations/settings.ts +11 -3
- package/src/modules/VoApi/mutations/users.ts +19 -9
- package/src/modules/VoApi/mutations/vodocs.ts +4 -0
- package/src/modules/VoApi/mutations/vogroups.ts +21 -7
- package/src/modules/VoApi/queries/applications.ts +71 -0
- package/src/modules/VoApi/queries/articles.ts +26 -4
- package/src/modules/VoApi/queries/books.ts +101 -0
- package/src/modules/VoApi/queries/cards.ts +87 -0
- package/src/modules/VoApi/queries/events.ts +80 -0
- package/src/modules/VoApi/queries/help.ts +12 -0
- package/src/modules/VoApi/queries/navigation.ts +3 -4
- package/src/modules/VoApi/queries/pages.ts +29 -4
- package/src/modules/VoApi/queries/queues.ts +69 -4
- package/src/modules/VoApi/queries/search.ts +105 -4
- package/src/modules/VoApi/queries/sections.ts +63 -0
- package/src/modules/VoApi/queries/settings.ts +9 -3
- package/src/modules/VoApi/queries/users.ts +93 -8
- package/src/modules/VoApi/queries/vodocs.ts +8 -4
- package/src/modules/VoApi/queries/vogroups.ts +48 -2
- package/src/modules/VoApp.ts +25 -8
- package/src/modules/VoAuth.ts +136 -37
- package/src/modules/VoConfig.ts +13 -0
- package/src/modules/VoDocs/VoDocs.ts +31 -58
- package/src/modules/VoGroups.ts +33 -0
- package/src/modules/VoHelpers.ts +283 -43
- package/src/modules/VoRouter.ts +10 -3
- package/src/modules/{VoUtils.ts → VoUtils_REMOVE.ts} +17 -13
- package/src/types.ts +0 -38
|
@@ -1,17 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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));
|
|
8
57
|
};
|
|
9
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
60
|
};
|
|
12
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
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;
|
|
14
63
|
var crypto_js_1 = __importDefault(require("crypto-js"));
|
|
64
|
+
var he_1 = __importDefault(require("he"));
|
|
15
65
|
var base64Url = function (string) {
|
|
16
66
|
return string
|
|
17
67
|
.toString(crypto_js_1.default.enc.Base64)
|
|
@@ -21,11 +71,13 @@ var base64Url = function (string) {
|
|
|
21
71
|
};
|
|
22
72
|
exports.base64Url = base64Url;
|
|
23
73
|
var createRandomString = function (num) {
|
|
24
|
-
return
|
|
74
|
+
return __spreadArray([], Array(num), true).map(function () { return Math.random().toString(36)[2]; }).join("");
|
|
25
75
|
};
|
|
26
76
|
exports.createRandomString = createRandomString;
|
|
27
77
|
exports.localStorage = {
|
|
28
78
|
set: function (key, value) {
|
|
79
|
+
if (typeof window === "undefined")
|
|
80
|
+
return false;
|
|
29
81
|
try {
|
|
30
82
|
window.localStorage.setItem(key, value);
|
|
31
83
|
return true;
|
|
@@ -36,6 +88,8 @@ exports.localStorage = {
|
|
|
36
88
|
}
|
|
37
89
|
},
|
|
38
90
|
get: function (key) {
|
|
91
|
+
if (typeof window === "undefined")
|
|
92
|
+
return false;
|
|
39
93
|
try {
|
|
40
94
|
var item = window.localStorage.getItem(key);
|
|
41
95
|
return item;
|
|
@@ -63,11 +117,14 @@ var encodeQueryData = function (data) {
|
|
|
63
117
|
};
|
|
64
118
|
exports.encodeQueryData = encodeQueryData;
|
|
65
119
|
exports.regexPatterns = {
|
|
66
|
-
username: /(^[a-z]{3,})([0-9]?)+$/,
|
|
120
|
+
// username: /(^[a-z]{3,})([0-9]?)+$/,
|
|
121
|
+
username: /(^[a-z]{3,})([\.]|[\_]|[a-z]|[0-9]?)+$/,
|
|
67
122
|
email: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
68
123
|
stringNonDigit: /^[^0-9]+$/,
|
|
69
124
|
password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/,
|
|
70
|
-
cleanName: /(^[A-Za-z]{1,})(\w
|
|
125
|
+
cleanName: /(^[A-Za-z]{1,})(\w|-?)+$/,
|
|
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_"
|
|
156
|
+
return "new_".concat(Math.random().toString(36).substr(2, 12));
|
|
100
157
|
};
|
|
101
158
|
exports.getTemporaryId = getTemporaryId;
|
|
102
159
|
var createSlug2 = function (value) {
|
|
@@ -109,7 +166,7 @@ var createSlug2 = function (value) {
|
|
|
109
166
|
Å: "A",
|
|
110
167
|
Ä: "A",
|
|
111
168
|
Ö: "O",
|
|
112
|
-
Ü: "U",
|
|
169
|
+
Ü: "U", // probably more to come
|
|
113
170
|
};
|
|
114
171
|
value = value.trim().replaceAll(" ", "-").toLocaleLowerCase();
|
|
115
172
|
value = value.replace(translate_re, function (match) {
|
|
@@ -146,44 +203,284 @@ var wrapPromise = function (promise) {
|
|
|
146
203
|
return { read: read };
|
|
147
204
|
};
|
|
148
205
|
exports.wrapPromise = wrapPromise;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
206
|
+
var downloadFile = function (url) {
|
|
207
|
+
try {
|
|
208
|
+
var elId = "file-".concat(url);
|
|
209
|
+
// Ensure that an old element is not left in the DOM.
|
|
210
|
+
var el = document.getElementById(elId);
|
|
211
|
+
if (el !== null && el.parentNode) {
|
|
212
|
+
el.parentNode.removeChild(el);
|
|
213
|
+
}
|
|
214
|
+
var anchor_1 = document.createElement("a");
|
|
215
|
+
anchor_1.id = elId;
|
|
216
|
+
anchor_1.href = url;
|
|
217
|
+
anchor_1.download = url;
|
|
218
|
+
document.body.appendChild(anchor_1);
|
|
219
|
+
anchor_1.click();
|
|
220
|
+
setTimeout(function () {
|
|
221
|
+
if (anchor_1.parentNode) {
|
|
222
|
+
anchor_1.parentNode.removeChild(anchor_1);
|
|
223
|
+
}
|
|
224
|
+
}, 500);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
exports.downloadFile = downloadFile;
|
|
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));
|
|
173
392
|
// }
|
|
174
|
-
// return
|
|
175
|
-
// <ul>
|
|
176
|
-
// {error.map((v) => (
|
|
177
|
-
// <li>{typeof error[0] === "object" ? error[0].message : error[0]}</li>
|
|
178
|
-
// ))}
|
|
179
|
-
// </ul>
|
|
180
|
-
// );
|
|
181
|
-
// };
|
|
182
|
-
// export {
|
|
183
|
-
// base64Url,
|
|
184
|
-
// createRandomString,
|
|
185
|
-
// localStorage,
|
|
186
|
-
// encodeQueryData,
|
|
187
|
-
// regexPatterns,
|
|
188
|
-
// getError
|
|
393
|
+
// return result;
|
|
189
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;
|
package/dist/modules/VoRouter.js
CHANGED
|
@@ -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
|
-
|
|
50
|
-
|
|
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("");
|
|
@@ -23,4 +23,4 @@ declare type errorObjectType = {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
declare const getError: (error: any) => errorObjectType;
|
|
26
|
-
export { base64Url, createRandomString, localStorage, encodeQueryData, regexPatterns, getError };
|
|
26
|
+
export { base64Url, createRandomString, localStorage, encodeQueryData, regexPatterns, getError, };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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));
|
|
8
10
|
};
|
|
9
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -22,7 +24,7 @@ var base64Url = function (string) {
|
|
|
22
24
|
};
|
|
23
25
|
exports.base64Url = base64Url;
|
|
24
26
|
var createRandomString = function (num) {
|
|
25
|
-
return
|
|
27
|
+
return __spreadArray([], Array(num), true).map(function () { return Math.random().toString(36)[2]; }).join("");
|
|
26
28
|
};
|
|
27
29
|
exports.createRandomString = createRandomString;
|
|
28
30
|
var localStorage = {
|
|
@@ -68,13 +70,13 @@ var regexPatterns = {
|
|
|
68
70
|
username: /(^[a-z]{3,})([0-9]?)+$/,
|
|
69
71
|
email: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
70
72
|
stringNonDigit: /^[^0-9]+$/,
|
|
71
|
-
password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}
|
|
73
|
+
password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/, // At least 8 characters, 1 uppercase, 1 lowercase and 1 digit.
|
|
72
74
|
};
|
|
73
75
|
exports.regexPatterns = regexPatterns;
|
|
74
76
|
var getError = function (error) {
|
|
75
|
-
var message =
|
|
77
|
+
var message = "";
|
|
76
78
|
var fields = {};
|
|
77
|
-
if (typeof error ===
|
|
79
|
+
if (typeof error === "string") {
|
|
78
80
|
message = error;
|
|
79
81
|
}
|
|
80
82
|
if (error.message) {
|
|
@@ -83,11 +85,13 @@ var getError = function (error) {
|
|
|
83
85
|
else if (error.debugMessage) {
|
|
84
86
|
message = error.debugMessage;
|
|
85
87
|
}
|
|
86
|
-
if (error.graphQLErrors &&
|
|
88
|
+
if (error.graphQLErrors &&
|
|
89
|
+
error.graphQLErrors[0].extensions.category &&
|
|
90
|
+
error.graphQLErrors[0].extensions.category === "validation") {
|
|
87
91
|
fields = Object.assign({}, error.graphQLErrors[0].extensions.validation);
|
|
88
92
|
}
|
|
89
93
|
var result = {
|
|
90
|
-
message: message
|
|
94
|
+
message: message,
|
|
91
95
|
};
|
|
92
96
|
if (Object.keys(fields).length > 0) {
|
|
93
97
|
result.fields = fields;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocollege/app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,29 +10,38 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@apollo/client": "^3.
|
|
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/
|
|
18
|
+
"@types/he": "^1.1.2",
|
|
19
|
+
"@types/js-cookie": "^3.0.2",
|
|
19
20
|
"@types/node": "^14.14.21",
|
|
20
|
-
"@types/react": "^
|
|
21
|
-
"
|
|
21
|
+
"@types/react": "^18.0.9",
|
|
22
|
+
"@types/ws": "^8.2.2",
|
|
23
|
+
"apollo-upload-client": "^16.0.0",
|
|
22
24
|
"axios": "^0.21.1",
|
|
23
25
|
"crypto-js": "^4.0.0",
|
|
24
26
|
"graphql": "^14.0.0 || ^15.0.0",
|
|
25
|
-
"
|
|
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": "^
|
|
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
|
-
"
|
|
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"
|
|
37
46
|
}
|
|
38
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 "./
|
|
13
|
+
export * from "./global";
|
|
13
14
|
export default VoApp;
|