ronds-metadata 1.3.19 → 1.3.21

Sign up to get free protection for your applications and to get access to all the features.
package/es/api/index.js CHANGED
@@ -5,7 +5,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  /*
6
6
  * @Author:wangxian
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2023-09-25 17:13:26
8
+ * @LastEditTime: 2023-11-21 18:51:09
9
9
  */
10
10
  import { guid, md5 } from '../utils';
11
11
  import { addInterceptor, HttpHelper } from '../framework/http';
@@ -261,7 +261,7 @@ var Api = /*#__PURE__*/function () {
261
261
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
262
262
  while (1) switch (_context8.prev = _context8.next) {
263
263
  case 0:
264
- url = '/wx/dataset-web/source/kafka/queue:Kafka:通信平台-kafka:MQTT.TimeScaleData/message/byte';
264
+ url = '/wx/dataset-web/source/kafka/queue:Kafka:24-kafka:raw.TraitData/message/byte';
265
265
  _context8.next = 3;
266
266
  return http.post(encodeURI(url), {}, {}, {
267
267
  responseType: 'arraybuffer',
@@ -8,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
8
  /*
9
9
  * @Author: wangxian
10
10
  * @Date: 2023-02-06 08:24:17
11
- * @LastEditTime: 2023-07-07 16:01:20
11
+ * @LastEditTime: 2023-10-12 10:50:46
12
12
  */
13
13
  import React from 'react';
14
14
  import copy from 'copy-to-clipboard';
@@ -67,6 +67,11 @@ var Canvas = function Canvas() {
67
67
  type: streamEventType.onClearCanvas
68
68
  });
69
69
  };
70
+ var onImportSchema = function onImportSchema() {
71
+ fGCtx.fgStream && fGCtx.fgStream.next({
72
+ type: streamEventType.onImportSchema
73
+ });
74
+ };
70
75
  var onPreview = function onPreview() {
71
76
  if (schema.length === 0) {
72
77
  var _schema = transFG2Schema(nodesRef.current, settingRef.current, typesRef.current);
@@ -96,6 +101,9 @@ var Canvas = function Canvas() {
96
101
  },
97
102
  onClick: onClearCanvas
98
103
  }, "\u6E05\u7A7A"), /*#__PURE__*/React.createElement(_Button, {
104
+ style: {
105
+ marginRight: '8px'
106
+ },
99
107
  type: "primary",
100
108
  onClick: function onClick() {
101
109
  var _schema = transFG2Schema(nodesRef.current, settingRef.current, typesRef.current);
@@ -103,7 +111,12 @@ var Canvas = function Canvas() {
103
111
  _message.success("\u5DF2\u590D\u5236\u5230\u526A\u5207\u677F");
104
112
  }
105
113
  }
106
- }, "\u5BFC\u51FASchema")), schema.length > 0 && /*#__PURE__*/React.createElement(Preview, {
114
+ }, "\u5BFC\u51FASchema"), /*#__PURE__*/React.createElement(_Button, {
115
+ style: {
116
+ marginRight: '8px'
117
+ },
118
+ onClick: onImportSchema
119
+ }, "\u5BFC\u5165")), schema.length > 0 && /*#__PURE__*/React.createElement(Preview, {
107
120
  schema: schema
108
121
  }), /*#__PURE__*/React.createElement("div", {
109
122
  style: {
@@ -4,6 +4,7 @@ interface IFormGeneratorProps {
4
4
  * 初始化默认渲染的schema(首次加载渲染)
5
5
  */
6
6
  defaultSchema?: any;
7
+ onImportSchema?: () => void;
7
8
  }
8
9
  declare const FormGenerator: (props: IFormGeneratorProps) => JSX.Element;
9
10
  export default FormGenerator;
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  /*
4
4
  * @Author: wangxian
5
5
  * @Date: 2023-02-04 13:45:31
6
- * @LastEditTime: 2023-04-21 09:02:38
6
+ * @LastEditTime: 2023-10-12 10:48:31
7
7
  */
8
8
  import React from 'react';
9
9
  import { DndProvider } from 'react-dnd';
@@ -19,7 +19,8 @@ import useObservable from '../../framework/rxjs-hooks/useObservable';
19
19
  import { streamEventType } from './settings';
20
20
  import { transSchema2FG } from './transformer';
21
21
  var FormGenerator = function FormGenerator(props) {
22
- var defaultSchema = props.defaultSchema;
22
+ var defaultSchema = props.defaultSchema,
23
+ onImportSchema = props.onImportSchema;
23
24
  var FGStream = useMemoSubject();
24
25
  var _React$useState = React.useState({}),
25
26
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -43,6 +44,9 @@ var FormGenerator = function FormGenerator(props) {
43
44
  setTypes(_objectSpread({}, typesRef.current));
44
45
  }
45
46
  break;
47
+ case streamEventType.onImportSchema:
48
+ onImportSchema && onImportSchema();
49
+ break;
46
50
  }
47
51
  }, []);
48
52
  useObservable(function (p) {
@@ -2384,4 +2384,5 @@ export declare const streamEventType: {
2384
2384
  onDropOver: string;
2385
2385
  onDefaultValue: string;
2386
2386
  onJsonSchema: string;
2387
+ onImportSchema: string;
2387
2388
  };
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  /*
3
3
  * @Author: wangxian
4
4
  * @Date: 2023-02-06 08:24:17
5
- * @LastEditTime: 2023-06-30 16:21:01
5
+ * @LastEditTime: 2023-10-12 10:48:05
6
6
  */
7
7
  import { RefRule, Rule } from './ruleConfig';
8
8
  export var inputSchema = [{
@@ -395,5 +395,6 @@ export var streamEventType = {
395
395
  onTypesChange: 'onTypesChange',
396
396
  onDropOver: 'onDropOver',
397
397
  onDefaultValue: 'onDefaultValue',
398
- onJsonSchema: 'onJsonSchema'
398
+ onJsonSchema: 'onJsonSchema',
399
+ onImportSchema: 'onImportSchema'
399
400
  };
@@ -16,7 +16,7 @@ import _Input from "antd/es/input";
16
16
  /*
17
17
  * @Author: wangxian
18
18
  * @Date: 2021-09-18 14:15:04
19
- * @LastEditTime: 2023-08-14 19:17:56
19
+ * @LastEditTime: 2023-10-18 15:23:06
20
20
  */
21
21
  import React from 'react';
22
22
  import { UploadOutlined } from '@ant-design/icons';
@@ -156,7 +156,8 @@ function Index(props) {
156
156
  return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
157
157
  style: {
158
158
  flex: 1,
159
- paddingRight: '10px'
159
+ paddingRight: '10px',
160
+ display: "".concat(extraInfo.hidden ? 'none' : '')
160
161
  },
161
162
  label: /*#__PURE__*/React.createElement("span", {
162
163
  style: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color) ? {
@@ -216,7 +217,8 @@ function Index(props) {
216
217
  }, processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || '')) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
217
218
  style: {
218
219
  flex: 1,
219
- paddingRight: '10px'
220
+ paddingRight: '10px',
221
+ display: "".concat(extraInfo.hidden ? 'none' : '')
220
222
  },
221
223
  name: [field === null || field === void 0 ? void 0 : field.name],
222
224
  rules: [{
@@ -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-06-05 18:47:31
7
+ * @LastEditTime: 2023-11-01 15:56:30
8
8
  */
9
9
  import { getLocale } from '../../../framework/locale';
10
10
  import moment from 'moment';
@@ -61,7 +61,7 @@ export var useWatchDepend = function useWatchDepend(_depends, stream$, name) {
61
61
  if ((p === null || p === void 0 ? void 0 : p.type) === STREAM_EVENT_TYPE.ON_VALUES_CHANGE) {
62
62
  if (_depends === null || _depends === void 0 ? void 0 : _depends.hidden) {
63
63
  var _p$payload;
64
- var _hidden = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.hidden, p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.allVals, stream$, name);
64
+ var _hidden = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.hidden, p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.val, stream$, name);
65
65
  var _dr = dependsRef.current;
66
66
  _dr.hidden = _hidden;
67
67
  setDepends(_objectSpread({}, _dr));
@@ -69,7 +69,7 @@ export var useWatchDepend = function useWatchDepend(_depends, stream$, name) {
69
69
  }
70
70
  if (_depends === null || _depends === void 0 ? void 0 : _depends.show) {
71
71
  var _p$payload2;
72
- var _show = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.show, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.allVals, stream$, name);
72
+ var _show = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.show, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.val, stream$, name);
73
73
  var _dr2 = dependsRef.current;
74
74
  _dr2.show = _show;
75
75
  setDepends(_objectSpread({}, _dr2));
@@ -77,7 +77,7 @@ export var useWatchDepend = function useWatchDepend(_depends, stream$, name) {
77
77
  }
78
78
  if (_depends === null || _depends === void 0 ? void 0 : _depends.notRequire) {
79
79
  var _p$payload3;
80
- var _notRequire = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.notRequire, p === null || p === void 0 ? void 0 : (_p$payload3 = p.payload) === null || _p$payload3 === void 0 ? void 0 : _p$payload3.allVals, stream$, name);
80
+ var _notRequire = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.notRequire, p === null || p === void 0 ? void 0 : (_p$payload3 = p.payload) === null || _p$payload3 === void 0 ? void 0 : _p$payload3.val, stream$, name);
81
81
  var _dr3 = dependsRef.current;
82
82
  _dr3.notRequire = _notRequire;
83
83
  setDepends(_objectSpread({}, _dr3));
@@ -85,7 +85,7 @@ export var useWatchDepend = function useWatchDepend(_depends, stream$, name) {
85
85
  }
86
86
  if (_depends === null || _depends === void 0 ? void 0 : _depends.disabled) {
87
87
  var _p$payload4;
88
- var _disabled = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.disabled, p === null || p === void 0 ? void 0 : (_p$payload4 = p.payload) === null || _p$payload4 === void 0 ? void 0 : _p$payload4.allVals, stream$, name);
88
+ var _disabled = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.disabled, p === null || p === void 0 ? void 0 : (_p$payload4 = p.payload) === null || _p$payload4 === void 0 ? void 0 : _p$payload4.val, stream$, name);
89
89
  var _dr4 = dependsRef.current;
90
90
  _dr4.disabled = _disabled;
91
91
  setDepends(_objectSpread({}, _dr4));
@@ -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 === "choose.indexOf('1')>-1") {
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);
@@ -114,7 +117,17 @@ var processDependHiddenOrShow = function processDependHiddenOrShow(depend, chang
114
117
  for (var _i = 0; _i < name.length; _i++) {
115
118
  evalString = "".concat(evalString, "[name[").concat(_i, "]]");
116
119
  }
117
- var _changeData = eval("".concat(evalString, "['").concat(_key[0], "']"));
120
+ var _d = eval("".concat(evalString));
121
+ var _changeData = undefined;
122
+ // 判断_d 是否为数组
123
+ if (Array.isArray(_d)) {
124
+ var _ = _d.filter(function (v) {
125
+ return !!v;
126
+ });
127
+ _changeData = eval("_[0]['".concat(_key[0], "']"));
128
+ } else {
129
+ _changeData = eval("".concat(evalString, "['").concat(_key[0], "']"));
130
+ }
118
131
  if (_changeData || _changeData === 0) {
119
132
  var r = key === _key[0] ? "'".concat(_changeData, "'") : eval("_changeData.".concat(_key[1]));
120
133
  expression = expression.replace(key, r);
@@ -1,7 +1,3 @@
1
- declare const protobuf: any;
2
- declare const data: {
3
- name: string;
4
- age: number;
5
- sexEnum: number;
1
+ export declare function transProtobuf2Json(base64: string, protoSchema: string, message: string): {
2
+ [k: string]: any;
6
3
  };
7
- declare function setMessage(data: any): void;
@@ -1,27 +1,32 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2023-09-22 11:28:45
4
- * @LastEditTime: 2023-09-22 13:55:58
4
+ * @LastEditTime: 2023-11-23 15:25:42
5
5
  */
6
- var protobuf = require('protobufjs');
7
- var data = {
8
- name: '狍狍',
9
- age: 1,
10
- sexEnum: 1
11
- };
12
- function setMessage(data) {
13
- protobuf.load('./transfer.proto').then(function (root) {
14
- // 根据proto文件中的内容对message进行实例化
15
- var transferMessage = root.lookupType('transferData.transferMessage');
16
- // 验证
17
- var errMsg = transferMessage.verify(data);
18
- if (errMsg) {
19
- throw new Error(errMsg);
20
- }
21
- // 转换为message实例
22
- var messageFromObj = transferMessage.fromObject(data);
23
- // 编码
24
- var buffer = transferMessage.encode(messageFromObj).finish();
25
- }).catch(function () {});
6
+ import protobuf from 'protobufjs';
7
+ function transBase642byte(base64String) {
8
+ // 解码 Base64 字符串为原始二进制数据
9
+ var decodedData = window.atob(base64String);
10
+ // 将解码后的字符串转换为 Uint8Array
11
+ var uint8Array = new Uint8Array(decodedData.length);
12
+ for (var i = 0; i < decodedData.length; ++i) {
13
+ uint8Array[i] = decodedData.charCodeAt(i);
14
+ }
15
+ return uint8Array;
26
16
  }
27
- setMessage(data);
17
+ export function transProtobuf2Json(base64, protoSchema, message) {
18
+ var root = protobuf.parse(protoSchema, {
19
+ keepCase: true
20
+ }).root;
21
+ // 根据proto文件中的内容对message进行实例化
22
+ var transferMessage = root.lookupType(message);
23
+ var uint8Array = transBase642byte(base64);
24
+ try {
25
+ // 解码消息
26
+ var result = transferMessage.decode(uint8Array);
27
+ return transferMessage.toObject(result);
28
+ } catch (err) {
29
+ console.error('解码失败:', err);
30
+ return null;
31
+ }
32
+ }
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2023-09-15 11:32:01
4
+ * @LastEditTime: 2023-11-23 15:45:56
5
5
  */
6
6
  import './theme.less';
7
7
  export { default as MetadataEdit } from './comps/MetadataEdit';
@@ -30,4 +30,5 @@ export { default as useSyncScroll, useSyncScrollByRefs } from './framework/hooks
30
30
  export { registerMetadataAPI } from './framework/metadata/MetadataService';
31
31
  export { FormRobot } from './framework/fg/index';
32
32
  export { globalSettingStream } from './config';
33
- export { handleMd2Doc } from './utils';
33
+ export { handleMd2Doc } from './utils';
34
+ // export { transProtobuf2Json } from './framework/proto/index';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.3.19",
4
+ "version": "1.3.21",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -1,12 +0,0 @@
1
- syntax = "proto2"
2
- package transferData;
3
-
4
- message transferMessage {
5
- required string name = 1;
6
- required int32 age = 2;
7
- enum SexEnum {
8
- Boy = 0;
9
- Girl = 1;
10
- }
11
- optional SexEnum SexEnum = 3;
12
- }