@kwiz/common 1.0.78 → 1.0.79

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 (113) hide show
  1. package/.github/workflows/npm-publish.yml +24 -0
  2. package/.madgerc +2 -2
  3. package/LICENSE +21 -21
  4. package/fix-folder-imports.js +26 -26
  5. package/lib/cjs/helpers/sharepoint.js +5 -1
  6. package/lib/cjs/helpers/sharepoint.js.map +1 -1
  7. package/lib/cjs/types/libs/msal.types.js +26 -26
  8. package/lib/cjs/utils/sharepoint.rest/list.js +1 -1
  9. package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -1
  10. package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
  11. package/lib/esm/helpers/sharepoint.js +3 -0
  12. package/lib/esm/helpers/sharepoint.js.map +1 -1
  13. package/lib/esm/types/libs/msal.types.js +26 -26
  14. package/lib/esm/utils/sharepoint.rest/list.js +2 -2
  15. package/lib/esm/utils/sharepoint.rest/list.js.map +1 -1
  16. package/lib/esm/utils/sharepoint.rest/user.js +11 -11
  17. package/lib/types/helpers/sharepoint.d.ts +1 -0
  18. package/package.json +77 -77
  19. package/readme.md +17 -17
  20. package/src/_dependencies.ts +12 -12
  21. package/src/config.ts +17 -17
  22. package/src/helpers/Guid.ts +181 -181
  23. package/src/helpers/base64.ts +173 -173
  24. package/src/helpers/browser.test.js +13 -13
  25. package/src/helpers/browser.ts +1348 -1348
  26. package/src/helpers/browserinfo.ts +292 -292
  27. package/src/helpers/collections.base.test.js +25 -25
  28. package/src/helpers/collections.base.ts +437 -437
  29. package/src/helpers/collections.ts +107 -107
  30. package/src/helpers/color.ts +54 -54
  31. package/src/helpers/cookies.ts +59 -59
  32. package/src/helpers/date.test.js +119 -119
  33. package/src/helpers/date.ts +188 -188
  34. package/src/helpers/debug.ts +186 -186
  35. package/src/helpers/emails.ts +6 -6
  36. package/src/helpers/eval.ts +5 -5
  37. package/src/helpers/file.test.js +50 -50
  38. package/src/helpers/file.ts +58 -58
  39. package/src/helpers/flatted.ts +149 -149
  40. package/src/helpers/functions.ts +16 -16
  41. package/src/helpers/graph/calendar.types.ts +10 -10
  42. package/src/helpers/http.ts +69 -69
  43. package/src/helpers/images.ts +22 -22
  44. package/src/helpers/json.ts +38 -38
  45. package/src/helpers/md5.ts +189 -189
  46. package/src/helpers/objects.test.js +33 -33
  47. package/src/helpers/objects.ts +270 -270
  48. package/src/helpers/promises.test.js +37 -37
  49. package/src/helpers/promises.ts +165 -165
  50. package/src/helpers/random.ts +27 -27
  51. package/src/helpers/scheduler/scheduler.test.js +103 -103
  52. package/src/helpers/scheduler/scheduler.ts +131 -131
  53. package/src/helpers/sharepoint.ts +776 -772
  54. package/src/helpers/strings.test.js +101 -101
  55. package/src/helpers/strings.ts +317 -317
  56. package/src/helpers/typecheckers.test.js +34 -34
  57. package/src/helpers/typecheckers.ts +262 -262
  58. package/src/helpers/url.test.js +43 -43
  59. package/src/helpers/url.ts +207 -207
  60. package/src/helpers/urlhelper.ts +111 -111
  61. package/src/index.ts +6 -6
  62. package/src/types/auth.ts +54 -54
  63. package/src/types/common.types.ts +15 -15
  64. package/src/types/flatted.types.ts +59 -59
  65. package/src/types/globals.types.ts +6 -6
  66. package/src/types/graph/calendar.types.ts +80 -80
  67. package/src/types/knownscript.types.ts +18 -18
  68. package/src/types/libs/datajs.types.ts +28 -28
  69. package/src/types/libs/ics.types.ts +30 -30
  70. package/src/types/libs/msal.types.ts +49 -49
  71. package/src/types/locales.ts +124 -124
  72. package/src/types/localstoragecache.types.ts +8 -8
  73. package/src/types/location.types.ts +27 -27
  74. package/src/types/moment.ts +11 -11
  75. package/src/types/regex.types.ts +16 -16
  76. package/src/types/rest.types.ts +95 -95
  77. package/src/types/sharepoint.types.ts +1465 -1465
  78. package/src/types/sharepoint.utils.types.ts +287 -287
  79. package/src/utils/auth/common.ts +74 -74
  80. package/src/utils/auth/discovery.test.js +12 -12
  81. package/src/utils/auth/discovery.ts +132 -132
  82. package/src/utils/base64.ts +27 -27
  83. package/src/utils/consolelogger.ts +320 -320
  84. package/src/utils/date.ts +35 -35
  85. package/src/utils/emails.ts +24 -24
  86. package/src/utils/knownscript.ts +286 -286
  87. package/src/utils/localstoragecache.ts +441 -441
  88. package/src/utils/rest.ts +501 -501
  89. package/src/utils/script.ts +170 -170
  90. package/src/utils/sharepoint.rest/common.ts +154 -154
  91. package/src/utils/sharepoint.rest/date.ts +62 -62
  92. package/src/utils/sharepoint.rest/file.folder.ts +598 -598
  93. package/src/utils/sharepoint.rest/item.ts +547 -547
  94. package/src/utils/sharepoint.rest/list.ts +1388 -1388
  95. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
  96. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
  97. package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
  98. package/src/utils/sharepoint.rest/location.ts +141 -141
  99. package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
  100. package/src/utils/sharepoint.rest/user-search.ts +252 -252
  101. package/src/utils/sharepoint.rest/user.ts +491 -491
  102. package/src/utils/sharepoint.rest/web.ts +1384 -1384
  103. package/src/utils/sod.ts +194 -194
  104. package/lib/cjs/helpers/_dependencies.js +0 -21
  105. package/lib/cjs/helpers/_dependencies.js.map +0 -1
  106. package/lib/cjs/utils/_dependencies.js +0 -24
  107. package/lib/cjs/utils/_dependencies.js.map +0 -1
  108. package/lib/esm/helpers/_dependencies.js +0 -3
  109. package/lib/esm/helpers/_dependencies.js.map +0 -1
  110. package/lib/esm/utils/_dependencies.js +0 -4
  111. package/lib/esm/utils/_dependencies.js.map +0 -1
  112. package/lib/types/helpers/_dependencies.d.ts +0 -2
  113. package/lib/types/utils/_dependencies.d.ts +0 -3
