@kwiz/common 1.0.107 → 1.0.109

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 (116) 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/browser.js +9 -5
  6. package/lib/cjs/helpers/browser.js.map +1 -1
  7. package/lib/cjs/types/libs/msal.types.js +26 -26
  8. package/lib/cjs/types/libs/msal.types.js.map +1 -1
  9. package/lib/cjs/types/sharepoint.utils.types.js +9 -1
  10. package/lib/cjs/types/sharepoint.utils.types.js.map +1 -1
  11. package/lib/cjs/utils/sharepoint.rest/file.folder.js +4 -4
  12. package/lib/cjs/utils/sharepoint.rest/file.folder.js.map +1 -1
  13. package/lib/cjs/utils/sharepoint.rest/list.js +60 -1
  14. package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -1
  15. package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
  16. package/lib/esm/helpers/browser.js +9 -5
  17. package/lib/esm/helpers/browser.js.map +1 -1
  18. package/lib/esm/types/libs/msal.types.js +26 -26
  19. package/lib/esm/types/libs/msal.types.js.map +1 -1
  20. package/lib/esm/types/sharepoint.utils.types.js +8 -0
  21. package/lib/esm/types/sharepoint.utils.types.js.map +1 -1
  22. package/lib/esm/utils/sharepoint.rest/file.folder.js +4 -4
  23. package/lib/esm/utils/sharepoint.rest/file.folder.js.map +1 -1
  24. package/lib/esm/utils/sharepoint.rest/list.js +57 -0
  25. package/lib/esm/utils/sharepoint.rest/list.js.map +1 -1
  26. package/lib/esm/utils/sharepoint.rest/user.js +11 -11
  27. package/lib/types/types/libs/msal.types.d.ts +8 -3
  28. package/lib/types/types/sharepoint.utils.types.d.ts +17 -0
  29. package/lib/types/utils/sharepoint.rest/list.d.ts +7 -1
  30. package/package.json +81 -81
  31. package/readme.md +17 -17
  32. package/src/_dependencies.ts +12 -12
  33. package/src/config.ts +17 -17
  34. package/src/helpers/Guid.ts +181 -181
  35. package/src/helpers/base64.ts +173 -173
  36. package/src/helpers/browser.test.js +13 -13
  37. package/src/helpers/browser.ts +1448 -1448
  38. package/src/helpers/browserinfo.ts +292 -292
  39. package/src/helpers/collections.base.test.js +25 -25
  40. package/src/helpers/collections.base.ts +437 -437
  41. package/src/helpers/collections.ts +107 -107
  42. package/src/helpers/color.ts +54 -54
  43. package/src/helpers/cookies.ts +59 -59
  44. package/src/helpers/date.test.js +119 -119
  45. package/src/helpers/date.ts +188 -188
  46. package/src/helpers/debug.ts +186 -186
  47. package/src/helpers/diagrams.ts +43 -43
  48. package/src/helpers/emails.ts +6 -6
  49. package/src/helpers/eval.ts +5 -5
  50. package/src/helpers/file.test.js +50 -50
  51. package/src/helpers/file.ts +63 -63
  52. package/src/helpers/flatted.ts +149 -149
  53. package/src/helpers/functions.ts +16 -16
  54. package/src/helpers/graph/calendar.types.ts +10 -10
  55. package/src/helpers/http.ts +69 -69
  56. package/src/helpers/images.ts +22 -22
  57. package/src/helpers/json.ts +44 -44
  58. package/src/helpers/md5.ts +189 -189
  59. package/src/helpers/objects.test.js +33 -33
  60. package/src/helpers/objects.ts +274 -274
  61. package/src/helpers/promises.test.js +37 -37
  62. package/src/helpers/promises.ts +165 -165
  63. package/src/helpers/random.ts +27 -27
  64. package/src/helpers/scheduler/scheduler.test.js +103 -103
  65. package/src/helpers/scheduler/scheduler.ts +131 -131
  66. package/src/helpers/sharepoint.ts +785 -785
  67. package/src/helpers/strings.test.js +122 -122
  68. package/src/helpers/strings.ts +337 -337
  69. package/src/helpers/typecheckers.test.js +34 -34
  70. package/src/helpers/typecheckers.ts +266 -266
  71. package/src/helpers/url.test.js +43 -43
  72. package/src/helpers/url.ts +207 -207
  73. package/src/helpers/urlhelper.ts +111 -111
  74. package/src/index.ts +6 -6
  75. package/src/types/auth.ts +54 -54
  76. package/src/types/common.types.ts +15 -15
  77. package/src/types/flatted.types.ts +59 -59
  78. package/src/types/globals.types.ts +6 -6
  79. package/src/types/graph/calendar.types.ts +80 -80
  80. package/src/types/knownscript.types.ts +18 -18
  81. package/src/types/libs/datajs.types.ts +28 -28
  82. package/src/types/libs/ics.types.ts +30 -30
  83. package/src/types/libs/msal.types.ts +57 -49
  84. package/src/types/locales.ts +125 -125
  85. package/src/types/localstoragecache.types.ts +8 -8
  86. package/src/types/location.types.ts +27 -27
  87. package/src/types/moment.ts +11 -11
  88. package/src/types/regex.types.ts +16 -16
  89. package/src/types/rest.types.ts +95 -95
  90. package/src/types/sharepoint.types.ts +1466 -1466
  91. package/src/types/sharepoint.utils.types.ts +306 -287
  92. package/src/utils/auth/common.ts +74 -74
  93. package/src/utils/auth/discovery.test.js +12 -12
  94. package/src/utils/auth/discovery.ts +132 -132
  95. package/src/utils/base64.ts +27 -27
  96. package/src/utils/consolelogger.ts +320 -320
  97. package/src/utils/date.ts +172 -172
  98. package/src/utils/emails.ts +24 -24
  99. package/src/utils/knownscript.ts +286 -286
  100. package/src/utils/localstoragecache.ts +446 -446
  101. package/src/utils/rest.ts +501 -501
  102. package/src/utils/script.ts +170 -170
  103. package/src/utils/sharepoint.rest/common.ts +154 -154
  104. package/src/utils/sharepoint.rest/date.ts +62 -62
  105. package/src/utils/sharepoint.rest/file.folder.ts +598 -598
  106. package/src/utils/sharepoint.rest/item.ts +547 -547
  107. package/src/utils/sharepoint.rest/list.ts +1548 -1482
  108. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
  109. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
  110. package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
  111. package/src/utils/sharepoint.rest/location.ts +141 -141
  112. package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
  113. package/src/utils/sharepoint.rest/user-search.ts +252 -252
  114. package/src/utils/sharepoint.rest/user.ts +491 -491
  115. package/src/utils/sharepoint.rest/web.ts +1384 -1384
  116. package/src/utils/sod.ts +194 -194
