@huoye/app-ship 0.1.2 → 0.2.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/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 上传配置接口
3
- */
4
- interface UploadConfig {
3
+ */ interface UploadConfig {
5
4
  /** 应用 ID */
6
5
  appId?: string;
7
6
  /** 版本号 */
@@ -406,8 +405,8 @@ interface UploadConfig {
406
405
  };
407
406
  /** 包名 */
408
407
  packageName?: string;
409
- /** 发布轨道:internal | alpha | beta | production */
410
- track?: 'internal' | 'alpha' | 'beta' | 'production';
408
+ /** 发布轨道;首版只支持 internal */
409
+ track?: 'internal';
411
410
  };
412
411
  /** 未来扩展的其他平台 */
413
412
  [key: string]: any;
@@ -415,8 +414,7 @@ interface UploadConfig {
415
414
  }
416
415
  /**
417
416
  * 应用元数据接口
418
- */
419
- interface AppMetadata {
417
+ */ interface AppMetadata {
420
418
  /** 版本号 */
421
419
  version: string;
422
420
  /** 应用名称 */
@@ -439,8 +437,7 @@ interface AppMetadata {
439
437
  }
440
438
  /**
441
439
  * 上传结果接口
442
- */
443
- interface UploadResult {
440
+ */ interface UploadResult {
444
441
  /** 平台名称 */
445
442
  platform: string;
446
443
  /** 是否成功 */
@@ -469,8 +466,7 @@ interface UploadResult {
469
466
  }
470
467
  /**
471
468
  * 上传器接口
472
- */
473
- interface IUploader {
469
+ */ interface IUploader {
474
470
  /** 上传器名称 */
475
471
  name: string;
476
472
  /**
@@ -491,8 +487,7 @@ interface IUploader {
491
487
  }
492
488
  /**
493
489
  * 构建结果接口
494
- */
495
- interface BuildResult {
490
+ */ interface BuildResult {
496
491
  /** 是否成功 */
497
492
  success: boolean;
498
493
  /**
@@ -521,6 +516,12 @@ declare class ConfigValidator {
521
516
  * @param filePath 配置文件路径
522
517
  */
523
518
  static loadAndValidate(filePath: string): UploadConfig | null;
519
+ /**
520
+ * 只收集本次实际启用配置中的环境变量,避免禁用平台阻塞其它上传任务。
521
+ */
522
+ private static collectRequiredEnvVars;
523
+ /** 在内存中递归解析环境变量,不重新拼接 YAML,避免密钥字符破坏 YAML 结构。 */
524
+ private static resolveEnvVars;
524
525
  /**
525
526
  * 验证配置 Schema
526
527
  * @param config 配置对象
@@ -1162,6 +1163,44 @@ declare class TencentUploader implements IUploader {
1162
1163
  private submitModifyAppInfo;
1163
1164
  }
1164
1165
 
1166
+ interface GooglePlayHttpResponse<T = any> {
1167
+ data: T;
1168
+ }
1169
+ interface GooglePlayHttpClient {
1170
+ post<T = any>(url: string, data?: any, config?: any): Promise<GooglePlayHttpResponse<T>>;
1171
+ put<T = any>(url: string, data?: any, config?: any): Promise<GooglePlayHttpResponse<T>>;
1172
+ delete<T = any>(url: string, config?: any): Promise<GooglePlayHttpResponse<T>>;
1173
+ }
1174
+ interface GooglePlayAuthConfig {
1175
+ serviceAccountJsonPath?: string;
1176
+ serviceAccountJsonContent?: string;
1177
+ }
1178
+ interface GooglePlayUploaderDependencies {
1179
+ httpClient?: GooglePlayHttpClient;
1180
+ getAccessToken?: (auth: GooglePlayAuthConfig) => Promise<string>;
1181
+ }
1182
+ /**
1183
+ * Google Play 上传器。
1184
+ *
1185
+ * 首版能力刻意限制为:上传一个 AAB 到内部测试轨道并保留为 draft。
1186
+ * 配置层与 Google Play API 都使用 internal 作为内部测试轨道标识。
1187
+ * 创建应用、填写商店资料、提交审核和生产发布均不在此适配器范围内。
1188
+ */
1189
+ declare class GooglePlayUploader implements IUploader {
1190
+ name: string;
1191
+ private readonly httpClient;
1192
+ private readonly getAccessToken;
1193
+ constructor(dependencies?: GooglePlayUploaderDependencies);
1194
+ validateConfig(config: any): boolean;
1195
+ canHandle(filePath: string): boolean;
1196
+ upload(filePath: string, config: any, _metadata: AppMetadata): Promise<UploadResult>;
1197
+ private createAccessToken;
1198
+ private deleteEditBestEffort;
1199
+ private describeError;
1200
+ private redactAndTruncate;
1201
+ private failure;
1202
+ }
1203
+
1165
1204
  interface RetryConfig {
1166
1205
  maxRetries?: number;
1167
1206
  initialDelayMs?: number;
@@ -1306,7 +1345,7 @@ declare class UploadManager {
1306
1345
  /**
1307
1346
  * 重试失败的平台
1308
1347
  */
1309
- retryFailedPlatforms(failedPlatforms: string[], filePath: string, config: any, metadata: AppMetadata): Promise<UploadReport>;
1348
+ retryFailedPlatforms(failedPlatforms: string[], filePath: string | string[], config: any, metadata: AppMetadata): Promise<UploadReport>;
1310
1349
  }
1311
1350
  /**
1312
1351
  * 创建上传管理器实例
@@ -1401,4 +1440,88 @@ interface ParseOptions {
1401
1440
  */
1402
1441
  declare function parsePackageInfo(filePath: string, options?: ParseOptions): Promise<PackageInfo | null>;
1403
1442
 
1404
- export { AdHocUploader, type AppMetadata, AppleJWTGenerator, AppleStoreUploader, type BuildResult, ConfigValidator, DEFAULT_RETRY_CONFIG, EnvValidator, ErrorCategory, HarmonyUploader, HuaweiUploader, type IUploader, OppoUploader, type PackageInfo, type ParseOptions, PgyerUploader, type RetryConfig, type RetryResult, RetryStrategy, TencentUploader, TestFlightUploader, type UploadConfig, UploadManager, type UploadManagerConfig, type UploadReport, type UploadResult, VivoUploader, XiaomiUploader, createUploadManager, createUploadRetryStrategy, parsePackageInfo };
1443
+ declare const RELEASE_RECEIPT_SCHEMA_VERSION: 1;
1444
+ declare const DEFAULT_RELEASE_RECEIPT_LIMIT = 100;
1445
+ type ReleaseReceiptKind = 'build' | 'upload';
1446
+ type ReleaseReceiptOutcome = 'success' | 'partial' | 'failed' | 'cancelled';
1447
+ type ReleaseReceiptState = 'built' | 'uploaded' | 'draft_created' | 'review_submitted' | 'reviewing' | 'approved' | 'rejected' | 'released' | 'failed' | 'cancelled';
1448
+ interface ReleaseArtifactReceipt {
1449
+ path: string;
1450
+ name: string;
1451
+ sizeBytes?: number;
1452
+ sha256?: string;
1453
+ available: boolean;
1454
+ }
1455
+ interface ReleaseRemoteReceipt {
1456
+ consoleUrl?: string;
1457
+ downloadUrl?: string;
1458
+ identifiers?: Record<string, string | number | boolean>;
1459
+ }
1460
+ interface ReleaseTargetReceipt {
1461
+ platform: string;
1462
+ state: ReleaseReceiptState;
1463
+ outcome: ReleaseReceiptOutcome;
1464
+ message: string;
1465
+ remote?: ReleaseRemoteReceipt;
1466
+ lastKnownRemoteStatus?: string;
1467
+ checkedAt?: string;
1468
+ }
1469
+ interface ReleaseReceipt {
1470
+ schemaVersion: typeof RELEASE_RECEIPT_SCHEMA_VERSION;
1471
+ id: string;
1472
+ projectKey: string;
1473
+ projectRoot: string;
1474
+ kind: ReleaseReceiptKind;
1475
+ appName?: string;
1476
+ packageName?: string;
1477
+ versionName?: string;
1478
+ buildNumber?: string;
1479
+ changelog?: string;
1480
+ artifacts: ReleaseArtifactReceipt[];
1481
+ targets: ReleaseTargetReceipt[];
1482
+ outcome: ReleaseReceiptOutcome;
1483
+ startedAt: string;
1484
+ finishedAt: string;
1485
+ durationMs: number;
1486
+ }
1487
+ interface ReleaseReceiptInput {
1488
+ projectRoot: string;
1489
+ kind: ReleaseReceiptKind;
1490
+ appName?: string;
1491
+ packageName?: string;
1492
+ versionName?: string;
1493
+ buildNumber?: string | number;
1494
+ changelog?: string;
1495
+ artifactPaths?: unknown;
1496
+ targets: ReleaseTargetReceipt[];
1497
+ startedAt?: string | number | Date;
1498
+ finishedAt?: string | number | Date;
1499
+ outcome?: ReleaseReceiptOutcome;
1500
+ }
1501
+ interface ReleaseReceiptStoreOptions {
1502
+ storageRoot?: string;
1503
+ maxEntries?: number;
1504
+ }
1505
+ /** 解析发布回执所属项目;显式项目目录优先,未提供时才使用配置文件目录。 */
1506
+ declare function resolveReleaseProjectRoot(projectRoot: string | undefined, configPath: string): string;
1507
+ /** 将可能包含凭据的错误信息压缩为可安全持久化的短文本。 */
1508
+ declare function sanitizeReleaseMessage(value: unknown, maxLength?: number): string;
1509
+ /** 将上传结果转换为稳定、可公开展示的渠道状态。 */
1510
+ declare function createUploadTargets(results: UploadResult[]): ReleaseTargetReceipt[];
1511
+ /** 创建回执;只接受已经挑选过的业务字段,不接受完整配置或原始响应。 */
1512
+ declare function createReleaseReceipt(input: ReleaseReceiptInput): Promise<ReleaseReceipt>;
1513
+ /** 将回执转换为适合复制给客户或 AI 的纯文本摘要。 */
1514
+ declare function formatReleaseReceipt(receipt: ReleaseReceipt): string;
1515
+ declare class ReleaseReceiptStore {
1516
+ private readonly storageRoot;
1517
+ private readonly maxEntries;
1518
+ constructor(options?: ReleaseReceiptStoreOptions);
1519
+ append(receipt: ReleaseReceipt): Promise<void>;
1520
+ list(projectRoot: string, limit?: number): Promise<ReleaseReceipt[]>;
1521
+ save(input: ReleaseReceiptInput): Promise<ReleaseReceipt>;
1522
+ private getFilePath;
1523
+ private readFile;
1524
+ }
1525
+ declare function createProjectKey(projectRoot: string): string;
1526
+
1527
+ export { AdHocUploader, type AppMetadata, AppleJWTGenerator, AppleStoreUploader, type BuildResult, ConfigValidator, DEFAULT_RELEASE_RECEIPT_LIMIT, DEFAULT_RETRY_CONFIG, EnvValidator, ErrorCategory, GooglePlayUploader, type GooglePlayUploaderDependencies, HarmonyUploader, HuaweiUploader, type IUploader, OppoUploader, type PackageInfo, type ParseOptions, PgyerUploader, RELEASE_RECEIPT_SCHEMA_VERSION, type ReleaseArtifactReceipt, type ReleaseReceipt, type ReleaseReceiptInput, type ReleaseReceiptKind, type ReleaseReceiptOutcome, type ReleaseReceiptState, ReleaseReceiptStore, type ReleaseReceiptStoreOptions, type ReleaseRemoteReceipt, type ReleaseTargetReceipt, type RetryConfig, type RetryResult, RetryStrategy, TencentUploader, TestFlightUploader, type UploadConfig, UploadManager, type UploadManagerConfig, type UploadReport, type UploadResult, VivoUploader, XiaomiUploader, createProjectKey, createReleaseReceipt, createUploadManager, createUploadRetryStrategy, createUploadTargets, formatReleaseReceipt, parsePackageInfo, resolveReleaseProjectRoot, sanitizeReleaseMessage };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 上传配置接口
3
- */
4
- interface UploadConfig {
3
+ */ interface UploadConfig {
5
4
  /** 应用 ID */
6
5
  appId?: string;
7
6
  /** 版本号 */
@@ -406,8 +405,8 @@ interface UploadConfig {
406
405
  };
407
406
  /** 包名 */
408
407
  packageName?: string;
409
- /** 发布轨道:internal | alpha | beta | production */
410
- track?: 'internal' | 'alpha' | 'beta' | 'production';
408
+ /** 发布轨道;首版只支持 internal */
409
+ track?: 'internal';
411
410
  };
412
411
  /** 未来扩展的其他平台 */
413
412
  [key: string]: any;
@@ -415,8 +414,7 @@ interface UploadConfig {
415
414
  }
416
415
  /**
417
416
  * 应用元数据接口
418
- */
419
- interface AppMetadata {
417
+ */ interface AppMetadata {
420
418
  /** 版本号 */
421
419
  version: string;
422
420
  /** 应用名称 */
@@ -439,8 +437,7 @@ interface AppMetadata {
439
437
  }
440
438
  /**
441
439
  * 上传结果接口
442
- */
443
- interface UploadResult {
440
+ */ interface UploadResult {
444
441
  /** 平台名称 */
445
442
  platform: string;
446
443
  /** 是否成功 */
@@ -469,8 +466,7 @@ interface UploadResult {
469
466
  }
470
467
  /**
471
468
  * 上传器接口
472
- */
473
- interface IUploader {
469
+ */ interface IUploader {
474
470
  /** 上传器名称 */
475
471
  name: string;
476
472
  /**
@@ -491,8 +487,7 @@ interface IUploader {
491
487
  }
492
488
  /**
493
489
  * 构建结果接口
494
- */
495
- interface BuildResult {
490
+ */ interface BuildResult {
496
491
  /** 是否成功 */
497
492
  success: boolean;
498
493
  /**
@@ -521,6 +516,12 @@ declare class ConfigValidator {
521
516
  * @param filePath 配置文件路径
522
517
  */
523
518
  static loadAndValidate(filePath: string): UploadConfig | null;
519
+ /**
520
+ * 只收集本次实际启用配置中的环境变量,避免禁用平台阻塞其它上传任务。
521
+ */
522
+ private static collectRequiredEnvVars;
523
+ /** 在内存中递归解析环境变量,不重新拼接 YAML,避免密钥字符破坏 YAML 结构。 */
524
+ private static resolveEnvVars;
524
525
  /**
525
526
  * 验证配置 Schema
526
527
  * @param config 配置对象
@@ -1162,6 +1163,44 @@ declare class TencentUploader implements IUploader {
1162
1163
  private submitModifyAppInfo;
1163
1164
  }
1164
1165
 
1166
+ interface GooglePlayHttpResponse<T = any> {
1167
+ data: T;
1168
+ }
1169
+ interface GooglePlayHttpClient {
1170
+ post<T = any>(url: string, data?: any, config?: any): Promise<GooglePlayHttpResponse<T>>;
1171
+ put<T = any>(url: string, data?: any, config?: any): Promise<GooglePlayHttpResponse<T>>;
1172
+ delete<T = any>(url: string, config?: any): Promise<GooglePlayHttpResponse<T>>;
1173
+ }
1174
+ interface GooglePlayAuthConfig {
1175
+ serviceAccountJsonPath?: string;
1176
+ serviceAccountJsonContent?: string;
1177
+ }
1178
+ interface GooglePlayUploaderDependencies {
1179
+ httpClient?: GooglePlayHttpClient;
1180
+ getAccessToken?: (auth: GooglePlayAuthConfig) => Promise<string>;
1181
+ }
1182
+ /**
1183
+ * Google Play 上传器。
1184
+ *
1185
+ * 首版能力刻意限制为:上传一个 AAB 到内部测试轨道并保留为 draft。
1186
+ * 配置层与 Google Play API 都使用 internal 作为内部测试轨道标识。
1187
+ * 创建应用、填写商店资料、提交审核和生产发布均不在此适配器范围内。
1188
+ */
1189
+ declare class GooglePlayUploader implements IUploader {
1190
+ name: string;
1191
+ private readonly httpClient;
1192
+ private readonly getAccessToken;
1193
+ constructor(dependencies?: GooglePlayUploaderDependencies);
1194
+ validateConfig(config: any): boolean;
1195
+ canHandle(filePath: string): boolean;
1196
+ upload(filePath: string, config: any, _metadata: AppMetadata): Promise<UploadResult>;
1197
+ private createAccessToken;
1198
+ private deleteEditBestEffort;
1199
+ private describeError;
1200
+ private redactAndTruncate;
1201
+ private failure;
1202
+ }
1203
+
1165
1204
  interface RetryConfig {
1166
1205
  maxRetries?: number;
1167
1206
  initialDelayMs?: number;
@@ -1306,7 +1345,7 @@ declare class UploadManager {
1306
1345
  /**
1307
1346
  * 重试失败的平台
1308
1347
  */
1309
- retryFailedPlatforms(failedPlatforms: string[], filePath: string, config: any, metadata: AppMetadata): Promise<UploadReport>;
1348
+ retryFailedPlatforms(failedPlatforms: string[], filePath: string | string[], config: any, metadata: AppMetadata): Promise<UploadReport>;
1310
1349
  }
1311
1350
  /**
1312
1351
  * 创建上传管理器实例
@@ -1401,4 +1440,88 @@ interface ParseOptions {
1401
1440
  */
1402
1441
  declare function parsePackageInfo(filePath: string, options?: ParseOptions): Promise<PackageInfo | null>;
1403
1442
 
1404
- export { AdHocUploader, type AppMetadata, AppleJWTGenerator, AppleStoreUploader, type BuildResult, ConfigValidator, DEFAULT_RETRY_CONFIG, EnvValidator, ErrorCategory, HarmonyUploader, HuaweiUploader, type IUploader, OppoUploader, type PackageInfo, type ParseOptions, PgyerUploader, type RetryConfig, type RetryResult, RetryStrategy, TencentUploader, TestFlightUploader, type UploadConfig, UploadManager, type UploadManagerConfig, type UploadReport, type UploadResult, VivoUploader, XiaomiUploader, createUploadManager, createUploadRetryStrategy, parsePackageInfo };
1443
+ declare const RELEASE_RECEIPT_SCHEMA_VERSION: 1;
1444
+ declare const DEFAULT_RELEASE_RECEIPT_LIMIT = 100;
1445
+ type ReleaseReceiptKind = 'build' | 'upload';
1446
+ type ReleaseReceiptOutcome = 'success' | 'partial' | 'failed' | 'cancelled';
1447
+ type ReleaseReceiptState = 'built' | 'uploaded' | 'draft_created' | 'review_submitted' | 'reviewing' | 'approved' | 'rejected' | 'released' | 'failed' | 'cancelled';
1448
+ interface ReleaseArtifactReceipt {
1449
+ path: string;
1450
+ name: string;
1451
+ sizeBytes?: number;
1452
+ sha256?: string;
1453
+ available: boolean;
1454
+ }
1455
+ interface ReleaseRemoteReceipt {
1456
+ consoleUrl?: string;
1457
+ downloadUrl?: string;
1458
+ identifiers?: Record<string, string | number | boolean>;
1459
+ }
1460
+ interface ReleaseTargetReceipt {
1461
+ platform: string;
1462
+ state: ReleaseReceiptState;
1463
+ outcome: ReleaseReceiptOutcome;
1464
+ message: string;
1465
+ remote?: ReleaseRemoteReceipt;
1466
+ lastKnownRemoteStatus?: string;
1467
+ checkedAt?: string;
1468
+ }
1469
+ interface ReleaseReceipt {
1470
+ schemaVersion: typeof RELEASE_RECEIPT_SCHEMA_VERSION;
1471
+ id: string;
1472
+ projectKey: string;
1473
+ projectRoot: string;
1474
+ kind: ReleaseReceiptKind;
1475
+ appName?: string;
1476
+ packageName?: string;
1477
+ versionName?: string;
1478
+ buildNumber?: string;
1479
+ changelog?: string;
1480
+ artifacts: ReleaseArtifactReceipt[];
1481
+ targets: ReleaseTargetReceipt[];
1482
+ outcome: ReleaseReceiptOutcome;
1483
+ startedAt: string;
1484
+ finishedAt: string;
1485
+ durationMs: number;
1486
+ }
1487
+ interface ReleaseReceiptInput {
1488
+ projectRoot: string;
1489
+ kind: ReleaseReceiptKind;
1490
+ appName?: string;
1491
+ packageName?: string;
1492
+ versionName?: string;
1493
+ buildNumber?: string | number;
1494
+ changelog?: string;
1495
+ artifactPaths?: unknown;
1496
+ targets: ReleaseTargetReceipt[];
1497
+ startedAt?: string | number | Date;
1498
+ finishedAt?: string | number | Date;
1499
+ outcome?: ReleaseReceiptOutcome;
1500
+ }
1501
+ interface ReleaseReceiptStoreOptions {
1502
+ storageRoot?: string;
1503
+ maxEntries?: number;
1504
+ }
1505
+ /** 解析发布回执所属项目;显式项目目录优先,未提供时才使用配置文件目录。 */
1506
+ declare function resolveReleaseProjectRoot(projectRoot: string | undefined, configPath: string): string;
1507
+ /** 将可能包含凭据的错误信息压缩为可安全持久化的短文本。 */
1508
+ declare function sanitizeReleaseMessage(value: unknown, maxLength?: number): string;
1509
+ /** 将上传结果转换为稳定、可公开展示的渠道状态。 */
1510
+ declare function createUploadTargets(results: UploadResult[]): ReleaseTargetReceipt[];
1511
+ /** 创建回执;只接受已经挑选过的业务字段,不接受完整配置或原始响应。 */
1512
+ declare function createReleaseReceipt(input: ReleaseReceiptInput): Promise<ReleaseReceipt>;
1513
+ /** 将回执转换为适合复制给客户或 AI 的纯文本摘要。 */
1514
+ declare function formatReleaseReceipt(receipt: ReleaseReceipt): string;
1515
+ declare class ReleaseReceiptStore {
1516
+ private readonly storageRoot;
1517
+ private readonly maxEntries;
1518
+ constructor(options?: ReleaseReceiptStoreOptions);
1519
+ append(receipt: ReleaseReceipt): Promise<void>;
1520
+ list(projectRoot: string, limit?: number): Promise<ReleaseReceipt[]>;
1521
+ save(input: ReleaseReceiptInput): Promise<ReleaseReceipt>;
1522
+ private getFilePath;
1523
+ private readFile;
1524
+ }
1525
+ declare function createProjectKey(projectRoot: string): string;
1526
+
1527
+ export { AdHocUploader, type AppMetadata, AppleJWTGenerator, AppleStoreUploader, type BuildResult, ConfigValidator, DEFAULT_RELEASE_RECEIPT_LIMIT, DEFAULT_RETRY_CONFIG, EnvValidator, ErrorCategory, GooglePlayUploader, type GooglePlayUploaderDependencies, HarmonyUploader, HuaweiUploader, type IUploader, OppoUploader, type PackageInfo, type ParseOptions, PgyerUploader, RELEASE_RECEIPT_SCHEMA_VERSION, type ReleaseArtifactReceipt, type ReleaseReceipt, type ReleaseReceiptInput, type ReleaseReceiptKind, type ReleaseReceiptOutcome, type ReleaseReceiptState, ReleaseReceiptStore, type ReleaseReceiptStoreOptions, type ReleaseRemoteReceipt, type ReleaseTargetReceipt, type RetryConfig, type RetryResult, RetryStrategy, TencentUploader, TestFlightUploader, type UploadConfig, UploadManager, type UploadManagerConfig, type UploadReport, type UploadResult, VivoUploader, XiaomiUploader, createProjectKey, createReleaseReceipt, createUploadManager, createUploadRetryStrategy, createUploadTargets, formatReleaseReceipt, parsePackageInfo, resolveReleaseProjectRoot, sanitizeReleaseMessage };