npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yachteye/uploader

v1.0.3

Published

YachtEye Collector Uploader library

Downloads

213

Readme

YachtEye Uploader

This small library implements the SYT Uploader and abstracts the details away into a single call to the back-end to upload a file.

Installation

npm install --save @yachteye/uploader

Usage

import YachtEyeUploader from '@yachteye/uploader'

// set to true to enable debug logs
const enableDebugLogs = false

const onProgress = (progress) => {
  // This is currently not yet used
  console.log('Progress: ' + progress)
}

const onUploaded = ({ id, file, result }) => {
  // the file was uploaded successfully
}

/*
 * @Param {String} Collector base URL
 * @Param {String} NodeJS API base URL
 * @Param {String} NodeJS API upload API token
 * @Param {Function} Callback that gets called when progress changes. Doesn't yet work
 * @Param {Function} Callback that gets called when the upload itself completes
 * @Param {Bool} Enable or disable debug logs
 */
const uploader = new YachtEyeUploader('https://collector-dev.superyachtapi.com', 'https://api0.superyachtapi.com', 'MY_API_KEY', onProgress, onUploaded, enableDebugLogs)

/*
 * @Param {Job} Collector job information. See interfaces below
 * @Param {File} file
 * @Param {string} owner - e.g. current yacht ID
 *
 * @Returns {JobResult}
 */
await uploader.uploadWithJob(job, file, owner)

/*
 * OTHER INSTANCE METHODS
 */

// Get the status of a previously created file job
await uploader.getFileJobStatus(jobId) // => Promise<JobResult>

// Manually create a job for an uploaded file
await uploader.createFileJob(fileId, jobName, jobEntityType, jobEntityId, jobMemoryId, photoIndex) // => Promise<JobResult>

// Manually upload a file, without creating a job
await uploader.upload(file, owner) // => Promise<FileJobResult>

// Sequentially upload files, for a single job (useful with attach-gallery-item)
await uploader.uploadMultipleWithJob(job, files, owner) // => Promise<JobResult[]>

NB The uploader will throw an error if anything fails along the way.

Interfaces

export interface Job {
  jobName: string
  jobEntityType: string
  jobEntityId: string
  jobMemoryId?: string
  photoIndex?: number
}

export interface JobFileEndpoints {
  getUploadUrl: string
  getFileUrl: string
  getFile: string
  downloadFile: string
  updateFile: string
  registerVariant: string
}

export interface JobResult extends Job {
  upstreamErrorCount: number
  status: string
  fileId: string
  mediaIds: string[]
  endpoints: JobFileEndpoints
  createdAt: string
  updatedAt: string
  date: string
  time: string
  _id: string
}