Loading...
Loading...
Anders & A-Cube S.r.l. / 15 luglio 2025 • 4 min read
@a-cube-io/ereceipts-js-sdk è un SDK TypeScript production-ready per la gestione di ricevute elettroniche, che fornisce supporto multi-piattaforma senza soluzione di continuità su Browser, Node.js e ambienti React Native. Costruito con strumenti moderni e rigida type safety, offre affidabilità di livello enterprise con un'esperienza sviluppatore intuitiva.
Vedi su GitHub | Pacchetto NPM
L'SDK implementa un'architettura a livelli con ottimizzazioni specifiche per piattaforma:
┌─────────────────────────────────────────────────┐
│ Livello Applicazione (React/RN/Node) │
│ Hook Personalizzati & Utility │
└────────────────┬────────────────────────────────┘
│
┌────────────────▼────────────────────────────────┐
│ Livello SDK Core (TypeScript) │
│ Gestione Ricevute • Validazione • Caching │
└──────┬──────────────────────────────┬──────────┘
│ │
┌──────▼─────────┐ ┌─────────▼──────────┐
│ Livello │ │ Livello Native │
│ Browser │ │ - AsyncStorage │
│ - IndexedDB │ │ - SQLite │
│ - LocalStorage │ │ - Moduli Expo │
│ - Fetch API │ │ │
└────────────────┘ └────────────────────┘
L'SDK fornisce una gestione completa del ciclo di vita delle ricevute:
import { EReceiptsSDK } from '@a-cube-io/ereceipts-js-sdk'
// Inizializza SDK
const sdk = new EReceiptsSDK({
apiUrl: 'https://api.acubeapi.com',
authToken: 'user-jwt-token',
enableCache: true,
cacheTTL: 3600000 // 1 ora
})
// Recupera ricevute con caching automatico
const receipts = await sdk.getReceipts({
startDate: '2025-01-01',
endDate: '2025-12-31',
status: 'validated'
})
// Ottieni singola ricevuta (dalla cache se disponibile)
const receipt = await sdk.getReceipt('receipt-id-123')
// Scarica PDF della ricevuta
const pdfBlob = await sdk.downloadReceiptPDF('receipt-id-123')import { useReceipts, useReceipt } from '@a-cube-io/ereceipts-js-sdk/react'
function ReceiptsList() {
const { receipts, loading, error, refresh } = useReceipts({
startDate: '2025-01-01',
endDate: '2025-12-31'
})
if (loading) return <LoadingSpinner />
if (error) return <ErrorMessage error={error} />
return (
<div>
{receipts.map(receipt => (
Tutte le risposte API e le strutture dati validate at runtime:
import { z } from 'zod'
// Schema ricevuta
const ReceiptSchema = z.object({
id: z.string().uuid(),
merchantName: z.string().min(1),
amount: z.number().positive(),
currency: z.enum(['EUR', 'USD', 'GBP']),
date: z.string().datetime(),
status: z.enum(['pending', 'validated', 'rejected'
Strategia di caching multi-livello ottimizzata per ogni piattaforma:
Integrazione seamless con @a-cube-io/expo-mutual-tls per chiamate API sicure:
import ExpoMutualTls from '@a-cube-io/expo-mutual-tls'
import { EReceiptsSDK } from '@a-cube-io/ereceipts-js-sdk'
// Configura mTLS
await ExpoMutualTls.configureP12('ereceipts-app', true)
await ExpoMutualTls.storeP12(certificateData, password)
// SDK usa automaticamente mTLS per chiamate API
const sdk = new EReceiptsSDK({
apiUrl: 'https://api.acubeapi.com',
useMTLS: true,
authToken: 'user-jwt-token'
})
// Tutte le chiamate API usano autenticazione certificato client
const receipts = await sdk.getReceipts() // mTLS secured| Operazione | Browser | React Native | Node.js |
|---|---|---|---|
| Inizializzazione SDK | 50ms | 80ms | 30ms |
| Lettura Cache (100 ricevute) | 20ms | 40ms | 15ms |
| Scrittura Cache (100 ricevute) | 100ms | 180ms | 50ms |
| Fetch API (100 ricevute) | 800ms | 900ms | 600ms |
| Validazione Ricevuta (Zod) | 5ms | 7ms |
import React, { useEffect } from 'react'
import { View, FlatList, Text, Button } from 'react-native'
import { useReceipts } from '@a-cube-io/ereceipts-js-sdk/react'
import ExpoMutualTls from '@a-cube-io/expo-mutual-tls'
export default function ReceiptsScreen() {
const { receipts, loading, error, refresh, downloadPDF } = useReceipts({
startDate: '2025-01-01',
endDate: '2025-12-31'
})
useEffect(() => {
const setupAuth =
✅ Cosa Ha Funzionato Bene:
📚 Punti Chiave:
@a-cube-io/ereceipts-js-sdk dimostra lo sviluppo di SDK multi-piattaforma production-ready con focus su type safety, performance ed esperienza sviluppatore. Il progetto bilancia con successo:
Repository: Repository interno A-Cube Pacchetto: @a-cube-io/ereceipts-js-sdk Licenza: MIT
| 3ms |