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

Method parse

src/utils/FieldSuggestionParser.ts:45–175  ·  view source on GitHub ↗

* Parses the field suggestion syntax to extract field name and filters * Examples: * - "fieldname" -> { fieldName: "fieldname", filters: {} } * - "fieldname|folder:daily" -> { fieldName: "fieldname", filters: { folder: "daily" } } * - "fieldname|folder:daily|tag:work|tag:project" -> { fieldN

(
		input: string,
		options?: { warnUnknown?: boolean },
	)

Source from the content-addressed store, hash-verified

43 * - "fieldname|folder:daily|tag:work|tag:project" -> { fieldName: "fieldname", filters: { folder: "daily", tags: ["work", "project"] } }
44 */
45 static parse(
46 input: string,
47 options?: { warnUnknown?: boolean },
48 ): {
49 fieldName: string;
50 filters: FieldFilter;
51 multiSelect?: boolean;
52 } {
53 const parts = splitPipeParts(input).map((p) => p.trim());
54 const fieldName = parts[0];
55 const filters: FieldFilter = {};
56 let multiSelect = false;
57
58 for (let i = 1; i < parts.length; i++) {
59 const filterPart = parts[i];
60 if (filterPart.toLowerCase() === "multi") {
61 multiSelect = true;
62 continue;
63 }
64
65 const parsed = parsePipeKeyValue(filterPart);
66 if (!parsed) continue; // Skip invalid filter format
67
68 const filterType = parsed.key;
69 const filterValue = parsed.value;
70
71 switch (filterType) {
72 case "multi":
73 multiSelect = parseBooleanFlag(filterValue);
74 break;
75 case "folder":
76 if (!filters.folders) {
77 filters.folders = [];
78 }
79 filters.folders.push(filterValue);
80 if (!filters.folder) {
81 filters.folder = filterValue;
82 }
83 break;
84 case "tag": {
85 if (!filters.tags) {
86 filters.tags = [];
87 }
88 // Remove # prefix if present
89 const tagName = filterValue.startsWith("#")
90 ? filterValue.substring(1)
91 : filterValue;
92 filters.tags.push(tagName);
93 break;
94 }
95 case "inline":
96 filters.inline = filterValue.toLowerCase() === "true";
97 break;
98 case "inline-code-blocks":
99 if (!filters.inlineCodeBlocks) {
100 filters.inlineCodeBlocks = [];
101 }
102 filters.inlineCodeBlocks.push(

Callers 15

version-bump.mjsFile · 0.80
parsePipeFiltersFunction · 0.80
keyFieldNameMethod · 0.80
parsePropertyTargetFunction · 0.80
parseFileTokenFunction · 0.80
replaceFieldVarInStringFunction · 0.80
suggestForFieldMethod · 0.80
parseStoredCanvasDataFunction · 0.80

Calls 5

splitPipePartsFunction · 0.90
parsePipeKeyValueFunction · 0.90
parseBooleanFlagFunction · 0.90
pushMethod · 0.80
logWarningMethod · 0.65

Tested by 2

endFunction · 0.64
asSavedProxyFunction · 0.64