diff --git a/jest.config.ts b/jest.config.ts index 03fa659a19..46a00ea93b 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -7,6 +7,7 @@ const jestConfig = { coverageDirectory: './coverage/', collectCoverage: true, testEnvironment: 'jsdom', + setupFiles: ['./jest.setup.ts'], }; export default jestConfig; diff --git a/jest.setup.ts b/jest.setup.ts new file mode 100644 index 0000000000..4be3734a77 --- /dev/null +++ b/jest.setup.ts @@ -0,0 +1 @@ +import 'whatwg-fetch'; diff --git a/package-lock.json b/package-lock.json index 0ac284ff5b..0f5e45892e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,6 @@ "typescript": "4.9.4", "uuid": "9.0.0", "waitasecond": "1.11.1", - "whoiser": "1.17.1", "xmldom-qsa": "1.1.3", "xyzt": "5.4.0", "yaml": "2.2.2" @@ -3100,6 +3099,11 @@ "@promptbook/core": "0.18.0" } }, + "node_modules/@promptbook/openai/node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, "node_modules/@promptbook/openai/node_modules/openai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/openai/-/openai-4.2.0.tgz", @@ -3304,6 +3308,17 @@ "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true }, + "node_modules/@sindresorhus/is": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.6.0.tgz", + "integrity": "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, "node_modules/@sinonjs/commons": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", @@ -4061,6 +4076,17 @@ "tslib": "^2.4.0" } }, + "node_modules/@szmarczak/http-timer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", + "integrity": "sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==", + "dependencies": { + "defer-to-connect": "^2.0.1" + }, + "engines": { + "node": ">=14.16" + } + }, "node_modules/@tokenizer/token": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", @@ -4310,6 +4336,11 @@ "hoist-non-react-statics": "^3.3.0" } }, + "node_modules/@types/http-cache-semantics": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", + "integrity": "sha512-V46MYLFp08Wf2mmaBhvgjStM3tPa+2GAdy/iqoX+noX1//zje2x4XmrIU0cAwyClATsTmahbtoQ2EwP7I5WSiA==" + }, "node_modules/@types/http-errors": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", @@ -6136,6 +6167,42 @@ "node": ">=8" } }, + "node_modules/cacheable-lookup": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz", + "integrity": "sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==", + "engines": { + "node": ">=14.16" + } + }, + "node_modules/cacheable-request": { + "version": "10.2.14", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-10.2.14.tgz", + "integrity": "sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ==", + "dependencies": { + "@types/http-cache-semantics": "^4.0.2", + "get-stream": "^6.0.1", + "http-cache-semantics": "^4.1.1", + "keyv": "^4.5.3", + "mimic-response": "^4.0.0", + "normalize-url": "^8.0.0", + "responselike": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + } + }, + "node_modules/cacheable-request/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cachedir": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.4.0.tgz", @@ -6527,6 +6594,14 @@ "node": ">=6" } }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/cmd-shim": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.2.tgz", @@ -7113,6 +7188,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/dedent": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", @@ -7150,6 +7236,14 @@ "node": ">=0.10.0" } }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "engines": { + "node": ">=10" + } + }, "node_modules/define-data-property": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", @@ -8972,9 +9066,12 @@ } }, "node_modules/form-data-encoder": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", - "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.1.4.tgz", + "integrity": "sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==", + "engines": { + "node": ">= 14.17" + } }, "node_modules/formdata-node": { "version": "4.4.1", @@ -9563,6 +9660,41 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/got": { + "version": "12.6.1", + "resolved": "https://registry.npmjs.org/got/-/got-12.6.1.tgz", + "integrity": "sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==", + "dependencies": { + "@sindresorhus/is": "^5.2.0", + "@szmarczak/http-timer": "^5.0.1", + "cacheable-lookup": "^7.0.0", + "cacheable-request": "^10.2.8", + "decompress-response": "^6.0.0", + "form-data-encoder": "^2.1.2", + "get-stream": "^6.0.1", + "http2-wrapper": "^2.1.10", + "lowercase-keys": "^3.0.0", + "p-cancelable": "^3.0.0", + "responselike": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/got/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -9800,6 +9932,11 @@ "entities": "^4.3.0" } }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -9843,6 +9980,29 @@ "node": ">=0.10" } }, + "node_modules/http2-wrapper": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-2.2.0.tgz", + "integrity": "sha512-kZB0wxMo0sh1PehyjJUWRFEd99KC5TLjZ2cULC4f9iqJBAmKQQXEICjxl5iPJRwP40dpeHFqqhm7tYCvODpqpQ==", + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.2.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/http2-wrapper/node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -10082,6 +10242,11 @@ "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" }, + "node_modules/ip-matching": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ip-matching/-/ip-matching-2.1.2.tgz", + "integrity": "sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg==" + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -11622,8 +11787,7 @@ "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", @@ -12055,6 +12219,17 @@ "loose-envify": "cli.js" } }, + "node_modules/lowercase-keys": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", + "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -12229,11 +12404,11 @@ } }, "node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-4.0.0.tgz", + "integrity": "sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==", "engines": { - "node": ">=10" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -12545,6 +12720,17 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" }, + "node_modules/node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "dependencies": { + "clone": "2.x" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -12603,6 +12789,26 @@ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true }, + "node_modules/node-rdap": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/node-rdap/-/node-rdap-0.3.5.tgz", + "integrity": "sha512-XZzNPqinZUUGPJi7dh5btPT4RKVvxj4eQfNQvnC8+o8ghzj1JjvouKKzxHXCyRZRSj9dbUIzwi6xDEgYxB/iFA==", + "dependencies": { + "commander": "^10.0.0", + "got": "^12.5.3", + "ip-matching": "^2.1.2", + "node-cache": "^5.1.2", + "punycode": "^2.1.1" + } + }, + "node_modules/node-rdap/node_modules/commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "engines": { + "node": ">=14" + } + }, "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", @@ -12641,6 +12847,17 @@ "node": ">=0.10.0" } }, + "node_modules/normalize-url": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.0.tgz", + "integrity": "sha512-uVFpKhj5MheNBJRTiMZ9pE/7hD1QTeEvugSJW/OmLzAp78PB5O6adfMNTvmfKhXBkvCzC+rqifWcVYpGFwTjnw==", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/npm-normalize-package-bin": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", @@ -12852,6 +13069,11 @@ "openai": "bin/cli" } }, + "node_modules/openai/node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -12890,6 +13112,14 @@ "integrity": "sha512-o6E5qJV5zkAbIDNhGSIlyOhScKXgQrSRMilfph0clDfM0nEnBOlKlH4sWDmG95BW/CvwNz0vmm7dJVtU2KlMiA==", "dev": true }, + "node_modules/p-cancelable": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-3.0.0.tgz", + "integrity": "sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==", + "engines": { + "node": ">=12.20" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -14219,6 +14449,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==" + }, "node_modules/resolve-cwd": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", @@ -14266,6 +14501,20 @@ "node": ">=10" } }, + "node_modules/responselike": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", + "integrity": "sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg==", + "dependencies": { + "lowercase-keys": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -16603,6 +16852,18 @@ "node": ">=0.10.0" } }, + "node_modules/whatwg-encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/whatwg-fetch": { "version": "3.6.19", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.19.tgz", @@ -16740,17 +17001,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/whoiser": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/whoiser/-/whoiser-1.17.1.tgz", - "integrity": "sha512-dyIwadr1nYHPbz/rqoUTJvIarA2ZzBozi34etDff4Z3o5aj9Z3HPG9AULBRk3D0Vz/xtVAZwez6QaRoeV9GJPg==", - "dependencies": { - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=15.0.0" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -19473,6 +19723,11 @@ "openai": "4.2.0" }, "dependencies": { + "form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, "openai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/openai/-/openai-4.2.0.tgz", @@ -19626,6 +19881,11 @@ "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true }, + "@sindresorhus/is": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.6.0.tgz", + "integrity": "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==" + }, "@sinonjs/commons": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", @@ -20256,6 +20516,14 @@ "tslib": "^2.4.0" } }, + "@szmarczak/http-timer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", + "integrity": "sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==", + "requires": { + "defer-to-connect": "^2.0.1" + } + }, "@tokenizer/token": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", @@ -20501,6 +20769,11 @@ "hoist-non-react-statics": "^3.3.0" } }, + "@types/http-cache-semantics": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", + "integrity": "sha512-V46MYLFp08Wf2mmaBhvgjStM3tPa+2GAdy/iqoX+noX1//zje2x4XmrIU0cAwyClATsTmahbtoQ2EwP7I5WSiA==" + }, "@types/http-errors": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", @@ -21930,6 +22203,32 @@ "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", "dev": true }, + "cacheable-lookup": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz", + "integrity": "sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==" + }, + "cacheable-request": { + "version": "10.2.14", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-10.2.14.tgz", + "integrity": "sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ==", + "requires": { + "@types/http-cache-semantics": "^4.0.2", + "get-stream": "^6.0.1", + "http-cache-semantics": "^4.1.1", + "keyv": "^4.5.3", + "mimic-response": "^4.0.0", + "normalize-url": "^8.0.0", + "responselike": "^3.0.0" + }, + "dependencies": { + "get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + } + } + }, "cachedir": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.4.0.tgz", @@ -22203,6 +22502,11 @@ } } }, + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==" + }, "cmd-shim": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.2.tgz", @@ -22659,6 +22963,13 @@ "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "requires": { "mimic-response": "^3.1.0" + }, + "dependencies": { + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + } } }, "dedent": { @@ -22685,6 +22996,11 @@ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", "dev": true }, + "defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==" + }, "define-data-property": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", @@ -24055,9 +24371,9 @@ } }, "form-data-encoder": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", - "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.1.4.tgz", + "integrity": "sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==" }, "formdata-node": { "version": "4.4.1", @@ -24496,6 +24812,31 @@ "get-intrinsic": "^1.1.3" } }, + "got": { + "version": "12.6.1", + "resolved": "https://registry.npmjs.org/got/-/got-12.6.1.tgz", + "integrity": "sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==", + "requires": { + "@sindresorhus/is": "^5.2.0", + "@szmarczak/http-timer": "^5.0.1", + "cacheable-lookup": "^7.0.0", + "cacheable-request": "^10.2.8", + "decompress-response": "^6.0.0", + "form-data-encoder": "^2.1.2", + "get-stream": "^6.0.1", + "http2-wrapper": "^2.1.10", + "lowercase-keys": "^3.0.0", + "p-cancelable": "^3.0.0", + "responselike": "^3.0.0" + }, + "dependencies": { + "get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + } + } + }, "graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -24671,6 +25012,11 @@ "entities": "^4.3.0" } }, + "http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -24705,6 +25051,22 @@ "sshpk": "^1.14.1" } }, + "http2-wrapper": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-2.2.0.tgz", + "integrity": "sha512-kZB0wxMo0sh1PehyjJUWRFEd99KC5TLjZ2cULC4f9iqJBAmKQQXEICjxl5iPJRwP40dpeHFqqhm7tYCvODpqpQ==", + "requires": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.2.0" + }, + "dependencies": { + "quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==" + } + } + }, "https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -24878,6 +25240,11 @@ "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" }, + "ip-matching": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ip-matching/-/ip-matching-2.1.2.tgz", + "integrity": "sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg==" + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -26036,8 +26403,7 @@ "json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, "json-parse-even-better-errors": { "version": "2.3.1", @@ -26390,6 +26756,11 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, + "lowercase-keys": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", + "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==" + }, "lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -26521,9 +26892,9 @@ "dev": true }, "mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-4.0.0.tgz", + "integrity": "sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==" }, "min-document": { "version": "2.19.0", @@ -26728,6 +27099,14 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" }, + "node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "requires": { + "clone": "2.x" + } + }, "node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -26757,6 +27136,25 @@ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true }, + "node-rdap": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/node-rdap/-/node-rdap-0.3.5.tgz", + "integrity": "sha512-XZzNPqinZUUGPJi7dh5btPT4RKVvxj4eQfNQvnC8+o8ghzj1JjvouKKzxHXCyRZRSj9dbUIzwi6xDEgYxB/iFA==", + "requires": { + "commander": "^10.0.0", + "got": "^12.5.3", + "ip-matching": "^2.1.2", + "node-cache": "^5.1.2", + "punycode": "^2.1.1" + }, + "dependencies": { + "commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==" + } + } + }, "node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", @@ -26786,6 +27184,11 @@ "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", "dev": true }, + "normalize-url": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.0.tgz", + "integrity": "sha512-uVFpKhj5MheNBJRTiMZ9pE/7hD1QTeEvugSJW/OmLzAp78PB5O6adfMNTvmfKhXBkvCzC+rqifWcVYpGFwTjnw==" + }, "npm-normalize-package-bin": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", @@ -26977,6 +27380,11 @@ "integrity": "sha512-o6E5qJV5zkAbIDNhGSIlyOhScKXgQrSRMilfph0clDfM0nEnBOlKlH4sWDmG95BW/CvwNz0vmm7dJVtU2KlMiA==", "dev": true }, + "p-cancelable": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-3.0.0.tgz", + "integrity": "sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==" + }, "p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -27926,6 +28334,11 @@ "supports-preserve-symlinks-flag": "^1.0.0" } }, + "resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==" + }, "resolve-cwd": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", @@ -27960,6 +28373,14 @@ "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "dev": true }, + "responselike": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", + "integrity": "sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg==", + "requires": { + "lowercase-keys": "^3.0.0" + } + }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -29839,14 +30260,6 @@ "has-tostringtag": "^1.0.0" } }, - "whoiser": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/whoiser/-/whoiser-1.17.1.tgz", - "integrity": "sha512-dyIwadr1nYHPbz/rqoUTJvIarA2ZzBozi34etDff4Z3o5aj9Z3HPG9AULBRk3D0Vz/xtVAZwez6QaRoeV9GJPg==", - "requires": { - "punycode": "^2.1.1" - } - }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 51a9cd58b3..31f30490b9 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,6 @@ "typescript": "4.9.4", "uuid": "9.0.0", "waitasecond": "1.11.1", - "whoiser": "1.17.1", "xmldom-qsa": "1.1.3", "xyzt": "5.4.0", "yaml": "2.2.2" diff --git a/scripts/playground/playground.ts b/scripts/playground/playground.ts index ecc221ae74..a2c879a143 100644 --- a/scripts/playground/playground.ts +++ b/scripts/playground/playground.ts @@ -5,7 +5,6 @@ import * as dotenv from 'dotenv'; dotenv.config({ path: '.env' }); import chalk from 'chalk'; -import OpenAI from 'openai'; import { join } from 'path'; import { OPENAI_API_KEY } from '../../config'; @@ -30,22 +29,9 @@ async function playground() { // Do here stuff you want to test //========================================> - const openai = new OpenAI({ - apiKey: OPENAI_API_KEY, - }); - - const generatedImage = await openai.images.generate({ - prompt: 'A dog', - model: 'dall-e-2', - n: 0, - size: '256x256', - // size: '1792x1024', - // quality: 'standard', - // style: 'natural', - user: 'playground', - }); - - console.log(generatedImage); + console.log('--------------------'); + console.log(JSON.stringify(await lookupDomain(`towns.cz`), null, 4)); + console.log('--------------------'); //========================================/ console.info(`[ Done 🧸 Playground ]`); diff --git a/src/components/Domains/DomainStatusChecker/DomainStatusChecker.tsx b/src/components/Domains/DomainStatusChecker/DomainStatusChecker.tsx new file mode 100644 index 0000000000..dcd448111e --- /dev/null +++ b/src/components/Domains/DomainStatusChecker/DomainStatusChecker.tsx @@ -0,0 +1,91 @@ +import { useEffect, useState } from 'react'; +import { forTime } from 'waitasecond'; +import { checkDomain } from '../../../utils/domains/checkDomain'; +import { DomainStatus } from '../../../utils/domains/DomainStatus'; + +import { justNoActionWith } from '../../../utils/justNoActionWith'; +import type { DomainStatusTextProps } from '../DomainStatusText/DomainStatusText'; +import { DomainStatusText } from '../DomainStatusText/DomainStatusText'; +import styles from '../DomainStatusText/DomainStatusText.module.css'; + +interface DomainStatusCheckerProps extends Omit { + /** + * Is checking immediately after the component is mounted OR after some debounce time + */ + isDebounced: boolean; + + /** + * Is auto refreshed after some time when the domain is UNKNOWN, LIMIT or TIMEOUT + */ + isRetried: boolean; +} + +/** + * Renderrs an info about a domain + * + * Note: It internally fetches and displays the whois + */ +export function DomainStatusChecker(props: DomainStatusCheckerProps) { + const { domain, isActionButtonShown, isShownDetailedFail, isDebounced, isRetried, className } = props; + + const [domainStatus, setDomainStatus] = useState('PENDING'); + const [checkedAt, setCheckedAt] = useState(null); + const [tryCount, setTryCount] = useState(1); + const domainStatusPromise = useEffect(() => { + let isDestroyed = false; + + (async () => { + if (isDebounced) { + await forTime(200 /* <- TODO: !! DEBOUNCE_TIME_MS to config */); + } + if (isDestroyed) { + return; + } + justNoActionWith(tryCount); + const domainStatus = await checkDomain(domain); + + if (['LIMIT', 'TIMEOUT', 'UNKNOWN'].includes(domainStatus)) { + await forTime(5000 + Math.random() * 10000 /* <- TODO: !! RETRY_TIME_MS to config */); + setTryCount(tryCount + 1); + } + + setCheckedAt(new Date()); + setDomainStatus(domainStatus); + })(); + + return () => { + isDestroyed = true; + }; + }, [domain, isDebounced, isRetried, tryCount]); + + let domainStatusShown = domainStatus; + + if ( + ['LIMIT', 'TIMEOUT', 'NOT_SUPPORTED'].includes(domainStatusShown as keyof typeof DomainStatus | 'PENDING') && + !isShownDetailedFail + ) { + domainStatusShown = 'UNKNOWN'; + } + + return ( + <> + + {isActionButtonShown && ['UNKNOWN', 'LIMIT'].includes(domainStatusShown as any) && ( + + )} + + ); +} + +/** + * TODO: !! Probbably debounce the whois lookup + */ diff --git a/src/components/Domains/DomainStatusText/DomainStatusText.module.css b/src/components/Domains/DomainStatusText/DomainStatusText.module.css index a208ed7807..8202c3256c 100644 --- a/src/components/Domains/DomainStatusText/DomainStatusText.module.css +++ b/src/components/Domains/DomainStatusText/DomainStatusText.module.css @@ -14,6 +14,12 @@ color: #888888; } +.DomainStatusText .timeoput { + color: #888888; +} +.DomainStatusText .limit { + color: #888888; +} .DomainStatusText span b { color: inherit; } diff --git a/src/components/Domains/DomainStatusText/DomainStatusText.tsx b/src/components/Domains/DomainStatusText/DomainStatusText.tsx index a3493f4284..0f551d3e51 100644 --- a/src/components/Domains/DomainStatusText/DomainStatusText.tsx +++ b/src/components/Domains/DomainStatusText/DomainStatusText.tsx @@ -1,29 +1,44 @@ +import moment from 'moment'; import Link from 'next/link'; -import { useMemo } from 'react'; import { classNames } from '../../../utils/classNames'; -import { checkDomain } from '../../../utils/domains/checkDomain'; -import { usePromise } from '../../../utils/hooks/usePromise'; -import { string_css_class, string_domain } from '../../../utils/typeAliases'; +import type { DomainStatus } from '../../../utils/domains/DomainStatus'; +import { getDomainTdl } from '../../../utils/domains/getDomainTdl'; +import type { string_css_class, string_domain } from '../../../utils/typeAliases'; import styles from './DomainStatusText.module.css'; -interface DomainStatusTextProps { +export interface DomainStatusTextProps { /** - * The domain to check + * The domain which is checked * - * Note: The domain will be normalized - trimmed and lowercased + * Note: The domain should be normalized - trimmed and lowercased */ domain: string_domain; + /** + * Status of the domain + */ + domainStatus: keyof typeof DomainStatus | 'PENDING'; + + /** + * How much attempts to check were done? + */ + tryCount: number; + + /** + * When was the domain checked? + */ + checkedAt: Date | null; + /** * Is button to open page shown? */ isActionButtonShown?: boolean; /** - * Is shown that the domain exceeded limit for whois lookups? + * Is shown that the domain exceeded limit, timeout or not supported tdl for whois lookups? * If no or not set, it will be shown as UNKNOWN */ - isShownExceededLimit?: boolean; + isShownDetailedFail?: boolean; /** * Optional CSS class name which will be added to root element @@ -37,15 +52,20 @@ interface DomainStatusTextProps { * Note: It internally fetches and displays the whois */ export function DomainStatusText(props: DomainStatusTextProps) { - const { domain, isActionButtonShown, isShownExceededLimit, className } = props; + const { domain, isActionButtonShown, isShownDetailedFail, tryCount, checkedAt, className } = props; + let { domainStatus } = props; - const domainStatusPromise = useMemo(() => /* not await */ checkDomain(domain), [domain]); - let { value: domainStatus } = usePromise(domainStatusPromise, [domain]); - - if (domainStatus === 'LIMIT' && !isShownExceededLimit) { + if (['LIMIT', 'TIMEOUT', 'NOT_SUPPORTED'].includes(domainStatus as any) && !isShownDetailedFail) { domainStatus = 'UNKNOWN'; } + const tryCountMessage = tryCount > 1 ? (Tried {tryCount}x) : <>; + const checkedAtMessage = checkedAt ? ( + ({moment(checkedAt).calendar(/* <- TODO: !! Use current locale */)}) + ) : ( + <> + ); + return (
console.info(whois)} @@ -55,12 +75,12 @@ export function DomainStatusText(props: DomainStatusTextProps) { { PENDING: ( - {domain}: Getting whois info... + {domain}: Getting info about domain ⏣ {/* <- TODO: Circle between ⌬ and ⏣ */} ), AVAILABLE: ( - {domain} is available for registration + {domain} is available for registration {checkedAtMessage} ), REGISTERED: ( @@ -70,24 +90,27 @@ export function DomainStatusText(props: DomainStatusTextProps) { ), LIMIT: ( - {domain} exceeded limit for whois lookups + {domain} exceeded limit for whois lookups {tryCountMessage} + + ), + TIMEOUT: ( + + {domain} timeouted while getting whois info {tryCountMessage} ), - // TODO: TIMEOUT: Timeout in whois lookup, UNKNOWN: ( - {domain} status is unknown + {domain} status is unknown {tryCountMessage} + + ), + TDL_NOT_SUPPORTED: ( + + {domain} unfortunately we can not check .{getDomainTdl(domain)} domains ), - }[domainStatus || 'PENDING'] + }[domainStatus] } - {/* TODO: [🧠] How to refresh the domain information? - - */} - {/* TODO: [🧠] How/where to offer domain registration? {domainStatus === 'AVAILABLE' && ( ); } - -/** - * TODO: !! Probbably debounce the whois lookup - */ diff --git a/src/components/Domains/DomainsStatusList/DomainsStatusList.module.css b/src/components/Domains/DomainsStatusList/DomainsStatusList.module.css deleted file mode 100644 index 23f6342461..0000000000 --- a/src/components/Domains/DomainsStatusList/DomainsStatusList.module.css +++ /dev/null @@ -1,20 +0,0 @@ -.DomainsStatusList { - /*/ - outline: 1px dotted rgb(255, 38, 38); - /**/ - - width: 100%; - - padding: 10px; - padding-top: 20px; -} - -textarea.pattern { - /*/ - outline: 1px dotted rgb(255, 38, 38); - /**/ - - width: 50%; - - height: 300px; -} diff --git a/src/components/Domains/DomainsStatusList/DomainsStatusList.tsx b/src/components/Domains/DomainsStatusList/DomainsStatusList.tsx deleted file mode 100644 index 531bc0d8d9..0000000000 --- a/src/components/Domains/DomainsStatusList/DomainsStatusList.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { string_domain } from '../../../utils/typeAliases'; -import { DomainStatusText } from '../DomainStatusText/DomainStatusText'; -import styles from './DomainsStatusList.module.css'; - -interface DomainsStatusListProps { - /** - * The domains to check - * - * Note: All domains will be normalized - trimmed and lowercased - */ - domains: Array; -} - -/** - * Renderrs an info about multiple domains - * Note: It internally fetches and displays the whois - */ -export function DomainsStatusList(props: DomainsStatusListProps) { - const { domains } = props; - - return ( -
- {domains.map((domain) => ( - - ))} -
- ); -} diff --git a/src/components/Domains/SimpleDomainChecker.tsx b/src/components/Domains/SimpleDomainChecker.tsx index 71e8c32dbc..0d22776074 100644 --- a/src/components/Domains/SimpleDomainChecker.tsx +++ b/src/components/Domains/SimpleDomainChecker.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { string_hostname } from '../../utils/typeAliases'; -import { DomainStatusText } from './DomainStatusText/DomainStatusText'; +import { DomainStatusChecker } from './DomainStatusChecker/DomainStatusChecker'; /** * Renders a simple domain checker with a single input and single output @@ -15,7 +15,14 @@ export function SimpleDomainChecker() { onChange={(event) => setDomain(event.target.value)} placeholder="example.com" /> - +
); } diff --git a/src/components/Domains/TODO.txt b/src/components/Domains/TODO.txt new file mode 100644 index 0000000000..a75ae90c12 --- /dev/null +++ b/src/components/Domains/TODO.txt @@ -0,0 +1 @@ +TODO: !! Break into more folders + utils to utils \ No newline at end of file diff --git a/src/components/Domains/AdvancedDomainsChecker.module.css b/src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.module.css similarity index 96% rename from src/components/Domains/AdvancedDomainsChecker.module.css rename to src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.module.css index 6ec95b5237..5bb7a03f1e 100644 --- a/src/components/Domains/AdvancedDomainsChecker.module.css +++ b/src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.module.css @@ -1,4 +1,4 @@ -.AdvancedDomainsChecker { +.DomainsCombinationsChecker { /*/ outline: 1px dotted rgb(123, 255, 0); /**/ diff --git a/src/components/Domains/AdvancedDomainsChecker.tsx b/src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.tsx similarity index 66% rename from src/components/Domains/AdvancedDomainsChecker.tsx rename to src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.tsx index 27d3b1a2b2..f8dc456f59 100644 --- a/src/components/Domains/AdvancedDomainsChecker.tsx +++ b/src/components/DomainsCombinationsChecker/DomainsCombinationsChecker.tsx @@ -1,17 +1,17 @@ import { useState } from 'react'; import spaceTrim from 'spacetrim'; -import { string_domain, string_tdl } from '../../utils/typeAliases'; -import styles from './AdvancedDomainsChecker.module.css'; -import { DomainsStatusList } from './DomainsStatusList/DomainsStatusList'; -import { createAllPermutationsOf } from './utils/createAllPermutationsOf'; -import { createAllSubsetsOf } from './utils/createAllSubsetsOf'; +import type { string_domain, string_domain_tdl } from '../../utils/typeAliases'; +import { DomainStatusChecker } from '../Domains/DomainStatusChecker/DomainStatusChecker'; +import { createAllPermutationsOf } from '../Domains/utils/createAllPermutationsOf'; +import { createAllSubsetsOf } from '../Domains/utils/createAllSubsetsOf'; +import styles from './DomainsCombinationsChecker.module.css'; /** * Renders a domain checker with advanced options and patterns */ -export function AdvancedDomainsChecker() { +export function DomainsCombinationsChecker() { const [names, setNames] = useState>(['web', 'gpt']); - const [tdls, setTdls] = useState>(['com', /*'org', 'io', 'net',*/ 'cz']); + const [tdls, setTdls] = useState>(['com', /*'org', 'io', 'net',*/ 'cz']); const namePartsCombinations = createAllSubsetsOf(...names); const namePartsPermutations = namePartsCombinations.flatMap((subset) => createAllPermutationsOf(...subset)); @@ -26,7 +26,7 @@ export function AdvancedDomainsChecker() { const sortedDomains = uniqueDomains.sort((a, b) => a.length - b.length); return ( -
+