MCPcopy Create free account
hub / github.com/chhoumann/quickadd / remapChoiceTree

Function remapChoiceTree

src/services/packageImportService.ts:869–911  ·  view source on GitHub ↗
(
	choice: IChoice,
	idMap: Map<string, string>,
	importableChoiceIds: Set<string>,
	secretSanitizerOptions: UserScriptSecretSanitizerOptions,
)

Source from the content-addressed store, hash-verified

867}
868
869function remapChoiceTree(
870 choice: IChoice,
871 idMap: Map<string, string>,
872 importableChoiceIds: Set<string>,
873 secretSanitizerOptions: UserScriptSecretSanitizerOptions,
874): IChoice {
875 const originalId = choice.id;
876 const finalId = idMap.get(originalId) ?? originalId;
877 choice.id = finalId;
878 const isDuplicated = finalId !== originalId;
879
880 if (choice.type === "Macro") {
881 const macroChoice = choice as IMacroChoice;
882 if (isDuplicated) {
883 macroChoice.macro.id = uuidv4();
884 }
885 remapCommands(
886 macroChoice.macro.commands,
887 idMap,
888 importableChoiceIds,
889 isDuplicated,
890 secretSanitizerOptions,
891 );
892 }
893
894 if (choice.type === "Multi") {
895 const multi = choice as IMultiChoice;
896 if (Array.isArray(multi.choices)) {
897 multi.choices = multi.choices
898 .filter((child) => importableChoiceIds.has(child.id))
899 .map((child) =>
900 remapChoiceTree(
901 child,
902 idMap,
903 importableChoiceIds,
904 secretSanitizerOptions,
905 ),
906 );
907 }
908 }
909
910 return choice;
911}
912
913function remapCommands(
914 commands: ICommand[],

Callers 2

applyPackageImportFunction · 0.85
remapCommandsFunction · 0.85

Calls 2

remapCommandsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected