ronds-metadata 1.3.73 → 1.3.74

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/es/api/index.js CHANGED
@@ -5,12 +5,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  /*
6
6
  * @Author:wangxian
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2024-07-23 19:54:50
8
+ * @LastEditTime: 2024-08-20 11:46:17
9
9
  */
10
10
  import { guid, md5 } from '../utils';
11
11
  import { addInterceptor, HttpHelper } from '../framework/http';
12
12
  var http = new HttpHelper();
13
- var token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IkMyMTJFMjI1NTcwNjRDQTE3M0U2NjkxRjM4QzFDOEEyIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE3MjQxNDAxNzYsImV4cCI6MTcyNDM5OTM3NiwiaXNzIjoiaHR0cDovL2ZhYmlvOjk5OTkvc3VwZXJjYXJlY29yZSIsImF1ZCI6ImVwbSIsImNsaWVudF9pZCI6ImVwbSIsInN1YiI6IjNhMTIxZDJiLWYwZDUtZDQ3OC0xN2Q3LWQwODEwZDgzZDViMSIsImF1dGhfdGltZSI6MTcyNDE0MDE3NiwiaWRwIjoibG9jYWwiLCJuYW1lIjoicGhtIiwiZW1haWwiOiJwaG1AYWJwLmlvIiwicm9sZSI6WyJhZG1pbiIsInBobV9hZG1pbiJdLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9naXZlbm5hbWUiOiJwaG3ov5Dnu7TotKblj7ciLCJwaG9uZV9udW1iZXIiOiIxMzYwMDAwMDAwMCIsInBob25lX251bWJlcl92ZXJpZmllZCI6IlRydWUiLCJlbWFpbF92ZXJpZmllZCI6IlRydWUiLCJpYXQiOjE3MjQxNDAxNzYsInNjb3BlIjpbImFkZHJlc3MiLCJlbWFpbCIsImVwbSIsIm9wZW5pZCIsInBob25lIiwicHJvZmlsZSIsInJvbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.UbzQuknIHc6bHvyF-ph0NlqenAOCxUjlt1Q0DkPhX9BJkKMetIgo1HL9Dv0wJV1m7J5nkha7kqFM4lfnTXlZEn-hJdkse96C-NLfR4lrRedgrljhfqnwyCPZm0RbEOLsLAAKNN8Ib7m4NJ-4glgqO_ZdEMa4eZIY9WKSWDLsuyyMSyaXNGWzFf5aHGolIy4RguJ_NXzOJgZfsln3V9iaxSc7g2XXtn4gVIK-Pqw33Ig6_gpATd6hGFj0eBbZ6RMQPc-BNQ4H9JDvGuURIUsOAvcct2U36N1avB1qf9NKECFC4CoWR4CArcZJl-s5p2uCopcYe2d4alZqQofOzrei1Q';
13
+ var token = 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkMyMTJFMjI1NTcwNjRDQTE3M0U2NjkxRjM4QzFDOEEyIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE3MjQxMjUzODgsImV4cCI6MTcyNDM4NDU4OCwiaXNzIjoiaHR0cDovL2ZhYmlvOjk5OTkvc3VwZXJjYXJlY29yZSIsImF1ZCI6ImVwbSIsImNsaWVudF9pZCI6ImVwbSIsInN1YiI6IjNhMTIxZDJiLWYwZDUtZDQ3OC0xN2Q3LWQwODEwZDgzZDViMSIsImF1dGhfdGltZSI6MTcyNDEyNTM4OCwiaWRwIjoibG9jYWwiLCJuYW1lIjoicGhtIiwiZW1haWwiOiJwaG1AYWJwLmlvIiwicm9sZSI6WyJhZG1pbiIsInBobV9hZG1pbiJdLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9naXZlbm5hbWUiOiJwaG3ov5Dnu7TotKblj7ciLCJwaG9uZV9udW1iZXIiOiIxMzYwMDAwMDAwMCIsInBob25lX251bWJlcl92ZXJpZmllZCI6IlRydWUiLCJlbWFpbF92ZXJpZmllZCI6IlRydWUiLCJpYXQiOjE3MjQxMjUzODgsInNjb3BlIjpbImFkZHJlc3MiLCJlbWFpbCIsImVwbSIsIm9wZW5pZCIsInBob25lIiwicHJvZmlsZSIsInJvbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.fH99cc4srAXIIsJARb7YTafKvM3qtpcdufA_NZKPNEtSRMFI6vhmr5qv2SdzLL2MvtRMwOTNTTAaIswMLKlp9IXDqJ2-E5yri6Qye1e1lp5mYlN-l8H0cGKVl3lpwfUBW85VK5UhSW4GP236Ae5MTBfqlxnriVhYwi0p2TYg4EdOYxmKAxZUER4PIhH40tkQjvA-KaHExJ0BDmGdIGTRTSpw_wqnpBHqzlWgjIurNUg-I_R4OfhMRE266cvr5TTdwfKB2tEpUYFPq-Nj6Oth3Oa2u1hdpXZX6JsqM3pKQCJYPbxLgg-Shgp1gPm21DE6GTxXKfx2UtV0YhBknnILzA';
14
14
  addInterceptor(function (httpClient) {
15
15
  httpClient.interceptors.request.use(function (_config) {
16
16
  if (!_config.headers) {
@@ -2,6 +2,7 @@ import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
3
  import "antd/es/select/style";
4
4
  import _Select from "antd/es/select";
5
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
6
  import _extends from "@babel/runtime/helpers/esm/extends";
6
7
  import "antd/es/upload/style";
7
8
  import _Upload from "antd/es/upload";
@@ -20,7 +21,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
20
21
  /*
21
22
  * @Author: wangxian
22
23
  * @Date: 2021-09-18 14:15:04
23
- * @LastEditTime: 2024-07-16 15:37:30
24
+ * @LastEditTime: 2024-08-20 17:58:34
24
25
  */
25
26
  import React from 'react';
26
27
  import { UploadOutlined } from '@ant-design/icons';
@@ -34,6 +35,8 @@ import { MetadataService } from '../../../framework/metadata/MetadataService';
34
35
  import SparkSqlTable from './plugin/SparkSqlTable';
35
36
  import MapTable from './plugin/MapTable';
36
37
  import SourceConfig from './plugin/SourceConfig';
38
+ import DataSource from './plugin/Datasource';
39
+ import BusinessForm from './business';
37
40
  var TextArea = _Input.TextArea;
38
41
  function Index(props) {
39
42
  var _extraInfo$addonAfter7;
@@ -131,7 +134,7 @@ function Index(props) {
131
134
  }, _callee);
132
135
  })), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.autoComplete]);
