@ha-bits/cortex 1.0.4 → 1.0.6
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/README.md +1 -1
- package/pack/index.cjs +242 -101
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Cortex uses `createRequire` from Node.js's `module` API instead of the standard
|
|
|
47
47
|
|
|
48
48
|
1. **Bundler Compatibility**: When the code is bundled with esbuild/webpack then ncc, the bundler transforms `require()` calls and creates a static context that can't resolve paths determined at runtime.
|
|
49
49
|
|
|
50
|
-
2. **Dynamic Path Resolution**: Activepieces modules are downloaded to `/tmp/habits-nodes/` or wherever the env points to at runtime and their paths aren't known at build time. Using `createRequire(__filename)` creates a fresh require function that bypasses the bundler's static analysis.
|
|
50
|
+
2. **Dynamic Path Resolution**: Activepieces modules are downloaded to `/tmp/habits-nodes/` or wherever the env points to at runtime (HABITS_NODES_PATH) and their paths aren't known at build time. Using `createRequire(__filename)` creates a fresh require function that bypasses the bundler's static analysis.
|
|
51
51
|
|
|
52
52
|
3. **Production Environment**: In production (`/app/dist/pack/index.cjs`), the bundled code would throw "Cannot find module" errors with regular `require()` because webpack's `webpackEmptyContext` can't resolve dynamic paths.
|
|
53
53
|
|
package/pack/index.cjs
CHANGED
|
@@ -254452,17 +254452,59 @@ var import_uuid = __nccwpck_require__(12048);
|
|
|
254452
254452
|
|
|
254453
254453
|
// packages/cortex/server/src/utils/moduleLoader.ts
|
|
254454
254454
|
var path3 = __toESM(__nccwpck_require__(16928));
|
|
254455
|
-
var import_child_process2 = __nccwpck_require__(35317);
|
|
254456
|
-
var import_util2 = __nccwpck_require__(39023);
|
|
254457
254455
|
|
|
254458
254456
|
// packages/cortex/server/src/utils/moduleCloner.ts
|
|
254459
254457
|
var fs = __toESM(__nccwpck_require__(79896));
|
|
254460
254458
|
var path2 = __toESM(__nccwpck_require__(16928));
|
|
254461
|
-
var
|
|
254462
|
-
var
|
|
254459
|
+
var import_child_process2 = __nccwpck_require__(35317);
|
|
254460
|
+
var import_util2 = __nccwpck_require__(39023);
|
|
254463
254461
|
|
|
254464
254462
|
// packages/cortex/server/src/utils/utils.ts
|
|
254465
254463
|
var path = __toESM(__nccwpck_require__(16928));
|
|
254464
|
+
var import_child_process = __nccwpck_require__(35317);
|
|
254465
|
+
var import_util = __nccwpck_require__(39023);
|
|
254466
|
+
var logger = console;
|
|
254467
|
+
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
254468
|
+
function buildNpmInstallCommand(packageSpec, options = {}) {
|
|
254469
|
+
const parts = ["npm", "install"];
|
|
254470
|
+
const prefix = getNodesBasePath();
|
|
254471
|
+
if (packageSpec) {
|
|
254472
|
+
parts.push(packageSpec);
|
|
254473
|
+
}
|
|
254474
|
+
if (options.global) {
|
|
254475
|
+
parts.push("-g");
|
|
254476
|
+
}
|
|
254477
|
+
if (options.legacyPeerDeps) {
|
|
254478
|
+
parts.push("--legacy-peer-deps");
|
|
254479
|
+
}
|
|
254480
|
+
if (options.includePeer) {
|
|
254481
|
+
parts.push("--include=peer");
|
|
254482
|
+
}
|
|
254483
|
+
if (options.production) {
|
|
254484
|
+
parts.push("--production");
|
|
254485
|
+
}
|
|
254486
|
+
if (options.noSave) {
|
|
254487
|
+
parts.push("--no-save");
|
|
254488
|
+
}
|
|
254489
|
+
parts.push(`--prefix ${prefix}`);
|
|
254490
|
+
parts.push(`--save`);
|
|
254491
|
+
if (options.saveOptional) {
|
|
254492
|
+
parts.push("--save-optional");
|
|
254493
|
+
}
|
|
254494
|
+
return parts.join(" ");
|
|
254495
|
+
}
|
|
254496
|
+
async function npmInstall(packageSpec, options = {}) {
|
|
254497
|
+
const command = buildNpmInstallCommand(packageSpec, options);
|
|
254498
|
+
const execOptions = {};
|
|
254499
|
+
if (options.cwd) {
|
|
254500
|
+
execOptions.cwd = options.cwd;
|
|
254501
|
+
}
|
|
254502
|
+
if (options.timeout) {
|
|
254503
|
+
execOptions.timeout = options.timeout;
|
|
254504
|
+
}
|
|
254505
|
+
logger.log(`Executing command: ${command}`);
|
|
254506
|
+
return execAsync(command, execOptions);
|
|
254507
|
+
}
|
|
254466
254508
|
var NODES_BASE_PATH_ENV = "HABITS_NODES_PATH";
|
|
254467
254509
|
var DEFAULT_NODES_BASE_PATH = "/tmp/habits-nodes";
|
|
254468
254510
|
var cachedNodesBasePath = null;
|
|
@@ -254478,14 +254520,14 @@ function getNodesBasePath() {
|
|
|
254478
254520
|
return cachedNodesBasePath;
|
|
254479
254521
|
}
|
|
254480
254522
|
function getNodesPath(framework) {
|
|
254481
|
-
return path.join(getNodesBasePath(), "
|
|
254523
|
+
return path.join(getNodesBasePath(), "node_modules");
|
|
254482
254524
|
}
|
|
254483
254525
|
function getModuleFullPath(framework, moduleName) {
|
|
254484
|
-
return path.join(getNodesBasePath(), "
|
|
254526
|
+
return path.join(getNodesBasePath(), "node_modules", moduleName);
|
|
254485
254527
|
}
|
|
254486
254528
|
|
|
254487
254529
|
// packages/cortex/server/src/utils/moduleCloner.ts
|
|
254488
|
-
var
|
|
254530
|
+
var execAsync2 = (0, import_util2.promisify)(import_child_process2.exec);
|
|
254489
254531
|
function getShimsPath() {
|
|
254490
254532
|
const distShimsPath = path2.join(__dirname, "..", "shims");
|
|
254491
254533
|
if (fs.existsSync(distShimsPath) && fs.existsSync(path2.join(distShimsPath, "n8n-workflow", "index.js"))) {
|
|
@@ -254503,7 +254545,7 @@ function getShimsPath() {
|
|
|
254503
254545
|
}
|
|
254504
254546
|
async function areShimsLinkedGlobally() {
|
|
254505
254547
|
try {
|
|
254506
|
-
const { stdout } = await
|
|
254548
|
+
const { stdout } = await execAsync2('npm ls -g --depth=0 --json 2>/dev/null || echo "{}"');
|
|
254507
254549
|
const globalPackages = JSON.parse(stdout);
|
|
254508
254550
|
return globalPackages.dependencies?.["n8n-workflow"]?.version === "999.0.0";
|
|
254509
254551
|
} catch {
|
|
@@ -254526,13 +254568,85 @@ async function registerShimsGlobally() {
|
|
|
254526
254568
|
}
|
|
254527
254569
|
console.log(`\u{1F517} Registering ${shimName} shim globally...`);
|
|
254528
254570
|
try {
|
|
254529
|
-
await
|
|
254571
|
+
await execAsync2("npm link", { cwd: shimPath, timeout: 3e4 });
|
|
254530
254572
|
console.log(`\u2713 Registered ${shimName} shim globally`);
|
|
254531
254573
|
} catch (error) {
|
|
254532
254574
|
console.warn(`\u26A0\uFE0F Failed to register ${shimName} shim globally: ${error.message}`);
|
|
254533
254575
|
}
|
|
254534
254576
|
}
|
|
254535
254577
|
}
|
|
254578
|
+
var ACTIVEPIECES_PEER_DEPS = [
|
|
254579
|
+
"@activepieces/pieces-common",
|
|
254580
|
+
"@activepieces/pieces-framework",
|
|
254581
|
+
"@activepieces/shared"
|
|
254582
|
+
];
|
|
254583
|
+
function getActivepiecesPackagesPath() {
|
|
254584
|
+
const possiblePaths = [
|
|
254585
|
+
// Development: relative to the source file
|
|
254586
|
+
path2.join(__dirname, "..", "..", "..", "..", "..", "node_modules"),
|
|
254587
|
+
// Packed: relative to dist folder
|
|
254588
|
+
path2.join(__dirname, "..", "..", "..", "..", "node_modules"),
|
|
254589
|
+
// From process.cwd()
|
|
254590
|
+
path2.join(process.cwd(), "node_modules"),
|
|
254591
|
+
// Parent directories from cwd
|
|
254592
|
+
path2.join(process.cwd(), "..", "node_modules"),
|
|
254593
|
+
path2.join(process.cwd(), "..", "..", "node_modules"),
|
|
254594
|
+
// NEW: In case of the newer setup where nodes are in getNodesBasePath()
|
|
254595
|
+
path2.join(getNodesBasePath(), "node_modules")
|
|
254596
|
+
];
|
|
254597
|
+
for (const basePath of possiblePaths) {
|
|
254598
|
+
const testPath = path2.join(basePath, "@activepieces", "pieces-framework");
|
|
254599
|
+
if (fs.existsSync(testPath)) {
|
|
254600
|
+
return basePath;
|
|
254601
|
+
}
|
|
254602
|
+
}
|
|
254603
|
+
return null;
|
|
254604
|
+
}
|
|
254605
|
+
async function linkActivepiecesDeps(modulePath, moduleName) {
|
|
254606
|
+
const cortexNodeModules = getActivepiecesPackagesPath();
|
|
254607
|
+
if (!cortexNodeModules) {
|
|
254608
|
+
console.warn(`\u26A0\uFE0F Could not find cortex node_modules with ActivePieces packages`);
|
|
254609
|
+
return;
|
|
254610
|
+
}
|
|
254611
|
+
console.log(`\u{1F517} Linking ActivePieces peer dependencies for ${moduleName}...`);
|
|
254612
|
+
const moduleNodeModules = path2.join(modulePath, "node_modules");
|
|
254613
|
+
const activepiecesDir = path2.join(moduleNodeModules, "@activepieces");
|
|
254614
|
+
if (!fs.existsSync(activepiecesDir)) {
|
|
254615
|
+
fs.mkdirSync(activepiecesDir, { recursive: true });
|
|
254616
|
+
}
|
|
254617
|
+
for (const dep of ACTIVEPIECES_PEER_DEPS) {
|
|
254618
|
+
const [scope, pkgName] = dep.split("/");
|
|
254619
|
+
const sourcePackagePath = path2.join(cortexNodeModules, scope, pkgName);
|
|
254620
|
+
const targetPackagePath = path2.join(moduleNodeModules, scope, pkgName);
|
|
254621
|
+
if (!fs.existsSync(sourcePackagePath)) {
|
|
254622
|
+
console.warn(`\u26A0\uFE0F Source package not found: ${sourcePackagePath}`);
|
|
254623
|
+
continue;
|
|
254624
|
+
}
|
|
254625
|
+
if (fs.existsSync(targetPackagePath)) {
|
|
254626
|
+
try {
|
|
254627
|
+
const stats = fs.lstatSync(targetPackagePath);
|
|
254628
|
+
if (stats.isSymbolicLink()) {
|
|
254629
|
+
const linkTarget = fs.readlinkSync(targetPackagePath);
|
|
254630
|
+
if (linkTarget === sourcePackagePath || linkTarget.endsWith(path2.join(scope, pkgName))) {
|
|
254631
|
+
console.log(`\u2713 ${dep} already linked for ${moduleName}`);
|
|
254632
|
+
continue;
|
|
254633
|
+
}
|
|
254634
|
+
}
|
|
254635
|
+
fs.rmSync(targetPackagePath, { recursive: true, force: true });
|
|
254636
|
+
} catch (e) {
|
|
254637
|
+
}
|
|
254638
|
+
}
|
|
254639
|
+
try {
|
|
254640
|
+
fs.symlinkSync(sourcePackagePath, targetPackagePath, "dir");
|
|
254641
|
+
console.log(`\u2713 Linked ${dep} for ${moduleName}`);
|
|
254642
|
+
} catch (error) {
|
|
254643
|
+
console.warn(`\u26A0\uFE0F Failed to link ${dep}: ${error.message}`);
|
|
254644
|
+
}
|
|
254645
|
+
}
|
|
254646
|
+
}
|
|
254647
|
+
async function ensureActivepiecesDepsLinked(modulePath, moduleName) {
|
|
254648
|
+
await linkActivepiecesDeps(modulePath, moduleName);
|
|
254649
|
+
}
|
|
254536
254650
|
async function linkN8nShims(modulePath, moduleName) {
|
|
254537
254651
|
const shimsPath = getShimsPath();
|
|
254538
254652
|
if (!await areShimsLinkedGlobally()) {
|
|
@@ -254547,7 +254661,7 @@ async function linkN8nShims(modulePath, moduleName) {
|
|
|
254547
254661
|
}
|
|
254548
254662
|
console.log(`\u{1F517} Linking ${shimName} shim for ${moduleName}...`);
|
|
254549
254663
|
try {
|
|
254550
|
-
await
|
|
254664
|
+
await execAsync2(`npm link ${shimName}`, { cwd: modulePath, timeout: 3e4 });
|
|
254551
254665
|
console.log(`\u2713 Linked ${shimName} shim for ${moduleName}`);
|
|
254552
254666
|
} catch (error) {
|
|
254553
254667
|
console.log(`\u2139\uFE0F npm link failed, using manual link for ${shimName}...`);
|
|
@@ -254619,7 +254733,7 @@ async function cloneModule(moduleDefinition, targetDir) {
|
|
|
254619
254733
|
if (!fs.existsSync(targetDir)) {
|
|
254620
254734
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
254621
254735
|
}
|
|
254622
|
-
const { stdout, stderr } = await
|
|
254736
|
+
const { stdout, stderr } = await execAsync2(
|
|
254623
254737
|
`git clone ${repository} ${modulePath}`,
|
|
254624
254738
|
{ cwd: targetDir }
|
|
254625
254739
|
);
|
|
@@ -254631,13 +254745,12 @@ async function cloneModule(moduleDefinition, targetDir) {
|
|
|
254631
254745
|
console.log(`\u{1F4E6} Installing dependencies for ${name}...`);
|
|
254632
254746
|
try {
|
|
254633
254747
|
await linkN8nShims(modulePath, name);
|
|
254634
|
-
|
|
254635
|
-
cwd: modulePath,
|
|
254636
|
-
timeout: 18e4
|
|
254637
|
-
// 3 minutes timeout for larger repos
|
|
254638
|
-
});
|
|
254748
|
+
await npmInstall(void 0, { cwd: modulePath, legacyPeerDeps: true, includePeer: true, timeout: 18e4 });
|
|
254639
254749
|
console.log(`\u2713 Dependencies installed for ${name}`);
|
|
254640
254750
|
await removeN8nPackagesIfReinstalled(modulePath, name);
|
|
254751
|
+
if (moduleDefinition.framework === "activepieces") {
|
|
254752
|
+
await ensureActivepiecesDepsLinked(modulePath, name);
|
|
254753
|
+
}
|
|
254641
254754
|
} catch (error) {
|
|
254642
254755
|
console.warn(`\u26A0\uFE0F Warning: Failed to install dependencies for ${name}: ${error.message}`);
|
|
254643
254756
|
}
|
|
@@ -254654,12 +254767,11 @@ async function buildModule(moduleDefinition, modulePath) {
|
|
|
254654
254767
|
console.log(`\u{1F4E6} Installing production dependencies for ${name}...`);
|
|
254655
254768
|
try {
|
|
254656
254769
|
await linkN8nShims(modulePath, name);
|
|
254657
|
-
|
|
254658
|
-
cwd: modulePath,
|
|
254659
|
-
timeout: 12e4
|
|
254660
|
-
// 2 minutes timeout
|
|
254661
|
-
});
|
|
254770
|
+
await npmInstall(void 0, { cwd: modulePath, legacyPeerDeps: true, includePeer: true, production: true, timeout: 12e4 });
|
|
254662
254771
|
await removeN8nPackagesIfReinstalled(modulePath, name);
|
|
254772
|
+
if (moduleDefinition.framework === "activepieces") {
|
|
254773
|
+
await ensureActivepiecesDepsLinked(modulePath, name);
|
|
254774
|
+
}
|
|
254663
254775
|
} catch (error) {
|
|
254664
254776
|
console.warn(`\u26A0\uFE0F Warning: Failed to install production dependencies for ${name}: ${error.message}`);
|
|
254665
254777
|
}
|
|
@@ -254674,7 +254786,7 @@ async function buildModule(moduleDefinition, modulePath) {
|
|
|
254674
254786
|
}
|
|
254675
254787
|
console.log(`\u{1F528} Building ${name} with command: ${buildCommand}`);
|
|
254676
254788
|
try {
|
|
254677
|
-
const { stdout, stderr } = await
|
|
254789
|
+
const { stdout, stderr } = await execAsync2(buildCommand, {
|
|
254678
254790
|
cwd: modulePath,
|
|
254679
254791
|
maxBuffer: 1024 * 1024 * 10
|
|
254680
254792
|
// 10MB buffer
|
|
@@ -254830,17 +254942,15 @@ async function installNpmModule(moduleDefinition, targetDir) {
|
|
|
254830
254942
|
console.log(`\u2713 Module ${name} already installed at ${modulePath}`);
|
|
254831
254943
|
return modulePath;
|
|
254832
254944
|
}
|
|
254833
|
-
|
|
254945
|
+
const prefix = getNodesBasePath();
|
|
254946
|
+
console.log(`\u{1F4E6} Installing ${name} from npm registry (${packageName}) to ${prefix}...`);
|
|
254834
254947
|
try {
|
|
254835
254948
|
if (!fs.existsSync(targetDir)) {
|
|
254836
254949
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
254837
254950
|
}
|
|
254838
254951
|
const tempDir = path2.join(targetDir, `.temp-${name}`);
|
|
254839
254952
|
fs.mkdirSync(tempDir, { recursive: true });
|
|
254840
|
-
const { stdout, stderr } = await
|
|
254841
|
-
`npm install ${packageName} --no-save --prefix .`,
|
|
254842
|
-
{ cwd: tempDir }
|
|
254843
|
-
);
|
|
254953
|
+
const { stdout, stderr } = await npmInstall(packageName, { cwd: tempDir, noSave: true, prefix, includePeer: true });
|
|
254844
254954
|
if (stderr && !stderr.includes("npm warn")) {
|
|
254845
254955
|
console.warn(`Install warnings: ${stderr}`);
|
|
254846
254956
|
}
|
|
@@ -254894,13 +255004,12 @@ async function installNpmModule(moduleDefinition, targetDir) {
|
|
|
254894
255004
|
console.log(`\u{1F4E6} Installing dependencies for ${name}...`);
|
|
254895
255005
|
try {
|
|
254896
255006
|
await linkN8nShims(modulePath, name);
|
|
254897
|
-
|
|
254898
|
-
cwd: modulePath,
|
|
254899
|
-
timeout: 12e4
|
|
254900
|
-
// 2 minutes timeout
|
|
254901
|
-
});
|
|
255007
|
+
await npmInstall(void 0, { cwd: modulePath, legacyPeerDeps: true, includePeer: true, timeout: 12e4 });
|
|
254902
255008
|
console.log(`\u2713 Dependencies installed for ${name}`);
|
|
254903
255009
|
await removeN8nPackagesIfReinstalled(modulePath, name);
|
|
255010
|
+
if (moduleDefinition.framework === "activepieces") {
|
|
255011
|
+
await ensureActivepiecesDepsLinked(modulePath, name);
|
|
255012
|
+
}
|
|
254904
255013
|
} catch (error) {
|
|
254905
255014
|
console.warn(`\u26A0\uFE0F Warning: Failed to install dependencies for ${name}: ${error.message}`);
|
|
254906
255015
|
}
|
|
@@ -254921,6 +255030,39 @@ function getModulePath(moduleDefinition) {
|
|
|
254921
255030
|
}
|
|
254922
255031
|
function getModuleMainFile(moduleDefinition) {
|
|
254923
255032
|
const modulePath = getModulePath(moduleDefinition);
|
|
255033
|
+
const packageJsonPath = path2.join(modulePath, "package.json");
|
|
255034
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
255035
|
+
try {
|
|
255036
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
255037
|
+
let mainEntry = packageJson.main || packageJson.module;
|
|
255038
|
+
if (!mainEntry && packageJson.exports) {
|
|
255039
|
+
if (typeof packageJson.exports === "string") {
|
|
255040
|
+
mainEntry = packageJson.exports;
|
|
255041
|
+
} else if (packageJson.exports["."]) {
|
|
255042
|
+
const dotExport = packageJson.exports["."];
|
|
255043
|
+
if (typeof dotExport === "string") {
|
|
255044
|
+
mainEntry = dotExport;
|
|
255045
|
+
} else if (dotExport.require) {
|
|
255046
|
+
mainEntry = dotExport.require;
|
|
255047
|
+
} else if (dotExport.import) {
|
|
255048
|
+
mainEntry = dotExport.import;
|
|
255049
|
+
} else if (dotExport.default) {
|
|
255050
|
+
mainEntry = dotExport.default;
|
|
255051
|
+
}
|
|
255052
|
+
}
|
|
255053
|
+
}
|
|
255054
|
+
if (mainEntry) {
|
|
255055
|
+
mainEntry = mainEntry.replace(/^\.\//, "");
|
|
255056
|
+
const mainPath = path2.join(modulePath, mainEntry);
|
|
255057
|
+
if (fs.existsSync(mainPath)) {
|
|
255058
|
+
console.log(`\u2713 Found main file from package.json for module: ${moduleDefinition.repository} at path: ${mainPath}`);
|
|
255059
|
+
return mainPath;
|
|
255060
|
+
}
|
|
255061
|
+
}
|
|
255062
|
+
} catch (error) {
|
|
255063
|
+
console.warn(`\u26A0\uFE0F Failed to parse package.json for ${moduleDefinition.repository}`);
|
|
255064
|
+
}
|
|
255065
|
+
}
|
|
254924
255066
|
const commonPaths = [
|
|
254925
255067
|
"dist/index.js",
|
|
254926
255068
|
"dist/main.js",
|
|
@@ -254945,7 +255087,6 @@ function getModuleMainFile(moduleDefinition) {
|
|
|
254945
255087
|
}
|
|
254946
255088
|
|
|
254947
255089
|
// packages/cortex/server/src/utils/moduleLoader.ts
|
|
254948
|
-
var execAsync2 = (0, import_util2.promisify)(import_child_process2.exec);
|
|
254949
255090
|
function getModuleName(moduleDefinition) {
|
|
254950
255091
|
if (moduleDefinition.source === "github") {
|
|
254951
255092
|
const url = moduleDefinition.repository;
|
|
@@ -254988,7 +255129,7 @@ var fs2 = __toESM(__nccwpck_require__(79896));
|
|
|
254988
255129
|
var import_axios = __toESM(__nccwpck_require__(87269));
|
|
254989
255130
|
var import_form_data = __toESM(__nccwpck_require__(96454));
|
|
254990
255131
|
var import_module = __nccwpck_require__(73339);
|
|
254991
|
-
var
|
|
255132
|
+
var logger2 = console;
|
|
254992
255133
|
var credentialTypeCache = /* @__PURE__ */ new Map();
|
|
254993
255134
|
function loadCredentialType(moduleDefinition, credentialTypeName) {
|
|
254994
255135
|
if (credentialTypeCache.has(credentialTypeName)) {
|
|
@@ -255017,7 +255158,7 @@ function loadCredentialType(moduleDefinition, credentialTypeName) {
|
|
|
255017
255158
|
const instance = new exported();
|
|
255018
255159
|
if (instance && instance.name === credentialTypeName) {
|
|
255019
255160
|
credentialTypeCache.set(credentialTypeName, instance);
|
|
255020
|
-
|
|
255161
|
+
logger2.log(`\u{1F4CB} Loaded credential type: ${credentialTypeName}`);
|
|
255021
255162
|
return instance;
|
|
255022
255163
|
}
|
|
255023
255164
|
} catch (e) {
|
|
@@ -255029,7 +255170,7 @@ function loadCredentialType(moduleDefinition, credentialTypeName) {
|
|
|
255029
255170
|
}
|
|
255030
255171
|
}
|
|
255031
255172
|
} catch (error) {
|
|
255032
|
-
|
|
255173
|
+
logger2.warn(`Failed to load credential type ${credentialTypeName}: ${error}`);
|
|
255033
255174
|
}
|
|
255034
255175
|
return null;
|
|
255035
255176
|
}
|
|
@@ -255045,7 +255186,7 @@ function resolveCredentialExpression(expression, credentials) {
|
|
|
255045
255186
|
function applyCredentialAuthentication(requestOptions, credentialType, credentials) {
|
|
255046
255187
|
const auth = credentialType.authenticate;
|
|
255047
255188
|
if (!auth) {
|
|
255048
|
-
|
|
255189
|
+
logger2.warn(`Credential type ${credentialType.name} has no authenticate property`);
|
|
255049
255190
|
return;
|
|
255050
255191
|
}
|
|
255051
255192
|
if (typeof auth === "object" && auth.type === "generic") {
|
|
@@ -255092,9 +255233,9 @@ function applyCredentialAuthentication(requestOptions, credentialType, credentia
|
|
|
255092
255233
|
);
|
|
255093
255234
|
requestOptions.auth = { username, password };
|
|
255094
255235
|
}
|
|
255095
|
-
|
|
255236
|
+
logger2.log(`\u2705 Applied generic authentication from credential type: ${credentialType.name}`);
|
|
255096
255237
|
} else if (typeof auth === "function") {
|
|
255097
|
-
|
|
255238
|
+
logger2.warn(`Function-based authentication not yet supported for ${credentialType.name}`);
|
|
255098
255239
|
}
|
|
255099
255240
|
}
|
|
255100
255241
|
function applyFallbackAuthentication(headers, credentials) {
|
|
@@ -255196,7 +255337,7 @@ async function httpRequest(requestOptions) {
|
|
|
255196
255337
|
if (axiosConfig.data === void 0 || axiosConfig.method?.toUpperCase() === "GET") {
|
|
255197
255338
|
delete axiosConfig.data;
|
|
255198
255339
|
}
|
|
255199
|
-
|
|
255340
|
+
logger2.log(`\u{1F310} Making HTTP request: ${axiosConfig.method} ${axiosConfig.url}`);
|
|
255200
255341
|
try {
|
|
255201
255342
|
const response = await (0, import_axios.default)(axiosConfig);
|
|
255202
255343
|
if (requestOptions.returnFullResponse) {
|
|
@@ -255210,7 +255351,7 @@ async function httpRequest(requestOptions) {
|
|
|
255210
255351
|
return response.data;
|
|
255211
255352
|
} catch (error) {
|
|
255212
255353
|
if (error.response) {
|
|
255213
|
-
|
|
255354
|
+
logger2.error(`HTTP Error (${error.response.status}): ${JSON.stringify(error.response.data)}`);
|
|
255214
255355
|
throw new Error(`HTTP Error (${error.response.status}): ${JSON.stringify(error.response.data)}`);
|
|
255215
255356
|
}
|
|
255216
255357
|
throw error;
|
|
@@ -255446,22 +255587,22 @@ function createExecutionContext(node, params, options) {
|
|
|
255446
255587
|
getInstanceId: () => "instance-1",
|
|
255447
255588
|
// Logging
|
|
255448
255589
|
logger: {
|
|
255449
|
-
info: (...args) =>
|
|
255450
|
-
warn: (...args) =>
|
|
255451
|
-
error: (...args) =>
|
|
255452
|
-
debug: (...args) =>
|
|
255590
|
+
info: (...args) => logger2.log("[n8n]", ...args),
|
|
255591
|
+
warn: (...args) => logger2.warn("[n8n]", ...args),
|
|
255592
|
+
error: (...args) => logger2.error("[n8n]", ...args),
|
|
255593
|
+
debug: (...args) => logger2.log("[n8n:debug]", ...args)
|
|
255453
255594
|
},
|
|
255454
255595
|
// Send message to UI (no-op in headless execution)
|
|
255455
255596
|
sendMessageToUI: (message) => {
|
|
255456
|
-
|
|
255597
|
+
logger2.log("[n8n:ui]", message);
|
|
255457
255598
|
},
|
|
255458
255599
|
// Put execution to wait (for wait nodes)
|
|
255459
255600
|
putExecutionToWait: async (waitTill) => {
|
|
255460
|
-
|
|
255601
|
+
logger2.log(`[n8n] Waiting until: ${waitTill.toISOString()}`);
|
|
255461
255602
|
},
|
|
255462
255603
|
// Send response (for webhook response nodes)
|
|
255463
255604
|
sendResponse: (response) => {
|
|
255464
|
-
|
|
255605
|
+
logger2.log("[n8n] Sending response:", response);
|
|
255465
255606
|
},
|
|
255466
255607
|
// Prepare output data - transforms INodeExecutionData[] to INodeExecutionData[][]
|
|
255467
255608
|
prepareOutputData: async (outputData, outputIndex = 0) => {
|
|
@@ -255476,22 +255617,22 @@ function createExecutionContext(node, params, options) {
|
|
|
255476
255617
|
}
|
|
255477
255618
|
function getN8nNodeFile(moduleDefinition) {
|
|
255478
255619
|
const modulePath = getModulePath(moduleDefinition);
|
|
255479
|
-
|
|
255620
|
+
logger2.log(`
|
|
255480
255621
|
\u{1F50D} getN8nNodeFile looking for module at: ${modulePath}`);
|
|
255481
|
-
|
|
255622
|
+
logger2.log(` Source: ${moduleDefinition.source}`);
|
|
255482
255623
|
const packageJsonPath = path4.join(modulePath, "package.json");
|
|
255483
255624
|
if (!fs2.existsSync(packageJsonPath)) {
|
|
255484
|
-
|
|
255625
|
+
logger2.error(`package.json not found at: ${packageJsonPath}`);
|
|
255485
255626
|
return null;
|
|
255486
255627
|
}
|
|
255487
|
-
|
|
255628
|
+
logger2.log(` Found package.json at: ${packageJsonPath}`);
|
|
255488
255629
|
try {
|
|
255489
255630
|
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
255490
255631
|
if (packageJson.n8n?.nodes && packageJson.n8n.nodes.length > 0) {
|
|
255491
255632
|
const nodeFile = packageJson.n8n.nodes[0];
|
|
255492
255633
|
const fullPath = path4.join(modulePath, nodeFile);
|
|
255493
255634
|
if (fs2.existsSync(fullPath)) {
|
|
255494
|
-
|
|
255635
|
+
logger2.log(`\u{1F50D} Found n8n node at: ${fullPath}`);
|
|
255495
255636
|
return fullPath;
|
|
255496
255637
|
}
|
|
255497
255638
|
}
|
|
@@ -255505,14 +255646,14 @@ function getN8nNodeFile(moduleDefinition) {
|
|
|
255505
255646
|
if (fs2.existsSync(dir) && fs2.statSync(dir).isDirectory()) {
|
|
255506
255647
|
const nodeFile = findNodeFileInDirectory(dir);
|
|
255507
255648
|
if (nodeFile) {
|
|
255508
|
-
|
|
255649
|
+
logger2.log(`\u{1F50D} Found n8n node via search at: ${nodeFile}`);
|
|
255509
255650
|
return nodeFile;
|
|
255510
255651
|
}
|
|
255511
255652
|
}
|
|
255512
255653
|
}
|
|
255513
255654
|
return null;
|
|
255514
255655
|
} catch (error) {
|
|
255515
|
-
|
|
255656
|
+
logger2.error(`Error reading package.json: ${error.message}`);
|
|
255516
255657
|
return null;
|
|
255517
255658
|
}
|
|
255518
255659
|
}
|
|
@@ -255536,7 +255677,7 @@ async function executeN8nModule(paramsOrModuleName, maybeParams) {
|
|
|
255536
255677
|
let moduleDefinition;
|
|
255537
255678
|
let executionParams;
|
|
255538
255679
|
if (typeof paramsOrModuleName === "string") {
|
|
255539
|
-
|
|
255680
|
+
logger2.log(`
|
|
255540
255681
|
\u{1F4CB} executeN8nModule called with string: ${paramsOrModuleName}`);
|
|
255541
255682
|
moduleDefinition = {
|
|
255542
255683
|
framework: "n8n",
|
|
@@ -255545,11 +255686,11 @@ async function executeN8nModule(paramsOrModuleName, maybeParams) {
|
|
|
255545
255686
|
};
|
|
255546
255687
|
executionParams = maybeParams || {};
|
|
255547
255688
|
} else {
|
|
255548
|
-
|
|
255689
|
+
logger2.log(`
|
|
255549
255690
|
\u{1F4CB} executeN8nModule called with params object:`);
|
|
255550
|
-
|
|
255551
|
-
|
|
255552
|
-
|
|
255691
|
+
logger2.log(` Framework: ${paramsOrModuleName.framework}`);
|
|
255692
|
+
logger2.log(` Source: ${paramsOrModuleName.source}`);
|
|
255693
|
+
logger2.log(` ModuleName: ${paramsOrModuleName.moduleName}`);
|
|
255553
255694
|
moduleDefinition = {
|
|
255554
255695
|
framework: paramsOrModuleName.framework,
|
|
255555
255696
|
source: paramsOrModuleName.source,
|
|
@@ -255558,7 +255699,7 @@ async function executeN8nModule(paramsOrModuleName, maybeParams) {
|
|
|
255558
255699
|
executionParams = paramsOrModuleName.params;
|
|
255559
255700
|
}
|
|
255560
255701
|
const inferredModuleName = getModuleName(moduleDefinition);
|
|
255561
|
-
|
|
255702
|
+
logger2.log(`
|
|
255562
255703
|
\u{1F50D} Ensuring n8n module is ready: ${inferredModuleName}`);
|
|
255563
255704
|
await ensureModuleInstalled(moduleDefinition);
|
|
255564
255705
|
let mainFilePath = getN8nNodeFile(moduleDefinition);
|
|
@@ -255568,7 +255709,7 @@ async function executeN8nModule(paramsOrModuleName, maybeParams) {
|
|
|
255568
255709
|
if (!mainFilePath) {
|
|
255569
255710
|
throw new Error(`Could not locate node file for n8n module: ${inferredModuleName}`);
|
|
255570
255711
|
}
|
|
255571
|
-
|
|
255712
|
+
logger2.log(`\u{1F4E6} n8n node file at: ${mainFilePath}`);
|
|
255572
255713
|
try {
|
|
255573
255714
|
return await executeGenericN8nNode(executionParams, moduleDefinition, mainFilePath);
|
|
255574
255715
|
} catch (error) {
|
|
@@ -255592,7 +255733,7 @@ async function loadNodeFromModule(moduleDefinition, mainFilePath) {
|
|
|
255592
255733
|
const instance = new exported();
|
|
255593
255734
|
if (instance && typeof instance === "object" && "description" in instance) {
|
|
255594
255735
|
nodeInstance = instance;
|
|
255595
|
-
|
|
255736
|
+
logger2.debug(`Found n8n node class: ${key}`);
|
|
255596
255737
|
break;
|
|
255597
255738
|
}
|
|
255598
255739
|
} catch (e) {
|
|
@@ -255606,17 +255747,17 @@ async function loadNodeFromModule(moduleDefinition, mainFilePath) {
|
|
|
255606
255747
|
return nodeInstance;
|
|
255607
255748
|
} catch (error) {
|
|
255608
255749
|
process.chdir(originalCwd);
|
|
255609
|
-
|
|
255750
|
+
logger2.error(error.stack);
|
|
255610
255751
|
throw error;
|
|
255611
255752
|
}
|
|
255612
255753
|
}
|
|
255613
255754
|
async function executeGenericN8nNode(params, moduleDefinition, mainFilePath) {
|
|
255614
255755
|
try {
|
|
255615
255756
|
const node = await loadNodeFromModule(moduleDefinition, mainFilePath);
|
|
255616
|
-
|
|
255757
|
+
logger2.log(`\u{1F680} Executing n8n node: ${node.description.displayName}`);
|
|
255617
255758
|
const operation = params.operation;
|
|
255618
255759
|
const resource = params.resource;
|
|
255619
|
-
|
|
255760
|
+
logger2.log(`Resource: ${resource || "default"}, Operation: ${operation || "default"}`);
|
|
255620
255761
|
const paramsWithModule = {
|
|
255621
255762
|
...params,
|
|
255622
255763
|
__moduleDefinition: moduleDefinition
|
|
@@ -255626,12 +255767,12 @@ async function executeGenericN8nNode(params, moduleDefinition, mainFilePath) {
|
|
|
255626
255767
|
if (node.execute) {
|
|
255627
255768
|
result = await node.execute.call(context);
|
|
255628
255769
|
} else if (node.description.requestDefaults || hasRoutingInDescription(node.description)) {
|
|
255629
|
-
|
|
255770
|
+
logger2.log(`\u{1F4E1} Using routing-based execution for declarative node`);
|
|
255630
255771
|
result = await executeRoutingBasedNode(node, paramsWithModule, context);
|
|
255631
255772
|
} else {
|
|
255632
255773
|
throw new Error(`Node does not have an execute method and is not a routing-based node`);
|
|
255633
255774
|
}
|
|
255634
|
-
|
|
255775
|
+
logger2.log(`\u2705 Successfully executed n8n node: ${node.description.displayName}`);
|
|
255635
255776
|
const output = result?.[0]?.map((item) => item.json) || result;
|
|
255636
255777
|
return {
|
|
255637
255778
|
success: true,
|
|
@@ -255647,8 +255788,8 @@ async function executeGenericN8nNode(params, moduleDefinition, mainFilePath) {
|
|
|
255647
255788
|
}
|
|
255648
255789
|
};
|
|
255649
255790
|
} catch (error) {
|
|
255650
|
-
|
|
255651
|
-
|
|
255791
|
+
logger2.error(`Failed to execute n8n node: ${error.message}`);
|
|
255792
|
+
logger2.error(error.stack);
|
|
255652
255793
|
throw error;
|
|
255653
255794
|
}
|
|
255654
255795
|
}
|
|
@@ -255686,7 +255827,7 @@ async function executeRoutingBasedNode(node, params, context) {
|
|
|
255686
255827
|
if (!routingConfig) {
|
|
255687
255828
|
throw new Error(`No routing configuration found for operation: ${operation}`);
|
|
255688
255829
|
}
|
|
255689
|
-
|
|
255830
|
+
logger2.log(`\u{1F4E1} Found routing config for operation: ${operation}`);
|
|
255690
255831
|
const requestDefaults = description.requestDefaults || {};
|
|
255691
255832
|
const requestConfig = routingConfig.request || {};
|
|
255692
255833
|
let url = requestConfig.url || "";
|
|
@@ -255750,8 +255891,8 @@ async function executeRoutingBasedNode(node, params, context) {
|
|
|
255750
255891
|
applyFallbackAuthentication(headers, creds);
|
|
255751
255892
|
}
|
|
255752
255893
|
}
|
|
255753
|
-
|
|
255754
|
-
|
|
255894
|
+
logger2.log(`\u{1F310} Making routing-based request: ${method} ${url}`);
|
|
255895
|
+
logger2.log(`\u{1F4E4} Request body:`, JSON.stringify(body));
|
|
255755
255896
|
const axiosConfig = {
|
|
255756
255897
|
method,
|
|
255757
255898
|
url,
|
|
@@ -255764,7 +255905,7 @@ async function executeRoutingBasedNode(node, params, context) {
|
|
|
255764
255905
|
}
|
|
255765
255906
|
try {
|
|
255766
255907
|
const response = await (0, import_axios.default)(axiosConfig);
|
|
255767
|
-
|
|
255908
|
+
logger2.log(`\u2705 Routing-based request successful: ${response.status}`);
|
|
255768
255909
|
if (requestConfig.encoding === "arraybuffer" || response.headers["content-type"]?.includes("audio")) {
|
|
255769
255910
|
const binaryData = Buffer.from(response.data);
|
|
255770
255911
|
const base64Data = binaryData.toString("base64");
|
|
@@ -255790,7 +255931,7 @@ async function executeRoutingBasedNode(node, params, context) {
|
|
|
255790
255931
|
if (error.response) {
|
|
255791
255932
|
const errorData = error.response.data;
|
|
255792
255933
|
const errorMessage = Buffer.isBuffer(errorData) ? errorData.toString("utf-8") : JSON.stringify(errorData);
|
|
255793
|
-
|
|
255934
|
+
logger2.error(`HTTP Error (${error.response.status}): ${errorMessage}`);
|
|
255794
255935
|
throw new Error(`HTTP Error (${error.response.status}): ${errorMessage}`);
|
|
255795
255936
|
}
|
|
255796
255937
|
throw error;
|
|
@@ -255847,7 +255988,7 @@ function resolveParamValue(value) {
|
|
|
255847
255988
|
var path5 = __toESM(__nccwpck_require__(16928));
|
|
255848
255989
|
var import_module2 = __nccwpck_require__(73339);
|
|
255849
255990
|
var import_shared = __nccwpck_require__(92279);
|
|
255850
|
-
var
|
|
255991
|
+
var logger3 = console;
|
|
255851
255992
|
async function executeActivepiecesModule(params) {
|
|
255852
255993
|
const moduleDefinition = {
|
|
255853
255994
|
framework: params.framework,
|
|
@@ -255890,18 +256031,18 @@ async function pieceFromModule(moduleDefinition) {
|
|
|
255890
256031
|
return piece;
|
|
255891
256032
|
} catch (error) {
|
|
255892
256033
|
process.chdir(originalCwd);
|
|
255893
|
-
|
|
256034
|
+
logger3.error(error.stack);
|
|
255894
256035
|
throw error;
|
|
255895
256036
|
}
|
|
255896
256037
|
}
|
|
255897
256038
|
async function executeGenericActivepiecesPiece(params, moduleDefinition) {
|
|
255898
256039
|
try {
|
|
255899
256040
|
const piece = await pieceFromModule(moduleDefinition);
|
|
255900
|
-
|
|
256041
|
+
logger3.log(`\u{1F680} Executing Activepieces piece: ${piece.displayName}`);
|
|
255901
256042
|
const actionName = params.params.operation;
|
|
255902
256043
|
const pieceActions = piece.actions();
|
|
255903
|
-
|
|
255904
|
-
|
|
256044
|
+
logger3.log(`Available actions: ${Object.keys(pieceActions).join(", ")}`);
|
|
256045
|
+
logger3.log(`Requested action: ${actionName}`);
|
|
255905
256046
|
const action = piece.actions()[actionName];
|
|
255906
256047
|
if (!action) {
|
|
255907
256048
|
throw new Error(`Action '${actionName}' not found in piece '${piece.displayName}'. Available actions: ${Object.keys(pieceActions).join(", ")}`);
|
|
@@ -255912,7 +256053,7 @@ async function executeGenericActivepiecesPiece(params, moduleDefinition) {
|
|
|
255912
256053
|
const credentialKeys = Object.keys(credentials);
|
|
255913
256054
|
if (credentialKeys.length > 0) {
|
|
255914
256055
|
auth = credentials[credentialKeys[0]];
|
|
255915
|
-
|
|
256056
|
+
logger3.log(`\u{1F510} Using credentials for: ${credentialKeys[0]}`);
|
|
255916
256057
|
}
|
|
255917
256058
|
}
|
|
255918
256059
|
const result = await action.run({
|
|
@@ -255921,7 +256062,7 @@ async function executeGenericActivepiecesPiece(params, moduleDefinition) {
|
|
|
255921
256062
|
...actionProps
|
|
255922
256063
|
}
|
|
255923
256064
|
});
|
|
255924
|
-
|
|
256065
|
+
logger3.log(`\u2705 Successfully executed Activepieces piece action: ${actionName}`, result);
|
|
255925
256066
|
return {
|
|
255926
256067
|
success: true,
|
|
255927
256068
|
module: moduleDefinition.repository,
|
|
@@ -255936,7 +256077,7 @@ async function executeGenericActivepiecesPiece(params, moduleDefinition) {
|
|
|
255936
256077
|
}
|
|
255937
256078
|
};
|
|
255938
256079
|
} catch (error) {
|
|
255939
|
-
|
|
256080
|
+
logger3.error(error.stack);
|
|
255940
256081
|
throw error;
|
|
255941
256082
|
}
|
|
255942
256083
|
}
|
|
@@ -255947,7 +256088,7 @@ var import_shared2 = __nccwpck_require__(92279);
|
|
|
255947
256088
|
var import_module3 = __nccwpck_require__(73339);
|
|
255948
256089
|
var import_shared3 = __nccwpck_require__(92279);
|
|
255949
256090
|
var path6 = __toESM(__nccwpck_require__(16928));
|
|
255950
|
-
var
|
|
256091
|
+
var logger4 = console;
|
|
255951
256092
|
function createSimpleStore(prefix = "") {
|
|
255952
256093
|
const storage = /* @__PURE__ */ new Map();
|
|
255953
256094
|
return {
|
|
@@ -255975,7 +256116,7 @@ var triggerHelper = {
|
|
|
255975
256116
|
if (!mainFilePath) {
|
|
255976
256117
|
throw new Error(`Could not locate main file for module: ${moduleName}`);
|
|
255977
256118
|
}
|
|
255978
|
-
|
|
256119
|
+
logger4.log(`\u{1F4E6} Loading piece from: ${mainFilePath}`);
|
|
255979
256120
|
const originalCwd = process.cwd();
|
|
255980
256121
|
const moduleDir = path6.dirname(mainFilePath);
|
|
255981
256122
|
try {
|
|
@@ -255999,7 +256140,7 @@ var triggerHelper = {
|
|
|
255999
256140
|
return piece;
|
|
256000
256141
|
} catch (error) {
|
|
256001
256142
|
process.chdir(originalCwd);
|
|
256002
|
-
|
|
256143
|
+
logger4.error(error.stack);
|
|
256003
256144
|
throw error;
|
|
256004
256145
|
}
|
|
256005
256146
|
},
|
|
@@ -256027,7 +256168,7 @@ var triggerHelper = {
|
|
|
256027
256168
|
throw new Error("Trigger name is not set");
|
|
256028
256169
|
}
|
|
256029
256170
|
const { piece, trigger } = await this.getTrigger(moduleDefinition, triggerName);
|
|
256030
|
-
|
|
256171
|
+
logger4.log(`\u{1F514} Executing trigger: ${triggerName} (${hookType})`);
|
|
256031
256172
|
const appListeners = [];
|
|
256032
256173
|
let scheduleOptions;
|
|
256033
256174
|
const storePrefix = isTest ? "test" : "";
|
|
@@ -256114,7 +256255,7 @@ var triggerHelper = {
|
|
|
256114
256255
|
};
|
|
256115
256256
|
}
|
|
256116
256257
|
} catch (error) {
|
|
256117
|
-
|
|
256258
|
+
logger4.error(`Error executing trigger ${triggerName}:`, error);
|
|
256118
256259
|
return {
|
|
256119
256260
|
success: false,
|
|
256120
256261
|
message: `Error executing trigger: ${(0, import_node_util.inspect)(error)}`,
|
|
@@ -256144,28 +256285,28 @@ var triggerHelper = {
|
|
|
256144
256285
|
const piece = await this.loadPieceFromModule(moduleDefinition);
|
|
256145
256286
|
const triggers = piece.triggers();
|
|
256146
256287
|
for (const [triggerName, trigger] of Object.entries(triggers)) {
|
|
256147
|
-
|
|
256288
|
+
logger4.log(`\u{1F514} Hooking trigger: ${triggerName} (type: ${trigger.type})`);
|
|
256148
256289
|
switch (trigger.type) {
|
|
256149
256290
|
case import_shared2.TriggerStrategy.POLLING:
|
|
256150
|
-
|
|
256291
|
+
logger4.log(` \u2192 Setting up polling trigger`);
|
|
256151
256292
|
if (options?.onPollingTrigger) {
|
|
256152
256293
|
options.onPollingTrigger(triggerName, trigger);
|
|
256153
256294
|
}
|
|
256154
256295
|
break;
|
|
256155
256296
|
case import_shared2.TriggerStrategy.WEBHOOK:
|
|
256156
|
-
|
|
256297
|
+
logger4.log(` \u2192 Setting up webhook trigger`);
|
|
256157
256298
|
if (options?.onWebhookTrigger) {
|
|
256158
256299
|
options.onWebhookTrigger(triggerName, trigger);
|
|
256159
256300
|
}
|
|
256160
256301
|
break;
|
|
256161
256302
|
case import_shared2.TriggerStrategy.APP_WEBHOOK:
|
|
256162
|
-
|
|
256303
|
+
logger4.log(` \u2192 Setting up app webhook trigger`);
|
|
256163
256304
|
if (options?.onAppWebhookTrigger) {
|
|
256164
256305
|
options.onAppWebhookTrigger(triggerName, trigger);
|
|
256165
256306
|
}
|
|
256166
256307
|
break;
|
|
256167
256308
|
default:
|
|
256168
|
-
|
|
256309
|
+
logger4.warn(` \u26A0\uFE0F Unknown trigger type: ${trigger.type}`);
|
|
256169
256310
|
}
|
|
256170
256311
|
}
|
|
256171
256312
|
},
|
|
@@ -256197,7 +256338,7 @@ var triggerHelper = {
|
|
|
256197
256338
|
* Execute a webhook trigger with received payload
|
|
256198
256339
|
*/
|
|
256199
256340
|
async executeWebhookTrigger(nodeId, payload, headers, query) {
|
|
256200
|
-
|
|
256341
|
+
logger4.log(`\u{1F514} Executing webhook trigger for node: ${nodeId}`);
|
|
256201
256342
|
return {
|
|
256202
256343
|
success: true,
|
|
256203
256344
|
output: [{
|
|
@@ -256219,7 +256360,7 @@ var vm = __toESM(__nccwpck_require__(69154));
|
|
|
256219
256360
|
var import_child_process3 = __nccwpck_require__(35317);
|
|
256220
256361
|
var os = __toESM(__nccwpck_require__(70857));
|
|
256221
256362
|
var ts = __toESM(__nccwpck_require__(35672));
|
|
256222
|
-
var
|
|
256363
|
+
var logger5 = console;
|
|
256223
256364
|
function convertDenoImports(code) {
|
|
256224
256365
|
const npmPackages = [];
|
|
256225
256366
|
const imports = [];
|
|
@@ -256393,7 +256534,7 @@ async function executeJavaScript(code, params, context) {
|
|
|
256393
256534
|
});
|
|
256394
256535
|
return result;
|
|
256395
256536
|
} catch (error) {
|
|
256396
|
-
|
|
256537
|
+
logger5.error(`JavaScript execution error: ${error.message}`);
|
|
256397
256538
|
throw error;
|
|
256398
256539
|
}
|
|
256399
256540
|
}
|
|
@@ -256648,9 +256789,9 @@ async function executeWindmillModule(paramsOrModuleName, maybeParams) {
|
|
|
256648
256789
|
executionParams = paramsOrModuleName.params;
|
|
256649
256790
|
inlineScript = paramsOrModuleName.script;
|
|
256650
256791
|
}
|
|
256651
|
-
|
|
256792
|
+
logger5.log(`
|
|
256652
256793
|
\u{1F300} Executing Windmill module: ${moduleName}`);
|
|
256653
|
-
|
|
256794
|
+
logger5.log(` Source: ${source}`);
|
|
256654
256795
|
let script = null;
|
|
256655
256796
|
if (source === "inline" && inlineScript) {
|
|
256656
256797
|
script = inlineScript;
|
|
@@ -256662,7 +256803,7 @@ async function executeWindmillModule(paramsOrModuleName, maybeParams) {
|
|
|
256662
256803
|
if (!script || !script.content) {
|
|
256663
256804
|
throw new Error(`Could not load Windmill script: ${moduleName}`);
|
|
256664
256805
|
}
|
|
256665
|
-
|
|
256806
|
+
logger5.log(` Language: ${script.language}`);
|
|
256666
256807
|
const context = {
|
|
256667
256808
|
flow_input: executionParams,
|
|
256668
256809
|
previous_result: executionParams.previous_result || null,
|
|
@@ -256688,7 +256829,7 @@ async function executeWindmillModule(paramsOrModuleName, maybeParams) {
|
|
|
256688
256829
|
default:
|
|
256689
256830
|
throw new Error(`Unsupported language: ${script.language}`);
|
|
256690
256831
|
}
|
|
256691
|
-
|
|
256832
|
+
logger5.log(`\u2705 Windmill script executed successfully`);
|
|
256692
256833
|
return {
|
|
256693
256834
|
success: true,
|
|
256694
256835
|
module: moduleName,
|
|
@@ -256702,7 +256843,7 @@ async function executeWindmillModule(paramsOrModuleName, maybeParams) {
|
|
|
256702
256843
|
}
|
|
256703
256844
|
};
|
|
256704
256845
|
} catch (error) {
|
|
256705
|
-
|
|
256846
|
+
logger5.error(`\u274C Windmill script failed: ${error.message}`);
|
|
256706
256847
|
return {
|
|
256707
256848
|
success: false,
|
|
256708
256849
|
module: moduleName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ha-bits/cortex",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Cortex - Habits Workflow Executor CLI",
|
|
5
5
|
"main": "./pack/index.cjs",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"pack",
|
|
12
12
|
"ui",
|
|
13
|
-
"package.json",
|
|
13
|
+
"package.json",
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
@@ -55,5 +55,4 @@
|
|
|
55
55
|
"esbuild": "^0.20.0",
|
|
56
56
|
"typescript": "^5.3.3"
|
|
57
57
|
}
|
|
58
|
-
|
|
59
58
|
}
|