Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create types module #1807

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
packageName:
description: "Package Name (schemas, common, toolkit)"
description: "Package Name (schemas, types, toolkit)"
required: true
version:
description: "Version to publish (e.g., 1.0.0)"
Expand All @@ -20,7 +20,7 @@ jobs:

- name: Validate package name
run: |
if [[ ${{ github.event.inputs.packageName }} != "schemas" && ${{ github.event.inputs.packageName }} != "common" && ${{ github.event.inputs.packageName }} != "toolkit" ]]; then
if [[ ${{ github.event.inputs.packageName }} != "schemas" && ${{ github.event.inputs.packageName }} != "types" && ${{ github.event.inputs.packageName }} != "toolkit" ]]; then
echo "Error: Invalid package name"
exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dev": "nodemon --ignore \"*.json\" -e ts,tsx --watch src/ --exec \"yarn build\""
},
"dependencies": {
"@dappnode/types": "^0.1.0",
"@dappnode/common": "^0.1.0",
"@dappnode/dappmanager": "^0.1.0",
"@dappnode/eventbus": "^0.1.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/admin-ui/server-mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import path from "path";
import { calls } from "../src/__mock-backend__";
import { startHttpApi } from "@dappnode/dappmanager/src/api/startHttpApi";
import { LoggerMiddleware } from "@dappnode/common";
import { LoggerMiddleware } from "@dappnode/types";
import { eventBus } from "./eventBus";
import { AdminPasswordDb } from "@dappnode/dappmanager/src/api/auth/adminPasswordDb";
import { DeviceCalls } from "@dappnode/dappmanager/src/calls/device/index.js";

const testFileDir = "test_files";

Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/server-mock/mockVpnClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VpnDevice, PackageVersionData } from "@dappnode/common";
import { VpnDevice, PackageVersionData } from "@dappnode/types";
import { VpnApiClient } from "@dappnode/dappmanager/src/api/vpnApiClient";

const url = "link-to-otp/?id=617824#hdfuisf";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/autoUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AutoUpdateDataView, Routes } from "@dappnode/common";
import { AutoUpdateDataView, Routes } from "@dappnode/types";
import { pause } from "./utils/pause";

export const autoUpdate: Pick<
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/data/directory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MockDnp } from "./dnps/types";
import { mockDnps } from "./dnps";
import { DirectoryItem, DirectoryItemOk } from "@dappnode/common";
import { DirectoryItem, DirectoryItemOk } from "@dappnode/types";

function getDirectoryDnp(dnp: MockDnp, index: number): DirectoryItemOk {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InstalledPackageDetailData, PackageContainer } from "@dappnode/common";
import { InstalledPackageDetailData, PackageContainer } from "@dappnode/types";
import { sampleContainer, sampleDnp } from "./sample";
import { MockDnp } from "./dnps/types";
import { mockDnps } from "./dnps";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
UserSettingsAllDnps,
SetupWizardAllDnps,
CompatibleDnps
} from "@dappnode/common";
} from "@dappnode/types";
import { sampleRequestState } from "./sample";
import { MockDnp } from "./dnps/types";
import { mockDnps } from "./dnps";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PortProtocol } from "@dappnode/common";
import { PortProtocol } from "@dappnode/types";
import { bitcoin } from "./bitcoin";
import { MockDnp } from "./types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PortProtocol } from "@dappnode/common";
import { PortProtocol } from "@dappnode/types";
import { MockDnp } from "./types";

const dnpName = "multi-service.dnp.dappnode.eth";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PortProtocol } from "@dappnode/common";
import { PortProtocol } from "@dappnode/types";
import { MockDnp } from "./types";

const dnpName = "open-ethereum.dnp.dappnode.eth";
Expand Down
7 changes: 3 additions & 4 deletions packages/admin-ui/src/__mock-backend__/data/dnps/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import {
SpecialPermission,
InstalledPackageDetailData,
PackageContainer,
RequestedDnp,
Manifest,
SetupWizard
} from "@dappnode/common";
RequestedDnp
} from "@dappnode/types";
import { Manifest, SetupWizard } from "@dappnode/types";

export interface MockDnp {
manifest: Manifest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DirectoryItem } from "@dappnode/common";
import { DirectoryItem } from "@dappnode/types";

// Packages from ENS public.dappnode.eth
// From block 8905883 to ~ 13000000
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/data/registry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DirectoryItem } from "@dappnode/common";
import { DirectoryItem } from "@dappnode/types";
import { mockPublicDnps } from "./publicDnps";

export const registry: DirectoryItem[] = [
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/data/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
RequestedDnp,
InstalledPackageDetailData,
PackageContainer
} from "@dappnode/common";
} from "@dappnode/types";

const dnpName = "test.dnp.dappnode.eth";
export const sampleRequestState: RequestedDnp = {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/devices.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes, VpnDevice } from "@dappnode/common";
import { Routes, VpnDevice } from "@dappnode/types";

