@liquid-labs/liq-integrations
v1.0.0-alpha.2
Published
Enables integrations plugins for a @liquid-labs/plugable-express server.
Downloads
3
Readme
liq-integrations
Enables integrations plugins for plugable-express based servers.
Installation
From a plugable express server:
catalyst server plugins handlers add -- npmName=@liquid-labs/liq-integrations
Where 'catalyst' may be replaced by the CLI for the particular pluggable server.
Usage
Once installed, you can then install integrations like this:
catalyst server plugins integrations add -- npmName=@liquid-labs/liq-integrations-issues-github
Where 'catalyst' may be replaced by the CLI for the particular pluggable server.
Integrations overview
This section is aimed primarily at those seeking a deeper understanding of how integrations work; e.g., integration developers. Casual users can skip this section.
Structure
An integration spec defines a single integration:
hooks
: an object containing hook functions referenced by name. The hook functions are what are ultimately executed byIntegrationsManager.callHook()
. Every integration which is aproviderFor
a particular thing will define the same set of hooks. The hooks are "what the integration can do".name
: a simple name describing the integration spec. (The use ofname
is still in flux and may be dropped.)npmName
: the name of the package providing the integrations.providerFor
: a noun or verb naming the thing (e.g. 'tickets'). TheproviderFor
value is used byIntegrationsManager.callHook()
to for first-level selection of possible integration providers.providerTest
: a test function which decides whether this integration fits this project. The provider test always receivespkgJSON
, which is thepackage.json
value for the project being acted upon and may receive additional arguments depending on theproviderFor
type.
Flow
- 'liq-integrations'
setup()
adds sets upapp.ext.integrations = new IntegrationsManager()
. - 'lig-integrations'
setup()
calls theregisterIntegrationsPlugin()
function exported by each installed integrations plugin package. Each plugin registers its integrations. - When an integration is required (e.g., to create a pull request), instead of calling a function directly,
IntegrationsManager.callHook()
is invoked with the following parameters:
providerFor
: a string naming the integration basic domain / purpose (e.g., 'pull requests')providerArgs
: a parameter object containing thepkgJSON
for the project in question and (depending on theproviderFor
type) possibly additional arguments.hook
: the name of the specific hook in the integrations to be invoked (e.g., 'createOrUpdatePullRequest').hookArgs
: a parameter object containing arguments particular to thehook
.
- The
IntegrationsManager.callHook()
will filter the available integrations based onproviderFor
and then the itnegaritonsproviderTest
. Once found, the integrationshook
is invoked with the caller'shookArgs
. If no applicable integration is found, then an exception is raised.
Note in theory, it would be possible to find an integration based on the hook
name alone but we retain providerFor
as it clarifies things and to make determination of providerArgs
cotnent more clear in particular. There is also the thought that it helps avoid hook
name collisions in future.