@sankhyalabs/sankhyablocks 4.8.0 → 4.8.1

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 (36) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/snk-application.cjs.entry.js +149 -2
  3. package/dist/cjs/snk-crud.cjs.entry.js +0 -1
  4. package/dist/cjs/snk-detail-view.cjs.entry.js +1 -2
  5. package/dist/cjs/{snk-guides-viewer-ed5012ff.js → snk-guides-viewer-cb02e675.js} +0 -1
  6. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -2
  7. package/dist/cjs/snk-simple-crud.cjs.entry.js +0 -1
  8. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -6
  9. package/dist/components/snk-application2.js +149 -2
  10. package/dist/components/snk-crud.js +0 -1
  11. package/dist/components/snk-detail-view2.js +0 -1
  12. package/dist/components/snk-simple-crud.js +0 -1
  13. package/dist/esm/snk-application.entry.js +149 -2
  14. package/dist/esm/snk-crud.entry.js +0 -1
  15. package/dist/esm/snk-detail-view.entry.js +1 -2
  16. package/dist/esm/{snk-guides-viewer-3a29e72b.js → snk-guides-viewer-b13cff0a.js} +0 -1
  17. package/dist/esm/snk-guides-viewer.entry.js +1 -2
  18. package/dist/esm/snk-simple-crud.entry.js +0 -1
  19. package/dist/sankhyablocks/p-2eab10a4.entry.js +88 -0
  20. package/dist/sankhyablocks/p-5afa5b01.entry.js +1 -0
  21. package/dist/sankhyablocks/p-5b80ee28.entry.js +1 -0
  22. package/dist/sankhyablocks/{p-6f8eb54b.entry.js → p-6181e6cb.entry.js} +1 -1
  23. package/dist/sankhyablocks/p-64f21075.entry.js +1 -0
  24. package/dist/sankhyablocks/p-e1dbaecb.js +1 -0
  25. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  26. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -4
  27. package/package.json +1 -1
  28. package/dist/cjs/pesquisa-fetcher-a3f0954f.js +0 -158
  29. package/dist/components/pesquisa-fetcher.js +0 -156
  30. package/dist/esm/pesquisa-fetcher-e60477d1.js +0 -156
  31. package/dist/sankhyablocks/p-1da34865.js +0 -1
  32. package/dist/sankhyablocks/p-3c18709f.entry.js +0 -1
  33. package/dist/sankhyablocks/p-5643a554.entry.js +0 -1
  34. package/dist/sankhyablocks/p-57c40d37.entry.js +0 -83
  35. package/dist/sankhyablocks/p-9b51be04.entry.js +0 -1
  36. package/dist/sankhyablocks/p-a81f0854.js +0 -6
