@cloudbase/app 3.3.4 → 3.3.5

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": "@cloudbase/app",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "description": "cloudbase javascript sdk core",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -43,8 +43,8 @@
43
43
  "dependencies": {
44
44
  "@cloudbase/adapter-interface": "^0.7.1",
45
45
  "@cloudbase/adapter-wx_mp": "^1.3.1",
46
- "@cloudbase/types": "3.3.4",
47
- "@cloudbase/utilities": "3.3.4"
46
+ "@cloudbase/types": "3.3.5",
47
+ "@cloudbase/utilities": "3.3.5"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@cloudbase/signature-nodejs": ">=1.0.0",
@@ -62,5 +62,5 @@
62
62
  "optional": true
63
63
  }
64
64
  },
65
- "gitHead": "007548511b11c6e7648bb93c10b9dbae3a480a32"
65
+ "gitHead": "c49e85b029e204845cc7e402aef4ca7af89b7875"
66
66
  }
@@ -1,8 +1,6 @@
1
1
  import { EndPointKey } from '@cloudbase/types'
2
2
  import { constants } from '@cloudbase/utilities'
3
3
 
4
- const ZONE_CHINA = ['ap-shanghai', 'ap-guangzhou', 'ap-shenzhen-fsi', 'ap-shanghai-fsi', 'ap-nanjing', 'ap-beijing', 'ap-chengdu', 'ap-chongqing', 'ap-hongkong']
5
-
6
4
  // @ts-ignore
7
5
  const { setSdkName: setUtilitiesSdkName, setProtocol: setUtilitiesProtocol } = constants
8
6
  /**
@@ -88,11 +86,10 @@ export interface ISetEndPointWithKey {
88
86
  protocol?: 'http' | 'https'
89
87
  }
90
88
 
91
- export function setGatewayEndPointWithEnv(env: string, protocol?: Protocol, region = 'ap-shanghai') {
92
- region = region || 'ap-shanghai'
89
+ export function setGatewayEndPointWithEnv(env: string, protocol?: Protocol, init?: boolean) {
93
90
  let baseUrl = `//${env}.api.tcloudbasegateway.com/v1`
94
91
 
95
- if (!ZONE_CHINA.includes(region)) {
92
+ if (init) {
96
93
  baseUrl = `//${env}.api.intl.tcloudbasegateway.com/v1`
97
94
  }
98
95
 
package/src/index.ts CHANGED
@@ -101,7 +101,7 @@ class Cloudbase implements ICloudbase {
101
101
  ],
102
102
  })
103
103
  public init(config: ICloudbaseConfig & { lang?: LANGS } = { env: '' }): Cloudbase {
104
- config.endPointMode = config.endPointMode || 'GATEWAY'
104
+ config.endPointMode = config.endPointMode || 'CLOUD_API'
105
105
 
106
106
  // 初始化时若未兼容平台,则使用默认adapter
107
107
  if (!Platform.adapter) {
@@ -144,7 +144,7 @@ class Cloudbase implements ICloudbase {
144
144
  initCache({ env, persistence, debug, platformInfo: this.platform })
145
145
 
146
146
  setRegionLevelEndpoint(env, config.region || '')
147
- setGatewayEndPointWithEnv(env, DEFAULT_PROTOCOL, config.region || '')
147
+ setGatewayEndPointWithEnv(env, DEFAULT_PROTOCOL, config.intl)
148
148
 
149
149
  const app = new Cloudbase(this.cloudbaseConfig)
150
150
  initRequest({
@@ -252,20 +252,26 @@ class Cloudbase implements ICloudbase {
252
252
  public isInitialized(config = this.cloudbaseConfig): boolean {
253
253
  // 检测常见占位符 env 值,在开发阶段给出友好提示
254
254
  const PLACEHOLDER_PATTERNS = [
255
- 'your-env-id', 'your-envid', 'your_env_id',
256
- 'xxx-yyy', 'xxxx-yyy', 'envId', 'env-id',
257
- 'your-environment-id', 'REPLACE_ME',
255
+ 'your-env-id',
256
+ 'your-envid',
257
+ 'your_env_id',
258
+ 'xxx-yyy',
259
+ 'xxxx-yyy',
260
+ 'envId',
261
+ 'env-id',
262
+ 'your-environment-id',
263
+ 'REPLACE_ME',
258
264
  ]
259
265
  if (PLACEHOLDER_PATTERNS.some(p => config.env.toLowerCase() === p.toLowerCase())) {
260
266
  printWarn(
261
267
  ERRORS.INVALID_PARAMS,
262
268
  `[CloudBase] 检测到环境 ID "${config.env}" 可能是占位符,请替换为真实的环境 ID。\n`
263
- + ' 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n'
264
- + ' 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV',
269
+ + ' 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n'
270
+ + ' 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV',
265
271
  )
266
272
  }
267
273
 
268
- return !!(config?.env)
274
+ return !!config?.env
269
275
  }
270
276
 
271
277
  /** 设置 tcb api 的 endpoint */
@@ -333,7 +339,12 @@ class Cloudbase implements ICloudbase {
333
339
  */
334
340
  private dealNodeAdapterConfig(config: ICloudbaseConfig) {
335
341
  // node环境可以从adapter获取默认的secretId和secretKey
336
- if (typeof process !== 'undefined' && typeof process.env !== 'undefined' && !process.env.IS_BROWSER_BUILD && Platform.adapter?.getSecretInfo) {
342
+ if (
343
+ typeof process !== 'undefined'
344
+ && typeof process.env !== 'undefined'
345
+ && !process.env.IS_BROWSER_BUILD
346
+ && Platform.adapter?.getSecretInfo
347
+ ) {
337
348
  const secretInfo = Platform.adapter?.getSecretInfo(config)
338
349
  // 将 adapter 提供的密钥信息写入 config.auth
339
350
  config.auth = {