@agility/management-sdk 0.1.30 → 0.1.31

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 CHANGED
@@ -4,8 +4,10 @@
4
4
 
5
5
  - Provides a facility to developers to use the new Agility Management API more effectively.
6
6
  - Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
7
- - Supports the creation of Pages and Content in batches.
7
+ - **Content and Page Creation** - Create individual or multiple content items and pages (which automatically get added to batches).
8
+ - **Essential batch workflow operations** - Perform publish, unpublish, approve, decline, and request approval operations on existing batches.
8
9
  - Ability to generate Content in bulk for a Website.
10
+ - **Strongly typed TypeScript interfaces** for all batch operations with comprehensive error handling.
9
11
 
10
12
  ## Getting Started
11
13
 
@@ -22,6 +24,10 @@ The authentication process uses OAuth 2.0 and requires multiple steps:
22
24
  1. First, initiate the authorization flow by making a GET request to the authorization endpoint:
23
25
  ```javascript
24
26
  const authUrl = 'https://mgmt.aglty.io/oauth/authorize';
27
+
28
+ //if you wish to implement offline access using refresh tokens, use this URL (enables refresh tokens)
29
+ //const authUrl = 'https://mgmt.aglty.io/oauth/authorize?scope=offline-access ';
30
+
25
31
  const params = new URLSearchParams({
26
32
  response_type: 'code',
27
33
  redirect_uri: 'YOUR_REDIRECT_URI',
@@ -50,7 +56,7 @@ const { access_token, refresh_token, expires_in } = await response.json();
50
56
 
51
57
  3. Use the obtained token to initialize the SDK:
52
58
  ```javascript
53
- import * as mgmtApi from "./index";
59
+ import * as mgmtApi from "@agility/management-sdk";
54
60
 
55
61
  // Initialize the Options Class with your authentication token
56
62
  let options = new mgmtApi.Options();
@@ -88,11 +94,10 @@ Note:
88
94
  - Store refresh tokens securely and never expose them in client-side code
89
95
  - Implement proper error handling for authentication failures
90
96
 
91
- 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 -
92
97
 
93
98
  ### Making a Request
94
99
  ```Javascript
95
- import * as mgmtApi from "./index";
100
+ import * as mgmtApi from "@agility/management-sdk";
96
101
 
97
102
  //initialize the Options Class
98
103
  let options = new mgmtApi.Options();
@@ -112,6 +117,26 @@ var contentItem = await apiClient.contentMethods.getContentItem(22,guid, locale)
112
117
  //To log the response of the contentItem object in console.
113
118
  console.log(JSON.stringify(contentItem));
114
119
  ```
120
+
121
+ ## Understanding Agility CMS Batch Architecture
122
+
123
+ Agility CMS uses a simple approach for working with content and batches:
124
+
125
+ ### Content/Page Creation (Handled by Respective Controllers)
126
+ - **contentMethods.saveContentItem()** - Creates a single new content item and adds it to a batch
127
+ - **contentMethods.saveContentItems()** - Creates multiple new content items and adds them to a batch
128
+ - **pageMethods.savePage()** - Creates a new page and adds it to a batch
129
+ - These methods create the content AND automatically handle batch creation/management
130
+
131
+ ### Batch Workflow Operations (Handled by Batch Controller)
132
+ - **batchMethods.publishBatch()** - Publishes all items in an existing batch
133
+ - **batchMethods.unpublishBatch()** - Unpublishes all items in an existing batch
134
+ - **batchMethods.approveBatch()** - Approves all items in an existing batch
135
+ - **batchMethods.declineBatch()** - Declines all items in an existing batch
136
+ - **batchMethods.requestApprovalBatch()** - Requests approval for all items in an existing batch
137
+ - **batchMethods.getBatch()** - Retrieves details of an existing batch
138
+ - **batchMethods.getBatchTypes()** - Retrieves all batch-related enum types for developer discovery
139
+
115
140
  ## Class AssetMethods
116
141
  This class is used to perform operations related to Assets. The following are the methods: -
117
142
 
@@ -240,539 +265,281 @@ Returns: An object of ```Media``` class with the information of the asset.
240
265
  Returns: An object of ```Media``` class with the information of the asset.
241
266
 
242
267
  ## Class BatchMethods
