@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.
- package/.github/workflows/npm-publish.yml +61 -0
- package/README.md +396 -371
- package/dist/apiMethods/instanceMethods.d.ts +13 -0
- package/dist/apiMethods/instanceMethods.js +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/exception.d.ts +4 -0
- package/dist/models/exception.js +17 -1
- package/dist/models/fetchApiStatus.d.ts +38 -0
- package/dist/models/fetchApiStatus.js +2 -0
- package/docs/asset-methods.md +381 -381
- package/docs/auth-component.md +360 -360
- package/docs/auth.md +593 -593
- package/docs/batch-methods.md +243 -243
- package/docs/cicd.md +606 -606
- package/docs/container-methods.md +267 -267
- package/docs/content-methods.md +491 -491
- package/docs/instance-methods.md +185 -105
- package/docs/instance-user-methods.md +230 -230
- package/docs/model-methods.md +433 -433
- package/docs/multi-instance-operations.md +191 -191
- package/docs/page-methods.md +737 -737
- package/docs/server-user-methods.md +279 -279
- package/docs/webhook-methods.md +451 -451
- package/license.txt +20 -20
- package/package.json +42 -41
- package/tsconfig.json +14 -14
package/docs/instance-methods.md
CHANGED
|
@@ -1,105 +1,185 @@
|
|
|
1
|
-
# InstanceMethods API Documentation
|
|
2
|
-
|
|
3
|
-
The `InstanceMethods` class provides instance-level operations for retrieving configuration and
|
|
4
|
-
|
|
5
|
-
## Function List
|
|
6
|
-
|
|
7
|
-
| Function | Description |
|
|
8
|
-
|----------|-------------|
|
|
9
|
-
| [getLocales](#getlocales) | Retrieves all available locales for the instance |
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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)
|