@@ -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
  }
@@ -1,23 +1,23 @@
1
- const prefix = "https://apps.kwizcom.com/products/common/images/";
2
-
3
- export const LOGO_ANIM_SMALL = `${prefix}logo/anim-small.gif`;
4
- export const LOGO_ANIM = `${prefix}logo/anim.gif`;
5
-
6
- export const LOGO_BLACK_HORIZONTAL = `${prefix}logo/black/horizontal.png`;
7
- export const LOGO_BLACK_SQUARE = `${prefix}logo/black/square.png`;
8
- export const LOGO_BLACK_VERTICAL = `${prefix}logo/black/vertical.png`;
9
-
10
- export const LOGO_BLUE_HORIZONTAL = `${prefix}logo/blue/horizontal.png`;
11
- export const LOGO_BLUE_SQUARE = `${prefix}logo/blue/square.png`;
12
- export const LOGO_BLUE_VERTICAL = `${prefix}logo/blue/vertical.png`;
13
-
14
- export const LOGO_CYAN_HORIZONTAL = `${prefix}logo/cyan/horizontal.png`;
15
- export const LOGO_CYAN_VERTICAL = `${prefix}logo/cyan/vertical.png`;
16
-
17
- export const LOGO_GRAD_HORIZONTAL = `${prefix}logo/grad/horizontal.png`;
18
- export const LOGO_GRAD_SQUARE = `${prefix}logo/grad/square.png`;
19
- export const LOGO_GRAD_VERTICAL = `${prefix}logo/grad/vertical.png`;
20
-
21
- export const LOGO_WHITE_HORIZONTAL = `${prefix}logo/white/horizontal.png`;
22
- export const LOGO_WHITE_SQUARE = `${prefix}logo/white/square.png`;
1
+ const prefix = "https://apps.kwizcom.com/products/common/images/";
2
+
3
+ export const LOGO_ANIM_SMALL = `${prefix}logo/anim-small.gif`;
4
+ export const LOGO_ANIM = `${prefix}logo/anim.gif`;
5
+
6
+ export const LOGO_BLACK_HORIZONTAL = `${prefix}logo/black/horizontal.png`;
7
+ export const LOGO_BLACK_SQUARE = `${prefix}logo/black/square.png`;
8
+ export const LOGO_BLACK_VERTICAL = `${prefix}logo/black/vertical.png`;
9
+
10
+ export const LOGO_BLUE_HORIZONTAL = `${prefix}logo/blue/horizontal.png`;
11
+ export const LOGO_BLUE_SQUARE = `${prefix}logo/blue/square.png`;
12
+ export const LOGO_BLUE_VERTICAL = `${prefix}logo/blue/vertical.png`;
13
+
14
+ export const LOGO_CYAN_HORIZONTAL = `${prefix}logo/cyan/horizontal.png`;
15
+ export const LOGO_CYAN_VERTICAL = `${prefix}logo/cyan/vertical.png`;
16
+
17
+ export const LOGO_GRAD_HORIZONTAL = `${prefix}logo/grad/horizontal.png`;
18
+ export const LOGO_GRAD_SQUARE = `${prefix}logo/grad/square.png`;
19
+ export const LOGO_GRAD_VERTICAL = `${prefix}logo/grad/vertical.png`;
20
+
21
+ export const LOGO_WHITE_HORIZONTAL = `${prefix}logo/white/horizontal.png`;
22
+ export const LOGO_WHITE_SQUARE = `${prefix}logo/white/square.png`;
23
23
  export const LOGO_WHITE_VERTICAL = `${prefix}logo/white/vertical.png`;
