Skip to content

Commit

Permalink
OGC API draft
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Oct 24, 2024
1 parent 30cd63c commit 107c874
Show file tree
Hide file tree
Showing 43 changed files with 836 additions and 672 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ node_modules/

# Build related
/report.html
/openeo.js
/openeo.min.js
/openeo.node.js
/openeo.node.min.js
/client.js
/client.min.js
/client.node.js
/client.node.min.js

# Reports
coverage/
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Class `OpenEO` renamed to `Client` (i.e. use `Client.connect` instead of `OpenEO.connect`)
- Moved `makeLinksAbsolute` and `getLinKHref` to `Utils` class

## [2.6.0] - 2024-07-11

### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To use it in a browser environment simply add the following code to your HTML fi
<script src="https://cdn.jsdelivr.net/npm/axios@0.21/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/oidc-client@1/dist/oidc-client.min.js"></script> <!-- Only required if you'd like to enable authentication via OpenID Connect -->
<script src="https://cdn.jsdelivr.net/npm/multihashes@3/src/index.min.js"></script> <!-- Only required if you have checksums in the STAC metadata -->
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@3/client.min.js"></script>
```

### NodeJS
Expand All @@ -30,7 +30,7 @@ To install it in a NodeJS environment run:
`npm install @openeo/js-client`

Afterwards, you can import the package:
`const { OpenEO } = require('@openeo/js-client');`
`const { Client } = require('@openeo/js-client');`

### TypeScript

Expand All @@ -40,7 +40,7 @@ To install it in a TypeScript environment run:
`npm install @openeo/js-client`

Afterwards, you can import the package:
`import { OpenEO } from '@openeo/js-client';`
`import { Client } from '@openeo/js-client';`

### Examples

Expand All @@ -63,7 +63,7 @@ More information can be found in the [documentation](https://open-eo.github.io/o
Always make sure to adapt changes in the *.js files to the openeo.d.ts file.
If changes are larger you may want to run `npm run tsd` and regenerate the declaration file and cherry-pick your changes from there.

Generate a build: `npm run build` (generates `openeo.js` and `openeo.min.js`)
Generate a build: `npm run build` (generates `client.js` and `client.min.js`)

Generate the documentation to the `docs/` folder: `npm run docs`

Expand Down
6 changes: 3 additions & 3 deletions examples/node/discovery.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Import the JS client
const { OpenEO } = require('@openeo/js-client');
const { Client } = require('@openeo/js-client');

const url = "https://earthengine.openeo.org"; // Insert the openEO server URL here
let connection = null;

console.log('URL: ' + url);
console.log('Client Version: ' + OpenEO.clientVersion());
console.log('Client Version: ' + Client.clientVersion());

OpenEO.connect(url)
Client.connect(url)
.then(c => {
connection = c;
return connection.capabilities();
Expand Down
4 changes: 2 additions & 2 deletions examples/oidc/openid-connect-popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/axios@1/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/oidc-client@1/dist/oidc-client.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/client.min.js"></script>
<script type="text/javascript">
const BACKEND = "https://example.openeo.org"; // TODO: Set the back-end to authenticate against
const CLIENT_ID = ""; // TODO: Set the client id
Expand All @@ -22,7 +22,7 @@

try {
// Connect to the back-end
con = await OpenEO.connect(BACKEND);
con = await Client.connect(BACKEND);

// Show whether OIDC is supported by the back-end
var capabilities = con.capabilities();
Expand Down
4 changes: 2 additions & 2 deletions examples/oidc/openid-connect-redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/axios@1/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/oidc-client@1/dist/oidc-client.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/client.min.js"></script>
<script type="text/javascript">
const BACKEND = "https://example.openeo.org"; // TODO: Set the back-end to authenticate against
const CLIENT_ID = ""; // TODO: Set the client id
Expand All @@ -20,7 +20,7 @@

try {
// Connect to the back-end
con = await OpenEO.connect(BACKEND);
con = await Client.connect(BACKEND);

// Show whether OIDC is supported by the back-end
var capabilities = con.capabilities();
Expand Down
8 changes: 4 additions & 4 deletions examples/typescript/discovery.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// import the JS client main part (OpenEO) for the actual functionality
// import the JS client main part (Client) for the actual functionality
// and some classes (Connection, Capabilities) and types (Collections, Processes) for TypeScript stuff
import { OpenEO, Connection, Capabilities, Collections, Processes } from '@openeo/js-client';
import { Client, Connection, Capabilities, Collections, Processes } from '@openeo/js-client';

let url: string = "https://earthengine.openeo.org"; // Insert the openEO server URL here
let connection: Connection = null; // Reserve a variable for the connection and specify its type

console.log('URL: ' + url);
console.log('Client Version: ' + OpenEO.clientVersion());
console.log('Client Version: ' + Client.clientVersion());

OpenEO.connect(url)
Client.connect(url)
.then((c: Connection): Capabilities => { // specify parameter type and return type
connection = c;
return connection.capabilities();
Expand Down
6 changes: 3 additions & 3 deletions examples/web/discovery.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/axios@1/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@3/client.min.js"></script>
<script type="text/javascript">
var url = "https://earthengine.openeo.org"; // Insert the openEO server URL here
var connection = null;

window.onload = function () {
document.getElementById('url').innerText = url;
document.getElementById('clientVersion').innerText = OpenEO.clientVersion();
document.getElementById('clientVersion').innerText = Client.clientVersion();

OpenEO.connect(url)
Client.connect(url)
.then(c => {
connection = c;
return connection.capabilities();
Expand Down
6 changes: 3 additions & 3 deletions examples/web/workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/axios@1/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@3/client.min.js"></script>
<script type="text/javascript">
async function run() {
// Show the client version
log("Client Version: " + OpenEO.clientVersion());
log("Client Version: " + Client.clientVersion());

try {
// Connect to the back-end
var con = await OpenEO.connect("https://earthengine.openeo.org");
var con = await Client.connect("https://earthengine.openeo.org");

// Show implemented API version of the back-end
var capabilities = con.capabilities();
Expand Down
45 changes: 5 additions & 40 deletions openeo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { User, UserManager } from 'oidc-client';
import { ProcessRegistry } from '@openeo/js-commons';
import { Readable } from 'stream';

declare module OpenEO {
declare module Client {
/**
* The base class for authentication providers such as Basic and OpenID Connect.
*
Expand Down Expand Up @@ -347,12 +347,6 @@ declare module OpenEO {
* @throws {Error}
*/
protected validate(): void;
/**
* Initializes the class.
*
* @protected
*/
protected init(): void;
/**
* Returns the capabilities response as a JSON serializable representation of the data that is API compliant.
*
Expand Down Expand Up @@ -1922,15 +1916,6 @@ declare module OpenEO {
* @type {ProcessRegistry}
*/
protected processes: ProcessRegistry;
/**
* Initializes the connection by requesting the capabilities.
*
* @async
* @protected
* @returns {Promise<Capabilities>} Capabilities
* @throws {Error}
*/
protected init(): Promise<Capabilities>;
/**
* Refresh the cache for processes.
*
Expand Down Expand Up @@ -2298,13 +2283,11 @@ declare module OpenEO {
*
* @async
* @param {Process} process - A user-defined process.
* @param {?string} [plan=null] - The billing plan to use for this computation.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this computation.
* @param {?AbortController} [abortController=null] - An AbortController object that can be used to cancel the processing request.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the batch job, e.g. `log_level`.
* @returns {Promise<SyncResult>} - An object with the data and some metadata.
*/
computeResult(process: Process, plan?: string | null, budget?: number | null, abortController?: AbortController | null, additional?: object<string, any>): Promise<SyncResult>;
computeResult(process: Process, abortController?: AbortController | null, additional?: object<string, any>): Promise<SyncResult>;
/**
* Executes a process synchronously and downloads to result the given path.
*
Expand Down Expand Up @@ -2401,24 +2384,6 @@ declare module OpenEO {
* @returns {ResponseArray}
*/
protected _toResponseArray(arr: Array<any>, response: object<string, any>): ResponseArray;
/**
* Get the a link with the given rel type.
*
* @protected
* @param {Array.<Link>} links - An array of links.
* @param {string|Array.<string>} rel - Relation type(s) to find.
* @returns {string | null}
* @throws {Error}
*/
protected _getLinkHref(links: Array<Link>, rel: string | Array<string>): string | null;
/**
* Makes all links in the list absolute.
*
* @param {Array.<Link>} links - An array of links.
* @param {?string|AxiosResponse} [base=null] - The base url to use for relative links, or an response to derive the url from.
* @returns {Array.<Link>}
*/
makeLinksAbsolute(links: Array<Link>, base?: (string | AxiosResponse) | null): Array<Link>;
/**
* Sends a GET request.
*
Expand Down Expand Up @@ -2538,7 +2503,7 @@ declare module OpenEO {
*
* @hideconstructor
*/
export class OpenEO {
export class Client {
/**
* Connect to a back-end with version discovery (recommended).
*
Expand Down Expand Up @@ -2575,7 +2540,7 @@ declare module OpenEO {
*/
static clientVersion(): string;
}
export namespace OpenEO {
export namespace Client {
const Environment: Environment;
}

Expand Down Expand Up @@ -2918,4 +2883,4 @@ declare module OpenEO {

}

export = OpenEO;
export = Client;
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openeo/js-client",
"version": "2.6.0",
"version": "3.0.0-alpha.1",
"author": "openEO Consortium",
"contributors": [
{
Expand All @@ -27,12 +27,12 @@
"type": "github",
"url": "https://github.com/sponsors/m-mohr"
},
"main": "src/openeo.js",
"types": "openeo.d.ts",
"main": "src/client.js",
"types": "client.d.ts",
"files": [
"openeo.js",
"openeo.d.ts",
"openeo.min.js",
"client.js",
"client.d.ts",
"client.min.js",
"src/*"
],
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/basicprovider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Environment = require('./env');
const Utils = require('@openeo/js-commons/src/utils');
const Utils = require('./utils');
const AuthProvider = require('./authprovider');

/**
Expand Down
2 changes: 1 addition & 1 deletion src/builder/builder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const BuilderNode = require('./node');
const Parameter = require('./parameter');
const axios = require('axios');
const Utils = require('@openeo/js-commons/src/utils');
const Utils = require('../utils');
const ProcessUtils = require("@openeo/js-commons/src/processUtils");
const ProcessRegistry = require('@openeo/js-commons/src/processRegistry');

Expand Down
2 changes: 1 addition & 1 deletion src/builder/node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Utils = require("@openeo/js-commons/src/utils");
const Utils = require("../utils");
const Parameter = require("./parameter");

/**
Expand Down
Loading

0 comments on commit 107c874

Please sign in to comment.