@factpulse/sdk 3.0.37 → 4.0.0

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 (110) hide show
  1. package/.openapi-generator/FILES +6 -6
  2. package/CHANGELOG.md +10 -13
  3. package/README.md +135 -148
  4. package/api/invoice-processing-api.ts +2 -2
  5. package/dist/esm/models/chorus-pro-credentials.d.ts +19 -7
  6. package/dist/esm/models/chorus-pro-destination.d.ts +2 -2
  7. package/dist/esm/models/{facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.d.ts → facture-electronique-models-invoice-type-code.d.ts} +63 -18
  8. package/dist/{models/facture-electronique-rest-api-schemas-ereporting-invoice-type-code.js → esm/models/facture-electronique-models-invoice-type-code.js} +66 -10
  9. package/dist/esm/models/{facture-electronique-rest-api-schemas-validation-validation-error-response.d.ts → facture-electronique-rest-api-schemas-cdar-validation-error-response.d.ts} +13 -4
  10. package/dist/esm/models/{facture-electronique-rest-api-schemas-ereporting-invoice-type-code.d.ts → facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.d.ts} +11 -9
  11. package/dist/esm/models/get-chorus-pro-id-request.d.ts +2 -2
  12. package/dist/esm/models/get-invoice-request.d.ts +2 -2
  13. package/dist/esm/models/get-structure-request.d.ts +2 -2
  14. package/dist/esm/models/index.d.ts +3 -3
  15. package/dist/esm/models/index.js +3 -3
  16. package/dist/esm/models/invoice-input.d.ts +2 -2
  17. package/dist/esm/models/invoice-type-code.d.ts +6 -65
  18. package/dist/esm/models/invoice-type-code.js +6 -65
  19. package/dist/esm/models/recipient.d.ts +1 -1
  20. package/dist/esm/models/scheme-id.d.ts +7 -7
  21. package/dist/esm/models/scheme-id.js +7 -7
  22. package/dist/esm/models/search-structure-request.d.ts +2 -2
  23. package/dist/esm/models/simplified-invoice-data.d.ts +2 -2
  24. package/dist/esm/models/submit-complete-invoice-response.d.ts +1 -1
  25. package/dist/esm/models/submit-invoice-request.d.ts +2 -2
  26. package/dist/esm/models/supplier.d.ts +1 -1
  27. package/dist/esm/models/validate-cdarresponse.d.ts +3 -3
  28. package/dist/esm/models/validation-error-response.d.ts +3 -12
  29. package/dist/esm/src/helpers/client.d.ts +43 -265
  30. package/dist/esm/src/helpers/client.js +196 -779
  31. package/dist/esm/src/helpers/index.d.ts +1 -2
  32. package/dist/esm/src/helpers/index.js +1 -3
  33. package/dist/models/chorus-pro-credentials.d.ts +19 -7
  34. package/dist/models/chorus-pro-destination.d.ts +2 -2
  35. package/dist/models/{facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.d.ts → facture-electronique-models-invoice-type-code.d.ts} +63 -18
  36. package/dist/models/facture-electronique-models-invoice-type-code.js +85 -0
  37. package/dist/models/{facture-electronique-rest-api-schemas-validation-validation-error-response.d.ts → facture-electronique-rest-api-schemas-cdar-validation-error-response.d.ts} +13 -4
  38. package/dist/{esm/models/facture-electronique-rest-api-schemas-ereporting-invoice-type-code.js → models/facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.d.ts} +11 -10
  39. package/dist/models/get-chorus-pro-id-request.d.ts +2 -2
  40. package/dist/models/get-invoice-request.d.ts +2 -2
  41. package/dist/models/get-structure-request.d.ts +2 -2
  42. package/dist/models/index.d.ts +3 -3
  43. package/dist/models/index.js +3 -3
  44. package/dist/models/invoice-input.d.ts +2 -2
  45. package/dist/models/invoice-type-code.d.ts +6 -65
  46. package/dist/models/invoice-type-code.js +6 -65
  47. package/dist/models/recipient.d.ts +1 -1
  48. package/dist/models/scheme-id.d.ts +7 -7
  49. package/dist/models/scheme-id.js +7 -7
  50. package/dist/models/search-structure-request.d.ts +2 -2
  51. package/dist/models/simplified-invoice-data.d.ts +2 -2
  52. package/dist/models/submit-complete-invoice-response.d.ts +1 -1
  53. package/dist/models/submit-invoice-request.d.ts +2 -2
  54. package/dist/models/supplier.d.ts +1 -1
  55. package/dist/models/validate-cdarresponse.d.ts +3 -3
  56. package/dist/models/validation-error-response.d.ts +3 -12
  57. package/dist/src/helpers/client.d.ts +43 -265
  58. package/dist/src/helpers/client.js +199 -823
  59. package/dist/src/helpers/index.d.ts +1 -2
  60. package/dist/src/helpers/index.js +2 -12
  61. package/docs/ChorusProCredentials.md +9 -9
  62. package/docs/ChorusProDestination.md +1 -1
  63. package/docs/FactureElectroniqueModelsInvoiceTypeCode.md +39 -0
  64. package/docs/FactureElectroniqueRestApiSchemasCdarValidationErrorResponse.md +27 -0
  65. package/docs/FactureElectroniqueRestApiSchemasProcessingChorusProCredentials.md +29 -0
  66. package/docs/GetChorusProIdRequest.md +1 -1
  67. package/docs/GetInvoiceRequest.md +1 -1
  68. package/docs/GetStructureRequest.md +1 -1
  69. package/docs/InvoiceInput.md +1 -1
  70. package/docs/InvoiceTypeCode.md +6 -28
  71. package/docs/Recipient.md +1 -1
  72. package/docs/SchemeID.md +4 -4
  73. package/docs/SearchStructureRequest.md +1 -1
  74. package/docs/SimplifiedInvoiceData.md +1 -1
  75. package/docs/SubmitCompleteInvoiceResponse.md +2 -2
  76. package/docs/SubmitInvoiceRequest.md +1 -1
  77. package/docs/Supplier.md +1 -1
  78. package/docs/ValidateCDARResponse.md +2 -2
  79. package/docs/ValidationErrorResponse.md +3 -9
  80. package/models/chorus-pro-credentials.ts +19 -7
  81. package/models/chorus-pro-destination.ts +2 -2
  82. package/models/{facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.ts → facture-electronique-models-invoice-type-code.ts} +67 -18
  83. package/models/{facture-electronique-rest-api-schemas-validation-validation-error-response.ts → facture-electronique-rest-api-schemas-cdar-validation-error-response.ts} +13 -4
  84. package/models/{facture-electronique-rest-api-schemas-ereporting-invoice-type-code.ts → facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.ts} +11 -13
  85. package/models/get-chorus-pro-id-request.ts +2 -2
  86. package/models/get-invoice-request.ts +2 -2
  87. package/models/get-structure-request.ts +2 -2
  88. package/models/index.ts +3 -3
  89. package/models/invoice-input.ts +2 -2
  90. package/models/invoice-type-code.ts +6 -65
  91. package/models/recipient.ts +1 -1
  92. package/models/scheme-id.ts +7 -7
  93. package/models/search-structure-request.ts +2 -2
  94. package/models/simplified-invoice-data.ts +2 -2
  95. package/models/submit-complete-invoice-response.ts +1 -1
  96. package/models/submit-invoice-request.ts +2 -2
  97. package/models/supplier.ts +1 -1
  98. package/models/validate-cdarresponse.ts +3 -3
  99. package/models/validation-error-response.ts +3 -12
  100. package/package.json +1 -1
  101. package/src/helpers/client.ts +211 -834
  102. package/src/helpers/index.ts +1 -3
  103. package/dist/models/facture-electronique-rest-api-schemas-ereporting-invoice-type-code.d.ts +0 -22
  104. package/docs/FactureElectroniqueRestApiSchemasChorusProChorusProCredentials.md +0 -29
  105. package/docs/FactureElectroniqueRestApiSchemasEreportingInvoiceTypeCode.md +0 -17
  106. package/docs/FactureElectroniqueRestApiSchemasValidationValidationErrorResponse.md +0 -21
  107. /package/dist/esm/models/{facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.js → facture-electronique-rest-api-schemas-cdar-validation-error-response.js} +0 -0
  108. /package/dist/esm/models/{facture-electronique-rest-api-schemas-validation-validation-error-response.js → facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.js} +0 -0
  109. /package/dist/models/{facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.js → facture-electronique-rest-api-schemas-cdar-validation-error-response.js} +0 -0
  110. /package/dist/models/{facture-electronique-rest-api-schemas-validation-validation-error-response.js → facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.js} +0 -0
