Model Configuration
HCMS is based on a JSON model configuration. Its intent is to define from a JSON configuration an API usable by any of your client applications (often single page applications).
TIP
|
pages about the environment setup - datasource, server, ... - are on the configuration deployment pages. |
Get completion
Before starting to dig into the model itself, it is important to be properly setup. As soon as you get an IDE/editor with JSON schema support/completion you can just create a documentation (model.json
) and inject the schema reference in it: JSON-Schema
.
Here is a basic document:
{
"$schema": "https://www.yupiik.io/hcms/schema/model.jsonschema.json"
}
Configuration concept
The configuration is focused on two concepts:
-
Entities,
-
JSON-RPC mapping.
The entity (a.k.a. EntitySpec
) defines what is an entity - columns, how it is mapped to SQL and what is allowed or not on it.
The JSON-RPC mapping just links an entity to JSON-RPC method(s). For example linking an entity to a JSON-RPC type CRUD
will define the methods $entity.findById
, $entity.findAll
, $entity.create
, $entity.update
, $entity.deleteById
.
TIP
|
since JSON-RPC supports bulking (send multiple requests as arrays), the |
Configuration reference
HCMS Model Schema
Name | Type | Nullable | Description |
---|---|---|---|
enableOpenAPI |
boolean |
true |
Should |
enableOpenRPC |
boolean |
true |
Should |
enableSwaggerUI |
boolean |
true |
Should |
entities |
array with items of type unknown |
false |
Entities to define and make available for JSON-RPC methods. |
jsonRpcMethods |
array with items of type unknown |
false |
JSON-RPC methods to register. |
partialOpenRPC |
object of type |
true |
OpenRPC partial object, should generally set the |
sql |
array with items of type |
false |
List of SQL scripts to execute at model load time. |
$schema |
string |
false |
- |
JsonRpcMethod schema
Name | Type | Nullable | Description |
---|---|---|---|
description |
string |
true |
OpenRPC description. |
entityName |
string |
true |
Name of the entity to use to generate the JSON-RPC methods. |
security |
unknown |
true |
Security model for this method(s) registration(s). If not set, default is equivalent to anonymous access. |
type |
enum with potential values |
true |
Type of JSON-RPC method generation. |
ImplicitFiltering schema
Name | Type | Nullable | Description |
---|---|---|---|
clause |
string |
true |
Filtering clause(s), ex: |
SecurityValidation schema
Name | Type | Nullable | Description |
---|---|---|---|
anonymous |
boolean |
false |
Can anyone call the endpoint without any validation, not even a JWT. |
logged |
boolean |
false |
Can anyone authenticated call this endpoint - requires a valid JWT. |
roles |
array with items of type |
false |
Requires one of this list roles to be in the roles of the JWT. At least one role from the JWT ( |
JsonSchema schema
Name | Type | Nullable | Description |
---|---|---|---|
exclusiveMaximum |
integer |
true |
For |
exclusiveMinimum |
integer |
true |
For |
format |
enum with potential values |
true |
For |
items |
unknown |
true |
As of today defining an array is not supported, will come in the future. |
maxLength |
integer |
true |
For |
maximum |
integer |
true |
For |
minLength |
integer |
true |
For |
minimum |
integer |
true |
For |
multipleOf |
integer |
true |
For |
pattern |
string |
true |
For |
properties |
object of type |
true |
For |
required |
array with items of type |
false |
Required attributes for objects. |
type |
array with items of type |
false |
Type for the schema, for entities it is normally |
EntitySpec schema
Name | Type | Nullable | Description |
---|---|---|---|
allowedSortKeys |
array with items of type |
false |
List of (JSON) properties which are enabled to sort the |
allowedWhereKeys |
array with items of type |
false |
List of (JSON) properties which are enabled to filter the |
allowedWhereOperators |
array with items of type |
false |
The where operators which can be used in |
autoGeneratedIds |
boolean |
false |
If |
generatedCreateFields |
object of type |
true |
Field generated at |
generatedUpdateFields |
object of type |
true |
Field generated at |
identifierNames |
array with items of type |
false |
List of properties representing the identifiers of the entity - JSON names, if ignored and properties has an |
implicitFiltering |
unknown |
true |
Implicit where clause entries, note that create will need to use |
jsonSchema |
unknown |
true |
Simplified JSON-Schema definition for the entity and JSON-RPC related endpoints. |
name |
string |
true |
Entity name - identifier. |
naming |
enum with potential values |
true |
How to transform properties name to get database names from JSON-RPC ones. No-op if ignored. |
revisionProperty |
string |
true |
Name of the field used to manage the versioning. If not set there is no revision (only a snapshot of the entity). If set the targetting field if should target either a number or a date ( |
tableName |
string |
true |
Database table name. |
validateWithJsonSchema |
boolean |
false |
For |
JsonRpcMethodSecurity schema
Name | Type | Nullable | Description |
---|---|---|---|
create |
unknown |
true |
Security for creation access ( |
delete |
unknown |
true |
Security for deletion access ( |
update |
unknown |
true |
Security for creation access ( |
view |
unknown |
true |
Security for view access ( |
EntityImplicitFiltering schema
Name | Type | Nullable | Description |
---|---|---|---|
delete |
unknown |
true |
Where clause (without |
update |
unknown |
true |
Where clause (without |
view |
unknown |
true |
Where clause (without |