Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev', v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed May 23, 2022
2 parents 80ebf6a + 3647812 commit 7bef496
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 23 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/docs.yml
Expand Up @@ -5,11 +5,10 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/setup-node@v1
with:
node-version: '16'
- uses: actions/checkout@v2
- run: npm install
- run: npm run docs
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Expand Up @@ -3,11 +3,10 @@ on: [push, pull_request]
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/setup-node@v1
with:
node-version: '16'
- uses: actions/checkout@v2
- run: npm install
- run: npm run lint
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.1] - 2022-05-23

### Fixed

- Callback parameters for type `metadata-filter` (in `additionalProperties`) get detected properly.

## [1.4.0] - 2021-08-09

### Added
Expand Down Expand Up @@ -59,7 +65,8 @@ First release supporting openEO API 1.0.0.

All prior releases have been documented in the [GitHub Releases](https://github.com/Open-EO/openeo-js-commons/releases).

[Unreleased]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.4.0...HEAD>
[Unreleased]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.4.1...HEAD>
[1.4.1]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.4.0...v1.4.1>
[1.4.0]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.3.0...v1.4.0>
[1.3.0]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.2.0...v1.3.0>
[1.2.0]: <https://github.com/Open-EO/openeo-js-commons/compare/v1.1.1...v1.2.0>
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -2,12 +2,12 @@

A set of common JavaScript functionalities for [openEO](http://openeo.org).

The [master branch](https://github.com/Open-EO/openeo-api/tree/master) is the 'stable' version of library, which is currently version **1.4.0**.
The [master branch](https://github.com/Open-EO/openeo-api/tree/master) is the 'stable' version of library, which is currently version **1.4.1**.
The [draft branch](https://github.com/Open-EO/openeo-api/tree/draft) is where active development takes place.

![Dependencies](https://img.shields.io/librariesio/release/npm/@openeo/js-commons)
![Minified Size](https://img.shields.io/bundlephobia/min/@openeo/js-commons/1.4.0)
![Minzipped Size](https://img.shields.io/bundlephobia/minzip/@openeo/js-commons/1.4.0)
![Minified Size](https://img.shields.io/bundlephobia/min/@openeo/js-commons/1.4.1)
![Minzipped Size](https://img.shields.io/bundlephobia/minzip/@openeo/js-commons/1.4.1)
![Supported API Versions](https://img.shields.io/github/package-json/apiVersions/Open-Eo/openeo-js-commons/master)
![JS Commons Tests](https://github.com/Open-EO/openeo-js-commons/workflows/JS%20Commons%20Tests/badge.svg)

Expand Down Expand Up @@ -40,4 +40,4 @@ In a web environment you can include the library as follows:
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-commons@1/dist/main.min.js"></script>
```

More information can be found in the [**JS commons documentation**](https://open-eo.github.io/openeo-js-commons/1.4.0/).
More information can be found in the [**JS commons documentation**](https://open-eo.github.io/openeo-js-commons/1.4.1/).
16 changes: 8 additions & 8 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@openeo/js-commons",
"version": "1.4.0",
"version": "1.4.1",
"apiVersions": [
"0.4.x",
"1.0.x"
Expand Down Expand Up @@ -28,22 +28,22 @@
],
"devDependencies": {
"@babel/core": "^7.10.5",
"jest": "^25.5.4",
"jest-html-reporter": "^3.1.3",
"jest": "^27.0.0",
"jest-html-reporter": "^3.5.0",
"jsdoc": "^3.6.4",
"jshint": "^2.11.1",
"unminified-webpack-plugin": "^2.0.0",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.12"
"unminified-webpack-plugin": "^3.0.0",
"webpack": "^5.0.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.0.0"
},
"dependencies": {
"compare-versions": "^3.6.0",
"fast-deep-equal": "^3.1.3"
},
"scripts": {
"docs": "jsdoc src -r -d docs/ -P package.json -R README.md",
"build": "npx webpack",
"build": "npx webpack --mode production",
"lint": "jshint src",
"test": "jest --env=jsdom",
"test_node": "jest --env=node"
Expand Down
10 changes: 9 additions & 1 deletion src/processDataType.js
Expand Up @@ -123,7 +123,15 @@ class ProcessDataType {
* @returns {array<object>}
*/
getCallbackParameters() {
return Array.isArray(this.schema.parameters) ? this.schema.parameters : [];
if (Array.isArray(this.schema.parameters)) { // For "normal" callbacks
return this.schema.parameters;
}
else if (Utils.isObject(this.schema.additionalProperties) && Array.isArray(this.schema.additionalProperties.parameters)) {
return this.schema.additionalProperties.parameters; // Used for metadata-filter
}
else {
return [];
}
}

/**
Expand Down
13 changes: 10 additions & 3 deletions src/processUtils.js
Expand Up @@ -89,11 +89,18 @@ class ProcessUtils {

let cbParams = [];
for(let schema of schemas) {
if (Array.isArray(schema.parameters)) {
if (cbParams.length > 0 && !Utils.equals(cbParams, schema.parameters)) {
let params = null;
if (Array.isArray(schema.parameters)) { // For "normal" callbacks
params = schema.parameters;
}
else if (Utils.isObject(schema.additionalProperties) && Array.isArray(schema.additionalProperties.parameters)) {
params = schema.additionalProperties.parameters; // Used for metadata-filter
}
if (Array.isArray(params)) {
if (cbParams.length > 0 && !Utils.equals(cbParams, params)) {
throw new Error("Multiple schemas with different callback parameters found.");
}
cbParams = schema.parameters;
cbParams = params;
}
}

Expand Down
43 changes: 43 additions & 0 deletions tests/processes.test.js
Expand Up @@ -200,6 +200,49 @@ describe('Process(Parameter|Schema|DataType) Tests', () => {
expect(obj.default()).toBe(_default);
});

test('ProcessDataType (metadata-filter)', () => {
let params = [
{
"name": "value",
"description": "The property value to be checked against.",
"schema": {
"description": "Any data type."
}
}
];
let schema = {
"type": "object",
"subtype": "metadata-filter",
"title": "Filters",
"description": "A list of filters to check against. Specify key-value-pairs with the key being the name of the metadata property name and the value being a process evaluated against the metadata values.",
"additionalProperties": {
"type": "object",
"subtype": "process-graph",
"parameters": params,
"returns": {
"description": "`true` if the data should be loaded into the data cube, otherwise `false`.",
"schema": {
"type": "boolean"
}
}
}
};

let obj = new ProcessDataType(schema);
expect(obj.schema).toEqual(schema);

expect(obj.toJSON()).toEqual(schema);
expect(obj.isAny()).toBe(false);
expect(obj.isNull()).toBe(false);
expect(obj.nullable()).toBe(false);
expect(obj.isEditable()).toBe(true);
expect(obj.dataType()).toBe("metadata-filter");
expect(obj.nativeDataType()).toBe("object");
expect(obj.getCallbackParameters()).toEqual(params);
expect(obj.group()).toBe("Other");
expect(obj.title()).toBe("Filters");
});

test('ProcessDataType (any)', () => {
let obj = new ProcessDataType({}, null, {});
expect(obj.toJSON()).toEqual({
Expand Down

0 comments on commit 7bef496

Please sign in to comment.