diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7a537b49c..e59b2da94 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -15,6 +15,6 @@ jobs: - name: โคต๏ธ Check out code from GitHub uses: actions/checkout@v2 - name: ๐Ÿ— Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 - name: ๐Ÿš€ Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/package-lock.json b/package-lock.json index 0d99bade4..6443f0a18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,6 @@ "mustache": "^4.2.0", "nanoid": "^4.0.0", "next": "12.3.1", - "next-connect": "^0.13.0", "nodemailer": "^6.8.0", "path": "^0.12.7", "polished": "^4.2.2", @@ -124,7 +123,7 @@ "rollup-plugin-svg-import": "^1.6.0", "standard-version": "^9.5.0", "tsup": "^6.2.2", - "typescript": "^4.7.4" + "typescript": "4.9" }, "engines": { "node": ">=16" @@ -3034,20 +3033,6 @@ "typescript": ">=3" } }, - "node_modules/@commitlint/load/node_modules/typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/@commitlint/message": { "version": "17.2.0", "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.2.0.tgz", @@ -8456,23 +8441,6 @@ "@babel/types": "^7.3.0" } }, - "node_modules/@types/body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", - "dependencies": { - "@types/connect": "*", - "@types/node": "*" - } - }, - "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", @@ -8511,27 +8479,6 @@ "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "dev": true }, - "node_modules/@types/express": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz", - "integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==", - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.31", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, - "node_modules/@types/express-serve-static-core": { - "version": "4.17.31", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", - "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*" - } - }, "node_modules/@types/formidable": { "version": "3.4.5", "resolved": "https://registry.npmjs.org/@types/formidable/-/formidable-3.4.5.tgz", @@ -8811,11 +8758,6 @@ "resolved": "https://registry.npmjs.org/@types/microseconds/-/microseconds-0.2.0.tgz", "integrity": "sha512-+UyZ10BHttSgwkFOxXiuGn9qJ0CMzM1sLWFPIjA21ddgF9nh21ZZ771OtmnTqOXn5BqtcrWwvDv88hoyIe/FMw==" }, - "node_modules/@types/mime": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", - "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" - }, "node_modules/@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -8967,11 +8909,6 @@ "ts-toolbelt": "^6.15.1" } }, - "node_modules/@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" - }, "node_modules/@types/react": { "version": "18.0.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.15.tgz", @@ -9026,15 +8963,6 @@ "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, - "node_modules/@types/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", - "dependencies": { - "@types/mime": "*", - "@types/node": "*" - } - }, "node_modules/@types/set-cookie-parser": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@types/set-cookie-parser/-/set-cookie-parser-2.4.2.tgz", @@ -10023,11 +9951,6 @@ "integrity": "sha512-jlpIfsOoNoafl92Sz//64uQHGSyMrD2vYG5d8o2a4qGvyNCvXur7bzIsWtAC/6flI2RYAp3kv8rsfBtaLm7w0g==", "dev": true }, - "node_modules/append-field": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", - "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" - }, "node_modules/aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", @@ -11345,6 +11268,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, "license": "MIT" }, "node_modules/buffer-writer": { @@ -11410,17 +11334,6 @@ "esbuild": ">=0.13" } }, - "node_modules/busboy": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", - "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", - "dependencies": { - "streamsearch": "^1.1.0" - }, - "engines": { - "node": ">=10.16.0" - } - }, "node_modules/bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -13094,6 +13007,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, "license": "MIT" }, "node_modules/cosmiconfig": { @@ -19984,6 +19898,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, "license": "MIT" }, "node_modules/isexe": { @@ -22078,6 +21993,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -23151,14 +23067,6 @@ } } }, - "node_modules/next-connect": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/next-connect/-/next-connect-0.13.0.tgz", - "integrity": "sha512-f2G4edY01XomjCECSrgOpb/zzQinJO6Whd8Zds0+rLUYhj5cLwkh6FVvZsQCSSbxSc4k9nCwNuk5NLIhvO1gUA==", - "dependencies": { - "trouter": "^3.2.0" - } - }, "node_modules/next-router-mock": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/next-router-mock/-/next-router-mock-0.7.4.tgz", @@ -25812,6 +25720,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, "license": "MIT" }, "node_modules/promise": { @@ -26968,14 +26877,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexparam": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-1.3.0.tgz", - "integrity": "sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g==", - "engines": { - "node": ">=6" - } - }, "node_modules/regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -29527,14 +29428,6 @@ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", "dev": true }, - "node_modules/streamsearch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", - "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/strict-event-emitter": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.2.4.tgz", @@ -30695,17 +30588,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/trouter": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/trouter/-/trouter-3.2.0.tgz", - "integrity": "sha512-rLLXbhTObLy2MBVjLC+jTnoIKw99n0GuJs9ov10J870vDw5qhTurPzsDrudNtBf5w/CZ9ctZy2p2IMmhGcel2w==", - "dependencies": { - "regexparam": "^1.3.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/ts-dedent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", @@ -31057,6 +30939,7 @@ "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, "license": "MIT", "dependencies": { "media-typer": "0.3.0", @@ -31083,6 +30966,7 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true, "license": "MIT" }, "node_modules/typedarray-to-buffer": { @@ -31095,11 +30979,10 @@ } }, "node_modules/typescript": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, - "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -35180,12 +35063,6 @@ "integrity": "sha512-NkANeMnaHrlaSSlpKGyvn2R4rqUDeE/9E5YHx+b4nwo0R8dZyAqcih8/gxpCZvqWP9Vf6xuLpMSzSgdVEIM78g==", "dev": true, "requires": {} - }, - "typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", - "dev": true } } }, @@ -39045,23 +38922,6 @@ "@babel/types": "^7.3.0" } }, - "@types/body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", - "requires": { - "@types/connect": "*", - "@types/node": "*" - } - }, - "@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "requires": { - "@types/node": "*" - } - }, "@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", @@ -39096,27 +38956,6 @@ "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "dev": true }, - "@types/express": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz", - "integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==", - "requires": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.31", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, - "@types/express-serve-static-core": { - "version": "4.17.31", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", - "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", - "requires": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*" - } - }, "@types/formidable": { "version": "3.4.5", "resolved": "https://registry.npmjs.org/@types/formidable/-/formidable-3.4.5.tgz", @@ -39353,11 +39192,6 @@ "resolved": "https://registry.npmjs.org/@types/microseconds/-/microseconds-0.2.0.tgz", "integrity": "sha512-+UyZ10BHttSgwkFOxXiuGn9qJ0CMzM1sLWFPIjA21ddgF9nh21ZZ771OtmnTqOXn5BqtcrWwvDv88hoyIe/FMw==" }, - "@types/mime": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", - "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" - }, "@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -39496,11 +39330,6 @@ "ts-toolbelt": "^6.15.1" } }, - "@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" - }, "@types/react": { "version": "18.0.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.15.tgz", @@ -39550,15 +39379,6 @@ "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, - "@types/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", - "requires": { - "@types/mime": "*", - "@types/node": "*" - } - }, "@types/set-cookie-parser": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@types/set-cookie-parser/-/set-cookie-parser-2.4.2.tgz", @@ -40322,11 +40142,6 @@ "integrity": "sha512-jlpIfsOoNoafl92Sz//64uQHGSyMrD2vYG5d8o2a4qGvyNCvXur7bzIsWtAC/6flI2RYAp3kv8rsfBtaLm7w0g==", "dev": true }, - "append-field": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", - "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" - }, "aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", @@ -41311,7 +41126,8 @@ "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true }, "buffer-writer": { "version": "2.0.0", @@ -41359,14 +41175,6 @@ "load-tsconfig": "^0.2.0" } }, - "busboy": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", - "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", - "requires": { - "streamsearch": "^1.1.0" - } - }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -42616,7 +42424,8 @@ "core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true }, "cosmiconfig": { "version": "7.0.1", @@ -47726,7 +47535,8 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true }, "isexe": { "version": "2.0.0", @@ -49258,7 +49068,8 @@ "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true }, "memfs": { "version": "3.5.3", @@ -50087,14 +49898,6 @@ } } }, - "next-connect": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/next-connect/-/next-connect-0.13.0.tgz", - "integrity": "sha512-f2G4edY01XomjCECSrgOpb/zzQinJO6Whd8Zds0+rLUYhj5cLwkh6FVvZsQCSSbxSc4k9nCwNuk5NLIhvO1gUA==", - "requires": { - "trouter": "^3.2.0" - } - }, "next-router-mock": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/next-router-mock/-/next-router-mock-0.7.4.tgz", @@ -51951,7 +51754,8 @@ "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "promise": { "version": "7.3.1", @@ -52808,11 +52612,6 @@ "functions-have-names": "^1.2.2" } }, - "regexparam": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-1.3.0.tgz", - "integrity": "sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g==" - }, "regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -54780,11 +54579,6 @@ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", "dev": true }, - "streamsearch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", - "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" - }, "strict-event-emitter": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.2.4.tgz", @@ -55614,14 +55408,6 @@ "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", "dev": true }, - "trouter": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/trouter/-/trouter-3.2.0.tgz", - "integrity": "sha512-rLLXbhTObLy2MBVjLC+jTnoIKw99n0GuJs9ov10J870vDw5qhTurPzsDrudNtBf5w/CZ9ctZy2p2IMmhGcel2w==", - "requires": { - "regexparam": "^1.3.0" - } - }, "ts-dedent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", @@ -55851,6 +55637,7 @@ "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -55869,7 +55656,8 @@ "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true }, "typedarray-to-buffer": { "version": "3.1.5", @@ -55881,9 +55669,9 @@ } }, "typescript": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true }, "ua-parser-js": { diff --git a/package.json b/package.json index 88fbfc8f9..ec6a1886e 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "rollup-plugin-svg-import": "^1.6.0", "standard-version": "^9.5.0", "tsup": "^6.2.2", - "typescript": "^4.7.4" + "typescript": "^4.9.5" }, "engines": { "node": ">=16" diff --git a/src/__tests__/admin/settings/system.spec.tsx b/src/__tests__/admin/settings/system.spec.tsx index 1d0b483ef..373597742 100644 --- a/src/__tests__/admin/settings/system.spec.tsx +++ b/src/__tests__/admin/settings/system.spec.tsx @@ -22,9 +22,9 @@ describe("pages/admin/settings/system", () => { ); - await waitFor(() => { + await waitFor(async () => { expect( - screen.getByLabelText("Token Validity Duration In Days") + await screen.findByLabelText("Token Validity Duration In Days") ).toHaveValue(5); }); }); diff --git a/src/backend/configuration/configuration.service.ts b/src/backend/configuration/configuration.service.ts index 4e5b4a3b1..3969e113d 100644 --- a/src/backend/configuration/configuration.service.ts +++ b/src/backend/configuration/configuration.service.ts @@ -1,5 +1,6 @@ import { IApplicationService } from "backend/types"; import { progammingError } from "backend/lib/errors"; +import { AppConfigurationValueType } from "shared/configurations/constants"; import { createConfigDomainPersistenceService, AbstractConfigDataPersistenceService, @@ -20,16 +21,6 @@ export class ConfigurationApiService implements IApplicationService { await this._appConfigPersistenceService.setup(); } - private checkConfigKeyEntityRequirement( - key: AppConfigurationKeys, - entity?: string - ) { - progammingError( - `Configuration '${key}' requires an entity to be passed in`, - APP_CONFIGURATION_CONFIG[key].requireEntity && !entity - ); - } - async showMultipleConfigForEntities( key: AppConfigurationKeys, entities: string[] @@ -55,7 +46,10 @@ export class ConfigurationApiService implements IApplicationService { ); } - async show(key: AppConfigurationKeys, entity?: string): Promise { + async show( + key: T, + entity?: string + ): Promise> { this.checkConfigKeyEntityRequirement(key, entity); const value = await this._appConfigPersistenceService.getItem( @@ -72,7 +66,7 @@ export class ConfigurationApiService implements IApplicationService { async getSystemSettings( key: T ): Promise { - const systemSettings = await this.show("system_settings"); + const systemSettings = await this.show("system_settings"); return { ...DEFAULT_SYSTEM_SETTINGS, ...systemSettings }[key]; } @@ -88,6 +82,19 @@ export class ConfigurationApiService implements IApplicationService { value ); } + + private checkConfigKeyEntityRequirement( + key: AppConfigurationKeys, + entity?: string + ) { + const config = APP_CONFIGURATION_CONFIG[key]; + if ("requireEntity" in config) { + progammingError( + `Configuration '${key}' requires an entity to be passed in`, + config.requireEntity && !entity + ); + } + } } const appConfigPersistenceService = diff --git a/src/backend/data/data.service.ts b/src/backend/data/data.service.ts index f48067fb3..444909a12 100644 --- a/src/backend/data/data.service.ts +++ b/src/backend/data/data.service.ts @@ -9,7 +9,6 @@ import { ActionsApiService, } from "backend/actions/actions.service"; import { BaseAction } from "shared/types/actions"; -import { IFieldValidationItem } from "shared/validations/types"; import { IEntityField } from "shared/types/db"; import { IAccountProfile } from "shared/types/user"; import { noop } from "shared/lib/noop"; @@ -40,7 +39,7 @@ export class DataApiService implements IDataApiService { ) {} async bootstrap() { - this.getDataAccessInstance().bootstrap(); + await this.getDataAccessInstance().bootstrap(); } private getDataAccessInstance() { @@ -132,9 +131,7 @@ export class DataApiService implements IDataApiService { const [allowedFields, primaryField, entityValidations] = await Promise.all([ this._entitiesApiService.getAllowedCrudsFieldsToShow(entity, "create"), this._entitiesApiService.getEntityPrimaryField(entity), - this._configurationApiService.show< - Record - >("entity_validations", entity), + this._configurationApiService.show("entity_validations", entity), ]); noop(entityValidations); @@ -235,9 +232,7 @@ export class DataApiService implements IDataApiService { const [allowedFields, primaryField, entityValidations] = await Promise.all([ this._entitiesApiService.getAllowedCrudsFieldsToShow(entity, "update"), this._entitiesApiService.getEntityPrimaryField(entity), - this._configurationApiService.show< - Record - >("entity_validations", entity), + this._configurationApiService.show("entity_validations", entity), ]); // validate only the fields presents in 'data' @@ -314,19 +309,16 @@ export class DataApiService implements IDataApiService { format: string; fields: string[]; }> { - const relationshipSettings = await this._configurationApiService.show<{ - format: string; - fields: string[]; - }>("entity_relation_template", entity); + const relationshipSettings = await this._configurationApiService.show( + "entity_relation_template", + entity + ); if (relationshipSettings.fields.length > 0) { return relationshipSettings; } const [hiddenColumns, primaryField, entityFields] = await Promise.all([ - this._configurationApiService.show( - "hidden_entity_table_columns", - entity - ), + this._configurationApiService.show("hidden_entity_table_columns", entity), this._entitiesApiService.getEntityPrimaryField(entity), this._entitiesApiService.getEntityFields(entity), ]); diff --git a/src/backend/entities/entities.controller.ts b/src/backend/entities/entities.controller.ts index 6c5ffa97a..3f682b52d 100644 --- a/src/backend/entities/entities.controller.ts +++ b/src/backend/entities/entities.controller.ts @@ -23,7 +23,7 @@ export class EntitiesApiController { async listAllEntityRelations(entity: string): Promise { const [entityRelations, disabledEntities] = await Promise.all([ this._entitiesApiService.getEntityRelations(entity), - this._configurationApiService.show("disabled_entities"), + this._configurationApiService.show("disabled_entities"), ]); const allowedEntityRelation = entityRelations.filter( diff --git a/src/backend/entities/entities.service.ts b/src/backend/entities/entities.service.ts index 3285419cf..224e45f01 100644 --- a/src/backend/entities/entities.service.ts +++ b/src/backend/entities/entities.service.ts @@ -35,7 +35,7 @@ export class EntitiesApiService implements IApplicationService { async getActiveEntities(): Promise { const [hiddenEntities, entities] = await Promise.all([ - this._configurationApiService.show("disabled_entities"), + this._configurationApiService.show("disabled_entities"), this.getAllEntities(), ]); return entities.filter(({ value }) => !hiddenEntities.includes(value)); @@ -48,10 +48,7 @@ export class EntitiesApiService implements IApplicationService { async getOrderedEntityFields(entity: string) { const [entityFields, entityFieldsOrder] = await Promise.all([ this.getEntityFields(entity), - this._configurationApiService.show( - "entity_fields_orders", - entity - ), + this._configurationApiService.show("entity_fields_orders", entity), ]); sortByList( @@ -93,10 +90,7 @@ export class EntitiesApiService implements IApplicationService { crudKey: DataCrudKeys ): Promise { const [configHiddenFields, entityFields] = await Promise.all([ - this._configurationApiService.show( - CRUD_KEY_CONFIG[crudKey], - entity - ), + this._configurationApiService.show(CRUD_KEY_CONFIG[crudKey], entity), this.getEntityFields(entity), ]); @@ -127,7 +121,7 @@ export class EntitiesApiService implements IApplicationService { async isEntityDisabled(entity: string): Promise { return ( - await this._configurationApiService.show("disabled_entities") + await this._configurationApiService.show("disabled_entities") ).includes(entity); } @@ -150,19 +144,10 @@ export class EntitiesApiService implements IApplicationService { hiddenEntity, ] = await Promise.all([ this.getEntityRelations(entity), - this._configurationApiService.show("disabled_entities"), - this._configurationApiService.show>( - "entity_relations_labels", - entity - ), - this._configurationApiService.show( - "entity_relations_order", - entity - ), - this._configurationApiService.show( - "hidden_entity_relations", - entity - ), + this._configurationApiService.show("disabled_entities"), + this._configurationApiService.show("entity_relations_labels", entity), + this._configurationApiService.show("entity_relations_order", entity), + this._configurationApiService.show("hidden_entity_relations", entity), ]); const allowedEntityRelation = diff --git a/src/backend/lib/request/validations/implementations/crud-enabled.ts b/src/backend/lib/request/validations/implementations/crud-enabled.ts index 18149b446..f56924848 100644 --- a/src/backend/lib/request/validations/implementations/crud-enabled.ts +++ b/src/backend/lib/request/validations/implementations/crud-enabled.ts @@ -69,12 +69,9 @@ export const crudEnabledValidationImpl: ValidationImplType = async ( if ( EntityCrudCheck[actionType].entityCrudField && - !( - await configurationApiService.show( - "entity_crud_settings", - entity - ) - )[actionType] + !(await configurationApiService.show("entity_crud_settings", entity))[ + actionType + ] ) { throw new ForbiddenError( `Action '${actionType}' has been disabled for '${entity}'` diff --git a/src/backend/menu/menu.service.ts b/src/backend/menu/menu.service.ts index 686f4e49e..8f29aa3df 100644 --- a/src/backend/menu/menu.service.ts +++ b/src/backend/menu/menu.service.ts @@ -139,8 +139,8 @@ export class NavigationMenuApiService private async getUserEntities(): Promise { const [hiddenMenuEntities, entitiesOrder, activeEntities] = await Promise.all([ - this._configurationApiService.show("disabled_menu_entities"), - this._configurationApiService.show("menu_entities_order"), + this._configurationApiService.show("disabled_menu_entities"), + this._configurationApiService.show("menu_entities_order"), this._entitiesApiService.getActiveEntities(), ]); diff --git a/src/backend/uploads/parse.ts b/src/backend/uploads/parse.ts index 043f31226..736648cc2 100644 --- a/src/backend/uploads/parse.ts +++ b/src/backend/uploads/parse.ts @@ -7,15 +7,13 @@ import { NextApiRequest } from "next"; import { nanoid } from "nanoid"; import { compileTemplateString } from "shared/lib/strings/templates"; import { configurationApiService } from "backend/configuration/configuration.service"; -import { IFileUploadSettings } from "shared/types/file"; export async function parseForm( req: NextApiRequest ): Promise<{ fields: formidable.Fields; files: formidable.Files }> { - const fileUploadSettings = - await configurationApiService.show( - "file_upload_settings" - ); + const fileUploadSettings = await configurationApiService.show( + "file_upload_settings" + ); const UPLOAD_CONFIG = { entity: sluggify("posts"), maxFileSize: 1024 * 1024 * fileUploadSettings.defaultMaxFileSizeInMB, diff --git a/src/frontend/_layouts/app/LayoutImpl/SideBar.tsx b/src/frontend/_layouts/app/LayoutImpl/SideBar.tsx index e292f1d52..eceb25363 100644 --- a/src/frontend/_layouts/app/LayoutImpl/SideBar.tsx +++ b/src/frontend/_layouts/app/LayoutImpl/SideBar.tsx @@ -1,5 +1,4 @@ import { ViewStateMachine } from "frontend/components/ViewStateMachine"; -import { useSiteConfig } from "frontend/hooks/app/site.config"; import Link from "next/link"; import React from "react"; import { ChevronRight } from "react-feather"; @@ -12,6 +11,7 @@ import { useStorageApi } from "frontend/lib/data/useApi"; import { INavigationMenuItem } from "shared/types/menu"; import { useSessionStorage } from "react-use"; import { PlainButton } from "frontend/design-system/components/Button/TextButton"; +import { useAppConfiguration } from "frontend/hooks/configuration/configuration.store"; import { NAVIGATION_MENU_ENDPOINT, SIDE_BAR_WIDTH_VARIATIONS, @@ -95,7 +95,7 @@ export const useNavigationMenuItems = () => { }; export function SideBar({ isFullWidth, setIsFullWidth }: IProps) { - const siteConfig = useSiteConfig(); + const siteConfig = useAppConfiguration("site_settings"); const navigationMenuItems = useNavigationMenuItems(); const getThemeColorShade = useThemeColorShade(); @@ -122,9 +122,9 @@ export function SideBar({ isFullWidth, setIsFullWidth }: IProps) { > {isFullWidth ? ( - + ) : ( - + )} diff --git a/src/frontend/_layouts/app/_MainContent.tsx b/src/frontend/_layouts/app/_MainContent.tsx index 84e7a03e1..8440486b4 100644 --- a/src/frontend/_layouts/app/_MainContent.tsx +++ b/src/frontend/_layouts/app/_MainContent.tsx @@ -12,7 +12,7 @@ import { Stack } from "frontend/design-system/primitives/Stack"; import { Breadcrumbs } from "frontend/design-system/components/Breadcrumbs"; import { Typo } from "frontend/design-system/primitives/Typo"; import { Spacer } from "frontend/design-system/primitives/Spacer"; -import { useSiteConfig } from "frontend/hooks/app/site.config"; +import { useAppConfiguration } from "frontend/hooks/configuration/configuration.store"; import { GoogleTagManager } from "../scripts/GoogleTagManager"; import { DEMO_LINKS } from "./constant"; @@ -27,7 +27,7 @@ export function MainContent({ actionItems = [], secondaryActionItems = [], }: IMainContentProps) { - const siteConfig = useSiteConfig(); + const siteConfig = useAppConfiguration("site_settings"); const { history, pushToStack, goToLinkIndex } = useNavigationStack(); const router = useRouter(); const [ @@ -63,7 +63,7 @@ export function MainContent({ <> - {pageTitle} - {siteConfig.name} + {pageTitle} - {siteConfig.data.name} diff --git a/src/frontend/_layouts/guest/index.tsx b/src/frontend/_layouts/guest/index.tsx index a7d056791..ba99a53cd 100644 --- a/src/frontend/_layouts/guest/index.tsx +++ b/src/frontend/_layouts/guest/index.tsx @@ -1,8 +1,8 @@ import React, { ReactNode } from "react"; import Head from "next/head"; -import { useSiteConfig } from "frontend/hooks/app/site.config"; import styled from "styled-components"; import { SHADOW_CSS, CardBody } from "frontend/design-system/components/Card"; +import { useAppConfiguration } from "frontend/hooks/configuration/configuration.store"; import { useAppTheme } from "../useAppTheme"; import { GoogleTagManager } from "../scripts/GoogleTagManager"; import { PortalProvider } from "../app/portal"; @@ -27,14 +27,14 @@ const Root = styled.div` `; export function AuthLayout({ children, title, subTitle }: IProps) { - const siteConfig = useSiteConfig(); + const siteConfig = useAppConfiguration("site_settings"); useAppTheme(); return ( - {title} - {siteConfig.name} + {title} - {siteConfig.data.name} diff --git a/src/frontend/_layouts/types.ts b/src/frontend/_layouts/types.ts deleted file mode 100644 index 7722a63e9..000000000 --- a/src/frontend/_layouts/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type IThemeSettings = { - primary: string; - primaryDark: string; -}; diff --git a/src/frontend/_layouts/useAppTheme.ts b/src/frontend/_layouts/useAppTheme.ts index 26a3c8276..4b2ba805d 100644 --- a/src/frontend/_layouts/useAppTheme.ts +++ b/src/frontend/_layouts/useAppTheme.ts @@ -5,7 +5,6 @@ import { useTheme } from "frontend/design-system/theme/useTheme"; import { useUserPreference } from "frontend/hooks/auth/preferences.store"; import { ColorSchemes } from "shared/types/ui"; import { processThemeColors } from "./portal"; -import { IThemeSettings } from "./types"; import { getThemePrimaryColor } from "./utils"; export const THEME_SETTINGS_CRUD_CONFIG = MAKE_CRUD_CONFIG({ @@ -15,7 +14,7 @@ export const THEME_SETTINGS_CRUD_CONFIG = MAKE_CRUD_CONFIG({ }); export const useUserThemePreference = () => { - const themeColor = useAppConfiguration("theme_color"); + const themeColor = useAppConfiguration("theme_color"); const userPreferences = useUserPreference("theme"); const theme: ColorSchemes | IColorMode = userPreferences.data; diff --git a/src/frontend/_layouts/utils.ts b/src/frontend/_layouts/utils.ts index c983292ea..df09360b0 100644 --- a/src/frontend/_layouts/utils.ts +++ b/src/frontend/_layouts/utils.ts @@ -1,6 +1,5 @@ import { DataStateKeys } from "frontend/lib/data/types"; -import { ColorSchemes } from "shared/types/ui"; -import { IThemeSettings } from "./types"; +import { ColorSchemes, IThemeSettings } from "shared/types/ui"; export const getThemePrimaryColor = ( theme: ColorSchemes, diff --git a/src/frontend/components/SchemaForm/index.tsx b/src/frontend/components/SchemaForm/index.tsx index 1f25aa28c..17cd21412 100644 --- a/src/frontend/components/SchemaForm/index.tsx +++ b/src/frontend/components/SchemaForm/index.tsx @@ -15,7 +15,7 @@ import { useSchemaFormScriptContext } from "./useSchemaFormScriptContext"; interface IProps { fields: IAppliedSchemaFormConfig; - onSubmit: (data: T) => Promise; + onSubmit: (data: T) => Promise; initialValues?: Partial; buttonText?: (submitting: boolean) => string; action?: string; diff --git a/src/frontend/design-system/components/SortList/index.tsx b/src/frontend/design-system/components/SortList/index.tsx index 644be29b1..13cc40d9e 100644 --- a/src/frontend/design-system/components/SortList/index.tsx +++ b/src/frontend/design-system/components/SortList/index.tsx @@ -33,7 +33,7 @@ function arrayMoveImmutable(array: T[], fromIndex: number, toIndex: number) { export interface IProps { data: DataStateKeys; - onSave: (data: string[]) => Promise; + onSave: (data: string[]) => Promise; } const THRESHOLD_FOR_LONG_ITEMS_TO_SHOW_SAVE_CHANGES_AT_TOP = 10; diff --git a/src/frontend/hooks/app/site.config.ts b/src/frontend/hooks/app/site.config.ts deleted file mode 100644 index 0b686e1da..000000000 --- a/src/frontend/hooks/app/site.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ISiteSettings } from "shared/types/config"; -import { useAppConfiguration } from "../configuration/configuration.store"; - -const DEFAULT_SITE_CONFIG: ISiteSettings = { - name: "DashPress", - homeLink: "/", - logo: "/assets/images/logo.png", - fullLogo: "/assets/images/full-logo.png", -}; - -export const useSiteConfig = () => { - const { data = DEFAULT_SITE_CONFIG } = - useAppConfiguration("site_settings"); - return data; -}; diff --git a/src/frontend/hooks/configuration/configuration.store.ts b/src/frontend/hooks/configuration/configuration.store.ts index b01dbde3b..c07837a90 100644 --- a/src/frontend/hooks/configuration/configuration.store.ts +++ b/src/frontend/hooks/configuration/configuration.store.ts @@ -7,6 +7,7 @@ import { makeActionRequest } from "frontend/lib/data/makeRequest"; import { useStorageApi } from "frontend/lib/data/useApi"; import { useWaitForResponseMutationOptions } from "frontend/lib/data/useMutate/useWaitForResponseMutationOptions"; import { AppStorage } from "frontend/lib/storage/app"; +import { AppConfigurationValueType } from "shared/configurations/constants"; import { isRouterParamEnabled } from ".."; import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "./configuration.constant"; @@ -23,44 +24,52 @@ export const configurationApiPath = ( return `/api/config/${key}`; } - if (APP_CONFIGURATION_CONFIG[key].guest) { + const config = APP_CONFIGURATION_CONFIG[key]; + + if ("guest" in config && config.guest) { return `/api/config/${key}/__guest`; } return `/api/config/${key}`; }; -export function useAppConfiguration(key: AppConfigurationKeys) { - return useStorageApi(configurationApiPath(key), { - errorMessage: MAKE_APP_CONFIGURATION_CRUD_CONFIG(key).TEXT_LANG.NOT_FOUND, - defaultData: APP_CONFIGURATION_CONFIG[key].defaultValue as T, - }); +export function useAppConfiguration(key: T) { + return useStorageApi>( + configurationApiPath(key), + { + errorMessage: MAKE_APP_CONFIGURATION_CRUD_CONFIG(key).TEXT_LANG.NOT_FOUND, + defaultData: APP_CONFIGURATION_CONFIG[key].defaultValue, + } + ); } -export function useEntityConfiguration( - key: AppConfigurationKeys, +export function useEntityConfiguration( + key: T, entity: string, - forceDefaultValue?: T + forceDefaultValue?: AppConfigurationValueType ) { - return useStorageApi(configurationApiPath(key, entity), { - enabled: isRouterParamEnabled(entity), - errorMessage: MAKE_APP_CONFIGURATION_CRUD_CONFIG(key).TEXT_LANG.NOT_FOUND, - defaultData: - forceDefaultValue || (APP_CONFIGURATION_CONFIG[key].defaultValue as T), - }); + return useStorageApi>( + configurationApiPath(key, entity), + { + enabled: isRouterParamEnabled(entity), + errorMessage: MAKE_APP_CONFIGURATION_CRUD_CONFIG(key).TEXT_LANG.NOT_FOUND, + defaultData: + forceDefaultValue || (APP_CONFIGURATION_CONFIG[key].defaultValue as T), + } + ); } interface IUpsertConfigMutationOptions { otherEndpoints?: string[]; } -export function useUpsertConfigurationMutation( - key: AppConfigurationKeys, +export function useUpsertConfigurationMutation( + key: T, entity?: string, mutationOptions?: IUpsertConfigMutationOptions ) { const apiMutateOptions = useWaitForResponseMutationOptions< - Record | unknown[] + AppConfigurationValueType >({ endpoints: [ configurationApiPath(key, entity), @@ -72,7 +81,7 @@ export function useUpsertConfigurationMutation( successMessage: MAKE_APP_CONFIGURATION_CRUD_CONFIG(key).MUTATION_LANG.SAVED, }); - return useMutation(async (values: unknown) => { + return useMutation(async (values: AppConfigurationValueType) => { await makeActionRequest("PUT", configurationApiPath(key, entity, "PUT"), { data: values, }); diff --git a/src/frontend/hooks/entity/entity.config.ts b/src/frontend/hooks/entity/entity.config.ts index 3a20cf0cc..7fc733feb 100644 --- a/src/frontend/hooks/entity/entity.config.ts +++ b/src/frontend/hooks/entity/entity.config.ts @@ -13,8 +13,6 @@ import { MAKE_CRUD_CONFIG } from "frontend/lib/crud-config"; import { uniqBy } from "shared/lib/array/uniq-by"; import { userFriendlyCase } from "shared/lib/strings/friendly-case"; import { FIELD_TYPES_CONFIG_MAP } from "shared/validations"; -import { IEntityCrudSettings } from "shared/configurations"; -import { ISingularPlural } from "shared/types/config"; import { useEntityFields } from "./entity.store"; import { getFieldTypeBoundedValidations, @@ -34,10 +32,7 @@ export function useEntityId() { export function useEntityDiction(paramEntity?: string) { const entity = useEntitySlug(paramEntity); - const entityDiction = useEntityConfiguration( - "entity_diction", - entity - ); + const entityDiction = useEntityConfiguration("entity_diction", entity); return { singular: entityDiction.data?.singular || userFriendlyCase(entity), plural: entityDiction.data?.plural || userFriendlyCase(entity), @@ -56,7 +51,7 @@ export function useEntityCrudConfig(paramEntity?: string) { export function useEntityFieldLabels(paramEntity?: string) { const entity = useEntitySlug(paramEntity); - const entityFieldLabelsMap = useEntityConfiguration>( + const entityFieldLabelsMap = useEntityConfiguration( "entity_columns_labels", entity ); @@ -78,9 +73,10 @@ export function useProcessedEntityFieldTypes( paramEntity?: string ): Record { const entity = useEntitySlug(paramEntity); - const entityFieldTypesMap = useEntityConfiguration< - Record - >("entity_columns_types", entity); + const entityFieldTypesMap = useEntityConfiguration( + "entity_columns_types", + entity + ); const entityFields = useEntityFields(entity); @@ -97,9 +93,10 @@ export function useProcessedEntityFieldTypes( export function useEntityFieldValidations(paramEntity?: string) { const entity = useEntitySlug(paramEntity); - const entityValidationsMap = useEntityConfiguration< - Record - >("entity_validations", entity); + const entityValidationsMap = useEntityConfiguration( + "entity_validations", + entity + ); const processedEntityFieldTypes = useProcessedEntityFieldTypes(entity); const entityFields = useEntityFields(entity); @@ -141,9 +138,7 @@ export function useEntityFieldSelections( ): Record { const entity = useEntitySlug(paramEntity); - const entitySelections = useEntityConfiguration< - Record - >("entity_selections", entity); + const entitySelections = useEntityConfiguration("entity_selections", entity); const processedEntityFieldTypes = useProcessedEntityFieldTypes(entity); const entityFields = useEntityFields(entity); @@ -166,16 +161,12 @@ export function useEntityFieldSelections( export function useEntityCrudSettings(paramEntity?: string) { const entity = useEntitySlug(paramEntity); - return useEntityConfiguration( - "entity_crud_settings", - entity, - { - create: false, - details: false, - delete: false, - update: false, - } - ); + return useEntityConfiguration("entity_crud_settings", entity, { + create: false, + details: false, + delete: false, + update: false, + }); } export function useHiddenEntityColumns( @@ -183,7 +174,7 @@ export function useHiddenEntityColumns( overrideEntity?: string ): DataStateKeys { const entity = useEntitySlug(); - const entityConfig = useEntityConfiguration( + const entityConfig = useEntityConfiguration( CRUD_KEY_CONFIG[crudKey], overrideEntity || entity ); diff --git a/src/frontend/lib/form/types.ts b/src/frontend/lib/form/types.ts index 22a447db5..0194ec394 100644 --- a/src/frontend/lib/form/types.ts +++ b/src/frontend/lib/form/types.ts @@ -1,5 +1,5 @@ export interface IFormProps { - onSubmit: (arg0: T) => Promise; + onSubmit: (arg0: T) => Promise; initialValues?: Partial; } diff --git a/src/frontend/views/Dashboard/Widget/Update.tsx b/src/frontend/views/Dashboard/Widget/Update.tsx index 603cbdf8f..080de62f4 100644 --- a/src/frontend/views/Dashboard/Widget/Update.tsx +++ b/src/frontend/views/Dashboard/Widget/Update.tsx @@ -23,9 +23,7 @@ export function UpdateDashboardWidget() { return ( - await updateDashboardWidgetMutation.mutateAsync(data) - } + onSave={updateDashboardWidgetMutation.mutateAsync} /> ); } diff --git a/src/frontend/views/Dashboard/Widget/_manage/Form.tsx b/src/frontend/views/Dashboard/Widget/_manage/Form.tsx index 95da1e12b..2320e680f 100644 --- a/src/frontend/views/Dashboard/Widget/_manage/Form.tsx +++ b/src/frontend/views/Dashboard/Widget/_manage/Form.tsx @@ -1,6 +1,5 @@ import { useEntityConfiguration } from "frontend/hooks/configuration/configuration.store"; import { Field, Form } from "react-final-form"; -import { ITableTab } from "shared/types/data"; import { ISummaryWidgetConfig, IWidgetConfig } from "shared/types/dashboard"; import { ROYGBIV } from "shared/constants/colors"; import { IconInputField } from "frontend/components/IconInputField"; @@ -93,7 +92,7 @@ export function DashboardWidgetForm({ onSubmit={onSubmit} initialValues={initialValues} render={({ handleSubmit, form, pristine, values, submitting }) => { - const entityViews = useEntityConfiguration( + const entityViews = useEntityConfiguration( "entity_views", values.entity ); diff --git a/src/frontend/views/Dashboard/Widget/useWidgetNavigationLink.ts b/src/frontend/views/Dashboard/Widget/useWidgetNavigationLink.ts index 0e33d8749..8fdb7e6f4 100644 --- a/src/frontend/views/Dashboard/Widget/useWidgetNavigationLink.ts +++ b/src/frontend/views/Dashboard/Widget/useWidgetNavigationLink.ts @@ -2,11 +2,10 @@ import { SLUG_LOADING_VALUE } from "frontend/lib/routing/constants"; import { useEntityConfiguration } from "frontend/hooks/configuration/configuration.store"; import { NAVIGATION_LINKS } from "frontend/lib/routing/links"; import { useCanUserPerformCrudAction } from "frontend/views/data/useCanUserPerformCrudAction"; -import { ITableTab } from "shared/types/data"; export const useWidgetNavigationLink = (entity?: string, queryId?: string) => { const canUserPerformCrudAction = useCanUserPerformCrudAction(entity); - const entityViews = useEntityConfiguration( + const entityViews = useEntityConfiguration( "entity_views", queryId ? entity : SLUG_LOADING_VALUE ); diff --git a/src/frontend/views/data/Details/DetailsView.tsx b/src/frontend/views/data/Details/DetailsView.tsx index 35ee5ee14..fe9db4bd3 100644 --- a/src/frontend/views/data/Details/DetailsView.tsx +++ b/src/frontend/views/data/Details/DetailsView.tsx @@ -24,7 +24,6 @@ import styled from "styled-components"; import { filterOutHiddenScalarColumns } from "../utils"; import { useEntityViewStateMachine } from "../useEntityViewStateMachine"; import { viewSpecialDataTypes } from "../viewSpecialDataTypes"; -import { IEntityPresentationScript } from "../types"; import { evalutePresentationScript } from "../evaluatePresentationScript"; const ContentText = styled(Typo.SM)` @@ -46,15 +45,14 @@ export function EntityDetailsView({ const entityFields = useEntityFields(entity); const entityFieldTypes = useProcessedEntityFieldTypes(entity); const hiddenDetailsColumns = useHiddenEntityColumns("details", entity); - const defaultDateFormat = useAppConfiguration("default_date_format"); + const defaultDateFormat = useAppConfiguration("default_date_format"); const getEntityFieldLabels = useEntityFieldLabels(entity); const entityToOneReferenceFields = useEntityToOneReferenceFields(entity); const entityFieldSelections = useEntityFieldSelections(entity); - const entityPresentationScript = - useEntityConfiguration( - "entity_presentation_script", - entity - ); + const entityPresentationScript = useEntityConfiguration( + "entity_presentation_script", + entity + ); const error = dataDetails.error || diff --git a/src/frontend/views/data/Table/_WholeEntityTable/index.tsx b/src/frontend/views/data/Table/_WholeEntityTable/index.tsx index f5dc47238..070fef282 100644 --- a/src/frontend/views/data/Table/_WholeEntityTable/index.tsx +++ b/src/frontend/views/data/Table/_WholeEntityTable/index.tsx @@ -1,5 +1,5 @@ import { useEntitiesFilterCount } from "frontend/hooks/data/data.store"; -import { ITableTab, FieldQueryFilter } from "shared/types/data"; +import { FieldQueryFilter } from "shared/types/data"; import { useEntityConfiguration } from "frontend/hooks/configuration/configuration.store"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; import { useChangeRouterParam } from "frontend/lib/routing/useChangeRouterParam"; @@ -21,10 +21,7 @@ export function WholeEntityTable({ entity, persistFilters = [] }: IProps) { const tabFromUrl = useRouteParam("tab"); const changeTabParam = useChangeRouterParam("tab"); const portalTableTabs = usePortalTableTabs(entity); - const entityViews = useEntityConfiguration( - "entity_views", - entity - ); + const entityViews = useEntityConfiguration("entity_views", entity); const tableTabs = [...entityViews.data, ...portalTableTabs.data]; diff --git a/src/frontend/views/data/Table/useTableColumns.tsx b/src/frontend/views/data/Table/useTableColumns.tsx index 2c6f375cd..e6ea2bb7e 100644 --- a/src/frontend/views/data/Table/useTableColumns.tsx +++ b/src/frontend/views/data/Table/useTableColumns.tsx @@ -26,7 +26,6 @@ import { TableActions } from "./Actions"; import { viewSpecialDataTypes } from "../viewSpecialDataTypes"; import { usePortalTableColumns } from "./portal"; import { evalutePresentationScript } from "../evaluatePresentationScript"; -import { IEntityPresentationScript } from "../types"; import { useCanUserPerformCrudAction } from "../useCanUserPerformCrudAction"; export const ACTIONS_ACCESSOR = "__actions__"; @@ -88,12 +87,11 @@ export const useTableColumns = ( const entityFields = useEntityFields(entity); const entityToOneReferenceFields = useEntityToOneReferenceFields(entity); const hiddenTableColumns = useHiddenEntityColumns("table", entity); - const defaultDateFormat = useAppConfiguration("default_date_format"); - const entityPresentationScript = - useEntityConfiguration( - "entity_presentation_script", - entity - ); + const defaultDateFormat = useAppConfiguration("default_date_format"); + const entityPresentationScript = useEntityConfiguration( + "entity_presentation_script", + entity + ); const idField = useEntityIdField(entity); diff --git a/src/frontend/views/data/_BaseEntityForm.tsx b/src/frontend/views/data/_BaseEntityForm.tsx index 800fbf336..6e685cafd 100644 --- a/src/frontend/views/data/_BaseEntityForm.tsx +++ b/src/frontend/views/data/_BaseEntityForm.tsx @@ -15,7 +15,6 @@ import { useEntityFieldValidations, useEntityCrudConfig, } from "frontend/hooks/entity/entity.config"; -import { IFormExtension } from "frontend/components/SchemaForm/types"; import { useMemo } from "react"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; import { DataStateKeys, DataStates } from "frontend/lib/data/types"; @@ -49,11 +48,11 @@ export function BaseEntityForm({ const getEntityFieldLabels = useEntityFieldLabels(entity); const entityFieldTypes = useProcessedEntityFieldTypes(entity); const entityFieldSelections = useEntityFieldSelections(entity); - const entityFieldTypesMap = useEntityConfiguration>( + const entityFieldTypesMap = useEntityConfiguration( "entity_columns_types", entity ); - const entityFormExtension = useEntityConfiguration( + const entityFormExtension = useEntityConfiguration( "entity_form_extension", entity ); diff --git a/src/frontend/views/data/types.ts b/src/frontend/views/data/types.ts deleted file mode 100644 index 0232b9779..000000000 --- a/src/frontend/views/data/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type IEntityPresentationScript = { - script: string; -}; diff --git a/src/frontend/views/data/useEntityViewStateMachine.ts b/src/frontend/views/data/useEntityViewStateMachine.ts index fbb2994a2..014304945 100644 --- a/src/frontend/views/data/useEntityViewStateMachine.ts +++ b/src/frontend/views/data/useEntityViewStateMachine.ts @@ -15,7 +15,7 @@ export const useEntityViewStateMachine = ( | { type: DataStates.Loading } | { type: DataStates.Loaded } | { type: DataStates.Error; message: unknown } => { - const entitiesToHide = useAppConfiguration("disabled_entities"); + const entitiesToHide = useAppConfiguration("disabled_entities"); const entity = useEntitySlug(entityOverride); const canUserPerformCrudAction = useCanUserPerformCrudAction(entity); diff --git a/src/frontend/views/entity/Crud/SelectionTab.tsx b/src/frontend/views/entity/Crud/SelectionTab.tsx index c6174a341..ad1645029 100644 --- a/src/frontend/views/entity/Crud/SelectionTab.tsx +++ b/src/frontend/views/entity/Crud/SelectionTab.tsx @@ -13,7 +13,7 @@ interface IProps { label: string; columns?: { fields: IEntityField[]; - submit?: (columnsSelection: string[]) => Promise; + submit?: (columnsSelection: string[]) => Promise; hidden: string[]; getEntityFieldLabels?: (fieldName: string) => string; }; diff --git a/src/frontend/views/entity/Crud/index.tsx b/src/frontend/views/entity/Crud/index.tsx index e6ee45d9a..047d2bba2 100644 --- a/src/frontend/views/entity/Crud/index.tsx +++ b/src/frontend/views/entity/Crud/index.tsx @@ -41,19 +41,19 @@ function useEntityCrudView() { const getEntityFieldLabels = useEntityFieldLabels(); - const hiddenTableColumns = useEntityConfiguration( + const hiddenTableColumns = useEntityConfiguration( "hidden_entity_table_columns", entity ); - const hiddenCreateColumns = useEntityConfiguration( + const hiddenCreateColumns = useEntityConfiguration( "hidden_entity_create_columns", entity ); - const hiddenUpdateColumns = useEntityConfiguration( + const hiddenUpdateColumns = useEntityConfiguration( "hidden_entity_update_columns", entity ); - const hiddenDetailsColumns = useEntityConfiguration( + const hiddenDetailsColumns = useEntityConfiguration( "hidden_entity_details_columns", entity ); @@ -126,9 +126,7 @@ function useEntityCrudView() { } setEntityCrudSettingsState(newState); - upsertCrudSettingsMutation.mutateAsync( - newState as unknown as Record - ); + upsertCrudSettingsMutation.mutateAsync(newState); }; const error = entityFields.error || entityCrudSettings.error; @@ -141,9 +139,7 @@ function useEntityCrudView() { label={ENTITY_CRUD_SETTINGS_TAB_LABELS.TABLE} columns={{ fields: entityFields.data, - submit: async (data) => { - await upsertTableColumnsMutation.mutateAsync(data); - }, + submit: upsertTableColumnsMutation.mutateAsync, hidden: hiddenTableColumns.data, getEntityFieldLabels, }} @@ -163,9 +159,7 @@ function useEntityCrudView() { label={ENTITY_CRUD_SETTINGS_TAB_LABELS.DETAILS} columns={{ fields: entityFields.data, - submit: async (data) => { - await upsertDetailsColumnsMutation.mutateAsync(data); - }, + submit: upsertDetailsColumnsMutation.mutateAsync, hidden: hiddenDetailsColumns.data, getEntityFieldLabels, }} @@ -186,9 +180,7 @@ function useEntityCrudView() { label={ENTITY_CRUD_SETTINGS_TAB_LABELS.CREATE} columns={{ fields: entityFields.data, - submit: async (data) => { - await upsertCreateColumnsMutation.mutateAsync(data); - }, + submit: upsertCreateColumnsMutation.mutateAsync, hidden: hiddenCreateColumns.data, getEntityFieldLabels, }} @@ -209,9 +201,7 @@ function useEntityCrudView() { label={ENTITY_CRUD_SETTINGS_TAB_LABELS.UPDATE} columns={{ fields: entityFields.data, - submit: async (data) => { - await upsertUpdateColumnsMutation.mutateAsync(data); - }, + submit: upsertUpdateColumnsMutation.mutateAsync, hidden: hiddenUpdateColumns.data, getEntityFieldLabels, }} diff --git a/src/frontend/views/entity/Diction/index.tsx b/src/frontend/views/entity/Diction/index.tsx index f3012ba46..370dc6990 100644 --- a/src/frontend/views/entity/Diction/index.tsx +++ b/src/frontend/views/entity/Diction/index.tsx @@ -66,11 +66,7 @@ export function EntityDictionSettings() { } > { - await upsertConfigurationMutation.mutateAsync( - values as unknown as Record - ); - }} + onSubmit={upsertConfigurationMutation.mutateAsync} initialValues={entityDiction} /> diff --git a/src/frontend/views/entity/Fields/FieldsLabel.form.tsx b/src/frontend/views/entity/Fields/FieldsLabel.form.tsx index 861392a36..04b7ee551 100644 --- a/src/frontend/views/entity/Fields/FieldsLabel.form.tsx +++ b/src/frontend/views/entity/Fields/FieldsLabel.form.tsx @@ -14,9 +14,9 @@ import { FormButton } from "frontend/design-system/components/Button/FormButton" interface IProps { fields: string[]; - initialValues?: Record; + initialValues?: Record; crudConfig: ICrudConfig; - onSubmit: (data: Record) => void; + onSubmit: (data: Record) => void; } export const loadingFieldsLabelForm = ( diff --git a/src/frontend/views/entity/Fields/index.tsx b/src/frontend/views/entity/Fields/index.tsx index ed2f1b76a..439abfb62 100644 --- a/src/frontend/views/entity/Fields/index.tsx +++ b/src/frontend/views/entity/Fields/index.tsx @@ -48,7 +48,7 @@ export function EntityFieldsSettings() { const entity = useEntitySlug(); const entityFieldLists = useEntityFieldLists(entity); - const entityFieldLabelsMap = useEntityConfiguration>( + const entityFieldLabelsMap = useEntityConfiguration( "entity_columns_labels", entity ); @@ -57,18 +57,12 @@ export function EntityFieldsSettings() { const { isLoading: entityFieldTypesMapIsLoading, error: entityFieldTypesMapError, - } = useEntityConfiguration>( - "entity_columns_types", - entity - ); + } = useEntityConfiguration("entity_columns_types", entity); const { isLoading: entityValidationsMapIsLoading, error: entityValidationsMapError, - } = useEntityConfiguration>( - "entity_validations", - entity - ); + } = useEntityConfiguration("entity_validations", entity); const entityFieldTypes = useProcessedEntityFieldTypes(); const entityFieldValidations = useEntityFieldValidations(); @@ -150,11 +144,7 @@ export function EntityFieldsSettings() { crudConfig={MAKE_APP_CONFIGURATION_CRUD_CONFIG( "entity_columns_labels" )} - onSubmit={async (data) => { - await upsertEntityFieldsMapMutation.mutateAsync( - data as Record - ); - }} + onSubmit={upsertEntityFieldsMapMutation.mutateAsync} /> ), @@ -224,11 +214,7 @@ export function EntityFieldsSettings() { label: getEntityFieldLabels(name), })), }} - onSave={ - upsertEntityColumnsOrderMutation.mutateAsync as ( - data: string[] - ) => Promise - } + onSave={upsertEntityColumnsOrderMutation.mutateAsync} /> ), diff --git a/src/frontend/views/entity/Form/index.tsx b/src/frontend/views/entity/Form/index.tsx index 3519c28db..c2781a6c2 100644 --- a/src/frontend/views/entity/Form/index.tsx +++ b/src/frontend/views/entity/Form/index.tsx @@ -21,7 +21,7 @@ import { ScriptForm } from "./ScriptForm"; function useEntityFormView() { const entity = useEntitySlug(); - const entityFormExtensionSettings = useEntityConfiguration( + const entityFormExtensionSettings = useEntityConfiguration( "entity_form_extension", entity ); diff --git a/src/frontend/views/entity/Presentation/Form.tsx b/src/frontend/views/entity/Presentation/Form.tsx index 6c2a5f96e..6e14c1f0c 100644 --- a/src/frontend/views/entity/Presentation/Form.tsx +++ b/src/frontend/views/entity/Presentation/Form.tsx @@ -4,7 +4,10 @@ import { IFormProps } from "frontend/lib/form/types"; import { evalJavascriptString } from "frontend/lib/script-runner"; import { ToastService } from "frontend/lib/toast"; import { IPresentationScriptParams } from "frontend/views/data/evaluatePresentationScript"; -import { IEntityPresentationScript } from "frontend/views/data/types"; + +type IEntityPresentationScript = { + script: string; +}; export function PresentationScriptForm({ initialValues, diff --git a/src/frontend/views/entity/Presentation/index.tsx b/src/frontend/views/entity/Presentation/index.tsx index 76e369b6f..886707236 100644 --- a/src/frontend/views/entity/Presentation/index.tsx +++ b/src/frontend/views/entity/Presentation/index.tsx @@ -13,7 +13,6 @@ import { useUpsertConfigurationMutation, } from "frontend/hooks/configuration/configuration.store"; import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant"; -import { IEntityPresentationScript } from "frontend/views/data/types"; import { useState } from "react"; import { DOCUMENTATION_LABEL } from "frontend/docs"; import { PresentationScriptDocumentation } from "frontend/docs/scripts/presentations-scripts"; @@ -29,11 +28,10 @@ const DOCS_TITLE = "Presentation Script"; export function EntityPresentationScriptSettings() { const entity = useEntitySlug(); - const entityPresentationScript = - useEntityConfiguration( - "entity_presentation_script", - entity - ); + const entityPresentationScript = useEntityConfiguration( + "entity_presentation_script", + entity + ); const upsertConfigurationMutation = useUpsertConfigurationMutation( "entity_presentation_script", entity @@ -65,11 +63,7 @@ export function EntityPresentationScriptSettings() { loader={} > { - await upsertConfigurationMutation.mutateAsync( - values as unknown as Record - ); - }} + onSubmit={upsertConfigurationMutation.mutateAsync} initialValues={entityPresentationScript.data} /> diff --git a/src/frontend/views/entity/Relations/index.tsx b/src/frontend/views/entity/Relations/index.tsx index a84ba5dcf..a758efcf1 100644 --- a/src/frontend/views/entity/Relations/index.tsx +++ b/src/frontend/views/entity/Relations/index.tsx @@ -55,11 +55,12 @@ export function EntityRelationsSettings() { permission: USER_PERMISSIONS.CAN_CONFIGURE_APP, }); - const entityRelationTemplate = useEntityConfiguration<{ - format: string; - }>("entity_relation_template", entity); + const entityRelationTemplate = useEntityConfiguration( + "entity_relation_template", + entity + ); - const hiddenEntityRelations = useEntityConfiguration( + const hiddenEntityRelations = useEntityConfiguration( "hidden_entity_relations", entity ); @@ -69,9 +70,10 @@ export function EntityRelationsSettings() { "value" ); - const entityRelationsLabelsMap = useEntityConfiguration< - Record - >("entity_relations_labels", entity); + const entityRelationsLabelsMap = useEntityConfiguration( + "entity_relations_labels", + entity + ); const upsertEntityRelationTemplateMutation = useUpsertConfigurationMutation( "entity_relation_template", @@ -141,11 +143,7 @@ export function EntityRelationsSettings() { loader={} > { - await upsertEntityRelationTemplateMutation.mutateAsync( - values as unknown as Record - ); - }} + onSubmit={upsertEntityRelationTemplateMutation.mutateAsync} entityFields={entityFields.data.map(({ name }) => name)} initialValues={entityRelationTemplate.data} /> @@ -167,11 +165,7 @@ export function EntityRelationsSettings() { "entity_relations_labels" )} fields={referenceFields.data.map(({ table }) => table)} - onSubmit={async (data) => { - await upsertEntityRelationsLabelsMutation.mutateAsync( - data as Record - ); - }} + onSubmit={upsertEntityRelationsLabelsMutation.mutateAsync} /> ), @@ -195,9 +189,7 @@ export function EntityRelationsSettings() { "hidden_entity_relations" )} hiddenList={hiddenEntityRelations.data} - onSubmit={async (data) => { - await upsertHideEntityRelationMutation.mutateAsync(data); - }} + onSubmit={upsertHideEntityRelationMutation.mutateAsync} /> ), @@ -218,11 +210,7 @@ export function EntityRelationsSettings() { label: label || getEntitiesDictionPlurals(table), })), }} - onSave={ - upsertEntityRelationsOrderMutation.mutateAsync as ( - data: string[] - ) => Promise - } + onSave={upsertEntityRelationsOrderMutation.mutateAsync} /> ), diff --git a/src/frontend/views/entity/Views/index.tsx b/src/frontend/views/entity/Views/index.tsx index 68ca7024c..79a52da17 100644 --- a/src/frontend/views/entity/Views/index.tsx +++ b/src/frontend/views/entity/Views/index.tsx @@ -6,7 +6,6 @@ import { import { SLUG_LOADING_VALUE } from "frontend/lib/routing/constants"; import { useSetPageDetails } from "frontend/lib/routing/usePageDetails"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; -import { ITableTab } from "shared/types/data"; import { useEntitySlug } from "frontend/hooks/entity/entity.config"; import { useEntityConfiguration, @@ -35,10 +34,7 @@ export function EntityViewsSettings() { entity ); - const entityViews = useEntityConfiguration( - "entity_views", - entity - ); + const entityViews = useEntityConfiguration("entity_views", entity); const tableColumns = useTableColumns(entity); @@ -79,9 +75,7 @@ export function EntityViewsSettings() { {!isLoading && ( { - await upsertEntityViewsMutation.mutateAsync(data); - }} + onSubmit={upsertEntityViewsMutation.mutateAsync} tableColumns={tableColumns.data || []} /> )} diff --git a/src/frontend/views/integrations/storage/General.tsx b/src/frontend/views/integrations/storage/General.tsx index 244d9b25e..faaa6b5f0 100644 --- a/src/frontend/views/integrations/storage/General.tsx +++ b/src/frontend/views/integrations/storage/General.tsx @@ -12,9 +12,7 @@ import { import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant"; export function GeneralStorageSettings() { - const fileUploadSettings = useAppConfiguration( - "file_upload_settings" - ); + const fileUploadSettings = useAppConfiguration("file_upload_settings"); const upsertFileUploadSettingsMutation = useUpsertConfigurationMutation( "file_upload_settings" @@ -69,9 +67,7 @@ export function GeneralStorageSettings() { ], }, }} - onSubmit={async (data) => { - await upsertFileUploadSettingsMutation.mutateAsync(data); - }} + onSubmit={upsertFileUploadSettingsMutation.mutateAsync} buttonText={ MAKE_APP_CONFIGURATION_CRUD_CONFIG("file_upload_settings").FORM_LANG .UPSERT diff --git a/src/frontend/views/roles/Create/index.tsx b/src/frontend/views/roles/Create/index.tsx index 86c7dba91..8d45f84f8 100644 --- a/src/frontend/views/roles/Create/index.tsx +++ b/src/frontend/views/roles/Create/index.tsx @@ -24,11 +24,7 @@ export function RoleCreate() { title={ADMIN_ROLES_CRUD_CONFIG.TEXT_LANG.CREATE} backLink={backLink} > - { - await roleCreationMutation.mutateAsync(role); - }} - /> + diff --git a/src/frontend/views/settings/DateFormat/index.tsx b/src/frontend/views/settings/DateFormat/index.tsx index 6e62d8c95..a5ce0b169 100644 --- a/src/frontend/views/settings/DateFormat/index.tsx +++ b/src/frontend/views/settings/DateFormat/index.tsx @@ -20,7 +20,7 @@ import { SETTINGS_VIEW_KEY } from "../constants"; const CRUD_CONFIG = MAKE_APP_CONFIGURATION_CRUD_CONFIG("default_date_format"); export function DateFormatSettings() { - const defaultDateFormat = useAppConfiguration("default_date_format"); + const defaultDateFormat = useAppConfiguration("default_date_format"); const upsertConfigurationMutation = useUpsertConfigurationMutation( "default_date_format" diff --git a/src/frontend/views/settings/Entities/Selection.tsx b/src/frontend/views/settings/Entities/Selection.tsx index 51743083d..7adfdc091 100644 --- a/src/frontend/views/settings/Entities/Selection.tsx +++ b/src/frontend/views/settings/Entities/Selection.tsx @@ -11,7 +11,7 @@ interface IProps { hiddenList: string[]; allList: string[]; crudConfig: ICrudConfig; - onSubmit: (columnsSelection: string[]) => Promise; + onSubmit: (columnsSelection: string[]) => Promise; getEntityFieldLabels: (fieldName: string) => string; } diff --git a/src/frontend/views/settings/Entities/index.tsx b/src/frontend/views/settings/Entities/index.tsx index 916b55078..5ad584f54 100644 --- a/src/frontend/views/settings/Entities/index.tsx +++ b/src/frontend/views/settings/Entities/index.tsx @@ -41,7 +41,7 @@ export function EntitiesSettings() { const [isDocOpen, setIsDocOpen] = useState(false); - const entitiesToHide = useAppConfiguration("disabled_entities"); + const entitiesToHide = useAppConfiguration("disabled_entities"); const upsertHideFromAppMutation = useUpsertConfigurationMutation( "disabled_entities", @@ -83,9 +83,7 @@ export function EntitiesSettings() { allList={entitiesList.data.map(({ value }) => value)} getEntityFieldLabels={getEntitiesDictionPlurals} hiddenList={entitiesToHide.data} - onSubmit={async (data) => { - await upsertHideFromAppMutation.mutateAsync(data); - }} + onSubmit={upsertHideFromAppMutation.mutateAsync} /> diff --git a/src/frontend/views/settings/Menu/index.tsx b/src/frontend/views/settings/Menu/index.tsx index 12c6d4d3c..0cb54b152 100644 --- a/src/frontend/views/settings/Menu/index.tsx +++ b/src/frontend/views/settings/Menu/index.tsx @@ -39,13 +39,9 @@ export function MenuSettings() { const changeTabParam = useChangeRouterParam("tab"); - const menuEntitiesToHide = useAppConfiguration( - "disabled_menu_entities" - ); + const menuEntitiesToHide = useAppConfiguration("disabled_menu_entities"); - const menuEntitiesOrder = useAppConfiguration( - "menu_entities_order" - ); + const menuEntitiesOrder = useAppConfiguration("menu_entities_order"); const activeEntities = useActiveEntities(); @@ -105,9 +101,7 @@ export function MenuSettings() { allList={activeEntities.data.map(({ value }) => value)} getEntityFieldLabels={getEntitiesDictionPlurals} hiddenList={menuEntitiesToHide.data} - onSubmit={async (data) => { - await upsertHideFromMenuMutation.mutateAsync(data); - }} + onSubmit={upsertHideFromMenuMutation.mutateAsync} /> ), @@ -122,11 +116,7 @@ export function MenuSettings() { > Promise - } + onSave={upsertEntitiesOrderMutation.mutateAsync} /> ), diff --git a/src/frontend/views/settings/Site/index.tsx b/src/frontend/views/settings/Site/index.tsx index 9d2c95b94..842f844bd 100644 --- a/src/frontend/views/settings/Site/index.tsx +++ b/src/frontend/views/settings/Site/index.tsx @@ -10,7 +10,6 @@ import { useUpsertConfigurationMutation, } from "frontend/hooks/configuration/configuration.store"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; -import { ISiteSettings } from "shared/types/config"; import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant"; import { BaseSettingsLayout } from "../_Base"; import { SiteSettingsForm } from "./Form"; @@ -19,7 +18,7 @@ import { SETTINGS_VIEW_KEY } from "../constants"; const CRUD_CONFIG = MAKE_APP_CONFIGURATION_CRUD_CONFIG("site_settings"); export function SiteSettings() { - const siteSettings = useAppConfiguration("site_settings"); + const siteSettings = useAppConfiguration("site_settings"); const upsertConfigurationMutation = useUpsertConfigurationMutation("site_settings"); @@ -48,9 +47,7 @@ export function SiteSettings() { } > { - await upsertConfigurationMutation.mutateAsync(values); - }} + onSubmit={upsertConfigurationMutation.mutateAsync} initialValues={siteSettings.data} /> diff --git a/src/frontend/views/settings/System/index.tsx b/src/frontend/views/settings/System/index.tsx index 70e09b9c9..410281891 100644 --- a/src/frontend/views/settings/System/index.tsx +++ b/src/frontend/views/settings/System/index.tsx @@ -9,7 +9,6 @@ import { useAppConfiguration, useUpsertConfigurationMutation, } from "frontend/hooks/configuration/configuration.store"; -import { ISystemSettings } from "shared/configurations"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant"; import { SystemSettingsDocumentation } from "frontend/docs/system-settings"; @@ -24,8 +23,7 @@ const CRUD_CONFIG = MAKE_APP_CONFIGURATION_CRUD_CONFIG("system_settings"); const DOCS_TITLE = "System Settings"; export function SystemSettings() { - const systemSettings = - useAppConfiguration("system_settings"); + const systemSettings = useAppConfiguration("system_settings"); const upsertConfigurationMutation = useUpsertConfigurationMutation("system_settings"); @@ -56,9 +54,7 @@ export function SystemSettings() { loader={} > { - await upsertConfigurationMutation.mutateAsync(values); - }} + onSubmit={upsertConfigurationMutation.mutateAsync} initialValues={systemSettings.data} /> diff --git a/src/frontend/views/settings/Theme/Form.tsx b/src/frontend/views/settings/Theme/Form.tsx index 0398b6fd6..cda3ca148 100644 --- a/src/frontend/views/settings/Theme/Form.tsx +++ b/src/frontend/views/settings/Theme/Form.tsx @@ -1,9 +1,8 @@ import { IFormProps } from "frontend/lib/form/types"; import { SchemaForm } from "frontend/components/SchemaForm"; -import { IThemeSettings } from "frontend/_layouts/types"; import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant"; import { UPDATE_USER_PREFERENCES_FORM_SCHEMA } from "frontend/views/account/Preferences/constants"; -import { ColorSchemes } from "shared/types/ui"; +import { ColorSchemes, IThemeSettings } from "shared/types/ui"; type Settings = IThemeSettings & { theme: ColorSchemes }; diff --git a/src/frontend/views/settings/Theme/index.tsx b/src/frontend/views/settings/Theme/index.tsx index 6196ac3d1..85048c665 100644 --- a/src/frontend/views/settings/Theme/index.tsx +++ b/src/frontend/views/settings/Theme/index.tsx @@ -10,7 +10,6 @@ import { useUpsertConfigurationMutation, } from "frontend/hooks/configuration/configuration.store"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; -import { IThemeSettings } from "frontend/_layouts/types"; import { THEME_SETTINGS_CRUD_CONFIG } from "frontend/_layouts/useAppTheme"; import { useUpsertUserPreferenceMutation, @@ -22,7 +21,7 @@ import { ThemeSettingsForm } from "./Form"; import { SETTINGS_VIEW_KEY } from "../constants"; export function ThemeSettings() { - const themeColor = useAppConfiguration("theme_color"); + const themeColor = useAppConfiguration("theme_color"); const userPreference = useUserPreference("theme"); diff --git a/src/frontend/views/users/Create/index.tsx b/src/frontend/views/users/Create/index.tsx index af6e89609..29d6208b9 100644 --- a/src/frontend/views/users/Create/index.tsx +++ b/src/frontend/views/users/Create/index.tsx @@ -37,11 +37,7 @@ export function UserCreate() { }, ]} > - { - await userCreationMutation.mutateAsync(user); - }} - /> + = { +export const APP_CONFIGURATION_CONFIG = { ...PORTAL_APP_CONFIGURATION_CONFIG, hidden_entity_table_columns: { label: "Table Columns Settings", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, hidden_entity_create_columns: { label: "Create Columns Settings", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, - hidden_entity_update_columns: { label: "Update Columns Settings", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, hidden_entity_details_columns: { label: "Details Columns Settings", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, entity_columns_labels: { label: "Column Labels Settings", requireEntity: true, - defaultValue: {}, + defaultValue: {} as Record, }, entity_columns_types: { label: "Column Types Settings", requireEntity: true, - defaultValue: {}, + defaultValue: {} as Record, }, entity_validations: { label: "Validations", requireEntity: true, - defaultValue: {}, + defaultValue: {} as Record, }, entity_selections: { label: "Selections Settings", requireEntity: true, - defaultValue: {}, + defaultValue: {} as Record, }, entity_diction: { label: "Diction Settings", @@ -89,7 +89,7 @@ export const APP_CONFIGURATION_CONFIG: Record< entity_fields_orders: { label: "Fields Order", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, entity_crud_settings: { label: "CRUD Settings", @@ -100,44 +100,47 @@ export const APP_CONFIGURATION_CONFIG: Record< table: true, update: true, delete: true, - }, + } as IEntityCrudSettings, }, entity_views: { label: "Views Settings", requireEntity: true, - defaultValue: [], + defaultValue: [] as ITableTab[], }, entity_relations_order: { label: "Relations Order", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, hidden_entity_relations: { label: "Enabled Relations", requireEntity: true, - defaultValue: [], + defaultValue: [] as string[], }, entity_relation_template: { label: "Relation Template", requireEntity: true, - defaultValue: { format: "", fields: [] }, + defaultValue: { format: "", fields: [] } as { + format: string; + fields: string[]; + }, }, entity_relations_labels: { label: "Relation Labels", requireEntity: true, - defaultValue: {}, + defaultValue: {} as Record, }, disabled_entities: { label: "Enabled Entities Settings", - defaultValue: [], + defaultValue: [] as string[], }, disabled_menu_entities: { label: "Menu Settings", - defaultValue: [], + defaultValue: [] as string[], }, menu_entities_order: { label: "Menu Settings", - defaultValue: [], + defaultValue: [] as string[], }, default_date_format: { label: "Date Format", @@ -153,7 +156,7 @@ export const APP_CONFIGURATION_CONFIG: Record< defaultValue: { primary: "#4b38b3", primaryDark: "#8c68cd", - }, + } as IThemeSettings, }, site_settings: { label: "Site Settings", @@ -163,6 +166,9 @@ export const APP_CONFIGURATION_CONFIG: Record< fullLogo: "/assets/images/full-logo.png", homeLink: "https://dashpress.io", logo: "/assets/images/logo.png", - }, + } as ISiteSettings, }, }; + +export type AppConfigurationValueType = + typeof APP_CONFIGURATION_CONFIG[T]["defaultValue"]; diff --git a/src/shared/configurations/permissions.ts b/src/shared/configurations/permissions.ts index e6bce890e..85904c6c5 100644 --- a/src/shared/configurations/permissions.ts +++ b/src/shared/configurations/permissions.ts @@ -1,9 +1,10 @@ +/* eslint-disable */ import { DataCrudKeys } from "shared/types/data"; import { AppConfigurationKeys } from "./constants"; -export const CRUD_KEY_CONFIG: Record = { +export const CRUD_KEY_CONFIG = { create: "hidden_entity_create_columns", update: "hidden_entity_update_columns", details: "hidden_entity_details_columns", table: "hidden_entity_table_columns", -}; +} satisfies Record; diff --git a/src/shared/types/ui.ts b/src/shared/types/ui.ts index 1e0d2e787..f4d432174 100644 --- a/src/shared/types/ui.ts +++ b/src/shared/types/ui.ts @@ -12,3 +12,8 @@ export type EntityTypesForSelection = export const FOR_CODE_COV = 1; export type ColorSchemes = "light" | "dark"; + +export type IThemeSettings = { + primary: string; + primaryDark: string; +};