@fileverse-dev/formulajs 4.4.38 → 4.4.41-example

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,
@@ -18315,11 +18350,10 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
18315
18350
  /* global window */
18316
18351
 
18317
18352
 
18318
-
18319
18353
  async function COINGECKO() {
18320
18354
  try {
18321
- const [category, param1, param2] = argsToArray(arguments);
18322
- validateParams(coingeckoParamsSchema, { category, param1, param2 });
18355
+ const [category, param1, param2, columnName = null] = argsToArray(arguments);
18356
+ validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
18323
18357
 
18324
18358
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
18325
18359
 
@@ -18354,7 +18388,7 @@ async function COINGECKO() {
18354
18388
  break
18355
18389
  }
18356
18390
  }
18357
- const {URL: finalUrl, HEADERS} = getUrlAndHeaders({url, serviceName: 'Coingecko', headers});
18391
+ const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Coingecko', headers });
18358
18392
 
18359
18393
  const res = await fetch(finalUrl + "?refresh=true", { headers: HEADERS });
18360
18394
  const json = await res.json();
@@ -18380,6 +18414,16 @@ async function COINGECKO() {
18380
18414
  flat[key] = value;
18381
18415
  }
18382
18416
  }
18417
+ if (columnName) {
18418
+ const filterData = {};
18419
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18420
+ filterColumnName.forEach(col => {
18421
+ if (flat[col] !== undefined) {
18422
+ filterData[col] = flat[col];
18423
+ }
18424
+ });
18425
+ return filterData;
18426
+ }
18383
18427
  return flat
18384
18428
  })
