@pega/custom-dx-components 0.0.1 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/.vscode/extensions.json +1 -1
  2. package/README.md +6 -189
  3. package/package.json +34 -32
  4. package/src/auth.js +608 -0
  5. package/src/cli.js +42 -0
  6. package/src/constants.js +122 -8
  7. package/src/tasks/authenticate/helper.js +91 -8
  8. package/src/tasks/authenticate/index.js +169 -49
  9. package/src/tasks/build/helper.js +122 -0
  10. package/src/tasks/build/index.js +54 -0
  11. package/src/tasks/build-all/helper.js +70 -0
  12. package/src/tasks/build-all/index.js +79 -0
  13. package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
  14. package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
  15. package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
  16. package/src/tasks/create/index.js +87 -64
  17. package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
  18. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
  19. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +145 -0
  20. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
  21. package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
  22. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
  23. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  24. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
  25. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  26. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  27. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +195 -0
  28. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
  29. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
  30. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
  31. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  32. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
  33. package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
  34. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +256 -0
  35. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
  36. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
  37. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
  38. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
  39. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
  40. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  41. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
  42. package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
  43. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +278 -0
  44. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
  45. package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
  46. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
  47. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  48. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
  49. package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
  50. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +291 -0
  51. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
  52. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
  53. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
  54. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  55. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
  56. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
  57. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +93 -0
  58. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
  59. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
  60. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
  61. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  62. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
  63. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
  64. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +347 -0
  65. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
  66. package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
  67. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
  68. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  69. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
  70. package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
  71. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +114 -0
  72. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
  73. package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
  74. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
  75. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  76. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
  77. package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
  78. package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +14 -5
  79. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
  80. package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
  81. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  82. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
  83. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +111 -0
  84. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
  85. package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
  86. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
  87. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  88. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
  89. package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
  90. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +111 -0
  92. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
  93. package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
  94. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
  95. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  96. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
  97. package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
  98. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +111 -0
  99. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
  100. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
  101. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
  102. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  103. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
  104. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
  105. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +123 -0
  106. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
  107. package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
  108. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
  109. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  110. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
  111. package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
  112. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +237 -0
  113. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
  114. package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
  115. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
  116. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  117. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
  118. package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
  119. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
  120. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +185 -0
  121. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
  122. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
  123. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
  124. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
  125. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
  126. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
  127. package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
  128. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  129. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +35 -0
  130. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
  131. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
  132. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
  133. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
  134. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
  135. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  136. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
  137. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +42 -0
  138. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
  139. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
  140. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
  141. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
  142. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
  143. package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
  144. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +45 -0
  145. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
  146. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
  147. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
  148. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
  149. package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
  150. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +27 -0
  151. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
  152. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
  153. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
  154. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
  155. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
  156. package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
  157. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +32 -0
  158. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  159. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
  160. package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
  161. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  162. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
  163. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
  164. package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
  165. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +23 -0
  166. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  167. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
  168. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
  169. package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
  170. package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
  171. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +59 -0
  172. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  173. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
  174. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
  175. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
  176. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
  177. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
  178. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
  179. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +66 -0
  180. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  181. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
  182. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  183. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
  184. package/src/tasks/create-all/index.js +398 -0
  185. package/src/tasks/delete/helper.js +6 -4
  186. package/src/tasks/delete/index.js +4 -0
  187. package/src/tasks/delete-all/helper.js +153 -0
  188. package/src/tasks/delete-all/index.js +49 -0
  189. package/src/tasks/generate-ai/aiPrompt.txt.mustache +121 -0
  190. package/src/tasks/generate-ai/helper.js +184 -0
  191. package/src/tasks/generate-ai/index.js +33 -0
  192. package/src/tasks/index.js +7 -0
  193. package/src/tasks/init/index.js +9 -3
  194. package/src/tasks/init/template/.eslintignore +8 -0
  195. package/src/tasks/init/template/.eslintrc.json +186 -5
  196. package/src/tasks/init/template/.vscode/extensions.json +1 -1
  197. package/src/tasks/init/template/README.md +80 -61
  198. package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
  199. package/src/tasks/init/template/keys/dxcb.crt +32 -0
  200. package/src/tasks/init/template/keys/dxcb.key +51 -0
  201. package/src/tasks/init/template/package.json.mustache +44 -21
  202. package/src/tasks/init/template/tasks.config.json +19 -5
  203. package/src/tasks/init/template/templateNPMRC.txt +8 -0
  204. package/src/tasks/linter/index.js +46 -0
  205. package/src/tasks/list/helper.js +19 -6
  206. package/src/tasks/list/index.js +4 -0
  207. package/src/tasks/publish/helper.js +13 -4
  208. package/src/tasks/publish/index.js +14 -1
  209. package/src/tasks/publish-all/helper.js +154 -0
  210. package/src/tasks/publish-all/index.js +95 -0
  211. package/src/tasks/rename/index.js +314 -0
  212. package/src/tasks/validator/index.js +291 -18
  213. package/src/util.js +247 -6
  214. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  215. package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
  216. package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
  217. package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
  218. package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
  219. package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
  220. package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
  221. package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
  222. /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
  223. /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