243
- This class is used to perform operations related to Batches. The following are the methods: -
244
-
245
- ### getBatch
246
- | Parameter | Type | Description |
247
- | :-------- | :------- | :------------------------- |
248
- | `id` | `number` | The batchID of the requested batch.|
249
- | `guid` | `string` | Current website guid.|
250
-
251
- Returns: A object of ```Batch``` class.
252
-
253
- ## Class ContainerMethods
254
- This class is used to perform operations related to Containers. The following are the methods: -
255
-
256
- ### getContainerByID
257
- | Parameter | Type | Description |
258
- | :-------- | :------- | :------------------------- |
259
- | `id` | `number` | The container id of the requested container.|
260
- | `guid` | `string` | Current website guid.|
261
-
262
- Returns: A object of ```Container``` class.
263
-
264
- ### getContainersByModel
265
- | Parameter | Type | Description |
266
- | :-------- | :------- | :------------------------- |
267
- | `modelId` | `number` | The model id of the requested container.|
268
- | `guid` | `string` | Current website guid.|
269
-
270
- Returns: A object of ```Container``` class.
271
-
272
- ### getContainerByReferenceName
273
- | Parameter | Type | Description |
274
- | :-------- | :------- | :------------------------- |
275
- | `referenceName` | `string` | The container reference name of the requested container.|
276
- | `guid` | `string` | Current website guid.|
277
-
278
- Returns: A object of ```Container``` class.
279
-
280
- ### getContainerSecurity
281
- | Parameter | Type | Description |
282
- | :-------- | :------- | :------------------------- |
283
- | `id` | `number` | The container id of the requested container.|
284
- | `guid` | `string` | Current website guid.|
285
-
286
- Returns: A object of ```Container``` class.
287
-
288
- ### getContainerList
289
- | Parameter | Type | Description |
290
- | :-------- | :------- | :------------------------- |
291
- | `guid` | `string` | Current website guid.|
292
- Returns: A collection object of ```Container``` class.
293
-
294
- ### getNotificationList
295
- | Parameter | Type | Description |
296
- | :-------- | :------- | :------------------------- |
297
- | `id` | `number` | The container id of the requested container.|
298
- | `guid` | `string` | Current website guid.|
299
- Returns: A collection object of ```Notification``` class.
300
-
301
- ### saveContainer
302
- | Parameter | Type | Description |
303
- | :-------- | :------- | :------------------------- |
304
- | `container` | `Container` | A Container type object to create or update a container.|
305
- | `guid` | `string` | Current website guid.|
306
-
307
- Returns: An object of ```Container``` class.
308
-
309
- ### deleteContainer
310
- | Parameter | Type | Description |
311
- | :-------- | :------- | :------------------------- |
312
- | `id` | `number` | The container id of the requested container.|
313
- | `guid` | `string` | Current website guid.|
314
- Returns: A ```string``` response if a container has been deleted.
315
-
316
- ## Class ContentMethods
317
- This class is used to perform operations related to Content. The following are the methods: -
318
-
319
- ### getContentItem
320
- | Parameter | Type | Description |
321
- | :-------- | :------- | :------------------------- |
322
- | `contentID` | `number` | The contentid of the requested content.|
323
- | `guid` | `string` | Current website guid.|
324
- | `locale` | `string` | Current website locale.|
325
-
326
- Returns: An object of ```ContentItem``` class.
327
-
328
- ### publishContent
329
- | Parameter | Type | Description |
330
- | :-------- | :------- | :------------------------- |
331
- | `contentID` | `number` | The contentid of the requested content.|
332
- | `guid` | `string` | Current website guid.|
333
- | `locale` | `string` | Current website locale.|
334
- | `comments` | `string` | Additional comments for a batch request.|
335
-
336
- Returns: An array of ```contentID``` of the requested content.
337
-
338
- ### unPublishContent
339
- | Parameter | Type | Description |
340
- | :-------- | :------- | :------------------------- |
341
- | `contentID` | `number` | The contentid of the requested content.|
342
- | `guid` | `string` | Current website guid.|
343
- | `locale` | `string` | Current website locale.|
344
- | `comments` | `string` | Additional comments for a batch request.|
345
-
346
- Returns: An array of ```contentID``` of the requested content.
347
-
348
- ### contentRequestApproval
349
- | Parameter | Type | Description |
350
- | :-------- | :------- | :------------------------- |
351
- | `contentID` | `number` | The contentid of the requested content.|
352
- | `guid` | `string` | Current website guid.|
353
- | `locale` | `string` | Current website locale.|
354
- | `comments` | `string` | Additional comments for a batch request.|
355
-
356
- Returns: An array of ```contentID``` of the requested content.
357
-
358
- ### approveContent
359
- | Parameter | Type | Description |
360
- | :-------- | :------- | :------------------------- |
361
- | `contentID` | `number` | The contentid of the requested content.|
362
- | `guid` | `string` | Current website guid.|
363
- | `locale` | `string` | Current website locale.|
364
- | `comments` | `string` | Additional comments for a batch request.|
365
-
366
- Returns: An array of ```contentID``` of the requested content.
367
-
368
- ### declineContent
369
- | Parameter | Type | Description |
370
- | :-------- | :------- | :------------------------- |
371
- | `contentID` | `number` | The contentid of the requested content.|
372
- | `guid` | `string` | Current website guid.|
373
- | `locale` | `string` | Current website locale.|
374
- | `comments` | `string` | Additional comments for a batch request.|
375
-
376
- Returns: An array of ```contentID``` of the requested content.
377
-
378
- ### saveContentItem
379
- | Parameter | Type | Description |
380
- | :-------- | :------- | :------------------------- |
381
- | `contentItem` | `ContentItem` | A contentItem object to create or update a content.|
382
- | `guid` | `string` | Current website guid.|
383
- | `locale` | `string` | Current website locale.|
384
-
385
- Returns: An array of ```contentID``` of the requested content.
386
-
387
- ### saveContentItems
388
- | Parameter | Type | Description |
389
- | :-------- | :------- | :------------------------- |
390
- | `contentItems` | `ContentItem[]` | A collection of contentItems object to create or update multiple contents.|
391
- | `guid` | `string` | Current website guid.|
392
- | `locale` | `string` | Current website locale.|
393
-
394
- Returns: An array of ```contentID``` of the requested content.
395
-
396
- ### deleteContent
397
- | Parameter | Type | Description |
398
- | :-------- | :------- | :------------------------- |
399
- | `contentID` | `number` | The contentid of the requested content.|
400
- | `guid` | `string` | Current website guid.|
401
- | `locale` | `string` | Current website locale.|
402
- | `comments` | `string` | Additional comments for a batch request.|
403
-
404
- Returns: An array of ```contentID``` of the requested content.
405
-
406
- ### getContentItems
407
- | Parameter | Type | Description |
408
- | :-------- | :------- | :------------------------- |
409
- | `referenceName` | `string` | The reference name of the container for the requested content.|
410
- | `guid` | `string` | Current website guid.|
411
- | `locale` | `string` | Current website locale.|
412
- | `listParams` | `ListParams` | The parameters list to apply filter on the content list.|
413
-
414
- Returns: An object of ```ContentList``` class of the requested content.
415
-
416
- ### getContentList
417
- | Parameter | Type | Description |
418
- | :-------- | :------- | :------------------------- |
419
- | `referenceName` | `string` | The reference name of the container for the requested content.|
420
- | `guid` | `string` | Current website guid.|
421
- | `locale` | `string` | Current website locale.|
422
- | `listParams` | `ListParams` | The parameters list to apply filter on the content list.|
423
- | `filterObject` | `ContentListFilterModel` | To apply filter at the field level.|
424
-
425
- Returns: An object of ```ContentList``` class of the requested content.
426
-
427
- ### getContentHistory
428
- | Parameter | Type | Description |
429
- | :-------- | :------- | :------------------------- |
430
- | `locale` | `string` | Current website locale.|
431
- | `guid` | `string` | Current website guid.|
432
- | `contentID` | `number` | The contentID of the requested content.|
433
- | `take` | `number` | The number of items per record set default value 50.|
434
- | `skip` | `number` | The skip level on the record set default value 0.|
435
-
436
- Returns: An object of ```ContentItemHistory``` class of the requested content history.
437
-
438
- ### getContentComments
439
- | Parameter | Type | Description |
440
- | :-------- | :------- | :------------------------- |
441
- | `locale` | `string` | Current website locale.|
442
- | `guid` | `string` | Current website guid.|
443
- | `contentID` | `number` | The contentID of the requested content.|
444
- | `take` | `number` | The number of items per record set default value 50.|
445
- | `skip` | `number` | The skip level on the record set default value 0.|
268
+ This class is used to perform **workflow operations** on existing batches.
446
269
 