18385
18429
  } catch (err) {
@@ -18389,7 +18433,8 @@ async function COINGECKO() {
18389
18433
 
18390
18434
  const categories = ['protocols','yields','dex','fees'];
18391
18435
  const defillamaParamsSchema = objectType({
18392
- category: enumType(categories)
18436
+ category: enumType(categories),
18437
+ columnName: stringType().optional(),
18393
18438
  });
18394
18439
 
18395
18440
  const CATEGORY_URLS = {
@@ -18401,8 +18446,8 @@ const CATEGORY_URLS = {
18401
18446
 
18402
18447
  async function DEFILLAMA() {
18403
18448
  try {
18404
- const [category] = argsToArray(arguments);
18405
- validateParams(defillamaParamsSchema, { category });
18449
+ const [category, columnName = null] = argsToArray(arguments);
18450
+ validateParams(defillamaParamsSchema, { category, columnName });
18406
18451
  const url = CATEGORY_URLS[category];
18407
18452
  if (!url) throw new ValidationError(`Invalid category: ${category}`)
18408
18453
  const res = await fetch(url);
@@ -18422,10 +18467,12 @@ async function DEFILLAMA() {
18422
18467
  break
18423
18468
  }
18424
18469
 
18470
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18471
+
18425
18472
  return (Array.isArray(json) ? json : [json]).map(item => {
18426
18473
  const out = {};
18427
18474
  for (const [k, v] of Object.entries(item)) {
18428
- if (v === null || typeof v !== 'object') out[k] = v;
18475
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
18429
18476
  }
18430
18477
  return out
18431
18478
  })
@@ -18440,6 +18487,7 @@ const gasSchema = objectType({
18440
18487
  endDate: dateOrTimestamp.optional(),
18441
18488
  page: numberType().int().nonnegative().default(1),
18442
18489
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18490
+ columnName: stringType().optional(),
18443
18491
  });
18444
18492
 
18445
18493
  const txnSchema = objectType({
@@ -18450,6 +18498,7 @@ const txnSchema = objectType({
18450
18498
  chain: enumType(['ethereum','base','gnosis']),
18451
18499
  page: numberType().int().nonnegative().default(1),
18452
18500
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18501
+ columnName: stringType().optional(),
18453
18502
  });
18454
18503
 
18455
18504
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
@@ -18463,18 +18512,18 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
18463
18512
 
18464
18513
  async function ETHERSCAN() {
18465
18514
  try {
18466
- const [type, chain, address, startDate, endDate, page = 1, limit = 10] =
18515
+ const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
18467
18516
  argsToArray(arguments);
18468
18517
 
18469
18518
 
18470
- validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit });
18519
+ validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit, columnName });
18471
18520
 
18472
18521
  const chainId = CHAIN_ID_MAP[chain];
18473
18522
  if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
18474
18523
 
18475
18524
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18476
18525
 
18477
- return await handleScanRequest({
18526
+ const out = await handleScanRequest({
18478
18527
  type,
18479
18528
  address,
18480
18529
  startDate,
@@ -18485,7 +18534,18 @@ async function ETHERSCAN() {
18485
18534
  functionName: 'ETHERSCAN',
18486
18535
  chainId,
18487
18536
  network: chain,
18488
- })
18537
+ });
18538
+ if (columnName) {
18539
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18540
+ return out.map(obj =>
18541
+ Object.fromEntries(
18542
+ filterColumnName
18543
+ .filter(key => key in obj)
18544
+ .map(key => [key, obj[key]])
18545
+ )
18546
+ );
18547
+ }
18548
+ return out
18489
18549
  } catch (err) {
18490
18550
  return errorMessageHandler(err, 'ETHERSCAN')
18491
18551
  }
@@ -18924,13 +18984,14 @@ const uniswapParamsSchema = objectType({
18924
18984
  category: enumType(['tokens','markets']),
18925
18985
  param1: stringType().nonempty(),
18926
18986
  param2: stringType().optional(),
18987
+ colummnName: stringType().optional(),
18927
18988
  });
18928
18989
 
18929
18990
  async function UNISWAP() {
18930
18991
  try {
18931
- const [graphType, category, param1, param2] = argsToArray(arguments);
18992
+ const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
18932
18993
 
18933
- validateParams(uniswapParamsSchema, { graphType, category, param1, param2 });
18994
+ validateParams(uniswapParamsSchema, { graphType, category, param1, param2, columnName });
18934
18995
 
18935
18996
  const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
18936
18997
  const url =
@@ -18948,16 +19009,24 @@ async function UNISWAP() {
18948
19009
  }
18949
19010
 
18950
19011
  const json = await res.json();
19012
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18951
19013
  if (Array.isArray(json)) {
18952
19014
  // flatten nested
18953
19015
  return json.map(item => {
18954
19016
  const flat = {};
18955
19017
  Object.entries(item).forEach(([k, v]) => {
18956
- if (v === null || typeof v !== 'object') flat[k] = v;
19018
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
18957
19019
  });
18958
19020
  return flat
18959
19021
  })
18960
19022
  }
19023
+ if(columnName && typeof json === 'object') {
19024
+ const data = {};
19025
+ filterColumnName.forEach(k => {
19026
+ data[k] = json[k];
19027
+ });
19028
+ return data
19029
+ }
18961
19030
  return json
18962
19031
  } catch (err) {
18963
19032
  return errorMessageHandler(err, 'UNISWAP')
@@ -18967,6 +19036,7 @@ async function UNISWAP() {
18967
19036
  async function SMARTCONTRACT() {
18968
19037
  try {
18969
19038
  const args = argsToArray(arguments);
19039
+ console.log(args, arguments);
18970
19040
 
18971
19041
  return new Promise((resolve) => {
18972
19042
  resolve( {
@@ -29870,14 +29940,15 @@ class CirclesData {
29870
29940
  const circlesParamsSchema = objectType({
29871
29941
  functionName: enumType(['trust', 'profile', 'transactions', 'balances']),
29872
29942
  address: stringType().nonempty(),
29873
- entries: numberType().int().nonnegative().default(10)
29943
+ entries: numberType().int().nonnegative().default(10),
29944
+ columnName: stringType().optional(),
29874
29945
  });
29875
29946
 
29876
29947
  async function CIRCLES() {
29877
29948
  try {
29878
- const [functionName, address, entries] = argsToArray(arguments);
29949
+ const [functionName, address, entries, columnName] = argsToArray(arguments);
29879
29950
 
29880
- validateParams(circlesParamsSchema, { functionName, address, entries });
29951
+ validateParams(circlesParamsSchema, { functionName, address, entries, columnName });
29881
29952
 
29882
29953
  const resolved = await fromEnsNameToAddress$1.validateAndGetAddress(address);
29883
29954
  const dataClient = new CirclesData('https://rpc.aboutcircles.com');
@@ -29895,10 +29966,34 @@ async function CIRCLES() {
29895
29966
 
29896
29967
  switch (functionName) {
29897
29968
  case 'trust':
29898
- return await runOnePage(dataClient.getTrustRelations(resolved, limit))
29969
+ const dataTrust = await runOnePage(dataClient.getTrustRelations(resolved, limit));
29970
+ if (columnName) {
29971
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29972
+ return dataTrust.map(obj =>
29973
+ Object.fromEntries(
29974
+ filterColumnName
29975
+ .filter(key => key in obj)
29976
+ .map(key => [key, obj[key]])
29977
+ )
29978
+ );
29979
+ } else {
29980
+ return dataTrust;
29981
+ }
29899
29982
 
29900
29983
  case 'transactions':
29901
- return await runOnePage(dataClient.getTransactionHistory(resolved, limit))
29984
+ const data = await runOnePage(dataClient.getTransactionHistory(resolved, limit));
29985
+ if (columnName) {
29986
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29987
+ return data.map(obj =>
29988
+ Object.fromEntries(
29989
+ filterColumnName
29990
+ .filter(key => key in obj)
29991
+ .map(key => [key, obj[key]])
29992
+ )
29993
+ );
29994
+ } else {
29995
+ return data;
29996
+ }
29902
29997
 
29903
29998
  case 'profile': {
29904
29999
  const res = await dataClient.getAvatarInfo(resolved);