@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
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, DependencyType, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { DependencyType } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
4
+ import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
5
5
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -1233,7 +1233,7 @@ function isNode(maybeNode) {
1233
1233
  }
1234
1234
  /** Name */
1235
1235
 
1236
- let OperationTypeNode;
1236
+ var OperationTypeNode;
1237
1237
  exports.OperationTypeNode = OperationTypeNode;
1238
1238
 
1239
1239
  (function (OperationTypeNode) {
@@ -1253,13 +1253,7 @@ exports.DirectiveLocation = void 0;
1253
1253
  /**
1254
1254
  * The set of allowed directive location values.
1255
1255
  */
1256
- let DirectiveLocation;
1257
- /**
1258
- * The enum type representing the directive location values.
1259
- *
1260
- * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1261
- */
1262
-
1256
+ var DirectiveLocation;
1263
1257
  exports.DirectiveLocation = DirectiveLocation;
1264
1258
 
1265
1259
  (function (DirectiveLocation) {
@@ -1283,6 +1277,11 @@ exports.DirectiveLocation = DirectiveLocation;
1283
1277
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
1284
1278
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
1285
1279
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1280
+ /**
1281
+ * The enum type representing the directive location values.
1282
+ *
1283
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1284
+ */
1286
1285
  });
1287
1286
 
1288
1287
  var kinds = createCommonjsModule(function (module, exports) {
@@ -1295,13 +1294,7 @@ exports.Kind = void 0;
1295
1294
  /**
1296
1295
  * The set of allowed kind values for AST nodes.
1297
1296
  */
1298
- let Kind;
1299
- /**
1300
- * The enum type representing the possible kind values of AST nodes.
1301
- *
1302
- * @deprecated Please use `Kind`. Will be remove in v17.
1303
- */
1304
-
1297
+ var Kind;
1305
1298
  exports.Kind = Kind;
1306
1299
 
1307
1300
  (function (Kind) {
@@ -1349,6 +1342,11 @@ exports.Kind = Kind;
1349
1342
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
1350
1343
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
1351
1344
  })(Kind || (exports.Kind = Kind = {}));
1345
+ /**
1346
+ * The enum type representing the possible kind values of AST nodes.
1347
+ *
1348
+ * @deprecated Please use `Kind`. Will be remove in v17.
1349
+ */
1352
1350
  });
1353
1351
 
1354
1352
  var characterClasses = createCommonjsModule(function (module, exports) {
@@ -1636,13 +1634,7 @@ exports.TokenKind = void 0;
1636
1634
  * An exported enum describing the different kinds of tokens that the
1637
1635
  * lexer emits.
1638
1636
  */
1639
- let TokenKind;
1640
- /**
1641
- * The enum type representing the token kinds values.
1642
- *
1643
- * @deprecated Please use `TokenKind`. Will be remove in v17.
1644
- */
1645
-
1637
+ var TokenKind;
1646
1638
  exports.TokenKind = TokenKind;
1647
1639
 
1648
1640
  (function (TokenKind) {
@@ -1669,6 +1661,11 @@ exports.TokenKind = TokenKind;
1669
1661
  TokenKind['BLOCK_STRING'] = 'BlockString';
1670
1662
  TokenKind['COMMENT'] = 'Comment';
1671
1663
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1664
+ /**
1665
+ * The enum type representing the token kinds values.
1666
+ *
1667
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
1668
+ */
1672
1669
  });
1673
1670
 
1674
1671
  var lexer = createCommonjsModule(function (module, exports) {
@@ -3005,12 +3002,13 @@ function parseType(source, options) {
3005
3002
  */
3006
3003
 
3007
3004
  class Parser {
3008
- constructor(source$1, options) {
3005
+ constructor(source$1, options = {}) {
3009
3006
  const sourceObj = (0, source.isSource)(source$1)
3010
3007
  ? source$1
3011
3008
  : new source.Source(source$1);
3012
3009
  this._lexer = new lexer.Lexer(sourceObj);
3013
3010
  this._options = options;
3011
+ this._tokenCounter = 0;
3014
3012
  }
3015
3013
  /**
3016
3014
  * Converts a name lex token into a name parse node.
@@ -3345,18 +3343,12 @@ class Parser {
3345
3343
  */
3346
3344
 
3347
3345
  parseFragmentDefinition() {
3348
- var _this$_options;
3349
-
3350
3346
  const start = this._lexer.token;
3351
3347
  this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
3352
3348
  // the grammar of FragmentDefinition:
3353
3349
  // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
3354
3350
 
3355
- if (
3356
- ((_this$_options = this._options) === null || _this$_options === void 0
3357
- ? void 0
3358
- : _this$_options.allowLegacyFragmentVariables) === true
3359
- ) {
3351
+ if (this._options.allowLegacyFragmentVariables === true) {
3360
3352
  return this.node(start, {
3361
3353
  kind: kinds.Kind.FRAGMENT_DEFINITION,
3362
3354
  name: this.parseFragmentName(),
@@ -3417,16 +3409,14 @@ class Parser {
3417
3409
  return this.parseObject(isConst);
3418
3410
 
3419
3411
  case tokenKind.TokenKind.INT:
3420
- this._lexer.advance();
3421
-
3412
+ this.advanceLexer();
3422
3413
  return this.node(token, {
3423
3414
  kind: kinds.Kind.INT,
3424
3415
  value: token.value,
3425
3416
  });
3426
3417
 
3427
3418
  case tokenKind.TokenKind.FLOAT:
3428
- this._lexer.advance();
3429
-
3419
+ this.advanceLexer();
3430
3420
  return this.node(token, {
3431
3421
  kind: kinds.Kind.FLOAT,
3432
3422
  value: token.value,
@@ -3437,7 +3427,7 @@ class Parser {
3437
3427
  return this.parseStringLiteral();
3438
3428
 
3439
3429
  case tokenKind.TokenKind.NAME:
3440
- this._lexer.advance();
3430
+ this.advanceLexer();
3441
3431
 
3442
3432
  switch (token.value) {
3443
3433
  case 'true':
@@ -3493,9 +3483,7 @@ class Parser {
3493
3483
 
3494
3484
  parseStringLiteral() {
3495
3485
  const token = this._lexer.token;
3496
-
3497
- this._lexer.advance();
3498
-
3486
+ this.advanceLexer();
3499
3487
  return this.node(token, {
3500
3488
  kind: kinds.Kind.STRING,
3501
3489
  value: token.value,
@@ -4286,13 +4274,7 @@ class Parser {
4286
4274
  */
4287
4275
 
4288
4276
  node(startToken, node) {
4289
- var _this$_options2;
4290
-
4291
- if (
4292
- ((_this$_options2 = this._options) === null || _this$_options2 === void 0
4293
- ? void 0
4294
- : _this$_options2.noLocation) !== true
4295
- ) {
4277
+ if (this._options.noLocation !== true) {
4296
4278
  node.loc = new ast.Location(
4297
4279
  startToken,
4298
4280
  this._lexer.lastToken,
@@ -4318,8 +4300,7 @@ class Parser {
4318
4300
  const token = this._lexer.token;
4319
4301
 
4320
4302
  if (token.kind === kind) {
4321
- this._lexer.advance();
4322
-
4303
+ this.advanceLexer();
4323
4304
  return token;
4324
4305
  }
4325
4306
 
@@ -4338,8 +4319,7 @@ class Parser {
4338
4319
  const token = this._lexer.token;
4339
4320
 
4340
4321
  if (token.kind === kind) {
4341
- this._lexer.advance();
4342
-
4322
+ this.advanceLexer();
4343
4323
  return true;
4344
4324
  }
4345
4325
 
@@ -4354,7 +4334,7 @@ class Parser {
4354
4334
  const token = this._lexer.token;
4355
4335
 
4356
4336
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4357
- this._lexer.advance();
4337
+ this.advanceLexer();
4358
4338
  } else {
4359
4339
  throw (0, syntaxError_1.syntaxError)(
4360
4340
  this._lexer.source,
@@ -4372,8 +4352,7 @@ class Parser {
4372
4352
  const token = this._lexer.token;
4373
4353
 
4374
4354
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4375
- this._lexer.advance();
4376
-
4355
+ this.advanceLexer();
4377
4356
  return true;
4378
4357
  }
4379
4358
 
@@ -4460,6 +4439,24 @@ class Parser {
4460
4439
 
4461
4440
  return nodes;
4462
4441
  }
4442
+
4443
+ advanceLexer() {
4444
+ const { maxTokens } = this._options;
4445
+
4446
+ const token = this._lexer.advance();
4447
+
4448
+ if (maxTokens !== undefined && token.kind !== tokenKind.TokenKind.EOF) {
4449
+ ++this._tokenCounter;
4450
+
4451
+ if (this._tokenCounter > maxTokens) {
4452
+ throw (0, syntaxError_1.syntaxError)(
4453
+ this._lexer.source,
4454
+ token.start,
4455
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`,
4456
+ );
4457
+ }
4458
+ }
4459
+ }
4463
4460
  }
4464
4461
  /**
4465
4462
  * A helper function to describe a token as a string for debugging.
@@ -6459,7 +6456,7 @@ class UrlUtils {
6459
6456
 
6460
6457
  class DataFetcher {
6461
6458
  constructor() {
6462
- this.GRAPHQL_PATH = window['applicationenv'] === "sankhyaom" ? "/mge/graphql" : "";
6459
+ this.GRAPHQL_PATH = "/mge/graphql";
6463
6460
  this.watingRequestsById = new Map();
6464
6461
  }
6465
6462
  static get() {
@@ -6692,6 +6689,7 @@ class WaitingRequest {
6692
6689
  class DataUnitFetcher {
6693
6690
  constructor() {
6694
6691
  this.templateByQuery = new Map();
6692
+ this._loadDataTimeout = {};
6695
6693
  this.buldTemplates();
6696
6694
  }
6697
6695
  buldTemplates() {
@@ -6720,9 +6718,9 @@ class DataUnitFetcher {
6720
6718
  }
6721
6719
  }
6722
6720
  }`);
6723
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6721
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6724
6722
  $queryAlias$: fetchDataUnit(name: $dataunit){
6725
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6723
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6726
6724
  limit
6727
6725
  offset
6728
6726
  total
@@ -6751,7 +6749,7 @@ class DataUnitFetcher {
6751
6749
  getDataUnit(entityName, resourceID) {
6752
6750
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6753
6751
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6754
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6752
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6755
6753
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6756
6754
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6757
6755
  return dataUnit;
@@ -6788,25 +6786,39 @@ class DataUnitFetcher {
6788
6786
  });
6789
6787
  });
6790
6788
  }
6791
- loadData(dataUnit, page, sort, filter) {
6789
+ loadData(dataUnit, request) {
6790
+ const duName = dataUnit.name;
6791
+ if (this._loadDataTimeout[duName]) {
6792
+ clearTimeout(this._loadDataTimeout[duName]);
6793
+ delete this._loadDataTimeout[duName];
6794
+ }
6792
6795
  return new Promise((resolve, reject) => {
6793
- var _a, _b, _c;
6794
- const variables = { dataunit: dataUnit.name, sort, filter };
6795
- if (page) {
6796
- variables.limit = page.limit;
6797
- variables.offset = page.offset;
6798
- }
6799
- if (!StringUtils.isEmpty((_a = page === null || page === void 0 ? void 0 : page.quickFilter) === null || _a === void 0 ? void 0 : _a.term)) {
6796
+ this._loadDataTimeout[duName] = setTimeout(() => {
6797
+ delete this._loadDataTimeout[duName];
6798
+ this.doLoadData(dataUnit, request)
6799
+ .then(result => resolve(result))
6800
+ .catch(reason => reject(reason));
6801
+ }, 200);
6802
+ });
6803
+ }
6804
+ doLoadData(dataUnit, request) {
6805
+ return new Promise((resolve, reject) => {
6806
+ var _a;
6807
+ const { sort, filters, limit, offset, quickFilter } = request;
6808
+ const variables = { dataunit: dataUnit.name, sort, filters };
6809
+ variables.limit = limit;
6810
+ variables.offset = offset;
6811
+ if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6800
6812
  if (variables.filter === undefined) {
6801
6813
  variables.filter = [];
6802
6814
  }
6803
6815
  const quickFilterCriteria = {
6804
6816
  name: "__QUICK_FILTER__",
6805
6817
  expression: "__QUICK_FILTER__",
6806
- params: [{ name: "term", dataType: DataType.TEXT, value: page.quickFilter.term }]
6818
+ params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
6807
6819
  };
6808
- if (((_c = (_b = page.quickFilter) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length) > 0) {
6809
- quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: page.quickFilter.fields });
6820
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6821
+ quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
6810
6822
  }
6811
6823
  variables.filter.push(quickFilterCriteria);
6812
6824
  }
@@ -6816,16 +6828,32 @@ class DataUnitFetcher {
6816
6828
  query: this.templateByQuery.get("fetchData"),
6817
6829
  })
6818
6830
  .then((resp) => {
6819
- const pageResult = resp.data;
6820
- const records = [];
6821
- pageResult.records.forEach((responseRecord) => {
6831
+ const { limit, offset, total, hasMore, records } = resp.data;
6832
+ let paginationInfo;
6833
+ if (limit) {
6834
+ const firstRecord = offset + 1;
6835
+ const lastRecord = offset + Math.min(records.length, limit);
6836
+ const currentPage = offset / limit;
6837
+ paginationInfo = {
6838
+ firstRecord,
6839
+ lastRecord,
6840
+ total,
6841
+ currentPage,
6842
+ hasMore
6843
+ };
6844
+ }
6845
+ const processedRecords = [];
6846
+ records.forEach((responseRecord) => {
6822
6847
  const duRecord = { __record__id__: responseRecord.id };
6823
6848
  responseRecord.fields.forEach(({ name, value }) => {
6824
6849
  duRecord[name] = dataUnit.valueFromString(name, value);
6825
6850
  });
6826
- records.push(duRecord);
6851
+ processedRecords.push(duRecord);
6852
+ });
6853
+ resolve({
6854
+ paginationInfo,
6855
+ records: processedRecords
6827
6856
  });
6828
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6829
6857
  })
6830
6858
  .catch((error) => {
6831
6859
  reject(error);
@@ -7051,15 +7079,16 @@ class GridConfigFetcher extends ResourceFetcher {
7051
7079
  super(...arguments);
7052
7080
  this.GRID_CONFIG_VERSION = "V3:";
7053
7081
  }
7054
- getConfig(resourceID) {
7082
+ getConfig(_gridName, resourceID) {
7055
7083
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7056
7084
  return new Promise((resolve, reject) => {
7057
7085
  this.loadResource(completePath)
7058
7086
  .then(loadedResource => {
7087
+ let config = undefined;
7059
7088
  if (loadedResource) {
7060
- let config = JSON.parse(loadedResource);
7061
- resolve(config);
7089
+ config = JSON.parse(loadedResource);
7062
7090
  }
7091
+ resolve(config);
7063
7092
  }).catch((error) => {
7064
7093
  reject(error);
7065
7094
  });
@@ -7094,6 +7123,8 @@ class PesquisaFetcher {
7094
7123
  }`);
7095
7124
  }
7096
7125
  loadSearchOptions(entityName, argument, criteria, options) {
7126
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7127
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7097
7128
  return new Promise((resolve, reject) => {
7098
7129
  DataFetcher.get()
7099
7130
  .callGraphQL({
@@ -7234,7 +7265,7 @@ class SnkErrorHandler {
7234
7265
  }
7235
7266
  else {
7236
7267
  const title = (exception === null || exception === void 0 ? void 0 : exception.title) || "Erro detectado";
7237
- const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${exception}"`;
7268
+ const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${ObjectUtils.objectToString(exception)}"`;
7238
7269
  this._app.error(title, message);
7239
7270
  }
7240
7271
  }
@@ -7253,6 +7284,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7253
7284
  this.__registerHost();
7254
7285
  this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
7255
7286
  this.applicationLoading = createEvent(this, "applicationLoading", 7);
7287
+ this._authPromises = [];
7288
+ this._duCache = new Map();
7289
+ this._duPromises = new Map();
7256
7290
  this._requestListener = new RequestListenerLoadingBar();
7257
7291
  }
7258
7292
  get parameters() {
@@ -7271,18 +7305,31 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7271
7305
  return this._resourceID;
7272
7306
  }
7273
7307
  get auth() {
7274
- return new Promise((resolve, reject) => {
7275
- if (this._auth) {
7276
- resolve(this._auth);
7277
- }
7278
- else {
7279
- this.authFetcher.getData(this._resourceID).then((authList) => {
7280
- this._auth = authList;
7281
- resolve(authList);
7282
- }).catch(error => reject(error));
7283
- }
7284
- });
7308
+ if (this._auth) {
7309
+ return Promise.resolve(this._auth);
7310
+ }
7311
+ else {
7312
+ return new Promise((resolve, reject) => {
7313
+ const waitingAuth = this._authPromises.length > 0;
7314
+ this._authPromises.push(new PendingPromise(resolve, reject));
7315
+ if (!waitingAuth) {
7316
+ this.authFetcher.getData(this._resourceID).then((authList) => {
7317
+ this._auth = authList;
7318
+ while (this._authPromises.length > 0) {
7319
+ this._authPromises.pop().resolve(this._auth);
7320
+ }
7321
+ }).catch(error => {
7322
+ while (this._authPromises.length > 0) {
7323
+ this._authPromises.pop().reject(error);
7324
+ }
7325
+ });
7326
+ }
7327
+ });
7328
+ }
7285
7329
  }
7330
+ /**
7331
+ * Caso o usuário logado seja o SUP.
7332
+ */
7286
7333
  async isUserSup() {
7287
7334
  return new Promise((resolve, reject) => {
7288
7335
  this.auth.then((authorization) => {
@@ -7292,6 +7339,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7292
7339
  });
7293
7340
  });
7294
7341
  }
7342
+ /**
7343
+ * Se o usuário logado tem permissão pra determinada ação.
7344
+ */
7295
7345
  async hasAccess(access) {
7296
7346
  return new Promise((resolve, reject) => {
7297
7347
  this.auth.then((authorization) => {
@@ -7301,6 +7351,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7301
7351
  });
7302
7352
  });
7303
7353
  }
7354
+ /**
7355
+ * Retorna todos os acessos do usuário logado.
7356
+ */
7304
7357
  async getAllAccess() {
7305
7358
  return new Promise((resolve, reject) => {
7306
7359
  this.auth.then((authorization) => {
@@ -7315,34 +7368,54 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7315
7368
  });
7316
7369
  });
7317
7370
  }
7318
- async getAuthList(_auth) {
7319
- return await (new MGEAuthorization()).parseFromJSON(_auth);
7320
- }
7371
+ /**
7372
+ * Retorna o valor de um parâmetro do tipo string.
7373
+ */
7321
7374
  async getStringParam(name) {
7322
7375
  return this.parameters.asString(name, this.resourceID);
7323
7376
  }
7377
+ /**
7378
+ * Retorna o valor de um parâmetro do tipo Inteiro.
7379
+ */
7324
7380
  async getIntParam(name) {
7325
7381
  return this.parameters.asInteger(name, this.resourceID);
7326
7382
  }
7383
+ /**
7384
+ * Retorna o valor de um parâmetro do tipo Decimal.
7385
+ */
7327
7386
  async getFloatParam(name) {
7328
7387
  return this.parameters.asFloat(name, this.resourceID);
7329
7388
  }
7389
+ /**
7390
+ * Retorna o valor de um parâmetro do tipo booleano.
7391
+ */
7330
7392
  async getBooleanParam(name) {
7331
7393
  return this.parameters.asBoolean(name, this.resourceID);
7332
7394
  }
7395
+ /**
7396
+ * Retorna o valor de um parâmetro do tipo data.
7397
+ */
7333
7398
  async getDateParam(name) {
7334
7399
  return this.parameters.asDate(name, this.resourceID);
7335
7400
  }
7401
+ /**
7402
+ * Mostra o conteúdo passado em um Popup
7403
+ */
7336
7404
  async showPopUp(content) {
7405
+ this.clearPopUpContent();
7337
7406
  this._popUp.appendChild(content);
7338
- this._popUp["opened"] = true;
7407
+ this._popUp.opened = true;
7339
7408
  }
7409
+ /**
7410
+ * Fecha o popup, liberando o conteúdo.
7411
+ */
7340
7412
  async closePopUp() {
7341
- Array.from(this._popUp.children).forEach(c => {
7342
- this._popUp.removeChild(c);
7343
- });
7344
- this._popUp["opened"] = false;
7413
+ this.clearPopUpContent();
7414
+ this._popUp.opened = false;
7345
7415
  }
7416
+ /**
7417
+ * Verifica se a licença do cliente tem determinado opcional (produto)
7418
+ */
7346
7419
  async temOpcional(opcional) {
7347
7420
  const opts = opcional.split(",");
7348
7421
  return new Promise((resolve, reject) => {
@@ -7366,6 +7439,10 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7366
7439
  });
7367
7440
  });
7368
7441
  }
7442
+ /**
7443
+ * Retorna a configuração de um recurso por service broker
7444
+ * Veja também o método "loadConfig"
7445
+ */
7369
7446
  async getConfig(key) {
7370
7447
  let payload = {
7371
7448
  "serviceName": "SystemUtilsSP.getConf",
@@ -7383,6 +7460,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7383
7460
  .catch(error => reject(error));
7384
7461
  });
7385
7462
  }
7463
+ /**
7464
+ * Salva a configuração de determinado recurso.
7465
+ */
7386
7466
  async saveConfig(key, data) {
7387
7467
  let payload = {
7388
7468
  "serviceName": "SystemUtilsSP.saveConf",
@@ -7401,42 +7481,122 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7401
7481
  .catch(error => reject(error));
7402
7482
  });
7403
7483
  }
7484
+ /**
7485
+ * Acessa informações de contexto "empurrados" na abertura da tela
7486
+ */
7404
7487
  async getAttributeFromHTMLWrapper(attribName) {
7405
7488
  return Promise.resolve(window[attribName]);
7406
7489
  }
7490
+ /**
7491
+ * Abre determinada tela, repassando pkObject
7492
+ */
7407
7493
  async openApp(resourceId, pkObject) {
7408
7494
  Workspace.openAppActivity(resourceId, pkObject);
7409
7495
  }
7410
- async createDataunit(entityName) {
7411
- return new Promise(resolve => {
7412
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7413
- dataUnit.loadMetadata().then(() => resolve(dataUnit));
7496
+ getDuPromissesStack(dataUnitName) {
7497
+ let stack;
7498
+ if (dataUnitName) {
7499
+ stack = this._duPromises.get(dataUnitName);
7500
+ if (!stack) {
7501
+ stack = [];
7502
+ this._duPromises.set(dataUnitName, stack);
7503
+ }
7504
+ }
7505
+ return stack || [];
7506
+ }
7507
+ /**
7508
+ * Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
7509
+ * passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado
7510
+ */
7511
+ async createDataunit(entityName, dataUnitName) {
7512
+ return new Promise((resolve, reject) => {
7513
+ const duPromisses = this.getDuPromissesStack(dataUnitName);
7514
+ const waitingDu = duPromisses.length > 0;
7515
+ duPromisses.push(new PendingPromise(resolve, reject));
7516
+ if (!waitingDu) {
7517
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7518
+ dataUnit.loadMetadata().then(() => {
7519
+ if (dataUnitName) {
7520
+ this._duCache.set(dataUnitName, dataUnit);
7521
+ }
7522
+ while (duPromisses.length > 0) {
7523
+ duPromisses.pop().resolve(dataUnit);
7524
+ }
7525
+ }).catch(reason => {
7526
+ while (duPromisses.length > 0) {
7527
+ duPromisses.pop().reject(reason);
7528
+ }
7529
+ });
7530
+ }
7531
+ });
7532
+ }
7533
+ /**
7534
+ * Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
7535
+ */
7536
+ async getDataUnit(entityName, dataUnitName) {
7537
+ return new Promise((resolve, reject) => {
7538
+ const dataUnit = this._duCache.get(dataUnitName);
7539
+ if (dataUnit) {
7540
+ resolve(dataUnit);
7541
+ }
7542
+ else {
7543
+ this.createDataunit(entityName, dataUnitName).then(dataUnit => {
7544
+ resolve(dataUnit);
7545
+ }).catch(reason => reject(reason));
7546
+ }
7414
7547
  });
7415
7548
  }
7549
+ /**
7550
+ * Retorna o resourceID da tela em questão.
7551
+ */
7416
7552
  async getResourceID() {
7417
7553
  return Promise.resolve(this.resourceID);
7418
7554
  }
7555
+ /**
7556
+ * Mostra o diálogo de alerta de acordo com os parâmetros passados.
7557
+ */
7419
7558
  async alert(title, message, icon, options) {
7420
7559
  return ApplicationUtils.alert(title, message, icon, options);
7421
7560
  }
7561
+ /**
7562
+ * Mostra o diálogo de erro de acordo com os parâmetros passados.
7563
+ */
7422
7564
  async error(title, message, icon, options) {
7423
7565
  return ApplicationUtils.error(title, message, icon, options);
7424
7566
  }
7567
+ /**
7568
+ * Exibe um diálogo de confirmação
7569
+ */
7425
7570
  async confirm(title, message, icon, critical, options) {
7426
7571
  return ApplicationUtils.confirm(title, message, icon, critical, options);
7427
7572
  }
7573
+ /**
7574
+ * Mostra uma informação efêmera (de segundo plano).
7575
+ */
7428
7576
  async info(message, options) {
7429
7577
  return ApplicationUtils.info(message, options);
7430
7578
  }
7579
+ /**
7580
+ * Busca a configuração de formulário.
7581
+ */
7431
7582
  async loadFormConfig(name) {
7432
7583
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7433
7584
  }
7434
- async loadGridConfig() {
7435
- return this.gridConfigFetcher.getConfig(this.resourceID);
7585
+ /**
7586
+ * Busca a configuração de grade.
7587
+ */
7588
+ async loadGridConfig(name) {
7589
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7436
7590
  }
7591
+ /**
7592
+ * Salva a configuração de grade.
7593
+ */
7437
7594
  async saveGridConfig(config) {
7438
7595
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7439
7596
  }
7597
+ async getAuthList(_auth) {
7598
+ return await (new MGEAuthorization()).parseFromJSON(_auth);
7599
+ }
7440
7600
  get urlParams() {
7441
7601
  if (!this._urlParams) {
7442
7602
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7514,7 +7674,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7514
7674
  pesquisaContent.searchLoader = (text) => this.pesquisaFetcher.loadAdvancedSearch(ENTITYNAME, text, criteria, searchOptions);
7515
7675
  pesquisaContent.selectItem = (option) => {
7516
7676
  accept(option);
7517
- this.cleanPopUpTitle();
7677
+ this.clearPopUpTitle();
7518
7678
  this.closePopUp();
7519
7679
  };
7520
7680
  this.setPopUpTitle(DESCRIPTIONENTITY);
@@ -7531,14 +7691,22 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7531
7691
  accept(window['isDebugMode']);
7532
7692
  });
7533
7693
  }
7534
- cleanPopUpTitle() {
7535
- this._popUp['ezTitle'] = "";
7694
+ clearPopUpContent() {
7695
+ if (this._popUp) {
7696
+ Array.from(this._popUp.children).forEach(c => {
7697
+ this._popUp.removeChild(c);
7698
+ });
7699
+ }
7700
+ }
7701
+ clearPopUpTitle() {
7702
+ this._popUp.ezTitle = "";
7536
7703
  }
7537
7704
  setPopUpTitle(title) {
7538
- this._popUp['ezTitle'] = title;
7705
+ this._popUp.ezTitle = title;
7539
7706
  }
7540
7707
  componentWillLoad() {
7541
7708
  this._errorHandler = new SnkErrorHandler(this);
7709
+ this.messagesBuilder = new SnkMessageBuilder();
7542
7710
  ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
7543
7711
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7544
7712
  return this.executeSearch(searchArgument, fieldName, dataUnit);
@@ -7547,6 +7715,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7547
7715
  ErrorTracking.init();
7548
7716
  }
7549
7717
  connectedCallback() {
7718
+ ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7550
7719
  DataFetcher.addRequestListener(this._requestListener);
7551
7720
  }
7552
7721
  disconnectedCallback() {
@@ -7563,6 +7732,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7563
7732
  }
7564
7733
  static get style() { return snkApplicationCss; }
7565
7734
  }, [2, "snk-application", {
7735
+ "messagesBuilder": [1040],
7566
7736
  "isUserSup": [64],
7567
7737
  "hasAccess": [64],
7568
7738
  "getAllAccess": [64],
@@ -7579,6 +7749,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7579
7749
  "getAttributeFromHTMLWrapper": [64],
7580
7750
  "openApp": [64],
7581
7751
  "createDataunit": [64],
7752
+ "getDataUnit": [64],
7582
7753
  "getResourceID": [64],
7583
7754
  "alert": [64],
7584
7755
  "error": [64],
@@ -7613,6 +7784,12 @@ class RequestListenerLoadingBar {
7613
7784
  }
7614
7785
  ;
7615
7786
  }
7787
+ class PendingPromise {
7788
+ constructor(resolve, reject) {
7789
+ this.resolve = resolve;
7790
+ this.reject = reject;
7791
+ }
7792
+ }
7616
7793
  function defineCustomElement() {
7617
7794
  if (typeof customElements === "undefined") {
7618
7795
  return;