@kwiz/common 1.0.92 → 1.0.93

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 (106) hide show
  1. package/.github/workflows/npm-publish.yml +24 -24
  2. package/.madgerc +2 -2
  3. package/LICENSE +21 -21
  4. package/fix-folder-imports.js +26 -26
  5. package/lib/cjs/helpers/diagrams.js +38 -0
  6. package/lib/cjs/helpers/diagrams.js.map +1 -0
  7. package/lib/cjs/helpers/exports-index.js +1 -0
  8. package/lib/cjs/helpers/exports-index.js.map +1 -1
  9. package/lib/cjs/types/libs/msal.types.js +26 -26
  10. package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
  11. package/lib/esm/helpers/diagrams.js +35 -0
  12. package/lib/esm/helpers/diagrams.js.map +1 -0
  13. package/lib/esm/helpers/exports-index.js +1 -0
  14. package/lib/esm/helpers/exports-index.js.map +1 -1
  15. package/lib/esm/types/libs/msal.types.js +26 -26
  16. package/lib/esm/utils/sharepoint.rest/user.js +11 -11
  17. package/lib/types/helpers/diagrams.d.ts +10 -0
  18. package/lib/types/helpers/exports-index.d.ts +1 -0
  19. package/package.json +81 -81
  20. package/readme.md +17 -17
  21. package/src/_dependencies.ts +12 -12
  22. package/src/config.ts +17 -17
  23. package/src/helpers/Guid.ts +181 -181
  24. package/src/helpers/base64.ts +173 -173
  25. package/src/helpers/browser.test.js +13 -13
  26. package/src/helpers/browser.ts +1386 -1386
  27. package/src/helpers/browserinfo.ts +292 -292
  28. package/src/helpers/collections.base.test.js +25 -25
  29. package/src/helpers/collections.base.ts +437 -437
  30. package/src/helpers/collections.ts +107 -107
  31. package/src/helpers/color.ts +54 -54
  32. package/src/helpers/cookies.ts +59 -59
  33. package/src/helpers/date.test.js +119 -119
  34. package/src/helpers/date.ts +188 -188
  35. package/src/helpers/debug.ts +186 -186
  36. package/src/helpers/diagrams.ts +44 -0
  37. package/src/helpers/emails.ts +6 -6
  38. package/src/helpers/eval.ts +5 -5
  39. package/src/helpers/exports-index.ts +1 -0
  40. package/src/helpers/file.test.js +50 -50
  41. package/src/helpers/file.ts +60 -60
  42. package/src/helpers/flatted.ts +149 -149
  43. package/src/helpers/functions.ts +16 -16
  44. package/src/helpers/graph/calendar.types.ts +10 -10
  45. package/src/helpers/http.ts +69 -69
  46. package/src/helpers/images.ts +22 -22
  47. package/src/helpers/json.ts +38 -38
  48. package/src/helpers/md5.ts +189 -189
  49. package/src/helpers/objects.test.js +33 -33
  50. package/src/helpers/objects.ts +274 -274
  51. package/src/helpers/promises.test.js +37 -37
  52. package/src/helpers/promises.ts +165 -165
  53. package/src/helpers/random.ts +27 -27
  54. package/src/helpers/scheduler/scheduler.test.js +103 -103
  55. package/src/helpers/scheduler/scheduler.ts +131 -131
  56. package/src/helpers/sharepoint.ts +776 -776
  57. package/src/helpers/strings.test.js +101 -101
  58. package/src/helpers/strings.ts +317 -317
  59. package/src/helpers/typecheckers.test.js +34 -34
  60. package/src/helpers/typecheckers.ts +266 -266
  61. package/src/helpers/url.test.js +43 -43
  62. package/src/helpers/url.ts +207 -207
  63. package/src/helpers/urlhelper.ts +111 -111
  64. package/src/index.ts +6 -6
  65. package/src/types/auth.ts +54 -54
  66. package/src/types/common.types.ts +15 -15
  67. package/src/types/flatted.types.ts +59 -59
  68. package/src/types/globals.types.ts +6 -6
  69. package/src/types/graph/calendar.types.ts +80 -80
  70. package/src/types/knownscript.types.ts +18 -18
  71. package/src/types/libs/datajs.types.ts +28 -28
  72. package/src/types/libs/ics.types.ts +30 -30
  73. package/src/types/libs/msal.types.ts +49 -49
  74. package/src/types/locales.ts +124 -124
  75. package/src/types/localstoragecache.types.ts +8 -8
  76. package/src/types/location.types.ts +27 -27
  77. package/src/types/moment.ts +11 -11
  78. package/src/types/regex.types.ts +16 -16
  79. package/src/types/rest.types.ts +95 -95
  80. package/src/types/sharepoint.types.ts +1465 -1465
  81. package/src/types/sharepoint.utils.types.ts +287 -287
  82. package/src/utils/auth/common.ts +74 -74
  83. package/src/utils/auth/discovery.test.js +12 -12
  84. package/src/utils/auth/discovery.ts +132 -132
  85. package/src/utils/base64.ts +27 -27
  86. package/src/utils/consolelogger.ts +320 -320
  87. package/src/utils/date.ts +35 -35
  88. package/src/utils/emails.ts +24 -24
  89. package/src/utils/knownscript.ts +286 -286
  90. package/src/utils/localstoragecache.ts +441 -441
  91. package/src/utils/rest.ts +501 -501
  92. package/src/utils/script.ts +170 -170
  93. package/src/utils/sharepoint.rest/common.ts +154 -154
  94. package/src/utils/sharepoint.rest/date.ts +62 -62
  95. package/src/utils/sharepoint.rest/file.folder.ts +598 -598
  96. package/src/utils/sharepoint.rest/item.ts +547 -547
  97. package/src/utils/sharepoint.rest/list.ts +1480 -1480
  98. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
  99. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
  100. package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
  101. package/src/utils/sharepoint.rest/location.ts +141 -141
  102. package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
  103. package/src/utils/sharepoint.rest/user-search.ts +252 -252
  104. package/src/utils/sharepoint.rest/user.ts +491 -491
  105. package/src/utils/sharepoint.rest/web.ts +1384 -1384
  106. package/src/utils/sod.ts +194 -194
