Apps
You can extend Aidbox with custom Apps. The app can define custom resources, custom endpoints, and subscribe to hooks or subscriptions. The app is a standalone service which will work with Aidbox to implement your specific app. App should be registered in Aidbox.
You define the App using Aidbox SDK for your language and should not reverse engineer internal API, because it can be subject to change.

App Resource

To define the App, we should provide the app manifest:
1
resourceType: App
2
id: myorg.myapp # id of your application
3
apiVersion: 1 # App API version
4
type: app
5
endpoint: # communication protocol between aidbox and app
6
type: http-rpc # type of protocol - http-rpc | ws-rpc
7
host: app.mydomain.com # app service host for http protocols
8
scheme: https # app service schema for http protocols - default = https
9
port: 8080 # app service port - default = 80
10
secret: <yoursercret> # will be used to secure aidbox - app communication
11
entities: <Resource's Definitions, Profiles & Hooks>
12
operations: <Operation's Definitions>
13
subscriptions: <Subscriptions>
Copied!

endpoint

In the endpoint section, you describe how Aidbox will communicate with your service.
Key
type
required
Options
default
description
type
string
true
http-rpc | ws-rpc
http-rpc
Protocol of communication
host
string
false
​
​
Domain of service for http protocols
schema
​
​
http | https
https
Schema of service for http
port
integer
​
​
80
Port of service for http
secret
string
​
​
​
Secret key used for communication

entities

In the entities section of the App manifest, you can extend existing resources, define custom profiles, or hook into lifecycle:
entities:
1
Patient: # existing resource type
2
attrs:
3
# here we devine extension `race` for patient
4
race: { extensionUrl: 'https://myapp/race', type: 'code' }
5
hooks: # resource life cycle hooks
6
before_create: # map of hooks <hook-id>: { config-map }
7
notify_on_patient: { emails: ['[email protected]'] }
8
​
Copied!
As well as define custom resources:
entities:
1
User: # custom resource type
2
attrs:
3
email: { type: 'email', isRequred: true }
4
password: { type: 'password' }
5
active: { type: 'boolean' }
6
patient: { type: 'Reference', refers: ['Patient'] }
7
settings:
8
attrs:
9
theme: { type: 'string', enum: ['black', 'white'] }
10
hooks:
11
before_create:
12
check_ldap: {}
13
after_create:
14
save_to_third_paty: {}
15
profiles:
16
user-uniq-email:
17
type: sql
18
query: SELECT true FROM "User" WHERE resource->>'email' == {{ .email }}
19
message: Email is already taken
Copied!
In the entities section, you define resources as a map <resourceType> : <resourceStructure> :
1
entities:
2
Patient: <structure>
3
User: <structure>
4
Payment: <structure>
Copied!
Resource structure is defined by keyword attrs{ <element-name>: <element-definition> ... }
entities:
1
User:
2
attrs:
3
email: <element-definition>
4
password: <element-definition>
5
profiles: <profiles-definition>
6
hooks: <hooks-definition>
Copied!
At the root of resource definition, you can also define hooks and profiles for this resource.
Element definition will be translated into Attribute Meta-Resource and have the following properties:
name
type
Description
type
code
Primitive or Complex Type name

operations

In the operation section, you define Custom REST operations as a map <operation-id>: <operation-definition> and access policy (which will be bound to this operation):
operations:
1
daily-patient-report:
2
method: GET
3
path: ['Patient', '$daily-report', { name: 'date'} ]
4
register-user:
5
method: POST
6
path: [ 'User', '$register' ]
7
policies:
8
register-user: { engine: allow }
Copied!

resources

In the resources section, you can provide other meta-resources for Aidbox in the form {resourceType: {id: resource}}
resources:
1
# resource type
2
AccessPolicy:
3
# resource id
4
public-policy:
5
# resource body
6
engine: allow
7
link:
8
- {id: 'opname', resourceType: 'Operation'}
Copied!

hooks

Aidbox will provide a set of hooks you can hook-in to customize its behavior:
TBD

subscriptions

In the subscription section, you can define subscriptions (a special type of hooks, which do not need a response). You can subscribe to specific life-cycle events of resources filtered by criteria or to changes in search queries.
TBD
Last modified 6mo ago