From e030c0604c99a484fca1b3b7ff959f195d9a52e3 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Tue, 15 Oct 2024 11:45:41 -0400 Subject: [PATCH] feat: more dino changes --- api/deno.json | 1 - api/package-lock.json | 102 ++++++------------ api/package.json | 7 +- api/src/core/logrotate/setup-logrotate.ts | 3 +- api/src/core/utils/vms/get-hypervisor.ts | 10 +- .../remote-graphql/remote-graphql-helpers.ts | 7 +- 6 files changed, 48 insertions(+), 82 deletions(-) diff --git a/api/deno.json b/api/deno.json index c73ea7559..13ee15a7e 100644 --- a/api/deno.json +++ b/api/deno.json @@ -1,7 +1,6 @@ { "imports": { "lodash": "https://cdn.skypack.dev/lodash", - "graphql-tag": "https://cdn.skypack.dev/graphql-tag", "xml2js": "npm:xml2js", "@app/": "./src/", "@std/collections": "jsr:@std/collections@^1.0.8", diff --git a/api/package-lock.json b/api/package-lock.json index 037035542..38387895c 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -9,7 +9,7 @@ "version": "3.11.0", "license": "UNLICENSED", "dependencies": { - "@apollo/client": "^3.10.4", + "@apollo/client": "^3.11.8", "@apollo/server": "^4.10.4", "@as-integrations/fastify": "^2.1.1", "@fastify/cookie": "^9.4.0", @@ -88,6 +88,8 @@ "ws": "^8.17.0", "wtfnode": "^0.9.2", "xhr2": "^0.2.1", + "xml2js": "^0.6.2", + "zen-observable-ts": "^1.1.0", "zod": "^3.23.8" }, "bin": { @@ -163,9 +165,6 @@ }, "engines": { "node": ">=16.5.0" - }, - "optionalDependencies": { - "@vmngr/libvirt": "github:unraid/libvirt" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -196,9 +195,9 @@ } }, "node_modules/@apollo/client": { - "version": "3.10.4", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.4.tgz", - "integrity": "sha512-51gk0xOwN6Ls1EbTG5svFva1kdm2APHYTzmFhaAdvUQoJFDxfc0UwQgDxGptzH84vkPlo1qunY1FuboyF9LI3Q==", + "version": "3.11.8", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.8.tgz", + "integrity": "sha512-CgG1wbtMjsV2pRGe/eYITmV5B8lXUCYljB2gB/6jWTFQcrvirUVvKg7qtFdjYkQSFbIffU1IDyxgeaN81eTjbA==", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", "@wry/caches": "^1.0.0", @@ -218,8 +217,8 @@ "peerDependencies": { "graphql": "^15.0.0 || ^16.0.0", "graphql-ws": "^5.5.5", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0", "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" }, "peerDependenciesMeta": { @@ -5877,17 +5876,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/@vmngr/libvirt": { - "version": "0.0.6", - "resolved": "git+ssh://git@github.com/unraid/libvirt.git#437a77501c51df4143286a380cc5df010c1e9f81", - "license": "MIT", - "optional": true, - "dependencies": { - "bindings": "^1.5.0", - "node-addon-api": "^3.2.0", - "xml2js": "^0.5.0" - } - }, "node_modules/@whatwg-node/events": { "version": "0.0.2", "dev": true, @@ -6555,14 +6543,6 @@ "node": ">=8" } }, - "node_modules/bindings": { - "version": "1.5.0", - "license": "MIT", - "optional": true, - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bl": { "version": "4.1.0", "license": "MIT", @@ -9944,11 +9924,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "license": "MIT", - "optional": true - }, "node_modules/filename-reserved-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-3.0.0.tgz", @@ -10954,7 +10929,8 @@ }, "node_modules/graphql-tag": { "version": "2.12.6", - "license": "MIT", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", "dependencies": { "tslib": "^2.1.0" }, @@ -13394,8 +13370,10 @@ }, "node_modules/node-addon-api": { "version": "3.2.1", + "dev": true, "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/node-cache": { "version": "5.1.2", @@ -15759,8 +15737,7 @@ }, "node_modules/sax": { "version": "1.2.4", - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/scuid": { "version": "1.1.0", @@ -18841,9 +18818,9 @@ } }, "node_modules/xml2js": { - "version": "0.5.0", - "license": "MIT", - "optional": true, + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", "dependencies": { "sax": ">=0.6.0", "xmlbuilder": "~11.0.0" @@ -18855,7 +18832,6 @@ "node_modules/xmlbuilder": { "version": "11.0.1", "license": "MIT", - "optional": true, "engines": { "node": ">=4.0" } @@ -19156,9 +19132,9 @@ "requires": {} }, "@apollo/client": { - "version": "3.10.4", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.4.tgz", - "integrity": "sha512-51gk0xOwN6Ls1EbTG5svFva1kdm2APHYTzmFhaAdvUQoJFDxfc0UwQgDxGptzH84vkPlo1qunY1FuboyF9LI3Q==", + "version": "3.11.8", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.8.tgz", + "integrity": "sha512-CgG1wbtMjsV2pRGe/eYITmV5B8lXUCYljB2gB/6jWTFQcrvirUVvKg7qtFdjYkQSFbIffU1IDyxgeaN81eTjbA==", "requires": { "@graphql-typed-document-node/core": "^3.1.1", "@wry/caches": "^1.0.0", @@ -23049,16 +23025,6 @@ "tinyrainbow": "^1.2.0" } }, - "@vmngr/libvirt": { - "version": "git+ssh://git@github.com/unraid/libvirt.git#437a77501c51df4143286a380cc5df010c1e9f81", - "from": "@vmngr/libvirt@github:unraid/libvirt", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "node-addon-api": "^3.2.0", - "xml2js": "^0.5.0" - } - }, "@whatwg-node/events": { "version": "0.0.2", "dev": true @@ -23508,13 +23474,6 @@ "binary-extensions": { "version": "2.2.0" }, - "bindings": { - "version": "1.5.0", - "optional": true, - "requires": { - "file-uri-to-path": "1.0.0" - } - }, "bl": { "version": "4.1.0", "requires": { @@ -25845,10 +25804,6 @@ "flat-cache": "^3.0.4" } }, - "file-uri-to-path": { - "version": "1.0.0", - "optional": true - }, "filename-reserved-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-3.0.0.tgz", @@ -26550,6 +26505,8 @@ }, "graphql-tag": { "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", "requires": { "tslib": "^2.1.0" } @@ -28141,7 +28098,9 @@ }, "node-addon-api": { "version": "3.2.1", - "optional": true + "dev": true, + "optional": true, + "peer": true }, "node-cache": { "version": "5.1.2", @@ -29671,8 +29630,7 @@ "version": "2.1.2" }, "sax": { - "version": "1.2.4", - "optional": true + "version": "1.2.4" }, "scuid": { "version": "1.1.0", @@ -31597,16 +31555,16 @@ "version": "0.2.1" }, "xml2js": { - "version": "0.5.0", - "optional": true, + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", "requires": { "sax": ">=0.6.0", "xmlbuilder": "~11.0.0" } }, "xmlbuilder": { - "version": "11.0.1", - "optional": true + "version": "11.0.1" }, "xss": { "version": "1.0.14", diff --git a/api/package.json b/api/package.json index fda4b5c25..71ade7526 100644 --- a/api/package.json +++ b/api/package.json @@ -60,7 +60,7 @@ "unraid-api" ], "dependencies": { - "@apollo/client": "^3.10.4", + "@apollo/client": "^3.11.8", "@apollo/server": "^4.10.4", "@as-integrations/fastify": "^2.1.1", "@fastify/cookie": "^9.4.0", @@ -210,5 +210,10 @@ "vite-tsconfig-paths": "^4.3.2", "vitest": "^2.1.1", "zx": "^7.2.3" + }, + "overrides": { + "dependencies": { + "graphql-tag": "^2.12.6" + } } } diff --git a/api/src/core/logrotate/setup-logrotate.ts b/api/src/core/logrotate/setup-logrotate.ts index f436bb05c..beb61adae 100644 --- a/api/src/core/logrotate/setup-logrotate.ts +++ b/api/src/core/logrotate/setup-logrotate.ts @@ -9,9 +9,10 @@ export const setupLogRotation = async () => { '/etc/logrotate.d/unraid-api', ` /var/log/unraid-api/*.log { - rotate 1 + rotate 0 missingok size 5M + copytruncate } `, { mode: '644' } diff --git a/api/src/core/utils/vms/get-hypervisor.ts b/api/src/core/utils/vms/get-hypervisor.ts index 2b9153970..7b05b1df5 100644 --- a/api/src/core/utils/vms/get-hypervisor.ts +++ b/api/src/core/utils/vms/get-hypervisor.ts @@ -1,11 +1,12 @@ import { access } from 'node:fs/promises'; import { constants } from 'node:fs'; +import { Hypervisor } from '@vmngr/libvirt'; import { libvirtLogger } from '@app/core/log'; const uri = process.env.LIBVIRT_URI ?? 'qemu:///system'; -let hypervisor: unknown | null; +let hypervisor: Hypervisor | null; const libvirtPid = '/var/run/libvirt/libvirtd.pid'; @@ -18,8 +19,7 @@ const isLibvirtRunning = async (): Promise => { } }; -export const getHypervisor = async (): Promise => { - /* +export const getHypervisor = async (): Promise => { // Return hypervisor if it's already connected const running = await isLibvirtRunning(); @@ -41,7 +41,7 @@ export const getHypervisor = async (): Promise => { ); throw error; - });*/ - const hypervisor = null; + }); + return hypervisor; }; diff --git a/api/src/graphql/resolvers/subscription/remote-graphql/remote-graphql-helpers.ts b/api/src/graphql/resolvers/subscription/remote-graphql/remote-graphql-helpers.ts index 0150a5d28..9988e6e53 100644 --- a/api/src/graphql/resolvers/subscription/remote-graphql/remote-graphql-helpers.ts +++ b/api/src/graphql/resolvers/subscription/remote-graphql/remote-graphql-helpers.ts @@ -1,5 +1,8 @@ -import { type QueryOptions } from '@apollo/client/core/index.js'; -import gql from 'graphql-tag'; + +import type { QueryOptions } from "@apollo/client/core"; +import { gql } from "graphql-tag"; + +; interface ParsedQuery { query?: string; variables?: Record;