@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/libs/validator.spec.js
DELETED
|
@@ -1,615 +0,0 @@
|
|
|
1
|
-
import { describe, expect, jest, test } from '@jest/globals'
|
|
2
|
-
import { Validator } from './validator.mjs'
|
|
3
|
-
import { EasyflowError } from './errors.mjs'
|
|
4
|
-
|
|
5
|
-
jest.mock('./exception-handler.mjs', () => ({
|
|
6
|
-
throwsError: jest.fn((error) => {
|
|
7
|
-
throw error
|
|
8
|
-
}),
|
|
9
|
-
}))
|
|
10
|
-
|
|
11
|
-
describe('Validator', () => {
|
|
12
|
-
describe('validateEmail', () => {
|
|
13
|
-
test('should validate correct email addresses', () => {
|
|
14
|
-
const validEmails = [
|
|
15
|
-
'user@example.com',
|
|
16
|
-
'user.name@example.com',
|
|
17
|
-
'user+tag@example.co.uk',
|
|
18
|
-
'123@example.org',
|
|
19
|
-
'user@subdomain.example.com',
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
validEmails.forEach((email) => {
|
|
23
|
-
expect(() => Validator.validateEmail(email)).not.toThrow()
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('should reject invalid email addresses', () => {
|
|
28
|
-
const invalidEmails = [
|
|
29
|
-
'invalid-email',
|
|
30
|
-
'@example.com',
|
|
31
|
-
'user@',
|
|
32
|
-
'user..name@example.com',
|
|
33
|
-
'.user@example.com',
|
|
34
|
-
'user@example.com.',
|
|
35
|
-
'user name@example.com',
|
|
36
|
-
'user@example..com',
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
invalidEmails.forEach((email) => {
|
|
40
|
-
expect(() => Validator.validateEmail(email)).toThrow(
|
|
41
|
-
EasyflowError
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test('should reject emails that are too long', () => {
|
|
47
|
-
const longEmail = 'a'.repeat(250) + '@example.com'
|
|
48
|
-
expect(() => Validator.validateEmail(longEmail)).toThrow(
|
|
49
|
-
EasyflowError
|
|
50
|
-
)
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('validateCPF', () => {
|
|
55
|
-
test('should validate correct CPFs', () => {
|
|
56
|
-
const validCPFs = ['12345678909', '11144477735']
|
|
57
|
-
|
|
58
|
-
validCPFs.forEach((cpf) => {
|
|
59
|
-
expect(() => Validator.validateCPF(cpf)).not.toThrow()
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('should reject invalid CPFs', () => {
|
|
64
|
-
const invalidCPFs = [
|
|
65
|
-
'12345678910',
|
|
66
|
-
'11111111111',
|
|
67
|
-
'00000000000',
|
|
68
|
-
'123',
|
|
69
|
-
'123456789012',
|
|
70
|
-
'abc123def45',
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
invalidCPFs.forEach((cpf) => {
|
|
74
|
-
expect(() => Validator.validateCPF(cpf)).toThrow(EasyflowError)
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
describe('validateCNPJ', () => {
|
|
80
|
-
test('should validate correct CNPJs', () => {
|
|
81
|
-
const validCNPJs = ['11222333000181', '00000000000191']
|
|
82
|
-
|
|
83
|
-
validCNPJs.forEach((cnpj) => {
|
|
84
|
-
expect(() => Validator.validateCNPJ(cnpj)).not.toThrow()
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('should reject invalid CNPJs', () => {
|
|
89
|
-
const invalidCNPJs = [
|
|
90
|
-
'11222333000182',
|
|
91
|
-
'11111111111111',
|
|
92
|
-
'00000000000000',
|
|
93
|
-
'123',
|
|
94
|
-
'123456789012345',
|
|
95
|
-
'abc123def45678',
|
|
96
|
-
]
|
|
97
|
-
|
|
98
|
-
invalidCNPJs.forEach((cnpj) => {
|
|
99
|
-
expect(() => Validator.validateCNPJ(cnpj)).toThrow(
|
|
100
|
-
EasyflowError
|
|
101
|
-
)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
describe('validateLegalDocument', () => {
|
|
107
|
-
test('should validate correct legal documents', () => {
|
|
108
|
-
const validDocuments = [
|
|
109
|
-
{ type: 'CPF', number: '12345678909' },
|
|
110
|
-
{ type: 'CNPJ', number: '11222333000181' },
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
validDocuments.forEach((doc) => {
|
|
114
|
-
expect(() => Validator.validateLegalDocument(doc)).not.toThrow()
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test('should reject documents with non-digit numbers', () => {
|
|
119
|
-
expect(() =>
|
|
120
|
-
Validator.validateLegalDocument({
|
|
121
|
-
type: 'CPF',
|
|
122
|
-
number: '123.456.789-09',
|
|
123
|
-
})
|
|
124
|
-
).toThrow(EasyflowError)
|
|
125
|
-
|
|
126
|
-
expect(() =>
|
|
127
|
-
Validator.validateLegalDocument({
|
|
128
|
-
type: 'CNPJ',
|
|
129
|
-
number: '11.222.333/0001-81',
|
|
130
|
-
})
|
|
131
|
-
).toThrow(EasyflowError)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
test('should reject invalid document types', () => {
|
|
135
|
-
expect(() =>
|
|
136
|
-
Validator.validateLegalDocument({
|
|
137
|
-
type: 'INVALID',
|
|
138
|
-
number: '12345678909',
|
|
139
|
-
})
|
|
140
|
-
).toThrow(EasyflowError)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
test('should reject missing fields', () => {
|
|
144
|
-
expect(() =>
|
|
145
|
-
Validator.validateLegalDocument({
|
|
146
|
-
type: 'CPF',
|
|
147
|
-
})
|
|
148
|
-
).toThrow(EasyflowError)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
describe('validatePhone', () => {
|
|
153
|
-
test('should validate correct phone numbers', () => {
|
|
154
|
-
const validPhones = [
|
|
155
|
-
{
|
|
156
|
-
areaCode: '+55',
|
|
157
|
-
ddd: '11',
|
|
158
|
-
number: '999999999',
|
|
159
|
-
isMobile: true,
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
areaCode: '+1',
|
|
163
|
-
ddd: '21',
|
|
164
|
-
number: '12345678',
|
|
165
|
-
isMobile: false,
|
|
166
|
-
},
|
|
167
|
-
]
|
|
168
|
-
|
|
169
|
-
validPhones.forEach((phone) => {
|
|
170
|
-
expect(() => Validator.validatePhone(phone)).not.toThrow()
|
|
171
|
-
})
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
test('should reject invalid phone numbers', () => {
|
|
175
|
-
const invalidPhones = [
|
|
176
|
-
{
|
|
177
|
-
areaCode: '55',
|
|
178
|
-
ddd: '11',
|
|
179
|
-
number: '999999999',
|
|
180
|
-
isMobile: true,
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
areaCode: '+55',
|
|
184
|
-
ddd: '1',
|
|
185
|
-
number: '999999999',
|
|
186
|
-
isMobile: true,
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
areaCode: '+55',
|
|
190
|
-
ddd: '11',
|
|
191
|
-
number: '123',
|
|
192
|
-
isMobile: true,
|
|
193
|
-
},
|
|
194
|
-
]
|
|
195
|
-
|
|
196
|
-
invalidPhones.forEach((phone) => {
|
|
197
|
-
expect(() => Validator.validatePhone(phone)).toThrow(
|
|
198
|
-
EasyflowError
|
|
199
|
-
)
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
describe('validateAddress', () => {
|
|
205
|
-
test('should validate correct addresses', () => {
|
|
206
|
-
const validAddress = {
|
|
207
|
-
zipCode: '01234567',
|
|
208
|
-
street: 'Main Street',
|
|
209
|
-
complement: 'Apt 123',
|
|
210
|
-
neighborhood: 'Downtown',
|
|
211
|
-
city: 'São Paulo',
|
|
212
|
-
state: 'SP',
|
|
213
|
-
number: '123',
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
expect(() => Validator.validateAddress(validAddress)).not.toThrow()
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
test('should reject invalid addresses', () => {
|
|
220
|
-
const invalidAddresses = [
|
|
221
|
-
{
|
|
222
|
-
zipCode: '123',
|
|
223
|
-
street: 'Main Street',
|
|
224
|
-
neighborhood: 'Downtown',
|
|
225
|
-
city: 'São Paulo',
|
|
226
|
-
state: 'SP',
|
|
227
|
-
number: '123',
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
zipCode: '01234-567',
|
|
231
|
-
street: 'Main Street',
|
|
232
|
-
neighborhood: 'Downtown',
|
|
233
|
-
city: 'São Paulo',
|
|
234
|
-
state: 'SP',
|
|
235
|
-
number: '123',
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
zipCode: '01234567',
|
|
239
|
-
street: 'Ma',
|
|
240
|
-
neighborhood: 'Downtown',
|
|
241
|
-
city: 'São Paulo',
|
|
242
|
-
state: 'SP',
|
|
243
|
-
number: '123',
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
zipCode: '01234567',
|
|
247
|
-
street: 'Main Street',
|
|
248
|
-
neighborhood: 'Downtown',
|
|
249
|
-
city: 'São Paulo',
|
|
250
|
-
state: 'INVALID',
|
|
251
|
-
number: '123',
|
|
252
|
-
},
|
|
253
|
-
]
|
|
254
|
-
|
|
255
|
-
invalidAddresses.forEach((address) => {
|
|
256
|
-
expect(() => Validator.validateAddress(address)).toThrow(
|
|
257
|
-
EasyflowError
|
|
258
|
-
)
|
|
259
|
-
})
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
describe('validateCustomer', () => {
|
|
264
|
-
test('should validate correct customer data', () => {
|
|
265
|
-
const validCustomer = {
|
|
266
|
-
name: 'John Doe',
|
|
267
|
-
email: 'john@example.com',
|
|
268
|
-
document: { type: 'CPF', number: '12345678909' },
|
|
269
|
-
phone: {
|
|
270
|
-
areaCode: '+55',
|
|
271
|
-
ddd: '11',
|
|
272
|
-
number: '999999999',
|
|
273
|
-
isMobile: true,
|
|
274
|
-
},
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
expect(() =>
|
|
278
|
-
Validator.validateCustomer(validCustomer)
|
|
279
|
-
).not.toThrow()
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
test('should reject invalid customer data', () => {
|
|
283
|
-
const invalidCustomer = {
|
|
284
|
-
name: 'J',
|
|
285
|
-
email: 'invalid-email',
|
|
286
|
-
document: { type: 'CPF', number: '12345678909' },
|
|
287
|
-
phone: {
|
|
288
|
-
areaCode: '+55',
|
|
289
|
-
ddd: '11',
|
|
290
|
-
number: '999999999',
|
|
291
|
-
isMobile: true,
|
|
292
|
-
},
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
expect(() => Validator.validateCustomer(invalidCustomer)).toThrow(
|
|
296
|
-
EasyflowError
|
|
297
|
-
)
|
|
298
|
-
})
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
describe('validatePagination', () => {
|
|
302
|
-
test('should validate correct pagination parameters', () => {
|
|
303
|
-
expect(() => Validator.validatePagination(1, 10)).not.toThrow()
|
|
304
|
-
expect(() => Validator.validatePagination(5, 50)).not.toThrow()
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
test('should reject invalid pagination parameters', () => {
|
|
308
|
-
expect(() => Validator.validatePagination(0, 10)).toThrow(
|
|
309
|
-
EasyflowError
|
|
310
|
-
)
|
|
311
|
-
expect(() => Validator.validatePagination(1, 0)).toThrow(
|
|
312
|
-
EasyflowError
|
|
313
|
-
)
|
|
314
|
-
expect(() => Validator.validatePagination(1, 101)).toThrow(
|
|
315
|
-
EasyflowError
|
|
316
|
-
)
|
|
317
|
-
})
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
describe('validateBusinessId', () => {
|
|
321
|
-
test('should validate correct business IDs', () => {
|
|
322
|
-
const validBusinessIds = [
|
|
323
|
-
'business-123',
|
|
324
|
-
'my-business',
|
|
325
|
-
'company-456-789',
|
|
326
|
-
]
|
|
327
|
-
|
|
328
|
-
validBusinessIds.forEach((id) => {
|
|
329
|
-
expect(() => Validator.validateBusinessId(id)).not.toThrow()
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
test('should reject invalid business IDs', () => {
|
|
334
|
-
const invalidBusinessIds = [
|
|
335
|
-
'ab',
|
|
336
|
-
'-business',
|
|
337
|
-
'business-',
|
|
338
|
-
'business--123',
|
|
339
|
-
'business_123',
|
|
340
|
-
'business.123',
|
|
341
|
-
]
|
|
342
|
-
|
|
343
|
-
invalidBusinessIds.forEach((id) => {
|
|
344
|
-
expect(() => Validator.validateBusinessId(id)).toThrow(
|
|
345
|
-
EasyflowError
|
|
346
|
-
)
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
describe('validateCreditCardToken', () => {
|
|
352
|
-
test('should validate correct credit card tokens', () => {
|
|
353
|
-
const validTokens = [
|
|
354
|
-
'a'.repeat(32),
|
|
355
|
-
'a'.repeat(64),
|
|
356
|
-
'a'.repeat(128),
|
|
357
|
-
'abc123_-def456'.repeat(3),
|
|
358
|
-
]
|
|
359
|
-
|
|
360
|
-
validTokens.forEach((token) => {
|
|
361
|
-
expect(() =>
|
|
362
|
-
Validator.validateCreditCardToken(token)
|
|
363
|
-
).not.toThrow()
|
|
364
|
-
})
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
test('should reject invalid credit card tokens', () => {
|
|
368
|
-
const invalidTokens = [
|
|
369
|
-
'a'.repeat(31),
|
|
370
|
-
'a'.repeat(129),
|
|
371
|
-
'abc@123',
|
|
372
|
-
'abc 123',
|
|
373
|
-
'abc.123',
|
|
374
|
-
]
|
|
375
|
-
|
|
376
|
-
invalidTokens.forEach((token) => {
|
|
377
|
-
expect(() => Validator.validateCreditCardToken(token)).toThrow(
|
|
378
|
-
EasyflowError
|
|
379
|
-
)
|
|
380
|
-
})
|
|
381
|
-
})
|
|
382
|
-
})
|
|
383
|
-
|
|
384
|
-
describe('validateOrderId', () => {
|
|
385
|
-
test('should validate correct order IDs', () => {
|
|
386
|
-
const validOrderIds = [
|
|
387
|
-
// UUID v4 examples (strict v4)
|
|
388
|
-
'f47ac10b-58cc-4372-a567-0e02b2c3d479',
|
|
389
|
-
'a8098c1a-f86e-4f4c-a9f5-0b8add7c7f3d',
|
|
390
|
-
'16fd2706-8baf-433b-82eb-8c7fada847da',
|
|
391
|
-
'58c8f2e0-3d22-4b5d-98ab-9c0a1f2b3c4d',
|
|
392
|
-
// UUID v7 examples
|
|
393
|
-
'01890b24-2d7f-7c3f-8f1a-123456789abc',
|
|
394
|
-
'01890b24-2d7f-7c3f-9f1a-123456789abc',
|
|
395
|
-
'01890b24-2d7f-7c3f-af1a-123456789abc',
|
|
396
|
-
'01890b24-2d7f-7c3f-bf1a-123456789abc',
|
|
397
|
-
// MongoDB ObjectId examples
|
|
398
|
-
'507f1f77bcf86cd799439011',
|
|
399
|
-
'507f1f77bcf86cd799439012',
|
|
400
|
-
'507f1f77bcf86cd799439013',
|
|
401
|
-
'507f1f77bcf86cd799439014',
|
|
402
|
-
]
|
|
403
|
-
|
|
404
|
-
validOrderIds.forEach((id) => {
|
|
405
|
-
expect(() => Validator.validateOrderId(id)).not.toThrow()
|
|
406
|
-
})
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
test('should reject invalid order IDs', () => {
|
|
410
|
-
const invalidOrderIds = [
|
|
411
|
-
// Old format patterns
|
|
412
|
-
'order-1234567890123456',
|
|
413
|
-
'order-abcdefghijklmnop',
|
|
414
|
-
// Invalid UUIDs
|
|
415
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
416
|
-
'550e8400-e29b-41d4-a716-4466554400000',
|
|
417
|
-
'550e8400-e29b-41d4-a716-44665544000g',
|
|
418
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
419
|
-
// Invalid UUID v7 (wrong version)
|
|
420
|
-
'01890b24-2d7f-8c3f-8f1a-123456789abc',
|
|
421
|
-
'01890b24-2d7f-6c3f-8f1a-123456789abc',
|
|
422
|
-
// Invalid MongoDB ObjectId
|
|
423
|
-
'507f1f77bcf86cd79943901',
|
|
424
|
-
'507f1f77bcf86cd7994390111',
|
|
425
|
-
'507f1f77bcf86cd79943901g',
|
|
426
|
-
// Other invalid formats
|
|
427
|
-
'invalid-uuid',
|
|
428
|
-
'12345678-1234-1234-1234-123456789012',
|
|
429
|
-
'not-an-id',
|
|
430
|
-
'12345',
|
|
431
|
-
'abc-def-ghi',
|
|
432
|
-
]
|
|
433
|
-
|
|
434
|
-
invalidOrderIds.forEach((id) => {
|
|
435
|
-
expect(() => Validator.validateOrderId(id)).toThrow(
|
|
436
|
-
EasyflowError
|
|
437
|
-
)
|
|
438
|
-
})
|
|
439
|
-
})
|
|
440
|
-
})
|
|
441
|
-
|
|
442
|
-
describe('validateOfferId', () => {
|
|
443
|
-
test('should validate correct offer IDs', () => {
|
|
444
|
-
const validOfferIds = [
|
|
445
|
-
// UUID v4 examples (strict v4)
|
|
446
|
-
'f47ac10b-58cc-4372-a567-0e02b2c3d479',
|
|
447
|
-
'a8098c1a-f86e-4f4c-a9f5-0b8add7c7f3d',
|
|
448
|
-
'16fd2706-8baf-433b-82eb-8c7fada847da',
|
|
449
|
-
'58c8f2e0-3d22-4b5d-98ab-9c0a1f2b3c4d',
|
|
450
|
-
// UUID v7 examples
|
|
451
|
-
'01890b24-2d7f-7c3f-8f1a-123456789abc',
|
|
452
|
-
'01890b24-2d7f-7c3f-9f1a-123456789abc',
|
|
453
|
-
'01890b24-2d7f-7c3f-af1a-123456789abc',
|
|
454
|
-
'01890b24-2d7f-7c3f-bf1a-123456789abc',
|
|
455
|
-
// MongoDB ObjectId examples
|
|
456
|
-
'507f1f77bcf86cd799439011',
|
|
457
|
-
'507f1f77bcf86cd799439012',
|
|
458
|
-
'507f1f77bcf86cd799439013',
|
|
459
|
-
'507f1f77bcf86cd799439014',
|
|
460
|
-
]
|
|
461
|
-
|
|
462
|
-
validOfferIds.forEach((id) => {
|
|
463
|
-
expect(() => Validator.validateOfferId(id)).not.toThrow()
|
|
464
|
-
})
|
|
465
|
-
})
|
|
466
|
-
|
|
467
|
-
test('should reject invalid offer IDs', () => {
|
|
468
|
-
const invalidOfferIds = [
|
|
469
|
-
// Old format patterns
|
|
470
|
-
'offer-1234567890123456',
|
|
471
|
-
'offer-abcdefghijklmnop',
|
|
472
|
-
// Invalid UUIDs
|
|
473
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
474
|
-
'550e8400-e29b-41d4-a716-4466554400000',
|
|
475
|
-
'550e8400-e29b-41d4-a716-44665544000g',
|
|
476
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
477
|
-
// Invalid UUID v7 (wrong version)
|
|
478
|
-
'01890b24-2d7f-8c3f-8f1a-123456789abc',
|
|
479
|
-
'01890b24-2d7f-6c3f-8f1a-123456789abc',
|
|
480
|
-
// Invalid MongoDB ObjectId
|
|
481
|
-
'507f1f77bcf86cd79943901',
|
|
482
|
-
'507f1f77bcf86cd7994390111',
|
|
483
|
-
'507f1f77bcf86cd79943901g',
|
|
484
|
-
// Other invalid formats
|
|
485
|
-
'invalid-uuid',
|
|
486
|
-
'12345678-1234-1234-1234-123456789012',
|
|
487
|
-
'not-an-id',
|
|
488
|
-
'12345',
|
|
489
|
-
'abc-def-ghi',
|
|
490
|
-
]
|
|
491
|
-
|
|
492
|
-
invalidOfferIds.forEach((id) => {
|
|
493
|
-
expect(() => Validator.validateOfferId(id)).toThrow(
|
|
494
|
-
EasyflowError
|
|
495
|
-
)
|
|
496
|
-
})
|
|
497
|
-
})
|
|
498
|
-
})
|
|
499
|
-
|
|
500
|
-
describe('validateCustomerId', () => {
|
|
501
|
-
test('should validate correct customer IDs', () => {
|
|
502
|
-
const validCustomerIds = [
|
|
503
|
-
// UUID v4 examples (strict v4)
|
|
504
|
-
'f47ac10b-58cc-4372-a567-0e02b2c3d479',
|
|
505
|
-
'a8098c1a-f86e-4f4c-a9f5-0b8add7c7f3d',
|
|
506
|
-
'16fd2706-8baf-433b-82eb-8c7fada847da',
|
|
507
|
-
'58c8f2e0-3d22-4b5d-98ab-9c0a1f2b3c4d',
|
|
508
|
-
// UUID v7 examples
|
|
509
|
-
'01890b24-2d7f-7c3f-8f1a-123456789abc',
|
|
510
|
-
'01890b24-2d7f-7c3f-9f1a-123456789abc',
|
|
511
|
-
'01890b24-2d7f-7c3f-af1a-123456789abc',
|
|
512
|
-
'01890b24-2d7f-7c3f-bf1a-123456789abc',
|
|
513
|
-
// MongoDB ObjectId examples
|
|
514
|
-
'507f1f77bcf86cd799439011',
|
|
515
|
-
'507f1f77bcf86cd799439012',
|
|
516
|
-
'507f1f77bcf86cd799439013',
|
|
517
|
-
'507f1f77bcf86cd799439014',
|
|
518
|
-
]
|
|
519
|
-
|
|
520
|
-
validCustomerIds.forEach((id) => {
|
|
521
|
-
expect(() => Validator.validateCustomerId(id)).not.toThrow()
|
|
522
|
-
})
|
|
523
|
-
})
|
|
524
|
-
|
|
525
|
-
test('should reject invalid customer IDs', () => {
|
|
526
|
-
const invalidCustomerIds = [
|
|
527
|
-
// Old format patterns
|
|
528
|
-
'customer-1234567890123456',
|
|
529
|
-
'customer-abcdefghijklmnop',
|
|
530
|
-
// Invalid UUIDs
|
|
531
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
532
|
-
'550e8400-e29b-41d4-a716-4466554400000',
|
|
533
|
-
'550e8400-e29b-41d4-a716-44665544000g',
|
|
534
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
535
|
-
// Invalid UUID v7 (wrong version)
|
|
536
|
-
'01890b24-2d7f-8c3f-8f1a-123456789abc',
|
|
537
|
-
'01890b24-2d7f-6c3f-8f1a-123456789abc',
|
|
538
|
-
// Invalid MongoDB ObjectId
|
|
539
|
-
'507f1f77bcf86cd79943901',
|
|
540
|
-
'507f1f77bcf86cd7994390111',
|
|
541
|
-
'507f1f77bcf86cd79943901g',
|
|
542
|
-
// Other invalid formats
|
|
543
|
-
'invalid-uuid',
|
|
544
|
-
'12345678-1234-1234-1234-123456789012',
|
|
545
|
-
'not-an-id',
|
|
546
|
-
'12345',
|
|
547
|
-
'abc-def-ghi',
|
|
548
|
-
]
|
|
549
|
-
|
|
550
|
-
invalidCustomerIds.forEach((id) => {
|
|
551
|
-
expect(() => Validator.validateCustomerId(id)).toThrow(
|
|
552
|
-
EasyflowError
|
|
553
|
-
)
|
|
554
|
-
})
|
|
555
|
-
})
|
|
556
|
-
})
|
|
557
|
-
|
|
558
|
-
describe('validateCreditCardId', () => {
|
|
559
|
-
test('should validate correct credit card IDs', () => {
|
|
560
|
-
const validCreditCardIds = [
|
|
561
|
-
// UUID v4 examples (strict v4)
|
|
562
|
-
'f47ac10b-58cc-4372-a567-0e02b2c3d479',
|
|
563
|
-
'a8098c1a-f86e-4f4c-a9f5-0b8add7c7f3d',
|
|
564
|
-
'16fd2706-8baf-433b-82eb-8c7fada847da',
|
|
565
|
-
'58c8f2e0-3d22-4b5d-98ab-9c0a1f2b3c4d',
|
|
566
|
-
// UUID v7 examples
|
|
567
|
-
'01890b24-2d7f-7c3f-8f1a-123456789abc',
|
|
568
|
-
'01890b24-2d7f-7c3f-9f1a-123456789abc',
|
|
569
|
-
'01890b24-2d7f-7c3f-af1a-123456789abc',
|
|
570
|
-
'01890b24-2d7f-7c3f-bf1a-123456789abc',
|
|
571
|
-
// MongoDB ObjectId examples
|
|
572
|
-
'507f1f77bcf86cd799439011',
|
|
573
|
-
'507f1f77bcf86cd799439012',
|
|
574
|
-
'507f1f77bcf86cd799439013',
|
|
575
|
-
'507f1f77bcf86cd799439014',
|
|
576
|
-
]
|
|
577
|
-
|
|
578
|
-
validCreditCardIds.forEach((id) => {
|
|
579
|
-
expect(() => Validator.validateCreditCardId(id)).not.toThrow()
|
|
580
|
-
})
|
|
581
|
-
})
|
|
582
|
-
|
|
583
|
-
test('should reject invalid credit card IDs', () => {
|
|
584
|
-
const invalidCreditCardIds = [
|
|
585
|
-
// Old format patterns
|
|
586
|
-
'card-1234567890123456',
|
|
587
|
-
'credit-card-abcdefghijklmnop',
|
|
588
|
-
// Invalid UUIDs
|
|
589
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
590
|
-
'550e8400-e29b-41d4-a716-4466554400000',
|
|
591
|
-
'550e8400-e29b-41d4-a716-44665544000g',
|
|
592
|
-
'550e8400-e29b-41d4-a716-44665544000',
|
|
593
|
-
// Invalid UUID v7 (wrong version)
|
|
594
|
-
'01890b24-2d7f-8c3f-8f1a-123456789abc',
|
|
595
|
-
'01890b24-2d7f-6c3f-8f1a-123456789abc',
|
|
596
|
-
// Invalid MongoDB ObjectId
|
|
597
|
-
'507f1f77bcf86cd79943901',
|
|
598
|
-
'507f1f77bcf86cd7994390111',
|
|
599
|
-
'507f1f77bcf86cd79943901g',
|
|
600
|
-
// Other invalid formats
|
|
601
|
-
'invalid-uuid',
|
|
602
|
-
'12345678-1234-1234-1234-123456789012',
|
|
603
|
-
'not-an-id',
|
|
604
|
-
'12345',
|
|
605
|
-
'abc-def-ghi',
|
|
606
|
-
]
|
|
607
|
-
|
|
608
|
-
invalidCreditCardIds.forEach((id) => {
|
|
609
|
-
expect(() => Validator.validateCreditCardId(id)).toThrow(
|
|
610
|
-
EasyflowError
|
|
611
|
-
)
|
|
612
|
-
})
|
|
613
|
-
})
|
|
614
|
-
})
|
|
615
|
-
})
|
package/mocks/offer.mock.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/* OFFER MODEL MOCK
|
|
2
|
-
{
|
|
3
|
-
id: string,
|
|
4
|
-
business: {
|
|
5
|
-
id: string,
|
|
6
|
-
owner: {
|
|
7
|
-
id: string,
|
|
8
|
-
name: string,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
checkoutTemplate: {
|
|
12
|
-
id: string,
|
|
13
|
-
createdAt: string,
|
|
14
|
-
isDefault: boolean,
|
|
15
|
-
color: 'black-white' | 'blue-theme' | 'green-theme' | 'red-theme' | 'purple-theme' | 'yellow-theme',
|
|
16
|
-
theme: 'light-theme' | 'dark-theme',
|
|
17
|
-
name: string,
|
|
18
|
-
requestAddress: boolean,
|
|
19
|
-
requestDeliveryAddress: boolean,
|
|
20
|
-
showSellerName: boolean,
|
|
21
|
-
acceptNaturalPersonBuyer: boolean,
|
|
22
|
-
acceptCorporationBuyer: boolean,
|
|
23
|
-
creditCard: {
|
|
24
|
-
defaultInstallments?: number | null,
|
|
25
|
-
maxInstallments?: number | null,
|
|
26
|
-
},
|
|
27
|
-
billet: {
|
|
28
|
-
dueDateDelay?: number | null,
|
|
29
|
-
},
|
|
30
|
-
pix: {
|
|
31
|
-
expirationInMinutes?: number | null,
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
name: string,
|
|
35
|
-
warrantyInDays: number,
|
|
36
|
-
status: 'draft' | 'active' | 'inactive' | 'blocked',
|
|
37
|
-
createdAt: string,
|
|
38
|
-
items: Array<
|
|
39
|
-
{
|
|
40
|
-
id: string,
|
|
41
|
-
product: {
|
|
42
|
-
id: string,
|
|
43
|
-
name: string,
|
|
44
|
-
description: string,
|
|
45
|
-
type: 'Online-Course' | 'Mentoring' | 'Consultancy' | 'Subscription' | 'Community' | 'Online-Event' | 'Face-to-face-Event' | 'E-Book' | 'Downloadable-File' | 'App' | 'Physical-Product' | 'Services' | 'Others',
|
|
46
|
-
image: {
|
|
47
|
-
name: string | null,
|
|
48
|
-
path: string | null,
|
|
49
|
-
url: string | null,
|
|
50
|
-
isPublic: boolean,
|
|
51
|
-
extension: string | null,
|
|
52
|
-
},
|
|
53
|
-
supportContact: {
|
|
54
|
-
name: string | null,
|
|
55
|
-
email: string | null,
|
|
56
|
-
validated: boolean | null
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
priceInCents: number,
|
|
60
|
-
priceWithoutDiscountValueInCents: number,
|
|
61
|
-
offerItemType: 'unique-purchase' | 'recurrent',
|
|
62
|
-
optional: boolean,
|
|
63
|
-
recurrence?: {
|
|
64
|
-
periodicity: 'Monthly' | 'Quarterly' | 'Biannualy' | 'Annualy',
|
|
65
|
-
numberRecurrence: number,
|
|
66
|
-
recurrenceValueInCents: number,
|
|
67
|
-
repeatIndefinitely: boolean,
|
|
68
|
-
customValue: {
|
|
69
|
-
recurrenceFrom: number | null,
|
|
70
|
-
recurrenceTo: number | null,
|
|
71
|
-
valueInCents: number | null,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
>,
|
|
76
|
-
}
|
|
77
|
-
*/
|