@rockcarver/frodo-lib 0.16.2-9 → 0.17.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 (355) hide show
  1. package/CHANGELOG.md +222 -1
  2. package/cjs/api/AgentApi.js +14 -61
  3. package/cjs/api/AgentApi.js.map +1 -1
  4. package/cjs/api/AgentApi.test.js.map +1 -1
  5. package/cjs/api/ApiTypes.js +0 -5
  6. package/cjs/api/ApiTypes.js.map +1 -1
  7. package/cjs/api/AuthenticateApi.js +9 -20
  8. package/cjs/api/AuthenticateApi.js.map +1 -1
  9. package/cjs/api/AuthenticateApi.test.js.map +1 -0
  10. package/cjs/api/BaseApi.js +82 -124
  11. package/cjs/api/BaseApi.js.map +1 -1
  12. package/cjs/api/CirclesOfTrustApi.js +8 -32
  13. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  14. package/cjs/api/IdmConfigApi.js +9 -34
  15. package/cjs/api/IdmConfigApi.js.map +1 -1
  16. package/cjs/api/LogApi.js +8 -31
  17. package/cjs/api/LogApi.js.map +1 -1
  18. package/cjs/api/ManagedObjectApi.js +34 -31
  19. package/cjs/api/ManagedObjectApi.js.map +1 -1
  20. package/cjs/api/NodeApi.js +10 -41
  21. package/cjs/api/NodeApi.js.map +1 -1
  22. package/cjs/api/NodeApi.test.js.map +1 -1
  23. package/cjs/api/OAuth2ClientApi.js +7 -26
  24. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  25. package/cjs/api/OAuth2OIDCApi.js +28 -34
  26. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  27. package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
  28. package/cjs/api/OAuth2ProviderApi.js +5 -15
  29. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  30. package/cjs/api/RealmApi.js +8 -34
  31. package/cjs/api/RealmApi.js.map +1 -1
  32. package/cjs/api/Saml2Api.js +16 -67
  33. package/cjs/api/Saml2Api.js.map +1 -1
  34. package/cjs/api/ScriptApi.js +8 -30
  35. package/cjs/api/ScriptApi.js.map +1 -1
  36. package/cjs/api/SecretsApi.js +14 -64
  37. package/cjs/api/SecretsApi.js.map +1 -1
  38. package/cjs/api/SecretsApi.test.js.map +1 -1
  39. package/cjs/api/ServerInfoApi.js +6 -21
  40. package/cjs/api/ServerInfoApi.js.map +1 -1
  41. package/cjs/api/ServiceApi.js +49 -47
  42. package/cjs/api/ServiceApi.js.map +1 -1
  43. package/cjs/api/SocialIdentityProvidersApi.js +9 -36
  44. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  45. package/cjs/api/StartupApi.js +5 -24
  46. package/cjs/api/StartupApi.js.map +1 -1
  47. package/cjs/api/StartupApi.test.js.map +1 -1
  48. package/cjs/api/TreeApi.js +8 -30
  49. package/cjs/api/TreeApi.js.map +1 -1
  50. package/cjs/api/TreeApi.test.js.map +1 -1
  51. package/cjs/api/VariablesApi.js +9 -37
  52. package/cjs/api/VariablesApi.js.map +1 -1
  53. package/cjs/api/VariablesApi.test.js.map +1 -1
  54. package/cjs/api/utils/ApiUtils.js +47 -57
  55. package/cjs/api/utils/ApiUtils.js.map +1 -1
  56. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  57. package/cjs/api/utils/Base64.js +5 -15
  58. package/cjs/api/utils/Base64.js.map +1 -1
  59. package/cjs/ext/axios-curlirize/curlirize.js +2 -9
  60. package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
  61. package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
  62. package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
  63. package/cjs/index.js +30 -89
  64. package/cjs/index.js.map +1 -1
  65. package/cjs/ops/AdminOps.js +27 -165
  66. package/cjs/ops/AdminOps.js.map +1 -1
  67. package/cjs/ops/AgentOps.js +2 -159
  68. package/cjs/ops/AgentOps.js.map +1 -1
  69. package/cjs/ops/AgentOps.test.js.map +1 -1
  70. package/cjs/ops/AuthenticateOps.js +266 -226
  71. package/cjs/ops/AuthenticateOps.js.map +1 -1
  72. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  73. package/cjs/ops/CirclesOfTrustOps.js +13 -91
  74. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  75. package/cjs/ops/ConnectionProfileOps.js +220 -136
  76. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  77. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  78. package/cjs/ops/EmailTemplateOps.js +35 -379
  79. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  80. package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
  81. package/cjs/ops/IdmOps.js +52 -426
  82. package/cjs/ops/IdmOps.js.map +1 -1
  83. package/cjs/ops/IdmOps.test.js.map +1 -1
  84. package/cjs/ops/IdpOps.js +11 -94
  85. package/cjs/ops/IdpOps.js.map +1 -1
  86. package/cjs/ops/IdpOps.test.js.map +1 -1
  87. package/cjs/ops/JoseOps.js +81 -0
  88. package/cjs/ops/JoseOps.js.map +1 -0
  89. package/cjs/ops/JoseOps.test.js.map +1 -0
  90. package/cjs/ops/JourneyOps.js +139 -370
  91. package/cjs/ops/JourneyOps.js.map +1 -1
  92. package/cjs/ops/JourneyOps.test.js.map +1 -1
  93. package/cjs/ops/LogOps.js +14 -47
  94. package/cjs/ops/LogOps.js.map +1 -1
  95. package/cjs/ops/ManagedObjectOps.js +4 -12
  96. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  97. package/cjs/ops/NodeOps.js +9 -67
  98. package/cjs/ops/NodeOps.js.map +1 -1
  99. package/cjs/ops/OAuth2ClientOps.js +10 -40
  100. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  101. package/cjs/ops/OpsTypes.js +0 -5
  102. package/cjs/ops/OpsTypes.js.map +1 -1
  103. package/cjs/ops/OrganizationOps.js +6 -25
  104. package/cjs/ops/OrganizationOps.js.map +1 -1
  105. package/cjs/ops/RealmOps.js +0 -19
  106. package/cjs/ops/RealmOps.js.map +1 -1
  107. package/cjs/ops/Saml2Ops.js +11 -107
  108. package/cjs/ops/Saml2Ops.js.map +1 -1
  109. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  110. package/cjs/ops/ScriptOps.js +26 -73
  111. package/cjs/ops/ScriptOps.js.map +1 -1
  112. package/cjs/ops/SecretsOps.js +2 -58
  113. package/cjs/ops/SecretsOps.js.map +1 -1
  114. package/cjs/ops/ServiceAccountOps.js +61 -0
  115. package/cjs/ops/ServiceAccountOps.js.map +1 -0
  116. package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
  117. package/cjs/ops/ServiceOps.js +55 -101
  118. package/cjs/ops/ServiceOps.js.map +1 -1
  119. package/cjs/ops/StartupOps.js +2 -23
  120. package/cjs/ops/StartupOps.js.map +1 -1
  121. package/cjs/ops/ThemeOps.js +230 -436
  122. package/cjs/ops/ThemeOps.js.map +1 -1
  123. package/cjs/ops/ThemeOps.test.js.map +1 -0
  124. package/cjs/ops/VariablesOps.js +0 -38
  125. package/cjs/ops/VariablesOps.js.map +1 -1
  126. package/cjs/ops/utils/Console.js +29 -62
  127. package/cjs/ops/utils/Console.js.map +1 -1
  128. package/cjs/ops/utils/DataProtection.js +13 -47
  129. package/cjs/ops/utils/DataProtection.js.map +1 -1
  130. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  131. package/cjs/ops/utils/ExportImportUtils.js +36 -74
  132. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  133. package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
  134. package/cjs/ops/utils/OpsUtils.js +27 -43
  135. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  136. package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
  137. package/cjs/ops/utils/ValidationUtils.js +0 -13
  138. package/cjs/ops/utils/ValidationUtils.js.map +1 -1
  139. package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
  140. package/cjs/ops/utils/Version.js +2 -12
  141. package/cjs/ops/utils/Version.js.map +1 -1
  142. package/cjs/ops/utils/Version.test.js.map +1 -1
  143. package/cjs/ops/utils/Wordwrap.js +1 -2
  144. package/cjs/ops/utils/Wordwrap.js.map +1 -1
  145. package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
  146. package/cjs/shared/State.js +239 -0
  147. package/cjs/shared/State.js.map +1 -0
  148. package/cjs/shared/State.test.js.map +1 -0
  149. package/cjs/storage/StaticStorage.js.map +1 -1
  150. package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  151. package/cjs/test/mocks/ForgeRockApiMockEngine.js +161 -83
  152. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  153. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  154. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  155. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  156. package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  157. package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  158. package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  159. package/cjs/utils/AutoSetupPolly.js +79 -0
  160. package/cjs/utils/AutoSetupPolly.js.map +1 -0
  161. package/cjs/utils/SetupJest.js +6 -0
  162. package/cjs/utils/SetupJest.js.map +1 -0
  163. package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
  164. package/cjs/utils/snapshotResolve.js.map +1 -0
  165. package/esm/api/AgentApi.mjs +19 -21
  166. package/esm/api/AgentApi.test.mjs +6 -15
  167. package/esm/api/ApiTypes.mjs +0 -5
  168. package/esm/api/AuthenticateApi.mjs +7 -10
  169. package/esm/api/AuthenticateApi.test.mjs +39 -0
  170. package/esm/api/BaseApi.mjs +96 -81
  171. package/esm/api/CirclesOfTrustApi.mjs +9 -12
  172. package/esm/api/IdmConfigApi.mjs +11 -12
  173. package/esm/api/LogApi.mjs +6 -10
  174. package/esm/api/ManagedObjectApi.mjs +23 -8
  175. package/esm/api/NodeApi.mjs +13 -15
  176. package/esm/api/NodeApi.test.mjs +13 -17
  177. package/esm/api/OAuth2ClientApi.mjs +7 -9
  178. package/esm/api/OAuth2OIDCApi.mjs +15 -9
  179. package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
  180. package/esm/api/OAuth2ProviderApi.mjs +3 -5
  181. package/esm/api/RealmApi.mjs +10 -13
  182. package/esm/api/Saml2Api.mjs +25 -29
  183. package/esm/api/ScriptApi.mjs +9 -11
  184. package/esm/api/SecretsApi.mjs +21 -24
  185. package/esm/api/SecretsApi.test.mjs +9 -31
  186. package/esm/api/ServerInfoApi.mjs +5 -9
  187. package/esm/api/ServiceApi.mjs +53 -26
  188. package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
  189. package/esm/api/StartupApi.mjs +5 -10
  190. package/esm/api/StartupApi.test.mjs +4 -7
  191. package/esm/api/TreeApi.mjs +9 -11
  192. package/esm/api/TreeApi.test.mjs +24 -61
  193. package/esm/api/VariablesApi.mjs +11 -13
  194. package/esm/api/VariablesApi.test.mjs +80 -222
  195. package/esm/api/utils/ApiUtils.mjs +45 -48
  196. package/esm/api/utils/ApiUtils.test.mjs +33 -32
  197. package/esm/api/utils/Base64.mjs +5 -9
  198. package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
  199. package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
  200. package/esm/index.mjs +23 -13
  201. package/esm/ops/AdminOps.mjs +33 -119
  202. package/esm/ops/AgentOps.mjs +37 -80
  203. package/esm/ops/AgentOps.test.mjs +5 -45
  204. package/esm/ops/AuthenticateOps.mjs +242 -175
  205. package/esm/ops/AuthenticateOps.test.mjs +7 -9
  206. package/esm/ops/CirclesOfTrustOps.mjs +24 -61
  207. package/esm/ops/ConnectionProfileOps.mjs +192 -82
  208. package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
  209. package/esm/ops/EmailTemplateOps.mjs +18 -276
  210. package/esm/ops/EmailTemplateOps.test.mjs +19 -44
  211. package/esm/ops/IdmOps.mjs +30 -327
  212. package/esm/ops/IdmOps.test.mjs +47 -54
  213. package/esm/ops/IdpOps.mjs +21 -59
  214. package/esm/ops/IdpOps.test.mjs +5 -5
  215. package/esm/ops/JoseOps.mjs +41 -0
  216. package/esm/ops/JoseOps.test.mjs +137 -0
  217. package/esm/ops/JourneyOps.mjs +146 -289
  218. package/esm/ops/JourneyOps.test.mjs +29 -27
  219. package/esm/ops/LogOps.mjs +15 -25
  220. package/esm/ops/ManagedObjectOps.mjs +6 -6
  221. package/esm/ops/NodeOps.mjs +9 -47
  222. package/esm/ops/OAuth2ClientOps.mjs +13 -19
  223. package/esm/ops/OpsTypes.mjs +1 -3
  224. package/esm/ops/OrganizationOps.mjs +7 -14
  225. package/esm/ops/RealmOps.mjs +4 -7
  226. package/esm/ops/Saml2Ops.mjs +28 -62
  227. package/esm/ops/Saml2Ops.test.mjs +20 -23
  228. package/esm/ops/ScriptOps.mjs +29 -47
  229. package/esm/ops/SecretsOps.mjs +15 -31
  230. package/esm/ops/ServiceAccountOps.mjs +41 -0
  231. package/esm/ops/ServiceAccountOps.test.mjs +51 -0
  232. package/esm/ops/ServiceOps.mjs +66 -83
  233. package/esm/ops/StartupOps.mjs +4 -13
  234. package/esm/ops/ThemeOps.mjs +189 -298
  235. package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
  236. package/esm/ops/VariablesOps.mjs +9 -18
  237. package/esm/ops/utils/Console.mjs +28 -46
  238. package/esm/ops/utils/DataProtection.mjs +15 -28
  239. package/esm/ops/utils/DataProtection.test.mjs +8 -8
  240. package/esm/ops/utils/ExportImportUtils.mjs +34 -43
  241. package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
  242. package/esm/ops/utils/OpsUtils.mjs +27 -21
  243. package/esm/ops/utils/OpsUtils.test.mjs +155 -27
  244. package/esm/ops/utils/ValidationUtils.mjs +0 -9
  245. package/esm/ops/utils/Version.mjs +2 -3
  246. package/esm/ops/utils/Version.test.mjs +0 -2
  247. package/esm/ops/utils/Wordwrap.mjs +1 -1
  248. package/esm/ops/utils/Wordwrap.test.mjs +19 -0
  249. package/esm/shared/State.mjs +164 -0
  250. package/esm/shared/State.test.mjs +249 -0
  251. package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  252. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +147 -31
  253. package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  254. package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  255. package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  256. package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  257. package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  258. package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  259. package/esm/utils/AutoSetupPolly.mjs +72 -0
  260. package/esm/utils/SetupJest.mjs +3 -0
  261. package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
  262. package/package.json +36 -26
  263. package/types/api/AgentApi.d.ts.map +1 -1
  264. package/types/api/ApiTypes.d.ts +15 -16
  265. package/types/api/ApiTypes.d.ts.map +1 -1
  266. package/types/api/AuthenticateApi.d.ts +1 -1
  267. package/types/api/AuthenticateApi.d.ts.map +1 -1
  268. package/types/api/BaseApi.d.ts +2 -0
  269. package/types/api/BaseApi.d.ts.map +1 -1
  270. package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
  271. package/types/api/IdmConfigApi.d.ts.map +1 -1
  272. package/types/api/LogApi.d.ts.map +1 -1
  273. package/types/api/ManagedObjectApi.d.ts +9 -1
  274. package/types/api/ManagedObjectApi.d.ts.map +1 -1
  275. package/types/api/NodeApi.d.ts.map +1 -1
  276. package/types/api/OAuth2ClientApi.d.ts.map +1 -1
  277. package/types/api/OAuth2OIDCApi.d.ts +4 -2
  278. package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
  279. package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
  280. package/types/api/RealmApi.d.ts.map +1 -1
  281. package/types/api/Saml2Api.d.ts.map +1 -1
  282. package/types/api/ScriptApi.d.ts.map +1 -1
  283. package/types/api/SecretsApi.d.ts.map +1 -1
  284. package/types/api/ServerInfoApi.d.ts.map +1 -1
  285. package/types/api/ServiceApi.d.ts +14 -7
  286. package/types/api/ServiceApi.d.ts.map +1 -1
  287. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
  288. package/types/api/StartupApi.d.ts.map +1 -1
  289. package/types/api/TreeApi.d.ts.map +1 -1
  290. package/types/api/VariablesApi.d.ts.map +1 -1
  291. package/types/api/utils/ApiUtils.d.ts +1 -0
  292. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  293. package/types/index.d.ts +11 -5
  294. package/types/index.d.ts.map +1 -1
  295. package/types/ops/AuthenticateOps.d.ts +10 -2
  296. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  297. package/types/ops/ConnectionProfileOps.d.ts +49 -21
  298. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  299. package/types/ops/EmailTemplateOps.d.ts +14 -33
  300. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  301. package/types/ops/IdmOps.d.ts +29 -37
  302. package/types/ops/IdmOps.d.ts.map +1 -1
  303. package/types/ops/JoseOps.d.ts +33 -0
  304. package/types/ops/JoseOps.d.ts.map +1 -0
  305. package/types/ops/JourneyOps.d.ts.map +1 -1
  306. package/types/ops/LogOps.d.ts.map +1 -1
  307. package/types/ops/NodeOps.d.ts.map +1 -1
  308. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  309. package/types/ops/OpsTypes.d.ts +1 -1
  310. package/types/ops/OpsTypes.d.ts.map +1 -1
  311. package/types/ops/OrganizationOps.d.ts.map +1 -1
  312. package/types/ops/ScriptOps.d.ts.map +1 -1
  313. package/types/ops/ServiceAccountOps.d.ts +20 -0
  314. package/types/ops/ServiceAccountOps.d.ts.map +1 -0
  315. package/types/ops/ServiceOps.d.ts +18 -10
  316. package/types/ops/ServiceOps.d.ts.map +1 -1
  317. package/types/ops/ThemeOps.d.ts +35 -50
  318. package/types/ops/ThemeOps.d.ts.map +1 -1
  319. package/types/ops/utils/Console.d.ts +1 -1
  320. package/types/ops/utils/Console.d.ts.map +1 -1
  321. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  322. package/types/ops/utils/ExportImportUtils.d.ts +5 -2
  323. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  324. package/types/ops/utils/OpsUtils.d.ts +6 -0
  325. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  326. package/types/ops/utils/Wordwrap.d.ts.map +1 -1
  327. package/types/shared/State.d.ts +223 -0
  328. package/types/shared/State.d.ts.map +1 -0
  329. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +19 -1
  330. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
  331. package/types/utils/AutoSetupPolly.d.ts +1 -0
  332. package/types/utils/AutoSetupPolly.d.ts.map +1 -0
  333. package/types/utils/SetupJest.d.ts +1 -0
  334. package/types/utils/SetupJest.d.ts.map +1 -0
  335. package/types/utils/snapshotResolve.d.ts +1 -0
  336. package/types/utils/snapshotResolve.d.ts.map +1 -0
  337. package/cjs/api/EmailTemplateApi.js +0 -73
  338. package/cjs/api/EmailTemplateApi.js.map +0 -1
  339. package/cjs/api/ThemeApi.js +0 -367
  340. package/cjs/api/ThemeApi.js.map +0 -1
  341. package/cjs/api/ThemeApi.test.js.map +0 -1
  342. package/cjs/storage/SessionStorage.js +0 -91
  343. package/cjs/storage/SessionStorage.js.map +0 -1
  344. package/cjs/test/mocks/snapshotResolve.js.map +0 -1
  345. package/esm/api/EmailTemplateApi.mjs +0 -34
  346. package/esm/api/ThemeApi.mjs +0 -271
  347. package/esm/storage/SessionStorage.mjs +0 -79
  348. package/types/api/EmailTemplateApi.d.ts +0 -22
  349. package/types/api/EmailTemplateApi.d.ts.map +0 -1
  350. package/types/api/ThemeApi.d.ts +0 -56
  351. package/types/api/ThemeApi.d.ts.map +0 -1
  352. package/types/storage/SessionStorage.d.ts +0 -71
  353. package/types/storage/SessionStorage.d.ts.map +0 -1
  354. package/types/test/mocks/snapshotResolve.d.ts +0 -1
  355. package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
