@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
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Easyflow SDK Integration Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Este wrapper facilita a integração com plataformas low-code/no-code como:
|
|
5
|
-
* - Lovable.dev
|
|
6
|
-
* - Bubble
|
|
7
|
-
* - Webflow
|
|
8
|
-
* - Zapier
|
|
9
|
-
* - Make.com
|
|
10
|
-
* - Outras plataformas
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { EasyflowSDK } from '../sdk.mjs'
|
|
14
|
-
import { Validator } from './validator.mjs'
|
|
15
|
-
import { Sanitizer } from './sanitizer.mjs'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Wrapper de integração universal para plataformas low-code/no-code
|
|
19
|
-
*/
|
|
20
|
-
class EasyflowIntegrationWrapper {
|
|
21
|
-
constructor(config = {}) {
|
|
22
|
-
this.config = {
|
|
23
|
-
autoInitialize: true,
|
|
24
|
-
globalScope: 'window',
|
|
25
|
-
exposeGlobally: true,
|
|
26
|
-
enableDebug: false,
|
|
27
|
-
...config,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
this.sdk = null
|
|
31
|
-
this.isInitialized = false
|
|
32
|
-
|
|
33
|
-
if (this.config.autoInitialize) {
|
|
34
|
-
this.initialize()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Inicializa o wrapper e expõe funcionalidades globalmente
|
|
40
|
-
*/
|
|
41
|
-
initialize() {
|
|
42
|
-
try {
|
|
43
|
-
// Criar instância do SDK
|
|
44
|
-
if (!this.config.businessId) {
|
|
45
|
-
throw new Error('businessId é obrigatório para inicialização')
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.sdk = new EasyflowSDK(this.config.businessId)
|
|
49
|
-
this.isInitialized = true
|
|
50
|
-
|
|
51
|
-
// Expor funcionalidades globalmente se configurado
|
|
52
|
-
if (this.config.exposeGlobally) {
|
|
53
|
-
this.exposeToGlobalScope()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Log de sucesso
|
|
57
|
-
if (this.config.enableDebug) {
|
|
58
|
-
console.log(
|
|
59
|
-
'✅ Easyflow SDK Integration Wrapper inicializado com sucesso'
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return true
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error('❌ Erro ao inicializar Easyflow SDK:', error.message)
|
|
66
|
-
return false
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exposeToGlobalScope() {
|
|
71
|
-
const globalObj = this.getGlobalObject()
|
|
72
|
-
globalObj.EasyflowSDK = EasyflowSDK
|
|
73
|
-
globalObj.EasyflowSDKWrapper = this
|
|
74
|
-
globalObj.easyflow = this.sdk
|
|
75
|
-
globalObj.easyflowSDK = {
|
|
76
|
-
createCustomer: (data) => this.safeCall('createCustomer', data),
|
|
77
|
-
getCustomer: (id) => this.safeCall('getCustomer', id),
|
|
78
|
-
updateCustomer: (id, data) =>
|
|
79
|
-
this.safeCall('updateCustomer', id, data),
|
|
80
|
-
placeOrder: (offerId, data) =>
|
|
81
|
-
this.safeCall('placeOrder', offerId, data),
|
|
82
|
-
charge: (data) => this.safeCall('charge', data),
|
|
83
|
-
encrypt: (data) => this.safeCall('encrypt', data),
|
|
84
|
-
addCreditCard: (customerId, token) =>
|
|
85
|
-
this.safeCall('addCreditCard', customerId, token),
|
|
86
|
-
getCreditCard: (customerId, cardId) =>
|
|
87
|
-
this.safeCall('getCreditCard', customerId, cardId),
|
|
88
|
-
removeCreditCard: (customerId, cardId) =>
|
|
89
|
-
this.safeCall('removeCreditCard', customerId, cardId),
|
|
90
|
-
getOffer: (id) => this.safeCall('getOffer', id),
|
|
91
|
-
getOrder: (id) => this.safeCall('getOrder', id),
|
|
92
|
-
getPix: (orderId) => this.safeCall('getPix', orderId),
|
|
93
|
-
getBankBillet: (orderId) => this.safeCall('getBankBillet', orderId),
|
|
94
|
-
validate: {
|
|
95
|
-
email: (email) => Validator.validateEmail(email),
|
|
96
|
-
cpf: (cpf) => Validator.validateCPF(cpf),
|
|
97
|
-
cnpj: (cnpj) => Validator.validateCNPJ(cnpj),
|
|
98
|
-
phone: (phone) => Validator.validatePhone(phone),
|
|
99
|
-
address: (address) => Validator.validateAddress(address),
|
|
100
|
-
customer: (customer) => Validator.validateCustomer(customer),
|
|
101
|
-
},
|
|
102
|
-
sanitize: {
|
|
103
|
-
input: (input) => Sanitizer.sanitizeInput(input),
|
|
104
|
-
headers: (headers) => Sanitizer.sanitizeHeaders(headers),
|
|
105
|
-
customer: (customer) =>
|
|
106
|
-
Sanitizer.sanitizeObjectFields(customer),
|
|
107
|
-
},
|
|
108
|
-
getVersion: () => this.sdk.version,
|
|
109
|
-
getStatus: () => ({
|
|
110
|
-
initialized: this.isInitialized,
|
|
111
|
-
businessId: this.config.businessId,
|
|
112
|
-
}),
|
|
113
|
-
configure: (newConfig) => this.configure(newConfig),
|
|
114
|
-
}
|
|
115
|
-
globalObj.easyflowCallbacks = {
|
|
116
|
-
onCustomerCreated: null,
|
|
117
|
-
onPaymentProcessed: null,
|
|
118
|
-
onError: null,
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (this.config.enableDebug) {
|
|
122
|
-
console.log('Easyflow SDK exposto globalmente como "easyflowSDK"')
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Obtém o objeto global baseado na configuração
|
|
128
|
-
*/
|
|
129
|
-
getGlobalObject() {
|
|
130
|
-
switch (this.config.globalScope) {
|
|
131
|
-
case 'window':
|
|
132
|
-
return typeof window !== 'undefined' ? window : global
|
|
133
|
-
case 'global':
|
|
134
|
-
return typeof global !== 'undefined' ? global : window
|
|
135
|
-
default:
|
|
136
|
-
return typeof window !== 'undefined' ? window : global
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async safeCall(method, ...args) {
|
|
141
|
-
try {
|
|
142
|
-
if (!this.isInitialized || !this.sdk)
|
|
143
|
-
throw new Error(
|
|
144
|
-
'SDK não inicializado. Execute easyflowSDK.initialize() primeiro.'
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
if (!this.sdk[method])
|
|
148
|
-
throw new Error(`Método "${method}" não encontrado no SDK`)
|
|
149
|
-
|
|
150
|
-
const result = await this.sdk[method](...args)
|
|
151
|
-
this.executeCallbacks(method, result, null)
|
|
152
|
-
return {
|
|
153
|
-
success: true,
|
|
154
|
-
data: result,
|
|
155
|
-
error: null,
|
|
156
|
-
}
|
|
157
|
-
} catch (error) {
|
|
158
|
-
const errorResult = {
|
|
159
|
-
success: false,
|
|
160
|
-
data: null,
|
|
161
|
-
error: {
|
|
162
|
-
message: error.message,
|
|
163
|
-
code: error.code || 'UNKNOWN_ERROR',
|
|
164
|
-
type: error.constructor.name,
|
|
165
|
-
},
|
|
166
|
-
}
|
|
167
|
-
this.executeCallbacks(method, null, errorResult.error)
|
|
168
|
-
return errorResult
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
executeCallbacks(method, result, error) {
|
|
173
|
-
const globalObj = this.getGlobalObject()
|
|
174
|
-
if (error && globalObj.easyflowCallbacks.onError) {
|
|
175
|
-
try {
|
|
176
|
-
globalObj.easyflowCallbacks.onError(error, method)
|
|
177
|
-
} catch (callbackError) {
|
|
178
|
-
console.warn('Erro no callback onError:', callbackError)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (result && !error) {
|
|
182
|
-
if (
|
|
183
|
-
method === 'createCustomer' &&
|
|
184
|
-
globalObj.easyflowCallbacks.onCustomerCreated
|
|
185
|
-
) {
|
|
186
|
-
try {
|
|
187
|
-
globalObj.easyflowCallbacks.onCustomerCreated(result)
|
|
188
|
-
} catch (callbackError) {
|
|
189
|
-
console.warn(
|
|
190
|
-
'Erro no callback onCustomerCreated:',
|
|
191
|
-
callbackError
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
(method === 'placeOrder' || method === 'charge') &&
|
|
198
|
-
globalObj.easyflowCallbacks.onPaymentProcessed
|
|
199
|
-
) {
|
|
200
|
-
try {
|
|
201
|
-
globalObj.easyflowCallbacks.onPaymentProcessed(
|
|
202
|
-
result,
|
|
203
|
-
method
|
|
204
|
-
)
|
|
205
|
-
} catch (callbackError) {
|
|
206
|
-
console.warn(
|
|
207
|
-
'Erro no callback onPaymentProcessed:',
|
|
208
|
-
callbackError
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Configura callbacks para eventos
|
|
217
|
-
*/
|
|
218
|
-
on(event, callback) {
|
|
219
|
-
const globalObj = this.getGlobalObject()
|
|
220
|
-
|
|
221
|
-
switch (event) {
|
|
222
|
-
case 'customerCreated':
|
|
223
|
-
globalObj.easyflowCallbacks.onCustomerCreated = callback
|
|
224
|
-
break
|
|
225
|
-
case 'paymentProcessed':
|
|
226
|
-
globalObj.easyflowCallbacks.onPaymentProcessed = callback
|
|
227
|
-
break
|
|
228
|
-
case 'error':
|
|
229
|
-
globalObj.easyflowCallbacks.onError = callback
|
|
230
|
-
break
|
|
231
|
-
default:
|
|
232
|
-
console.warn(`Evento desconhecido: ${event}`)
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Configura novas opções
|
|
238
|
-
*/
|
|
239
|
-
configure(newConfig) {
|
|
240
|
-
this.config = { ...this.config, ...newConfig }
|
|
241
|
-
if (this.config.enableDebug)
|
|
242
|
-
console.log('Configuração atualizada:', this.config)
|
|
243
|
-
return this.config
|
|
244
|
-
}
|
|
245
|
-
getStatus() {
|
|
246
|
-
return {
|
|
247
|
-
initialized: this.isInitialized,
|
|
248
|
-
businessId: this.config.businessId,
|
|
249
|
-
sdkVersion: this.sdk?.version || 'N/A',
|
|
250
|
-
wrapperVersion: '1.0.0',
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function initializeEasyflow(config) {
|
|
256
|
-
return new EasyflowIntegrationWrapper(config)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function validateEasyflowData(type, data) {
|
|
260
|
-
try {
|
|
261
|
-
switch (type) {
|
|
262
|
-
case 'email':
|
|
263
|
-
return Validator.validateEmail(data)
|
|
264
|
-
case 'cpf':
|
|
265
|
-
return Validator.validateCPF(data)
|
|
266
|
-
case 'cnpj':
|
|
267
|
-
return Validator.validateCNPJ(data)
|
|
268
|
-
case 'phone':
|
|
269
|
-
return Validator.validatePhone(data)
|
|
270
|
-
case 'address':
|
|
271
|
-
return Validator.validateAddress(data)
|
|
272
|
-
case 'customer':
|
|
273
|
-
return Validator.validateCustomer(data)
|
|
274
|
-
default:
|
|
275
|
-
throw new Error(`Tipo de validação desconhecido: ${type}`)
|
|
276
|
-
}
|
|
277
|
-
} catch (error) {
|
|
278
|
-
return {
|
|
279
|
-
valid: false,
|
|
280
|
-
error: error.message,
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export { EasyflowIntegrationWrapper, initializeEasyflow, validateEasyflowData }
|
package/libs/logger.mjs
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secure Logger for Easyflow SDK
|
|
3
|
-
*
|
|
4
|
-
* This class provides secure logging functionality that automatically
|
|
5
|
-
* redacts sensitive information like credit card numbers, tokens, and passwords.
|
|
6
|
-
*
|
|
7
|
-
* @class SecureLogger
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
*/
|
|
10
|
-
export class SecureLogger {
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new SecureLogger instance
|
|
13
|
-
*
|
|
14
|
-
* @param {string} [level='error'] - Logging level ('error', 'warn', 'info', 'debug')
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```javascript
|
|
18
|
-
* const logger = new SecureLogger('info');
|
|
19
|
-
* logger.info('SDK initialized', { businessId: '123' });
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
constructor(level = 'error') {
|
|
23
|
-
this.level = level
|
|
24
|
-
this.levels = { error: 0, warn: 1, info: 2, debug: 3 }
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal logging method that handles level filtering and data sanitization
|
|
29
|
-
*
|
|
30
|
-
* @param {string} level - Log level ('error', 'warn', 'info', 'debug')
|
|
31
|
-
* @param {string} message - Log message
|
|
32
|
-
* @param {*} [data=null] - Additional data to log (will be sanitized)
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
log(level, message, data = null) {
|
|
37
|
-
if (this.levels[level] <= this.levels[this.level]) {
|
|
38
|
-
const sanitizedData = this.sanitizeData(data)
|
|
39
|
-
const logMessage = `[EasyflowSDK:${level.toUpperCase()}] ${message}`
|
|
40
|
-
|
|
41
|
-
if (level === 'error') {
|
|
42
|
-
console.error(logMessage, sanitizedData)
|
|
43
|
-
} else if (level === 'warn') {
|
|
44
|
-
console.warn(logMessage, sanitizedData)
|
|
45
|
-
} else {
|
|
46
|
-
console.log(logMessage, sanitizedData)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sanitizes data by redacting sensitive information
|
|
53
|
-
*
|
|
54
|
-
* This method automatically detects and redacts sensitive fields like
|
|
55
|
-
* credit card numbers, tokens, passwords, and other sensitive data.
|
|
56
|
-
* It also truncates long strings to prevent log flooding.
|
|
57
|
-
*
|
|
58
|
-
* @param {*} data - Data to sanitize
|
|
59
|
-
* @returns {*} Sanitized data with sensitive information redacted
|
|
60
|
-
*
|
|
61
|
-
* @private
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```javascript
|
|
65
|
-
* const sanitized = logger.sanitizeData({
|
|
66
|
-
* cardNumber: '4111111111111111',
|
|
67
|
-
* token: 'secret-token',
|
|
68
|
-
* message: 'Very long message...'
|
|
69
|
-
* });
|
|
70
|
-
* // Returns: { cardNumber: '[REDACTED]', token: '[REDACTED]', message: 'Very long message...' }
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
sanitizeData(data) {
|
|
74
|
-
if (!data) return null
|
|
75
|
-
|
|
76
|
-
const sensitive = [
|
|
77
|
-
'token',
|
|
78
|
-
'cardNumber',
|
|
79
|
-
'password',
|
|
80
|
-
'cvv',
|
|
81
|
-
'number',
|
|
82
|
-
'key',
|
|
83
|
-
'secret',
|
|
84
|
-
'apiKey',
|
|
85
|
-
'private',
|
|
86
|
-
'credential',
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
return JSON.parse(
|
|
90
|
-
JSON.stringify(data, (key, value) => {
|
|
91
|
-
if (sensitive.some((s) => key.toLowerCase().includes(s))) {
|
|
92
|
-
return '[REDACTED]'
|
|
93
|
-
}
|
|
94
|
-
if (typeof value === 'string' && value.length > 100) {
|
|
95
|
-
return `${value.substring(0, 100)}...`
|
|
96
|
-
}
|
|
97
|
-
return value
|
|
98
|
-
})
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Logs an error message
|
|
104
|
-
*
|
|
105
|
-
* @param {string} message - Error message
|
|
106
|
-
* @param {*} [data=null] - Additional error data (will be sanitized)
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```javascript
|
|
110
|
-
* logger.error('Failed to process payment', { orderId: '123', error: 'Network timeout' });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
error(message, data = null) {
|
|
114
|
-
this.log('error', message, data)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Logs a warning message
|
|
119
|
-
*
|
|
120
|
-
* @param {string} message - Warning message
|
|
121
|
-
* @param {*} [data=null] - Additional warning data (will be sanitized)
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```javascript
|
|
125
|
-
* logger.warn('Rate limit approaching', { requests: 25, limit: 30 });
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
warn(message, data = null) {
|
|
129
|
-
this.log('warn', message, data)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Logs an info message
|
|
134
|
-
*
|
|
135
|
-
* @param {string} message - Info message
|
|
136
|
-
* @param {*} [data=null] - Additional info data (will be sanitized)
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```javascript
|
|
140
|
-
* logger.info('Order placed successfully', { orderId: '123', amount: 1000 });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
info(message, data = null) {
|
|
144
|
-
this.log('info', message, data)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Logs a debug message
|
|
149
|
-
*
|
|
150
|
-
* @param {string} message - Debug message
|
|
151
|
-
* @param {*} [data=null] - Additional debug data (will be sanitized)
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```javascript
|
|
155
|
-
* logger.debug('API request details', { url: '/api/charge', method: 'POST' });
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
debug(message, data = null) {
|
|
159
|
-
this.log('debug', message, data)
|
|
160
|
-
}
|
|
161
|
-
}
|