447
- Returns: An object of ```ItemComments``` class of the requested content comments.
270
+ **Important**: To CREATE new content or pages, use `contentMethods.saveContentItem(s)` or `pageMethods.savePage()` instead. These batch methods are for managing workflow operations (publish, unpublish, approve, etc.) on existing batches.
448
271
 
449
- ## Class InstanceUserMethods
450
- This class is used to perform operations related to User. The following are the methods: -
451
-
452
- ### getUsers
453
- | Parameter | Type | Description |
454
- | :-------- | :------- | :------------------------- |
455
- | `guid` | `string` | Current website guid.|
456
- Returns: A collection of ```WebsiteUser``` class of the requested content.
457
-
458
- ### saveUser
459
- | Parameter | Type | Description |
460
- | :-------- | :------- | :------------------------- |
461
- | `emailAddress` | `string` | The email address of the requested user.|
462
- | `roles` | `InstanceRole[]` | Collection object of InstanceRole class for the requested user.|
463
- | `guid` | `string` | Current website guid.|
464
- | `firstName` | `string` | The first name of the requested user.|
465
- | `lastName` | `string` | The last name of the requested user.|
466
-
467
- Returns: An object of the ```InstanceUser``` class.
468
-
469
- ### deleteUser
470
- | Parameter | Type | Description |
471
- | :-------- | :------- | :------------------------- |
472
- | `userID` | `number` | The userID of the requested user.|
473
- | `guid` | `string` | Current website guid.|
474
-
475
- Returns: A ```string``` response if a user has been deleted.
476
-
477
- ## Class ModelMethods
478
- This class is used to perform operations related to Models. The following are the methods: -
479
-
480
- ### getContentModel
481
- | Parameter | Type | Description |
482
- | :-------- | :------- | :------------------------- |
483
- | `id` | `number` | The id of the requested model.|
484
- | `guid` | `string` | Current website guid.|
485
-
486
- Returns: An object of ```Model``` class.
487
-
488
- ### GetModelByReferenceName
489
- | Parameter | Type | Description |
490
- | :-------- | :------- | :------------------------- |
491
- | `referenceName` | `string` | The referenceName of the requested model.|
492
- | `guid` | `string` | The guid of the requested model.|
493
-
494
- ### getContentModules
495
- | Parameter | Type | Description |
496
- | :-------- | :------- | :------------------------- |
497
- | `includeDefaults` | `bool` | Boolean value to include defaults.|
498
- | `guid` | `string` | Current website guid.|
499
- | `includeModules` | `bool` | Boolean value to include modules.|
500
-
501
- Returns: A collection object of ```Model``` class.
502
-
503
- ### getPageModules
504
- | Parameter | Type | Description |
505
- | :-------- | :------- | :------------------------- |
506
- | `includeDefault` | `bool` | Boolean value to include defaults.|
507
- | `guid` | `string` | Current website guid.|
508
-
509
- Returns: A collection object of ```Model``` class.
510
-
511
- ### saveModel
512
- | Parameter | Type | Description |
513
- | :-------- | :------- | :------------------------- |
514
- | `model` | `Model` | The object of Model to for the requested model.|
515
- | `guid` | `string` | Current website guid.|
516
-
517
- Returns: An object of ```Model``` class.
518
-
519
- ### deleteModel
520
- | Parameter | Type | Description |
521
- | :-------- | :------- | :------------------------- |
522
- | `id` | `number` | The id for the requested model.|
523
- | `guid` | `string` | Current website guid.|
524
-
525
- Returns: A ```string``` response if a model is deleted.
526
-
527
- ## Class PageMethods
528
- This class is used to perform operations related to Pages. The following are the methods: -
529
-
530
- ### getSitemap
531
- | Parameter | Type | Description |
532
- | :-------- | :------- | :------------------------- |
533
- | `guid` | `string` | Current website guid.|
534
- | `locale` | `string` | Current website locale.|
535
- Returns: A collection object of ```Sitemap``` class.
536
-
537
- ### getPageTemplates
538
- | Parameter | Type | Description |
539
- | :-------- | :------- | :------------------------- |
540
- | `guid` | `string` | Current website guid.|
541
- | `locale` | `string` | Current website locale.|
542
- | `includeModuleZones` | `boolean` | To include zones in the result set.|
543
- | `searchFilter` | `string` | To apply search criteria on the requested page template.|
544
- Returns: A collection object of ```PageModel``` class.
272
+ ### getBatch
273
+ Retrieves details of an existing batch.
545
274
 
