@xyo-network/crypto-nft-diviner-score-plugin 2.99.4 → 2.99.5

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.
Files changed (133) hide show
  1. package/dist/browser/Plugin.d.cts +1 -1
  2. package/dist/browser/Plugin.d.mts +1 -1
  3. package/dist/browser/Plugin.d.ts +1 -1
  4. package/dist/browser/index.cjs +233 -126
  5. package/dist/browser/index.cjs.map +1 -1
  6. package/dist/browser/index.d.cts +3 -3
  7. package/dist/browser/index.d.mts +3 -3
  8. package/dist/browser/index.d.ts +3 -3
  9. package/dist/browser/{index.js → index.mjs} +237 -132
  10. package/dist/browser/index.mjs.map +1 -0
  11. package/dist/browser/lib/index.d.cts +1 -1
  12. package/dist/browser/lib/index.d.mts +1 -1
  13. package/dist/browser/lib/index.d.ts +1 -1
  14. package/dist/browser/lib/rating/analyzeNft.d.cts +1 -1
  15. package/dist/browser/lib/rating/analyzeNft.d.mts +1 -1
  16. package/dist/browser/lib/rating/analyzeNft.d.ts +1 -1
  17. package/dist/browser/lib/rating/criteria/index.d.cts +1 -1
  18. package/dist/browser/lib/rating/criteria/index.d.mts +1 -1
  19. package/dist/browser/lib/rating/criteria/index.d.ts +1 -1
  20. package/dist/browser/lib/rating/criteria/scoring/index.d.cts +5 -5
  21. package/dist/browser/lib/rating/criteria/scoring/index.d.mts +5 -5
  22. package/dist/browser/lib/rating/criteria/scoring/index.d.ts +5 -5
  23. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
  24. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
  25. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
  26. package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
  27. package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
  28. package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
  29. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
  30. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
  31. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -1
  32. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  33. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  34. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  35. package/dist/browser/lib/rating/index.d.cts +2 -2
  36. package/dist/browser/lib/rating/index.d.mts +2 -2
  37. package/dist/browser/lib/rating/index.d.ts +2 -2
  38. package/dist/neutral/Plugin.d.cts +1 -1
  39. package/dist/neutral/Plugin.d.mts +1 -1
  40. package/dist/neutral/Plugin.d.ts +1 -1
  41. package/dist/neutral/index.cjs +233 -126
  42. package/dist/neutral/index.cjs.map +1 -1
  43. package/dist/neutral/index.d.cts +3 -3
  44. package/dist/neutral/index.d.mts +3 -3
  45. package/dist/neutral/index.d.ts +3 -3
  46. package/dist/neutral/{index.js → index.mjs} +237 -132
  47. package/dist/neutral/index.mjs.map +1 -0
  48. package/dist/neutral/lib/index.d.cts +1 -1
  49. package/dist/neutral/lib/index.d.mts +1 -1
  50. package/dist/neutral/lib/index.d.ts +1 -1
  51. package/dist/neutral/lib/rating/analyzeNft.d.cts +1 -1
  52. package/dist/neutral/lib/rating/analyzeNft.d.mts +1 -1
  53. package/dist/neutral/lib/rating/analyzeNft.d.ts +1 -1
  54. package/dist/neutral/lib/rating/criteria/index.d.cts +1 -1
  55. package/dist/neutral/lib/rating/criteria/index.d.mts +1 -1
  56. package/dist/neutral/lib/rating/criteria/index.d.ts +1 -1
  57. package/dist/neutral/lib/rating/criteria/scoring/index.d.cts +5 -5
  58. package/dist/neutral/lib/rating/criteria/scoring/index.d.mts +5 -5
  59. package/dist/neutral/lib/rating/criteria/scoring/index.d.ts +5 -5
  60. package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
  61. package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
  62. package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
  63. package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
  64. package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
  65. package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
  66. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
  67. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
  68. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -1
  69. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  70. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  71. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  72. package/dist/neutral/lib/rating/index.d.cts +2 -2
  73. package/dist/neutral/lib/rating/index.d.mts +2 -2
  74. package/dist/neutral/lib/rating/index.d.ts +2 -2
  75. package/dist/node/Plugin.d.cts +1 -1
  76. package/dist/node/Plugin.d.mts +1 -1
  77. package/dist/node/Plugin.d.ts +1 -1
  78. package/dist/node/index.cjs +244 -133
  79. package/dist/node/index.cjs.map +1 -1
  80. package/dist/node/index.d.cts +3 -3
  81. package/dist/node/index.d.mts +3 -3
  82. package/dist/node/index.d.ts +3 -3
  83. package/dist/node/{index.js → index.mjs} +248 -139
  84. package/dist/node/index.mjs.map +1 -0
  85. package/dist/node/lib/index.d.cts +1 -1
  86. package/dist/node/lib/index.d.mts +1 -1
  87. package/dist/node/lib/index.d.ts +1 -1
  88. package/dist/node/lib/rating/analyzeNft.d.cts +1 -1
  89. package/dist/node/lib/rating/analyzeNft.d.mts +1 -1
  90. package/dist/node/lib/rating/analyzeNft.d.ts +1 -1
  91. package/dist/node/lib/rating/criteria/index.d.cts +1 -1
  92. package/dist/node/lib/rating/criteria/index.d.mts +1 -1
  93. package/dist/node/lib/rating/criteria/index.d.ts +1 -1
  94. package/dist/node/lib/rating/criteria/scoring/index.d.cts +5 -5
  95. package/dist/node/lib/rating/criteria/scoring/index.d.mts +5 -5
  96. package/dist/node/lib/rating/criteria/scoring/index.d.ts +5 -5
  97. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
  98. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
  99. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
  100. package/dist/node/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
  101. package/dist/node/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
  102. package/dist/node/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
  103. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
  104. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
  105. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -1
  106. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  107. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  108. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  109. package/dist/node/lib/rating/index.d.cts +2 -2
  110. package/dist/node/lib/rating/index.d.mts +2 -2
  111. package/dist/node/lib/rating/index.d.ts +2 -2
  112. package/package.json +19 -19
  113. package/src/Diviner.ts +1 -1
  114. package/src/Plugin.ts +1 -1
  115. package/src/index.ts +3 -3
  116. package/src/lib/index.ts +1 -1
  117. package/src/lib/rating/analyzeNft.ts +2 -2
  118. package/src/lib/rating/criteria/index.ts +1 -1
  119. package/src/lib/rating/criteria/scoring/index.ts +5 -5
  120. package/src/lib/rating/criteria/scoring/metadata/animationUrl.ts +1 -1
  121. package/src/lib/rating/criteria/scoring/metadata/attributes/index.ts +1 -1
  122. package/src/lib/rating/criteria/scoring/metadata/externalUrl.ts +1 -1
  123. package/src/lib/rating/criteria/scoring/metadata/image.ts +1 -1
  124. package/src/lib/rating/criteria/scoring/metadata/imageData.ts +2 -2
  125. package/src/lib/rating/criteria/scoring/metadata/index.ts +9 -9
  126. package/src/lib/rating/criteria/scoring/metadata/lib/index.ts +1 -1
  127. package/src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts +1 -1
  128. package/src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts +1 -1
  129. package/src/lib/rating/criteria/scoringCriteria.ts +6 -6
  130. package/src/lib/rating/index.ts +2 -2
  131. package/dist/browser/index.js.map +0 -1
  132. package/dist/neutral/index.js.map +0 -1
  133. package/dist/node/index.js.map +0 -1
