@ichicraft/widgets-widget-base 1.16.6 → 1.17.0
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/README.md +4 -0
- package/lib/types/index.d.ts +6 -41
- package/lib/types/index.js +1 -8
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +6 -3
- package/lib/utils/UserHelper.d.ts +0 -9
- package/lib/utils/UserHelper.js +0 -97
package/README.md
CHANGED
|
@@ -9,6 +9,10 @@ All notable changes to this project will be documented here.
|
|
|
9
9
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
10
10
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
11
11
|
|
|
12
|
+
## 1.17.0 - 2026-07-16
|
|
13
|
+
|
|
14
|
+
- Moved `UserHelper`, `ICPersona`, `ICPersonaType`, `ICSite`, `ICTeam` and `ICTerm` to an internal package.
|
|
15
|
+
|
|
12
16
|
## 1.16.6 - 2026-06-03
|
|
13
17
|
|
|
14
18
|
- Replaced unused `design.header.activeTextColor` with `design.header.subTextColor`
|
package/lib/types/index.d.ts
CHANGED
|
@@ -216,6 +216,11 @@ export interface WidgetContext {
|
|
|
216
216
|
* Provide the id of the SP Group.
|
|
217
217
|
*/
|
|
218
218
|
isCurrentUserMemberOfSPGroup?: (groupId: number) => Promise<boolean>;
|
|
219
|
+
/**
|
|
220
|
+
* Returns whether or not the currently signed in user is part of a Bloom Group.
|
|
221
|
+
* Provide the id (GUID) of the Bloom Group.
|
|
222
|
+
*/
|
|
223
|
+
isCurrentUserMemberOfBloomGroup?: (groupId: string) => Promise<boolean>;
|
|
219
224
|
/**
|
|
220
225
|
* Generates a hash of all combined SP Groups of the current user. This can be used as
|
|
221
226
|
* cache invalidator to detect changes.
|
|
@@ -445,7 +450,7 @@ export interface WidgetVariantContext {
|
|
|
445
450
|
/**
|
|
446
451
|
* A list of administrators able to edit the admin configuration of this widget variant.
|
|
447
452
|
*/
|
|
448
|
-
administrators?:
|
|
453
|
+
administrators?: any[];
|
|
449
454
|
/**
|
|
450
455
|
* The icon defined for this widget variant.
|
|
451
456
|
*/
|
|
@@ -714,46 +719,6 @@ export interface WidgetDebugServeConfig {
|
|
|
714
719
|
*/
|
|
715
720
|
debugComponentType?: DebugComponentType;
|
|
716
721
|
}
|
|
717
|
-
export declare enum ICPersonaType {
|
|
718
|
-
User = 0,
|
|
719
|
-
SPGroup = 1,
|
|
720
|
-
Other = 2,
|
|
721
|
-
Custom = 3
|
|
722
|
-
}
|
|
723
|
-
export interface ICPersona {
|
|
724
|
-
displayName: string;
|
|
725
|
-
id: string;
|
|
726
|
-
type?: ICPersonaType;
|
|
727
|
-
objectId?: string;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Represents a SharePoint site.
|
|
731
|
-
*/
|
|
732
|
-
export interface ICSite {
|
|
733
|
-
id: string;
|
|
734
|
-
displayName?: string;
|
|
735
|
-
url?: string;
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Represents a Microsoft Teams team.
|
|
739
|
-
*/
|
|
740
|
-
export interface ICTeam {
|
|
741
|
-
id: string;
|
|
742
|
-
displayName?: string;
|
|
743
|
-
url?: string;
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* Represents a SharePoint Taxonomy Term.
|
|
747
|
-
*/
|
|
748
|
-
export interface ICTerm {
|
|
749
|
-
id: string;
|
|
750
|
-
displayName?: string;
|
|
751
|
-
path?: string;
|
|
752
|
-
termSetId: string;
|
|
753
|
-
termSetDisplayName?: string;
|
|
754
|
-
/** Was this term checked in an indeterminate state? Used e.g. when you only want to select the term itself, not its children. */
|
|
755
|
-
isIndeterminate?: boolean;
|
|
756
|
-
}
|
|
757
722
|
/**
|
|
758
723
|
* Tells the severity of the command bar item, resulting in
|
|
759
724
|
* distinguishable presentation of the item
|
package/lib/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBarItemType = exports.CustomCommandBarItemSeverity = exports.
|
|
3
|
+
exports.CommandBarItemType = exports.CustomCommandBarItemSeverity = exports.DebugComponentType = void 0;
|
|
4
4
|
var DebugComponentType;
|
|
5
5
|
(function (DebugComponentType) {
|
|
6
6
|
/**
|
|
@@ -13,13 +13,6 @@ var DebugComponentType;
|
|
|
13
13
|
*/
|
|
14
14
|
DebugComponentType["AdminConfig"] = "AdminConfig";
|
|
15
15
|
})(DebugComponentType || (exports.DebugComponentType = DebugComponentType = {}));
|
|
16
|
-
var ICPersonaType;
|
|
17
|
-
(function (ICPersonaType) {
|
|
18
|
-
ICPersonaType[ICPersonaType["User"] = 0] = "User";
|
|
19
|
-
ICPersonaType[ICPersonaType["SPGroup"] = 1] = "SPGroup";
|
|
20
|
-
ICPersonaType[ICPersonaType["Other"] = 2] = "Other";
|
|
21
|
-
ICPersonaType[ICPersonaType["Custom"] = 3] = "Custom";
|
|
22
|
-
})(ICPersonaType || (exports.ICPersonaType = ICPersonaType = {}));
|
|
23
16
|
/**
|
|
24
17
|
* Tells the severity of the command bar item, resulting in
|
|
25
18
|
* distinguishable presentation of the item
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichicraft/widgets-widget-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Part of the Widget Development Kit for building widgets for Bloom Intranet",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"
|
|
8
|
+
"build": "tsc --build --force --verbose",
|
|
9
|
+
"build:watch": "tsc --build --force --verbose --watch",
|
|
10
|
+
"clean": "rimraf lib",
|
|
11
|
+
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\"",
|
|
12
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
10
13
|
},
|
|
11
14
|
"keywords": [
|
|
12
15
|
"ichicraft",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ICPersona, WidgetContext } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* @class
|
|
4
|
-
* Helper class for User related methods.
|
|
5
|
-
*/
|
|
6
|
-
export declare class UserHelper {
|
|
7
|
-
static isCurrentUserInScope(personas: ICPersona[], context: WidgetContext): Promise<boolean>;
|
|
8
|
-
static gatherAllNormalizedUserPersonaIds(userName: string, claimBasedLoginName: string, spGroups: number[], secGroups: string[]): string[];
|
|
9
|
-
}
|
package/lib/utils/UserHelper.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UserHelper = void 0;
|
|
13
|
-
const types_1 = require("../types");
|
|
14
|
-
/**
|
|
15
|
-
* @class
|
|
16
|
-
* Helper class for User related methods.
|
|
17
|
-
*/
|
|
18
|
-
class UserHelper {
|
|
19
|
-
static isCurrentUserInScope(personas, context) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
let userIsPartOfThis = false;
|
|
22
|
-
for (let i = 0; i < personas.length; i++) {
|
|
23
|
-
const personaItem = personas[i];
|
|
24
|
-
switch (personaItem.type) {
|
|
25
|
-
case types_1.ICPersonaType.SPGroup: {
|
|
26
|
-
const userIsMemberOfSPGroup = yield context.isCurrentUserMemberOfSPGroup(Number.parseInt(personaItem.id));
|
|
27
|
-
if (userIsMemberOfSPGroup) {
|
|
28
|
-
userIsPartOfThis = true;
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case types_1.ICPersonaType.User: {
|
|
33
|
-
// handle a username exact match and partial match in case picker is in format 'i:0#.f|membership|USERNAME'
|
|
34
|
-
if (personaItem.id.toLowerCase() === context.userName.toLowerCase() ||
|
|
35
|
-
personaItem.id.toLowerCase() ===
|
|
36
|
-
context.claimBasedLoginName.toLowerCase() ||
|
|
37
|
-
(personaItem.id.indexOf('|') > -1 &&
|
|
38
|
-
personaItem.id
|
|
39
|
-
.toLowerCase()
|
|
40
|
-
.endsWith('|' + context.userName.toLowerCase()))) {
|
|
41
|
-
userIsPartOfThis = true;
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
case types_1.ICPersonaType.Other:
|
|
46
|
-
case null: {
|
|
47
|
-
let personaItemId = personaItem.id;
|
|
48
|
-
// Check if this is the infamous "Everyone except external users" group,
|
|
49
|
-
// in which case we need special treatment to check if the user is internal
|
|
50
|
-
if (personaItemId.indexOf('c:0-.f|rolemanager|spo-grid-all-users/') === 0) {
|
|
51
|
-
// There you have it: we need special treatment.
|
|
52
|
-
// If this is an external user, break, otherwise, assume user is member of group
|
|
53
|
-
if (context.claimBasedLoginName.toLocaleLowerCase().indexOf('#ext#') === -1) {
|
|
54
|
-
// This is an internal user and thus a member of the group
|
|
55
|
-
userIsPartOfThis = true;
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
// Check if the id of the picker item contains a pipe, this means we need to strip the id
|
|
60
|
-
if (personaItemId.indexOf('|') > -1) {
|
|
61
|
-
personaItemId = personaItemId.split('|').slice(-1)[0];
|
|
62
|
-
}
|
|
63
|
-
const userIsMemberOfSecGroup = yield context.isCurrentUserMemberOfSecGroup(personaItemId);
|
|
64
|
-
if (userIsMemberOfSecGroup) {
|
|
65
|
-
userIsPartOfThis = true;
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (userIsPartOfThis)
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
return userIsPartOfThis;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
static gatherAllNormalizedUserPersonaIds(userName, claimBasedLoginName, spGroups, secGroups) {
|
|
77
|
-
const personas = [];
|
|
78
|
-
// 1. The user name in two known shapes
|
|
79
|
-
personas.push(`USER|${userName.toLowerCase()}`);
|
|
80
|
-
personas.push(`USER|${claimBasedLoginName.toLowerCase()}`);
|
|
81
|
-
// 2. The SP Groups, just as they are: numeric strings
|
|
82
|
-
spGroups.forEach((spg) => {
|
|
83
|
-
personas.push(`SPGROUP|${spg}`);
|
|
84
|
-
});
|
|
85
|
-
// 3. The Security Groups, as Guids
|
|
86
|
-
secGroups.forEach((secg) => {
|
|
87
|
-
personas.push(`ADGROUP|${secg.toLowerCase()}`);
|
|
88
|
-
});
|
|
89
|
-
// 4. Optionally the all users except external users group:
|
|
90
|
-
if (claimBasedLoginName.indexOf('#ext#') === -1) {
|
|
91
|
-
// This is an internal user
|
|
92
|
-
personas.push('ADGROUP|spo-grid-all-users');
|
|
93
|
-
}
|
|
94
|
-
return personas;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.UserHelper = UserHelper;
|