546
- ### getPageTemplate
547
275
  | Parameter | Type | Description |
548
276
  | :-------- | :------- | :------------------------- |
277
+ | `batchID` | `number` | The batchID of the requested batch.|
549
278
  | `guid` | `string` | Current website guid.|
550
- | `locale` | `string` | Current website locale.|
551
- | `pageTemplateId` | `number` | The pageTemplateId of the requested page template.|
552
- Returns: An object of ```PageModel``` class.
279
+ | `expandItems` | `boolean` | *(Optional)* Whether to include full item details. Default: `true`|
553
280
 
554
- ### getPageTemplateName
555
- | Parameter | Type | Description |
556
- | :-------- | :------- | :------------------------- |
557
- | `guid` | `string` | Current website guid.|
558
- | `locale` | `string` | Current website locale.|
559
- | `templateName` | `string` | The templateName of the requested page template.|
560
- Returns: An object of ```PageModel``` class.
281
+ Returns: An object of ```Batch``` class.
561
282
 
562
- ### deletePageTemplate
563
- | Parameter | Type | Description |
564
- | :-------- | :------- | :------------------------- |
565
- | `guid` | `string` | Current website guid.|
566
- | `locale` | `string` | Current website locale.|
567
- | `pageTemplateId` | `string` | The pageTemplateId of the requested page template.|
283
+ ```javascript
284
+ // Get batch with full item details (default)
285
+ const batch = await apiClient.batchMethods.getBatch(123, guid);
568
286
 
569
- ### getPageItemTemplates
570
- | Parameter | Type | Description |
571
- | :-------- | :------- | :------------------------- |
572
- | `guid` | `string` | Current website guid.|
573
- | `locale` | `string` | Current website locale.|
574
- | `id` | `number` | The id of the requested page template.|
575
- Returns: A collection of ```ContentSectionDefinition``` class.
287
+ // Get basic batch information only (performance optimization)
288
+ const batchBasic = await apiClient.batchMethods.getBatch(123, guid, false);
289
+ ```
576
290
 
