Skip to content

Commit ba4ed4e

Browse files
committed
deploy: 8dc5beb
1 parent 8061d35 commit ba4ed4e

File tree

14 files changed

+244
-242
lines changed

14 files changed

+244
-242
lines changed

classes/IdentitiesCrudService.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ <h3 id="methods">
592592
</tr>
593593
<tr>
594594
<td class="col-md-4">
595-
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:104</a></code>
595+
<div class="io-line">Defined in <code><a href="../injectables/AbstractServiceSchema.html#source" target="_self" >AbstractServiceSchema:105</a></code>
596596
</div>
597597
</td>
598598
</tr>
@@ -789,8 +789,8 @@ <h3 id="methods">
789789

790790
<tr>
791791
<td class="col-md-4">
792-
<div class="io-line">Defined in <a href="" data-line="73"
793-
class="link-to-prism">src/management/identities/identities-crud.service.ts:73</a></div>
792+
<div class="io-line">Defined in <a href="" data-line="74"
793+
class="link-to-prism">src/management/identities/identities-crud.service.ts:74</a></div>
794794
</td>
795795
</tr>
796796

@@ -890,8 +890,8 @@ <h3 id="methods">
890890

891891
<tr>
892892
<td class="col-md-4">
893-
<div class="io-line">Defined in <a href="" data-line="81"
894-
class="link-to-prism">src/management/identities/identities-crud.service.ts:81</a></div>
893+
<div class="io-line">Defined in <a href="" data-line="82"
894+
class="link-to-prism">src/management/identities/identities-crud.service.ts:82</a></div>
895895
</td>
896896
</tr>
897897

