class RecordsBlockSchema(BundleBlockSchema): mode = fields.Constant(BlockModes.record_block) bundles_spec = fields.Nested(BundlesSpecSchema, required=True) status = fields.Nested(FetchStatusSchema, required=True) header = fields.Constant(('key', 'value')) rows = fields.Nested(RecordsRowSchema, many=True, required=True)
class RecordsBlockSchema(BundleBlockSchema): mode = fields.Constant(BlockModes.record_block) bundles_spec = fields.Nested(BundlesSpecSchema, required=True) status = fields.Nested(FetchStatusSchema, required=True) header = fields.Constant(('key', 'value')) rows = fields.Nested(RecordsRowSchema, many=True, required=True) sort_keys = fields.List(fields.Integer()) first_bundle_source_index = fields.Integer( ) # index for the first bundle in source using_schemas = fields.List(fields.String())
class TableBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.table_block) bundles_spec = fields.Nested(BundlesSpecSchema, required=True) status = fields.Nested(FetchStatusSchema, required=True) header = fields.List(fields.String(), required=True) rows = fields.List(fields.Dict(), required=True)
class MarkupBlockSchema(WorksheetBlockSchema): """ Schema for blocks that contain markup. Does not need refining, contains markup text as payload. """ mode = fields.Constant(BlockModes.markup_block) is_refined = fields.Bool(validate=validate.Equal(True)) # always refined text = fields.String()
class GraphBlockSchema(BundleBlockSchema): mode = fields.Constant(BlockModes.graph_block) bundles_spec = fields.Nested(BundlesSpecSchema, required=True) status = fields.Nested(FetchStatusSchema, required=True) trajectories = fields.Nested(GraphTrajectorySchema, many=True, required=True) max_lines = fields.Integer() xlabel = fields.String() ylabel = fields.String()
class BundleImageBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.BUNDLE_IMAGE_MODE) path = fields.String() bundle = fields.Relationship( include_resource_linkage=True, type_='bundles', attribute='bundle_uuid', allow_none=True ) max_lines = fields.Integer() status = fields.Nested(FetchStatusSchema) image_data = fields.String()
class TableBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.table_block) bundles_spec = fields.Nested(BundlesSpecSchema, required=True) status = fields.Nested(FetchStatusSchema, required=True) header = fields.List(fields.String(), required=True) rows = fields.List(fields.Dict(), required=True) sort_keys = fields.List(fields.Integer()) first_bundle_source_index = fields.Integer( ) # index for the first bundle in source using_schemas = fields.List(fields.String())
class SchemaBlockSchema(WorksheetBlockSchema): """ Schema for user-defined schemas in worksheets """ mode = fields.Constant(BlockModes.schema_block) schema_name = fields.String(required=True) header = fields.List(fields.String(), required=True) field_rows = fields.List(fields.Dict(), required=True) sort_keys = fields.List(fields.Integer()) ids = fields.List(fields.Integer())
class BundleContentsBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.BUNDLE_CONTENTS_MODE) path = fields.String() bundle = fields.Relationship( include_resource_linkage=True, type_='bundles', attribute='bundle_uuid', allow_none=True ) max_lines = fields.Integer() status = fields.Nested(FetchStatusSchema) files = fields.List(fields.String()) lines = fields.List(fields.String())
class BundleUUIDSpecSchema(BundlesSpecSchema): spec_type = fields.Constant(BundlesSpecSchema.uuid_spec_type) uuid_spec = fields.List(fields.String(), required=True) @staticmethod def create_json(bundle_infos): return { 'spec_type': BundlesSpecSchema.uuid_spec_type, 'uuid_spec': [bundle_info['uuid'] for bundle_info in bundle_infos], 'bundle_infos': bundle_infos, 'fetch_status': FetchStatusSchema.get_ready_status(), }
class MarkupBlockSchema(WorksheetBlockSchema): """ Schema for blocks that contain markup. Does not need refining, contains markup text as payload. """ ids = fields.List(fields.Integer()) sort_keys = fields.List(fields.Integer()) mode = fields.Constant(BlockModes.markup_block) is_refined = fields.Bool(validate=validate.Equal(True)) # always refined text = fields.String() error = fields.Bool(default=False) # True if the markdown shows an error
class PlaceholderBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.placeholder_block) directive = fields.String() sort_keys = fields.List(fields.Integer())
class SubworksheetsBlock(WorksheetBlockSchema): mode = fields.Constant(BlockModes.subworksheets_block) subworksheet_infos = fields.List(fields.Dict, required=True) sort_keys = fields.List(fields.Integer())
class BundleImageBlockSchema(BundleBlockSchema): mode = fields.Constant(BlockModes.image_block) image_data = fields.String() height = fields.Integer() width = fields.Integer()
class BundleContentsBlockSchema(BundleBlockSchema): mode = fields.Constant(BlockModes.contents_block) max_lines = fields.Integer() lines = fields.List(fields.String())
class MarkupBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.MARKUP_MODE) is_refined = fields.Bool(validate=validate.Equal(True)) # always refined text = fields.String()
class TableBlockSchema(WorksheetBlockSchema): mode = fields.Constant(BlockModes.TABLE_MODE) table_schema = fields.Nested(TableSchemaItemSchema, many=True) header = fields.List(fields.String())