@514labs/moose-lib 0.6.322-ci-9-g72529e37 → 0.6.322-ci-14-ga8e5dacb
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 -9
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +0 -9
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js +3 -7
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs +3 -7
- package/dist/dataModels/toDataModels.mjs.map +1 -1
- package/dist/dmv2/index.js +0 -9
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +0 -9
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +16 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -64
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +57 -140
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +64 -147
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +2 -3
- package/dist/moose-tspc.d.mts +0 -1
- package/dist/moose-tspc.d.ts +0 -1
- package/dist/moose-tspc.js +0 -121
- package/dist/moose-tspc.js.map +0 -1
- package/dist/moose-tspc.mjs +0 -98
- package/dist/moose-tspc.mjs.map +0 -1
package/dist/moose-runner.js
CHANGED
|
@@ -30,59 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
// src/compiler-config.ts
|
|
34
|
-
function getSourceDir() {
|
|
35
|
-
return process.env.MOOSE_SOURCE_DIR || "app";
|
|
36
|
-
}
|
|
37
|
-
function hasCompiledArtifacts(projectRoot = process.cwd()) {
|
|
38
|
-
const sourceDir = getSourceDir();
|
|
39
|
-
const compiledIndexPath = import_path.default.join(
|
|
40
|
-
projectRoot,
|
|
41
|
-
".moose",
|
|
42
|
-
"compiled",
|
|
43
|
-
sourceDir,
|
|
44
|
-
"index.js"
|
|
45
|
-
);
|
|
46
|
-
return (0, import_fs.existsSync)(compiledIndexPath);
|
|
47
|
-
}
|
|
48
|
-
function shouldUseCompiled(projectRoot = process.cwd()) {
|
|
49
|
-
const envSaysCompiled = process.env.MOOSE_USE_COMPILED === "true";
|
|
50
|
-
if (!envSaysCompiled) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
const hasArtifacts = hasCompiledArtifacts(projectRoot);
|
|
54
|
-
if (!hasArtifacts) {
|
|
55
|
-
console.warn(
|
|
56
|
-
`[moose] MOOSE_USE_COMPILED=true but no compiled artifacts found at .moose/compiled/${getSourceDir()}/index.js. Falling back to ts-node.`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
return hasArtifacts;
|
|
60
|
-
}
|
|
61
|
-
var import_fs, import_path, MOOSE_COMPILER_PLUGINS, COMMANDS_REQUIRING_PLUGINS;
|
|
62
|
-
var init_compiler_config = __esm({
|
|
63
|
-
"src/compiler-config.ts"() {
|
|
64
|
-
"use strict";
|
|
65
|
-
import_fs = require("fs");
|
|
66
|
-
import_path = __toESM(require("path"));
|
|
67
|
-
MOOSE_COMPILER_PLUGINS = [
|
|
68
|
-
{
|
|
69
|
-
transform: "./node_modules/@514labs/moose-lib/dist/compilerPlugin.js",
|
|
70
|
-
transformProgram: true
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
transform: "typia/lib/transform"
|
|
74
|
-
}
|
|
75
|
-
];
|
|
76
|
-
COMMANDS_REQUIRING_PLUGINS = [
|
|
77
|
-
"consumption-apis",
|
|
78
|
-
"consumption-type-serializer",
|
|
79
|
-
"dmv2-serializer",
|
|
80
|
-
"streaming-functions",
|
|
81
|
-
"scripts"
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
33
|
// src/dmv2/utils/stackTrace.ts
|
|
87
34
|
var init_stackTrace = __esm({
|
|
88
35
|
"src/dmv2/utils/stackTrace.ts"() {
|
|
@@ -1274,15 +1221,11 @@ var init_runner = __esm({
|
|
|
1274
1221
|
init_cluster_utils();
|
|
1275
1222
|
init_sqlHelpers();
|
|
1276
1223
|
init_internal();
|
|
1277
|
-
init_compiler_config();
|
|
1278
1224
|
toClientConfig2 = (config) => ({
|
|
1279
1225
|
...config,
|
|
1280
1226
|
useSSL: config.useSSL ? "true" : "false"
|
|
1281
1227
|
});
|
|
1282
|
-
createPath = (apisDir,
|
|
1283
|
-
const extension = useCompiled2 ? ".js" : ".ts";
|
|
1284
|
-
return `${apisDir}${path6}${extension}`;
|
|
1285
|
-
};
|
|
1228
|
+
createPath = (apisDir, path5) => `${apisDir}${path5}.ts`;
|
|
1286
1229
|
httpLogger = (req, res, startMs) => {
|
|
1287
1230
|
console.log(
|
|
1288
1231
|
`${req.method} ${req.url} ${res.statusCode} ${Date.now() - startMs}ms`
|
|
@@ -1290,9 +1233,6 @@ var init_runner = __esm({
|
|
|
1290
1233
|
};
|
|
1291
1234
|
modulesCache = /* @__PURE__ */ new Map();
|
|
1292
1235
|
apiHandler = async (publicKey, clickhouseClient, temporalClient, apisDir, enforceAuth, isDmv2, jwtConfig) => {
|
|
1293
|
-
const useCompiled2 = shouldUseCompiled();
|
|
1294
|
-
const sourceDir = getSourceDir();
|
|
1295
|
-
const actualApisDir = useCompiled2 ? `${process.cwd()}/.moose/compiled/${sourceDir}/apis/` : apisDir;
|
|
1296
1236
|
const apis = isDmv2 ? await getApis2() : /* @__PURE__ */ new Map();
|
|
1297
1237
|
return async (req, res) => {
|
|
1298
1238
|
const start = Date.now();
|
|
@@ -1330,7 +1270,7 @@ var init_runner = __esm({
|
|
|
1330
1270
|
httpLogger(req, res, start);
|
|
1331
1271
|
return;
|
|
1332
1272
|
}
|
|
1333
|
-
const pathName = createPath(
|
|
1273
|
+
const pathName = createPath(apisDir, fileName);
|
|
1334
1274
|
const paramsObject = Array.from(url.searchParams.entries()).reduce(
|
|
1335
1275
|
(obj, [key, value]) => {
|
|
1336
1276
|
const existingValue = obj[key];
|
|
@@ -1788,12 +1728,15 @@ var init_index = __esm({
|
|
|
1788
1728
|
});
|
|
1789
1729
|
|
|
1790
1730
|
// src/dmv2/internal.ts
|
|
1731
|
+
function getSourceDir() {
|
|
1732
|
+
return import_process.default.env.MOOSE_SOURCE_DIR || "app";
|
|
1733
|
+
}
|
|
1791
1734
|
function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
|
|
1792
1735
|
const files = [];
|
|
1793
1736
|
try {
|
|
1794
1737
|
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
1795
1738
|
for (const entry of entries) {
|
|
1796
|
-
const fullPath =
|
|
1739
|
+
const fullPath = path2.join(dir, entry.name);
|
|
1797
1740
|
if (entry.isDirectory()) {
|
|
1798
1741
|
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
1799
1742
|
files.push(...findSourceFiles(fullPath, extensions));
|
|
@@ -1802,7 +1745,7 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
|
|
|
1802
1745
|
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".d.mts") || entry.name.endsWith(".d.cts")) {
|
|
1803
1746
|
continue;
|
|
1804
1747
|
}
|
|
1805
|
-
const ext =
|
|
1748
|
+
const ext = path2.extname(entry.name);
|
|
1806
1749
|
if (extensions.includes(ext)) {
|
|
1807
1750
|
files.push(fullPath);
|
|
1808
1751
|
}
|
|
@@ -1814,12 +1757,12 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
|
|
|
1814
1757
|
return files;
|
|
1815
1758
|
}
|
|
1816
1759
|
function findUnloadedFiles() {
|
|
1817
|
-
const appDir =
|
|
1760
|
+
const appDir = path2.resolve(import_process.default.cwd(), getSourceDir());
|
|
1818
1761
|
const allSourceFiles = findSourceFiles(appDir);
|
|
1819
1762
|
const loadedFiles = new Set(
|
|
1820
|
-
Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) =>
|
|
1763
|
+
Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) => path2.resolve(key))
|
|
1821
1764
|
);
|
|
1822
|
-
const unloadedFiles = allSourceFiles.map((file) =>
|
|
1765
|
+
const unloadedFiles = allSourceFiles.map((file) => path2.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path2.relative(import_process.default.cwd(), file));
|
|
1823
1766
|
return unloadedFiles;
|
|
1824
1767
|
}
|
|
1825
1768
|
function isS3QueueConfig(config) {
|
|
@@ -2072,16 +2015,15 @@ function findTaskInTree(task, targetName) {
|
|
|
2072
2015
|
}
|
|
2073
2016
|
return void 0;
|
|
2074
2017
|
}
|
|
2075
|
-
var import_process, fs2,
|
|
2018
|
+
var import_process, fs2, path2, moose_internal, defaultRetentionPeriod, toInfraMap, getMooseInternal, dumpMooseInternal, loadIndex, getStreamingFunctions, getApis2, getWorkflows2, getTaskForWorkflow, getWebApps2;
|
|
2076
2019
|
var init_internal = __esm({
|
|
2077
2020
|
"src/dmv2/internal.ts"() {
|
|
2078
2021
|
"use strict";
|
|
2079
2022
|
import_process = __toESM(require("process"));
|
|
2080
2023
|
fs2 = __toESM(require("fs"));
|
|
2081
|
-
|
|
2024
|
+
path2 = __toESM(require("path"));
|
|
2082
2025
|
init_index();
|
|
2083
2026
|
init_commons();
|
|
2084
|
-
init_compiler_config();
|
|
2085
2027
|
moose_internal = {
|
|
2086
2028
|
tables: /* @__PURE__ */ new Map(),
|
|
2087
2029
|
streams: /* @__PURE__ */ new Map(),
|
|
@@ -2366,7 +2308,6 @@ var init_internal = __esm({
|
|
|
2366
2308
|
);
|
|
2367
2309
|
};
|
|
2368
2310
|
loadIndex = () => {
|
|
2369
|
-
const useCompiled2 = shouldUseCompiled();
|
|
2370
2311
|
const registry = getMooseInternal();
|
|
2371
2312
|
registry.tables.clear();
|
|
2372
2313
|
registry.streams.clear();
|
|
@@ -2377,21 +2318,14 @@ var init_internal = __esm({
|
|
|
2377
2318
|
registry.webApps.clear();
|
|
2378
2319
|
registry.materializedViews.clear();
|
|
2379
2320
|
registry.views.clear();
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
delete require.cache[key];
|
|
2385
|
-
}
|
|
2386
|
-
});
|
|
2387
|
-
}
|
|
2388
|
-
try {
|
|
2389
|
-
const sourceDir = getSourceDir();
|
|
2390
|
-
if (useCompiled2) {
|
|
2391
|
-
require(`${import_process.default.cwd()}/.moose/compiled/${sourceDir}/index.js`);
|
|
2392
|
-
} else {
|
|
2393
|
-
require(`${import_process.default.cwd()}/${sourceDir}/index.ts`);
|
|
2321
|
+
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
2322
|
+
Object.keys(require.cache).forEach((key) => {
|
|
2323
|
+
if (key.startsWith(appDir)) {
|
|
2324
|
+
delete require.cache[key];
|
|
2394
2325
|
}
|
|
2326
|
+
});
|
|
2327
|
+
try {
|
|
2328
|
+
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
2395
2329
|
} catch (error) {
|
|
2396
2330
|
let hint;
|
|
2397
2331
|
let includeDetails = true;
|
|
@@ -2499,7 +2433,6 @@ var init_internal = __esm({
|
|
|
2499
2433
|
|
|
2500
2434
|
// src/moose-runner.ts
|
|
2501
2435
|
var import_ts_node = require("ts-node");
|
|
2502
|
-
init_compiler_config();
|
|
2503
2436
|
init_internal();
|
|
2504
2437
|
|
|
2505
2438
|
// src/blocks/runner.ts
|
|
@@ -2507,7 +2440,6 @@ var import_fastq = __toESM(require("fastq"));
|
|
|
2507
2440
|
init_commons();
|
|
2508
2441
|
var import_node_fs = __toESM(require("fs"));
|
|
2509
2442
|
var import_node_path2 = __toESM(require("path"));
|
|
2510
|
-
init_compiler_config();
|
|
2511
2443
|
var walkDir = (dir, fileExtension, fileList) => {
|
|
2512
2444
|
const files = import_node_fs.default.readdirSync(dir);
|
|
2513
2445
|
files.forEach((file) => {
|
|
@@ -2579,11 +2511,7 @@ var asyncWorker = async (task) => {
|
|
|
2579
2511
|
var runBlocks = async (config) => {
|
|
2580
2512
|
const chClient = getClickhouseClient(toClientConfig3(config.clickhouseConfig));
|
|
2581
2513
|
console.log(`Connected`);
|
|
2582
|
-
const
|
|
2583
|
-
const sourceDir = getSourceDir();
|
|
2584
|
-
const blocksDir = useCompiled2 ? `${process.cwd()}/.moose/compiled/${sourceDir}/blocks/` : config.blocksDir;
|
|
2585
|
-
const fileExtension = useCompiled2 ? ".js" : ".ts";
|
|
2586
|
-
const blocksFiles = walkDir(blocksDir, fileExtension, []);
|
|
2514
|
+
const blocksFiles = walkDir(config.blocksDir, ".ts", []);
|
|
2587
2515
|
const numOfBlockFiles = blocksFiles.length;
|
|
2588
2516
|
console.log(`Found ${numOfBlockFiles} blocks files`);
|
|
2589
2517
|
const queue = import_fastq.default.promise(asyncWorker, 1);
|
|
@@ -2594,10 +2522,10 @@ var runBlocks = async (config) => {
|
|
|
2594
2522
|
}
|
|
2595
2523
|
}
|
|
2596
2524
|
});
|
|
2597
|
-
for (const
|
|
2598
|
-
console.log(`Adding to queue: ${
|
|
2525
|
+
for (const path5 of blocksFiles) {
|
|
2526
|
+
console.log(`Adding to queue: ${path5}`);
|
|
2599
2527
|
try {
|
|
2600
|
-
const blocks = require(
|
|
2528
|
+
const blocks = require(path5).default;
|
|
2601
2529
|
queue.push({
|
|
2602
2530
|
chClient,
|
|
2603
2531
|
blocks,
|
|
@@ -2606,7 +2534,7 @@ var runBlocks = async (config) => {
|
|
|
2606
2534
|
} catch (err) {
|
|
2607
2535
|
cliLog({
|
|
2608
2536
|
action: "Blocks",
|
|
2609
|
-
message: `Failed to import blocks from ${
|
|
2537
|
+
message: `Failed to import blocks from ${path5}: ${err}`,
|
|
2610
2538
|
message_type: "Error"
|
|
2611
2539
|
});
|
|
2612
2540
|
}
|
|
@@ -2904,8 +2832,7 @@ var sendMessageMetrics = (logger2, metrics) => {
|
|
|
2904
2832
|
function loadStreamingFunction(functionFilePath) {
|
|
2905
2833
|
let streamingFunctionImport;
|
|
2906
2834
|
try {
|
|
2907
|
-
|
|
2908
|
-
streamingFunctionImport = require(pathWithoutExt);
|
|
2835
|
+
streamingFunctionImport = require(functionFilePath.substring(0, functionFilePath.length - 3));
|
|
2909
2836
|
} catch (e) {
|
|
2910
2837
|
cliLog({ action: "Function", message: `${e}`, message_type: "Error" });
|
|
2911
2838
|
throw e;
|
|
@@ -3177,32 +3104,18 @@ var runStreamingFunctions = async (args) => {
|
|
|
3177
3104
|
};
|
|
3178
3105
|
|
|
3179
3106
|
// src/moduleExportSerializer.ts
|
|
3180
|
-
init_compiler_config();
|
|
3181
3107
|
async function runExportSerializer(targetModel) {
|
|
3182
|
-
const
|
|
3183
|
-
const sourceDir = getSourceDir();
|
|
3184
|
-
let modulePath = targetModel;
|
|
3185
|
-
if (useCompiled2) {
|
|
3186
|
-
if (modulePath.includes(sourceDir)) {
|
|
3187
|
-
modulePath = modulePath.replace(
|
|
3188
|
-
new RegExp(`/${sourceDir}/`),
|
|
3189
|
-
`/.moose/compiled/${sourceDir}/`
|
|
3190
|
-
);
|
|
3191
|
-
}
|
|
3192
|
-
modulePath = modulePath.replace(/\.ts$/, ".js");
|
|
3193
|
-
}
|
|
3194
|
-
const exports_list = require(modulePath);
|
|
3108
|
+
const exports_list = require(targetModel);
|
|
3195
3109
|
console.log(JSON.stringify(exports_list));
|
|
3196
3110
|
}
|
|
3197
3111
|
|
|
3198
3112
|
// src/consumption-apis/exportTypeSerializer.ts
|
|
3199
3113
|
var import_process2 = __toESM(require("process"));
|
|
3200
|
-
|
|
3114
|
+
function getSourceDir2() {
|
|
3115
|
+
return import_process2.default.env.MOOSE_SOURCE_DIR || "app";
|
|
3116
|
+
}
|
|
3201
3117
|
async function runApiTypeSerializer(targetModel) {
|
|
3202
|
-
const
|
|
3203
|
-
const useCompiled2 = shouldUseCompiled();
|
|
3204
|
-
const apiPath = useCompiled2 ? `${import_process2.default.cwd()}/.moose/compiled/${sourceDir}/apis/${targetModel}.js` : `${import_process2.default.cwd()}/${sourceDir}/apis/${targetModel}.ts`;
|
|
3205
|
-
const func = require(apiPath).default;
|
|
3118
|
+
const func = require(`${import_process2.default.cwd()}/${getSourceDir2()}/apis/${targetModel}.ts`).default;
|
|
3206
3119
|
const inputSchema = func["moose_input_schema"] || null;
|
|
3207
3120
|
const outputSchema = func["moose_output_schema"] || null;
|
|
3208
3121
|
console.log(
|
|
@@ -3215,7 +3128,7 @@ async function runApiTypeSerializer(targetModel) {
|
|
|
3215
3128
|
|
|
3216
3129
|
// src/scripts/runner.ts
|
|
3217
3130
|
var import_worker2 = require("@temporalio/worker");
|
|
3218
|
-
var
|
|
3131
|
+
var path4 = __toESM(require("path"));
|
|
3219
3132
|
var fs4 = __toESM(require("fs"));
|
|
3220
3133
|
init_internal();
|
|
3221
3134
|
|
|
@@ -3508,7 +3421,7 @@ async function registerWorkflows(logger2, config) {
|
|
|
3508
3421
|
}
|
|
3509
3422
|
};
|
|
3510
3423
|
const workflowBundle = await (0, import_worker2.bundleWorkflowCode)({
|
|
3511
|
-
workflowsPath:
|
|
3424
|
+
workflowsPath: path4.resolve(__dirname, "scripts/workflow.js"),
|
|
3512
3425
|
logger: silentLogger
|
|
3513
3426
|
});
|
|
3514
3427
|
const worker = await import_worker2.Worker.create({
|
|
@@ -3589,27 +3502,31 @@ async function runScripts(config) {
|
|
|
3589
3502
|
// src/moose-runner.ts
|
|
3590
3503
|
var import_process3 = __toESM(require("process"));
|
|
3591
3504
|
var import_commander = require("commander");
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3505
|
+
if (import_process3.default.argv[2] == "consumption-apis" || import_process3.default.argv[2] == "consumption-type-serializer" || import_process3.default.argv[2] == "dmv2-serializer" || // Streaming functions for dmv2 need to load moose internals
|
|
3506
|
+
import_process3.default.argv[2] == "streaming-functions" || import_process3.default.argv[2] == "scripts") {
|
|
3507
|
+
(0, import_ts_node.register)({
|
|
3508
|
+
require: ["tsconfig-paths/register"],
|
|
3509
|
+
esm: true,
|
|
3510
|
+
experimentalTsImportSpecifiers: true,
|
|
3511
|
+
compiler: "ts-patch/compiler",
|
|
3512
|
+
compilerOptions: {
|
|
3513
|
+
plugins: [
|
|
3514
|
+
{
|
|
3515
|
+
transform: `./node_modules/@514labs/moose-lib/dist/compilerPlugin.js`,
|
|
3516
|
+
transformProgram: true
|
|
3517
|
+
},
|
|
3518
|
+
{
|
|
3519
|
+
transform: "typia/lib/transform"
|
|
3520
|
+
}
|
|
3521
|
+
],
|
|
3522
|
+
experimentalDecorators: true
|
|
3523
|
+
}
|
|
3524
|
+
});
|
|
3525
|
+
} else {
|
|
3526
|
+
(0, import_ts_node.register)({
|
|
3527
|
+
esm: true,
|
|
3528
|
+
experimentalTsImportSpecifiers: true
|
|
3529
|
+
});
|
|
3613
3530
|
}
|
|
3614
3531
|
var program = new import_commander.Command();
|
|
3615
3532
|
program.name("moose-runner").description("Moose runner for various operations").version("1.0.0");
|