Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove and add missing element in config #37

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions tdm-be/src/controller/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ const router = express.Router();
* type: array
* items:
* $ref: '#/components/schemas/SwaggerApi'
* example: [{'url':'https://data-computer.services.istex.fr', 'retrieveUrl':'/v1/retrieve', 'tags':[{'name':'data-computer','excluded':['/v1/collect','/v1/retrieve','/v1/mock-error-async','/v1/mock-error-sync']}]}]
* mailSuccess:
* type:
* $ref: '#/components/schemas/Mail'
* example: {'subject':'Objet du mail succès', 'text':'Vous pouvez télécharger le fichier enrichi à l'adresse ci-dessous' }
* mailError:
* type:
* $ref: '#/components/schemas/Mail'
* example: {'subject':'Objet du mail d'erreur', 'text':'Une erreur s'est produite lors de l'enrichissement' }
* example: [{'url':'https://data-computer.services.istex.fr', 'retrieveUrl':{url: '/v1/retrieve-csv', fileExtension: 'csv'}, 'tags':[{'name':'data-computer','excluded':['/v1/collect','/v1/retrieve','/v1/mock-error-async','/v1/mock-error-sync']}]}]
parmentf marked this conversation as resolved.
Show resolved Hide resolved
*
* SwaggerApi:
* type: object
Expand All @@ -38,7 +30,14 @@ const router = express.Router();
* type: string
* example: 'https://data-wrapper.services.istex.fr'
* retrieveUrl:
* type: string
* type: object
* properties:
* url:
* type: string
* example: /v1/retrieve-csv
* fileExtension:
* type: string
* example: csv
* tags:
* type: array
* items:
Expand All @@ -54,13 +53,6 @@ const router = express.Router();
* items:
* type: string
* example: ['csv']
* Mail:
* type: object
* properties:
* subject:
* type: string
* text:
* type: string
*
*/

Expand Down
25 changes: 0 additions & 25 deletions tdm-be/src/model/DynamicConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@ export class SwaggerApi {
tags: Tag[] = [];
}

export class Mail {
subject = '';
text = '';
}

type ConfigType = {
wrappers: SwaggerApi[];
enrichments: SwaggerApi[];
mailSuccess: Mail;
mailError: Mail;
};

export class DynamicConfig {
Expand Down Expand Up @@ -88,14 +81,6 @@ export class DynamicConfig {
],
},
],
mailSuccess: localConfig.mailSuccess ?? {
subject: 'Objet du mail succès',
text: "Vous pouvez télécharger le fichier enrichi à l'adresse ci-dessous",
},
mailError: localConfig.mailError ?? {
subject: "Objet du mail d'erreur",
text: "Une erreur s'est produite lors de l'enrichissement",
},
};
logger.info('Dynamic config loaded');
this.saveConfig();
Expand All @@ -117,16 +102,6 @@ export class DynamicConfig {
this.config.enrichments = data.enrichments;
}

if (data.mailSuccess) {
hasChange = true;
this.config.mailSuccess = data.mailSuccess;
}

if (data.mailError) {
hasChange = true;
this.config.mailError = data.mailError;
}

if (hasChange) {
this.saveConfig();
}
Expand Down
45 changes: 13 additions & 32 deletions tdm-be/src/swagger/swagger-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"example": [
{
"url": "https://data-computer.services.istex.fr",
"retrieveUrl": "/v1/retrieve",
"retrieveUrl": {"url": "/v1/retrieve-csv", "fileExtension": "csv"},
parmentf marked this conversation as resolved.
Show resolved Hide resolved
"tags": [
{
"name": "data-computer",
Expand All @@ -117,24 +117,6 @@
]
}
]
},
"mailSuccess": {
"type": {
"$ref": "#/components/schemas/Mail"
},
"example": {
"subject": "Objet du mail succès",
"text": "Vous pouvez télécharger le fichier enrichi à l'adresse ci-dessous"
}
},
"mailError": {
"type": {
"$ref": "#/components/schemas/Mail"
},
"example": {
"subject": "Objet du mail d'erreur",
"text": "Une erreur s'est produite lors de l'enrichissement"
}
}
}
},
Expand All @@ -146,7 +128,17 @@
"example": "https://data-wrapper.services.istex.fr"
},
"retrieveUrl": {
"type": "string"
"type": "object",
"properties": {
"url": {
"type": "string",
"example": "/v1/retrieve-csv"
},
"fileExtension": {
"type": "string",
"example": "csv"
}
}
},
"tags": {
"type": "array",
Expand All @@ -173,19 +165,8 @@
]
}
}
},
"Mail": {
"type": "object",
"properties": {
"subject": {
"type": "string"
},
"text": {
"type": "string"
}
}
}
}
},
"tags": []
}
}
Loading