Files
obsidian-api/packages/n8n-nodes-obsidian-api/nodes/ObsidianApi/output.ts
T
daniel156161 e115698e92
Build and Push Docker Container / build-and-push (push) Successful in 3m31s
fix: serialize property writes and expose n8n results
- Serialize property set and remove commands per vault note to avoid lost frontmatter writes.
- Wait briefly for successful property writes to hit disk before releasing the note lock.
- Return property path, name, value, type, operation, and ok status in n8n outputs.
- Include property details on continue-on-fail errors so failed items are visible in n8n.
- Bump obsidian-api to 1.0.7 and n8n-nodes-obsidian-cli-api to 0.2.8.
- Add regression coverage for concurrent property writes to the same note.
2026-09-15 09:43:24 +02:00

37 lines
1.5 KiB
TypeScript

import type { IDataObject, INodeExecutionData } from 'n8n-workflow';
import type { ObsidianCommandResult } from '../../shared/ObsidianApiClient';
import { propertyDetailsFromArgs } from './propertyOutput';
export function outputForResult(result: ObsidianCommandResult, resource: string, operation: string, itemIndex: number): INodeExecutionData {
const stdout = result.stdout ?? '';
if (resource === 'daily' && operation === 'dailyPath') {
return paired({ path: stdout }, result, itemIndex);
}
if (resource === 'daily' && operation === 'dailyRead') {
return paired({ content: stdout }, result, itemIndex);
}
if (resource === 'note' && operation === 'read') {
return paired({ content: stdout }, result, itemIndex);
}
if (resource === 'property' && (operation === 'propertyRead' || operation === 'properties')) {
return paired({ content: stdout }, result, itemIndex);
}
if (resource === 'property' && (operation === 'propertySet' || operation === 'propertyRemove')) {
return paired({ ok: true, operation, ...propertyDetailsFromArgs(result.command) }, result, itemIndex);
}
const parsed = result.parsed_stdout;
if (parsed) return paired(parsed, result, itemIndex);
return paired({ ok: true }, result, itemIndex);
}
function paired(json: IDataObject, result: ObsidianCommandResult, itemIndex: number): INodeExecutionData {
const out: IDataObject = { ...json };
if (result.stderr) out.stderr = result.stderr;
if (result.timed_out) out.timed_out = result.timed_out;
return { json: out, pairedItem: { item: itemIndex } };
}