feat: 清理openspec
This commit is contained in:
@@ -15,10 +15,6 @@ export interface ServerCreateFormState {
|
||||
id: string;
|
||||
name: string;
|
||||
pluginId: string;
|
||||
deploymentTargetId: string;
|
||||
runEndpointId: string;
|
||||
profileKey: string;
|
||||
bindings: Record<string, string>;
|
||||
createInputs: Record<string, string>;
|
||||
deploymentMode: ServerDeploymentMode;
|
||||
serverRoot: string;
|
||||
@@ -30,12 +26,6 @@ export interface ServerCreateFormState {
|
||||
shell: "" | "posix-sh" | "powershell" | "cmd";
|
||||
}
|
||||
|
||||
export interface RuntimeBindingField {
|
||||
key: string;
|
||||
required: boolean;
|
||||
sensitive: boolean;
|
||||
}
|
||||
|
||||
export interface ServerWorkflowActionState {
|
||||
label: ServerLifecycleActionLabel;
|
||||
serverInstanceId?: string;
|
||||
@@ -73,10 +63,6 @@ export const emptyServerCreateForm: ServerCreateFormState = {
|
||||
id: "",
|
||||
name: "",
|
||||
pluginId: "",
|
||||
deploymentTargetId: "",
|
||||
runEndpointId: "",
|
||||
profileKey: "",
|
||||
bindings: {},
|
||||
createInputs: {},
|
||||
deploymentMode: "guided-install",
|
||||
serverRoot: "",
|
||||
@@ -108,13 +94,6 @@ export function pluginLabel(plugin: GamePluginResponse | undefined, pluginId: st
|
||||
return plugin.serverDisplayName || plugin.name || plugin.id;
|
||||
}
|
||||
|
||||
export function endpointLabel(endpoint: RunEndpointResponse | undefined, runEndpointId: string): string {
|
||||
if (!endpoint) {
|
||||
return runEndpointId;
|
||||
}
|
||||
return endpoint.displayName || endpoint.id;
|
||||
}
|
||||
|
||||
export function canStartServer(state: ServerInstanceState): boolean {
|
||||
return state === "ready" || state === "stopped" || state === "failed";
|
||||
}
|
||||
@@ -127,13 +106,11 @@ export function isPendingJobState(state: JobResponse["state"]): boolean {
|
||||
return state === "queued" || state === "accepted" || state === "running" || state === "retrying";
|
||||
}
|
||||
|
||||
export function defaultServerCreateForm(plugins: GamePluginResponse[], endpoints: RunEndpointResponse[]): ServerCreateFormState {
|
||||
export function defaultServerCreateForm(plugins: GamePluginResponse[]): ServerCreateFormState {
|
||||
const plugin = plugins[0];
|
||||
return {
|
||||
...emptyServerCreateForm,
|
||||
pluginId: plugin?.id ?? "",
|
||||
profileKey: plugin?.runtimeProfiles?.lifecycleProfiles?.[0]?.key ?? "",
|
||||
runEndpointId: "",
|
||||
createInputs: pluginCreateInputDefaults(plugin)
|
||||
};
|
||||
}
|
||||
@@ -142,30 +119,6 @@ export function pluginCreateInputDefaults(plugin: GamePluginResponse | undefined
|
||||
return Object.fromEntries((plugin?.createFields ?? []).map((field) => [field.key, field.defaultValue ?? ""]));
|
||||
}
|
||||
|
||||
export function runtimeBindingFields(plugin: GamePluginResponse | undefined, profileKey: string): RuntimeBindingField[] {
|
||||
const profiles = plugin?.runtimeProfiles;
|
||||
const lifecycle = profiles?.lifecycleProfiles?.find((profile) => profile.key === profileKey);
|
||||
if (!profiles || !lifecycle) return [];
|
||||
const fields = new Map<string, RuntimeBindingField>();
|
||||
const add = (key: string | undefined, required: boolean) => {
|
||||
if (!key) return;
|
||||
const current = fields.get(key);
|
||||
fields.set(key, { key, required: required || current?.required === true, sensitive: runtimeBindingKeyIsSensitive(key) });
|
||||
};
|
||||
profiles.discovery?.forEach((probe) => add(probe.targetKey, probe.required === true));
|
||||
profiles.dependencyProbes?.forEach((probe) => add(probe.targetKey, probe.required === true));
|
||||
profiles.logSources?.forEach((source) => add(source.targetKey, Boolean(source.targetKey)));
|
||||
profiles.installPlans?.forEach((plan) => plan.steps.forEach((step) => add(step.targetKey, false)));
|
||||
profiles.transportProfiles?.filter((transport) => lifecycle.transportKeys?.includes(transport.key)).forEach((transport) => add(transport.targetKey || transport.key, true));
|
||||
add(lifecycle.clientManagerRef, Boolean(lifecycle.clientManagerRef));
|
||||
return [...fields.values()].sort((left, right) => left.key.localeCompare(right.key));
|
||||
}
|
||||
|
||||
export function runtimeBindingKeyIsSensitive(key: string): boolean {
|
||||
const normalized = key.toLowerCase();
|
||||
return ["password", "credential", "secret", "token", "dsn"].some((part) => normalized.includes(part));
|
||||
}
|
||||
|
||||
export function serverMetadataFormFromInstance(instance: ServerInstanceResponse): ServerMetadataFormState {
|
||||
return { name: instance.name };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user