@@ -1,53 +1,63 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __reflectGet = Reflect.get;
4
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
8
+
1
9
  // src/Diviner.ts
2
- import {
3
- isNftInfo,
4
- NftScoreDivinerConfigSchema,
5
- NftScoreSchema
6
- } from "@xyo-network/crypto-nft-payload-plugin";
10
+ import { isNftInfo, NftScoreDivinerConfigSchema, NftScoreSchema } from "@xyo-network/crypto-nft-payload-plugin";
7
11
  import { AbstractDiviner } from "@xyo-network/diviner-abstract";
8
12
  import { PayloadBuilder } from "@xyo-network/payload-builder";
9
13
 
10
14
  // src/lib/rating/criteria/scoring/contract.ts
11
15
  import { FAIL, PASS } from "@xyo-network/crypto-nft-score-model";
12
16
  import { isAddress } from "ethers";
13
- var scoreContractAddress = (nft) => {
17
+ var scoreContractAddress = /* @__PURE__ */ __name((nft) => {
14
18
  if (!nft.address) return FAIL;
15
19
  if (typeof nft.address !== "string") return FAIL;
16
20
  if (!isAddress(nft.address)) return FAIL;
17
21
  return PASS;
18
- };
22
+ }, "scoreContractAddress");
19
23
 
