Add the status field to the Entity envelope

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-05-11 18:31:37 +02:00
parent 8a45504787
commit 68fdbf014e
13 changed files with 183 additions and 13 deletions
+1
View File
@@ -112,6 +112,7 @@ export type Entity = {
metadata: EntityMeta;
spec?: JsonObject;
relations?: EntityRelation[];
status?: Record<string, JsonObject>;
};
// @public
@@ -48,6 +48,14 @@ export type Entity = {
* The relations that this entity has with other entities.
*/
relations?: EntityRelation[];
/**
* The current status of the entity, as claimed by various sources.
*
* The keys are implementation defined and the values can be any JSON object
* with semantics that match that implementation.
*/
status?: Record<string, JsonObject>;
};
/**
+4 -4
View File
@@ -42,11 +42,9 @@ export function generateEntityEtag(): string {
* the next version of this entity.
*
* Significance, in this case, means that we do not compare generated fields
* such as uid, etag and generation, and we only check that no new annotations
* are added or existing annotations were changed (since they are effectively
* merged when doing updates).
* such as uid, etag and generation.
*
* Note that this comparison does NOT take state, relations or similar into
* Note that this comparison does NOT take status, relations or similar into
* account. It only compares the actual input entity data, i.e. metadata and
* spec.
*
@@ -86,7 +84,9 @@ export function entityHasChanges(previous: Entity, next: Entity): boolean {
// Remove things that we explicitly do not compare
delete e1.relations;
delete e1.status;
delete e2.relations;
delete e2.status;
return !lodash.isEqual(e1, e2);
}
@@ -62,6 +62,15 @@
"items": {
"$ref": "common#relation"
}
},
"status": {
"type": "object",
"description": "The current status of the entity, as claimed by various sources.",
"patternProperties": {
"^.+$": {
"$ref": "common#status"
}
}
}
}
}
@@ -29,7 +29,7 @@
"$id": "#relation",
"type": "object",
"description": "A directed relation from one entity to another.",
"required": ["type", "source", "target"],
"required": ["type", "target"],
"additionalProperties": false,
"properties": {
"type": {
@@ -38,13 +38,16 @@
"pattern": "^\\w+$",
"description": "The type of relation."
},
"source": {
"$ref": "#reference"
},
"target": {
"$ref": "#reference"
}
}
},
"status": {
"$id": "#status",
"type": "object",
"description": "A specific status of an entity.",
"additionalProperties": true
}
}
}