@agility/management-sdk 0.1.3 → 0.1.4-beta.1

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 (238) hide show
  1. package/.cursor/api-documentation-manifest.md +275 -0
  2. package/.cursor/api-functions-analysis.md +111 -0
  3. package/.cursor/docs-final-check.md +269 -0
  4. package/.cursor/manifest.md +153 -0
  5. package/.env +92 -0
  6. package/README.md +219 -352
  7. package/dist/apiClient.d.ts +86 -0
  8. package/dist/apiClient.js +229 -0
  9. package/dist/apiClient.js.map +1 -0
  10. package/dist/apiMethods/assetMethods.d.ts +28 -6
  11. package/dist/apiMethods/assetMethods.js +224 -29
  12. package/dist/apiMethods/assetMethods.js.map +1 -0
  13. package/dist/apiMethods/authMethods.d.ts +239 -0
  14. package/dist/apiMethods/authMethods.js +604 -0
  15. package/dist/apiMethods/batchMethods.d.ts +32 -1
  16. package/dist/apiMethods/batchMethods.js +241 -11
  17. package/dist/apiMethods/batchMethods.js.map +1 -0
  18. package/dist/apiMethods/clientInstance.d.ts +58 -4
  19. package/dist/apiMethods/clientInstance.js +311 -44
  20. package/dist/apiMethods/clientInstance.js.map +1 -0
  21. package/dist/apiMethods/containerMethods.d.ts +15 -7
  22. package/dist/apiMethods/containerMethods.js +70 -38
  23. package/dist/apiMethods/containerMethods.js.map +1 -0
  24. package/dist/apiMethods/contentMethods.d.ts +17 -10
  25. package/dist/apiMethods/contentMethods.js +169 -70
  26. package/dist/apiMethods/contentMethods.js.map +1 -0
  27. package/dist/apiMethods/instanceMethods.d.ts +9 -0
  28. package/dist/apiMethods/instanceMethods.js +69 -0
  29. package/dist/apiMethods/instanceMethods.js.map +1 -0
  30. package/dist/apiMethods/instanceUserMethods.d.ts +3 -3
  31. package/dist/apiMethods/instanceUserMethods.js +18 -18
  32. package/dist/apiMethods/instanceUserMethods.js.map +1 -0
  33. package/dist/apiMethods/modelMethods.d.ts +6 -5
  34. package/dist/apiMethods/modelMethods.js +46 -26
  35. package/dist/apiMethods/modelMethods.js.map +1 -0
  36. package/dist/apiMethods/pageMethods.d.ts +21 -9
  37. package/dist/apiMethods/pageMethods.js +278 -76
  38. package/dist/apiMethods/pageMethods.js.map +1 -0
  39. package/dist/apiMethods/serverUserMethods.d.ts +10 -0
  40. package/dist/apiMethods/serverUserMethods.js +89 -0
  41. package/dist/apiMethods/serverUserMethods.js.map +1 -0
  42. package/dist/apiMethods/webhookMethods.d.ts +12 -0
  43. package/dist/apiMethods/webhookMethods.js +131 -0
  44. package/dist/apiMethods/webhookMethods.js.map +1 -0
  45. package/dist/enums/assetGroupingType.d.ts +3 -0
  46. package/dist/enums/assetGroupingType.js +7 -0
  47. package/dist/enums/assetGroupingType.js.map +1 -0
  48. package/dist/enums/batchItemType.d.ts +7 -0
  49. package/dist/enums/batchItemType.js +11 -0
  50. package/dist/enums/batchOperationType.js +1 -1
  51. package/dist/enums/batchOperationType.js.map +1 -0
  52. package/dist/enums/batchState..js +1 -1
  53. package/dist/enums/batchState.d.ts +7 -0
  54. package/dist/enums/batchState.js +12 -0
  55. package/dist/enums/batchState.js.map +1 -0
  56. package/dist/enums/pageItemTemplateType.d.ts +4 -0
  57. package/dist/enums/pageItemTemplateType.js +8 -0
  58. package/dist/enums/pageItemTemplateType.js.map +1 -0
  59. package/dist/enums/workflowOperationType.d.ts +26 -0
  60. package/dist/enums/workflowOperationType.js +30 -0
  61. package/dist/errors/exception.d.ts +4 -0
  62. package/dist/errors/exception.js +11 -0
  63. package/dist/errors/exception.js.map +1 -0
  64. package/dist/index.d.ts +41 -9
  65. package/dist/index.js +48 -10
  66. package/dist/index.js.map +1 -0
  67. package/dist/models/assetContainer.d.ts +7 -0
  68. package/dist/models/assetContainer.js +9 -0
  69. package/dist/models/assetGalleries.d.ts +5 -0
  70. package/dist/models/assetGalleries.js +9 -0
  71. package/dist/models/assetMediaGrouping.d.ts +17 -0
  72. package/dist/models/assetMediaGrouping.js +9 -0
  73. package/dist/models/assetMediaGroupingMetaData.d.ts +4 -0
  74. package/dist/models/assetMediaGroupingMetaData.js +9 -0
  75. package/dist/models/authTokens.d.ts +73 -0
  76. package/dist/models/authTokens.js +2 -0
  77. package/dist/models/batchItem.d.ts +1 -0
  78. package/dist/models/batchRequests.d.ts +67 -0
  79. package/dist/models/batchRequests.js +2 -0
  80. package/dist/models/batchTypes.d.ts +34 -0
  81. package/dist/models/batchTypes.js +2 -0
  82. package/dist/models/container.d.ts +2 -1
  83. package/dist/models/contentDefinitionTypeID.d.ts +17 -0
  84. package/dist/models/contentDefinitionTypeID.js +21 -0
  85. package/dist/models/contentItemHistory.d.ts +20 -0
  86. package/dist/models/contentItemHistory.js +15 -0
  87. package/dist/models/contentListFilterModel.d.ts +26 -0
  88. package/dist/models/contentListFilterModel.js +33 -0
  89. package/dist/models/contentSectionDefaultModule.d.ts +7 -0
  90. package/dist/models/contentSectionDefaultModule.js +9 -0
  91. package/dist/models/contentSectionDefinition.d.ts +35 -0
  92. package/dist/models/contentSectionDefinition.js +9 -0
  93. package/dist/models/exception.js +2 -0
  94. package/dist/models/itemComments.d.ts +14 -0
  95. package/dist/models/itemComments.js +15 -0
  96. package/dist/models/listParams.d.ts +9 -0
  97. package/dist/models/listParams.js +16 -0
  98. package/dist/models/locales.d.ts +3 -0
  99. package/dist/models/locales.js +30 -0
  100. package/dist/models/options.d.ts +2 -5
  101. package/dist/models/options.js +0 -19
  102. package/dist/models/pageHistory.d.ts +21 -0
  103. package/dist/models/pageHistory.js +15 -0
  104. package/dist/models/pageModel.d.ts +14 -0
  105. package/dist/models/pageModel.js +9 -0
  106. package/dist/models/serverUser.d.ts +21 -0
  107. package/dist/models/serverUser.js +9 -0
  108. package/dist/models/sharedModule.d.ts +7 -0
  109. package/dist/models/sharedModule.js +9 -0
  110. package/dist/models/webhook.d.ts +9 -0
  111. package/dist/models/webhook.js +9 -0
  112. package/dist/models/websiteListing.d.ts +16 -0
  113. package/dist/models/websiteListing.js +9 -0
  114. package/dist/tests/authHelper.d.ts +2 -0
  115. package/dist/tests/authHelper.js +14 -0
  116. package/dist/tests/authHelper.js.map +1 -0
  117. package/dist/tests/config/apiClient.config.d.ts +16 -0
  118. package/dist/tests/config/apiClient.config.js +84 -0
  119. package/dist/tests/config/apiClient.config.js.map +1 -0
  120. package/dist/tests/config/test.config.d.ts +24 -0
  121. package/dist/tests/config/test.config.js +47 -0
  122. package/dist/tests/config/test.config.js.map +1 -0
  123. package/dist/tokenStorage.d.ts +72 -0
  124. package/dist/tokenStorage.js +366 -0
  125. package/dist/types/apiResponse.d.ts +13 -0
  126. package/dist/types/apiResponse.js +3 -0
  127. package/dist/types/apiResponse.js.map +1 -0
  128. package/dist/types/assetContainer.d.ts +7 -0
  129. package/dist/types/assetContainer.js +3 -0
  130. package/dist/types/assetContainer.js.map +1 -0
  131. package/dist/types/assetGalleries.d.ts +5 -0
  132. package/dist/types/assetGalleries.js +3 -0
  133. package/dist/types/assetGalleries.js.map +1 -0
  134. package/dist/types/assetMediaGrouping.d.ts +17 -0
  135. package/dist/types/assetMediaGrouping.js +3 -0
  136. package/dist/types/assetMediaGrouping.js.map +1 -0
  137. package/dist/types/assetMediaGroupingMetaData.d.ts +4 -0
  138. package/dist/types/assetMediaGroupingMetaData.js +3 -0
  139. package/dist/types/assetMediaGroupingMetaData.js.map +1 -0
  140. package/dist/types/batch.d.ts +29 -0
  141. package/dist/types/batch.js +3 -0
  142. package/dist/types/batch.js.map +1 -0
  143. package/dist/types/batchItem.d.ts +13 -0
  144. package/dist/types/batchItem.js +3 -0
  145. package/dist/types/batchItem.js.map +1 -0
  146. package/dist/types/container.d.ts +47 -0
  147. package/dist/types/container.js +3 -0
  148. package/dist/types/container.js.map +1 -0
  149. package/dist/types/contentItem.d.ts +37 -0
  150. package/dist/types/contentItem.js +3 -0
  151. package/dist/types/contentItem.js.map +1 -0
  152. package/dist/types/contentItemHistory.d.ts +20 -0
  153. package/dist/types/contentItemHistory.js +3 -0
  154. package/dist/types/contentItemHistory.js.map +1 -0
  155. package/dist/types/contentListFilterModel.d.ts +26 -0
  156. package/dist/types/contentListFilterModel.js +3 -0
  157. package/dist/types/contentListFilterModel.js.map +1 -0
  158. package/dist/types/contentSectionDefaultModule.d.ts +7 -0
  159. package/dist/types/contentSectionDefaultModule.js +3 -0
  160. package/dist/types/contentSectionDefaultModule.js.map +1 -0
  161. package/dist/types/contentSectionDefinition.d.ts +35 -0
  162. package/dist/types/contentSectionDefinition.js +3 -0
  163. package/dist/types/contentSectionDefinition.js.map +1 -0
  164. package/dist/types/contentViewColumn.d.ts +8 -0
  165. package/dist/types/contentViewColumn.js +3 -0
  166. package/dist/types/contentViewColumn.js.map +1 -0
  167. package/dist/types/instanceRole.d.ts +7 -0
  168. package/dist/types/instanceRole.js +3 -0
  169. package/dist/types/instanceRole.js.map +1 -0
  170. package/dist/types/instanceUser.d.ts +14 -0
  171. package/dist/types/instanceUser.js +3 -0
  172. package/dist/types/instanceUser.js.map +1 -0
  173. package/dist/types/itemComments.d.ts +14 -0
  174. package/dist/types/itemComments.js +3 -0
  175. package/dist/types/itemComments.js.map +1 -0
  176. package/dist/types/listParams.d.ts +9 -0
  177. package/dist/types/listParams.js +3 -0
  178. package/dist/types/listParams.js.map +1 -0
  179. package/dist/types/locales.d.ts +1 -0
  180. package/dist/types/locales.js +3 -0
  181. package/dist/types/locales.js.map +1 -0
  182. package/dist/types/media.d.ts +30 -0
  183. package/dist/types/media.js +3 -0
  184. package/dist/types/media.js.map +1 -0
  185. package/dist/types/model.d.ts +30 -0
  186. package/dist/types/model.js +3 -0
  187. package/dist/types/model.js.map +1 -0
  188. package/dist/types/notification.d.ts +13 -0
  189. package/dist/types/notification.js +3 -0
  190. package/dist/types/notification.js.map +1 -0
  191. package/dist/types/options.d.ts +7 -0
  192. package/dist/types/options.js +3 -0
  193. package/dist/types/options.js.map +1 -0
  194. package/dist/types/pageHistory.d.ts +21 -0
  195. package/dist/types/pageHistory.js +3 -0
  196. package/dist/types/pageHistory.js.map +1 -0
  197. package/dist/types/pageItem.d.ts +56 -0
  198. package/dist/types/pageItem.js +3 -0
  199. package/dist/types/pageItem.js.map +1 -0
  200. package/dist/types/pageModel.d.ts +14 -0
  201. package/dist/types/pageModel.js +3 -0
  202. package/dist/types/pageModel.js.map +1 -0
  203. package/dist/types/serverUser.d.ts +21 -0
  204. package/dist/types/serverUser.js +3 -0
  205. package/dist/types/serverUser.js.map +1 -0
  206. package/dist/types/sharedModule.d.ts +7 -0
  207. package/dist/types/sharedModule.js +3 -0
  208. package/dist/types/sharedModule.js.map +1 -0
  209. package/dist/types/sitemap.d.ts +20 -0
  210. package/dist/types/sitemap.js +3 -0
  211. package/dist/types/sitemap.js.map +1 -0
  212. package/dist/types/tokenResponseData.d.ts +10 -0
  213. package/dist/types/tokenResponseData.js +3 -0
  214. package/dist/types/tokenResponseData.js.map +1 -0
  215. package/dist/types/webhook.d.ts +9 -0
  216. package/dist/types/webhook.js +3 -0
  217. package/dist/types/webhook.js.map +1 -0
  218. package/dist/types/websiteListing.d.ts +16 -0
  219. package/dist/types/websiteListing.js +3 -0
  220. package/dist/types/websiteListing.js.map +1 -0
  221. package/dist/types/websiteUser.d.ts +22 -0
  222. package/dist/types/websiteUser.js +3 -0
  223. package/dist/types/websiteUser.js.map +1 -0
  224. package/docs/asset-methods.md +382 -0
  225. package/docs/auth.md +594 -0
  226. package/docs/batch-methods.md +244 -0
  227. package/docs/cicd.md +607 -0
  228. package/docs/container-methods.md +268 -0
  229. package/docs/content-methods.md +423 -0
  230. package/docs/instance-methods.md +105 -0
  231. package/docs/instance-user-methods.md +231 -0
  232. package/docs/model-methods.md +434 -0
  233. package/docs/multi-instance-operations.md +192 -0
  234. package/docs/page-methods.md +671 -0
  235. package/docs/server-user-methods.md +280 -0
  236. package/docs/webhook-methods.md +452 -0
  237. package/package.json +14 -10
  238. package/tsconfig.json +1 -1
