@kwiz/common 1.0.127 → 1.0.128

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 (101) 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/types/libs/msal.types.js +26 -26
  6. package/lib/cjs/utils/auth/common.js +84 -37
  7. package/lib/cjs/utils/auth/common.js.map +1 -1
  8. package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
  9. package/lib/esm/types/libs/msal.types.js +26 -26
  10. package/lib/esm/utils/auth/common.js +84 -38
  11. package/lib/esm/utils/auth/common.js.map +1 -1
  12. package/lib/esm/utils/sharepoint.rest/user.js +11 -11
  13. package/lib/types/types/auth.d.ts +7 -0
  14. package/lib/types/utils/auth/common.d.ts +2 -0
  15. package/package.json +81 -81
  16. package/readme.md +17 -17
  17. package/src/_dependencies.ts +12 -12
  18. package/src/config.ts +17 -17
  19. package/src/helpers/Guid.ts +181 -181
  20. package/src/helpers/base64.ts +173 -173
  21. package/src/helpers/browser.test.js +13 -13
  22. package/src/helpers/browser.ts +1498 -1498
  23. package/src/helpers/browserinfo.ts +292 -292
  24. package/src/helpers/collections.base.test.js +25 -25
  25. package/src/helpers/collections.base.ts +437 -437
  26. package/src/helpers/collections.ts +107 -107
  27. package/src/helpers/color.ts +54 -54
  28. package/src/helpers/cookies.ts +59 -59
  29. package/src/helpers/date.test.js +119 -119
  30. package/src/helpers/date.ts +188 -188
  31. package/src/helpers/debug.ts +186 -186
  32. package/src/helpers/diagrams.ts +43 -43
  33. package/src/helpers/emails.ts +6 -6
  34. package/src/helpers/eval.ts +5 -5
  35. package/src/helpers/file.test.js +50 -50
  36. package/src/helpers/file.ts +63 -63
  37. package/src/helpers/flatted.ts +149 -149
  38. package/src/helpers/functions.ts +16 -16
  39. package/src/helpers/graph/calendar.types.ts +10 -10
  40. package/src/helpers/http.ts +69 -69
  41. package/src/helpers/images.ts +22 -22
  42. package/src/helpers/json.ts +44 -44
  43. package/src/helpers/md5.ts +189 -189
  44. package/src/helpers/objects.test.js +33 -33
  45. package/src/helpers/objects.ts +274 -274
  46. package/src/helpers/promises.test.js +37 -37
  47. package/src/helpers/promises.ts +165 -165
  48. package/src/helpers/random.ts +27 -27
  49. package/src/helpers/scheduler/scheduler.test.js +103 -103
  50. package/src/helpers/scheduler/scheduler.ts +131 -131
  51. package/src/helpers/sharepoint.ts +796 -796
  52. package/src/helpers/strings.test.js +122 -122
  53. package/src/helpers/strings.ts +337 -337
  54. package/src/helpers/typecheckers.test.js +34 -34
  55. package/src/helpers/typecheckers.ts +266 -266
  56. package/src/helpers/url.test.js +43 -43
  57. package/src/helpers/url.ts +207 -207
  58. package/src/helpers/urlhelper.ts +111 -111
  59. package/src/index.ts +6 -6
  60. package/src/types/auth.ts +62 -54
  61. package/src/types/common.types.ts +15 -15
  62. package/src/types/flatted.types.ts +59 -59
  63. package/src/types/globals.types.ts +6 -6
  64. package/src/types/graph/calendar.types.ts +80 -80
  65. package/src/types/knownscript.types.ts +18 -18
  66. package/src/types/libs/datajs.types.ts +28 -28
  67. package/src/types/libs/ics.types.ts +30 -30
  68. package/src/types/libs/msal.types.ts +57 -57
  69. package/src/types/locales.ts +125 -125
  70. package/src/types/localstoragecache.types.ts +8 -8
  71. package/src/types/location.types.ts +27 -27
  72. package/src/types/moment.ts +11 -11
  73. package/src/types/regex.types.ts +16 -16
  74. package/src/types/rest.types.ts +95 -95
  75. package/src/types/sharepoint.types.ts +1466 -1466
  76. package/src/types/sharepoint.utils.types.ts +306 -306
  77. package/src/utils/auth/common.ts +119 -74
  78. package/src/utils/auth/discovery.test.js +12 -12
  79. package/src/utils/auth/discovery.ts +132 -132
  80. package/src/utils/base64.ts +27 -27
  81. package/src/utils/consolelogger.ts +333 -333
  82. package/src/utils/date.ts +172 -172
  83. package/src/utils/emails.ts +24 -24
  84. package/src/utils/knownscript.ts +286 -286
  85. package/src/utils/localstoragecache.ts +446 -446
  86. package/src/utils/rest.ts +501 -501
  87. package/src/utils/script.ts +170 -170
  88. package/src/utils/sharepoint.rest/common.ts +159 -159
  89. package/src/utils/sharepoint.rest/date.ts +62 -62
  90. package/src/utils/sharepoint.rest/file.folder.ts +685 -685
  91. package/src/utils/sharepoint.rest/item.ts +547 -547
  92. package/src/utils/sharepoint.rest/list.ts +1572 -1572
  93. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
  94. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
  95. package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
  96. package/src/utils/sharepoint.rest/location.ts +141 -141
  97. package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
  98. package/src/utils/sharepoint.rest/user-search.ts +252 -252
  99. package/src/utils/sharepoint.rest/user.ts +558 -558
  100. package/src/utils/sharepoint.rest/web.ts +1384 -1384
  101. package/src/utils/sod.ts +194 -194
