openxiangda 1.0.128 → 1.0.129

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.
Files changed (2) hide show
  1. package/lib/cli.js +58 -7
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -155,7 +155,7 @@ Usage:
155
155
  openxiangda permission form-group-list|form-group-create|form-group-update|form-group-delete|form-group-bind
156
156
  openxiangda settings get|save|indexes|indexes-save|data-management|data-management-save|public-access
157
157
  openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json] [--dry-run]
158
- openxiangda runtime deploy [--profile name] [--dist dist] [--build-id id] [--upload-mode staged|legacy-json] [--upload-timeout-ms ms] [--no-build] [--no-activate] [--json]
158
+ openxiangda runtime deploy [--profile name] [--dist dist] [--build-id id] [--upload-mode auto|staged|oss-direct|legacy-json] [--upload-timeout-ms ms] [--no-build] [--no-activate] [--json]
159
159
  openxiangda runtime releases [--profile name] [--json]
160
160
  openxiangda runtime activate <releaseId> [--profile name] [--json]
161
161
  openxiangda inspect app|form|workflow|automation|permissions
@@ -3902,10 +3902,42 @@ async function runtime(args) {
3902
3902
  if (subcommand === 'deploy') {
3903
3903
  const buildId = normalizeRuntimeBuildId(flags['build-id'] || createRuntimeBuildId());
3904
3904
  const distDir = path.resolve(process.cwd(), flags.dist || 'dist');
3905
- const assetBaseUrl = buildRuntimeAssetBaseUrl(target.appType, buildId);
3906
3905
  const uploadMode = normalizeRuntimeUploadMode(flags['upload-mode']);
3907
3906
  const uploadTimeoutMs = normalizeRuntimeUploadTimeoutMs(flags['upload-timeout-ms']);
3908
3907
  const traceId = createRuntimeTraceId();
3908
+ const gatewayAssetBaseUrl = buildRuntimeAssetBaseUrl(target.appType, buildId);
3909
+ let assetBaseUrl = gatewayAssetBaseUrl;
3910
+ let effectiveUploadMode = uploadMode;
3911
+ if (uploadMode === 'auto' || uploadMode === 'oss-direct') {
3912
+ try {
3913
+ const plan = await createRuntimeOssUploadBasePlan({
3914
+ config,
3915
+ profileName: target.profileName,
3916
+ appType: target.appType,
3917
+ buildId,
3918
+ traceId,
3919
+ timeoutMs: uploadTimeoutMs,
3920
+ });
3921
+ if (plan?.assetBaseUrl) {
3922
+ assetBaseUrl = plan.assetBaseUrl;
3923
+ if (uploadMode === 'auto') {
3924
+ effectiveUploadMode = 'oss-direct';
3925
+ printRuntimeProgress(
3926
+ `runtime builtin OSS available; using OSS direct upload traceId=${traceId}`
3927
+ );
3928
+ }
3929
+ }
3930
+ } catch (error) {
3931
+ if (uploadMode === 'oss-direct') {
3932
+ throw error;
3933
+ }
3934
+ effectiveUploadMode = 'auto';
3935
+ assetBaseUrl = gatewayAssetBaseUrl;
3936
+ printRuntimeProgress(
3937
+ `runtime builtin OSS preflight unavailable; using staged upload first traceId=${traceId}`
3938
+ );
3939
+ }
3940
+ }
3909
3941
  if (!flags['no-build']) {
3910
3942
  runRuntimeBuild({
3911
3943
  buildId,
@@ -3920,9 +3952,8 @@ async function runtime(args) {
3920
3952
  });
3921
3953
  const totalBytes = files.reduce((sum, file) => sum + file.size, 0);
3922
3954
  printRuntimeProgress(
3923
- `runtime release upload: mode=${uploadMode} traceId=${traceId} files=${files.length} size=${formatBytes(totalBytes)} timeout=${uploadTimeoutMs}ms`
3955
+ `runtime release upload: mode=${effectiveUploadMode} traceId=${traceId} files=${files.length} size=${formatBytes(totalBytes)} timeout=${uploadTimeoutMs}ms`
3924
3956
  );
3925
- let effectiveUploadMode = uploadMode;
3926
3957
  let releaseFiles;
3927
3958
  if (uploadMode === 'legacy-json') {
3928
3959
  releaseFiles = files.map(file => ({
@@ -3932,7 +3963,8 @@ async function runtime(args) {
3932
3963
  contentType: file.contentType,
3933
3964
  contentBase64: file.buffer.toString('base64'),
3934
3965
  }));
3935
- } else if (uploadMode === 'oss-direct') {
3966
+ effectiveUploadMode = 'legacy-json';
3967
+ } else if (effectiveUploadMode === 'oss-direct') {
3936
3968
  releaseFiles = await uploadRuntimeDistFilesOssDirect({
3937
3969
  config,
3938
3970
  profileName: target.profileName,
@@ -3990,6 +4022,7 @@ async function runtime(args) {
3990
4022
  }
3991
4023
  );
3992
4024
  saveRuntimeReleaseState(target, data);
4025
+ const releaseAssetBaseUrl = data?.assetBaseUrl || assetBaseUrl;
3993
4026
  const result = {
3994
4027
  appType: target.appType,
3995
4028
  buildId,
@@ -3997,7 +4030,7 @@ async function runtime(args) {
3997
4030
  distDir,
3998
4031
  fileCount: files.length,
3999
4032
  totalBytes,
4000
- assetBaseUrl,
4033
+ assetBaseUrl: releaseAssetBaseUrl,
4001
4034
  activated: !flags['no-activate'],
4002
4035
  uploadMode: effectiveUploadMode,
4003
4036
  traceId,
@@ -4010,7 +4043,7 @@ async function runtime(args) {
4010
4043
  `files: ${files.length} (${formatBytes(totalBytes)})`,
4011
4044
  `upload: ${effectiveUploadMode}`,
4012
4045
  `traceId: ${traceId}`,
4013
- `assetBase: ${assetBaseUrl}`,
4046
+ `assetBase: ${releaseAssetBaseUrl}`,
4014
4047
  `active: ${result.activated ? 'yes' : 'no'}`,
4015
4048
  ].join('\n')
4016
4049
  );
@@ -4020,6 +4053,24 @@ async function runtime(args) {
4020
4053
  fail('用法: openxiangda runtime deploy|releases|activate [--profile name]');
4021
4054
  }
4022
4055
 
4056
+ async function createRuntimeOssUploadBasePlan(options) {
4057
+ return await requestWithAuth(
4058
+ options.config,
4059
+ options.profileName,
4060
+ `/openxiangda-api/v1/apps/${encodeURIComponent(options.appType)}/runtime/releases/oss-upload-plan`,
4061
+ {
4062
+ method: 'POST',
4063
+ timeoutMs: options.timeoutMs,
4064
+ headers: { 'x-openxiangda-trace-id': options.traceId },
4065
+ body: {
4066
+ buildId: options.buildId,
4067
+ planOnly: true,
4068
+ files: [],
4069
+ },
4070
+ }
4071
+ );
4072
+ }
4073
+
4023
4074
  function runRuntimeBuild(options) {
4024
4075
  const command = options.command || defaultRuntimeBuildCommand();
4025
4076
  if (options.jsonOutput) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.128",
3
+ "version": "1.0.129",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {