2.0.3 • Published 2 years ago

@hiro-ui/sdk v2.0.3

Weekly downloads
567
License
MIT
Repository
github
Last release
2 years ago

HIRO SDK for HIRO 7.x

Available Functions

initSdk

Initializes the SDK and provides config details from HIRO Desktop. initSdk also provides a ready callback and a state object.

const config = {}; // Optional default config

initSdk(config).then(
  ({
    config: { } // Config values provided by SDK
    ready, // Callback, once your application is ready
    state, // Stored application state
  }: InitSdkResult) => {
      // SDK is initialized and ready to use
  }
);

close

Closes the application within HIRO Desktop

close();

unauthorized

Callback to SDK for unauthorized Token

unauthorized();

saveState

Sync application state back to HIRO Desktop

const state = {}; // Application state object
saveState(state);

runApp

Open a different application, with parameters, from within your application.

const appParameters = {}; // Parameters for the new application
runApp(appId, appParameters);

Available TypeScript Interfaces

SdkConfig TypeScript Interface

interface SdkConfig {
  authUrl?: string;
  graphUrl?: string;
  redirectUrl?: string;
  clientId?: string;
  roles?: string[];
}

LoadedConfig TypeScript Interface

interface LoadedConfig {
  graphUrl?: string;
  token?: string;
}

DesktopUser TypeScript Interface

interface DesktopUser {
  _id: string;
  accountId: string;
  email: string;
  id: string;
  name: string;
  roles: string[];
}

DesktopConfig TypeScript Interface

interface DesktopConfig {
  user: DesktopUser;
  org: {
    id: string;
    name: string;
  };
  token: string;
  graphUrl: string;
  shared: {
    [key: string]: any;
  };
  options?: {
    [key: string]: any;
  };
}

InitSdkResult TypeScript Interface

InitSdkResult TypeScript Interface

interface InitSdkResult<S = {}> {
  ready: () => void;
  state: S;
  config: DesktopConfig;
}

Example Usage in React

import React from 'react';
import ReactDOM from 'react-dom';

import YourReactApp from './YourReactApp';

import {
  SdkConfig, // SdkConfig TypeScript Interface
  InitSdkResult, // InitSdkResult TypeScript Interface
  initSdk, // Initializes the SDK
  unauthorized, // Callback to SDK for unauthorized Token
} from '@hiro-ui/sdk';

import Client, { Token } from '@hiro-graph/client';

// Default config for Development
const config: SdkConfig = {
  clientId: process.env.HIRO_CLIENT_ID,
  graphUrl: process.env.HIRO_GRAPH_URL,
  authUrl: process.env.HIRO_AUTH_URL,
  redirectUrl: process.env.HIRO_REDIRECT_URL,
  scopeId: process.env.HIRO_SCOPE_ID,
};

// Initializes the SDK with Default config
initSdk(config).then(
  ({
    config: { user, graphUrl, token, shared, scopeId, options },
    ready, // Callback, once your application is ready
    state, // Stored application state
  }: InitSdkResult) => {
    // SDK is initialized and ready to use

    const myToken = new Token({
      onInvalidate: () => {
        // Handle unauthorized Token
        unauthorized();
        return Promise.resolve();
      },
      getToken: () => Promise.resolve(token),
    });

    // Get Graph Client with SKD Configs
    const graphClient = new Client({
      endpoint: graphUrl,
      token: myToken,
    });

    ReactDOM.render(
      <YourReactApp />,
      document.getElementById('app'),
      ready, //ready callback for SDK
    );
  },
);
2.0.3

2 years ago

2.0.2

2 years ago

2.0.0

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.26-alpha.12

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22-audit.0

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21-alpha.0

3 years ago

1.0.21-alpha.1

3 years ago

1.0.21

3 years ago

1.0.18-alpha.54

3 years ago

1.0.20

3 years ago

1.0.20-audit.4

3 years ago

1.0.19

3 years ago

1.0.19-audit.8

3 years ago

1.0.19-audit.7

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.12-audit.97

3 years ago

1.0.16-alpha.9

3 years ago

1.0.16

3 years ago

1.1.0-alpha.6

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.12-alpha.94

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11-alpha.12

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.10

4 years ago

1.0.8-alpha.8

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-rc.25

4 years ago

1.0.0-rc.24

4 years ago

1.0.0-rc.23

4 years ago

1.0.0-rc.22

5 years ago

1.0.0-rc.21

5 years ago

1.0.0-rc.20

5 years ago

1.0.0-rc.19

5 years ago

1.0.0-rc.16

5 years ago

1.0.0-rc.15

5 years ago

1.0.0-rc.14

5 years ago

1.0.0-rc.13

5 years ago

1.0.0-rc.12

5 years ago

1.0.0-rc.11

5 years ago

1.0.0-rc.10

5 years ago

1.0.0-rc.9

5 years ago

1.0.0-rc.8

5 years ago

1.0.0-rc7

5 years ago

1.0.0-rc6

5 years ago

1.0.0-rc5

5 years ago

1.0.0-rc4

5 years ago

1.0.0-rc3

5 years ago

1.0.0-rc2

5 years ago

1.0.0-rc1

5 years ago