Configuring package.json
- Update the package name
- Update
evidence.datasources
- This contains an array of arbitrary data source names that users will use to select this source in their connection.yaml files
- If your connector supports multiple sources, or you have several aliases (e.g. psql, postgres, postgresql), you can provide a nested array, this will show only the first item in the UI
- In this example,
postgres
,psql
,postgresql
,redshift
, andtimescaledb
will all select this connector
However, onlypostgres
,redshift
, andtimescaledb
will be presented as options in the UI.{ "evidence": { "datasources": [ [ "postgres", "psql", "postgresql" ], // Shows only `postgres` in the UI "redshift", "timescaledb" ] } }
- In this example,
- Optionally, specify an icon for your datasource.
- Icons can come from Simple Icons, or Tabler Icons.
- Evidence uses Steeze UI for our icons, so the casing must match
the Steeze UI export
index.js
defines the type ConnectorOptions
, and exports an options
constant.
ConnectorOptions
should be typed to the expected configuration for your datasource (e.g. hostname, port, etc)
options
defines how your connector will be configured in the UI, we recommend reading the docs, and/or taking a look at the Evidence Postgres Connector. Technically, implementing this is optional, but it provides a much better user experience when your datasource is installed.
Evidence accepts 2 different interfaces when using datasources, one is much easier to write, but is much less flexible.
Note that
lib.js
has a stubbeddatabaseTypeToEvidenceType
, which is helpful for buildingColumnTypes
more easily.
For the simple interface, implement the getRunner
function; which is a factory pattern for building a configured QueryRunner.
Each query can either return an array of results, or an async generator function if implementing cursor logic (this enables much larger datasets)
For the advanced interface, implement the processSource
function; which is an async generator function returning tables directly.
processSource
receives a proxy of the source's filetree, so it must look for files itself, but returns results in the same available formats as getRunner
. processSource
should be used in instances where output tables do not map one to one with input files (e.g. if a list of tables is provided in connection.yaml
that should all be SELECT *
'd)
This template comes with vitest
pre-installed. If you've used jest, vitest implements a very similar API.
Tests have been stubbed in index.spec.js
, and can be run with npm run test
Typescript has also been included with a basic configuration, and your types can be checked with npm run check
- Install your connector in
test-project
usingnpm i ../datasource
- Add your connector's package name to
evidence.plugins.yaml
- Create a source that uses your connector
- You can either create it manually in
sources
, or in the settings ui. - If you populated your
options
object, testing it in the settings UI is recommended.
- You can either create it manually in
- Use
npm run sources
in the test project to execute your datasource, and modifyindex.md
to use your new source.- It can also be helpful to referenecs the
schema explorer
to make sure that the types returned
by your connector match what you are expecting.
- It can also be helpful to referenecs the
- Run
npm install
indatasource
andtest-project
directories