Comparing version 1.5.2 to 1.6.0
@@ -1,3 +0,3 @@ | ||
import { IJsonPropertiesMapper, TJsonaModel, TJsonaRelationships, TJsonApiBody, TJsonApiData, IJsonaModelBuilder, IDeserializeCache } from '../JsonaTypes'; | ||
declare class JsonDeserializer implements IJsonaModelBuilder { | ||
import { IJsonPropertiesMapper, TJsonaModel, TJsonaRelationships, TJsonApiBody, TJsonApiData, IJsonaDeserializer, IDeserializeCache } from '../JsonaTypes'; | ||
export declare class JsonDeserializer implements IJsonaDeserializer { | ||
protected pm: IJsonPropertiesMapper; | ||
@@ -4,0 +4,0 @@ protected dc: IDeserializeCache; |
@@ -167,3 +167,4 @@ "use strict"; | ||
}()); | ||
exports.JsonDeserializer = JsonDeserializer; | ||
exports.default = JsonDeserializer; | ||
//# sourceMappingURL=JsonDeserializer.js.map |
@@ -1,3 +0,3 @@ | ||
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonaDenormalizedIncludeNames, TJsonaNormalizedIncludeNamesTree, TJsonaUniqueIncluded, IModelPropertiesMapper } from '../JsonaTypes'; | ||
declare class ModelsSerializer { | ||
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonaDenormalizedIncludeNames, TJsonaNormalizedIncludeNamesTree, TJsonaUniqueIncluded, IModelPropertiesMapper, IModelsSerializer } from '../JsonaTypes'; | ||
export declare class ModelsSerializer implements IModelsSerializer { | ||
protected propertiesMapper: IModelPropertiesMapper; | ||
@@ -4,0 +4,0 @@ protected stuff: TJsonaModel | Array<TJsonaModel>; |
@@ -167,3 +167,4 @@ "use strict"; | ||
}()); | ||
exports.ModelsSerializer = ModelsSerializer; | ||
exports.default = ModelsSerializer; | ||
//# sourceMappingURL=ModelsSerializer.js.map |
@@ -1,2 +0,2 @@ | ||
import { IModelPropertiesMapper, IJsonPropertiesMapper, TJsonaDenormalizedIncludeNames, TJsonaNormalizedIncludeNamesTree, TJsonaModel, TJsonApiBody, TReduxObject, IDeserializeCacheConstructor, TDeserializeOptions } from './JsonaTypes'; | ||
import { IModelPropertiesMapper, IModelsSerializerConstructor, IJsonDeserializerConstructor, IJsonPropertiesMapper, TJsonaDenormalizedIncludeNames, TJsonaNormalizedIncludeNamesTree, TJsonaModel, TJsonApiBody, TReduxObject, IDeserializeCacheConstructor, TDeserializeOptions } from './JsonaTypes'; | ||
declare class Jsona { | ||
@@ -6,2 +6,4 @@ modelPropertiesMapper: IModelPropertiesMapper; | ||
DeserializeCache: IDeserializeCacheConstructor; | ||
ModelsSerializer: IModelsSerializerConstructor; | ||
JsonDeserializer: IJsonDeserializerConstructor; | ||
constructor(params?: { | ||
@@ -11,2 +13,4 @@ modelPropertiesMapper?: IModelPropertiesMapper; | ||
DeserializeCache?: IDeserializeCacheConstructor; | ||
ModelsSerializer?: IModelsSerializerConstructor; | ||
JsonDeserializer?: IJsonDeserializerConstructor; | ||
}); | ||
@@ -13,0 +17,0 @@ /** |
@@ -14,2 +14,4 @@ "use strict"; | ||
this.DeserializeCache = cache_1.DeserializeCache; | ||
this.ModelsSerializer = ModelsSerializer_1.default; | ||
this.JsonDeserializer = JsonDeserializer_1.default; | ||
if (params && params.modelPropertiesMapper) { | ||
@@ -24,2 +26,8 @@ this.modelPropertiesMapper = params.modelPropertiesMapper; | ||
} | ||
if (params && params.ModelsSerializer) { | ||
this.ModelsSerializer = params.ModelsSerializer; | ||
} | ||
if (params && params.JsonDeserializer) { | ||
this.JsonDeserializer = params.JsonDeserializer; | ||
} | ||
} | ||
@@ -35,3 +43,3 @@ /** | ||
} | ||
var jsonBuilder = new ModelsSerializer_1.default(this.modelPropertiesMapper); | ||
var jsonBuilder = new this.ModelsSerializer(this.modelPropertiesMapper); | ||
jsonBuilder.setStuff(stuff); | ||
@@ -52,3 +60,3 @@ if (includeNames) { | ||
var deserializeCache = new this.DeserializeCache(); | ||
var modelBuilder = new JsonDeserializer_1.default(this.jsonPropertiesMapper, deserializeCache, options); | ||
var modelBuilder = new this.JsonDeserializer(this.jsonPropertiesMapper, deserializeCache, options); | ||
if (typeof body === 'string') { | ||
@@ -55,0 +63,0 @@ modelBuilder.setJsonParsedObject(utils_1.jsonParse(body)); |
@@ -28,2 +28,32 @@ export interface IModelPropertiesMapper { | ||
} | ||
export interface IJsonaDeserializer extends IJsonaModelBuilder { | ||
setDeserializeCache(dc: IDeserializeCache): void; | ||
setPropertiesMapper(pm: IJsonPropertiesMapper): void; | ||
setJsonParsedObject(body: TJsonApiBody): void; | ||
buildModelByData(data: TJsonApiData): TJsonaModel; | ||
buildRelationsByData(data: TJsonApiData, model: TJsonaModel): TJsonaRelationships | null; | ||
buildDataFromIncludedOrData(id: string | number, type: string): TJsonApiData; | ||
buildDataInObject(): { | ||
[key: string]: TJsonApiData; | ||
}; | ||
buildIncludedInObject(): { | ||
[key: string]: TJsonApiData; | ||
}; | ||
} | ||
export interface IJsonDeserializerConstructor { | ||
new (propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options: any): any; | ||
} | ||
export interface IModelsSerializer { | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper): any; | ||
setStuff(stuff: any): any; | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree): any; | ||
build(): TJsonApiBody; | ||
buildDataByModel(model: TJsonaModel | null): TJsonApiData; | ||
buildRelationshipsByModel(model: TJsonaModel): any; | ||
buildIncludedByModel(model: TJsonaModel, includeTree: TJsonaNormalizedIncludeNamesTree, builtIncluded: TJsonaUniqueIncluded): void; | ||
buildIncludedItem(relationModel: TJsonaModel, subIncludeTree: TJsonaNormalizedIncludeNamesTree, builtIncluded: TJsonaUniqueIncluded): any; | ||
} | ||
export interface IModelsSerializerConstructor { | ||
new (propertiesMapper?: IModelPropertiesMapper): IModelsSerializer; | ||
} | ||
export declare type TDeserializeOptions = { | ||
@@ -30,0 +60,0 @@ preferNestedDataFromData?: boolean; |
{ | ||
"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.5.2", | ||
"version": "1.6.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "json-api", |
@@ -7,7 +7,7 @@ import { | ||
TJsonApiData, | ||
IJsonaModelBuilder, | ||
IJsonaDeserializer, | ||
IDeserializeCache, | ||
} from '../JsonaTypes'; | ||
class JsonDeserializer implements IJsonaModelBuilder { | ||
export class JsonDeserializer implements IJsonaDeserializer { | ||
@@ -14,0 +14,0 @@ protected pm: IJsonPropertiesMapper; |
@@ -8,3 +8,4 @@ import { | ||
TJsonaUniqueIncluded, | ||
IModelPropertiesMapper | ||
IModelPropertiesMapper, | ||
IModelsSerializer | ||
} from '../JsonaTypes'; | ||
@@ -14,3 +15,3 @@ | ||
class ModelsSerializer { | ||
export class ModelsSerializer implements IModelsSerializer { | ||
@@ -17,0 +18,0 @@ protected propertiesMapper: IModelPropertiesMapper; |
import { | ||
IModelPropertiesMapper, | ||
IModelsSerializerConstructor, | ||
IJsonDeserializerConstructor, | ||
IJsonPropertiesMapper, | ||
@@ -10,3 +12,3 @@ TJsonaDenormalizedIncludeNames, | ||
IDeserializeCacheConstructor, | ||
TDeserializeOptions, | ||
TDeserializeOptions | ||
} from './JsonaTypes'; | ||
@@ -31,2 +33,4 @@ | ||
public DeserializeCache: IDeserializeCacheConstructor = DeserializeCache; | ||
public ModelsSerializer: IModelsSerializerConstructor = ModelsSerializer; | ||
public JsonDeserializer: IJsonDeserializerConstructor = JsonDeserializer; | ||
@@ -37,2 +41,4 @@ constructor(params?: { | ||
DeserializeCache?: IDeserializeCacheConstructor, | ||
ModelsSerializer?: IModelsSerializerConstructor, | ||
JsonDeserializer?: IJsonDeserializerConstructor, | ||
}) { | ||
@@ -48,2 +54,8 @@ if (params && params.modelPropertiesMapper) { | ||
} | ||
if (params && params.ModelsSerializer) { | ||
this.ModelsSerializer = params.ModelsSerializer; | ||
} | ||
if (params && params.JsonDeserializer) { | ||
this.JsonDeserializer = params.JsonDeserializer; | ||
} | ||
} | ||
@@ -65,3 +77,3 @@ | ||
const jsonBuilder = new ModelsSerializer(this.modelPropertiesMapper); | ||
const jsonBuilder = new this.ModelsSerializer(this.modelPropertiesMapper); | ||
@@ -87,3 +99,3 @@ jsonBuilder.setStuff(stuff); | ||
const deserializeCache = new this.DeserializeCache(); | ||
const modelBuilder = new JsonDeserializer(this.jsonPropertiesMapper, deserializeCache, options); | ||
const modelBuilder = new this.JsonDeserializer(this.jsonPropertiesMapper, deserializeCache, options); | ||
@@ -90,0 +102,0 @@ if (typeof body === 'string') { |
@@ -34,2 +34,40 @@ | ||
export interface IJsonaDeserializer extends IJsonaModelBuilder { | ||
setDeserializeCache(dc: IDeserializeCache): void; | ||
setPropertiesMapper(pm: IJsonPropertiesMapper): void; | ||
setJsonParsedObject(body: TJsonApiBody): void; | ||
buildModelByData(data: TJsonApiData): TJsonaModel; | ||
buildRelationsByData(data: TJsonApiData, model: TJsonaModel): TJsonaRelationships | null; | ||
buildDataFromIncludedOrData(id: string | number, type: string): TJsonApiData; | ||
buildDataInObject(): { [key: string]: TJsonApiData }; | ||
buildIncludedInObject(): { [key: string]: TJsonApiData }; | ||
} | ||
export interface IJsonDeserializerConstructor { | ||
new(propertiesMapper: IJsonPropertiesMapper, deserializeCache: IDeserializeCache, options); | ||
} | ||
export interface IModelsSerializer { | ||
setPropertiesMapper(propertiesMapper: IModelPropertiesMapper); | ||
setStuff(stuff); | ||
setIncludeNames(includeNames: TJsonaDenormalizedIncludeNames | TJsonaNormalizedIncludeNamesTree); | ||
build(): TJsonApiBody; | ||
buildDataByModel(model: TJsonaModel | null): TJsonApiData; | ||
buildRelationshipsByModel(model: TJsonaModel); | ||
buildIncludedByModel( | ||
model: TJsonaModel, | ||
includeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
): void; | ||
buildIncludedItem( | ||
relationModel: TJsonaModel, | ||
subIncludeTree: TJsonaNormalizedIncludeNamesTree, | ||
builtIncluded: TJsonaUniqueIncluded | ||
); | ||
} | ||
export interface IModelsSerializerConstructor { | ||
new(propertiesMapper?: IModelPropertiesMapper): IModelsSerializer; | ||
} | ||
export type TDeserializeOptions = { | ||
@@ -36,0 +74,0 @@ preferNestedDataFromData?: boolean, |
Sorry, the diff of this file is not supported yet
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
134416
2331