|
| 1 | +export type SchemaOptions = { |
| 2 | + idAttribute?: string | Function; |
| 3 | +} |
| 4 | + |
| 5 | +export type IterableSchemaOptions = { |
| 6 | + schemaAttribute?: string | Function; |
| 7 | +} |
| 8 | + |
| 9 | +export type UnionSchemaOptions = { |
| 10 | + schemaAttribute: string | Function; |
| 11 | +} |
| 12 | + |
| 13 | +export type NormalizeOptions = { |
| 14 | + assignEntity?: Function; |
| 15 | + mergeIntoEntity?: Function; |
| 16 | +} |
| 17 | + |
| 18 | +export type NormalizeInput = Object | Array<Object>; |
| 19 | + |
| 20 | +export type NormalizeOutput = { |
| 21 | + result: any; |
| 22 | + entities?: any; |
| 23 | +} |
| 24 | + |
| 25 | +export class Schema { |
| 26 | + constructor (key: string, options?: SchemaOptions); |
| 27 | + |
| 28 | + define(schema: SchemaMap): void; |
| 29 | + getKey(): string; |
| 30 | + getIdAttribute(): string; |
| 31 | +} |
| 32 | + |
| 33 | +export class IterableSchema { |
| 34 | + constructor (schema: SchemaValue, options?: IterableSchemaOptions); |
| 35 | + |
| 36 | + getItemSchema(): SchemaValue; |
| 37 | +} |
| 38 | + |
| 39 | +export class UnionSchema { |
| 40 | + constructor (schema: SchemaValue, options: UnionSchemaOptions); |
| 41 | + |
| 42 | + getItemSchema(): SchemaValue; |
| 43 | +} |
| 44 | + |
| 45 | +export type SchemaValue = Schema | IterableSchema | UnionSchema | SchemaMap; |
| 46 | + |
| 47 | +export type SchemaMap = { |
| 48 | + [key: string]: SchemaValue; |
| 49 | +} |
| 50 | + |
| 51 | +export function arrayOf( |
| 52 | + schema: SchemaValue, |
| 53 | + options?: IterableSchemaOptions |
| 54 | +): IterableSchema; |
| 55 | + |
| 56 | +export function valuesOf( |
| 57 | + schema: SchemaValue, |
| 58 | + options?: IterableSchemaOptions |
| 59 | +): IterableSchema; |
| 60 | + |
| 61 | +export function unionOf( |
| 62 | + schema: SchemaValue, |
| 63 | + options?: UnionSchemaOptions |
| 64 | +): UnionSchema; |
| 65 | + |
| 66 | +export function normalize( |
| 67 | + input: NormalizeInput, |
| 68 | + schema: SchemaValue, |
| 69 | + options?: NormalizeOptions |
| 70 | +): NormalizeOutput; |
0 commit comments