bpmn-server / Connectors
Class: Connectors#
Table of contents#
Constructors#
Properties#
Accessors#
Methods#
- compile
- install
- list
- get
- operations
- document
- backup
- load
- upgrade
- required
- withoutSecret
- add
- update
- refresh
- openapiOf
- remove
- setKey
- clearKey
- authScheme
- fromScheme
- test
- call
- backoff
- buildRequest
- readBody
- readDocument
- checkBaseUrl
- checkHost
Constructors#
constructor#
• new Connectors(server): Connectors
Parameters#
| Name | Type |
|---|---|
server |
IBPMNServer |
Returns#
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:108
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:106
server#
• Private Readonly server: IBPMNServer
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:108
Accessors#
settings#
• get settings(): any
Returns#
any
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:121
store#
• get store(): any
Returns#
any
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:122
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:127
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:111
install#
▸ install(): Promise\<void>
Returns#
Promise\<void>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:129
list#
▸ list(): Promise\<Connector[]>
Every connector, without its key.
Returns#
Promise\<Connector[]>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:136
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:142
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:148
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:155
backup#
▸ backup(): Promise\<Record\<string, any[]>>
Every connector as stored (keys encrypted): for a backup.
Returns#
Promise\<Record\<string, any[]>>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:160
load#
▸ load(id): Promise\<Connector>
Parameters#
| Name | Type |
|---|---|
id |
string |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:164
upgrade#
▸ upgrade(connector): Promise\<Connector>
A connector stored before documents were packed (openapi.document): packed now, and saved so.
Parameters#
| Name | Type |
|---|---|
connector |
any |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:170
required#
▸ required(id): Promise\<Connector>
Parameters#
| Name | Type |
|---|---|
id |
string |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:180
withoutSecret#
▸ withoutSecret(connector): Connector
What callers see: no key, and the document only described (document(id) reads it).
Parameters#
| Name | Type |
|---|---|
connector |
Connector |
Returns#
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:187
add#
▸ add(input, userName?): Promise\<Connector>
Adds a connector from its OpenAPI document (given, or fetched from source).
Parameters#
| Name | Type |
|---|---|
input |
ConnectorInput |
userName? |
string |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:201
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">> |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:230
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:246
openapiOf#
▸ openapiOf(document, source?): Object
What is stored of a document: where it came from, its version and title, and itself packed.
Parameters#
| Name | Type |
|---|---|
document |
any |
source? |
string |
Returns#
Object
| Name | Type |
|---|---|
source? |
string |
version |
string |
title? |
string |
fetchedAt |
string |
packed |
string |
bytes |
number |
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:261
remove#
▸ remove(id): Promise\<boolean>
Parameters#
| Name | Type |
|---|---|
id |
string |
Returns#
Promise\<boolean>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:266
setKey#
▸ setKey(id, key, how?, userName?): Promise\<Connector>
Sets (or replaces) the connector's authorization key, stored encrypted. 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.
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:276
clearKey#
▸ clearKey(id): Promise\<Connector>
Removes the connector's key: its calls go without authorization.
Parameters#
| Name | Type |
|---|---|
id |
string |
Returns#
Promise\<Connector>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:289
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#
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:296
fromScheme#
▸ fromScheme(scheme): ConnectorAuth
Parameters#
| Name | Type |
|---|---|
scheme |
any |
Returns#
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:318
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:326
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:349
backoff#
▸ backoff(attempt): Promise\<unknown>
Parameters#
| Name | Type |
|---|---|
attempt |
number |
Returns#
Promise\<unknown>
Defined in#
packages/bpmn-server/src/connectors/Connectors.ts:393
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:399
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:462
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:481
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:496
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:511