package/README.md CHANGED
@@ -74,3 +74,5 @@ The first step for all three of these strategies is to [publish to NPM](https://
74
74
  - Add an import to the npm packages `import my-component;`
75
75
  - Then you can use the element anywhere in your template, JSX, html etc
76
76
 
77
+
78
+
@@ -6,7 +6,6 @@ const index = require('./index-21bd01e1.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const DataFetcher = require('./DataFetcher-6acfc3a8.js');
8
8
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
9
- const pesquisaFetcher = require('./pesquisa-fetcher-a3f0954f.js');
10
9
  const SnkMessageBuilder = require('./SnkMessageBuilder-47185d5d.js');
11
10
  const ConfigStorage = require('./ConfigStorage-bc7d1d9b.js');
12
11
  const formConfigFetcher = require('./form-config-fetcher-4a952a50.js');
@@ -72,6 +71,154 @@ class SnkErrorHandler {
72
71
  }
73
72
  }
74
73
 
74
+ class PesquisaFetcher {
75
+ constructor() {
76
+ this._defaultPageSize = 100;
77
+ this._templateByQuery = new Map();
78
+ this._searchListenersByDataUnit = new Map();
79
+ this.buldTemplates();
80
+ }
81
+ buldTemplates() {
82
+ this._templateByQuery.set("search", DataFetcher.dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
83
+ $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
84
+ value
85
+ label
86
+ }
87
+ }`);
88
+ }
89
+ loadSearchOptions(entityName, argument, criteria, options) {
90
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
91
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
92
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
93
+ const values = {
94
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
95
+ entityName,
96
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
97
+ options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
98
+ };
99
+ return new Promise((resolve, reject) => {
100
+ DataFetcher.DataFetcher.get()
101
+ .callGraphQL({
102
+ values,
103
+ query: this._templateByQuery.get("search"),
104
+ })
105
+ .then((result) => {
106
+ resolve(result);
107
+ })
108
+ .catch((error) => {
109
+ reject(error);
110
+ });
111
+ });
112
+ }
113
+ loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
114
+ var _a, _b, _c;
115
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
116
+ const values = {
117
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
118
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
119
+ searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
120
+ };
121
+ const serviceName = "PesquisaSP.getSuggestion";
122
+ const externalCriteria = {
123
+ query: {
124
+ $: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
125
+ }
126
+ };
127
+ if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
128
+ externalCriteria.params = {
129
+ param: values.criteria.params.map(param => {
130
+ let value = param.value;
131
+ let type = param.dataType;
132
+ if (type === core.DataType.OBJECT) {
133
+ value = value.value;
134
+ type = "S";
135
+ }
136
+ else {
137
+ type = convertParamType(param.dataType);
138
+ }
139
+ return { $: value, type };
140
+ })
141
+ };
142
+ }
143
+ const options = searchOptions != undefined
144
+ ? {
145
+ "pkFieldName": searchOptions.codeFieldName,
146
+ "label": searchOptions.descriptionFieldName,
147
+ "fieldName": searchOptions.codeFieldName,
148
+ "useDescriptionOptions": false,
149
+ "enableRowsCounter": true
150
+ }
151
+ : undefined;
152
+ const reqBody = {
153
+ "serviceName": serviceName,
154
+ "requestBody": {
155
+ "criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
156
+ "clientEventList": {
157
+ "clientEvent": []
158
+ }
159
+ }
160
+ };
161
+ return new Promise((resolve, reject) => {
162
+ DataFetcher.DataFetcher.get()
163
+ .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
164
+ .then(result => resolve(result))
165
+ .catch(error => reject(error));
166
+ });
167
+ }
168
+ addSearchListener(entityName, dataUnitID, listener) {
169
+ var _a;
170
+ const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
171
+ const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
172
+ if (!entityListener) {
173
+ this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
174
+ }
175
+ else {
176
+ for (const type of Object.keys(listener)) {
177
+ if (type in entityListener.listener) {
178
+ const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
179
+ if (listenerFunctionIsEquals)
180
+ continue;
181
+ entityListener.listener[type] = listener[type];
182
+ }
183
+ }
184
+ }
185
+ return () => {
186
+ const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
187
+ if (!newListeners.length) {
188
+ this._searchListenersByDataUnit.delete(dataUnitID);
189
+ return;
190
+ }
191
+ this._searchListenersByDataUnit.set(dataUnitID, newListeners);
192
+ };
193
+ }
194
+ applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
195
+ var _a;
196
+ const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
197
+ if (!dataUnitId)
198
+ return;
199
+ const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
200
+ if (!entityListener)
201
+ return;
202
+ const { listener } = entityListener;
203
+ if (!(listenerType in listener))
204
+ return;
205
+ return listener[listenerType]({ argument, criteria, searchOptions });
206
+ }
207
+ }
208
+ function convertParamType(dataType) {
209
+ //Alerta: Cuidado pra não contaminar o DataType com a implementação
210
+ //atual da pesquisa... em geral, somente inteiros,
211
+ //data (com ou sem hora) e string são realmente relevantes
212
+ switch (dataType) {
213
+ case core.DataType.NUMBER:
214
+ return "I";
215
+ case core.DataType.DATE:
216
+ return "D";
217
+ default:
218
+ return "S";
219
+ }
220
+ }
221
+
75
222
  function _0x53e1(){const _0x340df8=['2909523kXwted','CompanyName=Sankhya\x20Jiva\x20Tecnologia\x20e\x20Inovao\x20Ltda,LicensedApplication=Sankhya\x20Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869','1131048CARoeW','502909mLEPmu','447255iQEXuN','428UHbJwW','270AFTxAV','194369jhGqTI','1540nWuTrj','2044062GicUQI','30CkXPWg'];_0x53e1=function(){return _0x340df8;};return _0x53e1();}const _0xc7632f=_0x15c2;function _0x15c2(_0x353a9c,_0x3e4a5a){const _0x53e110=_0x53e1();return _0x15c2=function(_0x15c2aa,_0x219858){_0x15c2aa=_0x15c2aa-0x188;let _0x307231=_0x53e110[_0x15c2aa];return _0x307231;},_0x15c2(_0x353a9c,_0x3e4a5a);}(function(_0x42617e,_0x57debe){const _0x31061a=_0x15c2,_0x128d7d=_0x42617e();while(!![]){try{const _0x1c9bb1=-parseInt(_0x31061a(0x18e))/0x1+-parseInt(_0x31061a(0x189))/0x2+parseInt(_0x31061a(0x18b))/0x3+-parseInt(_0x31061a(0x190))/0x4*(parseInt(_0x31061a(0x188))/0x5)+-parseInt(_0x31061a(0x191))/0x6*(-parseInt(_0x31061a(0x192))/0x7)+parseInt(_0x31061a(0x18d))/0x8+-parseInt(_0x31061a(0x18f))/0x9*(-parseInt(_0x31061a(0x18a))/0xa);if(_0x1c9bb1===_0x57debe)break;else _0x128d7d['push'](_0x128d7d['shift']());}catch(_0x1bd816){_0x128d7d['push'](_0x128d7d['shift']());}}}(_0x53e1,0xe8676));const agGridLicense=_0xc7632f(0x18c);
76
223
 
77
224
  class TotalsFetcher {
@@ -989,7 +1136,7 @@ const SnkApplication = class {
989
1136
  }
990
1137
  get pesquisaFetcher() {
991
1138
  if (!this._pesquisaFetcher) {
992
- this._pesquisaFetcher = new pesquisaFetcher.PesquisaFetcher();
1139
+ this._pesquisaFetcher = new PesquisaFetcher();
993
1140
  }
994
1141
  return this._pesquisaFetcher;
995
1142
  }
@@ -6,7 +6,6 @@ const index = require('./index-21bd01e1.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const taskbarElements = require('./taskbar-elements-5e87cf44.js');
8
8
  require('./DataFetcher-6acfc3a8.js');
9
- require('./pesquisa-fetcher-a3f0954f.js');
10
9
  const index$1 = require('./index-f400b1d6.js');
11
10
  const constants = require('./constants-ae0ed870.js');
12
11
  require('./index-fc7ca86c.js');
@@ -6,12 +6,11 @@ const index = require('./index-21bd01e1.js');
6
6
  const SnkFormConfigManager = require('./SnkFormConfigManager-5230e010.js');
7
7
  const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
8
8
  require('./DataFetcher-6acfc3a8.js');
9
- require('./pesquisa-fetcher-a3f0954f.js');
10
9
  require('@sankhyalabs/core');
11
10
  const index$1 = require('./index-f400b1d6.js');
12
11
  const taskbarElements = require('./taskbar-elements-5e87cf44.js');
13
12
  const constants = require('./constants-ae0ed870.js');
14
- const snkGuidesViewer = require('./snk-guides-viewer-ed5012ff.js');
13
+ const snkGuidesViewer = require('./snk-guides-viewer-cb02e675.js');
15
14
  require('./ConfigStorage-bc7d1d9b.js');
16
15
  require('./form-config-fetcher-4a952a50.js');
17
16
  require('./_commonjsHelpers-537d719a.js');
@@ -8,7 +8,6 @@ const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
8
8
  const taskbarElements = require('./taskbar-elements-5e87cf44.js');
9
9
  const constants = require('./constants-ae0ed870.js');
10
10
  require('./DataFetcher-6acfc3a8.js');
11
- require('./pesquisa-fetcher-a3f0954f.js');
12
11
  const index$1 = require('./index-f400b1d6.js');
13
12
 
14
13
  const snkGuidesViewerCss = ".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const snkGuidesViewer = require('./snk-guides-viewer-ed5012ff.js');
5
+ const snkGuidesViewer = require('./snk-guides-viewer-cb02e675.js');
6
6
  require('./index-21bd01e1.js');
7
7
  require('@sankhyalabs/core');
8
8
  require('./SnkFormConfigManager-5230e010.js');
@@ -16,7 +16,6 @@ require('./taskbar-elements-5e87cf44.js');
16
16
  require('./index-f400b1d6.js');
17
17
  require('./index-fc7ca86c.js');
18
18
  require('./constants-ae0ed870.js');
19
- require('./pesquisa-fetcher-a3f0954f.js');
20
19
 
21
20
 
22
21
 
@@ -7,7 +7,6 @@ const core = require('@sankhyalabs/core');
7
7
  const constants = require('./constants-ae0ed870.js');
8
8
  const taskbarElements = require('./taskbar-elements-5e87cf44.js');
9
9
  require('./DataFetcher-6acfc3a8.js');
10
- require('./pesquisa-fetcher-a3f0954f.js');
11
10
  const index$1 = require('./index-f400b1d6.js');
12
11
  const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
13
12
  require('./index-fc7ca86c.js');
@@ -19,7 +19,7 @@ export class PesquisaFetcher {
19
19
  loadSearchOptions(entityName, argument, criteria, options) {
20
20
  const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
21
21
  argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
22
- const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
22
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
23
23
  const values = {
24
24
  argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
25
25
  entityName,
@@ -42,7 +42,7 @@ export class PesquisaFetcher {
42
42
  }
43
43
  loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
44
44
  var _a, _b, _c;
45
- const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
45
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
46
46
  const values = {
47
47
  argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
48
48
  criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
@@ -148,7 +148,3 @@ function convertParamType(dataType) {
148
148
  return "S";
149
149
  }
150
150
  }
151
- export var SearchListenerType;
152
- (function (SearchListenerType) {
153
- SearchListenerType["beforeSearch"] = "beforeSearch";
154
- })(SearchListenerType || (SearchListenerType = {}));
@@ -1,8 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataType, DataUnit, StringUtils, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
4
4
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
- import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
6
5
  import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
7
6
  import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage.js';
8
7
  import { R as ResourceFetcher } from './form-config-fetcher.js';
@@ -68,6 +67,154 @@ class SnkErrorHandler {
68
67
  }
69
68
  }
70
69
 
70
+ class PesquisaFetcher {
71
+ constructor() {
72
+ this._defaultPageSize = 100;
73
+ this._templateByQuery = new Map();
74
+ this._searchListenersByDataUnit = new Map();
75
+ this.buldTemplates();
76
+ }
77
+ buldTemplates() {
78
+ this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
79
+ $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
80
+ value
81
+ label
82
+ }
83
+ }`);
84
+ }
85
+ loadSearchOptions(entityName, argument, criteria, options) {
86
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
87
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
88
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
89
+ const values = {
90
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
91
+ entityName,
92
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
93
+ options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
94
+ };
95
+ return new Promise((resolve, reject) => {
96
+ DataFetcher.get()
97
+ .callGraphQL({
98
+ values,
99
+ query: this._templateByQuery.get("search"),
100
+ })
101
+ .then((result) => {
102
+ resolve(result);
103
+ })
104
+ .catch((error) => {
105
+ reject(error);
106
+ });
107
+ });
108
+ }
109
+ loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
110
+ var _a, _b, _c;
111
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
112
+ const values = {
113
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
114
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
115
+ searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
116
+ };
117
+ const serviceName = "PesquisaSP.getSuggestion";
118
+ const externalCriteria = {
119
+ query: {
120
+ $: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
121
+ }
122
+ };
123
+ if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
124
+ externalCriteria.params = {
125
+ param: values.criteria.params.map(param => {
126
+ let value = param.value;
127
+ let type = param.dataType;
128
+ if (type === DataType.OBJECT) {
129
+ value = value.value;
130
+ type = "S";
131
+ }
132
+ else {
133
+ type = convertParamType(param.dataType);
134
+ }
135
+ return { $: value, type };
136
+ })
137
+ };
138
+ }
139
+ const options = searchOptions != undefined
140
+ ? {
141
+ "pkFieldName": searchOptions.codeFieldName,
142
+ "label": searchOptions.descriptionFieldName,
143
+ "fieldName": searchOptions.codeFieldName,
144
+ "useDescriptionOptions": false,
145
+ "enableRowsCounter": true
146
+ }
147
+ : undefined;
148
+ const reqBody = {
149
+ "serviceName": serviceName,
150
+ "requestBody": {
151
+ "criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
152
+ "clientEventList": {
153
+ "clientEvent": []
154
+ }
155
+ }
156
+ };
157
+ return new Promise((resolve, reject) => {
158
+ DataFetcher.get()
159
+ .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
160
+ .then(result => resolve(result))
161
+ .catch(error => reject(error));
162
+ });
163
+ }
164
+ addSearchListener(entityName, dataUnitID, listener) {
165
+ var _a;
166
+ const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
167
+ const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
168
+ if (!entityListener) {
169
+ this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
170
+ }
171
+ else {
172
+ for (const type of Object.keys(listener)) {
173
+ if (type in entityListener.listener) {
174
+ const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
175
+ if (listenerFunctionIsEquals)
176
+ continue;
177
+ entityListener.listener[type] = listener[type];
178
+ }
179
+ }
180
+ }
181
+ return () => {
182
+ const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
183
+ if (!newListeners.length) {
184
+ this._searchListenersByDataUnit.delete(dataUnitID);
185
+ return;
186
+ }
187
+ this._searchListenersByDataUnit.set(dataUnitID, newListeners);
188
+ };
189
+ }
190
+ applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
191
+ var _a;
192
+ const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
193
+ if (!dataUnitId)
194
+ return;
195
+ const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
196
+ if (!entityListener)
197
+ return;
198
+ const { listener } = entityListener;
199
+ if (!(listenerType in listener))
200
+ return;
201
+ return listener[listenerType]({ argument, criteria, searchOptions });
202
+ }
203
+ }
204
+ function convertParamType(dataType) {
205
+ //Alerta: Cuidado pra não contaminar o DataType com a implementação
206
+ //atual da pesquisa... em geral, somente inteiros,
207
+ //data (com ou sem hora) e string são realmente relevantes
208
+ switch (dataType) {
209
+ case DataType.NUMBER:
210
+ return "I";
211
+ case DataType.DATE:
212
+ return "D";
213
+ default:
214
+ return "S";
215
+ }
216
+ }
217
+
71
218
  function _0x53e1(){const _0x340df8=['2909523kXwted','CompanyName=Sankhya\x20Jiva\x20Tecnologia\x20e\x20Inovao\x20Ltda,LicensedApplication=Sankhya\x20Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869','1131048CARoeW','502909mLEPmu','447255iQEXuN','428UHbJwW','270AFTxAV','194369jhGqTI','1540nWuTrj','2044062GicUQI','30CkXPWg'];_0x53e1=function(){return _0x340df8;};return _0x53e1();}const _0xc7632f=_0x15c2;function _0x15c2(_0x353a9c,_0x3e4a5a){const _0x53e110=_0x53e1();return _0x15c2=function(_0x15c2aa,_0x219858){_0x15c2aa=_0x15c2aa-0x188;let _0x307231=_0x53e110[_0x15c2aa];return _0x307231;},_0x15c2(_0x353a9c,_0x3e4a5a);}(function(_0x42617e,_0x57debe){const _0x31061a=_0x15c2,_0x128d7d=_0x42617e();while(!![]){try{const _0x1c9bb1=-parseInt(_0x31061a(0x18e))/0x1+-parseInt(_0x31061a(0x189))/0x2+parseInt(_0x31061a(0x18b))/0x3+-parseInt(_0x31061a(0x190))/0x4*(parseInt(_0x31061a(0x188))/0x5)+-parseInt(_0x31061a(0x191))/0x6*(-parseInt(_0x31061a(0x192))/0x7)+parseInt(_0x31061a(0x18d))/0x8+-parseInt(_0x31061a(0x18f))/0x9*(-parseInt(_0x31061a(0x18a))/0xa);if(_0x1c9bb1===_0x57debe)break;else _0x128d7d['push'](_0x128d7d['shift']());}catch(_0x1bd816){_0x128d7d['push'](_0x128d7d['shift']());}}}(_0x53e1,0xe8676));const agGridLicense=_0xc7632f(0x18c);
