@bayoudhi/moose-lib-serverless 0.7.1 → 0.7.3

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.
@@ -1,28 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
3
+ var __create2 = Object.create;
4
+ var __defProp2 = Object.defineProperty;
5
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
7
+ var __getProtoOf2 = Object.getPrototypeOf;
8
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
9
9
  var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
11
  };
12
- var __copyProps = (to, from, except, desc) => {
12
+ var __copyProps2 = (to, from, except, desc) => {
13
13
  if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ for (let key of __getOwnPropNames2(from))
15
+ if (!__hasOwnProp2.call(to, key) && key !== except)
16
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
21
21
  // If the importer is in node compatibility mode or this is not an ESM
22
22
  // file that has been converted to a CommonJS file using a Babel-
23
23
  // compatible transform (i.e. "__esModule" has not been set), then set
24
24
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
26
26
  mod
27
27
  ));
28
28
 
@@ -261,118 +261,35 @@ var require_workflow = __commonJS({
261
261
  });
262
262
 
263
263
  // src/moose-runner.ts
264
- var __create2 = Object.create;
265
- var __defProp2 = Object.defineProperty;
266
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
267
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
268
- var __getProtoOf2 = Object.getPrototypeOf;
269
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
264
+ var __create = Object.create;
265
+ var __defProp = Object.defineProperty;
266
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
267
+ var __getOwnPropNames = Object.getOwnPropertyNames;
268
+ var __getProtoOf = Object.getPrototypeOf;
269
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
270
270
  var __esm = (fn, res) => function __init() {
271
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
271
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
272
272
  };
273
273
  var __export = (target, all) => {
274
274
  for (var name in all)
275
- __defProp2(target, name, { get: all[name], enumerable: true });
275
+ __defProp(target, name, { get: all[name], enumerable: true });
276
276
  };
277
- var __copyProps2 = (to, from, except, desc) => {
277
+ var __copyProps = (to, from, except, desc) => {
278
278
  if (from && typeof from === "object" || typeof from === "function") {
279
- for (let key of __getOwnPropNames2(from))
280
- if (!__hasOwnProp2.call(to, key) && key !== except)
281
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
279
+ for (let key of __getOwnPropNames(from))
280
+ if (!__hasOwnProp.call(to, key) && key !== except)
281
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
282
282
  }
283
283
  return to;
284
284
  };
285
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
285
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
286
286
  // If the importer is in node compatibility mode or this is not an ESM
287
287
  // file that has been converted to a CommonJS file using a Babel-
288
288
  // compatible transform (i.e. "__esModule" has not been set), then set
289
289
  // "default" to the CommonJS "module.exports" for node compatibility.
290
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
290
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
291
291
  mod
292
292
  ));
