@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
@@ -2,13 +2,28 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-6ac5268e.js');
5
+ const index = require('./index-4720dab8.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const _commonjsHelpers = require('./_commonjsHelpers-537d719a.js');
8
7
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
9
8
 
10
- var browserPonyfill = _commonjsHelpers.createCommonjsModule(function (module, exports) {
11
- var global = typeof self !== 'undefined' ? self : _commonjsHelpers.commonjsGlobal;
9
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
+
11
+ function createCommonjsModule(fn, basedir, module) {
12
+ return module = {
13
+ path: basedir,
14
+ exports: {},
15
+ require: function (path, base) {
16
+ return commonjsRequire();
17
+ }
18
+ }, fn(module, module.exports), module.exports;
19
+ }
20
+
21
+ function commonjsRequire () {
22
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
23
+ }
24
+
25
+ var browserPonyfill = createCommonjsModule(function (module, exports) {
26
+ var global = typeof self !== 'undefined' ? self : commonjsGlobal;
12
27
  var __self__ = (function () {
13
28
  function F() {
14
29
  this.fetch = false;
@@ -564,7 +579,7 @@ exports.Response = ctx.Response;
564
579
  module.exports = exports;
565
580
  });
566
581
 
567
- var isObjectLike_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
582
+ var isObjectLike_1 = createCommonjsModule(function (module, exports) {
568
583
 
569
584
  Object.defineProperty(exports, '__esModule', {
570
585
  value: true,
@@ -580,7 +595,7 @@ function isObjectLike(value) {
580
595
  }
581
596
  });
582
597
 
583
- var invariant_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
598
+ var invariant_1 = createCommonjsModule(function (module, exports) {
584
599
 
585
600
  Object.defineProperty(exports, '__esModule', {
586
601
  value: true,
@@ -598,7 +613,7 @@ function invariant(condition, message) {
598
613
  }
599
614
  });
600
615
 
601
- var location_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
616
+ var location_1 = createCommonjsModule(function (module, exports) {
602
617
 
603
618
  Object.defineProperty(exports, '__esModule', {
604
619
  value: true,
@@ -638,7 +653,7 @@ function getLocation(source, position) {
638
653
  }
639
654
  });
640
655
 
641
- var printLocation_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
656
+ var printLocation_1 = createCommonjsModule(function (module, exports) {
642
657
 
643
658
  Object.defineProperty(exports, '__esModule', {
644
659
  value: true,
@@ -714,7 +729,7 @@ function printPrefixedLines(lines) {
714
729
  }
715
730
  });
716
731
 
717
- var GraphQLError_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
732
+ var GraphQLError_1 = createCommonjsModule(function (module, exports) {
718
733
 
719
734
  Object.defineProperty(exports, '__esModule', {
720
735
  value: true,
@@ -983,7 +998,7 @@ function formatError(error) {
983
998
  }
984
999
  });
985
1000
 
986
- var syntaxError_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1001
+ var syntaxError_1 = createCommonjsModule(function (module, exports) {
987
1002
 
988
1003
  Object.defineProperty(exports, '__esModule', {
989
1004
  value: true,
@@ -1004,7 +1019,7 @@ function syntaxError(source, position, description) {
1004
1019
  }
1005
1020
  });
1006
1021
 
1007
- var ast = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1022
+ var ast = createCommonjsModule(function (module, exports) {
1008
1023
 
1009
1024
  Object.defineProperty(exports, '__esModule', {
1010
1025
  value: true,
@@ -1230,7 +1245,7 @@ exports.OperationTypeNode = OperationTypeNode;
1230
1245
  })(OperationTypeNode || (exports.OperationTypeNode = OperationTypeNode = {}));
1231
1246
  });
1232
1247
 
1233
- var directiveLocation = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1248
+ var directiveLocation = createCommonjsModule(function (module, exports) {
1234
1249
 
1235
1250
  Object.defineProperty(exports, '__esModule', {
1236
1251
  value: true,
@@ -1272,7 +1287,7 @@ exports.DirectiveLocation = DirectiveLocation;
1272
1287
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1273
1288
  });
1274
1289
 
1275
- var kinds = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1290
+ var kinds = createCommonjsModule(function (module, exports) {
1276
1291
 
1277
1292
  Object.defineProperty(exports, '__esModule', {
1278
1293
  value: true,
@@ -1338,7 +1353,7 @@ exports.Kind = Kind;
1338
1353
  })(Kind || (exports.Kind = Kind = {}));
1339
1354
  });
1340
1355
 
1341
- var characterClasses = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1356
+ var characterClasses = createCommonjsModule(function (module, exports) {
1342
1357
 
1343
1358
  Object.defineProperty(exports, '__esModule', {
1344
1359
  value: true,
@@ -1415,7 +1430,7 @@ function isNameContinue(code) {
1415
1430
  }
1416
1431
  });
1417
1432
 
1418
- var blockString = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1433
+ var blockString = createCommonjsModule(function (module, exports) {
1419
1434
 
1420
1435
  Object.defineProperty(exports, '__esModule', {
1421
1436
  value: true,
@@ -1612,7 +1627,7 @@ function printBlockString(value, options) {
1612
1627
  }
1613
1628
  });
1614
1629
 
1615
- var tokenKind = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1630
+ var tokenKind = createCommonjsModule(function (module, exports) {
1616
1631
 
1617
1632
  Object.defineProperty(exports, '__esModule', {
1618
1633
  value: true,
@@ -1658,7 +1673,7 @@ exports.TokenKind = TokenKind;
1658
1673
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1659
1674
  });
1660
1675
 
1661
- var lexer = _commonjsHelpers.createCommonjsModule(function (module, exports) {
1676
+ var lexer = createCommonjsModule(function (module, exports) {
1662
1677
 
1663
1678
  Object.defineProperty(exports, '__esModule', {
1664
1679
  value: true,
@@ -2666,7 +2681,7 @@ function readName(lexer, start) {
2666
2681
  }
2667
2682
  });
2668
2683
 
2669
- var devAssert_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
2684
+ var devAssert_1 = createCommonjsModule(function (module, exports) {
2670
2685
 
2671
2686
  Object.defineProperty(exports, '__esModule', {
2672
2687
  value: true,
@@ -2682,7 +2697,7 @@ function devAssert(condition, message) {
2682
2697
  }
2683
2698
  });
2684
2699
 
2685
- var inspect_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
2700
+ var inspect_1 = createCommonjsModule(function (module, exports) {
2686
2701
 
2687
2702
  Object.defineProperty(exports, '__esModule', {
2688
2703
  value: true,
@@ -2805,7 +2820,7 @@ function getObjectTag(object) {
2805
2820
  }
2806
2821
  });
2807
2822
 
2808
- var instanceOf_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
2823
+ var instanceOf_1 = createCommonjsModule(function (module, exports) {
2809
2824
 
2810
2825
  Object.defineProperty(exports, '__esModule', {
2811
2826
  value: true,
@@ -2831,7 +2846,7 @@ const instanceOf =
2831
2846
  exports.instanceOf = instanceOf;
2832
2847
  });
2833
2848
 
2834
- var source = _commonjsHelpers.createCommonjsModule(function (module, exports) {
2849
+ var source = createCommonjsModule(function (module, exports) {
2835
2850
 
2836
2851
  Object.defineProperty(exports, '__esModule', {
2837
2852
  value: true,
@@ -2898,7 +2913,7 @@ function isSource(source) {
2898
2913
  }
2899
2914
  });
2900
2915
 
2901
- var parser = _commonjsHelpers.createCommonjsModule(function (module, exports) {
2916
+ var parser = createCommonjsModule(function (module, exports) {
2902
2917
 
2903
2918
  Object.defineProperty(exports, '__esModule', {
2904
2919
  value: true,
@@ -4467,7 +4482,7 @@ function getTokenKindDesc(kind) {
4467
4482
  }
4468
4483
  });
4469
4484
 
4470
- var printString_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
4485
+ var printString_1 = createCommonjsModule(function (module, exports) {
4471
4486
 
4472
4487
  Object.defineProperty(exports, '__esModule', {
4473
4488
  value: true,
@@ -4652,7 +4667,7 @@ const escapeSequences = [
4652
4667
  ];
4653
4668
  });
4654
4669
 
4655
- var visitor = _commonjsHelpers.createCommonjsModule(function (module, exports) {
4670
+ var visitor = createCommonjsModule(function (module, exports) {
4656
4671
 
4657
4672
  Object.defineProperty(exports, '__esModule', {
4658
4673
  value: true,
@@ -5031,7 +5046,7 @@ function getVisitFn(visitor, kind, isLeaving) {
5031
5046
  }
5032
5047
  });
5033
5048
 
5034
- var printer = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5049
+ var printer = createCommonjsModule(function (module, exports) {
5035
5050
 
5036
5051
  Object.defineProperty(exports, '__esModule', {
5037
5052
  value: true,
@@ -5465,7 +5480,7 @@ var _public = {
5465
5480
  /* eslint-env browser */
5466
5481
  var browser = typeof self == 'object' ? self.FormData : window.FormData;
5467
5482
 
5468
- var defaultJsonSerializer = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5483
+ var defaultJsonSerializer = createCommonjsModule(function (module, exports) {
5469
5484
  Object.defineProperty(exports, "__esModule", { value: true });
5470
5485
  exports.defaultJsonSerializer = void 0;
5471
5486
  exports.defaultJsonSerializer = {
@@ -5475,8 +5490,8 @@ exports.defaultJsonSerializer = {
5475
5490
  //# sourceMappingURL=defaultJsonSerializer.js.map
5476
5491
  });
5477
5492
 
5478
- var createRequestBody_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5479
- var __importDefault = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__importDefault) || function (mod) {
5493
+ var createRequestBody_1 = createCommonjsModule(function (module, exports) {
5494
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
5480
5495
  return (mod && mod.__esModule) ? mod : { "default": mod };
5481
5496
  };
5482
5497
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5532,7 +5547,7 @@ exports.default = createRequestBody;
5532
5547
  //# sourceMappingURL=createRequestBody.js.map
5533
5548
  });
5534
5549
 
5535
- var parseArgs = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5550
+ var parseArgs = createCommonjsModule(function (module, exports) {
5536
5551
  Object.defineProperty(exports, "__esModule", { value: true });
5537
5552
  exports.parseBatchRequestsExtendedArgs = exports.parseRawRequestExtendedArgs = exports.parseRequestExtendedArgs = exports.parseBatchRequestArgs = exports.parseRawRequestArgs = exports.parseRequestArgs = void 0;
5538
5553
  function parseRequestArgs(documentOrOptions, variables, requestHeaders) {
@@ -5605,8 +5620,8 @@ exports.parseBatchRequestsExtendedArgs = parseBatchRequestsExtendedArgs;
5605
5620
  //# sourceMappingURL=parseArgs.js.map
5606
5621
  });
5607
5622
 
5608
- var types = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5609
- var __extends = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__extends) || (function () {
5623
+ var types = createCommonjsModule(function (module, exports) {
5624
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
5610
5625
  var extendStatics = function (d, b) {
5611
5626
  extendStatics = Object.setPrototypeOf ||
5612
5627
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -5655,8 +5670,282 @@ exports.ClientError = ClientError;
5655
5670
  //# sourceMappingURL=types.js.map
5656
5671
  });
5657
5672
 
5658
- var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
5659
- var __assign = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__assign) || function () {
5673
+ var graphqlWs = createCommonjsModule(function (module, exports) {
5674
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
5675
+ __assign = Object.assign || function(t) {
5676
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5677
+ s = arguments[i];
5678
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5679
+ t[p] = s[p];
5680
+ }
5681
+ return t;
5682
+ };
5683
+ return __assign.apply(this, arguments);
5684
+ };
5685
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
5686
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5687
+ return new (P || (P = Promise))(function (resolve, reject) {
5688
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5689
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5690
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5691
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5692
+ });
5693
+ };
5694
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
5695
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
5696
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5697
+ function verb(n) { return function (v) { return step([n, v]); }; }
5698
+ function step(op) {
5699
+ if (f) throw new TypeError("Generator is already executing.");
5700
+ while (_) try {
5701
+ 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;
5702
+ if (y = 0, t) op = [op[0] & 2, t.value];
5703
+ switch (op[0]) {
5704
+ case 0: case 1: t = op; break;
5705
+ case 4: _.label++; return { value: op[1], done: false };
5706
+ case 5: _.label++; y = op[1]; op = [0]; continue;
5707
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
5708
+ default:
5709
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
5710
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
5711
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
5712
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
5713
+ if (t[2]) _.ops.pop();
5714
+ _.trys.pop(); continue;
5715
+ }
5716
+ op = body.call(thisArg, _);
5717
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
5718
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
5719
+ }
5720
+ };
5721
+ Object.defineProperty(exports, "__esModule", { value: true });
5722
+ exports.GraphQLWebSocketClient = void 0;
5723
+
5724
+
5725
+ var CONNECTION_INIT = 'connection_init';
5726
+ var CONNECTION_ACK = 'connection_ack';
5727
+ var PING = 'ping';
5728
+ var PONG = 'pong';
5729
+ var SUBSCRIBE = 'subscribe';
5730
+ var NEXT = 'next';
5731
+ var ERROR = 'error';
5732
+ var COMPLETE = 'complete';
5733
+ var GraphQLWebSocketMessage = /** @class */ (function () {
5734
+ function GraphQLWebSocketMessage(type, payload, id) {
5735
+ this._type = type;
5736
+ this._payload = payload;
5737
+ this._id = id;
5738
+ }
5739
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "type", {
5740
+ get: function () { return this._type; },
5741
+ enumerable: false,
5742
+ configurable: true
5743
+ });
5744
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "id", {
5745
+ get: function () { return this._id; },
5746
+ enumerable: false,
5747
+ configurable: true
5748
+ });
5749
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "payload", {
5750
+ get: function () { return this._payload; },
5751
+ enumerable: false,
5752
+ configurable: true
5753
+ });
5754
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "text", {
5755
+ get: function () {
5756
+ var result = { type: this.type };
5757
+ if (this.id != null && this.id != undefined)
5758
+ result.id = this.id;
5759
+ if (this.payload != null && this.payload != undefined)
5760
+ result.payload = this.payload;
5761
+ return JSON.stringify(result);
5762
+ },
5763
+ enumerable: false,
5764
+ configurable: true
5765
+ });
5766
+ GraphQLWebSocketMessage.parse = function (data, f) {
5767
+ var _a = JSON.parse(data), type = _a.type, payload = _a.payload, id = _a.id;
5768
+ return new GraphQLWebSocketMessage(type, f(payload), id);
5769
+ };
5770
+ return GraphQLWebSocketMessage;
5771
+ }());
5772
+ var GraphQLWebSocketClient = /** @class */ (function () {
5773
+ function GraphQLWebSocketClient(socket, _a) {
5774
+ var _this = this;
5775
+ var onInit = _a.onInit, onAcknowledged = _a.onAcknowledged, onPing = _a.onPing, onPong = _a.onPong;
5776
+ this.socketState = { acknowledged: false, lastRequestId: 0, subscriptions: {} };
5777
+ this.socket = socket;
5778
+ socket.onopen = function (e) { return __awaiter(_this, void 0, void 0, function () {
5779
+ var _a, _b, _c, _d;
5780
+ return __generator(this, function (_e) {
5781
+ switch (_e.label) {
5782
+ case 0:
5783
+ this.socketState.acknowledged = false;
5784
+ this.socketState.subscriptions = {};
5785
+ _b = (_a = socket).send;
5786
+ _c = ConnectionInit;
5787
+ if (!onInit) return [3 /*break*/, 2];
5788
+ return [4 /*yield*/, onInit()];
5789
+ case 1:
5790
+ _d = _e.sent();
5791
+ return [3 /*break*/, 3];
5792
+ case 2:
5793
+ _d = null;
5794
+ _e.label = 3;
5795
+ case 3:
5796
+ _b.apply(_a, [_c.apply(void 0, [_d]).text]);
5797
+ return [2 /*return*/];
5798
+ }
5799
+ });
5800
+ }); };
5801
+ socket.onclose = function (e) {
5802
+ _this.socketState.acknowledged = false;
5803
+ _this.socketState.subscriptions = {};
5804
+ };
5805
+ socket.onerror = function (e) {
5806
+ console.error(e);
5807
+ };
5808
+ socket.onmessage = function (e) {
5809
+ try {
5810
+ var message = parseMessage(e.data);
5811
+ switch (message.type) {
5812
+ case CONNECTION_ACK: {
5813
+ if (_this.socketState.acknowledged) {
5814
+ console.warn("Duplicate CONNECTION_ACK message ignored");
5815
+ }
5816
+ else {
5817
+ _this.socketState.acknowledged = true;
5818
+ if (onAcknowledged)
5819
+ onAcknowledged(message.payload);
5820
+ }
5821
+ return;
5822
+ }
5823
+ case PING: {
5824
+ if (onPing)
5825
+ onPing(message.payload).then(function (r) { return socket.send(Pong(r).text); });
5826
+ else
5827
+ socket.send(Pong(null).text);
5828
+ return;
5829
+ }
5830
+ case PONG: {
5831
+ if (onPong)
5832
+ onPong(message.payload);
5833
+ return;
5834
+ }
5835
+ }
5836
+ if (!_this.socketState.acknowledged) {
5837
+ // Web-socket connection not acknowledged
5838
+ return;
5839
+ }
5840
+ if (message.id === undefined || message.id === null || !_this.socketState.subscriptions[message.id]) {
5841
+ // No subscription identifer or subscription indentifier is not found
5842
+ return;
5843
+ }
5844
+ var _a = _this.socketState.subscriptions[message.id], query = _a.query, variables = _a.variables, subscriber = _a.subscriber;
5845
+ switch (message.type) {
5846
+ case NEXT: {
5847
+ if (!message.payload.errors && message.payload.data) {
5848
+ subscriber.next && subscriber.next(message.payload.data);
5849
+ }
5850
+ if (message.payload.errors) {
5851
+ subscriber.error && subscriber.error(new types.ClientError(__assign(__assign({}, message.payload), { status: 200 }), { query: query, variables: variables }));
5852
+ }
5853
+ return;
5854
+ }
5855
+ case ERROR: {
5856
+ subscriber.error && subscriber.error(new types.ClientError({ errors: message.payload, status: 200 }, { query: query, variables: variables }));
5857
+ return;
5858
+ }
5859
+ case COMPLETE: {
5860
+ subscriber.complete && subscriber.complete();
5861
+ delete _this.socketState.subscriptions[message.id];
5862
+ return;
5863
+ }
5864
+ }
5865
+ }
5866
+ catch (e) {
5867
+ // Unexpected errors while handling graphql-ws message
5868
+ console.error(e);
5869
+ socket.close(1006);
5870
+ }
5871
+ socket.close(4400, "Unknown graphql-ws message.");
5872
+ };
5873
+ }
5874
+ GraphQLWebSocketClient.prototype.makeSubscribe = function (query, operationName, variables, subscriber) {
5875
+ var _this = this;
5876
+ var subscriptionId = (this.socketState.lastRequestId++).toString();
5877
+ this.socketState.subscriptions[subscriptionId] = { query: query, variables: variables, subscriber: subscriber };
5878
+ this.socket.send(Subscribe(subscriptionId, { query: query, operationName: operationName, variables: variables }).text);
5879
+ return function () {
5880
+ _this.socket.send(Complete(subscriptionId).text);
5881
+ delete _this.socketState.subscriptions[subscriptionId];
5882
+ };
5883
+ };
5884
+ GraphQLWebSocketClient.prototype.rawRequest = function (query, variables) {
5885
+ var _this = this;
5886
+ return new Promise(function (resolve, reject) {
5887
+ var result;
5888
+ _this.rawSubscribe(query, {
5889
+ next: function (data, extensions) { return (result = { data: data, extensions: extensions }); },
5890
+ error: reject,
5891
+ complete: function () { return resolve(result); },
5892
+ }, variables);
5893
+ });
5894
+ };
5895
+ GraphQLWebSocketClient.prototype.request = function (document, variables) {
5896
+ var _this = this;
5897
+ return new Promise(function (resolve, reject) {
5898
+ var result;
5899
+ _this.subscribe(document, {
5900
+ next: function (data) { return (result = data); },
5901
+ error: reject,
5902
+ complete: function () { return resolve(result); },
5903
+ }, variables);
5904
+ });
5905
+ };
5906
+ GraphQLWebSocketClient.prototype.subscribe = function (document, subscriber, variables) {
5907
+ var _a = dist.resolveRequestDocument(document), query = _a.query, operationName = _a.operationName;
5908
+ return this.makeSubscribe(query, operationName, variables, subscriber);
5909
+ };
5910
+ GraphQLWebSocketClient.prototype.rawSubscribe = function (query, subscriber, variables) {
5911
+ return this.makeSubscribe(query, undefined, variables, subscriber);
5912
+ };
5913
+ GraphQLWebSocketClient.prototype.ping = function (payload) {
5914
+ this.socket.send(Ping(payload).text);
5915
+ };
5916
+ GraphQLWebSocketClient.prototype.close = function () {
5917
+ this.socket.close(1000);
5918
+ };
5919
+ GraphQLWebSocketClient.PROTOCOL = "graphql-transport-ws";
5920
+ return GraphQLWebSocketClient;
5921
+ }());
5922
+ exports.GraphQLWebSocketClient = GraphQLWebSocketClient;
5923
+ // Helper functions
5924
+ function parseMessage(data, f) {
5925
+ if (f === void 0) { f = function (a) { return a; }; }
5926
+ var m = GraphQLWebSocketMessage.parse(data, f);
5927
+ return m;
5928
+ }
5929
+ function ConnectionInit(payload) {
5930
+ return new GraphQLWebSocketMessage(CONNECTION_INIT, payload);
5931
+ }
5932
+ function Ping(payload) {
5933
+ return new GraphQLWebSocketMessage(PING, payload, undefined);
5934
+ }
5935
+ function Pong(payload) {
5936
+ return new GraphQLWebSocketMessage(PONG, payload, undefined);
5937
+ }
5938
+ function Subscribe(id, payload) {
5939
+ return new GraphQLWebSocketMessage(SUBSCRIBE, payload, id);
5940
+ }
5941
+ function Complete(id) {
5942
+ return new GraphQLWebSocketMessage(COMPLETE, undefined, id);
5943
+ }
5944
+ //# sourceMappingURL=graphql-ws.js.map
5945
+ });
5946
+
5947
+ var dist = createCommonjsModule(function (module, exports) {
5948
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
5660
5949
  __assign = Object.assign || function(t) {
5661
5950
  for (var s, i = 1, n = arguments.length; i < n; i++) {
5662
5951
  s = arguments[i];
@@ -5667,26 +5956,26 @@ var __assign = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlob
5667
5956
  };
5668
5957
  return __assign.apply(this, arguments);
5669
5958
  };
5670
- var __createBinding = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5959
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5671
5960
  if (k2 === undefined) k2 = k;
5672
5961
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5673
5962
  }) : (function(o, m, k, k2) {
5674
5963
  if (k2 === undefined) k2 = k;
5675
5964
  o[k2] = m[k];
5676
5965
  }));
5677
- var __setModuleDefault = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
5966
+ var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
5678
5967
  Object.defineProperty(o, "default", { enumerable: true, value: v });
5679
5968
  }) : function(o, v) {
5680
5969
  o["default"] = v;
5681
5970
  });
5682
- var __importStar = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__importStar) || function (mod) {
5971
+ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
5683
5972
  if (mod && mod.__esModule) return mod;
5684
5973
  var result = {};
5685
5974
  if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5686
5975
  __setModuleDefault(result, mod);
5687
5976
  return result;
5688
5977
  };
5689
- var __awaiter = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
5978
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
5690
5979
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5691
5980
  return new (P || (P = Promise))(function (resolve, reject) {
5692
5981
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -5695,7 +5984,7 @@ var __awaiter = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlo
5695
5984
  step((generator = generator.apply(thisArg, _arguments || [])).next());
5696
5985
  });
5697
5986
  };
5698
- var __generator = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__generator) || function (thisArg, body) {
5987
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
5699
5988
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
5700
5989
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5701
5990
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -5722,7 +6011,7 @@ var __generator = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsG
5722
6011
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
5723
6012
  }
5724
6013
  };
5725
- var __rest = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__rest) || function (s, e) {
6014
+ var __rest = (commonjsGlobal && commonjsGlobal.__rest) || function (s, e) {
5726
6015
  var t = {};
5727
6016
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5728
6017
  t[p] = s[p];
@@ -5733,11 +6022,11 @@ var __rest = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal
5733
6022
  }
5734
6023
  return t;
5735
6024
  };
5736
- var __importDefault = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__importDefault) || function (mod) {
6025
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
5737
6026
  return (mod && mod.__esModule) ? mod : { "default": mod };
5738
6027
  };
5739
6028
  Object.defineProperty(exports, "__esModule", { value: true });
5740
- exports.gql = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
6029
+ exports.GraphQLWebSocketClient = exports.gql = exports.resolveRequestDocument = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
5741
6030
  var cross_fetch_1 = __importStar(browserPonyfill), CrossFetch = cross_fetch_1;
5742
6031
 
5743
6032
 
@@ -5871,7 +6160,7 @@ var GraphQLClient = /** @class */ (function () {
5871
6160
  url: url,
5872
6161
  query: rawRequestOptions.query,
5873
6162
  variables: rawRequestOptions.variables,
5874
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(rawRequestOptions.requestHeaders)),
6163
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(rawRequestOptions.requestHeaders)),
5875
6164
  operationName: operationName,
5876
6165
  fetch: fetch,
5877
6166
  method: method,
@@ -5897,7 +6186,7 @@ var GraphQLClient = /** @class */ (function () {
5897
6186
  url: url,
5898
6187
  query: query,
5899
6188
  variables: requestOptions.variables,
5900
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(requestOptions.requestHeaders)),
6189
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(requestOptions.requestHeaders)),
5901
6190
  operationName: operationName,
5902
6191
  fetch: fetch,
5903
6192
  method: method,
@@ -5934,7 +6223,7 @@ var GraphQLClient = /** @class */ (function () {
5934
6223
  url: url,
5935
6224
  query: queries,
5936
6225
  variables: variables,
5937
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(batchRequestOptions.requestHeaders)),
6226
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(batchRequestOptions.requestHeaders)),
5938
6227
  operationName: undefined,
5939
6228
  fetch: fetch,
5940
6229
  method: method,
@@ -5980,7 +6269,7 @@ exports.GraphQLClient = GraphQLClient;
5980
6269
  function makeRequest(_a) {
5981
6270
  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;
5982
6271
  return __awaiter(this, void 0, void 0, function () {
5983
- var fetcher, isBathchingQuery, response, result, successfullyReceivedData, headers_1, status_1, errorResult;
6272
+ var fetcher, isBathchingQuery, response, result, successfullyReceivedData, successfullyPassedErrorPolicy, headers_1, status_1, rest, data, errorResult;
5984
6273
  return __generator(this, function (_c) {
5985
6274
  switch (_c.label) {
5986
6275
  case 0:
@@ -6004,9 +6293,12 @@ function makeRequest(_a) {
6004
6293
  var data = _a.data;
6005
6294
  return !data;
6006
6295
  }) : !!result.data;
6007
- if (response.ok && !result.errors && successfullyReceivedData) {
6296
+ successfullyPassedErrorPolicy = !result.errors || fetchOptions.errorPolicy === 'all' || fetchOptions.errorPolicy === 'ignore';
6297
+ if (response.ok && successfullyPassedErrorPolicy && successfullyReceivedData) {
6008
6298
  headers_1 = response.headers, status_1 = response.status;
6009
- return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: result } : result)), { headers: headers_1, status: status_1 })];
6299
+ rest = __rest(result, ["errors"]);
6300
+ data = fetchOptions.errorPolicy === 'ignore' ? rest : result;
6301
+ return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: data } : data)), { headers: headers_1, status: status_1 })];
6010
6302
  }
6011
6303
  else {
6012
6304
  errorResult = typeof result === 'string' ? { error: result } : result;
@@ -6101,6 +6393,10 @@ function resolveRequestDocument(document) {
6101
6393
  var operationName = extractOperationName(document);
6102
6394
  return { query: printer.print(document), operationName: operationName };
6103
6395
  }
6396
+ exports.resolveRequestDocument = resolveRequestDocument;
6397
+ function callOrIdentity(value) {
6398
+ return typeof value === 'function' ? value() : value;
6399
+ }
6104
6400
  /**
6105
6401
  * 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.
6106
6402
  *
@@ -6132,636 +6428,638 @@ function HeadersInstanceToPlainObject(headers) {
6132
6428
  });
6133
6429
  return o;
6134
6430
  }
6431
+
6432
+ Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get: function () { return graphqlWs.GraphQLWebSocketClient; } });
6135
6433
  //# sourceMappingURL=index.js.map
6136
6434
  });
6137
6435
 
6138
- class HttpFetcher {
6139
- constructor() {
6140
- this.watingRequestsById = new Map();
6141
- }
6142
- static get() {
6143
- if (!HttpFetcher.instance) {
6144
- HttpFetcher.instance = new HttpFetcher();
6145
- const application = document.querySelector(this.appTagName);
6146
- if (application === null) {
6147
- HttpFetcher.instance.resume();
6148
- }
6149
- else {
6150
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6151
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6152
- }
6153
- }
6154
- return this.instance;
6155
- }
6156
- async callGraphQL(req) {
6157
- var _a;
6158
- const reqKey = this.getReqKey(req);
6159
- req.queryID = reqKey;
6160
- req.values.queryID = reqKey;
6161
- if (this.ready) {
6162
- return new Promise(async (resolve, reject) => {
6163
- let query = this.getQueryTemplate(req);
6164
- const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6165
- if (res.errors.length > 0) {
6166
- reject(res);
6167
- }
6168
- else {
6169
- //resolve(res);
6170
- //FIXME: Precisamos trabalhar melhor a resposta, quem chamou
6171
- //a API não pode ficar responsavel por desempacotar... fiz uma
6172
- //gambiarra aqui...
6173
- resolve(res.data[0][reqKey]);
6174
- }
6175
- });
6176
- }
6177
- else {
6178
- if (!this.watingRequestsById.has(reqKey)) {
6179
- this.watingRequestsById.set(reqKey, new WaitingRequest(req));
6180
- }
6181
- return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
6182
- }
6183
- }
6184
- getReqKey(req) {
6185
- return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6186
- }
6187
- getQueryTemplate(re) {
6188
- return (re.query || "").replaceAll("$queryAlias$", re.queryID);
6189
- }
6190
- getWatingRequest(reqID) {
6191
- return this.watingRequestsById.get(reqID);
6192
- }
6193
- pause() {
6194
- this.ready = false;
6195
- }
6196
- async resume() {
6197
- this.ready = true;
6198
- if (this.watingRequestsById.size > 0) {
6199
- const requestsBatch = [];
6200
- this.watingRequestsById.forEach(async (waitingReq) => {
6201
- let query = this.getQueryTemplate(waitingReq.request);
6202
- requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
6203
- });
6204
- let res = undefined;
6205
- let dataResponse = [];
6206
- let errorsResponse = [];
6207
- res = await this.fecthGrapql(requestsBatch);
6208
- dataResponse = res.data;
6209
- errorsResponse = res.errors;
6210
- //Reject promises with errors from query
6211
- errorsResponse.forEach((errorResponse) => {
6212
- Object.entries(errorResponse).forEach(([_key, val]) => {
6213
- var _a;
6214
- (((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
6215
- });
6216
- });
6217
- //Resolve promises with data from query
6218
- dataResponse.forEach((data) => {
6219
- Object.entries(data).forEach(([key, val]) => {
6220
- var _a;
6221
- (((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
6222
- });
6223
- });
6224
- this.watingRequestsById.clear();
6225
- }
6226
- }
6227
- async fecthGrapql(request) {
6228
- let res = undefined;
6229
- let dataResponse = [];
6230
- let errorsResponse = [];
6231
- try {
6232
- res = await dist.batchRequests('http://localhost:8082/', request);
6233
- res.forEach((resItem) => {
6234
- dataResponse.push(resItem.data);
6235
- });
6236
- }
6237
- catch (err) {
6238
- //TODO: Tratar erro quando não existir err.response
6239
- res = err.response;
6240
- const req = err.request;
6241
- Object.entries(res).forEach(([key, val]) => {
6242
- if (val.errors) {
6243
- errorsResponse.push(val.errors.map((item) => {
6244
- item.request = req;
6245
- item.index = Number(key);
6246
- return item;
6247
- }));
6248
- }
6249
- else if (val.data) {
6250
- dataResponse.push(val.data);
6251
- }
6252
- });
6253
- }
6254
- return { data: dataResponse, errors: errorsResponse };
6255
- }
6256
- //TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
6257
- hashCode(txt) {
6258
- var hash = 0, i, chr;
6259
- if (txt.length === 0)
6260
- return hash.toString();
6261
- for (i = 0; i < txt.length; i++) {
6262
- chr = txt.charCodeAt(i);
6263
- hash = ((hash << 5) - hash) + chr;
6264
- hash |= 0; // Convert to 32bit integer
6265
- }
6266
- return hash.toString();
6267
- }
6268
- ;
6269
- }
6270
- HttpFetcher.appTagName = "snk-application";
6271
- class WaitingRequest {
6272
- constructor(req) {
6273
- this._resolve = () => { };
6274
- this._reject = () => { };
6275
- this._request = undefined;
6276
- this._request = req;
6277
- this._promisse = new Promise((resolve, reject) => {
6278
- this._resolve = resolve;
6279
- this._reject = reject;
6280
- });
6281
- }
6282
- get resolve() {
6283
- return this._resolve;
6284
- }
6285
- get reject() {
6286
- return this._reject;
6287
- }
6288
- get promise() {
6289
- return this._promisse;
6290
- }
6291
- get request() {
6292
- return this._request;
6293
- }
6436
+ class HttpFetcher {
6437
+ constructor() {
6438
+ this.watingRequestsById = new Map();
6439
+ }
6440
+ static get() {
6441
+ if (!HttpFetcher.instance) {
6442
+ HttpFetcher.instance = new HttpFetcher();
6443
+ const application = document.querySelector(this.appTagName);
6444
+ if (application === null) {
6445
+ HttpFetcher.instance.resume();
6446
+ }
6447
+ else {
6448
+ application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6449
+ application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6450
+ }
6451
+ }
6452
+ return this.instance;
6453
+ }
6454
+ async callGraphQL(req) {
6455
+ var _a;
6456
+ const reqKey = this.getReqKey(req);
6457
+ req.queryID = reqKey;
6458
+ req.values.queryID = reqKey;
6459
+ if (this.ready) {
6460
+ return new Promise(async (resolve, reject) => {
6461
+ let query = this.getQueryTemplate(req);
6462
+ const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6463
+ if (res.errors.length > 0) {
6464
+ reject(res);
6465
+ }
6466
+ else {
6467
+ //resolve(res);
6468
+ //FIXME: Precisamos trabalhar melhor a resposta, quem chamou
6469
+ //a API não pode ficar responsavel por desempacotar... fiz uma
6470
+ //gambiarra aqui...
6471
+ resolve(res.data[0][reqKey]);
6472
+ }
6473
+ });
6474
+ }
6475
+ else {
6476
+ if (!this.watingRequestsById.has(reqKey)) {
6477
+ this.watingRequestsById.set(reqKey, new WaitingRequest(req));
6478
+ }
6479
+ return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
6480
+ }
6481
+ }
6482
+ getReqKey(req) {
6483
+ return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6484
+ }
6485
+ getQueryTemplate(re) {
6486
+ return (re.query || "").replaceAll("$queryAlias$", re.queryID);
6487
+ }
6488
+ getWatingRequest(reqID) {
6489
+ return this.watingRequestsById.get(reqID);
6490
+ }
6491
+ pause() {
6492
+ this.ready = false;
6493
+ }
6494
+ async resume() {
6495
+ this.ready = true;
6496
+ if (this.watingRequestsById.size > 0) {
6497
+ const requestsBatch = [];
6498
+ this.watingRequestsById.forEach(async (waitingReq) => {
6499
+ let query = this.getQueryTemplate(waitingReq.request);
6500
+ requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
6501
+ });
6502
+ let res = undefined;
6503
+ let dataResponse = [];
6504
+ let errorsResponse = [];
6505
+ res = await this.fecthGrapql(requestsBatch);
6506
+ dataResponse = res.data;
6507
+ errorsResponse = res.errors;
6508
+ //Reject promises with errors from query
6509
+ errorsResponse.forEach((errorResponse) => {
6510
+ Object.entries(errorResponse).forEach(([_key, val]) => {
6511
+ var _a;
6512
+ (((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
6513
+ });
6514
+ });
6515
+ //Resolve promises with data from query
6516
+ dataResponse.forEach((data) => {
6517
+ Object.entries(data).forEach(([key, val]) => {
6518
+ var _a;
6519
+ (((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
6520
+ });
6521
+ });
6522
+ this.watingRequestsById.clear();
6523
+ }
6524
+ }
6525
+ async fecthGrapql(request) {
6526
+ let res = undefined;
6527
+ let dataResponse = [];
6528
+ let errorsResponse = [];
6529
+ try {
6530
+ res = await dist.batchRequests('http://localhost:8082/', request);
6531
+ res.forEach((resItem) => {
6532
+ dataResponse.push(resItem.data);
6533
+ });
6534
+ }
6535
+ catch (err) {
6536
+ //TODO: Tratar erro quando não existir err.response
6537
+ res = err.response;
6538
+ const req = err.request;
6539
+ Object.entries(res).forEach(([key, val]) => {
6540
+ if (val.errors) {
6541
+ errorsResponse.push(val.errors.map((item) => {
6542
+ item.request = req;
6543
+ item.index = Number(key);
6544
+ return item;
6545
+ }));
6546
+ }
6547
+ else if (val.data) {
6548
+ dataResponse.push(val.data);
6549
+ }
6550
+ });
6551
+ }
6552
+ return { data: dataResponse, errors: errorsResponse };
6553
+ }
6554
+ //TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
6555
+ hashCode(txt) {
6556
+ var hash = 0, i, chr;
6557
+ if (txt.length === 0)
6558
+ return hash.toString();
6559
+ for (i = 0; i < txt.length; i++) {
6560
+ chr = txt.charCodeAt(i);
6561
+ hash = ((hash << 5) - hash) + chr;
6562
+ hash |= 0; // Convert to 32bit integer
6563
+ }
6564
+ return hash.toString();
6565
+ }
6566
+ ;
6567
+ }
6568
+ HttpFetcher.appTagName = "snk-application";
6569
+ class WaitingRequest {
6570
+ constructor(req) {
6571
+ this._resolve = () => { };
6572
+ this._reject = () => { };
6573
+ this._request = undefined;
6574
+ this._request = req;
6575
+ this._promisse = new Promise((resolve, reject) => {
6576
+ this._resolve = resolve;
6577
+ this._reject = reject;
6578
+ });
6579
+ }
6580
+ get resolve() {
6581
+ return this._resolve;
6582
+ }
6583
+ get reject() {
6584
+ return this._reject;
6585
+ }
6586
+ get promise() {
6587
+ return this._promisse;
6588
+ }
6589
+ get request() {
6590
+ return this._request;
6591
+ }
6294
6592
  }
6295
6593
 
6296
- class DataUnitFetcher {
6297
- constructor() {
6298
- this.templateByQuery = new Map();
6299
- this.buldTemplates();
6300
- }
6301
- buldTemplates() {
6302
- this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
6303
- $queryAlias$: fetchDataUnit(name: $name){
6304
- name
6305
- fields{
6306
- name
6307
- defaultValue
6308
- label
6309
- readOnly
6310
- required
6311
- dataType
6312
- userInterface
6313
- properties{
6314
- name
6315
- value
6316
- }
6317
- dependencies{
6318
- masterFields
6319
- type
6320
- expression
6321
- }
6322
- }
6323
- }
6324
- }`);
6325
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6326
- $queryAlias$: fetchDataUnit(name: $dataunit){
6327
- data(first: $first offset: $offset filters: $filter sort: $sort){
6328
- first
6329
- offset
6330
- total
6331
- hasMore
6332
- records{
6333
- id
6334
- fields {
6335
- name
6336
- value
6337
- }
6338
- }
6339
- }
6340
- }
6341
- }`);
6342
- this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
6343
- $queryAlias$: saveDataUnitChanges(changes: $changes){
6344
- oldId
6345
- id
6346
- fields {
6347
- name
6348
- value
6349
- }
6350
- }
6351
- }`);
6352
- }
6353
- getDataUnit(entityName, resourceID) {
6354
- const dataUnit = new core.DataUnit(`dd://${entityName}/${resourceID}`);
6355
- dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6356
- dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6357
- dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6358
- dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6359
- return dataUnit;
6360
- }
6361
- loadMetadata(dataUnit) {
6362
- return new Promise((resolve, reject) => {
6363
- HttpFetcher.get()
6364
- .callGraphQL({
6365
- values: { name: dataUnit.name },
6366
- query: this.templateByQuery.get("fetchDataUnit"),
6367
- })
6368
- .then((resp) => {
6369
- var _a;
6370
- const metadata = {
6371
- name: resp.name,
6372
- label: resp.name,
6373
- fields: [],
6374
- };
6375
- (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
6376
- let properties = undefined;
6377
- if (Array.isArray(source.properties)) {
6378
- properties = {};
6379
- source.properties.forEach((prop) => (properties[prop.name] = prop.value));
6380
- }
6381
- metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
6382
- });
6383
- resolve(metadata);
6384
- })
6385
- .catch((error) => {
6386
- reject(error);
6387
- });
6388
- });
6389
- }
6390
- loadData(dataUnit, sort, filters) {
6391
- return new Promise((resolve, reject) => {
6392
- HttpFetcher.get()
6393
- .callGraphQL({
6394
- values: { dataunit: dataUnit.name, sort, filters },
6395
- query: this.templateByQuery.get("fetchData"),
6396
- })
6397
- .then((resp) => {
6398
- const result = resp.data;
6399
- const dataUnitRecords = [];
6400
- result.records.forEach((responseRecord) => {
6401
- const duRecord = { __record__id__: responseRecord.id };
6402
- responseRecord.fields.forEach(({ name, value }) => {
6403
- duRecord[name] = dataUnit.valueFromString(name, value);
6404
- });
6405
- dataUnitRecords.push(duRecord);
6406
- });
6407
- resolve(dataUnitRecords);
6408
- })
6409
- .catch((error) => {
6410
- reject(error);
6411
- });
6412
- });
6413
- }
6414
- saveData(dataUnit, duChanges) {
6415
- const changes = duChanges.map((change) => {
6416
- const { dataUnit: changeDU, record, updatingFields, operation } = change;
6417
- const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
6418
- return { fieldName, value: this.formatValueToServer(value) };
6419
- });
6420
- return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
6421
- });
6422
- return new Promise((resolve, reject) => {
6423
- HttpFetcher.get()
6424
- .callGraphQL({
6425
- values: { changes: changes },
6426
- query: this.templateByQuery.get("saveData"),
6427
- })
6428
- .then((resp) => {
6429
- const dataUnitRecords = [];
6430
- resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
6431
- const duRecord = { __record__id__: responseRecord.id };
6432
- if (responseRecord.oldId) {
6433
- duRecord.__old__id__ = responseRecord.oldId;
6434
- }
6435
- responseRecord.fields.forEach(({ name, value }) => {
6436
- duRecord[name] = dataUnit.valueFromString(name, value);
6437
- });
6438
- dataUnitRecords.push(duRecord);
6439
- });
6440
- resolve(dataUnitRecords);
6441
- })
6442
- .catch((error) => {
6443
- reject(error);
6444
- });
6445
- });
6446
- }
6447
- formatValueToServer(value) {
6448
- if (value === undefined)
6449
- return value;
6450
- try {
6451
- if (value instanceof Date) {
6452
- return value.toString();
6453
- }
6454
- //Any others objects
6455
- value = JSON.stringify(value);
6456
- }
6457
- catch (_a) {
6458
- value = value.toString();
6459
- }
6460
- return value;
6461
- }
6462
- removeRecords(dataUnit, recordIds) {
6463
- const changes = recordIds.map((recordId) => {
6464
- return { dataUnit: dataUnit.name, operation: core.ChangeOperation.DELETE, recordId };
6465
- });
6466
- return new Promise((resolve, reject) => {
6467
- HttpFetcher.get()
6468
- .callGraphQL({
6469
- values: { changes: changes },
6470
- query: this.templateByQuery.get("saveData"),
6471
- })
6472
- .then((_resp) => {
6473
- resolve(recordIds);
6474
- })
6475
- .catch((error) => {
6476
- reject(error);
6477
- });
6478
- });
6479
- }
6594
+ class DataUnitFetcher {
6595
+ constructor() {
6596
+ this.templateByQuery = new Map();
6597
+ this.buldTemplates();
6598
+ }
6599
+ buldTemplates() {
6600
+ this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
6601
+ $queryAlias$: fetchDataUnit(name: $name){
6602
+ name
6603
+ fields{
6604
+ name
6605
+ defaultValue
6606
+ label
6607
+ readOnly
6608
+ required
6609
+ dataType
6610
+ userInterface
6611
+ properties{
6612
+ name
6613
+ value
6614
+ }
6615
+ dependencies{
6616
+ masterFields
6617
+ type
6618
+ expression
6619
+ }
6620
+ }
6621
+ }
6622
+ }`);
6623
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6624
+ $queryAlias$: fetchDataUnit(name: $dataunit){
6625
+ data(first: $first offset: $offset filters: $filter sort: $sort){
6626
+ first
6627
+ offset
6628
+ total
6629
+ hasMore
6630
+ records{
6631
+ id
6632
+ fields {
6633
+ name
6634
+ value
6635
+ }
6636
+ }
6637
+ }
6638
+ }
6639
+ }`);
6640
+ this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
6641
+ $queryAlias$: saveDataUnitChanges(changes: $changes){
6642
+ oldId
6643
+ id
6644
+ fields {
6645
+ name
6646
+ value
6647
+ }
6648
+ }
6649
+ }`);
6650
+ }
6651
+ getDataUnit(entityName, resourceID) {
6652
+ const dataUnit = new core.DataUnit(`dd://${entityName}/${resourceID}`);
6653
+ dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6654
+ dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6655
+ dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6656
+ dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6657
+ return dataUnit;
6658
+ }
6659
+ loadMetadata(dataUnit) {
6660
+ return new Promise((resolve, reject) => {
6661
+ HttpFetcher.get()
6662
+ .callGraphQL({
6663
+ values: { name: dataUnit.name },
6664
+ query: this.templateByQuery.get("fetchDataUnit"),
6665
+ })
6666
+ .then((resp) => {
6667
+ var _a;
6668
+ const metadata = {
6669
+ name: resp.name,
6670
+ label: resp.name,
6671
+ fields: [],
6672
+ };
6673
+ (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
6674
+ let properties = undefined;
6675
+ if (Array.isArray(source.properties)) {
6676
+ properties = {};
6677
+ source.properties.forEach((prop) => (properties[prop.name] = prop.value));
6678
+ }
6679
+ metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
6680
+ });
6681
+ resolve(metadata);
6682
+ })
6683
+ .catch((error) => {
6684
+ reject(error);
6685
+ });
6686
+ });
6687
+ }
6688
+ loadData(dataUnit, sort, filters) {
6689
+ return new Promise((resolve, reject) => {
6690
+ HttpFetcher.get()
6691
+ .callGraphQL({
6692
+ values: { dataunit: dataUnit.name, sort, filters },
6693
+ query: this.templateByQuery.get("fetchData"),
6694
+ })
6695
+ .then((resp) => {
6696
+ const result = resp.data;
6697
+ const dataUnitRecords = [];
6698
+ result.records.forEach((responseRecord) => {
6699
+ const duRecord = { __record__id__: responseRecord.id };
6700
+ responseRecord.fields.forEach(({ name, value }) => {
6701
+ duRecord[name] = dataUnit.valueFromString(name, value);
6702
+ });
6703
+ dataUnitRecords.push(duRecord);
6704
+ });
6705
+ resolve(dataUnitRecords);
6706
+ })
6707
+ .catch((error) => {
6708
+ reject(error);
6709
+ });
6710
+ });
6711
+ }
6712
+ saveData(dataUnit, duChanges) {
6713
+ const changes = duChanges.map((change) => {
6714
+ const { dataUnit: changeDU, record, updatingFields, operation } = change;
6715
+ const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
6716
+ return { fieldName, value: this.formatValueToServer(value) };
6717
+ });
6718
+ return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
6719
+ });
6720
+ return new Promise((resolve, reject) => {
6721
+ HttpFetcher.get()
6722
+ .callGraphQL({
6723
+ values: { changes: changes },
6724
+ query: this.templateByQuery.get("saveData"),
6725
+ })
6726
+ .then((resp) => {
6727
+ const dataUnitRecords = [];
6728
+ resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
6729
+ const duRecord = { __record__id__: responseRecord.id };
6730
+ if (responseRecord.oldId) {
6731
+ duRecord.__old__id__ = responseRecord.oldId;
6732
+ }
6733
+ responseRecord.fields.forEach(({ name, value }) => {
6734
+ duRecord[name] = dataUnit.valueFromString(name, value);
6735
+ });
6736
+ dataUnitRecords.push(duRecord);
6737
+ });
6738
+ resolve(dataUnitRecords);
6739
+ })
6740
+ .catch((error) => {
6741
+ reject(error);
6742
+ });
6743
+ });
6744
+ }
6745
+ formatValueToServer(value) {
6746
+ if (value === undefined)
6747
+ return value;
6748
+ try {
6749
+ if (value instanceof Date) {
6750
+ return value.toString();
6751
+ }
6752
+ //Any others objects
6753
+ value = JSON.stringify(value);
6754
+ }
6755
+ catch (_a) {
6756
+ value = value.toString();
6757
+ }
6758
+ return value;
6759
+ }
6760
+ removeRecords(dataUnit, recordIds) {
6761
+ const changes = recordIds.map((recordId) => {
6762
+ return { dataUnit: dataUnit.name, operation: core.ChangeOperation.DELETE, recordId };
6763
+ });
6764
+ return new Promise((resolve, reject) => {
6765
+ HttpFetcher.get()
6766
+ .callGraphQL({
6767
+ values: { changes: changes },
6768
+ query: this.templateByQuery.get("saveData"),
6769
+ })
6770
+ .then((_resp) => {
6771
+ resolve(recordIds);
6772
+ })
6773
+ .catch((error) => {
6774
+ reject(error);
6775
+ });
6776
+ });
6777
+ }
6480
6778
  }
6481
6779
 
6482
- class UrlUtils {
6483
- static getQueryParams(queryString) {
6484
- const params = new Map();
6485
- const re = /[?&]?([^=]+)=([^&]*)/g;
6486
- let tokens;
6487
- //Necessário por causa da tela Histórico Padrão que possui resourceID com acento
6488
- queryString = window.unescape(queryString);
6489
- queryString = queryString.split("+").join(" ");
6490
- while ((tokens = re.exec(queryString))) {
6491
- params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
6492
- }
6493
- //Inserimos a urlBase no params.
6494
- params.set("urlBase", this.getUrlBase());
6495
- if (window["moduleID"] && window["URIServiceBroker"]) {
6496
- params.set("moduleID", window["moduleID"]);
6497
- params.set("URIServiceBroker", window["URIServiceBroker"]);
6498
- }
6499
- return params;
6500
- }
6501
- static getUrlBase() {
6502
- return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6503
- }
6780
+ class UrlUtils {
6781
+ static getQueryParams(queryString) {
6782
+ const params = new Map();
6783
+ const re = /[?&]?([^=]+)=([^&]*)/g;
6784
+ let tokens;
6785
+ //Necessário por causa da tela Histórico Padrão que possui resourceID com acento
6786
+ queryString = window.unescape(queryString);
6787
+ queryString = queryString.split("+").join(" ");
6788
+ while ((tokens = re.exec(queryString))) {
6789
+ params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
6790
+ }
6791
+ //Inserimos a urlBase no params.
6792
+ params.set("urlBase", this.getUrlBase());
6793
+ if (window["moduleID"] && window["URIServiceBroker"]) {
6794
+ params.set("moduleID", window["moduleID"]);
6795
+ params.set("URIServiceBroker", window["URIServiceBroker"]);
6796
+ }
6797
+ return params;
6798
+ }
6799
+ static getUrlBase() {
6800
+ return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6801
+ }
6504
6802
  }
6505
6803
 
6506
- class Workspace {
6507
- static openAppActivity(resourceId, pkObject) {
6508
- var _a;
6509
- (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
6510
- }
6511
- }
6804
+ class Workspace {
6805
+ static openAppActivity(resourceId, pkObject) {
6806
+ var _a;
6807
+ (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
6808
+ }
6809
+ }
6512
6810
  Workspace.resourceID = window["workspace"].resourceID;
6513
6811
 
6514
- class ParametersFetcher {
6515
- constructor() {
6516
- this.templateByQuery = new Map();
6517
- this.buldTemplates();
6518
- }
6519
- buldTemplates() {
6520
- this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
6521
- $queryAlias$: fetchResource(name: $name){
6522
- name
6523
- resource
6524
- }
6525
- }`);
6526
- }
6527
- async getParam(name, resourceID) {
6528
- const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6529
- return HttpFetcher.get().callGraphQL({
6530
- values: { name: completPath },
6531
- query: this.templateByQuery.get("fetchParam"),
6532
- });
6533
- }
6534
- async asString(name, resourceID) {
6535
- const paramArr = await this.getParam(name, resourceID);
6536
- return this.getValue(paramArr);
6537
- }
6538
- async asInteger(name, resourceID) {
6539
- const paramArr = await this.getParam(name, resourceID);
6540
- return parseInt(this.getValue(paramArr));
6541
- }
6542
- async asFloat(name, resourceID) {
6543
- const paramArr = await this.getParam(name, resourceID);
6544
- return parseFloat(this.getValue(paramArr));
6545
- }
6546
- async asBoolean(name, resourceID) {
6547
- const paramArr = await this.getParam(name, resourceID);
6548
- return this.getValue(paramArr) == "S";
6549
- }
6550
- async asDate(name, resourceID) {
6551
- const paramArr = await this.getParam(name, resourceID);
6552
- return core.DateUtils.strToDate(this.getValue(paramArr));
6553
- }
6554
- async getBatchParams(names, resourceID) {
6555
- const paramArr = await this.getParam(names.join(","), resourceID);
6556
- //TODO: try to typed params val?
6557
- const response = {};
6558
- paramArr.forEach((param) => (response[param.name] = param.resource));
6559
- return response;
6560
- }
6561
- getValue(obj = {}) {
6562
- if (Array.isArray(obj) && obj.length > 0) {
6563
- obj = obj[0];
6564
- }
6565
- if (core.StringUtils.isEmpty(obj.resource))
6566
- return "";
6567
- return obj.resource;
6568
- }
6812
+ class ParametersFetcher {
6813
+ constructor() {
6814
+ this.templateByQuery = new Map();
6815
+ this.buldTemplates();
6816
+ }
6817
+ buldTemplates() {
6818
+ this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
6819
+ $queryAlias$: fetchResource(name: $name){
6820
+ name
6821
+ resource
6822
+ }
6823
+ }`);
6824
+ }
6825
+ async getParam(name, resourceID) {
6826
+ const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6827
+ return HttpFetcher.get().callGraphQL({
6828
+ values: { name: completPath },
6829
+ query: this.templateByQuery.get("fetchParam"),
6830
+ });
6831
+ }
6832
+ async asString(name, resourceID) {
6833
+ const paramArr = await this.getParam(name, resourceID);
6834
+ return this.getValue(paramArr);
6835
+ }
6836
+ async asInteger(name, resourceID) {
6837
+ const paramArr = await this.getParam(name, resourceID);
6838
+ return parseInt(this.getValue(paramArr));
6839
+ }
6840
+ async asFloat(name, resourceID) {
6841
+ const paramArr = await this.getParam(name, resourceID);
6842
+ return parseFloat(this.getValue(paramArr));
6843
+ }
6844
+ async asBoolean(name, resourceID) {
6845
+ const paramArr = await this.getParam(name, resourceID);
6846
+ return this.getValue(paramArr) == "S";
6847
+ }
6848
+ async asDate(name, resourceID) {
6849
+ const paramArr = await this.getParam(name, resourceID);
6850
+ return core.DateUtils.strToDate(this.getValue(paramArr));
6851
+ }
6852
+ async getBatchParams(names, resourceID) {
6853
+ const paramArr = await this.getParam(names.join(","), resourceID);
6854
+ //TODO: try to typed params val?
6855
+ const response = {};
6856
+ paramArr.forEach((param) => (response[param.name] = param.resource));
6857
+ return response;
6858
+ }
6859
+ getValue(obj = {}) {
6860
+ if (Array.isArray(obj) && obj.length > 0) {
6861
+ obj = obj[0];
6862
+ }
6863
+ if (core.StringUtils.isEmpty(obj.resource))
6864
+ return "";
6865
+ return obj.resource;
6866
+ }
6569
6867
  }
6570
6868
 
6571
- class ResourceFetcher {
6572
- constructor() {
6573
- this.templateByQuery = new Map();
6574
- this.buldTemplates();
6575
- }
6576
- buldTemplates() {
6577
- this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
6578
- $queryAlias$: fetchResource(name: $name){
6579
- resource
6580
- }
6581
- }`);
6582
- }
6583
- loadResource(name) {
6584
- return new Promise((resolve, reject) => {
6585
- HttpFetcher.get()
6586
- .callGraphQL({
6587
- values: { name },
6588
- query: this.templateByQuery.get("fetchResource"),
6589
- })
6590
- .then((result) => {
6591
- resolve(result === null || result === void 0 ? void 0 : result.resource);
6592
- })
6593
- .catch((error) => {
6594
- reject(error);
6595
- });
6596
- });
6597
- }
6869
+ class ResourceFetcher {
6870
+ constructor() {
6871
+ this.templateByQuery = new Map();
6872
+ this.buldTemplates();
6873
+ }
6874
+ buldTemplates() {
6875
+ this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
6876
+ $queryAlias$: fetchResource(name: $name){
6877
+ resource
6878
+ }
6879
+ }`);
6880
+ }
6881
+ loadResource(name) {
6882
+ return new Promise((resolve, reject) => {
6883
+ HttpFetcher.get()
6884
+ .callGraphQL({
6885
+ values: { name },
6886
+ query: this.templateByQuery.get("fetchResource"),
6887
+ })
6888
+ .then((result) => {
6889
+ resolve(result === null || result === void 0 ? void 0 : result.resource);
6890
+ })
6891
+ .catch((error) => {
6892
+ reject(error);
6893
+ });
6894
+ });
6895
+ }
6598
6896
  }
6599
6897
 
6600
- class FormConfigFetcher extends ResourceFetcher {
6601
- loadFormConfig(formName, resourceID) {
6602
- return new Promise((accept, reject) => {
6603
- this.loadResource(`cfg://form/${resourceID}/${formName}`)
6604
- .then((configAsString) => {
6605
- if (configAsString) {
6606
- const config = JSON.parse(configAsString);
6607
- const { tabs, fields } = config;
6608
- if (tabs) {
6609
- const allTabs = new Map(tabs.map(t => [t.label, t]));
6610
- fields.forEach(f => f.tab = allTabs.get(f.tab));
6611
- }
6612
- accept(fields);
6613
- }
6614
- else {
6615
- reject(`Sem configuração pro formulário "${formName}".`);
6616
- }
6617
- })
6618
- .catch((error) => {
6619
- reject(error);
6620
- });
6621
- });
6622
- }
6898
+ class FormConfigFetcher extends ResourceFetcher {
6899
+ loadFormConfig(formName, resourceID) {
6900
+ return new Promise((accept, reject) => {
6901
+ this.loadResource(`cfg://form/${resourceID}/${formName}`)
6902
+ .then((configAsString) => {
6903
+ if (configAsString) {
6904
+ const config = JSON.parse(configAsString);
6905
+ const { tabs, fields } = config;
6906
+ if (tabs) {
6907
+ const allTabs = new Map(tabs.map(t => [t.label, t]));
6908
+ fields.forEach(f => f.tab = allTabs.get(f.tab));
6909
+ }
6910
+ accept(fields);
6911
+ }
6912
+ else {
6913
+ reject(`Sem configuração pro formulário "${formName}".`);
6914
+ }
6915
+ })
6916
+ .catch((error) => {
6917
+ reject(error);
6918
+ });
6919
+ });
6920
+ }
6623
6921
  }
6624
6922
 
6625
- const mockByEntity = {
6626
- "ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
6627
- "HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
6628
- "ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
6629
- "HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
6630
- "Usuario": [{ "value": 0, "label": "SUP" }],
6631
- "ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
6632
- "TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
6633
- };
6634
- const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
6635
- var _a;
6636
- console.log(searchArgument);
6637
- const field = dataUnit.getField(fieldName);
6638
- const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
6639
- return (mockByEntity[entityName] || []);
6923
+ const mockByEntity = {
6924
+ "ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
6925
+ "HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
6926
+ "ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
6927
+ "HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
6928
+ "Usuario": [{ "value": 0, "label": "SUP" }],
6929
+ "ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
6930
+ "TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
6931
+ };
6932
+ const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
6933
+ var _a;
6934
+ console.log(searchArgument);
6935
+ const field = dataUnit.getField(fieldName);
6936
+ const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
6937
+ return (mockByEntity[entityName] || []);
6640
6938
  };
6641
6939
 
6642
6940
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
6643
6941
 
6644
- const SnkApplication = class {
6645
- constructor(hostRef) {
6646
- index.registerInstance(this, hostRef);
6647
- this.applicationLoaded = index.createEvent(this, "applicationLoaded", 7);
6648
- this.applicationLoading = index.createEvent(this, "applicationLoading", 7);
6649
- }
6650
- get parameters() {
6651
- if (!this._parameters) {
6652
- this._parameters = new ParametersFetcher();
6653
- }
6654
- return this._parameters;
6655
- }
6656
- get resourceID() {
6657
- if (!this._resourceID) {
6658
- this._resourceID = this.urlParams.get("workspaceResourceID") ||
6659
- this.urlParams.get("resourceID") ||
6660
- Workspace.resourceID ||
6661
- "unknown.resource.id";
6662
- }
6663
- return this._resourceID;
6664
- }
6665
- async getStringParam(name) {
6666
- return this.parameters.asString(name, this.resourceID);
6667
- }
6668
- async getIntParam(name) {
6669
- return this.parameters.asInteger(name, this.resourceID);
6670
- }
6671
- async getFloatParam(name) {
6672
- return this.parameters.asFloat(name, this.resourceID);
6673
- }
6674
- async getBooleanParam(name) {
6675
- return this.parameters.asBoolean(name, this.resourceID);
6676
- }
6677
- async getDateParam(name) {
6678
- return this.parameters.asDate(name, this.resourceID);
6679
- }
6680
- async temOpcional(opcional) {
6681
- const opts = opcional.split(",");
6682
- return new Promise((resolve, reject) => {
6683
- this.getAttributeFromHTMLWrapper("opc0009")
6684
- .then(value => {
6685
- if (value === "1") {
6686
- resolve(true);
6687
- }
6688
- else {
6689
- Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
6690
- .then(result => {
6691
- resolve(result.includes("1"));
6692
- })
6693
- .catch(error => {
6694
- reject(error);
6695
- });
6696
- }
6697
- })
6698
- .catch(error => {
6699
- reject(error);
6700
- });
6701
- });
6702
- }
6703
- async getAttributeFromHTMLWrapper(attribName) {
6704
- return Promise.resolve(window[attribName]);
6705
- }
6706
- async openApp(resourceId, pkObject) {
6707
- Workspace.openAppActivity(resourceId, pkObject);
6708
- }
6709
- async createDataunit(entityName) {
6710
- return new Promise(resolve => {
6711
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
6712
- dataUnit.loadMetadata();
6713
- resolve(dataUnit);
6714
- });
6715
- }
6716
- async getResourceID() {
6717
- return Promise.resolve(this.resourceID);
6718
- }
6719
- async alert(title, message, icon) {
6720
- return utils.ApplicationUtils.alert(title, message, icon);
6721
- }
6722
- async error(title, message, icon) {
6723
- return utils.ApplicationUtils.error(title, message, icon);
6724
- }
6725
- async confirm(title, message, icon, critical) {
6726
- return utils.ApplicationUtils.confirm(title, message, icon, critical);
6727
- }
6728
- async info(message, options = undefined) {
6729
- return utils.ApplicationUtils.info(message, options);
6730
- }
6731
- async loadFormConfig(name) {
6732
- return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
6733
- }
6734
- get urlParams() {
6735
- if (!this._urlParams) {
6736
- this._urlParams = UrlUtils.getQueryParams(location.search);
6737
- }
6738
- return this._urlParams;
6739
- }
6740
- get dataUnitFetcher() {
6741
- if (!this._dataUnitFetcher) {
6742
- this._dataUnitFetcher = new DataUnitFetcher();
6743
- }
6744
- return this._dataUnitFetcher;
6745
- }
6746
- get formConfigFetcher() {
6747
- if (!this._formConfigFetcher) {
6748
- this._formConfigFetcher = new FormConfigFetcher();
6749
- }
6750
- return this._formConfigFetcher;
6751
- }
6752
- componentWillLoad() {
6753
- core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
6754
- }
6755
- componentDidLoad() {
6756
- this.applicationLoading.emit(true);
6757
- window.requestAnimationFrame(() => {
6758
- this.applicationLoaded.emit(true);
6759
- });
6760
- }
6761
- render() {
6762
- return (index.h("div", null));
6763
- }
6764
- };
6942
+ const SnkApplication = class {
6943
+ constructor(hostRef) {
6944
+ index.registerInstance(this, hostRef);
6945
+ this.applicationLoaded = index.createEvent(this, "applicationLoaded", 7);
6946
+ this.applicationLoading = index.createEvent(this, "applicationLoading", 7);
6947
+ }
6948
+ get parameters() {
6949
+ if (!this._parameters) {
6950
+ this._parameters = new ParametersFetcher();
6951
+ }
6952
+ return this._parameters;
6953
+ }
6954
+ get resourceID() {
6955
+ if (!this._resourceID) {
6956
+ this._resourceID = this.urlParams.get("workspaceResourceID") ||
6957
+ this.urlParams.get("resourceID") ||
6958
+ Workspace.resourceID ||
6959
+ "unknown.resource.id";
6960
+ }
6961
+ return this._resourceID;
6962
+ }
6963
+ async getStringParam(name) {
6964
+ return this.parameters.asString(name, this.resourceID);
6965
+ }
6966
+ async getIntParam(name) {
6967
+ return this.parameters.asInteger(name, this.resourceID);
6968
+ }
6969
+ async getFloatParam(name) {
6970
+ return this.parameters.asFloat(name, this.resourceID);
6971
+ }
6972
+ async getBooleanParam(name) {
6973
+ return this.parameters.asBoolean(name, this.resourceID);
6974
+ }
6975
+ async getDateParam(name) {
6976
+ return this.parameters.asDate(name, this.resourceID);
6977
+ }
6978
+ async temOpcional(opcional) {
6979
+ const opts = opcional.split(",");
6980
+ return new Promise((resolve, reject) => {
6981
+ this.getAttributeFromHTMLWrapper("opc0009")
6982
+ .then(value => {
6983
+ if (value === "1") {
6984
+ resolve(true);
6985
+ }
6986
+ else {
6987
+ Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
6988
+ .then(result => {
6989
+ resolve(result.includes("1"));
6990
+ })
6991
+ .catch(error => {
6992
+ reject(error);
6993
+ });
6994
+ }
6995
+ })
6996
+ .catch(error => {
6997
+ reject(error);
6998
+ });
6999
+ });
7000
+ }
7001
+ async getAttributeFromHTMLWrapper(attribName) {
7002
+ return Promise.resolve(window[attribName]);
7003
+ }
7004
+ async openApp(resourceId, pkObject) {
7005
+ Workspace.openAppActivity(resourceId, pkObject);
7006
+ }
7007
+ async createDataunit(entityName) {
7008
+ return new Promise(resolve => {
7009
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7010
+ dataUnit.loadMetadata();
7011
+ resolve(dataUnit);
7012
+ });
7013
+ }
7014
+ async getResourceID() {
7015
+ return Promise.resolve(this.resourceID);
7016
+ }
7017
+ async alert(title, message, icon) {
7018
+ return utils.ApplicationUtils.alert(title, message, icon);
7019
+ }
7020
+ async error(title, message, icon) {
7021
+ return utils.ApplicationUtils.error(title, message, icon);
7022
+ }
7023
+ async confirm(title, message, icon, critical) {
7024
+ return utils.ApplicationUtils.confirm(title, message, icon, critical);
7025
+ }
7026
+ async info(message, options = undefined) {
7027
+ return utils.ApplicationUtils.info(message, options);
7028
+ }
7029
+ async loadFormConfig(name) {
7030
+ return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7031
+ }
7032
+ get urlParams() {
7033
+ if (!this._urlParams) {
7034
+ this._urlParams = UrlUtils.getQueryParams(location.search);
7035
+ }
7036
+ return this._urlParams;
7037
+ }
7038
+ get dataUnitFetcher() {
7039
+ if (!this._dataUnitFetcher) {
7040
+ this._dataUnitFetcher = new DataUnitFetcher();
7041
+ }
7042
+ return this._dataUnitFetcher;
7043
+ }
7044
+ get formConfigFetcher() {
7045
+ if (!this._formConfigFetcher) {
7046
+ this._formConfigFetcher = new FormConfigFetcher();
7047
+ }
7048
+ return this._formConfigFetcher;
7049
+ }
7050
+ componentWillLoad() {
7051
+ core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
7052
+ }
7053
+ componentDidLoad() {
7054
+ this.applicationLoading.emit(true);
7055
+ window.requestAnimationFrame(() => {
7056
+ this.applicationLoaded.emit(true);
7057
+ });
7058
+ }
7059
+ render() {
7060
+ return (index.h("div", null));
7061
+ }
7062
+ };
6765
7063
  SnkApplication.style = snkApplicationCss;
6766
7064
 
6767
7065
  exports.snk_application = SnkApplication;