@pega/custom-dx-components 0.23.3 → 0.23.4

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 (254) hide show
  1. package/.prettierrc.json +7 -1
  2. package/babel.config.cjs +13 -0
  3. package/jest.config.cjs +18 -0
  4. package/package.json +18 -11
  5. package/src/auth.js +578 -555
  6. package/src/cli.js +11 -5
  7. package/src/constants.js +23 -25
  8. package/src/currentPath.cjs +1 -0
  9. package/src/tasks/authenticate/helper.js +82 -18
  10. package/src/tasks/authenticate/index.js +21 -7
  11. package/src/tasks/build/helper.js +17 -8
  12. package/src/tasks/build/index.js +29 -7
  13. package/src/tasks/build-all/helper.js +2 -1
  14. package/src/tasks/build-all/index.js +32 -25
  15. package/src/tasks/bundle/builder/index.js +5 -0
  16. package/src/tasks/bundle/builder/webpack.config.js +3 -2
  17. package/src/tasks/create/index.js +8 -5
  18. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +0 -1
  19. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +7 -7
  20. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +0 -1
  21. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +8 -8
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +0 -1
  23. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +10 -10
  24. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +6 -5
  25. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +6 -3
  26. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +0 -1
  27. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +0 -1
  28. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +0 -1
  29. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +0 -1
  30. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +0 -1
  31. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +0 -1
  32. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +0 -1
  33. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +0 -1
  34. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +0 -1
  35. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +0 -1
  36. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +0 -1
  37. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +0 -1
  38. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +0 -1
  39. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +6 -5
  40. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +0 -1
  41. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +0 -1
  42. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +0 -1
  43. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +0 -1
  44. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +0 -1
  45. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +0 -1
  46. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +0 -1
  47. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +0 -1
  48. package/src/tasks/create-all/index.js +68 -47
  49. package/src/tasks/delete/helper.js +90 -40
  50. package/src/tasks/delete/index.js +5 -5
  51. package/src/tasks/delete-all/helper.js +108 -48
  52. package/src/tasks/delete-all/index.js +6 -6
  53. package/src/tasks/index.js +2 -1
  54. package/src/tasks/init/template/README.md +2 -204
  55. package/src/tasks/init/template/babel.config.cjs +13 -0
  56. package/src/tasks/init/template/jest.config.cjs +25 -0
  57. package/src/tasks/init/template/package.json.mustache +13 -5
  58. package/src/tasks/init/template/src/components/_components.md +1 -1
  59. package/src/tasks/init/template/tasks.config.json +11 -8
  60. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/config.json +55 -0
  61. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/demo.stories.jsx +51 -0
  62. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/index.jsx +60 -0
  63. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/mock.stories.js +13 -0
  64. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/styles.js +7 -0
  65. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/Boolean.js +38 -0
  66. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/boolean-format.js +26 -0
  67. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/config.json +145 -0
  68. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/demo.stories.jsx +61 -0
  69. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/event-utils.js +18 -0
  70. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/index.jsx +170 -0
  71. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/mock.stories.js +21 -0
  72. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/styles.js +7 -0
  73. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/OneColumnPage.svg +36 -0
  74. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/config.json +23 -0
  75. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/demo.stories.jsx +78 -0
  76. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/index.jsx +73 -0
  77. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/mock.stories.js +390 -0
  78. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/styles.js +7 -0
  79. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/config.json +291 -0
  80. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/demo.stories.jsx +53 -0
  81. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/event-utils.js +18 -0
  82. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/index.jsx +296 -0
  83. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/mock.stories.js +23 -0
  84. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/styles.js +7 -0
  85. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/suggestions-handler.js +10 -0
  86. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/DateFormatter.js +61 -0
  87. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/FormattedText.jsx +41 -0
  88. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/config.json +195 -0
  89. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/date.js +439 -0
  90. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/demo.stories.jsx +73 -0
  91. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/index.jsx +256 -0
  92. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/mock.stories.js +23 -0
  93. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/styles.js +7 -0
  94. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/suggestions-handler.js +10 -0
  95. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/config.json +256 -0
  96. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-time.js +92 -0
  97. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-utils.js +288 -0
  98. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date.js +331 -0
  99. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/demo.stories.jsx +73 -0
  100. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/index.jsx +254 -0
  101. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/mock.stories.js +23 -0
  102. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/styles.js +7 -0
  103. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/suggestions-handler.js +10 -0
  104. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/config.json +278 -0
  105. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/demo.stories.jsx +49 -0
  106. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/event-utils.js +18 -0
  107. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/index.jsx +270 -0
  108. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/mock.stories.js +21 -0
  109. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/styles.js +7 -0
  110. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/suggestions-handler.js +10 -0
  111. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/OneColumnDetails.svg +22 -0
  112. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/StatusWork.jsx +26 -0
  113. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/config.json +35 -0
  114. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/demo.stories.jsx +132 -0
  115. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/index.jsx +83 -0
  116. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/mock.stories.js +189 -0
  117. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/styles.js +7 -0
  118. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/utils.js +152 -0
  119. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/config.json +111 -0
  120. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/demo.stories.jsx +48 -0
  121. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/event-utils.js +18 -0
  122. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/index.jsx +231 -0
  123. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/mock.stories.js +22 -0
  124. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/styles.js +7 -0
  125. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/suggestions-handler.js +10 -0
  126. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/DefaultForm.svg +29 -0
  127. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/config.json +45 -0
  128. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/demo.stories.jsx +166 -0
  129. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/index.jsx +42 -0
  130. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/mock.stories.js +137 -0
  131. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/styles.js +7 -0
  132. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/config.json +344 -0
  133. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/demo.stories.jsx +49 -0
  134. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/event-utils.js +18 -0
  135. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/index.jsx +333 -0
  136. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/mock.stories.js +21 -0
  137. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/styles.js +7 -0
  138. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/suggestions-handler.js +10 -0
  139. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/GetNextWork.jsx +35 -0
  140. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/OneColumnPage.svg +36 -0
  141. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/config.json +32 -0
  142. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/demo.stories.jsx +102 -0
  143. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/index.jsx +70 -0
  144. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/localizations.json +4 -0
  145. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/mock.stories.js +94 -0
  146. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/styles.js +7 -0
  147. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/utils.js +229 -0
  148. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Avatar.jsx +75 -0
  149. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/OneColumnPage.svg +36 -0
  150. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Operator.jsx +237 -0
  151. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/config.json +66 -0
  152. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/demo.stories.jsx +68 -0
  153. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/index.jsx +108 -0
  154. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/mock.stories.js +51 -0
  155. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/styles.js +7 -0
  156. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/OneColumnPage.svg +36 -0
  157. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/config.json +59 -0
  158. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/demo.stories.jsx +30 -0
  159. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/index.jsx +48 -0
  160. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/mock.stories.js +23 -0
  161. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/styles.js +7 -0
  162. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/config.json +111 -0
  163. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/demo.stories.jsx +48 -0
  164. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/event-utils.js +18 -0
  165. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/index.jsx +231 -0
  166. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/mock.stories.js +20 -0
  167. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/styles.js +7 -0
  168. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/suggestions-handler.js +10 -0
  169. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/config.json +93 -0
  170. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/demo.stories.jsx +49 -0
  171. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/event-utils.js +18 -0
  172. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/index.jsx +275 -0
  173. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/mock.stories.js +21 -0
  174. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/styles.js +7 -0
  175. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/suggestions-handler.js +10 -0
  176. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/config.json +123 -0
  177. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/demo.stories.jsx +46 -0
  178. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/event-utils.js +18 -0
  179. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/index.jsx +266 -0
  180. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/mock.stories.js +37 -0
  181. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/styles.js +7 -0
  182. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/suggestions-handler.js +10 -0
  183. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/config.json +114 -0
  184. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/demo.stories.jsx +78 -0
  185. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/event-utils.js +18 -0
  186. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/index.jsx +351 -0
  187. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/mock.stories.js +67 -0
  188. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/styles.js +7 -0
  189. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/suggestions-handler.js +10 -0
  190. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/config.json +55 -0
  191. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/demo.stories.jsx +51 -0
  192. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/index.jsx +60 -0
  193. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/mock.stories.js +13 -0
  194. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/styles.js +7 -0
  195. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/StatusWork.jsx +26 -0
  196. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/config.json +111 -0
  197. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/demo.stories.jsx +48 -0
  198. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/event-utils.js +18 -0
  199. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/index.jsx +239 -0
  200. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/mock.stories.js +21 -0
  201. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/styles.js +7 -0
  202. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/suggestions-handler.js +10 -0
  203. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/config.json +185 -0
  204. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/demo.stories.jsx +57 -0
  205. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/index.jsx +213 -0
  206. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/mock.stories.js +20 -0
  207. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/styles.js +7 -0
  208. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/suggestions-handler.js +10 -0
  209. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/time-of-day.js +288 -0
  210. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/StatusWork.jsx +26 -0
  211. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/TwoColumnDetails.svg +28 -0
  212. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/config.json +42 -0
  213. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +136 -0
  214. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/index.jsx +83 -0
  215. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/mock.stories.js +230 -0
  216. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/styles.js +7 -0
  217. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/utils.js +155 -0
  218. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/TwoColumn.svg +38 -0
  219. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/config.json +27 -0
  220. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +175 -0
  221. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/index.jsx +45 -0
  222. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/mock.stories.js +143 -0
  223. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/styles.js +7 -0
  224. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/config.json +237 -0
  225. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/demo.stories.jsx +46 -0
  226. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/event-utils.js +18 -0
  227. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/index.jsx +232 -0
  228. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/mock.stories.js +22 -0
  229. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/styles.js +7 -0
  230. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/suggestions-handler.js +10 -0
  231. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/text-url.jsx +173 -0
  232. package/src/tasks/init/template/test/functionTest/localCreateAllListDeleteAll.test.js +157 -0
  233. package/src/tasks/init/template/test/functionTest/localCreateBuildAllDeleteAll.test.js +148 -0
  234. package/src/tasks/init/template/test/functionTest/localCreateBuildDelete.test.js +84 -0
  235. package/src/tasks/init/template/test/functionTest/localCreateListDelete.test.js +108 -0
  236. package/src/tasks/init/template/test/functionTest/localCreatePublishAllDeleteAll.test.js +148 -0
  237. package/src/tasks/init/template/test/functionTest/localCreatePublishDelete.test.js +84 -0
  238. package/src/tasks/init/template/test/functionTest/localCreateRenameDelete.test.js +84 -0
  239. package/src/tasks/init/template/test/functionTest/localPromoteRevertWP.test.js +59 -0
  240. package/src/tasks/list/helper.js +115 -14
  241. package/src/tasks/promote-webpack/index.js +126 -0
  242. package/src/tasks/promote-webpack/webpack.config.js +376 -0
  243. package/src/tasks/publish/helper.js +116 -61
  244. package/src/tasks/publish/index.js +34 -8
  245. package/src/tasks/publish-all/helper.js +115 -63
  246. package/src/tasks/publish-all/index.js +51 -30
  247. package/src/tasks/rename/index.js +127 -97
  248. package/src/tasks/revert-webpack/index.js +71 -0
  249. package/src/util.js +159 -320
  250. package/test/unitTest/util.test.js +525 -0
  251. package/src/tasks/generate-ai/aiPrompt.txt.mustache +0 -23
  252. package/src/tasks/generate-ai/aiPromptDavinci.txt.mustache +0 -14
  253. package/src/tasks/generate-ai/helper.js +0 -390
  254. package/src/tasks/generate-ai/index.js +0 -34
