Socket
Socket
Sign inDemoInstall

storyblok-management-api-wrapper

Package Overview
Dependencies
148
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    storyblok-management-api-wrapper

library for working with Storyblok management API


Version published
Weekly downloads
46
decreased by-51.58%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Storyblok Management API Wrapper

library for working with Storyblok management API. Uses axios to make Storyblok management API calls. Based on the official storyblok/storyblok-js-client

Install

npm install --save storyblok-management-api-wrapper

Usage

// 1. require the StoryblokApiClient
const StoryblokApiClient = require("storyblok-management-api-wrapper")

// 2. initialize the client with spaceId and apiKey
const spaceId = 123456
const apiKey = asdfklasjdfaksjfdaksjdfasjk
const apiClient = new StoryblokApiClient({ spaceId, apiKey })

Classes

StoryblokApiClient

instance of Storyblok API interface

StoryblokApiClient

instance of Storyblok API interface

Kind: global class

new StoryblokApiClient(config)

initialize an instance

ParamTypeDescription
configObjectsetup parameters
config.spaceIdnumber | stringworking spaceId
config.apiKeystringmanagement API oauth token
config.regionstringregion, default: undefined (optional)
config.timeoutnumbertimeout, default: 0 (optional)
config.httpsbooleanrequest protocol, default: undefined (optional)
config.rateLimitnumberrequest rate limit, default: 3 (optional)

Example

// 1. require the StoryblokApiClient
const StoryblokApiClient = require("storyblok-management-api-wrapper")

// 2. initialize the client with spaceId and apiKey
const spaceId = 123456
const apiKey = asdfklasjdfaksjfdaksjdfasjk
const apiClient = new StoryblokApiClient({ spaceId, apiKey })

storyblokApiClient.countAssets() ⇒ number

get total number of existing assets

Kind: instance method of StoryblokApiClient Returns: number - get a count of existing assets

storyblokApiClient.countStories() ⇒ number

get total number of existing stories

Storyblok API's space info does not account 'folders' as stories, so "this.getSpace({ spaceId }).then(space => space.stories_count)" does not work for the purpose of this function must be manually retrieved

Kind: instance method of StoryblokApiClient Returns: number - get a count of existing stories

storyblokApiClient.createAssetFolder(name) ⇒ Object

create an asset folder

Kind: instance method of StoryblokApiClient Returns: Object - asset folder information

ParamTypeDescription
namestringname of folder to create

storyblokApiClient.createComponent(definition) ⇒ Object

create a component

Kind: instance method of StoryblokApiClient Returns: Object - details of component that was created

ParamTypeDescription
definitionObjectStoryblok component definition object

storyblokApiClient.createStory(storyData) ⇒ Object

create a content story

Kind: instance method of StoryblokApiClient Returns: Object - details of story that was created

ParamTypeDescription
storyDataObjectStoryblok story data object

storyblokApiClient.createImageAsset(filePath, compression, dimLimit) ⇒ string

create an asset from image compression and resize using the sharp.js library

Kind: instance method of StoryblokApiClient Returns: string - public url to access the asset

ParamTypeDefaultDescription
filePathstringabsolute file path to image
compressionbooleanfalseflag to compress image
dimLimitnumberresize dimension limit value

storyblokApiClient.deleteAsset(assetId) ⇒ number

delete a specific asset

Kind: instance method of StoryblokApiClient Returns: number - assetId is returned on success

ParamTypeDescription
assetIdnumberid of the asset to be deleted

storyblokApiClient.deleteAssetFolder(assetFolderId) ⇒ number

delete a specific asset folder

Kind: instance method of StoryblokApiClient Returns: number - assetFolderId is returned on success

ParamTypeDescription
assetFolderIdnumberid of asset folder to be deleted

storyblokApiClient.deleteComponent(componentId) ⇒ number

delete a specific component

Kind: instance method of StoryblokApiClient Returns: number - componentId is returned on success

ParamTypeDescription
componentIdnumberid of component to be deleted

storyblokApiClient.deleteExistingAssets() ⇒ Array.<number>

delete all existing assets

Kind: instance method of StoryblokApiClient Returns: Array.<number> - array of asset id's that were removed

storyblokApiClient.deleteExistingComponents() ⇒ Array.<number>