20
24
  // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
21
25
  import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS as PASS2 } from "@xyo-network/crypto-nft-score-model";
22
26
 
23
27
  // src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts
24
28
  import { URL } from "@xylabs/url";
25
- var web3Protocols = ["ipfs:", "ar:"];
26
- var toUrl = (url) => {
29
+ var web3Protocols = [
30
+ "ipfs:",
31
+ "ar:"
32
+ ];
33
+ var toUrl = /* @__PURE__ */ __name((url) => {
27
34
  if (!url) return void 0;
28
35
  try {
29
36
  return new URL(url);
30
37
  } catch {
31
38
  return void 0;
32
39
  }
33
- };
34
- var isValidUrl = (url) => toUrl(url) !== void 0;
35
- var isWeb3 = (url) => web3Protocols.some((protocol) => {
40
+ }, "toUrl");
41
+ var isValidUrl = /* @__PURE__ */ __name((url) => toUrl(url) !== void 0, "isValidUrl");
42
+ var isWeb3 = /* @__PURE__ */ __name((url) => web3Protocols.some((protocol) => {
36
43
  var _a;
37
44
  return protocol === ((_a = toUrl(url)) == null ? void 0 : _a.protocol);
38
- });
39
- var isSecure = (url) => {
45
+ }), "isWeb3");
46
+ var isSecure = /* @__PURE__ */ __name((url) => {
40
47
  var _a;
41
48
  return isWeb3(url) || ((_a = toUrl(url)) == null ? void 0 : _a.protocol) === "https:";
42
- };
49
+ }, "isSecure");
43
50
 
44
51
  // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
45
- var scoreNftAnimationUrl = (nft) => {
52
+ var scoreNftAnimationUrl = /* @__PURE__ */ __name((nft) => {
46
53
  var _a;
47
54
  return scoreAnimationUrl((_a = nft.metadata) == null ? void 0 : _a.animation_url);
48
- };
49
- var scoreAnimationUrl = (animation_url) => {
50
- const score = [0, 0];
55
+ }, "scoreNftAnimationUrl");
56
+ var scoreAnimationUrl = /* @__PURE__ */ __name((animation_url) => {
57
+ const score = [
58
+ 0,
59
+ 0
60
+ ];
51
61
  if (animation_url === void 0 || animation_url === null) return PASS2;
52
62
  incrementPossible(score);
53
63
  if (typeof animation_url !== "string") return score;
@@ -58,11 +68,11 @@ var scoreAnimationUrl = (animation_url) => {
58
68
  incrementTotalAndPossible(score);
59
69
  if (!isWeb3(animation_url)) return score;
60
70
  return incrementTotal(score);
61
- };
71
+ }, "scoreAnimationUrl");
62
72
 
63
73
  // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
64
74
  import { incrementPossible as incrementPossible2, incrementTotal as incrementTotal2, incrementTotalAndPossible as incrementTotalAndPossible2 } from "@xyo-network/crypto-nft-score-model";
65
- var isDate = (value) => {
75
+ var isDate = /* @__PURE__ */ __name((value) => {
66
76
  if (isNumber(value)) {
67
77
  try {
68
78
  new Date(value);
@@ -72,26 +82,41 @@ var isDate = (value) => {
72
82
  }
73
83
  }
74
84
  return false;
75
- };
76
- var isNumber = (value) => typeof value === "number";
77
- var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
78
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
79
- var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
80
- var evaluateNftAttributes = (nft) => {
85
+ }, "isDate");
86
+ var isNumber = /* @__PURE__ */ __name((value) => typeof value === "number", "isNumber");
87
+ var isPercentage = /* @__PURE__ */ __name((value) => isNumber(value) && value >= 0 && value <= 100, "isPercentage");
88
+ var isNonEmptyString = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0, "isNonEmptyString");
89
+ var isNonEmptyStringOrNumber = /* @__PURE__ */ __name((value) => value === "number" || isNonEmptyString(value), "isNonEmptyStringOrNumber");
90
+ var evaluateNftAttributes = /* @__PURE__ */ __name((nft) => {
81
91
  var _a, _b;
82
- return ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes) : [0, 1];
83
- };
84
- var evaluateAttributes = (attributes) => {
85
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1];
86
- const score = [0, 0];
92
+ return ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes) : [
93
+ 0,
94
+ 1
95
+ ];
96
+ }, "evaluateNftAttributes");
97
+ var evaluateAttributes = /* @__PURE__ */ __name((attributes) => {
98
+ if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [
99
+ 0,
100
+ 1
101
+ ];
102
+ const score = [
103
+ 0,
104
+ 0
105
+ ];
87
106
  for (const attribute of attributes) {
88
107
  const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
89
108
  incrementTotalAndPossible2(score, attributeTotal, attributePossible);
90
109
  }
91
- return [1, 1];
92
- };
93
- var evaluateAttribute = (attribute) => {
94
- const score = [0, 1];
110
+ return [
111
+ 1,
112
+ 1
113
+ ];
114
+ }, "evaluateAttributes");
115
+ var evaluateAttribute = /* @__PURE__ */ __name((attribute) => {
116
+ const score = [
117
+ 0,
118
+ 1
119
+ ];
95
120
  const max_value = attribute == null ? void 0 : attribute.max_value;
96
121
  const trait_type = attribute == null ? void 0 : attribute.trait_type;
97
122
  const value = attribute == null ? void 0 : attribute.value;
@@ -104,8 +129,8 @@ var evaluateAttribute = (attribute) => {
104
129
  if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal2(score);
105
130
  }
106
131
  return score;
107
- };
108
- var validDisplayType = (attribute) => {
132
+ }, "evaluateAttribute");
133
+ var validDisplayType = /* @__PURE__ */ __name((attribute) => {
109
134
  switch (attribute == null ? void 0 : attribute.display_type) {
110
135
  case "number":
111
136
  case "boost_number": {
@@ -130,64 +155,79 @@ var validDisplayType = (attribute) => {
130
155
  }
131
156
  }
132
157
  return false;
133
- };
158
+ }, "validDisplayType");
134
159
 
135
160
  // src/lib/rating/criteria/scoring/metadata/backgroundColor.ts
136
161
  import { incrementPossible as incrementPossible3, incrementTotal as incrementTotal3, incrementTotalAndPossible as incrementTotalAndPossible3, PASS as PASS3 } from "@xyo-network/crypto-nft-score-model";
137
162
  var isHexColor = /^[\da-f]{6}$/i;
138
- var scoreNftBackgroundColor = (nft) => {
163
+ var scoreNftBackgroundColor = /* @__PURE__ */ __name((nft) => {
139
164
  var _a;
140
165
  return scoreBackgroundColor((_a = nft.metadata) == null ? void 0 : _a.background_color);
141
- };
142
- var scoreBackgroundColor = (background_color) => {
143
- const score = [0, 0];
166
+ }, "scoreNftBackgroundColor");
167
+ var scoreBackgroundColor = /* @__PURE__ */ __name((background_color) => {
168
+ const score = [
169
+ 0,
170
+ 0
171
+ ];
144
172
  if (background_color === void 0 || background_color === null) return PASS3;
145
173
  incrementPossible3(score);
146
174
  if (typeof background_color !== "string") return score;
147
175
  incrementTotalAndPossible3(score);
148
176
  if (!isHexColor.test(background_color.toUpperCase())) return score;
149
177
  return incrementTotal3(score);
150
- };
178
+ }, "scoreBackgroundColor");
151
179
 
152
180
  // src/lib/rating/criteria/scoring/metadata/description.ts
153
181
  import { incrementTotal as incrementTotal4 } from "@xyo-network/crypto-nft-score-model";
154
- var scoreNftDescription = (nft) => {
182
+ var scoreNftDescription = /* @__PURE__ */ __name((nft) => {
155
183
  var _a;
156
184
  return scoreDescription((_a = nft.metadata) == null ? void 0 : _a.description);
157
- };
158
- var scoreDescription = (description) => {
159
- const score = [0, 1];
185
+ }, "scoreNftDescription");
186
+ var scoreDescription = /* @__PURE__ */ __name((description) => {
187
+ const score = [
188
+ 0,
189
+ 1
190
+ ];
160
191
  if (!description || typeof description !== "string") return score;
161
192
  return incrementTotal4(score);
162
- };
193
+ }, "scoreDescription");
163
194
 
164
195
  // src/lib/rating/criteria/scoring/metadata/externalUrl.ts
165
196
  import { incrementTotal as incrementTotal5 } from "@xyo-network/crypto-nft-score-model";
166
- var scoreNftExternalUrl = (nft) => {
197
+ var scoreNftExternalUrl = /* @__PURE__ */ __name((nft) => {
167
198
  var _a;
168
199
  return scoreExternalUrl((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.external_url);
169
- };
170
- var scoreExternalUrl = (external_url) => {
171
- const score = [0, 2];
200
+ }, "scoreNftExternalUrl");
201
+ var scoreExternalUrl = /* @__PURE__ */ __name((external_url) => {
202
+ const score = [
203
+ 0,
204
+ 2
205
+ ];
172
206
  if (external_url === void 0 || external_url === null || typeof external_url !== "string" || !isValidUrl(external_url)) return score;
173
207
  incrementTotal5(score);
174
208
  if (!isSecure(external_url)) return score;
175
209
  return incrementTotal5(score);
176
- };
210
+ }, "scoreExternalUrl");
177
211
 
178
212
  // src/lib/rating/criteria/scoring/metadata/image.ts
179
213
  import { incrementTotal as incrementTotal6, PASS as PASS4 } from "@xyo-network/crypto-nft-score-model";
180
214
  var MaxPossibleImageScore = 3;
181
- var scoreNftImage = (nft) => {
215
+ var scoreNftImage = /* @__PURE__ */ __name((nft) => {
182
216
  var _a, _b, _c;
183
217
  if ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.image) {
184
218
  return scoreImage((_b = nft.metadata) == null ? void 0 : _b.image);
185
219
  } else {
186
- return ((_c = nft.metadata) == null ? void 0 : _c.image_data) ? PASS4 : [0, MaxPossibleImageScore];
220
+ return ((_c = nft.metadata) == null ? void 0 : _c.image_data) ? PASS4 : [
221
+ 0,
222
+ MaxPossibleImageScore
223
+ ];
187
224
  }
188
- };
189
- var scoreImage = (image) => {
190
- const score = [0, MaxPossibleImageScore];
225
+ }, "scoreNftImage");
226
+ var scoreImage = /* @__PURE__ */ __name((image) => {
227
+ const score = [
228
+ 0,
229
+ MaxPossibleImageScore
230
+ ];
191
231
  if (!image || typeof image !== "string" || !isValidUrl(image)) return score;
192
232
  incrementTotal6(score);
193
233
  if (!isSecure(image)) return score;
@@ -195,13 +235,13 @@ var scoreImage = (image) => {
195
235
  if (!isWeb3(image)) return score;
196
236
  incrementTotal6(score);
197
237
  return score;
198
- };
238
+ }, "scoreImage");
199
239
 
200
240
  // src/lib/rating/criteria/scoring/metadata/imageData.ts
201
241
  import { PASS as PASS5 } from "@xyo-network/crypto-nft-score-model";
202
242
  import { parse } from "svg-parser";
203
243
  var MaxPossibleImageDataScore = 1;
204
- var isValidImageData = (image_data) => {
244
+ var isValidImageData = /* @__PURE__ */ __name((image_data) => {
205
245
  if (!image_data.startsWith("<svg")) return false;
206
246
  try {
207
247
  parse(image_data);
@@ -209,49 +249,64 @@ var isValidImageData = (image_data) => {
209
249
  } catch {
210
250
  return false;
211
251
  }
212
- };
213
- var scoreNftImageData = (nft) => {
252
+ }, "isValidImageData");
253
+ var scoreNftImageData = /* @__PURE__ */ __name((nft) => {
214
254
  var _a, _b, _c;
215
255
  if ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.image_data) {
216
256
  return scoreImageData((_b = nft.metadata) == null ? void 0 : _b.image_data);
217
257
  } else {
218
- return ((_c = nft.metadata) == null ? void 0 : _c.image) ? PASS5 : [0, MaxPossibleImageDataScore];
258
+ return ((_c = nft.metadata) == null ? void 0 : _c.image) ? PASS5 : [
259
+ 0,
260
+ MaxPossibleImageDataScore
261
+ ];
219
262
  }
220
- };
221
- var scoreImageData = (image_data) => {
222
- return !image_data || typeof image_data !== "string" || !isValidImageData(image_data) ? [0, MaxPossibleImageDataScore] : [MaxPossibleImageDataScore, MaxPossibleImageDataScore];
223
- };
263
+ }, "scoreNftImageData");
264
+ var scoreImageData = /* @__PURE__ */ __name((image_data) => {
265
+ return !image_data || typeof image_data !== "string" || !isValidImageData(image_data) ? [
266
+ 0,
267
+ MaxPossibleImageDataScore
268
+ ] : [
269
+ MaxPossibleImageDataScore,
270
+ MaxPossibleImageDataScore
271
+ ];
272
+ }, "scoreImageData");
224
273
 
225
274
  // src/lib/rating/criteria/scoring/metadata/name.ts
226
275
  import { incrementTotal as incrementTotal7 } from "@xyo-network/crypto-nft-score-model";
227
- var scoreNftName = (nft) => {
276
+ var scoreNftName = /* @__PURE__ */ __name((nft) => {
228
277
  var _a;
229
278
  return scoreName((_a = nft.metadata) == null ? void 0 : _a.name);
230
- };
231
- var scoreName = (name) => {
232
- const score = [0, 1];
279
+ }, "scoreNftName");
280
+ var scoreName = /* @__PURE__ */ __name((name) => {
281
+ const score = [
282
+ 0,
283
+ 1
284
+ ];
233
285
  if (!name || typeof name !== "string") return score;
234
286
  return incrementTotal7(score);
235
- };
287
+ }, "scoreName");
236
288
 
237
289
  // src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts
238
290
  import { incrementTotal as incrementTotal8, PASS as PASS6 } from "@xyo-network/crypto-nft-score-model";
239
- var scoreNftYoutubeUrl = (nft) => {
291
+ var scoreNftYoutubeUrl = /* @__PURE__ */ __name((nft) => {
240
292
  var _a;
241
293
  return scoreYoutubeUrl((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.youtube_url);
242
- };
243
- var scoreYoutubeUrl = (youtube_url) => {
294
+ }, "scoreNftYoutubeUrl");
295
+ var scoreYoutubeUrl = /* @__PURE__ */ __name((youtube_url) => {
244
296
  if (youtube_url === void 0 || youtube_url === null) return PASS6;
245
- const score = [0, 2];
297
+ const score = [
298
+ 0,
299
+ 2
300
+ ];
246
301
  if (typeof youtube_url !== "string" || !isValidUrl(youtube_url)) return score;
247
302
  incrementTotal8(score);
248
303
  if (!isSecure(youtube_url)) return score;
249
304
  return incrementTotal8(score);
250
- };
305
+ }, "scoreYoutubeUrl");
251
306
 
252
307
  // src/lib/rating/criteria/scoring/supply.ts
253
308
  import { FAIL as FAIL2, PASS as PASS7 } from "@xyo-network/crypto-nft-score-model";
254
- var scoreSupply = (nft) => {
309
+ var scoreSupply = /* @__PURE__ */ __name((nft) => {
255
310
  if (!nft.supply) return FAIL2;
256
311
  if (typeof nft.supply !== "string") return FAIL2;
257
312
  try {
@@ -259,11 +314,11 @@ var scoreSupply = (nft) => {
259
314
  } catch {
260
315
  return FAIL2;
261
316
  }
262
- };
317
+ }, "scoreSupply");
263
318
 
264
319
  // src/lib/rating/criteria/scoring/tokenId.ts
265
320
  import { FAIL as FAIL3, PASS as PASS8 } from "@xyo-network/crypto-nft-score-model";
266
- var scoreTokenId = (nft) => {
321
+ var scoreTokenId = /* @__PURE__ */ __name((nft) => {
267
322
  if (!nft.tokenId) return FAIL3;
268
323
  if (typeof nft.tokenId !== "string") return FAIL3;
269
324
  try {
@@ -271,94 +326,148 @@ var scoreTokenId = (nft) => {
271
326
  } catch {
272
327
  return FAIL3;
273
328
  }
274
- };
329
+ }, "scoreTokenId");
275
330
 
276
331
  // src/lib/rating/criteria/scoring/type.ts
277
332
  import { FAIL as FAIL4, PASS as PASS9 } from "@xyo-network/crypto-nft-score-model";
278
- var scoreType = (nft) => {
333
+ var scoreType = /* @__PURE__ */ __name((nft) => {
279
334
  if (!nft.type) return FAIL4;
280
335
  if (typeof nft.type !== "string") return FAIL4;
281
336
  const type = nft.type.toUpperCase();
282
337
  if (type !== "ERC721" && type !== "ERC1155") return FAIL4;
283
338
  return PASS9;
284
- };
339
+ }, "scoreType");
285
340
 
286
341
  // src/lib/rating/criteria/scoringCriteria.ts
287
342
  var attributesScoringCriteria = {
288
- Attributes: { score: evaluateNftAttributes, weight: 1 }
343
+ Attributes: {
344
+ score: evaluateNftAttributes,
345
+ weight: 1
346
+ }
289
347
  };
290
348
  var metadataScoringCriteria = {
291
- "Animation URL": { score: scoreNftAnimationUrl, weight: 1 },
292
- "Background Color": { score: scoreNftBackgroundColor, weight: 1 },
293
- Description: { score: scoreNftDescription, weight: 1 },
294
- "External Url": { score: scoreNftExternalUrl, weight: 1 },
295
- Image: { score: scoreNftImage, weight: 1 },
296
- "Image Data": { score: scoreNftImageData, weight: 1 },
297
- Name: { score: scoreNftName, weight: 1 },
298
- "YouTube URL": { score: scoreNftYoutubeUrl, weight: 1 },
349
+ "Animation URL": {
350
+ score: scoreNftAnimationUrl,
351
+ weight: 1
352
+ },
353
+ "Background Color": {
354
+ score: scoreNftBackgroundColor,
355
+ weight: 1
356
+ },
357
+ "Description": {
358
+ score: scoreNftDescription,
359
+ weight: 1
360
+ },
361
+ "External Url": {
362
+ score: scoreNftExternalUrl,
363
+ weight: 1
364
+ },
365
+ "Image": {
366
+ score: scoreNftImage,
367
+ weight: 1
368
+ },
369
+ "Image Data": {
370
+ score: scoreNftImageData,
371
+ weight: 1
372
+ },
373
+ "Name": {
374
+ score: scoreNftName,
375
+ weight: 1
376
+ },
377
+ "YouTube URL": {
378
+ score: scoreNftYoutubeUrl,
379
+ weight: 1
380
+ },
299
381
  ...attributesScoringCriteria
300
382
  };
301
383
  var scoringCriteria = {
302
- "Contract Address": { score: scoreContractAddress, weight: 1 },
303
- Supply: { score: scoreSupply, weight: 1 },
304
- "Token Id": { score: scoreTokenId, weight: 1 },
305
- Type: { score: scoreType, weight: 1 },
384
+ "Contract Address": {
385
+ score: scoreContractAddress,
386
+ weight: 1
387
+ },
388
+ "Supply": {
389
+ score: scoreSupply,
390
+ weight: 1
391
+ },
392
+ "Token Id": {
393
+ score: scoreTokenId,
394
+ weight: 1
395
+ },
396
+ "Type": {
397
+ score: scoreType,
398
+ weight: 1
399
+ },
306
400
  ...metadataScoringCriteria
307
401
  };
308
402
 
309
403
  // src/lib/rating/analyzeNft.ts
310
- var analyzeNft = async (nft) => {
311
- const result = Object.fromEntries(
312
- await Promise.all(
313
- Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
314
- const rawScore = await score(nft);
315
- const weighted = rawScore.map((v) => v * weight);
316
- return [key, weighted];
317
- })
318
- )
319
- );
404
+ var analyzeNft = /* @__PURE__ */ __name(async (nft) => {
405
+ const result = Object.fromEntries(await Promise.all(Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
406
+ const rawScore = await score(nft);
407
+ const weighted = rawScore.map((v) => v * weight);
408
+ return [
409
+ key,
410
+ weighted
411
+ ];
412
+ })));
320
413
  return result;
321
- };
414
+ }, "analyzeNft");
322
415
 
