@agility/management-sdk 0.1.37 → 0.1.39

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.
@@ -1,105 +1,185 @@
1
- # InstanceMethods API Documentation
2
-
3
- The `InstanceMethods` class provides instance-level operations for retrieving configuration and settings.
4
-
5
- ## Function List
6
-
7
- | Function | Description |
8
- |----------|-------------|
9
- | [getLocales](#getlocales) | Retrieves all available locales for the instance |
10
-
11
- ---
12
-
13
- ## getLocales
14
-
15
- Retrieves all available locales configured for the current Agility CMS instance.
16
-
17
- ### Parameters
18
-
19
- | Parameter | Type | Required | Description |
20
- |-----------|------|----------|-------------|
21
- | guid | string | Yes | The website GUID |
22
-
23
- ### Returns
24
-
25
- `Promise<Locales[]>` - Array of locale objects with language configuration
26
-
27
- ### Usage Example
28
-
29
- ```typescript
30
- const locales = await client.instanceMethods.getLocales('your-guid');
31
-
32
- // Display available locales
33
- locales.forEach(locale => {
34
- console.log(`${locale.name} (${locale.code})`);
35
- });
36
-
37
- // Find default locale
38
- const defaultLocale = locales.find(locale => locale.isDefault);
39
- console.log('Default locale:', defaultLocale.code);
40
-
41
- // Get all enabled locales
42
- const enabledLocales = locales.filter(locale => locale.isEnabled);
43
- console.log(`${enabledLocales.length} locales are enabled`);
44
- ```
45
-
46
- ### Locale Object Structure
47
-
48
- ```typescript
49
- interface Locales {
50
- code: string; // Language code (e.g., 'en-us', 'fr-ca')
51
- name: string; // Display name (e.g., 'English (United States)')
52
- isDefault: boolean; // Whether this is the default locale
53
- isEnabled: boolean; // Whether this locale is enabled
54
- // Additional locale properties may be available
55
- }
56
- ```
57
-
58
- ### Common Use Cases
59
-
60
- ```typescript
61
- // Get locale codes for content operations
62
- const locales = await client.instanceMethods.getLocales(guid);
63
- const localeCodes = locales.map(locale => locale.code);
64
-
65
- // Use with content operations
66
- for (const localeCode of localeCodes) {
67
- const content = await client.contentMethods.getContentItem(123, guid, localeCode);
68
- console.log(`Content in ${localeCode}:`, content.fields.title);
69
- }
70
-
71
- // Check if a specific locale is available
72
- const hasSpanish = locales.some(locale => locale.code === 'es-es');
73
- if (hasSpanish) {
74
- console.log('Spanish locale is available');
75
- }
76
- ```
77
-
78
- ---
79
-
80
- ## Error Handling
81
-
82
- The method throws `Exception` objects on failure:
83
-
84
- ```typescript
85
- try {
86
- const locales = await client.instanceMethods.getLocales('your-guid');
87
- } catch (error) {
88
- console.error('Failed to retrieve locales:', error.message);
89
- }
90
- ```
91
-
92
- ---
93
-
94
- ## Navigation
95
- - [← Back to Main Documentation](../README.md)
96
- - [Authentication & Setup](./auth.md)
97
- - [AssetMethods](./asset-methods.md)
98
- - [BatchMethods](./batch-methods.md)
99
- - [ContainerMethods](./container-methods.md)
100
- - [ContentMethods](./content-methods.md)
101
- - [InstanceUserMethods](./instance-user-methods.md)
102
- - [ModelMethods](./model-methods.md)
103
- - [PageMethods](./page-methods.md)
104
- - [ServerUserMethods](./server-user-methods.md)
105
- - [WebhookMethods](./webhook-methods.md)
1
+ # InstanceMethods API Documentation
2
+
3
+ The `InstanceMethods` class provides instance-level operations for retrieving configuration, settings, and sync status.
4
+
5
+ ## Function List
6
+
7
+ | Function | Description |
8
+ |----------|-------------|
9
+ | [getLocales](#getlocales) | Retrieves all available locales for the instance |
10
+ | [getFetchApiStatus](#getfetchapistatus) | Gets the Fetch API CDN sync status for the instance |
11
+
12
+ ---
13
+
14
+ ## getLocales
15
+
16
+ Retrieves all available locales configured for the current Agility CMS instance.
17
+
18
+ ### Parameters
19
+
20
+ | Parameter | Type | Required | Description |
21
+ |-----------|------|----------|-------------|
22
+ | guid | string | Yes | The website GUID |
23
+
24
+ ### Returns
25
+
26
+ `Promise<Locales[]>` - Array of locale objects with language configuration
27
+
28
+ ### Usage Example
29
+
30
+ ```typescript
31
+ const locales = await client.instanceMethods.getLocales('your-guid');
32
+
33
+ // Display available locales
34
+ locales.forEach(locale => {
35
+ console.log(`${locale.name} (${locale.code})`);
36
+ });
37
+
38
+ // Find default locale
39
+ const defaultLocale = locales.find(locale => locale.isDefault);
40
+ console.log('Default locale:', defaultLocale.code);
41
+
42
+ // Get all enabled locales
43
+ const enabledLocales = locales.filter(locale => locale.isEnabled);
44
+ console.log(`${enabledLocales.length} locales are enabled`);
45
+ ```
46
+
47
+ ### Locale Object Structure
48
+
49
+ ```typescript
50
+ interface Locales {
51
+ code: string; // Language code (e.g., 'en-us', 'fr-ca')
52
+ name: string; // Display name (e.g., 'English (United States)')
53
+ isDefault: boolean; // Whether this is the default locale
54
+ isEnabled: boolean; // Whether this locale is enabled
55
+ }
56
+ ```
57
+
58
+ ---
59
+
60
+ ## getFetchApiStatus
61
+
62
+ Gets the Fetch API CDN sync status for an instance. Use this to check if changes made via the Management API have propagated to the Fetch API CDNs after batch operations or workflows.
63
+
64
+ ### Parameters
65
+
66
+ | Parameter | Type | Required | Description |
67
+ |-----------|------|----------|-------------|
68
+ | guid | string | Yes | The website GUID |
69
+ | mode | 'fetch' \| 'preview' | No | Sync mode: 'fetch' for live/published content, 'preview' for preview content. Defaults to 'fetch'. |
70
+ | waitForCompletion | boolean | No | If true, polls until sync is complete. Defaults to false. |
71
+
72
+ ### Returns
73
+
74
+ `Promise<FetchApiStatus>` - The sync status object
75
+
76
+ ### FetchApiStatus Interface
77
+
78
+ ```typescript
79
+ interface FetchApiStatus {
80
+ timestamp?: string; // Record timestamp
81
+ completionTime?: string; // When the sync completed
82
+ errorMessage?: string; // Error message if sync failed
83
+ inProgress: boolean; // Whether sync is currently in progress
84
+ itemsAffected: number; // Number of items being synced (only available during sync)
85
+ lastContentVersionID: number; // Last content version ID synced
86
+ lastDeletedContentVersionID: number; // Last deleted content version ID synced
87
+ lastDeletedPageVersionID: number; // Last deleted page version ID synced
88
+ leaseID?: string; // Lease ID for the sync operation
89
+ maxChangeDate?: string; // Maximum change date processed
90
+ maxContentModelDate?: string; // Maximum content model date processed
91
+ pushType: number; // Push type (1 = Preview, 2 = Fetch/Live)
92
+ startTime?: string; // When the sync started
93
+ websiteName?: string; // The website name
94
+ }
95
+ ```
96
+
97
+ > **Note:** The `itemsAffected` count is only meaningful while sync is in progress. It decreases as items are processed and reaches 0 when sync completes.
98
+
99
+ ### Usage Examples
100
+
101
+ #### Check Current Sync Status
102
+
103
+ ```typescript
104
+ const status = await client.instanceMethods.getFetchApiStatus('your-guid');
105
+
106
+ if (status.inProgress) {
107
+ console.log('Fetch API sync is in progress...');
108
+ console.log('Started at:', status.startTime);
109
+ } else {
110
+ console.log('Fetch API sync is complete');
111
+ console.log('Completed at:', status.completionTime);
112
+ }
113
+
114
+ // Check preview content sync status
115
+ const previewStatus = await client.instanceMethods.getFetchApiStatus('your-guid', 'preview');
116
+ console.log('Preview sync in progress:', previewStatus.inProgress);
117
+ ```
118
+
119
+ #### Wait for Sync to Complete
120
+
121
+ ```typescript
122
+ // After a batch publish, wait for CDN propagation
123
+ await client.batchMethods.publishBatch(batchId, guid);
124
+
125
+ console.log('Waiting for Fetch API sync to complete...');
126
+ const status = await client.instanceMethods.getFetchApiStatus(guid, 'fetch', true);
127
+ console.log('Sync complete!');
128
+ ```
129
+
130
+ ### Complete Workflow Example
131
+
132
+ ```typescript
133
+ import * as mgmtApi from '@agility/management-sdk';
134
+
135
+ const options = new mgmtApi.Options();
136
+ options.token = 'your-access-token';
137
+ const client = new mgmtApi.ApiClient(options);
138
+
139
+ const guid = 'your-instance-guid';
140
+ const locale = 'en-us';
141
+
142
+ // Step 1: Perform a large batch publish operation
143
+ const contentIDs = [101, 102, 103, 104, 105];
144
+ await client.contentMethods.batchWorkflowContent(
145
+ contentIDs,
146
+ guid,
147
+ locale,
148
+ mgmtApi.WorkflowOperationType.Publish
149
+ );
150
+ console.log('Batch publish submitted');
151
+
152
+ // Step 2: Wait for changes to propagate to CDN
153
+ console.log('Waiting for Fetch API sync...');
154
+ await client.instanceMethods.getFetchApiStatus(guid, 'fetch', true);
155
+ console.log('Sync complete! Content is now available on the CDN');
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Error Handling
161
+
162
+ All methods throw `Exception` objects on failure:
163
+
164
+ ```typescript
165
+ try {
166
+ const status = await client.instanceMethods.getFetchApiStatus('your-guid');
167
+ } catch (error) {
168
+ console.error('Failed to get Fetch API status:', error.message);
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Navigation
175
+ - [← Back to Main Documentation](../README.md)
176
+ - [Authentication & Setup](./auth.md)
177
+ - [AssetMethods](./asset-methods.md)
178
+ - [BatchMethods](./batch-methods.md)
179
+ - [ContainerMethods](./container-methods.md)
180
+ - [ContentMethods](./content-methods.md)
181
+ - [InstanceUserMethods](./instance-user-methods.md)
182
+ - [ModelMethods](./model-methods.md)
183
+ - [PageMethods](./page-methods.md)
184
+ - [ServerUserMethods](./server-user-methods.md)
185
+ - [WebhookMethods](./webhook-methods.md)