Skip to content

bpmn-server / Connectors

Class: Connectors#

Table of contents#

Constructors#

Properties#

Accessors#

Methods#

Constructors#

constructor#

• new Connectors(server): Connectors

Parameters#

Name Type
server IBPMNServer

Returns#

Connectors

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:143

Properties#

compiled#

• Private Readonly compiled: Map\<string, { stamp: string ; document: any ; operations: Map\<string, Operation> }>

each connector's document and operations, read once and kept until the document changes

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:139


files#

• Private Readonly files: Map\<string, { stamp: string ; definition: any }>

each file as last read, kept while it is the same (its time and size)

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:141


server#

• Private Readonly server: IBPMNServer

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:143


looseChecked#

• Private looseChecked: boolean = false

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:171

Accessors#

settings#

• get settings(): any

Returns#

any

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:156


store#

• get store(): any

Returns#

any

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:157


database#

• get database(): any

The logical database, as the data store has it (ignored by single-database stores). A MongoDB configuration without a db leaves it undefined: MongoDB then uses the database its URL names.

Returns#

any

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:162


modelsFolder#

• get modelsFolder(): string

Returns#

string

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:166


folder#

• get folder(): string

The connectors' folder, in the models folder.

Returns#

string

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:168

Methods#

compile#

▸ compile(connector): Object

The connector's document and operations, from the cache while the document is the same.

Parameters#

Name Type
connector Connector

Returns#

Object

Name Type
stamp string
document any
operations Map\<string, Operation>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:146


fileOf#

▸ fileOf(id): string

Parameters#

Name Type
id string

Returns#

string

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:169


moveLoose#

▸ moveLoose(): void

Connector files beside the models (where 3.7 wrote them at first) moved into the connectors folder: at a list, and before the first read. One already in the folder is kept; the other is left where it is, and said so.

Returns#

void

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:176


readDefinition#

▸ readDefinition(id): any

A connector's definition from its file, or undefined; read again only when the file changed.

Parameters#

Name Type
id string

Returns#

any

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:194


writeDefinition#

▸ writeDefinition(definition): void

Writes a connector's definition to its file (as the models are written: by the server, into its folder).

Parameters#

Name Type
definition any

Returns#

void

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:212


fileIds#

▸ fileIds(): string[]

The ids of the connectors' files.

Returns#

string[]

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:220


stateOf#

▸ stateOf(id): Promise\<any>

Parameters#

Name Type
id string

Returns#

Promise\<any>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:228


setState#

▸ setState(id, set, unset?): Promise\<void>

Parameters#

Name Type
id string
set Record\<string, any>
unset? Record\<string, string>

Returns#

Promise\<void>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:233


install#

▸ install(): Promise\<void>

Returns#

Promise\<void>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:237


list#

▸ list(): Promise\<Connector[]>

Every connector, without its key.

Returns#

Promise\<Connector[]>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:246


get#

▸ get(id): Promise\<Connector>

One connector, without its key; undefined when there is none.

Parameters#

Name Type
id string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:258


operations#

▸ operations(id): Promise\<Operation & { enabled: boolean }[]>

A connector's operations: every one the document has, and whether designers may use it.

Parameters#

Name Type
id string

Returns#

Promise\<Operation & { enabled: boolean }[]>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:264


document#

▸ document(id): Promise\<any>

A connector's OpenAPI document, as it was read.

Parameters#

Name Type
id string

Returns#

Promise\<any>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:271


backup#

▸ backup(): Promise\<Record\<string, any[]>>

What this server keeps of its connectors (keys encrypted, tests): for a backup. The files are the models'.

Returns#

Promise\<Record\<string, any[]>>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:276


load#

▸ load(id): Promise\<Connector>

A connector: its file, with this server's key and test. One kept whole in the collection is written out first.

Parameters#

Name Type
id string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:281


writeOut#

▸ writeOut(kept): Promise\<{ definition: any ; state: ServerState }>

A connector kept whole in the collection (3.6): its definition to its file; its key and test stay, alone.

Parameters#

Name Type
kept any

Returns#

Promise\<{ definition: any ; state: ServerState }>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:293


required#

▸ required(id): Promise\<Connector>

Parameters#

Name Type
id string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:310


withoutSecret#

▸ withoutSecret(connector): Connector

What callers see: no key, and the document only described (document(id) reads it).

Parameters#

Name Type
connector Connector

Returns#

Connector

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:317


add#

▸ add(input, userName?): Promise\<Connector>

Adds a connector from its OpenAPI document (given, or fetched from source): its file in the models folder.

Parameters#

Name Type
input ConnectorInput
userName? string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:331


update#

▸ update(id, patch): Promise\<Connector>

Changes a connector's name, description, base URL, operations, groups, enabled, timeout or retries.

Parameters#

Name Type
id string
patch Partial\<Pick\<Connector, "name" | "timeout" | "description" | "baseUrl" | "operations" | "groups" | "enabled" | "retries" | "testing">>

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:360


refresh#

▸ refresh(id, document?): Promise\<{ added: string[] ; removed: string[] }>

Reads the document again (from its source, or the one given): operations it no longer has are dropped, new ones are enabled. Returns what changed.

Parameters#

Name Type
id string
document? string | object

Returns#

Promise\<{ added: string[] ; removed: string[] }>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:378


openapiOf#

▸ openapiOf(document, source?): Object

What is kept of a document: where it came from, its version and title, and itself, as JSON.

Parameters#

Name Type
document any
source? string

Returns#

Object

Name Type
source? string
version string
title? string
fetchedAt string
bytes number
document? any

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:389


remove#

▸ remove(id): Promise\<boolean>