package/README.md CHANGED
@@ -1,396 +1,263 @@
1
1
  # Agility CMS & Management API TypeScript SDK
2
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
+
3
15
  ## About the Management API SDK
4
16
 
5
17
  - Provides a facility to developers to use the new Agility Management API more effectively.
6
18
  - Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
7
- - Supports the creation of Pages and Content in batches.
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.
8
21
  - Ability to generate Content in bulk for a Website.
22
+ - **Strongly typed TypeScript interfaces** for all batch operations with comprehensive error handling.
9
23
 
10
24
  ## Getting Started
11
25
 
12
26
  ### Prerequisites
13
27
  1. Clone the repository agility-cms-management-sdk-typescript.
14
28
  2. Import the index file to make use of the Options class.
15
- 3. Create an object of the Options class to provide values of -
16
- - token -> Bearer token to authenticate a Rest Request to perform an operation.
17
- - locale -> The locale under which your application is hosted. Example en-us.
18
- - guid -> The guid under which your application is hosted.
19
- 4. Create an object of Method class(es), which can be used to create and perform operations. Following is the description of Classes and their respective methods -
29
+ 3. You will need valid Agility CMS credentials to authenticate and obtain an access token.
20
30
 
21
- ### Making a Request
22
- ```Javascript
23
- import * as index from "./index";
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)**.
24
33
 
25
- //initialize the Options Class
26
- let options = new index.Options();
34
+ ### Making a Request
27
35
 
28
- options.token = "<<Provide Auth Token>>";
29
- options.guid = "<<Provide the Guid of the Website>>";
30
- options.locale = "<<Provide the locale of the Website>>"; //Example: en-us
36
+ #### Simple OAuth Authentication (Recommended)
37
+ ```typescript
38
+ import * as mgmtApi from "@agility/management-sdk";
31
39
 
