foggy-data-viewer 1.0.1-beta.46 → 1.0.1-beta.47

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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Foggy Data Viewer
2
2
 
3
- 一个基于 Vue 3 + TypeScript + vxe-table 的企业级数据表格组件库。
3
+ 一个基于 Vue 3 + TypeScript + vxe-table 的企业级数据表格组件库。
4
+
5
+ HTTP 鉴权接入(beta.47 起):从公共入口导入 `configureDataViewerHttp`,在应用挂载前配置动态 `getHeaders` 和 `onUnauthorized`。允许先导入 SDK 再配置,无需 patch Axios,也无需修改 generated 文件。详见 [HTTP 接入与 TMS 迁移指南](./docs/http-auth.md)。
4
6
 
5
7
  ## 特性
6
8
 
@@ -99,31 +101,31 @@ function handlePageChange(page: number, pageSize: number) {
99
101
  :loading="false"
100
102
  @page-change="handlePageChange"
101
103
  />
102
- </template>
103
- ```
104
-
105
- ### 3. 展示“分”为“元”的金额字段
106
-
107
- 金额单位必须由字段元数据显式声明;组件不会根据字段名、`MONEY` 类型或
108
- `semanticScaleFactor` 推断。模型定义可直接复用公共导出:
109
-
110
- ```typescript
111
- import { MONEY_VIEWER } from 'foggy-data-viewer'
112
-
113
- const amountField = {
114
- name: 'amount',
115
- type: 'MONEY',
116
- extData: {
117
- viewer: MONEY_VIEWER
118
- }
119
- }
120
- ```
121
-
122
- 此配置会把原始值 `3400` 展示为 `34.00`,并把筛选输入的 `34` 精确换算为
123
- 提交给查询端的 `3400`。行数据、服务端汇总数据和排序值始终保持原始“分”值;
124
- 已经返回“元”的字段不要配置 `MONEY_VIEWER`。
125
-
126
- ## 组件列表
104
+ </template>
105
+ ```
106
+
107
+ ### 3. 展示“分”为“元”的金额字段
108
+
109
+ 金额单位必须由字段元数据显式声明;组件不会根据字段名、`MONEY` 类型或
110
+ `semanticScaleFactor` 推断。模型定义可直接复用公共导出:
111
+
112
+ ```typescript
113
+ import { MONEY_VIEWER } from 'foggy-data-viewer'
114
+
115
+ const amountField = {
116
+ name: 'amount',
117
+ type: 'MONEY',
118
+ extData: {
119
+ viewer: MONEY_VIEWER
120
+ }
121
+ }
122
+ ```
123
+
124
+ 此配置会把原始值 `3400` 展示为 `34.00`,并把筛选输入的 `34` 精确换算为
125
+ 提交给查询端的 `3400`。行数据、服务端汇总数据和排序值始终保持原始“分”值;
126
+ 已经返回“元”的字段不要配置 `MONEY_VIEWER`。
127
+
128
+ ## 组件列表
127
129
 
128
130
  ### 核心组件
129
131
 
@@ -0,0 +1,20 @@
1
+ import type { AxiosRequestConfig } from 'axios';
2
+ export type DataViewerHttpHeaders = Record<string, string | null | undefined>;
3
+ export interface DataViewerHttpRequestOptions {
4
+ headers?: DataViewerHttpHeaders;
5
+ }
6
+ export interface DataViewerUnauthorizedContext {
7
+ status: 401;
8
+ method: string;
9
+ /** Path only: excludes credentials, query, fragment, headers and body. */
10
+ path: string;
11
+ }
12
+ export interface DataViewerHttpConfig {
13
+ getHeaders?: () => DataViewerHttpHeaders | Promise<DataViewerHttpHeaders>;
14
+ onUnauthorized?: (context: DataViewerUnauthorizedContext) => void | Promise<void>;
15
+ }
16
+ /** Replace configuration for all SDK clients, including already-created clients. */
17
+ export declare function configureDataViewerHttp(config: DataViewerHttpConfig): void;
18
+ export declare function httpOptions(options?: DataViewerHttpRequestOptions): AxiosRequestConfig;
19
+ /** Internal factory; response unwrapping remains owned by each existing API. */
20
+ export declare function createDataViewerHttpClient(baseURL: string): import("axios").AxiosInstance;
@@ -1,3 +1,4 @@
1
+ import type { DataViewerHttpRequestOptions } from './http';
1
2
  import type { ColumnViewSetting, ListPresetDef, ListPresetVisibility, QueryConditionPreset } from '@/types';
2
3
  export interface ListPresetScope {
3
4
  userId: string;
@@ -19,32 +20,32 @@ export type UpdateListPresetRequest = Partial<SaveListPresetRequest>;
19
20
  /**
20
21
  * 查询当前用户在指定 model/businessKey 下的自定义列表方案。
21
22
  */
22
- export declare function listPresets(scope: ListPresetScope): Promise<ListPresetDef[]>;
23
+ export declare function listPresets(scope: ListPresetScope, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef[]>;
23
24
  /**
24
25
  * 查询当前用户在指定 model/businessKey 下的默认自定义列表。
25
26
  */
26
- export declare function getDefaultListPreset(scope: ListPresetScope): Promise<ListPresetDef | null>;
27
+ export declare function getDefaultListPreset(scope: ListPresetScope, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef | null>;
27
28
  /**
28
29
  * 保存新的自定义列表方案。
29
30
  */
30
- export declare function createListPreset(scope: ListPresetScope, request: SaveListPresetRequest): Promise<ListPresetDef>;
31
+ export declare function createListPreset(scope: ListPresetScope, request: SaveListPresetRequest, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef>;
31
32
  /**
32
33
  * 获取单个自定义列表详情。
33
34
  */
34
- export declare function getListPreset(userId: string, presetId: string): Promise<ListPresetDef>;
35
+ export declare function getListPreset(userId: string, presetId: string, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef>;
35
36
  /**
36
37
  * 更新自定义列表方案。
37
38
  */
38
- export declare function updateListPreset(userId: string, presetId: string, request: UpdateListPresetRequest): Promise<ListPresetDef>;
39
+ export declare function updateListPreset(userId: string, presetId: string, request: UpdateListPresetRequest, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef>;
39
40
  /**
40
41
  * 删除自定义列表方案。
41
42
  */
42
- export declare function deleteListPreset(userId: string, presetId: string): Promise<void>;
43
+ export declare function deleteListPreset(userId: string, presetId: string, options?: DataViewerHttpRequestOptions): Promise<void>;
43
44
  /**
44
45
  * 将某个自定义列表设为默认方案。
45
46
  */
46
- export declare function setDefaultListPreset(userId: string, presetId: string): Promise<ListPresetDef>;
47
+ export declare function setDefaultListPreset(userId: string, presetId: string, options?: DataViewerHttpRequestOptions): Promise<ListPresetDef>;
47
48
  /**
48
49
  * 清除当前 model/businessKey 下的默认方案。
49
50
  */
50
- export declare function clearDefaultListPreset(scope: ListPresetScope): Promise<void>;
51
+ export declare function clearDefaultListPreset(scope: ListPresetScope, options?: DataViewerHttpRequestOptions): Promise<void>;
@@ -1,2 +1,3 @@
1
+ import type { DataViewerHttpRequestOptions } from './http';
1
2
  import type { TableDefaultQueryConfig, TableDefaultQueryConfigScope } from '@/types';
2
- export declare function getTableDefaultQueryConfig(scope: TableDefaultQueryConfigScope): Promise<TableDefaultQueryConfig | null>;
3
+ export declare function getTableDefaultQueryConfig(scope: TableDefaultQueryConfigScope, options?: DataViewerHttpRequestOptions): Promise<TableDefaultQueryConfig | null>;
@@ -1,3 +1,4 @@
1
+ import type { DataViewerHttpRequestOptions } from './http';
1
2
  import type { QueryMetaResponse, ViewerQueryRequest, ViewerDataResponse, FilterOptionsResponse, ColumnSchema, FrontendMeta, MemberQueryRequest, MemberQueryResponse, OrderRequestDef } from '@/types';
2
3
  /**
3
4
  * 查询 payload(与 dataset.query_model 格式一致)
@@ -41,40 +42,40 @@ export interface CreateQueryResponse {
41
42
  /**
42
43
  * 创建查询(从 DSL 输入)
43
44
  */
44
- export declare function createQuery(request: CreateQueryRequest): Promise<CreateQueryResponse>;
45
+ export declare function createQuery(request: CreateQueryRequest, options?: DataViewerHttpRequestOptions): Promise<CreateQueryResponse>;
45
46
  /**
46
47
  * 获取查询元数据
47
48
  */
48
- export declare function fetchQueryMeta(model: string, queryId: string): Promise<QueryMetaResponse>;
49
+ export declare function fetchQueryMeta(model: string, queryId: string, options?: DataViewerHttpRequestOptions): Promise<QueryMetaResponse>;
49
50
  /**
50
51
  * 查询数据
51
52
  */
52
- export declare function fetchQueryData(model: string, queryId: string, request: ViewerQueryRequest): Promise<ViewerDataResponse>;
53
+ export declare function fetchQueryData(model: string, queryId: string, request: ViewerQueryRequest, options?: DataViewerHttpRequestOptions): Promise<ViewerDataResponse>;
53
54
  /**
54
55
  * 获取过滤选项(维度成员或字典项)
55
56
  */
56
- export declare function fetchFilterOptions(model: string, queryId: string, columnName: string): Promise<FilterOptionsResponse>;
57
+ export declare function fetchFilterOptions(model: string, queryId: string, columnName: string, options?: DataViewerHttpRequestOptions): Promise<FilterOptionsResponse>;
57
58
  /**
58
59
  * 获取 QM Schema(查询模型的字段元数据)
59
60
  */
60
- export declare function fetchQmSchema(qmModel: string): Promise<ColumnSchema[]>;
61
+ export declare function fetchQmSchema(qmModel: string, options?: DataViewerHttpRequestOptions): Promise<ColumnSchema[]>;
61
62
  /**
62
63
  * 直连查询数据(无需提前创建 queryId)
63
64
  *
64
65
  * 适用于生成组件的标准用法:只需 qmModel + 分页/筛选/排序/列集合即可查询。
65
66
  * 现有 fetchQueryData(model, queryId, request) 保留给 DataViewer / SavedQuery 场景。
66
67
  */
67
- export declare function fetchQueryDataDirect(qmModel: string, request: ViewerQueryRequest): Promise<ViewerDataResponse>;
68
+ export declare function fetchQueryDataDirect(qmModel: string, request: ViewerQueryRequest, options?: DataViewerHttpRequestOptions): Promise<ViewerDataResponse>;
68
69
  /**
69
70
  * 获取前端元数据契约 (frontend-meta v1)
70
71
  *
71
72
  * 返回面向前端渲染的标准元数据:fields 为有序数组、包含 memberLookup/category/uiHints。
72
73
  */
73
- export declare function fetchFrontendMeta(qmModel: string): Promise<FrontendMeta>;
74
+ export declare function fetchFrontendMeta(qmModel: string, options?: DataViewerHttpRequestOptions): Promise<FrontendMeta>;
74
75
  /**
75
76
  * 查询维度成员(远程搜索、分页、回填)
76
77
  *
77
78
  * 用于 SelectFilter 的 dimension 远程模式,替代旧的 fetchFilterOptions。
78
79
  * DSL slice 应使用返回的 selectionFieldName,而非 displayFieldName。
79
80
  */
80
- export declare function fetchMemberOptions(request: MemberQueryRequest): Promise<MemberQueryResponse>;
81
+ export declare function fetchMemberOptions(request: MemberQueryRequest, options?: DataViewerHttpRequestOptions): Promise<MemberQueryResponse>;
package/dist/index.d.ts CHANGED
@@ -20,6 +20,8 @@ export { MONEY_VIEWER, formatViewerValue, getColumnMoneyViewer, resolveMoneyView
20
20
  export { buildPivotGridColumns, flattenPivotLeafNodes, validatePivotHeaderTree } from './utils/pivotHeaderTree';
21
21
  export { buildPivotCellField, toPivotViewModel } from './utils/pivotViewModelAdapter';
22
22
  export type { BuildPivotGridColumnsOptions, PivotGridColumn, PivotHeaderValidationResult } from './utils/pivotHeaderTree';
23
+ export { configureDataViewerHttp } from './api/http';
24
+ export type { DataViewerHttpConfig, DataViewerHttpHeaders, DataViewerHttpRequestOptions, DataViewerUnauthorizedContext } from './api/http';
23
25
  export { createQuery, fetchQueryMeta, fetchQueryData, fetchFilterOptions, fetchQmSchema, fetchQueryDataDirect, fetchFrontendMeta, fetchMemberOptions } from './api/viewer';
24
26
  export type { QueryPayload, CreateQueryRequest, CreateQueryResponse } from './api/viewer';
25
27
  export { listPresets, getDefaultListPreset, createListPreset, getListPreset, updateListPreset, deleteListPreset, setDefaultListPreset, clearDefaultListPreset } from './api/listPreset';