Skip to content

Commit 59e8b29

Browse files
committed
Remove mongoose-duplicate-error and mongoose-unique-validator packages; refactor update handling in identity services
1 parent e6020f1 commit 59e8b29

File tree

6 files changed

+8
-50
lines changed

6 files changed

+8
-50
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
"loglevel": "^1.9.1",
8181
"mjml": "^4.15.3",
8282
"mongoose": "^8.4.3",
83-
"mongoose-duplicate-error": "^1.0.0",
84-
"mongoose-unique-validator": "^4.0.1",
8583
"nest-commander": "^3.13.0",
8684
"nest-winston": "^1.10.0",
8785
"nestjs-request-context": "^3.0.0",
@@ -169,4 +167,4 @@
169167
"downloadUrl": "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-5.0.22.tgz"
170168
}
171169
}
172-
}
170+
}

src/_common/abstracts/abstract.service.schema.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,11 @@ export abstract class AbstractServiceSchema extends AbstractService implements S
228228
if (beforeEvent?.options) options = { ...options, ...beforeEvent.options }
229229
}
230230
}
231-
console.log('_id', update)
232231
let updated = await this._model
233-
.findByIdAndUpdate<Query<T | null, T, any, T>>(
234-
_id,
232+
.findOneAndUpdate<Query<T | null, T, any, T>>(
233+
{ _id },
235234
{
236-
...omit(update, ['_id']),
235+
...update,
237236
$setOnInsert: {
238237
'metadata.createdBy': this.request?.user?.username || 'anonymous',
239238
'metadata.createdAt': new Date(),

src/config.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ export default (): ConfigInstance => ({
106106
directConnection: true,
107107
},
108108
plugins: [
109-
{
110-
package: 'mongoose-duplicate-error',
111-
enabled: true,
112-
},
113-
{
114-
package: 'mongoose-unique-validator',
115-
enabled: true,
116-
},
117109
],
118110
},
119111
factorydrive: {

src/management/identities/identities-crud.service.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,16 @@ export class IdentitiesCrudService extends AbstractIdentitiesService {
5454
}
5555

5656
// if (update.state === IdentityState.TO_COMPLETE) {
57-
update = {
58-
...update,
59-
state: IdentityState.TO_VALIDATE,
60-
};
57+
update = { ...update, state: IdentityState.TO_VALIDATE };
6158

6259
await this.checkInetOrgPersonJpegPhoto(update);
6360

64-
console.log('update', update, _id, options)
65-
6661
// }
6762
// if (update.state === IdentityState.SYNCED) {
6863
// update = { ...update, state: IdentityState.TO_VALIDATE };
6964
// }
7065
//update.state = IdentityState.TO_VALIDATE;
71-
const updated = await super.update(_id, { $set: update }, options);
66+
const updated = await super.update(_id, update, options);
7267
//TODO: add backends service logic here (TO_SYNC)
7368
return await this.generateFingerprint(updated as unknown as Identities);
7469
}

src/management/identities/identities-upsert.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class IdentitiesUpsertService extends AbstractIdentitiesService {
3737
);
3838
}
3939
//controle si l identité est fusionnée si c est la bonne à mettre à jour puisqu elle a 2 employeeNumber
40-
if (identity !== null && identity?.srcFusionId !== null) {
40+
if (identity !== null && identity?.srcFusionId) {
4141
if (identity.primaryEmployeeNumber !== data?.inetOrgPerson?.employeeNumber[0]) {
4242
throw new HttpException('Secondary identity', HttpStatus.SEE_OTHER);
4343
}

yarn.lock

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8865,16 +8865,6 @@ lodash.defaults@^4.2.0:
88658865
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
88668866
integrity sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==
88678867

8868-
lodash.foreach@^4.1.0:
8869-
version "4.5.0"
8870-
resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53"
8871-
integrity sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==
8872-
8873-
lodash.get@^4.0.2:
8874-
version "4.4.2"
8875-
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
8876-
integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==
8877-
88788868
lodash.includes@^4.3.0:
88798869
version "4.3.0"
88808870
resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f"
@@ -8925,7 +8915,7 @@ lodash.once@^4.0.0:
89258915
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
89268916
integrity sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==
89278917

8928-
lodash@4.17.21, lodash@^4.17.15, lodash@^4.17.21, lodash@^4.17.4:
8918+
lodash@4.17.21, lodash@^4.17.15, lodash@^4.17.21:
89298919
version "4.17.21"
89308920
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
89318921
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@@ -9839,22 +9829,6 @@ mongodb@^5.9.1:
98399829
optionalDependencies:
98409830
"@mongodb-js/saslprep" "^1.1.0"
98419831

9842-
mongoose-duplicate-error@^1.0.0:
9843-
version "1.0.0"
9844-
resolved "https://registry.yarnpkg.com/mongoose-duplicate-error/-/mongoose-duplicate-error-1.0.0.tgz#bfd76ca0dea2bd9014e1398a4b58c3d6f830a747"
9845-
integrity sha512-gpx3BABwup473tM1vpotVOvtlyB6ZMgbdBUBjWDYb6JKJYojHrOa2ph27uVchxpShtvL+pxGpoDIPzx4bEKl2w==
9846-
dependencies:
9847-
lodash "^4.17.4"
9848-
9849-
mongoose-unique-validator@^4.0.1:
9850-
version "4.0.1"
9851-
resolved "https://registry.yarnpkg.com/mongoose-unique-validator/-/mongoose-unique-validator-4.0.1.tgz#fc63365ab8d223ad1b186e4018b0fea6a043476a"
9852-
integrity sha512-kd080ytRa6SmTOJlQPlAnsJHz7eH/b27dMHsN3WO2PeJc1lkcZ+ns6dLvcsu7Kx/f4SQEXu9JfL8kFkr4aFqFQ==
9853-
dependencies:
9854-
lodash.foreach "^4.1.0"
9855-
lodash.get "^4.0.2"
9856-
lodash.merge "^4.6.2"
9857-
98589832
mongoose@^8.4.3:
98599833
version "8.4.3"
98609834
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-8.4.3.tgz#f16ea170eeff60a8c8357bed9968e914a4156d1a"

0 commit comments

Comments
 (0)