@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/esm/index.mjs CHANGED
@@ -17695,15 +17695,16 @@ const aaveParamsSchema = objectType({
17695
17695
  category: enumType(['tokens','markets']),
17696
17696
  param1: stringType().nonempty(),
17697
17697
  param2: stringType().optional(),
17698
+ columnName: stringType().optional(),
17698
17699
  });
17699
17700
 
17700
17701
  async function AAVE() {
17701
17702
  try {
17702
17703
 
17703
- const [graphType, category, param1, param2] = argsToArray(arguments);
17704
+ const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
17704
17705
 
17705
17706
 
17706
- validateParams(aaveParamsSchema, { graphType, category, param1, param2 });
17707
+ validateParams(aaveParamsSchema, { graphType, category, param1, param2, columnName });
17707
17708
 
17708
17709
  const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
17709
17710
  const url =
@@ -17720,16 +17721,25 @@ async function AAVE() {
17720
17721
  }
17721
17722
 
17722
17723
  const json = await res.json();
17724
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
17725
+
17723
17726
  if (Array.isArray(json)) {
17724
17727
  return json.map(item => {
17725
17728
  const flat = {};
17726
17729
  Object.entries(item).forEach(([k, v]) => {
17727
- if (v === null || typeof v !== 'object') flat[k] = v;
17730
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
17728
17731
  });
17729
17732
  return flat
17730
17733
  })
17731
17734
  }
17732
- return json
17735
+ if(columnName && typeof json === 'object') {
17736
+ const data = {};
17737
+ filterColumnName.forEach(k => {
17738
+ data[k] = json[k];
17739
+ });
17740
+ return data
17741
+ }
17742
+ return json;
17733
17743
  } catch (err) {
17734
17744
  return errorMessageHandler(err, 'AAVE')
17735
17745
  }
@@ -17769,6 +17779,7 @@ const baseSchema = objectType({
17769
17779
  endTime: dateOrTimestamp.optional(),
17770
17780
  page: numberType().int().nonnegative().default(1),
17771
17781
  offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17782
+ columnName: stringType().optional(),
17772
17783
  });
17773
17784
 
17774
17785
  const eoaParamsSchema = preprocessType(
@@ -17998,9 +18009,9 @@ function toTimestamp(dateStr) {
17998
18009
 
17999
18010
  async function EOA() {
18000
18011
  try {
18001
- const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
18012
+ const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName = null] =
18002
18013
  argsToArray(arguments);
18003
- validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
18014
+ validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset, columnName });
18004
18015
 
18005
18016
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18006
18017
 
@@ -18070,6 +18081,16 @@ async function EOA() {
18070
18081
  }
18071
18082
  }
18072
18083
  }
18084
+ if(columnName){
18085
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18086
+ return out.map(obj =>
18087
+ Object.fromEntries(
18088
+ filterColumnName
18089
+ .filter(key => key in obj)
18090
+ .map(key => [key, obj[key]])
18091
+ )
18092
+ );
18093
+ }
18073
18094
  return out
