0.3.1 • Published 5 years ago

stac-validator v0.3.1

Weekly downloads
1
License
Apache License 2....
Repository
github
Last release
5 years ago

NodeJS Stac Validator

Validates a spatial temporal catalog asset based on the specs laid out by Radiant Earth.

Usage

validateStac

Validate from URL validates STAC from a remote source.

ParameterTypeDescriptionRequired
urlstringthe source of the STAC to be validatedyes
typestringThe type of stac being validated. Can be "item", "stac-item", "catalog", "collection" or "geojson"yes
versionstringThe version. Defaults to 'v0.6.0'Optional
useRecursionbooleanset to true if you want to traverse deeper than the initial fileno
contextobjectNot implemented. Intended for streaming resultsNo

validateFromObject

Validates a STAC asset from user-provided parsed object. Will not check any deeper.

ParameterTypeDescriptionRequired
assetstringthe stringified JSON assetyes
typestringThe type of stac being validated. Can be "item", "stac-item", "catalog", "collection" or "geojson"yes
versionstringThe version. Defaults to 'v0.6.0'Optional
contextobjectNot implemented. Intended for streaming resultsNo

Intended Usage

Modules

This will be subject to change until this is released on NPM

    const { validateStac, validateFromObject } = require('@sparkgeo/stac-validator')


    const type = 'catalog' // or 'item' or 'collection'
    const url = 'https//...'

    const responseFromUrl = validateStac({url, type})

    (...)

    const catalog = { ... } // stac catalog
    const collection = { ... } // stac collection
    const item = { ... } // stac item

    const responseFromJsonItem = validateFromObject({asset: item, type: 'item'})
    const responseFromJsonCollection = validateFromObject({asset: collection, type: 'collection'})
    const responseFromJsonCatalog = validateFromObject({asset: catalog, type: 'catalog'})

Example Responses

Success

A successful response returns an object with a success boolean, as well as a verified_files, which provides a series of responses.

  {
    success: true,
    responses: [
      {
        valid: true,
        location: '<location of file>',
        errors: []
      }, (...)
    ]
  }

Failure

A failure response shares the success and verified_files attributes. In addition, it adds a new attribute called errors. The errors object is flat, meaning that there should be no nester arrays of objects present.

The errors object is subject to change until the first stable release, v0.7.0.

  {
    success: false,
    responses: [
      {
        valid: false,
        location: '<location of file>',
        errors: [
          {
            keyword: '',
            message: '',
          }
        ]
      }, (...)
    ]
  }

TODO's

the following is the progress of this progress. Because, at this point, it is a one-man show, I'm documenting everything here.

  • Initial Building
  • Mock integration tests from requirements
  • Set up and document entry point
  • Use Recursion to obtain an entire STAC stack from a single entry point
  • Enforce rigidity of the context object.
  • Example of push-polling
  • Remove webpack for production build
  • Add CI/CD Support as part of release to master.

The Context Object

The context object allows for real-time operations such as streaming. This is in-progress.

Key nameIntended usetype
errorLista list of errorsobject
indicateErrora function for updating that accepts an error objectfunction
indicateCompletea function that indicates the linting is completefunction

Sample Catalog

https://cbers-stac.s3.amazonaws.com/CBERS4/catalog.json

Internal Testing

To test this library internally, open the node REPL from the base directory of this repository

 $ node

From within, you will be able to access the library with the following commands:

     const { validateStac, validateFromObject } = require('./src/index.js')
     let url = 'https://cbers-stac.s3.amazonaws.com/CBERS4/catalog.json'
     let type = 'catalog'
     let version = '0.5.2'
     let useRecursion = true


     validateStac({url, type, version, useRecursion})
       .then(result => {
         console.log('Response -> ', response)
         })
       .catch(e => {
         console.log('Error -> ', e)
       })

     // Check the response after
0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago