{"id":19370588,"url":"https://github.com/evidence-dev/datasource-template","last_synced_at":"2025-04-23T15:32:32.981Z","repository":{"id":217356784,"uuid":"743673231","full_name":"evidence-dev/datasource-template","owner":"evidence-dev","description":"This repository contains a template to help you easily create an Evidence Data Source plugin","archived":false,"fork":false,"pushed_at":"2024-10-29T23:30:44.000Z","size":673,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T17:11:19.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evidence-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-15T18:33:24.000Z","updated_at":"2024-10-29T23:30:48.000Z","dependencies_parsed_at":"2024-01-19T16:02:40.298Z","dependency_job_id":"c36593df-8dbb-449f-8eca-810ce155fe2a","html_url":"https://github.com/evidence-dev/datasource-template","commit_stats":null,"previous_names":["evidence-dev/datasource-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evidence-dev%2Fdatasource-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evidence-dev%2Fdatasource-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evidence-dev%2Fdatasource-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evidence-dev%2Fdatasource-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evidence-dev","download_url":"https://codeload.github.com/evidence-dev/datasource-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250460654,"owners_count":21434270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T08:16:02.576Z","updated_at":"2025-04-23T15:32:32.661Z","avatar_url":"https://github.com/evidence-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Evidence Source Plugin Template\n\nUse this template to create a new Evidence source plugin. The template includes a simple example plugin, which you can use to get started.\n\n\n## Install and run the sample plugin\n\nClick the \"Use this template\" button above to create a new repository from this template. The convention for the repo name is `evidence-connector-[sourcename]`.\n\nOpen your repository and run the following (you may need to run `chmod +x bootstrap.sh` to make the scripts executable)\n\n```bash\n./bootstrap.sh\n./run-plugin.sh\n```\n\nThese commands:\n- Installs a sample plugin\n- Create a test Evidence app in `test-app`\n- Install the sample plugin in the test app\n- Add a source to the test app\n- Run the test app\n\nTo verify the plugin works, scroll to the bottom of the app homepage and you should see \"Test Plugin is working\" with some sample data in a table.\n\n## Make the plugin your own\n\n### Modify the plugin code\n\nThe plugin code is in [`src/index.js`](./src/index.js).\n\nEvidence accepts 2 different interfaces when using datasources:\n1. File-based Interface: Each file in the user's source directory is processed by `getRunner`\n2. Advanced Interface: Files are not explcitly processed by `getRunner`, and instead the `processSource` function is implemented.\n\n\u003e Note that [`lib.js`](./src/lib.js) has a stubbed `databaseTypeToEvidenceType`, which is helpful for building `ColumnTypes` more easily.\n\n#### File-based Interface\n\nFor the file-based interface, modify the `getRunner` function; which is a factory pattern for building a configured QueryRunner.\n\nThe sample plugin uses the file-based interface.\n\nEach query can either return an array of results, or an [async generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*) if implementing cursor logic (this enables much larger datasets)\n\n#### Advanced Interface (File-independent)\n\nFor the advanced interface, implement the `processSource` function; which is an [async generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*) returning tables directly.\n\n`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)\n\n### Specify any plugin options\n\n[`index.js`](./src/index.js) defines the type `ConnectorOptions`, and exports an `options` constant.  \n\n`ConnectorOptions` should be typed to the expected configuration for your datasource (e.g. hostname, port, etc)  \n\n`options` defines how your connector will be configured in the UI, see the [docs](https://docs.evidence.dev/plugins/create-source-plugin/), and/or taking a look at the [Evidence Postgres Connector](https://github.com/evidence-dev/evidence/blob/main/packages/datasources/postgres/index.cjs#L242).\n\n### [Optional] Add aliases and icons to package.json\n\n1. 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\n    - In this example, `postgres`, `psql`, `postgresql`, `redshift`, and `timescaledb` will all select this connector  \n    However, only `postgres`, `redshift`, and `timescaledb` will be presented as options in the UI.\n```json\n{\n    \"evidence\": {\n        \"datasources\": [\n            [ \"postgres\", \"psql\", \"postgresql\" ],  // Shows only `postgres` in the UI\n            \"redshift\",\n            \"timescaledb\"\n        ]\n    }\n}\n```\n2. Specify an icon for your datasource.\n    1. Icons can come from [Simple Icons](https://simpleicons.org/), or [Tabler Icons](https://tabler-icons.io/).\n    2. Evidence uses [Steeze UI](https://github.com/steeze-ui/icons#icon-packs) for our icons, so the casing must match  \n        the Steeze UI export\n   ```json\n   {\n       \"evidence\": {\n           \"icon\": \"YourIconName\"\n       }\n   }\n   ```\n\n### [Recommended] Write Unit Tests\n\nThis template comes with [`vitest`](https://vitest.dev/) pre-installed. If you've used [jest](https://jestjs.io/), vitest implements a very similar API.\n\nTests have been stubbed in [`index.spec.js`](./src/index.spec.js), and can be run with `npm run test`\n\n### Publishing to npm\n\nYou need an npm account to publish your plugin. \nIf you don't have one, you can [sign up](https://www.npmjs.com/signup) for free.\n\nTo publish your connector to npm, follow these steps:\n\n1. **Login to npm**: If you haven't already, you need to login to your npm account. You can do this by running:\n\n```bash\nnpm login\n```\n\n2. **Publish the package**: Once you are logged in and the version is updated in package.json, you can publish your package by running:\n\n```bash\nnpm publish\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevidence-dev%2Fdatasource-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevidence-dev%2Fdatasource-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevidence-dev%2Fdatasource-template/lists"}