feat : update
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
parseTeamTransfer,
|
||||
parseTeamPresets,
|
||||
serializeTeamTransfer,
|
||||
teamTransferFileName,
|
||||
type TeamToolValue,
|
||||
} from "./team-tools";
|
||||
|
||||
@@ -152,6 +153,12 @@ describe("team bulk tools", () => {
|
||||
}))).toThrow();
|
||||
});
|
||||
|
||||
it("uses the team name as a safe JSON download filename", () => {
|
||||
expect(teamTransferFileName("Ineffa Exai")).toBe("Ineffa Exai.json");
|
||||
expect(teamTransferFileName('A/B: Team?')).toBe("A-B- Team-.json");
|
||||
expect(teamTransferFileName("... ")).toBe("team.json");
|
||||
});
|
||||
|
||||
it("reports missing and incompatible imported catalog references", () => {
|
||||
const source = team("source");
|
||||
source.members[0] = {
|
||||
|
||||
@@ -90,6 +90,14 @@ export function serializeTeamTransfer(team: TeamToolValue): string {
|
||||
return JSON.stringify(payload, null, 2);
|
||||
}
|
||||
|
||||
export function teamTransferFileName(teamName: string): string {
|
||||
const safeName = teamName
|
||||
.replace(/[<>:"/\\|?*\u0000-\u001f]/gu, "-")
|
||||
.replace(/[. ]+$/gu, "")
|
||||
.trim();
|
||||
return `${safeName || "team"}.json`;
|
||||
}
|
||||
|
||||
export function parseTeamTransfer(serialized: string): Omit<TeamToolValue, "clientId"> {
|
||||
const payload = teamTransferSchema.parse(JSON.parse(serialized) as unknown);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user