@solinker/nodes-laomashitu
Version:
可通过API完成内容替换及批量图片生成。 • 不会代码 ? 不是问题 ! 以表格、无代码方式配置数据来源及图片处理步骤,完成琐碎重复任务。
101 lines • 3.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LaomashituV1 = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const renderPic_1 = __importDefault(require("./renderPic"));
const getTemplateList_1 = __importDefault(require("./getTemplateList"));
const getDynamicsParams_1 = __importDefault(require("./getDynamicsParams"));
const descriptionV1 = {
defaults: {
name: '老码十途',
},
displayName: '老码十途',
description: '可通过API完成内容替换及批量图片生成。 • 不会代码 ? 不是问题 ! 以表格、无代码方式配置数据来源及图片处理步骤,完成琐碎重复任务。',
name: 'laomashitu',
inputs: ["main"],
outputs: ['main'],
group: ['group'],
version: 1,
credentials: [{ name: 'laomashituApi', required: true }],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
options: [
{
displayName: '发送渲染指令',
name: '发送渲染指令',
value: 'renderPic',
action: '发送渲染指令',
},
{
displayName: '获取图片模板列表',
name: '获取图片模板列表',
value: 'getTemplateList',
action: '获取图片模板列表',
},
{
displayName: '获取模板内动态参数',
name: '获取模板内动态参数',
value: 'getDynamicsParams',
action: '获取模板内动态参数',
},
],
default: 'renderPic',
noDataExpression: true,
},
...renderPic_1.default,
...getTemplateList_1.default,
...getDynamicsParams_1.default,
],
};
class LaomashituV1 {
constructor(baseDescription) {
this.description = {
...baseDescription,
...descriptionV1,
};
}
async execute() {
var _a;
const returnData = [];
const credentials = await this.getCredentials('laomashituApi');
const items = this.getInputData();
for (let index = 0; index < items.length; index++) {
try {
const parameters = {};
Object.keys(this.getNode().parameters).forEach((key) => {
parameters[key] = this.getNodeParameter(key, index);
});
returnData.push({
json: await this.helpers.httpRequest({
baseURL: `${(_a = process.env.N8N_STORE_API_URL) !== null && _a !== void 0 ? _a : 'https://api.n8n.store'}/api/laomashitu`,
url: '/operation',
method: 'POST',
body: {
...parameters,
credentials,
},
headers: {
'X-Instance-Id': this.getInstanceId(),
},
}),
});
}
catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
continue;
}
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex: index });
}
}
return this.prepareOutputData(returnData);
}
}
exports.LaomashituV1 = LaomashituV1;
//# sourceMappingURL=LaomashituV1.js.map