0.1.6 • Published 23 days ago

@elodigit/client v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
23 days ago

Features

  • ✅ Typescript support

  • ✅ Node.js and browser support

  • ✅ Easy to use and setup with npm

  • ✅ All enpoints available

  • ✅ Reuse of existing browser sessions

  • ✅ Async/await support

Installation

npm install @elodigit/client

Usage

Import and initialize a client using ELO login credentials.

import { Client } from "@elodigit/client";

// Initializing a client
const client = new Client({
  IX_URL: "http://playground.com/ix-Solutions",
  USERNAME: "Administrator",
  PASSWORD: "elo",
});
await client.connect();

OR reuse an existing ELO session (only available in browsers for e.g. web apps)

const client = new Client({
  IX_URL: "http://playground.com/ix-Solutions",
  USE_SESSION: true,
  REDIRECT: true,
});
await client.connect();

Make a request to any ELO API service/endpoint.

See the complete list of endpoints in the IX API Documentation

const response = await client.ix.checkoutSord({
  objId: "1",
  editInfoZ: EditInfoC.mbSord,
  lockZ: LockC.NO,
});

const sord = response.result?.sord;

Each method returns a Promise which resolves the response.

console.log(response);
{
  result: {
    sord: {
      TStamp: "2023.02.24.10.48.35",
      acl: "75PYJA",
      childCount: 0,
      doc: 33,
      guid: "(804CE708-8221-716F-7452-4FA201E7F858)",
      id: 1,
      kind: 1,
      mask: 0,
      name: "Solutions",
      ownerId: 0,
      parentId: 1,
      ...
    }
  }
}

Client options

The Client supports the following options on initialization. These options are all keys in the single constructor parameter.

OptionDefault valueTypeRequiredDescription
IX_URLundefinedstringtrueUrl to the IX service for connection e.g. https://playground.com/ix-Solutions
USERNAMEundefinedstring | ResolverfalseELO username for basic authentication. This authentication method is discouraged in the browser because there is no CSRF protection.
PASSWORDundefinedstring | ResolverfalseELO password for basic authentication
TIMEOUT10000numberfalseConnection timeout to ELO server in ms.
USE_SESSIONfalsebooleanfalseReuses an existing session that's provided by e.g. the Java Client, Web Client, Mobile Client. This option is only available in browsers (e.g. for web apps)
REDIRECTtruebooleanfalseRedirects to the login page if session expires. Works only in combination with USE_SESSION
KEEP_ALIVEtruebooleanfalseTries to keep the session alive by pinging the server every 60 seconds. Works only in combination with USE_SESSION or SESSION_TICKET
CLIENT_INFOlanguage=en country=US timezone=UTCClientInfo | ResolverfalseThe ClientInfo object containing the users language and country
ELO_APPROVEDundefinedstring | ResolverfalseCSRF token to send approved REST requests
WITH_CREDENTIALStruebooleanfalseOption is used to include cookies in the request. Required for option USE_SESSION
SESSION_TICKETundefinedstring | ResolverfalseSession ticket that is used as Bearer-Header for authentication
HEADERSundefinedHeaders | ResolverfalseAdditional custom headers for request

Resolver are async functions that can be passed instead of static values to the client. They provide the ability of resolving values at runtime.

async (options: ApiRequestOptions, config: OpenAPIConfig) => {
  return "Administrator";
};

Enable CORS

To enabled CORS add the "Access-Control-Allow-*" headers as entries in the Indexserver config.xml. At least "Access-Control-Allow-Origin" is requried. Example:

<entry key="Access-Control-Allow-Origin">*</entry>

TypeScript

This package contains type definitions for all request parameters and responses.

Constants

All ELO constants are available for e.g. endpoint requests. LockC.NO, SordC.mbAllIndex, etc.

0.1.6

23 days ago

0.1.5

30 days ago

0.1.0

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.4

1 month ago

0.1.3

1 month ago

1.0.0

5 months ago