@@ -173,9 +173,9 @@ docs/ErrorSource.md
173
173
  docs/ExtractionInfo.md
174
174
  docs/FacturXInvoice.md
175
175
  docs/FacturXPDFInfo.md
176
- docs/FactureElectroniqueRestApiSchemasChorusProChorusProCredentials.md
177
- docs/FactureElectroniqueRestApiSchemasEreportingInvoiceTypeCode.md
178
- docs/FactureElectroniqueRestApiSchemasValidationValidationErrorResponse.md
176
+ docs/FactureElectroniqueModelsInvoiceTypeCode.md
177
+ docs/FactureElectroniqueRestApiSchemasCdarValidationErrorResponse.md
178
+ docs/FactureElectroniqueRestApiSchemasProcessingChorusProCredentials.md
179
179
  docs/FieldStatus.md
180
180
  docs/FileInfo.md
181
181
  docs/FilesInfo.md
@@ -472,9 +472,9 @@ models/error-source.ts
472
472
  models/extraction-info.ts
473
473
  models/factur-xinvoice.ts
474
474
  models/factur-xpdfinfo.ts
475
- models/facture-electronique-rest-api-schemas-chorus-pro-chorus-pro-credentials.ts
476
- models/facture-electronique-rest-api-schemas-ereporting-invoice-type-code.ts
477
- models/facture-electronique-rest-api-schemas-validation-validation-error-response.ts
475
+ models/facture-electronique-models-invoice-type-code.ts
476
+ models/facture-electronique-rest-api-schemas-cdar-validation-error-response.ts
477
+ models/facture-electronique-rest-api-schemas-processing-chorus-pro-credentials.ts
478
478
  models/field-status.ts
