Docs‎ > ‎

Extensibility

Live API Creator complements automation with provisions for extending:

  • SQL access. Your SQL operations are normally automated, but you can override these defaults to address more complex cases:
  • Logic. Reactive logic addresses most of your logic, but you can use server-side JavaScript. Live API Creator applies table-based logic to updates on the table and to updates to all custom resource defined over the table.
  • Request. You can control processing at the request level.
For more information:

API Creator is, underneath, a WAR file. It runs within the JVM and you can install it in a standard WAR container. Authorized clients or servers can call into API Creator, via REST. In addition to typical web/mobile apps, this might include cron jobs, app servers built with familiar frameworks, other systems in your organization, partners, and ESB systems.

The following key tenants make the logic open and extensible:

  • The system provides numerous events, which you can handle in server-side JavaScript.
  • Logic for Events, Formulas and Constraints are specified in JavaScript (learn more about JavaScript here).

In both cases, after you get into JavaScript, you have full access to JavaScript (note it is restricted in some eval versions, due to multi-tenant security considerations). JavaScript provides access to:

  • Other JavaScript or Java logic running in the JVM, via loadable libraries (described below)
  • External services, by way of REST, SOAP, etc.

Server-side JavaScript

You can extend system automation for update and retrieval logic with procedural code using server-side JavaScript. Underlying these services is the Object Model created from your schema, providing persistence-enabled row objects for accessing attributes and related data.

Formula and Validation Logic

You specify JavaScript methods for Reactive formula and validation expressions. In the most common case, these are simple expression such as row.price * row.quantity. The system analyzes your JavaScript for dependencies to provide proper ordering.

JavaScript support makes it straightforward to build conditional logic or invoke standard functions such as date arithmetic. You can perform complex processing or invoke other SOA services or re-usable Java/JavaScript methods. Live API Creator analyzes the logic for dependencies which are reflected in proper execution order.

Events

Rules (above) fire in an order that reflects their dependencies.  This order will change as you alter rules and so affect their dependencies.

By contrast, events (below) fire at designated points in the request processing cycle, as illustrated here:


Custom Endpoints

While most end points are defined as table, views, stored procedures and Custom Resources, you can define Custom Endpoint.  Such custom HTTP Handler to build services perhaps unrelated to your database objects, or, you may wish to convert JSON into the format expected by Custom Resources.

As noted in the diagram, Custom Endpoints can proceed with normal request processing, or they may return directly to the client.   For example, the B2B Demo includes a Custom Endpoint that returns HTML.

Custom Endpoints are not subjected to normal authorization.  This enables you to handle your own authorization, eg, Basic Authorization.

Custom endpoints apply to the RESTful server.

Request Event

Request Events fire before resource and logic processing begin.  For example, you might reformat the request information, as illustrated in the B2B.  You might also wish to log the requests.

JavaScript Resource Type

Automated SQL typically retrieves resources, but you can specify the Resource Type as JavaScript, wherein you supply your own JavaScript to return the JSON. You can materialize data using JavaScript, for example, by invoking REST services to build a request that integrates data from other systems.

Resource Row Event

Resource Row Events are invoked as rows are retrieved. You can inject new attributes or remove attributes or even make REST calls and append results.

Row Logic Events

Table event handlers are invoked with the current/old rows and the current verb on POST, PUT and DELETE operations. They can operate on this row, the results of which is subjected to reactive logic. For an example, see the Business to Business Example.


Request Event (Response)

Request Events provide an entry point after server processing is complete, just before returning to the client.  You can reformat the response message, as illustrated in the Integration Example.  Or, you might log requests.



Supporting Services


The extension capabilities draw upon the following underlying services:

JavaScript Context Variables

Live API Creator initializes the following JavaScript context variables you need for your code to operate:

  • The row object model. A row is a JavaScript object representing the current row, with accessors for attributes and related data, persistence (with logic enforcement).

For more information about row object behavior, see Define Custom REST Resources.

  • The logicContext object. The logicContext object provides services for creating, reading, updating and deleting rows and information about key logic state, including verb and nest level.

For more information about the LogicContext object, see LogicContext object.

  • You also have access to System Methods, such as allocate and copy.

For more information about System Methods, see System Methods.

For more information about the JavaScript context variables that are set when JavaScript logic is invoked, see Quick Reference.

Logic Libraries

Logic libraries can be JavaScript or Java JAR files. JavaScript invocations typically provide the row and logic context for your programmatic access. In many cases, you will want to utilize libraries of existing functions, such as date routines.

You can include your own libraries by uploading them. For more information about adding and using logic libraries, see Logic Libraries.

Re-usable Rule Types

You can add new Rule Types to the core rules (Formula, Sum, Count, Validation and so forth). You can define the parameters the rule types accept. The Logic Designers uses the parameters to use an extended rule. You can detect logic patterns and implement re-usable solutions to these using the Extended Rule Types.

For more information about viewing an illustration of how the InsertIntoFrom and allocation rules use this underlying technology, see Insert Into From and Allocation.

Customized SQL

Custom SQL

You can supply your own SQL for updatable objects using resources with a Type of Custom SQL. Your SQL must return the columns modeled by the resource.

Free SQL

You can define Resources with a type of Free SQL. Use this to supply your own SQL, without restriction.

Request Meta Data

You can use services to Insert @metadata action tags to link child rows to parent rows, without the requirement for the client to supply autonum identifiers (which they may not know). Related services enable you to designate that request rows can result in either an update of an existing row, or (if not present, the insertion of a new row.

For more information:

  • About viewing an example of how to link child rows to parent rows using metadata tags, see the Business to Business Example.
  • About the services you can use, such as the logicContext object and System Methods, see Quick Reference.

Admin Data Access

Observe that the Admin data Live Creator API uses is accessed by way of an API. So, in addition to creating APIs using the browser, you can drive it with RESTful calls.

For more information: