Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Commits on Source (8)
Showing
with 6230 additions and 5387 deletions
......@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.0.0](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta5...v2.0.0) (2022-12-02)
### ⚠ BREAKING CHANGES
* **deps:** mongoose and axios updates.
### Bug Fixes
* **structure:** issues ([8587561](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/858756190cd2c0e805726e9b09c65c3193ba00e6))
* **deps:** major updates of libs ([6b411a7](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/6b411a74b364af6efec1b082a0f7981f4a1e14b5))
## [2.0.0-beta5](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta4...v2.0.0-beta5) (2022-11-23)
......
{
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/src/.*\\.(test|spec).(ts|tsx|js)$",
"collectCoverageFrom": ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],
"coverageReporters": ["json", "lcov"],
"reporters": ["default", "jest-junit"]
}
This diff is collapsed.
{
"name": "ram_server",
"private": true,
"version": "2.0.0-beta5",
"version": "2.0.0",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
......@@ -17,9 +17,9 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"release": "standard-version",
"init-db": "node ./scripts/init-db.js",
"test": "jest --config ./test/jest.json --coverage",
"test:watch": "jest --config ./test/jest.json --watch --coverage",
"test:cov": "jest --config ./test/jest.json --coverage --ci --reporters=default --reporters=jest-junit",
"test": "jest --config ./jest.json --coverage",
"test:watch": "jest --config ./jest.json --watch --coverage",
"test:cov": "jest --config ./jest.json --coverage --ci --reporters=default --reporters=jest-junit",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"migrate:create": "migrate create --template-file ./src/migrations/migrations-utils/template.ts --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\"",
......@@ -27,40 +27,39 @@
"migrate:down": "migrate --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\" down"
},
"dependencies": {
"@elastic/elasticsearch": "^7.12.0",
"@mailchimp/mailchimp_marketing": "^3.0.78",
"@nestjs/axios": "^0.1.0",
"@elastic/elasticsearch": "~8.5.0",
"@mailchimp/mailchimp_marketing": "^3.0.80",
"@nestjs/axios": "^1.0.0",
"@nestjs/common": "^9.0.11",
"@nestjs/config": "^0.6.3",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.11",
"@nestjs/elasticsearch": "^7.1.0",
"@nestjs/jwt": "^7.2.0",
"@nestjs/mongoose": "^7.1.0",
"@nestjs/passport": "^7.1.5",
"@nestjs/platform-express": "^9.0.11",
"@nestjs/elasticsearch": "^9.0.0",
"@nestjs/jwt": "^9.0.0",
"@nestjs/mongoose": "^9.2.1",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.2.0",
"@nestjs/schedule": "^0.4.1",
"@nestjs/swagger": "^6.1.2",
"@tryghost/admin-api": "^1.4.4",
"@types/bcrypt": "^3.0.0",
"axios": "^0.27.2",
"bcrypt": "^5.0.1",
"class-transformer": "^0.3.1",
"class-validator": "^0.13.0",
"dotenv": "^8.2.0",
"ejs": "^3.1.7",
"form-data": "^3.0.0",
"@nestjs/swagger": "^6.1.3",
"@tryghost/admin-api": "^1.13.1",
"@types/bcrypt": "^5.0.0",
"axios": "1.1.3",
"bcrypt": "^5.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"form-data": "^4.0.0",
"luxon": "^1.25.0",
"migrate": "^1.7.0",
"mongoose": "^5.10.15",
"migrate": "^1.8.0",
"mongoose": "^6.7.3",
"passport": "^0.6.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.7",
"sanitize-html": "^2.6.1",
"standard-version": "^9.3.2",
"swagger-ui-express": "^4.3.0"
"rxjs": "^7.5.5",
"sanitize-html": "^2.7.3",
"swagger-ui-express": "^4.6.0"
},
"devDependencies": {
"@compodoc/compodoc": "^1.1.16",
......@@ -70,7 +69,6 @@
"@nestjs/testing": "^9.0.11",
"@types/express": "^4.17.8",
"@types/jest": "^26.0.15",
"@types/mongoose": "^5.10.1",
"@types/node": "^14.14.6",
"@types/passport-local": "^1.0.33",
"@types/supertest": "^2.0.10",
......@@ -79,13 +77,14 @@
"eslint": "^8.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^26.6.3",
"jest": "28.1.2",
"jest-junit": "^14.0.0",
"nodemon": "^2.0.20",
"prettier": "^2.1.2",
"standard-version": "^9.5.0",
"supertest": "^6.0.0",
"ts-jest": "^26.4.3",
"ts-loader": "^8.0.8",
"ts-jest": "^28.0.5",
"ts-loader": "^9.4.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.4"
......
......@@ -2,5 +2,6 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>systemes-dinformation/renovate/renovate-config"
]
],
"labels": ["dependencies"]
}
......@@ -365,5 +365,24 @@ module.exports = {
theme: 'Public',
id: 'publicOthers',
},
{
modules: [
{
id: 'donDeMateriels',
name: 'Prêt / don de matériels',
},
{
id: 'reconditionnementsDeMateriel',
name: 'Reconditionnements de matériel',
},
{
id: 'accesLivresInformatiques',
name: 'Accès à des revues ou livres informatiques et numériques',
},
],
name: 'Autres services',
theme: 'Matériel et wifi',
id: 'equipmentsServices',
},
],
};
......@@ -28,7 +28,6 @@ const param =
mongoose.connect(param, { useNewUrlParser: true, useUnifiedTopology: true }).catch((error) => console.log(error));
// Make Mongoose use `findOneAndUpdate()`. Note that this option is `true`
// by default, you need to set it to false.
mongoose.set('useFindAndModify', false);
function hashPassword() {
return bcrypt.hashSync(process.env.USER_PWD, process.env.SALT);
......
......@@ -210,7 +210,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = '6231aefe76598527c8d0b5bc';
const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra',
validated: true,
};
......@@ -228,7 +228,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = '6231aefe76598527c8d0b5bc';
const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra',
validated: true,
};
......@@ -250,7 +250,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = 'thisuserdoesnotexist';
const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra',
validated: true,
};
......@@ -274,7 +274,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = '6231aefe76598527c8d0b5bc';
const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Toto',
validated: true,
};
......@@ -292,7 +292,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = '6231aefe76598527c8d0b5bc';
const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Dev',
validated: true,
};
......@@ -314,7 +314,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = 'thisuserdoesntexist';
const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'),
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Dev',
validated: true,
};
......
......@@ -219,8 +219,8 @@ export class AdminController {
return formatUsers.map((user) => {
return {
id: user._id,
createdAt: user.createdAt ? user.createdAt.toLocaleDateString() : '',
unattachedSince: user.unattachedSince ? user.unattachedSince.toLocaleDateString() : '',
createdAt: user.createdAt ? user.createdAt.toLocaleDateString('fr-FR') : '',
unattachedSince: user.unattachedSince ? user.unattachedSince.toLocaleDateString('fr-FR') : '',
surname: user.surname,
name: user.name,
email: user.email,
......
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import * as dotenv from 'dotenv';
import { config } from 'dotenv';
import { UsersModule } from '../users/users.module';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { JwtStrategy } from './strategy/jwt.strategy';
dotenv.config();
config();
@Module({
imports: [
......
import { Logger } from '@nestjs/common';
import * as dotenv from 'dotenv';
import { config } from './config';
import { configProd } from './config.prod';
import { configDev } from './config.dev';
import { configProd } from './config.prod';
import { configRec } from './config.rec';
export class ConfigurationService {
private readonly _config;
......
import { MongoClient } from 'mongodb';
import { config } from 'dotenv';
import { MongoClient } from 'mongodb';
export const getDb = async () => {
config(); // Required for reading .env
const client: MongoClient = await MongoClient.connect(
`mongodb://${process.env.MONGO_NON_ROOT_USERNAME}:${process.env.MONGO_NON_ROOT_PASSWORD}@${process.env.MONGO_DB_HOST_AND_PORT}/ram`,
{ useUnifiedTopology: true }
`mongodb://${process.env.MONGO_NON_ROOT_USERNAME}:${process.env.MONGO_NON_ROOT_PASSWORD}@${process.env.MONGO_DB_HOST_AND_PORT}/ram`
);
return client.db();
};
import { Db, Cursor } from 'mongodb';
import { Db } from 'mongodb';
import { StructureDocument } from '../../structures/schemas/structure.schema';
import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({});
let document: StructureDocument;
const cursor = db.collection('structures').find({});
let document;
while ((document = await cursor.next())) {
const newDoc = updateStructure(document);
const newDoc: StructureDocument = updateStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log("Updated : removed 'Arrondissement' from structure's commune ");
......@@ -15,10 +15,10 @@ export const up = async () => {
export const down = async () => {
const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({});
let document: StructureDocument;
const cursor = db.collection('structures').find({});
let document;
while ((document = await cursor.next())) {
const newDoc = downgradeStructure(document);
const newDoc: StructureDocument = downgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log("Downgraded : added 'Arrondissement' to structure's commune");
......
......@@ -3,7 +3,8 @@ import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
await db.collection('tclstoppoints').updateMany({}, { $pull: { busLines: { $in: ['PL1', 'PL2', 'PL3'] } } });
//Removed after mongosse migration. It's now useless, it's handled by tcl service directly
// await db.collection('tclstoppoints').updateMany({}, { $pull: { busLines: { $in: ['PL1', 'PL2', 'PL3'] } } });
await db.collection('tclstoppoints').deleteMany({
$and: [{ tramLines: { $size: 0 } }, { subLines: { $size: 0 } }, { busLines: { $size: 0 } }],
});
......
......@@ -10,7 +10,7 @@ export const up = async () => {
// Create categories fields
let document;
while ((document = await cursor.next())) {
const newDoc = upgradeStructure(document);
const newDoc: StructureDocument = upgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log(`Update done : new structrure repository ref`);
......@@ -29,9 +29,9 @@ export const up = async () => {
export const down = async () => {
const db: Db = await getDb();
const cursor = db.collection('structures').find({});
let document: StructureDocument;
let document;
while ((document = await cursor.next())) {
const newDoc = downgradeStructure(document);
const newDoc: StructureDocument = downgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log(`Downgrade done : new structrure repository removed`);
......@@ -310,6 +310,7 @@ const mapPublics = (doc: any): StructureDocument => {
const languageAndIlliteracy = [];
const handicaps = [];
const publicOthers = [];
const solidarityMaterial = [];
doc.publics?.forEach((el) => {
switch (el) {
case 'toutPublic':
......@@ -368,5 +369,6 @@ const mapPublics = (doc: any): StructureDocument => {
doc.categories.languageAndIlliteracy = languageAndIlliteracy;
doc.categories.handicaps = handicaps;
doc.categories.publicOthers = publicOthers;
doc.categories.solidarityMaterial = solidarityMaterial;
return doc;
};
import { Db } from 'mongodb';
import { StructureType } from '../../structures/structure-type/structure-type.schema';
import { StructureTypeDocument } from '../../structures/structure-type/structure-type.schema';
import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
const cursor = db.collection('structuretype').find({});
let document: StructureType;
let document;
const documents = [];
// List documents to process
while ((document = await cursor.next())) {
......@@ -24,7 +24,9 @@ export const up = async () => {
let structure;
while ((structure = await cursorStructure.next())) {
if (structure.structureType) {
const structureType = await db.collection('structuretype').findOne({ value: structure.structureType });
const structureType = await db
.collection('structuretype')
.findOne<StructureTypeDocument>({ value: structure.structureType });
await db
.collection('structures')
.updateOne({ _id: structure._id }, { $set: { structureType: structureType ? structureType._id : null } });
......@@ -41,7 +43,9 @@ export const down = async () => {
let structure;
while ((structure = await cursorStructure.next())) {
if (structure.structureType) {
const structureType = await db.collection('structuretype').findOne({ _id: structure.structureType });
const structureType = await db
.collection('structuretype')
.findOne<StructureTypeDocument>({ _id: structure.structureType });
await db
.collection('structures')
.updateOne({ _id: structure._id }, { $set: { structureType: structureType.value } });
......@@ -49,7 +53,7 @@ export const down = async () => {
}
const cursor = db.collection('structuretype').find({});
let document: StructureType;
let document;
const documents = [];
// List documents to process
......
......@@ -3,6 +3,10 @@ import { Document } from 'mongoose';
export type OnlineMediationDocument = OnlineMediation & Document;
class DateSlot {
day: string;
hours: string;
}
@Schema()
export class OnlineMediation {
@Prop()
......@@ -17,8 +21,8 @@ export class OnlineMediation {
@Prop()
onlineDemarchType: string[];
@Prop()
dateSlot: { day: string; hours: string };
@Prop({ type: DateSlot })
dateSlot: DateSlot;
@Prop()
preferredLanguage: string;
......
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { StructureCategories } from '../../structures/schemas/structureCategories.schema';
export type PersonalOfferDocument = PersonalOffer & Document;
@Schema({ timestamps: true })
export class PersonalOffer {
@Prop()
categories: any;
@Prop({ type: StructureCategories })
categories: StructureCategories;
}
export const PersonalOfferSchema = SchemaFactory.createForClass(PersonalOffer);
import { AnalysisAnalyzer, IndicesIndexSettings } from '@elastic/elasticsearch/lib/api/types';
import { ConfigurationService } from '../configuration/configuration.service';
import { Page } from '../pages/schemas/page.schema';
import { Post } from '../posts/schemas/post.schema';
......@@ -22,7 +23,20 @@ export function hasAdminRole(user: User): boolean {
return user.role === UserRole.admin;
}
export const es_settings_homemade_french = {
const analyzer: Record<string, AnalysisAnalyzer> = {
homemade_french: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stop', 'french_stemmer'],
},
homemade_french_stopless: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stemmer'],
},
};
export const es_settings_homemade_french: IndicesIndexSettings = {
analysis: {
filter: {
french_elision: {
......@@ -39,15 +53,6 @@ export const es_settings_homemade_french = {
language: 'minimal_french',
},
},
analyzer: {
homemade_french: {
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stop', 'french_stemmer'],
},
homemade_french_stopless: {
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stemmer'],
},
},
analyzer: analyzer,
},
};
import { StructureSearchBody } from './structure-search-body.interface';
export interface StructureSearchResult {
hits: {
total: number;
max_score: number;
hits: Array<{
_score: number;
_source: StructureSearchBody;
}>;
};
}