@514labs/moose-lib 0.6.302 → 0.6.303
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.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +68 -27
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +73 -32
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -892,16 +892,16 @@ var init_cluster_utils = __esm({
|
|
|
892
892
|
* @returns A promise that resolves when all workers have terminated
|
|
893
893
|
*/
|
|
894
894
|
shutdownWorkers = (signal) => {
|
|
895
|
-
return new Promise((
|
|
895
|
+
return new Promise((resolve3, reject) => {
|
|
896
896
|
if (!import_node_cluster.default.isPrimary) {
|
|
897
|
-
return
|
|
897
|
+
return resolve3();
|
|
898
898
|
}
|
|
899
899
|
if (!import_node_cluster.default.workers) {
|
|
900
|
-
return
|
|
900
|
+
return resolve3();
|
|
901
901
|
}
|
|
902
902
|
const workerIds = Object.keys(import_node_cluster.default.workers);
|
|
903
903
|
if (workerIds.length == 0) {
|
|
904
|
-
return
|
|
904
|
+
return resolve3();
|
|
905
905
|
}
|
|
906
906
|
let workersAlive = 0;
|
|
907
907
|
let funcRun = 0;
|
|
@@ -919,7 +919,7 @@ var init_cluster_utils = __esm({
|
|
|
919
919
|
console.info(workersAlive + " workers alive");
|
|
920
920
|
if (workersAlive == 0) {
|
|
921
921
|
clearInterval(interval);
|
|
922
|
-
return
|
|
922
|
+
return resolve3();
|
|
923
923
|
}
|
|
924
924
|
};
|
|
925
925
|
const interval = setInterval(cleanWorkers, SHUTDOWN_WORKERS_INTERVAL);
|
|
@@ -931,11 +931,11 @@ var init_cluster_utils = __esm({
|
|
|
931
931
|
|
|
932
932
|
// src/config/configFile.ts
|
|
933
933
|
async function findConfigFile(startDir = process.cwd()) {
|
|
934
|
-
const
|
|
934
|
+
const fs5 = await import("fs");
|
|
935
935
|
let currentDir = import_node_path.default.resolve(startDir);
|
|
936
936
|
while (true) {
|
|
937
937
|
const configPath = import_node_path.default.join(currentDir, "moose.config.toml");
|
|
938
|
-
if (
|
|
938
|
+
if (fs5.existsSync(configPath)) {
|
|
939
939
|
return configPath;
|
|
940
940
|
}
|
|
941
941
|
const parentDir = import_node_path.default.dirname(currentDir);
|
|
@@ -947,7 +947,7 @@ async function findConfigFile(startDir = process.cwd()) {
|
|
|
947
947
|
return null;
|
|
948
948
|
}
|
|
949
949
|
async function readProjectConfig() {
|
|
950
|
-
const
|
|
950
|
+
const fs5 = await import("fs");
|
|
951
951
|
const configPath = await findConfigFile();
|
|
952
952
|
if (!configPath) {
|
|
953
953
|
throw new ConfigError(
|
|
@@ -955,7 +955,7 @@ async function readProjectConfig() {
|
|
|
955
955
|
);
|
|
956
956
|
}
|
|
957
957
|
try {
|
|
958
|
-
const configContent =
|
|
958
|
+
const configContent = fs5.readFileSync(configPath, "utf-8");
|
|
959
959
|
const config = toml.parse(configContent);
|
|
960
960
|
return config;
|
|
961
961
|
} catch (error) {
|
|
@@ -1221,7 +1221,7 @@ var init_runner = __esm({
|
|
|
1221
1221
|
...config,
|
|
1222
1222
|
useSSL: config.useSSL ? "true" : "false"
|
|
1223
1223
|
});
|
|
1224
|
-
createPath = (apisDir,
|
|
1224
|
+
createPath = (apisDir, path5) => `${apisDir}${path5}.ts`;
|
|
1225
1225
|
httpLogger = (req, res, startMs) => {
|
|
1226
1226
|
console.log(
|
|
1227
1227
|
`${req.method} ${req.url} ${res.statusCode} ${Date.now() - startMs}ms`
|
|
@@ -1518,8 +1518,8 @@ var init_runner = __esm({
|
|
|
1518
1518
|
return server;
|
|
1519
1519
|
},
|
|
1520
1520
|
workerStop: async (server) => {
|
|
1521
|
-
return new Promise((
|
|
1522
|
-
server.close(() =>
|
|
1521
|
+
return new Promise((resolve3) => {
|
|
1522
|
+
server.close(() => resolve3());
|
|
1523
1523
|
});
|
|
1524
1524
|
}
|
|
1525
1525
|
});
|
|
@@ -1727,6 +1727,40 @@ var init_index = __esm({
|
|
|
1727
1727
|
function getSourceDir() {
|
|
1728
1728
|
return import_process.default.env.MOOSE_SOURCE_DIR || "app";
|
|
1729
1729
|
}
|
|
1730
|
+
function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
|
|
1731
|
+
const files = [];
|
|
1732
|
+
try {
|
|
1733
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
1734
|
+
for (const entry of entries) {
|
|
1735
|
+
const fullPath = path2.join(dir, entry.name);
|
|
1736
|
+
if (entry.isDirectory()) {
|
|
1737
|
+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
1738
|
+
files.push(...findSourceFiles(fullPath, extensions));
|
|
1739
|
+
}
|
|
1740
|
+
} else if (entry.isFile()) {
|
|
1741
|
+
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".d.mts") || entry.name.endsWith(".d.cts")) {
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
const ext = path2.extname(entry.name);
|
|
1745
|
+
if (extensions.includes(ext)) {
|
|
1746
|
+
files.push(fullPath);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
} catch (error) {
|
|
1751
|
+
compilerLog(`Warning: Could not read directory ${dir}: ${error}`);
|
|
1752
|
+
}
|
|
1753
|
+
return files;
|
|
1754
|
+
}
|
|
1755
|
+
function findUnloadedFiles() {
|
|
1756
|
+
const appDir = path2.resolve(import_process.default.cwd(), getSourceDir());
|
|
1757
|
+
const allSourceFiles = findSourceFiles(appDir);
|
|
1758
|
+
const loadedFiles = new Set(
|
|
1759
|
+
Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) => path2.resolve(key))
|
|
1760
|
+
);
|
|
1761
|
+
const unloadedFiles = allSourceFiles.map((file) => path2.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path2.relative(import_process.default.cwd(), file));
|
|
1762
|
+
return unloadedFiles;
|
|
1763
|
+
}
|
|
1730
1764
|
function isS3QueueConfig(config) {
|
|
1731
1765
|
return "engine" in config && config.engine === "S3Queue" /* S3Queue */;
|
|
1732
1766
|
}
|
|
@@ -1977,11 +2011,13 @@ function findTaskInTree(task, targetName) {
|
|
|
1977
2011
|
}
|
|
1978
2012
|
return void 0;
|
|
1979
2013
|
}
|
|
1980
|
-
var import_process, moose_internal, defaultRetentionPeriod, toInfraMap, getMooseInternal, dumpMooseInternal, loadIndex, getStreamingFunctions, getApis2, getWorkflows2, getTaskForWorkflow, getWebApps2;
|
|
2014
|
+
var import_process, fs2, path2, moose_internal, defaultRetentionPeriod, toInfraMap, getMooseInternal, dumpMooseInternal, loadIndex, getStreamingFunctions, getApis2, getWorkflows2, getTaskForWorkflow, getWebApps2;
|
|
1981
2015
|
var init_internal = __esm({
|
|
1982
2016
|
"src/dmv2/internal.ts"() {
|
|
1983
2017
|
"use strict";
|
|
1984
2018
|
import_process = __toESM(require("process"));
|
|
2019
|
+
fs2 = __toESM(require("fs"));
|
|
2020
|
+
path2 = __toESM(require("path"));
|
|
1985
2021
|
init_index();
|
|
1986
2022
|
init_commons();
|
|
1987
2023
|
moose_internal = {
|
|
@@ -2247,7 +2283,9 @@ var init_internal = __esm({
|
|
|
2247
2283
|
workflows,
|
|
2248
2284
|
webApps,
|
|
2249
2285
|
materializedViews,
|
|
2250
|
-
views
|
|
2286
|
+
views,
|
|
2287
|
+
unloadedFiles: []
|
|
2288
|
+
// Will be populated by dumpMooseInternal
|
|
2251
2289
|
};
|
|
2252
2290
|
};
|
|
2253
2291
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2256,9 +2294,12 @@ var init_internal = __esm({
|
|
|
2256
2294
|
}
|
|
2257
2295
|
dumpMooseInternal = async () => {
|
|
2258
2296
|
loadIndex();
|
|
2297
|
+
const infraMap = toInfraMap(getMooseInternal());
|
|
2298
|
+
const unloadedFiles = findUnloadedFiles();
|
|
2299
|
+
infraMap.unloadedFiles = unloadedFiles;
|
|
2259
2300
|
console.log(
|
|
2260
2301
|
"___MOOSE_STUFF___start",
|
|
2261
|
-
JSON.stringify(
|
|
2302
|
+
JSON.stringify(infraMap),
|
|
2262
2303
|
"end___MOOSE_STUFF___"
|
|
2263
2304
|
);
|
|
2264
2305
|
};
|
|
@@ -2477,10 +2518,10 @@ var runBlocks = async (config) => {
|
|
|
2477
2518
|
}
|
|
2478
2519
|
}
|
|
2479
2520
|
});
|
|
2480
|
-
for (const
|
|
2481
|
-
console.log(`Adding to queue: ${
|
|
2521
|
+
for (const path5 of blocksFiles) {
|
|
2522
|
+
console.log(`Adding to queue: ${path5}`);
|
|
2482
2523
|
try {
|
|
2483
|
-
const blocks = require(
|
|
2524
|
+
const blocks = require(path5).default;
|
|
2484
2525
|
queue.push({
|
|
2485
2526
|
chClient,
|
|
2486
2527
|
blocks,
|
|
@@ -2489,13 +2530,13 @@ var runBlocks = async (config) => {
|
|
|
2489
2530
|
} catch (err) {
|
|
2490
2531
|
cliLog({
|
|
2491
2532
|
action: "Blocks",
|
|
2492
|
-
message: `Failed to import blocks from ${
|
|
2533
|
+
message: `Failed to import blocks from ${path5}: ${err}`,
|
|
2493
2534
|
message_type: "Error"
|
|
2494
2535
|
});
|
|
2495
2536
|
}
|
|
2496
2537
|
}
|
|
2497
2538
|
while (!queue.idle()) {
|
|
2498
|
-
await new Promise((
|
|
2539
|
+
await new Promise((resolve3) => setTimeout(resolve3, 1e3));
|
|
2499
2540
|
}
|
|
2500
2541
|
};
|
|
2501
2542
|
|
|
@@ -3036,7 +3077,7 @@ var runStreamingFunctions = async (args) => {
|
|
|
3036
3077
|
logger2.log("Stopping consumer first...");
|
|
3037
3078
|
await stopConsumer(logger2, consumer, args.sourceTopic);
|
|
3038
3079
|
logger2.log("Waiting for in-flight messages to complete...");
|
|
3039
|
-
await new Promise((
|
|
3080
|
+
await new Promise((resolve3) => setTimeout(resolve3, 2e3));
|
|
3040
3081
|
logger2.log("Stopping producer...");
|
|
3041
3082
|
await stopProducer(logger2, producer);
|
|
3042
3083
|
logger2.log("Graceful shutdown completed");
|
|
@@ -3070,8 +3111,8 @@ async function runApiTypeSerializer(targetModel) {
|
|
|
3070
3111
|
|
|
3071
3112
|
// src/scripts/runner.ts
|
|
3072
3113
|
var import_worker2 = require("@temporalio/worker");
|
|
3073
|
-
var
|
|
3074
|
-
var
|
|
3114
|
+
var path4 = __toESM(require("path"));
|
|
3115
|
+
var fs4 = __toESM(require("fs"));
|
|
3075
3116
|
init_internal();
|
|
3076
3117
|
|
|
3077
3118
|
// src/scripts/activity.ts
|
|
@@ -3255,8 +3296,8 @@ async function createTemporalConnection(logger2, temporalConfig) {
|
|
|
3255
3296
|
};
|
|
3256
3297
|
if (temporalConfig.clientCert && temporalConfig.clientKey) {
|
|
3257
3298
|
logger2.info("Using TLS for secure Temporal");
|
|
3258
|
-
const cert = await
|
|
3259
|
-
const key = await
|
|
3299
|
+
const cert = await fs4.readFileSync(temporalConfig.clientCert);
|
|
3300
|
+
const key = await fs4.readFileSync(temporalConfig.clientKey);
|
|
3260
3301
|
connectionOptions.tls = {
|
|
3261
3302
|
clientCertPair: {
|
|
3262
3303
|
crt: cert,
|
|
@@ -3292,7 +3333,7 @@ async function createTemporalConnection(logger2, temporalConfig) {
|
|
|
3292
3333
|
}
|
|
3293
3334
|
const backoff = baseDelay * Math.pow(2, attempt - 1);
|
|
3294
3335
|
logger2.warn(`<workflow> Retrying connection in ${backoff}ms...`);
|
|
3295
|
-
await new Promise((
|
|
3336
|
+
await new Promise((resolve3) => setTimeout(resolve3, backoff));
|
|
3296
3337
|
}
|
|
3297
3338
|
}
|
|
3298
3339
|
}
|
|
@@ -3363,7 +3404,7 @@ async function registerWorkflows(logger2, config) {
|
|
|
3363
3404
|
}
|
|
3364
3405
|
};
|
|
3365
3406
|
const workflowBundle = await (0, import_worker2.bundleWorkflowCode)({
|
|
3366
|
-
workflowsPath:
|
|
3407
|
+
workflowsPath: path4.resolve(__dirname, "scripts/workflow.js"),
|
|
3367
3408
|
logger: silentLogger
|
|
3368
3409
|
});
|
|
3369
3410
|
const worker = await import_worker2.Worker.create({
|