577
- ### savePageTemplate
578
- | Parameter | Type | Description |
579
- | :-------- | :------- | :------------------------- |
580
- | `guid` | `string` | Current website guid.|
581
- | `locale` | `string` | Current website locale.|
582
- | `pageModel` | `PageModel` | The pageModel object of the requested page template.|
583
- Returns: An object of ```PageModel``` class.
291
+ ### publishBatch
292
+ Publishes all items in an existing batch.
584
293
 
585
- ### getPage
586
294
  | Parameter | Type | Description |
587
295
  | :-------- | :------- | :------------------------- |
588
- | `pageID` | `number` | The id of the requested page.|
296
+ | `batchID` | `number` | The batchID of the batch to publish.|
589
297
  | `guid` | `string` | Current website guid.|
590
- | `locale` | `string` | Current website locale.|
298
+ | `returnBatchId` | `boolean` | *(Optional)* If `true`, returns batch ID immediately. If `false` (default), waits for completion.|
591
299
 
592
- Returns: An object of ```PageItem``` class.
300
+ Returns: A ```number``` representing the batch ID.
593
301
 
594
- ### publishPage
595
- | Parameter | Type | Description |
596
- | :-------- | :------- | :------------------------- |
597
- | `pageID` | `number` | The pageID of the requested page.|
598
- | `guid` | `string` | Current website guid.|
599
- | `locale` | `string` | Current website locale.|
600
- | `comments` | `string` | Additional comments for a batch request.|
601
-
602
- Returns: An array of ```pageID``` of the requested page.
302
+ ```javascript
303
+ // Publish batch and wait for completion (default)
304
+ const batchId = await apiClient.batchMethods.publishBatch(123, guid);
603
305
 
604
- ### unPublishPage
605
- | Parameter | Type | Description |
606
- | :-------- | :------- | :------------------------- |
607
- | `pageID` | `number` | The pageID of the requested page.|
608
- | `guid` | `string` | Current website guid.|
609
- | `locale` | `string` | Current website locale.|
610
- | `comments` | `string` | Additional comments for a batch request.|
306
+ // Publish batch and return immediately for custom polling
307
+ const batchId = await apiClient.batchMethods.publishBatch(123, guid, true);
308
+ ```
611
309
 
612
- Returns: An array of ```pageID``` of the requested page.
310
+ ### unpublishBatch
311
+ Unpublishes all items in an existing batch.
613
312
 
614
- ### deletePage
615
313
  | Parameter | Type | Description |
616
314
  | :-------- | :------- | :------------------------- |
617
- | `pageID` | `number` | The pageID of the requested page.|
315
+ | `batchID` | `number` | The batchID of the batch to unpublish.|
618
316
  | `guid` | `string` | Current website guid.|
619
- | `locale` | `string` | Current website locale.|
620
- | `comments` | `string` | Additional comments for a batch request.|
621
-
622
- Returns: An array of ```pageID``` of the requested page.
317
+ | `returnBatchId` | `boolean` | *(Optional)* If `true`, returns batch ID immediately. If `false` (default), waits for completion.|
623
318
 
624
- ### approvePage
625
- | Parameter | Type | Description |
626
- | :-------- | :------- | :------------------------- |
627
- | `pageID` | `number` | The pageID of the requested page.|
628
- | `guid` | `string` | Current website guid.|
629
- | `locale` | `string` | Current website locale.|
630
- | `comments` | `string` | Additional comments for a batch request.|
319
+ Returns: A ```number``` representing the batch ID.
631
320
 
632
- Returns: An array of ```pageID``` of the requested page.
321
+ ### approveBatch
322
+ Approves all items in an existing batch.
633
323
 
634
- ### declinePage
635
324
  | Parameter | Type | Description |
636
325
  | :-------- | :------- | :------------------------- |
637
- | `pageID` | `number` | The pageID of the requested page.|
326
+ | `batchID` | `number` | The batchID of the batch to approve.|
638
327
  | `guid` | `string` | Current website guid.|
639
- | `locale` | `string` | Current website locale.|
640
- | `comments` | `string` | Additional comments for a batch request.|
328
+ | `returnBatchId` | `boolean` | *(Optional)* If `true`, returns batch ID immediately. If `false` (default), waits for completion.|
641
329
 
642
- Returns: An array of ```pageID``` of the requested page.
330
+ Returns: A ```number``` representing the batch ID.
643
331
 
