@fileverse-dev/formulajs 4.4.11-mod-68 → 4.4.11-mod-69

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/lib/cjs/index.cjs CHANGED
@@ -13289,13 +13289,14 @@ async function handleScanRequest({
13289
13289
  'all-txns': 'txlist',
13290
13290
  'token-txns': 'tokentx',
13291
13291
  'nft-txns': 'tokennfttx',
13292
- gas: 'gastracker'
13292
+ 'gas': 'gasoracle'
13293
13293
  };
13294
13294
 
13295
13295
  const action = ACTION_MAP[type];
13296
13296
  if (!action) throw new ValidationError(`Invalid type: ${type}`)
13297
13297
 
13298
- let url = `${baseUrl}?chainid=${chainId}&module=account&action=${action}&apikey=${apiKey}`;
13298
+ const module = action === 'gasoracle' ? 'gastracker' : 'account';
13299
+ let url = `${baseUrl}?chainid=${chainId}&module=${module}&action=${action}&apikey=${apiKey}`;
13299
13300
 
13300
13301
  if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
13301
13302
  url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
@@ -17348,7 +17349,7 @@ const farcasterSchema = objectType({
17348
17349
  contentType: enumType(['posts', 'replies', 'channels']),
17349
17350
  identifier: stringType().nonempty(),
17350
17351
  start: numberType().int().nonnegative().default(0),
17351
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17352
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17352
17353
  });
17353
17354
 
17354
17355
  const lensSchema = objectType({
@@ -17356,7 +17357,7 @@ const lensSchema = objectType({
17356
17357
  contentType: enumType(['posts', 'replies']),
17357
17358
  identifier: stringType().nonempty(),
17358
17359
  start: numberType().int().nonnegative().default(0),
17359
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17360
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17360
17361
  });
17361
17362
 
17362
17363
  const fireflyParamsSchema = discriminatedUnionType('platform', [
@@ -17379,31 +17380,33 @@ const lensParamsSchema = objectType({
17379
17380
  contentType: enumType(['posts', 'replies']),
17380
17381
  identifier: stringType().nonempty(),
17381
17382
  start: numberType().int().nonnegative().default(0),
17382
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17383
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17383
17384
  });
17384
17385
 
17385
17386
  const farcasterParamsSchema = objectType({
17386
17387
  contentType: enumType(['posts', 'replies', 'channels']),
17387
17388
  identifier: stringType().nonempty(),
17388
17389
  start: numberType().int().nonnegative().default(0),
17389
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17390
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17390
17391
  });
17391
17392
 
17392
17393
  const dateStringToTimestamp = (val) => {
17393
- const [mm, dd, yyyy] = val.split('/');
17394
- return Math.floor(new Date(`${yyyy}-${mm}-${dd}`).getTime() / 1000);
17394
+ const [dd, mm, yyyy] = val.split('/');
17395
+ const date = new Date(`${yyyy}-${mm.padStart(2, '0')}-${dd.padStart(2, '0')}`);
17396
+ const timestamp = date.getTime();
17397
+ return isNaN(timestamp) ? NaN : Math.floor(timestamp / 1000);
17395
17398
  };
17396
17399
 
17397
17400
  /**
17398
- * Accepts either a UNIXtimestamp number or a MM/DD/YYYY string,
17401
+ * Accepts either a UNIX timestamp number or a DD/MM/YYYY string,
17399
17402
  * and always returns a nonnegative integer timestamp.
17400
17403
  */
17401
17404
  const dateOrTimestamp = preprocessType(
17402
17405
  (val) =>
17403
- typeof val === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(val)
17406
+ typeof val === 'string' && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)
17404
17407
  ? dateStringToTimestamp(val)
17405
17408
  : val,
17406
- numberType().int().nonnegative()
17409
+ numberType({ invalid_type_error: 'Date must be a valid DD/MM/YYYY or timestamp' }).int('Date must be an integer timestamp').nonnegative('Date must be a nonnegative timestamp').refine((n) => !isNaN(n), { message: 'Invalid date format or value: expected DD/MM/YYYY' })
17407
17410
  );
17408
17411
 
17409
17412
  const blockscoutParamsSchema = objectType({
@@ -17413,7 +17416,7 @@ const blockscoutParamsSchema = objectType({
17413
17416
  startTimestamp: dateOrTimestamp.optional(),
17414
17417
  endTimestamp: dateOrTimestamp.optional(),
17415
17418
  page: numberType().int().nonnegative().default(1),
17416
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17419
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17417
17420
  });
17418
17421
 
17419
17422
  const gasSchema$1 = objectType({
@@ -17421,7 +17424,7 @@ const gasSchema$1 = objectType({
17421
17424
  startDate: dateOrTimestamp.optional(),
17422
17425
  endDate: dateOrTimestamp.optional(),
17423
17426
  page: numberType().int().nonnegative().default(1),
17424
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17427
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17425
17428
  });
17426
17429
 
17427
17430
  const txnSchema$1 = objectType({
@@ -17430,7 +17433,7 @@ const txnSchema$1 = objectType({
17430
17433
  startDate: dateOrTimestamp.optional(),
17431
17434
  endDate: dateOrTimestamp.optional(),
17432
17435
  page: numberType().int().nonnegative().default(1),
17433
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17436
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17434
17437
  });
17435
17438
 
17436
17439
  const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
@@ -17440,7 +17443,7 @@ const gasSchema = objectType({
17440
17443
  startDate: dateOrTimestamp.optional(),
17441
17444
  endDate: dateOrTimestamp.optional(),
17442
17445
  page: numberType().int().nonnegative().default(1),
17443
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17446
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17444
17447
  });
17445
17448
 
17446
17449
  const txnSchema = objectType({
@@ -17450,11 +17453,21 @@ const txnSchema = objectType({
17450
17453
  endDate: dateOrTimestamp.optional(),
17451
17454
  chain: enumType(['ethereum','base','gnosis']),
17452
17455
  page: numberType().int().nonnegative().default(1),
17453
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17456
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17454
17457
  });
17455
17458
 
17456
17459
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
17457
17460
 
17461
+ const allowedValues = ['1h', '24h', '7d'];
17462
+ const param2Schema = stringType()
17463
+ .refine((val) => {
17464
+ const tokens = val.split(',').map((t) => t.trim().toLowerCase());
17465
+ return tokens.some((token) =>
17466
+ allowedValues.some((allowed) => token.includes(allowed))
17467
+ );
17468
+ }, {
17469
+ message: "param2 must contain at least one of: '1h', '24h', '7d'",
17470
+ }).optional();
17458
17471
  const priceSchema = objectType({
17459
17472
  category: literalType('price'),
17460
17473
  param1: stringType().nonempty(),
@@ -17464,13 +17477,13 @@ const marketEcosystems = ['all','base','meme','aiagents','bitcoin','ethereum','h
17464
17477
  const marketSchema = objectType({
17465
17478
  category: literalType('market'),
17466
17479
  param1: enumType(marketEcosystems),
17467
- param2: enumType(['1h','24h','7d']).optional(),
17480
+ param2: param2Schema,
17468
17481
  });
17469
17482
  const stablecoinsTypes = ['all','yield-bearing-stablecoins','crypto-backed-stablecoin'];
17470
17483
  const stablecoinsSchema = objectType({
17471
17484
  category: literalType('stablecoins'),
17472
17485
  param1: enumType(stablecoinsTypes),
17473
- param2: enumType(['1h','24h','7d']).optional(),
17486
+ param2: param2Schema,
17474
17487
  });
17475
17488
  const derivativesSchema = objectType({
17476
17489
  category: literalType('derivatives'),
@@ -17498,7 +17511,7 @@ const baseSchema = objectType({
17498
17511
  startTime: dateOrTimestamp.optional(),
17499
17512
  endTime: dateOrTimestamp.optional(),
17500
17513
  page: numberType().int().nonnegative().default(1),
17501
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17514
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17502
17515
  });
17503
17516
 
17504
17517
  const eoaParamsSchema = preprocessType(
@@ -17527,7 +17540,7 @@ const safeParamsSchema = objectType({
17527
17540
  address: stringType().nonempty(),
17528
17541
  utility: literalType('txns'),
17529
17542
  chain: enumType(['ethereum','gnosis']),
17530
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17543
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17531
17544
  offset: numberType().int().nonnegative().default(0),
17532
17545
  });
17533
17546
 
@@ -286,14 +286,14 @@ If "derivatives": exchange name (e.g., "binance_futures", "hyperliquid", "weex-f
286
286
  {
287
287
  name: "page",
288
288
  detail: "Page number for paginated transaction results. Applies only to 'txns', 'token-txns', and 'nft-txns'.",
289
- example: `"1"`,
289
+ example: `1`,
290
290
  require: "o",
291
291
  type: "number"
292
292
  },
293
293
  {
294
294
  name: "offset",
295
295
  detail: "Number of results per page (limit). Applies only to 'txns', 'token-txns', and 'nft-txns'.",
296
- example: `"50"`,
296
+ example: `50`,
297
297
  require: "o",
298
298
  type: "number"
299
299
  }
package/lib/esm/index.mjs CHANGED
@@ -13287,13 +13287,14 @@ async function handleScanRequest({
13287
13287
  'all-txns': 'txlist',
13288
13288
  'token-txns': 'tokentx',
13289
13289
  'nft-txns': 'tokennfttx',
13290
- gas: 'gastracker'
13290
+ 'gas': 'gasoracle'
13291
13291
  };
13292
13292
 
13293
13293
  const action = ACTION_MAP[type];
13294
13294
  if (!action) throw new ValidationError(`Invalid type: ${type}`)
13295
13295
 
13296
- let url = `${baseUrl}?chainid=${chainId}&module=account&action=${action}&apikey=${apiKey}`;
13296
+ const module = action === 'gasoracle' ? 'gastracker' : 'account';
13297
+ let url = `${baseUrl}?chainid=${chainId}&module=${module}&action=${action}&apikey=${apiKey}`;
13297
13298
 
13298
13299
  if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
13299
13300
  url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
@@ -17346,7 +17347,7 @@ const farcasterSchema = objectType({
17346
17347
  contentType: enumType(['posts', 'replies', 'channels']),
17347
17348
  identifier: stringType().nonempty(),
17348
17349
  start: numberType().int().nonnegative().default(0),
17349
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17350
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17350
17351
  });
17351
17352
 
17352
17353
  const lensSchema = objectType({
@@ -17354,7 +17355,7 @@ const lensSchema = objectType({
17354
17355
  contentType: enumType(['posts', 'replies']),
17355
17356
  identifier: stringType().nonempty(),
17356
17357
  start: numberType().int().nonnegative().default(0),
17357
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17358
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17358
17359
  });
17359
17360
 
17360
17361
  const fireflyParamsSchema = discriminatedUnionType('platform', [
@@ -17377,31 +17378,33 @@ const lensParamsSchema = objectType({
17377
17378
  contentType: enumType(['posts', 'replies']),
17378
17379
  identifier: stringType().nonempty(),
17379
17380
  start: numberType().int().nonnegative().default(0),
17380
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17381
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17381
17382
  });
17382
17383
 
17383
17384
  const farcasterParamsSchema = objectType({
17384
17385
  contentType: enumType(['posts', 'replies', 'channels']),
17385
17386
  identifier: stringType().nonempty(),
17386
17387
  start: numberType().int().nonnegative().default(0),
17387
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17388
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17388
17389
  });
17389
17390
 
17390
17391
  const dateStringToTimestamp = (val) => {
17391
- const [mm, dd, yyyy] = val.split('/');
17392
- return Math.floor(new Date(`${yyyy}-${mm}-${dd}`).getTime() / 1000);
17392
+ const [dd, mm, yyyy] = val.split('/');
17393
+ const date = new Date(`${yyyy}-${mm.padStart(2, '0')}-${dd.padStart(2, '0')}`);
17394
+ const timestamp = date.getTime();
17395
+ return isNaN(timestamp) ? NaN : Math.floor(timestamp / 1000);
17393
17396
  };
17394
17397
 
17395
17398
  /**
17396
- * Accepts either a UNIXtimestamp number or a MM/DD/YYYY string,
17399
+ * Accepts either a UNIX timestamp number or a DD/MM/YYYY string,
17397
17400
  * and always returns a nonnegative integer timestamp.
17398
17401
  */
17399
17402
  const dateOrTimestamp = preprocessType(
17400
17403
  (val) =>
17401
- typeof val === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(val)
17404
+ typeof val === 'string' && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)
17402
17405
  ? dateStringToTimestamp(val)
17403
17406
  : val,
17404
- numberType().int().nonnegative()
17407
+ numberType({ invalid_type_error: 'Date must be a valid DD/MM/YYYY or timestamp' }).int('Date must be an integer timestamp').nonnegative('Date must be a nonnegative timestamp').refine((n) => !isNaN(n), { message: 'Invalid date format or value: expected DD/MM/YYYY' })
17405
17408
  );
17406
17409
 
17407
17410
  const blockscoutParamsSchema = objectType({
@@ -17411,7 +17414,7 @@ const blockscoutParamsSchema = objectType({
17411
17414
  startTimestamp: dateOrTimestamp.optional(),
17412
17415
  endTimestamp: dateOrTimestamp.optional(),
17413
17416
  page: numberType().int().nonnegative().default(1),
17414
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17417
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17415
17418
  });
17416
17419
 
17417
17420
  const gasSchema$1 = objectType({
@@ -17419,7 +17422,7 @@ const gasSchema$1 = objectType({
17419
17422
  startDate: dateOrTimestamp.optional(),
17420
17423
  endDate: dateOrTimestamp.optional(),
17421
17424
  page: numberType().int().nonnegative().default(1),
17422
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17425
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17423
17426
  });
17424
17427
 
17425
17428
  const txnSchema$1 = objectType({
@@ -17428,7 +17431,7 @@ const txnSchema$1 = objectType({
17428
17431
  startDate: dateOrTimestamp.optional(),
17429
17432
  endDate: dateOrTimestamp.optional(),
17430
17433
  page: numberType().int().nonnegative().default(1),
17431
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17434
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17432
17435
  });
17433
17436
 
17434
17437
  const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
@@ -17438,7 +17441,7 @@ const gasSchema = objectType({
17438
17441
  startDate: dateOrTimestamp.optional(),
17439
17442
  endDate: dateOrTimestamp.optional(),
17440
17443
  page: numberType().int().nonnegative().default(1),
17441
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17444
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17442
17445
  });
17443
17446
 
17444
17447
  const txnSchema = objectType({
@@ -17448,11 +17451,21 @@ const txnSchema = objectType({
17448
17451
  endDate: dateOrTimestamp.optional(),
17449
17452
  chain: enumType(['ethereum','base','gnosis']),
17450
17453
  page: numberType().int().nonnegative().default(1),
17451
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17454
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17452
17455
  });
17453
17456
 
17454
17457
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
17455
17458
 
17459
+ const allowedValues = ['1h', '24h', '7d'];
17460
+ const param2Schema = stringType()
17461
+ .refine((val) => {
17462
+ const tokens = val.split(',').map((t) => t.trim().toLowerCase());
17463
+ return tokens.some((token) =>
17464
+ allowedValues.some((allowed) => token.includes(allowed))
17465
+ );
17466
+ }, {
17467
+ message: "param2 must contain at least one of: '1h', '24h', '7d'",
17468
+ }).optional();
17456
17469
  const priceSchema = objectType({
17457
17470
  category: literalType('price'),
17458
17471
  param1: stringType().nonempty(),
@@ -17462,13 +17475,13 @@ const marketEcosystems = ['all','base','meme','aiagents','bitcoin','ethereum','h
17462
17475
  const marketSchema = objectType({
17463
17476
  category: literalType('market'),
17464
17477
  param1: enumType(marketEcosystems),
17465
- param2: enumType(['1h','24h','7d']).optional(),
17478
+ param2: param2Schema,
17466
17479
  });
17467
17480
  const stablecoinsTypes = ['all','yield-bearing-stablecoins','crypto-backed-stablecoin'];
17468
17481
  const stablecoinsSchema = objectType({
17469
17482
  category: literalType('stablecoins'),
17470
17483
  param1: enumType(stablecoinsTypes),
17471
- param2: enumType(['1h','24h','7d']).optional(),
17484
+ param2: param2Schema,
17472
17485
  });
17473
17486
  const derivativesSchema = objectType({
17474
17487
  category: literalType('derivatives'),
@@ -17496,7 +17509,7 @@ const baseSchema = objectType({
17496
17509
  startTime: dateOrTimestamp.optional(),
17497
17510
  endTime: dateOrTimestamp.optional(),
17498
17511
  page: numberType().int().nonnegative().default(1),
17499
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17512
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17500
17513
  });
17501
17514
 
17502
17515
  const eoaParamsSchema = preprocessType(
@@ -17525,7 +17538,7 @@ const safeParamsSchema = objectType({
17525
17538
  address: stringType().nonempty(),
17526
17539
  utility: literalType('txns'),
17527
17540
  chain: enumType(['ethereum','gnosis']),
17528
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17541
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17529
17542
  offset: numberType().int().nonnegative().default(0),
17530
17543
  });
17531
17544
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.11-mod-68",
3
+ "version": "4.4.11-mod-69",
4
4
  "description": "JavaScript implementation of most Microsoft Excel formula functions",
5
5
  "author": "Formulajs",
6
6
  "publishConfig": {