@openeo/js-client 2.5.1 → 2.7.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 +94 -84
- package/openeo.d.ts +310 -72
- package/openeo.js +5412 -5191
- 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 +274 -220
- package/src/connection.js +1290 -1211
- package/src/env.js +16 -6
- package/src/filetypes.js +111 -111
- package/src/job.js +323 -322
- package/src/logs.js +109 -68
- package/src/node.js +168 -168
- package/src/oidcprovider.js +387 -375
- package/src/openeo.js +137 -138
- package/src/pages.js +349 -0
- package/src/service.js +222 -221
- package/src/typedefs.js +271 -243
- package/src/userfile.js +128 -128
- package/src/userprocess.js +166 -166
package/src/authprovider.js
CHANGED
|
@@ -1,138 +1,147 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base class for authentication providers such as Basic and OpenID Connect.
|
|
3
|
-
*
|
|
4
|
-
* @abstract
|
|
5
|
-
*/
|
|
6
|
-
class AuthProvider {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new OidcProvider instance to authenticate using OpenID Connect.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} type - The type of the authentication procedure as specified by the API, e.g. `oidc` or `basic`.
|
|
12
|
-
* @param {Connection} connection - A Connection object representing an established connection to an openEO back-end.
|
|
13
|
-
* @param {AuthProviderMeta} options - Options
|
|
14
|
-
*/
|
|
15
|
-
constructor(type, connection, options) {
|
|
16
|
-
this.id = options.id || null;
|
|
17
|
-
this.title = options.title || "";
|
|
18
|
-
this.description = options.description || "";
|
|
19
|
-
this.type = type;
|
|
20
|
-
/**
|
|
21
|
-
* @protected
|
|
22
|
-
* @type {Connection}
|
|
23
|
-
*/
|
|
24
|
-
this.connection = connection;
|
|
25
|
-
this.token = null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get an identifier for the auth provider (combination of the type + provider identifier).
|
|
30
|
-
*
|
|
31
|
-
* @returns {string}
|
|
32
|
-
*/
|
|
33
|
-
getId() {
|
|
34
|
-
let id = this.getType();
|
|
35
|
-
if (this.getProviderId().length > 0) {
|
|
36
|
-
id += '.' + this.getProviderId();
|
|
37
|
-
}
|
|
38
|
-
return id;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns
|
|
43
|
-
*
|
|
44
|
-
* @returns {string}
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Returns the
|
|
52
|
-
*
|
|
53
|
-
* @returns {string}
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Returns the
|
|
61
|
-
*
|
|
62
|
-
* @returns {string}
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
return this.
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Returns the human-readable
|
|
70
|
-
*
|
|
71
|
-
* @returns {string}
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
return this.
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns the
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The base class for authentication providers such as Basic and OpenID Connect.
|
|
3
|
+
*
|
|
4
|
+
* @abstract
|
|
5
|
+
*/
|
|
6
|
+
class AuthProvider {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new OidcProvider instance to authenticate using OpenID Connect.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} type - The type of the authentication procedure as specified by the API, e.g. `oidc` or `basic`.
|
|
12
|
+
* @param {Connection} connection - A Connection object representing an established connection to an openEO back-end.
|
|
13
|
+
* @param {AuthProviderMeta} options - Options
|
|
14
|
+
*/
|
|
15
|
+
constructor(type, connection, options) {
|
|
16
|
+
this.id = options.id || null;
|
|
17
|
+
this.title = options.title || "";
|
|
18
|
+
this.description = options.description || "";
|
|
19
|
+
this.type = type;
|
|
20
|
+
/**
|
|
21
|
+
* @protected
|
|
22
|
+
* @type {Connection}
|
|
23
|
+
*/
|
|
24
|
+
this.connection = connection;
|
|
25
|
+
this.token = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get an identifier for the auth provider (combination of the type + provider identifier).
|
|
30
|
+
*
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
getId() {
|
|
34
|
+
let id = this.getType();
|
|
35
|
+
if (this.getProviderId().length > 0) {
|
|
36
|
+
id += '.' + this.getProviderId();
|
|
37
|
+
}
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns a display name for the authenticated user.
|
|
43
|
+
*
|
|
44
|
+
* @returns {string?} Name of the user or `null`
|
|
45
|
+
*/
|
|
46
|
+
getDisplayName() {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the type of the authentication procedure as specified by the API, e.g. `oidc` or `basic`.
|
|
52
|
+
*
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
getType() {
|
|
56
|
+
return this.type;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns the provider identifier, may not be available for all authentication methods.
|
|
61
|
+
*
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
getProviderId() {
|
|
65
|
+
return typeof this.id === 'string' ? this.id : "";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Returns the human-readable title for the authentication method / provider.
|
|
70
|
+
*
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
getTitle() {
|
|
74
|
+
return this.title;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the human-readable description for the authentication method / provider.
|
|
79
|
+
*
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
getDescription() {
|
|
83
|
+
return this.description;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns the access token that is used as Bearer Token in API requests.
|
|
88
|
+
*
|
|
89
|
+
* Returns `null` if no access token has been set yet (i.e. not authenticated any longer).
|
|
90
|
+
*
|
|
91
|
+
* @returns {string | null}
|
|
92
|
+
*/
|
|
93
|
+
getToken() {
|
|
94
|
+
if (typeof this.token === 'string') {
|
|
95
|
+
return this.getType() + "/" + this.getProviderId() + "/" + this.token;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Sets the access token that is used as Bearer Token in API requests.
|
|
104
|
+
*
|
|
105
|
+
* Set to `null` to remove the access token.
|
|
106
|
+
*
|
|
107
|
+
* This also manages which auth provider is set for the connection.
|
|
108
|
+
*
|
|
109
|
+
* @param {?string} token
|
|
110
|
+
*/
|
|
111
|
+
setToken(token) {
|
|
112
|
+
this.token = token;
|
|
113
|
+
this.connection.emit('tokenChanged', token);
|
|
114
|
+
if (this.token !== null) {
|
|
115
|
+
this.connection.setAuthProvider(this);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.connection.setAuthProvider(null);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Abstract method that extending classes implement the login process with.
|
|
124
|
+
*
|
|
125
|
+
* @async
|
|
126
|
+
* @param {...*} args
|
|
127
|
+
* @throws {Error}
|
|
128
|
+
*/
|
|
129
|
+
async login(...args) {
|
|
130
|
+
throw new Error("Not implemented.", args);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Logout from the established session.
|
|
135
|
+
*
|
|
136
|
+
* This is experimental and just removes the token for now.
|
|
137
|
+
* May need to be overridden by sub-classes.
|
|
138
|
+
*
|
|
139
|
+
* @async
|
|
140
|
+
*/
|
|
141
|
+
async logout() {
|
|
142
|
+
this.setToken(null);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = AuthProvider;
|
package/src/baseentity.js
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base class for entities such as Job, Process Graph, Service etc.
|
|
3
|
-
*
|
|
4
|
-
* @abstract
|
|
5
|
-
*/
|
|
6
|
-
class BaseEntity {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of this object.
|
|
10
|
-
*
|
|
11
|
-
* @param {Connection} connection - A Connection object representing an established connection to an openEO back-end.
|
|
12
|
-
* @param {Array.<string|Array.<string>>} properties - A mapping from the API property names to the JS client property names (usually to convert between snake_case and camelCase), e.g. `["id", "title", ["process_graph", "processGraph"]]`
|
|
13
|
-
*/
|
|
14
|
-
constructor(connection, properties = []) {
|
|
15
|
-
/**
|
|
16
|
-
* @protected
|
|
17
|
-
* @type {Connection}
|
|
18
|
-
*/
|
|
19
|
-
this.connection = connection;
|
|
20
|
-
/**
|
|
21
|
-
* @protected
|
|
22
|
-
* @type {object.<string, string>}
|
|
23
|
-
*/
|
|
24
|
-
this.apiToClientNames = {};
|
|
25
|
-
/**
|
|
26
|
-
* @protected
|
|
27
|
-
* @type {object.<string, string>}
|
|
28
|
-
*/
|
|
29
|
-
this.clientToApiNames = {};
|
|
30
|
-
/**
|
|
31
|
-
* @protected
|
|
32
|
-
* @type {number}
|
|
33
|
-
*/
|
|
34
|
-
this.lastRefreshTime = 0;
|
|
35
|
-
/**
|
|
36
|
-
* Additional (non-standardized) properties received from the API.
|
|
37
|
-
*
|
|
38
|
-
* @protected
|
|
39
|
-
* @type {object.<string, *>}
|
|
40
|
-
*/
|
|
41
|
-
this.extra = {};
|
|
42
|
-
|
|
43
|
-
for(let i in properties) {
|
|
44
|
-
let backend, client;
|
|
45
|
-
if (Array.isArray(properties[i])) {
|
|
46
|
-
backend = properties[i][0];
|
|
47
|
-
client = properties[i][1];
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
backend = properties[i];
|
|
51
|
-
client = properties[i];
|
|
52
|
-
}
|
|
53
|
-
this.apiToClientNames[backend] = client;
|
|
54
|
-
this.clientToApiNames[client] = backend;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Returns a JSON serializable representation of the data that is API compliant.
|
|
60
|
-
*
|
|
61
|
-
* @returns {object.<string, *>}
|
|
62
|
-
*/
|
|
63
|
-
toJSON() {
|
|
64
|
-
let obj = {};
|
|
65
|
-
for(let key in this.clientToApiNames) {
|
|
66
|
-
let apiKey = this.clientToApiNames[key];
|
|
67
|
-
if (typeof this[key] !== 'undefined') {
|
|
68
|
-
obj[apiKey] = this[key];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return Object.assign(obj, this.extra);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Converts the data from an API response into data suitable for our JS client models.
|
|
76
|
-
*
|
|
77
|
-
* @param {object.<string, *>} metadata - JSON object originating from an API response.
|
|
78
|
-
* @returns {BaseEntity} Returns the object itself.
|
|
79
|
-
*/
|
|
80
|
-
setAll(metadata) {
|
|
81
|
-
for(let name in metadata) {
|
|
82
|
-
if (typeof this.apiToClientNames[name] === 'undefined') {
|
|
83
|
-
this.extra[name] = metadata[name];
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this[this.apiToClientNames[name]] = metadata[name];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
this.lastRefreshTime = Date.now();
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Returns the age of the data in seconds.
|
|
95
|
-
*
|
|
96
|
-
* @returns {number} Age of the data in seconds as integer.
|
|
97
|
-
*/
|
|
98
|
-
getDataAge() {
|
|
99
|
-
return (Date.now() - this.lastRefreshTime) / 1000;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Returns all data in the model.
|
|
104
|
-
*
|
|
105
|
-
* @returns {object.<string, *>}
|
|
106
|
-
*/
|
|
107
|
-
getAll() {
|
|
108
|
-
let obj = {};
|
|
109
|
-
for(let backend in this.apiToClientNames) {
|
|
110
|
-
let client = this.apiToClientNames[backend];
|
|
111
|
-
if (typeof this[client] !== 'undefined') {
|
|
112
|
-
obj[client] = this[client];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return Object.assign(obj, this.extra);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get a value from the additional data that is not part of the core model, i.e. from proprietary extensions.
|
|
120
|
-
*
|
|
121
|
-
* @param {string} name - Name of the property.
|
|
122
|
-
* @returns {*} The value, which could be of any type.
|
|
123
|
-
*/
|
|
124
|
-
get(name) {
|
|
125
|
-
return typeof this.extra[name] !== 'undefined' ? this.extra[name] : null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Converts the object to a valid objects for API requests.
|
|
130
|
-
*
|
|
131
|
-
* @param {object.<string, *>} parameters
|
|
132
|
-
* @returns {object.<string, *>}
|
|
133
|
-
* @protected
|
|
134
|
-
*/
|
|
135
|
-
_convertToRequest(parameters) {
|
|
136
|
-
let request = {};
|
|
137
|
-
for(let key in parameters) {
|
|
138
|
-
if (typeof this.clientToApiNames[key] === 'undefined') {
|
|
139
|
-
request[key] = parameters[key];
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
request[this.clientToApiNames[key]] = parameters[key];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return request;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Checks whether a features is supported by the API.
|
|
150
|
-
*
|
|
151
|
-
* @param {string} feature
|
|
152
|
-
* @returns {boolean}
|
|
153
|
-
* @protected
|
|
154
|
-
* @see Capabilities#hasFeature
|
|
155
|
-
*/
|
|
156
|
-
_supports(feature) {
|
|
157
|
-
return this.connection.capabilities().hasFeature(feature);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
module.exports = BaseEntity;
|
|
1
|
+
/**
|
|
2
|
+
* The base class for entities such as Job, Process Graph, Service etc.
|
|
3
|
+
*
|
|
4
|
+
* @abstract
|
|
5
|
+
*/
|
|
6
|
+
class BaseEntity {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of this object.
|
|
10
|
+
*
|
|
11
|
+
* @param {Connection} connection - A Connection object representing an established connection to an openEO back-end.
|
|
12
|
+
* @param {Array.<string|Array.<string>>} properties - A mapping from the API property names to the JS client property names (usually to convert between snake_case and camelCase), e.g. `["id", "title", ["process_graph", "processGraph"]]`
|
|
13
|
+
*/
|
|
14
|
+
constructor(connection, properties = []) {
|
|
15
|
+
/**
|
|
16
|
+
* @protected
|
|
17
|
+
* @type {Connection}
|
|
18
|
+
*/
|
|
19
|
+
this.connection = connection;
|
|
20
|
+
/**
|
|
21
|
+
* @protected
|
|
22
|
+
* @type {object.<string, string>}
|
|
23
|
+
*/
|
|
24
|
+
this.apiToClientNames = {};
|
|
25
|
+
/**
|
|
26
|
+
* @protected
|
|
27
|
+
* @type {object.<string, string>}
|
|
28
|
+
*/
|
|
29
|
+
this.clientToApiNames = {};
|
|
30
|
+
/**
|
|
31
|
+
* @protected
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
this.lastRefreshTime = 0;
|
|
35
|
+
/**
|
|
36
|
+
* Additional (non-standardized) properties received from the API.
|
|
37
|
+
*
|
|
38
|
+
* @protected
|
|
39
|
+
* @type {object.<string, *>}
|
|
40
|
+
*/
|
|
41
|
+
this.extra = {};
|
|
42
|
+
|
|
43
|
+
for(let i in properties) {
|
|
44
|
+
let backend, client;
|
|
45
|
+
if (Array.isArray(properties[i])) {
|
|
46
|
+
backend = properties[i][0];
|
|
47
|
+
client = properties[i][1];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
backend = properties[i];
|
|
51
|
+
client = properties[i];
|
|
52
|
+
}
|
|
53
|
+
this.apiToClientNames[backend] = client;
|
|
54
|
+
this.clientToApiNames[client] = backend;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns a JSON serializable representation of the data that is API compliant.
|
|
60
|
+
*
|
|
61
|
+
* @returns {object.<string, *>}
|
|
62
|
+
*/
|
|
63
|
+
toJSON() {
|
|
64
|
+
let obj = {};
|
|
65
|
+
for(let key in this.clientToApiNames) {
|
|
66
|
+
let apiKey = this.clientToApiNames[key];
|
|
67
|
+
if (typeof this[key] !== 'undefined') {
|
|
68
|
+
obj[apiKey] = this[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Object.assign(obj, this.extra);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Converts the data from an API response into data suitable for our JS client models.
|
|
76
|
+
*
|
|
77
|
+
* @param {object.<string, *>} metadata - JSON object originating from an API response.
|
|
78
|
+
* @returns {BaseEntity} Returns the object itself.
|
|
79
|
+
*/
|
|
80
|
+
setAll(metadata) {
|
|
81
|
+
for(let name in metadata) {
|
|
82
|
+
if (typeof this.apiToClientNames[name] === 'undefined') {
|
|
83
|
+
this.extra[name] = metadata[name];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this[this.apiToClientNames[name]] = metadata[name];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
this.lastRefreshTime = Date.now();
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Returns the age of the data in seconds.
|
|
95
|
+
*
|
|
96
|
+
* @returns {number} Age of the data in seconds as integer.
|
|
97
|
+
*/
|
|
98
|
+
getDataAge() {
|
|
99
|
+
return (Date.now() - this.lastRefreshTime) / 1000;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns all data in the model.
|
|
104
|
+
*
|
|
105
|
+
* @returns {object.<string, *>}
|
|
106
|
+
*/
|
|
107
|
+
getAll() {
|
|
108
|
+
let obj = {};
|
|
109
|
+
for(let backend in this.apiToClientNames) {
|
|
110
|
+
let client = this.apiToClientNames[backend];
|
|
111
|
+
if (typeof this[client] !== 'undefined') {
|
|
112
|
+
obj[client] = this[client];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return Object.assign(obj, this.extra);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get a value from the additional data that is not part of the core model, i.e. from proprietary extensions.
|
|
120
|
+
*
|
|
121
|
+
* @param {string} name - Name of the property.
|
|
122
|
+
* @returns {*} The value, which could be of any type.
|
|
123
|
+
*/
|
|
124
|
+
get(name) {
|
|
125
|
+
return typeof this.extra[name] !== 'undefined' ? this.extra[name] : null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Converts the object to a valid objects for API requests.
|
|
130
|
+
*
|
|
131
|
+
* @param {object.<string, *>} parameters
|
|
132
|
+
* @returns {object.<string, *>}
|
|
133
|
+
* @protected
|
|
134
|
+
*/
|
|
135
|
+
_convertToRequest(parameters) {
|
|
136
|
+
let request = {};
|
|
137
|
+
for(let key in parameters) {
|
|
138
|
+
if (typeof this.clientToApiNames[key] === 'undefined') {
|
|
139
|
+
request[key] = parameters[key];
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
request[this.clientToApiNames[key]] = parameters[key];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return request;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Checks whether a features is supported by the API.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} feature
|
|
152
|
+
* @returns {boolean}
|
|
153
|
+
* @protected
|
|
154
|
+
* @see Capabilities#hasFeature
|
|
155
|
+
*/
|
|
156
|
+
_supports(feature) {
|
|
157
|
+
return this.connection.capabilities().hasFeature(feature);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = BaseEntity;
|