From c4d2cba4cb1027aa253c9e6656a6785c29cd27ca Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 6 Dec 2022 14:26:39 +0200 Subject: [PATCH] initial data structures --- .vscode/settings.json | 3 + README.md | 77 +-------- docker-compose.yml | 3 +- mongo-init.js | 10 ++ package-lock.json | 154 +++++++++++------- package.json | 4 +- src/app.module.ts | 19 ++- src/cli.ts | 20 +++ src/enums/industry.enum.ts | 12 ++ src/enums/regulatory-election.enums.ts | 37 +++++ src/enums/status.enum.ts | 15 ++ src/enums/type-of-registration.enums.ts | 10 ++ ...egister-industry-change-application.dto.ts | 43 +++++ .../industry-change-application.controller.ts | 24 +++ .../industry-change-application.module.ts | 35 ++++ .../industry-change-application.service.ts | 19 +++ .../schemas/Decision.schema.ts | 15 ++ .../schemas/ICAInformation.schema.ts | 21 +++ .../IndustryChangeApplication.schema.ts | 65 ++++++++ src/resident/resident.module.ts | 27 +++ src/resident/resident.seed.ts | 55 +++++++ src/resident/resident.service.ts | 17 ++ src/resident/schemas/Resident.schema.ts | 92 +++++++++++ .../schemas/ResidentAddress.schema.ts | 25 +++ 24 files changed, 668 insertions(+), 134 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 mongo-init.js create mode 100644 src/cli.ts create mode 100644 src/enums/industry.enum.ts create mode 100644 src/enums/regulatory-election.enums.ts create mode 100644 src/enums/status.enum.ts create mode 100644 src/enums/type-of-registration.enums.ts create mode 100644 src/industry-change-application/dtos/register-industry-change-application.dto.ts create mode 100644 src/industry-change-application/industry-change-application.controller.ts create mode 100644 src/industry-change-application/industry-change-application.module.ts create mode 100644 src/industry-change-application/industry-change-application.service.ts create mode 100644 src/industry-change-application/schemas/Decision.schema.ts create mode 100644 src/industry-change-application/schemas/ICAInformation.schema.ts create mode 100644 src/industry-change-application/schemas/IndustryChangeApplication.schema.ts create mode 100644 src/resident/resident.module.ts create mode 100644 src/resident/resident.seed.ts create mode 100644 src/resident/resident.service.ts create mode 100644 src/resident/schemas/Resident.schema.ts create mode 100644 src/resident/schemas/ResidentAddress.schema.ts diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ad92582 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": true +} diff --git a/README.md b/README.md index 0e94224..3d3195e 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,6 @@ -

- Nest Logo -

+# Exercise -[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 -[circleci-url]: https://circleci.com/gh/nestjs/nest - -

A progressive Node.js framework for building efficient and scalable server-side applications.

-

-NPM Version -Package License -NPM Downloads -CircleCI -Coverage -Discord -Backers on Open Collective -Sponsors on Open Collective - Donate us - Support us - Follow us on Twitter -

