From 455d4a57d84bfe6dac00b4469ac254731ab59622 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Mon, 30 Sep 2024 19:21:32 +0200 Subject: [PATCH 01/21] feat: add openapi client generation --- openapi-ts.config.ts | 11 ++ package.json | 5 +- pnpm-lock.yaml | 273 ++++++++++++++++++++++++++++++++++++++++++- src/hooks.client.ts | 15 +++ src/hooks.server.ts | 12 ++ svelte.config.js | 6 +- tsconfig.json | 2 +- 7 files changed, 319 insertions(+), 5 deletions(-) create mode 100644 openapi-ts.config.ts create mode 100644 src/hooks.client.ts diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts new file mode 100644 index 0000000..a845f53 --- /dev/null +++ b/openapi-ts.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from '@hey-api/openapi-ts'; + +export default defineConfig({ + client: '@hey-api/client-fetch', + input: 'http://localhost:8080/openapi.json', + output: 'src/client', + services: { + // This does not suppport tree-shaking and could lead to a larger bundle size + asClass: true + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 3fbfa05..ca2821c 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,11 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "test": "vitest", "lint": "prettier --check . && eslint .", - "format": "prettier --write ." + "format": "prettier --write .", + "generate-client": "openapi-ts generate" }, "devDependencies": { + "@hey-api/openapi-ts": "^0.53.6", "@sveltejs/adapter-node": "^5.0.1", "@sveltejs/kit": "^2.5.10", "@sveltejs/vite-plugin-svelte": "^3.1.1", @@ -46,6 +48,7 @@ }, "type": "module", "dependencies": { + "@hey-api/client-fetch": "^0.4.0", "better-sqlite3": "^11.1.2", "bits-ui": "^0.21.10", "clsx": "^2.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 344ff05..29a4137 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@hey-api/client-fetch': + specifier: ^0.4.0 + version: 0.4.0 better-sqlite3: specifier: ^11.1.2 version: 11.1.2 @@ -82,6 +85,9 @@ importers: specifier: ^4.0.8 version: 4.0.8 devDependencies: + '@hey-api/openapi-ts': + specifier: ^0.53.6 + version: 0.53.6(typescript@5.5.4) '@sveltejs/adapter-node': specifier: ^5.0.1 version: 5.2.2(@sveltejs/kit@2.5.24(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.4.1(@types/node@22.4.1)))(svelte@4.2.18)(vite@5.4.1(@types/node@22.4.1))) @@ -183,6 +189,10 @@ packages: resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} + '@apidevtools/json-schema-ref-parser@11.7.0': + resolution: {integrity: sha512-pRrmXMCwnmrkS3MLgAIW5dXRzeTv6GLjkjb4HmxNnvAKXN1Nfzp4KmGADBQvlVUcqi+a5D+hfGDLLnd5NnYxog==} + engines: {node: '>= 16'} + '@ark/schema@0.2.0': resolution: {integrity: sha512-IkNWCSHdjaoemMXpps4uFHEAQzwJPbTAS8K2vcQpk90sa+eNBuPSVyB/81/Qyl1VYW0iX3ceGC5NL/OznQv1jg==} @@ -523,6 +533,16 @@ packages: '@hapi/topo@5.1.0': resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==} + '@hey-api/client-fetch@0.4.0': + resolution: {integrity: sha512-T8T3yCl2+AiVVDP6tvfnU/rXOkEHddMTOYCZXUVbydj7URVErh5BelIa8UWBkFYZBP2/mi2nViScNhe9eBolPw==} + + '@hey-api/openapi-ts@0.53.6': + resolution: {integrity: sha512-wbTWu1GpKYoC1J1z1E4yNAsqwbrXoDx3AA6TOjK5bVEZjmxlF7JSmbxZf2cE+sDbmotId3R/J/DKPUHHyWMK+w==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + typescript: ^5.x + '@humanwhocodes/module-importer@1.0.1': resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} @@ -556,6 +576,9 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@jsdevtools/ono@7.1.3': + resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} + '@melt-ui/svelte@0.61.2': resolution: {integrity: sha512-BHkD9G31zQBToA4euDRBgTQRvWxT9scufOVCXgDO6HKTvyxFspbWT2bgiSFqAK4BbAGDn9Ao36Q8F9O71KN4OQ==} peerDependencies: @@ -1036,6 +1059,14 @@ packages: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} + c12@1.11.2: + resolution: {integrity: sha512-oBs8a4uvSDO9dm8b7OCFW7+dgtVrwmwnrVXYzLm43ta7ep2jCn/0MhoUFygIWtxhyy6+/MG7/agvpY0U1Iemew==} + peerDependencies: + magicast: ^0.3.4 + peerDependenciesMeta: + magicast: + optional: true + cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -1078,6 +1109,13 @@ packages: chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + + citty@0.1.6: + resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} + clsx@2.1.1: resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} engines: {node: '>=6'} @@ -1103,6 +1141,10 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + commander@12.1.0: + resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} + engines: {node: '>=18'} + commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -1113,6 +1155,13 @@ packages: concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + confbox@0.1.7: + resolution: {integrity: sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==} + + consola@3.2.3: + resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} + engines: {node: ^14.18.0 || >=16.10.0} + cookie@0.6.0: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} @@ -1161,10 +1210,16 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} + destr@2.0.3: + resolution: {integrity: sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==} + detect-indent@6.1.0: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} @@ -1408,6 +1463,10 @@ packages: fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -1430,6 +1489,10 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} + giget@1.2.3: + resolution: {integrity: sha512-8EHPljDvs7qKykr6uw8b+lqLiUc/vUg+KVTI0uND4s63TdsZM2Xus3mflvF0DDG9SiM4RlCkFGL+7aAjRmV7KA==} + hasBin: true + git-diff@2.0.6: resolution: {integrity: sha512-/Iu4prUrydE3Pb3lCBMbcSNIf81tgGt0W1ZwknnyF62t3tHmtiJTRj0f+1ZIhp3+Rh0ktz1pJVoa7ZXUCskivA==} engines: {node: '>= 4.8.0'} @@ -1477,6 +1540,11 @@ packages: graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + handlebars@4.7.8: + resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} + engines: {node: '>=0.4.7'} + hasBin: true + has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} @@ -1743,10 +1811,22 @@ packages: minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + + minipass@5.0.0: + resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} + engines: {node: '>=8'} + minipass@7.1.2: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} + minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} @@ -1754,6 +1834,14 @@ packages: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + mlly@1.7.1: + resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} + mode-watcher@0.3.1: resolution: {integrity: sha512-inghSVSXpEENV0SHM98+AvjDmTOjh9EJIrJXMScK42GNkDm5QJL7a/nZQ8M8i8RK7loFHqsQKBKdlXfw5e5C4w==} peerDependencies: @@ -1797,10 +1885,16 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + neo-async@2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + node-abi@3.65.0: resolution: {integrity: sha512-ThjYBfoDNr08AWx6hGaRbfPwxKV9kVzAzOzlLKbk2CuqXE2xnCh+cbAGnwM3t8Lq4v9rUB7VfondlkBckcJrVA==} engines: {node: '>=10'} + node-fetch-native@1.6.4: + resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==} + node-gyp-build@4.8.1: resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==} hasBin: true @@ -1827,6 +1921,11 @@ packages: nprogress@0.2.0: resolution: {integrity: sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==} + nypm@0.3.12: + resolution: {integrity: sha512-D3pzNDWIvgA+7IORhD/IuWzEk4uXv6GsgOxiid4UU3h9oq5IqV1KtPDi63n4sZJ/xcWlr88c0QM2RgN5VbOhFA==} + engines: {node: ^14.16.0 || >=16.10.0} + hasBin: true + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -1838,6 +1937,9 @@ packages: obuf@1.1.2: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} + ohash@1.1.4: + resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -1898,6 +2000,9 @@ packages: resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} engines: {node: '>= 14.16'} + perfect-debounce@1.0.0: + resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} + periscopic@3.1.0: resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} @@ -1958,6 +2063,9 @@ packages: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} + pkg-types@1.2.0: + resolution: {integrity: sha512-+ifYuSSqOQ8CqP4MbZA5hDpb97n3E8SVWdJe+Wms9kj745lmd3b7EZJiqvmLwAlmRfjrI7Hi5z3kdBJ93lFNPA==} + postcss-import@15.1.0: resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==} engines: {node: '>=14.0.0'} @@ -2147,6 +2255,9 @@ packages: queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + rc9@2.1.2: + resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} + rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true @@ -2435,6 +2546,10 @@ packages: resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} engines: {node: '>=6'} + tar@6.2.1: + resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} + engines: {node: '>=10'} + text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -2524,6 +2639,14 @@ packages: engines: {node: '>=14.17'} hasBin: true + ufo@1.5.4: + resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} + + uglify-js@3.19.3: + resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==} + engines: {node: '>=0.8.0'} + hasBin: true + undici-types@6.19.6: resolution: {integrity: sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==} @@ -2641,6 +2764,9 @@ packages: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} + wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -2668,6 +2794,9 @@ packages: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + yaml@1.10.2: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} engines: {node: '>= 6'} @@ -2701,6 +2830,12 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 + '@apidevtools/json-schema-ref-parser@11.7.0': + dependencies: + '@jsdevtools/ono': 7.1.3 + '@types/json-schema': 7.0.15 + js-yaml: 4.1.0 + '@ark/schema@0.2.0': dependencies: '@ark/util': 0.1.0 @@ -2919,6 +3054,18 @@ snapshots: '@hapi/hoek': 9.3.0 optional: true + '@hey-api/client-fetch@0.4.0': {} + + '@hey-api/openapi-ts@0.53.6(typescript@5.5.4)': + dependencies: + '@apidevtools/json-schema-ref-parser': 11.7.0 + c12: 1.11.2 + commander: 12.1.0 + handlebars: 4.7.8 + typescript: 5.5.4 + transitivePeerDependencies: + - magicast + '@humanwhocodes/module-importer@1.0.1': {} '@humanwhocodes/retry@0.3.0': {} @@ -2953,6 +3100,8 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@jsdevtools/ono@7.1.3': {} + '@melt-ui/svelte@0.61.2(svelte@4.2.18)': dependencies: '@floating-ui/core': 1.6.7 @@ -3498,6 +3647,21 @@ snapshots: builtin-modules@3.3.0: {} + c12@1.11.2: + dependencies: + chokidar: 3.6.0 + confbox: 0.1.7 + defu: 6.1.4 + dotenv: 16.4.5 + giget: 1.2.3 + jiti: 1.21.6 + mlly: 1.7.1 + ohash: 1.1.4 + pathe: 1.1.2 + perfect-debounce: 1.0.0 + pkg-types: 1.2.0 + rc9: 2.1.2 + cac@6.7.14: {} callsites@3.1.0: {} @@ -3544,6 +3708,12 @@ snapshots: chownr@1.1.4: {} + chownr@2.0.0: {} + + citty@0.1.6: + dependencies: + consola: 3.2.3 + clsx@2.1.1: {} cmdk-sv@0.0.17(svelte@4.2.18): @@ -3572,12 +3742,18 @@ snapshots: color-name@1.1.4: {} + commander@12.1.0: {} + commander@4.1.1: {} commondir@1.0.1: {} concat-map@0.0.1: {} + confbox@0.1.7: {} + + consola@3.2.3: {} + cookie@0.6.0: {} cross-spawn@7.0.3: @@ -3612,8 +3788,12 @@ snapshots: deepmerge@4.3.1: {} + defu@6.1.4: {} + dequal@2.0.3: {} + destr@2.0.3: {} + detect-indent@6.1.0: {} detect-libc@2.0.3: {} @@ -3921,6 +4101,10 @@ snapshots: fs-constants@1.0.0: {} + fs-minipass@2.1.0: + dependencies: + minipass: 3.3.6 + fs.realpath@1.0.0: {} fsevents@2.3.3: @@ -3934,6 +4118,17 @@ snapshots: get-stream@8.0.1: {} + giget@1.2.3: + dependencies: + citty: 0.1.6 + consola: 3.2.3 + defu: 6.1.4 + node-fetch-native: 1.6.4 + nypm: 0.3.12 + ohash: 1.1.4 + pathe: 1.1.2 + tar: 6.2.1 + git-diff@2.0.6: dependencies: chalk: 2.4.2 @@ -3991,6 +4186,15 @@ snapshots: graphemer@1.4.0: {} + handlebars@4.7.8: + dependencies: + minimist: 1.2.8 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.19.3 + has-flag@3.0.0: {} has-flag@4.0.0: {} @@ -4193,14 +4397,34 @@ snapshots: minimist@1.2.8: {} + minipass@3.3.6: + dependencies: + yallist: 4.0.0 + + minipass@5.0.0: {} + minipass@7.1.2: {} + minizlib@2.1.2: + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + mkdirp-classic@0.5.3: {} mkdirp@0.5.6: dependencies: minimist: 1.2.8 + mkdirp@1.0.4: {} + + mlly@1.7.1: + dependencies: + acorn: 8.12.1 + pathe: 1.1.2 + pkg-types: 1.2.0 + ufo: 1.5.4 + mode-watcher@0.3.1(svelte@4.2.18): dependencies: svelte: 4.2.18 @@ -4234,10 +4458,14 @@ snapshots: natural-compare@1.4.0: {} + neo-async@2.6.2: {} + node-abi@3.65.0: dependencies: semver: 7.6.3 + node-fetch-native@1.6.4: {} + node-gyp-build@4.8.1: optional: true @@ -4256,12 +4484,23 @@ snapshots: nprogress@0.2.0: {} + nypm@0.3.12: + dependencies: + citty: 0.1.6 + consola: 3.2.3 + execa: 8.0.1 + pathe: 1.1.2 + pkg-types: 1.2.0 + ufo: 1.5.4 + object-assign@4.1.1: {} object-hash@3.0.0: {} obuf@1.1.2: {} + ohash@1.1.4: {} + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -4314,6 +4553,8 @@ snapshots: pathval@2.0.0: {} + perfect-debounce@1.0.0: {} + periscopic@3.1.0: dependencies: '@types/estree': 1.0.5 @@ -4375,6 +4616,12 @@ snapshots: pirates@4.0.6: {} + pkg-types@1.2.0: + dependencies: + confbox: 0.1.7 + mlly: 1.7.1 + pathe: 1.1.2 + postcss-import@15.1.0(postcss@8.4.41): dependencies: postcss: 8.4.41 @@ -4496,6 +4743,11 @@ snapshots: queue-microtask@1.2.3: {} + rc9@2.1.2: + dependencies: + defu: 6.1.4 + destr: 2.0.3 + rc@1.2.8: dependencies: deep-extend: 0.6.0 @@ -4630,8 +4882,7 @@ snapshots: source-map: 0.6.1 optional: true - source-map@0.6.1: - optional: true + source-map@0.6.1: {} split2@4.2.0: {} @@ -4844,6 +5095,15 @@ snapshots: inherits: 2.0.4 readable-stream: 3.6.2 + tar@6.2.1: + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + text-table@0.2.0: {} thenify-all@1.6.0: @@ -4919,6 +5179,11 @@ snapshots: typescript@5.5.4: {} + ufo@1.5.4: {} + + uglify-js@3.19.3: + optional: true + undici-types@6.19.6: {} update-browserslist-db@1.1.0(browserslist@4.23.3): @@ -5024,6 +5289,8 @@ snapshots: word-wrap@1.2.5: {} + wordwrap@1.0.0: {} + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 @@ -5044,6 +5311,8 @@ snapshots: xtend@4.0.2: {} + yallist@4.0.0: {} + yaml@1.10.2: {} yaml@2.5.0: {} diff --git a/src/hooks.client.ts b/src/hooks.client.ts new file mode 100644 index 0000000..c4a82b5 --- /dev/null +++ b/src/hooks.client.ts @@ -0,0 +1,15 @@ +import { env } from '$env/dynamic/public'; +const BACKEND_URL = env.PUBLIC_BACKEND_URL || 'http://127.0.0.1:8080'; +import { client } from './client/services.gen'; + + +client.setConfig({ + baseUrl: BACKEND_URL +}) + +client.interceptors.error.use((error) => { + if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { + return error.detail; + } + return undefined; +}); diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 039ef8d..22dc173 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -4,6 +4,7 @@ import { sequence } from '@sveltejs/kit/hooks'; import { env } from '$env/dynamic/private'; const BACKEND_URL = env.BACKEND_URL || 'http://127.0.0.1:8080'; import { db } from '$lib/server/db'; +import { client } from './client/services.gen'; const setLocals: Handle = async ({ event, resolve }) => { event.locals.BACKEND_URL = BACKEND_URL; @@ -29,4 +30,15 @@ const onboarding: Handle = async ({ event, resolve }) => { return resolve(event); }; +client.setConfig({ + baseUrl: BACKEND_URL +}) + +client.interceptors.error.use((error) => { + if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { + return error.detail; + } + return undefined; +}); + export const handle = sequence(setLocals, onboarding); diff --git a/svelte.config.js b/svelte.config.js index fffb849..ac772d7 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,7 +11,11 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() + adapter: adapter(), + alias: { + '$lib': './src/lib', + '$': './src', + } } }; diff --git a/tsconfig.json b/tsconfig.json index fc93cbd..7683490 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "moduleResolution": "bundler" + "moduleResolution": "bundler", } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files From fcacae40e3039721fa3a5467426186ccac87144f Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Thu, 3 Oct 2024 20:31:53 +0200 Subject: [PATCH 02/21] feat: add openapi generated API --- src/client/index.ts | 4 + src/client/schemas.gen.ts | 4266 ++++++++++++++++++++++++++++++++++++ src/client/services.gen.ts | 525 +++++ src/client/types.gen.ts | 1278 +++++++++++ 4 files changed, 6073 insertions(+) create mode 100644 src/client/index.ts create mode 100644 src/client/schemas.gen.ts create mode 100644 src/client/services.gen.ts create mode 100644 src/client/types.gen.ts diff --git a/src/client/index.ts b/src/client/index.ts new file mode 100644 index 0000000..0a2b84b --- /dev/null +++ b/src/client/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './schemas.gen'; +export * from './services.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts new file mode 100644 index 0000000..7cba915 --- /dev/null +++ b/src/client/schemas.gen.ts @@ -0,0 +1,4266 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export const AddItemsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + } + }, + type: 'object', + required: ['success', 'message'], + title: 'AddItemsResponse' +} as const; + +export const AllDebridModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + proxy_enabled: { + type: 'boolean', + title: 'Proxy Enabled', + default: false + }, + proxy_url: { + type: 'string', + title: 'Proxy Url', + default: '' + } + }, + type: 'object', + title: 'AllDebridModel' +} as const; + +export const AnnatarConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://annatar.elfhosted.com' + }, + limit: { + type: 'integer', + title: 'Limit', + default: 2000 + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'AnnatarConfig' +} as const; + +export const AppModelSchema = { + properties: { + version: { + type: 'string', + title: 'Version', + default: '0.15.1' + }, + debug: { + type: 'boolean', + title: 'Debug', + default: true + }, + log: { + type: 'boolean', + title: 'Log', + default: true + }, + force_refresh: { + type: 'boolean', + title: 'Force Refresh', + default: false + }, + map_metadata: { + type: 'boolean', + title: 'Map Metadata', + default: true + }, + tracemalloc: { + type: 'boolean', + title: 'Tracemalloc', + default: false + }, + symlink: { + '$ref': '#/components/schemas/SymlinkModel', + default: { + rclone_path: '.', + library_path: '.', + separate_anime_dirs: false, + repair_symlinks: false, + repair_interval: 6 + } + }, + updaters: { + '$ref': '#/components/schemas/UpdatersModel', + default: { + updater_interval: 120, + plex: { + enabled: false, + token: '', + url: 'http://localhost:32400' + }, + jellyfin: { + api_key: '', + enabled: false, + url: 'http://localhost:8096' + }, + emby: { + api_key: '', + enabled: false, + url: 'http://localhost:8096' + } + } + }, + downloaders: { + '$ref': '#/components/schemas/DownloadersModel', + default: { + video_extensions: ['mp4', 'mkv', 'avi'], + prefer_speed_over_quality: true, + real_debrid: { + api_key: '', + enabled: false, + proxy_enabled: false, + proxy_url: '' + }, + all_debrid: { + api_key: '', + enabled: false, + proxy_enabled: false, + proxy_url: '' + }, + torbox: { + api_key: '', + enabled: false + } + } + }, + content: { + '$ref': '#/components/schemas/ContentModel', + default: { + overseerr: { + api_key: '', + enabled: false, + update_interval: 60, + url: 'http://localhost:5055', + use_webhook: false + }, + plex_watchlist: { + enabled: false, + rss: [], + update_interval: 60 + }, + mdblist: { + api_key: '', + enabled: false, + lists: [], + update_interval: 300 + }, + listrr: { + api_key: '', + enabled: false, + movie_lists: [], + show_lists: [], + update_interval: 300 + }, + trakt: { + api_key: '', + collection: [], + enabled: false, + fetch_popular: false, + fetch_trending: false, + popular_count: 10, + trending_count: 10, + update_interval: 300, + user_lists: [], + watchlist: [] + } + } + }, + scraping: { + '$ref': '#/components/schemas/ScraperModel', + default: { + after_2: 2, + after_5: 6, + after_10: 24, + parse_debug: false, + enable_aliases: true, + torrentio: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + ratelimit: true, + timeout: 30, + url: 'http://torrentio.strem.fun' + }, + knightcrawler: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + ratelimit: true, + timeout: 30, + url: 'https://knightcrawler.elfhosted.com' + }, + jackett: { + api_key: '', + enabled: false, + ratelimit: true, + timeout: 30, + url: 'http://localhost:9117' + }, + prowlarr: { + api_key: '', + enabled: false, + limiter_seconds: 60, + ratelimit: true, + timeout: 30, + url: 'http://localhost:9696' + }, + orionoid: { + api_key: '', + cached_results_only: false, + enabled: false, + parameters: { + limitcount: 5, + video3d: 'false', + videoquality: 'sd_hd8k' + }, + ratelimit: true, + timeout: 30 + }, + annatar: { + enabled: false, + limit: 2000, + ratelimit: true, + timeout: 30, + url: 'http://annatar.elfhosted.com' + }, + torbox_scraper: { + enabled: false, + timeout: 30 + }, + mediafusion: { + catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'], + enabled: false, + ratelimit: true, + timeout: 30, + url: 'https://mediafusion.elfhosted.com' + }, + zilean: { + enabled: false, + ratelimit: true, + timeout: 30, + url: 'http://localhost:8181' + }, + comet: { + enabled: false, + indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], + ratelimit: true, + timeout: 30, + url: 'http://localhost:8000' + } + } + }, + ranking: { + '$ref': '#/components/schemas/RTNSettingsModel', + default: { + profile: 'default', + require: [], + exclude: [], + preferred: [], + resolutions: { + '1080p': true, + '2160p': false, + '360p': false, + '480p': false, + '720p': true, + unknown: true + }, + options: { + allow_english_in_languages: false, + remove_all_trash: true, + remove_ranks_under: -10000, + remove_unknown_languages: false, + title_similarity: 0.85 + }, + languages: { + exclude: [], + preferred: [], + required: [] + }, + custom_ranks: { + audio: { + aac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + ac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + atmos: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital_plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossless: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossy: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + eac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + flac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mono: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + mp3: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + stereo: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + surround: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + truehd: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + extras: { + '3d': { + fetch: false, + rank: 0, + use_custom_rank: false + }, + converted: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + documentary: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dubbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + edition: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hardcoded: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + network: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + proper: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + repack: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + retail: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + site: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + subbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + upscaled: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + hdr: { + '10bit': { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_vision: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr10plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + sdr: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + quality: { + av1: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + avc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + bluray: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dvd: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdtv: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hevc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mpeg: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + remux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhs: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + web: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webdl: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webmux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + xvid: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + rips: { + bdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + brrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dvdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + ppvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + satrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + tvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + uhdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhsrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webdlrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webrip: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + trash: { + cam: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + clean_audio: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + pdtv: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + r5: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + screener: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + size: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telecine: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telesync: { + fetch: false, + rank: 0, + use_custom_rank: false + } + } + } + } + }, + indexer: { + '$ref': '#/components/schemas/IndexerModel', + default: { + update_interval: 3600 + } + }, + database: { + '$ref': '#/components/schemas/DatabaseModel', + default: { + host: 'postgresql+psycopg2://postgres:postgres@localhost/riven' + } + }, + notifications: { + '$ref': '#/components/schemas/NotificationsModel', + default: { + enabled: false, + title: 'Riven completed something!', + on_item_type: ['movie', 'show', 'season'], + service_urls: [] + } + }, + post_processing: { + '$ref': '#/components/schemas/PostProcessing', + default: { + subliminal: { + enabled: false, + languages: ['eng'], + providers: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + } + } + }, + type: 'object', + title: 'AppModel' +} as const; + +export const BelongsToCollectionSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + poster_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Poster Path' + }, + backdrop_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Backdrop Path' + } + }, + type: 'object', + required: ['id', 'name', 'poster_path', 'backdrop_path'], + title: 'BelongsToCollection' +} as const; + +export const CometConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8000' + }, + indexers: { + items: { + type: 'string' + }, + type: 'array', + title: 'Indexers', + default: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'] + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'CometConfig' +} as const; + +export const ContentModelSchema = { + properties: { + overseerr: { + '$ref': '#/components/schemas/OverseerrModel', + default: { + update_interval: 60, + enabled: false, + url: 'http://localhost:5055', + api_key: '', + use_webhook: false + } + }, + plex_watchlist: { + '$ref': '#/components/schemas/PlexWatchlistModel', + default: { + update_interval: 60, + enabled: false, + rss: [] + } + }, + mdblist: { + '$ref': '#/components/schemas/MdblistModel', + default: { + update_interval: 300, + enabled: false, + api_key: '', + lists: [] + } + }, + listrr: { + '$ref': '#/components/schemas/ListrrModel', + default: { + update_interval: 300, + enabled: false, + movie_lists: [], + show_lists: [], + api_key: '' + } + }, + trakt: { + '$ref': '#/components/schemas/TraktModel', + default: { + update_interval: 300, + enabled: false, + api_key: '', + watchlist: [], + user_lists: [], + collection: [], + fetch_trending: false, + trending_count: 10, + fetch_popular: false, + popular_count: 10 + } + } + }, + type: 'object', + title: 'ContentModel' +} as const; + +export const CustomRankSchema = { + properties: { + fetch: { + type: 'boolean', + title: 'Fetch', + default: true + }, + use_custom_rank: { + type: 'boolean', + title: 'Use Custom Rank', + default: false + }, + rank: { + type: 'integer', + title: 'Rank', + default: 0 + } + }, + type: 'object', + title: 'CustomRank', + description: 'Custom Ranks used in SettingsModel.' +} as const; + +export const DataAndSuccessResponse_RDUser_Schema = { + properties: { + data: { + '$ref': '#/components/schemas/RDUser' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['data', 'success'], + title: 'DataAndSuccessResponse[RDUser]' +} as const; + +export const DataAndSuccessResponse_StatsResponse_Schema = { + properties: { + data: { + '$ref': '#/components/schemas/StatsResponse' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['data', 'success'], + title: 'DataAndSuccessResponse[StatsResponse]' +} as const; + +export const DataAndSuccessResponse_dict_Schema = { + properties: { + data: { + type: 'object', + title: 'Data' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['data', 'success'], + title: 'DataAndSuccessResponse[dict]' +} as const; + +export const DataAndSuccessResponse_dict_str__list_EventUpdate___Schema = { + properties: { + data: { + additionalProperties: { + items: { + '$ref': '#/components/schemas/EventUpdate' + }, + type: 'array' + }, + type: 'object', + title: 'Data' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['data', 'success'], + title: 'DataAndSuccessResponse[dict[str, list[EventUpdate]]]' +} as const; + +export const DataAndSuccessResponse_dict_str__str__Schema = { + properties: { + data: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Data' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['data', 'success'], + title: 'DataAndSuccessResponse[dict[str, str]]' +} as const; + +export const DatabaseModelSchema = { + properties: { + host: { + type: 'string', + title: 'Host', + default: 'postgresql+psycopg2://postgres:postgres@localhost/riven' + } + }, + type: 'object', + title: 'DatabaseModel' +} as const; + +export const DatesSchema = { + properties: { + maximum: { + type: 'string', + format: 'date', + title: 'Maximum' + }, + minimum: { + type: 'string', + format: 'date', + title: 'Minimum' + } + }, + type: 'object', + required: ['maximum', 'minimum'], + title: 'Dates' +} as const; + +export const DownloadersModelSchema = { + properties: { + video_extensions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Video Extensions', + default: ['mp4', 'mkv', 'avi'] + }, + prefer_speed_over_quality: { + type: 'boolean', + title: 'Prefer Speed Over Quality', + default: true + }, + real_debrid: { + '$ref': '#/components/schemas/RealDebridModel', + default: { + enabled: false, + api_key: '', + proxy_enabled: false, + proxy_url: '' + } + }, + all_debrid: { + '$ref': '#/components/schemas/AllDebridModel', + default: { + enabled: false, + api_key: '', + proxy_enabled: false, + proxy_url: '' + } + }, + torbox: { + '$ref': '#/components/schemas/TorboxModel', + default: { + enabled: false, + api_key: '' + } + } + }, + type: 'object', + title: 'DownloadersModel' +} as const; + +export const EmbyLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8096' + } + }, + type: 'object', + title: 'EmbyLibraryModel' +} as const; + +export const EventUpdateSchema = { + properties: { + item_id: { + type: 'integer', + title: 'Item Id' + }, + imdb_id: { + type: 'string', + title: 'Imdb Id' + }, + title: { + type: 'string', + title: 'Title' + }, + type: { + type: 'string', + title: 'Type' + }, + emitted_by: { + type: 'string', + title: 'Emitted By' + }, + run_at: { + type: 'string', + title: 'Run At' + }, + last_state: { + type: 'string', + title: 'Last State' + } + }, + type: 'object', + required: ['item_id', 'imdb_id', 'title', 'type', 'emitted_by', 'run_at', 'last_state'], + title: 'EventUpdate' +} as const; + +export const ExternalIDExternalSourceSchema = { + type: 'string', + enum: ['imdb_id', 'facebook_id', 'instagram_id', 'tvdb_id', 'tiktok_id', 'twitter_id', 'wikidata_id', 'youtube_id'], + title: 'ExternalIDExternalSource' +} as const; + +export const GenreSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['id', 'name'], + title: 'Genre' +} as const; + +export const GetAllSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + '$ref': '#/components/schemas/AppModel' + } + }, + type: 'object', + required: ['success', 'data'], + title: 'GetAllSettingsResponse' +} as const; + +export const GetSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + type: 'object', + title: 'Data' + } + }, + type: 'object', + required: ['success', 'data'], + title: 'GetSettingsResponse' +} as const; + +export const HTTPValidationErrorSchema = { + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' +} as const; + +export const IncludeAdultSchema = { + type: 'string', + enum: ['true', 'false'], + title: 'IncludeAdult' +} as const; + +export const IndexerModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 3600 + } + }, + type: 'object', + title: 'IndexerModel' +} as const; + +export const ItemResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + item: { + type: 'object', + title: 'Item' + } + }, + type: 'object', + required: ['success', 'item'], + title: 'ItemResponse' +} as const; + +export const ItemsByImdbResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + items: { + items: { + type: 'object' + }, + type: 'array', + title: 'Items' + } + }, + type: 'object', + required: ['success', 'items'], + title: 'ItemsByImdbResponse' +} as const; + +export const ItemsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + items: { + items: { + type: 'object' + }, + type: 'array', + title: 'Items' + }, + page: { + type: 'integer', + title: 'Page' + }, + limit: { + type: 'integer', + title: 'Limit' + }, + total_items: { + type: 'integer', + title: 'Total Items' + }, + total_pages: { + type: 'integer', + title: 'Total Pages' + } + }, + type: 'object', + required: ['success', 'items', 'page', 'limit', 'total_items', 'total_pages'], + title: 'ItemsResponse' +} as const; + +export const JackettConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:9117' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'JackettConfig' +} as const; + +export const JellyfinLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8096' + } + }, + type: 'object', + title: 'JellyfinLibraryModel' +} as const; + +export const KnightcrawlerConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + filter: { + type: 'string', + title: 'Filter', + default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' + }, + url: { + type: 'string', + title: 'Url', + default: 'https://knightcrawler.elfhosted.com' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'KnightcrawlerConfig' +} as const; + +export const ListrrModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + movie_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'Movie Lists', + default: [] + }, + show_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'Show Lists', + default: [] + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + } + }, + type: 'object', + title: 'ListrrModel' +} as const; + +export const LoadSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + } + }, + type: 'object', + required: ['success', 'message'], + title: 'LoadSettingsResponse' +} as const; + +export const LogsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + logs: { + type: 'string', + title: 'Logs' + } + }, + type: 'object', + required: ['success', 'logs'], + title: 'LogsResponse' +} as const; + +export const MdblistModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + lists: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Lists', + default: [] + } + }, + type: 'object', + title: 'MdblistModel' +} as const; + +export const MediafusionConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'https://mediafusion.elfhosted.com' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + }, + catalogs: { + items: { + type: 'string' + }, + type: 'array', + title: 'Catalogs', + default: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] + } + }, + type: 'object', + title: 'MediafusionConfig' +} as const; + +export const MessageAndSuccessResponseSchema = { + properties: { + message: { + type: 'string', + title: 'Message' + }, + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['message', 'success'], + title: 'MessageAndSuccessResponse' +} as const; + +export const NetworkSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + logo_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Logo Path' + }, + name: { + type: 'string', + title: 'Name' + }, + origin_country: { + type: 'string', + title: 'Origin Country' + } + }, + type: 'object', + required: ['id', 'logo_path', 'name', 'origin_country'], + title: 'Network' +} as const; + +export const NotificationsModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + title: { + type: 'string', + title: 'Title', + default: 'Riven completed something!' + }, + on_item_type: { + items: { + type: 'string' + }, + type: 'array', + title: 'On Item Type', + default: ['movie', 'show', 'season'] + }, + service_urls: { + items: { + type: 'string' + }, + type: 'array', + title: 'Service Urls', + default: [] + } + }, + type: 'object', + title: 'NotificationsModel' +} as const; + +export const OrionoidConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + cached_results_only: { + type: 'boolean', + title: 'Cached Results Only', + default: false + }, + parameters: { + type: 'object', + title: 'Parameters', + default: { + video3d: 'false', + videoquality: 'sd_hd8k', + limitcount: 5 + } + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'OrionoidConfig' +} as const; + +export const OverseerrModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 60 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:5055' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + use_webhook: { + type: 'boolean', + title: 'Use Webhook', + default: false + } + }, + type: 'object', + title: 'OverseerrModel' +} as const; + +export const PlexLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + token: { + type: 'string', + title: 'Token', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:32400' + } + }, + type: 'object', + title: 'PlexLibraryModel' +} as const; + +export const PlexWatchlistModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 60 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + rss: { + items: { + type: 'string' + }, + type: 'array', + title: 'Rss', + default: [] + } + }, + type: 'object', + title: 'PlexWatchlistModel' +} as const; + +export const PostProcessingSchema = { + properties: { + subliminal: { + '$ref': '#/components/schemas/SubliminalConfig', + default: { + enabled: false, + languages: ['eng'], + providers: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + } + }, + type: 'object', + title: 'PostProcessing' +} as const; + +export const ProductionCompanySchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + logo_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Logo Path' + }, + name: { + type: 'string', + title: 'Name' + }, + origin_country: { + type: 'string', + title: 'Origin Country' + } + }, + type: 'object', + required: ['id', 'logo_path', 'name', 'origin_country'], + title: 'ProductionCompany' +} as const; + +export const ProductionCountrySchema = { + properties: { + iso_3166_1: { + type: 'string', + title: 'Iso 3166 1' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['iso_3166_1', 'name'], + title: 'ProductionCountry' +} as const; + +export const ProwlarrConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:9696' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + }, + limiter_seconds: { + type: 'integer', + title: 'Limiter Seconds', + default: 60 + } + }, + type: 'object', + title: 'ProwlarrConfig' +} as const; + +export const RDTorrentSchema = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + hash: { + type: 'string', + title: 'Hash' + }, + filename: { + type: 'string', + title: 'Filename' + }, + bytes: { + type: 'integer', + title: 'Bytes' + }, + status: { + '$ref': '#/components/schemas/RDTorrentStatus' + }, + added: { + type: 'string', + format: 'date-time', + title: 'Added' + }, + links: { + items: { + type: 'string' + }, + type: 'array', + title: 'Links' + }, + ended: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Ended' + }, + speed: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Speed' + }, + seeders: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Seeders' + } + }, + type: 'object', + required: ['id', 'hash', 'filename', 'bytes', 'status', 'added', 'links'], + title: 'RDTorrent' +} as const; + +export const RDTorrentStatusSchema = { + type: 'string', + enum: ['magnet_error', 'magnet_conversion', 'waiting_files_selection', 'downloading', 'downloaded', 'error', 'seeding', 'dead', 'uploading', 'compressing'], + title: 'RDTorrentStatus' +} as const; + +export const RDUserSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + username: { + type: 'string', + title: 'Username' + }, + email: { + type: 'string', + title: 'Email' + }, + points: { + type: 'integer', + title: 'Points', + description: "User's RD points" + }, + locale: { + type: 'string', + title: 'Locale' + }, + avatar: { + type: 'string', + title: 'Avatar', + description: "URL to the user's avatar" + }, + type: { + type: 'string', + enum: ['free', 'premium'], + title: 'Type' + }, + premium: { + type: 'integer', + title: 'Premium', + description: 'Premium subscription left in seconds' + } + }, + type: 'object', + required: ['id', 'username', 'email', 'points', 'locale', 'avatar', 'type', 'premium'], + title: 'RDUser' +} as const; + +export const RTNSettingsModelSchema = { + properties: { + profile: { + type: 'string', + title: 'Profile', + default: 'default' + }, + require: { + items: { + type: 'string' + }, + type: 'array', + title: 'Require', + default: [] + }, + exclude: { + items: { + type: 'string' + }, + type: 'array', + title: 'Exclude', + default: [] + }, + preferred: { + items: { + type: 'string' + }, + type: 'array', + title: 'Preferred', + default: [] + }, + resolutions: { + additionalProperties: { + type: 'boolean' + }, + type: 'object', + title: 'Resolutions', + default: { + '2160p': false, + '1080p': true, + '720p': true, + '480p': false, + '360p': false, + unknown: true + } + }, + options: { + type: 'object', + title: 'Options', + default: { + title_similarity: 0.85, + remove_all_trash: true, + remove_ranks_under: -10000, + remove_unknown_languages: false, + allow_english_in_languages: false + } + }, + languages: { + type: 'object', + title: 'Languages', + default: { + required: [], + exclude: [], + preferred: [] + } + }, + custom_ranks: { + additionalProperties: { + additionalProperties: { + '$ref': '#/components/schemas/CustomRank' + }, + type: 'object' + }, + type: 'object', + title: 'Custom Ranks', + default: { + quality: { + av1: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + avc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + bluray: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dvd: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdtv: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hevc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mpeg: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + remux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhs: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + web: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webdl: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webmux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + xvid: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + rips: { + bdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + brrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dvdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + ppvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + satrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + tvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + uhdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhsrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webdlrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webrip: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + hdr: { + '10bit': { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_vision: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr10plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + sdr: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + audio: { + aac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + ac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + atmos: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital_plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossless: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossy: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + eac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + flac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mono: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + mp3: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + stereo: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + surround: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + truehd: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + extras: { + '3d': { + fetch: false, + rank: 0, + use_custom_rank: false + }, + converted: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + documentary: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dubbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + edition: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hardcoded: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + network: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + proper: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + repack: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + retail: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + site: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + subbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + upscaled: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + trash: { + cam: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + clean_audio: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + pdtv: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + r5: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + screener: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + size: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telecine: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telesync: { + fetch: false, + rank: 0, + use_custom_rank: false + } + } + } + } + }, + type: 'object', + title: 'RTNSettingsModel' +} as const; + +export const RealDebridModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + proxy_enabled: { + type: 'boolean', + title: 'Proxy Enabled', + default: false + }, + proxy_url: { + type: 'string', + title: 'Proxy Url', + default: '' + } + }, + type: 'object', + title: 'RealDebridModel' +} as const; + +export const RemoveResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + }, + ids: { + items: { + type: 'integer' + }, + type: 'array', + title: 'Ids' + } + }, + type: 'object', + required: ['success', 'message', 'ids'], + title: 'RemoveResponse' +} as const; + +export const ResetResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + }, + ids: { + items: { + type: 'string' + }, + type: 'array', + title: 'Ids' + } + }, + type: 'object', + required: ['success', 'message', 'ids'], + title: 'ResetResponse' +} as const; + +export const RetryResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + }, + ids: { + items: { + type: 'string' + }, + type: 'array', + title: 'Ids' + } + }, + type: 'object', + required: ['success', 'message', 'ids'], + title: 'RetryResponse' +} as const; + +export const RootResponseSchema = { + properties: { + message: { + type: 'string', + title: 'Message' + }, + success: { + type: 'boolean', + title: 'Success' + }, + version: { + type: 'string', + title: 'Version' + } + }, + type: 'object', + required: ['message', 'success', 'version'], + title: 'RootResponse' +} as const; + +export const SaveSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + } + }, + type: 'object', + required: ['success', 'message'], + title: 'SaveSettingsResponse' +} as const; + +export const ScrapeResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + items: { + '$ref': '#/components/schemas/ScrapedTorrent' + }, + type: 'array', + title: 'Data' + } + }, + type: 'object', + required: ['success', 'data'], + title: 'ScrapeResponse' +} as const; + +export const ScrapedTorrentSchema = { + properties: { + rank: { + type: 'integer', + title: 'Rank' + }, + raw_title: { + type: 'string', + title: 'Raw Title' + }, + infohash: { + type: 'string', + title: 'Infohash' + } + }, + type: 'object', + required: ['rank', 'raw_title', 'infohash'], + title: 'ScrapedTorrent' +} as const; + +export const ScraperModelSchema = { + properties: { + after_2: { + type: 'number', + title: 'After 2', + default: 2 + }, + after_5: { + type: 'integer', + title: 'After 5', + default: 6 + }, + after_10: { + type: 'integer', + title: 'After 10', + default: 24 + }, + parse_debug: { + type: 'boolean', + title: 'Parse Debug', + default: false + }, + enable_aliases: { + type: 'boolean', + title: 'Enable Aliases', + default: true + }, + torrentio: { + '$ref': '#/components/schemas/TorrentioConfig', + default: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + url: 'http://torrentio.strem.fun', + timeout: 30, + ratelimit: true + } + }, + knightcrawler: { + '$ref': '#/components/schemas/KnightcrawlerConfig', + default: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + url: 'https://knightcrawler.elfhosted.com', + timeout: 30, + ratelimit: true + } + }, + jackett: { + '$ref': '#/components/schemas/JackettConfig', + default: { + enabled: false, + url: 'http://localhost:9117', + api_key: '', + timeout: 30, + ratelimit: true + } + }, + prowlarr: { + '$ref': '#/components/schemas/ProwlarrConfig', + default: { + enabled: false, + url: 'http://localhost:9696', + api_key: '', + timeout: 30, + ratelimit: true, + limiter_seconds: 60 + } + }, + orionoid: { + '$ref': '#/components/schemas/OrionoidConfig', + default: { + enabled: false, + api_key: '', + cached_results_only: false, + parameters: { + limitcount: 5, + video3d: 'false', + videoquality: 'sd_hd8k' + }, + timeout: 30, + ratelimit: true + } + }, + annatar: { + '$ref': '#/components/schemas/AnnatarConfig', + default: { + enabled: false, + url: 'http://annatar.elfhosted.com', + limit: 2000, + timeout: 30, + ratelimit: true + } + }, + torbox_scraper: { + '$ref': '#/components/schemas/TorBoxScraperConfig', + default: { + enabled: false, + timeout: 30 + } + }, + mediafusion: { + '$ref': '#/components/schemas/MediafusionConfig', + default: { + enabled: false, + url: 'https://mediafusion.elfhosted.com', + timeout: 30, + ratelimit: true, + catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] + } + }, + zilean: { + '$ref': '#/components/schemas/ZileanConfig', + default: { + enabled: false, + url: 'http://localhost:8181', + timeout: 30, + ratelimit: true + } + }, + comet: { + '$ref': '#/components/schemas/CometConfig', + default: { + enabled: false, + url: 'http://localhost:8000', + indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], + timeout: 30, + ratelimit: true + } + } + }, + type: 'object', + title: 'ScraperModel' +} as const; + +export const SetAllSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + } + }, + type: 'object', + required: ['success', 'message'], + title: 'SetAllSettingsResponse' +} as const; + +export const SetSettingsSchema = { + properties: { + key: { + type: 'string', + title: 'Key' + }, + value: { + title: 'Value' + } + }, + type: 'object', + required: ['key', 'value'], + title: 'SetSettings' +} as const; + +export const SetSettingsResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + } + }, + type: 'object', + required: ['success', 'message'], + title: 'SetSettingsResponse' +} as const; + +export const SetTorrentRDResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + message: { + type: 'string', + title: 'Message' + }, + item_id: { + type: 'integer', + title: 'Item Id' + }, + torrent_id: { + type: 'string', + title: 'Torrent Id' + } + }, + type: 'object', + required: ['success', 'message', 'item_id', 'torrent_id'], + title: 'SetTorrentRDResponse' +} as const; + +export const SpokenLanguageSchema = { + properties: { + english_name: { + type: 'string', + title: 'English Name' + }, + iso_639_1: { + type: 'string', + title: 'Iso 639 1' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['english_name', 'iso_639_1', 'name'], + title: 'SpokenLanguage' +} as const; + +export const StateResponseSchema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + states: { + items: { + type: 'string' + }, + type: 'array', + title: 'States' + } + }, + type: 'object', + required: ['success', 'states'], + title: 'StateResponse' +} as const; + +export const StatesSchema = { + type: 'string', + enum: ['Unknown', 'Unreleased', 'Ongoing', 'Requested', 'Indexed', 'Scraped', 'Downloaded', 'Symlinked', 'Completed', 'PartiallyCompleted', 'Failed'], + title: 'States' +} as const; + +export const StatsResponseSchema = { + properties: { + total_items: { + type: 'integer', + title: 'Total Items' + }, + total_movies: { + type: 'integer', + title: 'Total Movies' + }, + total_shows: { + type: 'integer', + title: 'Total Shows' + }, + total_seasons: { + type: 'integer', + title: 'Total Seasons' + }, + total_episodes: { + type: 'integer', + title: 'Total Episodes' + }, + total_symlinks: { + type: 'integer', + title: 'Total Symlinks' + }, + incomplete_items: { + type: 'integer', + title: 'Incomplete Items' + }, + incomplete_retries: { + additionalProperties: { + type: 'integer' + }, + type: 'object', + title: 'Incomplete Retries', + description: 'Media item log string: number of retries' + }, + states: { + additionalProperties: { + type: 'integer' + }, + type: 'object', + title: 'States' + } + }, + type: 'object', + required: ['total_items', 'total_movies', 'total_shows', 'total_seasons', 'total_episodes', 'total_symlinks', 'incomplete_items', 'incomplete_retries', 'states'], + title: 'StatsResponse' +} as const; + +export const SubliminalConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + languages: { + items: { + type: 'string' + }, + type: 'array', + title: 'Languages', + default: ['eng'] + }, + providers: { + type: 'object', + title: 'Providers', + default: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + }, + type: 'object', + title: 'SubliminalConfig' +} as const; + +export const SymlinkModelSchema = { + properties: { + rclone_path: { + type: 'string', + format: 'path', + title: 'Rclone Path', + default: '.' + }, + library_path: { + type: 'string', + format: 'path', + title: 'Library Path', + default: '.' + }, + separate_anime_dirs: { + type: 'boolean', + title: 'Separate Anime Dirs', + default: false + }, + repair_symlinks: { + type: 'boolean', + title: 'Repair Symlinks', + default: false + }, + repair_interval: { + type: 'number', + title: 'Repair Interval', + default: 6 + } + }, + type: 'object', + title: 'SymlinkModel' +} as const; + +export const TmdbCollectionDetailsSchema = { + properties: { + adult: { + type: 'boolean', + title: 'Adult' + }, + backdrop_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Backdrop Path' + }, + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + overview: { + type: 'string', + title: 'Overview' + }, + original_language: { + type: 'string', + title: 'Original Language' + }, + original_name: { + type: 'string', + title: 'Original Name' + }, + poster_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Poster Path' + } + }, + type: 'object', + required: ['adult', 'backdrop_path', 'id', 'name', 'overview', 'original_language', 'original_name', 'poster_path'], + title: 'TmdbCollectionDetails' +} as const; + +export const TmdbEpisodeDetailsSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + overview: { + type: 'string', + title: 'Overview' + }, + media_type: { + type: 'string', + enum: ['tv_episode'], + const: 'tv_episode', + title: 'Media Type' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + vote_count: { + type: 'integer', + title: 'Vote Count' + }, + air_date: { + type: 'string', + format: 'date', + title: 'Air Date' + }, + episode_number: { + type: 'integer', + title: 'Episode Number' + }, + episode_type: { + type: 'string', + title: 'Episode Type' + }, + production_code: { + type: 'string', + title: 'Production Code' + }, + runtime: { + type: 'integer', + title: 'Runtime' + }, + season_number: { + type: 'integer', + title: 'Season Number' + }, + show_id: { + type: 'integer', + title: 'Show Id' + }, + still_path: { + type: 'string', + title: 'Still Path' + }, + crew: { + items: { + type: 'object' + }, + type: 'array', + title: 'Crew' + }, + guest_stars: { + items: { + type: 'object' + }, + type: 'array', + title: 'Guest Stars' + } + }, + type: 'object', + required: ['id', 'name', 'overview', 'media_type', 'vote_average', 'vote_count', 'air_date', 'episode_number', 'episode_type', 'production_code', 'runtime', 'season_number', 'show_id', 'still_path', 'crew', 'guest_stars'], + title: 'TmdbEpisodeDetails' +} as const; + +export const TmdbEpisodeItemSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + overview: { + type: 'string', + title: 'Overview' + }, + media_type: { + type: 'string', + enum: ['tv_episode'], + const: 'tv_episode', + title: 'Media Type' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + vote_count: { + type: 'integer', + title: 'Vote Count' + }, + air_date: { + type: 'string', + format: 'date', + title: 'Air Date' + }, + episode_number: { + type: 'integer', + title: 'Episode Number' + }, + episode_type: { + type: 'string', + title: 'Episode Type' + }, + production_code: { + type: 'string', + title: 'Production Code' + }, + runtime: { + type: 'integer', + title: 'Runtime' + }, + season_number: { + type: 'integer', + title: 'Season Number' + }, + show_id: { + type: 'integer', + title: 'Show Id' + }, + still_path: { + type: 'string', + title: 'Still Path' + } + }, + type: 'object', + required: ['id', 'name', 'overview', 'media_type', 'vote_average', 'vote_count', 'air_date', 'episode_number', 'episode_type', 'production_code', 'runtime', 'season_number', 'show_id', 'still_path'], + title: 'TmdbEpisodeItem' +} as const; + +export const TmdbFindResultsSchema = { + properties: { + movie_results: { + items: { + '$ref': '#/components/schemas/TmdbItem' + }, + type: 'array', + title: 'Movie Results' + }, + tv_results: { + items: { + '$ref': '#/components/schemas/TmdbItem' + }, + type: 'array', + title: 'Tv Results' + }, + tv_episode_results: { + items: { + '$ref': '#/components/schemas/TmdbEpisodeItem' + }, + type: 'array', + title: 'Tv Episode Results' + }, + tv_season_results: { + items: { + '$ref': '#/components/schemas/TmdbSeasonItem' + }, + type: 'array', + title: 'Tv Season Results' + } + }, + type: 'object', + required: ['movie_results', 'tv_results', 'tv_episode_results', 'tv_season_results'], + title: 'TmdbFindResults' +} as const; + +export const TmdbItemSchema = { + properties: { + adult: { + type: 'boolean', + title: 'Adult' + }, + backdrop_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Backdrop Path' + }, + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + original_title: { + type: 'string', + title: 'Original Title' + }, + original_language: { + type: 'string', + title: 'Original Language' + }, + overview: { + type: 'string', + title: 'Overview' + }, + poster_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Poster Path' + }, + media_type: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbMediaType' + }, + { + type: 'null' + } + ] + }, + genre_ids: { + items: { + type: 'integer' + }, + type: 'array', + title: 'Genre Ids' + }, + popularity: { + type: 'number', + title: 'Popularity' + }, + release_date: { + type: 'string', + title: 'Release Date' + }, + video: { + type: 'boolean', + title: 'Video' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + vote_count: { + type: 'integer', + title: 'Vote Count' + } + }, + type: 'object', + required: ['adult', 'backdrop_path', 'id', 'title', 'original_title', 'original_language', 'overview', 'poster_path', 'genre_ids', 'popularity', 'release_date', 'video', 'vote_average', 'vote_count'], + title: 'TmdbItem' +} as const; + +export const TmdbMediaTypeSchema = { + type: 'string', + enum: ['movie', 'tv', 'tv_episode', 'tv_season'], + title: 'TmdbMediaType' +} as const; + +export const TmdbMovieDetailsSchema = { + properties: { + adult: { + type: 'boolean', + title: 'Adult' + }, + backdrop_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Backdrop Path' + }, + belongs_to_collection: { + anyOf: [ + { + '$ref': '#/components/schemas/BelongsToCollection' + }, + { + type: 'null' + } + ] + }, + budget: { + type: 'integer', + title: 'Budget' + }, + genres: { + items: { + '$ref': '#/components/schemas/Genre' + }, + type: 'array', + title: 'Genres' + }, + homepage: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Homepage' + }, + id: { + type: 'integer', + title: 'Id' + }, + imdb_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Imdb Id' + }, + original_language: { + type: 'string', + title: 'Original Language' + }, + original_title: { + type: 'string', + title: 'Original Title' + }, + overview: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Overview' + }, + popularity: { + type: 'number', + title: 'Popularity' + }, + poster_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Poster Path' + }, + production_companies: { + items: { + '$ref': '#/components/schemas/ProductionCompany' + }, + type: 'array', + title: 'Production Companies' + }, + production_countries: { + items: { + '$ref': '#/components/schemas/ProductionCountry' + }, + type: 'array', + title: 'Production Countries' + }, + release_date: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Release Date' + }, + revenue: { + type: 'integer', + title: 'Revenue' + }, + runtime: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Runtime' + }, + spoken_languages: { + items: { + '$ref': '#/components/schemas/SpokenLanguage' + }, + type: 'array', + title: 'Spoken Languages' + }, + status: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Status' + }, + tagline: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Tagline' + }, + title: { + type: 'string', + title: 'Title' + }, + video: { + type: 'boolean', + title: 'Video' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + vote_count: { + type: 'integer', + title: 'Vote Count' + } + }, + type: 'object', + required: ['adult', 'backdrop_path', 'belongs_to_collection', 'budget', 'genres', 'homepage', 'id', 'imdb_id', 'original_language', 'original_title', 'overview', 'popularity', 'poster_path', 'production_companies', 'production_countries', 'release_date', 'revenue', 'runtime', 'spoken_languages', 'status', 'tagline', 'title', 'video', 'vote_average', 'vote_count'], + title: 'TmdbMovieDetails' +} as const; + +export const TmdbPagedResultsWithDates_TmdbItem_Schema = { + properties: { + page: { + type: 'integer', + title: 'Page' + }, + results: { + items: { + '$ref': '#/components/schemas/TmdbItem' + }, + type: 'array', + title: 'Results' + }, + total_pages: { + type: 'integer', + title: 'Total Pages' + }, + total_results: { + type: 'integer', + title: 'Total Results' + }, + dates: { + '$ref': '#/components/schemas/Dates' + } + }, + type: 'object', + required: ['page', 'results', 'total_pages', 'total_results', 'dates'], + title: 'TmdbPagedResultsWithDates[TmdbItem]' +} as const; + +export const TmdbPagedResults_TmdbCollectionDetails_Schema = { + properties: { + page: { + type: 'integer', + title: 'Page' + }, + results: { + items: { + '$ref': '#/components/schemas/TmdbCollectionDetails' + }, + type: 'array', + title: 'Results' + }, + total_pages: { + type: 'integer', + title: 'Total Pages' + }, + total_results: { + type: 'integer', + title: 'Total Results' + } + }, + type: 'object', + required: ['page', 'results', 'total_pages', 'total_results'], + title: 'TmdbPagedResults[TmdbCollectionDetails]' +} as const; + +export const TmdbPagedResults_TmdbItem_Schema = { + properties: { + page: { + type: 'integer', + title: 'Page' + }, + results: { + items: { + '$ref': '#/components/schemas/TmdbItem' + }, + type: 'array', + title: 'Results' + }, + total_pages: { + type: 'integer', + title: 'Total Pages' + }, + total_results: { + type: 'integer', + title: 'Total Results' + } + }, + type: 'object', + required: ['page', 'results', 'total_pages', 'total_results'], + title: 'TmdbPagedResults[TmdbItem]' +} as const; + +export const TmdbResponse_TmdbEpisodeDetails_Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbEpisodeDetails' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbEpisodeDetails]' +} as const; + +export const TmdbResponse_TmdbFindResults_Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbFindResults' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbFindResults]' +} as const; + +export const TmdbResponse_TmdbMovieDetails_Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbMovieDetails' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbMovieDetails]' +} as const; + +export const TmdbResponse_TmdbPagedResultsWithDates_TmdbItem__Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbPagedResultsWithDates_TmdbItem_' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbPagedResultsWithDates[TmdbItem]]' +} as const; + +export const TmdbResponse_TmdbPagedResults_TmdbCollectionDetails__Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbPagedResults_TmdbCollectionDetails_' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbPagedResults[TmdbCollectionDetails]]' +} as const; + +export const TmdbResponse_TmdbPagedResults_TmdbItem__Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbPagedResults_TmdbItem_' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbPagedResults[TmdbItem]]' +} as const; + +export const TmdbResponse_TmdbSeasonDetails_Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbSeasonDetails' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbSeasonDetails]' +} as const; + +export const TmdbResponse_TmdbTVDetails_Schema = { + properties: { + success: { + type: 'boolean', + title: 'Success' + }, + data: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbTVDetails' + }, + { + type: 'null' + } + ] + }, + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message' + } + }, + type: 'object', + required: ['success'], + title: 'TmdbResponse[TmdbTVDetails]' +} as const; + +export const TmdbSeasonDetailsSchema = { + properties: { + air_date: { + type: 'string', + title: 'Air Date' + }, + episodes: { + items: { + '$ref': '#/components/schemas/TmdbEpisodeDetails' + }, + type: 'array', + title: 'Episodes' + } + }, + type: 'object', + required: ['air_date', 'episodes'], + title: 'TmdbSeasonDetails' +} as const; + +export const TmdbSeasonItemSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + overview: { + type: 'string', + title: 'Overview' + }, + poster_path: { + type: 'string', + title: 'Poster Path' + }, + media_type: { + type: 'string', + enum: ['tv_season'], + const: 'tv_season', + title: 'Media Type' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + air_date: { + type: 'string', + format: 'date', + title: 'Air Date' + }, + season_number: { + type: 'integer', + title: 'Season Number' + }, + show_id: { + type: 'integer', + title: 'Show Id' + }, + episode_count: { + type: 'integer', + title: 'Episode Count' + } + }, + type: 'object', + required: ['id', 'name', 'overview', 'poster_path', 'media_type', 'vote_average', 'air_date', 'season_number', 'show_id', 'episode_count'], + title: 'TmdbSeasonItem' +} as const; + +export const TmdbTVDetailsSchema = { + properties: { + adult: { + type: 'boolean', + title: 'Adult' + }, + backdrop_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Backdrop Path' + }, + episode_run_time: { + items: { + type: 'integer' + }, + type: 'array', + title: 'Episode Run Time' + }, + first_air_date: { + type: 'string', + title: 'First Air Date' + }, + genres: { + items: { + '$ref': '#/components/schemas/Genre' + }, + type: 'array', + title: 'Genres' + }, + homepage: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Homepage' + }, + id: { + type: 'integer', + title: 'Id' + }, + in_production: { + type: 'boolean', + title: 'In Production' + }, + languages: { + items: { + type: 'string' + }, + type: 'array', + title: 'Languages' + }, + last_air_date: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Last Air Date' + }, + last_episode_to_air: { + anyOf: [ + { + '$ref': '#/components/schemas/TmdbEpisodeItem' + }, + { + type: 'null' + } + ] + }, + name: { + type: 'string', + title: 'Name' + }, + next_episode_to_air: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Next Episode To Air' + }, + networks: { + items: { + '$ref': '#/components/schemas/Network' + }, + type: 'array', + title: 'Networks' + }, + number_of_episodes: { + type: 'integer', + title: 'Number Of Episodes' + }, + number_of_seasons: { + type: 'integer', + title: 'Number Of Seasons' + }, + origin_country: { + items: { + type: 'string' + }, + type: 'array', + title: 'Origin Country' + }, + original_language: { + type: 'string', + title: 'Original Language' + }, + original_name: { + type: 'string', + title: 'Original Name' + }, + overview: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Overview' + }, + popularity: { + type: 'number', + title: 'Popularity' + }, + poster_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Poster Path' + }, + production_companies: { + items: { + '$ref': '#/components/schemas/ProductionCompany' + }, + type: 'array', + title: 'Production Companies' + }, + production_countries: { + items: { + '$ref': '#/components/schemas/ProductionCountry' + }, + type: 'array', + title: 'Production Countries' + }, + seasons: { + items: { + '$ref': '#/components/schemas/TmdbSeasonItem' + }, + type: 'array', + title: 'Seasons' + }, + spoken_languages: { + items: { + type: 'string' + }, + type: 'array', + title: 'Spoken Languages' + }, + status: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Status' + }, + tagline: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Tagline' + }, + type: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Type' + }, + vote_average: { + type: 'number', + title: 'Vote Average' + }, + vote_count: { + type: 'integer', + title: 'Vote Count' + } + }, + type: 'object', + required: ['adult', 'backdrop_path', 'episode_run_time', 'first_air_date', 'genres', 'homepage', 'id', 'in_production', 'languages', 'last_air_date', 'last_episode_to_air', 'name', 'next_episode_to_air', 'networks', 'number_of_episodes', 'number_of_seasons', 'origin_country', 'original_language', 'original_name', 'overview', 'popularity', 'poster_path', 'production_companies', 'production_countries', 'seasons', 'spoken_languages', 'status', 'tagline', 'type', 'vote_average', 'vote_count'], + title: 'TmdbTVDetails' +} as const; + +export const TorBoxScraperConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + } + }, + type: 'object', + title: 'TorBoxScraperConfig' +} as const; + +export const TorboxModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + } + }, + type: 'object', + title: 'TorboxModel' +} as const; + +export const TorrentioConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + filter: { + type: 'string', + title: 'Filter', + default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://torrentio.strem.fun' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'TorrentioConfig' +} as const; + +export const TraktModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + watchlist: { + items: { + type: 'string' + }, + type: 'array', + title: 'Watchlist', + default: [] + }, + user_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'User Lists', + default: [] + }, + collection: { + items: { + type: 'string' + }, + type: 'array', + title: 'Collection', + default: [] + }, + fetch_trending: { + type: 'boolean', + title: 'Fetch Trending', + default: false + }, + trending_count: { + type: 'integer', + title: 'Trending Count', + default: 10 + }, + fetch_popular: { + type: 'boolean', + title: 'Fetch Popular', + default: false + }, + popular_count: { + type: 'integer', + title: 'Popular Count', + default: 10 + } + }, + type: 'object', + title: 'TraktModel' +} as const; + +export const TraktOAuthInitiateResponseSchema = { + properties: { + auth_url: { + type: 'string', + title: 'Auth Url' + } + }, + type: 'object', + required: ['auth_url'], + title: 'TraktOAuthInitiateResponse' +} as const; + +export const TrendingTypeSchema = { + type: 'string', + enum: ['all', 'movie', 'tv', 'person'], + title: 'TrendingType' +} as const; + +export const TrendingWindowSchema = { + type: 'string', + enum: ['day', 'week'], + title: 'TrendingWindow' +} as const; + +export const UpdatersModelSchema = { + properties: { + updater_interval: { + type: 'integer', + title: 'Updater Interval', + default: 120 + }, + plex: { + '$ref': '#/components/schemas/PlexLibraryModel', + default: { + enabled: false, + token: '', + url: 'http://localhost:32400' + } + }, + jellyfin: { + '$ref': '#/components/schemas/JellyfinLibraryModel', + default: { + enabled: false, + api_key: '', + url: 'http://localhost:8096' + } + }, + emby: { + '$ref': '#/components/schemas/EmbyLibraryModel', + default: { + enabled: false, + api_key: '', + url: 'http://localhost:8096' + } + } + }, + type: 'object', + title: 'UpdatersModel' +} as const; + +export const ValidationErrorSchema = { + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { + type: 'string', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } + }, + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' +} as const; + +export const ZileanConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8181' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'ZileanConfig' +} as const; \ No newline at end of file diff --git a/src/client/services.gen.ts b/src/client/services.gen.ts new file mode 100644 index 0000000..a841309 --- /dev/null +++ b/src/client/services.gen.ts @@ -0,0 +1,525 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; +import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse2, EventsError, EventsResponse, MountError, MountResponse, OverseerrWebhookOverseerrPostError, OverseerrWebhookOverseerrPostResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse2, SaveSettingsError, SaveSettingsResponse2, GetAllSettingsError, GetAllSettingsResponse2, GetSettingsData, GetSettingsError, GetSettingsResponse2, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse2, SetSettingsSettingsSetPostData, SetSettingsSettingsSetPostError, SetSettingsSettingsSetPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse2, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, SetTorrentRdMagnetData, SetTorrentRdMagnetError, SetTorrentRdMagnetResponse, SetTorrentRdItemsIdSetTorrentRdPostData, SetTorrentRdItemsIdSetTorrentRdPostError, SetTorrentRdItemsIdSetTorrentRdPostResponse, ScrapeData, ScrapeError, ScrapeResponse2, GetRdTorrentsData, GetRdTorrentsError, GetRdTorrentsResponse, GetTrendingData, GetTrendingError, GetTrendingResponse, GetMoviesNowPlayingData, GetMoviesNowPlayingError, GetMoviesNowPlayingResponse, GetMoviesPopularData, GetMoviesPopularError, GetMoviesPopularResponse, GetMoviesTopRatedData, GetMoviesTopRatedError, GetMoviesTopRatedResponse, GetMoviesUpcomingData, GetMoviesUpcomingError, GetMoviesUpcomingResponse, GetMovieDetailsData, GetMovieDetailsError, GetMovieDetailsResponse, GetTvAiringTodayData, GetTvAiringTodayError, GetTvAiringTodayResponse, GetTvOnTheAirData, GetTvOnTheAirError, GetTvOnTheAirResponse, GetTvPopularData, GetTvPopularError, GetTvPopularResponse, GetTvTopRatedData, GetTvTopRatedError, GetTvTopRatedResponse, GetTvDetailsData, GetTvDetailsError, GetTvDetailsResponse, GetTvSeasonDetailsData, GetTvSeasonDetailsError, GetTvSeasonDetailsResponse, GetTvEpisodeDetailsData, GetTvEpisodeDetailsError, GetTvEpisodeDetailsResponse, SearchCollectionData, SearchCollectionError, SearchCollectionResponse, SearchMovieData, SearchMovieError, SearchMovieResponse, SearchMultiData, SearchMultiError, SearchMultiResponse, SearchTvData, SearchTvError, SearchTvResponse, GetFromExternalIdData, GetFromExternalIdError, GetFromExternalIdResponse } from './types.gen'; + +export const client = createClient(createConfig()); + +export class DefaultService { + /** + * Root + */ + public static root(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/' + }); + } + + /** + * Health + */ + public static health(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/health' + }); + } + + /** + * Get Rd User + */ + public static rd(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/rd' + }); + } + + /** + * Get Torbox User + */ + public static torbox(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/torbox' + }); + } + + /** + * Get Services + */ + public static services(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/services' + }); + } + + /** + * Initiate Trakt Oauth + */ + public static traktOauthInitiate(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/trakt/oauth/initiate' + }); + } + + /** + * Trakt Oauth Callback + */ + public static traktOauthCallback(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/trakt/oauth/callback' + }); + } + + /** + * Get Stats + */ + public static stats(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/stats' + }); + } + + /** + * Get Logs + */ + public static logs(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/logs' + }); + } + + /** + * Get Events + */ + public static events(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/events' + }); + } + + /** + * Get Rclone Files + * Get all files in the rclone mount. + */ + public static mount(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/mount' + }); + } + + /** + * Overseerr + * Webhook for Overseerr + */ + public static overseerrWebhookOverseerrPost(options?: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/webhook/overseerr' + }); + } + +} + +export class SettingsService { + /** + * Get Settings Schema + * Get the JSON schema for the settings. + */ + public static getSettingsSchema(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/settings/schema' + }); + } + + /** + * Load Settings + */ + public static loadSettings(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/settings/load' + }); + } + + /** + * Save Settings + */ + public static saveSettings(options?: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/settings/save' + }); + } + + /** + * Get All Settings + */ + public static getAllSettings(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/settings/get/all' + }); + } + + /** + * Get Settings + */ + public static getSettings(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/settings/get/{paths}' + }); + } + + /** + * Set All Settings + */ + public static setAllSettings(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/settings/set/all' + }); + } + + /** + * Set Settings + */ + public static setSettingsSettingsSetPost(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/settings/set' + }); + } + +} + +export class ItemsService { + /** + * Get States + */ + public static getStates(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/items/states' + }); + } + + /** + * Retrieve Media Items + * Fetch media items with optional filters and pagination + */ + public static getItems(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/items' + }); + } + + /** + * Add Media Items + * Add media items with bases on imdb IDs + */ + public static addItems(options?: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/items/add' + }); + } + + /** + * Retrieve Media Item + * Fetch a single media item by ID + */ + public static getItem(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/items/{id}' + }); + } + + /** + * Retrieve Media Items By IMDb IDs + * Fetch media items by IMDb IDs + */ + public static getItemsByImdbIds(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/items/{imdb_ids}' + }); + } + + /** + * Reset Media Items + * Reset media items with bases on item IDs + */ + public static resetItems(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/items/reset' + }); + } + + /** + * Retry Media Items + * Retry media items with bases on item IDs + */ + public static retryItems(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/items/retry' + }); + } + + /** + * Remove Media Items + * Remove media items based on item IDs + */ + public static removeItem(options: Options) { + return (options?.client ?? client).delete({ + ...options, + url: '/items/remove' + }); + } + + /** + * Set Torrent Rd Magnet + * Set a torrent for a media item using a magnet link. + */ + public static setTorrentRdMagnet(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/items/{id}/set_torrent_rd_magnet' + }); + } + + /** + * Set Torrent Rd + * Set a torrent for a media item using RD torrent ID. + */ + public static setTorrentRdItemsIdSetTorrentRdPost(options: Options) { + return (options?.client ?? client).post({ + ...options, + url: '/items/{id}/set_torrent_rd' + }); + } + +} + +export class ScrapeService { + /** + * Scrape Media Item + * Scrape media item based on IMDb ID. + */ + public static scrape(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/scrape' + }); + } + + /** + * Get Real-Debrid Torrents + * Get torrents from Real-Debrid. + */ + public static getRdTorrents(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/scrape/rd' + }); + } + +} + +export class TmdbService { + /** + * Get Trending + */ + public static getTrending(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/trending/{type}/{window}' + }); + } + + /** + * Get Movies Now Playing + */ + public static getMoviesNowPlaying(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/movie/now_playing' + }); + } + + /** + * Get Movies Popular + */ + public static getMoviesPopular(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/movie/popular' + }); + } + + /** + * Get Movies Top Rated + */ + public static getMoviesTopRated(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/movie/top_rated' + }); + } + + /** + * Get Movies Upcoming + */ + public static getMoviesUpcoming(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/movie/upcoming' + }); + } + + /** + * Get Movie Details + */ + public static getMovieDetails(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/movie/{movie_id}' + }); + } + + /** + * Get Tv Airing Today + */ + public static getTvAiringToday(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/airing_today' + }); + } + + /** + * Get Tv On The Air + */ + public static getTvOnTheAir(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/on_the_air' + }); + } + + /** + * Get Tv Popular + */ + public static getTvPopular(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/popular' + }); + } + + /** + * Get Tv Top Rated + */ + public static getTvTopRated(options?: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/top_rated' + }); + } + + /** + * Get Tv Details + */ + public static getTvDetails(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/{series_id}' + }); + } + + /** + * Get Tv Season Details + */ + public static getTvSeasonDetails(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/{series_id}/season/{season_number}' + }); + } + + /** + * Get Tv Episode Details + */ + public static getTvEpisodeDetails(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/tv/{series_id}/season/{season_number}/episode/{episode_number}' + }); + } + + /** + * Search Collection + */ + public static searchCollection(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/search/collection' + }); + } + + /** + * Search Movie + */ + public static searchMovie(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/search/movie' + }); + } + + /** + * Search Multi + */ + public static searchMulti(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/search/multi' + }); + } + + /** + * Search Tv + */ + public static searchTv(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/search/tv' + }); + } + + /** + * Get From External Id + */ + public static getFromExternalId(options: Options) { + return (options?.client ?? client).get({ + ...options, + url: '/tmdb/external_id/{external_id}' + }); + } + +} \ No newline at end of file diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts new file mode 100644 index 0000000..402f6be --- /dev/null +++ b/src/client/types.gen.ts @@ -0,0 +1,1278 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AddItemsResponse = { + success: boolean; + message: string; +}; + +export type AllDebridModel = { + enabled?: boolean; + api_key?: string; + proxy_enabled?: boolean; + proxy_url?: string; +}; + +export type AnnatarConfig = { + enabled?: boolean; + url?: string; + limit?: number; + timeout?: number; + ratelimit?: boolean; +}; + +export type AppModel = { + version?: string; + debug?: boolean; + log?: boolean; + force_refresh?: boolean; + map_metadata?: boolean; + tracemalloc?: boolean; + symlink?: SymlinkModel; + updaters?: UpdatersModel; + downloaders?: DownloadersModel; + content?: ContentModel; + scraping?: ScraperModel; + ranking?: RTNSettingsModel; + indexer?: IndexerModel; + database?: DatabaseModel; + notifications?: NotificationsModel; + post_processing?: PostProcessing; +}; + +export type BelongsToCollection = { + id: number; + name: string; + poster_path: (string | null); + backdrop_path: (string | null); +}; + +export type CometConfig = { + enabled?: boolean; + url?: string; + indexers?: Array<(string)>; + timeout?: number; + ratelimit?: boolean; +}; + +export type ContentModel = { + overseerr?: OverseerrModel; + plex_watchlist?: PlexWatchlistModel; + mdblist?: MdblistModel; + listrr?: ListrrModel; + trakt?: TraktModel; +}; + +/** + * Custom Ranks used in SettingsModel. + */ +export type CustomRank = { + fetch?: boolean; + use_custom_rank?: boolean; + rank?: number; +}; + +export type DataAndSuccessResponse_RDUser_ = { + data: RDUser; + success: boolean; +}; + +export type DataAndSuccessResponse_StatsResponse_ = { + data: StatsResponse; + success: boolean; +}; + +export type DataAndSuccessResponse_dict_ = { + data: { + [key: string]: unknown; + }; + success: boolean; +}; + +export type DataAndSuccessResponse_dict_str__list_EventUpdate___ = { + data: { + [key: string]: Array; + }; + success: boolean; +}; + +export type DataAndSuccessResponse_dict_str__str__ = { + data: { + [key: string]: (string); + }; + success: boolean; +}; + +export type DatabaseModel = { + host?: string; +}; + +export type Dates = { + maximum: string; + minimum: string; +}; + +export type DownloadersModel = { + video_extensions?: Array<(string)>; + prefer_speed_over_quality?: boolean; + real_debrid?: RealDebridModel; + all_debrid?: AllDebridModel; + torbox?: TorboxModel; +}; + +export type EmbyLibraryModel = { + enabled?: boolean; + api_key?: string; + url?: string; +}; + +export type EventUpdate = { + item_id: number; + imdb_id: string; + title: string; + type: string; + emitted_by: string; + run_at: string; + last_state: string; +}; + +export type ExternalIDExternalSource = 'imdb_id' | 'facebook_id' | 'instagram_id' | 'tvdb_id' | 'tiktok_id' | 'twitter_id' | 'wikidata_id' | 'youtube_id'; + +export type Genre = { + id: number; + name: string; +}; + +export type GetAllSettingsResponse = { + success: boolean; + data: AppModel; +}; + +export type GetSettingsResponse = { + success: boolean; + data: { + [key: string]: unknown; + }; +}; + +export type HTTPValidationError = { + detail?: Array; +}; + +export type IncludeAdult = 'true' | 'false'; + +export type IndexerModel = { + update_interval?: number; +}; + +export type ItemResponse = { + success: boolean; + item: { + [key: string]: unknown; + }; +}; + +export type ItemsByImdbResponse = { + success: boolean; + items: Array<{ + [key: string]: unknown; + }>; +}; + +export type ItemsResponse = { + success: boolean; + items: Array<{ + [key: string]: unknown; + }>; + page: number; + limit: number; + total_items: number; + total_pages: number; +}; + +export type JackettConfig = { + enabled?: boolean; + url?: string; + api_key?: string; + timeout?: number; + ratelimit?: boolean; +}; + +export type JellyfinLibraryModel = { + enabled?: boolean; + api_key?: string; + url?: string; +}; + +export type KnightcrawlerConfig = { + enabled?: boolean; + filter?: string; + url?: string; + timeout?: number; + ratelimit?: boolean; +}; + +export type ListrrModel = { + update_interval?: number; + enabled?: boolean; + movie_lists?: Array<(string)>; + show_lists?: Array<(string)>; + api_key?: string; +}; + +export type LoadSettingsResponse = { + success: boolean; + message: string; +}; + +export type LogsResponse = { + success: boolean; + logs: string; +}; + +export type MdblistModel = { + update_interval?: number; + enabled?: boolean; + api_key?: string; + lists?: Array<(string | number)>; +}; + +export type MediafusionConfig = { + enabled?: boolean; + url?: string; + timeout?: number; + ratelimit?: boolean; + catalogs?: Array<(string)>; +}; + +export type MessageAndSuccessResponse = { + message: string; + success: boolean; +}; + +export type Network = { + id: number; + logo_path: (string | null); + name: string; + origin_country: string; +}; + +export type NotificationsModel = { + enabled?: boolean; + title?: string; + on_item_type?: Array<(string)>; + service_urls?: Array<(string)>; +}; + +export type OrionoidConfig = { + enabled?: boolean; + api_key?: string; + cached_results_only?: boolean; + parameters?: { + [key: string]: unknown; + }; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + +export type OverseerrModel = { + update_interval?: number; + enabled?: boolean; + url?: string; + api_key?: string; + use_webhook?: boolean; +}; + +export type PlexLibraryModel = { + enabled?: boolean; + token?: string; + url?: string; +}; + +export type PlexWatchlistModel = { + update_interval?: number; + enabled?: boolean; + rss?: Array<(string)>; +}; + +export type PostProcessing = { + subliminal?: SubliminalConfig; +}; + +export type ProductionCompany = { + id: number; + logo_path: (string | null); + name: string; + origin_country: string; +}; + +export type ProductionCountry = { + iso_3166_1: string; + name: string; +}; + +export type ProwlarrConfig = { + enabled?: boolean; + url?: string; + api_key?: string; + timeout?: number; + ratelimit?: boolean; + limiter_seconds?: number; +}; + +export type RDTorrent = { + id: string; + hash: string; + filename: string; + bytes: number; + status: RDTorrentStatus; + added: string; + links: Array<(string)>; + ended?: (string | null); + speed?: (number | null); + seeders?: (number | null); +}; + +export type RDTorrentStatus = 'magnet_error' | 'magnet_conversion' | 'waiting_files_selection' | 'downloading' | 'downloaded' | 'error' | 'seeding' | 'dead' | 'uploading' | 'compressing'; + +export type RDUser = { + id: number; + username: string; + email: string; + /** + * User's RD points + */ + points: number; + locale: string; + /** + * URL to the user's avatar + */ + avatar: string; + type: 'free' | 'premium'; + /** + * Premium subscription left in seconds + */ + premium: number; +}; + +export type type = 'free' | 'premium'; + +export type RTNSettingsModel = { + profile?: string; + require?: Array<(string)>; + exclude?: Array<(string)>; + preferred?: Array<(string)>; + resolutions?: { + [key: string]: (boolean); + }; + options?: { + [key: string]: unknown; + }; + languages?: { + [key: string]: unknown; + }; + custom_ranks?: { + [key: string]: { + [key: string]: CustomRank; + }; + }; +}; + +export type RealDebridModel = { + enabled?: boolean; + api_key?: string; + proxy_enabled?: boolean; + proxy_url?: string; +}; + +export type RemoveResponse = { + success: boolean; + message: string; + ids: Array<(number)>; +}; + +export type ResetResponse = { + success: boolean; + message: string; + ids: Array<(string)>; +}; + +export type RetryResponse = { + success: boolean; + message: string; + ids: Array<(string)>; +}; + +export type RootResponse = { + message: string; + success: boolean; + version: string; +}; + +export type SaveSettingsResponse = { + success: boolean; + message: string; +}; + +export type ScrapeResponse = { + success: boolean; + data: Array; +}; + +export type ScrapedTorrent = { + rank: number; + raw_title: string; + infohash: string; +}; + +export type ScraperModel = { + after_2?: number; + after_5?: number; + after_10?: number; + parse_debug?: boolean; + enable_aliases?: boolean; + torrentio?: TorrentioConfig; + knightcrawler?: KnightcrawlerConfig; + jackett?: JackettConfig; + prowlarr?: ProwlarrConfig; + orionoid?: OrionoidConfig; + annatar?: AnnatarConfig; + torbox_scraper?: TorBoxScraperConfig; + mediafusion?: MediafusionConfig; + zilean?: ZileanConfig; + comet?: CometConfig; +}; + +export type SetAllSettingsResponse = { + success: boolean; + message: string; +}; + +export type SetSettings = { + key: string; + value: unknown; +}; + +export type SetSettingsResponse = { + success: boolean; + message: string; +}; + +export type SetTorrentRDResponse = { + success: boolean; + message: string; + item_id: number; + torrent_id: string; +}; + +export type SpokenLanguage = { + english_name: string; + iso_639_1: string; + name: string; +}; + +export type StateResponse = { + success: boolean; + states: Array<(string)>; +}; + +export type States = 'Unknown' | 'Unreleased' | 'Ongoing' | 'Requested' | 'Indexed' | 'Scraped' | 'Downloaded' | 'Symlinked' | 'Completed' | 'PartiallyCompleted' | 'Failed'; + +export type StatsResponse = { + total_items: number; + total_movies: number; + total_shows: number; + total_seasons: number; + total_episodes: number; + total_symlinks: number; + incomplete_items: number; + /** + * Media item log string: number of retries + */ + incomplete_retries: { + [key: string]: (number); + }; + states: { + [key: string]: (number); + }; +}; + +export type SubliminalConfig = { + enabled?: boolean; + languages?: Array<(string)>; + providers?: { + [key: string]: unknown; + }; +}; + +export type SymlinkModel = { + rclone_path?: string; + library_path?: string; + separate_anime_dirs?: boolean; + repair_symlinks?: boolean; + repair_interval?: number; +}; + +export type TmdbCollectionDetails = { + adult: boolean; + backdrop_path: (string | null); + id: number; + name: string; + overview: string; + original_language: string; + original_name: string; + poster_path: (string | null); +}; + +export type TmdbEpisodeDetails = { + id: number; + name: string; + overview: string; + media_type: 'tv_episode'; + vote_average: number; + vote_count: number; + air_date: string; + episode_number: number; + episode_type: string; + production_code: string; + runtime: number; + season_number: number; + show_id: number; + still_path: string; + crew: Array<{ + [key: string]: unknown; + }>; + guest_stars: Array<{ + [key: string]: unknown; + }>; +}; + +export type media_type = 'tv_episode'; + +export type TmdbEpisodeItem = { + id: number; + name: string; + overview: string; + media_type: 'tv_episode'; + vote_average: number; + vote_count: number; + air_date: string; + episode_number: number; + episode_type: string; + production_code: string; + runtime: number; + season_number: number; + show_id: number; + still_path: string; +}; + +export type TmdbFindResults = { + movie_results: Array; + tv_results: Array; + tv_episode_results: Array; + tv_season_results: Array; +}; + +export type TmdbItem = { + adult: boolean; + backdrop_path: (string | null); + id: number; + title: string; + original_title: string; + original_language: string; + overview: string; + poster_path: (string | null); + media_type?: (TmdbMediaType | null); + genre_ids: Array<(number)>; + popularity: number; + release_date: string; + video: boolean; + vote_average: number; + vote_count: number; +}; + +export type TmdbMediaType = 'movie' | 'tv' | 'tv_episode' | 'tv_season'; + +export type TmdbMovieDetails = { + adult: boolean; + backdrop_path: (string | null); + belongs_to_collection: (BelongsToCollection | null); + budget: number; + genres: Array; + homepage: (string | null); + id: number; + imdb_id: (string | null); + original_language: string; + original_title: string; + overview: (string | null); + popularity: number; + poster_path: (string | null); + production_companies: Array; + production_countries: Array; + release_date: (string | null); + revenue: number; + runtime: (number | null); + spoken_languages: Array; + status: (string | null); + tagline: (string | null); + title: string; + video: boolean; + vote_average: number; + vote_count: number; +}; + +export type TmdbPagedResultsWithDates_TmdbItem_ = { + page: number; + results: Array; + total_pages: number; + total_results: number; + dates: Dates; +}; + +export type TmdbPagedResults_TmdbCollectionDetails_ = { + page: number; + results: Array; + total_pages: number; + total_results: number; +}; + +export type TmdbPagedResults_TmdbItem_ = { + page: number; + results: Array; + total_pages: number; + total_results: number; +}; + +export type TmdbResponse_TmdbEpisodeDetails_ = { + success: boolean; + data?: (TmdbEpisodeDetails | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbFindResults_ = { + success: boolean; + data?: (TmdbFindResults | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbMovieDetails_ = { + success: boolean; + data?: (TmdbMovieDetails | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbPagedResultsWithDates_TmdbItem__ = { + success: boolean; + data?: (TmdbPagedResultsWithDates_TmdbItem_ | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbPagedResults_TmdbCollectionDetails__ = { + success: boolean; + data?: (TmdbPagedResults_TmdbCollectionDetails_ | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbPagedResults_TmdbItem__ = { + success: boolean; + data?: (TmdbPagedResults_TmdbItem_ | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbSeasonDetails_ = { + success: boolean; + data?: (TmdbSeasonDetails | null); + message?: (string | null); +}; + +export type TmdbResponse_TmdbTVDetails_ = { + success: boolean; + data?: (TmdbTVDetails | null); + message?: (string | null); +}; + +export type TmdbSeasonDetails = { + air_date: string; + episodes: Array; +}; + +export type TmdbSeasonItem = { + id: number; + name: string; + overview: string; + poster_path: string; + media_type: 'tv_season'; + vote_average: number; + air_date: string; + season_number: number; + show_id: number; + episode_count: number; +}; + +export type media_type2 = 'tv_season'; + +export type TmdbTVDetails = { + adult: boolean; + backdrop_path: (string | null); + episode_run_time: Array<(number)>; + first_air_date: string; + genres: Array; + homepage: (string | null); + id: number; + in_production: boolean; + languages: Array<(string)>; + last_air_date: (string | null); + last_episode_to_air: (TmdbEpisodeItem | null); + name: string; + next_episode_to_air: (string | null); + networks: Array; + number_of_episodes: number; + number_of_seasons: number; + origin_country: Array<(string)>; + original_language: string; + original_name: string; + overview: (string | null); + popularity: number; + poster_path: (string | null); + production_companies: Array; + production_countries: Array; + seasons: Array; + spoken_languages: Array<(string)>; + status: (string | null); + tagline: (string | null); + type: (string | null); + vote_average: number; + vote_count: number; +}; + +export type TorBoxScraperConfig = { + enabled?: boolean; + timeout?: number; +}; + +export type TorboxModel = { + enabled?: boolean; + api_key?: string; +}; + +export type TorrentioConfig = { + enabled?: boolean; + filter?: string; + url?: string; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + +export type TraktModel = { + update_interval?: number; + enabled?: boolean; + api_key?: string; + watchlist?: Array<(string)>; + user_lists?: Array<(string)>; + collection?: Array<(string)>; + fetch_trending?: boolean; + trending_count?: number; + fetch_popular?: boolean; + popular_count?: number; +}; + +export type TraktOAuthInitiateResponse = { + auth_url: string; +}; + +export type TrendingType = 'all' | 'movie' | 'tv' | 'person'; + +export type TrendingWindow = 'day' | 'week'; + +export type UpdatersModel = { + updater_interval?: number; + plex?: PlexLibraryModel; + jellyfin?: JellyfinLibraryModel; + emby?: EmbyLibraryModel; +}; + +export type ValidationError = { + loc: Array<(string | number)>; + msg: string; + type: string; +}; + +export type ZileanConfig = { + enabled?: boolean; + url?: string; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + +export type RootResponse2 = (RootResponse); + +export type RootError = (unknown); + +export type HealthResponse = (MessageAndSuccessResponse); + +export type HealthError = (unknown); + +export type RdResponse = (DataAndSuccessResponse_RDUser_); + +export type RdError = (unknown); + +export type TorboxResponse = (unknown); + +export type TorboxError = (unknown); + +export type ServicesResponse = (DataAndSuccessResponse_dict_); + +export type ServicesError = (unknown); + +export type TraktOauthInitiateResponse = (TraktOAuthInitiateResponse); + +export type TraktOauthInitiateError = (unknown); + +export type TraktOauthCallbackData = { + query: { + code: string; + }; +}; + +export type TraktOauthCallbackResponse = (MessageAndSuccessResponse); + +export type TraktOauthCallbackError = (unknown | HTTPValidationError); + +export type StatsResponse2 = (DataAndSuccessResponse_StatsResponse_); + +export type StatsError = (unknown); + +export type LogsResponse2 = (LogsResponse); + +export type LogsError = (unknown); + +export type EventsResponse = (DataAndSuccessResponse_dict_str__list_EventUpdate___); + +export type EventsError = (unknown); + +export type MountResponse = (DataAndSuccessResponse_dict_str__str__); + +export type MountError = (unknown); + +export type OverseerrWebhookOverseerrPostResponse = ({ + [key: string]: unknown; +}); + +export type OverseerrWebhookOverseerrPostError = (unknown); + +export type GetSettingsSchemaResponse = ({ + [key: string]: unknown; +}); + +export type GetSettingsSchemaError = (unknown); + +export type LoadSettingsResponse2 = (LoadSettingsResponse); + +export type LoadSettingsError = (unknown); + +export type SaveSettingsResponse2 = (SaveSettingsResponse); + +export type SaveSettingsError = (unknown); + +export type GetAllSettingsResponse2 = (GetAllSettingsResponse); + +export type GetAllSettingsError = (unknown); + +export type GetSettingsData = { + path: { + paths: string; + }; +}; + +export type GetSettingsResponse2 = (GetSettingsResponse); + +export type GetSettingsError = (unknown | HTTPValidationError); + +export type SetAllSettingsData = { + body: { + [key: string]: unknown; + }; +}; + +export type SetAllSettingsResponse2 = (SetAllSettingsResponse); + +export type SetAllSettingsError = (unknown | HTTPValidationError); + +export type SetSettingsSettingsSetPostData = { + body: Array; +}; + +export type SetSettingsSettingsSetPostResponse = (SetSettingsResponse); + +export type SetSettingsSettingsSetPostError = (unknown | HTTPValidationError); + +export type GetStatesResponse = (StateResponse); + +export type GetStatesError = (unknown); + +export type GetItemsData = { + query?: { + extended?: (boolean | null); + is_anime?: (boolean | null); + limit?: (number | null); + page?: (number | null); + search?: (string | null); + sort?: ('date_desc' | 'date_asc' | 'title_asc' | 'title_desc' | null); + states?: (string | null); + type?: (string | null); + }; +}; + +export type GetItemsResponse = (ItemsResponse); + +export type GetItemsError = (unknown | HTTPValidationError); + +export type AddItemsData = { + query?: { + imdb_ids?: string; + }; +}; + +export type AddItemsResponse2 = (AddItemsResponse); + +export type AddItemsError = (unknown | HTTPValidationError); + +export type GetItemData = { + path: { + id: number; + }; +}; + +export type GetItemResponse = (ItemResponse); + +export type GetItemError = (unknown | HTTPValidationError); + +export type GetItemsByImdbIdsData = { + path: { + imdb_ids: string; + }; +}; + +export type GetItemsByImdbIdsResponse = (ItemsByImdbResponse); + +export type GetItemsByImdbIdsError = (unknown | HTTPValidationError); + +export type ResetItemsData = { + query: { + ids: string; + }; +}; + +export type ResetItemsResponse = (ResetResponse); + +export type ResetItemsError = (unknown | HTTPValidationError); + +export type RetryItemsData = { + query: { + ids: string; + }; +}; + +export type RetryItemsResponse = (RetryResponse); + +export type RetryItemsError = (unknown | HTTPValidationError); + +export type RemoveItemData = { + query: { + ids: string; + }; +}; + +export type RemoveItemResponse = (RemoveResponse); + +export type RemoveItemError = (unknown | HTTPValidationError); + +export type SetTorrentRdMagnetData = { + path: { + id: number; + }; + query: { + magnet: string; + }; +}; + +export type SetTorrentRdMagnetResponse = (SetTorrentRDResponse); + +export type SetTorrentRdMagnetError = (unknown | HTTPValidationError); + +export type SetTorrentRdItemsIdSetTorrentRdPostData = { + path: { + id: number; + }; + query: { + torrent_id: string; + }; +}; + +export type SetTorrentRdItemsIdSetTorrentRdPostResponse = (unknown); + +export type SetTorrentRdItemsIdSetTorrentRdPostError = (unknown | HTTPValidationError); + +export type ScrapeData = { + query: { + episode?: number; + imdb_id: string; + season?: number; + }; +}; + +export type ScrapeResponse2 = (ScrapeResponse); + +export type ScrapeError = (HTTPValidationError); + +export type GetRdTorrentsData = { + query?: { + limit?: number; + }; +}; + +export type GetRdTorrentsResponse = (Array); + +export type GetRdTorrentsError = (HTTPValidationError); + +export type GetTrendingData = { + path: { + type: TrendingType; + window: TrendingWindow; + }; + query?: { + language?: string; + page?: number; + }; +}; + +export type GetTrendingResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetTrendingError = (unknown | HTTPValidationError); + +export type GetMoviesNowPlayingData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetMoviesNowPlayingResponse = (TmdbResponse_TmdbPagedResultsWithDates_TmdbItem__); + +export type GetMoviesNowPlayingError = (unknown | HTTPValidationError); + +export type GetMoviesPopularData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetMoviesPopularResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetMoviesPopularError = (unknown | HTTPValidationError); + +export type GetMoviesTopRatedData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetMoviesTopRatedResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetMoviesTopRatedError = (unknown | HTTPValidationError); + +export type GetMoviesUpcomingData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetMoviesUpcomingResponse = (TmdbResponse_TmdbPagedResultsWithDates_TmdbItem__); + +export type GetMoviesUpcomingError = (unknown | HTTPValidationError); + +export type GetMovieDetailsData = { + path: { + movie_id: string; + }; + query?: { + append_to_response?: string; + language?: string; + }; +}; + +export type GetMovieDetailsResponse = (TmdbResponse_TmdbMovieDetails_); + +export type GetMovieDetailsError = (unknown | HTTPValidationError); + +export type GetTvAiringTodayData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetTvAiringTodayResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetTvAiringTodayError = (unknown | HTTPValidationError); + +export type GetTvOnTheAirData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetTvOnTheAirResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetTvOnTheAirError = (unknown | HTTPValidationError); + +export type GetTvPopularData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetTvPopularResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetTvPopularError = (unknown | HTTPValidationError); + +export type GetTvTopRatedData = { + query?: { + language?: string; + page?: number; + }; +}; + +export type GetTvTopRatedResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type GetTvTopRatedError = (unknown | HTTPValidationError); + +export type GetTvDetailsData = { + path: { + series_id: string; + }; + query?: { + append_to_response?: string; + language?: string; + }; +}; + +export type GetTvDetailsResponse = (TmdbResponse_TmdbTVDetails_); + +export type GetTvDetailsError = (unknown | HTTPValidationError); + +export type GetTvSeasonDetailsData = { + path: { + season_number: number; + series_id: number; + }; + query?: { + append_to_response?: string; + language?: string; + }; +}; + +export type GetTvSeasonDetailsResponse = (TmdbResponse_TmdbSeasonDetails_); + +export type GetTvSeasonDetailsError = (unknown | HTTPValidationError); + +export type GetTvEpisodeDetailsData = { + path: { + episode_number: number; + season_number: number; + series_id: number; + }; + query?: { + append_to_response?: string; + language?: string; + }; +}; + +export type GetTvEpisodeDetailsResponse = (TmdbResponse_TmdbEpisodeDetails_); + +export type GetTvEpisodeDetailsError = (unknown | HTTPValidationError); + +export type SearchCollectionData = { + query: { + include_adult?: IncludeAdult; + language?: string; + page?: number; + query: string; + region?: string; + }; +}; + +export type SearchCollectionResponse = (TmdbResponse_TmdbPagedResults_TmdbCollectionDetails__); + +export type SearchCollectionError = (unknown | HTTPValidationError); + +export type SearchMovieData = { + query: { + include_adult?: IncludeAdult; + language?: string; + page?: number; + primary_release_year?: number; + query: string; + region?: string; + year?: number; + }; +}; + +export type SearchMovieResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type SearchMovieError = (unknown | HTTPValidationError); + +export type SearchMultiData = { + query: { + include_adult?: IncludeAdult; + language?: string; + page?: number; + query: string; + }; +}; + +export type SearchMultiResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type SearchMultiError = (unknown | HTTPValidationError); + +export type SearchTvData = { + query: { + first_air_date_year?: number; + include_adult?: IncludeAdult; + language?: string; + page?: number; + query: string; + year?: number; + }; +}; + +export type SearchTvResponse = (TmdbResponse_TmdbPagedResults_TmdbItem__); + +export type SearchTvError = (unknown | HTTPValidationError); + +export type GetFromExternalIdData = { + path: { + external_id: string; + }; + query?: { + external_source?: ExternalIDExternalSource; + language?: string; + }; +}; + +export type GetFromExternalIdResponse = (TmdbResponse_TmdbFindResults_); + +export type GetFromExternalIdError = (unknown | HTTPValidationError); \ No newline at end of file From 0a9c34d5f2e50b030cc86886c694b96d42d56103 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Thu, 3 Oct 2024 20:32:05 +0200 Subject: [PATCH 03/21] feat: migrate library to backend api --- src/routes/library/+page.server.ts | 91 ++++++++++-------------------- src/routes/library/+page.svelte | 2 +- 2 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/routes/library/+page.server.ts b/src/routes/library/+page.server.ts index e780d5d..bec6769 100644 --- a/src/routes/library/+page.server.ts +++ b/src/routes/library/+page.server.ts @@ -1,70 +1,39 @@ import type { PageServerLoad } from './$types'; -import type { Expression, SqlBool } from 'kysely'; -import Fuse from 'fuse.js'; - -const fuseOptions = { - keys: ['_id', 'item_id', 'title'], - threshold: 0.8 -}; - -export const load = (async ({ url, locals }) => { - const limit = Number(url.searchParams.get('limit')) || 24; - const page = Number(url.searchParams.get('page')) || 1; - const types = url.searchParams.get('types'); - const query = url.searchParams.get('query'); - const states = url.searchParams.get('states'); - - let dbQuery = locals.db.selectFrom('MediaItem').selectAll(); - - async function getLibrary() { - if (types) { - const typesArray = types.split(','); - - dbQuery = dbQuery.where((eb) => { - const ors: Expression[] = []; - typesArray.forEach((type) => { - if (type === 'anime') { - ors.push( - eb('is_anime', '=', true).and(eb('type', '=', 'show').or(eb('type', '=', 'movie'))) - ); - } else { - ors.push(eb('type', '=', type)); - } - }); - - return eb.or(ors); - }); +import { ItemsService, type ItemsResponse } from '$/client'; +import { error } from '@sveltejs/kit'; + +export const load = (async ({ url }) => { + + async function getLibraryApi(): Promise { + const limit = Number(url.searchParams.get('limit')) || 24; + const page = Number(url.searchParams.get('page')) || 1; + const types = url.searchParams.get('types'); + const query = url.searchParams.get('query'); + const states = url.searchParams.get('states'); + + const { data, error: itemsError } = await ItemsService.getItems({ + query: { + limit, + page, + states, + type: types ?? "movie,show", + search: query, + sort: "date_desc" + } + }) + + if (data) { + return data; } else { - dbQuery = dbQuery.where((eb) => eb.or([eb('type', '=', 'movie'), eb('type', '=', 'show')])); + console.log(itemsError) + throw error(500, "Couldn't reach backend to get library items"); } - - if (states) { - const statesArray = states.split(','); - dbQuery = dbQuery.where((eb) => { - const ors: Expression[] = []; - statesArray.forEach((state) => { - ors.push(eb('last_state', '=', state)); - }); - - return eb.or(ors); - }); - } - - if (query && query.length > 0) { - dbQuery = dbQuery.orderBy('requested_at', 'desc'); - const fuse = new Fuse(await dbQuery.execute(), fuseOptions); - return fuse.search(query).map((result) => result.item); - } - - dbQuery = dbQuery.orderBy('requested_at', 'desc'); - - return await dbQuery.execute(); } - const library = await getLibrary(); + const { items, total_items } = await getLibraryApi(); return { - library: library.slice((page - 1) * limit, page * limit), - total: library.length + library: items, + total: total_items }; }) satisfies PageServerLoad; diff --git a/src/routes/library/+page.svelte b/src/routes/library/+page.svelte index dd0bab8..bc3ceab 100644 --- a/src/routes/library/+page.svelte +++ b/src/routes/library/+page.svelte @@ -171,7 +171,7 @@
- {#each $library as item (item._id)} + {#each $library as item (item.id)} {/each}
From 278f779666dbb3dcd1f95e4489c73c77f0eff898 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Thu, 3 Oct 2024 21:06:58 +0200 Subject: [PATCH 04/21] feat: migrate single item page --- src/client/schemas.gen.ts | 16 ----- src/client/types.gen.ts | 14 ++--- src/routes/[type]/[id]/+page.server.ts | 20 +++++- src/routes/[type]/[id]/+page.svelte | 67 ++++++++++++--------- src/routes/api/media/[id]/magnet/+server.ts | 19 +++--- 5 files changed, 75 insertions(+), 61 deletions(-) diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts index 7cba915..c1db106 100644 --- a/src/client/schemas.gen.ts +++ b/src/client/schemas.gen.ts @@ -1155,22 +1155,6 @@ export const IndexerModelSchema = { title: 'IndexerModel' } as const; -export const ItemResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - item: { - type: 'object', - title: 'Item' - } - }, - type: 'object', - required: ['success', 'item'], - title: 'ItemResponse' -} as const; - export const ItemsByImdbResponseSchema = { properties: { success: { diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index 402f6be..77ea192 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -164,13 +164,6 @@ export type IndexerModel = { update_interval?: number; }; -export type ItemResponse = { - success: boolean; - item: { - [key: string]: unknown; - }; -}; - export type ItemsByImdbResponse = { success: boolean; items: Array<{ @@ -949,9 +942,14 @@ export type GetItemData = { path: { id: number; }; + query?: { + use_tmdb_id?: (boolean | null); + }; }; -export type GetItemResponse = (ItemResponse); +export type GetItemResponse = ({ + [key: string]: unknown; +}); export type GetItemError = (unknown | HTTPValidationError); diff --git a/src/routes/[type]/[id]/+page.server.ts b/src/routes/[type]/[id]/+page.server.ts index 31655b0..e046580 100644 --- a/src/routes/[type]/[id]/+page.server.ts +++ b/src/routes/[type]/[id]/+page.server.ts @@ -1,3 +1,4 @@ +import { ItemsService } from '$/client'; import type { PageServerLoad } from './$types'; export const load = (async ({ params, locals }) => { @@ -34,7 +35,24 @@ export const load = (async ({ params, locals }) => { } } + const {data} = await ItemsService.getItem({ + path: { + id: id + }, + query: { + use_tmdb_id: true + } + }) + + if(data) { + data.requested_at = new Date(data.requested_at as string) + } + + console.log(dbData, data); + return { - db: dbData + // eslint-disable-next-line @typescript-eslint/no-explicit-any + db: data as any, + data }; }) satisfies PageServerLoad; diff --git a/src/routes/[type]/[id]/+page.svelte b/src/routes/[type]/[id]/+page.svelte index 1519430..0786499 100644 --- a/src/routes/[type]/[id]/+page.svelte +++ b/src/routes/[type]/[id]/+page.svelte @@ -29,6 +29,7 @@ import { Input } from '$lib/components/ui/input'; import * as Select from '$lib/components/ui/select'; import type { Selected } from 'bits-ui'; + import { ItemsService } from '$/client'; export let data: PageData; @@ -36,7 +37,7 @@ let magnetLink = ''; let magnetLoading = false; let isShow = data.db ? data.db.type === 'show' : false; - let selectedMagnetItem: Selected<{ _id: number; file?: string; folder?: string }>; + let selectedMagnetItem: Selected<{ id: string; file?: string; folder?: string }>; $: buttonEnabled = magnetLink && !magnetLoading && (isShow ? selectedMagnetItem : true); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -45,12 +46,14 @@ return seasons.filter((season: any) => season.season_number !== 0); } - async function deleteItem(_id: number) { - const response = await fetch(`/api/media/${_id}`, { - method: 'DELETE' + async function deleteItem(id: number) { + const response = await ItemsService.removeItem({ + query: { + ids: id.toString() + } }); - if (response.ok) { + if (!response.error) { toast.success('Media deleted successfully'); goto('/library'); } else { @@ -58,12 +61,14 @@ } } - async function retryItem(_id: number) { - const response = await fetch(`/api/media/${_id}/retry`, { - method: 'POST' + async function retryItem(id: number) { + const response = await ItemsService.retryItems({ + query: { + ids: id.toString() + } }); - if (response.ok) { + if (!response.error) { toast.success('Media retried successfully'); invalidateAll(); } else { @@ -71,12 +76,14 @@ } } - async function resetItem(_id: number) { - const response = await fetch(`/api/media/${_id}/reset`, { - method: 'POST' - }); + async function resetItem(id: number) { + const response = await ItemsService.resetItems({ + query: { + ids: id.toString() + } + }) - if (response.ok) { + if (!response.error) { toast.success('Media reset successfully'); invalidateAll(); } else { @@ -93,7 +100,7 @@ }); } - async function addMagnetLink(_id: number, magnet: string) { + async function addMagnetLink(id: string, magnet: string) { if (!magnet) { toast.error('Magnet link cannot be empty'); return; @@ -104,17 +111,18 @@ } if (magnetLoading) return; magnetLoading = true; - const id = isShow ? selectedMagnetItem.value._id : _id; - const response = await fetch(`/api/media/${id}/magnet`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' + const idToSet = isShow ? selectedMagnetItem.value.id : id; + const { error } = await ItemsService.setTorrentRdMagnet({ + path: { + id: parseInt(idToSet) }, - body: JSON.stringify({ magnet }) + query: { + magnet + } }); magnetLoading = false; - if (!response.ok) { - toast.error((await response.json()).error ?? 'Unknown error'); + if (error) { + toast.error(error as string ?? 'Unknown error'); return; } toast.success('Magnet link added successfully'); @@ -172,7 +180,8 @@ 'bg-red-500': data.db.last_state === 'Unknown' })} > - {statesName[data.db.last_state]} + { + statesName[(data.db.last_state)]} {/if} @@ -235,7 +244,7 @@ > -

ID: {data.db._id}

+

ID: {data.db.id}

{#if data.db.requested_by}

Requested by: {data.db.requested_by}

{/if} @@ -290,7 +299,7 @@ disabled={!buttonEnabled} on:click={async () => { if (data.db && magnetLink) { - await addMagnetLink(data.db._id, magnetLink); + await addMagnetLink(data.db.id, magnetLink); } }} > @@ -332,7 +341,7 @@ { if (data.db) { - await retryItem(data.db._id); + await retryItem(data.db.id); } }}>Continue @@ -371,7 +380,7 @@ { if (data.db) { - await resetItem(data.db._id); + await resetItem(data.db.id); } }}>Continue @@ -428,7 +437,7 @@ { if (data.db) { - await deleteItem(data.db._id); + await deleteItem(data.db.id); } }}>Continue diff --git a/src/routes/api/media/[id]/magnet/+server.ts b/src/routes/api/media/[id]/magnet/+server.ts index 0a496c0..56f2bce 100644 --- a/src/routes/api/media/[id]/magnet/+server.ts +++ b/src/routes/api/media/[id]/magnet/+server.ts @@ -1,3 +1,4 @@ +import { ItemsService, ScrapeService } from'$/client'; import type { RequestHandler } from './$types'; export const POST: RequestHandler = async ({ params, locals, request }) => { @@ -22,16 +23,20 @@ export const POST: RequestHandler = async ({ params, locals, request }) => { url.searchParams.set('magnet', magnet); try { - const response = await fetch(url, { - method: 'POST' + const {data, error} = await ItemsService.setTorrentRdMagnet({ + path: { + id: parseInt(id) + }, + query: { + magnet: magnet, + } }); - const data = await response.json(); - if (response.ok) { + if (data) { return new Response( JSON.stringify({ success: 'Magnet link added', - data + data: data }), { status: 200, @@ -40,10 +45,10 @@ export const POST: RequestHandler = async ({ params, locals, request }) => { } } ); - } else { + } else if (error) { return new Response( JSON.stringify({ - error: data.detail + error: error }), { status: 500, From 7ec19593b7b33cfbd018eaad7a04c79f6f14a60c Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 11:13:07 +0200 Subject: [PATCH 05/21] feat: migrate season page --- .../[type]/[id]/[season]/+page.server.ts | 27 ------------------- src/routes/[type]/[id]/[season]/+page.svelte | 2 +- src/routes/[type]/[id]/[season]/+page.ts | 22 +++++++++++++-- 3 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 src/routes/[type]/[id]/[season]/+page.server.ts diff --git a/src/routes/[type]/[id]/[season]/+page.server.ts b/src/routes/[type]/[id]/[season]/+page.server.ts deleted file mode 100644 index 00d14bf..0000000 --- a/src/routes/[type]/[id]/[season]/+page.server.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { PageServerLoad } from './$types'; - -export const load = (async ({ locals, params }) => { - const id = Number(params.id); - const season = Number(params.season); - - async function getMediaItemDetails(tvID: number) { - return await locals.db - .selectFrom('MediaItem as show') - .select(['episodeItem.number', 'episodeItem.last_state']) - .innerJoin('Season as season', 'show._id', 'season.parent_id') - .innerJoin('MediaItem as seasonItem', 'seasonItem._id', 'season._id') - .innerJoin('Episode as episode', 'episode.parent_id', 'season._id') - .innerJoin('MediaItem as episodeItem', 'episodeItem._id', 'episode._id') - .where((eb) => - eb.and({ - 'show.tmdb_id': String(tvID), - 'seasonItem.number': season - }) - ) - .distinct() - .execute(); - } - return { - mediaItemDetails: await getMediaItemDetails(id) - }; -}) satisfies PageServerLoad; diff --git a/src/routes/[type]/[id]/[season]/+page.svelte b/src/routes/[type]/[id]/[season]/+page.svelte index f1c10ec..7aa2765 100644 --- a/src/routes/[type]/[id]/[season]/+page.svelte +++ b/src/routes/[type]/[id]/[season]/+page.svelte @@ -98,7 +98,7 @@ > {statesName[ data.mediaItemDetails.find((x) => x.number == episode.episode_number) - ?.last_state ?? 'Unknown' + ?.state ?? 'Unknown' ]} {/if} diff --git a/src/routes/[type]/[id]/[season]/+page.ts b/src/routes/[type]/[id]/[season]/+page.ts index 5ca41ed..553756b 100644 --- a/src/routes/[type]/[id]/[season]/+page.ts +++ b/src/routes/[type]/[id]/[season]/+page.ts @@ -1,8 +1,10 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { PageLoad } from './$types'; import { getTVSeasonDetails, getTVDetails } from '$lib/tmdb'; import { error } from '@sveltejs/kit'; +import { ItemsService } from '$/client'; -export const load = (async ({ data, fetch, params }) => { +export const load = (async ({ fetch, params }) => { const type = params.type; const id = Number(params.id); const season = Number(params.season); @@ -20,12 +22,28 @@ export const load = (async ({ data, fetch, params }) => { return await getTVDetails(fetch, 'en-US', null, tvID); } + async function getMediaItemDetails(tvID: number): Promise { + const { data } = await ItemsService.getItem({ + path: { + id: tvID + }, + query: { + use_tmdb_id: true, + } + }); + if(!data) { + throw error(404, 'Media item not found'); + } + const anyData = data as any; + return anyData.seasons.find((seasonItem: any) => seasonItem.number === season).episodes; + } + return { details: await getDetails(id, season), mediaDetails: await mediaDetails(id), mediaType: type, mediaID: id, seasonNumber: season, - ...data + mediaItemDetails: await getMediaItemDetails(id), }; }) satisfies PageLoad; From 1ea8ba2e3dca05b503c214e46a9f5612b4f6e8d2 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 18:36:23 +0200 Subject: [PATCH 06/21] chore: add auto-generated client to the ignore for linting --- .prettierignore | 3 ++- eslint.config.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.prettierignore b/.prettierignore index a0f8a74..07cd518 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,4 +3,5 @@ pnpm-lock.yaml package-lock.json yarn.lock CHANGELOG.md -.idea \ No newline at end of file +.idea +src/client/ \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 3decb1c..ce41eea 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -48,6 +48,6 @@ export default [ } }, { - ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/components/ui/', '.idea/'] + ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/components/ui/', '.idea/', 'src/client/'] } ]; From 27f349a8fd26c44fafa4d3df7bd39d564fd8b267 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 18:36:35 +0200 Subject: [PATCH 07/21] refactor: format and lint --- openapi-ts.config.ts | 16 ++++++++-------- src/hooks.client.ts | 3 +-- src/hooks.server.ts | 2 +- src/routes/[type]/[id]/+page.server.ts | 8 ++++---- src/routes/[type]/[id]/+page.svelte | 7 +++---- src/routes/[type]/[id]/[season]/+page.ts | 6 +++--- src/routes/api/media/[id]/magnet/+server.ts | 6 +++--- src/routes/library/+page.server.ts | 9 ++++----- svelte.config.js | 6 +----- tsconfig.json | 2 +- 10 files changed, 29 insertions(+), 36 deletions(-) diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts index a845f53..2e8a3b9 100644 --- a/openapi-ts.config.ts +++ b/openapi-ts.config.ts @@ -1,11 +1,11 @@ import { defineConfig } from '@hey-api/openapi-ts'; export default defineConfig({ - client: '@hey-api/client-fetch', - input: 'http://localhost:8080/openapi.json', - output: 'src/client', - services: { - // This does not suppport tree-shaking and could lead to a larger bundle size - asClass: true - } -}); \ No newline at end of file + client: '@hey-api/client-fetch', + input: 'http://localhost:8080/openapi.json', + output: 'src/client', + services: { + // This does not suppport tree-shaking and could lead to a larger bundle size + asClass: true + } +}); diff --git a/src/hooks.client.ts b/src/hooks.client.ts index c4a82b5..8789a7b 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -2,10 +2,9 @@ import { env } from '$env/dynamic/public'; const BACKEND_URL = env.PUBLIC_BACKEND_URL || 'http://127.0.0.1:8080'; import { client } from './client/services.gen'; - client.setConfig({ baseUrl: BACKEND_URL -}) +}); client.interceptors.error.use((error) => { if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 22dc173..0c27b31 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -32,7 +32,7 @@ const onboarding: Handle = async ({ event, resolve }) => { client.setConfig({ baseUrl: BACKEND_URL -}) +}); client.interceptors.error.use((error) => { if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { diff --git a/src/routes/[type]/[id]/+page.server.ts b/src/routes/[type]/[id]/+page.server.ts index e046580..695ef99 100644 --- a/src/routes/[type]/[id]/+page.server.ts +++ b/src/routes/[type]/[id]/+page.server.ts @@ -35,17 +35,17 @@ export const load = (async ({ params, locals }) => { } } - const {data} = await ItemsService.getItem({ + const { data } = await ItemsService.getItem({ path: { id: id }, query: { use_tmdb_id: true } - }) + }); - if(data) { - data.requested_at = new Date(data.requested_at as string) + if (data) { + data.requested_at = new Date(data.requested_at as string); } console.log(dbData, data); diff --git a/src/routes/[type]/[id]/+page.svelte b/src/routes/[type]/[id]/+page.svelte index 0786499..b3e3f2c 100644 --- a/src/routes/[type]/[id]/+page.svelte +++ b/src/routes/[type]/[id]/+page.svelte @@ -81,7 +81,7 @@ query: { ids: id.toString() } - }) + }); if (!response.error) { toast.success('Media reset successfully'); @@ -122,7 +122,7 @@ }); magnetLoading = false; if (error) { - toast.error(error as string ?? 'Unknown error'); + toast.error((error as string) ?? 'Unknown error'); return; } toast.success('Magnet link added successfully'); @@ -180,8 +180,7 @@ 'bg-red-500': data.db.last_state === 'Unknown' })} > - { - statesName[(data.db.last_state)]} + {statesName[data.db.last_state]} {/if} diff --git a/src/routes/[type]/[id]/[season]/+page.ts b/src/routes/[type]/[id]/[season]/+page.ts index 553756b..5dc77b5 100644 --- a/src/routes/[type]/[id]/[season]/+page.ts +++ b/src/routes/[type]/[id]/[season]/+page.ts @@ -28,10 +28,10 @@ export const load = (async ({ fetch, params }) => { id: tvID }, query: { - use_tmdb_id: true, + use_tmdb_id: true } }); - if(!data) { + if (!data) { throw error(404, 'Media item not found'); } const anyData = data as any; @@ -44,6 +44,6 @@ export const load = (async ({ fetch, params }) => { mediaType: type, mediaID: id, seasonNumber: season, - mediaItemDetails: await getMediaItemDetails(id), + mediaItemDetails: await getMediaItemDetails(id) }; }) satisfies PageLoad; diff --git a/src/routes/api/media/[id]/magnet/+server.ts b/src/routes/api/media/[id]/magnet/+server.ts index 56f2bce..c2c998a 100644 --- a/src/routes/api/media/[id]/magnet/+server.ts +++ b/src/routes/api/media/[id]/magnet/+server.ts @@ -1,4 +1,4 @@ -import { ItemsService, ScrapeService } from'$/client'; +import { ItemsService } from '$/client'; import type { RequestHandler } from './$types'; export const POST: RequestHandler = async ({ params, locals, request }) => { @@ -23,12 +23,12 @@ export const POST: RequestHandler = async ({ params, locals, request }) => { url.searchParams.set('magnet', magnet); try { - const {data, error} = await ItemsService.setTorrentRdMagnet({ + const { data, error } = await ItemsService.setTorrentRdMagnet({ path: { id: parseInt(id) }, query: { - magnet: magnet, + magnet: magnet } }); diff --git a/src/routes/library/+page.server.ts b/src/routes/library/+page.server.ts index bec6769..4b65068 100644 --- a/src/routes/library/+page.server.ts +++ b/src/routes/library/+page.server.ts @@ -3,7 +3,6 @@ import { ItemsService, type ItemsResponse } from '$/client'; import { error } from '@sveltejs/kit'; export const load = (async ({ url }) => { - async function getLibraryApi(): Promise { const limit = Number(url.searchParams.get('limit')) || 24; const page = Number(url.searchParams.get('page')) || 1; @@ -16,16 +15,16 @@ export const load = (async ({ url }) => { limit, page, states, - type: types ?? "movie,show", + type: types ?? 'movie,show', search: query, - sort: "date_desc" + sort: 'date_desc' } - }) + }); if (data) { return data; } else { - console.log(itemsError) + console.log(itemsError); throw error(500, "Couldn't reach backend to get library items"); } } diff --git a/svelte.config.js b/svelte.config.js index ac772d7..fffb849 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,11 +11,7 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter(), - alias: { - '$lib': './src/lib', - '$': './src', - } + adapter: adapter() } }; diff --git a/tsconfig.json b/tsconfig.json index 7683490..fc93cbd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "moduleResolution": "bundler", + "moduleResolution": "bundler" } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files From c16c67ecc4f17c42240184a702613a7f8c10889e Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 18:58:55 +0200 Subject: [PATCH 08/21] feat: add backend proxy --- src/hooks.client.ts | 4 +- src/routes/api/[...backend_proxy]/+server.ts | 68 ++++++++++++++++++++ svelte.config.js | 5 +- 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 src/routes/api/[...backend_proxy]/+server.ts diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 8789a7b..bf5818d 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,9 +1,7 @@ -import { env } from '$env/dynamic/public'; -const BACKEND_URL = env.PUBLIC_BACKEND_URL || 'http://127.0.0.1:8080'; import { client } from './client/services.gen'; client.setConfig({ - baseUrl: BACKEND_URL + baseUrl: "/api" }); client.interceptors.error.use((error) => { diff --git a/src/routes/api/[...backend_proxy]/+server.ts b/src/routes/api/[...backend_proxy]/+server.ts new file mode 100644 index 0000000..87b0754 --- /dev/null +++ b/src/routes/api/[...backend_proxy]/+server.ts @@ -0,0 +1,68 @@ +import { error, json } from "@sveltejs/kit"; +import type { RequestHandler } from "@sveltejs/kit"; + +export const GET: RequestHandler = async ({ locals, url }) => { + const { pathname } = url; + const backendPathname = pathname.replace("/api", ""); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`); + return json(await response.json()); + } catch { + throw error(500, "Failed to fetch data from backend"); + } +}; + +export const PUT: RequestHandler = async ({ locals, url, request }) => { + const { pathname } = url; + const backendPathname = pathname.replace("/api", ""); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: await request.text() + }); + return json(await response.json()); + } catch { + throw error(500, "Failed to fetch data from backend"); + } +}; + +export const POST: RequestHandler = async ({ locals, url, request }) => { + const { pathname } = url; + const backendPathname = pathname.replace("/api", ""); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: await request.text() + }); + return json(await response.json()); + } catch { + throw error(500, "Failed to fetch data from backend"); + } +}; + +export const DELETE: RequestHandler = async ({ locals, url }) => { + const { pathname } = url; + const backendPathname = pathname.replace("/api", ""); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'DELETE' + }); + return json(await response.json()); + } catch { + throw error(500, "Failed to fetch data from backend"); + } +} \ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index fffb849..10cea5f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,7 +11,10 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() + adapter: adapter(), + alias: { + '$': './src' + } } }; From 7f3c93fe54fcff0564762ddb1617954095b6c874 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 19:03:52 +0200 Subject: [PATCH 09/21] feat: add status code forwarding to the proxy --- src/routes/api/[...backend_proxy]/+server.ts | 114 ++++++++++--------- 1 file changed, 61 insertions(+), 53 deletions(-) diff --git a/src/routes/api/[...backend_proxy]/+server.ts b/src/routes/api/[...backend_proxy]/+server.ts index 87b0754..18cee82 100644 --- a/src/routes/api/[...backend_proxy]/+server.ts +++ b/src/routes/api/[...backend_proxy]/+server.ts @@ -1,68 +1,76 @@ -import { error, json } from "@sveltejs/kit"; -import type { RequestHandler } from "@sveltejs/kit"; +import { error, json } from '@sveltejs/kit'; +import type { RequestHandler } from '@sveltejs/kit'; export const GET: RequestHandler = async ({ locals, url }) => { - const { pathname } = url; - const backendPathname = pathname.replace("/api", ""); - const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + const { pathname } = url; + const backendPathname = pathname.replace('/api', ''); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); - try { - const response = await fetch(`${backendUrl.toString()}${url.search}`); - return json(await response.json()); - } catch { - throw error(500, "Failed to fetch data from backend"); - } + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`); + return json(await response.json(), { + status: response.status + }); + } catch { + throw error(500, 'Failed to fetch data from backend'); + } }; export const PUT: RequestHandler = async ({ locals, url, request }) => { - const { pathname } = url; - const backendPathname = pathname.replace("/api", ""); - const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + const { pathname } = url; + const backendPathname = pathname.replace('/api', ''); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); - try { - const response = await fetch(`${backendUrl.toString()}${url.search}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json' - }, - body: await request.text() - }); - return json(await response.json()); - } catch { - throw error(500, "Failed to fetch data from backend"); - } + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: await request.text() + }); + return json(await response.json(), { + status: response.status + }); + } catch { + throw error(500, 'Failed to fetch data from backend'); + } }; export const POST: RequestHandler = async ({ locals, url, request }) => { - const { pathname } = url; - const backendPathname = pathname.replace("/api", ""); - const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + const { pathname } = url; + const backendPathname = pathname.replace('/api', ''); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); - try { - const response = await fetch(`${backendUrl.toString()}${url.search}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: await request.text() - }); - return json(await response.json()); - } catch { - throw error(500, "Failed to fetch data from backend"); - } + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: await request.text() + }); + return json(await response.json(), { + status: response.status + }); + } catch { + throw error(500, 'Failed to fetch data from backend'); + } }; export const DELETE: RequestHandler = async ({ locals, url }) => { - const { pathname } = url; - const backendPathname = pathname.replace("/api", ""); - const backendUrl = new URL(backendPathname, locals.BACKEND_URL); + const { pathname } = url; + const backendPathname = pathname.replace('/api', ''); + const backendUrl = new URL(backendPathname, locals.BACKEND_URL); - try { - const response = await fetch(`${backendUrl.toString()}${url.search}`, { - method: 'DELETE' - }); - return json(await response.json()); - } catch { - throw error(500, "Failed to fetch data from backend"); - } -} \ No newline at end of file + try { + const response = await fetch(`${backendUrl.toString()}${url.search}`, { + method: 'DELETE' + }); + return json(await response.json(), { + status: response.status + }); + } catch { + throw error(500, 'Failed to fetch data from backend'); + } +}; From dd80337edec644b42b53edb668d01ee28ab0c7b4 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 19:03:57 +0200 Subject: [PATCH 10/21] refactor: lint --- src/hooks.client.ts | 2 +- svelte.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index bf5818d..5add38b 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,7 +1,7 @@ import { client } from './client/services.gen'; client.setConfig({ - baseUrl: "/api" + baseUrl: '/api' }); client.interceptors.error.use((error) => { diff --git a/svelte.config.js b/svelte.config.js index 10cea5f..1d42f77 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,7 @@ const config = { // See https://kit.svelte.dev/docs/adapters for more information about adapters. adapter: adapter(), alias: { - '$': './src' + $: './src' } } }; From 392294a4c842dd91b09aaa8aa5db52c84e20a7ed Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 19:55:04 +0200 Subject: [PATCH 11/21] feat: migrate summary page --- src/client/schemas.gen.ts | 31 ------------- src/client/types.gen.ts | 18 ++------ src/hooks.server.ts | 11 +++-- src/routes/summary/+page.server.ts | 70 ------------------------------ src/routes/summary/+page.svelte | 35 +++++++++------ src/routes/summary/+page.ts | 9 ++++ 6 files changed, 39 insertions(+), 135 deletions(-) delete mode 100644 src/routes/summary/+page.server.ts create mode 100644 src/routes/summary/+page.ts diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts index c1db106..d3d9f5d 100644 --- a/src/client/schemas.gen.ts +++ b/src/client/schemas.gen.ts @@ -865,37 +865,6 @@ export const DataAndSuccessResponse_RDUser_Schema = { title: 'DataAndSuccessResponse[RDUser]' } as const; -export const DataAndSuccessResponse_StatsResponse_Schema = { - properties: { - data: { - '$ref': '#/components/schemas/StatsResponse' - }, - success: { - type: 'boolean', - title: 'Success' - } - }, - type: 'object', - required: ['data', 'success'], - title: 'DataAndSuccessResponse[StatsResponse]' -} as const; - -export const DataAndSuccessResponse_dict_Schema = { - properties: { - data: { - type: 'object', - title: 'Data' - }, - success: { - type: 'boolean', - title: 'Success' - } - }, - type: 'object', - required: ['data', 'success'], - title: 'DataAndSuccessResponse[dict]' -} as const; - export const DataAndSuccessResponse_dict_str__list_EventUpdate___Schema = { properties: { data: { diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index 77ea192..49efc4a 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -76,18 +76,6 @@ export type DataAndSuccessResponse_RDUser_ = { success: boolean; }; -export type DataAndSuccessResponse_StatsResponse_ = { - data: StatsResponse; - success: boolean; -}; - -export type DataAndSuccessResponse_dict_ = { - data: { - [key: string]: unknown; - }; - success: boolean; -}; - export type DataAndSuccessResponse_dict_str__list_EventUpdate___ = { data: { [key: string]: Array; @@ -821,7 +809,9 @@ export type TorboxResponse = (unknown); export type TorboxError = (unknown); -export type ServicesResponse = (DataAndSuccessResponse_dict_); +export type ServicesResponse = ({ + [key: string]: (boolean); +}); export type ServicesError = (unknown); @@ -839,7 +829,7 @@ export type TraktOauthCallbackResponse = (MessageAndSuccessResponse); export type TraktOauthCallbackError = (unknown | HTTPValidationError); -export type StatsResponse2 = (DataAndSuccessResponse_StatsResponse_); +export type StatsResponse2 = (StatsResponse); export type StatsError = (unknown); diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 0c27b31..33956c7 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -4,7 +4,7 @@ import { sequence } from '@sveltejs/kit/hooks'; import { env } from '$env/dynamic/private'; const BACKEND_URL = env.BACKEND_URL || 'http://127.0.0.1:8080'; import { db } from '$lib/server/db'; -import { client } from './client/services.gen'; +import { client, DefaultService } from './client/services.gen'; const setLocals: Handle = async ({ event, resolve }) => { event.locals.BACKEND_URL = BACKEND_URL; @@ -15,13 +15,12 @@ const setLocals: Handle = async ({ event, resolve }) => { const onboarding: Handle = async ({ event, resolve }) => { if (!event.url.pathname.startsWith('/onboarding') && event.request.method === 'GET') { - const res = await event.fetch(`${BACKEND_URL}/services`); - const data = await res.json(); - if (!data.success || !data.data) { - error(500, 'API Error'); + const {data, error: apiError} = await DefaultService.services(); + if (apiError || !data) { + return error(500, 'API Error'); } const toCheck = ['symlink', 'symlinklibrary']; - const allServicesTrue: boolean = toCheck.every((service) => data.data[service] === true); + const allServicesTrue: boolean = toCheck.every((service) => data[service] === true); if (!allServicesTrue) { redirect(302, '/onboarding'); } diff --git a/src/routes/summary/+page.server.ts b/src/routes/summary/+page.server.ts deleted file mode 100644 index 0e8309c..0000000 --- a/src/routes/summary/+page.server.ts +++ /dev/null @@ -1,70 +0,0 @@ -import type { PageServerLoad } from './$types'; -import { error } from '@sveltejs/kit'; - -export const load = (async ({ locals }) => { - const statistics = await locals.db - .selectFrom('MediaItem') - .select(({ fn }) => [ - fn.count('_id').as('total'), - fn.count('_id').filterWhere('type', '=', 'movie').as('movies'), - fn.count('_id').filterWhere('type', '=', 'show').as('shows'), - fn.count('_id').filterWhere('type', '=', 'season').as('seasons'), - fn.count('_id').filterWhere('type', '=', 'episode').as('episodes'), - fn.count('_id').filterWhere('last_state', '!=', 'Completed').as('incomplete') - ]) - .executeTakeFirst(); - - type States = { - Completed: number; - Failed: number; - Requested: number; - Indexed: number; - Scraped: number; - Downloaded: number; - Symlinked: number; - PartiallyCompleted: number; - Unknown: number; - Unreleased: number; - Ongoing: number; - [key: string]: number; // Index signature - }; - - const states = (await locals.db - .selectFrom('MediaItem') - .select(({ fn }) => [ - fn.count('_id').filterWhere('last_state', '=', 'Completed').as('Completed'), - fn.count('_id').filterWhere('last_state', '=', 'Failed').as('Failed'), - fn.count('_id').filterWhere('last_state', '=', 'Requested').as('Requested'), - fn.count('_id').filterWhere('last_state', '=', 'Indexed').as('Indexed'), - fn.count('_id').filterWhere('last_state', '=', 'Scraped').as('Scraped'), - fn.count('_id').filterWhere('last_state', '=', 'Downloaded').as('Downloaded'), - fn.count('_id').filterWhere('last_state', '=', 'Symlinked').as('Symlinked'), - fn.count('_id').filterWhere('last_state', '=', 'Unreleased').as('Unreleased'), - fn.count('_id').filterWhere('last_state', '=', 'Ongoing').as('Ongoing'), - fn - .count('_id') - .filterWhere('last_state', '=', 'PartiallyCompleted') - .as('PartiallyCompleted'), - fn.count('_id').filterWhere('last_state', '=', 'Unknown').as('Unknown') - ]) - .executeTakeFirst()) as States; - - async function getServices() { - try { - const res = await fetch(`${locals.BACKEND_URL}/services`); - if (res.ok) { - return await res.json(); - } - error(400, `Unable to fetch services data: ${res.status} ${res.statusText}`); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch services data. Server error or API is down.'); - } - } - - return { - stats: statistics, - states: states, - services: await getServices() - }; -}) satisfies PageServerLoad; diff --git a/src/routes/summary/+page.svelte b/src/routes/summary/+page.svelte index 6c93f40..994dd03 100644 --- a/src/routes/summary/+page.svelte +++ b/src/routes/summary/+page.svelte @@ -18,28 +18,35 @@ const statsData: { title: string; value: number; refTo: string }[] = [ { title: 'Total Items', - value: data.stats?.total || 0, + value: data.stats?.total_items || 0, refTo: '/library' }, { title: 'Total Movies', - value: data.stats?.movies || 0, + value: data.stats?.total_movies || 0, refTo: '/library?types=movie' }, { title: 'Total Shows', - value: data.stats?.shows || 0, + value: data.stats?.total_shows || 0, refTo: '/library?types=show' }, { title: 'Incomplete Items', - value: data.stats?.incomplete || 0, + value: data.stats?.incomplete_items || 0, refTo: '/library?states=Unknown%2CRequested%2CIndexed%2CScraped%2CDownloaded%2CSymlinked%2CFailed%2CPartiallyCompleted' } ]; - function sortServices(services: string[], data: Record) { + function sortServices(services: string[], data?: Record): Record { + if (!data) { + const sortedData = {} as Record; + services.forEach((service) => { + sortedData[service] = false; + }); + return sortedData; + } let sortedData = {} as Record; for (let service of services) { @@ -51,10 +58,10 @@ return sortedData as Record; } - const coreServicesData = sortServices(coreServices, data.services.data); - const downloaderServicesData = sortServices(downloaderServices, data.services.data); - const contentServicesData = sortServices(contentServices, data.services.data); - const scrapingServicesData = sortServices(scrapingServices, data.services.data); + const coreServicesData = sortServices(coreServices, data.services); + const downloaderServicesData = sortServices(downloaderServices, data.services); + const contentServicesData = sortServices(contentServices, data.services); + const scrapingServicesData = sortServices(scrapingServices, data.services); const coreServicesStatus = Object.keys(coreServicesData).map((service) => { return { @@ -129,10 +136,10 @@ {#if stat.title === 'Total Shows'}

{stat.value}

- {data.stats?.seasons || 0} Seasons + {data.stats?.total_seasons || 0} Seasons

- {data.stats?.episodes || 0} Episodes + {data.stats?.total_episodes || 0} Episodes

{:else}

{stat.value}

@@ -195,9 +202,9 @@ - {#if data.states} + {#if data.stats?.states}
- {#each Object.keys(data.states) as state} + {#each Object.keys(data.stats.states) as state} {statesName[state]} -

{data.states[state]}

+

{data.stats.states[state]}

See items diff --git a/src/routes/summary/+page.ts b/src/routes/summary/+page.ts new file mode 100644 index 0000000..67bd523 --- /dev/null +++ b/src/routes/summary/+page.ts @@ -0,0 +1,9 @@ +import { DefaultService } from "$/client" + +export const load = async () => { + console.log("Loading summary page") + return { + stats: (await DefaultService.stats()).data, + services: (await DefaultService.services()).data + } +} \ No newline at end of file From ab8e91f7e8c31d41c7564fb7ac0f244371b1526e Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 19:59:09 +0200 Subject: [PATCH 12/21] refactor: add type to summary page loader --- src/routes/summary/+page.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/summary/+page.ts b/src/routes/summary/+page.ts index 67bd523..0ff01ad 100644 --- a/src/routes/summary/+page.ts +++ b/src/routes/summary/+page.ts @@ -1,7 +1,7 @@ import { DefaultService } from "$/client" +import type { PageLoad } from "./$types" -export const load = async () => { - console.log("Loading summary page") +export const load: PageLoad = async () => { return { stats: (await DefaultService.stats()).data, services: (await DefaultService.services()).data From 56a0a5c7901ce25127e18b41ccec8766b5b8ccf2 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 20:23:28 +0200 Subject: [PATCH 13/21] feat: migrate settings to api --- src/client/schemas.gen.ts | 2426 +---------------- src/client/services.gen.ts | 16 +- src/client/types.gen.ts | 349 +-- src/lib/forms/helpers.server.ts | 44 +- src/lib/forms/helpers.ts | 234 +- src/routes/settings/about/+page.server.ts | 18 +- src/routes/settings/about/+page.svelte | 6 +- src/routes/settings/all.json/+server.ts | 56 +- src/routes/settings/content/+page.server.ts | 28 +- src/routes/settings/general/+page.server.ts | 28 +- .../settings/mediaserver/+page.server.ts | 31 +- src/routes/settings/scrapers/+page.server.ts | 28 +- 12 files changed, 316 insertions(+), 2948 deletions(-) diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts index d3d9f5d..d7e9ff6 100644 --- a/src/client/schemas.gen.ts +++ b/src/client/schemas.gen.ts @@ -16,685 +16,6 @@ export const AddItemsResponseSchema = { title: 'AddItemsResponse' } as const; -export const AllDebridModelSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - proxy_enabled: { - type: 'boolean', - title: 'Proxy Enabled', - default: false - }, - proxy_url: { - type: 'string', - title: 'Proxy Url', - default: '' - } - }, - type: 'object', - title: 'AllDebridModel' -} as const; - -export const AnnatarConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://annatar.elfhosted.com' - }, - limit: { - type: 'integer', - title: 'Limit', - default: 2000 - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true - } - }, - type: 'object', - title: 'AnnatarConfig' -} as const; - -export const AppModelSchema = { - properties: { - version: { - type: 'string', - title: 'Version', - default: '0.15.1' - }, - debug: { - type: 'boolean', - title: 'Debug', - default: true - }, - log: { - type: 'boolean', - title: 'Log', - default: true - }, - force_refresh: { - type: 'boolean', - title: 'Force Refresh', - default: false - }, - map_metadata: { - type: 'boolean', - title: 'Map Metadata', - default: true - }, - tracemalloc: { - type: 'boolean', - title: 'Tracemalloc', - default: false - }, - symlink: { - '$ref': '#/components/schemas/SymlinkModel', - default: { - rclone_path: '.', - library_path: '.', - separate_anime_dirs: false, - repair_symlinks: false, - repair_interval: 6 - } - }, - updaters: { - '$ref': '#/components/schemas/UpdatersModel', - default: { - updater_interval: 120, - plex: { - enabled: false, - token: '', - url: 'http://localhost:32400' - }, - jellyfin: { - api_key: '', - enabled: false, - url: 'http://localhost:8096' - }, - emby: { - api_key: '', - enabled: false, - url: 'http://localhost:8096' - } - } - }, - downloaders: { - '$ref': '#/components/schemas/DownloadersModel', - default: { - video_extensions: ['mp4', 'mkv', 'avi'], - prefer_speed_over_quality: true, - real_debrid: { - api_key: '', - enabled: false, - proxy_enabled: false, - proxy_url: '' - }, - all_debrid: { - api_key: '', - enabled: false, - proxy_enabled: false, - proxy_url: '' - }, - torbox: { - api_key: '', - enabled: false - } - } - }, - content: { - '$ref': '#/components/schemas/ContentModel', - default: { - overseerr: { - api_key: '', - enabled: false, - update_interval: 60, - url: 'http://localhost:5055', - use_webhook: false - }, - plex_watchlist: { - enabled: false, - rss: [], - update_interval: 60 - }, - mdblist: { - api_key: '', - enabled: false, - lists: [], - update_interval: 300 - }, - listrr: { - api_key: '', - enabled: false, - movie_lists: [], - show_lists: [], - update_interval: 300 - }, - trakt: { - api_key: '', - collection: [], - enabled: false, - fetch_popular: false, - fetch_trending: false, - popular_count: 10, - trending_count: 10, - update_interval: 300, - user_lists: [], - watchlist: [] - } - } - }, - scraping: { - '$ref': '#/components/schemas/ScraperModel', - default: { - after_2: 2, - after_5: 6, - after_10: 24, - parse_debug: false, - enable_aliases: true, - torrentio: { - enabled: false, - filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', - ratelimit: true, - timeout: 30, - url: 'http://torrentio.strem.fun' - }, - knightcrawler: { - enabled: false, - filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', - ratelimit: true, - timeout: 30, - url: 'https://knightcrawler.elfhosted.com' - }, - jackett: { - api_key: '', - enabled: false, - ratelimit: true, - timeout: 30, - url: 'http://localhost:9117' - }, - prowlarr: { - api_key: '', - enabled: false, - limiter_seconds: 60, - ratelimit: true, - timeout: 30, - url: 'http://localhost:9696' - }, - orionoid: { - api_key: '', - cached_results_only: false, - enabled: false, - parameters: { - limitcount: 5, - video3d: 'false', - videoquality: 'sd_hd8k' - }, - ratelimit: true, - timeout: 30 - }, - annatar: { - enabled: false, - limit: 2000, - ratelimit: true, - timeout: 30, - url: 'http://annatar.elfhosted.com' - }, - torbox_scraper: { - enabled: false, - timeout: 30 - }, - mediafusion: { - catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'], - enabled: false, - ratelimit: true, - timeout: 30, - url: 'https://mediafusion.elfhosted.com' - }, - zilean: { - enabled: false, - ratelimit: true, - timeout: 30, - url: 'http://localhost:8181' - }, - comet: { - enabled: false, - indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], - ratelimit: true, - timeout: 30, - url: 'http://localhost:8000' - } - } - }, - ranking: { - '$ref': '#/components/schemas/RTNSettingsModel', - default: { - profile: 'default', - require: [], - exclude: [], - preferred: [], - resolutions: { - '1080p': true, - '2160p': false, - '360p': false, - '480p': false, - '720p': true, - unknown: true - }, - options: { - allow_english_in_languages: false, - remove_all_trash: true, - remove_ranks_under: -10000, - remove_unknown_languages: false, - title_similarity: 0.85 - }, - languages: { - exclude: [], - preferred: [], - required: [] - }, - custom_ranks: { - audio: { - aac: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - ac3: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - atmos: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_digital: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_digital_plus: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dts_lossless: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dts_lossy: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - eac3: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - flac: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - mono: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - mp3: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - stereo: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - surround: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - truehd: { - fetch: true, - rank: 0, - use_custom_rank: false - } - }, - extras: { - '3d': { - fetch: false, - rank: 0, - use_custom_rank: false - }, - converted: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - documentary: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - dubbed: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - edition: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hardcoded: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - network: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - proper: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - repack: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - retail: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - site: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - subbed: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - upscaled: { - fetch: false, - rank: 0, - use_custom_rank: false - } - }, - hdr: { - '10bit': { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_vision: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hdr: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hdr10plus: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - sdr: { - fetch: true, - rank: 0, - use_custom_rank: false - } - }, - quality: { - av1: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - avc: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - bluray: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dvd: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - hdtv: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hevc: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - mpeg: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - remux: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - vhs: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - web: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - webdl: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - webmux: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - xvid: { - fetch: false, - rank: 0, - use_custom_rank: false - } - }, - rips: { - bdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - brrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - dvdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - hdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - ppvrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - satrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - tvrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - uhdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - vhsrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - webdlrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - webrip: { - fetch: true, - rank: 0, - use_custom_rank: false - } - }, - trash: { - cam: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - clean_audio: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - pdtv: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - r5: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - screener: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - size: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - telecine: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - telesync: { - fetch: false, - rank: 0, - use_custom_rank: false - } - } - } - } - }, - indexer: { - '$ref': '#/components/schemas/IndexerModel', - default: { - update_interval: 3600 - } - }, - database: { - '$ref': '#/components/schemas/DatabaseModel', - default: { - host: 'postgresql+psycopg2://postgres:postgres@localhost/riven' - } - }, - notifications: { - '$ref': '#/components/schemas/NotificationsModel', - default: { - enabled: false, - title: 'Riven completed something!', - on_item_type: ['movie', 'show', 'season'], - service_urls: [] - } - }, - post_processing: { - '$ref': '#/components/schemas/PostProcessing', - default: { - subliminal: { - enabled: false, - languages: ['eng'], - providers: { - opensubtitles: { - enabled: false, - password: '', - username: '' - }, - opensubtitlescom: { - enabled: false, - password: '', - username: '' - } - } - } - } - } - }, - type: 'object', - title: 'AppModel' -} as const; - export const BelongsToCollectionSchema = { properties: { id: { @@ -733,123 +54,6 @@ export const BelongsToCollectionSchema = { title: 'BelongsToCollection' } as const; -export const CometConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:8000' - }, - indexers: { - items: { - type: 'string' - }, - type: 'array', - title: 'Indexers', - default: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'] - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true - } - }, - type: 'object', - title: 'CometConfig' -} as const; - -export const ContentModelSchema = { - properties: { - overseerr: { - '$ref': '#/components/schemas/OverseerrModel', - default: { - update_interval: 60, - enabled: false, - url: 'http://localhost:5055', - api_key: '', - use_webhook: false - } - }, - plex_watchlist: { - '$ref': '#/components/schemas/PlexWatchlistModel', - default: { - update_interval: 60, - enabled: false, - rss: [] - } - }, - mdblist: { - '$ref': '#/components/schemas/MdblistModel', - default: { - update_interval: 300, - enabled: false, - api_key: '', - lists: [] - } - }, - listrr: { - '$ref': '#/components/schemas/ListrrModel', - default: { - update_interval: 300, - enabled: false, - movie_lists: [], - show_lists: [], - api_key: '' - } - }, - trakt: { - '$ref': '#/components/schemas/TraktModel', - default: { - update_interval: 300, - enabled: false, - api_key: '', - watchlist: [], - user_lists: [], - collection: [], - fetch_trending: false, - trending_count: 10, - fetch_popular: false, - popular_count: 10 - } - } - }, - type: 'object', - title: 'ContentModel' -} as const; - -export const CustomRankSchema = { - properties: { - fetch: { - type: 'boolean', - title: 'Fetch', - default: true - }, - use_custom_rank: { - type: 'boolean', - title: 'Use Custom Rank', - default: false - }, - rank: { - type: 'integer', - title: 'Rank', - default: 0 - } - }, - type: 'object', - title: 'CustomRank', - description: 'Custom Ranks used in SettingsModel.' -} as const; - export const DataAndSuccessResponse_RDUser_Schema = { properties: { data: { @@ -906,18 +110,6 @@ export const DataAndSuccessResponse_dict_str__str__Schema = { title: 'DataAndSuccessResponse[dict[str, str]]' } as const; -export const DatabaseModelSchema = { - properties: { - host: { - type: 'string', - title: 'Host', - default: 'postgresql+psycopg2://postgres:postgres@localhost/riven' - } - }, - type: 'object', - title: 'DatabaseModel' -} as const; - export const DatesSchema = { properties: { maximum: { @@ -936,73 +128,6 @@ export const DatesSchema = { title: 'Dates' } as const; -export const DownloadersModelSchema = { - properties: { - video_extensions: { - items: { - type: 'string' - }, - type: 'array', - title: 'Video Extensions', - default: ['mp4', 'mkv', 'avi'] - }, - prefer_speed_over_quality: { - type: 'boolean', - title: 'Prefer Speed Over Quality', - default: true - }, - real_debrid: { - '$ref': '#/components/schemas/RealDebridModel', - default: { - enabled: false, - api_key: '', - proxy_enabled: false, - proxy_url: '' - } - }, - all_debrid: { - '$ref': '#/components/schemas/AllDebridModel', - default: { - enabled: false, - api_key: '', - proxy_enabled: false, - proxy_url: '' - } - }, - torbox: { - '$ref': '#/components/schemas/TorboxModel', - default: { - enabled: false, - api_key: '' - } - } - }, - type: 'object', - title: 'DownloadersModel' -} as const; - -export const EmbyLibraryModelSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:8096' - } - }, - type: 'object', - title: 'EmbyLibraryModel' -} as const; - export const EventUpdateSchema = { properties: { item_id: { @@ -1061,37 +186,6 @@ export const GenreSchema = { title: 'Genre' } as const; -export const GetAllSettingsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - data: { - '$ref': '#/components/schemas/AppModel' - } - }, - type: 'object', - required: ['success', 'data'], - title: 'GetAllSettingsResponse' -} as const; - -export const GetSettingsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - data: { - type: 'object', - title: 'Data' - } - }, - type: 'object', - required: ['success', 'data'], - title: 'GetSettingsResponse' -} as const; - export const HTTPValidationErrorSchema = { properties: { detail: { @@ -1112,18 +206,6 @@ export const IncludeAdultSchema = { title: 'IncludeAdult' } as const; -export const IndexerModelSchema = { - properties: { - update_interval: { - type: 'integer', - title: 'Update Interval', - default: 3600 - } - }, - type: 'object', - title: 'IndexerModel' -} as const; - export const ItemsByImdbResponseSchema = { properties: { success: { @@ -1178,466 +260,86 @@ export const ItemsResponseSchema = { title: 'ItemsResponse' } as const; -export const JackettConfigSchema = { +export const LogsResponseSchema = { properties: { - enabled: { + success: { type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:9117' + title: 'Success' }, - api_key: { + logs: { type: 'string', - title: 'Api Key', - default: '' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true + title: 'Logs' } }, type: 'object', - title: 'JackettConfig' + required: ['success', 'logs'], + title: 'LogsResponse' } as const; -export const JellyfinLibraryModelSchema = { +export const MessageAndSuccessResponseSchema = { properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { + message: { type: 'string', - title: 'Api Key', - default: '' + title: 'Message' }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:8096' + success: { + type: 'boolean', + title: 'Success' } }, type: 'object', - title: 'JellyfinLibraryModel' + required: ['message', 'success'], + title: 'MessageAndSuccessResponse' } as const; -export const KnightcrawlerConfigSchema = { +export const MessageResponseSchema = { properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - filter: { - type: 'string', - title: 'Filter', - default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' - }, - url: { + message: { type: 'string', - title: 'Url', - default: 'https://knightcrawler.elfhosted.com' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true + title: 'Message' } }, type: 'object', - title: 'KnightcrawlerConfig' + required: ['message'], + title: 'MessageResponse' } as const; -export const ListrrModelSchema = { +export const NetworkSchema = { properties: { - update_interval: { + id: { type: 'integer', - title: 'Update Interval', - default: 300 - }, - enabled: { - type: 'boolean', - title: 'Enabled', - default: false + title: 'Id' }, - movie_lists: { - items: { - type: 'string' - }, - type: 'array', - title: 'Movie Lists', - default: [] + logo_path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Logo Path' }, - show_lists: { - items: { - type: 'string' - }, - type: 'array', - title: 'Show Lists', - default: [] + name: { + type: 'string', + title: 'Name' }, - api_key: { + origin_country: { type: 'string', - title: 'Api Key', - default: '' + title: 'Origin Country' } }, type: 'object', - title: 'ListrrModel' + required: ['id', 'logo_path', 'name', 'origin_country'], + title: 'Network' } as const; -export const LoadSettingsResponseSchema = { +export const ProductionCompanySchema = { properties: { - success: { - type: 'boolean', - title: 'Success' - }, - message: { - type: 'string', - title: 'Message' - } - }, - type: 'object', - required: ['success', 'message'], - title: 'LoadSettingsResponse' -} as const; - -export const LogsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - logs: { - type: 'string', - title: 'Logs' - } - }, - type: 'object', - required: ['success', 'logs'], - title: 'LogsResponse' -} as const; - -export const MdblistModelSchema = { - properties: { - update_interval: { - type: 'integer', - title: 'Update Interval', - default: 300 - }, - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - lists: { - items: { - anyOf: [ - { - type: 'string' - }, - { - type: 'integer' - } - ] - }, - type: 'array', - title: 'Lists', - default: [] - } - }, - type: 'object', - title: 'MdblistModel' -} as const; - -export const MediafusionConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'https://mediafusion.elfhosted.com' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true - }, - catalogs: { - items: { - type: 'string' - }, - type: 'array', - title: 'Catalogs', - default: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] - } - }, - type: 'object', - title: 'MediafusionConfig' -} as const; - -export const MessageAndSuccessResponseSchema = { - properties: { - message: { - type: 'string', - title: 'Message' - }, - success: { - type: 'boolean', - title: 'Success' - } - }, - type: 'object', - required: ['message', 'success'], - title: 'MessageAndSuccessResponse' -} as const; - -export const NetworkSchema = { - properties: { - id: { - type: 'integer', - title: 'Id' - }, - logo_path: { - anyOf: [ - { - type: 'string' - }, - { - type: 'null' - } - ], - title: 'Logo Path' - }, - name: { - type: 'string', - title: 'Name' - }, - origin_country: { - type: 'string', - title: 'Origin Country' - } - }, - type: 'object', - required: ['id', 'logo_path', 'name', 'origin_country'], - title: 'Network' -} as const; - -export const NotificationsModelSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - title: { - type: 'string', - title: 'Title', - default: 'Riven completed something!' - }, - on_item_type: { - items: { - type: 'string' - }, - type: 'array', - title: 'On Item Type', - default: ['movie', 'show', 'season'] - }, - service_urls: { - items: { - type: 'string' - }, - type: 'array', - title: 'Service Urls', - default: [] - } - }, - type: 'object', - title: 'NotificationsModel' -} as const; - -export const OrionoidConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - cached_results_only: { - type: 'boolean', - title: 'Cached Results Only', - default: false - }, - parameters: { - type: 'object', - title: 'Parameters', - default: { - video3d: 'false', - videoquality: 'sd_hd8k', - limitcount: 5 - } - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true, - deprecated: true - } - }, - type: 'object', - title: 'OrionoidConfig' -} as const; - -export const OverseerrModelSchema = { - properties: { - update_interval: { - type: 'integer', - title: 'Update Interval', - default: 60 - }, - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:5055' - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - use_webhook: { - type: 'boolean', - title: 'Use Webhook', - default: false - } - }, - type: 'object', - title: 'OverseerrModel' -} as const; - -export const PlexLibraryModelSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - token: { - type: 'string', - title: 'Token', - default: '' - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:32400' - } - }, - type: 'object', - title: 'PlexLibraryModel' -} as const; - -export const PlexWatchlistModelSchema = { - properties: { - update_interval: { - type: 'integer', - title: 'Update Interval', - default: 60 - }, - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - rss: { - items: { - type: 'string' - }, - type: 'array', - title: 'Rss', - default: [] - } - }, - type: 'object', - title: 'PlexWatchlistModel' -} as const; - -export const PostProcessingSchema = { - properties: { - subliminal: { - '$ref': '#/components/schemas/SubliminalConfig', - default: { - enabled: false, - languages: ['eng'], - providers: { - opensubtitles: { - enabled: false, - password: '', - username: '' - }, - opensubtitlescom: { - enabled: false, - password: '', - username: '' - } - } - } - } - }, - type: 'object', - title: 'PostProcessing' -} as const; - -export const ProductionCompanySchema = { - properties: { - id: { - type: 'integer', - title: 'Id' + id: { + type: 'integer', + title: 'Id' }, logo_path: { anyOf: [ @@ -1680,43 +382,6 @@ export const ProductionCountrySchema = { title: 'ProductionCountry' } as const; -export const ProwlarrConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:9696' - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true - }, - limiter_seconds: { - type: 'integer', - title: 'Limiter Seconds', - default: 60 - } - }, - type: 'object', - title: 'ProwlarrConfig' -} as const; - export const RDTorrentSchema = { properties: { id: { @@ -1765,521 +430,79 @@ export const RDTorrentSchema = { speed: { anyOf: [ { - type: 'integer' - }, - { - type: 'null' - } - ], - title: 'Speed' - }, - seeders: { - anyOf: [ - { - type: 'integer' - }, - { - type: 'null' - } - ], - title: 'Seeders' - } - }, - type: 'object', - required: ['id', 'hash', 'filename', 'bytes', 'status', 'added', 'links'], - title: 'RDTorrent' -} as const; - -export const RDTorrentStatusSchema = { - type: 'string', - enum: ['magnet_error', 'magnet_conversion', 'waiting_files_selection', 'downloading', 'downloaded', 'error', 'seeding', 'dead', 'uploading', 'compressing'], - title: 'RDTorrentStatus' -} as const; - -export const RDUserSchema = { - properties: { - id: { - type: 'integer', - title: 'Id' - }, - username: { - type: 'string', - title: 'Username' - }, - email: { - type: 'string', - title: 'Email' - }, - points: { - type: 'integer', - title: 'Points', - description: "User's RD points" - }, - locale: { - type: 'string', - title: 'Locale' - }, - avatar: { - type: 'string', - title: 'Avatar', - description: "URL to the user's avatar" - }, - type: { - type: 'string', - enum: ['free', 'premium'], - title: 'Type' - }, - premium: { - type: 'integer', - title: 'Premium', - description: 'Premium subscription left in seconds' - } - }, - type: 'object', - required: ['id', 'username', 'email', 'points', 'locale', 'avatar', 'type', 'premium'], - title: 'RDUser' -} as const; - -export const RTNSettingsModelSchema = { - properties: { - profile: { - type: 'string', - title: 'Profile', - default: 'default' - }, - require: { - items: { - type: 'string' - }, - type: 'array', - title: 'Require', - default: [] - }, - exclude: { - items: { - type: 'string' - }, - type: 'array', - title: 'Exclude', - default: [] - }, - preferred: { - items: { - type: 'string' - }, - type: 'array', - title: 'Preferred', - default: [] - }, - resolutions: { - additionalProperties: { - type: 'boolean' - }, - type: 'object', - title: 'Resolutions', - default: { - '2160p': false, - '1080p': true, - '720p': true, - '480p': false, - '360p': false, - unknown: true - } - }, - options: { - type: 'object', - title: 'Options', - default: { - title_similarity: 0.85, - remove_all_trash: true, - remove_ranks_under: -10000, - remove_unknown_languages: false, - allow_english_in_languages: false - } - }, - languages: { - type: 'object', - title: 'Languages', - default: { - required: [], - exclude: [], - preferred: [] - } - }, - custom_ranks: { - additionalProperties: { - additionalProperties: { - '$ref': '#/components/schemas/CustomRank' - }, - type: 'object' - }, - type: 'object', - title: 'Custom Ranks', - default: { - quality: { - av1: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - avc: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - bluray: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dvd: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - hdtv: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hevc: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - mpeg: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - remux: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - vhs: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - web: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - webdl: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - webmux: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - xvid: { - fetch: false, - rank: 0, - use_custom_rank: false - } - }, - rips: { - bdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - brrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - dvdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - hdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - ppvrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - satrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - tvrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - uhdrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - vhsrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - webdlrip: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - webrip: { - fetch: true, - rank: 0, - use_custom_rank: false - } - }, - hdr: { - '10bit': { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_vision: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hdr: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hdr10plus: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - sdr: { - fetch: true, - rank: 0, - use_custom_rank: false - } - }, - audio: { - aac: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - ac3: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - atmos: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_digital: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dolby_digital_plus: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dts_lossless: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - dts_lossy: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - eac3: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - flac: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - mono: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - mp3: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - stereo: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - surround: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - truehd: { - fetch: true, - rank: 0, - use_custom_rank: false - } + type: 'integer' }, - extras: { - '3d': { - fetch: false, - rank: 0, - use_custom_rank: false - }, - converted: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - documentary: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - dubbed: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - edition: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - hardcoded: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - network: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - proper: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - repack: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - retail: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - site: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - subbed: { - fetch: true, - rank: 0, - use_custom_rank: false - }, - upscaled: { - fetch: false, - rank: 0, - use_custom_rank: false - } + { + type: 'null' + } + ], + title: 'Speed' + }, + seeders: { + anyOf: [ + { + type: 'integer' }, - trash: { - cam: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - clean_audio: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - pdtv: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - r5: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - screener: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - size: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - telecine: { - fetch: false, - rank: 0, - use_custom_rank: false - }, - telesync: { - fetch: false, - rank: 0, - use_custom_rank: false - } + { + type: 'null' } - } + ], + title: 'Seeders' } }, type: 'object', - title: 'RTNSettingsModel' + required: ['id', 'hash', 'filename', 'bytes', 'status', 'added', 'links'], + title: 'RDTorrent' +} as const; + +export const RDTorrentStatusSchema = { + type: 'string', + enum: ['magnet_error', 'magnet_conversion', 'waiting_files_selection', 'downloading', 'downloaded', 'error', 'seeding', 'dead', 'uploading', 'compressing'], + title: 'RDTorrentStatus' } as const; -export const RealDebridModelSchema = { +export const RDUserSchema = { properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false + id: { + type: 'integer', + title: 'Id' }, - api_key: { + username: { type: 'string', - title: 'Api Key', - default: '' + title: 'Username' }, - proxy_enabled: { - type: 'boolean', - title: 'Proxy Enabled', - default: false + email: { + type: 'string', + title: 'Email' + }, + points: { + type: 'integer', + title: 'Points', + description: "User's RD points" + }, + locale: { + type: 'string', + title: 'Locale' }, - proxy_url: { + avatar: { + type: 'string', + title: 'Avatar', + description: "URL to the user's avatar" + }, + type: { type: 'string', - title: 'Proxy Url', - default: '' + enum: ['free', 'premium'], + title: 'Type' + }, + premium: { + type: 'integer', + title: 'Premium', + description: 'Premium subscription left in seconds' } }, type: 'object', - title: 'RealDebridModel' + required: ['id', 'username', 'email', 'points', 'locale', 'avatar', 'type', 'premium'], + title: 'RDUser' } as const; export const RemoveResponseSchema = { @@ -2371,22 +594,6 @@ export const RootResponseSchema = { title: 'RootResponse' } as const; -export const SaveSettingsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - message: { - type: 'string', - title: 'Message' - } - }, - type: 'object', - required: ['success', 'message'], - title: 'SaveSettingsResponse' -} as const; - export const ScrapeResponseSchema = { properties: { success: { @@ -2426,156 +633,6 @@ export const ScrapedTorrentSchema = { title: 'ScrapedTorrent' } as const; -export const ScraperModelSchema = { - properties: { - after_2: { - type: 'number', - title: 'After 2', - default: 2 - }, - after_5: { - type: 'integer', - title: 'After 5', - default: 6 - }, - after_10: { - type: 'integer', - title: 'After 10', - default: 24 - }, - parse_debug: { - type: 'boolean', - title: 'Parse Debug', - default: false - }, - enable_aliases: { - type: 'boolean', - title: 'Enable Aliases', - default: true - }, - torrentio: { - '$ref': '#/components/schemas/TorrentioConfig', - default: { - enabled: false, - filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', - url: 'http://torrentio.strem.fun', - timeout: 30, - ratelimit: true - } - }, - knightcrawler: { - '$ref': '#/components/schemas/KnightcrawlerConfig', - default: { - enabled: false, - filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', - url: 'https://knightcrawler.elfhosted.com', - timeout: 30, - ratelimit: true - } - }, - jackett: { - '$ref': '#/components/schemas/JackettConfig', - default: { - enabled: false, - url: 'http://localhost:9117', - api_key: '', - timeout: 30, - ratelimit: true - } - }, - prowlarr: { - '$ref': '#/components/schemas/ProwlarrConfig', - default: { - enabled: false, - url: 'http://localhost:9696', - api_key: '', - timeout: 30, - ratelimit: true, - limiter_seconds: 60 - } - }, - orionoid: { - '$ref': '#/components/schemas/OrionoidConfig', - default: { - enabled: false, - api_key: '', - cached_results_only: false, - parameters: { - limitcount: 5, - video3d: 'false', - videoquality: 'sd_hd8k' - }, - timeout: 30, - ratelimit: true - } - }, - annatar: { - '$ref': '#/components/schemas/AnnatarConfig', - default: { - enabled: false, - url: 'http://annatar.elfhosted.com', - limit: 2000, - timeout: 30, - ratelimit: true - } - }, - torbox_scraper: { - '$ref': '#/components/schemas/TorBoxScraperConfig', - default: { - enabled: false, - timeout: 30 - } - }, - mediafusion: { - '$ref': '#/components/schemas/MediafusionConfig', - default: { - enabled: false, - url: 'https://mediafusion.elfhosted.com', - timeout: 30, - ratelimit: true, - catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] - } - }, - zilean: { - '$ref': '#/components/schemas/ZileanConfig', - default: { - enabled: false, - url: 'http://localhost:8181', - timeout: 30, - ratelimit: true - } - }, - comet: { - '$ref': '#/components/schemas/CometConfig', - default: { - enabled: false, - url: 'http://localhost:8000', - indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], - timeout: 30, - ratelimit: true - } - } - }, - type: 'object', - title: 'ScraperModel' -} as const; - -export const SetAllSettingsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - message: { - type: 'string', - title: 'Message' - } - }, - type: 'object', - required: ['success', 'message'], - title: 'SetAllSettingsResponse' -} as const; - export const SetSettingsSchema = { properties: { key: { @@ -2591,22 +648,6 @@ export const SetSettingsSchema = { title: 'SetSettings' } as const; -export const SetSettingsResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success' - }, - message: { - type: 'string', - title: 'Message' - } - }, - type: 'object', - required: ['success', 'message'], - title: 'SetSettingsResponse' -} as const; - export const SetTorrentRDResponseSchema = { properties: { success: { @@ -2727,76 +768,6 @@ export const StatsResponseSchema = { title: 'StatsResponse' } as const; -export const SubliminalConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - languages: { - items: { - type: 'string' - }, - type: 'array', - title: 'Languages', - default: ['eng'] - }, - providers: { - type: 'object', - title: 'Providers', - default: { - opensubtitles: { - enabled: false, - password: '', - username: '' - }, - opensubtitlescom: { - enabled: false, - password: '', - username: '' - } - } - } - }, - type: 'object', - title: 'SubliminalConfig' -} as const; - -export const SymlinkModelSchema = { - properties: { - rclone_path: { - type: 'string', - format: 'path', - title: 'Rclone Path', - default: '.' - }, - library_path: { - type: 'string', - format: 'path', - title: 'Library Path', - default: '.' - }, - separate_anime_dirs: { - type: 'boolean', - title: 'Separate Anime Dirs', - default: false - }, - repair_symlinks: { - type: 'boolean', - title: 'Repair Symlinks', - default: false - }, - repair_interval: { - type: 'number', - title: 'Repair Interval', - default: 6 - } - }, - type: 'object', - title: 'SymlinkModel' -} as const; - export const TmdbCollectionDetailsSchema = { properties: { adult: { @@ -3967,139 +1938,6 @@ export const TmdbTVDetailsSchema = { title: 'TmdbTVDetails' } as const; -export const TorBoxScraperConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - } - }, - type: 'object', - title: 'TorBoxScraperConfig' -} as const; - -export const TorboxModelSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - } - }, - type: 'object', - title: 'TorboxModel' -} as const; - -export const TorrentioConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - filter: { - type: 'string', - title: 'Filter', - default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' - }, - url: { - type: 'string', - title: 'Url', - default: 'http://torrentio.strem.fun' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true, - deprecated: true - } - }, - type: 'object', - title: 'TorrentioConfig' -} as const; - -export const TraktModelSchema = { - properties: { - update_interval: { - type: 'integer', - title: 'Update Interval', - default: 300 - }, - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - api_key: { - type: 'string', - title: 'Api Key', - default: '' - }, - watchlist: { - items: { - type: 'string' - }, - type: 'array', - title: 'Watchlist', - default: [] - }, - user_lists: { - items: { - type: 'string' - }, - type: 'array', - title: 'User Lists', - default: [] - }, - collection: { - items: { - type: 'string' - }, - type: 'array', - title: 'Collection', - default: [] - }, - fetch_trending: { - type: 'boolean', - title: 'Fetch Trending', - default: false - }, - trending_count: { - type: 'integer', - title: 'Trending Count', - default: 10 - }, - fetch_popular: { - type: 'boolean', - title: 'Fetch Popular', - default: false - }, - popular_count: { - type: 'integer', - title: 'Popular Count', - default: 10 - } - }, - type: 'object', - title: 'TraktModel' -} as const; - export const TraktOAuthInitiateResponseSchema = { properties: { auth_url: { @@ -4124,42 +1962,6 @@ export const TrendingWindowSchema = { title: 'TrendingWindow' } as const; -export const UpdatersModelSchema = { - properties: { - updater_interval: { - type: 'integer', - title: 'Updater Interval', - default: 120 - }, - plex: { - '$ref': '#/components/schemas/PlexLibraryModel', - default: { - enabled: false, - token: '', - url: 'http://localhost:32400' - } - }, - jellyfin: { - '$ref': '#/components/schemas/JellyfinLibraryModel', - default: { - enabled: false, - api_key: '', - url: 'http://localhost:8096' - } - }, - emby: { - '$ref': '#/components/schemas/EmbyLibraryModel', - default: { - enabled: false, - api_key: '', - url: 'http://localhost:8096' - } - } - }, - type: 'object', - title: 'UpdatersModel' -} as const; - export const ValidationErrorSchema = { properties: { loc: { @@ -4188,32 +1990,4 @@ export const ValidationErrorSchema = { type: 'object', required: ['loc', 'msg', 'type'], title: 'ValidationError' -} as const; - -export const ZileanConfigSchema = { - properties: { - enabled: { - type: 'boolean', - title: 'Enabled', - default: false - }, - url: { - type: 'string', - title: 'Url', - default: 'http://localhost:8181' - }, - timeout: { - type: 'integer', - title: 'Timeout', - default: 30 - }, - ratelimit: { - type: 'boolean', - title: 'Ratelimit', - default: true, - deprecated: true - } - }, - type: 'object', - title: 'ZileanConfig' } as const; \ No newline at end of file diff --git a/src/client/services.gen.ts b/src/client/services.gen.ts index a841309..321a6d5 100644 --- a/src/client/services.gen.ts +++ b/src/client/services.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; -import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse2, EventsError, EventsResponse, MountError, MountResponse, OverseerrWebhookOverseerrPostError, OverseerrWebhookOverseerrPostResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse2, SaveSettingsError, SaveSettingsResponse2, GetAllSettingsError, GetAllSettingsResponse2, GetSettingsData, GetSettingsError, GetSettingsResponse2, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse2, SetSettingsSettingsSetPostData, SetSettingsSettingsSetPostError, SetSettingsSettingsSetPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse2, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, SetTorrentRdMagnetData, SetTorrentRdMagnetError, SetTorrentRdMagnetResponse, SetTorrentRdItemsIdSetTorrentRdPostData, SetTorrentRdItemsIdSetTorrentRdPostError, SetTorrentRdItemsIdSetTorrentRdPostResponse, ScrapeData, ScrapeError, ScrapeResponse2, GetRdTorrentsData, GetRdTorrentsError, GetRdTorrentsResponse, GetTrendingData, GetTrendingError, GetTrendingResponse, GetMoviesNowPlayingData, GetMoviesNowPlayingError, GetMoviesNowPlayingResponse, GetMoviesPopularData, GetMoviesPopularError, GetMoviesPopularResponse, GetMoviesTopRatedData, GetMoviesTopRatedError, GetMoviesTopRatedResponse, GetMoviesUpcomingData, GetMoviesUpcomingError, GetMoviesUpcomingResponse, GetMovieDetailsData, GetMovieDetailsError, GetMovieDetailsResponse, GetTvAiringTodayData, GetTvAiringTodayError, GetTvAiringTodayResponse, GetTvOnTheAirData, GetTvOnTheAirError, GetTvOnTheAirResponse, GetTvPopularData, GetTvPopularError, GetTvPopularResponse, GetTvTopRatedData, GetTvTopRatedError, GetTvTopRatedResponse, GetTvDetailsData, GetTvDetailsError, GetTvDetailsResponse, GetTvSeasonDetailsData, GetTvSeasonDetailsError, GetTvSeasonDetailsResponse, GetTvEpisodeDetailsData, GetTvEpisodeDetailsError, GetTvEpisodeDetailsResponse, SearchCollectionData, SearchCollectionError, SearchCollectionResponse, SearchMovieData, SearchMovieError, SearchMovieResponse, SearchMultiData, SearchMultiError, SearchMultiResponse, SearchTvData, SearchTvError, SearchTvResponse, GetFromExternalIdData, GetFromExternalIdError, GetFromExternalIdResponse } from './types.gen'; +import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse2, EventsError, EventsResponse, MountError, MountResponse, OverseerrWebhookOverseerrPostError, OverseerrWebhookOverseerrPostResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse, SaveSettingsError, SaveSettingsResponse, GetAllSettingsError, GetAllSettingsResponse, GetSettingsData, GetSettingsError, GetSettingsResponse, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse, SetSettingsData, SetSettingsError, SetSettingsResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse2, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, SetTorrentRdMagnetData, SetTorrentRdMagnetError, SetTorrentRdMagnetResponse, SetTorrentRdItemsIdSetTorrentRdPostData, SetTorrentRdItemsIdSetTorrentRdPostError, SetTorrentRdItemsIdSetTorrentRdPostResponse, ScrapeData, ScrapeError, ScrapeResponse2, GetRdTorrentsData, GetRdTorrentsError, GetRdTorrentsResponse, GetTrendingData, GetTrendingError, GetTrendingResponse, GetMoviesNowPlayingData, GetMoviesNowPlayingError, GetMoviesNowPlayingResponse, GetMoviesPopularData, GetMoviesPopularError, GetMoviesPopularResponse, GetMoviesTopRatedData, GetMoviesTopRatedError, GetMoviesTopRatedResponse, GetMoviesUpcomingData, GetMoviesUpcomingError, GetMoviesUpcomingResponse, GetMovieDetailsData, GetMovieDetailsError, GetMovieDetailsResponse, GetTvAiringTodayData, GetTvAiringTodayError, GetTvAiringTodayResponse, GetTvOnTheAirData, GetTvOnTheAirError, GetTvOnTheAirResponse, GetTvPopularData, GetTvPopularError, GetTvPopularResponse, GetTvTopRatedData, GetTvTopRatedError, GetTvTopRatedResponse, GetTvDetailsData, GetTvDetailsError, GetTvDetailsResponse, GetTvSeasonDetailsData, GetTvSeasonDetailsError, GetTvSeasonDetailsResponse, GetTvEpisodeDetailsData, GetTvEpisodeDetailsError, GetTvEpisodeDetailsResponse, SearchCollectionData, SearchCollectionError, SearchCollectionResponse, SearchMovieData, SearchMovieError, SearchMovieResponse, SearchMultiData, SearchMultiError, SearchMultiResponse, SearchTvData, SearchTvError, SearchTvResponse, GetFromExternalIdData, GetFromExternalIdError, GetFromExternalIdResponse } from './types.gen'; export const client = createClient(createConfig()); @@ -146,7 +146,7 @@ export class SettingsService { * Load Settings */ public static loadSettings(options?: Options) { - return (options?.client ?? client).get({ + return (options?.client ?? client).get({ ...options, url: '/settings/load' }); @@ -156,7 +156,7 @@ export class SettingsService { * Save Settings */ public static saveSettings(options?: Options) { - return (options?.client ?? client).post({ + return (options?.client ?? client).post({ ...options, url: '/settings/save' }); @@ -166,7 +166,7 @@ export class SettingsService { * Get All Settings */ public static getAllSettings(options?: Options) { - return (options?.client ?? client).get({ + return (options?.client ?? client).get({ ...options, url: '/settings/get/all' }); @@ -176,7 +176,7 @@ export class SettingsService { * Get Settings */ public static getSettings(options: Options) { - return (options?.client ?? client).get({ + return (options?.client ?? client).get({ ...options, url: '/settings/get/{paths}' }); @@ -186,7 +186,7 @@ export class SettingsService { * Set All Settings */ public static setAllSettings(options: Options) { - return (options?.client ?? client).post({ + return (options?.client ?? client).post({ ...options, url: '/settings/set/all' }); @@ -195,8 +195,8 @@ export class SettingsService { /** * Set Settings */ - public static setSettingsSettingsSetPost(options: Options) { - return (options?.client ?? client).post({ + public static setSettings(options: Options) { + return (options?.client ?? client).post({ ...options, url: '/settings/set' }); diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index 49efc4a..92d7006 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -5,40 +5,6 @@ export type AddItemsResponse = { message: string; }; -export type AllDebridModel = { - enabled?: boolean; - api_key?: string; - proxy_enabled?: boolean; - proxy_url?: string; -}; - -export type AnnatarConfig = { - enabled?: boolean; - url?: string; - limit?: number; - timeout?: number; - ratelimit?: boolean; -}; - -export type AppModel = { - version?: string; - debug?: boolean; - log?: boolean; - force_refresh?: boolean; - map_metadata?: boolean; - tracemalloc?: boolean; - symlink?: SymlinkModel; - updaters?: UpdatersModel; - downloaders?: DownloadersModel; - content?: ContentModel; - scraping?: ScraperModel; - ranking?: RTNSettingsModel; - indexer?: IndexerModel; - database?: DatabaseModel; - notifications?: NotificationsModel; - post_processing?: PostProcessing; -}; - export type BelongsToCollection = { id: number; name: string; @@ -46,31 +12,6 @@ export type BelongsToCollection = { backdrop_path: (string | null); }; -export type CometConfig = { - enabled?: boolean; - url?: string; - indexers?: Array<(string)>; - timeout?: number; - ratelimit?: boolean; -}; - -export type ContentModel = { - overseerr?: OverseerrModel; - plex_watchlist?: PlexWatchlistModel; - mdblist?: MdblistModel; - listrr?: ListrrModel; - trakt?: TraktModel; -}; - -/** - * Custom Ranks used in SettingsModel. - */ -export type CustomRank = { - fetch?: boolean; - use_custom_rank?: boolean; - rank?: number; -}; - export type DataAndSuccessResponse_RDUser_ = { data: RDUser; success: boolean; @@ -90,29 +31,11 @@ export type DataAndSuccessResponse_dict_str__str__ = { success: boolean; }; -export type DatabaseModel = { - host?: string; -}; - export type Dates = { maximum: string; minimum: string; }; -export type DownloadersModel = { - video_extensions?: Array<(string)>; - prefer_speed_over_quality?: boolean; - real_debrid?: RealDebridModel; - all_debrid?: AllDebridModel; - torbox?: TorboxModel; -}; - -export type EmbyLibraryModel = { - enabled?: boolean; - api_key?: string; - url?: string; -}; - export type EventUpdate = { item_id: number; imdb_id: string; @@ -130,28 +53,12 @@ export type Genre = { name: string; }; -export type GetAllSettingsResponse = { - success: boolean; - data: AppModel; -}; - -export type GetSettingsResponse = { - success: boolean; - data: { - [key: string]: unknown; - }; -}; - export type HTTPValidationError = { detail?: Array; }; export type IncludeAdult = 'true' | 'false'; -export type IndexerModel = { - update_interval?: number; -}; - export type ItemsByImdbResponse = { success: boolean; items: Array<{ @@ -170,66 +77,20 @@ export type ItemsResponse = { total_pages: number; }; -export type JackettConfig = { - enabled?: boolean; - url?: string; - api_key?: string; - timeout?: number; - ratelimit?: boolean; -}; - -export type JellyfinLibraryModel = { - enabled?: boolean; - api_key?: string; - url?: string; -}; - -export type KnightcrawlerConfig = { - enabled?: boolean; - filter?: string; - url?: string; - timeout?: number; - ratelimit?: boolean; -}; - -export type ListrrModel = { - update_interval?: number; - enabled?: boolean; - movie_lists?: Array<(string)>; - show_lists?: Array<(string)>; - api_key?: string; -}; - -export type LoadSettingsResponse = { - success: boolean; - message: string; -}; - export type LogsResponse = { success: boolean; logs: string; }; -export type MdblistModel = { - update_interval?: number; - enabled?: boolean; - api_key?: string; - lists?: Array<(string | number)>; -}; - -export type MediafusionConfig = { - enabled?: boolean; - url?: string; - timeout?: number; - ratelimit?: boolean; - catalogs?: Array<(string)>; -}; - export type MessageAndSuccessResponse = { message: string; success: boolean; }; +export type MessageResponse = { + message: string; +}; + export type Network = { id: number; logo_path: (string | null); @@ -237,51 +98,6 @@ export type Network = { origin_country: string; }; -export type NotificationsModel = { - enabled?: boolean; - title?: string; - on_item_type?: Array<(string)>; - service_urls?: Array<(string)>; -}; - -export type OrionoidConfig = { - enabled?: boolean; - api_key?: string; - cached_results_only?: boolean; - parameters?: { - [key: string]: unknown; - }; - timeout?: number; - /** - * @deprecated - */ - ratelimit?: boolean; -}; - -export type OverseerrModel = { - update_interval?: number; - enabled?: boolean; - url?: string; - api_key?: string; - use_webhook?: boolean; -}; - -export type PlexLibraryModel = { - enabled?: boolean; - token?: string; - url?: string; -}; - -export type PlexWatchlistModel = { - update_interval?: number; - enabled?: boolean; - rss?: Array<(string)>; -}; - -export type PostProcessing = { - subliminal?: SubliminalConfig; -}; - export type ProductionCompany = { id: number; logo_path: (string | null); @@ -294,15 +110,6 @@ export type ProductionCountry = { name: string; }; -export type ProwlarrConfig = { - enabled?: boolean; - url?: string; - api_key?: string; - timeout?: number; - ratelimit?: boolean; - limiter_seconds?: number; -}; - export type RDTorrent = { id: string; hash: string; @@ -340,34 +147,6 @@ export type RDUser = { export type type = 'free' | 'premium'; -export type RTNSettingsModel = { - profile?: string; - require?: Array<(string)>; - exclude?: Array<(string)>; - preferred?: Array<(string)>; - resolutions?: { - [key: string]: (boolean); - }; - options?: { - [key: string]: unknown; - }; - languages?: { - [key: string]: unknown; - }; - custom_ranks?: { - [key: string]: { - [key: string]: CustomRank; - }; - }; -}; - -export type RealDebridModel = { - enabled?: boolean; - api_key?: string; - proxy_enabled?: boolean; - proxy_url?: string; -}; - export type RemoveResponse = { success: boolean; message: string; @@ -392,11 +171,6 @@ export type RootResponse = { version: string; }; -export type SaveSettingsResponse = { - success: boolean; - message: string; -}; - export type ScrapeResponse = { success: boolean; data: Array; @@ -408,39 +182,11 @@ export type ScrapedTorrent = { infohash: string; }; -export type ScraperModel = { - after_2?: number; - after_5?: number; - after_10?: number; - parse_debug?: boolean; - enable_aliases?: boolean; - torrentio?: TorrentioConfig; - knightcrawler?: KnightcrawlerConfig; - jackett?: JackettConfig; - prowlarr?: ProwlarrConfig; - orionoid?: OrionoidConfig; - annatar?: AnnatarConfig; - torbox_scraper?: TorBoxScraperConfig; - mediafusion?: MediafusionConfig; - zilean?: ZileanConfig; - comet?: CometConfig; -}; - -export type SetAllSettingsResponse = { - success: boolean; - message: string; -}; - export type SetSettings = { key: string; value: unknown; }; -export type SetSettingsResponse = { - success: boolean; - message: string; -}; - export type SetTorrentRDResponse = { success: boolean; message: string; @@ -480,22 +226,6 @@ export type StatsResponse = { }; }; -export type SubliminalConfig = { - enabled?: boolean; - languages?: Array<(string)>; - providers?: { - [key: string]: unknown; - }; -}; - -export type SymlinkModel = { - rclone_path?: string; - library_path?: string; - separate_anime_dirs?: boolean; - repair_symlinks?: boolean; - repair_interval?: number; -}; - export type TmdbCollectionDetails = { adult: boolean; backdrop_path: (string | null); @@ -728,40 +458,6 @@ export type TmdbTVDetails = { vote_count: number; }; -export type TorBoxScraperConfig = { - enabled?: boolean; - timeout?: number; -}; - -export type TorboxModel = { - enabled?: boolean; - api_key?: string; -}; - -export type TorrentioConfig = { - enabled?: boolean; - filter?: string; - url?: string; - timeout?: number; - /** - * @deprecated - */ - ratelimit?: boolean; -}; - -export type TraktModel = { - update_interval?: number; - enabled?: boolean; - api_key?: string; - watchlist?: Array<(string)>; - user_lists?: Array<(string)>; - collection?: Array<(string)>; - fetch_trending?: boolean; - trending_count?: number; - fetch_popular?: boolean; - popular_count?: number; -}; - export type TraktOAuthInitiateResponse = { auth_url: string; }; @@ -770,29 +466,12 @@ export type TrendingType = 'all' | 'movie' | 'tv' | 'person'; export type TrendingWindow = 'day' | 'week'; -export type UpdatersModel = { - updater_interval?: number; - plex?: PlexLibraryModel; - jellyfin?: JellyfinLibraryModel; - emby?: EmbyLibraryModel; -}; - export type ValidationError = { loc: Array<(string | number)>; msg: string; type: string; }; -export type ZileanConfig = { - enabled?: boolean; - url?: string; - timeout?: number; - /** - * @deprecated - */ - ratelimit?: boolean; -}; - export type RootResponse2 = (RootResponse); export type RootError = (unknown); @@ -857,15 +536,17 @@ export type GetSettingsSchemaResponse = ({ export type GetSettingsSchemaError = (unknown); -export type LoadSettingsResponse2 = (LoadSettingsResponse); +export type LoadSettingsResponse = (MessageResponse); export type LoadSettingsError = (unknown); -export type SaveSettingsResponse2 = (SaveSettingsResponse); +export type SaveSettingsResponse = (MessageResponse); export type SaveSettingsError = (unknown); -export type GetAllSettingsResponse2 = (GetAllSettingsResponse); +export type GetAllSettingsResponse = ({ + [key: string]: unknown; +}); export type GetAllSettingsError = (unknown); @@ -875,7 +556,9 @@ export type GetSettingsData = { }; }; -export type GetSettingsResponse2 = (GetSettingsResponse); +export type GetSettingsResponse = ({ + [key: string]: unknown; +}); export type GetSettingsError = (unknown | HTTPValidationError); @@ -885,17 +568,17 @@ export type SetAllSettingsData = { }; }; -export type SetAllSettingsResponse2 = (SetAllSettingsResponse); +export type SetAllSettingsResponse = (MessageResponse); export type SetAllSettingsError = (unknown | HTTPValidationError); -export type SetSettingsSettingsSetPostData = { +export type SetSettingsData = { body: Array; }; -export type SetSettingsSettingsSetPostResponse = (SetSettingsResponse); +export type SetSettingsResponse = (MessageResponse); -export type SetSettingsSettingsSetPostError = (unknown | HTTPValidationError); +export type SetSettingsError = (unknown | HTTPValidationError); export type GetStatesResponse = (StateResponse); diff --git a/src/lib/forms/helpers.server.ts b/src/lib/forms/helpers.server.ts index 24f5acd..5477dbc 100644 --- a/src/lib/forms/helpers.server.ts +++ b/src/lib/forms/helpers.server.ts @@ -1,43 +1,23 @@ -import { env } from '$env/dynamic/private'; -const BACKEND_URL = env.BACKEND_URL || 'http://127.0.0.1:8080'; +import { SettingsService } from '$/client'; // TODO: Add toCheck // eslint-disable-next-line @typescript-eslint/no-explicit-any -export async function setSettings(fetch: any, toSet: any) { - const settings = await fetch(`${BACKEND_URL}/settings/set`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(toSet) +export async function setSettings(toSet: any) { + const settings = await SettingsService.setSettings({ + body: + toSet }); - const settingsData = await settings.json(); - - return { - data: settingsData - }; + return settings.data; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export async function saveSettings(fetch: any) { - const data = await fetch(`${BACKEND_URL}/settings/save`, { - method: 'POST' - }); - const response = await data.json(); - - return { - data: response - }; +export async function saveSettings() { + const response = await SettingsService.saveSettings(); + return response.data } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export async function loadSettings(fetch: any) { - const data = await fetch(`${BACKEND_URL}/settings/load`, { - method: 'GET' - }); - const response = await data.json(); - +export async function loadSettings() { + const response = await SettingsService.loadSettings(); return { - data: response + data: response.data }; } diff --git a/src/lib/forms/helpers.ts b/src/lib/forms/helpers.ts index cab3761..c87de9d 100644 --- a/src/lib/forms/helpers.ts +++ b/src/lib/forms/helpers.ts @@ -58,47 +58,47 @@ export type GeneralSettingsSchema = typeof generalSettingsSchema; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function generalSettingsToPass(data: any) { return { - debug: data.data.debug, - log: data.data.log, - rclone_path: data.data.symlink.rclone_path, - library_path: data.data.symlink.library_path, - separate_anime_dirs: data.data.symlink.separate_anime_dirs, - repair_symlinks: data.data.symlink.repair_symlinks, - repair_interval: data.data.symlink.repair_interval, - movie_filesize_min: data.data.downloaders.movie_filesize_min, - movie_filesize_max: data.data.downloaders.movie_filesize_max, - episode_filesize_min: data.data.downloaders.episode_filesize_min, - episode_filesize_max: data.data.downloaders.episode_filesize_max, - realdebrid_enabled: data.data.downloaders.real_debrid.enabled, - realdebrid_api_key: data.data.downloaders.real_debrid?.api_key, - realdebrid_proxy_enabled: data.data.downloaders.real_debrid?.proxy_enabled, - realdebrid_proxy_url: data.data.downloaders.real_debrid?.proxy_url, - torbox_enabled: data.data.downloaders.torbox.enabled, - torbox_api_key: data.data.downloaders.torbox?.api_key, - alldebrid_enabled: data.data.downloaders.all_debrid.enabled, - alldebrid_api_key: data.data.downloaders.all_debrid?.api_key, - alldebrid_proxy_enabled: data.data.downloaders.all_debrid?.proxy_enabled, - alldebrid_proxy_url: data.data.downloaders.all_debrid?.proxy_url, - database_host: data.data.database.host, - notifications_enabled: data.data.notifications.enabled, - notifications_title: data.data.notifications.title, - notifications_on_item_type: data.data.notifications.on_item_type, - notifications_service_urls: data.data.notifications.service_urls, - subliminal_enabled: data.data.post_processing.subliminal.enabled, - subliminal_languages: data.data.post_processing.subliminal?.languages, + debug: data.debug, + log: data.log, + rclone_path: data.symlink.rclone_path, + library_path: data.symlink.library_path, + separate_anime_dirs: data.symlink.separate_anime_dirs, + repair_symlinks: data.symlink.repair_symlinks, + repair_interval: data.symlink.repair_interval, + movie_filesize_min: data.downloaders.movie_filesize_min, + movie_filesize_max: data.downloaders.movie_filesize_max, + episode_filesize_min: data.downloaders.episode_filesize_min, + episode_filesize_max: data.downloaders.episode_filesize_max, + realdebrid_enabled: data.downloaders.real_debrid.enabled, + realdebrid_api_key: data.downloaders.real_debrid?.api_key, + realdebrid_proxy_enabled: data.downloaders.real_debrid?.proxy_enabled, + realdebrid_proxy_url: data.downloaders.real_debrid?.proxy_url, + torbox_enabled: data.downloaders.torbox.enabled, + torbox_api_key: data.downloaders.torbox?.api_key, + alldebrid_enabled: data.downloaders.all_debrid.enabled, + alldebrid_api_key: data.downloaders.all_debrid?.api_key, + alldebrid_proxy_enabled: data.downloaders.all_debrid?.proxy_enabled, + alldebrid_proxy_url: data.downloaders.all_debrid?.proxy_url, + database_host: data.database.host, + notifications_enabled: data.notifications.enabled, + notifications_title: data.notifications.title, + notifications_on_item_type: data.notifications.on_item_type, + notifications_service_urls: data.notifications.service_urls, + subliminal_enabled: data.post_processing.subliminal.enabled, + subliminal_languages: data.post_processing.subliminal?.languages, subliminal_providers_opensubtitles_enabled: - data.data.post_processing.subliminal?.providers.opensubtitles.enabled, + data.post_processing.subliminal?.providers.opensubtitles.enabled, subliminal_providers_opensubtitles_username: - data.data.post_processing.subliminal?.providers.opensubtitles.username, + data.post_processing.subliminal?.providers.opensubtitles.username, subliminal_providers_opensubtitles_password: - data.data.post_processing.subliminal?.providers.opensubtitles.password, + data.post_processing.subliminal?.providers.opensubtitles.password, subliminal_providers_opensubtitlescom_enabled: - data.data.post_processing.subliminal?.providers.opensubtitlescom.enabled, + data.post_processing.subliminal?.providers.opensubtitlescom.enabled, subliminal_providers_opensubtitlescom_username: - data.data.post_processing.subliminal?.providers.opensubtitlescom.username, + data.post_processing.subliminal?.providers.opensubtitlescom.username, subliminal_providers_opensubtitlescom_password: - data.data.post_processing.subliminal?.providers.opensubtitlescom.password, - indexer_update_interval: data.data.indexer.update_interval + data.post_processing.subliminal?.providers.opensubtitlescom.password, + indexer_update_interval: data.indexer.update_interval }; } @@ -208,10 +208,10 @@ export type MediaServerSettingsSchema = typeof mediaServerSettingsSchema; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function mediaServerSettingsToPass(data: any) { return { - update_interval: data.data.updaters.update_interval, - plex_token: data.data.updaters.plex.token, - plex_url: data.data.updaters.plex.url, - plex_enabled: data.data.updaters.plex.enabled + update_interval: data.updaters.update_interval, + plex_token: data.updaters.plex.token, + plex_url: data.updaters.plex.url, + plex_enabled: data.updaters.plex.enabled }; } @@ -299,57 +299,57 @@ export type ScrapersSettingsSchema = typeof scrapersSettingsSchema; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function scrapersSettingsToPass(data: any) { return { - after_2: data.data.scraping.after_2, - after_5: data.data.scraping.after_5, - after_10: data.data.scraping.after_10, - torrentio_url: data.data.scraping.torrentio?.url, - torrentio_enabled: data.data.scraping.torrentio.enabled, - torrentio_filter: data.data.scraping.torrentio?.filter, - torrentio_timeout: data.data.scraping.torrentio?.timeout, - torrentio_ratelimit: data.data.scraping.torrentio?.ratelimit, - knightcrawler_url: data.data.scraping.knightcrawler?.url, - knightcrawler_enabled: data.data.scraping.knightcrawler.enabled, - knightcrawler_filter: data.data.scraping.knightcrawler?.filter, - knightcrawler_timeout: data.data.scraping.knightcrawler?.timeout, - knightcrawler_ratelimit: data.data.scraping.knightcrawler?.ratelimit, - annatar_url: data.data.scraping.annatar?.url, - annatar_enabled: data.data.scraping.annatar.enabled, - annatar_limit: data.data.scraping.annatar?.limit, - annatar_timeout: data.data.scraping.annatar?.timeout, - annatar_ratelimit: data.data.scraping.annatar?.ratelimit, - orionoid_enabled: data.data.scraping.orionoid.enabled, - orionoid_api_key: data.data.scraping.orionoid?.api_key, - orionoid_limitcount: data.data.scraping.orionoid?.limitcount, - orionoid_timeout: data.data.scraping.orionoid?.timeout, - orionoid_ratelimit: data.data.scraping.orionoid?.ratelimit, - jackett_enabled: data.data.scraping.jackett.enabled, - jackett_url: data.data.scraping.jackett?.url, - jackett_api_key: data.data.scraping.jackett?.api_key, - jackett_timeout: data.data.scraping.jackett?.timeout, - jackett_ratelimit: data.data.scraping.jackett?.ratelimit, - mediafusion_url: data.data.scraping.mediafusion?.url, - mediafusion_enabled: data.data.scraping.mediafusion.enabled, - mediafusion_catalogs: data.data.scraping.mediafusion.catalogs, - mediafusion_timeout: data.data.scraping.mediafusion?.timeout, - mediafusion_ratelimit: data.data.scraping.mediafusion?.ratelimit, - prowlarr_enabled: data.data.scraping.prowlarr?.enabled, - prowlarr_url: data.data.scraping.prowlarr?.url, - prowlarr_api_key: data.data.scraping.prowlarr?.api_key, - prowlarr_timeout: data.data.scraping.prowlarr?.timeout, - prowlarr_ratelimit: data.data.scraping.prowlarr?.ratelimit, - prowlarr_limiter_seconds: data.data.scraping.prowlarr?.limiter_seconds, - torbox_scraper_enabled: data.data.scraping.torbox_scraper?.enabled, - torbox_scraper_timeout: data.data.scraping.torbox_scraper?.timeout, - torbox_scraper_ratelimit: data.data.scraping.torbox_scraper?.ratelimit, - zilean_enabled: data.data.scraping.zilean?.enabled, - zilean_url: data.data.scraping.zilean?.url, - zilean_timeout: data.data.scraping.zilean?.timeout, - zilean_ratelimit: data.data.scraping.zilean?.ratelimit, - comet_enabled: data.data.scraping.comet?.enabled, - comet_url: data.data.scraping.comet?.url, - comet_indexers: data.data.scraping.comet?.indexers, - comet_timeout: data.data.scraping.comet?.timeout, - comet_ratelimit: data.data.scraping.comet?.ratelimit + after_2: data.scraping.after_2, + after_5: data.scraping.after_5, + after_10: data.scraping.after_10, + torrentio_url: data.scraping.torrentio?.url, + torrentio_enabled: data.scraping.torrentio.enabled, + torrentio_filter: data.scraping.torrentio?.filter, + torrentio_timeout: data.scraping.torrentio?.timeout, + torrentio_ratelimit: data.scraping.torrentio?.ratelimit, + knightcrawler_url: data.scraping.knightcrawler?.url, + knightcrawler_enabled: data.scraping.knightcrawler.enabled, + knightcrawler_filter: data.scraping.knightcrawler?.filter, + knightcrawler_timeout: data.scraping.knightcrawler?.timeout, + knightcrawler_ratelimit: data.scraping.knightcrawler?.ratelimit, + annatar_url: data.scraping.annatar?.url, + annatar_enabled: data.scraping.annatar.enabled, + annatar_limit: data.scraping.annatar?.limit, + annatar_timeout: data.scraping.annatar?.timeout, + annatar_ratelimit: data.scraping.annatar?.ratelimit, + orionoid_enabled: data.scraping.orionoid.enabled, + orionoid_api_key: data.scraping.orionoid?.api_key, + orionoid_limitcount: data.scraping.orionoid?.limitcount, + orionoid_timeout: data.scraping.orionoid?.timeout, + orionoid_ratelimit: data.scraping.orionoid?.ratelimit, + jackett_enabled: data.scraping.jackett.enabled, + jackett_url: data.scraping.jackett?.url, + jackett_api_key: data.scraping.jackett?.api_key, + jackett_timeout: data.scraping.jackett?.timeout, + jackett_ratelimit: data.scraping.jackett?.ratelimit, + mediafusion_url: data.scraping.mediafusion?.url, + mediafusion_enabled: data.scraping.mediafusion.enabled, + mediafusion_catalogs: data.scraping.mediafusion.catalogs, + mediafusion_timeout: data.scraping.mediafusion?.timeout, + mediafusion_ratelimit: data.scraping.mediafusion?.ratelimit, + prowlarr_enabled: data.scraping.prowlarr?.enabled, + prowlarr_url: data.scraping.prowlarr?.url, + prowlarr_api_key: data.scraping.prowlarr?.api_key, + prowlarr_timeout: data.scraping.prowlarr?.timeout, + prowlarr_ratelimit: data.scraping.prowlarr?.ratelimit, + prowlarr_limiter_seconds: data.scraping.prowlarr?.limiter_seconds, + torbox_scraper_enabled: data.scraping.torbox_scraper?.enabled, + torbox_scraper_timeout: data.scraping.torbox_scraper?.timeout, + torbox_scraper_ratelimit: data.scraping.torbox_scraper?.ratelimit, + zilean_enabled: data.scraping.zilean?.enabled, + zilean_url: data.scraping.zilean?.url, + zilean_timeout: data.scraping.zilean?.timeout, + zilean_ratelimit: data.scraping.zilean?.ratelimit, + comet_enabled: data.scraping.comet?.enabled, + comet_url: data.scraping.comet?.url, + comet_indexers: data.scraping.comet?.indexers, + comet_timeout: data.scraping.comet?.timeout, + comet_ratelimit: data.scraping.comet?.ratelimit }; } @@ -472,33 +472,33 @@ export type ContentSettingsSchema = typeof contentSettingsSchema; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function contentSettingsToPass(data: any) { return { - overseerr_enabled: data.data.content.overseerr.enabled, - overseerr_url: data.data.content.overseerr?.url, - overseerr_api_key: data.data.content.overseerr?.api_key, - overseerr_update_interval: data.data.content.overseerr?.update_interval, - overseerr_use_webhook: data.data.content.overseerr?.use_webhook, - mdblist_enabled: data.data.content.mdblist.enabled, - mdblist_api_key: data.data.content.mdblist?.api_key, - mdblist_update_interval: data.data.content.mdblist?.update_interval, - mdblist_lists: data.data.content.mdblist?.lists, - plex_watchlist_enabled: data.data.content.plex_watchlist.enabled, - plex_watchlist_rss: data.data.content.plex_watchlist?.rss, - plex_watchlist_update_interval: data.data.content.plex_watchlist?.update_interval, - listrr_enabled: data.data.content.listrr.enabled, - listrr_api_key: data.data.content.listrr?.api_key, - listrr_update_interval: data.data.content.listrr?.update_interval, - listrr_movie_lists: data.data.content.listrr?.movie_lists, - listrr_show_lists: data.data.content.listrr?.show_lists, - trakt_enabled: data.data.content.trakt.enabled, - trakt_api_key: data.data.content.trakt?.api_key, - trakt_update_interval: data.data.content.trakt?.update_interval, - trakt_watchlist: data.data.content.trakt?.watchlist, - trakt_user_lists: data.data.content.trakt?.user_lists, - trakt_collection: data.data.content.trakt?.collection, - trakt_fetch_trending: data.data.content.trakt?.fetch_trending, - trakt_fetch_popular: data.data.content.trakt?.fetch_popular, - trakt_trending_count: data.data.content.trakt?.trending_count, - trakt_popular_count: data.data.content.trakt?.popular_count + overseerr_enabled: data.content.overseerr.enabled, + overseerr_url: data.content.overseerr?.url, + overseerr_api_key: data.content.overseerr?.api_key, + overseerr_update_interval: data.content.overseerr?.update_interval, + overseerr_use_webhook: data.content.overseerr?.use_webhook, + mdblist_enabled: data.content.mdblist.enabled, + mdblist_api_key: data.content.mdblist?.api_key, + mdblist_update_interval: data.content.mdblist?.update_interval, + mdblist_lists: data.content.mdblist?.lists, + plex_watchlist_enabled: data.content.plex_watchlist.enabled, + plex_watchlist_rss: data.content.plex_watchlist?.rss, + plex_watchlist_update_interval: data.content.plex_watchlist?.update_interval, + listrr_enabled: data.content.listrr.enabled, + listrr_api_key: data.content.listrr?.api_key, + listrr_update_interval: data.content.listrr?.update_interval, + listrr_movie_lists: data.content.listrr?.movie_lists, + listrr_show_lists: data.content.listrr?.show_lists, + trakt_enabled: data.content.trakt.enabled, + trakt_api_key: data.content.trakt?.api_key, + trakt_update_interval: data.content.trakt?.update_interval, + trakt_watchlist: data.content.trakt?.watchlist, + trakt_user_lists: data.content.trakt?.user_lists, + trakt_collection: data.content.trakt?.collection, + trakt_fetch_trending: data.content.trakt?.fetch_trending, + trakt_fetch_popular: data.content.trakt?.fetch_popular, + trakt_trending_count: data.content.trakt?.trending_count, + trakt_popular_count: data.content.trakt?.popular_count }; } diff --git a/src/routes/settings/about/+page.server.ts b/src/routes/settings/about/+page.server.ts index c940b80..e3e75a3 100644 --- a/src/routes/settings/about/+page.server.ts +++ b/src/routes/settings/about/+page.server.ts @@ -3,17 +3,21 @@ import { error } from '@sveltejs/kit'; import fs from 'fs/promises'; import path from 'path'; import { dev } from '$app/environment'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { +export const load: PageServerLoad = async () => { async function getAboutInfo() { - try { - const toGet = ['version', 'symlink']; - const results = await fetch(`${locals.BACKEND_URL}/settings/get/${toGet.join(',')}`); - return await results.json(); - } catch (e) { - console.error(e); + const toGet = ['version', 'symlink']; + const { data, error: apiError } = await SettingsService.getSettings({ + path: { + paths: toGet.join(',') + } + }) + if (apiError) { error(503, 'Unable to fetch settings data. API is down.'); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return data! as any; } let versionFilePath: string = '/riven/version.txt'; if (dev) { diff --git a/src/routes/settings/about/+page.svelte b/src/routes/settings/about/+page.svelte index fa9b5ed..6bd1ab4 100644 --- a/src/routes/settings/about/+page.svelte +++ b/src/routes/settings/about/+page.svelte @@ -8,10 +8,10 @@ export let data: PageData; - const version = data.settings.data.version; // Backend version + const version = data.settings.version; // Backend version const frontendVersion = data.frontendVersion; // Frontend version passed from server - const rclone_path = data.settings.data.symlink.rclone_path; - const library_path = data.settings.data.symlink.library_path; + const rclone_path = data.settings.symlink.rclone_path; + const library_path = data.settings.symlink.library_path; interface AboutData { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/routes/settings/all.json/+server.ts b/src/routes/settings/all.json/+server.ts index 460413d..54b3984 100644 --- a/src/routes/settings/all.json/+server.ts +++ b/src/routes/settings/all.json/+server.ts @@ -1,53 +1,11 @@ +import { SettingsService } from '$/client'; import type { RequestHandler } from './$types'; -export const GET: RequestHandler = async ({ fetch, locals }) => { - try { - const response = await fetch(`${locals.BACKEND_URL}/settings/get/all`, { - method: 'GET' - }); - - if (response.ok) { - const data = await response.json(); - return new Response( - JSON.stringify( - { - data - }, - null, - 2 - ), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } else { - return new Response( - JSON.stringify({ - error: 'Failed to get settings' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); +export const GET: RequestHandler = async () => { + const { data } = await SettingsService.getAllSettings(); + return new Response(JSON.stringify(data, null, 2), { + headers: { + 'content-type': 'application/json' } - } catch (e) { - console.error(e); - return new Response( - JSON.stringify({ - error: 'Failed to get settings' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } + }); }; diff --git a/src/routes/settings/content/+page.server.ts b/src/routes/settings/content/+page.server.ts index b0c1c78..e70c6a7 100644 --- a/src/routes/settings/content/+page.server.ts +++ b/src/routes/settings/content/+page.server.ts @@ -9,22 +9,14 @@ import { contentSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${contentSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const { data } = await SettingsService.getSettings({ + path: { + paths: contentSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }); const toPassToSchema = contentSettingsToPass(data); return { @@ -45,16 +37,16 @@ export const actions: Actions = { const toSet = contentSettingsToSet(form); try { - const data = await setSettings(event.fetch, toSet); - if (!data.data.success) { + const data = await setSettings(toSet); + if (!data) { return message(form, `Service(s) failed to initialize. Please check your settings.`, { status: 400 }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _save = await saveSettings(event.fetch); + const _save = await saveSettings(); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _load = await loadSettings(event.fetch); + const _load = await loadSettings(); } catch (e) { console.error(e); return message(form, 'Unable to save settings. API is down.', { diff --git a/src/routes/settings/general/+page.server.ts b/src/routes/settings/general/+page.server.ts index 8cd7010..dd7a7ae 100644 --- a/src/routes/settings/general/+page.server.ts +++ b/src/routes/settings/general/+page.server.ts @@ -9,22 +9,14 @@ import { generalSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${generalSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const { data } = await SettingsService.getSettings({ + path: { + paths: generalSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }); const toPassToSchema = generalSettingsToPass(data); return { @@ -45,16 +37,16 @@ export const actions: Actions = { const toSet = generalSettingsToSet(form); try { - const data = await setSettings(event.fetch, toSet); - if (!data.data.success) { + const data = await setSettings(toSet); + if (!data) { return message(form, `Service(s) failed to initialize. Please check your settings.`, { status: 400 }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _save = await saveSettings(event.fetch); + const _save = await saveSettings(); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _load = await loadSettings(event.fetch); + const _load = await loadSettings(); } catch (e) { console.error(e); return message(form, 'Unable to save settings. API is down.', { diff --git a/src/routes/settings/mediaserver/+page.server.ts b/src/routes/settings/mediaserver/+page.server.ts index fbb538e..a5b8815 100644 --- a/src/routes/settings/mediaserver/+page.server.ts +++ b/src/routes/settings/mediaserver/+page.server.ts @@ -1,7 +1,7 @@ import type { PageServerLoad, Actions } from './$types'; import { superValidate, message } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { fail, error, redirect } from '@sveltejs/kit'; +import { fail, redirect } from '@sveltejs/kit'; import { mediaServerSettingsSchema, mediaServerSettingsToGet, @@ -9,22 +9,15 @@ import { mediaServerSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${mediaServerSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); - } - } +export const load: PageServerLoad = async () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + const {data} = await SettingsService.getSettings({ + path: { + paths: mediaServerSettingsToGet.join(',') + } + }); const toPassToSchema = mediaServerSettingsToPass(data); return { @@ -45,16 +38,16 @@ export const actions: Actions = { const toSet = mediaServerSettingsToSet(form); try { - const data = await setSettings(event.fetch, toSet); - if (!data.data.success) { + const data = await setSettings(toSet); + if (!data) { return message(form, `Service(s) failed to initialize. Please check your settings.`, { status: 400 }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _save = await saveSettings(event.fetch); + const _save = await saveSettings(); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _load = await loadSettings(event.fetch); + const _load = await loadSettings(); } catch (e) { console.error(e); return message(form, 'Unable to save settings. API is down.', { diff --git a/src/routes/settings/scrapers/+page.server.ts b/src/routes/settings/scrapers/+page.server.ts index 098057e..6ac35fe 100644 --- a/src/routes/settings/scrapers/+page.server.ts +++ b/src/routes/settings/scrapers/+page.server.ts @@ -9,22 +9,14 @@ import { scrapersSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${scrapersSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const { data } = await SettingsService.getSettings({ + path: { + paths: scrapersSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }); const toPassToSchema = scrapersSettingsToPass(data); return { @@ -45,16 +37,16 @@ export const actions: Actions = { const toSet = scrapersSettingsToSet(form); try { - const data = await setSettings(event.fetch, toSet); - if (!data.data.success) { + const data = await setSettings(toSet); + if (!data) { return message(form, `Service(s) failed to initialize. Please check your settings.`, { status: 400 }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _save = await saveSettings(event.fetch); + const _save = await saveSettings(); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _load = await loadSettings(event.fetch); + const _load = await loadSettings(); } catch (e) { console.error(e); return message(form, 'Unable to save settings. API is down.', { From d7424feeceeee9d3b16d8720bdd9525f6191ff7e Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 20:41:44 +0200 Subject: [PATCH 14/21] feat: add settings type schema --- src/client/schemas.gen.ts | 2147 ++++++++++++++++++++++++++++++++++++- src/client/types.gen.ts | 297 ++++- 2 files changed, 2439 insertions(+), 5 deletions(-) diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts index d7e9ff6..daf458e 100644 --- a/src/client/schemas.gen.ts +++ b/src/client/schemas.gen.ts @@ -16,6 +16,685 @@ export const AddItemsResponseSchema = { title: 'AddItemsResponse' } as const; +export const AllDebridModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + proxy_enabled: { + type: 'boolean', + title: 'Proxy Enabled', + default: false + }, + proxy_url: { + type: 'string', + title: 'Proxy Url', + default: '' + } + }, + type: 'object', + title: 'AllDebridModel' +} as const; + +export const AnnatarConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://annatar.elfhosted.com' + }, + limit: { + type: 'integer', + title: 'Limit', + default: 2000 + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'AnnatarConfig' +} as const; + +export const AppModelSchema = { + properties: { + version: { + type: 'string', + title: 'Version', + default: '0.15.1' + }, + debug: { + type: 'boolean', + title: 'Debug', + default: true + }, + log: { + type: 'boolean', + title: 'Log', + default: true + }, + force_refresh: { + type: 'boolean', + title: 'Force Refresh', + default: false + }, + map_metadata: { + type: 'boolean', + title: 'Map Metadata', + default: true + }, + tracemalloc: { + type: 'boolean', + title: 'Tracemalloc', + default: false + }, + symlink: { + '$ref': '#/components/schemas/SymlinkModel', + default: { + rclone_path: '.', + library_path: '.', + separate_anime_dirs: false, + repair_symlinks: false, + repair_interval: 6 + } + }, + updaters: { + '$ref': '#/components/schemas/UpdatersModel', + default: { + updater_interval: 120, + plex: { + enabled: false, + token: '', + url: 'http://localhost:32400' + }, + jellyfin: { + api_key: '', + enabled: false, + url: 'http://localhost:8096' + }, + emby: { + api_key: '', + enabled: false, + url: 'http://localhost:8096' + } + } + }, + downloaders: { + '$ref': '#/components/schemas/DownloadersModel', + default: { + video_extensions: ['mp4', 'mkv', 'avi'], + prefer_speed_over_quality: true, + real_debrid: { + api_key: '', + enabled: false, + proxy_enabled: false, + proxy_url: '' + }, + all_debrid: { + api_key: '', + enabled: false, + proxy_enabled: false, + proxy_url: '' + }, + torbox: { + api_key: '', + enabled: false + } + } + }, + content: { + '$ref': '#/components/schemas/ContentModel', + default: { + overseerr: { + api_key: '', + enabled: false, + update_interval: 60, + url: 'http://localhost:5055', + use_webhook: false + }, + plex_watchlist: { + enabled: false, + rss: [], + update_interval: 60 + }, + mdblist: { + api_key: '', + enabled: false, + lists: [], + update_interval: 300 + }, + listrr: { + api_key: '', + enabled: false, + movie_lists: [], + show_lists: [], + update_interval: 300 + }, + trakt: { + api_key: '', + collection: [], + enabled: false, + fetch_popular: false, + fetch_trending: false, + popular_count: 10, + trending_count: 10, + update_interval: 300, + user_lists: [], + watchlist: [] + } + } + }, + scraping: { + '$ref': '#/components/schemas/ScraperModel', + default: { + after_2: 2, + after_5: 6, + after_10: 24, + parse_debug: false, + enable_aliases: true, + torrentio: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + ratelimit: true, + timeout: 30, + url: 'http://torrentio.strem.fun' + }, + knightcrawler: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + ratelimit: true, + timeout: 30, + url: 'https://knightcrawler.elfhosted.com' + }, + jackett: { + api_key: '', + enabled: false, + ratelimit: true, + timeout: 30, + url: 'http://localhost:9117' + }, + prowlarr: { + api_key: '', + enabled: false, + limiter_seconds: 60, + ratelimit: true, + timeout: 30, + url: 'http://localhost:9696' + }, + orionoid: { + api_key: '', + cached_results_only: false, + enabled: false, + parameters: { + limitcount: 5, + video3d: 'false', + videoquality: 'sd_hd8k' + }, + ratelimit: true, + timeout: 30 + }, + annatar: { + enabled: false, + limit: 2000, + ratelimit: true, + timeout: 30, + url: 'http://annatar.elfhosted.com' + }, + torbox_scraper: { + enabled: false, + timeout: 30 + }, + mediafusion: { + catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'], + enabled: false, + ratelimit: true, + timeout: 30, + url: 'https://mediafusion.elfhosted.com' + }, + zilean: { + enabled: false, + ratelimit: true, + timeout: 30, + url: 'http://localhost:8181' + }, + comet: { + enabled: false, + indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], + ratelimit: true, + timeout: 30, + url: 'http://localhost:8000' + } + } + }, + ranking: { + '$ref': '#/components/schemas/RTNSettingsModel', + default: { + profile: 'default', + require: [], + exclude: [], + preferred: [], + resolutions: { + '1080p': true, + '2160p': false, + '360p': false, + '480p': false, + '720p': true, + unknown: true + }, + options: { + allow_english_in_languages: false, + remove_all_trash: true, + remove_ranks_under: -10000, + remove_unknown_languages: false, + title_similarity: 0.85 + }, + languages: { + exclude: [], + preferred: [], + required: [] + }, + custom_ranks: { + audio: { + aac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + ac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + atmos: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital_plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossless: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossy: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + eac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + flac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mono: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + mp3: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + stereo: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + surround: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + truehd: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + extras: { + '3d': { + fetch: false, + rank: 0, + use_custom_rank: false + }, + converted: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + documentary: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dubbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + edition: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hardcoded: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + network: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + proper: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + repack: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + retail: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + site: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + subbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + upscaled: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + hdr: { + '10bit': { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_vision: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr10plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + sdr: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + quality: { + av1: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + avc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + bluray: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dvd: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdtv: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hevc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mpeg: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + remux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhs: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + web: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webdl: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webmux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + xvid: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + rips: { + bdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + brrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dvdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + ppvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + satrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + tvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + uhdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhsrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webdlrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webrip: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + trash: { + cam: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + clean_audio: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + pdtv: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + r5: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + screener: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + size: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telecine: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telesync: { + fetch: false, + rank: 0, + use_custom_rank: false + } + } + } + } + }, + indexer: { + '$ref': '#/components/schemas/IndexerModel', + default: { + update_interval: 3600 + } + }, + database: { + '$ref': '#/components/schemas/DatabaseModel', + default: { + host: 'postgresql+psycopg2://postgres:postgres@localhost/riven' + } + }, + notifications: { + '$ref': '#/components/schemas/NotificationsModel', + default: { + enabled: false, + title: 'Riven completed something!', + on_item_type: ['movie', 'show', 'season'], + service_urls: [] + } + }, + post_processing: { + '$ref': '#/components/schemas/PostProcessing', + default: { + subliminal: { + enabled: false, + languages: ['eng'], + providers: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + } + } + }, + type: 'object', + title: 'AppModel' +} as const; + export const BelongsToCollectionSchema = { properties: { id: { @@ -54,6 +733,123 @@ export const BelongsToCollectionSchema = { title: 'BelongsToCollection' } as const; +export const CometConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8000' + }, + indexers: { + items: { + type: 'string' + }, + type: 'array', + title: 'Indexers', + default: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'] + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'CometConfig' +} as const; + +export const ContentModelSchema = { + properties: { + overseerr: { + '$ref': '#/components/schemas/OverseerrModel', + default: { + update_interval: 60, + enabled: false, + url: 'http://localhost:5055', + api_key: '', + use_webhook: false + } + }, + plex_watchlist: { + '$ref': '#/components/schemas/PlexWatchlistModel', + default: { + update_interval: 60, + enabled: false, + rss: [] + } + }, + mdblist: { + '$ref': '#/components/schemas/MdblistModel', + default: { + update_interval: 300, + enabled: false, + api_key: '', + lists: [] + } + }, + listrr: { + '$ref': '#/components/schemas/ListrrModel', + default: { + update_interval: 300, + enabled: false, + movie_lists: [], + show_lists: [], + api_key: '' + } + }, + trakt: { + '$ref': '#/components/schemas/TraktModel', + default: { + update_interval: 300, + enabled: false, + api_key: '', + watchlist: [], + user_lists: [], + collection: [], + fetch_trending: false, + trending_count: 10, + fetch_popular: false, + popular_count: 10 + } + } + }, + type: 'object', + title: 'ContentModel' +} as const; + +export const CustomRankSchema = { + properties: { + fetch: { + type: 'boolean', + title: 'Fetch', + default: true + }, + use_custom_rank: { + type: 'boolean', + title: 'Use Custom Rank', + default: false + }, + rank: { + type: 'integer', + title: 'Rank', + default: 0 + } + }, + type: 'object', + title: 'CustomRank', + description: 'Custom Ranks used in SettingsModel.' +} as const; + export const DataAndSuccessResponse_RDUser_Schema = { properties: { data: { @@ -110,6 +906,18 @@ export const DataAndSuccessResponse_dict_str__str__Schema = { title: 'DataAndSuccessResponse[dict[str, str]]' } as const; +export const DatabaseModelSchema = { + properties: { + host: { + type: 'string', + title: 'Host', + default: 'postgresql+psycopg2://postgres:postgres@localhost/riven' + } + }, + type: 'object', + title: 'DatabaseModel' +} as const; + export const DatesSchema = { properties: { maximum: { @@ -128,6 +936,73 @@ export const DatesSchema = { title: 'Dates' } as const; +export const DownloadersModelSchema = { + properties: { + video_extensions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Video Extensions', + default: ['mp4', 'mkv', 'avi'] + }, + prefer_speed_over_quality: { + type: 'boolean', + title: 'Prefer Speed Over Quality', + default: true + }, + real_debrid: { + '$ref': '#/components/schemas/RealDebridModel', + default: { + enabled: false, + api_key: '', + proxy_enabled: false, + proxy_url: '' + } + }, + all_debrid: { + '$ref': '#/components/schemas/AllDebridModel', + default: { + enabled: false, + api_key: '', + proxy_enabled: false, + proxy_url: '' + } + }, + torbox: { + '$ref': '#/components/schemas/TorboxModel', + default: { + enabled: false, + api_key: '' + } + } + }, + type: 'object', + title: 'DownloadersModel' +} as const; + +export const EmbyLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8096' + } + }, + type: 'object', + title: 'EmbyLibraryModel' +} as const; + export const EventUpdateSchema = { properties: { item_id: { @@ -206,6 +1081,18 @@ export const IncludeAdultSchema = { title: 'IncludeAdult' } as const; +export const IndexerModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 3600 + } + }, + type: 'object', + title: 'IndexerModel' +} as const; + export const ItemsByImdbResponseSchema = { properties: { success: { @@ -260,6 +1147,130 @@ export const ItemsResponseSchema = { title: 'ItemsResponse' } as const; +export const JackettConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:9117' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'JackettConfig' +} as const; + +export const JellyfinLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8096' + } + }, + type: 'object', + title: 'JellyfinLibraryModel' +} as const; + +export const KnightcrawlerConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + filter: { + type: 'string', + title: 'Filter', + default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' + }, + url: { + type: 'string', + title: 'Url', + default: 'https://knightcrawler.elfhosted.com' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + } + }, + type: 'object', + title: 'KnightcrawlerConfig' +} as const; + +export const ListrrModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + movie_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'Movie Lists', + default: [] + }, + show_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'Show Lists', + default: [] + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + } + }, + type: 'object', + title: 'ListrrModel' +} as const; + export const LogsResponseSchema = { properties: { success: { @@ -276,6 +1287,78 @@ export const LogsResponseSchema = { title: 'LogsResponse' } as const; +export const MdblistModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + lists: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Lists', + default: [] + } + }, + type: 'object', + title: 'MdblistModel' +} as const; + +export const MediafusionConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'https://mediafusion.elfhosted.com' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + }, + catalogs: { + items: { + type: 'string' + }, + type: 'array', + title: 'Catalogs', + default: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] + } + }, + type: 'object', + title: 'MediafusionConfig' +} as const; + export const MessageAndSuccessResponseSchema = { properties: { message: { @@ -335,6 +1418,186 @@ export const NetworkSchema = { title: 'Network' } as const; +export const NotificationsModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + title: { + type: 'string', + title: 'Title', + default: 'Riven completed something!' + }, + on_item_type: { + items: { + type: 'string' + }, + type: 'array', + title: 'On Item Type', + default: ['movie', 'show', 'season'] + }, + service_urls: { + items: { + type: 'string' + }, + type: 'array', + title: 'Service Urls', + default: [] + } + }, + type: 'object', + title: 'NotificationsModel' +} as const; + +export const OrionoidConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + cached_results_only: { + type: 'boolean', + title: 'Cached Results Only', + default: false + }, + parameters: { + type: 'object', + title: 'Parameters', + default: { + video3d: 'false', + videoquality: 'sd_hd8k', + limitcount: 5 + } + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'OrionoidConfig' +} as const; + +export const OverseerrModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 60 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:5055' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + use_webhook: { + type: 'boolean', + title: 'Use Webhook', + default: false + } + }, + type: 'object', + title: 'OverseerrModel' +} as const; + +export const PlexLibraryModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + token: { + type: 'string', + title: 'Token', + default: '' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:32400' + } + }, + type: 'object', + title: 'PlexLibraryModel' +} as const; + +export const PlexWatchlistModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 60 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + rss: { + items: { + type: 'string' + }, + type: 'array', + title: 'Rss', + default: [] + } + }, + type: 'object', + title: 'PlexWatchlistModel' +} as const; + +export const PostProcessingSchema = { + properties: { + subliminal: { + '$ref': '#/components/schemas/SubliminalConfig', + default: { + enabled: false, + languages: ['eng'], + providers: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + } + }, + type: 'object', + title: 'PostProcessing' +} as const; + export const ProductionCompanySchema = { properties: { id: { @@ -378,8 +1641,45 @@ export const ProductionCountrySchema = { } }, type: 'object', - required: ['iso_3166_1', 'name'], - title: 'ProductionCountry' + required: ['iso_3166_1', 'name'], + title: 'ProductionCountry' +} as const; + +export const ProwlarrConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:9696' + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true + }, + limiter_seconds: { + type: 'integer', + title: 'Limiter Seconds', + default: 60 + } + }, + type: 'object', + title: 'ProwlarrConfig' } as const; export const RDTorrentSchema = { @@ -505,6 +1805,448 @@ export const RDUserSchema = { title: 'RDUser' } as const; +export const RTNSettingsModelSchema = { + properties: { + profile: { + type: 'string', + title: 'Profile', + default: 'default' + }, + require: { + items: { + type: 'string' + }, + type: 'array', + title: 'Require', + default: [] + }, + exclude: { + items: { + type: 'string' + }, + type: 'array', + title: 'Exclude', + default: [] + }, + preferred: { + items: { + type: 'string' + }, + type: 'array', + title: 'Preferred', + default: [] + }, + resolutions: { + additionalProperties: { + type: 'boolean' + }, + type: 'object', + title: 'Resolutions', + default: { + '2160p': false, + '1080p': true, + '720p': true, + '480p': false, + '360p': false, + unknown: true + } + }, + options: { + type: 'object', + title: 'Options', + default: { + title_similarity: 0.85, + remove_all_trash: true, + remove_ranks_under: -10000, + remove_unknown_languages: false, + allow_english_in_languages: false + } + }, + languages: { + type: 'object', + title: 'Languages', + default: { + required: [], + exclude: [], + preferred: [] + } + }, + custom_ranks: { + additionalProperties: { + additionalProperties: { + '$ref': '#/components/schemas/CustomRank' + }, + type: 'object' + }, + type: 'object', + title: 'Custom Ranks', + default: { + quality: { + av1: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + avc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + bluray: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dvd: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdtv: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hevc: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mpeg: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + remux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhs: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + web: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webdl: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + webmux: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + xvid: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + rips: { + bdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + brrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dvdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + hdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + ppvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + satrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + tvrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + uhdrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + vhsrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webdlrip: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + webrip: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + hdr: { + '10bit': { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_vision: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hdr10plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + sdr: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + audio: { + aac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + ac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + atmos: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dolby_digital_plus: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossless: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + dts_lossy: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + eac3: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + flac: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + mono: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + mp3: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + stereo: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + surround: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + truehd: { + fetch: true, + rank: 0, + use_custom_rank: false + } + }, + extras: { + '3d': { + fetch: false, + rank: 0, + use_custom_rank: false + }, + converted: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + documentary: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + dubbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + edition: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + hardcoded: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + network: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + proper: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + repack: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + retail: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + site: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + subbed: { + fetch: true, + rank: 0, + use_custom_rank: false + }, + upscaled: { + fetch: false, + rank: 0, + use_custom_rank: false + } + }, + trash: { + cam: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + clean_audio: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + pdtv: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + r5: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + screener: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + size: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telecine: { + fetch: false, + rank: 0, + use_custom_rank: false + }, + telesync: { + fetch: false, + rank: 0, + use_custom_rank: false + } + } + } + } + }, + type: 'object', + title: 'RTNSettingsModel' +} as const; + +export const RealDebridModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + proxy_enabled: { + type: 'boolean', + title: 'Proxy Enabled', + default: false + }, + proxy_url: { + type: 'string', + title: 'Proxy Url', + default: '' + } + }, + type: 'object', + title: 'RealDebridModel' +} as const; + export const RemoveResponseSchema = { properties: { success: { @@ -633,6 +2375,140 @@ export const ScrapedTorrentSchema = { title: 'ScrapedTorrent' } as const; +export const ScraperModelSchema = { + properties: { + after_2: { + type: 'number', + title: 'After 2', + default: 2 + }, + after_5: { + type: 'integer', + title: 'After 5', + default: 6 + }, + after_10: { + type: 'integer', + title: 'After 10', + default: 24 + }, + parse_debug: { + type: 'boolean', + title: 'Parse Debug', + default: false + }, + enable_aliases: { + type: 'boolean', + title: 'Enable Aliases', + default: true + }, + torrentio: { + '$ref': '#/components/schemas/TorrentioConfig', + default: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + url: 'http://torrentio.strem.fun', + timeout: 30, + ratelimit: true + } + }, + knightcrawler: { + '$ref': '#/components/schemas/KnightcrawlerConfig', + default: { + enabled: false, + filter: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam', + url: 'https://knightcrawler.elfhosted.com', + timeout: 30, + ratelimit: true + } + }, + jackett: { + '$ref': '#/components/schemas/JackettConfig', + default: { + enabled: false, + url: 'http://localhost:9117', + api_key: '', + timeout: 30, + ratelimit: true + } + }, + prowlarr: { + '$ref': '#/components/schemas/ProwlarrConfig', + default: { + enabled: false, + url: 'http://localhost:9696', + api_key: '', + timeout: 30, + ratelimit: true, + limiter_seconds: 60 + } + }, + orionoid: { + '$ref': '#/components/schemas/OrionoidConfig', + default: { + enabled: false, + api_key: '', + cached_results_only: false, + parameters: { + limitcount: 5, + video3d: 'false', + videoquality: 'sd_hd8k' + }, + timeout: 30, + ratelimit: true + } + }, + annatar: { + '$ref': '#/components/schemas/AnnatarConfig', + default: { + enabled: false, + url: 'http://annatar.elfhosted.com', + limit: 2000, + timeout: 30, + ratelimit: true + } + }, + torbox_scraper: { + '$ref': '#/components/schemas/TorBoxScraperConfig', + default: { + enabled: false, + timeout: 30 + } + }, + mediafusion: { + '$ref': '#/components/schemas/MediafusionConfig', + default: { + enabled: false, + url: 'https://mediafusion.elfhosted.com', + timeout: 30, + ratelimit: true, + catalogs: ['prowlarr_streams', 'torrentio_streams', 'zilean_dmm_streams'] + } + }, + zilean: { + '$ref': '#/components/schemas/ZileanConfig', + default: { + enabled: false, + url: 'http://localhost:8181', + timeout: 30, + ratelimit: true + } + }, + comet: { + '$ref': '#/components/schemas/CometConfig', + default: { + enabled: false, + url: 'http://localhost:8000', + indexers: ['bitsearch', 'eztv', 'thepiratebay', 'therarbg', 'yts'], + timeout: 30, + ratelimit: true + } + } + }, + type: 'object', + title: 'ScraperModel' +} as const; + export const SetSettingsSchema = { properties: { key: { @@ -768,6 +2644,76 @@ export const StatsResponseSchema = { title: 'StatsResponse' } as const; +export const SubliminalConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + languages: { + items: { + type: 'string' + }, + type: 'array', + title: 'Languages', + default: ['eng'] + }, + providers: { + type: 'object', + title: 'Providers', + default: { + opensubtitles: { + enabled: false, + password: '', + username: '' + }, + opensubtitlescom: { + enabled: false, + password: '', + username: '' + } + } + } + }, + type: 'object', + title: 'SubliminalConfig' +} as const; + +export const SymlinkModelSchema = { + properties: { + rclone_path: { + type: 'string', + format: 'path', + title: 'Rclone Path', + default: '.' + }, + library_path: { + type: 'string', + format: 'path', + title: 'Library Path', + default: '.' + }, + separate_anime_dirs: { + type: 'boolean', + title: 'Separate Anime Dirs', + default: false + }, + repair_symlinks: { + type: 'boolean', + title: 'Repair Symlinks', + default: false + }, + repair_interval: { + type: 'number', + title: 'Repair Interval', + default: 6 + } + }, + type: 'object', + title: 'SymlinkModel' +} as const; + export const TmdbCollectionDetailsSchema = { properties: { adult: { @@ -1938,6 +3884,139 @@ export const TmdbTVDetailsSchema = { title: 'TmdbTVDetails' } as const; +export const TorBoxScraperConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + } + }, + type: 'object', + title: 'TorBoxScraperConfig' +} as const; + +export const TorboxModelSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + } + }, + type: 'object', + title: 'TorboxModel' +} as const; + +export const TorrentioConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + filter: { + type: 'string', + title: 'Filter', + default: 'sort=qualitysize%7Cqualityfilter=480p,scr,cam' + }, + url: { + type: 'string', + title: 'Url', + default: 'http://torrentio.strem.fun' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'TorrentioConfig' +} as const; + +export const TraktModelSchema = { + properties: { + update_interval: { + type: 'integer', + title: 'Update Interval', + default: 300 + }, + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + api_key: { + type: 'string', + title: 'Api Key', + default: '' + }, + watchlist: { + items: { + type: 'string' + }, + type: 'array', + title: 'Watchlist', + default: [] + }, + user_lists: { + items: { + type: 'string' + }, + type: 'array', + title: 'User Lists', + default: [] + }, + collection: { + items: { + type: 'string' + }, + type: 'array', + title: 'Collection', + default: [] + }, + fetch_trending: { + type: 'boolean', + title: 'Fetch Trending', + default: false + }, + trending_count: { + type: 'integer', + title: 'Trending Count', + default: 10 + }, + fetch_popular: { + type: 'boolean', + title: 'Fetch Popular', + default: false + }, + popular_count: { + type: 'integer', + title: 'Popular Count', + default: 10 + } + }, + type: 'object', + title: 'TraktModel' +} as const; + export const TraktOAuthInitiateResponseSchema = { properties: { auth_url: { @@ -1962,6 +4041,42 @@ export const TrendingWindowSchema = { title: 'TrendingWindow' } as const; +export const UpdatersModelSchema = { + properties: { + updater_interval: { + type: 'integer', + title: 'Updater Interval', + default: 120 + }, + plex: { + '$ref': '#/components/schemas/PlexLibraryModel', + default: { + enabled: false, + token: '', + url: 'http://localhost:32400' + } + }, + jellyfin: { + '$ref': '#/components/schemas/JellyfinLibraryModel', + default: { + enabled: false, + api_key: '', + url: 'http://localhost:8096' + } + }, + emby: { + '$ref': '#/components/schemas/EmbyLibraryModel', + default: { + enabled: false, + api_key: '', + url: 'http://localhost:8096' + } + } + }, + type: 'object', + title: 'UpdatersModel' +} as const; + export const ValidationErrorSchema = { properties: { loc: { @@ -1990,4 +4105,32 @@ export const ValidationErrorSchema = { type: 'object', required: ['loc', 'msg', 'type'], title: 'ValidationError' +} as const; + +export const ZileanConfigSchema = { + properties: { + enabled: { + type: 'boolean', + title: 'Enabled', + default: false + }, + url: { + type: 'string', + title: 'Url', + default: 'http://localhost:8181' + }, + timeout: { + type: 'integer', + title: 'Timeout', + default: 30 + }, + ratelimit: { + type: 'boolean', + title: 'Ratelimit', + default: true, + deprecated: true + } + }, + type: 'object', + title: 'ZileanConfig' } as const; \ No newline at end of file diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index 92d7006..3192208 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -5,6 +5,40 @@ export type AddItemsResponse = { message: string; }; +export type AllDebridModel = { + enabled?: boolean; + api_key?: string; + proxy_enabled?: boolean; + proxy_url?: string; +}; + +export type AnnatarConfig = { + enabled?: boolean; + url?: string; + limit?: number; + timeout?: number; + ratelimit?: boolean; +}; + +export type AppModel = { + version?: string; + debug?: boolean; + log?: boolean; + force_refresh?: boolean; + map_metadata?: boolean; + tracemalloc?: boolean; + symlink?: SymlinkModel; + updaters?: UpdatersModel; + downloaders?: DownloadersModel; + content?: ContentModel; + scraping?: ScraperModel; + ranking?: RTNSettingsModel; + indexer?: IndexerModel; + database?: DatabaseModel; + notifications?: NotificationsModel; + post_processing?: PostProcessing; +}; + export type BelongsToCollection = { id: number; name: string; @@ -12,6 +46,31 @@ export type BelongsToCollection = { backdrop_path: (string | null); }; +export type CometConfig = { + enabled?: boolean; + url?: string; + indexers?: Array<(string)>; + timeout?: number; + ratelimit?: boolean; +}; + +export type ContentModel = { + overseerr?: OverseerrModel; + plex_watchlist?: PlexWatchlistModel; + mdblist?: MdblistModel; + listrr?: ListrrModel; + trakt?: TraktModel; +}; + +/** + * Custom Ranks used in SettingsModel. + */ +export type CustomRank = { + fetch?: boolean; + use_custom_rank?: boolean; + rank?: number; +}; + export type DataAndSuccessResponse_RDUser_ = { data: RDUser; success: boolean; @@ -31,11 +90,29 @@ export type DataAndSuccessResponse_dict_str__str__ = { success: boolean; }; +export type DatabaseModel = { + host?: string; +}; + export type Dates = { maximum: string; minimum: string; }; +export type DownloadersModel = { + video_extensions?: Array<(string)>; + prefer_speed_over_quality?: boolean; + real_debrid?: RealDebridModel; + all_debrid?: AllDebridModel; + torbox?: TorboxModel; +}; + +export type EmbyLibraryModel = { + enabled?: boolean; + api_key?: string; + url?: string; +}; + export type EventUpdate = { item_id: number; imdb_id: string; @@ -59,6 +136,10 @@ export type HTTPValidationError = { export type IncludeAdult = 'true' | 'false'; +export type IndexerModel = { + update_interval?: number; +}; + export type ItemsByImdbResponse = { success: boolean; items: Array<{ @@ -77,11 +158,56 @@ export type ItemsResponse = { total_pages: number; }; +export type JackettConfig = { + enabled?: boolean; + url?: string; + api_key?: string; + timeout?: number; + ratelimit?: boolean; +}; + +export type JellyfinLibraryModel = { + enabled?: boolean; + api_key?: string; + url?: string; +}; + +export type KnightcrawlerConfig = { + enabled?: boolean; + filter?: string; + url?: string; + timeout?: number; + ratelimit?: boolean; +}; + +export type ListrrModel = { + update_interval?: number; + enabled?: boolean; + movie_lists?: Array<(string)>; + show_lists?: Array<(string)>; + api_key?: string; +}; + export type LogsResponse = { success: boolean; logs: string; }; +export type MdblistModel = { + update_interval?: number; + enabled?: boolean; + api_key?: string; + lists?: Array<(string | number)>; +}; + +export type MediafusionConfig = { + enabled?: boolean; + url?: string; + timeout?: number; + ratelimit?: boolean; + catalogs?: Array<(string)>; +}; + export type MessageAndSuccessResponse = { message: string; success: boolean; @@ -98,6 +224,51 @@ export type Network = { origin_country: string; }; +export type NotificationsModel = { + enabled?: boolean; + title?: string; + on_item_type?: Array<(string)>; + service_urls?: Array<(string)>; +}; + +export type OrionoidConfig = { + enabled?: boolean; + api_key?: string; + cached_results_only?: boolean; + parameters?: { + [key: string]: unknown; + }; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + +export type OverseerrModel = { + update_interval?: number; + enabled?: boolean; + url?: string; + api_key?: string; + use_webhook?: boolean; +}; + +export type PlexLibraryModel = { + enabled?: boolean; + token?: string; + url?: string; +}; + +export type PlexWatchlistModel = { + update_interval?: number; + enabled?: boolean; + rss?: Array<(string)>; +}; + +export type PostProcessing = { + subliminal?: SubliminalConfig; +}; + export type ProductionCompany = { id: number; logo_path: (string | null); @@ -110,6 +281,15 @@ export type ProductionCountry = { name: string; }; +export type ProwlarrConfig = { + enabled?: boolean; + url?: string; + api_key?: string; + timeout?: number; + ratelimit?: boolean; + limiter_seconds?: number; +}; + export type RDTorrent = { id: string; hash: string; @@ -147,6 +327,34 @@ export type RDUser = { export type type = 'free' | 'premium'; +export type RTNSettingsModel = { + profile?: string; + require?: Array<(string)>; + exclude?: Array<(string)>; + preferred?: Array<(string)>; + resolutions?: { + [key: string]: (boolean); + }; + options?: { + [key: string]: unknown; + }; + languages?: { + [key: string]: unknown; + }; + custom_ranks?: { + [key: string]: { + [key: string]: CustomRank; + }; + }; +}; + +export type RealDebridModel = { + enabled?: boolean; + api_key?: string; + proxy_enabled?: boolean; + proxy_url?: string; +}; + export type RemoveResponse = { success: boolean; message: string; @@ -182,6 +390,24 @@ export type ScrapedTorrent = { infohash: string; }; +export type ScraperModel = { + after_2?: number; + after_5?: number; + after_10?: number; + parse_debug?: boolean; + enable_aliases?: boolean; + torrentio?: TorrentioConfig; + knightcrawler?: KnightcrawlerConfig; + jackett?: JackettConfig; + prowlarr?: ProwlarrConfig; + orionoid?: OrionoidConfig; + annatar?: AnnatarConfig; + torbox_scraper?: TorBoxScraperConfig; + mediafusion?: MediafusionConfig; + zilean?: ZileanConfig; + comet?: CometConfig; +}; + export type SetSettings = { key: string; value: unknown; @@ -226,6 +452,22 @@ export type StatsResponse = { }; }; +export type SubliminalConfig = { + enabled?: boolean; + languages?: Array<(string)>; + providers?: { + [key: string]: unknown; + }; +}; + +export type SymlinkModel = { + rclone_path?: string; + library_path?: string; + separate_anime_dirs?: boolean; + repair_symlinks?: boolean; + repair_interval?: number; +}; + export type TmdbCollectionDetails = { adult: boolean; backdrop_path: (string | null); @@ -458,6 +700,40 @@ export type TmdbTVDetails = { vote_count: number; }; +export type TorBoxScraperConfig = { + enabled?: boolean; + timeout?: number; +}; + +export type TorboxModel = { + enabled?: boolean; + api_key?: string; +}; + +export type TorrentioConfig = { + enabled?: boolean; + filter?: string; + url?: string; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + +export type TraktModel = { + update_interval?: number; + enabled?: boolean; + api_key?: string; + watchlist?: Array<(string)>; + user_lists?: Array<(string)>; + collection?: Array<(string)>; + fetch_trending?: boolean; + trending_count?: number; + fetch_popular?: boolean; + popular_count?: number; +}; + export type TraktOAuthInitiateResponse = { auth_url: string; }; @@ -466,12 +742,29 @@ export type TrendingType = 'all' | 'movie' | 'tv' | 'person'; export type TrendingWindow = 'day' | 'week'; +export type UpdatersModel = { + updater_interval?: number; + plex?: PlexLibraryModel; + jellyfin?: JellyfinLibraryModel; + emby?: EmbyLibraryModel; +}; + export type ValidationError = { loc: Array<(string | number)>; msg: string; type: string; }; +export type ZileanConfig = { + enabled?: boolean; + url?: string; + timeout?: number; + /** + * @deprecated + */ + ratelimit?: boolean; +}; + export type RootResponse2 = (RootResponse); export type RootError = (unknown); @@ -544,9 +837,7 @@ export type SaveSettingsResponse = (MessageResponse); export type SaveSettingsError = (unknown); -export type GetAllSettingsResponse = ({ - [key: string]: unknown; -}); +export type GetAllSettingsResponse = (AppModel); export type GetAllSettingsError = (unknown); From d98d9f2d18f66d603c601efaf36b9eec51b56c14 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 20:55:56 +0200 Subject: [PATCH 15/21] feat: migrate onboarding to new client --- src/routes/onboarding/1/+page.server.ts | 20 ++++++-------------- src/routes/onboarding/2/+page.server.ts | 20 ++++++-------------- src/routes/onboarding/3/+page.server.ts | 20 ++++++-------------- src/routes/onboarding/4/+page.server.ts | 20 ++++++-------------- 4 files changed, 24 insertions(+), 56 deletions(-) diff --git a/src/routes/onboarding/1/+page.server.ts b/src/routes/onboarding/1/+page.server.ts index b82e7f3..fe3fe53 100644 --- a/src/routes/onboarding/1/+page.server.ts +++ b/src/routes/onboarding/1/+page.server.ts @@ -7,22 +7,14 @@ import { generalSettingsToGet, generalSettingsToPass } from '$lib/forms/helpers'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${generalSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const {data} = await SettingsService.getSettings({ + path: { + paths: generalSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }) const toPassToSchema = generalSettingsToPass(data); return { diff --git a/src/routes/onboarding/2/+page.server.ts b/src/routes/onboarding/2/+page.server.ts index 02948af..a38c3ba 100644 --- a/src/routes/onboarding/2/+page.server.ts +++ b/src/routes/onboarding/2/+page.server.ts @@ -7,22 +7,14 @@ import { mediaServerSettingsToGet, mediaServerSettingsToPass } from '$lib/forms/helpers'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${mediaServerSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const { data } = await SettingsService.getSettings({ + path: { + paths: mediaServerSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }) const toPassToSchema = mediaServerSettingsToPass(data); return { diff --git a/src/routes/onboarding/3/+page.server.ts b/src/routes/onboarding/3/+page.server.ts index 810b031..2a55f7b 100644 --- a/src/routes/onboarding/3/+page.server.ts +++ b/src/routes/onboarding/3/+page.server.ts @@ -7,22 +7,14 @@ import { contentSettingsToGet, contentSettingsToPass } from '$lib/forms/helpers'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${contentSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const {data} = await SettingsService.getSettings({ + path: { + paths: contentSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }) const toPassToSchema = contentSettingsToPass(data); return { diff --git a/src/routes/onboarding/4/+page.server.ts b/src/routes/onboarding/4/+page.server.ts index 894ae26..2de8c14 100644 --- a/src/routes/onboarding/4/+page.server.ts +++ b/src/routes/onboarding/4/+page.server.ts @@ -7,22 +7,14 @@ import { scrapersSettingsToGet, scrapersSettingsToPass } from '$lib/forms/helpers'; +import { SettingsService } from '$/client'; -export const load: PageServerLoad = async ({ fetch, locals }) => { - async function getPartialSettings() { - try { - const results = await fetch( - `${locals.BACKEND_URL}/settings/get/${scrapersSettingsToGet.join(',')}` - ); - return await results.json(); - } catch (e) { - console.error(e); - error(503, 'Unable to fetch settings data. API is down.'); +export const load: PageServerLoad = async () => { + const { data } = await SettingsService.getSettings({ + path: { + paths: scrapersSettingsToGet.join(',') } - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = await getPartialSettings(); + }) const toPassToSchema = scrapersSettingsToPass(data); return { From c4e22ca8a12c1e102e7166a2b777215b592ad3de Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 21:01:07 +0200 Subject: [PATCH 16/21] feat: migrate item request to new client --- src/lib/components/item-request.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/components/item-request.svelte b/src/lib/components/item-request.svelte index 4630e88..8ce2535 100644 --- a/src/lib/components/item-request.svelte +++ b/src/lib/components/item-request.svelte @@ -3,6 +3,7 @@ import { Button } from '$lib/components/ui/button'; import { toast } from 'svelte-sonner'; import { getExternalID } from '$lib/tmdb'; + import { ItemsService } from '$/client'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export let data: any; @@ -10,11 +11,13 @@ async function requestItem(id: number) { const externalIds = await getExternalID(fetch, type, id); - const response = await fetch(`/api/media/${externalIds.imdb_id}`, { - method: 'POST' - }); + const response = await ItemsService.addItems({ + query: { + imdb_ids: externalIds.imdb_id + } + }) - if (response.ok) { + if (!response.error) { toast.success('Media requested successfully'); } else { toast.error('An error occurred while requesting the media'); From 5f98b685c700d1e0495b95f4a0bdc92ff9d2247b Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 21:01:31 +0200 Subject: [PATCH 17/21] feat: remove the old api routes --- src/routes/api/media/[id]/+server.ts | 99 --------------------- src/routes/api/media/[id]/magnet/+server.ts | 74 --------------- src/routes/api/media/[id]/reset/+server.ts | 51 ----------- src/routes/api/media/[id]/retry/+server.ts | 51 ----------- src/routes/browse/+page.server.ts | 5 -- 5 files changed, 280 deletions(-) delete mode 100644 src/routes/api/media/[id]/+server.ts delete mode 100644 src/routes/api/media/[id]/magnet/+server.ts delete mode 100644 src/routes/api/media/[id]/reset/+server.ts delete mode 100644 src/routes/api/media/[id]/retry/+server.ts delete mode 100644 src/routes/browse/+page.server.ts diff --git a/src/routes/api/media/[id]/+server.ts b/src/routes/api/media/[id]/+server.ts deleted file mode 100644 index f537bc4..0000000 --- a/src/routes/api/media/[id]/+server.ts +++ /dev/null @@ -1,99 +0,0 @@ -import type { RequestHandler } from './$types'; - -export const POST: RequestHandler = async ({ params, locals }) => { - const imdb = params.id; // This is the IMDB ID - - try { - const response = await fetch(`${locals.BACKEND_URL}/items/add?imdb_ids=${imdb}`, { - method: 'POST' - }); - - if (response.ok) { - const data = await response.json(); - return new Response( - JSON.stringify({ - success: 'Media item added', - data - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } else { - return new Response( - JSON.stringify({ - error: 'Failed to add media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - } catch { - return new Response( - JSON.stringify({ - error: 'Failed to add media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } -}; - -export const DELETE: RequestHandler = async ({ params, locals }) => { - const id = params.id; - - try { - const itemDeleteResponse = await fetch(`${locals.BACKEND_URL}/items/remove?ids=${id}`, { - method: 'DELETE' - }); - - if (!itemDeleteResponse.ok) { - return new Response( - JSON.stringify({ - error: 'Failed to delete media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - - return new Response( - JSON.stringify({ - success: 'Media item deleted' - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } catch { - return new Response( - JSON.stringify({ - error: 'Failed to delete media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } -}; diff --git a/src/routes/api/media/[id]/magnet/+server.ts b/src/routes/api/media/[id]/magnet/+server.ts deleted file mode 100644 index c2c998a..0000000 --- a/src/routes/api/media/[id]/magnet/+server.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ItemsService } from '$/client'; -import type { RequestHandler } from './$types'; - -export const POST: RequestHandler = async ({ params, locals, request }) => { - const id = params.id; - const magnet = (await request.json())['magnet']; - - if (!magnet) { - return new Response( - JSON.stringify({ - error: 'No magnet provided' - }), - { - status: 400, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - - const url = new URL(`${locals.BACKEND_URL}/items/${id}/set_torrent_rd_magnet`); - url.searchParams.set('magnet', magnet); - - try { - const { data, error } = await ItemsService.setTorrentRdMagnet({ - path: { - id: parseInt(id) - }, - query: { - magnet: magnet - } - }); - - if (data) { - return new Response( - JSON.stringify({ - success: 'Magnet link added', - data: data - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } else if (error) { - return new Response( - JSON.stringify({ - error: error - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - } catch { - return new Response( - JSON.stringify({ - error: 'Failed to reach backend' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } -}; diff --git a/src/routes/api/media/[id]/reset/+server.ts b/src/routes/api/media/[id]/reset/+server.ts deleted file mode 100644 index 88b9f90..0000000 --- a/src/routes/api/media/[id]/reset/+server.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { RequestHandler } from './$types'; - -export const POST: RequestHandler = async ({ params, locals }) => { - const id = params.id; - - try { - const response = await fetch(`${locals.BACKEND_URL}/items/reset?ids=${id}`, { - method: 'POST' - }); - - if (response.ok) { - const data = await response.json(); - return new Response( - JSON.stringify({ - success: 'Media item reset', - data - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } else { - return new Response( - JSON.stringify({ - error: 'Failed to reset media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - } catch { - return new Response( - JSON.stringify({ - error: 'Failed to reset media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } -}; diff --git a/src/routes/api/media/[id]/retry/+server.ts b/src/routes/api/media/[id]/retry/+server.ts deleted file mode 100644 index d9402a3..0000000 --- a/src/routes/api/media/[id]/retry/+server.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { RequestHandler } from './$types'; - -export const POST: RequestHandler = async ({ params, locals }) => { - const id = params.id; - - try { - const response = await fetch(`${locals.BACKEND_URL}/items/retry?ids=${id}`, { - method: 'POST' - }); - - if (response.ok) { - const data = await response.json(); - return new Response( - JSON.stringify({ - success: 'Media item retried', - data - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } else { - return new Response( - JSON.stringify({ - error: 'Failed to retry media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } - } catch { - return new Response( - JSON.stringify({ - error: 'Failed to retry media item' - }), - { - status: 500, - headers: { - 'Content-Type': 'application/json' - } - } - ); - } -}; diff --git a/src/routes/browse/+page.server.ts b/src/routes/browse/+page.server.ts deleted file mode 100644 index 335e7bc..0000000 --- a/src/routes/browse/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { PageServerLoad } from './$types'; - -export const load = (async () => { - return {}; -}) satisfies PageServerLoad; From b9a8419f7c4f89aaeefff851e6ccf3ec19a981b5 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Fri, 4 Oct 2024 21:03:07 +0200 Subject: [PATCH 18/21] refactor: lint --- src/hooks.server.ts | 2 +- src/lib/components/item-request.svelte | 2 +- src/lib/forms/helpers.server.ts | 5 ++--- src/routes/onboarding/1/+page.server.ts | 5 ++--- src/routes/onboarding/2/+page.server.ts | 3 +-- src/routes/onboarding/3/+page.server.ts | 5 ++--- src/routes/onboarding/4/+page.server.ts | 3 +-- src/routes/settings/about/+page.server.ts | 2 +- src/routes/settings/content/+page.server.ts | 2 +- src/routes/settings/general/+page.server.ts | 2 +- src/routes/settings/mediaserver/+page.server.ts | 3 +-- src/routes/settings/scrapers/+page.server.ts | 2 +- src/routes/summary/+page.svelte | 5 ++++- src/routes/summary/+page.ts | 14 +++++++------- 14 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 33956c7..6d01f97 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -15,7 +15,7 @@ const setLocals: Handle = async ({ event, resolve }) => { const onboarding: Handle = async ({ event, resolve }) => { if (!event.url.pathname.startsWith('/onboarding') && event.request.method === 'GET') { - const {data, error: apiError} = await DefaultService.services(); + const { data, error: apiError } = await DefaultService.services(); if (apiError || !data) { return error(500, 'API Error'); } diff --git a/src/lib/components/item-request.svelte b/src/lib/components/item-request.svelte index 8ce2535..270515c 100644 --- a/src/lib/components/item-request.svelte +++ b/src/lib/components/item-request.svelte @@ -15,7 +15,7 @@ query: { imdb_ids: externalIds.imdb_id } - }) + }); if (!response.error) { toast.success('Media requested successfully'); diff --git a/src/lib/forms/helpers.server.ts b/src/lib/forms/helpers.server.ts index 5477dbc..19db98e 100644 --- a/src/lib/forms/helpers.server.ts +++ b/src/lib/forms/helpers.server.ts @@ -4,15 +4,14 @@ import { SettingsService } from '$/client'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export async function setSettings(toSet: any) { const settings = await SettingsService.setSettings({ - body: - toSet + body: toSet }); return settings.data; } export async function saveSettings() { const response = await SettingsService.saveSettings(); - return response.data + return response.data; } export async function loadSettings() { diff --git a/src/routes/onboarding/1/+page.server.ts b/src/routes/onboarding/1/+page.server.ts index fe3fe53..9ed4c9e 100644 --- a/src/routes/onboarding/1/+page.server.ts +++ b/src/routes/onboarding/1/+page.server.ts @@ -1,7 +1,6 @@ import type { PageServerLoad } from './$types'; import { superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { error } from '@sveltejs/kit'; import { generalSettingsSchema, generalSettingsToGet, @@ -10,11 +9,11 @@ import { import { SettingsService } from '$/client'; export const load: PageServerLoad = async () => { - const {data} = await SettingsService.getSettings({ + const { data } = await SettingsService.getSettings({ path: { paths: generalSettingsToGet.join(',') } - }) + }); const toPassToSchema = generalSettingsToPass(data); return { diff --git a/src/routes/onboarding/2/+page.server.ts b/src/routes/onboarding/2/+page.server.ts index a38c3ba..25e8012 100644 --- a/src/routes/onboarding/2/+page.server.ts +++ b/src/routes/onboarding/2/+page.server.ts @@ -1,7 +1,6 @@ import type { PageServerLoad } from './$types'; import { superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { error } from '@sveltejs/kit'; import { mediaServerSettingsSchema, mediaServerSettingsToGet, @@ -14,7 +13,7 @@ export const load: PageServerLoad = async () => { path: { paths: mediaServerSettingsToGet.join(',') } - }) + }); const toPassToSchema = mediaServerSettingsToPass(data); return { diff --git a/src/routes/onboarding/3/+page.server.ts b/src/routes/onboarding/3/+page.server.ts index 2a55f7b..133f2c5 100644 --- a/src/routes/onboarding/3/+page.server.ts +++ b/src/routes/onboarding/3/+page.server.ts @@ -1,7 +1,6 @@ import type { PageServerLoad } from './$types'; import { superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { error } from '@sveltejs/kit'; import { contentSettingsSchema, contentSettingsToGet, @@ -10,11 +9,11 @@ import { import { SettingsService } from '$/client'; export const load: PageServerLoad = async () => { - const {data} = await SettingsService.getSettings({ + const { data } = await SettingsService.getSettings({ path: { paths: contentSettingsToGet.join(',') } - }) + }); const toPassToSchema = contentSettingsToPass(data); return { diff --git a/src/routes/onboarding/4/+page.server.ts b/src/routes/onboarding/4/+page.server.ts index 2de8c14..cd1422c 100644 --- a/src/routes/onboarding/4/+page.server.ts +++ b/src/routes/onboarding/4/+page.server.ts @@ -1,7 +1,6 @@ import type { PageServerLoad } from './$types'; import { superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { error } from '@sveltejs/kit'; import { scrapersSettingsSchema, scrapersSettingsToGet, @@ -14,7 +13,7 @@ export const load: PageServerLoad = async () => { path: { paths: scrapersSettingsToGet.join(',') } - }) + }); const toPassToSchema = scrapersSettingsToPass(data); return { diff --git a/src/routes/settings/about/+page.server.ts b/src/routes/settings/about/+page.server.ts index e3e75a3..82d3287 100644 --- a/src/routes/settings/about/+page.server.ts +++ b/src/routes/settings/about/+page.server.ts @@ -12,7 +12,7 @@ export const load: PageServerLoad = async () => { path: { paths: toGet.join(',') } - }) + }); if (apiError) { error(503, 'Unable to fetch settings data. API is down.'); } diff --git a/src/routes/settings/content/+page.server.ts b/src/routes/settings/content/+page.server.ts index e70c6a7..a212de3 100644 --- a/src/routes/settings/content/+page.server.ts +++ b/src/routes/settings/content/+page.server.ts @@ -1,7 +1,7 @@ import type { PageServerLoad, Actions } from './$types'; import { superValidate, message } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { fail, error, redirect } from '@sveltejs/kit'; +import { fail, redirect } from '@sveltejs/kit'; import { contentSettingsSchema, contentSettingsToGet, diff --git a/src/routes/settings/general/+page.server.ts b/src/routes/settings/general/+page.server.ts index dd7a7ae..87cab2b 100644 --- a/src/routes/settings/general/+page.server.ts +++ b/src/routes/settings/general/+page.server.ts @@ -1,7 +1,7 @@ import type { PageServerLoad, Actions } from './$types'; import { superValidate, message } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { fail, error, redirect } from '@sveltejs/kit'; +import { fail, redirect } from '@sveltejs/kit'; import { generalSettingsSchema, generalSettingsToGet, diff --git a/src/routes/settings/mediaserver/+page.server.ts b/src/routes/settings/mediaserver/+page.server.ts index a5b8815..5d3095a 100644 --- a/src/routes/settings/mediaserver/+page.server.ts +++ b/src/routes/settings/mediaserver/+page.server.ts @@ -12,8 +12,7 @@ import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.serv import { SettingsService } from '$/client'; export const load: PageServerLoad = async () => { - - const {data} = await SettingsService.getSettings({ + const { data } = await SettingsService.getSettings({ path: { paths: mediaServerSettingsToGet.join(',') } diff --git a/src/routes/settings/scrapers/+page.server.ts b/src/routes/settings/scrapers/+page.server.ts index 6ac35fe..ce8b396 100644 --- a/src/routes/settings/scrapers/+page.server.ts +++ b/src/routes/settings/scrapers/+page.server.ts @@ -1,7 +1,7 @@ import type { PageServerLoad, Actions } from './$types'; import { superValidate, message } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; -import { fail, error, redirect } from '@sveltejs/kit'; +import { fail, redirect } from '@sveltejs/kit'; import { scrapersSettingsSchema, scrapersSettingsToGet, diff --git a/src/routes/summary/+page.svelte b/src/routes/summary/+page.svelte index 994dd03..3ccf9fc 100644 --- a/src/routes/summary/+page.svelte +++ b/src/routes/summary/+page.svelte @@ -39,7 +39,10 @@ } ]; - function sortServices(services: string[], data?: Record): Record { + function sortServices( + services: string[], + data?: Record + ): Record { if (!data) { const sortedData = {} as Record; services.forEach((service) => { diff --git a/src/routes/summary/+page.ts b/src/routes/summary/+page.ts index 0ff01ad..20f8159 100644 --- a/src/routes/summary/+page.ts +++ b/src/routes/summary/+page.ts @@ -1,9 +1,9 @@ -import { DefaultService } from "$/client" -import type { PageLoad } from "./$types" +import { DefaultService } from '$/client'; +import type { PageLoad } from './$types'; export const load: PageLoad = async () => { - return { - stats: (await DefaultService.stats()).data, - services: (await DefaultService.services()).data - } -} \ No newline at end of file + return { + stats: (await DefaultService.stats()).data, + services: (await DefaultService.services()).data + }; +}; From 245bb1b351badaf8c5c138c17f4b21ad8ad96d01 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Sat, 5 Oct 2024 12:51:46 +0200 Subject: [PATCH 19/21] refactor: move client into lib --- .prettierignore | 2 +- src/{ => lib}/client/index.ts | 0 src/{ => lib}/client/schemas.gen.ts | 0 src/{ => lib}/client/services.gen.ts | 0 src/{ => lib}/client/types.gen.ts | 0 src/lib/components/item-request.svelte | 2 +- src/lib/forms/helpers.server.ts | 2 +- src/routes/[type]/[id]/+page.server.ts | 2 +- src/routes/[type]/[id]/+page.svelte | 2 +- src/routes/[type]/[id]/[season]/+page.ts | 2 +- src/routes/library/+page.server.ts | 2 +- src/routes/onboarding/1/+page.server.ts | 2 +- src/routes/onboarding/2/+page.server.ts | 2 +- src/routes/onboarding/3/+page.server.ts | 2 +- src/routes/onboarding/4/+page.server.ts | 2 +- src/routes/settings/about/+page.server.ts | 2 +- src/routes/settings/all.json/+server.ts | 2 +- src/routes/settings/content/+page.server.ts | 2 +- src/routes/settings/general/+page.server.ts | 2 +- src/routes/settings/mediaserver/+page.server.ts | 2 +- src/routes/settings/scrapers/+page.server.ts | 2 +- src/routes/summary/+page.ts | 2 +- svelte.config.js | 5 +---- 23 files changed, 19 insertions(+), 22 deletions(-) rename src/{ => lib}/client/index.ts (100%) rename src/{ => lib}/client/schemas.gen.ts (100%) rename src/{ => lib}/client/services.gen.ts (100%) rename src/{ => lib}/client/types.gen.ts (100%) diff --git a/.prettierignore b/.prettierignore index 07cd518..4d9175b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,4 +4,4 @@ package-lock.json yarn.lock CHANGELOG.md .idea -src/client/ \ No newline at end of file +src/lib/client/ \ No newline at end of file diff --git a/src/client/index.ts b/src/lib/client/index.ts similarity index 100% rename from src/client/index.ts rename to src/lib/client/index.ts diff --git a/src/client/schemas.gen.ts b/src/lib/client/schemas.gen.ts similarity index 100% rename from src/client/schemas.gen.ts rename to src/lib/client/schemas.gen.ts diff --git a/src/client/services.gen.ts b/src/lib/client/services.gen.ts similarity index 100% rename from src/client/services.gen.ts rename to src/lib/client/services.gen.ts diff --git a/src/client/types.gen.ts b/src/lib/client/types.gen.ts similarity index 100% rename from src/client/types.gen.ts rename to src/lib/client/types.gen.ts diff --git a/src/lib/components/item-request.svelte b/src/lib/components/item-request.svelte index 270515c..7ff40c7 100644 --- a/src/lib/components/item-request.svelte +++ b/src/lib/components/item-request.svelte @@ -3,7 +3,7 @@ import { Button } from '$lib/components/ui/button'; import { toast } from 'svelte-sonner'; import { getExternalID } from '$lib/tmdb'; - import { ItemsService } from '$/client'; + import { ItemsService } from '$lib/client'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export let data: any; diff --git a/src/lib/forms/helpers.server.ts b/src/lib/forms/helpers.server.ts index 19db98e..8d8f6d8 100644 --- a/src/lib/forms/helpers.server.ts +++ b/src/lib/forms/helpers.server.ts @@ -1,4 +1,4 @@ -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; // TODO: Add toCheck // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/routes/[type]/[id]/+page.server.ts b/src/routes/[type]/[id]/+page.server.ts index 695ef99..8c152aa 100644 --- a/src/routes/[type]/[id]/+page.server.ts +++ b/src/routes/[type]/[id]/+page.server.ts @@ -1,4 +1,4 @@ -import { ItemsService } from '$/client'; +import { ItemsService } from '$lib/client'; import type { PageServerLoad } from './$types'; export const load = (async ({ params, locals }) => { diff --git a/src/routes/[type]/[id]/+page.svelte b/src/routes/[type]/[id]/+page.svelte index b3e3f2c..335c76d 100644 --- a/src/routes/[type]/[id]/+page.svelte +++ b/src/routes/[type]/[id]/+page.svelte @@ -29,7 +29,7 @@ import { Input } from '$lib/components/ui/input'; import * as Select from '$lib/components/ui/select'; import type { Selected } from 'bits-ui'; - import { ItemsService } from '$/client'; + import { ItemsService } from '$lib/client'; export let data: PageData; diff --git a/src/routes/[type]/[id]/[season]/+page.ts b/src/routes/[type]/[id]/[season]/+page.ts index 5dc77b5..285f5ed 100644 --- a/src/routes/[type]/[id]/[season]/+page.ts +++ b/src/routes/[type]/[id]/[season]/+page.ts @@ -2,7 +2,7 @@ import type { PageLoad } from './$types'; import { getTVSeasonDetails, getTVDetails } from '$lib/tmdb'; import { error } from '@sveltejs/kit'; -import { ItemsService } from '$/client'; +import { ItemsService } from '$lib/client'; export const load = (async ({ fetch, params }) => { const type = params.type; diff --git a/src/routes/library/+page.server.ts b/src/routes/library/+page.server.ts index 4b65068..f2b7d64 100644 --- a/src/routes/library/+page.server.ts +++ b/src/routes/library/+page.server.ts @@ -1,5 +1,5 @@ import type { PageServerLoad } from './$types'; -import { ItemsService, type ItemsResponse } from '$/client'; +import { ItemsService, type ItemsResponse } from '$lib/client'; import { error } from '@sveltejs/kit'; export const load = (async ({ url }) => { diff --git a/src/routes/onboarding/1/+page.server.ts b/src/routes/onboarding/1/+page.server.ts index 9ed4c9e..93ffe6a 100644 --- a/src/routes/onboarding/1/+page.server.ts +++ b/src/routes/onboarding/1/+page.server.ts @@ -6,7 +6,7 @@ import { generalSettingsToGet, generalSettingsToPass } from '$lib/forms/helpers'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/onboarding/2/+page.server.ts b/src/routes/onboarding/2/+page.server.ts index 25e8012..c1a409d 100644 --- a/src/routes/onboarding/2/+page.server.ts +++ b/src/routes/onboarding/2/+page.server.ts @@ -6,7 +6,7 @@ import { mediaServerSettingsToGet, mediaServerSettingsToPass } from '$lib/forms/helpers'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/onboarding/3/+page.server.ts b/src/routes/onboarding/3/+page.server.ts index 133f2c5..c1853b2 100644 --- a/src/routes/onboarding/3/+page.server.ts +++ b/src/routes/onboarding/3/+page.server.ts @@ -6,7 +6,7 @@ import { contentSettingsToGet, contentSettingsToPass } from '$lib/forms/helpers'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/onboarding/4/+page.server.ts b/src/routes/onboarding/4/+page.server.ts index cd1422c..148870d 100644 --- a/src/routes/onboarding/4/+page.server.ts +++ b/src/routes/onboarding/4/+page.server.ts @@ -6,7 +6,7 @@ import { scrapersSettingsToGet, scrapersSettingsToPass } from '$lib/forms/helpers'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/settings/about/+page.server.ts b/src/routes/settings/about/+page.server.ts index 82d3287..58a4c09 100644 --- a/src/routes/settings/about/+page.server.ts +++ b/src/routes/settings/about/+page.server.ts @@ -3,7 +3,7 @@ import { error } from '@sveltejs/kit'; import fs from 'fs/promises'; import path from 'path'; import { dev } from '$app/environment'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { async function getAboutInfo() { diff --git a/src/routes/settings/all.json/+server.ts b/src/routes/settings/all.json/+server.ts index 54b3984..673bc95 100644 --- a/src/routes/settings/all.json/+server.ts +++ b/src/routes/settings/all.json/+server.ts @@ -1,4 +1,4 @@ -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; import type { RequestHandler } from './$types'; export const GET: RequestHandler = async () => { diff --git a/src/routes/settings/content/+page.server.ts b/src/routes/settings/content/+page.server.ts index a212de3..e4c3e75 100644 --- a/src/routes/settings/content/+page.server.ts +++ b/src/routes/settings/content/+page.server.ts @@ -9,7 +9,7 @@ import { contentSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/settings/general/+page.server.ts b/src/routes/settings/general/+page.server.ts index 87cab2b..bc037ba 100644 --- a/src/routes/settings/general/+page.server.ts +++ b/src/routes/settings/general/+page.server.ts @@ -9,7 +9,7 @@ import { generalSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/settings/mediaserver/+page.server.ts b/src/routes/settings/mediaserver/+page.server.ts index 5d3095a..56aaf55 100644 --- a/src/routes/settings/mediaserver/+page.server.ts +++ b/src/routes/settings/mediaserver/+page.server.ts @@ -9,7 +9,7 @@ import { mediaServerSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/settings/scrapers/+page.server.ts b/src/routes/settings/scrapers/+page.server.ts index ce8b396..e800339 100644 --- a/src/routes/settings/scrapers/+page.server.ts +++ b/src/routes/settings/scrapers/+page.server.ts @@ -9,7 +9,7 @@ import { scrapersSettingsToSet } from '$lib/forms/helpers'; import { setSettings, saveSettings, loadSettings } from '$lib/forms/helpers.server'; -import { SettingsService } from '$/client'; +import { SettingsService } from '$lib/client'; export const load: PageServerLoad = async () => { const { data } = await SettingsService.getSettings({ diff --git a/src/routes/summary/+page.ts b/src/routes/summary/+page.ts index 20f8159..ecced6e 100644 --- a/src/routes/summary/+page.ts +++ b/src/routes/summary/+page.ts @@ -1,4 +1,4 @@ -import { DefaultService } from '$/client'; +import { DefaultService } from '$lib/client'; import type { PageLoad } from './$types'; export const load: PageLoad = async () => { diff --git a/svelte.config.js b/svelte.config.js index 1d42f77..fffb849 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,10 +11,7 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter(), - alias: { - $: './src' - } + adapter: adapter() } }; From c1dcf9795b3479b10bf550fd397a125ecdf5a3ef Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Sat, 5 Oct 2024 12:52:56 +0200 Subject: [PATCH 20/21] fix: update path for generating the client --- openapi-ts.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts index 2e8a3b9..1817cd9 100644 --- a/openapi-ts.config.ts +++ b/openapi-ts.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from '@hey-api/openapi-ts'; export default defineConfig({ client: '@hey-api/client-fetch', input: 'http://localhost:8080/openapi.json', - output: 'src/client', + output: 'src/lib/client', services: { // This does not suppport tree-shaking and could lead to a larger bundle size asClass: true From 10f7a6d9796873359d872c955cb246785d67a256 Mon Sep 17 00:00:00 2001 From: Filip Trplan Date: Sat, 5 Oct 2024 14:15:41 +0200 Subject: [PATCH 21/21] fix: fix imports on hooks --- src/hooks.client.ts | 4 ++-- src/hooks.server.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 5add38b..8b6a188 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,10 +1,10 @@ -import { client } from './client/services.gen'; +import { client } from '$lib/client/services.gen'; client.setConfig({ baseUrl: '/api' }); -client.interceptors.error.use((error) => { +client.interceptors.error.use((error: unknown) => { if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { return error.detail; } diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 6d01f97..07c6ae6 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -4,7 +4,7 @@ import { sequence } from '@sveltejs/kit/hooks'; import { env } from '$env/dynamic/private'; const BACKEND_URL = env.BACKEND_URL || 'http://127.0.0.1:8080'; import { db } from '$lib/server/db'; -import { client, DefaultService } from './client/services.gen'; +import { client, DefaultService } from '$lib/client/services.gen'; const setLocals: Handle = async ({ event, resolve }) => { event.locals.BACKEND_URL = BACKEND_URL; @@ -33,7 +33,7 @@ client.setConfig({ baseUrl: BACKEND_URL }); -client.interceptors.error.use((error) => { +client.interceptors.error.use((error: unknown) => { if (error && typeof error == 'object' && 'detail' in error && typeof error.detail == 'string') { return error.detail; }