293
- function getSourceDir() {
294
- return process.env.MOOSE_SOURCE_DIR || "app";
295
- }
296
- function hasCompiledArtifacts(projectRoot = process.cwd()) {
297
- const sourceDir = getSourceDir();
298
- const compiledIndexPath = import_path.default.join(
299
- projectRoot,
300
- ".moose",
301
- "compiled",
302
- sourceDir,
303
- "index.js"
304
- );
305
- return (0, import_fs.existsSync)(compiledIndexPath);
306
- }
307
- function shouldUseCompiled(projectRoot = process.cwd()) {
308
- const envSaysCompiled = process.env.MOOSE_USE_COMPILED === "true";
309
- if (!envSaysCompiled) {
310
- return false;
311
- }
312
- const hasArtifacts = hasCompiledArtifacts(projectRoot);
313
- if (!hasArtifacts) {
314
- console.warn(
315
- `[moose] MOOSE_USE_COMPILED=true but no compiled artifacts found at .moose/compiled/${getSourceDir()}/index.js. Falling back to ts-node.`
316
- );
317
- }
318
- return hasArtifacts;
319
- }
320
- function detectModuleSystem(projectRoot = process.cwd()) {
321
- const pkgPath = import_path.default.join(projectRoot, "package.json");
322
- if ((0, import_fs.existsSync)(pkgPath)) {
323
- try {
324
- const pkgContent = (0, import_fs.readFileSync)(pkgPath, "utf-8");
325
- const pkg = JSON.parse(pkgContent);
326
- if (pkg.type === "module") {
327
- return "esm";
328
- }
329
- } catch (e) {
330
- console.debug(
331
- `[moose] Failed to parse package.json at ${pkgPath}, defaulting to CJS:`,
332
- e
333
- );
334
- }
335
- }
336
- return "cjs";
337
- }
338
- async function loadModule(modulePath, projectRoot = process.cwd()) {
339
- const moduleSystem = detectModuleSystem(projectRoot);
340
- if (moduleSystem === "esm") {
341
- const { pathToFileURL } = await import("url");
342
- const fileUrl = pathToFileURL(modulePath).href;
343
- return await import(fileUrl);
344
- }
345
- return require(modulePath);
346
- }
347
- var import_fs;
348
- var import_path;
349
- var MOOSE_COMPILER_PLUGINS;
350
- var COMMANDS_REQUIRING_PLUGINS;
351
- var init_compiler_config = __esm({
352
- "src/compiler-config.ts"() {
353
- "use strict";
354
- import_fs = require("fs");
355
- import_path = __toESM2(require("path"));
356
- MOOSE_COMPILER_PLUGINS = [
357
- {
358
- transform: "./node_modules/@bayoudhi/moose-lib-serverless/dist/compilerPlugin.js"
359
- // No longer using transformProgram - direct typia integration eliminates
360
- // the need for program replacement and the associated incremental compilation issues
361
- },
362
- {
363
- // Keep typia plugin for users who use typia directly (not through Moose resources)
364
- transform: "typia/lib/transform"
365
- }
366
- ];
367
- COMMANDS_REQUIRING_PLUGINS = [
368
- "consumption-apis",
369
- "consumption-type-serializer",
370
- "dmv2-serializer",
371
- "streaming-functions",
372
- "scripts"
373
- ];
374
- }
375
- });
376
293
  var init_stackTrace = __esm({
377
294
  "src/dmv2/utils/stackTrace.ts"() {
378
295
  "use strict";
@@ -905,7 +822,7 @@ var init_helpers = __esm({
905
822
  import_client2 = require_client();
906
823
  import_node_crypto3 = require("crypto");
907
824
  import_perf_hooks = require("perf_hooks");
908
- fs = __toESM2(require("fs"));
825
+ fs = __toESM(require("fs"));
909
826
  init_internal();
910
827
  init_sqlHelpers();
911
828
  MooseClient = class {
@@ -1102,8 +1019,8 @@ var ConfigError;
1102
1019
  var init_configFile = __esm({
1103
1020
  "src/config/configFile.ts"() {
1104
1021
  "use strict";
1105
- import_node_path = __toESM2(require("path"));
1106
- toml = __toESM2(require("toml"));
1022
+ import_node_path = __toESM(require("path"));
1023
+ toml = __toESM(require("toml"));
1107
1024
  ConfigError = class extends Error {
1108
1025
  constructor(message) {
1109
1026
  super(message);
@@ -1514,6 +1431,112 @@ var init_index = __esm({
1514
1431
  init_types();
1515
1432
  }
1516
1433
  });
1434
+ function getSourceDir() {
1435
+ return process.env.MOOSE_SOURCE_DIR || "app";
1436
+ }
1437
+ function readUserOutDir(projectRoot = process.cwd()) {
1438
+ try {
1439
+ let content = (0, import_fs.readFileSync)(
1440
+ import_path.default.join(projectRoot, "tsconfig.json"),
1441
+ "utf-8"
1442
+ );
1443
+ if (content.charCodeAt(0) === 65279) {
1444
+ content = content.slice(1);
1445
+ }
1446
+ const tsconfig = eval(`(${content})`);
1447
+ return tsconfig.compilerOptions?.outDir || null;
1448
+ } catch {
1449
+ return null;
1450
+ }
1451
+ }
1452
+ function getOutDir(projectRoot2 = process.cwd()) {
1453
+ const userOutDir = readUserOutDir(projectRoot2);
1454
+ return userOutDir || DEFAULT_OUT_DIR;
1455
+ }
1456
+ function getCompiledIndexPath(projectRoot2 = process.cwd()) {
1457
+ const outDir = getOutDir(projectRoot2);
1458
+ const sourceDir = getSourceDir();
1459
+ return import_path.default.resolve(projectRoot2, outDir, sourceDir, "index.js");
1460
+ }
1461
+ function hasCompiledArtifacts(projectRoot2 = process.cwd()) {
1462
+ return (0, import_fs.existsSync)(getCompiledIndexPath(projectRoot2));
1463
+ }
1464
+ function detectModuleSystem(projectRoot2 = process.cwd()) {
1465
+ const pkgPath = import_path.default.join(projectRoot2, "package.json");
1466
+ if ((0, import_fs.existsSync)(pkgPath)) {
1467
+ try {
1468
+ const pkgContent = (0, import_fs.readFileSync)(pkgPath, "utf-8");
1469
+ const pkg = JSON.parse(pkgContent);
1470
+ if (pkg.type === "module") {
1471
+ return "esm";
1472
+ }
1473
+ } catch (e) {
1474
+ console.debug(
1475
+ `[moose] Failed to parse package.json at ${pkgPath}, defaulting to CJS:`,
1476
+ e
1477
+ );
1478
+ }
1479
+ }
1480
+ return "cjs";
1481
+ }
1482
+ function getModuleOptions(moduleSystem) {
1483
+ if (moduleSystem === "esm") {
1484
+ return {
1485
+ module: "ES2022",
1486
+ moduleResolution: "bundler"
1487
+ };
1488
+ }
1489
+ return {
1490
+ module: "CommonJS",
1491
+ moduleResolution: "Node"
1492
+ };
1493
+ }
1494
+ async function loadModule(modulePath, projectRoot2 = process.cwd()) {
1495
+ const moduleSystem = detectModuleSystem(projectRoot2);
1496
+ if (moduleSystem === "esm") {
1497
+ const { pathToFileURL } = await import("url");
1498
+ const fileUrl = pathToFileURL(modulePath).href;
1499
+ return await import(fileUrl);
1500
+ }
1501
+ return require(modulePath);
1502
+ }
1503
+ var import_fs;
1504
+ var import_path;
1505
+ var MOOSE_COMPILER_PLUGINS;
1506
+ var MOOSE_COMPILER_OPTIONS;
1507
+ var MOOSE_MODULE_OPTIONS;
1508
+ var DEFAULT_OUT_DIR;
1509
+ var init_compiler_config = __esm({
1510
+ "src/compiler-config.ts"() {
1511
+ "use strict";
1512
+ import_fs = require("fs");
1513
+ import_path = __toESM(require("path"));
1514
+ MOOSE_COMPILER_PLUGINS = [
1515
+ {
1516
+ transform: "./node_modules/@bayoudhi/moose-lib-serverless/dist/compilerPlugin.js"
1517
+ // No longer using transformProgram - direct typia integration eliminates
1518
+ // the need for program replacement and the associated incremental compilation issues
1519
+ },
1520
+ {
1521
+ // Keep typia plugin for users who use typia directly (not through Moose resources)
1522
+ transform: "typia/lib/transform"
1523
+ }
1524
+ ];
1525
+ MOOSE_COMPILER_OPTIONS = {
1526
+ experimentalDecorators: true,
1527
+ esModuleInterop: true,
1528
+ // Disable strict module syntax checking to avoid dual-package type conflicts
1529
+ // This prevents errors where the same type imported with different resolution
1530
+ // modes (CJS vs ESM) is treated as incompatible
1531
+ verbatimModuleSyntax: false
1532
+ };
1533
+ MOOSE_MODULE_OPTIONS = {
1534
+ module: "NodeNext",
1535
+ moduleResolution: "NodeNext"
1536
+ };
1537
+ DEFAULT_OUT_DIR = ".moose/compiled";
1538
+ }
1539
+ });
1517
1540
  function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"]) {
1518
1541
  const files = [];
1519
1542
  try {
@@ -1539,13 +1562,23 @@ function findSourceFiles(dir, extensions = [".ts", ".tsx", ".js", ".jsx", ".mts"
1539
1562
  }
1540
1563
  return files;
1541
1564
  }
1565
+ function pathStem(filePath) {
1566
+ const ext = path3.extname(filePath);
1567
+ return ext ? filePath.slice(0, -ext.length) : filePath;
1568
+ }
1542
1569
  function findUnloadedFiles() {
1543
- const appDir = path3.resolve(import_process.default.cwd(), getSourceDir());
1570
+ const cwd = import_process.default.cwd();
1571
+ const sourceDir = getSourceDir();
1572
+ const appDir = path3.resolve(cwd, sourceDir);
1573
+ const compiledAppDir = path3.resolve(cwd, getOutDir(), sourceDir);
1544
1574
  const allSourceFiles = findSourceFiles(appDir);
1545
- const loadedFiles = new Set(
1546
- Object.keys(require.cache).filter((key) => key.startsWith(appDir)).map((key) => path3.resolve(key))
1575
+ const loadedStems = new Set(
1576
+ Object.keys(require.cache).filter((key) => key.startsWith(compiledAppDir)).map((key) => pathStem(path3.relative(compiledAppDir, key)))
1547
1577
  );
1548
- const unloadedFiles = allSourceFiles.map((file) => path3.resolve(file)).filter((file) => !loadedFiles.has(file)).map((file) => path3.relative(import_process.default.cwd(), file));
1578
+ const unloadedFiles = allSourceFiles.filter((file) => {
1579
+ const stem = pathStem(path3.relative(appDir, file));
1580
+ return !loadedStems.has(stem);
1581
+ }).map((file) => path3.relative(cwd, file));
1549
1582
  return unloadedFiles;
1550
1583
  }
1551
1584
  function isS3QueueConfig(config) {
@@ -1754,6 +1787,16 @@ function convertKafkaEngineConfig(config) {
1754
1787
  format: config.format
1755
1788
  };
1756
1789
  }
1790
+ function convertMergeEngineConfig(config) {
1791
+ if (!("engine" in config) || config.engine !== "Merge") {
1792
+ return void 0;
1793
+ }
1794
+ return {
1795
+ engine: "Merge",
1796
+ sourceDatabase: config.sourceDatabase,
1797
+ tablesRegexp: config.tablesRegexp
1798
+ };
1799
+ }
1757
1800
  function convertTableConfigToEngineConfig(config) {
1758
1801
  const engine = extractEngineValue(config);
1759
1802
  const basicConfig = convertBasicEngineConfig(engine, config);
@@ -1782,6 +1825,9 @@ function convertTableConfigToEngineConfig(config) {
1782
1825
  if (engine === "Kafka") {
1783
1826
  return convertKafkaEngineConfig(config);
1784
1827
  }
1828
+ if (engine === "Merge") {
1829
+ return convertMergeEngineConfig(config);
1830
+ }
1785
1831
  return void 0;
1786
1832
  }
1787
1833
  function findTaskInTree(task, targetName) {
@@ -1815,9 +1861,9 @@ var getWebApps2;
1815
1861
  var init_internal = __esm({
1816
1862
  "src/dmv2/internal.ts"() {
1817
1863
  "use strict";
1818
- import_process = __toESM2(require("process"));
1819
- fs2 = __toESM2(require("fs"));
1820
- path3 = __toESM2(require("path"));
1864
+ import_process = __toESM(require("process"));
1865
+ fs2 = __toESM(require("fs"));
1866
+ path3 = __toESM(require("path"));
1821
1867
  init_index();
1822
1868
  init_commons();
1823
1869
  init_compiler_config();
@@ -2064,7 +2110,8 @@ var init_internal = __esm({
2064
2110
  sourceTables: mv.sourceTables,
2065
2111
  targetTable: mv.targetTable.name,
2066
2112
  targetDatabase: mv.targetTable.config.database,
2067
- metadata: mv.metadata
2113
+ metadata: mv.metadata,
2114
+ lifeCycle: mv.lifeCycle
2068
2115
  };
2069
2116
  });
2070
2117
  registry.views.forEach((view) => {
@@ -2105,34 +2152,33 @@ var init_internal = __esm({
2105
2152
  );
2106
2153
  };
2107
2154
  loadIndex = async () => {
2108
- const useCompiled2 = shouldUseCompiled();
2109
- if (!useCompiled2) {
2110
- const registry = getMooseInternal();
2111
- registry.tables.clear();
2112
- registry.streams.clear();
2113
- registry.ingestApis.clear();
2114
- registry.apis.clear();
2115
- registry.sqlResources.clear();
2116
- registry.workflows.clear();
2117
- registry.webApps.clear();
2118
- registry.materializedViews.clear();
2119
- registry.views.clear();
2120
- const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
2121
- Object.keys(require.cache).forEach((key) => {
2122
- if (key.startsWith(appDir)) {
2123
- delete require.cache[key];
2124
- }
2125
- });
2126
- }
2127
- try {
2155
+ if (!hasCompiledArtifacts()) {
2156
+ const outDir2 = getOutDir();
2128
2157
  const sourceDir = getSourceDir();
2129
- if (useCompiled2) {
2130
- await loadModule(
2131
- `${import_process.default.cwd()}/.moose/compiled/${sourceDir}/index.js`
2132
- );
2133
- } else {
2134
- require(`${import_process.default.cwd()}/${sourceDir}/index.ts`);
2158
+ throw new Error(
2159
+ `Compiled artifacts not found at ${outDir2}/${sourceDir}/index.js. Run 'npx moose-tspc' to compile your TypeScript first.`
2160
+ );
2161
+ }
2162
+ const registry = getMooseInternal();
2163
+ registry.tables.clear();
2164
+ registry.streams.clear();
2165
+ registry.ingestApis.clear();
2166
+ registry.apis.clear();
2167
+ registry.sqlResources.clear();
2168
+ registry.workflows.clear();
2169
+ registry.webApps.clear();
2170
+ registry.materializedViews.clear();
2171
+ registry.views.clear();
2172
+ const outDir = getOutDir();
2173
+ const compiledDir = path3.isAbsolute(outDir) ? outDir : path3.join(import_process.default.cwd(), outDir);
2174
+ Object.keys(require.cache).forEach((key) => {
2175
+ if (key.startsWith(compiledDir)) {
2176
+ delete require.cache[key];
2135
2177
  }
2178
+ });
2179
+ try {
2180
+ const indexPath = getCompiledIndexPath();
2181
+ await loadModule(indexPath);
2136
2182
  } catch (error) {
2137
2183
  let hint;
2138
2184
  let includeDetails = true;
@@ -2237,14 +2283,15 @@ var init_internal = __esm({
2237
2283
  };
2238
2284
  }
2239
2285
  });
2240
- var import_ts_node = require("ts-node");
2241
- init_compiler_config();
2286
+ var import_fs2 = require("fs");
2287
+ var import_path2 = require("path");
2242
2288
  init_internal();
2243
- var import_http = __toESM2(require("http"));
2289
+ var import_http = __toESM(require("http"));
2290
+ var path4 = __toESM(require("path"));
2244
2291
  init_commons();
2245
2292
  init_helpers();
2246
- var jose = __toESM2(require("jose"));
2247
- var import_node_cluster = __toESM2(require("cluster"));
2293
+ var jose = __toESM(require("jose"));
2294
+ var import_node_cluster = __toESM(require("cluster"));
2248
2295
  var import_node_os = require("os");
2249
2296
  var import_node_process = require("process");
2250
2297
  var DEFAULT_MAX_CPU_USAGE_RATIO = 0.7;
@@ -2450,7 +2497,7 @@ var Cluster = class {
2450
2497
  init_sqlHelpers();
2451
2498
  init_internal();
2452
2499
  init_compiler_config();
2453
- var util = __toESM2(require("util"));
2500
+ var util = __toESM(require("util"));
2454
2501
  var import_async_hooks = require("async_hooks");
2455
2502
  function setupStructuredConsole(getContextField, contextFieldName) {
2456
2503
  const contextStorage = new import_async_hooks.AsyncLocalStorage();
@@ -2573,9 +2620,8 @@ var toClientConfig2 = (config) => ({
2573
2620
  ...config,
2574
2621
  useSSL: config.useSSL ? "true" : "false"
2575
2622
  });
2576
- var createPath = (apisDir, path5, useCompiled2) => {
2577
- const extension = useCompiled2 ? ".js" : ".ts";
2578
- return `${apisDir}${path5}${extension}`;
2623
+ var createPath = (apisDir, path6) => {
2624
+ return `${apisDir}${path6}.js`;
2579
2625
  };
2580
2626
  var httpLogger = (req, res, startMs, apiName) => {
2581
2627
  const logFn = () => console.log(
@@ -2593,9 +2639,10 @@ var apiContextStorage = setupStructuredConsole(
2593
2639
  "api_name"
2594
2640
  );
2595
2641
  var apiHandler = async (publicKey, clickhouseClient, temporalClient, enforceAuth, jwtConfig) => {
2596
- const useCompiled2 = shouldUseCompiled();
2597
2642
  const sourceDir = getSourceDir();
2598
- const actualApisDir = useCompiled2 ? `${process.cwd()}/.moose/compiled/${sourceDir}/apis/` : void 0;
2643
+ const outDir = getOutDir();
2644
+ const outRoot = path4.isAbsolute(outDir) ? outDir : path4.join(process.cwd(), outDir);
2645
+ const actualApisDir = path4.join(outRoot, sourceDir, "apis");
2599
2646
  const apis = await getApis2();
2600
2647
  return async (req, res) => {
2601
2648
  const start = Date.now();
@@ -2634,7 +2681,7 @@ var apiHandler = async (publicKey, clickhouseClient, temporalClient, enforceAuth
2634
2681
  httpLogger(req, res, start);
2635
2682
  return;
2636
2683
  }
2637
- const pathName = actualApisDir ? createPath(actualApisDir, fileName, useCompiled2) : fileName;
2684
+ const pathName = createPath(actualApisDir, fileName);
2638
2685
  const paramsObject = Array.from(url.searchParams.entries()).reduce(
2639
2686
  (obj, [key, value]) => {
2640
2687
  const existingValue = obj[key];
@@ -2907,8 +2954,8 @@ var runApis = async (config) => {
2907
2954
  var import_node_stream2 = require("stream");
2908
2955
  var import_kafka_javascript2 = require_kafka_javascript();
2909
2956
  var import_node_buffer = require("buffer");
2910
- var process3 = __toESM2(require("process"));
2911
- var http2 = __toESM2(require("http"));
2957
+ var process3 = __toESM(require("process"));
2958
+ var http2 = __toESM(require("http"));
2912
2959
  init_commons();
2913
2960
  init_internal();
2914
2961
  init_json();
@@ -3459,42 +3506,20 @@ var runStreamingFunctions = async (args) => {
3459
3506
  };
3460
3507
  init_compiler_config();
3461
3508
  async function runExportSerializer(targetModel) {
3462
- const useCompiled2 = shouldUseCompiled();
3463
3509
  const sourceDir = getSourceDir();
3510
+ const outDir = getOutDir();
3464
3511
  let modulePath = targetModel;
3465
- if (useCompiled2) {
3466
- const sourcePattern = `/${sourceDir}/`;
3467
- if (modulePath.includes(sourcePattern)) {
3468
- modulePath = modulePath.replace(
3469
- sourcePattern,
3470
- `/.moose/compiled/${sourceDir}/`
3471
- );
3472
- }
3473
- modulePath = modulePath.replace(/\.ts$/, ".js");
3512
+ const sourcePattern = `/${sourceDir}/`;
3513
+ if (modulePath.includes(sourcePattern)) {
3514
+ modulePath = modulePath.replace(sourcePattern, `/${outDir}/${sourceDir}/`);
3474
3515
  }
3516
+ modulePath = modulePath.replace(/\.ts$/, ".js");
3475
3517
  const exports_list = await loadModule(modulePath);
3476
3518
  console.log(JSON.stringify(exports_list));
3477
3519
  }
3478
- var import_process2 = __toESM2(require("process"));
3479
- init_compiler_config();
3480
- async function runApiTypeSerializer(targetModel) {
3481
- const sourceDir = getSourceDir();
3482
- const useCompiled2 = shouldUseCompiled();
3483
- const apiPath = useCompiled2 ? `${import_process2.default.cwd()}/.moose/compiled/${sourceDir}/apis/${targetModel}.js` : `${import_process2.default.cwd()}/${sourceDir}/apis/${targetModel}.ts`;
3484
- const module2 = await loadModule(apiPath);
3485
- const func = module2.default;
3486
- const inputSchema = func["moose_input_schema"] || null;
3487
- const outputSchema = func["moose_output_schema"] || null;
3488
- console.log(
3489
- JSON.stringify({
3490
- inputSchema,
3491
- outputSchema
3492
- })
3493
- );
3494
- }
3495
3520
  var import_worker2 = require_worker();
3496
- var path4 = __toESM2(require("path"));
3497
- var fs3 = __toESM2(require("fs"));
3521
+ var path5 = __toESM(require("path"));
3522
+ var fs3 = __toESM(require("fs"));
3498
3523
  init_internal();
3499
3524
  var import_activity = require_activity();
3500
3525
  var import_workflow3 = require_workflow();
@@ -3805,7 +3830,7 @@ async function registerWorkflows(logger2, config) {
3805
3830
  }
3806
3831
  };
3807
3832
  const workflowBundle = await (0, import_worker2.bundleWorkflowCode)({
3808
- workflowsPath: path4.resolve(__dirname, "scripts/workflow.js"),
3833
+ workflowsPath: path5.resolve(__dirname, "scripts/workflow.js"),
3809
3834
  logger: silentLogger
3810
3835
  });
3811
3836
  const worker = await import_worker2.Worker.create({
@@ -3882,32 +3907,13 @@ async function runScripts(config) {
3882
3907
  }
3883
3908
  return worker;
3884
3909
  }
3885
- var import_process3 = __toESM2(require("process"));
3886
3910
  var import_commander = require("commander");
3887
- var useCompiled = shouldUseCompiled();
3888
- if (!useCompiled) {
3889
- const command = import_process3.default.argv[2];
3890
- const needsPlugins = COMMANDS_REQUIRING_PLUGINS.includes(command);
3891
- if (needsPlugins) {
3892
- (0, import_ts_node.register)({
3893
- require: ["tsconfig-paths/register"],
3894
- esm: true,
3895
- experimentalTsImportSpecifiers: true,
3896
- compiler: "ts-patch/compiler",
3897
- compilerOptions: {
3898
- plugins: [...MOOSE_COMPILER_PLUGINS],
3899
- experimentalDecorators: true
3900
- }
3901
- });
3902
- } else {
3903
- (0, import_ts_node.register)({
3904
- esm: true,
3905
- experimentalTsImportSpecifiers: true
3906
- });
3907
- }
3908
- }
3911
+ var packageJson = { version: "0.6.417" };
3909
3912
  var program = new import_commander.Command();
3910
- program.name("moose-runner").description("Moose runner for various operations").version("1.0.0");
3913
+ program.name("moose-runner").description("Moose runner for various operations").version(packageJson.version);
3914
+ program.command("print-version").description("Print the installed moose-lib version").action(() => {
3915
+ process.stdout.write(packageJson.version);
3916
+ });
3911
3917
  program.command("dmv2-serializer").description("Load DMv2 index").action(async () => {
3912
3918
  await dumpMooseInternal();
3913
3919
  });
@@ -3971,9 +3977,6 @@ program.command("streaming-functions").description("Run streaming functions").ar
3971
3977
  runStreamingFunctions(config);
3972
3978
  }
3973
3979
  );
3974
- program.command("consumption-type-serializer").description("Run consumption type serializer").argument("<target-model>", "Target model to serialize").action(async (targetModel) => {
3975
- await runApiTypeSerializer(targetModel);
3976
- });
3977
3980
  program.command("scripts").description("Run scripts").option("--temporal-url <url>", "Temporal server URL").option("--temporal-namespace <namespace>", "Temporal namespace").option("--client-cert <path>", "Path to client certificate").option("--client-key <path>", "Path to client key").option("--api-key <key>", "API key for authentication").action((options) => {
3978
3981
  runScripts({
3979
3982
  temporalConfig: options.temporalUrl ? {