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