@@ -2312,6 +2312,7 @@ <h3 id="methods">
23122312
this.logger.log(&#x60;${logPrefix} AdditionalFields validation successful.&#x60;);
23132313
this.logger.log(&#x60;Validations : ${validations}&#x60;);
23142314
} catch (error) {
2315+
console.log(error);
23152316
if (error instanceof ValidationConfigException) {
23162317
this.logger.error(&#x60;${logPrefix} Validation config error. ${JSON.stringify(error.getValidations())}&#x60;);
23172318
throw new ValidationConfigException(error.getPayload());

injectables/IdentitiesValidationService.html

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ <h3 id="methods">
428428

429429
<tr>
430430
<td class="col-md-4">
431-
<div class="io-line">Defined in <a href="" data-line="352"
432-
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:352</a></div>
431+
<div class="io-line">Defined in <a href="" data-line="353"
432+
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:353</a></div>
433433
</td>
434434
</tr>
435435

@@ -468,8 +468,8 @@ <h3 id="methods">
468468

469469
<tr>
470470
<td class="col-md-4">
471-
<div class="io-line">Defined in <a href="" data-line="407"
472-
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:407</a></div>
471+
<div class="io-line">Defined in <a href="" data-line="408"
472+
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:408</a></div>
473473
</td>
474474
</tr>
475475

@@ -956,8 +956,8 @@ <h3 id="methods">
956956

957957
<tr>
958958
<td class="col-md-4">
959-
<div class="io-line">Defined in <a href="" data-line="304"
960-
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:304</a></div>
959+
<div class="io-line">Defined in <a href="" data-line="305"
960+
class="link-to-prism">src/management/identities/validations/identities.validation.service.ts:305</a></div>
961961
</td>
962962
</tr>
963963

@@ -1071,7 +1071,7 @@ <h3 id="inputs">
10711071
</tr>
10721072
<tr>
10731073
<td class="col-md-4">
1074-
<i>Default value : </i><code>new Ajv({allErrors: true })</code>
1074+
<i>Default value : </i><code>new Ajv({ allErrors: true })</code>
10751075
</td>
10761076
</tr>
10771077
<tr>
@@ -1137,32 +1137,32 @@ <h3 id="inputs">
11371137

11381138

11391139
<div class="tab-pane fade tab-source-code" id="source">
1140-
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {BadRequestException, Injectable, Logger, OnApplicationBootstrap} from &#x27;@nestjs/common&#x27;;
1141-
import {parse} from &#x27;yaml&#x27;;
1142-
import {existsSync, readFileSync, readdirSync, writeFileSync} from &#x27;fs&#x27;;
1143-
import {ConfigObjectSchemaDTO} from &#x27;./_dto/config.dto&#x27;;
1144-
import {diff} from &#x27;radash&#x27;;
1145-
import {AdditionalFieldsPart} from &#x27;../_schemas/_parts/additionalFields.part.schema&#x27;;
1140+
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { BadRequestException, Injectable, Logger, OnApplicationBootstrap } from &#x27;@nestjs/common&#x27;;
1141+
import { parse } from &#x27;yaml&#x27;;
1142+
import { existsSync, readFileSync, readdirSync, writeFileSync } from &#x27;fs&#x27;;
1143+
import { ConfigObjectSchemaDTO } from &#x27;./_dto/config.dto&#x27;;
1144+
import { diff } from &#x27;radash&#x27;;
1145+
import { AdditionalFieldsPart } from &#x27;../_schemas/_parts/additionalFields.part.schema&#x27;;
11461146
import Ajv from &#x27;ajv&#x27;;
11471147
import addFormats from &#x27;ajv-formats&#x27;;
11481148
import validSchema from &#x27;./_config/validSchema&#x27;;
11491149
import ajvErrors from &#x27;ajv-errors&#x27;;
1150-
import {ValidationConfigException, ValidationSchemaException} from &#x27;~/_common/errors/ValidationException&#x27;;
1151-
import {additionalFieldsPartDto} from &#x27;../_dto/_parts/additionalFields.dto&#x27;;
1150+
import { ValidationConfigException, ValidationSchemaException } from &#x27;~/_common/errors/ValidationException&#x27;;
1151+
import { additionalFieldsPartDto } from &#x27;../_dto/_parts/additionalFields.dto&#x27;;
11521152

11531153
/**
11541154
* Service responsible for validating identities.
11551155
*/
11561156
@Injectable()
11571157
export class IdentitiesValidationService implements OnApplicationBootstrap {
1158-
private ajv: Ajv &#x3D; new Ajv({allErrors: true });
1158+
private ajv: Ajv &#x3D; new Ajv({ allErrors: true });
11591159
private validateSchema;
11601160
private logger: Logger;
11611161

11621162
public constructor() {
11631163
addFormats(this.ajv);
11641164
ajvErrors(this.ajv);
1165-
this.ajv.addFormat(&#x27;number&#x27;,/^\d*$/);
1165+
this.ajv.addFormat(&#x27;number&#x27;, /^\d*$/);
11661166
this.validateSchema &#x3D; this.ajv.compile(validSchema);
11671167
this.logger &#x3D; new Logger(IdentitiesValidationService.name);
11681168
}
@@ -1232,26 +1232,26 @@ <h3 id="inputs">
12321232
* check objectclasses and add missing keys
12331233
* @param data
12341234
*/
1235-
public async checkAndCreateObjectClasses(data){
1235+
public async checkAndCreateObjectClasses(data) {
12361236
const objectClasses &#x3D; data.objectClasses || [];
12371237
const attributes &#x3D; data.attributes || {};
12381238
const attributesKeys &#x3D; Object.keys(attributes);
1239-
for(const objectclass of objectClasses) {
1240-
if (! attributesKeys.includes(objectclass)) {
1241-
this.logger.log( objectclass + &quot; attribute not found creating&quot;);
1242-
await this.createAttributes(objectclass,data);
1239+
for (const objectclass of objectClasses) {
1240+
if (!attributesKeys.includes(objectclass)) {
1241+
this.logger.log(objectclass + &quot; attribute not found creating&quot;);
1242+
await this.createAttributes(objectclass, data);
12431243
}
12441244
}
12451245
}
1246-
private async createAttributes(key:string,data:any){
1246+
private async createAttributes(key: string, data: any) {
12471247

12481248
// Validate the key to prevent prototype pollution
12491249
if (key &#x3D;&#x3D;&#x3D; &#x27;__proto__&#x27; || key &#x3D;&#x3D;&#x3D; &#x27;constructor&#x27; || key &#x3D;&#x3D;&#x3D; &#x27;prototype&#x27;) {
12501250
this.logger.error(&#x27;Invalid key: &#x27; + key);
12511251
throw new BadRequestException(&#x27;Invalid key: &#x27; + key);
12521252
}
12531253
const path &#x3D; this.resolveConfigPath(key);
1254-
if (path &#x3D;&#x3D;&#x3D; null){
1254+
if (path &#x3D;&#x3D;&#x3D; null) {
12551255
this.logger.error(&#x27;schema for &#x27; + key + &#x27; does not exist&#x27;);
12561256
throw new BadRequestException(&#x27;schema for &#x27; + key + &#x27; does not exist&#x27;);
12571257
}
@@ -1287,7 +1287,7 @@ <h3 id="inputs">
12871287
public async transformAttribute(key: string, attribute: any, data: any) {
12881288

12891289
const path &#x3D; this.resolveConfigPath(key);
1290-
if (path &#x3D;&#x3D;&#x3D; null){
1290+
if (path &#x3D;&#x3D;&#x3D; null) {
12911291
this.logger.error(&#x27;schema for &#x27; + key + &#x27; does not exist&#x27;);
12921292
throw new BadRequestException(&#x27;schema for &#x27; + key + &#x27; does not exist&#x27;);
12931293
}
@@ -1299,42 +1299,42 @@ <h3 id="inputs">
12991299
if (typeof data[key][index] &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; || data[key][index] &#x3D;&#x3D;&#x3D; null) {
13001300
data[key][index] &#x3D; [];
13011301
}
1302-
if (!(data[key][index] instanceof Array)){
1303-
data[key][index]&#x3D;[data[key][index]];
1302+
if (!(data[key][index] instanceof Array)) {
1303+
data[key][index] &#x3D; [data[key][index]];
13041304
}
13051305
if (typeof def[&#x27;items&#x27;] !&#x3D;&#x3D; &#x27;undefined&#x27;) {
1306-
//test si toutes les valeurs sont du bon type
1307-
for(const elems in data[key][index]){
1308-
if (typeof data[key][index][elems] !&#x3D;&#x3D; def[&#x27;items&#x27;][&#x27;type&#x27;]){
1309-
switch(def[&#x27;items&#x27;][&#x27;type&#x27;]){
1310-
case &#x27;string&#x27;:
1311-
data[key][index][elems]&#x3D;String(data[key][index][elems]);
1312-
break;
1313-
case &#x27;number&#x27;:
1314-
data[key][index][elems]&#x3D;await this.transformNumber(data[key][index][elems])
1315-
break;
1316-
}
1306+
//test si toutes les valeurs sont du bon type
1307+
for (const elems in data[key][index]) {
1308+
if (typeof data[key][index][elems] !&#x3D;&#x3D; def[&#x27;items&#x27;][&#x27;type&#x27;]) {
1309+
switch (def[&#x27;items&#x27;][&#x27;type&#x27;]) {
1310+
case &#x27;string&#x27;:
1311+
data[key][index][elems] &#x3D; String(data[key][index][elems]);
1312+
break;
1313+
case &#x27;number&#x27;:
1314+
data[key][index][elems] &#x3D; await this.transformNumber(data[key][index][elems])
1315+
break;
13171316
}
13181317
}
1318+
}
13191319
}
13201320
break;
13211321
case &#x27;number&#x27;:
13221322
if (typeof data[key][index] &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; || data[key][index] &#x3D;&#x3D;&#x3D; null) {
13231323
data[key][index] &#x3D; 0;
13241324
}
1325-
if (typeof data[key][index] !&#x3D;&#x3D; &#x27;number&#x27;){
1325+
if (typeof data[key][index] !&#x3D;&#x3D; &#x27;number&#x27;) {
13261326
//on ne convertit pas si la chaine est vide
1327-
if (typeof data[key][index] &#x3D;&#x3D;&#x3D; &#x27;string&#x27; &amp;&amp; data[key][index] !&#x3D;&#x3D; &quot;&quot;){
1328-
data[key][index]&#x3D;await this.transformNumber(data[key][index])
1327+
if (typeof data[key][index] &#x3D;&#x3D;&#x3D; &#x27;string&#x27; &amp;&amp; data[key][index] !&#x3D;&#x3D; &quot;&quot;) {
1328+
data[key][index] &#x3D; await this.transformNumber(data[key][index])
13291329
}
13301330
}
13311331
break;
13321332
case &#x27;string&#x27;:
13331333
if (typeof data[key][index] &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; || data[key][index] &#x3D;&#x3D;&#x3D; null) {
13341334
data[key][index] &#x3D; &quot;&quot;;
13351335
}
1336-
if (typeof data[key][index] !&#x3D;&#x3D; &#x27;string&#x27;){
1337-
data[key][index]&#x3D;String(data[key][index]);
1336+
if (typeof data[key][index] !&#x3D;&#x3D; &#x27;string&#x27;) {
1337+
data[key][index] &#x3D; String(data[key][index]);
13381338
}
13391339
break;
13401340
}
@@ -1346,12 +1346,12 @@ <h3 id="inputs">
13461346
* @param value
13471347
* @private
13481348
*/
1349-
private async transformNumber(value){
1350-
if (typeof value &#x3D;&#x3D;&#x3D; &#x27;string&#x27;){
1351-
const tr&#x3D;parseFloat(value)
1352-
if (! isNaN(tr)){
1349+
private async transformNumber(value) {
1350+
if (typeof value &#x3D;&#x3D;&#x3D; &#x27;string&#x27;) {
1351+
const tr &#x3D; parseFloat(value)
1352+
if (!isNaN(tr)) {
13531353
return tr
1354-
}else{
1354+
} else {
13551355
return 0
13561356
}
13571357
}
@@ -1402,15 +1402,16 @@ <h3 id="inputs">
14021402
}
14031403

14041404
// Check for invalid schema
1405+
this.logger.verbose(&#x60;Validating schema ${key}.yml&#x60;);
14051406
const schema: ConfigObjectSchemaDTO &#x3D; parse(readFileSync(path, &#x27;utf8&#x27;));
14061407
if (!this.validateSchema(schema)) {
14071408
validations[&#x27;message&#x27;] &#x3D; &#x60;Schema ${key}.yml invalide: ${this.ajv.errorsText(this.validateSchema.errors)}&#x60;;
14081409
throw new ValidationConfigException(validations);
14091410
}
14101411
//verification des required, il faut que l&#x27;entree soit presente dans les proprietes
14111412
if (schema.hasOwnProperty(&#x27;required&#x27;)) {
1412-
for (const required of schema[&#x27;required&#x27;]){
1413-
if (! schema[&#x27;properties&#x27;].hasOwnProperty(required)){
1413+
for (const required of schema[&#x27;required&#x27;]) {
1414+
if (!schema[&#x27;properties&#x27;].hasOwnProperty(required)) {
14141415
validations[&#x27;message&#x27;] &#x3D; &#x60;Schema ${key}.yml invalide : required : ${required} without property&#x60;;
14151416
throw new ValidationConfigException(validations);
14161417
}
@@ -1429,9 +1430,9 @@ <h3 id="inputs">
14291430
}
14301431

14311432
if (reject) {
1432-
throw new ValidationSchemaException({validations});
1433+
throw new ValidationSchemaException({ validations });
14331434
}
1434-
return Promise.resolve({message: &#x27;Validation succeeded&#x27;});
1435+
return Promise.resolve({ message: &#x27;Validation succeeded&#x27; });
14351436
}
14361437

14371438
/**
@@ -1473,23 +1474,23 @@ <h3 id="inputs">
14731474
this.logger.debug(&#x60;Additionalfields object validation: ${JSON.stringify(data[key])}&#x60;);
14741475
//limitation de la taille du data pour le pb de deny of service de ajv
14751476
//voir (https://ajv.js.org/security.html)
1476-
if (Object.keys(data[key]).length &gt;500){
1477+
if (Object.keys(data[key]).length &gt; 500) {
14771478
this.logger.error(&#x27;Request too large&#x27;);
14781479
throw new BadRequestException(&#x27;Request too large&#x27;);
14791480
}
1480-
const ok&#x3D; await this.ajv.validate(schema,data[key]);
1481+
const ok &#x3D; await this.ajv.validate(schema, data[key]);
14811482
if (ok &#x3D;&#x3D;&#x3D; false) {
14821483
const retErrors &#x3D; {};
14831484
for (const err of this.ajv.errors) {
1484-
retErrors[err[&#x27;instancePath&#x27;].substring(1)]&#x3D; err[&#x27;instancePath&#x27;].substring(1) + &#x27; &#x27; + err[&#x27;message&#x27;]
1485+
retErrors[err[&#x27;instancePath&#x27;].substring(1)] &#x3D; err[&#x27;instancePath&#x27;].substring(1) + &#x27; &#x27; + err[&#x27;message&#x27;]
14851486
}
1486-
return(retErrors)
1487+
return (retErrors)
14871488
}
14881489
return null
14891490
}
14901491

14911492
public async findAll(): Promise&lt;any&gt; {
1492-
this.logger.debug([&#x27;findAll&#x27;, JSON.stringify(Object.values({...arguments}))].join(&#x27; &#x27;));
1493+
this.logger.debug([&#x27;findAll&#x27;, JSON.stringify(Object.values({ ...arguments }))].join(&#x27; &#x27;));
14931494
const hardConfigPath &#x3D; &#x27;./src/management/identities/validations/_config&#x27;;
14941495
const dynamicConfigPath &#x3D; &#x27;./configs/identities/validations&#x27;;
14951496
// Retrieve files from each directory and tag them with their source
@@ -1538,7 +1539,7 @@ <h3 id="inputs">
15381539
const filePath &#x3D; &#x60;${fileObj.path}/${fileObj.file}&#x60;;
15391540
const data &#x3D; parse(readFileSync(filePath, &#x27;utf-8&#x27;));
15401541
const key &#x3D; fileObj.file.replace(&#x27;.yml&#x27;, &#x27;&#x27;);
1541-
result.push({[key]: data, source: fileObj.source, name: key});
1542+
result.push({ [key]: data, source: fileObj.source, name: key });
15421543
}
15431544
return [result, files.length];
15441545
}
@@ -1550,13 +1551,13 @@ <h3 id="inputs">
15501551
filePath &#x3D; &#x27;./validation/inetorgperson.json&#x27;;
15511552
if (!existsSync(filePath)) {
15521553
const message &#x3D; &#x60;File not found /validation/inetorgperson.json&#x60;;
1553-
throw new ValidationConfigException({message});
1554+
throw new ValidationConfigException({ message });
15541555
}
15551556
} else {
15561557
filePath &#x3D; this.resolveConfigPath(schema);
15571558
if (!existsSync(filePath)) {
15581559
const message &#x3D; &#x60;File not found: ${filePath}&#x60;;
1559-
throw new ValidationConfigException({message});
1560+
throw new ValidationConfigException({ message });
15601561
}
15611562
}
15621563
return parse(readFileSync(filePath, &#x27;utf-8&#x27;));

js/search/search_index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)