@@ -3,44 +3,40 @@ import { lstat, readdir } from 'fs/promises';
3
3
  import { join } from 'path';
4
4
  import slugify from 'slugify';
5
5
  import { decode, decodeBase64Url, encode, encodeBase64Url } from '../../api/utils/Base64';
6
- import storage from '../../storage/SessionStorage';
6
+ import * as state from '../../shared/State';
7
7
  import { FRODO_METADATA_ID } from '../../storage/StaticStorage';
8
8
  import { debugMessage, printMessage } from './Console';
9
9
  export function getCurrentTimestamp() {
10
10
  const ts = new Date();
11
11
  return ts.toISOString();
12
12
  }
13
-
14
- function getMetadata() {
13
+ export function getMetadata() {
15
14
  const metadata = {
16
- origin: storage.session.getTenant(),
17
- originAmVersion: storage.session.getAmVersion(),
18
- exportedBy: storage.session.getUsername(),
15
+ origin: state.getHost(),
16
+ originAmVersion: state.getAmVersion(),
17
+ exportedBy: state.getUsername(),
19
18
  exportDate: getCurrentTimestamp(),
20
19
  exportTool: FRODO_METADATA_ID,
21
- exportToolVersion: storage.session.getFrodoVersion()
20
+ exportToolVersion: state.getFrodoVersion()
22
21
  };
23
22
  return metadata;
24
23
  }
24
+
25
25
  /*
26
26
  * Output str in title case
27
27
  *
28
28
  * e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'
29
29
  */
30
-
31
-
32
30
  export function titleCase(input) {
33
31
  const str = input.toString();
34
32
  const splitStr = str.toLowerCase().split(' ');
35
-
36
33
  for (let i = 0; i < splitStr.length; i += 1) {
37
34
  splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);
38
35
  }
39
-
40
36
  return splitStr.join(' ');
41
37
  }
