@sankhyalabs/sankhyablocks 1.3.31-beta.1 → 1.3.31-beta.11

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 (92) hide show
  1. package/dist/cjs/SnkMessageBuilder-13239761.js +188 -0
  2. package/dist/cjs/{index-1133bc2a.js → index-c6671817.js} +416 -9
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  5. package/dist/cjs/snk-application.cjs.entry.js +283 -108
  6. package/dist/cjs/snk-crud.cjs.entry.js +64 -0
  7. package/dist/cjs/snk-data-unit.cjs.entry.js +277 -0
  8. package/dist/cjs/snk-form_2.cjs.entry.js +177 -0
  9. package/dist/cjs/snk-pesquisa.cjs.entry.js +6 -3
  10. package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
  11. package/dist/cjs/taskbar-elements-73d524e5.js +70 -0
  12. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  13. package/dist/collection/collection-manifest.json +5 -0
  14. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
  15. package/dist/collection/components/snk-application/snk-application.js +267 -63
  16. package/dist/collection/components/snk-crud/snk-crud.css +5 -0
  17. package/dist/collection/components/snk-crud/snk-crud.js +137 -0
  18. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  19. package/dist/collection/components/snk-data-unit/snk-data-unit.js +528 -0
  20. package/dist/collection/components/snk-form/snk-form.css +34 -0
  21. package/dist/collection/components/snk-form/snk-form.js +220 -0
  22. package/dist/collection/components/snk-grid/snk-grid.css +5 -0
  23. package/dist/collection/components/snk-grid/snk-grid.js +148 -0
  24. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +56 -13
  25. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +5 -1
  26. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +65 -0
  27. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  28. package/dist/collection/components/snk-taskbar/snk-taskbar.js +271 -0
  29. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
  30. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
  31. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  32. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
  33. package/dist/collection/lib/message/SnkMessageBuilder.js +119 -0
  34. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +22 -0
  35. package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
  36. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +16 -0
  37. package/dist/components/SnkMessageBuilder.js +166 -0
  38. package/dist/components/snk-application2.js +284 -107
  39. package/dist/components/snk-crud.d.ts +11 -0
  40. package/dist/components/snk-crud.js +101 -0
  41. package/dist/components/snk-data-unit.d.ts +11 -0
  42. package/dist/components/snk-data-unit.js +300 -0
  43. package/dist/components/snk-form.d.ts +11 -0
  44. package/dist/components/snk-form.js +6 -0
  45. package/dist/components/snk-form2.js +140 -0
  46. package/dist/components/snk-grid.d.ts +11 -0
  47. package/dist/components/snk-grid.js +6 -0
  48. package/dist/components/snk-grid2.js +91 -0
  49. package/dist/components/snk-pesquisa2.js +5 -2
  50. package/dist/components/snk-taskbar.d.ts +11 -0
  51. package/dist/components/snk-taskbar.js +6 -0
  52. package/dist/components/snk-taskbar2.js +240 -0
  53. package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
  54. package/dist/esm/{index-ffda6382.js → index-6a83ac96.js} +416 -10
  55. package/dist/esm/loader.js +2 -2
  56. package/dist/esm/sankhyablocks.js +2 -2
  57. package/dist/esm/snk-application.entry.js +283 -108
  58. package/dist/esm/snk-crud.entry.js +60 -0
  59. package/dist/esm/snk-data-unit.entry.js +273 -0
  60. package/dist/esm/snk-form_2.entry.js +172 -0
  61. package/dist/esm/snk-pesquisa.entry.js +6 -3
  62. package/dist/esm/snk-taskbar.entry.js +155 -0
  63. package/dist/esm/taskbar-elements-6d01a640.js +68 -0
  64. package/dist/esm/teste-pesquisa.entry.js +1 -1
  65. package/dist/sankhyablocks/p-4c7b32d6.entry.js +1 -0
  66. package/dist/sankhyablocks/p-5e1b7e51.entry.js +1 -0
  67. package/dist/sankhyablocks/p-72bccbb6.js +1 -0
  68. package/dist/sankhyablocks/p-8c74d163.entry.js +1 -0
  69. package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
  70. package/dist/sankhyablocks/p-cd1dc099.js +2 -0
  71. package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-d25637c9.entry.js} +1 -1
  72. package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
  73. package/dist/sankhyablocks/p-e942c604.entry.js +69 -0
  74. package/dist/sankhyablocks/p-f4d0394b.entry.js +1 -0
  75. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  76. package/dist/types/components/snk-application/snk-application.d.ts +109 -15
  77. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +25 -0
  78. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +53 -0
  79. package/dist/types/components.d.ts +372 -6
  80. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
  81. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +3 -3
  82. package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
  83. package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
  84. package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
  85. package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
  86. package/package.json +5 -5
  87. package/react/components.d.ts +5 -0
  88. package/react/components.js +5 -0
  89. package/react/components.js.map +1 -1
  90. package/dist/sankhyablocks/p-d62412bb.entry.js +0 -1
  91. package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
  92. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-1133bc2a.js');