133
136
  var processInputType = function processInputType(_type) {
134
- var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$disabled6, _extraInfo$disabled7, _extraInfo$addonAfter2, _extraInfo$addonAfter3, _extraInfo$addonAfter4, _extraInfo$addonAfter5, _extraInfo$disabled8;
137
+ var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$disabled6, _extraInfo$disabled7, _extraInfo$disabled8, _extraInfo$disabled9, _extraInfo$addonAfter2, _extraInfo$addonAfter3, _extraInfo$addonAfter4, _extraInfo$addonAfter5, _extraInfo$disabled10;
135
138
  switch (_type) {
136
139
  case 'autoComplete':
137
140
  return /*#__PURE__*/React.createElement(_AutoComplete, {
@@ -191,6 +194,22 @@ function Index(props) {
191
194
  return /*#__PURE__*/React.createElement(NumberRange, _extends({}, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.numberRange, {
192
195
  disabled: (_extraInfo$disabled7 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled7 !== void 0 ? _extraInfo$disabled7 : disabled
193
196
  }));
197
+ case 'datasource':
198
+ return /*#__PURE__*/React.createElement(DataSource, {
199
+ extraInfo: _objectSpread(_objectSpread({}, extraInfo), {}, {
200
+ labelSpan: formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan,
201
+ layout: formContext === null || formContext === void 0 ? void 0 : formContext.layout
202
+ }),
203
+ disabled: (_extraInfo$disabled8 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled8 !== void 0 ? _extraInfo$disabled8 : disabled
204
+ });
205
+ case 'bussiness':
206
+ return /*#__PURE__*/React.createElement(BusinessForm, {
207
+ extraInfo: _objectSpread(_objectSpread({}, extraInfo), {}, {
208
+ labelSpan: formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan,
209
+ layout: formContext === null || formContext === void 0 ? void 0 : formContext.layout
210
+ }),
211
+ disabled: (_extraInfo$disabled9 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled9 !== void 0 ? _extraInfo$disabled9 : disabled
212
+ });
194
213
  case 'sparkSqlTable':
195
214
  return /*#__PURE__*/React.createElement(SparkSqlTable, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.sparkSqlTable);
196
215
  case 'mapTable':
@@ -211,13 +230,49 @@ function Index(props) {
211
230
  }))) : undefined,
212
231
  showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
213
232
  maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
214
- disabled: (_extraInfo$disabled8 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled8 !== void 0 ? _extraInfo$disabled8 : disabled,
233
+ disabled: (_extraInfo$disabled10 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled10 !== void 0 ? _extraInfo$disabled10 : disabled,
215
234
  placeholder: tr(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder),
216
235
  title: tr(valueTitle),
217
236
  allowClear: true
218
237
  });
219
238
  }
220
239
  };
240
+ var getLabelCol = function getLabelCol() {
241
+ if (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) {
242
+ return {
243
+ flex: 0,
244
+ offset: 0
245
+ };
246
+ }
247
+ if (labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal') {
248
+ return {
249
+ flex: "0 0 ".concat(labelSpan * 100 / 24, "%"),
250
+ offset: 0
251
+ };
252
+ }
253
+ return undefined;
254
+ };
255
+ var getWrapperCol = function getWrapperCol() {
256
+ if (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) {
257
+ return {
258
+ style: {
259
+ width: 0,
260
+ flex: 0,
261
+ offset: 0
262
+ }
263
+ };
264
+ }
265
+ if (labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal') {
266
+ return {
267
+ style: {
268
+ width: "".concat((24 - labelSpan) * 100 / 24, "%")
269
+ },
270
+ flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
271
+ offset: 0
272
+ };
273
+ }
274
+ return undefined;
275
+ };
221
276
  // ref引用的 应用类型是否展示成表单
222
277
  if (isObj && isRefForm && field) {
223
278
  var _extraInfo$addonAfter6;
@@ -267,7 +322,10 @@ function Index(props) {
267
322
  color: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color
268
323
  } : {}
269
324
  }, (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) ? '' : tr(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id),
270
- labelCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? {
325
+ labelCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) ? {
326
+ flex: 0,
327
+ offset: 0
328
+ } : {
271
329
  flex: "0 0 ".concat(labelSpan * 100 / 24, "%"),
272
330
  offset: 0
273
331
  } : undefined,
@@ -280,7 +338,7 @@ function Index(props) {
280
338
  } : undefined,
281
339
  name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter7 = extraInfo.addonAfter) === null || _extraInfo$addonAfter7 === void 0 ? void 0 : _extraInfo$addonAfter7.key) ? [].concat(_toConsumableArray(name), ['value']) : name,
282
340
  rules: [{
283
- required: notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require,
341
+ required: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) ? false : notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require,
284
342
  message: "".concat(tr('请输入'), " ").concat(tr(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id)
285
343
  }].concat(_toConsumableArray(rules)),
286
344
  help: tr(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help),
@@ -0,0 +1,86 @@
1
+ export declare const BusinessSchema: {
2
+ kafka: {
3
+ id: string;
4
+ type: string;
5
+ properties: ({
6
+ id: string;
7
+ type: string;
8
+ fields: {
9
+ id: string;
10
+ type: string;
11
+ refId: string;
12
+ value: {
13
+ common: {
14
+ label: string;
15
+ titleHidden: boolean;
16
+ borderHidden: boolean;
17
+ labelSpan: number;
18
+ };
19
+ 'common-en-US': {};
20
+ text: {
21
+ type: string;
22
+ datasource: {
23
+ type: string[];
24
+ kafka: {
25
+ isMutiple: boolean;
26
+ };
27
+ };
28
+ };
29
+ };
30
+ }[];
31
+ enum?: undefined;
32
+ } | {
33
+ id: string;
34
+ type: string;
35
+ enum: {
36
+ value: string;
37
+ }[];
38
+ fields: {
39
+ id: string;
40
+ type: string;
41
+ refId: string;
42
+ value: {
43
+ common: {
44
+ label: string;
45
+ require: boolean;
46
+ labelSpan: number;
47
+ depend: {
48
+ show: string;
49
+ };
50
+ };
51
+ 'common-en-US': {};
52
+ };
53
+ }[];
54
+ } | {
55
+ id: string;
56
+ type: string;
57
+ fields: {
58
+ id: string;
59
+ type: string;
60
+ refId: string;
61
+ value: {
62
+ common: {
63
+ label: string;
64
+ require: boolean;
65
+ labelSpan: number;
66
+ depend: {
67
+ show: string;
68
+ };
69
+ };
70
+ 'common-en-US': {};
71
+ };
72
+ }[];
73
+ enum?: undefined;
74
+ })[];
75
+ fields: {
76
+ id: string;
77
+ type: string;
78
+ refId: string;
79
+ value: {
80
+ colSpan: number;
81
+ labelSpan: number;
82
+ layout: string;
83
+ };
84
+ }[];
85
+ }[];
86
+ };
@@ -0,0 +1,92 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2024-08-20 19:43:42
4
+ * @LastEditTime: 2024-08-20 19:43:54
5
+ */
6
+ var KAFKA_SCHEMA = [{
7
+ id: 'FormGenerator',
8
+ type: 'object',
9
+ properties: [{
10
+ id: 'datasource',
11
+ type: 'text',
12
+ fields: [{
13
+ id: 'Rule.Form',
14
+ type: 'ref',
15
+ refId: 'com.ronds.schema.default.Rule.Form',
16
+ value: {
17
+ common: {
18
+ label: '数据源配置',
19
+ titleHidden: true,
20
+ borderHidden: true,
21
+ labelSpan: 4
22
+ },
23
+ 'common-en-US': {},
24
+ text: {
25
+ type: 'datasource',
26
+ datasource: {
27
+ type: ['Kafka', 'PgSql'],
28
+ kafka: {
29
+ isMutiple: true
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }]
35
+ }, {
36
+ id: 'autoOffsetReset',
37
+ type: 'enum',
38
+ enum: [{
39
+ value: 'earliest'
40
+ }, {
41
+ value: 'latest'
42
+ }],
43
+ fields: [{
44
+ id: 'Rule.Form',
45
+ type: 'ref',
46
+ refId: 'com.ronds.schema.default.Rule.Form',
47
+ value: {
48
+ common: {
49
+ label: '消费策略',
50
+ require: true,
51
+ labelSpan: 4,
52
+ depend: {
53
+ show: 'datasource.dsType=="Kafka"'
54
+ }
55
+ },
56
+ 'common-en-US': {}
57
+ }
58
+ }]
59
+ }, {
60
+ id: 'batchDuration',
61
+ type: 'number',
62
+ fields: [{
63
+ id: 'Rule.Form',
64
+ type: 'ref',
65
+ refId: 'com.ronds.schema.default.Rule.Form',
66
+ value: {
67
+ common: {
68
+ label: '批间隔',
69
+ require: true,
70
+ labelSpan: 4,
71
+ depend: {
72
+ show: 'datasource.dsType=="Kafka"'
73
+ }
74
+ },
75
+ 'common-en-US': {}
76
+ }
77
+ }]
78
+ }],
79
+ fields: [{
80
+ id: 'com.ronds.schema.default.Rule.Form',
81
+ type: 'ref',
82
+ refId: 'com.ronds.schema.default.Rule.Form',
83
+ value: {
84
+ colSpan: 24,
85
+ labelSpan: 2,
86
+ layout: 'horizontal'
87
+ }
88
+ }]
89
+ }];
90
+ export var BusinessSchema = {
91
+ kafka: KAFKA_SCHEMA
92
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface IBusinessFormProps {
3
+ extraInfo?: any;
4
+ disabled?: boolean;
5
+ value?: any;
6
+ onChange?: (value: any) => void;
7
+ }
8
+ declare const BusinessForm: (props: IBusinessFormProps) => React.JSX.Element;
9
+ export default BusinessForm;
@@ -0,0 +1,23 @@
1
+ import MetadataForm from '../..';
2
+ import { BusinessSchema } from './config';
3
+ import React from 'react';
4
+ var BusinessForm = function BusinessForm(props) {
5
+ var _extraInfo$bussiness2;
6
+ var extraInfo = props.extraInfo,
7
+ disabled = props.disabled,
8
+ value = props.value,
9
+ onChange = props.onChange;
10
+ var schema = React.useMemo(function () {
11
+ var _extraInfo$bussiness;
12
+ return BusinessSchema[extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$bussiness = extraInfo.bussiness) === null || _extraInfo$bussiness === void 0 ? void 0 : _extraInfo$bussiness.type];
13
+ }, [extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$bussiness2 = extraInfo.bussiness) === null || _extraInfo$bussiness2 === void 0 ? void 0 : _extraInfo$bussiness2.type]);
14
+ var onValuesChange = function onValuesChange(values, allVals) {};
15
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MetadataForm, {
16
+ schema: schema,
17
+ getFormInstance: function getFormInstance(form) {
18
+ // formRef.current = form;
19
+ },
20
+ onValuesChange: onValuesChange
21
+ }));
22
+ };
23
+ export default BusinessForm;
@@ -0,0 +1,7 @@
1
+ interface IKafkaDatasourceProps {
2
+ extraInfo?: any;
3
+ datasource?: any;
4
+ onChange?: any;
5
+ }
6
+ declare const KafkaDatasource: (props: IKafkaDatasourceProps) => import("react").JSX.Element;
7
+ export default KafkaDatasource;
@@ -0,0 +1,43 @@
1
+ import "antd/es/select/style";
2
+ import _Select from "antd/es/select";
3
+ import "antd/es/col/style";
4
+ import _Col from "antd/es/col";
5
+ import React from "react";
6
+ import { tr } from '../../../../../framework/locale';
7
+ import { useGetDatasource } from './hooks';
8
+ var KafkaDatasource = function KafkaDatasource(props) {
9
+ var _extraInfo$datasource, _extraInfo$datasource2;
10
+ var extraInfo = props.extraInfo,
11
+ datasource = props.datasource,
12
+ onChange = props.onChange;
13
+ var topicOpts = useGetDatasource('Kafka', 2, datasource);
14
+ var onTopicChange = function onTopicChange(value) {
15
+ onChange && onChange(value);
16
+ };
17
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Col, {
18
+ span: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'vertical' && 24,
19
+ flex: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) * 100 / 24, "%") : ''
20
+ }, /*#__PURE__*/React.createElement("label", {
21
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
22
+ }, /*#__PURE__*/React.createElement("div", {
23
+ className: "ant-form-item-label",
24
+ style: {
25
+ width: '100%',
26
+ textAlign: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? 'right' : 'left'),
27
+ flex: '1'
28
+ }
29
+ }, /*#__PURE__*/React.createElement("label", {
30
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
31
+ }, tr('主题'))))), /*#__PURE__*/React.createElement(_Col, {
32
+ flex: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((24 - (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan)) * 100 / 24, "%") : 1,
33
+ style: {
34
+ paddingBottom: '8px'
35
+ }
36
+ }, /*#__PURE__*/React.createElement(_Select, {
37
+ mode: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$datasource = extraInfo.datasource) === null || _extraInfo$datasource === void 0 ? void 0 : (_extraInfo$datasource2 = _extraInfo$datasource.kafka) === null || _extraInfo$datasource2 === void 0 ? void 0 : _extraInfo$datasource2.isMutiple) ? 'multiple' : undefined,
38
+ allowClear: true,
39
+ options: topicOpts,
40
+ onChange: onTopicChange
41
+ })));
42
+ };
43
+ export default KafkaDatasource;
@@ -0,0 +1,5 @@
1
+ interface IPostgreSQLDatasourceProps {
2
+ extraInfo?: any;
3
+ }
4
+ declare const PostgreSQLDatasource: (props: IPostgreSQLDatasourceProps) => import("react").JSX.Element;
5
+ export default PostgreSQLDatasource;
@@ -0,0 +1,60 @@
1
+ import "antd/es/select/style";
2
+ import _Select from "antd/es/select";
3
+ import "antd/es/col/style";
4
+ import _Col from "antd/es/col";
5
+ import React from "react";
6
+ /*
7
+ * @Author: wangxian
8
+ * @Date: 2024-08-20 14:32:52
9
+ * @LastEditTime: 2024-08-20 14:34:19
10
+ */
11
+ import { tr } from '../../../../../framework/locale';
12
+ var PostgreSQLDatasource = function PostgreSQLDatasource(props) {
13
+ var extraInfo = props.extraInfo;
14
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Col, {
15
+ span: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'vertical' && 24,
16
+ flex: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) * 100 / 24, "%") : ''
17
+ }, /*#__PURE__*/React.createElement("label", {
18
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
19
+ }, /*#__PURE__*/React.createElement("div", {
20
+ className: "ant-form-item-label",
21
+ style: {
22
+ width: '100%',
23
+ textAlign: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? 'right' : 'left'),
24
+ flex: '1'
25
+ }
26
+ }, /*#__PURE__*/React.createElement("label", {
27
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
28
+ }, tr('数据库'))))), /*#__PURE__*/React.createElement(_Col, {
29
+ flex: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((24 - (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan)) * 100 / 24, "%") : 1,
30
+ style: {
31
+ paddingBottom: '8px'
32
+ }
33
+ }, /*#__PURE__*/React.createElement(_Select, {
34
+ mode: "multiple",
35
+ allowClear: true
36
+ })), /*#__PURE__*/React.createElement(_Col, {
37
+ span: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'vertical' && 24,
38
+ flex: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) * 100 / 24, "%") : ''
39
+ }, /*#__PURE__*/React.createElement("label", {
40
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ className: "ant-form-item-label",
43
+ style: {
44
+ width: '100%',
45
+ textAlign: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? 'right' : 'left'),
46
+ flex: '1'
47
+ }
48
+ }, /*#__PURE__*/React.createElement("label", {
49
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
50
+ }, tr('模式'))))), /*#__PURE__*/React.createElement(_Col, {
51
+ flex: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((24 - (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan)) * 100 / 24, "%") : 1,
52
+ style: {
53
+ paddingBottom: '8px'
54
+ }
55
+ }, /*#__PURE__*/React.createElement(_Select, {
56
+ mode: "multiple",
57
+ allowClear: true
58
+ })));
59
+ };
60
+ export default PostgreSQLDatasource;
@@ -0,0 +1 @@
1
+ export declare const useGetDatasource: (type: string, level?: number, source?: string) => any[];
@@ -0,0 +1,69 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import { MetadataService } from '../../../../../framework/metadata/MetadataService';
6
+ import React from 'react';
7
+ /*
8
+ * @Author: wangxian
9
+ * @Date: 2024-08-20 14:38:09
10
+ * @LastEditTime: 2024-08-20 18:24:10
11
+ */
12
+ export var useGetDatasource = function useGetDatasource(type) {
13
+ var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
14
+ var source = arguments.length > 2 ? arguments[2] : undefined;
15
+ var _React$useState = React.useState([]),
16
+ _React$useState2 = _slicedToArray(_React$useState, 2),
17
+ list = _React$useState2[0],
18
+ setList = _React$useState2[1];
19
+ var server = new MetadataService();
20
+ var getHttpResult = React.useCallback( /*#__PURE__*/function () {
21
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_type, _level) {
22
+ var res, _config, _list;
23
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ _context.next = 2;
27
+ return server.GetEnumDataByUrl(DATASOURCE_HTTP_URL, 'post', {
28
+ type: _type,
29
+ level: _level,
30
+ source: source
31
+ });
32
+ case 2:
33
+ res = _context.sent;
34
+ _config = RESULT_MAP[_level];
35
+ _list = res.map(function (it) {
36
+ return {
37
+ value: it[_config.key],
38
+ label: it[_config.value]
39
+ };
40
+ });
41
+ setList(_toConsumableArray(_list));
42
+ case 6:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee);
47
+ }));
48
+ return function (_x, _x2) {
49
+ return _ref.apply(this, arguments);
50
+ };
51
+ }(), [source]);
52
+ React.useEffect(function () {
53
+ if (type && level) {
54
+ getHttpResult(type, level);
55
+ }
56
+ }, [type, level, source, getHttpResult]);
57
+ return list;
58
+ };
59
+ var DATASOURCE_HTTP_URL = '/dataset-web/source/cascade/data/v2';
60
+ var RESULT_MAP = {
61
+ 1: {
62
+ key: 'config',
63
+ value: 'name'
64
+ },
65
+ 2: {
66
+ key: 'name',
67
+ value: 'name'
68
+ }
69
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface IDatasourceProps {
3
+ extraInfo?: any;
4
+ disabled?: boolean;
5
+ value?: any;
6
+ onChange?: (value: any) => void;
7
+ }
8
+ declare const DataSource: (props: IDatasourceProps) => React.JSX.Element;
9
+ export default DataSource;
@@ -0,0 +1,128 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
3
+ import "antd/es/input/style";
4
+ import _Input from "antd/es/input";
5
+ import "antd/es/tooltip/style";
6
+ import _Tooltip from "antd/es/tooltip";
7
+ import "antd/es/button/style";
8
+ import _Button from "antd/es/button";
9
+ import "antd/es/select/style";
10
+ import _Select from "antd/es/select";
11
+ import "antd/es/col/style";
12
+ import _Col from "antd/es/col";
13
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
14
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
15
+ import { tr } from '../../../../../framework/locale';
16
+ import React from 'react';
17
+ import KafkaDatasource from './Kafka';
18
+ import { LinkOutlined } from '@ant-design/icons';
19
+ import PostgreSQLDatasource from './PostgreSQL';
20
+ import { useGetDatasource } from './hooks';
21
+ var DataSource = function DataSource(props) {
22
+ var _extraInfo$datasource2;
23
+ var extraInfo = props.extraInfo,
24
+ disabled = props.disabled,
25
+ value = props.value,
26
+ onChange = props.onChange;
27
+ var _React$useState = React.useState(''),
28
+ _React$useState2 = _slicedToArray(_React$useState, 2),
29
+ dsType = _React$useState2[0],
30
+ setDsType = _React$useState2[1];
31
+ var _React$useState3 = React.useState(''),
32
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
33
+ datasource = _React$useState4[0],
34
+ setDatasource = _React$useState4[1];
35
+ var valueRef = React.useRef({});
36
+ var datasourceOpts = useGetDatasource(dsType);
37
+ var datasourceTypeOpts = React.useMemo(function () {
38
+ var _extraInfo$datasource;
39
+ var typeEnum = (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$datasource = extraInfo.datasource) === null || _extraInfo$datasource === void 0 ? void 0 : _extraInfo$datasource.type) || [];
40
+ return typeEnum.map(function (it) {
41
+ return {
42
+ value: it,
43
+ label: it
44
+ };
45
+ });
46
+ }, [extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$datasource2 = extraInfo.datasource) === null || _extraInfo$datasource2 === void 0 ? void 0 : _extraInfo$datasource2.type]);
47
+ var triggerChange = function triggerChange(changedValue) {
48
+ valueRef.current = _objectSpread(_objectSpread({}, valueRef.current), changedValue);
49
+ onChange && onChange(valueRef.current);
50
+ };
51
+ var onDatasourceTypeChange = function onDatasourceTypeChange(value) {
52
+ setDsType(value);
53
+ triggerChange({
54
+ dsType: value
55
+ });
56
+ };
57
+ var onDatasourceChange = function onDatasourceChange(value) {
58
+ setDatasource(value);
59
+ triggerChange(_objectSpread({
60
+ datasource: value
61
+ }, JSON.parse(value)));
62
+ };
63
+ var onKafkaChange = function onKafkaChange(value) {
64
+ triggerChange({
65
+ topics: value
66
+ });
67
+ };
68
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
69
+ style: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.borderHidden) ? {
70
+ padding: '10px 10px 10px 10px',
71
+ border: '1px solid var(--ronds-metadata-color-border-1)',
72
+ width: '100%',
73
+ borderRadius: '4px'
74
+ } : {}
75
+ }, /*#__PURE__*/React.createElement(_Row, {
76
+ className: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.borderHidden) && 'ant-form-item',
77
+ style: {
78
+ alignItems: 'center'
79
+ }
80
+ }, /*#__PURE__*/React.createElement(_Col, {
81
+ span: !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'vertical' && 24,
82
+ flex: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) * 100 / 24, "%") : ''
83
+ }, /*#__PURE__*/React.createElement("div", {
84
+ className: "ant-form-item-label",
85
+ style: {
86
+ width: '100%',
87
+ textAlign: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? 'right' : 'left'),
88
+ flex: '1'
89
+ }
90
+ }, /*#__PURE__*/React.createElement("label", {
91
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
92
+ }, tr('数据源')))), /*#__PURE__*/React.createElement(_Col, {
93
+ flex: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.layout) === 'horizontal' ? "0 0 ".concat((24 - (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.labelSpan)) * 100 / 24, "%") : 1,
94
+ style: {
95
+ paddingBottom: '8px'
96
+ }
97
+ }, /*#__PURE__*/React.createElement(_Input.Group, {
98
+ compact: true
99
+ }, /*#__PURE__*/React.createElement(_Select, {
100
+ id: 'datasourceType',
101
+ style: {
102
+ width: '30%'
103
+ },
104
+ options: datasourceTypeOpts,
105
+ onChange: onDatasourceTypeChange
106
+ }), /*#__PURE__*/React.createElement(_Select, {
107
+ id: 'datasource',
108
+ style: {
109
+ width: 'calc(70% - 32px)'
110
+ },
111
+ options: datasourceOpts,
112
+ onChange: onDatasourceChange
113
+ }), /*#__PURE__*/React.createElement(_Tooltip, {
114
+ title: tr('测试链接'),
115
+ style: {
116
+ width: '32px'
117
+ }
118
+ }, /*#__PURE__*/React.createElement(_Button, {
119
+ icon: /*#__PURE__*/React.createElement(LinkOutlined, null)
120
+ })))), dsType === 'Kafka' && /*#__PURE__*/React.createElement(KafkaDatasource, {
121
+ extraInfo: extraInfo,
122
+ datasource: datasource,
123
+ onChange: onKafkaChange
124
+ }), dsType === 'PgSql' && /*#__PURE__*/React.createElement(PostgreSQLDatasource, {
125
+ extraInfo: extraInfo
126
+ }))));
127
+ };
128
+ export default DataSource;
@@ -34,14 +34,10 @@ var MapTable = function MapTable(props) {
34
34
  _React$useState10 = _slicedToArray(_React$useState9, 2),
35
35
  output = _React$useState10[0],
36
36
  setOutput = _React$useState10[1];
37
- var _React$useState11 = React.useState(false),
37
+ var _React$useState11 = React.useState(),
38
38
  _React$useState12 = _slicedToArray(_React$useState11, 2),
39
- isDataCome = _React$useState12[0],
40
- setIsDataCome = _React$useState12[1];
41
- var _React$useState13 = React.useState(),
42
- _React$useState14 = _slicedToArray(_React$useState13, 2),
43
- disableArray = _React$useState14[0],
44
- setDisableArray = _React$useState14[1];
39
+ disableArray = _React$useState12[0],
40
+ setDisableArray = _React$useState12[1];
45
41
  var sourceEditableStreamRef = React.useRef();
46
42
  var targetEditableStreamRef = React.useRef();
47
43
  var _React$useContext = React.useContext(MetadataFormContext),
@@ -110,17 +106,14 @@ var MapTable = function MapTable(props) {
110
106
  }
111
107
  }, [disableArray]);