package/src/util.js CHANGED
@@ -1,16 +1,20 @@
1
1
  import fs from 'fs';
2
- import path from 'path';
3
2
  import { join } from 'path';
4
3
  import { promisify } from 'util';
5
4
  import https from 'https';
6
5
 
6
+
7
7
  import chalk from 'chalk';
8
8
  import mustache from 'mustache';
9
9
  import pascalCase from 'pascalcase';
10
10
  import fetch from 'node-fetch';
11
11
  import { createRequire } from 'module';
12
12
 
13
- import _ from 'lodash';
13
+ import checkGit from 'check-git';
14
+
15
+ import * as currentPath from "./currentPath.cjs";
16
+
17
+
14
18
 
15
19
 
16
20
  import {
@@ -19,17 +23,12 @@ import {
19
23
  TOKEN_PATH,
20
24
  OOTB_COMPONENT_SERVICE_REST_ENDPOINT,
21
25
  DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
22
- OOTB_COMPONENTS,
23
- SERVICES_AI_REST_ENDPOINT,
24
- BOOTSTRAP_SERVICE_REST_ENDPOINT,
25
- DXCOMPGENAI_SERVICE_REST_ENDPOINT,
26
- SERVICE_TOKEN_PATH
26
+ LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
27
+ OOTB_COMPONENTS
27
28
  } from './constants.js';
28
29
 
29
30
  const access = promisify(fs.access);
30
31
 
31
- let servicesToken = "";
32
-
33
32
  export const checkPathAccess = async (path, options = {}) => {
34
33
  const { errorMessage } = options;
35
34
 
@@ -43,7 +42,7 @@ export const checkPathAccess = async (path, options = {}) => {
43
42
  }
44
43
  };
45
44
 
46
- export const deleteLocalComponent = async componentKey => {
45
+ export const deleteLocalComponent = async (componentKey) => {
47
46
  const currentDirectory = process.cwd();
48
47
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
49
48
 
@@ -61,13 +60,14 @@ export const deleteLocalComponent = async componentKey => {
61
60
 
62
61
  const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
63
62
 
64
- fs.rm(directory, { recursive: true }, err => {
65
- if (err) {
66
- throw err;
67
- }
68
-
63
+ try {
64
+ fs.rmSync(directory, { recursive: true });
69
65
  console.log(`${chalk.red.bold(componentKey)} is deleted from Local`);
70
- });
66
+ }
67
+ catch (err) {
68
+ console.log("no file");
69
+ throw new Error (`No such file ${componentKey}`);
70
+ }
71
71
  };
72
72
 
73
73
  export const deleteServerComponent = async componentKey => {
@@ -84,9 +84,7 @@ export const deleteServerComponent = async componentKey => {
84
84
  token_type: tokenType,
85
85
  refresh_token: refreshToken
86
86
  } = JSON.parse(OauthData);
87
-
88
-
89
- await fetch(deleteUrl, {
87
+ fetch(deleteUrl, {
90
88
  method: 'DELETE',
91
89
  agent: new https.Agent({ rejectUnauthorized: false }),
92
90
  headers: {
@@ -128,11 +126,12 @@ export const getComponents = async () => {
128
126
  await checkPathAccess(pegaConfigJsonPath);
129
127
 
130
128
  let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
129
+
131
130
  data = JSON.parse(data);
132
131
 
133
132
  if (!data[COMPONENTS_DIRECTORY_PATH]) {
134
133
  console.error(
135
- `${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
134
+ `${chalk.red.bold('ERROR')} Could not find components directory path in config.json`
136
135
  );
137
136
  process.exit(1);
138
137
  }
@@ -144,46 +143,6 @@ export const getComponents = async () => {
144
143
  .map(dirent => dirent.name);
145
144
  };
146
145
 
147
- export const getComponentsOfType = async (componentType) => {
148
- const componentList = await getComponents();
149
- let filteredList = Array();
150
- if (componentList.length > 0) {
151
-
152
- const currentDirectory = process.cwd();
153
- const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
154
-
155
- await checkPathAccess(pegaConfigJsonPath);
156
-
157
- let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
158
- data = JSON.parse(data);
159
-
160
- if (!data[COMPONENTS_DIRECTORY_PATH]) {
161
- console.error(
162
- `${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
163
- );
164
- process.exit(1);
165
- }
166
-
167
- const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH]);
168
- const arTypes = componentType.split(",");
169
-
170
- for (let index in componentList) {
171
- let compDir = directory + path.sep + componentList[index];
172
- let type = await getComponentConfigType(compDir);
173
- if (arTypes.includes(type)) {
174
- filteredList.push( componentList[index]);
175
- }
176
- }
177
-
178
-
179
-
180
- return filteredList;
181
- }
182
- else {
183
- return componentList;
184
- }
185
- };
186
-
187
146
 
188
147
 
189
148
 
@@ -192,24 +151,21 @@ export const getSubComponents = async (directory, type) => {
192
151
  const subDirectory = join(directory, type);
193
152
  return fs
194
153
  .readdirSync(subDirectory, { withFileTypes: true })
195
- .filter(dirent => dirent.isDirectory())
196
- .map(dirent => dirent.name);
197
- }
198
-
154
+ .filter((dirent) => dirent.isDirectory())
155
+ .map((dirent) => dirent.name);
156
+ };
199
157
 
200
158
  export const getDirectoryFiles = async (directory) => {
201
159
  return fs
202
160
  .readdirSync(directory, { withFileTypes: true })
203
- .filter(dirent => !dirent.isDirectory())
204
- .map(dirent => dirent.name);
205
- }
206
-
161
+ .filter((dirent) => !dirent.isDirectory())
162
+ .map((dirent) => dirent.name);
163
+ };
207
164
 
208
165
  export const getComponentsObj = async () => {
166
+ const compList = [];
209
167
 
210
- let compList = new Array();
211
-
212
- //const componentList = await getDirectoryFiles(directory);
168
+ // const componentList = await getDirectoryFiles(directory);
213
169
  const componentList = await getComponents();
214
170
 
215
171
 
@@ -227,7 +183,7 @@ export const getComponentsObj = async () => {
227
183
  }
228
184
 
229
185
  return compList;
230
- }
186
+ };
231
187
 
232
188
  export const getPegaConfig = async () => {
233
189
  const currentDirectory = process.cwd();
@@ -241,47 +197,17 @@ export const getPegaConfig = async () => {
241
197
  return data;
242
198
  };
243
199
 
244
- export const getAIPromptData = async (aiPromptPath) => {
245
- await checkPathAccess(aiPromptPath);
246
-
247
- let data = fs.readFileSync(aiPromptPath, { encoding: 'utf8' });
248
-
249
- return data;
250
- }
251
-
252
- export const getComponentConfigJson = async (componentDirectory) => {
253
-
254
- const filePath = join(componentDirectory, "config.json");
255
- await checkPathAccess(filePath);
256
-
257
- let data = fs.readFileSync(filePath, { encoding: 'utf8' });
258
-
259
- data = _.unescape(data);
260
-
261
- return data;
262
- }
263
-
264
- export const getComponentConfigType = async (componentDirectory) => {
265
- const configData = await getComponentConfigJson(componentDirectory);
266
-
267
- let data = JSON.parse(configData);
268
-
269
- return data.type;
270
-
271
- }
272
-
273
200
  export const getPegaServerConfig = async () => {
274
201
  const config = await getPegaConfig();
275
202
  return config['server-config'];
276
203
  };
277
204
 
278
-
279
205
  export const getComponentDefaults = async () => {
280
206
  const config = await getPegaConfig();
281
207
  return config.component;
282
208
  };
283
209
 
284
- export const getComponentDirectoryPath = async componentKey => {
210
+ export const getComponentDirectoryPath = async (componentKey) => {
285
211
  const currentDirectory = process.cwd();
286
212
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
287
213
 
@@ -305,11 +231,11 @@ export const compileMustacheTemplate = (file, data) => {
305
231
  return mustache.render(content, data);
306
232
  };
307
233
 
308
- export const isPascalCase = string => {
234
+ export const isPascalCase = (string) => {
309
235
  return string === pascalCase(string);
310
236
  };
311
237
 
312
- export const convertIntoPascalCase = string => {
238
+ export const convertIntoPascalCase = (string) => {
313
239
  return pascalCase(string);
314
240
  };
315
241
 
@@ -317,23 +243,23 @@ export const constructCompleteUrl = (baseServer, endPoint) => {
317
243
  return baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`;
318
244
  };
319
245
 
320
- export const nodeFetch = (url, config) => {
321
- const { method, user, password, headers, ...restConfig } = config;
246
+ // export const nodeFetch = (url, config) => {
247
+ // const { method, user, password, headers, ...restConfig } = config;
322
248
 
323
- if (url.startsWith('https')) restConfig.agent = new https.Agent({ rejectUnauthorized: false });
249
+ // if (url.startsWith('https')) restConfig.agent = new https.Agent({ rejectUnauthorized: false });
324
250
 
325
- return fetch(url, {
326
- method,
327
- ...restConfig,
328
- headers: {
329
- 'Content-Type': 'application/json;charset=utf-8',
330
- Authorization: `Basic ${Buffer.from(`${user}:${password}`).toString('base64')}`,
331
- ...headers
332
- }
333
- });
334
- };
251
+ // return fetch(url, {
252
+ // method,
253
+ // ...restConfig,
254
+ // headers: {
255
+ // 'Content-Type': 'application/json;charset=utf-8',
256
+ // Authorization: `Basic ${Buffer.from(`${user}:${password}`).toString('base64')}`,
257
+ // ...headers
258
+ // }
259
+ // });
260
+ // };
335
261
 
336
- export const sanitize = str => {
262
+ export const sanitize = (str) => {
337
263
  /* Allow only numbers and case insensitive alphabets */
338
264
  str = str.replace(/[^a-zA-Z0-9 ]/g, '');
339
265
  /* spaces will be replaced by - */
@@ -341,13 +267,13 @@ export const sanitize = str => {
341
267
  return str;
342
268
  };
343
269
 
344
- export const validateSemver = str => {
270
+ export const validateSemver = (str) => {
345
271
  /* basic semver version validation - 0.0.1-dev */
346
272
  const regex = /^[0-9]\d*\.\d+\.\d+(?:-[a-zA-Z0-9]+)?$/g;
347
273
  return regex.test(str);
348
274
  };
349
275
 
350
- export const validateRulesetVersion = str => {
276
+ export const validateRulesetVersion = (str) => {
351
277
  /* Ruleset version range - 01-99 */
352
278
  if (str.indexOf('00') !== -1) {
353
279
  return false;
@@ -357,15 +283,21 @@ export const validateRulesetVersion = str => {
357
283
  return regex.test(str);
358
284
  };
359
285
 
286
+ export const standardizeStr = (str, length) => {
287
+ return str.padEnd(length);
288
+ };
289
+
360
290
  export const showVersion = () => {
361
291
  // get package version, so can display at start
362
- const require = createRequire(import.meta.url);
292
+ // const require = createRequire(import.meta.url);
293
+ const require = createRequire(currentPath.default);
294
+
363
295
  const pData = require("@pega/custom-dx-components/package.json");
364
296
 
365
- console.log(chalk.green("DX Component Builder v" + pData.version));
297
+ console.log(chalk.green(`DX Component Builder v${pData.version}`));
366
298
 
367
299
  // do a check of node version, it should be 18 or greater
368
- const arNodeVersion = process.versions.node.split(".");
300
+ const arNodeVersion = process.versions.node.split('.');
369
301
 
370
302
  const nodeMajorVersion = parseInt(arNodeVersion[0]);
371
303
  const nodeMinorVersion = parseInt(arNodeVersion[1]);
@@ -374,22 +306,27 @@ export const showVersion = () => {
374
306
  console.log(chalk.redBright("DX Component Builder - SDK requires node v18 or greater, current version: " + process.version));
375
307
  process.exit(1);
376
308
  }
309
+
310
+ const hasGit = checkGit(process.cwd());
311
+
312
+ if (!hasGit) {
313
+ console.log(chalk.redBright("DX Component Builder - SDK git to be installed."));
314
+ process.exit(1);
315
+ }
316
+
317
+
377
318
  };
378
319
 
379
320
  export const getOOTBComponents = async () => {
380
- return new Promise((resolve, reject) => {
381
- fs.readFile(OOTB_COMPONENTS, 'utf-8', async (err, data) => {
382
- if (err) {
321
+ return new Promise((resolve) => {
322
+ fs.readFile(OOTB_COMPONENTS, 'utf-8', async (error, ootbComponentsData) => {
323
+ if (error) {
383
324
  try {
384
325
  const { server } = await getPegaServerConfig();
385
326
  const url = constructCompleteUrl(server, OOTB_COMPONENT_SERVICE_REST_ENDPOINT);
386
327
  const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
387
328
  if (OauthData) {
388
- const {
389
- access_token: accessToken,
390
- token_type: tokenType,
391
- refresh_token: refreshToken
392
- } = JSON.parse(OauthData);
329
+ const { access_token: accessToken, token_type: tokenType } = JSON.parse(OauthData);
393
330
  fetch(url, {
394
331
  method: 'GET',
395
332
  agent: new https.Agent({ rejectUnauthorized: false }),
@@ -397,12 +334,12 @@ export const getOOTBComponents = async () => {
397
334
  Authorization: `${tokenType} ${accessToken}`
398
335
  }
399
336
  })
400
- .then(response => response.text())
401
- .then(data => {
337
+ .then((response) => response.text())
338
+ .then((data) => {
402
339
  if (data.charAt() === '[') {
403
340
  data = data.slice(1, -1);
404
341
  data = data.replace(/\s/g, '');
405
- fs.writeFile(OOTB_COMPONENTS, data, err => {
342
+ fs.writeFile(OOTB_COMPONENTS, data, (err) => {
406
343
  if (err) {
407
344
  console.error(err);
408
345
  }
@@ -412,232 +349,134 @@ export const getOOTBComponents = async () => {
412
349
  data = JSON.parse(data);
413
350
  if (data && data.errors) {
414
351
  const errMessages = data.errors;
415
- errMessages.forEach(msgArr => {
352
+ errMessages.forEach((msgArr) => {
416
353
  throw new Error(`Failed with error - ${JSON.stringify(msgArr.message)}`);
417
354
  });
418
355
  }
419
356
  }
420
357
  })
421
- .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
358
+ // eslint-disable-next-line prefer-promise-reject-errors
359
+ .catch((e) => Promise.reject(`${chalk.bold.red(e)}`));
422
360
  }
423
- } catch (error) {
424
- throw new Error('Error occurred in validation', error);
361
+ } catch (e) {
362
+ throw new Error('Error occurred in validation', e);
425
363
  }
426
364
  } else {
427
- resolve(data.split(','));
365
+ resolve(ootbComponentsData.split(','));
428
366
  }
429
367
  });
430
368
  });
431
369
  };
432
370
 
433
-
434
-
435
- export const storeServicesToken = async () => {
371
+ export const deleteInfinityServerComponent = async (componentKey) => {
436
372
  const { server } = await getPegaServerConfig();
437
- const url = constructCompleteUrl(server, BOOTSTRAP_SERVICE_REST_ENDPOINT);
438
-
439
- let returnToken = "";
440
-
373
+ const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
374
+ const [componentName, rulesetName, rulesetVersion] = componentKey.split('~|~');
375
+ const deleteUrl = `${url}/${componentName}/rulesetname/${rulesetName}/rulesetversion/${rulesetVersion}`;
441
376
  try {
442
377
  const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
443
- if (OauthData) {
444
- let {
445
- access_token: accessToken,
446
- token_type: tokenType,
447
- refresh_token: refreshToken
448
- } = JSON.parse(OauthData);
449
378
 
450
- await fetch(url, {
451
- method: 'GET',
379
+ let status = 500;
380
+
381
+ if (OauthData) {
382
+ const { access_token: accessToken, token_type: tokenType } = JSON.parse(OauthData);
383
+ fetch(deleteUrl, {
384
+ method: 'DELETE',
452
385
  agent: new https.Agent({ rejectUnauthorized: false }),
453
386
  headers: {
454
387
  Authorization: `${tokenType} ${accessToken}`
455
- },
388
+ }
456
389
  })
457
- .then(response => response.text())
458
- .then(data => {
459
-
460
- try {
461
- const returnData = JSON.parse(data);
462
-
463
- if (returnData != null && returnData.pyConfigJSON) {
464
- const returnJSON = JSON.parse(returnData.pyConfigJSON);
465
- const strToken = JSON.stringify(returnJSON.tokens, null, 2);
466
-
467
-
468
- fs.writeFileSync(SERVICE_TOKEN_PATH, strToken, err => {
469
- if (err) {
470
- Promise.reject(`${chalk.bold.red(err)}`);
471
- }
472
- });
473
- //returnToken = returnJSON.tokens.C11NB2S;
474
- }
475
- else {
476
- //returnToken = "";
477
- }
478
- }
479
- catch {
480
- Promise.reject(`${chalk.bold.red(data)}`);
481
- }
482
-
483
-
390
+ .then((response) => {
391
+ status = response.status;
392
+ return response.text();
484
393
  })
485
- .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
486
- }
487
- }
488
- catch (error) {
489
- throw new Error('Error occurred in validation', error);
490
- }
491
-
492
- //return returnToken;
493
-
494
- }
495
-
496
- export const getAIComponent = async (prompt) => {
497
-
498
-
499
- const { servicesServer } = await getPegaServerConfig();
500
- if (servicesServer === undefined) {
501
- Promise.reject(`${chalk.bold.red("ERROR: servicesServer not defined in tasks.config.json" )}`);
502
- }
503
-
504
- const serviceUrl = constructCompleteUrl(servicesServer, SERVICES_AI_REST_ENDPOINT);
505
-
506
- const jsonBody = { "prompt" : prompt };
507
-
508
- let returnCode = "";
509
-
510
- try {
511
- const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
512
- const ServicesData = fs.readFileSync(SERVICE_TOKEN_PATH, 'utf8');
513
- if (OauthData && ServicesData) {
514
- let {
515
- access_token: accessToken,
516
- token_type: tokenType,
517
- refresh_token: refreshToken
518
- } = JSON.parse(OauthData);
519
-
520
- const { C11NB2S } = JSON.parse(ServicesData);
521
-
522
- // services needs Bearer with a big "B"
523
- tokenType = convertIntoPascalCase(tokenType);
524
-
525
- await fetch(serviceUrl, {
526
- method: 'POST',
527
- agent: new https.Agent({ rejectUnauthorized: false }),
528
- headers: {
529
- Authorization: `${tokenType} ${C11NB2S}`,
530
- 'Accept': 'application/json',
531
- 'Content-Type': 'application/json'
532
- },
533
- body: JSON.stringify(jsonBody),
534
- })
535
- .then(response => response.text())
536
- .then(data => {
537
-
394
+ .then((resp) => {
395
+ let respData;
538
396
  try {
539
- const returnData = JSON.parse(data);
540
-
541
- if (returnData != null && returnData.code) {
542
- returnCode = returnData.code;
543
- }
544
- else {
545
- returnCode = "";
546
- }
547
- }
548
- catch {
549
- Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
550
- //throw new Error('Error occurred in validation', data);
397
+ respData = JSON.parse(resp);
398
+ } catch (e) {
399
+ console.log(chalk.bold.redBright(`Failure : ${resp}`));
400
+ process.exit(1);
551
401
  }
552
402
 
553
-
403
+ if (status === 200) {
404
+ console.log(chalk.bold.green(`Success : ${respData.message}`));
405
+ } else {
406
+ throw new Error(`${respData.message}`);
407
+ }
554
408
  })
555
- .catch(e => Promise.reject(`Error in AI generation: \n ${chalk.bold.red(e)}`));
556
- }
557
- }
558
- catch (error) {
559
- if (error.code === 'ENOENT') {
560
- Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
561
- }
562
- else {
563
- throw new Error('Error occurred in validation', error);
409
+ .catch((e) => {
410
+ if (status === 403) {
411
+ // eslint-disable-next-line prefer-promise-reject-errors
412
+ Promise.reject(`${chalk.bold.red('Error forbidden: User does not have privileges to Delete.')}`);
413
+ } else {
414
+ // eslint-disable-next-line prefer-promise-reject-errors
415
+ Promise.reject(`${chalk.bold.red(e)}`);
416
+ }
417
+ });
564
418
  }
565
-
419
+ } catch (error) {
420
+ console.log(`\n${chalk.bold.red(error)}`);
566
421
  }
567
-
568
- return returnCode;
569
422
  };
570
423
 
571
-
572
- export const getInfinityAIComponent = async (prompt) => {
573
- const { server } = await getPegaServerConfig();
574
- const dataPageUrl = constructCompleteUrl(server, DXCOMPGENAI_SERVICE_REST_ENDPOINT);
575
-
576
- const jsonBody = { "dataViewParameters" : { "Prompt" : prompt } };
577
-
578
-
579
-
580
- let returnCode = "";
424
+ export const deleteLaunchpadServerComponent = async (componentKey) => {
425
+ const { server, isolationId } = await getPegaServerConfig();
426
+ const deleteUrl = constructCompleteUrl(server, LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT.replace('{isolationId}', isolationId));
427
+ const [componentName] = componentKey.split('~|~');
581
428
 
582
429
  try {
583
430
  const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
584
431
 
432
+ let status = 500;
433
+
585
434
  if (OauthData) {
586
- let {
587
- access_token: accessToken,
588
- token_type: tokenType,
589
- refresh_token: refreshToken
590
- } = JSON.parse(OauthData);
435
+ const { access_token: accessToken, token_type: tokenType } = JSON.parse(OauthData);
436
+
437
+ const headers = {
438
+ Authorization: `${tokenType} ${accessToken}`,
439
+ cookie: `Pega-AAT=${accessToken}`,
440
+ 'Content-Type': 'application/json'
441
+ };
591
442
 
592
- // services needs Bearer with a big "B"
593
- //tokenType = convertIntoPascalCase(tokenType);
443
+ const apiBody = {
444
+ type: 'CustomComponent',
445
+ componentName
446
+ };
594
447
 
595
- await fetch(dataPageUrl, {
596
- method: 'POST',
448
+ fetch(deleteUrl, {
449
+ method: 'DELETE',
597
450
  agent: new https.Agent({ rejectUnauthorized: false }),
598
- headers: {
599
- Authorization: `${tokenType} ${accessToken}`
600
- },
601
- body: JSON.stringify(jsonBody),
451
+ headers,
452
+ body: JSON.stringify(apiBody)
602
453
  })
603
- .then(response => response.text())
604
- .then(data => {
605
-
606
- try {
607
- const returnData = JSON.parse(data);
608
-
609
- if (returnData != null && returnData.data) {
610
- returnCode = returnData.data[0].pyValue;
611
- }
612
- else if (returnData != null && returnData.errors) {
613
- if (returnData.errors[0].message.indexOf("token") >= 0) {
614
- Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
615
- }
616
- }
617
- else {
618
- returnCode = "";
619
- Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
620
- }
621
- }
622
- catch {
623
- Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
624
- //throw new Error('Error occurred in validation', data);
454
+ .then((response) => {
455
+ status = response.status;
456
+ return response.text();
457
+ })
458
+ .then((response) => {
459
+ if (status === 401) {
460
+ throw new Error('Error occurred in authentication. Please regenerate using authenticate');
461
+ // console.log(accessTokenUri, refreshToken);
462
+ /* TODO - Handle refresh_token */
463
+ } else if (status === 200 || status === 201) {
464
+ console.log(chalk.bold.green(`Success : ${response}`));
465
+ } else {
466
+ throw new Error(`${response.message}`);
625
467
  }
626
-
627
-
628
468
  })
629
- .catch(e => Promise.reject(`Error in AI generation: \n ${chalk.bold.red(e)}`));
630
- }
631
- }
632
- catch (error) {
633
- if (error.code === 'ENOENT') {
634
- Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
635
- }
636
- else {
637
- throw new Error('Error occurred in validation', error);
469
+ .catch((e) => {
470
+ if (status === 403) {
471
+ // eslint-disable-next-line prefer-promise-reject-errors
472
+ Promise.reject(`${chalk.bold.red('Error forbidden: User does not have privileges to Delete.')}`);
473
+ } else {
474
+ // eslint-disable-next-line prefer-promise-reject-errors
475
+ Promise.reject(`${chalk.bold.red(e)}`);
476
+ }
477
+ });
638
478
  }
639
-
479
+ } catch (error) {
480
+ console.log(`\n${chalk.bold.red(error)}`);
640
481
  }
641
-
642
- return returnCode;
643
482
  };