@514labs/moose-lib 0.6.320-ci-6-g8ee5a20d → 0.6.320-ci-4-g05309f4d
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 +8 -0
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +8 -0
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js +7 -3
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs +7 -3
- package/dist/dataModels/toDataModels.mjs.map +1 -1
- package/dist/dmv2/index.js +8 -0
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +8 -0
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +59 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -21
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +107 -53
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +114 -60
- package/dist/moose-runner.mjs.map +1 -1
- package/dist/moose-tspc.d.mts +1 -0
- package/dist/moose-tspc.d.ts +1 -0
- package/dist/moose-tspc.js +85 -0
- package/dist/moose-tspc.js.map +1 -0
- package/dist/moose-tspc.mjs +62 -0
- package/dist/moose-tspc.mjs.map +1 -0
- package/package.json +3 -2
package/dist/moose-runner.mjs
CHANGED
|
@@ -15,6 +15,59 @@ var __export = (target, all) => {
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// src/compiler-config.ts
|
|
19
|
+
import { existsSync } from "fs";
|
|
20
|
+
import path from "path";
|
|
21
|
+
function getSourceDir() {
|
|
22
|
+
return process.env.MOOSE_SOURCE_DIR || "app";
|
|
23
|
+
}
|
|
24
|
+
function hasCompiledArtifacts(projectRoot = process.cwd()) {
|
|
25
|
+
const sourceDir = getSourceDir();
|
|
26
|
+
const compiledIndexPath = path.join(
|
|
27
|
+
projectRoot,
|
|
28
|
+
".moose",
|
|
29
|
+
"compiled",
|
|
30
|
+
sourceDir,
|
|
31
|
+
"index.js"
|
|
32
|
+
);
|
|
33
|
+
return existsSync(compiledIndexPath);
|
|
34
|
+
}
|
|
35
|
+
function shouldUseCompiled(projectRoot = process.cwd()) {
|
|
36
|
+
const envSaysCompiled = process.env.MOOSE_USE_COMPILED === "true";
|
|
37
|
+
if (!envSaysCompiled) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const hasArtifacts = hasCompiledArtifacts(projectRoot);
|
|
41
|
+
if (!hasArtifacts) {
|
|
42
|
+
console.warn(
|
|
43
|
+
`[moose] MOOSE_USE_COMPILED=true but no compiled artifacts found at .moose/compiled/${getSourceDir()}/index.js. Falling back to ts-node.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return hasArtifacts;
|
|
47
|
+
}
|
|
48
|
+
var MOOSE_COMPILER_PLUGINS, COMMANDS_REQUIRING_PLUGINS;
|
|
49
|
+
var init_compiler_config = __esm({
|
|
50
|
+
"src/compiler-config.ts"() {
|
|
51
|
+
"use strict";
|
|
52
|
+
MOOSE_COMPILER_PLUGINS = [
|
|
53
|
+
{
|
|
54
|
+
transform: "./node_modules/@514labs/moose-lib/dist/compilerPlugin.js",
|
|
55
|
+
transformProgram: true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
transform: "typia/lib/transform"
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
COMMANDS_REQUIRING_PLUGINS = [
|
|
62
|
+
"consumption-apis",
|
|
63
|
+
"consumption-type-serializer",
|
|
64
|
+
"dmv2-serializer",
|
|
65
|
+
"streaming-functions",
|
|
66
|
+
"scripts"
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
18
71
|
// src/dmv2/utils/stackTrace.ts
|
|
19
72
|
var init_stackTrace = __esm({
|
|
20
73
|
"src/dmv2/utils/stackTrace.ts"() {
|
|
@@ -920,17 +973,17 @@ var init_cluster_utils = __esm({
|
|
|
920
973
|
});
|
|
921
974
|
|
|
922
975
|
// src/config/configFile.ts
|
|
923
|
-
import
|
|
976
|
+
import path2 from "path";
|
|
924
977
|
import * as toml from "toml";
|
|
925
978
|
async function findConfigFile(startDir = process.cwd()) {
|
|
926
979
|
const fs5 = await import("fs");
|
|
927
|
-
let currentDir =
|
|
980
|
+
let currentDir = path2.resolve(startDir);
|
|
928
981
|
while (true) {
|
|
929
|
-
const configPath =
|
|
982
|
+
const configPath = path2.join(currentDir, "moose.config.toml");
|
|
930
983
|
if (fs5.existsSync(configPath)) {
|
|
931
984
|
return configPath;
|
|
932
985
|
}
|
|
933
|
-
const parentDir =
|
|
986
|
+
const parentDir = path2.dirname(currentDir);
|
|
934
987
|
if (parentDir === currentDir) {
|
|
935
988
|
break;
|
|
936
989
|
}
|
|
@@ -1211,7 +1264,7 @@ var init_runner = __esm({
|
|
|
1211
1264
|
...config,
|
|
1212
1265
|
useSSL: config.useSSL ? "true" : "false"
|
|
1213
1266
|
});
|
|
1214
|
-
createPath = (apisDir,
|
|
1267
|
+
createPath = (apisDir, path6) => `${apisDir}${path6}.ts`;
|
|
1215
1268
|
httpLogger = (req, res, startMs) => {
|
|
1216
1269
|
console.log(
|
|
1217
1270
|
`${req.method} ${req.url} ${res.statusCode} ${Date.now() - startMs}ms`
|
|
@@ -1715,16 +1768,13 @@ var init_index = __esm({
|
|
|
1715
1768
|
// src/dmv2/internal.ts
|
|
1716
1769
|
import process2 from "process";
|
|
1717
1770
|
import * as fs2 from "fs";
|
|
1718
|
-
import * as
|
|
1719
|
-
function getSourceDir() {
|
|
1720
|
-
return process2.env.MOOSE_SOURCE_DIR || "app";
|
|
1721
|
-
}
|
|
1771
|
+
import * as path3 from "path";
|
|
1722
1772
|
function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
|
|
1723
1773
|
const files = [];
|
|
1724
1774
|
try {
|
|
1725
1775
|
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
1726
1776
|
for (const entry of entries) {
|
|
1727
|
-
const fullPath =
|
|
1777
|
+
const fullPath = path3.join(dir, entry.name);
|
|
1728
1778
|
if (entry.isDirectory()) {
|
|
1729
1779
|
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
1730
1780
|
files.push(...findSourceFiles(fullPath, extensions));
|
|
@@ -1733,7 +1783,7 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
|
|
|
1733
1783
|
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".d.mts") || entry.name.endsWith(".d.cts")) {
|
|
1734
1784
|
continue;
|
|
1735
1785
|
}
|
|
1736
|
-
const ext =
|
|
1786
|
+
const ext = path3.extname(entry.name);
|
|
1737
1787
|
if (extensions.includes(ext)) {
|
|
1738
1788
|
files.push(fullPath);
|
|
1739
1789
|
}
|
|
@@ -1745,12 +1795,12 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
|
|
|
1745
1795
|
return files;
|
|
1746
1796
|
}
|
|
1747
1797
|
function findUnloadedFiles() {
|
|
1748
|
-
const appDir =
|
|
1798
|
+
const appDir = path3.resolve(process2.cwd(), getSourceDir());
|
|
1749
1799
|
const allSourceFiles = findSourceFiles(appDir);
|
|
1750
1800
|
const loadedFiles = new Set(
|
|
1751
|
-
Object.keys(__require.cache).filter((key) => key.startsWith(appDir)).map((key) =>
|
|
1801
|
+
Object.keys(__require.cache).filter((key) => key.startsWith(appDir)).map((key) => path3.resolve(key))
|
|
1752
1802
|
);
|
|
1753
|
-
const unloadedFiles = allSourceFiles.map((file) =>
|
|
1803
|
+
const unloadedFiles = allSourceFiles.map((file) => path3.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path3.relative(process2.cwd(), file));
|
|
1754
1804
|
return unloadedFiles;
|
|
1755
1805
|
}
|
|
1756
1806
|
function isS3QueueConfig(config) {
|
|
@@ -2009,6 +2059,7 @@ var init_internal = __esm({
|
|
|
2009
2059
|
"use strict";
|
|
2010
2060
|
init_index();
|
|
2011
2061
|
init_commons();
|
|
2062
|
+
init_compiler_config();
|
|
2012
2063
|
moose_internal = {
|
|
2013
2064
|
tables: /* @__PURE__ */ new Map(),
|
|
2014
2065
|
streams: /* @__PURE__ */ new Map(),
|
|
@@ -2293,6 +2344,7 @@ var init_internal = __esm({
|
|
|
2293
2344
|
);
|
|
2294
2345
|
};
|
|
2295
2346
|
loadIndex = () => {
|
|
2347
|
+
const useCompiled2 = shouldUseCompiled();
|
|
2296
2348
|
const registry = getMooseInternal();
|
|
2297
2349
|
registry.tables.clear();
|
|
2298
2350
|
registry.streams.clear();
|
|
@@ -2303,14 +2355,21 @@ var init_internal = __esm({
|
|
|
2303
2355
|
registry.webApps.clear();
|
|
2304
2356
|
registry.materializedViews.clear();
|
|
2305
2357
|
registry.views.clear();
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2358
|
+
if (!useCompiled2) {
|
|
2359
|
+
const appDir = `${process2.cwd()}/${getSourceDir()}`;
|
|
2360
|
+
Object.keys(__require.cache).forEach((key) => {
|
|
2361
|
+
if (key.startsWith(appDir)) {
|
|
2362
|
+
delete __require.cache[key];
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2312
2366
|
try {
|
|
2313
|
-
|
|
2367
|
+
const sourceDir = getSourceDir();
|
|
2368
|
+
if (useCompiled2) {
|
|
2369
|
+
__require(`${process2.cwd()}/.moose/compiled/${sourceDir}/index.js`);
|
|
2370
|
+
} else {
|
|
2371
|
+
__require(`${process2.cwd()}/${sourceDir}/index.ts`);
|
|
2372
|
+
}
|
|
2314
2373
|
} catch (error) {
|
|
2315
2374
|
let hint;
|
|
2316
2375
|
let includeDetails = true;
|
|
@@ -2417,6 +2476,7 @@ var init_internal = __esm({
|
|
|
2417
2476
|
});
|
|
2418
2477
|
|
|
2419
2478
|
// src/moose-runner.ts
|
|
2479
|
+
init_compiler_config();
|
|
2420
2480
|
init_internal();
|
|
2421
2481
|
import { register } from "ts-node";
|
|
2422
2482
|
|
|
@@ -2424,14 +2484,14 @@ import { register } from "ts-node";
|
|
|
2424
2484
|
init_commons();
|
|
2425
2485
|
import fastq from "fastq";
|
|
2426
2486
|
import fs3 from "fs";
|
|
2427
|
-
import
|
|
2487
|
+
import path4 from "path";
|
|
2428
2488
|
var walkDir = (dir, fileExtension, fileList) => {
|
|
2429
2489
|
const files = fs3.readdirSync(dir);
|
|
2430
2490
|
files.forEach((file) => {
|
|
2431
|
-
if (fs3.statSync(
|
|
2432
|
-
fileList = walkDir(
|
|
2491
|
+
if (fs3.statSync(path4.join(dir, file)).isDirectory()) {
|
|
2492
|
+
fileList = walkDir(path4.join(dir, file), fileExtension, fileList);
|
|
2433
2493
|
} else if (file.endsWith(fileExtension)) {
|
|
2434
|
-
fileList.push(
|
|
2494
|
+
fileList.push(path4.join(dir, file));
|
|
2435
2495
|
}
|
|
2436
2496
|
});
|
|
2437
2497
|
return fileList;
|
|
@@ -2507,10 +2567,10 @@ var runBlocks = async (config) => {
|
|
|
2507
2567
|
}
|
|
2508
2568
|
}
|
|
2509
2569
|
});
|
|
2510
|
-
for (const
|
|
2511
|
-
console.log(`Adding to queue: ${
|
|
2570
|
+
for (const path6 of blocksFiles) {
|
|
2571
|
+
console.log(`Adding to queue: ${path6}`);
|
|
2512
2572
|
try {
|
|
2513
|
-
const blocks = __require(
|
|
2573
|
+
const blocks = __require(path6).default;
|
|
2514
2574
|
queue.push({
|
|
2515
2575
|
chClient,
|
|
2516
2576
|
blocks,
|
|
@@ -2519,7 +2579,7 @@ var runBlocks = async (config) => {
|
|
|
2519
2579
|
} catch (err) {
|
|
2520
2580
|
cliLog({
|
|
2521
2581
|
action: "Blocks",
|
|
2522
|
-
message: `Failed to import blocks from ${
|
|
2582
|
+
message: `Failed to import blocks from ${path6}: ${err}`,
|
|
2523
2583
|
message_type: "Error"
|
|
2524
2584
|
});
|
|
2525
2585
|
}
|
|
@@ -3095,12 +3155,10 @@ async function runExportSerializer(targetModel) {
|
|
|
3095
3155
|
}
|
|
3096
3156
|
|
|
3097
3157
|
// src/consumption-apis/exportTypeSerializer.ts
|
|
3158
|
+
init_compiler_config();
|
|
3098
3159
|
import process4 from "process";
|
|
3099
|
-
function getSourceDir2() {
|
|
3100
|
-
return process4.env.MOOSE_SOURCE_DIR || "app";
|
|
3101
|
-
}
|
|
3102
3160
|
async function runApiTypeSerializer(targetModel) {
|
|
3103
|
-
const func = __require(`${process4.cwd()}/${
|
|
3161
|
+
const func = __require(`${process4.cwd()}/${getSourceDir()}/apis/${targetModel}.ts`).default;
|
|
3104
3162
|
const inputSchema = func["moose_input_schema"] || null;
|
|
3105
3163
|
const outputSchema = func["moose_output_schema"] || null;
|
|
3106
3164
|
console.log(
|
|
@@ -3118,7 +3176,7 @@ import {
|
|
|
3118
3176
|
Worker,
|
|
3119
3177
|
bundleWorkflowCode
|
|
3120
3178
|
} from "@temporalio/worker";
|
|
3121
|
-
import * as
|
|
3179
|
+
import * as path5 from "path";
|
|
3122
3180
|
import * as fs4 from "fs";
|
|
3123
3181
|
|
|
3124
3182
|
// src/scripts/activity.ts
|
|
@@ -3414,7 +3472,7 @@ async function registerWorkflows(logger2, config) {
|
|
|
3414
3472
|
}
|
|
3415
3473
|
};
|
|
3416
3474
|
const workflowBundle = await bundleWorkflowCode({
|
|
3417
|
-
workflowsPath:
|
|
3475
|
+
workflowsPath: path5.resolve(__dirname, "scripts/workflow.js"),
|
|
3418
3476
|
logger: silentLogger
|
|
3419
3477
|
});
|
|
3420
3478
|
const worker = await Worker.create({
|
|
@@ -3495,31 +3553,27 @@ async function runScripts(config) {
|
|
|
3495
3553
|
// src/moose-runner.ts
|
|
3496
3554
|
import process5 from "process";
|
|
3497
3555
|
import { Command } from "commander";
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
}
|
|
3519
|
-
register({
|
|
3520
|
-
esm: true,
|
|
3521
|
-
experimentalTsImportSpecifiers: true
|
|
3522
|
-
});
|
|
3556
|
+
var useCompiled = shouldUseCompiled();
|
|
3557
|
+
if (!useCompiled) {
|
|
3558
|
+
const command = process5.argv[2];
|
|
3559
|
+
const needsPlugins = COMMANDS_REQUIRING_PLUGINS.includes(command);
|
|
3560
|
+
if (needsPlugins) {
|
|
3561
|
+
register({
|
|
3562
|
+
require: ["tsconfig-paths/register"],
|
|
3563
|
+
esm: true,
|
|
3564
|
+
experimentalTsImportSpecifiers: true,
|
|
3565
|
+
compiler: "ts-patch/compiler",
|
|
3566
|
+
compilerOptions: {
|
|
3567
|
+
plugins: [...MOOSE_COMPILER_PLUGINS],
|
|
3568
|
+
experimentalDecorators: true
|
|
3569
|
+
}
|
|
3570
|
+
});
|
|
3571
|
+
} else {
|
|
3572
|
+
register({
|
|
3573
|
+
esm: true,
|
|
3574
|
+
experimentalTsImportSpecifiers: true
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3523
3577
|
}
|
|
3524
3578
|
var program = new Command();
|
|
3525
3579
|
program.name("moose-runner").description("Moose runner for various operations").version("1.0.0");
|