gd-sprest 8.3.2 → 8.3.3
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/@types/helper/methods/setWebProperty.d.ts +1 -1
- package/build/helper/methods/setWebProperty.js +103 -12
- package/build/mapper/def.js +18 -1
- package/build/rest.js +1 -1
- package/build/utils/methodInfo.js +3 -2
- package/build/utils/targetInfo.js +8 -1
- package/dist/gd-sprest.d.ts +1 -1
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
|
@@ -1,23 +1,114 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setWebProperty = void 0;
|
|
4
|
+
var contextInfo_1 = require("../../lib/contextInfo");
|
|
5
|
+
var web_1 = require("../../lib/web");
|
|
4
6
|
/**
|
|
5
7
|
* Adds or updates a key/value pair for a web's property bag
|
|
6
8
|
* This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
|
|
7
9
|
*/
|
|
8
|
-
exports.setWebProperty = function (key, value, siteUrl) {
|
|
10
|
+
exports.setWebProperty = function (key, value, indexed, siteUrl) {
|
|
11
|
+
var encodedKey = "vti_x005f_indexedpropertykeys";
|
|
12
|
+
var decodedKey = "vti_indexedpropertykeys";
|
|
9
13
|
// Return a promise
|
|
10
14
|
return new Promise(function (resolve, reject) {
|
|
11
|
-
//
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
// Gets the request digest value of the web
|
|
16
|
+
var getRequestDigest = function () {
|
|
17
|
+
// Return a promise
|
|
18
|
+
return new Promise(function (resolve, reject) {
|
|
19
|
+
// See if the site url exists
|
|
20
|
+
if (siteUrl) {
|
|
21
|
+
contextInfo_1.ContextInfo.getWeb(siteUrl).execute(function (context) {
|
|
22
|
+
// Resolve the request
|
|
23
|
+
resolve(context.GetContextWebInformation.FormDigestValue);
|
|
24
|
+
}, reject);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Resolve the request w/ the default digest value
|
|
28
|
+
resolve(contextInfo_1.ContextInfo.formDigestValue);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
// Get the request digest for the web
|
|
33
|
+
getRequestDigest().then(function (requestDigest) {
|
|
34
|
+
// Convert the key to a base64 string
|
|
35
|
+
var idxKeyValue = "";
|
|
36
|
+
for (var i = 0; i < key.length; i++) {
|
|
37
|
+
idxKeyValue += key[i] + "\x00";
|
|
38
|
+
}
|
|
39
|
+
idxKeyValue = btoa(idxKeyValue);
|
|
40
|
+
// See if a value exists
|
|
41
|
+
if (value) {
|
|
42
|
+
// Add the property
|
|
43
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().add(key, value).execute(function () {
|
|
44
|
+
// See if we are indexing the property
|
|
45
|
+
if (indexed) {
|
|
46
|
+
// Get the properties
|
|
47
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().execute(function (propBag) {
|
|
48
|
+
// See if the indexed keys doesn't contain this value
|
|
49
|
+
var idxKeys = propBag[encodedKey] || "";
|
|
50
|
+
if (idxKeys.indexOf(idxKeyValue) < 0) {
|
|
51
|
+
// Append the value
|
|
52
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().add(decodedKey, idxKeys + idxKeyValue + "|").execute(function () {
|
|
53
|
+
// Resolve the request
|
|
54
|
+
resolve();
|
|
55
|
+
}, function () {
|
|
56
|
+
// Reject the request
|
|
57
|
+
reject("Error setting the indexed keys property.");
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Resolve the request
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Resolve the request
|
|
68
|
+
resolve();
|
|
69
|
+
}
|
|
70
|
+
}, function () {
|
|
71
|
+
// Reject the request
|
|
72
|
+
reject("Error adding the web property.");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Remove the property
|
|
77
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().remove(key).execute(function () {
|
|
78
|
+
// See if we are indexing the property
|
|
79
|
+
if (indexed) {
|
|
80
|
+
// Get the properties
|
|
81
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().execute(function (propBag) {
|
|
82
|
+
// See if the indexed keys contains the value
|
|
83
|
+
var idxKeys = propBag[encodedKey] || "";
|
|
84
|
+
if (idxKeys.indexOf(idxKeyValue) >= 0) {
|
|
85
|
+
// Remove the value
|
|
86
|
+
web_1.Web(siteUrl, { requestDigest: requestDigest }).AllProperties().add(decodedKey, idxKeys.replace(idxKeyValue + "|", "")).execute(function () {
|
|
87
|
+
// Resolve the request
|
|
88
|
+
resolve();
|
|
89
|
+
}, function () {
|
|
90
|
+
// Reject the request
|
|
91
|
+
reject("Error setting the indexed keys property.");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Resolve the request
|
|
96
|
+
resolve();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Resolve the request
|
|
102
|
+
resolve();
|
|
103
|
+
}
|
|
104
|
+
}, function () {
|
|
105
|
+
// Reject the request
|
|
106
|
+
reject("Error removing the web property.");
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}, function () {
|
|
110
|
+
// Reject the request
|
|
111
|
+
reject("Unable to get the context of this web.");
|
|
112
|
+
});
|
|
22
113
|
});
|
|
23
114
|
};
|
package/build/mapper/def.js
CHANGED
|
@@ -5358,6 +5358,23 @@ exports.Mapper = {
|
|
|
5358
5358
|
"SP.OrganizationNews": {
|
|
5359
5359
|
sitesReference: {}
|
|
5360
5360
|
},
|
|
5361
|
+
"SP.PropertyValues.Collection": {
|
|
5362
|
+
add: {
|
|
5363
|
+
argNames: ["key", "value"],
|
|
5364
|
+
name: "_vti_bin/client.svc/ProcessQuery",
|
|
5365
|
+
replaceEndpointFl: true,
|
|
5366
|
+
requestType: utils_1.RequestType.PostReplace,
|
|
5367
|
+
data: "<Request xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\"Javascript Library\">\n <Actions>\n <ObjectPath Id=\"1\" ObjectPathId=\"0\" />\n <ObjectPath Id=\"3\" ObjectPathId=\"2\" />\n <ObjectPath Id=\"5\" ObjectPathId=\"4\" />\n <Method Name=\"SetFieldValue\" Id=\"6\" ObjectPathId=\"4\">\n <Parameters>\n <Parameter Type=\"String\">[[key]]</Parameter>\n <Parameter Type=\"String\">[[value]]</Parameter>\n </Parameters>\n </Method>\n <Query Id=\"7\" ObjectPathId=\"2\">\n <Query SelectAllProperties=\"true\">\n <Properties />\n </Query>\n </Query>\n <Method Name=\"Update\" Id=\"8\" ObjectPathId=\"2\" />\n </Actions>\n <ObjectPaths>\n <StaticProperty Id=\"0\" TypeId=\"{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}\" Name=\"Current\" />\n <Property Id=\"2\" ParentId=\"0\" Name=\"Web\" />\n <Property Id=\"4\" ParentId=\"2\" Name=\"AllProperties\" />\n </ObjectPaths>\n </Request>"
|
|
5368
|
+
},
|
|
5369
|
+
query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
|
|
5370
|
+
remove: {
|
|
5371
|
+
argNames: ["key"],
|
|
5372
|
+
name: "_vti_bin/client.svc/ProcessQuery",
|
|
5373
|
+
replaceEndpointFl: true,
|
|
5374
|
+
requestType: utils_1.RequestType.PostReplace,
|
|
5375
|
+
data: "<Request xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\"Javascript Library\">\n <Actions>\n <ObjectPath Id=\"1\" ObjectPathId=\"0\" />\n <ObjectPath Id=\"3\" ObjectPathId=\"2\" />\n <ObjectPath Id=\"5\" ObjectPathId=\"4\" />\n <Method Name=\"SetFieldValue\" Id=\"6\" ObjectPathId=\"4\">\n <Parameters>\n <Parameter Type=\"String\">[[key]]</Parameter>\n <Parameter Type=\"Null\" />\n </Parameters>\n </Method>\n <Query Id=\"7\" ObjectPathId=\"2\">\n <Query SelectAllProperties=\"true\">\n <Properties />\n </Query>\n </Query>\n <Method Name=\"Update\" Id=\"8\" ObjectPathId=\"2\" />\n </Actions>\n <ObjectPaths>\n <StaticProperty Id=\"0\" TypeId=\"{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}\" Name=\"Current\" />\n <Property Id=\"2\" ParentId=\"0\" Name=\"Web\" />\n <Property Id=\"4\" ParentId=\"2\" Name=\"AllProperties\" />\n </ObjectPaths>\n </Request>"
|
|
5376
|
+
},
|
|
5377
|
+
},
|
|
5361
5378
|
"SP.Publishing.AnnouncementsController": {
|
|
5362
5379
|
active: {},
|
|
5363
5380
|
channel: {},
|
|
@@ -7470,7 +7487,7 @@ exports.Mapper = {
|
|
|
7470
7487
|
},
|
|
7471
7488
|
"SP.Web": {
|
|
7472
7489
|
properties: [
|
|
7473
|
-
"AllProperties", "AppTiles", "AssociatedMemberGroup|SP.Group", "AssociatedOwnerGroup|SP.Group",
|
|
7490
|
+
"AllProperties|SP.PropertyValues.Collection", "AppTiles", "AssociatedMemberGroup|SP.Group", "AssociatedOwnerGroup|SP.Group",
|
|
7474
7491
|
"AssociatedVisitorGroup|SP.Group", "Author|SP.User", "AvailableContentTypes|SP.ContentType.Collection", "AvailableFields|SP.Field.Collection",
|
|
7475
7492
|
"ClientWebParts", "ContentTypes|SP.ContentType.Collection|('[Name]')|SP.ContentType", "CurrentUser|SP.User", "DataLeakagePreventionStatusInfo",
|
|
7476
7493
|
"DescriptionResource", "EffectiveBasePermissions", "EventReceivers|SP.EventReceiverDefinition.Collection|('[Name]')|SP.EventReceiverDefinition",
|
package/build/rest.js
CHANGED
|
@@ -65,13 +65,14 @@ var MethodInfo = /** @class */ (function () {
|
|
|
65
65
|
case _1.RequestType.Delete:
|
|
66
66
|
case _1.RequestType.Post:
|
|
67
67
|
case _1.RequestType.PostBodyNoArgs:
|
|
68
|
+
case _1.RequestType.PostReplace:
|
|
69
|
+
case _1.RequestType.PostReplaceWithData:
|
|
68
70
|
case _1.RequestType.PostWithArgs:
|
|
69
71
|
case _1.RequestType.PostWithArgsAndData:
|
|
70
72
|
case _1.RequestType.PostWithArgsInBody:
|
|
71
73
|
case _1.RequestType.PostWithArgsInQS:
|
|
72
74
|
case _1.RequestType.PostWithArgsInQSAsVar:
|
|
73
75
|
case _1.RequestType.PostWithArgsValueOnly:
|
|
74
|
-
case _1.RequestType.PostReplace:
|
|
75
76
|
return "POST";
|
|
76
77
|
default:
|
|
77
78
|
return "GET";
|
|
@@ -176,7 +177,7 @@ var MethodInfo = /** @class */ (function () {
|
|
|
176
177
|
// Replace \\" with \\\\"
|
|
177
178
|
var methodData = this.methodInfo.data.replace(/\\"/g, '\\\\"');
|
|
178
179
|
// Set the method data
|
|
179
|
-
this.methodData = JSON.parse(methodData);
|
|
180
|
+
this.methodData = typeof (methodData) === "string" ? methodData : JSON.parse(methodData);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
// See if argument values exist
|
|
@@ -96,7 +96,14 @@ var TargetInfo = /** @class */ (function () {
|
|
|
96
96
|
var endpoint = this.props.endpoint ? "/" + this.props.endpoint : "";
|
|
97
97
|
var hostUrl = TargetInfo.getQueryStringValue("SPHostUrl");
|
|
98
98
|
var qs = (endpoint.indexOf("?") === -1 ? "?" : "&") + "@target='{{Target}}'";
|
|
99
|
-
var template = "{{Url}}"
|
|
99
|
+
var template = "{{Url}}";
|
|
100
|
+
// See if the template is targeting the _vti_bin
|
|
101
|
+
if (endpoint.indexOf("_vti_bin") >= 0) {
|
|
102
|
+
template += "/{{EndPoint}}{{TargetUrl}}";
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
template += this.props.endpoint ? "/_api/{{EndPoint}}{{TargetUrl}}" : "";
|
|
106
|
+
}
|
|
100
107
|
// See if we are defaulting the url for the app web
|
|
101
108
|
if (lib_1.ContextInfo.existsFl && lib_1.ContextInfo.window.$REST && lib_1.ContextInfo.window.$REST.DefaultRequestToHostFl && lib_1.ContextInfo.isAppWeb && !this.props.overrideDefaultRequestToHostFl && this.props.url == null) {
|
|
102
109
|
// Default the url to the host web
|
package/dist/gd-sprest.d.ts
CHANGED
|
@@ -7000,7 +7000,7 @@ declare module 'gd-sprest/helper/methods/setWebProperty' {
|
|
|
7000
7000
|
*/
|
|
7001
7001
|
export const setWebProperty: IsetWebProperty;
|
|
7002
7002
|
export interface IsetWebProperty {
|
|
7003
|
-
(key: string, value: string, siteUrl?: string): PromiseLike<void>;
|
|
7003
|
+
(key: string, value: string, indexed?: boolean, siteUrl?: string): PromiseLike<void>;
|
|
7004
7004
|
}
|
|
7005
7005
|
}
|
|
7006
7006
|
|