32
- //Initialize the Method Class
33
- let contentMethods = new index.ContentMethods(options);
40
+ // Simple OAuth authentication - tokens managed automatically
41
+ const apiClient = new mgmtApi.ApiClient();
42
+ await apiClient.auth();
34
43
 
35
- //make the request: get a content item with the ID '22'
36
- var contentItem = await contentMethods.getContentItem(22);
44
+ const guid = "your-website-guid";
45
+ const locale = "en-us";
37
46
 
38
- //To log the response of the contentItem object in console.
47
+ // Make authenticated request - token refresh handled automatically
48
+ const contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
39
49
  console.log(JSON.stringify(contentItem));
40
50
  ```
41
- ## Class AssetMethods
42
- This class is used to perform operations related to Assets. The following are the methods: -
43
-
44
- ### upload
45
- | Parameter | Type | Description |
46
- | :-------- | :------- | :------------------------- |
47
- | `formData` | `FormData` | This is an object of type FormData where files can be posted eg : `const file = fs.readFileSync(<<Local File>>, null);const form = new FormData(); form.append('files',file,'<<File Name>>');`|
48
- | `agilityFolderPath` | `string` | Path of the folder in Agility where the file(s) needs to be uploaded.|
49
- | `groupingID` | `number` | Path of the folder in Agility where the file(s) needs to be uploaded.|
50
-
51
- Returns: A collection of ```Media``` class Object.
52
-
53
- ### deleteFile
54
- | Parameter | Type | Description |
55
- | :-------- | :------- | :------------------------- |
56
- | `mediaID` | `number` | The mediaID of the asset which needs to be deleted.|
57
- Returns
58
- A ```string``` response if a file has been deleted.
59
-
60
- ### moveFile
61
- | Parameter | Type | Description |
62
- | :-------- | :------- | :------------------------- |
63
- | `mediaID` | `number` | The mediaID of the file that needs to be moved.|
64
- | `newFolder` | `string` | The new location (in Agility) where the file needs to be moved.|
65
-
66
- Returns: An object of ```Media``` class with the new location of the file.
67
-
68
- ### getMediaList
69
- | Parameter | Type | Description |
70
- | :-------- | :------- | :------------------------- |
71
- | `pageSize` | `number` | The page size on which the assets needs to selected.|
72
- | `recordOffset` | `number` | The record offset value to skip search results.|
73
-
74
- Returns: An object of ```AssetMediaList``` class.
75
-
76
- ### getAssetByID
77
- | Parameter | Type | Description |
78
- | :-------- | :------- | :------------------------- |
79
- | `mediaID` | `number` | The mediaID of the requested asset.|
80
-
81
- Returns: An object of ```Media``` class with the information of the asset.
82
-
83
- ### getAssetByUrl
84
- | Parameter | Type | Description |
85
- | :-------- | :------- | :------------------------- |
86
- | `url` | `string` | The url of the requested asset.|
87
-
88
- Returns: An object of ```Media``` class with the information of the asset.
89
-
90
- ## Class BatchMethods
91
- This class is used to perform operations related to Batches. The following are the methods: -
92
-
93
- ### getBatch
94
- | Parameter | Type | Description |
95
- | :-------- | :------- | :------------------------- |
96
- | `id` | `number` | The batchID of the requested batch.|
97
-
98
- Returns: A object of ```Batch``` class.
99
-
100
- ## Class ContainerMethods
101
- This class is used to perform operations related to Containers. The following are the methods: -
102
-
103
- ### getContainerByID
104
- | Parameter | Type | Description |
105
- | :-------- | :------- | :------------------------- |
106
- | `id` | `number` | The container id of the requested container.|
107
-
108
- Returns: A object of ```Container``` class.
109
-
110
- ### getContainerByReferenceName
111
- | Parameter | Type | Description |
112
- | :-------- | :------- | :------------------------- |
113
- | `referenceName` | `string` | The container reference name of the requested container.|
114
-
115
- Returns: A object of ```Container``` class.
116
-
117
- ### getContainerSecurity
118
- | Parameter | Type | Description |
119
- | :-------- | :------- | :------------------------- |
120
- | `id` | `number` | The container id of the requested container.|
121
-
122
- Returns: A object of ```Container``` class.
123
-
124
- ### getContainerList
125
- Returns: A collection object of ```Container``` class.
126
-
127
- ### getNotificationList
128
- | Parameter | Type | Description |
129
- | :-------- | :------- | :------------------------- |
130
- | `id` | `number` | The container id of the requested container.|
131
-
132
- Returns: A collection object of ```Notification``` class.
133
-
134
- ### saveContainer
135
- | Parameter | Type | Description |
136
- | :-------- | :------- | :------------------------- |
137
- | `container` | `Container` | A Container type object to create or update a container.|
138
-
139
- Returns: An object of ```Container``` class.
140
-
141
- ### deleteContainer
142
- | Parameter | Type | Description |
143
- | :-------- | :------- | :------------------------- |
144
- | `id` | `number` | The container id of the requested container.|
145
-
146
- Returns: A ```string``` response if a container has been deleted.
147
-
148
- ## Class ContentMethods
149
- This class is used to perform operations related to Content. The following are the methods: -
150
-
151
- ### getContentItem
152
- | Parameter | Type | Description |
153
- | :-------- | :------- | :------------------------- |
154
- | `contentID` | `number` | The contentid of the requested content.|
155
-
156
- Returns: An object of ```ContentItem``` class.
157
-
158
- ### publishContent
159
- | Parameter | Type | Description |
160
- | :-------- | :------- | :------------------------- |
161
- | `contentID` | `number` | The contentid of the requested content.|
162
- | `comments` | `string` | Additional comments for a batch request.|
163
-
164
- Returns: An array of ```contentID``` of the requested content.
165
-
166
- ### unPublishContent
167
- | Parameter | Type | Description |
168
- | :-------- | :------- | :------------------------- |
169
- | `contentID` | `number` | The contentid of the requested content.|
170
- | `comments` | `string` | Additional comments for a batch request.|
171
-
172
- Returns: An array of ```contentID``` of the requested content.
173
-
174
- ### contentRequestApproval
175
- | Parameter | Type | Description |
176
- | :-------- | :------- | :------------------------- |
177
- | `contentID` | `number` | The contentid of the requested content.|
178
- | `comments` | `string` | Additional comments for a batch request.|
179
51
 
180
- Returns: An array of ```contentID``` of the requested content.
52
+ #### Manual Token Authentication (For CI/CD)
53
+ ```typescript
54
+ import * as mgmtApi from "@agility/management-sdk";
181
55
 
