@514labs/moose-lib 0.6.320-ci-6-g6656ed59 → 0.6.321-ci-8-g6956014f

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.
@@ -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"() {
@@ -1278,7 +1225,7 @@ var init_runner = __esm({
1278
1225
  ...config,
1279
1226
  useSSL: config.useSSL ? "true" : "false"
1280
1227
  });
1281
- createPath = (apisDir, path6) => `${apisDir}${path6}.ts`;
1228
+ createPath = (apisDir, path5) => `${apisDir}${path5}.ts`;
1282
1229
  httpLogger = (req, res, startMs) => {
1283
1230
  console.log(
1284
1231
  `${req.method} ${req.url} ${res.statusCode} ${Date.now() - startMs}ms`
@@ -1781,12 +1728,15 @@ var init_index = __esm({
1781
1728
  });
1782
1729
 
1783
1730
  // src/dmv2/internal.ts
1731
+ function getSourceDir() {
1732
+ return import_process.default.env.MOOSE_SOURCE_DIR || "app";
1733
+ }
1784
1734
  function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
1785
1735
  const files = [];
1786
1736
  try {
1787
1737
  const entries = fs2.readdirSync(dir, { withFileTypes: true });
1788
1738
  for (const entry of entries) {
1789
- const fullPath = path3.join(dir, entry.name);
1739
+ const fullPath = path2.join(dir, entry.name);
1790
1740
  if (entry.isDirectory()) {
1791
1741
  if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
1792
1742
  files.push(...findSourceFiles(fullPath, extensions));
@@ -1795,7 +1745,7 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
1795
1745
  if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".d.mts") || entry.name.endsWith(".d.cts")) {
1796
1746
  continue;
1797
1747
  }
1798
- const ext = path3.extname(entry.name);
1748
+ const ext = path2.extname(entry.name);
1799
1749
  if (extensions.includes(ext)) {
1800
1750
  files.push(fullPath);
1801
1751
  }
@@ -1807,12 +1757,12 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
1807
1757
  return files;
1808
1758
  }
1809
1759
  function findUnloadedFiles() {
1810
- const appDir = path3.resolve(import_process.default.cwd(), getSourceDir());
1760
+ const appDir = path2.resolve(import_process.default.cwd(), getSourceDir());
1811
1761
  const allSourceFiles = findSourceFiles(appDir);
1812
1762
  const loadedFiles = new Set(
1813
- Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) => path3.resolve(key))
1763
+ Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) => path2.resolve(key))
1814
1764
  );
1815
- const unloadedFiles = allSourceFiles.map((file) => path3.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path3.relative(import_process.default.cwd(), file));
1765
+ const unloadedFiles = allSourceFiles.map((file) => path2.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path2.relative(import_process.default.cwd(), file));
1816
1766
  return unloadedFiles;
1817
1767
  }
1818
1768
  function isS3QueueConfig(config) {
@@ -2065,16 +2015,15 @@ function findTaskInTree(task, targetName) {
2065
2015
  }
2066
2016
  return void 0;
2067
2017
  }