const url = "link-to-otp/?id=617824#hdfuisf";
const password = "SAMPLETEMPPASSWORD";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/fetchPkgsData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoreUpdateDataAvailable, Routes } from "@dappnode/common";
import { CoreUpdateDataAvailable, Routes } from "@dappnode/types";
import { directory, registry, dnpRequests } from "./data";

export const fetchPkgsData: Pick<
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/httpsPortal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ExposableServiceInfo,
HttpsPortalMapping,
Routes
} from "@dappnode/common";
} from "@dappnode/types";

const mappings = new Map<string, HttpsPortalMapping>();

Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IpfsClientTarget, PortProtocol, Routes } from "@dappnode/common";
import { IpfsClientTarget, PortProtocol, Routes } from "@dappnode/types";
import { autoUpdate } from "./autoUpdate";
import { devices } from "./devices";
import { fetchPkgsData } from "./fetchPkgsData";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/localProxying.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocalProxyingStatus, Routes } from "@dappnode/common";
import { LocalProxyingStatus, Routes } from "@dappnode/types";
import { pause } from "./utils/pause";

const localProxyingStatusON: LocalProxyingStatus = "running";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PackageNotificationDb, Routes } from "@dappnode/common";
import { PackageNotificationDb, Routes } from "@dappnode/types";

export const notifications: Pick<
Routes,
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/packages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InstalledPackageDetailData, Routes } from "@dappnode/common";
import { InstalledPackageDetailData, Routes } from "@dappnode/types";
import { dnpInstalled } from "./data";
import { sampleContainer, sampleDnp } from "./data/sample";
import { pause } from "./utils/pause";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/password.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from "@dappnode/common";
import { Routes } from "@dappnode/types";

let hostPasswordIsSecureState = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes, TrustedReleaseKey } from "@dappnode/common";
import { Routes, TrustedReleaseKey } from "@dappnode/types";

const initialTrustedKey: TrustedReleaseKey = {
name: "DAppNode Association",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/ssh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from "@dappnode/common";
import { Routes } from "@dappnode/types";

let sshPort = 22;
let sshStatus: "enabled" | "disabled" = "enabled";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/stakerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Routes,
Signer,
Network
} from "@dappnode/common";
} from "@dappnode/types";

export const stakerConfig: Pick<
Routes,
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/telegram.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from "@dappnode/common";
import { Routes } from "@dappnode/types";

let isEnabled = false;
let token: string | null = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/userActionLogs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes, UserActionLog } from "@dappnode/common";
import { Routes, UserActionLog } from "@dappnode/types";

const userActionLogsState: UserActionLog[] = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/volumes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pause } from "./utils/pause";
import { dnpInstalled } from "./data";
import { VolumeData, Routes } from "@dappnode/common";
import { VolumeData, Routes } from "@dappnode/types";

const volumesState = new Map<string, VolumeData>(
getInitialVolumes().map(vol => [vol.name, vol])
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/wifi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from "@dappnode/common";
import { Routes } from "@dappnode/types";

export const wifi: Pick<Routes, "wifiCredentialsGet" | "wifiReportGet"> = {
wifiCredentialsGet: async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/wireguard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from "@dappnode/common";
import { Routes } from "@dappnode/types";

const initialDevices = [
"dappnode_admin",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import filterDirectory from "pages/installer/helpers/filterDirectory";
import { DirectoryItem } from "@dappnode/common";
import { DirectoryItem } from "@dappnode/types";
import { SelectedCategories } from "pages/installer/types";

const sampleDirectoryState: DirectoryItem = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
userSettingsToFormData
} from "pages/installer/parsers/formDataParser";
import { SetupWizardFormDataReturn } from "pages/installer/types";
import { UserSettingsAllDnps } from "@dappnode/common";
import { UserSettingsAllDnps } from "@dappnode/types";
import deepmerge from "deepmerge";
import { SetupTargetAllDnps } from "types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserSettingsAllDnps } from "@dappnode/common";
import { UserSettingsAllDnps } from "@dappnode/types";
import deepmerge from "deepmerge";
import { difference, isDeepEmpty } from "utils/lodashExtended";

Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoginStatusReturn } from "@dappnode/common";
import { LoginStatusReturn } from "@dappnode/types";
import {
apiTestMode,
apiUrls,
Expand Down
7 changes: 3 additions & 4 deletions packages/admin-ui/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import {
SubscriptionsTypes,
Routes,
routesData,
ResolvedType,
parseRpcResponse,
subscriptionsFactory
} from "@dappnode/common";
ResolvedType
} from "@dappnode/types";
import { parseRpcResponse, subscriptionsFactory } from "@dappnode/common";
// Internal
import { mapSubscriptionsToRedux } from "./subscriptions";
import { initialCallsOnOpen } from "./initialCalls";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/api/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Emitter } from "mitt";
import { RpcPayload, RpcResponse } from "@dappnode/common";
import { RpcPayload, RpcResponse } from "@dappnode/types";

