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 2ca4089
Show file tree
Hide file tree
Showing 2 changed files with 67 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
66 changes: 66 additions & 0 deletions typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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): void;
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 2ca4089

Please sign in to comment.