@easyflow/javascript-sdk 2.1.7 → 2.1.9
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 +294 -713
- package/dist/index.d.ts +421 -0
- package/package.json +19 -6
- package/.babelrc +0 -5
- package/.github/workflows/deploy-sdk-cf.yml +0 -49
- package/.github/workflows/release-sdk-cdn.yml +0 -144
- package/.github/workflows/release-sdk.yml +0 -112
- package/.prettierrc +0 -6
- package/CDN-DEPLOYMENT.md +0 -175
- package/DEMO.md +0 -258
- package/DEPLOYMENT.md +0 -224
- package/INTEGRATION-GUIDE.md +0 -521
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/easyflow-javascript-sdk/index.html +0 -116
- package/coverage/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
- package/coverage/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
- package/coverage/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
- package/coverage/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
- package/coverage/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
- package/coverage/easyflow-javascript-sdk/libs/index.html +0 -266
- package/coverage/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
- package/coverage/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
- package/coverage/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
- package/coverage/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
- package/coverage/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
- package/coverage/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
- package/coverage/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/easyflow-javascript-sdk/index.html +0 -116
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/index.html +0 -266
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
- package/coverage/lcov-report/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -131
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -1429
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/dist/435.easyflow-sdk.min.js +0 -1
- package/dist/easyflow-sdk.min.js +0 -1
- package/dist/easyflow-sdk.min.js.LICENSE.txt +0 -1
- package/dist/index.html +0 -756
- package/docs/index.html +0 -775
- package/examples/lovable-integration.html +0 -410
- package/index.html +0 -981
- package/jest.config.js +0 -37
- package/jsdoc.json +0 -42
- package/libs/auto-integration.mjs +0 -333
- package/libs/constants.mjs +0 -61
- package/libs/constants.spec.js +0 -198
- package/libs/errors.mjs +0 -62
- package/libs/errors.spec.js +0 -178
- package/libs/exception-handler.mjs +0 -21
- package/libs/exception-handler.spec.js +0 -237
- package/libs/fingerprint.mjs +0 -270
- package/libs/http.mjs +0 -163
- package/libs/http.spec.js +0 -427
- package/libs/integration-wrapper.mjs +0 -285
- package/libs/logger.mjs +0 -161
- package/libs/logger.spec.js +0 -389
- package/libs/sanitizer.mjs +0 -340
- package/libs/sanitizer.spec.js +0 -583
- package/libs/security.mjs +0 -217
- package/libs/types.mjs +0 -141
- package/libs/utils.mjs +0 -368
- package/libs/utils.spec.js +0 -231
- package/libs/validator.mjs +0 -952
- package/libs/validator.spec.js +0 -615
- package/mocks/offer.mock.js +0 -77
- package/scripts/publish-npm.sh +0 -82
- package/sdk.mjs +0 -945
- package/sdk.spec.js +0 -796
- package/test-setup.cjs +0 -211
- package/test.html +0 -154
- package/webpack.config.cjs +0 -41
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
declare module '@easyflow/javascript-sdk' {
|
|
2
|
+
export interface EasyflowSDKConfig {
|
|
3
|
+
businessId: string
|
|
4
|
+
environment?: 'production' | 'sandbox'
|
|
5
|
+
debug?: boolean
|
|
6
|
+
timeout?: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CustomerData {
|
|
10
|
+
name: string
|
|
11
|
+
email: string
|
|
12
|
+
document: {
|
|
13
|
+
type: 'CPF' | 'CNPJ'
|
|
14
|
+
number: string
|
|
15
|
+
}
|
|
16
|
+
phone?: {
|
|
17
|
+
areaCode: string
|
|
18
|
+
ddd: string
|
|
19
|
+
number: string
|
|
20
|
+
isMobile: boolean
|
|
21
|
+
}
|
|
22
|
+
address?: {
|
|
23
|
+
zipCode: string
|
|
24
|
+
street: string
|
|
25
|
+
number: string
|
|
26
|
+
complement?: string
|
|
27
|
+
neighborhood: string
|
|
28
|
+
city: string
|
|
29
|
+
state: string
|
|
30
|
+
}
|
|
31
|
+
deliveryAddress?: {
|
|
32
|
+
zipCode: string
|
|
33
|
+
street: string
|
|
34
|
+
number: string
|
|
35
|
+
complement?: string
|
|
36
|
+
neighborhood: string
|
|
37
|
+
city: string
|
|
38
|
+
state: string
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PaymentMethod {
|
|
43
|
+
method: 'credit-card' | 'pix' | 'bank-billet'
|
|
44
|
+
numberInstallments: number
|
|
45
|
+
creditCard?: {
|
|
46
|
+
number: string
|
|
47
|
+
holderName: string
|
|
48
|
+
month: string
|
|
49
|
+
year: string
|
|
50
|
+
cvv: string
|
|
51
|
+
}
|
|
52
|
+
creditCardId?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface OrderData {
|
|
56
|
+
customer: CustomerData
|
|
57
|
+
payments: PaymentMethod[]
|
|
58
|
+
items?: Array<{
|
|
59
|
+
name: string
|
|
60
|
+
price: number
|
|
61
|
+
quantity?: number
|
|
62
|
+
}>
|
|
63
|
+
metadata?: Record<string, any>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CreditCardData {
|
|
67
|
+
number: string
|
|
68
|
+
holderName: string
|
|
69
|
+
month: string
|
|
70
|
+
year: string
|
|
71
|
+
cvv: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface Customer {
|
|
75
|
+
id: string
|
|
76
|
+
name: string
|
|
77
|
+
email: string
|
|
78
|
+
document: {
|
|
79
|
+
type: 'CPF' | 'CNPJ'
|
|
80
|
+
number: string
|
|
81
|
+
}
|
|
82
|
+
phone?: {
|
|
83
|
+
areaCode: string
|
|
84
|
+
ddd: string
|
|
85
|
+
number: string
|
|
86
|
+
isMobile: boolean
|
|
87
|
+
}
|
|
88
|
+
address?: {
|
|
89
|
+
zipCode: string
|
|
90
|
+
street: string
|
|
91
|
+
number: string
|
|
92
|
+
complement?: string
|
|
93
|
+
neighborhood: string
|
|
94
|
+
city: string
|
|
95
|
+
state: string
|
|
96
|
+
}
|
|
97
|
+
deliveryAddress?: {
|
|
98
|
+
zipCode: string
|
|
99
|
+
street: string
|
|
100
|
+
number: string
|
|
101
|
+
complement?: string
|
|
102
|
+
neighborhood: string
|
|
103
|
+
city: string
|
|
104
|
+
state: string
|
|
105
|
+
}
|
|
106
|
+
createdAt?: string
|
|
107
|
+
updatedAt?: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CreditCard {
|
|
111
|
+
creditCardId: string
|
|
112
|
+
brand?: string
|
|
113
|
+
last4Numbers?: string
|
|
114
|
+
expiresAtMonth?: string
|
|
115
|
+
expiresAtYear?: string
|
|
116
|
+
holderName?: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface Order {
|
|
120
|
+
id: string
|
|
121
|
+
status: string
|
|
122
|
+
total: number
|
|
123
|
+
customer: Customer
|
|
124
|
+
payments: PaymentMethod[]
|
|
125
|
+
items?: Array<{
|
|
126
|
+
name: string
|
|
127
|
+
price: number
|
|
128
|
+
quantity: number
|
|
129
|
+
}>
|
|
130
|
+
createdAt?: string
|
|
131
|
+
updatedAt?: string
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface Offer {
|
|
135
|
+
id: string
|
|
136
|
+
name: string
|
|
137
|
+
price: number
|
|
138
|
+
description?: string
|
|
139
|
+
items: Array<{
|
|
140
|
+
name: string
|
|
141
|
+
price: number
|
|
142
|
+
quantity: number
|
|
143
|
+
}>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface PixData {
|
|
147
|
+
qrCode: string
|
|
148
|
+
copyAndPasteCode: string
|
|
149
|
+
expirationDate: string
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface BankBilletData {
|
|
153
|
+
link: string
|
|
154
|
+
line: string
|
|
155
|
+
barCode: string
|
|
156
|
+
expirationDate: string
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface ValidationResult {
|
|
160
|
+
isValid: boolean
|
|
161
|
+
errors?: string[]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export class EasyflowSDK {
|
|
165
|
+
static readonly version: string
|
|
166
|
+
|
|
167
|
+
constructor(config: EasyflowSDKConfig | string)
|
|
168
|
+
|
|
169
|
+
// Core Methods
|
|
170
|
+
placeOrder(
|
|
171
|
+
offerId: string,
|
|
172
|
+
data: OrderData,
|
|
173
|
+
headers?: Record<string, string>
|
|
174
|
+
): Promise<string>
|
|
175
|
+
charge(
|
|
176
|
+
data: OrderData,
|
|
177
|
+
headers?: Record<string, string>
|
|
178
|
+
): Promise<string>
|
|
179
|
+
encrypt(
|
|
180
|
+
creditCardData: CreditCardData,
|
|
181
|
+
headers?: Record<string, string>
|
|
182
|
+
): Promise<string>
|
|
183
|
+
|
|
184
|
+
// Offer & Order Management
|
|
185
|
+
getOffer(
|
|
186
|
+
offerId: string,
|
|
187
|
+
headers?: Record<string, string>
|
|
188
|
+
): Promise<Offer>
|
|
189
|
+
getOrder(
|
|
190
|
+
orderId: string,
|
|
191
|
+
headers?: Record<string, string>
|
|
192
|
+
): Promise<Order>
|
|
193
|
+
|
|
194
|
+
// Payment Methods
|
|
195
|
+
getPix(
|
|
196
|
+
orderId: string,
|
|
197
|
+
headers?: Record<string, string>
|
|
198
|
+
): Promise<PixData | null>
|
|
199
|
+
getBankBillet(
|
|
200
|
+
orderId: string,
|
|
201
|
+
headers?: Record<string, string>
|
|
202
|
+
): Promise<BankBilletData | null>
|
|
203
|
+
|
|
204
|
+
// Customer Management
|
|
205
|
+
createCustomer(
|
|
206
|
+
customerData: CustomerData,
|
|
207
|
+
headers?: Record<string, string>
|
|
208
|
+
): Promise<Customer>
|
|
209
|
+
getCustomer(
|
|
210
|
+
customerId: string,
|
|
211
|
+
headers?: Record<string, string>
|
|
212
|
+
): Promise<Customer>
|
|
213
|
+
updateCustomer(
|
|
214
|
+
customerId: string,
|
|
215
|
+
updateData: Partial<CustomerData>,
|
|
216
|
+
headers?: Record<string, string>
|
|
217
|
+
): Promise<ValidationResult>
|
|
218
|
+
|
|
219
|
+
// Credit Card Management
|
|
220
|
+
addCreditCard(
|
|
221
|
+
customerId: string,
|
|
222
|
+
creditCardToken: string,
|
|
223
|
+
headers?: Record<string, string>
|
|
224
|
+
): Promise<CreditCard>
|
|
225
|
+
getCreditCard(
|
|
226
|
+
customerId: string,
|
|
227
|
+
creditCardId: string,
|
|
228
|
+
headers?: Record<string, string>
|
|
229
|
+
): Promise<CreditCard>
|
|
230
|
+
removeCreditCard(
|
|
231
|
+
customerId: string,
|
|
232
|
+
creditCardId: string,
|
|
233
|
+
headers?: Record<string, string>
|
|
234
|
+
): Promise<ValidationResult>
|
|
235
|
+
|
|
236
|
+
// Event System
|
|
237
|
+
on(
|
|
238
|
+
event: 'customerCreated' | 'orderPlaced' | 'paymentProcessed',
|
|
239
|
+
callback: (data: any) => void
|
|
240
|
+
): void
|
|
241
|
+
off(
|
|
242
|
+
event: 'customerCreated' | 'orderPlaced' | 'paymentProcessed',
|
|
243
|
+
callback: (data: any) => void
|
|
244
|
+
): void
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Validator Class
|
|
248
|
+
export class Validator {
|
|
249
|
+
static validateEmail(email: string): boolean
|
|
250
|
+
static validateCPF(cpf: string): boolean
|
|
251
|
+
static validateCNPJ(cnpj: string): boolean
|
|
252
|
+
static validateLegalDocument(document: {
|
|
253
|
+
type: 'CPF' | 'CNPJ'
|
|
254
|
+
number: string
|
|
255
|
+
}): boolean
|
|
256
|
+
static validatePhone(phone: {
|
|
257
|
+
areaCode: string
|
|
258
|
+
ddd: string
|
|
259
|
+
number: string
|
|
260
|
+
isMobile: boolean
|
|
261
|
+
}): boolean
|
|
262
|
+
static validateAddress(address: {
|
|
263
|
+
zipCode: string
|
|
264
|
+
street: string
|
|
265
|
+
number: string
|
|
266
|
+
complement?: string
|
|
267
|
+
neighborhood: string
|
|
268
|
+
city: string
|
|
269
|
+
state: string
|
|
270
|
+
}): boolean
|
|
271
|
+
static validateCustomer(customer: CustomerData): boolean
|
|
272
|
+
static validatePagination(page: number, limit: number): boolean
|
|
273
|
+
static validateBusinessId(businessId: string): boolean
|
|
274
|
+
static validateCreditCardToken(token: string): boolean
|
|
275
|
+
static validateOrderId(orderId: string): boolean
|
|
276
|
+
static validateOfferId(offerId: string): boolean
|
|
277
|
+
static validateCustomerId(customerId: string): boolean
|
|
278
|
+
static validateCreditCardId(creditCardId: string): boolean
|
|
279
|
+
static validateOrderData(orderData: OrderData): boolean
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Constants
|
|
283
|
+
export const PAYMENT_METHODS: {
|
|
284
|
+
readonly CREDIT_CARD: 'credit-card'
|
|
285
|
+
readonly PIX: 'pix'
|
|
286
|
+
readonly BANK_BILLET: 'bank-billet'
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export const TARGETS: {
|
|
290
|
+
readonly CHARGE: 'charge'
|
|
291
|
+
readonly PLACE_ORDER: 'place-order'
|
|
292
|
+
readonly ENCRYPT: 'encrypt'
|
|
293
|
+
readonly GET_OFFER: 'get-offer'
|
|
294
|
+
readonly GET_ORDER: 'get-order'
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export const HTTP_STATUS_CODES: {
|
|
298
|
+
readonly OK: 200
|
|
299
|
+
readonly CREATED: 201
|
|
300
|
+
readonly BAD_REQUEST: 400
|
|
301
|
+
readonly UNAUTHORIZED: 401
|
|
302
|
+
readonly FORBIDDEN: 403
|
|
303
|
+
readonly NOT_FOUND: 404
|
|
304
|
+
readonly INTERNAL_SERVER_ERROR: 500
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const HTTP_REQUEST_METHODS: {
|
|
308
|
+
readonly GET: 'GET'
|
|
309
|
+
readonly POST: 'POST'
|
|
310
|
+
readonly PUT: 'PUT'
|
|
311
|
+
readonly DELETE: 'DELETE'
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Error Classes
|
|
315
|
+
export class EasyflowError extends Error {
|
|
316
|
+
constructor(message: string, status?: number, code?: string)
|
|
317
|
+
status: number
|
|
318
|
+
code: string
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export class SecurityError extends EasyflowError {
|
|
322
|
+
constructor(message: string)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export class ValidationError extends EasyflowError {
|
|
326
|
+
constructor(message: string)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export class NetworkError extends EasyflowError {
|
|
330
|
+
constructor(message: string)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export const ERROR_CODES: {
|
|
334
|
+
readonly VALIDATION_ERROR: 'VALIDATION_ERROR'
|
|
335
|
+
readonly SECURITY_ERROR: 'SECURITY_ERROR'
|
|
336
|
+
readonly NETWORK_ERROR: 'NETWORK_ERROR'
|
|
337
|
+
readonly UNKNOWN_ERROR: 'UNKNOWN_ERROR'
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Default export
|
|
341
|
+
export default EasyflowSDK
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Global instance for browser environments
|
|
345
|
+
declare global {
|
|
346
|
+
interface Window {
|
|
347
|
+
easyflowSDK: {
|
|
348
|
+
on(event: string, callback: (data: any) => void): void
|
|
349
|
+
off(event: string, callback: (data: any) => void): void
|
|
350
|
+
placeOrder(
|
|
351
|
+
offerId: string,
|
|
352
|
+
data: any,
|
|
353
|
+
headers?: Record<string, string>
|
|
354
|
+
): Promise<string>
|
|
355
|
+
charge(data: any, headers?: Record<string, string>): Promise<string>
|
|
356
|
+
encrypt(
|
|
357
|
+
creditCardData: any,
|
|
358
|
+
headers?: Record<string, string>
|
|
359
|
+
): Promise<string>
|
|
360
|
+
getOffer(
|
|
361
|
+
offerId: string,
|
|
362
|
+
headers?: Record<string, string>
|
|
363
|
+
): Promise<any>
|
|
364
|
+
getOrder(
|
|
365
|
+
orderId: string,
|
|
366
|
+
headers?: Record<string, string>
|
|
367
|
+
): Promise<any>
|
|
368
|
+
getPix(
|
|
369
|
+
orderId: string,
|
|
370
|
+
headers?: Record<string, string>
|
|
371
|
+
): Promise<any>
|
|
372
|
+
getBankBillet(
|
|
373
|
+
orderId: string,
|
|
374
|
+
headers?: Record<string, string>
|
|
375
|
+
): Promise<any>
|
|
376
|
+
createCustomer(
|
|
377
|
+
customerData: any,
|
|
378
|
+
headers?: Record<string, string>
|
|
379
|
+
): Promise<any>
|
|
380
|
+
getCustomer(
|
|
381
|
+
customerId: string,
|
|
382
|
+
headers?: Record<string, string>
|
|
383
|
+
): Promise<any>
|
|
384
|
+
updateCustomer(
|
|
385
|
+
customerId: string,
|
|
386
|
+
updateData: any,
|
|
387
|
+
headers?: Record<string, string>
|
|
388
|
+
): Promise<any>
|
|
389
|
+
addCreditCard(
|
|
390
|
+
customerId: string,
|
|
391
|
+
creditCardToken: string,
|
|
392
|
+
headers?: Record<string, string>
|
|
393
|
+
): Promise<any>
|
|
394
|
+
getCreditCard(
|
|
395
|
+
customerId: string,
|
|
396
|
+
creditCardId: string,
|
|
397
|
+
headers?: Record<string, string>
|
|
398
|
+
): Promise<any>
|
|
399
|
+
removeCreditCard(
|
|
400
|
+
customerId: string,
|
|
401
|
+
creditCardId: string,
|
|
402
|
+
headers?: Record<string, string>
|
|
403
|
+
): Promise<any>
|
|
404
|
+
validate: {
|
|
405
|
+
email(email: string): boolean
|
|
406
|
+
cpf(cpf: string): boolean
|
|
407
|
+
cnpj(cnpj: string): boolean
|
|
408
|
+
phone(phone: any): boolean
|
|
409
|
+
address(address: any): boolean
|
|
410
|
+
customer(customer: any): boolean
|
|
411
|
+
orderId(orderId: string): boolean
|
|
412
|
+
offerId(offerId: string): boolean
|
|
413
|
+
customerId(customerId: string): boolean
|
|
414
|
+
creditCardId(creditCardId: string): boolean
|
|
415
|
+
}
|
|
416
|
+
version: string
|
|
417
|
+
PAYMENT_METHODS: any
|
|
418
|
+
}
|
|
419
|
+
EasyflowSDK: typeof import('@easyflow/javascript-sdk').EasyflowSDK
|
|
420
|
+
}
|
|
421
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyflow/javascript-sdk",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Easyflow
|
|
5
|
-
"main": "
|
|
3
|
+
"version": "2.1.9",
|
|
4
|
+
"description": "Easyflow JavaScript SDK - Documentation and TypeScript definitions. For production use, use the CDN script: https://easyflow-sdk.pages.dev/easyflow-sdk.min.js",
|
|
5
|
+
"main": "README.md",
|
|
6
|
+
"module": "README.md",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"dist/index.d.ts"
|
|
13
|
+
],
|
|
8
14
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/easyflow-sdk.min.js",
|
|
17
|
+
"require": "./dist/easyflow-sdk.min.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
11
21
|
},
|
|
12
22
|
"scripts": {
|
|
13
|
-
"build": "npm run generate-version && npx webpack --config webpack.config.cjs",
|
|
23
|
+
"build": "npm run generate-version && npm run build:types && npx webpack --config webpack.config.cjs",
|
|
24
|
+
"build:types": "npx tsc --project tsconfig.json",
|
|
14
25
|
"generate-version": "node -e \"const pkg=require('./package.json'); const fs=require('fs'); const content='export const SDK_VERSION = \\'' + pkg.version + '\\';'; fs.writeFileSync('./version.mjs', content);\"",
|
|
15
26
|
"server:up": "rm -rf ./dist && npm run build && npx http-server . -p 8080 -o",
|
|
16
27
|
"dev": "npm run build && npx http-server . -p 8080 -o --cors",
|
|
@@ -38,12 +49,14 @@
|
|
|
38
49
|
"@babel/cli": "^7.26.4",
|
|
39
50
|
"@babel/core": "^7.26.8",
|
|
40
51
|
"@babel/preset-env": "^7.26.8",
|
|
52
|
+
"@types/node": "^20.19.11",
|
|
41
53
|
"babel-loader": "^9.2.1",
|
|
42
54
|
"http-server": "^14.1.1",
|
|
43
55
|
"javascript-obfuscator": "^4.1.1",
|
|
44
56
|
"jest": "^29.7.0",
|
|
45
57
|
"prettier": "^3.4.2",
|
|
46
58
|
"terser-webpack-plugin": "^5.3.11",
|
|
59
|
+
"typescript": "^5.9.2",
|
|
47
60
|
"webpack": "^5.97.1",
|
|
48
61
|
"webpack-cli": "^6.0.1",
|
|
49
62
|
"webpack-obfuscator": "^3.5.1"
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
name: Deploy Easyflow SDK to Cloudflare Pages
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
build-and-deploy:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
|
-
steps:
|
|
13
|
-
- name: Checkout code
|
|
14
|
-
uses: actions/checkout@v4
|
|
15
|
-
|
|
16
|
-
- name: Setup Node.js
|
|
17
|
-
uses: actions/setup-node@v4
|
|
18
|
-
with:
|
|
19
|
-
node-version: '18'
|
|
20
|
-
cache: 'npm'
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: npm ci
|
|
24
|
-
|
|
25
|
-
- name: Build SDK
|
|
26
|
-
run: npm run build
|
|
27
|
-
|
|
28
|
-
- name: Copy Documentation to Build
|
|
29
|
-
run: |
|
|
30
|
-
# Copiar apenas o index.html da documentação
|
|
31
|
-
cp docs/index.html dist/
|
|
32
|
-
echo "📚 Documentação copiada para build (apenas index.html)"
|
|
33
|
-
|
|
34
|
-
- name: Deploy to Cloudflare Pages
|
|
35
|
-
uses: cloudflare/pages-action@v1
|
|
36
|
-
with:
|
|
37
|
-
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
38
|
-
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
39
|
-
projectName: easyflow-sdk
|
|
40
|
-
directory: dist
|
|
41
|
-
|
|
42
|
-
- name: Success Message
|
|
43
|
-
run: |
|
|
44
|
-
echo "🚀 SDK e Documentação Deployados com sucesso!"
|
|
45
|
-
echo "📦 SDK + Docs: https://easyflow-sdk.pages.dev"
|
|
46
|
-
echo "🌐 jsDelivr: https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"
|
|
47
|
-
echo ""
|
|
48
|
-
echo "✅ Documentação agora está disponível em:"
|
|
49
|
-
echo " https://easyflow-sdk.pages.dev"
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
name: Release Easyflow SDK - Multi-CDN
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*'
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
release:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
|
-
steps:
|
|
13
|
-
- name: Checkout do repositório
|
|
14
|
-
uses: actions/checkout@v4
|
|
15
|
-
|
|
16
|
-
- name: Instalar Node.js
|
|
17
|
-
uses: actions/setup-node@v4
|
|
18
|
-
with:
|
|
19
|
-
node-version: 20
|
|
20
|
-
cache: 'npm'
|
|
21
|
-
|
|
22
|
-
- name: Instalar dependências
|
|
23
|
-
run: npm install
|
|
24
|
-
|
|
25
|
-
- name: Gerar arquivo de versão
|
|
26
|
-
run: npm run generate-version
|
|
27
|
-
|
|
28
|
-
- name: Executar testes
|
|
29
|
-
run: npm test
|
|
30
|
-
|
|
31
|
-
- name: Build do SDK
|
|
32
|
-
run: npm run build
|
|
33
|
-
|
|
34
|
-
- name: Extrair versão do SDK
|
|
35
|
-
id: version
|
|
36
|
-
run: |
|
|
37
|
-
VERSION=$(jq -r .version package.json)
|
|
38
|
-
echo "VERSION=v$VERSION" >> "$GITHUB_ENV"
|
|
39
|
-
echo "version=v$VERSION" >> "$GITHUB_OUTPUT"
|
|
40
|
-
|
|
41
|
-
- name: Copiar arquivo com versão
|
|
42
|
-
run: |
|
|
43
|
-
cp dist/easyflow-sdk.min.js dist/easyflow-sdk.${{ env.VERSION }}.min.js
|
|
44
|
-
|
|
45
|
-
- name: Copiar interface de teste
|
|
46
|
-
run: |
|
|
47
|
-
cp index.html dist/
|
|
48
|
-
# Update the script src to use the correct path for production
|
|
49
|
-
sed -i 's|./dist/easyflow-sdk.min.js|./easyflow-sdk.min.js|g' dist/index.html
|
|
50
|
-
|
|
51
|
-
- name: Gerar hash de integridade (SRI)
|
|
52
|
-
id: sri
|
|
53
|
-
run: |
|
|
54
|
-
HASH=$(openssl dgst -sha384 -binary dist/easyflow-sdk.${{ env.VERSION }}.min.js | openssl base64 -A)
|
|
55
|
-
echo "SRI=sha384-${HASH}" >> "$GITHUB_ENV"
|
|
56
|
-
echo "sha=sha384-${HASH}" >> "$GITHUB_OUTPUT"
|
|
57
|
-
|
|
58
|
-
- name: Criar arquivo de exemplo com SRI
|
|
59
|
-
run: |
|
|
60
|
-
cat > dist/example.html << EOF
|
|
61
|
-
<!DOCTYPE html>
|
|
62
|
-
<html>
|
|
63
|
-
<head>
|
|
64
|
-
<title>Easyflow SDK Example</title>
|
|
65
|
-
</head>
|
|
66
|
-
<body>
|
|
67
|
-
<h1>Easyflow SDK v${{ env.VERSION }}</h1>
|
|
68
|
-
<script src="easyflow-sdk.${{ env.VERSION }}.min.js"
|
|
69
|
-
integrity="${{ env.SRI }}"
|
|
70
|
-
crossorigin="anonymous"></script>
|
|
71
|
-
<script>
|
|
72
|
-
console.log('EasyflowSDK version:', EasyflowSDK.version);
|
|
73
|
-
</script>
|
|
74
|
-
</body>
|
|
75
|
-
</html>
|
|
76
|
-
EOF
|
|
77
|
-
|
|
78
|
-
- name: Deploy para Cloudflare Pages
|
|
79
|
-
uses: cloudflare/pages-action@v1
|
|
80
|
-
with:
|
|
81
|
-
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
82
|
-
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
83
|
-
projectName: easyflow-sdk
|
|
84
|
-
directory: dist
|
|
85
|
-
|
|
86
|
-
- name: Verificar disponibilidade no jsDelivr
|
|
87
|
-
run: |
|
|
88
|
-
echo "Verificando disponibilidade no jsDelivr..."
|
|
89
|
-
echo "URL: https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@${{ env.VERSION }}/dist/easyflow-sdk.min.js"
|
|
90
|
-
echo "Note: jsDelivr pode levar alguns minutos para sincronizar com npm"
|
|
91
|
-
|
|
92
|
-
- name: Criar Release no GitHub
|
|
93
|
-
uses: actions/create-release@v1
|
|
94
|
-
env:
|
|
95
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
96
|
-
with:
|
|
97
|
-
tag_name: ${{ github.ref }}
|
|
98
|
-
release_name: Easyflow SDK ${{ env.VERSION }}
|
|
99
|
-
body: |
|
|
100
|
-
## Easyflow SDK ${{ env.VERSION }}
|
|
101
|
-
|
|
102
|
-
### CDNs Disponíveis
|
|
103
|
-
|
|
104
|
-
#### Cloudflare Pages
|
|
105
|
-
- **Latest**: `https://easyflow-sdk.pages.dev/easyflow-sdk.min.js`
|
|
106
|
-
- **Versionado**: `https://easyflow-sdk.pages.dev/easyflow-sdk.${{ env.VERSION }}.min.js`
|
|
107
|
-
|
|
108
|
-
#### jsDelivr CDN
|
|
109
|
-
- **Latest**: `https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js`
|
|
110
|
-
- **Versionado**: `https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@${{ env.VERSION }}/dist/easyflow-sdk.min.js`
|
|
111
|
-
|
|
112
|
-
### SRI Hash
|
|
113
|
-
```
|
|
114
|
-
sha384-${{ env.SRI }}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Exemplo de Uso
|
|
118
|
-
|
|
119
|
-
#### Cloudflare Pages
|
|
120
|
-
```html
|
|
121
|
-
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.${{ env.VERSION }}.min.js"
|
|
122
|
-
integrity="sha384-${{ env.SRI }}"
|
|
123
|
-
crossorigin="anonymous"></script>
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
#### jsDelivr CDN
|
|
127
|
-
```html
|
|
128
|
-
<script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@${{ env.VERSION }}/dist/easyflow-sdk.min.js"
|
|
129
|
-
integrity="sha384-${{ env.SRI }}"
|
|
130
|
-
crossorigin="anonymous"></script>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Arquivos
|
|
134
|
-
- `easyflow-sdk.${{ env.VERSION }}.min.js` - SDK minificado
|
|
135
|
-
- `easyflow-sdk.min.js` - SDK minificado (sem versão)
|
|
136
|
-
- `example.html` - Exemplo de uso com SRI
|
|
137
|
-
draft: false
|
|
138
|
-
prerelease: false
|
|
139
|
-
|
|
140
|
-
- name: Publicar no NPM (se necessário)
|
|
141
|
-
run: |
|
|
142
|
-
echo "Para publicar no NPM, execute manualmente:"
|
|
143
|
-
echo "npm publish --access public"
|
|
144
|
-
echo "Isso tornará o SDK disponível no jsDelivr automaticamente"
|