diff --git a/common/changes/@cats-cradle/authentication-service/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/authentication-service/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index da9f87a7..00000000 --- a/common/changes/@cats-cradle/authentication-service/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/authentication-service", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/authentication-service" -} \ No newline at end of file diff --git a/common/changes/@cats-cradle/create-artifact/feature-pojo-faker-factory_2023-10-28-21-42.json b/common/changes/@cats-cradle/create-artifact/feature-pojo-faker-factory_2023-10-28-21-42.json new file mode 100644 index 00000000..aff2fe80 --- /dev/null +++ b/common/changes/@cats-cradle/create-artifact/feature-pojo-faker-factory_2023-10-28-21-42.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cats-cradle/create-artifact", + "comment": "", + "type": "none" + } + ], + "packageName": "@cats-cradle/create-artifact" +} \ No newline at end of file diff --git a/common/changes/@cats-cradle/email-service/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/email-service/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index 33a12f8c..00000000 --- a/common/changes/@cats-cradle/email-service/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/email-service", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/email-service" -} \ No newline at end of file diff --git a/common/changes/@cats-cradle/faker-factory/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/faker-factory/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index 19bd26d8..00000000 --- a/common/changes/@cats-cradle/faker-factory/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/faker-factory", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/faker-factory" -} \ No newline at end of file diff --git a/common/changes/@cats-cradle/html-to-pdf/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/html-to-pdf/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index 766aa1bd..00000000 --- a/common/changes/@cats-cradle/html-to-pdf/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/html-to-pdf", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/html-to-pdf" -} \ No newline at end of file diff --git a/common/changes/@cats-cradle/nestjs-modules/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/nestjs-modules/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index c82a25b8..00000000 --- a/common/changes/@cats-cradle/nestjs-modules/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/nestjs-modules", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/nestjs-modules" -} \ No newline at end of file diff --git a/common/changes/@cats-cradle/validation-schemas/bugfix-add-build_2023-10-28-05-20.json b/common/changes/@cats-cradle/validation-schemas/bugfix-add-build_2023-10-28-05-20.json deleted file mode 100644 index 02632e59..00000000 --- a/common/changes/@cats-cradle/validation-schemas/bugfix-add-build_2023-10-28-05-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@cats-cradle/validation-schemas", - "comment": "", - "type": "none" - } - ], - "packageName": "@cats-cradle/validation-schemas" -} \ No newline at end of file diff --git a/libraries/faker-factory/.eslintrc.js b/libraries/faker-factory/.eslintrc.js index 8400fa89..977701a3 100644 --- a/libraries/faker-factory/.eslintrc.js +++ b/libraries/faker-factory/.eslintrc.js @@ -3,4 +3,7 @@ module.exports = { parserOptions: { tsconfigRootDir: __dirname, }, + rules: { + 'no-prototype-builtins': 'off', + }, }; diff --git a/libraries/faker-factory/CHANGELOG.json b/libraries/faker-factory/CHANGELOG.json index cec489b1..3a9ceebc 100644 --- a/libraries/faker-factory/CHANGELOG.json +++ b/libraries/faker-factory/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/faker-factory", "entries": [ + { + "version": "1.1.0", + "tag": "@cats-cradle/faker-factory_v1.1.0", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "minor": [ + { + "comment": "add to pojo option" + } + ] + } + }, { "version": "1.0.4", "tag": "@cats-cradle/faker-factory_v1.0.4", diff --git a/libraries/faker-factory/CHANGELOG.md b/libraries/faker-factory/CHANGELOG.md index 71a37d7d..0241fc00 100644 --- a/libraries/faker-factory/CHANGELOG.md +++ b/libraries/faker-factory/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @cats-cradle/faker-factory -This log was last generated on Wed, 04 Oct 2023 03:44:49 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 1.1.0 +Sat, 28 Oct 2023 21:42:52 GMT + +### Minor changes + +- add to pojo option ## 1.0.4 Wed, 04 Oct 2023 03:44:49 GMT diff --git a/libraries/faker-factory/package.json b/libraries/faker-factory/package.json index 9fda2d34..0619bd09 100644 --- a/libraries/faker-factory/package.json +++ b/libraries/faker-factory/package.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/faker-factory", - "version": "1.0.4", + "version": "1.1.0", "main": "./dist/index.js", "repository": { "type": "git", diff --git a/libraries/faker-factory/src/__tests__/faker-factory.test.ts b/libraries/faker-factory/src/__tests__/faker-factory.test.ts index bac2b095..07e5fc88 100644 --- a/libraries/faker-factory/src/__tests__/faker-factory.test.ts +++ b/libraries/faker-factory/src/__tests__/faker-factory.test.ts @@ -5,10 +5,19 @@ describe('FakerFactory', () => { describe('create', () => { let faker: SampleClass; - beforeAll(async () => { + beforeEach(async () => { faker = await FakerFactory.create(SampleClass); }); + it('should create a pojo faker object', async () => { + faker = await FakerFactory.create( + SampleClass, + {}, + { pojo: true }, + ); + expect(typeof faker).toBe('object'); + }); + it('should create a faker object', () => { expect(typeof faker).toBe('object'); }); diff --git a/libraries/faker-factory/src/__tests__/pojo.test.ts b/libraries/faker-factory/src/__tests__/pojo.test.ts new file mode 100644 index 00000000..9b14f885 --- /dev/null +++ b/libraries/faker-factory/src/__tests__/pojo.test.ts @@ -0,0 +1,35 @@ +import { isPojo, toPojo } from '../pojo'; + +class TestClass { + a: string; + + b() { + return this.a; + } +} + +describe('toPojo', () => { + it('should convert complex object into plain old javascript object', () => { + const sut = new TestClass(); + sut.a = 'Test'; + + expect(toPojo(sut)).toEqual({ a: 'Test' }); + }); +}); + +describe('isPojo', () => { + it('should return false for non-pojo', () => { + const sut = new TestClass(); + sut.a = 'Test'; + + expect(isPojo(sut)).toBeFalsy(); + }); + + it('should return true for pojo', () => { + const sut = new TestClass(); + sut.a = 'Test'; + const pojo = sut; + + expect(isPojo(pojo)).toBeFalsy(); + }); +}); diff --git a/libraries/faker-factory/src/faker-factory.ts b/libraries/faker-factory/src/faker-factory.ts index 3c14b6ef..2ab08a4c 100644 --- a/libraries/faker-factory/src/faker-factory.ts +++ b/libraries/faker-factory/src/faker-factory.ts @@ -3,6 +3,7 @@ import { cloneDeep } from 'lodash'; import { Settings } from './settings'; import { generateFakeData } from './generate-fake-data'; import { getSchemas } from './schemas'; +import { toPojo } from './pojo'; export class FakerFactory { public static create( @@ -30,6 +31,10 @@ export class FakerFactory { ...partialClone, }); + if (settings?.pojo === true) { + return toPojo(objectInstance); + } + return objectInstance as T; } } diff --git a/libraries/faker-factory/src/index.ts b/libraries/faker-factory/src/index.ts index 89be2499..8411a89d 100644 --- a/libraries/faker-factory/src/index.ts +++ b/libraries/faker-factory/src/index.ts @@ -1 +1,3 @@ export * from './faker-factory'; +export { toPojo, isPojo } from './pojo'; +export { Settings } from './settings'; diff --git a/libraries/faker-factory/src/pojo.ts b/libraries/faker-factory/src/pojo.ts new file mode 100644 index 00000000..7508eef9 --- /dev/null +++ b/libraries/faker-factory/src/pojo.ts @@ -0,0 +1,34 @@ +/** + * toPojo + * @param obj + * @returns + */ +export function toPojo(obj: any): any { + if (obj === null || typeof obj !== 'object') { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map((item) => toPojo(item)); + } + + const result: { [key: string]: any } = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + result[key] = toPojo(obj[key]); + } + } + + return result; +} + +export function isPojo(obj: any): boolean { + if (typeof obj !== 'object' || obj === null) { + return false; + } + + const prototype = Object.getPrototypeOf(obj); + + // If the prototype is null, it's a plain object + return prototype === null; +} diff --git a/libraries/faker-factory/src/settings.ts b/libraries/faker-factory/src/settings.ts index 1adfb500..ba280c7c 100644 --- a/libraries/faker-factory/src/settings.ts +++ b/libraries/faker-factory/src/settings.ts @@ -7,6 +7,12 @@ export interface Settings { */ optionals?: boolean | undefined; + /** + * whether to return a plain old javascript object + * which is helpful when comparing rest request + */ + pojo?: boolean | undefined; + /** * whether optional properties are shown */ diff --git a/libraries/nestjs-modules/CHANGELOG.json b/libraries/nestjs-modules/CHANGELOG.json index ef905f06..a3a613f4 100644 --- a/libraries/nestjs-modules/CHANGELOG.json +++ b/libraries/nestjs-modules/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/nestjs-modules", "entries": [ + { + "version": "0.2.5", + "tag": "@cats-cradle/nestjs-modules_v0.2.5", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.1.0`" + } + ] + } + }, { "version": "0.2.4", "tag": "@cats-cradle/nestjs-modules_v0.2.4", diff --git a/libraries/nestjs-modules/CHANGELOG.md b/libraries/nestjs-modules/CHANGELOG.md index 6cb969c4..67d713d6 100644 --- a/libraries/nestjs-modules/CHANGELOG.md +++ b/libraries/nestjs-modules/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/nestjs-modules -This log was last generated on Wed, 04 Oct 2023 03:44:49 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 0.2.5 +Sat, 28 Oct 2023 21:42:52 GMT + +_Version update only_ ## 0.2.4 Wed, 04 Oct 2023 03:44:49 GMT diff --git a/libraries/nestjs-modules/package.json b/libraries/nestjs-modules/package.json index 69e56072..69d73614 100644 --- a/libraries/nestjs-modules/package.json +++ b/libraries/nestjs-modules/package.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/nestjs-modules", - "version": "0.2.4", + "version": "0.2.5", "main": "./dist/index.js", "repository": { "type": "git", diff --git a/libraries/validation-schemas/CHANGELOG.json b/libraries/validation-schemas/CHANGELOG.json index fa5ee953..f9b989d3 100644 --- a/libraries/validation-schemas/CHANGELOG.json +++ b/libraries/validation-schemas/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/validation-schemas", "entries": [ + { + "version": "0.3.1", + "tag": "@cats-cradle/validation-schemas_v0.3.1", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.1.0`" + } + ] + } + }, { "version": "0.3.0", "tag": "@cats-cradle/validation-schemas_v0.3.0", diff --git a/libraries/validation-schemas/CHANGELOG.md b/libraries/validation-schemas/CHANGELOG.md index bc2f7cd7..0a18c4a2 100644 --- a/libraries/validation-schemas/CHANGELOG.md +++ b/libraries/validation-schemas/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/validation-schemas -This log was last generated on Sun, 22 Oct 2023 15:17:07 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 0.3.1 +Sat, 28 Oct 2023 21:42:52 GMT + +_Version update only_ ## 0.3.0 Sun, 22 Oct 2023 15:17:07 GMT diff --git a/libraries/validation-schemas/package.json b/libraries/validation-schemas/package.json index d8d94b72..07402f7a 100644 --- a/libraries/validation-schemas/package.json +++ b/libraries/validation-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/validation-schemas", - "version": "0.3.0", + "version": "0.3.1", "main": "./dist/index.js", "license": "MIT", "repository": { diff --git a/platform/create-artifact/src/__tests__/test-data/package-output.json b/platform/create-artifact/src/__tests__/test-data/package-output.json index 58c03e7b..6597770d 100644 --- a/platform/create-artifact/src/__tests__/test-data/package-output.json +++ b/platform/create-artifact/src/__tests__/test-data/package-output.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/create-artifact", - "version": "1.1.1", + "version": "2.0.0", "license": "MIT", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/services/authentication-service/CHANGELOG.json b/services/authentication-service/CHANGELOG.json index c2156604..a94553a3 100644 --- a/services/authentication-service/CHANGELOG.json +++ b/services/authentication-service/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@cats-cradle/authentication-service", "entries": [ + { + "version": "1.0.6", + "tag": "@cats-cradle/authentication-service_v1.0.6", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/nestjs-modules\" to `0.2.5`" + }, + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.1.0`" + } + ] + } + }, { "version": "1.0.5", "tag": "@cats-cradle/authentication-service_v1.0.5", diff --git a/services/authentication-service/CHANGELOG.md b/services/authentication-service/CHANGELOG.md index f2a06ea6..fc86c32a 100644 --- a/services/authentication-service/CHANGELOG.md +++ b/services/authentication-service/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/authentication-service -This log was last generated on Sat, 28 Oct 2023 04:52:47 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 1.0.6 +Sat, 28 Oct 2023 21:42:52 GMT + +_Version update only_ ## 1.0.5 Sat, 28 Oct 2023 04:52:47 GMT diff --git a/services/authentication-service/package.json b/services/authentication-service/package.json index 79f0089f..1e1629ae 100644 --- a/services/authentication-service/package.json +++ b/services/authentication-service/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/authentication-service", "module": "commonjs", - "version": "1.0.5", + "version": "1.0.6", "scripts": { "dev": "nest start --debug --watch", "build": "tsc", diff --git a/services/email-service/CHANGELOG.json b/services/email-service/CHANGELOG.json index 2d0f8cb4..1031304d 100644 --- a/services/email-service/CHANGELOG.json +++ b/services/email-service/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@cats-cradle/email-service", "entries": [ + { + "version": "0.0.13", + "tag": "@cats-cradle/email-service_v0.0.13", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/validation-schemas\" to `0.3.1`" + }, + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.1.0`" + } + ] + } + }, { "version": "0.0.12", "tag": "@cats-cradle/email-service_v0.0.12", diff --git a/services/email-service/CHANGELOG.md b/services/email-service/CHANGELOG.md index f8561927..c429ae91 100644 --- a/services/email-service/CHANGELOG.md +++ b/services/email-service/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/email-service -This log was last generated on Sat, 28 Oct 2023 04:52:47 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 0.0.13 +Sat, 28 Oct 2023 21:42:52 GMT + +_Version update only_ ## 0.0.12 Sat, 28 Oct 2023 04:52:47 GMT diff --git a/services/email-service/package.json b/services/email-service/package.json index d10d5367..712c7381 100644 --- a/services/email-service/package.json +++ b/services/email-service/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/email-service", "module": "commonjs", - "version": "0.0.12", + "version": "0.0.13", "scripts": { "dev": "nest start --debug --watch", "build": "tsc", diff --git a/services/html-to-pdf/CHANGELOG.json b/services/html-to-pdf/CHANGELOG.json index d69239d3..843622eb 100644 --- a/services/html-to-pdf/CHANGELOG.json +++ b/services/html-to-pdf/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/html-to-pdf", "entries": [ + { + "version": "1.0.7", + "tag": "@cats-cradle/html-to-pdf_v1.0.7", + "date": "Sat, 28 Oct 2023 21:42:52 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.1.0`" + } + ] + } + }, { "version": "1.0.6", "tag": "@cats-cradle/html-to-pdf_v1.0.6", diff --git a/services/html-to-pdf/CHANGELOG.md b/services/html-to-pdf/CHANGELOG.md index 53f9b0f5..09a352e9 100644 --- a/services/html-to-pdf/CHANGELOG.md +++ b/services/html-to-pdf/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/html-to-pdf -This log was last generated on Sat, 28 Oct 2023 04:52:47 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 21:42:52 GMT and should not be manually modified. + +## 1.0.7 +Sat, 28 Oct 2023 21:42:52 GMT + +_Version update only_ ## 1.0.6 Sat, 28 Oct 2023 04:52:47 GMT diff --git a/services/html-to-pdf/package.json b/services/html-to-pdf/package.json index 38ba096e..0e27e40f 100644 --- a/services/html-to-pdf/package.json +++ b/services/html-to-pdf/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/html-to-pdf", "module": "commonjs", - "version": "1.0.6", + "version": "1.0.7", "license": "MIT", "description": "Your Go-To Solution for PDF Generation from HTML.", "bugs": {