72
219
 
73
220
  class TotalsFetcher {
@@ -2,7 +2,6 @@ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/i
2
2
  import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
4
4
  import './DataFetcher.js';
5
- import './pesquisa-fetcher.js';
6
5
  import { P as PresentationMode } from './index2.js';
7
6
  import { V as VIEW_MODE } from './constants.js';
8
7
  import { d as defineCustomElement$m } from './snk-config-options2.js';
@@ -2,7 +2,6 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Fragment, forceUpdate,
2
2
  import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
3
3
  import { buildFormMetadata, FormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
4
4
  import './DataFetcher.js';
5
- import './pesquisa-fetcher.js';
6
5
  import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
7
6
  import { P as PresentationMode } from './index2.js';
8
7
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
@@ -3,7 +3,6 @@ import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, ObjectUtils
3
3
  import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
4
4
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
5
5
  import './DataFetcher.js';
6
- import './pesquisa-fetcher.js';
7
6
  import { P as PresentationMode } from './index2.js';
8
7
  import { T as TaskbarProcessor } from './taskbar-processor.js';
9
8
  import { d as defineCustomElement$5 } from './snk-data-exporter2.js';
@@ -1,8 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
2
- import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataType, DataUnit, StringUtils, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-5e99fa75.js';
4
4
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
- import { P as PesquisaFetcher } from './pesquisa-fetcher-e60477d1.js';
6
5
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-ec0850af.js';
7
6
  import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage-1b64cd96.js';
8
7
  import { R as ResourceFetcher } from './form-config-fetcher-677f86dd.js';
@@ -68,6 +67,154 @@ class SnkErrorHandler {
68
67
  }
69
68
  }
70
69
 
70
+ class PesquisaFetcher {
71
+ constructor() {
72
+ this._defaultPageSize = 100;
73
+ this._templateByQuery = new Map();
74
+ this._searchListenersByDataUnit = new Map();
75
+ this.buldTemplates();
76
+ }
77
+ buldTemplates() {
78
+ this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
79
+ $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
80
+ value
81
+ label
82
+ }
83
+ }`);
84
+ }
85
+ loadSearchOptions(entityName, argument, criteria, options) {
86
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
87
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
88
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
89
+ const values = {
90
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
91
+ entityName,
92
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
93
+ options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
94
+ };
95
+ return new Promise((resolve, reject) => {
96
+ DataFetcher.get()
97
+ .callGraphQL({
98
+ values,
99
+ query: this._templateByQuery.get("search"),
100
+ })
101
+ .then((result) => {
102
+ resolve(result);
103
+ })
104
+ .catch((error) => {
105
+ reject(error);
106
+ });
107
+ });
108
+ }
109
+ loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
110
+ var _a, _b, _c;
111
+ const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
112
+ const values = {
113
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
114
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
115
+ searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
116
+ };
117
+ const serviceName = "PesquisaSP.getSuggestion";
118
+ const externalCriteria = {
119
+ query: {
120
+ $: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
121
+ }
122
+ };
123
+ if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
124
+ externalCriteria.params = {
125
+ param: values.criteria.params.map(param => {
126
+ let value = param.value;
127
+ let type = param.dataType;
128
+ if (type === DataType.OBJECT) {
129
+ value = value.value;
130
+ type = "S";
131
+ }
132
+ else {
133
+ type = convertParamType(param.dataType);
134
+ }
135
+ return { $: value, type };
136
+ })
137
+ };
138
+ }
139
+ const options = searchOptions != undefined
140
+ ? {
141
+ "pkFieldName": searchOptions.codeFieldName,
142
+ "label": searchOptions.descriptionFieldName,
143
+ "fieldName": searchOptions.codeFieldName,
144
+ "useDescriptionOptions": false,
145
+ "enableRowsCounter": true
146
+ }
147
+ : undefined;
148
+ const reqBody = {
149
+ "serviceName": serviceName,
150
+ "requestBody": {
151
+ "criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
152
+ "clientEventList": {
153
+ "clientEvent": []
154
+ }
155
+ }
156
+ };
157
+ return new Promise((resolve, reject) => {
158
+ DataFetcher.get()
159
+ .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
160
+ .then(result => resolve(result))
161
+ .catch(error => reject(error));
162
+ });
163
+ }
164
+ addSearchListener(entityName, dataUnitID, listener) {
165
+ var _a;
166
+ const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
167
+ const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
168
+ if (!entityListener) {
169
+ this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
170
+ }
171
+ else {
172
+ for (const type of Object.keys(listener)) {
173
+ if (type in entityListener.listener) {
174
+ const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
175
+ if (listenerFunctionIsEquals)
176
+ continue;
177
+ entityListener.listener[type] = listener[type];
178
+ }
179
+ }
180
+ }
181
+ return () => {
182
+ const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
183
+ if (!newListeners.length) {
184
+ this._searchListenersByDataUnit.delete(dataUnitID);
185
+ return;
186
+ }
187
+ this._searchListenersByDataUnit.set(dataUnitID, newListeners);
188
+ };
189
+ }
190
+ applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
191
+ var _a;
192
+ const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
193
+ if (!dataUnitId)
194
+ return;
195
+ const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
196
+ if (!entityListener)
197
+ return;
198
+ const { listener } = entityListener;
199
+ if (!(listenerType in listener))
200
+ return;
201
+ return listener[listenerType]({ argument, criteria, searchOptions });
202
+ }
203
+ }
204
+ function convertParamType(dataType) {
205
+ //Alerta: Cuidado pra não contaminar o DataType com a implementação
206
+ //atual da pesquisa... em geral, somente inteiros,
207
+ //data (com ou sem hora) e string são realmente relevantes
208
+ switch (dataType) {
209
+ case DataType.NUMBER:
210
+ return "I";
211
+ case DataType.DATE:
212
+ return "D";
213
+ default:
214
+ return "S";
215
+ }
216
+ }
217
+
71
218
  function _0x53e1(){const _0x340df8=['2909523kXwted','CompanyName=Sankhya\x20Jiva\x20Tecnologia\x20e\x20Inovao\x20Ltda,LicensedApplication=Sankhya\x20Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869','1131048CARoeW','502909mLEPmu','447255iQEXuN','428UHbJwW','270AFTxAV','194369jhGqTI','1540nWuTrj','2044062GicUQI','30CkXPWg'];_0x53e1=function(){return _0x340df8;};return _0x53e1();}const _0xc7632f=_0x15c2;function _0x15c2(_0x353a9c,_0x3e4a5a){const _0x53e110=_0x53e1();return _0x15c2=function(_0x15c2aa,_0x219858){_0x15c2aa=_0x15c2aa-0x188;let _0x307231=_0x53e110[_0x15c2aa];return _0x307231;},_0x15c2(_0x353a9c,_0x3e4a5a);}(function(_0x42617e,_0x57debe){const _0x31061a=_0x15c2,_0x128d7d=_0x42617e();while(!![]){try{const _0x1c9bb1=-parseInt(_0x31061a(0x18e))/0x1+-parseInt(_0x31061a(0x189))/0x2+parseInt(_0x31061a(0x18b))/0x3+-parseInt(_0x31061a(0x190))/0x4*(parseInt(_0x31061a(0x188))/0x5)+-parseInt(_0x31061a(0x191))/0x6*(-parseInt(_0x31061a(0x192))/0x7)+parseInt(_0x31061a(0x18d))/0x8+-parseInt(_0x31061a(0x18f))/0x9*(-parseInt(_0x31061a(0x18a))/0xa);if(_0x1c9bb1===_0x57debe)break;else _0x128d7d['push'](_0x128d7d['shift']());}catch(_0x1bd816){_0x128d7d['push'](_0x128d7d['shift']());}}}(_0x53e1,0xe8676));const agGridLicense=_0xc7632f(0x18c);
72
219
 
73
220
  class TotalsFetcher {
@@ -2,7 +2,6 @@ import { r as registerInstance, c as createEvent, h, g as getElement } from './i
2
2
  import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
4
4
  import './DataFetcher-5e99fa75.js';
5
- import './pesquisa-fetcher-e60477d1.js';
6
5
  import { P as PresentationMode } from './index-6519a79e.js';
7
6
  import { c as VIEW_MODE } from './constants-15617e7d.js';
8
7
  import './index-e467ade5.js';
@@ -2,12 +2,11 @@ import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host
2
2
  import { S as SnkFormConfigManager } from './SnkFormConfigManager-0d9752c3.js';
3
3
  import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
4
4
  import './DataFetcher-5e99fa75.js';
5
- import './pesquisa-fetcher-e60477d1.js';
6
5
  import '@sankhyalabs/core';
7
6
  import { P as PresentationMode } from './index-6519a79e.js';
8
7
  import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
9
8
  import { c as VIEW_MODE } from './constants-15617e7d.js';
10
- import { S as SnkGuidesViewer } from './snk-guides-viewer-3a29e72b.js';
9
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-b13cff0a.js';
11
10
  import './ConfigStorage-1b64cd96.js';
12
11
  import './form-config-fetcher-677f86dd.js';
13
12
  import './_commonjsHelpers-9943807e.js';