Skip to content

Latest commit

 

History

History
86 lines (67 loc) · 2.02 KB

AutoRest-extension-protocol.md

File metadata and controls

86 lines (67 loc) · 2.02 KB

AutoRest extension protocol

The protocol is bidirectional, i.e. AutoRest may call the API of the extension and vice versa.

Implementations

AutoRest ⇒ Extension

GetPluginNames(): string[]
Process(pluginName: string, sessionId: string): boolean

Extension ⇒ AutoRest

ListInputs(sessionId: string): string[]
ReadFile(sessionId: string, filename: string): string
GetValue(sessionId: string, key: string): any

WriteFile(sessionId: string, filename: string, content: string, sourceMap?: Mapping[] | RawSourceMap): void
Message(sessionId: string, message: Message): void

Type: Message

{
  Channel: "information" | "warning" | "error" | "debug" | "verbose"
  Key?: string[]
  Details?: any
  Text: string
  Source?: SourceLocation[]
}

Type: SourceLocation

{
  document: string  // the URI of the input document (as used for `ReadFile`)
  Position: Position
}

Type: Position

{
  line: number // 1-based
  column: number // 0-based
} |
{
  path: (string | number)[] // object path (e.g. `['b', 3, 'a']` for $.b[3].a)
}

Type: Mapping

{
  generated: Position // position in generated document
  original: Position  // position in source document
  source: string      // the URI of the input document (as used for `ReadFile`)
  name?: string
}

Type: RawSourceMap

see An Introduction to Source Maps

{
  file?: string
  sourceRoot?: string
  version: string
  sources: string[]
  names: string[]
  sourcesContent?: string[]
  mappings: string
}