Skip to content

Commit af7687b

Browse files
committed
deploy: 17776af
1 parent a5430be commit af7687b

File tree

19 files changed

+609
-367
lines changed

19 files changed

+609
-367
lines changed

classes/IdentitiesCrudService.html

Lines changed: 128 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ <h6><b>Methods</b></h6>
181181
<tr>
182182
<td class="col-md-4">
183183
<ul class="index-list">
184+
<li>
185+
<span class="modifier">Public</span>
186+
<span class="modifier">Async</span>
187+
<a href="#countAll" >countAll</a>
188+
</li>
184189
<li>
185190
<span class="modifier">Public</span>
186191
<span class="modifier">Async</span>
@@ -482,6 +487,96 @@ <h3 id="inputs">
482487
<h3 id="methods">
483488
Methods
484489
</h3>
490+
<table class="table table-sm table-bordered">
491+
<tbody>
492+
<tr>
493+
<td class="col-md-4">
494+
<a name="countAll"></a>
495+
<span class="name">
496+
<span class="modifier">Public</span>
497+
<span class="modifier">Async</span>
498+
<span ><b>countAll</b></span>
499+
<a href="#countAll"><span class="icon ion-ios-link"></span></a>
500+
</span>
501+
</td>
502+
</tr>
503+
<tr>
504+
<td class="col-md-4">
505+
<span class="modifier-icon icon ion-ios-reset"></span>
506+
<code>countAll(filters: literal type, options?: | null)</code>
507+
</td>
508+
</tr>
509+
510+
511+
<tr>
512+
<td class="col-md-4">
513+
<div class="io-line">Defined in <a href="" data-line="139"
514+
class="link-to-prism">src/management/identities/identities-crud.service.ts:139</a></div>
515+
</td>
516+
</tr>
517+
518+
<tr>
519+
<td class="col-md-4">
520+
<b>Type parameters :</b>
521+
<ul class="type-parameters">
522+
<li>T</li>
523+
</ul>
524+
</td>
525+
</tr>
526+
527+
<tr>
528+
<td class="col-md-4">
529+
530+
<div class="io-description">
531+
<b>Parameters :</b>
532+
533+
<table class="params">
534+
<thead>
535+
<tr>
536+
<td>Name</td>
537+
<td>Type</td>
538+
<td>Optional</td>
539+
</tr>
540+
</thead>
541+
<tbody>
542+
<tr>
543+
<td>filters</td>
544+
<td>
545+
<code>literal type</code>
546+
</td>
547+
548+
<td>
549+
No
550+
</td>
551+
552+
553+
</tr>
554+
<tr>
555+
<td>options</td>
556+
<td>
557+
<code> | null</code>
558+
</td>
559+
560+
<td>
561+
Yes
562+
</td>
563+
564+
565+
</tr>
566+
</tbody>
567+
</table>
568+
</div>
569+
<div class="io-description">
570+
<b>Returns : </b> <code>unknown</code>
571+
572+
</div>
573+
<div class="io-description">
574+
575+
</div>
576+
</td>
577+
</tr>
578+
</tbody>
579+
</table>
485580
<table class="table table-sm table-bordered">
486581
<tbody>
487582
<tr>
@@ -511,7 +606,7 @@ <h3 id="methods">
511606
</tr>
512607
<tr>
513608
<td class="col-md-4">
514-
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:11</a></code>
609+
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:12</a></code>
515610
</div>
516611
</td>
517612
</tr>
@@ -607,7 +702,7 @@ <h3 id="methods">
607702
</tr>
608703
<tr>
609704
<td class="col-md-4">
610-
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:129</a></code>
705+
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:130</a></code>
611706
</div>
612707
</td>
613708
</tr>
@@ -703,7 +798,7 @@ <h3 id="methods">
703798
</tr>
704799
<tr>
705800
<td class="col-md-4">
706-
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:33</a></code>
801+
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:34</a></code>
707802
</div>
708803
</td>
709804
</tr>
@@ -804,8 +899,8 @@ <h3 id="methods">
804899

805900
<tr>
806901
<td class="col-md-4">
807-
<div class="io-line">Defined in <a href="" data-line="98"
808-
class="link-to-prism">src/management/identities/identities-crud.service.ts:98</a></div>
902+
<div class="io-line">Defined in <a href="" data-line="99"
903+
class="link-to-prism">src/management/identities/identities-crud.service.ts:99</a></div>
809904
</td>
810905
</tr>
811906

@@ -905,8 +1000,8 @@ <h3 id="methods">
9051000

9061001
<tr>
9071002
<td class="col-md-4">
908-
<div class="io-line">Defined in <a href="" data-line="106"
909-
class="link-to-prism">src/management/identities/identities-crud.service.ts:106</a></div>
1003+
<div class="io-line">Defined in <a href="" data-line="107"
1004+
class="link-to-prism">src/management/identities/identities-crud.service.ts:107</a></div>
9101005
</td>
9111006
</tr>
9121007

