gd-sprest 7.4.4 → 7.4.6

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gets the current theme information for a classic page.
3
+ * @category Helper
4
+ */
5
+ export const getCurrentTheme: PromiseLike<{ [key: string]: string }>;
6
+ export interface IgetCurrentTheme {
7
+ (): PromiseLike<{ [key: string]: string }>;
8
+ }
@@ -4,6 +4,7 @@ export * from "./addScriptEditorWebPart";
4
4
  export * from "./copyPermissionLevel";
5
5
  export * from "./createContentType";
6
6
  export * from "./createDocSet";
7
+ export * from "./getCurrentTheme";
7
8
  export * from "./hasPermissions";
8
9
  export * from "./loadSPCore";
9
10
  export * from "./parse";
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentTheme = void 0;
4
+ var lib_1 = require("../../lib");
5
+ /**
6
+ * Determines if the user has permissions, based on the permission kind value
7
+ */
8
+ exports.getCurrentTheme = function () {
9
+ // Return a promise
10
+ return new Promise(function (resolve, reject) {
11
+ // Get the current theme info
12
+ lib_1.Web().Lists("Composed Looks").Items().query({
13
+ Filter: "DisplayOrder eq 0 or Title eq 'Office'",
14
+ OrderBy: ["DisplayOrder"],
15
+ Select: ["DisplayOrder", "MasterPageUrl", "ThemeUrl", "Title"]
16
+ }).execute(function (items) {
17
+ var currentItem = items.results[0];
18
+ var defaultItem = items.results[1];
19
+ // See if the current theme info exists
20
+ if (currentItem && currentItem["ThemeUrl"]) {
21
+ // Get the theme information
22
+ getThemeInfo(currentItem["ThemeUrl"].Url).then(resolve, reject);
23
+ }
24
+ else if (defaultItem && defaultItem["ThemeUrl"]) {
25
+ // Get the theme information
26
+ getThemeInfo(defaultItem["ThemeUrl"].Url).then(resolve, reject);
27
+ }
28
+ else {
29
+ // Unable to determine the theme
30
+ reject();
31
+ }
32
+ }, reject);
33
+ });
34
+ };
35
+ // Gets the theme information for a color palette
36
+ var getThemeInfo = function (url) {
37
+ if (url === void 0) { url = ""; }
38
+ // Return a promise
39
+ return new Promise(function (resolve, reject) {
40
+ var themeInfo = {};
41
+ // Ensure the url exists
42
+ if (url.length == 0) {
43
+ resolve(themeInfo);
44
+ return;
45
+ }
46
+ // Get the file item
47
+ lib_1.Site().RootWeb().getFileByUrl(url).execute(function (file) {
48
+ // Read the contents
49
+ file.content().execute(function (contents) {
50
+ // Convert the xml
51
+ var parser = new DOMParser();
52
+ var xmlDoc = parser.parseFromString(String.fromCharCode.apply(null, new Uint8Array(contents)), "text/xml");
53
+ // Get the colors and parse them
54
+ var colors = xmlDoc.getElementsByTagName("s:color");
55
+ for (var i = 0; i < colors.length; i++) {
56
+ var color = colors[i];
57
+ // Add the color information
58
+ themeInfo[color.getAttribute("name")] = color.getAttribute("value");
59
+ }
60
+ // Resolve the request
61
+ resolve(themeInfo);
62
+ }, reject);
63
+ }, reject);
64
+ });
65
+ };
@@ -6299,7 +6299,8 @@ exports.Mapper = {
6299
6299
  },
6300
6300
  getFileByUrl: {
6301
6301
  argNames: ["fileUrl"],
6302
- requestType: utils_1.RequestType.GetWithArgsValueOnly,
6302
+ name: "getFileByUrl(@url)?@url='[[fileUrl]]'",
6303
+ requestType: utils_1.RequestType.GetReplace,
6303
6304
  returnType: "SP.File"
6304
6305
  },
6305
6306
  getFileByWOPIFrameUrl: {
package/build/rest.js CHANGED
@@ -8,7 +8,7 @@ var sptypes_1 = require("./sptypes");
8
8
  * SharePoint REST Library
9
9
  */
10
10
  exports.$REST = {
11
- __ver: 7.44,
11
+ __ver: 7.46,
12
12
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
13
13
  Apps: Lib.Apps,
14
14
  ContextInfo: Lib.ContextInfo,
@@ -4271,6 +4271,7 @@ declare module 'gd-sprest/helper/methods' {
4271
4271
  export * from "gd-sprest/helper/methods/copyPermissionLevel";
4272
4272
  export * from "gd-sprest/helper/methods/createContentType";
4273
4273
  export * from "gd-sprest/helper/methods/createDocSet";
4274
+ export * from "gd-sprest/helper/methods/getCurrentTheme";
4274
4275
  export * from "gd-sprest/helper/methods/hasPermissions";
4275
4276
  export * from "gd-sprest/helper/methods/loadSPCore";
4276
4277
  export * from "gd-sprest/helper/methods/parse";
@@ -6626,6 +6627,17 @@ declare module 'gd-sprest/helper/methods/createDocSet' {
6626
6627
  }
6627
6628
  }
6628
6629
 
6630
+ declare module 'gd-sprest/helper/methods/getCurrentTheme' {
6631
+ /**
6632
+ * Gets the current theme information for a classic page.
6633
+ * @category Helper
6634
+ */
6635
+ export const getCurrentTheme: PromiseLike<{ [key: string]: string }>;
6636
+ export interface IgetCurrentTheme {
6637
+ (): PromiseLike<{ [key: string]: string }>;
6638
+ }
6639
+ }
6640
+
6629
6641
  declare module 'gd-sprest/helper/methods/hasPermissions' {
6630
6642
  /**
6631
6643
  * Determines if the user has permissions, based on the permission kind value