n8n-nodes-apexapi 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@ class ApexApi {
12
12
  this.description = {
13
13
  displayName: 'ApexApi',
14
14
  name: 'apexApi',
15
- icon: 'file:apexapi.svg',
15
+ icon: 'file:apexapi.png',
16
16
  group: ['transform'],
17
17
  version: 1,
18
18
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@@ -111,6 +111,19 @@ class ApexApi {
111
111
  default: '',
112
112
  required: true,
113
113
  },
114
+ {
115
+ displayName: 'Size',
116
+ name: 'imageSize',
117
+ type: 'options',
118
+ displayOptions: { show: { resource: ['image'] } },
119
+ options: [
120
+ { name: 'Square — 1:1 (1024×1024)', value: '1024x1024' },
121
+ { name: 'Landscape — 16:9 (1344×768)', value: '1344x768' },
122
+ { name: 'Portrait — 9:16 (768×1344)', value: '768x1344' },
123
+ ],
124
+ default: '1024x1024',
125
+ description: 'Output resolution / aspect ratio. Note: some models only support specific sizes.',
126
+ },
114
127
  {
115
128
  displayName: 'Options',
116
129
  name: 'options',
@@ -118,10 +131,7 @@ class ApexApi {
118
131
  placeholder: 'Add Option',
119
132
  displayOptions: { show: { resource: ['image'] } },
120
133
  default: {},
121
- options: [
122
- { displayName: 'Size', name: 'size', type: 'string', default: '1024x1024' },
123
- { displayName: 'Number of Images', name: 'n', type: 'number', default: 1 },
124
- ],
134
+ options: [{ displayName: 'Number of Images', name: 'n', type: 'number', default: 1 }],
125
135
  },
126
136
  // ---- Video ----
127
137
  {
@@ -182,7 +192,7 @@ class ApexApi {
182
192
  this.methods = {
183
193
  loadOptions: {
184
194
  async getChatModels() {
185
- return (0, loadOptions_1.loadModels)(this, 'text');
195
+ return (0, loadOptions_1.loadModels)(this, 'chat');
186
196
  },
187
197
  async getImageModels() {
188
198
  return (0, loadOptions_1.loadModels)(this, 'image');
@@ -220,7 +230,7 @@ class ApexApi {
220
230
  const body = (0, image_1.buildImageBody)({
221
231
  model: this.getNodeParameter('model', i),
222
232
  prompt: this.getNodeParameter('prompt', i),
223
- size: options.size,
233
+ size: this.getNodeParameter('imageSize', i, '1024x1024'),
224
234
  n: options.n,
225
235
  });
226
236
  const resp = await (0, transport_1.apexApiRequest)(ctx, 'POST', '/images/generations', body);
Binary file
@@ -1,10 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadModels = loadModels;
4
- const transport_1 = require("./transport");
4
+ const constants_1 = require("./constants");
5
5
  const models_1 = require("./models");
6
+ /**
7
+ * Load the model dropdown options for a resource. The `/v1/models` endpoint is
8
+ * PUBLIC, so this uses the unauthenticated request helper and works even before
9
+ * a credential is attached — that avoids n8n's "error fetching options" when the
10
+ * key hasn't been entered yet. The base URL comes from the credential when
11
+ * present, otherwise the default.
12
+ */
6
13
  async function loadModels(ctx, modelType) {
7
- const resp = await (0, transport_1.apexApiRequest)(ctx, 'GET', '/models');
14
+ let baseUrl = constants_1.DEFAULT_BASE_URL;
15
+ try {
16
+ const creds = await ctx.getCredentials(constants_1.CREDENTIAL_NAME);
17
+ if (creds && creds.baseUrl)
18
+ baseUrl = String(creds.baseUrl);
19
+ }
20
+ catch {
21
+ // No credential attached yet — /models is public, so fall back to the
22
+ // default base URL and load the list anyway.
23
+ }
24
+ baseUrl = baseUrl.replace(/\/+$/, '');
25
+ const http = ctx.helpers.httpRequest;
26
+ if (!http)
27
+ return [];
28
+ const resp = (await http({ method: 'GET', url: `${baseUrl}/models`, json: true }));
8
29
  const data = Array.isArray(resp?.data) ? resp.data : [];
9
30
  return (0, models_1.mapModelsToOptions)(data, modelType);
10
31
  }
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapModelsToOptions = mapModelsToOptions;
4
4
  /**
5
5
  * Map the `/v1/models` `data` array to n8n dropdown options. When `modelType`
6
- * is given, keep only models of that type (text/image/video); if that leaves
7
- * nothing, fall back to all models rather than showing an empty dropdown.
6
+ * is given, keep only models of that type (chat/image/video matching the live
7
+ * /v1/models `type` field); if that leaves nothing, fall back to all models
8
+ * rather than showing an empty dropdown.
8
9
  */
9
10
  function mapModelsToOptions(models, modelType) {
10
11
  const filtered = modelType ? models.filter((m) => m.type === modelType) : models;
package/package.json CHANGED
@@ -1,12 +1,26 @@
1
1
  {
2
2
  "name": "n8n-nodes-apexapi",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "n8n community node for ApexApi — call 14 AI providers (OpenAI, Anthropic, Google, Mistral, and more) through one OpenAI-compatible API.",
5
- "keywords": ["n8n-community-node-package", "apexapi", "ai", "llm", "openai", "anthropic", "gemini"],
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "apexapi",
8
+ "ai",
9
+ "llm",
10
+ "openai",
11
+ "anthropic",
12
+ "gemini"
13
+ ],
6
14
  "license": "MIT",
7
15
  "homepage": "https://apexapi.dev",
8
- "author": { "name": "ApexApi", "email": "support@apexapi.dev" },
9
- "repository": { "type": "git", "url": "git+https://github.com/apexapi/apexapi.git" },
16
+ "author": {
17
+ "name": "ApexApi",
18
+ "email": "support@apexapi.dev"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/apexapi/apexapi.git"
23
+ },
10
24
  "main": "dist/index.js",
11
25
  "scripts": {
12
26
  "build": "tsc && node scripts/build-icons.mjs",
@@ -14,13 +28,21 @@
14
28
  "test": "vitest run",
15
29
  "prepublishOnly": "pnpm build"
16
30
  },
17
- "files": ["dist"],
31
+ "files": [
32
+ "dist"
33
+ ],
18
34
  "n8n": {
19
35
  "n8nNodesApiVersion": 1,
20
- "credentials": ["dist/credentials/ApexApiApi.credentials.js"],
21
- "nodes": ["dist/nodes/ApexApi/ApexApi.node.js"]
36
+ "credentials": [
37
+ "dist/credentials/ApexApiApi.credentials.js"
38
+ ],
39
+ "nodes": [
40
+ "dist/nodes/ApexApi/ApexApi.node.js"
41
+ ]
42
+ },
43
+ "peerDependencies": {
44
+ "n8n-workflow": "*"
22
45
  },
23
- "peerDependencies": { "n8n-workflow": "*" },
24
46
  "devDependencies": {
25
47
  "n8n-workflow": "^1.82.0",
26
48
  "typescript": "^5.9.3",
@@ -1,5 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
- <rect width="64" height="64" rx="12" fill="#0B0B0F"/>
3
- <path d="M20 44 32 20 44 44" fill="none" stroke="#5B8CFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
4
- <line x1="25" y1="36" x2="39" y2="36" stroke="#5B8CFF" stroke-width="4" stroke-linecap="round"/>
5
- </svg>