@agility/management-sdk 0.1.0

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.
Files changed (56) hide show
  1. package/README.md +398 -0
  2. package/dist/apiMethods/assetMethods.d.ts +14 -0
  3. package/dist/apiMethods/assetMethods.js +95 -0
  4. package/dist/apiMethods/batchMethods.d.ts +11 -0
  5. package/dist/apiMethods/batchMethods.js +65 -0
  6. package/dist/apiMethods/clientInstance.d.ts +8 -0
  7. package/dist/apiMethods/clientInstance.js +77 -0
  8. package/dist/apiMethods/containerMethods.d.ts +16 -0
  9. package/dist/apiMethods/containerMethods.js +105 -0
  10. package/dist/apiMethods/contentMethods.d.ts +20 -0
  11. package/dist/apiMethods/contentMethods.js +175 -0
  12. package/dist/apiMethods/instanceUserMethods.d.ts +13 -0
  13. package/dist/apiMethods/instanceUserMethods.js +57 -0
  14. package/dist/apiMethods/modelMethods.d.ts +13 -0
  15. package/dist/apiMethods/modelMethods.js +81 -0
  16. package/dist/apiMethods/pageMethods.d.ts +20 -0
  17. package/dist/apiMethods/pageMethods.js +159 -0
  18. package/dist/enums/batchOperationType.d.ts +19 -0
  19. package/dist/enums/batchOperationType.js +23 -0
  20. package/dist/enums/batchState..d.ts +7 -0
  21. package/dist/enums/batchState..js +11 -0
  22. package/dist/index.d.ts +21 -0
  23. package/dist/index.js +33 -0
  24. package/dist/models/batch.d.ts +29 -0
  25. package/dist/models/batch.js +6 -0
  26. package/dist/models/batchItem.d.ts +13 -0
  27. package/dist/models/batchItem.js +6 -0
  28. package/dist/models/container.d.ts +47 -0
  29. package/dist/models/container.js +6 -0
  30. package/dist/models/contentItem.d.ts +37 -0
  31. package/dist/models/contentItem.js +18 -0
  32. package/dist/models/contentViewColumn.d.ts +8 -0
  33. package/dist/models/contentViewColumn.js +6 -0
  34. package/dist/models/exception.d.ts +4 -0
  35. package/dist/models/exception.js +10 -0
  36. package/dist/models/instanceRole.d.ts +7 -0
  37. package/dist/models/instanceRole.js +6 -0
  38. package/dist/models/instanceUser.d.ts +14 -0
  39. package/dist/models/instanceUser.js +6 -0
  40. package/dist/models/media.d.ts +30 -0
  41. package/dist/models/media.js +9 -0
  42. package/dist/models/model.d.ts +30 -0
  43. package/dist/models/model.js +9 -0
  44. package/dist/models/notification.d.ts +13 -0
  45. package/dist/models/notification.js +6 -0
  46. package/dist/models/options.d.ts +10 -0
  47. package/dist/models/options.js +25 -0
  48. package/dist/models/pageItem.d.ts +56 -0
  49. package/dist/models/pageItem.js +21 -0
  50. package/dist/models/sitemap.d.ts +20 -0
  51. package/dist/models/sitemap.js +9 -0
  52. package/dist/models/websiteUser.d.ts +22 -0
  53. package/dist/models/websiteUser.js +9 -0
  54. package/license.txt +21 -0
  55. package/package.json +39 -0
  56. package/tsconfig.json +15 -0
