Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Made minor grammar and spelling changes

...

Note

The content on page is for the beta release of API Builder 1.10.0. You may find some information is either missing, incomplete , or in general draft state.

Introduction

An A Connector project is similar in structure to a project. This guide covers how to manage your Connector project.

...

  • Select  Component for the type of component
  • Select Connector for the component
  • Select Empty Connector Project to use a boiler plate boilerplate project.
  • Enter a name and directory name for your project.

...

Place all the connector logic in the lib folder.  There must be an index.js file in your lib folder, which is the first file loaded by the connector.

The boiler plate boilerplate index.js file expose a create() method, which is passed the API Builder class.  The method must return a Connector instance, which is created using the Arrow.Connector.extend()method.  Uncomment each Capability constant in the capabilities field to have API Builder generate boiler plate boilerplate logic for each capability you want the Connector to support.  Each method will have its own JavaScript file. You may also pass the extend() method an object, which implements the methods of the Connector class and a few methods from the Model class.  

...

API Builder is based on Arrow and starting with Arrow 1.2.48 or Appcelerator CLI 4.1.3, the connector configuration object passed to the Connect.extend() method supports a capabilities property.  The first time you run a project after adding a Capability constant to the capabilities property, API Builder will generate boiler plate boilerplate logic, which you can modify.  The table below explains what each capability constant exposes and creates. If a certain connector is not exposed through a capability, you can implement the method in the object passed to the Connector.extend() method.

Capability ConstantLocationExposed Connector Methods
ConnectToADataSource./lib/lifecycle
  • connect
  • disconnect
ValidatesConfiguration./lib/metadata
  • fetchMetadata
AddsCustomTypes./lib/metadata 
  • coerceCustomType
  • getCustomType
GenerateModels./lib/schema
  • createModelsFromSchema
  • fetchSchema
ContainsModels./modelsCreates a boiler plate model in the models folder.
CanCreate./lib/methods
  • create
CanRetrieve./lib/methods
  • distinct
  • findAll
  • findById
  • query
CanUpdate./lib/methods
  • findAndModify
  • save
  • upsert
CanDelete./lib/methods 
  • delete
  • deleteAll

AuthenticatesThroughConnector

./lib/lifecycle
  • login
  • loginRequired

...

If you need to add some custom initialization logic when creating the connector, implement the following methods.  The The connector instance is the value passed to this in the functions. The functions do not take any arguments or return any values:

...

To access data from the Connector, you need to implement the following methods. Each method is passed the Model class as it its first parameter and a callback as its last parameter. After completing the operation, invoke the callback function and pass it an Error object (or null if successful) as the first parameter, and the results of the operation as the second parameter. None of the methods have a return value.

...