@@ -1,81 +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
- }
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
81
  }
@@ -1,19 +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;
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
19
  }
@@ -1,29 +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;
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
29
  }
@@ -1,31 +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
- }
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
31
  }
@@ -1,50 +1,58 @@
1
- import { ITenantInfo } from "../auth";
2
-
3
- export interface IMSALBaseRequest { scopes: string[]; }
4
- export interface IMSALConfig {
5
- auth: {
6
- clientId: string;
7
- authority: string;
8
- redirectUri: string;
9
- }
10
- }
11
-
12
- export const MSALSampleLoginPopupScript = `<p id="msg">please wait...</p>
13
- <script>
14
- function finish() {
15
- try {
16
- var hash = window.location.hash;
17
- if (hash[0] === "#") hash = hash.slice(1);//get rid of #
18
- var hashDictionary = {};
19
- hash.split("&").forEach(function (keyValue) {
20
- if (keyValue !== "") {
21
- var vals = keyValue.split("=");
22
- hashDictionary[vals[0]] = decodeURIComponent(vals[1]);
23
- }
24
- });
25
- if (Object.keys(hashDictionary).length < 1)
26
- window.close();//we lose the hash!
27
- else if (hashDictionary.error && hashDictionary.error_description)
28
- document.getElementById("msg").innerHTML = hashDictionary.error_description.replace(/\\+/g," ").replace(/\\n/g,"<br /><br />");
29
- else if (hashDictionary.state) {
30
- var origin = hashDictionary.state.split("|")[1];
31
- if (origin) {
32
- window.location.href = origin.split("#")[0] + window.location.hash;
33
- }
34
- }
35
- } catch (e) { }
36
- }
37
- finish();
38
- </script>`;
39
-
40
- export interface IMSAL {
41
- AutoDiscoverTenantInfo: () => Promise<ITenantInfo>;
42
- GetConfig: (clientId: string, authority: string, redirectUri: string) => Promise<IMSALConfig>;
43
- GetTokenPopup: (config: IMSALConfig, requestOptions?: { scopes?: string[]; }) => Promise<string>;
44
- }
45
-
46
- declare global {
47
- interface IKWizComGlobalsLibs {
48
- msal?: IMSAL;
49
- }
1
+ import { ITenantInfo } from "../auth";
2
+
3
+ export interface IMSALBaseRequest { scopes: string[]; }
4
+ export interface IMSALConfig {
5
+ auth: {
6
+ clientId: string;
7
+ authority: string;
8
+ redirectUri: string;
9
+ }
10
+ }
11
+ export interface IMSALRequestOptions {
12
+ scopes?: string[];
13
+ /** the custom state you would like to be passed to your login handler, otherwise it sends the current window.location.href */
14
+ state?: string;
15
+ /** turn this on if you want to allow the option to redirect if popup are blocked. */
16
+ allowRedirect?: boolean;
17
+
18
+ }
19
+
20
+ export const MSALSampleLoginPopupScript = `<p id="msg">please wait...</p>
21
+ <script>
22
+ function finish() {
23
+ try {
24
+ var hash = window.location.hash;
25
+ if (hash[0] === "#") hash = hash.slice(1);//get rid of #
26
+ var hashDictionary = {};
27
+ hash.split("&").forEach(function (keyValue) {
28
+ if (keyValue !== "") {
29
+ var vals = keyValue.split("=");
30
+ hashDictionary[vals[0]] = decodeURIComponent(vals[1]);
31
+ }
32
+ });
33
+ if (Object.keys(hashDictionary).length < 1)
34
+ window.close();//we lose the hash!
35
+ else if (hashDictionary.error && hashDictionary.error_description)
36
+ document.getElementById("msg").innerHTML = hashDictionary.error_description.replace(/\\+/g," ").replace(/\\n/g,"<br /><br />");
37
+ else if (hashDictionary.state) {
38
+ var origin = hashDictionary.state.split("|")[1];
39
+ if (origin) {
40
+ window.location.href = origin.split("#")[0] + window.location.hash;
41
+ }
42
+ }
43
+ } catch (e) { }
44
+ }
45
+ finish();
46
+ </script>`;
47
+
48
+ export interface IMSAL {
49
+ AutoDiscoverTenantInfo: () => Promise<ITenantInfo>;
50
+ GetConfig: (clientId: string, authority: string, redirectUri: string) => Promise<IMSALConfig>;
51
+ GetTokenPopup: (config: IMSALConfig, requestOptions?: IMSALRequestOptions) => Promise<string>;
52
+ }
53
+
54
+ declare global {
55
+ interface IKWizComGlobalsLibs {
56
+ msal?: IMSAL;
57
+ }
50
58
  }