uiApplyCompactInputSchema function

Json uiApplyCompactInputSchema()

The compact ui_apply input schema: the op envelope, strictly (op names, field names and kinds from EditOp.specs); a node is any object, its contents described by the starter and checked by validation.

Implementation

Json uiApplyCompactInputSchema() {
  final fields = <String, EditOpField>{};
  for (final s in EditOp.specs) {
    for (final f in s.fields) {
      fields.putIfAbsent(f.key, () => f);
    }
  }
  return {
    'type': 'object',
    'required': ['ops'],
    'properties': {
      'ops': {
        'type': 'array',
        'items': {
          'type': 'object',
          'required': ['op'],
          'properties': {
            for (final f in fields.values)
              f.key: f.key == 'op' ? {'enum': [for (final s in EditOp.specs) s.op]} : _fieldSchema(f),
          },
          'additionalProperties': false,
        },
      },
      'baseRev': {'type': 'integer'},
      'atomic': {'type': 'boolean'},
    },
    'additionalProperties': false,
  };
}