npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@factpulse/sdk

v2.0.12

Published

OpenAPI client for @factpulse/sdk

Downloads

1,364

Readme

FactPulse SDK TypeScript

Client TypeScript/JavaScript officiel pour l'API FactPulse - Facturation électronique française.

🎯 Fonctionnalités

  • Factur-X : Génération et validation de factures électroniques (profils MINIMUM, BASIC, EN16931, EXTENDED)
  • Chorus Pro : Intégration avec la plateforme de facturation publique française
  • AFNOR PDP/PA : Soumission de flux conformes à la norme XP Z12-013
  • Signature électronique : Signature PDF (PAdES-B-B, PAdES-B-T, PAdES-B-LT)
  • Client simplifié : Authentification JWT et polling intégrés via helpers
  • TypeScript : Support complet avec types générés automatiquement

🚀 Installation

npm install @factpulse/sdk
# ou
yarn add @factpulse/sdk

📖 Démarrage rapide

Méthode recommandée : Client simplifié avec helpers

Le module helpers offre une API simplifiée avec authentification et polling automatiques :

import { FactPulseClient } from '@factpulse/sdk/helpers';
import * as fs from 'fs';

// Créer le client (authentification automatique)
const client = new FactPulseClient({
  email: '[email protected]',
  password: 'votre_mot_de_passe'
});

// Données de la facture
const factureData = {
  numero_facture: 'FAC-2025-001',
  date_facture: '2025-01-15',
  fournisseur: {
    nom: 'Mon Entreprise SAS',
    siret: '12345678901234',
    adresse_postale: {
      ligne_un: '123 Rue Example',
      code_postal: '75001',
      nom_ville: 'Paris',
      pays_code_iso: 'FR'
    }
  },
  destinataire: {
    nom: 'Client SARL',
    siret: '98765432109876',
    adresse_postale: {
      ligne_un: '456 Avenue Test',
      code_postal: '69001',
      nom_ville: 'Lyon',
      pays_code_iso: 'FR'
    }
  },
  montant_total: {
    montant_ht_total: '1000.00',
    montant_tva: '200.00',
    montant_ttc_total: '1200.00',
    montant_a_payer: '1200.00'
  },
  lignes_de_poste: [{
    numero: 1,
    denomination: 'Prestation de conseil',
    quantite: '10.00',
    unite: 'PIECE',
    montant_unitaire_ht: '100.00'
  }]
};

// Lire le PDF source
const pdfSource = fs.readFileSync('facture_source.pdf');

// Générer le PDF Factur-X (polling automatique)
const pdfBytes = await client.genererFacturx(
  factureData,
  pdfSource,
  'EN16931',  // profil
  'pdf',      // format
  true        // sync (attend le résultat)
);

// Sauvegarder
fs.writeFileSync('facture_facturx.pdf', pdfBytes);

Méthode alternative : SDK brut

Pour un contrôle total, utilisez le SDK généré directement :

import { Configuration, TraitementFactureApi } from '@factpulse/sdk';
import axios from 'axios';

// 1. Obtenir le token JWT
const tokenResponse = await axios.post('https://factpulse.fr/api/token/', {
  username: '[email protected]',
  password: 'votre_mot_de_passe'
});
const token = tokenResponse.data.access;

// 2. Configurer le client
const config = new Configuration({
  basePath: 'https://factpulse.fr/api/facturation',
  accessToken: token
});

// 3. Appeler l'API
const api = new TraitementFactureApi(config);
const response = await api.genererFactureApiV1TraitementGenererFacturePost(
  JSON.stringify(factureData),
  'EN16931',
  'pdf',
  new Blob([pdfSource])
);

// 4. Polling manuel pour récupérer le résultat
const taskId = response.data.id_tache;
// ... (implémenter le polling)

🔧 Avantages des helpers

| Fonctionnalité | SDK brut | helpers | |----------------|----------|---------| | Authentification | Manuelle | Automatique | | Refresh token | Manuel | Automatique | | Polling tâches async | Manuel | Automatique (backoff) | | Retry sur 401 | Manuel | Automatique | | Types TypeScript | ✓ | ✓ |

🔑 Options d'authentification

Client UID (multi-clients)

Si vous gérez plusieurs clients :

const client = new FactPulseClient({
  email: '[email protected]',
  password: 'votre_mot_de_passe',
  clientUid: 'identifiant_client'  // UID du client cible
});

Configuration avancée

const client = new FactPulseClient({
  email: '[email protected]',
  password: 'votre_mot_de_passe',
  apiUrl: 'https://factpulse.fr',  // URL personnalisée
  pollingInterval: 2000,  // Intervalle de polling initial (ms)
  pollingTimeout: 120000,  // Timeout de polling (ms)
  maxRetries: 2  // Tentatives en cas de 401
});

💡 Formats de montants acceptés

L'API accepte plusieurs formats pour les montants :

// String (recommandé pour la précision)
const montant = "1234.56";

// Number
const montant = 1234.56;

// Integer
const montant = 1234;

// Helper de formatage
const montantFormate = FactPulseClient.formatMontant(1234.5);  // "1234.50"

📚 Ressources

  • Documentation API : https://factpulse.fr/api/facturation/documentation
  • Code source : https://github.com/factpulse/sdk-typescript
  • Issues : https://github.com/factpulse/sdk-typescript/issues
  • Support : [email protected]

📄 Licence

MIT License - Copyright (c) 2025 FactPulse