@cloudbase/cals 1.0.3-alpha.7 → 1.0.3-alpha.9

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 (110) hide show
  1. package/lib/parser/cals/index.d.ts +8 -0
  2. package/lib/parser/cals/index.d.ts.map +1 -1
  3. package/lib/parser/cals/index.js +63 -1
  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/constants.d.ts +2 -0
  41. package/lib/parser/constants.d.ts.map +1 -0
  42. package/lib/parser/constants.js +4 -0
  43. package/lib/parser/expression/index.d.ts +0 -0
  44. package/lib/parser/expression/index.d.ts.map +0 -0
  45. package/lib/parser/expression/index.js +0 -0
  46. package/lib/parser/index.d.ts +0 -0
  47. package/lib/parser/index.d.ts.map +0 -0
  48. package/lib/parser/index.js +0 -0
  49. package/lib/types/basic/app.d.ts +0 -0
  50. package/lib/types/basic/app.d.ts.map +0 -0
  51. package/lib/types/basic/app.js +0 -0
  52. package/lib/types/basic/common.d.ts +1 -1
  53. package/lib/types/basic/common.d.ts.map +1 -1
  54. package/lib/types/basic/common.js +0 -0
  55. package/lib/types/basic/component.d.ts +5 -0
  56. package/lib/types/basic/component.d.ts.map +1 -1
  57. package/lib/types/basic/component.js +0 -0
  58. package/lib/types/basic/datasource.d.ts +0 -0
  59. package/lib/types/basic/datasource.d.ts.map +0 -0
  60. package/lib/types/basic/datasource.js +0 -0
  61. package/lib/types/index.d.ts +1 -0
  62. package/lib/types/index.d.ts.map +1 -1
  63. package/lib/types/index.js +0 -0
  64. package/lib/types/lcds.d.ts +148 -11
  65. package/lib/types/lcds.d.ts.map +1 -1
  66. package/lib/types/lcds.js +0 -0
  67. package/lib/types/platform/app.d.ts +0 -0
  68. package/lib/types/platform/app.d.ts.map +0 -0
  69. package/lib/types/platform/app.js +0 -0
  70. package/lib/types/platform/common.d.ts +11 -1
  71. package/lib/types/platform/common.d.ts.map +1 -1
  72. package/lib/types/platform/common.js +0 -0
  73. package/lib/types/platform/component.d.ts +5 -0
  74. package/lib/types/platform/component.d.ts.map +1 -1
  75. package/lib/types/platform/component.js +0 -0
  76. package/lib/types/platform/datasource.d.ts +0 -0
  77. package/lib/types/platform/datasource.d.ts.map +0 -0
  78. package/lib/types/platform/datasource.js +0 -0
  79. package/lib/types/platform/eventFlow.d.ts +20 -0
  80. package/lib/types/platform/eventFlow.d.ts.map +1 -0
  81. package/lib/types/platform/eventFlow.js +2 -0
  82. package/lib/types/platform/query.d.ts +58 -0
  83. package/lib/types/platform/query.d.ts.map +1 -0
  84. package/lib/types/platform/query.js +2 -0
  85. package/lib/types/platform/widget/form.d.ts +0 -0
  86. package/lib/types/platform/widget/form.d.ts.map +0 -0
  87. package/lib/types/platform/widget/form.js +0 -0
  88. package/lib/types/platform/widget/meta.d.ts +0 -0
  89. package/lib/types/platform/widget/meta.d.ts.map +0 -0
  90. package/lib/types/platform/widget/meta.js +0 -0
  91. package/lib/utils/CSSProperty.d.ts +0 -0
  92. package/lib/utils/CSSProperty.d.ts.map +0 -0
  93. package/lib/utils/CSSProperty.js +0 -0
  94. package/lib/utils/build.d.ts +0 -0
  95. package/lib/utils/build.d.ts.map +0 -0
  96. package/lib/utils/build.js +0 -0
  97. package/lib/utils/constant.d.ts +0 -0
  98. package/lib/utils/constant.d.ts.map +0 -0
  99. package/lib/utils/constant.js +0 -0
  100. package/lib/utils/dts/auto-generated.d.ts +1 -1
  101. package/lib/utils/dts/auto-generated.d.ts.map +1 -1
  102. package/lib/utils/dts/auto-generated.js +35 -1227
  103. package/lib/utils/dts/build.js +4 -1
  104. package/lib/utils/dts/index.d.ts +2 -39
  105. package/lib/utils/dts/index.d.ts.map +1 -1
  106. package/lib/utils/dts/index.js +33 -288
  107. package/lib/utils/index.d.ts +0 -0
  108. package/lib/utils/index.d.ts.map +0 -0
  109. package/lib/utils/index.js +0 -0
  110. package/package.json +1 -2
@@ -42,7 +42,10 @@ 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.replace(/^declare module.*$/m, '').replace(/^\}$/m, '').replace(/^\s+/mg, '');
45
+ return dts
46
+ .replace(/^declare module.*$/m, '')
47
+ .replace(/^\}$/m, '')
48
+ .replace(/^\s+/gm, '');
46
49
  });
47
50
  }
48
51
  });
@@ -1,22 +1,4 @@
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
- }
20
2
  export interface IDTSCodeItem {
21
3
  name: string;
22
4
  code: string;
@@ -37,27 +19,10 @@ export interface IInputDataWidgetItem {
37
19
  idList: string[];
38
20
  }
39
21
  export interface IInputDataRepeaterItem {
40
- widgetId: string;
41
22
  currentItemAlias: string;
42
23
  currentIndexAlias: string;
43
24
  itemData: IJsonSchemaAny;
44
25
  }
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
- }
61
26
  export interface IOptions {
62
27
  isCompMode?: boolean;
63
28
  needGlobalFormula?: boolean;
@@ -77,8 +42,7 @@ export declare enum IInputDataType {
77
42
  compPropEvents = "compPropEvents",
78
43
  usedComponents = "usedComponents",
79
44
  usedWidgets = "usedWidgets",
80
- repeaterScope = "repeaterScope",
81
- redefineAnyType = "redefineAnyType"
45
+ repeaterScope = "repeaterScope"
82
46
  }
83
47
  export interface IInputData {
84
48
  [IInputDataType.globalState]?: IJsonSchemaObject;
@@ -94,7 +58,6 @@ export interface IInputData {
94
58
  [IInputDataType.usedComponents]?: IInputDataUsedComponents[];
95
59
  [IInputDataType.usedWidgets]?: IInputDataWidgetItem[];
96
60
  [IInputDataType.repeaterScope]?: IInputDataRepeaterItem[];
97
- [IInputDataType.redefineAnyType]?: IInputDataRedefineAnyType[];
98
61
  }
99
62
  /**
100
63
  * 通过该类可以共享同个dts。
@@ -109,7 +72,7 @@ export declare class WeDaDTS {
109
72
  /**
110
73
  * 部分更新 - 只更新一种类型
111
74
  */
112
- static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[] | IInputDataRedefineAnyType[], itemType: IInputDataType, options?: {
75
+ static updateDTSPartial(inputData: IJsonSchemaObject | IDTSCodeItem[] | string[] | IInputDataUsedComponents[] | IInputDataWidgetItem[] | IInputDataRepeaterItem[], itemType: IInputDataType, options?: {
113
76
  setEmptyIfError: boolean;
114
77
  }): Promise<void>;
115
78
  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":"AAGA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAI/D,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,OAAO,CAAA;KACpB,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAA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QAAQ,EAAE,cAAc,EAAE,OAAO,GAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAA+B;IAYrQ,MAAM,CAAC,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAgF;CAanI;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,GAAE,UAAe,EAAE,OAAO,GAAE,QAA0G,GAAG,OAAO,CAAC,MAAM,CAAC,CAyCzM;AAgKD,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,13 +8,8 @@ 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
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  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"));
18
13
  const auto_generated_1 = require("./auto-generated");
19
14
  var IInputDataType;
20
15
  (function (IInputDataType) {
@@ -31,7 +26,6 @@ var IInputDataType;
31
26
  IInputDataType["usedComponents"] = "usedComponents";
32
27
  IInputDataType["usedWidgets"] = "usedWidgets";
33
28
  IInputDataType["repeaterScope"] = "repeaterScope";
34
- IInputDataType["redefineAnyType"] = "redefineAnyType";
35
29
  })(IInputDataType = exports.IInputDataType || (exports.IInputDataType = {}));
36
30
  const DtsPlaceholder = {
37
31
  [IInputDataType.globalState]: "// Global State 全局变量 - Don't touch me",
@@ -46,8 +40,7 @@ const DtsPlaceholder = {
46
40
  [IInputDataType.compPropEvents]: "// Comp Prop Events 组件事件 - Don't touch me",
47
41
  [IInputDataType.usedComponents]: "// Used Components - Don't touch me",
48
42
  [IInputDataType.usedWidgets]: "// used widgets - Don't touch me",
49
- [IInputDataType.repeaterScope]: "// repeater scope - Don't touch me",
50
- [IInputDataType.redefineAnyType]: "// Redefine Any Type - Don't touch me",
43
+ [IInputDataType.repeaterScope]: "// repeater scope - Don't touch me"
51
44
  };
52
45
  const DtsInnerSign = {
53
46
  [IInputDataType.globalState]: "Global State Inner",
@@ -62,18 +55,8 @@ const DtsInnerSign = {
62
55
  [IInputDataType.compPropEvents]: "Comp Prop Events Inner",
63
56
  [IInputDataType.usedComponents]: "Used Components Inner",
64
57
  [IInputDataType.usedWidgets]: "used widgets Inner",
65
- [IInputDataType.repeaterScope]: "repeater scope Inner",
66
- [IInputDataType.redefineAnyType]: "Redefine Any Type Inner",
58
+ [IInputDataType.repeaterScope]: "repeater scope Inner"
67
59
  };
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 = {}));
77
60
  /**
78
61
  * 通过该类可以共享同个dts。
79
62
  * 场景:在 weda 中,低代码的变更会通知更改 dts,而低码编辑器和表达式编辑器对 dts 的需求是不一样的,这样不同的 dts 共享的是同一份全的 dts。如果直接调用 generateWeDaAppDTS 会导致 dts 重复地解析
@@ -92,16 +75,14 @@ class WeDaDTS {
92
75
  */
93
76
  static updateDTSPartial(inputData, itemType, options = { setEmptyIfError: false }) {
94
77
  return __awaiter(this, void 0, void 0, function* () {
78
+ let dts = '';
95
79
  try {
96
- const [dts, replaceRules] = yield _generateOneItemDTS(inputData, itemType);
97
- replaceRules.forEach(rule => {
98
- WeDaDTS._dts = WeDaDTS._dts.replace(rule.from, rule.to);
99
- });
80
+ dts = yield _generateOneItemDTS(inputData, itemType);
100
81
  WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
101
82
  }
102
83
  catch (e) {
103
84
  if (options.setEmptyIfError) {
104
- WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${''}\n$2`);
85
+ WeDaDTS._dts = WeDaDTS._dts.replace(new RegExp(`^(\\s*\\/\\/ ${DtsInnerSign[itemType]} Begin)[\\s\\S]*(^\\s*\\/\\/ ${DtsInnerSign[itemType]} End)`, 'm'), `$1\n${dts}\n$2`);
105
86
  }
106
87
  }
107
88
  });
@@ -133,11 +114,8 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
133
114
  if (placeholder) {
134
115
  // 防止某项错误导致全部都错误
135
116
  try {
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);
117
+ const dts = yield _generateOneItemDTS(inputData[key], key);
118
+ resultDts = resultDts.replace(placeholder, dts + placeholder);
141
119
  }
142
120
  catch (e) {
143
121
  console.error(e);
@@ -163,141 +141,17 @@ function generateWeDaAppDTS(inputData = {}, options = { isCompMode: false, needG
163
141
  if (!(options === null || options === void 0 ? void 0 : options.needRepeaterScope)) {
164
142
  resultDts = resultDts.replace(/\/\/ repeater scope Inner Begin[\s\S]*\/\/ repeater scope Inner End$/m, '');
165
143
  }
144
+ // console.log(resultDts)
166
145
  return resultDts;
167
146
  });
168
147
  }
169
148
  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
- }
177
149
  /**
178
150
  * 生成指定类型的 DTS
179
151
  */
180
152
  function _generateOneItemDTS(inputData, itemType) {
181
153
  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
- }
279
154
  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
- },
301
155
  [IInputDataType.globalCommonCodes]: function (inputData) {
302
156
  return __awaiter(this, void 0, void 0, function* () {
303
157
  const dts = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
@@ -351,8 +205,7 @@ function _generateOneItemDTS(inputData, itemType) {
351
205
  // 属性
352
206
  let exportPropertiesDTS = '';
353
207
  if (item.exportProperties) {
354
- const handledProperties = _handleComment(item.exportProperties);
355
- exportPropertiesDTS = yield _compile(handledProperties);
208
+ exportPropertiesDTS = yield _compile(item.exportProperties);
356
209
  }
357
210
  // 方法
358
211
  let exportMethodsDTS = '';
@@ -385,15 +238,8 @@ function _generateOneItemDTS(inputData, itemType) {
385
238
  // ${exportMethodsDTS}
386
239
  // }
387
240
  // `
388
- const interfaceName = _genCompInterfaceName(item.module, item.component);
389
241
  return `
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 {
242
+ declare class ${_genCompInterfaceName(item.module, item.component)} extends UserWidget {
397
243
 
398
244
  ${exportPropertiesDTS}
399
245
 
@@ -408,19 +254,7 @@ function _generateOneItemDTS(inputData, itemType) {
408
254
  return inputData.map(item => {
409
255
  if (item.idList && item.idList.length > 0) {
410
256
  const interfaceName = _genCompInterfaceName(item.module, item.component);
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');
257
+ return item.idList.map(id => `const ${id}: ${interfaceName}`).join('\n');
424
258
  }
425
259
  return '';
426
260
  }).join('\n');
@@ -428,134 +262,45 @@ function _generateOneItemDTS(inputData, itemType) {
428
262
  [IInputDataType.repeaterScope]: function (inputData) {
429
263
  return __awaiter(this, void 0, void 0, function* () {
430
264
  const results = yield Promise.all(inputData.map((item) => __awaiter(this, void 0, void 0, function* () {
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
- }
265
+ let itemDataDTS = yield _compile(item.itemData, true);
441
266
  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
- */
453
267
  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
- */
464
268
  const ${item.currentIndexAlias}: number
465
269
  `;
466
270
  })));
467
271
  return results.join('\n');
468
272
  });
469
273
  },
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
- }
548
274
  };
549
275
  let dts = '';
550
276
  if (!inputData)
551
- return [dts, replaceRules];
277
+ return dts;
552
278
  const handler = hanlderMap[itemType];
553
279
  // 优先判断是否有独立的处理逻辑
554
280
  if (handler) {
555
281
  dts = yield handler.call(hanlderMap, inputData);
556
282
  }
557
283
  dts = dts || (yield _compile(inputData));
558
- return [dts, replaceRules];
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
+ }
559
304
  });
560
305
  }
561
306
  // 仅仅为了与 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.3-alpha.7",
3
+ "version": "1.0.3-alpha.9",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
6
  "source": "src/utils/index.ts",
@@ -30,7 +30,6 @@
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
32
  "acorn": "^8.0.4",
33
- "json-easy-filter": "^0.3.1",
34
33
  "json-schema-to-typescript-for-browser": "^11.0.3",
35
34
  "lodash": "^4.17.20",
36
35
  "postcss": "^8.4.20",