@514labs/moose-lib 0.6.267-ci-2-g72faeb73 → 0.6.267-ci-2-g580f80e4
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/dist/browserCompatible.js +0 -1
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +0 -1
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.js +0 -1
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +0 -1
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +42 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -28
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +52 -88
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +52 -88
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -501,7 +501,6 @@ async function getTemporalClient(temporalUrl, namespace, clientCert, clientKey,
|
|
|
501
501
|
|
|
502
502
|
// src/consumption-apis/runner.ts
|
|
503
503
|
var import_http2 = __toESM(require("http"));
|
|
504
|
-
var import_node_cluster2 = __toESM(require("cluster"));
|
|
505
504
|
init_commons();
|
|
506
505
|
var jose = __toESM(require("jose"));
|
|
507
506
|
|
|
@@ -723,13 +722,7 @@ var httpLogger = (req, res, startMs) => {
|
|
|
723
722
|
};
|
|
724
723
|
var modulesCache = /* @__PURE__ */ new Map();
|
|
725
724
|
var apiHandler = async (publicKey, clickhouseClient, temporalClient, apisDir, enforceAuth, isDmv2, jwtConfig) => {
|
|
726
|
-
console.log(
|
|
727
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} apiHandler: about to call getApis (isDmv2=${isDmv2})`
|
|
728
|
-
);
|
|
729
725
|
const apis = isDmv2 ? await getApis2() : /* @__PURE__ */ new Map();
|
|
730
|
-
console.log(
|
|
731
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} apiHandler: getApis completed, returning handler`
|
|
732
|
-
);
|
|
733
726
|
return async (req, res) => {
|
|
734
727
|
const start = Date.now();
|
|
735
728
|
try {
|
|
@@ -874,9 +867,6 @@ var apiHandler = async (publicKey, clickhouseClient, temporalClient, apisDir, en
|
|
|
874
867
|
};
|
|
875
868
|
};
|
|
876
869
|
var createMainRouter = async (publicKey, clickhouseClient, temporalClient, apisDir, enforceAuth, isDmv2, jwtConfig) => {
|
|
877
|
-
console.log(
|
|
878
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} createMainRouter: about to call apiHandler`
|
|
879
|
-
);
|
|
880
870
|
const apiRequestHandler = await apiHandler(
|
|
881
871
|
publicKey,
|
|
882
872
|
clickhouseClient,
|
|
@@ -886,16 +876,7 @@ var createMainRouter = async (publicKey, clickhouseClient, temporalClient, apisD
|
|
|
886
876
|
isDmv2,
|
|
887
877
|
jwtConfig
|
|
888
878
|
);
|
|
889
|
-
console.log(
|
|
890
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} createMainRouter: apiHandler completed`
|
|
891
|
-
);
|
|
892
|
-
console.log(
|
|
893
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} createMainRouter: about to call getWebApps (isDmv2=${isDmv2})`
|
|
894
|
-
);
|
|
895
879
|
const webApps = isDmv2 ? await getWebApps2() : /* @__PURE__ */ new Map();
|
|
896
|
-
console.log(
|
|
897
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} createMainRouter: getWebApps completed, returning router`
|
|
898
|
-
);
|
|
899
880
|
const sortedWebApps = Array.from(webApps.values()).sort((a, b) => {
|
|
900
881
|
const pathA = a.config.mountPath || "/";
|
|
901
882
|
const pathB = b.config.mountPath || "/";
|
|
@@ -1012,10 +993,6 @@ var runApis = async (config) => {
|
|
|
1012
993
|
console.log("Importing JWT public key...");
|
|
1013
994
|
publicKey = await jose.importSPKI(config.jwtConfig.secret, "RS256");
|
|
1014
995
|
}
|
|
1015
|
-
const port = config.proxyPort !== void 0 ? config.proxyPort : 4001;
|
|
1016
|
-
console.log(
|
|
1017
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} about to create server on port ${port}`
|
|
1018
|
-
);
|
|
1019
996
|
const server = import_http2.default.createServer(
|
|
1020
997
|
await createMainRouter(
|
|
1021
998
|
publicKey,
|
|
@@ -1027,39 +1004,11 @@ var runApis = async (config) => {
|
|
|
1027
1004
|
config.jwtConfig
|
|
1028
1005
|
)
|
|
1029
1006
|
);
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
return new Promise((resolve2, reject) => {
|
|
1034
|
-
server.on("error", (err) => {
|
|
1035
|
-
console.error(
|
|
1036
|
-
`[ERROR] Worker ${import_node_cluster2.default.worker?.id} server error on port ${port}:`,
|
|
1037
|
-
err
|
|
1038
|
-
);
|
|
1039
|
-
if (err.code === "EADDRINUSE") {
|
|
1040
|
-
console.error(`[ERROR] Port ${port} is already in use`);
|
|
1041
|
-
}
|
|
1042
|
-
reject(err);
|
|
1043
|
-
});
|
|
1044
|
-
server.listen(port, "localhost", () => {
|
|
1045
|
-
console.log(
|
|
1046
|
-
`[SUCCESS] Worker ${import_node_cluster2.default.worker?.id} server running on port ${port}`
|
|
1047
|
-
);
|
|
1048
|
-
resolve2(server);
|
|
1049
|
-
});
|
|
1050
|
-
const timeout = setTimeout(() => {
|
|
1051
|
-
console.error(
|
|
1052
|
-
`[ERROR] Worker ${import_node_cluster2.default.worker?.id} listen timeout after 10s on port ${port}`
|
|
1053
|
-
);
|
|
1054
|
-
reject(new Error(`Listen timeout on port ${port}`));
|
|
1055
|
-
}, 1e4);
|
|
1056
|
-
server.once("listening", () => {
|
|
1057
|
-
clearTimeout(timeout);
|
|
1058
|
-
console.log(
|
|
1059
|
-
`[DEBUG] Worker ${import_node_cluster2.default.worker?.id} 'listening' event fired for port ${port}`
|
|
1060
|
-
);
|
|
1061
|
-
});
|
|
1007
|
+
const port = config.proxyPort !== void 0 ? config.proxyPort : 4001;
|
|
1008
|
+
server.listen(port, "localhost", () => {
|
|
1009
|
+
console.log(`Server running on port ${port}`);
|
|
1062
1010
|
});
|
|
1011
|
+
return server;
|
|
1063
1012
|
},
|
|
1064
1013
|
workerStop: async (server) => {
|
|
1065
1014
|
return new Promise((resolve2) => {
|
|
@@ -1678,43 +1627,58 @@ if (getMooseInternal() === void 0) {
|
|
|
1678
1627
|
globalThis.moose_internal = moose_internal;
|
|
1679
1628
|
}
|
|
1680
1629
|
var dumpMooseInternal = async () => {
|
|
1681
|
-
loadIndex();
|
|
1630
|
+
await loadIndex();
|
|
1682
1631
|
console.log(
|
|
1683
1632
|
"___MOOSE_STUFF___start",
|
|
1684
1633
|
JSON.stringify(toInfraMap(getMooseInternal())),
|
|
1685
1634
|
"end___MOOSE_STUFF___"
|
|
1686
1635
|
);
|
|
1687
1636
|
};
|
|
1688
|
-
var
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
registry.apis.clear();
|
|
1694
|
-
registry.sqlResources.clear();
|
|
1695
|
-
registry.workflows.clear();
|
|
1696
|
-
registry.webApps.clear();
|
|
1697
|
-
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
1698
|
-
Object.keys(require.cache).forEach((key) => {
|
|
1699
|
-
if (key.startsWith(appDir)) {
|
|
1700
|
-
delete require.cache[key];
|
|
1701
|
-
}
|
|
1702
|
-
});
|
|
1703
|
-
try {
|
|
1704
|
-
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1705
|
-
} catch (error) {
|
|
1706
|
-
let hint;
|
|
1707
|
-
const details = error instanceof Error ? error.message : String(error);
|
|
1708
|
-
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1709
|
-
hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
|
|
1710
|
-
}
|
|
1711
|
-
const errorMsg = `${hint ?? ""}${details}`;
|
|
1712
|
-
const cause = error instanceof Error ? error : void 0;
|
|
1713
|
-
throw new Error(errorMsg, { cause });
|
|
1637
|
+
var indexLoadState = "unloaded";
|
|
1638
|
+
var indexLoadPromise = null;
|
|
1639
|
+
var loadIndex = async () => {
|
|
1640
|
+
if (indexLoadState === "loaded") {
|
|
1641
|
+
return;
|
|
1714
1642
|
}
|
|
1643
|
+
if (indexLoadState === "loading" && indexLoadPromise) {
|
|
1644
|
+
return indexLoadPromise;
|
|
1645
|
+
}
|
|
1646
|
+
indexLoadState = "loading";
|
|
1647
|
+
indexLoadPromise = (async () => {
|
|
1648
|
+
try {
|
|
1649
|
+
const registry = getMooseInternal();
|
|
1650
|
+
registry.tables.clear();
|
|
1651
|
+
registry.streams.clear();
|
|
1652
|
+
registry.ingestApis.clear();
|
|
1653
|
+
registry.apis.clear();
|
|
1654
|
+
registry.sqlResources.clear();
|
|
1655
|
+
registry.workflows.clear();
|
|
1656
|
+
registry.webApps.clear();
|
|
1657
|
+
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
1658
|
+
Object.keys(require.cache).forEach((key) => {
|
|
1659
|
+
if (key.startsWith(appDir)) {
|
|
1660
|
+
delete require.cache[key];
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1664
|
+
indexLoadState = "loaded";
|
|
1665
|
+
} catch (error) {
|
|
1666
|
+
indexLoadState = "unloaded";
|
|
1667
|
+
indexLoadPromise = null;
|
|
1668
|
+
let hint;
|
|
1669
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
1670
|
+
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1671
|
+
hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
|
|
1672
|
+
}
|
|
1673
|
+
const errorMsg = `${hint ?? ""}${details}`;
|
|
1674
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1675
|
+
throw new Error(errorMsg, { cause });
|
|
1676
|
+
}
|
|
1677
|
+
})();
|
|
1678
|
+
return indexLoadPromise;
|
|
1715
1679
|
};
|
|
1716
1680
|
var getStreamingFunctions = async () => {
|
|
1717
|
-
loadIndex();
|
|
1681
|
+
await loadIndex();
|
|
1718
1682
|
const registry = getMooseInternal();
|
|
1719
1683
|
const transformFunctions = /* @__PURE__ */ new Map();
|
|
1720
1684
|
registry.streams.forEach((stream) => {
|
|
@@ -1741,7 +1705,7 @@ var getStreamingFunctions = async () => {
|
|
|
1741
1705
|
return transformFunctions;
|
|
1742
1706
|
};
|
|
1743
1707
|
var getApis2 = async () => {
|
|
1744
|
-
loadIndex();
|
|
1708
|
+
await loadIndex();
|
|
1745
1709
|
const apiFunctions = /* @__PURE__ */ new Map();
|
|
1746
1710
|
const registry = getMooseInternal();
|
|
1747
1711
|
const versionCountByName = /* @__PURE__ */ new Map();
|
|
@@ -1773,7 +1737,7 @@ var getApis2 = async () => {
|
|
|
1773
1737
|
return apiFunctions;
|
|
1774
1738
|
};
|
|
1775
1739
|
var getWorkflows2 = async () => {
|
|
1776
|
-
loadIndex();
|
|
1740
|
+
await loadIndex();
|
|
1777
1741
|
const registry = getMooseInternal();
|
|
1778
1742
|
return registry.workflows;
|
|
1779
1743
|
};
|
|
@@ -1807,7 +1771,7 @@ var getTaskForWorkflow = async (workflowName, taskName) => {
|
|
|
1807
1771
|
return task;
|
|
1808
1772
|
};
|
|
1809
1773
|
var getWebApps2 = async () => {
|
|
1810
|
-
loadIndex();
|
|
1774
|
+
await loadIndex();
|
|
1811
1775
|
return getMooseInternal().webApps;
|
|
1812
1776
|
};
|
|
1813
1777
|
|
|
@@ -2374,7 +2338,7 @@ var runStreamingFunctions = async (args) => {
|
|
|
2374
2338
|
validateTopicConfig(args.targetTopic);
|
|
2375
2339
|
}
|
|
2376
2340
|
const streamingFuncId = `flow-${args.sourceTopic.name}-${args.targetTopic?.name || ""}`;
|
|
2377
|
-
const
|
|
2341
|
+
const cluster2 = new Cluster({
|
|
2378
2342
|
maxCpuUsageRatio: 0.5,
|
|
2379
2343
|
maxWorkerCount: args.maxSubscriberCount,
|
|
2380
2344
|
workerStart: async (worker, parallelism) => {
|
|
@@ -2457,7 +2421,7 @@ var runStreamingFunctions = async (args) => {
|
|
|
2457
2421
|
logger2.log("Graceful shutdown completed");
|
|
2458
2422
|
}
|
|
2459
2423
|
});
|
|
2460
|
-
|
|
2424
|
+
cluster2.start();
|
|
2461
2425
|
};
|
|
2462
2426
|
|
|
2463
2427
|
// src/moduleExportSerializer.ts
|