@agility/management-sdk 0.1.36 → 0.1.37

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 (259) hide show
  1. package/README.md +371 -317
  2. package/dist/apiMethods/clientInstance.d.ts +2 -0
  3. package/dist/apiMethods/clientInstance.js +11 -2
  4. package/dist/apiMethods/containerMethods.d.ts +3 -0
  5. package/dist/apiMethods/containerMethods.js +43 -9
  6. package/dist/apiMethods/contentMethods.d.ts +12 -0
  7. package/dist/apiMethods/contentMethods.js +100 -46
  8. package/dist/apiMethods/pageMethods.d.ts +12 -0
  9. package/dist/apiMethods/pageMethods.js +88 -34
  10. package/dist/enums/contentViewType.d.ts +6 -0
  11. package/dist/enums/contentViewType.js +10 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +2 -0
  14. package/dist/models/pagedResult.d.ts +4 -0
  15. package/dist/models/pagedResult.js +2 -0
  16. package/docs/asset-methods.md +381 -381
  17. package/docs/auth-component.md +360 -360
  18. package/docs/auth.md +593 -593
  19. package/docs/batch-methods.md +243 -243
  20. package/docs/cicd.md +606 -606
  21. package/docs/container-methods.md +267 -267
  22. package/docs/content-methods.md +491 -422
  23. package/docs/instance-methods.md +104 -104
  24. package/docs/instance-user-methods.md +230 -230
  25. package/docs/model-methods.md +433 -433
  26. package/docs/multi-instance-operations.md +191 -191
  27. package/docs/page-methods.md +737 -670
  28. package/docs/server-user-methods.md +279 -279
  29. package/docs/webhook-methods.md +451 -451
  30. package/license.txt +20 -20
  31. package/package.json +40 -40
  32. package/tsconfig.json +14 -14
  33. package/.cursor/api-coverage.md +0 -217
  34. package/.cursor/api-documentation-manifest.md +0 -275
  35. package/.cursor/api-functions-analysis.md +0 -111
  36. package/.cursor/breakout-manifest.md +0 -278
  37. package/.cursor/docs-final-check.md +0 -269
  38. package/.cursor/github-actions-improvements.md +0 -76
  39. package/.cursor/hardening.md +0 -271
  40. package/.cursor/linting-fix.md +0 -160
  41. package/.cursor/manifest.md +0 -243
  42. package/.cursor/mocks.md +0 -100
  43. package/.cursor/test-coverage.md +0 -841
  44. package/.env +0 -92
  45. package/coverage/base.css +0 -224
  46. package/coverage/block-navigation.js +0 -87
  47. package/coverage/coverage-summary.json +0 -43
  48. package/coverage/favicon.png +0 -0
  49. package/coverage/index.html +0 -161
  50. package/coverage/lcov-report/base.css +0 -224
  51. package/coverage/lcov-report/block-navigation.js +0 -87
  52. package/coverage/lcov-report/favicon.png +0 -0
  53. package/coverage/lcov-report/index.html +0 -161
  54. package/coverage/lcov-report/prettify.css +0 -1
  55. package/coverage/lcov-report/prettify.js +0 -2
  56. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  57. package/coverage/lcov-report/sorter.js +0 -210
  58. package/coverage/lcov-report/src/apiClient.ts.html +0 -199
  59. package/coverage/lcov-report/src/apiMethods/assetMethods.ts.html +0 -682
  60. package/coverage/lcov-report/src/apiMethods/batchMethods.ts.html +0 -736
  61. package/coverage/lcov-report/src/apiMethods/clientInstance.ts.html +0 -403
  62. package/coverage/lcov-report/src/apiMethods/containerMethods.ts.html +0 -460
  63. package/coverage/lcov-report/src/apiMethods/contentMethods.ts.html +0 -1183
  64. package/coverage/lcov-report/src/apiMethods/index.html +0 -266
  65. package/coverage/lcov-report/src/apiMethods/instanceMethods.ts.html +0 -160
  66. package/coverage/lcov-report/src/apiMethods/instanceUserMethods.ts.html +0 -268
  67. package/coverage/lcov-report/src/apiMethods/modelMethods.ts.html +0 -352
  68. package/coverage/lcov-report/src/apiMethods/pageMethods.ts.html +0 -1276
  69. package/coverage/lcov-report/src/apiMethods/serverUserMethods.ts.html +0 -196
  70. package/coverage/lcov-report/src/apiMethods/webhookMethods.ts.html +0 -271
  71. package/coverage/lcov-report/src/enums/batchItemType.ts.html +0 -106
  72. package/coverage/lcov-report/src/enums/batchOperationType.ts.html +0 -142
  73. package/coverage/lcov-report/src/enums/batchState..ts.html +0 -106
  74. package/coverage/lcov-report/src/enums/index.html +0 -161
  75. package/coverage/lcov-report/src/enums/workflowOperationType.ts.html +0 -175
  76. package/coverage/lcov-report/src/index.html +0 -116
  77. package/coverage/lcov-report/src/models/assetContainer.ts.html +0 -106
  78. package/coverage/lcov-report/src/models/assetGalleries.ts.html +0 -103
  79. package/coverage/lcov-report/src/models/assetMediaGrouping.ts.html +0 -136
  80. package/coverage/lcov-report/src/models/assetMediaGroupingMetaData.ts.html +0 -97
  81. package/coverage/lcov-report/src/models/batch.ts.html +0 -178
  82. package/coverage/lcov-report/src/models/batchItem.ts.html +0 -127
  83. package/coverage/lcov-report/src/models/container.ts.html +0 -232
  84. package/coverage/lcov-report/src/models/contentDefinitionTypeID.ts.html +0 -142
  85. package/coverage/lcov-report/src/models/contentItem.ts.html +0 -202
  86. package/coverage/lcov-report/src/models/contentSectionDefaultModule.ts.html +0 -106
  87. package/coverage/lcov-report/src/models/contentSectionDefinition.ts.html +0 -196
  88. package/coverage/lcov-report/src/models/contentViewColumn.ts.html +0 -109
  89. package/coverage/lcov-report/src/models/exception.ts.html +0 -109
  90. package/coverage/lcov-report/src/models/index.html +0 -476
  91. package/coverage/lcov-report/src/models/instanceRole.ts.html +0 -106
  92. package/coverage/lcov-report/src/models/instanceUser.ts.html +0 -130
  93. package/coverage/lcov-report/src/models/locales.ts.html +0 -100
  94. package/coverage/lcov-report/src/models/media.ts.html +0 -178
  95. package/coverage/lcov-report/src/models/model.ts.html +0 -172
  96. package/coverage/lcov-report/src/models/notification.ts.html +0 -124
  97. package/coverage/lcov-report/src/models/options.ts.html +0 -109
  98. package/coverage/lcov-report/src/models/pageItem.ts.html +0 -268
  99. package/coverage/lcov-report/src/models/pageModel.ts.html +0 -130
  100. package/coverage/lcov-report/src/models/sharedModule.ts.html +0 -106
  101. package/coverage/lcov-report/src/models/sitemap.ts.html +0 -148
  102. package/coverage/lcov-report/src/models/websiteUser.ts.html +0 -157
  103. package/coverage/lcov.info +0 -1459
  104. package/coverage/prettify.css +0 -1
  105. package/coverage/prettify.js +0 -2
  106. package/coverage/sort-arrow-sprite.png +0 -0
  107. package/coverage/sorter.js +0 -210
  108. package/coverage/src/apiClient.ts.html +0 -199
  109. package/coverage/src/apiMethods/assetMethods.ts.html +0 -682
  110. package/coverage/src/apiMethods/batchMethods.ts.html +0 -736
  111. package/coverage/src/apiMethods/clientInstance.ts.html +0 -403
  112. package/coverage/src/apiMethods/containerMethods.ts.html +0 -460
  113. package/coverage/src/apiMethods/contentMethods.ts.html +0 -1183
  114. package/coverage/src/apiMethods/index.html +0 -266
  115. package/coverage/src/apiMethods/instanceMethods.ts.html +0 -160
  116. package/coverage/src/apiMethods/instanceUserMethods.ts.html +0 -268
  117. package/coverage/src/apiMethods/modelMethods.ts.html +0 -352
  118. package/coverage/src/apiMethods/pageMethods.ts.html +0 -1276
  119. package/coverage/src/apiMethods/serverUserMethods.ts.html +0 -196
  120. package/coverage/src/apiMethods/webhookMethods.ts.html +0 -271
  121. package/coverage/src/enums/batchItemType.ts.html +0 -106
  122. package/coverage/src/enums/batchOperationType.ts.html +0 -142
  123. package/coverage/src/enums/batchState..ts.html +0 -106
  124. package/coverage/src/enums/index.html +0 -161
  125. package/coverage/src/enums/workflowOperationType.ts.html +0 -175
  126. package/coverage/src/index.html +0 -116
  127. package/coverage/src/models/assetContainer.ts.html +0 -106
  128. package/coverage/src/models/assetGalleries.ts.html +0 -103
  129. package/coverage/src/models/assetMediaGrouping.ts.html +0 -136
  130. package/coverage/src/models/assetMediaGroupingMetaData.ts.html +0 -97
  131. package/coverage/src/models/batch.ts.html +0 -178
  132. package/coverage/src/models/batchItem.ts.html +0 -127
  133. package/coverage/src/models/container.ts.html +0 -232
  134. package/coverage/src/models/contentDefinitionTypeID.ts.html +0 -142
  135. package/coverage/src/models/contentItem.ts.html +0 -202
  136. package/coverage/src/models/contentSectionDefaultModule.ts.html +0 -106
  137. package/coverage/src/models/contentSectionDefinition.ts.html +0 -196
  138. package/coverage/src/models/contentViewColumn.ts.html +0 -109
  139. package/coverage/src/models/exception.ts.html +0 -109
  140. package/coverage/src/models/index.html +0 -476
  141. package/coverage/src/models/instanceRole.ts.html +0 -106
  142. package/coverage/src/models/instanceUser.ts.html +0 -130
  143. package/coverage/src/models/locales.ts.html +0 -100
  144. package/coverage/src/models/media.ts.html +0 -178
  145. package/coverage/src/models/model.ts.html +0 -172
  146. package/coverage/src/models/notification.ts.html +0 -124
  147. package/coverage/src/models/options.ts.html +0 -109
  148. package/coverage/src/models/pageItem.ts.html +0 -268
  149. package/coverage/src/models/pageModel.ts.html +0 -130
  150. package/coverage/src/models/sharedModule.ts.html +0 -106
  151. package/coverage/src/models/sitemap.ts.html +0 -148
  152. package/coverage/src/models/websiteUser.ts.html +0 -157
  153. package/dist/.tsbuildinfo +0 -1
  154. package/dist/apiClient.d.ts.map +0 -1
  155. package/dist/apiClient.js.map +0 -1
  156. package/dist/apiMethods/assetMethods.d.ts.map +0 -1
  157. package/dist/apiMethods/assetMethods.js.map +0 -1
  158. package/dist/apiMethods/batchMethods.d.ts.map +0 -1
  159. package/dist/apiMethods/batchMethods.js.map +0 -1
  160. package/dist/apiMethods/clientInstance.d.ts.map +0 -1
  161. package/dist/apiMethods/clientInstance.js.map +0 -1
  162. package/dist/apiMethods/containerMethods.d.ts.map +0 -1
  163. package/dist/apiMethods/containerMethods.js.map +0 -1
  164. package/dist/apiMethods/contentMethods.d.ts.map +0 -1
  165. package/dist/apiMethods/contentMethods.js.map +0 -1
  166. package/dist/apiMethods/instanceMethods.d.ts.map +0 -1
  167. package/dist/apiMethods/instanceMethods.js.map +0 -1
  168. package/dist/apiMethods/instanceUserMethods.d.ts.map +0 -1
  169. package/dist/apiMethods/instanceUserMethods.js.map +0 -1
  170. package/dist/apiMethods/modelMethods.d.ts.map +0 -1
  171. package/dist/apiMethods/modelMethods.js.map +0 -1
  172. package/dist/apiMethods/pageMethods.d.ts.map +0 -1
  173. package/dist/apiMethods/pageMethods.js.map +0 -1
  174. package/dist/apiMethods/serverUserMethods.d.ts.map +0 -1
  175. package/dist/apiMethods/serverUserMethods.js.map +0 -1
  176. package/dist/apiMethods/webhookMethods.d.ts.map +0 -1
  177. package/dist/apiMethods/webhookMethods.js.map +0 -1
  178. package/dist/enums/assetGroupingType.d.ts.map +0 -1
  179. package/dist/enums/assetGroupingType.js.map +0 -1
  180. package/dist/enums/batchItemType.d.ts.map +0 -1
  181. package/dist/enums/batchItemType.js.map +0 -1
  182. package/dist/enums/batchOperationType.d.ts.map +0 -1
  183. package/dist/enums/batchOperationType.js.map +0 -1
  184. package/dist/enums/batchState..d.ts.map +0 -1
  185. package/dist/enums/batchState..js.map +0 -1
  186. package/dist/enums/pageItemTemplateType.d.ts.map +0 -1
  187. package/dist/enums/pageItemTemplateType.js.map +0 -1
  188. package/dist/enums/workflowOperationType.d.ts.map +0 -1
  189. package/dist/enums/workflowOperationType.js.map +0 -1
  190. package/dist/index.d.ts.map +0 -1
  191. package/dist/index.js.map +0 -1
  192. package/dist/models/assetContainer.d.ts.map +0 -1
  193. package/dist/models/assetContainer.js.map +0 -1
  194. package/dist/models/assetGalleries.d.ts.map +0 -1
  195. package/dist/models/assetGalleries.js.map +0 -1
  196. package/dist/models/assetMediaGrouping.d.ts.map +0 -1
  197. package/dist/models/assetMediaGrouping.js.map +0 -1
  198. package/dist/models/assetMediaGroupingMetaData.d.ts.map +0 -1
  199. package/dist/models/assetMediaGroupingMetaData.js.map +0 -1
  200. package/dist/models/batch.d.ts.map +0 -1
  201. package/dist/models/batch.js.map +0 -1
  202. package/dist/models/batchItem.d.ts.map +0 -1
  203. package/dist/models/batchItem.js.map +0 -1
  204. package/dist/models/batchTypes.d.ts.map +0 -1
  205. package/dist/models/batchTypes.js.map +0 -1
  206. package/dist/models/container.d.ts.map +0 -1
  207. package/dist/models/container.js.map +0 -1
  208. package/dist/models/contentDefinitionTypeID.d.ts.map +0 -1
  209. package/dist/models/contentDefinitionTypeID.js.map +0 -1
  210. package/dist/models/contentItem.d.ts.map +0 -1
  211. package/dist/models/contentItem.js.map +0 -1
  212. package/dist/models/contentItemHistory.d.ts.map +0 -1
  213. package/dist/models/contentItemHistory.js.map +0 -1
  214. package/dist/models/contentListFilterModel.d.ts.map +0 -1
  215. package/dist/models/contentListFilterModel.js.map +0 -1
  216. package/dist/models/contentSectionDefaultModule.d.ts.map +0 -1
  217. package/dist/models/contentSectionDefaultModule.js.map +0 -1
  218. package/dist/models/contentSectionDefinition.d.ts.map +0 -1
  219. package/dist/models/contentSectionDefinition.js.map +0 -1
  220. package/dist/models/contentViewColumn.d.ts.map +0 -1
  221. package/dist/models/contentViewColumn.js.map +0 -1
  222. package/dist/models/exception.d.ts.map +0 -1
  223. package/dist/models/exception.js.map +0 -1
  224. package/dist/models/instanceRole.d.ts.map +0 -1
  225. package/dist/models/instanceRole.js.map +0 -1
  226. package/dist/models/instanceUser.d.ts.map +0 -1
  227. package/dist/models/instanceUser.js.map +0 -1
  228. package/dist/models/itemComments.d.ts.map +0 -1
  229. package/dist/models/itemComments.js.map +0 -1
  230. package/dist/models/listParams.d.ts.map +0 -1
  231. package/dist/models/listParams.js.map +0 -1
  232. package/dist/models/locales.d.ts.map +0 -1
  233. package/dist/models/locales.js.map +0 -1
  234. package/dist/models/media.d.ts.map +0 -1
  235. package/dist/models/media.js.map +0 -1
  236. package/dist/models/model.d.ts.map +0 -1
  237. package/dist/models/model.js.map +0 -1
  238. package/dist/models/notification.d.ts.map +0 -1
  239. package/dist/models/notification.js.map +0 -1
  240. package/dist/models/options.d.ts.map +0 -1
  241. package/dist/models/options.js.map +0 -1
  242. package/dist/models/pageHistory.d.ts.map +0 -1
  243. package/dist/models/pageHistory.js.map +0 -1
  244. package/dist/models/pageItem.d.ts.map +0 -1
  245. package/dist/models/pageItem.js.map +0 -1
  246. package/dist/models/pageModel.d.ts.map +0 -1
  247. package/dist/models/pageModel.js.map +0 -1
  248. package/dist/models/serverUser.d.ts.map +0 -1
  249. package/dist/models/serverUser.js.map +0 -1
  250. package/dist/models/sharedModule.d.ts.map +0 -1
  251. package/dist/models/sharedModule.js.map +0 -1
  252. package/dist/models/sitemap.d.ts.map +0 -1
  253. package/dist/models/sitemap.js.map +0 -1
  254. package/dist/models/webhook.d.ts.map +0 -1
  255. package/dist/models/webhook.js.map +0 -1
  256. package/dist/models/websiteListing.d.ts.map +0 -1
  257. package/dist/models/websiteListing.js.map +0 -1
  258. package/dist/models/websiteUser.d.ts.map +0 -1
  259. package/dist/models/websiteUser.js.map +0 -1