644
- ### pageRequestApproval
645
- | Parameter | Type | Description |
646
- | :-------- | :------- | :------------------------- |
647
- | `pageID` | `number` | The pageID of the requested page.|
648
- | `guid` | `string` | Current website guid.|
649
- | `locale` | `string` | Current website locale.|
650
- | `comments` | `string` | Additional comments for a batch request.|
651
-
652
- Returns: An array of ```pageID``` of the requested page.
332
+ ### declineBatch
333
+ Declines all items in an existing batch.
653
334
 
654
- ### savePage
655
335
  | Parameter | Type | Description |
656
336
  | :-------- | :------- | :------------------------- |
657
- | `pageItem` | `PageItem` | The object of PageItem class for the requested Page.|
337
+ | `batchID` | `number` | The batchID of the batch to decline.|
658
338
  | `guid` | `string` | Current website guid.|
659
- | `locale` | `string` | Current website locale.|
660
- | `parentPageID` | `number` | The id of the parent page.|
661
- | `placeBeforePageItemID` | `number` | The id of the page before the page.|
339
+ | `returnBatchId` | `boolean` | *(Optional)* If `true`, returns batch ID immediately. If `false` (default), waits for completion.|
662
340
 
663
- Returns: An array of ```pageID``` of the requested page.
664
-
665
- ### getPageHistory
666
- | Parameter | Type | Description |
667
- | :-------- | :------- | :------------------------- |
668
- | `locale` | `string` | Current website locale.|
669
- | `guid` | `string` | Current website guid.|
670
- | `pageID` | `number` | The pageID of the requested page.|
671
- | `take` | `number` | The number of items per record set default value 50.|
672
- | `skip` | `number` | The skip level on the record set default value 0.|
341
+ Returns: A ```number``` representing the batch ID.
673
342
 
674
- Returns: An object of ```PageHistory``` class of the requested page history.
343
+ ### requestApprovalBatch
344
+ Requests approval for all items in an existing batch.
675
345
 
676
- ### getPageComments
677
346
  | Parameter | Type | Description |
678
347
  | :-------- | :------- | :------------------------- |
679
- | `locale` | `string` | Current website locale.|
348
+ | `batchID` | `number` | The batchID of the batch to request approval for.|
680
349
  | `guid` | `string` | Current website guid.|
681
- | `pageID` | `number` | The pageID of the requested page.|
682
- | `take` | `number` | The number of items per record set default value 50.|
683
- | `skip` | `number` | The skip level on the record set default value 0.|
684
-
685
- Returns: An object of ```ItemComments``` class of the requested page comments.
350
+ | `returnBatchId` | `boolean` | *(Optional)* If `true`, returns batch ID immediately. If `false` (default), waits for completion.|
686
351
 
687
- ## Class ServerUserMethods
688
- This class is used to perform operations related to Server User. The following are the methods: -
689
-
690
- ### me
691
- | Parameter | Type | Description |
692
- | :-------- | :------- | :------------------------- |
693
- | `guid` | `string` | Current website guid.|
352
+ Returns: A ```number``` representing the batch ID.
694
353
 
695
- Returns: An object of ```ServerUser``` class of the requested user.
354
+ ### getBatchTypes
355
+ Retrieves all batch-related enum types for developer discovery and dynamic UI population.
696
356
 
697
- ### you
698
357
  | Parameter | Type | Description |
699
358
  | :-------- | :------- | :------------------------- |
700
359
  | `guid` | `string` | Current website guid.|
701
- | `serverUserID` | `number` | Current website guid.|
702
360
 
703
- Returns: An object of ```ServerUser``` class of the requested user.
361
+ Returns: A ```BatchTypesResponse``` object containing all enum types.
704
362
 
705
- ## Class WebhookMethods
706
- This class is used to perform operations related to Webhooks in the agility instance. The following are the methods: -
363
+ ```javascript
364
+ // Get all batch types for dynamic UI population
365
+ const types = await apiClient.batchMethods.getBatchTypes(guid);
366
+
367
+ // Create dropdown options for item types
368
+ const itemTypeOptions = types.itemTypes.map(type => ({
369
+ label: type.name,
370
+ value: type.value
371
+ }));
372
+
373
+ // Validate operation type
374
+ const isValidWorkflowOperation = (value) =>
375
+ types.workflowOperations.some(op => op.value === value);
376
+
377
+ // Access specific enum data
378
+ console.log('Available item types:', types.itemTypes);
379
+ console.log('Available workflow operations:', types.workflowOperations);
380
+ console.log('Available batch states:', types.states);
381
+ console.log('All operation types:', types.operationTypes);
382
+ ```
707
383
 
