@sankhyalabs/sankhyablocks 1.1.27 → 1.3.0

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 (237) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +75 -75
  3. package/dist/cjs/index-4720dab8.js +735 -0
  4. package/dist/cjs/loader.cjs.js +3 -3
  5. package/dist/cjs/sankhyablocks.cjs.js +3 -3
  6. package/dist/cjs/snk-application.cjs.entry.js +954 -656
  7. package/dist/collection/collection-manifest.json +6 -35
  8. package/dist/collection/components/snk-application/snk-application.css +5 -5
  9. package/dist/collection/components/snk-application/snk-application.js +492 -495
  10. package/dist/collection/index.js +1 -1
  11. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +158 -158
  12. package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +23 -23
  13. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +188 -188
  14. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +25 -25
  15. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +2 -2
  16. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +59 -59
  17. package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +30 -30
  18. package/dist/collection/lib/http/data-fetcher/state/LoadStateManager.js +66 -66
  19. package/dist/collection/lib/utils/pesquisa.js +16 -16
  20. package/dist/collection/lib/utils/urlutils.js +23 -23
  21. package/dist/collection/lib/workspace/workspace.js +7 -7
  22. package/dist/components/snk-application.js +945 -647
  23. package/dist/esm/index-72d4e2e0.js +709 -0
  24. package/dist/esm/loader.js +3 -3
  25. package/dist/esm/polyfills/core-js.js +0 -0
  26. package/dist/esm/polyfills/dom.js +0 -0
  27. package/dist/esm/polyfills/es5-html-element.js +0 -0
  28. package/dist/esm/polyfills/index.js +0 -0
  29. package/dist/esm/polyfills/system.js +0 -0
  30. package/dist/esm/sankhyablocks.js +3 -3
  31. package/dist/esm/snk-application.entry.js +916 -618
  32. package/dist/sankhyablocks/p-5d8ddbda.entry.js +57 -0
  33. package/dist/sankhyablocks/p-a33afc3b.js +2 -0
  34. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  35. package/dist/types/components/snk-application/snk-application.d.ts +44 -44
  36. package/dist/types/components.d.ts +6 -2
  37. package/dist/types/index.d.ts +1 -1
  38. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +15 -15
  39. package/dist/types/lib/http/data-fetcher/fetchers/application-config-fetcher.d.ts +6 -6
  40. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +12 -12
  41. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +5 -5
  42. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +2 -2
  43. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +13 -13
  44. package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +6 -6
  45. package/dist/types/lib/http/data-fetcher/state/LoadStateManager.d.ts +23 -23
  46. package/dist/types/lib/utils/pesquisa.d.ts +2 -2
  47. package/dist/types/lib/utils/urlutils.d.ts +4 -4
  48. package/dist/types/lib/workspace/workspace.d.ts +4 -4
  49. package/package.json +63 -52
  50. package/react/.keepfolder +1 -0
  51. package/react/components.d.ts +3 -32
  52. package/react/components.js +5 -34
  53. package/react/components.js.map +1 -1
  54. package/react/react-component-lib/createComponent.d.ts +10 -10
  55. package/react/react-component-lib/createComponent.js +58 -74
  56. package/react/react-component-lib/createComponent.js.map +1 -1
  57. package/react/react-component-lib/createOverlayComponent.d.ts +20 -21
  58. package/react/react-component-lib/createOverlayComponent.js +88 -108
  59. package/react/react-component-lib/createOverlayComponent.js.map +1 -1
  60. package/react/react-component-lib/index.d.ts +2 -2
  61. package/react/react-component-lib/index.js +2 -2
  62. package/react/react-component-lib/interfaces.d.ts +29 -29
  63. package/react/react-component-lib/utils/attachProps.d.ts +12 -12
  64. package/react/react-component-lib/utils/attachProps.js +95 -97
  65. package/react/react-component-lib/utils/attachProps.js.map +1 -1
  66. package/react/react-component-lib/utils/case.d.ts +2 -2
  67. package/react/react-component-lib/utils/case.js +6 -6
  68. package/react/react-component-lib/utils/dev.d.ts +2 -2
  69. package/react/react-component-lib/utils/dev.js +12 -12
  70. package/react/react-component-lib/utils/index.d.ts +7 -10
  71. package/react/react-component-lib/utils/index.js +20 -33
  72. package/react/react-component-lib/utils/index.js.map +1 -1
  73. package/dist/cjs/ApplicationUtils-05b74ee9.js +0 -39
  74. package/dist/cjs/AssetsUtils-bd004f63.js +0 -24
  75. package/dist/cjs/CSSVarsUtils-75ca9c64.js +0 -19
  76. package/dist/cjs/_commonjsHelpers-537d719a.js +0 -20
  77. package/dist/cjs/ez-action-chip.cjs.entry.js +0 -27
  78. package/dist/cjs/ez-application.cjs.entry.js +0 -26
  79. package/dist/cjs/ez-button_4.cjs.entry.js +0 -660
  80. package/dist/cjs/ez-calendar.cjs.entry.js +0 -223
  81. package/dist/cjs/ez-collapsible-box.cjs.entry.js +0 -47
  82. package/dist/cjs/ez-combo-box.cjs.entry.js +0 -278
  83. package/dist/cjs/ez-date-input.cjs.entry.js +0 -102
  84. package/dist/cjs/ez-date-time-input.cjs.entry.js +0 -145
  85. package/dist/cjs/ez-dialog.cjs.entry.js +0 -89
  86. package/dist/cjs/ez-form.cjs.entry.js +0 -785
  87. package/dist/cjs/ez-grid.cjs.entry.js +0 -110485
  88. package/dist/cjs/ez-icon.cjs.entry.js +0 -41
  89. package/dist/cjs/ez-label-chip.cjs.entry.js +0 -104
  90. package/dist/cjs/ez-modal_2.cjs.entry.js +0 -316
  91. package/dist/cjs/ez-number-input.cjs.entry.js +0 -86
  92. package/dist/cjs/ez-popover.cjs.entry.js +0 -120
  93. package/dist/cjs/ez-popup.cjs.entry.js +0 -48
  94. package/dist/cjs/ez-search.cjs.entry.js +0 -64
  95. package/dist/cjs/ez-tabselector.cjs.entry.js +0 -198
  96. package/dist/cjs/ez-text-area.cjs.entry.js +0 -114
  97. package/dist/cjs/ez-text-input.cjs.entry.js +0 -201
  98. package/dist/cjs/ez-time-input.cjs.entry.js +0 -118
  99. package/dist/cjs/ez-toast.cjs.entry.js +0 -44
  100. package/dist/cjs/ez-upload.cjs.entry.js +0 -356
  101. package/dist/cjs/index-6ac5268e.js +0 -1769
  102. package/dist/cjs/test-du.cjs.entry.js +0 -76
  103. package/dist/components/ApplicationUtils.js +0 -37
  104. package/dist/components/AssetsUtils.js +0 -22
  105. package/dist/components/CSSVarsUtils.js +0 -17
  106. package/dist/components/_commonjsHelpers.js +0 -17
  107. package/dist/components/ez-action-chip.js +0 -44
  108. package/dist/components/ez-application.js +0 -39
  109. package/dist/components/ez-button.js +0 -6
  110. package/dist/components/ez-button2.js +0 -105
  111. package/dist/components/ez-calendar.js +0 -6
  112. package/dist/components/ez-calendar2.js +0 -242
  113. package/dist/components/ez-check.js +0 -6
  114. package/dist/components/ez-check2.js +0 -94
  115. package/dist/components/ez-collapsible-box.js +0 -67
  116. package/dist/components/ez-combo-box.js +0 -6
  117. package/dist/components/ez-combo-box2.js +0 -311
  118. package/dist/components/ez-date-input.js +0 -135
  119. package/dist/components/ez-date-time-input.js +0 -179
  120. package/dist/components/ez-dialog.js +0 -124
  121. package/dist/components/ez-form.js +0 -6
  122. package/dist/components/ez-form2.js +0 -807
  123. package/dist/components/ez-grid.js +0 -110576
  124. package/dist/components/ez-icon.js +0 -6
  125. package/dist/components/ez-icon2.js +0 -56
  126. package/dist/components/ez-label-chip.js +0 -125
  127. package/dist/components/ez-list.js +0 -6
  128. package/dist/components/ez-list2.js +0 -523
  129. package/dist/components/ez-modal.js +0 -6
  130. package/dist/components/ez-modal2.js +0 -82
  131. package/dist/components/ez-number-input.js +0 -115
  132. package/dist/components/ez-popover.js +0 -145
  133. package/dist/components/ez-popup.js +0 -67
  134. package/dist/components/ez-search.js +0 -100
  135. package/dist/components/ez-tabselector.js +0 -6
  136. package/dist/components/ez-tabselector2.js +0 -213
  137. package/dist/components/ez-text-area.js +0 -137
  138. package/dist/components/ez-text-input.js +0 -6
  139. package/dist/components/ez-text-input2.js +0 -223
  140. package/dist/components/ez-time-input.js +0 -153
  141. package/dist/components/ez-toast.js +0 -64
  142. package/dist/components/ez-upload.js +0 -382
  143. package/dist/components/grid-config.js +0 -6
  144. package/dist/components/grid-config2.js +0 -318
  145. package/dist/components/select-box.js +0 -6
  146. package/dist/components/select-box2.js +0 -47
  147. package/dist/components/test-du.js +0 -101
  148. package/dist/esm/ApplicationUtils-e0b6d857.js +0 -37
  149. package/dist/esm/AssetsUtils-98074c9c.js +0 -22
  150. package/dist/esm/CSSVarsUtils-0787c3f3.js +0 -17
  151. package/dist/esm/_commonjsHelpers-9943807e.js +0 -17
  152. package/dist/esm/ez-action-chip.entry.js +0 -23
  153. package/dist/esm/ez-application.entry.js +0 -22
  154. package/dist/esm/ez-button_4.entry.js +0 -653
  155. package/dist/esm/ez-calendar.entry.js +0 -219
  156. package/dist/esm/ez-collapsible-box.entry.js +0 -43
  157. package/dist/esm/ez-combo-box.entry.js +0 -274
  158. package/dist/esm/ez-date-input.entry.js +0 -98
  159. package/dist/esm/ez-date-time-input.entry.js +0 -141
  160. package/dist/esm/ez-dialog.entry.js +0 -85
  161. package/dist/esm/ez-form.entry.js +0 -781
  162. package/dist/esm/ez-grid.entry.js +0 -110481
  163. package/dist/esm/ez-icon.entry.js +0 -37
  164. package/dist/esm/ez-label-chip.entry.js +0 -100
  165. package/dist/esm/ez-modal_2.entry.js +0 -311
  166. package/dist/esm/ez-number-input.entry.js +0 -82
  167. package/dist/esm/ez-popover.entry.js +0 -116
  168. package/dist/esm/ez-popup.entry.js +0 -44
  169. package/dist/esm/ez-search.entry.js +0 -60
  170. package/dist/esm/ez-tabselector.entry.js +0 -194
  171. package/dist/esm/ez-text-area.entry.js +0 -110
  172. package/dist/esm/ez-text-input.entry.js +0 -197
  173. package/dist/esm/ez-time-input.entry.js +0 -114
  174. package/dist/esm/ez-toast.entry.js +0 -40
  175. package/dist/esm/ez-upload.entry.js +0 -352
  176. package/dist/esm/index-df166135.js +0 -1738
  177. package/dist/esm/test-du.entry.js +0 -72
  178. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +0 -67
  179. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +0 -3
  180. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +0 -180
  181. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +0 -319
  182. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +0 -327
  183. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +0 -162
  184. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +0 -217
  185. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +0 -49
  186. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +0 -44
  187. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +0 -527
  188. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +0 -5
  189. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +0 -31
  190. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +0 -129
  191. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +0 -10
  192. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +0 -176
  193. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +0 -139
  194. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +0 -335
  195. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +0 -358
  196. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +0 -4
  197. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +0 -44
  198. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +0 -405
  199. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +0 -3
  200. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -138
  201. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +0 -165
  202. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +0 -196
  203. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +0 -10
  204. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +0 -127
  205. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +0 -568
  206. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +0 -3
  207. package/dist/sankhyablocks/p-08e1cded.entry.js +0 -1
  208. package/dist/sankhyablocks/p-0a77ac95.entry.js +0 -57
  209. package/dist/sankhyablocks/p-112455b1.js +0 -1
  210. package/dist/sankhyablocks/p-126c4aaa.entry.js +0 -1
  211. package/dist/sankhyablocks/p-1421b89a.entry.js +0 -1
  212. package/dist/sankhyablocks/p-1beadcaf.entry.js +0 -1
  213. package/dist/sankhyablocks/p-1c423f5d.entry.js +0 -1
  214. package/dist/sankhyablocks/p-28a0dbf0.entry.js +0 -1
  215. package/dist/sankhyablocks/p-4763d5c2.js +0 -1
  216. package/dist/sankhyablocks/p-4c66200a.entry.js +0 -1
  217. package/dist/sankhyablocks/p-5dc772be.entry.js +0 -1
  218. package/dist/sankhyablocks/p-5ff3e300.entry.js +0 -1
  219. package/dist/sankhyablocks/p-7122cec4.entry.js +0 -1
  220. package/dist/sankhyablocks/p-811b4b9d.js +0 -1
  221. package/dist/sankhyablocks/p-813fe4f7.js +0 -1
  222. package/dist/sankhyablocks/p-9b33a005.entry.js +0 -1
  223. package/dist/sankhyablocks/p-9e22ec87.entry.js +0 -1
  224. package/dist/sankhyablocks/p-9f7239df.entry.js +0 -1
  225. package/dist/sankhyablocks/p-9f7e6e48.js +0 -1
  226. package/dist/sankhyablocks/p-a47e0537.entry.js +0 -1
  227. package/dist/sankhyablocks/p-a9aba60a.entry.js +0 -1
  228. package/dist/sankhyablocks/p-afda7940.entry.js +0 -1
  229. package/dist/sankhyablocks/p-b3a83eaf.entry.js +0 -1
  230. package/dist/sankhyablocks/p-b96a8d40.entry.js +0 -1
  231. package/dist/sankhyablocks/p-c61c0e40.entry.js +0 -1
  232. package/dist/sankhyablocks/p-ca29d028.entry.js +0 -1
  233. package/dist/sankhyablocks/p-cd17abb1.entry.js +0 -1
  234. package/dist/sankhyablocks/p-d3a5366d.entry.js +0 -369
  235. package/dist/sankhyablocks/p-d5703a41.entry.js +0 -1
  236. package/dist/sankhyablocks/p-e5f77a59.entry.js +0 -1
  237. package/dist/sankhyablocks/p-e9e94d51.entry.js +0 -1