112
108
  React.useEffect(function () {
113
- if (!isDataCome) {
114
- var values = form.getFieldsValue().mapTable;
115
- values.dataSource && setTableDataSource(values.dataSource);
116
- values.dataTarget && setTableDataTarget(values.dataTarget);
117
- values.options && setOptions(values.options);
118
- if (!disableArray && values.dataSource && values.dataTarget) {
119
- var _values$dataSource, _values$dataTarget;
120
- var valueArray = new Array(Math.min((_values$dataSource = values.dataSource) === null || _values$dataSource === void 0 ? void 0 : _values$dataSource.length, (_values$dataTarget = values.dataTarget) === null || _values$dataTarget === void 0 ? void 0 : _values$dataTarget.length)).fill(true);
121
- setDisableArray(valueArray);
122
- }
123
- setIsDataCome(true);
109
+ var values = form.getFieldsValue().mapTable;
110
+ values.dataSource && setTableDataSource(values.dataSource);
111
+ values.dataTarget && setTableDataTarget(values.dataTarget);
112
+ values.options && setOptions(values.options);
113
+ if (!disableArray && values.dataSource && values.dataTarget) {
114
+ var _values$dataSource, _values$dataTarget;
115
+ var valueArray = new Array(Math.min((_values$dataSource = values.dataSource) === null || _values$dataSource === void 0 ? void 0 : _values$dataSource.length, (_values$dataTarget = values.dataTarget) === null || _values$dataTarget === void 0 ? void 0 : _values$dataTarget.length)).fill(true);
116
+ setDisableArray(valueArray);
124
117
  }
125
118
  }, [form.getFieldsValue()]);
126
119
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  /*
6
6
  * @Author: wangxian
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2023-11-27 11:19:01
8
+ * @LastEditTime: 2024-08-20 18:59:44
9
9
  */
10
10
  import React from 'react';
11
11
  import { deepClone } from '../../../utils';
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: your name
6
6
  * @Date: 2021-09-18 14:15:04
7
- * @LastEditTime: 2023-11-27 13:58:40
7
+ * @LastEditTime: 2024-08-20 19:38:44
8
8
  */
9
9
  import { getLocale } from '../../../framework/locale';
10
10
  import moment from 'moment';
@@ -99,6 +99,9 @@ export var useWatchDepend = function useWatchDepend(_depends, stream$, name) {
99
99
  };
100
100
  var processDependHiddenOrShow = function processDependHiddenOrShow(depend, changeData, stream$, name) {
101
101
  try {
102
+ // if (depend === 'datasource.dsType =="Kafka"') {
103
+ // debugger;
104
+ // }
102
105
  // const regex = /\w+(\.\w+)?[=<>!]{1}/g;
103
106
  var regex = /\w+(\.\w+)?[=<>!]{1}|\w+(\.\w+)?(\.indexOf\('.+'\)[=<>!]{1})/g;
104
107
  var keys = depend.trim().replace(/\s/g, '').match(regex);
@@ -127,6 +130,8 @@ var processDependHiddenOrShow = function processDependHiddenOrShow(depend, chang
127
130
  }
128
131
  if (_changeData || _changeData === 0) {
129
132
  var r = key === _key[0] ? "'".concat(_changeData, "'") : eval("_changeData.".concat(_key[1]));
133
+ // 判断 r 是否是字符串
134
+ r = typeof r === 'string' ? "\"".concat(r, "\"") : r;
130
135
  expression = expression.replace(key, r);
131
136
  } else {
132
137
  expression = expression.replace(key, undefined);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.3.73",
4
+ "version": "1.3.74",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",