708
- ### webhookList
709
- | Parameter | Type | Description |
710
- | :-------- | :------- | :------------------------- |
711
- | `guid` | `string` | Current website guid.|
712
- | `take` | `number` | The number of items per record set default value 20.|
713
- | `skip` | `number` | The skip level on the record set default value 0.|
384
+ **Response Structure:**
385
+ ```typescript
386
+ interface BatchTypesResponse {
387
+ itemTypes: EnumInfo[]; // Page, ContentItem, ContentList, Tag, ModuleDef
388
+ operationTypes: EnumInfo[]; // All operation types
389
+ workflowOperations: EnumInfo[]; // Publish, Unpublish, Approve, Decline, RequestApproval
390
+ states: EnumInfo[]; // None, Pending, InProcess, Processed, Deleted
391
+ }
392
+
393
+ interface EnumInfo {
394
+ value: number; // Numeric enum value
395
+ name: string; // String name (e.g., "Publish")
396
+ description: string; // Human-readable description
397
+ }
398
+ ```
714
399
 
715
- Returns: A list of webhooks configured in the instance.
400
+ **Benefits:**
401
+ - 🎨 **Dynamic UI Population** - Frontend dropdowns populate automatically
402
+ - ✅ **Client Validation** - Validate inputs against live API data
403
+ - 🔍 **API Discovery** - Explore options without reading docs
404
+ - 🚀 **Future-Proof** - New enum values appear automatically
405
+
406
+ ## Complete Workflow Example
407
+
408
+ Here's a complete example showing how to work with batches:
409
+
410
+ ```typescript
411
+ import { ApiClient } from '@agility/management-sdk';
412
+
413
+ const client = new ApiClient({ token: 'your-token' });
414
+ const guid = 'your-instance-guid';
415
+ const locale = 'en-us';
416
+
417
+ // Get batch types for dynamic UI and validation
418
+ const batchTypes = await client.batchMethods.getBatchTypes(guid);
419
+ console.log('Available batch types loaded:', batchTypes);
420
+
421
+ // Create NEW content items (handled by content controller)
422
+ // This automatically creates and manages batches
423
+ const newContentBatchID = await client.contentMethods.saveContentItem(locale, {
424
+ properties: {
425
+ referenceName: 'blog-post',
426
+ definitionName: 'BlogPost',
427
+ state: 2
428
+ },
429
+ fields: {
430
+ title: 'My New Blog Post',
431
+ content: 'This is the blog post content...'
432
+ }
433
+ });
716
434
 
717
- ### saveWebhook
718
- | Parameter | Type | Description |
719
- | :-------- | :------- | :------------------------- |
720
- | `guid` | `string` | Current website guid.|
721
- | `webhook` | `Webhook` | An object of Webhook type with the webhook data.|
435
+ // Create NEW page (handled by page controller)
436
+ // This automatically creates and manages batches
437
+ const newPageBatchID = await client.pageMethods.savePage(locale, {
438
+ name: 'new-product-page',
439
+ title: 'New Product Page',
440
+ menuText: 'New Product',
441
+ pageType: 'static',
442
+ templateName: 'Product Template',
443
+ parentPageID: -1
444
+ });
722
445
 
723
- Returns: An object with the created Webhook.
446
+ // Retrieve details of an existing batch
447
+ const batchDetails = await client.batchMethods.getBatch(newContentBatchID, guid);
448
+ console.log('Batch details:', batchDetails);
724
449
 
725
- ### getWebhook
726
- | Parameter | Type | Description |
727
- | :-------- | :------- | :------------------------- |
728
- | `guid` | `string` | Current website guid.|
729
- | `webhookID` | `string` | The webhookID of the requested webhook.|
450
+ // Perform workflow operations on existing batches
451
+ await client.batchMethods.publishBatch(newContentBatchID, guid);
452
+ await client.batchMethods.approveBatch(newPageBatchID, guid);
730
453
 
731
- Returns: An object with the requested Webhook.
454
+ // Or use immediate return for custom polling
455
+ const batchId = await client.batchMethods.publishBatch(newContentBatchID, guid, true);
456
+ console.log('Batch submitted for publishing:', batchId);
732
457
 
733
- ### deleteWebhook
734
- | Parameter | Type | Description |
735
- | :-------- | :------- | :------------------------- |
736
- | `guid` | `string` | Current website guid.|
737
- | `webhookID` | `string` | The webhookID of the requested webhook.|
458
+ console.log('All operations completed successfully!');
459
+ ```
738
460
 
