@openeo/js-client 2.3.1 → 2.4.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.
package/openeo.js CHANGED
@@ -1840,6 +1840,7 @@ class AuthProvider {
1840
1840
  /**
1841
1841
  * Abstract method that extending classes implement the login process with.
1842
1842
  *
1843
+ * @async
1843
1844
  * @param {...*} args
1844
1845
  * @throws {Error}
1845
1846
  */
@@ -2460,19 +2461,19 @@ class Builder {
2460
2461
  this.id = id;
2461
2462
  /**
2462
2463
  * The parent builder.
2463
- * @type {?Builder}
2464
+ * @type {Builder | null}
2464
2465
  */
2465
2466
 
2466
2467
  this.parent = parent;
2467
2468
  /**
2468
2469
  * The parent node.
2469
- * @type {?BuilderNode}
2470
+ * @type {BuilderNode | null}
2470
2471
  */
2471
2472
 
2472
2473
  this.parentNode = null;
2473
2474
  /**
2474
2475
  * The parent parameter name.
2475
- * @type {?string}
2476
+ * @type {string | null}
2476
2477
  */
2477
2478
 
2478
2479
  this.parentParameter = null;
@@ -2808,7 +2809,7 @@ class Formula {
2808
2809
 
2809
2810
  this.tree = parser.parse(formula);
2810
2811
  /**
2811
- * @type {?Builder}
2812
+ * @type {Builder | null}
2812
2813
  */
2813
2814
 
2814
2815
  this.builder = null;
@@ -4328,7 +4329,7 @@ class Connection {
4328
4329
  * Auth Provider cache
4329
4330
  *
4330
4331
  * @protected
4331
- * @type {?Array.<AuthProvider>}
4332
+ * @type {Array.<AuthProvider> | null}
4332
4333
  */
4333
4334
 
4334
4335
  this.authProviderList = null;
@@ -4336,7 +4337,7 @@ class Connection {
4336
4337
  * Current auth provider
4337
4338
  *
4338
4339
  * @protected
4339
- * @type {?AuthProvider}
4340
+ * @type {AuthProvider | null}
4340
4341
  */
4341
4342
 
4342
4343
  this.authProvider = null;
@@ -4344,7 +4345,7 @@ class Connection {
4344
4345
  * Capability cache
4345
4346
  *
4346
4347
  * @protected
4347
- * @type {?Capabilities}
4348
+ * @type {Capabilities | null}
4348
4349
  */
4349
4350
 
4350
4351
  this.capabilitiesObject = null;
@@ -4598,6 +4599,26 @@ class Connection {
4598
4599
  nextUrl = this._getLinkHref(response.data.links);
4599
4600
  }
4600
4601
  }
4602
+ /**
4603
+ * Normalisation of the namespace to a value that is compatible with the OpenEO specs - EXPERIMENTAL.
4604
+ *
4605
+ * This is required to support UDP that are shared as public. These can only be executed with providing the full URL
4606
+ * (e.g. https://<backend>/processes/<namespace>/<process_id>) as the namespace value in the processing graph. For other
4607
+ * parts of the API (such as the listing of the processes, only the name of the namespace is required.
4608
+ *
4609
+ * This function will extract the short name of the namespace from a shareable URL.
4610
+ *
4611
+ * @protected
4612
+ * @param {?string} namespace - Namespace of the process
4613
+ * @returns {?string}
4614
+ */
4615
+
4616
+
4617
+ normalizeNamespace(namespace) {
4618
+ // The pattern in https://github.com/Open-EO/openeo-api/pull/348 doesn't include the double colon yet - the regexp may change in the future
4619
+ const matches = namespace.match(/^https?:\/\/.*\/processes\/(@?[\w\-.~:]+)\/?/i);
4620
+ return matches && matches.length > 1 ? matches[1] : namespace;
4621
+ }
4601
4622
  /**
4602
4623
  * List processes available on the back-end.
4603
4624
  *
@@ -4621,7 +4642,7 @@ class Connection {
4621
4642
  namespace = 'backend';
4622
4643
  }
4623
4644
 
4624
- let path = namespace === 'backend' ? '/processes' : `/processes/${namespace}`;
4645
+ let path = namespace === 'backend' ? '/processes' : `/processes/${this.normalizeNamespace(namespace)}`;
4625
4646
  let response = await this._get(path);
4626
4647
 
4627
4648
  if (!Utils.isObject(response.data) || !Array.isArray(response.data.processes)) {
@@ -4657,7 +4678,7 @@ class Connection {
4657
4678
  if (namespace === 'backend') {
4658
4679
  await this.listProcesses();
4659
4680
  } else {
4660
- let response = await this._get(`/processes/${namespace}/${processId}`);
4681
+ let response = await this._get(`/processes/${this.normalizeNamespace(namespace)}/${processId}`);
4661
4682
 
4662
4683
  if (!Utils.isObject(response.data) || typeof response.data.id !== 'string') {
4663
4684
  throw new Error('Invalid response received for process');
@@ -5723,7 +5744,7 @@ class Job extends BaseEntity {
5723
5744
  * The process chain to be executed.
5724
5745
  * @public
5725
5746
  * @readonly
5726
- * @type {Process}
5747
+ * @type {?Process}
5727
5748
  */
5728
5749
 
5729
5750
  this.process = undefined;
@@ -5732,7 +5753,7 @@ class Job extends BaseEntity {
5732
5753
  * One of "created", "queued", "running", "canceled", "finished" or "error".
5733
5754
  * @public
5734
5755
  * @readonly
5735
- * @type {string}
5756
+ * @type {?string}
5736
5757
  */
5737
5758
 
5738
5759
  this.status = undefined;
@@ -5740,7 +5761,7 @@ class Job extends BaseEntity {
5740
5761
  * Indicates the process of a running batch job in percent.
5741
5762
  * @public
5742
5763
  * @readonly
5743
- * @type {number}
5764
+ * @type {?number}
5744
5765
  */
5745
5766
 
5746
5767
  this.progress = undefined;
@@ -5748,7 +5769,7 @@ class Job extends BaseEntity {
5748
5769
  * Date and time of creation, formatted as a RFC 3339 date-time.
5749
5770
  * @public
5750
5771
  * @readonly
5751
- * @type {string}
5772
+ * @type {?string}
5752
5773
  */
5753
5774
 
5754
5775
  this.created = undefined;
@@ -5756,7 +5777,7 @@ class Job extends BaseEntity {
5756
5777
  * Date and time of the last status change, formatted as a RFC 3339 date-time.
5757
5778
  * @public
5758
5779
  * @readonly
5759
- * @type {string}
5780
+ * @type {?string}
5760
5781
  */
5761
5782
 
5762
5783
  this.updated = undefined;
@@ -5764,7 +5785,7 @@ class Job extends BaseEntity {
5764
5785
  * The billing plan to process and charge the batch job with.
5765
5786
  * @public
5766
5787
  * @readonly
5767
- * @type {string}
5788
+ * @type {?string}
5768
5789
  */
5769
5790
 
5770
5791
  this.plan = undefined;
@@ -6216,7 +6237,7 @@ class OidcProvider extends AuthProvider {
6216
6237
  /**
6217
6238
  * The client ID to use for authentication.
6218
6239
  *
6219
- * @type {?string}
6240
+ * @type {string | null}
6220
6241
  */
6221
6242
 
6222
6243
  this.clientId = null;
@@ -6244,6 +6265,13 @@ class OidcProvider extends AuthProvider {
6244
6265
  */
6245
6266
 
6246
6267
  this.scopes = Array.isArray(options.scopes) && options.scopes.length > 0 ? options.scopes : ['openid'];
6268
+ /**
6269
+ * The scope that is used to request a refresh token.
6270
+ *
6271
+ * @type {string}
6272
+ */
6273
+
6274
+ this.refreshTokenScope = "offline_access";
6247
6275
  /**
6248
6276
  * Any additional links.
6249
6277
  *
@@ -6304,21 +6332,25 @@ class OidcProvider extends AuthProvider {
6304
6332
  *
6305
6333
  * Supported only in Browser environments.
6306
6334
  *
6335
+ * @async
6307
6336
  * @param {object.<string, *>} [options={}] - Object with authentication options.
6337
+ * @param {boolean} [requestRefreshToken=false] - If set to `true`, adds a scope to request a refresh token.
6308
6338
  * @returns {Promise<void>}
6309
6339
  * @throws {Error}
6310
6340
  * @see https://github.com/IdentityModel/oidc-client-js/wiki#other-optional-settings
6341
+ * @see {OidcProvider#refreshTokenScope}
6311
6342
  */
6312
6343
 
6313
6344
 
6314
6345
  async login() {
6315
6346
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6347
+ let requestRefreshToken = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6316
6348
 
6317
6349
  if (!this.issuer || typeof this.issuer !== 'string') {
6318
6350
  throw new Error("No Issuer URL available for OpenID Connect");
6319
6351
  }
6320
6352
 
6321
- this.manager = new Oidc.UserManager(this.getOptions(options));
6353
+ this.manager = new Oidc.UserManager(this.getOptions(options, requestRefreshToken));
6322
6354
  this.addListener('UserLoaded', async () => this.setUser(await this.manager.getUser()), 'js-client');
6323
6355
  this.addListener('AccessTokenExpired', () => this.setUser(null), 'js-client');
6324
6356
 
@@ -6363,18 +6395,27 @@ class OidcProvider extends AuthProvider {
6363
6395
  *
6364
6396
  * @protected
6365
6397
  * @param {object.<string, *>} options
6398
+ * @param {boolean} [requestRefreshToken=false] - If set to `true`, adds a scope to request a refresh token.
6366
6399
  * @returns {object.<string, *>}
6400
+ * @see {OidcProvider#refreshTokenScope}
6367
6401
  */
6368
6402
 
6369
6403
 
6370
6404
  getOptions() {
6371
6405
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6406
+ let requestRefreshToken = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6372
6407
  let response_type = this.getResponseType();
6408
+ let scope = this.scopes.slice(0);
6409
+
6410
+ if (requestRefreshToken && !scope.includes(this.refreshTokenScope)) {
6411
+ scope.push(this.refreshTokenScope);
6412
+ }
6413
+
6373
6414
  return Object.assign({
6374
6415
  client_id: this.clientId,
6375
6416
  redirect_uri: OidcProvider.redirectUrl,
6376
6417
  authority: this.issuer.replace('/.well-known/openid-configuration', ''),
6377
- scope: this.scopes.join(' '),
6418
+ scope,
6378
6419
  validateSubOnSilentRenew: true,
6379
6420
  response_type,
6380
6421
  response_mode: response_type.includes('code') ? 'query' : 'fragment'
@@ -6652,7 +6693,7 @@ class OpenEO {
6652
6693
 
6653
6694
 
6654
6695
  static clientVersion() {
6655
- return "2.3.1";
6696
+ return "2.4.0";
6656
6697
  }
6657
6698
 
6658
6699
  }
@@ -6728,7 +6769,7 @@ class Service extends BaseEntity {
6728
6769
  * The process chain to be executed.
6729
6770
  * @public
6730
6771
  * @readonly
6731
- * @type {Process}
6772
+ * @type {?Process}
6732
6773
  */
6733
6774
 
6734
6775
  this.process = undefined;
@@ -6736,7 +6777,7 @@ class Service extends BaseEntity {
6736
6777
  * URL at which the secondary web service is accessible
6737
6778
  * @public
6738
6779
  * @readonly
6739
- * @type {string}
6780
+ * @type {?string}
6740
6781
  */
6741
6782
 
6742
6783
  this.url = undefined;
@@ -6744,14 +6785,14 @@ class Service extends BaseEntity {
6744
6785
  * Web service type (protocol / standard) that is exposed.
6745
6786
  * @public
6746
6787
  * @readonly
6747
- * @type {string}
6788
+ * @type {?string}
6748
6789
  */
6749
6790
 
6750
6791
  this.type = undefined;
6751
6792
  /**
6752
6793
  * @public
6753
6794
  * @readonly
6754
- * @type {boolean}
6795
+ * @type {?boolean}
6755
6796
  */
6756
6797
 
6757
6798
  this.enabled = undefined;
@@ -6759,7 +6800,7 @@ class Service extends BaseEntity {
6759
6800
  * Map of configuration settings, i.e. the setting names supported by the secondary web service combined with actual values.
6760
6801
  * @public
6761
6802
  * @readonly
6762
- * @type {object.<string, *>}
6803
+ * @type {?object.<string, *>}
6763
6804
  */
6764
6805
 
6765
6806
  this.configuration = undefined;
@@ -6767,7 +6808,7 @@ class Service extends BaseEntity {
6767
6808
  * Additional attributes of the secondary web service, e.g. available layers for a WMS based on the bands in the underlying GeoTiff.
6768
6809
  * @public
6769
6810
  * @readonly
6770
- * @type {object.<string, *>}
6811
+ * @type {?object.<string, *>}
6771
6812
  */
6772
6813
 
6773
6814
  this.attributes = undefined;
@@ -6775,7 +6816,7 @@ class Service extends BaseEntity {
6775
6816
  * Date and time of creation, formatted as a RFC 3339 date-time.
6776
6817
  * @public
6777
6818
  * @readonly
6778
- * @type {string}
6819
+ * @type {?string}
6779
6820
  */
6780
6821
 
6781
6822
  this.created = undefined;
@@ -6783,7 +6824,7 @@ class Service extends BaseEntity {
6783
6824
  * The billing plan to process and charge the service with.
6784
6825
  * @public
6785
6826
  * @readonly
6786
- * @type {string}
6827
+ * @type {?string}
6787
6828
  */
6788
6829
 
6789
6830
  this.plan = undefined;
@@ -7134,7 +7175,7 @@ class UserProcess extends BaseEntity {
7134
7175
  * A list of categories.
7135
7176
  * @public
7136
7177
  * @readonly
7137
- * @type {Array.<string>}
7178
+ * @type {?Array.<string>}
7138
7179
  */
7139
7180
 
7140
7181
  this.categories = undefined;
@@ -7159,7 +7200,7 @@ class UserProcess extends BaseEntity {
7159
7200
  * Specifies that the process or parameter is deprecated with the potential to be removed in any of the next versions.
7160
7201
  * @public
7161
7202
  * @readonly
7162
- * @type {boolean}
7203
+ * @type {?boolean}
7163
7204
  */
7164
7205
 
7165
7206
  this.deprecated = undefined;
@@ -7167,7 +7208,7 @@ class UserProcess extends BaseEntity {
7167
7208
  * Declares the process or parameter to be experimental, which means that it is likely to change or may produce unpredictable behaviour.
7168
7209
  * @public
7169
7210
  * @readonly
7170
- * @type {boolean}
7211
+ * @type {?boolean}
7171
7212
  */
7172
7213
 
7173
7214
  this.experimental = undefined;
@@ -7175,14 +7216,14 @@ class UserProcess extends BaseEntity {
7175
7216
  * Declares any exceptions (errors) that might occur during execution of this process.
7176
7217
  * @public
7177
7218
  * @readonly
7178
- * @type {object.<string, *>}
7219
+ * @type {?object.<string, *>}
7179
7220
  */
7180
7221
 
7181
7222
  this.exceptions = undefined;
7182
7223
  /**
7183
7224
  * @public
7184
7225
  * @readonly
7185
- * @type {Array.<object.<string, *>>}
7226
+ * @type {?Array.<object.<string, *>>}
7186
7227
  */
7187
7228
 
7188
7229
  this.examples = undefined;
@@ -7190,14 +7231,14 @@ class UserProcess extends BaseEntity {
7190
7231
  * Links related to this process.
7191
7232
  * @public
7192
7233
  * @readonly
7193
- * @type {Array.<Link>}
7234
+ * @type {?Array.<Link>}
7194
7235
  */
7195
7236
 
7196
7237
  this.links = undefined;
7197
7238
  /**
7198
7239
  * @public
7199
7240
  * @readonly
7200
- * @type {object.<string, *>}
7241
+ * @type {?object.<string, *>}
7201
7242
  */
7202
7243
 
7203
7244
  this.processGraph = undefined;