@kwiz/common 1.0.132 → 1.0.134

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 (108) hide show
  1. package/lib/cjs/helpers/promises.js +4 -3
  2. package/lib/cjs/helpers/promises.js.map +1 -1
  3. package/lib/cjs/utils/sharepoint.rest/web.js +10 -2
  4. package/lib/cjs/utils/sharepoint.rest/web.js.map +1 -1
  5. package/lib/esm/helpers/promises.js +4 -3
  6. package/lib/esm/helpers/promises.js.map +1 -1
  7. package/lib/esm/utils/sharepoint.rest/web.js +7 -0
  8. package/lib/esm/utils/sharepoint.rest/web.js.map +1 -1
  9. package/lib/types/helpers/promises.d.ts +1 -1
  10. package/lib/types/utils/sharepoint.rest/web.d.ts +1 -0
  11. package/package.json +3 -2
  12. package/.github/workflows/npm-publish.yml +0 -24
  13. package/src/_dependencies.ts +0 -13
  14. package/src/config.ts +0 -19
  15. package/src/exports-index.ts +0 -4
  16. package/src/helpers/Guid.ts +0 -182
  17. package/src/helpers/base64.ts +0 -174
  18. package/src/helpers/browser.test.js +0 -13
  19. package/src/helpers/browser.ts +0 -1505
  20. package/src/helpers/browserinfo.ts +0 -293
  21. package/src/helpers/collections.base.test.js +0 -26
  22. package/src/helpers/collections.base.ts +0 -438
  23. package/src/helpers/collections.ts +0 -108
  24. package/src/helpers/color.ts +0 -55
  25. package/src/helpers/cookies.ts +0 -60
  26. package/src/helpers/date.test.js +0 -120
  27. package/src/helpers/date.ts +0 -189
  28. package/src/helpers/debug.ts +0 -187
  29. package/src/helpers/diagrams.ts +0 -44
  30. package/src/helpers/emails.ts +0 -7
  31. package/src/helpers/eval.ts +0 -5
  32. package/src/helpers/exports-index.ts +0 -30
  33. package/src/helpers/file.test.js +0 -51
  34. package/src/helpers/file.ts +0 -64
  35. package/src/helpers/flatted.ts +0 -150
  36. package/src/helpers/functions.ts +0 -17
  37. package/src/helpers/graph/calendar.types.ts +0 -11
  38. package/src/helpers/graph/exports-index.ts +0 -1
  39. package/src/helpers/http.ts +0 -70
  40. package/src/helpers/images.ts +0 -23
  41. package/src/helpers/json.ts +0 -45
  42. package/src/helpers/md5.ts +0 -190
  43. package/src/helpers/objects.test.js +0 -34
  44. package/src/helpers/objects.ts +0 -275
  45. package/src/helpers/promises.test.js +0 -38
  46. package/src/helpers/promises.ts +0 -166
  47. package/src/helpers/random.ts +0 -27
  48. package/src/helpers/scheduler/exports-index.ts +0 -1
  49. package/src/helpers/scheduler/scheduler.test.js +0 -104
  50. package/src/helpers/scheduler/scheduler.ts +0 -132
  51. package/src/helpers/sharepoint.ts +0 -797
  52. package/src/helpers/strings.test.js +0 -123
  53. package/src/helpers/strings.ts +0 -338
  54. package/src/helpers/typecheckers.test.js +0 -35
  55. package/src/helpers/typecheckers.ts +0 -267
  56. package/src/helpers/url.test.js +0 -44
  57. package/src/helpers/url.ts +0 -208
  58. package/src/helpers/urlhelper.ts +0 -112
  59. package/src/index.ts +0 -6
  60. package/src/types/auth.ts +0 -63
  61. package/src/types/common.types.ts +0 -16
  62. package/src/types/exports-index.ts +0 -15
  63. package/src/types/flatted.types.ts +0 -60
  64. package/src/types/globals.types.ts +0 -7
  65. package/src/types/graph/calendar.types.ts +0 -81
  66. package/src/types/graph/exports-index.ts +0 -1
  67. package/src/types/knownscript.types.ts +0 -19
  68. package/src/types/libs/datajs.types.ts +0 -29
  69. package/src/types/libs/exports-index.ts +0 -3
  70. package/src/types/libs/ics.types.ts +0 -31
  71. package/src/types/libs/msal.types.ts +0 -58
  72. package/src/types/locales.ts +0 -126
  73. package/src/types/localstoragecache.types.ts +0 -9
  74. package/src/types/location.types.ts +0 -28
  75. package/src/types/moment.ts +0 -12
  76. package/src/types/regex.types.ts +0 -17
  77. package/src/types/rest.types.ts +0 -96
  78. package/src/types/sharepoint.types.ts +0 -1467
  79. package/src/types/sharepoint.utils.types.ts +0 -307
  80. package/src/utils/auth/common.ts +0 -119
  81. package/src/utils/auth/discovery.test.js +0 -13
  82. package/src/utils/auth/discovery.ts +0 -132
  83. package/src/utils/auth/exports-index.ts +0 -2
  84. package/src/utils/base64.ts +0 -28
  85. package/src/utils/consolelogger.ts +0 -334
  86. package/src/utils/date.ts +0 -173
  87. package/src/utils/emails.ts +0 -25
  88. package/src/utils/exports-index.ts +0 -11
  89. package/src/utils/knownscript.ts +0 -287
  90. package/src/utils/localstoragecache.ts +0 -447
  91. package/src/utils/rest.ts +0 -502
  92. package/src/utils/script.ts +0 -171
  93. package/src/utils/sharepoint.rest/common.ts +0 -160
  94. package/src/utils/sharepoint.rest/date.ts +0 -63
  95. package/src/utils/sharepoint.rest/exports-index.ts +0 -11
  96. package/src/utils/sharepoint.rest/file.folder.ts +0 -685
  97. package/src/utils/sharepoint.rest/item.ts +0 -547
  98. package/src/utils/sharepoint.rest/list.ts +0 -1572
  99. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +0 -775
  100. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +0 -275
  101. package/src/utils/sharepoint.rest/listutils/common.ts +0 -207
  102. package/src/utils/sharepoint.rest/listutils/exports-index.ts +0 -3
  103. package/src/utils/sharepoint.rest/location.ts +0 -142
  104. package/src/utils/sharepoint.rest/navigation-links.ts +0 -87
  105. package/src/utils/sharepoint.rest/user-search.ts +0 -253
  106. package/src/utils/sharepoint.rest/user.ts +0 -559
  107. package/src/utils/sharepoint.rest/web.ts +0 -1385
  108. package/src/utils/sod.ts +0 -195