package/src/auth.js ADDED
@@ -0,0 +1,608 @@
1
+ class PegaAuth {
2
+ constructor(ssKeyConfig) {
3
+ if (typeof ssKeyConfig === "string") {
4
+ this.ssKeyConfig = ssKeyConfig;
5
+ this.#reloadConfig();
6
+ } else {
7
+ // object with config structure is passed in
8
+ this.config = ssKeyConfig;
9
+ }
10
+ this.urlencoded = 'application/x-www-form-urlencoded';
11
+ this.isNode = typeof window === 'undefined';
12
+
13
+ // For isNode path the below attributes are initialized on first method invocation
14
+ if (!this.isNode) {
15
+ this.crypto = window.crypto;
16
+ this.subtle = window.crypto.subtle;
17
+ }
18
+ if (!this.config.serverType) {
19
+ this.config.serverType = 'infinity';
20
+ }
21
+ }
22
+
23
+ #reloadConfig() {
24
+ if (!this.ssKeyConfig) {
25
+ return;
26
+ }
27
+ const peConfig = window.sessionStorage.getItem(this.ssKeyConfig);
28
+ let obj = {};
29
+ if (peConfig) {
30
+ try {
31
+ obj = JSON.parse(peConfig);
32
+ } catch (e) {
33
+ try {
34
+ obj = JSON.parse(this.#atob(peConfig));
35
+ } catch (err) {
36
+ obj = {};
37
+ }
38
+ }
39
+ }
40
+ this.config = peConfig ? obj : {};
41
+ }
42
+
43
+ #updateConfig() {
44
+ if (this.ssKeyConfig) {
45
+ window.sessionStorage.setItem(this.ssKeyConfig, this.#btoa(JSON.stringify(this.config)));
46
+ }
47
+ }
48
+
49
+ async #importSingleLib(libName, libProp) {
50
+ return import(libName).then((mod) => {
51
+ this[libProp] = mod.default;
52
+ }).catch((e) => {
53
+ console.error(`Library ${libName} failed to load`);
54
+ });
55
+ }
56
+
57
+ async #importNodeLibs() {
58
+ // Also current assumption is using Node 18 or better
59
+ return Promise.all([
60
+ this.#importSingleLib('node-fetch', 'fetch'),
61
+ this.#importSingleLib('open', 'open'),
62
+ this.#importSingleLib('node:crypto', 'crypto'),
63
+ this.#importSingleLib('node:https', 'https'),
64
+ this.#importSingleLib('node:http', 'http'),
65
+ this.#importSingleLib('node:fs', 'fs')
66
+ ]).then(() => {
67
+ this.subtle = this.crypto.subtle || this.crypto.webcrypto.subtle;
68
+ /* eslint-disable-next-line no-global-assign */
69
+ fetch = this.fetch;
70
+ });
71
+ }
72
+
73
+ // For PKCE the authorize includes a code_challenge & code_challenge_method as well
74
+ async #buildAuthorizeUrl(state) {
75
+ const { serverType, clientId, redirectUri, authorizeUri, authService, sessionIndex, appAlias,
76
+ userIdentifier, password, noPKCE, isolationId } = this.config;
77
+ const bInfinity = serverType === 'infinity';
78
+
79
+ if (!noPKCE) {
80
+ // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars
81
+ const buf = new Uint8Array(64);
82
+ this.crypto.getRandomValues(buf);
83
+ this.config.codeVerifier = this.#base64UrlSafeEncode(buf);
84
+ }
85
+
86
+ // If sessionIndex exists then increment attempts count (we will stop sending session_index after two failures)
87
+ if (sessionIndex) {
88
+ this.config.sessionIndexAttempts += 1;
89
+ }
90
+ // Persist codeVerifier in session storage so it survives the redirects that are to follow
91
+ this.#updateConfig();
92
+
93
+ if (!state) {
94
+ // Calc random state variable
95
+ const buf = new Uint8Array(32);
96
+ this.crypto.getRandomValues(buf);
97
+ state = this.#base64UrlSafeEncode(buf);
98
+ }
99
+
100
+ // Trim alias to include just the real alias piece
101
+ const addtlScope = appAlias ? `+app.alias.${appAlias.replace(/^app\//, '')}` : '';
102
+ const scope = (bInfinity ? `openid${addtlScope}` : 'user_info');
103
+
104
+ // Add explicit creds if specified to try to avoid login popup
105
+ const authServiceArg = authService ? `&authentication_service=${encodeURIComponent(authService)}` : '';
106
+ const sessionIndexArg = sessionIndex && this.config.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : '';
107
+ const userIdentifierArg = userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '';
108
+ const passwordArg = password && userIdentifier ? `&Password=${encodeURIComponent(window.atob(password))}` : '';
109
+ const moreAuthArgs = bInfinity
110
+ ? `&enable_psyncid=true${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}`
111
+ : `&isolationID=${isolationId}`;
112
+
113
+ let pkceArgs = '';
114
+ if (!noPKCE) {
115
+ const cc = await this.#getCodeChallenge(this.config.codeVerifier);
116
+ pkceArgs = `&code_challenge=${cc}&code_challenge_method=S256`;
117
+ }
118
+ return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=${scope}&state=${state}${pkceArgs}${moreAuthArgs}`;
119
+ }
120
+
121
+ async login() {
122
+ if (this.isNode && !this.crypto) {
123
+ // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
124
+ await this.#importNodeLibs();
125
+ }
126
+ const { grantType } = this.config;
127
+ if (grantType && grantType !== 'authCode') {
128
+ return this.getToken();
129
+ }
130
+ return this.#authCodeStart();
131
+ }
132
+
133
+ // authCode login issues the authorize endpoint transaction and deals with redirects
134
+ /* eslint-disable-next-line sonarjs/cognitive-complexity */
135
+ async #authCodeStart() {
136
+ const fnGetRedirectUriOrigin = () => {
137
+ const redirectUri = this.config.redirectUri;
138
+ const nRootOffset = redirectUri.indexOf("//");
139
+ const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf("/", nRootOffset + 2) : -1;
140
+ return nFirstPathOffset !== -1 ? redirectUri.substring(0, nFirstPathOffset) : redirectUri;
141
+ };
142
+
143
+ const redirectOrigin = fnGetRedirectUriOrigin();
144
+ const state = this.isNode ? '' : this.#btoa(window.location.origin);
145
+
146
+ return new Promise((resolve, reject) => {
147
+ this.#buildAuthorizeUrl(state).then((url) => {
148
+ let myWindow = null; // popup or iframe
149
+ let elIframe = null;
150
+ let elCloseBtn = null;
151
+ const iframeTimeout = this.config.silentTimeout !== undefined ? this.config.silentTimeout : 5000;
152
+ let bWinIframe = !this.isNode &&
153
+ iframeTimeout > 0 &&
154
+ ((!!this.config.userIdentifier && !!this.config.password) ||
155
+ this.config.iframeLoginUI ||
156
+ this.config.authService !== 'pega');
157
+ let tmrAuthComplete = null;
158
+ let checkWindowClosed = null;
159
+ const myWinOnLoad = () => {
160
+ try {
161
+ if (bWinIframe) {
162
+ elIframe.contentWindow.postMessage({ type: "PegaAuth" }, redirectOrigin);
163
+ console.log("authjs(login): loaded a page in iFrame");
164
+ } else {
165
+ myWindow.postMessage({ type: "PegaAuth" }, redirectOrigin);
166
+ }
167
+ } catch (e) {
168
+ console.log("authjs(login): Exception trying to postMessage on load");
169
+ }
170
+ };
171
+ /* eslint-disable prefer-promise-reject-errors */
172
+ const fnOpenPopup = () => {
173
+ if (this.config.noPopups) {
174
+ return reject("no-popups");
175
+ }
176
+ myWindow = (this.isNode ? this.open : window.open)(url, '_blank', 'width=700,height=500,left=200,top=100');
177
+ if (!myWindow) {
178
+ // Blocked by popup-blocker
179
+ return reject("blocked");
180
+ }
181
+ checkWindowClosed = setInterval(() => {
182
+ if (myWindow.closed) {
183
+ clearInterval(checkWindowClosed);
184
+ reject("closed");
185
+ }
186
+ }, 500);
187
+ if (!this.isNode) {
188
+ try {
189
+ myWindow.addEventListener("load", myWinOnLoad, true);
190
+ } catch (e) {
191
+ console.log("authjs(login): Exception trying to add onload handler to opened window;");
192
+ }
193
+ }
194
+ };
195
+ /* eslint-enable prefer-promise-reject-errors */
196
+ const fnCloseIframe = () => {
197
+ elIframe.parentNode.removeChild(elIframe);
198
+ elCloseBtn.parentNode.removeChild(elCloseBtn);
199
+ elIframe = null;
200
+ elCloseBtn = null;
201
+ bWinIframe = false;
202
+ };
203
+ const fnCloseAndReject = () => {
204
+ fnCloseIframe();
205
+ /* eslint-disable-next-line prefer-promise-reject-errors */
206
+ reject("closed");
207
+ };
208
+ let authMessageReceiver = null;
209
+ /* Retrieve token(s) and close login window */
210
+ const fnGetTokenAndFinish = (code) => {
211
+ if (!this.isNode) {
212
+ window.removeEventListener("message", authMessageReceiver, false);
213
+ }
214
+ this.getToken(code).then(token => {
215
+ if (bWinIframe) {
216
+ clearTimeout(tmrAuthComplete);
217
+ fnCloseIframe();
218
+ } else if (!this.isNode) {
219
+ clearInterval(checkWindowClosed);
220
+ myWindow.close();
221
+ }
222
+ resolve(token);
223
+ })
224
+ .catch(e => {
225
+ reject(e);
226
+ });
227
+ };
228
+ // If there is a userIdentifier and password specified or an external SSO auth service,
229
+ // we can try to use this silently in an iFrame first
230
+ if (bWinIframe) {
231
+ const nFrameZLevel = 99999;
232
+ elIframe = document.createElement('iframe');
233
+ elIframe.id = `pe${this.config.clientId}`;
234
+ const loginBoxWidth = 500;
235
+ const loginBoxHeight = 700;
236
+ const oStyle = elIframe.style;
237
+ oStyle.position = 'absolute';
238
+ oStyle.display = 'none';
239
+ oStyle.zIndex = nFrameZLevel;
240
+ oStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2)}px`;
241
+ oStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2)}px`;
242
+ oStyle.width = '500px';
243
+ oStyle.height = '700px';
244
+ // Add Iframe to top of document DOM to have it load
245
+ document.body.insertBefore(elIframe, document.body.firstChild);
246
+ // document.getElementsByTagName('body')[0].appendChild(elIframe);
247
+ elIframe.addEventListener('load', myWinOnLoad, true);
248
+ // Disallow iframe content attempts to navigate main window
249
+ elIframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin');
250
+ // Adding prompt=none as this is standard OIDC way to communicate no UI is expected (expecting Pega security to support this one day)
251
+ elIframe.setAttribute('src', `${url}&prompt=none`);
252
+
253
+ const svgCloseBtn = `<?xml version="1.0" encoding="UTF-8"?>
254
+ <svg width="34px" height="34px" viewBox="0 0 34 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
255
+ <title>Dismiss - Black</title>
256
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
257
+ <g transform="translate(1.000000, 1.000000)">
258
+ <circle fill="#252C32" cx="16" cy="16" r="16"></circle>
259
+ <g transform="translate(9.109375, 9.214844)" fill="#FFFFFF" fill-rule="nonzero">
260
+ <path d="M12.7265625,0 L0,12.6210938 L1.0546875,13.5703125 L13.78125,1.0546875 L12.7265625,0 Z M13.7460938,12.5507812 L1.01953125,0 L0,1.01953125 L12.7617188,13.6054688 L13.7460938,12.5507812 Z"></path>
261
+ </g>
262
+ </g>
263
+ </g>
264
+ </svg>`;
265
+ const bCloseWithinFrame = false;
266
+ elCloseBtn = document.createElement('img');
267
+ elCloseBtn.onclick = fnCloseAndReject;
268
+ elCloseBtn.src = `data:image/svg+xml;base64,${this.#btoa(svgCloseBtn)}`;
269
+ const oBtnStyle = elCloseBtn.style;
270
+ oBtnStyle.cursor = 'pointer';
271
+ // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'
272
+ oBtnStyle.position = 'absolute';
273
+ oBtnStyle.display = 'none';
274
+ oBtnStyle.zIndex = nFrameZLevel + 1;
275
+ const nTopOffset = bCloseWithinFrame ? 5 : -10;
276
+ const nRightOffset = bCloseWithinFrame ? -34 : -20;
277
+ oBtnStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2) + nTopOffset}px`;
278
+ oBtnStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2) + loginBoxWidth + nRightOffset
279
+ }px`;
280
+ document.body.insertBefore(elCloseBtn, document.body.firstChild);
281
+ // If the password was wrong, then the login screen will be in the iframe
282
+ // ..and with Pega without realization of US-372314 it may replace the top (main portal) window
283
+ // For now set a timer and if the timer expires, remove the iFrame and use same url within
284
+ // visible window
285
+ tmrAuthComplete = setTimeout(() => {
286
+ clearTimeout(tmrAuthComplete);
287
+ // remove password from config
288
+ if (this.config.password) {
289
+ delete this.config.password;
290
+ this.#updateConfig();
291
+ }
292
+ // Display the iframe where the redirects did not succeed (or invoke a popup window)
293
+ if (this.config.iframeLoginUI) {
294
+ elIframe.style.display = 'block';
295
+ elCloseBtn.style.display = 'block';
296
+ } else {
297
+ fnCloseIframe();
298
+ fnOpenPopup();
299
+ }
300
+ }, iframeTimeout);
301
+ } else {
302
+ if (this.isNode) {
303
+ // Determine port to listen to by extracting it from redirect uri
304
+ const { redirectUri, cert, key } = this.config;
305
+ const isHttp = redirectUri.startsWith('http:');
306
+ const nLocalhost = redirectUri.indexOf("localhost:");
307
+ const nSlash = redirectUri.indexOf('/', nLocalhost + 10);
308
+ const nPort = parseInt(redirectUri.substring(nLocalhost + 10, nSlash), 10);
309
+ if (nLocalhost !== -1) {
310
+ const options = key && cert && !isHttp ? {
311
+ key: this.fs.readFileSync(key),
312
+ cert: this.fs.readFileSync(cert)
313
+ } : {};
314
+ const server = (isHttp ? this.http : this.https).createServer(options, (req, res) => {
315
+ const { winTitle, winBodyHtml } = this.config;
316
+ // console.log(`HTTP request received: ${req.url}`);
317
+ res.writeHead(200, { 'Content-Type': 'text/html' });
318
+ // Auto closing window for now. Can always leave it up and allow authConfig props to set title and bodyHtml
319
+ res.end(`<html><head><title>${winTitle}</title><script>window.close();</script></head><body>${winBodyHtml}</body></html>`);
320
+ const queryString = req.url.split('?')[1];
321
+ const urlParams = new URLSearchParams(queryString);
322
+ const code = urlParams.get('code');
323
+ if (code) {
324
+ // console.log(`Auth code received: ${code}`);
325
+ // Stop receiving connections and close when all are handled.
326
+ server.close();
327
+ fnGetTokenAndFinish(code);
328
+ }
329
+ });
330
+ /* eslint-enable no-undef */
331
+ server.listen(nPort);
332
+ }
333
+ }
334
+ fnOpenPopup();
335
+ }
336
+
337
+ if (!this.isNode) {
338
+ /* Handler to receive the auth code */
339
+ authMessageReceiver = (event) => {
340
+ // Check origin to make sure it is the redirect origin
341
+ if (event.origin !== redirectOrigin) return;
342
+ if (!event.data || !event.data.type || event.data.type !== 'PegaAuth') return;
343
+ console.log('authjs(login): postMessage received with code');
344
+ const code = event.data.code.toString();
345
+ fnGetTokenAndFinish(code);
346
+ };
347
+ window.addEventListener('message', authMessageReceiver, false);
348
+ window.authCodeCallback = (code) => {
349
+ console.log('authjs(login): authCodeCallback used with code');
350
+ fnGetTokenAndFinish(code);
351
+ };
352
+ }
353
+ });
354
+ });
355
+ }
356
+
357
+ // For PKCE token endpoint includes code_verifier
358
+ /* eslint-disable-next-line sonarjs/cognitive-complexity */
359
+ getToken(authCode) {
360
+ // Reload config to pick up the previously stored codeVerifier
361
+ this.#reloadConfig();
362
+
363
+ const { serverType, isolationId, clientId, clientSecret, redirectUri, tokenUri, codeVerifier, grantType,
364
+ sessionIndex, customTokenParams, userIdentifier, password, noPKCE } = this.config;
365
+
366
+ const bAuthCode = !grantType || grantType === 'authCode';
367
+ if (bAuthCode && !authCode && !this.isNode) {
368
+ const queryString = window.location.search;
369
+ const urlParams = new URLSearchParams(queryString);
370
+ authCode = urlParams.get('code');
371
+ }
372
+
373
+ const formData = new URLSearchParams();
374
+ formData.append('client_id', clientId);
375
+ if (clientSecret) {
376
+ formData.append('client_secret', clientSecret);
377
+ }
378
+ /* eslint-disable camelcase */
379
+ const fullGTName = {
380
+ "authCode": "authorization_code",
381
+ "clientCreds": "client_credentials",
382
+ "customBearer": "custom-bearer",
383
+ "passwordCreds": "password"
384
+ }[grantType];
385
+ const grant_type = fullGTName || grantType || 'authorization_code';
386
+ formData.append('grant_type', grant_type);
387
+ if (serverType === 'launchpad' && grantType !== 'authCode') {
388
+ formData.append('isolation_ids', isolationId);
389
+ }
390
+ if (bAuthCode) {
391
+ formData.append('code', authCode);
392
+ formData.append('redirect_uri', redirectUri);
393
+ if (!noPKCE) {
394
+ formData.append('code_verifier', codeVerifier);
395
+ }
396
+ } else if (sessionIndex) {
397
+ formData.append('session_index', sessionIndex);
398
+ }
399
+ /* eslint-enable camelcase */
400
+ if (grantType === 'customBearer' && customTokenParams) {
401
+ Object.keys(customTokenParams).forEach((param) => {
402
+ formData.append(param, customTokenParams[param]);
403
+ });
404
+ }
405
+ if (grantType === 'passwordCreds') {
406
+ formData.append('username', userIdentifier);
407
+ formData.append('password', this.#atob(password));
408
+ }
409
+
410
+ return fetch(tokenUri, {
411
+ agent: this.#getAgent(),
412
+ method: 'POST',
413
+ headers: new Headers({
414
+ 'content-type': this.urlencoded
415
+ }),
416
+
417
+ body: formData.toString()
418
+ })
419
+ .then((response) => response.json())
420
+ .then((token) => {
421
+ if (token.errors || token.error) {
422
+ // console.log(`formData: ${formData.toString()}`);
423
+ console.log(`Token endpoint error: ${JSON.stringify(token.errors || token.error)}`);
424
+ } else {
425
+ // .expires_in contains the # of seconds before access token expires
426
+ // add property to keep track of current time when the token expires
427
+ token.eA = Date.now() + token.expires_in * 1000;
428
+ if (this.config.codeVerifier) {
429
+ delete this.config.codeVerifier;
430
+ }
431
+ // If there is a session_index then move this to the peConfig structure (as used on authorize)
432
+ if (token.session_index) {
433
+ this.config.sessionIndex = token.session_index;
434
+ }
435
+ // If we got a token and have a session index, then reset the sessionIndexAttempts
436
+ if (this.config.sessionIndex) {
437
+ this.config.sessionIndexAttempts = 0;
438
+ }
439
+ this.#updateConfig();
440
+ }
441
+ return token;
442
+ })
443
+ .catch((e) => {
444
+ console.log(e);
445
+ });
446
+ }
447
+
448
+ /* eslint-disable camelcase */
449
+ async refreshToken(refresh_token) {
450
+ const { clientId, clientSecret, tokenUri } = this.config;
451
+
452
+ if (this.isNode && !this.crypto) {
453
+ // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
454
+ await this.#importNodeLibs();
455
+ }
456
+
457
+ const formData = new URLSearchParams();
458
+ formData.append('client_id', clientId);
459
+ if (clientSecret) {
460
+ formData.append('client_secret', clientSecret);
461
+ }
462
+ formData.append('grant_type', 'refresh_token');
463
+ formData.append('refresh_token', refresh_token);
464
+
465
+ return fetch(tokenUri, {
466
+ agent: this.#getAgent(),
467
+ method: 'POST',
468
+ headers: new Headers({
469
+ 'content-type': this.urlencoded
470
+ }),
471
+
472
+ body: formData.toString()
473
+ })
474
+ .then((response) => {
475
+ if (!response.ok && response.status === 401) {
476
+ return null;
477
+ }
478
+ return response.json();
479
+ })
480
+ .then((token) => {
481
+ if (token) {
482
+ // .expires_in contains the # of seconds before access token expires
483
+ // add property to keep track of current time when the token expires
484
+ token.eA = Date.now() + token.expires_in * 1000;
485
+ }
486
+ return token;
487
+ })
488
+ .catch((e) => {
489
+ console.log(e);
490
+ });
491
+ }
492
+
493
+ async revokeTokens(access_token, refresh_token = null) {
494
+ if (Object.keys(this.config).length === 0) {
495
+ // Must have a config structure to proceed
496
+ return;
497
+ }
498
+ const { clientId, clientSecret, revokeUri } = this.config;
499
+
500
+ if (this.isNode && !this.crypto) {
501
+ // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
502
+ await this.#importNodeLibs();
503
+ }
504
+
505
+ const hdrs = { 'content-type': this.urlencoded };
506
+ if (clientSecret) {
507
+ const basicCreds = window.btoa(`${clientId}:${clientSecret}`);
508
+ hdrs.authorization = `Basic ${basicCreds}`;
509
+ }
510
+ const aTknProps = ['access_token'];
511
+ if (refresh_token) {
512
+ aTknProps.push('refresh_token');
513
+ }
514
+ aTknProps.forEach((prop) => {
515
+ const formData = new URLSearchParams();
516
+ if (!clientSecret) {
517
+ formData.append('client_id', clientId);
518
+ }
519
+ formData.append('token', prop === 'access_token' ? access_token : refresh_token);
520
+ formData.append('token_type_hint', prop);
521
+ fetch(revokeUri, {
522
+ agent: this.#getAgent(),
523
+ method: 'POST',
524
+ headers: new Headers(hdrs),
525
+ body: formData.toString()
526
+ })
527
+ .then((response) => {
528
+ if (!response.ok) {
529
+ console.log(`Error revoking ${prop}:${response.status}`);
530
+ }
531
+ })
532
+ .catch((e) => {
533
+ console.log(e);
534
+ });
535
+ });
536
+ // Also clobber any sessionIndex
537
+ if (this.config.sessionIndex) {
538
+ delete this.config.sessionIndex;
539
+ this.#updateConfig();
540
+ }
541
+ }
542
+ /* eslint-enable camelcase */
543
+
544
+ #sha256Hash(str) {
545
+ // Found that the Node implementation of subtle.digest is yielding incorrect results
546
+ // so using a different set of apis to get expected results.
547
+ if (this.isNode) {
548
+ return new Promise((resolve) => {
549
+ return resolve(this.crypto.createHash("sha256").update(str).digest());
550
+ });
551
+ }
552
+ return this.subtle.digest('SHA-256', new TextEncoder().encode(str));
553
+ }
554
+
555
+ /* btoa to work with node or browser - create B64 string */
556
+ #btoa(str) {
557
+ if (this.isNode) {
558
+ return Buffer.from(str, 'binary').toString('base64');
559
+ }
560
+ return window.btoa(str);
561
+ }
562
+
563
+ /* atoa to work with node or browser - convert B64 to binary */
564
+ #atob(str) {
565
+ if (this.isNode) {
566
+ return Buffer.from(str, 'base64').toString('binary');
567
+ }
568
+ return window.atob(str);
569
+ }
570
+
571
+ // Base64 encode
572
+ #encode64(buff) {
573
+ return this.#btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));
574
+ }
575
+
576
+ /*
577
+ * Base64 url safe encoding of an array
578
+ */
579
+ #base64UrlSafeEncode(buf) {
580
+ return this.#encode64(buf).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
581
+ }
582
+
583
+ /* Calc code verifier if necessary
584
+ */
585
+ /* eslint-disable camelcase */
586
+ async #getCodeChallenge(code_verifier) {
587
+ return this.#sha256Hash(code_verifier)
588
+ .then((hashed) => {
589
+ return this.#base64UrlSafeEncode(hashed);
590
+ })
591
+ .catch((error) => {
592
+ console.log(error);
593
+ })
594
+ .finally(() => {
595
+ return null;
596
+ });
597
+ }
598
+ /* eslint-enable camelcase */
599
+
600
+ /*
601
+ * Return agent value for POST commands
602
+ */
603
+ #getAgent() {
604
+ return this.isNode && this.config.ignoreInvalidCerts ? new this.https.Agent({ rejectUnauthorized: false }) : undefined;
605
+ }
606
+ }
607
+
608
+ export default PegaAuth;
package/src/cli.js CHANGED
@@ -3,11 +3,18 @@ import chalk from 'chalk';
3
3
 
