@shutter/api
[Shutter.sh](https://shutter.sh/) API client package.
Last updated 2 years ago by andywer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shutter/api 
SYNC missed versions from official npm registry.

@shutter/api NPM Version

Shutter.sh API client package.

API

import { createSnapshot, retrieveFile, loadFileFromDisk } from '@shutter/api'

createSnapshot(authToken: string, page: File, pageAssets: File[], options: SnapshotCreationOptions = {}): Promise<Snapshot>

Sends an HTML document and additional assets to the shutter.sh service for rendering. Returns a promise that resolves upon finished upload. The snapshot will not have been rendered yet (see retrieveProcessedSnapshot).

interface SnapshotCreationOptions {
  expectation?: File | null,
  diffOptions?: DiffOptions,
  labels?: Labels,
  renderOptions?: RenderOptions
}

interface DiffOptions {
  autoCrop?: boolean,
  relativeThreshold?: number
}

interface RenderOptions {
  autoCrop?: boolean,
  omitBackground?: boolean
}

type Snapshot = any   // Not yet typed

retrieveFile(fileHash: string): Promise<Buffer>

Takes a file hash as included in the Snapshot body and returns a promise that resolves to a Buffer containing the file contents.

retrieveProcessedSnapshot(snapshotID: string): Promise<Snapshot>

Takes a snapshot ID and returns a promise resolving to the rendered snapshot once the rendering has completed.

createFileFromBuffer(content: Buffer, fileName: string, options: FromBufferOptions = {}): File

Takes a Buffer and wraps it to become a File.

interface FromBufferOptions {
  contentType?: string
}

loadFileFromDisk(filePath: string, options: FromFSOptions = {}): Promise<File>

Loads a file from the file system.

interface FromFSOptions {
  contentType?: string,
  fileName?: string
}

File

interface File {
  readonly contentType: string | null
  readonly fileName: string
  getContent: () => Promise<Buffer>
}

Current Tags

  • 0.5.0                                ...           latest (2 years ago)

5 Versions

  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 7
Dependencies (4)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |