@cloudbase/cals 1.0.2 → 1.0.3-alpha.1

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 (104) hide show
  1. package/lib/parser/cals/index.d.ts +0 -0
  2. package/lib/parser/cals/index.d.ts.map +0 -0
  3. package/lib/parser/cals/index.js +0 -0
  4. package/lib/parser/cals/utils/block/index.d.ts +0 -0
  5. package/lib/parser/cals/utils/block/index.d.ts.map +0 -0
  6. package/lib/parser/cals/utils/block/index.js +0 -0
  7. package/lib/parser/cals/utils/code/index.d.ts +0 -0
  8. package/lib/parser/cals/utils/code/index.d.ts.map +0 -0
  9. package/lib/parser/cals/utils/code/index.js +0 -0
  10. package/lib/parser/cals/utils/common.d.ts +0 -0
  11. package/lib/parser/cals/utils/common.d.ts.map +0 -0
  12. package/lib/parser/cals/utils/common.js +0 -0
  13. package/lib/parser/cals/utils/runtime.d.ts +0 -0
  14. package/lib/parser/cals/utils/runtime.d.ts.map +0 -0
  15. package/lib/parser/cals/utils/runtime.js +0 -0
  16. package/lib/parser/cals/utils/spinoff/index.d.ts +0 -0
  17. package/lib/parser/cals/utils/spinoff/index.d.ts.map +0 -0
  18. package/lib/parser/cals/utils/spinoff/index.js +0 -0
  19. package/lib/parser/cals/utils/style.d.ts +0 -0
  20. package/lib/parser/cals/utils/style.d.ts.map +0 -0
  21. package/lib/parser/cals/utils/style.js +0 -0
  22. package/lib/parser/cals/utils/template.d.ts +0 -0
  23. package/lib/parser/cals/utils/template.d.ts.map +0 -0
  24. package/lib/parser/cals/utils/template.js +0 -0
  25. package/lib/parser/cals/utils/version/common.d.ts +0 -0
  26. package/lib/parser/cals/utils/version/common.d.ts.map +0 -0
  27. package/lib/parser/cals/utils/version/common.js +0 -0
  28. package/lib/parser/cals/utils/version/config.d.ts +0 -0
  29. package/lib/parser/cals/utils/version/config.d.ts.map +0 -0
  30. package/lib/parser/cals/utils/version/config.js +0 -0
  31. package/lib/parser/cals/utils/version/index.d.ts +0 -0
  32. package/lib/parser/cals/utils/version/index.d.ts.map +0 -0
  33. package/lib/parser/cals/utils/version/index.js +0 -0
  34. package/lib/parser/cals/utils/version/parses.d.ts +0 -0
  35. package/lib/parser/cals/utils/version/parses.d.ts.map +0 -0
  36. package/lib/parser/cals/utils/version/parses.js +0 -0
  37. package/lib/parser/cals/utils/version/utils.d.ts +0 -0
  38. package/lib/parser/cals/utils/version/utils.d.ts.map +0 -0
  39. package/lib/parser/cals/utils/version/utils.js +0 -0
  40. package/lib/parser/expression/index.d.ts +0 -0
  41. package/lib/parser/expression/index.d.ts.map +0 -0
  42. package/lib/parser/expression/index.js +0 -0
  43. package/lib/parser/index.d.ts +0 -0
  44. package/lib/parser/index.d.ts.map +0 -0
  45. package/lib/parser/index.js +0 -0
  46. package/lib/types/basic/app.d.ts +0 -0
  47. package/lib/types/basic/app.d.ts.map +0 -0
  48. package/lib/types/basic/app.js +0 -0
  49. package/lib/types/basic/common.d.ts +1 -0
  50. package/lib/types/basic/common.d.ts.map +1 -1
  51. package/lib/types/basic/common.js +0 -0
  52. package/lib/types/basic/component.d.ts +0 -0
  53. package/lib/types/basic/component.d.ts.map +0 -0
  54. package/lib/types/basic/component.js +0 -0
  55. package/lib/types/basic/datasource.d.ts +0 -0
  56. package/lib/types/basic/datasource.d.ts.map +0 -0
  57. package/lib/types/basic/datasource.js +0 -0
  58. package/lib/types/index.d.ts +0 -0
  59. package/lib/types/index.d.ts.map +0 -0
  60. package/lib/types/index.js +0 -0
  61. package/lib/types/lcds.d.ts +32 -0
  62. package/lib/types/lcds.d.ts.map +1 -1
  63. package/lib/types/lcds.js +0 -0
  64. package/lib/types/platform/app.d.ts +0 -0
  65. package/lib/types/platform/app.d.ts.map +0 -0
  66. package/lib/types/platform/app.js +0 -0
  67. package/lib/types/platform/common.d.ts +0 -0
  68. package/lib/types/platform/common.d.ts.map +0 -0
  69. package/lib/types/platform/common.js +0 -0
  70. package/lib/types/platform/component.d.ts +0 -0
  71. package/lib/types/platform/component.d.ts.map +0 -0
  72. package/lib/types/platform/component.js +0 -0
  73. package/lib/types/platform/datasource.d.ts +0 -0
  74. package/lib/types/platform/datasource.d.ts.map +0 -0
  75. package/lib/types/platform/datasource.js +0 -0
  76. package/lib/types/platform/widget/form.d.ts +0 -0
  77. package/lib/types/platform/widget/form.d.ts.map +0 -0
  78. package/lib/types/platform/widget/form.js +0 -0
  79. package/lib/types/platform/widget/meta.d.ts +0 -0
  80. package/lib/types/platform/widget/meta.d.ts.map +0 -0
  81. package/lib/types/platform/widget/meta.js +0 -0
  82. package/lib/utils/CSSProperty.d.ts +0 -0
  83. package/lib/utils/CSSProperty.d.ts.map +0 -0
  84. package/lib/utils/CSSProperty.js +0 -0
  85. package/lib/utils/build.d.ts +0 -0
  86. package/lib/utils/build.d.ts.map +0 -0
  87. package/lib/utils/build.js +0 -0
  88. package/lib/utils/constant.d.ts +0 -0
  89. package/lib/utils/constant.d.ts.map +0 -0
  90. package/lib/utils/constant.js +0 -0
  91. package/lib/utils/dts/auto-generated.d.ts +1 -1
  92. package/lib/utils/dts/auto-generated.d.ts.map +1 -1
  93. package/lib/utils/dts/auto-generated.js +1107 -26
  94. package/lib/utils/dts/build.js +1 -4
  95. package/lib/utils/dts/index.d.ts +39 -2
  96. package/lib/utils/dts/index.d.ts.map +1 -1
  97. package/lib/utils/dts/index.js +288 -33
  98. package/lib/utils/index.d.ts +0 -0
  99. package/lib/utils/index.d.ts.map +0 -0
  100. package/lib/utils/index.js +0 -0
  101. package/package.json +2 -1
  102. package/lib/parser/constants.d.ts +0 -2
  103. package/lib/parser/constants.d.ts.map +0 -1
  104. package/lib/parser/constants.js +0 -4
