1.0.0 • Published 6 years ago

pensieve-sdk v1.0.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
6 years ago

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)

ParamTypeDefaultDescription
repositoryObjectrepository
repository.referenceStringgit reference
repository.ownerStringGitHub repository owner
repository.nameStringGitHub repository name
repository.credentialsObjectGitHub repository credentials
repository.credentials.usernameStringGitHub username
repository.credentials.passwordStringGitHub password
repository.credentials.tokenStringGitHub token
repository.pathStringgit repository path
documentStringdocument name
contentPathStringdocument content path
backendString'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

ParamTypeDescription
fragmentObjectfragment

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

ParamTypeDescription
uuidStringfragment 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

ParamTypeDescription
viewObjectview

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

ParamTypeDescription
keyStringview 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

ParamTypeDescription
schemaObjectschema

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.