diff --git a/lib/AnotherFile.d.ts b/lib/AnotherFile.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/lib/AnotherFile.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/lib/AnotherFile.js b/lib/AnotherFile.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/lib/AnotherFile.js @@ -0,0 +1 @@ +export {}; diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..e26a57a --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/index.d.ts.map b/lib/index.d.ts.map new file mode 100644 index 0000000..535b86d --- /dev/null +++ b/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..7d60c4f --- /dev/null +++ b/lib/index.js @@ -0,0 +1,2 @@ +import "axios"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map new file mode 100644 index 0000000..1b03ee0 --- /dev/null +++ b/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAsB,OAAO,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 9bc825e..103de2a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,11 @@ "name": "issue-repo", "private": true, "type": "module", - "scripts": {}, + "scripts": { + "start": "node src/index.js" + }, + "dependencies": { + "serializr": "3.0.2" + }, "packageManager": "yarn@3.2.0" } diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..ebf81a3 --- /dev/null +++ b/src/index.js @@ -0,0 +1,42 @@ +import { createModelSchema, primitive, serialize } from "serializr"; + +class Person { + name; +} + +class Worker extends Person { + company; +} + +// const workerModelSchema = createModelSchema(Worker, { +// company: primitive(), +// name: primitive(), +// }); +// output: { company: 'FirmX', name: 'John' } --> this works + +const personModelSchema = createModelSchema(Person, { + name: primitive(), +}); + +const workerModelSchema = createModelSchema(Worker, { + company: primitive(), + name: primitive(), +}); +// output: { name: 'John', company: 'FirmX' } --> this doesn't work as expected + +// const workerModelSchema2 = { +// factory: () => new Worker(), +// props: { +// company: primitive(), +// name: primitive(), +// }, +// }; +// output: { company: 'FirmX', name: 'John' } --> this works + +const newWorker = new Worker(); +newWorker.name = "John"; +newWorker.company = "FirmX"; + +const json = serialize(workerModelSchema, newWorker); + +console.log(json); diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/yarn.lock b/yarn.lock index 9b67dbf..13074d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,21 +3,19 @@ __metadata: version: 6 + cacheKey: 8 "issue-repo@workspace:.": version: 0.0.0-use.local resolution: "issue-repo@workspace:." + dependencies: + serializr: 3.0.2 languageName: unknown linkType: soft -"pkg1@workspace:packages/pkg1": - version: 0.0.0-use.local - resolution: "pkg1@workspace:packages/pkg1" - languageName: unknown - linkType: soft - -"pkg2@workspace:packages/pkg2": - version: 0.0.0-use.local - resolution: "pkg2@workspace:packages/pkg2" - languageName: unknown - linkType: soft +"serializr@npm:3.0.2": + version: 3.0.2 + resolution: "serializr@npm:3.0.2" + checksum: 4276e0418eef9e30aab9557d299f028396e448a2ec8f4838bffb04e757f7d03bc012d85ff5a60e9260fb9cce6f52b6fba80266f5634eece8f48dc3b9f948dfb9 + languageName: node + linkType: hard