This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81d95dd
commit 443b079
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
export type SchemaOptions = { | ||
idAttribute?: string | Function; | ||
} | ||
|
||
export type IterableSchemaOptions = { | ||
schemaAttribute?: string | Function; | ||
} | ||
|
||
export type UnionSchemaOptions = { | ||
schemaAttribute: string | Function; | ||
} | ||
|
||
export type NormalizeOptions = { | ||
assignEntity?: Function; | ||
mergeIntoEntity?: Function; | ||
} | ||
|
||
export type NormalizeInput = Object | Array<Object>; | ||
|
||
export type NormalizeOutput = { | ||
result: any; | ||
entities?: any; | ||
} | ||
|
||
export class Schema { | ||
constructor (key: string, options?: SchemaOptions); | ||
|
||
define(schema: SchemaMap): void; | ||
getKey(): string; | ||
getIdAttribute(): string; | ||
} | ||
|
||
export class IterableSchema { | ||
constructor (schema: SchemaValue, options?: IterableSchemaOptions); | ||
|
||
getItemSchema(): SchemaValue; | ||
} | ||
|
||
export class UnionSchema { | ||
constructor (schema: SchemaValue, options: UnionSchemaOptions); | ||
|
||
getItemSchema(): SchemaValue; | ||
} | ||
|
||
export type SchemaValue = Schema | IterableSchema | UnionSchema | SchemaMap; | ||
|
||
export type SchemaMap = { | ||
[key: string]: SchemaValue; | ||
} | ||
|
||
export function arrayOf( | ||
schema: SchemaValue, | ||
options?: IterableSchemaOptions | ||
): IterableSchema; | ||
|
||
export function valuesOf( | ||
schema: SchemaValue, | ||
options?: IterableSchemaOptions | ||
): IterableSchema; | ||
|
||
export function unionOf( | ||
schema: SchemaValue, | ||
options?: UnionSchemaOptions | ||
): UnionSchema; | ||
|
||
export function normalize( | ||
input: NormalizeInput, | ||
schema: SchemaValue, | ||
options?: NormalizeOptions | ||
): NormalizeOutput; |