@pnp/config-store
Advanced tools
Comparing version 2.1.0-beta8 to 2.1.0-beta9
@@ -6,3 +6,3 @@ import { mergeMaps, objectToMap, jsS } from "@pnp/common"; | ||
*/ | ||
var Settings = /** @class */ (function () { | ||
export class Settings { | ||
/** | ||
@@ -13,4 +13,3 @@ * Creates a new instance of the settings class | ||
*/ | ||
function Settings(_settings) { | ||
if (_settings === void 0) { _settings = new Map(); } | ||
constructor(_settings = new Map()) { | ||
this._settings = _settings; | ||
@@ -24,5 +23,5 @@ } | ||
*/ | ||
Settings.prototype.add = function (key, value) { | ||
add(key, value) { | ||
this._settings.set(key, value); | ||
}; | ||
} | ||
/** | ||
@@ -34,5 +33,5 @@ * Adds a JSON value to the collection as a string, you must use getJSON to rehydrate the object when read | ||
*/ | ||
Settings.prototype.addJSON = function (key, value) { | ||
addJSON(key, value) { | ||
this._settings.set(key, jsS(value)); | ||
}; | ||
} | ||
/** | ||
@@ -43,7 +42,6 @@ * Applies the supplied hash to the setting collection overwriting any existing value, or created new values | ||
*/ | ||
Settings.prototype.apply = function (hash) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
apply(hash) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
_this._settings = mergeMaps(_this._settings, objectToMap(hash)); | ||
this._settings = mergeMaps(this._settings, objectToMap(hash)); | ||
resolve(); | ||
@@ -55,3 +53,3 @@ } | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -62,11 +60,10 @@ * Loads configuration settings into the collection from the supplied provider and returns a Promise | ||
*/ | ||
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)); | ||
load(provider) { | ||
return new Promise((resolve, reject) => { | ||
provider.getConfiguration().then((value) => { | ||
this._settings = mergeMaps(this._settings, objectToMap(value)); | ||
resolve(); | ||
}).catch(reject); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -78,5 +75,5 @@ * Gets a value from the configuration | ||
*/ | ||
Settings.prototype.get = function (key) { | ||
get(key) { | ||
return this._settings.get(key) || null; | ||
}; | ||
} | ||
/** | ||
@@ -88,4 +85,4 @@ * Gets a JSON value, rehydrating the stored string to the original object | ||
*/ | ||
Settings.prototype.getJSON = function (key) { | ||
var o = this.get(key); | ||
getJSON(key) { | ||
const o = this.get(key); | ||
if (o === undefined || o === null) { | ||
@@ -95,6 +92,4 @@ return o; | ||
return JSON.parse(o); | ||
}; | ||
return Settings; | ||
}()); | ||
export { Settings }; | ||
} | ||
} | ||
//# sourceMappingURL=configuration.js.map |
{ | ||
"name": "@pnp/config-store", | ||
"version": "2.1.0-beta8", | ||
"version": "2.1.0-beta9", | ||
"description": "pnp - provides a way to manage configuration within your application", | ||
@@ -9,5 +9,5 @@ "main": "./index.js", | ||
"tslib": "2.0.3", | ||
"@pnp/common": "2.1.0-beta8", | ||
"@pnp/sp": "2.1.0-beta8", | ||
"@pnp/logging": "2.1.0-beta8" | ||
"@pnp/common": "2.1.0-beta9", | ||
"@pnp/sp": "2.1.0-beta9", | ||
"@pnp/logging": "2.1.0-beta9" | ||
}, | ||
@@ -14,0 +14,0 @@ "author": { |
@@ -6,3 +6,3 @@ import { PnPClientStorage } from "@pnp/common"; | ||
*/ | ||
var CachingConfigurationProvider = /** @class */ (function () { | ||
export default class CachingConfigurationProvider { | ||
/** | ||
@@ -15,3 +15,3 @@ * Creates a new caching configuration provider | ||
*/ | ||
function CachingConfigurationProvider(wrappedProvider, cacheKey, cacheStore) { | ||
constructor(wrappedProvider, cacheKey, cacheStore) { | ||
this.wrappedProvider = wrappedProvider; | ||
@@ -27,5 +27,5 @@ this.cacheKey = cacheKey; | ||
*/ | ||
CachingConfigurationProvider.prototype.getWrappedProvider = function () { | ||
getWrappedProvider() { | ||
return this.wrappedProvider; | ||
}; | ||
} | ||
/** | ||
@@ -36,4 +36,3 @@ * Loads the configuration values either from the cache or from the wrapped provider | ||
*/ | ||
CachingConfigurationProvider.prototype.getConfiguration = function () { | ||
var _this = this; | ||
getConfiguration() { | ||
// Cache not available, pass control to the wrapped provider | ||
@@ -43,11 +42,11 @@ if ((!this.store) || (!this.store.enabled)) { | ||
} | ||
return this.store.getOrPut(this.cacheKey, function () { | ||
return _this.wrappedProvider.getConfiguration().then(function (providedConfig) { | ||
_this.store.put(_this.cacheKey, providedConfig); | ||
return this.store.getOrPut(this.cacheKey, () => { | ||
return this.wrappedProvider.getConfiguration().then((providedConfig) => { | ||
this.store.put(this.cacheKey, providedConfig); | ||
return providedConfig; | ||
}); | ||
}); | ||
}; | ||
CachingConfigurationProvider.prototype.selectPnPCache = function () { | ||
var pnpCache = new PnPClientStorage(); | ||
} | ||
selectPnPCache() { | ||
const pnpCache = new PnPClientStorage(); | ||
if ((pnpCache.local) && (pnpCache.local.enabled)) { | ||
@@ -60,6 +59,4 @@ return pnpCache.local; | ||
throw Error("Cannot create a caching configuration provider since cache is not available."); | ||
}; | ||
return CachingConfigurationProvider; | ||
}()); | ||
export default CachingConfigurationProvider; | ||
} | ||
} | ||
//# sourceMappingURL=cachingConfigurationProvider.js.map |
@@ -8,3 +8,3 @@ import { default as CachingConfigurationProvider } from "./cachingConfigurationProvider.js"; | ||
*/ | ||
var SPListConfigurationProvider = /** @class */ (function () { | ||
export default class SPListConfigurationProvider { | ||
/** | ||
@@ -18,6 +18,3 @@ * Creates a new SharePoint list based configuration provider | ||
*/ | ||
function SPListConfigurationProvider(web, listTitle, keyFieldName, valueFieldName) { | ||
if (listTitle === void 0) { listTitle = "config"; } | ||
if (keyFieldName === void 0) { keyFieldName = "Title"; } | ||
if (valueFieldName === void 0) { valueFieldName = "Value"; } | ||
constructor(web, listTitle = "config", keyFieldName = "Title", valueFieldName = "Value") { | ||
this.web = web; | ||
@@ -33,10 +30,9 @@ this.listTitle = listTitle; | ||
*/ | ||
SPListConfigurationProvider.prototype.getConfiguration = function () { | ||
var _this = this; | ||
getConfiguration() { | ||
return this.web.lists.getByTitle(this.listTitle).items.select(this.keyFieldName, this.valueFieldName)() | ||
.then(function (data) { return data.reduce(function (c, item) { | ||
c[item[_this.keyFieldName]] = item[_this.valueFieldName]; | ||
.then((data) => data.reduce((c, item) => { | ||
c[item[this.keyFieldName]] = item[this.valueFieldName]; | ||
return c; | ||
}, {}); }); | ||
}; | ||
}, {})); | ||
} | ||
/** | ||
@@ -47,9 +43,6 @@ * Wraps the current provider in a cache enabled provider | ||
*/ | ||
SPListConfigurationProvider.prototype.asCaching = function (cacheKey) { | ||
if (cacheKey === void 0) { cacheKey = "pnp_configcache_splist_" + this.web.toUrl() + "+" + this.listTitle; } | ||
asCaching(cacheKey = `pnp_configcache_splist_${this.web.toUrl()}+${this.listTitle}`) { | ||
return new CachingConfigurationProvider(this, cacheKey); | ||
}; | ||
return SPListConfigurationProvider; | ||
}()); | ||
export default SPListConfigurationProvider; | ||
} | ||
} | ||
//# sourceMappingURL=spListConfigurationProvider.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23790
323
+ Added@pnp/common@2.1.0-beta9(transitive)
+ Added@pnp/logging@2.1.0-beta9(transitive)
+ Added@pnp/odata@2.1.0-beta9(transitive)
+ Added@pnp/sp@2.1.0-beta9(transitive)
- Removed@pnp/common@2.1.0-beta8(transitive)
- Removed@pnp/logging@2.1.0-beta8(transitive)
- Removed@pnp/odata@2.1.0-beta8(transitive)
- Removed@pnp/sp@2.1.0-beta8(transitive)
Updated@pnp/common@2.1.0-beta9
Updated@pnp/logging@2.1.0-beta9
Updated@pnp/sp@2.1.0-beta9