@fileverse-dev/formulajs 4.4.11-mod-27 → 4.4.11-mod-28

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
@@ -13128,6 +13128,13 @@ if(!timestamp || !chain || !apiKey) return
13128
13128
 
13129
13129
  };
13130
13130
 
13131
+ function toTimestamp(dateStr) {
13132
+ // Expecting format: "DD/MM/YYYY"
13133
+ const [day, month, year] = dateStr.split("/").map(Number);
13134
+ const date = new Date(year, month - 1, day);
13135
+ return Math.floor(date.getTime() / 1000); // Unix timestamp in seconds
13136
+ }
13137
+
13131
13138
  async function handleScanRequest({
13132
13139
  scanKey,
13133
13140
  baseUrl,
@@ -13168,8 +13175,8 @@ if (scanKey === SERVICE_API_KEY.Gnosisscan) chainId = 'gnosis';
13168
13175
 
13169
13176
  if (!isNaN(startDate) && !isNaN(endDate)) {
13170
13177
  const [startBlock, endBlock] = await Promise.all([
13171
- fromTimeStampToBlock(startDate, chain, API_KEY),
13172
- fromTimeStampToBlock(endDate, chain, API_KEY),
13178
+ fromTimeStampToBlock(toTimestamp(startDate), chain, API_KEY),
13179
+ fromTimeStampToBlock(toTimestamp(endDate), chain, API_KEY),
13173
13180
  ]);
13174
13181
  url += `&startblock=${startBlock}&endblock=${endBlock}`;
13175
13182
  }
@@ -13193,13 +13200,6 @@ if (scanKey === SERVICE_API_KEY.Gnosisscan) chainId = 'gnosis';
13193
13200
  }
13194
13201
  }
13195
13202
 
13196
- function toTimestamp(dateStr) {
13197
- // Expecting format: "DD/MM/YYYY"
13198
- const [day, month, year] = dateStr.split("/").map(Number);
13199
- const date = new Date(year, month - 1, day);
13200
- return Math.floor(date.getTime() / 1000); // Unix timestamp in seconds
13201
- }
13202
-
13203
13203
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13204
13204
 
13205
13205
  var sha3 = {exports: {}};
@@ -13961,66 +13961,58 @@ function bytesToHex(bytes) {
13961
13961
  return Array.from(bytes).map(b => b.toString(16).padStart(2, "0")).join("");
13962
13962
  }
13963
13963
 
13964
- async function FIREFLY(platform, contentType, identifier) {
13964
+ async function FIREFLY(platform, contentType, identifier, start = 0, end = 10) {
13965
13965
  const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Firefly);
13966
13966
  if (!API_KEY) return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
13967
13967
 
13968
13968
  const baseUrl = "https://openapi.firefly.land/v1/fileverse/fetch";
13969
- const headers = {
13970
- "x-api-key": API_KEY,
13969
+ const headers = { "x-api-key": API_KEY };
13970
+
13971
+ const typeMap = {
13972
+ farcaster: {
13973
+ posts: "farcasterid",
13974
+ replies: "farcasterpostid",
13975
+ channels: "farcasterchannels",
13976
+ },
13977
+ lens: {
13978
+ posts: "lensid",
13979
+ replies: "lenspostid",
13980
+ }
13971
13981
  };
13972
13982
 
13973
- let query = "";
13974
- let type = "";
13983
+ const platformType = typeMap[platform]?.[contentType];
13984
+ if (!platformType) return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.INVALID_TYPE}`;
13975
13985
 
13976
- // normalize input
13977
- const normalizedId = identifier.trim().replace(/.*\/([^\/]+)$/, "$1"); // extract last part of URL if needed
13978
-
13979
- if (platform === "farcaster") {
13980
- if (contentType === "posts") {
13981
- type = "farcasterid";
13982
- query = normalizedId;
13983
- } else if (contentType === "replies") {
13984
- type = "farcasterpostid";
13985
- query = normalizedId.startsWith("0x") ? normalizedId : Number(normalizedId).toString();
13986
- } else {
13987
- return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.INVALID_TYPE}`;
13988
- }
13989
- } else if (platform === "lens") {
13990
- if (contentType === "posts") {
13991
- type = "lensid";
13992
- query = normalizedId;
13993
- } else if (contentType === "replies") {
13994
- type = "lenspostid";
13995
- query = normalizedId;
13996
- } else {
13997
- return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.INVALID_TYPE}`;
13998
- }
13999
- } else {
14000
- return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`;
14001
- }
13986
+ const query = identifier
13987
+ .split(",")
13988
+ .map(s => s.trim())
13989
+ .filter(Boolean)
13990
+ .join(",");
14002
13991
 
