gd-sprest 8.2.9 → 8.3.0

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.
@@ -11,4 +11,5 @@ export * from "./parse";
11
11
  export * from "./request";
12
12
  export * from "./setContentTypeFields";
13
13
  export * from "./setGroupOwner";
14
+ export * from "./setWebProperty";
14
15
  export * from "./stringify";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Adds or updates a key/value pair for a web's property bag
3
+ * This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
4
+ * @param key The property key.
5
+ * @param value The property value.
6
+ * @param siteUrl The site url to apply the property to. If blank, it will default to the current web.
7
+ */
8
+ export const setWebProperty: IsetWebProperty;
9
+ export interface IsetWebProperty {
10
+ (key: string, value: string, siteUrl?: string): PromiseLike<void>;
11
+ }
@@ -23,4 +23,5 @@ __exportStar(require("./parse"), exports);
23
23
  __exportStar(require("./request"), exports);
24
24
  __exportStar(require("./setContentTypeFields"), exports);
25
25
  __exportStar(require("./setGroupOwner"), exports);
26
+ __exportStar(require("./setWebProperty"), exports);
26
27
  __exportStar(require("./stringify"), exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setWebProperty = void 0;
4
+ /**
5
+ * Adds or updates a key/value pair for a web's property bag
6
+ * This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
7
+ */
8
+ exports.setWebProperty = function (key, value, siteUrl) {
9
+ // Return a promise
10
+ return new Promise(function (resolve, reject) {
11
+ // Get the site groups
12
+ var context = siteUrl ? new SP.ClientContext(siteUrl) : SP.ClientContext.get_current();
13
+ var web = context.get_web();
14
+ var allProps = web.get_allProperties();
15
+ // Set the property
16
+ allProps.set_item(key, value);
17
+ // Save the changes
18
+ context.load(web);
19
+ web.update();
20
+ // Execute the request
21
+ context.executeQueryAsync(resolve, reject);
22
+ });
23
+ };
package/build/rest.js CHANGED
@@ -9,7 +9,7 @@ var sptypes_1 = require("./sptypes");
9
9
  * SharePoint REST Library
10
10
  */
11
11
  exports.$REST = {
12
- __ver: 8.29,
12
+ __ver: 8.30,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -4425,6 +4425,7 @@ declare module 'gd-sprest/helper/methods' {
4425
4425
  export * from "gd-sprest/helper/methods/request";
4426
4426
  export * from "gd-sprest/helper/methods/setContentTypeFields";
4427
4427
  export * from "gd-sprest/helper/methods/setGroupOwner";
4428
+ export * from "gd-sprest/helper/methods/setWebProperty";
4428
4429
  export * from "gd-sprest/helper/methods/stringify";
4429
4430
  }
4430
4431
 
@@ -6989,6 +6990,20 @@ declare module 'gd-sprest/helper/methods/setGroupOwner' {
6989
6990
  }
6990
6991
  }
6991
6992
 
6993
+ declare module 'gd-sprest/helper/methods/setWebProperty' {
6994
+ /**
6995
+ * Adds or updates a key/value pair for a web's property bag
6996
+ * This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
6997
+ * @param key The property key.
6998
+ * @param value The property value.
6999
+ * @param siteUrl The site url to apply the property to. If blank, it will default to the current web.
7000
+ */
7001
+ export const setWebProperty: IsetWebProperty;
7002
+ export interface IsetWebProperty {
7003
+ (key: string, value: string, siteUrl?: string): PromiseLike<void>;
7004
+ }
7005
+ }
7006
+
6992
7007
  declare module 'gd-sprest/helper/methods/stringify' {
6993
7008
  /**
6994
7009
  * Convert an object to a string