OpenEO JS Client

website·Indexed 29 days ago

https://open-eo.github.io/openeo-js-client/latest/

A JavaScript client for interacting with OpenEO environments. It provides tools for managing authentication via OIDC and Basic providers, constructing process trees with a Builder, monitoring job execution, and handling user files and services. The client includes support for STAC 1.0.0 compatibility and utilities for paginating through collections.

Tokens
31.5K
Snippets
239
Records
310
Agent score
70%

What's inside OpenEO JS Client

  1. Use OidcProvider for OpenID Connect authentication

    The OidcProvider class is the authentication provider for OpenID Connect. It supports three grant types: authorization_code+pkce (default), implicit, and client_credentials. While authorization_code+pkce and implicit are intended for browser environments, client_credentials is supported in all environments. If implementing OIDC in a non-browser environment, you can override OidcProvider or AuthProvider and provide a custom factory via Connection.setOidcProviderFactory().
  2. Manage user-defined processes and jobs

    The Connection class provides methods to retrieve detailed information about user-specific resources:

    • getUserProcess(id): Gets information about a user-defined process.
    • getJob(id): Gets information about a batch job.
    • getService(id): Gets information about a secondary web service.
  3. Manage federation back-end information

    The Capabilities class provides methods to retrieve information about other back-ends in a federation, converting the API's federation object into a list of FederationBackend objects.
    // List all back-ends in the federation
    const allBackends = capabilities.listFederation();
    
    // Get details for a specific back-end by ID
    const backend = capabilities.getFederationBackend('backend-id');
    
    // Get details for multiple back-ends
    const backends = capabilities.getFederationBackends(['id1', 'id2']);
  4. Manage stored user-defined processes

    The client provides methods to create, retrieve, and list stored processes on the back-end:

    • setUserProcess(id, process): Creates or replaces a stored process with the given ID.
    • getUserProcess(id): Retrieves all information about a stored process by its ID.
    • listUserProcesses(oldProcesses): Returns a list of all user-defined processes.
    • paginateUserProcesses(limit): Returns a ProcessPages object to paginate through stored processes (default limit is 50).
    // Store a process
    await connection.setUserProcess('my-process-id', processGraph);
    
    // Retrieve a process
    const process = await connection.getUserProcess('my-process-id');
    
    // List all processes
    const processes = await connection.listUserProcesses();
  5. AuthProviderMeta type definition

    The AuthProviderMeta object contains details about an authentication provider:

    • id (string, nullable): Provider identifier; may not be used for all authentication methods.
    • title (string): Title of the authentication method.
    • description (string): Description of the authentication method.
  6. Use the Node.js Environment class for openEO JS Client

    The Environment class provides Node.js-specific implementations for the openEO JS Client. It handles platform-dependent tasks such as reading/writing files via streams, Base64 encoding, and managing the server instance URL. This class is intended specifically for Node.js environments and should not be used in browsers.
  7. Manage stored process graphs with the UserProcess class

    The UserProcess class represents a process graph stored on an openEO back-end. It allows developers to retrieve metadata, update the process graph definition, or delete it from the server. A UserProcess instance is initialized with a connection to the back-end and the unique identifier of the stored process.
    const UserProcess = require('./userprocess');
    const userProcess = new UserProcess(connection, 'process-id');
  8. Understand UserAccount and UserAccountStorage types

    The UserAccount object provides details about the authenticated user, including their ID, name, budget, and storage capacity. Storage details are nested within the UserAccountStorage object, which tracks free space and total quota in bytes.
    interface UserAccountStorage {
      free: number;  // bytes as integer
      quota: number; // bytes as integer
    }
    
    interface UserAccount {
      user_id: string;
      name: string | null;
      default_plan: string | null;
      storage: UserAccountStorage | null;
      budget: number | null;
      links: Array<Link> | null;
    }
  9. Manage files in the user workspace with UserFile

    The UserFile class represents a file in the openEO user workspace. It provides methods to upload, download, retrieve, and delete files. The class tracks the file's path (relative to the user directory), size (in bytes), and modified date (RFC 3339 format).
    const UserFile = require('./userfile');
    // constructor: new UserFile(connection, path)
  10. Use the Browser Environment class for openEO JS Client

    The Environment class provides browser-specific utilities for the openEO JS Client. It should only be used in browser environments. It handles platform-specific tasks such as retrieving the current window URL, encoding strings to Base64, and managing binary response types.
    // Example of accessing environment name
    const name = Environment.getName(); // Returns 'Browser'
  11. Retrieve back-end version and metadata

    Use the following methods on a Capabilities instance to get metadata about the openEO back-end:

    • apiVersion(): Returns the openEO API version implemented by the back-end.
    • backendVersion(): Returns the back-end version number.
    • title(): Returns the back-end title.
    • description(): Returns the back-end description.
    • isStable(): Returns true if the back-end is suitable for production, otherwise false.