@staffbase/widget-sdk 3.3.1 → 3.4.0-beta.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.
@@ -0,0 +1,27 @@
1
+ # Interface: SBUserAvatar
2
+
3
+ User avatar definition
4
+
5
+ ## Properties
6
+
7
+ ### icon
8
+
9
+ • **icon**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
10
+
11
+ ___
12
+
13
+ ### original
14
+
15
+ • **original**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
16
+
17
+ ___
18
+
19
+ ### publicID
20
+
21
+ • **publicID**: *string*
22
+
23
+ ___
24
+
25
+ ### thumb
26
+
27
+ • **thumb**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
@@ -0,0 +1,51 @@
1
+ # Interface: SBUserProfile
2
+
3
+ User profile data
4
+
5
+ ## Properties
6
+
7
+ ### avatar
8
+
9
+ • `Optional` **avatar**: [*SBUserAvatar*](../wiki/Interface:%20SBUserAvatar)
10
+
11
+ ___
12
+
13
+ ### department
14
+
15
+ • `Optional` **department**: *string*
16
+
17
+ ___
18
+
19
+ ### firstName
20
+
21
+ • **firstName**: *string*
22
+
23
+ ___
24
+
25
+ ### lastName
26
+
27
+ • **lastName**: *string*
28
+
29
+ ___
30
+
31
+ ### location
32
+
33
+ • `Optional` **location**: *string*
34
+
35
+ ___
36
+
37
+ ### phoneNumber
38
+
39
+ • `Optional` **phoneNumber**: *string*
40
+
41
+ ___
42
+
43
+ ### position
44
+
45
+ • `Optional` **position**: *string*
46
+
47
+ ___
48
+
49
+ ### publicEmailAddress
50
+
51
+ • `Optional` **publicEmailAddress**: *string*
@@ -0,0 +1,27 @@
1
+ # Interface: UserListItem
2
+
3
+ Single user item
4
+
5
+ ## Properties
6
+
7
+ ### entityType
8
+
9
+ • `Optional` **entityType**: *string*
10
+
11
+ ___
12
+
13
+ ### firstName
14
+
15
+ • `Optional` **firstName**: *string*
16
+
17
+ ___
18
+
19
+ ### id
20
+
21
+ • `Optional` **id**: *string*
22
+
23
+ ___
24
+
25
+ ### lastName
26
+
27
+ • `Optional` **lastName**: *string*
@@ -0,0 +1,27 @@
1
+ # Interface: UserListRequestQuery
2
+
3
+ User list request parameters
4
+
5
+ ## Properties
6
+
7
+ ### filter
8
+
9
+ • `Optional` **filter**: *string*
10
+
11
+ ___
12
+
13
+ ### limit
14
+
15
+ • `Optional` **limit**: *number*
16
+
17
+ ___
18
+
19
+ ### offset
20
+
21
+ • `Optional` **offset**: *number*
22
+
23
+ ___
24
+
25
+ ### sort
26
+
27
+ • `Optional` **sort**: [*UserListSorting*](../wiki/Home#userlistsorting)
@@ -0,0 +1,27 @@
1
+ # Interface: UserListResponse
2
+
3
+ Responded user list
4
+
5
+ ## Properties
6
+
7
+ ### data
8
+
9
+ • **data**: [*UserListItem*](../wiki/Interface:%20UserListItem)[]
10
+
11
+ ___
12
+
13
+ ### limit
14
+
15
+ • **limit**: *number*
16
+
17
+ ___
18
+
19
+ ### offset
20
+
21
+ • **offset**: *number*
22
+
23
+ ___
24
+
25
+ ### total
26
+
27
+ • **total**: *number*
@@ -0,0 +1,75 @@
1
+ # Interface: WidgetApi
2
+
3
+ Widget API class.
4
+
5
+ A class providing access to additional information about the Staffbase ecosystem for widgets.
6
+
7
+ ## Methods
8
+
9
+ ### getLegacyAppTheme
10
+
11
+ ▸ **getLegacyAppTheme**(): [*ColorTheme*](../wiki/Interface:%20ColorTheme)
12
+
13
+ Call to retrieve the color theme of the app. Since this theme definitions
14
+ are currently redesigned, this method is called legacy.
15
+
16
+ **Returns:** [*ColorTheme*](../wiki/Interface:%20ColorTheme)
17
+
18
+ An object containing the color theme data is returned.
19
+
20
+ ___
21
+
22
+ ### getUserInformation
23
+
24
+ ▸ **getUserInformation**(`userId?`: *string*): *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
25
+
26
+ Call to retrieve the user profile of the current or a specific user.
27
+
28
+ #### Parameters:
29
+
30
+ | Name | Type | Description |
31
+ | :------ | :------ | :------ |
32
+ | `userId?` | *string* | User ID to lookup for; leave blank to retrieve current user |
33
+
34
+ **Returns:** *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
35
+
36
+ A promise containing the SBUserProfile is returned. In case of an error,
37
+ the promise is rejected.
38
+
39
+ ___
40
+
41
+ ### getUserInformationByExternalId
42
+
43
+ ▸ **getUserInformationByExternalId**(`externalId`: *string*): *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
44
+
45
+ Call to retrieve a user profile by its external ID.
46
+
47
+ #### Parameters:
48
+
49
+ | Name | Type | Description |
50
+ | :------ | :------ | :------ |
51
+ | `externalId` | *string* | An external ID of the user that shall be returned |
52
+
53
+ **Returns:** *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
54
+
55
+ A promise containing the SBUserProfile is returned. In case of an error,
56
+ the promise is rejected.
57
+
58
+ ___
59
+
60
+ ### getUserList
61
+
62
+ ▸ **getUserList**(`query`: [*UserListRequestQuery*](../wiki/Interface:%20UserListRequestQuery)): *Promise*<[*UserListResponse*](../wiki/Interface:%20UserListResponse)\>
63
+
64
+ Call to retrieve a list of users determined by the query object.
65
+
66
+ #### Parameters:
67
+
68
+ | Name | Type | Description |
69
+ | :------ | :------ | :------ |
70
+ | `query` | [*UserListRequestQuery*](../wiki/Interface:%20UserListRequestQuery) | Adjust limit, offset, filter, and sorting for the request |
71
+
72
+ **Returns:** *Promise*<[*UserListResponse*](../wiki/Interface:%20UserListResponse)\>
73
+
74
+ A promise containing the UserListResponse is returned. In case of an error,
75
+ the promise is rejected.
@@ -0,0 +1,20 @@
1
+ ## [@staffbase/widget-sdk](../wiki/Home)
2
+
3
+
4
+ ### Interfaces
5
+
6
+ - [BaseBlock](../wiki/Interface:%20BaseBlock)
7
+ - [BlockAttributes](../wiki/Interface:%20BlockAttributes)
8
+ - [BlockDefinition](../wiki/Interface:%20BlockDefinition)
9
+ - [BlockElement](../wiki/Interface:%20BlockElement)
10
+ - [ColorTheme](../wiki/Interface:%20ColorTheme)
11
+ - [ExternalBlockDefinition](../wiki/Interface:%20ExternalBlockDefinition)
12
+ - [SBColors](../wiki/Interface:%20SBColors)
13
+ - [SBFileType](../wiki/Interface:%20SBFileType)
14
+ - [SBImageEntity](../wiki/Interface:%20SBImageEntity)
15
+ - [SBUserAvatar](../wiki/Interface:%20SBUserAvatar)
16
+ - [SBUserProfile](../wiki/Interface:%20SBUserProfile)
17
+ - [UserListItem](../wiki/Interface:%20UserListItem)
18
+ - [UserListRequestQuery](../wiki/Interface:%20UserListRequestQuery)
19
+ - [UserListResponse](../wiki/Interface:%20UserListResponse)
20
+ - [WidgetApi](../wiki/Interface:%20WidgetApi)
package/lib/base-block.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -11,6 +11,13 @@
11
11
  * limitations under the License.
12
12
  */
13
13
 
14
+ type Value = string | number | boolean | unknown[] | Record<string, unknown> | null | undefined;
15
+
16
+ /**
17
+ * Generic map of parsed attributes.
18
+ */
19
+ type ValueMap = Record<string, Value>;
20
+
14
21
  /**
15
22
  * Base class for custom widgets.
16
23
  *
@@ -79,7 +86,7 @@ export interface BaseBlock extends HTMLElement {
79
86
  * NOTE: The default implementation turns every value in a string, except arrays and object, which
80
87
  * are converted to base64 encoded data uris in the format `data:text/plain;base64,...`
81
88
  */
82
- parseConfig<T extends Record<string, any>>(attributes: T): Record<string, string>;
89
+ parseConfig<T extends ValueMap>(attributes: T): Record<string, string>;
83
90
 
84
91
  /**
85
92
  * Called when the config dialog is opened. The dialog uses the parsed attributes, to fill
@@ -95,7 +102,7 @@ export interface BaseBlock extends HTMLElement {
95
102
  * NOTE: The default implementation converts every string to string, boolean or number and decodes
96
103
  * and parses the data uris to the arrays and objects. Dates are remaining a string!
97
104
  */
98
- parseAttributes<T extends Record<string, any>>(): T;
105
+ parseAttributes(): ValueMap;
99
106
 
100
107
  /**
101
108
  * The content language as defined in the hosting system. Should be used to provide
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -17,39 +17,73 @@ import {UiSchema} from '@rjsf/core';
17
17
 
18
18
  export interface BlockDefinition<Factory = BlockFactory> {
19
19
  /**
20
- * tag of the widget, must be compatible with webcomponent naming conventions
20
+ * The tag name of the widget. It must be compatible with
21
+ * webcomponent naming conventions.
22
+ *
23
+ * @see https://www.webcomponents.org/community/articles/how-should-i-name-my-element
21
24
  */
22
25
  name: string;
23
26
 
24
27
  /**
25
- * the implementation of the webcomponent
28
+ * The implementation of the web component.
26
29
  */
27
30
  factory: Factory;
28
31
 
29
32
  /**
30
- * can be used for extending from a built-in element
33
+ * Can be used for extending from a built-in element.
31
34
  */
32
35
  options?: ElementDefinitionOptions;
33
36
 
34
37
  /**
35
- * DOM-attributes of the element, must be kebab-case
38
+ * DOM attributes of the element, must be in kebab-case.
36
39
  */
37
40
  attributes: string[];
38
41
 
39
42
  /**
40
- * set to "inline" if you want the element to behave like a span element rather than a div element
41
- * if not specified, it defaults to "block"
43
+ * Set to `inline` if you want the element to behave like a span element
44
+ * rather than a div element if not specified, it defaults to `block`.
42
45
  */
43
46
  blockLevel?: "block" | "inline";
44
47
 
45
48
  /**
46
- * schema used for creating the configuration form
49
+ * Schema used for defining the configuration form.
50
+ *
51
+ * @example
52
+ * ```json
53
+ * {
54
+ * "type": "object",
55
+ * "required": [
56
+ * "firstName",
57
+ * "lastName"
58
+ * ],
59
+ * "properties": {
60
+ * "firstName": {
61
+ * "type": "string",
62
+ * "title": "First name"
63
+ * },
64
+ * "lastName": {
65
+ * "type": "string",
66
+ * "title": "Last name"
67
+ * }
68
+ * }
69
+ * }
70
+ * ```
47
71
  * @see https://react-jsonschema-form.readthedocs.io/en/latest/
48
72
  */
49
73
  configurationSchema: JSONSchema7;
50
74
 
51
75
  /**
52
- * schema to add more customization to the form's look and feel
76
+ *
77
+ * Schema to add more customization to the look and feel of the configuration form.
78
+ *
79
+ * ```json
80
+ * {
81
+ * "firstName": {
82
+ * "ui:help": "Your first name."
83
+ * }
84
+ * }
85
+ * ```
86
+ *
53
87
  * @see https://react-jsonschema-form.readthedocs.io/en/latest/api-reference/uiSchema/
54
88
  */
55
89
  uiSchema?: UiSchema;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -18,12 +18,12 @@ export interface BlockElement {
18
18
  // readonly observedAttributes: string[];
19
19
 
20
20
  /**
21
- * Invoked when the custom element is first connected to the document's DOM.
21
+ * Invoked when the custom element is first connected to the DOM.
22
22
  */
23
23
  connectedCallback: () => void;
24
24
 
25
25
  /**
26
- * Invoked when the custom element is disconnected from the document's DOM.
26
+ * Invoked when the custom element is disconnected from the DOM.
27
27
  */
28
28
  disconnectedCallback: () => void;
29
29
 
@@ -33,13 +33,13 @@ export interface BlockElement {
33
33
  adoptedCallback: () => void;
34
34
 
35
35
  /**
36
- * Invoked when one of the custom element's attributes is added, removed, or changed.
36
+ * Invoked when one of the attributes of the custom element is added, removed, or changed.
37
37
  *
38
38
  * Note that you have to statically register the observed values with the 'observedAttributes' static getter.
39
39
  *
40
40
  * @param attrName The changed attributes name
41
- * @param oldValue
42
- * @param newValue
41
+ * @param oldValue The old value
42
+ * @param newValue The new value
43
43
  */
44
44
  attributeChangedCallback: (
45
45
  attrName: string,
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
package/lib/global.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -96,7 +96,8 @@ export interface SBColors {
96
96
  }
97
97
 
98
98
  /**
99
- * Color theme entity definition
99
+ * The color theme allows the widget to mimic the look
100
+ * and feel of the Staffbase ecosystem it was added to.
100
101
  */
101
102
  export interface ColorTheme {
102
103
  bgColor: string;
@@ -146,7 +147,8 @@ export interface SBUserProfile {
146
147
  }
147
148
 
148
149
  /**
149
- * sorting order
150
+ * The sorting order of the user list.
151
+ *
150
152
  * @param lastname sort response by lastName_ASC_firstName_ASC (default)
151
153
  * @param created sort by date of creation descending
152
154
  * @param updated sort by date of last update descending
@@ -182,3 +184,17 @@ export interface UserListResponse {
182
184
  limit: number;
183
185
  total: number;
184
186
  }
187
+
188
+
189
+ export type IntegrationType = "ms365"
190
+
191
+ /**
192
+ * Integration Token including the expiration time
193
+ */
194
+ export interface IntegrationToken {
195
+ // the token to access the api of the integration
196
+ accessToken: string;
197
+
198
+ // date when the access token expires
199
+ accessTokenExpiresAt?: Date;
200
+ }
package/lib/widget-api.ts CHANGED
@@ -11,25 +11,25 @@
11
11
  * limitations under the License.
12
12
  */
13
13
 
14
- import { ColorTheme, SBUserProfile, UserListRequestQuery, UserListResponse } from './widget-api-types';
14
+ import { ColorTheme, IntegrationToken, IntegrationType, SBUserProfile, UserListRequestQuery, UserListResponse } from './widget-api-types';
15
15
 
16
16
 
17
17
  /**
18
- * WidgetApi class.
18
+ * Widget API class.
19
19
  *
20
- * A class providing access to additional information for widgets
20
+ * A class providing access to additional information about the Staffbase ecosystem for widgets.
21
21
  */
22
22
  export interface WidgetApi {
23
23
  /**
24
- * Call to retrieve the color theme of the app. Since this themes definitions
24
+ * Call to retrieve the color theme of the app. Since this theme definitions
25
25
  * are currently redesigned, this method is called legacy.
26
26
  *
27
- * @returns A promise containing the SBUserProfile or an error is returned
27
+ * @returns An object containing the color theme data is returned.
28
28
  */
29
29
  getLegacyAppTheme(): ColorTheme;
30
30
 
31
31
  /**
32
- * Call to retrieve the user profile of the current or a specific user
32
+ * Call to retrieve the user profile of the current or a specific user.
33
33
  *
34
34
  * @param userId User ID to lookup for; leave blank to retrieve current user
35
35
  * @returns A promise containing the SBUserProfile is returned. In case of an error,
@@ -38,7 +38,7 @@ export interface WidgetApi {
38
38
  getUserInformation(userId?: string): Promise<SBUserProfile>;
39
39
 
40
40
  /**
41
- * Call to retrieve the user profile by its external ID
41
+ * Call to retrieve a user profile by its external ID.
42
42
  *
43
43
  * @param externalId An external ID of the user that shall be returned
44
44
  * @returns A promise containing the SBUserProfile is returned. In case of an error,
@@ -47,7 +47,7 @@ export interface WidgetApi {
47
47
  getUserInformationByExternalId(externalId: string): Promise<SBUserProfile>;
48
48
 
49
49
  /**
50
- * Call to retrieve a list of users determined by the query object
50
+ * Call to retrieve a list of users determined by the query object.
51
51
  *
52
52
  * @param query Adjust limit, offset, filter, and sorting for the request
53
53
  * @returns A promise containing the UserListResponse is returned. In case of an error,
@@ -55,4 +55,14 @@ export interface WidgetApi {
55
55
  */
56
56
  getUserList(query: UserListRequestQuery): Promise<UserListResponse>;
57
57
 
58
+
59
+ /**
60
+ * Call to retrieve a valid token to access the Microsoft API. Includes a time value to
61
+ * refresh the token.
62
+ *
63
+ * @param type The name of the integration. ("ms365")
64
+ * @returns A promise containing the IntegrationToken is returned. In case of an error,
65
+ * the promise is rejected.
66
+ */
67
+ getIntegration(type: IntegrationType): Promise<IntegrationToken | null>;
58
68
  }
package/package.json CHANGED
@@ -1,27 +1,33 @@
1
1
  {
2
2
  "name": "@staffbase/widget-sdk",
3
- "version": "3.3.1",
4
- "description": "sdk for widgets",
3
+ "version": "3.4.0-beta.1",
4
+ "description": "Staffbase SDK for Custom Widgets",
5
5
  "keywords": [
6
6
  "web-components"
7
7
  ],
8
- "license": "Apache-2.0",
9
- "author": "Staffbase",
10
8
  "scripts": {
9
+ "clean-doc": "npx rimraf docs",
10
+ "doc": "npm run clean-doc && typedoc --out docs index.d.ts --plugin typedoc-plugin-markdown --readme none --disableSources --theme ./node_modules/typedoc-github-wiki-theme/dist",
11
11
  "release": "semantic-release",
12
12
  "prepare": "husky install"
13
13
  },
14
+ "license": "Apache-2.0",
15
+ "author": "Staffbase",
14
16
  "dependencies": {
15
- "@rjsf/core": "2.5.0",
17
+ "@rjsf/core": "3.0.0",
16
18
  "@types/json-schema": "^7.0.5"
17
19
  },
18
20
  "devDependencies": {
19
- "@amanda-mitchell/semantic-release-npm-multiple": "2.8.0",
20
- "@commitlint/cli": "12.1.1",
21
- "@commitlint/config-conventional": "12.1.1",
22
- "@tmware/semantic-release-npm-github-publish": "1.4.3",
23
- "husky": "^6.0.0",
21
+ "@amanda-mitchell/semantic-release-npm-multiple": "2.12.0",
22
+ "@commitlint/cli": "13.1.0",
23
+ "@commitlint/config-conventional": "13.1.0",
24
+ "@tmware/semantic-release-npm-github-publish": "1.4.4",
25
+ "@types/react": "^17.0.15",
26
+ "husky": "^7.0.1",
24
27
  "semantic-release": "^17.4.2",
28
+ "typedoc": "0.21.5",
29
+ "typedoc-github-wiki-theme": "0.5.1",
30
+ "typedoc-plugin-markdown": "3.10.4",
25
31
  "typescript": "^4.2.4"
26
32
  },
27
33
  "repository": {
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "commonjs",
5
+ "noEmit": true,
6
+
7
+ "strict": true,
8
+
9
+ "moduleResolution": "node",
10
+ "baseUrl": "./",
11
+ "esModuleInterop": true
12
+ }
13
+ }