@xyo-network/crypto-nft-diviner-score-plugin 2.75.14 → 2.75.16

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 (249) hide show
  1. package/dist/browser/Diviner.d.cts +1 -1
  2. package/dist/browser/Diviner.d.cts.map +1 -1
  3. package/dist/browser/Diviner.d.mts +1 -1
  4. package/dist/browser/Diviner.d.mts.map +1 -1
  5. package/dist/browser/Diviner.d.ts +1 -1
  6. package/dist/browser/Diviner.d.ts.map +1 -1
  7. package/dist/browser/Plugin.d.cts +2 -2
  8. package/dist/browser/Plugin.d.mts +2 -2
  9. package/dist/browser/Plugin.d.ts +2 -2
  10. package/dist/browser/index.cjs.map +1 -1
  11. package/dist/browser/index.js.map +1 -1
  12. package/dist/docs.json +789 -392
  13. package/dist/node/Diviner.d.cts +1 -1
  14. package/dist/node/Diviner.d.cts.map +1 -1
  15. package/dist/node/Diviner.d.mts +1 -1
  16. package/dist/node/Diviner.d.mts.map +1 -1
  17. package/dist/node/Diviner.d.ts +1 -1
  18. package/dist/node/Diviner.d.ts.map +1 -1
  19. package/dist/node/Plugin.d.cts +2 -2
  20. package/dist/node/Plugin.d.mts +2 -2
  21. package/dist/node/Plugin.d.ts +2 -2
  22. package/dist/node/index.js.map +1 -1
  23. package/dist/node/index.mjs.map +1 -1
  24. package/package.json +16 -16
  25. package/src/Diviner.ts +1 -1
  26. package/dist/browser/Diviner.cjs +0 -407
  27. package/dist/browser/Diviner.cjs.map +0 -1
  28. package/dist/browser/Diviner.js +0 -390
  29. package/dist/browser/Diviner.js.map +0 -1
  30. package/dist/browser/Plugin.cjs +0 -421
  31. package/dist/browser/Plugin.cjs.map +0 -1
  32. package/dist/browser/Plugin.js +0 -404
  33. package/dist/browser/Plugin.js.map +0 -1
  34. package/dist/browser/lib/index.cjs +0 -378
  35. package/dist/browser/lib/index.cjs.map +0 -1
  36. package/dist/browser/lib/index.js +0 -355
  37. package/dist/browser/lib/index.js.map +0 -1
  38. package/dist/browser/lib/rating/analyzeNft.cjs +0 -378
  39. package/dist/browser/lib/rating/analyzeNft.cjs.map +0 -1
  40. package/dist/browser/lib/rating/analyzeNft.js +0 -355
  41. package/dist/browser/lib/rating/analyzeNft.js.map +0 -1
  42. package/dist/browser/lib/rating/criteria/index.cjs +0 -364
  43. package/dist/browser/lib/rating/criteria/index.cjs.map +0 -1
  44. package/dist/browser/lib/rating/criteria/index.js +0 -341
  45. package/dist/browser/lib/rating/criteria/index.js.map +0 -1
  46. package/dist/browser/lib/rating/criteria/scoring/contract.cjs +0 -37
  47. package/dist/browser/lib/rating/criteria/scoring/contract.cjs.map +0 -1
  48. package/dist/browser/lib/rating/criteria/scoring/contract.js +0 -16
  49. package/dist/browser/lib/rating/criteria/scoring/contract.js.map +0 -1
  50. package/dist/browser/lib/rating/criteria/scoring/index.cjs +0 -363
  51. package/dist/browser/lib/rating/criteria/scoring/index.cjs.map +0 -1
  52. package/dist/browser/lib/rating/criteria/scoring/index.js +0 -340
  53. package/dist/browser/lib/rating/criteria/scoring/index.js.map +0 -1
  54. package/dist/browser/lib/rating/criteria/scoring/lib/index.cjs +0 -43
  55. package/dist/browser/lib/rating/criteria/scoring/lib/index.cjs.map +0 -1
  56. package/dist/browser/lib/rating/criteria/scoring/lib/index.js +0 -20
  57. package/dist/browser/lib/rating/criteria/scoring/lib/index.js.map +0 -1
  58. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.cjs +0 -42
  59. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.cjs.map +0 -1
  60. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +0 -19
  61. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +0 -1
  62. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.cjs +0 -34
  63. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.cjs.map +0 -1
  64. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.js +0 -13
  65. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.js.map +0 -1
  66. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.cjs +0 -67
  67. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.cjs.map +0 -1
  68. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.js +0 -46
  69. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.js.map +0 -1
  70. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.cjs +0 -103
  71. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.cjs.map +0 -1
  72. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +0 -82
  73. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +0 -1
  74. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.cjs +0 -105
  75. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.cjs.map +0 -1
  76. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.js +0 -82
  77. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.js.map +0 -1
  78. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.cjs +0 -44
  79. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.cjs.map +0 -1
  80. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.js +0 -23
  81. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +0 -1
  82. package/dist/browser/lib/rating/criteria/scoring/metadata/description.cjs +0 -37
  83. package/dist/browser/lib/rating/criteria/scoring/metadata/description.cjs.map +0 -1
  84. package/dist/browser/lib/rating/criteria/scoring/metadata/description.js +0 -16
  85. package/dist/browser/lib/rating/criteria/scoring/metadata/description.js.map +0 -1
  86. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.cjs +0 -58
  87. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.cjs.map +0 -1
  88. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.js +0 -37
  89. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.js.map +0 -1
  90. package/dist/browser/lib/rating/criteria/scoring/metadata/image.cjs +0 -67
  91. package/dist/browser/lib/rating/criteria/scoring/metadata/image.cjs.map +0 -1
  92. package/dist/browser/lib/rating/criteria/scoring/metadata/image.js +0 -46
  93. package/dist/browser/lib/rating/criteria/scoring/metadata/image.js.map +0 -1
  94. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.cjs +0 -50
  95. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.cjs.map +0 -1
  96. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.js +0 -29
  97. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.js.map +0 -1
  98. package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs +0 -287
  99. package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs.map +0 -1
  100. package/dist/browser/lib/rating/criteria/scoring/metadata/index.js +0 -264
  101. package/dist/browser/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
  102. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.cjs +0 -48
  103. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.cjs.map +0 -1
  104. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.js +0 -25
  105. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.js.map +0 -1
  106. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.cjs +0 -46
  107. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.cjs.map +0 -1
  108. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +0 -25
  109. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +0 -1
  110. package/dist/browser/lib/rating/criteria/scoring/metadata/name.cjs +0 -37
  111. package/dist/browser/lib/rating/criteria/scoring/metadata/name.cjs.map +0 -1
  112. package/dist/browser/lib/rating/criteria/scoring/metadata/name.js +0 -16
  113. package/dist/browser/lib/rating/criteria/scoring/metadata/name.js.map +0 -1
  114. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.cjs +0 -60
  115. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.cjs.map +0 -1
  116. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.js +0 -39
  117. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +0 -1
  118. package/dist/browser/lib/rating/criteria/scoring/supply.cjs +0 -56
  119. package/dist/browser/lib/rating/criteria/scoring/supply.cjs.map +0 -1
  120. package/dist/browser/lib/rating/criteria/scoring/supply.js +0 -35
  121. package/dist/browser/lib/rating/criteria/scoring/supply.js.map +0 -1
  122. package/dist/browser/lib/rating/criteria/scoring/tokenId.cjs +0 -56
  123. package/dist/browser/lib/rating/criteria/scoring/tokenId.cjs.map +0 -1
  124. package/dist/browser/lib/rating/criteria/scoring/tokenId.js +0 -35
  125. package/dist/browser/lib/rating/criteria/scoring/tokenId.js.map +0 -1
  126. package/dist/browser/lib/rating/criteria/scoring/type.cjs +0 -37
  127. package/dist/browser/lib/rating/criteria/scoring/type.cjs.map +0 -1
  128. package/dist/browser/lib/rating/criteria/scoring/type.js +0 -16
  129. package/dist/browser/lib/rating/criteria/scoring/type.js.map +0 -1
  130. package/dist/browser/lib/rating/criteria/scoringCriteria.cjs +0 -364
  131. package/dist/browser/lib/rating/criteria/scoringCriteria.cjs.map +0 -1
  132. package/dist/browser/lib/rating/criteria/scoringCriteria.js +0 -341
  133. package/dist/browser/lib/rating/criteria/scoringCriteria.js.map +0 -1
  134. package/dist/browser/lib/rating/index.cjs +0 -378
  135. package/dist/browser/lib/rating/index.cjs.map +0 -1
  136. package/dist/browser/lib/rating/index.js +0 -355
  137. package/dist/browser/lib/rating/index.js.map +0 -1
  138. package/dist/node/Diviner.js +0 -429
  139. package/dist/node/Diviner.js.map +0 -1
  140. package/dist/node/Diviner.mjs +0 -407
  141. package/dist/node/Diviner.mjs.map +0 -1
  142. package/dist/node/Plugin.js +0 -442
  143. package/dist/node/Plugin.js.map +0 -1
  144. package/dist/node/Plugin.mjs +0 -421
  145. package/dist/node/Plugin.mjs.map +0 -1
  146. package/dist/node/lib/index.js +0 -399
  147. package/dist/node/lib/index.js.map +0 -1
  148. package/dist/node/lib/index.mjs +0 -372
  149. package/dist/node/lib/index.mjs.map +0 -1
  150. package/dist/node/lib/rating/analyzeNft.js +0 -399
  151. package/dist/node/lib/rating/analyzeNft.js.map +0 -1
  152. package/dist/node/lib/rating/analyzeNft.mjs +0 -372
  153. package/dist/node/lib/rating/analyzeNft.mjs.map +0 -1
  154. package/dist/node/lib/rating/criteria/index.js +0 -385
  155. package/dist/node/lib/rating/criteria/index.js.map +0 -1
  156. package/dist/node/lib/rating/criteria/index.mjs +0 -358
  157. package/dist/node/lib/rating/criteria/index.mjs.map +0 -1
  158. package/dist/node/lib/rating/criteria/scoring/contract.js +0 -41
  159. package/dist/node/lib/rating/criteria/scoring/contract.js.map +0 -1
  160. package/dist/node/lib/rating/criteria/scoring/contract.mjs +0 -16
  161. package/dist/node/lib/rating/criteria/scoring/contract.mjs.map +0 -1
  162. package/dist/node/lib/rating/criteria/scoring/index.js +0 -406
  163. package/dist/node/lib/rating/criteria/scoring/index.js.map +0 -1
  164. package/dist/node/lib/rating/criteria/scoring/index.mjs +0 -357
  165. package/dist/node/lib/rating/criteria/scoring/index.mjs.map +0 -1
  166. package/dist/node/lib/rating/criteria/scoring/lib/index.js +0 -48
  167. package/dist/node/lib/rating/criteria/scoring/lib/index.js.map +0 -1
  168. package/dist/node/lib/rating/criteria/scoring/lib/index.mjs +0 -20
  169. package/dist/node/lib/rating/criteria/scoring/lib/index.mjs.map +0 -1
  170. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +0 -46
  171. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +0 -1
  172. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.mjs +0 -19
  173. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.mjs.map +0 -1
  174. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.js +0 -38
  175. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.js.map +0 -1
  176. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.mjs +0 -13
  177. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.mjs.map +0 -1
  178. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.js +0 -79
  179. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.js.map +0 -1
  180. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.mjs +0 -53
  181. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.mjs.map +0 -1
  182. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +0 -112
  183. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +0 -1
  184. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.mjs +0 -85
  185. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.mjs.map +0 -1
  186. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.js +0 -114
  187. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.js.map +0 -1
  188. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.mjs +0 -85
  189. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.mjs.map +0 -1
  190. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.js +0 -50
  191. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +0 -1
  192. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.mjs +0 -24
  193. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.mjs.map +0 -1
  194. package/dist/node/lib/rating/criteria/scoring/metadata/description.js +0 -43
  195. package/dist/node/lib/rating/criteria/scoring/metadata/description.js.map +0 -1
  196. package/dist/node/lib/rating/criteria/scoring/metadata/description.mjs +0 -17
  197. package/dist/node/lib/rating/criteria/scoring/metadata/description.mjs.map +0 -1
  198. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.js +0 -70
  199. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.js.map +0 -1
  200. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.mjs +0 -44
  201. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.mjs.map +0 -1
  202. package/dist/node/lib/rating/criteria/scoring/metadata/image.js +0 -79
  203. package/dist/node/lib/rating/criteria/scoring/metadata/image.js.map +0 -1
  204. package/dist/node/lib/rating/criteria/scoring/metadata/image.mjs +0 -53
  205. package/dist/node/lib/rating/criteria/scoring/metadata/image.mjs.map +0 -1
  206. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.js +0 -56
  207. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.js.map +0 -1
  208. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.mjs +0 -30
  209. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.mjs.map +0 -1
  210. package/dist/node/lib/rating/criteria/scoring/metadata/index.js +0 -326
  211. package/dist/node/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
  212. package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs +0 -281
  213. package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs.map +0 -1
  214. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.js +0 -63
  215. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.js.map +0 -1
  216. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.mjs +0 -31
  217. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.mjs.map +0 -1
  218. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +0 -61
  219. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +0 -1
  220. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.mjs +0 -31
  221. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.mjs.map +0 -1
  222. package/dist/node/lib/rating/criteria/scoring/metadata/name.js +0 -43
  223. package/dist/node/lib/rating/criteria/scoring/metadata/name.js.map +0 -1
  224. package/dist/node/lib/rating/criteria/scoring/metadata/name.mjs +0 -17
  225. package/dist/node/lib/rating/criteria/scoring/metadata/name.mjs.map +0 -1
  226. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.js +0 -72
  227. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +0 -1
  228. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.mjs +0 -46
  229. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.mjs.map +0 -1
  230. package/dist/node/lib/rating/criteria/scoring/supply.js +0 -60
  231. package/dist/node/lib/rating/criteria/scoring/supply.js.map +0 -1
  232. package/dist/node/lib/rating/criteria/scoring/supply.mjs +0 -35
  233. package/dist/node/lib/rating/criteria/scoring/supply.mjs.map +0 -1
  234. package/dist/node/lib/rating/criteria/scoring/tokenId.js +0 -60
  235. package/dist/node/lib/rating/criteria/scoring/tokenId.js.map +0 -1
  236. package/dist/node/lib/rating/criteria/scoring/tokenId.mjs +0 -35
  237. package/dist/node/lib/rating/criteria/scoring/tokenId.mjs.map +0 -1
  238. package/dist/node/lib/rating/criteria/scoring/type.js +0 -41
  239. package/dist/node/lib/rating/criteria/scoring/type.js.map +0 -1
  240. package/dist/node/lib/rating/criteria/scoring/type.mjs +0 -16
  241. package/dist/node/lib/rating/criteria/scoring/type.mjs.map +0 -1
  242. package/dist/node/lib/rating/criteria/scoringCriteria.js +0 -385
  243. package/dist/node/lib/rating/criteria/scoringCriteria.js.map +0 -1
  244. package/dist/node/lib/rating/criteria/scoringCriteria.mjs +0 -358
  245. package/dist/node/lib/rating/criteria/scoringCriteria.mjs.map +0 -1
  246. package/dist/node/lib/rating/index.js +0 -399
  247. package/dist/node/lib/rating/index.js.map +0 -1
  248. package/dist/node/lib/rating/index.mjs +0 -372
  249. package/dist/node/lib/rating/index.mjs.map +0 -1
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
21
- var animationUrl_exports = {};
22
- __export(animationUrl_exports, {
23
- scoreAnimationUrl: () => scoreAnimationUrl,
24
- scoreNftAnimationUrl: () => scoreNftAnimationUrl
25
- });
26
- module.exports = __toCommonJS(animationUrl_exports);
27
- var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
28
-
29
- // src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts
30
- var import_url = require("@xylabs/url");
31
- var web3Protocols = ["ipfs:", "ar:"];
32
- var toUrl = (url) => {
33
- if (!url)
34
- return void 0;
35
- try {
36
- return new import_url.URL(url);
37
- } catch (e) {
38
- return void 0;
39
- }
40
- };
41
- var isValidUrl = (url) => toUrl(url) !== void 0;
42
- var isWeb3 = (url) => web3Protocols.some((protocol) => {
43
- var _a;
44
- return protocol === ((_a = toUrl(url)) == null ? void 0 : _a.protocol);
45
- });
46
- var isSecure = (url) => {
47
- var _a;
48
- return isWeb3(url) || ((_a = toUrl(url)) == null ? void 0 : _a.protocol) === "https:";
49
- };
50
-
51
- // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
52
- var scoreNftAnimationUrl = (nft) => {
53
- var _a;
54
- return scoreAnimationUrl((_a = nft.metadata) == null ? void 0 : _a.animation_url);
55
- };
56
- var scoreAnimationUrl = (animation_url) => {
57
- const score = [0, 0];
58
- if (animation_url === void 0 || animation_url === null)
59
- return import_crypto_nft_score_model.PASS;
60
- (0, import_crypto_nft_score_model.incrementPossible)(score);
61
- if (typeof animation_url !== "string")
62
- return score;
63
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score);
64
- if (!isValidUrl(animation_url))
65
- return score;
66
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score);
67
- if (!isSecure(animation_url))
68
- return score;
69
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score);
70
- if (!isWeb3(animation_url))
71
- return score;
72
- return (0, import_crypto_nft_score_model.incrementTotal)(score);
73
- };
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- scoreAnimationUrl,
77
- scoreNftAnimationUrl
78
- });
79
- //# sourceMappingURL=animationUrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/lib/rating/criteria/scoring/metadata/animationUrl.ts","../../../../../../../src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts"],"sourcesContent":["import { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nimport { isSecure, isValidUrl, isWeb3 } from './lib'\n\nexport const scoreNftAnimationUrl = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {\n return scoreAnimationUrl(nft.metadata?.animation_url)\n}\n\nexport const scoreAnimationUrl = (animation_url: unknown): ScaledScore => {\n const score: ScaledScore = [0, 0]\n if (animation_url === undefined || animation_url === null) return PASS\n incrementPossible(score)\n if (typeof animation_url !== 'string') return score\n incrementTotalAndPossible(score)\n if (!isValidUrl(animation_url)) return score\n incrementTotalAndPossible(score)\n if (!isSecure(animation_url)) return score\n incrementTotalAndPossible(score)\n if (!isWeb3(animation_url)) return score\n return incrementTotal(score)\n}\n","import { URL } from '@xylabs/url'\n\nexport const web3Protocols = ['ipfs:', 'ar:']\n\nexport const toUrl = (url?: string | null): URL | undefined => {\n if (!url) return undefined\n try {\n return new URL(url)\n } catch (e) {\n return undefined\n }\n}\n\nexport const isValidUrl = (url?: string | null): boolean => toUrl(url) !== undefined\nexport const isWeb3 = (url?: string | null): boolean => web3Protocols.some((protocol) => protocol === toUrl(url)?.protocol)\nexport const isWeb2 = (url?: string | null): boolean => !isWeb3(url)\nexport const isSecure = (url?: string | null): boolean => isWeb3(url) || toUrl(url)?.protocol === 'https:'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAgG;;;ACDhG,iBAAoB;AAEb,IAAM,gBAAgB,CAAC,SAAS,KAAK;AAErC,IAAM,QAAQ,CAAC,QAAyC;AAC7D,MAAI,CAAC;AAAK,WAAO;AACjB,MAAI;AACF,WAAO,IAAI,eAAI,GAAG;AAAA,EACpB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,IAAM,aAAa,CAAC,QAAiC,MAAM,GAAG,MAAM;AACpE,IAAM,SAAS,CAAC,QAAiC,cAAc,KAAK,CAAC,aAAU;AAdtF;AAcyF,wBAAa,WAAM,GAAG,MAAT,mBAAY;AAAA,CAAQ;AAEnH,IAAM,WAAW,CAAC,QAA8B;AAhBvD;AAgB0D,gBAAO,GAAG,OAAK,WAAM,GAAG,MAAT,mBAAY,cAAa;AAAA;;;ADX3F,IAAM,uBAAuB,CAAC,QAA2D;AALhG;AAME,SAAO,mBAAkB,SAAI,aAAJ,mBAAc,aAAa;AACtD;AAEO,IAAM,oBAAoB,CAAC,kBAAwC;AACxE,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,MAAI,kBAAkB,UAAa,kBAAkB;AAAM,WAAO;AAClE,uDAAkB,KAAK;AACvB,MAAI,OAAO,kBAAkB;AAAU,WAAO;AAC9C,+DAA0B,KAAK;AAC/B,MAAI,CAAC,WAAW,aAAa;AAAG,WAAO;AACvC,+DAA0B,KAAK;AAC/B,MAAI,CAAC,SAAS,aAAa;AAAG,WAAO;AACrC,+DAA0B,KAAK;AAC/B,MAAI,CAAC,OAAO,aAAa;AAAG,WAAO;AACnC,aAAO,8CAAe,KAAK;AAC7B;","names":[]}
@@ -1,53 +0,0 @@
1
- // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
2
- import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS } from "@xyo-network/crypto-nft-score-model";
3
-
4
- // src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts
5
- import { URL } from "@xylabs/url";
6
- var web3Protocols = ["ipfs:", "ar:"];
7
- var toUrl = (url) => {
8
- if (!url)
9
- return void 0;
10
- try {
11
- return new URL(url);
12
- } catch (e) {
13
- return void 0;
14
- }
15
- };
16
- var isValidUrl = (url) => toUrl(url) !== void 0;
17
- var isWeb3 = (url) => web3Protocols.some((protocol) => {
18
- var _a;
19
- return protocol === ((_a = toUrl(url)) == null ? void 0 : _a.protocol);
20
- });
21
- var isSecure = (url) => {
22
- var _a;
23
- return isWeb3(url) || ((_a = toUrl(url)) == null ? void 0 : _a.protocol) === "https:";
24
- };
25
-
26
- // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
27
- var scoreNftAnimationUrl = (nft) => {
28
- var _a;
29
- return scoreAnimationUrl((_a = nft.metadata) == null ? void 0 : _a.animation_url);
30
- };
31
- var scoreAnimationUrl = (animation_url) => {
32
- const score = [0, 0];
33
- if (animation_url === void 0 || animation_url === null)
34
- return PASS;
35
- incrementPossible(score);
36
- if (typeof animation_url !== "string")
37
- return score;
38
- incrementTotalAndPossible(score);
39
- if (!isValidUrl(animation_url))
40
- return score;
41
- incrementTotalAndPossible(score);
42
- if (!isSecure(animation_url))
43
- return score;
44
- incrementTotalAndPossible(score);
45
- if (!isWeb3(animation_url))
46
- return score;
47
- return incrementTotal(score);
48
- };
49
- export {
50
- scoreAnimationUrl,
51
- scoreNftAnimationUrl
52
- };
53
- //# sourceMappingURL=animationUrl.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/lib/rating/criteria/scoring/metadata/animationUrl.ts","../../../../../../../src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts"],"sourcesContent":["import { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nimport { isSecure, isValidUrl, isWeb3 } from './lib'\n\nexport const scoreNftAnimationUrl = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {\n return scoreAnimationUrl(nft.metadata?.animation_url)\n}\n\nexport const scoreAnimationUrl = (animation_url: unknown): ScaledScore => {\n const score: ScaledScore = [0, 0]\n if (animation_url === undefined || animation_url === null) return PASS\n incrementPossible(score)\n if (typeof animation_url !== 'string') return score\n incrementTotalAndPossible(score)\n if (!isValidUrl(animation_url)) return score\n incrementTotalAndPossible(score)\n if (!isSecure(animation_url)) return score\n incrementTotalAndPossible(score)\n if (!isWeb3(animation_url)) return score\n return incrementTotal(score)\n}\n","import { URL } from '@xylabs/url'\n\nexport const web3Protocols = ['ipfs:', 'ar:']\n\nexport const toUrl = (url?: string | null): URL | undefined => {\n if (!url) return undefined\n try {\n return new URL(url)\n } catch (e) {\n return undefined\n }\n}\n\nexport const isValidUrl = (url?: string | null): boolean => toUrl(url) !== undefined\nexport const isWeb3 = (url?: string | null): boolean => web3Protocols.some((protocol) => protocol === toUrl(url)?.protocol)\nexport const isWeb2 = (url?: string | null): boolean => !isWeb3(url)\nexport const isSecure = (url?: string | null): boolean => isWeb3(url) || toUrl(url)?.protocol === 'https:'\n"],"mappings":";AACA,SAAS,mBAAmB,gBAAgB,2BAA2B,YAAyB;;;ACDhG,SAAS,WAAW;AAEb,IAAM,gBAAgB,CAAC,SAAS,KAAK;AAErC,IAAM,QAAQ,CAAC,QAAyC;AAC7D,MAAI,CAAC;AAAK,WAAO;AACjB,MAAI;AACF,WAAO,IAAI,IAAI,GAAG;AAAA,EACpB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,IAAM,aAAa,CAAC,QAAiC,MAAM,GAAG,MAAM;AACpE,IAAM,SAAS,CAAC,QAAiC,cAAc,KAAK,CAAC,aAAU;AAdtF;AAcyF,wBAAa,WAAM,GAAG,MAAT,mBAAY;AAAA,CAAQ;AAEnH,IAAM,WAAW,CAAC,QAA8B;AAhBvD;AAgB0D,gBAAO,GAAG,OAAK,WAAM,GAAG,MAAT,mBAAY,cAAa;AAAA;;;ADX3F,IAAM,uBAAuB,CAAC,QAA2D;AALhG;AAME,SAAO,mBAAkB,SAAI,aAAJ,mBAAc,aAAa;AACtD;AAEO,IAAM,oBAAoB,CAAC,kBAAwC;AACxE,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,MAAI,kBAAkB,UAAa,kBAAkB;AAAM,WAAO;AAClE,oBAAkB,KAAK;AACvB,MAAI,OAAO,kBAAkB;AAAU,WAAO;AAC9C,4BAA0B,KAAK;AAC/B,MAAI,CAAC,WAAW,aAAa;AAAG,WAAO;AACvC,4BAA0B,KAAK;AAC/B,MAAI,CAAC,SAAS,aAAa;AAAG,WAAO;AACrC,4BAA0B,KAAK;AAC/B,MAAI,CAAC,OAAO,aAAa;AAAG,WAAO;AACnC,SAAO,eAAe,KAAK;AAC7B;","names":[]}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
21
- var evaluateAttributes_exports = {};
22
- __export(evaluateAttributes_exports, {
23
- evaluateAttribute: () => evaluateAttribute,
24
- evaluateAttributes: () => evaluateAttributes,
25
- evaluateNftAttributes: () => evaluateNftAttributes
26
- });
27
- module.exports = __toCommonJS(evaluateAttributes_exports);
28
- var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
29
- var isDate = (value) => {
30
- if (isNumber(value)) {
31
- try {
32
- new Date(value);
33
- return true;
34
- } catch (error) {
35
- return false;
36
- }
37
- }
38
- return false;
39
- };
40
- var isNumber = (value) => typeof value === "number";
41
- var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
42
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
43
- var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
44
- var evaluateNftAttributes = (nft) => {
45
- var _a, _b;
46
- return !((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? [0, 1] : evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes);
47
- };
48
- var evaluateAttributes = (attributes) => {
49
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0)
50
- return [0, 1];
51
- const score = [0, 0];
52
- for (const attribute of attributes) {
53
- const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
54
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score, attributeTotal, attributePossible);
55
- }
56
- return [1, 1];
57
- };
58
- var evaluateAttribute = (attribute) => {
59
- const score = [0, 1];
60
- const max_value = attribute == null ? void 0 : attribute.max_value;
61
- const trait_type = attribute == null ? void 0 : attribute.trait_type;
62
- const value = attribute == null ? void 0 : attribute.value;
63
- if (!attribute || typeof attribute !== "object" || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value))
64
- return score;
65
- (0, import_crypto_nft_score_model.incrementTotal)(score);
66
- (0, import_crypto_nft_score_model.incrementPossible)(score);
67
- if (validDisplayType(attribute))
68
- (0, import_crypto_nft_score_model.incrementTotal)(score);
69
- if (max_value !== void 0) {
70
- (0, import_crypto_nft_score_model.incrementPossible)(score);
71
- if (isNumber(max_value) && isNumber(value) && value <= max_value)
72
- (0, import_crypto_nft_score_model.incrementTotal)(score);
73
- }
74
- return score;
75
- };
76
- var validDisplayType = (attribute) => {
77
- switch (attribute == null ? void 0 : attribute.display_type) {
78
- case "number":
79
- case "boost_number": {
80
- if (isNumber(attribute == null ? void 0 : attribute.value))
81
- return true;
82
- break;
83
- }
84
- case "boost_percentage": {
85
- if (isPercentage(attribute == null ? void 0 : attribute.value))
86
- return true;
87
- break;
88
- }
89
- case "date": {
90
- if (isDate(attribute == null ? void 0 : attribute.value))
91
- return true;
92
- break;
93
- }
94
- case "string":
95
- case void 0: {
96
- if (isNonEmptyString(attribute == null ? void 0 : attribute.value))
97
- return true;
98
- break;
99
- }
100
- default: {
101
- break;
102
- }
103
- }
104
- return false;
105
- };
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
108
- evaluateAttribute,
109
- evaluateAttributes,
110
- evaluateNftAttributes
111
- });
112
- //# sourceMappingURL=evaluateAttributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts"],"sourcesContent":["import { NftAttribute, NftInfoFields, OpenSeaNftAttribute, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nconst isDate = (value: unknown): value is Date => {\n if (isNumber(value)) {\n try {\n new Date(value)\n return true\n } catch (error) {\n return false\n }\n }\n return false\n}\n\nconst isNumber = (value: unknown): value is number => typeof value === 'number'\n\nconst isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100\n\nconst isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0\n\nconst isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)\n\nexport const evaluateNftAttributes = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore =>\n !nft?.metadata?.attributes ? [0, 1] : evaluateAttributes(nft?.metadata?.attributes)\n\nexport const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]\n const score: ScaledScore = [0, 0]\n for (const attribute of attributes) {\n const [attributeTotal, attributePossible] = evaluateAttribute(attribute)\n incrementTotalAndPossible(score, attributeTotal, attributePossible)\n }\n return [1, 1]\n}\n\nexport const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {\n const score: ScaledScore = [0, 1]\n const max_value = attribute?.max_value\n const trait_type = attribute?.trait_type\n const value = attribute?.value\n\n // Validate trait_type & value\n if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score\n incrementTotal(score)\n\n // Validate display_type\n incrementPossible(score)\n if (validDisplayType(attribute)) incrementTotal(score)\n\n // Validate max_value\n if (max_value !== undefined) {\n incrementPossible(score)\n if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)\n }\n\n return score\n}\n\nconst validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {\n switch (attribute?.display_type) {\n case 'number':\n case 'boost_number': {\n if (isNumber(attribute?.value)) return true\n break\n }\n case 'boost_percentage': {\n if (isPercentage(attribute?.value)) return true\n break\n }\n case 'date': {\n if (isDate(attribute?.value)) return true\n break\n }\n case 'string':\n case undefined: {\n if (isNonEmptyString(attribute?.value)) return true\n break\n }\n default: {\n break\n }\n }\n return false\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAA0F;AAE1F,IAAM,SAAS,CAAC,UAAkC;AAChD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI;AACF,UAAI,KAAK,KAAK;AACd,aAAO;AAAA,IACT,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAM,WAAW,CAAC,UAAoC,OAAO,UAAU;AAEvE,IAAM,eAAe,CAAC,UAA4B,SAAS,KAAK,KAAK,SAAS,KAAK,SAAS;AAE5F,IAAM,mBAAmB,CAAC,UAAoC,OAAO,UAAU,YAAY,MAAM,SAAS;AAE1G,IAAM,2BAA2B,CAAC,UAA6C,UAAU,YAAY,iBAAiB,KAAK;AAEpH,IAAM,wBAAwB,CAAC,QAAwD;AAvB9F;AAwBE,YAAC,gCAAK,aAAL,mBAAe,cAAa,CAAC,GAAG,CAAC,IAAI,oBAAmB,gCAAK,aAAL,mBAAe,UAAU;AAAA;AAE7E,IAAM,qBAAqB,CAAC,eAA8E;AAC/G,MAAI,CAAC,cAAc,CAAC,MAAM,QAAQ,UAAU,KAAK,WAAW,WAAW;AAAG,WAAO,CAAC,GAAG,CAAC;AACtF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,aAAW,aAAa,YAAY;AAClC,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,kBAAkB,SAAS;AACvE,iEAA0B,OAAO,gBAAgB,iBAAiB;AAAA,EACpE;AACA,SAAO,CAAC,GAAG,CAAC;AACd;AAEO,IAAM,oBAAoB,CAAC,cAAgD;AAChF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,QAAM,YAAY,uCAAW;AAC7B,QAAM,aAAa,uCAAW;AAC9B,QAAM,QAAQ,uCAAW;AAGzB,MAAI,CAAC,aAAa,OAAO,cAAc,YAAY,CAAC,iBAAiB,UAAU,KAAK,CAAC,yBAAyB,KAAK;AAAG,WAAO;AAC7H,oDAAe,KAAK;AAGpB,uDAAkB,KAAK;AACvB,MAAI,iBAAiB,SAAS;AAAG,sDAAe,KAAK;AAGrD,MAAI,cAAc,QAAW;AAC3B,yDAAkB,KAAK;AACvB,QAAI,SAAS,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS;AAAW,wDAAe,KAAK;AAAA,EACxF;AAEA,SAAO;AACT;AAEA,IAAM,mBAAmB,CAAC,cAA4C;AACpE,UAAQ,uCAAW,cAAc;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK,gBAAgB;AACnB,UAAI,SAAS,uCAAW,KAAK;AAAG,eAAO;AACvC;AAAA,IACF;AAAA,IACA,KAAK,oBAAoB;AACvB,UAAI,aAAa,uCAAW,KAAK;AAAG,eAAO;AAC3C;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,UAAI,OAAO,uCAAW,KAAK;AAAG,eAAO;AACrC;AAAA,IACF;AAAA,IACA,KAAK;AAAA,IACL,KAAK,QAAW;AACd,UAAI,iBAAiB,uCAAW,KAAK;AAAG,eAAO;AAC/C;AAAA,IACF;AAAA,IACA,SAAS;AACP;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,85 +0,0 @@
1
- // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
2
- import { incrementPossible, incrementTotal, incrementTotalAndPossible } from "@xyo-network/crypto-nft-score-model";
3
- var isDate = (value) => {
4
- if (isNumber(value)) {
5
- try {
6
- new Date(value);
7
- return true;
8
- } catch (error) {
9
- return false;
10
- }
11
- }
12
- return false;
13
- };
14
- var isNumber = (value) => typeof value === "number";
15
- var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
16
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
17
- var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
18
- var evaluateNftAttributes = (nft) => {
19
- var _a, _b;
20
- return !((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? [0, 1] : evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes);
21
- };
22
- var evaluateAttributes = (attributes) => {
23
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0)
24
- return [0, 1];
25
- const score = [0, 0];
26
- for (const attribute of attributes) {
27
- const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
28
- incrementTotalAndPossible(score, attributeTotal, attributePossible);
29
- }
30
- return [1, 1];
31
- };
32
- var evaluateAttribute = (attribute) => {
33
- const score = [0, 1];
34
- const max_value = attribute == null ? void 0 : attribute.max_value;
35
- const trait_type = attribute == null ? void 0 : attribute.trait_type;
36
- const value = attribute == null ? void 0 : attribute.value;
37
- if (!attribute || typeof attribute !== "object" || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value))
38
- return score;
39
- incrementTotal(score);
40
- incrementPossible(score);
41
- if (validDisplayType(attribute))
42
- incrementTotal(score);
43
- if (max_value !== void 0) {
44
- incrementPossible(score);
45
- if (isNumber(max_value) && isNumber(value) && value <= max_value)
46
- incrementTotal(score);
47
- }
48
- return score;
49
- };
50
- var validDisplayType = (attribute) => {
51
- switch (attribute == null ? void 0 : attribute.display_type) {
52
- case "number":
53
- case "boost_number": {
54
- if (isNumber(attribute == null ? void 0 : attribute.value))
55
- return true;
56
- break;
57
- }
58
- case "boost_percentage": {
59
- if (isPercentage(attribute == null ? void 0 : attribute.value))
60
- return true;
61
- break;
62
- }
63
- case "date": {
64
- if (isDate(attribute == null ? void 0 : attribute.value))
65
- return true;
66
- break;
67
- }
68
- case "string":
69
- case void 0: {
70
- if (isNonEmptyString(attribute == null ? void 0 : attribute.value))
71
- return true;
72
- break;
73
- }
74
- default: {
75
- break;
76
- }
77
- }
78
- return false;
79
- };
80
- export {
81
- evaluateAttribute,
82
- evaluateAttributes,
83
- evaluateNftAttributes
84
- };
85
- //# sourceMappingURL=evaluateAttributes.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts"],"sourcesContent":["import { NftAttribute, NftInfoFields, OpenSeaNftAttribute, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nconst isDate = (value: unknown): value is Date => {\n if (isNumber(value)) {\n try {\n new Date(value)\n return true\n } catch (error) {\n return false\n }\n }\n return false\n}\n\nconst isNumber = (value: unknown): value is number => typeof value === 'number'\n\nconst isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100\n\nconst isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0\n\nconst isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)\n\nexport const evaluateNftAttributes = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore =>\n !nft?.metadata?.attributes ? [0, 1] : evaluateAttributes(nft?.metadata?.attributes)\n\nexport const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]\n const score: ScaledScore = [0, 0]\n for (const attribute of attributes) {\n const [attributeTotal, attributePossible] = evaluateAttribute(attribute)\n incrementTotalAndPossible(score, attributeTotal, attributePossible)\n }\n return [1, 1]\n}\n\nexport const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {\n const score: ScaledScore = [0, 1]\n const max_value = attribute?.max_value\n const trait_type = attribute?.trait_type\n const value = attribute?.value\n\n // Validate trait_type & value\n if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score\n incrementTotal(score)\n\n // Validate display_type\n incrementPossible(score)\n if (validDisplayType(attribute)) incrementTotal(score)\n\n // Validate max_value\n if (max_value !== undefined) {\n incrementPossible(score)\n if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)\n }\n\n return score\n}\n\nconst validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {\n switch (attribute?.display_type) {\n case 'number':\n case 'boost_number': {\n if (isNumber(attribute?.value)) return true\n break\n }\n case 'boost_percentage': {\n if (isPercentage(attribute?.value)) return true\n break\n }\n case 'date': {\n if (isDate(attribute?.value)) return true\n break\n }\n case 'string':\n case undefined: {\n if (isNonEmptyString(attribute?.value)) return true\n break\n }\n default: {\n break\n }\n }\n return false\n}\n"],"mappings":";AACA,SAAS,mBAAmB,gBAAgB,iCAA8C;AAE1F,IAAM,SAAS,CAAC,UAAkC;AAChD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI;AACF,UAAI,KAAK,KAAK;AACd,aAAO;AAAA,IACT,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAM,WAAW,CAAC,UAAoC,OAAO,UAAU;AAEvE,IAAM,eAAe,CAAC,UAA4B,SAAS,KAAK,KAAK,SAAS,KAAK,SAAS;AAE5F,IAAM,mBAAmB,CAAC,UAAoC,OAAO,UAAU,YAAY,MAAM,SAAS;AAE1G,IAAM,2BAA2B,CAAC,UAA6C,UAAU,YAAY,iBAAiB,KAAK;AAEpH,IAAM,wBAAwB,CAAC,QAAwD;AAvB9F;AAwBE,YAAC,gCAAK,aAAL,mBAAe,cAAa,CAAC,GAAG,CAAC,IAAI,oBAAmB,gCAAK,aAAL,mBAAe,UAAU;AAAA;AAE7E,IAAM,qBAAqB,CAAC,eAA8E;AAC/G,MAAI,CAAC,cAAc,CAAC,MAAM,QAAQ,UAAU,KAAK,WAAW,WAAW;AAAG,WAAO,CAAC,GAAG,CAAC;AACtF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,aAAW,aAAa,YAAY;AAClC,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,kBAAkB,SAAS;AACvE,8BAA0B,OAAO,gBAAgB,iBAAiB;AAAA,EACpE;AACA,SAAO,CAAC,GAAG,CAAC;AACd;AAEO,IAAM,oBAAoB,CAAC,cAAgD;AAChF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,QAAM,YAAY,uCAAW;AAC7B,QAAM,aAAa,uCAAW;AAC9B,QAAM,QAAQ,uCAAW;AAGzB,MAAI,CAAC,aAAa,OAAO,cAAc,YAAY,CAAC,iBAAiB,UAAU,KAAK,CAAC,yBAAyB,KAAK;AAAG,WAAO;AAC7H,iBAAe,KAAK;AAGpB,oBAAkB,KAAK;AACvB,MAAI,iBAAiB,SAAS;AAAG,mBAAe,KAAK;AAGrD,MAAI,cAAc,QAAW;AAC3B,sBAAkB,KAAK;AACvB,QAAI,SAAS,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS;AAAW,qBAAe,KAAK;AAAA,EACxF;AAEA,SAAO;AACT;AAEA,IAAM,mBAAmB,CAAC,cAA4C;AACpE,UAAQ,uCAAW,cAAc;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK,gBAAgB;AACnB,UAAI,SAAS,uCAAW,KAAK;AAAG,eAAO;AACvC;AAAA,IACF;AAAA,IACA,KAAK,oBAAoB;AACvB,UAAI,aAAa,uCAAW,KAAK;AAAG,eAAO;AAC3C;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,UAAI,OAAO,uCAAW,KAAK;AAAG,eAAO;AACrC;AAAA,IACF;AAAA,IACA,KAAK;AAAA,IACL,KAAK,QAAW;AACd,UAAI,iBAAiB,uCAAW,KAAK;AAAG,eAAO;AAC/C;AAAA,IACF;AAAA,IACA,SAAS;AACP;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/rating/criteria/scoring/metadata/attributes/index.ts
21
- var attributes_exports = {};
22
- __export(attributes_exports, {
23
- evaluateAttribute: () => evaluateAttribute,
24
- evaluateAttributes: () => evaluateAttributes,
25
- evaluateNftAttributes: () => evaluateNftAttributes
26
- });
27
- module.exports = __toCommonJS(attributes_exports);
28
-
29
- // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
30
- var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
31
- var isDate = (value) => {
32
- if (isNumber(value)) {
33
- try {
34
- new Date(value);
35
- return true;
36
- } catch (error) {
37
- return false;
38
- }
39
- }
40
- return false;
41
- };
42
- var isNumber = (value) => typeof value === "number";
43
- var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
44
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
45
- var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
46
- var evaluateNftAttributes = (nft) => {
47
- var _a, _b;
48
- return !((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? [0, 1] : evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes);
49
- };
50
- var evaluateAttributes = (attributes) => {
51
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0)
52
- return [0, 1];
53
- const score = [0, 0];
54
- for (const attribute of attributes) {
55
- const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
56
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score, attributeTotal, attributePossible);
57
- }
58
- return [1, 1];
59
- };
60
- var evaluateAttribute = (attribute) => {
61
- const score = [0, 1];
62
- const max_value = attribute == null ? void 0 : attribute.max_value;
63
- const trait_type = attribute == null ? void 0 : attribute.trait_type;
64
- const value = attribute == null ? void 0 : attribute.value;
65
- if (!attribute || typeof attribute !== "object" || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value))
66
- return score;
67
- (0, import_crypto_nft_score_model.incrementTotal)(score);
68
- (0, import_crypto_nft_score_model.incrementPossible)(score);
69
- if (validDisplayType(attribute))
70
- (0, import_crypto_nft_score_model.incrementTotal)(score);
71
- if (max_value !== void 0) {
72
- (0, import_crypto_nft_score_model.incrementPossible)(score);
73
- if (isNumber(max_value) && isNumber(value) && value <= max_value)
74
- (0, import_crypto_nft_score_model.incrementTotal)(score);
75
- }
76
- return score;
77
- };
78
- var validDisplayType = (attribute) => {
79
- switch (attribute == null ? void 0 : attribute.display_type) {
80
- case "number":
81
- case "boost_number": {
82
- if (isNumber(attribute == null ? void 0 : attribute.value))
83
- return true;
84
- break;
85
- }
86
- case "boost_percentage": {
87
- if (isPercentage(attribute == null ? void 0 : attribute.value))
88
- return true;
89
- break;
90
- }
91
- case "date": {
92
- if (isDate(attribute == null ? void 0 : attribute.value))
93
- return true;
94
- break;
95
- }
96
- case "string":
97
- case void 0: {
98
- if (isNonEmptyString(attribute == null ? void 0 : attribute.value))
99
- return true;
100
- break;
101
- }
102
- default: {
103
- break;
104
- }
105
- }
106
- return false;
107
- };
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- evaluateAttribute,
111
- evaluateAttributes,
112
- evaluateNftAttributes
113
- });
114
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/attributes/index.ts","../../../../../../../../src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts"],"sourcesContent":["export * from './evaluateAttributes'\n","import { NftAttribute, NftInfoFields, OpenSeaNftAttribute, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nconst isDate = (value: unknown): value is Date => {\n if (isNumber(value)) {\n try {\n new Date(value)\n return true\n } catch (error) {\n return false\n }\n }\n return false\n}\n\nconst isNumber = (value: unknown): value is number => typeof value === 'number'\n\nconst isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100\n\nconst isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0\n\nconst isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)\n\nexport const evaluateNftAttributes = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore =>\n !nft?.metadata?.attributes ? [0, 1] : evaluateAttributes(nft?.metadata?.attributes)\n\nexport const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]\n const score: ScaledScore = [0, 0]\n for (const attribute of attributes) {\n const [attributeTotal, attributePossible] = evaluateAttribute(attribute)\n incrementTotalAndPossible(score, attributeTotal, attributePossible)\n }\n return [1, 1]\n}\n\nexport const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {\n const score: ScaledScore = [0, 1]\n const max_value = attribute?.max_value\n const trait_type = attribute?.trait_type\n const value = attribute?.value\n\n // Validate trait_type & value\n if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score\n incrementTotal(score)\n\n // Validate display_type\n incrementPossible(score)\n if (validDisplayType(attribute)) incrementTotal(score)\n\n // Validate max_value\n if (max_value !== undefined) {\n incrementPossible(score)\n if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)\n }\n\n return score\n}\n\nconst validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {\n switch (attribute?.display_type) {\n case 'number':\n case 'boost_number': {\n if (isNumber(attribute?.value)) return true\n break\n }\n case 'boost_percentage': {\n if (isPercentage(attribute?.value)) return true\n break\n }\n case 'date': {\n if (isDate(attribute?.value)) return true\n break\n }\n case 'string':\n case undefined: {\n if (isNonEmptyString(attribute?.value)) return true\n break\n }\n default: {\n break\n }\n }\n return false\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oCAA0F;AAE1F,IAAM,SAAS,CAAC,UAAkC;AAChD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI;AACF,UAAI,KAAK,KAAK;AACd,aAAO;AAAA,IACT,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAM,WAAW,CAAC,UAAoC,OAAO,UAAU;AAEvE,IAAM,eAAe,CAAC,UAA4B,SAAS,KAAK,KAAK,SAAS,KAAK,SAAS;AAE5F,IAAM,mBAAmB,CAAC,UAAoC,OAAO,UAAU,YAAY,MAAM,SAAS;AAE1G,IAAM,2BAA2B,CAAC,UAA6C,UAAU,YAAY,iBAAiB,KAAK;AAEpH,IAAM,wBAAwB,CAAC,QAAwD;AAvB9F;AAwBE,YAAC,gCAAK,aAAL,mBAAe,cAAa,CAAC,GAAG,CAAC,IAAI,oBAAmB,gCAAK,aAAL,mBAAe,UAAU;AAAA;AAE7E,IAAM,qBAAqB,CAAC,eAA8E;AAC/G,MAAI,CAAC,cAAc,CAAC,MAAM,QAAQ,UAAU,KAAK,WAAW,WAAW;AAAG,WAAO,CAAC,GAAG,CAAC;AACtF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,aAAW,aAAa,YAAY;AAClC,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,kBAAkB,SAAS;AACvE,iEAA0B,OAAO,gBAAgB,iBAAiB;AAAA,EACpE;AACA,SAAO,CAAC,GAAG,CAAC;AACd;AAEO,IAAM,oBAAoB,CAAC,cAAgD;AAChF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,QAAM,YAAY,uCAAW;AAC7B,QAAM,aAAa,uCAAW;AAC9B,QAAM,QAAQ,uCAAW;AAGzB,MAAI,CAAC,aAAa,OAAO,cAAc,YAAY,CAAC,iBAAiB,UAAU,KAAK,CAAC,yBAAyB,KAAK;AAAG,WAAO;AAC7H,oDAAe,KAAK;AAGpB,uDAAkB,KAAK;AACvB,MAAI,iBAAiB,SAAS;AAAG,sDAAe,KAAK;AAGrD,MAAI,cAAc,QAAW;AAC3B,yDAAkB,KAAK;AACvB,QAAI,SAAS,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS;AAAW,wDAAe,KAAK;AAAA,EACxF;AAEA,SAAO;AACT;AAEA,IAAM,mBAAmB,CAAC,cAA4C;AACpE,UAAQ,uCAAW,cAAc;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK,gBAAgB;AACnB,UAAI,SAAS,uCAAW,KAAK;AAAG,eAAO;AACvC;AAAA,IACF;AAAA,IACA,KAAK,oBAAoB;AACvB,UAAI,aAAa,uCAAW,KAAK;AAAG,eAAO;AAC3C;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,UAAI,OAAO,uCAAW,KAAK;AAAG,eAAO;AACrC;AAAA,IACF;AAAA,IACA,KAAK;AAAA,IACL,KAAK,QAAW;AACd,UAAI,iBAAiB,uCAAW,KAAK;AAAG,eAAO;AAC/C;AAAA,IACF;AAAA,IACA,SAAS;AACP;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,85 +0,0 @@
1
- // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
2
- import { incrementPossible, incrementTotal, incrementTotalAndPossible } from "@xyo-network/crypto-nft-score-model";
3
- var isDate = (value) => {
4
- if (isNumber(value)) {
5
- try {
6
- new Date(value);
7
- return true;
8
- } catch (error) {
9
- return false;
10
- }
11
- }
12
- return false;
13
- };
14
- var isNumber = (value) => typeof value === "number";
15
- var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
16
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
17
- var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
18
- var evaluateNftAttributes = (nft) => {
19
- var _a, _b;
20
- return !((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.attributes) ? [0, 1] : evaluateAttributes((_b = nft == null ? void 0 : nft.metadata) == null ? void 0 : _b.attributes);
21
- };
22
- var evaluateAttributes = (attributes) => {
23
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0)
24
- return [0, 1];
25
- const score = [0, 0];
26
- for (const attribute of attributes) {
27
- const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
28
- incrementTotalAndPossible(score, attributeTotal, attributePossible);
29
- }
30
- return [1, 1];
31
- };
32
- var evaluateAttribute = (attribute) => {
33
- const score = [0, 1];
34
- const max_value = attribute == null ? void 0 : attribute.max_value;
35
- const trait_type = attribute == null ? void 0 : attribute.trait_type;
36
- const value = attribute == null ? void 0 : attribute.value;
37
- if (!attribute || typeof attribute !== "object" || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value))
38
- return score;
39
- incrementTotal(score);
40
- incrementPossible(score);
41
- if (validDisplayType(attribute))
42
- incrementTotal(score);
43
- if (max_value !== void 0) {
44
- incrementPossible(score);
45
- if (isNumber(max_value) && isNumber(value) && value <= max_value)
46
- incrementTotal(score);
47
- }
48
- return score;
49
- };
50
- var validDisplayType = (attribute) => {
51
- switch (attribute == null ? void 0 : attribute.display_type) {
52
- case "number":
53
- case "boost_number": {
54
- if (isNumber(attribute == null ? void 0 : attribute.value))
55
- return true;
56
- break;
57
- }
58
- case "boost_percentage": {
59
- if (isPercentage(attribute == null ? void 0 : attribute.value))
60
- return true;
61
- break;
62
- }
63
- case "date": {
64
- if (isDate(attribute == null ? void 0 : attribute.value))
65
- return true;
66
- break;
67
- }
68
- case "string":
69
- case void 0: {
70
- if (isNonEmptyString(attribute == null ? void 0 : attribute.value))
71
- return true;
72
- break;
73
- }
74
- default: {
75
- break;
76
- }
77
- }
78
- return false;
79
- };
80
- export {
81
- evaluateAttribute,
82
- evaluateAttributes,
83
- evaluateNftAttributes
84
- };
85
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts"],"sourcesContent":["import { NftAttribute, NftInfoFields, OpenSeaNftAttribute, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nconst isDate = (value: unknown): value is Date => {\n if (isNumber(value)) {\n try {\n new Date(value)\n return true\n } catch (error) {\n return false\n }\n }\n return false\n}\n\nconst isNumber = (value: unknown): value is number => typeof value === 'number'\n\nconst isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100\n\nconst isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0\n\nconst isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)\n\nexport const evaluateNftAttributes = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore =>\n !nft?.metadata?.attributes ? [0, 1] : evaluateAttributes(nft?.metadata?.attributes)\n\nexport const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]\n const score: ScaledScore = [0, 0]\n for (const attribute of attributes) {\n const [attributeTotal, attributePossible] = evaluateAttribute(attribute)\n incrementTotalAndPossible(score, attributeTotal, attributePossible)\n }\n return [1, 1]\n}\n\nexport const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {\n const score: ScaledScore = [0, 1]\n const max_value = attribute?.max_value\n const trait_type = attribute?.trait_type\n const value = attribute?.value\n\n // Validate trait_type & value\n if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score\n incrementTotal(score)\n\n // Validate display_type\n incrementPossible(score)\n if (validDisplayType(attribute)) incrementTotal(score)\n\n // Validate max_value\n if (max_value !== undefined) {\n incrementPossible(score)\n if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)\n }\n\n return score\n}\n\nconst validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {\n switch (attribute?.display_type) {\n case 'number':\n case 'boost_number': {\n if (isNumber(attribute?.value)) return true\n break\n }\n case 'boost_percentage': {\n if (isPercentage(attribute?.value)) return true\n break\n }\n case 'date': {\n if (isDate(attribute?.value)) return true\n break\n }\n case 'string':\n case undefined: {\n if (isNonEmptyString(attribute?.value)) return true\n break\n }\n default: {\n break\n }\n }\n return false\n}\n"],"mappings":";AACA,SAAS,mBAAmB,gBAAgB,iCAA8C;AAE1F,IAAM,SAAS,CAAC,UAAkC;AAChD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI;AACF,UAAI,KAAK,KAAK;AACd,aAAO;AAAA,IACT,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAM,WAAW,CAAC,UAAoC,OAAO,UAAU;AAEvE,IAAM,eAAe,CAAC,UAA4B,SAAS,KAAK,KAAK,SAAS,KAAK,SAAS;AAE5F,IAAM,mBAAmB,CAAC,UAAoC,OAAO,UAAU,YAAY,MAAM,SAAS;AAE1G,IAAM,2BAA2B,CAAC,UAA6C,UAAU,YAAY,iBAAiB,KAAK;AAEpH,IAAM,wBAAwB,CAAC,QAAwD;AAvB9F;AAwBE,YAAC,gCAAK,aAAL,mBAAe,cAAa,CAAC,GAAG,CAAC,IAAI,oBAAmB,gCAAK,aAAL,mBAAe,UAAU;AAAA;AAE7E,IAAM,qBAAqB,CAAC,eAA8E;AAC/G,MAAI,CAAC,cAAc,CAAC,MAAM,QAAQ,UAAU,KAAK,WAAW,WAAW;AAAG,WAAO,CAAC,GAAG,CAAC;AACtF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,aAAW,aAAa,YAAY;AAClC,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,kBAAkB,SAAS;AACvE,8BAA0B,OAAO,gBAAgB,iBAAiB;AAAA,EACpE;AACA,SAAO,CAAC,GAAG,CAAC;AACd;AAEO,IAAM,oBAAoB,CAAC,cAAgD;AAChF,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,QAAM,YAAY,uCAAW;AAC7B,QAAM,aAAa,uCAAW;AAC9B,QAAM,QAAQ,uCAAW;AAGzB,MAAI,CAAC,aAAa,OAAO,cAAc,YAAY,CAAC,iBAAiB,UAAU,KAAK,CAAC,yBAAyB,KAAK;AAAG,WAAO;AAC7H,iBAAe,KAAK;AAGpB,oBAAkB,KAAK;AACvB,MAAI,iBAAiB,SAAS;AAAG,mBAAe,KAAK;AAGrD,MAAI,cAAc,QAAW;AAC3B,sBAAkB,KAAK;AACvB,QAAI,SAAS,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS;AAAW,qBAAe,KAAK;AAAA,EACxF;AAEA,SAAO;AACT;AAEA,IAAM,mBAAmB,CAAC,cAA4C;AACpE,UAAQ,uCAAW,cAAc;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK,gBAAgB;AACnB,UAAI,SAAS,uCAAW,KAAK;AAAG,eAAO;AACvC;AAAA,IACF;AAAA,IACA,KAAK,oBAAoB;AACvB,UAAI,aAAa,uCAAW,KAAK;AAAG,eAAO;AAC3C;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,UAAI,OAAO,uCAAW,KAAK;AAAG,eAAO;AACrC;AAAA,IACF;AAAA,IACA,KAAK;AAAA,IACL,KAAK,QAAW;AACd,UAAI,iBAAiB,uCAAW,KAAK;AAAG,eAAO;AAC/C;AAAA,IACF;AAAA,IACA,SAAS;AACP;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/rating/criteria/scoring/metadata/backgroundColor.ts
21
- var backgroundColor_exports = {};
22
- __export(backgroundColor_exports, {
23
- scoreBackgroundColor: () => scoreBackgroundColor,
24
- scoreNftBackgroundColor: () => scoreNftBackgroundColor
25
- });
26
- module.exports = __toCommonJS(backgroundColor_exports);
27
- var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
28
- var isHexColor = /^[0-9A-F]{6}$/i;
29
- var scoreNftBackgroundColor = (nft) => {
30
- var _a;
31
- return scoreBackgroundColor((_a = nft.metadata) == null ? void 0 : _a.background_color);
32
- };
33
- var scoreBackgroundColor = (background_color) => {
34
- const score = [0, 0];
35
- if (background_color === void 0 || background_color === null)
36
- return import_crypto_nft_score_model.PASS;
37
- (0, import_crypto_nft_score_model.incrementPossible)(score);
38
- if (typeof background_color !== "string")
39
- return score;
40
- (0, import_crypto_nft_score_model.incrementTotalAndPossible)(score);
41
- if (!background_color.toUpperCase().match(isHexColor))
42
- return score;
43
- return (0, import_crypto_nft_score_model.incrementTotal)(score);
44
- };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- scoreBackgroundColor,
48
- scoreNftBackgroundColor
49
- });
50
- //# sourceMappingURL=backgroundColor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/lib/rating/criteria/scoring/metadata/backgroundColor.ts"],"sourcesContent":["import { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'\nimport { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS, ScaledScore } from '@xyo-network/crypto-nft-score-model'\n\nconst isHexColor = /^[0-9A-F]{6}$/i\n\nexport const scoreNftBackgroundColor = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {\n return scoreBackgroundColor(nft.metadata?.background_color)\n}\n\nexport const scoreBackgroundColor = (background_color: unknown): ScaledScore => {\n const score: ScaledScore = [0, 0]\n if (background_color === undefined || background_color === null) return PASS\n incrementPossible(score)\n if (typeof background_color !== 'string') return score\n incrementTotalAndPossible(score)\n if (!background_color.toUpperCase().match(isHexColor)) return score\n return incrementTotal(score)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAgG;AAEhG,IAAM,aAAa;AAEZ,IAAM,0BAA0B,CAAC,QAA2D;AALnG;AAME,SAAO,sBAAqB,SAAI,aAAJ,mBAAc,gBAAgB;AAC5D;AAEO,IAAM,uBAAuB,CAAC,qBAA2C;AAC9E,QAAM,QAAqB,CAAC,GAAG,CAAC;AAChC,MAAI,qBAAqB,UAAa,qBAAqB;AAAM,WAAO;AACxE,uDAAkB,KAAK;AACvB,MAAI,OAAO,qBAAqB;AAAU,WAAO;AACjD,+DAA0B,KAAK;AAC/B,MAAI,CAAC,iBAAiB,YAAY,EAAE,MAAM,UAAU;AAAG,WAAO;AAC9D,aAAO,8CAAe,KAAK;AAC7B;","names":[]}