@easyquery/core 7.2.4-rc03 → 7.2.4-rc05

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.
@@ -18,7 +18,7 @@ return /******/ (() => { // webpackBootstrap
18
18
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
19
19
  /* harmony export */ e: () => (/* binding */ GoogleDataConverter)
20
20
  /* harmony export */ });
21
- /* harmony import */ var _easydata_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(907);
21
+ /* harmony import */ var _easydata_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(902);
22
22
 
23
23
  /**
24
24
  * Represents Google data table class
@@ -196,7 +196,7 @@ var GoogleDataConverter = /** @class */ (function () {
196
196
 
197
197
  /***/ }),
198
198
 
199
- /***/ 907:
199
+ /***/ 902:
200
200
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
201
201
 
202
202
 
@@ -359,39 +359,6 @@ var HttpRequest = /** @class */ (function () {
359
359
  }());
360
360
 
361
361
  //# sourceMappingURL=http_request.js.map
362
- ;// CONCATENATED MODULE: ../../easydata/easydata.js/packs/core/dist/lib/utils/string_utils.js
363
- function repeatString(str, times) {
364
- var result = "";
365
- for (var i = 0; i < times; i++) {
366
- result += str;
367
- }
368
- return result;
369
- }
370
- function reverseString(str) {
371
- return str.split("").reverse().join("");
372
- }
373
- function strEndsWith(str, symbol) {
374
- return str && str.lastIndexOf(symbol) == (str.length - symbol.length);
375
- }
376
- /**
377
- * Adds two paths and returns the result
378
- * Correctly processes leading and trailing slashes
379
- * @param path1
380
- * @param path2
381
- */
382
- function combinePath(path1, path2) {
383
- var result = path1;
384
- if (result != null && result.length > 0) {
385
- if (result.charAt(result.length - 1) != '/')
386
- result += "/";
387
- result += path2;
388
- }
389
- else {
390
- result = path2;
391
- }
392
- return result;
393
- }
394
- //# sourceMappingURL=string_utils.js.map
395
362
  ;// CONCATENATED MODULE: ../../easydata/easydata.js/packs/core/dist/lib/i18n/i18n.js
396
363
 
397
364
 
@@ -865,7 +832,6 @@ var i18n;
865
832
  ;// CONCATENATED MODULE: ../../easydata/easydata.js/packs/core/dist/lib/utils/utils.js
866
833
 
867
834
 
868
-
869
835
  var utils;
