UNPKG

3.5 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 } 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 content type)
30 * @param name The name of the content type
31 * @param description The description of the content type
32 * @param group The group in which to add the content type
33 * @param additionalSettings Any additional settings to provide when creating the content type
34 *
35 */
36 async add(id, name, description = "", group = "Custom Content Types", additionalSettings = {}) {
37 const postBody = body({
38 Description: description,
39 Group: group,
40 Id: { StringValue: id },
41 Name: name,
42 ...additionalSettings,
43 });
44 const data = await spPost(this, postBody);
45 return { contentType: this.getById(data.id), data };
46 }
47};
48_ContentTypes = __decorate([
49 defaultPath("contenttypes")
50], _ContentTypes);
51export { _ContentTypes };
52export const ContentTypes = spInvokableFactory(_ContentTypes);
53export class _ContentType extends _SPInstance {
54 constructor() {
55 super(...arguments);
56 this.delete = deleteable();
57 }
58 /**
59 * Gets the column (also known as field) references in the content type.
60 */
61 get fieldLinks() {
62 return FieldLinks(this);
63 }
64 /**
65 * Gets a value that specifies the collection of fields for the content type.
66 */
67 get fields() {
68 return SPCollection(this, "fields");
69 }
70 /**
71 * Gets the parent content type of the content type.
72 */
73 get parent() {
74 return ContentType(this, "parent");
75 }
76 /**
77 * Gets a value that specifies the collection of workflow associations for the content type.
78 */
79 get workflowAssociations() {
80 return SPCollection(this, "workflowAssociations");
81 }
82}
83export const ContentType = spInvokableFactory(_ContentType);
84let _FieldLinks = class _FieldLinks extends _SPCollection {
85 /**
86 * Gets a FieldLink by GUID id
87 *
88 * @param id The GUID id of the field link
89 */
90 getById(id) {
91 return FieldLink(this).concat(`(guid'${id}')`);
92 }
93};
94_FieldLinks = __decorate([
95 defaultPath("fieldlinks")
96], _FieldLinks);
97export { _FieldLinks };
98export const FieldLinks = spInvokableFactory(_FieldLinks);
99export class _FieldLink extends _SPInstance {
100}
101export const FieldLink = spInvokableFactory(_FieldLink);
102//# sourceMappingURL=types.js.map
\No newline at end of file