@openeo/js-client 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,7 @@
1
1
  const Utils = require('@openeo/js-commons/src/utils');
2
+ if (typeof RegExp.escape !== 'function') {
3
+ require('regexp.escape').shim();
4
+ }
2
5
 
3
6
  const FEATURE_MAP = {
4
7
  // Discovery
@@ -6,6 +9,7 @@ const FEATURE_MAP = {
6
9
  listFileTypes: 'get /file_formats',
7
10
  listServiceTypes: 'get /service_types',
8
11
  listUdfRuntimes: 'get /udf_runtimes',
12
+ listProcessingParameters: 'get /processing_parameters',
9
13
  // Collections
10
14
  listCollections: 'get /collections',
11
15
  describeCollection: 'get /collections/{}',
@@ -58,6 +62,22 @@ const FEATURE_MAP = {
58
62
  debugService: 'get /services/{}/logs',
59
63
  };
60
64
 
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
+
61
81
  /**
62
82
  * Capabilities of a back-end.
63
83
  */
@@ -261,6 +281,29 @@ class Capabilities {
261
281
  return feature === true || this.features.some(e => e === feature);
262
282
  }
263
283
 
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
+
264
307
  /**
265
308
  * Get the billing currency.
266
309
  *
@@ -302,4 +345,6 @@ class Capabilities {
302
345
  }
303
346
  }
304
347
 
348
+ Capabilities.Conformance = CONFORMANCE_CLASSES;
349
+
305
350
  module.exports = Capabilities;
package/src/connection.js CHANGED
@@ -194,6 +194,18 @@ class Connection {
194
194
  return new FileTypes(response.data);
195
195
  }
196
196
 
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
+
197
209
  /**
198
210
  * List the supported secondary service types.
199
211
  *
@@ -733,7 +745,7 @@ class Connection {
733
745
  const response = await this._post('/validation', this._normalizeUserProcess(process).process);
734
746
  if (Array.isArray(response.data.errors)) {
735
747
  const errors = response.data.errors;
736
- errors['federation:backends'] = Array.isArray(response.data['federation:missing']) ? response.data['federation:missing'] : [];
748
+ errors['federation:backends'] = Array.isArray(response.data['federation:backends']) ? response.data['federation:backends'] : [];
737
749
  return errors;
738
750
  }
739
751
  else {
@@ -948,7 +960,7 @@ class Connection {
948
960
  *
949
961
  * @async
950
962
  * @param {Array.<Service>} [oldServices=[]] - A list of existing services to update.
951
- * @returns {Promise<ResponseArray.<Job>>} A list of services.
963
+ * @returns {Promise<ResponseArray.<Service>>} A list of services.
952
964
  * @throws {Error}
953
965
  */
954
966
  async listServices(oldServices = []) {
@@ -127,6 +127,16 @@ class OidcProvider extends AuthProvider {
127
127
  */
128
128
  this.defaultClients = Array.isArray(options.default_clients) ? options.default_clients : [];
129
129
 
130
+ /**
131
+ * Additional parameters to include in authorization requests.
132
+ *
133
+ * As defined by the API, these parameters MUST be included when
134
+ * requesting the authorization endpoint.
135
+ *
136
+ * @type {object.<string, *>}
137
+ */
138
+ this.authorizationParameters = Utils.isObject(options.authorization_parameters) ? options.authorization_parameters : {};
139
+
130
140
  /**
131
141
  * The detected default Client.
132
142
  *
@@ -244,7 +254,8 @@ class OidcProvider extends AuthProvider {
244
254
  scope: scope.join(' '),
245
255
  validateSubOnSilentRenew: true,
246
256
  response_type,
247
- response_mode: response_type.includes('code') ? 'query' : 'fragment'
257
+ response_mode: response_type.includes('code') ? 'query' : 'fragment',
258
+ extraQueryParams: this.authorizationParameters
248
259
  }, options);
249
260
  }
250
261
 
package/src/openeo.js CHANGED
@@ -109,7 +109,7 @@ class OpenEO {
109
109
  * @returns {string} Version number (according to SemVer).
110
110
  */
111
111
  static clientVersion() {
112
- return "2.8.0";
112
+ return "2.10.0";
113
113
  }
114
114
 
115
115
  }
package/src/typedefs.js CHANGED
@@ -195,6 +195,23 @@
195
195
  * @type {object.<string, *>}
196
196
  */
197
197
 
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
+
198
215
  /**
199
216
  * A back-end in the federation.
200
217
  *