From a0ddea419e938345a86e5f9dab8da2f35b4380b5 Mon Sep 17 00:00:00 2001 From: Gillian Perard Date: Mon, 30 Apr 2018 21:31:17 +0200 Subject: [PATCH 1/4] src/ and coverage/ added to .npmignore --- .npmignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.npmignore b/.npmignore index e69de29..34bdf4e 100644 --- a/.npmignore +++ b/.npmignore @@ -0,0 +1,2 @@ +src/ +coverage/ \ No newline at end of file From 996b04114ba82831dbb3646512f257edcc02024e Mon Sep 17 00:00:00 2001 From: Gillian Perard Date: Mon, 30 Apr 2018 21:36:33 +0200 Subject: [PATCH 2/4] declaration set to true inside tsconfig.json --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 17d6661..ef930ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "./dist", "sourceMap": false, - "declaration": false, + "declaration": true, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, From a5e0cb4b31254287d44d2e1a2871b7de6f8caf49 Mon Sep 17 00:00:00 2001 From: Gillian Perard Date: Mon, 30 Apr 2018 21:51:26 +0200 Subject: [PATCH 3/4] main, types and keywords set into package.json --- package.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bd30455..1f8f11e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "typescript-json-serializer", - "version": "1.0.0", + "version": "1.0.1", "description": "Typescript library to serialize classes into json and deserialize json into classes.", - "main": "src/index.ts", + "main": "dist/src/index.js", + "types": "dist/src/index.d.ts", "scripts": { "build": "tsc", "test": "npm run build && mocha -r ts-node/register dist/spec/**/*.spec.js", @@ -18,6 +19,14 @@ "url": "https://github.com/GillianPerard/typescript-json-serializer/issues" }, "homepage": "https://github.com/GillianPerard/typescript-json-serializer#readme", + "keywords": [ + "json", + "typescript", + "serializer", + "deserializer", + "decorator", + "metadata" + ], "dependencies": { "lodash": "^4.17.5", "reflect-metadata": "^0.1.12" From 7ef9e36fa0d7aa0baa915545ac5d1773ed1a5415 Mon Sep 17 00:00:00 2001 From: Gillian Perard Date: Mon, 30 Apr 2018 21:51:36 +0200 Subject: [PATCH 4/4] d.ts added --- dist/examples/json/data.d.ts | 3 +++ dist/examples/models/animal.d.ts | 9 +++++++++ dist/examples/models/employee.d.ts | 8 ++++++++ dist/examples/models/gender.d.ts | 5 +++++ dist/examples/models/panther.d.ts | 6 ++++++ dist/examples/models/snake.d.ts | 5 +++++ dist/examples/models/zoo.d.ts | 13 +++++++++++++ dist/spec/index.spec.d.ts | 1 + dist/src/index.d.ts | 20 ++++++++++++++++++++ 9 files changed, 70 insertions(+) create mode 100644 dist/examples/json/data.d.ts create mode 100644 dist/examples/models/animal.d.ts create mode 100644 dist/examples/models/employee.d.ts create mode 100644 dist/examples/models/gender.d.ts create mode 100644 dist/examples/models/panther.d.ts create mode 100644 dist/examples/models/snake.d.ts create mode 100644 dist/examples/models/zoo.d.ts create mode 100644 dist/spec/index.spec.d.ts create mode 100644 dist/src/index.d.ts diff --git a/dist/examples/json/data.d.ts b/dist/examples/json/data.d.ts new file mode 100644 index 0000000..668147e --- /dev/null +++ b/dist/examples/json/data.d.ts @@ -0,0 +1,3 @@ +import { Zoo } from '../models/zoo'; +export declare const data: any; +export declare const deserializedData: Zoo; diff --git a/dist/examples/models/animal.d.ts b/dist/examples/models/animal.d.ts new file mode 100644 index 0000000..41e0e9c --- /dev/null +++ b/dist/examples/models/animal.d.ts @@ -0,0 +1,9 @@ +export declare class Animal { + id: number; + name: string; + birthdate: Date; + numberOfPaws: number; + gender: string; + childrenIds: Array; + constructor(); +} diff --git a/dist/examples/models/employee.d.ts b/dist/examples/models/employee.d.ts new file mode 100644 index 0000000..07d57d2 --- /dev/null +++ b/dist/examples/models/employee.d.ts @@ -0,0 +1,8 @@ +export declare class Employee { + id: number; + name: string; + birthdate: Date; + email: string; + gender: string; + constructor(); +} diff --git a/dist/examples/models/gender.d.ts b/dist/examples/models/gender.d.ts new file mode 100644 index 0000000..e33533a --- /dev/null +++ b/dist/examples/models/gender.d.ts @@ -0,0 +1,5 @@ +export declare enum Gender { + female = 0, + male = 1, + other = 2, +} diff --git a/dist/examples/models/panther.d.ts b/dist/examples/models/panther.d.ts new file mode 100644 index 0000000..0a1d31d --- /dev/null +++ b/dist/examples/models/panther.d.ts @@ -0,0 +1,6 @@ +import { Animal } from './animal'; +export declare class Panther extends Animal { + color: string; + isSpeckled: boolean; + constructor(); +} diff --git a/dist/examples/models/snake.d.ts b/dist/examples/models/snake.d.ts new file mode 100644 index 0000000..3a7d0f4 --- /dev/null +++ b/dist/examples/models/snake.d.ts @@ -0,0 +1,5 @@ +import { Animal } from './animal'; +export declare class Snake extends Animal { + isPoisonous: boolean; + constructor(); +} diff --git a/dist/examples/models/zoo.d.ts b/dist/examples/models/zoo.d.ts new file mode 100644 index 0000000..fbd330b --- /dev/null +++ b/dist/examples/models/zoo.d.ts @@ -0,0 +1,13 @@ +import { Employee } from './employee'; +import { Panther } from './panther'; +export declare class Zoo { + boss: Employee; + city: string; + country: string; + employees: Array; + id: number; + name: string; + panthers: Array; + isOpen: boolean; + constructor(); +} diff --git a/dist/spec/index.spec.d.ts b/dist/spec/index.spec.d.ts new file mode 100644 index 0000000..d2c9bc6 --- /dev/null +++ b/dist/spec/index.spec.d.ts @@ -0,0 +1 @@ +import 'reflect-metadata'; diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts new file mode 100644 index 0000000..fbb6977 --- /dev/null +++ b/dist/src/index.d.ts @@ -0,0 +1,20 @@ +import 'reflect-metadata'; +/** + * Decorator JsonProperty + */ +export declare function JsonProperty(args?: string | { + name?: string; + type: Function; +}): Function; +/** + * Decorator Serializable + */ +export declare function Serializable(parentType?: string): Function; +/** + * Function to deserialize json into a class + */ +export declare function deserialize(json: any, type: any): any; +/** + * Function to serialize a class into json + */ +export declare function serialize(instance: any, removeUndefined?: boolean): any;