@obelisk/client
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
import { Observable } from 'rxjs'; | ||
import { AjaxResponse } from 'rxjs/ajax'; | ||
import { IotClient } from '../iot-client'; | ||
import { ObeliskClient } from '../obelisk-client'; | ||
/** | ||
@@ -19,3 +19,3 @@ * Endpoint class represents an IoT-stack API Endpoint. | ||
*/ | ||
static create(client: IotClient, uri: string): Endpoint; | ||
static create(client: ObeliskClient, uri: string): Endpoint; | ||
private constructor(); | ||
@@ -22,0 +22,0 @@ /** |
import { Observable } from 'rxjs'; | ||
import { TPage } from '.'; | ||
import { IotClient } from '../iot-client'; | ||
import { ObeliskClient } from '../obelisk-client'; | ||
/** | ||
@@ -20,3 +20,3 @@ * Endpoint class represents an IoT-stack API Endpoint. | ||
*/ | ||
static create(client: IotClient, uri: string): StreamEndpoint; | ||
static create(client: ObeliskClient, uri: string): StreamEndpoint; | ||
private constructor(); | ||
@@ -23,0 +23,0 @@ /** |
import { Observable } from 'rxjs'; | ||
import { TPageResponse } from '.'; | ||
import { IotClient } from '../iot-client'; | ||
import { ObeliskClient } from '../obelisk-client'; | ||
/** | ||
@@ -19,3 +19,3 @@ * Endpoint class represents an IoT-stack API Endpoint. | ||
*/ | ||
static create(client: IotClient, uri: string): TPageEndpoint; | ||
static create(client: ObeliskClient, uri: string): TPageEndpoint; | ||
private constructor(); | ||
@@ -22,0 +22,0 @@ private get; |
export * from './api'; | ||
export * from './auth'; | ||
export * from './interfaces'; | ||
export * from './iot-client'; | ||
export * from './obelisk-client'; | ||
export * from './util/config'; |
@@ -9,3 +9,3 @@ "use strict"; | ||
__export(require("./interfaces")); | ||
__export(require("./iot-client")); | ||
__export(require("./obelisk-client")); | ||
__export(require("./util/config")); |
@@ -86,3 +86,3 @@ import { Observable } from "rxjs"; | ||
/** | ||
* General configuration properties needed for IotClient setup and Keycloak instance setup. | ||
* General configuration properties needed for ObeliskClient setup and Keycloak instance setup. | ||
*/ | ||
@@ -89,0 +89,0 @@ export interface ClientOptions { |
import { Observable, OperatorFunction } from "rxjs"; | ||
import { AjaxRequest, AjaxResponse } from "rxjs/ajax"; | ||
import { TPageResponse, Link } from "../api"; | ||
import { IotClient } from "../iot-client"; | ||
import { ObeliskClient } from "../obelisk-client"; | ||
/** | ||
* @hidden | ||
* @hiddens | ||
*/ | ||
@@ -11,3 +11,3 @@ export declare class InternalUtils { | ||
static mapAjaxResponse2TPageResponse(resp: AjaxResponse, index: number): TPageResponse; | ||
static token2header(client: IotClient, cfg: AjaxRequest): AjaxRequest; | ||
static token2header(client: ObeliskClient, cfg: AjaxRequest): AjaxRequest; | ||
static parseLinkHeader(linkHeaderValue: string): Link; | ||
@@ -24,12 +24,12 @@ /** | ||
*/ | ||
static norm(client: IotClient, uri: string): string; | ||
static isTPageCompatible(client: IotClient, uri: string): boolean; | ||
static isStreamEndpointCompatible(client: IotClient, uri: string): boolean; | ||
static norm(client: ObeliskClient, uri: string): string; | ||
static isTPageCompatible(client: ObeliskClient, uri: string): boolean; | ||
static isStreamEndpointCompatible(client: ObeliskClient, uri: string): boolean; | ||
/** | ||
* Catches the first 40x error, on 401, will redirect once and try to get a new token (refreshing too), | ||
* then retry the caught observable or request. If that doesn't work, the error is thrown anyway. | ||
* @param client IotClient to get token from | ||
* @param client ObeliskClient to get token from | ||
* @param request Optional AjaxRequest to retry instead of caught Observable | ||
*/ | ||
static catch40xAndRetry<T>(client: IotClient, request?: AjaxRequest): OperatorFunction<T, T>; | ||
static catch40xAndRetry<T>(client: ObeliskClient, request?: AjaxRequest): OperatorFunction<T, T>; | ||
/** | ||
@@ -47,3 +47,3 @@ * Catches a 504 client and retries the original observable. | ||
*/ | ||
static authRequest(client: IotClient, request: AjaxRequest): Observable<AjaxResponse>; | ||
static authRequest(client: ObeliskClient, request: AjaxRequest): Observable<AjaxResponse>; | ||
/** | ||
@@ -50,0 +50,0 @@ * First authenticates and gets a new PAT token, then requests a new RPT token, then retries. |
@@ -9,3 +9,3 @@ "use strict"; | ||
/** | ||
* @hidden | ||
* @hiddens | ||
*/ | ||
@@ -102,3 +102,3 @@ class InternalUtils { | ||
* then retry the caught observable or request. If that doesn't work, the error is thrown anyway. | ||
* @param client IotClient to get token from | ||
* @param client ObeliskClient to get token from | ||
* @param request Optional AjaxRequest to retry instead of caught Observable | ||
@@ -105,0 +105,0 @@ */ |
{ | ||
"name": "@obelisk/client", | ||
"version": "2.0.0-alpha.2", | ||
"description": "Typescript client to interact with Obelisk on a higher level than with regular ReST API calls.", | ||
"version": "2.0.0-alpha.3", | ||
"description": "Typescript client to interact with Obelisk on a higher level than the regular ReST API calls.", | ||
"keywords": [ | ||
@@ -36,3 +36,3 @@ "obelisk", | ||
"ts-jest": "^22.4.6", | ||
"typedoc": "^0.11.1", | ||
"typedoc": "^0.14.2", | ||
"typescript": "^3.3.1" | ||
@@ -39,0 +39,0 @@ }, |
# Obelisk Client | ||
[![pipeline status](https://gitlab.ilabt.imec.be/ibcndevs/iot-stack/obelisk-client/badges/master/pipeline.svg)](https://gitlab.ilabt.imec.be/ibcndevs/iot-stack/iot-stack-client/commits/master) | ||
A client library written in Typescript to interact with [Obelisk](https://obelisk.ilabt.imec.be). | ||
A client library written in Typescript to interact with Obelisk. Link back to the **full documentation** [here][full-docs]. | ||
## Prerequisites | ||
@@ -12,16 +10,6 @@ This library makes use of **RxJS** (Reactive Extensions for JavaScript). | ||
## Overview | ||
** This client library only works for web applications that connect on behalf of users. It is meant for the browser, so node-js servers cannot use this. _(For those use cases, please refer to the HTTP ReST API documented on [Obelisk](https://obelisk.ilabt.imec.be))_** | ||
The client has a clear purpose: | ||
* Make it easier to do follow up requests on Temporal Pages (see [IoT-stack documentation](https://idlab.tengu.io)). | ||
* Do the heavy lifting on authentication and authorization | ||
The client helps to make authorized calls to the API. With the client you create *Endpoints*. These endpoints can be acted on with methods like `execute()` or `get()`. An endpoint takes an API uri as argument. **This means that the [HTTP REST api](https://obelisk.ilabt.imec.be/api/v1/spec/swagger) is as important to you, as this API.** | ||
The client help with authorization to the Obelisk keycloak authorization Server. This should handle: | ||
* Logging in to a supported Identity Provider (eg. Google) | ||
* Getting the access token | ||
* Getting the RPT token | ||
* Refreshing tokens when needed | ||
* Login/logout support | ||
With the client you create *Endpoints*. These endpoints can be acted on with methods like `execute()` or `get()`. An endpoint takes an API uri as argument. This means that the HTTP REST api is as important to you, as this API. | ||
## Installation | ||
@@ -33,8 +21,7 @@ ```bash | ||
## Usage | ||
To start you need to create an IotClient instance with a proper options object. | ||
To start you need to create an ObeliskClient instance with a proper options object. | ||
```typescript | ||
import { ClientOptions, IotClient } from '@obelisk/client'; | ||
import { ClientOptions, ObeliskClient } from '@obelisk/client'; | ||
// Create shareable observable. (caches the client object) | ||
const options: ClientOptions = { | ||
@@ -46,3 +33,3 @@ host: 'https://obelisk.ilabt.imec.be', | ||
} | ||
let client = new IotClient(options); | ||
let client = new ObeliskClient(options); | ||
``` | ||
@@ -62,3 +49,2 @@ | ||
[full-docs]: https://obelisk.ilabt.imec.be/api/v1/client-docs | ||
@@ -68,1 +54,5 @@ ## Angular | ||
There is an optional angular package to use in conjunction with the client packages. More information can be found at [@obelisk/ngx](https://www.npmjs.com/package/@obelisk/ngx). | ||
## Further documentation | ||
The generated @obelisk/client api can be found [here](https://obelisk.ilabt.imec.be/api/v1/client-docs) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99060
50
2549
53