Skip to content

Commit 1289dff

Browse files
committed
Merge remote-tracking branch 'origin/dev' into master, v0.4.7
2 parents b23948d + 164a0e1 commit 1289dff

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

COMPARISON.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Here I'd like to give an overview of what the validators are capable of and what
1414

1515
| | Python Validator | PySTAC | STAC Node Validator |
1616
| :------------------------- | ------------------------------------------ | ------------------- | ------------------- |
17-
| Validator Version | 1.0.1 | 0.5.2 | 0.4.6 |
17+
| Validator Version | 1.0.1 | 0.5.2 | 0.4.7 |
1818
| Language | Python 3.6 | Python 3 | NodeJS |
1919
| CLI | Yes | No | Yes |
2020
| Programmatic | Yes | Yes | Planned |
@@ -24,24 +24,23 @@ Here I'd like to give an overview of what the validators are capable of and what
2424

2525
## Specifications supported
2626

27-
| | Python Validator | PySTAC | STAC Node Validator |
28-
| --------------------------------------------------- | ------------------- | ------------------- | ------------------------------------------- |
29-
| STAC Versions supported | >= 0.4.0 | >= 0.4.0 | >= 1.0.0-beta.1 |
30-
| Protocols supported | HTTP(S), Filesystem | HTTP(S), Filesystem | HTTP(S), Filesystem |
31-
| Validates Items / Catalogs / Collections | Yes | Yes | Yes |
32-
| Validates Core Extensions | Yes | Yes | Yes |
33-
| Validates External / Custom Extensions | Yes | No | Yes |
34-
| Validates STAC API responses | No | No | Partially (only items/collections in lists) |
35-
| Validates STAC API extensions | No | No | No |
36-
| Validates additional properties in STAC Item Assets | No | No | No |
27+
| | Python Validator | PySTAC | STAC Node Validator |
28+
| ---------------------------------------- | ------------------- | ------------------- | ------------------------------------------- |
29+
| STAC Versions supported | >= 0.7.0 | >= 0.4.0 | >= 1.0.0-beta.1 |
30+
| Protocols supported | HTTP(S), Filesystem | HTTP(S), Filesystem | HTTP(S), Filesystem |
31+
| Validates Items / Catalogs / Collections | Yes | Yes | Yes |
32+
| Validates Core Extensions | Yes | Yes | Yes |
33+
| Validates External / Custom Extensions | No | No | Yes |
34+
| Validates STAC API responses | No | No | Partially (only items/collections in lists) |
35+
| Validates STAC API extensions | No | No | No |
3736

3837
## Other Features
3938

4039
| | Python Validator | PySTAC | STAC Node Validator |
4140
| :----------------------------- | ---------------------- | ------------------------------------------------- | ------------------- |
4241
| Can follow links | Yes | Yes | No |
43-
| Parallelisation | Yes | No | No |
42+
| Parallelization | Yes | No | No |
4443
| Validate against local schemas | Yes | Planned | Yes |
4544
| Lint JSON files | No | No | Yes |
4645
| Format/Pretty-print JSON files | No | Yes | Yes |
47-
| Other comments | Uses pystac validation | General Python library to work with STAC catalogs | - |
46+
| Other comments | Uses PySTAC validation | General Python library to work with STAC catalogs | - |

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
const $RefParser = require("@apidevtools/json-schema-ref-parser");
22
const Ajv = require('ajv');
3+
const formats = require('ajv-formats-draft2019/formats');
4+
const iriFormats = require('./iri.js');
35
const fs = require('fs-extra');
46
const klaw = require('klaw');
57
const path = require('path')
68
const minimist = require('minimist');
79
const compareVersions = require('compare-versions');
810
const {diffStringsUnified} = require('jest-diff');
11+
const package = require('./package.json');
912

1013
let DEBUG = false;
1114
let COMPILED = {};
1215
let SHORTCUTS = [
13-
'card4l-sar-nrb',
14-
'checksum',
16+
'card4l-eo',
17+
'card4l-sar',
18+
'checksum', // legacy
1519
'collection-assets',
1620
'datacube',
1721
'eo',
22+
'file',
1823
'item-assets',
1924
'label',
2025
'pointcloud',
@@ -30,13 +35,15 @@ let SHORTCUTS = [
3035
'view'
3136
];
3237
let ajv = new Ajv({
38+
formats: Object.assign(formats, iriFormats),
3339
allErrors: true,
3440
missingRefs: "ignore",
3541
addUsedSchema: false,
3642
logger: DEBUG ? console : false
3743
});
3844

3945
async function run() {
46+
console.log(`STAC Node Validator v${package.version}\n`);
4047
try {
4148
let args = minimist(process.argv.slice(2));
4249

iri.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { parse } = require('uri-js');
2+
3+
// We don't allow empty URIs, same-document and mailto here
4+
module.exports = {
5+
'iri': value => {
6+
if (typeof value !== 'string' || value.length === 0) {
7+
return;
8+
}
9+
10+
const iri = parse(value);
11+
if ((iri.reference === 'absolute' || iri.reference === 'uri') && iri.scheme && iri.host) {
12+
return true;
13+
}
14+
15+
return false;
16+
},
17+
'iri-reference': value => {
18+
if (typeof value !== 'string' || value.length === 0) {
19+
return;
20+
}
21+
22+
const iri = parse(value);
23+
if ((iri.reference === 'absolute' || iri.reference === 'uri') && iri.scheme && iri.host) {
24+
return true;
25+
}
26+
27+
return (iri.path && (iri.reference === 'relative' || iri.reference === 'uri'));
28+
}
29+
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stac-node-validator",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"description": "STAC Validator for NodeJS",
55
"author": "Matthias Mohr",
66
"license": "Apache-2.0",
@@ -22,11 +22,13 @@
2222
},
2323
"files": [
2424
"bin/cli.js",
25+
"iri.js",
2526
"index.js"
2627
],
2728
"dependencies": {
2829
"@apidevtools/json-schema-ref-parser": "^9.0.1",
2930
"ajv": "^6.12.2",
31+
"ajv-formats-draft2019": "^1.4.3",
3032
"compare-versions": "^3.6.0",
3133
"fs-extra": "^9.0.0",
3234
"jest-diff": "^26.6.2",

0 commit comments

Comments
 (0)