@easyquery/core 7.2.5-beta01 → 7.2.5-rc01

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 (191) hide show
  1. package/dist/easyquery.core.cjs.js +6165 -0
  2. package/dist/easyquery.core.esm.js +6126 -0
  3. package/dist/{lib → types}/common/eq_services.d.ts +16 -12
  4. package/dist/{lib → types}/dm/data_model.d.ts +3 -23
  5. package/dist/{lib → types}/dm/operator.d.ts +2 -2
  6. package/dist/{lib → types}/main/context.d.ts +17 -2
  7. package/dist/types/main/context_resolver.d.ts +3 -0
  8. package/dist/types/main/init.d.ts +1 -0
  9. package/dist/{lib → types}/public_api.d.ts +2 -0
  10. package/dist/{lib → types}/query/query.d.ts +19 -8
  11. package/package.json +13 -37
  12. package/dist/bundles/easyquery.core.js +0 -9584
  13. package/dist/bundles/easyquery.core.js.map +0 -1
  14. package/dist/bundles/easyquery.core.min.js +0 -2
  15. package/dist/bundles/easyquery.core.min.js.map +0 -1
  16. package/dist/lib/common/eq_services.js +0 -160
  17. package/dist/lib/common/eq_services.js.map +0 -1
  18. package/dist/lib/common/query_param.js +0 -2
  19. package/dist/lib/common/query_param.js.map +0 -1
  20. package/dist/lib/common/tree.js +0 -58
  21. package/dist/lib/common/tree.js.map +0 -1
  22. package/dist/lib/data/eq_aggr_container.js +0 -109
  23. package/dist/lib/data/eq_aggr_container.js.map +0 -1
  24. package/dist/lib/data/eq_data_loader.js +0 -50
  25. package/dist/lib/data/eq_data_loader.js.map +0 -1
  26. package/dist/lib/data/google_data_converter.js +0 -174
  27. package/dist/lib/data/google_data_converter.js.map +0 -1
  28. package/dist/lib/dm/aggr_function.js +0 -43
  29. package/dist/lib/dm/aggr_function.js.map +0 -1
  30. package/dist/lib/dm/data_model.js +0 -935
  31. package/dist/lib/dm/data_model.js.map +0 -1
  32. package/dist/lib/dm/dto/af_data.js +0 -2
  33. package/dist/lib/dm/dto/af_data.js.map +0 -1
  34. package/dist/lib/dm/dto/dm_data.js +0 -2
  35. package/dist/lib/dm/dto/dm_data.js.map +0 -1
  36. package/dist/lib/dm/dto/entity_data.js +0 -2
  37. package/dist/lib/dm/dto/entity_data.js.map +0 -1
  38. package/dist/lib/dm/dto/operator_data.js +0 -2
  39. package/dist/lib/dm/dto/operator_data.js.map +0 -1
  40. package/dist/lib/dm/dto/ve_data.js +0 -2
  41. package/dist/lib/dm/dto/ve_data.js.map +0 -1
  42. package/dist/lib/dm/entity.js +0 -91
  43. package/dist/lib/dm/entity.js.map +0 -1
  44. package/dist/lib/dm/link.js +0 -2
  45. package/dist/lib/dm/link.js.map +0 -1
  46. package/dist/lib/dm/operator.js +0 -94
  47. package/dist/lib/dm/operator.js.map +0 -1
  48. package/dist/lib/dm/value_editor.js +0 -44
  49. package/dist/lib/dm/value_editor.js.map +0 -1
  50. package/dist/lib/eqs/eqs_data_fetcher.js +0 -37
  51. package/dist/lib/eqs/eqs_data_fetcher.js.map +0 -1
  52. package/dist/lib/eqs/eqs_exporter.js +0 -60
  53. package/dist/lib/eqs/eqs_exporter.js.map +0 -1
  54. package/dist/lib/eqs/eqs_model_loader.js +0 -43
  55. package/dist/lib/eqs/eqs_model_loader.js.map +0 -1
  56. package/dist/lib/eqs/eqs_query_file_loader.js +0 -55
  57. package/dist/lib/eqs/eqs_query_file_loader.js.map +0 -1
  58. package/dist/lib/eqs/eqs_query_synchronizer.js +0 -24
  59. package/dist/lib/eqs/eqs_query_synchronizer.js.map +0 -1
  60. package/dist/lib/eqs/eqs_value_list_resolver.js +0 -29
  61. package/dist/lib/eqs/eqs_value_list_resolver.js.map +0 -1
  62. package/dist/lib/export/exporter.js +0 -7
  63. package/dist/lib/export/exporter.js.map +0 -1
  64. package/dist/lib/i18n/text_resources.js +0 -27
  65. package/dist/lib/i18n/text_resources.js.map +0 -1
  66. package/dist/lib/main/action.js +0 -6
  67. package/dist/lib/main/action.js.map +0 -1
  68. package/dist/lib/main/context.js +0 -1492
  69. package/dist/lib/main/context.js.map +0 -1
  70. package/dist/lib/main/context_options.js +0 -2
  71. package/dist/lib/main/context_options.js.map +0 -1
  72. package/dist/lib/main/data_fetcher.js +0 -2
  73. package/dist/lib/main/data_fetcher.js.map +0 -1
  74. package/dist/lib/main/eq_actions.js +0 -16
  75. package/dist/lib/main/eq_actions.js.map +0 -1
  76. package/dist/lib/main/list_cache.js +0 -2
  77. package/dist/lib/main/list_cache.js.map +0 -1
  78. package/dist/lib/main/model_loader.js +0 -33
  79. package/dist/lib/main/model_loader.js.map +0 -1
  80. package/dist/lib/main/model_storage.js +0 -18
  81. package/dist/lib/main/model_storage.js.map +0 -1
  82. package/dist/lib/main/query_file_loader.js +0 -2
  83. package/dist/lib/main/query_file_loader.js.map +0 -1
  84. package/dist/lib/main/query_storage.js +0 -125
  85. package/dist/lib/main/query_storage.js.map +0 -1
  86. package/dist/lib/main/query_synchronizer.js +0 -2
  87. package/dist/lib/main/query_synchronizer.js.map +0 -1
  88. package/dist/lib/main/value_list_resolver.js +0 -2
  89. package/dist/lib/main/value_list_resolver.js.map +0 -1
  90. package/dist/lib/main/widget.js +0 -102
  91. package/dist/lib/main/widget.js.map +0 -1
  92. package/dist/lib/public_api.js +0 -60
  93. package/dist/lib/public_api.js.map +0 -1
  94. package/dist/lib/query/condition.js +0 -332
  95. package/dist/lib/query/condition.js.map +0 -1
  96. package/dist/lib/query/descriptors.js +0 -2
  97. package/dist/lib/query/descriptors.js.map +0 -1
  98. package/dist/lib/query/dto/condition_data.js +0 -2
  99. package/dist/lib/query/dto/condition_data.js.map +0 -1
  100. package/dist/lib/query/dto/expression_data.js +0 -2
  101. package/dist/lib/query/dto/expression_data.js.map +0 -1
  102. package/dist/lib/query/dto/query_column_data.js +0 -2
  103. package/dist/lib/query/dto/query_column_data.js.map +0 -1
  104. package/dist/lib/query/dto/query_data.js +0 -2
  105. package/dist/lib/query/dto/query_data.js.map +0 -1
  106. package/dist/lib/query/expression.js +0 -203
  107. package/dist/lib/query/expression.js.map +0 -1
  108. package/dist/lib/query/query.js +0 -1503
  109. package/dist/lib/query/query.js.map +0 -1
  110. package/dist/lib/query/query_column.js +0 -205
  111. package/dist/lib/query/query_column.js.map +0 -1
  112. package/dist/lib/query/query_events.js +0 -20
  113. package/dist/lib/query/query_events.js.map +0 -1
  114. package/dist/lib/types/cond_part.js +0 -8
  115. package/dist/lib/types/cond_part.js.map +0 -1
  116. package/dist/lib/types/cond_tag.js +0 -14
  117. package/dist/lib/types/cond_tag.js.map +0 -1
  118. package/dist/lib/types/data_kind.js +0 -17
  119. package/dist/lib/types/data_kind.js.map +0 -1
  120. package/dist/lib/types/eq_editor_tag.js +0 -21
  121. package/dist/lib/types/eq_editor_tag.js.map +0 -1
  122. package/dist/lib/types/expr_tag.js +0 -21
  123. package/dist/lib/types/expr_tag.js.map +0 -1
  124. package/dist/lib/types/link_type.js +0 -19
  125. package/dist/lib/types/link_type.js.map +0 -1
  126. package/dist/lib/types/widget_group.js +0 -19
  127. package/dist/lib/types/widget_group.js.map +0 -1
  128. package/dist/lib/utils/constants.js +0 -51
  129. package/dist/lib/utils/constants.js.map +0 -1
  130. package/dist/lib/utils/format_parser.js +0 -88
  131. package/dist/lib/utils/format_parser.js.map +0 -1
  132. package/dist/lib/utils/utils.js +0 -103
  133. package/dist/lib/utils/utils.js.map +0 -1
  134. package/dist/lib/utils/version_info.js +0 -13
  135. package/dist/lib/utils/version_info.js.map +0 -1
  136. package/tsconfig.json +0 -22
  137. package/webpack.config.js +0 -51
  138. /package/dist/{lib → types}/common/query_param.d.ts +0 -0
  139. /package/dist/{lib → types}/common/tree.d.ts +0 -0
  140. /package/dist/{lib → types}/data/eq_aggr_container.d.ts +0 -0
  141. /package/dist/{lib → types}/data/eq_data_loader.d.ts +0 -0
  142. /package/dist/{lib → types}/data/google_data_converter.d.ts +0 -0
  143. /package/dist/{lib → types}/dm/aggr_function.d.ts +0 -0
  144. /package/dist/{lib → types}/dm/dto/af_data.d.ts +0 -0
  145. /package/dist/{lib → types}/dm/dto/dm_data.d.ts +0 -0
  146. /package/dist/{lib → types}/dm/dto/entity_data.d.ts +0 -0
  147. /package/dist/{lib → types}/dm/dto/operator_data.d.ts +0 -0
  148. /package/dist/{lib → types}/dm/dto/ve_data.d.ts +0 -0
  149. /package/dist/{lib → types}/dm/entity.d.ts +0 -0
  150. /package/dist/{lib → types}/dm/link.d.ts +0 -0
  151. /package/dist/{lib → types}/dm/value_editor.d.ts +0 -0
  152. /package/dist/{lib → types}/eqs/eqs_data_fetcher.d.ts +0 -0
  153. /package/dist/{lib → types}/eqs/eqs_exporter.d.ts +0 -0
  154. /package/dist/{lib → types}/eqs/eqs_model_loader.d.ts +0 -0
  155. /package/dist/{lib → types}/eqs/eqs_query_file_loader.d.ts +0 -0
  156. /package/dist/{lib → types}/eqs/eqs_query_synchronizer.d.ts +0 -0
  157. /package/dist/{lib → types}/eqs/eqs_value_list_resolver.d.ts +0 -0
  158. /package/dist/{lib → types}/export/exporter.d.ts +0 -0
  159. /package/dist/{lib → types}/i18n/text_resources.d.ts +0 -0
  160. /package/dist/{lib → types}/main/action.d.ts +0 -0
  161. /package/dist/{lib → types}/main/context_options.d.ts +0 -0
  162. /package/dist/{lib → types}/main/data_fetcher.d.ts +0 -0
  163. /package/dist/{lib → types}/main/eq_actions.d.ts +0 -0
  164. /package/dist/{lib → types}/main/list_cache.d.ts +0 -0
  165. /package/dist/{lib → types}/main/model_loader.d.ts +0 -0
  166. /package/dist/{lib → types}/main/model_storage.d.ts +0 -0
  167. /package/dist/{lib → types}/main/query_file_loader.d.ts +0 -0
  168. /package/dist/{lib → types}/main/query_storage.d.ts +0 -0
  169. /package/dist/{lib → types}/main/query_synchronizer.d.ts +0 -0
  170. /package/dist/{lib → types}/main/value_list_resolver.d.ts +0 -0
  171. /package/dist/{lib → types}/main/widget.d.ts +0 -0
  172. /package/dist/{lib → types}/query/condition.d.ts +0 -0
  173. /package/dist/{lib → types}/query/descriptors.d.ts +0 -0
  174. /package/dist/{lib → types}/query/dto/condition_data.d.ts +0 -0
  175. /package/dist/{lib → types}/query/dto/expression_data.d.ts +0 -0
  176. /package/dist/{lib → types}/query/dto/query_column_data.d.ts +0 -0
  177. /package/dist/{lib → types}/query/dto/query_data.d.ts +0 -0
  178. /package/dist/{lib → types}/query/expression.d.ts +0 -0
  179. /package/dist/{lib → types}/query/query_column.d.ts +0 -0
  180. /package/dist/{lib → types}/query/query_events.d.ts +0 -0
  181. /package/dist/{lib → types}/types/cond_part.d.ts +0 -0
  182. /package/dist/{lib → types}/types/cond_tag.d.ts +0 -0
  183. /package/dist/{lib → types}/types/data_kind.d.ts +0 -0
  184. /package/dist/{lib → types}/types/eq_editor_tag.d.ts +0 -0
  185. /package/dist/{lib → types}/types/expr_tag.d.ts +0 -0
  186. /package/dist/{lib → types}/types/link_type.d.ts +0 -0
  187. /package/dist/{lib → types}/types/widget_group.d.ts +0 -0
  188. /package/dist/{lib → types}/utils/constants.d.ts +0 -0
  189. /package/dist/{lib → types}/utils/format_parser.d.ts +0 -0
  190. /package/dist/{lib → types}/utils/utils.d.ts +0 -0
  191. /package/dist/{lib → types}/utils/version_info.d.ts +0 -0