Removes a connector: its file, and this server's key and test. Its halves: removeFile, forget.

Parameters#

Name Type
id string

Returns#

Promise\<boolean>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:394


removeFile#

▸ removeFile(id): boolean

The connector's file gone (model access's).

Parameters#

Name Type
id string

Returns#

boolean

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:401


forget#

▸ forget(id): Promise\<boolean>

This server's key and test for the connector gone (the engine's).

Parameters#

Name Type
id string

Returns#

Promise\<boolean>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:413


setKey#

▸ setKey(id, key, how?, userName?): Promise\<Connector>

Sets (or replaces) the connector's authorization key, stored encrypted with this server. how is a securitySchemes name of the document, or a scheme given here; none: the document's only scheme. For basic, the key is user:password. Its two halves, for when the engine is elsewhere: setScheme (the file: model access) and storeKey (this server's key: the engine).

Parameters#

Name Type Default value
id string undefined
key string undefined
how string | Omit\<ConnectorAuth, "secret" | "last4" | "setAt" | "setBy"> undefined
userName? string undefined

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:424


setScheme#

▸ setScheme(id, how?, key?): Promise\<ConnectorAuth>

How the connector's key is sent, into its file (written only when it changes); the key, when given, checked against it.

Parameters#

Name Type Default value
id string undefined
how string | Omit\<ConnectorAuth, "secret" | "last4" | "setAt" | "setBy"> undefined
key? string undefined

Returns#

Promise\<ConnectorAuth>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:430


storeKey#

▸ storeKey(id, key, userName?): Promise\<Connector>

This server's key for the connector, stored encrypted (SECRETS_KEY): the engine's, where the calls are made.

Parameters#

Name Type
id string
key string
userName? string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:444


clearKey#

▸ clearKey(id): Promise\<Connector>

Removes the connector's key: its calls go without authorization. Its halves: clearScheme, forgetKey.

Parameters#

Name Type
id string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:453


clearScheme#

▸ clearScheme(id): Promise\<void>

No scheme in the connector's file.

Parameters#

Name Type
id string

Returns#

Promise\<void>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:459


forgetKey#

▸ forgetKey(id): Promise\<Connector>

This server's key for the connector, gone.

Parameters#

Name Type
id string

Returns#

Promise\<Connector>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:466


authScheme#

▸ authScheme(connector, how): ConnectorAuth

How a key is sent: from the document's securitySchemes (by name, or its only one), or as given.

Parameters#

Name Type
connector Connector
how any

Returns#

ConnectorAuth

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:473


fromScheme#

▸ fromScheme(scheme): ConnectorAuth

Parameters#

Name Type
scheme any

Returns#

ConnectorAuth

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:495


test#

▸ test(id, operationId?, input?): Promise\<{ at: string ; operation: string ; ok: boolean ; status?: number ; message?: string }>

Tests the connection: calls an operation (none named: a GET that needs no input) with the inputs given, and keeps the answer.

Parameters#

Name Type
id string
operationId? string
input Record\<string, any>

Returns#

Promise\<{ at: string ; operation: string ; ok: boolean ; status?: number ; message?: string }>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:503


call#

▸ call(ref, input?, options?): Promise\<CallResult>

Calls <connector>/<operationId> with the inputs: the operation's parameters by name, the JSON body as body or its fields as body.<field>. Answers { status, output }; a status other than 2xx throws a ConnectorError.

Parameters#

Name Type
ref string
input Record\<string, any>
options Object
options.signal? AbortSignal
options.test? boolean
options.log? (line: string) => void

Returns#

Promise\<CallResult>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:526


exampleAnswer#

▸ exampleAnswer(connector, op, ref, input, log?): CallResult

An operation's answer outside production, with no call: the connector's own answer for it (testing.answers), else its document's example of its first success response, else one made from that response's schema.

Parameters#

Name Type
connector Connector
op Operation
ref string
input Record\<string, any>
log? (line: string) => void

Returns#

CallResult

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:579


checkTesting#

▸ checkTesting(testing): ConnectorTesting

A connector's testing, checked: its answer one of real, examples, sandbox; a sandbox's address an http(s) URL.

Parameters#

Name Type
testing any

Returns#

ConnectorTesting

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:602


backoff#

▸ backoff(attempt): Promise\<unknown>

Parameters#

Name Type
attempt number

Returns#

Promise\<unknown>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:617


buildRequest#

▸ buildRequest(connector, op, input): Object

The request: the base URL joined with the operation's path, its parameters in place, the body, the key.

Parameters#

Name Type
connector Connector
op Operation
input Record\<string, any>

Returns#

Object

Name Type
url string
headers Record\<string, string>
body string
logUrl string

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:623


readBody#

▸ readBody(response, ref): Promise\<any>

The body: JSON when it is, else text; refused past the size limit.

Parameters#

Name Type
response Response
ref string

Returns#

Promise\<any>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:686


readDocument#

▸ readDocument(input): Promise\<any>

Parameters#

Name Type
input Object
input.id string
input.source? string
input.document? string | object

Returns#

Promise\<any>

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:705


checkBaseUrl#

▸ checkBaseUrl(value, source?): string

An http(s) URL on an allowed host; a relative server URL is read against the document's URL.

Parameters#

Name Type
value string
source? string

Returns#

string

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:720


checkHost#

▸ checkHost(url): void

CONNECTORS_ALLOW_HOSTS (a comma list; *.example.com for its subdomains), when set, limits the hosts.

Parameters#

Name Type
url URL

Returns#

void

Defined in#

packages/bpmn-server/src/connectors/Connectors.ts:735

Comments