@hcl-software/dxclient 221.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (486) hide show
  1. package/LICENSE +62 -0
  2. package/README.txt +3143 -0
  3. package/bin/dxclient +3 -0
  4. package/dist/LICENSE +62 -0
  5. package/dist/configuration/config.json +52 -0
  6. package/dist/configuration/versionConfigMap.json +34 -0
  7. package/dist/package.json +149 -0
  8. package/dist/packages/admintasks/package-lock.json +21843 -0
  9. package/dist/packages/admintasks/package.json +56 -0
  10. package/dist/packages/admintasks/src/commands/createCredentialVault.d.ts +5 -0
  11. package/dist/packages/admintasks/src/commands/createCredentialVault.js +100 -0
  12. package/dist/packages/admintasks/src/commands/createCredentialVault.js.map +1 -0
  13. package/dist/packages/admintasks/src/commands/createSyndicationRelation.d.ts +4 -0
  14. package/dist/packages/admintasks/src/commands/createSyndicationRelation.js +70 -0
  15. package/dist/packages/admintasks/src/commands/createSyndicationRelation.js.map +1 -0
  16. package/dist/packages/admintasks/src/commands/createVirtualPortal.d.ts +4 -0
  17. package/dist/packages/admintasks/src/commands/createVirtualPortal.js +63 -0
  18. package/dist/packages/admintasks/src/commands/createVirtualPortal.js.map +1 -0
  19. package/dist/packages/admintasks/src/commands/differentialReport.d.ts +6 -0
  20. package/dist/packages/admintasks/src/commands/differentialReport.js +149 -0
  21. package/dist/packages/admintasks/src/commands/differentialReport.js.map +1 -0
  22. package/dist/packages/admintasks/src/commands/exportVirtualPortal.d.ts +4 -0
  23. package/dist/packages/admintasks/src/commands/exportVirtualPortal.js +66 -0
  24. package/dist/packages/admintasks/src/commands/exportVirtualPortal.js.map +1 -0
  25. package/dist/packages/admintasks/src/commands/exportWCMLibrary.d.ts +4 -0
  26. package/dist/packages/admintasks/src/commands/exportWCMLibrary.js +141 -0
  27. package/dist/packages/admintasks/src/commands/exportWCMLibrary.js.map +1 -0
  28. package/dist/packages/admintasks/src/commands/importVirtualPortal.d.ts +4 -0
  29. package/dist/packages/admintasks/src/commands/importVirtualPortal.js +67 -0
  30. package/dist/packages/admintasks/src/commands/importVirtualPortal.js.map +1 -0
  31. package/dist/packages/admintasks/src/commands/importWCMLibrary.d.ts +4 -0
  32. package/dist/packages/admintasks/src/commands/importWCMLibrary.js +112 -0
  33. package/dist/packages/admintasks/src/commands/importWCMLibrary.js.map +1 -0
  34. package/dist/packages/admintasks/src/commands/listVirtualPortals.d.ts +4 -0
  35. package/dist/packages/admintasks/src/commands/listVirtualPortals.js +57 -0
  36. package/dist/packages/admintasks/src/commands/listVirtualPortals.js.map +1 -0
  37. package/dist/packages/admintasks/src/commands/pznRulesExport.d.ts +4 -0
  38. package/dist/packages/admintasks/src/commands/pznRulesExport.js +85 -0
  39. package/dist/packages/admintasks/src/commands/pznRulesExport.js.map +1 -0
  40. package/dist/packages/admintasks/src/commands/pznRulesImport.d.ts +4 -0
  41. package/dist/packages/admintasks/src/commands/pznRulesImport.js +130 -0
  42. package/dist/packages/admintasks/src/commands/pznRulesImport.js.map +1 -0
  43. package/dist/packages/admintasks/src/commands/resEnvProviderActions.d.ts +4 -0
  44. package/dist/packages/admintasks/src/commands/resEnvProviderActions.js +179 -0
  45. package/dist/packages/admintasks/src/commands/resEnvProviderActions.js.map +1 -0
  46. package/dist/packages/admintasks/src/commands/restartCorePods.d.ts +4 -0
  47. package/dist/packages/admintasks/src/commands/restartCorePods.js +45 -0
  48. package/dist/packages/admintasks/src/commands/restartCorePods.js.map +1 -0
  49. package/dist/packages/admintasks/src/commands/restartDXCore.d.ts +4 -0
  50. package/dist/packages/admintasks/src/commands/restartDXCore.js +68 -0
  51. package/dist/packages/admintasks/src/commands/restartDXCore.js.map +1 -0
  52. package/dist/packages/admintasks/src/errors/CommandLineMessages_en.json +62 -0
  53. package/dist/packages/admintasks/src/messages/messages_en.json +34 -0
  54. package/dist/packages/admintasks/src/services/createSyndicationRelationServices.d.ts +4 -0
  55. package/dist/packages/admintasks/src/services/createSyndicationRelationServices.js +53 -0
  56. package/dist/packages/admintasks/src/services/createSyndicationRelationServices.js.map +1 -0
  57. package/dist/packages/admintasks/src/services/differentialReportService.d.ts +5 -0
  58. package/dist/packages/admintasks/src/services/differentialReportService.js +59 -0
  59. package/dist/packages/admintasks/src/services/differentialReportService.js.map +1 -0
  60. package/dist/packages/admintasks/src/services/resEnvProviderService.d.ts +9 -0
  61. package/dist/packages/admintasks/src/services/resEnvProviderService.js +238 -0
  62. package/dist/packages/admintasks/src/services/resEnvProviderService.js.map +1 -0
  63. package/dist/packages/admintasks/src/services/restartCorePodsService.d.ts +4 -0
  64. package/dist/packages/admintasks/src/services/restartCorePodsService.js +45 -0
  65. package/dist/packages/admintasks/src/services/restartCorePodsService.js.map +1 -0
  66. package/dist/packages/admintasks/src/services/restartDXCoreService.d.ts +4 -0
  67. package/dist/packages/admintasks/src/services/restartDXCoreService.js +82 -0
  68. package/dist/packages/admintasks/src/services/restartDXCoreService.js.map +1 -0
  69. package/dist/packages/admintasks/src/services/virtualPortalServices.d.ts +33 -0
  70. package/dist/packages/admintasks/src/services/virtualPortalServices.js +169 -0
  71. package/dist/packages/admintasks/src/services/virtualPortalServices.js.map +1 -0
  72. package/dist/packages/admintasks/src/utils/createCredentialVault.xml +14 -0
  73. package/dist/packages/admintasks/src/utils/differential-report-utils.d.ts +11 -0
  74. package/dist/packages/admintasks/src/utils/differential-report-utils.js +1564 -0
  75. package/dist/packages/admintasks/src/utils/differential-report-utils.js.map +1 -0
  76. package/dist/packages/admintasks/src/utils/differential-report-utils.ts +1651 -0
  77. package/dist/packages/admintasks/src/utils/reportAttributes.properties +179 -0
  78. package/dist/packages/dam/package-lock.json +14605 -0
  79. package/dist/packages/dam/package.json +57 -0
  80. package/dist/packages/dam/src/commands/createSecrets.d.ts +4 -0
  81. package/dist/packages/dam/src/commands/createSecrets.js +61 -0
  82. package/dist/packages/dam/src/commands/createSecrets.js.map +1 -0
  83. package/dist/packages/dam/src/commands/deleteDAMStagingMismatch.d.ts +7 -0
  84. package/dist/packages/dam/src/commands/deleteDAMStagingMismatch.js +50 -0
  85. package/dist/packages/dam/src/commands/deleteDAMStagingMismatch.js.map +1 -0
  86. package/dist/packages/dam/src/commands/deleteSchema.d.ts +4 -0
  87. package/dist/packages/dam/src/commands/deleteSchema.js +80 -0
  88. package/dist/packages/dam/src/commands/deleteSchema.js.map +1 -0
  89. package/dist/packages/dam/src/commands/exportAssets.d.ts +5 -0
  90. package/dist/packages/dam/src/commands/exportAssets.js +106 -0
  91. package/dist/packages/dam/src/commands/exportAssets.js.map +1 -0
  92. package/dist/packages/dam/src/commands/findDAMStagingMismatch.d.ts +7 -0
  93. package/dist/packages/dam/src/commands/findDAMStagingMismatch.js +53 -0
  94. package/dist/packages/dam/src/commands/findDAMStagingMismatch.js.map +1 -0
  95. package/dist/packages/dam/src/commands/importAssets.d.ts +4 -0
  96. package/dist/packages/dam/src/commands/importAssets.js +78 -0
  97. package/dist/packages/dam/src/commands/importAssets.js.map +1 -0
  98. package/dist/packages/dam/src/commands/listSchema.d.ts +4 -0
  99. package/dist/packages/dam/src/commands/listSchema.js +44 -0
  100. package/dist/packages/dam/src/commands/listSchema.js.map +1 -0
  101. package/dist/packages/dam/src/commands/stagingMismatchReport.d.ts +15 -0
  102. package/dist/packages/dam/src/commands/stagingMismatchReport.js +168 -0
  103. package/dist/packages/dam/src/commands/stagingMismatchReport.js.map +1 -0
  104. package/dist/packages/dam/src/commands/stagingResync.d.ts +7 -0
  105. package/dist/packages/dam/src/commands/stagingResync.js +53 -0
  106. package/dist/packages/dam/src/commands/stagingResync.js.map +1 -0
  107. package/dist/packages/dam/src/commands/subscriberDeRegistration.d.ts +4 -0
  108. package/dist/packages/dam/src/commands/subscriberDeRegistration.js +45 -0
  109. package/dist/packages/dam/src/commands/subscriberDeRegistration.js.map +1 -0
  110. package/dist/packages/dam/src/commands/subscriberDetails.d.ts +9 -0
  111. package/dist/packages/dam/src/commands/subscriberDetails.js +50 -0
  112. package/dist/packages/dam/src/commands/subscriberDetails.js.map +1 -0
  113. package/dist/packages/dam/src/commands/subscriberRegistration.d.ts +9 -0
  114. package/dist/packages/dam/src/commands/subscriberRegistration.js +62 -0
  115. package/dist/packages/dam/src/commands/subscriberRegistration.js.map +1 -0
  116. package/dist/packages/dam/src/commands/triggerDAMStaging.d.ts +4 -0
  117. package/dist/packages/dam/src/commands/triggerDAMStaging.js +45 -0
  118. package/dist/packages/dam/src/commands/triggerDAMStaging.js.map +1 -0
  119. package/dist/packages/dam/src/commands/triggerDamReindexing.d.ts +4 -0
  120. package/dist/packages/dam/src/commands/triggerDamReindexing.js +54 -0
  121. package/dist/packages/dam/src/commands/triggerDamReindexing.js.map +1 -0
  122. package/dist/packages/dam/src/commands/updateSecrets.d.ts +4 -0
  123. package/dist/packages/dam/src/commands/updateSecrets.js +61 -0
  124. package/dist/packages/dam/src/commands/updateSecrets.js.map +1 -0
  125. package/dist/packages/dam/src/commands/validateAssets.d.ts +4 -0
  126. package/dist/packages/dam/src/commands/validateAssets.js +64 -0
  127. package/dist/packages/dam/src/commands/validateAssets.js.map +1 -0
  128. package/dist/packages/dam/src/errors/CommandLineMessages_en.json +80 -0
  129. package/dist/packages/dam/src/export/collection.d.ts +10 -0
  130. package/dist/packages/dam/src/export/collection.js +291 -0
  131. package/dist/packages/dam/src/export/collection.js.map +1 -0
  132. package/dist/packages/dam/src/export/favorite.d.ts +2 -0
  133. package/dist/packages/dam/src/export/favorite.js +61 -0
  134. package/dist/packages/dam/src/export/favorite.js.map +1 -0
  135. package/dist/packages/dam/src/export/media-item.d.ts +6 -0
  136. package/dist/packages/dam/src/export/media-item.js +193 -0
  137. package/dist/packages/dam/src/export/media-item.js.map +1 -0
  138. package/dist/packages/dam/src/export/media-type-group.d.ts +2 -0
  139. package/dist/packages/dam/src/export/media-type-group.js +43 -0
  140. package/dist/packages/dam/src/export/media-type-group.js.map +1 -0
  141. package/dist/packages/dam/src/export/media-type.d.ts +2 -0
  142. package/dist/packages/dam/src/export/media-type.js +43 -0
  143. package/dist/packages/dam/src/export/media-type.js.map +1 -0
  144. package/dist/packages/dam/src/export/renditions.d.ts +8 -0
  145. package/dist/packages/dam/src/export/renditions.js +255 -0
  146. package/dist/packages/dam/src/export/renditions.js.map +1 -0
  147. package/dist/packages/dam/src/import/collection.d.ts +5 -0
  148. package/dist/packages/dam/src/import/collection.js +148 -0
  149. package/dist/packages/dam/src/import/collection.js.map +1 -0
  150. package/dist/packages/dam/src/import/favorite.d.ts +2 -0
  151. package/dist/packages/dam/src/import/favorite.js +65 -0
  152. package/dist/packages/dam/src/import/favorite.js.map +1 -0
  153. package/dist/packages/dam/src/import/media-items.d.ts +5 -0
  154. package/dist/packages/dam/src/import/media-items.js +182 -0
  155. package/dist/packages/dam/src/import/media-items.js.map +1 -0
  156. package/dist/packages/dam/src/import/media-type-group.d.ts +2 -0
  157. package/dist/packages/dam/src/import/media-type-group.js +68 -0
  158. package/dist/packages/dam/src/import/media-type-group.js.map +1 -0
  159. package/dist/packages/dam/src/import/media-type.d.ts +2 -0
  160. package/dist/packages/dam/src/import/media-type.js +71 -0
  161. package/dist/packages/dam/src/import/media-type.js.map +1 -0
  162. package/dist/packages/dam/src/import/permission.d.ts +5 -0
  163. package/dist/packages/dam/src/import/permission.js +96 -0
  164. package/dist/packages/dam/src/import/permission.js.map +1 -0
  165. package/dist/packages/dam/src/import/renditions.d.ts +9 -0
  166. package/dist/packages/dam/src/import/renditions.js +326 -0
  167. package/dist/packages/dam/src/import/renditions.js.map +1 -0
  168. package/dist/packages/dam/src/messages/messages_en.json +19 -0
  169. package/dist/packages/dam/src/services/authService.d.ts +5 -0
  170. package/dist/packages/dam/src/services/authService.js +55 -0
  171. package/dist/packages/dam/src/services/authService.js.map +1 -0
  172. package/dist/packages/dam/src/services/stagingService.d.ts +37 -0
  173. package/dist/packages/dam/src/services/stagingService.js +440 -0
  174. package/dist/packages/dam/src/services/stagingService.js.map +1 -0
  175. package/dist/packages/dam/src/services/tokenCache.d.ts +8 -0
  176. package/dist/packages/dam/src/services/tokenCache.js +68 -0
  177. package/dist/packages/dam/src/services/tokenCache.js.map +1 -0
  178. package/dist/packages/dam/src/utils/constants.d.ts +70 -0
  179. package/dist/packages/dam/src/utils/constants.js +76 -0
  180. package/dist/packages/dam/src/utils/constants.js.map +1 -0
  181. package/dist/packages/dam/src/utils/interfaces/collection.d.ts +46 -0
  182. package/dist/packages/dam/src/utils/interfaces/collection.js +3 -0
  183. package/dist/packages/dam/src/utils/interfaces/collection.js.map +1 -0
  184. package/dist/packages/dam/src/utils/interfaces/favorite-request.d.ts +6 -0
  185. package/dist/packages/dam/src/utils/interfaces/favorite-request.js +3 -0
  186. package/dist/packages/dam/src/utils/interfaces/favorite-request.js.map +1 -0
  187. package/dist/packages/dam/src/utils/interfaces/media-request.d.ts +54 -0
  188. package/dist/packages/dam/src/utils/interfaces/media-request.js +3 -0
  189. package/dist/packages/dam/src/utils/interfaces/media-request.js.map +1 -0
  190. package/dist/packages/dam/src/utils/interfaces/media-type-group.d.ts +8 -0
  191. package/dist/packages/dam/src/utils/interfaces/media-type-group.js +3 -0
  192. package/dist/packages/dam/src/utils/interfaces/media-type-group.js.map +1 -0
  193. package/dist/packages/dam/src/utils/interfaces/media-type.d.ts +11 -0
  194. package/dist/packages/dam/src/utils/interfaces/media-type.js +3 -0
  195. package/dist/packages/dam/src/utils/interfaces/media-type.js.map +1 -0
  196. package/dist/packages/dam/src/utils/interfaces/media.d.ts +118 -0
  197. package/dist/packages/dam/src/utils/interfaces/media.js +3 -0
  198. package/dist/packages/dam/src/utils/interfaces/media.js.map +1 -0
  199. package/dist/packages/dam/src/utils/service.d.ts +8 -0
  200. package/dist/packages/dam/src/utils/service.js +126 -0
  201. package/dist/packages/dam/src/utils/service.js.map +1 -0
  202. package/dist/packages/dam/src/validation/collection-list-validate.d.ts +2 -0
  203. package/dist/packages/dam/src/validation/collection-list-validate.js +81 -0
  204. package/dist/packages/dam/src/validation/collection-list-validate.js.map +1 -0
  205. package/dist/packages/dam/src/validation/media-list-validate.d.ts +2 -0
  206. package/dist/packages/dam/src/validation/media-list-validate.js +91 -0
  207. package/dist/packages/dam/src/validation/media-list-validate.js.map +1 -0
  208. package/dist/packages/dam/src/validation/media-type-group-validate.d.ts +1 -0
  209. package/dist/packages/dam/src/validation/media-type-group-validate.js +28 -0
  210. package/dist/packages/dam/src/validation/media-type-group-validate.js.map +1 -0
  211. package/dist/packages/dam/src/validation/media-type-validate.d.ts +1 -0
  212. package/dist/packages/dam/src/validation/media-type-validate.js +28 -0
  213. package/dist/packages/dam/src/validation/media-type-validate.js.map +1 -0
  214. package/dist/packages/dam/src/validation/root-validate.d.ts +1 -0
  215. package/dist/packages/dam/src/validation/root-validate.js +42 -0
  216. package/dist/packages/dam/src/validation/root-validate.js.map +1 -0
  217. package/dist/packages/dam/src/validation/validate.rendition.d.ts +1 -0
  218. package/dist/packages/dam/src/validation/validate.rendition.js +69 -0
  219. package/dist/packages/dam/src/validation/validate.rendition.js.map +1 -0
  220. package/dist/packages/dam/src/validation/validate.versions.d.ts +1 -0
  221. package/dist/packages/dam/src/validation/validate.versions.js +67 -0
  222. package/dist/packages/dam/src/validation/validate.versions.js.map +1 -0
  223. package/dist/packages/deployportlet/package-lock.json +20575 -0
  224. package/dist/packages/deployportlet/package.json +51 -0
  225. package/dist/packages/deployportlet/src/commands/deployPortlet.d.ts +4 -0
  226. package/dist/packages/deployportlet/src/commands/deployPortlet.js +99 -0
  227. package/dist/packages/deployportlet/src/commands/deployPortlet.js.map +1 -0
  228. package/dist/packages/deployportlet/src/commands/undeployPortlet.d.ts +4 -0
  229. package/dist/packages/deployportlet/src/commands/undeployPortlet.js +118 -0
  230. package/dist/packages/deployportlet/src/commands/undeployPortlet.js.map +1 -0
  231. package/dist/packages/deployportlet/src/commands/xmlaccess.d.ts +4 -0
  232. package/dist/packages/deployportlet/src/commands/xmlaccess.js +37 -0
  233. package/dist/packages/deployportlet/src/commands/xmlaccess.js.map +1 -0
  234. package/dist/packages/deployportlet/src/errors/CommandLineMessages_en.json +5 -0
  235. package/dist/packages/deployportlet/src/messages/messages_en.json +10 -0
  236. package/dist/packages/deployportlet/src/services/undeployPortletServices.d.ts +4 -0
  237. package/dist/packages/deployportlet/src/services/undeployPortletServices.js +92 -0
  238. package/dist/packages/deployportlet/src/services/undeployPortletServices.js.map +1 -0
  239. package/dist/packages/deployscriptapplication/package-lock.json +20758 -0
  240. package/dist/packages/deployscriptapplication/package.json +48 -0
  241. package/dist/packages/deployscriptapplication/src/commands/list.js +109 -0
  242. package/dist/packages/deployscriptapplication/src/commands/pull.d.ts +6 -0
  243. package/dist/packages/deployscriptapplication/src/commands/pull.js +195 -0
  244. package/dist/packages/deployscriptapplication/src/commands/pull.js.map +1 -0
  245. package/dist/packages/deployscriptapplication/src/commands/push.d.ts +9 -0
  246. package/dist/packages/deployscriptapplication/src/commands/push.js +282 -0
  247. package/dist/packages/deployscriptapplication/src/commands/push.js.map +1 -0
  248. package/dist/packages/deployscriptapplication/src/commands/restoreScriptApplication.d.ts +5 -0
  249. package/dist/packages/deployscriptapplication/src/commands/restoreScriptApplication.js +125 -0
  250. package/dist/packages/deployscriptapplication/src/commands/restoreScriptApplication.js.map +1 -0
  251. package/dist/packages/deployscriptapplication/src/commands/undeployScriptApplication.d.ts +5 -0
  252. package/dist/packages/deployscriptapplication/src/commands/undeployScriptApplication.js +162 -0
  253. package/dist/packages/deployscriptapplication/src/commands/undeployScriptApplication.js.map +1 -0
  254. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages.properties +211 -0
  255. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ar.properties +211 -0
  256. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ca.properties +211 -0
  257. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_cs.properties +211 -0
  258. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_da.properties +211 -0
  259. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_de.properties +211 -0
  260. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_el.properties +211 -0
  261. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_en.json +129 -0
  262. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_en.properties +211 -0
  263. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_es.properties +211 -0
  264. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_fi.properties +211 -0
  265. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_fr.properties +211 -0
  266. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_hr.properties +211 -0
  267. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_hu.properties +211 -0
  268. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_it.properties +212 -0
  269. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_iw.properties +211 -0
  270. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ja.properties +211 -0
  271. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_kk.properties +211 -0
  272. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ko.properties +211 -0
  273. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_nl.properties +211 -0
  274. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_no.properties +211 -0
  275. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_pl.properties +211 -0
  276. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_pt.properties +211 -0
  277. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_pt_BR.properties +211 -0
  278. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ro.properties +211 -0
  279. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_ru.properties +211 -0
  280. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_sk.properties +211 -0
  281. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_sl.properties +211 -0
  282. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_sv.properties +211 -0
  283. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_th.properties +211 -0
  284. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_tr.properties +211 -0
  285. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_uk.properties +211 -0
  286. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_zh.properties +210 -0
  287. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_zh_TW.properties +211 -0
  288. package/dist/packages/deployscriptapplication/src/messages/messages.properties +63 -0
  289. package/dist/packages/deployscriptapplication/src/messages/messages_ar.properties +63 -0
  290. package/dist/packages/deployscriptapplication/src/messages/messages_ca.properties +63 -0
  291. package/dist/packages/deployscriptapplication/src/messages/messages_cs.properties +63 -0
  292. package/dist/packages/deployscriptapplication/src/messages/messages_da.properties +63 -0
  293. package/dist/packages/deployscriptapplication/src/messages/messages_de.properties +63 -0
  294. package/dist/packages/deployscriptapplication/src/messages/messages_el.properties +63 -0
  295. package/dist/packages/deployscriptapplication/src/messages/messages_en.json +61 -0
  296. package/dist/packages/deployscriptapplication/src/messages/messages_en.properties +63 -0
  297. package/dist/packages/deployscriptapplication/src/messages/messages_es.properties +63 -0
  298. package/dist/packages/deployscriptapplication/src/messages/messages_fi.properties +63 -0
  299. package/dist/packages/deployscriptapplication/src/messages/messages_fr.properties +63 -0
  300. package/dist/packages/deployscriptapplication/src/messages/messages_hr.properties +63 -0
  301. package/dist/packages/deployscriptapplication/src/messages/messages_hu.properties +63 -0
  302. package/dist/packages/deployscriptapplication/src/messages/messages_it.properties +63 -0
  303. package/dist/packages/deployscriptapplication/src/messages/messages_iw.properties +63 -0
  304. package/dist/packages/deployscriptapplication/src/messages/messages_ja.properties +63 -0
  305. package/dist/packages/deployscriptapplication/src/messages/messages_kk.properties +63 -0
  306. package/dist/packages/deployscriptapplication/src/messages/messages_ko.properties +63 -0
  307. package/dist/packages/deployscriptapplication/src/messages/messages_nl.properties +63 -0
  308. package/dist/packages/deployscriptapplication/src/messages/messages_no.properties +63 -0
  309. package/dist/packages/deployscriptapplication/src/messages/messages_pl.properties +63 -0
  310. package/dist/packages/deployscriptapplication/src/messages/messages_pt.properties +63 -0
  311. package/dist/packages/deployscriptapplication/src/messages/messages_pt_BR.properties +63 -0
  312. package/dist/packages/deployscriptapplication/src/messages/messages_ro.properties +63 -0
  313. package/dist/packages/deployscriptapplication/src/messages/messages_ru.properties +63 -0
  314. package/dist/packages/deployscriptapplication/src/messages/messages_sk.properties +63 -0
  315. package/dist/packages/deployscriptapplication/src/messages/messages_sl.properties +63 -0
  316. package/dist/packages/deployscriptapplication/src/messages/messages_sv.properties +63 -0
  317. package/dist/packages/deployscriptapplication/src/messages/messages_th.properties +63 -0
  318. package/dist/packages/deployscriptapplication/src/messages/messages_tr.properties +63 -0
  319. package/dist/packages/deployscriptapplication/src/messages/messages_uk.properties +63 -0
  320. package/dist/packages/deployscriptapplication/src/messages/messages_zh.properties +67 -0
  321. package/dist/packages/deployscriptapplication/src/messages/messages_zh_TW.properties +67 -0
  322. package/dist/packages/deployscriptapplication/src/util/constants.d.ts +74 -0
  323. package/dist/packages/deployscriptapplication/src/util/constants.js +98 -0
  324. package/dist/packages/deployscriptapplication/src/util/constants.js.map +1 -0
  325. package/dist/packages/deployscriptapplication/src/util/generic.d.ts +2 -0
  326. package/dist/packages/deployscriptapplication/src/util/generic.js +29 -0
  327. package/dist/packages/deployscriptapplication/src/util/generic.js.map +1 -0
  328. package/dist/packages/deploytheme/package-lock.json +21204 -0
  329. package/dist/packages/deploytheme/package.json +56 -0
  330. package/dist/packages/deploytheme/src/commands/deployApplication.d.ts +4 -0
  331. package/dist/packages/deploytheme/src/commands/deployApplication.js +115 -0
  332. package/dist/packages/deploytheme/src/commands/deployApplication.js.map +1 -0
  333. package/dist/packages/deploytheme/src/commands/deployTheme.d.ts +7 -0
  334. package/dist/packages/deploytheme/src/commands/deployTheme.js +286 -0
  335. package/dist/packages/deploytheme/src/commands/deployTheme.js.map +1 -0
  336. package/dist/packages/deploytheme/src/commands/undeployApplication.d.ts +4 -0
  337. package/dist/packages/deploytheme/src/commands/undeployApplication.js +46 -0
  338. package/dist/packages/deploytheme/src/commands/undeployApplication.js.map +1 -0
  339. package/dist/packages/deploytheme/src/commands/undeployTheme.d.ts +10 -0
  340. package/dist/packages/deploytheme/src/commands/undeployTheme.js +288 -0
  341. package/dist/packages/deploytheme/src/commands/undeployTheme.js.map +1 -0
  342. package/dist/packages/deploytheme/src/errors/CommandLineMessages_en.json +28 -0
  343. package/dist/packages/deploytheme/src/messages/messages_en.json +30 -0
  344. package/dist/packages/deploytheme/src/services/themeServices.d.ts +15 -0
  345. package/dist/packages/deploytheme/src/services/themeServices.js +413 -0
  346. package/dist/packages/deploytheme/src/services/themeServices.js.map +1 -0
  347. package/dist/packages/deploytheme/src/utils/Export.xml +28 -0
  348. package/dist/packages/livesync/package-lock.json +9737 -0
  349. package/dist/packages/livesync/package.json +49 -0
  350. package/dist/packages/livesync/src/commands/pullTheme.d.ts +5 -0
  351. package/dist/packages/livesync/src/commands/pullTheme.js +104 -0
  352. package/dist/packages/livesync/src/commands/pullTheme.js.map +1 -0
  353. package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.d.ts +18 -0
  354. package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js +193 -0
  355. package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js.map +1 -0
  356. package/dist/packages/livesync/src/commands/pushTheme.d.ts +12 -0
  357. package/dist/packages/livesync/src/commands/pushTheme.js +233 -0
  358. package/dist/packages/livesync/src/commands/pushTheme.js.map +1 -0
  359. package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.d.ts +4 -0
  360. package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.js +23 -0
  361. package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.js.map +1 -0
  362. package/dist/packages/livesync/src/errors/CommandLineMessages_en.json +52 -0
  363. package/dist/packages/livesync/src/messages/messages_en.json +33 -0
  364. package/dist/packages/livesync/src/services/EventsQueue.d.ts +12 -0
  365. package/dist/packages/livesync/src/services/EventsQueue.js +66 -0
  366. package/dist/packages/livesync/src/services/EventsQueue.js.map +1 -0
  367. package/dist/packages/livesync/src/services/foldersWcmServices.d.ts +7 -0
  368. package/dist/packages/livesync/src/services/foldersWcmServices.js +120 -0
  369. package/dist/packages/livesync/src/services/foldersWcmServices.js.map +1 -0
  370. package/dist/packages/livesync/src/services/htmlComponentWcmServices.d.ts +6 -0
  371. package/dist/packages/livesync/src/services/htmlComponentWcmServices.js +108 -0
  372. package/dist/packages/livesync/src/services/htmlComponentWcmServices.js.map +1 -0
  373. package/dist/packages/livesync/src/services/initialSyncServices.d.ts +3 -0
  374. package/dist/packages/livesync/src/services/initialSyncServices.js +94 -0
  375. package/dist/packages/livesync/src/services/initialSyncServices.js.map +1 -0
  376. package/dist/packages/livesync/src/services/livesyncUtils.d.ts +2 -0
  377. package/dist/packages/livesync/src/services/livesyncUtils.js +59 -0
  378. package/dist/packages/livesync/src/services/livesyncUtils.js.map +1 -0
  379. package/dist/packages/livesync/src/services/metadataServices.d.ts +16 -0
  380. package/dist/packages/livesync/src/services/metadataServices.js +117 -0
  381. package/dist/packages/livesync/src/services/metadataServices.js.map +1 -0
  382. package/dist/packages/livesync/src/services/ongoingSyncServices.d.ts +10 -0
  383. package/dist/packages/livesync/src/services/ongoingSyncServices.js +266 -0
  384. package/dist/packages/livesync/src/services/ongoingSyncServices.js.map +1 -0
  385. package/dist/packages/livesync/src/services/wcmRestV2Services.d.ts +5 -0
  386. package/dist/packages/livesync/src/services/wcmRestV2Services.js +92 -0
  387. package/dist/packages/livesync/src/services/wcmRestV2Services.js.map +1 -0
  388. package/dist/packages/livesync/src/types/EventHandler.type.d.ts +5 -0
  389. package/dist/packages/livesync/src/types/EventHandler.type.js +3 -0
  390. package/dist/packages/livesync/src/types/EventHandler.type.js.map +1 -0
  391. package/dist/packages/livesync/src/types/EventQueueItem.type.d.ts +7 -0
  392. package/dist/packages/livesync/src/types/EventQueueItem.type.js +3 -0
  393. package/dist/packages/livesync/src/types/EventQueueItem.type.js.map +1 -0
  394. package/dist/packages/livesync/src/types/OngoingSyncHooks.type.d.ts +4 -0
  395. package/dist/packages/livesync/src/types/OngoingSyncHooks.type.js +3 -0
  396. package/dist/packages/livesync/src/types/OngoingSyncHooks.type.js.map +1 -0
  397. package/dist/packages/livesync/src/types/WcmRestApiV2.type.d.ts +99 -0
  398. package/dist/packages/livesync/src/types/WcmRestApiV2.type.js +3 -0
  399. package/dist/packages/livesync/src/types/WcmRestApiV2.type.js.map +1 -0
  400. package/dist/packages/livesync/src/types/index.d.ts +4 -0
  401. package/dist/packages/livesync/src/types/index.js +17 -0
  402. package/dist/packages/livesync/src/types/index.js.map +1 -0
  403. package/dist/packages/mls_exim/package-lock.json +13855 -0
  404. package/dist/packages/mls_exim/package.json +51 -0
  405. package/dist/packages/mls_exim/src/errors/CommandLineMessages_en.json +19 -0
  406. package/dist/packages/mls_exim/src/export/mlsExport.d.ts +7 -0
  407. package/dist/packages/mls_exim/src/export/mlsExport.js +292 -0
  408. package/dist/packages/mls_exim/src/export/mlsExport.js.map +1 -0
  409. package/dist/packages/mls_exim/src/export/mlsExport.ts +371 -0
  410. package/dist/packages/mls_exim/src/import/mlsImport.d.ts +8 -0
  411. package/dist/packages/mls_exim/src/import/mlsImport.js +104 -0
  412. package/dist/packages/mls_exim/src/import/mlsImport.js.map +1 -0
  413. package/dist/packages/mls_exim/src/import/mlsImport.ts +138 -0
  414. package/dist/packages/mls_exim/src/messages/messages_en.json +14 -0
  415. package/dist/packages/mls_exim/src/utils/interfaces/export.d.ts +133 -0
  416. package/dist/packages/mls_exim/src/utils/interfaces/export.js +3 -0
  417. package/dist/packages/mls_exim/src/utils/interfaces/export.js.map +1 -0
  418. package/dist/packages/mls_exim/src/utils/interfaces/export.ts +165 -0
  419. package/dist/packages/mls_exim/src/utils/interfaces/import.d.ts +52 -0
  420. package/dist/packages/mls_exim/src/utils/interfaces/import.js +3 -0
  421. package/dist/packages/mls_exim/src/utils/interfaces/import.js.map +1 -0
  422. package/dist/packages/mls_exim/src/utils/interfaces/import.ts +76 -0
  423. package/dist/packages/sharedlibrary/package-lock.json +20575 -0
  424. package/dist/packages/sharedlibrary/package.json +51 -0
  425. package/dist/packages/sharedlibrary/src/commands/delete.d.ts +4 -0
  426. package/dist/packages/sharedlibrary/src/commands/delete.js +64 -0
  427. package/dist/packages/sharedlibrary/src/commands/delete.js.map +1 -0
  428. package/dist/packages/sharedlibrary/src/commands/upload.d.ts +4 -0
  429. package/dist/packages/sharedlibrary/src/commands/upload.js +105 -0
  430. package/dist/packages/sharedlibrary/src/commands/upload.js.map +1 -0
  431. package/dist/packages/sharedlibrary/src/errors/CommandLineMessages_en.json +10 -0
  432. package/dist/packages/sharedlibrary/src/messages/messages_en.json +7 -0
  433. package/dist/packages/sharedlibrary/src/services/sharedLibraryServices.d.ts +5 -0
  434. package/dist/packages/sharedlibrary/src/services/sharedLibraryServices.js +100 -0
  435. package/dist/packages/sharedlibrary/src/services/sharedLibraryServices.js.map +1 -0
  436. package/dist/packages/syndication/package-lock.json +20575 -0
  437. package/dist/packages/syndication/package.json +51 -0
  438. package/dist/packages/syndication/src/commands/subscriber.d.ts +4 -0
  439. package/dist/packages/syndication/src/commands/subscriber.js +62 -0
  440. package/dist/packages/syndication/src/commands/subscriber.js.map +1 -0
  441. package/dist/packages/syndication/src/commands/syndicationReport.d.ts +2 -0
  442. package/dist/packages/syndication/src/commands/syndicationReport.js +99 -0
  443. package/dist/packages/syndication/src/commands/syndicationReport.js.map +1 -0
  444. package/dist/packages/syndication/src/commands/syndicator.d.ts +4 -0
  445. package/dist/packages/syndication/src/commands/syndicator.js +62 -0
  446. package/dist/packages/syndication/src/commands/syndicator.js.map +1 -0
  447. package/dist/packages/syndication/src/commands/syndicatorFailedItem.d.ts +4 -0
  448. package/dist/packages/syndication/src/commands/syndicatorFailedItem.js +104 -0
  449. package/dist/packages/syndication/src/commands/syndicatorFailedItem.js.map +1 -0
  450. package/dist/packages/syndication/src/errors/CommandLineMessages_en.json +12 -0
  451. package/dist/packages/syndication/src/messages/messages_en.json +9 -0
  452. package/dist/packages/syndication/src/services/syndicationService.d.ts +108 -0
  453. package/dist/packages/syndication/src/services/syndicationService.js +167 -0
  454. package/dist/packages/syndication/src/services/syndicationService.js.map +1 -0
  455. package/dist/src/errors/CommandLineMessages_en.json +53 -0
  456. package/dist/src/index.d.ts +1 -0
  457. package/dist/src/index.js +2207 -0
  458. package/dist/src/index.js.map +1 -0
  459. package/dist/src/services/apiServices.d.ts +32 -0
  460. package/dist/src/services/apiServices.js +932 -0
  461. package/dist/src/services/apiServices.js.map +1 -0
  462. package/dist/src/services/filesServices.d.ts +9 -0
  463. package/dist/src/services/filesServices.js +134 -0
  464. package/dist/src/services/filesServices.js.map +1 -0
  465. package/dist/src/services/requestService.d.ts +4 -0
  466. package/dist/src/services/requestService.js +55 -0
  467. package/dist/src/services/requestService.js.map +1 -0
  468. package/dist/src/utils/commands.d.ts +2 -0
  469. package/dist/src/utils/commands.js +13 -0
  470. package/dist/src/utils/commands.js.map +1 -0
  471. package/dist/src/utils/constants.d.ts +389 -0
  472. package/dist/src/utils/constants.js +464 -0
  473. package/dist/src/utils/constants.js.map +1 -0
  474. package/dist/src/utils/interfaces.d.ts +19 -0
  475. package/dist/src/utils/interfaces.js +3 -0
  476. package/dist/src/utils/interfaces.js.map +1 -0
  477. package/dist/src/utils/logger.d.ts +3 -0
  478. package/dist/src/utils/logger.js +126 -0
  479. package/dist/src/utils/logger.js.map +1 -0
  480. package/dist/src/utils/utils.d.ts +31 -0
  481. package/dist/src/utils/utils.js +791 -0
  482. package/dist/src/utils/utils.js.map +1 -0
  483. package/dist/src/utils/validateOptions.d.ts +4 -0
  484. package/dist/src/utils/validateOptions.js +730 -0
  485. package/dist/src/utils/validateOptions.js.map +1 -0
  486. package/package.json +149 -0
