@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/builder/parameter.js
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A class that represents a process parameter.
|
|
5
|
-
*
|
|
6
|
-
* This is used for two things:
|
|
7
|
-
* 1. You can create process parameters (placeholders) with `new Parameter()`.
|
|
8
|
-
* 2. This is passed to functions for the parameters of the sub-process.
|
|
9
|
-
*
|
|
10
|
-
* For the second case, you can access array elements referred to by the parameter
|
|
11
|
-
* with a simplified notation:
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* function(data, context) {
|
|
15
|
-
* data['B1'] // Accesses the B1 element of the array by label
|
|
16
|
-
* data[1] // Accesses the second element of the array by index
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Those array calls create corresponding `array_element` nodes in the process. So it's
|
|
21
|
-
* equivalent to
|
|
22
|
-
* `this.array_element(data, undefined, 'B1')` or
|
|
23
|
-
* `this.array_element(data, 1)` respectively.
|
|
24
|
-
*
|
|
25
|
-
* Simple access to numeric labels is not supported. You need to use `array_element` directly, e.g.
|
|
26
|
-
* `this.array_element(data, undefined, 1)`.
|
|
27
|
-
*/
|
|
28
|
-
class Parameter {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new parameter instance, but proxies calls to it
|
|
32
|
-
* so that array access is possible (see class description).
|
|
33
|
-
*
|
|
34
|
-
* @static
|
|
35
|
-
* @param {Builder} builder
|
|
36
|
-
* @param {string} parameterName
|
|
37
|
-
* @returns {Proxy<Parameter>}
|
|
38
|
-
*/
|
|
39
|
-
static create(builder, parameterName) {
|
|
40
|
-
let parameter = new Parameter(parameterName, null);
|
|
41
|
-
if (typeof Proxy !== "undefined") {
|
|
42
|
-
return new Proxy(parameter, {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
nodeCache: {},
|
|
45
|
-
/**
|
|
46
|
-
* Getter for array access (see class description).
|
|
47
|
-
*
|
|
48
|
-
* @ignore
|
|
49
|
-
* @param {object} target
|
|
50
|
-
* @param {string|number|symbol} name
|
|
51
|
-
* @param {?*} receiver
|
|
52
|
-
* @returns {*}
|
|
53
|
-
*/
|
|
54
|
-
get(target, name, receiver) {
|
|
55
|
-
if (!Reflect.has(target, name)) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
if (!this.nodeCache[name]) {
|
|
58
|
-
let args = {
|
|
59
|
-
data: parameter
|
|
60
|
-
};
|
|
61
|
-
if (typeof name === 'string' && name.match(/^(0|[1-9]\d*)$/)) {
|
|
62
|
-
args.index = parseInt(name, 10);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
args.label = name;
|
|
66
|
-
}
|
|
67
|
-
// We assume array_element exists
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
this.nodeCache[name] = builder.process("array_element", args);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
return this.nodeCache[name];
|
|
74
|
-
}
|
|
75
|
-
return Reflect.get(target, name, receiver);
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* Setter for array access.
|
|
79
|
-
*
|
|
80
|
-
* Usually fails as write access to arrays is not supported.
|
|
81
|
-
*
|
|
82
|
-
* @ignore
|
|
83
|
-
* @param {object} target
|
|
84
|
-
* @param {string|number|symbol} name
|
|
85
|
-
* @param {*} value
|
|
86
|
-
* @param {?*} receiver
|
|
87
|
-
* @returns {boolean}
|
|
88
|
-
*/
|
|
89
|
-
set(target, name, value, receiver) {
|
|
90
|
-
if (!Reflect.has(target, name)) {
|
|
91
|
-
throw new Error('Simplified array access is read-only');
|
|
92
|
-
}
|
|
93
|
-
return Reflect.set(target, name, value, receiver);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw new Error('Simplified array access not supported, use array_element directly');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new process parameter.
|
|
104
|
-
*
|
|
105
|
-
* @param {string} name - Name of the parameter.
|
|
106
|
-
* @param {object.<string, *>|string} schema - The schema for the parameter. Can be either an object compliant to JSON Schema or a string with a JSON Schema compliant data type, e.g. `string`.
|
|
107
|
-
* @param {string} description - A description for the parameter
|
|
108
|
-
* @param {*} defaultValue - An optional default Value for the parameter. If set, make the parameter optional. If not set, the parameter is required. Defaults to `undefined`.
|
|
109
|
-
*/
|
|
110
|
-
constructor(name, schema = {}, description = "", defaultValue = undefined) {
|
|
111
|
-
this.name = name;
|
|
112
|
-
this.spec = {
|
|
113
|
-
name: name,
|
|
114
|
-
schema: typeof schema === 'string' ? { type: schema } : schema,
|
|
115
|
-
description: description,
|
|
116
|
-
};
|
|
117
|
-
// No support for experimental and deprecated yet
|
|
118
|
-
if (typeof defaultValue !== 'undefined') {
|
|
119
|
-
this.spec.optional = true;
|
|
120
|
-
this.spec.default = defaultValue;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Returns a JSON serializable representation of the data that is API compliant.
|
|
126
|
-
*
|
|
127
|
-
* @returns {object.<string, *>}
|
|
128
|
-
*/
|
|
129
|
-
toJSON() {
|
|
130
|
-
return this.spec;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Returns the reference object for this parameter.
|
|
135
|
-
*
|
|
136
|
-
* @returns {FromParameter}
|
|
137
|
-
*/
|
|
138
|
-
ref() {
|
|
139
|
-
return { from_parameter: this.name };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = Parameter;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A class that represents a process parameter.
|
|
5
|
+
*
|
|
6
|
+
* This is used for two things:
|
|
7
|
+
* 1. You can create process parameters (placeholders) with `new Parameter()`.
|
|
8
|
+
* 2. This is passed to functions for the parameters of the sub-process.
|
|
9
|
+
*
|
|
10
|
+
* For the second case, you can access array elements referred to by the parameter
|
|
11
|
+
* with a simplified notation:
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* function(data, context) {
|
|
15
|
+
* data['B1'] // Accesses the B1 element of the array by label
|
|
16
|
+
* data[1] // Accesses the second element of the array by index
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Those array calls create corresponding `array_element` nodes in the process. So it's
|
|
21
|
+
* equivalent to
|
|
22
|
+
* `this.array_element(data, undefined, 'B1')` or
|
|
23
|
+
* `this.array_element(data, 1)` respectively.
|
|
24
|
+
*
|
|
25
|
+
* Simple access to numeric labels is not supported. You need to use `array_element` directly, e.g.
|
|
26
|
+
* `this.array_element(data, undefined, 1)`.
|
|
27
|
+
*/
|
|
28
|
+
class Parameter {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new parameter instance, but proxies calls to it
|
|
32
|
+
* so that array access is possible (see class description).
|
|
33
|
+
*
|
|
34
|
+
* @static
|
|
35
|
+
* @param {Builder} builder
|
|
36
|
+
* @param {string} parameterName
|
|
37
|
+
* @returns {Proxy<Parameter>}
|
|
38
|
+
*/
|
|
39
|
+
static create(builder, parameterName) {
|
|
40
|
+
let parameter = new Parameter(parameterName, null);
|
|
41
|
+
if (typeof Proxy !== "undefined") {
|
|
42
|
+
return new Proxy(parameter, {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
nodeCache: {},
|
|
45
|
+
/**
|
|
46
|
+
* Getter for array access (see class description).
|
|
47
|
+
*
|
|
48
|
+
* @ignore
|
|
49
|
+
* @param {object} target
|
|
50
|
+
* @param {string|number|symbol} name
|
|
51
|
+
* @param {?*} receiver
|
|
52
|
+
* @returns {*}
|
|
53
|
+
*/
|
|
54
|
+
get(target, name, receiver) {
|
|
55
|
+
if (!Reflect.has(target, name)) {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
if (!this.nodeCache[name]) {
|
|
58
|
+
let args = {
|
|
59
|
+
data: parameter
|
|
60
|
+
};
|
|
61
|
+
if (typeof name === 'string' && name.match(/^(0|[1-9]\d*)$/)) {
|
|
62
|
+
args.index = parseInt(name, 10);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
args.label = name;
|
|
66
|
+
}
|
|
67
|
+
// We assume array_element exists
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
this.nodeCache[name] = builder.process("array_element", args);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
return this.nodeCache[name];
|
|
74
|
+
}
|
|
75
|
+
return Reflect.get(target, name, receiver);
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Setter for array access.
|
|
79
|
+
*
|
|
80
|
+
* Usually fails as write access to arrays is not supported.
|
|
81
|
+
*
|
|
82
|
+
* @ignore
|
|
83
|
+
* @param {object} target
|
|
84
|
+
* @param {string|number|symbol} name
|
|
85
|
+
* @param {*} value
|
|
86
|
+
* @param {?*} receiver
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
set(target, name, value, receiver) {
|
|
90
|
+
if (!Reflect.has(target, name)) {
|
|
91
|
+
throw new Error('Simplified array access is read-only');
|
|
92
|
+
}
|
|
93
|
+
return Reflect.set(target, name, value, receiver);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error('Simplified array access not supported, use array_element directly');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new process parameter.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} name - Name of the parameter.
|
|
106
|
+
* @param {object.<string, *>|string} schema - The schema for the parameter. Can be either an object compliant to JSON Schema or a string with a JSON Schema compliant data type, e.g. `string`.
|
|
107
|
+
* @param {string} description - A description for the parameter
|
|
108
|
+
* @param {*} defaultValue - An optional default Value for the parameter. If set, make the parameter optional. If not set, the parameter is required. Defaults to `undefined`.
|
|
109
|
+
*/
|
|
110
|
+
constructor(name, schema = {}, description = "", defaultValue = undefined) {
|
|
111
|
+
this.name = name;
|
|
112
|
+
this.spec = {
|
|
113
|
+
name: name,
|
|
114
|
+
schema: typeof schema === 'string' ? { type: schema } : schema,
|
|
115
|
+
description: description,
|
|
116
|
+
};
|
|
117
|
+
// No support for experimental and deprecated yet
|
|
118
|
+
if (typeof defaultValue !== 'undefined') {
|
|
119
|
+
this.spec.optional = true;
|
|
120
|
+
this.spec.default = defaultValue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns a JSON serializable representation of the data that is API compliant.
|
|
126
|
+
*
|
|
127
|
+
* @returns {object.<string, *>}
|
|
128
|
+
*/
|
|
129
|
+
toJSON() {
|
|
130
|
+
return this.spec;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns the reference object for this parameter.
|
|
135
|
+
*
|
|
136
|
+
* @returns {FromParameter}
|
|
137
|
+
*/
|
|
138
|
+
ref() {
|
|
139
|
+
return { from_parameter: this.name };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = Parameter;
|