@chainpatrol/sdk 0.3.0 → 0.4.1

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/dist/index.d.ts CHANGED
@@ -54,6 +54,14 @@ type ApiRequest = {
54
54
  };
55
55
  type AssetType = "URL" | "PAGE" | "ADDRESS";
56
56
  type AssetStatus = "ALLOWED" | "BLOCKED" | "UNKNOWN";
57
+ declare class ChainPatrolClientError extends Error {
58
+ readonly code: ChainPatrolClientErrorCodes;
59
+ constructor(message: string, code: ChainPatrolClientErrorCodes);
60
+ }
61
+ declare enum ChainPatrolClientErrorCodes {
62
+ MISSING_API_KEY = "MISSING_API_KEY",
63
+ API_ERROR = "API_ERROR"
64
+ }
57
65
  declare class ChainPatrolClient {
58
66
  readonly baseUrl: string;
59
67
  private readonly apiKey;
@@ -69,9 +77,9 @@ declare class ChainPatrolClient {
69
77
  id: number;
70
78
  createdAt: Date;
71
79
  organization: {
72
- slug: string;
73
- name: string;
74
80
  id: number;
81
+ name: string;
82
+ slug: string;
75
83
  } | null;
76
84
  }>;
77
85
  };
@@ -208,4 +216,4 @@ declare namespace index {
208
216
  };
209
217
  }
210
218
 
211
- export { AssetStatus, AssetType, ChainPatrolClient, ChainPatrolClientOptions, DetectorAssetStatus, DomainParseError, EventData, Events, Relay, index as Storage, ThreatDetector, URLResult };
219
+ export { AssetStatus, AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, ChainPatrolClientOptions, DetectorAssetStatus, DomainParseError, EventData, Events, Relay, index as Storage, ThreatDetector, URLResult };
package/dist/index.js CHANGED
@@ -466,6 +466,24 @@ function normalizeUrl(urlString, options) {
466
466
  }
467
467
  return urlString;
468
468
  }
