@514labs/moose-lib 0.6.301 → 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.mjs
CHANGED
|
@@ -878,16 +878,16 @@ var init_cluster_utils = __esm({
|
|
|
878
878
|
* @returns A promise that resolves when all workers have terminated
|
|
879
879
|
*/
|
|
880
880
|
shutdownWorkers = (signal) => {
|
|
881
|
-
return new Promise((
|
|
881
|
+
return new Promise((resolve3, reject) => {
|
|
882
882
|
if (!cluster.isPrimary) {
|
|
883
|
-
return
|
|
883
|
+
return resolve3();
|
|
884
884
|
}
|
|
885
885
|
if (!cluster.workers) {
|
|
886
|
-
return
|
|
886
|
+
return resolve3();
|
|
887
887
|
}
|
|
888
888
|
const workerIds = Object.keys(cluster.workers);
|
|
889
889
|
if (workerIds.length == 0) {
|
|
890
|
-
return
|
|
890
|
+
return resolve3();
|
|
891
891
|
}
|
|
892
892
|
let workersAlive = 0;
|
|
893
893
|
let funcRun = 0;
|
|
@@ -905,7 +905,7 @@ var init_cluster_utils = __esm({
|
|
|
905
905
|
console.info(workersAlive + " workers alive");
|
|
906
906
|
if (workersAlive == 0) {
|
|
907
907
|
clearInterval(interval);
|
|
908
|
-
return
|
|
908
|
+
return resolve3();
|
|
909
909
|
}
|
|
910
910
|
};
|
|
911
911
|
const interval = setInterval(cleanWorkers, SHUTDOWN_WORKERS_INTERVAL);
|
|
@@ -919,11 +919,11 @@ var init_cluster_utils = __esm({
|
|
|
919
919
|
import path from "path";
|
|
920
920
|
import * as toml from "toml";
|
|
921
921
|
async function findConfigFile(startDir = process.cwd()) {
|
|
922
|
-
const
|
|
922
|
+
const fs5 = await import("fs");
|
|
923
923
|
let currentDir = path.resolve(startDir);
|
|
924
924
|
while (true) {
|
|
925
925
|
const configPath = path.join(currentDir, "moose.config.toml");
|
|
926
|
-
if (
|
|
926
|
+
if (fs5.existsSync(configPath)) {
|
|
927
927
|
return configPath;
|
|
928
928
|
}
|
|
929
929
|
const parentDir = path.dirname(currentDir);
|
|
@@ -935,7 +935,7 @@ async function findConfigFile(startDir = process.cwd()) {
|
|
|
935
935
|
return null;
|
|
936
936
|
}
|
|
937
937
|
async function readProjectConfig() {
|
|
938
|
-
const
|
|
938
|
+
const fs5 = await import("fs");
|
|
939
939
|
const configPath = await findConfigFile();
|
|
940
940
|
if (!configPath) {
|
|
941
941
|
throw new ConfigError(
|
|
@@ -943,7 +943,7 @@ async function readProjectConfig() {
|
|
|
943
943
|
);
|
|
944
944
|
}
|
|
945
945
|
try {
|
|
946
|
-
const configContent =
|
|
946
|
+
const configContent = fs5.readFileSync(configPath, "utf-8");
|
|
947
947
|
const config = toml.parse(configContent);
|
|
948
948
|
return config;
|
|
949
949
|
} catch (error) {
|
|
@@ -1207,7 +1207,7 @@ var init_runner = __esm({
|
|
|
1207
1207
|
...config,
|
|
1208
1208
|
useSSL: config.useSSL ? "true" : "false"
|
|
1209
1209
|
});
|
|
1210
|
-
createPath = (apisDir,
|
|
1210
|
+
createPath = (apisDir, path5) => `${apisDir}${path5}.ts`;
|
|
1211
1211
|
httpLogger = (req, res, startMs) => {
|
|
1212
1212
|
console.log(
|
|
1213
1213
|
`${req.method} ${req.url} ${res.statusCode} ${Date.now() - startMs}ms`
|
|
@@ -1504,8 +1504,8 @@ var init_runner = __esm({
|
|
|
1504
1504
|
return server;
|
|
1505
1505
|
},
|
|
1506
1506
|
workerStop: async (server) => {
|
|
1507
|
-
return new Promise((
|
|
1508
|
-
server.close(() =>
|
|
1507
|
+
return new Promise((resolve3) => {
|
|
1508
|
+
server.close(() => resolve3());
|
|
1509
1509
|
});
|
|
1510
1510
|
}
|
|
1511
1511
|
});
|
|
@@ -1710,9 +1710,45 @@ var init_index = __esm({
|
|
|
1710
1710
|
|
|
1711
1711
|
// src/dmv2/internal.ts
|
|
1712
1712
|
import process2 from "process";
|
|
1713
|
+
import * as fs2 from "fs";
|
|
1714
|
+
import * as path2 from "path";
|
|
1713
1715
|
function getSourceDir() {
|
|
1714
1716
|
return process2.env.MOOSE_SOURCE_DIR || "app";
|
|
1715
1717
|
}
|
|
1718
|
+
function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
|
|
1719
|
+
const files = [];
|
|
1720
|
+
try {
|
|
1721
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
1722
|
+
for (const entry of entries) {
|
|
1723
|
+
const fullPath = path2.join(dir, entry.name);
|
|
1724
|
+
if (entry.isDirectory()) {
|
|
1725
|
+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
1726
|
+
files.push(...findSourceFiles(fullPath, extensions));
|
|
1727
|
+
}
|
|
1728
|
+
} else if (entry.isFile()) {
|
|
1729
|
+
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".d.mts") || entry.name.endsWith(".d.cts")) {
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
const ext = path2.extname(entry.name);
|
|
1733
|
+
if (extensions.includes(ext)) {
|
|
1734
|
+
files.push(fullPath);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
compilerLog(`Warning: Could not read directory ${dir}: ${error}`);
|
|
1740
|
+
}
|
|
1741
|
+
return files;
|
|
1742
|
+
}
|
|
1743
|
+
function findUnloadedFiles() {
|
|
1744
|
+
const appDir = path2.resolve(process2.cwd(), getSourceDir());
|
|
1745
|
+
const allSourceFiles = findSourceFiles(appDir);
|
|
1746
|
+
const loadedFiles = new Set(
|
|
1747
|
+
Object.keys(__require.cache).filter((key) => key.startsWith(appDir)).map((key) => path2.resolve(key))
|
|
1748
|
+
);
|
|
1749
|
+
const unloadedFiles = allSourceFiles.map((file) => path2.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path2.relative(process2.cwd(), file));
|
|
1750
|
+
return unloadedFiles;
|
|
1751
|
+
}
|
|
1716
1752
|
function isS3QueueConfig(config) {
|
|
1717
1753
|
return "engine" in config && config.engine === "S3Queue" /* S3Queue */;
|
|
1718
1754
|
}
|
|
@@ -2232,7 +2268,9 @@ var init_internal = __esm({
|
|
|
2232
2268
|
workflows,
|
|
2233
2269
|
webApps,
|
|
2234
2270
|
materializedViews,
|
|
2235
|
-
views
|
|
2271
|
+
views,
|
|
2272
|
+
unloadedFiles: []
|
|
2273
|
+
// Will be populated by dumpMooseInternal
|
|
2236
2274
|
};
|
|
2237
2275
|
};
|
|
2238
2276
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2241,9 +2279,12 @@ var init_internal = __esm({
|
|
|
2241
2279
|
}
|
|
2242
2280
|
dumpMooseInternal = async () => {
|
|
2243
2281
|
loadIndex();
|
|
2282
|
+
const infraMap = toInfraMap(getMooseInternal());
|
|
2283
|
+
const unloadedFiles = findUnloadedFiles();
|
|
2284
|
+
infraMap.unloadedFiles = unloadedFiles;
|
|
2244
2285
|
console.log(
|
|
2245
2286
|
"___MOOSE_STUFF___start",
|
|
2246
|
-
JSON.stringify(
|
|
2287
|
+
JSON.stringify(infraMap),
|
|
2247
2288
|
"end___MOOSE_STUFF___"
|
|
2248
2289
|
);
|
|
2249
2290
|
};
|
|
@@ -2378,15 +2419,15 @@ import { register } from "ts-node";
|
|
|
2378
2419
|
// src/blocks/runner.ts
|
|
2379
2420
|
init_commons();
|
|
2380
2421
|
import fastq from "fastq";
|
|
2381
|
-
import
|
|
2382
|
-
import
|
|
2422
|
+
import fs3 from "fs";
|
|
2423
|
+
import path3 from "path";
|
|
2383
2424
|
var walkDir = (dir, fileExtension, fileList) => {
|
|
2384
|
-
const files =
|
|
2425
|
+
const files = fs3.readdirSync(dir);
|
|
2385
2426
|
files.forEach((file) => {
|
|
2386
|
-
if (
|
|
2387
|
-
fileList = walkDir(
|
|
2427
|
+
if (fs3.statSync(path3.join(dir, file)).isDirectory()) {
|
|
2428
|
+
fileList = walkDir(path3.join(dir, file), fileExtension, fileList);
|
|
2388
2429
|
} else if (file.endsWith(fileExtension)) {
|
|
2389
|
-
fileList.push(
|
|
2430
|
+
fileList.push(path3.join(dir, file));
|
|
2390
2431
|
}
|
|
2391
2432
|
});
|
|
2392
2433
|
return fileList;
|
|
@@ -2462,10 +2503,10 @@ var runBlocks = async (config) => {
|
|
|
2462
2503
|
}
|
|
2463
2504
|
}
|
|
2464
2505
|
});
|
|
2465
|
-
for (const
|
|
2466
|
-
console.log(`Adding to queue: ${
|
|
2506
|
+
for (const path5 of blocksFiles) {
|
|
2507
|
+
console.log(`Adding to queue: ${path5}`);
|
|
2467
2508
|
try {
|
|
2468
|
-
const blocks = __require(
|
|
2509
|
+
const blocks = __require(path5).default;
|
|
2469
2510
|
queue.push({
|
|
2470
2511
|
chClient,
|
|
2471
2512
|
blocks,
|
|
@@ -2474,13 +2515,13 @@ var runBlocks = async (config) => {
|
|
|
2474
2515
|
} catch (err) {
|
|
2475
2516
|
cliLog({
|
|
2476
2517
|
action: "Blocks",
|
|
2477
|
-
message: `Failed to import blocks from ${
|
|
2518
|
+
message: `Failed to import blocks from ${path5}: ${err}`,
|
|
2478
2519
|
message_type: "Error"
|
|
2479
2520
|
});
|
|
2480
2521
|
}
|
|
2481
2522
|
}
|
|
2482
2523
|
while (!queue.idle()) {
|
|
2483
|
-
await new Promise((
|
|
2524
|
+
await new Promise((resolve3) => setTimeout(resolve3, 1e3));
|
|
2484
2525
|
}
|
|
2485
2526
|
};
|
|
2486
2527
|
|
|
@@ -3021,7 +3062,7 @@ var runStreamingFunctions = async (args) => {
|
|
|
3021
3062
|
logger2.log("Stopping consumer first...");
|
|
3022
3063
|
await stopConsumer(logger2, consumer, args.sourceTopic);
|
|
3023
3064
|
logger2.log("Waiting for in-flight messages to complete...");
|
|
3024
|
-
await new Promise((
|
|
3065
|
+
await new Promise((resolve3) => setTimeout(resolve3, 2e3));
|
|
3025
3066
|
logger2.log("Stopping producer...");
|
|
3026
3067
|
await stopProducer(logger2, producer);
|
|
3027
3068
|
logger2.log("Graceful shutdown completed");
|
|
@@ -3060,8 +3101,8 @@ import {
|
|
|
3060
3101
|
Worker,
|
|
3061
3102
|
bundleWorkflowCode
|
|
3062
3103
|
} from "@temporalio/worker";
|
|
3063
|
-
import * as
|
|
3064
|
-
import * as
|
|
3104
|
+
import * as path4 from "path";
|
|
3105
|
+
import * as fs4 from "fs";
|
|
3065
3106
|
|
|
3066
3107
|
// src/scripts/activity.ts
|
|
3067
3108
|
init_internal();
|
|
@@ -3248,8 +3289,8 @@ async function createTemporalConnection(logger2, temporalConfig) {
|
|
|
3248
3289
|
};
|
|
3249
3290
|
if (temporalConfig.clientCert && temporalConfig.clientKey) {
|
|
3250
3291
|
logger2.info("Using TLS for secure Temporal");
|
|
3251
|
-
const cert = await
|
|
3252
|
-
const key = await
|
|
3292
|
+
const cert = await fs4.readFileSync(temporalConfig.clientCert);
|
|
3293
|
+
const key = await fs4.readFileSync(temporalConfig.clientKey);
|
|
3253
3294
|
connectionOptions.tls = {
|
|
3254
3295
|
clientCertPair: {
|
|
3255
3296
|
crt: cert,
|
|
@@ -3285,7 +3326,7 @@ async function createTemporalConnection(logger2, temporalConfig) {
|
|
|
3285
3326
|
}
|
|
3286
3327
|
const backoff = baseDelay * Math.pow(2, attempt - 1);
|
|
3287
3328
|
logger2.warn(`<workflow> Retrying connection in ${backoff}ms...`);
|
|
3288
|
-
await new Promise((
|
|
3329
|
+
await new Promise((resolve3) => setTimeout(resolve3, backoff));
|
|
3289
3330
|
}
|
|
3290
3331
|
}
|
|
3291
3332
|
}
|
|
@@ -3356,7 +3397,7 @@ async function registerWorkflows(logger2, config) {
|
|
|
3356
3397
|
}
|
|
3357
3398
|
};
|
|
3358
3399
|
const workflowBundle = await bundleWorkflowCode({
|
|
3359
|
-
workflowsPath:
|
|
3400
|
+
workflowsPath: path4.resolve(__dirname, "scripts/workflow.js"),
|
|
3360
3401
|
logger: silentLogger
|
|
3361
3402
|
});
|
|
3362
3403
|
const worker = await Worker.create({
|