@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,246 @@
|
|
|
1
|
+
/** types for KWIZ sharepoint API */
|
|
2
|
+
import { IDictionary } from "./common.types";
|
|
3
|
+
import { AttachmentFilesRESTValue, BaseTypes, FileSystemObjectTypes, IFieldInfoEX, ISPEventReceiver, ListTemplateTypes, PrincipalType, RoleType } from "./sharepoint.types";
|
|
4
|
+
|
|
5
|
+
export interface ISiteInfo { Id: string; ServerRelativeUrl: string; }
|
|
6
|
+
export interface IRootWebInfo { Id: string; ServerRelativeUrl: string; }
|
|
7
|
+
|
|
8
|
+
export interface ISPRestError {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IUserInfo {
|
|
14
|
+
Id: number;
|
|
15
|
+
LoginName: string;
|
|
16
|
+
UserPrincipalName: string;
|
|
17
|
+
Title: string;
|
|
18
|
+
IsSiteAdmin: boolean;
|
|
19
|
+
Email: string;
|
|
20
|
+
Groups?: IUserGroupInfo[];
|
|
21
|
+
PrincipalType: PrincipalType;
|
|
22
|
+
}
|
|
23
|
+
export interface IUserGroupInfo {
|
|
24
|
+
Id: number;
|
|
25
|
+
LoginName: string;
|
|
26
|
+
Title: string;
|
|
27
|
+
Description: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IGroupInfo {
|
|
31
|
+
Id: number;
|
|
32
|
+
Title: string;
|
|
33
|
+
Description: string;
|
|
34
|
+
CanCurrentUserViewMembership: boolean;
|
|
35
|
+
OnlyAllowMembersViewMembership: boolean;
|
|
36
|
+
LoginName: string;
|
|
37
|
+
Users?: IUserInfo[];
|
|
38
|
+
PrincipalType: PrincipalType.SharePointGroup;
|
|
39
|
+
IsHiddenInUI?: boolean;
|
|
40
|
+
OwnerTitle?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line no-shadow
|
|
44
|
+
export enum ListExperienceOptions {
|
|
45
|
+
Default = 0,
|
|
46
|
+
Modern = 1,
|
|
47
|
+
Classic = 2
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface iList {
|
|
51
|
+
Title: string;
|
|
52
|
+
Description: string;
|
|
53
|
+
EnableAttachments: boolean;
|
|
54
|
+
EnableModeration: boolean;
|
|
55
|
+
BaseTemplate: ListTemplateTypes;
|
|
56
|
+
BaseType: BaseTypes;
|
|
57
|
+
Id: string;
|
|
58
|
+
Hidden: boolean;
|
|
59
|
+
IsApplicationList: boolean;
|
|
60
|
+
IsPrivate: boolean;
|
|
61
|
+
IsCatalog: boolean;
|
|
62
|
+
ImageUrl: string;
|
|
63
|
+
ItemCount: number;
|
|
64
|
+
ParentWebUrl: string;
|
|
65
|
+
EntityTypeName: string;
|
|
66
|
+
DefaultViewUrl: string;
|
|
67
|
+
ParentWeb: { Id: string; Title: string; };
|
|
68
|
+
Views?: iListView[];
|
|
69
|
+
ContentTypes?: iContentType[];
|
|
70
|
+
EffectiveBasePermissions: { High: number; Low: number; },
|
|
71
|
+
RootFolder?: {
|
|
72
|
+
ServerRelativeUrl: string;
|
|
73
|
+
Name: string;
|
|
74
|
+
};
|
|
75
|
+
EventReceivers?: ISPEventReceiver[];
|
|
76
|
+
ListExperienceOptions?: ListExperienceOptions;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface iListView {
|
|
80
|
+
Title: string;
|
|
81
|
+
Id: string;
|
|
82
|
+
ServerRelativeUrl: string;
|
|
83
|
+
RowLimit: number;
|
|
84
|
+
Paged: boolean;
|
|
85
|
+
ViewQuery: string;
|
|
86
|
+
ListViewXml: string;
|
|
87
|
+
PersonalView: boolean;
|
|
88
|
+
MobileView: boolean;
|
|
89
|
+
MobileDefaultView: boolean;
|
|
90
|
+
Hidden: boolean;
|
|
91
|
+
DefaultView: boolean;
|
|
92
|
+
ReadOnlyView: boolean;
|
|
93
|
+
ViewFields?: string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface IListWorkflowAssociation {
|
|
97
|
+
AllowManual: boolean;
|
|
98
|
+
BaseId: string;//guid
|
|
99
|
+
Created: string;
|
|
100
|
+
Description: string;
|
|
101
|
+
Enabled: boolean;
|
|
102
|
+
HistoryListTitle: string;
|
|
103
|
+
Id: string;//guid
|
|
104
|
+
InstantiationUrl?: string;
|
|
105
|
+
InternalName: string;
|
|
106
|
+
IsDeclarative: boolean;
|
|
107
|
+
ListId: string;//guid
|
|
108
|
+
Modified: string;
|
|
109
|
+
Name: string;
|
|
110
|
+
RunningInstances: number;
|
|
111
|
+
TaskListTitle: string;
|
|
112
|
+
WebId: string;//guid
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface iContentType {
|
|
116
|
+
Name: string;
|
|
117
|
+
Description: string;
|
|
118
|
+
StringId: string;
|
|
119
|
+
Group: string;
|
|
120
|
+
Hidden: boolean;
|
|
121
|
+
ReadOnly: boolean;
|
|
122
|
+
NewFormUrl: string;
|
|
123
|
+
DisplayFormUrl: string;
|
|
124
|
+
EditFormUrl: string;
|
|
125
|
+
Fields?: IFieldInfoEX[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// eslint-disable-next-line no-shadow
|
|
129
|
+
export enum WebTypes {
|
|
130
|
+
Team = 0,
|
|
131
|
+
Group = 1,
|
|
132
|
+
App = 2,
|
|
133
|
+
Other = 3
|
|
134
|
+
}
|
|
135
|
+
export interface IWebBasicInfo {
|
|
136
|
+
Title: string;
|
|
137
|
+
ServerRelativeUrl: string;
|
|
138
|
+
WebId: string;
|
|
139
|
+
/**STS, APP, WIKI, MPS, APPCATALOG, DEV, PWA, PWS, SPS, GROUP or other... */
|
|
140
|
+
WebTemplate: "STS" | "APP" | "WIKI" | "MPS" | "APPCATALOG" | "DEV" | "PWA" | "PWS" | "SPS" | "GROUP" | string;
|
|
141
|
+
WebType: WebTypes;
|
|
142
|
+
Description?: string;
|
|
143
|
+
SiteLogoUrl?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface IRestRoleDefinition {
|
|
147
|
+
BasePermissions: { High: number; Low: number; };
|
|
148
|
+
Description: string;
|
|
149
|
+
Hidden: boolean;
|
|
150
|
+
Id: number;
|
|
151
|
+
Name: string;
|
|
152
|
+
Order: number;
|
|
153
|
+
RoleTypeKind: RoleType;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface IAppTile {
|
|
157
|
+
Title: string;
|
|
158
|
+
ProductId: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface IFileInfo {
|
|
162
|
+
Exists: boolean;
|
|
163
|
+
Name: string;
|
|
164
|
+
ServerRelativeUrl: string;
|
|
165
|
+
TimeCreated: Date;
|
|
166
|
+
TimeLastModified: Date;
|
|
167
|
+
Title: string;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface ITimeZone {
|
|
171
|
+
Description: string;
|
|
172
|
+
Id: number;
|
|
173
|
+
Information: { Bias: number; DaylightBias: number; StandardBias: number; };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line no-shadow
|
|
177
|
+
export enum GeListItemsFoldersBehaviour { AllItemsNoFolders, ItemsAndFoldersFlat, ItemsInsideFolders }
|
|
178
|
+
|
|
179
|
+
export interface IRestItem {
|
|
180
|
+
Id: number;
|
|
181
|
+
FileRef: string;
|
|
182
|
+
FileDirRef: string;
|
|
183
|
+
FileLeafRef: string;
|
|
184
|
+
/** file type (lower case) or 'folder' or 'listitem' */
|
|
185
|
+
FileType: 'folder' | 'listitem' | string;
|
|
186
|
+
/** Folder=1, list item=0 */
|
|
187
|
+
FileSystemObjectType: FileSystemObjectTypes;
|
|
188
|
+
[InternalName: string]: any;
|
|
189
|
+
FieldValuesAsText?: IDictionary<string>;
|
|
190
|
+
FieldValuesForEdit?: IDictionary<any>;
|
|
191
|
+
AttachmentFiles?: AttachmentFilesRESTValue;
|
|
192
|
+
|
|
193
|
+
/** File name (no extension) for files or folders, Title for list items or 'Item #ID' for items with an empty title */
|
|
194
|
+
__DisplayTitle: string;
|
|
195
|
+
/** For a folder, this will have items inside the folder */
|
|
196
|
+
__Items?: IRestItem[];
|
|
197
|
+
/** For an item inside a folder, this will be the parent folder */
|
|
198
|
+
__ParentFolder?: IRestItem;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface IRestItemExpandedLookupValue {
|
|
202
|
+
Id: number;
|
|
203
|
+
Title: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export type UserEntityValueType = {
|
|
207
|
+
principalType: PrincipalType.User | PrincipalType.SecurityGroup | PrincipalType.SharePointGroup;
|
|
208
|
+
spId: number;
|
|
209
|
+
loginOrPrincipalName?: string;
|
|
210
|
+
/** not saved in settings. pre-loaded when loading settings. */
|
|
211
|
+
title?: string;
|
|
212
|
+
/** not saved in settings. pre-loaded when loading settings. */
|
|
213
|
+
email?: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export interface IWebRegionalSettings {
|
|
217
|
+
AdjustHijriDays: number;
|
|
218
|
+
AlternateCalendarType: number;
|
|
219
|
+
AM: string;
|
|
220
|
+
CalendarType: number;
|
|
221
|
+
Collation: number;
|
|
222
|
+
CollationLCID: number;
|
|
223
|
+
DateFormat: number;
|
|
224
|
+
DateSeparator: string;
|
|
225
|
+
DecimalSeparator: string;
|
|
226
|
+
DigitGrouping: string;
|
|
227
|
+
FirstDayOfWeek: number;
|
|
228
|
+
FirstWeekOfYear: number;
|
|
229
|
+
IsEastAsia: boolean;
|
|
230
|
+
IsRightToLeft: boolean;
|
|
231
|
+
IsUIRightToLeft: boolean;
|
|
232
|
+
ListSeparator: string;
|
|
233
|
+
LocaleId: number;
|
|
234
|
+
NegativeSign: string;
|
|
235
|
+
NegNumberMode: number;
|
|
236
|
+
PM: string;
|
|
237
|
+
PositiveSign: string;
|
|
238
|
+
ShowWeeks: boolean;
|
|
239
|
+
ThousandSeparator: string;
|
|
240
|
+
Time24: boolean;
|
|
241
|
+
TimeMarkerPosition: number;
|
|
242
|
+
TimeSeparator: string;
|
|
243
|
+
WorkDayEndHour: number;
|
|
244
|
+
WorkDays: number;
|
|
245
|
+
WorkDayStartHour: number;
|
|
246
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { blobToBase64, isNullOrEmptyString } from "./_dependencies";
|
|
2
|
+
import { GetJson } from "./rest";
|
|
3
|
+
import { GetFile } from "./sharepoint.rest/file.folder";
|
|
4
|
+
|
|
5
|
+
/** if the file is in SharePoint, provide a siteRelativeUrl so that we can get the file value via REST api to avoid CORS error when accessing a file on the site from within the app web */
|
|
6
|
+
export async function imageToBase64(imageSrc: string, siteRelativeUrl?: string): Promise<string> {
|
|
7
|
+
try {
|
|
8
|
+
let fileBlob: Blob = null;
|
|
9
|
+
if (!isNullOrEmptyString(siteRelativeUrl) && imageSrc.toLowerCase().indexOf(siteRelativeUrl.toLowerCase()) >= 0) {
|
|
10
|
+
let spFile = await GetFile<Blob>(siteRelativeUrl, imageSrc, true, "blob");
|
|
11
|
+
if (spFile && spFile.Exists)
|
|
12
|
+
fileBlob = spFile.Content;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//try simple rest if the first option failed
|
|
16
|
+
if (fileBlob === null) {
|
|
17
|
+
fileBlob = await GetJson<Blob>(imageSrc, null, { responseType: "blob", allowCache: true });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (fileBlob) {
|
|
21
|
+
let base64 = await blobToBase64(fileBlob);
|
|
22
|
+
return base64;
|
|
23
|
+
}
|
|
24
|
+
} catch (e) {
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { BuildNumber, IDictionary, ReleaseStatus, consoleLoggerFilter, getGlobal, getSecondsElapsed, isDebug, isFunction, isNullOrEmptyString, isNumber, isNumeric, isString, padLeft, padRight } from "./_dependencies";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LOGGER_NAME = "DEFAULT";
|
|
4
|
+
const LoggerPrefix = "[kw]";
|
|
5
|
+
|
|
6
|
+
interface ILoggerGlobal {
|
|
7
|
+
loggers: IDictionary<ConsoleLogger>;
|
|
8
|
+
loggedBuild: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line no-shadow
|
|
12
|
+
export enum LoggerLevel {
|
|
13
|
+
VERBOSE = 0,
|
|
14
|
+
DEBUG = 1,
|
|
15
|
+
INFO = 2,
|
|
16
|
+
LOG = 3,
|
|
17
|
+
/** shows when debug=off */
|
|
18
|
+
WARN = 4,
|
|
19
|
+
/** shows when debug=off */
|
|
20
|
+
TRACE = 5,
|
|
21
|
+
/** shows when debug=off */
|
|
22
|
+
ERROR = 6,
|
|
23
|
+
OFF = 10
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type LoggerContext = {
|
|
27
|
+
//allow to not set logger level, so it will be set by isDebug always. But - dev can set it for a specific logger instance if they want to override
|
|
28
|
+
filterLevel?: LoggerLevel;
|
|
29
|
+
name?: string;
|
|
30
|
+
//allow to have a different prefix
|
|
31
|
+
prefix?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export class ConsoleLogger {
|
|
35
|
+
public context: LoggerContext;
|
|
36
|
+
|
|
37
|
+
protected constructor(context: LoggerContext) {
|
|
38
|
+
this.context = context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public static get(name: string, prefix?: string) {
|
|
42
|
+
var global = ConsoleLogger._getGlobal();
|
|
43
|
+
var loggers = global.loggers;
|
|
44
|
+
|
|
45
|
+
if (!global.loggedBuild) {
|
|
46
|
+
global.loggedBuild = true;
|
|
47
|
+
console.debug(`${ConsoleLogger.commonPrefix()} KWIZ build ${ReleaseStatus}.${BuildNumber}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return loggers[name] || (loggers[name] = new ConsoleLogger({ name: name, prefix:prefix }));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private static _getGlobal() {
|
|
54
|
+
var global: ILoggerGlobal = getGlobal("loggers", {
|
|
55
|
+
loggedBuild: false,
|
|
56
|
+
loggers: {}
|
|
57
|
+
}, true);
|
|
58
|
+
return global;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private static _getDefaultLogger() {
|
|
62
|
+
return ConsoleLogger.get(DEFAULT_LOGGER_NAME);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static setLevel(newLevel: LoggerLevel) {
|
|
66
|
+
ConsoleLogger._getDefaultLogger().setLevel(newLevel);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static getLevel() {
|
|
70
|
+
return ConsoleLogger._getDefaultLogger().getLevel();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public static debug(message: string) {
|
|
74
|
+
ConsoleLogger._getDefaultLogger().debug(message);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public static info(message: string) {
|
|
78
|
+
ConsoleLogger._getDefaultLogger().info(message);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public static log(message: string) {
|
|
82
|
+
ConsoleLogger._getDefaultLogger().log(message);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public static warn(message: string) {
|
|
86
|
+
ConsoleLogger._getDefaultLogger().warn(message);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public static error(message: string) {
|
|
90
|
+
ConsoleLogger._getDefaultLogger().error(message);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public static trace(message: string) {
|
|
94
|
+
ConsoleLogger._getDefaultLogger().trace(message);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public static commonPrefix(prefix?: string) {
|
|
98
|
+
var d = new Date();
|
|
99
|
+
var timestamp = padLeft(d.getHours().toString(), 2, "0")
|
|
100
|
+
+ ":" + padLeft(d.getMinutes().toString(), 2, "0")
|
|
101
|
+
+ ":" + padLeft(d.getSeconds().toString(), 2, "0")
|
|
102
|
+
+ "." + padRight(d.getMilliseconds().toString(), 3, "0");
|
|
103
|
+
|
|
104
|
+
return `[${timestamp}] ${prefix || LoggerPrefix}`;
|
|
105
|
+
}
|
|
106
|
+
private contextPrefix() {
|
|
107
|
+
return `${ConsoleLogger.commonPrefix(this.context.prefix)} [${this.context.name}]`;
|
|
108
|
+
}
|
|
109
|
+
private format(message: string) {
|
|
110
|
+
return `${this.contextPrefix()} ${message}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public setLevel(newLevel: LoggerLevel) {
|
|
114
|
+
if (isNumeric(newLevel)) {
|
|
115
|
+
this.context.filterLevel = newLevel;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public getLevel() {
|
|
120
|
+
if (isNumeric(this.context.filterLevel))
|
|
121
|
+
return this.context.filterLevel;
|
|
122
|
+
else return isDebug() ? LoggerLevel.VERBOSE : LoggerLevel.WARN;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public enabledFor(level: LoggerLevel) {
|
|
126
|
+
if (consoleLoggerFilter().indexOf(this.context.name) >= 0) return false;
|
|
127
|
+
var filterLevel = this.getLevel();
|
|
128
|
+
return level >= filterLevel;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public debug(message: any) {
|
|
132
|
+
this.logWithLevel(LoggerLevel.DEBUG, message);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public info(message: string) {
|
|
136
|
+
this.logWithLevel(LoggerLevel.INFO, message);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public log(message: string) {
|
|
140
|
+
this.logWithLevel(LoggerLevel.LOG, message);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** output a message when debug is off */
|
|
144
|
+
public warn(message: string) {
|
|
145
|
+
this.logWithLevel(LoggerLevel.WARN, message);
|
|
146
|
+
}
|
|
147
|
+
/** output a message when debug is off */
|
|
148
|
+
public error(message: string) {
|
|
149
|
+
this.logWithLevel(LoggerLevel.ERROR, message);
|
|
150
|
+
}
|
|
151
|
+
/** output a message when debug is off */
|
|
152
|
+
public trace(message: string) {
|
|
153
|
+
this.logWithLevel(LoggerLevel.TRACE, message);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**start timer on a label, call timeEnd with the same label to print out the time that passed */
|
|
157
|
+
public time(label: string) {
|
|
158
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.time))
|
|
159
|
+
console.time(`[timer] [kw] [${this.context.name}] ${label}`);
|
|
160
|
+
}
|
|
161
|
+
/**start timer on a label, call timeEnd with the same label to print out the time that passed */
|
|
162
|
+
public timeEnd(label: string) {
|
|
163
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.timeEnd))
|
|
164
|
+
console.timeEnd(`[timer] [kw] [${this.context.name}] ${label}`);
|
|
165
|
+
}
|
|
166
|
+
/**prints an array or dictionary to the console inside a group */
|
|
167
|
+
public table(data: any, groupLabel?: string, groupCollapsed?: boolean) {
|
|
168
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.table)) {
|
|
169
|
+
this.group(() => console.table(data), groupLabel, groupCollapsed);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**prints a JSON object to the console inside a group */
|
|
173
|
+
public json(data: any, groupLabel?: string, groupCollapsed?: boolean) {
|
|
174
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.dir)) {
|
|
175
|
+
this.group(() => console.dir(data), groupLabel, groupCollapsed);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**prints an XML object to the console inside a group. If data is string that looks like an XML - will try to parse it. */
|
|
179
|
+
public xml(data: any, groupLabel?: string, groupCollapsed?: boolean) {
|
|
180
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.dirxml)) {
|
|
181
|
+
this.group(() => {
|
|
182
|
+
if (isString(data) && data.startsWith('<')) {
|
|
183
|
+
try {
|
|
184
|
+
//maybe this string is an html element?
|
|
185
|
+
data = new DOMParser().parseFromString(data, "text/html");
|
|
186
|
+
} catch (e) { }
|
|
187
|
+
}
|
|
188
|
+
console.dirxml(data);
|
|
189
|
+
}, groupLabel, groupCollapsed);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** render messages inside a group, and closes the group when done. if a label is not provided - a group will not be rendered */
|
|
193
|
+
public group(renderContent: () => void, label?: string, collapsed?: boolean) {
|
|
194
|
+
let hadGroup = false;
|
|
195
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.group) && !isNullOrEmptyString(label)) {
|
|
196
|
+
if (collapsed) {
|
|
197
|
+
console.groupCollapsed(`${this.contextPrefix()} ${label}`);
|
|
198
|
+
} else {
|
|
199
|
+
console.group(`${this.contextPrefix()} ${label}`);
|
|
200
|
+
}
|
|
201
|
+
hadGroup = true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (hadGroup) this.time(label);
|
|
205
|
+
//we must run render content even if no groups - since this might hold other code the caller needs to run
|
|
206
|
+
renderContent();
|
|
207
|
+
if (hadGroup) {
|
|
208
|
+
this.timeEnd(label);
|
|
209
|
+
console.groupEnd();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public groupSync<ReturnType>(label: string, renderContent: (log: (message: string) => void) => ReturnType, options?: {
|
|
214
|
+
expand?: boolean;
|
|
215
|
+
/** do not write to log */
|
|
216
|
+
supress?: boolean;
|
|
217
|
+
}) {
|
|
218
|
+
if (isNullOrEmptyString(label)) label = "SyncGroup";
|
|
219
|
+
let { logMessages, start, lastMessage } = this.$startGroup();
|
|
220
|
+
|
|
221
|
+
let result: ReturnType;
|
|
222
|
+
try {
|
|
223
|
+
result = renderContent(message => {
|
|
224
|
+
logMessages.push({ message: message, seconds: getSecondsElapsed(lastMessage) });
|
|
225
|
+
lastMessage = new Date();
|
|
226
|
+
});
|
|
227
|
+
} catch (e) {
|
|
228
|
+
logMessages.push({ message: `Unhandled exception: ${e}`, seconds: getSecondsElapsed(lastMessage) });
|
|
229
|
+
throw this.$finishGroup(label, e, start, logMessages, options);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return this.$finishGroup(label, result, start, logMessages, options);
|
|
233
|
+
}
|
|
234
|
+
public async groupAsync<ReturnType>(label: string, renderContent: (log: (message: string) => void) => Promise<ReturnType>, options?: {
|
|
235
|
+
expand?: boolean;
|
|
236
|
+
/** do not write to log */
|
|
237
|
+
supress?: boolean;
|
|
238
|
+
}) {
|
|
239
|
+
if (isNullOrEmptyString(label)) label = "AsyncGroup";
|
|
240
|
+
let { logMessages, start, lastMessage } = this.$startGroup();
|
|
241
|
+
|
|
242
|
+
let result: ReturnType;
|
|
243
|
+
try {
|
|
244
|
+
result = await renderContent(message => {
|
|
245
|
+
logMessages.push({ message: message, seconds: getSecondsElapsed(lastMessage) });
|
|
246
|
+
lastMessage = new Date();
|
|
247
|
+
});
|
|
248
|
+
} catch (e) {
|
|
249
|
+
logMessages.push({ message: `Unhandled exception: ${e}`, seconds: getSecondsElapsed(lastMessage) });
|
|
250
|
+
throw this.$finishGroup(label, e, start, logMessages, options);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return this.$finishGroup(label, result, start, logMessages, options);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private $startGroup() {
|
|
257
|
+
let logMessages: { seconds: number, message: string }[] = [];
|
|
258
|
+
|
|
259
|
+
let start = new Date();
|
|
260
|
+
let lastMessage = start;
|
|
261
|
+
return { logMessages, start, lastMessage };
|
|
262
|
+
}
|
|
263
|
+
private $finishGroup<ReturnType>(label: string, result: ReturnType, start: Date, logMessages: { seconds: number, message: string }[], options?: {
|
|
264
|
+
expand?: boolean;
|
|
265
|
+
/** do not write to log */
|
|
266
|
+
supress?: boolean;
|
|
267
|
+
}) {
|
|
268
|
+
if (options && options.supress) return result;
|
|
269
|
+
label = `${label} (${getSecondsElapsed(start)}s)`;
|
|
270
|
+
|
|
271
|
+
if (this.enabledFor(LoggerLevel.DEBUG) && isFunction(console.group) && !isNullOrEmptyString(label)) {
|
|
272
|
+
if (options && options.expand) {
|
|
273
|
+
console.group(`${this.contextPrefix()} ${label}`);
|
|
274
|
+
} else {
|
|
275
|
+
console.groupCollapsed(`${this.contextPrefix()} ${label}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else return result;
|
|
279
|
+
|
|
280
|
+
//drop directly, without a prefix, in the group
|
|
281
|
+
logMessages.forEach(m => console.debug(`(${m.seconds}s) ${m.message}`));
|
|
282
|
+
console.groupEnd();
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private logWithLevel(level, message) {
|
|
287
|
+
try {
|
|
288
|
+
if (this.enabledFor(level)) {
|
|
289
|
+
var isSimpleObject = isString(message) || isNumber(message);
|
|
290
|
+
var logMessage = this.format(isSimpleObject ? "%s" : "%o");
|
|
291
|
+
switch (level) {
|
|
292
|
+
case LoggerLevel.DEBUG:
|
|
293
|
+
console.debug(logMessage, message);
|
|
294
|
+
break;
|
|
295
|
+
case LoggerLevel.ERROR:
|
|
296
|
+
console.error(logMessage, message);
|
|
297
|
+
break;
|
|
298
|
+
case LoggerLevel.WARN:
|
|
299
|
+
console.warn(logMessage, message);
|
|
300
|
+
break;
|
|
301
|
+
case LoggerLevel.INFO:
|
|
302
|
+
console.info(logMessage, message);
|
|
303
|
+
break;
|
|
304
|
+
case LoggerLevel.TRACE:
|
|
305
|
+
console.trace(logMessage, message);
|
|
306
|
+
break;
|
|
307
|
+
default:
|
|
308
|
+
console.log(logMessage, message);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
} catch (ex) {
|
|
312
|
+
//empty
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isBoolean, isFunction } from "./_dependencies";
|
|
2
|
+
import { LocaleKnownScript } from "./knownscript";
|
|
3
|
+
|
|
4
|
+
/** return date format as yyyy-MM-ddTHH:mm:ssZ
|
|
5
|
+
* Optionally: remove Z, remove seconds, or set time to zero
|
|
6
|
+
*/
|
|
7
|
+
export function toIsoDateFormat(date: Date, options?: {
|
|
8
|
+
zeroTime?: boolean;
|
|
9
|
+
/** remove trailing Z (add do not add local time offset) */
|
|
10
|
+
omitZ?: boolean;
|
|
11
|
+
omitSeconds?: boolean;
|
|
12
|
+
addLocalTimezoneOffset?: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
let omitZ = options && options.omitZ === true || false;
|
|
15
|
+
let omitSeconds = options && options.omitSeconds === true || false;
|
|
16
|
+
let zeroTime = options && options.zeroTime === true || false;
|
|
17
|
+
|
|
18
|
+
let addLocalTimezoneOffset = options && isBoolean(options.addLocalTimezoneOffset)
|
|
19
|
+
? options.addLocalTimezoneOffset
|
|
20
|
+
: omitZ !== true;
|
|
21
|
+
|
|
22
|
+
let format = `yyyy-MM-ddT${zeroTime ? '00:00' : 'HH:mm'}${omitSeconds ? '' : zeroTime ? ':00' : ':ss'}${omitZ ? '' : 'Z'}`;
|
|
23
|
+
|
|
24
|
+
if (!isFunction(date.format)) {
|
|
25
|
+
LocaleKnownScript.loadSync();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let oDate = new Date(date.getTime());
|
|
29
|
+
if (addLocalTimezoneOffset) {
|
|
30
|
+
//If we do not omit Z, the caller wants to get the object's UTC time.
|
|
31
|
+
//Date format will get the current local time - so we need to compensate.
|
|
32
|
+
oDate = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
|
|
33
|
+
}
|
|
34
|
+
let o = oDate.format(format);
|
|
35
|
+
return o;
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isValidEmail } from "./_dependencies";
|
|
2
|
+
import { GetJsonSync, longLocalCache } from "./rest";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/** returns true if a valid email that is from a known free email provider */
|
|
6
|
+
export function isFreeEmail(email: string) {
|
|
7
|
+
if (isValidEmail(email)) {
|
|
8
|
+
var freeEmailListData = GetJsonSync<string>("https://apps.kwizcom.com/products/common/scripts/free-email-list.txt", null, {
|
|
9
|
+
...longLocalCache,
|
|
10
|
+
headers: {
|
|
11
|
+
"content-type": "text/plain",
|
|
12
|
+
"Accept": "*/*"
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var freeEmailList = freeEmailListData.success ? freeEmailListData.result.replace(/\r/g, '').split('\n') : [
|
|
16
|
+
"gmail.com",
|
|
17
|
+
"yaho.com",
|
|
18
|
+
"live.com"
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
if (freeEmailList.includes(email.split('@')[1].toLowerCase()))
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as _script } from "./script";
|
|
2
|
+
import { default as _sod } from "./sod";
|
|
3
|
+
export * from './base64';
|
|
4
|
+
export * from "./consolelogger";
|
|
5
|
+
export * from './date';
|
|
6
|
+
export * from './emails';
|
|
7
|
+
export * from './knownscript';
|
|
8
|
+
export * from './localstoragecache';
|
|
9
|
+
export * from './rest';
|
|
10
|
+
export * from './sharepoint.rest';
|
|
11
|
+
export * from './sod';
|
|
12
|
+
export const script = _script;
|
|
13
|
+
export const Sod = _sod;
|