@@ -0,0 +1,371 @@
1
+ /*
2
+ ********************************************************************
3
+ * Licensed Materials - Property of HCL *
4
+ * *
5
+ * Copyright HCL Technologies Ltd. 2024. All Rights Reserved. *
6
+ * *
7
+ * Note to US Government Users Restricted Rights: *
8
+ * *
9
+ * Use, duplication or disclosure restricted by GSA ADP Schedule *
10
+ ********************************************************************
11
+ */
12
+ import commander from 'commander';
13
+ import path from 'path';
14
+ import fs, {
15
+ existsSync, mkdirSync, statSync,
16
+ } from 'fs';
17
+ import { createObjectCsvWriter } from 'csv-writer';
18
+ import { filter, includes, find } from 'lodash';
19
+ import { logger } from '../../../../src/utils/logger';
20
+ import { apiServices } from '../../../../src/services/apiServices';
21
+
22
+ import {
23
+ CONTENT_ELEMENT_TYPE,
24
+ defaultExportPath,
25
+ URL_PATH,
26
+ WCMElementTypes,
27
+ WCM_TYPE,
28
+ CONTENT_INFORMATION_TYPE,
29
+ CONTENT_TITLE_TYPE,
30
+ CONTENT_DESCRIPTION_TYPE,
31
+ } from '../../../../src/utils/constants';
32
+ import { ICSVFileContents, IMLSTranslations, IWCMLibrary } from '../utils/interfaces/export';
33
+ import {
34
+ errorMessage, getBaseDXUrlFromCommand, getStoreDir, message,
35
+ } from '../../../../src/utils/utils';
36
+
37
+ const MLS_CSV_HEADERS = [{ id: 'source', title: 'source' }, { id: 'target', title: 'target' }, { id: 'sourceUUID', title: 'sourceUUID' },
38
+ { id: 'targetUUID', title: 'targetUUID' }, { id: 'sourceLanguage', title: 'sourceLanguage' }, { id: 'targetLanguage', title: 'targetLanguage' },
39
+ { id: 'field', title: 'field' }, { id: 'type', title: 'type' }, { id: 'wcmType', title: 'wcmType' }, { id: 'componentType', title: 'componentType' },
40
+ { id: 'fieldLimit', title: 'fieldLimit' }, { id: 'previewLink', title: 'previewLink' }, { id: 'lastModifiedOfSource', title: 'lastModifiedOfSource' },
41
+ { id: 'lastModifiedOfTarget', title: 'lastModifiedOfTarget' }];
42
+
43
+ /**
44
+ * Returns the csv file path where the contents are to be exported.
45
+ * @param {string} exportPath Path where the contents have to be exported.
46
+ * @param {string} wcmQueryParam WCM library id or WCM project name used as query parameter.
47
+ * @returns {string} CSV file path.
48
+ */
49
+ const getFilePath = async (exportPath: string, wcmQueryParam: string): Promise<string> => {
50
+ if (!existsSync(exportPath) || !statSync(exportPath).isDirectory()) {
51
+ logger.debug('Export path provided is not a directory path: %s', exportPath);
52
+ logger.error(errorMessage('ERROR_INVALID_EXPORT_PATH'));
53
+ return '';
54
+ }
55
+
56
+ const filePath = `${exportPath}/mls_${wcmQueryParam}_${new Date().getTime()}.csv`;
57
+ logger.debug('CSV file path to export - %s.', filePath);
58
+ return filePath;
59
+ };
60
+
61
+ /**
62
+ * Returns the preview link for the specified content.
63
+ * @param {commander.Command} cmdArgs Argument which will be used for processing the exporting the wcm contents.
64
+ * Contains export path, WCM library id and DX API configuration.
65
+ * @param {string} contentId Content ID for which the preview link url has to be generated.
66
+ * @returns {string} Preview link for the specofied content.
67
+ */
68
+ const getPreviewLinkUrl = (cmdArgs: commander.Command, contentId: string): string => {
69
+ const contenthandlerPath = cmdArgs.contenthandlerPath.split('/');
70
+ // Content root will be the first parameter of the contenthandlerPath array if the length of the array is more than 2.
71
+ // Content root will be empty string in case of no context root and contenthandlerPath array will be 2.
72
+ const contextRoot = (contenthandlerPath.length > 2) ? `/${contenthandlerPath[1]}/` : '/';
73
+ return `${cmdArgs.dxProtocol}://${cmdArgs.hostname}:${cmdArgs.dxPort}${contextRoot}mypoc/${cmdArgs.virtualPortalContext}wcm/oid:${contentId}`;
74
+ };
75
+
76
+ /**
77
+ * This function is used to write the source contents into CSV file.
78
+ * @param {string} csvFilePath CSV file path to export.
79
+ * @param {Array} mlsTranslationData MLS translation contents to write into csv file.
80
+ * @param {commander.Command} cmdArgs Argument which will be used for processing the exporting the wcm contents.
81
+ * Contains export path, WCM library id and DX API configuration.
82
+ */
83
+ export const writeContents = async (csvFilePath: string, mlsTranslationData: IMLSTranslations[], cmdArgs: commander.Command) => {
84
+ try {
85
+ logger.debug('Entered to insert contents into CSV file, CSV file path - %s.', csvFilePath);
86
+ const csvWriterData = createObjectCsvWriter({
87
+ path: `${csvFilePath}`,
88
+ header: MLS_CSV_HEADERS,
89
+ append: false,
90
+ });
91
+ const contentsDataArray: ICSVFileContents[] = [];
92
+ mlsTranslationData.forEach((data) => {
93
+ // Checks existence of translated items and source item elements
94
+ const translatedContent = data.translated_items[0].translated_content;
95
+ const sourceContent = data.translated_items[0].source_content;
96
+ if (data.translated_items.length > 0 && translatedContent && translatedContent.length > 0 && Object.keys(sourceContent).length > 0) {
97
+ translatedContent.forEach((target) => {
98
+ const titleObject: ICSVFileContents = {
99
+ source: sourceContent.title.value,
100
+ target: target.title.value,
101
+ sourceUUID: sourceContent.uuid,
102
+ targetUUID: target.uuid,
103
+ sourceLanguage: sourceContent.locale,
104
+ targetLanguage: target.locale,
105
+ field: CONTENT_TITLE_TYPE,
106
+ type: CONTENT_INFORMATION_TYPE,
107
+ wcmType: WCM_TYPE,
108
+ componentType: '',
109
+ fieldLimit: '',
110
+ previewLink: getPreviewLinkUrl(cmdArgs, sourceContent.uuid),
111
+ lastModifiedOfSource: sourceContent.updated ? new Date(sourceContent.updated).toUTCString() : '',
112
+ lastModifiedOfTarget: target.updated ? new Date(target.updated).toUTCString() : '',
113
+ };
114
+ contentsDataArray.push(titleObject);
115
+
116
+ const descriptionObject: ICSVFileContents = {
117
+ source: sourceContent.description.value,
118
+ target: target.description.value,
119
+ sourceUUID: sourceContent.uuid,
120
+ targetUUID: target.uuid,
121
+ sourceLanguage: sourceContent.locale,
122
+ targetLanguage: target.locale,
123
+ field: CONTENT_DESCRIPTION_TYPE,
124
+ type: CONTENT_INFORMATION_TYPE,
125
+ wcmType: WCM_TYPE,
126
+ componentType: '',
127
+ fieldLimit: '',
128
+ previewLink: getPreviewLinkUrl(cmdArgs, sourceContent.uuid),
129
+ lastModifiedOfSource: sourceContent.updated ? new Date(sourceContent.updated).toUTCString() : '',
130
+ lastModifiedOfTarget: target.updated ? new Date(target.updated).toUTCString() : '',
131
+ };
132
+ contentsDataArray.push(descriptionObject);
133
+ });
134
+ sourceContent.elements.element.forEach((sourceElements) => {
135
+ // Writes contents only for configured wcm element types like ShortText, RichText etc.
136
+ if (Object.values(WCMElementTypes).indexOf(sourceElements.type) !== -1) {
137
+ translatedContent.forEach((target) => {
138
+ const targetElementObject = find(target.elements.element, { name: sourceElements.name });
139
+ // Fetching Field Limit of the content to write into CSV
140
+ const fieldCharLimit = Object.keys(target.elements).length > 0 && targetElementObject
141
+ && targetElementObject.data.PropertiesContent.properties ? targetElementObject.data.PropertiesContent.properties
142
+ .filter((obj) => {
143
+ return obj.key === 'MAX_CHARS' && obj.value;
144
+ }) : '';
145
+ const contentObject: ICSVFileContents = {
146
+ source: sourceElements.data.PropertiesContent.content && sourceElements.data.PropertiesContent.content.value,
147
+ target: Object.keys(target.elements).length > 0 && targetElementObject && targetElementObject.data.PropertiesContent.content
148
+ ? targetElementObject.data.PropertiesContent.content.value : '',
149
+ sourceUUID: sourceContent.uuid,
150
+ targetUUID: target.uuid,
151
+ sourceLanguage: sourceContent.locale,
152
+ targetLanguage: target.locale,
153
+ field: sourceElements.name,
154
+ type: CONTENT_ELEMENT_TYPE,
155
+ wcmType: WCM_TYPE,
156
+ componentType: Object.keys(target.elements).length > 0 && targetElementObject ? targetElementObject.type : '',
157
+ fieldLimit: fieldCharLimit && fieldCharLimit.length > 0 ? fieldCharLimit[0].value : '',
158
+ previewLink: getPreviewLinkUrl(cmdArgs, sourceContent.uuid),
159
+ lastModifiedOfSource: sourceContent.updated ? new Date(sourceContent.updated).toUTCString() : '',
160
+ lastModifiedOfTarget: target.updated ? new Date(target.updated).toUTCString() : '',
161
+ };
162
+ contentsDataArray.push(contentObject);
163
+ });
164
+ }
165
+ });
166
+ }
167
+ });
168
+ logger.debug('Write the contents into the CSV file, content data length - %d', contentsDataArray.length);
169
+ if (contentsDataArray && contentsDataArray.length > 0) {
170
+ // Write the content data to the CSV file
171
+ await csvWriterData.writeRecords(contentsDataArray);
172
+ // Reading the file data by utf8 encoding
173
+ const originalFile = fs.readFileSync(csvFilePath, { encoding: 'utf8' });
174
+ const writeStream = fs.createWriteStream(csvFilePath);
175
+ // Writing the contents with BOM
176
+ writeStream.write(`\uFEFF ${originalFile}`, 'utf8');
177
+ writeStream.on('finish', () => {
178
+ logger.debug('Finished writing the contents into the CSV file with utf8 encoding');
179
+ // close the stream
180
+ writeStream.end();
181
+ });
182
+ }
183
+ } catch (error) {
184
+ logger.debug('Exception during writing contents into CSV file: %o', error);
185
+ throw new Error(errorMessage('ERROR_WRITING_CONTENTS'));
186
+ }
187
+ };
188
+
189
+ /**
190
+ * This method will check for duplicates in library IDs and library names.
191
+ * @param {string} wcmLibraryIds wcmLibraryIds command line argument
192
+ * @param {string} wcmLibraryNames wcmLibraryNames command line argument
193
+ * @param {string} baseDxURL Base URL to login into DX server
194
+ * @param {string} cookie Received from the response of DX server authentication
195
+ * @returns {Array} List of library IDs and names in the format {id: string, name?: string}
196
+ */
197
+ export const getLibraryIdNameList = async (wcmLibraryIds: string, wcmLibraryNames: string, baseDxURL: string, cookie: string): Promise<IWCMLibrary[]> => {
198
+ logger.debug('Entering the getLibraryIdNameList function.');
199
+ const wcmLibraries: IWCMLibrary[] = [];
200
+ let duplicateIdsList: string[] = [];
201
+ let duplicateNamesList: string[] = [];
202
+
203
+ // Convert wcmLibraryIds string to array and check if duplicate Ids are found
204
+ if (wcmLibraryIds) {
205
+ const wcmLibraryIdsList = wcmLibraryIds.split(',').map((libId) => {
206
+ return libId.trim();
207
+ });
208
+
209
+ duplicateIdsList = filter(wcmLibraryIdsList, (val, index, iteratee) => {
210
+ return includes(iteratee, val, index + 1);
211
+ });
212
+
213
+ if (!duplicateIdsList.length) {
214
+ for (let index = 0; index < wcmLibraryIdsList.length; index += 1) {
215
+ if (wcmLibraryIdsList[index] && wcmLibraryIdsList[index].length) {
216
+ wcmLibraries.push({ id: wcmLibraryIdsList[index] });
217
+ }
218
+ }
219
+ }
220
+ }
221
+
222
+ // Convert wcmLibraryNames string to array and check if duplicate names are found
223
+ if (wcmLibraryNames) {
224
+ const wcmLibraryNamesList = wcmLibraryNames.split(',').map((libName) => {
225
+ return libName.trim();
226
+ });
227
+
228
+ duplicateNamesList = filter(wcmLibraryNamesList, (val, index, iteratee) => {
229
+ return includes(iteratee, val, index + 1);
230
+ });
231
+
232
+ if (!duplicateNamesList.length) {
233
+ for (let index = 0; index < wcmLibraryNamesList.length; index += 1) {
234
+ if (wcmLibraryNamesList[index] && wcmLibraryNamesList[index].length) {
235
+ wcmLibraries.push({ name: wcmLibraryNamesList[index] });
236
+ }
237
+ }
238
+ }
239
+
240
+ // Fetch library IDs using library name and check if ID is duplicate.
241
+ for (let index = 0; index < wcmLibraries.length; index += 1) {
242
+ if (wcmLibraries[index].name) {
243
+ // eslint-why to get library id for all names in loop.
244
+ // eslint-disable-next-line no-await-in-loop
245
+ const libraryId = await apiServices.getWCMLibraryIdFromName(baseDxURL, cookie, wcmLibraries[index].name);
246
+ if (libraryId && libraryId.length) {
247
+ const isDuplicate = wcmLibraries.some((lib) => {
248
+ return lib.id === libraryId;
249
+ });
250
+
251
+ if (isDuplicate) {
252
+ duplicateNamesList.push(`${wcmLibraries[index].name} with ID ${libraryId}`);
253
+ } else {
254
+ wcmLibraries[index].id = libraryId;
255
+ }
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ // Log both ID and Name if duplicate found in both duplicateID and duplicateName list and throw
262
+ if (duplicateIdsList.length && duplicateNamesList.length) {
263
+ logger.debug('Duplicate WCM library IDs found - ', duplicateIdsList.join(','));
264
+ logger.debug('Duplicate WCM library Names found - ', duplicateNamesList.join(','));
265
+ throw new Error(errorMessage('ERROR_DUPLICATE_LIBRARY_ID_AND_NAME', { 0: duplicateIdsList.join(','), 1: duplicateNamesList.join(',') }));
266
+ }
267
+
268
+ // Log IDs if duplicate found in duplicateID list and throw
269
+ if (duplicateIdsList.length) {
270
+ logger.debug('Duplicate WCM library IDs found - ', duplicateIdsList.join(','));
271
+ throw new Error(errorMessage('ERROR_DUPLICATE_LIBRARY_ID', { 0: duplicateIdsList.join(',') }));
272
+ }
273
+
274
+ // Log Names if duplicate found in duplicateName list and throw
275
+ if (duplicateNamesList.length) {
276
+ logger.debug('Duplicate WCM library Names found - ', duplicateNamesList.join(','));
277
+ throw new Error(errorMessage('ERROR_DUPLICATE_LIBRARY_NAME', { 0: duplicateNamesList.join(',') }));
278
+ }
279
+
280
+ return wcmLibraries;
281
+ };
282
+
283
+ /**
284
+ * This method will get filePath, invokes the DX services to get WCM contents based on Ids or names.
285
+ * @param {commander.Command} cmdArgs Argument which will be used for processing the exporting the wcm contents.
286
+ * Contains export path, WCM library id and DX API configuration.
287
+ * @param {string} baseDxURL Base URL to login into DX server
288
+ * @param {string} cookie Received from the response of DX server authentication
289
+ * @param {string} wcmLibraryId WcmLibraryId command line argument
290
+ * @param {string} wcmLibraryName WcmLibraryName command line argument
291
+ * @param {string} wcmProjectName WcmProjectName command line argument
292
+ * @param {string} wcmProjectId wcmProjectId to query to DX to get contents
293
+ * @returns {boolean} returns true
294
+ */
295
+ const invokeExportServices = async (cmdArgs: commander.Command, baseDxUrl: string, cookie: string, wcmLibraryId?: string, wcmLibraryName?: string,
296
+ wcmProjectName?: string, wcmProjectId?: string) : Promise<boolean> => {
297
+ logger.debug('Entering the invokeExportServices function.');
298
+ const wcmQueryParam = wcmLibraryId || wcmProjectName;
299
+ // eslint-why to get filePath for all ids and names in list.
300
+ // eslint-disable-next-line no-await-in-loop
301
+ const filePath = await getFilePath(cmdArgs.exportPath, (wcmLibraryId || wcmProjectName.trim().replace(' ', '_'))); // Modify spaces to underscores in project name
302
+ logger.debug('File path to export the source contents - %s.', filePath);
303
+ if (filePath && filePath.length) {
304
+ // eslint-why to get wcmContentIds for all ids and names in list.
305
+ // eslint-disable-next-line no-await-in-loop
306
+ const wcmContentIds = await apiServices.getWebContentIds(baseDxUrl, cookie, 1, wcmLibraryId, wcmProjectName, wcmProjectId, cmdArgs.lastModifiedAfter);
307
+ logger.debug('Found content ids for - %s %d ', wcmQueryParam, wcmContentIds.length);
308
+ // append projectName to url if project name is provided
309
+ if (wcmProjectName) {
310
+ baseDxUrl += `/$project/${wcmProjectName}`;
311
+ logger.debug('baseDXUrl appended with project name - %s', baseDxUrl);
312
+ }
313
+ if (wcmContentIds && wcmContentIds.length) {
314
+ // eslint-why to get mlsTranslationData content for all ids and names in list.
315
+ // eslint-disable-next-line no-await-in-loop
316
+ const mlsTranslationData: IMLSTranslations[] = await apiServices.getMultilingualTranslationsData(baseDxUrl, cookie, wcmContentIds, wcmProjectId);
317
+ logger.info(message('MLS_EXPORT_WRITE_INTO_FILE', { 0: mlsTranslationData.length }));
318
+ if (mlsTranslationData && mlsTranslationData.length) {
319
+ // eslint-why to get writeContents for all ids and names in list.
320
+ // eslint-disable-next-line no-await-in-loop
321
+ await writeContents(filePath, mlsTranslationData, cmdArgs);
322
+ logger.info(message('MLS_EXPORT_CONTENT_SUCCESS', { 0: path.relative(process.cwd(), filePath), 1: (wcmLibraryName || wcmQueryParam) }));
323
+ }
324
+ }
325
+ }
326
+ return true;
327
+ };
328
+
329
+ export class MLSExport {
330
+ /**
331
+ * This function is used to export the WCM source contents into CSV file.
332
+ * @param {commander.Command} cmdArgs Argument which will be used for processing the exporting the wcm contents.
333
+ * Contains export path, WCM library id and DX API configuration.
334
+ * @returns {Promise<boolean>} True or false, if success true otherwise false.
335
+ */
336
+ async invoke(cmdArgs: commander.Command): Promise<boolean> {
337
+ try {
338
+ logger.debug('Enter export wcm source contents invoke function');
339
+ // self signing the certificate
340
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
341
+ cmdArgs.contenthandlerPath = cmdArgs.contenthandlerPath || URL_PATH.defaultContentHandler;
342
+ if (cmdArgs.exportPath) {
343
+ cmdArgs.exportPath = path.resolve(__dirname, cmdArgs.exportPath);
344
+ } else {
345
+ cmdArgs.exportPath = path.resolve(getStoreDir(), defaultExportPath);
346
+ if (!existsSync(cmdArgs.exportPath)) mkdirSync(cmdArgs.exportPath, { recursive: true });
347
+ }
348
+ const baseDxUrl = getBaseDXUrlFromCommand(cmdArgs);
349
+ const cookie = await apiServices.login(cmdArgs.dxUsername, cmdArgs.dxPassword, baseDxUrl);
350
+ logger.info(message('MLS_EXPORT_DX_LOGIN_SUCCESS'));
351
+ if (cmdArgs.wcmLibraryId || cmdArgs.wcmLibraryName) {
352
+ const wcmLibraries = await getLibraryIdNameList(cmdArgs.wcmLibraryId, cmdArgs.wcmLibraryName, baseDxUrl, cookie);
353
+ for (let index = 0; index < wcmLibraries.length; index += 1) {
354
+ if (wcmLibraries[index].id) {
355
+ // eslint-why to get filePath for all ids and names in list.
356
+ // eslint-disable-next-line no-await-in-loop
357
+ await invokeExportServices(cmdArgs, baseDxUrl, cookie, wcmLibraries[index].id, wcmLibraries[index].name, undefined);
358
+ }
359
+ }
360
+ } else {
361
+ const projectId = await apiServices.getWCMProjectIdFromName(baseDxUrl, cookie, cmdArgs.wcmProjectName);
362
+ return await invokeExportServices(cmdArgs, baseDxUrl, cookie, undefined, undefined, cmdArgs.wcmProjectName, projectId);
363
+ }
364
+
365
+ return true;
366
+ } catch (error) {
367
+ logger.error(error.message);
368
+ return false;
369
+ }
370
+ }
371
+ }
@@ -0,0 +1,8 @@
1
+ import commander from 'commander';
2
+ import { ICSVFileContents } from '../utils/interfaces/import';
3
+ export declare const readFileData: (importPath: string) => Promise<ICSVFileContents[]>;
4
+ export declare const validateFileData: (fileData: ICSVFileContents[], importPath: string) => boolean;
5
+ export declare const getSourceContentIds: (fileData: ICSVFileContents[]) => string[];
6
+ export declare class MLSImport {
7
+ invoke(cmdArgs: commander.Command): Promise<boolean>;
8
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MLSImport = exports.getSourceContentIds = exports.validateFileData = exports.readFileData = void 0;
16
+ const csvtojson_1 = __importDefault(require("csvtojson"));
17
+ const fs_1 = require("fs");
18
+ const path_1 = require("path");
19
+ const logger_1 = require("../../../../src/utils/logger");
20
+ const apiServices_1 = require("../../../../src/services/apiServices");
21
+ const utils_1 = require("../../../../src/utils/utils");
22
+ const constants_1 = require("../../../../src/utils/constants");
23
+ const readFileData = (importPath) => __awaiter(void 0, void 0, void 0, function* () {
24
+ if (!fs_1.existsSync(importPath) || !fs_1.statSync(importPath).isFile() || path_1.extname(importPath) !== `.${constants_1.FileType.CSV}`) {
25
+ logger_1.logger.info(utils_1.message('MLS_IMPORT_INVALID_IMPORT_PATH', { 0: importPath }));
26
+ return [];
27
+ }
28
+ try {
29
+ logger_1.logger.debug('Path from where the file data is imported - %s.', importPath);
30
+ const dataArray = yield csvtojson_1.default({
31
+ noheader: false,
32
+ }).fromFile(importPath);
33
+ return dataArray;
34
+ }
35
+ catch (error) {
36
+ logger_1.logger.debug('Exception while reading the CSV file: %o', error);
37
+ throw new Error(utils_1.errorMessage('ERROR_IMPORT_READ_FILE', { 0: importPath, 1: JSON.stringify(error) }));
38
+ }
39
+ });
40
+ exports.readFileData = readFileData;
41
+ const validateFileData = (fileData, importPath) => {
42
+ const maxDataLengthContents = fileData.filter((content) => {
43
+ return content.componentType === constants_1.WCMElementTypes.SHORT_TEXT_COMPONENT && content.target.length > constants_1.MAX_DATA_LENGTH_CONTENT;
44
+ });
45
+ if (maxDataLengthContents.length > 0) {
46
+ maxDataLengthContents.forEach((row) => {
47
+ logger_1.logger.info(utils_1.message('MLS_IMPORT_MAX_DATA_LENGTH_INFO', {
48
+ MAX_LENGTH: constants_1.MAX_DATA_LENGTH_CONTENT, 0: row.targetUUID, 1: row.targetLanguage, 2: row.field, 3: importPath,
49
+ }));
50
+ });
51
+ return false;
52
+ }
53
+ return true;
54
+ };
55
+ exports.validateFileData = validateFileData;
56
+ const getSourceContentIds = (fileData) => {
57
+ const sourceContentIdsObj = {};
58
+ fileData.forEach((row) => {
59
+ if (!sourceContentIdsObj[row.sourceUUID]) {
60
+ sourceContentIdsObj[row.sourceUUID] = 1;
61
+ }
62
+ });
63
+ return Object.keys(sourceContentIdsObj);
64
+ };
65
+ exports.getSourceContentIds = getSourceContentIds;
66
+ class MLSImport {
67
+ invoke(cmdArgs) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ try {
70
+ logger_1.logger.debug('Enter import wcm source contents invoke function');
71
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
72
+ cmdArgs.contenthandlerPath = cmdArgs.contenthandlerPath || constants_1.URL_PATH.defaultContentHandler;
73
+ const baseDxUrl = utils_1.getBaseDXUrlFromCommand(cmdArgs);
74
+ const cookie = yield apiServices_1.apiServices.login(cmdArgs.dxUsername, cmdArgs.dxPassword, baseDxUrl);
75
+ if (cmdArgs.wcmProjectName) {
76
+ yield apiServices_1.apiServices.getWCMProjectIdFromName(baseDxUrl, cookie, cmdArgs.wcmProjectName);
77
+ }
78
+ cmdArgs.importPath = cmdArgs.importPath.split(',').map((entry) => { return entry.trim(); });
79
+ for (let index = 0; index < cmdArgs.importPath.length; index += 1) {
80
+ if (cmdArgs.importPath[index] && cmdArgs.importPath[index].length) {
81
+ const fileData = yield exports.readFileData(cmdArgs.importPath[index]);
82
+ if (fileData && fileData.length) {
83
+ logger_1.logger.info(utils_1.message('MLS_IMPORT_FETCH_TRANSLATED_DATA', { 0: cmdArgs.importPath[index], 1: fileData.length }));
84
+ if (exports.validateFileData(fileData, cmdArgs.importPath[index])) {
85
+ const sourceContentIds = exports.getSourceContentIds(fileData);
86
+ logger_1.logger.info(utils_1.message('MLS_IMPORT_FETCH_SOURCE_IDS', { 0: sourceContentIds.length }));
87
+ const projectName = cmdArgs.wcmProjectName || '';
88
+ yield apiServices_1.apiServices.importMultilingualTranslationsData(sourceContentIds, fileData, cookie, baseDxUrl, projectName, (/^true$/i).test(cmdArgs.forceImport));
89
+ logger_1.logger.info(utils_1.message('MLS_IMPORT_PROCESS_COMPLETE', { 0: cmdArgs.importPath[index] }));
90
+ }
91
+ }
92
+ }
93
+ }
94
+ return true;
95
+ }
96
+ catch (error) {
97
+ logger_1.logger.error(error.message);
98
+ return false;
99
+ }
100
+ });
101
+ }
102
+ }
103
+ exports.MLSImport = MLSImport;
104
+ //# sourceMappingURL=mlsImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mlsImport.js","sourceRoot":"","sources":["../../../../../packages/mls_exim/src/import/mlsImport.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,138 @@
1
+ /*
2
+ ********************************************************************
3
+ * Licensed Materials - Property of HCL *
4
+ * *
5
+ * Copyright HCL Technologies Ltd. 2021. All Rights Reserved. *
6
+ * *
7
+ * Note to US Government Users Restricted Rights: *
8
+ * *
9
+ * Use, duplication or disclosure restricted by GSA ADP Schedule *
10
+ ********************************************************************
11
+ */
12
+ import commander from 'commander';
13
+ import csvReader from 'csvtojson';
14
+ import { existsSync, statSync } from 'fs';
15
+ import { extname } from 'path';
16
+ import { logger } from '../../../../src/utils/logger';
17
+ import { apiServices } from '../../../../src/services/apiServices';
18
+ import { ICSVFileContents } from '../utils/interfaces/import';
19
+ import {
20
+ errorMessage, getBaseDXUrlFromCommand, message,
21
+ } from '../../../../src/utils/utils';
22
+ import {
23
+ FileType, MAX_DATA_LENGTH_CONTENT, URL_PATH, WCMElementTypes,
24
+ } from '../../../../src/utils/constants';
25
+
26
+ /**
27
+ * Returns the csv file data array from the file path specified.
28
+ * @param {string} importPath Path from where the contents have to be imported.
29
+ * @returns {Array} CSV file data array.
30
+ */
31
+ export const readFileData = async (importPath: string): Promise<ICSVFileContents[]> => {
32
+ if (!existsSync(importPath) || !statSync(importPath).isFile() || extname(importPath) !== `.${FileType.CSV}`) {
33
+ logger.info(message('MLS_IMPORT_INVALID_IMPORT_PATH', { 0: importPath }));
34
+ return [] as ICSVFileContents[];
35
+ }
36
+
37
+ try {
38
+ logger.debug('Path from where the file data is imported - %s.', importPath);
39
+ const dataArray = await csvReader({
40
+ noheader: false,
41
+ }).fromFile(importPath); // Returns array of objects
42
+ return dataArray;
43
+ } catch (error) {
44
+ logger.debug('Exception while reading the CSV file: %o', error);
45
+ throw new Error(errorMessage('ERROR_IMPORT_READ_FILE', { 0: importPath, 1: JSON.stringify(error) }));
46
+ }
47
+ };
48
+
49
+ /**
50
+ * Check whether CSV file data is valid
51
+ * @param {string} fileData CSV file data array.
52
+ * @param {string} importPath Path from where the contents have to be imported.
53
+ * @returns {Boolean} true if CSF file data is valid else false.
54
+ */
55
+ export const validateFileData = (fileData: ICSVFileContents[], importPath: string): boolean => {
56
+ const maxDataLengthContents = fileData.filter((content) => {
57
+ return content.componentType === WCMElementTypes.SHORT_TEXT_COMPONENT && content.target.length > MAX_DATA_LENGTH_CONTENT;
58
+ });
59
+
60
+ if (maxDataLengthContents.length > 0) {
61
+ maxDataLengthContents.forEach((row) => {
62
+ logger.info(message('MLS_IMPORT_MAX_DATA_LENGTH_INFO', {
63
+ MAX_LENGTH: MAX_DATA_LENGTH_CONTENT, 0: row.targetUUID, 1: row.targetLanguage, 2: row.field, 3: importPath,
64
+ }));
65
+ });
66
+ return false;
67
+ }
68
+ return true;
69
+ };
70
+
71
+ /**
72
+ * Returns the unique list of source content ids.
73
+ * @param {string} fileData File data which has to be imported.
74
+ * @returns {Array} Array of source content ids.
75
+ */
76
+ export const getSourceContentIds = (fileData: ICSVFileContents[]): string[] => {
77
+ const sourceContentIdsObj: {[key: string]: number} = {};
78
+ fileData.forEach((row) => {
79
+ if (!sourceContentIdsObj[row.sourceUUID]) {
80
+ sourceContentIdsObj[row.sourceUUID] = 1;
81
+ }
82
+ });
83
+ // Return the unique source content ids list
84
+ return Object.keys(sourceContentIdsObj);
85
+ };
86
+
87
+ export class MLSImport {
88
+ /**
89
+ * This function is used to export the WCM source contents into CSV file.
90
+ * @param {commander.Command} cmdArgs Argument which will be used for processing the exporting the wcm contents.
91
+ * Contains export path, WCM library id and RING API configuration.
92
+ * @returns {Promise<boolean>} True or false, if success true otherwise false.
93
+ */
94
+ async invoke(cmdArgs: commander.Command): Promise<boolean> {
95
+ try {
96
+ logger.debug('Enter import wcm source contents invoke function');
97
+ // self signing the certificate
98
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
99
+ cmdArgs.contenthandlerPath = cmdArgs.contenthandlerPath || URL_PATH.defaultContentHandler;
100
+ const baseDxUrl = getBaseDXUrlFromCommand(cmdArgs);
101
+ const cookie = await apiServices.login(cmdArgs.dxUsername, cmdArgs.dxPassword, baseDxUrl);
102
+
103
+ if (cmdArgs.wcmProjectName) {
104
+ // This is to validate if the project name is valid or not.
105
+ await apiServices.getWCMProjectIdFromName(baseDxUrl, cookie, cmdArgs.wcmProjectName);
106
+ }
107
+
108
+ cmdArgs.importPath = cmdArgs.importPath.split(',').map((entry:string) => { return entry.trim(); });
109
+ for (let index = 0; index < cmdArgs.importPath.length; index += 1) {
110
+ // Checking array elements length to verify path existence
111
+ if (cmdArgs.importPath[index] && cmdArgs.importPath[index].length) {
112
+ // eslint-why We need a synchronous fashion execution to process the data.
113
+ // eslint-disable-next-line no-await-in-loop
114
+ const fileData = await readFileData(cmdArgs.importPath[index]);
115
+ // Checking fileData array is empty or not to process importing
116
+ if (fileData && fileData.length) {
117
+ logger.info(message('MLS_IMPORT_FETCH_TRANSLATED_DATA', { 0: cmdArgs.importPath[index], 1: fileData.length }));
118
+ // Validating each row from fileData to handle max data length
119
+ if (validateFileData(fileData, cmdArgs.importPath[index])) {
120
+ const sourceContentIds = getSourceContentIds(fileData);
121
+ logger.info(message('MLS_IMPORT_FETCH_SOURCE_IDS', { 0: sourceContentIds.length }));
122
+
123
+ const projectName = cmdArgs.wcmProjectName || '';
124
+ // eslint-why to invoke dx api in synchronous fashion and process it.
125
+ // eslint-disable-next-line no-await-in-loop
126
+ await apiServices.importMultilingualTranslationsData(sourceContentIds, fileData, cookie, baseDxUrl, projectName, (/^true$/i).test(cmdArgs.forceImport));
127
+ logger.info(message('MLS_IMPORT_PROCESS_COMPLETE', { 0: cmdArgs.importPath[index] }));
128
+ }
129
+ }
130
+ }
131
+ }
132
+ return true;
133
+ } catch (error) {
134
+ logger.error(error.message);
135
+ return false;
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "MLS_EXPORT_CONTENT_SUCCESS": "Successfully exported the contents in specified path {0} for {1}.",
3
+ "MLS_EXPORT_DX_LOGIN_SUCCESS": "Successfully logged in to DX server.",
4
+ "MLS_EXPORT_WRITE_INTO_FILE": "{0} web contents are found to export the MLS translation data.",
5
+ "MLS_EXPORT_RETRIEVED_TRANSLATION": "Retrieved translated contents to write into file for the content Id {0}",
6
+ "MLS_IMPORT_FETCH_TRANSLATED_DATA": "Translated data fetched successfully from the path - {0}, total number of rows in the file - {1}.",
7
+ "MLS_IMPORT_FETCH_SOURCE_IDS": "Unique sourceContentIds fetched successfully, total number of sourceContentIds - {0}.",
8
+ "MLS_IMPORT_PROCESS_COMPLETE": "Import process completed for the CSV file - {0}.",
9
+ "MLS_IMPORT_TRANSLATION_DATA_SUCCESS": "Imported translations data successfully for sourceContentId - {0}.",
10
+ "MLS_IMPORT_TRANSLATION_DATA_ERROR": "Translation unsuccessful for the sourceContentId - {0}, error response - {1}.",
11
+ "MLS_IMPORT_MAX_DATA_LENGTH_INFO": "Translated content data length is more than maximum supported data length {MAX_LENGTH} for targetUUID - {0}, targetLanguage - {1}, field - {2} for CSV file path - {3}, hence skipping the import process for this.",
12
+ "MLS_IMPORT_INVALID_IMPORT_PATH": "Import path provided is not a valid CSV file path - {0}, hence skipping the import process for this.",
13
+ "MLS_IMPORT_VALIDATION_FAILED": "Either source content or one of the target contents updated since last export, hence skipping the import process for this content - {0}. Perform force import to ignore this."
14
+ }