@@ -1,39 +1,39 @@
1
- import { eval2 } from "./eval";
2
- import { isFunction, isNullOrEmptyString } from "./typecheckers";
3
-
4
- export function jsonParse<T = any>(str: string) {
5
- if (isNullOrEmptyString(str)) {
6
- return null;
7
- }
8
-
9
- if (JSON) {
10
- if (isFunction(JSON.parse)) {
11
- try {
12
- var v = JSON.parse(str);
13
- return v as T;
14
- } catch (ex) {
15
- return null;
16
- }
17
- }
18
- }
19
- try {
20
- var v2 = eval2("(" + str + ")");
21
-
22
- return v2 as T;
23
- } catch (ex1) {
24
- return null;
25
- }
26
- }
27
-
28
- /** stringify JSON object, but also sorts properties alphabetically */
29
- export function jsonStringify(obj: any, space?: number): string {
30
- if (isNullOrEmptyString(obj)) return "";
31
- var allKeys = [];
32
- JSON.stringify(obj, (key, value) => {
33
- if (!allKeys.includes(key))
34
- allKeys.push(key);
35
- return value;
36
- });
37
- allKeys.sort();
38
- return JSON.stringify(obj, allKeys, space);
1
+ import { eval2 } from "./eval";
2
+ import { isFunction, isNullOrEmptyString } from "./typecheckers";
3
+
4
+ export function jsonParse<T = any>(str: string) {
5
+ if (isNullOrEmptyString(str)) {
6
+ return null;
7
+ }
8
+
9
+ if (JSON) {
10
+ if (isFunction(JSON.parse)) {
11
+ try {
12
+ var v = JSON.parse(str);
13
+ return v as T;
14
+ } catch (ex) {
15
+ return null;
16
+ }
17
+ }
18
+ }
19
+ try {
20
+ var v2 = eval2("(" + str + ")");
21
+
22
+ return v2 as T;
23
+ } catch (ex1) {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ /** stringify JSON object, but also sorts properties alphabetically */
29
+ export function jsonStringify(obj: any, space?: number): string {
30
+ if (isNullOrEmptyString(obj)) return "";
31
+ var allKeys = [];
32
+ JSON.stringify(obj, (key, value) => {
33
+ if (!allKeys.includes(key))
34
+ allKeys.push(key);
35
+ return value;
36
+ });
37
+ allKeys.sort();
38
+ return JSON.stringify(obj, allKeys, space);
39
39
  }