870
836
  (function (utils) {
871
837
  function getAllDataTypes() {
@@ -1188,27 +1154,26 @@ var utils;
1188
1154
  if (prfx && prfx.length > 0) {
1189
1155
  prfx += "-";
1190
1156
  }
1191
- //adding 2 random symbols
1192
- var randValue = repeatString("", 2);
1193
- ;
1194
- var maxSymbolIndex = symbols.length - 1;
1195
- randValue = replaceAtString(randValue, 0, symbols[getRandomInt(0, maxSymbolIndex)]);
1196
- randValue = replaceAtString(randValue, 1, symbols[getRandomInt(0, maxSymbolIndex)]);
1197
- //generating main ID part (64-base representation of the current value of the time ticks)
1198
- var ticksNum64 = intToNum36(getNowTicks() - magicTicks);
1199
- return prfx + randValue + ticksNum64;
1157
+ //adding 3 random symbols
1158
+ var randCharPart = symbols[getRandomInt(0, symbols.length)] +
1159
+ symbols[getRandomInt(0, symbols.length)] +
1160
+ symbols[getRandomInt(0, symbols.length)];
1161
+ var randInt = getRandomInt(0, 10000);
1162
+ //generating main ID part
1163
+ //it's a 36-base representation of some random number based on current value of ticks
1164
+ var ticksNum36 = intToNumBase(getNowTicks() - magicTicks - randInt);
1165
+ return prfx + randCharPart + ticksNum36;
1200
1166
  }
1201
1167
  utils.generateId = generateId;
1202
- function intToNum36(value) {
1203
- var targetBase = 36;
1204
- var i = 14;
1205
- var buffer = repeatString("", i);
1168
+ function intToNumBase(value, targetBase) {
1169
+ if (targetBase === void 0) { targetBase = 36; }
1170
+ var buffer = '';
1206
1171
  var rest = value;
1207
1172
  do {
1208
- buffer = replaceAtString(buffer, i--, symbols[rest % targetBase]);
1173
+ buffer = symbols[rest % targetBase] + buffer;
1209
1174
  rest = Math.floor(rest /= targetBase);
1210
1175
  } while (rest > 0);
1211
- return reverseString(buffer.trim());
1176
+ return buffer;
1212
1177
  }
1213
1178
  function squeezeMoniker(str, maxlen) {
1214
1179
  var parts = str.split('-');
@@ -1245,8 +1210,8 @@ var utils;
1245
1210
  return str;
1246
1211
  }
1247
1212
  }
1248
- function replaceAtString(str, index, value) {
1249
- return str.substr(0, index) + value + str.substr(index + value.length);
1213
+ function replaceAtString(str, index, replacement) {
1214
+ return str.substring(0, index) + replacement + str.substring(index + replacement.length);
1250
1215
  }
1251
1216
  function getRandomInt(min, max) {
1252
1217
  return Math.floor(Math.random() * (max - min)) + min;
@@ -3210,8 +3175,8 @@ __webpack_require__.d(__webpack_exports__, {
3210
3175
  versionInfo: () => (/* reexport */ versionInfo)
3211
3176
  });
3212
3177
 
3213
- // EXTERNAL MODULE: ../../easydata/easydata.js/packs/core/dist/lib/public_api.js + 21 modules
3214
- var public_api = __webpack_require__(907);
3178
+ // EXTERNAL MODULE: ../../easydata/easydata.js/packs/core/dist/lib/public_api.js + 20 modules
3179
+ var public_api = __webpack_require__(902);
3215
3180
  ;// CONCATENATED MODULE: ./src/utils/format_parser.ts
3216
3181
  /**
3217
3182
  * Represents a parser for format expressions in operators
@@ -5964,7 +5929,7 @@ var Query = /** @class */ (function () {
5964
5929
  throw new InvalidQueryError(entityAttrNotExistError + column.expr.args[0].value);
5965
5930
  }
5966
5931
  }
5967
- else if (column.expr.tag !== ExprTag.CustomSql) {
5932
+ else if (column.expr.tag === ExprTag.Unknown) {
5968
5933
  throw new InvalidQueryError(wrongExprTag + column.expr.tag);
5969
5934
  }
5970
5935
  }
@@ -6447,7 +6412,6 @@ var Query = /** @class */ (function () {
6447
6412
  }
6448
6413
  public_api/* utils.moveArrayItem */.P6.moveArrayItem(this.sortedColumns, colIdx, index);
6449
6414
  this.fixupSortingIndices();
6450
- this.fireColumnsChangedEvent(QueryChangeAction.All);
6451
6415
  };
6452
6416
  Query.prototype.getColumnSorting = function (col) {
6453
6417
  var idx = this.getColumnSortIndex(col);
@@ -6474,7 +6438,6 @@ var Query = /** @class */ (function () {
6474
6438
  }
6475
6439
  }
6476
6440
  this.adjustColumnsSorting();
6477
- this.fireColumnsChangedEvent(QueryChangeAction.Modify, col, col.isJustSorted());
6478
6441
  };
6479
6442
  Query.prototype.fixupSortingIndices = function () {
6480
6443
  this.sortedColumns.forEach(function (col, index) {
@@ -6523,10 +6486,8 @@ var Query = /** @class */ (function () {
6523
6486
  * sortIndex: SortDirection.Ascending
6524
6487
  * }});
6525
6488
  */
6526
- Query.prototype.addColumn = function (descriptor, author) {
6527
- // let columns = (descriptor.justsorted)
6528
- // ? this.justsorted
6529
- // : this.columns;
6489
+ Query.prototype.addColumn = function (descriptor, silent) {
6490
+ if (silent === void 0) { silent = false; }
6530
6491
  var newColumn;
6531
6492
  if (descriptor.column) {
6532
6493
  newColumn = descriptor.column;
@@ -6543,10 +6504,10 @@ var Query = /** @class */ (function () {
6543
6504
  throw new Error("Incorrect attribute id (".concat(descriptor.attributeId, "): addColumn"));
6544
6505
  }
6545
6506
  }
6546
- else {
6547
- throw new Error('Not enought data for addColumn operation. Need attribute or attributeId');
6507
+ else if (typeof descriptor.constValue === 'undefined' && !descriptor.customSql) {
6508
+ throw new Error('Not enought data for addColumn operation. One of the following options must be defined: attribute, attributeId, constValue or customSlq');
6548
6509
  }
6549
- if (!attr.useInResult) {
6510
+ if (attr && !attr.useInResult) {
6550
6511
  if (attr.lookupAttr) {
6551
6512
  attr = this.model.getAttributeById(attr.lookupAttr);
6552
6513
  }
@@ -6554,22 +6515,29 @@ var Query = /** @class */ (function () {
6554
6515
  throw new Error("Can't use this attribute for a column");
6555
6516
  }
6556
6517
  }
6557
- if (descriptor.aggrFuncId && descriptor.cusomtSql) {
6518
+ if (descriptor.aggrFuncId && descriptor.customSql) {
6558
6519
  console.warn("Column cannot be created using aggrFuncId and customSql at the same time. " +
6559
6520
  "cusomSql will be used.");
6560
6521
  }
6561
- if (descriptor.cusomtSql) {
6522
+ if (typeof descriptor.constValue !== 'undefined') {
6523
+ newColumn.expr.tag = ExprTag.Constant;
6524
+ newColumn.expr.setValue(descriptor.constValue);
6525
+ newColumn.expr.kind = DataKind.Scalar;
6526
+ newColumn.expr.dataType = descriptor.constType || public_api/* DataType.String */.g.String;
6527
+ }
6528
+ else if (descriptor.customSql) {
6562
6529
  newColumn.caption = 'Custom SQL Column';
6563
6530
  newColumn.expr.tag = ExprTag.CustomSql;
6564
- newColumn.expr.baseAttrId = attr.id;
6565
- newColumn.expr.sql = descriptor.cusomtSql;
6531
+ newColumn.expr.sql = descriptor.customSql;
6566
6532
  newColumn.expr.kind = DataKind.Query;
6567
6533
  newColumn.expr.dataType = public_api/* DataType.Unknown */.g.Unknown;
6534
+ newColumn.expr.baseAttrId = descriptor.attributeId;
6535
+ if (!this.context.options.allowCustomExpressions) {
6536
+ newColumn.enabled = false;
6537
+ }
6568
6538
  }
6569
6539
  else if (descriptor.aggrFuncId) {
6570
6540
  var funcId = descriptor.aggrFuncId;
6571
- newColumn.caption = attr.caption + ' '
6572
- + this.model.getAggrFunctionCaption(descriptor.aggrFuncId);
6573
6541
  newColumn.expr.tag = ExprTag.AggregateFunction;
6574
6542
  newColumn.expr.func = descriptor.aggrFuncId;
6575
6543
  newColumn.expr.kind = DataKind.Scalar;
@@ -6578,16 +6546,18 @@ var Query = /** @class */ (function () {
6578
6546
  var arg = new Expression(newColumn);
6579
6547
  arg.setValue(attr.id, true);
6580
6548
  arg.tag = ExprTag.EntityAttribute;
6549
+ arg.kind = DataKind.Attribute;
6581
6550
  arg.dataType = attr.dataType;
6582
6551
  newColumn.expr.args.push(arg);
6583
6552
  }
6584
6553
  else {
6585
- newColumn.caption = attr.caption;
6586
6554
  newColumn.expr.setValue(attr.id, true);
6587
6555
  newColumn.expr.tag = ExprTag.EntityAttribute;
6556
+ newColumn.expr.kind = DataKind.Attribute;
6588
6557
  newColumn.expr.dataType = attr.dataType;
6558
+ newColumn.params.concat(attr.params);
6589
6559
  }
6590
- newColumn.caption = descriptor.caption || newColumn.caption;
6560
+ newColumn.caption = descriptor.caption || this.context.getDefaultColumnCaption(newColumn);
6591
6561
  newColumn._sorting = descriptor.sorting || SortDirection.None;
6592
6562
  newColumn._sortIndex = descriptor.sortIndex || -1;
6593
6563
  newColumn.enabled = public_api/* utils.getIfDefined */.P6.getIfDefined(descriptor.enabled, true);
@@ -6603,7 +6573,9 @@ var Query = /** @class */ (function () {
6603
6573
  }
6604
6574
  }
6605
6575
  this.setColumnSorting(newColumn, newColumn._sorting);
6606
- this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
6576
+ if (!silent) {
6577
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
6578
+ }
6607
6579
  return newColumn;
6608
6580
  };
6609
6581
  /**
@@ -6657,9 +6629,6 @@ var Query = /** @class */ (function () {
6657
6629
  if (column.isJustSorted())
6658
6630
  return;
6659
6631
  args = args || {};
6660
- column.caption = (typeof args.caption !== 'undefined')
6661
- ? args.caption
6662
- : '';
6663
6632
  if (tag === ExprTag.AggregateFunction) {
6664
6633
  if (!args.funcId)
6665
6634
  throw Error('"funcId" argument is not defined');
@@ -6697,22 +6666,24 @@ var Query = /** @class */ (function () {
6697
6666
  || column.expr.tag === ExprTag.ParentEntityAttribute) {
6698
6667
  return;
6699
6668
  }
6700
- var exprId = (column.expr.tag === ExprTag.CustomSql)
6701
- ? column.expr.baseAttrId
6702
- : column.expr.args[0].value;
6703
- var attr = this.model.getAttributeById(exprId);
6669
+ var attrId = (column.expr.tag == ExprTag.AggregateFunction)
6670
+ ? column.expr.args[0].value
6671
+ : column.expr.baseAttrId;
6672
+ var attr = attrId
6673
+ ? this.model.getAttributeById(attrId)
6674
+ : this.model.getFirstUICAttr();
6704
6675
  var expr = new Expression(column);
6705
6676
  expr.tag = ExprTag.EntityAttribute;
6706
- expr.dataType = attr != null ? attr.dataType : public_api/* DataType.Unknown */.g.Unknown;
6707
- expr.setValue(exprId, true);
6677
+ expr.dataType = attr.dataType;
6678
+ expr.setValue(attr.id, true);
6708
6679
  column.expr = expr;
6709
6680
  }
6681
+ column.caption = this.context.getDefaultColumnCaption(column);
6710
6682
  };
6711
6683
  /**
6712
6684
  * Moves the column with specified index to another position.
6713
6685
  * @param index1 The index of the column that should be moved.
6714
6686
  * @param index2 The index of the position the column should be moved to
6715
- * @param author The author
6716
6687
  */
6717
6688
  Query.prototype.moveColumn = function (index1, index2) {
6718
6689
  var columns = this.getColumns();
@@ -6722,12 +6693,8 @@ var Query = /** @class */ (function () {
6722
6693
  /**
6723
6694
  * Removes the column.
6724
6695
  * @param column The column to be removed.
6725
- * @param author The author
6726
6696
  */
6727
- Query.prototype.removeColumn = function (column, author) {
6728
- // const columns = (column.isJustSorted())
6729
- // ? this.getJustSortedColumns()
6730
- // : this.getColumns();
6697
+ Query.prototype.removeColumn = function (column) {
6731
6698
  public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.columns, column);
6732
6699
  public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.sortedColumns, column);
6733
6700
  };
@@ -6988,7 +6955,9 @@ var Query = /** @class */ (function () {
6988
6955
  var expr = cond.expressions[part.index];
6989
6956
  if (expr.kind == DataKind.Attribute || expr.tag == ExprTag.EntityAttribute) {
6990
6957
  var attr = model.getAttributeById(expr.value);
6991
- txt = model.getAttributeText(attr, "{entity} {attr}");
6958
+ if (attr != null) {
6959
+ txt = model.getAttributeText(attr, "{entity} {attr}");
6960
+ }
6992
6961
  }
6993
6962
  else {
6994
6963
  txt = expr.getText();
@@ -7839,13 +7808,6 @@ var InMemoryModelStorage = /** @class */ (function () {
7839
7808
  }());
7840
7809
 
7841
7810
 
7842
- ;// CONCATENATED MODULE: ./src/main/action.ts
7843
- var EqActionResult;
7844
- (function (EqActionResult) {
7845
- EqActionResult[EqActionResult["Error"] = 0] = "Error";
7846
- EqActionResult[EqActionResult["Success"] = 1] = "Success";
7847
- })(EqActionResult || (EqActionResult = {}));
7848
-
7849
7811
  ;// CONCATENATED MODULE: ./src/eqs/eqs_exporter.ts
7850
7812
 
7851
7813
  var EqServerExporter = /** @class */ (function () {
@@ -7907,6 +7869,13 @@ var EqServerExporter = /** @class */ (function () {
7907
7869
  }());
7908
7870
 
7909
7871
 
7872
+ ;// CONCATENATED MODULE: ./src/main/action.ts
7873
+ var EqActionResult;
7874
+ (function (EqActionResult) {
7875
+ EqActionResult[EqActionResult["Error"] = 0] = "Error";
7876
+ EqActionResult[EqActionResult["Success"] = 1] = "Success";
7877
+ })(EqActionResult || (EqActionResult = {}));
7878
+
7910
7879
  ;// CONCATENATED MODULE: ./src/main/context.ts
7911
7880
  var context_assign = (undefined && undefined.__assign) || function () {
7912
7881
  context_assign = Object.assign || function(t) {
@@ -7944,7 +7913,9 @@ var EqContext = /** @class */ (function () {
7944
7913
  function EqContext() {
7945
7914
  var _this = this;
7946
7915
  this.options = {
7947
- syncSortOrderWithColumnsOrder: true
7916
+ syncSortOrderWithColumnsOrder: true,
7917
+ attributeFormat: '{entity} {attr}',
7918
+ columnTitleFormat: null //means it will be the same as attributeFormat
7948
7919
  };
7949
7920
  this.servicesInitialized = false;
7950
7921
  this.internalListCache = {};
@@ -9363,6 +9334,37 @@ var EqContext = /** @class */ (function () {
9363
9334
  });
9364
9335
  }
9365
9336
  };
9337
+ EqContext.prototype.getAttributeTitle = function (attr) {
9338
+ var format = this.options.attributeFormat;
9339
+ return this.getModel().getAttributeText(attr, format);
9340
+ };
9341
+ EqContext.prototype.getColumnTitle = function (attr) {
9342
+ var format = this.options.columnTitleFormat || this.options.attributeFormat;
9343
+ return this.getModel().getAttributeText(attr, format);
9344
+ };
9345
+ EqContext.prototype.getDefaultColumnCaption = function (column) {
9346
+ var attr;
9347
+ var model = this.getModel();
9348
+ switch (column.expr.tag) {
9349
+ case ExprTag.Constant:
9350
+ return "Contant Column";
9351
+ case ExprTag.CustomSql:
9352
+ return "SQL Column";
9353
+ case ExprTag.ParentColumn:
9354
+ return "Parent Column";
9355
+ case ExprTag.Query:
9356
+ return "Query Column";
9357
+ case ExprTag.EntityAttribute:
9358
+ case ExprTag.ParentEntityAttribute:
9359
+ attr = model.getAttributeById(column.expr.value);
9360
+ return this.getColumnTitle(attr);
9361
+ case ExprTag.AggregateFunction:
9362
+ attr = model.getAttributeById(column.expr.args[0].value);
9363
+ return this.getColumnTitle(attr) + ' ' + model.getAggrFunctionCaption(column.expr.func);
9364
+ default:
9365
+ return 'Column';
9366
+ }
9367
+ };
9366
9368
  return EqContext;
9367
9369
  }());
9368
9370