@be-link/shield-for-tcb-node-sdk 0.0.7 → 0.1.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/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { backendConfigService, frontendConfigService } from './modules/config/service';
1
+ export { backendConfigService } from './modules/config/service';
2
2
  export type { Service as ConfigControllerTypes } from './modules/config/types';
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.frontendConfigService = exports.backendConfigService = void 0;
3
+ exports.backendConfigService = void 0;
4
4
  var service_1 = require("./modules/config/service");
5
5
  Object.defineProperty(exports, "backendConfigService", { enumerable: true, get: function () { return service_1.backendConfigService; } });
6
- Object.defineProperty(exports, "frontendConfigService", { enumerable: true, get: function () { return service_1.frontendConfigService; } });
@@ -3,11 +3,11 @@ export default abstract class BaseService {
3
3
  /** URL一级路径 */
4
4
  protected abstract prefixUrl: string;
5
5
  /** 子网域名 */
6
- protected readonly natDevHost = "http://yayvmsbg.shield-for-tcb.07vmo6rk.by26x7u9.com:8090";
7
- protected readonly natProdHost = "";
6
+ protected readonly natDevHost = "http://shield:8090";
7
+ protected readonly natProdHost = "http://shield:8090";
8
8
  /** 公网域名 */
9
- protected readonly publicDevHost = "https://shield-for-tcb-196345-5-1304510571.sh.run.tcloudbase.com";
10
- protected readonly publicProdHost = "";
9
+ protected readonly publicDevHost = "https://ecommerce-dev.wejourney.top";
10
+ protected readonly publicProdHost = "https://ecommerce-release.wejourney.top";
11
11
  constructor();
12
12
  /** 获取API URL */
13
13
  protected getApiUrl(func: Function): string;
@@ -8,11 +8,11 @@ const string_1 = require("../utils/string");
8
8
  class BaseService {
9
9
  constructor() {
10
10
  /** 子网域名 */
11
- this.natDevHost = 'http://yayvmsbg.shield-for-tcb.07vmo6rk.by26x7u9.com:8090';
12
- this.natProdHost = '';
11
+ this.natDevHost = 'http://shield:8090';
12
+ this.natProdHost = 'http://shield:8090';
13
13
  /** 公网域名 */
14
- this.publicDevHost = 'https://shield-for-tcb-196345-5-1304510571.sh.run.tcloudbase.com';
15
- this.publicProdHost = '';
14
+ this.publicDevHost = 'https://ecommerce-dev.wejourney.top';
15
+ this.publicProdHost = 'https://ecommerce-release.wejourney.top';
16
16
  /** 如果是云函数环境, 默认走公网访问 */
17
17
  this.isPublicEnv = (process.env.CONTAINER_ENV || 'SCF') === 'SCF';
18
18
  }
@@ -1,19 +1,10 @@
1
1
  import { Service } from './types';
2
2
  import BaseService from '../BaseService';
3
- type CallerType = 'frontend' | 'backend';
4
- export interface ConfigServiceOptions {
5
- caller?: CallerType;
6
- }
7
3
  export declare class ConfigService extends BaseService implements Service.ConfigController {
8
4
  protected prefixUrl: string;
9
- private caller;
10
- constructor(options?: ConfigServiceOptions);
11
- private get shouldSkipErrorHandling();
12
5
  fetchConfig(req: Service.Request.QueryFetchConfig): Promise<any>;
13
6
  fetchGlobalDynamicConfig(): Promise<Service.Response.IFetchGlobalDynamicConfigResponse>;
14
7
  getCosTempSecret(): Promise<Service.Response.CosTempSecretResponse>;
15
- fetchSystemTime(): Promise<Date>;
8
+ fetchSystemTime(): Promise<number>;
16
9
  }
17
10
  export declare const backendConfigService: ConfigService;
18
- export declare const frontendConfigService: ConfigService;
19
- export {};
@@ -3,33 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.frontendConfigService = exports.backendConfigService = exports.ConfigService = void 0;
6
+ exports.backendConfigService = exports.ConfigService = void 0;
7
7
  const http_1 = require("../../utils/http");
8
8
  const BaseService_1 = __importDefault(require("../BaseService"));
9
9
  class ConfigService extends BaseService_1.default {
10
- constructor(options) {
11
- super();
12
- this.prefixUrl = '/config';
13
- this.caller = options?.caller ?? 'backend';
14
- }
15
- get shouldSkipErrorHandling() {
16
- return this.caller === 'frontend';
10
+ constructor() {
11
+ super(...arguments);
12
+ this.prefixUrl = '/shield/config';
17
13
  }
18
14
  fetchConfig(req) {
19
- return (0, http_1.callApi)(this.getApiUrl(this.fetchConfig), req, {
20
- skipErrorHandling: this.shouldSkipErrorHandling,
21
- });
15
+ return (0, http_1.callApi)(this.getApiUrl(this.fetchConfig), req);
22
16
  }
23
17
  fetchGlobalDynamicConfig() {
24
- return (0, http_1.callApi)(this.getApiUrl(this.fetchGlobalDynamicConfig), undefined, { skipErrorHandling: this.shouldSkipErrorHandling });
18
+ return (0, http_1.callApi)(this.getApiUrl(this.fetchGlobalDynamicConfig), undefined);
25
19
  }
26
20
  getCosTempSecret() {
27
- return (0, http_1.callApi)(this.getApiUrl(this.getCosTempSecret), undefined, { skipErrorHandling: this.shouldSkipErrorHandling });
21
+ return (0, http_1.callApi)(this.getApiUrl(this.getCosTempSecret), undefined);
28
22
  }
29
23
  fetchSystemTime() {
30
- return (0, http_1.callApi)(this.getApiUrl(this.fetchSystemTime), undefined, { skipErrorHandling: this.shouldSkipErrorHandling });
24
+ return (0, http_1.callApi)(this.getApiUrl(this.fetchSystemTime), undefined);
31
25
  }
32
26
  }
33
27
  exports.ConfigService = ConfigService;
34
- exports.backendConfigService = new ConfigService({ caller: 'backend' });
35
- exports.frontendConfigService = new ConfigService({ caller: 'frontend' });
28
+ exports.backendConfigService = new ConfigService();
@@ -60,6 +60,6 @@ export declare namespace Service {
60
60
  * 获取系统时间
61
61
  * @returns 系统时间
62
62
  */
63
- fetchSystemTime(): Promise<Date>;
63
+ fetchSystemTime(): Promise<number>;
64
64
  }
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/shield-for-tcb-node-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.1.1",
4
4
  "description": "ShieldForTCB Node.js SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/utils/http.js CHANGED
@@ -74,7 +74,7 @@ async function callApi(url, request, options) {
74
74
  console.error(`shield-for-tcb 异常: ${axiosError.message}, requestId: ${requestId}`);
75
75
  console.info('响应信息', data.message);
76
76
  console.error('异常堆栈', JSON.stringify(error.stack));
77
- throw new Error(data.errorType + ' - ' + data.message);
77
+ throw axiosError;
78
78
  }
79
79
  // 调用dns模块解析url
80
80
  const dns = await Promise.resolve().then(() => __importStar(require('dns')));