@agility/management-sdk 0.1.37 → 0.1.38
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 +27 -2
- 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/fetchApiStatus.d.ts +38 -0
- package/dist/models/fetchApiStatus.js +2 -0
- package/docs/instance-methods.md +99 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,8 +146,8 @@ console.log('Content retrieved:', contentItem.fields.title);
|
|
|
146
146
|
- [getPage](./docs/page-methods.md#getpage), [getPageByPath](./docs/page-methods.md#getpagebypath), [getPageHistory](./docs/page-methods.md#getpagehistory), [getPageComments](./docs/page-methods.md#getpagecomments), [getPageList](./docs/page-methods.md#getpagelist), [getPageListByPageTemplateID](./docs/page-methods.md#getpagelistbypagetemplateid), [getPageListByPage](./docs/page-methods.md#getpagelistbypage), [getPageListByPageAndPageTemplateID](./docs/page-methods.md#getpagelistbypageandpagetemplateid), [getPageTree](./docs/page-methods.md#getpagetree), [getPageTemplateList](./docs/page-methods.md#getpagetemplatelist), [getPageSecurity](./docs/page-methods.md#getpagesecurity), [getPageItemTemplateList](./docs/page-methods.md#getpageitemtemplatelist), [getPageContentZones](./docs/page-methods.md#getpagecontentzones), [savePage](./docs/page-methods.md#savepage), [savePageSecurity](./docs/page-methods.md#savepagesecurity), [movePageItem](./docs/page-methods.md#movepageitem), [deletePage](./docs/page-methods.md#deletepage), [batchWorkflowPages](./docs/page-methods.md#batchworkflowpages)
|
|
147
147
|
|
|
148
148
|
### User Management
|
|
149
|
-
- **[InstanceMethods](./docs/instance-methods.md)** - Instance-level operations (
|
|
150
|
-
- [getLocales](./docs/instance-methods.md#getlocales)
|
|
149
|
+
- **[InstanceMethods](./docs/instance-methods.md)** - Instance-level operations (2 functions)
|
|
150
|
+
- [getLocales](./docs/instance-methods.md#getlocales), [getFetchApiStatus](./docs/instance-methods.md#getfetchapistatus)
|
|
151
151
|
|
|
152
152
|
- **[InstanceUserMethods](./docs/instance-user-methods.md)** - Instance user management (3 functions)
|
|
153
153
|
- [getUsers](./docs/instance-user-methods.md#getusers), [saveUser](./docs/instance-user-methods.md#saveuser), [deleteUser](./docs/instance-user-methods.md#deleteuser)
|
|
@@ -304,6 +304,31 @@ const [batchId] = await client.contentMethods.batchWorkflowContent(
|
|
|
304
304
|
console.log('Batch submitted, ID:', batchId);
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
+
### Checking Fetch API Sync Status
|
|
308
|
+
|
|
309
|
+
After batch operations, you may want to verify that changes have propagated to the Fetch API CDN before using the content on your frontend:
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import * as mgmtApi from '@agility/management-sdk';
|
|
313
|
+
|
|
314
|
+
const options = new mgmtApi.Options();
|
|
315
|
+
options.token = 'your-access-token';
|
|
316
|
+
const client = new mgmtApi.ApiClient(options);
|
|
317
|
+
|
|
318
|
+
const guid = 'your-instance-guid';
|
|
319
|
+
|
|
320
|
+
// After a batch publish operation, wait for CDN sync
|
|
321
|
+
await client.batchMethods.publishBatch(batchId, guid);
|
|
322
|
+
|
|
323
|
+
// Wait for sync to complete
|
|
324
|
+
await client.instanceMethods.getFetchApiStatus(guid, 'fetch', true);
|
|
325
|
+
console.log('Sync complete! Content is now available on the CDN');
|
|
326
|
+
|
|
327
|
+
// Or just check current status without waiting
|
|
328
|
+
const status = await client.instanceMethods.getFetchApiStatus(guid);
|
|
329
|
+
console.log('Sync in progress:', status.inProgress);
|
|
330
|
+
```
|
|
331
|
+
|
|
307
332
|
## TypeScript Interfaces
|
|
308
333
|
|
|
309
334
|
### Batch Response Interfaces
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { Options } from "../models/options";
|
|
2
2
|
import { ClientInstance } from "./clientInstance";
|
|
3
3
|
import { Locales } from "../models/locales";
|
|
4
|
+
import { FetchApiStatus, FetchApiSyncMode } from "../models/fetchApiStatus";
|
|
4
5
|
export declare class InstanceMethods {
|
|
5
6
|
_options: Options;
|
|
6
7
|
_clientInstance: ClientInstance;
|
|
7
8
|
constructor(options: Options);
|
|
8
9
|
getLocales(guid: string): Promise<Locales[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the Fetch API sync status for an instance.
|
|
12
|
+
* Use this to check if changes made via the Management API have propagated to the Fetch API CDNs.
|
|
13
|
+
* This is particularly useful after large batch operations or batch workflows to verify
|
|
14
|
+
* that content changes are available on the CDN before proceeding with dependent operations.
|
|
15
|
+
*
|
|
16
|
+
* @param guid - The website GUID
|
|
17
|
+
* @param mode - Sync mode: 'fetch' (live/published content) or 'preview' (preview content). Defaults to 'fetch'.
|
|
18
|
+
* @param waitForCompletion - If true, polls until sync is complete. Defaults to false.
|
|
19
|
+
* @returns The sync status including whether a sync is in progress and version information
|
|
20
|
+
*/
|
|
21
|
+
getFetchApiStatus(guid: string, mode?: FetchApiSyncMode, waitForCompletion?: boolean): Promise<FetchApiStatus>;
|
|
9
22
|
}
|
|
@@ -64,6 +64,54 @@ var InstanceMethods = /** @class */ (function () {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Gets the Fetch API sync status for an instance.
|
|
69
|
+
* Use this to check if changes made via the Management API have propagated to the Fetch API CDNs.
|
|
70
|
+
* This is particularly useful after large batch operations or batch workflows to verify
|
|
71
|
+
* that content changes are available on the CDN before proceeding with dependent operations.
|
|
72
|
+
*
|
|
73
|
+
* @param guid - The website GUID
|
|
74
|
+
* @param mode - Sync mode: 'fetch' (live/published content) or 'preview' (preview content). Defaults to 'fetch'.
|
|
75
|
+
* @param waitForCompletion - If true, polls until sync is complete. Defaults to false.
|
|
76
|
+
* @returns The sync status including whether a sync is in progress and version information
|
|
77
|
+
*/
|
|
78
|
+
InstanceMethods.prototype.getFetchApiStatus = function (guid_1) {
|
|
79
|
+
return __awaiter(this, arguments, void 0, function (guid, mode, waitForCompletion) {
|
|
80
|
+
var apiPath, resp, resp, status_1, err_2;
|
|
81
|
+
if (mode === void 0) { mode = 'fetch'; }
|
|
82
|
+
if (waitForCompletion === void 0) { waitForCompletion = false; }
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
_a.trys.push([0, 6, , 7]);
|
|
87
|
+
apiPath = "fetch-api-status?mode=".concat(mode);
|
|
88
|
+
if (!!waitForCompletion) return [3 /*break*/, 2];
|
|
89
|
+
return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
|
|
90
|
+
case 1:
|
|
91
|
+
resp = _a.sent();
|
|
92
|
+
return [2 /*return*/, resp.data];
|
|
93
|
+
case 2:
|
|
94
|
+
if (!true) return [3 /*break*/, 5];
|
|
95
|
+
return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
|
|
96
|
+
case 3:
|
|
97
|
+
resp = _a.sent();
|
|
98
|
+
status_1 = resp.data;
|
|
99
|
+
if (!status_1.inProgress) {
|
|
100
|
+
return [2 /*return*/, status_1];
|
|
101
|
+
}
|
|
102
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
|
103
|
+
case 4:
|
|
104
|
+
_a.sent();
|
|
105
|
+
return [3 /*break*/, 2];
|
|
106
|
+
case 5: return [3 /*break*/, 7];
|
|
107
|
+
case 6:
|
|
108
|
+
err_2 = _a.sent();
|
|
109
|
+
throw new exception_1.Exception("Unable to retrieve Fetch API status.", err_2);
|
|
110
|
+
case 7: return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
67
115
|
return InstanceMethods;
|
|
68
116
|
}());
|
|
69
117
|
exports.InstanceMethods = InstanceMethods;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./models/contentItem";
|
|
|
8
8
|
export * from "./models/contentViewColumn";
|
|
9
9
|
export * from "./models/instanceRole";
|
|
10
10
|
export * from "./models/locales";
|
|
11
|
+
export * from "./models/fetchApiStatus";
|
|
11
12
|
export * from "./models/instanceUser";
|
|
12
13
|
export * from "./models/media";
|
|
13
14
|
export * from "./models/model";
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./models/contentItem"), exports);
|
|
|
24
24
|
__exportStar(require("./models/contentViewColumn"), exports);
|
|
25
25
|
__exportStar(require("./models/instanceRole"), exports);
|
|
26
26
|
__exportStar(require("./models/locales"), exports);
|
|
27
|
+
__exportStar(require("./models/fetchApiStatus"), exports);
|
|
27
28
|
__exportStar(require("./models/instanceUser"), exports);
|
|
28
29
|
__exportStar(require("./models/media"), exports);
|
|
29
30
|
__exportStar(require("./models/model"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the sync status of the Fetch API CDN for an instance.
|
|
3
|
+
* Used to check if changes made via the Management API have propagated to the Fetch API CDNs.
|
|
4
|
+
*/
|
|
5
|
+
export interface FetchApiStatus {
|
|
6
|
+
/** Record timestamp */
|
|
7
|
+
timestamp?: string;
|
|
8
|
+
/** When the sync completed */
|
|
9
|
+
completionTime?: string;
|
|
10
|
+
/** Error message if sync failed */
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
/** Indicates if a content sync is currently in progress */
|
|
13
|
+
inProgress: boolean;
|
|
14
|
+
/** Number of items affected by the sync */
|
|
15
|
+
itemsAffected: number;
|
|
16
|
+
/** Last content version ID synced */
|
|
17
|
+
lastContentVersionID: number;
|
|
18
|
+
/** Last deleted content version ID synced */
|
|
19
|
+
lastDeletedContentVersionID: number;
|
|
20
|
+
/** Last deleted page version ID synced */
|
|
21
|
+
lastDeletedPageVersionID: number;
|
|
22
|
+
/** Lease ID for the sync operation */
|
|
23
|
+
leaseID?: string;
|
|
24
|
+
/** Maximum change date processed */
|
|
25
|
+
maxChangeDate?: string;
|
|
26
|
+
/** Maximum content model date processed */
|
|
27
|
+
maxContentModelDate?: string;
|
|
28
|
+
/** Push type (1 = Preview, 2 = Fetch/Live) */
|
|
29
|
+
pushType: number;
|
|
30
|
+
/** When the sync started */
|
|
31
|
+
startTime?: string;
|
|
32
|
+
/** The website name */
|
|
33
|
+
websiteName?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sync mode for checking Fetch API status
|
|
37
|
+
*/
|
|
38
|
+
export type FetchApiSyncMode = 'fetch' | 'preview';
|
package/docs/instance-methods.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# InstanceMethods API Documentation
|
|
2
2
|
|
|
3
|
-
The `InstanceMethods` class provides instance-level operations for retrieving configuration and
|
|
3
|
+
The `InstanceMethods` class provides instance-level operations for retrieving configuration, settings, and sync status.
|
|
4
4
|
|
|
5
5
|
## Function List
|
|
6
6
|
|
|
7
7
|
| Function | Description |
|
|
8
8
|
|----------|-------------|
|
|
9
9
|
| [getLocales](#getlocales) | Retrieves all available locales for the instance |
|
|
10
|
+
| [getFetchApiStatus](#getfetchapistatus) | Gets the Fetch API CDN sync status for the instance |
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -51,41 +52,120 @@ interface Locales {
|
|
|
51
52
|
name: string; // Display name (e.g., 'English (United States)')
|
|
52
53
|
isDefault: boolean; // Whether this is the default locale
|
|
53
54
|
isEnabled: boolean; // Whether this locale is enabled
|
|
54
|
-
// Additional locale properties may be available
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
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
|
|
59
77
|
|
|
60
78
|
```typescript
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
69
94
|
}
|
|
95
|
+
```
|
|
70
96
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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);
|
|
75
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');
|
|
76
156
|
```
|
|
77
157
|
|
|
78
158
|
---
|
|
79
159
|
|
|
80
160
|
## Error Handling
|
|
81
161
|
|
|
82
|
-
|
|
162
|
+
All methods throw `Exception` objects on failure:
|
|
83
163
|
|
|
84
164
|
```typescript
|
|
85
165
|
try {
|
|
86
|
-
const
|
|
166
|
+
const status = await client.instanceMethods.getFetchApiStatus('your-guid');
|
|
87
167
|
} catch (error) {
|
|
88
|
-
console.error('Failed to
|
|
168
|
+
console.error('Failed to get Fetch API status:', error.message);
|
|
89
169
|
}
|
|
90
170
|
```
|
|
91
171
|
|
|
@@ -102,4 +182,4 @@ try {
|
|
|
102
182
|
- [ModelMethods](./model-methods.md)
|
|
103
183
|
- [PageMethods](./page-methods.md)
|
|
104
184
|
- [ServerUserMethods](./server-user-methods.md)
|
|
105
|
-
- [WebhookMethods](./webhook-methods.md)
|
|
185
|
+
- [WebhookMethods](./webhook-methods.md)
|