Connector Reference

Connectors are responsible for connecting to a particular data source and reading and writing data from/to it. Data sources can be anything from SAP to Twitter to a filesystem or a custom REST API in your organization. You can build connectors to interact with any data source.

Connectors are created as their own project and can be run as such while in development. This allows the connector developer to build a connector without having to switch to a separate API project while in development.

To create a new connector project, run the following command:

appc generate

And select the options to create a new connector project.

To run and try out your connector project, run the following command:

appc run

You can try out your connector in the app.js file. The main connector file is located in lib/index.js, with stubbed out methods that the connector should export.

The property you should look at first is the capabilities. This defines specific capabilities, like CanRetrieve, or ConnectsToADataSource. By enabling a capability, Arrow will help you add the right methods and configuration to your connector to make it work.

To run unit tests for your connector project, run the following command (npm install is only necessary the first time):

npm install
npm test

Configuring Your Connector

Each connector defines it’s configuration parameters. This configuration is specified in conf/default.js within your connector project.

By default, the default.js file will be loaded with your main configuration. To provide a connector specific configuration, use the following format:

{
    "connectors": {
        "name_of_connector_or_alias": {
            "connector": "real_name",
            "config": {
                // connector specific config
            }
        }
    }
}

You can alias your connector to provide different connector instances or to easily switch between different configurations.

For example, to use two different Salesforce instances based on the name, you could do the following:

{
    "connectors": {
        "sf_production": {
            "connector": "appc.salesforce",
            "config": {
                // connector specific config
            }
        },
        "sf_development": {
            "connector": "appc.salesforce",
            "config": {
                // connector specific config
            }
        }
    }
}

This type of configuration allows models to easily change from a development or production version of the same connector.

Generate Connector Endpoints

API endpoints can be generated from a connector’s model (if the connector supports models). For example, if your MySQL connector points to a database with a single table: employee. It will automatically generate a model definition for the employee table - hence the ability to extend or reduce a MySQL model by name in this manner: appc.mysql/employee. Additionally, you can generate API endpoints from connector models (when supported by the connector). To set this property for Salesforce (as an example), go to the conf directory and open appc.salesforce.default.js - this is the default configuration for the Salesforce connector. This configuration file is created when you install the Salesforce connector into your project.

Here’s an example of a Salesforce connector’s configuration (found in conf/appc.salesforce.default.js)

module.exports = {
    "connectors": {
        "appc.salesforce": {
            "modelAutogen":false,
            "requireSessionLogin": false,
            "url": 'https://test.salesforce.com/',
            "username": 'myemail@mydomain.com',
            "password": 'mypassword',
            "token": 'mytoken'
        }
    }
};

The property modelAutogen controls whether API endpoints are generated. The default is false, which means API endpoints will not be generated.