42
38
  export function getRealmString() {
43
- const realm = storage.session.getRealm();
39
+ const realm = state.getRealm();
44
40
  return realm.split('/').reduce((result, item) => `${result}${titleCase(item)}`, '');
45
41
  }
46
42
  export function convertBase64TextToArray(b64text) {
@@ -66,8 +62,9 @@ export function convertTextArrayToBase64Url(textArray) {
66
62
  const joinedText = textArray.join('\n');
67
63
  const b64encodedScript = encodeBase64Url(joinedText);
68
64
  return b64encodedScript;
69
- } // eslint-disable-next-line no-unused-vars
65
+ }
70
66
 
67
+ // eslint-disable-next-line no-unused-vars
71
68
  export function validateImport(metadata) {
72
69
  return metadata || true;
73
70
  }
@@ -77,10 +74,9 @@ export function getTypedFilename(name, type, suffix = 'json') {
77
74
  }
78
75
  export function getWorkingDirectory() {
79
76
  let wd = '.';
80
-
81
- if (storage.session.getDirectory()) {
82
- wd = storage.session.getDirectory().replace(/\/$/, ''); // create directory if it doesn't exist
83
-
77
+ if (state.getDirectory()) {
78
+ wd = state.getDirectory().replace(/\/$/, '');
79
+ // create directory if it doesn't exist
84
80
  if (!fs.existsSync(wd)) {
85
81
  debugMessage(`ExportImportUtils.getWorkingDirectory: creating directory '${wd}'`);
86
82
  fs.mkdirSync(wd, {
@@ -88,14 +84,12 @@ export function getWorkingDirectory() {
88
84
  });
89
85
  }
90
86
  }
91
-
92
87
  return wd;
93
88
  }
94
89
  export function saveToFile(type, data, identifier, filename) {
95
90
  const exportData = {};
96
91
  exportData['meta'] = getMetadata();
97
92
  exportData[type] = {};
98
-
99
93
  if (Array.isArray(data)) {
100
94
  data.forEach(element => {
101
95
  exportData[type][element[identifier]] = element;
@@ -103,54 +97,52 @@ export function saveToFile(type, data, identifier, filename) {
103
97
  } else {
104
98
  exportData[type][data[identifier]] = data;
105
99
  }
106
-
107
100
  fs.writeFile(filename, JSON.stringify(exportData, null, 2), err => {
108
101
  if (err) {
109
102
  return printMessage(`ERROR - can't save ${type} to file`, 'error');
110
103
  }
111
-
112
104
  return '';
113
105
  });
114
106
  }
107
+
115
108
  /**
116
109
  * Save JSON object to file
117
110
  * @param {Object} data data object
118
111
  * @param {String} filename file name
112
+ * @return {boolean} true if successful, false otherwise
119
113
  */
120
-
121
- export function saveJsonToFile(data, filename) {
114
+ export function saveJsonToFile(data, filename, includeMeta = true) {
122
115
  const exportData = data;
123
- exportData.meta = getMetadata();
124
- fs.writeFile(filename, JSON.stringify(exportData, null, 2), err => {
125
- if (err) {
126
- return printMessage(`ERROR - can't save ${filename}`, 'error');
127
- }
128
-
129
- return '';
130
- });
116
+ if (includeMeta) exportData.meta = getMetadata();
117
+ try {
118
+ fs.writeFileSync(filename, JSON.stringify(exportData, null, 2));
119
+ return true;
120
+ } catch (err) {
121
+ printMessage(`ERROR - can't save ${filename}`, 'error');
122
+ return false;
123
+ }
131
124
  }
125
+
132
126
  /**
133
127
  * Save text data to file
134
128
  * @param {String} data text data
135
129
  * @param {String} filename file name
136
130
  */
137
-
138
131
  export function saveTextToFile(data, filename) {
139
132
  fs.writeFile(filename, data, err => {
140
133
  if (err) {
141
134
  printMessage(`ERROR - can't save ${filename}`, 'error');
142
135
  return false;
143
136
  }
144
-
145
137
  return true;
146
138
  });
147
139
  }
140
+
148
141
  /**
149
142
  * Append text data to file
150
143
  * @param {String} data text data
151
144
  * @param {String} filename file name
152
145
  */
153
-
154
146
  export function appendTextToFile(data, filename) {
155
147
  try {
156
148
  fs.appendFileSync(filename, data);
@@ -158,6 +150,7 @@ export function appendTextToFile(data, filename) {
158
150
  printMessage(`${error.message}`, 'error');
159
151
  }
160
152
  }
153
+
161
154
  /**
162
155
  * Find files by name
163
156
  * @param {string} fileName file name to search for
@@ -165,40 +158,38 @@ export function appendTextToFile(data, filename) {
165
158
  * @param {string} path path to directory where to start the search
166
159
  * @returns {string[]} array of found file paths relative to starting directory
167
160
  */
168
-
169
161
  export function findFilesByName(fileName, fast = true, path = './') {
170
162
  const entries = fs.readdirSync(path, {
171
163
  encoding: 'utf8',
172
164
  withFileTypes: true
173
- }); // Get files within the current directory and add a path key to the file objects
165
+ });
174
166
 
175
- const files = entries.filter(entry => !entry.isDirectory()).filter(file => file.name === fileName) // .map((file) => ({ ...file, path: path + file.name }));
167
+ // Get files within the current directory and add a path key to the file objects
168
+ const files = entries.filter(entry => !entry.isDirectory()).filter(file => file.name === fileName)
169
+ // .map((file) => ({ ...file, path: path + file.name }));
176
170
  .map(file => path + file.name);
177
- if (fast && files.length > 0) return files; // search sub-folders
171
+ if (fast && files.length > 0) return files;
178
172
 
173
+ // search sub-folders
179
174
  const folders = entries.filter(entry => entry.isDirectory());
180
-
181
175
  for (const folder of folders) files.push(...findFilesByName(fileName, fast, `${path}${folder.name}/`));
182
-
183
176
  return files;
184
177
  }
178
+
185
179
  /**
186
180
  * find all (nested) files in a directory
187
181
  *
188
182
  * @param directory directory to search
189
183
  * @returns list of files
190
184
  */
191
-
192
185
  export async function readFilesRecursive(directory) {
193
186
  const items = await readdir(directory);
194
187
  const filePathsNested = await Promise.all(items.map(async entity => {
195
188
  const path = join(directory, entity);
196
189
  const isDirectory = (await lstat(path)).isDirectory();
197
-
198
190
  if (isDirectory) {
199
191
  return readFilesRecursive(path);
200
192
  }
201
-
202
193
  return path;
203
194
  }));
204
195
  return filePathsNested.flat();
@@ -1,6 +1,7 @@
1
1
  import { resolve } from 'path';
2
2
  import { rmSync, existsSync, readFileSync } from 'fs';
3
- import { convertTextArrayToBase64, convertBase64TextToArray, saveToFile, validateImport } from './ExportImportUtils'; // Warning! implimentation file contains non determinisitc functions which are either; not reasonable to test or imposible
3
+ import { convertTextArrayToBase64, convertBase64TextToArray, saveToFile, validateImport } from './ExportImportUtils';
4
+ // Warning! implimentation file contains non determinisitc functions which are either; not reasonable to test or imposible
4
5
  // Cause: date based non overidable functions
5
6
  // Not tested: getCurrentTimestamp
6
7
 
@@ -13,10 +14,10 @@ test('convertBase64TextToArray returns an array of text lines in base64 encoding
13
14
  return 'ring to mt doom';
14
15
  }
15
16
  `;
16
- const base64Script = Buffer.from(originalScript).toString('base64'); // Act
17
-
18
- const result = convertBase64TextToArray(base64Script); // Assert
19
-
17
+ const base64Script = Buffer.from(originalScript).toString('base64');
18
+ // Act
19
+ const result = convertBase64TextToArray(base64Script);
20
+ // Assert
20
21
  expect(result).toEqual(originalScript.split('\n'));
21
22
  });
22
23
  test('convertTextArrayToBase64', () => {
@@ -26,16 +27,17 @@ test('convertTextArrayToBase64', () => {
26
27
  return 'ring to mt doom';
27
28
  }
28
29
  `;
29
- const expected = Buffer.from(originalArrayOfScriptLines).toString('base64'); // Act
30
-
31
- const result = convertTextArrayToBase64(originalArrayOfScriptLines.split('\n')); // Assert
32
-
30
+ const expected = Buffer.from(originalArrayOfScriptLines).toString('base64');
31
+ // Act
32
+ const result = convertTextArrayToBase64(originalArrayOfScriptLines.split('\n'));
33
+ // Assert
33
34
  expect(result).toEqual(expected);
34
35
  });
35
36
  test('validateImport should always return true', () => {
36
37
  expect(validateImport(null)).not.toBe(false);
37
- }); // This function has no way to determine when its asnyc task is complete, suggest using callback or promises to allow for testing
38
+ });
38
39
 
40
+ // This function has no way to determine when its asnyc task is complete, suggest using callback or promises to allow for testing
39
41
  describe.skip('file system based tests', () => {
40
42
  afterAll(() => {
41
43
  if (existsSync(PATH_TO_ARTIFACT)) {
@@ -60,11 +62,11 @@ describe.skip('file system based tests', () => {
60
62
  words: 1064
61
63
  }
62
64
  }
63
- }; // Act
64
-
65
+ };
66
+ // Act
65
67
  saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
66
- const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8')); // Assert
67
-
68
+ const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
69
+ // Assert
68
70
  expect(resultingJSON.lotr).toEqual(expected.lotr);
69
71
  });
70
72
  test('saveToFile should save a file with metadata', async () => {
@@ -75,11 +77,11 @@ describe.skip('file system based tests', () => {
75
77
  location: 'The Shire',
76
78
  character: 'Gandalf',
77
79
  words: 1064
78
- }]; // Act
79
-
80
+ }];
81
+ // Act
80
82
  saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
81
- const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8')); // Assert
82
-
83
+ const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
84
+ // Assert
83
85
  expect(Object.keys(resultingJSON.meta)).toEqual(['origin', 'exportedBy', 'exportDate', 'exportTool', 'exportToolVersion']);
84
86
  });
85
87
  });
