Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Add type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
unindented committed Apr 6, 2016
1 parent 81d95dd commit 0e7615f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.1",
"description": "Normalizes JSON according to schema for Flux application",
"main": "lib/index.js",
"typings": "typings.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/gaearon/normalizr.git"
Expand Down
67 changes: 67 additions & 0 deletions typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
interface EntitySchemaOptions {
idAttribute?: string | Function;
}

interface IterableSchemaOptions {
schemaAttribute?: string | Function;
}

interface UnionSchemaOptions {
schemaAttribute?: string | Function;
}

type NormalizeOptions = {
assignEntity?: Function;
mergeIntoEntity?: Function;
}

type NormalizeInput = Object | Array<Object>;

type NormalizeOutput = {
result: any;
entities?: any;
}

class EntitySchema {
constructor (key: string, options?: EntitySchemaOptions);

define(schema: SchemaMap): this;
mappedBy(attr: string): this;
getKey(): string;
getIdAttribute(): string;
}

class IterableSchema {
}

class UnionSchema {
}

type SchemaValue = EntitySchema | IterableSchema | UnionSchema | SchemaMap;

interface 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;

export {EntitySchema as Schema};

0 comments on commit 0e7615f

Please sign in to comment.