182
- ### approveContent
183
- | Parameter | Type | Description |
184
- | :-------- | :------- | :------------------------- |
185
- | `contentID` | `number` | The contentid of the requested content.|
186
- | `comments` | `string` | Additional comments for a batch request.|
56
+ // Token-based approach for CI/CD and automated environments
57
+ const options = new mgmtApi.Options();
58
+ options.token = process.env.AGILITY_API_TOKEN;
59
+ const apiClient = new mgmtApi.ApiClient(options);
187
60
 
188
- Returns: An array of ```contentID``` of the requested content.
61
+ const guid = process.env.AGILITY_GUID;
62
+ const locale = "en-us";
189
63
 
190
- ### declineContent
191
- | Parameter | Type | Description |
192
- | :-------- | :------- | :------------------------- |
193
- | `contentID` | `number` | The contentid of the requested content.|
194
- | `comments` | `string` | Additional comments for a batch request.|
195
-
196
- Returns: An array of ```contentID``` of the requested content.
197
-
198
- ### saveContentItem
199
- | Parameter | Type | Description |
200
- | :-------- | :------- | :------------------------- |
201
- | `contentItem` | `ContentItem` | A contentItem object to create or update a content.|
202
-
203
- Returns: An array of ```contentID``` of the requested content.
204
-
205
- ### saveContentItems
206
- | Parameter | Type | Description |
207
- | :-------- | :------- | :------------------------- |
208
- | `contentItems` | `ContentItem[]` | A collection of contentItems object to create or update multiple contents.|
209
-
210
- Returns: An array of ```contentID``` of the requested content.
211
-
212
- ### deleteContent
213
- | Parameter | Type | Description |
214
- | :-------- | :------- | :------------------------- |
215
- | `contentID` | `number` | The contentid of the requested content.|
216
- | `comments` | `string` | Additional comments for a batch request.|
217
-
218
- Returns: An array of ```contentID``` of the requested content.
219
-
220
- ### getContentItems
221
- | Parameter | Type | Description |
222
- | :-------- | :------- | :------------------------- |
223
- | `referenceName` | `string` | The reference name of the container for the requested content.|
224
- | `filter` | `string` | The filter condition for the requested content.|
225
- | `fields` | `string` | The fields mapped to the container.|
226
- | `sortDirection` | `string` | The direction to sort the result.|
227
- | `sortField` | `string` | The field on which the sort needs to be performed.|
228
- | `take` | `number` | The page size for the result.|
229
- | `skip` | `number` | The record offset for the result.|
230
-
231
- Returns: An object of ```ContentList``` class of the requested content.
232
-
233
- ## Class InstanceUserMethods
234
- This class is used to perform operations related to User. The following are the methods: -
235
-
236
- ### getUsers
237
- Returns: A collection of ```WebsiteUser``` class of the requested content.
238
-
239
- ### saveUser
240
- | Parameter | Type | Description |
241
- | :-------- | :------- | :------------------------- |
242
- | `emailAddress` | `string` | The email address of the requested user.|
243
- | `roles` | `InstanceRole[]` | Collection object of InstanceRole class for the requested user.|
244
- | `firstName` | `string` | The first name of the requested user.|
245
- | `lastName` | `string` | The last name of the requested user.|
246
-
247
- Returns: An object of the ```InstanceUser``` class.
248
-
249
- ### deleteUser
250
- | Parameter | Type | Description |
251
- | :-------- | :------- | :------------------------- |
252
- | `userID` | `number` | The userID of the requested user.|
253
-
254
- Returns: A ```string``` response if a user has been deleted.
255
-
256
- ## Class ModelMethods
257
- This class is used to perform operations related to Models. The following are the methods: -
258
-
259
- ### getContentModel
260
- | Parameter | Type | Description |
261
- | :-------- | :------- | :------------------------- |
262
- | `id` | `number` | The id of the requested model.|
263
-
264
- Returns: An object of ```Model``` class.
265
-
266
- ### getContentModules
267
- | Parameter | Type | Description |
268
- | :-------- | :------- | :------------------------- |
269
- | `includeDefaults` | `bool` | Boolean value to include defaults.|
270
- | `includeModules` | `bool` | Boolean value to include modules.|
271
-
272
- Returns: A collection object of ```Model``` class.
273
-
274
- ### getPageModules
275
- | Parameter | Type | Description |
276
- | :-------- | :------- | :------------------------- |
277
- | `includeDefault` | `bool` | Boolean value to include defaults.|
278
-
279
- Returns: A collection object of ```Model``` class.
280
-
281
- ### saveModel
282
- | Parameter | Type | Description |
283
- | :-------- | :------- | :------------------------- |
284
- | `model` | `Model` | The object of Model to for the requested model.|
285
-
286
- Returns: An object of ```Model``` class.
287
-
288
- ### deleteModel
289
- | Parameter | Type | Description |
290
- | :-------- | :------- | :------------------------- |
291
- | `id` | `number` | The id for the requested model.|
292
-
293
- Returns: A ```string``` response if a model is deleted.
294
-
295
- ## Class PageMethods
296
- This class is used to perform operations related to Pages. The following are the methods: -
297
-
298
- ### getSitemap
299
- Returns: A collection object of ```Sitemap``` class.
300
-
301
- ### getPage
302
- | Parameter | Type | Description |
303
- | :-------- | :------- | :------------------------- |
304
- | `pageID` | `number` | The id of the requested page.|
305
-
306
- Returns: An object of ```PageItem``` class.
307
-
308
- ### publishPage
309
- | Parameter | Type | Description |
310
- | :-------- | :------- | :------------------------- |
311
- | `pageID` | `number` | The pageID of the requested page.|
312
- | `comments` | `string` | Additional comments for a batch request.|
313
-
314
- Returns: An array of ```pageID``` of the requested page.
315
-
316
- ### unPublishPage
317
- | Parameter | Type | Description |
318
- | :-------- | :------- | :------------------------- |
319
- | `pageID` | `number` | The pageID of the requested page.|
320
- | `comments` | `string` | Additional comments for a batch request.|
321
-
322
- Returns: An array of ```pageID``` of the requested page.
323
-
324
- ### deletePage
325
- | Parameter | Type | Description |
326
- | :-------- | :------- | :------------------------- |
327
- | `pageID` | `number` | The pageID of the requested page.|
328
- | `comments` | `string` | Additional comments for a batch request.|
329
-
330
- Returns: An array of ```pageID``` of the requested page.
331
-
332
- ### approvePage
333
- | Parameter | Type | Description |
334
- | :-------- | :------- | :------------------------- |
335
- | `pageID` | `number` | The pageID of the requested page.|
336
- | `comments` | `string` | Additional comments for a batch request.|
64
+ const contentItem = await apiClient.contentMethods.getContentItem(22, guid, locale);
65
+ console.log('Content retrieved:', contentItem.fields.title);
66
+ ```
337
67
 
338
- Returns: An array of ```pageID``` of the requested page.
68
+ > 💡 **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.
339
69
 
340
- ### declinePage
341
- | Parameter | Type | Description |
342
- | :-------- | :------- | :------------------------- |
343
- | `pageID` | `number` | The pageID of the requested page.|
344
- | `comments` | `string` | Additional comments for a batch request.|
70
+ ## API Method Classes
71
+
72
+ ### File and Media Management
73
+ - **[AssetMethods](./docs/asset-methods.md)** - File and media management operations (15 functions)
74
+ - [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)
75
+
76
+ ### Workflow Operations
77
+ - **[BatchMethods](./docs/batch-methods.md)** - Batch workflow operations (7 functions)
78
+ - [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)
79
+
80
+ ### Content Management
81
+ - **[ContainerMethods](./docs/container-methods.md)** - Container management operations (8 functions)
82
+ - [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)
83
+
84
+ - **[ContentMethods](./docs/content-methods.md)** - Content item operations (13 functions)
85
+ - [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)
86
+
87
+ - **[ModelMethods](./docs/model-methods.md)** - Content model operations (6 functions)
88
+ - [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)
89
+
90
+ ### Page Management
91
+ - **[PageMethods](./docs/page-methods.md)** - Page management operations (17 functions)
92
+ - [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)
93
+
94
+ ### User Management
95
+ - **[InstanceMethods](./docs/instance-methods.md)** - Instance-level operations (1 function)
96
+ - [getLocales](./docs/instance-methods.md#getlocales)
97
+
98
+ - **[InstanceUserMethods](./docs/instance-user-methods.md)** - Instance user management (3 functions)
99
+ - [getUsers](./docs/instance-user-methods.md#getusers), [saveUser](./docs/instance-user-methods.md#saveuser), [deleteUser](./docs/instance-user-methods.md#deleteuser)
100
+
101
+ - **[ServerUserMethods](./docs/server-user-methods.md)** - Server user operations (2 functions)
102
+ - [me](./docs/server-user-methods.md#me), [you](./docs/server-user-methods.md#you)
103
+
104
+ ### Integration
105
+ - **[WebhookMethods](./docs/webhook-methods.md)** - Webhook management (4 functions)
106
+ - [getWebhook](./docs/webhook-methods.md#getwebhook), [webhookList](./docs/webhook-methods.md#webhooklist), [saveWebhook](./docs/webhook-methods.md#savewebhook), [deleteWebhook](./docs/webhook-methods.md#deletewebhook)
107
+
108
+ ### Multi-Instance Operations
109
+ - **[Multi-Instance Operations](./docs/multi-instance-operations.md)** - Advanced workflows for managing content across multiple instances and locales
110
+ - Configuration-driven content creation across multiple environments
111
+ - Parallel processing and batch operations
112
+ - Performance optimization and error handling
113
+ - Cross-instance synchronization and reporting
114
+
115
+ ### CI/CD & Automation
116
+ - **[CI/CD & Automated Environments](./docs/cicd.md)** - Token-based authentication for automated environments
117
+ - CI/CD pipeline examples (GitHub Actions, GitLab CI, Jenkins)
118
+ - Serverless functions (AWS Lambda, Vercel)
119
+ - Environment configuration and security best practices
120
+ - Token management and rotation
121
+
122
+ ## Examples
123
+
124
+ ### Understanding Agility CMS Batch Architecture
125
+
126
+ Agility CMS uses a simple approach for working with content and batches:
127
+
128
+ #### Content/Page Creation (Handled by Respective Controllers)
129
+ - **contentMethods.saveContentItem()** - Creates a single new content item and adds it to a batch
130
+ - **contentMethods.saveContentItems()** - Creates multiple new content items and adds them to a batch
131
+ - **pageMethods.savePage()** - Creates a new page and adds it to a batch
132
+ - These methods create the content AND automatically handle batch creation/management
133
+
134
+ #### Batch Workflow Operations (Handled by Batch Controller)
135
+ - **batchMethods.publishBatch()** - Publishes all items in an existing batch
136
+ - **batchMethods.unpublishBatch()** - Unpublishes all items in an existing batch
137
+ - **batchMethods.approveBatch()** - Approves all items in an existing batch
138
+ - **batchMethods.declineBatch()** - Declines all items in an existing batch
139
+ - **batchMethods.requestApprovalBatch()** - Requests approval for all items in an existing batch
140
+ - **batchMethods.getBatch()** - Retrieves details of an existing batch
141
+ - **batchMethods.getBatchTypes()** - Retrieves all batch-related enum types for developer discovery
142
+
143
+ ### Complete Workflow Example
144
+
145
+ ```typescript
146
+ import * as mgmtApi from '@agility/management-sdk';
147
+
148
+ // Authenticate with simple OAuth flow
149
+ const client = new mgmtApi.ApiClient();
150
+ await client.auth();
151
+
152
+ const guid = 'your-instance-guid';
153
+ const locale = 'en-us';
154
+
155
+ // Get batch types for dynamic UI and validation
156
+ const batchTypes = await client.batchMethods.getBatchTypes(guid);
157
+ console.log('Available batch types loaded:', batchTypes);
158
+
159
+ // Create NEW content items (handled by content controller)
160
+ // This automatically creates and manages batches
161
+ const newContentBatchID = await client.contentMethods.saveContentItem(locale, {
162
+ properties: {
163
+ referenceName: 'blog-post',
164
+ definitionName: 'BlogPost',
165
+ state: 2
166
+ },
167
+ fields: {
168
+ title: 'My New Blog Post',
169
+ content: 'This is the blog post content...'
170
+ }
171
+ });
172
+
173
+ // Create NEW page (handled by page controller)
174
+ // This automatically creates and manages batches
175
+ const newPageBatchID = await client.pageMethods.savePage(locale, {
176
+ name: 'new-product-page',
177
+ title: 'New Product Page',
178
+ menuText: 'New Product',
179
+ pageType: 'static',
180
+ templateName: 'Product Template',
181
+ parentPageID: -1
182
+ });
183
+
184
+ // Retrieve details of an existing batch
185
+ const batchDetails = await client.batchMethods.getBatch(newContentBatchID, guid);
186
+ console.log('Batch details:', batchDetails);
187
+
188
+ // Perform workflow operations on existing batches
189
+ await client.batchMethods.publishBatch(newContentBatchID, guid);
190
+ await client.batchMethods.approveBatch(newPageBatchID, guid);
191
+
192
+ // Or use immediate return for custom polling
193
+ const batchId = await client.batchMethods.publishBatch(newContentBatchID, guid, true);
194
+ console.log('Batch submitted for publishing:', batchId);
195
+
196
+ console.log('All operations completed successfully!');
197
+ ```
345
198
 
346
- Returns: An array of ```pageID``` of the requested page.
199
+ ## TypeScript Interfaces
347
200
 
348
- ### pageRequestApproval
349
- | Parameter | Type | Description |
350
- | :-------- | :------- | :------------------------- |
351
- | `pageID` | `number` | The pageID of the requested page.|
352
- | `comments` | `string` | Additional comments for a batch request.|
201
+ ### Batch Response Interfaces
353
202
 
354
- Returns: An array of ```pageID``` of the requested page.
203
+ ```typescript
204
+ interface BatchTypesResponse {
205
+ itemTypes: EnumInfo[]; // Page, ContentItem, ContentList, Tag, ModuleDef
206
+ operationTypes: EnumInfo[]; // All operation types
207
+ workflowOperations: EnumInfo[]; // Publish, Unpublish, Approve, Decline, RequestApproval
208
+ states: EnumInfo[]; // None, Pending, InProcess, Processed, Deleted
209
+ }
355
210
 