@@ -1,50 +1,49 @@
1
- import storage from '../../storage/SessionStorage';
2
- import * as global from '../../storage/StaticStorage';
1
+ import * as state from '../../shared/State';
2
+ import * as globalConfig from '../../storage/StaticStorage';
3
3
  import { getCurrentRealmName, getRealmName as _getRealmName } from '../../api/utils/ApiUtils';
4
4
  import { lstat, readdir, readFile } from 'fs/promises';
5
5
  import { join } from 'path';
6
- import replaceall from 'replaceall'; // TODO: do we really need this? if yes: document
6
+ import replaceall from 'replaceall';
7
7
 
8
+ // TODO: do we really need this? if yes: document
8
9
  export function escapeRegExp(str) {
9
10
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
10
- } // TODO: do we really need this? if yes: document
11
+ }
11
12
 
13
+ // TODO: do we really need this? if yes: document
12
14
  export function replaceAll(str, find, replace) {
13
15
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
14
16
  }
17
+
15
18
  /**
16
19
  * Get new name when names collide
17
20
  * @param {String} name to apply policy to
18
21
  * @returns {String} new name according to policy
19
22
  */
20
-
21
23
  export function applyNameCollisionPolicy(name) {
22
24
  const capturingRegex = /(.* - imported) \(([0-9]+)\)/;
23
25
  const found = name.match(capturingRegex);
24
-
25
26
  if (found && found.length > 0 && found.length === 3) {
26
27
  // already renamed one or more times
27
28
  // return the next number
28
29
  return `${found[1]} (${parseInt(found[2], 10) + 1})`;
29
- } // first time
30
-
31
-
30
+ }
31
+ // first time
32
32
  return `${name} - imported (1)`;