@@ -42,10 +42,7 @@ function buildFormulaDTS() {
42
42
  const dts = yield fs_extra_1.default.readFile(tempDtsPath, 'utf8');
43
43
  yield fs_extra_1.default.remove(tempDtsPath);
44
44
  // 去掉最外层的模块声明
45
- return dts
46
- .replace(/^declare module.*$/m, '')
47
- .replace(/^\}$/m, '')
48
- .replace(/^\s+/gm, '');
45
+ return dts.replace(/^declare module.*$/m, '').replace(/^\}$/m, '').replace(/^\s+/mg, '');
49
46
  });
50
47
  }
51
48
  });
@@ -1,4 +1,22 @@
1
1
  import { IJsonSchemaAny, IJsonSchemaObject } from '../../types';
2
+ export interface IPrivateForWeDa {
3
+ displayType: string;
4
+ displayName: string;
5
+ dataFieldInfo?: {
6
+ type?: string;
7
+ format?: string;
8
+ 'x-system': boolean;
9
+ };
10
+ insertText: string;
11
+ group?: string;
12
+ subGroup?: string;
13
+ doc?: string;
14
+ description?: string;
15
+ definition?: string;
16
+ schema?: IJsonSchemaAny;
17
+ baseClass?: string;
18
+ datasource?: string;
19
+ }
2
20
  export interface IDTSCodeItem {
3
21
  name: string;
4
22
  code: string;
@@ -19,10 +37,27 @@ export interface IInputDataWidgetItem {
19
37
  idList: string[];
20
38
  }
21
39
  export interface IInputDataRepeaterItem {
40
+ widgetId: string;
22
41
  currentItemAlias: string;
23
42
  currentIndexAlias: string;
24
43
  itemData: IJsonSchemaAny;
25
44
  }
45
+ export interface IInputDataRedefineAnyType {
46
+ module: string;
47
+ component: string;
48
+ widgetId: string;
49
+ updateProps: {
50
+ widgetPropName: string;
51
+ widgetPropTitle: string;
52
+ widgetPropTypeSchema: IJsonSchemaAny;
53
+ datasource: {
54
+ id: string;
55
+ name: string;
56
+ title: string;
57
+ type: 'ds' | 'apis';
58
+ };
59
+ }[];
60
+ }
26
61
  export interface IOptions {
27
62
  isCompMode?: boolean;
28
63
  needGlobalFormula?: boolean;
@@ -42,7 +77,8 @@ export declare enum IInputDataType {
42
77
  compPropEvents = "compPropEvents",
43
78
  usedComponents = "usedComponents",
44
79
  usedWidgets = "usedWidgets",
45
- repeaterScope = "repeaterScope"
80
+ repeaterScope = "repeaterScope",
81
+ redefineAnyType = "redefineAnyType"
46
82
  }
47
83
  export interface IInputData {
48
84
  [IInputDataType.globalState]?: IJsonSchemaObject;
@@ -58,6 +94,7 @@ export interface IInputData {
58
94
  [IInputDataType.usedComponents]?: IInputDataUsedComponents[];
59
95
  [IInputDataType.usedWidgets]?: IInputDataWidgetItem[];
60
96
  [IInputDataType.repeaterScope]?: IInputDataRepeaterItem[];
97
+ [IInputDataType.redefineAnyType]?: IInputDataRedefineAnyType[];
61
98
  }
62
99
  /**
63
100
  * 通过该类可以共享同个dts。
@@ -72,7 +109,7 @@ export declare class WeDaDTS {
72
109
  /**
73
110
  * 部分更新 - 只更新一种类型
74
111
  */
75
- static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[], itemType: IInputDataType, options?: {
112
+ static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[] | IInputDataRedefineAnyType[], itemType: IInputDataType, options?: {
76
113
  setEmptyIfError: boolean;
77
114
  }): Promise<void>;
78
115
  static getDTS(options?: Omit<IOptions, "isCompMode">): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,iBAAiB,CAAA;IACpC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;QAAC,MAAM,CAAC,EAAE,cAAc,CAAA;KAAE,EAAE,CAAA;CACvF;AACD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAA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CAanI;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,GAAE,UAAe,EAAE,OAAO,GAAE,QAA0G,GAAG,OAAO,CAAC,MAAM,CAAC,CA2CzM;AAybD,eAAO,MAAM,UAAU,6yDA8DtB,CAAA;AAyDD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5D;AAID,eAAO,MAAM,mBAAmB,+tBAmB/B,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,KAAA,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5D"}
@@ -8,8 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.compileJSONToDTS = exports.jsonToDTSWorkerCode = exports.transpileToDTS = exports.workerCode = exports.generateWeDaAppDTS = exports.WeDaDTS = exports.IInputDataType = void 0;
16
+ const lodash_1 = require("lodash");
17
+ const json_easy_filter_1 = __importDefault(require("json-easy-filter"));
13
18
  const auto_generated_1 = require("./auto-generated");
14
19
  var IInputDataType;
15
20
  (function (IInputDataType) {
@@ -26,6 +31,7 @@ var IInputDataType;
26
31
  IInputDataType["usedComponents"] = "usedComponents";
27
32
  IInputDataType["usedWidgets"] = "usedWidgets";
28
33
  IInputDataType["repeaterScope"] = "repeaterScope";
34
+ IInputDataType["redefineAnyType"] = "redefineAnyType";
29
35
  })(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
30
36
  const DtsPlaceholder = {
31
37
  [IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
@@ -40,7 +46,8 @@ const DtsPlaceholder = {
40
46
  [IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
41
47
  [IInputDataType.usedComponents]: "// Used Components - Don't touch me",
42
48
  [IInputDataType.usedWidgets]: "// used widgets - Don't touch me",
43
- [IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
49
+ [IInputDataType.repeaterScope]: "// repeater scope - Don't touch me",
50
+ [IInputDataType.redefineAnyType]: "// Redefine Any Type - Don't touch me",
44
51
  };
45
52
  const DtsInnerSign = {
46
53
  [IInputDataType.globalState]: "Global State Inner",
@@ -55,8 +62,18 @@ const DtsInnerSign = {
55
62
  [IInputDataType.compPropEvents]: "Comp Prop Events Inner",
56
63
  [IInputDataType.usedComponents]: "Used Components Inner",
57
64
  [IInputDataType.usedWidgets]: "used widgets Inner",
58
- [IInputDataType.repeaterScope]: "repeater scope Inner"
65
+ [IInputDataType.repeaterScope]: "repeater scope Inner",
66
+ [IInputDataType.redefineAnyType]: "Redefine Any Type Inner",
59
67
  };
68
+ var GroupEnum;
69
+ (function (GroupEnum) {
70
+ GroupEnum["GLOBAL_VAR"] = "globalVar";
71
+ GroupEnum["PAGE_VAR"] = "pageVar";
72
+ GroupEnum["PAGE_PARAM"] = "pageParam";
73
+ GroupEnum["COMPONENT"] = "component";
74
+ GroupEnum["REPEATER"] = "repeater";
75
+ GroupEnum["DATA_FIELD"] = "dataField";
76
+ })(GroupEnum || (GroupEnum = {}));
60
77
  /**
61
78
  * 通过该类可以共享同个dts。
62
79
  * 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
@@ -75,14 +92,16 @@ class WeDaDTS {
75
92
  */
76
93
  static updateDTSPartial(inputData, itemType, options = { setEmptyIfError: false }) {
77
94
  return __awaiter(this, void 0, void 0, function* () {
78
- let dts = '';
79
95
  try {
80
- dts = yield _generateOneItemDTS(inputData, itemType);
96
+ const [dts, replaceRules] = yield _generateOneItemDTS(inputData, itemType);
97
+ replaceRules.forEach(rule => {
98
+ WeDaDTS._dts = WeDaDTS._dts.replace(rule.from, rule.to);
99
+ });
81
100
  WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
82
101
  }
83
102
  catch (e) {
84
103
  if (options.setEmptyIfError) {
85
- WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
104
+ WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${''}\n$2`);
86
105
  }
87
106
  }
88
107
  });
@@ -114,8 +133,11 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
114
133
  if (placeholder) {
115
134
  // 防止某项错误导致全部都错误
116
135
  try {
117
- const dts = yield _generateOneItemDTS(inputData[key], key);
118
- resultDts = resultDts.replace(placeholder, dts + placeholder);
136
+ const [dts, replaceRules] = yield _generateOneItemDTS(inputData[key], key);
137
+ replaceRules.forEach(rule => {
138
+ resultDts = resultDts.replace(rule.from, rule.to);
139
+ });
140
+ resultDts = resultDts.replace(placeholder, dts + '\n' + placeholder);
119
141
  }
120
142
  catch (e) {
121
143
  console.error(e);
@@ -141,17 +163,141 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
141
163
  if (!(options === null || options === void 0 ? void 0 : options.needRepeaterScope)) {
142
164
  resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
143
165
  }
144
- // console.log(resultDts)
145
166
  return resultDts;
146
167
  });
147
168
  }
148
169
  exports.generateWeDaAppDTS = generateWeDaAppDTS;
170
+ /**
171
+ * 生成 weda 专有的注释信息
172
+ */
173
+ function genWeDaCodeComment({ fieldName, title, description, type, dataFieldInfo, group, schema, subGroup, baseClass, datasource, }) {
174
+ const desc = (title || fieldName) ? `${title || fieldName}\n${description || ''}` : '';
175
+ return desc + `\n@privateForWeDa\n${JSON.stringify({ group, displayType: type, displayName: title || '', schema, subGroup, baseClass, datasource, dataFieldInfo })}`;
176
+ }
149
177
  /**
150
178
  * 生成指定类型的 DTS
151
179
  */
152
180
  function _generateOneItemDTS(inputData, itemType) {
153
181
  return __awaiter(this, void 0, void 0, function* () {
182
+ const replaceRules = [];
183
+ /**
184
+ * 获取数据字段的类型
185
+ */
186
+ function getDataFieldDisplayType(format) {
187
+ const nameMap = {
188
+ "email": "email",
189
+ "url": "url",
190
+ "tel": "tel",
191
+ "phone": "phone",
192
+ "x-image": "image",
193
+ "x-rtf": "rtf",
194
+ "datetime": "datetime",
195
+ "date": "date",
196
+ "time": "time",
197
+ "x-enum": "enum",
198
+ "x-location": "location",
199
+ "x-file": "file",
200
+ "related": "related",
201
+ "father-son": "father-son",
202
+ "x-autonumber": "autonumber",
203
+ "x-area-code": "area-code",
204
+ "function": "function"
205
+ };
206
+ return nameMap[format];
207
+ }
208
+ /**
209
+ * 处理注释信息
210
+ */
211
+ function _handleComment(inputData, group, needKeepSchema) {
212
+ const _inputData = (0, lodash_1.cloneDeep)(inputData);
213
+ json_easy_filter_1.default.traverse(_inputData, function (key, value, path) {
214
+ var _a;
215
+ if ((value === null || value === void 0 ? void 0 : value.type) && !((_a = value === null || value === void 0 ? void 0 : value.type) === null || _a === void 0 ? void 0 : _a.type)) {
216
+ // value?.type?.type 有值,则证明 type 是自定义的字段,而非 JSONSchema 中的 type
217
+ let schema = null;
218
+ if (needKeepSchema) {
219
+ const isFirstLevel = path.length === 2 && (path === null || path === void 0 ? void 0 : path[0]) === 'properties';
220
+ if (isFirstLevel) {
221
+ // 只需要第一级属性需要保存,且只保存子信息(对象或数组的子项)
222
+ schema = (value.properties || value.items) ? value : null;
223
+ }
224
+ }
225
+ // 特殊处理数据字段的类型
226
+ let type = value.type;
227
+ if (group === GroupEnum.DATA_FIELD) {
228
+ type = getDataFieldDisplayType(value.format) || type;
229
+ }
230
+ value.description = genWeDaCodeComment({
231
+ fieldName: key,
232
+ title: value.title,
233
+ description: value.description,
234
+ group,
235
+ type,
236
+ dataFieldInfo: (0, lodash_1.pick)(value, ['type', 'format', 'x-system']),
237
+ schema
238
+ });
239
+ }
240
+ });
241
+ _inputData.description = ''; // 避免第一层出现注释
242
+ return _inputData;
243
+ }
244
+ /**
245
+ * 获取用于显示的数据类型(仅有 number, string , boolean, array, object 等内置基础类型)
246
+ */
247
+ function getDisplayReturnType(typeStr) {
248
+ let displayType = typeStr.trim();
249
+ if (displayType.endsWith('[]')) {
250
+ displayType = 'array';
251
+ }
252
+ else if (displayType.endsWith('}')) {
253
+ displayType = 'object';
254
+ }
255
+ return displayType;
256
+ }
257
+ /**
258
+ * 获取组件接口定义名称
259
+ */
260
+ function _genCompInterfaceName(module, component) {
261
+ return `${module.replace(/-/g, '_')}_${component}`;
262
+ }
263
+ function _compile(jsonschema, isObjNeedWrapper = false) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ let dts = yield compileJSONToDTS(jsonschema);
266
+ if (dts.search(/^export interface IWeDa/) >= 0) {
267
+ dts = dts.replace(/^export interface.*$/m, '');
268
+ dts = dts.substring(0, dts.length - 2);
269
+ if (isObjNeedWrapper) {
270
+ dts = `{${dts}}`;
271
+ }
272
+ }
273
+ else {
274
+ dts = dts.replace(/^export type IWeDa =/m, '');
275
+ }
276
+ return dts;
277
+ });
278
+ }
154
279
  const hanlderMap = {
280
+ [IInputDataType.globalState]: function (inputData) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ // 完善注释信息
283
+ const handledInputData = _handleComment(inputData, GroupEnum.GLOBAL_VAR, true);
284
+ return yield _compile(handledInputData);
285
+ });
286
+ },
287
+ [IInputDataType.pageState]: function (inputData) {
288
+ return __awaiter(this, void 0, void 0, function* () {
289
+ // 完善注释信息
290
+ const handledInputData = _handleComment(inputData, GroupEnum.PAGE_VAR, true);
291
+ return yield _compile(handledInputData);
292
+ });
293
+ },
294
+ [IInputDataType.pageParams]: function (inputData) {
295
+ return __awaiter(this, void 0, void 0, function* () {
296
+ // 完善注释信息
297
+ const handledInputData = _handleComment(inputData, GroupEnum.PAGE_PARAM);
298
+ return yield _compile(handledInputData);
299
+ });
300
+ },
155
301
  [IInputDataType.globalCommonCodes]: function (inputData) {
156
302
  return __awaiter(this, void 0, void 0, function* () {
157
303
  const dts = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
@@ -205,7 +351,8 @@ function _generateOneItemDTS(inputData, itemType) {
205
351
  // 属性
206
352
  let exportPropertiesDTS = '';
207
353
  if (item.exportProperties) {
208
- exportPropertiesDTS = yield _compile(item.exportProperties);
354
+ const handledProperties = _handleComment(item.exportProperties);
355
+ exportPropertiesDTS = yield _compile(handledProperties);
209
356
  }
210
357
  // 方法
211
358
  let exportMethodsDTS = '';
@@ -238,8 +385,15 @@ function _generateOneItemDTS(inputData, itemType) {
238
385
  // ${exportMethodsDTS}
239
386
  // }
240
387
  // `
388
+ const interfaceName = _genCompInterfaceName(item.module, item.component);
241
389
  return `
242
- declare class ${_genCompInterfaceName(item.module, item.component)} extends UserWidget {
390
+ /**
391
+ ${genWeDaCodeComment({
392
+ fieldName: interfaceName,
393
+ schema: item.exportProperties,
394
+ }).split('\n').map(item => `* ${item}`).join('\n')}
395
+ */
396
+ declare class ${interfaceName} extends UserWidget {
243
397
 
244
398
  ${exportPropertiesDTS}
245
399
 
@@ -254,7 +408,19 @@ function _generateOneItemDTS(inputData, itemType) {
254
408
  return inputData.map(item => {
255
409
  if (item.idList && item.idList.length > 0) {
256
410
  const interfaceName = _genCompInterfaceName(item.module, item.component);
257
- return item.idList.map(id => `const ${id}: ${interfaceName}`).join('\n');
411
+ return item.idList.map(id => `
412
+ /**
413
+ ${genWeDaCodeComment({
414
+ fieldName: id,
415
+ title: '',
416
+ description: '',
417
+ group: GroupEnum.COMPONENT,
418
+ type: 'component',
419
+ baseClass: interfaceName,
420
+ datasource: `$${id}_start$ $${id}_end$`
421
+ }).split('\n').map(item => `* ${item}`).join('\n')}
422
+ */
423
+ const ${id}: ${interfaceName}`).join('\n');
258
424
  }
259
425
  return '';
260
426
  }).join('\n');
@@ -262,45 +428,134 @@ function _generateOneItemDTS(inputData, itemType) {
262
428
  [IInputDataType.repeaterScope]: function (inputData) {
263
429
  return __awaiter(this, void 0, void 0, function* () {
264
430
  const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
265
- let itemDataDTS = yield _compile(item.itemData, true);
431
+ let itemDataDTS = '';
432
+ if (item.itemData.title) {
433
+ // 特殊场景:数据字段
434
+ const handledInputData = _handleComment(item.itemData, GroupEnum.DATA_FIELD);
435
+ itemDataDTS = yield _compile(handledInputData, true);
436
+ }
437
+ else {
438
+ // 普通的循环项数据
439
+ itemDataDTS = yield _compile(item.itemData, true);
440
+ }
266
441
  return `
442
+ /**
443
+ ${genWeDaCodeComment({
444
+ fieldName: item.currentItemAlias,
445
+ title: '当前项值',
446
+ description: '',
447
+ group: GroupEnum.REPEATER,
448
+ type: getDisplayReturnType(itemDataDTS),
449
+ schema: item.itemData,
450
+ subGroup: item.widgetId
451
+ }).split('\n').map(item => `* ${item}`).join('\n')}
452
+ */
267
453
  const ${item.currentItemAlias}: ${itemDataDTS}
454
+ /**
455
+ ${genWeDaCodeComment({
456
+ fieldName: item.currentIndexAlias,
457
+ title: '当前下标',
458
+ description: '',
459
+ group: GroupEnum.REPEATER,
460
+ type: 'number',
461
+ subGroup: item.widgetId
462
+ }).split('\n').map(item => `* ${item}`).join('\n')}
463
+ */
268
464
  const ${item.currentIndexAlias}: number
269
465
  `;
270
466
  })));
271
467
  return results.join('\n');
272
468
  });
273
469
  },
470
+ [IInputDataType.redefineAnyType]: function (inputData) {
471
+ return __awaiter(this, void 0, void 0, function* () {
472
+ const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
473
+ const compInterfaceName = _genCompInterfaceName(item.module, item.component);
474
+ const widgetInterfaceName = `${item.widgetId}_${compInterfaceName}`;
475
+ /**
476
+ * 更新 widget 的类型名
477
+ */
478
+ replaceRules.push({
479
+ from: new RegExp(`(const ${item.widgetId}): .*`),
480
+ to: `$1: ${widgetInterfaceName}`
481
+ });
482
+ /**
483
+ * 增加类
484
+ */
485
+ const datasources = {};
486
+ const propDefinitions = yield Promise.all(item.updateProps.map((prop) => __awaiter(this, void 0, void 0, function* () {
487
+ const properties = _handleComment(prop.widgetPropTypeSchema, GroupEnum.DATA_FIELD);
488
+ const widgetPropTypeDTS = yield _compile(Object.assign(Object.assign({}, prop.widgetPropTypeSchema), properties), true);
489
+ // 同个数据源,有可能是数组类型,所以需要区分开
490
+ const id = `${prop.datasource.name}_${prop.widgetPropTypeSchema.type}`;
491
+ if (!datasources[id]) {
492
+ datasources[id] = {
493
+ fields: [{ name: prop.widgetPropName, title: prop.widgetPropTitle }],
494
+ schema: prop.widgetPropTypeSchema,
495
+ name: prop.datasource.name, title: prop.datasource.title, id: prop.datasource.id, type: prop.datasource.type
496
+ };
497
+ }
498
+ else {
499
+ datasources[id].fields.push({ name: prop.widgetPropName, title: prop.widgetPropTitle });
500
+ }
501
+ // 是否是多层级字段,如 "a.b"
502
+ // FIXME: 当前只支持 a.b 这种形式,不支持 a[].b
503
+ const multiLevelField = prop.widgetPropName.includes('.');
504
+ let multiLevelFields = [];
505
+ let multiLevelFieldObj = {};
506
+ let firstField = '';
507
+ let othersFields = [];
508
+ if (multiLevelField) {
509
+ multiLevelFields = prop.widgetPropName.split('.');
510
+ (0, lodash_1.set)(multiLevelFieldObj, prop.widgetPropName, "$$schema$$");
511
+ const [_firstField, ..._othersFields] = multiLevelFields;
512
+ firstField = _firstField;
513
+ othersFields = _othersFields;
514
+ }
515
+ return `
516
+ /**
517
+ ${genWeDaCodeComment({
518
+ fieldName: prop.widgetPropName,
519
+ title: prop.widgetPropTypeSchema.title,
520
+ description: prop.widgetPropTypeSchema.description,
521
+ group: undefined,
522
+ type: getDisplayReturnType(widgetPropTypeDTS)
523
+ }).split('\n').map(item => `* ${item}`).join('\n')}
524
+ */
525
+ ${multiLevelField ? `${firstField}: Omit<${compInterfaceName}['${firstField}'], '${othersFields.join(".")}'> & ${JSON.stringify(multiLevelFieldObj[firstField]).replace('"$$schema$$"', widgetPropTypeDTS)}` : `${prop.widgetPropName}: ${widgetPropTypeDTS}`}
526
+ `;
527
+ })));
528
+ /**
529
+ * 更新数据源信息
530
+ */
531
+ const datasourceInfoList = Object.values(datasources);
532
+ if (datasourceInfoList.length > 0) {
533
+ replaceRules.push({
534
+ from: new RegExp(`(\\$${item.widgetId}_start\\$).*(\\$${item.widgetId}_end\\$)`),
535
+ // encodeURIComponent 是为了能正常 parse 成 JSON
536
+ to: `$1${encodeURIComponent(JSON.stringify(datasourceInfoList))}$2`
537
+ });
538
+ }
539
+ return `
540
+ declare class ${widgetInterfaceName} extends ${compInterfaceName} {
541
+ ${propDefinitions.join('\n')}
542
+ }
543
+ `;
544
+ })));
545
+ return results.join('\n');
546
+ });
547
+ }
274
548
  };
275
549
  let dts = '';
276
550
  if (!inputData)
277
- return dts;
551
+ return [dts, replaceRules];
278
552
  const handler = hanlderMap[itemType];
279
553
  // 优先判断是否有独立的处理逻辑
280
554
  if (handler) {
281
555
  dts = yield handler.call(hanlderMap, inputData);
282
556
  }
283
557
  dts = dts || (yield _compile(inputData));
284
- return dts;
285
- function _genCompInterfaceName(module, component) {
286
- return `${module.replace(/-/g, '_')}_${component}`;
287
- }
288
- function _compile(jsonschema, isObjNeedWrapper = false) {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- let dts = yield compileJSONToDTS(jsonschema);
291
- if (dts.search(/^export interface IWeDa/) >= 0) {
292
- dts = dts.replace(/^export interface.*$/m, '');
293
- dts = dts.substring(0, dts.length - 2);
294
- if (isObjNeedWrapper) {
295
- dts = `{${dts}}`;
296
- }
297
- }
298
- else {
299
- dts = dts.replace(/^export type IWeDa =/m, '');
300
- }
301
- return dts;
302
- });
303
- }
558
+ return [dts, replaceRules];
304
559
  });
305
560
  }
306
561
  // 仅仅为了与 unittest 共享,外部请不要使用
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cals",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-alpha.1",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
6
  "source": "src/utils/index.ts",
@@ -30,6 +30,7 @@
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
32
  "acorn": "^8.0.4",
33
+ "json-easy-filter": "^0.3.1",
33
34
  "json-schema-to-typescript-for-browser": "^11.0.3",
34
35
  "lodash": "^4.17.20",
35
36
  "postcss": "^8.4.20",
@@ -1,2 +0,0 @@
1
- export declare const OFFICIAL_LIB_KEY = "gsd-h5-react";
2
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/parser/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,iBAAiB,CAAC"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OFFICIAL_LIB_KEY = void 0;
4
- exports.OFFICIAL_LIB_KEY = 'gsd-h5-react';