diff --git a/client/src/common/types/entities.ts b/client/src/common/types/entities.ts index fabef218..ccd33449 100644 --- a/client/src/common/types/entities.ts +++ b/client/src/common/types/entities.ts @@ -1,3 +1,73 @@ // If a globally shared type or interface doesn't have a clear owner, put it here export {}; + +export interface AnnotationColumn { + categories?: Category[]; + name: string; + type: "string" | "float32" | "int32" | "categorical" | "boolean"; + writable: boolean; +} + +interface DataFrame { + nObs: number; + nVar: number; + // TODO(thuang): Not sure what other types are available + type: "float32"; +} + +export interface LayoutColumn { + dims: string[]; + name: string; + // TODO(thuang): Not sure what other types are available + type: "float32"; +} +interface RawLayout { + obs: LayoutColumn[]; + var?: LayoutColumn[]; +} + +interface RawAnnotations { + obs: { + columns: AnnotationColumn[]; + index: string; + }; + var: { + columns: AnnotationColumn[]; + index: string; + }; +} + +export interface RawSchema { + annotations: RawAnnotations; + dataframe: DataFrame; + layout: RawLayout; +} + +interface Annotations extends RawAnnotations { + obsByName: { [name: string]: AnnotationColumn }; + varByName: { [name: string]: AnnotationColumn }; +} + +interface Layout extends RawLayout { + obsByName: { [name: string]: LayoutColumn }; + varByName: { [name: string]: LayoutColumn }; +} + +export interface Schema extends RawSchema { + annotations: Annotations; + layout: Layout; +} + +export type TypedArray = + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | Float32Array + | Float64Array; + +export type NumericArray = TypedArray | Array;