delete all existing components

Kind: instance method of StoryblokApiClient Returns: Array.<number> - array of component id's that were removed

storyblokApiClient.deleteExistingStories()

delete all existing stories

Kind: instance method of StoryblokApiClient

storyblokApiClient.deleteStory(storyId) ⇒ number

delete a specific story

Kind: instance method of StoryblokApiClient Returns: number - id of story that was removed

ParamTypeDescription
storyIdnumberid of the story to be deleted

storyblokApiClient.getComponent(componentId) ⇒ Object

get a specific component

Kind: instance method of StoryblokApiClient Returns: Object - component definition

ParamTypeDescription
componentIdnumberid of component

storyblokApiClient.getExistingAssets() ⇒ Array.<Object>

list all existing assets

Kind: instance method of StoryblokApiClient Returns: Array.<Object> - full list of existing assets

storyblokApiClient.getExistingAssetFolders() ⇒ Array.<Object>

list all existing asset folders

Kind: instance method of StoryblokApiClient Returns: Array.<Object> - List of asset folder details

storyblokApiClient.getExistingComponents() ⇒ Array.<Object>

list all existing components (it is assumed that the working space has at most 1000 existing components)

Kind: instance method of StoryblokApiClient Returns: Array.<Object> - List of component definitions

storyblokApiClient.getExistingStories() ⇒ Array.<Object>

list all existing stories

Kind: instance method of StoryblokApiClient Returns: Array.<Object> - full list of existing content stories

storyblokApiClient.getSpace() ⇒ Object

get information on the working space

Kind: instance method of StoryblokApiClient Returns: Object - space information

storyblokApiClient.getStory(storyId) ⇒ Object

get a specific story

Kind: instance method of StoryblokApiClient Returns: Object - details of content story

ParamTypeDescription
storyIdnumberid of the content story

storyblokApiClient.publishExistingStories() ⇒ Array.<number>

publish existing stories

Kind: instance method of StoryblokApiClient Returns: Array.<number> - list of published story id's

storyblokApiClient.publishStory(storyId) ⇒ number

publish a specific story

Kind: instance method of StoryblokApiClient Returns: number - published story id

ParamTypeDescription
storyIdnumberstory id

storyblokApiClient.reorderStory(storyId, afterId) ⇒ Object

modify a story's sequential order

Kind: instance method of StoryblokApiClient Returns: Object - details of the moved story

ParamTypeDescription
storyIdstringid of the story to be moved
afterIdstringto be positioned after story of this id

storyblokApiClient.signAsset(filename) ⇒ Object

register a file as a Storyblok asset the physical file still has to be uploaded

Kind: instance method of StoryblokApiClient Returns: Object - asset signing info

ParamTypeDescription
filenamestringfile name to be register

storyblokApiClient.uploadAsset(buffer, signedRequest) ⇒ string

physically upload an asset after it is registered with 'signAsset()' method

Kind: instance method of StoryblokApiClient Returns: string - Url to access the asset

ParamTypeDescription
bufferBufferbuffered asset
signedRequestObjectthe server response from 'signAsset()' method

apiErrorHandler(error, fnName)

API error handler

Kind: global function

ParamTypeDescription
errorObjecterror object provided by the request
fnNamestringfunction name where the error occured

bufferImage(filePath, compression, dimLimit) ⇒ Promise.<Buffer>

Using 'sharp' library to generate data buffer image compression is applied accordingly

Kind: global function Returns: Promise.<Buffer> - buffered image data

ParamTypeDefaultDescription
filePathstringabsolute path to image file
compressionbooleanfalseflag to compress image
dimLimitnumberresizing dimension limit value

compressImage(image, compression) ⇒ Object

takes a sharp.js image object and compress as specified

Kind: global function Returns: Object - processed sharp.js image object

ParamTypeDescription
imageObjectsharp.js image object
compressionbooleanflag to compress image

resizeImage(image, dimLimit) ⇒ Object

takes a sharp.js image object and resize as specified

Kind: global function Returns: Object - processed sharp.js image object

ParamTypeDescription
imageObjectsharp.js image object
dimLimitnumbervalue to limit image dimension

Keywords

FAQs

Last updated on 06 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc