@reqvet-sdk/sdk 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +65 -65
  2. package/SDK_REFERENCE.md +176 -176
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,78 +1,78 @@
1
- # @reqvet/sdk
1
+ # @reqvet-sdk/sdk
2
2
 
3
- Official JavaScript/TypeScript SDK for the [ReqVet](https://reqvet.com) API AI-powered veterinary report generation from audio recordings.
3
+ SDK JavaScript/TypeScript officiel pour l'API [ReqVet](https://reqvet.com) — génération de comptes rendus vétérinaires par IA à partir d'enregistrements audio.
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/@reqvet/sdk)](https://www.npmjs.com/package/@reqvet/sdk)
5
+ [![npm version](https://img.shields.io/npm/v/@reqvet-sdk/sdk)](https://www.npmjs.com/package/@reqvet-sdk/sdk)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
7
  [![Node.js ≥ 18](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
8
8
 
9
- ## What it does
9
+ ## Fonctionnalités
10
10
 
11
- - **Upload** an audio recording (`uploadAudio`)
12
- - **Generate** a veterinary report (`createJob`, `generateReport`)
13
- - **Track** jobs — webhook-first or polling (`getJob`, `waitForJob`, `listJobs`)
14
- - **Amend** a completed report with additional audio (`amendJob`)
15
- - **Regenerate** with new instructions (`regenerateJob`)
16
- - **Reformulate** for a specific audience — owner, referral, specialist (`reformulateReport`)
17
- - **Manage templates** (`listTemplates`, `createTemplate`, `updateTemplate`, `deleteTemplate`)
18
- - **Verify webhooks** with HMAC (`@reqvet/sdk/webhooks`)
11
+ - **Uploader** un enregistrement audio (`uploadAudio`)
12
+ - **Générer** un compte rendu vétérinaire (`createJob`, `generateReport`)
13
+ - **Suivre** les jobs — via webhook ou polling (`getJob`, `waitForJob`, `listJobs`)
14
+ - **Amender** un compte rendu terminé avec un audio complémentaire (`amendJob`)
15
+ - **Régénérer** avec de nouvelles instructions (`regenerateJob`)
16
+ - **Reformuler** pour une audience spécifique propriétaire, référé, spécialiste (`reformulateReport`)
17
+ - **Gérer les templates** (`listTemplates`, `createTemplate`, `updateTemplate`, `deleteTemplate`)
18
+ - **Vérifier les webhooks** avec HMAC (`@reqvet-sdk/sdk/webhooks`)
19
19
 
20
- > **Note**: this SDK does not include an audio recorder. Your application handles recording and passes a `File`, `Blob`, or `Buffer` to the SDK.
20
+ > **Note** : ce SDK n'inclut pas d'enregistreur audio. Votre application gère l'enregistrement et passe un `File`, `Blob` ou `Buffer` au SDK.
21
21
 
22
22
  ## Installation
23
23
 
24
24
  ```bash
25
- npm install @reqvet/sdk
25
+ npm install @reqvet-sdk/sdk
26
26
  ```
27
27
 
28
- Requires Node.js ≥ 18. Works in modern browsers for client methods (Blob/FormData required for upload).
28
+ Nécessite Node.js ≥ 18. Fonctionne dans les navigateurs modernes pour les méthodes client (Blob/FormData requis pour l'upload).
29
29
 
30
- ## Before your first call
30
+ ## Avant votre premier appel
31
31
 
32
- Your ReqVet account manager will provide three environment variables:
32
+ Votre responsable de compte ReqVet vous fournira trois variables d'environnement :
33
33
 
34
34
  ```bash
35
35
  REQVET_API_KEY=rqv_live_...
36
36
  REQVET_BASE_URL=https://api.reqvet.com
37
- REQVET_WEBHOOK_SECRET=... # only needed if using webhooks
37
+ REQVET_WEBHOOK_SECRET=... # uniquement si vous utilisez les webhooks
38
38
  ```
39
39
 
40
- Every job requires a `templateId`. **Call `listTemplates()` first** to discover what's available:
40
+ Chaque job nécessite un `templateId`. **Appelez `listTemplates()` en premier** pour découvrir ce qui est disponible :
41
41
 
42
42
  ```ts
43
43
  const { system, custom } = await reqvet.listTemplates();
44
- // system = ReqVet-provided templates, visible to all organizations (read-only)
45
- // custom = templates created by your organization
44
+ // system = templates fournis par ReqVet, visibles par toutes les organisations (lecture seule)
45
+ // custom = templates créés par votre organisation
46
46
 
47
47
  const templateId = system[0].id;
48
48
  ```
49
49
 
50
- ## Quick start
50
+ ## Démarrage rapide
51
51
 
52
- ### Webhook flow (recommended)
52
+ ### Flux webhook (recommandé)
53
53
 
54
54
  ```ts
55
- import ReqVet from '@reqvet/sdk';
55
+ import ReqVet from '@reqvet-sdk/sdk';
56
56
 
57
57
  const reqvet = new ReqVet(process.env.REQVET_API_KEY!, {
58
58
  baseUrl: process.env.REQVET_BASE_URL,
59
59
  });
60
60
 
61
- // 1. Upload the audio
61
+ // 1. Uploader l'audio
62
62
  const { path } = await reqvet.uploadAudio(audioBuffer, 'consultation.webm');
63
63
 
64
- // 2. Create a job — ReqVet will POST the result to your webhook when ready
64
+ // 2. Créer un job — ReqVet POSTera le résultat sur votre webhook quand il sera prêt
65
65
  const job = await reqvet.createJob({
66
66
  audioFile: path,
67
67
  animalName: 'Rex',
68
68
  templateId: 'your-template-uuid',
69
69
  callbackUrl: 'https://your-app.com/api/reqvet/webhook',
70
- metadata: { consultationId: 'abc123' }, // passed through to your webhook
70
+ metadata: { consultationId: 'abc123' }, // transmis tel quel à votre webhook
71
71
  });
72
72
  // { job_id: '...', status: 'pending' }
73
73
  ```
74
74
 
75
- Your webhook receives a `job.completed` event:
75
+ Votre webhook reçoit un événement `job.completed` :
76
76
 
77
77
  ```json
78
78
  {
@@ -86,7 +86,7 @@ Your webhook receives a `job.completed` event:
86
86
  }
87
87
  ```
88
88
 
89
- ### Polling flow (simpler for development)
89
+ ### Flux polling (plus simple pour le développement)
90
90
 
91
91
  ```ts
92
92
  const report = await reqvet.generateReport({
@@ -99,10 +99,10 @@ const report = await reqvet.generateReport({
99
99
  // { jobId, html, fields, transcription, cost, metadata }
100
100
  ```
101
101
 
102
- ### Verify an incoming webhook
102
+ ### Vérifier un webhook entrant
103
103
 
104
104
  ```ts
105
- import { verifyWebhookSignature } from '@reqvet/sdk/webhooks';
105
+ import { verifyWebhookSignature } from '@reqvet-sdk/sdk/webhooks';
106
106
 
107
107
  export async function POST(req: NextRequest) {
108
108
  const rawBody = await req.text();
@@ -123,36 +123,36 @@ export async function POST(req: NextRequest) {
123
123
 
124
124
  ## API
125
125
 
126
- | Method | Description |
127
- |--------|-------------|
128
- | `uploadAudio(audio, fileName?)` | Upload an audio file |
129
- | `generateReport(params)` | Upload + create job (convenience helper) |
130
- | `createJob(params)` | Create a generation job |
131
- | `listJobs(options?)` | List jobs with pagination and status filter |
132
- | `getJob(jobId)` | Get job status and result |
133
- | `waitForJob(jobId, onStatus?)` | Poll until job completes |
134
- | `regenerateJob(jobId, options?)` | Regenerate a completed report |
135
- | `amendJob(jobId, params)` | Add an audio complement to a completed job |
136
- | `reformulateReport(jobId, params)` | Generate an audience-specific version |
137
- | `listReformulations(jobId)` | List all reformulations for a job |
138
- | `listTemplates()` | List available templates (`{ system, custom }`) |
139
- | `getTemplate(templateId)` | Get a template by ID |
140
- | `createTemplate(params)` | Create a custom template |
141
- | `updateTemplate(templateId, updates)` | Update a template |
142
- | `deleteTemplate(templateId)` | Delete a template |
143
- | `health()` | API health check |
144
-
145
- ## Webhook events
146
-
147
- ReqVet fires 5 event types: `job.completed`, `job.failed`, `job.amended`, `job.amend_failed`, `job.regenerated`.
148
-
149
- Failed deliveries are retried 3 times (0s, 2s, 5s). Implement idempotency in your handler — deduplicate on `job_id + event`.
150
-
151
- See [SDK_REFERENCE.md §6](./SDK_REFERENCE.md#6-webhook-events) for the full payload structure of each event.
126
+ | Méthode | Description |
127
+ |---------|-------------|
128
+ | `uploadAudio(audio, fileName?)` | Uploader un fichier audio |
129
+ | `generateReport(params)` | Upload + création de job (helper tout-en-un) |
130
+ | `createJob(params)` | Créer un job de génération |
131
+ | `listJobs(options?)` | Lister les jobs avec pagination et filtre par statut |
132
+ | `getJob(jobId)` | Obtenir le statut et le résultat d'un job |
133
+ | `waitForJob(jobId, onStatus?)` | Attendre en polling la fin d'un job |
134
+ | `regenerateJob(jobId, options?)` | Régénérer un compte rendu terminé |
135
+ | `amendJob(jobId, params)` | Ajouter un audio complémentaire à un job terminé |
136
+ | `reformulateReport(jobId, params)` | Générer une version adaptée à une audience |
137
+ | `listReformulations(jobId)` | Lister toutes les reformulations d'un job |
138
+ | `listTemplates()` | Lister les templates disponibles (`{ system, custom }`) |
139
+ | `getTemplate(templateId)` | Obtenir un template par son ID |
140
+ | `createTemplate(params)` | Créer un template personnalisé |
141
+ | `updateTemplate(templateId, updates)` | Mettre à jour un template |
142
+ | `deleteTemplate(templateId)` | Supprimer un template |
143
+ | `health()` | Vérification de l'état de l'API |
144
+
145
+ ## Événements webhook
146
+
147
+ ReqVet déclenche 5 types d'événements : `job.completed`, `job.failed`, `job.amended`, `job.amend_failed`, `job.regenerated`.
148
+
149
+ Les livraisons échouées sont retentées 3 fois (0s, 2s, 5s). Implémentez l'idempotence dans votre handler — dédoublonnez sur `job_id + event`.
150
+
151
+ Voir [SDK_REFERENCE.md §6](./SDK_REFERENCE.md#6-webhook-events) pour la structure complète des payloads de chaque événement.
152
152
 
153
153
  ## TypeScript
154
154
 
155
- Full TypeScript definitions included:
155
+ Définitions TypeScript complètes incluses :
156
156
 
157
157
  ```ts
158
158
  import type {
@@ -162,18 +162,18 @@ import type {
162
162
  Template,
163
163
  ReqVetReformulation,
164
164
  ExtractedFields,
165
- } from '@reqvet/sdk';
165
+ } from '@reqvet-sdk/sdk';
166
166
  ```
167
167
 
168
- ## Further reading
168
+ ## Pour aller plus loin
169
169
 
170
- - [SDK_REFERENCE.md](./SDK_REFERENCE.md) — full parameter and response documentation, all webhook payloads, field schema, error codes
171
- - [SECURITY.md](./SECURITY.md) — security guidelines, proxy pattern, complete webhook verification example
170
+ - [SDK_REFERENCE.md](./SDK_REFERENCE.md) — documentation complète des paramètres et réponses, tous les payloads webhook, schéma des champs, codes d'erreur
171
+ - [SECURITY.md](./SECURITY.md) — bonnes pratiques de sécurité, pattern proxy, exemple complet de vérification webhook
172
172
 
173
- ## Security
173
+ ## Sécurité
174
174
 
175
- **Never** expose your API key in client-side code. Always use the SDK server-side and proxy requests from your frontend. See [SECURITY.md](./SECURITY.md).
175
+ **Ne jamais** exposer votre clé API dans du code côté client. Utilisez toujours le SDK côté serveur et proxifiez les requêtes depuis votre frontend. Voir [SECURITY.md](./SECURITY.md).
176
176
 
177
- ## License
177
+ ## Licence
178
178
 
179
179
  MIT
package/SDK_REFERENCE.md CHANGED
@@ -1,64 +1,64 @@
1
- # @reqvet/sdk — Technical Reference
1
+ # @reqvet-sdk/sdk — Référence technique
2
2
 
3
- Complete parameter and response documentation for all SDK methods.
3
+ Documentation complète des paramètres et réponses pour toutes les méthodes du SDK.
4
4
 
5
5
  ---
6
6
 
7
- ## 1) Instantiation
7
+ ## 1) Instanciation
8
8
 
9
9
  ```ts
10
- import ReqVet from '@reqvet/sdk';
10
+ import ReqVet from '@reqvet-sdk/sdk';
11
11
 
12
12
  const reqvet = new ReqVet(process.env.REQVET_API_KEY!, {
13
13
  baseUrl: process.env.REQVET_BASE_URL ?? 'https://api.reqvet.com',
14
- pollInterval: 5000, // polling interval in ms (default: 5000)
15
- timeout: 5 * 60 * 1000, // max polling wait in ms (default: 300 000 = 5 min)
14
+ pollInterval: 5000, // intervalle de polling en ms (défaut : 5000)
15
+ timeout: 5 * 60 * 1000, // attente maximale en polling en ms (défaut : 300 000 = 5 min)
16
16
  });
17
17
  ```
18
18
 
19
- The API key must start with `rqv_`. An `Error` is thrown immediately if it doesn't.
19
+ La clé API doit commencer par `rqv_`. Une `Error` est levée immédiatement dans le cas contraire.
20
20
 
21
21
  ---
22
22
 
23
- ## 2) Before your first call
23
+ ## 2) Avant votre premier appel
24
24
 
25
- ### Get your credentials
25
+ ### Obtenir vos identifiants
26
26
 
27
- Your ReqVet account manager will provide:
28
- - `REQVET_API_KEY` — your org API key (`rqv_live_...`)
29
- - `REQVET_BASE_URL` — the API base URL
30
- - `REQVET_WEBHOOK_SECRET` — your webhook signing secret (if using webhooks)
27
+ Votre responsable de compte ReqVet vous fournira :
28
+ - `REQVET_API_KEY` — votre clé API d'organisation (`rqv_live_...`)
29
+ - `REQVET_BASE_URL` — l'URL de base de l'API
30
+ - `REQVET_WEBHOOK_SECRET` — votre secret de signature webhook (si vous utilisez les webhooks)
31
31
 
32
- ### Discover your templates
32
+ ### Découvrir vos templates
33
33
 
34
- Every job requires a `templateId`. Before generating reports, list the templates available to your organization:
34
+ Chaque job nécessite un `templateId`. Avant de générer des comptes rendus, listez les templates disponibles pour votre organisation :
35
35
 
36
36
  ```ts
37
37
  const { custom, system } = await reqvet.listTemplates();
38
- // system = templates created by ReqVet, available to all organizations (read-only)
39
- // custom = templates created by your organization
40
- const templateId = system[0].id; // or custom[0].id
38
+ // system = templates créés par ReqVet, disponibles pour toutes les organisations (lecture seule)
39
+ // custom = templates créés par votre organisation
40
+ const templateId = system[0].id; // ou custom[0].id
41
41
  ```
42
42
 
43
43
  ---
44
44
 
45
- ## 3) Integration patterns
45
+ ## 3) Patterns d'intégration
46
46
 
47
- ### A) Webhook-first (recommended for production)
47
+ ### A) Webhook en priorité (recommandé pour la production)
48
48
 
49
49
  ```
50
- uploadAudio() → createJob({ callbackUrl }) → ReqVet POSTs result to your endpoint
50
+ uploadAudio() → createJob({ callbackUrl }) → ReqVet POSTe le résultat sur votre endpoint
51
51
  ```
52
52
 
53
- The user can close the browser the result arrives on your server asynchronously.
53
+ L'utilisateur peut fermer le navigateurle résultat arrive sur votre serveur de manière asynchrone.
54
54
 
55
- ### B) Polling (development / simple integrations)
55
+ ### B) Polling (développement / intégrations simples)
56
56
 
57
57
  ```
58
- uploadAudio() → createJob() → waitForJob() → report
58
+ uploadAudio() → createJob() → waitForJob() → rapport
59
59
  ```
60
60
 
61
- Or use the convenience wrapper:
61
+ Ou utilisez le wrapper pratique :
62
62
 
63
63
  ```ts
64
64
  const report = await reqvet.generateReport({ audio, animalName, templateId, waitForResult: true });
@@ -66,92 +66,92 @@ const report = await reqvet.generateReport({ audio, animalName, templateId, wait
66
66
 
67
67
  ---
68
68
 
69
- ## 4) Methods
69
+ ## 4) Méthodes
70
70
 
71
71
  ### `uploadAudio(audio, fileName?)`
72
72
 
73
- Upload an audio file to ReqVet storage.
73
+ Uploader un fichier audio vers le stockage ReqVet.
74
74
 
75
- **Parameters:**
76
- | Name | Type | Required | Description |
77
- |------|------|----------|-------------|
78
- | `audio` | `Blob \| File \| Buffer` | ✅ | Audio data |
79
- | `fileName` | `string` | — | File name, used to infer MIME type (default: `audio.webm`) |
75
+ **Paramètres :**
76
+ | Nom | Type | Requis | Description |
77
+ |-----|------|--------|-------------|
78
+ | `audio` | `Blob \| File \| Buffer` | ✅ | Données audio |
79
+ | `fileName` | `string` | — | Nom du fichier, utilisé pour inférer le type MIME (défaut : `audio.webm`) |
80
80
 
81
- **Response:**
81
+ **Réponse :**
82
82
  ```ts
83
83
  {
84
- audio_file: string; // canonical storage pathpass this to createJob()
85
- path: string; // alias of audio_file
84
+ audio_file: string; // chemin de stockage canonique à passer à createJob()
85
+ path: string; // alias de audio_file
86
86
  size_bytes: number;
87
87
  content_type: string;
88
88
  }
89
89
  ```
90
90
 
91
- Supported formats: `mp3`, `wav`, `webm`, `ogg`, `m4a`, `aac`, `flac`. Max size: 100 MB.
91
+ Formats supportés : `mp3`, `wav`, `webm`, `ogg`, `m4a`, `aac`, `flac`. Taille max : 100 Mo.
92
92
 
93
93
  ---
94
94
 
95
95
  ### `generateReport(params)`
96
96
 
97
- Convenience wrapper: `uploadAudio → createJob`. Optionally waits for completion.
98
-
99
- **Parameters:**
100
- | Name | Type | Required | Description |
101
- |------|------|----------|-------------|
102
- | `audio` | `Blob \| File \| Buffer` | ✅ | Audio data |
103
- | `animalName` | `string` | ✅ | Name of the animal |
104
- | `templateId` | `string` | ✅ | Template UUID (from `listTemplates()`) |
105
- | `fileName` | `string` | — | File name |
106
- | `callbackUrl` | `string` | — | Your webhook endpoint (HTTPS, publicly reachable) |
107
- | `metadata` | `Record<string, unknown>` | — | Passthrough data (e.g. `{ consultationId, vetId }`) |
108
- | `extraInstructions` | `string` | — | Additional generation instructions injected into the prompt |
109
- | `waitForResult` | `boolean` | — | If `true`, polls and returns the final report. Default: `false` |
110
- | `onStatus` | `(status: string) => void` | — | Called on each poll (only when `waitForResult: true`) |
111
-
112
- **Response:**
113
- - `waitForResult: false` (default): `{ job_id: string, status: 'pending' }`
114
- - `waitForResult: true`: `ReqVetReport` (see `waitForJob`)
97
+ Wrapper pratique : `uploadAudio → createJob`. Attend optionnellement la fin du traitement.
98
+
99
+ **Paramètres :**
100
+ | Nom | Type | Requis | Description |
101
+ |-----|------|--------|-------------|
102
+ | `audio` | `Blob \| File \| Buffer` | ✅ | Données audio |
103
+ | `animalName` | `string` | ✅ | Nom de l'animal |
104
+ | `templateId` | `string` | ✅ | UUID du template (depuis `listTemplates()`) |
105
+ | `fileName` | `string` | — | Nom du fichier |
106
+ | `callbackUrl` | `string` | — | Votre endpoint webhook (HTTPS, accessible publiquement) |
107
+ | `metadata` | `Record<string, unknown>` | — | Données passthrough (ex. `{ consultationId, vetId }`) |
108
+ | `extraInstructions` | `string` | — | Instructions de génération supplémentaires injectées dans le prompt |
109
+ | `waitForResult` | `boolean` | — | Si `true`, poll et retourne le rapport final. Défaut : `false` |
110
+ | `onStatus` | `(status: string) => void` | — | Appelé à chaque poll (uniquement si `waitForResult: true`) |
111
+
112
+ **Réponse :**
113
+ - `waitForResult: false` (défaut) : `{ job_id: string, status: 'pending' }`
114
+ - `waitForResult: true` : `ReqVetReport` (voir `waitForJob`)
115
115
 
116
116
  ---
117
117
 
118
118
  ### `createJob(params)`
119
119
 
120
- Start a transcription + report generation pipeline.
120
+ Démarrer un pipeline de transcription + génération de compte rendu.
121
121
 
122
- **Parameters:**
123
- | Name | Type | Required | Description |
124
- |------|------|----------|-------------|
125
- | `audioFile` | `string` | ✅ | Value of `uploadAudio().path` |
126
- | `animalName` | `string` | ✅ | Name of the animal |
127
- | `templateId` | `string` | ✅ | Template UUID |
128
- | `callbackUrl` | `string` | — | Webhook URL (HTTPS, publicly reachable). Falls back to the org default webhook if omitted. |
129
- | `metadata` | `Record<string, unknown>` | — | Passthrough datacorrelate with your own records |
130
- | `extraInstructions` | `string` | — | Extra generation instructions (max 5 000 chars) |
122
+ **Paramètres :**
123
+ | Nom | Type | Requis | Description |
124
+ |-----|------|--------|-------------|
125
+ | `audioFile` | `string` | ✅ | Valeur de `uploadAudio().path` |
126
+ | `animalName` | `string` | ✅ | Nom de l'animal |
127
+ | `templateId` | `string` | ✅ | UUID du template |
128
+ | `callbackUrl` | `string` | — | URL webhook (HTTPS, accessible publiquement). Utilise le webhook par défaut de l'organisation si omis. |
129
+ | `metadata` | `Record<string, unknown>` | — | Données passthroughpour corréler avec vos propres enregistrements |
130
+ | `extraInstructions` | `string` | — | Instructions de génération supplémentaires (max 5 000 caractères) |
131
131
 
132
- **Response:**
132
+ **Réponse :**
133
133
  ```ts
134
134
  { job_id: string; status: 'pending' }
135
135
  ```
136
136
 
137
- > **Rate limit**: 10 000 requests/minute per organization.
137
+ > **Limite de débit** : 10 000 requêtes/minute par organisation.
138
138
 
139
139
  ---
140
140
 
141
141
  ### `listJobs(options?)`
142
142
 
143
- List jobs for the authenticated organization, with pagination and filtering.
143
+ Lister les jobs de l'organisation authentifiée, avec pagination et filtrage.
144
144
 
145
- **Parameters:**
146
- | Name | Type | Default | Description |
147
- |------|------|---------|-------------|
148
- | `limit` | `number` | `20` | Results per page (1–100) |
149
- | `offset` | `number` | `0` | Pagination offset |
150
- | `status` | `string` | — | Filter: `pending` `transcribing` `generating` `completed` `failed` `amending` |
151
- | `sort` | `string` | `created_at` | Sort field: `created_at` or `updated_at` |
152
- | `order` | `string` | `desc` | Direction: `asc` or `desc` |
145
+ **Paramètres :**
146
+ | Nom | Type | Défaut | Description |
147
+ |-----|------|--------|-------------|
148
+ | `limit` | `number` | `20` | Résultats par page (1–100) |
149
+ | `offset` | `number` | `0` | Décalage de pagination |
150
+ | `status` | `string` | — | Filtre : `pending` `transcribing` `generating` `completed` `failed` `amending` |
151
+ | `sort` | `string` | `created_at` | Champ de tri : `created_at` ou `updated_at` |
152
+ | `order` | `string` | `desc` | Direction : `asc` ou `desc` |
153
153
 
154
- **Response:**
154
+ **Réponse :**
155
155
  ```ts
156
156
  {
157
157
  jobs: JobSummary[];
@@ -163,11 +163,11 @@ List jobs for the authenticated organization, with pagination and filtering.
163
163
 
164
164
  ### `getJob(jobId)`
165
165
 
166
- Get the current state and result of a job.
166
+ Obtenir l'état actuel et le résultat d'un job.
167
167
 
168
- **Response fields by status:**
168
+ **Champs de réponse par statut :**
169
169
 
170
- | Field | `pending` | `transcribing` | `generating` | `completed` | `failed` |
170
+ | Champ | `pending` | `transcribing` | `generating` | `completed` | `failed` |
171
171
  |-------|:---------:|:--------------:|:------------:|:-----------:|:--------:|
172
172
  | `job_id` | ✅ | ✅ | ✅ | ✅ | ✅ |
173
173
  | `status` | ✅ | ✅ | ✅ | ✅ | ✅ |
@@ -179,9 +179,9 @@ Get the current state and result of a job.
179
179
  | `cost` | — | — | — | ✅ | — |
180
180
  | `error` | — | — | — | — | ✅ |
181
181
 
182
- *`result.fields` is only present if your organization has a `field_schema` configured (structured data extraction). It is `null` otherwise. See [Field schema](#field-schema) below.
182
+ *`result.fields` n'est présent que si votre organisation a un `field_schema` configuré (extraction de données structurées). Vaut `null` sinon. Voir [Schéma de champs](#5-schéma-de-champs) ci-dessous.
183
183
 
184
- **Cost structure (completed jobs):**
184
+ **Structure du coût (jobs terminés) :**
185
185
  ```ts
186
186
  cost: {
187
187
  transcription_usd: number;
@@ -190,20 +190,20 @@ cost: {
190
190
  }
191
191
  ```
192
192
 
193
- > **Note**: `cost` is available via `getJob()` and `waitForJob()`, but is **not** included in webhook payloads. Retrieve it with `getJob()` after receiving a `job.completed` event if needed.
193
+ > **Note** : `cost` est disponible via `getJob()` et `waitForJob()`, mais n'est **pas** inclus dans les payloads webhook. Récupérez-le avec `getJob()` après réception d'un événement `job.completed` si nécessaire.
194
194
 
195
195
  ---
196
196
 
197
197
  ### `waitForJob(jobId, onStatus?)`
198
198
 
199
- Poll until a job reaches `completed` or `failed`. Respects `pollInterval` and `timeout`.
199
+ Poller jusqu'à ce qu'un job atteigne `completed` ou `failed`. Respecte `pollInterval` et `timeout`.
200
200
 
201
- **Response (`ReqVetReport`):**
201
+ **Réponse (`ReqVetReport`) :**
202
202
  ```ts
203
203
  {
204
204
  jobId: string;
205
- html: string; // generated report HTML
206
- fields: ExtractedFields | null; // null if no field_schema configured
205
+ html: string; // HTML du compte rendu généré
206
+ fields: ExtractedFields | null; // null si aucun field_schema configuré
207
207
  transcription: string;
208
208
  animalName: string;
209
209
  cost: { transcription_usd: number; generation_usd: number; total_usd: number };
@@ -211,70 +211,70 @@ Poll until a job reaches `completed` or `failed`. Respects `pollInterval` and `t
211
211
  }
212
212
  ```
213
213
 
214
- Throws `ReqVetError` if the job fails or the timeout is exceeded.
214
+ Lève une `ReqVetError` si le job échoue ou si le timeout est dépassé.
215
215
 
216
216
  ---
217
217
 
218
218
  ### `regenerateJob(jobId, options?)`
219
219
 
220
- Regenerate the report for a completed job — e.g. with different instructions or a different template.
220
+ Régénérer le compte rendu d'un job terminé par exemple avec des instructions différentes ou un autre template.
221
221
 
222
- **Parameters:**
223
- | Name | Type | Description |
224
- |------|------|-------------|
225
- | `extraInstructions` | `string` | New instructions (max 2 000 chars) |
226
- | `templateId` | `string` | Switch to a different template |
222
+ **Paramètres :**
223
+ | Nom | Type | Description |
224
+ |-----|------|-------------|
225
+ | `extraInstructions` | `string` | Nouvelles instructions (max 2 000 caractères) |
226
+ | `templateId` | `string` | Basculer vers un autre template |
227
227
 
228
- **Response:**
228
+ **Réponse :**
229
229
  ```ts
230
230
  { job_id: string; status: 'completed'; result: { html: string; fields?: ExtractedFields } }
231
231
  ```
232
232
 
233
- Triggers a `job.regenerated` webhook event if a `callbackUrl` is configured.
233
+ Déclenche un événement webhook `job.regenerated` si un `callbackUrl` est configuré.
234
234
 
235
- > **Rate limit**: 30 requests/minute per organization.
235
+ > **Limite de débit** : 30 requêtes/minute par organisation.
236
236
 
237
237
  ---
238
238
 
239
239
  ### `amendJob(jobId, params)`
240
240
 
241
- Add an audio complement to a completed job. The new audio is transcribed, merged with the existing transcription, and the report is regenerated.
241
+ Ajouter un audio complémentaire à un job terminé. Le nouvel audio est transcrit, fusionné avec la transcription existante, et le compte rendu est régénéré.
242
242
 
243
- **Parameters:**
244
- | Name | Type | Required | Description |
245
- |------|------|----------|-------------|
246
- | `audioFile` | `string` | ✅ | Value of `uploadAudio().path` |
247
- | `templateId` | `string` | — | Switch to a different template |
243
+ **Paramètres :**
244
+ | Nom | Type | Requis | Description |
245
+ |-----|------|--------|-------------|
246
+ | `audioFile` | `string` | ✅ | Valeur de `uploadAudio().path` |
247
+ | `templateId` | `string` | — | Basculer vers un autre template |
248
248
 
249
- **Response:**
249
+ **Réponse :**
250
250
  ```ts
251
251
  { job_id: string; status: 'amending'; amendment_number: number; message: string }
252
252
  ```
253
253
 
254
- The job returns to `completed` when the amendment finishes. Use `waitForJob()` or listen for the `job.amended` webhook event. Multiple amendments are supported each one appends to the full transcription.
254
+ Le job repasse à `completed` quand l'amendement est terminé. Utilisez `waitForJob()` ou écoutez l'événement webhook `job.amended`. Plusieurs amendements sont supportéschacun est ajouté à la transcription complète.
255
255
 
256
256
  ---
257
257
 
258
258
  ### `reformulateReport(jobId, params)`
259
259
 
260
- Generate an alternative version of a completed report for a specific audience.
260
+ Générer une version alternative d'un compte rendu terminé pour une audience spécifique.
261
261
 
262
- **Parameters:**
263
- | Name | Type | Required | Description |
264
- |------|------|----------|-------------|
262
+ **Paramètres :**
263
+ | Nom | Type | Requis | Description |
264
+ |-----|------|--------|-------------|
265
265
  | `purpose` | `string` | ✅ | `owner` `referral` `summary` `custom` `diagnostic_hypothesis` |
266
- | `customInstructions` | `string` | If `purpose: 'custom'` | Reformulation instructions |
267
-
268
- **Purpose values:**
269
- | Value | Output |
270
- |-------|--------|
271
- | `owner` | Simplified version for the pet owner |
272
- | `referral` | Clinical summary for a specialist |
273
- | `summary` | Short internal note |
274
- | `diagnostic_hypothesis` | Differential diagnosis list |
275
- | `custom` | Defined by `customInstructions` |
276
-
277
- **Response (`ReqVetReformulation`):**
266
+ | `customInstructions` | `string` | Si `purpose: 'custom'` | Instructions de reformulation |
267
+
268
+ **Valeurs de `purpose` :**
269
+ | Valeur | Résultat |
270
+ |--------|----------|
271
+ | `owner` | Version simplifiée pour le propriétaire de l'animal |
272
+ | `referral` | Résumé clinique pour un spécialiste |
273
+ | `summary` | Note interne courte |
274
+ | `diagnostic_hypothesis` | Liste de diagnostics différentiels |
275
+ | `custom` | Défini par `customInstructions` |
276
+
277
+ **Réponse (`ReqVetReformulation`) :**
278
278
  ```ts
279
279
  {
280
280
  id: string;
@@ -287,13 +287,13 @@ Generate an alternative version of a completed report for a specific audience.
287
287
  }
288
288
  ```
289
289
 
290
- > **Rate limit**: 30 requests/minute per organization.
290
+ > **Limite de débit** : 30 requêtes/minute par organisation.
291
291
 
292
292
  ---
293
293
 
294
294
  ### `listReformulations(jobId)`
295
295
 
296
- **Response:** `{ reformulations: ReqVetReformulation[] }`
296
+ **Réponse :** `{ reformulations: ReqVetReformulation[] }`
297
297
 
298
298
  ---
299
299
 
@@ -301,15 +301,15 @@ Generate an alternative version of a completed report for a specific audience.
301
301
 
302
302
  #### `listTemplates()` → `{ custom: Template[], system: Template[] }`
303
303
 
304
- - **`system`** — templates created by ReqVet, visible to all organizations. Read-only. Start here to find available `templateId` values.
305
- - **`custom`** — templates created by your organization. Editable via `createTemplate` / `updateTemplate`.
304
+ - **`system`** — templates créés par ReqVet, visibles par toutes les organisations. Lecture seule. Commencez ici pour trouver les `templateId` disponibles.
305
+ - **`custom`** — templates créés par votre organisation. Modifiables via `createTemplate` / `updateTemplate`.
306
306
 
307
307
  #### `getTemplate(templateId)` → `Template`
308
308
 
309
309
  #### `createTemplate(params)` → `Template`
310
310
 
311
- | Name | Type | Required |
312
- |------|------|----------|
311
+ | Nom | Type | Requis |
312
+ |-----|------|--------|
313
313
  | `name` | `string` | ✅ |
314
314
  | `content` | `string` | ✅ |
315
315
  | `description` | `string` | — |
@@ -317,7 +317,7 @@ Generate an alternative version of a completed report for a specific audience.
317
317
 
318
318
  #### `updateTemplate(templateId, updates)` → `Template`
319
319
 
320
- All fields optional (partial update). Same fields as `createTemplate`.
320
+ Tous les champs sont optionnels (mise à jour partielle). Mêmes champs que `createTemplate`.
321
321
 
322
322
  #### `deleteTemplate(templateId)` → `{ success: true }`
323
323
 
@@ -325,15 +325,15 @@ All fields optional (partial update). Same fields as `createTemplate`.
325
325
 
326
326
  ### `health()`
327
327
 
328
- **Response:** `{ status: 'ok' | 'degraded'; timestamp: string }`
328
+ **Réponse :** `{ status: 'ok' | 'degraded'; timestamp: string }`
329
329
 
330
330
  ---
331
331
 
332
- ## 5) Field schema
332
+ ## 5) Schéma de champs
333
333
 
334
- If your organization has a `field_schema` configured, ReqVet extracts structured fields from each consultation in addition to generating the HTML report.
334
+ Si votre organisation a un `field_schema` configuré, ReqVet extrait des champs structurés de chaque consultation en plus de générer le compte rendu HTML.
335
335
 
336
- Example `result.fields` for a standard checkup:
336
+ Exemple de `result.fields` pour un bilan de santé standard :
337
337
 
338
338
  ```json
339
339
  {
@@ -347,23 +347,23 @@ Example `result.fields` for a standard checkup:
347
347
  }
348
348
  ```
349
349
 
350
- `fields` is `null` if no `field_schema` is configured for your organization. Contact your ReqVet account manager to enable and configure structured extraction.
350
+ `fields` vaut `null` si aucun `field_schema` n'est configuré pour votre organisation. Contactez votre responsable de compte ReqVet pour activer et configurer l'extraction structurée.
351
351
 
352
352
  ---
353
353
 
354
- ## 6) Webhook events
354
+ ## 6) Événements webhook
355
355
 
356
- ReqVet POSTs to your `callbackUrl` when a job changes state. All events share the same format.
356
+ ReqVet POSTe sur votre `callbackUrl` quand un job change d'état. Tous les événements partagent le même format.
357
357
 
358
- ### Headers
358
+ ### En-têtes
359
359
 
360
360
  ```
361
361
  Content-Type: application/json
362
- X-ReqVet-Signature: sha256=<hex> (only if org has a webhook_secret)
363
- X-ReqVet-Timestamp: <unix_ms> (only if org has a webhook_secret)
362
+ X-ReqVet-Signature: sha256=<hex> (uniquement si l'organisation a un webhook_secret)
363
+ X-ReqVet-Timestamp: <unix_ms> (uniquement si l'organisation a un webhook_secret)
364
364
  ```
365
365
 
366
- ### Event types and payloads
366
+ ### Types d'événements et payloads
367
367
 
368
368
  #### `job.completed`
369
369
 
@@ -379,7 +379,7 @@ X-ReqVet-Timestamp: <unix_ms> (only if org has a webhook_secret)
379
379
  }
380
380
  ```
381
381
 
382
- > `fields` is absent if the organization has no `field_schema`. `cost` is not in the webhook — retrieve it with `getJob()` if needed.
382
+ > `fields` est absent si l'organisation n'a pas de `field_schema`. `cost` n'est pas dans le webhook — récupérez-le avec `getJob()` si nécessaire.
383
383
 
384
384
  ---
385
385
 
@@ -399,14 +399,14 @@ X-ReqVet-Timestamp: <unix_ms> (only if org has a webhook_secret)
399
399
 
400
400
  #### `job.amended`
401
401
 
402
- Sent when an amendment (`amendJob`) completes successfully.
402
+ Envoyé quand un amendement (`amendJob`) se termine avec succès.
403
403
 
404
404
  ```json
405
405
  {
406
406
  "event": "job.amended",
407
407
  "job_id": "a1b2c3d4-...",
408
408
  "animal_name": "Rex",
409
- "transcription": "...full transcription including amendment...",
409
+ "transcription": "...transcription complète incluant l'amendement...",
410
410
  "html": "<section class=\"cr\">...</section>",
411
411
  "amendment_number": 1,
412
412
  "fields": { "espece": "Chien", "poids": 28.5 },
@@ -418,7 +418,7 @@ Sent when an amendment (`amendJob`) completes successfully.
418
418
 
419
419
  #### `job.amend_failed`
420
420
 
421
- Sent when amendment transcription fails. The original report is preserved.
421
+ Envoyé quand la transcription d'un amendement échoue. Le compte rendu original est préservé.
422
422
 
423
423
  ```json
424
424
  {
@@ -434,7 +434,7 @@ Sent when amendment transcription fails. The original report is preserved.
434
434
 
435
435
  #### `job.regenerated`
436
436
 
437
- Sent when `regenerateJob()` completes.
437
+ Envoyé quand `regenerateJob()` se termine.
438
438
 
439
439
  ```json
440
440
  {
@@ -449,68 +449,68 @@ Sent when `regenerateJob()` completes.
449
449
 
450
450
  ---
451
451
 
452
- ### Retry policy
452
+ ### Politique de retry
453
453
 
454
- ReqVet retries failed webhook deliveries **3 times** with delays of 0s, 2s, and 5s. After 3 failures, the event is marked as undelivered. Implement idempotency in your handler (deduplicate on `job_id + event`).
454
+ ReqVet retente les livraisons webhook échouées **3 fois** avec des délais de 0s, 2s et 5s. Après 3 échecs, l'événement est marqué comme non livré. Implémentez l'idempotence dans votre handler (dédoublonnez sur `job_id + event`).
455
455
 
456
456
  ---
457
457
 
458
- ## 7) Webhook verification
458
+ ## 7) Vérification des webhooks
459
459
 
460
460
  ```ts
461
- import { verifyWebhookSignature } from '@reqvet/sdk/webhooks';
461
+ import { verifyWebhookSignature } from '@reqvet-sdk/sdk/webhooks';
462
462
 
463
463
  const { ok, reason } = verifyWebhookSignature({
464
464
  secret: process.env.REQVET_WEBHOOK_SECRET!,
465
- rawBody, // raw request body stringread BEFORE JSON.parse
466
- signature, // X-ReqVet-Signature header value
467
- timestamp, // X-ReqVet-Timestamp header value
468
- maxSkewMs: 5 * 60 * 1000, // reject events older than 5 min (default)
465
+ rawBody, // corps brut de la requête à lire AVANT JSON.parse
466
+ signature, // valeur de l'en-tête X-ReqVet-Signature
467
+ timestamp, // valeur de l'en-tête X-ReqVet-Timestamp
468
+ maxSkewMs: 5 * 60 * 1000, // rejeter les événements de plus de 5 min (défaut)
469
469
  });
470
470
  ```
471
471
 
472
- Rejection reasons: `missing_headers` `invalid_timestamp` `stale_timestamp` `invalid_signature`
472
+ Raisons de rejet : `missing_headers` `invalid_timestamp` `stale_timestamp` `invalid_signature`
473
473
 
474
- See [SECURITY.md](./SECURITY.md) for a complete Next.js implementation example.
474
+ Voir [SECURITY.md](./SECURITY.md) pour un exemple d'implémentation complet avec Next.js.
475
475
 
476
476
  ---
477
477
 
478
- ## 8) Error handling
478
+ ## 8) Gestion des erreurs
479
479
 
480
- All methods throw `ReqVetError` on HTTP errors or network failures:
480
+ Toutes les méthodes lèvent une `ReqVetError` en cas d'erreur HTTP ou de panne réseau :
481
481
 
482
482
  ```ts
483
- import { ReqVetError } from '@reqvet/sdk';
483
+ import { ReqVetError } from '@reqvet-sdk/sdk';
484
484
 
485
485
  try {
486
486
  const report = await reqvet.waitForJob(jobId);
487
487
  } catch (err) {
488
488
  if (err instanceof ReqVetError) {
489
- console.error(err.message); // human-readable message
490
- console.error(err.status); // HTTP status (0 for network/timeout errors)
491
- console.error(err.body); // raw response body
489
+ console.error(err.message); // message lisible par un humain
490
+ console.error(err.status); // statut HTTP (0 pour les erreurs réseau/timeout)
491
+ console.error(err.body); // corps brut de la réponse
492
492
  }
493
493
  }
494
494
  ```
495
495
 
496
- | Status | Meaning |
497
- |--------|---------|
498
- | `400` | Validation errorcheck `err.body.issues` |
499
- | `401` | Invalid or missing API key |
500
- | `403` | Monthly quota exceeded |
501
- | `404` | Job or template not found |
502
- | `429` | Rate limit exceededback off and retry |
503
- | `500` | ReqVet internal error |
496
+ | Statut | Signification |
497
+ |--------|---------------|
498
+ | `400` | Erreur de validation vérifiez `err.body.issues` |
499
+ | `401` | Clé API invalide ou manquante |
500
+ | `403` | Quota mensuel dépassé |
501
+ | `404` | Job ou template introuvable |
502
+ | `429` | Limite de débit dépassée attendez et réessayez |
503
+ | `500` | Erreur interne ReqVet |
504
504
 
505
505
  ---
506
506
 
507
- ## 9) Integration checklist
507
+ ## 9) Checklist d'intégration
508
508
 
509
- - [ ] SDK used **server-side only** — API key never in browser bundles
510
- - [ ] `listTemplates()` called at startup to discover available `templateId` values
511
- - [ ] `metadata` used to correlate ReqVet jobs with your own records (`consultationId`, `vetId`, etc.)
512
- - [ ] Webhook endpoint handles all 5 event types: `job.completed`, `job.failed`, `job.amended`, `job.amend_failed`, `job.regenerated`
513
- - [ ] Webhook signature verified on every incoming event
514
- - [ ] Timestamp anti-replay check enabled (`maxSkewMs`)
515
- - [ ] Idempotency implementeddeduplicate on `job_id + event`
516
- - [ ] `REQVET_API_KEY` and `REQVET_WEBHOOK_SECRET` stored in environment variables, never hardcoded
509
+ - [ ] SDK utilisé **côté serveur uniquement** — clé API jamais dans les bundles navigateur
510
+ - [ ] `listTemplates()` appelé au démarrage pour découvrir les `templateId` disponibles
511
+ - [ ] `metadata` utilisé pour corréler les jobs ReqVet avec vos propres enregistrements (`consultationId`, `vetId`, etc.)
512
+ - [ ] L'endpoint webhook gère les 5 types d'événements : `job.completed`, `job.failed`, `job.amended`, `job.amend_failed`, `job.regenerated`
513
+ - [ ] Signature webhook vérifiée sur chaque événement entrant
514
+ - [ ] Vérification anti-replay du timestamp activée (`maxSkewMs`)
515
+ - [ ] Idempotence implémentéedédoublonnage sur `job_id + event`
516
+ - [ ] `REQVET_API_KEY` et `REQVET_WEBHOOK_SECRET` stockés dans des variables d'environnement, jamais en dur dans le code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvet-sdk/sdk",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Official JavaScript SDK for the ReqVet veterinary report generation API.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",