18074
18095
  } catch (err) {
18075
18096
  return errorMessageHandler(err, 'EOA')
@@ -18082,6 +18103,7 @@ const gasSchema$1 = objectType({
18082
18103
  endDate: dateOrTimestamp.optional(),
18083
18104
  page: numberType().int().nonnegative().default(1),
18084
18105
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18106
+ columnName: stringType().optional(),
18085
18107
  });
18086
18108
 
18087
18109
  const txnSchema$1 = objectType({
@@ -18091,6 +18113,7 @@ const txnSchema$1 = objectType({
18091
18113
  endDate: dateOrTimestamp.optional(),
18092
18114
  page: numberType().int().nonnegative().default(1),
18093
18115
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18116
+ columnName: stringType().optional(),
18094
18117
  });
18095
18118
 
18096
18119
  const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
@@ -18167,11 +18190,11 @@ async function handleScanRequest({
18167
18190
 
18168
18191
  async function BASE() {
18169
18192
  try {
18170
- const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
18171
- validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
18193
+ const [type, address, startDate, endDate, page, limit, columnName] = argsToArray(arguments);
18194
+ validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit, columnName });
18172
18195
  const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
18173
18196
 
18174
- return await handleScanRequest({
18197
+ const out = await handleScanRequest({
18175
18198
  type,
18176
18199
  address,
18177
18200
  startDate,
@@ -18182,7 +18205,18 @@ async function BASE() {
18182
18205
  functionName: 'BASE',
18183
18206
  chainId: CHAIN_ID_MAP.base,
18184
18207
  network: 'base'
18185
- })
18208
+ });
18209
+ if (columnName) {
18210
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18211
+ return out.map(obj =>
18212
+ Object.fromEntries(
18213
+ filterColumnName
18214
+ .filter(key => key in obj)
18215
+ .map(key => [key, obj[key]])
18216
+ )
18217
+ );
18218
+ }
18219
+ return out
18186
18220
  } catch (error) {
18187
18221
  return errorMessageHandler(error, 'BASE')
18188
18222
  }
@@ -18302,6 +18336,7 @@ const derivativesSchema = objectType({
18302
18336
  category: literalType('derivatives'),
18303
18337
  param1: stringType().nonempty(),
18304
18338
  param2: anyType().optional(),
18339
+ columnName: stringType().optional(),
18305
18340
  });
18306
18341
  const coingeckoParamsSchema = discriminatedUnionType('category', [
18307
18342
  priceSchema$1,
@@ -18316,8 +18351,8 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
18316
18351
 
18317
18352
  async function COINGECKO() {
18318
18353
  try {
18319
- const [category, param1, param2] = argsToArray(arguments);
18320
- validateParams(coingeckoParamsSchema, { category, param1, param2 });
18354
+ const [category, param1, param2, columnName = null] = argsToArray(arguments);
18355
+ validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
18321
18356
 
18322
18357
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
18323
18358
 
@@ -18352,7 +18387,7 @@ async function COINGECKO() {
18352
18387
  break
18353
18388
  }
18354
18389
  }
18355
- const {URL: finalUrl, HEADERS} = getUrlAndHeaders({url, serviceName: 'Coingecko', headers});
18390
+ const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Coingecko', headers });
18356
18391
 
18357
18392
  const res = await fetch(finalUrl + "?refresh=true", { headers: HEADERS });
18358
18393
  const json = await res.json();
@@ -18378,6 +18413,16 @@ async function COINGECKO() {
18378
18413
  flat[key] = value;
18379
18414
  }
18380
18415
  }
18416
+ if (columnName) {
18417
+ const filterData = {};
18418
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18419
+ filterColumnName.forEach(col => {
18420
+ if (flat[col] !== undefined) {
18421
+ filterData[col] = flat[col];
18422
+ }
18423
+ });
18424
+ return filterData;
18425
+ }
18381
18426
  return flat
18382
18427
  })
18383
18428
  } catch (err) {
@@ -18387,7 +18432,8 @@ async function COINGECKO() {
18387
18432
 
18388
18433
  const categories = ['protocols','yields','dex','fees'];
18389
18434
  const defillamaParamsSchema = objectType({
18390
- category: enumType(categories)
18435
+ category: enumType(categories),
18436
+ columnName: stringType().optional(),
18391
18437
  });
18392
18438
 
18393
18439
  const CATEGORY_URLS = {
@@ -18399,8 +18445,8 @@ const CATEGORY_URLS = {
18399
18445
 
18400
18446
  async function DEFILLAMA() {
18401
18447
  try {
18402
- const [category] = argsToArray(arguments);
18403
- validateParams(defillamaParamsSchema, { category });
18448
+ const [category, columnName = null] = argsToArray(arguments);
18449
+ validateParams(defillamaParamsSchema, { category, columnName });
18404
18450
  const url = CATEGORY_URLS[category];
18405
18451
  if (!url) throw new ValidationError(`Invalid category: ${category}`)
18406
18452
  const res = await fetch(url);
@@ -18420,10 +18466,12 @@ async function DEFILLAMA() {
18420
18466
  break
18421
18467
  }
18422
18468
 
18469
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18470
+
18423
18471
  return (Array.isArray(json) ? json : [json]).map(item => {
18424
18472
  const out = {};
18425
18473
  for (const [k, v] of Object.entries(item)) {
18426
- if (v === null || typeof v !== 'object') out[k] = v;
18474
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
18427
18475
  }
18428
18476
  return out
18429
18477
  })
@@ -18438,6 +18486,7 @@ const gasSchema = objectType({
18438
18486
  endDate: dateOrTimestamp.optional(),
18439
18487
  page: numberType().int().nonnegative().default(1),
18440
18488
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18489
+ columnName: stringType().optional(),
18441
18490
  });
18442
18491
 
18443
18492
  const txnSchema = objectType({
@@ -18448,6 +18497,7 @@ const txnSchema = objectType({
18448
18497
  chain: enumType(['ethereum','base','gnosis']),
18449
18498
  page: numberType().int().nonnegative().default(1),
18450
18499
  limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
18500
+ columnName: stringType().optional(),
18451
18501
  });
18452
18502
 
18453
18503
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
@@ -18461,18 +18511,18 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
18461
18511
 
18462
18512
  async function ETHERSCAN() {
18463
18513
  try {
18464
- const [type, chain, address, startDate, endDate, page = 1, limit = 10] =
18514
+ const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
18465
18515
  argsToArray(arguments);
18466
18516
 
18467
18517
 
18468
- validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit });
18518
+ validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit, columnName });
18469
18519
 
18470
18520
  const chainId = CHAIN_ID_MAP[chain];
18471
18521
  if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
18472
18522
 
18473
18523
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18474
18524
 
18475
- return await handleScanRequest({
18525
+ const out = await handleScanRequest({
18476
18526
  type,
18477
18527
  address,
18478
18528
  startDate,
@@ -18483,7 +18533,18 @@ async function ETHERSCAN() {
18483
18533
  functionName: 'ETHERSCAN',
18484
18534
  chainId,
18485
18535
  network: chain,
18486
- })
18536
+ });
18537
+ if (columnName) {
18538
+ const filterColumnName = columnName.split(',').map(s => s.trim());
18539
+ return out.map(obj =>
18540
+ Object.fromEntries(
18541
+ filterColumnName
18542
+ .filter(key => key in obj)
18543
+ .map(key => [key, obj[key]])
18544
+ )
18545
+ );
18546
+ }
18547
+ return out
18487
18548
  } catch (err) {
18488
18549
  return errorMessageHandler(err, 'ETHERSCAN')
18489
18550
  }
@@ -18922,13 +18983,14 @@ const uniswapParamsSchema = objectType({
18922
18983
  category: enumType(['tokens','markets']),
18923
18984
  param1: stringType().nonempty(),
18924
18985
  param2: stringType().optional(),
18986
+ colummnName: stringType().optional(),
18925
18987
  });
18926
18988
 
18927
18989
  async function UNISWAP() {
18928
18990
  try {
18929
- const [graphType, category, param1, param2] = argsToArray(arguments);
18991
+ const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
18930
18992
 
18931
- validateParams(uniswapParamsSchema, { graphType, category, param1, param2 });
18993
+ validateParams(uniswapParamsSchema, { graphType, category, param1, param2, columnName });
18932
18994
 
18933
18995
  const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
18934
18996
  const url =
@@ -18946,16 +19008,24 @@ async function UNISWAP() {
18946
19008
  }
18947
19009
 
18948
19010
  const json = await res.json();
19011
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
18949
19012
  if (Array.isArray(json)) {
18950
19013
  // flatten nested
18951
19014
  return json.map(item => {
18952
19015
  const flat = {};
18953
19016
  Object.entries(item).forEach(([k, v]) => {
18954
- if (v === null || typeof v !== 'object') flat[k] = v;
19017
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
18955
19018
  });
18956
19019
  return flat
18957
19020
  })
18958
19021
  }
19022
+ if(columnName && typeof json === 'object') {
19023
+ const data = {};
19024
+ filterColumnName.forEach(k => {
19025
+ data[k] = json[k];
19026
+ });
19027
+ return data
19028
+ }
18959
19029
  return json
18960
19030
  } catch (err) {
18961
19031
  return errorMessageHandler(err, 'UNISWAP')
@@ -18965,6 +19035,7 @@ async function UNISWAP() {
18965
19035
  async function SMARTCONTRACT() {
18966
19036
  try {
18967
19037
  const args = argsToArray(arguments);
19038
+ console.log(args, arguments);
18968
19039
 
18969
19040
  return new Promise((resolve) => {
18970
19041
  resolve( {
@@ -29868,14 +29939,15 @@ class CirclesData {
29868
29939
  const circlesParamsSchema = objectType({
29869
29940
  functionName: enumType(['trust', 'profile', 'transactions', 'balances']),
29870
29941
  address: stringType().nonempty(),
29871
- entries: numberType().int().nonnegative().default(10)
29942
+ entries: numberType().int().nonnegative().default(10),
29943
+ columnName: stringType().optional(),
29872
29944
  });
29873
29945
 
29874
29946
  async function CIRCLES() {
29875
29947
  try {
29876
- const [functionName, address, entries] = argsToArray(arguments);
29948
+ const [functionName, address, entries, columnName] = argsToArray(arguments);
29877
29949
 
29878
- validateParams(circlesParamsSchema, { functionName, address, entries });
29950
+ validateParams(circlesParamsSchema, { functionName, address, entries, columnName });
29879
29951
 
29880
29952
  const resolved = await fromEnsNameToAddress$1.validateAndGetAddress(address);
29881
29953
  const dataClient = new CirclesData('https://rpc.aboutcircles.com');
@@ -29893,10 +29965,34 @@ async function CIRCLES() {
29893
29965
 
29894
29966
  switch (functionName) {
29895
29967
  case 'trust':
29896
- return await runOnePage(dataClient.getTrustRelations(resolved, limit))
29968
+ const dataTrust = await runOnePage(dataClient.getTrustRelations(resolved, limit));
29969
+ if (columnName) {
29970
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29971
+ return dataTrust.map(obj =>
29972
+ Object.fromEntries(
29973
+ filterColumnName
29974
+ .filter(key => key in obj)
29975
+ .map(key => [key, obj[key]])
29976
+ )
29977
+ );
29978
+ } else {
29979
+ return dataTrust;
29980
+ }
29897
29981
 
29898
29982
  case 'transactions':
29899
- return await runOnePage(dataClient.getTransactionHistory(resolved, limit))
29983
+ const data = await runOnePage(dataClient.getTransactionHistory(resolved, limit));
29984
+ if (columnName) {
29985
+ const filterColumnName = columnName.split(',').map(s => s.trim());
29986
+ return data.map(obj =>
29987
+ Object.fromEntries(
29988
+ filterColumnName
29989
+ .filter(key => key in obj)
29990
+ .map(key => [key, obj[key]])
29991
+ )
29992
+ );
29993
+ } else {
29994
+ return data;
29995
+ }
29900
29996
 
29901
29997
  case 'profile': {
29902
29998
  const res = await dataClient.getAvatarInfo(resolved);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.38",
3
+ "version": "4.4.39",
4
4
  "description": "JavaScript implementation of most Microsoft Excel formula functions",
5
5
  "author": "Formulajs",
6
6
  "publishConfig": {