From a55ad8b9639f09e3c1b79c5d37bbaf9d67e91209 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Tue, 12 Nov 2024 18:07:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20DailyPromptRecordEnti?= =?UTF-8?q?ty?= 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" ]