Accelerator Platform - Core APIs
The Accelerator Platform Core APIs allow developers to quickly create databases (Organizations), relational tables called Objects, and CRUD API Endpoints with validation and business logic.
Authentication: To test the APIs described below, authentication as a Project Admin in the Accelerator Platform is required. Further information can be found in the Accelerator Platform IAM documentation.
Organizations: Within an Accelerator Platform project, it is possible to create multiple organizations, each of which represents a MongoDB database containing objects. By default, each organization includes two fields: name and domain. The organization metadata is stored in an Object called "Org", which can be extended with additional fields, similar to any other Object.
Objects: Object metadata is stored in a MongoDB collection called "objects" within the organization database. When creating an Object, users can add fields to the object, and define validation rules and business logic for each field. below is a list of all the attributes of an Object.
(Attributes that starts with underscore (_) are read-only and cannot be modified)
_id
ObjectId
This is the unique identifier of the object.
name
string
Every Object name is unique in an organization. It should be in the camelCase format. We can use this name to get data from the object.
containsUsers
boolean
This is an optional attribute. However, if the objective is to store additional user information in an Object, then this value must be set to true. This will allow the user to create an Item in the object in which the _id will be the same as the logged-in user, thereby enforcing a one-to-one relationship between the ‘users’ collection in the auth database and the item collection of the object.
enableVersionHistory
boolean
When this optional field is set to true, the system generates a read-only array field named '_versionHistory' and a read-only string field named '_version' within each item of the Object. The '_version' field begins with '1.0' and increments by 0.1 with each update made to the item. As a result, the previous version of the item is added to the '_versionHistory', allowing users to track the changes made to it.
fields
ObjectArray
"The 'fields' attribute is an array that contains the definitions for all the fields associated with an object. These fields have common attributes such as _id, name, label, type, and validators. The _id and name is unique within an Object. In the case of a choice field, an additional attribute called 'options' is included, which is a string array that lists all the available options. For reference fields, there is an attribute called 'lookup', which will be further explained in the following section where all the different types of fields will be discussed."
_createdAt
Date
This is the date and time when the object was created.
_createdBy
string
This is the email of the user who created the object
_modifiedAt
Date
This is the date and time when the object was last modified
_modifiedBy
string
This is the email of the user who last modified the object.
_collectionName
string
This is the name of the item collection where the object data is stored. The item collection follows a specific syntax: <first_8_characters_of_object_name>_<object_id>
Below is a comprehensive list of field types supported by the Accelerator Platform, along with the validators applicable to each field type. Note that the data type refers to the value type of the field.
Common Validators:
isRequired: When set to true, this validator prohibits null or empty string values from being inserted or edited in the field of an object's item. This validator is applicable to all field types.
isUnique: When set to true, the value of the field must be unique in the object's item collection. this validator is applicable for text, number, date, and email fields.
regex: This validator is used to validate text and email fields using a regular expression.
text
string
isRequired,
isUnique,
regex,
minChars,
maxChars
To restrict the length of characters in a text field use ‘minChars’ and ‘maxChars’ validators.
Sample Field: {
"type": "text",
"name": "name",
"label": "Patient Name",
"validators": {
"isRequired": true,
"minChars": 3,
"maxChars": 50
}
}
number
integer/double
isRequired,
isUnique,
regex,
min,
max,
isInteger
The number field is capable of storing rational numbers. To only allow integers, set the 'isInteger' to true. To limit the range of values for the number field, use the 'min' and 'max' validators.
Sample Field:
{
"type": "number",
"name": "contactNo",
"label": "Patient Contact No",
"validators": {
"regex": "^[0-9]{10}$",
"isRequired": true
}
}
date
date
isRequired,
isUnique,
minDate,
maxDate
The date field accepts dates in a string format conforming to ISO 8601 standards. To define a date range, use the 'minDate' and 'maxDate' validators, which should be formatted in the same ISO 8601 format. Additionally, it is possible to set either value to 'Today' which will compare the date field value with the date and time when an item is being inserted or edited. For instance, if a date field stores a person's date and time of birth, the 'maxDate' validator can be set to 'Today' to ensure that the date and time of birth is not later than the date and time when the item is being inserted. Sample FIelds: {
"type": "date",
"name": "dob",
"label": "Date of Birth",
"validators": {
"isRequired": true,
"minDate": "1900-12-25",
"maxDate": "Today"
}
}
string
isRequired,
isUnique,
regex
Sample Field: {
"type": "email",
"name": "email",
"label": "Email",
"validators": {
"isRequired": true,
"isUnique": true,
"regex": "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"
}
}
choice
string
isRequired,
isSingleChoice
When there is a need to store a selection of values from a range of options, a choice field can be used. For all choice fields, it is mandatory to provide the 'options' attribute, which is an array of strings that contains all the available options. To insert multiple values into this field, use a comma-separated string format such as "option1, option2, option3". Additionally, it is possible to apply the ‘isSingleChoice’ validator to only allow one option to be selected.
Sample Field:
{
"type": "choice",
"name": "gender",
"label": "Gender",
"options": [ "Male", "Female" ],
"validators": {
"isRequired": true,
"IsSingleChoice": true
}
}
file
string
isRequired,
maxFileSize,
minFileSize allowedFileTypes
To insert an item that contains a file field, a two-step process is required. First, the file(s) must be uploaded using the UploadFiles API endpoint, which returns a list of IDs of the uploaded files. These IDs can then be used as the file field value when inserting an item. To limit the file size, validators such as "maxFileSize" and "minFileSize" can be used, which accept file sizes in the format of 100.0 KB, 1.0 MB, or 1.0 GB. It’s also possible to allow only a certain types of files using the “allowedFileTypes” validator, accept an array of file extensions
e. g. [ ".jpg", ".png", ".pdf" ].
Sample Field:
{
"type": "file",
"name": "profilePic",
"label": "Upload a Profile Picture",
"validators": {
"isRequired": true,
"minFileSize": "1.5 KB",
"maxFileSize": "1.5 MB",
"allowedFileTypes": [ "jpeg", "png", "jpg" ]
}
}
reference
string
isRequired
In the Accelerator Platform, a Reference field in an Object is capable of storing the '_id' of an Item from another Object within the same Organization. Whenever an Item with a reference field is retrieved, the '_id' allows the retrieval of additional information from the referenced Item. Therefore, the "lookup" attribute is mandatory for reference fields. This attribute is a JSON object that includes the "ObjectId" to hold the Id of the reference object and "returnedFields", an array of fields from the reference object that we want to retrieve when fetching the item. Sample Field:
{
"type": "reference",
"name": "provider",
"label": "Provider",
"validators": {
"isRequired": true
},
"lookup":{
"ObjectId": "<Providers-Object-Id>",
"returnedFields": [ "name", "email" ]
}
} Sample Item: {
"provider": "<Provider-Item-Id>" }
array
JSON Array
isRequired
This Field is used to store JSON Array
Sample Field: {
"type": "array",
"name": "symptoms",
"label": "Symptoms"
}
Sample Item: { "symptoms": [ "Fever", "Cough" ]
}
object
JSON Object
isRequired
This Field is used to store JSON Object Sample Field:
{
"type": "object",
"name": "address",
"label": "Address",
}
Sample Item: { "address": {
"addressLine": "Address Line ", city": "City", …
} }
Field Level Encryption: To encrypt a Field's value, set the "isEncrypted" attribute to true. This will store the value in an unreadable format
Example 2:
Use-case: To understand the functionalities of the Accelerator Platform, We will be implementing the following use case.
We have a organization called Clinic.
There are two type of user Providers and Patients.
Providers can invite a Patients
After Register and Login, users can insert and update their personal information.
Providers can view only those Patients that they are associated with.
Patients can view all the Providers in the Clinic.
In Example 1, we created the organization. Now we are ready to create the Objects
Step2. Create Provider Object
Note that the containsUsers flag is set to true. Since Provider object will store Provider’s user information that may not be there in the users collection of the auth database.
Note: In the Patients object, there is a reference field.
Step 4. Add Items to Object: After the Provider Registration and Login we are ready to insert Item into the Provider Object
Please note that to create an item, the Object's name is utilized in the request URL, and the JSON object of the item is constructed using the field names of the Object. As the AddItems API endpoint receives a list of items, the JSON object is enclosed within a JSON list.
Step 6. In the same way add Patients
Since the Patient Role has Policy that provide read access to “_id”, “name”, and “email” fields of all the Providers, You can get a <provider-item-id> by using the GetItems API endpoint with the Patient’s auth token
As there is a reference to providers in Patients, In the response the provider field of the items should include the _id, name, and email of the providers, where the _id matches the "<provider-item-Id>".
You can add more Providers and assign more Patients to them. Observe which Providers can access which Patients.
Last updated