@adobe/spacecat-shared-content-client 1.1.7 → 1.1.9
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/CHANGELOG.md +14 -0
- package/README.md +23 -0
- package/package.json +3 -3
- package/src/clients/index.d.ts +31 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-content-client-v1.1.9](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.1.8...@adobe/spacecat-shared-content-client-v1.1.9) (2024-10-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/spacecat-helix-content-sdk to v1.2.0 ([#398](https://github.com/adobe/spacecat-shared/issues/398)) ([6798ff6](https://github.com/adobe/spacecat-shared/commit/6798ff6a3ea41116fe549e2f30a85f2e8cfb0b23))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-content-client-v1.1.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.1.7...@adobe/spacecat-shared-content-client-v1.1.8) (2024-10-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* docs for content client ([0978c2d](https://github.com/adobe/spacecat-shared/commit/0978c2d84636f03b7ebdf22e9888740d9518b989))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-content-client-v1.1.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.1.6...@adobe/spacecat-shared-content-client-v1.1.7) (2024-10-02)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -20,7 +20,30 @@ To remove `node_modules` and `package-lock.json`:
|
|
|
20
20
|
```bash
|
|
21
21
|
npm run clean
|
|
22
22
|
```
|
|
23
|
+
## Usage
|
|
23
24
|
|
|
25
|
+
### Google Drive
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { ContentClient } from '../src/index.js';
|
|
29
|
+
|
|
30
|
+
const context = {}; // Your AWS Lambda context object
|
|
31
|
+
const gdriveclient = await ContentClient.createFrom(context, { url: 'GOOGLE_DRIVE_URL', type: 'drive.google' });
|
|
32
|
+
const results = await client.getPageMetadata('/path1');
|
|
33
|
+
console.log(results);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Microsoft Sharepoint Drive
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { ContentClient } from '../src/index.js';
|
|
40
|
+
|
|
41
|
+
const context = {}; // Your AWS Lambda context object
|
|
42
|
+
const onedriveclient = await ContentClient.createFrom(context, { url: 'ONEDRIVE_URL', type: 'onedrive' });
|
|
43
|
+
|
|
44
|
+
const results = await client.getPageMetadata('/path1');
|
|
45
|
+
console.log(results);
|
|
46
|
+
```
|
|
24
47
|
## Additional Information
|
|
25
48
|
|
|
26
49
|
- **Repository**: [GitHub](https://github.com/adobe/spacecat-shared.git)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-content-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Content Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/helix-universal": "5.0.6",
|
|
38
|
-
"@adobe/spacecat-helix-content-sdk": "1.
|
|
38
|
+
"@adobe/spacecat-helix-content-sdk": "1.2.0",
|
|
39
39
|
"@adobe/spacecat-shared-utils": "1.19.6",
|
|
40
40
|
"graph-data-structure": "4.0.0"
|
|
41
41
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"chai-as-promised": "8.0.0",
|
|
46
46
|
"esmock": "2.6.7",
|
|
47
47
|
"nock": "13.5.4",
|
|
48
|
-
"sinon": "
|
|
48
|
+
"sinon": "19.0.2",
|
|
49
49
|
"sinon-chai": "4.0.0",
|
|
50
50
|
"typescript": "5.6.2"
|
|
51
51
|
}
|
package/src/clients/index.d.ts
CHANGED
|
@@ -36,10 +36,11 @@ export class ContentClient {
|
|
|
36
36
|
* Example: "/path/to/page" (from the full URL: "https://www.example.com/path/to/page").
|
|
37
37
|
*
|
|
38
38
|
* @param {string} path The path to the page.
|
|
39
|
-
* @returns {Map<string, string
|
|
39
|
+
* @returns {Promise<Map<string, { value: string, type: string }>>} A promise that
|
|
40
|
+
* resolves to the page's metadata.
|
|
40
41
|
* @throws {Error} If the path is not a string, empty or does not start with a "/"
|
|
41
42
|
*/
|
|
42
|
-
getPageMetadata(path: string): Map<string, string
|
|
43
|
+
getPageMetadata(path: string): Promise<Map<string, { value: string, type: string }>>;
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* Updates the metadata for the given page path. The document backing the path
|
|
@@ -53,17 +54,41 @@ export class ContentClient {
|
|
|
53
54
|
* overwrites the existing metadata.
|
|
54
55
|
*
|
|
55
56
|
* @param {string} path The path to the page.
|
|
56
|
-
* @param {Map<string, string>} metadata The metadata to update.
|
|
57
|
+
* @param {Map<string, { value: string, type: string }>} metadata The metadata to update.
|
|
57
58
|
* @param {Object} [options] The options to use for updating the metadata.
|
|
58
59
|
* @param {Object} [options.overwrite] Whether to overwrite the existing metadata.
|
|
59
|
-
* @returns {Map<string, string
|
|
60
|
+
* @returns {Promise<Map<string, { value: string, type: string }>>} A promise that resolves to
|
|
61
|
+
* the page's merged metadata.
|
|
60
62
|
* @throws {Error} If the metadata is not a Map or empty
|
|
61
63
|
* @throws {Error} If any of the metadata keys or values are not a string
|
|
62
64
|
* @throws {Error} If the path is not a string, empty or does not start with a "/"
|
|
63
65
|
*/
|
|
64
66
|
updatePageMetadata(
|
|
65
67
|
path: string,
|
|
66
|
-
metadata: Map<string, string>,
|
|
68
|
+
metadata: Map<string, { value: string, type: string }>,
|
|
67
69
|
options: object,
|
|
68
|
-
): Map<string, string
|
|
70
|
+
): Promise<Map<string, { value: string, type: string }>>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the current redirects for the site from the redirects.xlsx file.
|
|
74
|
+
*
|
|
75
|
+
* @returns {Promise<Array<{ from: string, to: string }>>} A promise that resolves to
|
|
76
|
+
* an array of redirect objects.
|
|
77
|
+
* @throws {Error} If there is an issue retrieving the redirects.
|
|
78
|
+
*/
|
|
79
|
+
getRedirects(): Promise<Array<{ from: string, to: string }>>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Updates the redirects for the site with the valid array of redirects.
|
|
83
|
+
* The redirects are validated before updating the redirects.
|
|
84
|
+
* The duplicate redirects are removed.
|
|
85
|
+
* The redundant redirects are removed.
|
|
86
|
+
* The valid redirects are appended at the end of the redirects.xlsx file.
|
|
87
|
+
*
|
|
88
|
+
* @param {Array<{ from: string, to: string }>} redirects The array of redirect objects to update.
|
|
89
|
+
* @returns {Promise<void>} A promise that resolves when the redirects have been updated.
|
|
90
|
+
* @throws {Error} If the redirects array is not valid or if there
|
|
91
|
+
* is an issue updating the redirects.
|
|
92
|
+
*/
|
|
93
|
+
updateRedirects(redirects: Array<{ from: string, to: string }>): Promise<void>
|
|
69
94
|
}
|