Skip to content

Commit 7f32937

Browse files
Never return "null" in getFederationBackend(s)
see #69 (comment)
1 parent 303d3a6 commit 7f32937

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

openeo.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,19 @@ declare module OpenEO {
410410
*/
411411
listFederation(): Array<FederationBackend>;
412412
/**
413-
* Given just the string ID of a backend within the federation, returns that backend's full details as a FederationBackend object
413+
* Given just the string ID of a backend within the federation, returns that backend's full details as a FederationBackend object.
414414
*
415415
* @param {string} backendId - The ID of a backend within the federation
416-
* @returns {FederationBackend} The full details of the backend, or `null` if no backend with the given ID exists
416+
* @returns {FederationBackend} The full details of the backend
417417
*/
418-
getFederationBackend(backendId: string): FederationBackend | null;
418+
getFederationBackend(backendId: string): FederationBackend;
419419
/**
420-
* Given a list of string IDs of backends within the federation, returns those backends' full details as FederationBackend objects
420+
* Given a list of string IDs of backends within the federation, returns those backends' full details as FederationBackend objects.
421421
*
422422
* @param {Array<string>} backendIds - The IDs of backends within the federation
423-
* @returns {Array<FederationBackend>} An array in the same order as the input, containing for each position either the full details of the backend, or `null` if no backend with the given ID exists
423+
* @returns {Array<FederationBackend>} An array in the same order as the input, containing for each position the full details of the backend
424424
*/
425-
getFederationBackends(backendIds: Array<string>): Array<FederationBackend | null>;
425+
getFederationBackends(backendIds: Array<string>): Array<FederationBackend>;
426426
/**
427427
* Lists all supported features.
428428
*

src/capabilities.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,22 @@ class Capabilities {
210210
}
211211

212212
/**
213-
* Given just the string ID of a backend within the federation, returns that backend's full details as a FederationBackend object
213+
* Given just the string ID of a backend within the federation, returns that backend's full details as a FederationBackend object.
214214
*
215215
* @param {string} backendId - The ID of a backend within the federation
216-
* @returns {FederationBackend | null} The full details of the backend, or `null` if no backend with the given ID exists
216+
* @returns {FederationBackend} The full details of the backend
217217
*/
218218
getFederationBackend(backendId) {
219-
// Add `id` property to make it a proper FederationBackend object, but check for null case beforehand
220-
return this.data.federation[backendId] ? { id: backendId, ...this.data.federation[backendId] } : null;
219+
// Add `id` property to make it a proper FederationBackend object
220+
// If backendId doesn't exist in this.data.federation, will contain just the `id` field (intended behaviour)
221+
return { id: backendId, ...this.data.federation[backendId] }
221222
}
222223

223224
/**
224-
* Given a list of string IDs of backends within the federation, returns those backends' full details as FederationBackend objects
225+
* Given a list of string IDs of backends within the federation, returns those backends' full details as FederationBackend objects.
225226
*
226227
* @param {Array<string>} backendIds - The IDs of backends within the federation
227-
* @returns {Array<FederationBackend | null>} An array in the same order as the input, containing for each position either the full details of the backend, or `null` if no backend with the given ID exists
228+
* @returns {Array<FederationBackend>} An array in the same order as the input, containing for each position the full details of the backend
228229
*/
229230
getFederationBackends(backendIds) {
230231
// Let 'single case' function do the work, but pass `this` so that `this.data.federation` can be accessed in the callback context

0 commit comments

Comments
 (0)