tnx-shared 5.2.3 → 5.2.4

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.
@@ -329,18 +329,10 @@ function generateEnvironmentTsFile(environment) {
329
329
  }
330
330
 
331
331
  function transformEnvironmentTsAndJsonFile(envName, input) {
332
- return input.replaceAll('{{environmentName}}', envName).replaceAll('{{scopeName}}', angularSchemaObj.scopeName);
333
- }
334
-
335
- // obsolete, đọc config từ etcd nên cái này không cần gen nữa
336
- function generateApplicationJsonFile() {
337
- if (!fs.existsSync(`${pathSharedAssets}/environments/${angularSchemaObj.scopeName}/application.json`)) {
338
- return src(`${pathSharedAssets}/environments/application-template.json`)
339
- .pipe(rename(`application.json`))
340
- .pipe(dest(`${pathSharedAssets}/environments/${angularSchemaObj.scopeName}`));
341
- }
342
-
343
- return true;
332
+ return input
333
+ .replaceAll('{{environmentName}}', envName)
334
+ .replaceAll('{{scopeName}}', angularSchemaObj.scopeName)
335
+ .replaceAll('{{configService}}', angularSchemaObj.configService);
344
336
  }
345
337
 
346
338
  function generateEnvironmentJsonFile(environment) {
@@ -933,6 +933,9 @@
933
933
  EnvironmentService.prototype.getSignalr_ClientKey = function () {
934
934
  return this.environment.signalr.clientKey;
935
935
  };
936
+ EnvironmentService.prototype.getApiGateway = function () {
937
+ return this.environment.appMetadata.gateway;
938
+ };
936
939
  EnvironmentService.prototype.getGatewaySubpath = function () {
937
940
  return this.environment.appMetadata.gatewaySubpath;
938
941
  };
@@ -3321,6 +3324,9 @@
3321
3324
  };
3322
3325
  var mergeJSON = function (target, source) {
3323
3326
  var e_1, _a;
3327
+ if (Object.keys(source).length == 0) {
3328
+ return target;
3329
+ }
3324
3330
  if (isArray(source)) {
3325
3331
  if (!isArray(target)) {
3326
3332
  target = [];
@@ -3431,26 +3437,30 @@
3431
3437
  var commonMasterDataApi = window.commonMasterDataApi;
3432
3438
  var appXhr = new XMLHttpRequest();
3433
3439
  appXhr.open('GET', commonMasterDataApi + "v5/ConfigAndSetting/GetAppConfig", false);
3434
- appXhr.setRequestHeader('Cache-Control', 'no-cache, no-store, max-age=0');
3440
+ // Gọi api của mình thì ko cần logic cache này, logic này do phía api quyết định xem có cache không và cache bao lâu
3441
+ // appXhr.setRequestHeader('Cache-Control', 'no-cache, no-store, max-age=0');
3435
3442
  appXhr.send(null);
3436
3443
  var resGetAppConfig = appXhr.responseText;
3437
3444
  var op = JSON.parse(resGetAppConfig).data;
3438
- var res = [];
3439
- res.push(getEnvironmentByName(personalName, scopeName, customPath));
3440
- while (res.length > 0) {
3441
- var source = JSON.parse(res.shift());
3442
- op = mergeJSON(op, source);
3443
- }
3444
- if (op) {
3445
- if (op.apps) {
3446
- Object.keys(op.apps).forEach(function (appCode) {
3447
- op.apps[appCode].code = appCode.toLowerCase();
3448
- });
3449
- }
3450
- if (op.services) {
3451
- Object.keys(op.services).forEach(function (appCode) {
3452
- op.services[appCode].code = appCode.toLowerCase();
3453
- });
3445
+ // Nếu prod thì không cần đọc cấu hình từ json nữa
3446
+ if (personalName != 'prod') {
3447
+ var res = [];
3448
+ res.push(getEnvironmentByName(personalName, scopeName, customPath));
3449
+ while (res.length > 0) {
3450
+ var source = JSON.parse(res.shift());
3451
+ op = mergeJSON(op, source);
3452
+ }
3453
+ if (op) {
3454
+ if (op.apps) {
3455
+ Object.keys(op.apps).forEach(function (appCode) {
3456
+ op.apps[appCode].code = appCode.toLowerCase();
3457
+ });
3458
+ }
3459
+ if (op.services) {
3460
+ Object.keys(op.services).forEach(function (appCode) {
3461
+ op.services[appCode].code = appCode.toLowerCase();
3462
+ });
3463
+ }
3454
3464
  }
3455
3465
  }
3456
3466
  return op;
@@ -25303,7 +25313,7 @@
25303
25313
  this._environmentService = _environmentService;
25304
25314
  }
25305
25315
  SendAccessTokenInterceptor.prototype.intercept = function (request, next) {
25306
- if (!this._environmentService.getDisableAuthentication) {
25316
+ if (!this._environmentService.getDisableAuthentication()) {
25307
25317
  request = request.clone({
25308
25318
  setHeaders: {
25309
25319
  Authorization: "Bearer " + this.authenService.getAccessToken(),
@@ -25798,7 +25808,7 @@
25798
25808
  ngxMask.NgxMaskModule.forRoot(),
25799
25809
  i4.OAuthModule.forRoot({
25800
25810
  resourceServer: {
25801
- allowedUrls: [environment.apiDomain.gateway],
25811
+ allowedUrls: [environment.appMetadata.appGateway],
25802
25812
  sendAccessToken: false,
25803
25813
  },
25804
25814
  }),