@@ -1,935 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { DataType, MetaData, utils as dataUtils } from '@easydata/core';
17
- import { i18n } from '@easydata/core';
18
- import { AggrFunction } from './aggr_function';
19
- import { Operator, Operand } from './operator';
20
- import { Entity, EntityAttr } from './entity';
21
- import { EqValueEditor } from './value_editor';
22
- import { DataKind } from '../types/data_kind';
23
- import { EqEditorTag } from '../types/eq_editor_tag';
24
- import { Query } from '../query/query';
25
- import { ExprTag } from '../types/expr_tag';
26
- import { Tree } from '../common/tree';
27
- /**
28
- * Represents a data model
29
- */
30
- var DataModel = /** @class */ (function (_super) {
31
- __extends(DataModel, _super);
32
- /** The default constructor. */
33
- function DataModel() {
34
- var _this = _super.call(this) || this;
35
- _this.mainEntity = null;
36
- _this.nullAttribute = new EntityAttr(null);
37
- _this.nullOperator = new Operator();
38
- _this.operators = new Array();
39
- _this.rootEntity = new Entity();
40
- _this.aggrFunctions = new Array();
41
- _this.dateMacros = ['Today', 'Yesterday',
42
- 'Tomorrow', 'FirstDayOfMonth', 'LastDayOfMonth',
43
- 'FirstDayOfWeek', 'FirstDayOfYear', 'FirstDayOfNextWeek', 'FirstDayOfPrevMonth',
44
- 'FirstDayOfNextMonth', 'FirstDayOfNextYear', 'FirstDayOfPrevYear', 'FirstDayOfPrevWeek'];
45
- _this.timeMacros = ['Now', 'HourStart', 'Midnight', 'Noon'];
46
- _this.links = [];
47
- return _this;
48
- }
49
- /**
50
- * Gets the main entity of model
51
- * @return The main entity.
52
- */
53
- DataModel.prototype.getMainEntity = function () {
54
- return this.mainEntity;
55
- };
56
- /**
57
- * Loads data model from JSON.
58
- * @param stringJson The JSON string.
59
- */
60
- DataModel.prototype.loadFromJSON = function (stringJson) {
61
- var model = JSON.parse(stringJson);
62
- this.loadFromData(model);
63
- };
64
- /**
65
- * Loads data model from its JSON representation object.
66
- * @param data The JSON representation object.
67
- */
68
- DataModel.prototype.loadFromData = function (data) {
69
- _super.prototype.loadFromData.call(this, data);
70
- //Operators
71
- this.operators = new Array();
72
- if (data.operators) {
73
- for (var i = 0; i < data.operators.length; i++) {
74
- var newOperator = new Operator();
75
- newOperator.loadFromData(this, data.operators[i]);
76
- this.operators.push(newOperator);
77
- }
78
- }
79
- //rootEntity
80
- this.rootEntity.loadFromData(this, data.entroot);
81
- //Aggr Functions
82
- this.aggrFunctions = new Array();
83
- if (data.aggrfuncs) {
84
- for (var i = 0; i < data.aggrfuncs.length; i++) {
85
- var newAggrFunc = new AggrFunction();
86
- newAggrFunc.loadFromData(data.aggrfuncs[i]);
87
- this.aggrFunctions.push(newAggrFunc);
88
- }
89
- }
90
- };
91
- /**
92
- * Gets the data model object.
93
- * @returns Tha data model.
94
- */
95
- DataModel.prototype.getObject = function () {
96
- return this;
97
- };
98
- /**
99
- * Sets data to data model.
100
- * @param model Its JSON representation object or JSON string.
101
- */
102
- DataModel.prototype.setData = function (model) {
103
- if (typeof model === 'string') {
104
- this.loadFromJSON(model);
105
- }
106
- else {
107
- this.loadFromData(model);
108
- }
109
- };
110
- /**
111
- * Creates entity.
112
- * @param parent The parent entity.
113
- * @returns The Entity.
114
- */
115
- DataModel.prototype.createEntity = function (parent) {
116
- return new Entity(parent);
117
- };
118
- /**
119
- * Creates entity attribute.
120
- * @param parent The parent entity.
121
- * @returns The entity attribute.
122
- */
123
- DataModel.prototype.createEntityAttr = function (parent) {
124
- return new EntityAttr(parent);
125
- };
126
- /**
127
- * Creates new EqValueEditor
128
- * @returns An instance of EqValueEditor class
129
- */
130
- DataModel.prototype.createValueEditor = function () {
131
- return new EqValueEditor();
132
- };
133
- /**
134
- * Creates query.
135
- * @returns The Query.
136
- */
137
- DataModel.prototype.createQuery = function () {
138
- return new Query(this);
139
- };
140
- /**
141
- * Gets root entity of the data model.
142
- * @returns The root entity.
143
- */
144
- DataModel.prototype.getRootEntity = function () {
145
- return this.rootEntity;
146
- };
147
- /**
148
- * Finds editor by its ID.
149
- * @param editorId The editor ID.
150
- * @returns The value editor or `null`.
151
- */
152
- DataModel.prototype.getEditorById = function (editorId) {
153
- return _super.prototype.getEditorById.call(this, editorId);
154
- };
155
- /**
156
- * Gets entity attribute by its ID.
157
- * This function runs through all attributes inside specified model (it's root entity and all its sub-entities).
158
- * @param attrId The attribute ID.
159
- * @returns The attribute or `null`.
160
- */
161
- DataModel.prototype.getAttributeById = function (attrId) {
162
- var attr = this.getEntityAttrById(this.getRootEntity(), attrId);
163
- if (!attr) {
164
- return null;
165
- }
166
- return attr;
167
- };
168
- /**
169
- * Gets entity attribute by its ID.
170
- * This function runs through all attributes inside specified model (it's root entity and all its sub-entities).
171
- * @param attrId The attribute ID.
172
- * @returns The attribute or `nullAttribute`.
173
- */
174
- DataModel.prototype.getAttributeByIdSafe = function (attrId) {
175
- var attr = this.getAttributeById(attrId);
176
- if (!attr)
177
- return this.nullAttribute;
178
- return attr;
179
- };
180
- /**
181
- * Checks wether attribute contains such property.
182
- * @param attrId The attribute ID.
183
- * @param propName The property name.
184
- * @returns `true` if the attribute contains the property, otherwise `false`.
185
- */
186
- DataModel.prototype.checkAttrProperty = function (attrId, propName) {
187
- var attribute = this.getAttributeById(attrId);
188
- if (attribute) {
189
- if (typeof attribute[propName] === 'undefined') {
190
- throw 'No such property: ' + propName;
191
- }
192
- if (attribute[propName]) {
193
- return true;
194
- }
195
- else if (attribute.lookupAttr) {
196
- attrId = attribute.lookupAttr;
197
- attribute = this.getAttributeById(attrId);
198
- return attribute && attribute[propName];
199
- }
200
- else {
201
- return false;
202
- }
203
- }
204
- else
205
- return false;
206
- };
207
- /**
208
- * Gets entity attribute by its ID.
209
- * This function runs through all attributes inside specified entity and all its sub-entities.
210
- * @param entity
211
- * @param attrId
212
- * @returns The attribute or `null`.
213
- */
214
- DataModel.prototype.getEntityAttrById = function (entity, attrId) {
215
- return _super.prototype.getEntityAttrById.call(this, entity, attrId);
216
- };
217
- DataModel.prototype._listByEntityWithFilter = function (entity, filterFunc) {
218
- var result = new Array();
219
- var caption;
220
- var ent = null;
221
- if (entity.subEntities) {
222
- var subEntityCount = entity.subEntities.length;
223
- for (var entIdx = 0; entIdx < subEntityCount; entIdx++) {
224
- ent = entity.subEntities[entIdx];
225
- if (!filterFunc || filterFunc(ent, null)) {
226
- caption = i18n.getText('Entities', ent.name);
227
- if (!caption) {
228
- caption = ent.caption;
229
- }
230
- var newEnt = dataUtils.assign(new Entity(), { id: ent.name, text: caption, items: [], isEntity: true });
231
- newEnt.items = this._listByEntityWithFilter(ent, filterFunc);
232
- if (newEnt.items.length > 0)
233
- result.push(newEnt);
234
- }
235
- }
236
- }
237
- var attr = null;
238
- if (entity.attributes) {
239
- var attrCount = entity.attributes.length;
240
- for (var attrIdx = 0; attrIdx < attrCount; attrIdx++) {
241
- attr = entity.attributes[attrIdx];
242
- if (!filterFunc || filterFunc(entity, attr)) {
243
- caption = i18n.getText('Attributes', attr.id);
244
- if (!caption)
245
- caption = attr.caption;
246
- var newEnt = dataUtils.assign(new Entity(), { id: attr.id, text: caption, dataType: attr.dataType });
247
- result.push(newEnt);
248
- }
249
- }
250
- }
251
- return result;
252
- };
253
- DataModel.prototype._listByEntity = function (entity, opts, filterFunc) {
254
- opts = opts || {};
255
- var resultEntities = [];
256
- var resultAttributes = [];
257
- var caption;
258
- var ent = null;
259
- if (entity.subEntities) {
260
- var subEntityCount = entity.subEntities.length;
261
- for (var entIdx = 0; entIdx < subEntityCount; entIdx++) {
262
- ent = entity.subEntities[entIdx];
263
- if (!filterFunc || filterFunc(ent, null)) {
264
- if (opts.addUIC !== false && ent.useInConditions !== false ||
265
- opts.addUIR !== false && ent.useInResult !== false ||
266
- opts.addUIS !== false && ent.useInSorting !== false) {
267
- caption = i18n.getText('Entities', ent.name) || ent.caption;
268
- var newEnt = dataUtils.assign(new Entity(), {
269
- id: ent.name,
270
- text: caption,
271
- items: [],
272
- isEntity: true,
273
- description: ent.description
274
- });
275
- var newOpts = dataUtils.assign({}, opts);
276
- newOpts.includeRootData = false;
277
- newEnt.items = this._listByEntity(ent, newOpts, filterFunc);
278
- if (newEnt.items.length > 0) {
279
- resultEntities.push(newEnt);
280
- }
281
- }
282
- }
283
- }
284
- }
285
- var attr = null;
286
- if (entity.attributes) {
287
- var attrCount = entity.attributes.length;
288
- for (var attrIdx = 0; attrIdx < attrCount; attrIdx++) {
289
- attr = entity.attributes[attrIdx];
290
- if (!filterFunc || filterFunc(entity, attr)) {
291
- if (opts.addUIC !== false && attr.useInConditions !== false ||
292
- opts.addUIR !== false && attr.useInResult !== false ||
293
- opts.addUIS !== false && attr.useInSorting !== false) {
294
- caption = i18n.getText('Attributes', attr.id) || attr.caption;
295
- resultAttributes.push(dataUtils.assign(new EntityAttr(entity), { id: attr.id, text: caption, dataType: attr.dataType, lookupAttr: attr.lookupAttr, description: attr.description }));
296
- }
297
- }
298
- }
299
- }
300
- var sortCheck = function (a, b) {
301
- if (a.text.toLowerCase() == b.text.toLowerCase()) {
302
- return 0;
303
- }
304
- if (a.text.toLowerCase() > b.text.toLowerCase()) {
305
- return 1;
306
- }
307
- return -1;
308
- };
309
- if (opts.sortEntities) {
310
- resultEntities.sort(sortCheck);
311
- resultAttributes.sort(sortCheck);
312
- }
313
- var result;
314
- if (!opts.attrPlacement || opts.attrPlacement == 0) {
315
- result = resultEntities.concat(resultAttributes);
316
- }
317
- else {
318
- result = resultAttributes.concat(resultEntities);
319
- }
320
- if (opts.attrPlacement == 2) {
321
- result.sort(sortCheck);
322
- }
323
- if (opts.includeRootData) {
324
- caption = i18n.getText('Entities', entity.name);
325
- if (!caption)
326
- caption = entity.caption;
327
- return { id: entity.name, text: caption, items: result };
328
- }
329
- else {
330
- return result;
331
- }
332
- };
333
- /**
334
- * Clears data model.
335
- */
336
- DataModel.prototype.clear = function () {
337
- _super.prototype.clear.call(this);
338
- this.operators = [];
339
- this.aggrFunctions = [];
340
- };
341
- /**
342
- * Add or update an operator.
343
- * @param desc The operator descriptor.
344
- * @returns The operator.
345
- */
346
- DataModel.prototype.addOrUpdateOperator = function (desc) {
347
- var op = dataUtils.findItemById(this.operators, desc.id);
348
- if (!op) {
349
- op = new Operator();
350
- op.id = desc.id;
351
- this.operators.push(op);
352
- }
353
- op.caption = desc.caption;
354
- op.expr = desc.expr || '';
355
- op.displayFormat = desc.format;
356
- op.defaultOperand = new Operand();
357
- op.defaultOperand.kind = desc.kind || DataKind.Scalar;
358
- if (desc.appliedTypes)
359
- op.appliedTypes = desc.appliedTypes;
360
- if (desc.paramCount > 0) {
361
- op.paramCount = desc.paramCount;
362
- }
363
- this.runThroughEntities(function (attr, opts) {
364
- if (attr.operators.indexOf(op.id) < 0 && op.appliedTypes.indexOf(attr.dataType) >= 0) {
365
- attr.operators.push(op.id);
366
- }
367
- });
368
- return op;
369
- };
370
- /**
371
- * Removes an operator.
372
- * @param id The id.
373
- * @param soft If `false` - removes operators from model and attributes. Otherwise only
374
- * from attributes.
375
- */
376
- DataModel.prototype.removeOperator = function (id, soft) {
377
- if (soft === void 0) { soft = false; }
378
- var op = dataUtils.findItemById(this.operators, id);
379
- if (op) {
380
- if (!soft)
381
- dataUtils.removeArrayItem(this.operators, op);
382
- this.runThroughEntities(function (attr, opts) {
383
- dataUtils.removeArrayItem(attr.operators, op.id);
384
- });
385
- }
386
- };
387
- /**
388
- * Get operators for data type.
389
- * @param type The data type
390
- * @return The array of operator ids.
391
- */
392
- DataModel.prototype.getOperatorIdsByDataType = function (type) {
393
- switch (type) {
394
- case DataType.String:
395
- case DataType.Memo:
396
- return 'StartsWith,EndsWith,Contains,Equal,InList,NotStartsWith,NotEndsWith,NotContains,NotEqual,NotInList,IsNull,IsNotNull'.split(',');
397
- case DataType.Guid:
398
- return 'Equal,NotEqual'.split(',');
399
- case DataType.Date:
400
- case DataType.DateTime:
401
- return 'DateWithinToday,DateWithinThisWeek,DateWithinPrevWeek,DateWithinThisMonth,DateWithinPrevMonth,DateWithinThisYear,DateWithinPrevYear,DateBeforePrecise,DateAfterPrecise,DatePeriodPrecise,IsNull,IsNotNull'.split(',');
402
- case DataType.Time:
403
- return 'TimeBeforePrecise,TimeAfterPrecise,TimePeriodPrecise,IsNull,IsNotNull'.split(',');
404
- case DataType.Byte:
405
- case DataType.Word:
406
- case DataType.Int32:
407
- case DataType.Int64:
408
- case DataType.Float:
409
- case DataType.Currency:
410
- case DataType.BCD:
411
- case DataType.Autoinc:
412
- case DataType.Unknown:
413
- return 'Equal,Between,LessThan,LessOrEqual,GreaterThan,GreaterOrEqual,InList,NotEqual,NotBetween,NotInList,IsNull,IsNotNull'.split(',');
414
- case DataType.Bool:
415
- return 'IsTrue,NotTrue'.split(',');
416
- default:
417
- var result = [];
418
- for (var _i = 0, _a = this.operators; _i < _a.length; _i++) {
419
- var op = _a[_i];
420
- if (op.appliedTypes.indexOf(type) >= 0)
421
- result.push(op.id);
422
- }
423
- return result;
424
- }
425
- };
426
- /**
427
- * Builds entities tree used in query.
428
- * @param query The query.
429
- */
430
- DataModel.prototype.buildQueryPath = function (query) {
431
- var entity = this.mainEntity || this.rootEntity;
432
- var tree = this.createTreeNodeFromEntity(entity);
433
- tree.setParents();
434
- return tree;
435
- };
436
- DataModel.prototype.createTreeNodeFromEntity = function (entity) {
437
- var tree = new Tree(entity);
438
- for (var _i = 0, _a = entity.subEntities; _i < _a.length; _i++) {
439
- var subEnentity = _a[_i];
440
- tree.addChild(this.createTreeNodeFromEntity(subEnentity));
441
- }
442
- return tree;
443
- };
444
- /**
445
- * Get Entities used in query.
446
- * @param query The query.
447
- */
448
- DataModel.prototype.getEntitiesInQuery = function (query) {
449
- if (query.model.id !== this.id)
450
- throw Error('Model mithmatch');
451
- var entities = [];
452
- var columns = query.getColumns();
453
- for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) {
454
- var column = columns_1[_i];
455
- if (!column.enabled)
456
- continue;
457
- this.addEntityByExpression(entities, column.expr);
458
- }
459
- var rootCond = query.getRootCondition();
460
- this.fillEntitiesByCondtionGroup(entities, rootCond);
461
- return entities;
462
- };
463
- DataModel.prototype.findAggrFunctionById = function (funcId) {
464
- for (var _i = 0, _a = this.aggrFunctions; _i < _a.length; _i++) {
465
- var func = _a[_i];
466
- if (func.id === funcId)
467
- return func;
468
- }
469
- return null;
470
- };
471
- DataModel.prototype.fillEntitiesByCondtionGroup = function (entities, root) {
472
- for (var _i = 0, _a = root.getConditions(); _i < _a.length; _i++) {
473
- var condition = _a[_i];
474
- if (!condition.isGroup()) {
475
- for (var _b = 0, _c = condition.expressions; _b < _c.length; _b++) {
476
- var expr = _c[_b];
477
- this.addEntityByExpression(entities, expr);
478
- if (expr.args) {
479
- for (var _d = 0, _e = expr.args; _d < _e.length; _d++) {
480
- var arg = _e[_d];
481
- this.addEntityByExpression(entities, arg);
482
- }
483
- }
484
- }
485
- }
486
- else {
487
- this.fillEntitiesByCondtionGroup(entities, condition);
488
- }
489
- }
490
- };
491
- DataModel.prototype.addEntityByExpression = function (entities, expr) {
492
- if (expr.tag !== ExprTag.EntityAttribute)
493
- return;
494
- var attrId = expr.baseAttrId || expr.value;
495
- if (attrId) {
496
- var attr = this.getAttributeById(attrId);
497
- if (attr) {
498
- if (attr.entity && dataUtils.indexOfArrayItem(entities, attr.entity) < 0) {
499
- entities.push(attr.entity);
500
- }
501
- }
502
- }
503
- };
504
- /**
505
- * Finds link between two entities.
506
- * @param entityFrom The entity `from`.
507
- * @param entityTo The entity `to`.
508
- * @return The link.
509
- */
510
- DataModel.prototype.findLink = function (entityFrom, entityTo) {
511
- for (var _i = 0, _a = this.links; _i < _a.length; _i++) {
512
- var link = _a[_i];
513
- if (link.entityFrom == entityFrom
514
- && link.entityTo == entityTo)
515
- return link;
516
- }
517
- return null;
518
- };
519
- /**
520
- * Get links with the entity.
521
- * @param entity The entity.
522
- * @return The link.
523
- */
524
- DataModel.prototype.getLinksByEntity = function (entity) {
525
- var result = [];
526
- for (var _i = 0, _a = this.links; _i < _a.length; _i++) {
527
- var link = _a[_i];
528
- if (link.entityFrom == entity || link.entityTo == entity) {
529
- result.push(link);
530
- }
531
- }
532
- return result;
533
- };
534
- /**
535
- * Gets entities tree.
536
- * @param opts The options.
537
- * @param filterFunc The filter function.
538
- * Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).
539
- * @returns The tree of the entities and their attributes according to options and the filter function
540
- */
541
- DataModel.prototype.getEntitiesTree = function (opts, filterFunc) {
542
- return this._listByEntity(this.getRootEntity(), opts, filterFunc);
543
- };
544
- /**
545
- * Gets entities tree due to filter.
546
- * @param filterFunc The filter function.
547
- * Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).
548
- * @returns The tree of the entities and their attributes according to the filter function
549
- */
550
- DataModel.prototype.getEntitiesTreeWithFilter = function (filterFunc) {
551
- return this._listByEntityWithFilter(this.getRootEntity(), filterFunc);
552
- };
553
- /**
554
- * Finds full entity path by attribute
555
- * @param attrId The attribute id.
556
- * @param sep The separator.
557
- * @returns The path.
558
- */
559
- DataModel.prototype.getFullEntityPathByAttr = function (attrId, sep) {
560
- sep = sep || ' ';
561
- return this.getEntityPathByAttr(this.getRootEntity(), attrId, sep, true);
562
- };
563
- /**
564
- * Finds entity path by attribute
565
- * @param entity The entity.
566
- * @param attrId The attribute id.
567
- * @param sep The separator.
568
- * @param root The root option.
569
- * @returns The path.
570
- */
571
- DataModel.prototype.getEntityPathByAttr = function (entity, attrId, sep, root) {
572
- return _super.prototype.getEntityPathByAttr.call(this, entity, attrId, sep, root);
573
- };
574
- /**
575
- * Gets the attribute text.
576
- * @param attr The attribute.
577
- * @param format The format.
578
- * @returns Formatted text.
579
- */
580
- DataModel.prototype.getAttributeText = function (attr, format) {
581
- return _super.prototype.getAttributeText.call(this, attr, format);
582
- };
583
- DataModel.prototype.getFirstUICAttr = function () {
584
- return this.getFirstUICAttrInEntity(this.getRootEntity());
585
- };
586
- /**
587
- * Gets first `UIC` attribute in specified entity
588
- * (`UIC` stands for `use in conditions` - so such attribute can be used in conditions)
589
- * @param entity Entity object to search our attribute in.
590
- * @returns The entity attribute or `null`
591
- */
592
- DataModel.prototype.getFirstUICAttrInEntity = function (entity) {
593
- if (entity.useInConditions !== false) {
594
- if (entity.attributes) {
595
- var attrCount = entity.attributes.length;
596
- for (var i = 0; i < attrCount; i++) {
597
- if (entity.attributes[i].useInConditions) {
598
- return entity.attributes[i];
599
- }
600
- }
601
- }
602
- if (entity.subEntities) {
603
- var subEntityCount = entity.subEntities.length;
604
- for (var i = 0; i < subEntityCount; i++) {
605
- var result = this.getFirstUICAttrInEntity(entity.subEntities[i]);
606
- if (result) {
607
- return result;
608
- }
609
- }
610
- }
611
- }
612
- return null;
613
- };
614
- /**
615
- * Scans model's entity tree and calls the callback functions for each attribute and entity.
616
- * @param processAttribute The callback function which is called for each attribute in model's entity tree.
617
- * The processed attribute is passed in the first function parameter.
618
- * @param processEntity The callback function which is called for each entity in tree.
619
- * The processed entity is passed in the first function parameter.
620
- */
621
- DataModel.prototype.runThroughEntities = function (processAttribute, processEntity) {
622
- this.getRootEntity().scan(processAttribute, processEntity);
623
- };
624
- /**
625
- * Finds first attribute by filter.
626
- * @param filterFunc The filter function. Takes EntityAttr object in parameter and returns boolean
627
- */
628
- DataModel.prototype.getFirstAttributeByFilter = function (filterFunc) {
629
- var res = null;
630
- this.runThroughEntities(function (attr, opts) {
631
- if (filterFunc(attr)) {
632
- opts.stop = true;
633
- res = attr;
634
- }
635
- }, null);
636
- return res;
637
- };
638
- /**
639
- * Finds operator in model by its ID.
640
- * This function runs through all operators inside specified model and returns the one with specified ID.
641
- * @param operatorId An operator ID.
642
- * @returns The operator or `null`.
643
- */
644
- DataModel.prototype.findOperatorById = function (operatorId) {
645
- if (this.operators.length > 0) {
646
- var opCount = this.operators.length;
647
- for (var idx = 0; idx < opCount; idx++) {
648
- if (this.operators[idx].id == operatorId) {
649
- return this.operators[idx];
650
- }
651
- }
652
- }
653
- return null;
654
- };
655
- /**
656
- * Finds operator in model by its ID.
657
- * his function runs through all operators inside specified model and returns the one with specified ID.
658
- * @param operatorId Operator ID.
659
- * @returns The operator or special `NullOperator` object if operator is not found.
660
- */
661
- DataModel.prototype.getOperatorById = function (operatorId) {
662
- var op = this.findOperatorById(operatorId);
663
- if (!op)
664
- return this.nullOperator;
665
- return op;
666
- };
667
- DataModel.prototype.getDefaultOperatorIdForAttr = function (attr) {
668
- if (attr.defaultOperator) {
669
- return attr.defaultOperator;
670
- }
671
- else if (attr.operators.length > 0) {
672
- return attr.operators[0];
673
- }
674
- else {
675
- return this.nullOperator.id;
676
- }
677
- };
678
- /**
679
- * Gets caption of the aggregate function.
680
- * @param funcId The function id.
681
- * @returns The caption.
682
- */
683
- DataModel.prototype.getAggrFunctionCaption = function (funcId) {
684
- var funcTexts = i18n.getText('AggregateFunctions', funcId);
685
- var funcCaption = funcTexts ? funcTexts.caption : i18n.getText('Aggr' + funcId.replace(' ', '') + '_Caption');
686
- if (funcCaption) {
687
- return funcCaption;
688
- }
689
- var func = dataUtils.findItemById(this.aggrFunctions, funcId);
690
- if (!func || !func.caption)
691
- return funcId;
692
- return func.caption;
693
- };
694
- /**
695
- * Gets format of the aggregate function.
696
- * @param funcId The function id.
697
- * @returns The caption.
698
- */
699
- DataModel.prototype.getAggrFunctionFormat = function (funcId) {
700
- var funcTexts = i18n.getText('AggregateFunctions', funcId);
701
- var funcFormat = funcTexts ? funcTexts.displayFormat : i18n.getText('Aggr' + funcId.replace(' ', '') + '_Format');
702
- if (funcFormat) {
703
- return funcFormat;
704
- }
705
- var func = dataUtils.findItemById(this.aggrFunctions, funcId);
706
- if (!func || !func.displayFormat)
707
- return '';
708
- return func.displayFormat;
709
- };
710
- /**
711
- * Gets default operator for an attribute.
712
- * @param attr The attribute.
713
- * @returns The operator.
714
- */
715
- DataModel.prototype.getDefaultOperatorForAttr = function (attr) {
716
- var operatorId = this.getDefaultOperatorIdForAttr(attr);
717
- return this.getOperatorById(operatorId);
718
- };
719
- /**
720
- * Gets operand.
721
- * @param attr The attribute.
722
- * @param operator The operator.
723
- * @param index The index.
724
- * @returns The operand.
725
- */
726
- DataModel.prototype.getOperand = function (attr, operator, index) {
727
- var defOperand = new Operand();
728
- if (operator && operator.defaultOperand) {
729
- defOperand.copyFrom(operator.defaultOperand);
730
- if (!defOperand.defValue) {
731
- defOperand.defValue = '';
732
- }
733
- if (!defOperand.defText) {
734
- defOperand.defText = '';
735
- }
736
- }
737
- else {
738
- defOperand.kind = DataKind.Scalar;
739
- defOperand.dataType = attr.dataType;
740
- defOperand.defValue = '';
741
- defOperand.defText = '';
742
- defOperand.editor = null;
743
- }
744
- var result = defOperand;
745
- if (result.dataType === DataType.Unknown && attr) {
746
- result.dataType = attr.dataType;
747
- }
748
- if (operator && (index >= 0)) {
749
- if (operator.operands && operator.operands[index - 1]) {
750
- result = dataUtils.assign(result, operator.operands[index - 1]);
751
- }
752
- }
753
- ;
754
- if (!result.editor) {
755
- if (defOperand.editor) {
756
- result.editor = defOperand.editor;
757
- }
758
- else if (defOperand.kind === DataKind.Query) {
759
- result.editor.tag = EqEditorTag.SubQuery;
760
- }
761
- else if (attr && attr.defaultEditor) {
762
- result.editor = attr.defaultEditor;
763
- }
764
- else if (result.dataType === DataType.Date || result.dataType === DataType.DateTime
765
- || result.dataType === DataType.Time) {
766
- result.editor.tag = EqEditorTag.DateTime;
767
- }
768
- else {
769
- result.editor.tag = EqEditorTag.Edit;
770
- }
771
- }
772
- return result;
773
- };
774
- /**
775
- * Gets the list of aggegate functions.
776
- * @returns AN array of aggregate functions.
777
- */
778
- DataModel.prototype.getAggrFunctions = function () {
779
- return this.aggrFunctions;
780
- };
781
- /**
782
- * Checks wether macro value is date.
783
- * @param macroExpr The macro value.
784
- * @retruns `true` if the macro value is date, otherwise `false`.
785
- */
786
- DataModel.prototype.isDateMacro = function (macroExpr, macroProcessor) {
787
- var match = macroExpr.match(/\${{?(.*?)}?}/);
788
- if (match != null) {
789
- var macroId = match[1];
790
- if (dataUtils.indexOfArrayItem(this.dateMacros, macroId) >= 0) {
791
- if (macroProcessor) {
792
- macroProcessor(macroId);
793
- }
794
- return true;
795
- }
796
- }
797
- return false;
798
- };
799
- /**
800
- * Checks whether the expression passed in the parameter is an time macro.
801
- * @param macroExpr The macro expression
802
- * @retruns `true` if the expression is a time macro (like Now), otherwise `false`.
803
- */
804
- DataModel.prototype.isTimeMacro = function (macroExpr, macroProcessor) {
805
- var match = macroExpr.match(/\${{?(.*?)}?}/);
806
- if (match != null) {
807
- var macroId = match[1];
808
- if (dataUtils.indexOfArrayItem(this.timeMacros, macroId) >= 0) {
809
- if (macroProcessor) {
810
- macroProcessor(macroId);
811
- }
812
- return true;
813
- }
814
- }
815
- return false;
816
- };
817
- /**
818
- * Gets date by its macro value.
819
- * @param macroExpr The macro value.
820
- * @returns The date or `null`
821
- */
822
- DataModel.prototype.getDateMacroValue = function (macroExpr) {
823
- var d = new Date();
824
- var res = this.isDateMacro(macroExpr, function (macroId) {
825
- switch (macroId) {
826
- case 'Today':
827
- break;
828
- case 'Yesterday':
829
- d.setDate(d.getDate() - 1);
830
- break;
831
- case 'Tomorrow':
832
- d.setDate(d.getDate() + 1);
833
- break;
834
- case 'FirstDayOfMonth':
835
- d.setDate(1);
836
- break;
837
- case 'LastDayOfMonth':
838
- d.setMonth(d.getMonth() + 1, 0);
839
- break;
840
- case 'FirstDayOfPrevWeek':
841
- var day = d.getDay();
842
- day = (day == 0) ? 1 : 8 - day; //We start week from Monday, but js - from Sunday
843
- d.setDate(d.getDate() - day);
844
- break;
845
- case 'FirstDayOfWeek':
846
- var day = d.getDay();
847
- day = (day == 0) ? 6 : day - 1; //We start week from Monday, but js - from Sunday
848
- d.setDate(d.getDate() - day);
849
- break;
850
- case 'FirstDayOfYear':
851
- d.setMonth(0, 1);
852
- break;
853
- case 'FirstDayOfNextWeek':
854
- var day = d.getDay();
855
- day = (day == 0) ? 1 : 8 - day; //We start week from Monday, but js - from Sunday
856
- d.setDate(d.getDate() + day);
857
- break;
858
- case 'FirstDayOfNextMonth':
859
- d.setMonth(d.getMonth() + 1, 1);
860
- break;
861
- case 'FirstDayOfPrevMonth':
862
- d.setMonth(d.getMonth() - 1, 1);
863
- break;
864
- case 'FirstDayOfPrevYear':
865
- d.setFullYear(d.getFullYear() - 1, 0, 1);
866
- break;
867
- case 'FirstDayOfNextYear':
868
- d.setFullYear(d.getFullYear() + 1, 0, 1);
869
- break;
870
- }
871
- ;
872
- });
873
- return res ? d : null;
874
- };
875
- /**
876
- * Gets the date value by a macro expression of the expression itself.
877
- * @param macroExpr The macro value.
878
- * @returns The date or macro valu.
879
- */
880
- DataModel.prototype.getDateOrMacroValue = function (macroExpr) {
881
- var d = this.getDateMacroValue(macroExpr);
882
- return d ? d : macroExpr;
883
- };
884
- /**
885
- * Gets time by its macro value.
886
- * @param macroExpr The macro value.
887
- * @returns The date or `null`.
888
- */
889
- DataModel.prototype.getTimeMacroValue = function (macroExpr) {
890
- var d = new Date();
891
- var res = this.isDateMacro(macroExpr, function (macroId) {
892
- switch (macroId) {
893
- case 'Now':
894
- break;
895
- case 'HourStart':
896
- d.setMinutes(0, 0, 0);
897
- break;
898
- case 'Midnight':
899
- d.setHours(0, 0, 0, 0);
900
- break;
901
- case 'Noon':
902
- d.setHours(12, 0, 0, 0);
903
- break;
904
- }
905
- ;
906
- });
907
- return res ? d : null;
908
- };
909
- /**
910
- * Gets time or macro by macro value.
911
- * @param macroValue The macro value.
912
- * @returns The time or macro valu.
913
- */
914
- DataModel.prototype.getTimeOrMacroValue = function (time) {
915
- var t = this.getTimeMacroValue(time);
916
- return t ? t : time;
917
- };
918
- // /**
919
- // * Gets all date marcos.
920
- // * @returns The array of marcos
921
- // */
922
- DataModel.prototype.getAllDateMacros = function () {
923
- return this.dateMacros;
924
- };
925
- /**
926
- * Gets all time marcos.
927
- * @returns The array of marcos
928
- */
929
- DataModel.prototype.getAllTimeMacros = function () {
930
- return this.timeMacros;
931
- };
932
- return DataModel;
933
- }(MetaData));
934
- export { DataModel };
935
- //# sourceMappingURL=data_model.js.map