Comparing version 1.11.0 to 1.12.0
@@ -9,3 +9,3 @@ import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonaDenormalizedIncludeNames, TJsonaNormalizedIncludeNamesTree, TJsonaUniqueIncluded, IModelPropertiesMapper, IModelsSerializer } from '../JsonaTypes'; | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper): void; | ||
setStuff(stuff: any): void; | ||
setStuff(stuff: TJsonaModel | TJsonaModel[]): void; | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree): void; | ||
@@ -12,0 +12,0 @@ build(): TJsonApiBody; |
@@ -47,13 +47,13 @@ type AtLeastOneProperty<T, U = { | ||
export interface IJsonDeserializerConstructor { | ||
new (propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options: any): any; | ||
new (propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options?: TDeserializeOptions): IJsonaDeserializer; | ||
} | ||
export interface IModelsSerializer { | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper): any; | ||
setStuff(stuff: any): any; | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree): any; | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper): void; | ||
setStuff(stuff: TJsonaModel | TJsonaModel[]): void; | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree): void; | ||
build(): TJsonApiBody; | ||
buildDataByModel(model: TJsonaModel | null): TJsonApiData; | ||
buildRelationshipsByModel(model: TJsonaModel): any; | ||
buildRelationshipsByModel(model: TJsonaModel): TJsonApiRelationships; | ||
buildIncludedByModel(model: TJsonaModel, includeTree: TJsonaNormalizedIncludeNamesTree, builtIncluded: TJsonaUniqueIncluded): void; | ||
buildIncludedItem(relationModel: TJsonaModel, subIncludeTree: TJsonaNormalizedIncludeNamesTree, builtIncluded: TJsonaUniqueIncluded): any; | ||
buildIncludedItem(relationModel: TJsonaModel, subIncludeTree: TJsonaNormalizedIncludeNamesTree, builtIncluded: TJsonaUniqueIncluded): void; | ||
} | ||
@@ -85,2 +85,3 @@ export interface IModelsSerializerConstructor { | ||
meta?: TAnyKeyValueObject; | ||
[propertyName: string]: any; | ||
}; | ||
@@ -115,7 +116,4 @@ type FullTJsonApiRelation = { | ||
}; | ||
export type TResourceIdObj = { | ||
id?: string | number; | ||
export type TResourceIdObj = TJsonApiRelationshipData & { | ||
type: string; | ||
meta?: unknown; | ||
[propertyName: string]: any; | ||
}; | ||
@@ -122,0 +120,0 @@ export type TJsonaRelationshipBuild = () => (TJsonaModel | Array<TJsonaModel>); |
{ | ||
"name": "jsona", | ||
"description": "Provide data formatters (data model builder & json builder) to work with JSON API specification v1.0 in your JavaScript / TypeScript code", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"keywords": [ | ||
@@ -58,8 +58,8 @@ "json-api", | ||
"clean": "rm -rf ./lib/*", | ||
"compile": "./node_modules/.bin/tsc", | ||
"precompile": "npm run clean", | ||
"preversion": "npm run compile && npm test", | ||
"test-compile": "tsc --p tsconfig.test.json", | ||
"test": "npm run test-compile && env NODE_ENV=test ts-mocha ./**/*.test.ts" | ||
"build": "./node_modules/.bin/tsc", | ||
"prebuild": "npm run clean", | ||
"preversion": "npm run build && npm test", | ||
"test-build": "tsc --p tsconfig.test.json", | ||
"test": "npm run test-build && env NODE_ENV=test ts-mocha ./**/*.test.ts" | ||
} | ||
} |
@@ -8,3 +8,4 @@ import { | ||
IJsonaDeserializer, | ||
IDeserializeCache, TResourceIdObj, | ||
IDeserializeCache, | ||
TResourceIdObj, | ||
} from '../JsonaTypes'; | ||
@@ -11,0 +12,0 @@ |
@@ -9,3 +9,3 @@ import { | ||
IModelPropertiesMapper, | ||
IModelsSerializer | ||
IModelsSerializer, | ||
} from '../JsonaTypes'; | ||
@@ -31,3 +31,3 @@ | ||
setStuff(stuff) { | ||
setStuff(stuff: TJsonaModel | TJsonaModel[]) { | ||
this.stuff = stuff; | ||
@@ -66,9 +66,9 @@ } | ||
data.push( | ||
this.buildDataByModel(stuff[i]) | ||
this.buildDataByModel(stuff[i]) | ||
); | ||
this.buildIncludedByModel( | ||
stuff[i], | ||
this.includeNamesTree, | ||
uniqueIncluded | ||
stuff[i], | ||
this.includeNamesTree, | ||
uniqueIncluded | ||
); | ||
@@ -83,5 +83,5 @@ } | ||
this.buildIncludedByModel( | ||
stuff, | ||
this.includeNamesTree, | ||
uniqueIncluded | ||
stuff, | ||
this.includeNamesTree, | ||
uniqueIncluded | ||
); | ||
@@ -154,5 +154,5 @@ } else if (stuff === null) { | ||
console.error( | ||
`Can't create data item for relationship ${k}, | ||
`Can't create data item for relationship ${k}, | ||
it doesn't have 'id' or 'type', it was skipped`, | ||
relationItem | ||
relationItem | ||
); | ||
@@ -174,4 +174,4 @@ } | ||
console.error( | ||
`Can't create data for relationship ${k}, it doesn't have 'type', it was skipped`, | ||
relation | ||
`Can't create data for relationship ${k}, it doesn't have 'type', it was skipped`, | ||
relation | ||
); | ||
@@ -190,5 +190,5 @@ } | ||
buildIncludedByModel( | ||
model: TJsonaModel, | ||
includeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded = {} | ||
model: TJsonaModel, | ||
includeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded = {} | ||
): void { | ||
@@ -227,5 +227,5 @@ if (!includeTree || !Object.keys(includeTree).length) { | ||
buildIncludedItem( | ||
relationModel: TJsonaModel, | ||
subIncludeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
relationModel: TJsonaModel, | ||
subIncludeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
) { | ||
@@ -232,0 +232,0 @@ const id = this.propertiesMapper.getId(relationModel); |
@@ -48,22 +48,22 @@ type AtLeastOneProperty<T, U = {[K in keyof T]: Pick<T, K> }> = Partial<T> & U[keyof U]; | ||
export interface IJsonDeserializerConstructor { | ||
new(propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options); | ||
new(propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options?: TDeserializeOptions): IJsonaDeserializer; | ||
} | ||
export interface IModelsSerializer { | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper); | ||
setStuff(stuff); | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree); | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper): void; | ||
setStuff(stuff: TJsonaModel | TJsonaModel[]): void; | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree): void; | ||
build(): TJsonApiBody; | ||
buildDataByModel(model: TJsonaModel | null): TJsonApiData; | ||
buildRelationshipsByModel(model: TJsonaModel); | ||
buildRelationshipsByModel(model: TJsonaModel): TJsonApiRelationships; | ||
buildIncludedByModel( | ||
model: TJsonaModel, | ||
includeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
model: TJsonaModel, | ||
includeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
): void; | ||
buildIncludedItem( | ||
relationModel: TJsonaModel, | ||
subIncludeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
); | ||
relationModel: TJsonaModel, | ||
subIncludeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
): void; | ||
} | ||
@@ -88,2 +88,3 @@ | ||
export type TJsonApiData = { | ||
@@ -100,4 +101,5 @@ type: string; | ||
type: string; | ||
id: string|number; | ||
id: string | number; | ||
meta?: TAnyKeyValueObject | ||
[propertyName: string]: any | ||
}; | ||
@@ -119,3 +121,3 @@ | ||
export type TJsonApiLinks = { | ||
[key in LinkKey]?: LinkObjectMember; | ||
[key in LinkKey]?: LinkObjectMember; | ||
}; | ||
@@ -162,10 +164,8 @@ | ||
export type TResourceIdObj = { | ||
id?: string | number, | ||
export type TResourceIdObj = TJsonApiRelationshipData & { | ||
type: string, | ||
meta?: unknown, | ||
[propertyName: string]: any | ||
}; | ||
export type TJsonaRelationshipBuild = () => (TJsonaModel | Array<TJsonaModel>); | ||
export type TJsonaRelationships = { | ||
@@ -172,0 +172,0 @@ [relationName: string]: TJsonaRelationshipBuild | TJsonaModel | Array<TJsonaModel> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139281
2377