dymo-api 1.2.31 → 1.2.33

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.
Files changed (97) hide show
  1. package/dist/cjs/dymo-api.cjs +1123 -393
  2. package/dist/esm/dymo-api.js +1125 -356
  3. package/dist/types/branches/private/functions/extractWithTextly/index.d.ts +3 -2
  4. package/dist/types/branches/private/functions/extractWithTextly/index.d.ts.map +1 -0
  5. package/dist/types/branches/private/functions/getRandom/index.d.ts +3 -2
  6. package/dist/types/branches/private/functions/getRandom/index.d.ts.map +1 -0
  7. package/dist/types/branches/private/functions/isValidDataRaw/index.d.ts +3 -2
  8. package/dist/types/branches/private/functions/isValidDataRaw/index.d.ts.map +1 -0
  9. package/dist/types/branches/private/functions/isValidEmail/index.d.ts +3 -2
  10. package/dist/types/branches/private/functions/isValidEmail/index.d.ts.map +1 -0
  11. package/dist/types/branches/private/functions/isValidIP/index.d.ts +3 -2
  12. package/dist/types/branches/private/functions/isValidIP/index.d.ts.map +1 -0
  13. package/dist/types/branches/private/functions/isValidPhone/index.d.ts +3 -2
  14. package/dist/types/branches/private/functions/isValidPhone/index.d.ts.map +1 -0
  15. package/dist/types/branches/private/functions/protectReq/index.d.ts +3 -2
  16. package/dist/types/branches/private/functions/protectReq/index.d.ts.map +1 -0
  17. package/dist/types/branches/private/functions/protectReq/requestHandler.d.ts +1 -0
  18. package/dist/types/branches/private/functions/protectReq/requestHandler.d.ts.map +1 -0
  19. package/dist/types/branches/private/functions/sendEmail/index.d.ts +3 -2
  20. package/dist/types/branches/private/functions/sendEmail/index.d.ts.map +1 -0
  21. package/dist/types/branches/private/index.d.ts +9 -8
  22. package/dist/types/branches/private/index.d.ts.map +1 -0
  23. package/dist/types/branches/public/functions/getPrayerTimes/index.d.ts +3 -2
  24. package/dist/types/branches/public/functions/getPrayerTimes/index.d.ts.map +1 -0
  25. package/dist/types/branches/public/functions/isValidPwd/index.d.ts +3 -2
  26. package/dist/types/branches/public/functions/isValidPwd/index.d.ts.map +1 -0
  27. package/dist/types/branches/public/functions/satinize/index.d.ts +2 -1
  28. package/dist/types/branches/public/functions/satinize/index.d.ts.map +1 -0
  29. package/dist/types/branches/public/index.d.ts +4 -3
  30. package/dist/types/branches/public/index.d.ts.map +1 -0
  31. package/dist/types/config/index.d.ts +1 -0
  32. package/dist/types/config/index.d.ts.map +1 -0
  33. package/dist/types/dymo-api.d.ts +2 -1
  34. package/dist/types/dymo-api.d.ts.map +1 -0
  35. package/dist/types/lib/resilience/fallback.d.ts +1 -0
  36. package/dist/types/lib/resilience/fallback.d.ts.map +1 -0
  37. package/dist/types/lib/resilience/index.d.ts +3 -2
  38. package/dist/types/lib/resilience/index.d.ts.map +1 -0
  39. package/dist/types/lib/types/data-verifier.d.ts +3 -2
  40. package/dist/types/lib/types/data-verifier.d.ts.map +1 -0
  41. package/dist/types/lib/types/interfaces.d.ts +5 -4
  42. package/dist/types/lib/types/interfaces.d.ts.map +1 -0
  43. package/dist/types/lib/types/primitives.d.ts +1 -0
  44. package/dist/types/lib/types/primitives.d.ts.map +1 -0
  45. package/dist/types/lib/types/rules.d.ts +2 -1
  46. package/dist/types/lib/types/rules.d.ts.map +1 -0
  47. package/dist/types/lib/types/well-known-bots.d.ts +1 -0
  48. package/dist/types/lib/types/well-known-bots.d.ts.map +1 -0
  49. package/dist/types/utils/basics.d.ts +1 -0
  50. package/dist/types/utils/basics.d.ts.map +1 -0
  51. package/package.json +9 -10
  52. package/dist/cjs/branches/private/functions/extractWithTextly/index.cjs +0 -33
  53. package/dist/cjs/branches/private/functions/getRandom/index.cjs +0 -37
  54. package/dist/cjs/branches/private/functions/isValidDataRaw/index.cjs +0 -33
  55. package/dist/cjs/branches/private/functions/isValidEmail/index.cjs +0 -91
  56. package/dist/cjs/branches/private/functions/isValidIP/index.cjs +0 -80
  57. package/dist/cjs/branches/private/functions/isValidPhone/index.cjs +0 -77
  58. package/dist/cjs/branches/private/functions/protectReq/index.cjs +0 -74
  59. package/dist/cjs/branches/private/functions/protectReq/requestHandler.cjs +0 -22
  60. package/dist/cjs/branches/private/functions/sendEmail/index.cjs +0 -88
  61. package/dist/cjs/branches/private/index.cjs +0 -24
  62. package/dist/cjs/branches/public/functions/getPrayerTimes/index.cjs +0 -31
  63. package/dist/cjs/branches/public/functions/isValidPwd/index.cjs +0 -65
  64. package/dist/cjs/branches/public/functions/satinize/index.cjs +0 -26
  65. package/dist/cjs/branches/public/index.cjs +0 -19
  66. package/dist/cjs/config/index.cjs +0 -12
  67. package/dist/cjs/lib/resilience/fallback.cjs +0 -427
  68. package/dist/cjs/lib/resilience/index.cjs +0 -135
  69. package/dist/cjs/lib/types/data-verifier.cjs +0 -2
  70. package/dist/cjs/lib/types/interfaces.cjs +0 -24
  71. package/dist/cjs/lib/types/primitives.cjs +0 -2
  72. package/dist/cjs/lib/types/rules.cjs +0 -2
  73. package/dist/cjs/lib/types/well-known-bots.cjs +0 -739
  74. package/dist/cjs/utils/basics.cjs +0 -18
  75. package/dist/esm/branches/private/functions/extractWithTextly/index.js +0 -29
  76. package/dist/esm/branches/private/functions/getRandom/index.js +0 -33
  77. package/dist/esm/branches/private/functions/isValidDataRaw/index.js +0 -29
  78. package/dist/esm/branches/private/functions/isValidEmail/index.js +0 -87
  79. package/dist/esm/branches/private/functions/isValidIP/index.js +0 -76
  80. package/dist/esm/branches/private/functions/isValidPhone/index.js +0 -73
  81. package/dist/esm/branches/private/functions/protectReq/index.js +0 -37
  82. package/dist/esm/branches/private/functions/protectReq/requestHandler.js +0 -18
  83. package/dist/esm/branches/private/functions/sendEmail/index.js +0 -81
  84. package/dist/esm/branches/private/index.js +0 -8
  85. package/dist/esm/branches/public/functions/getPrayerTimes/index.js +0 -27
  86. package/dist/esm/branches/public/functions/isValidPwd/index.js +0 -61
  87. package/dist/esm/branches/public/functions/satinize/index.js +0 -22
  88. package/dist/esm/branches/public/index.js +0 -3
  89. package/dist/esm/config/index.js +0 -10
  90. package/dist/esm/lib/resilience/fallback.js +0 -423
  91. package/dist/esm/lib/resilience/index.js +0 -131
  92. package/dist/esm/lib/types/data-verifier.js +0 -1
  93. package/dist/esm/lib/types/interfaces.js +0 -8
  94. package/dist/esm/lib/types/primitives.js +0 -1
  95. package/dist/esm/lib/types/rules.js +0 -1
  96. package/dist/esm/lib/types/well-known-bots.js +0 -736
  97. package/dist/esm/utils/basics.js +0 -10