@@ -1,8 +1,23 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { DataUnit, ChangeOperation, DateUtils, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
- import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers.js';
4
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
4
 
5
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
+
7
+ function createCommonjsModule(fn, basedir, module) {
8
+ return module = {
9
+ path: basedir,
10
+ exports: {},
11
+ require: function (path, base) {
12
+ return commonjsRequire();
13
+ }
14
+ }, fn(module, module.exports), module.exports;
15
+ }
16
+
17
+ function commonjsRequire () {
18
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
19
+ }
20
+
6
21
  var browserPonyfill = createCommonjsModule(function (module, exports) {
7
22
  var global = typeof self !== 'undefined' ? self : commonjsGlobal;
8
23
  var __self__ = (function () {
@@ -5651,6 +5666,280 @@ exports.ClientError = ClientError;
5651
5666
  //# sourceMappingURL=types.js.map
5652
5667
  });
5653
5668
 
5669
+ var graphqlWs = createCommonjsModule(function (module, exports) {
5670
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
5671
+ __assign = Object.assign || function(t) {
5672
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5673
+ s = arguments[i];
5674
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5675
+ t[p] = s[p];
5676
+ }
5677
+ return t;
5678
+ };
5679
+ return __assign.apply(this, arguments);
5680
+ };
5681
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
5682
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5683
+ return new (P || (P = Promise))(function (resolve, reject) {
5684
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5685
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5686
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5687
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5688
+ });
5689
+ };
5690
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
5691
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
5692
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5693
+ function verb(n) { return function (v) { return step([n, v]); }; }
5694
+ function step(op) {
5695
+ if (f) throw new TypeError("Generator is already executing.");
5696
+ while (_) try {
5697
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
5698
+ if (y = 0, t) op = [op[0] & 2, t.value];
5699
+ switch (op[0]) {
5700
+ case 0: case 1: t = op; break;
5701
+ case 4: _.label++; return { value: op[1], done: false };
5702
+ case 5: _.label++; y = op[1]; op = [0]; continue;
5703
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
5704
+ default:
5705
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
5706
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
5707
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
5708
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
5709
+ if (t[2]) _.ops.pop();
5710
+ _.trys.pop(); continue;
5711
+ }
5712
+ op = body.call(thisArg, _);
5713
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
5714
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
5715
+ }
5716
+ };
5717
+ Object.defineProperty(exports, "__esModule", { value: true });
5718
+ exports.GraphQLWebSocketClient = void 0;
5719
+
5720
+
5721
+ var CONNECTION_INIT = 'connection_init';
5722
+ var CONNECTION_ACK = 'connection_ack';
5723
+ var PING = 'ping';
5724
+ var PONG = 'pong';
5725
+ var SUBSCRIBE = 'subscribe';
5726
+ var NEXT = 'next';
5727
+ var ERROR = 'error';
5728
+ var COMPLETE = 'complete';
5729
+ var GraphQLWebSocketMessage = /** @class */ (function () {
5730
+ function GraphQLWebSocketMessage(type, payload, id) {
5731
+ this._type = type;
5732
+ this._payload = payload;
5733
+ this._id = id;
5734
+ }
5735
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "type", {
5736
+ get: function () { return this._type; },
5737
+ enumerable: false,
5738
+ configurable: true
5739
+ });
5740
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "id", {
5741
+ get: function () { return this._id; },
5742
+ enumerable: false,
5743
+ configurable: true
5744
+ });
5745
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "payload", {
5746
+ get: function () { return this._payload; },
5747
+ enumerable: false,
5748
+ configurable: true
5749
+ });
5750
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "text", {
5751
+ get: function () {
5752
+ var result = { type: this.type };
5753
+ if (this.id != null && this.id != undefined)
5754
+ result.id = this.id;
5755
+ if (this.payload != null && this.payload != undefined)
5756
+ result.payload = this.payload;
5757
+ return JSON.stringify(result);
5758
+ },
5759
+ enumerable: false,
5760
+ configurable: true
5761
+ });
5762
+ GraphQLWebSocketMessage.parse = function (data, f) {
5763
+ var _a = JSON.parse(data), type = _a.type, payload = _a.payload, id = _a.id;
5764
+ return new GraphQLWebSocketMessage(type, f(payload), id);
5765
+ };
5766
+ return GraphQLWebSocketMessage;
5767
+ }());
5768
+ var GraphQLWebSocketClient = /** @class */ (function () {
5769
+ function GraphQLWebSocketClient(socket, _a) {
5770
+ var _this = this;
5771
+ var onInit = _a.onInit, onAcknowledged = _a.onAcknowledged, onPing = _a.onPing, onPong = _a.onPong;
5772
+ this.socketState = { acknowledged: false, lastRequestId: 0, subscriptions: {} };
5773
+ this.socket = socket;
5774
+ socket.onopen = function (e) { return __awaiter(_this, void 0, void 0, function () {
5775
+ var _a, _b, _c, _d;
5776
+ return __generator(this, function (_e) {
5777
+ switch (_e.label) {
5778
+ case 0:
5779
+ this.socketState.acknowledged = false;
5780
+ this.socketState.subscriptions = {};
5781
+ _b = (_a = socket).send;
5782
+ _c = ConnectionInit;
5783
+ if (!onInit) return [3 /*break*/, 2];
5784
+ return [4 /*yield*/, onInit()];
5785
+ case 1:
5786
+ _d = _e.sent();
5787
+ return [3 /*break*/, 3];
5788
+ case 2:
5789
+ _d = null;
5790
+ _e.label = 3;
5791
+ case 3:
5792
+ _b.apply(_a, [_c.apply(void 0, [_d]).text]);
5793
+ return [2 /*return*/];
5794
+ }
5795
+ });
5796
+ }); };
5797
+ socket.onclose = function (e) {
5798
+ _this.socketState.acknowledged = false;
5799
+ _this.socketState.subscriptions = {};
5800
+ };
5801
+ socket.onerror = function (e) {
5802
+ console.error(e);
5803
+ };
5804
+ socket.onmessage = function (e) {
5805
+ try {
5806
+ var message = parseMessage(e.data);
5807
+ switch (message.type) {
5808
+ case CONNECTION_ACK: {
5809
+ if (_this.socketState.acknowledged) {
5810
+ console.warn("Duplicate CONNECTION_ACK message ignored");
5811
+ }
5812
+ else {
5813
+ _this.socketState.acknowledged = true;
5814
+ if (onAcknowledged)
5815
+ onAcknowledged(message.payload);
5816
+ }
5817
+ return;
5818
+ }
5819
+ case PING: {
5820
+ if (onPing)
5821
+ onPing(message.payload).then(function (r) { return socket.send(Pong(r).text); });
5822
+ else
5823
+ socket.send(Pong(null).text);
5824
+ return;
5825
+ }
5826
+ case PONG: {
5827
+ if (onPong)
5828
+ onPong(message.payload);
5829
+ return;
5830
+ }
5831
+ }
5832
+ if (!_this.socketState.acknowledged) {
5833
+ // Web-socket connection not acknowledged
5834
+ return;
5835
+ }
5836
+ if (message.id === undefined || message.id === null || !_this.socketState.subscriptions[message.id]) {
5837
+ // No subscription identifer or subscription indentifier is not found
5838
+ return;
5839
+ }
5840
+ var _a = _this.socketState.subscriptions[message.id], query = _a.query, variables = _a.variables, subscriber = _a.subscriber;
5841
+ switch (message.type) {
5842
+ case NEXT: {
5843
+ if (!message.payload.errors && message.payload.data) {
5844
+ subscriber.next && subscriber.next(message.payload.data);
5845
+ }
5846
+ if (message.payload.errors) {
5847
+ subscriber.error && subscriber.error(new types.ClientError(__assign(__assign({}, message.payload), { status: 200 }), { query: query, variables: variables }));
5848
+ }
5849
+ return;
5850
+ }
5851
+ case ERROR: {
5852
+ subscriber.error && subscriber.error(new types.ClientError({ errors: message.payload, status: 200 }, { query: query, variables: variables }));
5853
+ return;
5854
+ }
5855
+ case COMPLETE: {
5856
+ subscriber.complete && subscriber.complete();
5857
+ delete _this.socketState.subscriptions[message.id];
5858
+ return;
5859
+ }
5860
+ }
5861
+ }
5862
+ catch (e) {
5863
+ // Unexpected errors while handling graphql-ws message
5864
+ console.error(e);
5865
+ socket.close(1006);
5866
+ }
5867
+ socket.close(4400, "Unknown graphql-ws message.");
5868
+ };
5869
+ }
5870
+ GraphQLWebSocketClient.prototype.makeSubscribe = function (query, operationName, variables, subscriber) {
5871
+ var _this = this;
5872
+ var subscriptionId = (this.socketState.lastRequestId++).toString();
5873
+ this.socketState.subscriptions[subscriptionId] = { query: query, variables: variables, subscriber: subscriber };
5874
+ this.socket.send(Subscribe(subscriptionId, { query: query, operationName: operationName, variables: variables }).text);
5875
+ return function () {
5876
+ _this.socket.send(Complete(subscriptionId).text);
5877
+ delete _this.socketState.subscriptions[subscriptionId];
5878
+ };
5879
+ };
5880
+ GraphQLWebSocketClient.prototype.rawRequest = function (query, variables) {
5881
+ var _this = this;
5882
+ return new Promise(function (resolve, reject) {
5883
+ var result;
5884
+ _this.rawSubscribe(query, {
5885
+ next: function (data, extensions) { return (result = { data: data, extensions: extensions }); },
5886
+ error: reject,
5887
+ complete: function () { return resolve(result); },
5888
+ }, variables);
5889
+ });
5890
+ };
5891
+ GraphQLWebSocketClient.prototype.request = function (document, variables) {
5892
+ var _this = this;
5893
+ return new Promise(function (resolve, reject) {
5894
+ var result;
5895
+ _this.subscribe(document, {
5896
+ next: function (data) { return (result = data); },
5897
+ error: reject,
5898
+ complete: function () { return resolve(result); },
5899
+ }, variables);
5900
+ });
5901
+ };
5902
+ GraphQLWebSocketClient.prototype.subscribe = function (document, subscriber, variables) {
5903
+ var _a = dist.resolveRequestDocument(document), query = _a.query, operationName = _a.operationName;
5904
+ return this.makeSubscribe(query, operationName, variables, subscriber);
5905
+ };
5906
+ GraphQLWebSocketClient.prototype.rawSubscribe = function (query, subscriber, variables) {
5907
+ return this.makeSubscribe(query, undefined, variables, subscriber);
5908
+ };
5909
+ GraphQLWebSocketClient.prototype.ping = function (payload) {
5910
+ this.socket.send(Ping(payload).text);
5911
+ };
5912
+ GraphQLWebSocketClient.prototype.close = function () {
5913
+ this.socket.close(1000);
5914
+ };
5915
+ GraphQLWebSocketClient.PROTOCOL = "graphql-transport-ws";
5916
+ return GraphQLWebSocketClient;
5917
+ }());
5918
+ exports.GraphQLWebSocketClient = GraphQLWebSocketClient;
5919
+ // Helper functions
5920
+ function parseMessage(data, f) {
5921
+ if (f === void 0) { f = function (a) { return a; }; }
5922
+ var m = GraphQLWebSocketMessage.parse(data, f);
5923
+ return m;
5924
+ }
5925
+ function ConnectionInit(payload) {
5926
+ return new GraphQLWebSocketMessage(CONNECTION_INIT, payload);
5927
+ }
5928
+ function Ping(payload) {
5929
+ return new GraphQLWebSocketMessage(PING, payload, undefined);
5930
+ }
5931
+ function Pong(payload) {
5932
+ return new GraphQLWebSocketMessage(PONG, payload, undefined);
5933
+ }
5934
+ function Subscribe(id, payload) {
5935
+ return new GraphQLWebSocketMessage(SUBSCRIBE, payload, id);
5936
+ }
5937
+ function Complete(id) {
5938
+ return new GraphQLWebSocketMessage(COMPLETE, undefined, id);
5939
+ }
5940
+ //# sourceMappingURL=graphql-ws.js.map
5941
+ });
5942
+
5654
5943
  var dist = createCommonjsModule(function (module, exports) {
5655
5944
  var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
5656
5945
  __assign = Object.assign || function(t) {
@@ -5733,7 +6022,7 @@ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || func
5733
6022
  return (mod && mod.__esModule) ? mod : { "default": mod };
5734
6023
  };
5735
6024
  Object.defineProperty(exports, "__esModule", { value: true });
5736
- exports.gql = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
6025
+ exports.GraphQLWebSocketClient = exports.gql = exports.resolveRequestDocument = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
5737
6026
  var cross_fetch_1 = __importStar(browserPonyfill), CrossFetch = cross_fetch_1;
5738
6027
 
5739
6028
 
@@ -5867,7 +6156,7 @@ var GraphQLClient = /** @class */ (function () {
5867
6156
  url: url,
5868
6157
  query: rawRequestOptions.query,
5869
6158
  variables: rawRequestOptions.variables,
5870
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(rawRequestOptions.requestHeaders)),
6159
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(rawRequestOptions.requestHeaders)),
5871
6160
  operationName: operationName,
5872
6161
  fetch: fetch,
5873
6162
  method: method,
@@ -5893,7 +6182,7 @@ var GraphQLClient = /** @class */ (function () {
5893
6182
  url: url,
5894
6183
  query: query,
5895
6184
  variables: requestOptions.variables,
5896
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(requestOptions.requestHeaders)),
6185
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(requestOptions.requestHeaders)),
5897
6186
  operationName: operationName,
5898
6187
  fetch: fetch,
5899
6188
  method: method,
@@ -5930,7 +6219,7 @@ var GraphQLClient = /** @class */ (function () {
5930
6219
  url: url,
5931
6220
  query: queries,
5932
6221
  variables: variables,
5933
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(batchRequestOptions.requestHeaders)),
6222
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(batchRequestOptions.requestHeaders)),
5934
6223
  operationName: undefined,
5935
6224
  fetch: fetch,
5936
6225
  method: method,
@@ -5976,7 +6265,7 @@ exports.GraphQLClient = GraphQLClient;
5976
6265
  function makeRequest(_a) {
5977
6266
  var url = _a.url, query = _a.query, variables = _a.variables, headers = _a.headers, operationName = _a.operationName, fetch = _a.fetch, _b = _a.method, method = _b === void 0 ? 'POST' : _b, fetchOptions = _a.fetchOptions;
5978
6267
  return __awaiter(this, void 0, void 0, function () {
5979
- var fetcher, isBathchingQuery, response, result, successfullyReceivedData, headers_1, status_1, errorResult;
6268
+ var fetcher, isBathchingQuery, response, result, successfullyReceivedData, successfullyPassedErrorPolicy, headers_1, status_1, rest, data, errorResult;
5980
6269
  return __generator(this, function (_c) {
5981
6270
  switch (_c.label) {
5982
6271
  case 0:
@@ -6000,9 +6289,12 @@ function makeRequest(_a) {
6000
6289
  var data = _a.data;
6001
6290
  return !data;
6002
6291
  }) : !!result.data;
6003
- if (response.ok && !result.errors && successfullyReceivedData) {
6292
+ successfullyPassedErrorPolicy = !result.errors || fetchOptions.errorPolicy === 'all' || fetchOptions.errorPolicy === 'ignore';
6293
+ if (response.ok && successfullyPassedErrorPolicy && successfullyReceivedData) {
6004
6294
  headers_1 = response.headers, status_1 = response.status;
6005
- return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: result } : result)), { headers: headers_1, status: status_1 })];
6295
+ rest = __rest(result, ["errors"]);
6296
+ data = fetchOptions.errorPolicy === 'ignore' ? rest : result;
6297
+ return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: data } : data)), { headers: headers_1, status: status_1 })];
6006
6298
  }
6007
6299
  else {
6008
6300
  errorResult = typeof result === 'string' ? { error: result } : result;
@@ -6097,6 +6389,10 @@ function resolveRequestDocument(document) {
6097
6389
  var operationName = extractOperationName(document);
6098
6390
  return { query: printer.print(document), operationName: operationName };
6099
6391
  }
6392
+ exports.resolveRequestDocument = resolveRequestDocument;
6393
+ function callOrIdentity(value) {
6394
+ return typeof value === 'function' ? value() : value;
6395
+ }
6100
6396
  /**
6101
6397
  * Convenience passthrough template tag to get the benefits of tooling for the gql template tag. This does not actually parse the input into a GraphQL DocumentNode like graphql-tag package does. It just returns the string with any variables given interpolated. Can save you a bit of performance and having to install another package.
6102
6398
  *
@@ -6128,666 +6424,668 @@ function HeadersInstanceToPlainObject(headers) {
6128
6424
  });
6129
6425
  return o;
6130
6426
  }
6427
+
6428
+ Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get: function () { return graphqlWs.GraphQLWebSocketClient; } });
6131
6429
  //# sourceMappingURL=index.js.map
6132
6430
  });
6133
6431
 
6134
- class HttpFetcher {
6135
- constructor() {
6136
- this.watingRequestsById = new Map();
6137
- }
6138
- static get() {
6139
- if (!HttpFetcher.instance) {
6140
- HttpFetcher.instance = new HttpFetcher();
6141
- const application = document.querySelector(this.appTagName);
6142
- if (application === null) {
6143
- HttpFetcher.instance.resume();
6144
- }
6145
- else {
6146
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6147
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6148
- }
6149
- }
6150
- return this.instance;
6151
- }
6152
- async callGraphQL(req) {
6153
- var _a;
6154
- const reqKey = this.getReqKey(req);
6155
- req.queryID = reqKey;
6156
- req.values.queryID = reqKey;
6157
- if (this.ready) {
6158
- return new Promise(async (resolve, reject) => {
6159
- let query = this.getQueryTemplate(req);
6160
- const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6161
- if (res.errors.length > 0) {
6162
- reject(res);
6163
- }
6164
- else {
6165
- //resolve(res);
6166
- //FIXME: Precisamos trabalhar melhor a resposta, quem chamou
6167
- //a API não pode ficar responsavel por desempacotar... fiz uma
6168
- //gambiarra aqui...
6169
- resolve(res.data[0][reqKey]);
6170
- }
6171
- });
6172
- }
6173
- else {
6174
- if (!this.watingRequestsById.has(reqKey)) {
6175
- this.watingRequestsById.set(reqKey, new WaitingRequest(req));
6176
- }
6177
- return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
6178
- }
6179
- }
6180
- getReqKey(req) {
6181
- return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6182
- }
6183
- getQueryTemplate(re) {
6184
- return (re.query || "").replaceAll("$queryAlias$", re.queryID);
6185
- }
6186
- getWatingRequest(reqID) {
6187
- return this.watingRequestsById.get(reqID);
6188
- }
6189
- pause() {
6190
- this.ready = false;
6191
- }
6192
- async resume() {
6193
- this.ready = true;
6194
- if (this.watingRequestsById.size > 0) {
6195
- const requestsBatch = [];
6196
- this.watingRequestsById.forEach(async (waitingReq) => {
6197
- let query = this.getQueryTemplate(waitingReq.request);
6198
- requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
6199
- });
6200
- let res = undefined;
6201
- let dataResponse = [];
6202
- let errorsResponse = [];
6203
- res = await this.fecthGrapql(requestsBatch);
6204
- dataResponse = res.data;
6205
- errorsResponse = res.errors;
6206
- //Reject promises with errors from query
6207
- errorsResponse.forEach((errorResponse) => {
6208
- Object.entries(errorResponse).forEach(([_key, val]) => {
6209
- var _a;
6210
- (((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
6211
- });
6212
- });
6213
- //Resolve promises with data from query
6214
- dataResponse.forEach((data) => {
6215
- Object.entries(data).forEach(([key, val]) => {
6216
- var _a;
6217
- (((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
6218
- });
6219
- });
6220
- this.watingRequestsById.clear();
6221
- }
6222
- }
6223
- async fecthGrapql(request) {
6224
- let res = undefined;
6225
- let dataResponse = [];
6226
- let errorsResponse = [];
6227
- try {
6228
- res = await dist.batchRequests('http://localhost:8082/', request);
6229
- res.forEach((resItem) => {
6230
- dataResponse.push(resItem.data);
6231
- });
6232
- }
6233
- catch (err) {
6234
- //TODO: Tratar erro quando não existir err.response
6235
- res = err.response;
6236
- const req = err.request;
6237
- Object.entries(res).forEach(([key, val]) => {
6238
- if (val.errors) {
6239
- errorsResponse.push(val.errors.map((item) => {
6240
- item.request = req;
6241
- item.index = Number(key);
6242
- return item;
6243
- }));
6244
- }
6245
- else if (val.data) {
6246
- dataResponse.push(val.data);
6247
- }
6248
- });
6249
- }
6250
- return { data: dataResponse, errors: errorsResponse };
6251
- }
6252
- //TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
6253
- hashCode(txt) {
6254
- var hash = 0, i, chr;
6255
- if (txt.length === 0)
6256
- return hash.toString();
6257
- for (i = 0; i < txt.length; i++) {
6258
- chr = txt.charCodeAt(i);
6259
- hash = ((hash << 5) - hash) + chr;
6260
- hash |= 0; // Convert to 32bit integer
6261
- }
6262
- return hash.toString();
6263
- }
6264
- ;
6265
- }
6266
- HttpFetcher.appTagName = "snk-application";
6267
- class WaitingRequest {
6268
- constructor(req) {
6269
- this._resolve = () => { };
6270
- this._reject = () => { };
6271
- this._request = undefined;
6272
- this._request = req;
6273
- this._promisse = new Promise((resolve, reject) => {
6274
- this._resolve = resolve;
6275
- this._reject = reject;
6276
- });
6277
- }
6278
- get resolve() {
6279
- return this._resolve;
6280
- }
6281
- get reject() {
6282
- return this._reject;
6283
- }
6284
- get promise() {
6285
- return this._promisse;
6286
- }
6287
- get request() {
6288
- return this._request;
6289
- }
6432
+ class HttpFetcher {
6433
+ constructor() {
6434
+ this.watingRequestsById = new Map();
6435
+ }
6436
+ static get() {
6437
+ if (!HttpFetcher.instance) {
6438
+ HttpFetcher.instance = new HttpFetcher();
6439
+ const application = document.querySelector(this.appTagName);
6440
+ if (application === null) {
6441
+ HttpFetcher.instance.resume();
6442
+ }
6443
+ else {
6444
+ application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6445
+ application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6446
+ }
6447
+ }
6448
+ return this.instance;
6449
+ }
6450
+ async callGraphQL(req) {
6451
+ var _a;
6452
+ const reqKey = this.getReqKey(req);
6453
+ req.queryID = reqKey;
6454
+ req.values.queryID = reqKey;
6455
+ if (this.ready) {
6456
+ return new Promise(async (resolve, reject) => {
6457
+ let query = this.getQueryTemplate(req);
6458
+ const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6459
+ if (res.errors.length > 0) {
6460
+ reject(res);
6461
+ }
6462
+ else {
6463
+ //resolve(res);
6464
+ //FIXME: Precisamos trabalhar melhor a resposta, quem chamou
6465
+ //a API não pode ficar responsavel por desempacotar... fiz uma
6466
+ //gambiarra aqui...
6467
+ resolve(res.data[0][reqKey]);
6468
+ }
6469
+ });
6470
+ }
6471
+ else {
6472
+ if (!this.watingRequestsById.has(reqKey)) {
6473
+ this.watingRequestsById.set(reqKey, new WaitingRequest(req));
6474
+ }
6475
+ return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
6476
+ }
6477
+ }
6478
+ getReqKey(req) {
6479
+ return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6480
+ }
6481
+ getQueryTemplate(re) {
6482
+ return (re.query || "").replaceAll("$queryAlias$", re.queryID);
6483
+ }
6484
+ getWatingRequest(reqID) {
6485
+ return this.watingRequestsById.get(reqID);
6486
+ }
6487
+ pause() {
6488
+ this.ready = false;
6489
+ }
6490
+ async resume() {
6491
+ this.ready = true;
6492
+ if (this.watingRequestsById.size > 0) {
6493
+ const requestsBatch = [];
6494
+ this.watingRequestsById.forEach(async (waitingReq) => {
6495
+ let query = this.getQueryTemplate(waitingReq.request);
6496
+ requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
6497
+ });
6498
+ let res = undefined;
6499
+ let dataResponse = [];
6500
+ let errorsResponse = [];
6501
+ res = await this.fecthGrapql(requestsBatch);
6502
+ dataResponse = res.data;
6503
+ errorsResponse = res.errors;
6504
+ //Reject promises with errors from query
6505
+ errorsResponse.forEach((errorResponse) => {
6506
+ Object.entries(errorResponse).forEach(([_key, val]) => {
6507
+ var _a;
6508
+ (((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
6509
+ });
6510
+ });
6511
+ //Resolve promises with data from query
6512
+ dataResponse.forEach((data) => {
6513
+ Object.entries(data).forEach(([key, val]) => {
6514
+ var _a;
6515
+ (((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
6516
+ });
6517
+ });
6518
+ this.watingRequestsById.clear();
6519
+ }
6520
+ }
6521
+ async fecthGrapql(request) {
6522
+ let res = undefined;
6523
+ let dataResponse = [];
6524
+ let errorsResponse = [];
6525
+ try {
6526
+ res = await dist.batchRequests('http://localhost:8082/', request);
6527
+ res.forEach((resItem) => {
6528
+ dataResponse.push(resItem.data);
6529
+ });
6530
+ }
6531
+ catch (err) {
6532
+ //TODO: Tratar erro quando não existir err.response
6533
+ res = err.response;
6534
+ const req = err.request;
6535
+ Object.entries(res).forEach(([key, val]) => {
6536
+ if (val.errors) {
6537
+ errorsResponse.push(val.errors.map((item) => {
6538
+ item.request = req;
6539
+ item.index = Number(key);
6540
+ return item;
6541
+ }));
6542
+ }
6543
+ else if (val.data) {
6544
+ dataResponse.push(val.data);
6545
+ }
6546
+ });
6547
+ }
6548
+ return { data: dataResponse, errors: errorsResponse };
6549
+ }
6550
+ //TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
6551
+ hashCode(txt) {
6552
+ var hash = 0, i, chr;
6553
+ if (txt.length === 0)
6554
+ return hash.toString();
6555
+ for (i = 0; i < txt.length; i++) {
6556
+ chr = txt.charCodeAt(i);
6557
+ hash = ((hash << 5) - hash) + chr;
6558
+ hash |= 0; // Convert to 32bit integer
6559
+ }
6560
+ return hash.toString();
6561
+ }
6562
+ ;
6563
+ }
6564
+ HttpFetcher.appTagName = "snk-application";
6565
+ class WaitingRequest {
6566
+ constructor(req) {
6567
+ this._resolve = () => { };
6568
+ this._reject = () => { };
6569
+ this._request = undefined;
6570
+ this._request = req;
6571
+ this._promisse = new Promise((resolve, reject) => {
6572
+ this._resolve = resolve;
6573
+ this._reject = reject;
6574
+ });
6575
+ }
6576
+ get resolve() {
6577
+ return this._resolve;
6578
+ }
6579
+ get reject() {
6580
+ return this._reject;
6581
+ }
6582
+ get promise() {
6583
+ return this._promisse;
6584
+ }
6585
+ get request() {
6586
+ return this._request;
6587
+ }
6290
6588
  }
6291
6589
 
6292
- class DataUnitFetcher {
6293
- constructor() {
6294
- this.templateByQuery = new Map();
6295
- this.buldTemplates();
6296
- }
6297
- buldTemplates() {
6298
- this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
6299
- $queryAlias$: fetchDataUnit(name: $name){
6300
- name
6301
- fields{
6302
- name
6303
- defaultValue
6304
- label
6305
- readOnly
6306
- required
6307
- dataType
6308
- userInterface
6309
- properties{
6310
- name
6311
- value
6312
- }
6313
- dependencies{
6314
- masterFields
6315
- type
6316
- expression
6317
- }
6318
- }
6319
- }
6320
- }`);
6321
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6322
- $queryAlias$: fetchDataUnit(name: $dataunit){
6323
- data(first: $first offset: $offset filters: $filter sort: $sort){
6324
- first
6325
- offset
6326
- total
6327
- hasMore
6328
- records{
6329
- id
6330
- fields {
6331
- name
6332
- value
6333
- }
6334
- }
6335
- }
6336
- }
6337
- }`);
6338
- this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
6339
- $queryAlias$: saveDataUnitChanges(changes: $changes){
6340
- oldId
6341
- id
6342
- fields {
6343
- name
6344
- value
6345
- }
6346
- }
6347
- }`);
6348
- }
6349
- getDataUnit(entityName, resourceID) {
6350
- const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6351
- dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6352
- dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6353
- dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6354
- dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6355
- return dataUnit;
6356
- }
6357
- loadMetadata(dataUnit) {
6358
- return new Promise((resolve, reject) => {
6359
- HttpFetcher.get()
6360
- .callGraphQL({
6361
- values: { name: dataUnit.name },
6362
- query: this.templateByQuery.get("fetchDataUnit"),
6363
- })
6364
- .then((resp) => {
6365
- var _a;
6366
- const metadata = {
6367
- name: resp.name,
6368
- label: resp.name,
6369
- fields: [],
6370
- };
6371
- (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
6372
- let properties = undefined;
6373
- if (Array.isArray(source.properties)) {
6374
- properties = {};
6375
- source.properties.forEach((prop) => (properties[prop.name] = prop.value));
6376
- }
6377
- metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
6378
- });
6379
- resolve(metadata);
6380
- })
6381
- .catch((error) => {
6382
- reject(error);
6383
- });
6384
- });
6385
- }
6386
- loadData(dataUnit, sort, filters) {
6387
- return new Promise((resolve, reject) => {
6388
- HttpFetcher.get()
6389
- .callGraphQL({
6390
- values: { dataunit: dataUnit.name, sort, filters },
6391
- query: this.templateByQuery.get("fetchData"),
6392
- })
6393
- .then((resp) => {
6394
- const result = resp.data;
6395
- const dataUnitRecords = [];
6396
- result.records.forEach((responseRecord) => {
6397
- const duRecord = { __record__id__: responseRecord.id };
6398
- responseRecord.fields.forEach(({ name, value }) => {
6399
- duRecord[name] = dataUnit.valueFromString(name, value);
6400
- });
6401
- dataUnitRecords.push(duRecord);
6402
- });
6403
- resolve(dataUnitRecords);
6404
- })
6405
- .catch((error) => {
6406
- reject(error);
6407
- });
6408
- });
6409
- }
6410
- saveData(dataUnit, duChanges) {
6411
- const changes = duChanges.map((change) => {
6412
- const { dataUnit: changeDU, record, updatingFields, operation } = change;
6413
- const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
6414
- return { fieldName, value: this.formatValueToServer(value) };
6415
- });
6416
- return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
6417
- });
6418
- return new Promise((resolve, reject) => {
6419
- HttpFetcher.get()
6420
- .callGraphQL({
6421
- values: { changes: changes },
6422
- query: this.templateByQuery.get("saveData"),
6423
- })
6424
- .then((resp) => {
6425
- const dataUnitRecords = [];
6426
- resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
6427
- const duRecord = { __record__id__: responseRecord.id };
6428
- if (responseRecord.oldId) {
6429
- duRecord.__old__id__ = responseRecord.oldId;
6430
- }
6431
- responseRecord.fields.forEach(({ name, value }) => {
6432
- duRecord[name] = dataUnit.valueFromString(name, value);
6433
- });
6434
- dataUnitRecords.push(duRecord);
6435
- });
6436
- resolve(dataUnitRecords);
6437
- })
6438
- .catch((error) => {
6439
- reject(error);
6440
- });
6441
- });
6442
- }
6443
- formatValueToServer(value) {
6444
- if (value === undefined)
6445
- return value;
6446
- try {
6447
- if (value instanceof Date) {
6448
- return value.toString();
6449
- }
6450
- //Any others objects
6451
- value = JSON.stringify(value);
6452
- }
6453
- catch (_a) {
6454
- value = value.toString();
6455
- }
6456
- return value;
6457
- }
6458
- removeRecords(dataUnit, recordIds) {
6459
- const changes = recordIds.map((recordId) => {
6460
- return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
6461
- });
6462
- return new Promise((resolve, reject) => {
6463
- HttpFetcher.get()
6464
- .callGraphQL({
6465
- values: { changes: changes },
6466
- query: this.templateByQuery.get("saveData"),
6467
- })
6468
- .then((_resp) => {
6469
- resolve(recordIds);
6470
- })
6471
- .catch((error) => {
6472
- reject(error);
6473
- });
6474
- });
6475
- }
6590
+ class DataUnitFetcher {
6591
+ constructor() {
6592
+ this.templateByQuery = new Map();
6593
+ this.buldTemplates();
6594
+ }
6595
+ buldTemplates() {
6596
+ this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
6597
+ $queryAlias$: fetchDataUnit(name: $name){
6598
+ name
6599
+ fields{
6600
+ name
6601
+ defaultValue
6602
+ label
6603
+ readOnly
6604
+ required
6605
+ dataType
6606
+ userInterface
6607
+ properties{
6608
+ name
6609
+ value
6610
+ }
6611
+ dependencies{
6612
+ masterFields
6613
+ type
6614
+ expression
6615
+ }
6616
+ }
6617
+ }
6618
+ }`);
6619
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6620
+ $queryAlias$: fetchDataUnit(name: $dataunit){
6621
+ data(first: $first offset: $offset filters: $filter sort: $sort){
6622
+ first
6623
+ offset
6624
+ total
6625
+ hasMore
6626
+ records{
6627
+ id
6628
+ fields {
6629
+ name
6630
+ value
6631
+ }
6632
+ }
6633
+ }
6634
+ }
6635
+ }`);
6636
+ this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
6637
+ $queryAlias$: saveDataUnitChanges(changes: $changes){
6638
+ oldId
6639
+ id
6640
+ fields {
6641
+ name
6642
+ value
6643
+ }
6644
+ }
6645
+ }`);
6646
+ }
6647
+ getDataUnit(entityName, resourceID) {
6648
+ const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6649
+ dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6650
+ dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6651
+ dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6652
+ dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6653
+ return dataUnit;
6654
+ }
6655
+ loadMetadata(dataUnit) {
6656
+ return new Promise((resolve, reject) => {
6657
+ HttpFetcher.get()
6658
+ .callGraphQL({
6659
+ values: { name: dataUnit.name },
6660
+ query: this.templateByQuery.get("fetchDataUnit"),
6661
+ })
6662
+ .then((resp) => {
6663
+ var _a;
6664
+ const metadata = {
6665
+ name: resp.name,
6666
+ label: resp.name,
6667
+ fields: [],
6668
+ };
6669
+ (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
6670
+ let properties = undefined;
6671
+ if (Array.isArray(source.properties)) {
6672
+ properties = {};
6673
+ source.properties.forEach((prop) => (properties[prop.name] = prop.value));
6674
+ }
6675
+ metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
6676
+ });
6677
+ resolve(metadata);
6678
+ })
6679
+ .catch((error) => {
6680
+ reject(error);
6681
+ });
6682
+ });
6683
+ }
6684
+ loadData(dataUnit, sort, filters) {
6685
+ return new Promise((resolve, reject) => {
6686
+ HttpFetcher.get()
6687
+ .callGraphQL({
6688
+ values: { dataunit: dataUnit.name, sort, filters },
6689
+ query: this.templateByQuery.get("fetchData"),
6690
+ })
6691
+ .then((resp) => {
6692
+ const result = resp.data;
6693
+ const dataUnitRecords = [];
6694
+ result.records.forEach((responseRecord) => {
6695
+ const duRecord = { __record__id__: responseRecord.id };
6696
+ responseRecord.fields.forEach(({ name, value }) => {
6697
+ duRecord[name] = dataUnit.valueFromString(name, value);
6698
+ });
6699
+ dataUnitRecords.push(duRecord);
6700
+ });
6701
+ resolve(dataUnitRecords);
6702
+ })
6703
+ .catch((error) => {
6704
+ reject(error);
6705
+ });
6706
+ });
6707
+ }
6708
+ saveData(dataUnit, duChanges) {
6709
+ const changes = duChanges.map((change) => {
6710
+ const { dataUnit: changeDU, record, updatingFields, operation } = change;
6711
+ const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
6712
+ return { fieldName, value: this.formatValueToServer(value) };
6713
+ });
6714
+ return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
6715
+ });
6716
+ return new Promise((resolve, reject) => {
6717
+ HttpFetcher.get()
6718
+ .callGraphQL({
6719
+ values: { changes: changes },
6720
+ query: this.templateByQuery.get("saveData"),
6721
+ })
6722
+ .then((resp) => {
6723
+ const dataUnitRecords = [];
6724
+ resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
6725
+ const duRecord = { __record__id__: responseRecord.id };
6726
+ if (responseRecord.oldId) {
6727
+ duRecord.__old__id__ = responseRecord.oldId;
6728
+ }
6729
+ responseRecord.fields.forEach(({ name, value }) => {
6730
+ duRecord[name] = dataUnit.valueFromString(name, value);
6731
+ });
6732
+ dataUnitRecords.push(duRecord);
6733
+ });
6734
+ resolve(dataUnitRecords);
6735
+ })
6736
+ .catch((error) => {
6737
+ reject(error);
6738
+ });
6739
+ });
6740
+ }
6741
+ formatValueToServer(value) {
6742
+ if (value === undefined)
6743
+ return value;
6744
+ try {
6745
+ if (value instanceof Date) {
6746
+ return value.toString();
6747
+ }
6748
+ //Any others objects
6749
+ value = JSON.stringify(value);
6750
+ }
6751
+ catch (_a) {
6752
+ value = value.toString();
6753
+ }
6754
+ return value;
6755
+ }
6756
+ removeRecords(dataUnit, recordIds) {
6757
+ const changes = recordIds.map((recordId) => {
6758
+ return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
6759
+ });
6760
+ return new Promise((resolve, reject) => {
6761
+ HttpFetcher.get()
6762
+ .callGraphQL({
6763
+ values: { changes: changes },
6764
+ query: this.templateByQuery.get("saveData"),
6765
+ })
6766
+ .then((_resp) => {
6767
+ resolve(recordIds);
6768
+ })
6769
+ .catch((error) => {
6770
+ reject(error);
6771
+ });
6772
+ });
6773
+ }
6476
6774
  }
6477
6775
 
6478
- class UrlUtils {
6479
- static getQueryParams(queryString) {
6480
- const params = new Map();
6481
- const re = /[?&]?([^=]+)=([^&]*)/g;
6482
- let tokens;
6483
- //Necessário por causa da tela Histórico Padrão que possui resourceID com acento
6484
- queryString = window.unescape(queryString);
6485
- queryString = queryString.split("+").join(" ");
6486
- while ((tokens = re.exec(queryString))) {
6487
- params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
6488
- }
6489
- //Inserimos a urlBase no params.
6490
- params.set("urlBase", this.getUrlBase());
6491
- if (window["moduleID"] && window["URIServiceBroker"]) {
6492
- params.set("moduleID", window["moduleID"]);
6493
- params.set("URIServiceBroker", window["URIServiceBroker"]);
6494
- }
6495
- return params;
6496
- }
6497
- static getUrlBase() {
6498
- return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6499
- }
6776
+ class UrlUtils {
6777
+ static getQueryParams(queryString) {
6778
+ const params = new Map();
6779
+ const re = /[?&]?([^=]+)=([^&]*)/g;
6780
+ let tokens;
6781
+ //Necessário por causa da tela Histórico Padrão que possui resourceID com acento
6782
+ queryString = window.unescape(queryString);
6783
+ queryString = queryString.split("+").join(" ");
6784
+ while ((tokens = re.exec(queryString))) {
6785
+ params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
6786
+ }
6787
+ //Inserimos a urlBase no params.
6788
+ params.set("urlBase", this.getUrlBase());
6789
+ if (window["moduleID"] && window["URIServiceBroker"]) {
6790
+ params.set("moduleID", window["moduleID"]);
6791
+ params.set("URIServiceBroker", window["URIServiceBroker"]);
6792
+ }
6793
+ return params;
6794
+ }
6795
+ static getUrlBase() {
6796
+ return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6797
+ }
6500
6798
  }
6501
6799
 
6502
- class Workspace {
6503
- static openAppActivity(resourceId, pkObject) {
6504
- var _a;
6505
- (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
6506
- }
6507
- }
6800
+ class Workspace {
6801
+ static openAppActivity(resourceId, pkObject) {
6802
+ var _a;
6803
+ (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
6804
+ }
6805
+ }
6508
6806
  Workspace.resourceID = window["workspace"].resourceID;
6509
6807
 
6510
- class ParametersFetcher {
6511
- constructor() {
6512
- this.templateByQuery = new Map();
6513
- this.buldTemplates();
6514
- }
6515
- buldTemplates() {
6516
- this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
6517
- $queryAlias$: fetchResource(name: $name){
6518
- name
6519
- resource
6520
- }
6521
- }`);
6522
- }
6523
- async getParam(name, resourceID) {
6524
- const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6525
- return HttpFetcher.get().callGraphQL({
6526
- values: { name: completPath },
6527
- query: this.templateByQuery.get("fetchParam"),
6528
- });
6529
- }
6530
- async asString(name, resourceID) {
6531
- const paramArr = await this.getParam(name, resourceID);
6532
- return this.getValue(paramArr);
6533
- }
6534
- async asInteger(name, resourceID) {
6535
- const paramArr = await this.getParam(name, resourceID);
6536
- return parseInt(this.getValue(paramArr));
6537
- }
6538
- async asFloat(name, resourceID) {
6539
- const paramArr = await this.getParam(name, resourceID);
6540
- return parseFloat(this.getValue(paramArr));
6541
- }
6542
- async asBoolean(name, resourceID) {
6543
- const paramArr = await this.getParam(name, resourceID);
6544
- return this.getValue(paramArr) == "S";
6545
- }
6546
- async asDate(name, resourceID) {
6547
- const paramArr = await this.getParam(name, resourceID);
6548
- return DateUtils.strToDate(this.getValue(paramArr));
6549
- }
6550
- async getBatchParams(names, resourceID) {
6551
- const paramArr = await this.getParam(names.join(","), resourceID);
6552
- //TODO: try to typed params val?
6553
- const response = {};
6554
- paramArr.forEach((param) => (response[param.name] = param.resource));
6555
- return response;
6556
- }
6557
- getValue(obj = {}) {
6558
- if (Array.isArray(obj) && obj.length > 0) {
6559
- obj = obj[0];
6560
- }
6561
- if (StringUtils.isEmpty(obj.resource))
6562
- return "";
6563
- return obj.resource;
6564
- }
6808
+ class ParametersFetcher {
6809
+ constructor() {
6810
+ this.templateByQuery = new Map();
6811
+ this.buldTemplates();
6812
+ }
6813
+ buldTemplates() {
6814
+ this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
6815
+ $queryAlias$: fetchResource(name: $name){
6816
+ name
6817
+ resource
6818
+ }
6819
+ }`);
6820
+ }
6821
+ async getParam(name, resourceID) {
6822
+ const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6823
+ return HttpFetcher.get().callGraphQL({
6824
+ values: { name: completPath },
6825
+ query: this.templateByQuery.get("fetchParam"),
6826
+ });
6827
+ }
6828
+ async asString(name, resourceID) {
6829
+ const paramArr = await this.getParam(name, resourceID);
6830
+ return this.getValue(paramArr);
6831
+ }
6832
+ async asInteger(name, resourceID) {
6833
+ const paramArr = await this.getParam(name, resourceID);
6834
+ return parseInt(this.getValue(paramArr));
6835
+ }
6836
+ async asFloat(name, resourceID) {
6837
+ const paramArr = await this.getParam(name, resourceID);
6838
+ return parseFloat(this.getValue(paramArr));
6839
+ }
6840
+ async asBoolean(name, resourceID) {
6841
+ const paramArr = await this.getParam(name, resourceID);
6842
+ return this.getValue(paramArr) == "S";
6843
+ }
6844
+ async asDate(name, resourceID) {
6845
+ const paramArr = await this.getParam(name, resourceID);
6846
+ return DateUtils.strToDate(this.getValue(paramArr));
6847
+ }
6848
+ async getBatchParams(names, resourceID) {
6849
+ const paramArr = await this.getParam(names.join(","), resourceID);
6850
+ //TODO: try to typed params val?
6851
+ const response = {};
6852
+ paramArr.forEach((param) => (response[param.name] = param.resource));
6853
+ return response;
6854
+ }
6855
+ getValue(obj = {}) {
6856
+ if (Array.isArray(obj) && obj.length > 0) {
6857
+ obj = obj[0];
6858
+ }
6859
+ if (StringUtils.isEmpty(obj.resource))
6860
+ return "";
6861
+ return obj.resource;
6862
+ }
6565
6863
  }
6566
6864
 
6567
- class ResourceFetcher {
6568
- constructor() {
6569
- this.templateByQuery = new Map();
6570
- this.buldTemplates();
6571
- }
6572
- buldTemplates() {
6573
- this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
6574
- $queryAlias$: fetchResource(name: $name){
6575
- resource
6576
- }
6577
- }`);
6578
- }
6579
- loadResource(name) {
6580
- return new Promise((resolve, reject) => {
6581
- HttpFetcher.get()
6582
- .callGraphQL({
6583
- values: { name },
6584
- query: this.templateByQuery.get("fetchResource"),
6585
- })
6586
- .then((result) => {
6587
- resolve(result === null || result === void 0 ? void 0 : result.resource);
6588
- })
6589
- .catch((error) => {
6590
- reject(error);
6591
- });
6592
- });
6593
- }
6865
+ class ResourceFetcher {
6866
+ constructor() {
6867
+ this.templateByQuery = new Map();
6868
+ this.buldTemplates();
6869
+ }
6870
+ buldTemplates() {
6871
+ this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
6872
+ $queryAlias$: fetchResource(name: $name){
6873
+ resource
6874
+ }
6875
+ }`);
6876
+ }
6877
+ loadResource(name) {
6878
+ return new Promise((resolve, reject) => {
6879
+ HttpFetcher.get()
6880
+ .callGraphQL({
6881
+ values: { name },
6882
+ query: this.templateByQuery.get("fetchResource"),
6883
+ })
6884
+ .then((result) => {
6885
+ resolve(result === null || result === void 0 ? void 0 : result.resource);
6886
+ })
6887
+ .catch((error) => {
6888
+ reject(error);
6889
+ });
6890
+ });
6891
+ }
6594
6892
  }
6595
6893
 
6596
- class FormConfigFetcher extends ResourceFetcher {
6597
- loadFormConfig(formName, resourceID) {
6598
- return new Promise((accept, reject) => {
6599
- this.loadResource(`cfg://form/${resourceID}/${formName}`)
6600
- .then((configAsString) => {
6601
- if (configAsString) {
6602
- const config = JSON.parse(configAsString);
6603
- const { tabs, fields } = config;
6604
- if (tabs) {
6605
- const allTabs = new Map(tabs.map(t => [t.label, t]));
6606
- fields.forEach(f => f.tab = allTabs.get(f.tab));
6607
- }
6608
- accept(fields);
6609
- }
6610
- else {
6611
- reject(`Sem configuração pro formulário "${formName}".`);
6612
- }
6613
- })
6614
- .catch((error) => {
6615
- reject(error);
6616
- });
6617
- });
6618
- }
6894
+ class FormConfigFetcher extends ResourceFetcher {
6895
+ loadFormConfig(formName, resourceID) {
6896
+ return new Promise((accept, reject) => {
6897
+ this.loadResource(`cfg://form/${resourceID}/${formName}`)
6898
+ .then((configAsString) => {
6899
+ if (configAsString) {
6900
+ const config = JSON.parse(configAsString);
6901
+ const { tabs, fields } = config;
6902
+ if (tabs) {
6903
+ const allTabs = new Map(tabs.map(t => [t.label, t]));
6904
+ fields.forEach(f => f.tab = allTabs.get(f.tab));
6905
+ }
6906
+ accept(fields);
6907
+ }
6908
+ else {
6909
+ reject(`Sem configuração pro formulário "${formName}".`);
6910
+ }
6911
+ })
6912
+ .catch((error) => {
6913
+ reject(error);
6914
+ });
6915
+ });
6916
+ }
6619
6917
  }
6620
6918
 
6621
- const mockByEntity = {
6622
- "ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
6623
- "HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
6624
- "ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
6625
- "HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
6626
- "Usuario": [{ "value": 0, "label": "SUP" }],
6627
- "ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
6628
- "TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
6629
- };
6630
- const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
6631
- var _a;
6632
- console.log(searchArgument);
6633
- const field = dataUnit.getField(fieldName);
6634
- const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
6635
- return (mockByEntity[entityName] || []);
6919
+ const mockByEntity = {
6920
+ "ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
6921
+ "HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
6922
+ "ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
6923
+ "HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
6924
+ "Usuario": [{ "value": 0, "label": "SUP" }],
6925
+ "ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
6926
+ "TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
6927
+ };
6928
+ const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
6929
+ var _a;
6930
+ console.log(searchArgument);
6931
+ const field = dataUnit.getField(fieldName);
6932
+ const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
6933
+ return (mockByEntity[entityName] || []);
6636
6934
  };
6637
6935
 
6638
6936
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
6639
6937
 
6640
- const SnkApplication$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6641
- constructor() {
6642
- super();
6643
- this.__registerHost();
6644
- this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
6645
- this.applicationLoading = createEvent(this, "applicationLoading", 7);
6646
- }
6647
- get parameters() {
6648
- if (!this._parameters) {
6649
- this._parameters = new ParametersFetcher();
6650
- }
6651
- return this._parameters;
6652
- }
6653
- get resourceID() {
6654
- if (!this._resourceID) {
6655
- this._resourceID = this.urlParams.get("workspaceResourceID") ||
6656
- this.urlParams.get("resourceID") ||
6657
- Workspace.resourceID ||
6658
- "unknown.resource.id";
6659
- }
6660
- return this._resourceID;
6661
- }
6662
- async getStringParam(name) {
6663
- return this.parameters.asString(name, this.resourceID);
6664
- }
6665
- async getIntParam(name) {
6666
- return this.parameters.asInteger(name, this.resourceID);
6667
- }
6668
- async getFloatParam(name) {
6669
- return this.parameters.asFloat(name, this.resourceID);
6670
- }
6671
- async getBooleanParam(name) {
6672
- return this.parameters.asBoolean(name, this.resourceID);
6673
- }
6674
- async getDateParam(name) {
6675
- return this.parameters.asDate(name, this.resourceID);
6676
- }
6677
- async temOpcional(opcional) {
6678
- const opts = opcional.split(",");
6679
- return new Promise((resolve, reject) => {
6680
- this.getAttributeFromHTMLWrapper("opc0009")
6681
- .then(value => {
6682
- if (value === "1") {
6683
- resolve(true);
6684
- }
6685
- else {
6686
- Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
6687
- .then(result => {
6688
- resolve(result.includes("1"));
6689
- })
6690
- .catch(error => {
6691
- reject(error);
6692
- });
6693
- }
6694
- })
6695
- .catch(error => {
6696
- reject(error);
6697
- });
6698
- });
6699
- }
6700
- async getAttributeFromHTMLWrapper(attribName) {
6701
- return Promise.resolve(window[attribName]);
6702
- }
6703
- async openApp(resourceId, pkObject) {
6704
- Workspace.openAppActivity(resourceId, pkObject);
6705
- }
6706
- async createDataunit(entityName) {
6707
- return new Promise(resolve => {
6708
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
6709
- dataUnit.loadMetadata();
6710
- resolve(dataUnit);
6711
- });
6712
- }
6713
- async getResourceID() {
6714
- return Promise.resolve(this.resourceID);
6715
- }
6716
- async alert(title, message, icon) {
6717
- return ApplicationUtils.alert(title, message, icon);
6718
- }
6719
- async error(title, message, icon) {
6720
- return ApplicationUtils.error(title, message, icon);
6721
- }
6722
- async confirm(title, message, icon, critical) {
6723
- return ApplicationUtils.confirm(title, message, icon, critical);
6724
- }
6725
- async info(message, options = undefined) {
6726
- return ApplicationUtils.info(message, options);
6727
- }
6728
- async loadFormConfig(name) {
6729
- return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
6730
- }
6731
- get urlParams() {
6732
- if (!this._urlParams) {
6733
- this._urlParams = UrlUtils.getQueryParams(location.search);
6734
- }
6735
- return this._urlParams;
6736
- }
6737
- get dataUnitFetcher() {
6738
- if (!this._dataUnitFetcher) {
6739
- this._dataUnitFetcher = new DataUnitFetcher();
6740
- }
6741
- return this._dataUnitFetcher;
6742
- }
6743
- get formConfigFetcher() {
6744
- if (!this._formConfigFetcher) {
6745
- this._formConfigFetcher = new FormConfigFetcher();
6746
- }
6747
- return this._formConfigFetcher;
6748
- }
6749
- componentWillLoad() {
6750
- ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
6751
- }
6752
- componentDidLoad() {
6753
- this.applicationLoading.emit(true);
6754
- window.requestAnimationFrame(() => {
6755
- this.applicationLoaded.emit(true);
6756
- });
6757
- }
6758
- render() {
6759
- return (h("div", null));
6760
- }
6761
- static get style() { return snkApplicationCss; }
6762
- }, [2, "snk-application", {
6763
- "getStringParam": [64],
6764
- "getIntParam": [64],
6765
- "getFloatParam": [64],
6766
- "getBooleanParam": [64],
6767
- "getDateParam": [64],
6768
- "temOpcional": [64],
6769
- "getAttributeFromHTMLWrapper": [64],
6770
- "openApp": [64],
6771
- "createDataunit": [64],
6772
- "getResourceID": [64],
6773
- "alert": [64],
6774
- "error": [64],
6775
- "confirm": [64],
6776
- "info": [64],
6777
- "loadFormConfig": [64]
6778
- }]);
6779
- function defineCustomElement$1() {
6780
- if (typeof customElements === "undefined") {
6781
- return;
6782
- }
6783
- const components = ["snk-application"];
6784
- components.forEach(tagName => { switch (tagName) {
6785
- case "snk-application":
6786
- if (!customElements.get(tagName)) {
6787
- customElements.define(tagName, SnkApplication$1);
6788
- }
6789
- break;
6790
- } });
6938
+ const SnkApplication$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6939
+ constructor() {
6940
+ super();
6941
+ this.__registerHost();
6942
+ this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
6943
+ this.applicationLoading = createEvent(this, "applicationLoading", 7);
6944
+ }
6945
+ get parameters() {
6946
+ if (!this._parameters) {
6947
+ this._parameters = new ParametersFetcher();
6948
+ }
6949
+ return this._parameters;
6950
+ }
6951
+ get resourceID() {
6952
+ if (!this._resourceID) {
6953
+ this._resourceID = this.urlParams.get("workspaceResourceID") ||
6954
+ this.urlParams.get("resourceID") ||
6955
+ Workspace.resourceID ||
6956
+ "unknown.resource.id";
6957
+ }
6958
+ return this._resourceID;
6959
+ }
6960
+ async getStringParam(name) {
6961
+ return this.parameters.asString(name, this.resourceID);
6962
+ }
6963
+ async getIntParam(name) {
6964
+ return this.parameters.asInteger(name, this.resourceID);
6965
+ }
6966
+ async getFloatParam(name) {
6967
+ return this.parameters.asFloat(name, this.resourceID);
6968
+ }
6969
+ async getBooleanParam(name) {
6970
+ return this.parameters.asBoolean(name, this.resourceID);
6971
+ }
6972
+ async getDateParam(name) {
6973
+ return this.parameters.asDate(name, this.resourceID);
6974
+ }
6975
+ async temOpcional(opcional) {
6976
+ const opts = opcional.split(",");
6977
+ return new Promise((resolve, reject) => {
6978
+ this.getAttributeFromHTMLWrapper("opc0009")
6979
+ .then(value => {
6980
+ if (value === "1") {
6981
+ resolve(true);
6982
+ }
6983
+ else {
6984
+ Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
6985
+ .then(result => {
6986
+ resolve(result.includes("1"));
6987
+ })
6988
+ .catch(error => {
6989
+ reject(error);
6990
+ });
6991
+ }
6992
+ })
6993
+ .catch(error => {
6994
+ reject(error);
6995
+ });
6996
+ });
6997
+ }
6998
+ async getAttributeFromHTMLWrapper(attribName) {
6999
+ return Promise.resolve(window[attribName]);
7000
+ }
7001
+ async openApp(resourceId, pkObject) {
7002
+ Workspace.openAppActivity(resourceId, pkObject);
7003
+ }
7004
+ async createDataunit(entityName) {
7005
+ return new Promise(resolve => {
7006
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7007
+ dataUnit.loadMetadata();
7008
+ resolve(dataUnit);
7009
+ });
7010
+ }
7011
+ async getResourceID() {
7012
+ return Promise.resolve(this.resourceID);
7013
+ }
7014
+ async alert(title, message, icon) {
7015
+ return ApplicationUtils.alert(title, message, icon);
7016
+ }
7017
+ async error(title, message, icon) {
7018
+ return ApplicationUtils.error(title, message, icon);
7019
+ }
7020
+ async confirm(title, message, icon, critical) {
7021
+ return ApplicationUtils.confirm(title, message, icon, critical);
7022
+ }
7023
+ async info(message, options = undefined) {
7024
+ return ApplicationUtils.info(message, options);
7025
+ }
7026
+ async loadFormConfig(name) {
7027
+ return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7028
+ }
7029
+ get urlParams() {
7030
+ if (!this._urlParams) {
7031
+ this._urlParams = UrlUtils.getQueryParams(location.search);
7032
+ }
7033
+ return this._urlParams;
7034
+ }
7035
+ get dataUnitFetcher() {
7036
+ if (!this._dataUnitFetcher) {
7037
+ this._dataUnitFetcher = new DataUnitFetcher();
7038
+ }
7039
+ return this._dataUnitFetcher;
7040
+ }
7041
+ get formConfigFetcher() {
7042
+ if (!this._formConfigFetcher) {
7043
+ this._formConfigFetcher = new FormConfigFetcher();
7044
+ }
7045
+ return this._formConfigFetcher;
7046
+ }
7047
+ componentWillLoad() {
7048
+ ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
7049
+ }
7050
+ componentDidLoad() {
7051
+ this.applicationLoading.emit(true);
7052
+ window.requestAnimationFrame(() => {
7053
+ this.applicationLoaded.emit(true);
7054
+ });
7055
+ }
7056
+ render() {
7057
+ return (h("div", null));
7058
+ }
7059
+ static get style() { return snkApplicationCss; }
7060
+ }, [2, "snk-application", {
7061
+ "getStringParam": [64],
7062
+ "getIntParam": [64],
7063
+ "getFloatParam": [64],
7064
+ "getBooleanParam": [64],
7065
+ "getDateParam": [64],
7066
+ "temOpcional": [64],
7067
+ "getAttributeFromHTMLWrapper": [64],
7068
+ "openApp": [64],
7069
+ "createDataunit": [64],
7070
+ "getResourceID": [64],
7071
+ "alert": [64],
7072
+ "error": [64],
7073
+ "confirm": [64],
7074
+ "info": [64],
7075
+ "loadFormConfig": [64]
7076
+ }]);
7077
+ function defineCustomElement$1() {
7078
+ if (typeof customElements === "undefined") {
7079
+ return;
7080
+ }
7081
+ const components = ["snk-application"];
7082
+ components.forEach(tagName => { switch (tagName) {
7083
+ case "snk-application":
7084
+ if (!customElements.get(tagName)) {
7085
+ customElements.define(tagName, SnkApplication$1);
7086
+ }
7087
+ break;
7088
+ } });
6791
7089
  }
6792
7090
 
6793
7091
  const SnkApplication = SnkApplication$1;