Skip to content

Commit 8eb3ae7

Browse files
committed
Implement processing parameters extension (#74)
1 parent 4a180b6 commit 8eb3ae7

File tree

7 files changed

+134
-2
lines changed

7 files changed

+134
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `Capabilities`: Added `hasConformance` function and `Conformance` URI object
13+
- `Connection`: Added `listProcessingParameters` function
14+
1015
## [2.8.0] - 2025-04-25
1116

1217
### Added

openeo.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,15 @@ declare namespace OpenEO {
437437
* @returns {boolean} `true` if the feature is supported, otherwise `false`.
438438
*/
439439
hasFeature(methodName: string): boolean;
440+
/**
441+
* Check whether a conformance class is supported by the back-end.
442+
*
443+
* Use `*` as a wildcard character for e.g. version numbers.
444+
*
445+
* @param {string|Array.<string>} uris - Conformance class URI(s) - any of them must match.
446+
* @returns {boolean} `true` if any of the conformance classes is supported, otherwise `false`.
447+
*/
448+
hasConformance(uris: string | Array<string>): boolean;
440449
/**
441450
* Get the billing currency.
442451
*
@@ -457,6 +466,8 @@ declare namespace OpenEO {
457466
* @returns {AxiosResponse}
458467
*/
459468
protected migrate(response: AxiosResponse): AxiosResponse;
469+
470+
static Conformance: Record<string, string | Array<string>>;
460471
}
461472
/**
462473
* The Authentication Provider for OpenID Connect.
@@ -2167,6 +2178,14 @@ declare namespace OpenEO {
21672178
* @throws {Error}
21682179
*/
21692180
listFileTypes(): Promise<FileTypes>;
2181+
/**
2182+
* List the supported output file formats.
2183+
*
2184+
* @async
2185+
* @returns {Promise<ProcessingParameters>} A response compatible to the API specification.
2186+
* @throws {Error}
2187+
*/
2188+
listProcessingParameters(): Promise<ProcessingParameters>;
21702189
/**
21712190
* List the supported secondary service types.
21722191
*
@@ -3078,6 +3097,27 @@ declare namespace OpenEO {
30783097
* An openEO processing chain.
30793098
*/
30803099
export type Process = Record<string, any>;
3100+
/**
3101+
* A specific processing parameter.
3102+
*/
3103+
type ProcessingParameter = object<string, any>;
3104+
/**
3105+
* All types of processing parameters.
3106+
*/
3107+
type ProcessingParameters = {
3108+
/**
3109+
* Processing parameters for batch jobs.
3110+
*/
3111+
create_job_parameters: Array<ProcessingParameter>;
3112+
/**
3113+
* Processing parameters for secondary web services.
3114+
*/
3115+
create_service_parameters: Array<ProcessingParameter>;
3116+
/**
3117+
* Processing parameters for synchronous processing.
3118+
*/
3119+
create_synchronous_parameters: Array<ProcessingParameter>;
3120+
};
30813121
/**
30823122
* A back-end in the federation.
30833123
*/

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"@openeo/js-commons": "^1.5.0",
5656
"@radiantearth/stac-migrate": "^1.0.0",
5757
"axios": "^1.0.0",
58-
"oidc-client": "^1.11.5"
58+
"oidc-client": "^1.11.5",
59+
"regexp.escape": "^2.0.1"
5960
},
6061
"scripts": {
6162
"docs": "jsdoc -r -d docs/ -P package.json -R README.md -c .jsdoc",

src/capabilities.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const Utils = require('@openeo/js-commons/src/utils');
2+
if (typeof RegExp.escape !== 'function') {
3+
require('regexp.escape').shim();
4+
}
25

36
const FEATURE_MAP = {
47
// Discovery
58
capabilities: true,
69
listFileTypes: 'get /file_formats',
710
listServiceTypes: 'get /service_types',
811
listUdfRuntimes: 'get /udf_runtimes',
12+
listProcessingParameters: 'get /processing_parameters',
913
// Collections
1014
listCollections: 'get /collections',
1115
describeCollection: 'get /collections/{}',
@@ -58,6 +62,22 @@ const FEATURE_MAP = {
5862
debugService: 'get /services/{}/logs',
5963
};
6064

65+
const CONFORMANCE_CLASSES = {
66+
openeo: "https://api.openeo.org/extensions/openeo/v1.*",
67+
// STAC API
68+
stacCollections: [
69+
'https://api.stacspec.org/v1.*/collections',
70+
'https://api.stacspec.org/v1.*/ogcapi-features'
71+
],
72+
stacItems: 'https://api.stacspec.org/v1.*/ogcapi-features',
73+
// openEO API Extensions
74+
commercialData: 'https://api.openeo.org/extensions/commercial-data/0.1.*',
75+
federation: 'https://api.openeo.org/extensions/federation/0.1.*',
76+
processingParameters: "https://api.openeo.org/extensions/processing-parameters/0.1.*",
77+
remoteProcessDefinition: 'https://api.openeo.org/extensions/remote-process-definition/0.1.*',
78+
workspaces: 'https://api.openeo.org/extensions/workspaces/0.1.*'
79+
};
80+
6181
/**
6282
* Capabilities of a back-end.
6383
*/
@@ -261,6 +281,29 @@ class Capabilities {
261281
return feature === true || this.features.some(e => e === feature);
262282
}
263283

284+
/**
285+
* Check whether a conformance class is supported by the back-end.
286+
*
287+
* Use `*` as a wildcard character for e.g. version numbers.
288+
*
289+
* @param {string|Array.<string>} uris - Conformance class URI(s) - any of them must match.
290+
* @returns {boolean} `true` if any of the conformance classes is supported, otherwise `false`.
291+
*/
292+
hasConformance(uris) {
293+
if (typeof uris === 'string') {
294+
uris = [uris];
295+
}
296+
if(!Array.isArray(this.data.conformsTo) || !Array.isArray(uris)) {
297+
return false;
298+
}
299+
300+
const classRegexp = uris
301+
.map(uri => RegExp.escape(uri).replaceAll('\\*', '[^/]+'))
302+
.join('|');
303+
const regexp = new RegExp('^(' + classRegexp + ')$');
304+
return Boolean(this.data.conformsTo.find(uri => uri.match(regexp)));
305+
}
306+
264307
/**
265308
* Get the billing currency.
266309
*
@@ -302,4 +345,6 @@ class Capabilities {
302345
}
303346
}
304347

348+
Capabilities.Conformance = CONFORMANCE_CLASSES;
349+
305350
module.exports = Capabilities;

src/connection.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ class Connection {
194194
return new FileTypes(response.data);
195195
}
196196

197+
/**
198+
* List the supported output file formats.
199+
*
200+
* @async
201+
* @returns {Promise<ProcessingParameters>} A response compatible to the API specification.
202+
* @throws {Error}
203+
*/
204+
async listProcessingParameters() {
205+
const response = await this._get('/processing_parameters');
206+
return response.data;
207+
}
208+
197209
/**
198210
* List the supported secondary service types.
199211
*

src/typedefs.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@
195195
* @type {object.<string, *>}
196196
*/
197197

198+
/**
199+
* A specific processing parameter.
200+
*
201+
* @typedef ProcessingParameter
202+
* @type {object.<string, *>}
203+
*/
204+
205+
/**
206+
* All types of processing parameters.
207+
*
208+
* @typedef ProcessingParameters
209+
* @type {object}
210+
* @property {Array.<ProcessingParameter>} create_job_parameters Processing parameters for batch jobs.
211+
* @property {Array.<ProcessingParameter>} create_service_parameters Processing parameters for secondary web services.
212+
* @property {Array.<ProcessingParameter>} create_synchronous_parameters Processing parameters for synchronous processing.
213+
*/
214+
198215
/**
199216
* A back-end in the federation.
200217
*

tests/vito.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { Utils } = require('@openeo/js-commons');
55
jest.setTimeout(30*1000);
66

77
describe('VITO back-end', () => {
8-
const TESTBACKEND = 'https://openeo.vito.be';
8+
const TESTBACKEND = 'https://openeo-dev.vito.be';
99

1010
let con;
1111
test('Connect', async () => {
@@ -37,6 +37,18 @@ describe('VITO back-end', () => {
3737
});
3838
});
3939

40+
describe('Processing Parameters', () => {
41+
test('conformance class', async () => {
42+
let cap = await con.capabilities();
43+
expect(cap.hasConformance(Capabilities.Conformance.processingParameters)).toBeTruthy();
44+
});
45+
test('listProcessingParameters', async () => {
46+
let params = await con.listProcessingParameters();
47+
expect(Array.isArray(params.create_job_parameters)).toBeTruthy();
48+
expect(Array.isArray(params.create_synchronous_parameters)).toBeTruthy();
49+
});
50+
});
51+
4052
describe('Request processes from namespace', () => {
4153

4254
// Not implemented yet by VITO

0 commit comments

Comments
 (0)