@kwiz/common 1.0.1
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/LICENSE +21 -0
- package/dist/_dependencies.d.ts +1 -0
- package/dist/_dependencies.js +8 -0
- package/dist/_dependencies.js.map +1 -0
- package/dist/helpers/Guid.d.ts +119 -0
- package/dist/helpers/Guid.js +183 -0
- package/dist/helpers/Guid.js.map +1 -0
- package/dist/helpers/_dependencies.d.ts +2 -0
- package/dist/helpers/_dependencies.js +21 -0
- package/dist/helpers/_dependencies.js.map +1 -0
- package/dist/helpers/base64.d.ts +8 -0
- package/dist/helpers/base64.js +178 -0
- package/dist/helpers/base64.js.map +1 -0
- package/dist/helpers/browser.d.ts +144 -0
- package/dist/helpers/browser.js +1200 -0
- package/dist/helpers/browser.js.map +1 -0
- package/dist/helpers/browserinfo.d.ts +23 -0
- package/dist/helpers/browserinfo.js +215 -0
- package/dist/helpers/browserinfo.js.map +1 -0
- package/dist/helpers/collections.base.d.ts +128 -0
- package/dist/helpers/collections.base.js +430 -0
- package/dist/helpers/collections.base.js.map +1 -0
- package/dist/helpers/collections.d.ts +18 -0
- package/dist/helpers/collections.js +99 -0
- package/dist/helpers/collections.js.map +1 -0
- package/dist/helpers/color.d.ts +11 -0
- package/dist/helpers/color.js +57 -0
- package/dist/helpers/color.js.map +1 -0
- package/dist/helpers/cookies.d.ts +6 -0
- package/dist/helpers/cookies.js +56 -0
- package/dist/helpers/cookies.js.map +1 -0
- package/dist/helpers/date.d.ts +43 -0
- package/dist/helpers/date.js +158 -0
- package/dist/helpers/date.js.map +1 -0
- package/dist/helpers/debug.d.ts +33 -0
- package/dist/helpers/debug.js +177 -0
- package/dist/helpers/debug.js.map +1 -0
- package/dist/helpers/emails.d.ts +2 -0
- package/dist/helpers/emails.js +10 -0
- package/dist/helpers/emails.js.map +1 -0
- package/dist/helpers/eval.d.ts +1 -0
- package/dist/helpers/eval.js +10 -0
- package/dist/helpers/eval.js.map +1 -0
- package/dist/helpers/file.d.ts +11 -0
- package/dist/helpers/file.js +55 -0
- package/dist/helpers/file.js.map +1 -0
- package/dist/helpers/flatted.d.ts +20 -0
- package/dist/helpers/flatted.js +135 -0
- package/dist/helpers/flatted.js.map +1 -0
- package/dist/helpers/functions.d.ts +4 -0
- package/dist/helpers/functions.js +17 -0
- package/dist/helpers/functions.js.map +1 -0
- package/dist/helpers/graph/calendar.types.d.ts +3 -0
- package/dist/helpers/graph/calendar.types.js +15 -0
- package/dist/helpers/graph/calendar.types.js.map +1 -0
- package/dist/helpers/http.d.ts +25 -0
- package/dist/helpers/http.js +70 -0
- package/dist/helpers/http.js.map +1 -0
- package/dist/helpers/images.d.ts +16 -0
- package/dist/helpers/images.js +21 -0
- package/dist/helpers/images.js.map +1 -0
- package/dist/helpers/index.d.ts +29 -0
- package/dist/helpers/index.js +46 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/json.d.ts +3 -0
- package/dist/helpers/json.js +44 -0
- package/dist/helpers/json.js.map +1 -0
- package/dist/helpers/md5.d.ts +5 -0
- package/dist/helpers/md5.js +172 -0
- package/dist/helpers/md5.js.map +1 -0
- package/dist/helpers/objects.d.ts +49 -0
- package/dist/helpers/objects.js +271 -0
- package/dist/helpers/objects.js.map +1 -0
- package/dist/helpers/promises.d.ts +14 -0
- package/dist/helpers/promises.js +112 -0
- package/dist/helpers/promises.js.map +1 -0
- package/dist/helpers/random.d.ts +2 -0
- package/dist/helpers/random.js +32 -0
- package/dist/helpers/random.js.map +1 -0
- package/dist/helpers/scheduler/scheduler.d.ts +39 -0
- package/dist/helpers/scheduler/scheduler.js +109 -0
- package/dist/helpers/scheduler/scheduler.js.map +1 -0
- package/dist/helpers/sharepoint.d.ts +112 -0
- package/dist/helpers/sharepoint.js +629 -0
- package/dist/helpers/sharepoint.js.map +1 -0
- package/dist/helpers/strings.d.ts +56 -0
- package/dist/helpers/strings.js +282 -0
- package/dist/helpers/strings.js.map +1 -0
- package/dist/helpers/typecheckers.d.ts +56 -0
- package/dist/helpers/typecheckers.js +274 -0
- package/dist/helpers/typecheckers.js.map +1 -0
- package/dist/helpers/url.d.ts +46 -0
- package/dist/helpers/url.js +199 -0
- package/dist/helpers/url.js.map +1 -0
- package/dist/helpers/urlhelper.d.ts +16 -0
- package/dist/helpers/urlhelper.js +96 -0
- package/dist/helpers/urlhelper.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/types/common.types.d.ts +19 -0
- package/dist/types/common.types.js +4 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/flatted.types.d.ts +49 -0
- package/dist/types/flatted.types.js +3 -0
- package/dist/types/flatted.types.js.map +1 -0
- package/dist/types/globals.types.d.ts +6 -0
- package/dist/types/globals.types.js +3 -0
- package/dist/types/globals.types.js.map +1 -0
- package/dist/types/graph/calendar.types.d.ts +79 -0
- package/dist/types/graph/calendar.types.js +3 -0
- package/dist/types/graph/calendar.types.js.map +1 -0
- package/dist/types/graph/index.d.ts +1 -0
- package/dist/types/graph/index.js +18 -0
- package/dist/types/graph/index.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +28 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knownscript.types.d.ts +22 -0
- package/dist/types/knownscript.types.js +3 -0
- package/dist/types/knownscript.types.js.map +1 -0
- package/dist/types/libs/datajs.types.d.ts +29 -0
- package/dist/types/libs/datajs.types.js +3 -0
- package/dist/types/libs/datajs.types.js.map +1 -0
- package/dist/types/libs/ics.types.d.ts +29 -0
- package/dist/types/libs/ics.types.js +3 -0
- package/dist/types/libs/ics.types.js.map +1 -0
- package/dist/types/libs/index.d.ts +3 -0
- package/dist/types/libs/index.js +20 -0
- package/dist/types/libs/index.js.map +1 -0
- package/dist/types/libs/msal.types.d.ts +33 -0
- package/dist/types/libs/msal.types.js +63 -0
- package/dist/types/libs/msal.types.js.map +1 -0
- package/dist/types/locales.d.ts +122 -0
- package/dist/types/locales.js +1 -0
- package/dist/types/locales.js.map +1 -0
- package/dist/types/localstoragecache.types.d.ts +8 -0
- package/dist/types/localstoragecache.types.js +3 -0
- package/dist/types/localstoragecache.types.js.map +1 -0
- package/dist/types/moment.d.ts +6 -0
- package/dist/types/moment.js +1 -0
- package/dist/types/moment.js.map +1 -0
- package/dist/types/regex.types.d.ts +14 -0
- package/dist/types/regex.types.js +3 -0
- package/dist/types/regex.types.js.map +1 -0
- package/dist/types/rest.types.d.ts +81 -0
- package/dist/types/rest.types.js +24 -0
- package/dist/types/rest.types.js.map +1 -0
- package/dist/types/sharepoint.types.d.ts +1432 -0
- package/dist/types/sharepoint.types.js +629 -0
- package/dist/types/sharepoint.types.js.map +1 -0
- package/dist/types/sharepoint.utils.types.d.ts +246 -0
- package/dist/types/sharepoint.utils.types.js +26 -0
- package/dist/types/sharepoint.utils.types.js.map +1 -0
- package/dist/utils/_dependencies.d.ts +3 -0
- package/dist/utils/_dependencies.js +24 -0
- package/dist/utils/_dependencies.js.map +1 -0
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +41 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/consolelogger.d.ts +73 -0
- package/dist/utils/consolelogger.js +281 -0
- package/dist/utils/consolelogger.js.map +1 -0
- package/dist/utils/date.d.ts +10 -0
- package/dist/utils/date.js +30 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/emails.d.ts +2 -0
- package/dist/utils/emails.js +24 -0
- package/dist/utils/emails.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/knownscript.d.ts +99 -0
- package/dist/utils/knownscript.js +261 -0
- package/dist/utils/knownscript.js.map +1 -0
- package/dist/utils/localstoragecache.d.ts +19 -0
- package/dist/utils/localstoragecache.js +372 -0
- package/dist/utils/localstoragecache.js.map +1 -0
- package/dist/utils/rest.d.ts +17 -0
- package/dist/utils/rest.js +402 -0
- package/dist/utils/rest.js.map +1 -0
- package/dist/utils/script.d.ts +33 -0
- package/dist/utils/script.js +169 -0
- package/dist/utils/script.js.map +1 -0
- package/dist/utils/sharepoint.rest/common.d.ts +32 -0
- package/dist/utils/sharepoint.rest/common.js +146 -0
- package/dist/utils/sharepoint.rest/common.js.map +1 -0
- package/dist/utils/sharepoint.rest/date.d.ts +2 -0
- package/dist/utils/sharepoint.rest/date.js +57 -0
- package/dist/utils/sharepoint.rest/date.js.map +1 -0
- package/dist/utils/sharepoint.rest/file.folder.d.ts +58 -0
- package/dist/utils/sharepoint.rest/file.folder.js +305 -0
- package/dist/utils/sharepoint.rest/file.folder.js.map +1 -0
- package/dist/utils/sharepoint.rest/index.d.ts +11 -0
- package/dist/utils/sharepoint.rest/index.js +28 -0
- package/dist/utils/sharepoint.rest/index.js.map +1 -0
- package/dist/utils/sharepoint.rest/item.d.ts +81 -0
- package/dist/utils/sharepoint.rest/item.js +444 -0
- package/dist/utils/sharepoint.rest/item.js.map +1 -0
- package/dist/utils/sharepoint.rest/list.d.ts +228 -0
- package/dist/utils/sharepoint.rest/list.js +868 -0
- package/dist/utils/sharepoint.rest/list.js.map +1 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.d.ts +19 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.js +629 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +1 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsById.d.ts +14 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsById.js +222 -0
- package/dist/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -0
- package/dist/utils/sharepoint.rest/listutils/common.d.ts +3 -0
- package/dist/utils/sharepoint.rest/listutils/common.js +198 -0
- package/dist/utils/sharepoint.rest/listutils/common.js.map +1 -0
- package/dist/utils/sharepoint.rest/user-search.d.ts +76 -0
- package/dist/utils/sharepoint.rest/user-search.js +239 -0
- package/dist/utils/sharepoint.rest/user-search.js.map +1 -0
- package/dist/utils/sharepoint.rest/user.d.ts +71 -0
- package/dist/utils/sharepoint.rest/user.js +404 -0
- package/dist/utils/sharepoint.rest/user.js.map +1 -0
- package/dist/utils/sharepoint.rest/web.d.ts +107 -0
- package/dist/utils/sharepoint.rest/web.js +929 -0
- package/dist/utils/sharepoint.rest/web.js.map +1 -0
- package/dist/utils/sod.d.ts +29 -0
- package/dist/utils/sod.js +177 -0
- package/dist/utils/sod.js.map +1 -0
- package/package.json +60 -0
- package/readme.md +13 -0
- package/src/_dependencies.ts +2 -0
- package/src/helpers/Guid.ts +182 -0
- package/src/helpers/_dependencies.ts +3 -0
- package/src/helpers/base64.ts +174 -0
- package/src/helpers/browser.test.js +9 -0
- package/src/helpers/browser.ts +1299 -0
- package/src/helpers/browserinfo.ts +293 -0
- package/src/helpers/collections.base.test.js +26 -0
- package/src/helpers/collections.base.ts +439 -0
- package/src/helpers/collections.ts +108 -0
- package/src/helpers/color.ts +55 -0
- package/src/helpers/cookies.ts +55 -0
- package/src/helpers/date.test.js +97 -0
- package/src/helpers/date.ts +163 -0
- package/src/helpers/debug.ts +187 -0
- package/src/helpers/emails.ts +7 -0
- package/src/helpers/eval.ts +5 -0
- package/src/helpers/file.test.js +51 -0
- package/src/helpers/file.ts +59 -0
- package/src/helpers/flatted.ts +150 -0
- package/src/helpers/functions.ts +17 -0
- package/src/helpers/graph/calendar.types.ts +11 -0
- package/src/helpers/http.ts +70 -0
- package/src/helpers/images.ts +23 -0
- package/src/helpers/index.ts +29 -0
- package/src/helpers/json.ts +39 -0
- package/src/helpers/md5.ts +190 -0
- package/src/helpers/objects.test.js +27 -0
- package/src/helpers/objects.ts +256 -0
- package/src/helpers/promises.test.js +18 -0
- package/src/helpers/promises.ts +102 -0
- package/src/helpers/random.ts +27 -0
- package/src/helpers/scheduler/scheduler.test.js +104 -0
- package/src/helpers/scheduler/scheduler.ts +132 -0
- package/src/helpers/sharepoint.ts +681 -0
- package/src/helpers/strings.test.js +43 -0
- package/src/helpers/strings.ts +288 -0
- package/src/helpers/typecheckers.test.js +35 -0
- package/src/helpers/typecheckers.ts +263 -0
- package/src/helpers/url.test.js +18 -0
- package/src/helpers/url.ts +202 -0
- package/src/helpers/urlhelper.ts +104 -0
- package/src/index.ts +24 -0
- package/src/types/common.types.ts +16 -0
- package/src/types/flatted.types.ts +60 -0
- package/src/types/globals.types.ts +7 -0
- package/src/types/graph/calendar.types.ts +81 -0
- package/src/types/graph/index.ts +1 -0
- package/src/types/index.ts +12 -0
- package/src/types/knownscript.types.ts +19 -0
- package/src/types/libs/datajs.types.ts +29 -0
- package/src/types/libs/ics.types.ts +31 -0
- package/src/types/libs/index.ts +4 -0
- package/src/types/libs/msal.types.ts +79 -0
- package/src/types/locales.ts +125 -0
- package/src/types/localstoragecache.types.ts +9 -0
- package/src/types/moment.ts +7 -0
- package/src/types/regex.types.ts +17 -0
- package/src/types/rest.types.ts +94 -0
- package/src/types/sharepoint.types.ts +1413 -0
- package/src/types/sharepoint.utils.types.ts +246 -0
- package/src/utils/_dependencies.ts +4 -0
- package/src/utils/base64.ts +27 -0
- package/src/utils/consolelogger.ts +315 -0
- package/src/utils/date.ts +36 -0
- package/src/utils/emails.ts +25 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/knownscript.ts +280 -0
- package/src/utils/localstoragecache.ts +419 -0
- package/src/utils/rest.ts +465 -0
- package/src/utils/script.ts +168 -0
- package/src/utils/sharepoint.rest/common.ts +149 -0
- package/src/utils/sharepoint.rest/date.ts +61 -0
- package/src/utils/sharepoint.rest/file.folder.ts +368 -0
- package/src/utils/sharepoint.rest/index.ts +11 -0
- package/src/utils/sharepoint.rest/item.ts +456 -0
- package/src/utils/sharepoint.rest/list.ts +1144 -0
- package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +750 -0
- package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +265 -0
- package/src/utils/sharepoint.rest/listutils/common.ts +202 -0
- package/src/utils/sharepoint.rest/user-search.ts +254 -0
- package/src/utils/sharepoint.rest/user.ts +447 -0
- package/src/utils/sharepoint.rest/web.ts +1031 -0
- package/src/utils/sod.ts +193 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { IDictionary } from "./_dependencies";
|
|
2
|
+
import { ArrayFill, lastOrNull } from "./collections.base";
|
|
3
|
+
import { isNullOrEmptyString, isString } from "./typecheckers";
|
|
4
|
+
import { URLHelper } from "./urlhelper";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get query string parameter by name
|
|
8
|
+
* @param name name of parameter
|
|
9
|
+
* @param url optional, url. if not sent - current window.location.href will be used
|
|
10
|
+
*/
|
|
11
|
+
export function getQueryStringParameter(param: string, url?: string, caseInSensitive?: boolean) {
|
|
12
|
+
let search = window.location.search;
|
|
13
|
+
if (!isNullOrEmptyString(url)) {
|
|
14
|
+
let tmp = url.split('#')[0].split('?');
|
|
15
|
+
search = tmp.length > 1 ? tmp[1] : '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return getParameterValue(param, search, caseInSensitive);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get url hash parameter by name
|
|
22
|
+
* @param name name of parameter
|
|
23
|
+
* @param url optional, url. if not sent - current window.location.href will be used
|
|
24
|
+
*/
|
|
25
|
+
export function getHashParameter(param: string, url?: string, caseInSensitive?: boolean) {
|
|
26
|
+
let hash = window.location.hash;
|
|
27
|
+
if (!isNullOrEmptyString(url)) {
|
|
28
|
+
let tmp = url.split('#');
|
|
29
|
+
hash = tmp.length > 1 ? tmp[1] : '';
|
|
30
|
+
}
|
|
31
|
+
return getParameterValue(param, hash, caseInSensitive);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** return a value of a parameter from a key/value string like: key=value&key2=value2 */
|
|
35
|
+
export function getParameterValue(param: string, keyValueString: string, caseInSensitive?: boolean) {
|
|
36
|
+
let _keyValueString = keyValueString.startsWith("#") || keyValueString.startsWith("?") ? keyValueString.substr(1) : keyValueString;
|
|
37
|
+
var parsed = _keyValueString.split('&');
|
|
38
|
+
for (var i = 0; i < parsed.length; i++) {
|
|
39
|
+
var values = parsed[i].split('=');
|
|
40
|
+
|
|
41
|
+
if (caseInSensitive ? values[0] === param : values[0].toLowerCase() === param.toLowerCase()) {
|
|
42
|
+
let v = (values.length > 1 ? values[1] : param);
|
|
43
|
+
return decodeURIComponent(v.replace(/\+/g, " "));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//ISSUE: 1301 - the query string parameter name was encoded in window.location.href/window.location.search even though in the
|
|
47
|
+
//url bar the paramter name was not encoded
|
|
48
|
+
if (caseInSensitive ? decodeURIComponent(values[0]) === param : decodeURIComponent(values[0]).toLowerCase() === param.toLowerCase()) {
|
|
49
|
+
let v = (values.length > 1 ? values[1] : param);
|
|
50
|
+
return decodeURIComponent(v.replace(/\+/g, " "));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Make full url relative to current page location
|
|
58
|
+
* @param url
|
|
59
|
+
*/
|
|
60
|
+
export function makeFullUrl(url: string, baseUrl?: string): string {
|
|
61
|
+
if (isNullOrEmptyString(url)) url = baseUrl || window.location.href;
|
|
62
|
+
|
|
63
|
+
if (url.indexOf('://') > 0) return url;
|
|
64
|
+
else {
|
|
65
|
+
//might be server relative or folder relative url.
|
|
66
|
+
|
|
67
|
+
if (isNullOrEmptyString(baseUrl) || url.startsWith('/')) {
|
|
68
|
+
var xxx = document.createElement("a");
|
|
69
|
+
xxx.href = url;
|
|
70
|
+
return xxx.href;
|
|
71
|
+
}
|
|
72
|
+
else//folder relative URL, and we have a different baseURL to base it on
|
|
73
|
+
{
|
|
74
|
+
return makeFullUrl(makeServerRelativeUrl(url, baseUrl));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** if the url is the same, only different hash parameter - reload the page. otherwise - navigate to the page */
|
|
80
|
+
export function navigateOrReload(urlWithHash: string) {
|
|
81
|
+
if (makeServerRelativeUrl(urlWithHash).split('#')[0].toLowerCase() === makeServerRelativeUrl(window.location.href).split('#')[0].toLowerCase())
|
|
82
|
+
window.location.reload();//can't change hash - it won't refresh page
|
|
83
|
+
else
|
|
84
|
+
window.location.href = urlWithHash;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** baseUrl is optional full or server relative URL to build folder relative urls from. */
|
|
88
|
+
export function makeServerRelativeUrl(url: string, baseUrl?: string): string {
|
|
89
|
+
if (isNullOrEmptyString(url)) url = baseUrl || window.location.href.split('?')[0];
|
|
90
|
+
|
|
91
|
+
var index = url.indexOf("//");
|
|
92
|
+
if (index > 0)//this is a full URL, just trim it from // until the first / and return.
|
|
93
|
+
{
|
|
94
|
+
index = url.indexOf("/", index + 2);//find next / after the ://domain.name
|
|
95
|
+
if (index < 0) return "/";//not found - return "/" for the root.
|
|
96
|
+
else return url.slice(index);//found - return from that "/" onwards.
|
|
97
|
+
}
|
|
98
|
+
else if (url.startsWith('/'))//server relative url already
|
|
99
|
+
return url;
|
|
100
|
+
else//folder relative url
|
|
101
|
+
{
|
|
102
|
+
let baseRelativeUrl = makeServerRelativeUrl(baseUrl || window.location.href);
|
|
103
|
+
baseRelativeUrl = baseRelativeUrl.split('?')[0];
|
|
104
|
+
//if ends with file name - strip it
|
|
105
|
+
if (lastOrNull(baseRelativeUrl.split('/')).indexOf('.') >= 0)
|
|
106
|
+
baseRelativeUrl = baseRelativeUrl.substr(0, baseRelativeUrl.lastIndexOf('/'));
|
|
107
|
+
return normalizeUrl(baseRelativeUrl, true) + url;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Normalizes URL ending, end with or without slash */
|
|
112
|
+
export function normalizeUrl(url: string, endWithSlash = false): string {
|
|
113
|
+
var tmp = url;
|
|
114
|
+
if (endWithSlash) {
|
|
115
|
+
if (isNullOrEmptyString(tmp))
|
|
116
|
+
tmp = "/";
|
|
117
|
+
else if (tmp.substr(-1) !== "/")
|
|
118
|
+
tmp += "/";
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (!isNullOrEmptyString(tmp) && tmp.endsWith('/'))
|
|
122
|
+
tmp = tmp.slice(0, url.length - 1);
|
|
123
|
+
}
|
|
124
|
+
return tmp;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Returns the extension for a specified url string. Requires the URL polyfill for IE.
|
|
129
|
+
*/
|
|
130
|
+
export function getURLExtension(url: string) {//, baseUri?: string) {
|
|
131
|
+
if (!isString(url)) {
|
|
132
|
+
return "";
|
|
133
|
+
}
|
|
134
|
+
//if (!isString(baseUri)) {
|
|
135
|
+
// baseUri = document.baseURI || window.location.protocol + "://" + window.location.hostname + window.location.pathname;
|
|
136
|
+
//}
|
|
137
|
+
var urlObj = new URL(url, "https://example.com");
|
|
138
|
+
url = urlObj.href.replace(urlObj.host, "").replace(urlObj.hash, "").replace(urlObj.search, "");
|
|
139
|
+
return url.substring(url.lastIndexOf("/") + 1).split(/#|\?/)[0].split(".").pop().trim();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function isDataUrl(url: string) {
|
|
143
|
+
var REGEXP_DATA_URL = /^data:(?:.+?\/.+?)?(?:;.+?=.+?)*(?:;base64)?,.*$/;
|
|
144
|
+
return REGEXP_DATA_URL.test(url);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function setUrlKeyValue(keyName: string, keyValue: string, bEncode: boolean, url?: string) {
|
|
148
|
+
if (!isString(url)) {
|
|
149
|
+
url = window.location.href + "";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var urlParams = new URLHelper(url);
|
|
153
|
+
return urlParams.setQueryStringParam(keyName, keyValue, bEncode);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function removeUrlKeyValue(keyName: string, url?: string) {
|
|
157
|
+
if (!isString(url)) {
|
|
158
|
+
url = window.location.href + "";
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var urlParams = new URLHelper(url);
|
|
162
|
+
return urlParams.removeQueryStringParam(keyName);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Returns encoded string from encodeURIComponent with single quote replaced with %27 or %27%27
|
|
167
|
+
*/
|
|
168
|
+
export function encodeURIComponentEX(str, options?: {
|
|
169
|
+
/** use this flag when making a REST requst, and encoding a parameter surrounded by 'param'
|
|
170
|
+
* for each level of '' your param is sorounded with
|
|
171
|
+
* example: filename('par'am') > send 2 to make it filename('par''am')
|
|
172
|
+
* example 2: sheet(' ''par'am'' ') > send 4 to make it sheet(' ''par''''am'' ')
|
|
173
|
+
*/
|
|
174
|
+
singleQuoteMultiplier?: number;
|
|
175
|
+
}) {
|
|
176
|
+
return encodeURIComponent(str).replace(/'/g, (s) => {
|
|
177
|
+
return options && options.singleQuoteMultiplier > 1
|
|
178
|
+
? ArrayFill(new Array(options.singleQuoteMultiplier), "%27").join('')
|
|
179
|
+
: `%27`;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function parseQueryString(url: string): IDictionary<string> {
|
|
184
|
+
if (isNullOrEmptyString(url) || url.indexOf('?') < 0) return {};
|
|
185
|
+
let strParams = url.split('?')[1].split('#')[0].split('&');
|
|
186
|
+
let params: IDictionary<string> = {};
|
|
187
|
+
strParams.forEach(p => {
|
|
188
|
+
let keyValue = p.split("=");
|
|
189
|
+
params[keyValue[0]] = decodeURIComponent(keyValue[1] || "");
|
|
190
|
+
});
|
|
191
|
+
return params;
|
|
192
|
+
}
|
|
193
|
+
export function parseHash(url: string): IDictionary<string> {
|
|
194
|
+
if (isNullOrEmptyString(url) || url.indexOf('#') < 0) return {};
|
|
195
|
+
let strParams = url.split('#')[1].split('&');
|
|
196
|
+
let params: IDictionary<string> = {};
|
|
197
|
+
strParams.forEach(p => {
|
|
198
|
+
let keyValue = p.split("=");
|
|
199
|
+
params[keyValue[0]] = decodeURIComponent(keyValue[1] || "");
|
|
200
|
+
});
|
|
201
|
+
return params;
|
|
202
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export class URLHelper {
|
|
2
|
+
private queryStringParams: { [key: string]: string; };
|
|
3
|
+
private hashParams: { [key: string]: string; };
|
|
4
|
+
private path: string;
|
|
5
|
+
|
|
6
|
+
public constructor(url: string) {
|
|
7
|
+
var parts = url.split("#");
|
|
8
|
+
var pathAndQueryString = parts[0];
|
|
9
|
+
var hash = parts[1];
|
|
10
|
+
var parts2 = pathAndQueryString.split("?");
|
|
11
|
+
var path = parts2[0];
|
|
12
|
+
var queryString = parts2[1];
|
|
13
|
+
|
|
14
|
+
this.path = path;
|
|
15
|
+
this.queryStringParams = this._parseParams(queryString);
|
|
16
|
+
this.hashParams = this._parseParams(hash);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public getQueryStringParam(keyName: string, bNoDecode?: boolean, bCaseInsensitive?: boolean) {
|
|
20
|
+
return this._getParam(this.queryStringParams, keyName, bNoDecode, bCaseInsensitive);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public setQueryStringParam(keyName: string, keyValue: string, bEncode: boolean) {
|
|
24
|
+
this.queryStringParams[keyName] = bEncode ? encodeURIComponent(keyValue) : keyValue;
|
|
25
|
+
return this.getUrl();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public removeQueryStringParam(keyName: string) {
|
|
29
|
+
this._removeParam(this.queryStringParams, keyName);
|
|
30
|
+
return this.getUrl();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getHashParam(keyName: string, bNoDecode?: boolean, bCaseInsensitive?: boolean) {
|
|
34
|
+
return this._getParam(this.hashParams, keyName, bNoDecode, bCaseInsensitive);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public setHashParam(keyName: string, keyValue: string, bEncode: boolean) {
|
|
38
|
+
this.hashParams[keyName] = bEncode ? encodeURIComponent(keyValue) : keyValue;
|
|
39
|
+
return this.getUrl();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public removeHashParam(keyName: string) {
|
|
43
|
+
this._removeParam(this.hashParams, keyName);
|
|
44
|
+
return this.getUrl();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private _parseParams(paramsAsString: string) {
|
|
48
|
+
var paramsDict: { [key: string]: string; } = {};
|
|
49
|
+
try {
|
|
50
|
+
(typeof (paramsAsString) === "string" && paramsAsString.length ? paramsAsString.split("&") : []).forEach((s) => {
|
|
51
|
+
var q = s.split("=");
|
|
52
|
+
var paramKey = decodeURIComponent(q[0]);
|
|
53
|
+
var paramValue = q[1];
|
|
54
|
+
if (typeof (paramKey) === "string" && paramKey.length) {
|
|
55
|
+
paramsDict[paramKey] = typeof (paramValue) === "string" && paramValue.length ? paramValue : null;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
} catch (ex) {
|
|
59
|
+
}
|
|
60
|
+
return paramsDict;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private _removeParam(obj: { [key: string]: string; }, keyName: string) {
|
|
64
|
+
if (obj && obj[keyName]) {
|
|
65
|
+
try {
|
|
66
|
+
delete obj[keyName];
|
|
67
|
+
} catch (ex) {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private _getParam(obj: { [key: string]: string; }, keyName: string, bNoDecode?: boolean, bCaseInsensitive?: boolean) {
|
|
73
|
+
var value: string = null;
|
|
74
|
+
if (bCaseInsensitive) {
|
|
75
|
+
var matchedKey = Object.keys(obj).filter((key) => {
|
|
76
|
+
return key.toLowerCase() === keyName.toLowerCase();
|
|
77
|
+
})[0];
|
|
78
|
+
|
|
79
|
+
if (matchedKey) {
|
|
80
|
+
value = obj[matchedKey];
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
value = obj[keyName];
|
|
84
|
+
}
|
|
85
|
+
return typeof (value) === "string" ? (bNoDecode ? value : decodeURIComponent(value)) : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public getUrl() {
|
|
89
|
+
var queryString = Object.keys(this.queryStringParams).map((key) => {
|
|
90
|
+
var value = this.queryStringParams[key];
|
|
91
|
+
return `${key}` + (value !== null ? `=${value}` : "");
|
|
92
|
+
});
|
|
93
|
+
var hash = Object.keys(this.hashParams).map((key) => {
|
|
94
|
+
var value = this.hashParams[key];
|
|
95
|
+
return `${key}` + (value !== null ? `=${value}` : "");
|
|
96
|
+
});
|
|
97
|
+
var newUrl = [
|
|
98
|
+
typeof (this.path) === "string" && this.path.length ? this.path : "",
|
|
99
|
+
queryString && queryString.length ? `?${queryString.join("&")}` : "",
|
|
100
|
+
hash && hash.length ? `#${hash.join("&")}` : ""
|
|
101
|
+
];
|
|
102
|
+
return newUrl.join("");
|
|
103
|
+
}
|
|
104
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConsoleLogger } from './utils';
|
|
2
|
+
export * from './helpers';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './utils';
|
|
5
|
+
|
|
6
|
+
export var BuildNumber = "unset";
|
|
7
|
+
export var IsLocalDev = false;
|
|
8
|
+
export var ReleaseStatus = "npm";
|
|
9
|
+
export function config(params: {
|
|
10
|
+
BuildNumber: string;
|
|
11
|
+
IsLocalDev: boolean;
|
|
12
|
+
ReleaseStatus: string;
|
|
13
|
+
ProjectName: string;
|
|
14
|
+
}) {
|
|
15
|
+
BuildNumber = params.BuildNumber;
|
|
16
|
+
IsLocalDev = params.IsLocalDev;
|
|
17
|
+
ReleaseStatus = params.ReleaseStatus;
|
|
18
|
+
function GetLogger(name: string) {
|
|
19
|
+
return ConsoleLogger.get(name, "[cms]");
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
logger: GetLogger
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//Drop common, non product specific, types
|
|
2
|
+
|
|
3
|
+
export interface IDictionary<valueType> { [key: string]: valueType; }
|
|
4
|
+
|
|
5
|
+
export type IdTextPair = { id: string; text: string; };
|
|
6
|
+
export type KeyValuePair<T> = { key: string; value: T; };
|
|
7
|
+
|
|
8
|
+
/** display info for enums or custom types for modern UI dropdowns */
|
|
9
|
+
export interface ITypesDisplayInfo<ValueType> {
|
|
10
|
+
value: ValueType;
|
|
11
|
+
title: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
fabricIconName?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type DateOrNull = Date | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*! (c) 2020 Andrea Giammarchi */
|
|
2
|
+
/**
|
|
3
|
+
* Fast and minimal circular JSON parser.
|
|
4
|
+
* logic example
|
|
5
|
+
```js
|
|
6
|
+
var a = [{one: 1}, {two: '2'}];
|
|
7
|
+
a[0].a = a;
|
|
8
|
+
// a is the main object, will be at index '0'
|
|
9
|
+
// {one: 1} is the second object, index '1'
|
|
10
|
+
// {two: '2'} the third, in '2', and it has a string
|
|
11
|
+
// which will be found at index '3'
|
|
12
|
+
Flatted.stringify(a);
|
|
13
|
+
// [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
|
|
14
|
+
// a[one,two] {one: 1, a} {two: '2'} '2'
|
|
15
|
+
```
|
|
16
|
+
*/
|
|
17
|
+
export interface IFlatted {
|
|
18
|
+
/**
|
|
19
|
+
* Converts a JavaScript Object Notation (using Flatted encoding) string into an object.
|
|
20
|
+
* @param text A valid Flatted string.
|
|
21
|
+
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
|
22
|
+
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
23
|
+
*/
|
|
24
|
+
parse(
|
|
25
|
+
text: string,
|
|
26
|
+
reviver?: (this: any, key: string, value: any) => any
|
|
27
|
+
): any;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a JavaScript value to a JavaScript Object Notation (using Flatted encoding) string.
|
|
30
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
31
|
+
* @param replacer A function that transforms the results.
|
|
32
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
33
|
+
*/
|
|
34
|
+
stringify(
|
|
35
|
+
value: any,
|
|
36
|
+
replacer?: (this: any, key: string, value: any) => any,
|
|
37
|
+
space?: string | number
|
|
38
|
+
): string;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a JavaScript value to a JavaScript Object Notation (using Flatted encoding) string.
|
|
41
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
42
|
+
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
|
|
43
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
44
|
+
*/
|
|
45
|
+
stringify(
|
|
46
|
+
value: any,
|
|
47
|
+
replacer?: (number | string)[] | null,
|
|
48
|
+
space?: string | number
|
|
49
|
+
): string;
|
|
50
|
+
/**
|
|
51
|
+
* Helper to allow explicit conversions with classes.
|
|
52
|
+
* @param value The JSON to convert to JavaScript value
|
|
53
|
+
*/
|
|
54
|
+
fromJSON(value: any): any;
|
|
55
|
+
/**
|
|
56
|
+
* Helper to allow explicit conversions with classes.
|
|
57
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
58
|
+
*/
|
|
59
|
+
toJSON(value: any): any;
|
|
60
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface IGraphEventUser {
|
|
2
|
+
emailAddress: {
|
|
3
|
+
name: string;
|
|
4
|
+
address: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface IGraphEventAttendee extends IGraphEventUser {
|
|
8
|
+
type: "optional" | "required";
|
|
9
|
+
status: {
|
|
10
|
+
response: GraphEventResponse;
|
|
11
|
+
time: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface IGraphEventLocation {
|
|
15
|
+
displayName: string,//"Microsoft Teams Meeting",
|
|
16
|
+
locationType: "default",
|
|
17
|
+
uniqueId: string,//"Microsoft Teams Meeting",
|
|
18
|
+
uniqueIdType: "private" | "unknown"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type GraphEventTimezone = "Eastern Standard Time" | "America/Toronto" | "UTC";
|
|
22
|
+
export type GraphEventType = "occurrence" | "singleInstance";
|
|
23
|
+
export type GraphEventResponse = "none" | "organizer" | "accepted";
|
|
24
|
+
|
|
25
|
+
export interface IGraphCalendar {
|
|
26
|
+
id: string,
|
|
27
|
+
createdDateTime: string,
|
|
28
|
+
lastModifiedDateTime: string,
|
|
29
|
+
changeKey: string,
|
|
30
|
+
categories: string[],
|
|
31
|
+
transactionId: null,
|
|
32
|
+
originalStartTimeZone: GraphEventTimezone,
|
|
33
|
+
originalEndTimeZone: GraphEventTimezone,
|
|
34
|
+
iCalUId: string,
|
|
35
|
+
reminderMinutesBeforeStart: number,
|
|
36
|
+
isReminderOn: boolean,
|
|
37
|
+
hasAttachments: boolean,
|
|
38
|
+
subject: string,
|
|
39
|
+
bodyPreview: string,
|
|
40
|
+
importance: string,//"normal",
|
|
41
|
+
sensitivity: string,// "normal",
|
|
42
|
+
isAllDay: boolean,
|
|
43
|
+
isCancelled: boolean,
|
|
44
|
+
isOrganizer: boolean,
|
|
45
|
+
responseRequested: boolean,
|
|
46
|
+
seriesMasterId: string,//null,
|
|
47
|
+
showAs: string,//"busy",
|
|
48
|
+
type: GraphEventType,
|
|
49
|
+
webLink: string,
|
|
50
|
+
onlineMeetingUrl: string,//null,
|
|
51
|
+
isOnlineMeeting: boolean,
|
|
52
|
+
onlineMeetingProvider: "teamsForBusiness" | "unknown",
|
|
53
|
+
allowNewTimeProposals: boolean,
|
|
54
|
+
occurrenceId: string,//null,
|
|
55
|
+
isDraft: boolean,
|
|
56
|
+
hideAttendees: boolean,
|
|
57
|
+
responseStatus: {
|
|
58
|
+
response: GraphEventResponse,
|
|
59
|
+
time: string
|
|
60
|
+
},
|
|
61
|
+
body: {
|
|
62
|
+
contentType: "html",
|
|
63
|
+
content: string,//"<html><head><body>....</html>"
|
|
64
|
+
},
|
|
65
|
+
start: {
|
|
66
|
+
dateTime: string,
|
|
67
|
+
timeZone: GraphEventTimezone,
|
|
68
|
+
},
|
|
69
|
+
end: {
|
|
70
|
+
dateTime: string,
|
|
71
|
+
timeZone: GraphEventTimezone,
|
|
72
|
+
},
|
|
73
|
+
location: IGraphEventLocation,
|
|
74
|
+
locations: IGraphEventLocation[],
|
|
75
|
+
recurrence: null,
|
|
76
|
+
attendees: IGraphEventAttendee[],
|
|
77
|
+
organizer: IGraphEventUser,
|
|
78
|
+
onlineMeeting: {
|
|
79
|
+
joinUrl: string
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./calendar.types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./common.types";
|
|
2
|
+
export * from './flatted.types';
|
|
3
|
+
export * from "./globals.types";
|
|
4
|
+
export * from "./graph";
|
|
5
|
+
export * from "./knownscript.types";
|
|
6
|
+
export * from "./libs";
|
|
7
|
+
export * from "./localstoragecache.types";
|
|
8
|
+
export * from "./regex.types";
|
|
9
|
+
export * from "./rest.types";
|
|
10
|
+
export * from "./sharepoint.types";
|
|
11
|
+
export * from "./sharepoint.utils.types";
|
|
12
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ksGlobal = string | { name: string; getter: (() => any); };
|
|
2
|
+
export interface IKnownScript {
|
|
3
|
+
/** cdn url for this script */
|
|
4
|
+
url: string;
|
|
5
|
+
/** specify any other libraries this script is depended on. These libraries will be loaded before this script if they were not loaded already. */
|
|
6
|
+
dependencies?: IKnownScript[];
|
|
7
|
+
/** specify global object name, if available. if this object exists - the script will not load, assuming it was already loaded
|
|
8
|
+
* Alternativly, provide a getter if it is more complex
|
|
9
|
+
*/
|
|
10
|
+
global: ksGlobal;
|
|
11
|
+
/** specify sod script name. if provided, and the sod in this name was already loaded - this script will not be loaded again. */
|
|
12
|
+
sodName?: string;
|
|
13
|
+
/** If this library requires a CSS file, add it here */
|
|
14
|
+
css?: string[];
|
|
15
|
+
/** If this library requires an RTL CSS file, add it here */
|
|
16
|
+
rtlCss?: string[];
|
|
17
|
+
/** set to true, to make sure known script will not try to load the non min version on debug */
|
|
18
|
+
forceMin?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface IDataJsRequestData {
|
|
2
|
+
__batchRequests: IDataJsBatchRequest[];
|
|
3
|
+
}
|
|
4
|
+
export interface IDataJsBatchRequest {
|
|
5
|
+
requestUri: string;
|
|
6
|
+
method: "GET" | "POST";
|
|
7
|
+
headers: { [key: string]: string; };
|
|
8
|
+
}
|
|
9
|
+
export interface IDataJsRequest {
|
|
10
|
+
requestUri: string;
|
|
11
|
+
method: "GET" | "POST";
|
|
12
|
+
headers: { [key: string]: string; };
|
|
13
|
+
data: IDataJsRequestData;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IDataJsResponseData<ResponseDataType> {
|
|
17
|
+
__batchResponses: { data: ResponseDataType; }[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IDataJsHandler { }
|
|
21
|
+
|
|
22
|
+
export interface IDataJs {
|
|
23
|
+
batchHandler: IDataJsHandler;
|
|
24
|
+
request<ResponseDataType>(request: IDataJsRequest, success: (data: IDataJsResponseData<ResponseDataType>, response: any) => void,
|
|
25
|
+
error: (error: string) => void,
|
|
26
|
+
handler: IDataJsHandler,
|
|
27
|
+
httpClient?: any,
|
|
28
|
+
metadata?: any): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ICSFrequency = "DAILY" | "WEEKLY" | "MONTHLY" | "YEARLY";
|
|
2
|
+
export type ICSDay = "SU" | "MO" | "TU" | "WE" | "TH" | "FR" | "SA";
|
|
3
|
+
|
|
4
|
+
export type ICS = () => {
|
|
5
|
+
/** add an event to this ICS file. begin and end need to be formatted in a way that is friendly to Date() -- Issue 572 */
|
|
6
|
+
addEvent(subject: string, description: string | {
|
|
7
|
+
/** non-outlook standard */
|
|
8
|
+
text: string;
|
|
9
|
+
/** special support for outlook, html */
|
|
10
|
+
html: string;
|
|
11
|
+
}, location: string, begin: string, end: string, recurrence?: {
|
|
12
|
+
freq: ICSFrequency;
|
|
13
|
+
/** A date string representing the date on which to end repitition. Must be friendly to Date() */
|
|
14
|
+
until?: string;
|
|
15
|
+
/** Alternative to until. Repeat the event count times. Must be an integer */
|
|
16
|
+
count?: number;
|
|
17
|
+
/** The interval of freq to recur at. For example, if freq is WEEKLY and interval is 2, the event will repeat every 2 weeks. Must be an integer. */
|
|
18
|
+
interval?: number;
|
|
19
|
+
/** Which days of the week the event is to occur. An array containing any of SU, MO, TU, WE, TH, FR, SA. */
|
|
20
|
+
byday?: ICSDay;
|
|
21
|
+
}): void;
|
|
22
|
+
/** get the ICS file content of the events added so far */
|
|
23
|
+
calendar(): string;
|
|
24
|
+
download(filename: string, extention?: string): void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
interface IKWizComGlobalsLibs {
|
|
29
|
+
ics?: ICS;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface IMSALBaseRequest { scopes: string[]; }
|
|
2
|
+
export interface IMSALConfig { }
|
|
3
|
+
export interface ITenantInfo {
|
|
4
|
+
environment: AzureEnvironment;
|
|
5
|
+
idOrName: string;
|
|
6
|
+
authorityUrl: string;
|
|
7
|
+
valid: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line no-shadow
|
|
11
|
+
export enum AzureEnvironment {
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
Production = 0,
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
PPE = 1,
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
China = 2,
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
Germany = 3,
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
USGovernment = 4
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MSALSampleLoginPopupScript = `<p id="msg">please wait...</p>
|
|
35
|
+
<script>
|
|
36
|
+
function finish() {
|
|
37
|
+
try {
|
|
38
|
+
var hash = window.location.hash;
|
|
39
|
+
if (hash[0] === "#") hash = hash.slice(1);//get rid of #
|
|
40
|
+
var hashDictionary = {};
|
|
41
|
+
hash.split("&").forEach(function (keyValue) {
|
|
42
|
+
if (keyValue !== "") {
|
|
43
|
+
var vals = keyValue.split("=");
|
|
44
|
+
hashDictionary[vals[0]] = decodeURIComponent(vals[1]);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (Object.keys(hashDictionary).length < 1)
|
|
48
|
+
window.close();//we lose the hash!
|
|
49
|
+
else if (hashDictionary.error && hashDictionary.error_description)
|
|
50
|
+
document.getElementById("msg").innerHTML = hashDictionary.error_description.replace(/\\+/g," ").replace(/\\n/g,"<br /><br />");
|
|
51
|
+
else if (hashDictionary.state) {
|
|
52
|
+
var origin = hashDictionary.state.split("|")[1];
|
|
53
|
+
if (origin) {
|
|
54
|
+
window.location.href = origin.split("#")[0] + window.location.hash;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} catch (e) { }
|
|
58
|
+
}
|
|
59
|
+
finish();
|
|
60
|
+
</script>`;
|
|
61
|
+
|
|
62
|
+
export function GetTokenAudiencePrefix(appId: string) {
|
|
63
|
+
return `api://${appId}`;
|
|
64
|
+
}
|
|
65
|
+
export function GetDefaultScope(appId: string) {
|
|
66
|
+
return `${GetTokenAudiencePrefix(appId)}/access_as_user`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface IMSAL {
|
|
70
|
+
AutoDiscoverTenantInfo: () => Promise<ITenantInfo>;
|
|
71
|
+
GetConfig: (clientId: string, authority: string, redirectUri: string) => Promise<IMSALConfig>;
|
|
72
|
+
GetTokenPopup: (config: IMSALConfig, requestOptions?: { scopes?: string[]; }) => Promise<string>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare global {
|
|
76
|
+
interface IKWizComGlobalsLibs {
|
|
77
|
+
msal?: IMSAL;
|
|
78
|
+
}
|
|
79
|
+
}
|