479
479
  models/file-info.ts
480
480
  models/files-info.ts
package/CHANGELOG.md CHANGED
@@ -7,18 +7,15 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [3.0.37] - 2026-01-17
10
+ ## [4.0.0] - 2026-01-19
11
11
 
12
12
  ### Added
13
- - Version initiale du SDK typescript
14
- - Support complet de l'API FactPulse
15
- - Endpoints Factur-X (génération, validation)
16
- - Endpoints AFNOR PDP/PA (Flow Service, Directory Service)
17
- - Endpoints Chorus Pro (recherche entreprise, soumission factures)
18
- - Endpoints Signature électronique (PAdES-B-B, PAdES-B-T, PAdES-B-LT)
19
- - Support des deux modes d'authentification (stored credentials et zero-trust)
20
- - Documentation complète et exemples
21
-
22
-
23
- [Unreleased]: https://github.com/factpulse/sdk-typescript/compare/v3.0.37...HEAD
24
- [3.0.37]: https://github.com/factpulse/sdk-typescript/releases/tag/v3.0.37
13
+ - Gestion automatique des taches asynchrones
14
+ - Gestion automatique du décodage des documents renvoyés en base 64.
15
+
16
+ ### Changed
17
+ - Rework complet du fonctionnement des SDK, fonctionnement totalement générique et transparent
18
+
19
+
20
+ [Unreleased]: https://github.com/factpulse/sdk-typescript/compare/v4.0.0...HEAD
21
+ [4.0.0]: https://github.com/factpulse/sdk-typescript/releases/tag/v4.0.0
package/README.md CHANGED
@@ -8,7 +8,7 @@ Official TypeScript/JavaScript client for the FactPulse API - French electronic
8
8
  - **Chorus Pro**: Integration with the French public invoicing platform
9
9
  - **AFNOR PDP/PA**: Submission of flows compliant with XP Z12-013 standard
10
10
  - **Electronic signature**: PDF signing (PAdES-B-B, PAdES-B-T, PAdES-B-LT)
11
- - **Simplified client**: JWT authentication and polling integrated via `helpers`
11
+ - **Thin HTTP wrapper**: Generic `post()` and `get()` methods with automatic JWT auth and polling
12
12
 
13
13
  ## Installation
14
14
 
@@ -20,8 +20,6 @@ yarn add @factpulse/sdk
20
20
 
21
21
  ## Quick Start
22
22
 
23
- The `helpers` module provides a simplified API with automatic authentication and polling:
24
-
25
23
  ```typescript
26
24
  import { FactPulseClient } from '@factpulse/sdk/helpers';
27
25
  import * as fs from 'fs';
@@ -29,189 +27,178 @@ import * as fs from 'fs';
29
27
  // Create the client
30
28
  const client = new FactPulseClient({
31
29
  email: 'your_email@example.com',
32
- password: 'your_password'
30
+ password: 'your_password',
31
+ clientUid: 'your-client-uuid', // From dashboard: Configuration > Clients
33
32
  });
34
33
 
35
- // Build the invoice using simplified format (auto-calculates totals)
36
- const invoiceData = {
37
- number: 'INV-2025-001',
38
- supplier: {
39
- name: 'My Company SAS',
40
- siret: '12345678901234',
41
- iban: 'FR7630001007941234567890185',
42
- },
43
- recipient: {
44
- name: 'Client SARL',
45
- siret: '98765432109876',
34
+ // Read your source PDF
35
+ const pdfB64 = fs.readFileSync('source_invoice.pdf').toString('base64');
36
+
37
+ // Generate Factur-X and submit to PDP in one call
38
+ const result = await client.post('processing/invoices/submit-complete-async', {
39
+ invoiceData: {
40
+ number: 'INV-2025-001',
41
+ supplier: {
42
+ siret: '12345678901234',
43
+ iban: 'FR7630001007941234567890185',
44
+ routing_address: '12345678901234',
45
+ },
46
+ recipient: {
47
+ siret: '98765432109876',
48
+ routing_address: '98765432109876',
49
+ },
50
+ lines: [
51
+ {
52
+ description: 'Consulting services',
53
+ quantity: 10,
54
+ unitPrice: 100.0,
55
+ vatRate: 20.0,
56
+ },
57
+ ],
46
58
  },
47
- lines: [
48
- {
49
- description: 'Consulting services',
50
- quantity: 10,
51
- unitPrice: 100.0,
52
- vatRate: 20,
53
- }
54
- ],
55
- };
56
-
57
- // Generate the Factur-X PDF
58
- const pdfBytes = await client.generateFacturx(invoiceData, 'source_invoice.pdf');
59
-
60
- fs.writeFileSync('facturx_invoice.pdf', pdfBytes);
61
- ```
62
-
63
- ## Available Helpers
64
-
65
- ### amount(value)
59
+ sourcePdf: pdfB64,
60
+ profile: 'EN16931',
61
+ destination: { type: 'afnor' },
62
+ });
66
63
 
