@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,382 +0,0 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { _EngagementLogger, _LogEntry, _LogType, _TraceLogger, _LogSource, _QosMonitor } from '@microsoft/sp-diagnostics';
|
|
3
|
-
import { Text, Validate } from '@microsoft/sp-core-library';
|
|
4
|
-
import { _DynamicDataUtilities } from '@microsoft/sp-dynamic-data';
|
|
5
|
-
import * as lodash from '@microsoft/sp-lodash-subset';
|
|
6
|
-
import { cloneDeep, findIndex, merge } from '@microsoft/sp-lodash-subset';
|
|
7
|
-
import DynamicDataProvider from './DynamicDataProvider';
|
|
8
|
-
import strings from './loc/Strings.resx';
|
|
9
|
-
import { isExemptWebPartWithDynamicDataFromLazyLoadKSActivated } from './common/KillSwitches';
|
|
10
|
-
/**
|
|
11
|
-
* The Dynamic Data Source Manager is responsible for:
|
|
12
|
-
* - Constructing the dynamic data source
|
|
13
|
-
* - Allowing initialization of the dynamic data source by a component
|
|
14
|
-
* - Allowing data source to update its metadata and notify when data has been updated.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
var DynamicDataSourceManager = /** @class */ (function () {
|
|
19
|
-
function DynamicDataSourceManager() {
|
|
20
|
-
this._src = undefined;
|
|
21
|
-
this._isDisposed = false;
|
|
22
|
-
this._isInitialized = false;
|
|
23
|
-
this._logSource = _LogSource.create('DynamicDataSourceManager');
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Initializes the Dynamic Data source manager for a specific component.
|
|
27
|
-
*
|
|
28
|
-
* @param component - Component on which the source is being constructed.
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
DynamicDataSourceManager.prototype._initialize = function (component, serviceScope) {
|
|
33
|
-
Validate.isNotNullOrUndefined(component, 'component');
|
|
34
|
-
Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
|
|
35
|
-
this._component = component;
|
|
36
|
-
this._dynamicDataManager = serviceScope.consume(_DynamicDataUtilities.IDynamicDataManagerServiceKey);
|
|
37
|
-
this._isInitialized = true;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Disposes the resources held by the Dynamic Data source.
|
|
41
|
-
*/
|
|
42
|
-
DynamicDataSourceManager.prototype.dispose = function () {
|
|
43
|
-
if (!this._isDisposed) {
|
|
44
|
-
if (this._src) {
|
|
45
|
-
this._dynamicDataManager.removeSource(this._src.id);
|
|
46
|
-
delete this._src;
|
|
47
|
-
}
|
|
48
|
-
delete this._dynamicDataManager;
|
|
49
|
-
delete this._component;
|
|
50
|
-
this._isInitialized = false;
|
|
51
|
-
this._isDisposed = true;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(DynamicDataSourceManager.prototype, "isDisposed", {
|
|
55
|
-
/**
|
|
56
|
-
* Returns true if the DynamicDataSourceManager is disposed.
|
|
57
|
-
*/
|
|
58
|
-
get: function () {
|
|
59
|
-
return this._isDisposed;
|
|
60
|
-
},
|
|
61
|
-
enumerable: false,
|
|
62
|
-
configurable: true
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(DynamicDataSourceManager.prototype, "_source", {
|
|
65
|
-
/**
|
|
66
|
-
* Returns the source of DynamicDataSourceManager.
|
|
67
|
-
* @internal
|
|
68
|
-
*/
|
|
69
|
-
get: function () {
|
|
70
|
-
return this._src;
|
|
71
|
-
},
|
|
72
|
-
enumerable: false,
|
|
73
|
-
configurable: true
|
|
74
|
-
});
|
|
75
|
-
/**
|
|
76
|
-
* Initializes the Dynamic Data Source for the component.
|
|
77
|
-
*
|
|
78
|
-
* @param callableFunctions - Set of methods that are exposed through the Dynamic Data Source
|
|
79
|
-
*/
|
|
80
|
-
DynamicDataSourceManager.prototype.initializeSource = function (callableFunctions) {
|
|
81
|
-
this._assertNotDisposed();
|
|
82
|
-
this._assertInitialized();
|
|
83
|
-
if (this._src) {
|
|
84
|
-
throw new Error(strings.SourceAlreadyInitialized);
|
|
85
|
-
}
|
|
86
|
-
this._callableFunctions = callableFunctions;
|
|
87
|
-
this._src = this._buildSource(this._component);
|
|
88
|
-
this._dynamicDataManager.addSource(this._src);
|
|
89
|
-
if (!isExemptWebPartWithDynamicDataFromLazyLoadKSActivated()) {
|
|
90
|
-
this._component._containsDynamicDataSource = true;
|
|
91
|
-
}
|
|
92
|
-
this._logFeatureEntry('DynamicDataSourceInitialized', { sourceId: this._src.id });
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Notifies that this source has updated its properties.
|
|
96
|
-
*
|
|
97
|
-
* When invoked, it enables to broadcast the notification to all the consumers who have
|
|
98
|
-
* registered to this notification from this source.
|
|
99
|
-
*/
|
|
100
|
-
DynamicDataSourceManager.prototype.notifySourceChanged = function () {
|
|
101
|
-
this._assertNotDisposed();
|
|
102
|
-
this._assertInitialized();
|
|
103
|
-
this._assertSourceExists();
|
|
104
|
-
this._dynamicDataManager.notifySourceChanged(this._src.id);
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Notifies that this source has updated a specific property.
|
|
108
|
-
*
|
|
109
|
-
* When invoked, it enables to broadcast the notification to all the consumers who have
|
|
110
|
-
* registered to this notification from this source.
|
|
111
|
-
*
|
|
112
|
-
* @param propertyId - Id of the updated property in the source.
|
|
113
|
-
*/
|
|
114
|
-
DynamicDataSourceManager.prototype.notifyPropertyChanged = function (propertyId) {
|
|
115
|
-
Validate.isNonemptyString(propertyId, 'propertyId');
|
|
116
|
-
this._assertNotDisposed();
|
|
117
|
-
this._assertInitialized();
|
|
118
|
-
this._assertSourceExists();
|
|
119
|
-
this._dynamicDataManager.notifyPropertyChanged(this._src.id, propertyId);
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Updates the metadata of the Dynamic Data Source.
|
|
123
|
-
* It allows to update fields like title or description.
|
|
124
|
-
* Auto-generated fields like alias, componentId or instanceId cannot be updated.
|
|
125
|
-
*
|
|
126
|
-
* @param metadata - Partial of the metadata.
|
|
127
|
-
*/
|
|
128
|
-
DynamicDataSourceManager.prototype.updateMetadata = function (metadata) {
|
|
129
|
-
this._assertNotDisposed();
|
|
130
|
-
this._assertInitialized();
|
|
131
|
-
this._assertSourceExists();
|
|
132
|
-
Validate.isNotNullOrUndefined(metadata, 'metadata');
|
|
133
|
-
// Ensure that auto-generated properties are not updated.
|
|
134
|
-
metadata.alias = undefined;
|
|
135
|
-
metadata.componentId = undefined;
|
|
136
|
-
metadata.instanceId = undefined;
|
|
137
|
-
merge(this._src.metadata, metadata);
|
|
138
|
-
};
|
|
139
|
-
Object.defineProperty(DynamicDataSourceManager.prototype, "sourceId", {
|
|
140
|
-
/**
|
|
141
|
-
* Returns the Id of the current DataSource.
|
|
142
|
-
* If the component did not initialize as a dynamic data source, then it returns an empty string.
|
|
143
|
-
*/
|
|
144
|
-
get: function () {
|
|
145
|
-
return this._src ? this._src.id : '';
|
|
146
|
-
},
|
|
147
|
-
enumerable: false,
|
|
148
|
-
configurable: true
|
|
149
|
-
});
|
|
150
|
-
DynamicDataSourceManager.prototype._buildSource = function (component) {
|
|
151
|
-
// If the source is returning non-empty allowed events then, it has to define
|
|
152
|
-
// 'sendEvent' event handler as well.
|
|
153
|
-
if (this._callableFunctions.allowedEvents && this._callableFunctions.allowedEvents.length > 0) {
|
|
154
|
-
if (!this._callableFunctions.sendEvent) {
|
|
155
|
-
throw new Error(strings.NoSendEventWhenAllowedEventsIsNonEmpty);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
id: this._component._dynamicDataSourceId,
|
|
160
|
-
metadata: this._buildMetadata(component),
|
|
161
|
-
// Return a clone to ensure that the consumer doesn't modify values in the source
|
|
162
|
-
getPropertyDefinitions: this._getPropertyDefinitions.bind(this),
|
|
163
|
-
getPropertyValue: this._getPropertyValue.bind(this),
|
|
164
|
-
getAnnotatedPropertyValue: this._getAnnotatedPropertyValue.bind(this),
|
|
165
|
-
// async callbacks
|
|
166
|
-
getPropertyDefinitionsAsync: this._getPropertyDefinitionsAsync.bind(this),
|
|
167
|
-
getPropertyValueAsync: this._getPropertyValueAsync.bind(this),
|
|
168
|
-
getAnnotatedPropertyValueAsync: this._getAnnotatedPropertyValueAsync.bind(this),
|
|
169
|
-
allowedEventsAsync: this._allowedEventsAsync.bind(this),
|
|
170
|
-
sendEvent: this._sendEvent.bind(this)
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* This is the allowedEvents() that the DynamicDataSource actually exposes.
|
|
175
|
-
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
176
|
-
*/
|
|
177
|
-
DynamicDataSourceManager.prototype._allowedEvents = function () {
|
|
178
|
-
return this._callableFunctions.allowedEvents
|
|
179
|
-
? cloneDeep(this._callableFunctions.allowedEvents())
|
|
180
|
-
: undefined;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* This is the sendEvent() that the consumer invokes to send an event to the source, with data.
|
|
184
|
-
* @param eventName - Name of the event
|
|
185
|
-
* @param data - Associated data
|
|
186
|
-
*/
|
|
187
|
-
DynamicDataSourceManager.prototype._sendEvent = function (eventName, data) {
|
|
188
|
-
this._assertValidEvent(eventName);
|
|
189
|
-
this._callableFunctions.sendEvent(eventName, data);
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* This is the getPropertyDefinitions() that the DynamicDataSource actually exposes.
|
|
193
|
-
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
194
|
-
* This assumes that the component has dynamic data and has a controller.
|
|
195
|
-
*/
|
|
196
|
-
DynamicDataSourceManager.prototype._getPropertyDefinitions = function () {
|
|
197
|
-
return cloneDeep(this._callableFunctions.getPropertyDefinitions());
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* This is the getPropertyValue() that the DynamicDataSource actually exposes.
|
|
201
|
-
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
202
|
-
* This assumes that the component has the source initialized.
|
|
203
|
-
* If there is no value returned, it checks whether the propertyId is incorrect or the value is actually undefined.
|
|
204
|
-
*
|
|
205
|
-
* @remarks
|
|
206
|
-
* If the property value associated with the property id, is an array then the
|
|
207
|
-
* propertyId will have [*] notation appended at the end to support valid JSON Path notation.
|
|
208
|
-
* Hence when reading the property id, we account for that and extract the name accordingly.
|
|
209
|
-
*/
|
|
210
|
-
DynamicDataSourceManager.prototype._getPropertyValue = function (propertyId) {
|
|
211
|
-
Validate.isNotNullOrUndefined(propertyId, 'propertyId');
|
|
212
|
-
var qosMonitor = new _QosMonitor('DynamicDataSourceManager._getPropertyValue');
|
|
213
|
-
var paths = propertyId.split(DynamicDataProvider._jsonPathArrayRegex);
|
|
214
|
-
try {
|
|
215
|
-
var propertyValue = this._callableFunctions.getPropertyValue(paths.shift());
|
|
216
|
-
if (paths.length > 0) {
|
|
217
|
-
if (!isNaN(parseInt(paths[0], 10)) && Array.isArray(propertyValue)) {
|
|
218
|
-
propertyValue = propertyValue[paths[0]];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (propertyValue === undefined) {
|
|
222
|
-
if (
|
|
223
|
-
// This code can be slow if there is a many property definitions (O(n) for number of properties).
|
|
224
|
-
// It's done this way to prioritize memory consumption instead of CPU cycles as this is an optional feature,
|
|
225
|
-
// so if it's not used there is no memory footprint
|
|
226
|
-
this._callableFunctions.getPropertyDefinitions().filter(function (def) { return def.id === propertyId; }).length ===
|
|
227
|
-
0 &&
|
|
228
|
-
this._src // Check that the source exists to get its title
|
|
229
|
-
) {
|
|
230
|
-
throw new Error("Property \"".concat(propertyId, "\" doesn't exist in source \"").concat(this._src.metadata.title, "\""));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// DO NOT log propertyValue it can contain PII.
|
|
234
|
-
qosMonitor.writeSuccess(__assign(__assign({}, ((this._src && this._src.metadata) || {})), { sourceId: this._src && this._src.id, propertyId: propertyId }));
|
|
235
|
-
return cloneDeep(propertyValue);
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
qosMonitor.writeUnexpectedFailure('NoPropertyId', error, { propertyId: propertyId });
|
|
239
|
-
_TraceLogger.logErrorData({
|
|
240
|
-
source: this._logSource,
|
|
241
|
-
error: error
|
|
242
|
-
});
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Returns the real time value of the property.
|
|
248
|
-
*/
|
|
249
|
-
DynamicDataSourceManager.prototype._getPropertyDefinitionsAsync = function () {
|
|
250
|
-
return Promise.resolve(this._getPropertyDefinitions());
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Returns the real time value of the property.
|
|
254
|
-
* @param propertyId - property id for which the value is requested.
|
|
255
|
-
*/
|
|
256
|
-
DynamicDataSourceManager.prototype._getPropertyValueAsync = function (propertyId) {
|
|
257
|
-
return Promise.resolve(this._getPropertyValue(propertyId));
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* This is the allowedEvents() that the DynamicDataSource actually exposes.
|
|
261
|
-
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
262
|
-
*/
|
|
263
|
-
DynamicDataSourceManager.prototype._allowedEventsAsync = function () {
|
|
264
|
-
return Promise.resolve(this._allowedEvents());
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* This is the getPropertyValueSchema() that the DynamicDataSource actually exposes.
|
|
268
|
-
* It does a copy of the data to ensure the consumer doesn't modify the source.
|
|
269
|
-
* If the source doesn't provide the annotated value, then it falls back to whatever
|
|
270
|
-
* 'getPropertyValue' returns as the sample value and metadata would be undefined.
|
|
271
|
-
*
|
|
272
|
-
* @remarks
|
|
273
|
-
* If the property value associated with the property id, is an array then the
|
|
274
|
-
* propertyId will have [*] notation appended at the end to support valid JSON Path notation.
|
|
275
|
-
* Hence when reading the property id, we account for that and extract the name accordingly.
|
|
276
|
-
*
|
|
277
|
-
* @param propertyId - property id for which the schema is requested.
|
|
278
|
-
*/
|
|
279
|
-
DynamicDataSourceManager.prototype._getAnnotatedPropertyValue = function (propertyId) {
|
|
280
|
-
Validate.isNotNullOrUndefined(propertyId, 'propertyId');
|
|
281
|
-
var qosMonitor = new _QosMonitor('DynamicDataSourceManager._getAnnotatedPropertyValue');
|
|
282
|
-
var annotatedPropertyValue;
|
|
283
|
-
var getAnnotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue;
|
|
284
|
-
if (getAnnotatedPropertyValue) {
|
|
285
|
-
var paths = propertyId.split(DynamicDataProvider._jsonPathArrayRegex);
|
|
286
|
-
try {
|
|
287
|
-
annotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue(paths.shift());
|
|
288
|
-
if (paths.length > 0) {
|
|
289
|
-
if (!isNaN(parseInt(paths[0], 10)) && Array.isArray(annotatedPropertyValue)) {
|
|
290
|
-
annotatedPropertyValue = annotatedPropertyValue[paths[0]];
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
qosMonitor.writeSuccess(__assign(__assign({}, ((this._src && this._src.metadata) || {})), { sourceId: this._src && this._src.id, annotatedPropertyValue: annotatedPropertyValue, propertyId: propertyId }));
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
qosMonitor.writeExpectedFailure('NoAnnotatedPropertyValue', error, { annotatedPropertyValue: annotatedPropertyValue });
|
|
297
|
-
_TraceLogger.logErrorData({
|
|
298
|
-
source: this._logSource,
|
|
299
|
-
error: error
|
|
300
|
-
});
|
|
301
|
-
annotatedPropertyValue = undefined;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (!annotatedPropertyValue) {
|
|
305
|
-
annotatedPropertyValue = {
|
|
306
|
-
sampleValue: this._getPropertyValue(propertyId),
|
|
307
|
-
metadata: undefined
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
return annotatedPropertyValue;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Returns the annotated value of the property.
|
|
314
|
-
* @param propertyId - property id for which the value is requested.
|
|
315
|
-
*/
|
|
316
|
-
DynamicDataSourceManager.prototype._getAnnotatedPropertyValueAsync = function (propertyId) {
|
|
317
|
-
return Promise.resolve(this._getAnnotatedPropertyValue(propertyId));
|
|
318
|
-
};
|
|
319
|
-
DynamicDataSourceManager.prototype._buildMetadata = function (component) {
|
|
320
|
-
var metadata = {
|
|
321
|
-
title: component.manifest.alias,
|
|
322
|
-
alias: component.manifest.alias,
|
|
323
|
-
componentId: component.componentId,
|
|
324
|
-
instanceId: component.instanceId
|
|
325
|
-
};
|
|
326
|
-
// Web parts have properties "title" and "description" that should go to the source by default.
|
|
327
|
-
var componentWithMetadata = component;
|
|
328
|
-
if (componentWithMetadata.title) {
|
|
329
|
-
metadata.title = componentWithMetadata.title;
|
|
330
|
-
}
|
|
331
|
-
if (componentWithMetadata.description) {
|
|
332
|
-
metadata.description = componentWithMetadata.description;
|
|
333
|
-
}
|
|
334
|
-
return metadata;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Asserts if the event is a valid event on the source.
|
|
338
|
-
*
|
|
339
|
-
* Its an invalid event in two cases:
|
|
340
|
-
* 1. When '_allowedEvent()' api returns undefined
|
|
341
|
-
* 2. When the event name is not one of the allowed events on the source.
|
|
342
|
-
*
|
|
343
|
-
* @param eventName - Name of the event.
|
|
344
|
-
*/
|
|
345
|
-
DynamicDataSourceManager.prototype._assertValidEvent = function (eventName) {
|
|
346
|
-
if (!this._allowedEvents() || findIndex(this._allowedEvents(), { name: eventName }) === -1) {
|
|
347
|
-
throw new Error(Text.format(strings.InvalidEvent, eventName, this._src.metadata.title));
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
DynamicDataSourceManager.prototype._assertNotDisposed = function () {
|
|
351
|
-
if (this.isDisposed) {
|
|
352
|
-
throw new Error(strings.DynamicDataSourceManagerIsDisposed);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
DynamicDataSourceManager.prototype._assertInitialized = function () {
|
|
356
|
-
if (!this._isInitialized) {
|
|
357
|
-
throw new Error(strings.DynamicDataSourceManagerIsNotInitialized);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
DynamicDataSourceManager.prototype._assertSourceExists = function () {
|
|
361
|
-
if (!this._src) {
|
|
362
|
-
throw new Error(strings.DynamicDataSourceIsNotInitialized);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
/**
|
|
366
|
-
* Logs a feature event.
|
|
367
|
-
* @param logFeature - Name of the feature to log.
|
|
368
|
-
* @param contextualProps - Contextual log properties of the feature event.
|
|
369
|
-
*/
|
|
370
|
-
DynamicDataSourceManager.prototype._logFeatureEntry = function (logFeature, contextualProps) {
|
|
371
|
-
var isInternal = this._component.manifest.isInternal || false;
|
|
372
|
-
var logProperties = {
|
|
373
|
-
alias: this._component.manifest.alias,
|
|
374
|
-
isInternal: isInternal.toString()
|
|
375
|
-
};
|
|
376
|
-
var logEntry = new _LogEntry('DynamicDataSourceManager', logFeature, _LogType.Event, lodash.merge(logProperties, contextualProps));
|
|
377
|
-
_EngagementLogger.logEventWithLogEntry(logEntry);
|
|
378
|
-
};
|
|
379
|
-
return DynamicDataSourceManager;
|
|
380
|
-
}());
|
|
381
|
-
export default DynamicDataSourceManager;
|
|
382
|
-
//# sourceMappingURL=DynamicDataSourceManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicProperty.d.ts","sourceRoot":"","sources":["../src/DynamicProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,KAAK,kBAAkB,EAAwB,MAAM,4BAA4B,CAAC;AAE3F,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,MAAM,CAAE,YAAW,WAAW;IACjE;;;OAGG;IACH,gBAAuB,UAAU,EAAE,MAAM,CAAqB;IAC9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAEpE,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAC,CAAsB;IACxC,OAAO,CAAC,WAAW,CAAkB;IAErC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,CAAkB;IACrC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAA2B;IACnD;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAC,CAAkB;IAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAa;IAEvC;;;;OAIG;gBACgB,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI;IAuBvE;;;;OAIG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAmB5C;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAcpC;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;OAEG;IACI,OAAO,IAAI,IAAI;IAsBtB;;;;;;;;OAQG;IACI,MAAM,IAAI,MAAM;IAcvB;;;;;;OAMG;IACH,IAAW,SAAS,IAAI,MAAM,GAAG,SAAS,CAEzC;IAED;;;;;OAKG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED;;;;;;;;;;;;OAYG;IACI,WAAW,IAAI,MAAM,GAAG,SAAS;IAoBxC;;;;;;;;;;;;;OAaG;IACI,YAAY,IAAI,MAAM,EAAE;IAkB/B;;;OAGG;IACI,YAAY,IAAI,kBAAkB,GAAG,SAAS;IAcrD;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAW3C;;;;OAIG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAW7C;;OAEG;IACI,kBAAkB,IAAI,OAAO;IAIpC;;;;;OAKG;IACI,qBAAqB,IAAI,IAAI;IAOpC;;;;OAIG;IACI,YAAY,IAAI,MAAM;IAK7B;;;;;OAKG;IACI,YAAY,IAAI,MAAM;IAK7B;;;;;OAKG;IACI,gBAAgB,IAAI,MAAM;IAKjC;;;;;;;;;;;;;;;;;OAiBG;IAEI,UAAU,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO;IAQ9D;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,QAAQ;CAwBjB"}
|