@@ -385,17 +385,17 @@ export async function SetGroupOwner(siteUrl, groupId, ownerId, ownerIsAGroup) {
385
385
  try {
386
386
  let soapUrl = `${GetSiteUrl(siteUrl)}_vti_bin/client.svc/ProcessQuery`;
387
387
  let siteId = await GetSiteId(siteUrl);
388
- let serviceJSONResponse = await GetJson(soapUrl, `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName=".NET Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
389
- <Actions>
390
- <SetProperty Id="1" ObjectPathId="2" Name="Owner">
391
- <Parameter ObjectPathId="3" />
392
- </SetProperty>
393
- <Method Name="Update" Id="4" ObjectPathId="2" />
394
- </Actions>
395
- <ObjectPaths>
396
- <Identity Id="2" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:g:${groupId}" />
397
- <Identity Id="3" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:g:${ownerId}" />
398
- </ObjectPaths>
388
+ let serviceJSONResponse = await GetJson(soapUrl, `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName=".NET Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
389
+ <Actions>
390
+ <SetProperty Id="1" ObjectPathId="2" Name="Owner">
391
+ <Parameter ObjectPathId="3" />
392
+ </SetProperty>
393
+ <Method Name="Update" Id="4" ObjectPathId="2" />
394
+ </Actions>
395
+ <ObjectPaths>
396
+ <Identity Id="2" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:g:${groupId}" />
397
+ <Identity Id="3" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:g:${ownerId}" />
398
+ </ObjectPaths>
399
399
  </Request>`, {
400
400
  headers: {
401
401
  Accept: jsonTypes.standard,
@@ -46,3 +46,10 @@ export declare enum SPFxAuthTokenType {
46
46
  Graph = 2,
47
47
  MySite = 3
48
48
  }
49
+ export interface SPFxAuthToken {
50
+ access_token: string;
51
+ expires_on: string;
52
+ resource: string;
53
+ scope: string;
54
+ token_type: string;
55
+ }
@@ -4,3 +4,5 @@ export declare function GetDefaultScope(appId: string): string;
4
4
  export declare function GetMSALSiteScope(hostName: string): string;
5
5
  /** Acquire an authorization token for a Outlook, Graph, or SharePoint the same way SPFx clients do */
6
6
  export declare function GetSPFxClientAuthToken(siteUrl: string, spfxTokenType?: SPFxAuthTokenType): Promise<string>;
7
+ /** Acquire an authorization token for a Outlook, Graph, or SharePoint the same way SPFx clients do */
8
+ export declare function GetSPFxClientAuthTokenSync(siteUrl: string, spfxTokenType?: SPFxAuthTokenType): string;
package/package.json CHANGED
@@ -1,81 +1,81 @@
1
- {
2
- "name": "@kwiz/common",
3
- "version": "1.0.127",
4
- "description": "KWIZ common utilities and helpers for M365 platform",
5
- "main": "lib/cjs/index.js",
6
- "module": "lib/esm/index.js",
7
- "types": "lib/types/index.d.ts",
8
- "sideEffects": [
9
- "*.scss*",
10
- "lib/esm/helpers/debug.js",
11
- "lib/esm/config.js"
12
- ],
13
- "exports": {
14
- ".": {
15
- "types": "./lib/types/index.d.ts",
16
- "import": "./lib/esm/index.js",
17
- "require": "./lib/cjs/index.js"
18
- },
19
- "./package.json": "./package.json"
20
- },
21
- "scripts": {
22
- "watch": "npm-run-all --parallel watch:esm watch:cjs",
23
- "watch:esm": "tsc -p tsconfig.esm.json -watch",
24
- "watch:cjs": "tsc -p tsconfig.cjs.json -watch",
25
- "build": "npm run reindex-project && npm run test && npm run build:esm && npm run build:cjs",
26
- "build:esm": "tsc -p tsconfig.esm.json",
27
- "build:cjs": "tsc -p tsconfig.cjs.json",
28
- "build-explain": "tsc --explainFiles",
29
- "check-dependencies": "madge --circular ./src",
30
- "create-link": "npm link",
31
- "test": "node --import tsx --test src",
32
- "npm-v-patch": "npm version patch && git push origin main:main && git push --tags",
33
- "npm-v-major": "npm version major && git push origin main:main && git push --tags",
34
- "___do_not_use_npm-publish": "npm publish --access public",
35
- "reset-repo": "git fetch origin && git reset --hard origin/main",
36
- "reindex-project": "cti create ./src -i _dependencies -w -b -n -o exports-index.ts && node fix-folder-imports.js"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/KWizCom/common.git"
41
- },
42
- "keywords": [
43
- "KWIZ",
44
- "SharePoint",
45
- "SPO",
46
- "Teams",
47
- "Utilities",
48
- "Helpers"
49
- ],
50
- "author": "Shai Petel",
51
- "contributors": [
52
- "Shai Petel",
53
- "Kevin Vieira"
54
- ],
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https://github.com/KWizCom/common/issues",
58
- "email": "support@kwizcom.com"
59
- },
60
- "homepage": "https://github.com/KWizCom/common#readme",
61
- "private": false,
62
- "engines": {
63
- "node": ">=16"
64
- },
65
- "packageManager": "npm@9.5.1",
66
- "devDependencies": {
67
- "@types/dom-navigation": "^1.0.4",
68
- "create-ts-index": "^1.14.0",
69
- "fs-extra": "^11.2.0",
70
- "madge": "^6.1.0",
71
- "npm-run-all": "^4.1.5",
72
- "tsx": "^4.7.1",
73
- "typescript": "^5.3.3",
74
- "xhr2": "^0.2.1"
75
- },
76
- "dependencies": {
77
- "esbuild": "^0.19.12",
78
- "get-tsconfig": "^4.7.2",
79
- "resolve-pkg-maps": "^1.0.0"
80
- }
81
- }
1
+ {
2
+ "name": "@kwiz/common",
3
+ "version": "1.0.128",
4
+ "description": "KWIZ common utilities and helpers for M365 platform",
5
+ "main": "lib/cjs/index.js",
6
+ "module": "lib/esm/index.js",
7
+ "types": "lib/types/index.d.ts",
8
+ "sideEffects": [
9
+ "*.scss*",
10
+ "lib/esm/helpers/debug.js",
11
+ "lib/esm/config.js"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./lib/types/index.d.ts",
16
+ "import": "./lib/esm/index.js",
17
+ "require": "./lib/cjs/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "scripts": {
22
+ "watch": "npm-run-all --parallel watch:esm watch:cjs",
23
+ "watch:esm": "tsc -p tsconfig.esm.json -watch",
24
+ "watch:cjs": "tsc -p tsconfig.cjs.json -watch",
25
+ "build": "npm run reindex-project && npm run test && npm run build:esm && npm run build:cjs",
26
+ "build:esm": "tsc -p tsconfig.esm.json",
27
+ "build:cjs": "tsc -p tsconfig.cjs.json",
28
+ "build-explain": "tsc --explainFiles",
29
+ "check-dependencies": "madge --circular ./src",
30
+ "create-link": "npm link",
31
+ "test": "node --import tsx --test src",
32
+ "npm-v-patch": "npm version patch && git push origin main:main && git push --tags",
33
+ "npm-v-major": "npm version major && git push origin main:main && git push --tags",
34
+ "___do_not_use_npm-publish": "npm publish --access public",
35
+ "reset-repo": "git fetch origin && git reset --hard origin/main",
36
+ "reindex-project": "cti create ./src -i _dependencies -w -b -n -o exports-index.ts && node fix-folder-imports.js"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/KWizCom/common.git"
41
+ },
42
+ "keywords": [
43
+ "KWIZ",
44
+ "SharePoint",
45
+ "SPO",
46
+ "Teams",
47
+ "Utilities",
48
+ "Helpers"
49
+ ],
50
+ "author": "Shai Petel",
51
+ "contributors": [
52
+ "Shai Petel",
53
+ "Kevin Vieira"
54
+ ],
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https://github.com/KWizCom/common/issues",
58
+ "email": "support@kwizcom.com"
59
+ },
60
+ "homepage": "https://github.com/KWizCom/common#readme",
61
+ "private": false,
62
+ "engines": {
63
+ "node": ">=16"
64
+ },
65
+ "packageManager": "npm@9.5.1",
66
+ "devDependencies": {
67
+ "@types/dom-navigation": "^1.0.4",
68
+ "create-ts-index": "^1.14.0",
69
+ "fs-extra": "^11.2.0",
70
+ "madge": "^6.1.0",
71
+ "npm-run-all": "^4.1.5",
72
+ "tsx": "^4.7.1",
73
+ "typescript": "^5.3.3",
74
+ "xhr2": "^0.2.1"
75
+ },
76
+ "dependencies": {
77
+ "esbuild": "^0.19.12",
78
+ "get-tsconfig": "^4.7.2",
79
+ "resolve-pkg-maps": "^1.0.0"
80
+ }
81
+ }
package/readme.md CHANGED
@@ -1,17 +1,17 @@
1
- # KWIZ Common Repo
2
-
3
- A collection of common helpers and utilities used across KWIZ projects
4
-
5
- To get started, configure our modules to your project by calling config:
6
-
7
- ```
8
- import { config } from "@kwiz/common";
9
- export const { logger: GetLogger } = config({
10
- BuildNumber: BuildNumber,
11
- //send true to have verbose logs and turn on debug mode
12
- IsLocalDev: IsLocalDev,
13
- ReleaseStatus: ReleaseStatus,
14
- //prefix logger with your project name
15
- ProjectName: "[cms]"
16
- });
17
- ```
1
+ # KWIZ Common Repo
2
+
3
+ A collection of common helpers and utilities used across KWIZ projects
4
+
5
+ To get started, configure our modules to your project by calling config:
6
+
7
+ ```
8
+ import { config } from "@kwiz/common";
9
+ export const { logger: GetLogger } = config({
10
+ BuildNumber: BuildNumber,
11
+ //send true to have verbose logs and turn on debug mode
12
+ IsLocalDev: IsLocalDev,
13
+ ReleaseStatus: ReleaseStatus,
14
+ //prefix logger with your project name
15
+ ProjectName: "[cms]"
16
+ });
17
+ ```
@@ -1,13 +1,13 @@
1
-
2
- export var BuildNumber = "unset";
3
- export var IsLocalDev = false;
4
- export var ReleaseStatus = "npm";
5
- export function SetDependencies(params: {
6
- BuildNumber?: string;
7
- IsLocalDev?: boolean;
8
- ReleaseStatus?: string;
9
- }) {
10
- if (typeof params.BuildNumber === "string") BuildNumber = params.BuildNumber;
11
- if (typeof params.IsLocalDev === "boolean") IsLocalDev = params.IsLocalDev;
12
- if (typeof params.ReleaseStatus === "string") ReleaseStatus = params.ReleaseStatus;
1
+
2
+ export var BuildNumber = "unset";
3
+ export var IsLocalDev = false;
4
+ export var ReleaseStatus = "npm";
5
+ export function SetDependencies(params: {
6
+ BuildNumber?: string;
7
+ IsLocalDev?: boolean;
8
+ ReleaseStatus?: string;
9
+ }) {
10
+ if (typeof params.BuildNumber === "string") BuildNumber = params.BuildNumber;
11
+ if (typeof params.IsLocalDev === "boolean") IsLocalDev = params.IsLocalDev;
12
+ if (typeof params.ReleaseStatus === "string") ReleaseStatus = params.ReleaseStatus;
13
13
  }
package/src/config.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { SetDependencies } from './_dependencies';
2
- import { ConsoleLogger } from './utils/consolelogger';
3
-
4
- export function config(params: {
5
- BuildNumber?: string;
6
- IsLocalDev?: boolean;
7
- ReleaseStatus?: string;
8
- ProjectName?: string;
9
- }) {
10
- SetDependencies(params);
11
- function GetLogger(name: string) {
12
- return ConsoleLogger.get(name, params.ProjectName);
13
- }
14
- return {
15
- logger: GetLogger
16
- }
17
- }
1
+ import { SetDependencies } from './_dependencies';
2
+ import { ConsoleLogger } from './utils/consolelogger';
3
+
4
+ export function config(params: {
5
+ BuildNumber?: string;
6
+ IsLocalDev?: boolean;
7
+ ReleaseStatus?: string;
8
+ ProjectName?: string;
9
+ }) {
10
+ SetDependencies(params);
11
+ function GetLogger(name: string) {
12
+ return ConsoleLogger.get(name, params.ProjectName);
13
+ }
14
+ return {
15
+ logger: GetLogger
16
+ }
17
+ }