README
Models
Contains model definitions for the REST API.
Testing
Install dependencies
npm i
Run the tests
npm test
JSON-LD Entity Definitions
All entities require a 'context' which explicitly types their JSON representation. The version is used to express schema changes per entity. This is inspired by JSON-LD.
ApiIndex
Describes entry points of an API.
{
"$context": "https://github.com/nRFCloud/models#ApiIndex",
"$contextVersion": 1,
"links": [
{
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://foo.iot.us-east-1.amazonaws.com",
"subject": "https://aws.amazon.com/iot-platform/",
"rel": "production"
},
{
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://bar.execute-api.us-east-1.amazonaws.com/prod",
"subject": "https://nrfcloud.com/",
"rel": "production"
}
]
}
JSON Schema: ApiIndex.json
Source: ApiIndex.ts
Link
Describes a link.
{
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://api.nrfcloud.com/stage/custom-cards/foo/some-id",
"subject": "https://github.com/nRFCloud/models#CustomCard",
"rel": "next"
}
JSON Schema: Link.json
Source: Link.ts
Status
Describes the status of the system.
{
"$context": "https://github.com/nRFCloud/models#Status",
"$contextVersion": 1,
"maintenance": false,
"version": "1.0.0-beta.1",
"time: "2017-10-02T11:05:46.793Z"
}
JSON Schema: Status.json
Source: Status.ts
List
Describes a list.
{
"$context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#List",
"$contextVersion": 1,
items: [
{
"$context": "...",
"$contextVersion": ...,
...
}
],
total: 1,
links: [
{
"$context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#Link",
"$contextVersion": 1,
"href": "...",
"subject": "...",
"rel": "next"
}
]
}
JSON Schema: Link.json
Source: Link.ts
Errors
HttpProblem
All error responses are expressed using this message format. See https://datatracker.ietf.org/doc/draft-ietf-appsawg-http-problem/.
{
"$context" : "https://www.ietf.org/id/draft-ietf-appsawg-http-problem-01.txt",
"$contextVersion" : 1,
"type" : "https://github.com/nRFCloud/models#EntityNotFoundError",
"title" : "Entity not found",
"status" : 404,
"detail" : "EntityNotFoundError: Custom card \"foo\" does not exist!"
}
JSON Schema: HttpProblem.json
Source: HttpProblem.ts
AccessDeniedError
Thrown if the access to a resource was denied.
BadRequestError
Thrown if the request was malformed.
EntityNotFoundError
Thrown if a requested resource could not be found.
InternalError
Thrown if an unexpected internal error happened.