@@ -0,0 +1,16 @@
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { Container } from "../models/container";
4
+ import { Notification } from "../models/notification";
5
+ export declare class ContainerMethods {
6
+ _options: Options;
7
+ _clientInstance: ClientInstance;
8
+ constructor(options: Options);
9
+ getContainerByID(id: number): Promise<Container>;
10
+ getContainerByReferenceName(referenceName: string): Promise<Container>;
11
+ getContainerSecurity(id: number): Promise<Container>;
12
+ getContainerList(): Promise<Container[]>;
13
+ getNotificationList(id: number): Promise<Notification[]>;
14
+ saveContainer(container: Container): Promise<Container>;
15
+ deleteContainer(id: number): Promise<string>;
16
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContainerMethods = void 0;
13
+ const clientInstance_1 = require("./clientInstance");
14
+ const exception_1 = require("../models/exception");
15
+ class ContainerMethods {
16
+ constructor(options) {
17
+ this._options = options;
18
+ this._clientInstance = new clientInstance_1.ClientInstance();
19
+ }
20
+ getContainerByID(id) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ try {
23
+ let apiPath = `container/${id}`;
24
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
25
+ return resp.data;
26
+ }
27
+ catch (err) {
28
+ throw new exception_1.Exception(`Unable to retreive the contianer for id: ${id}`, err);
29
+ }
30
+ });
31
+ }
32
+ getContainerByReferenceName(referenceName) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ let apiPath = `container/${referenceName}`;
36
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
37
+ return resp.data;
38
+ }
39
+ catch (err) {
40
+ throw new exception_1.Exception(`Unable to retreive the contianer for referenceName: ${referenceName}`, err);
41
+ }
42
+ });
43
+ }
44
+ getContainerSecurity(id) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ try {
47
+ let apiPath = `container/${id}/security`;
48
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
49
+ return resp.data;
50
+ }
51
+ catch (err) {
52
+ throw new exception_1.Exception(`Unable to retreive the contianer for id: ${id}`, err);
53
+ }
54
+ });
55
+ }
56
+ getContainerList() {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ let apiPath = `container/list`;
60
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
61
+ return resp.data;
62
+ }
63
+ catch (err) {
64
+ throw new exception_1.Exception(`Unable to retreive the contianer list`, err);
65
+ }
66
+ });
67
+ }
68
+ getNotificationList(id) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ try {
71
+ let apiPath = `container/${id}/notifications`;
72
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
73
+ return resp.data;
74
+ }
75
+ catch (err) {
76
+ throw new exception_1.Exception(`Unable to retreive the notifications for contianer id: ${id}`, err);
77
+ }
78
+ });
79
+ }
80
+ saveContainer(container) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ let apiPath = `container`;
84
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, container);
85
+ return resp.data;
86
+ }
87
+ catch (err) {
88
+ throw new exception_1.Exception(`Unable to save the contianer`, err);
89
+ }
90
+ });
91
+ }
92
+ deleteContainer(id) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ try {
95
+ let apiPath = `container/${id}`;
96
+ const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
97
+ return resp.data;
98
+ }
99
+ catch (err) {
100
+ throw new exception_1.Exception(`Unable to delete the contianer for id: ${id}`, err);
101
+ }
102
+ });
103
+ }
104
+ }
105
+ exports.ContainerMethods = ContainerMethods;
@@ -0,0 +1,20 @@
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { ContentItem, ContentList } from "../models/contentItem";
4
+ import { BatchMethods } from "./batchMethods";
5
+ export declare class ContentMethods {
6
+ _options: Options;
7
+ _clientInstance: ClientInstance;
8
+ _batchMethods: BatchMethods;
9
+ constructor(options: Options);
10
+ getContentItem(contentID: number): Promise<ContentItem>;
11
+ publishContent(contentID: number, comments?: string): Promise<number[]>;
12
+ unPublishContent(contentID: number, comments?: string): Promise<number[]>;
13
+ contentRequestApproval(contentID: number, comments?: string): Promise<number[]>;
14
+ approveContent(contentID: number, comments?: string): Promise<number[]>;
15
+ declineContent(contentID: number, comments?: string): Promise<number[]>;
16
+ deleteContent(contentID: number, comments?: string): Promise<number[]>;
17
+ saveContentItem(contentItem: ContentItem): Promise<number[]>;
18
+ saveContentItems(contentItems: ContentItem[]): Promise<number[]>;
19
+ getContentItems(referenceName: string, filter?: string, fields?: string, sortDirection?: string, sortField?: string, take?: number, skip?: number): Promise<ContentList>;
20
+ }
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContentMethods = void 0;
13
+ const clientInstance_1 = require("./clientInstance");
14
+ const batchMethods_1 = require("./batchMethods");
15
+ const exception_1 = require("../models/exception");
16
+ class ContentMethods {
17
+ constructor(options) {
18
+ this._options = options;
19
+ this._clientInstance = new clientInstance_1.ClientInstance();
20
+ this._batchMethods = new batchMethods_1.BatchMethods(this._options);
21
+ }
22
+ getContentItem(contentID) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ let apiPath = `${this._options.locale}/item/${contentID}`;
26
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
27
+ return resp.data;
28
+ }
29
+ catch (err) {
30
+ throw new exception_1.Exception(`Unable to retreive the content for id: ${contentID}`, err);
31
+ }
32
+ });
33
+ }
34
+ publishContent(contentID, comments = null) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ let apiPath = `${this._options.locale}/item/${contentID}/publish?comments=${comments}`;
38
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
39
+ let batchID = resp.data;
40
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
41
+ let contentIDs = [];
42
+ batch.items.forEach(element => contentIDs.push(element.itemID));
43
+ return contentIDs;
44
+ }
45
+ catch (err) {
46
+ throw new exception_1.Exception(`Unable to publish the content for id: ${contentID}`, err);
47
+ }
48
+ });
49
+ }
50
+ unPublishContent(contentID, comments = null) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ let apiPath = `${this._options.locale}/item/${contentID}/unpublish?comments=${comments}`;
54
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
55
+ let batchID = resp.data;
56
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
57
+ let contentIDs = [];
58
+ batch.items.forEach(element => contentIDs.push(element.itemID));
59
+ return contentIDs;
60
+ }
61
+ catch (err) {
62
+ throw new exception_1.Exception(`Unable to un-publish the content for id: ${contentID}`, err);
63
+ }
64
+ });
65
+ }
66
+ contentRequestApproval(contentID, comments = null) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ try {
69
+ let apiPath = `${this._options.locale}/item/${contentID}/request-approval?comments=${comments}`;
70
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
71
+ let batchID = resp.data;
72
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
73
+ let contentIDs = [];
74
+ batch.items.forEach(element => contentIDs.push(element.itemID));
75
+ return contentIDs;
76
+ }
77
+ catch (err) {
78
+ throw new exception_1.Exception(`Unable to request approval the content for id: ${contentID}`, err);
79
+ }
80
+ });
81
+ }
82
+ approveContent(contentID, comments = null) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ try {
85
+ let apiPath = `${this._options.locale}/item/${contentID}/approve?comments=${comments}`;
86
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
87
+ let batchID = resp.data;
88
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
89
+ let contentIDs = [];
90
+ batch.items.forEach(element => contentIDs.push(element.itemID));
91
+ return contentIDs;
92
+ }
93
+ catch (err) {
94
+ throw new exception_1.Exception(`Unable to approve the content for id: ${contentID}`, err);
95
+ }
96
+ });
97
+ }
98
+ declineContent(contentID, comments = null) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ try {
101
+ let apiPath = `${this._options.locale}/item/${contentID}/decline?comments=${comments}`;
102
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
103
+ let batchID = resp.data;
104
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
105
+ let contentIDs = [];
106
+ batch.items.forEach(element => contentIDs.push(element.itemID));
107
+ return contentIDs;
108
+ }
109
+ catch (err) {
110
+ throw new exception_1.Exception(`Unable to decline the content for id: ${contentID}`, err);
111
+ }
112
+ });
113
+ }
114
+ deleteContent(contentID, comments = null) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ try {
117
+ let apiPath = `${this._options.locale}/item/${contentID}?comments=${comments}`;
118
+ const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
119
+ let batchID = resp.data;
120
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
121
+ let contentIDs = [];
122
+ batch.items.forEach(element => contentIDs.push(element.itemID));
123
+ return contentIDs;
124
+ }
125
+ catch (err) {
126
+ throw new exception_1.Exception(`Unable to delete the content for id: ${contentID}`, err);
127
+ }
128
+ });
129
+ }
130
+ saveContentItem(contentItem) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ try {
133
+ let apiPath = `${this._options.locale}/item`;
134
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, contentItem);
135
+ let batchID = resp.data;
136
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
137
+ let contentIDs = [];
138
+ batch.items.forEach(element => contentIDs.push(element.itemID));
139
+ return contentIDs;
140
+ }
141
+ catch (err) {
142
+ throw new exception_1.Exception('Unable to create content.', err);
143
+ }
144
+ });
145
+ }
146
+ saveContentItems(contentItems) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ try {
149
+ let apiPath = `${this._options.locale}/item/multi`;
150
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, contentItems);
151
+ let batchID = resp.data;
152
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
153
+ let contentIDs = [];
154
+ batch.items.forEach(element => contentIDs.push(element.itemID));
155
+ return contentIDs;
156
+ }
157
+ catch (err) {
158
+ throw new exception_1.Exception('Unable to create contents.', err);
159
+ }
160
+ });
161
+ }
162
+ getContentItems(referenceName, filter = '', fields = null, sortDirection = null, sortField = null, take = 50, skip = 0) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ try {
165
+ let apiPath = `${this._options.locale}/list/${referenceName}?filter=${filter}&fields=${fields}&sortDirection=${sortDirection}&sortField=${sortField}&take=${take}&skip=${skip}`;
166
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
167
+ return resp.data;
168
+ }
169
+ catch (err) {
170
+ throw new exception_1.Exception(`Unable retreive the content details for reference name: ${referenceName}`, err);
171
+ }
172
+ });
173
+ }
174
+ }
175
+ exports.ContentMethods = ContentMethods;
@@ -0,0 +1,13 @@
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { InstanceUser } from "../models/instanceUser";
4
+ import { WebsiteUser } from "../models/websiteUser";
5
+ import { InstanceRole } from "../models/instanceRole";
6
+ export declare class InstanceUserMethods {
7
+ _options: Options;
8
+ _clientInstance: ClientInstance;
9
+ constructor(options: Options);
10
+ getUsers(): Promise<WebsiteUser>;
11
+ saveUser(emailAddress: string, roles: InstanceRole[], firstName?: string, lastName?: string): Promise<InstanceUser>;
12
+ deleteUser(userId: number): Promise<string>;
13
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InstanceUserMethods = void 0;
13
+ const clientInstance_1 = require("./clientInstance");
14
+ const exception_1 = require("../models/exception");
15
+ class InstanceUserMethods {
16
+ constructor(options) {
17
+ this._options = options;
18
+ this._clientInstance = new clientInstance_1.ClientInstance();
19
+ }
20
+ getUsers() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ try {
23
+ let apiPath = `user/list`;
24
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
25
+ return resp.data;
26
+ }
27
+ catch (err) {
28
+ throw new exception_1.Exception(`Unable to retreive users.`, err);
29
+ }
30
+ });
31
+ }
32
+ saveUser(emailAddress, roles, firstName = null, lastName = null) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ let apiPath = `user/save?emailAddress=${emailAddress}&firstName=${firstName}&lastName=${lastName}`;
36
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, roles);
37
+ return resp.data;
38
+ }
39
+ catch (err) {
40
+ throw new exception_1.Exception(`Unable to retreive users.`, err);
41
+ }
42
+ });
43
+ }
44
+ deleteUser(userId) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ try {
47
+ let apiPath = `user/delete/${userId}`;
48
+ const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
49
+ return resp.data;
50
+ }
51
+ catch (err) {
52
+ throw new exception_1.Exception(`Unable to delete the user for id: ${userId}`, err);
53
+ }
54
+ });
55
+ }
56
+ }
57
+ exports.InstanceUserMethods = InstanceUserMethods;
@@ -0,0 +1,13 @@
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { Model } from "../models/model";
4
+ export declare class ModelMethods {
5
+ _options: Options;
6
+ _clientInstance: ClientInstance;
7
+ constructor(options: Options);
8
+ getContentModel(id: number): Promise<Model>;
9
+ getContentModules(includeDefaults: boolean, includeModules?: boolean): Promise<Model[]>;
10
+ getPageModules(includeDefault: boolean): Promise<Model[]>;
11
+ saveModel(model: Model): Promise<Model>;
12
+ deleteModel(id: number): Promise<string>;
13
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ModelMethods = void 0;
13
+ const clientInstance_1 = require("./clientInstance");
14
+ const exception_1 = require("../models/exception");
15
+ class ModelMethods {
16
+ constructor(options) {
17
+ this._options = options;
18
+ this._clientInstance = new clientInstance_1.ClientInstance();
19
+ }
20
+ getContentModel(id) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ try {
23
+ let apiPath = `model/${id}`;
24
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
25
+ return resp.data;
26
+ }
27
+ catch (err) {
28
+ throw new exception_1.Exception(`Unable to retreive model for id: ${id}.`, err);
29
+ }
30
+ });
31
+ }
32
+ getContentModules(includeDefaults, includeModules = false) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ let apiPath = `model/list/${includeDefaults}?includeModules=${includeModules}`;
36
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
37
+ return resp.data;
38
+ }
39
+ catch (err) {
40
+ throw new exception_1.Exception(`Unable to retreive content modules.`, err);
41
+ }
42
+ });
43
+ }
44
+ getPageModules(includeDefault) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ try {
47
+ let apiPath = `model/list-page-modules/${includeDefault}`;
48
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
49
+ return resp.data;
50
+ }
51
+ catch (err) {
52
+ throw new exception_1.Exception(`Unable to retreive page modules.`, err);
53
+ }
54
+ });
55
+ }
56
+ saveModel(model) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ let apiPath = `model`;
60
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, model);
61
+ return resp.data;
62
+ }
63
+ catch (err) {
64
+ throw new exception_1.Exception(`Unable to save the model.`, err);
65
+ }
66
+ });
67
+ }
68
+ deleteModel(id) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ try {
71
+ let apiPath = `model/${id}`;
72
+ const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
73
+ return resp.data;
74
+ }
75
+ catch (err) {
76
+ throw new exception_1.Exception(`Unable to delete the model`, err);
77
+ }
78
+ });
79
+ }
80
+ }
81
+ exports.ModelMethods = ModelMethods;
@@ -0,0 +1,20 @@
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { PageItem } from "../models/pageItem";
4
+ import { Sitemap } from "../models/sitemap";
5
+ import { BatchMethods } from "./batchMethods";
6
+ export declare class PageMethods {
7
+ _options: Options;
8
+ _clientInstance: ClientInstance;
9
+ _batchMethods: BatchMethods;
10
+ constructor(options: Options);
11
+ getSitemap(): Promise<Sitemap[]>;
12
+ getPage(pageID: number): Promise<PageItem>;
13
+ publishPage(pageID: number, comments?: string): Promise<number[]>;
14
+ unPublishPage(pageID: number, comments?: string): Promise<number[]>;
15
+ pageRequestApproval(pageID: number, comments?: string): Promise<number[]>;
16
+ approvePage(pageID: number, comments?: string): Promise<number[]>;
17
+ declinePage(pageID: number, comments?: string): Promise<number[]>;
18
+ deletePage(pageID: number, comments?: string): Promise<number[]>;
19
+ savePage(pageItem: PageItem, parentPageID?: number, placeBeforePageItemID?: number): Promise<number[]>;
20
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PageMethods = void 0;
13
+ const clientInstance_1 = require("./clientInstance");
14
+ const batchMethods_1 = require("./batchMethods");
15
+ const exception_1 = require("../models/exception");
16
+ class PageMethods {
17
+ constructor(options) {
18
+ this._options = options;
19
+ this._clientInstance = new clientInstance_1.ClientInstance();
20
+ this._batchMethods = new batchMethods_1.BatchMethods(this._options);
21
+ }
22
+ getSitemap() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ let apiPath = `${this._options.locale}/sitemap`;
26
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
27
+ return resp.data;
28
+ }
29
+ catch (err) {
30
+ throw new exception_1.Exception(`Unable to retreive sitemap.`, err);
31
+ }
32
+ });
33
+ }
34
+ getPage(pageID) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ let apiPath = `${this._options.locale}/page/${pageID}`;
38
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
39
+ return resp.data;
40
+ }
41
+ catch (err) {
42
+ throw new exception_1.Exception(`Unable to retreive page for id ${pageID}.`, err);
43
+ }
44
+ });
45
+ }
46
+ publishPage(pageID, comments = null) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ try {
49
+ let apiPath = `${this._options.locale}/page/${pageID}/publish?comments=${comments}`;
50
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
51
+ let batchID = resp.data;
52
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
53
+ let pageIDs = [];
54
+ batch.items.forEach(element => pageIDs.push(element.itemID));
55
+ return pageIDs;
56
+ }
57
+ catch (err) {
58
+ throw new exception_1.Exception(`Unable to publish the page for id: ${pageID}`, err);
59
+ }
60
+ });
61
+ }
62
+ unPublishPage(pageID, comments = null) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ try {
65
+ let apiPath = `${this._options.locale}/page/${pageID}/unpublish?comments=${comments}`;
66
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
67
+ let batchID = resp.data;
68
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
69
+ let pageIDs = [];
70
+ batch.items.forEach(element => pageIDs.push(element.itemID));
71
+ return pageIDs;
72
+ }
73
+ catch (err) {
74
+ throw new exception_1.Exception(`Unable to un-publish the page for id: ${pageID}`, err);
75
+ }
76
+ });
77
+ }
78
+ pageRequestApproval(pageID, comments = null) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ try {
81
+ let apiPath = `${this._options.locale}/page/${pageID}/request-approval?comments=${comments}`;
82
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
83
+ let batchID = resp.data;
84
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
85
+ let pageIDs = [];
86
+ batch.items.forEach(element => pageIDs.push(element.itemID));
87
+ return pageIDs;
88
+ }
89
+ catch (err) {
90
+ throw new exception_1.Exception(`Unable to request approval the page for id: ${pageID}`, err);
91
+ }
92
+ });
93
+ }
94
+ approvePage(pageID, comments = null) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ try {
97
+ let apiPath = `${this._options.locale}/page/${pageID}/approve?comments=${comments}`;
98
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
99
+ let batchID = resp.data;
100
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
101
+ let pageIDs = [];
102
+ batch.items.forEach(element => pageIDs.push(element.itemID));
103
+ return pageIDs;
104
+ }
105
+ catch (err) {
106
+ throw new exception_1.Exception(`Unable to approve the page for id: ${pageID}`, err);
107
+ }
108
+ });
109
+ }
110
+ declinePage(pageID, comments = null) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ try {
113
+ let apiPath = `${this._options.locale}/page/${pageID}/decline?comments=${comments}`;
114
+ const resp = yield this._clientInstance.executeGet(apiPath, this._options);
115
+ let batchID = resp.data;
116
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
117
+ let pageIDs = [];
118
+ batch.items.forEach(element => pageIDs.push(element.itemID));
119
+ return pageIDs;
120
+ }
121
+ catch (err) {
122
+ throw new exception_1.Exception(`Unable to decline the page for id: ${pageID}`, err);
123
+ }
124
+ });
125
+ }
126
+ deletePage(pageID, comments = null) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ try {
129
+ let apiPath = `${this._options.locale}/page/${pageID}?comments=${comments}`;
130
+ const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
131
+ let batchID = resp.data;
132
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
133
+ let pageIDs = [];
134
+ batch.items.forEach(element => pageIDs.push(element.itemID));
135
+ return pageIDs;
136
+ }
137
+ catch (err) {
138
+ throw new exception_1.Exception(`Unable to delete the page for id: ${pageID}`, err);
139
+ }
140
+ });
141
+ }
142
+ savePage(pageItem, parentPageID = -1, placeBeforePageItemID = -1) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ try {
145
+ let apiPath = `${this._options.locale}/page?parentPageID=${parentPageID}&placeBeforePageItemID=${placeBeforePageItemID}`;
146
+ const resp = yield this._clientInstance.executePost(apiPath, this._options, pageItem);
147
+ let batchID = resp.data;
148
+ var batch = yield this._batchMethods.Retry(() => __awaiter(this, void 0, void 0, function* () { return yield this._batchMethods.getBatch(batchID); }));
149
+ let pageIDs = [];
150
+ batch.items.forEach(element => pageIDs.push(element.itemID));
151
+ return pageIDs;
152
+ }
153
+ catch (err) {
154
+ throw new exception_1.Exception(`Unable to create page. ${err}`, err);
155
+ }
156
+ });
157
+ }
158
+ }
159
+ exports.PageMethods = PageMethods;