@@ -1,423 +0,0 @@
1
- export class FallbackDataGenerator {
2
- static generateFallbackData(method, inputData) {
3
- switch (method) {
4
- case "isValidData": return this.generateDataValidationAnalysis(inputData);
5
- case "isValidEmail": return this.generateEmailValidatorResponse(inputData);
6
- case "isValidIP": return this.generateIPValidatorResponse(inputData);
7
- case "isValidPhone": return this.generatePhoneValidatorResponse(inputData);
8
- case "protectReq": return this.generateHTTPRequest(inputData);
9
- case "sendEmail": return this.generateEmailStatus();
10
- case "getRandom": return this.generateSRNSummary(inputData);
11
- case "extractWithTextly": return this.generateExtractWithTextly(inputData);
12
- case "getPrayerTimes": return this.generatePrayerTimes(inputData);
13
- case "satinize": return this.generateSatinizedInputAnalysis(inputData);
14
- case "isValidPwd": return this.generatePasswordValidationResult(inputData);
15
- default: throw new Error(`Unknown method for fallback: ${method}`);
16
- }
17
- }
18
- ;
19
- static validateURL(url) {
20
- if (!url)
21
- return false;
22
- const urlRegex = /^https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/(?:[\w\/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?$/;
23
- return urlRegex.test(url);
24
- }
25
- ;
26
- static validateEmail(email) {
27
- if (!email)
28
- return false;
29
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
30
- return emailRegex.test(email);
31
- }
32
- ;
33
- static validateDomain(domain) {
34
- if (!domain)
35
- return false;
36
- const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])*$/;
37
- if (!domainRegex.test(domain))
38
- return false;
39
- // Validar que tenga un TLD (último punto + contenido)
40
- const parts = domain.split('.');
41
- return parts.length >= 2 && parts[parts.length - 1].length > 0;
42
- }
43
- ;
44
- static validateCreditCard(creditCard) {
45
- if (!creditCard)
46
- return false;
47
- const cardNumber = typeof creditCard === "string" ? creditCard : creditCard?.pan || "";
48
- if (!cardNumber)
49
- return false;
50
- const cardRegex = /^\d{13,19}$/;
51
- if (!cardRegex.test(cardNumber.replace(/\s/g, "")))
52
- return false;
53
- // Luhn algorithm
54
- const digits = cardNumber.replace(/\s/g, "").split("").map(Number);
55
- let sum = 0;
56
- let isEven = false;
57
- for (let i = digits.length - 1; i >= 0; i--) {
58
- let digit = digits[i];
59
- if (isEven) {
60
- digit *= 2;
61
- if (digit > 9)
62
- digit -= 9;
63
- }
64
- sum += digit;
65
- isEven = !isEven;
66
- }
67
- return sum % 10 === 0;
68
- }
69
- ;
70
- static validateIP(ip) {
71
- if (!ip)
72
- return false;
73
- const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
74
- const ipv6Regex = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
75
- return ipv4Regex.test(ip) || ipv6Regex.test(ip);
76
- }
77
- ;
78
- static validatePhone(phone) {
79
- if (!phone)
80
- return false;
81
- const phoneRegex = /^\+?[1-9]\d{1,14}$/;
82
- return phoneRegex.test(phone.replace(/[^\d+]/g, ""));
83
- }
84
- ;
85
- static validateWallet(wallet) {
86
- if (!wallet)
87
- return false;
88
- const bitcoinRegex = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
89
- const ethereumRegex = /^0x[a-fA-F0-9]{40}$/;
90
- return bitcoinRegex.test(wallet) || ethereumRegex.test(wallet);
91
- }
92
- ;
93
- static validateIBAN(iban) {
94
- if (!iban)
95
- return false;
96
- const ibanRegex = /^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;
97
- return ibanRegex.test(iban.replace(/\s/g, "").toUpperCase());
98
- }
99
- ;
100
- static extractDomain(url) {
101
- if (!url)
102
- return "";
103
- try {
104
- return new URL(url).hostname;
105
- }
106
- catch {
107
- return "";
108
- }
109
- }
110
- ;
111
- static generateDataValidationAnalysis(inputData) {
112
- return {
113
- url: {
114
- valid: this.validateURL(inputData?.url),
115
- fraud: false,
116
- freeSubdomain: false,
117
- customTLD: false,
118
- url: inputData?.url || "",
119
- domain: this.extractDomain(inputData?.url),
120
- plugins: {
121
- blocklist: false,
122
- compromiseDetector: false,
123
- mxRecords: [],
124
- nsfw: false,
125
- reputation: "unknown",
126
- riskScore: 0,
127
- torNetwork: false,
128
- typosquatting: 0,
129
- urlShortener: false
130
- }
131
- },
132
- email: this.generateEmailDataAnalysis(inputData?.email),
133
- phone: this.generatePhoneDataAnalysis(inputData?.phone),
134
- domain: {
135
- valid: this.validateDomain(inputData?.domain),
136
- fraud: false,
137
- freeSubdomain: false,
138
- customTLD: false,
139
- domain: inputData?.domain || "",
140
- plugins: {
141
- blocklist: false,
142
- compromiseDetector: false,
143
- mxRecords: [],
144
- nsfw: false,
145
- reputation: "unknown",
146
- riskScore: 0,
147
- torNetwork: false,
148
- typosquatting: 0,
149
- urlShortener: false
150
- }
151
- },
152
- creditCard: {
153
- valid: this.validateCreditCard(inputData?.creditCard),
154
- fraud: false,
155
- test: false,
156
- type: "unknown",
157
- creditCard: typeof inputData?.creditCard === "string" ? inputData.creditCard : inputData?.creditCard?.pan || "",
158
- plugins: {
159
- blocklist: false,
160
- riskScore: 0
161
- }
162
- },
163
- ip: this.generateIPDataAnalysis(inputData?.ip),
164
- wallet: {
165
- valid: this.validateWallet(inputData?.wallet),
166
- fraud: false,
167
- wallet: inputData?.wallet || "",
168
- type: "unknown",
169
- plugins: {
170
- blocklist: false,
171
- riskScore: 0,
172
- torNetwork: false
173
- }
174
- },
175
- userAgent: {
176
- valid: false,
177
- fraud: false,
178
- userAgent: inputData?.userAgent || "",
179
- bot: true,
180
- device: { type: "unknown", brand: "unknown" },
181
- plugins: {
182
- blocklist: false,
183
- riskScore: 0
184
- }
185
- },
186
- iban: {
187
- valid: this.validateIBAN(inputData?.iban),
188
- fraud: false,
189
- iban: inputData?.iban || "",
190
- plugins: {
191
- blocklist: false,
192
- riskScore: 0
193
- }
194
- }
195
- };
196
- }
197
- ;
198
- static generateEmailValidatorResponse(inputData) {
199
- return {
200
- email: inputData?.email || "",
201
- allow: this.validateEmail(inputData?.email),
202
- reasons: this.validateEmail(inputData?.email) ? [] : ["INVALID"],
203
- response: this.generateEmailDataAnalysis(inputData?.email)
204
- };
205
- }
206
- ;
207
- static generateEmailDataAnalysis(email) {
208
- return {
209
- valid: this.validateEmail(email),
210
- fraud: false,
211
- proxiedEmail: false,
212
- freeSubdomain: false,
213
- corporate: false,
214
- email: email || "",
215
- realUser: "",
216
- didYouMean: null,
217
- noReply: false,
218
- customTLD: false,
219
- domain: "",
220
- roleAccount: false,
221
- plugins: {
222
- mxRecords: [],
223
- blocklist: false,
224
- compromiseDetector: false,
225
- nsfw: false,
226
- reputation: "unknown",
227
- riskScore: 0,
228
- torNetwork: false,
229
- typosquatting: 0,
230
- urlShortener: false
231
- }
232
- };
233
- }
234
- ;
235
- static generateIPValidatorResponse(inputData) {
236
- return {
237
- ip: inputData?.ip || "",
238
- allow: this.validateIP(inputData?.ip),
239
- reasons: this.validateIP(inputData?.ip) ? [] : ["INVALID"],
240
- response: this.generateIPDataAnalysis(inputData?.ip)
241
- };
242
- }
243
- ;
244
- static generateIPDataAnalysis(ip) {
245
- const isValid = this.validateIP(ip);
246
- return {
247
- valid: isValid,
248
- type: isValid ? "IPv4" : "Invalid",
249
- class: isValid ? "A" : "Unknown",
250
- fraud: false,
251
- ip: ip || "",
252
- continent: "",
253
- continentCode: "",
254
- country: "",
255
- countryCode: "",
256
- region: "",
257
- regionName: "",
258
- city: "",
259
- district: "",
260
- zipCode: "",
261
- lat: 0,
262
- lon: 0,
263
- timezone: "",
264
- offset: 0,
265
- currency: "",
266
- isp: "",
267
- org: "",
268
- as: "",
269
- asname: "",
270
- mobile: false,
271
- proxy: true,
272
- hosting: false,
273
- plugins: {
274
- blocklist: false,
275
- riskScore: 0
276
- }
277
- };
278
- }
279
- ;
280
- static generatePhoneValidatorResponse(inputData) {
281
- return {
282
- phone: inputData?.phone || "",
283
- allow: this.validatePhone(inputData?.phone),
284
- reasons: this.validatePhone(inputData?.phone) ? [] : ["INVALID"],
285
- response: this.generatePhoneDataAnalysis(inputData?.phone)
286
- };
287
- }
288
- ;
289
- static generatePhoneDataAnalysis(phone) {
290
- const phoneNumber = phone?.phone || phone;
291
- const isValid = this.validatePhone(phoneNumber);
292
- return {
293
- valid: isValid,
294
- fraud: false,
295
- phone: phone?.phone || "",
296
- prefix: "",
297
- number: "",
298
- lineType: "Unknown",
299
- carrierInfo: {
300
- carrierName: "",
301
- accuracy: 0,
302
- carrierCountry: "",
303
- carrierCountryCode: ""
304
- },
305
- country: "",
306
- countryCode: "",
307
- plugins: {
308
- blocklist: false,
309
- riskScore: 0
310
- }
311
- };
312
- }
313
- ;
314
- static generateHTTPRequest(inputData) {
315
- return {
316
- method: inputData?.method || "GET",
317
- url: inputData?.url || "",
318
- headers: inputData?.headers || {},
319
- body: inputData?.body || null,
320
- allow: false,
321
- reasons: ["FRAUD"],
322
- protected: true
323
- };
324
- }
325
- ;
326
- static generateEmailStatus() {
327
- return {
328
- status: false,
329
- error: "API unavailable - using fallback response"
330
- };
331
- }
332
- ;
333
- static generateSRNSummary(inputData) {
334
- const quantity = inputData?.quantity || 1;
335
- const values = Array.from({ length: quantity }, () => ({
336
- integer: 0,
337
- float: 0.0
338
- }));
339
- return {
340
- values,
341
- executionTime: 0
342
- };
343
- }
344
- ;
345
- static generateExtractWithTextly(inputData) {
346
- return {
347
- data: inputData?.data || "",
348
- extracted: {},
349
- error: "API unavailable - using fallback response"
350
- };
351
- }
352
- ;
353
- static generatePrayerTimes(inputData) {
354
- return {
355
- error: "API unavailable - using fallback response"
356
- };
357
- }
358
- ;
359
- static generateSatinizedInputAnalysis(inputData) {
360
- return {
361
- input: inputData?.input || "",
362
- formats: {
363
- ascii: false,
364
- bitcoinAddress: false,
365
- cLikeIdentifier: false,
366
- coordinates: false,
367
- crediCard: false,
368
- date: false,
369
- discordUsername: false,
370
- doi: false,
371
- domain: false,
372
- e164Phone: false,
373
- email: false,
374
- emoji: false,
375
- hanUnification: false,
376
- hashtag: false,
377
- hyphenWordBreak: false,
378
- ipv6: false,
379
- ip: false,
380
- jiraTicket: false,
381
- macAddress: false,
382
- name: false,
383
- number: false,
384
- panFromGstin: false,
385
- password: false,
386
- port: false,
387
- tel: false,
388
- text: false,
389
- semver: false,
390
- ssn: false,
391
- uuid: false,
392
- url: false,
393
- urlSlug: false,
394
- username: false
395
- },
396
- includes: {
397
- spaces: false,
398
- hasSql: false,
399
- hasNoSql: false,
400
- letters: false,
401
- uppercase: false,
402
- lowercase: false,
403
- symbols: false,
404
- digits: false
405
- }
406
- };
407
- }
408
- ;
409
- static generatePasswordValidationResult(inputData) {
410
- return {
411
- valid: false,
412
- password: inputData?.password || "",
413
- details: [
414
- {
415
- validation: "length",
416
- message: "API unavailable - using fallback response"
417
- }
418
- ]
419
- };
420
- }
421
- ;
422
- }
423
- ;
@@ -1,131 +0,0 @@
1
- class RateLimitManager {
2
- constructor() {
3
- this.tracker = {};
4
- }
5
- static getInstance() {
6
- if (!RateLimitManager.instance)
7
- RateLimitManager.instance = new RateLimitManager();
8
- return RateLimitManager.instance;
9
- }
10
- ;
11
- updateRateLimit(clientId, headers) {
12
- if (!this.tracker[clientId])
13
- this.tracker[clientId] = {};
14
- const limitInfo = this.tracker[clientId];
15
- if (headers["x-ratelimit-limit-requests"])
16
- limitInfo.limit = parseInt(headers["x-ratelimit-limit-requests"]);
17
- if (headers["x-ratelimit-remaining-requests"])
18
- limitInfo.remaining = parseInt(headers["x-ratelimit-remaining-requests"]);
19
- if (headers["x-ratelimit-reset-requests"])
20
- limitInfo.resetTime = headers["x-ratelimit-reset-requests"];
21
- if (headers["retry-after"])
22
- limitInfo.retryAfter = parseInt(headers["retry-after"]);
23
- limitInfo.lastUpdated = Date.now();
24
- }
25
- ;
26
- isRateLimited(clientId) {
27
- const limitInfo = this.tracker[clientId];
28
- return limitInfo?.remaining !== undefined && limitInfo.remaining <= 0;
29
- }
30
- ;
31
- getRetryAfter(clientId) {
32
- return this.tracker[clientId]?.retryAfter;
33
- }
34
- ;
35
- clearExpiredLimits() {
36
- const now = Date.now();
37
- Object.keys(this.tracker).forEach(clientId => {
38
- const limitInfo = this.tracker[clientId];
39
- if (limitInfo.lastUpdated && (now - limitInfo.lastUpdated) > 300000)
40
- delete this.tracker[clientId];
41
- });
42
- }
43
- ;
44
- }
45
- ;
46
- export class ResilienceManager {
47
- constructor(config = {}, clientId = "default") {
48
- this.config = {
49
- fallbackEnabled: config.fallbackEnabled ?? false,
50
- retryAttempts: Math.max(0, config.retryAttempts ?? 2), // Number of additional retries
51
- retryDelay: Math.max(0, config.retryDelay ?? 1000)
52
- };
53
- this.clientId = clientId;
54
- this.rateLimitManager = RateLimitManager.getInstance();
55
- }
56
- ;
57
- async executeWithResilience(axiosClient, requestConfig, fallbackData) {
58
- let lastError;
59
- const totalAttempts = 1 + this.config.retryAttempts; // 1 normal + N retries
60
- // Clean up expired rate limits periodically
61
- this.rateLimitManager.clearExpiredLimits();
62
- // Check if client is currently rate limited
63
- if (this.rateLimitManager.isRateLimited(this.clientId)) {
64
- const retryAfter = this.rateLimitManager.getRetryAfter(this.clientId);
65
- if (retryAfter) {
66
- console.warn(`[Dymo API] Client ${this.clientId} is rate limited. Waiting ${retryAfter} seconds...`);
67
- await this.sleep(retryAfter * 1000);
68
- }
69
- }
70
- for (let attempt = 1; attempt <= totalAttempts; attempt++) {
71
- try {
72
- const response = await axiosClient.request(requestConfig);
73
- // Update rate limit tracking
74
- this.rateLimitManager.updateRateLimit(this.clientId, response.headers);
75
- // Check for rate limiting
76
- if (response.status === 429) {
77
- const retryAfter = this.rateLimitManager.getRetryAfter(this.clientId);
78
- if (retryAfter) {
79
- console.warn(`[Dymo API] Rate limited. Waiting ${retryAfter} seconds (no retries)`);
80
- await this.sleep(retryAfter * 1000);
81
- }
82
- throw new Error(`Rate limited (429) - not retrying`);
83
- }
84
- return response.data;
85
- }
86
- catch (error) {
87
- lastError = error;
88
- let shouldRetry = this.shouldRetry(error);
89
- const isLastAttempt = attempt === totalAttempts;
90
- // Don't retry on rate limiting (429)
91
- if (error.response?.status === 429)
92
- shouldRetry = false;
93
- if (!shouldRetry || isLastAttempt) {
94
- if (this.config.fallbackEnabled && fallbackData) {
95
- console.warn(`[Dymo API] Request failed after ${attempt} attempts. Using fallback data.`);
96
- return fallbackData;
97
- }
98
- throw error;
99
- }
100
- const delay = this.config.retryDelay * Math.pow(2, attempt - 1);
101
- console.warn(`[Dymo API] Attempt ${attempt} failed. Retrying in ${delay}ms...`);
102
- await this.sleep(delay);
103
- }
104
- }
105
- throw lastError;
106
- }
107
- ;
108
- shouldRetry(error) {
109
- const statusCode = error.response?.status;
110
- const isNetworkError = !error.response && error.code !== "ECONNABORTED";
111
- const isServerError = statusCode && statusCode >= 500;
112
- // Retry on: network errors, server errors (5xx)
113
- // DON'T retry on: rate limiting (429) - handled separately
114
- // DON'T retry on: client errors (4xx except 429)
115
- return isNetworkError || isServerError;
116
- }
117
- ;
118
- sleep(ms) {
119
- return new Promise(resolve => setTimeout(resolve, ms));
120
- }
121
- ;
122
- getConfig() {
123
- return { ...this.config };
124
- }
125
- ;
126
- getClientId() {
127
- return this.clientId;
128
- }
129
- ;
130
- }
131
- ;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- ;
2
- ;
3
- ;
4
- ;
5
- export * from "./rules";
6
- export * from "./primitives";
7
- export * from "./data-verifier";
8
- export * from "./well-known-bots";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};