@microsoft/sp-component-base 1.23.1 → 1.24.0-beta.2
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/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +136 -141
- package/dist/{chunk.legacy-third-party-fabric-core-localfont_none_9e84ea19c68fdc8b9094.js → chunk.legacy-third-party-fabric-core-localfont_none_b7f7978a3e90166c361b.js} +1 -1
- package/dist/chunk.teams-apps-client_none_27d3c7c1d01080e4f131.js +2 -0
- package/dist/index-internal-beta.d.ts +30 -8
- package/dist/index-internal-public.d.ts +30 -8
- package/dist/index-internal.d.ts +30 -8
- package/dist/sp-component-base_default_8d535b51fa18aa47002b.js +22 -0
- package/dist/sp-component-base_en-us_8ce25dfb69a7786caece.js +22 -0
- package/dist/sp-component-base_qps-ploc_4fec831895d90df8aa7a.js +22 -0
- package/dist/sp-component-base_qps-ploca_b80610c8dff04dcec755.js +22 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-commonjs/BaseComponent.js +110 -145
- package/lib-commonjs/BaseComponentContext.js +126 -183
- package/lib-commonjs/DynamicDataProvider.js +251 -268
- package/lib-commonjs/DynamicDataSourceManager.js +218 -241
- package/lib-commonjs/DynamicProperty.js +232 -280
- package/lib-commonjs/EnsureIsolatedDomainUrl.js +14 -14
- package/lib-commonjs/IComponentPosition.js +8 -3
- package/lib-commonjs/IComponentPropertyMetadata.js +10 -3
- package/lib-commonjs/ISerializedServerProcessedData.js +24 -21
- package/lib-commonjs/LegacyThirdPartyFabricCoreLoader.js +53 -87
- package/lib-commonjs/PropertyMetadataProcessor.js +117 -150
- package/lib-commonjs/RenderableComponentContext.js +37 -0
- package/lib-commonjs/ShimmerFactory.js +66 -51
- package/lib-commonjs/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +6 -4
- package/lib-commonjs/common/Flights.js +22 -10
- package/lib-commonjs/common/KillSwitches.js +13 -6
- package/lib-commonjs/dataCollector/IWebPartLoadData.js +35 -30
- package/lib-commonjs/dataCollector/WebPartLoadDataCollector.js +82 -91
- package/lib-commonjs/index.js +78 -38
- package/lib-commonjs/teams/DeferredTeamsAppsClient.js +30 -52
- package/lib-commonjs/teams/ITeamsAppCatalog.js +10 -3
- package/lib-commonjs/teams/TeamsAppsClient.js +189 -231
- package/lib-commonjs/test-api/MockComponent.js +38 -23
- package/lib-commonjs/test-api/MockComponentContext.js +21 -14
- package/lib-commonjs/test-api/index.js +21 -7
- package/lib-commonjs/themeProvider/ThemeProvider.js +68 -82
- package/lib-commonjs/themeProvider/themeInterfaces/IFontStyles.js +5 -2
- package/lib-commonjs/themeProvider/themeInterfaces/IPalette.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticColors.js +59 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticTextColors.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ITheme.js +5 -2
- package/{lib → lib-dts}/BaseComponent.d.ts +8 -8
- package/{lib → lib-dts}/BaseComponentContext.d.ts +5 -5
- package/lib-dts/RenderableComponentContext.d.ts +35 -0
- package/{lib → lib-dts}/index.d.ts +1 -0
- package/lib-esm/BaseComponent.js +123 -0
- package/lib-esm/BaseComponentContext.js +157 -0
- package/lib-esm/DynamicDataProvider.js +401 -0
- package/lib-esm/DynamicDataSourceManager.js +358 -0
- package/lib-esm/DynamicProperty.js +344 -0
- package/{lib → lib-esm}/EnsureIsolatedDomainUrl.js +6 -6
- package/lib-esm/IComponentPosition.js +5 -0
- package/lib-esm/IComponentPropertyMetadata.js +7 -0
- package/lib-esm/ISerializedServerProcessedData.js +24 -0
- package/lib-esm/LegacyThirdPartyFabricCoreLoader.js +76 -0
- package/{lib → lib-esm}/PropertyMetadataProcessor.js +92 -127
- package/lib-esm/RenderableComponentContext.js +26 -0
- package/lib-esm/ShimmerFactory.js +74 -0
- package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +3 -3
- package/{lib → lib-esm}/common/Flights.js +4 -3
- package/{lib → lib-esm}/common/KillSwitches.js +3 -2
- package/lib-esm/dataCollector/IWebPartLoadData.js +33 -0
- package/lib-esm/dataCollector/WebPartLoadDataCollector.js +125 -0
- package/{lib → lib-esm}/index.js +4 -3
- package/lib-esm/teams/DeferredTeamsAppsClient.js +32 -0
- package/lib-esm/teams/ITeamsAppCatalog.js +9 -0
- package/lib-esm/teams/TeamsAppsClient.js +395 -0
- package/lib-esm/test-api/MockComponent.js +38 -0
- package/{lib → lib-esm}/test-api/MockComponentContext.js +10 -11
- package/{lib → lib-esm}/test-api/index.js +2 -1
- package/lib-esm/themeProvider/ThemeProvider.js +79 -0
- package/lib-esm/themeProvider/themeInterfaces/IFontStyles.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/IPalette.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticColors.js +56 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticTextColors.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ITheme.js +7 -0
- package/package.json +41 -14
- package/dist/chunk.teams-apps-client_none_f9872389cb6ea9ad28e2.js +0 -2
- package/dist/sp-component-base_default_5ba07be39b0dc8968f7b.js +0 -2
- package/dist/sp-component-base_en-us_eb9bebb3acce0ae83f1c.js +0 -2
- package/dist/sp-component-base_qps-ploc_45f37623d87c3d848f2a.js +0 -2
- package/dist/sp-component-base_qps-ploca_b3f3b7bf97c4185b0fd6.js +0 -2
- package/lib/BaseComponent.d.ts.map +0 -1
- package/lib/BaseComponent.js +0 -161
- package/lib/BaseComponentContext.d.ts.map +0 -1
- package/lib/BaseComponentContext.js +0 -222
- package/lib/DynamicDataProvider.d.ts.map +0 -1
- package/lib/DynamicDataProvider.js +0 -420
- package/lib/DynamicDataSourceManager.d.ts.map +0 -1
- package/lib/DynamicDataSourceManager.js +0 -382
- package/lib/DynamicProperty.d.ts.map +0 -1
- package/lib/DynamicProperty.js +0 -390
- package/lib/EnsureIsolatedDomainUrl.d.ts.map +0 -1
- package/lib/IComponentPosition.d.ts.map +0 -1
- package/lib/IComponentPosition.js +0 -2
- package/lib/IComponentPropertyMetadata.d.ts.map +0 -1
- package/lib/IComponentPropertyMetadata.js +0 -2
- package/lib/ISerializedServerProcessedData.d.ts.map +0 -1
- package/lib/ISerializedServerProcessedData.js +0 -28
- package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +0 -1
- package/lib/LegacyThirdPartyFabricCoreLoader.js +0 -90
- package/lib/PropertyMetadataProcessor.d.ts.map +0 -1
- package/lib/ShimmerFactory.d.ts.map +0 -1
- package/lib/ShimmerFactory.js +0 -62
- package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +0 -1
- package/lib/common/Flights.d.ts.map +0 -1
- package/lib/common/KillSwitches.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.js +0 -40
- package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +0 -1
- package/lib/dataCollector/WebPartLoadDataCollector.js +0 -137
- package/lib/index.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.js +0 -39
- package/lib/teams/ITeamsAppCatalog.d.ts.map +0 -1
- package/lib/teams/ITeamsAppCatalog.js +0 -2
- package/lib/teams/TeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/TeamsAppsClient.js +0 -440
- package/lib/test-api/MockComponent.d.ts.map +0 -1
- package/lib/test-api/MockComponent.js +0 -31
- package/lib/test-api/MockComponentContext.d.ts.map +0 -1
- package/lib/test-api/index.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.js +0 -99
- package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IFontStyles.js +0 -2
- package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IPalette.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ITheme.js +0 -2
- /package/{lib → lib-dts}/DynamicDataProvider.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicDataSourceManager.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicProperty.d.ts +0 -0
- /package/{lib → lib-dts}/EnsureIsolatedDomainUrl.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPosition.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPropertyMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/ISerializedServerProcessedData.d.ts +0 -0
- /package/{lib → lib-dts}/LegacyThirdPartyFabricCoreLoader.d.ts +0 -0
- /package/{lib → lib-dts}/PropertyMetadataProcessor.d.ts +0 -0
- /package/{lib → lib-dts}/ShimmerFactory.d.ts +0 -0
- /package/{lib → lib-dts}/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +0 -0
- /package/{lib → lib-dts}/common/Flights.d.ts +0 -0
- /package/{lib → lib-dts}/common/KillSwitches.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/IWebPartLoadData.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/WebPartLoadDataCollector.d.ts +0 -0
- /package/{lib → lib-dts}/loc/Strings.resx.d.ts +0 -0
- /package/{lib → lib-dts}/teams/DeferredTeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/teams/ITeamsAppCatalog.d.ts +0 -0
- /package/{lib → lib-dts}/teams/TeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponent.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponentContext.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/index.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/ThemeProvider.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IFontStyles.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IPalette.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ITheme.d.ts +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/iconDefinitions.css +0 -0
- /package/{lib → lib-esm}/loc/Strings.resx.json +0 -0
- /package/{lib → lib-esm}/sp-component-base.manifest.json +0 -0
- /package/{lib → lib-esm}/styles/shimmer.module.scss.css +0 -0
|
@@ -1,47 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var DynamicDataProvider_1 = tslib_1.__importDefault(require("./DynamicDataProvider"));
|
|
10
|
-
var Strings_resx_1 = tslib_1.__importDefault(require("./loc/Strings.resx"));
|
|
11
|
-
var KillSwitches_1 = require("./common/KillSwitches");
|
|
12
|
-
/**
|
|
13
|
-
* The Dynamic Data Source Manager is responsible for:
|
|
14
|
-
* - Constructing the dynamic data source
|
|
15
|
-
* - Allowing initialization of the dynamic data source by a component
|
|
16
|
-
* - Allowing data source to update its metadata and notify when data has been updated.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
var DynamicDataSourceManager = /** @class */ (function () {
|
|
21
|
-
function DynamicDataSourceManager() {
|
|
22
|
-
this._src = undefined;
|
|
23
|
-
this._isDisposed = false;
|
|
24
|
-
this._isInitialized = false;
|
|
25
|
-
this._logSource = sp_diagnostics_1._LogSource.create('DynamicDataSourceManager');
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return DynamicDataSourceManager;
|
|
26
9
|
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _spdiagnostics = require("@microsoft/sp-diagnostics");
|
|
14
|
+
const _spcorelibrary = require("@microsoft/sp-core-library");
|
|
15
|
+
const _spdynamicdata = require("@microsoft/sp-dynamic-data");
|
|
16
|
+
const _splodashsubset = /*#__PURE__*/ _interop_require_wildcard._(require("@microsoft/sp-lodash-subset"));
|
|
17
|
+
const _DynamicDataProvider = /*#__PURE__*/ _interop_require_default._(require("./DynamicDataProvider"));
|
|
18
|
+
const _Stringsresx = /*#__PURE__*/ _interop_require_default._(require("./loc/Strings.resx"));
|
|
19
|
+
const _KillSwitches = require("./common/KillSwitches");
|
|
20
|
+
class DynamicDataSourceManager {
|
|
27
21
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sp_core_library_1.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
|
|
22
|
+
* Initializes the Dynamic Data source manager for a specific component.
|
|
23
|
+
*
|
|
24
|
+
* @param component - Component on which the source is being constructed.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/ _initialize(component, serviceScope) {
|
|
28
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(component, 'component');
|
|
29
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
|
|
37
30
|
this._component = component;
|
|
38
|
-
this._dynamicDataManager = serviceScope.consume(
|
|
31
|
+
this._dynamicDataManager = serviceScope.consume(_spdynamicdata._DynamicDataUtilities.IDynamicDataManagerServiceKey);
|
|
39
32
|
this._isInitialized = true;
|
|
40
|
-
}
|
|
33
|
+
}
|
|
41
34
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
DynamicDataSourceManager.prototype.dispose = function () {
|
|
35
|
+
* Disposes the resources held by the Dynamic Data source.
|
|
36
|
+
*/ dispose() {
|
|
45
37
|
if (!this._isDisposed) {
|
|
46
38
|
if (this._src) {
|
|
47
39
|
this._dynamicDataManager.removeSource(this._src.id);
|
|
@@ -52,109 +44,92 @@ var DynamicDataSourceManager = /** @class */ (function () {
|
|
|
52
44
|
this._isInitialized = false;
|
|
53
45
|
this._isDisposed = true;
|
|
54
46
|
}
|
|
55
|
-
}
|
|
56
|
-
Object.defineProperty(DynamicDataSourceManager.prototype, "isDisposed", {
|
|
57
|
-
/**
|
|
58
|
-
* Returns true if the DynamicDataSourceManager is disposed.
|
|
59
|
-
*/
|
|
60
|
-
get: function () {
|
|
61
|
-
return this._isDisposed;
|
|
62
|
-
},
|
|
63
|
-
enumerable: false,
|
|
64
|
-
configurable: true
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(DynamicDataSourceManager.prototype, "_source", {
|
|
67
|
-
/**
|
|
68
|
-
* Returns the source of DynamicDataSourceManager.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
get: function () {
|
|
72
|
-
return this._src;
|
|
73
|
-
},
|
|
74
|
-
enumerable: false,
|
|
75
|
-
configurable: true
|
|
76
|
-
});
|
|
47
|
+
}
|
|
77
48
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
49
|
+
* Returns true if the DynamicDataSourceManager is disposed.
|
|
50
|
+
*/ get isDisposed() {
|
|
51
|
+
return this._isDisposed;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns the source of DynamicDataSourceManager.
|
|
55
|
+
* @internal
|
|
56
|
+
*/ get _source() {
|
|
57
|
+
return this._src;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Initializes the Dynamic Data Source for the component.
|
|
61
|
+
*
|
|
62
|
+
* @param callableFunctions - Set of methods that are exposed through the Dynamic Data Source
|
|
63
|
+
*/ initializeSource(callableFunctions) {
|
|
83
64
|
this._assertNotDisposed();
|
|
84
65
|
this._assertInitialized();
|
|
85
66
|
if (this._src) {
|
|
86
|
-
throw new Error(
|
|
67
|
+
throw new Error(_Stringsresx.default.SourceAlreadyInitialized);
|
|
87
68
|
}
|
|
88
69
|
this._callableFunctions = callableFunctions;
|
|
89
70
|
this._src = this._buildSource(this._component);
|
|
90
71
|
this._dynamicDataManager.addSource(this._src);
|
|
91
|
-
if (!(0,
|
|
72
|
+
if (!(0, _KillSwitches.isExemptWebPartWithDynamicDataFromLazyLoadKSActivated)()) {
|
|
92
73
|
this._component._containsDynamicDataSource = true;
|
|
93
74
|
}
|
|
94
|
-
this._logFeatureEntry('DynamicDataSourceInitialized', {
|
|
95
|
-
|
|
75
|
+
this._logFeatureEntry('DynamicDataSourceInitialized', {
|
|
76
|
+
sourceId: this._src.id
|
|
77
|
+
});
|
|
78
|
+
}
|
|
96
79
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
DynamicDataSourceManager.prototype.notifySourceChanged = function () {
|
|
80
|
+
* Notifies that this source has updated its properties.
|
|
81
|
+
*
|
|
82
|
+
* When invoked, it enables to broadcast the notification to all the consumers who have
|
|
83
|
+
* registered to this notification from this source.
|
|
84
|
+
*/ notifySourceChanged() {
|
|
103
85
|
this._assertNotDisposed();
|
|
104
86
|
this._assertInitialized();
|
|
105
87
|
this._assertSourceExists();
|
|
106
88
|
this._dynamicDataManager.notifySourceChanged(this._src.id);
|
|
107
|
-
}
|
|
89
|
+
}
|
|
108
90
|
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
sp_core_library_1.Validate.isNonemptyString(propertyId, 'propertyId');
|
|
91
|
+
* Notifies that this source has updated a specific property.
|
|
92
|
+
*
|
|
93
|
+
* When invoked, it enables to broadcast the notification to all the consumers who have
|
|
94
|
+
* registered to this notification from this source.
|
|
95
|
+
*
|
|
96
|
+
* @param propertyId - Id of the updated property in the source.
|
|
97
|
+
*/ notifyPropertyChanged(propertyId) {
|
|
98
|
+
_spcorelibrary.Validate.isNonemptyString(propertyId, 'propertyId');
|
|
118
99
|
this._assertNotDisposed();
|
|
119
100
|
this._assertInitialized();
|
|
120
101
|
this._assertSourceExists();
|
|
121
102
|
this._dynamicDataManager.notifyPropertyChanged(this._src.id, propertyId);
|
|
122
|
-
}
|
|
103
|
+
}
|
|
123
104
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
DynamicDataSourceManager.prototype.updateMetadata = function (metadata) {
|
|
105
|
+
* Updates the metadata of the Dynamic Data Source.
|
|
106
|
+
* It allows to update fields like title or description.
|
|
107
|
+
* Auto-generated fields like alias, componentId or instanceId cannot be updated.
|
|
108
|
+
*
|
|
109
|
+
* @param metadata - Partial of the metadata.
|
|
110
|
+
*/ updateMetadata(metadata) {
|
|
131
111
|
this._assertNotDisposed();
|
|
132
112
|
this._assertInitialized();
|
|
133
113
|
this._assertSourceExists();
|
|
134
|
-
|
|
114
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(metadata, 'metadata');
|
|
135
115
|
// Ensure that auto-generated properties are not updated.
|
|
136
116
|
metadata.alias = undefined;
|
|
137
117
|
metadata.componentId = undefined;
|
|
138
118
|
metadata.instanceId = undefined;
|
|
139
|
-
(0,
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
enumerable: false,
|
|
150
|
-
configurable: true
|
|
151
|
-
});
|
|
152
|
-
DynamicDataSourceManager.prototype._buildSource = function (component) {
|
|
119
|
+
(0, _splodashsubset.merge)(this._src.metadata, metadata);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns the Id of the current DataSource.
|
|
123
|
+
* If the component did not initialize as a dynamic data source, then it returns an empty string.
|
|
124
|
+
*/ get sourceId() {
|
|
125
|
+
return this._src ? this._src.id : '';
|
|
126
|
+
}
|
|
127
|
+
_buildSource(component) {
|
|
153
128
|
// If the source is returning non-empty allowed events then, it has to define
|
|
154
129
|
// 'sendEvent' event handler as well.
|
|
155
130
|
if (this._callableFunctions.allowedEvents && this._callableFunctions.allowedEvents.length > 0) {
|
|
156
131
|
if (!this._callableFunctions.sendEvent) {
|
|
157
|
-
throw new Error(
|
|
132
|
+
throw new Error(_Stringsresx.default.NoSendEventWhenAllowedEventsIsNonEmpty);
|
|
158
133
|
}
|
|
159
134
|
}
|
|
160
135
|
return {
|
|
@@ -171,120 +146,112 @@ var DynamicDataSourceManager = /** @class */ (function () {
|
|
|
171
146
|
allowedEventsAsync: this._allowedEventsAsync.bind(this),
|
|
172
147
|
sendEvent: this._sendEvent.bind(this)
|
|
173
148
|
};
|
|
174
|
-
}
|
|
149
|
+
}
|
|
175
150
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
? (0, sp_lodash_subset_1.cloneDeep)(this._callableFunctions.allowedEvents())
|
|
182
|
-
: undefined;
|
|
183
|
-
};
|
|
151
|
+
* This is the allowedEvents() that the DynamicDataSource actually exposes.
|
|
152
|
+
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
153
|
+
*/ _allowedEvents() {
|
|
154
|
+
return this._callableFunctions.allowedEvents ? (0, _splodashsubset.cloneDeep)(this._callableFunctions.allowedEvents()) : undefined;
|
|
155
|
+
}
|
|
184
156
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
DynamicDataSourceManager.prototype._sendEvent = function (eventName, data) {
|
|
157
|
+
* This is the sendEvent() that the consumer invokes to send an event to the source, with data.
|
|
158
|
+
* @param eventName - Name of the event
|
|
159
|
+
* @param data - Associated data
|
|
160
|
+
*/ _sendEvent(eventName, data) {
|
|
190
161
|
this._assertValidEvent(eventName);
|
|
191
162
|
this._callableFunctions.sendEvent(eventName, data);
|
|
192
|
-
}
|
|
163
|
+
}
|
|
193
164
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
};
|
|
165
|
+
* This is the getPropertyDefinitions() that the DynamicDataSource actually exposes.
|
|
166
|
+
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
167
|
+
* This assumes that the component has dynamic data and has a controller.
|
|
168
|
+
*/ _getPropertyDefinitions() {
|
|
169
|
+
return (0, _splodashsubset.cloneDeep)(this._callableFunctions.getPropertyDefinitions());
|
|
170
|
+
}
|
|
201
171
|
/**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
var paths = propertyId.split(DynamicDataProvider_1.default._jsonPathArrayRegex);
|
|
172
|
+
* This is the getPropertyValue() that the DynamicDataSource actually exposes.
|
|
173
|
+
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
174
|
+
* This assumes that the component has the source initialized.
|
|
175
|
+
* If there is no value returned, it checks whether the propertyId is incorrect or the value is actually undefined.
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* If the property value associated with the property id, is an array then the
|
|
179
|
+
* propertyId will have [*] notation appended at the end to support valid JSON Path notation.
|
|
180
|
+
* Hence when reading the property id, we account for that and extract the name accordingly.
|
|
181
|
+
*/ _getPropertyValue(propertyId) {
|
|
182
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
|
|
183
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('DynamicDataSourceManager._getPropertyValue');
|
|
184
|
+
const paths = propertyId.split(_DynamicDataProvider.default._jsonPathArrayRegex);
|
|
216
185
|
try {
|
|
217
|
-
|
|
186
|
+
let propertyValue = this._callableFunctions.getPropertyValue(paths.shift());
|
|
218
187
|
if (paths.length > 0) {
|
|
219
188
|
if (!isNaN(parseInt(paths[0], 10)) && Array.isArray(propertyValue)) {
|
|
220
189
|
propertyValue = propertyValue[paths[0]];
|
|
221
190
|
}
|
|
222
191
|
}
|
|
223
192
|
if (propertyValue === undefined) {
|
|
224
|
-
if (
|
|
225
|
-
// This code can be slow if there is a many property definitions (O(n) for number of properties).
|
|
193
|
+
if (// This code can be slow if there is a many property definitions (O(n) for number of properties).
|
|
226
194
|
// It's done this way to prioritize memory consumption instead of CPU cycles as this is an optional feature,
|
|
227
195
|
// so if it's not used there is no memory footprint
|
|
228
|
-
this._callableFunctions.getPropertyDefinitions().filter(
|
|
229
|
-
0 &&
|
|
230
|
-
this._src // Check that the source exists to get its title
|
|
196
|
+
this._callableFunctions.getPropertyDefinitions().filter((def)=>def.id === propertyId).length === 0 && this._src // Check that the source exists to get its title
|
|
231
197
|
) {
|
|
232
|
-
throw new Error(
|
|
198
|
+
throw new Error(`Property "${propertyId}" doesn't exist in source "${this._src.metadata.title}"`);
|
|
233
199
|
}
|
|
234
200
|
}
|
|
235
201
|
// DO NOT log propertyValue it can contain PII.
|
|
236
|
-
qosMonitor.writeSuccess(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
202
|
+
qosMonitor.writeSuccess({
|
|
203
|
+
...this._src && this._src.metadata || {},
|
|
204
|
+
sourceId: this._src && this._src.id,
|
|
205
|
+
propertyId
|
|
206
|
+
});
|
|
207
|
+
return (0, _splodashsubset.cloneDeep)(propertyValue);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
qosMonitor.writeUnexpectedFailure('NoPropertyId', error, {
|
|
210
|
+
propertyId
|
|
211
|
+
});
|
|
212
|
+
_spdiagnostics._TraceLogger.logErrorData({
|
|
242
213
|
source: this._logSource,
|
|
243
214
|
error: error
|
|
244
215
|
});
|
|
245
216
|
return undefined;
|
|
246
217
|
}
|
|
247
|
-
}
|
|
218
|
+
}
|
|
248
219
|
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
DynamicDataSourceManager.prototype._getPropertyDefinitionsAsync = function () {
|
|
220
|
+
* Returns the real time value of the property.
|
|
221
|
+
*/ _getPropertyDefinitionsAsync() {
|
|
252
222
|
return Promise.resolve(this._getPropertyDefinitions());
|
|
253
|
-
}
|
|
223
|
+
}
|
|
254
224
|
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
DynamicDataSourceManager.prototype._getPropertyValueAsync = function (propertyId) {
|
|
225
|
+
* Returns the real time value of the property.
|
|
226
|
+
* @param propertyId - property id for which the value is requested.
|
|
227
|
+
*/ _getPropertyValueAsync(propertyId) {
|
|
259
228
|
return Promise.resolve(this._getPropertyValue(propertyId));
|
|
260
|
-
}
|
|
229
|
+
}
|
|
261
230
|
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
DynamicDataSourceManager.prototype._allowedEventsAsync = function () {
|
|
231
|
+
* This is the allowedEvents() that the DynamicDataSource actually exposes.
|
|
232
|
+
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
233
|
+
*/ _allowedEventsAsync() {
|
|
266
234
|
return Promise.resolve(this._allowedEvents());
|
|
267
|
-
}
|
|
235
|
+
}
|
|
268
236
|
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var getAnnotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue;
|
|
237
|
+
* This is the getPropertyValueSchema() that the DynamicDataSource actually exposes.
|
|
238
|
+
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
239
|
+
* If the source doesn't provide the annotated value, then it falls back to whatever
|
|
240
|
+
* 'getPropertyValue' returns as the sample value and metadata would be undefined.
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* If the property value associated with the property id, is an array then the
|
|
244
|
+
* propertyId will have [*] notation appended at the end to support valid JSON Path notation.
|
|
245
|
+
* Hence when reading the property id, we account for that and extract the name accordingly.
|
|
246
|
+
*
|
|
247
|
+
* @param propertyId - property id for which the schema is requested.
|
|
248
|
+
*/ _getAnnotatedPropertyValue(propertyId) {
|
|
249
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
|
|
250
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('DynamicDataSourceManager._getAnnotatedPropertyValue');
|
|
251
|
+
let annotatedPropertyValue;
|
|
252
|
+
const { getAnnotatedPropertyValue } = this._callableFunctions;
|
|
286
253
|
if (getAnnotatedPropertyValue) {
|
|
287
|
-
|
|
254
|
+
const paths = propertyId.split(_DynamicDataProvider.default._jsonPathArrayRegex);
|
|
288
255
|
try {
|
|
289
256
|
annotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue(paths.shift());
|
|
290
257
|
if (paths.length > 0) {
|
|
@@ -292,11 +259,17 @@ var DynamicDataSourceManager = /** @class */ (function () {
|
|
|
292
259
|
annotatedPropertyValue = annotatedPropertyValue[paths[0]];
|
|
293
260
|
}
|
|
294
261
|
}
|
|
295
|
-
qosMonitor.writeSuccess(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
262
|
+
qosMonitor.writeSuccess({
|
|
263
|
+
...this._src && this._src.metadata || {},
|
|
264
|
+
sourceId: this._src && this._src.id,
|
|
265
|
+
annotatedPropertyValue,
|
|
266
|
+
propertyId
|
|
267
|
+
});
|
|
268
|
+
} catch (error) {
|
|
269
|
+
qosMonitor.writeExpectedFailure('NoAnnotatedPropertyValue', error, {
|
|
270
|
+
annotatedPropertyValue
|
|
271
|
+
});
|
|
272
|
+
_spdiagnostics._TraceLogger.logErrorData({
|
|
300
273
|
source: this._logSource,
|
|
301
274
|
error: error
|
|
302
275
|
});
|
|
@@ -310,23 +283,22 @@ var DynamicDataSourceManager = /** @class */ (function () {
|
|
|
310
283
|
};
|
|
311
284
|
}
|
|
312
285
|
return annotatedPropertyValue;
|
|
313
|
-
}
|
|
286
|
+
}
|
|
314
287
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
DynamicDataSourceManager.prototype._getAnnotatedPropertyValueAsync = function (propertyId) {
|
|
288
|
+
* Returns the annotated value of the property.
|
|
289
|
+
* @param propertyId - property id for which the value is requested.
|
|
290
|
+
*/ _getAnnotatedPropertyValueAsync(propertyId) {
|
|
319
291
|
return Promise.resolve(this._getAnnotatedPropertyValue(propertyId));
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
292
|
+
}
|
|
293
|
+
_buildMetadata(component) {
|
|
294
|
+
const metadata = {
|
|
323
295
|
title: component.manifest.alias,
|
|
324
296
|
alias: component.manifest.alias,
|
|
325
297
|
componentId: component.componentId,
|
|
326
298
|
instanceId: component.instanceId
|
|
327
299
|
};
|
|
328
300
|
// Web parts have properties "title" and "description" that should go to the source by default.
|
|
329
|
-
|
|
301
|
+
const componentWithMetadata = component;
|
|
330
302
|
if (componentWithMetadata.title) {
|
|
331
303
|
metadata.title = componentWithMetadata.title;
|
|
332
304
|
}
|
|
@@ -334,51 +306,56 @@ var DynamicDataSourceManager = /** @class */ (function () {
|
|
|
334
306
|
metadata.description = componentWithMetadata.description;
|
|
335
307
|
}
|
|
336
308
|
return metadata;
|
|
337
|
-
}
|
|
309
|
+
}
|
|
338
310
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
311
|
+
* Asserts if the event is a valid event on the source.
|
|
312
|
+
*
|
|
313
|
+
* Its an invalid event in two cases:
|
|
314
|
+
* 1. When '_allowedEvent()' api returns undefined
|
|
315
|
+
* 2. When the event name is not one of the allowed events on the source.
|
|
316
|
+
*
|
|
317
|
+
* @param eventName - Name of the event.
|
|
318
|
+
*/ _assertValidEvent(eventName) {
|
|
319
|
+
if (!this._allowedEvents() || (0, _splodashsubset.findIndex)(this._allowedEvents(), {
|
|
320
|
+
name: eventName
|
|
321
|
+
}) === -1) {
|
|
322
|
+
throw new Error(_spcorelibrary.Text.format(_Stringsresx.default.InvalidEvent, eventName, this._src.metadata.title));
|
|
350
323
|
}
|
|
351
|
-
}
|
|
352
|
-
|
|
324
|
+
}
|
|
325
|
+
_assertNotDisposed() {
|
|
353
326
|
if (this.isDisposed) {
|
|
354
|
-
throw new Error(
|
|
327
|
+
throw new Error(_Stringsresx.default.DynamicDataSourceManagerIsDisposed);
|
|
355
328
|
}
|
|
356
|
-
}
|
|
357
|
-
|
|
329
|
+
}
|
|
330
|
+
_assertInitialized() {
|
|
358
331
|
if (!this._isInitialized) {
|
|
359
|
-
throw new Error(
|
|
332
|
+
throw new Error(_Stringsresx.default.DynamicDataSourceManagerIsNotInitialized);
|
|
360
333
|
}
|
|
361
|
-
}
|
|
362
|
-
|
|
334
|
+
}
|
|
335
|
+
_assertSourceExists() {
|
|
363
336
|
if (!this._src) {
|
|
364
|
-
throw new Error(
|
|
337
|
+
throw new Error(_Stringsresx.default.DynamicDataSourceIsNotInitialized);
|
|
365
338
|
}
|
|
366
|
-
}
|
|
339
|
+
}
|
|
367
340
|
/**
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
var logProperties = {
|
|
341
|
+
* Logs a feature event.
|
|
342
|
+
* @param logFeature - Name of the feature to log.
|
|
343
|
+
* @param contextualProps - Contextual log properties of the feature event.
|
|
344
|
+
*/ _logFeatureEntry(logFeature, contextualProps) {
|
|
345
|
+
const isInternal = this._component.manifest.isInternal || false;
|
|
346
|
+
const logProperties = {
|
|
375
347
|
alias: this._component.manifest.alias,
|
|
376
348
|
isInternal: isInternal.toString()
|
|
377
349
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
350
|
+
const logEntry = new _spdiagnostics._LogEntry('DynamicDataSourceManager', logFeature, _spdiagnostics._LogType.Event, _splodashsubset.merge(logProperties, contextualProps));
|
|
351
|
+
_spdiagnostics._EngagementLogger.logEventWithLogEntry(logEntry);
|
|
352
|
+
}
|
|
353
|
+
constructor(){
|
|
354
|
+
this._src = undefined;
|
|
355
|
+
this._isDisposed = false;
|
|
356
|
+
this._isInitialized = false;
|
|
357
|
+
this._logSource = _spdiagnostics._LogSource.create('DynamicDataSourceManager');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
//# sourceMappingURL=./DynamicDataSourceManager.js.map
|