@sdata-plugin-adapter/types 0.0.0-alpha.2 → 0.0.0-alpha.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.
Files changed (2) hide show
  1. package/dist/index.d.mts +155 -22
  2. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -3,12 +3,11 @@ import * as ReactDOMClientType from "react-dom/client";
3
3
 
4
4
  //#region index.d.ts
5
5
  interface CustomConfig {
6
- componentId: string;
6
+ componentId?: string;
7
7
  id: string;
8
- appId?: string;
9
8
  [key: string]: any;
10
9
  }
11
- type ConfigType = "default" | "data" | "style" | "interaction";
10
+ type ConfigType = 'default' | 'data' | 'style' | 'interaction';
12
11
  type ActionsFunction = {
13
12
  [key: string]: (...args: any[]) => any;
14
13
  };
@@ -39,46 +38,180 @@ interface UseRegisterComponentParams {
39
38
  actions?: ActionsFunction;
40
39
  eventActionDefinitions?: EventActionDefinitions;
41
40
  }
42
- interface AppTriggerEventPayload {
41
+ interface TriggerEventPayload {
43
42
  componentId?: string;
44
43
  event: string;
45
44
  payload?: Record<string, any>;
46
45
  [key: string]: any;
47
46
  }
48
- interface AdapterProps {
49
- isConfig?: boolean;
50
- changeCustomConfig?: (customConfigStr: string) => void;
51
- onConfigChange: (config: any) => void;
52
- componentId?: string;
47
+ interface BaseAppProps {
48
+ isConfig: boolean;
49
+ configType: ConfigType;
53
50
  customConfig: CustomConfig;
54
- configType?: ConfigType;
55
- type?: string;
56
- appTriggerEvent?: (payload: AppTriggerEventPayload) => void;
57
- triggerEvent?: (eventName: string, payload?: Record<string, any>) => void;
58
- useRegisterComponent?: (params: UseRegisterComponentParams) => void;
51
+ onConfigChange: (parasm: Record<string, any>) => void;
52
+ appTriggerEvent: (payload: TriggerEventPayload) => void;
53
+ }
54
+ interface AppAdapterProps extends BaseAppProps {
55
+ changeCustomConfig: (customConfig: string | CustomConfig) => void;
56
+ componentId: string;
57
+ type: string;
58
+ triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
59
+ useRegisterComponent: (params: UseRegisterComponentParams) => void;
60
+ }
61
+ interface FormConfig {
62
+ id: string;
63
+ form_name: string;
59
64
  [key: string]: any;
60
65
  }
61
- type PluginProps = AdapterProps & Record<string, any>;
62
- interface startOptions {
66
+ interface QueryProps {
67
+ data: Record<string, any>;
68
+ queryConfig: Record<string, any>;
69
+ onSearch: unknown;
70
+ onChange: (params: Record<string, any>) => void;
71
+ }
72
+ interface BaseReportProps {
73
+ type: string;
74
+ formConfig: FormConfig;
75
+ queryProps: QueryProps;
76
+ queryData: Record<string, any>;
77
+ component: CustomConfig;
78
+ control$: Record<string, any>;
79
+ parent: CustomConfig;
80
+ configuration: string;
81
+ changeConfiguration: (param: any) => void;
82
+ instance: Record<string, any>;
83
+ isDesign: boolean;
84
+ index: string | number;
85
+ child_id: string | number;
86
+ }
87
+ interface ReportAdapterProps extends BaseReportProps {
88
+ formId: string;
89
+ formName: string;
90
+ isInChildTable: boolean;
91
+ componentId: string;
92
+ componentName: string;
93
+ customConfig: CustomConfig;
94
+ type: string;
95
+ changeCustomConfig?: (customConfig: string | Record<string, any>) => void;
96
+ onSearch: unknown;
97
+ onSearchChange: (value: unknown, type: number) => void;
98
+ triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
99
+ useRegisterComponent: (params: UseRegisterComponentParams) => void;
100
+ }
101
+ type baseCol = {
102
+ id: string | number;
103
+ showType: string;
104
+ componentConfig: Record<string, any>;
105
+ [key: string]: any;
106
+ };
107
+ type column = {
108
+ showType: string;
109
+ value: string | number;
110
+ label: string;
111
+ };
112
+ interface BaseDFListProps {
113
+ viewId: string;
114
+ pluginId: string;
115
+ type: string;
116
+ configuration: string;
117
+ pluginConfig: CustomConfig;
118
+ allComponentList: baseCol[];
119
+ changeConfiguration: (param: any) => void;
120
+ }
121
+ interface DFListAdapterProps extends BaseDFListProps {
122
+ componentId: string;
123
+ type: 'designConfiguration' | 'main';
124
+ customConfig: CustomConfig;
125
+ columnList: column[];
126
+ changeCustomConfig?: (customConfig: string | Record<string, any>) => void;
127
+ triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
128
+ useRegisterComponent: (params: UseRegisterComponentParams) => void;
129
+ }
130
+ type BScreenBlock = {
131
+ baseConfig: {
132
+ id: string | number;
133
+ } & Record<string, any>;
134
+ dataConfig: {
135
+ pluginOptions: Record<string, any>;
136
+ columns: unknown;
137
+ };
138
+ };
139
+ type bigScreenType = {
140
+ updateBlockById: (id: string | number, data: Record<string, any>) => void;
141
+ pluginDetailMap: Record<string, any>;
142
+ variableList: unknown;
143
+ rootStore: {
144
+ bigscreen: bigScreenType;
145
+ };
146
+ };
147
+ type bigScreenOptions = {
148
+ externalVariables: any;
149
+ } & Record<string, any>;
150
+ type bigScreenPubSub = {
151
+ subscribe: (id: string, call: (...args: unknown[]) => void) => void;
152
+ };
153
+ interface BaseBScreenProps {
154
+ componentId: string;
155
+ type: 'main' | string;
156
+ block: BScreenBlock;
157
+ bigscreen: bigScreenType;
158
+ options: bigScreenOptions;
159
+ pubSub: bigScreenPubSub;
160
+ }
161
+ interface BScreenAdapterProps extends BaseBScreenProps {
162
+ customConfig: Record<string, any>;
163
+ customOptions: bigScreenOptions;
164
+ variableList: unknown;
165
+ afterUpdateComponent: (callback: (data: unknown) => unknown) => void;
166
+ setComponentVisible: (visible: boolean) => void;
167
+ changeCustomConfig: (pluginOptions: string) => void;
168
+ triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
169
+ useRegisterComponent: (params: UseRegisterComponentParams) => void;
170
+ }
171
+ type AnalyzerOptions = {
172
+ analyzer_secondary_configuration: string;
173
+ externalVariables: Record<string, any>;
174
+ };
175
+ interface BaseAnalyzerProps {
176
+ componentId: string;
177
+ type: 'main' | string;
178
+ configuration: CustomConfig;
179
+ options: AnalyzerOptions;
180
+ dataSource: unknown;
181
+ data: unknown;
182
+ changeConfiguration: (configuration: unknown) => void;
183
+ }
184
+ interface AnalyzerAdapterProps extends BaseAnalyzerProps {
185
+ data: unknown;
186
+ customConfig: CustomConfig;
187
+ customOptions: Record<string, any>;
188
+ changeCustomConfig: (configuration: string) => void;
189
+ triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
190
+ useRegisterComponent: (params: UseRegisterComponentParams) => void;
191
+ }
192
+ type BaseProps = BaseAppProps | BaseReportProps | BaseDFListProps | BaseBScreenProps | BaseAnalyzerProps;
193
+ type AdapterFn<T extends BaseProps, R extends T> = (props: T) => R;
194
+ interface StartOptions {
63
195
  App: React.ComponentType;
64
196
  beforeBootstrap?: (callback: () => void) => void;
65
197
  }
66
- interface createPluginOptions extends startOptions {
67
- setAttributes: (dom: Element, props: PluginProps) => Promise<any>;
68
- adapter: (props: AdapterProps) => AdapterProps;
198
+ type SetAttributes<T extends BaseProps> = (dom: Element, props: T) => Promise<void>;
199
+ interface CreatePluginOptions<P extends BaseProps, R extends P> extends StartOptions {
200
+ setAttributes: SetAttributes<P>;
201
+ adapter: AdapterFn<P, R>;
69
202
  }
70
203
  interface EventBus {
71
204
  emit: (props: Record<string, any>) => void;
72
205
  on: (callback: (payload?: any) => void) => void;
73
206
  remove: () => void;
74
207
  }
75
- type PluginRun = (dom: Element, props: PluginProps, context?: Record<string, any>, eventBus?: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
208
+ type PluginRun<T extends BaseProps> = (dom: Element, props: T, context: Record<string, any>, eventBus: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
76
209
  declare global {
77
210
  interface Window {
78
211
  React: typeof ReactType;
79
212
  ReactDOM: typeof ReactDOMClientType;
80
213
  online_development_islocal: boolean;
81
- CUSTOM_PLUGIN: Map<string, PluginRun>;
214
+ CUSTOM_PLUGIN: Map<string, PluginRun<keyof BaseProps>>;
82
215
  eventCenter: {
83
216
  triggerEventNew: (payload: Record<string, any>) => void;
84
217
  [key: string]: any;
@@ -92,4 +225,4 @@ declare global {
92
225
  }
93
226
  }
94
227
  //#endregion
95
- export { type ActionsFunction, type ActionsPayload, type AdapterProps, type AppTriggerEventPayload, type CustomConfig, type EventActionDefinitions, type EventBus, type EventsPayload, type PluginProps, type PluginRun, type UseRegisterComponentParams, type createPluginOptions, type startOptions };
228
+ export { type ActionsFunction, type ActionsPayload, type AdapterFn, type AnalyzerAdapterProps, type AppAdapterProps, type BScreenAdapterProps, type BaseAnalyzerProps, type BaseAppProps, type BaseBScreenProps, type BaseDFListProps, type BaseProps, type BaseReportProps, type CreatePluginOptions, type CustomConfig, type DFListAdapterProps, type EventActionDefinitions, type EventBus, type EventsPayload, type PluginRun, type ReportAdapterProps, type SetAttributes, type StartOptions, type TriggerEventPayload, type UseRegisterComponentParams };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdata-plugin-adapter/types",
3
- "version": "0.0.0-alpha.2",
3
+ "version": "0.0.0-alpha.3",
4
4
  "description": "adapter types of smdata plugin",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.mts",