MCPcopy Create free account
hub / github.com/codeaashu/claude-code / buildFinalValues

Function buildFinalValues

src/commands/plugin/PluginOptionsDialog.tsx:24–45  ·  view source on GitHub ↗
(fields: string[], collected: Record<string, string>, configSchema: PluginOptionSchema, initialValues: PluginOptionValues | undefined)

Source from the content-addressed store, hash-verified

22 * Exported for unit testing.
23 */
24export function buildFinalValues(fields: string[], collected: Record<string, string>, configSchema: PluginOptionSchema, initialValues: PluginOptionValues | undefined): PluginOptionValues {
25 const finalValues: PluginOptionValues = {};
26 for (const fieldKey of fields) {
27 const schema = configSchema[fieldKey];
28 const value = collected[fieldKey] ?? '';
29 if (schema?.sensitive === true && value === '' && initialValues?.[fieldKey] !== undefined) {
30 continue;
31 }
32 if (schema?.type === 'number') {
33 // Number('') returns 0, not NaN — omit blank number inputs so
34 // validateUserConfig's required check actually catches them.
35 if (value.trim() === '') continue;
36 const num = Number(value);
37 finalValues[fieldKey] = Number.isNaN(num) ? value : num;
38 } else if (schema?.type === 'boolean') {
39 finalValues[fieldKey] = isEnvTruthy(value);
40 } else {
41 finalValues[fieldKey] = value;
42 }
43 }
44 return finalValues;
45}
46type Props = {
47 title: string;
48 subtitle: string;

Callers 1

PluginOptionsDialogFunction · 0.85

Calls 1

isEnvTruthyFunction · 0.85

Tested by

no test coverage detected