@omen.foundation/node-microservice-runtime 0.1.103 → 0.1.104

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omen.foundation/node-microservice-runtime",
3
- "version": "0.1.103",
3
+ "version": "0.1.104",
4
4
  "description": "Beamable microservice runtime for Node.js/TypeScript services.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -747,19 +747,39 @@ async function fetchCurrentManifest(apiHost, token, cid, pid) {
747
747
  return response.json();
748
748
  }
749
749
 
750
- async function discoverStorageObjects(srcDir) {
750
+ async function discoverStorageObjects(srcDir, cwd = process.cwd()) {
751
751
  const storageObjects = [];
752
752
  try {
753
- const srcPath = path.resolve(srcDir || 'src');
753
+ // Resolve src path relative to current working directory (where publish is run from)
754
+ const srcPath = path.isAbsolute(srcDir) ? srcDir : path.resolve(cwd, srcDir || 'src');
755
+
756
+ console.log(`[beamo-node] Searching for @StorageObject decorators in: ${srcPath}`);
757
+
758
+ // Check if directory exists
759
+ try {
760
+ const stats = await fs.stat(srcPath);
761
+ if (!stats.isDirectory()) {
762
+ console.warn(`[beamo-node] Warning: ${srcPath} is not a directory`);
763
+ return storageObjects;
764
+ }
765
+ } catch (error) {
766
+ console.warn(`[beamo-node] Warning: Directory ${srcPath} does not exist`);
767
+ return storageObjects;
768
+ }
769
+
754
770
  const files = await getAllTypeScriptFiles(srcPath);
755
771
 
756
772
  if (files.length === 0) {
757
773
  console.warn(`[beamo-node] Warning: No TypeScript files found in ${srcPath}`);
774
+ return storageObjects;
758
775
  }
759
776
 
777
+ console.log(`[beamo-node] Scanning ${files.length} TypeScript file(s) for @StorageObject decorators...`);
778
+
760
779
  for (const file of files) {
761
780
  const content = await fs.readFile(file, 'utf-8');
762
- // Match @StorageObject('StorageName') pattern
781
+ // Match @StorageObject('StorageName') pattern - handle both single and double quotes
782
+ // Also match multiline patterns where decorator might be on a different line
763
783
  const storageRegex = /@StorageObject\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
764
784
  let match;
765
785
  while ((match = storageRegex.exec(content)) !== null) {
@@ -771,16 +791,20 @@ async function discoverStorageObjects(srcDir) {
771
791
  checksum: null,
772
792
  archived: false,
773
793
  });
774
- console.log(`[beamo-node] Discovered storage object: ${storageName}`);
794
+ console.log(`[beamo-node] Discovered storage object: ${storageName} (from ${path.relative(cwd, file)})`);
775
795
  }
776
796
  }
777
797
  }
778
798
 
779
799
  if (storageObjects.length === 0) {
780
- console.log(`[beamo-node] No @StorageObject decorators found in ${srcPath}`);
800
+ console.log(`[beamo-node] No @StorageObject decorators found in ${files.length} file(s) in ${srcPath}`);
801
+ console.log(`[beamo-node] Make sure your storage classes are decorated with @StorageObject('StorageName')`);
781
802
  }
782
803
  } catch (error) {
783
804
  console.warn(`[beamo-node] Error discovering storage objects: ${error instanceof Error ? error.message : String(error)}`);
805
+ if (error instanceof Error && error.stack) {
806
+ console.warn(`[beamo-node] Stack: ${error.stack}`);
807
+ }
784
808
  // If we can't discover storage, that's okay - we'll just use existing ones
785
809
  }
786
810
  return storageObjects;
@@ -1458,7 +1482,7 @@ async function main() {
1458
1482
  progress.start('Discovering storage objects and components');
1459
1483
  // shortImageId already defined above from verification step
1460
1484
  const existingManifest = await fetchCurrentManifest(apiHost, token, cid, pid);
1461
- const discoveredStorage = await discoverStorageObjects('src');
1485
+ const discoveredStorage = await discoverStorageObjects('src', process.cwd());
1462
1486
  const discoveredComponents = await discoverFederationComponents('src');
1463
1487
  // Dependencies are ServiceDependencyReference objects with id and storageType
1464
1488
  // storageType should be "mongov1" for MongoDB storage objects (matching C# microservices)