@easyflow/javascript-sdk 2.1.23 β 2.1.25
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/DATA-STRUCTURES.md +457 -0
- package/INDEX.md +123 -0
- package/PLATFORM-INTEGRATION.md +235 -0
- package/README.md +15 -70
- package/dist/easyflow-sdk.min.js +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# π Easyflow SDK - Platform Integration Guide
|
|
2
|
+
|
|
3
|
+
## π Overview
|
|
4
|
+
|
|
5
|
+
The Easyflow SDK provides a **dual initialization approach** to serve both traditional developers and low-code/no-code platforms. This guide explains the `initializeForPlatform` mechanism and how to use it effectively.
|
|
6
|
+
|
|
7
|
+
## π§ Two Ways to Initialize
|
|
8
|
+
|
|
9
|
+
### 1. **Traditional Initialization** (For Developers)
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Direct SDK instance - Full control
|
|
13
|
+
const sdk = new EasyflowSDK('your-business-id')
|
|
14
|
+
|
|
15
|
+
// Use all SDK methods directly
|
|
16
|
+
await sdk.createCustomer(customerData)
|
|
17
|
+
await sdk.placeOrder(offerId, orderData)
|
|
18
|
+
await sdk.charge(paymentData)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. **Platform Integration** (For Low-Code/No-Code)
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// Platform wrapper - Simplified API
|
|
25
|
+
const wrapper = EasyflowSDK.initializeForPlatform({
|
|
26
|
+
businessId: 'your-business-id',
|
|
27
|
+
enableDebug: true,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Use simplified methods
|
|
31
|
+
await wrapper.createCustomer(customerData)
|
|
32
|
+
await wrapper.placeOrder(offerId, orderData)
|
|
33
|
+
await wrapper.charge(paymentData)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## π― When to Use Each Approach
|
|
37
|
+
|
|
38
|
+
| **Use Case** | **Method** | **Benefits** |
|
|
39
|
+
| ------------------------ | ------------------------- | ----------------------------------------------- |
|
|
40
|
+
| **Full Control** | `new EasyflowSDK()` | Complete API access, custom error handling |
|
|
41
|
+
| **Platform Integration** | `initializeForPlatform()` | Simplified API, automatic callbacks, validation |
|
|
42
|
+
| **Quick Prototyping** | `initializeForPlatform()` | Faster setup, less configuration |
|
|
43
|
+
| **Production Apps** | `new EasyflowSDK()` | Better performance, more control |
|
|
44
|
+
|
|
45
|
+
## βοΈ Platform Integration Features
|
|
46
|
+
|
|
47
|
+
### **Automatic Callbacks**
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const wrapper = EasyflowSDK.initializeForPlatform({
|
|
51
|
+
businessId: 'your-business-id',
|
|
52
|
+
enableDebug: true,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Set up event handlers
|
|
56
|
+
wrapper.on('customerCreated', (customer) => {
|
|
57
|
+
console.log('Customer created:', customer)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
wrapper.on('paymentProcessed', (result, method) => {
|
|
61
|
+
console.log('Payment processed:', result, method)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
wrapper.on('error', (error) => {
|
|
65
|
+
console.error('Error occurred:', error)
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### **Simplified Validation**
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
// Automatic validation with friendly error messages
|
|
73
|
+
const validation = wrapper.validate('email', 'user@example.com')
|
|
74
|
+
if (!validation.valid) {
|
|
75
|
+
console.error('Validation failed:', validation.error)
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### **Configuration Management**
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
// Update configuration on the fly
|
|
83
|
+
wrapper.configure({
|
|
84
|
+
enableDebug: false,
|
|
85
|
+
timeout: 30000,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Get current status
|
|
89
|
+
const status = wrapper.getStatus()
|
|
90
|
+
console.log('Wrapper status:', status)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## π How It Works
|
|
94
|
+
|
|
95
|
+
### **1. Method Call**
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
static initializeForPlatform(config) {
|
|
99
|
+
return initializeEasyflow(config)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### **2. Wrapper Creation**
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
function initializeEasyflow(config) {
|
|
107
|
+
return new EasyflowIntegrationWrapper(config)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### **3. Simplified Interface**
|
|
112
|
+
|
|
113
|
+
The wrapper provides:
|
|
114
|
+
|
|
115
|
+
- β
**Simplified method names**
|
|
116
|
+
- β
**Automatic error handling**
|
|
117
|
+
- β
**Built-in validation**
|
|
118
|
+
- β
**Event management**
|
|
119
|
+
- β
**Configuration persistence**
|
|
120
|
+
|
|
121
|
+
## π± Platform Examples
|
|
122
|
+
|
|
123
|
+
### **Bubble Integration**
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
// In Bubble's JavaScript actions
|
|
127
|
+
const easyflow = EasyflowSDK.initializeForPlatform({
|
|
128
|
+
businessId: bubble.get('business_id'),
|
|
129
|
+
enableDebug: true,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Use in workflows
|
|
133
|
+
const customer = await easyflow.createCustomer({
|
|
134
|
+
name: bubble.get('customer_name'),
|
|
135
|
+
email: bubble.get('customer_email'),
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### **Webflow Integration**
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
// In Webflow's custom code
|
|
143
|
+
const easyflow = EasyflowSDK.initializeForPlatform({
|
|
144
|
+
businessId: 'your-business-id',
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Handle form submissions
|
|
148
|
+
document
|
|
149
|
+
.getElementById('payment-form')
|
|
150
|
+
.addEventListener('submit', async (e) => {
|
|
151
|
+
e.preventDefault()
|
|
152
|
+
const result = await easyflow.charge(paymentData)
|
|
153
|
+
})
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### **Custom Platform**
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
// For your own platform
|
|
160
|
+
class MyPlatform {
|
|
161
|
+
constructor() {
|
|
162
|
+
this.easyflow = EasyflowSDK.initializeForPlatform({
|
|
163
|
+
businessId: this.config.businessId,
|
|
164
|
+
enableDebug: this.config.debug,
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async processPayment(data) {
|
|
169
|
+
return await this.easyflow.charge(data)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## π‘οΈ Security & Validation
|
|
175
|
+
|
|
176
|
+
### **Automatic Sanitization**
|
|
177
|
+
|
|
178
|
+
- All input data is automatically sanitized
|
|
179
|
+
- Dangerous characters and protocols are removed
|
|
180
|
+
- Sensitive information is handled securely
|
|
181
|
+
|
|
182
|
+
### **Built-in Validation**
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
// Automatic validation for common data types
|
|
186
|
+
wrapper.validate('email', email) // Email format
|
|
187
|
+
wrapper.validate('cpf', cpf) // CPF validation
|
|
188
|
+
wrapper.validate('cnpj', cnpj) // CNPJ validation
|
|
189
|
+
wrapper.validate('phone', phone) // Phone format
|
|
190
|
+
wrapper.validate('address', address) // Address structure
|
|
191
|
+
wrapper.validate('customer', customer) // Customer data
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## π Performance Considerations
|
|
195
|
+
|
|
196
|
+
### **Memory Usage**
|
|
197
|
+
|
|
198
|
+
- **Traditional SDK**: Lower memory footprint, direct access
|
|
199
|
+
- **Platform Wrapper**: Slightly higher memory due to additional features
|
|
200
|
+
|
|
201
|
+
### **Execution Speed**
|
|
202
|
+
|
|
203
|
+
- **Traditional SDK**: Faster execution, no wrapper overhead
|
|
204
|
+
- **Platform Wrapper**: Minimal overhead, optimized for ease of use
|
|
205
|
+
|
|
206
|
+
## π§ Configuration Options
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
const wrapper = EasyflowSDK.initializeForPlatform({
|
|
210
|
+
businessId: 'your-business-id', // Required
|
|
211
|
+
enableDebug: true, // Optional: Enable debug logs
|
|
212
|
+
timeout: 30000, // Optional: Request timeout (ms)
|
|
213
|
+
retryAttempts: 3, // Optional: Retry attempts
|
|
214
|
+
enableValidation: true, // Optional: Enable validation
|
|
215
|
+
enableCallbacks: true, // Optional: Enable callbacks
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## π Related Documentation
|
|
220
|
+
|
|
221
|
+
- **[README.md](README.md)** - Main SDK documentation
|
|
222
|
+
- **[INDEX.md](INDEX.md)** - Documentation hub
|
|
223
|
+
- **[DATA-STRUCTURES.md](DATA-STRUCTURES.md)** - Data structure reference
|
|
224
|
+
- **[API Reference](docs/index.html)** - Complete API documentation
|
|
225
|
+
|
|
226
|
+
## π Getting Started
|
|
227
|
+
|
|
228
|
+
1. **Choose your approach** based on your needs
|
|
229
|
+
2. **Initialize the SDK** using the appropriate method
|
|
230
|
+
3. **Configure callbacks** if using platform integration
|
|
231
|
+
4. **Start building** your payment solution
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
**Need help?** Check the main [README.md](README.md) or create an issue on GitHub.
|
package/README.md
CHANGED
|
@@ -149,13 +149,6 @@ platform. With this SDK, you can:
|
|
|
149
149
|
- **MongoDB ObjectId**: 24-character hexadecimal format `507f1f77bcf86cd799439011`
|
|
150
150
|
- **Strict Validation**: Rejects any other formats for enhanced security
|
|
151
151
|
|
|
152
|
-
### Lovable Integration Fixes
|
|
153
|
-
|
|
154
|
-
- **Event System Implementation**: Complete event system with `on()` and `off()` methods
|
|
155
|
-
- **Iframe Compatibility**: Fixed iframe blocking issues for low-code platforms
|
|
156
|
-
- **Global Instance**: `window.easyflowSDK` instance with all methods and events
|
|
157
|
-
- **Event Emissions**: Automatic events for `customerCreated`, `orderPlaced`, and `paymentProcessed`
|
|
158
|
-
|
|
159
152
|
## Quick Start
|
|
160
153
|
|
|
161
154
|
### Installation
|
|
@@ -169,7 +162,7 @@ Add this script tag to your HTML:
|
|
|
169
162
|
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
170
163
|
|
|
171
164
|
<!-- Specific version -->
|
|
172
|
-
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.
|
|
165
|
+
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.19.min.js"></script>
|
|
173
166
|
```
|
|
174
167
|
|
|
175
168
|
#### Option 2: CDN jsDelivr (Alternative)
|
|
@@ -192,20 +185,6 @@ npm install @easyflow/javascript-sdk
|
|
|
192
185
|
|
|
193
186
|
### Basic Usage
|
|
194
187
|
|
|
195
|
-
#### Method 1: CDN Script (Recommended for Production)
|
|
196
|
-
|
|
197
|
-
```html
|
|
198
|
-
<!-- Load SDK via script tag -->
|
|
199
|
-
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### Method 2: CDN jsDelivr (Alternative)
|
|
203
|
-
|
|
204
|
-
```html
|
|
205
|
-
<!-- Load SDK via jsDelivr -->
|
|
206
|
-
<script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"></script>
|
|
207
|
-
```
|
|
208
|
-
|
|
209
188
|
```javascript
|
|
210
189
|
// Configure the global instance
|
|
211
190
|
easyflowSDK.configure({
|
|
@@ -238,43 +217,11 @@ easyflowSDK
|
|
|
238
217
|
})
|
|
239
218
|
```
|
|
240
219
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```html
|
|
244
|
-
<!-- Load SDK via script tag -->
|
|
245
|
-
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
```javascript
|
|
249
|
-
// Configure the global instance
|
|
250
|
-
easyflowSDK.configure({
|
|
251
|
-
businessId: 'demo-business-12345',
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
// Now you can use all methods directly
|
|
255
|
-
easyflowSDK
|
|
256
|
-
.createCustomer({
|
|
257
|
-
name: 'Maria Silva',
|
|
258
|
-
email: 'maria@exemplo.com',
|
|
259
|
-
document: { type: 'CPF', number: '12345678901' },
|
|
260
|
-
})
|
|
261
|
-
.then((customer) => {
|
|
262
|
-
console.log('Cliente criado:', customer)
|
|
263
|
-
})
|
|
264
|
-
.catch((error) => {
|
|
265
|
-
console.error('Erro ao criar cliente:', error.message)
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
// Validation methods are always available
|
|
269
|
-
if (easyflowSDK.validate.email('teste@exemplo.com')) {
|
|
270
|
-
console.log('Email vΓ‘lido!')
|
|
271
|
-
}
|
|
220
|
+
## π Documentation
|
|
272
221
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
})
|
|
277
|
-
```
|
|
222
|
+
- **[INDEX.md](INDEX.md)** - Central documentation hub
|
|
223
|
+
- **[DATA-STRUCTURES.md](DATA-STRUCTURES.md)** - Complete data structure reference
|
|
224
|
+
- **[PLATFORM-INTEGRATION.md](PLATFORM-INTEGRATION.md)** - Platform integration guide with `initializeForPlatform`
|
|
278
225
|
|
|
279
226
|
## Features
|
|
280
227
|
|
|
@@ -300,14 +247,6 @@ easyflowSDK.on('customerCreated', (data) => {
|
|
|
300
247
|
- **Obfuscated Builds**: Production builds are obfuscated for enhanced security
|
|
301
248
|
- **Controlled Distribution**: Secure distribution via CDN (Cloudflare Pages + jsDelivr)
|
|
302
249
|
|
|
303
|
-
### Low-Code Platform Support
|
|
304
|
-
|
|
305
|
-
- **Lovable Integration**: Full compatibility with Lovable platform
|
|
306
|
-
- **Global Instance**: `window.easyflowSDK` for easy integration
|
|
307
|
-
- **Event System**: Built-in event handling for `on()` and `off()`
|
|
308
|
-
- **Validation Methods**: Always available validation functions
|
|
309
|
-
- **Configuration**: Simple setup with `easyflowSDK.configure()`
|
|
310
|
-
|
|
311
250
|
## API Reference
|
|
312
251
|
|
|
313
252
|
### Core Methods
|
|
@@ -574,7 +513,7 @@ can find this value in your business configuration at [https://app.easyflow.digi
|
|
|
574
513
|
|
|
575
514
|
**Important:** Never share your business ID publicly. Keep it secure and use it only in your application code.
|
|
576
515
|
|
|
577
|
-
### SDK Options
|
|
516
|
+
### SDK Options
|
|
578
517
|
|
|
579
518
|
```javascript
|
|
580
519
|
// Configure the global instance
|
|
@@ -1193,12 +1132,18 @@ This project is licensed under the ISC License - see the [LICENSE](LICENSE) file
|
|
|
1193
1132
|
|
|
1194
1133
|
**Diego Moura** - Co-Found & CTO at Easyflow
|
|
1195
1134
|
|
|
1196
|
-
- **Email**: [
|
|
1197
|
-
- **Website**: [https://
|
|
1198
|
-
- **GitHub**: [https://github.com/dmourainatel](https://github.com/dmourainatel)
|
|
1135
|
+
- **Email**: [contato@easyflow.digital](mailto:contato@easyflow.digital)
|
|
1136
|
+
- **Website**: [https://www.easyflow.digital](https://www.easyflow.digital)
|
|
1199
1137
|
|
|
1200
1138
|
## Changelog
|
|
1201
1139
|
|
|
1140
|
+
### v2.1.23
|
|
1141
|
+
|
|
1142
|
+
- **SDK Simplification**: Removed all platform-specific integrations for cleaner, focused codebase
|
|
1143
|
+
- **Streamlined Documentation**: Focused README on core SDK functionality and usage
|
|
1144
|
+
- **Enhanced Security**: Maintained all security features while simplifying the codebase
|
|
1145
|
+
- **Better Developer Experience**: Cleaner documentation focused on essential features
|
|
1146
|
+
|
|
1202
1147
|
### v2.1.20
|
|
1203
1148
|
|
|
1204
1149
|
- **jsDelivr CDN Fix**: Fixed npm package to include easyflow-sdk.min.js for proper jsDelivr CDN support
|