@xyo-network/crypto-nft-diviner-score-plugin 2.75.15 → 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 (226) hide show
  1. package/dist/docs.json +14 -14
  2. package/package.json +16 -16
  3. package/dist/browser/Diviner.cjs +0 -407
  4. package/dist/browser/Diviner.cjs.map +0 -1
  5. package/dist/browser/Diviner.js +0 -390
  6. package/dist/browser/Diviner.js.map +0 -1
  7. package/dist/browser/Plugin.cjs +0 -421
  8. package/dist/browser/Plugin.cjs.map +0 -1
  9. package/dist/browser/Plugin.js +0 -404
  10. package/dist/browser/Plugin.js.map +0 -1
  11. package/dist/browser/lib/index.cjs +0 -378
  12. package/dist/browser/lib/index.cjs.map +0 -1
  13. package/dist/browser/lib/index.js +0 -355
  14. package/dist/browser/lib/index.js.map +0 -1
  15. package/dist/browser/lib/rating/analyzeNft.cjs +0 -378
  16. package/dist/browser/lib/rating/analyzeNft.cjs.map +0 -1
  17. package/dist/browser/lib/rating/analyzeNft.js +0 -355
  18. package/dist/browser/lib/rating/analyzeNft.js.map +0 -1
  19. package/dist/browser/lib/rating/criteria/index.cjs +0 -364
  20. package/dist/browser/lib/rating/criteria/index.cjs.map +0 -1
  21. package/dist/browser/lib/rating/criteria/index.js +0 -341
  22. package/dist/browser/lib/rating/criteria/index.js.map +0 -1
  23. package/dist/browser/lib/rating/criteria/scoring/contract.cjs +0 -37
  24. package/dist/browser/lib/rating/criteria/scoring/contract.cjs.map +0 -1
  25. package/dist/browser/lib/rating/criteria/scoring/contract.js +0 -16
  26. package/dist/browser/lib/rating/criteria/scoring/contract.js.map +0 -1
  27. package/dist/browser/lib/rating/criteria/scoring/index.cjs +0 -363
  28. package/dist/browser/lib/rating/criteria/scoring/index.cjs.map +0 -1
  29. package/dist/browser/lib/rating/criteria/scoring/index.js +0 -340
  30. package/dist/browser/lib/rating/criteria/scoring/index.js.map +0 -1
  31. package/dist/browser/lib/rating/criteria/scoring/lib/index.cjs +0 -43
  32. package/dist/browser/lib/rating/criteria/scoring/lib/index.cjs.map +0 -1
  33. package/dist/browser/lib/rating/criteria/scoring/lib/index.js +0 -20
  34. package/dist/browser/lib/rating/criteria/scoring/lib/index.js.map +0 -1
  35. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.cjs +0 -42
  36. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.cjs.map +0 -1
  37. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +0 -19
  38. package/dist/browser/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +0 -1
  39. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.cjs +0 -34
  40. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.cjs.map +0 -1
  41. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.js +0 -13
  42. package/dist/browser/lib/rating/criteria/scoring/lib/toBigNumber.js.map +0 -1
  43. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.cjs +0 -67
  44. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.cjs.map +0 -1
  45. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.js +0 -46
  46. package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.js.map +0 -1
  47. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.cjs +0 -103
  48. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.cjs.map +0 -1
  49. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +0 -82
  50. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +0 -1
  51. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.cjs +0 -105
  52. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.cjs.map +0 -1
  53. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.js +0 -82
  54. package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.js.map +0 -1
  55. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.cjs +0 -44
  56. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.cjs.map +0 -1
  57. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.js +0 -23
  58. package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +0 -1
  59. package/dist/browser/lib/rating/criteria/scoring/metadata/description.cjs +0 -37
  60. package/dist/browser/lib/rating/criteria/scoring/metadata/description.cjs.map +0 -1
  61. package/dist/browser/lib/rating/criteria/scoring/metadata/description.js +0 -16
  62. package/dist/browser/lib/rating/criteria/scoring/metadata/description.js.map +0 -1
  63. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.cjs +0 -58
  64. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.cjs.map +0 -1
  65. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.js +0 -37
  66. package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.js.map +0 -1
  67. package/dist/browser/lib/rating/criteria/scoring/metadata/image.cjs +0 -67
  68. package/dist/browser/lib/rating/criteria/scoring/metadata/image.cjs.map +0 -1
  69. package/dist/browser/lib/rating/criteria/scoring/metadata/image.js +0 -46
  70. package/dist/browser/lib/rating/criteria/scoring/metadata/image.js.map +0 -1
  71. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.cjs +0 -50
  72. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.cjs.map +0 -1
  73. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.js +0 -29
  74. package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.js.map +0 -1
  75. package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs +0 -287
  76. package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs.map +0 -1
  77. package/dist/browser/lib/rating/criteria/scoring/metadata/index.js +0 -264
  78. package/dist/browser/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
  79. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.cjs +0 -48
  80. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.cjs.map +0 -1
  81. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.js +0 -25
  82. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.js.map +0 -1
  83. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.cjs +0 -46
  84. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.cjs.map +0 -1
  85. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +0 -25
  86. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +0 -1
  87. package/dist/browser/lib/rating/criteria/scoring/metadata/name.cjs +0 -37
  88. package/dist/browser/lib/rating/criteria/scoring/metadata/name.cjs.map +0 -1
  89. package/dist/browser/lib/rating/criteria/scoring/metadata/name.js +0 -16
  90. package/dist/browser/lib/rating/criteria/scoring/metadata/name.js.map +0 -1
  91. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.cjs +0 -60
  92. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.cjs.map +0 -1
  93. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.js +0 -39
  94. package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +0 -1
  95. package/dist/browser/lib/rating/criteria/scoring/supply.cjs +0 -56
  96. package/dist/browser/lib/rating/criteria/scoring/supply.cjs.map +0 -1
  97. package/dist/browser/lib/rating/criteria/scoring/supply.js +0 -35
  98. package/dist/browser/lib/rating/criteria/scoring/supply.js.map +0 -1
  99. package/dist/browser/lib/rating/criteria/scoring/tokenId.cjs +0 -56
  100. package/dist/browser/lib/rating/criteria/scoring/tokenId.cjs.map +0 -1
  101. package/dist/browser/lib/rating/criteria/scoring/tokenId.js +0 -35
  102. package/dist/browser/lib/rating/criteria/scoring/tokenId.js.map +0 -1
  103. package/dist/browser/lib/rating/criteria/scoring/type.cjs +0 -37
  104. package/dist/browser/lib/rating/criteria/scoring/type.cjs.map +0 -1
  105. package/dist/browser/lib/rating/criteria/scoring/type.js +0 -16
  106. package/dist/browser/lib/rating/criteria/scoring/type.js.map +0 -1
  107. package/dist/browser/lib/rating/criteria/scoringCriteria.cjs +0 -364
  108. package/dist/browser/lib/rating/criteria/scoringCriteria.cjs.map +0 -1
  109. package/dist/browser/lib/rating/criteria/scoringCriteria.js +0 -341
  110. package/dist/browser/lib/rating/criteria/scoringCriteria.js.map +0 -1
  111. package/dist/browser/lib/rating/index.cjs +0 -378
  112. package/dist/browser/lib/rating/index.cjs.map +0 -1
  113. package/dist/browser/lib/rating/index.js +0 -355
  114. package/dist/browser/lib/rating/index.js.map +0 -1
  115. package/dist/node/Diviner.js +0 -429
  116. package/dist/node/Diviner.js.map +0 -1
  117. package/dist/node/Diviner.mjs +0 -407
  118. package/dist/node/Diviner.mjs.map +0 -1
  119. package/dist/node/Plugin.js +0 -442
  120. package/dist/node/Plugin.js.map +0 -1
  121. package/dist/node/Plugin.mjs +0 -421
  122. package/dist/node/Plugin.mjs.map +0 -1
  123. package/dist/node/lib/index.js +0 -399
  124. package/dist/node/lib/index.js.map +0 -1
  125. package/dist/node/lib/index.mjs +0 -372
  126. package/dist/node/lib/index.mjs.map +0 -1
  127. package/dist/node/lib/rating/analyzeNft.js +0 -399
  128. package/dist/node/lib/rating/analyzeNft.js.map +0 -1
  129. package/dist/node/lib/rating/analyzeNft.mjs +0 -372
  130. package/dist/node/lib/rating/analyzeNft.mjs.map +0 -1
  131. package/dist/node/lib/rating/criteria/index.js +0 -385
  132. package/dist/node/lib/rating/criteria/index.js.map +0 -1
  133. package/dist/node/lib/rating/criteria/index.mjs +0 -358
  134. package/dist/node/lib/rating/criteria/index.mjs.map +0 -1
  135. package/dist/node/lib/rating/criteria/scoring/contract.js +0 -41
  136. package/dist/node/lib/rating/criteria/scoring/contract.js.map +0 -1
  137. package/dist/node/lib/rating/criteria/scoring/contract.mjs +0 -16
  138. package/dist/node/lib/rating/criteria/scoring/contract.mjs.map +0 -1
  139. package/dist/node/lib/rating/criteria/scoring/index.js +0 -406
  140. package/dist/node/lib/rating/criteria/scoring/index.js.map +0 -1
  141. package/dist/node/lib/rating/criteria/scoring/index.mjs +0 -357
  142. package/dist/node/lib/rating/criteria/scoring/index.mjs.map +0 -1
  143. package/dist/node/lib/rating/criteria/scoring/lib/index.js +0 -48
  144. package/dist/node/lib/rating/criteria/scoring/lib/index.js.map +0 -1
  145. package/dist/node/lib/rating/criteria/scoring/lib/index.mjs +0 -20
  146. package/dist/node/lib/rating/criteria/scoring/lib/index.mjs.map +0 -1
  147. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +0 -46
  148. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +0 -1
  149. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.mjs +0 -19
  150. package/dist/node/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.mjs.map +0 -1
  151. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.js +0 -38
  152. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.js.map +0 -1
  153. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.mjs +0 -13
  154. package/dist/node/lib/rating/criteria/scoring/lib/toBigNumber.mjs.map +0 -1
  155. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.js +0 -79
  156. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.js.map +0 -1
  157. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.mjs +0 -53
  158. package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.mjs.map +0 -1
  159. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +0 -112
  160. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +0 -1
  161. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.mjs +0 -85
  162. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.mjs.map +0 -1
  163. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.js +0 -114
  164. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.js.map +0 -1
  165. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.mjs +0 -85
  166. package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.mjs.map +0 -1
  167. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.js +0 -50
  168. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +0 -1
  169. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.mjs +0 -24
  170. package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.mjs.map +0 -1
  171. package/dist/node/lib/rating/criteria/scoring/metadata/description.js +0 -43
  172. package/dist/node/lib/rating/criteria/scoring/metadata/description.js.map +0 -1
  173. package/dist/node/lib/rating/criteria/scoring/metadata/description.mjs +0 -17
  174. package/dist/node/lib/rating/criteria/scoring/metadata/description.mjs.map +0 -1
  175. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.js +0 -70
  176. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.js.map +0 -1
  177. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.mjs +0 -44
  178. package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.mjs.map +0 -1
  179. package/dist/node/lib/rating/criteria/scoring/metadata/image.js +0 -79
  180. package/dist/node/lib/rating/criteria/scoring/metadata/image.js.map +0 -1
  181. package/dist/node/lib/rating/criteria/scoring/metadata/image.mjs +0 -53
  182. package/dist/node/lib/rating/criteria/scoring/metadata/image.mjs.map +0 -1
  183. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.js +0 -56
  184. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.js.map +0 -1
  185. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.mjs +0 -30
  186. package/dist/node/lib/rating/criteria/scoring/metadata/imageData.mjs.map +0 -1
  187. package/dist/node/lib/rating/criteria/scoring/metadata/index.js +0 -326
  188. package/dist/node/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
  189. package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs +0 -281
  190. package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs.map +0 -1
  191. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.js +0 -63
  192. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.js.map +0 -1
  193. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.mjs +0 -31
  194. package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.mjs.map +0 -1
  195. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +0 -61
  196. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +0 -1
  197. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.mjs +0 -31
  198. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.mjs.map +0 -1
  199. package/dist/node/lib/rating/criteria/scoring/metadata/name.js +0 -43
  200. package/dist/node/lib/rating/criteria/scoring/metadata/name.js.map +0 -1
  201. package/dist/node/lib/rating/criteria/scoring/metadata/name.mjs +0 -17
  202. package/dist/node/lib/rating/criteria/scoring/metadata/name.mjs.map +0 -1
  203. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.js +0 -72
  204. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +0 -1
  205. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.mjs +0 -46
  206. package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.mjs.map +0 -1
  207. package/dist/node/lib/rating/criteria/scoring/supply.js +0 -60
  208. package/dist/node/lib/rating/criteria/scoring/supply.js.map +0 -1
  209. package/dist/node/lib/rating/criteria/scoring/supply.mjs +0 -35
  210. package/dist/node/lib/rating/criteria/scoring/supply.mjs.map +0 -1
  211. package/dist/node/lib/rating/criteria/scoring/tokenId.js +0 -60
  212. package/dist/node/lib/rating/criteria/scoring/tokenId.js.map +0 -1
  213. package/dist/node/lib/rating/criteria/scoring/tokenId.mjs +0 -35
  214. package/dist/node/lib/rating/criteria/scoring/tokenId.mjs.map +0 -1
  215. package/dist/node/lib/rating/criteria/scoring/type.js +0 -41
  216. package/dist/node/lib/rating/criteria/scoring/type.js.map +0 -1
  217. package/dist/node/lib/rating/criteria/scoring/type.mjs +0 -16
  218. package/dist/node/lib/rating/criteria/scoring/type.mjs.map +0 -1
  219. package/dist/node/lib/rating/criteria/scoringCriteria.js +0 -385
  220. package/dist/node/lib/rating/criteria/scoringCriteria.js.map +0 -1
  221. package/dist/node/lib/rating/criteria/scoringCriteria.mjs +0 -358
  222. package/dist/node/lib/rating/criteria/scoringCriteria.mjs.map +0 -1
  223. package/dist/node/lib/rating/index.js +0 -399
  224. package/dist/node/lib/rating/index.js.map +0 -1
  225. package/dist/node/lib/rating/index.mjs +0 -372
  226. 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,2BA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AAK;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,IAC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AAe,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,EAC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,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?.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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":[]}