From 030d27dfcb2403c57f3f6d248960ee536f8fbf32 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 17:59:02 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20wellbeing=20promp?= =?UTF-8?q?t=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/wellbeing-prompt-entity/README.md | 7 +++++++ .../wellbeing-prompt-entity/eslint.config.js | 3 +++ .../wellbeing-prompt-entity/jest.config.ts | 11 +++++++++++ .../domain/wellbeing-prompt-entity/project.json | 9 +++++++++ .../domain/wellbeing-prompt-entity/src/index.ts | 1 + .../src/lib/wellbeing-prompt-entity.spec.ts | 0 .../src/lib/wellbeing-prompt-entity.ts | 6 ++++++ .../domain/wellbeing-prompt-entity/tsconfig.json | 16 ++++++++++++++++ .../wellbeing-prompt-entity/tsconfig.lib.json | 11 +++++++++++ .../wellbeing-prompt-entity/tsconfig.spec.json | 14 ++++++++++++++ tsconfig.base.json | 3 +++ 11 files changed, 81 insertions(+) create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/README.md create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/project.json create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/src/index.ts create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json create mode 100644 libs/prompt/domain/wellbeing-prompt-entity/tsconfig.spec.json diff --git a/libs/prompt/domain/wellbeing-prompt-entity/README.md b/libs/prompt/domain/wellbeing-prompt-entity/README.md new file mode 100644 index 0000000..1eb8b1f --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/README.md @@ -0,0 +1,7 @@ +# wellbeing-prompt-entity + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test wellbeing-prompt-entity` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js b/libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js new file mode 100644 index 0000000..cdd3cba --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js @@ -0,0 +1,3 @@ +const baseConfig = require('../../../../eslint.config.js'); + +module.exports = [...baseConfig]; diff --git a/libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts b/libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts new file mode 100644 index 0000000..05ec1e5 --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts @@ -0,0 +1,11 @@ +export default { + displayName: 'wellbeing-prompt-entity', + preset: '../../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: + '../../../../coverage/libs/prompt/domain/wellbeing-prompt-entity', +}; diff --git a/libs/prompt/domain/wellbeing-prompt-entity/project.json b/libs/prompt/domain/wellbeing-prompt-entity/project.json new file mode 100644 index 0000000..e55ef7b --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/project.json @@ -0,0 +1,9 @@ +{ + "name": "wellbeing-prompt-entity", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/prompt/domain/wellbeing-prompt-entity/src", + "projectType": "library", + "tags": [], + "// targets": "to see all targets run: nx show project wellbeing-prompt-entity --web", + "targets": {} +} diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/index.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/index.ts new file mode 100644 index 0000000..401a023 --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/src/index.ts @@ -0,0 +1 @@ +export * from './lib/wellbeing-prompt-entity'; diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts new file mode 100644 index 0000000..e69de29 diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts new file mode 100644 index 0000000..0a7336b --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts @@ -0,0 +1,6 @@ +export interface WellbeingPromptEntity { + id: string; + content: string; + category: string; //TODO: Change to enum + createdAt: Date; +} \ No newline at end of file diff --git a/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json new file mode 100644 index 0000000..2c9d3a5 --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs" + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json new file mode 100644 index 0000000..28369ef --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], + "include": ["src/**/*.ts"] +} diff --git a/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.spec.json b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.spec.json new file mode 100644 index 0000000..6668655 --- /dev/null +++ b/libs/prompt/domain/wellbeing-prompt-entity/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 70deefe..f23a9ba 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -17,6 +17,9 @@ "paths": { "@graphql-federation-workspace/applications-config": [ "libs/application-config/src/index.ts" + ], + "@prompt/wellbeing-prompt-entity": [ + "libs/prompt/domain/wellbeing-prompt-entity/src/index.ts" ] } }, From 0d1cc704e266a9c804ebb5f92325fb8a69e8e812 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 18:07:16 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20type=20WellbeingC?= =?UTF-8?q?ategory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/wellbeing-prompt-entity.spec.ts | 31 +++++++++++++++++++ .../src/lib/wellbeing-prompt-entity.ts | 13 +++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts index e69de29..82f96b7 100644 --- a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts +++ b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts @@ -0,0 +1,31 @@ +import { WellbeingPromptEntity } from './wellbeing-prompt-entity'; + +describe('WellbeingPromptEntity', () => { + it('should create a valid WellbeingPromptEntity object', () => { + const wellbeingPrompt: WellbeingPromptEntity = { + id: '1', + content: 'Take a 5-minute walk outside.', + category: 'physical', + createdAt: new Date(), + }; + + expect(wellbeingPrompt).toBeDefined(); + expect(wellbeingPrompt.id).toBe('1'); + expect(wellbeingPrompt.content).toBe('Take a 5-minute walk outside.'); + expect(wellbeingPrompt.category).toBe('physical'); + expect(wellbeingPrompt.createdAt).toBeInstanceOf(Date); + }); + + it('should throw an error if category is invalid', () => { + const createInvalidWellbeingPrompt = () => { + const wellbeingPrompt: WellbeingPromptEntity = { + id: '2', + content: 'Meditate for 10 minutes.', + category: 'invalid-category' as any, + createdAt: new Date(), + }; + }; + + expect(createInvalidWellbeingPrompt).toThrowError(); + }); +}); \ No newline at end of file diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts index 0a7336b..9bc6c53 100644 --- a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts +++ b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.ts @@ -1,6 +1,17 @@ +type WellbeingCategory = + | 'physical' + | 'mental' + | 'social' + | 'emotional' + | 'mindfulness' + | 'productivity' + | 'self-care' + | 'gratitude' + | 'creativity'; + export interface WellbeingPromptEntity { id: string; content: string; - category: string; //TODO: Change to enum + category: WellbeingCategory; createdAt: Date; } \ No newline at end of file From a55ad8b9639f09e3c1b79c5d37bbaf9d67e91209 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 18:07:36 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20DailyPromptRecord?= =?UTF-8?q?Entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daily-prompt-record-entity/README.md | 7 ++++ .../eslint.config.js | 3 ++ .../daily-prompt-record-entity/jest.config.ts | 11 ++++++ .../daily-prompt-record-entity/project.json | 9 +++++ .../daily-prompt-record-entity/src/index.ts | 1 + .../lib/daily-prompt-record-entity.spec.ts | 35 +++++++++++++++++++ .../src/lib/daily-prompt-record-entity.ts | 7 ++++ .../daily-prompt-record-entity/tsconfig.json | 22 ++++++++++++ .../tsconfig.lib.json | 11 ++++++ .../tsconfig.spec.json | 14 ++++++++ tsconfig.base.json | 3 ++ 11 files changed, 123 insertions(+) create mode 100644 libs/prompt/domain/daily-prompt-record-entity/README.md create mode 100644 libs/prompt/domain/daily-prompt-record-entity/eslint.config.js create mode 100644 libs/prompt/domain/daily-prompt-record-entity/jest.config.ts create mode 100644 libs/prompt/domain/daily-prompt-record-entity/project.json create mode 100644 libs/prompt/domain/daily-prompt-record-entity/src/index.ts create mode 100644 libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.spec.ts create mode 100644 libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts create mode 100644 libs/prompt/domain/daily-prompt-record-entity/tsconfig.json create mode 100644 libs/prompt/domain/daily-prompt-record-entity/tsconfig.lib.json create mode 100644 libs/prompt/domain/daily-prompt-record-entity/tsconfig.spec.json diff --git a/libs/prompt/domain/daily-prompt-record-entity/README.md b/libs/prompt/domain/daily-prompt-record-entity/README.md new file mode 100644 index 0000000..7316381 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/README.md @@ -0,0 +1,7 @@ +# daily-prompt-record-entity + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test daily-prompt-record-entity` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/prompt/domain/daily-prompt-record-entity/eslint.config.js b/libs/prompt/domain/daily-prompt-record-entity/eslint.config.js new file mode 100644 index 0000000..cdd3cba --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/eslint.config.js @@ -0,0 +1,3 @@ +const baseConfig = require('../../../../eslint.config.js'); + +module.exports = [...baseConfig]; diff --git a/libs/prompt/domain/daily-prompt-record-entity/jest.config.ts b/libs/prompt/domain/daily-prompt-record-entity/jest.config.ts new file mode 100644 index 0000000..8deb5fa --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/jest.config.ts @@ -0,0 +1,11 @@ +export default { + displayName: 'daily-prompt-record-entity', + preset: '../../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: + '../../../../coverage/libs/prompt/domain/daily-prompt-record-entity', +}; diff --git a/libs/prompt/domain/daily-prompt-record-entity/project.json b/libs/prompt/domain/daily-prompt-record-entity/project.json new file mode 100644 index 0000000..30c04a7 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/project.json @@ -0,0 +1,9 @@ +{ + "name": "daily-prompt-record-entity", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/prompt/domain/daily-prompt-record-entity/src", + "projectType": "library", + "tags": [], + "// targets": "to see all targets run: nx show project daily-prompt-record-entity --web", + "targets": {} +} diff --git a/libs/prompt/domain/daily-prompt-record-entity/src/index.ts b/libs/prompt/domain/daily-prompt-record-entity/src/index.ts new file mode 100644 index 0000000..02591a3 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/src/index.ts @@ -0,0 +1 @@ +export * from './lib/daily-prompt-record-entity'; diff --git a/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.spec.ts b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.spec.ts new file mode 100644 index 0000000..c18e6e7 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.spec.ts @@ -0,0 +1,35 @@ +import {type DailyPromptRecordEntity } from './daily-prompt-record-entity'; + +describe('DailyPromptRecordEntity', () => { + it('should have all required properties', () => { + const record: DailyPromptRecordEntity = { + id: '1', + promptId: 'prompt1', + userId: 'user1', + createdAt: new Date(), + completedAt: new Date(), + }; + + expect(record).toHaveProperty('id'); + expect(record).toHaveProperty('promptId'); + expect(record).toHaveProperty('userId'); + expect(record).toHaveProperty('createdAt'); + expect(record).toHaveProperty('completedAt'); + }); + + it('should have correct types for properties', () => { + const record: DailyPromptRecordEntity = { + id: '1', + promptId: 'prompt1', + userId: 'user1', + createdAt: new Date(), + completedAt: new Date(), + }; + + expect(typeof record.id).toBe('string'); + expect(typeof record.promptId).toBe('string'); + expect(typeof record.userId).toBe('string'); + expect(record.createdAt).toBeInstanceOf(Date); + expect(record.completedAt).toBeInstanceOf(Date); + }); +}); diff --git a/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts new file mode 100644 index 0000000..09abbc5 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts @@ -0,0 +1,7 @@ +export interface DailyPromptRecordEntity { + id: string; + promptId: string; + userId: string; + createdAt: Date; + completedAt: Date; +} \ No newline at end of file diff --git a/libs/prompt/domain/daily-prompt-record-entity/tsconfig.json b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.json new file mode 100644 index 0000000..07e0ec6 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "noPropertyAccessFromIndexSignature": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/prompt/domain/daily-prompt-record-entity/tsconfig.lib.json b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.lib.json new file mode 100644 index 0000000..28369ef --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.lib.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], + "include": ["src/**/*.ts"] +} diff --git a/libs/prompt/domain/daily-prompt-record-entity/tsconfig.spec.json b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.spec.json new file mode 100644 index 0000000..6668655 --- /dev/null +++ b/libs/prompt/domain/daily-prompt-record-entity/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index f23a9ba..8d661fe 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -18,6 +18,9 @@ "@graphql-federation-workspace/applications-config": [ "libs/application-config/src/index.ts" ], + "@prompt/daily-prompt-record-entity": [ + "libs/prompt/domain/daily-prompt-record-entity/src/index.ts" + ], "@prompt/wellbeing-prompt-entity": [ "libs/prompt/domain/wellbeing-prompt-entity/src/index.ts" ] From f61d8c8e0d32f710cc70fbe9f1e67c2f8d47f84d Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 18:21:17 +0900 Subject: [PATCH 4/5] =?UTF-8?q?test:=20=F0=9F=A7=AA=20remove=20useless=20t?= =?UTF-8?q?est=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/wellbeing-prompt-entity.spec.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts index 82f96b7..76cd5c1 100644 --- a/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts +++ b/libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.ts @@ -15,17 +15,4 @@ describe('WellbeingPromptEntity', () => { expect(wellbeingPrompt.category).toBe('physical'); expect(wellbeingPrompt.createdAt).toBeInstanceOf(Date); }); - - it('should throw an error if category is invalid', () => { - const createInvalidWellbeingPrompt = () => { - const wellbeingPrompt: WellbeingPromptEntity = { - id: '2', - content: 'Meditate for 10 minutes.', - category: 'invalid-category' as any, - createdAt: new Date(), - }; - }; - - expect(createInvalidWellbeingPrompt).toThrowError(); - }); }); \ No newline at end of file From b90e583715c2e9cf56c9783cbde7755f2c5b84f4 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 18:22:19 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20completedAt=20is=20op?= =?UTF-8?q?tional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/daily-prompt-record-entity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts index 09abbc5..9470e4d 100644 --- a/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts +++ b/libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.ts @@ -3,5 +3,5 @@ export interface DailyPromptRecordEntity { promptId: string; userId: string; createdAt: Date; - completedAt: Date; + completedAt?: Date; } \ No newline at end of file