67
- Converts a value to a formatted string for monetary amounts.
64
+ // PDF is in result.content (auto-polled, auto-decoded from base64)
65
+ fs.writeFileSync('facturx_invoice.pdf', result.content);
68
66
 
69
- ```typescript
70
- import { amount } from '@factpulse/sdk/helpers';
71
-
72
- amount(1234.5); // "1234.50"
73
- amount("1234.56"); // "1234.56"
74
- amount(null); // "0.00"
67
+ console.log(`Flow ID: ${result.afnorResult?.flowId}`);
75
68
  ```
76
69
 
77
- ### invoiceTotals(exclTax, vat, inclTax, amountDue, options?)
70
+ ## API Methods
78
71
 
79
- Creates a complete invoice totals object.
72
+ The SDK provides two generic methods that map directly to API endpoints:
80
73
 
81
74
  ```typescript
82
- import { invoiceTotals } from '@factpulse/sdk/helpers';
75
+ // POST /api/v1/{path}
76
+ const result = await client.post('path/to/endpoint', { key1: value1, key2: value2 });
83
77
 
84
- const totals = invoiceTotals(1000.00, 200.00, 1200.00, 1200.00, {
85
- globalAllowanceAmount: 50.00, // Optional
86
- globalAllowanceReason: 'Loyalty', // Optional
87
- prepayment: 100.00, // Optional
88
- });
78
+ // GET /api/v1/{path}
79
+ const result = await client.get('path/to/endpoint', { param1: value1 });
89
80
  ```
90
81
 
91
- ### invoiceLine(lineNumber, itemName, quantity, unitNetPrice, lineNetAmount, options?)
82
+ ### Common Endpoints
92
83
 
93
- Creates an invoice line.
84
+ | Endpoint | Method | Description |
85
+ |----------|--------|-------------|
86
+ | `processing/invoices/submit-complete-async` | POST | Generate Factur-X + submit to PDP |
87
+ | `processing/generate-invoice` | POST | Generate Factur-X XML or PDF |
88
+ | `processing/validate-xml` | POST | Validate Factur-X XML |
89
+ | `processing/validate-facturx-pdf` | POST | Validate Factur-X PDF |
90
+ | `processing/sign-pdf` | POST | Sign PDF with certificate |
91
+ | `afnor/flow/v1/flows` | POST | Submit flow to AFNOR PDP |
92
+ | `afnor/incoming-flows/{flow_id}` | GET | Get incoming invoice |
93
+ | `chorus-pro/factures/soumettre` | POST | Submit to Chorus Pro |
94
94
 
95
- ```typescript
96
- import { invoiceLine } from '@factpulse/sdk/helpers';
97
-
98
- const line = invoiceLine(
99
- 1,
100
- 'Consulting services',
101
- 5,
102
- 200.00,
103
- 1000.00,
104
- {
105
- vatRate: 'TVA20', // Or manualVatRate: '20.00'
106
- vatCategory: 'S', // S, Z, E, AE, K
107
- unit: 'HOUR', // LUMP_SUM, PIECE, HOUR, DAY...
108
- reference: 'REF-001', // Optional
109
- }
110
- );
111
- ```
95
+ ## Webhooks
112
96
 
113
- ### vatLine(taxableAmount, vatAmount, options?)
114
-
115
- Creates a VAT breakdown line.
97
+ Instead of polling, you can receive results via webhook by adding `callbackUrl`:
116
98
 
117
99
  ```typescript
118
- import { vatLine } from '@factpulse/sdk/helpers';
119
-
120
- const vat = vatLine(1000.00, 200.00, {
121
- rate: 'TVA20', // Or manualRate: '20.00'
122
- category: 'S', // S, Z, E, AE, K
100
+ // Submit with webhook - returns immediately
101
+ const result = await client.post('processing/invoices/submit-complete-async', {
102
+ invoiceData,
103
+ sourcePdf: pdfB64,
104
+ destination: { type: 'afnor' },
105
+ callbackUrl: 'https://your-server.com/webhook/factpulse',
106
+ webhookMode: 'INLINE', // or 'DOWNLOAD_URL'
123
107
  });
124
- ```
125
108
 