package/README.md CHANGED
@@ -1,317 +1,371 @@
1
- # Agility CMS & Management API TypeScript SDK
2
-
3
- ## Table of Contents
4
-
5
- - [About the Management API SDK](#about-the-management-api-sdk)
6
- - [Getting Started](#getting-started)
7
- - [Authentication & Setup](./docs/auth.md)
8
- - [API Method Classes](#api-method-classes)
9
- - [Examples](#examples)
10
- - [TypeScript Interfaces](#typescript-interfaces)
11
- - [Available Enums](#available-enums)
12
-
13
- ---
14
-
15
- ## About the Management API SDK
16
-
17
- - Provides a facility to developers to use the new Agility Management API more effectively.
18
- - Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
19
- - **Content and Page Creation** - Create individual or multiple content items and pages (which automatically get added to batches).
20
- - **Essential batch workflow operations** - Perform publish, unpublish, approve, decline, and request approval operations on existing batches.
21
- - Ability to generate Content in bulk for a Website.
22
- - **Strongly typed TypeScript interfaces** for all batch operations with comprehensive error handling.
23
-
24
- ## Getting Started
25
-
26
- ### Prerequisites
27
- 1. Clone the repository agility-cms-management-sdk-typescript.
28
- 2. Import the index file to make use of the Options class.
29
- 3. You will need valid Agility CMS credentials to authenticate and obtain an access token.
30
-
31
- ### Authentication
32
- For detailed authentication instructions, including OAuth 2.0 setup, token management, and security best practices, see the **[Authentication & Setup Guide](./docs/auth.md)**.
33
-
34
- ### Making a Request
35
-
36
- #### Simple OAuth Authentication (Recommended)
37
-
38
- 1. First, initiate the authorization flow by making a GET request to the authorization endpoint:
39
- ```javascript
40
- const authUrl = 'https://mgmt.aglty.io/oauth/authorize';
41
-
42
- //if you wish to implement offline access using refresh tokens, use this URL (enables refresh tokens)
43
- //const authUrl = 'https://mgmt.aglty.io/oauth/authorize?scope=offline-access ';
44
-
45
- const params = new URLSearchParams({
46
- response_type: 'code',
47
- redirect_uri: 'YOUR_REDIRECT_URI',
48
- state: 'YOUR_STATE',
49
- scope: 'openid profile email offline_access'
50
- });
51
-
52
- // Redirect the user to the authorization URL
53
- window.location.href = `${authUrl}?${params.toString()}`;
54
- ```
55
-
56
- 2. After successful authentication, you'll receive an authorization code at your redirect URI. Use this code to obtain an access token:
57
- ```javascript
58
- const response = await fetch('https://mgmt.aglty.io/oauth/token', {
59
- method: 'POST',
60
- headers: {
61
- 'Content-Type': 'application/x-www-form-urlencoded'
62
- },
63
- body: new URLSearchParams({
64
- code: 'YOUR_AUTHORIZATION_CODE'
65
- })
66
- });
67
-
68
- const { access_token, refresh_token, expires_in } = await response.json();
69
- ```
70
-
71
- 3. Use the obtained token to initialize the SDK:
72
- ```javascript
73
- import * as mgmtApi from "@agility/management-sdk";
74
-
75
- // Initialize the Options Class with your authentication token
76
- let options = new mgmtApi.Options();
77
- options.token = access_token; // Use the token obtained from authentication
78
-
79
- // Initialize the APIClient Class
80
- let apiClient = new mgmtApi.ApiClient(options);
81
-
82
- let guid = "<<Provide the Guid of the Website>>";
83
- let locale = "<<Provide the locale of the Website>>"; // Example: en-us
84
-
85
- // Now you can make authenticated requests
86
- var contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
87
- console.log(JSON.stringify(contentItem));
88
- ```
89
-
90
- 4. When the access token expires, use the refresh token to obtain a new access token:
91
- ```javascript
92
- const response = await fetch('https://mgmt.aglty.io/oauth/refresh', {
93
- method: 'POST',
94
- headers: {
95
- 'Content-Type': 'application/json'
96
- },
97
- body: JSON.stringify({
98
- refresh_token: 'YOUR_REFRESH_TOKEN'
99
- })
100
- });
101
-
102
- const { access_token, refresh_token, expires_in } = await response.json();
103
- ```
104
-
105
-
106
- #### Manual Token Authentication (For CI/CD)
107
- ```typescript
108
- import * as mgmtApi from "@agility/management-sdk";
109
-
110
- // Token-based approach for CI/CD and automated environments
111
- const options = new mgmtApi.Options();
112
- options.token = process.env.AGILITY_API_TOKEN;
113
- const apiClient = new mgmtApi.ApiClient(options);
114
-
115
- const guid = process.env.AGILITY_GUID;
116
- const locale = "en-us";
117
-
118
- const contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
119
- console.log('Content retrieved:', contentItem.fields.title);
120
- ```
121
-
122
- > 💡 **Note**: The new OAuth authentication requires `keytar` for secure token storage. See the [Authentication & Setup Guide](./docs/auth.md) for OAuth setup or [CI/CD & Automated Environments](./docs/cicd.md) for token-based authentication.
123
-
124
- ## API Method Classes
125
-
126
- ### File and Media Management
127
- - **[AssetMethods](./docs/asset-methods.md)** - File and media management operations (15 functions)
128
- - [deleteFile](./docs/asset-methods.md#deletefile), [moveFile](./docs/asset-methods.md#movefile), [getMediaList](./docs/asset-methods.md#getmedialist), [getGalleries](./docs/asset-methods.md#getgalleries), [getGalleryById](./docs/asset-methods.md#getgallerybyid), [getGalleryByName](./docs/asset-methods.md#getgallerybyname), [getDefaultContainer](./docs/asset-methods.md#getdefaultcontainer), [saveGallery](./docs/asset-methods.md#savegallery), [deleteGallery](./docs/asset-methods.md#deletegallery), [getAssetByID](./docs/asset-methods.md#getassetbyid), [getAssetByUrl](./docs/asset-methods.md#getassetbyurl), [upload](./docs/asset-methods.md#upload), [createFolder](./docs/asset-methods.md#createfolder), [deleteFolder](./docs/asset-methods.md#deletefolder), [renameFolder](./docs/asset-methods.md#renamefolder)
129
-
130
- ### Workflow Operations
131
- - **[BatchMethods](./docs/batch-methods.md)** - Batch workflow operations (7 functions)
132
- - [getBatch](./docs/batch-methods.md#getbatch), [publishBatch](./docs/batch-methods.md#publishbatch), [unpublishBatch](./docs/batch-methods.md#unpublishbatch), [approveBatch](./docs/batch-methods.md#approvebatch), [declineBatch](./docs/batch-methods.md#declinebatch), [requestApprovalBatch](./docs/batch-methods.md#requestapprovalbatch), [getBatchTypes](./docs/batch-methods.md#getbatchtypes)
133
-
134
- ### Content Management
135
- - **[ContainerMethods](./docs/container-methods.md)** - Container management operations (8 functions)
136
- - [getContainerByID](./docs/container-methods.md#getcontainerbyid), [getContainersByModel](./docs/container-methods.md#getcontainersbymodel), [getContainerByReferenceName](./docs/container-methods.md#getcontainerbyreferencename), [getContainerSecurity](./docs/container-methods.md#getcontainersecurity), [getContainerList](./docs/container-methods.md#getcontainerlist), [getNotificationList](./docs/container-methods.md#getnotificationlist), [saveContainer](./docs/container-methods.md#savecontainer), [deleteContainer](./docs/container-methods.md#deletecontainer)
137
-
138
- - **[ContentMethods](./docs/content-methods.md)** - Content item operations (13 functions)
139
- - [getContentItem](./docs/content-methods.md#getcontentitem), [publishContent](./docs/content-methods.md#publishcontent), [unPublishContent](./docs/content-methods.md#unpublishcontent), [contentRequestApproval](./docs/content-methods.md#contentrequestapproval), [approveContent](./docs/content-methods.md#approvecontent), [declineContent](./docs/content-methods.md#declinecontent), [deleteContent](./docs/content-methods.md#deletecontent), [saveContentItem](./docs/content-methods.md#savecontentitem), [saveContentItems](./docs/content-methods.md#savecontentitems), [getContentItems](./docs/content-methods.md#getcontentitems), [getContentList](./docs/content-methods.md#getcontentlist), [getContentHistory](./docs/content-methods.md#getcontenthistory), [getContentComments](./docs/content-methods.md#getcontentcomments)
140
-
141
- - **[ModelMethods](./docs/model-methods.md)** - Content model operations (6 functions)
142
- - [getContentModel](./docs/model-methods.md#getcontentmodel), [getModelByReferenceName](./docs/model-methods.md#getmodelbyreferencename), [getContentModules](./docs/model-methods.md#getcontentmodules), [getPageModules](./docs/model-methods.md#getpagemodules), [saveModel](./docs/model-methods.md#savemodel), [deleteModel](./docs/model-methods.md#deletemodel)
143
-
144
- ### Page Management
145
- - **[PageMethods](./docs/page-methods.md)** - Page management operations (17 functions)
146
- - [getPage](./docs/page-methods.md#getpage), [getPageByPath](./docs/page-methods.md#getpagebypath), [getPageHistory](./docs/page-methods.md#getpagehistory), [getPageComments](./docs/page-methods.md#getpagecomments), [getPageList](./docs/page-methods.md#getpagelist), [getPageListByPageTemplateID](./docs/page-methods.md#getpagelistbypagetemplateid), [getPageListByPage](./docs/page-methods.md#getpagelistbypage), [getPageListByPageAndPageTemplateID](./docs/page-methods.md#getpagelistbypageandpagetemplateid), [getPageTree](./docs/page-methods.md#getpagetree), [getPageTemplateList](./docs/page-methods.md#getpagetemplatelist), [getPageSecurity](./docs/page-methods.md#getpagesecurity), [getPageItemTemplateList](./docs/page-methods.md#getpageitemtemplatelist), [getPageContentZones](./docs/page-methods.md#getpagecontentzones), [savePage](./docs/page-methods.md#savepage), [savePageSecurity](./docs/page-methods.md#savepagesecurity), [movePageItem](./docs/page-methods.md#movepageitem), [deletePage](./docs/page-methods.md#deletepage)
147
-
148
- ### User Management
149
- - **[InstanceMethods](./docs/instance-methods.md)** - Instance-level operations (1 function)
150
- - [getLocales](./docs/instance-methods.md#getlocales)
151
-
152
- - **[InstanceUserMethods](./docs/instance-user-methods.md)** - Instance user management (3 functions)
153
- - [getUsers](./docs/instance-user-methods.md#getusers), [saveUser](./docs/instance-user-methods.md#saveuser), [deleteUser](./docs/instance-user-methods.md#deleteuser)
154
-
155
- - **[ServerUserMethods](./docs/server-user-methods.md)** - Server user operations (2 functions)
156
- - [me](./docs/server-user-methods.md#me), [you](./docs/server-user-methods.md#you)
157
-
158
- ### Integration
159
- - **[WebhookMethods](./docs/webhook-methods.md)** - Webhook management (4 functions)
160
- - [getWebhook](./docs/webhook-methods.md#getwebhook), [webhookList](./docs/webhook-methods.md#webhooklist), [saveWebhook](./docs/webhook-methods.md#savewebhook), [deleteWebhook](./docs/webhook-methods.md#deletewebhook)
161
-
162
- ### Multi-Instance Operations
163
- - **[Multi-Instance Operations](./docs/multi-instance-operations.md)** - Advanced workflows for managing content across multiple instances and locales
164
- - Configuration-driven content creation across multiple environments
165
- - Parallel processing and batch operations
166
- - Performance optimization and error handling
167
- - Cross-instance synchronization and reporting
168
-
169
- ### CI/CD & Automation
170
- - **[CI/CD & Automated Environments](./docs/cicd.md)** - Token-based authentication for automated environments
171
- - CI/CD pipeline examples (GitHub Actions, GitLab CI, Jenkins)
172
- - Serverless functions (AWS Lambda, Vercel)
173
- - Environment configuration and security best practices
174
- - Token management and rotation
175
-
176
- ## Examples
177
-
178
- ### Understanding Agility CMS Batch Architecture
179
-
180
- Agility CMS uses a simple approach for working with content and batches:
181
-
182
- #### Content/Page Creation (Handled by Respective Controllers)
183
- - **contentMethods.saveContentItem()** - Creates a single new content item and adds it to a batch
184
- - **contentMethods.saveContentItems()** - Creates multiple new content items and adds them to a batch
185
- - **pageMethods.savePage()** - Creates a new page and adds it to a batch
186
- - These methods create the content AND automatically handle batch creation/management
187
-
188
- #### Batch Workflow Operations (Handled by Batch Controller)
189
- - **batchMethods.publishBatch()** - Publishes all items in an existing batch
190
- - **batchMethods.unpublishBatch()** - Unpublishes all items in an existing batch
191
- - **batchMethods.approveBatch()** - Approves all items in an existing batch
192
- - **batchMethods.declineBatch()** - Declines all items in an existing batch
193
- - **batchMethods.requestApprovalBatch()** - Requests approval for all items in an existing batch
194
- - **batchMethods.getBatch()** - Retrieves details of an existing batch
195
- - **batchMethods.getBatchTypes()** - Retrieves all batch-related enum types for developer discovery
196
-
197
- ### Complete Workflow Example
198
-
199
- ```typescript
200
- import * as mgmtApi from '@agility/management-sdk';
201
-
202
- // Authenticate with simple OAuth flow
203
- const client = new mgmtApi.ApiClient();
204
- await client.auth();
205
-
206
- const guid = 'your-instance-guid';
207
- const locale = 'en-us';
208
-
209
- // Get batch types for dynamic UI and validation
210
- const batchTypes = await client.batchMethods.getBatchTypes(guid);
211
- console.log('Available batch types loaded:', batchTypes);
212
-
213
- // Create NEW content items (handled by content controller)
214
- // This automatically creates and manages batches
215
- const newContentBatchID = await client.contentMethods.saveContentItem(locale, {
216
- properties: {
217
- referenceName: 'blog-post',
218
- definitionName: 'BlogPost',
219
- state: 2
220
- },
221
- fields: {
222
- title: 'My New Blog Post',
223
- content: 'This is the blog post content...'
224
- }
225
- });
226
-
227
- // Create NEW page (handled by page controller)
228
- // This automatically creates and manages batches
229
- const newPageBatchID = await client.pageMethods.savePage(locale, {
230
- name: 'new-product-page',
231
- title: 'New Product Page',
232
- menuText: 'New Product',
233
- pageType: 'static',
234
- templateName: 'Product Template',
235
- parentPageID: -1
236
- });
237
-
238
- // Retrieve details of an existing batch
239
- const batchDetails = await client.batchMethods.getBatch(newContentBatchID, guid);
240
- console.log('Batch details:', batchDetails);
241
-
242
- // Perform workflow operations on existing batches
243
- await client.batchMethods.publishBatch(newContentBatchID, guid);
244
- await client.batchMethods.approveBatch(newPageBatchID, guid);
245
-
246
- // Or use immediate return for custom polling
247
- const batchId = await client.batchMethods.publishBatch(newContentBatchID, guid, true);
248
- console.log('Batch submitted for publishing:', batchId);
249
-
250
- console.log('All operations completed successfully!');
251
- ```
252
-
253
- ## TypeScript Interfaces
254
-
255
- ### Batch Response Interfaces
256
-
257
- ```typescript
258
- interface BatchTypesResponse {
259
- itemTypes: EnumInfo[]; // Page, ContentItem, ContentList, Tag, ModuleDef
260
- operationTypes: EnumInfo[]; // All operation types
261
- workflowOperations: EnumInfo[]; // Publish, Unpublish, Approve, Decline, RequestApproval
262
- states: EnumInfo[]; // None, Pending, InProcess, Processed, Deleted
263
- }
264
-
265
- interface EnumInfo {
266
- value: number; // Numeric enum value
267
- name: string; // String name (e.g., "Publish")
268
- description: string; // Human-readable description
269
- }
270
- ```
271
-
272
- ## Available Enums
273
-
274
- ### WorkflowOperationType (for batch processing)
275
- > **Note**: In the API documentation (Swagger UI), these operations appear as descriptive dropdown options (Publish, Unpublish, Approve, Decline, RequestApproval) instead of numbers.
276
-
277
- - `Publish = 1`
278
- - `Unpublish = 2`
279
- - `Approve = 3`
280
- - `Decline = 4`
281
- - `RequestApproval = 5`
282
-
283
- ### BatchItemType
284
- > **Note**: In the API documentation (Swagger UI), these appear as descriptive dropdown options (Page, ContentItem, ContentList, Tag, ModuleDef) instead of numbers.
285
-
286
- - `Page = 1`
287
- - `ContentItem = 2`
288
- - `ContentList = 3`
289
- - `Tag = 4`
290
- - `ModuleDef = 5`
291
-
292
- ### BatchState
293
- > **Note**: In the API documentation (Swagger UI), these appear as descriptive names (None, Pending, InProcess, Processed, Deleted) instead of numbers.
294
-
295
- - `None = 0` - Batch created but not submitted for processing
296
- - `Pending = 1` - Batch is pending processing
297
- - `InProcess = 2` - Batch is currently being processed
298
- - `Processed = 3` - Batch has been processed successfully
299
- - `Deleted = 4` - Batch has been deleted
300
-
301
- ## Error Handling
302
-
303
- All methods throw exceptions on failure:
304
-
305
- ```typescript
306
- try {
307
- const batch = await client.batchMethods.getBatch(123, 'instance-guid');
308
- } catch (error) {
309
- console.error('Failed to get batch:', error.message);
310
- }
311
- ```
312
-
313
- ## License
314
-
315
- MIT
316
-
317
- If you have feedback or questions about this starter, please use the [Github Issues](https://github.com/agility/agility-cms-management-sdk-typescript/issues) on this repo, join our [Community Slack Channel](https://join.slack.com/t/agilitycommunity/shared_invite/enQtNzI2NDc3MzU4Njc2LWI2OTNjZTI3ZGY1NWRiNTYzNmEyNmI0MGZlZTRkYzI3NmRjNzkxYmI5YTZjNTg2ZTk4NGUzNjg5NzY3OWViZGI) or create a post on the [Agility Developer Community](https://help.agilitycms.com/hc/en-us/community/topics).
1
+ # Agility CMS & Management API TypeScript SDK
2
+
3
+ ## Table of Contents
4
+
5
+ - [About the Management API SDK](#about-the-management-api-sdk)
6
+ - [Getting Started](#getting-started)
7
+ - [Authentication & Setup](./docs/auth.md)
8
+ - [API Method Classes](#api-method-classes)
9
+ - [Examples](#examples)
10
+ - [TypeScript Interfaces](#typescript-interfaces)
11
+ - [Available Enums](#available-enums)
12
+
13
+ ---
14
+
15
+ ## About the Management API SDK
16
+
17
+ - Provides a facility to developers to use the new Agility Management API more effectively.
18
+ - Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
19
+ - **Content and Page Creation** - Create individual or multiple content items and pages (which automatically get added to batches).
20
+ - **Essential batch workflow operations** - Perform publish, unpublish, approve, decline, and request approval operations on existing batches.
21
+ - Ability to generate Content in bulk for a Website.
22
+ - **Strongly typed TypeScript interfaces** for all batch operations with comprehensive error handling.
23
+
24
+ ## Getting Started
25
+
26
+ ### Prerequisites
27
+ 1. Clone the repository agility-cms-management-sdk-typescript.
28
+ 2. Import the index file to make use of the Options class.
29
+ 3. You will need valid Agility CMS credentials to authenticate and obtain an access token.
30
+
31
+ ### Authentication
32
+ For detailed authentication instructions, including OAuth 2.0 setup, token management, and security best practices, see the **[Authentication & Setup Guide](./docs/auth.md)**.
33
+
34
+ ### Making a Request
35
+
36
+ #### Simple OAuth Authentication (Recommended)
37
+
38
+ 1. First, initiate the authorization flow by making a GET request to the authorization endpoint:
39
+ ```javascript
40
+ const authUrl = 'https://mgmt.aglty.io/oauth/authorize';
41
+
42
+ //if you wish to implement offline access using refresh tokens, use this URL (enables refresh tokens)
43
+ //const authUrl = 'https://mgmt.aglty.io/oauth/authorize?scope=offline-access ';
44
+
45
+ const params = new URLSearchParams({
46
+ response_type: 'code',
47
+ redirect_uri: 'YOUR_REDIRECT_URI',
48
+ state: 'YOUR_STATE',
49
+ scope: 'openid profile email offline_access'
50
+ });
51
+
52
+ // Redirect the user to the authorization URL
53
+ window.location.href = `${authUrl}?${params.toString()}`;
54
+ ```
55
+
56
+ 2. After successful authentication, you'll receive an authorization code at your redirect URI. Use this code to obtain an access token:
57
+ ```javascript
58
+ const response = await fetch('https://mgmt.aglty.io/oauth/token', {
59
+ method: 'POST',
60
+ headers: {
61
+ 'Content-Type': 'application/x-www-form-urlencoded'
62
+ },
63
+ body: new URLSearchParams({
64
+ code: 'YOUR_AUTHORIZATION_CODE'
65
+ })
66
+ });
67
+
68
+ const { access_token, refresh_token, expires_in } = await response.json();
69
+ ```
70
+
71
+ 3. Use the obtained token to initialize the SDK:
72
+ ```javascript
73
+ import * as mgmtApi from "@agility/management-sdk";
74
+
75
+ // Initialize the Options Class with your authentication token
76
+ let options = new mgmtApi.Options();
77
+ options.token = access_token; // Use the token obtained from authentication
78
+
79
+ // Initialize the APIClient Class
80
+ let apiClient = new mgmtApi.ApiClient(options);
81
+
82
+ let guid = "<<Provide the Guid of the Website>>";
83
+ let locale = "<<Provide the locale of the Website>>"; // Example: en-us
84
+
85
+ // Now you can make authenticated requests
86
+ var contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
87
+ console.log(JSON.stringify(contentItem));
88
+ ```
89
+
90
+ 4. When the access token expires, use the refresh token to obtain a new access token:
91
+ ```javascript
92
+ const response = await fetch('https://mgmt.aglty.io/oauth/refresh', {
93
+ method: 'POST',
94
+ headers: {
95
+ 'Content-Type': 'application/json'
96
+ },
97
+ body: JSON.stringify({
98
+ refresh_token: 'YOUR_REFRESH_TOKEN'
99
+ })
100
+ });
101
+
102
+ const { access_token, refresh_token, expires_in } = await response.json();
103
+ ```
104
+
105
+
106
+ #### Manual Token Authentication (For CI/CD)
107
+ ```typescript
108
+ import * as mgmtApi from "@agility/management-sdk";
109
+
110
+ // Token-based approach for CI/CD and automated environments
111
+ const options = new mgmtApi.Options();
112
+ options.token = process.env.AGILITY_API_TOKEN;
113
+ const apiClient = new mgmtApi.ApiClient(options);
114
+
115
+ const guid = process.env.AGILITY_GUID;
116
+ const locale = "en-us";
117
+
118
+ const contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
119
+ console.log('Content retrieved:', contentItem.fields.title);
120
+ ```
121
+
122
+ > 💡 **Note**: The new OAuth authentication requires `keytar` for secure token storage. See the [Authentication & Setup Guide](./docs/auth.md) for OAuth setup or [CI/CD & Automated Environments](./docs/cicd.md) for token-based authentication.
123
+
124
+ ## API Method Classes
125
+
126
+ ### File and Media Management
127
+ - **[AssetMethods](./docs/asset-methods.md)** - File and media management operations (15 functions)
128
+ - [deleteFile](./docs/asset-methods.md#deletefile), [moveFile](./docs/asset-methods.md#movefile), [getMediaList](./docs/asset-methods.md#getmedialist), [getGalleries](./docs/asset-methods.md#getgalleries), [getGalleryById](./docs/asset-methods.md#getgallerybyid), [getGalleryByName](./docs/asset-methods.md#getgallerybyname), [getDefaultContainer](./docs/asset-methods.md#getdefaultcontainer), [saveGallery](./docs/asset-methods.md#savegallery), [deleteGallery](./docs/asset-methods.md#deletegallery), [getAssetByID](./docs/asset-methods.md#getassetbyid), [getAssetByUrl](./docs/asset-methods.md#getassetbyurl), [upload](./docs/asset-methods.md#upload), [createFolder](./docs/asset-methods.md#createfolder), [deleteFolder](./docs/asset-methods.md#deletefolder), [renameFolder](./docs/asset-methods.md#renamefolder)
129
+
130
+ ### Workflow Operations
131
+ - **[BatchMethods](./docs/batch-methods.md)** - Batch workflow operations (7 functions)
132
+ - [getBatch](./docs/batch-methods.md#getbatch), [publishBatch](./docs/batch-methods.md#publishbatch), [unpublishBatch](./docs/batch-methods.md#unpublishbatch), [approveBatch](./docs/batch-methods.md#approvebatch), [declineBatch](./docs/batch-methods.md#declinebatch), [requestApprovalBatch](./docs/batch-methods.md#requestapprovalbatch), [getBatchTypes](./docs/batch-methods.md#getbatchtypes)
133
+
134
+ ### Content Management
135
+ - **[ContainerMethods](./docs/container-methods.md)** - Container management operations (8 functions)
136
+ - [getContainerByID](./docs/container-methods.md#getcontainerbyid), [getContainersByModel](./docs/container-methods.md#getcontainersbymodel), [getContainerByReferenceName](./docs/container-methods.md#getcontainerbyreferencename), [getContainerSecurity](./docs/container-methods.md#getcontainersecurity), [getContainerList](./docs/container-methods.md#getcontainerlist), [getNotificationList](./docs/container-methods.md#getnotificationlist), [saveContainer](./docs/container-methods.md#savecontainer), [deleteContainer](./docs/container-methods.md#deletecontainer)
137
+
138
+ - **[ContentMethods](./docs/content-methods.md)** - Content item operations (14 functions)
139
+ - [getContentItem](./docs/content-methods.md#getcontentitem), [publishContent](./docs/content-methods.md#publishcontent), [unPublishContent](./docs/content-methods.md#unpublishcontent), [batchWorkflowContent](./docs/content-methods.md#batchworkflowcontent), [contentRequestApproval](./docs/content-methods.md#contentrequestapproval), [approveContent](./docs/content-methods.md#approvecontent), [declineContent](./docs/content-methods.md#declinecontent), [deleteContent](./docs/content-methods.md#deletecontent), [saveContentItem](./docs/content-methods.md#savecontentitem), [saveContentItems](./docs/content-methods.md#savecontentitems), [getContentItems](./docs/content-methods.md#getcontentitems), [getContentList](./docs/content-methods.md#getcontentlist), [getContentHistory](./docs/content-methods.md#getcontenthistory), [getContentComments](./docs/content-methods.md#getcontentcomments)
140
+
141
+ - **[ModelMethods](./docs/model-methods.md)** - Content model operations (6 functions)
142
+ - [getContentModel](./docs/model-methods.md#getcontentmodel), [getModelByReferenceName](./docs/model-methods.md#getmodelbyreferencename), [getContentModules](./docs/model-methods.md#getcontentmodules), [getPageModules](./docs/model-methods.md#getpagemodules), [saveModel](./docs/model-methods.md#savemodel), [deleteModel](./docs/model-methods.md#deletemodel)
143
+
144
+ ### Page Management
145
+ - **[PageMethods](./docs/page-methods.md)** - Page management operations (18 functions)
146
+ - [getPage](./docs/page-methods.md#getpage), [getPageByPath](./docs/page-methods.md#getpagebypath), [getPageHistory](./docs/page-methods.md#getpagehistory), [getPageComments](./docs/page-methods.md#getpagecomments), [getPageList](./docs/page-methods.md#getpagelist), [getPageListByPageTemplateID](./docs/page-methods.md#getpagelistbypagetemplateid), [getPageListByPage](./docs/page-methods.md#getpagelistbypage), [getPageListByPageAndPageTemplateID](./docs/page-methods.md#getpagelistbypageandpagetemplateid), [getPageTree](./docs/page-methods.md#getpagetree), [getPageTemplateList](./docs/page-methods.md#getpagetemplatelist), [getPageSecurity](./docs/page-methods.md#getpagesecurity), [getPageItemTemplateList](./docs/page-methods.md#getpageitemtemplatelist), [getPageContentZones](./docs/page-methods.md#getpagecontentzones), [savePage](./docs/page-methods.md#savepage), [savePageSecurity](./docs/page-methods.md#savepagesecurity), [movePageItem](./docs/page-methods.md#movepageitem), [deletePage](./docs/page-methods.md#deletepage), [batchWorkflowPages](./docs/page-methods.md#batchworkflowpages)
147
+
148
+ ### User Management
149
+ - **[InstanceMethods](./docs/instance-methods.md)** - Instance-level operations (1 function)
150
+ - [getLocales](./docs/instance-methods.md#getlocales)
151
+
152
+ - **[InstanceUserMethods](./docs/instance-user-methods.md)** - Instance user management (3 functions)
153
+ - [getUsers](./docs/instance-user-methods.md#getusers), [saveUser](./docs/instance-user-methods.md#saveuser), [deleteUser](./docs/instance-user-methods.md#deleteuser)
154
+
155
+ - **[ServerUserMethods](./docs/server-user-methods.md)** - Server user operations (2 functions)
156
+ - [me](./docs/server-user-methods.md#me), [you](./docs/server-user-methods.md#you)
157
+
158
+ ### Integration
159
+ - **[WebhookMethods](./docs/webhook-methods.md)** - Webhook management (4 functions)
160
+ - [getWebhook](./docs/webhook-methods.md#getwebhook), [webhookList](./docs/webhook-methods.md#webhooklist), [saveWebhook](./docs/webhook-methods.md#savewebhook), [deleteWebhook](./docs/webhook-methods.md#deletewebhook)
161
+
162
+ ### Multi-Instance Operations
163
+ - **[Multi-Instance Operations](./docs/multi-instance-operations.md)** - Advanced workflows for managing content across multiple instances and locales
164
+ - Configuration-driven content creation across multiple environments
165
+ - Parallel processing and batch operations
166
+ - Performance optimization and error handling
167
+ - Cross-instance synchronization and reporting
168
+
169
+ ### CI/CD & Automation
170
+ - **[CI/CD & Automated Environments](./docs/cicd.md)** - Token-based authentication for automated environments
171
+ - CI/CD pipeline examples (GitHub Actions, GitLab CI, Jenkins)
172
+ - Serverless functions (AWS Lambda, Vercel)
173
+ - Environment configuration and security best practices
174
+ - Token management and rotation
175
+
176
+ ## Examples
177
+
178
+ ### Understanding Agility CMS Batch Architecture
179
+
180
+ Agility CMS uses a simple approach for working with content and batches:
181
+
182
+ #### Content/Page Creation (Handled by Respective Controllers)
183
+ - **contentMethods.saveContentItem()** - Creates a single new content item and adds it to a batch
184
+ - **contentMethods.saveContentItems()** - Creates multiple new content items and adds them to a batch
185
+ - **pageMethods.savePage()** - Creates a new page and adds it to a batch
186
+ - These methods create the content AND automatically handle batch creation/management
187
+
188
+ #### Batch Workflow Operations (Handled by Batch Controller)
189
+ - **batchMethods.publishBatch()** - Publishes all items in an existing batch
190
+ - **batchMethods.unpublishBatch()** - Unpublishes all items in an existing batch
191
+ - **batchMethods.approveBatch()** - Approves all items in an existing batch
192
+ - **batchMethods.declineBatch()** - Declines all items in an existing batch
193
+ - **batchMethods.requestApprovalBatch()** - Requests approval for all items in an existing batch
194
+ - **batchMethods.getBatch()** - Retrieves details of an existing batch
195
+ - **batchMethods.getBatchTypes()** - Retrieves all batch-related enum types for developer discovery
196
+
197
+ ### Complete Workflow Example
198
+
199
+ ```typescript
200
+ import * as mgmtApi from '@agility/management-sdk';
201
+
202
+ // Authenticate with simple OAuth flow
203
+ const client = new mgmtApi.ApiClient();
204
+ await client.auth();
205
+
206
+ const guid = 'your-instance-guid';
207
+ const locale = 'en-us';
208
+
209
+ // Get batch types for dynamic UI and validation
210
+ const batchTypes = await client.batchMethods.getBatchTypes(guid);
211
+ console.log('Available batch types loaded:', batchTypes);
212
+
213
+ // Create NEW content items (handled by content controller)
214
+ // This automatically creates and manages batches
215
+ const newContentBatchID = await client.contentMethods.saveContentItem(locale, {
216
+ properties: {
217
+ referenceName: 'blog-post',
218
+ definitionName: 'BlogPost',
219
+ state: 2
220
+ },
221
+ fields: {
222
+ title: 'My New Blog Post',
223
+ content: 'This is the blog post content...'
224
+ }
225
+ });
226
+
227
+ // Create NEW page (handled by page controller)
228
+ // This automatically creates and manages batches
229
+ const newPageBatchID = await client.pageMethods.savePage(locale, {
230
+ name: 'new-product-page',
231
+ title: 'New Product Page',
232
+ menuText: 'New Product',
233
+ pageType: 'static',
234
+ templateName: 'Product Template',
235
+ parentPageID: -1
236
+ });
237
+
238
+ // Retrieve details of an existing batch
239
+ const batchDetails = await client.batchMethods.getBatch(newContentBatchID, guid);
240
+ console.log('Batch details:', batchDetails);
241
+
242
+ // Perform workflow operations on existing batches
243
+ await client.batchMethods.publishBatch(newContentBatchID, guid);
244
+ await client.batchMethods.approveBatch(newPageBatchID, guid);
245
+
246
+ // Or use immediate return for custom polling
247
+ const batchId = await client.batchMethods.publishBatch(newContentBatchID, guid, true);
248
+ console.log('Batch submitted for publishing:', batchId);
249
+
250
+ console.log('All operations completed successfully!');
251
+ ```
252
+
253
+ ### Batch Workflow Operations
254
+
255
+ Perform workflow operations (publish, unpublish, approve, decline, request approval) on multiple content items or pages in a single operation using the `WorkflowOperationType` enum:
256
+
257
+ ```typescript
258
+ import * as mgmtApi from '@agility/management-sdk';
259
+ import { WorkflowOperationType } from '@agility/management-sdk';
260
+
261
+ const options = new mgmtApi.Options();
262
+ options.token = 'your-access-token';
263
+ const client = new mgmtApi.ApiClient(options);
264
+
265
+ const guid = 'your-instance-guid';
266
+ const locale = 'en-us';
267
+
268
+ // Batch publish multiple content items
269
+ const contentIDs = [101, 102, 103];
270
+ const publishedContentIDs = await client.contentMethods.batchWorkflowContent(
271
+ contentIDs, guid, locale, WorkflowOperationType.Publish
272
+ );
273
+ console.log('Published content IDs:', publishedContentIDs);
274
+
275
+ // Batch unpublish multiple content items
276
+ const unpublishedContentIDs = await client.contentMethods.batchWorkflowContent(
277
+ contentIDs, guid, locale, WorkflowOperationType.Unpublish
278
+ );
279
+ console.log('Unpublished content IDs:', unpublishedContentIDs);
280
+
281
+ // Batch approve multiple content items
282
+ const approvedContentIDs = await client.contentMethods.batchWorkflowContent(
283
+ contentIDs, guid, locale, WorkflowOperationType.Approve
284
+ );
285
+ console.log('Approved content IDs:', approvedContentIDs);
286
+
287
+ // Batch publish multiple pages
288
+ const pageIDs = [201, 202, 203];
289
+ const publishedPageIDs = await client.pageMethods.batchWorkflowPages(
290
+ pageIDs, guid, locale, WorkflowOperationType.Publish
291
+ );
292
+ console.log('Published page IDs:', publishedPageIDs);
293
+
294
+ // Batch unpublish multiple pages
295
+ const unpublishedPageIDs = await client.pageMethods.batchWorkflowPages(
296
+ pageIDs, guid, locale, WorkflowOperationType.Unpublish
297
+ );
298
+ console.log('Unpublished page IDs:', unpublishedPageIDs);
299
+
300
+ // Get batch ID immediately for custom polling (optional 5th parameter)
301
+ const [batchId] = await client.contentMethods.batchWorkflowContent(
302
+ contentIDs, guid, locale, WorkflowOperationType.Publish, true
303
+ );
304
+ console.log('Batch submitted, ID:', batchId);
305
+ ```
306
+
307
+ ## TypeScript Interfaces
308
+
309
+ ### Batch Response Interfaces
310
+
311
+ ```typescript
312
+ interface BatchTypesResponse {
313
+ itemTypes: EnumInfo[]; // Page, ContentItem, ContentList, Tag, ModuleDef
314
+ operationTypes: EnumInfo[]; // All operation types
315
+ workflowOperations: EnumInfo[]; // Publish, Unpublish, Approve, Decline, RequestApproval
316
+ states: EnumInfo[]; // None, Pending, InProcess, Processed, Deleted
317
+ }
318
+
319
+ interface EnumInfo {
320
+ value: number; // Numeric enum value
321
+ name: string; // String name (e.g., "Publish")
322
+ description: string; // Human-readable description
323
+ }
324
+ ```
325
+
326
+ ## Available Enums
327
+
328
+ ### WorkflowOperationType (for batch processing)
329
+ > **Note**: In the API documentation (Swagger UI), these operations appear as descriptive dropdown options (Publish, Unpublish, Approve, Decline, RequestApproval) instead of numbers.
330
+
331
+ - `Publish = 1`
332
+ - `Unpublish = 2`
333
+ - `Approve = 3`
334
+ - `Decline = 4`
335
+ - `RequestApproval = 5`
336
+
337
+ ### BatchItemType
338
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive dropdown options (Page, ContentItem, ContentList, Tag, ModuleDef) instead of numbers.
339
+
340
+ - `Page = 1`
341
+ - `ContentItem = 2`
342
+ - `ContentList = 3`
343
+ - `Tag = 4`
344
+ - `ModuleDef = 5`
345
+
346
+ ### BatchState
347
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive names (None, Pending, InProcess, Processed, Deleted) instead of numbers.
348
+
349
+ - `None = 0` - Batch created but not submitted for processing
350
+ - `Pending = 1` - Batch is pending processing
351
+ - `InProcess = 2` - Batch is currently being processed
352
+ - `Processed = 3` - Batch has been processed successfully
353
+ - `Deleted = 4` - Batch has been deleted
354
+
355
+ ## Error Handling
356
+
357
+ All methods throw exceptions on failure:
358
+
359
+ ```typescript
360
+ try {
361
+ const batch = await client.batchMethods.getBatch(123, 'instance-guid');
362
+ } catch (error) {
363
+ console.error('Failed to get batch:', error.message);
364
+ }
365
+ ```
366
+
367
+ ## License
368
+
369
+ MIT
370
+
371
+ If you have feedback or questions about this starter, please use the [Github Issues](https://github.com/agility/agility-cms-management-sdk-typescript/issues) on this repo, join our [Community Slack Channel](https://join.slack.com/t/agilitycommunity/shared_invite/enQtNzI2NDc3MzU4Njc2LWI2OTNjZTI3ZGY1NWRiNTYzNmEyNmI0MGZlZTRkYzI3NmRjNzkxYmI5YTZjNTg2ZTk4NGUzNjg5NzY3OWViZGI) or create a post on the [Agility Developer Community](https://help.agilitycms.com/hc/en-us/community/topics).