diff --git a/CHANGELOG.md b/CHANGELOG.md index ef6717e2a..8f5e62034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,9 +23,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed * Updated definition of the `ChatInitSettings` context type to use the new `Message` type. ([#779](https://github.com/finos/FDC3/pull/779)) +* Updated the `StartChat` intent to return a reference to the room. ([#794](https://github.com/finos/FDC3/pull/794)) * Updated definition of the `Instrument` context type to include optional market identifiers ([#819](https://github.com/finos/FDC3/pull/819)) * Corrected API functions and object types to always use `string` instead of `String` ([#924](https://github.com/finos/FDC3/pull/924)) -* Updated the `StartChat` intent to return a reference to the room. ([#794](https://github.com/finos/FDC3/pull/794)) +* Updated definition of the `otherConfig` element of the `Chart` context type from an Object to an array of Contexts as this allows the `type` of each additional item of config to be examined before it is used ([#985](https://github.com/finos/FDC3/pull/985)) ### Deprecated diff --git a/docs/context/ref/Chart.md b/docs/context/ref/Chart.md index de022425e..900c321fa 100644 --- a/docs/context/ref/Chart.md +++ b/docs/context/ref/Chart.md @@ -21,7 +21,7 @@ In addition to handling requests to plot charts, a charting application may use ## Schema -https://fdc3.finos.org/schemas/next/chart.schema.json +[https://fdc3.finos.org/schemas/next/chart.schema.json](https://fdc3.finos.org/schemas/next/chart.schema.json) ## Details @@ -31,9 +31,9 @@ https://fdc3.finos.org/schemas/next/chart.schema.json | `instruments` | Instrument[] | Yes |
[
  {
    "type": "fdc3.instrument",
    "id": {
      "ticker": "AAPL"
    }
  },
  {
    "type": "fdc3.instrument",
    "id": {
      "ticker": "MSFT"
    }
  }
]
| | `range` | TimeRange | No |
{
  "type": "fdc3.timerange",
  "startTime": "2022-03-30T15:44:44+00:00",
  "endTime": "2022-04-30T23:59:59+00:00"
}
| | `style` | string | No | one of: `'line'`, `'bar'`, `'stacked-bar'`, `'mountain'`, `'candle'`, `'pie'`, `'scatter'`, `'histogram'`, `'heatmap'`, `'custom'` | -| `otherConfig`* | object | No | `{ /* unstandardized additional config */}` | +| `otherConfig`* | array | No | `[ {/* additional config context objects */} ]` | -\* It is common for charts to support other configuration, such as indicators, annotations etc., which do not have standarized formats, but may be included in the `otherConfig` element. +\* It is common for charts to support other configuration, such as indicators, annotations etc., which do not have standardized formats, but may be included in the `otherConfig` array as context objects. ## Example @@ -60,20 +60,24 @@ const chart = { endTime: "2020-10-31T08:00:00.000Z" }, style: "line", - otherConfig: { - indicators: [ - { - name: "ma", - parameters: { - period: 14, - type: "ema" - } - }, - { - name: "volume" + otherConfig: [ + { + type: "somevendor.someproduct.indicator", + name: "stddev", + parameters: { + period: 10, + matype: "exponential" } - ] - } + }, + { + type: "someothervendor.someotherproduct.formula", + formula: "standard-deviation", + fields: { + lookback: 10, + type: "ema" + } + } + ] }; fdc3.raiseIntent("ViewChart", chart); diff --git a/src/context/ContextTypes.ts b/src/context/ContextTypes.ts index feb3e5d8a..ce36bd04f 100644 --- a/src/context/ContextTypes.ts +++ b/src/context/ContextTypes.ts @@ -24,7 +24,7 @@ export interface Chart { instruments: InstrumentElement[]; - otherConfig?: { [key: string]: any }; + otherConfig?: OtherConfigElement[]; range?: TimeRangeObject; style?: Style; type: string; @@ -62,6 +62,13 @@ export interface PurpleMarket { [property: string]: any; } +export interface OtherConfigElement { + id?: { [key: string]: any }; + name?: string; + type: string; + [property: string]: any; +} + export interface TimeRangeObject { endTime?: Date; startTime?: Date; @@ -623,7 +630,7 @@ const typeMap: any = { Chart: o( [ { json: 'instruments', js: 'instruments', typ: a(r('InstrumentElement')) }, - { json: 'otherConfig', js: 'otherConfig', typ: u(undefined, m('any')) }, + { json: 'otherConfig', js: 'otherConfig', typ: u(undefined, a(r('OtherConfigElement'))) }, { json: 'range', js: 'range', typ: u(undefined, r('TimeRangeObject')) }, { json: 'style', js: 'style', typ: u(undefined, r('Style')) }, { json: 'type', js: 'type', typ: '' }, @@ -664,6 +671,14 @@ const typeMap: any = { ], 'any' ), + OtherConfigElement: o( + [ + { json: 'id', js: 'id', typ: u(undefined, m('any')) }, + { json: 'name', js: 'name', typ: u(undefined, '') }, + { json: 'type', js: 'type', typ: '' }, + ], + 'any' + ), TimeRangeObject: o( [ { json: 'endTime', js: 'endTime', typ: u(undefined, Date) }, diff --git a/src/context/schemas/chart.schema.json b/src/context/schemas/chart.schema.json index ab541e70c..9a913f1ce 100644 --- a/src/context/schemas/chart.schema.json +++ b/src/context/schemas/chart.schema.json @@ -20,7 +20,10 @@ "enum": [ "line", "bar", "stacked-bar", "mountain", "candle", "pie", "scatter", "histogram", "heatmap", "custom"] }, "otherConfig": { - "type": "object" + "type": "array", + "items": { + "$ref": "context.schema.json#" + } } }, "required": ["instruments"]