namespace vast.fbs.v0;

/// A boolean value that can either be true or false.
table BoolType {}

/// A signed integer.
table IntType {}

/// An unsigned integer.
table CountType {}

/// A floating-point value.
table RealType {}

/// A time interval.
table DurationType {}

/// A point in time.
table TimeType {}

/// A string of characters.
table StringType {}

/// A regular expression.
table PatternType {}

/// An IP address (v4 or v6).
table AddressType {}

/// A CIDR subnet.
table SubnetType {}

/// An enumeration type that can have one specific value.
table EnumerationType {
  fields: [string];
}

/// An ordered sequence of values.
table VectorType {
  type: Type;
}

/// An unordered sequence of values.
table SetType {
  type: Type;
}

/// An associative mapping from keys to values.
table MapType {
  key_type: Type;
  value_type: Type;
}

/// A field in a record.
table RecordField {
  name: string;
  type: Type;
}

/// A list of fields, each of which have a name and type.
table RecordType {
  fields: [RecordField];
}

/// A type with a name.
table AliasType {
  type: Type;
}

/// The sum type of all possible types.
union TypeVariant {
  boolean: BoolType,
  integer: IntType,
  count: CountType,
  real: RealType,
  duration: DurationType,
  time: TimeType,
  string: StringType,
  pattern: PatternType,
  address: AddressType,
  subnet: SubnetType,
  enumeration: EnumerationType,
  vector: VectorType,
  set: SetType,
  map: MapType,
  record: RecordType,
  alias: AliasType
}

/// A key with optional value.
table Attribute {
  key: string;
  value: string;
}

/// The top-level type.
table Type {
  type: TypeVariant;
  name: string;
  attributes: [Attribute];
}

root_type Type;