356
- ### savePage
357
- | Parameter | Type | Description |
358
- | :-------- | :------- | :------------------------- |
359
- | `pageItem` | `PageItem` | The object of PageItem class for the requested Page.|
360
- | `parentPageID` | `number` | The id of the parent page.|
361
- | `placeBeforePageItemID` | `number` | The id of the page before the page.|
211
+ interface EnumInfo {
212
+ value: number; // Numeric enum value
213
+ name: string; // String name (e.g., "Publish")
214
+ description: string; // Human-readable description
215
+ }
216
+ ```
362
217
 
363
- Returns: An array of ```pageID``` of the requested page.
218
+ ## Available Enums
364
219
 
220
+ ### WorkflowOperationType (for batch processing)
221
+ > **Note**: In the API documentation (Swagger UI), these operations appear as descriptive dropdown options (Publish, Unpublish, Approve, Decline, RequestApproval) instead of numbers.
365
222
 
366
- ## Running the SDK Locally
223
+ - `Publish = 1`
224
+ - `Unpublish = 2`
225
+ - `Approve = 3`
226
+ - `Decline = 4`
227
+ - `RequestApproval = 5`
367
228
 
368
- - `npm run clean`
369
- - `npm run prepare`
370
- - `npm run build`
229
+ ### BatchItemType
230
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive dropdown options (Page, ContentItem, ContentList, Tag, ModuleDef) instead of numbers.
371
231
 
372
- ## How It Works
232
+ - `Page = 1`
233
+ - `ContentItem = 2`
234
+ - `ContentList = 3`
235
+ - `Tag = 4`
236
+ - `ModuleDef = 5`
373
237
 
374
- - [How Pages Work](https://help.agilitycms.com/hc/en-us/articles/4404222849677)
375
- - [How Page Modules Work](https://help.agilitycms.com/hc/en-us/articles/4404222989453)
376
- - [How Page Templates Work](https://help.agilitycms.com/hc/en-us/articles/4404229108877)
238
+ ### BatchState
239
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive names (None, Pending, InProcess, Processed, Deleted) instead of numbers.
377
240
 
378
- ## Resources
241
+ - `None = 0` - Batch created but not submitted for processing
242
+ - `Pending = 1` - Batch is pending processing
243
+ - `InProcess = 2` - Batch is currently being processed
244
+ - `Processed = 3` - Batch has been processed successfully
245
+ - `Deleted = 4` - Batch has been deleted
379
246
 
380
- ### Agility CMS
247
+ ## Error Handling
381
248
 
382
- - [Official site](https://agilitycms.com)
383
- - [Documentation](https://help.agilitycms.com/hc/en-us)
249
+ All methods throw exceptions on failure:
384
250
 
385
- ### Community
251
+ ```typescript
252
+ try {
253
+ const batch = await client.batchMethods.getBatch(123, 'instance-guid');
254
+ } catch (error) {
255
+ console.error('Failed to get batch:', error.message);
256
+ }
257
+ ```
386
258
 
387
- - [Official Slack](https://join.slack.com/t/agilitycommunity/shared_invite/enQtNzI2NDc3MzU4Njc2LWI2OTNjZTI3ZGY1NWRiNTYzNmEyNmI0MGZlZTRkYzI3NmRjNzkxYmI5YTZjNTg2ZTk4NGUzNjg5NzY3OWViZGI)
388
- - [Blog](https://agilitycms.com/resources/posts)
389
- - [GitHub](https://github.com/agility)
390
- - [Forums](https://help.agilitycms.com/hc/en-us/community/topics)
391
- - [Facebook](https://www.facebook.com/AgilityCMS/)
392
- - [Twitter](https://twitter.com/AgilityCMS)
259
+ ## License
393
260
 
394
- ## Feedback and Questions
261
+ MIT
395
262
 
396
- 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).
263
+ 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).