@iflyrpa/actions 4.0.9-beta.4 → 4.1.0-beta.6

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.
@@ -14,5 +14,12 @@ export declare class Http {
14
14
  retries?: number;
15
15
  retryDelay?: number;
16
16
  timeout?: number;
17
+ onUploadProgress?: (progressEvent: any) => void;
18
+ /**
19
+ * 外部取消信号(用于用户主动取消上传等场景)。
20
+ * 注意:不能直接用 config.signal —— 下面会用内部 AbortController 覆盖它做超时兜底,
21
+ * 所以外部信号必须在这里传入,由内部 controller 代理转发。
22
+ */
23
+ signal?: AbortSignal;
17
24
  }): Promise<T>;
18
25
  }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * 图片验证选项
3
+ */
4
+ export interface ImageValidationOptions {
5
+ /** 最大文件大小(字节),默认不限制 */
6
+ maxSize?: number;
7
+ /** 允许的文件扩展名(小写,包含点号),如 ['.jpg', '.png'] */
8
+ allowedFormats?: readonly string[];
9
+ /** 最小宽度(像素) */
10
+ minWidth?: number;
11
+ /** 最大宽度(像素) */
12
+ maxWidth?: number;
13
+ /** 最小高度(像素) */
14
+ minHeight?: number;
15
+ /** 最大高度(像素) */
16
+ maxHeight?: number;
17
+ }
18
+ /**
19
+ * 图片验证错误
20
+ */
21
+ export declare class ImageValidationError extends Error {
22
+ code: number;
23
+ data: string;
24
+ constructor(message: string, code?: number, data?: string);
25
+ }
26
+ /**
27
+ * 验证图片文件
28
+ * @param filePath 图片文件路径
29
+ * @param options 验证选项
30
+ * @param platformName 平台名称,用于错误提示
31
+ * @throws {ImageValidationError} 当验证失败时抛出错误
32
+ */
33
+ export declare function validateImageFile(filePath: string, options: ImageValidationOptions, platformName: string): void;
34
+ /**
35
+ * 各平台图片限制预设配置
36
+ */
37
+ export declare const PlatformImageLimits: {
38
+ /** 百家号:5MB,仅支持 jpg、png */
39
+ readonly baijiahao: {
40
+ readonly maxSize: number;
41
+ readonly allowedFormats: readonly [".jpg", ".jpeg", ".png"];
42
+ };
43
+ /** 视频号:20MB */
44
+ readonly shipinhao: {
45
+ readonly maxSize: number;
46
+ };
47
+ /** 头条号:20MB,推荐 jpg、png 格式 */
48
+ readonly toutiao: {
49
+ readonly maxSize: number;
50
+ readonly allowedFormats: readonly [".jpg", ".jpeg", ".png"];
51
+ };
52
+ /** 抖音:50MB */
53
+ readonly douyin: {
54
+ readonly maxSize: number;
55
+ };
56
+ /** 小红书:32MB,支持多种格式 */
57
+ readonly xiaohongshu: {
58
+ readonly maxSize: number;
59
+ readonly allowedFormats: readonly [".jpg", ".jpeg", ".png", ".gif"];
60
+ };
61
+ };
62
+ /**
63
+ * 使用预设配置验证图片
64
+ * @param filePath 图片文件路径
65
+ * @param platform 平台名称
66
+ */
67
+ export declare function validateImageByPlatform(filePath: string, platform: keyof typeof PlatformImageLimits): void;
@@ -0,0 +1,31 @@
1
+ import { Http } from "../http";
2
+ /**
3
+ * 视频号上传认证信息
4
+ *
5
+ * 说明:本文件的两个接口调用逻辑从 actions/shipinhaoPublish/mock.ts 抽取而来,
6
+ * 该流程已在图文发布链路中实测可用,视频上传复用同一套认证。
7
+ */
8
+ export interface ShipinhaoUploadAuth {
9
+ /** 微信号数字 uin,上传接口 X-Arguments 中的 weixinnum */
10
+ uin: number;
11
+ /** 上传接口 Authorization 头 */
12
+ authKey: string;
13
+ /** finderUsername,发布接口 _log_finder_id 使用 */
14
+ finderUsername: string;
15
+ /** 视频 filetype(服务端下发,实测 20302) */
16
+ videoFileType: number;
17
+ /** 图片/封面 filetype(服务端下发,实测 20304) */
18
+ pictureFileType: number;
19
+ }
20
+ /** 认证失败时抛出,携带平台错误码便于上层归类 */
21
+ export declare class ShipinhaoAuthError extends Error {
22
+ readonly errCode: number;
23
+ constructor(message: string, errCode: number);
24
+ }
25
+ /**
26
+ * 获取视频号上传所需的认证信息
27
+ *
28
+ * @param cookies cookie 字符串(`name=value; name=value` 形式)
29
+ * @param http Http 实例(不走代理即可,认证接口对代理无要求)
30
+ */
31
+ export declare function getShipinhaoUploadAuth(cookies: string, http: Http): Promise<ShipinhaoUploadAuth>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iflyrpa/actions",
3
- "version": "4.0.9-beta.4",
3
+ "version": "4.1.0-beta.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",