UNPKG

3.77 kBJavaScriptView Raw
1import { __decorate } from "tslib";
2import { body } from "@pnp/queryable";
3import { _SPCollection, _SPInstance, spInvokableFactory, SPCollection, deleteable, } from "../spqueryable.js";
4import { defaultPath } from "../decorators.js";
5import { spPost, spPostMerge } from "../operations.js";
6let _ContentTypes = class _ContentTypes extends _SPCollection {
7 /**
8 * Adds an existing contenttype to a content type collection
9 *
10 * @param contentTypeId in the following format, for example: 0x010102
11 */
12 async addAvailableContentType(contentTypeId) {
13 const data = await spPost(ContentTypes(this, "addAvailableContentType"), body({ "contentTypeId": contentTypeId }));
14 return {
15 contentType: this.getById(data.id),
16 data: data,
17 };
18 }
19 /**
20 * Gets a ContentType by content type id
21 * @param id The id of the content type to get, in the following format, for example: 0x010102
22 */
23 getById(id) {
24 return ContentType(this).concat(`('${id}')`);
25 }
26 /**
27 * Adds a new content type to the collection
28 *
29 * @param id The desired content type id for the new content type (also determines the parent
30 * content type)
31 * @param name The name of the content type
32 * @param description The description of the content type
33 * @param group The group in which to add the content type
34 * @param additionalSettings Any additional settings to provide when creating the content type
35 *
36 */
37 async add(id, name, description = "", group = "Custom Content Types", additionalSettings = {}) {
38 const postBody = body({
39 Description: description,
40 Group: group,
41 Id: { StringValue: id },
42 Name: name,
43 ...additionalSettings,
44 });
45 const data = await spPost(this, postBody);
46 return { contentType: this.getById(data.id), data };
47 }
48};
49_ContentTypes = __decorate([
50 defaultPath("contenttypes")
51], _ContentTypes);
52export { _ContentTypes };
53export const ContentTypes = spInvokableFactory(_ContentTypes);
54export class _ContentType extends _SPInstance {
55 constructor() {
56 super(...arguments);
57 this.delete = deleteable();
58 }
59 /**
60 * Updates this list instance with the supplied properties
61 *
62 * @param properties A plain object hash of values to update for the web
63 */
64 async update(properties) {
65 return spPostMerge(this, body(properties));
66 }
67 /**
68 * Gets the column (also known as field) references in the content type.
69 */
70 get fieldLinks() {
71 return FieldLinks(this);
72 }
73 /**
74 * Gets a value that specifies the collection of fields for the content type.
75 */
76 get fields() {
77 return SPCollection(this, "fields");
78 }
79 /**
80 * Gets the parent content type of the content type.
81 */
82 get parent() {
83 return ContentType(this, "parent");
84 }
85 /**
86 * Gets a value that specifies the collection of workflow associations for the content type.
87 */
88 get workflowAssociations() {
89 return SPCollection(this, "workflowAssociations");
90 }
91}
92export const ContentType = spInvokableFactory(_ContentType);
93let _FieldLinks = class _FieldLinks extends _SPCollection {
94 /**
95 * Gets a FieldLink by GUID id
96 *
97 * @param id The GUID id of the field link
98 */
99 getById(id) {
100 return FieldLink(this).concat(`(guid'${id}')`);
101 }
102};
103_FieldLinks = __decorate([
104 defaultPath("fieldlinks")
105], _FieldLinks);
106export { _FieldLinks };
107export const FieldLinks = spInvokableFactory(_FieldLinks);
108export class _FieldLink extends _SPInstance {
109}
110export const FieldLink = spInvokableFactory(_FieldLink);
111//# sourceMappingURL=types.js.map
\No newline at end of file