4
4
  import {
5
5
  authenticate,
6
+ buildComponent,
7
+ buildAllComponents,
6
8
  createComponent,
9
+ createAllComponents,
7
10
  deleteComponent,
11
+ deleteAllComponents,
12
+ generateWithAI,
8
13
  initProject,
9
14
  listComponents,
10
15
  publishComponent,
16
+ publishAllComponents,
17
+ renameComponent,
11
18
  updateComponent,
12
19
  validate,
13
20
  upgrade
@@ -16,11 +23,18 @@ import {
16
23
  const TASKS = {
17
24
  INIT: 'init',
18
25
  CREATE: 'create',
26
+ CREATE_ALL: 'createAll',
27
+ BUILD: 'buildComponent',
28
+ BUILD_ALL: 'buildAllComponents',
29
+ GENERATE_WITH_AI: 'generateWithAI',
19
30
  PUBLISH: 'publish',
31
+ PUBLISH_All: 'publishAll',
32
+ RENAME: 'rename',
20
33
  LIST: 'list',
21
34
  VALIDATE_SCHEMA: 'validateSchema',
22
35
  UPDATE: 'update',
23
36
  DELETE: 'delete',
37
+ DELETE_ALL: "deleteAll",
24
38
  AUTHENTICATE: 'authenticate',
25
39
  UPGRADE: 'upgrade'
26
40
  };
@@ -56,10 +70,34 @@ export default async (args = []) => {
56
70
  createComponent(options);
57
71
  break;
58
72
  }
73
+ case TASKS.CREATE_ALL: {
74
+ createAllComponents(options);
75
+ break;
76
+ }
77
+ case TASKS.GENERATE_WITH_AI: {
78
+ generateWithAI(options);
79
+ break;
80
+ }
59
81
  case TASKS.PUBLISH: {
60
82
  publishComponent(options);
61
83
  break;
62
84
  }
85
+ case TASKS.PUBLISH_All: {
86
+ publishAllComponents(options);
87
+ break;
88
+ }
89
+ case TASKS.RENAME: {
90
+ renameComponent(options);
91
+ break;
92
+ }
93
+ case TASKS.BUILD: {
94
+ buildComponent(options);
95
+ break;
96
+ }
97
+ case TASKS.BUILD_ALL: {
98
+ buildAllComponents(options);
99
+ break;
100
+ }
63
101
  case TASKS.LIST: {
64
102
  listComponents(options);
65
103
  break;
@@ -76,6 +114,10 @@ export default async (args = []) => {
76
114
  deleteComponent(options);
77
115
  break;
78
116
  }
117
+ case TASKS.DELETE_ALL: {
118
+ deleteAllComponents(options);
119
+ break;
120
+ }
79
121
  case TASKS.AUTHENTICATE: {
80
122
  authenticate(options);
81
123
  break;