OpenSlides/docs/interfaces/autoupdate-service.txt

146 lines
5.3 KiB
Plaintext
Raw Normal View History

2020-03-09 12:25:35 +01:00
/**
2020-03-21 10:01:05 +01:00
* SyntaxError is returned, when the syntax of the request body is wrong.
* This error is returned on the beginning of a request with http-status-code
* 400.
2020-03-09 12:25:35 +01:00
*/
2020-03-21 10:01:05 +01:00
Exception SyntaxError(msg: string);
2020-03-09 12:25:35 +01:00
/**
2020-03-21 10:01:05 +01:00
* JsonError is returned, when the body does not contain valid json. This error
* is returned on the beginning of a request with http-status-code 400.
2020-03-09 12:25:35 +01:00
*/
2020-03-21 10:01:05 +01:00
Exception JsonError(msg: string);
2020-03-09 12:25:35 +01:00
/**
2020-03-21 10:01:05 +01:00
* ValueError is returned, when the value of a field does not have the expected
* format. E.g. there is an indicated relation to a key, but the data are no
* foreign ids/fqids. The exception may happen, if the stream is used at
* runtime, because this cannot be detected when the caller makes the request.
*/
Exception ValueError(msg: string);
/**
* InternalError is an unexpected error on the server side. When it happens at
* the beginning of a request, an http-status-code 500 is used. But it can also
* happen after the first data have been streamed to the client. The error does
* not contain any useful information. More information can be found in the
* server log. This is the only error that generates a server log message.
*/
Expection InternalError(msg: string);
/**
* This methods subscribes to a list of given request. The response is a stream
2020-03-09 12:25:35 +01:00
* (language dependent) updating all models according to the ModelRequest if new
* data is available. On subscription, initial data must be pushed to the caller
* as soon as possible. The stream can be closed by closing the stream (e.g. the
* underlying network connection).
*
2020-03-21 10:01:05 +01:00
* @throws SyntaxError
* @throws JsonError
* @throws ValueError
* @throws InternalError
2020-03-09 12:25:35 +01:00
*/
2020-03-21 10:01:05 +01:00
subscribe(request: ModelRequest[]): stream<ModelData>;
2020-03-09 12:25:35 +01:00
/**
* This is the main interface for requesting models in a structured, nested way.
* The initial request targets some models as the root models of one collection
* with all the same fields. This build a tree of dependencies, because the
2020-03-16 10:41:41 +01:00
* value of some fields may be a GenericRelationFieldDescriptor again.
2020-03-09 12:25:35 +01:00
*
2020-03-21 10:01:05 +01:00
* For a description of `fields` and `collection`, see
* GenericRelationFieldDescriptor and RelationFieldDescriptor.
2020-03-09 12:25:35 +01:00
*
* `ids`: This is a list of ids for a collection, that should be provided. All
* models, that the user can see, must be included in the response. The model
2020-03-16 10:41:41 +01:00
* fields are handled according to `GenericRelationFieldDescriptor`.
2020-03-09 12:25:35 +01:00
*/
2020-03-16 10:41:41 +01:00
Interface ModelRequest extends Fields {
2020-03-09 12:25:35 +01:00
ids: ID[];
collection: Collection;
2020-03-16 10:41:41 +01:00
}
Interface Fields {
2020-03-09 12:25:35 +01:00
fields: {
2020-03-16 10:41:41 +01:00
[field: Field]: GenericRelationFieldDescriptor
| RelationFieldDescriptor
| StructuredFieldDescriptor
| null;
2020-03-09 12:25:35 +01:00
}
}
/**
* For an overview, see `ModelRequest`.
*
2020-03-16 10:41:41 +01:00
* `fields` (inherited from `Fields`, see above):
2020-03-09 12:25:35 +01:00
* Regardless of the value of a field, the restricted values are given in the
* response (multiple for structured fields). If the restricted value is null,
* the field must be included here.
*
* If the value is not null, it is indicated, that there is a reference to
2020-03-16 10:41:41 +01:00
* follow. There are three types of values:
2020-03-21 10:01:05 +01:00
* - GenericRelationFieldDescriptor: The reference is a generic one. This means,
* that the actual value from the model is a fqid or an array of fqids.
* - RelationFieldDescriptor: A collection is given, so it can be expected, that
* the actual model value is an id or an array of ids.
2020-03-16 10:41:41 +01:00
* - StructuredFieldDescriptor: The field is a template field and should be
* handled in this way.
2020-03-09 12:25:35 +01:00
*/
2020-03-16 10:41:41 +01:00
Interface GenericRelationFieldDecriptor extends Fields {
type: 'generic-relation' | 'generic-relation-list';
2020-03-09 12:25:35 +01:00
}
/**
2020-03-21 10:01:05 +01:00
* For an overview, see `ModelRequest`. For `fields`, see
* GenericRelationFieldDescriptor.
2020-03-09 12:25:35 +01:00
*
* `collection`:
* This is the collection, the ids are associated to. The ids are provided with
* two different ways:
* - In a ModelRequest, the ids are given.
* - If this interface is used in a field indication a relation, the id(s) are
* given by the actual model data.
*/
2020-03-16 10:41:41 +01:00
Interface RelationFieldDescriptor extends Fields {
type: 'relation' | 'relation-list';
2020-03-09 12:25:35 +01:00
collection: Collection;
}
2020-03-16 10:41:41 +01:00
/**
* Structured Fields: A field with `$` as a placeholder can be structured. The
* `$` is a template placeholder. The `template field` holds a list of strings
* with options to insert into `$`. All these fields are the `structured
* fields`. Example:
* B_$_ids is the template field. Its value may be `["1", "test"]`, so the
* structured fields are B_1_ids and B_test_ids.
*
* This interface indicates, that there are structured fields related to the
* given template field, that should be resolved. If one would give `B_$_ids:
* null` without using this interface, the response would be just the template
* field `B_$_ids` and no structured fields.
*
* For just resolving values, leav `values` out (hence the optional parameter).
*
* If the values of all structured fields are references, use the `values`
* parameter analog to the `fields` paramter as documented in
* `GenericRelationFieldDescriptor`.
*/
Interface StructuredFieldDecriptor {
2020-03-16 10:41:41 +01:00
type: 'template',
values?: {
[field: Field]: GenericRelationFieldDescriptor
| RelationFieldDescriptor
| StructuredFieldDescriptor
| null;
}
}
2020-03-09 12:25:35 +01:00
/**
2020-03-21 10:01:05 +01:00
* This structure holds all data given by the called service as a map of
* fqfields to the fields values.
2020-03-09 12:25:35 +01:00
*/
Interface ModelData {
2020-03-21 10:01:05 +01:00
[fqfield: Fqfield]: Value;
2020-03-09 12:25:35 +01:00
}