Open Design

Function createSdk

createSdk
createSdk(params: { apiRoot?: string; cached?: boolean; console?: ConsoleConfig | null; rendering?: boolean; svgExport?: boolean; systemFonts?: boolean; token: string; workingDirectory?: string | null }): Sdk

Creates an SDK instance

Based on the provided configuration, various services are made available:

  • When Open Design API credentials (a token) is provided, the API is configured and available for uploading and downloading designs.
  • A local rendering engine is available by default.
  • Local system fonts can be used for rendering design by default.
  • A local cache is available by default.

Example:

Full SDK

const sdk = createSdk({
  token: '<TOKEN>',
})

Full SDK with all logs for debugging purposes

const sdk = createSdk({
  token: '<TOKEN>',
  console: { level: 'debug' }
})

SDK without the local rendering engine

const sdk = createSdk({
  token: '<TOKEN>',
  rendering: false,
  systemFonts: false,
})

Parameters:

params:

SDK Parameters

OptionalapiRoot?: string

The URL base for Open Design API calls. By default, production Avocode Open Design API servers are used.

Optionalcached?: boolean

Whether to use a local (file system) cache in the form for .octopus files. This is enabled by default.

Optionalconsole?: ConsoleConfig | null

Configuration of the console/logger. This can either be a log level configuration for the bundled logger or a custom console object. The bundled logger can be replaced with the default node.js console via { console: console }.

Optionalrendering?: boolean

Whether to use a local rendering engine for rendering designs. This is enabled by default. cached must not be set to false for the rendering engine to be available.

OptionalsvgExport?: boolean

Whether to use a local SVG exporter. This is enabled by default.

OptionalsystemFonts?: boolean

Whether to use local system fonts for rendering designs via the rendering engine. This is enabled by default.

token: string

An Open Design API access token. Test tokens can be generated within the Open Design API documentation. When no token is provided, online services (the API) is not configured.

OptionalworkingDirectory?: string | null

An absolute path to the directory against which should the SDK resolve relative file paths and where should it look for its cache directory.

returns Sdk

An SDK instance.