sp-js-provisioning 1.3.1-1 → 1.3.1-2
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.
|
@@ -25,7 +25,6 @@ export declare class ContentTypes extends HandlerBase {
|
|
|
25
25
|
/**
|
|
26
26
|
* Provision a content type
|
|
27
27
|
*
|
|
28
|
-
* @param web - The web
|
|
29
28
|
* @param contentType - Content type
|
|
30
29
|
*/
|
|
31
30
|
private processContentType;
|
|
@@ -43,4 +42,5 @@ export declare class ContentTypes extends HandlerBase {
|
|
|
43
42
|
* @param spContentType - SP content type
|
|
44
43
|
*/
|
|
45
44
|
private processContentTypeFieldRefs;
|
|
45
|
+
private _initContext;
|
|
46
46
|
}
|
|
@@ -69,38 +69,21 @@ var ContentTypes = /** @class */ (function (_super) {
|
|
|
69
69
|
*/
|
|
70
70
|
ContentTypes.prototype.ProvisionObjects = function (web, contentTypes, context) {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var _a,
|
|
72
|
+
var _a, error_1;
|
|
73
73
|
var _this = this;
|
|
74
|
-
return __generator(this, function (
|
|
75
|
-
switch (
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
76
|
case 0:
|
|
77
77
|
_a = this;
|
|
78
78
|
return [4 /*yield*/, initSpfxJsom(context.web.ServerRelativeUrl)];
|
|
79
79
|
case 1:
|
|
80
|
-
_a.jsomContext = (
|
|
80
|
+
_a.jsomContext = (_b.sent()).jsomContext;
|
|
81
81
|
this.context = context;
|
|
82
82
|
_super.prototype.scope_started.call(this);
|
|
83
|
-
|
|
83
|
+
_b.label = 2;
|
|
84
84
|
case 2:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return [4 /*yield*/, web.contentTypes
|
|
88
|
-
.select('Id', 'Name', 'FieldLinks')
|
|
89
|
-
.expand('FieldLinks')()];
|
|
90
|
-
case 3:
|
|
91
|
-
_b.contentTypes = (_c.sent()).reduce(function (object, contentType) {
|
|
92
|
-
object[contentType.Name] = {
|
|
93
|
-
ID: contentType.Id.StringValue,
|
|
94
|
-
Name: contentType.Name,
|
|
95
|
-
FieldRefs: contentType['FieldLinks'].map(function (fieldLink) { return ({
|
|
96
|
-
ID: fieldLink.Id,
|
|
97
|
-
Name: fieldLink.Name,
|
|
98
|
-
Required: fieldLink.Required,
|
|
99
|
-
Hidden: fieldLink.Hidden
|
|
100
|
-
}); })
|
|
101
|
-
};
|
|
102
|
-
return object;
|
|
103
|
-
}, {});
|
|
85
|
+
_b.trys.push([2, 4, , 5]);
|
|
86
|
+
this._initContext(web);
|
|
104
87
|
return [4 /*yield*/, contentTypes
|
|
105
88
|
.sort(function (a, b) {
|
|
106
89
|
if (a.ID < b.ID) {
|
|
@@ -112,16 +95,16 @@ var ContentTypes = /** @class */ (function (_super) {
|
|
|
112
95
|
return 0;
|
|
113
96
|
})
|
|
114
97
|
.reduce(function (chain, contentType) {
|
|
115
|
-
return chain.then(function () { return _this.processContentType(
|
|
98
|
+
return chain.then(function () { return _this.processContentType(contentType); });
|
|
116
99
|
}, Promise.resolve())];
|
|
100
|
+
case 3:
|
|
101
|
+
_b.sent();
|
|
102
|
+
return [3 /*break*/, 5];
|
|
117
103
|
case 4:
|
|
118
|
-
|
|
119
|
-
return [3 /*break*/, 6];
|
|
120
|
-
case 5:
|
|
121
|
-
error_1 = _c.sent();
|
|
104
|
+
error_1 = _b.sent();
|
|
122
105
|
_super.prototype.scope_ended.call(this, error_1);
|
|
123
106
|
throw error_1;
|
|
124
|
-
case
|
|
107
|
+
case 5: return [2 /*return*/];
|
|
125
108
|
}
|
|
126
109
|
});
|
|
127
110
|
});
|
|
@@ -129,18 +112,17 @@ var ContentTypes = /** @class */ (function (_super) {
|
|
|
129
112
|
/**
|
|
130
113
|
* Provision a content type
|
|
131
114
|
*
|
|
132
|
-
* @param web - The web
|
|
133
115
|
* @param contentType - Content type
|
|
134
116
|
*/
|
|
135
|
-
ContentTypes.prototype.processContentType = function (
|
|
136
|
-
var _a;
|
|
117
|
+
ContentTypes.prototype.processContentType = function (contentType) {
|
|
118
|
+
var _a, _b;
|
|
137
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
138
120
|
var contentTypeId, spContentType, error_2;
|
|
139
|
-
return __generator(this, function (
|
|
140
|
-
switch (
|
|
121
|
+
return __generator(this, function (_c) {
|
|
122
|
+
switch (_c.label) {
|
|
141
123
|
case 0:
|
|
142
|
-
|
|
143
|
-
contentTypeId = (_a = this.context.contentTypes[contentType.Name]) === null ||
|
|
124
|
+
_c.trys.push([0, 4, , 5]);
|
|
125
|
+
contentTypeId = (_a = contentType.ID) !== null && _a !== void 0 ? _a : (_b = this.context.contentTypes[contentType.Name]) === null || _b === void 0 ? void 0 : _b.ID;
|
|
144
126
|
if (!contentTypeId)
|
|
145
127
|
throw new Error("Content type with name '" + contentType.Name + "' does not exist in the web.");
|
|
146
128
|
_super.prototype.log_info.call(this, 'processContentType', "Processing content type [" + contentType.Name + "] (" + contentTypeId + ")");
|
|
@@ -156,15 +138,15 @@ var ContentTypes = /** @class */ (function (_super) {
|
|
|
156
138
|
spContentType.update(true);
|
|
157
139
|
return [4 /*yield*/, ExecuteJsomQuery(this.jsomContext)];
|
|
158
140
|
case 1:
|
|
159
|
-
|
|
141
|
+
_c.sent();
|
|
160
142
|
if (!contentType.FieldRefs) return [3 /*break*/, 3];
|
|
161
143
|
return [4 /*yield*/, this.processContentTypeFieldRefs(contentType, spContentType)];
|
|
162
144
|
case 2:
|
|
163
|
-
|
|
164
|
-
|
|
145
|
+
_c.sent();
|
|
146
|
+
_c.label = 3;
|
|
165
147
|
case 3: return [3 /*break*/, 5];
|
|
166
148
|
case 4:
|
|
167
|
-
error_2 =
|
|
149
|
+
error_2 = _c.sent();
|
|
168
150
|
throw error_2;
|
|
169
151
|
case 5: return [2 /*return*/];
|
|
170
152
|
}
|
|
@@ -254,6 +236,36 @@ var ContentTypes = /** @class */ (function (_super) {
|
|
|
254
236
|
});
|
|
255
237
|
});
|
|
256
238
|
};
|
|
239
|
+
ContentTypes.prototype._initContext = function (web) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
var _a;
|
|
242
|
+
return __generator(this, function (_b) {
|
|
243
|
+
switch (_b.label) {
|
|
244
|
+
case 0:
|
|
245
|
+
_a = this.context;
|
|
246
|
+
return [4 /*yield*/, web.contentTypes
|
|
247
|
+
.select('Id', 'Name', 'FieldLinks')
|
|
248
|
+
.expand('FieldLinks')()];
|
|
249
|
+
case 1:
|
|
250
|
+
_a.contentTypes = (_b.sent()).reduce(function (object, contentType) {
|
|
251
|
+
var ct = {
|
|
252
|
+
ID: contentType.Id.StringValue,
|
|
253
|
+
Name: contentType.Name,
|
|
254
|
+
FieldRefs: contentType['FieldLinks'].map(function (fieldLink) { return ({
|
|
255
|
+
ID: fieldLink.Id,
|
|
256
|
+
Name: fieldLink.Name,
|
|
257
|
+
Required: fieldLink.Required,
|
|
258
|
+
Hidden: fieldLink.Hidden
|
|
259
|
+
}); })
|
|
260
|
+
};
|
|
261
|
+
object[ct.Name] = ct;
|
|
262
|
+
return object;
|
|
263
|
+
}, {});
|
|
264
|
+
return [2 /*return*/];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
257
269
|
return ContentTypes;
|
|
258
270
|
}(HandlerBase));
|
|
259
271
|
export { ContentTypes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contenttypes.js","sourceRoot":"","sources":["../../src/handlers/contenttypes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,YAAY,EAAE,EAAE,gBAAgB,EAAe,MAAM,WAAW,CAAA;AAIvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH;IAAkC,gCAAW;IAI3C;;OAEG;IACH,sBAAY,MAA2B;eACrC,kBAAM,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