@a-cube-io/ereceipts-js-sdk 1.1.0 → 2.0.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.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # ACube eReceipts JS SDK
2
+
3
+ SDK ufficiale per l'integrazione con la piattaforma ACube eReceipt in applicazioni Expo/React Native.
4
+
5
+ ## Caratteristiche
6
+
7
+ - Gestione completa scontrini elettronici (creazione, annullo, reso)
8
+ - Autenticazione JWT e mTLS
9
+ - Supporto offline con sincronizzazione automatica
10
+ - Gestione stati app (NORMAL, WARNING, BLOCKED, OFFLINE)
11
+ - TypeScript first con tipizzazione completa
12
+ - Ottimizzato per Expo e React Native
13
+
14
+ ## Quick Start
15
+
16
+ ### Installazione
17
+
18
+ ```bash
19
+ # Con bun (consigliato)
20
+ bun add @a-cube-io/ereceipts-js-sdk
21
+
22
+ # Con npm
23
+ npm install @a-cube-io/ereceipts-js-sdk
24
+
25
+ # Con yarn
26
+ yarn add @a-cube-io/ereceipts-js-sdk
27
+ ```
28
+
29
+ ### Dipendenze Expo
30
+
31
+ ```bash
32
+ expo install expo-secure-store @react-native-async-storage/async-storage
33
+ ```
34
+
35
+ ### Utilizzo con SDKManager (Raccomandato)
36
+
37
+ ```typescript
38
+ import { SDKManager } from '@a-cube-io/ereceipts-js-sdk';
39
+
40
+ // 1. Configura (una volta all'avvio)
41
+ SDKManager.configure({
42
+ environment: 'sandbox',
43
+ notificationPollIntervalMs: 30000,
44
+ });
45
+
46
+ // 2. Inizializza
47
+ const manager = SDKManager.getInstance();
48
+ await manager.initialize();
49
+
50
+ // 3. Osserva lo stato dell'app
51
+ manager.appState$.subscribe(state => {
52
+ console.log('Mode:', state.mode); // NORMAL, WARNING, BLOCKED, OFFLINE
53
+ });
54
+
55
+ // 4. Usa i servizi
56
+ const services = manager.getServices();
57
+ await services.login({ email: 'user@example.com', password: 'password' });
58
+ const receipts = await services.receipts.list();
59
+
60
+ // 5. Cleanup
61
+ SDKManager.destroy();
62
+ ```
63
+
64
+ ### Utilizzo Base (Alternativo)
65
+
66
+ ```typescript
67
+ import { createACubeSDK } from '@a-cube-io/ereceipts-js-sdk';
68
+
69
+ // Inizializza SDK
70
+ const sdk = await createACubeSDK({
71
+ environment: 'sandbox',
72
+ });
73
+
74
+ // Login
75
+ const user = await sdk.login({
76
+ email: 'user@example.com',
77
+ password: 'password',
78
+ });
79
+
80
+ // Crea scontrino
81
+ const receipt = await sdk.receipts.create({
82
+ items: [
83
+ {
84
+ description: 'Prodotto esempio',
85
+ quantity: '1',
86
+ unitPrice: '10.00',
87
+ vatRateCode: '22',
88
+ },
89
+ ],
90
+ });
91
+
92
+ console.log('Scontrino creato:', receipt.documentNumber);
93
+ ```
94
+
95
+ ## Documentazione
96
+
97
+ ### Getting Started
98
+ - [Installazione](./getting-started/installation.md)
99
+ - [Configurazione](./getting-started/configuration.md)
100
+ - [Setup Expo](./getting-started/expo-setup.md)
101
+ - [Autenticazione](./authentication/overview.md)
102
+
103
+ ### API Reference
104
+ - [SDKManager](./api-reference/sdk-manager.md) - API semplificata per produzione
105
+ - [ACubeSDK](./api-reference/sdk-instance.md) - API completa
106
+ - [AppStateService](./api-reference/app-state.md) - Gestione stati app
107
+ - [Notifications](./api-reference/notifications.md) - Sistema notifiche
108
+ - [Telemetry](./api-reference/telemetry.md) - Telemetria PEM
109
+
110
+ ### Esempi
111
+ - [Esempi Base](./examples/basic-usage.md)
112
+ - [Notifiche e Telemetria](./examples/notifications-telemetry.md) - Esempio Expo completo
113
+
114
+ ### Troubleshooting
115
+ - [Problemi Comuni](./troubleshooting/common-issues.md)
116
+
117
+ ## Ambienti Disponibili
118
+
119
+ | Ambiente | URL API | Descrizione |
120
+ |----------|---------|-------------|
121
+ | `sandbox` | `https://ereceipts-it-sandbox.acubeapi.com` | Test e sviluppo |
122
+ | `development` | `https://ereceipts-it.dev.acubeapi.com` | Sviluppo interno |
123
+ | `production` | `https://ereceipts-it.acubeapi.com` | Produzione |
124
+
125
+ ## Requisiti
126
+
127
+ - Expo SDK 50+
128
+ - React Native 0.73+
129
+ - TypeScript 5.0+
130
+ - iOS 13+ / Android API 24+
131
+
132
+ ## Repository API
133
+
134
+ L'SDK espone i seguenti repository tramite `SDKManager.getServices()` o `sdk`:
135
+
136
+ | Repository | Descrizione |
137
+ |------------|-------------|
138
+ | `receipts` | Gestione scontrini |
139
+ | `merchants` | Gestione esercenti |
140
+ | `cashiers` | Gestione cassieri |
141
+ | `cashRegisters` | Gestione registratori di cassa |
142
+ | `pointOfSales` | Gestione POS |
143
+ | `suppliers` | Gestione fornitori |
144
+ | `pems` | Gestione PEM (MF2) |
145
+ | `dailyReports` | Report giornalieri |
146
+ | `journals` | Gestione giornali |
147
+ | `notifications` | Notifiche sistema |
148
+ | `telemetry` | Telemetria PEM |
149
+
150
+ ## Stati App
151
+
152
+ Il sistema gestisce automaticamente gli stati dell'applicazione basandosi sulle notifiche dal backend:
153
+
154
+ | Stato | Trigger | Descrizione |
155
+ |-------|---------|-------------|
156
+ | `NORMAL` | SYS-I-01 | App funziona normalmente |
157
+ | `WARNING` | SYS-W-01 | Banner avviso con countdown |
158
+ | `BLOCKED` | SYS-C-01 | Solo visualizzazione telemetria |
159
+ | `OFFLINE` | No network | Dati dalla cache |
160
+
161
+ ## Licenza
162
+
163
+ Proprietary - ACube S.r.l.