@@ -2504,12 +2599,13 @@ <h3 id="methods">
25042599
<div class="tab-pane fade tab-source-code" id="source">
25052600
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { AbstractIdentitiesService } from &#x27;~/management/identities/abstract-identities.service&#x27;;
25062601
import { AbstractSchema } from &#x27;~/_common/abstracts/schemas/abstract.schema&#x27;;
2507-
import { Document, ModifyResult, Query, QueryOptions, SaveOptions, Types, UpdateQuery } from &#x27;mongoose&#x27;;
2602+
import { Document, FilterQuery, ModifyResult, MongooseBaseQueryOptions, Query, QueryOptions, SaveOptions, Types, UpdateQuery } from &#x27;mongoose&#x27;;
25082603
import { ValidationConfigException, ValidationSchemaException } from &#x27;~/_common/errors/ValidationException&#x27;;
25092604
import { IdentityState } from &#x27;~/management/identities/_enums/states.enum&#x27;;
25102605
import { Identities } from &#x27;~/management/identities/_schemas/identities.schema&#x27;;
25112606
import { HttpException } from &#x27;@nestjs/common&#x27;;
2512-
import { omit } from &#x27;radash&#x27;;
2607+
import { map, omit } from &#x27;radash&#x27;;
2608+
import { CountOptions } from &#x27;mongodb&#x27;;
25132609

25142610
export class IdentitiesCrudService extends AbstractIdentitiesService {
25152611
public async create&lt;T extends AbstractSchema | Document&gt;(
@@ -2518,18 +2614,18 @@ <h3 id="methods">
25182614
): Promise&lt;Document&lt;T, any, T&gt;&gt; {
25192615
data &#x3D; this.transformNullsToString(data);
25202616
await this.checkInetOrgPersonJpegPhoto(data);
2521-
if(await this.checkMailAndUid(data) &#x3D;&#x3D;&#x3D; false){
2617+
if (await this.checkMailAndUid(data) &#x3D;&#x3D;&#x3D; false) {
25222618
this.logger.error(&#x27;Uid ou mail déjà présent dans une autre identité&#x27;);
25232619
throw new HttpException(&quot;Uid ou mail déjà présent dans une autre identité&quot;, 400);
25242620
}
25252621
const logPrefix &#x3D; &#x60;Validation [${data.inetOrgPerson.cn}]:&#x60;;
25262622
this.logger.log(&#x60;${logPrefix} Starting inetOrgPerson validation.&#x60;);
2527-
const check&#x3D;{
2528-
objectClasses: [&#x27;inetorgperson&#x27;],
2529-
attributes:{ &#x27;inetorgperson&#x27;:data.inetOrgPerson}
2623+
const check &#x3D; {
2624+
objectClasses: [&#x27;inetorgperson&#x27;],
2625+
attributes: { &#x27;inetorgperson&#x27;: data.inetOrgPerson }
25302626
}
25312627
//pour la validation le employeeNumber doit exister on en met un avec une valeur par defaut
2532-
check.attributes.inetorgperson.employeeNumber&#x3D;[&quot;1&quot;];
2628+
check.attributes.inetorgperson.employeeNumber &#x3D; [&quot;1&quot;];
25332629
let validations &#x3D; await this._validation.validate(check);
25342630
const created: Document&lt;T, any, T&gt; &#x3D; await super.create(data, options);
25352631
return created;
@@ -2546,17 +2642,17 @@ <h3 id="methods">
25462642
const logPrefix &#x3D; &#x60;Validation [${update.inetOrgPerson.cn}]:&#x60;;
25472643
try {
25482644
this.logger.log(&#x60;${logPrefix} Starting additionalFields transformation.&#x60;);
2549-
if(update.hasOwnProperty(&#x27;metadata&#x27;)){
2645+
if (update.hasOwnProperty(&#x27;metadata&#x27;)) {
25502646
//suppresion de la clé metadata
2551-
delete(update.metadata);
2647+
delete (update.metadata);
25522648
}
25532649

25542650
await this._validation.transform(update.additionalFields);
25552651

25562652
this.logger.log(&#x60;${logPrefix} Starting inetOrgPerson validation.&#x60;);
2557-
const check&#x3D;{
2653+
const check &#x3D; {
25582654
objectClasses: [&#x27;inetorgperson&#x27;],
2559-
attributes:{ &#x27;inetorgperson&#x27;:update.inetOrgPerson}
2655+
attributes: { &#x27;inetorgperson&#x27;: update.inetOrgPerson }
25602656
}
25612657
let validationsInetOrg &#x3D; await this._validation.validate(check);
25622658
let validationsAdFields &#x3D; await this._validation.validate(update.additionalFields);
@@ -2580,7 +2676,7 @@ <h3 id="methods">
25802676
}
25812677
}
25822678
// check mail and Uid
2583-
if(await this.checkMailAndUid(update) &#x3D;&#x3D;&#x3D; false){
2679+
if (await this.checkMailAndUid(update) &#x3D;&#x3D;&#x3D; false) {
25842680
this.logger.error(&#x27;Uid ou mail déjà présent dans une autre identité&#x27;);
25852681
throw new HttpException(&quot;Uid ou mail déjà présent dans une autre identité&quot;, 400);
25862682
}
@@ -2639,7 +2735,19 @@ <h3 id="methods">
26392735
return deleted;
26402736
}
26412737

2642-
2738+
public async countAll&lt;T extends AbstractSchema | Document&gt;(filters: {
2739+
[key: string]: FilterQuery&lt;T&gt;;
2740+
}, options?: (CountOptions &amp; MongooseBaseQueryOptions&lt;T&gt;) | null) {
2741+
const res &#x3D; {}
2742+
const maxItems &#x3D; 500;
2743+
for (const key in filters) {
2744+
res[key] &#x3D; await this._model.countDocuments(filters[key], options);
2745+
if (res[key] &gt; maxItems) {
2746+
throw new HttpException(&#x60;La requête a retourné plus de ${maxItems} résultats.&#x60;, 400);
2747+
}
2748+
}
2749+
return res;
2750+
}
26432751
}
26442752
</code></pre>
26452753
</div>

0 commit comments

Comments
 (0)