@openeo/js-client 2.5.1 → 2.6.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/LICENSE +201 -201
- package/README.md +93 -83
- package/openeo.d.ts +112 -53
- package/openeo.js +3670 -4113
- package/openeo.min.js +1 -1
- package/package.json +72 -70
- package/src/authprovider.js +147 -138
- package/src/baseentity.js +162 -162
- package/src/basicprovider.js +69 -48
- package/src/browser.js +168 -168
- package/src/builder/builder.js +400 -400
- package/src/builder/formula.js +211 -211
- package/src/builder/node.js +268 -268
- package/src/builder/parameter.js +144 -144
- package/src/builder/tapdigit.js +489 -489
- package/src/capabilities.js +265 -220
- package/src/connection.js +1310 -1211
- package/src/env.js +5 -5
- package/src/filetypes.js +111 -111
- package/src/job.js +323 -322
- package/src/logs.js +73 -68
- package/src/node.js +168 -168
- package/src/oidcprovider.js +387 -375
- package/src/openeo.js +137 -138
- package/src/service.js +222 -221
- package/src/typedefs.js +242 -242
- package/src/userfile.js +128 -128
- package/src/userprocess.js +166 -166
package/src/capabilities.js
CHANGED
|
@@ -1,220 +1,265 @@
|
|
|
1
|
-
const Utils = require('@openeo/js-commons/src/utils');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
1
|
+
const Utils = require('@openeo/js-commons/src/utils');
|
|
2
|
+
|
|
3
|
+
const FEATURE_MAP = {
|
|
4
|
+
// Discovery
|
|
5
|
+
capabilities: true,
|
|
6
|
+
listFileTypes: 'get /file_formats',
|
|
7
|
+
listServiceTypes: 'get /service_types',
|
|
8
|
+
listUdfRuntimes: 'get /udf_runtimes',
|
|
9
|
+
// Collections
|
|
10
|
+
listCollections: 'get /collections',
|
|
11
|
+
describeCollection: 'get /collections/{}',
|
|
12
|
+
listCollectionItems: 'get /collections/{}/items',
|
|
13
|
+
describeCollectionItem: 'get /collections/{}/items/{}',
|
|
14
|
+
describeCollectionQueryables: 'get /collections/{}/queryables',
|
|
15
|
+
// Processes
|
|
16
|
+
listProcesses: 'get /processes',
|
|
17
|
+
describeProcess: 'get /processes',
|
|
18
|
+
// Auth / Account
|
|
19
|
+
listAuthProviders: true,
|
|
20
|
+
authenticateOIDC: 'get /credentials/oidc',
|
|
21
|
+
authenticateBasic: 'get /credentials/basic',
|
|
22
|
+
describeAccount: 'get /me',
|
|
23
|
+
// Files
|
|
24
|
+
listFiles: 'get /files',
|
|
25
|
+
getFile: 'get /files', // getFile is a virtual function and doesn't request an endpoint, but get /files should be available nevertheless.
|
|
26
|
+
uploadFile: 'put /files/{}',
|
|
27
|
+
downloadFile: 'get /files/{}',
|
|
28
|
+
deleteFile: 'delete /files/{}',
|
|
29
|
+
// User-Defined Processes
|
|
30
|
+
validateProcess: 'post /validation',
|
|
31
|
+
listUserProcesses: 'get /process_graphs',
|
|
32
|
+
describeUserProcess: 'get /process_graphs/{}',
|
|
33
|
+
getUserProcess: 'get /process_graphs/{}',
|
|
34
|
+
setUserProcess: 'put /process_graphs/{}',
|
|
35
|
+
replaceUserProcess: 'put /process_graphs/{}',
|
|
36
|
+
deleteUserProcess: 'delete /process_graphs/{}',
|
|
37
|
+
// Processing
|
|
38
|
+
computeResult: 'post /result',
|
|
39
|
+
listJobs: 'get /jobs',
|
|
40
|
+
createJob: 'post /jobs',
|
|
41
|
+
listServices: 'get /services',
|
|
42
|
+
createService: 'post /services',
|
|
43
|
+
getJob: 'get /jobs/{}',
|
|
44
|
+
describeJob: 'get /jobs/{}',
|
|
45
|
+
updateJob: 'patch /jobs/{}',
|
|
46
|
+
deleteJob: 'delete /jobs/{}',
|
|
47
|
+
estimateJob: 'get /jobs/{}/estimate',
|
|
48
|
+
debugJob: 'get /jobs/{}/logs',
|
|
49
|
+
startJob: 'post /jobs/{}/results',
|
|
50
|
+
stopJob: 'delete /jobs/{}/results',
|
|
51
|
+
listResults: 'get /jobs/{}/results',
|
|
52
|
+
downloadResults: 'get /jobs/{}/results',
|
|
53
|
+
// Web services
|
|
54
|
+
describeService: 'get /services/{}',
|
|
55
|
+
getService: 'get /services/{}',
|
|
56
|
+
updateService: 'patch /services/{}',
|
|
57
|
+
deleteService: 'delete /services/{}',
|
|
58
|
+
debugService: 'get /services/{}/logs',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Capabilities of a back-end.
|
|
63
|
+
*/
|
|
64
|
+
class Capabilities {
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new Capabilities object from an API-compatible JSON response.
|
|
68
|
+
*
|
|
69
|
+
* @param {object.<string, *>} data - A capabilities response compatible to the API specification for `GET /`.
|
|
70
|
+
* @throws {Error}
|
|
71
|
+
*/
|
|
72
|
+
constructor(data) {
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
* @type {object.<string, *>}
|
|
77
|
+
*/
|
|
78
|
+
this.data = data;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
* @ignore
|
|
83
|
+
* @type {object.<string, string>}
|
|
84
|
+
*/
|
|
85
|
+
this.featureMap = FEATURE_MAP;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @private
|
|
89
|
+
* @type {Array.<string>}
|
|
90
|
+
*/
|
|
91
|
+
this.features = [];
|
|
92
|
+
|
|
93
|
+
this.validate();
|
|
94
|
+
this.init();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Validates the capabilities.
|
|
99
|
+
*
|
|
100
|
+
* Throws an error in case of an issue, otherwise just passes.
|
|
101
|
+
*
|
|
102
|
+
* @protected
|
|
103
|
+
* @throws {Error}
|
|
104
|
+
*/
|
|
105
|
+
validate() {
|
|
106
|
+
if(!Utils.isObject(this.data)) {
|
|
107
|
+
throw new Error("No capabilities retrieved.");
|
|
108
|
+
}
|
|
109
|
+
else if(!this.data.api_version) {
|
|
110
|
+
throw new Error("Invalid capabilities: No API version retrieved");
|
|
111
|
+
}
|
|
112
|
+
else if(!Array.isArray(this.data.endpoints)) {
|
|
113
|
+
throw new Error("Invalid capabilities: No endpoints retrieved");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Initializes the class.
|
|
119
|
+
*
|
|
120
|
+
* @protected
|
|
121
|
+
*/
|
|
122
|
+
init() {
|
|
123
|
+
this.features = this.data.endpoints
|
|
124
|
+
// Flatten features and simplify variables to be compatible with the feature map.
|
|
125
|
+
.map(e => e.methods.map(method => {
|
|
126
|
+
const path = e.path.replace(/\{[^}]+\}/g, '{}');
|
|
127
|
+
return `${method} ${path}`.toLowerCase();
|
|
128
|
+
}))
|
|
129
|
+
.reduce((flat, next) => flat.concat(next), []); // .flat(1) once browser support for ECMAscript 10/2019 gets better
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns the capabilities response as a JSON serializable representation of the data that is API compliant.
|
|
134
|
+
*
|
|
135
|
+
* @returns {object.<string, *>} - A reference to the capabilities response.
|
|
136
|
+
*/
|
|
137
|
+
toJSON() {
|
|
138
|
+
return this.data;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns the openEO API version implemented by the back-end.
|
|
143
|
+
*
|
|
144
|
+
* @returns {string} openEO API version number.
|
|
145
|
+
*/
|
|
146
|
+
apiVersion() {
|
|
147
|
+
return this.data.api_version;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Returns the back-end version number.
|
|
152
|
+
*
|
|
153
|
+
* @returns {string} openEO back-end version number.
|
|
154
|
+
*/
|
|
155
|
+
backendVersion() {
|
|
156
|
+
return this.data.backend_version;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns the back-end title.
|
|
161
|
+
*
|
|
162
|
+
* @returns {string} Title
|
|
163
|
+
*/
|
|
164
|
+
title() {
|
|
165
|
+
return typeof this.data.title === 'string' ? this.data.title : "";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Returns the back-end description.
|
|
170
|
+
*
|
|
171
|
+
* @returns {string} Description
|
|
172
|
+
*/
|
|
173
|
+
description() {
|
|
174
|
+
return typeof this.data.description === 'string' ? this.data.description : "";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Is the back-end suitable for use in production?
|
|
179
|
+
*
|
|
180
|
+
* @returns {boolean} true = stable/production, false = unstable
|
|
181
|
+
*/
|
|
182
|
+
isStable() {
|
|
183
|
+
return this.data.production === true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Returns the links.
|
|
188
|
+
*
|
|
189
|
+
* @returns {Array.<Link>} Array of link objects (href, title, rel, type)
|
|
190
|
+
*/
|
|
191
|
+
links() {
|
|
192
|
+
return Array.isArray(this.data.links) ? this.data.links : [];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Lists all supported features.
|
|
197
|
+
*
|
|
198
|
+
* @returns {Array.<string>} An array of supported features.
|
|
199
|
+
*/
|
|
200
|
+
listFeatures() {
|
|
201
|
+
let features = [];
|
|
202
|
+
for(let feature in this.featureMap) {
|
|
203
|
+
if (this.featureMap[feature] === true || this.features.includes(this.featureMap[feature])) {
|
|
204
|
+
features.push(feature);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return features.sort();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Check whether a feature is supported by the back-end.
|
|
212
|
+
*
|
|
213
|
+
* @param {string} methodName - A feature name (corresponds to the JS client method names, see also the feature map for allowed values).
|
|
214
|
+
* @returns {boolean} `true` if the feature is supported, otherwise `false`.
|
|
215
|
+
*/
|
|
216
|
+
hasFeature(methodName) {
|
|
217
|
+
let feature = this.featureMap[methodName];
|
|
218
|
+
if (typeof feature === 'string') {
|
|
219
|
+
feature = feature.toLowerCase();
|
|
220
|
+
}
|
|
221
|
+
return feature === true || this.features.some(e => e === feature);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Get the billing currency.
|
|
226
|
+
*
|
|
227
|
+
* @returns {string | null} The billing currency or `null` if not available.
|
|
228
|
+
*/
|
|
229
|
+
currency() {
|
|
230
|
+
return (Utils.isObject(this.data.billing) && typeof this.data.billing.currency === 'string' ? this.data.billing.currency : null);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* List all billing plans.
|
|
235
|
+
*
|
|
236
|
+
* @returns {Array.<BillingPlan>} Billing plans
|
|
237
|
+
*/
|
|
238
|
+
listPlans() {
|
|
239
|
+
if (Utils.isObject(this.data.billing) && Array.isArray(this.data.billing.plans)) {
|
|
240
|
+
let defaultPlan = typeof this.data.billing.default_plan === 'string' ? this.data.billing.default_plan.toLowerCase() : null;
|
|
241
|
+
return this.data.billing.plans.map(plan => {
|
|
242
|
+
let addition = {
|
|
243
|
+
default: (defaultPlan === plan.name.toLowerCase())
|
|
244
|
+
};
|
|
245
|
+
return Object.assign({}, plan, addition);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Migrates a response, if required.
|
|
255
|
+
*
|
|
256
|
+
* @param {AxiosResponse} response
|
|
257
|
+
* @protected
|
|
258
|
+
* @returns {AxiosResponse}
|
|
259
|
+
*/
|
|
260
|
+
migrate(response) { // eslint-disable-line no-unused-vars
|
|
261
|
+
return response;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
module.exports = Capabilities;
|