@514labs/moose-lib 0.6.320-ci-4-g05309f4d → 0.6.321

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