@aire-ux/aire-condensation
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -40,3 +40,3 @@ var __read = (this && this.__read) || function (o, n) { | ||
import { allocate, Region } from "@condensation/types"; | ||
import { StringDeserializer, TypeRegistrationDeserializer, } from "@condensation/deserializer"; | ||
import { BooleanDeserializer, NumberDeserializer, StringDeserializer, TypeRegistrationDeserializer, } from "@condensation/deserializer"; | ||
/** | ||
@@ -155,2 +155,8 @@ * root context for all operations | ||
deserializer: new StringDeserializer(), | ||
}, { | ||
type: Boolean, | ||
deserializer: new BooleanDeserializer() | ||
}, { | ||
type: Number, | ||
deserializer: new NumberDeserializer() | ||
}); |
@@ -10,2 +10,8 @@ import "reflect-metadata"; | ||
} | ||
export declare class BooleanDeserializer implements Deserializer<boolean> { | ||
read(object: any): boolean; | ||
} | ||
export declare class NumberDeserializer implements Deserializer<number> { | ||
read(object: any): number; | ||
} | ||
export declare class TypeRegistrationDeserializer<T> implements Deserializer<T> { | ||
@@ -12,0 +18,0 @@ readonly type: Class<T>; |
@@ -39,2 +39,20 @@ var __values = (this && this.__values) || function(o) { | ||
export { StringDeserializer }; | ||
var BooleanDeserializer = /** @class */ (function () { | ||
function BooleanDeserializer() { | ||
} | ||
BooleanDeserializer.prototype.read = function (object) { | ||
return object; | ||
}; | ||
return BooleanDeserializer; | ||
}()); | ||
export { BooleanDeserializer }; | ||
var NumberDeserializer = /** @class */ (function () { | ||
function NumberDeserializer() { | ||
} | ||
NumberDeserializer.prototype.read = function (object) { | ||
return object; | ||
}; | ||
return NumberDeserializer; | ||
}()); | ||
export { NumberDeserializer }; | ||
var TypeRegistrationDeserializer = /** @class */ (function () { | ||
@@ -41,0 +59,0 @@ function TypeRegistrationDeserializer(type, registration) { |
@@ -18,3 +18,3 @@ import "reflect-metadata"; | ||
}; | ||
export declare function Property<T>(configuration?: PropertyConfiguration | Class<T>): any; | ||
export declare function Property<T>(configuration?: Partial<PropertyConfiguration> | Class<T>): any; | ||
export {}; |
{ | ||
"name": "@aire-ux/aire-condensation", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Client-side serialization library for Aire-UX", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,3 +5,4 @@ import TypeRegistry from "@condensation/type-registry"; | ||
import { | ||
Deserializer, | ||
BooleanDeserializer, | ||
Deserializer, NumberDeserializer, | ||
StringDeserializer, | ||
@@ -143,2 +144,8 @@ TypeRegistrationDeserializer, | ||
deserializer: new StringDeserializer(), | ||
}, { | ||
type: Boolean, | ||
deserializer: new BooleanDeserializer() | ||
}, { | ||
type: Number, | ||
deserializer: new NumberDeserializer() | ||
}); |
@@ -16,2 +16,13 @@ import "reflect-metadata"; | ||
export class BooleanDeserializer implements Deserializer<boolean> { | ||
read(object: any): boolean { | ||
return object as boolean; | ||
} | ||
} | ||
export class NumberDeserializer implements Deserializer<number> { | ||
read(object: any): number { | ||
return object as number; | ||
} | ||
} | ||
export class TypeRegistrationDeserializer<T> implements Deserializer<T> { | ||
@@ -18,0 +29,0 @@ constructor( |
@@ -42,4 +42,4 @@ import "reflect-metadata"; | ||
function isConfiguration<T>( | ||
cfg: PropertyConfiguration | Class<T> | ||
): cfg is PropertyConfiguration { | ||
cfg: Partial<PropertyConfiguration> | Class<T> | ||
): cfg is Partial<PropertyConfiguration> { | ||
return (cfg as PropertyConfiguration).type !== undefined; | ||
@@ -49,3 +49,3 @@ } | ||
export function Property<T>( | ||
configuration?: PropertyConfiguration | Class<T> | ||
configuration?: Partial<PropertyConfiguration> | Class<T> | ||
): any { | ||
@@ -60,5 +60,5 @@ return function (target: Class<T>, propertyName: string) { | ||
if (isConfiguration(configuration)) { | ||
type = configuration.type; | ||
type = configuration.type as Class<T>; | ||
} else { | ||
type = configuration; | ||
type = configuration as Class<T>; | ||
} | ||
@@ -65,0 +65,0 @@ } else { |
@@ -77,2 +77,72 @@ import { Receive, Remotable } from "@condensation/remotable"; | ||
test('ensure base use-case works', () => { | ||
@RootElement | ||
class GraphConfiguration { | ||
@Property({ | ||
type:String, | ||
read: { | ||
alias: 'load-resources' | ||
} | ||
}) | ||
loadResources: string | undefined; | ||
@Property({ | ||
type:Boolean, | ||
read: { | ||
alias: 'force-includes' | ||
} | ||
}) | ||
forceIncludes: string | undefined; | ||
@Property({ | ||
type:Boolean, | ||
read: { | ||
alias: 'force-includes' | ||
} | ||
}) | ||
loadStylesheets: boolean | undefined; | ||
@Property({ | ||
type:String, | ||
read: { | ||
alias: 'resource-extension' | ||
} | ||
}) | ||
resourceExtension: boolean | undefined; | ||
@Property({ | ||
type:Boolean, | ||
read: { | ||
alias: 'production-mode' | ||
} | ||
}) | ||
productionMode: boolean | undefined; | ||
@Property({ | ||
type:String, | ||
read: { | ||
alias: 'base-path' | ||
} | ||
}) | ||
basePath: string | undefined; | ||
} | ||
@Remotable | ||
class MxGraphManager { | ||
constructor(@Receive(GraphConfiguration) readonly configuration: GraphConfiguration) { | ||
} | ||
} | ||
const mgr = Condensation.newContext().create<MxGraphManager>(MxGraphManager, `{ | ||
"load-resources": "loading them resources" | ||
}`); | ||
expect(mgr.configuration?.loadResources).toEqual("loading them resources"); | ||
}); | ||
test("ensure array is deserializable", () => { | ||
@@ -79,0 +149,0 @@ @RootElement |
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
49467
1499