export const nativeLinkCommands = ["Std_LinkActions", "Std_LinkMake", "Std_LinkMakeGroup", "Std_LinkMakeRelative", "Std_LinkReplace", "Std_LinkUnlink", "Std_LinkImport", "Std_LinkImportAll", "Std_LinkSelectActions", "Std_LinkSelectAllLinks", "Std_LinkSelectLinked", "Std_LinkSelectLinkedFinal"]; export function isNativeLinkCommand(command: string): boolean { return nativeLinkCommands.includes(command); } export function validLinkResult(value: unknown, command: string, documentId: string): boolean { if (!value || typeof value !== "object" || Array.isArray(value)) return false; const result = value as Record; if (["Std_LinkMakeRelative", "Std_LinkReplace", "Std_LinkUnlink"].includes(command) && (!Array.isArray(result.parents) || !["read", "apply"].includes(String(result.action)) || result.parents.some(item => !item || typeof item.documentId !== "string" || typeof item.object !== "string" || typeof item.label !== "string"))) return false; return result.command === command && result.documentId === documentId && typeof result.changed === "boolean" && Array.isArray(result.selection) && result.selection.every(item => item && typeof item.documentId === "string" && typeof item.object === "string" && item.object.length > 0 && (item.subelements === undefined || (Array.isArray(item.subelements) && item.subelements.every((name: unknown) => typeof name === "string")))) && (result.changedDocuments === undefined || (Array.isArray(result.changedDocuments) && result.changedDocuments.every(name => typeof name === "string"))); }