@514labs/moose-lib 0.6.267-ci-5-gfe9b0c33 → 0.6.268
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.map +1 -1
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +27 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -90
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +43 -135
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +43 -135
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -975,15 +975,8 @@ var runApis = async (config) => {
|
|
|
975
975
|
const apisCluster = new Cluster({
|
|
976
976
|
maxWorkerCount: (config.workerCount ?? 0) > 0 ? config.workerCount : void 0,
|
|
977
977
|
workerStart: async () => {
|
|
978
|
-
const workerInfo = `[Worker ${process.pid}]`;
|
|
979
|
-
const startTime = Date.now();
|
|
980
|
-
console.log(`${workerInfo} workerStart: beginning initialization`);
|
|
981
978
|
let temporalClient;
|
|
982
979
|
if (config.temporalConfig) {
|
|
983
|
-
const temporalStart = Date.now();
|
|
984
|
-
console.log(
|
|
985
|
-
`${workerInfo} workerStart: initializing Temporal client...`
|
|
986
|
-
);
|
|
987
980
|
temporalClient = await getTemporalClient(
|
|
988
981
|
config.temporalConfig.url,
|
|
989
982
|
config.temporalConfig.namespace,
|
|
@@ -991,51 +984,29 @@ var runApis = async (config) => {
|
|
|
991
984
|
config.temporalConfig.clientKey,
|
|
992
985
|
config.temporalConfig.apiKey
|
|
993
986
|
);
|
|
994
|
-
console.log(
|
|
995
|
-
`${workerInfo} workerStart: Temporal client initialized in ${Date.now() - temporalStart}ms`
|
|
996
|
-
);
|
|
997
987
|
}
|
|
998
|
-
const clickhouseStart = Date.now();
|
|
999
|
-
console.log(
|
|
1000
|
-
`${workerInfo} workerStart: initializing ClickHouse client...`
|
|
1001
|
-
);
|
|
1002
988
|
const clickhouseClient = getClickhouseClient(
|
|
1003
989
|
toClientConfig(config.clickhouseConfig)
|
|
1004
990
|
);
|
|
1005
|
-
console.log(
|
|
1006
|
-
`${workerInfo} workerStart: ClickHouse client initialized in ${Date.now() - clickhouseStart}ms`
|
|
1007
|
-
);
|
|
1008
991
|
let publicKey;
|
|
1009
992
|
if (config.jwtConfig?.secret) {
|
|
1010
|
-
|
|
1011
|
-
console.log(`${workerInfo} workerStart: importing JWT public key...`);
|
|
993
|
+
console.log("Importing JWT public key...");
|
|
1012
994
|
publicKey = await jose.importSPKI(config.jwtConfig.secret, "RS256");
|
|
1013
|
-
console.log(
|
|
1014
|
-
`${workerInfo} workerStart: JWT key imported in ${Date.now() - jwtStart}ms`
|
|
1015
|
-
);
|
|
1016
995
|
}
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
);
|
|
1028
|
-
console.log(
|
|
1029
|
-
`${workerInfo} workerStart: main router created in ${Date.now() - routerStart}ms`
|
|
996
|
+
const server = import_http2.default.createServer(
|
|
997
|
+
await createMainRouter(
|
|
998
|
+
publicKey,
|
|
999
|
+
clickhouseClient,
|
|
1000
|
+
temporalClient,
|
|
1001
|
+
config.apisDir,
|
|
1002
|
+
config.enforceAuth,
|
|
1003
|
+
config.isDmv2,
|
|
1004
|
+
config.jwtConfig
|
|
1005
|
+
)
|
|
1030
1006
|
);
|
|
1031
|
-
const serverStart = Date.now();
|
|
1032
|
-
console.log(`${workerInfo} workerStart: creating HTTP server...`);
|
|
1033
|
-
const server = import_http2.default.createServer(router);
|
|
1034
1007
|
const port = config.proxyPort !== void 0 ? config.proxyPort : 4001;
|
|
1035
1008
|
server.listen(port, "localhost", () => {
|
|
1036
|
-
console.log(
|
|
1037
|
-
`${workerInfo} Server running on port ${port} (total startup: ${Date.now() - startTime}ms)`
|
|
1038
|
-
);
|
|
1009
|
+
console.log(`Server running on port ${port}`);
|
|
1039
1010
|
});
|
|
1040
1011
|
return server;
|
|
1041
1012
|
},
|
|
@@ -1656,106 +1627,43 @@ if (getMooseInternal() === void 0) {
|
|
|
1656
1627
|
globalThis.moose_internal = moose_internal;
|
|
1657
1628
|
}
|
|
1658
1629
|
var dumpMooseInternal = async () => {
|
|
1659
|
-
|
|
1630
|
+
loadIndex();
|
|
1660
1631
|
console.log(
|
|
1661
1632
|
"___MOOSE_STUFF___start",
|
|
1662
1633
|
JSON.stringify(toInfraMap(getMooseInternal())),
|
|
1663
1634
|
"end___MOOSE_STUFF___"
|
|
1664
1635
|
);
|
|
1665
1636
|
};
|
|
1666
|
-
var
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
);
|
|
1680
|
-
return indexLoadPromise;
|
|
1681
|
-
}
|
|
1682
|
-
console.log(`${workerInfo} loadIndex: starting load process`);
|
|
1683
|
-
const startTime = Date.now();
|
|
1684
|
-
const delay = Math.random() * 500;
|
|
1685
|
-
console.log(
|
|
1686
|
-
`${workerInfo} loadIndex: waiting ${delay.toFixed(0)}ms to stagger load`
|
|
1687
|
-
);
|
|
1688
|
-
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
1689
|
-
if (indexLoadState === "loading" && indexLoadPromise) {
|
|
1690
|
-
console.log(
|
|
1691
|
-
`${workerInfo} loadIndex: another worker started loading during delay, waiting`
|
|
1692
|
-
);
|
|
1693
|
-
return indexLoadPromise;
|
|
1694
|
-
}
|
|
1695
|
-
if (indexLoadState === "loaded") {
|
|
1696
|
-
console.log(
|
|
1697
|
-
`${workerInfo} loadIndex: loaded by another worker during delay`
|
|
1698
|
-
);
|
|
1699
|
-
return;
|
|
1700
|
-
}
|
|
1701
|
-
indexLoadState = "loading";
|
|
1702
|
-
indexLoadPromise = (async () => {
|
|
1703
|
-
try {
|
|
1704
|
-
console.log(`${workerInfo} loadIndex: clearing registry...`);
|
|
1705
|
-
const clearStart = Date.now();
|
|
1706
|
-
const registry = getMooseInternal();
|
|
1707
|
-
registry.tables.clear();
|
|
1708
|
-
registry.streams.clear();
|
|
1709
|
-
registry.ingestApis.clear();
|
|
1710
|
-
registry.apis.clear();
|
|
1711
|
-
registry.sqlResources.clear();
|
|
1712
|
-
registry.workflows.clear();
|
|
1713
|
-
registry.webApps.clear();
|
|
1714
|
-
console.log(
|
|
1715
|
-
`${workerInfo} loadIndex: registry cleared in ${Date.now() - clearStart}ms`
|
|
1716
|
-
);
|
|
1717
|
-
console.log(`${workerInfo} loadIndex: clearing require cache...`);
|
|
1718
|
-
const cacheStart = Date.now();
|
|
1719
|
-
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
1720
|
-
Object.keys(require.cache).forEach((key) => {
|
|
1721
|
-
if (key.startsWith(appDir)) {
|
|
1722
|
-
delete require.cache[key];
|
|
1723
|
-
}
|
|
1724
|
-
});
|
|
1725
|
-
console.log(
|
|
1726
|
-
`${workerInfo} loadIndex: require cache cleared in ${Date.now() - cacheStart}ms`
|
|
1727
|
-
);
|
|
1728
|
-
console.log(`${workerInfo} loadIndex: requiring index.ts...`);
|
|
1729
|
-
const requireStart = Date.now();
|
|
1730
|
-
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1731
|
-
console.log(
|
|
1732
|
-
`${workerInfo} loadIndex: require completed in ${Date.now() - requireStart}ms`
|
|
1733
|
-
);
|
|
1734
|
-
indexLoadState = "loaded";
|
|
1735
|
-
console.log(
|
|
1736
|
-
`${workerInfo} loadIndex: total load time ${Date.now() - startTime}ms`
|
|
1737
|
-
);
|
|
1738
|
-
} catch (error) {
|
|
1739
|
-
console.error(
|
|
1740
|
-
`${workerInfo} loadIndex: FAILED after ${Date.now() - startTime}ms`,
|
|
1741
|
-
error
|
|
1742
|
-
);
|
|
1743
|
-
indexLoadState = "unloaded";
|
|
1744
|
-
indexLoadPromise = null;
|
|
1745
|
-
let hint;
|
|
1746
|
-
const details = error instanceof Error ? error.message : String(error);
|
|
1747
|
-
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1748
|
-
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";
|
|
1749
|
-
}
|
|
1750
|
-
const errorMsg = `${hint ?? ""}${details}`;
|
|
1751
|
-
const cause = error instanceof Error ? error : void 0;
|
|
1752
|
-
throw new Error(errorMsg, { cause });
|
|
1637
|
+
var loadIndex = () => {
|
|
1638
|
+
const registry = getMooseInternal();
|
|
1639
|
+
registry.tables.clear();
|
|
1640
|
+
registry.streams.clear();
|
|
1641
|
+
registry.ingestApis.clear();
|
|
1642
|
+
registry.apis.clear();
|
|
1643
|
+
registry.sqlResources.clear();
|
|
1644
|
+
registry.workflows.clear();
|
|
1645
|
+
registry.webApps.clear();
|
|
1646
|
+
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
1647
|
+
Object.keys(require.cache).forEach((key) => {
|
|
1648
|
+
if (key.startsWith(appDir)) {
|
|
1649
|
+
delete require.cache[key];
|
|
1753
1650
|
}
|
|
1754
|
-
})
|
|
1755
|
-
|
|
1651
|
+
});
|
|
1652
|
+
try {
|
|
1653
|
+
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1654
|
+
} catch (error) {
|
|
1655
|
+
let hint;
|
|
1656
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
1657
|
+
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1658
|
+
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";
|
|
1659
|
+
}
|
|
1660
|
+
const errorMsg = `${hint ?? ""}${details}`;
|
|
1661
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1662
|
+
throw new Error(errorMsg, { cause });
|
|
1663
|
+
}
|
|
1756
1664
|
};
|
|
1757
1665
|
var getStreamingFunctions = async () => {
|
|
1758
|
-
|
|
1666
|
+
loadIndex();
|
|
1759
1667
|
const registry = getMooseInternal();
|
|
1760
1668
|
const transformFunctions = /* @__PURE__ */ new Map();
|
|
1761
1669
|
registry.streams.forEach((stream) => {
|
|
@@ -1782,7 +1690,7 @@ var getStreamingFunctions = async () => {
|
|
|
1782
1690
|
return transformFunctions;
|
|
1783
1691
|
};
|
|
1784
1692
|
var getApis2 = async () => {
|
|
1785
|
-
|
|
1693
|
+
loadIndex();
|
|
1786
1694
|
const apiFunctions = /* @__PURE__ */ new Map();
|
|
1787
1695
|
const registry = getMooseInternal();
|
|
1788
1696
|
const versionCountByName = /* @__PURE__ */ new Map();
|
|
@@ -1814,7 +1722,7 @@ var getApis2 = async () => {
|
|
|
1814
1722
|
return apiFunctions;
|
|
1815
1723
|
};
|
|
1816
1724
|
var getWorkflows2 = async () => {
|
|
1817
|
-
|
|
1725
|
+
loadIndex();
|
|
1818
1726
|
const registry = getMooseInternal();
|
|
1819
1727
|
return registry.workflows;
|
|
1820
1728
|
};
|
|
@@ -1848,7 +1756,7 @@ var getTaskForWorkflow = async (workflowName, taskName) => {
|
|
|
1848
1756
|
return task;
|
|
1849
1757
|
};
|
|
1850
1758
|
var getWebApps2 = async () => {
|
|
1851
|
-
|
|
1759
|
+
loadIndex();
|
|
1852
1760
|
return getMooseInternal().webApps;
|
|
1853
1761
|
};
|
|
1854
1762
|
|