14003
13992
  const url = new URL(baseUrl);
14004
13993
  url.searchParams.set("query", query);
14005
- url.searchParams.set("type", type);
14006
- url.searchParams.set("size", "10");
14007
- url.searchParams.set("cursor", "0");
13994
+ url.searchParams.set("type", platformType);
13995
+ url.searchParams.set("start", String(start));
13996
+ url.searchParams.set("end", String(end));
14008
13997
 
14009
13998
  try {
14010
13999
  const res = await fetch(url.toString(), { headers });
14011
14000
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
14001
+
14012
14002
  const json = await res.json();
14013
- const flattened = Array.isArray(json?.data)
14014
- ? json.data.map(item => ({
14015
- id: item?.id || null,
14016
- author: item?.author?.username || item?.author?.handle || "",
14017
- text: item?.text || item?.metadata?.content?.content || "",
14018
- createdAt: item?.createdAt || "",
14019
- platform: platform,
14020
- }))
14021
- : [];
14022
-
14023
- return flattened;
14003
+ if (!Array.isArray(json?.data)) return [];
14004
+
14005
+ return json.data.map(item => {
14006
+ const flat = {};
14007
+ for (const [key, value] of Object.entries(item)) {
14008
+ if (typeof value !== "object" || value === null) {
14009
+ flat[key] = value;
14010
+ }
14011
+ }
14012
+ flat.platform = platform;
14013
+ return flat;
14014
+ });
14015
+
14024
14016
  } catch (err) {
14025
14017
  console.error("FIREFLY fetch error:", err);
14026
14018
  return ERROR_MESSAGES_FLAG.DEFAULT;
@@ -14028,6 +14020,9 @@ async function FIREFLY(platform, contentType, identifier) {
14028
14020
  }
14029
14021
 
14030
14022
 
14023
+
14024
+
14025
+
14031
14026
  async function BLOCKSCOUT(address, type, chain, startTimestamp, endTimestamp, page, offset) {
14032
14027
  if (!chain) {
14033
14028
  chain = 'ethereum';
@@ -14043,6 +14038,17 @@ async function BLOCKSCOUT(address, type, chain, startTimestamp, endTimestamp, pa
14043
14038
  startTimestamp = Math.floor(startTimestamp / 1000);
14044
14039
  }
14045
14040
 
14041
+ if(isNaN(startTimestamp)){
14042
+ startTimestamp = toTimestamp(startTimestamp);
14043
+ }
14044
+
14045
+
14046
+ if(isNaN(endTimestamp) && endTimestamp){
14047
+ endTimestamp = toTimestamp(endTimestamp);
14048
+ }
14049
+
14050
+
14051
+
14046
14052
  const hostname = BLOCKSCOUT_CHAINS_MAP[chain];
14047
14053
 
14048
14054
  let requestUrl;
@@ -14167,7 +14173,7 @@ async function NEYNAR(
14167
14173
  return ERROR_MESSAGES_FLAG.DEFAULT;
14168
14174
  }
14169
14175
  }
14170
- async function GNOSIS({
14176
+ async function GNOSISPAY({
14171
14177
  cardId,
14172
14178
  startDate,
14173
14179
  endDate,
@@ -14183,11 +14189,11 @@ async function GNOSIS({
14183
14189
  url.searchParams.set('limit', limit.toString());
14184
14190
  url.searchParams.set('offset', offset.toString());
14185
14191
 
14186
- if (!isNaN(startDate)) {
14192
+ if (!isNaN(toTimestamp(startDate))) {
14187
14193
  url.searchParams.set('startDate', new Date(startDate * 1000).toISOString());
14188
14194
  }
14189
14195
 
14190
- if (!isNaN(endDate)) {
14196
+ if (!isNaN(toTimestamp(endDate))) {
14191
14197
  url.searchParams.set('endDate', new Date(endDate * 1000).toISOString());
14192
14198
  }
14193
14199
 
@@ -14681,7 +14687,7 @@ exports.GAUSS = GAUSS;
14681
14687
  exports.GCD = GCD;
14682
14688
  exports.GEOMEAN = GEOMEAN;
14683
14689
  exports.GESTEP = GESTEP;
14684
- exports.GNOSIS = GNOSIS;
14690
+ exports.GNOSISPAY = GNOSISPAY;
14685
14691
  exports.GNOSISSCAN = GNOSISSCAN;
14686
14692
  exports.GROWTH = GROWTH;
14687
14693
  exports.HARMEAN = HARMEAN;
@@ -45,8 +45,8 @@ var FUNCTION_LOCALE = [
45
45
  BRAND_SECONDARY_COLOR: "#855dcd",
46
46
  n: "FIREFLY",
47
47
  t: 20,
48
- d: "Fetches posts or replies from Farcaster or Lens using Firefly's OpenAPI and returns simplified text content.",
49
- a: "Retrieves posts or replies from Firefly OpenAPI by username, user ID, or post ID/hash for Farcaster and Lens platforms. Returns a flattened array of content with id, author, text, createdAt, and platform.",
48
+ d: "Fetches content from Farcaster or Lens using Firefly's OpenAPI with pagination and cleaned output.",
49
+ a: "Retrieves posts, replies, or channels from Farcaster and Lens using Firefly's OpenAPI by usernames, IDs, or hashes. Removes nested values and returns flat spreadsheet-friendly data. Supports pagination.",
50
50
  p: [
51
51
  {
52
52
  name: "platform",
@@ -57,17 +57,31 @@ var FUNCTION_LOCALE = [
57
57
  },
58
58
  {
59
59
  name: "contentType",
60
- detail: "The type of content to fetch. Can be 'posts' or 'replies'.",
60
+ detail: "Type of content to fetch. Supports 'posts', 'replies', and 'channels' (channels only for 'farcaster').",
61
61
  example: `"posts"`,
62
62
  require: "m",
63
63
  type: "string"
64
64
  },
65
65
  {
66
66
  name: "identifier",
67
- detail: "The username, user ID, or post ID/hash depending on platform and contentType.",
68
- example: `"toka" or "0xcb6cab2048..."`,
67
+ detail: "Comma-separated usernames, IDs, or post hashes depending on platform and contentType.",
68
+ example: `"toka,ngmisl" or "0xcb6c...,0x98b8..."`,
69
69
  require: "m",
70
70
  type: "string"
71
+ },
72
+ {
73
+ name: "start",
74
+ detail: "Pagination start index (default is 0).",
75
+ example: `0`,
76
+ require: "o",
77
+ type: "number"
78
+ },
79
+ {
80
+ name: "end",
81
+ detail: "Pagination end index (default is 10).",
82
+ example: `10`,
83
+ require: "o",
84
+ type: "number"
71
85
  }
72
86
  ]
73
87
  },
@@ -151,14 +165,14 @@ var FUNCTION_LOCALE = [
151
165
  },
152
166
  {
153
167
  name: "startDate",
154
- detail: "Start UNIX timestamp in seconds (used to resolve block range). Optional, only applies to txns.",
168
+ detail: "Start date (used to resolve block range). Optional, only applies to txns.",
155
169
  example: `"1704067200"`,
156
170
  require: "o",
157
171
  type: "rangenumber"
158
172
  },
159
173
  {
160
174
  name: "endDate",
161
- detail: "End UNIX timestamp in seconds (used to resolve block range). Optional, only applies to txns.",
175
+ detail: "End date (used to resolve block range). Optional, only applies to txns.",
162
176
  example: `"20250614"`,
163
177
  require: "o",
164
178
  type: "rangenumber"
@@ -212,15 +226,15 @@ var FUNCTION_LOCALE = [
212
226
  },
213
227
  {
214
228
  name: "startDate",
215
- detail: "Start timestamp in UNIX seconds. Used to resolve starting block for txns.",
216
- example: `"1704067200"`,
229
+ detail: "Used to resolve starting block for txns.",
230
+ example: `"01/01/2024"`,
217
231
  require: "o",
218
232
  type: "rangenumber"
219
233
  },
220
234
  {
221
235
  name: "endDate",
222
- detail: "End timestamp in UNIX seconds. Used to resolve ending block for txns.",
223
- example: `"20250614"`,
236
+ detail: "Used to resolve ending block for txns.",
237
+ example: `"14/06/2025"`,
224
238
  require: "o",
225
239
  type: "rangenumber"
226
240
  },
@@ -272,15 +286,15 @@ var FUNCTION_LOCALE = [
272
286
  },
273
287
  {
274
288
  name: "startTimestamp",
275
- detail: 'The Unix timestamp marking the start of the transaction search range. Work with type === "txns"',
276
- example: "1704067200",
289
+ detail: 'Start date marking the start of the transaction search range. Work with type === "txns"',
290
+ example: "01/01/2024",
277
291
  require: "o",
278
292
  type: "rangenumber"
279
293
  },
280
294
  {
281
295
  name: "endTimestamp",
282
- detail: 'The Unix timestamp marking the end of the transaction search range. Work with type === "txns"',
283
- example: "1719792000",
296
+ detail: 'End date marking the end of the transaction search range. Work with type === "txns"',
297
+ example: "14/06/2025",
284
298
  require: "o",
285
299
  type: "rangenumber"
286
300
  },
@@ -335,15 +349,15 @@ var FUNCTION_LOCALE = [
335
349
  },
336
350
  {
337
351
  name: "startDate",
338
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
339
- example: `"1704067200"`,
352
+ detail: "Used to filter block range.",
353
+ example: `"01/01/2024"`,
340
354
  require: "o",
341
355
  type: "rangenumber"
342
356
  },
343
357
  {
344
358
  name: "endDate",
345
- detail: "End timestamp in seconds (optional). Used to filter block range.",
346
- example: `"1706659200"`,
359
+ detail: "Used to filter block range.",
360
+ example: `"01/07/2025"`,
347
361
  require: "o",
348
362
  type: "rangenumber"
349
363
  }
@@ -382,14 +396,14 @@ var FUNCTION_LOCALE = [
382
396
  },
383
397
  {
384
398
  name: "startTime",
385
- detail: "Start time in UNIX timestamp (seconds). Used to calculate starting block for transaction queries.",
399
+ detail: "Used to calculate starting block for transaction queries.",
386
400
  example: "01/01/2024",
387
401
  require: "m",
388
402
  type: "rangenumber"
389
403
  },
390
404
  {
391
405
  name: "endTime",
392
- detail: "End time in UNIX timestamp (seconds). Used to calculate ending block for transaction queries.",
406
+ detail: "Used to calculate ending block for transaction queries.",
393
407
  example: "01/07/2024",
394
408
  require: "m",
395
409
  type: "rangenumber"
@@ -578,15 +592,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
578
592
  },
579
593
  {
580
594
  name: "startDate",
581
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
582
- example: `"1704067200"`,
595
+ detail: "Used to filter block range.",
596
+ example: `"01/01/2024"`,
583
597
  require: "o",
584
598
  type: "rangenumber"
585
599
  },
586
600
  {
587
601
  name: "endDate",
588
- detail: "End timestamp in seconds (optional). Used to filter block range.",
589
- example: `"1706659200"`,
602
+ detail: "Used to filter block range.",
603
+ example: `"01/01/2025"`,
590
604
  require: "o",
591
605
  type: "rangenumber"
592
606
  }
@@ -625,15 +639,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
625
639
  },
626
640
  {
627
641
  name: "startDate",
628
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
629
- example: `"1704067200"`,
642
+ detail: "Used to filter block range.",
643
+ example: `"01/01/2024"`,
630
644
  require: "o",
631
645
  type: "rangenumber"
632
646
  },
633
647
  {
634
648
  name: "endDate",
635
- detail: "End timestamp in seconds (optional). Used to filter block range.",
636
- example: `"1706659200"`,
649
+ detail: "Used to filter block range.",
650
+ example: `"01/07/2025"`,
637
651
  require: "o",
638
652
  type: "rangenumber"
639
653
  }
@@ -672,15 +686,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
672
686
  },
673
687
  {
674
688
  name: "startDate",
675
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
676
- example: `"1704067200"`,
689
+ detail: "Used to filter block range.",
690
+ example: `"01/01/2024"`,
677
691
  require: "o",
678
692
  type: "rangenumber"
679
693
  },
680
694
  {
681
695
  name: "endDate",
682
- detail: "End timestamp in seconds (optional). Used to filter block range.",
683
- example: `"1706659200"`,
696
+ detail: "Used to filter block range.",
697
+ example: `"01/07/2025"`,
684
698
  require: "o",
685
699
  type: "rangenumber"
686
700
  }
@@ -719,15 +733,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
719
733
  },
720
734
  {
721
735
  name: "startDate",
722
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
723
- example: `"1704067200"`,
736
+ detail: "Used to filter block range.",
737
+ example: `"01/01/2024"`,
724
738
  require: "o",
725
739
  type: "rangenumber"
726
740
  },
727
741
  {
728
742
  name: "endDate",
729
- detail: "End timestamp in seconds (optional). Used to filter block range.",
730
- example: `"1706659200"`,
743
+ detail: "Used to filter block range.",
744
+ example: `"01/07/2025"`,
731
745
  require: "o",
732
746
  type: "rangenumber"
733
747
  }
@@ -766,15 +780,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
766
780
  },
767
781
  {
768
782
  name: "startDate",
769
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
770
- example: `"1704067200"`,
783
+ detail: "Used to filter block range.",
784
+ example: `"01/01/2024"`,
771
785
  require: "o",
772
786
  type: "rangenumber"
773
787
  },
774
788
  {
775
789
  name: "endDate",
776
- detail: "End timestamp in seconds (optional). Used to filter block range.",
777
- example: `"1706659200"`,
790
+ detail: "Used to filter block range.",
791
+ example: `"01/07/2025"`,
778
792
  require: "o",
779
793
  type: "rangenumber"
780
794
  }
@@ -813,15 +827,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
813
827
  },
814
828
  {
815
829
  name: "startDate",
816
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
817
- example: `"1704067200"`,
830
+ detail: "Used to filter block range.",
831
+ example: `"01/01/2024"`,
818
832
  require: "o",
819
833
  type: "rangenumber"
820
834
  },
821
835
  {
822
836
  name: "endDate",
823
- detail: "End timestamp in seconds (optional). Used to filter block range.",
824
- example: `"1706659200"`,
837
+ detail: "Used to filter block range.",
838
+ example: `"01/07/2025"`,
825
839
  require: "o",
826
840
  type: "rangenumber"
827
841
  }
@@ -832,7 +846,7 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
832
846
  LOGO: "https://gnosisscan.io/assets/generic/html/favicon-light.ico",
833
847
  BRAND_COLOR: "#f6f7f6",
834
848
  BRAND_SECONDARY_COLOR: "#133629",
835
- n: "GNOSIS",
849
+ n: "GNOSISPAY",
836
850
  t: 20,
837
851
  d: "Fetches Gnosis Pay card transaction history, including merchant, amount, and currency info.",
838
852
  a: "Retrieves card transactions from Gnosis Pay\u2019s API for a specific card ID, filtered by date range and paginated via limit/offset.",
@@ -846,15 +860,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
846
860
  },
847
861
  {
848
862
  name: "startDate",
849
- detail: "Start timestamp in seconds (UNIX). Filters transactions created after this date.",
850
- example: `"1704067200"`,
863
+ detail: "Filters transactions created after this date.",
864
+ example: `"01/01/2024"`,
851
865
  require: "o",
852
866
  type: "rangenumber"
853
867
  },
854
868
  {
855
869
  name: "endDate",
856
- detail: "End timestamp in seconds (UNIX). Filters transactions created before this date.",
857
- example: `"1706659200"`,
870
+ detail: "Filters transactions created before this date.",
871
+ example: `"01/07/2025"`,
858
872
  require: "o",
859
873
  type: "rangenumber"
860
874
  },
@@ -907,15 +921,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
907
921
  },
908
922
  {
909
923
  name: "startDate",
910
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
911
- example: `"1704067200"`,
924
+ detail: "Used to filter block range.",
925
+ example: `"01/01/2024"`,
912
926
  require: "o",
913
927
  type: "rangenumber"
914
928
  },
915
929
  {
916
930
  name: "endDate",
917
- detail: "End timestamp in seconds (optional). Used to filter block range.",
918
- example: `"1706659200"`,
931
+ detail: "Used to filter block range.",
932
+ example: `"01/07/2025"`,
919
933
  require: "o",
920
934
  type: "rangenumber"
921
935
  }
@@ -954,15 +968,15 @@ For "market" and "stablecoins": comma-separated price trend keys (e.g. 1h,24h,7d
954
968
  },
955
969
  {
956
970
  name: "startDate",
957
- detail: "Start timestamp in seconds (optional). Used to filter block range.",
958
- example: `"1704067200"`,
971
+ detail: "Used to filter block range.",
972
+ example: `"01/01/2024"`,
959
973
  require: "o",
960
974
  type: "rangenumber"
961
975
  },
962
976
  {
963
977
  name: "endDate",
964
- detail: "End timestamp in seconds (optional). Used to filter block range.",
965
- example: `"1706659200"`,
978
+ detail: "Used to filter block range.",
979
+ example: `"01/07/2025"`,
966
980
  require: "o",
967
981
  type: "rangenumber"
968
982
  }