export type LoginStatus =
| { status: "logged-in"; username: string }
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/api/mock/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RpcPayload, RpcResponse } from "@dappnode/common";
import { RpcPayload, RpcResponse } from "@dappnode/types";
import { calls } from "../../__mock-backend__";
import { IApiRpc } from "../interface";

Expand Down
4 changes: 2 additions & 2 deletions packages/admin-ui/src/api/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import io, { Socket } from "socket.io-client";
import { Emitter } from "mitt";
import { Args, RpcPayload, RpcResponse } from "@dappnode/common";
import { Args, RpcPayload, RpcResponse } from "@dappnode/types";
import { IApiRpc } from "./interface";
import { socketIoUrl } from "params";
import { subscriptionsData } from "@dappnode/common";
import { subscriptionsData } from "@dappnode/types";

let socketGlobal: Socket | null = null;
let apiStarted = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/api/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { updateVolumes, setSystemInfo } from "services/dappnodeStatus/actions";
import { setDnpInstalled } from "services/dnpInstalled/actions";
import { updateDnpDirectory } from "services/dnpDirectory/actions";
import { updateDnpRegistry } from "services/dnpRegistry/actions";
import { Subscriptions } from "@dappnode/common";
import { Subscriptions } from "@dappnode/types";

export function mapSubscriptionsToRedux(subscriptions: Subscriptions): void {
subscriptions.directory.on(directoryDnps => {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/api/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dappmanagerDnpName, coreDnpName } from "params";
import { Args } from "@dappnode/common";
import { Args } from "@dappnode/types";

/**
* Restarting the DAPPMANAGER will cause this error
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/components/EthMultiClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ConsensusClientMainnet,
executionClientsMainnet,
consensusClientsMainnet
} from "@dappnode/common";
} from "@dappnode/types";
import { AiFillSafetyCertificate, AiFillClockCircle } from "react-icons/ai";
import { FaDatabase } from "react-icons/fa";
import Switch from "./Switch";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/components/IpfsClient.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import "./multiClient.scss";
import { IpfsClientTarget } from "@dappnode/common";
import { IpfsClientTarget } from "@dappnode/types";
import Card from "components/Card";
import { joinCssClass } from "utils/css";
import Input from "./Input";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { orderBy, isEmpty } from "lodash-es";
// Components
import Input from "components/Input";
import { UserSettingsAllDnps } from "@dappnode/common";
import { UserSettingsAllDnps } from "@dappnode/types";
import { prettyDnpName } from "utils/format";
import "./editorAdvanced.scss";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
// Components
import { SetupWizardAllDnps } from "@dappnode/common";
import { SetupWizardAllDnps } from "@dappnode/types";
import { prettyDnpName } from "utils/format";
import RenderMarkdown from "components/RenderMarkdown";
import InputField from "./InputField";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { SetupWizardField } from "@dappnode/common";
import { SetupWizardField } from "@dappnode/types";
import Input from "components/Input";
import InputFieldSelect from "./InputFieldSelect";
import InputFieldFile from "./InputFieldFile";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { joinCssClass } from "utils/css";
import newTabProps from "utils/newTabProps";
import { troubleShootMountpointsGuideUrl } from "params";
import "./selectMountpoint.scss";
import { MountpointData } from "@dappnode/common";
import { MountpointData } from "@dappnode/types";

function renderMountpointDataSummary({
mountpoint,
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/components/SetupWizard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isEqual } from "lodash-es";
// Components
import Card from "components/Card";
import Alert from "react-bootstrap/Alert";
import { UserSettingsAllDnps, SetupWizardAllDnps } from "@dappnode/common";
import { UserSettingsAllDnps, SetupWizardAllDnps } from "@dappnode/types";
import { prettyDnpName } from "utils/format";
import { EditorAdvanced } from "./EditorAdvanced";
import { EditorV2 } from "./EditorV2";
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/components/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import RepositoryFallback from "./features/RepositoryFallback";
import EnableEthicalMetrics from "./features/EnableEthicalMetrics";
// Utils
import { isEqual } from "lodash-es";
import { NewFeatureId } from "@dappnode/common";
import { NewFeatureId } from "@dappnode/types";
// styles
import "./welcome.scss";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from "react";
import { useSelector } from "react-redux";
import { EthMultiClientsAndFallback } from "components/EthMultiClient";
import { EthClientFallback, Eth2ClientTarget } from "@dappnode/common";
import { EthClientFallback, Eth2ClientTarget } from "@dappnode/types";
import { getEthClientTarget } from "services/dappnodeStatus/selectors";
import BottomButtons from "../BottomButtons";
import { api } from "api";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
fallbackToBoolean,
booleanToFallback
} from "components/EthMultiClient";
import { EthClientFallback } from "@dappnode/common";
import { EthClientFallback } from "@dappnode/types";
import BottomButtons from "../BottomButtons";
import { api } from "api";
import Alert from "react-bootstrap/Alert";
Expand Down
Loading
Loading