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

Method GetApi

src/quickAddApi.ts:146–910  ·  view source on GitHub ↗
(
		app: App,
		plugin: QuickAdd,
		choiceExecutor: IChoiceExecutor,
	)

Source from the content-addressed store, hash-verified

144
145export class QuickAddApi {
146 public static GetApi(
147 app: App,
148 plugin: QuickAdd,
149 choiceExecutor: IChoiceExecutor,
150 ) {
151 return {
152 /**
153 * Open a single one-page modal to collect multiple inputs at once from a script.
154 * Any values already present in variables will be used as defaults and not re-asked.
155 *
156 * Example spec items:
157 * { id: "project", label: "Project", type: "text", defaultValue: "Inbox" }
158 * { id: "tags", label: "Tags", type: "suggester", options: ["#work", "#personal"], suggesterConfig: { multiSelect: true } }
159 */
160 requestInputs: async (
161 inputs: Array<{
162 id: string;
163 label?: string;
164 type:
165 | "text"
166 | "number"
167 | "textarea"
168 | "dropdown"
169 | "date"
170 | "field-suggest"
171 | "suggester"
172 | "slider";
173 placeholder?: string;
174 defaultValue?: string;
175 numericConfig?: NumericInputConfig;
176 sliderConfig?: RequestSliderConfig;
177 options?: string[];
178 dateFormat?: string;
179 description?: string;
180 optional?: boolean;
181 suggesterConfig?: {
182 allowCustomInput?: boolean;
183 caseSensitive?: boolean;
184 multiSelect?: boolean;
185 };
186 }>,
187 ): Promise<Record<string, string>> => {
188 // If all inputs already have values, return them immediately
189 const existing: Record<string, string> = {};
190 const missing: FieldRequirement[] = [];
191 for (const spec of inputs) {
192 const val = choiceExecutor.variables.get(spec.id) as
193 | string
194 | undefined;
195 // Empty string is considered intentional and should not be re-asked
196 if (val !== undefined && val !== null) {
197 existing[spec.id] = String(val);
198 continue;
199 }
200 const sliderConfig = sanitizeSliderConfig(spec.sliderConfig);
201 const numericConfig =
202 sliderConfig ?? sanitizeNumericConfig(spec.numericConfig);
203 const type =

Callers 8

getApiFunction · 0.80
getApiFunction · 0.80
apiMethod · 0.80
buildParamsMethod · 0.80

Calls 15

formatISODateFunction · 0.90
reportErrorFunction · 0.90
isMarkdownTemplatePathFunction · 0.90
isTemplateInsertModeFunction · 0.90
applyTemplateToNoteFunction · 0.90
getModelByNameFunction · 0.90
getModelProviderFunction · 0.90
resolveProviderApiKeyFunction · 0.90
PromptFunction · 0.90
ChunkedPromptFunction · 0.90
getModelNamesFunction · 0.90

Tested by 2

getApiFunction · 0.64
getApiFunction · 0.64