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

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.
@@ -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,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,6 +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
  }
@@ -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 };