pensieve-sdk

1.0.0 • Public • Published

Pensieve SDK

npm npm license npm downloads travis

The official Pensieve Node.js/Browser SDK

Installation

Install pensieve-sdk by running:

npm install --save pensieve-sdk

Documentation

pensieve.Pensieve

Kind: static class of pensieve
Summary: Create a Pensieve instance
Access: public

new exports.Pensieve(repository, document, contentPath, [backend])

Param Type Default Description
repository Object repository
repository.reference String git reference
[repository.owner] String GitHub repository owner
[repository.name] String GitHub repository name
[repository.credentials] Object GitHub repository credentials
[repository.credentials.username] String GitHub username
[repository.credentials.password] String GitHub password
[repository.credentials.token] String GitHub token
[repository.path] String git repository path
document String document name
contentPath String document content path
[backend] String 'github' Pensieve backend (for advanced usage)

Example

const pensieve = new Pensieve({
  reference: 'master',
  owner: 'resin-io',
  name: 'pensieve',
  credentials: {
    token: '.........'
  }
}, 'mydocument', 'Document')

Example

const pensieve = new Pensieve({
  reference: 'master',
  owner: 'resin-io',
  name: 'pensieve',
  credentials: {
    username: 'myuser',
    password: 'secret'
  }
}, 'mydocument', 'Document')

pensieve.ready() ⇒ Promise

Kind: instance method of Pensieve
Summary: Ensure the instance is ready to be used
Access: public
Fulfil: Object - user profile
Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.ready().then((profile) => {
  console.log(profile)
  console.log('The instance is ready to be used')
})

pensieve.getFragments() ⇒ Promise

Kind: instance method of Pensieve
Summary: Get all fragments from the document
Access: public
Fulfil: Object[] - document fragments
Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.getFragments().each((fragment) => {
  console.log(fragment)
})

pensieve.updateFragment(fragment) ⇒ Promise

Kind: instance method of Pensieve
Summary: Update a document fragment
Access: public

Param Type Description
fragment Object fragment

Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.updateFragment({
  foo: 'bar',
  bar: 'baz',
  PS_UUID: '...'
}).then(() => {
  console.log('Done!')
})

pensieve.deleteFragment(uuid) ⇒ Promise

Kind: instance method of Pensieve
Summary: Delete a document fragment
Access: public

Param Type Description
uuid String fragment uuid

Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.deleteFragment('...').then(() => {
  console.log('Done!')
})

pensieve.getViews() ⇒ Promise

Kind: instance method of Pensieve
Summary: Get all views
Access: public
Fulfil: Object[] - views
Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.getViews().each((view) => {
  console.log(view)
})

pensieve.updateView(view) ⇒ Promise

Kind: instance method of Pensieve
Summary: Update a view
Access: public

Param Type Description
view Object view

Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.updateView({
  key: 'bar',
  scopeLabel: 'everyone',
  title: 'Bar',
  data: [ ... ]
}).then(() => {
  console.log('Done!')
})

pensieve.deleteView(key) ⇒ Promise

Kind: instance method of Pensieve
Summary: Delete a view
Access: public

Param Type Description
key String view key

Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.deleteView('MyView').then(() => {
  console.log('Done!')
})

pensieve.getSchema() ⇒ Promise

Kind: instance method of Pensieve
Summary: Get the schema
Access: public
Fulfil: Object - schema
Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.getSchema().each((schema) => {
  console.log(schema)
})

pensieve.updateSchema(schema) ⇒ Promise

Kind: instance method of Pensieve
Summary: Update the schema
Access: public

Param Type Description
schema Object schema

Example

const pensieve = new Pensieve({ ... }, 'mydocument', 'Document')
pensieve.updateSchema([ { ... } ]).then(() => {
  console.log('Done!')
})

Tests

Run the test suite with the following command:

npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that the linter runs without any warning:

npm run lint

Support

If you're having any problem, please raise an issue on GitHub.

License

This project is free software, and may be redistributed under the terms specified in the license.

Readme

Keywords

none

Package Sidebar

Install

npm i pensieve-sdk

Weekly Downloads

0

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • balena.io