@514labs/moose-lib 0.6.260-ci-5-g3b5261dd → 0.6.260-ci-2-g1b93253f

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.
@@ -111,8 +111,49 @@ function isTruthy(value) {
111
111
  return false;
112
112
  }
113
113
  }
114
- var compilerLog = (message) => {
115
- if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
114
+ function parseLogLevel(value) {
115
+ if (!value) return "Info" /* Info */;
116
+ const normalized = value.trim();
117
+ switch (normalized) {
118
+ case "Debug":
119
+ case "debug":
120
+ case "DEBUG":
121
+ return "Debug" /* Debug */;
122
+ case "Info":
123
+ case "info":
124
+ case "INFO":
125
+ return "Info" /* Info */;
126
+ case "Warn":
127
+ case "warn":
128
+ case "WARN":
129
+ return "Warn" /* Warn */;
130
+ case "Error":
131
+ case "error":
132
+ case "ERROR":
133
+ return "Error" /* Error */;
134
+ default:
135
+ return "Info" /* Info */;
136
+ }
137
+ }
138
+ var cachedLogLevel = null;
139
+ function getLogLevel() {
140
+ if (cachedLogLevel === null) {
141
+ cachedLogLevel = parseLogLevel(process.env.MOOSE_LOGGER__LEVEL);
142
+ }
143
+ return cachedLogLevel;
144
+ }
145
+ var compilerLog = (message, level = "Debug" /* Debug */) => {
146
+ if (isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
147
+ return;
148
+ }
149
+ const currentLevel = getLogLevel();
150
+ const levelPriority = {
151
+ ["Debug" /* Debug */]: 0,
152
+ ["Info" /* Info */]: 1,
153
+ ["Warn" /* Warn */]: 2,
154
+ ["Error" /* Error */]: 3
155
+ };
156
+ if (levelPriority[level] >= levelPriority[currentLevel]) {
116
157
  console.log(message);
117
158
  }
118
159
  };
@@ -1628,14 +1669,20 @@ var createTypiaImport = () => factory4.createImportDeclaration(
1628
1669
  );
1629
1670
  var applyTransformation = (node, typeChecker) => {
1630
1671
  if (isCreateApi(node, typeChecker)) {
1631
- compilerLog("[CompilerPlugin] Found legacy API, transforming...");
1672
+ compilerLog(
1673
+ "[CompilerPlugin] Found legacy API, transforming...",
1674
+ "Debug" /* Debug */
1675
+ );
1632
1676
  return {
1633
1677
  transformed: transformLegacyApi(node, typeChecker),
1634
1678
  wasTransformed: true
1635
1679
  };
1636
1680
  }
1637
1681
  if (isCreateApiV2(node, typeChecker)) {
1638
- compilerLog("[CompilerPlugin] Found API v2, transforming...");
1682
+ compilerLog(
1683
+ "[CompilerPlugin] Found API v2, transforming...",
1684
+ "Debug" /* Debug */
1685
+ );
1639
1686
  return {
1640
1687
  transformed: transformCreateApi(node, typeChecker),
1641
1688
  wasTransformed: true
@@ -1643,7 +1690,8 @@ var applyTransformation = (node, typeChecker) => {
1643
1690
  }
1644
1691
  if (isNewMooseResourceWithTypeParam(node, typeChecker)) {
1645
1692
  compilerLog(
1646
- "[CompilerPlugin] Found Moose resource with type param, transforming..."
1693
+ "[CompilerPlugin] Found Moose resource with type param, transforming...",
1694
+ "Debug" /* Debug */
1647
1695
  );
1648
1696
  return {
1649
1697
  transformed: transformNewMooseResource(node, typeChecker),
@@ -1667,18 +1715,23 @@ var hasExistingTypiaImport = (sourceFile) => {
1667
1715
  return false;
1668
1716
  });
1669
1717
  compilerLog(
1670
- `[CompilerPlugin] Checking for existing typia import (${avoidTypiaNameClash}) in ${sourceFile.fileName}: ${hasImport}`
1718
+ `[CompilerPlugin] Checking for existing typia import (${avoidTypiaNameClash}) in ${sourceFile.fileName}: ${hasImport}`,
1719
+ "Debug" /* Debug */
1671
1720
  );
1672
1721
  return hasImport;
1673
1722
  };
1674
1723
  var addTypiaImport = (sourceFile) => {
1675
1724
  if (hasExistingTypiaImport(sourceFile)) {
1676
1725
  compilerLog(
1677
- `[CompilerPlugin] Typia import already exists in ${sourceFile.fileName}, skipping...`
1726
+ `[CompilerPlugin] Typia import already exists in ${sourceFile.fileName}, skipping...`,
1727
+ "Debug" /* Debug */
1678
1728
  );
1679
1729
  return sourceFile;
1680
1730
  }
1681
- compilerLog(`[CompilerPlugin] Adding typia import to ${sourceFile.fileName}`);
1731
+ compilerLog(
1732
+ `[CompilerPlugin] Adding typia import to ${sourceFile.fileName}`,
1733
+ "Debug" /* Debug */
1734
+ );
1682
1735
  const statementsWithImport = factory4.createNodeArray([
1683
1736
  createTypiaImport(),
1684
1737
  ...sourceFile.statements
@@ -1688,7 +1741,8 @@ var addTypiaImport = (sourceFile) => {
1688
1741
  var transform = (typeChecker) => (_context) => (sourceFile) => {
1689
1742
  compilerLog(
1690
1743
  `
1691
- [CompilerPlugin] ========== Processing file: ${sourceFile.fileName} ==========`
1744
+ [CompilerPlugin] ========== Processing file: ${sourceFile.fileName} ==========`,
1745
+ "Debug" /* Debug */
1692
1746
  );
1693
1747
  let transformationCount = 0;
1694
1748
  let hasTypiaTransformations = false;
@@ -1701,7 +1755,8 @@ var transform = (typeChecker) => (_context) => (sourceFile) => {
1701
1755
  transformationCount++;
1702
1756
  hasTypiaTransformations = true;
1703
1757
  compilerLog(
1704
- `[CompilerPlugin] Transformation #${transformationCount} applied at position ${node.pos}`
1758
+ `[CompilerPlugin] Transformation #${transformationCount} applied at position ${node.pos}`,
1759
+ "Debug" /* Debug */
1705
1760
  );
1706
1761
  }
1707
1762
  return ts6.visitEachChild(transformed, visitNode, void 0);
@@ -1712,22 +1767,26 @@ var transform = (typeChecker) => (_context) => (sourceFile) => {
1712
1767
  void 0
1713
1768
  );
1714
1769
  compilerLog(
1715
- `[CompilerPlugin] Total transformations applied: ${transformationCount}`
1770
+ `[CompilerPlugin] Total transformations applied: ${transformationCount}`,
1771
+ "Debug" /* Debug */
1716
1772
  );
1717
1773
  compilerLog(
1718
- `[CompilerPlugin] Needs typia import: ${hasTypiaTransformations}`
1774
+ `[CompilerPlugin] Needs typia import: ${hasTypiaTransformations}`,
1775
+ "Debug" /* Debug */
1719
1776
  );
1720
1777
  if (hasTypiaTransformations) {
1721
1778
  const result = addTypiaImport(transformedSourceFile);
1722
1779
  compilerLog(
1723
1780
  `[CompilerPlugin] ========== Completed processing ${sourceFile.fileName} (with import) ==========
1724
- `
1781
+ `,
1782
+ "Debug" /* Debug */
1725
1783
  );
1726
1784
  return result;
1727
1785
  } else {
1728
1786
  compilerLog(
1729
1787
  `[CompilerPlugin] ========== Completed processing ${sourceFile.fileName} (no import needed) ==========
1730
- `
1788
+ `,
1789
+ "Debug" /* Debug */
1731
1790
  );
1732
1791
  return transformedSourceFile;
1733
1792
  }