739
- ## Class Instance
461
+ ## Summary: Complete BatchMethods API
462
+
463
+ The `BatchMethods` class provides **7 essential methods** for batch workflow management:
464
+
465
+ ### **Batch Operations (7 methods)**
466
+ - `getBatch()` - Retrieve batch details and status
467
+ - `publishBatch()` - Publish all items in a batch
468
+ - `unpublishBatch()` - Unpublish all items in a batch
469
+ - `approveBatch()` - Approve all items in a batch
470
+ - `declineBatch()` - Decline all items in a batch
471
+ - `requestApprovalBatch()` - Request approval for all items in a batch
472
+ - `getBatchTypes()` - Get all enum types for dynamic UIs
473
+
474
+ **Developer Experience Features:**
475
+ - 🎨 **Dynamic UI Support** - `getBatchTypes()` populates dropdowns automatically
476
+ - ✅ **Strong Typing** - Full TypeScript support with intellisense
477
+ - 🔄 **Auto-Retry Logic** - Built-in polling for operation completion
478
+ - 📚 **Self-Documenting** - Enum discovery eliminates hard-coded values
479
+ - ⚡ **Streamlined API** - Focused on essential batch workflow operations
480
+
481
+ ## TypeScript Interfaces
482
+
483
+ ### Batch Response Interfaces
484
+
485
+ ```typescript
486
+ interface BatchTypesResponse {
487
+ itemTypes: EnumInfo[]; // Page, ContentItem, ContentList, Tag, ModuleDef
488
+ operationTypes: EnumInfo[]; // All operation types
489
+ workflowOperations: EnumInfo[]; // Publish, Unpublish, Approve, Decline, RequestApproval
490
+ states: EnumInfo[]; // None, Pending, InProcess, Processed, Deleted
491
+ }
492
+
493
+ interface EnumInfo {
494
+ value: number; // Numeric enum value
495
+ name: string; // String name (e.g., "Publish")
496
+ description: string; // Human-readable description
497
+ }
498
+ ```
740
499
 
741
- ### getLocales
742
- | Parameter | Type | Description |
743
- | :-------- | :------- | :------------------------- |
744
- | `guid` | `string` | Current website guid.|
500
+ ## Available Enums
745
501
 
746
- Returns: An array of locales. ex. ['en-us','fr-ca']
502
+ ### WorkflowOperationType (for batch processing)
503
+ > **Note**: In the API documentation (Swagger UI), these operations appear as descriptive dropdown options (Publish, Unpublish, Approve, Decline, RequestApproval) instead of numbers.
747
504
 
748
- ## Running the SDK Locally
505
+ - `Publish = 1`
506
+ - `Unpublish = 2`
507
+ - `Approve = 3`
508
+ - `Decline = 4`
509
+ - `RequestApproval = 5`
749
510
 
750
- - `npm run clean`
751
- - `npm run prepare`
752
- - `npm run build`
511
+ ### BatchItemType
512
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive dropdown options (Page, ContentItem, ContentList, Tag, ModuleDef) instead of numbers.
753
513
 
754
- ## How It Works
514
+ - `Page = 1`
515
+ - `ContentItem = 2`
516
+ - `ContentList = 3`
517
+ - `Tag = 4`
518
+ - `ModuleDef = 5`
755
519
 
756
- - [How Pages Work](https://help.agilitycms.com/hc/en-us/articles/4404222849677)
757
- - [How Page Modules Work](https://help.agilitycms.com/hc/en-us/articles/4404222989453)
758
- - [How Page Templates Work](https://help.agilitycms.com/hc/en-us/articles/4404229108877)
520
+ ### BatchState
521
+ > **Note**: In the API documentation (Swagger UI), these appear as descriptive names (None, Pending, InProcess, Processed, Deleted) instead of numbers.
759
522
 
760
- ## Resources
523
+ - `None = 0` - Batch created but not submitted for processing
524
+ - `Pending = 1` - Batch is pending processing
525
+ - `InProcess = 2` - Batch is currently being processed
526
+ - `Processed = 3` - Batch has been processed successfully
527
+ - `Deleted = 4` - Batch has been deleted
761
528
 
762
- ### Agility CMS
529
+ ## Error Handling
763
530
 
764
- - [Official site](https://agilitycms.com)
765
- - [Documentation](https://help.agilitycms.com/hc/en-us)
531
+ All methods throw exceptions on failure:
766
532
 
767
- ### Community
533
+ ```typescript
534
+ try {
535
+ const batch = await client.batchMethods.getBatch(123, 'instance-guid');
536
+ } catch (error) {
537
+ console.error('Failed to get batch:', error.message);
538
+ }
539
+ ```
768
540
 
769
- - [Official Slack](https://join.slack.com/t/agilitycommunity/shared_invite/enQtNzI2NDc3MzU4Njc2LWI2OTNjZTI3ZGY1NWRiNTYzNmEyNmI0MGZlZTRkYzI3NmRjNzkxYmI5YTZjNTg2ZTk4NGUzNjg5NzY3OWViZGI)
770
- - [Blog](https://agilitycms.com/resources/posts)
771
- - [GitHub](https://github.com/agility)
772
- - [Forums](https://help.agilitycms.com/hc/en-us/community/topics)
773
- - [Facebook](https://www.facebook.com/AgilityCMS/)
774
- - [Twitter](https://twitter.com/AgilityCMS)
541
+ ## License
775
542
 
776
- ## Feedback and Questions
543
+ MIT
777
544
 
778
- 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).
545
+ 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).