Skip to content

npm v1.1.0

Compare
Choose a tag to compare
@rikoe rikoe released this 14 Apr 14:32

The first official release of the @finos/fdc3 npm package, corresponding with the FDC3 Standard v1.1.

Release highlights

API Typings

This release includes TypeScript typings for the FDC3 [DesktopAgent] interface and related types, as well as the window.fdc3 global object, e.g:

import { DesktopAgent, Channel } from '@finos/fdc3'

let channel: Channel;

async function fdc3Action() {
  channel = await window.fdc3.getOrCreateChannel('red');

  // use channel
}

ES6 Imports

The npm package also exposes the FDC3 API operations as ES6 functions that can be imported directly into your code, e.g.:

import { raiseIntent } from '@finos/fdc3'

const instrument = {
  type: 'fdc3.instrument',
  id: {
    ticker: 'AAPL'
  }
};

await raiseIntent('ViewAnalysis', instrument);

These functions will reject or throw appropriately if window.fdc3 is not defined when they are called.

Context Types

The package also includes generated TypeScript types for all standardised FDC3 Context Types, e.g.:

import { Contact } from '@finos/fdc3'

const contact: Contact = {
  type: 'fdc3.contact',
  id: {
    email: 'joe.bloggs@mail.com
  },
  name: 'Joe Bloggs'
};

Also included is a Convert helper object for generating for converting from raw JSON to the relevant type, e.g.:

import { Convert } from '@finos/fdc3'

const json = '{ "type": "fdc3.contact", "id": { "email": "joe.bloggs@mail.com" }, "name": "Joe Bloggs" }';

const contact = Convert.toContact(json);

The typings and conversion helper were generated with QuickType.

Enums for Intents and Context Types

The included Intents and ContextTypes enums provide named constants for the specific intents and context types that have been standardised as part of FDC3 1.1, so that strings don't have to be used:

import { ContextTypes, Intents, raiseIntent } from '@finos/fdc3'

const instrument = {
  type: ContextTypes.Instrument,
  id: {
    ticker: 'AAPL'
  }
}

await raiseIntent(Intents.ViewNews, instrument);

🚀 New Features

  • Build an npm package with exported TypeScript typings for API, Context Data and window.fdc3 global (#252)
  • Export helper enums for names of standardised Intents and ContextTypes (#264)
  • Export API operations as ES6 functions that can be directly imported (#266)
  • Check for the existence of window.fdc3 in ES6 functions, and reject or throw if not defined (#356)

🐛 Bug Fix

  • Return type of getCurrentChannel() should be Promise<Channel> (#222)

See CHANGELOG.md for more details.