diff --git a/api/contract/api-docs.ts b/api/contract/api-docs.ts index 2169702e..8ca7298c 100644 --- a/api/contract/api-docs.ts +++ b/api/contract/api-docs.ts @@ -209,9 +209,9 @@ const operations: Record = { } const tagTitles = { - processings: { fr: 'Traitements', en: 'Processings' }, - runs: { fr: 'Exécutions', en: 'Runs' }, - limits: { fr: 'Limites', en: 'Limits' } + processings: { en: 'Processings', fr: 'Traitements' }, + runs: { en: 'Runs', fr: 'Exécutions' }, + limits: { en: 'Limits', fr: 'Limites' } } export default (locale: ScopeLocale = 'fr') => { @@ -230,7 +230,7 @@ export default (locale: ScopeLocale = 'fr') => { return { openapi: '3.1.0', info: { - title: 'API Processings', + title: 'Processings API', description: 'Periodic processings: plugins that ingest, transform and publish datasets, their configs and their runs.', version: '1.0.0' }, diff --git a/api/package.json b/api/package.json index 56489c7d..7c43ce31 100644 --- a/api/package.json +++ b/api/package.json @@ -20,11 +20,11 @@ "@types/ws": "^8.5.12" }, "dependencies": { - "@data-fair/lib-common-types": "^1.27.0", + "@data-fair/lib-common-types": "^1.28.1", "@data-fair/lib-express": "^1.34.1", "@data-fair/lib-node": "^2.16.1", "@data-fair/lib-node-registry": "0.7.2", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/lib-validation": "^1.0.2", "@data-fair/processings-shared": "*", "@json-layout/core": "^2.13.3", diff --git a/api/src/misc/utils/api-docs.ts b/api/src/misc/utils/api-docs.ts index c9d683f1..307d485f 100644 --- a/api/src/misc/utils/api-docs.ts +++ b/api/src/misc/utils/api-docs.ts @@ -19,24 +19,24 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD const doc: Record = { openapi: '3.1.1', info: { - title: options?.processing?.title ? `API du traitement : ${options.processing.title}` : 'API Traitements de données', - description: `Cette documentation interactive à destination des développeurs permet d'utiliser l'API du ${options?.processing?.title ? `traitement ${options.processing.title}` : 'service de traitements periodiques'}.`, + title: options?.processing?.title ? `API of the processing: ${options.processing.title}` : 'Processings API', + description: `This interactive documentation for developers covers the API of the ${options?.processing?.title ? `processing ${options.processing.title}` : 'periodic processings service'}.`, version: packageJson.version, termsOfService: 'https://koumoul.com/pages/conditions-generales-dutilisation' }, servers: [{ url: `${origin}/processings/api/v1${options?.processing?._id ? `/processings/${options.processing?._id}` : ''}`, - description: `Instance DataFair - ${new URL(origin).hostname}` + description: `Data Fair instance - ${new URL(origin).hostname}` }], paths: { '/api-docs.json': { get: { - summary: 'Obtenir la documentation OpenAPI', - description: 'Accéder à cette documentation au format OpenAPI v3.', + summary: 'Get the OpenAPI documentation', + description: 'Get this documentation in the OpenAPI v3 format.', operationId: 'getApiDoc', responses: { 200: { - description: 'La documentation de l\'API', + description: 'The API documentation.', content: { 'application/json': { schema: { @@ -51,12 +51,12 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD '/': { get: { - summary: 'Lire les informations de ce traitement', - description: 'Accéder aux données de ce traitement.', + summary: 'Read this processing', + description: 'Read the information of this processing.', operationId: 'getProcessing', responses: { 200: { - description: 'Le traitement trouvé.', + description: 'The processing.', content: { 'application/json': { schema: ProcessingSchema @@ -64,19 +64,19 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD } }, 403: { - description: 'L\'utilisateur n\'a pas le droit de voir ce traitement.' + description: 'The user is not allowed to read this processing.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } }, patch: { - summary: 'Mettre à jour ce traitement', - description: 'Mettre à jour ce traitement.', + summary: 'Update this processing', + description: 'Update some fields of this processing.', operationId: 'patchProcessing', requestBody: { - description: 'Le traitement à mettre à jour', + description: 'The fields of the processing to update.', required: true, content: { 'application/json': { @@ -101,7 +101,7 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD }, responses: { 200: { - description: 'Le traitement a été mis à jour avec succès.', + description: 'The updated processing.', content: { 'application/json': { schema: ProcessingSchema @@ -109,41 +109,41 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD } }, 400: { - description: 'Body de la requête invalide.' + description: 'Invalid request body.' }, 403: { - description: 'L\'utilisateur n\'a pas le droit de mettre à jour ce traitement ou de faire cette modification sur ce traitement' + description: 'The user is not allowed to update this processing or to make this change to it.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } }, delete: { - summary: 'Supprimer ce traitement', - description: 'Supprimer ce traitement.', + summary: 'Delete this processing', + description: 'Delete this processing and its runs.', operationId: 'deleteProcessing', responses: { 204: { - description: 'Le traitement a été supprimé avec succès.' + description: 'The processing was deleted.' }, 403: { - description: 'L\'utilisateur n\'a pas le droit de supprimer ce traitement.' + description: 'The user is not allowed to delete this processing.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } } }, '/webhook-key': { get: { - summary: 'Lire la clé de webhook de ce traitement', - description: 'Lire la clé de webhook de ce traitement.', + summary: 'Read the webhook key of this processing', + description: 'Read the key that triggers this processing through its webhook.', operationId: 'getProcessingWebhookKey', responses: { 200: { - description: 'La clé de webhook du traitement.', + description: 'The webhook key of the processing.', content: { 'application/json': { schema: { @@ -153,63 +153,63 @@ export default (origin: string, options: { processing: Processing, plugin?: ApiD } }, 403: { - description: 'L\'utilisateur n\'a pas le droit de voir ce traitement.' + description: 'The user is not allowed to read this processing.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } }, delete: { - summary: 'Recréer la clé de webhook de ce traitement', - description: 'Recréer la clé de webhook de ce traitement.', + summary: 'Renew the webhook key of this processing', + description: 'Replace the webhook key of this processing with a new one, the previous key stops working.', operationId: 'deleteProcessingWebhookKey', responses: { 200: { - description: 'La clé de webhook du traitement a été recréée avec succès.', + description: 'The webhook key was renewed.', content: { 'application/json': { schema: { type: 'string', - description: 'La nouvelle clé de webhook du traitement.' + description: 'The new webhook key of the processing.' } } } }, 403: { - description: 'L\'utilisateur n\'a pas le droit de voir ce traitement.' + description: 'The user is not allowed to read this processing.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } } }, '/_trigger': { post: { - summary: 'Déclencher ce traitement manuellement', - description: 'Déclencher ce traitement manuellement.', + summary: 'Trigger this processing', + description: 'Trigger a run of this processing now, with a session or with its webhook key.', operationId: 'postProcessingTrigger', parameters: [ { name: 'key', in: 'query', - description: 'La clé de déclenchement du traitement.', + description: 'The webhook key of the processing, to trigger it without a session.', schema: { type: 'string', - title: 'Clé de déclenchement' + title: 'Webhook key' } } ], responses: { 200: { - description: 'Le traitement a été déclenché avec succès.' + description: 'The processing was triggered.' }, 403: { - description: 'L\'utilisateur n\'a pas le droit de déclencher ce traitement, ou la clé de déclenchement n\'est pas valide.' + description: 'The user is not allowed to trigger this processing, or the webhook key is invalid.' }, 404: { - description: 'Traitement non trouvé.' + description: 'Processing not found.' } } } diff --git a/api/src/processings/operations.ts b/api/src/processings/operations.ts index 23ffb74a..232ecac0 100644 --- a/api/src/processings/operations.ts +++ b/api/src/processings/operations.ts @@ -6,14 +6,14 @@ import { httpError } from '@data-fair/lib-utils/http-errors.js' /** * `lib-express/error-handler.js` collapses every AxiosRequestError to 500, so - * we translate registry failures into user-facing French messages at the + * we translate registry failures into user-facing messages at the * boundary. 403/404 keep their status (the UI relies on them to show its * "plugin broken" banner); anything else is a registry outage → 502. */ export const translateRegistryError = (err: any, processing: Pick) => { const status = err?.status ?? err?.statusCode const ownerLabel = processing.owner.name ?? processing.owner.id - if (status === 403) return httpError(403, `Le compte ${ownerLabel} n'a pas accès au plugin ${processing.plugin}.`) - if (status === 404) return httpError(404, `Le plugin ${processing.plugin} est introuvable dans le registre.`) - return httpError(502, 'Le registre des plugins est temporairement indisponible.') + if (status === 403) return httpError(403, `The account ${ownerLabel} has no access to the plugin ${processing.plugin}.`) + if (status === 404) return httpError(404, `The plugin ${processing.plugin} was not found in the registry.`) + return httpError(502, 'The plugins registry is temporarily unavailable.') } diff --git a/api/src/processings/router.ts b/api/src/processings/router.ts index f3ef786a..37e1e3c3 100644 --- a/api/src/processings/router.ts +++ b/api/src/processings/router.ts @@ -42,7 +42,7 @@ const ajv = ajvFormats(new Ajv({ strict: false, addUsedSchema: false })) /** * Ensure the plugin tarball is in the API's local cache (downloads on miss). * Registry enforces that `processing.owner` has access to the artefact; a 403 - * here surfaces directly to the caller as a user-facing French message. + * here surfaces directly to the caller as a user-facing message. * * The plugin's processing config schema is read from the conventional * `processing-config-schema.json` shipped alongside the plugin (v6 convention), @@ -120,21 +120,27 @@ async function fetchPluginArtefact (processing: Pick ({ en: `The processing ${title} was created`, fr: `Le traitement ${title} a été créé` }), + patch: (title: string) => ({ en: `The processing ${title} was updated`, fr: `Le traitement ${title} a été modifié` }), + delete: (title: string) => ({ en: `The processing ${title} was deleted`, fr: `Le traitement ${title} a été supprimé` }), + trigger: (title: string) => ({ en: `The processing ${title} was triggered manually`, fr: `Le traitement ${title} a été déclenché manuellement` }), + 'trigger-webhook': (title: string) => ({ en: `The processing ${title} was triggered by a webhook`, fr: `Le traitement ${title} a été déclenché par webhook` }) +} + /** - * Helper function to send events related to processings - * @param processing The processing object - * @param actionText The text describing the action (e.g. "a été créé") - * @param topicAction The action part of the topic key (e.g. "create", "delete") - * @param sessionState Optional session state for authentication + * Send an event about a processing. + * @param topicAction The action part of the topic key + * @param textAction The text of the title, when it is more precise than the topic action */ const sendProcessingEvent = ( processing: Processing, - actionText: string, - topicAction: string, - sessionState?: SessionStateAuthenticated + topicAction: 'create' | 'patch' | 'delete' | 'trigger', + sessionState?: SessionStateAuthenticated, + textAction: keyof typeof processingTitles = topicAction ) => { eventsQueue.pushEvent({ - title: `Le traitement ${processing.title} ${actionText}`, + title: processingTitles[textAction](processing.title), topic: { key: `processings:processing-${topicAction}:${processing._id}` }, sender: processing.owner, resource: { @@ -153,7 +159,7 @@ const sendProcessingEvent = ( * from the cached package.json#registry block, downloaded on cache miss) * * Skipped entirely when the processing has no config. Registry errors are - * translated to user-facing French messages inside ensurePluginAndReadSchema. + * translated to user-facing messages inside ensurePluginAndReadSchema. */ async function validateFullProcessing (processing: any): Promise { (await import('#types/processing/index.ts')).returnValid(processing) @@ -358,14 +364,14 @@ router.get('', requireOperationScope('listProcessings'), async (req, res) => { $filter: { input: '$departments', as: 'dept', - cond: { $ne: ['$$dept.department', null] } // Filtrer les départements null + cond: { $ne: ['$$dept.department', null] } // filter out null departments } } } } ] - // Ajout des `owners` dans le résultat final + // add the `owners` to the final result aggregationPipeline[1].$replaceRoot.newRoot.owners = { $ifNull: ['$owners', []] } } else { aggregationPipeline.unshift({ $match: query }) @@ -407,7 +413,7 @@ router.post('', requireOperationScope('postProcessing'), async (req, res) => { Object.assign(processing, await prepareProcessing(processing)) await mongo.processings.insertOne(processing) - sendProcessingEvent(processing, 'a été créé', 'create', sessionState) + sendProcessingEvent(processing, 'create', sessionState) res.status(200).json(cleanProcessing(processing, sessionState)) }) @@ -440,7 +446,7 @@ const saveProcessingPatch = async (processing: Processing, body: Record { const processing = await mongo.processings.findOne({ _id: req.params.id }) if (!processing) return res.status(404).send() if (req.query.key) { - if (req.query.key !== processing.webhookKey) return res.status(403).send('Mauvaise clé de déclenchement') - sendProcessingEvent(processing, 'a été déclenché par webhook', 'trigger') + if (req.query.key !== processing.webhookKey) return res.status(403).send('Wrong trigger key') + sendProcessingEvent(processing, 'trigger', undefined, 'trigger-webhook') } else { // the webhook key path reads no session, so the scope is checked here rather than by a middleware assertReqScope(req, acceptedScopes('processings', 'write')) const sessionState = await session.reqAuthenticated(req) if (!['admin', 'exec'].includes(permissions.getUserResourceProfile(processing.owner, processing.permissions, sessionState) ?? '')) return res.status(403).send() - sendProcessingEvent(processing, 'a été déclenché manuellement', 'trigger', sessionState) + sendProcessingEvent(processing, 'trigger', sessionState) } - if (!processing.active) return res.status(409).send('Le traitement n\'est pas actif') + if (!processing.active) return res.status(409).send('The processing is not active') res.send(await createNext(mongo.db, locks, processing, true, req.query.delay ? Number(req.query.delay) : 0)) }) diff --git a/api/src/scopes.ts b/api/src/scopes.ts index f6f73c1d..c2b5fece 100644 --- a/api/src/scopes.ts +++ b/api/src/scopes.ts @@ -12,10 +12,10 @@ export const vocabulary = defineScopes({ processings: { tiers: ['read', 'write', 'admin'], descriptions: { - umbrella: { fr: 'Tous les droits sur les traitements', en: 'All processing scopes' }, - read: { fr: 'Lire les traitements du compte, leurs exécutions et leurs journaux', en: "Read the account's processings, their runs and logs" }, - write: { fr: 'Créer et configurer les traitements, déclencher et arrêter leurs exécutions', en: 'Create and configure processings, trigger and kill their runs' }, - admin: { fr: 'Supprimer les traitements, gérer leurs permissions, leur propriétaire et leur clé de webhook', en: 'Delete processings, manage their permissions, owner and webhook key' } + umbrella: { en: 'All processing scopes', fr: 'Tous les droits sur les traitements' }, + read: { en: "Read the account's processings, their runs and logs", fr: 'Lire les traitements du compte, leurs exécutions et leurs journaux' }, + write: { en: 'Create and configure processings, trigger and kill their runs', fr: 'Créer et configurer les traitements, déclencher et arrêter leurs exécutions' }, + admin: { en: 'Delete processings, manage their permissions, owner and webhook key', fr: 'Supprimer les traitements, gérer leurs permissions, leur propriétaire et leur clé de webhook' } } } }) diff --git a/api/types/permission/schema.js b/api/types/permission/schema.js index 591b7555..5a56229b 100644 --- a/api/types/permission/schema.js +++ b/api/types/permission/schema.js @@ -14,21 +14,38 @@ export default { properties: { profile: { type: 'string', - title: 'profil', + title: 'Profile', + 'x-i18n-title': { fr: 'Profil' }, default: 'read', oneOf: [ - { const: 'read', title: "lecture - permet d'accéder aux informations essentielles du traitement dont les logs, mais pas aux informations sensibles" }, - { const: 'exec', title: "exécution - permet d'accéder aux informations essentielles du traitement et de déclencher le traitement" } + { + const: 'read', + title: 'Read profile', + 'x-i18n-title': { + en: 'Read - gives access to the essential information of the processing, logs included, but not to the sensitive information', + fr: "Lecture - permet d'accéder aux informations essentielles du traitement dont les logs, mais pas aux informations sensibles" + } + }, + { + const: 'exec', + title: 'Exec profile', + 'x-i18n-title': { + en: 'Execution - gives access to the essential information of the processing and allows triggering it', + fr: "Exécution - permet d'accéder aux informations essentielles du traitement et de déclencher le traitement" + } + } ] }, target: { type: 'object', oneOfLayout: { - label: 'type de cible' + label: 'Target type', + 'x-i18n-label': { fr: 'Type de cible' } }, oneOf: [ { - title: 'utilisateur désigné par son email', + title: 'User email', + 'x-i18n-title': { en: 'User designated by their email', fr: 'Utilisateur désigné par son email' }, required: ['email'], properties: { type: { @@ -36,12 +53,14 @@ export default { }, email: { type: 'string', - title: 'email' + title: 'Email', + 'x-i18n-title': { fr: 'Email' } } } }, { - title: 'organisation partenaire', + title: 'Partner organization', + 'x-i18n-title': { fr: 'Organisation partenaire' }, required: ['organization', 'roles'], properties: { type: { @@ -49,7 +68,8 @@ export default { }, organization: { type: 'object', - title: 'organisation', + title: 'Organization', + 'x-i18n-title': { fr: 'Organisation' }, additionalProperties: true, layout: { cols: 8, @@ -72,7 +92,8 @@ export default { }, roles: { type: 'array', - title: 'rôles', + title: 'Roles', + 'x-i18n-title': { fr: 'Rôles' }, default: ['admin'], layout: { cols: 4 }, items: { diff --git a/api/types/processing/schema.js b/api/types/processing/schema.js index 6aa5360e..7f98ca75 100644 --- a/api/types/processing/schema.js +++ b/api/types/processing/schema.js @@ -21,15 +21,18 @@ export default { properties: { _id: { type: 'string', - title: 'Identifiant du traitement', + title: 'Processing ID', + 'x-i18n-title': { fr: 'Identifiant du traitement' }, readOnly: true }, title: { type: 'string', - title: 'Titre' + title: 'Title', + 'x-i18n-title': { fr: 'Titre' } }, active: { - title: 'Actif', + title: 'Active', + 'x-i18n-title': { fr: 'Actif' }, type: 'boolean', default: false, layout: { @@ -76,8 +79,10 @@ export default { }, debug: { type: 'boolean', - title: 'Mode debug', - description: 'Capture des logs détaillés (stacks d\'erreurs, appels HTTP) réservés aux super-admins, pour diagnostiquer un plugin en erreur.', + title: 'Debug mode', + 'x-i18n-title': { fr: 'Mode debug' }, + description: 'Captures detailed logs (error stacks, HTTP calls) reserved for super-admins, to diagnose a failing plugin.', + 'x-i18n-description': { fr: 'Capture des logs détaillés (stacks d\'erreurs, appels HTTP) réservés aux super-admins, pour diagnostiquer un plugin en erreur.' }, readOnly: true }, owner: { @@ -91,10 +96,12 @@ export default { }, scheduling: { type: 'array', - title: 'Planification du traitement', + title: 'Processing scheduling', + 'x-i18n-title': { fr: 'Planification du traitement' }, layout: { messages: { - addItem: 'Ajouter une règle de planification' + addItem: 'Add a scheduling rule', + 'x-i18n-addItem': { fr: 'Ajouter une règle de planification' } }, cols: 6 }, @@ -114,7 +121,8 @@ export default { title: 'Permissions', layout: { messages: { - addItem: 'Ajouter une permission' + addItem: 'Add a permission', + 'x-i18n-addItem': { fr: 'Ajouter une permission' } }, cols: 6 }, @@ -153,16 +161,17 @@ export default { lastRun: jsonSchema(RunSchema) .removeId() .removeProperties(['log', 'processing', 'owner']) - .appendTitle('Dernière exécution') + .appendTitle(' last run') .schema, nextRun: jsonSchema(RunSchema) .removeId() .removeProperties(['log', 'processing', 'owner']) - .appendTitle('Prochaine exécution') + .appendTitle(' next run') .schema, webhookKey: { type: 'string', - title: 'Clé pour exécution à distance du traitement', + title: 'Remote execution key of the processing', + 'x-i18n-title': { fr: 'Clé pour exécution à distance du traitement' }, readOnly: true } }, diff --git a/package-lock.json b/package-lock.json index 11019c1c..3e605045 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,10 +20,10 @@ "devDependencies": { "@commitlint/cli": "^21.2.3", "@commitlint/config-conventional": "^21.2.3", - "@data-fair/lib-common-types": "^1.27.0", + "@data-fair/lib-common-types": "^1.28.1", "@data-fair/lib-dev": "^0.1.0", "@data-fair/lib-node": "^2.16.1", - "@data-fair/lib-utils": "^1.14.0", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/openapi-mcp": "^0.12.0", "@json-layout/agents": "^0.5.0", "@playwright/test": "^1.52.0", @@ -48,11 +48,11 @@ }, "api": { "dependencies": { - "@data-fair/lib-common-types": "^1.27.0", + "@data-fair/lib-common-types": "^1.28.1", "@data-fair/lib-express": "^1.34.1", "@data-fair/lib-node": "^2.16.1", "@data-fair/lib-node-registry": "0.7.2", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/lib-validation": "^1.0.2", "@data-fair/processings-shared": "*", "@json-layout/core": "^2.13.3", @@ -533,9 +533,9 @@ "license": "MIT" }, "node_modules/@data-fair/lib-common-types": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/@data-fair/lib-common-types/-/lib-common-types-1.27.0.tgz", - "integrity": "sha512-4Aol9enLJo8Ut4ypNwPa5X0XYJ/IUuH6iuhfGw/+a6+XFljPfXi+UNw/WorMUDWU0HhnJGPzHT27edlR6tXKRw==", + "version": "1.28.1", + "resolved": "https://registry.npmjs.org/@data-fair/lib-common-types/-/lib-common-types-1.28.1.tgz", + "integrity": "sha512-joY6owKDY5vhlM9YaUBT70WzM2ZqzZq3Q8Eq4lvyUqgnsKu75Cr+yoHoPJXkWyGrIg+4eVz185vunRlWJTL3iQ==", "license": "MIT", "dependencies": { "@data-fair/lib-utils": "^1.6.1", @@ -695,9 +695,9 @@ } }, "node_modules/@data-fair/lib-utils": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/@data-fair/lib-utils/-/lib-utils-1.14.0.tgz", - "integrity": "sha512-4a/E73ORqOrv/aJqk8GUO1mh3o2c4/LRA1x2KYngeJculJdTgv2ZZnjW9tJGyD6RCthzco4Twnk00UMI5cjLNw==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@data-fair/lib-utils/-/lib-utils-1.15.0.tgz", + "integrity": "sha512-obo84Se8fnLg5L1+vtU/UM+7Xh2FNUegrlH41q96fKupg7KYgPu+P4Nz+nk8wXnnRVBq7E1lZNZ2MhbNWc5K+Q==", "license": "MIT", "peerDependencies": { "dayjs": "1" @@ -754,9 +754,9 @@ } }, "node_modules/@data-fair/lib-vuetify": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/@data-fair/lib-vuetify/-/lib-vuetify-2.5.3.tgz", - "integrity": "sha512-C7lmw7/99fjRpM21AJDw3m97RXwAMDdcL06qlD5BwNejfpk2lIjVhI3gpP9madnMrX1gQky01QSXuyMLuLIvDA==", + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/@data-fair/lib-vuetify/-/lib-vuetify-2.5.4.tgz", + "integrity": "sha512-NXa7TjteQWv7cTsmTAhy+fmqGEwRRus2JcIGfLKqrAlKFJzajPKZgU19RDJWM9nriA1QT8PIdNH4wxtZAbXqFg==", "license": "MIT", "dependencies": { "@data-fair/lib-common-types": "^1.10.4", @@ -10032,7 +10032,7 @@ "name": "@data-fair/processings-shared", "dependencies": { "@data-fair/lib-node": "^2.16.1", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "croner": "^9.1.0", "dayjs": "^1.11.13", "fs-extra": "^11.3.0", @@ -10063,9 +10063,9 @@ "ui": { "dependencies": { "@data-fair/frame": "^0.18.4", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/lib-vue": "^1.31.1", - "@data-fair/lib-vuetify": "^2.5.1", + "@data-fair/lib-vuetify": "^2.5.4", "@data-fair/processings-shared": "*", "@intlify/unplugin-vue-i18n": "^11.0.7", "@koumoul/vjsf": "^4.2.0", diff --git a/package.json b/package.json index 73cdcd2c..2c0064dd 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,10 @@ "devDependencies": { "@commitlint/cli": "^21.2.3", "@commitlint/config-conventional": "^21.2.3", - "@data-fair/lib-common-types": "^1.27.0", + "@data-fair/lib-common-types": "^1.28.1", "@data-fair/lib-dev": "^0.1.0", "@data-fair/lib-node": "^2.16.1", - "@data-fair/lib-utils": "^1.14.0", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/openapi-mcp": "^0.12.0", "@json-layout/agents": "^0.5.0", "@playwright/test": "^1.52.0", diff --git a/shared/package.json b/shared/package.json index 1ed1dc33..246a4019 100644 --- a/shared/package.json +++ b/shared/package.json @@ -3,7 +3,7 @@ "type": "module", "dependencies": { "@data-fair/lib-node": "^2.16.1", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "croner": "^9.1.0", "dayjs": "^1.11.13", "fs-extra": "^11.3.0", diff --git a/shared/plugin-load.ts b/shared/plugin-load.ts index aefc6c6f..267ebc87 100644 --- a/shared/plugin-load.ts +++ b/shared/plugin-load.ts @@ -19,7 +19,7 @@ export const importPluginModule = async ( const mainRel = typeof pkg.main === 'string' && pkg.main.length > 0 ? pkg.main : 'index.js' const mainAbs = path.resolve(pluginDir, mainRel) if (!(await fs.pathExists(mainAbs))) { - throw new Error(`fichier source manquant : ${mainAbs}`) + throw new Error(`missing source file: ${mainAbs}`) } return (await import(mainAbs)) as T } diff --git a/shared/runs.ts b/shared/runs.ts index dbaeecf9..404e913f 100644 --- a/shared/runs.ts +++ b/shared/runs.ts @@ -40,9 +40,9 @@ export const nextScheduledDate = (schedulings: Scheduling[]): Date | null => { export const createNext = async (db: Db, locks: Locks, processing: Processing, triggered: boolean = false, delaySeconds:number = 0): Promise => { const ack = await locks.acquire(processing._id + '/next-run') try { - if (!ack) throw httpError(400, 'une planification est déjà en cours') + if (!ack) throw httpError(400, 'A scheduling is already in progress') if (await db.collection('runs').countDocuments({ 'processing._id': processing._id, status: 'running' }) > 0) { - throw httpError(400, 'une exécution est déjà en cours') + throw httpError(400, 'A run is already in progress') } const run = { @@ -74,7 +74,7 @@ export const createNext = async (db: Db, locks: Locks, processing: Processing, t } } else { if (await db.collection('runs').countDocuments({ 'processing._id': processing._id, status: 'triggered' }) > 0) { - throw httpError(400, 'une exécution manuelle est déjà demandée') + throw httpError(400, 'A manual run is already requested') } await runsCollection.deleteMany({ 'processing._id': processing._id, status: 'scheduled' }) await processingsCollection.updateOne({ _id: run.processing._id }, { $unset: { nextRun: 1 } }) diff --git a/tests/features/processings/broken-plugin.api.spec.ts b/tests/features/processings/broken-plugin.api.spec.ts index ff5c802f..99a7aa8a 100644 --- a/tests/features/processings/broken-plugin.api.spec.ts +++ b/tests/features/processings/broken-plugin.api.spec.ts @@ -79,7 +79,7 @@ test.describe('processing with unavailable plugin', () => { expect(after.status).toBe(404) }) - test('worker logs a friendly French message when the plugin is unavailable', async () => { + test('worker logs a friendly message when the plugin is unavailable', async () => { const superadmin = await axiosAuth('test_superadmin@test.com') const id = await createBrokenProcessing(superadmin) @@ -97,7 +97,7 @@ test.describe('processing with unavailable plugin', () => { const run = (await superadmin.get(`/api/v1/runs/${triggeredRunId}`)).data expect( - run.log.some((l: any) => l.type === 'error' && l.msg.includes("n'est plus disponible")) + run.log.some((l: any) => l.type === 'error' && l.msg.includes('is no longer available')) ).toBe(true) }) }) diff --git a/tests/features/processings/log-flood.api.spec.ts b/tests/features/processings/log-flood.api.spec.ts index 665b2a14..065e3c13 100644 --- a/tests/features/processings/log-flood.api.spec.ts +++ b/tests/features/processings/log-flood.api.spec.ts @@ -52,7 +52,7 @@ test.describe('run log size guard', () => { expect(flooding.length).toBeGreaterThan(0) for (const entry of flooding) expect(entry.msg).toBe('x'.repeat(maxLogEntryLength) + '...') // the document filled up, the log was truncated to make room for the guard message and finish() - expect(log.some(l => l.type === 'error' && /taille maximale/.test(l.msg))).toBe(true) + expect(log.some(l => l.type === 'error' && /maximum allowed size/.test(l.msg))).toBe(true) expect(Buffer.byteLength(JSON.stringify(log))).toBeLessThan(mongoDocumentLimit / 4) expect(log[log.length - 1].type).toBe('debug') // finish() could still add its entry }) diff --git a/tests/features/processings/memory-oom.api.spec.ts b/tests/features/processings/memory-oom.api.spec.ts index 33f4fec9..efbeb693 100644 --- a/tests/features/processings/memory-oom.api.spec.ts +++ b/tests/features/processings/memory-oom.api.spec.ts @@ -99,12 +99,12 @@ test.describe('memory pressure diagnostics', () => { const finalRun = await waitForRunStatus(triggered._id, 'error', 90_000) expect(finalRun.status).toBe('error') - // The run log carries the French user-facing OOM message. The English - // diagnostic ("heap OOM", "exit code 134") goes to the worker's stdout - // (ops), not the run log. Match on the French wording emitted by - // oomHeapUser() in worker/src/utils/exit-code.ts. + // The run log carries the user-facing OOM message. The ops diagnostic + // ("heap OOM", "exit code 134") goes to the worker's stdout, not the run + // log. Match on the wording emitted by oomHeapUser() in + // worker/src/utils/exit-code.ts. const allMsgs = (finalRun.log ?? []).map((l: any) => l.msg).join('\n') - expect(allMsgs).toMatch(/limite de mémoire|tas JavaScript/i) + expect(allMsgs).toMatch(/memory limit|JavaScript heap/i) // Prometheus counter incremented (best-effort; skip if endpoint unreachable // at baseline time). diff --git a/tests/features/processings/operations.unit.spec.ts b/tests/features/processings/operations.unit.spec.ts index 2a524776..17ab1131 100644 --- a/tests/features/processings/operations.unit.spec.ts +++ b/tests/features/processings/operations.unit.spec.ts @@ -9,18 +9,18 @@ test.describe('translateRegistryError', () => { test('403 names the owner and the plugin', () => { const err = translateRegistryError({ status: 403 }, processing) expect(err.status).toBe(403) - expect(err.message).toBe("Le compte Test User 1 n'a pas accès au plugin @test-plugin-1.") + expect(err.message).toBe('The account Test User 1 has no access to the plugin @test-plugin-1.') }) test('403 falls back to the owner id without a name', () => { const err = translateRegistryError({ statusCode: 403 }, { ...processing, owner: { type: 'user', id: 'test_user1' } }) - expect(err.message).toContain('Le compte test_user1 ') + expect(err.message).toContain('The account test_user1 ') }) test('404 says the plugin is missing from the registry', () => { const err = translateRegistryError({ status: 404 }, processing) expect(err.status).toBe(404) - expect(err.message).toBe('Le plugin @test-plugin-1 est introuvable dans le registre.') + expect(err.message).toBe('The plugin @test-plugin-1 was not found in the registry.') }) test('anything else is a registry outage (502)', () => { diff --git a/tests/features/processings/plugin-access.api.spec.ts b/tests/features/processings/plugin-access.api.spec.ts index de414d0c..01b4c007 100644 --- a/tests/features/processings/plugin-access.api.spec.ts +++ b/tests/features/processings/plugin-access.api.spec.ts @@ -8,7 +8,7 @@ import { publishFixturePlugin } from '../../support/registry.ts' * picked plugin is private and the owner is not on `privateAccess`, the * registry's /:id/download route returns 403 (no longer 404, since the * caller already knows the id). The processings API translates that into - * a French user-facing message and routes the response status correctly. + * a user-facing message and routes the response status correctly. * * The owner used here is `test_user1` because the default fixture grants only * include `test_superadmin` + the two orgs — a plain user account is the @@ -47,7 +47,7 @@ test.describe('processing creation with restricted plugin access', () => { // the owner. Pre-rebuild registry image hides the artefact behind 404; // post-rebuild it returns 403 (since the caller already knows the id and // we want to distinguish "no access" from "doesn't exist"). Either way - // the processings API translates to a French message containing the + // the processings API translates to a message containing the // plugin id, NOT the previous opaque 500. const schema = await superadmin.get( `/api/v1/processings/${res.data._id}/plugin-config-schema`, @@ -57,7 +57,7 @@ test.describe('processing creation with restricted plugin access', () => { const body = typeof schema.data === 'string' ? schema.data : JSON.stringify(schema.data) expect(body).toContain(fixture.pluginId) // Post-rebuild only: the message names the owner. Skip if the registry - // still returns 404 — that's just "Le plugin … est introuvable". + // still returns 404 — that's just "The plugin … was not found". if (schema.status === 403) expect(body).toContain('Test User 1') }) diff --git a/tests/features/worker-utils/exit-code.unit.spec.ts b/tests/features/worker-utils/exit-code.unit.spec.ts index ea819e53..146b3390 100644 --- a/tests/features/worker-utils/exit-code.unit.spec.ts +++ b/tests/features/worker-utils/exit-code.unit.spec.ts @@ -39,7 +39,7 @@ test('code 143 alone is sigterm', () => { expect(d.category).toBe('sigterm') }) -test('SIGKILL -> oom-host with English adminMessage and French userMessage', () => { +test('SIGKILL -> oom-host with an admin message and a user message', () => { const d = diagnoseExit(null, 'SIGKILL', '', sample, null, ctx) expect(d.category).toBe('oom-host') // English ops message (cause only, metrics live in adminMetrics) @@ -47,8 +47,8 @@ test('SIGKILL -> oom-host with English adminMessage and French userMessage', () expect(d.adminMessage).toContain('SIGKILL') expect(d.adminMetrics).toContain('heap used: 723.0MB') expect(d.adminMetrics).toContain('RSS: 812.0MB') - // French user-facing message in run log - expect(d.userMessage).toMatch(/tué|terminé par le système/i) + // user-facing message in run log + expect(d.userMessage).toContain('killed by the system') expect(d.userMessage).toContain('SIGKILL') }) @@ -70,15 +70,15 @@ test('code 137 with selfKilled=true -> sigterm category', () => { expect(d.category).toBe('sigterm') }) -test('code 134 -> oom-heap with mention of max heap config (English admin + French user)', () => { +test('code 134 -> oom-heap with mention of max heap config (admin + user messages)', () => { const d = diagnoseExit(134, null, 'FATAL ERROR: JavaScript heap out of memory', sample, null, ctx) expect(d.category).toBe('oom-heap') // English admin message (cause + mitigation) expect(d.adminMessage).toContain('exit code 134') expect(d.adminMessage).toContain('WORKER_TASK_MAX_HEAP_MB=768') expect(d.adminMessage).toContain('Concurrent tasks at exit: 3 / concurrency 4') - // French user message - expect(d.userMessage).toMatch(/mémoire|tas/i) + // user message + expect(d.userMessage).toContain('memory limit (JavaScript heap)') expect(d.userMessage).toContain('768') }) @@ -114,8 +114,8 @@ test('unknown code 99 -> unknown', () => { const d = diagnoseExit(99, null, 'weird', null, null, ctx) expect(d.category).toBe('unknown') expect(d.adminMessage).toContain('code=99') - // French user message for unknown - expect(d.userMessage).toMatch(/inattendue|inattendu/i) + // user message for unknown + expect(d.userMessage).toContain('Task ended unexpectedly') }) test('null code, null signal -> unknown', () => { @@ -159,16 +159,16 @@ test('lastExt with null cpuRatio omits CPU usage line', () => { expect(d.adminMetrics).not.toMatch(/CPU usage/) }) -test('oom-host with lastExt includes French external RSS and CPU usage in userMetrics', () => { +test('oom-host with lastExt includes external RSS and CPU usage in userMetrics', () => { const d = diagnoseExit(null, 'SIGKILL', '', sample, ext, ctx) - expect(d.userMetrics).toMatch(/Dernier RSS observé \(parent\)\s*:\s*815\.0MB/) - expect(d.userMetrics).toMatch(/Utilisation CPU \(parent\)\s*:\s*0\.92/) + expect(d.userMetrics).toMatch(/Last seen RSS \(external\):\s*815\.0MB/) + expect(d.userMetrics).toMatch(/CPU usage \(external\):\s*0\.92/) }) -test('lastExt with null cpuRatio omits CPU usage line from French userMetrics', () => { +test('lastExt with null cpuRatio omits CPU usage line from userMetrics', () => { const d = diagnoseExit(null, 'SIGKILL', '', sample, { ...ext, cpuRatio: null }, ctx) - expect(d.userMetrics).toMatch(/Dernier RSS observé \(parent\)/) - expect(d.userMetrics).not.toMatch(/Utilisation CPU/) + expect(d.userMetrics).toMatch(/Last seen RSS \(external\)/) + expect(d.userMetrics).not.toMatch(/CPU usage/) }) test('oom-host renders external RSS BEFORE in-process memLine in metrics (external is primary)', () => { diff --git a/tests/fixtures/agent-surface.json b/tests/fixtures/agent-surface.json index f3385c12..35307316 100644 --- a/tests/fixtures/agent-surface.json +++ b/tests/fixtures/agent-surface.json @@ -95,7 +95,10 @@ "properties": { "title": { "type": "string", - "title": "Titre" + "title": "Title", + "x-i18n-title": { + "fr": "Titre" + } }, "plugin": { "type": "string", @@ -318,10 +321,16 @@ }, "title": { "type": "string", - "title": "Titre" + "title": "Title", + "x-i18n-title": { + "fr": "Titre" + } }, "active": { - "title": "Actif", + "title": "Active", + "x-i18n-title": { + "fr": "Actif" + }, "type": "boolean", "default": false, "layout": { @@ -341,10 +350,16 @@ }, "scheduling": { "type": "array", - "title": "Planification du traitement", + "title": "Processing scheduling", + "x-i18n-title": { + "fr": "Planification du traitement" + }, "layout": { "messages": { - "addItem": "Ajouter une règle de planification" + "addItem": "Add a scheduling rule", + "x-i18n-addItem": { + "fr": "Ajouter une règle de planification" + } }, "cols": 6 }, @@ -817,7 +832,10 @@ "title": "Permissions", "layout": { "messages": { - "addItem": "Ajouter une permission" + "addItem": "Add a permission", + "x-i18n-addItem": { + "fr": "Ajouter une permission" + } }, "cols": 6 }, @@ -832,27 +850,45 @@ "properties": { "profile": { "type": "string", - "title": "profil", + "title": "Profile", + "x-i18n-title": { + "fr": "Profil" + }, "default": "read", "oneOf": [ { "const": "read", - "title": "lecture - permet d'accéder aux informations essentielles du traitement dont les logs, mais pas aux informations sensibles" + "title": "Read profile", + "x-i18n-title": { + "en": "Read - gives access to the essential information of the processing, logs included, but not to the sensitive information", + "fr": "Lecture - permet d'accéder aux informations essentielles du traitement dont les logs, mais pas aux informations sensibles" + } }, { "const": "exec", - "title": "exécution - permet d'accéder aux informations essentielles du traitement et de déclencher le traitement" + "title": "Exec profile", + "x-i18n-title": { + "en": "Execution - gives access to the essential information of the processing and allows triggering it", + "fr": "Exécution - permet d'accéder aux informations essentielles du traitement et de déclencher le traitement" + } } ] }, "target": { "type": "object", "oneOfLayout": { - "label": "type de cible" + "label": "Target type", + "x-i18n-label": { + "fr": "Type de cible" + } }, "oneOf": [ { - "title": "utilisateur désigné par son email", + "title": "User email", + "x-i18n-title": { + "en": "User designated by their email", + "fr": "Utilisateur désigné par son email" + }, "required": [ "email" ], @@ -862,12 +898,18 @@ }, "email": { "type": "string", - "title": "email" + "title": "Email", + "x-i18n-title": { + "fr": "Email" + } } } }, { - "title": "organisation partenaire", + "title": "Partner organization", + "x-i18n-title": { + "fr": "Organisation partenaire" + }, "required": [ "organization", "roles" @@ -878,7 +920,10 @@ }, "organization": { "type": "object", - "title": "organisation", + "title": "Organization", + "x-i18n-title": { + "fr": "Organisation" + }, "additionalProperties": true, "layout": { "cols": 8, @@ -900,7 +945,10 @@ }, "roles": { "type": "array", - "title": "rôles", + "title": "Roles", + "x-i18n-title": { + "fr": "Rôles" + }, "default": [ "admin" ], diff --git a/ui/package.json b/ui/package.json index cd29c4ec..ed50041d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -17,9 +17,9 @@ }, "dependencies": { "@data-fair/frame": "^0.18.4", - "@data-fair/lib-utils": "^1.13.1", + "@data-fair/lib-utils": "^1.15.0", "@data-fair/lib-vue": "^1.31.1", - "@data-fair/lib-vuetify": "^2.5.1", + "@data-fair/lib-vuetify": "^2.5.4", "@data-fair/processings-shared": "*", "@intlify/unplugin-vue-i18n": "^11.0.7", "@koumoul/vjsf": "^4.2.0", diff --git a/ui/src/App.vue b/ui/src/App.vue index a2d309dd..9a4450b3 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -9,4 +9,7 @@ diff --git a/ui/src/components/private-access.vue b/ui/src/components/private-access.vue index f737225a..73cf93a4 100644 --- a/ui/src/components/private-access.vue +++ b/ui/src/components/private-access.vue @@ -32,14 +32,14 @@ -fr: - public: Public - privateAccess: Vue restreinte à des comptes - searchName: Saisissez un nom d'organisation / un utilisateur en: public: Public privateAccess: Restricted access to some accounts searchName: Search an organization name / a user name +fr: + public: Public + privateAccess: Vue restreinte à des comptes + searchName: Saisissez un nom d'organisation / un utilisateur @@ -370,6 +370,7 @@ const timezoneLabel = (timeZone: string) => { timezone: 'Timezone:' updateError: Error while updating the processing updateSuccess: Processing saved! + pluginTitle: 'Plugin {title}' pluginUnavailableTitle: Plugin unavailable pluginUnavailableBody: This processing's plugin has been removed or its access revoked. You can no longer edit or run this processing, but you can still view its run history and delete it. configSchemaFetchError: Failed to load the plugin's configuration schema @@ -386,6 +387,7 @@ const timezoneLabel = (timeZone: string) => { timezone: 'Fuseau horaire :' updateError: Erreur lors de la mise à jour du traitement updateSuccess: Traitement enregistré ! + pluginTitle: 'Plugin {title}' pluginUnavailableTitle: Plugin indisponible pluginUnavailableBody: Le plugin de ce traitement a été supprimé ou son accès retiré. Vous ne pouvez plus modifier ni exécuter ce traitement, mais vous pouvez consulter son historique et le supprimer. configSchemaFetchError: Échec du chargement du schéma de configuration du plugin diff --git a/ui/src/pages/processings/new.vue b/ui/src/pages/processings/new.vue index 3e18408c..946ed5c1 100644 --- a/ui/src/pages/processings/new.vue +++ b/ui/src/pages/processings/new.vue @@ -154,7 +154,7 @@ type NewProcessing = { } const { t, locale } = useI18n() -const session = useSessionAuthenticated(() => new Error('Authentification nécessaire')) +const session = useSessionAuthenticated(() => new Error(t('authRequired'))) const router = useRouter() /* @@ -207,11 +207,11 @@ const filteredArtefacts = computed(() => { }) const artefactDisplayName = (a: RegistryArtefact) => - a.title?.[locale.value as 'fr' | 'en'] ?? a.title?.fr ?? a.title?.en ?? a.name + localizedText(a.title, locale.value) ?? a.name const artefactDisplayDescription = (a: RegistryArtefact) => - a.description?.[locale.value as 'fr' | 'en'] ?? a.description?.fr ?? a.description?.en ?? '' + localizedText(a.description, locale.value) ?? '' const artefactGroup = (a: RegistryArtefact) => - a.group?.[locale.value as 'fr' | 'en'] ?? a.group?.fr ?? a.group?.en ?? t('otherGroup') + localizedText(a.group, locale.value) ?? t('otherGroup') // Configured groups define the leading display order. Any registry group not // listed in the config is appended (alphabetically) after the configured ones, @@ -278,6 +278,7 @@ onMounted(() => { en: + authRequired: Authentication required selectPluginType: Plugin selection information: Information title: Title @@ -294,6 +295,7 @@ onMounted(() => { otherGroup: Other fr: + authRequired: Authentification nécessaire selectPluginType: Sélection du plugin information: Informations title: Titre diff --git a/ui/src/utils/localized-text.ts b/ui/src/utils/localized-text.ts new file mode 100644 index 00000000..4d80c7e2 --- /dev/null +++ b/ui/src/utils/localized-text.ts @@ -0,0 +1,10 @@ +// copy of the reading rule of { en, fr } registry values, see https://github.com/data-fair/registry/blob/main/ui/src/utils/localized.ts + +type LocalizedText = { fr?: string, en?: string } + +export const localizedText = (value: LocalizedText | undefined, lang: string | undefined): string | undefined => { + if (!value) return undefined + return lang?.startsWith('fr') ? (value.fr || value.en || undefined) : (value.en || value.fr || undefined) +} + +export default localizedText diff --git a/worker/src/task/axios.ts b/worker/src/task/axios.ts index ec51611f..9d33e9b6 100644 --- a/worker/src/task/axios.ts +++ b/worker/src/task/axios.ts @@ -67,7 +67,7 @@ export const getAxiosInstance = (processing: Processing, log: LogFunctions) => { onRetry: (retryCount, _err, requestConfig) => { const err = prepareAxiosError(_err) const message = getHttpErrorMessage(err) || err.message || err - log.warning(`tentative ${retryCount} de requête ${requestConfig.method} ${requestConfig.url} : ${message}`) + log.warning(`attempt ${retryCount} of request ${requestConfig.method} ${requestConfig.url}: ${message}`) } }) diff --git a/worker/src/task/task.ts b/worker/src/task/task.ts index 78529a70..9a7e5d31 100644 --- a/worker/src/task/task.ts +++ b/worker/src/task/task.ts @@ -58,7 +58,7 @@ const prepareLog = (processing: Processing, run: Run): LogFunctions => { // limit. Make room so the run can still be finished, leave an explicit // error and fail the task. overflowed = true - const msg = 'Le journal d\'exécution a atteint la taille maximale autorisée, l\'exécution est interrompue. Le traitement produit trop de messages, réduisez sa verbosité.' + const msg = 'The run log reached its maximum allowed size, the run is interrupted. The processing writes too many messages, reduce its verbosity.' await truncateLog(run._id) const errorLog: any = { type: 'error', msg, extra: '', date: log.date } await mongo.runs.updateOne({ _id: run._id }, { $push: { log: errorLog } }) @@ -104,7 +104,7 @@ export const run = async (mailTransport: any) => { // and (when processing.debug) appends debug entries to run.log. const memReporter = startMemoryReporter(processing, log.debug, config.worker.task.memorySampleIntervalMs) if (run.status === 'running') { - await log.step('Reprise après interruption.') + await log.step('Resuming after an interruption.') } await running(run) console.log('') @@ -131,7 +131,7 @@ export const run = async (mailTransport: any) => { } catch (err) { const status = (err as any)?.status ?? (err as any)?.statusCode if (status === 404 || status === 403) { - await log.error(`Le plugin ${processing.plugin} n'est plus disponible (supprimé ou accès retiré).`) + await log.error(`The plugin ${processing.plugin} is no longer available (deleted or access revoked).`) } throw err } @@ -198,8 +198,8 @@ export const run = async (mailTransport: any) => { await mongo.runs.updateOne({ _id: run._id }, { $set: { deleteOnComplete: true } }) } process.chdir(cwd) - if (_stopped) await log.error('L\'exécution a été interrompue', '') - else await log.info('L\'exécution est terminée', '') + if (_stopped) await log.error('The run was interrupted', '') + else await log.info('The run is finished', '') } catch (e: any) { process.chdir(cwd) const err = prepareAxiosError(e) diff --git a/worker/src/utils/exit-code.ts b/worker/src/utils/exit-code.ts index ebbcfa13..87577b7d 100644 --- a/worker/src/utils/exit-code.ts +++ b/worker/src/utils/exit-code.ts @@ -10,7 +10,7 @@ export type ExitDiagnosis = { category: ExitCategory // English text for ops/console/Prometheus context. adminMessage: string - // French text written to run.log (user-facing). Empty for silent categories. + // Text written to run.log (user-facing). Empty for silent categories. userMessage: string // Resource metrics (RSS / CPU / heap), kept separate from the human-readable // cause so the worker can log them as an independent (debug) entry instead of @@ -34,11 +34,6 @@ const memLine = (lastMem: MemorySample | null, maxHeapMB: number): string => { return `Last memory sample — heap used: ${toMB(lastMem.heapUsed)} / ${maxHeapMB}MB; RSS: ${toMB(lastMem.rss)}.` } -const memLineFr = (lastMem: MemorySample | null, maxHeapMB: number): string => { - if (!lastMem) return 'aucune mesure mémoire n\'a été reportée avant la sortie' - return `Dernière mesure mémoire — heap utilisé : ${toMB(lastMem.heapUsed)} / ${maxHeapMB}MB ; RSS : ${toMB(lastMem.rss)}.` -} - const extLines = (lastExt: ExternalSample | null): string[] => { if (!lastExt) return [] const out = [`Last seen RSS (external): ${toMB(lastExt.rssBytes)}.`] @@ -48,15 +43,6 @@ const extLines = (lastExt: ExternalSample | null): string[] => { return out } -const extLinesFr = (lastExt: ExternalSample | null): string[] => { - if (!lastExt) return [] - const out = [`Dernier RSS observé (parent) : ${toMB(lastExt.rssBytes)}.`] - if (lastExt.cpuRatio !== null) { - out.push(`Utilisation CPU (parent) : ${lastExt.cpuRatio.toFixed(2)} (1.0 = un cœur saturé).`) - } - return out -} - const oomHeapAdmin = (ctx: DiagnoseContext): string => [ 'Task exceeded the JavaScript heap limit (heap OOM, exit code 134).', `Concurrent tasks at exit: ${ctx.runningTasks} / concurrency ${ctx.concurrency}.`, @@ -65,8 +51,8 @@ const oomHeapAdmin = (ctx: DiagnoseContext): string => [ ].join('\n') const oomHeapUser = (ctx: DiagnoseContext): string => [ - `Le traitement a dépassé la limite de mémoire (tas JavaScript) allouée à la tâche (${ctx.maxHeapMB}MB).`, - 'Contactez un administrateur pour augmenter la limite ou réduire la concurrence.' + `The processing exceeded the memory limit (JavaScript heap) allocated to the task (${ctx.maxHeapMB}MB).`, + 'Contact an administrator to raise the limit or lower the concurrency.' ].join('\n') const oomHostAdmin = (): string => [ @@ -76,25 +62,25 @@ const oomHostAdmin = (): string => [ ].join('\n') const oomHostUser = (): string => [ - 'Le traitement a été terminé par le système (signal SIGKILL), vraisemblablement à cause d\'un dépassement de la mémoire allouée au conteneur.', - 'Contactez un administrateur pour augmenter la limite mémoire du conteneur ou réduire la concurrence.' + 'The processing was killed by the system (SIGKILL signal), probably because it exceeded the memory allocated to the container.', + 'Contact an administrator to raise the memory limit of the container or lower the concurrency.' ].join('\n') // heap OOM: child-reported heap is primary, external RSS secondary. const oomHeapMetricsAdmin = (lastMem: MemorySample | null, lastExt: ExternalSample | null, ctx: DiagnoseContext): string => [memLine(lastMem, ctx.maxHeapMB), ...extLines(lastExt)].join('\n') const oomHeapMetricsUser = (lastMem: MemorySample | null, lastExt: ExternalSample | null, ctx: DiagnoseContext): string => - [memLineFr(lastMem, ctx.maxHeapMB), ...extLinesFr(lastExt)].join('\n') + [memLine(lastMem, ctx.maxHeapMB), ...extLines(lastExt)].join('\n') // host OOM: external (parent-observed) RSS is primary, child sample secondary. const oomHostMetricsAdmin = (lastMem: MemorySample | null, lastExt: ExternalSample | null, ctx: DiagnoseContext): string => [...extLines(lastExt), memLine(lastMem, ctx.maxHeapMB)].join('\n') const oomHostMetricsUser = (lastMem: MemorySample | null, lastExt: ExternalSample | null, ctx: DiagnoseContext): string => - [...extLinesFr(lastExt), memLineFr(lastMem, ctx.maxHeapMB)].join('\n') + [...extLines(lastExt), memLine(lastMem, ctx.maxHeapMB)].join('\n') const unknownUser = (code: number | null, signal: NodeJS.Signals | null, stderr: string): string => { const tail = buildErrorMessageFromStderr(stderr, '') - const base = `Fin de tâche inattendue (code=${code}, signal=${signal ?? 'null'}).` + const base = `Task ended unexpectedly (code=${code}, signal=${signal ?? 'null'}).` return tail ? `${base} ${tail}` : base } @@ -146,7 +132,7 @@ export const diagnoseExit = ( adminMessage: base, userMessage: base, adminMetrics: extLines(lastExt).join('\n'), - userMetrics: extLinesFr(lastExt).join('\n') + userMetrics: extLines(lastExt).join('\n') } } return { @@ -154,6 +140,6 @@ export const diagnoseExit = ( adminMessage: `Task ended unexpectedly (code=${code}, signal=${signal ?? 'null'}). ${buildErrorMessageFromStderr(stderr, '')}`.trim(), userMessage: unknownUser(code, signal, stderr), adminMetrics: extLines(lastExt).join('\n'), - userMetrics: extLinesFr(lastExt).join('\n') + userMetrics: extLines(lastExt).join('\n') } } diff --git a/worker/src/utils/runs.ts b/worker/src/utils/runs.ts index 1a456162..4841b475 100644 --- a/worker/src/utils/runs.ts +++ b/worker/src/utils/runs.ts @@ -9,17 +9,24 @@ import mongo from '#mongo' import { internalError } from '@data-fair/lib-node/observer.js' import { isDocumentTooLargeError, shouldDisableForFailures } from './runs-operations.ts' +const runTitles = { + 'log-error': (title: string) => ({ en: `The processing ${title} finished but its log contains errors`, fr: `Le traitement ${title} s'est terminé mais son journal contient des erreurs` }), + 'finish-ok': (title: string) => ({ en: `The processing ${title} finished without errors`, fr: `Le traitement ${title} s'est terminé sans erreur` }), + 'finish-error': (title: string) => ({ en: `The processing ${title} failed`, fr: `Le traitement ${title} a échoué` }), + disabled: (title: string) => ({ en: `The processing ${title} was disabled after failing ${config.maxFailures} times in a row`, fr: `Le traitement ${title} a été désactivé après ${config.maxFailures} échecs consécutifs` }) +} + const sendProcessingEvent = ( run: Run, - statusText: string, - statusKey: string, + action: keyof typeof runTitles, body?: string ) => { - // @test:spy("pushEvent", `processings:processing-${statusKey}:${run.processing._id}`) + // @test:spy("pushEvent", `processings:processing-${action}:${run.processing._id}`) eventsQueue.pushEvent({ - title: `Le traitement ${run.processing.title} ${statusText}.`, - topic: { key: `processings:processing-${statusKey}:${run.processing._id}` }, + title: runTitles[action](run.processing.title), + topic: { key: `processings:processing-${action}:${run.processing._id}` }, sender: run.owner, + // the run's own error messages, not translated body, visibility: 'private' as const, urlParams: { @@ -28,12 +35,12 @@ const sendProcessingEvent = ( resource: { type: 'processing', id: run.processing._id, - title: 'Traitement associé : ' + run.processing.title, + title: run.processing.title, }, originator: { internalProcess: { id: 'processings-worker', - name: 'Processings Worker' + title: 'Processings Worker' } } }) @@ -118,17 +125,12 @@ export const finish = async (run: Run, errorMessage: string | undefined = undefi if (lastRun.status === 'finished') { const errorLogs = lastRun.log.filter((l) => l.type === 'error') if (errorLogs.length) { - sendProcessingEvent( - run, - 's\'est terminé correctement mais son journal contient des erreurs', - 'log-error', - errorLogs.map((l) => l.msg).join('\n --- \n') - ) + sendProcessingEvent(run, 'log-error', errorLogs.map((l) => l.msg).join('\n --- \n')) } else { - sendProcessingEvent(run, 's\'est terminé sans erreurs', 'finish-ok') + sendProcessingEvent(run, 'finish-ok') } } else if (lastRun.status === 'error') { - sendProcessingEvent(run, 'a échoué', 'finish-error', errorMessage) + sendProcessingEvent(run, 'finish-error', errorMessage) const raw = (await mongo.runs.aggregate([ { $match: { 'processing._id': run.processing._id } }, @@ -167,7 +169,7 @@ export const finish = async (run: Run, errorMessage: string | undefined = undefi { _id: run.processing._id }, { $set: { active: false } } ) - sendProcessingEvent(run, `a été désactivé car il a échoué ${config.maxFailures} fois de suite`, 'disabled') + sendProcessingEvent(run, 'disabled') } } diff --git a/worker/src/worker.ts b/worker/src/worker.ts index 5f5d5c48..0cea4652 100644 --- a/worker/src/worker.ts +++ b/worker/src/worker.ts @@ -246,7 +246,7 @@ async function iter (run: Run, freeSlot: number) { return } if (!processing.active) { - await finish(run, 'le traitement a été désactivé', 'error') + await finish(run, 'the processing was disabled', 'error') return } @@ -254,7 +254,7 @@ async function iter (run: Run, freeSlot: number) { const remaining = await limits.remaining(processing.owner) if (remaining.processingsSeconds === 0) { - await finish(run, 'le temps de traitement autorisé est épuisé', 'error') + await finish(run, 'the allowed processing time is exhausted', 'error') // @test:spy("processingsSecondsExceeded") return } @@ -346,7 +346,7 @@ async function iter (run: Run, freeSlot: number) { await finish(run) // @test:spy("isKilled") } else { - // Admin (English) → ops console; user (French) → run.log (debug level, + // Admin message → ops console; user message → run.log (debug level, // matching the pre-existing convention for technical failure messages). // Resource metrics (RSS/CPU/heap) are kept as a separate log entry so // they don't get appended to the human-readable error. @@ -415,7 +415,7 @@ async function acquireNext (): Promise { if (run.status === 'running') { try { console.warn('we had to close a run that was stuck in running status', run) - await finish(run, 'le traitement a été interrompu suite à une opération de maintenance', 'error') + await finish(run, 'the processing was interrupted by a maintenance operation', 'error') const processing = await mongo.processings.findOne({ _id: run.processing._id }) await locks.release(run.processing._id) if (processing && processing.active && processing.scheduling.length) {