@rest-hooks/normalizr
Advanced tools
Comparing version 5.0.4 to 5.0.5
@@ -6,2 +6,12 @@ # Change Log | ||
### [5.0.5](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@5.0.4...@rest-hooks/normalizr@5.0.5) (2020-02-26) | ||
### 🏠 Internal | ||
* readonly should exist on all levels of internal state ([#276](https://github.com/coinbase/rest-hooks/issues/276)) ([a884186](https://github.com/coinbase/rest-hooks/commit/a884186e2696b40ab764979d646089aa625dfe8d)) | ||
* Use Record<string, any> form for POJOs ([dae11b2](https://github.com/coinbase/rest-hooks/commit/dae11b233d4cc3d56ba93f1488a0b42ba7a1dfce)) | ||
### [5.0.4](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@5.0.3...@rest-hooks/normalizr@5.0.4) (2020-02-19) | ||
@@ -8,0 +18,0 @@ |
{ | ||
"name": "@rest-hooks/normalizr", | ||
"version": "5.0.4", | ||
"version": "5.0.5", | ||
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications", | ||
@@ -65,3 +65,3 @@ "homepage": "https://github.com/coinbase/rest-hooks/tree/master/packages/normalizr#readme", | ||
}, | ||
"gitHead": "ba28e839c4636f5f8740e645eaba8bf079ef7b15" | ||
"gitHead": "df8971741c68125fedd83c405ba3139d313aa892" | ||
} |
@@ -14,3 +14,3 @@ declare namespace schema { | ||
) => S; | ||
export type EntityMap<T = any> = { [key: string]: EntityInterface<T> }; | ||
export type EntityMap<T = any> = Record<string, EntityInterface<T>>; | ||
export type UnvisitFunction = (input: any, schema: any) => [any, boolean]; | ||
@@ -29,3 +29,3 @@ export type UnionResult<Choices extends EntityMap> = { | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): any; | ||
@@ -49,3 +49,3 @@ // this is not an actual member, but is needed for the recursive NormalizeNullable<> type algo | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): Normalize<S>[]; | ||
@@ -86,3 +86,3 @@ | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): string; // string is the ReturnType of 'pk' | ||
@@ -105,3 +105,3 @@ | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): string; | ||
@@ -113,5 +113,4 @@ denormalize(entity: any, unvisit: Function): [T, boolean]; | ||
export class Object< | ||
O extends { [key: string]: any } = { [key: string]: Schema } | ||
> implements SchemaClass { | ||
export class Object<O extends Record<string, any> = Record<string, Schema>> | ||
implements SchemaClass { | ||
constructor(definition: O); | ||
@@ -126,3 +125,3 @@ define(definition: Schema): void; | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): NormalizeObject<O>; | ||
@@ -160,3 +159,3 @@ | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): UnionResult<Choices>; | ||
@@ -207,3 +206,3 @@ | ||
addEntity: Function, | ||
visitedEntities: { [key: string]: any }, | ||
visitedEntities: Record<string, any>, | ||
): Record< | ||
@@ -246,15 +245,15 @@ string, | ||
type DenormalizeObject<S extends { [key: string]: any }> = { | ||
type DenormalizeObject<S extends Record<string, any>> = { | ||
[K in keyof S]: S[K] extends Schema ? Denormalize<S[K]> : S[K]; | ||
}; | ||
type DenormalizeNullableObject<S extends { [key: string]: any }> = { | ||
type DenormalizeNullableObject<S extends Record<string, any>> = { | ||
[K in keyof S]: S[K] extends Schema ? DenormalizeNullable<S[K]> : S[K]; | ||
}; | ||
type NormalizeObject<S extends { [key: string]: any }> = { | ||
type NormalizeObject<S extends Record<string, any>> = { | ||
[K in keyof S]: S[K] extends Schema ? Normalize<S[K]> : S[K]; | ||
}; | ||
type NormalizedNullableObject<S extends { [key: string]: any }> = { | ||
type NormalizedNullableObject<S extends Record<string, any>> = { | ||
[K in keyof S]: S[K] extends Schema ? NormalizeNullable<S[K]> : S[K]; | ||
@@ -324,3 +323,5 @@ }; | ||
export type NormalizedIndex = { | ||
[entityKey: string]: { [indexName: string]: { [lookup: string]: string } }; | ||
readonly [entityKey: string]: { | ||
readonly [indexName: string]: { readonly [lookup: string]: string }; | ||
}; | ||
}; | ||
@@ -336,5 +337,6 @@ | ||
S extends Schema = Schema, | ||
E extends { [key: string]: { [key: string]: any } } = { | ||
[key: string]: { [key: string]: any }; | ||
}, | ||
E extends Record<string, Record<string, any>> = Record< | ||
string, | ||
Record<string, any> | ||
>, | ||
R = NormalizeNullable<S> | ||
@@ -348,3 +350,3 @@ >(data: any, schema: S): NormalizedSchema<E, R>; | ||
): | ||
| [Denormalize<S>, true, { [key: string]: { [key: string]: any } }] | ||
| [DenormalizeNullable<S>, false, { [key: string]: { [key: string]: any } }]; | ||
| [Denormalize<S>, true, Record<string, Record<string, any>>] | ||
| [DenormalizeNullable<S>, false, Record<string, Record<string, any>>]; |
157587
3122