@djvlc/openapi-user-client 1.3.0 → 1.5.0

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.mts CHANGED
@@ -1,3 +1,6 @@
1
+ import { BaseClientOptions, Configuration as Configuration$1 } from '@djvlc/openapi-client-core';
2
+ export { AbortError, Configuration, DjvApiError, Interceptors, Logger, Middleware, NetworkError, RequestOptions, RetryOptions, TimeoutError, createConsoleLogger, createSilentLogger, isRetryableError } from '@djvlc/openapi-client-core';
3
+
1
4
  interface ConfigurationParameters {
2
5
  basePath?: string;
3
6
  fetchApi?: FetchAPI;
@@ -2534,33 +2537,107 @@ declare namespace apis {
2534
2537
  export { apis_ActionApi as ActionApi, type apis_ActionApiExecuteActionBatchOperationRequest as ActionApiExecuteActionBatchOperationRequest, type apis_ActionApiExecuteActionRequest as ActionApiExecuteActionRequest, type apis_ActionApiInterface as ActionApiInterface, apis_ActivityApi as ActivityApi, type apis_ActivityApiGetActivityStateBatchOperationRequest as ActivityApiGetActivityStateBatchOperationRequest, type apis_ActivityApiGetActivityStateRequest as ActivityApiGetActivityStateRequest, type apis_ActivityApiInterface as ActivityApiInterface, apis_DataApi as DataApi, type apis_DataApiInterface as DataApiInterface, type apis_DataApiQueryDataBatchOperationRequest as DataApiQueryDataBatchOperationRequest, type apis_DataApiQueryDataRequest as DataApiQueryDataRequest, apis_HealthApi as HealthApi, type apis_HealthApiInterface as HealthApiInterface, apis_PageApi as PageApi, type apis_PageApiInterface as PageApiInterface, type apis_PageApiResolvePageBatchOperationRequest as PageApiResolvePageBatchOperationRequest, type apis_PageApiResolvePageRequest as PageApiResolvePageRequest, type apis_ResolvePageChannelEnum as ResolvePageChannelEnum, apis_TrackApi as TrackApi, type apis_TrackApiInterface as TrackApiInterface, type apis_TrackApiTrackOperationRequest as TrackApiTrackOperationRequest };
2535
2538
  }
2536
2539
 
2537
- interface UserClientOptions {
2540
+ /**
2541
+ * @djvlc/openapi-user-client - User API 客户端
2542
+ *
2543
+ * 用于 Runtime 访问 User API(数据面)。
2544
+ *
2545
+ * @example
2546
+ * ```typescript
2547
+ * import { createUserClient, DjvApiError, TimeoutError } from '@djvlc/openapi-user-client';
2548
+ *
2549
+ * const client = createUserClient({
2550
+ * baseUrl: 'https://api.example.com',
2551
+ * getAuthToken: () => localStorage.getItem('token') ?? '',
2552
+ * getTraceHeaders: () => ({ traceparent: '00-...' }),
2553
+ * retry: { maxRetries: 2 },
2554
+ * });
2555
+ *
2556
+ * try {
2557
+ * const page = await client.PageApi.resolvePage({ pageUid: 'xxx' });
2558
+ * } catch (e) {
2559
+ * if (DjvApiError.is(e)) {
2560
+ * console.log('业务错误:', e.code, e.traceId);
2561
+ * } else if (TimeoutError.is(e)) {
2562
+ * console.log('请求超时');
2563
+ * }
2564
+ * }
2565
+ * ```
2566
+ */
2567
+
2568
+ interface UserClientOptions extends Omit<BaseClientOptions, 'baseUrl'> {
2569
+ /** API 基础 URL */
2538
2570
  baseUrl: string;
2539
- /** user-api 可能需要登录态 token(也可能不需要) */
2571
+ /**
2572
+ * 获取认证 Token
2573
+ *
2574
+ * User API 可能需要登录态(也可能不需要)
2575
+ */
2540
2576
  getAuthToken?: () => string | Promise<string>;
2541
- /** OTel:traceparent/baggage/... */
2577
+ /**
2578
+ * 获取追踪头
2579
+ *
2580
+ * OpenTelemetry: traceparent, baggage 等
2581
+ */
2542
2582
  getTraceHeaders?: () => Record<string, string>;
2543
- /** 比如 x-app-key / x-tenant-id / x-device-id */
2583
+ /**
2584
+ * 默认请求头
2585
+ *
2586
+ * 如 x-device-id, x-channel, x-app-key 等
2587
+ */
2544
2588
  defaultHeaders?: Record<string, string>;
2545
- /** 默认 15s(线上 user-api 通常更追求快失败) */
2589
+ /**
2590
+ * 超时时间(毫秒)
2591
+ *
2592
+ * @default 15000 (User API 追求快失败)
2593
+ */
2546
2594
  timeoutMs?: number;
2547
- fetchApi?: typeof fetch;
2548
- /** 默认 omit(通常不走 cookie) */
2595
+ /**
2596
+ * Cookie 策略
2597
+ *
2598
+ * @default 'omit' (User API 通常不走 Cookie)
2599
+ */
2549
2600
  credentials?: RequestCredentials;
2550
2601
  }
2551
- type ApiInstances = {
2552
- [K in keyof typeof apis as K extends `${string}Api` ? (typeof apis)[K] extends new (...args: any) => any ? K : never : never]: (typeof apis)[K] extends new (...args: any) => any ? InstanceType<(typeof apis)[K]> : never;
2602
+ type ApiClasses = typeof apis;
2603
+ type ApiInstanceMap = {
2604
+ [K in keyof ApiClasses as K extends `${string}Api` ? ApiClasses[K] extends new (...args: unknown[]) => unknown ? K : never : never]: ApiClasses[K] extends new (...args: unknown[]) => infer T ? T : never;
2553
2605
  };
2606
+ /**
2607
+ * 创建 User API 客户端
2608
+ *
2609
+ * @param opts - 客户端配置
2610
+ * @returns 包含所有 API 实例的客户端对象
2611
+ *
2612
+ * @example
2613
+ * ```typescript
2614
+ * const client = createUserClient({
2615
+ * baseUrl: 'https://api.example.com',
2616
+ * getAuthToken: () => getToken(),
2617
+ * defaultHeaders: {
2618
+ * 'x-device-id': deviceId,
2619
+ * 'x-channel': 'h5',
2620
+ * },
2621
+ * retry: { maxRetries: 2 },
2622
+ * });
2623
+ *
2624
+ * // 解析页面
2625
+ * const page = await client.PageApi.resolvePage({ pageUid: 'xxx' });
2626
+ *
2627
+ * // 执行动作
2628
+ * const result = await client.ActionsApi.executeAction({
2629
+ * actionExecuteRequest: {
2630
+ * actionType: 'claim',
2631
+ * params: { activityId: 'xxx' },
2632
+ * context: {},
2633
+ * },
2634
+ * });
2635
+ * ```
2636
+ */
2554
2637
  declare function createUserClient(opts: UserClientOptions): {
2555
- ActionApi: ActionApi;
2556
- ActivityApi: ActivityApi;
2557
- DataApi: DataApi;
2558
- HealthApi: HealthApi;
2559
- PageApi: PageApi;
2560
- TrackApi: TrackApi;
2561
- config: Configuration;
2562
- apis: ApiInstances;
2563
- };
2638
+ config: Configuration$1;
2639
+ apis: ApiInstanceMap;
2640
+ } & ApiInstanceMap;
2564
2641
  type UserClient = ReturnType<typeof createUserClient>;
2565
2642
 
2566
- export { ActionApi, type ActionApiExecuteActionBatchOperationRequest, type ActionApiExecuteActionRequest, type ActionApiInterface, type ActionContext, ActionContextFromJSON, ActionContextFromJSONTyped, ActionContextToJSON, ActionContextToJSONTyped, type ActionExecuteRequest, ActionExecuteRequestFromJSON, ActionExecuteRequestFromJSONTyped, ActionExecuteRequestToJSON, ActionExecuteRequestToJSONTyped, type ActionExecuteResponse, ActionExecuteResponseFromJSON, ActionExecuteResponseFromJSONTyped, ActionExecuteResponseToJSON, ActionExecuteResponseToJSONTyped, ActivityApi, type ActivityApiGetActivityStateBatchOperationRequest, type ActivityApiGetActivityStateRequest, type ActivityApiInterface, type ActivityState, type ActivityStateActivityInfo, ActivityStateActivityInfoFromJSON, ActivityStateActivityInfoFromJSONTyped, ActivityStateActivityInfoToJSON, ActivityStateActivityInfoToJSONTyped, ActivityStateFromJSON, ActivityStateFromJSONTyped, type ActivityStateResponse, ActivityStateResponseFromJSON, ActivityStateResponseFromJSONTyped, ActivityStateResponseToJSON, ActivityStateResponseToJSONTyped, ActivityStateStatusEnum, ActivityStateToJSON, ActivityStateToJSONTyped, type BaseResponseVo, BaseResponseVoFromJSON, BaseResponseVoFromJSONTyped, BaseResponseVoToJSON, BaseResponseVoToJSONTyped, type BlockedComponent, BlockedComponentFromJSON, BlockedComponentFromJSONTyped, BlockedComponentToJSON, BlockedComponentToJSONTyped, Configuration, DataApi, type DataApiInterface, type DataApiQueryDataBatchOperationRequest, type DataApiQueryDataRequest, type DataQueryContext, DataQueryContextFromJSON, DataQueryContextFromJSONTyped, DataQueryContextToJSON, DataQueryContextToJSONTyped, type DataQueryRequest, DataQueryRequestFromJSON, DataQueryRequestFromJSONTyped, DataQueryRequestToJSON, DataQueryRequestToJSONTyped, type DataQueryResponse, DataQueryResponseFromJSON, DataQueryResponseFromJSONTyped, DataQueryResponseToJSON, DataQueryResponseToJSONTyped, type ErrorDetail, ErrorDetailFromJSON, ErrorDetailFromJSONTyped, ErrorDetailToJSON, ErrorDetailToJSONTyped, type ErrorResponseVo, ErrorResponseVoFromJSON, ErrorResponseVoFromJSONTyped, ErrorResponseVoToJSON, ErrorResponseVoToJSONTyped, type ExecuteActionBatch200Response, ExecuteActionBatch200ResponseFromJSON, ExecuteActionBatch200ResponseFromJSONTyped, ExecuteActionBatch200ResponseToJSON, ExecuteActionBatch200ResponseToJSONTyped, type ExecuteActionBatchRequest, ExecuteActionBatchRequestFromJSON, ExecuteActionBatchRequestFromJSONTyped, ExecuteActionBatchRequestToJSON, ExecuteActionBatchRequestToJSONTyped, type GetActivityStateBatch200Response, GetActivityStateBatch200ResponseFromJSON, GetActivityStateBatch200ResponseFromJSONTyped, GetActivityStateBatch200ResponseToJSON, GetActivityStateBatch200ResponseToJSONTyped, type GetActivityStateBatchRequest, GetActivityStateBatchRequestFromJSON, GetActivityStateBatchRequestFromJSONTyped, GetActivityStateBatchRequestToJSON, GetActivityStateBatchRequestToJSONTyped, HealthApi, type HealthApiInterface, type HealthResponse, type HealthResponseChecksValue, HealthResponseChecksValueFromJSON, HealthResponseChecksValueFromJSONTyped, HealthResponseChecksValueToJSON, HealthResponseChecksValueToJSONTyped, HealthResponseFromJSON, HealthResponseFromJSONTyped, HealthResponseStatusEnum, HealthResponseToJSON, HealthResponseToJSONTyped, type ManifestItem, ManifestItemFromJSON, ManifestItemFromJSONTyped, ManifestItemToJSON, ManifestItemToJSONTyped, PageApi, type PageApiInterface, type PageApiResolvePageBatchOperationRequest, type PageApiResolvePageRequest, type PageManifest, PageManifestFromJSON, PageManifestFromJSONTyped, PageManifestToJSON, PageManifestToJSONTyped, type PageResolveResponse, PageResolveResponseFromJSON, PageResolveResponseFromJSONTyped, PageResolveResponseToJSON, PageResolveResponseToJSONTyped, type PageResolveResult, PageResolveResultFromJSON, PageResolveResultFromJSONTyped, PageResolveResultToJSON, PageResolveResultToJSONTyped, type QueryDataBatch200Response, QueryDataBatch200ResponseFromJSON, QueryDataBatch200ResponseFromJSONTyped, QueryDataBatch200ResponseToJSON, QueryDataBatch200ResponseToJSONTyped, type QueryDataBatchRequest, QueryDataBatchRequestFromJSON, QueryDataBatchRequestFromJSONTyped, QueryDataBatchRequestToJSON, QueryDataBatchRequestToJSONTyped, type ResolvePageBatch200Response, ResolvePageBatch200ResponseFromJSON, ResolvePageBatch200ResponseFromJSONTyped, ResolvePageBatch200ResponseToJSON, ResolvePageBatch200ResponseToJSONTyped, type ResolvePageBatchRequest, ResolvePageBatchRequestChannelEnum, ResolvePageBatchRequestFromJSON, ResolvePageBatchRequestFromJSONTyped, ResolvePageBatchRequestToJSON, ResolvePageBatchRequestToJSONTyped, ResolvePageChannelEnum, type RuntimeConfig, RuntimeConfigFromJSON, RuntimeConfigFromJSONTyped, type RuntimeConfigReportConfig, RuntimeConfigReportConfigFromJSON, RuntimeConfigReportConfigFromJSONTyped, RuntimeConfigReportConfigToJSON, RuntimeConfigReportConfigToJSONTyped, RuntimeConfigToJSON, RuntimeConfigToJSONTyped, type TraceContext, TraceContextFromJSON, TraceContextFromJSONTyped, TraceContextToJSON, TraceContextToJSONTyped, TrackApi, type TrackApiInterface, type TrackApiTrackOperationRequest, type TrackContext, TrackContextFromJSON, TrackContextFromJSONTyped, TrackContextToJSON, TrackContextToJSONTyped, type TrackEvent, TrackEventEventTypeEnum, TrackEventFromJSON, TrackEventFromJSONTyped, TrackEventToJSON, TrackEventToJSONTyped, type TrackRequest, TrackRequestFromJSON, TrackRequestFromJSONTyped, TrackRequestToJSON, TrackRequestToJSONTyped, type UserActivityState, UserActivityStateFromJSON, UserActivityStateFromJSONTyped, type UserActivityStateProgress, UserActivityStateProgressFromJSON, UserActivityStateProgressFromJSONTyped, UserActivityStateProgressToJSON, UserActivityStateProgressToJSONTyped, UserActivityStateToJSON, UserActivityStateToJSONTyped, type UserClient, type UserClientOptions, createUserClient, instanceOfActionContext, instanceOfActionExecuteRequest, instanceOfActionExecuteResponse, instanceOfActivityState, instanceOfActivityStateActivityInfo, instanceOfActivityStateResponse, instanceOfBaseResponseVo, instanceOfBlockedComponent, instanceOfDataQueryContext, instanceOfDataQueryRequest, instanceOfDataQueryResponse, instanceOfErrorDetail, instanceOfErrorResponseVo, instanceOfExecuteActionBatch200Response, instanceOfExecuteActionBatchRequest, instanceOfGetActivityStateBatch200Response, instanceOfGetActivityStateBatchRequest, instanceOfHealthResponse, instanceOfHealthResponseChecksValue, instanceOfManifestItem, instanceOfPageManifest, instanceOfPageResolveResponse, instanceOfPageResolveResult, instanceOfQueryDataBatch200Response, instanceOfQueryDataBatchRequest, instanceOfResolvePageBatch200Response, instanceOfResolvePageBatchRequest, instanceOfRuntimeConfig, instanceOfRuntimeConfigReportConfig, instanceOfTraceContext, instanceOfTrackContext, instanceOfTrackEvent, instanceOfTrackRequest, instanceOfUserActivityState, instanceOfUserActivityStateProgress };
2643
+ export { ActionApi, type ActionApiExecuteActionBatchOperationRequest, type ActionApiExecuteActionRequest, type ActionApiInterface, type ActionContext, ActionContextFromJSON, ActionContextFromJSONTyped, ActionContextToJSON, ActionContextToJSONTyped, type ActionExecuteRequest, ActionExecuteRequestFromJSON, ActionExecuteRequestFromJSONTyped, ActionExecuteRequestToJSON, ActionExecuteRequestToJSONTyped, type ActionExecuteResponse, ActionExecuteResponseFromJSON, ActionExecuteResponseFromJSONTyped, ActionExecuteResponseToJSON, ActionExecuteResponseToJSONTyped, ActivityApi, type ActivityApiGetActivityStateBatchOperationRequest, type ActivityApiGetActivityStateRequest, type ActivityApiInterface, type ActivityState, type ActivityStateActivityInfo, ActivityStateActivityInfoFromJSON, ActivityStateActivityInfoFromJSONTyped, ActivityStateActivityInfoToJSON, ActivityStateActivityInfoToJSONTyped, ActivityStateFromJSON, ActivityStateFromJSONTyped, type ActivityStateResponse, ActivityStateResponseFromJSON, ActivityStateResponseFromJSONTyped, ActivityStateResponseToJSON, ActivityStateResponseToJSONTyped, ActivityStateStatusEnum, ActivityStateToJSON, ActivityStateToJSONTyped, type BaseResponseVo, BaseResponseVoFromJSON, BaseResponseVoFromJSONTyped, BaseResponseVoToJSON, BaseResponseVoToJSONTyped, type BlockedComponent, BlockedComponentFromJSON, BlockedComponentFromJSONTyped, BlockedComponentToJSON, BlockedComponentToJSONTyped, DataApi, type DataApiInterface, type DataApiQueryDataBatchOperationRequest, type DataApiQueryDataRequest, type DataQueryContext, DataQueryContextFromJSON, DataQueryContextFromJSONTyped, DataQueryContextToJSON, DataQueryContextToJSONTyped, type DataQueryRequest, DataQueryRequestFromJSON, DataQueryRequestFromJSONTyped, DataQueryRequestToJSON, DataQueryRequestToJSONTyped, type DataQueryResponse, DataQueryResponseFromJSON, DataQueryResponseFromJSONTyped, DataQueryResponseToJSON, DataQueryResponseToJSONTyped, type ErrorDetail, ErrorDetailFromJSON, ErrorDetailFromJSONTyped, ErrorDetailToJSON, ErrorDetailToJSONTyped, type ErrorResponseVo, ErrorResponseVoFromJSON, ErrorResponseVoFromJSONTyped, ErrorResponseVoToJSON, ErrorResponseVoToJSONTyped, type ExecuteActionBatch200Response, ExecuteActionBatch200ResponseFromJSON, ExecuteActionBatch200ResponseFromJSONTyped, ExecuteActionBatch200ResponseToJSON, ExecuteActionBatch200ResponseToJSONTyped, type ExecuteActionBatchRequest, ExecuteActionBatchRequestFromJSON, ExecuteActionBatchRequestFromJSONTyped, ExecuteActionBatchRequestToJSON, ExecuteActionBatchRequestToJSONTyped, type GetActivityStateBatch200Response, GetActivityStateBatch200ResponseFromJSON, GetActivityStateBatch200ResponseFromJSONTyped, GetActivityStateBatch200ResponseToJSON, GetActivityStateBatch200ResponseToJSONTyped, type GetActivityStateBatchRequest, GetActivityStateBatchRequestFromJSON, GetActivityStateBatchRequestFromJSONTyped, GetActivityStateBatchRequestToJSON, GetActivityStateBatchRequestToJSONTyped, HealthApi, type HealthApiInterface, type HealthResponse, type HealthResponseChecksValue, HealthResponseChecksValueFromJSON, HealthResponseChecksValueFromJSONTyped, HealthResponseChecksValueToJSON, HealthResponseChecksValueToJSONTyped, HealthResponseFromJSON, HealthResponseFromJSONTyped, HealthResponseStatusEnum, HealthResponseToJSON, HealthResponseToJSONTyped, type ManifestItem, ManifestItemFromJSON, ManifestItemFromJSONTyped, ManifestItemToJSON, ManifestItemToJSONTyped, PageApi, type PageApiInterface, type PageApiResolvePageBatchOperationRequest, type PageApiResolvePageRequest, type PageManifest, PageManifestFromJSON, PageManifestFromJSONTyped, PageManifestToJSON, PageManifestToJSONTyped, type PageResolveResponse, PageResolveResponseFromJSON, PageResolveResponseFromJSONTyped, PageResolveResponseToJSON, PageResolveResponseToJSONTyped, type PageResolveResult, PageResolveResultFromJSON, PageResolveResultFromJSONTyped, PageResolveResultToJSON, PageResolveResultToJSONTyped, type QueryDataBatch200Response, QueryDataBatch200ResponseFromJSON, QueryDataBatch200ResponseFromJSONTyped, QueryDataBatch200ResponseToJSON, QueryDataBatch200ResponseToJSONTyped, type QueryDataBatchRequest, QueryDataBatchRequestFromJSON, QueryDataBatchRequestFromJSONTyped, QueryDataBatchRequestToJSON, QueryDataBatchRequestToJSONTyped, type ResolvePageBatch200Response, ResolvePageBatch200ResponseFromJSON, ResolvePageBatch200ResponseFromJSONTyped, ResolvePageBatch200ResponseToJSON, ResolvePageBatch200ResponseToJSONTyped, type ResolvePageBatchRequest, ResolvePageBatchRequestChannelEnum, ResolvePageBatchRequestFromJSON, ResolvePageBatchRequestFromJSONTyped, ResolvePageBatchRequestToJSON, ResolvePageBatchRequestToJSONTyped, ResolvePageChannelEnum, type RuntimeConfig, RuntimeConfigFromJSON, RuntimeConfigFromJSONTyped, type RuntimeConfigReportConfig, RuntimeConfigReportConfigFromJSON, RuntimeConfigReportConfigFromJSONTyped, RuntimeConfigReportConfigToJSON, RuntimeConfigReportConfigToJSONTyped, RuntimeConfigToJSON, RuntimeConfigToJSONTyped, type TraceContext, TraceContextFromJSON, TraceContextFromJSONTyped, TraceContextToJSON, TraceContextToJSONTyped, TrackApi, type TrackApiInterface, type TrackApiTrackOperationRequest, type TrackContext, TrackContextFromJSON, TrackContextFromJSONTyped, TrackContextToJSON, TrackContextToJSONTyped, type TrackEvent, TrackEventEventTypeEnum, TrackEventFromJSON, TrackEventFromJSONTyped, TrackEventToJSON, TrackEventToJSONTyped, type TrackRequest, TrackRequestFromJSON, TrackRequestFromJSONTyped, TrackRequestToJSON, TrackRequestToJSONTyped, type UserActivityState, UserActivityStateFromJSON, UserActivityStateFromJSONTyped, type UserActivityStateProgress, UserActivityStateProgressFromJSON, UserActivityStateProgressFromJSONTyped, UserActivityStateProgressToJSON, UserActivityStateProgressToJSONTyped, UserActivityStateToJSON, UserActivityStateToJSONTyped, type UserClient, type UserClientOptions, createUserClient, instanceOfActionContext, instanceOfActionExecuteRequest, instanceOfActionExecuteResponse, instanceOfActivityState, instanceOfActivityStateActivityInfo, instanceOfActivityStateResponse, instanceOfBaseResponseVo, instanceOfBlockedComponent, instanceOfDataQueryContext, instanceOfDataQueryRequest, instanceOfDataQueryResponse, instanceOfErrorDetail, instanceOfErrorResponseVo, instanceOfExecuteActionBatch200Response, instanceOfExecuteActionBatchRequest, instanceOfGetActivityStateBatch200Response, instanceOfGetActivityStateBatchRequest, instanceOfHealthResponse, instanceOfHealthResponseChecksValue, instanceOfManifestItem, instanceOfPageManifest, instanceOfPageResolveResponse, instanceOfPageResolveResult, instanceOfQueryDataBatch200Response, instanceOfQueryDataBatchRequest, instanceOfResolvePageBatch200Response, instanceOfResolvePageBatchRequest, instanceOfRuntimeConfig, instanceOfRuntimeConfigReportConfig, instanceOfTraceContext, instanceOfTrackContext, instanceOfTrackEvent, instanceOfTrackRequest, instanceOfUserActivityState, instanceOfUserActivityStateProgress };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { BaseClientOptions, Configuration as Configuration$1 } from '@djvlc/openapi-client-core';
2
+ export { AbortError, Configuration, DjvApiError, Interceptors, Logger, Middleware, NetworkError, RequestOptions, RetryOptions, TimeoutError, createConsoleLogger, createSilentLogger, isRetryableError } from '@djvlc/openapi-client-core';
3
+
1
4
  interface ConfigurationParameters {
2
5
  basePath?: string;
3
6
  fetchApi?: FetchAPI;
@@ -2534,33 +2537,107 @@ declare namespace apis {
2534
2537
  export { apis_ActionApi as ActionApi, type apis_ActionApiExecuteActionBatchOperationRequest as ActionApiExecuteActionBatchOperationRequest, type apis_ActionApiExecuteActionRequest as ActionApiExecuteActionRequest, type apis_ActionApiInterface as ActionApiInterface, apis_ActivityApi as ActivityApi, type apis_ActivityApiGetActivityStateBatchOperationRequest as ActivityApiGetActivityStateBatchOperationRequest, type apis_ActivityApiGetActivityStateRequest as ActivityApiGetActivityStateRequest, type apis_ActivityApiInterface as ActivityApiInterface, apis_DataApi as DataApi, type apis_DataApiInterface as DataApiInterface, type apis_DataApiQueryDataBatchOperationRequest as DataApiQueryDataBatchOperationRequest, type apis_DataApiQueryDataRequest as DataApiQueryDataRequest, apis_HealthApi as HealthApi, type apis_HealthApiInterface as HealthApiInterface, apis_PageApi as PageApi, type apis_PageApiInterface as PageApiInterface, type apis_PageApiResolvePageBatchOperationRequest as PageApiResolvePageBatchOperationRequest, type apis_PageApiResolvePageRequest as PageApiResolvePageRequest, type apis_ResolvePageChannelEnum as ResolvePageChannelEnum, apis_TrackApi as TrackApi, type apis_TrackApiInterface as TrackApiInterface, type apis_TrackApiTrackOperationRequest as TrackApiTrackOperationRequest };
2535
2538
  }
2536
2539
 
2537
- interface UserClientOptions {
2540
+ /**
2541
+ * @djvlc/openapi-user-client - User API 客户端
2542
+ *
2543
+ * 用于 Runtime 访问 User API(数据面)。
2544
+ *
2545
+ * @example
2546
+ * ```typescript
2547
+ * import { createUserClient, DjvApiError, TimeoutError } from '@djvlc/openapi-user-client';
2548
+ *
2549
+ * const client = createUserClient({
2550
+ * baseUrl: 'https://api.example.com',
2551
+ * getAuthToken: () => localStorage.getItem('token') ?? '',
2552
+ * getTraceHeaders: () => ({ traceparent: '00-...' }),
2553
+ * retry: { maxRetries: 2 },
2554
+ * });
2555
+ *
2556
+ * try {
2557
+ * const page = await client.PageApi.resolvePage({ pageUid: 'xxx' });
2558
+ * } catch (e) {
2559
+ * if (DjvApiError.is(e)) {
2560
+ * console.log('业务错误:', e.code, e.traceId);
2561
+ * } else if (TimeoutError.is(e)) {
2562
+ * console.log('请求超时');
2563
+ * }
2564
+ * }
2565
+ * ```
2566
+ */
2567
+
2568
+ interface UserClientOptions extends Omit<BaseClientOptions, 'baseUrl'> {
2569
+ /** API 基础 URL */
2538
2570
  baseUrl: string;
2539
- /** user-api 可能需要登录态 token(也可能不需要) */
2571
+ /**
2572
+ * 获取认证 Token
2573
+ *
2574
+ * User API 可能需要登录态(也可能不需要)
2575
+ */
2540
2576
  getAuthToken?: () => string | Promise<string>;
2541
- /** OTel:traceparent/baggage/... */
2577
+ /**
2578
+ * 获取追踪头
2579
+ *
2580
+ * OpenTelemetry: traceparent, baggage 等
2581
+ */
2542
2582
  getTraceHeaders?: () => Record<string, string>;
2543
- /** 比如 x-app-key / x-tenant-id / x-device-id */
2583
+ /**
2584
+ * 默认请求头
2585
+ *
2586
+ * 如 x-device-id, x-channel, x-app-key 等
2587
+ */
2544
2588
  defaultHeaders?: Record<string, string>;
2545
- /** 默认 15s(线上 user-api 通常更追求快失败) */
2589
+ /**
2590
+ * 超时时间(毫秒)
2591
+ *
2592
+ * @default 15000 (User API 追求快失败)
2593
+ */
2546
2594
  timeoutMs?: number;
2547
- fetchApi?: typeof fetch;
2548
- /** 默认 omit(通常不走 cookie) */
2595
+ /**
2596
+ * Cookie 策略
2597
+ *
2598
+ * @default 'omit' (User API 通常不走 Cookie)
2599
+ */
2549
2600
  credentials?: RequestCredentials;
2550
2601
  }
2551
- type ApiInstances = {
2552
- [K in keyof typeof apis as K extends `${string}Api` ? (typeof apis)[K] extends new (...args: any) => any ? K : never : never]: (typeof apis)[K] extends new (...args: any) => any ? InstanceType<(typeof apis)[K]> : never;
2602
+ type ApiClasses = typeof apis;
2603
+ type ApiInstanceMap = {
2604
+ [K in keyof ApiClasses as K extends `${string}Api` ? ApiClasses[K] extends new (...args: unknown[]) => unknown ? K : never : never]: ApiClasses[K] extends new (...args: unknown[]) => infer T ? T : never;
2553
2605
  };
2606
+ /**
2607
+ * 创建 User API 客户端
2608
+ *
2609
+ * @param opts - 客户端配置
2610
+ * @returns 包含所有 API 实例的客户端对象
2611
+ *
2612
+ * @example
2613
+ * ```typescript
2614
+ * const client = createUserClient({
2615
+ * baseUrl: 'https://api.example.com',
2616
+ * getAuthToken: () => getToken(),
2617
+ * defaultHeaders: {
2618
+ * 'x-device-id': deviceId,
2619
+ * 'x-channel': 'h5',
2620
+ * },
2621
+ * retry: { maxRetries: 2 },
2622
+ * });
2623
+ *
2624
+ * // 解析页面
2625
+ * const page = await client.PageApi.resolvePage({ pageUid: 'xxx' });
2626
+ *
2627
+ * // 执行动作
2628
+ * const result = await client.ActionsApi.executeAction({
2629
+ * actionExecuteRequest: {
2630
+ * actionType: 'claim',
2631
+ * params: { activityId: 'xxx' },
2632
+ * context: {},
2633
+ * },
2634
+ * });
2635
+ * ```
2636
+ */
2554
2637
  declare function createUserClient(opts: UserClientOptions): {
2555
- ActionApi: ActionApi;
2556
- ActivityApi: ActivityApi;
2557
- DataApi: DataApi;
2558
- HealthApi: HealthApi;
2559
- PageApi: PageApi;
2560
- TrackApi: TrackApi;
2561
- config: Configuration;
2562
- apis: ApiInstances;
2563
- };
2638
+ config: Configuration$1;
2639
+ apis: ApiInstanceMap;
2640
+ } & ApiInstanceMap;
2564
2641
  type UserClient = ReturnType<typeof createUserClient>;
2565
2642
 
2566
- export { ActionApi, type ActionApiExecuteActionBatchOperationRequest, type ActionApiExecuteActionRequest, type ActionApiInterface, type ActionContext, ActionContextFromJSON, ActionContextFromJSONTyped, ActionContextToJSON, ActionContextToJSONTyped, type ActionExecuteRequest, ActionExecuteRequestFromJSON, ActionExecuteRequestFromJSONTyped, ActionExecuteRequestToJSON, ActionExecuteRequestToJSONTyped, type ActionExecuteResponse, ActionExecuteResponseFromJSON, ActionExecuteResponseFromJSONTyped, ActionExecuteResponseToJSON, ActionExecuteResponseToJSONTyped, ActivityApi, type ActivityApiGetActivityStateBatchOperationRequest, type ActivityApiGetActivityStateRequest, type ActivityApiInterface, type ActivityState, type ActivityStateActivityInfo, ActivityStateActivityInfoFromJSON, ActivityStateActivityInfoFromJSONTyped, ActivityStateActivityInfoToJSON, ActivityStateActivityInfoToJSONTyped, ActivityStateFromJSON, ActivityStateFromJSONTyped, type ActivityStateResponse, ActivityStateResponseFromJSON, ActivityStateResponseFromJSONTyped, ActivityStateResponseToJSON, ActivityStateResponseToJSONTyped, ActivityStateStatusEnum, ActivityStateToJSON, ActivityStateToJSONTyped, type BaseResponseVo, BaseResponseVoFromJSON, BaseResponseVoFromJSONTyped, BaseResponseVoToJSON, BaseResponseVoToJSONTyped, type BlockedComponent, BlockedComponentFromJSON, BlockedComponentFromJSONTyped, BlockedComponentToJSON, BlockedComponentToJSONTyped, Configuration, DataApi, type DataApiInterface, type DataApiQueryDataBatchOperationRequest, type DataApiQueryDataRequest, type DataQueryContext, DataQueryContextFromJSON, DataQueryContextFromJSONTyped, DataQueryContextToJSON, DataQueryContextToJSONTyped, type DataQueryRequest, DataQueryRequestFromJSON, DataQueryRequestFromJSONTyped, DataQueryRequestToJSON, DataQueryRequestToJSONTyped, type DataQueryResponse, DataQueryResponseFromJSON, DataQueryResponseFromJSONTyped, DataQueryResponseToJSON, DataQueryResponseToJSONTyped, type ErrorDetail, ErrorDetailFromJSON, ErrorDetailFromJSONTyped, ErrorDetailToJSON, ErrorDetailToJSONTyped, type ErrorResponseVo, ErrorResponseVoFromJSON, ErrorResponseVoFromJSONTyped, ErrorResponseVoToJSON, ErrorResponseVoToJSONTyped, type ExecuteActionBatch200Response, ExecuteActionBatch200ResponseFromJSON, ExecuteActionBatch200ResponseFromJSONTyped, ExecuteActionBatch200ResponseToJSON, ExecuteActionBatch200ResponseToJSONTyped, type ExecuteActionBatchRequest, ExecuteActionBatchRequestFromJSON, ExecuteActionBatchRequestFromJSONTyped, ExecuteActionBatchRequestToJSON, ExecuteActionBatchRequestToJSONTyped, type GetActivityStateBatch200Response, GetActivityStateBatch200ResponseFromJSON, GetActivityStateBatch200ResponseFromJSONTyped, GetActivityStateBatch200ResponseToJSON, GetActivityStateBatch200ResponseToJSONTyped, type GetActivityStateBatchRequest, GetActivityStateBatchRequestFromJSON, GetActivityStateBatchRequestFromJSONTyped, GetActivityStateBatchRequestToJSON, GetActivityStateBatchRequestToJSONTyped, HealthApi, type HealthApiInterface, type HealthResponse, type HealthResponseChecksValue, HealthResponseChecksValueFromJSON, HealthResponseChecksValueFromJSONTyped, HealthResponseChecksValueToJSON, HealthResponseChecksValueToJSONTyped, HealthResponseFromJSON, HealthResponseFromJSONTyped, HealthResponseStatusEnum, HealthResponseToJSON, HealthResponseToJSONTyped, type ManifestItem, ManifestItemFromJSON, ManifestItemFromJSONTyped, ManifestItemToJSON, ManifestItemToJSONTyped, PageApi, type PageApiInterface, type PageApiResolvePageBatchOperationRequest, type PageApiResolvePageRequest, type PageManifest, PageManifestFromJSON, PageManifestFromJSONTyped, PageManifestToJSON, PageManifestToJSONTyped, type PageResolveResponse, PageResolveResponseFromJSON, PageResolveResponseFromJSONTyped, PageResolveResponseToJSON, PageResolveResponseToJSONTyped, type PageResolveResult, PageResolveResultFromJSON, PageResolveResultFromJSONTyped, PageResolveResultToJSON, PageResolveResultToJSONTyped, type QueryDataBatch200Response, QueryDataBatch200ResponseFromJSON, QueryDataBatch200ResponseFromJSONTyped, QueryDataBatch200ResponseToJSON, QueryDataBatch200ResponseToJSONTyped, type QueryDataBatchRequest, QueryDataBatchRequestFromJSON, QueryDataBatchRequestFromJSONTyped, QueryDataBatchRequestToJSON, QueryDataBatchRequestToJSONTyped, type ResolvePageBatch200Response, ResolvePageBatch200ResponseFromJSON, ResolvePageBatch200ResponseFromJSONTyped, ResolvePageBatch200ResponseToJSON, ResolvePageBatch200ResponseToJSONTyped, type ResolvePageBatchRequest, ResolvePageBatchRequestChannelEnum, ResolvePageBatchRequestFromJSON, ResolvePageBatchRequestFromJSONTyped, ResolvePageBatchRequestToJSON, ResolvePageBatchRequestToJSONTyped, ResolvePageChannelEnum, type RuntimeConfig, RuntimeConfigFromJSON, RuntimeConfigFromJSONTyped, type RuntimeConfigReportConfig, RuntimeConfigReportConfigFromJSON, RuntimeConfigReportConfigFromJSONTyped, RuntimeConfigReportConfigToJSON, RuntimeConfigReportConfigToJSONTyped, RuntimeConfigToJSON, RuntimeConfigToJSONTyped, type TraceContext, TraceContextFromJSON, TraceContextFromJSONTyped, TraceContextToJSON, TraceContextToJSONTyped, TrackApi, type TrackApiInterface, type TrackApiTrackOperationRequest, type TrackContext, TrackContextFromJSON, TrackContextFromJSONTyped, TrackContextToJSON, TrackContextToJSONTyped, type TrackEvent, TrackEventEventTypeEnum, TrackEventFromJSON, TrackEventFromJSONTyped, TrackEventToJSON, TrackEventToJSONTyped, type TrackRequest, TrackRequestFromJSON, TrackRequestFromJSONTyped, TrackRequestToJSON, TrackRequestToJSONTyped, type UserActivityState, UserActivityStateFromJSON, UserActivityStateFromJSONTyped, type UserActivityStateProgress, UserActivityStateProgressFromJSON, UserActivityStateProgressFromJSONTyped, UserActivityStateProgressToJSON, UserActivityStateProgressToJSONTyped, UserActivityStateToJSON, UserActivityStateToJSONTyped, type UserClient, type UserClientOptions, createUserClient, instanceOfActionContext, instanceOfActionExecuteRequest, instanceOfActionExecuteResponse, instanceOfActivityState, instanceOfActivityStateActivityInfo, instanceOfActivityStateResponse, instanceOfBaseResponseVo, instanceOfBlockedComponent, instanceOfDataQueryContext, instanceOfDataQueryRequest, instanceOfDataQueryResponse, instanceOfErrorDetail, instanceOfErrorResponseVo, instanceOfExecuteActionBatch200Response, instanceOfExecuteActionBatchRequest, instanceOfGetActivityStateBatch200Response, instanceOfGetActivityStateBatchRequest, instanceOfHealthResponse, instanceOfHealthResponseChecksValue, instanceOfManifestItem, instanceOfPageManifest, instanceOfPageResolveResponse, instanceOfPageResolveResult, instanceOfQueryDataBatch200Response, instanceOfQueryDataBatchRequest, instanceOfResolvePageBatch200Response, instanceOfResolvePageBatchRequest, instanceOfRuntimeConfig, instanceOfRuntimeConfigReportConfig, instanceOfTraceContext, instanceOfTrackContext, instanceOfTrackEvent, instanceOfTrackRequest, instanceOfUserActivityState, instanceOfUserActivityStateProgress };
2643
+ export { ActionApi, type ActionApiExecuteActionBatchOperationRequest, type ActionApiExecuteActionRequest, type ActionApiInterface, type ActionContext, ActionContextFromJSON, ActionContextFromJSONTyped, ActionContextToJSON, ActionContextToJSONTyped, type ActionExecuteRequest, ActionExecuteRequestFromJSON, ActionExecuteRequestFromJSONTyped, ActionExecuteRequestToJSON, ActionExecuteRequestToJSONTyped, type ActionExecuteResponse, ActionExecuteResponseFromJSON, ActionExecuteResponseFromJSONTyped, ActionExecuteResponseToJSON, ActionExecuteResponseToJSONTyped, ActivityApi, type ActivityApiGetActivityStateBatchOperationRequest, type ActivityApiGetActivityStateRequest, type ActivityApiInterface, type ActivityState, type ActivityStateActivityInfo, ActivityStateActivityInfoFromJSON, ActivityStateActivityInfoFromJSONTyped, ActivityStateActivityInfoToJSON, ActivityStateActivityInfoToJSONTyped, ActivityStateFromJSON, ActivityStateFromJSONTyped, type ActivityStateResponse, ActivityStateResponseFromJSON, ActivityStateResponseFromJSONTyped, ActivityStateResponseToJSON, ActivityStateResponseToJSONTyped, ActivityStateStatusEnum, ActivityStateToJSON, ActivityStateToJSONTyped, type BaseResponseVo, BaseResponseVoFromJSON, BaseResponseVoFromJSONTyped, BaseResponseVoToJSON, BaseResponseVoToJSONTyped, type BlockedComponent, BlockedComponentFromJSON, BlockedComponentFromJSONTyped, BlockedComponentToJSON, BlockedComponentToJSONTyped, DataApi, type DataApiInterface, type DataApiQueryDataBatchOperationRequest, type DataApiQueryDataRequest, type DataQueryContext, DataQueryContextFromJSON, DataQueryContextFromJSONTyped, DataQueryContextToJSON, DataQueryContextToJSONTyped, type DataQueryRequest, DataQueryRequestFromJSON, DataQueryRequestFromJSONTyped, DataQueryRequestToJSON, DataQueryRequestToJSONTyped, type DataQueryResponse, DataQueryResponseFromJSON, DataQueryResponseFromJSONTyped, DataQueryResponseToJSON, DataQueryResponseToJSONTyped, type ErrorDetail, ErrorDetailFromJSON, ErrorDetailFromJSONTyped, ErrorDetailToJSON, ErrorDetailToJSONTyped, type ErrorResponseVo, ErrorResponseVoFromJSON, ErrorResponseVoFromJSONTyped, ErrorResponseVoToJSON, ErrorResponseVoToJSONTyped, type ExecuteActionBatch200Response, ExecuteActionBatch200ResponseFromJSON, ExecuteActionBatch200ResponseFromJSONTyped, ExecuteActionBatch200ResponseToJSON, ExecuteActionBatch200ResponseToJSONTyped, type ExecuteActionBatchRequest, ExecuteActionBatchRequestFromJSON, ExecuteActionBatchRequestFromJSONTyped, ExecuteActionBatchRequestToJSON, ExecuteActionBatchRequestToJSONTyped, type GetActivityStateBatch200Response, GetActivityStateBatch200ResponseFromJSON, GetActivityStateBatch200ResponseFromJSONTyped, GetActivityStateBatch200ResponseToJSON, GetActivityStateBatch200ResponseToJSONTyped, type GetActivityStateBatchRequest, GetActivityStateBatchRequestFromJSON, GetActivityStateBatchRequestFromJSONTyped, GetActivityStateBatchRequestToJSON, GetActivityStateBatchRequestToJSONTyped, HealthApi, type HealthApiInterface, type HealthResponse, type HealthResponseChecksValue, HealthResponseChecksValueFromJSON, HealthResponseChecksValueFromJSONTyped, HealthResponseChecksValueToJSON, HealthResponseChecksValueToJSONTyped, HealthResponseFromJSON, HealthResponseFromJSONTyped, HealthResponseStatusEnum, HealthResponseToJSON, HealthResponseToJSONTyped, type ManifestItem, ManifestItemFromJSON, ManifestItemFromJSONTyped, ManifestItemToJSON, ManifestItemToJSONTyped, PageApi, type PageApiInterface, type PageApiResolvePageBatchOperationRequest, type PageApiResolvePageRequest, type PageManifest, PageManifestFromJSON, PageManifestFromJSONTyped, PageManifestToJSON, PageManifestToJSONTyped, type PageResolveResponse, PageResolveResponseFromJSON, PageResolveResponseFromJSONTyped, PageResolveResponseToJSON, PageResolveResponseToJSONTyped, type PageResolveResult, PageResolveResultFromJSON, PageResolveResultFromJSONTyped, PageResolveResultToJSON, PageResolveResultToJSONTyped, type QueryDataBatch200Response, QueryDataBatch200ResponseFromJSON, QueryDataBatch200ResponseFromJSONTyped, QueryDataBatch200ResponseToJSON, QueryDataBatch200ResponseToJSONTyped, type QueryDataBatchRequest, QueryDataBatchRequestFromJSON, QueryDataBatchRequestFromJSONTyped, QueryDataBatchRequestToJSON, QueryDataBatchRequestToJSONTyped, type ResolvePageBatch200Response, ResolvePageBatch200ResponseFromJSON, ResolvePageBatch200ResponseFromJSONTyped, ResolvePageBatch200ResponseToJSON, ResolvePageBatch200ResponseToJSONTyped, type ResolvePageBatchRequest, ResolvePageBatchRequestChannelEnum, ResolvePageBatchRequestFromJSON, ResolvePageBatchRequestFromJSONTyped, ResolvePageBatchRequestToJSON, ResolvePageBatchRequestToJSONTyped, ResolvePageChannelEnum, type RuntimeConfig, RuntimeConfigFromJSON, RuntimeConfigFromJSONTyped, type RuntimeConfigReportConfig, RuntimeConfigReportConfigFromJSON, RuntimeConfigReportConfigFromJSONTyped, RuntimeConfigReportConfigToJSON, RuntimeConfigReportConfigToJSONTyped, RuntimeConfigToJSON, RuntimeConfigToJSONTyped, type TraceContext, TraceContextFromJSON, TraceContextFromJSONTyped, TraceContextToJSON, TraceContextToJSONTyped, TrackApi, type TrackApiInterface, type TrackApiTrackOperationRequest, type TrackContext, TrackContextFromJSON, TrackContextFromJSONTyped, TrackContextToJSON, TrackContextToJSONTyped, type TrackEvent, TrackEventEventTypeEnum, TrackEventFromJSON, TrackEventFromJSONTyped, TrackEventToJSON, TrackEventToJSONTyped, type TrackRequest, TrackRequestFromJSON, TrackRequestFromJSONTyped, TrackRequestToJSON, TrackRequestToJSONTyped, type UserActivityState, UserActivityStateFromJSON, UserActivityStateFromJSONTyped, type UserActivityStateProgress, UserActivityStateProgressFromJSON, UserActivityStateProgressFromJSONTyped, UserActivityStateProgressToJSON, UserActivityStateProgressToJSONTyped, UserActivityStateToJSON, UserActivityStateToJSONTyped, type UserClient, type UserClientOptions, createUserClient, instanceOfActionContext, instanceOfActionExecuteRequest, instanceOfActionExecuteResponse, instanceOfActivityState, instanceOfActivityStateActivityInfo, instanceOfActivityStateResponse, instanceOfBaseResponseVo, instanceOfBlockedComponent, instanceOfDataQueryContext, instanceOfDataQueryRequest, instanceOfDataQueryResponse, instanceOfErrorDetail, instanceOfErrorResponseVo, instanceOfExecuteActionBatch200Response, instanceOfExecuteActionBatchRequest, instanceOfGetActivityStateBatch200Response, instanceOfGetActivityStateBatchRequest, instanceOfHealthResponse, instanceOfHealthResponseChecksValue, instanceOfManifestItem, instanceOfPageManifest, instanceOfPageResolveResponse, instanceOfPageResolveResult, instanceOfQueryDataBatch200Response, instanceOfQueryDataBatchRequest, instanceOfResolvePageBatch200Response, instanceOfResolvePageBatchRequest, instanceOfRuntimeConfig, instanceOfRuntimeConfigReportConfig, instanceOfTraceContext, instanceOfTrackContext, instanceOfTrackEvent, instanceOfTrackRequest, instanceOfUserActivityState, instanceOfUserActivityStateProgress };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AbortError: () => import_openapi_client_core2.AbortError,
23
24
  ActionApi: () => ActionApi,
24
25
  ActionContextFromJSON: () => ActionContextFromJSON,
25
26
  ActionContextFromJSONTyped: () => ActionContextFromJSONTyped,
@@ -55,7 +56,7 @@ __export(index_exports, {
55
56
  BlockedComponentFromJSONTyped: () => BlockedComponentFromJSONTyped,
56
57
  BlockedComponentToJSON: () => BlockedComponentToJSON,
57
58
  BlockedComponentToJSONTyped: () => BlockedComponentToJSONTyped,
58
- Configuration: () => Configuration,
59
+ Configuration: () => import_openapi_client_core2.Configuration,
59
60
  DataApi: () => DataApi,
60
61
  DataQueryContextFromJSON: () => DataQueryContextFromJSON,
61
62
  DataQueryContextFromJSONTyped: () => DataQueryContextFromJSONTyped,
@@ -69,6 +70,7 @@ __export(index_exports, {
69
70
  DataQueryResponseFromJSONTyped: () => DataQueryResponseFromJSONTyped,
70
71
  DataQueryResponseToJSON: () => DataQueryResponseToJSON,
71
72
  DataQueryResponseToJSONTyped: () => DataQueryResponseToJSONTyped,
73
+ DjvApiError: () => import_openapi_client_core2.DjvApiError,
72
74
  ErrorDetailFromJSON: () => ErrorDetailFromJSON,
73
75
  ErrorDetailFromJSONTyped: () => ErrorDetailFromJSONTyped,
74
76
  ErrorDetailToJSON: () => ErrorDetailToJSON,
@@ -107,6 +109,7 @@ __export(index_exports, {
107
109
  ManifestItemFromJSONTyped: () => ManifestItemFromJSONTyped,
108
110
  ManifestItemToJSON: () => ManifestItemToJSON,
109
111
  ManifestItemToJSONTyped: () => ManifestItemToJSONTyped,
112
+ NetworkError: () => import_openapi_client_core2.NetworkError,
110
113
  PageApi: () => PageApi,
111
114
  PageManifestFromJSON: () => PageManifestFromJSON,
112
115
  PageManifestFromJSONTyped: () => PageManifestFromJSONTyped,
@@ -146,6 +149,7 @@ __export(index_exports, {
146
149
  RuntimeConfigReportConfigToJSONTyped: () => RuntimeConfigReportConfigToJSONTyped,
147
150
  RuntimeConfigToJSON: () => RuntimeConfigToJSON,
148
151
  RuntimeConfigToJSONTyped: () => RuntimeConfigToJSONTyped,
152
+ TimeoutError: () => import_openapi_client_core2.TimeoutError,
149
153
  TraceContextFromJSON: () => TraceContextFromJSON,
150
154
  TraceContextFromJSONTyped: () => TraceContextFromJSONTyped,
151
155
  TraceContextToJSON: () => TraceContextToJSON,
@@ -172,6 +176,8 @@ __export(index_exports, {
172
176
  UserActivityStateProgressToJSONTyped: () => UserActivityStateProgressToJSONTyped,
173
177
  UserActivityStateToJSON: () => UserActivityStateToJSON,
174
178
  UserActivityStateToJSONTyped: () => UserActivityStateToJSONTyped,
179
+ createConsoleLogger: () => import_openapi_client_core2.createConsoleLogger,
180
+ createSilentLogger: () => import_openapi_client_core2.createSilentLogger,
175
181
  createUserClient: () => createUserClient,
176
182
  instanceOfActionContext: () => instanceOfActionContext,
177
183
  instanceOfActionExecuteRequest: () => instanceOfActionExecuteRequest,
@@ -207,9 +213,23 @@ __export(index_exports, {
207
213
  instanceOfTrackEvent: () => instanceOfTrackEvent,
208
214
  instanceOfTrackRequest: () => instanceOfTrackRequest,
209
215
  instanceOfUserActivityState: () => instanceOfUserActivityState,
210
- instanceOfUserActivityStateProgress: () => instanceOfUserActivityStateProgress
216
+ instanceOfUserActivityStateProgress: () => instanceOfUserActivityStateProgress,
217
+ isRetryableError: () => import_openapi_client_core2.isRetryableError
211
218
  });
212
219
  module.exports = __toCommonJS(index_exports);
220
+ var import_openapi_client_core = require("@djvlc/openapi-client-core");
221
+
222
+ // src/gen/apis/index.ts
223
+ var apis_exports = {};
224
+ __export(apis_exports, {
225
+ ActionApi: () => ActionApi,
226
+ ActivityApi: () => ActivityApi,
227
+ DataApi: () => DataApi,
228
+ HealthApi: () => HealthApi,
229
+ PageApi: () => PageApi,
230
+ ResolvePageChannelEnum: () => ResolvePageChannelEnum,
231
+ TrackApi: () => TrackApi
232
+ });
213
233
 
214
234
  // src/gen/runtime.ts
215
235
  var BASE_PATH = "https://api.djvlc.com".replace(/\/+$/, "");
@@ -444,11 +464,10 @@ function querystringSingleKey(key, value, keyPrefix = "") {
444
464
  return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
445
465
  }
446
466
  function mapValues(data, fn) {
447
- const result = {};
448
- for (const key of Object.keys(data)) {
449
- result[key] = fn(data[key]);
450
- }
451
- return result;
467
+ return Object.keys(data).reduce(
468
+ (acc, key) => ({ ...acc, [key]: fn(data[key]) }),
469
+ {}
470
+ );
452
471
  }
453
472
  var JSONApiResponse = class {
454
473
  constructor(raw, transformer = (jsonValue) => jsonValue) {
@@ -468,18 +487,6 @@ var VoidApiResponse = class {
468
487
  }
469
488
  };
470
489
 
471
- // src/gen/apis/index.ts
472
- var apis_exports = {};
473
- __export(apis_exports, {
474
- ActionApi: () => ActionApi,
475
- ActivityApi: () => ActivityApi,
476
- DataApi: () => DataApi,
477
- HealthApi: () => HealthApi,
478
- PageApi: () => PageApi,
479
- ResolvePageChannelEnum: () => ResolvePageChannelEnum,
480
- TrackApi: () => TrackApi
481
- });
482
-
483
490
  // src/gen/models/ActionContext.ts
484
491
  function instanceOfActionContext(value) {
485
492
  return true;
@@ -1742,9 +1749,8 @@ var ActionApi = class extends BaseAPI {
1742
1749
  const queryParameters = {};
1743
1750
  const headerParameters = {};
1744
1751
  headerParameters["Content-Type"] = "application/json";
1745
- let urlPath = `/api/actions/execute`;
1746
1752
  const response = await this.request({
1747
- path: urlPath,
1753
+ path: `/api/actions/execute`,
1748
1754
  method: "POST",
1749
1755
  headers: headerParameters,
1750
1756
  query: queryParameters,
@@ -1774,9 +1780,8 @@ var ActionApi = class extends BaseAPI {
1774
1780
  const queryParameters = {};
1775
1781
  const headerParameters = {};
1776
1782
  headerParameters["Content-Type"] = "application/json";
1777
- let urlPath = `/api/actions/batch`;
1778
1783
  const response = await this.request({
1779
- path: urlPath,
1784
+ path: `/api/actions/batch`,
1780
1785
  method: "POST",
1781
1786
  headers: headerParameters,
1782
1787
  query: queryParameters,
@@ -1815,9 +1820,8 @@ var ActivityApi = class extends BaseAPI {
1815
1820
  queryParameters["uid"] = requestParameters["uid"];
1816
1821
  }
1817
1822
  const headerParameters = {};
1818
- let urlPath = `/api/activity/state`;
1819
1823
  const response = await this.request({
1820
- path: urlPath,
1824
+ path: `/api/activity/state`,
1821
1825
  method: "GET",
1822
1826
  headers: headerParameters,
1823
1827
  query: queryParameters
@@ -1846,9 +1850,8 @@ var ActivityApi = class extends BaseAPI {
1846
1850
  const queryParameters = {};
1847
1851
  const headerParameters = {};
1848
1852
  headerParameters["Content-Type"] = "application/json";
1849
- let urlPath = `/api/activity/state/batch`;
1850
1853
  const response = await this.request({
1851
- path: urlPath,
1854
+ path: `/api/activity/state/batch`,
1852
1855
  method: "POST",
1853
1856
  headers: headerParameters,
1854
1857
  query: queryParameters,
@@ -1882,9 +1885,8 @@ var DataApi = class extends BaseAPI {
1882
1885
  const queryParameters = {};
1883
1886
  const headerParameters = {};
1884
1887
  headerParameters["Content-Type"] = "application/json";
1885
- let urlPath = `/api/data/query`;
1886
1888
  const response = await this.request({
1887
- path: urlPath,
1889
+ path: `/api/data/query`,
1888
1890
  method: "POST",
1889
1891
  headers: headerParameters,
1890
1892
  query: queryParameters,
@@ -1914,9 +1916,8 @@ var DataApi = class extends BaseAPI {
1914
1916
  const queryParameters = {};
1915
1917
  const headerParameters = {};
1916
1918
  headerParameters["Content-Type"] = "application/json";
1917
- let urlPath = `/api/data/query/batch`;
1918
1919
  const response = await this.request({
1919
- path: urlPath,
1920
+ path: `/api/data/query/batch`,
1920
1921
  method: "POST",
1921
1922
  headers: headerParameters,
1922
1923
  query: queryParameters,
@@ -1943,9 +1944,8 @@ var HealthApi = class extends BaseAPI {
1943
1944
  async healthRaw(initOverrides) {
1944
1945
  const queryParameters = {};
1945
1946
  const headerParameters = {};
1946
- let urlPath = `/api/health`;
1947
1947
  const response = await this.request({
1948
- path: urlPath,
1948
+ path: `/api/health`,
1949
1949
  method: "GET",
1950
1950
  headers: headerParameters,
1951
1951
  query: queryParameters
@@ -1967,9 +1967,8 @@ var HealthApi = class extends BaseAPI {
1967
1967
  async livenessRaw(initOverrides) {
1968
1968
  const queryParameters = {};
1969
1969
  const headerParameters = {};
1970
- let urlPath = `/api/health/live`;
1971
1970
  const response = await this.request({
1972
- path: urlPath,
1971
+ path: `/api/health/live`,
1973
1972
  method: "GET",
1974
1973
  headers: headerParameters,
1975
1974
  query: queryParameters
@@ -1991,9 +1990,8 @@ var HealthApi = class extends BaseAPI {
1991
1990
  async readinessRaw(initOverrides) {
1992
1991
  const queryParameters = {};
1993
1992
  const headerParameters = {};
1994
- let urlPath = `/api/health/ready`;
1995
1993
  const response = await this.request({
1996
- path: urlPath,
1994
+ path: `/api/health/ready`,
1997
1995
  method: "GET",
1998
1996
  headers: headerParameters,
1999
1997
  query: queryParameters
@@ -2040,9 +2038,8 @@ var PageApi = class extends BaseAPI {
2040
2038
  queryParameters["previewToken"] = requestParameters["previewToken"];
2041
2039
  }
2042
2040
  const headerParameters = {};
2043
- let urlPath = `/api/page/resolve`;
2044
2041
  const response = await this.request({
2045
- path: urlPath,
2042
+ path: `/api/page/resolve`,
2046
2043
  method: "GET",
2047
2044
  headers: headerParameters,
2048
2045
  query: queryParameters
@@ -2071,9 +2068,8 @@ var PageApi = class extends BaseAPI {
2071
2068
  const queryParameters = {};
2072
2069
  const headerParameters = {};
2073
2070
  headerParameters["Content-Type"] = "application/json";
2074
- let urlPath = `/api/page/resolve/batch`;
2075
2071
  const response = await this.request({
2076
- path: urlPath,
2072
+ path: `/api/page/resolve/batch`,
2077
2073
  method: "POST",
2078
2074
  headers: headerParameters,
2079
2075
  query: queryParameters,
@@ -2112,9 +2108,8 @@ var TrackApi = class extends BaseAPI {
2112
2108
  const queryParameters = {};
2113
2109
  const headerParameters = {};
2114
2110
  headerParameters["Content-Type"] = "application/json";
2115
- let urlPath = `/api/track`;
2116
2111
  const response = await this.request({
2117
- path: urlPath,
2112
+ path: `/api/track`,
2118
2113
  method: "POST",
2119
2114
  headers: headerParameters,
2120
2115
  query: queryParameters,
@@ -2132,64 +2127,27 @@ var TrackApi = class extends BaseAPI {
2132
2127
  };
2133
2128
 
2134
2129
  // src/index.ts
2135
- function stripTrailingSlash(url) {
2136
- return url.replace(/\/$/, "");
2137
- }
2138
- function createFetchWithTimeout(fetchImpl, timeoutMs) {
2139
- return (async (input, init) => {
2140
- const controller = new AbortController();
2141
- const id = setTimeout(() => controller.abort(), timeoutMs);
2142
- try {
2143
- return await fetchImpl(input, { ...init, signal: controller.signal });
2144
- } finally {
2145
- clearTimeout(id);
2146
- }
2147
- });
2148
- }
2149
- function normalizeHeaders(initHeaders) {
2150
- return new Headers(initHeaders ?? {});
2151
- }
2130
+ var import_openapi_client_core2 = require("@djvlc/openapi-client-core");
2131
+ var SDK_INFO = {
2132
+ name: true ? "@djvlc/openapi-user-client" : "@djvlc/openapi-user-client",
2133
+ version: true ? "1.0.0" : "0.0.0-dev"
2134
+ };
2152
2135
  function createUserClient(opts) {
2153
- const timeoutMs = opts.timeoutMs ?? 15e3;
2154
- const fetchImpl = opts.fetchApi ?? fetch;
2155
- const fetchWithTimeout = createFetchWithTimeout(fetchImpl, timeoutMs);
2156
- const headersMiddleware = {
2157
- async pre(context) {
2158
- const headers = normalizeHeaders(context.init.headers);
2159
- if (opts.defaultHeaders) {
2160
- for (const [k, v] of Object.entries(opts.defaultHeaders)) headers.set(k, v);
2161
- }
2162
- if (opts.getAuthToken) {
2163
- const token = await opts.getAuthToken();
2164
- if (token) headers.set("Authorization", `Bearer ${token}`);
2165
- }
2166
- if (opts.getTraceHeaders) {
2167
- const traceHeaders = opts.getTraceHeaders();
2168
- for (const [k, v] of Object.entries(traceHeaders)) headers.set(k, v);
2169
- }
2170
- return { url: context.url, init: { ...context.init, headers } };
2171
- }
2136
+ const defaultOpts = {
2137
+ timeoutMs: 15e3,
2138
+ // User API 追求快失败
2139
+ credentials: "omit"
2140
+ // 通常不走 Cookie
2172
2141
  };
2173
- const config = new Configuration({
2174
- basePath: stripTrailingSlash(opts.baseUrl),
2175
- fetchApi: fetchWithTimeout,
2176
- middleware: [headersMiddleware],
2177
- credentials: opts.credentials ?? "omit"
2178
- });
2179
- const apiInstances = {};
2180
- for (const [name, ApiClass] of Object.entries(apis_exports)) {
2181
- if (typeof ApiClass === "function" && name.endsWith("Api")) {
2182
- apiInstances[name] = new ApiClass(config);
2183
- }
2184
- }
2185
- return {
2186
- config,
2187
- apis: apiInstances,
2188
- ...apiInstances
2142
+ const mergedOpts = {
2143
+ ...defaultOpts,
2144
+ ...opts
2189
2145
  };
2146
+ return (0, import_openapi_client_core.createClient)(apis_exports, mergedOpts, SDK_INFO);
2190
2147
  }
2191
2148
  // Annotate the CommonJS export names for ESM import in node:
2192
2149
  0 && (module.exports = {
2150
+ AbortError,
2193
2151
  ActionApi,
2194
2152
  ActionContextFromJSON,
2195
2153
  ActionContextFromJSONTyped,
@@ -2239,6 +2197,7 @@ function createUserClient(opts) {
2239
2197
  DataQueryResponseFromJSONTyped,
2240
2198
  DataQueryResponseToJSON,
2241
2199
  DataQueryResponseToJSONTyped,
2200
+ DjvApiError,
2242
2201
  ErrorDetailFromJSON,
2243
2202
  ErrorDetailFromJSONTyped,
2244
2203
  ErrorDetailToJSON,
@@ -2277,6 +2236,7 @@ function createUserClient(opts) {
2277
2236
  ManifestItemFromJSONTyped,
2278
2237
  ManifestItemToJSON,
2279
2238
  ManifestItemToJSONTyped,
2239
+ NetworkError,
2280
2240
  PageApi,
2281
2241
  PageManifestFromJSON,
2282
2242
  PageManifestFromJSONTyped,
@@ -2316,6 +2276,7 @@ function createUserClient(opts) {
2316
2276
  RuntimeConfigReportConfigToJSONTyped,
2317
2277
  RuntimeConfigToJSON,
2318
2278
  RuntimeConfigToJSONTyped,
2279
+ TimeoutError,
2319
2280
  TraceContextFromJSON,
2320
2281
  TraceContextFromJSONTyped,
2321
2282
  TraceContextToJSON,
@@ -2342,6 +2303,8 @@ function createUserClient(opts) {
2342
2303
  UserActivityStateProgressToJSONTyped,
2343
2304
  UserActivityStateToJSON,
2344
2305
  UserActivityStateToJSONTyped,
2306
+ createConsoleLogger,
2307
+ createSilentLogger,
2345
2308
  createUserClient,
2346
2309
  instanceOfActionContext,
2347
2310
  instanceOfActionExecuteRequest,
@@ -2377,5 +2340,6 @@ function createUserClient(opts) {
2377
2340
  instanceOfTrackEvent,
2378
2341
  instanceOfTrackRequest,
2379
2342
  instanceOfUserActivityState,
2380
- instanceOfUserActivityStateProgress
2343
+ instanceOfUserActivityStateProgress,
2344
+ isRetryableError
2381
2345
  });
package/dist/index.mjs CHANGED
@@ -4,6 +4,23 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
+ // src/index.ts
8
+ import {
9
+ createClient
10
+ } from "@djvlc/openapi-client-core";
11
+
12
+ // src/gen/apis/index.ts
13
+ var apis_exports = {};
14
+ __export(apis_exports, {
15
+ ActionApi: () => ActionApi,
16
+ ActivityApi: () => ActivityApi,
17
+ DataApi: () => DataApi,
18
+ HealthApi: () => HealthApi,
19
+ PageApi: () => PageApi,
20
+ ResolvePageChannelEnum: () => ResolvePageChannelEnum,
21
+ TrackApi: () => TrackApi
22
+ });
23
+
7
24
  // src/gen/runtime.ts
8
25
  var BASE_PATH = "https://api.djvlc.com".replace(/\/+$/, "");
9
26
  var Configuration = class {
@@ -237,11 +254,10 @@ function querystringSingleKey(key, value, keyPrefix = "") {
237
254
  return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
238
255
  }
239
256
  function mapValues(data, fn) {
240
- const result = {};
241
- for (const key of Object.keys(data)) {
242
- result[key] = fn(data[key]);
243
- }
244
- return result;
257
+ return Object.keys(data).reduce(
258
+ (acc, key) => ({ ...acc, [key]: fn(data[key]) }),
259
+ {}
260
+ );
245
261
  }
246
262
  var JSONApiResponse = class {
247
263
  constructor(raw, transformer = (jsonValue) => jsonValue) {
@@ -261,18 +277,6 @@ var VoidApiResponse = class {
261
277
  }
262
278
  };
263
279
 
264
- // src/gen/apis/index.ts
265
- var apis_exports = {};
266
- __export(apis_exports, {
267
- ActionApi: () => ActionApi,
268
- ActivityApi: () => ActivityApi,
269
- DataApi: () => DataApi,
270
- HealthApi: () => HealthApi,
271
- PageApi: () => PageApi,
272
- ResolvePageChannelEnum: () => ResolvePageChannelEnum,
273
- TrackApi: () => TrackApi
274
- });
275
-
276
280
  // src/gen/models/ActionContext.ts
277
281
  function instanceOfActionContext(value) {
278
282
  return true;
@@ -1535,9 +1539,8 @@ var ActionApi = class extends BaseAPI {
1535
1539
  const queryParameters = {};
1536
1540
  const headerParameters = {};
1537
1541
  headerParameters["Content-Type"] = "application/json";
1538
- let urlPath = `/api/actions/execute`;
1539
1542
  const response = await this.request({
1540
- path: urlPath,
1543
+ path: `/api/actions/execute`,
1541
1544
  method: "POST",
1542
1545
  headers: headerParameters,
1543
1546
  query: queryParameters,
@@ -1567,9 +1570,8 @@ var ActionApi = class extends BaseAPI {
1567
1570
  const queryParameters = {};
1568
1571
  const headerParameters = {};
1569
1572
  headerParameters["Content-Type"] = "application/json";
1570
- let urlPath = `/api/actions/batch`;
1571
1573
  const response = await this.request({
1572
- path: urlPath,
1574
+ path: `/api/actions/batch`,
1573
1575
  method: "POST",
1574
1576
  headers: headerParameters,
1575
1577
  query: queryParameters,
@@ -1608,9 +1610,8 @@ var ActivityApi = class extends BaseAPI {
1608
1610
  queryParameters["uid"] = requestParameters["uid"];
1609
1611
  }
1610
1612
  const headerParameters = {};
1611
- let urlPath = `/api/activity/state`;
1612
1613
  const response = await this.request({
1613
- path: urlPath,
1614
+ path: `/api/activity/state`,
1614
1615
  method: "GET",
1615
1616
  headers: headerParameters,
1616
1617
  query: queryParameters
@@ -1639,9 +1640,8 @@ var ActivityApi = class extends BaseAPI {
1639
1640
  const queryParameters = {};
1640
1641
  const headerParameters = {};
1641
1642
  headerParameters["Content-Type"] = "application/json";
1642
- let urlPath = `/api/activity/state/batch`;
1643
1643
  const response = await this.request({
1644
- path: urlPath,
1644
+ path: `/api/activity/state/batch`,
1645
1645
  method: "POST",
1646
1646
  headers: headerParameters,
1647
1647
  query: queryParameters,
@@ -1675,9 +1675,8 @@ var DataApi = class extends BaseAPI {
1675
1675
  const queryParameters = {};
1676
1676
  const headerParameters = {};
1677
1677
  headerParameters["Content-Type"] = "application/json";
1678
- let urlPath = `/api/data/query`;
1679
1678
  const response = await this.request({
1680
- path: urlPath,
1679
+ path: `/api/data/query`,
1681
1680
  method: "POST",
1682
1681
  headers: headerParameters,
1683
1682
  query: queryParameters,
@@ -1707,9 +1706,8 @@ var DataApi = class extends BaseAPI {
1707
1706
  const queryParameters = {};
1708
1707
  const headerParameters = {};
1709
1708
  headerParameters["Content-Type"] = "application/json";
1710
- let urlPath = `/api/data/query/batch`;
1711
1709
  const response = await this.request({
1712
- path: urlPath,
1710
+ path: `/api/data/query/batch`,
1713
1711
  method: "POST",
1714
1712
  headers: headerParameters,
1715
1713
  query: queryParameters,
@@ -1736,9 +1734,8 @@ var HealthApi = class extends BaseAPI {
1736
1734
  async healthRaw(initOverrides) {
1737
1735
  const queryParameters = {};
1738
1736
  const headerParameters = {};
1739
- let urlPath = `/api/health`;
1740
1737
  const response = await this.request({
1741
- path: urlPath,
1738
+ path: `/api/health`,
1742
1739
  method: "GET",
1743
1740
  headers: headerParameters,
1744
1741
  query: queryParameters
@@ -1760,9 +1757,8 @@ var HealthApi = class extends BaseAPI {
1760
1757
  async livenessRaw(initOverrides) {
1761
1758
  const queryParameters = {};
1762
1759
  const headerParameters = {};
1763
- let urlPath = `/api/health/live`;
1764
1760
  const response = await this.request({
1765
- path: urlPath,
1761
+ path: `/api/health/live`,
1766
1762
  method: "GET",
1767
1763
  headers: headerParameters,
1768
1764
  query: queryParameters
@@ -1784,9 +1780,8 @@ var HealthApi = class extends BaseAPI {
1784
1780
  async readinessRaw(initOverrides) {
1785
1781
  const queryParameters = {};
1786
1782
  const headerParameters = {};
1787
- let urlPath = `/api/health/ready`;
1788
1783
  const response = await this.request({
1789
- path: urlPath,
1784
+ path: `/api/health/ready`,
1790
1785
  method: "GET",
1791
1786
  headers: headerParameters,
1792
1787
  query: queryParameters
@@ -1833,9 +1828,8 @@ var PageApi = class extends BaseAPI {
1833
1828
  queryParameters["previewToken"] = requestParameters["previewToken"];
1834
1829
  }
1835
1830
  const headerParameters = {};
1836
- let urlPath = `/api/page/resolve`;
1837
1831
  const response = await this.request({
1838
- path: urlPath,
1832
+ path: `/api/page/resolve`,
1839
1833
  method: "GET",
1840
1834
  headers: headerParameters,
1841
1835
  query: queryParameters
@@ -1864,9 +1858,8 @@ var PageApi = class extends BaseAPI {
1864
1858
  const queryParameters = {};
1865
1859
  const headerParameters = {};
1866
1860
  headerParameters["Content-Type"] = "application/json";
1867
- let urlPath = `/api/page/resolve/batch`;
1868
1861
  const response = await this.request({
1869
- path: urlPath,
1862
+ path: `/api/page/resolve/batch`,
1870
1863
  method: "POST",
1871
1864
  headers: headerParameters,
1872
1865
  query: queryParameters,
@@ -1905,9 +1898,8 @@ var TrackApi = class extends BaseAPI {
1905
1898
  const queryParameters = {};
1906
1899
  const headerParameters = {};
1907
1900
  headerParameters["Content-Type"] = "application/json";
1908
- let urlPath = `/api/track`;
1909
1901
  const response = await this.request({
1910
- path: urlPath,
1902
+ path: `/api/track`,
1911
1903
  method: "POST",
1912
1904
  headers: headerParameters,
1913
1905
  query: queryParameters,
@@ -1925,63 +1917,35 @@ var TrackApi = class extends BaseAPI {
1925
1917
  };
1926
1918
 
1927
1919
  // src/index.ts
1928
- function stripTrailingSlash(url) {
1929
- return url.replace(/\/$/, "");
1930
- }
1931
- function createFetchWithTimeout(fetchImpl, timeoutMs) {
1932
- return (async (input, init) => {
1933
- const controller = new AbortController();
1934
- const id = setTimeout(() => controller.abort(), timeoutMs);
1935
- try {
1936
- return await fetchImpl(input, { ...init, signal: controller.signal });
1937
- } finally {
1938
- clearTimeout(id);
1939
- }
1940
- });
1941
- }
1942
- function normalizeHeaders(initHeaders) {
1943
- return new Headers(initHeaders ?? {});
1944
- }
1920
+ import {
1921
+ DjvApiError,
1922
+ NetworkError,
1923
+ TimeoutError,
1924
+ AbortError,
1925
+ isRetryableError,
1926
+ Configuration as Configuration3,
1927
+ createConsoleLogger,
1928
+ createSilentLogger
1929
+ } from "@djvlc/openapi-client-core";
1930
+ var SDK_INFO = {
1931
+ name: true ? "@djvlc/openapi-user-client" : "@djvlc/openapi-user-client",
1932
+ version: true ? "1.0.0" : "0.0.0-dev"
1933
+ };
1945
1934
  function createUserClient(opts) {
1946
- const timeoutMs = opts.timeoutMs ?? 15e3;
1947
- const fetchImpl = opts.fetchApi ?? fetch;
1948
- const fetchWithTimeout = createFetchWithTimeout(fetchImpl, timeoutMs);
1949
- const headersMiddleware = {
1950
- async pre(context) {
1951
- const headers = normalizeHeaders(context.init.headers);
1952
- if (opts.defaultHeaders) {
1953
- for (const [k, v] of Object.entries(opts.defaultHeaders)) headers.set(k, v);
1954
- }
1955
- if (opts.getAuthToken) {
1956
- const token = await opts.getAuthToken();
1957
- if (token) headers.set("Authorization", `Bearer ${token}`);
1958
- }
1959
- if (opts.getTraceHeaders) {
1960
- const traceHeaders = opts.getTraceHeaders();
1961
- for (const [k, v] of Object.entries(traceHeaders)) headers.set(k, v);
1962
- }
1963
- return { url: context.url, init: { ...context.init, headers } };
1964
- }
1935
+ const defaultOpts = {
1936
+ timeoutMs: 15e3,
1937
+ // User API 追求快失败
1938
+ credentials: "omit"
1939
+ // 通常不走 Cookie
1965
1940
  };
1966
- const config = new Configuration({
1967
- basePath: stripTrailingSlash(opts.baseUrl),
1968
- fetchApi: fetchWithTimeout,
1969
- middleware: [headersMiddleware],
1970
- credentials: opts.credentials ?? "omit"
1971
- });
1972
- const apiInstances = {};
1973
- for (const [name, ApiClass] of Object.entries(apis_exports)) {
1974
- if (typeof ApiClass === "function" && name.endsWith("Api")) {
1975
- apiInstances[name] = new ApiClass(config);
1976
- }
1977
- }
1978
- return {
1979
- config,
1980
- apis: apiInstances,
1981
- ...apiInstances
1941
+ const mergedOpts = {
1942
+ ...defaultOpts,
1943
+ ...opts
1982
1944
  };
1945
+ return createClient(apis_exports, mergedOpts, SDK_INFO);
1983
1946
  }
1984
1947
  export {
1948
+ AbortError,
1985
1949
  ActionApi,
1986
1950
  ActionContextFromJSON,
1987
1951
  ActionContextFromJSONTyped,
@@ -2017,7 +1981,7 @@ export {
2017
1981
  BlockedComponentFromJSONTyped,
2018
1982
  BlockedComponentToJSON,
2019
1983
  BlockedComponentToJSONTyped,
2020
- Configuration,
1984
+ Configuration3 as Configuration,
2021
1985
  DataApi,
2022
1986
  DataQueryContextFromJSON,
2023
1987
  DataQueryContextFromJSONTyped,
@@ -2031,6 +1995,7 @@ export {
2031
1995
  DataQueryResponseFromJSONTyped,
2032
1996
  DataQueryResponseToJSON,
2033
1997
  DataQueryResponseToJSONTyped,
1998
+ DjvApiError,
2034
1999
  ErrorDetailFromJSON,
2035
2000
  ErrorDetailFromJSONTyped,
2036
2001
  ErrorDetailToJSON,
@@ -2069,6 +2034,7 @@ export {
2069
2034
  ManifestItemFromJSONTyped,
2070
2035
  ManifestItemToJSON,
2071
2036
  ManifestItemToJSONTyped,
2037
+ NetworkError,
2072
2038
  PageApi,
2073
2039
  PageManifestFromJSON,
2074
2040
  PageManifestFromJSONTyped,
@@ -2108,6 +2074,7 @@ export {
2108
2074
  RuntimeConfigReportConfigToJSONTyped,
2109
2075
  RuntimeConfigToJSON,
2110
2076
  RuntimeConfigToJSONTyped,
2077
+ TimeoutError,
2111
2078
  TraceContextFromJSON,
2112
2079
  TraceContextFromJSONTyped,
2113
2080
  TraceContextToJSON,
@@ -2134,6 +2101,8 @@ export {
2134
2101
  UserActivityStateProgressToJSONTyped,
2135
2102
  UserActivityStateToJSON,
2136
2103
  UserActivityStateToJSONTyped,
2104
+ createConsoleLogger,
2105
+ createSilentLogger,
2137
2106
  createUserClient,
2138
2107
  instanceOfActionContext,
2139
2108
  instanceOfActionExecuteRequest,
@@ -2169,5 +2138,6 @@ export {
2169
2138
  instanceOfTrackEvent,
2170
2139
  instanceOfTrackRequest,
2171
2140
  instanceOfUserActivityState,
2172
- instanceOfUserActivityStateProgress
2141
+ instanceOfUserActivityStateProgress,
2142
+ isRetryableError
2173
2143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djvlc/openapi-user-client",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "DJV Low-code Platform - User API 客户端(自动生成)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -19,12 +19,14 @@
19
19
  "scripts": {
20
20
  "clean": "rimraf src/gen dist",
21
21
  "gen": "node ../../tools/openapi/generate-clients.js user",
22
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
+ "build": "tsup --config tsup.config.ts",
23
23
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
24
24
  "lint": "eslint src/ --ext .ts --ignore-pattern src/gen/",
25
25
  "typecheck": "tsc --noEmit"
26
26
  },
27
- "dependencies": {},
27
+ "dependencies": {
28
+ "@djvlc/openapi-client-core": "1.1.0"
29
+ },
28
30
  "devDependencies": {
29
31
  "@types/node": "^20.0.0",
30
32
  "@typescript-eslint/eslint-plugin": "^7.0.0",