- - -## Description - -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. - -## Installation - -```bash -$ npm install -``` - -## Running the app - -```bash -# development -$ npm run start - -# watch mode -$ npm run start:dev - -# production mode -$ npm run start:prod -``` - -## Test - -```bash -# unit tests -$ npm run test - -# e2e tests -$ npm run test:e2e - -# test coverage -$ npm run test:cov -``` - -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch - -- Author - [Kamil Myƛliwiec](https://twitter.com/kammysliwiec) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) - -## License - - Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE). +1. Run MongoDB `docker-compose up` +2. Create initial resident `npx nestjs-command create:resident` +3. Run the application `npm run start:dev` +4. API is at http://localhost:3000 diff --git a/docker-compose.yml b/docker-compose.yml index f761dd2..6dba8e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: eprosperatest + MONGO_INITDB_DATABASE: nest volumes: - ./database:/data/db - + - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro diff --git a/mongo-init.js b/mongo-init.js new file mode 100644 index 0000000..c125d9f --- /dev/null +++ b/mongo-init.js @@ -0,0 +1,10 @@ +db.createUser({ + user: 'root', + pwd: 'eprosperatest', + roles: [ + { + role: 'readWrite', + db: 'nest', + }, + ], +}); diff --git a/package-lock.json b/package-lock.json index 8592b70..58a8395 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,8 +17,10 @@ "class-transformer": "^0.5.1", "class-validator": "^0.13.2", "mongoose": "^6.8.0", + "nestjs-command": "^3.1.2", "reflect-metadata": "^0.1.13", - "rxjs": "^7.5.5" + "rxjs": "^7.5.5", + "yargs": "^17.6.2" }, "devDependencies": { "@nestjs/cli": "^9.0.0", @@ -3711,7 +3713,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, "engines": { "node": ">=8" } @@ -3720,7 +3721,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4302,14 +4302,16 @@ } }, "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" } }, "node_modules/clone": { @@ -4341,7 +4343,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4352,8 +4353,7 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/combined-stream": { "version": "1.0.8", @@ -4680,8 +4680,7 @@ "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/encodeurl": { "version": "1.0.2", @@ -4732,7 +4731,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, "engines": { "node": ">=6" } @@ -5553,7 +5551,6 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, "engines": { "node": "6.* || 8.* || >= 10.*" } @@ -5982,7 +5979,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "engines": { "node": ">=8" } @@ -7283,6 +7279,16 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.compact": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash.compact/-/lodash.compact-3.0.1.tgz", + "integrity": "sha512-2ozeiPi+5eBXW1CLtzjk8XQFhQOEMwwfxblqeq6EGyTxZJ1bPATqilY0e6g2SLQpP4KuMeuioBhEnWz5Pr7ICQ==" + }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -7676,6 +7682,23 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/nestjs-command": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/nestjs-command/-/nestjs-command-3.1.2.tgz", + "integrity": "sha512-9PG4cEqx2OME+YSO7uzLg6YBzGwP7rv9ULZqa+Uitu7KR5S/FEWj1BrmET9vdWG61H/jy9mJdYro4ml4je02cg==", + "dependencies": { + "lodash.compact": "^3.0.1", + "lodash.flattendeep": "^4.4.0" + }, + "bin": { + "nestjs-command": "bin/cli" + }, + "peerDependencies": { + "@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "@nestjs/core": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "yargs": "^16.0.0 || ^17.0.0" + } + }, "node_modules/node-emoji": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", @@ -8311,7 +8334,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -8822,7 +8844,6 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -8836,7 +8857,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -9746,7 +9766,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -9790,7 +9809,6 @@ "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, "engines": { "node": ">=10" } @@ -9811,18 +9829,17 @@ } }, "node_modules/yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", - "dev": true, + "version": "17.6.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", + "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", "dependencies": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" + "yargs-parser": "^21.1.1" }, "engines": { "node": ">=12" @@ -9837,6 +9854,14 @@ "node": ">=12" } }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -12755,14 +12780,12 @@ "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "requires": { "color-convert": "^2.0.1" } @@ -13184,13 +13207,12 @@ "dev": true }, "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "requires": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, @@ -13216,7 +13238,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "requires": { "color-name": "~1.1.4" } @@ -13224,8 +13245,7 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "combined-stream": { "version": "1.0.8", @@ -13487,8 +13507,7 @@ "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "encodeurl": { "version": "1.0.2", @@ -13532,8 +13551,7 @@ "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, "escape-html": { "version": "1.0.3", @@ -14147,8 +14165,7 @@ "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" }, "get-intrinsic": { "version": "1.1.2", @@ -14454,8 +14471,7 @@ "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "is-generator-fn": { "version": "2.1.0", @@ -15434,6 +15450,16 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.compact": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash.compact/-/lodash.compact-3.0.1.tgz", + "integrity": "sha512-2ozeiPi+5eBXW1CLtzjk8XQFhQOEMwwfxblqeq6EGyTxZJ1bPATqilY0e6g2SLQpP4KuMeuioBhEnWz5Pr7ICQ==" + }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -15734,6 +15760,15 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "nestjs-command": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/nestjs-command/-/nestjs-command-3.1.2.tgz", + "integrity": "sha512-9PG4cEqx2OME+YSO7uzLg6YBzGwP7rv9ULZqa+Uitu7KR5S/FEWj1BrmET9vdWG61H/jy9mJdYro4ml4je02cg==", + "requires": { + "lodash.compact": "^3.0.1", + "lodash.flattendeep": "^4.4.0" + } + }, "node-emoji": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", @@ -16195,8 +16230,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" }, "require-from-string": { "version": "2.0.2", @@ -16577,7 +16611,6 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -16588,7 +16621,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "requires": { "ansi-regex": "^5.0.1" } @@ -17216,7 +17248,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -17247,8 +17278,7 @@ "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" }, "yallist": { "version": "4.0.0", @@ -17263,18 +17293,24 @@ "dev": true }, "yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", - "dev": true, + "version": "17.6.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", + "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", "requires": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" + "yargs-parser": "^21.1.1" + }, + "dependencies": { + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" + } } }, "yargs-parser": { diff --git a/package.json b/package.json index 21ab6f0..d8c8a63 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,10 @@ "class-transformer": "^0.5.1", "class-validator": "^0.13.2", "mongoose": "^6.8.0", + "nestjs-command": "^3.1.2", "reflect-metadata": "^0.1.13", - "rxjs": "^7.5.5" + "rxjs": "^7.5.5", + "yargs": "^17.6.2" }, "devDependencies": { "@nestjs/cli": "^9.0.0", diff --git a/src/app.module.ts b/src/app.module.ts index 8662803..dd54907 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,9 +1,26 @@ import { Module } from '@nestjs/common'; +import { ConfigModule, ConfigService } from '@nestjs/config'; +import { MongooseModule } from '@nestjs/mongoose'; import { AppController } from './app.controller'; import { AppService } from './app.service'; +import { IndustryChangeApplicationModule } from './industry-change-application/industry-change-application.module'; +import { ResidentModule } from './resident/resident.module'; +import { CommandModule } from 'nestjs-command'; @Module({ - imports: [], + imports: [ + CommandModule, + ConfigModule.forRoot({}), + MongooseModule.forRootAsync({ + imports: [ConfigModule], + useFactory: async (configService: ConfigService) => ({ + uri: configService.get('MONGODB_URI'), + }), + inject: [ConfigService], + }), + ResidentModule, + IndustryChangeApplicationModule, + ], controllers: [AppController], providers: [AppService], }) diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..914a4d9 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,20 @@ +import { NestFactory } from '@nestjs/core'; +import { CommandModule, CommandService } from 'nestjs-command'; +import { AppModule } from './app.module'; + +async function bootstrap() { + const app = await NestFactory.createApplicationContext(AppModule, { + logger: false, + }); + + try { + await app.select(CommandModule).get(CommandService).exec(); + await app.close(); + } catch (error) { + console.error(error); + await app.close(); + process.exit(1); + } +} + +bootstrap(); diff --git a/src/enums/industry.enum.ts b/src/enums/industry.enum.ts new file mode 100644 index 0000000..a3ca7f7 --- /dev/null +++ b/src/enums/industry.enum.ts @@ -0,0 +1,12 @@ +export enum Industry { + AGRICULTURAL = 'AGRICULTURAL', + CONSTRUCTION = 'CONSTRUCTION', + ENERGY = 'ENERGY', + FINANCE_AND_INSURANCE = 'FINANCE_AND_INSURANCE', + FOOD = 'FOOD', + HEALTH = 'HEALTH', + MANUFACTURING = 'MANUFACTURING', + MINING_AND_SUBSURFACE = 'MINING_AND_SUBSURFACE', + PRIVATE_SECURITY = 'PRIVATE_SECURITY', + WASTE_MANAGEMENT = 'WASTE_MANAGEMENT', +} diff --git a/src/enums/regulatory-election.enums.ts b/src/enums/regulatory-election.enums.ts new file mode 100644 index 0000000..abe21b5 --- /dev/null +++ b/src/enums/regulatory-election.enums.ts @@ -0,0 +1,37 @@ +export enum RegulatoryElection { + AUSTRALIA = 'AUSTRALIA', + AUSTRIA = 'AUSTRIA', + BELGIUM = 'BELGIUM', + CANADA = 'CANADA', + CHILE = 'CHILE', + ROATAN_COMMON_LAW_CODE = 'ROATAN_COMMON_LAW_CODE', + DENMARK = 'DENMARK', + DUBAI = 'DUBAI', + ESTONIA = 'ESTONIA', + FINLAND = 'FINLAND', + FRANCE = 'FRANCE', + GERMANY = 'GERMANY', + HONDURAS = 'HONDURAS', + HONG_KONG = 'HONG_KONG', + ICELAND = 'ICELAND', + IRELAND = 'IRELAND', + ISRAEL = 'ISRAEL', + ITALY = 'ITALY', + JAPAN = 'JAPAN', + LUXEMBOURG = 'LUXEMBOURG', + MEXICO = 'MEXICO', + NETHERLANDS = 'NETHERLANDS', + NEW_ZEALAND = 'NEW_ZEALAND', + null = 'null', + NORWAY = 'NORWAY', + PETITION_FOR_TAILORED_REGULATION_GRANTED = 'PETITION_FOR_TAILORED_REGULATION_GRANTED', + PETITION_FOR_TAILORED_REGULATION_PENDING = 'PETITION_FOR_TAILORED_REGULATION_PENDING', + POLAND = 'POLAND', + SINGAPORE = 'SINGAPORE', + SOUTH_KOREA = 'SOUTH_KOREA', + SPAIN = 'SPAIN', + SWEDEN = 'SWEDEN', + SWITZERLAND = 'SWITZERLAND', + UK = 'UK', + USA = 'USA', +} diff --git a/src/enums/status.enum.ts b/src/enums/status.enum.ts new file mode 100644 index 0000000..0461f62 --- /dev/null +++ b/src/enums/status.enum.ts @@ -0,0 +1,15 @@ +export enum ApplicationStatus { + IN_REVIEW = 'IN_REVIEW', + APPROVED = 'APPROVED', + REJECTED = 'REJECTED', +} + +export enum ObjectStatus { + CURRENT = 'CURRENT', + DELETED = 'DELETED', +} + +export enum ResidentStatus { + ACTIVE = 'ACTIVE', + INACTIVE = 'INACTIVE', +} diff --git a/src/enums/type-of-registration.enums.ts b/src/enums/type-of-registration.enums.ts new file mode 100644 index 0000000..02e5930 --- /dev/null +++ b/src/enums/type-of-registration.enums.ts @@ -0,0 +1,10 @@ +export enum TypeOfRegistration { + E_RESIDENCY = 'E_RESIDENCY', + RESIDENCY = 'RESIDENCY', + LIMITED_E_RESIDENCY = 'LIMITED_E_RESIDENCY', +} + +export enum TypeOfRegistrationSub { + HONDURAN = 'HONDURAN', + INTERNATIONAL = 'INTERNATIONAL', +} diff --git a/src/industry-change-application/dtos/register-industry-change-application.dto.ts b/src/industry-change-application/dtos/register-industry-change-application.dto.ts new file mode 100644 index 0000000..1c8f12f --- /dev/null +++ b/src/industry-change-application/dtos/register-industry-change-application.dto.ts @@ -0,0 +1,43 @@ +import { Exclude, Expose } from 'class-transformer'; +import { Industry } from 'src/enums/industry.enum'; +import { RegulatoryElection } from 'src/enums/regulatory-election.enums'; +import { ApplicationStatus, ObjectStatus } from 'src/enums/status.enum'; +import { Resident } from 'src/resident/schemas/Resident.schema'; + +export class ApplicationInformationDto { + @Exclude() + _id: string; + + willWorkInPhysicalJuristiction: string; + industry: Industry; + regulatoryElection: RegulatoryElection; + regulatoryElectionSub: string; +} + +export class DecisionDto { + @Exclude() + _id: string; + + decidedAt: Date; + rejctionReason: string; +} + +export class GetRegisterIndustryChangeApplicationDto { + @Expose({ name: 'id' }) + _id: string; + + @Exclude() + resident: Resident; + + @Expose({ name: 'residentSub' }) + getResidentSub() { + return this.resident.sub; + } + + current: ApplicationInformationDto; + requested: ApplicationInformationDto; + status: ApplicationStatus; + submittedAt: Date; + decision: DecisionDto; + objectStatus: ObjectStatus; +} diff --git a/src/industry-change-application/industry-change-application.controller.ts b/src/industry-change-application/industry-change-application.controller.ts new file mode 100644 index 0000000..927ec3d --- /dev/null +++ b/src/industry-change-application/industry-change-application.controller.ts @@ -0,0 +1,24 @@ +import { Controller, Get } from '@nestjs/common'; +import { plainToInstance } from 'class-transformer'; +import { GetRegisterIndustryChangeApplicationDto } from './dtos/register-industry-change-application.dto'; +import { IndustryChangeApplicationService } from './industry-change-application.service'; + +@Controller({ + path: '/resident-register/industry-change-applications', +}) +export class IndustryChangeApplicationController { + constructor( + private readonly applicationsSerivce: IndustryChangeApplicationService, + ) {} + + @Get() + async getList() { + const allApplications = await this.applicationsSerivce.getAll(); + const transformed = plainToInstance( + GetRegisterIndustryChangeApplicationDto, + allApplications, + { excludeExtraneousValues: true }, + ); + return transformed; + } +} diff --git a/src/industry-change-application/industry-change-application.module.ts b/src/industry-change-application/industry-change-application.module.ts new file mode 100644 index 0000000..f5d9393 --- /dev/null +++ b/src/industry-change-application/industry-change-application.module.ts @@ -0,0 +1,35 @@ +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { IndustryChangeApplicationController } from './industry-change-application.controller'; +import { IndustryChangeApplicationService } from './industry-change-application.service'; +import { Decision, DecisionSchema } from './schemas/Decision.schema'; +import { + ICAInformation, + ICAInformationSchema, +} from './schemas/ICAInformation.schema'; +import { + IndustryChangeApplication, + IndustryChangeApplicationSchema, +} from './schemas/IndustryChangeApplication.schema'; + +@Module({ + imports: [ + MongooseModule.forFeature([ + { + name: Decision.name, + schema: DecisionSchema, + }, + { + name: ICAInformation.name, + schema: ICAInformationSchema, + }, + { + name: IndustryChangeApplication.name, + schema: IndustryChangeApplicationSchema, + }, + ]), + ], + controllers: [IndustryChangeApplicationController], + providers: [IndustryChangeApplicationService], +}) +export class IndustryChangeApplicationModule {} diff --git a/src/industry-change-application/industry-change-application.service.ts b/src/industry-change-application/industry-change-application.service.ts new file mode 100644 index 0000000..55ba377 --- /dev/null +++ b/src/industry-change-application/industry-change-application.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Model } from 'mongoose'; +import { + IndustryChangeApplication, + IndustryChangeApplicationDocument, +} from './schemas/IndustryChangeApplication.schema'; + +@Injectable() +export class IndustryChangeApplicationService { + constructor( + @InjectModel(IndustryChangeApplication.name) + private applicationModel: Model, + ) {} + + async getAll() { + return this.applicationModel.find(); + } +} diff --git a/src/industry-change-application/schemas/Decision.schema.ts b/src/industry-change-application/schemas/Decision.schema.ts new file mode 100644 index 0000000..4be0f14 --- /dev/null +++ b/src/industry-change-application/schemas/Decision.schema.ts @@ -0,0 +1,15 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; + +@Schema({ _id: false }) +export class Decision { + @Prop() + decidedAt: Date; + + @Prop() + decidedBy: string; + + @Prop() + rejectionReason: string; +} + +export const DecisionSchema = SchemaFactory.createForClass(Decision); diff --git a/src/industry-change-application/schemas/ICAInformation.schema.ts b/src/industry-change-application/schemas/ICAInformation.schema.ts new file mode 100644 index 0000000..9994a30 --- /dev/null +++ b/src/industry-change-application/schemas/ICAInformation.schema.ts @@ -0,0 +1,21 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { Industry } from 'src/enums/industry.enum'; +import { RegulatoryElection } from 'src/enums/regulatory-election.enums'; + +@Schema({ _id: false }) +export class ICAInformation { + @Prop({ type: String, enum: Industry }) + industry: Industry; + + @Prop({ required: true }) + willWorkInPhysicalJurisdiction: boolean; + + @Prop({ type: String, enum: RegulatoryElection }) + regulatoryElection: RegulatoryElection; + + @Prop() + regulatoryElectionSub: string; +} + +export const ICAInformationSchema = + SchemaFactory.createForClass(ICAInformation); diff --git a/src/industry-change-application/schemas/IndustryChangeApplication.schema.ts b/src/industry-change-application/schemas/IndustryChangeApplication.schema.ts new file mode 100644 index 0000000..1d15f20 --- /dev/null +++ b/src/industry-change-application/schemas/IndustryChangeApplication.schema.ts @@ -0,0 +1,65 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import mongoose, { HydratedDocument } from 'mongoose'; +import { Resident } from 'src/resident/schemas/Resident.schema'; +import { Decision } from './Decision.schema'; +import { ApplicationStatus, ObjectStatus } from 'src/enums/status.enum'; +import { ICAInformation } from './ICAInformation.schema'; + +export type IndustryChangeApplicationDocument = + HydratedDocument; + +@Schema({ + timestamps: true, +}) +export class IndustryChangeApplication { + @Prop({ + required: true, + ref: 'Resident', + type: mongoose.Schema.Types.ObjectId, + }) + resident: Resident; + + @Prop({ + required: true, + type: ICAInformation, + }) + current: ICAInformation; + + @Prop({ + required: true, + type: ICAInformation, + }) + requested: ICAInformation; + + @Prop({ + type: String, + enum: ApplicationStatus, + default: ApplicationStatus.IN_REVIEW, + required: true, + }) + status: ApplicationStatus; + + @Prop() + submittedAt: Date; + + @Prop({ type: Decision }) + decision: Decision; + + @Prop() + createdBy: string; + + @Prop() + updatedBy: string; + + @Prop({ + type: String, + enum: ObjectStatus, + default: ObjectStatus.CURRENT, + required: true, + }) + objectStatus: ObjectStatus; +} + +export const IndustryChangeApplicationSchema = SchemaFactory.createForClass( + IndustryChangeApplication, +); diff --git a/src/resident/resident.module.ts b/src/resident/resident.module.ts new file mode 100644 index 0000000..1a8c196 --- /dev/null +++ b/src/resident/resident.module.ts @@ -0,0 +1,27 @@ +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { ResidentSeed } from './resident.seed'; +import { ResidentService } from './resident.service'; +import { Resident, ResidentSchema } from './schemas/Resident.schema'; +import { + ResidentAddress, + ResidentAddressSchema, +} from './schemas/ResidentAddress.schema'; + +@Module({ + imports: [ + MongooseModule.forFeature([ + { + name: ResidentAddress.name, + schema: ResidentAddressSchema, + }, + { + name: Resident.name, + schema: ResidentSchema, + }, + ]), + ], + providers: [ResidentService, ResidentSeed], + exports: [ResidentService], +}) +export class ResidentModule {} diff --git a/src/resident/resident.seed.ts b/src/resident/resident.seed.ts new file mode 100644 index 0000000..82b3e16 --- /dev/null +++ b/src/resident/resident.seed.ts @@ -0,0 +1,55 @@ +import { Injectable } from '@nestjs/common'; +import { ResidentService } from './resident.service'; +import { Command } from 'nestjs-command'; +import { + TypeOfRegistration, + TypeOfRegistrationSub, +} from 'src/enums/type-of-registration.enums'; +import { Industry } from 'src/enums/industry.enum'; +import { RegulatoryElection } from 'src/enums/regulatory-election.enums'; +import { ResidentStatus } from 'src/enums/status.enum'; + +@Injectable() +export class ResidentSeed { + constructor(private readonly residentService: ResidentService) {} + + @Command({ + command: 'create:resident', + describe: 'Create initial resident', + }) + async create() { + const resident = await this.residentService.createResident({ + sub: 'f26d49bd-73aa-4e9c-b793-a367e1315b7d', + firstName: 'Someone', + lastName: 'Special', + fullName: 'Someone Special', + permitNumber: 1234, + permitNumberQrCode: '', + dateOfBirth: new Date('1998-12-13'), + countryOfBirth: 'Estonia', + email: 'someone.special@world-news.local', + citizenship: 'Estonia', + gender: 'm', + address: { + country: 'Estonia', + city: 'Tallinn', + streetAddress: '9 Lambi Tee', + zipCode: '34211', + isVerifiedAddress: true, + }, + phoneNumber: '+372 5454 1010', + typeOfRegistration: TypeOfRegistration.E_RESIDENCY, + typeOfRegistrationSub: TypeOfRegistrationSub.INTERNATIONAL, + industry: Industry.WASTE_MANAGEMENT, + willWorkInPhysicalJurisdiction: false, + regulatoryElection: RegulatoryElection.ESTONIA, + regulatoryElectionSub: 'sub info', + firstRegistrationDate: new Date('2006-06-12'), + profilePicture: '', + status: ResidentStatus.ACTIVE, + nextSubscriptionPaymentDate: new Date(Date.now() + 31 * 24 * 60 * 60000), + }); + + console.log(resident); + } +} diff --git a/src/resident/resident.service.ts b/src/resident/resident.service.ts new file mode 100644 index 0000000..c227012 --- /dev/null +++ b/src/resident/resident.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Model } from 'mongoose'; +import { Resident, ResidentDocument } from './schemas/Resident.schema'; +import { ResidentAddress } from './schemas/ResidentAddress.schema'; + +@Injectable() +export class ResidentService { + constructor( + @InjectModel(Resident.name) private residentModel: Model, + ) {} + + public async createResident(resident: Partial): Promise { + const createdResident = new this.residentModel(resident); + return createdResident.save(); + } +} diff --git a/src/resident/schemas/Resident.schema.ts b/src/resident/schemas/Resident.schema.ts new file mode 100644 index 0000000..5458e12 --- /dev/null +++ b/src/resident/schemas/Resident.schema.ts @@ -0,0 +1,92 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { HydratedDocument } from 'mongoose'; +import { Industry } from 'src/enums/industry.enum'; +import { RegulatoryElection } from 'src/enums/regulatory-election.enums'; +import { ResidentStatus } from 'src/enums/status.enum'; +import { + TypeOfRegistration, + TypeOfRegistrationSub, +} from 'src/enums/type-of-registration.enums'; +import { ResidentAddress } from './ResidentAddress.schema'; + +export type ResidentDocument = HydratedDocument; + +@Schema() +export class Resident { + @Prop({ required: true, unique: true }) + sub: string; + + @Prop({ required: true }) + firstName: string; + + @Prop({ required: true }) + lastName: string; + + @Prop({ required: true }) + fullName: string; + + @Prop({ required: true }) + permitNumber: number; + + @Prop() + permitNumberQrCode: string; + + @Prop({ required: true }) + dateOfBirth: Date; + + @Prop({ required: true }) + countryOfBirth: string; + + @Prop({ required: true }) + email: string; + + @Prop({ required: true }) + citizenship: string; + + @Prop({ required: true }) + gender: string; + + @Prop({ + type: ResidentAddress, + required: true, + }) + address: ResidentAddress; + + @Prop({ required: true }) + phoneNumber: string; + + @Prop({ required: true, type: String, enum: TypeOfRegistration }) + typeOfRegistration: TypeOfRegistration; + + @Prop({ type: String, enum: TypeOfRegistrationSub }) + typeOfRegistrationSub: TypeOfRegistrationSub; + + @Prop({ type: String, enum: Industry }) + industry: Industry; + + @Prop({ required: true }) + willWorkInPhysicalJurisdiction: boolean; + + @Prop({ type: String, enum: RegulatoryElection }) + regulatoryElection: RegulatoryElection; + + @Prop() + regulatoryElectionSub: string; + + @Prop({ required: true }) + firstRegistrationDate: Date; + + @Prop({ required: true }) + nextSubscriptionPaymentDate: Date; + + @Prop({ required: true }) + profilePicture: string; + + @Prop({ required: true, type: String, enum: ResidentStatus }) + status: ResidentStatus; + + @Prop() + residencyEndDate: Date; +} + +export const ResidentSchema = SchemaFactory.createForClass(Resident); diff --git a/src/resident/schemas/ResidentAddress.schema.ts b/src/resident/schemas/ResidentAddress.schema.ts new file mode 100644 index 0000000..9b10fec --- /dev/null +++ b/src/resident/schemas/ResidentAddress.schema.ts @@ -0,0 +1,25 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; + +@Schema({ _id: false }) +export class ResidentAddress { + @Prop({ required: true }) + country: string; + + @Prop({ required: true }) + city: string; + + @Prop() + state?: string; + + @Prop({ required: true }) + streetAddress: string; + + @Prop({ required: true }) + zipCode: string; + + @Prop({ required: true }) + isVerifiedAddress: boolean; +} + +export const ResidentAddressSchema = + SchemaFactory.createForClass(ResidentAddress);