Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: docs for content client #391

Merged
merged 34 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
317ca32
feat: add rum api calls to shared
alinarublea Dec 13, 2023
2ce1404
feat: merge main changes
alinarublea Jan 22, 2024
5c2390e
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jan 24, 2024
641f735
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jan 24, 2024
c9fc3d1
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jan 29, 2024
f007a5f
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jan 29, 2024
f09c2f6
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jan 30, 2024
966d79d
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 6, 2024
6136548
chore: merge main
alinarublea Feb 12, 2024
d7918e3
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 13, 2024
78baaae
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 26, 2024
cac54f9
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 26, 2024
3a34590
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 27, 2024
6073613
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 27, 2024
ad0bb8b
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Feb 28, 2024
81204ae
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Mar 1, 2024
2594513
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Mar 1, 2024
f81d056
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Mar 19, 2024
5354fc8
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Apr 23, 2024
aaae74c
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea May 30, 2024
305a0a0
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jun 21, 2024
4eb43c3
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jul 9, 2024
835366c
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jul 15, 2024
f68704f
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jul 22, 2024
8371649
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Jul 22, 2024
a1dac87
fix: naming
alinarublea Jul 24, 2024
39f0a8d
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Aug 28, 2024
8dc69f6
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Sep 12, 2024
d6b853f
Merge branch 'main' of github.com:adobe/spacecat-shared
alinarublea Oct 1, 2024
dcf4eb4
fix: add docs to client
alinarublea Oct 2, 2024
5b68970
fix: add docs to client
alinarublea Oct 2, 2024
70d7071
fix: add docs to client
alinarublea Oct 2, 2024
ac566e8
Merge branch 'main' into docs
alinarublea Oct 2, 2024
db25441
fix: add docs to client
alinarublea Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/spacecat-shared-content-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,30 @@ To remove `node_modules` and `package-lock.json`:
```bash
npm run clean
```
## Usage

### Google Drive

```js
import { ContentClient } from '../src/index.js';

const context = {}; // Your AWS Lambda context object
const gdriveclient = await ContentClient.createFrom(context, { url: 'GOOGLE_DRIVE_URL', type: 'drive.google' });
const results = await client.getPageMetadata('/path1');
console.log(results);
```

### Microsoft Sharepoint Drive

```js
import { ContentClient } from '../src/index.js';

const context = {}; // Your AWS Lambda context object
const onedriveclient = await ContentClient.createFrom(context, { url: 'ONEDRIVE_URL', type: 'onedrive' });

const results = await client.getPageMetadata('/path1');
console.log(results);
```
## Additional Information

- **Repository**: [GitHub](https://github.com/adobe/spacecat-shared.git)
Expand Down
37 changes: 31 additions & 6 deletions packages/spacecat-shared-content-client/src/clients/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ export class ContentClient {
* Example: "/path/to/page" (from the full URL: "https://www.example.com/path/to/page").
*
* @param {string} path The path to the page.
* @returns {Map<string, string>} The page's metadata.
* @returns {Promise<Map<string, { value: string, type: string }>>} A promise that
* resolves to the page's metadata.
* @throws {Error} If the path is not a string, empty or does not start with a "/"
*/
getPageMetadata(path: string): Map<string, string>;
getPageMetadata(path: string): Promise<Map<string, { value: string, type: string }>>;

/**
* Updates the metadata for the given page path. The document backing the path
Expand All @@ -53,17 +54,41 @@ export class ContentClient {
* overwrites the existing metadata.
*
* @param {string} path The path to the page.
* @param {Map<string, string>} metadata The metadata to update.
* @param {Map<string, { value: string, type: string }>} metadata The metadata to update.
* @param {Object} [options] The options to use for updating the metadata.
* @param {Object} [options.overwrite] Whether to overwrite the existing metadata.
* @returns {Map<string, string>} The page's merged metadata.
* @returns {Promise<Map<string, { value: string, type: string }>>} A promise that resolves to
* the page's merged metadata.
* @throws {Error} If the metadata is not a Map or empty
* @throws {Error} If any of the metadata keys or values are not a string
* @throws {Error} If the path is not a string, empty or does not start with a "/"
*/
updatePageMetadata(
path: string,
metadata: Map<string, string>,
metadata: Map<string, { value: string, type: string }>,
options: object,
): Map<string, string>;
): Promise<Map<string, { value: string, type: string }>>;

/**
* Retrieves the current redirects for the site from the redirects.xlsx file.
*
* @returns {Promise<Array<{ from: string, to: string }>>} A promise that resolves to
* an array of redirect objects.
* @throws {Error} If there is an issue retrieving the redirects.
*/
getRedirects(): Promise<Array<{ from: string, to: string }>>

/**
* Updates the redirects for the site with the valid array of redirects.
* The redirects are validated before updating the redirects.
* The duplicate redirects are removed.
* The redundant redirects are removed.
* The valid redirects are appended at the end of the redirects.xlsx file.
*
* @param {Array<{ from: string, to: string }>} redirects The array of redirect objects to update.
* @returns {Promise<void>} A promise that resolves when the redirects have been updated.
* @throws {Error} If the redirects array is not valid or if there
* is an issue updating the redirects.
*/
updateRedirects(redirects: Array<{ from: string, to: string }>): Promise<void>
}
Loading