2068
- var import_process, fs2, path3, moose_internal, defaultRetentionPeriod, toInfraMap, getMooseInternal, dumpMooseInternal, loadIndex, getStreamingFunctions, getApis2, getWorkflows2, getTaskForWorkflow, getWebApps2;
2018
+ var import_process, fs2, path2, moose_internal, defaultRetentionPeriod, toInfraMap, getMooseInternal, dumpMooseInternal, loadIndex, getStreamingFunctions, getApis2, getWorkflows2, getTaskForWorkflow, getWebApps2;
2069
2019
  var init_internal = __esm({
2070
2020
  "src/dmv2/internal.ts"() {
2071
2021
  "use strict";
2072
2022
  import_process = __toESM(require("process"));
2073
2023
  fs2 = __toESM(require("fs"));
2074
- path3 = __toESM(require("path"));
2024
+ path2 = __toESM(require("path"));
2075
2025
  init_index();
2076
2026
  init_commons();
2077
- init_compiler_config();
2078
2027
  moose_internal = {
2079
2028
  tables: /* @__PURE__ */ new Map(),
2080
2029
  streams: /* @__PURE__ */ new Map(),
@@ -2359,7 +2308,6 @@ var init_internal = __esm({
2359
2308
  );
2360
2309
  };
2361
2310
  loadIndex = () => {
2362
- const useCompiled2 = shouldUseCompiled();
2363
2311
  const registry = getMooseInternal();
2364
2312
  registry.tables.clear();
2365
2313
  registry.streams.clear();
@@ -2370,21 +2318,14 @@ var init_internal = __esm({
2370
2318
  registry.webApps.clear();
2371
2319
  registry.materializedViews.clear();
2372
2320
  registry.views.clear();
2373
- if (!useCompiled2) {
2374
- const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
2375
- Object.keys(require.cache).forEach((key) => {
2376
- if (key.startsWith(appDir)) {
2377
- delete require.cache[key];
2378
- }
2379
- });
2380
- }
2381
- try {
2382
- const sourceDir = getSourceDir();
2383
- if (useCompiled2) {
2384
- require(`${import_process.default.cwd()}/.moose/compiled/${sourceDir}/index.js`);
2385
- } else {
2386
- 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];
2387
2325
  }
2326
+ });
2327
+ try {
2328
+ require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
2388
2329
  } catch (error) {
2389
2330
  let hint;
2390
2331
  let includeDetails = true;
@@ -2492,7 +2433,6 @@ var init_internal = __esm({
2492
2433
 
2493
2434
  // src/moose-runner.ts
2494
2435
  var import_ts_node = require("ts-node");
2495
- init_compiler_config();
2496
2436
  init_internal();
2497
2437
 
2498
2438
  // src/blocks/runner.ts
@@ -2582,10 +2522,10 @@ var runBlocks = async (config) => {
2582
2522
  }
2583
2523
  }
2584
2524
  });
2585
- for (const path6 of blocksFiles) {
2586
- console.log(`Adding to queue: ${path6}`);
2525
+ for (const path5 of blocksFiles) {
2526
+ console.log(`Adding to queue: ${path5}`);
2587
2527
  try {
2588
- const blocks = require(path6).default;
2528
+ const blocks = require(path5).default;
2589
2529
  queue.push({
2590
2530
  chClient,
2591
2531
  blocks,
@@ -2594,7 +2534,7 @@ var runBlocks = async (config) => {
2594
2534
  } catch (err) {
2595
2535
  cliLog({
2596
2536
  action: "Blocks",
2597
- message: `Failed to import blocks from ${path6}: ${err}`,
2537
+ message: `Failed to import blocks from ${path5}: ${err}`,
2598
2538
  message_type: "Error"
2599
2539
  });
2600
2540
  }
@@ -3171,9 +3111,11 @@ async function runExportSerializer(targetModel) {
3171
3111
 
3172
3112
  // src/consumption-apis/exportTypeSerializer.ts
3173
3113
  var import_process2 = __toESM(require("process"));
3174
- init_compiler_config();
3114
+ function getSourceDir2() {
3115
+ return import_process2.default.env.MOOSE_SOURCE_DIR || "app";
3116
+ }
3175
3117
  async function runApiTypeSerializer(targetModel) {
3176
- const func = require(`${import_process2.default.cwd()}/${getSourceDir()}/apis/${targetModel}.ts`).default;
3118
+ const func = require(`${import_process2.default.cwd()}/${getSourceDir2()}/apis/${targetModel}.ts`).default;
3177
3119
  const inputSchema = func["moose_input_schema"] || null;
3178
3120
  const outputSchema = func["moose_output_schema"] || null;
3179
3121
  console.log(
@@ -3186,7 +3128,7 @@ async function runApiTypeSerializer(targetModel) {
3186
3128
 
3187
3129
  // src/scripts/runner.ts
3188
3130
  var import_worker2 = require("@temporalio/worker");
3189
- var path5 = __toESM(require("path"));
3131
+ var path4 = __toESM(require("path"));
3190
3132
  var fs4 = __toESM(require("fs"));
3191
3133
  init_internal();
3192
3134
 
@@ -3479,7 +3421,7 @@ async function registerWorkflows(logger2, config) {
3479
3421
  }
3480
3422
  };
3481
3423
  const workflowBundle = await (0, import_worker2.bundleWorkflowCode)({
3482
- workflowsPath: path5.resolve(__dirname, "scripts/workflow.js"),
3424
+ workflowsPath: path4.resolve(__dirname, "scripts/workflow.js"),
3483
3425
  logger: silentLogger
3484
3426
  });
3485
3427
  const worker = await import_worker2.Worker.create({
@@ -3560,27 +3502,31 @@ async function runScripts(config) {
3560
3502
  // src/moose-runner.ts
3561
3503
  var import_process3 = __toESM(require("process"));
3562
3504
  var import_commander = require("commander");
3563
- var useCompiled = shouldUseCompiled();
3564
- if (!useCompiled) {
3565
- const command = import_process3.default.argv[2];
3566
- const needsPlugins = COMMANDS_REQUIRING_PLUGINS.includes(command);
3567
- if (needsPlugins) {
3568
- (0, import_ts_node.register)({
3569
- require: ["tsconfig-paths/register"],
3570
- esm: true,
3571
- experimentalTsImportSpecifiers: true,
3572
- compiler: "ts-patch/compiler",
3573
- compilerOptions: {
3574
- plugins: [...MOOSE_COMPILER_PLUGINS],
3575
- experimentalDecorators: true
3576
- }
3577
- });
3578
- } else {
3579
- (0, import_ts_node.register)({
3580
- esm: true,
3581
- experimentalTsImportSpecifiers: true
3582
- });
3583
- }
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
+ });
3584
3530
  }
3585
3531
  var program = new import_commander.Command();
3586
3532
  program.name("moose-runner").description("Moose runner for various operations").version("1.0.0");