@arc-js/config-manager 0.0.94 → 0.0.95

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/utils.js ADDED
@@ -0,0 +1,94 @@
1
+ const mergeDeep = (target, source) => {
2
+ if (typeof target !== 'object' || typeof source !== 'object')
3
+ return source;
4
+ const output = Object.assign({}, target);
5
+ for (const key in source) {
6
+ if (source.hasOwnProperty(key)) {
7
+ if (target.hasOwnProperty(key)) {
8
+ output[key] = mergeDeep(target[key], source[key]);
9
+ }
10
+ else {
11
+ output[key] = source[key];
12
+ }
13
+ }
14
+ }
15
+ return output;
16
+ };
17
+
18
+
19
+
20
+
21
+
22
+ function __awaiter(thisArg, _arguments, P, generator) {
23
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
+ return new (P || (P = Promise))(function (resolve, reject) {
25
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
+ step((generator = generator.apply(thisArg, [])).next());
29
+ });
30
+ }
31
+
32
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
33
+ var e = new Error(message);
34
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
35
+ };
36
+
37
+ const loadBaseConfig = (scope, configManagerConfig) => __awaiter(void 0, void 0, void 0, function* () {
38
+ if (!(configManagerConfig === null || configManagerConfig === void 0 ? void 0 : configManagerConfig.base[scope])) {
39
+ console.warn(`❌ No base config found for scope: ${scope}`);
40
+ console.warn('Available scopes:', (configManagerConfig === null || configManagerConfig === void 0 ? void 0 : configManagerConfig.base) ? Object.keys(configManagerConfig.base) : 'none');
41
+ return {};
42
+ }
43
+ try {
44
+ const loader = configManagerConfig.base[scope];
45
+ const result = yield loader();
46
+ return result;
47
+ }
48
+ catch (error) {
49
+ console.error(`❌ Failed to load base ${scope} config`, error);
50
+ return {};
51
+ }
52
+ });
53
+ const loadModulesConfig = (configManagerConfig) => __awaiter(void 0, void 0, void 0, function* () {
54
+ const results = [];
55
+ if (!(configManagerConfig === null || configManagerConfig === void 0 ? void 0 : configManagerConfig.modules)) {
56
+ console.warn(`⚠️ No modules configuration found`);
57
+ return results;
58
+ }
59
+ for (const [moduleName, moduleLoader] of Object.entries(configManagerConfig.modules)) {
60
+ try {
61
+ const config = yield moduleLoader();
62
+ results.push({
63
+ moduleName,
64
+ config
65
+ });
66
+ }
67
+ catch (error) {
68
+ console.error(`❌ Failed to load config for module "${moduleName}"`, error);
69
+ }
70
+ }
71
+ return results;
72
+ });
73
+ const loadModuleConfig = (moduleName, configManagerConfig) => __awaiter(void 0, void 0, void 0, function* () {
74
+ var _a;
75
+ if (!((_a = configManagerConfig === null || configManagerConfig === void 0 ? void 0 : configManagerConfig.modules) === null || _a === void 0 ? void 0 : _a[moduleName])) {
76
+ console.warn(`❌ No config found for module "${moduleName}"`);
77
+ console.warn('Available modules:', (configManagerConfig === null || configManagerConfig === void 0 ? void 0 : configManagerConfig.modules) ? Object.keys(configManagerConfig.modules) : 'none');
78
+ return undefined;
79
+ }
80
+ try {
81
+ const loader = configManagerConfig.modules[moduleName];
82
+ const config = yield loader();
83
+ return {
84
+ moduleName,
85
+ config
86
+ };
87
+ }
88
+ catch (error) {
89
+ console.error(`❌ Failed to load config for module "${moduleName}"`, error);
90
+ return undefined;
91
+ }
92
+ });
93
+
94
+ export { loadBaseConfig, loadModuleConfig, loadModulesConfig, mergeDeep };
package/utils.min.js ADDED
@@ -0,0 +1,2 @@
1
+ let mergeDeep=(e,o)=>{if("object"!=typeof e||"object"!=typeof o)return o;var n,t=Object.assign({},e);for(n in o)o.hasOwnProperty(n)&&(e.hasOwnProperty(n)?t[n]=mergeDeep(e[n],o[n]):t[n]=o[n]);return t};function __awaiter(e,o,a,u){return new(a=a||Promise)(function(n,o){function t(e){try{i(u.next(e))}catch(e){o(e)}}function r(e){try{i(u.throw(e))}catch(e){o(e)}}function i(e){var o;e.done?n(e.value):((o=e.value)instanceof a?o:new a(function(e){e(o)})).then(t,r)}i((u=u.apply(e,[])).next())})}let loadBaseConfig=(e,o)=>__awaiter(void 0,void 0,void 0,function*(){if(null==o||!o.base[e])return{};try{return yield(0,o.base[e])()}catch(e){return{}}}),loadModulesConfig=r=>__awaiter(void 0,void 0,void 0,function*(){var e=[];if(null!=r&&r.modules)for(var[o,n]of Object.entries(r.modules))try{var t=yield n();e.push({moduleName:o,config:t})}catch(e){}return e}),loadModuleConfig=(n,t)=>__awaiter(void 0,void 0,void 0,function*(){var e;if(null!=(e=null==t?void 0:t.modules)&&e[n])try{var o=yield(0,t.modules[n])();return{moduleName:n,config:o}}catch(e){}});export{loadBaseConfig,loadModuleConfig,loadModulesConfig,mergeDeep};
2
+ //# sourceMappingURL=utils.min.js.map
File without changes
File without changes