323
416
  // src/Diviner.ts
324
- var toNftScorePayload = (nftInfo, scores) => {
417
+ var toNftScorePayload = /* @__PURE__ */ __name((nftInfo, scores) => {
325
418
  const { address, chainId, type } = nftInfo;
326
- return { address, chainId, schema: NftScoreSchema, scores, type };
327
- };
328
- var isNftScore = (payload) => payload.schema === NftScoreSchema;
329
- var NftScoreDiviner = class extends AbstractDiviner {
330
- static configSchemas = [...super.configSchemas, NftScoreDivinerConfigSchema];
331
- static defaultConfigSchema = NftScoreDivinerConfigSchema;
332
- divineHandler = async (payloads) => {
419
+ return {
420
+ address,
421
+ chainId,
422
+ schema: NftScoreSchema,
423
+ scores,
424
+ type
425
+ };
426
+ }, "toNftScorePayload");
427
+ var isNftScore = /* @__PURE__ */ __name((payload) => payload.schema === NftScoreSchema, "isNftScore");
428
+ var _NftScoreDiviner = class _NftScoreDiviner extends AbstractDiviner {
429
+ divineHandler = /* @__PURE__ */ __name(async (payloads) => {
333
430
  const nftInfos = (payloads == null ? void 0 : payloads.filter(isNftInfo)) ?? [];
334
- const results = await Promise.all(
335
- nftInfos.map(async (nftInfo) => {
336
- const [score, sourceHash] = await Promise.all([
337
- // Analyze the NFT
338
- toNftScorePayload(nftInfo, await analyzeNft(nftInfo)),
339
- // Hash the source payload
340
- PayloadBuilder.dataHash(nftInfo)
341
- ]);
342
- return { ...score, sources: [sourceHash] };
343
- })
344
- );
431
+ const results = await Promise.all(nftInfos.map(async (nftInfo) => {
432
+ const [score, sourceHash] = await Promise.all([
433
+ // Analyze the NFT
434
+ toNftScorePayload(nftInfo, await analyzeNft(nftInfo)),
435
+ // Hash the source payload
436
+ PayloadBuilder.dataHash(nftInfo)
437
+ ]);
438
+ return {
439
+ ...score,
440
+ sources: [
441
+ sourceHash
442
+ ]
443
+ };
444
+ }));
345
445
  return results;
346
- };
347
- };
446
+ }, "divineHandler");
447
+ };
448
+ __name(_NftScoreDiviner, "NftScoreDiviner");
449
+ __publicField(_NftScoreDiviner, "configSchemas", [
450
+ ...__superGet(_NftScoreDiviner, _NftScoreDiviner, "configSchemas"),
451
+ NftScoreDivinerConfigSchema
452
+ ]);
453
+ __publicField(_NftScoreDiviner, "defaultConfigSchema", NftScoreDivinerConfigSchema);
454
+ var NftScoreDiviner = _NftScoreDiviner;
348
455
 
