c34dab2cca
Build and Push Docker Container / build-and-push (push) Successful in 4m28s
- Create missing note files before running property:set. - Default date-only datetime values to midnight. - Keep property names out of path authorization checks. - Split policy, vault, daily note, and command target helpers. - Split n8n node args, description, output, and API response helpers. - Split API tests by auth, command, daily note, and property behavior. - Bump API and n8n node versions.
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { IDataObject, INodeExecutionData } from 'n8n-workflow';
|
|
|
|
import type { ObsidianCommandResult } from '../../shared/ObsidianApiClient';
|
|
|
|
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);
|
|
}
|
|
|
|
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 } };
|
|
}
|