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

@map-colonies/export-interfaces

v1.5.0

Published

This package define and expose common interfaces & types for export tasks

Downloads

6

Readme

Export-Interfaces

npm - @mapcolonies/export-interfaces

This package define and expose common interfaces & types for export tasks

Quickstart


  1. install
npm install @mapcolonies/export-interfaces

Data in Export-Interfaces

export-interfaces exposes the 'Export Manager' interface with common functions to be implement

export interface IExportManager {
  createExportTask: (data: CreateExportTaskRequest<TaskParameters>) => Promise<CreateExportTaskResponse>;
  getEstimations: (catalogRecordID: string, ROI: FeatureCollection, additional?: Record<string, unknown>) => Promise<GetEstimationsResponse>;
  getFootprint: (catalogRecordID: string) => Promise<FeatureCollection>;
}

most of Export-Interfaces functions uses @turf/turf npm package for geographic data.


  1. import & implement
import { IExportManager } from '@map-colonies/export-interfaces';

export class ExportManager implements IExportManager {
    ...
}
  1. implements IExportManager functions
  • createExportTask example:
export class ExportManager implements IExportManager {
  public constructor(@inject(SERVICES.LOGGER) private readonly logger: Logger) {}

  public async createExportTask(data: CreateExportTaskRequest<TaskParameters>): Promise<CreateExportTaskResponse> {
    this.logger.info({ msg: 'log message' });
    ...
    ...
    const geometry1: Polygon = {
      coordinates: [
        [
          [38.12777806969146, 34.88509668647414],
          [37.79098758535008, 34.88509668647414],
          [37.79098758535008, 34.557014824377575],
          [38.12777806969146, 34.557014824377575],
          [38.12777806969146, 34.88509668647414],
        ],
      ],
      type: 'Polygon',
    };

    const geometry2: MultiPolygon = {
      coordinates: [
        [
          [30.10241695788926, 27.097838272461956],
          [29.991351500386685, 27.0731170944439],
          [29.991351500386685, 26.949429475478382],
          [30.08853377570128, 26.776038590550044],
          [30.310664690705238, 26.98655005029447],
          [30.10241695788926, 27.097838272461956],
        ],
      ],
      type: 'Polygon',
    };

    const taskGeometries: TaskGeometry[] = [{ geometry: geometry1, metadata: { maxRes: 0.732 } }, { geometry2 }]; // ⇨ 'metadata' is optional here
    
    const createExportTaskResponse: CreateExportTaskResponse = {
      jobId: '4b3d6bcd-bbfd-4b2d-9x5d-ab8dfbdd4be4', // uuid format
      geometries: taskGeometries,
    }
    ...

    return createExportTaskResponse; 
  }
}

  • getEstimatations ⇨ returns the estimated exported data size in bytes and estimated export task time in seconds


  • getFootprint ⇨ returns the completed record footprint by id

Event Message


Export-Interfaces exposes different event message types for each events Export-Management usage (expects to receive those message objects in order to handle them while task event has occurred)

Task Events:

  • TaskStartedMessage
  • TaskCompletedMessage
  • TaskFailedMessage
  • TaskAbortedMessage
  • TaskExpiredMessage
  • TaskPausedMessage

publisher should handle those event message types ("DataType") by publishing them into message queue on Redis server ⇨ use BullMQ npm package