n8n-nodes-apexapi 0.1.1 → 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.
|
@@ -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, '
|
|
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:
|
|
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);
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadModels = loadModels;
|
|
4
|
-
const
|
|
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
|
-
|
|
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
|
}
|
package/dist/shared/models.js
CHANGED
|
@@ -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 (
|
|
7
|
-
* nothing, fall back to all models
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-apexapi",
|
|
3
|
-
"version": "0.1.
|
|
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
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|