33
33
  }
34
+
34
35
  /**
35
36
  * Get the name of the managed user object for the current realm
36
37
  * @returns {String} the name of the managed user object for the current realm
37
38
  */
38
-
39
39
  export function getRealmManagedUser() {
40
40
  let realmManagedUser = 'user';
41
-
42
- if (storage.session.getDeploymentType() === global.CLOUD_DEPLOYMENT_TYPE_KEY) {
41
+ if (state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY) {
43
42
  realmManagedUser = `${getCurrentRealmName()}_user`;
44
43
  }
45
-
46
44
  return realmManagedUser;
47
45
  }
46
+
48
47
  /**
49
48
  * Compare two json objects
50
49
  * @param {Object} obj1 object 1
@@ -52,15 +51,12 @@ export function getRealmManagedUser() {
52
51
  * @param {[String]} ignoreKeys array of keys to ignore in comparison
53
52
  * @returns {boolean} true if the two json objects have the same length and all the properties have the same value
54
53
  */
55
-
56
54
  export function isEqualJson(obj1, obj2, ignoreKeys = []) {
57
55
  const obj1Keys = Object.keys(obj1).filter(key => !ignoreKeys.includes(key));
58
56
  const obj2Keys = Object.keys(obj2).filter(key => !ignoreKeys.includes(key));
59
-
60
57
  if (obj1Keys.length !== obj2Keys.length) {
61
58
  return false;
62
59
  }
63
-
64
60
  for (const objKey of obj1Keys) {
65
61
  if (obj1[objKey] !== obj2[objKey]) {
66
62
  if (typeof obj1[objKey] === 'object' && typeof obj2[objKey] === 'object') {
@@ -72,18 +68,18 @@ export function isEqualJson(obj1, obj2, ignoreKeys = []) {
72
68
  }
73
69
  }
74
70
  }
75
-
76
71
  return true;
77
72
  }
73
+
78
74
  /**
79
75
  * Get current realm name
80
76
  * @param {String} realm realm
81
77
  * @returns {String} name of the realm. /alpha -> alpha
82
78
  */
83
-
84
79
  export function getRealmName(realm) {
85
80
  return _getRealmName(realm);
86
81
  }
82
+
87
83
  /**
88
84
  * find all (nested) files in a directory
89
85
  *
@@ -91,7 +87,6 @@ export function getRealmName(realm) {
91
87
  * @param childDirectory subdirectory to search
92
88
  * @returns list of files
93
89
  */
94
-
95
90
  export async function readFiles(baseDirectory, childDirectory = '') {
96
91
  const targetDirectory = join(baseDirectory, childDirectory);
97
92
  const directoryItems = await readdir(targetDirectory);
@@ -99,11 +94,9 @@ export async function readFiles(baseDirectory, childDirectory = '') {
99
94
  const filePathsNested = await Promise.all(childPaths.map(async childPath => {
100
95
  const path = join(baseDirectory, childPath);
101
96
  const isDirectory = (await lstat(path)).isDirectory();
102
-
103
97
  if (isDirectory) {
104
98
  return readFiles(baseDirectory, childPath);
105
99
  }
106
-
107
100
  return {
108
101
  path: childPath,
109
102
  content: await readFile(path, 'utf8')
@@ -123,4 +116,17 @@ export function unSubstituteEnvParams(input, reader) {
123
116
  });
124
117
  return input;
125
118
  }
119
+
120
+ /**
121
+ * Check if a string is a valid URL
122
+ * @param {string} urlString input string to be evaluated
123
+ * @returns {boolean} true if a valid URL, false otherwise
124
+ */
125
+ export function isValidUrl(urlString) {
126
+ try {
127
+ return Boolean(new URL(urlString));
128
+ } catch (error) {
129
+ return false;
130
+ }
131
+ }
126
132
  //# sourceMappingURL=OpsUtils.js.map
@@ -1,50 +1,178 @@
1
- import { getRealmManagedUser } from './OpsUtils';
2
- import sessionStorage from '../../storage/SessionStorage';
1
+ import * as OpsUtils from './OpsUtils';
2
+ import * as state from '../../shared/State';
3
3
  import { CLOUD_DEPLOYMENT_TYPE_KEY, FORGEOPS_DEPLOYMENT_TYPE_KEY, CLASSIC_DEPLOYMENT_TYPE_KEY } from '../../storage/StaticStorage';
4
- describe('OpsUtils', () => {
5
- test('getRealmManagedUser should prepend realm to managed user type in identity cloud', () => {
4
+ describe('OpsUtils - getRealmManagedUser()', () => {
5
+ test('getRealmManagedUser() 0: Method is implemented', async () => {
6
+ expect(OpsUtils.getRealmManagedUser).toBeDefined();
7
+ });
8
+ test('getRealmManagedUser() 1: should prepend realm to managed user type in identity cloud', () => {
6
9
  // Arrange
7
10
  const REALM = 'alpha';
8
11
  const DEPLOYMENT_TYPE = CLOUD_DEPLOYMENT_TYPE_KEY;
9
- sessionStorage.session.setRealm(REALM);
10
- sessionStorage.session.setDeploymentType(DEPLOYMENT_TYPE); // Act
11
-
12
- const testString = getRealmManagedUser(); // Assert
13
-
12
+ state.setRealm(REALM);
13
+ state.setDeploymentType(DEPLOYMENT_TYPE);
14
+ // Act
15
+ const testString = OpsUtils.getRealmManagedUser();
16
+ // Assert
14
17
  expect(testString).toBe('alpha_user');
15
18
  });
16
- test('getCurrentRealmPath should prepend realm without leading slash to managed user type in identity cloud', () => {
19
+ test('getRealmManagedUser() 2: should prepend realm without leading slash to managed user type in identity cloud', () => {
17
20
  // Arrange
18
21
  const REALM = '/alpha';
19
22
  const DEPLOYMENT_TYPE = CLOUD_DEPLOYMENT_TYPE_KEY;
20
- sessionStorage.session.setRealm(REALM);
21
- sessionStorage.session.setDeploymentType(DEPLOYMENT_TYPE); // Act
22
-
23
- const testString = getRealmManagedUser(); // Assert
24
-
23
+ state.setRealm(REALM);
24
+ state.setDeploymentType(DEPLOYMENT_TYPE);
25
+ // Act
26
+ const testString = OpsUtils.getRealmManagedUser();
27
+ // Assert
25
28
  expect(testString).toBe('alpha_user');
26
29
  });
27
- test('getRealmManagedUser should not prepend realm to managed user type in forgeops deployments', () => {
30
+ test('getRealmManagedUser() 3: should not prepend realm to managed user type in forgeops deployments', () => {
28
31
  // Arrange
29
32
  const REALM = 'alpha';
30
33
  const DEPLOYMENT_TYPE = FORGEOPS_DEPLOYMENT_TYPE_KEY;
31
- sessionStorage.session.setRealm(REALM);
32
- sessionStorage.session.setDeploymentType(DEPLOYMENT_TYPE); // Act
33
-
34
- const testString = getRealmManagedUser(); // Assert
35
-
34
+ state.setRealm(REALM);
35
+ state.setDeploymentType(DEPLOYMENT_TYPE);
36
+ // Act
37
+ const testString = OpsUtils.getRealmManagedUser();
38
+ // Assert
36
39
  expect(testString).toBe('user');
37
40
  });
38
- test('getRealmManagedUser should not prepend realm to managed user type in classic deployments', () => {
41
+ test('getRealmManagedUser() 4: should not prepend realm to managed user type in classic deployments', () => {
39
42
  // Arrange
40
43
  const REALM = 'alpha';
41
44
  const DEPLOYMENT_TYPE = CLASSIC_DEPLOYMENT_TYPE_KEY;
42
- sessionStorage.session.setRealm(REALM);
43
- sessionStorage.session.setDeploymentType(DEPLOYMENT_TYPE); // Act
44
-
45
- const testString = getRealmManagedUser(); // Assert
46
-
45
+ state.setRealm(REALM);
46
+ state.setDeploymentType(DEPLOYMENT_TYPE);
47
+ // Act
48
+ const testString = OpsUtils.getRealmManagedUser();
49
+ // Assert
47
50
  expect(testString).toBe('user');
48
51
  });
49
52
  });
53
+ describe('OpsUtils - isEqualJson()', () => {
54
+ test('isEqualJson() 0: Method is implemented', async () => {
55
+ expect(OpsUtils.isEqualJson).toBeDefined();
56
+ });
57
+ test('isEqualJson() 1: two empty objects should be equal', () => {
58
+ const obj1 = {};
59
+ const obj2 = {};
60
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
61
+ });
62
+ test('isEqualJson() 2: two objects with single and equal entry should be equal', () => {
63
+ const obj1 = {
64
+ key: 'value'
65
+ };
66
+ const obj2 = {
67
+ key: 'value'
68
+ };
69
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
70
+ });
71
+ test('isEqualJson() 3: two objects with equal key but different value should not be equal', () => {
72
+ const obj1 = {
73
+ key: 'value1'
74
+ };
75
+ const obj2 = {
76
+ key: 'value2'
77
+ };
78
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
79
+ });
80
+ test('isEqualJson() 4: two objects with differing keys but equal values should not be equal', () => {
81
+ const obj1 = {
82
+ key1: 'value'
83
+ };
84
+ const obj2 = {
85
+ key2: 'value'
86
+ };
87
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
88
+ });
89
+ test('isEqualJson() 5: two objects with unequal amounts of entries should not be equal', () => {
90
+ const obj1 = {
91
+ key1: 'value'
92
+ };
93
+ const obj2 = {
94
+ key1: 'value',
95
+ key2: 'value2'
96
+ };
97
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
98
+ });
99
+ test('isEqualJson() 6: two objects with equal but nested keys should be equal', () => {
100
+ const obj1 = {
101
+ key1: 'value1',
102
+ key2: {
103
+ key3: 'value3'
104
+ }
105
+ };
106
+ const obj2 = {
107
+ key1: 'value1',
108
+ key2: {
109
+ key3: 'value3'
110
+ }
111
+ };
112
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
113
+ });
114
+ test('isEqualJson() 7: two objects with equal but multi-nested keys should be equal', () => {
115
+ const obj1 = {
116
+ key1: 'value1',
117
+ key2: {
118
+ key3: 'value3',
119
+ key4: {
120
+ key5: 'value5'
121
+ }
122
+ }
123
+ };
124
+ const obj2 = {
125
+ key1: 'value1',
126
+ key2: {
127
+ key3: 'value3',
128
+ key4: {
129
+ key5: 'value5'
130
+ }
131
+ }
132
+ };
133
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
134
+ });
135
+ test('isEqualJson() 8: two objects with equal multi-nested keys but unequal values should not be equal', () => {
136
+ const obj1 = {
137
+ key1: 'value1',
138
+ key2: {
139
+ key3: 'value3',
140
+ key4: {
141
+ key5: 'value5'
142
+ }
143
+ }
144
+ };
145
+ const obj2 = {
146
+ key1: 'value1',
147
+ key2: {
148
+ key3: 'value3',
149
+ key4: {
150
+ key5: 'value'
151
+ }
152
+ }
153
+ };
154
+ expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
155
+ });
156
+ test('isEqualJson() 9: two objects with equal multi-nested keys but unequal values with the offending key excluded should be equal', () => {
157
+ const obj1 = {
158
+ key1: 'value1',
159
+ key2: {
160
+ key3: 'value3',
161
+ key4: {
162
+ key5: 'value5'
163
+ }
164
+ }
165
+ };
166
+ const obj2 = {
167
+ key1: 'value1',
168
+ key2: {
169
+ key3: 'value3',
170
+ key4: {
171
+ key5: 'value'
172
+ }
173
+ }
174
+ };
175
+ expect(OpsUtils.isEqualJson(obj1, obj2, ['key5'])).toBeTruthy();
176
+ });
177
+ });
50
178
  //# sourceMappingURL=OpsUtils.test.js.map
@@ -2,42 +2,33 @@ import { parseScript } from 'esprima';
2
2
  import { printMessage } from './Console';
3
3
  export function validateScriptHooks(jsonData) {
4
4
  const scriptHooks = findAllScriptHooks(jsonData);
5
-
6
5
  for (const scriptHook of scriptHooks) {
7
6
  if (!('source' in scriptHook)) {
8
7
  continue;
9
8
  }
10
-
11
9
  if (!isValidJs(scriptHook.source)) {
12
10
  return false;
13
11
  }
14
12
  }
15
-
16
13
  return true;
17
14
  }
18
-
19
15
  function findAllScriptHooks(jsonData, scriptHooksArray = []) {
20
16
  if (typeof jsonData !== 'object' || jsonData === null) {
21
17
  return scriptHooksArray;
22
18
  }
23
-
24
19
  for (const key in jsonData) {
25
20
  const item = jsonData[key];
26
-
27
21
  if (typeof item !== 'object' || item === null) {
28
22
  continue;
29
23
  }
30
-
31
24
  if ('type' in item && item.type === 'text/javascript') {
32
25
  scriptHooksArray.push(item);
33
26
  } else {
34
27
  findAllScriptHooks(item, scriptHooksArray);
35
28
  }
36
29
  }
37
-
38
30
  return scriptHooksArray;
39
31
  }
40
-
41
32
  function isValidJs(javascriptSource) {
42
33
  try {
43
34
  parseScript(javascriptSource);