@@ -1,61 +1,61 @@
1
- import { escapeRegExp } from "./strings";
2
-
3
- //https://support.microsoft.com/en-gb/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa
4
- //These names aren't allowed for files or folders: .lock, CON, PRN, AUX, NUL, COM0 - COM9, LPT0 - LPT9, _vti_,
5
- //desktop.ini, any filename starting with ~$. "_vti_" can't appear anywhere in a file name.
6
-
7
- export var ImageFileTypes = ["png", "jpg", "jpeg", "gif", "bmp", "svg", "jfif"];
8
-
9
- function _getRegexCollection() {
10
- return {
11
- IllegalCharsRegex: new RegExp("[" + escapeRegExp(`"*:<>?/\\|`) + "]", "gi"),
12
- IllegalCharsExtraRegex: new RegExp("[" + escapeRegExp(`~"#%&*:<>?/\\|`) + "]", "gi"),
13
- IllegalNamesRegex: /^(\.lock|CON|PRN|AUX|NUL|COM\d|LPT\d|.*_VTI_.*|~\$.*)$/gi,
14
- IsDesktopIni: /^desktop\.ini$/gi
15
- };
16
- }
17
-
18
- export function validateFilename(fileNameWithExtension: string) {
19
- let filenameWithOutExtension = fileNameWithExtension;
20
- let split = filenameWithOutExtension.split(".");
21
- split.pop();
22
- filenameWithOutExtension = split.join(".");
23
-
24
- let regexCollection = _getRegexCollection();
25
-
26
- let hasIllegalCharacter = regexCollection.IllegalCharsRegex.test(filenameWithOutExtension);
27
- let hasIllegalName = regexCollection.IllegalNamesRegex.test(filenameWithOutExtension) || regexCollection.IsDesktopIni.test(fileNameWithExtension);
28
-
29
- return {
30
- hasIllegalCharacter,
31
- hasIllegalName,
32
- valid: !hasIllegalCharacter && !hasIllegalName
33
- };
34
- }
35
-
36
- export function validateFoldername(folderName: string) {
37
- let regexCollection = _getRegexCollection();
38
-
39
- let hasIllegalCharacter = regexCollection.IllegalCharsRegex.test(folderName);
40
- let hasIllegalName = regexCollection.IllegalNamesRegex.test(folderName) || regexCollection.IsDesktopIni.test(folderName);
41
-
42
- return {
43
- hasIllegalCharacter,
44
- hasIllegalName,
45
- valid: !hasIllegalCharacter && !hasIllegalName
46
- };
47
- }
48
-
49
- export function validateAndSetFilename(fileNameWithExtension: string) {
50
- let regexCollection = _getRegexCollection();
51
-
52
- let validateFilenameChk = validateFilename(fileNameWithExtension);
53
- if (!validateFilenameChk.valid || regexCollection.IllegalCharsExtraRegex.test(fileNameWithExtension)) {
54
- fileNameWithExtension =
55
- fileNameWithExtension.replace(regexCollection.IllegalCharsRegex, "")
56
- .replace(regexCollection.IllegalCharsExtraRegex, "")
57
- .replace(regexCollection.IllegalNamesRegex, "")
58
- .replace(regexCollection.IsDesktopIni, "");
59
- }
60
- return fileNameWithExtension;
1
+ import { escapeRegExp } from "./strings";
2
+
3
+ //https://support.microsoft.com/en-gb/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa
4
+ //These names aren't allowed for files or folders: .lock, CON, PRN, AUX, NUL, COM0 - COM9, LPT0 - LPT9, _vti_,
5
+ //desktop.ini, any filename starting with ~$. "_vti_" can't appear anywhere in a file name.
6
+
7
+ export var ImageFileTypes = ["png", "jpg", "jpeg", "gif", "bmp", "svg", "jfif"];
8
+
9
+ function _getRegexCollection() {
10
+ return {
11
+ IllegalCharsRegex: new RegExp("[" + escapeRegExp(`"*:<>?/\\|`) + "]", "gi"),
12
+ IllegalCharsExtraRegex: new RegExp("[" + escapeRegExp(`~"#%&*:<>?/\\|`) + "]", "gi"),
13
+ IllegalNamesRegex: /^(\.lock|CON|PRN|AUX|NUL|COM\d|LPT\d|.*_VTI_.*|~\$.*)$/gi,
14
+ IsDesktopIni: /^desktop\.ini$/gi
15
+ };
16
+ }
17
+
18
+ export function validateFilename(fileNameWithExtension: string) {
19
+ let filenameWithOutExtension = fileNameWithExtension;
20
+ let split = filenameWithOutExtension.split(".");
21
+ split.pop();
22
+ filenameWithOutExtension = split.join(".");
23
+
24
+ let regexCollection = _getRegexCollection();
25
+
26
+ let hasIllegalCharacter = regexCollection.IllegalCharsRegex.test(filenameWithOutExtension);
27
+ let hasIllegalName = regexCollection.IllegalNamesRegex.test(filenameWithOutExtension) || regexCollection.IsDesktopIni.test(fileNameWithExtension);
28
+
29
+ return {
30
+ hasIllegalCharacter,
31
+ hasIllegalName,
32
+ valid: !hasIllegalCharacter && !hasIllegalName
33
+ };
34
+ }
35
+
36
+ export function validateFoldername(folderName: string) {
37
+ let regexCollection = _getRegexCollection();
38
+
39
+ let hasIllegalCharacter = regexCollection.IllegalCharsRegex.test(folderName);
40
+ let hasIllegalName = regexCollection.IllegalNamesRegex.test(folderName) || regexCollection.IsDesktopIni.test(folderName);
41
+
42
+ return {
43
+ hasIllegalCharacter,
44
+ hasIllegalName,
45
+ valid: !hasIllegalCharacter && !hasIllegalName
46
+ };
47
+ }
48
+
49
+ export function validateAndSetFilename(fileNameWithExtension: string) {
50
+ let regexCollection = _getRegexCollection();
51
+
52
+ let validateFilenameChk = validateFilename(fileNameWithExtension);
53
+ if (!validateFilenameChk.valid || regexCollection.IllegalCharsExtraRegex.test(fileNameWithExtension)) {
54
+ fileNameWithExtension =
55
+ fileNameWithExtension.replace(regexCollection.IllegalCharsRegex, "")
56
+ .replace(regexCollection.IllegalCharsExtraRegex, "")
57
+ .replace(regexCollection.IllegalNamesRegex, "")
58
+ .replace(regexCollection.IsDesktopIni, "");
59
+ }
60
+ return fileNameWithExtension;
61
61
  }
@@ -1,150 +1,150 @@
1
- /* eslint-disable */
2
-
3
- /*! (c) 2020 Andrea Giammarchi */
4
-
5
- import { IFlatted } from "../types/flatted.types";
6
- import { isNullOrEmptyArray } from "./typecheckers";
7
-
8
- /** Version 3.2.9 */
9
- /**
10
- * Fast and minimal circular JSON parser.
11
- * logic example
12
- ```js
13
- var a = [{one: 1}, {two: '2'}];
14
- a[0].a = a;
15
- // a is the main object, will be at index '0'
16
- // {one: 1} is the second object, index '1'
17
- // {two: '2'} the third, in '2', and it has a string
18
- // which will be found at index '3'
19
- Flatted.stringify(a);
20
- // [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
21
- // a[one,two] {one: 1, a} {two: '2'} '2'
22
- ```
23
- */
24
- const { parse: $parse, stringify: $stringify } = JSON;
25
- const { keys } = Object;
26
-
27
- const Primitive = String; // it could be Number
28
- const primitive = 'string'; // it could be 'number'
29
-
30
- const ignore = {};
31
- const object = 'object';
32
-
33
- const noop = (_, value) => value;
34
-
35
- const primitives = value => (
36
- value instanceof Primitive ? Primitive(value) : value
37
- );
38
-
39
- const Primitives = (_, value) => (
40
- typeof value === primitive ? new Primitive(value) : value
41
- );
42
-
43
- const revive = (input, parsed, output, $) => {
44
- const lazy = [];
45
- for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
46
- const k = ke[y];
47
- const value = output[k];
48
- if (value instanceof Primitive) {
49
- const tmp = input[value as string];
50
- if (typeof tmp === object && !parsed.has(tmp)) {
51
- parsed.add(tmp);
52
- output[k] = ignore;
53
- lazy.push({ k, a: [input, parsed, tmp, $] });
54
- }
55
- else
56
- output[k] = $.call(output, k, tmp);
57
- }
58
- else if (output[k] !== ignore)
59
- output[k] = $.call(output, k, value);
60
- }
61
- for (let { length } = lazy, i = 0; i < length; i++) {
62
- const { k, a } = lazy[i];
63
- output[k] = $.call(output, k, revive.apply(null, a));
64
- }
65
- return output;
66
- };
67
-
68
- const set = (known, input, value) => {
69
- const index = Primitive(input.push(value) - 1);
70
- known.set(value, index);
71
- return index;
72
- };
73
-
74
- const parse = (text, reviver?) => {
75
- const input = $parse(text, Primitives).map(primitives);
76
- const value = input[0];
77
- const $ = reviver || noop;
78
- const tmp = typeof value === object && value ?
79
- revive(input, new Set, value, $) :
80
- value;
81
- return $.call({ '': tmp }, '', tmp);
82
- };
83
- //exports.parse = parse;
84
-
85
- const stringify = (value, replacer?, space?) => {
86
- const $ = replacer && typeof replacer === object ?
87
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
88
- (replacer || noop);
89
- const known = new Map;
90
- const input = [];
91
- const output = [];
92
- let i = +set(known, input, $.call({ '': value }, '', value));
93
- let firstRun = !i;
94
- while (i < input.length) {
95
- firstRun = true;
96
- output[i] = $stringify(input[i++], replace, space);
97
- }
98
- return '[' + output.join(',') + ']';
99
- function replace(key, value) {
100
- if (firstRun) {
101
- firstRun = !firstRun;
102
- return value;
103
- }
104
- const after = $.call(this, key, value);
105
- switch (typeof after) {
106
- case object:
107
- if (after === null) return after;
108
- return known.get(after) || set(known, input, after);
109
- case primitive:
110
- return known.get(after) || set(known, input, after);
111
- }
112
- return after;
113
- }
114
- };
115
- //exports.stringify = stringify;
116
-
117
- const toJSON = any => $parse(stringify(any));
118
- //exports.toJSON = toJSON;
119
- const fromJSON = any => parse($stringify(any));
120
- //exports.fromJSON = fromJSON;
121
-
122
-
123
- /*! (c) 2020 Andrea Giammarchi */
124
- /**
125
- * Fast and minimal circular JSON parser.
126
- * logic example
127
- ```js
128
- var a = [{one: 1}, {two: '2'}];
129
- a[0].a = a;
130
- // a is the main object, will be at index '0'
131
- // {one: 1} is the second object, index '1'
132
- // {two: '2'} the third, in '2', and it has a string
133
- // which will be found at index '3'
134
- Flatted.stringify(a);
135
- // [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
136
- // a[one,two] {one: 1, a} {two: '2'} '2'
137
- ```
138
- */
139
- export var flatted: IFlatted = {
140
- toJSON: toJSON,
141
- fromJSON: fromJSON,
142
- stringify: stringify,
143
- parse: parse
144
- };
145
-
146
- export function flattedClone<T>(obj: T): T {
147
- if (isNullOrEmptyArray(obj)) return obj;
148
- //json clone won't work on circular object. must use flatted.
149
- return flatted.parse(flatted.stringify(obj));
1
+ /* eslint-disable */
2
+
3
+ /*! (c) 2020 Andrea Giammarchi */
4
+
5
+ import { IFlatted } from "../types/flatted.types";
6
+ import { isNullOrEmptyArray } from "./typecheckers";
7
+
8
+ /** Version 3.2.9 */
9
+ /**
10
+ * Fast and minimal circular JSON parser.
11
+ * logic example
12
+ ```js
13
+ var a = [{one: 1}, {two: '2'}];
14
+ a[0].a = a;
15
+ // a is the main object, will be at index '0'
16
+ // {one: 1} is the second object, index '1'
17
+ // {two: '2'} the third, in '2', and it has a string
18
+ // which will be found at index '3'
19
+ Flatted.stringify(a);
20
+ // [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
21
+ // a[one,two] {one: 1, a} {two: '2'} '2'
22
+ ```
23
+ */
24
+ const { parse: $parse, stringify: $stringify } = JSON;
25
+ const { keys } = Object;
26
+
27
+ const Primitive = String; // it could be Number
28
+ const primitive = 'string'; // it could be 'number'
29
+
30
+ const ignore = {};
31
+ const object = 'object';
32
+
33
+ const noop = (_, value) => value;
34
+
35
+ const primitives = value => (
36
+ value instanceof Primitive ? Primitive(value) : value
37
+ );
38
+
39
+ const Primitives = (_, value) => (
40
+ typeof value === primitive ? new Primitive(value) : value
41
+ );
42
+
43
+ const revive = (input, parsed, output, $) => {
44
+ const lazy = [];
45
+ for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
46
+ const k = ke[y];
47
+ const value = output[k];
48
+ if (value instanceof Primitive) {
49
+ const tmp = input[value as string];
50
+ if (typeof tmp === object && !parsed.has(tmp)) {
51
+ parsed.add(tmp);
52
+ output[k] = ignore;
53
+ lazy.push({ k, a: [input, parsed, tmp, $] });
54
+ }
55
+ else
56
+ output[k] = $.call(output, k, tmp);
57
+ }
58
+ else if (output[k] !== ignore)
59
+ output[k] = $.call(output, k, value);
60
+ }
61
+ for (let { length } = lazy, i = 0; i < length; i++) {
62
+ const { k, a } = lazy[i];
63
+ output[k] = $.call(output, k, revive.apply(null, a));
64
+ }
65
+ return output;
66
+ };
67
+
68
+ const set = (known, input, value) => {
69
+ const index = Primitive(input.push(value) - 1);
70
+ known.set(value, index);
71
+ return index;
72
+ };
73
+
74
+ const parse = (text, reviver?) => {
75
+ const input = $parse(text, Primitives).map(primitives);
76
+ const value = input[0];
77
+ const $ = reviver || noop;
78
+ const tmp = typeof value === object && value ?
79
+ revive(input, new Set, value, $) :
80
+ value;
81
+ return $.call({ '': tmp }, '', tmp);
82
+ };
83
+ //exports.parse = parse;
84
+
85
+ const stringify = (value, replacer?, space?) => {
86
+ const $ = replacer && typeof replacer === object ?
87
+ (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
88
+ (replacer || noop);
89
+ const known = new Map;
90
+ const input = [];
91
+ const output = [];
92
+ let i = +set(known, input, $.call({ '': value }, '', value));
93
+ let firstRun = !i;
94
+ while (i < input.length) {
95
+ firstRun = true;
96
+ output[i] = $stringify(input[i++], replace, space);
97
+ }
98
+ return '[' + output.join(',') + ']';
99
+ function replace(key, value) {
100
+ if (firstRun) {
101
+ firstRun = !firstRun;
102
+ return value;
103
+ }
104
+ const after = $.call(this, key, value);
105
+ switch (typeof after) {
106
+ case object:
107
+ if (after === null) return after;
108
+ return known.get(after) || set(known, input, after);
109
+ case primitive:
110
+ return known.get(after) || set(known, input, after);
111
+ }
112
+ return after;
113
+ }
114
+ };
115
+ //exports.stringify = stringify;
116
+
117
+ const toJSON = any => $parse(stringify(any));
118
+ //exports.toJSON = toJSON;
119
+ const fromJSON = any => parse($stringify(any));
120
+ //exports.fromJSON = fromJSON;
121
+
122
+
123
+ /*! (c) 2020 Andrea Giammarchi */
124
+ /**
125
+ * Fast and minimal circular JSON parser.
126
+ * logic example
127
+ ```js
128
+ var a = [{one: 1}, {two: '2'}];
129
+ a[0].a = a;
130
+ // a is the main object, will be at index '0'
131
+ // {one: 1} is the second object, index '1'
132
+ // {two: '2'} the third, in '2', and it has a string
133
+ // which will be found at index '3'
134
+ Flatted.stringify(a);
135
+ // [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
136
+ // a[one,two] {one: 1, a} {two: '2'} '2'
137
+ ```
138
+ */
139
+ export var flatted: IFlatted = {
140
+ toJSON: toJSON,
141
+ fromJSON: fromJSON,
142
+ stringify: stringify,
143
+ parse: parse
144
+ };
145
+
146
+ export function flattedClone<T>(obj: T): T {
147
+ if (isNullOrEmptyArray(obj)) return obj;
148
+ //json clone won't work on circular object. must use flatted.
149
+ return flatted.parse(flatted.stringify(obj));
150
150
  }
@@ -1,17 +1,17 @@
1
- import { isFunction } from "./typecheckers";
2
-
3
- export function wrapFunction<ValueType, ReturnType>(f: (value: ValueType) => ReturnType, props: {
4
- before?: (value: ValueType) => ValueType;
5
- after?: (value: ValueType, returned: ReturnType) => void;
6
- }) {
7
- return (v: ValueType) => {
8
- if (isFunction(props.before)) {
9
- v = props.before(v);
10
- }
11
- let result = f(v);
12
- if (isFunction(props.after))
13
- props.after(v, result);
14
-
15
- return result;
16
- };
1
+ import { isFunction } from "./typecheckers";
2
+
3
+ export function wrapFunction<ValueType, ReturnType>(f: (value: ValueType) => ReturnType, props: {
4
+ before?: (value: ValueType) => ValueType;
5
+ after?: (value: ValueType, returned: ReturnType) => void;
6
+ }) {
7
+ return (v: ValueType) => {
8
+ if (isFunction(props.before)) {
9
+ v = props.before(v);
10
+ }
11
+ let result = f(v);
12
+ if (isFunction(props.after))
13
+ props.after(v, result);
14
+
15
+ return result;
16
+ };
17
17
  }
@@ -1,11 +1,11 @@
1
- import { IGraphEventAttendee, IGraphEventUser } from "../../types/graph/calendar.types";
2
- import { isNullOrEmptyString } from "../typecheckers";
3
-
4
- export function IsGraphEventUser(obj: any): obj is IGraphEventUser {
5
- let asEA = obj as IGraphEventUser;
6
- return asEA && asEA.emailAddress && !isNullOrEmptyString(asEA.emailAddress.address);
7
- }
8
- export function IsGraphEventAttendee(obj: any): obj is IGraphEventAttendee {
9
- let asEA = obj as IGraphEventAttendee;
10
- return IsGraphEventUser(obj) && asEA.status && !isNullOrEmptyString(asEA.type);
1
+ import { IGraphEventAttendee, IGraphEventUser } from "../../types/graph/calendar.types";
2
+ import { isNullOrEmptyString } from "../typecheckers";
3
+
4
+ export function IsGraphEventUser(obj: any): obj is IGraphEventUser {
5
+ let asEA = obj as IGraphEventUser;
6
+ return asEA && asEA.emailAddress && !isNullOrEmptyString(asEA.emailAddress.address);
7
+ }
8
+ export function IsGraphEventAttendee(obj: any): obj is IGraphEventAttendee {
9
+ let asEA = obj as IGraphEventAttendee;
10
+ return IsGraphEventUser(obj) && asEA.status && !isNullOrEmptyString(asEA.type);
11
11
  }
@@ -1,70 +1,70 @@
1
- import { objectValues } from "./objects";
2
- import { isNullOrUndefined } from "./typecheckers";
3
-
4
- // eslint-disable-next-line no-shadow
5
- export enum CommonHttpHeaderNames {
6
- Accept = "Accept",
7
- Authorization = "Authorization",
8
- ContentType = "content-type",
9
- XHTTPMethod = "X-HTTP-Method",
10
- XRapidApiHost = "x-rapidapi-host",
11
- XRapidApiKey = "x-rapidapi-key"
12
- }
13
-
14
- // eslint-disable-next-line no-shadow
15
- enum AcceptOrContentTypeHeaderValues {
16
- JsonVerbose = "application/json; odata=verbose",
17
- JsonMinimal = "application/json; odata=minimal",
18
- JsonNometadata = "application/json; odata=nometadata"
19
- }
20
-
21
- // eslint-disable-next-line no-shadow
22
- enum AuthorizationHeaderValues {
23
- Bearer = "Bearer [token]",
24
- Basic = "Basic [user]:[password]"
25
- }
26
-
27
- // eslint-disable-next-line no-shadow
28
- enum XHttpMethodHeaderValues {
29
- MERGE = "MERGE",
30
- DELETE = "DELETE",
31
- PUT = "PUT"
32
- }
33
-
34
- export function GetCommonHeaderNames() {
35
- return objectValues<CommonHttpHeaderNames>(CommonHttpHeaderNames);
36
- }
37
-
38
- export function GetCommonHeaderValueSuggestions(headerName: CommonHttpHeaderNames | string) {
39
- if (isNullOrUndefined(headerName)) {
40
- return [];
41
- }
42
-
43
- let parsedHeaderName = _getValueByKeyForStringEnum(headerName);
44
-
45
- if (isNullOrUndefined(parsedHeaderName)) {
46
- return [];
47
- }
48
-
49
- switch (parsedHeaderName) {
50
- case CommonHttpHeaderNames.Accept:
51
- case CommonHttpHeaderNames.ContentType:
52
- return objectValues<AcceptOrContentTypeHeaderValues>(AcceptOrContentTypeHeaderValues);
53
- case CommonHttpHeaderNames.Authorization:
54
- return objectValues<AuthorizationHeaderValues>(AuthorizationHeaderValues);
55
- case CommonHttpHeaderNames.XHTTPMethod:
56
- return objectValues<XHttpMethodHeaderValues>(XHttpMethodHeaderValues);
57
- default:
58
- return [];
59
- }
60
- }
61
-
62
- function _getValueByKeyForStringEnum(keyOrValue: string | CommonHttpHeaderNames) {
63
- let found = objectValues<CommonHttpHeaderNames>(CommonHttpHeaderNames).filter((value) => {
64
- return value === keyOrValue;
65
- })[0];
66
- if (isNullOrUndefined(found)) {
67
- found = CommonHttpHeaderNames[keyOrValue as keyof typeof CommonHttpHeaderNames];
68
- }
69
- return found;
1
+ import { objectValues } from "./objects";
2
+ import { isNullOrUndefined } from "./typecheckers";
3
+
4
+ // eslint-disable-next-line no-shadow
5
+ export enum CommonHttpHeaderNames {
6
+ Accept = "Accept",
7
+ Authorization = "Authorization",
8
+ ContentType = "content-type",
9
+ XHTTPMethod = "X-HTTP-Method",
10
+ XRapidApiHost = "x-rapidapi-host",
11
+ XRapidApiKey = "x-rapidapi-key"
12
+ }
13
+
14
+ // eslint-disable-next-line no-shadow
15
+ enum AcceptOrContentTypeHeaderValues {
16
+ JsonVerbose = "application/json; odata=verbose",
17
+ JsonMinimal = "application/json; odata=minimal",
18
+ JsonNometadata = "application/json; odata=nometadata"
19
+ }
20
+
21
+ // eslint-disable-next-line no-shadow
22
+ enum AuthorizationHeaderValues {
23
+ Bearer = "Bearer [token]",
24
+ Basic = "Basic [user]:[password]"
25
+ }
26
+
27
+ // eslint-disable-next-line no-shadow
28
+ enum XHttpMethodHeaderValues {
29
+ MERGE = "MERGE",
30
+ DELETE = "DELETE",
31
+ PUT = "PUT"
32
+ }
33
+
34
+ export function GetCommonHeaderNames() {
35
+ return objectValues<CommonHttpHeaderNames>(CommonHttpHeaderNames);
36
+ }
37
+
38
+ export function GetCommonHeaderValueSuggestions(headerName: CommonHttpHeaderNames | string) {
39
+ if (isNullOrUndefined(headerName)) {
40
+ return [];
41
+ }
42
+
43
+ let parsedHeaderName = _getValueByKeyForStringEnum(headerName);
44
+
45
+ if (isNullOrUndefined(parsedHeaderName)) {
46
+ return [];
47
+ }
48
+
49
+ switch (parsedHeaderName) {
50
+ case CommonHttpHeaderNames.Accept:
51
+ case CommonHttpHeaderNames.ContentType:
52
+ return objectValues<AcceptOrContentTypeHeaderValues>(AcceptOrContentTypeHeaderValues);
53
+ case CommonHttpHeaderNames.Authorization:
54
+ return objectValues<AuthorizationHeaderValues>(AuthorizationHeaderValues);
55
+ case CommonHttpHeaderNames.XHTTPMethod:
56
+ return objectValues<XHttpMethodHeaderValues>(XHttpMethodHeaderValues);
57
+ default:
58
+ return [];
59
+ }
60
+ }
61
+
62
+ function _getValueByKeyForStringEnum(keyOrValue: string | CommonHttpHeaderNames) {
63
+ let found = objectValues<CommonHttpHeaderNames>(CommonHttpHeaderNames).filter((value) => {
64
+ return value === keyOrValue;
65
+ })[0];
66
+ if (isNullOrUndefined(found)) {
67
+ found = CommonHttpHeaderNames[keyOrValue as keyof typeof CommonHttpHeaderNames];
68
+ }
69
+ return found;
70
70
  }