diff --git a/.eslintrc.js b/.eslintrc.js index b50df38abb667dbd958088aa1e1628bf6f368532..ea22bc2bd2cf7a14d7ad92192883cbd32c334200 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,12 +4,13 @@ module.exports = { project: true, sourceType: 'module', }, - plugins: ['@typescript-eslint/eslint-plugin', 'jest'], + plugins: ['@typescript-eslint/eslint-plugin', 'jest', 'jsdoc'], extends: [ 'plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended', 'plugin:jest/recommended', + 'plugin:jsdoc/recommended', ], root: true, env: { @@ -23,5 +24,17 @@ module.exports = { '@typescript-eslint/no-explicit-any': 'warn', 'jest/no-conditional-expect': 'off', + + // JSDOC extends overrides: disable some of extends rules + // JSdoc is not always needed + 'jsdoc/require-jsdoc': 0, + // Prefer declaring types with typescript + 'jsdoc/require-returns': 0, + 'jsdoc/require-returns-type': 0, + 'jsdoc/require-param': 0, + 'jsdoc/require-param-type': 0, + + // Allow some params to be described and some to be omitted + 'jsdoc/check-param-names': 0, }, }; diff --git a/package-lock.json b/package-lock.json index 4ae30cc8ce2c01466ab7d732a94a241d5fff82e7..c850d2f45d28ea3fca6478d14bca8e7a276506c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,6 +62,7 @@ "@typescript-eslint/parser": "^5.37", "eslint": "^8.0.0", "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^48.2.4", "eslint-plugin-prettier": "^4.0.0", "jest": "28.1.2", "jest-junit": "^14.0.0", @@ -4421,6 +4422,42 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/@es-joy/jsdoccomment": { + "version": "0.43.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.43.0.tgz", + "integrity": "sha512-Q1CnsQrytI3TlCB1IVWXWeqUIPGVEKGaE7IbVdt13Nq/3i0JESAkQQERrfiQkmlpijl+++qyqPgaS31Bvc1jRQ==", + "dev": true, + "dependencies": { + "@types/eslint": "^8.56.5", + "@types/estree": "^1.0.5", + "@typescript-eslint/types": "^7.2.0", + "comment-parser": "1.4.1", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@es-joy/jsdoccomment/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/@es-joy/jsdoccomment/node_modules/@typescript-eslint/types": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.8.0.tgz", + "integrity": "sha512-wf0peJ+ZGlcH+2ZS23aJbOv+ztjeeP8uQ9GgwMJGVLx/Nj9CJt17GWgWWoSmoRVKAX2X+7fzEnAjxdvK2gqCLw==", + "dev": true, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", @@ -6749,9 +6786,9 @@ "dev": true }, "node_modules/@types/eslint": { - "version": "8.4.6", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.6.tgz", - "integrity": "sha512-/fqTbjxyFUaYNO7VcW5g+4npmqVACz1bB7RTHYuLj+PRjw9hrCwrUXVQFpChUS0JsyEFvMZ7U/PfmvWgxJhI9g==", + "version": "8.56.10", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", + "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", "dev": true, "dependencies": { "@types/estree": "*", @@ -7737,6 +7774,15 @@ "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", + "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/are-we-there-yet": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", @@ -8432,6 +8478,18 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -8836,6 +8894,15 @@ "node": ">= 6" } }, + "node_modules/comment-parser": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz", + "integrity": "sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -10360,6 +10427,74 @@ } } }, + "node_modules/eslint-plugin-jsdoc": { + "version": "48.2.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.2.4.tgz", + "integrity": "sha512-3ebvVgCJFy06gpmuS2ynz13uh9iFSzZ1C1dDkgcSAqVVg82zlORKMk2fvjq708pAO6bwfs5YLttknFEbaoDiGw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.43.0", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.1", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.6.0", + "spdx-expression-parse": "^4.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/eslint-plugin-jsdoc/node_modules/spdx-expression-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz", + "integrity": "sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ==", + "dev": true, + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "node_modules/eslint-plugin-prettier": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", @@ -10752,9 +10887,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dependencies": { "estraverse": "^5.1.0" }, @@ -12756,6 +12891,21 @@ "node": ">=8" } }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-core-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.0.0.tgz", @@ -15726,6 +15876,15 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -18504,12 +18663,9 @@ "integrity": "sha512-ZQruFgZnIWH+WyO9t5rWt4ZEGqCKPwhiw+YbzTwpmT9elgLrLcfuyUiSnwwjUiVy9r4VM3urtbNF1xmEh9IL2w==" }, "node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "bin": { "semver": "bin/semver.js" }, @@ -18517,22 +18673,6 @@ "node": ">=10" } }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", diff --git a/package.json b/package.json index 125101c81f14c6ec97d2825cd41776fa773bcf1f..493a2c71dad28639540c4640883a97a4d853c721 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "@typescript-eslint/parser": "^5.37", "eslint": "^8.0.0", "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^48.2.4", "eslint-plugin-prettier": "^4.0.0", "jest": "28.1.2", "jest-junit": "^14.0.0", diff --git a/src/appointment/appointment.service.ts b/src/appointment/appointment.service.ts index e4658919ec6819a44197f97eaf5af1338f575d10..98aec695574005fdd0690bc814f078b62757bb3c 100644 --- a/src/appointment/appointment.service.ts +++ b/src/appointment/appointment.service.ts @@ -25,10 +25,6 @@ export class AppointmentService { private readonly mailerService: MailerService ) {} - /** - * @param newAppointment - * @returns {Promise<AppointmentDocument>} - */ public async create(newAppointment: AppointmentDto): Promise<IAppointment> { this.appointment = newAppointment; @@ -55,9 +51,6 @@ export class AppointmentService { } } - /** - * @returns {Promise<AppointmentDocument[]>} - */ public async findAll(): Promise<IAppointment[]> { return this.AppointmentModel.find().exec(); } diff --git a/src/mailer/mailer.service.ts b/src/mailer/mailer.service.ts index 56ba22d8a25b2461c9e01cbb8ea7259cbffd2f09..ae2b20808dfbaf403bd6066c08778f4b6994799e 100644 --- a/src/mailer/mailer.service.ts +++ b/src/mailer/mailer.service.ts @@ -72,7 +72,6 @@ export class MailerService { /** * Add site mail signature to a given html - * @param html */ public addSignature(html: string): string { html += `<br /><br /><p>L’équipe projet inclusion numérique.</p><p style="font-family:helvetica;font-size:24px;font-weight:bold;margin:0;">rés<span style="color:red;font-weight:400;">’in</span></p><br /><br /><p>Ce mail est automatique. Merci de ne pas y répondre.<br/><br/>Pour nous contacter : <a href="mailto:inclusionnumerique@grandlyon.com">inclusionnumerique@grandlyon.com</a></p>`; diff --git a/src/online-mediation/onlineMediation.service.ts b/src/online-mediation/onlineMediation.service.ts index ae44246a535041ec0b394d6936ed8bebab4f5866..f7dd58268add39c1142d3577643f7cf80833dedf 100644 --- a/src/online-mediation/onlineMediation.service.ts +++ b/src/online-mediation/onlineMediation.service.ts @@ -18,10 +18,6 @@ export class OnlineMediationService { private readonly mailerService: MailerService ) {} - /** - * @param newMediation - * @returns {Promise<OnlineMediationDocument>} - */ public async create(newMediation: OnlineMediationDto): Promise<IOnlineMediation> { try { newMediation.surname = newMediation.surname.toUpperCase(); @@ -32,9 +28,6 @@ export class OnlineMediationService { } } - /** - * @returns {Promise<OnlineMediationDocument[]>} - */ public async getAll(): Promise<IOnlineMediation[]> { return this.OnlineMediationModel.find().sort({ NamedNodeMap: 1 }).exec(); } diff --git a/src/personal-offers/dto/personal-offer.dto.ts b/src/personal-offers/dto/personal-offer.dto.ts index 98734c4e5640db94b892bff75b73a2b2c65655f4..32ed3bfd777a658591feb73f9ba72cb2c2c149c8 100644 --- a/src/personal-offers/dto/personal-offer.dto.ts +++ b/src/personal-offers/dto/personal-offer.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; export class PersonalOfferDto { - /** accompaniments **/ + /** accompaniments */ @ApiProperty({ description: 'List of personal offers categories', type: [{}], diff --git a/src/personal-offers/personal-offers.controller.ts b/src/personal-offers/personal-offers.controller.ts index d3543b6ab132abcc9108e0acb95c0e337242c346..483e7ce8566d7f7d08688a090ba887963cfde540 100644 --- a/src/personal-offers/personal-offers.controller.ts +++ b/src/personal-offers/personal-offers.controller.ts @@ -20,7 +20,7 @@ import { UsersService } from '../users/services/users.service'; import { CreatePersonalOfferDto } from './dto/create-personal-offer.dto'; import { PersonalOfferDto } from './dto/personal-offer.dto'; import { PersonalOffersService } from './personal-offers.service'; -import { PersonalOfferDocument } from './schemas/personal-offer.schema'; +import { PersonalOffer, PersonalOfferDocument } from './schemas/personal-offer.schema'; import { Types } from 'mongoose'; @ApiTags('personnal-offers') @@ -34,19 +34,15 @@ export class PersonalOffersController { /** * Return personal offer of given id. - * @param id - * @returns {PersonalOffer} Personal offer */ @Get(':id') @ApiParam({ name: 'id', type: String, required: true }) - public async find(@Param('id') id: string) { + public async find(@Param('id') id: string): Promise<PersonalOffer> { return this.personalOffersService.findOne(id); } /** * Create and return a personal offer. - * @param createPersonalOfferDto - * @returns {PersonalOffer} created personal offer */ @Post() @ApiBody({ type: CreatePersonalOfferDto, required: true }) @@ -74,9 +70,6 @@ export class PersonalOffersController { /** * Update and return a personal offer. - * @param id - id of the personal offer to update - * @param updatePersonalOfferDto - personal offer data to update - * @returns {PersonalOffer} Updated personal offer */ @Put(':id') @ApiParam({ name: 'id', type: String, required: true }) @@ -91,8 +84,6 @@ export class PersonalOffersController { /** * Delete and return a personal offer. - * @param id - id of the personal offer to delete - * @returns {PersonalOffer} Deleted personal offer */ @Delete(':id') @ApiParam({ name: 'id', type: String, required: true }) diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index fd524aee4c12c384e1ee060a748cd0ede250b652..019fef247999b7a88af191552f29f251b4083eaf 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -131,9 +131,6 @@ export class StructuresService { /** * Filter offers using structure offers and structure members personalOffers - * @param structures - * @param andFiltersOnOffers - * @returns StructureDocument[] */ private async filterOnOffers( structures: StructureDocument[], @@ -171,7 +168,6 @@ export class StructuresService { /** * set structure offers and structure social workers personalOffers in non-persistant property structure.categoriesWithPersonalOffers - * @param structure */ public async setCategoriesWithPersonalOffers(structure: StructureDocument, onlyOffersWithAppointment: boolean) { if (onlyOffersWithAppointment) { @@ -310,8 +306,6 @@ export class StructuresService { /** * Parse equipments. Ex : if structure doesn't have computers but nbComputer changes, then the key is added to equipmentsAndServices - * @param structure - * @returns Structure */ public getSelfServiceMaterial(structure: StructureDocument): string[] { Logger.debug(`getSelfServiceMaterial of ${structure.structureName}`, StructuresService.name); @@ -333,7 +327,6 @@ export class StructuresService { /** * Parse filter value from string to boolean and map filter category to categories key - * @param filters */ private parseFilter(filters: Array<{ [key: string]: unknown }>): Array<{ [key: string]: unknown }> { return filters.map((filter) => { @@ -406,9 +399,6 @@ export class StructuresService { } /** * Map modules labels to ids - * @param structureModule - * @param baseModule - * @returns */ public mapModules(structureModule: string[], baseModule: Module[]): string[] { if (structureModule.length === 0) { @@ -661,7 +651,6 @@ export class StructuresService { /** * Get city formatted without "Arrondissement" - * @param {searchQuery} data - Query address */ public getFormattedCity(city: string, postcode: string) { let formattedCity: string = city; @@ -678,7 +667,6 @@ export class StructuresService { /** * Search structure address based on data search WS - * @param {searchQuery} data - Query address */ public async searchAddress(data: { searchQuery: string }): Promise<{ features: PhotonPoints[] }> { const reqBan = `https://download.data.grandlyon.com/geocoding/photon/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`; @@ -708,7 +696,7 @@ export class StructuresService { /** * Remove accents from a string by decomposing accented characters and removing diacritical marks. * @param {string} str - The input string. - * @returns {string} - The string with accents removed. + * @returns {string} The string with accents removed. */ const removeAccents = (str: string) => { if (!str) return ''; @@ -738,7 +726,6 @@ export class StructuresService { /** * Count every value occurrence of a given key * @param key structure key - * @return [{id: 'key', count: 'value'}] */ public async countByStructureKey(key: string, selected: { id: string; text: string }[]) { const uniqueElements = await this.structureModel.distinct(key).exec(); @@ -790,8 +777,6 @@ export class StructuresService { /** * Set the structure to be deleted in 5 weeks - * @param user IUser - * @param structure StructureDocument */ public async setToBeDeleted(user: IUser, structure: StructureDocument): Promise<Structure> { if (!structure) { @@ -806,7 +791,6 @@ export class StructuresService { /** * Send an email to structure owners (except the one who asked for the deletion) to inform the structure is will be deleted in 5 weeks - * @param user User */ public async sendToBeDeletedNotification(user: IUser, structure: StructureDocument): Promise<void> { const config = this.mailerService.config; @@ -832,8 +816,6 @@ export class StructuresService { /** * Cancel the structure deletion when one of the structure owners had asked the structure for deletion - * @param user IUser - * @param structure StructureDocument */ public async cancelDelete(user: IUser, structure: StructureDocument): Promise<Structure> { if (!structure) { @@ -850,7 +832,6 @@ export class StructuresService { /** * Send an email to other structure owners to inform an owner cancelled the structure deletion - * @param user User */ public async sendCancelDeleteNotification(user: IUser, structure: StructureDocument): Promise<void> { const config = this.mailerService.config; @@ -1026,7 +1007,6 @@ export class StructuresService { /** * Send an email to prevent outdated * a new account. - * @param user User */ private async sendOutdatedEmailToUser(userEmail: string, structureName: string, id: string): Promise<void> { const config = this.mailerService.config; @@ -1043,7 +1023,6 @@ export class StructuresService { /** * Send an email to structure owners and admin in order to accept or decline a join request - * @param user User */ public async sendStructureJoinRequest( user: IUser, @@ -1143,8 +1122,6 @@ export class StructuresService { * Case 1 : null value stands for 'no' * Case 2: a date stands for 'yes' * Case 3: no key in document when there is no reply to consent - * @param users {IUser} - * @returns {Structure[]} */ public async getAllDataConsentPendingStructures(users: IUser): Promise<Structure[]> { const data = await Promise.all( @@ -1160,9 +1137,6 @@ export class StructuresService { /** * Add the personal offer to the structure - * @param structureId string - * @param personalOfferDocument PersonalOfferDocument - * @returns {Structure} structure with personal offer added */ public async addPersonalOffer( structureId: string, @@ -1186,7 +1160,6 @@ export class StructuresService { /** * Fetch espace coop and filter structures in 69XXX and structures with courriel and phone - * @returns CNFSStructure[] */ public getCNFSStructures(): Promise<Array<CNFSStructure>> { this.logger.debug(`get CNFS structures`); @@ -1224,7 +1197,6 @@ export class StructuresService { /** * When a structure is created, fetch espace coop and tries to find a match to bind CNFSid to the resin structure. - * @param resinStructureId string */ public async bindOneCNFSStructure(resinStructureId: string): Promise<string> { this.logger.debug(`bind CNFS id to one resin structure`); @@ -1361,7 +1333,6 @@ export class StructuresService { /** * Updates the denormalized (DN) fields of the structure - * @param user */ public async updateDenormalizedFields(idStructure: Types.ObjectId): Promise<StructureDocument> { const structure = await this.findOne(idStructure.toHexString()); diff --git a/src/structures/structures.controller.ts b/src/structures/structures.controller.ts index 135bb7e12c02728ead23971af354bd5e02abdf24..cefcd5ef266116233ae267ae882d0728ecc06577 100644 --- a/src/structures/structures.controller.ts +++ b/src/structures/structures.controller.ts @@ -59,7 +59,6 @@ export class StructuresController { /** * Return points of given town exist. - * @param zipcode * @returns Array of points */ @Get('coordinates/:zipcode') diff --git a/src/tcl/tclStopPoint.service.ts b/src/tcl/tclStopPoint.service.ts index ae1967c6eaaabe5d6ffec3258bd14199ddeb7474..4dd0256bdd65273387f04f6006c3ee660ef472e5 100644 --- a/src/tcl/tclStopPoint.service.ts +++ b/src/tcl/tclStopPoint.service.ts @@ -262,9 +262,7 @@ export class TclStopPointService { } /** - * Query collection to get neareast coord - * @param pgisCoord PgisCoord - * @param maxDistance number + * Query collection to get nearest coord */ public async getStopPointsByDistance(pgisCoord: PgisCoord, maxDistance: number): Promise<TclStopPoint[]> { return this.tclStopPointModel diff --git a/src/temp-user/temp-user.service.ts b/src/temp-user/temp-user.service.ts index 20da703198fd1ec6a240dd9bc3d4ad0f41b52503..89e35da2ec1e81dea8e661c5e77388098b26e9a3 100644 --- a/src/temp-user/temp-user.service.ts +++ b/src/temp-user/temp-user.service.ts @@ -86,7 +86,6 @@ export class TempUserService { /** * Send email in order to tell the user that an account is already filled with his structure info. - * @param user User */ public async sendUserMail(user: ITempUser, structureName: string, existingUser?: boolean): Promise<void> { const config = this.mailerService.config; diff --git a/src/users/controllers/employer.controller.ts b/src/users/controllers/employer.controller.ts index 8fff0d995c7dd9e6c3fc08d02bb76461168ccf42..fd6083cec41a6f194bca4e2325d2bdc9bb92919e 100644 --- a/src/users/controllers/employer.controller.ts +++ b/src/users/controllers/employer.controller.ts @@ -34,8 +34,6 @@ export class EmployerController { /** * Find all employer. If search is given as param, filter on it. Otherwise return everything - * @param query {Query} - * @returns {Employer[]} */ @Get() public async findAll(@Query() query?: { search: string }): Promise<Employer[]> { @@ -49,8 +47,6 @@ export class EmployerController { /** * Create new employer if does not exist - * @param newEmployer {CreateEmployerDto} - * @returns {Employer} */ @Post() @UseGuards(JwtAuthGuard) @@ -74,7 +70,6 @@ export class EmployerController { /** * Init or reset search index for employer - * @returns {Employer[]} */ @Post('searchIndex') @UseGuards(JwtAuthGuard, RolesGuard) @@ -137,8 +132,6 @@ export class EmployerController { /** * Delete Employer if exist - * @param employer {CreateEmployerDto} - Employer to delete - * @returns {Employer} */ @Delete(':id') @UseGuards(JwtAuthGuard, RolesGuard) diff --git a/src/users/controllers/jobs.controller.ts b/src/users/controllers/jobs.controller.ts index 323a00b34035f5a0e07a089693ba4c7ab1944fec..a04d58596e68026e06d02179890ec4399353dad7 100644 --- a/src/users/controllers/jobs.controller.ts +++ b/src/users/controllers/jobs.controller.ts @@ -42,8 +42,6 @@ export class JobsController { /** * Create a new job - * @param job {CreateJobDto} - * @returns {Job} */ @Post() @UseGuards(JwtAuthGuard) diff --git a/src/users/controllers/jobsGroups.controller.ts b/src/users/controllers/jobsGroups.controller.ts index e78ff9d7fb2e7f72fc5d739fbf511151575f542d..71b0961f20cf46a12eaf1be05c9e18efaf62ae0a 100644 --- a/src/users/controllers/jobsGroups.controller.ts +++ b/src/users/controllers/jobsGroups.controller.ts @@ -50,8 +50,6 @@ export class JobsGroupsController { /** * Create a new jobsGroups - * @param jobsGroups {CreateJobsGroupsDto} - * @returns {jobsGroups} */ @Post() @UseGuards(JwtAuthGuard) diff --git a/src/users/controllers/userRegistry.controller.ts b/src/users/controllers/userRegistry.controller.ts index 21184599895cb3dfbf1362a8afa8a9b0b70c869e..3980b1e7173ce5a83b147680770af61751f16ad3 100644 --- a/src/users/controllers/userRegistry.controller.ts +++ b/src/users/controllers/userRegistry.controller.ts @@ -3,7 +3,7 @@ import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger'; import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard'; import { Roles } from '../decorators/roles.decorator'; import { RolesGuard } from '../guards/roles.guard'; -import { UserRegistryPaginatedResponse } from '../interfaces/userRegistry.interface'; +import { IUserRegistry, UserRegistryPaginatedResponse } from '../interfaces/userRegistry.interface'; import { UserRegistryService } from '../services/userRegistry.service'; @ApiTags('userRegistry') @@ -14,8 +14,6 @@ export class UsersRegistryController { /** * Find all users in Registry. If search is given as param, filter on it. Otherwise return everything. Results comes paginated (default is 20 per page, defined in service) - * @param query {Query} - * @returns {PaginatedResponse} */ @Post() @UseGuards(JwtAuthGuard) @@ -36,7 +34,6 @@ export class UsersRegistryController { /** * Return every user in registry - * @returns {Promise<number>} */ @Get('/count') public async findAllCount(): Promise<number> { @@ -46,12 +43,11 @@ export class UsersRegistryController { /** * Init or reset search index for users - * @returns {IUserRegistry[]} */ @Post('searchIndex') @UseGuards(JwtAuthGuard, RolesGuard) @Roles('admin') - public async resetES() { + public async resetES(): Promise<IUserRegistry[]> { this.logger.debug('reset ES UserRegistry'); return await this.userRegistryService.initUserRegistryIndex(); } diff --git a/src/users/services/users.service.ts b/src/users/services/users.service.ts index ead2f9720df4890e8085079bf7d80e53ac2d54cb..75cba1c0546d21fceb00a5d8b679a7303a38b141 100644 --- a/src/users/services/users.service.ts +++ b/src/users/services/users.service.ts @@ -46,7 +46,6 @@ export class UsersService { /** * Create a user account - * @param createUserDto CreateUserDto */ public async create(createUserDto: CreateUserDto): Promise<IUser> { const userInDb = await this.findOne(createUserDto.email); @@ -79,13 +78,12 @@ export class UsersService { } /** - * Verify password strenth with the following rule: + * Verify password strength with the following rule: * - The string must contain at least 1 lowercase alphabetical character * - The string must contain at least 1 uppercase alphabetical character * - The string must contain at least 1 numeric character * - The string must contain at least one special character, reserved RegEx characters are escaped to avoid conflict * - The string must be eight characters or longer - * @param password string */ public isStrongPassword(password: string): boolean { const strongRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[*.! @#$%^&(){}\[\]:;<>,?\/\\~_+\-=|])(?=.{8,})/; //NOSONAR @@ -194,7 +192,6 @@ export class UsersService { /** * Return a user after credential checking. * Use for login action - * @param param LoginDto */ public async checkLogin({ email, password }: LoginDto): Promise<IUser> { const user = await this.findOne(email, true); @@ -217,7 +214,6 @@ export class UsersService { /** * Generate activation token and send it to user by email, in order to validate * a new account. - * @param user User */ private async verifyUserMail(user: IUser): Promise<IUser> { const token = crypto.randomBytes(64).toString('hex'); @@ -233,7 +229,6 @@ export class UsersService { /** * Send verification email to user - * @param user User */ public async sendVerifyUserMail(user: IUser): Promise<AxiosResponse> { const config = this.mailerService.config; @@ -268,8 +263,6 @@ export class UsersService { /** * Check that the given token is associated to userId. If it's true, validate user account. - * @param userId string - * @param token string */ public async validateUser(userId: string, token: string): Promise<User | HttpException> { const user = await this.findById(userId); @@ -360,7 +353,6 @@ export class UsersService { /** * Send reset password email based on ejs template - * @param email string */ public async sendResetPasswordEmail(email: string): Promise<void> { const user = await this.findOne(email); @@ -385,7 +377,6 @@ export class UsersService { /** * Verify reset password token existence - * @param token string */ public async checkPasswordResetToken(token: string): Promise<boolean> { const user = await this.userModel.findOne({ resetPasswordToken: token }).exec(); @@ -395,8 +386,6 @@ export class UsersService { /** * Change password with the given token and password * Token existence and password strength are verified - * @param password string - * @param token string */ public async resetPassword(password: string, token: string): Promise<void> { const user = await this.userModel.findOne({ resetPasswordToken: token }).exec(); @@ -523,9 +512,6 @@ export class UsersService { /** * Creates a 1 month valid token for a pending structure request - * @param user - * @param idStructure - * @returns */ private createPendingToken(user: IUser, idStructure: string): { token: string; createdAt: string } { const local = DateTime.local().setZone('Europe/Paris'); @@ -537,9 +523,6 @@ export class UsersService { /** * Updates the array of user's pending structures - * @param userEmail - * @param idStructure - * @returns */ public async updatePendingStructureLinked( userEmail: string, @@ -566,10 +549,7 @@ export class UsersService { } /** - * Removes a strcture from the users's pending list - * @param userEmail - * @param idStructure - * @returns + * Removes a structure from the users's pending list */ public async removeFromPendingStructureLinked( userEmail: string, @@ -779,8 +759,6 @@ export class UsersService { /** * Add the personal offer to the user - * @param userId string - * @param personalOfferDocument PersonalOfferDocument * @returns {IUser} user with personal offer added */ public async addPersonalOffer(userId: string, personalOfferDocument: PersonalOfferDocument): Promise<IUser> { @@ -816,7 +794,6 @@ export class UsersService { /** * Updates the denormalized fields of the structures of the user - * @param user */ public updateStructuresDenormalizedFields(user: IUser) { user.structuresLink.forEach(async (structureId) => { @@ -824,13 +801,6 @@ export class UsersService { }); } - /** - * - * @param profile - * @param userId - * @param employer - * @param job - */ public async updateUserProfile( userId: Types.ObjectId, employer: EmployerDocument, @@ -861,11 +831,6 @@ export class UsersService { return updated; } - /** - * - * @param job - * @param userId - */ public async updateUserJob(userId: Types.ObjectId, job: JobDocument): Promise<IUser> { this.logger.debug(`updateUserProfile - Job | ${userId}`); const updated = await this.userModel @@ -882,10 +847,6 @@ export class UsersService { return updated; } - /** - * - * @param userId - */ public async removeUserJob(userId: Types.ObjectId): Promise<IUser> { this.logger.debug(`updateUserProfile - RemoveJob | ${userId}`); const updated = await this.userModel @@ -902,11 +863,6 @@ export class UsersService { return updated; } - /** - * - * @param employer - * @param userId - */ public async updateUserEmployer(userId: Types.ObjectId, employer: EmployerDocument): Promise<IUser> { this.logger.debug(`updateUserProfile - Employer | ${userId}`); const updated = await this.userModel @@ -919,10 +875,6 @@ export class UsersService { return updated; } - /** - * - * @param userId - */ public async removeUserEmployer(userId: Types.ObjectId): Promise<IUser> { this.logger.debug(`updateUserProfile - RemoveEmployer | ${userId}`); const updated = await this.userModel.findByIdAndUpdate({ _id: userId }, { $unset: { employer: 1 } }).exec(); @@ -935,8 +887,6 @@ export class UsersService { /** * Update user details (name, surname and phone number) - * @param {UpdateDetailsDto} - * @returns {User} */ public async updateUserDetails(userId: string, updatedDetails: UpdateDetailsDto): Promise<IUser> { this.logger.debug(`updateUserDetails | ${userId}`); @@ -951,8 +901,6 @@ export class UsersService { /** * Update user's description - * @param {DescriptionDto} - * @returns {User} */ public async updateDescription(userId: string, description: DescriptionDto) { this.logger.debug(`updateUserDescription | ${userId}`); @@ -970,7 +918,6 @@ export class UsersService { /** * Update user's lastLoginDate - * @returns {User} */ public async updateLastLoginDate(user: IUser) { this.logger.debug(`updateLastLoginDate | ${user._id}`);