@agility/management-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +398 -0
- package/dist/apiMethods/assetMethods.d.ts +14 -0
- package/dist/apiMethods/assetMethods.js +95 -0
- package/dist/apiMethods/batchMethods.d.ts +11 -0
- package/dist/apiMethods/batchMethods.js +65 -0
- package/dist/apiMethods/clientInstance.d.ts +8 -0
- package/dist/apiMethods/clientInstance.js +77 -0
- package/dist/apiMethods/containerMethods.d.ts +16 -0
- package/dist/apiMethods/containerMethods.js +105 -0
- package/dist/apiMethods/contentMethods.d.ts +20 -0
- package/dist/apiMethods/contentMethods.js +175 -0
- package/dist/apiMethods/instanceUserMethods.d.ts +13 -0
- package/dist/apiMethods/instanceUserMethods.js +57 -0
- package/dist/apiMethods/modelMethods.d.ts +13 -0
- package/dist/apiMethods/modelMethods.js +81 -0
- package/dist/apiMethods/pageMethods.d.ts +20 -0
- package/dist/apiMethods/pageMethods.js +159 -0
- package/dist/enums/batchOperationType.d.ts +19 -0
- package/dist/enums/batchOperationType.js +23 -0
- package/dist/enums/batchState..d.ts +7 -0
- package/dist/enums/batchState..js +11 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +33 -0
- package/dist/models/batch.d.ts +29 -0
- package/dist/models/batch.js +6 -0
- package/dist/models/batchItem.d.ts +13 -0
- package/dist/models/batchItem.js +6 -0
- package/dist/models/container.d.ts +47 -0
- package/dist/models/container.js +6 -0
- package/dist/models/contentItem.d.ts +37 -0
- package/dist/models/contentItem.js +18 -0
- package/dist/models/contentViewColumn.d.ts +8 -0
- package/dist/models/contentViewColumn.js +6 -0
- package/dist/models/exception.d.ts +4 -0
- package/dist/models/exception.js +10 -0
- package/dist/models/instanceRole.d.ts +7 -0
- package/dist/models/instanceRole.js +6 -0
- package/dist/models/instanceUser.d.ts +14 -0
- package/dist/models/instanceUser.js +6 -0
- package/dist/models/media.d.ts +30 -0
- package/dist/models/media.js +9 -0
- package/dist/models/model.d.ts +30 -0
- package/dist/models/model.js +9 -0
- package/dist/models/notification.d.ts +13 -0
- package/dist/models/notification.js +6 -0
- package/dist/models/options.d.ts +10 -0
- package/dist/models/options.js +25 -0
- package/dist/models/pageItem.d.ts +56 -0
- package/dist/models/pageItem.js +21 -0
- package/dist/models/sitemap.d.ts +20 -0
- package/dist/models/sitemap.js +9 -0
- package/dist/models/websiteUser.d.ts +22 -0
- package/dist/models/websiteUser.js +9 -0
- package/license.txt +21 -0
- package/package.json +39 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# Agility CMS & Management API TypeScript SDK
|
|
2
|
+
|
|
3
|
+
To start using the Agility CMS & .NET 5 Starter, [sign up](https://agilitycms.com/free) for a FREE account and create a new Instance using the Blog Template.
|
|
4
|
+
|
|
5
|
+
## About the Management API SDK
|
|
6
|
+
|
|
7
|
+
- Provides a facility to developers to use the new Agility Management API more effectively.
|
|
8
|
+
- Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
|
|
9
|
+
- Supports the creation of Pages and Content in batches.
|
|
10
|
+
- Ability to generate Content in bulk for a Website.
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
### Prerequisites
|
|
15
|
+
1. Clone the repository agility-cms-management-sdk-typescript.
|
|
16
|
+
2. Import the index file to make use of the Options class.
|
|
17
|
+
3. Create an object of the Options class to provide values of -
|
|
18
|
+
- token -> Bearer token to authenticate a Rest Request to perform an operation.
|
|
19
|
+
- locale -> The locale under which your application is hosted. Example en-us.
|
|
20
|
+
- guid -> The guid under which your application is hosted.
|
|
21
|
+
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 -
|
|
22
|
+
|
|
23
|
+
### Making a Request
|
|
24
|
+
```Javascript
|
|
25
|
+
import * as index from "./index";
|
|
26
|
+
|
|
27
|
+
//initialize the Options Class
|
|
28
|
+
let options = new index.Options();
|
|
29
|
+
|
|
30
|
+
options.token = "<<Provide Auth Token>>";
|
|
31
|
+
options.guid = "<<Provide the Guid of the Website>>";
|
|
32
|
+
options.locale = "<<Provide the locale of the Website>>"; //Example: en-us
|
|
33
|
+
|
|
34
|
+
//Initialize the Method Class
|
|
35
|
+
let contentMethods = new index.ContentMethods(options);
|
|
36
|
+
|
|
37
|
+
//make the request: get a content item with the ID '22'
|
|
38
|
+
var contentItem = await contentMethods.getContentItem(22);
|
|
39
|
+
|
|
40
|
+
//To log the response of the contentItem object in console.
|
|
41
|
+
console.log(JSON.stringify(contentItem));
|
|
42
|
+
```
|
|
43
|
+
## Class AssetMethods
|
|
44
|
+
This class is used to perform operations related to Assets. The following are the methods: -
|
|
45
|
+
|
|
46
|
+
### upload
|
|
47
|
+
| Parameter | Type | Description |
|
|
48
|
+
| :-------- | :------- | :------------------------- |
|
|
49
|
+
| `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>>');`|
|
|
50
|
+
| `agilityFolderPath` | `string` | Path of the folder in Agility where the file(s) needs to be uploaded.|
|
|
51
|
+
| `groupingID` | `number` | Path of the folder in Agility where the file(s) needs to be uploaded.|
|
|
52
|
+
|
|
53
|
+
Returns: A collection of ```Media``` class Object.
|
|
54
|
+
|
|
55
|
+
### deleteFile
|
|
56
|
+
| Parameter | Type | Description |
|
|
57
|
+
| :-------- | :------- | :------------------------- |
|
|
58
|
+
| `mediaID` | `number` | The mediaID of the asset which needs to be deleted.|
|
|
59
|
+
Returns
|
|
60
|
+
A ```string``` response if a file has been deleted.
|
|
61
|
+
|
|
62
|
+
### moveFile
|
|
63
|
+
| Parameter | Type | Description |
|
|
64
|
+
| :-------- | :------- | :------------------------- |
|
|
65
|
+
| `mediaID` | `number` | The mediaID of the file that needs to be moved.|
|
|
66
|
+
| `newFolder` | `string` | The new location (in Agility) where the file needs to be moved.|
|
|
67
|
+
|
|
68
|
+
Returns: An object of ```Media``` class with the new location of the file.
|
|
69
|
+
|
|
70
|
+
### getMediaList
|
|
71
|
+
| Parameter | Type | Description |
|
|
72
|
+
| :-------- | :------- | :------------------------- |
|
|
73
|
+
| `pageSize` | `number` | The page size on which the assets needs to selected.|
|
|
74
|
+
| `recordOffset` | `number` | The record offset value to skip search results.|
|
|
75
|
+
|
|
76
|
+
Returns: An object of ```AssetMediaList``` class.
|
|
77
|
+
|
|
78
|
+
### getAssetByID
|
|
79
|
+
| Parameter | Type | Description |
|
|
80
|
+
| :-------- | :------- | :------------------------- |
|
|
81
|
+
| `mediaID` | `number` | The mediaID of the requested asset.|
|
|
82
|
+
|
|
83
|
+
Returns: An object of ```Media``` class with the information of the asset.
|
|
84
|
+
|
|
85
|
+
### getAssetByUrl
|
|
86
|
+
| Parameter | Type | Description |
|
|
87
|
+
| :-------- | :------- | :------------------------- |
|
|
88
|
+
| `url` | `string` | The url of the requested asset.|
|
|
89
|
+
|
|
90
|
+
Returns: An object of ```Media``` class with the information of the asset.
|
|
91
|
+
|
|
92
|
+
## Class BatchMethods
|
|
93
|
+
This class is used to perform operations related to Batches. The following are the methods: -
|
|
94
|
+
|
|
95
|
+
### getBatch
|
|
96
|
+
| Parameter | Type | Description |
|
|
97
|
+
| :-------- | :------- | :------------------------- |
|
|
98
|
+
| `id` | `number` | The batchID of the requested batch.|
|
|
99
|
+
|
|
100
|
+
Returns: A object of ```Batch``` class.
|
|
101
|
+
|
|
102
|
+
## Class ContainerMethods
|
|
103
|
+
This class is used to perform operations related to Containers. The following are the methods: -
|
|
104
|
+
|
|
105
|
+
### getContainerByID
|
|
106
|
+
| Parameter | Type | Description |
|
|
107
|
+
| :-------- | :------- | :------------------------- |
|
|
108
|
+
| `id` | `number` | The container id of the requested container.|
|
|
109
|
+
|
|
110
|
+
Returns: A object of ```Container``` class.
|
|
111
|
+
|
|
112
|
+
### getContainerByReferenceName
|
|
113
|
+
| Parameter | Type | Description |
|
|
114
|
+
| :-------- | :------- | :------------------------- |
|
|
115
|
+
| `referenceName` | `string` | The container reference name of the requested container.|
|
|
116
|
+
|
|
117
|
+
Returns: A object of ```Container``` class.
|
|
118
|
+
|
|
119
|
+
### getContainerSecurity
|
|
120
|
+
| Parameter | Type | Description |
|
|
121
|
+
| :-------- | :------- | :------------------------- |
|
|
122
|
+
| `id` | `number` | The container id of the requested container.|
|
|
123
|
+
|
|
124
|
+
Returns: A object of ```Container``` class.
|
|
125
|
+
|
|
126
|
+
### getContainerList
|
|
127
|
+
Returns: A collection object of ```Container``` class.
|
|
128
|
+
|
|
129
|
+
### getNotificationList
|
|
130
|
+
| Parameter | Type | Description |
|
|
131
|
+
| :-------- | :------- | :------------------------- |
|
|
132
|
+
| `id` | `number` | The container id of the requested container.|
|
|
133
|
+
|
|
134
|
+
Returns: A collection object of ```Notification``` class.
|
|
135
|
+
|
|
136
|
+
### saveContainer
|
|
137
|
+
| Parameter | Type | Description |
|
|
138
|
+
| :-------- | :------- | :------------------------- |
|
|
139
|
+
| `container` | `Container` | A Container type object to create or update a container.|
|
|
140
|
+
|
|
141
|
+
Returns: An object of ```Container``` class.
|
|
142
|
+
|
|
143
|
+
### deleteContainer
|
|
144
|
+
| Parameter | Type | Description |
|
|
145
|
+
| :-------- | :------- | :------------------------- |
|
|
146
|
+
| `id` | `number` | The container id of the requested container.|
|
|
147
|
+
|
|
148
|
+
Returns: A ```string``` response if a container has been deleted.
|
|
149
|
+
|
|
150
|
+
## Class ContentMethods
|
|
151
|
+
This class is used to perform operations related to Content. The following are the methods: -
|
|
152
|
+
|
|
153
|
+
### getContentItem
|
|
154
|
+
| Parameter | Type | Description |
|
|
155
|
+
| :-------- | :------- | :------------------------- |
|
|
156
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
157
|
+
|
|
158
|
+
Returns: An object of ```ContentItem``` class.
|
|
159
|
+
|
|
160
|
+
### publishContent
|
|
161
|
+
| Parameter | Type | Description |
|
|
162
|
+
| :-------- | :------- | :------------------------- |
|
|
163
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
164
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
165
|
+
|
|
166
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
167
|
+
|
|
168
|
+
### unPublishContent
|
|
169
|
+
| Parameter | Type | Description |
|
|
170
|
+
| :-------- | :------- | :------------------------- |
|
|
171
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
172
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
173
|
+
|
|
174
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
175
|
+
|
|
176
|
+
### contentRequestApproval
|
|
177
|
+
| Parameter | Type | Description |
|
|
178
|
+
| :-------- | :------- | :------------------------- |
|
|
179
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
180
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
181
|
+
|
|
182
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
183
|
+
|
|
184
|
+
### approveContent
|
|
185
|
+
| Parameter | Type | Description |
|
|
186
|
+
| :-------- | :------- | :------------------------- |
|
|
187
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
188
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
189
|
+
|
|
190
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
191
|
+
|
|
192
|
+
### declineContent
|
|
193
|
+
| Parameter | Type | Description |
|
|
194
|
+
| :-------- | :------- | :------------------------- |
|
|
195
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
196
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
197
|
+
|
|
198
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
199
|
+
|
|
200
|
+
### saveContentItem
|
|
201
|
+
| Parameter | Type | Description |
|
|
202
|
+
| :-------- | :------- | :------------------------- |
|
|
203
|
+
| `contentItem` | `ContentItem` | A contentItem object to create or update a content.|
|
|
204
|
+
|
|
205
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
206
|
+
|
|
207
|
+
### saveContentItems
|
|
208
|
+
| Parameter | Type | Description |
|
|
209
|
+
| :-------- | :------- | :------------------------- |
|
|
210
|
+
| `contentItems` | `ContentItem[]` | A collection of contentItems object to create or update multiple contents.|
|
|
211
|
+
|
|
212
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
213
|
+
|
|
214
|
+
### deleteContent
|
|
215
|
+
| Parameter | Type | Description |
|
|
216
|
+
| :-------- | :------- | :------------------------- |
|
|
217
|
+
| `contentID` | `number` | The contentid of the requested content.|
|
|
218
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
219
|
+
|
|
220
|
+
Returns: An array of ```contentID``` of the requested content.
|
|
221
|
+
|
|
222
|
+
### getContentItems
|
|
223
|
+
| Parameter | Type | Description |
|
|
224
|
+
| :-------- | :------- | :------------------------- |
|
|
225
|
+
| `referenceName` | `string` | The reference name of the container for the requested content.|
|
|
226
|
+
| `filter` | `string` | The filter condition for the requested content.|
|
|
227
|
+
| `fields` | `string` | The fields mapped to the container.|
|
|
228
|
+
| `sortDirection` | `string` | The direction to sort the result.|
|
|
229
|
+
| `sortField` | `string` | The field on which the sort needs to be performed.|
|
|
230
|
+
| `take` | `number` | The page size for the result.|
|
|
231
|
+
| `skip` | `number` | The record offset for the result.|
|
|
232
|
+
|
|
233
|
+
Returns: An object of ```ContentList``` class of the requested content.
|
|
234
|
+
|
|
235
|
+
## Class InstanceUserMethods
|
|
236
|
+
This class is used to perform operations related to User. The following are the methods: -
|
|
237
|
+
|
|
238
|
+
### getUsers
|
|
239
|
+
Returns: A collection of ```WebsiteUser``` class of the requested content.
|
|
240
|
+
|
|
241
|
+
### saveUser
|
|
242
|
+
| Parameter | Type | Description |
|
|
243
|
+
| :-------- | :------- | :------------------------- |
|
|
244
|
+
| `emailAddress` | `string` | The email address of the requested user.|
|
|
245
|
+
| `roles` | `InstanceRole[]` | Collection object of InstanceRole class for the requested user.|
|
|
246
|
+
| `firstName` | `string` | The first name of the requested user.|
|
|
247
|
+
| `lastName` | `string` | The last name of the requested user.|
|
|
248
|
+
|
|
249
|
+
Returns: An object of the ```InstanceUser``` class.
|
|
250
|
+
|
|
251
|
+
### deleteUser
|
|
252
|
+
| Parameter | Type | Description |
|
|
253
|
+
| :-------- | :------- | :------------------------- |
|
|
254
|
+
| `userID` | `number` | The userID of the requested user.|
|
|
255
|
+
|
|
256
|
+
Returns: A ```string``` response if a user has been deleted.
|
|
257
|
+
|
|
258
|
+
## Class ModelMethods
|
|
259
|
+
This class is used to perform operations related to Models. The following are the methods: -
|
|
260
|
+
|
|
261
|
+
### getContentModel
|
|
262
|
+
| Parameter | Type | Description |
|
|
263
|
+
| :-------- | :------- | :------------------------- |
|
|
264
|
+
| `id` | `number` | The id of the requested model.|
|
|
265
|
+
|
|
266
|
+
Returns: An object of ```Model``` class.
|
|
267
|
+
|
|
268
|
+
### getContentModules
|
|
269
|
+
| Parameter | Type | Description |
|
|
270
|
+
| :-------- | :------- | :------------------------- |
|
|
271
|
+
| `includeDefaults` | `bool` | Boolean value to include defaults.|
|
|
272
|
+
| `includeModules` | `bool` | Boolean value to include modules.|
|
|
273
|
+
|
|
274
|
+
Returns: A collection object of ```Model``` class.
|
|
275
|
+
|
|
276
|
+
### getPageModules
|
|
277
|
+
| Parameter | Type | Description |
|
|
278
|
+
| :-------- | :------- | :------------------------- |
|
|
279
|
+
| `includeDefault` | `bool` | Boolean value to include defaults.|
|
|
280
|
+
|
|
281
|
+
Returns: A collection object of ```Model``` class.
|
|
282
|
+
|
|
283
|
+
### saveModel
|
|
284
|
+
| Parameter | Type | Description |
|
|
285
|
+
| :-------- | :------- | :------------------------- |
|
|
286
|
+
| `model` | `Model` | The object of Model to for the requested model.|
|
|
287
|
+
|
|
288
|
+
Returns: An object of ```Model``` class.
|
|
289
|
+
|
|
290
|
+
### deleteModel
|
|
291
|
+
| Parameter | Type | Description |
|
|
292
|
+
| :-------- | :------- | :------------------------- |
|
|
293
|
+
| `id` | `number` | The id for the requested model.|
|
|
294
|
+
|
|
295
|
+
Returns: A ```string``` response if a model is deleted.
|
|
296
|
+
|
|
297
|
+
## Class PageMethods
|
|
298
|
+
This class is used to perform operations related to Pages. The following are the methods: -
|
|
299
|
+
|
|
300
|
+
### getSitemap
|
|
301
|
+
Returns: A collection object of ```Sitemap``` class.
|
|
302
|
+
|
|
303
|
+
### getPage
|
|
304
|
+
| Parameter | Type | Description |
|
|
305
|
+
| :-------- | :------- | :------------------------- |
|
|
306
|
+
| `pageID` | `number` | The id of the requested page.|
|
|
307
|
+
|
|
308
|
+
Returns: An object of ```PageItem``` class.
|
|
309
|
+
|
|
310
|
+
### publishPage
|
|
311
|
+
| Parameter | Type | Description |
|
|
312
|
+
| :-------- | :------- | :------------------------- |
|
|
313
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
314
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
315
|
+
|
|
316
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
317
|
+
|
|
318
|
+
### unPublishPage
|
|
319
|
+
| Parameter | Type | Description |
|
|
320
|
+
| :-------- | :------- | :------------------------- |
|
|
321
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
322
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
323
|
+
|
|
324
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
325
|
+
|
|
326
|
+
### deletePage
|
|
327
|
+
| Parameter | Type | Description |
|
|
328
|
+
| :-------- | :------- | :------------------------- |
|
|
329
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
330
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
331
|
+
|
|
332
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
333
|
+
|
|
334
|
+
### approvePage
|
|
335
|
+
| Parameter | Type | Description |
|
|
336
|
+
| :-------- | :------- | :------------------------- |
|
|
337
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
338
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
339
|
+
|
|
340
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
341
|
+
|
|
342
|
+
### declinePage
|
|
343
|
+
| Parameter | Type | Description |
|
|
344
|
+
| :-------- | :------- | :------------------------- |
|
|
345
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
346
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
347
|
+
|
|
348
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
349
|
+
|
|
350
|
+
### pageRequestApproval
|
|
351
|
+
| Parameter | Type | Description |
|
|
352
|
+
| :-------- | :------- | :------------------------- |
|
|
353
|
+
| `pageID` | `number` | The pageID of the requested page.|
|
|
354
|
+
| `comments` | `string` | Additional comments for a batch request.|
|
|
355
|
+
|
|
356
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
357
|
+
|
|
358
|
+
### savePage
|
|
359
|
+
| Parameter | Type | Description |
|
|
360
|
+
| :-------- | :------- | :------------------------- |
|
|
361
|
+
| `pageItem` | `PageItem` | The object of PageItem class for the requested Page.|
|
|
362
|
+
| `parentPageID` | `number` | The id of the parent page.|
|
|
363
|
+
| `placeBeforePageItemID` | `number` | The id of the page before the page.|
|
|
364
|
+
|
|
365
|
+
Returns: An array of ```pageID``` of the requested page.
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
## Running the SDK Locally
|
|
369
|
+
|
|
370
|
+
- `npm run clean`
|
|
371
|
+
- `npm run prepare`
|
|
372
|
+
- `npm run build`
|
|
373
|
+
|
|
374
|
+
## How It Works
|
|
375
|
+
|
|
376
|
+
- [How Pages Work](https://help.agilitycms.com/hc/en-us/articles/4404222849677)
|
|
377
|
+
- [How Page Modules Work](https://help.agilitycms.com/hc/en-us/articles/4404222989453)
|
|
378
|
+
- [How Page Templates Work](https://help.agilitycms.com/hc/en-us/articles/4404229108877)
|
|
379
|
+
|
|
380
|
+
## Resources
|
|
381
|
+
|
|
382
|
+
### Agility CMS
|
|
383
|
+
|
|
384
|
+
- [Official site](https://agilitycms.com)
|
|
385
|
+
- [Documentation](https://help.agilitycms.com/hc/en-us)
|
|
386
|
+
|
|
387
|
+
### Community
|
|
388
|
+
|
|
389
|
+
- [Official Slack](https://join.slack.com/t/agilitycommunity/shared_invite/enQtNzI2NDc3MzU4Njc2LWI2OTNjZTI3ZGY1NWRiNTYzNmEyNmI0MGZlZTRkYzI3NmRjNzkxYmI5YTZjNTg2ZTk4NGUzNjg5NzY3OWViZGI)
|
|
390
|
+
- [Blog](https://agilitycms.com/resources/posts)
|
|
391
|
+
- [GitHub](https://github.com/agility)
|
|
392
|
+
- [Forums](https://help.agilitycms.com/hc/en-us/community/topics)
|
|
393
|
+
- [Facebook](https://www.facebook.com/AgilityCMS/)
|
|
394
|
+
- [Twitter](https://twitter.com/AgilityCMS)
|
|
395
|
+
|
|
396
|
+
## Feedback and Questions
|
|
397
|
+
|
|
398
|
+
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).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Options } from "../models/options";
|
|
2
|
+
import { ClientInstance } from "./clientInstance";
|
|
3
|
+
import { AssetMediaList, Media } from "../models/media";
|
|
4
|
+
export declare class AssetMethods {
|
|
5
|
+
_options: Options;
|
|
6
|
+
_clientInstance: ClientInstance;
|
|
7
|
+
constructor(options: Options);
|
|
8
|
+
deleteFile(mediaID: number): Promise<string>;
|
|
9
|
+
moveFile(mediaID: number, newFolder: string): Promise<Media>;
|
|
10
|
+
getMediaList(pageSize: number, recordOffset: number): Promise<AssetMediaList>;
|
|
11
|
+
getAssetByID(mediaID: number): Promise<Media>;
|
|
12
|
+
getAssetByUrl(url: string): Promise<Media>;
|
|
13
|
+
upload(formData: FormData, agilityFolderPath: string, groupingID?: number): Promise<Media[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AssetMethods = void 0;
|
|
13
|
+
const clientInstance_1 = require("./clientInstance");
|
|
14
|
+
const exception_1 = require("../models/exception");
|
|
15
|
+
class AssetMethods {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this._options = options;
|
|
18
|
+
this._clientInstance = new clientInstance_1.ClientInstance();
|
|
19
|
+
}
|
|
20
|
+
deleteFile(mediaID) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
let apiPath = `asset/delete/${mediaID}`;
|
|
24
|
+
const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
|
|
25
|
+
;
|
|
26
|
+
return resp.data;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new exception_1.Exception(`Unable to delete the media for mediaID: ${mediaID}`, err);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
moveFile(mediaID, newFolder) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
let folder = encodeURIComponent(newFolder);
|
|
37
|
+
let apiPath = `asset/move/${mediaID}?newFolder=${folder}`;
|
|
38
|
+
const resp = yield this._clientInstance.executePost(apiPath, this._options, null);
|
|
39
|
+
return resp.data;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw new exception_1.Exception(`Unable to move the media for mediaID: ${mediaID}`, err);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getMediaList(pageSize, recordOffset) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
let apiPath = `asset/list?pageSize=${pageSize}&recordOffset=${recordOffset}`;
|
|
50
|
+
const resp = yield this._clientInstance.executeGet(apiPath, this._options);
|
|
51
|
+
return resp.data;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new exception_1.Exception(`Unable to retrieve assets for the website.`, err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
getAssetByID(mediaID) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
let apiPath = `asset/${mediaID}`;
|
|
62
|
+
const resp = yield this._clientInstance.executeGet(apiPath, this._options);
|
|
63
|
+
return resp.data;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
throw new exception_1.Exception(`Unable to retrieve asset for mediaID ${mediaID}`, err);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getAssetByUrl(url) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
try {
|
|
73
|
+
let apiPath = `asset?url=${url}`;
|
|
74
|
+
const resp = yield this._clientInstance.executeGet(apiPath, this._options);
|
|
75
|
+
return resp.data;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
throw new exception_1.Exception(`Unable to retrieve asset for url ${url}`, err);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
upload(formData, agilityFolderPath, groupingID = -1) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
try {
|
|
85
|
+
let apiPath = `asset/upload?folderPath=${agilityFolderPath}&groupingID=${groupingID}`;
|
|
86
|
+
const resp = yield this._clientInstance.executePost(apiPath, this._options, formData);
|
|
87
|
+
return resp.data;
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
throw new exception_1.Exception(`Unable to upload media.`, err);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.AssetMethods = AssetMethods;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Options } from "../models/options";
|
|
2
|
+
import { ClientInstance } from "./clientInstance";
|
|
3
|
+
import { Batch } from "../models/batch";
|
|
4
|
+
export declare class BatchMethods {
|
|
5
|
+
_options: Options;
|
|
6
|
+
_clientInstance: ClientInstance;
|
|
7
|
+
constructor(options: Options);
|
|
8
|
+
getBatch(batchID: number): Promise<Batch>;
|
|
9
|
+
Retry(method: Function): Promise<Batch>;
|
|
10
|
+
delay(ms: number): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BatchMethods = void 0;
|
|
13
|
+
const clientInstance_1 = require("./clientInstance");
|
|
14
|
+
const batchState_1 = require("../enums/batchState.");
|
|
15
|
+
const exception_1 = require("../models/exception");
|
|
16
|
+
class BatchMethods {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this._options = options;
|
|
19
|
+
this._clientInstance = new clientInstance_1.ClientInstance();
|
|
20
|
+
}
|
|
21
|
+
getBatch(batchID) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
let apiPath = `batch/${batchID}`;
|
|
25
|
+
const resp = yield this._clientInstance.executeGet(apiPath, this._options);
|
|
26
|
+
return resp.data;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new exception_1.Exception(`Unable to retreive the batch for id: ${batchID}`, err);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
Retry(method) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let retryCount = this._options.retryCount;
|
|
36
|
+
let duration = this._options.duration;
|
|
37
|
+
if (retryCount <= 0)
|
|
38
|
+
throw new Error('Number of retries has been exhausted.');
|
|
39
|
+
while (true) {
|
|
40
|
+
try {
|
|
41
|
+
let batch = yield method();
|
|
42
|
+
if (batch.batchState === batchState_1.BatchState.Processed) {
|
|
43
|
+
return batch;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
--retryCount;
|
|
47
|
+
if (--retryCount <= 0) {
|
|
48
|
+
throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
|
|
49
|
+
}
|
|
50
|
+
yield this.delay(duration);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
delay(ms) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.BatchMethods = BatchMethods;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { Options } from "../models/options";
|
|
3
|
+
export declare class ClientInstance {
|
|
4
|
+
getInstance(options: Options): AxiosInstance;
|
|
5
|
+
executeGet(apiPath: string, options: Options): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
executeDelete(apiPath: string, options: Options): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
executePost(apiPath: string, options: Options, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ClientInstance = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
class ClientInstance {
|
|
18
|
+
getInstance(options) {
|
|
19
|
+
let baseUrl = options.determineBaseUrl(options.guid);
|
|
20
|
+
let instance = axios_1.default.create({
|
|
21
|
+
baseURL: `${baseUrl}/api/v1/instance/${options.guid}`
|
|
22
|
+
});
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
executeGet(apiPath, options) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
let instance = this.getInstance(options);
|
|
28
|
+
try {
|
|
29
|
+
const resp = yield instance.get(apiPath, {
|
|
30
|
+
headers: {
|
|
31
|
+
'Authorization': `Bearer ${options.token}`,
|
|
32
|
+
'Cache-Control': 'no-cache'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return resp;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
executeDelete(apiPath, options) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
let instance = this.getInstance(options);
|
|
45
|
+
try {
|
|
46
|
+
const resp = yield instance.delete(apiPath, {
|
|
47
|
+
headers: {
|
|
48
|
+
'Authorization': `Bearer ${options.token}`,
|
|
49
|
+
'Cache-Control': 'no-cache'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return resp;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
executePost(apiPath, options, data) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
let instance = this.getInstance(options);
|
|
62
|
+
try {
|
|
63
|
+
const resp = yield instance.post(apiPath, data, {
|
|
64
|
+
headers: {
|
|
65
|
+
'Authorization': `Bearer ${options.token}`,
|
|
66
|
+
'Cache-Control': 'no-cache'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return resp;
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.ClientInstance = ClientInstance;
|