@bonsae/nrg 0.10.1 → 0.11.0

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.
package/types/server.d.ts CHANGED
@@ -2146,12 +2146,8 @@ export type ConfigNodeContext = {
2146
2146
  export declare abstract class IONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> {
2147
2147
  static readonly align?: "left" | "right";
2148
2148
  static readonly color: HexColor;
2149
- static readonly labelStyle?: "node_label" | "node_label_italic" | string;
2150
- static readonly paletteLabel?: string;
2151
2149
  static readonly inputs?: number;
2152
2150
  static readonly outputs?: number;
2153
- static readonly inputLabels?: string | string[];
2154
- static readonly outputLabels?: string | string[];
2155
2151
  static readonly inputSchema?: Schema;
2156
2152
  static readonly outputsSchema?: Schema | Schema[];
2157
2153
  static readonly validateInput: boolean;
@@ -2207,11 +2203,7 @@ export interface IONodeDefinition<TConfigSchema extends TSchema | undefined = un
2207
2203
  color?: HexColor;
2208
2204
  inputs?: 0 | 1;
2209
2205
  outputs?: number;
2210
- paletteLabel?: string;
2211
- inputLabels?: string | string[];
2212
- outputLabels?: string | string[];
2213
2206
  align?: "left" | "right";
2214
- labelStyle?: string;
2215
2207
  configSchema?: TConfigSchema;
2216
2208
  credentialsSchema?: TCredsSchema;
2217
2209
  settingsSchema?: TSettingsSchema;
package/vite/index.js CHANGED
@@ -1118,6 +1118,235 @@ import fs6 from "fs";
1118
1118
  import path6 from "path";
1119
1119
  import { pathToFileURL } from "url";
1120
1120
  import { createRequire } from "module";
1121
+
1122
+ // src/vite/client/plugins/help-i18n.ts
1123
+ var translations = {
1124
+ "en-US": {
1125
+ sections: {
1126
+ properties: "Properties",
1127
+ credentials: "Credentials",
1128
+ input: "Input",
1129
+ output: "Output",
1130
+ outputs: "Outputs",
1131
+ port: "Port"
1132
+ },
1133
+ columns: {
1134
+ property: "Property",
1135
+ label: "Label",
1136
+ type: "Type",
1137
+ required: "Required",
1138
+ default: "Default",
1139
+ description: "Description"
1140
+ },
1141
+ values: {
1142
+ yes: "Yes",
1143
+ no: "No"
1144
+ }
1145
+ },
1146
+ de: {
1147
+ sections: {
1148
+ properties: "Eigenschaften",
1149
+ credentials: "Zugangsdaten",
1150
+ input: "Eingang",
1151
+ output: "Ausgang",
1152
+ outputs: "Ausg\xE4nge",
1153
+ port: "Port"
1154
+ },
1155
+ columns: {
1156
+ property: "Eigenschaft",
1157
+ label: "Bezeichnung",
1158
+ type: "Typ",
1159
+ required: "Erforderlich",
1160
+ default: "Standard",
1161
+ description: "Beschreibung"
1162
+ },
1163
+ values: {
1164
+ yes: "Ja",
1165
+ no: "Nein"
1166
+ }
1167
+ },
1168
+ "es-ES": {
1169
+ sections: {
1170
+ properties: "Propiedades",
1171
+ credentials: "Credenciales",
1172
+ input: "Entrada",
1173
+ output: "Salida",
1174
+ outputs: "Salidas",
1175
+ port: "Puerto"
1176
+ },
1177
+ columns: {
1178
+ property: "Propiedad",
1179
+ label: "Etiqueta",
1180
+ type: "Tipo",
1181
+ required: "Requerido",
1182
+ default: "Predeterminado",
1183
+ description: "Descripci\xF3n"
1184
+ },
1185
+ values: {
1186
+ yes: "S\xED",
1187
+ no: "No"
1188
+ }
1189
+ },
1190
+ fr: {
1191
+ sections: {
1192
+ properties: "Propri\xE9t\xE9s",
1193
+ credentials: "Identifiants",
1194
+ input: "Entr\xE9e",
1195
+ output: "Sortie",
1196
+ outputs: "Sorties",
1197
+ port: "Port"
1198
+ },
1199
+ columns: {
1200
+ property: "Propri\xE9t\xE9",
1201
+ label: "Libell\xE9",
1202
+ type: "Type",
1203
+ required: "Requis",
1204
+ default: "Par d\xE9faut",
1205
+ description: "Description"
1206
+ },
1207
+ values: {
1208
+ yes: "Oui",
1209
+ no: "Non"
1210
+ }
1211
+ },
1212
+ ko: {
1213
+ sections: {
1214
+ properties: "\uC18D\uC131",
1215
+ credentials: "\uC790\uACA9 \uC99D\uBA85",
1216
+ input: "\uC785\uB825",
1217
+ output: "\uCD9C\uB825",
1218
+ outputs: "\uCD9C\uB825",
1219
+ port: "\uD3EC\uD2B8"
1220
+ },
1221
+ columns: {
1222
+ property: "\uC18D\uC131",
1223
+ label: "\uB77C\uBCA8",
1224
+ type: "\uC720\uD615",
1225
+ required: "\uD544\uC218",
1226
+ default: "\uAE30\uBCF8\uAC12",
1227
+ description: "\uC124\uBA85"
1228
+ },
1229
+ values: {
1230
+ yes: "\uC608",
1231
+ no: "\uC544\uB2C8\uC624"
1232
+ }
1233
+ },
1234
+ "pt-BR": {
1235
+ sections: {
1236
+ properties: "Propriedades",
1237
+ credentials: "Credenciais",
1238
+ input: "Entrada",
1239
+ output: "Sa\xEDda",
1240
+ outputs: "Sa\xEDdas",
1241
+ port: "Porta"
1242
+ },
1243
+ columns: {
1244
+ property: "Propriedade",
1245
+ label: "R\xF3tulo",
1246
+ type: "Tipo",
1247
+ required: "Obrigat\xF3rio",
1248
+ default: "Padr\xE3o",
1249
+ description: "Descri\xE7\xE3o"
1250
+ },
1251
+ values: {
1252
+ yes: "Sim",
1253
+ no: "N\xE3o"
1254
+ }
1255
+ },
1256
+ ru: {
1257
+ sections: {
1258
+ properties: "\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430",
1259
+ credentials: "\u0423\u0447\u0451\u0442\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435",
1260
+ input: "\u0412\u0445\u043E\u0434",
1261
+ output: "\u0412\u044B\u0445\u043E\u0434",
1262
+ outputs: "\u0412\u044B\u0445\u043E\u0434\u044B",
1263
+ port: "\u041F\u043E\u0440\u0442"
1264
+ },
1265
+ columns: {
1266
+ property: "\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u043E",
1267
+ label: "\u041C\u0435\u0442\u043A\u0430",
1268
+ type: "\u0422\u0438\u043F",
1269
+ required: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E",
1270
+ default: "\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
1271
+ description: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435"
1272
+ },
1273
+ values: {
1274
+ yes: "\u0414\u0430",
1275
+ no: "\u041D\u0435\u0442"
1276
+ }
1277
+ },
1278
+ ja: {
1279
+ sections: {
1280
+ properties: "\u30D7\u30ED\u30D1\u30C6\u30A3",
1281
+ credentials: "\u8A8D\u8A3C\u60C5\u5831",
1282
+ input: "\u5165\u529B",
1283
+ output: "\u51FA\u529B",
1284
+ outputs: "\u51FA\u529B",
1285
+ port: "\u30DD\u30FC\u30C8"
1286
+ },
1287
+ columns: {
1288
+ property: "\u30D7\u30ED\u30D1\u30C6\u30A3",
1289
+ label: "\u30E9\u30D9\u30EB",
1290
+ type: "\u578B",
1291
+ required: "\u5FC5\u9808",
1292
+ default: "\u30C7\u30D5\u30A9\u30EB\u30C8",
1293
+ description: "\u8AAC\u660E"
1294
+ },
1295
+ values: {
1296
+ yes: "\u306F\u3044",
1297
+ no: "\u3044\u3044\u3048"
1298
+ }
1299
+ },
1300
+ "zh-CN": {
1301
+ sections: {
1302
+ properties: "\u5C5E\u6027",
1303
+ credentials: "\u51ED\u8BC1",
1304
+ input: "\u8F93\u5165",
1305
+ output: "\u8F93\u51FA",
1306
+ outputs: "\u8F93\u51FA",
1307
+ port: "\u7AEF\u53E3"
1308
+ },
1309
+ columns: {
1310
+ property: "\u5C5E\u6027",
1311
+ label: "\u6807\u7B7E",
1312
+ type: "\u7C7B\u578B",
1313
+ required: "\u5FC5\u586B",
1314
+ default: "\u9ED8\u8BA4\u503C",
1315
+ description: "\u63CF\u8FF0"
1316
+ },
1317
+ values: {
1318
+ yes: "\u662F",
1319
+ no: "\u5426"
1320
+ }
1321
+ },
1322
+ "zh-TW": {
1323
+ sections: {
1324
+ properties: "\u5C6C\u6027",
1325
+ credentials: "\u6191\u8B49",
1326
+ input: "\u8F38\u5165",
1327
+ output: "\u8F38\u51FA",
1328
+ outputs: "\u8F38\u51FA",
1329
+ port: "\u57E0"
1330
+ },
1331
+ columns: {
1332
+ property: "\u5C6C\u6027",
1333
+ label: "\u6A19\u7C64",
1334
+ type: "\u985E\u578B",
1335
+ required: "\u5FC5\u586B",
1336
+ default: "\u9810\u8A2D\u503C",
1337
+ description: "\u63CF\u8FF0"
1338
+ },
1339
+ values: {
1340
+ yes: "\u662F",
1341
+ no: "\u5426"
1342
+ }
1343
+ }
1344
+ };
1345
+ function getHelpTranslations(lang) {
1346
+ return translations[lang] ?? translations["en-US"];
1347
+ }
1348
+
1349
+ // src/vite/client/plugins/help-generator.ts
1121
1350
  function buildPropertyRow(name, schema, required, label) {
1122
1351
  let type = "";
1123
1352
  if (schema["x-nrg-node-type"]) {
@@ -1154,7 +1383,15 @@ var SKIP_FIELDS = /* @__PURE__ */ new Set([
1154
1383
  "g",
1155
1384
  "_users"
1156
1385
  ]);
1157
- function generateSchemaSection(title, schema, labels, heading = "###") {
1386
+ function generateSchemaSection(options) {
1387
+ const {
1388
+ title,
1389
+ schema,
1390
+ t,
1391
+ labels,
1392
+ heading = "###",
1393
+ includeDefault = true
1394
+ } = options;
1158
1395
  if (!schema?.properties) return "";
1159
1396
  const required = new Set(schema.required ?? []);
1160
1397
  const rows = Object.entries(schema.properties).filter(([key]) => !SKIP_FIELDS.has(key)).map(
@@ -1167,10 +1404,24 @@ function generateSchemaSection(title, schema, labels, heading = "###") {
1167
1404
  );
1168
1405
  if (rows.length === 0) return "";
1169
1406
  const hasLabels = rows.some((r) => r.label);
1170
- const headerCells = hasLabels ? '<th>Property</th><th>Label</th><th>Type</th><th>Required</th><th>Default</th><th style="width:35%">Description</th>' : '<th>Property</th><th>Type</th><th>Required</th><th>Default</th><th style="width:40%">Description</th>';
1171
- const tableRows = rows.map(
1172
- (r) => hasLabels ? `<tr><td>${r.name}</td><td>${r.label}</td><td>${r.type}</td><td>${r.required ? "Yes" : "No"}</td><td>${r.defaultVal ? `<code>${r.defaultVal}</code>` : ""}</td><td>${r.description}</td></tr>` : `<tr><td>${r.name}</td><td>${r.type}</td><td>${r.required ? "Yes" : "No"}</td><td>${r.defaultVal ? `<code>${r.defaultVal}</code>` : ""}</td><td>${r.description}</td></tr>`
1173
- ).join("\n");
1407
+ const c = t.columns;
1408
+ const v = t.values;
1409
+ let headerCells;
1410
+ let rowFn;
1411
+ if (hasLabels && includeDefault) {
1412
+ headerCells = `<th>${c.label}</th><th>${c.property}</th><th>${c.type}</th><th>${c.required}</th><th>${c.default}</th><th style="width:35%">${c.description}</th>`;
1413
+ rowFn = (r) => `<tr><td>${r.label}</td><td>${r.name}</td><td>${r.type}</td><td>${r.required ? v.yes : v.no}</td><td>${r.defaultVal ? `<code>${r.defaultVal}</code>` : ""}</td><td>${r.description}</td></tr>`;
1414
+ } else if (hasLabels) {
1415
+ headerCells = `<th>${c.label}</th><th>${c.property}</th><th>${c.type}</th><th>${c.required}</th><th style="width:35%">${c.description}</th>`;
1416
+ rowFn = (r) => `<tr><td>${r.label}</td><td>${r.name}</td><td>${r.type}</td><td>${r.required ? v.yes : v.no}</td><td>${r.description}</td></tr>`;
1417
+ } else if (includeDefault) {
1418
+ headerCells = `<th>${c.property}</th><th>${c.type}</th><th>${c.required}</th><th>${c.default}</th><th style="width:40%">${c.description}</th>`;
1419
+ rowFn = (r) => `<tr><td>${r.name}</td><td>${r.type}</td><td>${r.required ? v.yes : v.no}</td><td>${r.defaultVal ? `<code>${r.defaultVal}</code>` : ""}</td><td>${r.description}</td></tr>`;
1420
+ } else {
1421
+ headerCells = `<th>${c.property}</th><th>${c.type}</th><th>${c.required}</th><th style="width:40%">${c.description}</th>`;
1422
+ rowFn = (r) => `<tr><td>${r.name}</td><td>${r.type}</td><td>${r.required ? v.yes : v.no}</td><td>${r.description}</td></tr>`;
1423
+ }
1424
+ const tableRows = rows.map(rowFn).join("\n");
1174
1425
  const table = `<div style="overflow-x:auto">
1175
1426
  <table width="100%" style="min-width:500px">
1176
1427
  <thead><tr>${headerCells}</tr></thead>
@@ -1179,8 +1430,9 @@ ${tableRows}
1179
1430
  </tbody>
1180
1431
  </table>
1181
1432
  </div>`;
1182
- return `${heading} ${title}
1183
-
1433
+ const headingLevel = heading.length;
1434
+ const tag = `h${headingLevel}`;
1435
+ return `<${tag}>${title}</${tag}>
1184
1436
  ${table}
1185
1437
  `;
1186
1438
  }
@@ -1199,65 +1451,66 @@ function loadNodeLabels(labelPath) {
1199
1451
  return {};
1200
1452
  }
1201
1453
  }
1202
- function generateHelpDoc(nodeClass, labels) {
1454
+ function generateHelpDoc(nodeClass, labels, t) {
1203
1455
  const lines = [];
1204
1456
  if (labels.description) {
1205
- lines.push(labels.description);
1206
- lines.push("");
1457
+ lines.push(`<p>${labels.description}</p>`);
1207
1458
  }
1208
- const configSection = generateSchemaSection(
1209
- "Properties",
1210
- nodeClass.configSchema,
1211
- labels.configs
1212
- );
1459
+ const configSection = generateSchemaSection({
1460
+ title: t.sections.properties,
1461
+ schema: nodeClass.configSchema,
1462
+ t,
1463
+ labels: labels.configs
1464
+ });
1213
1465
  if (configSection) lines.push(configSection);
1214
- const credsSection = generateSchemaSection(
1215
- "Credentials",
1216
- nodeClass.credentialsSchema,
1217
- labels.credentials
1218
- );
1466
+ const credsSection = generateSchemaSection({
1467
+ title: t.sections.credentials,
1468
+ schema: nodeClass.credentialsSchema,
1469
+ t,
1470
+ labels: labels.credentials
1471
+ });
1219
1472
  if (credsSection) lines.push(credsSection);
1220
1473
  if (nodeClass.inputSchema) {
1221
- const inputLabels = nodeClass.inputLabels;
1222
- const inputLabel = typeof inputLabels === "string" ? inputLabels : Array.isArray(inputLabels) ? inputLabels[0] : void 0;
1223
- const inputTitle = inputLabel ? `Input (${inputLabel})` : "Input";
1224
- const inputSection = generateSchemaSection(
1225
- inputTitle,
1226
- nodeClass.inputSchema,
1227
- labels.input
1228
- );
1474
+ const inputSection = generateSchemaSection({
1475
+ title: t.sections.input,
1476
+ schema: nodeClass.inputSchema,
1477
+ t,
1478
+ labels: labels.input,
1479
+ includeDefault: false
1480
+ });
1229
1481
  if (inputSection) lines.push(inputSection);
1230
1482
  }
1231
1483
  if (nodeClass.outputsSchema) {
1232
- const outputLabels = nodeClass.outputLabels;
1233
1484
  if (Array.isArray(nodeClass.outputsSchema)) {
1234
1485
  const portSections = [];
1235
1486
  nodeClass.outputsSchema.forEach((schema, i) => {
1236
- const portLabel = Array.isArray(outputLabels) ? outputLabels[i] : void 0;
1237
- const title = portLabel ? `Port ${i + 1} \u2014 ${portLabel}` : `Port ${i + 1}`;
1487
+ const title = `${t.sections.port} ${i + 1}`;
1238
1488
  const portPropLabels = labels.outputs?.[i];
1239
- const section = generateSchemaSection(
1489
+ const section = generateSchemaSection({
1240
1490
  title,
1241
1491
  schema,
1242
- portPropLabels,
1243
- "####"
1244
- );
1492
+ t,
1493
+ labels: portPropLabels,
1494
+ heading: "####",
1495
+ includeDefault: false
1496
+ });
1245
1497
  if (section) portSections.push(section);
1246
1498
  });
1247
1499
  if (portSections.length) {
1248
- lines.push(`### Outputs
1249
-
1250
- ${portSections.join("\n")}`);
1500
+ lines.push(
1501
+ `<h3>${t.sections.outputs}</h3>
1502
+ ${portSections.join("\n")}`
1503
+ );
1251
1504
  }
1252
1505
  } else {
1253
- const label = typeof outputLabels === "string" ? outputLabels : Array.isArray(outputLabels) ? outputLabels[0] : void 0;
1254
- const title = label ? `Output (${label})` : "Output";
1255
1506
  const outputPropLabels = labels.outputs?.[0];
1256
- const section = generateSchemaSection(
1257
- title,
1258
- nodeClass.outputsSchema,
1259
- outputPropLabels
1260
- );
1507
+ const section = generateSchemaSection({
1508
+ title: t.sections.output,
1509
+ schema: nodeClass.outputsSchema,
1510
+ t,
1511
+ labels: outputPropLabels,
1512
+ includeDefault: false
1513
+ });
1261
1514
  if (section) lines.push(section);
1262
1515
  }
1263
1516
  }
@@ -1305,11 +1558,12 @@ function helpGenerator(options) {
1305
1558
  if (fs6.existsSync(manualMd) || fs6.existsSync(manualHtml)) continue;
1306
1559
  const labelPath = path6.join(labelsDir, type, `${lang}.json`);
1307
1560
  const labels = loadNodeLabels(labelPath);
1308
- const content = generateHelpDoc(NodeClass, labels);
1561
+ const t = getHelpTranslations(lang);
1562
+ const content = generateHelpDoc(NodeClass, labels, t);
1309
1563
  if (!content) continue;
1310
1564
  if (!helpByLang.has(lang)) helpByLang.set(lang, []);
1311
1565
  helpByLang.get(lang).push(
1312
- `<script type="text/markdown" data-help-name="${type}">
1566
+ `<script type="text/html" data-help-name="${type}">
1313
1567
  ${content}
1314
1568
  </script>`
1315
1569
  );
@@ -1609,12 +1863,8 @@ function nodeDefinitionsInliner(serverOutDir, entryPath, iconsDir, componentsDir
1609
1863
  align: NodeClass.align,
1610
1864
  color: NodeClass.color,
1611
1865
  icon: iconsDir ? resolveIcon(iconsDir, type) : void 0,
1612
- labelStyle: NodeClass.labelStyle,
1613
- paletteLabel: NodeClass.paletteLabel,
1614
1866
  inputs: NodeClass.inputs,
1615
1867
  outputs: NodeClass.outputs,
1616
- inputLabels: NodeClass.inputLabels,
1617
- outputLabels: NodeClass.outputLabels,
1618
1868
  inputSchema,
1619
1869
  outputsSchema
1620
1870
  };