8.3.12 • Published 9 months ago

@hiro-ui/sdk v8.3.12

Weekly downloads
567
License
MIT
Repository
github
Last release
9 months 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
    );
  },
);
8.3.12

9 months ago

2.0.4

1 year ago

8.3.10

11 months ago

8.3.9-pre3

11 months ago

8.3.11

10 months ago

8.3.9-pre1

11 months ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.0

3 years ago

1.2.5

3 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.26-alpha.12

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22-audit.0

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21-alpha.0

4 years ago

1.0.21-alpha.1

4 years ago

1.0.21

4 years ago

1.0.18-alpha.54

4 years ago

1.0.20

4 years ago

1.0.20-audit.4

4 years ago

1.0.19

4 years ago

1.0.19-audit.8

4 years ago

1.0.19-audit.7

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.12-audit.97

4 years ago

1.0.16-alpha.9

5 years ago

1.0.16

5 years ago

1.1.0-alpha.6

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.12-alpha.94

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11-alpha.12

5 years ago

1.0.11

5 years ago

1.0.9

5 years ago

1.0.10

5 years ago

1.0.8-alpha.8

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc.25

5 years ago

1.0.0-rc.24

5 years ago

1.0.0-rc.23

5 years ago

1.0.0-rc.22

6 years ago

1.0.0-rc.21

6 years ago

1.0.0-rc.20

6 years ago

1.0.0-rc.19

6 years ago

1.0.0-rc.16

6 years ago

1.0.0-rc.15

6 years ago

1.0.0-rc.14

6 years ago

1.0.0-rc.13

6 years ago

1.0.0-rc.12

6 years ago

1.0.0-rc.11

6 years ago

1.0.0-rc.10

6 years ago

1.0.0-rc.9

6 years ago

1.0.0-rc.8

6 years ago

1.0.0-rc7

6 years ago

1.0.0-rc6

6 years ago

1.0.0-rc5

6 years ago

1.0.0-rc4

6 years ago

1.0.0-rc3

6 years ago

1.0.0-rc2

6 years ago

1.0.0-rc1

6 years ago