ronds-metadata 1.3.18 → 1.3.20

Sign up to get free protection for your applications and to get access to all the features.
package/es/api/index.d.ts CHANGED
@@ -25,4 +25,5 @@ export default class Api implements IAPI {
25
25
  StopGraphRun(data: any): Promise<{
26
26
  success: boolean;
27
27
  }>;
28
+ getKafkaInfo(): Promise<any>;
28
29
  }
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-08-30 09:08:24
8
+ * @LastEditTime: 2023-09-25 17:13:26
9
9
  */
10
10
  import { guid, md5 } from '../utils';
11
11
  import { addInterceptor, HttpHelper } from '../framework/http';
@@ -252,6 +252,36 @@ var Api = /*#__PURE__*/function () {
252
252
  return _StopGraphRun.apply(this, arguments);
253
253
  }
254
254
  return StopGraphRun;
255
+ }() // 通过扩展规则获取枚举类型的值
256
+ }, {
257
+ key: "getKafkaInfo",
258
+ value: function () {
259
+ var _getKafkaInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
260
+ var url, res;
261
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
262
+ while (1) switch (_context8.prev = _context8.next) {
263
+ case 0:
264
+ url = '/wx/dataset-web/source/kafka/queue:Kafka:通信平台-kafka:MQTT.TimeScaleData/message/byte';
265
+ _context8.next = 3;
266
+ return http.post(encodeURI(url), {}, {}, {
267
+ responseType: 'arraybuffer',
268
+ headers: {
269
+ 'Content-Type': 'application/protobuf'
270
+ }
271
+ });
272
+ case 3:
273
+ res = _context8.sent;
274
+ return _context8.abrupt("return", res.successed ? res.data : []);
275
+ case 5:
276
+ case "end":
277
+ return _context8.stop();
278
+ }
279
+ }, _callee8);
280
+ }));
281
+ function getKafkaInfo() {
282
+ return _getKafkaInfo.apply(this, arguments);
283
+ }
284
+ return getKafkaInfo;
255
285
  }()
256
286
  }]);
257
287
  return Api;
@@ -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
  };
@@ -0,0 +1,7 @@
1
+ declare const protobuf: any;
2
+ declare const data: {
3
+ name: string;
4
+ age: number;
5
+ sexEnum: number;
6
+ };
7
+ declare function setMessage(data: any): void;
@@ -0,0 +1,27 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2023-09-22 11:28:45
4
+ * @LastEditTime: 2023-09-22 13:55:58
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 () {});
26
+ }
27
+ setMessage(data);
@@ -0,0 +1,12 @@
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
+ }
package/es/utils.js CHANGED
@@ -6,7 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2021-09-18 14:15:04
9
- * @LastEditTime: 2023-09-14 16:28:26
9
+ * @LastEditTime: 2023-09-27 08:03:46
10
10
  */
11
11
  import saveAs from 'file-saver';
12
12
  import { asBlob } from 'html-docx-js-typescript';
@@ -192,7 +192,6 @@ function _handleMd2Doc() {
192
192
  // 修改图片路径;
193
193
  token.attrs[token.attrIndex('src')][1] = "".concat(window.location.origin, "/").concat(src);
194
194
  }
195
- token.attrs[token.attrIndex('src')][1] = 'https://images.app.goo.gl/fxbwKFuGSmgXPZ6a8';
196
195
  var width = '620'; // 自定义宽度
197
196
  var height = 'auto'; // 自适应高度
198
197
  // 添加自定义宽高属性
@@ -272,4 +271,16 @@ function convertImagePathToBase64(imagePath) {
272
271
  };
273
272
  img.src = imagePath;
274
273
  });
274
+ function transBase642byte(base64String) {
275
+ // 解码 Base64 字符串为原始二进制数据
276
+ var decodedData = window.atob(base64String);
277
+ // 将解码后的字符串转换为 Uint8Array
278
+ var uint8Array = new Uint8Array(decodedData.length);
279
+ for (var i = 0; i < decodedData.length; ++i) {
280
+ uint8Array[i] = decodedData.charCodeAt(i);
281
+ }
282
+ // 打印解码结果
283
+
284
+ return uint8Array;
285
+ }
275
286
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.3.18",
4
+ "version": "1.3.20",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -65,6 +65,7 @@
65
65
  "markdown-it": "^13.0.1",
66
66
  "markdown-navbar": "^1.4.3",
67
67
  "monaco-editor": "^0.41.0",
68
+ "protobufjs": "^7.2.5",
68
69
  "qs": "^6.10.1",
69
70
  "react": "^17.0.2",
70
71
  "react-contenteditable": "^3.3.7",
@@ -111,4 +112,4 @@
111
112
  "webpack-cli": "^3.3.12",
112
113
  "yorkie": "^2.0.0"
113
114
  }
114
- }
115
+ }