diff --git a/package-lock.json b/package-lock.json index 83c07a5..51048d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@ehmpathy/error-fns": "1.0.2", - "domain-objects": "^0.13.2", + "domain-objects": "^0.20.0", "joi": "17.4.0", "lodash.omit": "^4.5.0", "type-fns": "^0.9.1", @@ -8235,9 +8235,9 @@ } }, "node_modules/domain-objects": { - "version": "0.13.2", - "resolved": "https://registry.npmjs.org/domain-objects/-/domain-objects-0.13.2.tgz", - "integrity": "sha512-00d0Otc642zfjF2WxUkk2/zgXA+2GOQbBnUSgww5dPsRbVcFOL/Qu+XsoiwcWT35TXmL2XHB41ovFh+snZH3tw==", + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/domain-objects/-/domain-objects-0.20.0.tgz", + "integrity": "sha512-9zE6sFk9aTNSavKr8iCX/Ey8q806pXxA12YPAUCeIVuNoCtvjXR46MCkYCWDJBQ+uZx7EhM7YvL5JvKT7acfig==", "hasInstallScript": true, "dependencies": { "@types/joi": "^17.2.3", @@ -8246,7 +8246,9 @@ "change-case": "^4.1.2", "cross-sha256": "^1.2.0", "lodash.omit": "^4.5.0", - "lodash.pick": "^4.4.0" + "lodash.pick": "^4.4.0", + "test-fns": "^1.3.0", + "type-fns": "^1.13.0" }, "engines": { "node": ">=8.0.0" @@ -8261,6 +8263,17 @@ "joi": "*" } }, + "node_modules/domain-objects/node_modules/type-fns": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/type-fns/-/type-fns-1.15.0.tgz", + "integrity": "sha512-IAxaiIMleiQ1pU6pBbmJagVmQz/88JVydpGXSEGYoIBo1F1Zkz9ibC1IWN+t5mj1PAByDf7S4yOsc6LNYxQM+Q==", + "dependencies": { + "@ehmpathy/error-fns": "1.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/dot-case": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", @@ -18524,6 +18537,18 @@ "node": ">=8" } }, + "node_modules/test-fns": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/test-fns/-/test-fns-1.3.0.tgz", + "integrity": "sha512-3PQtEhIM3Q5+ZanixJiF0HdQge7Jape52L+QlIueDwwuXdLXGv0MTVh1k23DYOEsBT2vJuT+3r7baJ40brqrag==", + "hasInstallScript": true, + "dependencies": { + "@ehmpathy/error-fns": "1.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", diff --git a/package.json b/package.json index 2dd8dfd..e5869b4 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "dependencies": { "@ehmpathy/error-fns": "1.0.2", - "domain-objects": "^0.13.2", + "domain-objects": "^0.20.0", "joi": "17.4.0", "lodash.omit": "^4.5.0", "type-fns": "^0.9.1", diff --git a/readme.md b/readme.md index 7f8d629..34e2965 100644 --- a/readme.md +++ b/readme.md @@ -17,14 +17,14 @@ npm install --save domain-objects-metadata # Usage Examples -### metadata of a value object +### metadata of a literal say you've defined an `Address` as one of the objects in your domain ```ts // src/domain/objects/Address.ts -import { DomainValueObject } from 'domain-objects'; +import { DomainLiteral } from 'domain-objects'; interface Address { street: string; @@ -33,7 +33,7 @@ interface Address { state: string; postal: string; } -class Address extends DomainValueObject
implements Address {} +class Address extends DomainLiteral
implements Address {} ``` you can introspect the file that its defined in to get its metadata @@ -49,7 +49,7 @@ which looks like ```ts { name: 'Address', - extends: 'DomainValueObject', + extends: 'DomainLiteral', properties: { street: { name: 'street', type: 'string', required: true }, suite: { name: 'suite', type: 'string', nullable: true, required: true }, @@ -187,7 +187,7 @@ which looks like destination: { name: 'destination', type: 'reference', - of: { name: 'Address', extends: 'DomainValueObject' }, + of: { name: 'Address', extends: 'DomainLiteral' }, required: true, }, contactInfo: { diff --git a/src/domain/constants.ts b/src/domain/constants.ts index 07a6bab..1f648e9 100644 --- a/src/domain/constants.ts +++ b/src/domain/constants.ts @@ -2,7 +2,7 @@ import { createIsOfEnum } from 'type-fns'; export enum DomainObjectVariant { DOMAIN_OBJECT = 'DomainObject', - DOMAIN_VALUE_OBJECT = 'DomainValueObject', + DOMAIN_LITERAL = 'DomainLiteral', DOMAIN_ENTITY = 'DomainEntity', DOMAIN_EVENT = 'DomainEvent', } diff --git a/src/logic/__snapshots__/introspect.test.ts.snap b/src/logic/__snapshots__/introspect.test.ts.snap index 207107a..1762839 100644 --- a/src/logic/__snapshots__/introspect.test.ts.snap +++ b/src/logic/__snapshots__/introspect.test.ts.snap @@ -7,7 +7,7 @@ exports[`introspect should be possible to introspect all of those files at the s "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata { @@ -160,7 +160,7 @@ exports[`introspect should be possible to introspect all of those files at the s "name": "destination", "nullable": false, "of": DomainObjectReferenceMetadata { - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", }, "required": true, @@ -228,7 +228,7 @@ exports[`introspect should be possible to introspect the Address file 1`] = ` "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata { @@ -273,7 +273,7 @@ exports[`introspect should be possible to introspect the Delivery file 1`] = ` "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata { @@ -426,7 +426,7 @@ exports[`introspect should be possible to introspect the Delivery file 1`] = ` "name": "destination", "nullable": false, "of": DomainObjectReferenceMetadata { - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", }, "required": true, diff --git a/src/logic/__test_assets__/Address.ts b/src/logic/__test_assets__/Address.ts index d6c6ea2..61a5dd7 100644 --- a/src/logic/__test_assets__/Address.ts +++ b/src/logic/__test_assets__/Address.ts @@ -1,4 +1,4 @@ -import { DomainValueObject } from 'domain-objects'; +import { DomainLiteral } from 'domain-objects'; export interface Address { street: string; @@ -7,4 +7,4 @@ export interface Address { state: string; postal: string; } -export class Address extends DomainValueObject
implements Address {} +export class Address extends DomainLiteral
implements Address {} diff --git a/src/logic/extract/__snapshots__/extractDomainObjectMetadataForDeclarationInFile.test.ts.snap b/src/logic/extract/__snapshots__/extractDomainObjectMetadataForDeclarationInFile.test.ts.snap index 9942d03..a1d9f29 100644 --- a/src/logic/extract/__snapshots__/extractDomainObjectMetadataForDeclarationInFile.test.ts.snap +++ b/src/logic/extract/__snapshots__/extractDomainObjectMetadataForDeclarationInFile.test.ts.snap @@ -96,13 +96,13 @@ DomainObjectMetadata { } `; -exports[`extractDomainObjectMetadataForDeclarationInFile should be able to extract domain object metadata for simple value object 1`] = ` +exports[`extractDomainObjectMetadataForDeclarationInFile should be able to extract domain object metadata for simple literal 1`] = ` DomainObjectMetadata { "decorations": { "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata { diff --git a/src/logic/extract/extractDomainObjectMetadataForDeclarationInFile.test.ts b/src/logic/extract/extractDomainObjectMetadataForDeclarationInFile.test.ts index 7fa362e..45e6d04 100644 --- a/src/logic/extract/extractDomainObjectMetadataForDeclarationInFile.test.ts +++ b/src/logic/extract/extractDomainObjectMetadataForDeclarationInFile.test.ts @@ -3,7 +3,7 @@ import ts, { isClassDeclaration } from 'typescript'; import { extractDomainObjectMetadataForDeclarationInFile } from './extractDomainObjectMetadataForDeclarationInFile'; describe('extractDomainObjectMetadataForDeclarationInFile', () => { - it('should be able to extract domain object metadata for simple value object', () => { + it('should be able to extract domain object metadata for simple literal', () => { const program = ts.createProgram( [`${__dirname}/../__test_assets__/Address.ts`], {}, diff --git a/src/logic/extract/extractRelevantStaticPropertiesFromClassDeclaration.test.ts b/src/logic/extract/extractRelevantStaticPropertiesFromClassDeclaration.test.ts index c72f0a3..d02851d 100644 --- a/src/logic/extract/extractRelevantStaticPropertiesFromClassDeclaration.test.ts +++ b/src/logic/extract/extractRelevantStaticPropertiesFromClassDeclaration.test.ts @@ -20,7 +20,7 @@ describe('extractRelevantStaticPropertiesFromClassDeclaration', () => { updatable: ['status', 'amount', 'currency'], }); }); - it('should be able to get the unique and updatable properties of a DomainValueObject', () => { + it('should be able to get the unique and updatable properties of a DomainLiteral', () => { const program = ts.createProgram( [`${__dirname}/../__test_assets__/Address.ts`], {}, diff --git a/src/logic/guard/isDomainObjectReferenceProperty.test.ts b/src/logic/guard/isDomainObjectReferenceProperty.test.ts index 7e602be..2c2988d 100644 --- a/src/logic/guard/isDomainObjectReferenceProperty.test.ts +++ b/src/logic/guard/isDomainObjectReferenceProperty.test.ts @@ -13,7 +13,7 @@ describe('isDomainObjectReferenceProperty', () => { name: 'geocode', type: DomainObjectPropertyType.REFERENCE, of: new DomainObjectReferenceMetadata({ - extends: DomainObjectVariant.DOMAIN_VALUE_OBJECT, + extends: DomainObjectVariant.DOMAIN_LITERAL, name: 'Geocode', }), }); @@ -37,7 +37,7 @@ describe('isDomainObjectReferenceProperty', () => { of: { type: DomainObjectPropertyType.REFERENCE, of: new DomainObjectReferenceMetadata({ - extends: DomainObjectVariant.DOMAIN_VALUE_OBJECT, + extends: DomainObjectVariant.DOMAIN_LITERAL, name: 'Geocode', }), }, diff --git a/src/logic/hydrate/__snapshots__/getHydratedDomainObjectMetadatasFromFiles.test.ts.snap b/src/logic/hydrate/__snapshots__/getHydratedDomainObjectMetadatasFromFiles.test.ts.snap index a2394c8..497568a 100644 --- a/src/logic/hydrate/__snapshots__/getHydratedDomainObjectMetadatasFromFiles.test.ts.snap +++ b/src/logic/hydrate/__snapshots__/getHydratedDomainObjectMetadatasFromFiles.test.ts.snap @@ -7,7 +7,7 @@ exports[`getHydratedDomainObjectMetadatasFromFiles should return metadata from f "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata { @@ -99,7 +99,7 @@ exports[`getHydratedDomainObjectMetadatasFromFiles should return metadata from f "name": "destination", "nullable": false, "of": DomainObjectReferenceMetadata { - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", }, "required": true, @@ -150,7 +150,7 @@ exports[`getHydratedDomainObjectMetadatasFromFiles should return metadata from f "unique": null, "updatable": null, }, - "extends": "DomainValueObject", + "extends": "DomainLiteral", "name": "Address", "properties": { "city": DomainObjectPropertyMetadata {