@agility/management-sdk 0.1.39 → 0.2.0-beta.2
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 +5 -1
- package/dist/apiClient.d.ts +2 -0
- package/dist/apiClient.js +2 -0
- package/dist/apiMethods/searchMethods.d.ts +16 -0
- package/dist/apiMethods/searchMethods.js +81 -0
- package/dist/apiMethods/webhookMethods.d.ts +11 -2
- package/dist/apiMethods/webhookMethods.js +58 -7
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/models/contentItem.d.ts +26 -0
- package/dist/models/contentItem.js +7 -1
- package/dist/models/geo.d.ts +38 -0
- package/dist/models/geo.js +31 -0
- package/dist/models/pageItem.d.ts +11 -0
- package/dist/models/pagedResult.d.ts +4 -0
- package/dist/models/search.d.ts +114 -0
- package/dist/models/search.js +45 -0
- package/dist/models/searchNotAvailableException.d.ts +12 -0
- package/dist/models/searchNotAvailableException.js +41 -0
- package/dist/models/webhook.d.ts +17 -0
- package/dist/models/webhookHistory.d.ts +32 -0
- package/dist/models/webhookHistory.js +9 -0
- package/docs/content-methods.md +10 -0
- package/docs/page-methods.md +32 -0
- package/docs/search-methods.md +129 -0
- package/docs/webhook-methods.md +253 -354
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exception } from "./exception";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by `searchMethods.search` when the API answers 501: search is not available for this
|
|
4
|
+
* instance yet. It isn't a transient failure, so don't retry it; fall back to listing or filtering
|
|
5
|
+
* content instead.
|
|
6
|
+
*
|
|
7
|
+
* Check with `err instanceof SearchNotAvailableException`, or `err.name === "SearchNotAvailableException"`
|
|
8
|
+
* when more than one copy of the SDK may be loaded. `statusCode` is 501.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SearchNotAvailableException extends Exception {
|
|
11
|
+
constructor(message: string, inner?: Error);
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SearchNotAvailableException = void 0;
|
|
19
|
+
var exception_1 = require("./exception");
|
|
20
|
+
/**
|
|
21
|
+
* Thrown by `searchMethods.search` when the API answers 501: search is not available for this
|
|
22
|
+
* instance yet. It isn't a transient failure, so don't retry it; fall back to listing or filtering
|
|
23
|
+
* content instead.
|
|
24
|
+
*
|
|
25
|
+
* Check with `err instanceof SearchNotAvailableException`, or `err.name === "SearchNotAvailableException"`
|
|
26
|
+
* when more than one copy of the SDK may be loaded. `statusCode` is 501.
|
|
27
|
+
*/
|
|
28
|
+
var SearchNotAvailableException = /** @class */ (function (_super) {
|
|
29
|
+
__extends(SearchNotAvailableException, _super);
|
|
30
|
+
function SearchNotAvailableException(message, inner) {
|
|
31
|
+
var _this = _super.call(this, message, inner) || this;
|
|
32
|
+
// The SDK compiles to ES5, where a subclass of Error loses its prototype; restore it so
|
|
33
|
+
// `instanceof SearchNotAvailableException` works.
|
|
34
|
+
Object.setPrototypeOf(_this, SearchNotAvailableException.prototype);
|
|
35
|
+
_this.name = "SearchNotAvailableException";
|
|
36
|
+
_this.statusCode = 501;
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
return SearchNotAvailableException;
|
|
40
|
+
}(exception_1.Exception));
|
|
41
|
+
exports.SearchNotAvailableException = SearchNotAvailableException;
|
package/dist/models/webhook.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare class Webhook {
|
|
2
|
+
partitionKey: string | null;
|
|
3
|
+
rowKey: string | null;
|
|
4
|
+
timestamp?: string | null;
|
|
5
|
+
eTag?: string | null;
|
|
2
6
|
name: string | null;
|
|
3
7
|
url: string | null;
|
|
4
8
|
instanceGuid: string | null;
|
|
@@ -6,4 +10,17 @@ export declare class Webhook {
|
|
|
6
10
|
contentWorkflowEvents: boolean;
|
|
7
11
|
contentPublishEvents: boolean;
|
|
8
12
|
contentSaveEvents: boolean;
|
|
13
|
+
secureDeliveryEnabled: boolean;
|
|
14
|
+
signingSecret: string | null;
|
|
15
|
+
previousSigningSecret: string | null;
|
|
16
|
+
secretRolledUtc: string | null;
|
|
17
|
+
retriesEnabled: boolean;
|
|
18
|
+
retryCount: number;
|
|
19
|
+
retrySpeed: "fast" | "standard" | "slow" | null;
|
|
20
|
+
/**
|
|
21
|
+
* Set only on a `saveWebhook` response, and only when that save is what minted `signingSecret`
|
|
22
|
+
* (the first save with `secureDeliveryEnabled` on). Use it to surface the new secret once — it is
|
|
23
|
+
* never stored on the webhook, so a `getWebhook` response never has it.
|
|
24
|
+
*/
|
|
25
|
+
signingSecretJustCreated?: boolean;
|
|
9
26
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class WebhookHistory {
|
|
2
|
+
partitionKey: string | null;
|
|
3
|
+
rowKey: string | null;
|
|
4
|
+
queuedDate: string | null;
|
|
5
|
+
sendDate: string | null;
|
|
6
|
+
url: string | null;
|
|
7
|
+
instanceGuid: string | null;
|
|
8
|
+
contentWorkflowEvent: boolean;
|
|
9
|
+
contentPublishEvent: boolean;
|
|
10
|
+
contentSaveEvent: boolean;
|
|
11
|
+
payload: string | null;
|
|
12
|
+
httpResponseCode: number | null;
|
|
13
|
+
success: boolean;
|
|
14
|
+
responseText: string | null;
|
|
15
|
+
webhookRowKey: string | null;
|
|
16
|
+
eventKey: string | null;
|
|
17
|
+
attemptCount: number;
|
|
18
|
+
lastAttemptDate: string | null;
|
|
19
|
+
nextAttemptUtc: string | null;
|
|
20
|
+
lastError: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the last attempt was sent with Standard Webhooks signature headers, as recorded at send
|
|
23
|
+
* time. `null` means no record — the delivery has not been attempted yet, or the row predates the
|
|
24
|
+
* field. This is the fact at delivery time, not the webhook's current `secureDeliveryEnabled`.
|
|
25
|
+
*/
|
|
26
|
+
signed: boolean | null;
|
|
27
|
+
/**
|
|
28
|
+
* Signatures sent in the `webhook-signature` header on the last attempt: 0 unsigned, 1 normally,
|
|
29
|
+
* 2 during the 24-hour grace window after a secret roll.
|
|
30
|
+
*/
|
|
31
|
+
signatureKeyCount: number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookHistory = void 0;
|
|
4
|
+
var WebhookHistory = /** @class */ (function () {
|
|
5
|
+
function WebhookHistory() {
|
|
6
|
+
}
|
|
7
|
+
return WebhookHistory;
|
|
8
|
+
}());
|
|
9
|
+
exports.WebhookHistory = WebhookHistory;
|
package/docs/content-methods.md
CHANGED
|
@@ -337,6 +337,16 @@ const contentItems = [
|
|
|
337
337
|
const savedIds = await client.contentMethods.saveContentItems(contentItems, 'your-guid', 'en-us');
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
+
### GEO / AEO on dynamic page list items
|
|
341
|
+
|
|
342
|
+
An item in a list that backs a dynamic page can carry a top-level `geo` object (`schemaType`, `summary`, `structuredData`, `ai`), the same shape as a page's `geo` (see [savePage](./page-methods.md#savepage)). `saveContentItem` and `saveContentItems` send it as given, with the same three states: leave `geo` (or a property in it) out to keep what's stored, set a property to `null` to clear it, send `geo: null` to clear the whole block. Items in other lists don't carry `geo`, and `getContentItem` leaves it out when the item has none.
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
const item = await client.contentMethods.getContentItem(123, 'your-guid', 'en-us');
|
|
346
|
+
item.geo = { ...item.geo, summary: 'The post in one sentence.', ai: { crawl: 'block' } };
|
|
347
|
+
await client.contentMethods.saveContentItem(item, 'your-guid', 'en-us');
|
|
348
|
+
```
|
|
349
|
+
|
|
340
350
|
---
|
|
341
351
|
|
|
342
352
|
## getContentItems
|
package/docs/page-methods.md
CHANGED
|
@@ -525,6 +525,38 @@ console.log('Batch created with ID:', batchId);
|
|
|
525
525
|
**Error Handling:**
|
|
526
526
|
- Throws `Exception` when validation fails or save operation fails
|
|
527
527
|
|
|
528
|
+
**GEO / AEO and the extra SEO properties:**
|
|
529
|
+
|
|
530
|
+
A page can carry a top-level `geo` object (`schemaType`, `summary`, `structuredData`, `ai`) and four more `seo` properties (`title`, `canonicalUrl`, `robots`, `ogImage`). On save, each of these properties has three states:
|
|
531
|
+
|
|
532
|
+
| In the object you save | Effect |
|
|
533
|
+
|---|---|
|
|
534
|
+
| Property left out (`undefined`), or the whole `geo` left out | The stored value is kept |
|
|
535
|
+
| `geo: null` | The whole `geo` block is cleared |
|
|
536
|
+
| Property set to `null` | The stored value is cleared |
|
|
537
|
+
| Property set to a value | The stored value is replaced |
|
|
538
|
+
|
|
539
|
+
`savePage` sends the object as JSON, and `JSON.stringify` drops `undefined`, so a read-modify-save that doesn't touch these properties keeps them. Don't set them to `null` unless you mean to clear them. Responses leave out any property that isn't set.
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
const page = await apiClient.pageMethods.getPage(123, guid, locale);
|
|
543
|
+
page.geo = {
|
|
544
|
+
...page.geo,
|
|
545
|
+
schemaType: 'AboutPage',
|
|
546
|
+
summary: 'Who we are, in two sentences.',
|
|
547
|
+
structuredData: { '@context': 'https://schema.org', '@type': 'Organization', name: 'Example' },
|
|
548
|
+
ai: { llmsInclude: 'include' }
|
|
549
|
+
};
|
|
550
|
+
page.seo = { ...page.seo, title: 'About us | Example', robots: { index: true, follow: true } };
|
|
551
|
+
await apiClient.pageMethods.savePage(page, guid, locale);
|
|
552
|
+
|
|
553
|
+
// Clear the summary only; everything else in geo is kept
|
|
554
|
+
await apiClient.pageMethods.savePage({ ...page, geo: { summary: null } }, guid, locale);
|
|
555
|
+
|
|
556
|
+
// Clear all of geo
|
|
557
|
+
await apiClient.pageMethods.savePage({ ...page, geo: null }, guid, locale);
|
|
558
|
+
```
|
|
559
|
+
|
|
528
560
|
### savePageSecurity
|
|
529
561
|
|
|
530
562
|
Updates security settings for a specific page.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Agility CMS & Management API TypeScript SDK
|
|
2
|
+
|
|
3
|
+
## SearchMethods
|
|
4
|
+
|
|
5
|
+
This class searches everything in an instance in one call: content items, components, pages, assets, models and containers. Results are ranked across kinds, best match first, and come with a count per kind so they can drive tabs.
|
|
6
|
+
|
|
7
|
+
**Important Notes:**
|
|
8
|
+
- Words match as prefixes (`newsl` finds `newsletter`) and every word must match; text in double quotes matches as an exact phrase. A number also matches content, page, asset and model IDs exactly
|
|
9
|
+
- If nothing matches every word, the results match **any** of the words instead and `relaxed` is `true`
|
|
10
|
+
- You only see what your permissions allow: content, pages and containers for everyone; components and models need Develop or Manage; assets need Edit or Delete; content and pages in containers or pages you can't read are left out. The API applies this, so there's nothing to filter on the client
|
|
11
|
+
- Changes are searchable a few seconds after they are saved
|
|
12
|
+
- Search is not yet available on every instance. When it isn't, `search` throws a [`SearchNotAvailableException`](#searchnotavailableexception)
|
|
13
|
+
|
|
14
|
+
### Function List
|
|
15
|
+
- [search](#search) - Searches an instance
|
|
16
|
+
|
|
17
|
+
### Reference
|
|
18
|
+
- [The SearchRequest object](#the-searchrequest-object)
|
|
19
|
+
- [The SearchResult object](#the-searchresult-object)
|
|
20
|
+
- [SearchNotAvailableException](#searchnotavailableexception)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### search
|
|
25
|
+
|
|
26
|
+
Searches an instance. Makes one request and never retries.
|
|
27
|
+
|
|
28
|
+
| Parameter | Type | Required | Description |
|
|
29
|
+
|-----------|------|----------|-------------|
|
|
30
|
+
| `guid` | `string` | Yes | Current website GUID |
|
|
31
|
+
| `request` | `SearchRequest` | Yes | What to search for, and optional filters and paging. Only `query` is required |
|
|
32
|
+
|
|
33
|
+
**Returns:** `Promise<SearchResult>`
|
|
34
|
+
|
|
35
|
+
**Usage Example:**
|
|
36
|
+
```typescript
|
|
37
|
+
import * as mgmtApi from '@agility/management-sdk';
|
|
38
|
+
|
|
39
|
+
const result = await apiClient.searchMethods.search(guid, { query: 'newsletter' });
|
|
40
|
+
|
|
41
|
+
console.log(`${result.total} results${result.relaxed ? ' (matching any word)' : ''}`);
|
|
42
|
+
for (const [kind, facet] of Object.entries(result.facets ?? {})) {
|
|
43
|
+
console.log(`${kind}: ${facet.count}${facet.capped ? '+' : ''}`);
|
|
44
|
+
}
|
|
45
|
+
result.hits?.forEach(hit => {
|
|
46
|
+
console.log(`[${hit.typeLabel}] ${hit.name} in ${hit.context} -> ${hit.viewLink}`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Only published content and pages in en-us, second page of 10
|
|
50
|
+
const page2 = await apiClient.searchMethods.search(guid, {
|
|
51
|
+
query: '"spring sale"',
|
|
52
|
+
kinds: ['content', 'page'],
|
|
53
|
+
locale: 'en-us',
|
|
54
|
+
state: 'published',
|
|
55
|
+
skip: 10,
|
|
56
|
+
take: 10
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Error Handling:**
|
|
61
|
+
- Throws `SearchNotAvailableException` (`statusCode` 501) when search is not available for the instance yet
|
|
62
|
+
- Throws `Exception` with `statusCode` 400 for a blank query, an unknown kind or an unknown state
|
|
63
|
+
- Throws `Exception` when the search fails for any other reason
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### The SearchRequest object
|
|
68
|
+
|
|
69
|
+
| Property | Type | Description |
|
|
70
|
+
|----------|------|-------------|
|
|
71
|
+
| `query` | `string` | **Required.** The text to search for |
|
|
72
|
+
| `kinds` | `SearchKind[]` | Any of `content`, `component`, `page`, `asset`, `model`, `container`. Defaults to every kind you can see. The facet counts always cover every kind you can see, whatever this is |
|
|
73
|
+
| `locale` | `string` | Only search content, components and pages in this locale (for example `en-us`). Omit it, or pass `*`, for every locale |
|
|
74
|
+
| `containers` | `string[]` | Only return content in these containers, by reference name. Limits the search to content kinds |
|
|
75
|
+
| `models` | `string[]` | Only return content and components of these models, by reference name. Limits the search to content kinds |
|
|
76
|
+
| `state` | `SearchState` | `staging`, `published`, `unpublished` or `any`. Limits the search to content kinds |
|
|
77
|
+
| `modifiedAfter` | `string \| Date` | Only return results modified on or after this date |
|
|
78
|
+
| `skip` | `number` | Results to skip, for paging (default: 0) |
|
|
79
|
+
| `take` | `number` | Results to return (default: 25, at most 100) |
|
|
80
|
+
|
|
81
|
+
### The SearchResult object
|
|
82
|
+
|
|
83
|
+
| Property | Type | Description |
|
|
84
|
+
|----------|------|-------------|
|
|
85
|
+
| `query` | `string` | The query as it was searched |
|
|
86
|
+
| `relaxed` | `boolean` | `true` when nothing matched every word, so the results match any of the words |
|
|
87
|
+
| `facets` | `{ [kind: string]: SearchFacet }` | `{ count, capped }` for each kind you can see, whichever kinds you asked for. When `capped` is `true` there are more than `count`: show it as "N+" |
|
|
88
|
+
| `total` | `number` | How many results there are across the requested kinds |
|
|
89
|
+
| `hits` | `SearchHit[]` | The requested page of results, best match first |
|
|
90
|
+
| `indexing` | `SearchIndexing` | `{ pending, catchingUp }`: `pending` is the number of changes not yet searchable (usually 0, high after a big import); `catchingUp` is `true` while the instance is being indexed in the background, so search again shortly |
|
|
91
|
+
|
|
92
|
+
Each `SearchHit` has a `kind`, `typeLabel`, `name`, `context` (its container, page path, folder or model reference name), `snippet` (HTML-encoded, with matched words wrapped in `<mark>`), `matchedFields`, `score`, and a `viewLink` to open it in the Content Manager, relative to the instance. The IDs and details that apply to its kind are set too: `contentID`, `containerID`, `containerReferenceName`, `pageID`, `pagePath`, `channel`, `languageCode`, `state`, `modifiedDate`, `modifiedBy`, `mediaID`, `url`, `contentType`, `size`, `modelID` and `modelReferenceName`. The rest are `null` or left out.
|
|
93
|
+
|
|
94
|
+
### SearchNotAvailableException
|
|
95
|
+
|
|
96
|
+
Thrown when the API answers 501: search is not available for this instance yet. It isn't a transient failure, so don't retry it.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { SearchNotAvailableException } from '@agility/management-sdk';
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const result = await apiClient.searchMethods.search(guid, { query: 'newsletter' });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if (err instanceof SearchNotAvailableException) {
|
|
105
|
+
// Fall back to listing or filtering content instead.
|
|
106
|
+
} else {
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
When more than one copy of the SDK may be loaded, check `err.name === 'SearchNotAvailableException'` instead. `err.statusCode` is `501`.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Navigation
|
|
117
|
+
- [← Back to Main Documentation](../README.md)
|
|
118
|
+
- [Authentication & Setup](./auth.md)
|
|
119
|
+
- [AssetMethods](./asset-methods.md)
|
|
120
|
+
- [BatchMethods](./batch-methods.md)
|
|
121
|
+
- [ContainerMethods](./container-methods.md)
|
|
122
|
+
- [ContentMethods](./content-methods.md)
|
|
123
|
+
- [InstanceMethods](./instance-methods.md)
|
|
124
|
+
- [InstanceUserMethods](./instance-user-methods.md)
|
|
125
|
+
- [ModelMethods](./model-methods.md)
|
|
126
|
+
- [PageMethods](./page-methods.md)
|
|
127
|
+
- **SearchMethods** *(current)*
|
|
128
|
+
- [ServerUserMethods](./server-user-methods.md)
|
|
129
|
+
- [WebhookMethods](./webhook-methods.md)
|