126
- ### postalAddress(line1, postalCode, city, options?)
109
+ const taskId = result.taskId;
110
+ // Result will be POSTed to your webhook URL
111
+ ```
127
112
 
128
- Creates a structured postal address.
113
+ ### Webhook Receiver Example (Express.js)
129
114
 
130
115
  ```typescript
131
- import { postalAddress } from '@factpulse/sdk/helpers';
132
-
133
- const address = postalAddress('123 Republic Street', '75001', 'Paris', {
134
- country: 'FR', // Default: 'FR'
135
- line2: 'Building A' // Optional
136
- });
137
- ```
138
-
139
- ### electronicAddress(identifier, schemeId?)
116
+ import express from 'express';
117
+ import crypto from 'crypto';
118
+
119
+ const app = express();
120
+ app.use(express.json({ verify: (req, res, buf) => (req.rawBody = buf) }));
121
+
122
+ const WEBHOOK_SECRET = 'your-shared-secret';
123
+
124
+ function verifySignature(payload: Buffer, signature: string): boolean {
125
+ if (!signature.startsWith('sha256=')) return false;
126
+ const expected = crypto
127
+ .createHmac('sha256', WEBHOOK_SECRET)
128
+ .update(payload)
129
+ .digest('hex');
130
+ return crypto.timingSafeEqual(
131
+ Buffer.from(signature.slice(7)),
132
+ Buffer.from(expected)
133
+ );
134
+ }
135
+
136
+ app.post('/webhook/factpulse', (req, res) => {
137
+ const signature = req.headers['x-webhook-signature'] as string || '';
138
+ if (!verifySignature(req.rawBody, signature)) {
139
+ return res.status(401).json({ error: 'Invalid signature' });
140
+ }
140
141
 
141
- Creates an electronic address (digital identifier).
142
+ const event = req.body;
143
+ const eventType = event.event_type;
144
+ const data = event.data;
142
145
 
143
- ```typescript
144
- import { electronicAddress } from '@factpulse/sdk/helpers';
146
+ if (eventType === 'submission.completed') {
147
+ console.log(`Invoice submitted: ${data.afnorResult?.flowId}`);
148
+ } else if (eventType === 'submission.failed') {
149
+ console.log(`Submission failed: ${data.error}`);
150
+ }
145
151
 
146
- // SIRET (schemeId="0225")
147
- const address = electronicAddress('12345678901234', '0225');
152
+ res.json({ status: 'received' });
153
+ });
148
154
 
149
- // SIREN (schemeId="0009", default)
150
- const address = electronicAddress('123456789');
155
+ app.listen(3000);
151
156
  ```
152
157
 
153
- ### supplier(name, siret, addressLine1, postalCode, city, options?)
158
+ ### Webhook Event Types
154
159
 
155
- Creates a complete supplier with automatic SIREN and intra-EU VAT calculation.
160
+ | Event | Description |
161
+ |-------|-------------|
162
+ | `generation.completed` | Factur-X generated successfully |
163
+ | `generation.failed` | Generation failed |
164
+ | `validation.completed` | Validation passed |
165
+ | `validation.failed` | Validation failed |
166
+ | `signature.completed` | PDF signed |
167
+ | `submission.completed` | Submitted to PDP/Chorus |
168
+ | `submission.failed` | Submission failed |
156
169
 
157
- ```typescript
158
- import { supplier } from '@factpulse/sdk/helpers';
159
-
160
- const s = supplier(
161
- 'My Company SAS',
162
- '12345678901234',
163
- '123 Example Street',
164
- '75001',
165
- 'Paris',
166
- { iban: 'FR7630006000011234567890189' }
167
- );
168
- // SIREN and intra-EU VAT number calculated automatically
169
- ```
170
-
171
- ### recipient(name, siret, addressLine1, postalCode, city, options?)
170
+ ## Zero-Storage Mode
172
171
 
173
- Creates a recipient (customer) with automatic SIREN calculation.
172
+ Pass PDP credentials directly in the request (no server-side storage):
174
173
 
175
174
  ```typescript
176
- import { recipient } from '@factpulse/sdk/helpers';
177
-
178
- const r = recipient(
179
- 'Client SARL',
180
- '98765432109876',
181
- '456 Test Avenue',
182
- '69001',
183
- 'Lyon'
184
- );
175
+ const result = await client.post('processing/invoices/submit-complete-async', {
176
+ invoiceData,
177
+ sourcePdf: pdfB64,
178
+ destination: {
179
+ type: 'afnor',
180
+ flowServiceUrl: 'https://api.pdp.example.com/flow/v1',
181
+ tokenUrl: 'https://auth.pdp.example.com/oauth/token',
182
+ clientId: 'your_pdp_client_id',
183
+ clientSecret: 'your_pdp_client_secret',
184
+ },
185
+ });
185
186
  ```
186
187
 
187
- ## Zero-Trust Mode (Chorus Pro / AFNOR)
188
-
189
- To pass your own credentials without server-side storage:
188
+ ## Error Handling
190
189
 
191
190
  ```typescript
