feat(properties): prepare property commands before execution
Build and Push Docker Container / build-and-push (push) Successful in 4m28s
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.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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 } };
|
||||
}
|
||||
Reference in New Issue
Block a user