@@ -1,132 +0,0 @@
1
- import { firstOrNull, sortNumberArrayAsc } from "../collections.base";
2
- import { cloneDate } from "../date";
3
- import { padLeft } from "../strings";
4
- import { isNotEmptyArray, isNullOrUndefined } from "../typecheckers";
5
-
6
- export type hourlyInterval = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
7
- export type hours = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
8
- export type days = 0 | 1 | 2 | 3 | 4 | 5 | 6;
9
-
10
- export enum ScheduleTypes {
11
- hourly = "hourly",
12
- daily = "daily",
13
- weekly = "weekly"
14
- }
15
-
16
- export const ScheduleTypesDefinitions: { [Name: string]: { title: string, value: ScheduleTypes }; } = {
17
- weekly: {
18
- value: ScheduleTypes.weekly,
19
- title: "Run on specific days, at specific times"
20
- },
21
- daily: {
22
- value: ScheduleTypes.daily,
23
- title: "Run every day, at specific times"
24
- },
25
- hourly: {
26
- value: ScheduleTypes.hourly,
27
- title: "Run every few hours"
28
- }
29
- };
30
-
31
- export interface IScheduleHourly {
32
- ScheduleType: ScheduleTypes.hourly,
33
- /** run every x number of hours */
34
- interval: hourlyInterval;
35
- }
36
- export interface IScheduleDaily {
37
- ScheduleType: ScheduleTypes.daily,
38
- /** run every day, at these hours */
39
- hours: hours[];
40
- }
41
- export interface IScheduleWeekly {
42
- ScheduleType: ScheduleTypes.weekly,
43
- /** run in the following days */
44
- days: days[];
45
- /** run at these hours */
46
- hours: hours[];
47
- }
48
-
49
- export type TypeSchedule = IScheduleHourly | IScheduleDaily | IScheduleWeekly;
50
-
51
- export const defaultWeeklySchedule: IScheduleWeekly = {
52
- ScheduleType: ScheduleTypes.weekly,
53
- days: [1, 2, 3, 4, 5],
54
- hours: [0]
55
- };
56
- export const defaultDailySchedule: IScheduleDaily = {
57
- ScheduleType: ScheduleTypes.daily,
58
- hours: [0, 12]
59
- };
60
- export const defaultHourlySchedule: IScheduleHourly = {
61
- ScheduleType: ScheduleTypes.hourly,
62
- interval: 4
63
- };
64
-
65
- export function isValidSchedule(schedule: TypeSchedule) {
66
- if (isNullOrUndefined(schedule)) return false;
67
- if (schedule.ScheduleType === ScheduleTypes.hourly)
68
- return schedule.interval > 0 && schedule.interval <= 12;
69
- else if (schedule.ScheduleType === ScheduleTypes.daily) {
70
- return isNotEmptyArray(schedule.hours) && schedule.hours.every(h => h >= 0 && h <= 23);
71
- }
72
- else if (schedule.ScheduleType === ScheduleTypes.weekly) {
73
- return isNotEmptyArray(schedule.hours) && schedule.hours.every(h => h >= 0 && h <= 23)
74
- && isNotEmptyArray(schedule.days) && schedule.days.every(d => d >= 0 && d <= 6);
75
- }
76
- else return false;
77
- }
78
- /** returns a yyyyMMddHH for the next time this schedule needs to run after the currentDate */
79
- export function getNextUTC(currentDate: Date, schedule: TypeSchedule): string {
80
- if (!isValidSchedule(schedule)) return "9999999999";
81
-
82
- currentDate = cloneDate(currentDate);
83
-
84
- let date = currentDate.getUTCDate();
85
- let hour = currentDate.getUTCHours();
86
- let day = currentDate.getUTCDay() as days;
87
-
88
- //adjust date based on selected schedule
89
- if (schedule.ScheduleType === ScheduleTypes.hourly) {
90
- hour += schedule.interval;
91
- currentDate.setUTCHours(hour);
92
- }
93
- else if (schedule.ScheduleType === ScheduleTypes.daily) {
94
- //get current hour, see if the next run is today or tomorrow
95
- let sortedHours = schedule.hours.sort(sortNumberArrayAsc);
96
- let nextHour = firstOrNull(sortedHours.filter(h => h > hour));
97
- if (nextHour !== null) {
98
- currentDate.setUTCHours(nextHour);
99
- }
100
- else {
101
- //tomorrow at the first scheduled hour
102
- currentDate.setUTCHours(sortedHours[0]);
103
- currentDate.setUTCDate(date + 1);
104
- }
105
- }
106
- else {
107
- //implement weekly
108
- let sortedDays = schedule.days.sort(sortNumberArrayAsc);
109
- let sortedHours = schedule.hours.sort(sortNumberArrayAsc);
110
- let nextHour = firstOrNull(sortedHours.filter(h => h > hour));
111
- let nextDay = firstOrNull(sortedDays.filter(h => h > day));
112
-
113
- if (sortedDays.includes(day) && nextHour !== null)//today is allowed
114
- {
115
- currentDate.setUTCHours(nextHour);
116
- }
117
- else//move to next allowed day, at first hour allowed
118
- {
119
- let daysToAdd = nextDay === null
120
- ? 7 - day + sortedDays[0]
121
- : nextDay - day;
122
- currentDate.setUTCHours(sortedHours[0]);
123
- currentDate.setUTCDate(date + daysToAdd);
124
- }
125
- }
126
-
127
- return getUTCDateMarker(currentDate);
128
- }
129
-
130
- export function getUTCDateMarker(date: Date) {
131
- return `${date.getUTCFullYear()}${padLeft(date.getUTCMonth() + 1, 2)}${padLeft(date.getUTCDate(), 2)}${padLeft(date.getUTCHours(), 2)}`;
132
- }