469
+ zod.z.object({
470
+ assetId: zod.z.number()
471
+ });
472
+ zod.z.object({
473
+ id: zod.z.number().optional(),
474
+ assetId: zod.z.number().optional(),
475
+ active: zod.z.boolean()
476
+ });
477
+ zod.z.object({
478
+ // Required
479
+ content: zod.z.string().min(1, {
480
+ message: "Content is required"
481
+ }).max(1e3, {
482
+ message: "Content cannot be longer than 1000 characters"
483
+ }).describe("Asset content"),
484
+ name: zod.z.string().optional().describe("Asset name"),
485
+ description: zod.z.string().nullish().optional().describe("Asset description")
486
+ });
469
487
  zod.z.object({
470
488
  slug: zod.z.string(),
471
489
  assetId: zod.z.number(),
@@ -479,7 +497,7 @@ zod.z.object({
479
497
  description: zod.z.string().optional().default("")
480
498
  });
481
499
 
482
- // ../../node_modules/luxon/src/errors.js
500
+ // ../../internal/validation/node_modules/luxon/src/errors.js
483
501
  var LuxonError = class extends Error {
484
502
  };
485
503
  var InvalidDateTimeError = class extends LuxonError {
@@ -512,7 +530,7 @@ var ZoneIsAbstractError = class extends LuxonError {
512
530
  }
513
531
  };
514
532
 
515
- // ../../node_modules/luxon/src/impl/formats.js
533
+ // ../../internal/validation/node_modules/luxon/src/impl/formats.js
516
534
  var n = "numeric";
517
535
  var s = "short";
518
536
  var l = "long";
@@ -664,7 +682,7 @@ var DATETIME_HUGE_WITH_SECONDS = {
664
682
  timeZoneName: l
665
683
  };
666
684
 
667
- // ../../node_modules/luxon/src/impl/util.js
685
+ // ../../internal/validation/node_modules/luxon/src/impl/util.js
668
686
  function isUndefined(o) {
669
687
  return typeof o === "undefined";
670
688
  }
@@ -856,7 +874,7 @@ function timeObject(obj) {
856
874
  }
857
875
  var ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
858
876
 
859
- // ../../node_modules/luxon/src/impl/english.js
877
+ // ../../internal/validation/node_modules/luxon/src/impl/english.js
860
878
  var monthsLong = [
861
879
  "January",
862
880
  "February",
@@ -982,7 +1000,7 @@ function formatRelativeTime(unit, count, numeric = "always", narrow = false) {
982
1000
  return isInPast ? `${fmtValue} ${fmtUnit} ago` : `in ${fmtValue} ${fmtUnit}`;
983
1001
  }
984
1002
 
985
- // ../../node_modules/luxon/src/impl/formatter.js
1003
+ // ../../internal/validation/node_modules/luxon/src/impl/formatter.js
986
1004
  function stringifyTokens(splits, tokenToString) {
987
1005
  let s2 = "";
988
1006
  for (const token of splits) {
@@ -1260,7 +1278,7 @@ var Formatter = class _Formatter {
1260
1278
  }
1261
1279
  };
1262
1280
 
1263
- // ../../node_modules/luxon/src/impl/invalid.js
1281
+ // ../../internal/validation/node_modules/luxon/src/impl/invalid.js
1264
1282
  var Invalid = class {
1265
1283
  constructor(reason, explanation) {
1266
1284
  this.reason = reason;
@@ -1275,7 +1293,7 @@ var Invalid = class {
1275
1293
  }
1276
1294
  };
1277
1295
 
1278
- // ../../node_modules/luxon/src/zone.js
1296
+ // ../../internal/validation/node_modules/luxon/src/zone.js
1279
1297
  var Zone = class {
1280
1298
  /**
1281
1299
  * The type of zone
@@ -1355,7 +1373,7 @@ var Zone = class {
1355
1373
  }
1356
1374
  };
1357
1375
 
1358
- // ../../node_modules/luxon/src/zones/systemZone.js
1376
+ // ../../internal/validation/node_modules/luxon/src/zones/systemZone.js
1359
1377
  var singleton = null;
1360
1378
  var SystemZone = class _SystemZone extends Zone {
1361
1379
  /**
@@ -1402,7 +1420,7 @@ var SystemZone = class _SystemZone extends Zone {
1402
1420
  }
1403
1421
  };
1404
1422
 
1405
- // ../../node_modules/luxon/src/zones/IANAZone.js
1423
+ // ../../internal/validation/node_modules/luxon/src/zones/IANAZone.js
1406
1424
  var dtfCache = {};
1407
1425
  function makeDTF(zone) {
1408
1426
  if (!dtfCache[zone]) {
@@ -1557,7 +1575,7 @@ var IANAZone = class _IANAZone extends Zone {
1557
1575
  }
1558
1576
  };
1559
1577
 
1560
- // ../../node_modules/luxon/src/zones/fixedOffsetZone.js
1578
+ // ../../internal/validation/node_modules/luxon/src/zones/fixedOffsetZone.js
1561
1579
  var singleton2 = null;
1562
1580
  var FixedOffsetZone = class _FixedOffsetZone extends Zone {
1563
1581
  /**
@@ -1640,7 +1658,7 @@ var FixedOffsetZone = class _FixedOffsetZone extends Zone {
1640
1658
  }
1641
1659
  };
1642
1660
 
1643
- // ../../node_modules/luxon/src/zones/invalidZone.js
1661
+ // ../../internal/validation/node_modules/luxon/src/zones/invalidZone.js
1644
1662
  var InvalidZone = class extends Zone {
1645
1663
  constructor(zoneName) {
1646
1664
  super();
@@ -1680,7 +1698,7 @@ var InvalidZone = class extends Zone {
1680
1698
  }
1681
1699
  };
1682
1700
 
1683
- // ../../node_modules/luxon/src/impl/zoneUtil.js
1701
+ // ../../internal/validation/node_modules/luxon/src/impl/zoneUtil.js
1684
1702
  function normalizeZone(input, defaultZone2) {
1685
1703
  if (isUndefined(input) || input === null) {
1686
1704
  return defaultZone2;
@@ -1705,7 +1723,7 @@ function normalizeZone(input, defaultZone2) {
1705
1723
  }
1706
1724
  }
1707
1725
 
1708
- // ../../node_modules/luxon/src/settings.js
1726
+ // ../../internal/validation/node_modules/luxon/src/settings.js
1709
1727
  var now = () => Date.now();
1710
1728
  var defaultZone = "system";
1711
1729
  var defaultLocale = null;
@@ -1812,7 +1830,7 @@ var Settings = class {
1812
1830
  }
1813
1831
  };
1814
1832
 
1815
- // ../../node_modules/luxon/src/impl/locale.js
1833
+ // ../../internal/validation/node_modules/luxon/src/impl/locale.js
1816
1834
  var intlLFCache = {};
1817
1835
  function getCachedLF(locString, opts = {}) {
1818
1836
  const key = JSON.stringify([locString, opts]);
@@ -1951,15 +1969,15 @@ var PolyNumberFormatter = class {
1951
1969
  var PolyDateFormatter = class {
1952
1970
  constructor(dt, intl, opts) {
1953
1971
  this.opts = opts;
1954
- let z9;
1972
+ let z12;
1955
1973
  if (dt.zone.isUniversal) {
1956
1974
  const gmtOffset = -1 * (dt.offset / 60);
1957
1975
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
1958
1976
  if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
1959
- z9 = offsetZ;
1977
+ z12 = offsetZ;
1960
1978
  this.dt = dt;
1961
1979
  } else {
1962
- z9 = "UTC";
1980
+ z12 = "UTC";
1963
1981
  if (opts.timeZoneName) {
1964
1982
  this.dt = dt;
1965
1983
  } else {
@@ -1970,11 +1988,11 @@ var PolyDateFormatter = class {
1970
1988
  this.dt = dt;
1971
1989
  } else {
1972
1990
  this.dt = dt;
1973
- z9 = dt.zone.name;
1991
+ z12 = dt.zone.name;
1974
1992
  }
1975
1993
  const intlOpts = __spreadValues({}, this.opts);
1976
- if (z9) {
1977
- intlOpts.timeZone = z9;
1994
+ if (z12) {
1995
+ intlOpts.timeZone = z12;
1978
1996
  }
1979
1997
  this.dtf = getCachedDTF(intl, intlOpts);
1980
1998
  }
@@ -2144,7 +2162,7 @@ var Locale = class _Locale {
2144
2162
  }
2145
2163
  };
2146
2164
 
2147
- // ../../node_modules/luxon/src/impl/regexParser.js
2165
+ // ../../internal/validation/node_modules/luxon/src/impl/regexParser.js
2148
2166
  function combineRegexes(...regexes) {
2149
2167
  const full = regexes.reduce((f, r) => f + r.source, "");
2150
2168
  return RegExp(`^${full}$`);
@@ -2379,7 +2397,7 @@ function parseSQL(s2) {
2379
2397
  );
2380
2398
  }
2381
2399
 
2382
- // ../../node_modules/luxon/src/duration.js
2400
+ // ../../internal/validation/node_modules/luxon/src/duration.js
2383
2401
  var INVALID = "Invalid Duration";
2384
2402
  var lowOrderMatrix = {
2385
2403
  weeks: {
@@ -3174,7 +3192,7 @@ var Duration = class _Duration {
3174
3192
  }
3175
3193
  };
3176
3194
 
3177
- // ../../node_modules/luxon/src/interval.js
3195
+ // ../../internal/validation/node_modules/luxon/src/interval.js
3178
3196
  var INVALID2 = "Invalid Interval";
3179
3197
  function validateStartEnd(start, end) {
3180
3198
  if (!start || !start.isValid) {
@@ -3687,7 +3705,7 @@ var Interval = class _Interval {
3687
3705
  }
3688
3706
  };
3689
3707
 
3690
- // ../../node_modules/luxon/src/info.js
3708
+ // ../../internal/validation/node_modules/luxon/src/info.js
3691
3709
  var Info = class {
3692
3710
  /**
3693
3711
  * Return whether the specified zone contains a DST.
@@ -3828,7 +3846,7 @@ var Info = class {
3828
3846
  }
3829
3847
  };
3830
3848
 
3831
- // ../../node_modules/luxon/src/impl/diff.js
3849
+ // ../../internal/validation/node_modules/luxon/src/impl/diff.js
3832
3850
  function dayDiff(earlier, later) {
3833
3851
  const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(), ms = utcDayStart(later) - utcDayStart(earlier);
3834
3852
  return Math.floor(Duration.fromMillis(ms).as("days"));
@@ -3887,7 +3905,7 @@ function diff_default(earlier, later, units, opts) {
3887
3905
  }
3888
3906
  }
3889
3907
 
3890
- // ../../node_modules/luxon/src/impl/digits.js
3908
+ // ../../internal/validation/node_modules/luxon/src/impl/digits.js
3891
3909
  var numberingSystems = {
3892
3910
  arab: "[\u0660-\u0669]",
3893
3911
  arabext: "[\u06F0-\u06F9]",
@@ -3959,7 +3977,7 @@ function digitRegex({ numberingSystem }, append = "") {
3959
3977
  return new RegExp(`${numberingSystems[numberingSystem || "latn"]}${append}`);
3960
3978
  }
3961
3979
 
3962
- // ../../node_modules/luxon/src/impl/tokenParser.js
3980
+ // ../../internal/validation/node_modules/luxon/src/impl/tokenParser.js
3963
3981
  var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
3964
3982
  function intUnit(regex, post = (i) => i) {
3965
3983
  return { regex, deser: ([s2]) => post(parseDigits(s2)) };
@@ -4304,7 +4322,7 @@ function formatOptsToTokens(formatOpts, locale) {
4304
4322
  return parts.map((p) => tokenForPart(p, locale, formatOpts));
4305
4323
  }
4306
4324
 
4307
- // ../../node_modules/luxon/src/impl/conversions.js
4325
+ // ../../internal/validation/node_modules/luxon/src/impl/conversions.js
4308
4326
  var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
4309
4327
  var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
4310
4328
  function unitOutOfRange(unit, value) {
@@ -4413,7 +4431,7 @@ function hasInvalidTimeData(obj) {
4413
4431
  return false;
4414
4432
  }
4415
4433
 
4416
- // ../../node_modules/luxon/src/datetime.js
4434
+ // ../../internal/validation/node_modules/luxon/src/datetime.js
4417
4435
  var INVALID3 = "Invalid DateTime";
4418
4436
  var MAX_DATE = 864e13;
4419
4437
  function unsupportedZone(zone) {
@@ -6245,8 +6263,12 @@ var AssetType = {
6245
6263
  MEDIUM: "MEDIUM",
6246
6264
  CHROME_WEB_STORE: "CHROME_WEB_STORE",
6247
6265
  MOZILLA_ADDONS: "MOZILLA_ADDONS",
6266
+ OPERA_ADDONS: "OPERA_ADDONS",
6248
6267
  EMAIL: "EMAIL",
6249
- PATREON: "PATREON"
6268
+ PATREON: "PATREON",
6269
+ OPENSEA: "OPENSEA",
6270
+ FARCASTER: "FARCASTER",
6271
+ IPFS: "IPFS"
6250
6272
  };
6251
6273
  var AssetStatus = {
6252
6274
  UNKNOWN: "UNKNOWN",
@@ -6255,6 +6277,7 @@ var AssetStatus = {
6255
6277
  };
6256
6278
 
6257
6279
  // ../../internal/validation/src/public/asset/changelog.ts
6280
+ var DateString = zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be in the format `YYYY-MM-DD`").pipe(zod.z.coerce.date());
6258
6281
  zod.z.object({
6259
6282
  /** The type of asset to retrieve. */
6260
6283
  type: zod.z.nativeEnum(AssetType).optional().describe("Asset type"),
@@ -6269,7 +6292,7 @@ zod.z.object({
6269
6292
  * Transformed into JavaScript Date objects from strings.
6270
6293
  * If the startDate is after the endDate, a validation error will occur.
6271
6294
  */
6272
- startDate: zod.z.string().transform((str) => new Date(str)).optional().describe(
6295
+ startDate: DateString.optional().describe(
6273
6296
  "The start date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
6274
6297
  ),
6275
6298
  /**
@@ -6278,7 +6301,7 @@ zod.z.object({
6278
6301
  * Transformed into JavaScript Date objects from strings.
6279
6302
  * If the startDate is after the endDate, a validation error will occur.
6280
6303
  */
6281
- endDate: zod.z.string().transform((str) => new Date(str)).optional().describe(
6304
+ endDate: DateString.optional().describe(
6282
6305
  "The end date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
6283
6306
  )
6284
6307
  }).describe(
@@ -6294,15 +6317,13 @@ for parsing the dates.`
6294
6317
  data.endDate = DateTime.now().toJSDate();
6295
6318
  }
6296
6319
  return data;
6297
- }).refine((data) => {
6298
- if (data.startDate && data.endDate && data.startDate > data.endDate) {
6299
- return {
6300
- path: ["startDate"],
6301
- message: "startDate must be before endDate"
6302
- };
6320
+ }).refine(
6321
+ (data) => data.startDate !== void 0 && data.endDate !== void 0 && data.startDate <= data.endDate,
6322
+ {
6323
+ path: ["startDate"],
6324
+ message: "startDate must be before endDate"
6303
6325
  }
6304
- return true;
6305
- });
6326
+ );
6306
6327
  zod.z.object({
6307
6328
  /** An array of asset change with their content, type, status, and update timestamp. */
6308
6329
  changelog: zod.z.array(
@@ -6398,6 +6419,8 @@ var reportCreateInputSchema = zod.z.object({
6398
6419
  organizationSlug: zod.z.string().describe("Organization slug used to identify the organization on ChainPatrol").optional(),
6399
6420
  /** Optional Discord Guild ID associated with the organization. */
6400
6421
  discordGuildId: zod.z.string().describe("Discord Guild (Server) ID linked to the organization on ChainPatrol").optional(),
6422
+ /** Optional Telegram Group ID associated with the organization. */
6423
+ telegramGroupId: zod.z.string().describe("Telegram Group ID linked to the organization on ChainPatrol").optional(),
6401
6424
  /** Title of the report. */
6402
6425
  title: zod.z.string().min(3).describe("Title of the report"),
6403
6426
  /** Description of the report, supporting markdown syntax. */
@@ -6476,11 +6499,19 @@ var ChainPatrolClientError = class extends Error {
6476
6499
  this.code = code;
6477
6500
  }
6478
6501
  };
6502
+ var ChainPatrolClientErrorCodes = /* @__PURE__ */ ((ChainPatrolClientErrorCodes2) => {
6503
+ ChainPatrolClientErrorCodes2["MISSING_API_KEY"] = "MISSING_API_KEY";
6504
+ ChainPatrolClientErrorCodes2["API_ERROR"] = "API_ERROR";
6505
+ return ChainPatrolClientErrorCodes2;
6506
+ })(ChainPatrolClientErrorCodes || {});
6479
6507
  var ChainPatrolClient = class {
6480
6508
  constructor(options) {
6481
6509
  var _a;
6482
6510
  if (!options.apiKey) {
6483
- throw new ChainPatrolClientError("Missing API key", "MISSING_API_KEY");
6511
+ throw new ChainPatrolClientError(
6512
+ "Missing API key",
6513
+ "MISSING_API_KEY" /* MISSING_API_KEY */
6514
+ );
6484
6515
  }
6485
6516
  this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
6486
6517
  this.logger = new Logger({ component: "ChainPatrolClient" });
@@ -6502,7 +6533,7 @@ var ChainPatrolClient = class {
6502
6533
  if (!res.ok) {
6503
6534
  const text = yield res.text();
6504
6535
  this.logger.error("fetch", { url, req, res: { status: res.status, text } });
6505
- throw new ChainPatrolClientError(text, "API_ERROR");
6536
+ throw new ChainPatrolClientError(text, "API_ERROR" /* API_ERROR */);
6506
6537
  }
6507
6538
  return res.json();
6508
6539
  });
@@ -6949,6 +6980,8 @@ _ThreatDetector.Schema = zod.z.object({
6949
6980
  var ThreatDetector = _ThreatDetector;
6950
6981
 
6951
6982
  exports.ChainPatrolClient = ChainPatrolClient;
6983
+ exports.ChainPatrolClientError = ChainPatrolClientError;
6984
+ exports.ChainPatrolClientErrorCodes = ChainPatrolClientErrorCodes;
6952
6985
  exports.DomainParseError = DomainParseError;
6953
6986
  exports.Events = Events;
6954
6987
  exports.Relay = Relay;