fix(n8n): require explicit API URL
- Remove the default Docker service URL from credentials. - Move vault, verbose, and timeout into additional fields. - Keep optional command settings hidden until explicitly added. - Bump the n8n community node package to 0.1.1.
This commit is contained in:
@@ -34,7 +34,7 @@ Resources:
|
|||||||
Credential type: **Obsidian API**
|
Credential type: **Obsidian API**
|
||||||
|
|
||||||
Fields:
|
Fields:
|
||||||
- **Base URL**: e.g. `http://obsidian-api:8080`
|
- **Base URL**: URL of your Obsidian API service, e.g. `http://localhost:8080`
|
||||||
- **API Token**: JWT created with `scripts/create_jwt.py`
|
- **API Token**: JWT created with `scripts/create_jwt.py`
|
||||||
- **Default Vault**: optional, e.g. `work`
|
- **Default Vault**: optional, e.g. `work`
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ export class ObsidianApi implements ICredentialType {
|
|||||||
displayName: 'Base URL',
|
displayName: 'Base URL',
|
||||||
name: 'baseUrl',
|
name: 'baseUrl',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'http://obsidian-api:8080',
|
default: '',
|
||||||
placeholder: 'http://obsidian-api:8080',
|
placeholder: 'http://localhost:8080',
|
||||||
description: 'Base URL of the Obsidian API Docker service',
|
description: 'Base URL of the Obsidian API service',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,14 +29,6 @@ export class ObsidianApi implements INodeType {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
{
|
|
||||||
displayName: 'Vault',
|
|
||||||
name: 'vault',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
placeholder: 'work',
|
|
||||||
description: 'Optional vault name/path. Overrides the credential default vault. Sent as vault=<value>.',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Resource',
|
displayName: 'Resource',
|
||||||
name: 'resource',
|
name: 'resource',
|
||||||
@@ -183,13 +175,6 @@ export class ObsidianApi implements INodeType {
|
|||||||
],
|
],
|
||||||
default: 'vaultInfo',
|
default: 'vaultInfo',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Verbose',
|
|
||||||
name: 'verbose',
|
|
||||||
type: 'boolean',
|
|
||||||
displayOptions: { show: { resource: ['vault'], operation: ['vaults'] } },
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Raw command
|
// Raw command
|
||||||
{
|
{
|
||||||
@@ -202,11 +187,35 @@ export class ObsidianApi implements INodeType {
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Timeout Seconds',
|
displayName: 'Additional Fields',
|
||||||
name: 'timeout',
|
name: 'additionalFields',
|
||||||
type: 'number',
|
type: 'collection',
|
||||||
default: 60,
|
placeholder: 'Add Field',
|
||||||
description: 'Command timeout in seconds',
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Timeout Seconds',
|
||||||
|
name: 'timeout',
|
||||||
|
type: 'number',
|
||||||
|
default: 60,
|
||||||
|
description: 'Command timeout in seconds',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Vault',
|
||||||
|
name: 'vault',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
placeholder: 'work',
|
||||||
|
description: 'Optional vault name/path. Overrides the credential default vault. Sent as vault=<value>.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Verbose',
|
||||||
|
name: 'verbose',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: 'Only used by the List Vaults operation',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -218,8 +227,9 @@ export class ObsidianApi implements INodeType {
|
|||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
const resource = this.getNodeParameter('resource', itemIndex) as string;
|
const resource = this.getNodeParameter('resource', itemIndex) as string;
|
||||||
const operation = this.getNodeParameter('operation', itemIndex) as string;
|
const operation = this.getNodeParameter('operation', itemIndex) as string;
|
||||||
const vault = this.getNodeParameter('vault', itemIndex, '') as string;
|
const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}) as Record<string, unknown>;
|
||||||
const timeout = this.getNodeParameter('timeout', itemIndex, 60) as number;
|
const vault = String(additionalFields.vault || '');
|
||||||
|
const timeout = Number(additionalFields.timeout ?? 60);
|
||||||
|
|
||||||
let args: string[];
|
let args: string[];
|
||||||
|
|
||||||
@@ -237,7 +247,7 @@ export class ObsidianApi implements INodeType {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'vault': {
|
case 'vault': {
|
||||||
args = buildVaultArgs(this, operation, itemIndex);
|
args = buildVaultArgs(this, operation, itemIndex, additionalFields);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'raw': {
|
case 'raw': {
|
||||||
@@ -302,12 +312,14 @@ function buildSearchArgs(context: IExecuteFunctions, operation: string, itemInde
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildVaultArgs(context: IExecuteFunctions, operation: string, itemIndex: number): string[] {
|
function buildVaultArgs(context: IExecuteFunctions, operation: string, itemIndex: number, additionalFields: Record<string, unknown>): string[] {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case 'vaultInfo':
|
case 'vaultInfo':
|
||||||
return ['vault'];
|
return ['vault'];
|
||||||
case 'vaults':
|
case 'vaults': {
|
||||||
return compactArgs(['vaults', kv('verbose', context.getNodeParameter('verbose', itemIndex) as boolean)]);
|
const verbose = additionalFields.verbose === undefined ? true : Boolean(additionalFields.verbose);
|
||||||
|
return compactArgs(['vaults', kv('verbose', verbose)]);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new NodeOperationError(context.getNode(), `Unsupported vault operation: ${operation}`, { itemIndex });
|
throw new NodeOperationError(context.getNode(), `Unsupported vault operation: ${operation}`, { itemIndex });
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "n8n-nodes-obsidian-cli-api",
|
"name": "n8n-nodes-obsidian-cli-api",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "n8n-nodes-obsidian-cli-api",
|
"name": "n8n-nodes-obsidian-cli-api",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.0.0",
|
"@types/node": "^24.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "n8n-nodes-obsidian-cli-api",
|
"name": "n8n-nodes-obsidian-cli-api",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "n8n community nodes for the Obsidian API Docker service backed by the official Obsidian CLI.",
|
"description": "n8n community nodes for the Obsidian API Docker service backed by the official Obsidian CLI.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://git.yiprawr.dev/Docker/obsidian-api",
|
"homepage": "https://git.yiprawr.dev/Docker/obsidian-api",
|
||||||
|
|||||||
Reference in New Issue
Block a user