349
456
  // src/Plugin.ts
350
457
  import { NftSchema } from "@xyo-network/crypto-nft-payload-plugin";
351
458
  import { PayloadSetSchema } from "@xyo-network/payload-model";
352
459
  import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
353
- var NftScoreDivinerPlugin = () => createPayloadSetDivinerPlugin(
354
- { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },
355
- {
356
- diviner: async (params) => {
357
- const result = await NftScoreDiviner.create(params);
358
- return result;
359
- }
360
- }
361
- );
460
+ var NftScoreDivinerPlugin = /* @__PURE__ */ __name(() => createPayloadSetDivinerPlugin({
461
+ required: {
462
+ [NftSchema]: 1
463
+ },
464
+ schema: PayloadSetSchema
465
+ }, {
466
+ diviner: /* @__PURE__ */ __name(async (params) => {
467
+ const result = await NftScoreDiviner.create(params);
468
+ return result;
469
+ }, "diviner")
470
+ }), "NftScoreDivinerPlugin");
362
471
  export {
363
472
  NftScoreDiviner,
364
473
  NftScoreDivinerPlugin,
@@ -367,4 +476,4 @@ export {
367
476
  isNftScore,
368
477
  scoringCriteria
369
478
  };
370
- //# sourceMappingURL=index.js.map
479
+ //# sourceMappingURL=index.mjs.map