@antglobal/voyager-campaign-sdk 1.0.0 → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * CN 协议中心签约公共流程(mp 与 mp_web 共用,基于 @alipay/agreement-utils);
3
- * 环境判断与工具库加载由各平台注入。
2
+ * CN 协议中心签约公共流程(基于 @alipay/agreement-utils);
3
+ * 环境判断与工具库加载由本端注入。
4
4
  */
5
5
  import type { AgreementUtilsPort } from './types';
6
6
  import type { SignResult } from '../types';
@@ -15,7 +15,7 @@ export declare function getDevEnvInfo(): DevEnvInfo | undefined;
15
15
  * 非 PROD 环境注入联调信息:sofa -> sofa-group-name 头,pspId -> 请求参数,
16
16
  * userId -> mockAuth + userId 头,AppId -> AppId 头,并移除 _voyager_dev_env 参数
17
17
  */
18
- export declare function applyDevEnvInfo(headers: Record<string, string>, params: Record<string, unknown>): void;
18
+ export declare function applyDevEnvInfo(headers: Record<string, string>, params: Record<string, unknown>, env?: string): void;
19
19
  /** headers 同步写入 requestData[0].extHeaders:兼容容器不支持自定义请求头 */
20
20
  export declare function addExtHeaders(requestData: Array<Record<string, unknown>>, headers: Record<string, string>): void;
21
21
  /** 按环境与钱包选联调网关;PRE 额外携带 workspaceId=pre */
@@ -1,4 +1,4 @@
1
- import type { SignResult, SystemInfo, VoyagerPlatform } from '../types';
1
+ import type { SignResult, SystemInfo, VoyagerPlatform, VoyagerRequestOptions } from '../types';
2
2
  export type { VoyagerPlatform };
3
3
  export interface RpcPayload {
4
4
  operationType: string;
@@ -6,24 +6,21 @@ export interface RpcPayload {
6
6
  serviceCode: string;
7
7
  params: Array<Record<string, unknown>>;
8
8
  }>;
9
- /** DEV/TEST/PRE 联调注入的请求头(_voyager_dev_env) */
9
+ /** 请求路由注入的请求头 */
10
10
  headers?: Record<string, string>;
11
- /** DEV/TEST/PRE 联调切换的网关地址 */
11
+ /** 完整 RPC 网关地址 */
12
12
  gateway?: string;
13
13
  /** PRE 联调环境标识 */
14
14
  workspaceId?: string;
15
15
  }
16
- export interface RequestInput<TParams extends Record<string, unknown> = Record<string, unknown>> {
17
- serviceCode: string;
18
- params: TParams;
19
- }
16
+ export type RequestInput<TParams extends Record<string, unknown> = Record<string, unknown>> = VoyagerRequestOptions<TParams>;
20
17
  export interface StoragePort {
21
18
  read(key: string): Promise<unknown>;
22
19
  write(key: string, data: unknown): Promise<void>;
23
20
  remove(key: string): Promise<void>;
24
21
  }
25
22
  /**
26
- * 平台适配器:mp 与 mp_web 各自实现,共享核心不直接触碰端能力
23
+ * 平台适配器:mp_web 实现端能力对接,共享核心不直接触碰端能力
27
24
  */
28
25
  export interface PlatformAdapter {
29
26
  platform: VoyagerPlatform;
@@ -31,9 +28,9 @@ export interface PlatformAdapter {
31
28
  /** 发送前对 payload 做平台级加工(如 mp_web 联调环境的网关切换与请求头注入) */
32
29
  decoratePayload?(payload: RpcPayload): Promise<RpcPayload> | RpcPayload;
33
30
  getSystemInfo(): Promise<SystemInfo>;
34
- /** 钱包标识(对齐 biz-base 取 hylid client):mp_web 用 client,mp 固定 alipay */
31
+ /** 钱包标识(对齐 biz-base 取 hylid client),未识别兜底 unknown */
35
32
  getClientName(): string;
36
- /** 当前语言原始值:mp_web 用 hylid getCurrentLanguage,mp 用 systemInfo 语言字段 */
33
+ /** 当前语言原始值(hylid getCurrentLanguage) */
37
34
  getLocale(systemInfo: SystemInfo): string;
38
35
  /** 可选:获取风控 tokenId(envInfo.tokenId),未提供时不注入 */
39
36
  getAppToken?(): Promise<string | undefined>;
@@ -0,0 +1,19 @@
1
+ /** iQuic 平台语言模型,对齐 aplus-biz-base i18n/interface.ts */
2
+ export declare const Language: {
3
+ readonly zh_CN: "zh_CN";
4
+ readonly zh_HK: "zh_HK";
5
+ readonly en_US: "en_US";
6
+ readonly th_TH: "th_TH";
7
+ readonly ko_KR: "ko_KR";
8
+ readonly it_IT: "it_IT";
9
+ readonly in_ID: "in_ID";
10
+ };
11
+ export type Language = (typeof Language)[keyof typeof Language];
12
+ /**
13
+ * 按钱包匹配支持的语言,对齐 aplus-biz-base matchSiteSupportedLanguage:
14
+ * 1. 归一化原始语言(连字符转下划线、id→in、region 大写)
15
+ * 2. 全匹配(忽略大小写)→ 返回
16
+ * 3. 前缀匹配 → 返回
17
+ * 4. 兜底 → 返回列表第一个或 en_US
18
+ */
19
+ export declare function matchWalletSupportedLanguage(clientName: string, rawLocale: string): Language;