@fileverse-dev/formulajs 4.4.38 → 4.4.39

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
@@ -17697,15 +17697,16 @@ const aaveParamsSchema = objectType({
17697
17697
  category: enumType(['tokens','markets']),
17698
17698
  param1: stringType().nonempty(),
17699
17699
  param2: stringType().optional(),
17700
+ columnName: stringType().optional(),
17700
17701
  });
17701
17702
 
17702
17703
  async function AAVE() {
17703
17704
  try {
17704
17705
 
17705
- const [graphType, category, param1, param2] = argsToArray(arguments);
17706
+ const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
17706
17707
 
17707
17708
 
17708
- validateParams(aaveParamsSchema, { graphType, category, param1, param2 });
17709
+ validateParams(aaveParamsSchema, { graphType, category, param1, param2, columnName });
17709
17710
 
17710
17711
  const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
17711
17712
  const url =
@@ -17722,16 +17723,25 @@ async function AAVE() {
17722
17723
  }
17723
17724
 
17724
17725
  const json = await res.json();
17726
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
17727
+
17725
17728
  if (Array.isArray(json)) {
17726
17729
  return json.map(item => {
17727
17730
  const flat = {};
17728
17731
  Object.entries(item).forEach(([k, v]) => {
17729
- if (v === null || typeof v !== 'object') flat[k] = v;
17732
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
17730
17733
  });
17731
17734
  return flat
17732
17735
  })
17733
17736
  }
17734
- return json
17737
+ if(columnName && typeof json === 'object') {
17738
+ const data = {};
17739
+ filterColumnName.forEach(k => {
17740
+ data[k] = json[k];
17741
+ });
17742
+ return data
17743
+ }
17744
+ return json;
17735
17745
  } catch (err) {
17736
17746
  return errorMessageHandler(err, 'AAVE')
17737
17747
  }
@@ -17771,6 +17781,7 @@ const baseSchema = objectType({
17771
17781
  endTime: dateOrTimestamp.optional(),
17772
17782
  page: numberType().int().nonnegative().default(1),
17773
17783
  offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17784
+ columnName: stringType().optional(),
17774
17785
  });
17775
17786
 
17776
17787
  const eoaParamsSchema = preprocessType(
@@ -18000,9 +18011,9 @@ function toTimestamp(dateStr) {
18000
18011
 
18001
18012
  async function EOA() {
18002
18013
  try {
18003
- const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
18014
+ const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName = null] =
18004
18015
  argsToArray(arguments);
18005
- validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
18016
+ validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset, columnName });
18006
18017
 
18007
18018
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18008
18019
 
@@ -18072,6 +18083,16 @@ async function EOA() {
18072
18083
  }
18073
18084
  }
18074
18085
  }
18086
+ if(columnName){
18087
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18088
+ return out.map(obj =>
18089
+ Object.fromEntries(
18090
+ filterColumnName
18091
+ .filter(key => key in obj)
18092
+ .map(key => [key, obj[key]])
18093
+ )
18094
+ );
18095
+ }
18075
18096
  return out
18076
18097
  } catch (err) {
18077
18098
  return errorMessageHandler(err, 'EOA')
@@ -18084,6 +18105,7 @@ const gasSchema$1 = objectType({
18084
18105
  endDate: dateOrTimestamp.optional(),
18085
18106
  page: numberType().int().nonnegative().default(1),
18086
18107
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18108
+ columnName: stringType().optional(),
18087
18109
  });
18088
18110
 
18089
18111
  const txnSchema$1 = objectType({
@@ -18093,6 +18115,7 @@ const txnSchema$1 = objectType({
18093
18115
  endDate: dateOrTimestamp.optional(),
18094
18116
  page: numberType().int().nonnegative().default(1),
18095
18117
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18118
+ columnName: stringType().optional(),
18096
18119
  });
18097
18120
 
18098
18121
  const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
@@ -18169,11 +18192,11 @@ async function handleScanRequest({
18169
18192
 
18170
18193
  async function BASE() {
18171
18194
  try {
18172
- const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
18173
- validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
18195
+ const [type, address, startDate, endDate, page, limit, columnName] = argsToArray(arguments);
18196
+ validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit, columnName });
18174
18197
  const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
18175
18198
 
18176
- return await handleScanRequest({
18199
+ const out = await handleScanRequest({
18177
18200
  type,
18178
18201
  address,
18179
18202
  startDate,
@@ -18184,7 +18207,18 @@ async function BASE() {
18184
18207
  functionName: 'BASE',
18185
18208
  chainId: CHAIN_ID_MAP.base,
18186
18209
  network: 'base'
18187
- })
18210
+ });
18211
+ if (columnName) {
18212
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18213
+ return out.map(obj =>
18214
+ Object.fromEntries(
18215
+ filterColumnName
18216
+ .filter(key => key in obj)
18217
+ .map(key => [key, obj[key]])
18218
+ )
18219
+ );
18220
+ }
18221
+ return out
18188
18222
  } catch (error) {
18189
18223
  return errorMessageHandler(error, 'BASE')
18190
18224
  }
@@ -18304,6 +18338,7 @@ const derivativesSchema = objectType({
18304
18338
  category: literalType('derivatives'),
18305
18339
  param1: stringType().nonempty(),
18306
18340
  param2: anyType().optional(),
18341
+ columnName: stringType().optional(),
18307
18342
  });
18308
18343
  const coingeckoParamsSchema = discriminatedUnionType('category', [
18309
18344
  priceSchema$1,
@@ -18318,8 +18353,8 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
18318
18353
 
18319
18354
  async function COINGECKO() {
18320
18355
  try {
18321
- const [category, param1, param2] = argsToArray(arguments);
18322
- validateParams(coingeckoParamsSchema, { category, param1, param2 });
18356
+ const [category, param1, param2, columnName = null] = argsToArray(arguments);
18357
+ validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
18323
18358
 
18324
18359
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
18325
18360
 
@@ -18354,7 +18389,7 @@ async function COINGECKO() {
18354
18389
  break
18355
18390
  }
18356
18391
  }
18357
- const {URL: finalUrl, HEADERS} = getUrlAndHeaders({url, serviceName: 'Coingecko', headers});
18392
+ const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Coingecko', headers });
18358
18393
 
18359
18394
  const res = await fetch(finalUrl + "?refresh=true", { headers: HEADERS });
18360
18395
  const json = await res.json();
@@ -18380,6 +18415,16 @@ async function COINGECKO() {
18380
18415
  flat[key] = value;
18381
18416
  }
18382
18417
  }
18418
+ if (columnName) {
18419
+ const filterData = {};
18420
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18421
+ filterColumnName.forEach(col => {
18422
+ if (flat[col] !== undefined) {
18423
+ filterData[col] = flat[col];
18424
+ }
18425
+ });
18426
+ return filterData;
18427
+ }
18383
18428
  return flat
18384
18429
  })
18385
18430
  } catch (err) {
@@ -18389,7 +18434,8 @@ async function COINGECKO() {
18389
18434
 
18390
18435
  const categories = ['protocols','yields','dex','fees'];
18391
18436
  const defillamaParamsSchema = objectType({
18392
- category: enumType(categories)
18437
+ category: enumType(categories),
18438
+ columnName: stringType().optional(),
18393
18439
  });
18394
18440
 
18395
18441
  const CATEGORY_URLS = {
@@ -18401,8 +18447,8 @@ const CATEGORY_URLS = {
18401
18447
 
18402
18448
  async function DEFILLAMA() {
18403
18449
  try {
18404
- const [category] = argsToArray(arguments);
18405
- validateParams(defillamaParamsSchema, { category });
18450
+ const [category, columnName = null] = argsToArray(arguments);
18451
+ validateParams(defillamaParamsSchema, { category, columnName });
18406
18452
  const url = CATEGORY_URLS[category];
18407
18453
  if (!url) throw new ValidationError(`Invalid category: ${category}`)
18408
18454
  const res = await fetch(url);
@@ -18422,10 +18468,12 @@ async function DEFILLAMA() {
18422
18468
  break
18423
18469
  }
18424
18470
 
18471
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18472
+
18425
18473
  return (Array.isArray(json) ? json : [json]).map(item => {
18426
18474
  const out = {};
18427
18475
  for (const [k, v] of Object.entries(item)) {
18428
- if (v === null || typeof v !== 'object') out[k] = v;
18476
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
18429
18477
  }
18430
18478
  return out
18431
18479
  })
@@ -18440,6 +18488,7 @@ const gasSchema = objectType({
18440
18488
  endDate: dateOrTimestamp.optional(),
18441
18489
  page: numberType().int().nonnegative().default(1),
18442
18490
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18491
+ columnName: stringType().optional(),
18443
18492
  });
18444
18493
 
18445
18494
  const txnSchema = objectType({
@@ -18450,6 +18499,7 @@ const txnSchema = objectType({
18450
18499
  chain: enumType(['ethereum','base','gnosis']),
18451
18500
  page: numberType().int().nonnegative().default(1),
18452
18501
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18502
+ columnName: stringType().optional(),
18453
18503
  });
18454
18504
 
18455
18505
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
@@ -18463,18 +18513,18 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
18463
18513
 
18464
18514
  async function ETHERSCAN() {
18465
18515
  try {
18466
- const [type, chain, address, startDate, endDate, page = 1, limit = 10] =
18516
+ const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
18467
18517
  argsToArray(arguments);
18468
18518
 
18469
18519
 
18470
- validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit });
18520
+ validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit, columnName });
18471
18521
 
18472
18522
  const chainId = CHAIN_ID_MAP[chain];
18473
18523
  if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
18474
18524
 
18475
18525
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18476
18526
 
18477
- return await handleScanRequest({
18527
+ const out = await handleScanRequest({
18478
18528
  type,
18479
18529
  address,
18480
18530
  startDate,
@@ -18485,7 +18535,18 @@ async function ETHERSCAN() {
18485
18535
  functionName: 'ETHERSCAN',
18486
18536
  chainId,
18487
18537
  network: chain,
18488
- })
18538
+ });
18539
+ if (columnName) {
18540
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18541
+ return out.map(obj =>
18542
+ Object.fromEntries(
18543
+ filterColumnName
18544
+ .filter(key => key in obj)
18545
+ .map(key => [key, obj[key]])
18546
+ )
18547
+ );
18548
+ }
18549
+ return out
18489
18550
  } catch (err) {
18490
18551
  return errorMessageHandler(err, 'ETHERSCAN')
18491
18552
  }
@@ -18924,13 +18985,14 @@ const uniswapParamsSchema = objectType({
18924
18985
  category: enumType(['tokens','markets']),
18925
18986
  param1: stringType().nonempty(),
18926
18987
  param2: stringType().optional(),
18988
+ colummnName: stringType().optional(),
18927
18989
  });
18928
18990
 
18929
18991
  async function UNISWAP() {
18930
18992
  try {
18931
- const [graphType, category, param1, param2] = argsToArray(arguments);
18993
+ const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
18932
18994
 
18933
- validateParams(uniswapParamsSchema, { graphType, category, param1, param2 });
18995
+ validateParams(uniswapParamsSchema, { graphType, category, param1, param2, columnName });
18934
18996
 
18935
18997
  const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
18936
18998
  const url =
@@ -18948,16 +19010,24 @@ async function UNISWAP() {
18948
19010
  }
18949
19011
 
18950
19012
  const json = await res.json();
19013
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18951
19014
  if (Array.isArray(json)) {
18952
19015
  // flatten nested
18953
19016
  return json.map(item => {
18954
19017
  const flat = {};
18955
19018
  Object.entries(item).forEach(([k, v]) => {
18956
- if (v === null || typeof v !== 'object') flat[k] = v;
19019
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
18957
19020
  });
18958
19021
  return flat
18959
19022
  })
18960
19023
  }
19024
+ if(columnName && typeof json === 'object') {
19025
+ const data = {};
19026
+ filterColumnName.forEach(k => {
19027
+ data[k] = json[k];
19028
+ });
19029
+ return data
19030
+ }
18961
19031
  return json
18962
19032
  } catch (err) {
18963
19033
  return errorMessageHandler(err, 'UNISWAP')
@@ -18967,6 +19037,7 @@ async function UNISWAP() {
18967
19037
  async function SMARTCONTRACT() {
18968
19038
  try {
18969
19039
  const args = argsToArray(arguments);
19040
+ console.log(args, arguments);
18970
19041
 
18971
19042
  return new Promise((resolve) => {
18972
19043
  resolve( {
@@ -29870,14 +29941,15 @@ class CirclesData {
29870
29941
  const circlesParamsSchema = objectType({
29871
29942
  functionName: enumType(['trust', 'profile', 'transactions', 'balances']),
29872
29943
  address: stringType().nonempty(),
29873
- entries: numberType().int().nonnegative().default(10)
29944
+ entries: numberType().int().nonnegative().default(10),
29945
+ columnName: stringType().optional(),
29874
29946
  });
29875
29947
 
29876
29948
  async function CIRCLES() {
29877
29949
  try {
29878
- const [functionName, address, entries] = argsToArray(arguments);
29950
+ const [functionName, address, entries, columnName] = argsToArray(arguments);
29879
29951
 
29880
- validateParams(circlesParamsSchema, { functionName, address, entries });
29952
+ validateParams(circlesParamsSchema, { functionName, address, entries, columnName });
29881
29953
 
29882
29954
  const resolved = await fromEnsNameToAddress$1.validateAndGetAddress(address);
29883
29955
  const dataClient = new CirclesData('https://rpc.aboutcircles.com');
@@ -29895,10 +29967,34 @@ async function CIRCLES() {
29895
29967
 
29896
29968
  switch (functionName) {
29897
29969
  case 'trust':
29898
- return await runOnePage(dataClient.getTrustRelations(resolved, limit))
29970
+ const dataTrust = await runOnePage(dataClient.getTrustRelations(resolved, limit));
29971
+ if (columnName) {
29972
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29973
+ return dataTrust.map(obj =>
29974
+ Object.fromEntries(
29975
+ filterColumnName
29976
+ .filter(key => key in obj)
29977
+ .map(key => [key, obj[key]])
29978
+ )
29979
+ );
29980
+ } else {
29981
+ return dataTrust;
29982
+ }
29899
29983
 
29900
29984
  case 'transactions':
29901
- return await runOnePage(dataClient.getTransactionHistory(resolved, limit))
29985
+ const data = await runOnePage(dataClient.getTransactionHistory(resolved, limit));
29986
+ if (columnName) {
29987
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29988
+ return data.map(obj =>
29989
+ Object.fromEntries(
29990
+ filterColumnName
29991
+ .filter(key => key in obj)
29992
+ .map(key => [key, obj[key]])
29993
+ )
29994
+ );
29995
+ } else {
29996
+ return data;
29997
+ }
29902
29998
 
29903
29999
  case 'profile': {
29904
30000
  const res = await dataClient.getAvatarInfo(resolved);
@@ -236,6 +236,13 @@ var EOA_metadata = {
236
236
  example: "10",
237
237
  require: "o",
238
238
  type: "number"
239
+ },
240
+ {
241
+ name: "columnsName",
242
+ detail: "Filter columns by name in output. Comma separated list.",
243
+ example: `"id,address"`,
244
+ require: "o",
245
+ type: "string"
239
246
  }
240
247
  ]
241
248
  };
@@ -270,6 +277,13 @@ var UNISWAP_metadata = {
270
277
  example: `"eth"`,
271
278
  require: "m",
272
279
  type: "string"
280
+ },
281
+ {
282
+ name: "columnsName",
283
+ detail: "Filter columns by name in output. Comma separated list.",
284
+ example: `"id,address"`,
285
+ require: "o",
286
+ type: "string"
273
287
  }
274
288
  ]
275
289
  };
@@ -305,6 +319,13 @@ If "derivatives": exchange name (e.g., "binance_futures", "hyperliquid", "weex-f
305
319
  detail: `If "market" and "stablecoins" then eg. "1h", "24h", "7d", "14d", "30d", "200d", "1y".`,
306
320
  example: `"1h,24h,7d"`,
307
321
  require: "o"
322
+ },
323
+ {
324
+ name: "columnsName",
325
+ detail: "Filter columns by name in output. Comma separated list.",
326
+ example: `"id,address"`,
327
+ require: "o",
328
+ type: "string"
308
329
  }
309
330
  ]
310
331
  };
@@ -326,6 +347,13 @@ var DEFILLAMA_metadata = {
326
347
  example: `"protocols"`,
327
348
  require: "m",
328
349
  type: "string"
350
+ },
351
+ {
352
+ name: "columnsName",
353
+ detail: "Filter columns by name in output. Comma separated list.",
354
+ example: `"id,address"`,
355
+ require: "o",
356
+ type: "string"
329
357
  }
330
358
  ]
331
359
  };
@@ -382,6 +410,13 @@ var BASE_metadata = {
382
410
  example: `2`,
383
411
  require: "o",
384
412
  type: "number"
413
+ },
414
+ {
415
+ name: "columnsName",
416
+ detail: "Filter columns by name in output. Comma separated list.",
417
+ example: `"id,address"`,
418
+ require: "o",
419
+ type: "string"
385
420
  }
386
421
  ]
387
422
  };
@@ -487,6 +522,13 @@ var ETHERSCAN_metadata = {
487
522
  example: `"01/07/2025"`,
488
523
  require: "o",
489
524
  type: "string"
525
+ },
526
+ {
527
+ name: "columnsName",
528
+ detail: "Filter columns by name in output. Comma separated list.",
529
+ example: `"id,address"`,
530
+ require: "o",
531
+ type: "string"
490
532
  }
491
533
  ]
492
534
  };
@@ -657,6 +699,13 @@ var AAVE_metadata = {
657
699
  example: `"USDT"`,
658
700
  require: "m",
659
701
  type: "string"
702
+ },
703
+ {
704
+ name: "columnsName",
705
+ detail: "Filter columns by name in output. Comma separated list.",
706
+ example: `"balance"`,
707
+ require: "o",
708
+ type: "string"
660
709
  }
661
710
  ]
662
711
  };
@@ -1036,6 +1085,13 @@ var CIRCLES_metadata = {
1036
1085
  example: `10`,
1037
1086
  require: "o",
1038
1087
  type: "number"
1088
+ },
1089
+ {
1090
+ name: "columnsName",
1091
+ detail: "Filter columns by name in output. Comma separated list.",
1092
+ example: `"id,address"`,
1093
+ require: "o",
1094
+ type: "string"
1039
1095
  }
1040
1096
  ]
1041
1097
  };