192
- import {
193
- FactPulseClient,
194
- ChorusProCredentials,
195
- AFNORCredentials,
196
- } from '@factpulse/sdk/helpers';
197
-
198
- const client = new FactPulseClient({
199
- email: 'your_email@example.com',
200
- password: 'your_password',
201
- chorusCredentials: {
202
- pisteClientId: 'your_client_id',
203
- pisteClientSecret: 'your_client_secret',
204
- chorusProLogin: 'your_login',
205
- chorusProPassword: 'your_password',
206
- sandbox: true,
207
- },
208
- afnorCredentials: {
209
- flowServiceUrl: 'https://api.pdp.fr/flow/v1',
210
- tokenUrl: 'https://auth.pdp.fr/oauth/token',
211
- clientId: 'your_client_id',
212
- clientSecret: 'your_client_secret',
213
- },
214
- });
191
+ import { FactPulseClient, FactPulseError } from '@factpulse/sdk/helpers';
192
+
193
+ try {
194
+ const result = await client.post('processing/validate-xml', { xmlContent });
195
+ } catch (e) {
196
+ if (e instanceof FactPulseError) {
197
+ console.log(`Error: ${e.message}`);
198
+ console.log(`Status code: ${e.statusCode}`);
199
+ console.log(`Details: ${e.details}`); // Validation errors list
200
+ }
201
+ }
215
202
  ```
216
203
 
217
204
  ## Resources
@@ -28,8 +28,6 @@ import type { APIProfile } from '../models';
28
28
  // @ts-ignore
29
29
  import type { AsyncTaskStatus } from '../models';
30
30
  // @ts-ignore
31
- import type { FactureElectroniqueRestApiSchemasValidationValidationErrorResponse } from '../models';
32
- // @ts-ignore
33
31
  import type { GenerateCertificateRequest } from '../models';
34
32
  // @ts-ignore
35
33
  import type { GenerateCertificateResponse } from '../models';
@@ -46,6 +44,8 @@ import type { SubmitCompleteInvoiceResponse } from '../models';
46
44
  // @ts-ignore
47
45
  import type { TaskResponse } from '../models';
48
46
  // @ts-ignore
47
+ import type { ValidationErrorResponse } from '../models';
48
+ // @ts-ignore
49
49
  import type { ValidationSuccessResponse } from '../models';
50
50
  /**
51
51
  * InvoiceProcessingApi - axios parameter creator
@@ -10,15 +10,27 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  /**
13
- * Optional Chorus Pro credentials. **MODE 1 - JWT retrieval (recommended):** Do not provide this `credentials` field in the payload. Credentials will be automatically retrieved via client_uid from JWT (0-trust). **MODE 2 - Credentials in payload:** Provide all required fields below. Useful for tests or third-party integrations.
13
+ * Chorus Pro credentials for Zero-Trust mode. **Zero-Trust Mode**: Credentials are passed in each request and are NEVER stored. **Security**: - Credentials are never persisted in the database - They are used only for the duration of the request - Secure transmission via HTTPS **Use cases**: - High-security environments (banks, administrations) - Strict GDPR compliance - Tests with temporary credentials - Users who don\'t want to store their credentials
14
14
  */
15
15
  export interface ChorusProCredentials {
16
- 'pisteClientId'?: string | null;
17
- 'pisteClientSecret'?: string | null;
18
- 'chorusLogin'?: string | null;
19
- 'chorusPassword'?: string | null;
20
16
  /**
21
- * [MODE 2] Use sandbox mode (default: True)
17
+ * PISTE Client ID (government API portal)
22
18
  */
23
- 'sandboxMode'?: boolean;
19
+ 'pisteClientId': string;
20
+ /**
21
+ * PISTE Client Secret
22
+ */
23
+ 'pisteClientSecret': string;
24
+ /**
25
+ * Chorus Pro login
26
+ */
27
+ 'chorusProLogin': string;
28
+ /**
29
+ * Chorus Pro password
30
+ */
31
+ 'chorusProPassword': string;
32
+ /**
33
+ * Use sandbox environment (true) or production (false)
34
+ */
35
+ 'sandbox'?: boolean;
24
36
  }
@@ -9,13 +9,13 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
- import type { ChorusProCredentials } from './chorus-pro-credentials';
12
+ import type { FactureElectroniqueRestApiSchemasProcessingChorusProCredentials } from './facture-electronique-rest-api-schemas-processing-chorus-pro-credentials';
13
13
  /**
14
14
  * Specific configuration for Chorus Pro destination.
15
15
  */
16
16
  export interface ChorusProDestination {
17
17
  'type'?: ChorusProDestinationTypeEnum;
18
- 'credentials'?: ChorusProCredentials | null;
18
+ 'credentials'?: FactureElectroniqueRestApiSchemasProcessingChorusProCredentials | null;
19
19
  }
20
20
  export declare const ChorusProDestinationTypeEnum: {
21
21
  readonly ChorusPro: "chorus_pro";
@@ -10,27 +10,72 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  /**
13
- * Chorus Pro credentials for Zero-Trust mode. **Zero-Trust Mode**: Credentials are passed in each request and are NEVER stored. **Security**: - Credentials are never persisted in the database - They are used only for the duration of the request - Secure transmission via HTTPS **Use cases**: - High-security environments (banks, administrations) - Strict GDPR compliance - Tests with temporary credentials - Users who don\'t want to store their credentials
13
+ * Document type according to BR-FR-04 (UNTDID 1001 codes). | Code | Name | Description | |------|------|-------------| | 380 | INVOICE | Commercial invoice | | 389 | SELF_BILLED_INVOICE | Self-billed invoice | | 393 | FACTORED_INVOICE | Factored invoice | | 501 | SELF_BILLED_FACTORED_INVOICE | Self-billed factored invoice | | 386 | PREPAYMENT_INVOICE | Prepayment invoice | | 500 | SELF_BILLED_PREPAYMENT_INVOICE | Self-billed prepayment invoice | | 384 | CORRECTIVE_INVOICE | Corrective invoice | | 471 | SELF_BILLED_CORRECTIVE_INVOICE | Self-billed corrective invoice | | 472 | FACTORED_CORRECTIVE_INVOICE | Factored corrective invoice | | 473 | SELF_BILLED_FACTORED_CORRECTIVE_INVOICE | Self-billed factored corrective invoice | | 381 | CREDIT_NOTE | Credit note | | 261 | SELF_BILLED_CREDIT_NOTE | Self-billed credit note | | 262 | GLOBAL_ALLOWANCE_CREDIT_NOTE | Credit note for global allowance | | 396 | FACTORED_CREDIT_NOTE | Factored credit note | | 502 | SELF_BILLED_FACTORED_CREDIT_NOTE | Self-billed factored credit note | | 503 | PREPAYMENT_CREDIT_NOTE | Credit note for prepayment invoice |
14
14
  */
15
- export interface FactureElectroniqueRestApiSchemasChorusProChorusProCredentials {
15
+ export declare const FactureElectroniqueModelsInvoiceTypeCode: {
16
16
  /**
17
- * PISTE Client ID (government API portal)
18
- */
19
- 'pisteClientId': string;
17
+ * Commercial Invoice
18
+ */
19
+ readonly INVOICE: "380";
20
20
  /**
21
- * PISTE Client Secret
22
- */
23
- 'pisteClientSecret': string;
21
+ * Self-billed Invoice
22
+ */
23
+ readonly SELF_BILLED_INVOICE: "389";
24
24
  /**
25
- * Chorus Pro login
26
- */
27
- 'chorusProLogin': string;
25
+ * Factored Invoice
26
+ */
27
+ readonly FACTORED_INVOICE: "393";
28
28
  /**
29
- * Chorus Pro password
30
- */
31
- 'chorusProPassword': string;
29
+ * Self-billed Factored Invoice
30
+ */
31
+ readonly SELF_BILLED_FACTORED_INVOICE: "501";
32
32
  /**
33
- * Use sandbox environment (true) or production (false)
34
- */
35
- 'sandbox'?: boolean;
36
- }
33
+ * Prepayment Invoice
34
+ */
35
+ readonly PREPAYMENT_INVOICE: "386";
36
+ /**
37
+ * Self-billed Prepayment Invoice
38
+ */
39
+ readonly SELF_BILLED_PREPAYMENT_INVOICE: "500";
40
+ /**
41
+ * Corrective Invoice
42
+ */
43
+ readonly CORRECTIVE_INVOICE: "384";
44
+ /**
45
+ * Self-billed Corrective Invoice
46
+ */
47
+ readonly SELF_BILLED_CORRECTIVE_INVOICE: "471";
48
+ /**
49
+ * Factored Corrective Invoice
50
+ */
51
+ readonly FACTORED_CORRECTIVE_INVOICE: "472";
52
+ /**
53
+ * Self-billed Factored Corrective Invoice
54
+ */
55
+ readonly SELF_BILLED_FACTORED_CORRECTIVE_INVOICE: "473";
56
+ /**
57
+ * Credit Note
58
+ */
59
+ readonly CREDIT_NOTE: "381";
60
+ /**
61
+ * Self-billed Credit Note
62
+ */
63
+ readonly SELF_BILLED_CREDIT_NOTE: "261";
64
+ /**
65
+ * Global Allowance Credit Note
66
+ */
67
+ readonly GLOBAL_ALLOWANCE_CREDIT_NOTE: "262";
68
+ /**
69
+ * Factored Credit Note
70
+ */
71
+ readonly FACTORED_CREDIT_NOTE: "396";
72
+ /**
73
+ * Self-billed Factored Credit Note
74
+ */
75
+ readonly SELF_BILLED_FACTORED_CREDIT_NOTE: "502";
76
+ /**
77
+ * Prepayment Credit Note
78
+ */
79
+ readonly PREPAYMENT_CREDIT_NOTE: "503";
80
+ };
81
+ export type FactureElectroniqueModelsInvoiceTypeCode = typeof FactureElectroniqueModelsInvoiceTypeCode[keyof typeof FactureElectroniqueModelsInvoiceTypeCode];
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* tslint:disable */
3
2
  /* eslint-disable */
4
3
  /**
@@ -12,15 +11,72 @@
12
11
  * https://openapi-generator.tech
13
12
  * Do not edit the class manually.
14
13
  */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.FactureElectroniqueRestApiSchemasEreportingInvoiceTypeCode = void 0;
17
14
  /**
18
- * Invoice type codes (UNTDID 1001).
15
+ * Document type according to BR-FR-04 (UNTDID 1001 codes). | Code | Name | Description | |------|------|-------------| | 380 | INVOICE | Commercial invoice | | 389 | SELF_BILLED_INVOICE | Self-billed invoice | | 393 | FACTORED_INVOICE | Factored invoice | | 501 | SELF_BILLED_FACTORED_INVOICE | Self-billed factored invoice | | 386 | PREPAYMENT_INVOICE | Prepayment invoice | | 500 | SELF_BILLED_PREPAYMENT_INVOICE | Self-billed prepayment invoice | | 384 | CORRECTIVE_INVOICE | Corrective invoice | | 471 | SELF_BILLED_CORRECTIVE_INVOICE | Self-billed corrective invoice | | 472 | FACTORED_CORRECTIVE_INVOICE | Factored corrective invoice | | 473 | SELF_BILLED_FACTORED_CORRECTIVE_INVOICE | Self-billed factored corrective invoice | | 381 | CREDIT_NOTE | Credit note | | 261 | SELF_BILLED_CREDIT_NOTE | Self-billed credit note | | 262 | GLOBAL_ALLOWANCE_CREDIT_NOTE | Credit note for global allowance | | 396 | FACTORED_CREDIT_NOTE | Factored credit note | | 502 | SELF_BILLED_FACTORED_CREDIT_NOTE | Self-billed factored credit note | | 503 | PREPAYMENT_CREDIT_NOTE | Credit note for prepayment invoice |
19
16
  */
20
- exports.FactureElectroniqueRestApiSchemasEreportingInvoiceTypeCode = {
21
- _380: '380',
22
- _381: '381',
23
- _384: '384',
24
- _389: '389',
25
- _386: '386'
17
+ export const FactureElectroniqueModelsInvoiceTypeCode = {
18
+ /**
19
+ * Commercial Invoice
20
+ */
21
+ INVOICE: '380',
22
+ /**
23
+ * Self-billed Invoice
24
+ */
25
+ SELF_BILLED_INVOICE: '389',
26
+ /**
27
+ * Factored Invoice
28
+ */
29
+ FACTORED_INVOICE: '393',
30
+ /**
31
+ * Self-billed Factored Invoice
32
+ */
33
+ SELF_BILLED_FACTORED_INVOICE: '501',
34
+ /**
35
+ * Prepayment Invoice
36
+ */
37
+ PREPAYMENT_INVOICE: '386',
38
+ /**
39
+ * Self-billed Prepayment Invoice
40
+ */
41
+ SELF_BILLED_PREPAYMENT_INVOICE: '500',
42
+ /**
43
+ * Corrective Invoice
44
+ */
45
+ CORRECTIVE_INVOICE: '384',
46
+ /**
47
+ * Self-billed Corrective Invoice
48
+ */
49
+ SELF_BILLED_CORRECTIVE_INVOICE: '471',
50
+ /**
51
+ * Factored Corrective Invoice
52
+ */
53
+ FACTORED_CORRECTIVE_INVOICE: '472',
54
+ /**
55
+ * Self-billed Factored Corrective Invoice
56
+ */
57
+ SELF_BILLED_FACTORED_CORRECTIVE_INVOICE: '473',
58
+ /**
59
+ * Credit Note
60
+ */
61
+ CREDIT_NOTE: '381',
62
+ /**
63
+ * Self-billed Credit Note
64
+ */
65
+ SELF_BILLED_CREDIT_NOTE: '261',
66
+ /**
67
+ * Global Allowance Credit Note
68
+ */
69
+ GLOBAL_ALLOWANCE_CREDIT_NOTE: '262',
70
+ /**
71
+ * Factored Credit Note
72
+ */
73
+ FACTORED_CREDIT_NOTE: '396',
74
+ /**
75
+ * Self-billed Factored Credit Note
76
+ */
77
+ SELF_BILLED_FACTORED_CREDIT_NOTE: '502',
78
+ /**
79
+ * Prepayment Credit Note
80
+ */
81
+ PREPAYMENT_CREDIT_NOTE: '503'
26
82
  };