@alicloud/alfa-core 1.5.9-beta.3 → 1.6.0-beta.1
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/es/utils/channel.js +26 -0
- package/es/utils/getManifest.js +0 -5
- package/es/utils/getRelease.js +62 -8
- package/es/utils/interceptors/responseInterceptor.js +6 -0
- package/es/utils/logger.js +4 -5
- package/lib/utils/channel.js +32 -0
- package/lib/utils/getManifest.js +0 -5
- package/lib/utils/getRelease.js +62 -8
- package/lib/utils/interceptors/responseInterceptor.js +6 -0
- package/lib/utils/logger.js +4 -5
- package/package.json +1 -1
- package/types/types/index.d.ts +2 -1
- package/types/utils/channel.d.ts +2 -0
- package/types/utils/getRelease.d.ts +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function getChannel(value) {
|
|
2
|
+
var _window, _window$ALIYUN_CONSOL;
|
|
3
|
+
if (value) return value;
|
|
4
|
+
if ((_window = window) !== null && _window !== void 0 && (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) !== null && _window$ALIYUN_CONSOL !== void 0 && _window$ALIYUN_CONSOL.CHANNEL) {
|
|
5
|
+
var _ALIYUN_CONSOLE_CONFI;
|
|
6
|
+
return (_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.CHANNEL;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 本地始终返回 OFFICIAL
|
|
10
|
+
if (typeof process !== 'undefined') {
|
|
11
|
+
var _process;
|
|
12
|
+
if (((_process = process) === null || _process === void 0 ? void 0 : _process.env.NODE_ENV) === 'development') {
|
|
13
|
+
return 'OFFICIAL';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 尝试根据域名判断
|
|
18
|
+
if (['alibabacloud.com', 'idptcloud01cs.com', 'idptcloud01-inc.com'].find(function (domain) {
|
|
19
|
+
return location.hostname.endsWith(domain);
|
|
20
|
+
})) {
|
|
21
|
+
return 'SIN';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 默认返回 OFFICIAL
|
|
25
|
+
return 'OFFICIAL';
|
|
26
|
+
}
|
package/es/utils/getManifest.js
CHANGED
|
@@ -106,11 +106,6 @@ export var getManifest = /*#__PURE__*/function () {
|
|
|
106
106
|
_context.next = 5;
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
|
-
(logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
110
|
-
E_CODE: 'GetManifestError',
|
|
111
|
-
E_MSG: 'no entry of manifest.',
|
|
112
|
-
data: JSON.stringify(releaseConfig)
|
|
113
|
-
});
|
|
114
109
|
return _context.abrupt("return", undefined);
|
|
115
110
|
case 5:
|
|
116
111
|
_context.prev = 5;
|
package/es/utils/getRelease.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
7
|
import cache from './cacheManager';
|
|
4
8
|
import { getMicroAppRelease } from './oss';
|
|
5
9
|
import { getEnv } from './env';
|
|
10
|
+
import { getChannel } from './channel';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* get alfa release url
|
|
@@ -10,10 +15,17 @@ import { getEnv } from './env';
|
|
|
10
15
|
* @param env
|
|
11
16
|
* @returns
|
|
12
17
|
*/
|
|
13
|
-
export var getReleaseUrl = function getReleaseUrl(name, env) {
|
|
18
|
+
export var getReleaseUrl = function getReleaseUrl(name, env, channel) {
|
|
14
19
|
var _process;
|
|
15
20
|
var cdnUrl = "https://cws.alicdn.com/Release/alfa/".concat(name, "/release.json");
|
|
16
21
|
var cdnPreUrl = "https://cws2.alicdn.com/Prepub/alfa/".concat(name, "/release.json");
|
|
22
|
+
if (channel === 'OFFICIAL') {
|
|
23
|
+
cdnUrl = "htts://cws.alyasset.com/Release/alfa/".concat(name, "/release.json");
|
|
24
|
+
cdnPreUrl = "https://cws.alyasset.com/Prepub/alfa/".concat(name, "/release.json");
|
|
25
|
+
} else if (channel === 'SIN') {
|
|
26
|
+
cdnUrl = "https://cws.alcasset.com/Release/alfa/".concat(name, "/release.json");
|
|
27
|
+
cdnPreUrl = "https://cws.alcasset.com/Prepub/alfa/".concat(name, "/release.json");
|
|
28
|
+
}
|
|
17
29
|
switch (env) {
|
|
18
30
|
case 'local':
|
|
19
31
|
return ((_process = process) === null || _process === void 0 ? void 0 : _process.env.ALFA_RELEASE_URL) || cdnPreUrl;
|
|
@@ -28,17 +40,58 @@ export var getReleaseUrl = function getReleaseUrl(name, env) {
|
|
|
28
40
|
}
|
|
29
41
|
return undefined;
|
|
30
42
|
};
|
|
43
|
+
function patchReleaseResult(releaseConfig, channel) {
|
|
44
|
+
if (!channel) {
|
|
45
|
+
return releaseConfig;
|
|
46
|
+
}
|
|
47
|
+
var replace = function replace(domain) {
|
|
48
|
+
if (!domain) {
|
|
49
|
+
return domain;
|
|
50
|
+
}
|
|
51
|
+
if (channel === 'OFFICIAL') {
|
|
52
|
+
return domain.replace(/cws2?\.alicdn\.com/, 'cws.alyasset.com');
|
|
53
|
+
} else if (channel === 'SIN') {
|
|
54
|
+
return domain.replace(/cws2?\.alicdn\.com/, 'cws.alcasset.com');
|
|
55
|
+
}
|
|
56
|
+
return domain;
|
|
57
|
+
};
|
|
58
|
+
var mapObject = function mapObject(obj, fn) {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
60
|
+
var newObject = {};
|
|
61
|
+
Object.entries(obj).forEach(function (_ref) {
|
|
62
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
63
|
+
key = _ref2[0],
|
|
64
|
+
value = _ref2[1];
|
|
65
|
+
newObject[key] = fn(value, key);
|
|
66
|
+
});
|
|
67
|
+
return newObject;
|
|
68
|
+
};
|
|
69
|
+
return _objectSpread(_objectSpread(_objectSpread({}, releaseConfig), releaseConfig['locales-versions'] ? {
|
|
70
|
+
'locales-versions': mapObject(releaseConfig['locales-versions'], function (localeVersion) {
|
|
71
|
+
return mapObject(localeVersion, function (url) {
|
|
72
|
+
return replace(url);
|
|
73
|
+
});
|
|
74
|
+
})
|
|
75
|
+
} : undefined), releaseConfig['config-versions'] ? {
|
|
76
|
+
'config-versions': mapObject(releaseConfig['config-versions'], function (configVersion) {
|
|
77
|
+
return mapObject(configVersion, function (url) {
|
|
78
|
+
return replace(url);
|
|
79
|
+
});
|
|
80
|
+
})
|
|
81
|
+
} : undefined);
|
|
82
|
+
}
|
|
31
83
|
export var getRelease = /*#__PURE__*/function () {
|
|
32
|
-
var
|
|
33
|
-
var logger, name, env, releaseConfig, _t, _t2;
|
|
84
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(config) {
|
|
85
|
+
var logger, name, env, channel, releaseConfig, _t, _t2, _t3;
|
|
34
86
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
35
87
|
while (1) switch (_context.prev = _context.next) {
|
|
36
88
|
case 0:
|
|
37
89
|
logger = config.logger, name = config.name;
|
|
38
90
|
env = getEnv(config.env);
|
|
91
|
+
channel = getChannel(config.channel);
|
|
39
92
|
_context.prev = 1;
|
|
40
93
|
_context.next = 2;
|
|
41
|
-
return cache.getRemote(getReleaseUrl(name, env));
|
|
94
|
+
return cache.getRemote(getReleaseUrl(name, env, channel));
|
|
42
95
|
case 2:
|
|
43
96
|
releaseConfig = _context.sent.data;
|
|
44
97
|
if (releaseConfig) {
|
|
@@ -47,18 +100,19 @@ export var getRelease = /*#__PURE__*/function () {
|
|
|
47
100
|
}
|
|
48
101
|
throw new Error('releaseConfig is null');
|
|
49
102
|
case 3:
|
|
50
|
-
return _context.abrupt("return", releaseConfig);
|
|
103
|
+
return _context.abrupt("return", patchReleaseResult(releaseConfig, channel));
|
|
51
104
|
case 4:
|
|
52
105
|
_context.prev = 4;
|
|
53
106
|
_t = _context["catch"](1);
|
|
54
107
|
_context.prev = 5;
|
|
108
|
+
_t2 = patchReleaseResult;
|
|
55
109
|
_context.next = 6;
|
|
56
110
|
return getMicroAppRelease(name, env);
|
|
57
111
|
case 6:
|
|
58
|
-
return _context.abrupt("return", _context.sent);
|
|
112
|
+
return _context.abrupt("return", _t2(_context.sent));
|
|
59
113
|
case 7:
|
|
60
114
|
_context.prev = 7;
|
|
61
|
-
|
|
115
|
+
_t3 = _context["catch"](5);
|
|
62
116
|
(logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
63
117
|
E_CODE: 'GetReleaseError',
|
|
64
118
|
E_MSG: _t.message
|
|
@@ -71,6 +125,6 @@ export var getRelease = /*#__PURE__*/function () {
|
|
|
71
125
|
}, _callee, null, [[1, 4], [5, 7]]);
|
|
72
126
|
}));
|
|
73
127
|
return function getRelease(_x) {
|
|
74
|
-
return
|
|
128
|
+
return _ref3.apply(this, arguments);
|
|
75
129
|
};
|
|
76
130
|
}();
|
|
@@ -85,6 +85,12 @@ function _responseInterceptor() {
|
|
|
85
85
|
}
|
|
86
86
|
return _context.abrupt("return", response);
|
|
87
87
|
case 1:
|
|
88
|
+
if (['cws.alyasset.com', 'cws.alcasset.com'].some(function (domain) {
|
|
89
|
+
return url === null || url === void 0 ? void 0 : url.includes("://".concat(domain, "/"));
|
|
90
|
+
})) {
|
|
91
|
+
_context.next = 3;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
88
94
|
config.url = url === null || url === void 0 ? void 0 : url.replace(/:\/\/cws\.([a-z0-9-]+)\.com\//, function (match, p1) {
|
|
89
95
|
return "://cws2.".concat(p1, ".com/");
|
|
90
96
|
});
|
package/es/utils/logger.js
CHANGED
|
@@ -81,11 +81,10 @@ var Logger = /*#__PURE__*/function () {
|
|
|
81
81
|
})) return false;
|
|
82
82
|
|
|
83
83
|
// do not track during development
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (this.context.ENV !== 'prod' && !(params !== null && params !== void 0 && params.__force_log__)) {
|
|
85
|
+
console[method](topic, data);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
89
88
|
logger[method](topic, data);
|
|
90
89
|
}
|
|
91
90
|
}]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getChannel = getChannel;
|
|
7
|
+
function getChannel(value) {
|
|
8
|
+
var _window, _window$ALIYUN_CONSOL;
|
|
9
|
+
if (value) return value;
|
|
10
|
+
if ((_window = window) !== null && _window !== void 0 && (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) !== null && _window$ALIYUN_CONSOL !== void 0 && _window$ALIYUN_CONSOL.CHANNEL) {
|
|
11
|
+
var _ALIYUN_CONSOLE_CONFI;
|
|
12
|
+
return (_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.CHANNEL;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 本地始终返回 OFFICIAL
|
|
16
|
+
if (typeof process !== 'undefined') {
|
|
17
|
+
var _process;
|
|
18
|
+
if (((_process = process) === null || _process === void 0 ? void 0 : _process.env.NODE_ENV) === 'development') {
|
|
19
|
+
return 'OFFICIAL';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 尝试根据域名判断
|
|
24
|
+
if (['alibabacloud.com', 'idptcloud01cs.com', 'idptcloud01-inc.com'].find(function (domain) {
|
|
25
|
+
return location.hostname.endsWith(domain);
|
|
26
|
+
})) {
|
|
27
|
+
return 'SIN';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 默认返回 OFFICIAL
|
|
31
|
+
return 'OFFICIAL';
|
|
32
|
+
}
|
package/lib/utils/getManifest.js
CHANGED
|
@@ -113,11 +113,6 @@ var getManifest = exports.getManifest = /*#__PURE__*/function () {
|
|
|
113
113
|
_context.next = 5;
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
|
-
(logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
117
|
-
E_CODE: 'GetManifestError',
|
|
118
|
-
E_MSG: 'no entry of manifest.',
|
|
119
|
-
data: JSON.stringify(releaseConfig)
|
|
120
|
-
});
|
|
121
116
|
return _context.abrupt("return", undefined);
|
|
122
117
|
case 5:
|
|
123
118
|
_context.prev = 5;
|
package/lib/utils/getRelease.js
CHANGED
|
@@ -7,19 +7,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getReleaseUrl = exports.getRelease = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
12
|
var _cacheManager = _interopRequireDefault(require("./cacheManager"));
|
|
11
13
|
var _oss = require("./oss");
|
|
12
14
|
var _env = require("./env");
|
|
15
|
+
var _channel = require("./channel");
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
18
|
/**
|
|
14
19
|
* get alfa release url
|
|
15
20
|
* @param appId
|
|
16
21
|
* @param env
|
|
17
22
|
* @returns
|
|
18
23
|
*/
|
|
19
|
-
var getReleaseUrl = exports.getReleaseUrl = function getReleaseUrl(name, env) {
|
|
24
|
+
var getReleaseUrl = exports.getReleaseUrl = function getReleaseUrl(name, env, channel) {
|
|
20
25
|
var _process;
|
|
21
26
|
var cdnUrl = "https://cws.alicdn.com/Release/alfa/".concat(name, "/release.json");
|
|
22
27
|
var cdnPreUrl = "https://cws2.alicdn.com/Prepub/alfa/".concat(name, "/release.json");
|
|
28
|
+
if (channel === 'OFFICIAL') {
|
|
29
|
+
cdnUrl = "htts://cws.alyasset.com/Release/alfa/".concat(name, "/release.json");
|
|
30
|
+
cdnPreUrl = "https://cws.alyasset.com/Prepub/alfa/".concat(name, "/release.json");
|
|
31
|
+
} else if (channel === 'SIN') {
|
|
32
|
+
cdnUrl = "https://cws.alcasset.com/Release/alfa/".concat(name, "/release.json");
|
|
33
|
+
cdnPreUrl = "https://cws.alcasset.com/Prepub/alfa/".concat(name, "/release.json");
|
|
34
|
+
}
|
|
23
35
|
switch (env) {
|
|
24
36
|
case 'local':
|
|
25
37
|
return ((_process = process) === null || _process === void 0 ? void 0 : _process.env.ALFA_RELEASE_URL) || cdnPreUrl;
|
|
@@ -34,17 +46,58 @@ var getReleaseUrl = exports.getReleaseUrl = function getReleaseUrl(name, env) {
|
|
|
34
46
|
}
|
|
35
47
|
return undefined;
|
|
36
48
|
};
|
|
49
|
+
function patchReleaseResult(releaseConfig, channel) {
|
|
50
|
+
if (!channel) {
|
|
51
|
+
return releaseConfig;
|
|
52
|
+
}
|
|
53
|
+
var replace = function replace(domain) {
|
|
54
|
+
if (!domain) {
|
|
55
|
+
return domain;
|
|
56
|
+
}
|
|
57
|
+
if (channel === 'OFFICIAL') {
|
|
58
|
+
return domain.replace(/cws2?\.alicdn\.com/, 'cws.alyasset.com');
|
|
59
|
+
} else if (channel === 'SIN') {
|
|
60
|
+
return domain.replace(/cws2?\.alicdn\.com/, 'cws.alcasset.com');
|
|
61
|
+
}
|
|
62
|
+
return domain;
|
|
63
|
+
};
|
|
64
|
+
var mapObject = function mapObject(obj, fn) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
66
|
+
var newObject = {};
|
|
67
|
+
Object.entries(obj).forEach(function (_ref) {
|
|
68
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
69
|
+
key = _ref2[0],
|
|
70
|
+
value = _ref2[1];
|
|
71
|
+
newObject[key] = fn(value, key);
|
|
72
|
+
});
|
|
73
|
+
return newObject;
|
|
74
|
+
};
|
|
75
|
+
return _objectSpread(_objectSpread(_objectSpread({}, releaseConfig), releaseConfig['locales-versions'] ? {
|
|
76
|
+
'locales-versions': mapObject(releaseConfig['locales-versions'], function (localeVersion) {
|
|
77
|
+
return mapObject(localeVersion, function (url) {
|
|
78
|
+
return replace(url);
|
|
79
|
+
});
|
|
80
|
+
})
|
|
81
|
+
} : undefined), releaseConfig['config-versions'] ? {
|
|
82
|
+
'config-versions': mapObject(releaseConfig['config-versions'], function (configVersion) {
|
|
83
|
+
return mapObject(configVersion, function (url) {
|
|
84
|
+
return replace(url);
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
} : undefined);
|
|
88
|
+
}
|
|
37
89
|
var getRelease = exports.getRelease = /*#__PURE__*/function () {
|
|
38
|
-
var
|
|
39
|
-
var logger, name, env, releaseConfig, _t, _t2;
|
|
90
|
+
var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(config) {
|
|
91
|
+
var logger, name, env, channel, releaseConfig, _t, _t2, _t3;
|
|
40
92
|
return _regenerator.default.wrap(function (_context) {
|
|
41
93
|
while (1) switch (_context.prev = _context.next) {
|
|
42
94
|
case 0:
|
|
43
95
|
logger = config.logger, name = config.name;
|
|
44
96
|
env = (0, _env.getEnv)(config.env);
|
|
97
|
+
channel = (0, _channel.getChannel)(config.channel);
|
|
45
98
|
_context.prev = 1;
|
|
46
99
|
_context.next = 2;
|
|
47
|
-
return _cacheManager.default.getRemote(getReleaseUrl(name, env));
|
|
100
|
+
return _cacheManager.default.getRemote(getReleaseUrl(name, env, channel));
|
|
48
101
|
case 2:
|
|
49
102
|
releaseConfig = _context.sent.data;
|
|
50
103
|
if (releaseConfig) {
|
|
@@ -53,18 +106,19 @@ var getRelease = exports.getRelease = /*#__PURE__*/function () {
|
|
|
53
106
|
}
|
|
54
107
|
throw new Error('releaseConfig is null');
|
|
55
108
|
case 3:
|
|
56
|
-
return _context.abrupt("return", releaseConfig);
|
|
109
|
+
return _context.abrupt("return", patchReleaseResult(releaseConfig, channel));
|
|
57
110
|
case 4:
|
|
58
111
|
_context.prev = 4;
|
|
59
112
|
_t = _context["catch"](1);
|
|
60
113
|
_context.prev = 5;
|
|
114
|
+
_t2 = patchReleaseResult;
|
|
61
115
|
_context.next = 6;
|
|
62
116
|
return (0, _oss.getMicroAppRelease)(name, env);
|
|
63
117
|
case 6:
|
|
64
|
-
return _context.abrupt("return", _context.sent);
|
|
118
|
+
return _context.abrupt("return", _t2(_context.sent));
|
|
65
119
|
case 7:
|
|
66
120
|
_context.prev = 7;
|
|
67
|
-
|
|
121
|
+
_t3 = _context["catch"](5);
|
|
68
122
|
(logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
69
123
|
E_CODE: 'GetReleaseError',
|
|
70
124
|
E_MSG: _t.message
|
|
@@ -77,6 +131,6 @@ var getRelease = exports.getRelease = /*#__PURE__*/function () {
|
|
|
77
131
|
}, _callee, null, [[1, 4], [5, 7]]);
|
|
78
132
|
}));
|
|
79
133
|
return function getRelease(_x) {
|
|
80
|
-
return
|
|
134
|
+
return _ref3.apply(this, arguments);
|
|
81
135
|
};
|
|
82
136
|
}();
|
|
@@ -92,6 +92,12 @@ function _responseInterceptor() {
|
|
|
92
92
|
}
|
|
93
93
|
return _context.abrupt("return", response);
|
|
94
94
|
case 1:
|
|
95
|
+
if (['cws.alyasset.com', 'cws.alcasset.com'].some(function (domain) {
|
|
96
|
+
return url === null || url === void 0 ? void 0 : url.includes("://".concat(domain, "/"));
|
|
97
|
+
})) {
|
|
98
|
+
_context.next = 3;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
95
101
|
config.url = url === null || url === void 0 ? void 0 : url.replace(/:\/\/cws\.([a-z0-9-]+)\.com\//, function (match, p1) {
|
|
96
102
|
return "://cws2.".concat(p1, ".com/");
|
|
97
103
|
});
|
package/lib/utils/logger.js
CHANGED
|
@@ -88,11 +88,10 @@ var Logger = exports.default = /*#__PURE__*/function () {
|
|
|
88
88
|
})) return false;
|
|
89
89
|
|
|
90
90
|
// do not track during development
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
if (this.context.ENV !== 'prod' && !(params !== null && params !== void 0 && params.__force_log__)) {
|
|
92
|
+
console[method](topic, data);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
96
95
|
logger[method](topic, data);
|
|
97
96
|
}
|
|
98
97
|
}]);
|
package/package.json
CHANGED
package/types/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class AlfaLogger<P = any> {
|
|
|
9
9
|
warn?: (params: P) => void;
|
|
10
10
|
debug?: (params: P) => void;
|
|
11
11
|
}
|
|
12
|
-
type Channel = string;
|
|
12
|
+
export type Channel = 'OFFICIAL' | 'SIN' | string;
|
|
13
13
|
type ChannelLinks = Partial<Record<string, string>>;
|
|
14
14
|
type ChannelFeatures = Partial<Record<string, {
|
|
15
15
|
status: boolean;
|
|
@@ -57,6 +57,7 @@ export interface IAppConfig<P = any> extends IOptions {
|
|
|
57
57
|
};
|
|
58
58
|
app?: OSApplication;
|
|
59
59
|
env?: EnvEnum;
|
|
60
|
+
channel?: Channel;
|
|
60
61
|
locale?: string;
|
|
61
62
|
dynamicConfig?: boolean;
|
|
62
63
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IAppConfig, AlfaReleaseConfig } from '../types';
|
|
1
|
+
import { IAppConfig, AlfaReleaseConfig, Channel } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* get alfa release url
|
|
4
4
|
* @param appId
|
|
5
5
|
* @param env
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const getReleaseUrl: (name?: string, env?: string) => string | undefined;
|
|
8
|
+
export declare const getReleaseUrl: (name?: string, env?: string, channel?: Channel) => string | undefined;
|
|
9
9
|
export declare const getRelease: (config: IAppConfig) => Promise<AlfaReleaseConfig>;
|