@onlineapps/service-wrapper 2.1.10 → 2.1.11

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": "@onlineapps/service-wrapper",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Thin orchestration layer for microservices - delegates all infrastructure concerns to specialized connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -76,8 +76,26 @@ class ConfigLoader {
76
76
  return CONFIG_REGISTRY;
77
77
  }
78
78
 
79
+ /**
80
+ * Load version from package.json (Single Source of Truth)
81
+ * @param {string} basePath - Base path (defaults to process.cwd())
82
+ * @returns {string} Package version
83
+ */
84
+ static loadPackageVersion(basePath = process.cwd()) {
85
+ const packagePath = path.join(basePath, 'package.json');
86
+ try {
87
+ const content = fs.readFileSync(packagePath, 'utf8');
88
+ const pkg = JSON.parse(content);
89
+ return pkg.version || '0.0.0';
90
+ } catch (error) {
91
+ console.warn(`[ConfigLoader] Could not read package.json version: ${error.message}`);
92
+ return '0.0.0';
93
+ }
94
+ }
95
+
79
96
  /**
80
97
  * Load service configuration from conn-config/config.json
98
+ * Version is always taken from package.json (Single Source of Truth)
81
99
  * @param {string} basePath - Base path (defaults to process.cwd())
82
100
  * @returns {Object} Service configuration
83
101
  * @throws {Error} If config file not found or invalid JSON
@@ -89,11 +107,14 @@ class ConfigLoader {
89
107
  const content = fs.readFileSync(configPath, 'utf8');
90
108
  const config = JSON.parse(content);
91
109
 
92
- // Validate required fields
93
- if (!config.service || !config.service.name || !config.service.version) {
94
- throw new Error('Invalid config.json: Missing required fields (service.name, service.version)');
110
+ // Validate required fields (version not required - comes from package.json)
111
+ if (!config.service || !config.service.name) {
112
+ throw new Error('Invalid config.json: Missing required field (service.name)');
95
113
  }
96
114
 
115
+ // Always use version from package.json (Single Source of Truth)
116
+ config.service.version = this.loadPackageVersion(basePath);
117
+
97
118
  return config;
98
119
  } catch (error) {
99
120
  if (error.code === 'ENOENT') {
package/src/index.js CHANGED
@@ -116,4 +116,4 @@ module.exports.ServiceWrapper = ServiceWrapper;
116
116
  module.exports.ConfigLoader = ConfigLoader;
117
117
  module.exports.bootstrap = bootstrap;
118
118
  module.exports.default = ServiceWrapper;
119
- module.exports.VERSION = '2.1.10';
119
+ module.exports.VERSION = '2.1.11';