1.2.3 • Published 8 months ago

@adobe/spacecat-helix-content-sdk v1.2.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Spacecat Helix Content SDK

This library offers a minimal SDK around content bus modifications for Helix. It currently supports 2 backends:

  • Microsoft Sharepoint, via an application service principal
  • Google Drive, via a service account

:warning: Still early stage, so use at your own risk knowing we have:

  • No input validation
  • No error handling
  • No tests

Install

Just run:

npm install @adobe/spacecat-helix-content-sdk

Giving access to the client

Google Drive

  1. Go to your Google Cloud console
  2. Select the project to create the API access in
  3. Enable the Google Drive API, Google Docs API & Google Sheets API
  4. Create a new service account
  5. Create a new key for the service account
  6. Share the Google Drive folder for the project with the service account email

Microsoft Sharepoint

  1. Create a new App Registration in your azure portal
  2. Create a client credential (certificate or secret) for it
  3. Set the API permissions to Files.SelectedOperations.Selected and Sites.Selected
  4. Give the app access to the desired Sharepoint site collection: https://devblogs.microsoft.com/microsoft365dev/controlling-app-access-on-specific-sharepoint-site-collections/

Usage

Google Drive

import { createFrom } from '../src/index.js';

const gdriveclient = await createFrom({
    client_email: '',
    private_key: '',
    private_key_id: '',
    project_id: '',
    client_id: '',
    type: '',
    auth_uri: '',
    token_uri: '',
    auth_provider_x509_cert_url: '',
    client_x509_cert_url: '',
    universe_domain: '',
}, { url: 'GOOGLE_DRIVE_URL', type: 'drive.google' });
document = await gdriveclient.read('/index');
metadata = document.getMetadata();
metadata.set('testkey', { value: 'testvalue', type: 'text' });
const results = await document.updateMetadata(metadata);
console.log(results);

Microsoft Sharepoint Drive

import { createFrom } from '../src/index.js';


const onedriveclient = await createFrom({
    clientId: '',
    clientSecret: '',
    authority: '',
    domainId: '',
}, { url: 'ONEDRIVE_URL', type: 'onedrive' });

let document = await onedriveclient.read('./index.docx');
let metadata = document.getMetadata();
console.log(metadata);
metadata.set('testkey', { value: 'testvalue', type: 'text' });
document.updateMetadata(metadata);
await onedriveclient.save(document);

Client API

See: client.interface.js