5
+ const index = require('./index-c6671817.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
- const UnitMetadata = require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
8
+ const SnkMessageBuilder = require('./SnkMessageBuilder-13239761.js');
9
9
 
10
10
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11
11
 
@@ -1236,7 +1236,7 @@ function isNode(maybeNode) {
1236
1236
  }
1237
1237
  /** Name */
1238
1238
 
1239
- let OperationTypeNode;
1239
+ var OperationTypeNode;
1240
1240
  exports.OperationTypeNode = OperationTypeNode;
1241
1241
 
1242
1242
  (function (OperationTypeNode) {
@@ -1256,13 +1256,7 @@ exports.DirectiveLocation = void 0;
1256
1256
  /**
1257
1257
  * The set of allowed directive location values.
1258
1258
  */
1259
- let DirectiveLocation;
1260
- /**
1261
- * The enum type representing the directive location values.
1262
- *
1263
- * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1264
- */
1265
-
1259
+ var DirectiveLocation;
1266
1260
  exports.DirectiveLocation = DirectiveLocation;
1267
1261
 
1268
1262
  (function (DirectiveLocation) {
@@ -1286,6 +1280,11 @@ exports.DirectiveLocation = DirectiveLocation;
1286
1280
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
1287
1281
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
1288
1282
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1283
+ /**
1284
+ * The enum type representing the directive location values.
1285
+ *
1286
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1287
+ */
1289
1288
  });
1290
1289
 
1291
1290
  var kinds = createCommonjsModule(function (module, exports) {
@@ -1298,13 +1297,7 @@ exports.Kind = void 0;
1298
1297
  /**
1299
1298
  * The set of allowed kind values for AST nodes.
1300
1299
  */
1301
- let Kind;
1302
- /**
1303
- * The enum type representing the possible kind values of AST nodes.
1304
- *
1305
- * @deprecated Please use `Kind`. Will be remove in v17.
1306
- */
1307
-
1300
+ var Kind;
1308
1301
  exports.Kind = Kind;
1309
1302
 
1310
1303
  (function (Kind) {
@@ -1352,6 +1345,11 @@ exports.Kind = Kind;
1352
1345
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
1353
1346
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
1354
1347
  })(Kind || (exports.Kind = Kind = {}));
1348
+ /**
1349
+ * The enum type representing the possible kind values of AST nodes.
1350
+ *
1351
+ * @deprecated Please use `Kind`. Will be remove in v17.
1352
+ */
1355
1353
  });
1356
1354
 
1357
1355
  var characterClasses = createCommonjsModule(function (module, exports) {
@@ -1639,13 +1637,7 @@ exports.TokenKind = void 0;
1639
1637
  * An exported enum describing the different kinds of tokens that the
1640
1638
  * lexer emits.
1641
1639
  */
1642
- let TokenKind;
1643
- /**
1644
- * The enum type representing the token kinds values.
1645
- *
1646
- * @deprecated Please use `TokenKind`. Will be remove in v17.
1647
- */
1648
-
1640
+ var TokenKind;
1649
1641
  exports.TokenKind = TokenKind;
1650
1642
 
1651
1643
  (function (TokenKind) {
@@ -1672,6 +1664,11 @@ exports.TokenKind = TokenKind;
1672
1664
  TokenKind['BLOCK_STRING'] = 'BlockString';
1673
1665
  TokenKind['COMMENT'] = 'Comment';
1674
1666
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1667
+ /**
1668
+ * The enum type representing the token kinds values.
1669
+ *
1670
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
1671
+ */
1675
1672
  });
1676
1673
 
1677
1674
  var lexer = createCommonjsModule(function (module, exports) {
@@ -3008,12 +3005,13 @@ function parseType(source, options) {
3008
3005
  */
3009
3006
 
3010
3007
  class Parser {
3011
- constructor(source$1, options) {
3008
+ constructor(source$1, options = {}) {
3012
3009
  const sourceObj = (0, source.isSource)(source$1)
3013
3010
  ? source$1
3014
3011
  : new source.Source(source$1);
3015
3012
  this._lexer = new lexer.Lexer(sourceObj);
3016
3013
  this._options = options;
3014
+ this._tokenCounter = 0;
3017
3015
  }
3018
3016
  /**
3019
3017
  * Converts a name lex token into a name parse node.
@@ -3348,18 +3346,12 @@ class Parser {
3348
3346
  */
3349
3347
 
3350
3348
  parseFragmentDefinition() {
3351
- var _this$_options;
3352
-
3353
3349
  const start = this._lexer.token;
3354
3350
  this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
3355
3351
  // the grammar of FragmentDefinition:
3356
3352
  // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
3357
3353
 
3358
- if (
3359
- ((_this$_options = this._options) === null || _this$_options === void 0
3360
- ? void 0
3361
- : _this$_options.allowLegacyFragmentVariables) === true
3362
- ) {
3354
+ if (this._options.allowLegacyFragmentVariables === true) {
3363
3355
  return this.node(start, {
3364
3356
  kind: kinds.Kind.FRAGMENT_DEFINITION,
3365
3357
  name: this.parseFragmentName(),
@@ -3420,16 +3412,14 @@ class Parser {
3420
3412
  return this.parseObject(isConst);
3421
3413
 
3422
3414
  case tokenKind.TokenKind.INT:
3423
- this._lexer.advance();
3424
-
3415
+ this.advanceLexer();
3425
3416
  return this.node(token, {
3426
3417
  kind: kinds.Kind.INT,
3427
3418
  value: token.value,
3428
3419
  });
3429
3420
 
3430
3421
  case tokenKind.TokenKind.FLOAT:
3431
- this._lexer.advance();
3432
-
3422
+ this.advanceLexer();
3433
3423
  return this.node(token, {
3434
3424
  kind: kinds.Kind.FLOAT,
3435
3425
  value: token.value,
@@ -3440,7 +3430,7 @@ class Parser {
3440
3430
  return this.parseStringLiteral();
3441
3431
 
3442
3432
  case tokenKind.TokenKind.NAME:
3443
- this._lexer.advance();
3433
+ this.advanceLexer();
3444
3434
 
3445
3435
  switch (token.value) {
3446
3436
  case 'true':
@@ -3496,9 +3486,7 @@ class Parser {
3496
3486
 
3497
3487
  parseStringLiteral() {
3498
3488
  const token = this._lexer.token;
3499
-
3500
- this._lexer.advance();
3501
-
3489
+ this.advanceLexer();
3502
3490
  return this.node(token, {
3503
3491
  kind: kinds.Kind.STRING,
3504
3492
  value: token.value,
@@ -4289,13 +4277,7 @@ class Parser {
4289
4277
  */
4290
4278
 
4291
4279
  node(startToken, node) {
4292
- var _this$_options2;
4293
-
4294
- if (
4295
- ((_this$_options2 = this._options) === null || _this$_options2 === void 0
4296
- ? void 0
4297
- : _this$_options2.noLocation) !== true
4298
- ) {
4280
+ if (this._options.noLocation !== true) {
4299
4281
  node.loc = new ast.Location(
4300
4282
  startToken,
4301
4283
  this._lexer.lastToken,
@@ -4321,8 +4303,7 @@ class Parser {
4321
4303
  const token = this._lexer.token;
4322
4304
 
4323
4305
  if (token.kind === kind) {
4324
- this._lexer.advance();
4325
-
4306
+ this.advanceLexer();
4326
4307
  return token;
4327
4308
  }
4328
4309
 
@@ -4341,8 +4322,7 @@ class Parser {
4341
4322
  const token = this._lexer.token;
4342
4323
 
4343
4324
  if (token.kind === kind) {
4344
- this._lexer.advance();
4345
-
4325
+ this.advanceLexer();
4346
4326
  return true;
4347
4327
  }
4348
4328
 
@@ -4357,7 +4337,7 @@ class Parser {
4357
4337
  const token = this._lexer.token;
4358
4338
 
4359
4339
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4360
- this._lexer.advance();
4340
+ this.advanceLexer();
4361
4341
  } else {
4362
4342
  throw (0, syntaxError_1.syntaxError)(
4363
4343
  this._lexer.source,
@@ -4375,8 +4355,7 @@ class Parser {
4375
4355
  const token = this._lexer.token;
4376
4356
 
4377
4357
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4378
- this._lexer.advance();
4379
-
4358
+ this.advanceLexer();
4380
4359
  return true;
4381
4360
  }
4382
4361
 
@@ -4463,6 +4442,24 @@ class Parser {
4463
4442
 
4464
4443
  return nodes;
4465
4444
  }
4445
+
4446
+ advanceLexer() {
4447
+ const { maxTokens } = this._options;
4448
+
4449
+ const token = this._lexer.advance();
4450
+
4451
+ if (maxTokens !== undefined && token.kind !== tokenKind.TokenKind.EOF) {
4452
+ ++this._tokenCounter;
4453
+
4454
+ if (this._tokenCounter > maxTokens) {
4455
+ throw (0, syntaxError_1.syntaxError)(
4456
+ this._lexer.source,
4457
+ token.start,
4458
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`,
4459
+ );
4460
+ }
4461
+ }
4462
+ }
4466
4463
  }
4467
4464
  /**
4468
4465
  * A helper function to describe a token as a string for debugging.
@@ -6462,7 +6459,7 @@ class UrlUtils {
6462
6459
 
6463
6460
  class DataFetcher {
6464
6461
  constructor() {
6465
- this.GRAPHQL_PATH = window['applicationenv'] === "sankhyaom" ? "/mge/graphql" : "";
6462
+ this.GRAPHQL_PATH = "/mge/graphql";
6466
6463
  this.watingRequestsById = new Map();
6467
6464
  }
6468
6465
  static get() {
@@ -6695,6 +6692,7 @@ class WaitingRequest {
6695
6692
  class DataUnitFetcher {
6696
6693
  constructor() {
6697
6694
  this.templateByQuery = new Map();
6695
+ this._loadDataTimeout = {};
6698
6696
  this.buldTemplates();
6699
6697
  }
6700
6698
  buldTemplates() {
@@ -6723,9 +6721,9 @@ class DataUnitFetcher {
6723
6721
  }
6724
6722
  }
6725
6723
  }`);
6726
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6724
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6727
6725
  $queryAlias$: fetchDataUnit(name: $dataunit){
6728
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6726
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6729
6727
  limit
6730
6728
  offset
6731
6729
  total
@@ -6754,7 +6752,7 @@ class DataUnitFetcher {
6754
6752
  getDataUnit(entityName, resourceID) {
6755
6753
  const dataUnit = new core.DataUnit(`dd://${entityName}/${resourceID}`);
6756
6754
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6757
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6755
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6758
6756
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6759
6757
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6760
6758
  return dataUnit;
@@ -6791,25 +6789,39 @@ class DataUnitFetcher {
6791
6789
  });
6792
6790
  });
6793
6791
  }
6794
- loadData(dataUnit, page, sort, filter) {
6792
+ loadData(dataUnit, request) {
6793
+ const duName = dataUnit.name;
6794
+ if (this._loadDataTimeout[duName]) {
6795
+ clearTimeout(this._loadDataTimeout[duName]);
6796
+ delete this._loadDataTimeout[duName];
6797
+ }
6795
6798
  return new Promise((resolve, reject) => {
6796
- var _a, _b, _c;
6797
- const variables = { dataunit: dataUnit.name, sort, filter };
6798
- if (page) {
6799
- variables.limit = page.limit;
6800
- variables.offset = page.offset;
6801
- }
6802
- if (!core.StringUtils.isEmpty((_a = page === null || page === void 0 ? void 0 : page.quickFilter) === null || _a === void 0 ? void 0 : _a.term)) {
6799
+ this._loadDataTimeout[duName] = setTimeout(() => {
6800
+ delete this._loadDataTimeout[duName];
6801
+ this.doLoadData(dataUnit, request)
6802
+ .then(result => resolve(result))
6803
+ .catch(reason => reject(reason));
6804
+ }, 200);
6805
+ });
6806
+ }
6807
+ doLoadData(dataUnit, request) {
6808
+ return new Promise((resolve, reject) => {
6809
+ var _a;
6810
+ const { sort, filters, limit, offset, quickFilter } = request;
6811
+ const variables = { dataunit: dataUnit.name, sort, filters };
6812
+ variables.limit = limit;
6813
+ variables.offset = offset;
6814
+ if (!core.StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6803
6815
  if (variables.filter === undefined) {
6804
6816
  variables.filter = [];
6805
6817
  }
6806
6818
  const quickFilterCriteria = {
6807
6819
  name: "__QUICK_FILTER__",
6808
6820
  expression: "__QUICK_FILTER__",
6809
- params: [{ name: "term", dataType: core.DataType.TEXT, value: page.quickFilter.term }]
6821
+ params: [{ name: "term", dataType: core.DataType.TEXT, value: quickFilter.term }]
6810
6822
  };
6811
- if (((_c = (_b = page.quickFilter) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length) > 0) {
6812
- quickFilterCriteria.params.push({ name: "fields", dataType: core.DataType.OBJECT, value: page.quickFilter.fields });
6823
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6824
+ quickFilterCriteria.params.push({ name: "fields", dataType: core.DataType.OBJECT, value: quickFilter.fields });
6813
6825
  }
6814
6826
  variables.filter.push(quickFilterCriteria);
6815
6827
  }
@@ -6819,16 +6831,32 @@ class DataUnitFetcher {
6819
6831
  query: this.templateByQuery.get("fetchData"),
6820
6832
  })
6821
6833
  .then((resp) => {
6822
- const pageResult = resp.data;
6823
- const records = [];
6824
- pageResult.records.forEach((responseRecord) => {
6834
+ const { limit, offset, total, hasMore, records } = resp.data;
6835
+ let paginationInfo;
6836
+ if (limit) {
6837
+ const firstRecord = offset + 1;
6838
+ const lastRecord = offset + Math.min(records.length, limit);
6839
+ const currentPage = offset / limit;
6840
+ paginationInfo = {
6841
+ firstRecord,
6842
+ lastRecord,
6843
+ total,
6844
+ currentPage,
6845
+ hasMore
6846
+ };
6847
+ }
6848
+ const processedRecords = [];
6849
+ records.forEach((responseRecord) => {
6825
6850
  const duRecord = { __record__id__: responseRecord.id };
6826
6851
  responseRecord.fields.forEach(({ name, value }) => {
6827
6852
  duRecord[name] = dataUnit.valueFromString(name, value);
6828
6853
  });
6829
- records.push(duRecord);
6854
+ processedRecords.push(duRecord);
6855
+ });
6856
+ resolve({
6857
+ paginationInfo,
6858
+ records: processedRecords
6830
6859
  });
6831
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6832
6860
  })
6833
6861
  .catch((error) => {
6834
6862
  reject(error);
@@ -7054,15 +7082,16 @@ class GridConfigFetcher extends ResourceFetcher {
7054
7082
  super(...arguments);
7055
7083
  this.GRID_CONFIG_VERSION = "V3:";
7056
7084
  }
7057
- getConfig(resourceID) {
7085
+ getConfig(_gridName, resourceID) {
7058
7086
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7059
7087
  return new Promise((resolve, reject) => {
7060
7088
  this.loadResource(completePath)
7061
7089
  .then(loadedResource => {
7090
+ let config = undefined;
7062
7091
  if (loadedResource) {
7063
- let config = JSON.parse(loadedResource);
7064
- resolve(config);
7092
+ config = JSON.parse(loadedResource);
7065
7093
  }
7094
+ resolve(config);
7066
7095
  }).catch((error) => {
7067
7096
  reject(error);
7068
7097
  });
@@ -7097,6 +7126,8 @@ class PesquisaFetcher {
7097
7126
  }`);
7098
7127
  }
7099
7128
  loadSearchOptions(entityName, argument, criteria, options) {
7129
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7130
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7100
7131
  return new Promise((resolve, reject) => {
7101
7132
  DataFetcher.get()
7102
7133
  .callGraphQL({
@@ -7237,7 +7268,7 @@ class SnkErrorHandler {
7237
7268
  }
7238
7269
  else {
7239
7270
  const title = (exception === null || exception === void 0 ? void 0 : exception.title) || "Erro detectado";
7240
- const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${exception}"`;
7271
+ const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${core.ObjectUtils.objectToString(exception)}"`;
7241
7272
  this._app.error(title, message);
7242
7273
  }
7243
7274
  }
@@ -7255,6 +7286,9 @@ const SnkApplication = class {
7255
7286
  index.registerInstance(this, hostRef);
7256
7287
  this.applicationLoaded = index.createEvent(this, "applicationLoaded", 7);
7257
7288
  this.applicationLoading = index.createEvent(this, "applicationLoading", 7);
7289
+ this._authPromises = [];
7290
+ this._duCache = new Map();
7291
+ this._duPromises = new Map();
7258
7292
  this._requestListener = new RequestListenerLoadingBar();
7259
7293
  }
7260
7294
  get parameters() {
@@ -7273,18 +7307,31 @@ const SnkApplication = class {
7273
7307
  return this._resourceID;
7274
7308
  }
7275
7309
  get auth() {
7276
- return new Promise((resolve, reject) => {
7277
- if (this._auth) {
7278
- resolve(this._auth);
7279
- }
7280
- else {
7281
- this.authFetcher.getData(this._resourceID).then((authList) => {
7282
- this._auth = authList;
7283
- resolve(authList);
7284
- }).catch(error => reject(error));
7285
- }
7286
- });
7310
+ if (this._auth) {
7311
+ return Promise.resolve(this._auth);
7312
+ }
7313
+ else {
7314
+ return new Promise((resolve, reject) => {
7315
+ const waitingAuth = this._authPromises.length > 0;
7316
+ this._authPromises.push(new PendingPromise(resolve, reject));
7317
+ if (!waitingAuth) {
7318
+ this.authFetcher.getData(this._resourceID).then((authList) => {
7319
+ this._auth = authList;
7320
+ while (this._authPromises.length > 0) {
7321
+ this._authPromises.pop().resolve(this._auth);
7322
+ }
7323
+ }).catch(error => {
7324
+ while (this._authPromises.length > 0) {
7325
+ this._authPromises.pop().reject(error);
7326
+ }
7327
+ });
7328
+ }
7329
+ });
7330
+ }
7287
7331
  }
7332
+ /**
7333
+ * Caso o usuário logado seja o SUP.
7334
+ */
7288
7335
  async isUserSup() {
7289
7336
  return new Promise((resolve, reject) => {
7290
7337
  this.auth.then((authorization) => {
@@ -7294,6 +7341,9 @@ const SnkApplication = class {
7294
7341
  });
7295
7342
  });
7296
7343
  }
7344
+ /**
7345
+ * Se o usuário logado tem permissão pra determinada ação.
7346
+ */
7297
7347
  async hasAccess(access) {
7298
7348
  return new Promise((resolve, reject) => {
7299
7349
  this.auth.then((authorization) => {
@@ -7303,6 +7353,9 @@ const SnkApplication = class {
7303
7353
  });
7304
7354
  });
7305
7355
  }
7356
+ /**
7357
+ * Retorna todos os acessos do usuário logado.
7358
+ */
7306
7359
  async getAllAccess() {
7307
7360
  return new Promise((resolve, reject) => {
7308
7361
  this.auth.then((authorization) => {
@@ -7317,34 +7370,54 @@ const SnkApplication = class {
7317
7370
  });
7318
7371
  });
7319
7372
  }
7320
- async getAuthList(_auth) {
7321
- return await (new MGEAuthorization()).parseFromJSON(_auth);
7322
- }
7373
+ /**
7374
+ * Retorna o valor de um parâmetro do tipo string.
7375
+ */
7323
7376
  async getStringParam(name) {
7324
7377
  return this.parameters.asString(name, this.resourceID);
7325
7378
  }
7379
+ /**
7380
+ * Retorna o valor de um parâmetro do tipo Inteiro.
7381
+ */
7326
7382
  async getIntParam(name) {
7327
7383
  return this.parameters.asInteger(name, this.resourceID);
7328
7384
  }
7385
+ /**
7386
+ * Retorna o valor de um parâmetro do tipo Decimal.
7387
+ */
7329
7388
  async getFloatParam(name) {
7330
7389
  return this.parameters.asFloat(name, this.resourceID);
7331
7390
  }
7391
+ /**
7392
+ * Retorna o valor de um parâmetro do tipo booleano.
7393
+ */
7332
7394
  async getBooleanParam(name) {
7333
7395
  return this.parameters.asBoolean(name, this.resourceID);
7334
7396
  }
7397
+ /**
7398
+ * Retorna o valor de um parâmetro do tipo data.
7399
+ */
7335
7400
  async getDateParam(name) {
7336
7401
  return this.parameters.asDate(name, this.resourceID);
7337
7402
  }
7403
+ /**
7404
+ * Mostra o conteúdo passado em um Popup
7405
+ */
7338
7406
  async showPopUp(content) {
7407
+ this.clearPopUpContent();
7339
7408
  this._popUp.appendChild(content);
7340
- this._popUp["opened"] = true;
7409
+ this._popUp.opened = true;
7341
7410
  }
7411
+ /**
7412
+ * Fecha o popup, liberando o conteúdo.
7413
+ */
7342
7414
  async closePopUp() {
7343
- Array.from(this._popUp.children).forEach(c => {
7344
- this._popUp.removeChild(c);
7345
- });
7346
- this._popUp["opened"] = false;
7415
+ this.clearPopUpContent();
7416
+ this._popUp.opened = false;
7347
7417
  }
7418
+ /**
7419
+ * Verifica se a licença do cliente tem determinado opcional (produto)
7420
+ */
7348
7421
  async temOpcional(opcional) {
7349
7422
  const opts = opcional.split(",");
7350
7423
  return new Promise((resolve, reject) => {
@@ -7368,6 +7441,10 @@ const SnkApplication = class {
7368
7441
  });
7369
7442
  });
7370
7443
  }
7444
+ /**
7445
+ * Retorna a configuração de um recurso por service broker
7446
+ * Veja também o método "loadConfig"
7447
+ */
7371
7448
  async getConfig(key) {
7372
7449
  let payload = {
7373
7450
  "serviceName": "SystemUtilsSP.getConf",
@@ -7385,6 +7462,9 @@ const SnkApplication = class {
7385
7462
  .catch(error => reject(error));
7386
7463
  });
7387
7464
  }
7465
+ /**
7466
+ * Salva a configuração de determinado recurso.
7467
+ */
7388
7468
  async saveConfig(key, data) {
7389
7469
  let payload = {
7390
7470
  "serviceName": "SystemUtilsSP.saveConf",
@@ -7403,42 +7483,122 @@ const SnkApplication = class {
7403
7483
  .catch(error => reject(error));
7404
7484
  });
7405
7485
  }
7486
+ /**
7487
+ * Acessa informações de contexto "empurrados" na abertura da tela
7488
+ */
7406
7489
  async getAttributeFromHTMLWrapper(attribName) {
7407
7490
  return Promise.resolve(window[attribName]);
7408
7491
  }
7492
+ /**
7493
+ * Abre determinada tela, repassando pkObject
7494
+ */
7409
7495
  async openApp(resourceId, pkObject) {
7410
7496
  Workspace.openAppActivity(resourceId, pkObject);
7411
7497
  }
7412
- async createDataunit(entityName) {
7413
- return new Promise(resolve => {
7414
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7415
- dataUnit.loadMetadata().then(() => resolve(dataUnit));
7498
+ getDuPromissesStack(dataUnitName) {
7499
+ let stack;
7500
+ if (dataUnitName) {
7501
+ stack = this._duPromises.get(dataUnitName);
7502
+ if (!stack) {
7503
+ stack = [];
7504
+ this._duPromises.set(dataUnitName, stack);
7505
+ }
7506
+ }
7507
+ return stack || [];
7508
+ }
7509
+ /**
7510
+ * Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
7511
+ * passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado
7512
+ */
7513
+ async createDataunit(entityName, dataUnitName) {
7514
+ return new Promise((resolve, reject) => {
7515
+ const duPromisses = this.getDuPromissesStack(dataUnitName);
7516
+ const waitingDu = duPromisses.length > 0;
7517
+ duPromisses.push(new PendingPromise(resolve, reject));
7518
+ if (!waitingDu) {
7519
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7520
+ dataUnit.loadMetadata().then(() => {
7521
+ if (dataUnitName) {
7522
+ this._duCache.set(dataUnitName, dataUnit);
7523
+ }
7524
+ while (duPromisses.length > 0) {
7525
+ duPromisses.pop().resolve(dataUnit);
7526
+ }
7527
+ }).catch(reason => {
7528
+ while (duPromisses.length > 0) {
7529
+ duPromisses.pop().reject(reason);
7530
+ }
7531
+ });
7532
+ }
7533
+ });
7534
+ }
7535
+ /**
7536
+ * Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
7537
+ */
7538
+ async getDataUnit(entityName, dataUnitName) {
7539
+ return new Promise((resolve, reject) => {
7540
+ const dataUnit = this._duCache.get(dataUnitName);
7541
+ if (dataUnit) {
7542
+ resolve(dataUnit);
7543
+ }
7544
+ else {
7545
+ this.createDataunit(entityName, dataUnitName).then(dataUnit => {
7546
+ resolve(dataUnit);
7547
+ }).catch(reason => reject(reason));
7548
+ }
7416
7549
  });
7417
7550
  }
7551
+ /**
7552
+ * Retorna o resourceID da tela em questão.
7553
+ */
7418
7554
  async getResourceID() {
7419
7555
  return Promise.resolve(this.resourceID);
7420
7556
  }
7557
+ /**
7558
+ * Mostra o diálogo de alerta de acordo com os parâmetros passados.
7559
+ */
7421
7560
  async alert(title, message, icon, options) {
7422
7561
  return utils.ApplicationUtils.alert(title, message, icon, options);
7423
7562
  }
7563
+ /**
7564
+ * Mostra o diálogo de erro de acordo com os parâmetros passados.
7565
+ */
7424
7566
  async error(title, message, icon, options) {
7425
7567
  return utils.ApplicationUtils.error(title, message, icon, options);
7426
7568
  }
7569
+ /**
7570
+ * Exibe um diálogo de confirmação
7571
+ */
7427
7572
  async confirm(title, message, icon, critical, options) {
7428
7573
  return utils.ApplicationUtils.confirm(title, message, icon, critical, options);
7429
7574
  }
7575
+ /**
7576
+ * Mostra uma informação efêmera (de segundo plano).
7577
+ */
7430
7578
  async info(message, options) {
7431
7579
  return utils.ApplicationUtils.info(message, options);
7432
7580
  }
7581
+ /**
7582
+ * Busca a configuração de formulário.
7583
+ */
7433
7584
  async loadFormConfig(name) {
7434
7585
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7435
7586
  }
7436
- async loadGridConfig() {
7437
- return this.gridConfigFetcher.getConfig(this.resourceID);
7587
+ /**
7588
+ * Busca a configuração de grade.
7589
+ */
7590
+ async loadGridConfig(name) {
7591
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7438
7592
  }
7593
+ /**
7594
+ * Salva a configuração de grade.
7595
+ */
7439
7596
  async saveGridConfig(config) {
7440
7597
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7441
7598
  }
7599
+ async getAuthList(_auth) {
7600
+ return await (new MGEAuthorization()).parseFromJSON(_auth);
7601
+ }
7442
7602
  get urlParams() {
7443
7603
  if (!this._urlParams) {
7444
7604
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7491,7 +7651,7 @@ const SnkApplication = class {
7491
7651
  };
7492
7652
  dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => { var _a; return (_a = dep.masterFields) === null || _a === void 0 ? void 0 : _a.every(f => { var _a; return (_a = dataUnit.getField(f)) === null || _a === void 0 ? void 0 : _a.visible; }); }).forEach(dependency => {
7493
7653
  var _a;
7494
- if (dependency.type === UnitMetadata.DependencyType.SEARCHING) {
7654
+ if (dependency.type === core.DependencyType.SEARCHING) {
7495
7655
  if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
7496
7656
  criteria = {
7497
7657
  expression: dependency.expression,
@@ -7516,7 +7676,7 @@ const SnkApplication = class {
7516
7676
  pesquisaContent.searchLoader = (text) => this.pesquisaFetcher.loadAdvancedSearch(ENTITYNAME, text, criteria, searchOptions);
7517
7677
  pesquisaContent.selectItem = (option) => {
7518
7678
  accept(option);
7519
- this.cleanPopUpTitle();
7679
+ this.clearPopUpTitle();
7520
7680
  this.closePopUp();
7521
7681
  };
7522
7682
  this.setPopUpTitle(DESCRIPTIONENTITY);
@@ -7533,14 +7693,22 @@ const SnkApplication = class {
7533
7693
  accept(window['isDebugMode']);
7534
7694
  });
7535
7695
  }
7536
- cleanPopUpTitle() {
7537
- this._popUp['ezTitle'] = "";
7696
+ clearPopUpContent() {
7697
+ if (this._popUp) {
7698
+ Array.from(this._popUp.children).forEach(c => {
7699
+ this._popUp.removeChild(c);
7700
+ });
7701
+ }
7702
+ }
7703
+ clearPopUpTitle() {
7704
+ this._popUp.ezTitle = "";
7538
7705
  }
7539
7706
  setPopUpTitle(title) {
7540
- this._popUp['ezTitle'] = title;
7707
+ this._popUp.ezTitle = title;
7541
7708
  }
7542
7709
  componentWillLoad() {
7543
7710
  this._errorHandler = new SnkErrorHandler(this);
7711
+ this.messagesBuilder = new SnkMessageBuilder.SnkMessageBuilder();
7544
7712
  core.ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
7545
7713
  core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7546
7714
  return this.executeSearch(searchArgument, fieldName, dataUnit);
@@ -7549,6 +7717,7 @@ const SnkApplication = class {
7549
7717
  core.ErrorTracking.init();
7550
7718
  }
7551
7719
  connectedCallback() {
7720
+ core.ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7552
7721
  DataFetcher.addRequestListener(this._requestListener);
7553
7722
  }
7554
7723
  disconnectedCallback() {
@@ -7587,6 +7756,12 @@ class RequestListenerLoadingBar {
7587
7756
  }
7588
7757
  ;
7589
7758
  }
7759
+ class PendingPromise {
7760
+ constructor(resolve, reject) {
7761
+ this.resolve = resolve;
7762
+ this.reject = reject;
7763
+ }
7764
+ }
7590
7765
  SnkApplication.style = snkApplicationCss;
7591
7766
 
7592
7767
  exports.snk_application = SnkApplication;