refactor(types): move shared types from renderer to shared directory
- Move type definitions from src/renderer/src/types/ to src/shared/types/ - Add @shared/* path alias to tsconfig.node.json and tsconfig.web.json - Update all imports from @renderer/types/* to @shared/types/* - Update AGENTS.md with new directory structure and path alias This fixes architecture violation where main/preload processes imported from renderer directory. Types are now properly shared across all processes.
This commit is contained in:
@@ -11,16 +11,13 @@ import {
|
||||
getDomain,
|
||||
deleteDomain,
|
||||
listDomains,
|
||||
saveVersion,
|
||||
listVersions,
|
||||
deleteVersion,
|
||||
saveDownload,
|
||||
saveBackup,
|
||||
isSecureStorageAvailable,
|
||||
getStorageBackend,
|
||||
} from "./storage";
|
||||
import { KintoneClient, KintoneError } from "./kintone-api";
|
||||
import type { Result } from "@renderer/types/ipc";
|
||||
import { KintoneClient, createKintoneClient } from "./kintone-api";
|
||||
import type { Result } from "@shared/types/ipc";
|
||||
import type {
|
||||
CreateDomainParams,
|
||||
UpdateDomainParams,
|
||||
@@ -35,13 +32,13 @@ import type {
|
||||
DownloadResult,
|
||||
GetVersionsParams,
|
||||
RollbackParams,
|
||||
} from "@renderer/types/ipc";
|
||||
import type { Domain, DomainWithStatus } from "@renderer/types/domain";
|
||||
} from "@shared/types/ipc";
|
||||
import type { Domain, DomainWithStatus, DomainWithPassword } from "@shared/types/domain";
|
||||
import type {
|
||||
Version,
|
||||
DownloadMetadata,
|
||||
BackupMetadata,
|
||||
} from "@renderer/types/version";
|
||||
} from "@shared/types/version";
|
||||
|
||||
// Cache for Kintone clients
|
||||
const clientCache = new Map<string, KintoneClient>();
|
||||
@@ -59,7 +56,7 @@ async function getClient(domainId: string): Promise<KintoneClient> {
|
||||
throw new Error(`Domain not found: ${domainId}`);
|
||||
}
|
||||
|
||||
const client = new KintoneClient(domainWithPassword);
|
||||
const client = createKintoneClient(domainWithPassword);
|
||||
clientCache.set(domainId, client);
|
||||
return client;
|
||||
}
|
||||
@@ -196,7 +193,7 @@ function registerTestConnection(): void {
|
||||
throw new Error(`Domain not found: ${id}`);
|
||||
}
|
||||
|
||||
const client = new KintoneClient(domainWithPassword);
|
||||
const client = createKintoneClient(domainWithPassword);
|
||||
const result = await client.testConnection();
|
||||
|
||||
return {
|
||||
@@ -226,7 +223,7 @@ function registerTestDomainConnection(): void {
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
const client = new KintoneClient(tempDomain);
|
||||
const client = createKintoneClient(tempDomain);
|
||||
const result = await client.testConnection();
|
||||
|
||||
if (!result.success) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { KintoneRestAPIClient } from "@kintone/rest-api-client";
|
||||
import type { KintoneRestAPIError } from "@kintone/rest-api-client";
|
||||
import type { DomainWithPassword } from "@renderer/types/domain";
|
||||
import type { DomainWithPassword } from "@shared/types/domain";
|
||||
import type {
|
||||
KintoneSpace,
|
||||
KintoneApp,
|
||||
@@ -10,7 +10,7 @@ import type {
|
||||
KintoneApiError,
|
||||
JSFileConfig,
|
||||
CSSFileConfig,
|
||||
} from "@renderer/types/kintone";
|
||||
} from "@shared/types/kintone";
|
||||
|
||||
/**
|
||||
* Custom error class for Kintone API errors
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import { app, safeStorage } from "electron";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import type { Domain, DomainWithPassword } from "@renderer/types/domain";
|
||||
import type { Domain, DomainWithPassword } from "@shared/types/domain";
|
||||
import type {
|
||||
Version,
|
||||
DownloadMetadata,
|
||||
BackupMetadata,
|
||||
} from "@renderer/types/version";
|
||||
} from "@shared/types/version";
|
||||
|
||||
// ==================== Path Helpers ====================
|
||||
|
||||
|
||||
8
src/preload/index.d.ts
vendored
8
src/preload/index.d.ts
vendored
@@ -14,15 +14,15 @@ import type {
|
||||
DownloadResult,
|
||||
GetVersionsParams,
|
||||
RollbackParams,
|
||||
} from "@renderer/types/ipc";
|
||||
import type { Domain, DomainWithStatus } from "@renderer/types/domain";
|
||||
} from "@shared/types/ipc";
|
||||
import type { Domain, DomainWithStatus } from "@shared/types/domain";
|
||||
import type {
|
||||
KintoneSpace,
|
||||
KintoneApp,
|
||||
AppDetail,
|
||||
FileContent,
|
||||
} from "@renderer/types/kintone";
|
||||
import type { Version } from "@renderer/types/version";
|
||||
} from "@shared/types/kintone";
|
||||
import type { Version } from "@shared/types/version";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
||||
@@ -29,7 +29,7 @@ import { FileUploader } from "../FileUploader";
|
||||
import { useDeployStore } from "@renderer/stores";
|
||||
import { useDomainStore } from "@renderer/stores";
|
||||
import { useAppStore } from "@renderer/stores";
|
||||
import type { DeployFile } from "@renderer/types/ipc";
|
||||
import type { DeployFile } from "@shared/types/ipc";
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ import React from "react";
|
||||
import { Modal, Form, Input, Select, Button, Space, message } from "antd";
|
||||
import { createStyles } from "antd-style";
|
||||
import { useDomainStore } from "@renderer/stores";
|
||||
import type { Domain } from "@renderer/types/domain";
|
||||
import type {
|
||||
CreateDomainParams,
|
||||
UpdateDomainParams,
|
||||
} from "@renderer/types/ipc";
|
||||
} from "@shared/types/ipc";
|
||||
|
||||
const useStyles = createStyles(({ token, css }) => ({
|
||||
form: css`
|
||||
@@ -184,6 +183,8 @@ const DomainForm: React.FC<DomainFormProps> = ({ open, onClose, domainId }) => {
|
||||
>
|
||||
<Form.Item name="name" label="名称" style={{ marginTop: 8 }}>
|
||||
<Input placeholder="可选,留空则使用域名" />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item
|
||||
name="domain"
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import { createStyles } from "antd-style";
|
||||
import { useDomainStore } from "@renderer/stores";
|
||||
import type { Domain } from "@renderer/types/domain";
|
||||
import type { Domain } from "@shared/types/domain";
|
||||
|
||||
const useStyles = createStyles(({ token, css }) => ({
|
||||
item: css`
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import { createStyles } from "antd-style";
|
||||
import type { UploadFile, UploadProps } from "antd";
|
||||
import type { DeployFile } from "@renderer/types/ipc";
|
||||
import type { DeployFile } from "@shared/types/ipc";
|
||||
|
||||
const { Dragger } = Upload;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import { createStyles } from "antd-style";
|
||||
import type { TreeDataNode, TreeProps } from "antd";
|
||||
import { useAppStore } from "@renderer/stores";
|
||||
import { useDomainStore } from "@renderer/stores";
|
||||
import type { KintoneSpace, KintoneApp } from "@renderer/types/kintone";
|
||||
import type { KintoneSpace, KintoneApp } from "@shared/types/kintone";
|
||||
|
||||
const useStyles = createStyles(({ token, css }) => ({
|
||||
container: css`
|
||||
|
||||
@@ -29,7 +29,7 @@ import { createStyles } from "antd-style";
|
||||
import { useVersionStore } from "@renderer/stores";
|
||||
import { useDomainStore } from "@renderer/stores";
|
||||
import { useAppStore } from "@renderer/stores";
|
||||
import type { Version } from "@renderer/types/version";
|
||||
import type { Version } from "@shared/types/version";
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
KintoneSpace,
|
||||
KintoneApp,
|
||||
AppDetail,
|
||||
} from "@renderer/types/kintone";
|
||||
} from "@shared/types/kintone";
|
||||
|
||||
interface AppState {
|
||||
// State
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { create } from "zustand";
|
||||
import type { DeployFile, DeployResult } from "@renderer/types/ipc";
|
||||
import type { DeployFile, DeployResult } from "@shared/types/ipc";
|
||||
|
||||
export type DeployStep =
|
||||
| "select"
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import type { Domain, DomainWithStatus } from "@renderer/types/domain";
|
||||
import type { ConnectionStatus } from "@renderer/types/domain";
|
||||
import type { Domain, DomainWithStatus } from "@shared/types/domain";
|
||||
import type { ConnectionStatus } from "@shared/types/domain";
|
||||
import type {
|
||||
CreateDomainParams,
|
||||
UpdateDomainParams,
|
||||
} from "@renderer/types/ipc";
|
||||
} from "@shared/types/ipc";
|
||||
|
||||
interface DomainState {
|
||||
// State
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { create } from "zustand";
|
||||
import type { Version } from "@renderer/types/version";
|
||||
import type { Version } from "@shared/types/version";
|
||||
|
||||
interface VersionState {
|
||||
// State
|
||||
|
||||
Reference in New Issue
Block a user