@antglobal/voyager-campaign-sdk 0.0.1788950302-dev.2 → 0.0.1788950302-dev.4

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,16 +1,31 @@
1
1
  /**
2
- * CN 协议中心签约公共流程(mp 与 mp_web 共用,基于 @alipay/agreement-utils);
3
- * 环境判断与工具库加载由各平台注入。
2
+ * CN 协议中心签约公共流程(mp 与 mp_web 共用,直接使用 openRpc);
3
+ * 环境判断与开放通道由各平台注入。
4
4
  */
5
- import type { AgreementUtilsPort } from './types';
6
5
  import type { SignResult } from '../types';
6
+ import type { OpenRpcPayload } from './openRpc';
7
+ interface AgreementResponse {
8
+ success?: boolean;
9
+ userId?: string;
10
+ errorContext?: {
11
+ errorMsg?: string;
12
+ };
13
+ data?: {
14
+ userId?: string;
15
+ signRecordVOS?: Array<{
16
+ agreementId?: string;
17
+ status?: string;
18
+ }>;
19
+ };
20
+ }
7
21
  export interface AgreementSignFlowOptions {
8
22
  /** prod/pre 用正式签约产品,其余环境用联调签约产品 */
9
23
  isProdOrPreEnv: () => boolean;
10
- loadAgreementUtils: () => AgreementUtilsPort;
24
+ openRpc: (payload: OpenRpcPayload) => Promise<AgreementResponse>;
11
25
  }
12
26
  export interface AgreementSignFlow {
13
27
  querySignStatus(): Promise<SignResult>;
14
28
  sign(): Promise<SignResult>;
15
29
  }
16
30
  export declare function createAgreementSignFlow(options: AgreementSignFlowOptions): AgreementSignFlow;
31
+ export {};
@@ -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 */
@@ -0,0 +1,10 @@
1
+ import type { VoyagerPlatform } from '../types';
2
+ export interface OpenRpcPayload {
3
+ operationType: string;
4
+ requestData: Array<Record<string, unknown>>;
5
+ gateway?: string;
6
+ headers?: Record<string, string>;
7
+ }
8
+ export declare function rpcError(error: unknown, fallback: string): Error;
9
+ /** CN 开放通道;不回退到普通 rpc。响应保持原样,业务 data 不解包。 */
10
+ export declare function callOpenRpc<TResponse>(platform: VoyagerPlatform, payload: OpenRpcPayload): Promise<TResponse>;
@@ -0,0 +1,9 @@
1
+ import type { VoyagerRequestEnvInfo } from '../types';
2
+ export declare function resolveRequestEnvInfo(value?: VoyagerRequestEnvInfo): VoyagerRequestEnvInfo;
3
+ export declare function getRequestRouting(info: VoyagerRequestEnvInfo, clientName: string): {
4
+ headers?: {
5
+ 'sofa-group-name': string;
6
+ } | undefined;
7
+ workspaceId?: string | undefined;
8
+ gateway: string;
9
+ };
@@ -1,4 +1,4 @@
1
- import type { SignResult, SystemInfo, VoyagerPlatform } from '../types';
1
+ import type { SignResult, SystemInfo, VoyagerPlatform, VoyagerRequestOptions, VoyagerRequestEnvInfo } from '../types';
2
2
  export type { VoyagerPlatform };
3
3
  export interface RpcPayload {
4
4
  operationType: string;
@@ -6,20 +6,17 @@ 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
- /** 外部传入的环境标识(dev/test/pre/prod),用于 mp 匹配联调网关 */
16
- env?: string;
17
- }
18
- export interface RequestInput<TParams extends Record<string, unknown> = Record<string, unknown>> {
19
- serviceCode: string;
20
- params: TParams;
15
+ /** 有效业务请求环境;内部签约请求可省略。 */
21
16
  env?: string;
17
+ routingInfo?: VoyagerRequestEnvInfo;
22
18
  }
19
+ export type RequestInput<TParams extends Record<string, unknown> = Record<string, unknown>> = VoyagerRequestOptions<TParams>;
23
20
  export interface StoragePort {
24
21
  read(key: string): Promise<unknown>;
25
22
  write(key: string, data: unknown): Promise<void>;
@@ -42,25 +39,7 @@ export interface PlatformAdapter {
42
39
  getAppToken?(): Promise<string | undefined>;
43
40
  storage: StoragePort;
44
41
  fetchWhitelistConfig(): Promise<unknown>;
42
+ fetchMockConfig?(): Promise<unknown>;
45
43
  querySignStatus(): Promise<SignResult>;
46
44
  sign(): Promise<SignResult>;
47
45
  }
48
- export interface AgreementUtilsPort {
49
- querySignRecord(productCd: string): Promise<{
50
- success?: boolean;
51
- data?: {
52
- userId?: string;
53
- signRecordVOS?: Array<{
54
- agreementId?: string;
55
- status?: string;
56
- }>;
57
- };
58
- }>;
59
- signAgreement(options: {
60
- productCd: string;
61
- agreementIds: string[];
62
- }): Promise<{
63
- success?: boolean;
64
- userId?: string;
65
- }>;
66
- }
@@ -0,0 +1,5 @@
1
+ import type { PlatformAdapter } from '../adapter/types';
2
+ export declare const MOCK_CONFIG_URL = "https://config-dev.marmot-cloud.com/config/voyager-campaign-sdk-config_service-code-whitelist-mock/en_US.json";
3
+ /** Marmot may encode JSON repeatedly, including escaped JSON without outer quotes. */
4
+ export declare function decodeMockData(value: unknown): unknown;
5
+ export declare function requestMock(adapter: PlatformAdapter, serviceCode: string): Promise<unknown>;
@@ -1,6 +1,6 @@
1
1
  import type { PlatformAdapter } from '../adapter/types';
2
- import type { VoyagerEnvInfo } from '../types';
2
+ import type { VoyagerEnvInfo, VoyagerRequestEnvInfo } from '../types';
3
3
  import { createEnvInfoLoader } from './envInfo';
4
- export type RawRequestFn = <TResponse>(serviceCode: string, params: Record<string, unknown>, env?: string) => Promise<TResponse>;
4
+ export type RawRequestFn = <TResponse>(serviceCode: string, params: Record<string, unknown>, routingInfo?: VoyagerRequestEnvInfo) => Promise<TResponse>;
5
5
  export declare function createRawRequest(adapter: PlatformAdapter, getEnvInfo: () => Promise<VoyagerEnvInfo>): RawRequestFn;
6
6
  export { createEnvInfoLoader };