@pnp/config-store
Advanced tools
+1
-4
@@ -1,5 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./src/configstore"), exports); | ||
| export * from "./src/configstore"; | ||
| //# sourceMappingURL=index.js.map |
+4
-4
| { | ||
| "name": "@pnp/config-store", | ||
| "version": "2.0.0-1", | ||
| "version": "2.0.0-2", | ||
| "description": "pnp - provides a way to manage configuration within your application", | ||
@@ -11,5 +11,5 @@ "main": "./index.js", | ||
| "peerDependencies": { | ||
| "@pnp/common": "2.0.0-1", | ||
| "@pnp/sp": "2.0.0-1", | ||
| "@pnp/logging": "2.0.0-1" | ||
| "@pnp/common": "2.0.0-2", | ||
| "@pnp/sp": "2.0.0-2", | ||
| "@pnp/logging": "2.0.0-2" | ||
| }, | ||
@@ -16,0 +16,0 @@ "author": { |
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./configuration"), exports); | ||
| tslib_1.__exportStar(require("./providers/index"), exports); | ||
| export * from "./configuration"; | ||
| export * from "./providers/index"; | ||
| //# sourceMappingURL=configstore.js.map |
+28
-26
@@ -1,4 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const common_1 = require("@pnp/common"); | ||
| import { mergeMaps, objectToMap, jsS } from "@pnp/common"; | ||
| /** | ||
@@ -8,3 +6,3 @@ * Class used to manage the current application settings | ||
| */ | ||
| class Settings { | ||
| var Settings = /** @class */ (function () { | ||
| /** | ||
@@ -15,3 +13,4 @@ * Creates a new instance of the settings class | ||
| */ | ||
| constructor(_settings = new Map()) { | ||
| function Settings(_settings) { | ||
| if (_settings === void 0) { _settings = new Map(); } | ||
| this._settings = _settings; | ||
@@ -25,5 +24,5 @@ } | ||
| */ | ||
| add(key, value) { | ||
| Settings.prototype.add = function (key, value) { | ||
| this._settings.set(key, value); | ||
| } | ||
| }; | ||
| /** | ||
@@ -35,5 +34,5 @@ * Adds a JSON value to the collection as a string, you must use getJSON to rehydrate the object when read | ||
| */ | ||
| addJSON(key, value) { | ||
| this._settings.set(key, common_1.jsS(value)); | ||
| } | ||
| Settings.prototype.addJSON = function (key, value) { | ||
| this._settings.set(key, jsS(value)); | ||
| }; | ||
| /** | ||
@@ -44,6 +43,7 @@ * Applies the supplied hash to the setting collection overwriting any existing value, or created new values | ||
| */ | ||
| apply(hash) { | ||
| return new Promise((resolve, reject) => { | ||
| Settings.prototype.apply = function (hash) { | ||
| var _this = this; | ||
| return new Promise(function (resolve, reject) { | ||
| try { | ||
| this._settings = common_1.mergeMaps(this._settings, common_1.objectToMap(hash)); | ||
| _this._settings = mergeMaps(_this._settings, objectToMap(hash)); | ||
| resolve(); | ||
@@ -55,3 +55,3 @@ } | ||
| }); | ||
| } | ||
| }; | ||
| /** | ||
@@ -62,10 +62,11 @@ * Loads configuration settings into the collection from the supplied provider and returns a Promise | ||
| */ | ||
| load(provider) { | ||
| return new Promise((resolve, reject) => { | ||
| provider.getConfiguration().then((value) => { | ||
| this._settings = common_1.mergeMaps(this._settings, common_1.objectToMap(value)); | ||
| Settings.prototype.load = function (provider) { | ||
| var _this = this; | ||
| return new Promise(function (resolve, reject) { | ||
| provider.getConfiguration().then(function (value) { | ||
| _this._settings = mergeMaps(_this._settings, objectToMap(value)); | ||
| resolve(); | ||
| }).catch(reject); | ||
| }); | ||
| } | ||
| }; | ||
| /** | ||
@@ -77,5 +78,5 @@ * Gets a value from the configuration | ||
| */ | ||
| get(key) { | ||
| Settings.prototype.get = function (key) { | ||
| return this._settings.get(key) || null; | ||
| } | ||
| }; | ||
| /** | ||
@@ -87,4 +88,4 @@ * Gets a JSON value, rehydrating the stored string to the original object | ||
| */ | ||
| getJSON(key) { | ||
| const o = this.get(key); | ||
| Settings.prototype.getJSON = function (key) { | ||
| var o = this.get(key); | ||
| if (o === undefined || o === null) { | ||
@@ -94,5 +95,6 @@ return o; | ||
| return JSON.parse(o); | ||
| } | ||
| } | ||
| exports.Settings = Settings; | ||
| }; | ||
| return Settings; | ||
| }()); | ||
| export { Settings }; | ||
| //# sourceMappingURL=configuration.js.map |
@@ -1,4 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const common_1 = require("@pnp/common"); | ||
| import { PnPClientStorage } from "@pnp/common"; | ||
| /** | ||
@@ -8,3 +6,3 @@ * A caching provider which can wrap other non-caching providers | ||
| */ | ||
| class CachingConfigurationProvider { | ||
| var CachingConfigurationProvider = /** @class */ (function () { | ||
| /** | ||
@@ -17,3 +15,3 @@ * Creates a new caching configuration provider | ||
| */ | ||
| constructor(wrappedProvider, cacheKey, cacheStore) { | ||
| function CachingConfigurationProvider(wrappedProvider, cacheKey, cacheStore) { | ||
| this.wrappedProvider = wrappedProvider; | ||
@@ -29,5 +27,5 @@ this.cacheKey = cacheKey; | ||
| */ | ||
| getWrappedProvider() { | ||
| CachingConfigurationProvider.prototype.getWrappedProvider = function () { | ||
| return this.wrappedProvider; | ||
| } | ||
| }; | ||
| /** | ||
@@ -38,3 +36,4 @@ * Loads the configuration values either from the cache or from the wrapped provider | ||
| */ | ||
| getConfiguration() { | ||
| CachingConfigurationProvider.prototype.getConfiguration = function () { | ||
| var _this = this; | ||
| // Cache not available, pass control to the wrapped provider | ||
@@ -44,11 +43,11 @@ if ((!this.store) || (!this.store.enabled)) { | ||
| } | ||
| return this.store.getOrPut(this.cacheKey, () => { | ||
| return this.wrappedProvider.getConfiguration().then((providedConfig) => { | ||
| this.store.put(this.cacheKey, providedConfig); | ||
| return this.store.getOrPut(this.cacheKey, function () { | ||
| return _this.wrappedProvider.getConfiguration().then(function (providedConfig) { | ||
| _this.store.put(_this.cacheKey, providedConfig); | ||
| return providedConfig; | ||
| }); | ||
| }); | ||
| } | ||
| selectPnPCache() { | ||
| const pnpCache = new common_1.PnPClientStorage(); | ||
| }; | ||
| CachingConfigurationProvider.prototype.selectPnPCache = function () { | ||
| var pnpCache = new PnPClientStorage(); | ||
| if ((pnpCache.local) && (pnpCache.local.enabled)) { | ||
@@ -61,5 +60,6 @@ return pnpCache.local; | ||
| throw Error("Cannot create a caching configuration provider since cache is not available."); | ||
| } | ||
| } | ||
| exports.default = CachingConfigurationProvider; | ||
| }; | ||
| return CachingConfigurationProvider; | ||
| }()); | ||
| export default CachingConfigurationProvider; | ||
| //# sourceMappingURL=cachingConfigurationProvider.js.map |
@@ -1,7 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var cachingConfigurationProvider_1 = require("./cachingConfigurationProvider"); | ||
| exports.CachingConfigurationProvider = cachingConfigurationProvider_1.default; | ||
| var spListConfigurationProvider_1 = require("./spListConfigurationProvider"); | ||
| exports.SPListConfigurationProvider = spListConfigurationProvider_1.default; | ||
| export { default as CachingConfigurationProvider, } from "./cachingConfigurationProvider"; | ||
| export { default as SPListConfigurationProvider, } from "./spListConfigurationProvider"; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const cachingConfigurationProvider_1 = require("./cachingConfigurationProvider"); | ||
| import { default as CachingConfigurationProvider } from "./cachingConfigurationProvider"; | ||
| /** | ||
@@ -8,3 +6,3 @@ * A configuration provider which loads configuration values from a SharePoint list | ||
| */ | ||
| class SPListConfigurationProvider { | ||
| var SPListConfigurationProvider = /** @class */ (function () { | ||
| /** | ||
@@ -18,3 +16,6 @@ * Creates a new SharePoint list based configuration provider | ||
| */ | ||
| constructor(web, listTitle = "config", keyFieldName = "Title", valueFieldName = "Value") { | ||
| function SPListConfigurationProvider(web, listTitle, keyFieldName, valueFieldName) { | ||
| if (listTitle === void 0) { listTitle = "config"; } | ||
| if (keyFieldName === void 0) { keyFieldName = "Title"; } | ||
| if (valueFieldName === void 0) { valueFieldName = "Value"; } | ||
| this.web = web; | ||
@@ -30,9 +31,10 @@ this.listTitle = listTitle; | ||
| */ | ||
| getConfiguration() { | ||
| SPListConfigurationProvider.prototype.getConfiguration = function () { | ||
| var _this = this; | ||
| return this.web.lists.getByTitle(this.listTitle).items.select(this.keyFieldName, this.valueFieldName)() | ||
| .then((data) => data.reduce((c, item) => { | ||
| c[item[this.keyFieldName]] = item[this.valueFieldName]; | ||
| .then(function (data) { return data.reduce(function (c, item) { | ||
| c[item[_this.keyFieldName]] = item[_this.valueFieldName]; | ||
| return c; | ||
| }, {})); | ||
| } | ||
| }, {}); }); | ||
| }; | ||
| /** | ||
@@ -43,7 +45,9 @@ * Wraps the current provider in a cache enabled provider | ||
| */ | ||
| asCaching(cacheKey = `pnp_configcache_splist_${this.web.toUrl()}+${this.listTitle}`) { | ||
| return new cachingConfigurationProvider_1.default(this, cacheKey); | ||
| } | ||
| } | ||
| exports.default = SPListConfigurationProvider; | ||
| SPListConfigurationProvider.prototype.asCaching = function (cacheKey) { | ||
| if (cacheKey === void 0) { cacheKey = "pnp_configcache_splist_" + this.web.toUrl() + "+" + this.listTitle; } | ||
| return new CachingConfigurationProvider(this, cacheKey); | ||
| }; | ||
| return SPListConfigurationProvider; | ||
| }()); | ||
| export default SPListConfigurationProvider; | ||
| //# sourceMappingURL=spListConfigurationProvider.js.map |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
17736
1.94%336
-1.18%