@rockcarver/frodo-lib 1.0.0 → 2.0.0-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 (406) hide show
  1. package/CHANGELOG.md +3 -7
  2. package/cjs/api/AgentApi.js +91 -37
  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.map +1 -1
  6. package/cjs/api/AuthenticateApi.js +18 -11
  7. package/cjs/api/AuthenticateApi.js.map +1 -1
  8. package/cjs/api/AuthenticateApi.test.js.map +1 -1
  9. package/cjs/api/BaseApi.js +50 -26
  10. package/cjs/api/BaseApi.js.map +1 -1
  11. package/cjs/api/CirclesOfTrustApi.js +47 -23
  12. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  13. package/cjs/api/IdmConfigApi.js +54 -21
  14. package/cjs/api/IdmConfigApi.js.map +1 -1
  15. package/cjs/api/IdmSystemApi.js +9 -6
  16. package/cjs/api/IdmSystemApi.js.map +1 -1
  17. package/cjs/api/ManagedObjectApi.js +49 -27
  18. package/cjs/api/ManagedObjectApi.js.map +1 -1
  19. package/cjs/api/NodeApi.js +71 -32
  20. package/cjs/api/NodeApi.js.map +1 -1
  21. package/cjs/api/NodeApi.test.js.map +1 -1
  22. package/cjs/api/OAuth2ClientApi.js +43 -20
  23. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  24. package/cjs/api/OAuth2OIDCApi.js +74 -27
  25. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  26. package/cjs/api/OAuth2OIDCApi.test.js.map +1 -1
  27. package/cjs/api/OAuth2ProviderApi.js +10 -9
  28. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  29. package/cjs/api/PoliciesApi.js +54 -22
  30. package/cjs/api/PoliciesApi.js.map +1 -1
  31. package/cjs/api/PoliciesApi.test.js.map +1 -1
  32. package/cjs/api/PolicySetApi.js +54 -23
  33. package/cjs/api/PolicySetApi.js.map +1 -1
  34. package/cjs/api/PolicySetApi.test.js.map +1 -1
  35. package/cjs/api/RealmApi.js +73 -29
  36. package/cjs/api/RealmApi.js.map +1 -1
  37. package/cjs/api/ResourceTypesApi.js +67 -28
  38. package/cjs/api/ResourceTypesApi.js.map +1 -1
  39. package/cjs/api/ResourceTypesApi.test.js.map +1 -1
  40. package/cjs/api/Saml2Api.js +90 -122
  41. package/cjs/api/Saml2Api.js.map +1 -1
  42. package/cjs/api/ScriptApi.js +54 -23
  43. package/cjs/api/ScriptApi.js.map +1 -1
  44. package/cjs/api/ServerInfoApi.js +23 -10
  45. package/cjs/api/ServerInfoApi.js.map +1 -1
  46. package/cjs/api/ServiceApi.js +91 -42
  47. package/cjs/api/ServiceApi.js.map +1 -1
  48. package/cjs/api/SocialIdentityProvidersApi.js +70 -31
  49. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  50. package/cjs/api/TreeApi.js +43 -20
  51. package/cjs/api/TreeApi.js.map +1 -1
  52. package/cjs/api/TreeApi.test.js.map +1 -1
  53. package/cjs/api/cloud/EnvInfoApi.js +10 -6
  54. package/cjs/api/cloud/EnvInfoApi.js.map +1 -1
  55. package/cjs/api/cloud/FeatureApi.js +9 -6
  56. package/cjs/api/cloud/FeatureApi.js.map +1 -1
  57. package/cjs/api/cloud/LogApi.js +48 -18
  58. package/cjs/api/cloud/LogApi.js.map +1 -1
  59. package/cjs/api/cloud/SecretsApi.js +109 -35
  60. package/cjs/api/cloud/SecretsApi.js.map +1 -1
  61. package/cjs/api/cloud/SecretsApi.test.js.map +1 -1
  62. package/cjs/api/cloud/StartupApi.js +21 -10
  63. package/cjs/api/cloud/StartupApi.js.map +1 -1
  64. package/cjs/api/cloud/StartupApi.test.js.map +1 -1
  65. package/cjs/api/cloud/VariablesApi.js +52 -20
  66. package/cjs/api/cloud/VariablesApi.js.map +1 -1
  67. package/cjs/api/cloud/VariablesApi.test.js.map +1 -1
  68. package/cjs/api/utils/ApiUtils.js +2 -5
  69. package/cjs/api/utils/ApiUtils.js.map +1 -1
  70. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  71. package/cjs/index.js +22 -17
  72. package/cjs/index.js.map +1 -1
  73. package/cjs/lib/FrodoLib.js +142 -0
  74. package/cjs/lib/FrodoLib.js.map +1 -0
  75. package/cjs/ops/AdminOps.js +578 -90
  76. package/cjs/ops/AdminOps.js.map +1 -1
  77. package/cjs/ops/AgentOps.js +956 -118
  78. package/cjs/ops/AgentOps.js.map +1 -1
  79. package/cjs/ops/AgentOps.test.js.map +1 -1
  80. package/cjs/ops/AuthenticateOps.js +155 -87
  81. package/cjs/ops/AuthenticateOps.js.map +1 -1
  82. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  83. package/cjs/ops/CirclesOfTrustOps.js +334 -291
  84. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  85. package/cjs/ops/ConnectionProfileOps.js +241 -46
  86. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  87. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  88. package/cjs/ops/EmailTemplateOps.js +84 -10
  89. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  90. package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
  91. package/cjs/ops/IdmOps.js +97 -81
  92. package/cjs/ops/IdmOps.js.map +1 -1
  93. package/cjs/ops/IdmOps.test.js.map +1 -1
  94. package/cjs/ops/IdpOps.js +275 -42
  95. package/cjs/ops/IdpOps.js.map +1 -1
  96. package/cjs/ops/IdpOps.test.js.map +1 -1
  97. package/cjs/ops/InfoOps.js +42 -27
  98. package/cjs/ops/InfoOps.js.map +1 -1
  99. package/cjs/ops/JoseOps.test.js.map +1 -1
  100. package/cjs/ops/JourneyOps.js +721 -126
  101. package/cjs/ops/JourneyOps.js.map +1 -1
  102. package/cjs/ops/JourneyOps.test.js.map +1 -1
  103. package/cjs/ops/ManagedObjectOps.js +79 -12
  104. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  105. package/cjs/ops/NodeOps.js +127 -100
  106. package/cjs/ops/NodeOps.js.map +1 -1
  107. package/cjs/ops/OAuth2ClientOps.js +323 -65
  108. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  109. package/cjs/ops/OAuth2ClientOps.test.js.map +1 -1
  110. package/cjs/ops/OAuth2ProviderOps.js +20 -13
  111. package/cjs/ops/OAuth2ProviderOps.js.map +1 -1
  112. package/cjs/ops/OpsTypes.js.map +1 -1
  113. package/cjs/ops/OrganizationOps.js +67 -12
  114. package/cjs/ops/OrganizationOps.js.map +1 -1
  115. package/cjs/ops/PolicyOps.js +476 -136
  116. package/cjs/ops/PolicyOps.js.map +1 -1
  117. package/cjs/ops/PolicyOps.test.js.map +1 -1
  118. package/cjs/ops/PolicySetOps.js +402 -132
  119. package/cjs/ops/PolicySetOps.js.map +1 -1
  120. package/cjs/ops/PolicySetOps.test.js.map +1 -1
  121. package/cjs/ops/RealmOps.js +119 -84
  122. package/cjs/ops/RealmOps.js.map +1 -1
  123. package/cjs/ops/ResourceTypeOps.js +348 -95
  124. package/cjs/ops/ResourceTypeOps.js.map +1 -1
  125. package/cjs/ops/ResourceTypeOps.test.js.map +1 -1
  126. package/cjs/ops/Saml2Ops.js +407 -145
  127. package/cjs/ops/Saml2Ops.js.map +1 -1
  128. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  129. package/cjs/ops/ScriptOps.js +256 -79
  130. package/cjs/ops/ScriptOps.js.map +1 -1
  131. package/cjs/ops/ScriptOps.test.js.map +1 -1
  132. package/cjs/ops/ServiceOps.js +328 -55
  133. package/cjs/ops/ServiceOps.js.map +1 -1
  134. package/cjs/ops/ThemeOps.js +349 -54
  135. package/cjs/ops/ThemeOps.js.map +1 -1
  136. package/cjs/ops/ThemeOps.test.js.map +1 -1
  137. package/cjs/ops/cloud/FeatureOps.js +57 -12
  138. package/cjs/ops/cloud/FeatureOps.js.map +1 -1
  139. package/cjs/ops/cloud/LogOps.js +136 -6
  140. package/cjs/ops/cloud/LogOps.js.map +1 -1
  141. package/cjs/ops/cloud/SecretsOps.js +230 -289
  142. package/cjs/ops/cloud/SecretsOps.js.map +1 -1
  143. package/cjs/ops/cloud/ServiceAccountOps.js +101 -18
  144. package/cjs/ops/cloud/ServiceAccountOps.js.map +1 -1
  145. package/cjs/ops/cloud/ServiceAccountOps.test.js.map +1 -1
  146. package/cjs/ops/cloud/StartupOps.js +64 -9
  147. package/cjs/ops/cloud/StartupOps.js.map +1 -1
  148. package/cjs/ops/cloud/VariablesOps.js +100 -175
  149. package/cjs/ops/cloud/VariablesOps.js.map +1 -1
  150. package/cjs/ops/utils/Console.js +9 -10
  151. package/cjs/ops/utils/Console.js.map +1 -1
  152. package/cjs/ops/utils/DataProtection.js +2 -2
  153. package/cjs/ops/utils/DataProtection.js.map +1 -1
  154. package/cjs/ops/utils/ExportImportUtils.js +35 -13
  155. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  156. package/cjs/ops/utils/OpsUtils.js +7 -5
  157. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  158. package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
  159. package/cjs/ops/utils/{ValidationUtils.js → ScriptValidationUtils.js} +1 -1
  160. package/cjs/ops/utils/ScriptValidationUtils.js.map +1 -0
  161. package/cjs/ops/utils/ScriptValidationUtils.test.js.map +1 -0
  162. package/cjs/ops/utils/Version.js +9 -2
  163. package/cjs/ops/utils/Version.js.map +1 -1
  164. package/cjs/shared/State.js +455 -210
  165. package/cjs/shared/State.js.map +1 -1
  166. package/cjs/shared/State.test.js.map +1 -1
  167. package/cjs/utils/AutoSetupPolly.js +4 -1
  168. package/cjs/utils/AutoSetupPolly.js.map +1 -1
  169. package/esm/api/AgentApi.mjs +75 -27
  170. package/esm/api/AgentApi.test.mjs +319 -71
  171. package/esm/api/AuthenticateApi.mjs +15 -4
  172. package/esm/api/AuthenticateApi.test.mjs +27 -8
  173. package/esm/api/BaseApi.mjs +43 -19
  174. package/esm/api/CirclesOfTrustApi.mjs +39 -17
  175. package/esm/api/IdmConfigApi.mjs +44 -13
  176. package/esm/api/IdmSystemApi.mjs +7 -3
  177. package/esm/api/ManagedObjectApi.mjs +44 -20
  178. package/esm/api/NodeApi.mjs +59 -24
  179. package/esm/api/NodeApi.test.mjs +158 -40
  180. package/esm/api/OAuth2ClientApi.mjs +36 -15
  181. package/esm/api/OAuth2OIDCApi.mjs +69 -20
  182. package/esm/api/OAuth2OIDCApi.test.mjs +21 -3
  183. package/esm/api/OAuth2ProviderApi.mjs +8 -6
  184. package/esm/api/PoliciesApi.mjs +45 -16
  185. package/esm/api/PoliciesApi.test.mjs +63 -15
  186. package/esm/api/PolicySetApi.mjs +44 -16
  187. package/esm/api/PolicySetApi.test.mjs +48 -12
  188. package/esm/api/RealmApi.mjs +65 -24
  189. package/esm/api/ResourceTypesApi.mjs +56 -21
  190. package/esm/api/ResourceTypesApi.test.mjs +58 -14
  191. package/esm/api/Saml2Api.mjs +75 -89
  192. package/esm/api/ScriptApi.mjs +45 -17
  193. package/esm/api/ServerInfoApi.mjs +19 -6
  194. package/esm/api/ServiceApi.mjs +77 -26
  195. package/esm/api/SocialIdentityProvidersApi.mjs +58 -23
  196. package/esm/api/TreeApi.mjs +36 -15
  197. package/esm/api/TreeApi.test.mjs +129 -34
  198. package/esm/api/cloud/EnvInfoApi.mjs +8 -3
  199. package/esm/api/cloud/FeatureApi.mjs +7 -3
  200. package/esm/api/cloud/LogApi.mjs +38 -11
  201. package/esm/api/cloud/SecretsApi.mjs +89 -21
  202. package/esm/api/cloud/SecretsApi.test.mjs +193 -50
  203. package/esm/api/cloud/StartupApi.mjs +17 -6
  204. package/esm/api/cloud/StartupApi.test.mjs +28 -11
  205. package/esm/api/cloud/VariablesApi.mjs +43 -14
  206. package/esm/api/cloud/VariablesApi.test.mjs +124 -33
  207. package/esm/api/utils/ApiUtils.mjs +2 -4
  208. package/esm/api/utils/ApiUtils.test.mjs +14 -6
  209. package/esm/index.mjs +3 -4
  210. package/esm/lib/FrodoLib.mjs +127 -0
  211. package/esm/ops/AdminOps.mjs +500 -71
  212. package/esm/ops/AgentOps.mjs +773 -81
  213. package/esm/ops/AgentOps.test.mjs +296 -113
  214. package/esm/ops/AuthenticateOps.mjs +136 -64
  215. package/esm/ops/AuthenticateOps.test.mjs +7 -4
  216. package/esm/ops/CirclesOfTrustOps.mjs +278 -229
  217. package/esm/ops/ConnectionProfileOps.mjs +206 -35
  218. package/esm/ops/ConnectionProfileOps.test.mjs +25 -5
  219. package/esm/ops/EmailTemplateOps.mjs +66 -6
  220. package/esm/ops/EmailTemplateOps.test.mjs +32 -11
  221. package/esm/ops/IdmOps.mjs +60 -47
  222. package/esm/ops/IdmOps.test.mjs +54 -18
  223. package/esm/ops/IdpOps.mjs +227 -31
  224. package/esm/ops/IdpOps.test.mjs +57 -20
  225. package/esm/ops/InfoOps.mjs +36 -23
  226. package/esm/ops/JoseOps.test.mjs +8 -0
  227. package/esm/ops/JourneyOps.mjs +634 -96
  228. package/esm/ops/JourneyOps.test.mjs +73 -31
  229. package/esm/ops/ManagedObjectOps.mjs +66 -10
  230. package/esm/ops/NodeOps.mjs +108 -85
  231. package/esm/ops/OAuth2ClientOps.mjs +258 -42
  232. package/esm/ops/OAuth2ClientOps.test.mjs +80 -29
  233. package/esm/ops/OAuth2ProviderOps.mjs +11 -8
  234. package/esm/ops/OrganizationOps.mjs +56 -8
  235. package/esm/ops/PolicyOps.mjs +379 -93
  236. package/esm/ops/PolicyOps.test.mjs +180 -65
  237. package/esm/ops/PolicySetOps.mjs +311 -88
  238. package/esm/ops/PolicySetOps.test.mjs +108 -39
  239. package/esm/ops/RealmOps.mjs +85 -65
  240. package/esm/ops/ResourceTypeOps.mjs +268 -61
  241. package/esm/ops/ResourceTypeOps.test.mjs +113 -27
  242. package/esm/ops/Saml2Ops.mjs +346 -106
  243. package/esm/ops/Saml2Ops.test.mjs +117 -81
  244. package/esm/ops/ScriptOps.mjs +202 -56
  245. package/esm/ops/ScriptOps.test.mjs +64 -23
  246. package/esm/ops/ServiceOps.mjs +258 -27
  247. package/esm/ops/ThemeOps.mjs +300 -33
  248. package/esm/ops/ThemeOps.test.mjs +197 -47
  249. package/esm/ops/cloud/FeatureOps.mjs +45 -10
  250. package/esm/ops/cloud/LogOps.mjs +117 -4
  251. package/esm/ops/cloud/SecretsOps.mjs +123 -204
  252. package/esm/ops/cloud/ServiceAccountOps.mjs +85 -15
  253. package/esm/ops/cloud/ServiceAccountOps.test.mjs +16 -6
  254. package/esm/ops/cloud/StartupOps.mjs +49 -6
  255. package/esm/ops/cloud/VariablesOps.mjs +58 -120
  256. package/esm/ops/utils/Console.mjs +9 -8
  257. package/esm/ops/utils/DataProtection.mjs +2 -3
  258. package/esm/ops/utils/ExportImportUtils.mjs +28 -8
  259. package/esm/ops/utils/OpsUtils.mjs +4 -3
  260. package/esm/ops/utils/OpsUtils.test.mjs +21 -5
  261. package/esm/ops/utils/{ValidationUtils.mjs → ScriptValidationUtils.mjs} +1 -1
  262. package/esm/ops/utils/{ValidationUtils.test.mjs → ScriptValidationUtils.test.mjs} +2 -2
  263. package/esm/ops/utils/Version.mjs +8 -2
  264. package/esm/shared/State.mjs +459 -145
  265. package/esm/shared/State.test.mjs +8 -0
  266. package/esm/utils/AutoSetupPolly.mjs +4 -1
  267. package/package.json +1 -1
  268. package/types/api/AgentApi.d.ts +37 -8
  269. package/types/api/AgentApi.d.ts.map +1 -1
  270. package/types/api/ApiTypes.d.ts +12 -0
  271. package/types/api/ApiTypes.d.ts.map +1 -1
  272. package/types/api/AuthenticateApi.d.ts +13 -3
  273. package/types/api/AuthenticateApi.d.ts.map +1 -1
  274. package/types/api/BaseApi.d.ts +36 -7
  275. package/types/api/BaseApi.d.ts.map +1 -1
  276. package/types/api/CirclesOfTrustApi.d.ts +21 -7
  277. package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
  278. package/types/api/IdmConfigApi.d.ts +28 -13
  279. package/types/api/IdmConfigApi.d.ts.map +1 -1
  280. package/types/api/IdmSystemApi.d.ts +4 -1
  281. package/types/api/IdmSystemApi.d.ts.map +1 -1
  282. package/types/api/ManagedObjectApi.d.ts +25 -10
  283. package/types/api/ManagedObjectApi.d.ts.map +1 -1
  284. package/types/api/NodeApi.d.ts +31 -9
  285. package/types/api/NodeApi.d.ts.map +1 -1
  286. package/types/api/OAuth2ClientApi.d.ts +18 -5
  287. package/types/api/OAuth2ClientApi.d.ts.map +1 -1
  288. package/types/api/OAuth2OIDCApi.d.ts +45 -11
  289. package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
  290. package/types/api/OAuth2ProviderApi.d.ts +4 -1
  291. package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
  292. package/types/api/PoliciesApi.d.ts +21 -5
  293. package/types/api/PoliciesApi.d.ts.map +1 -1
  294. package/types/api/PolicySetApi.d.ts +20 -5
  295. package/types/api/PolicySetApi.d.ts.map +1 -1
  296. package/types/api/RealmApi.d.ts +26 -10
  297. package/types/api/RealmApi.d.ts.map +1 -1
  298. package/types/api/ResourceTypesApi.d.ts +27 -8
  299. package/types/api/ResourceTypesApi.d.ts.map +1 -1
  300. package/types/api/Saml2Api.d.ts +39 -32
  301. package/types/api/Saml2Api.d.ts.map +1 -1
  302. package/types/api/ScriptApi.d.ts +21 -5
  303. package/types/api/ScriptApi.d.ts.map +1 -1
  304. package/types/api/ServerInfoApi.d.ts +9 -2
  305. package/types/api/ServerInfoApi.d.ts.map +1 -1
  306. package/types/api/ServiceApi.d.ts +41 -7
  307. package/types/api/ServiceApi.d.ts.map +1 -1
  308. package/types/api/SocialIdentityProvidersApi.d.ts +30 -8
  309. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
  310. package/types/api/TreeApi.d.ts +18 -4
  311. package/types/api/TreeApi.d.ts.map +1 -1
  312. package/types/api/cloud/EnvInfoApi.d.ts +4 -1
  313. package/types/api/cloud/EnvInfoApi.d.ts.map +1 -1
  314. package/types/api/cloud/FeatureApi.d.ts +4 -1
  315. package/types/api/cloud/FeatureApi.d.ts.map +1 -1
  316. package/types/api/cloud/LogApi.d.ts +24 -6
  317. package/types/api/cloud/LogApi.d.ts.map +1 -1
  318. package/types/api/cloud/SecretsApi.d.ts +50 -10
  319. package/types/api/cloud/SecretsApi.d.ts.map +1 -1
  320. package/types/api/cloud/StartupApi.d.ts +7 -2
  321. package/types/api/cloud/StartupApi.d.ts.map +1 -1
  322. package/types/api/cloud/VariablesApi.d.ts +23 -5
  323. package/types/api/cloud/VariablesApi.d.ts.map +1 -1
  324. package/types/api/utils/ApiUtils.d.ts +3 -2
  325. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  326. package/types/index.d.ts +2 -2
  327. package/types/index.d.ts.map +1 -1
  328. package/types/lib/FrodoLib.d.ts +95 -0
  329. package/types/lib/FrodoLib.d.ts.map +1 -0
  330. package/types/ops/AdminOps.d.ts +71 -12
  331. package/types/ops/AdminOps.d.ts.map +1 -1
  332. package/types/ops/AgentOps.d.ts +345 -36
  333. package/types/ops/AgentOps.d.ts.map +1 -1
  334. package/types/ops/AuthenticateOps.d.ts +18 -5
  335. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  336. package/types/ops/CirclesOfTrustOps.d.ts +76 -26
  337. package/types/ops/CirclesOfTrustOps.d.ts.map +1 -1
  338. package/types/ops/ConnectionProfileOps.d.ts +88 -9
  339. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  340. package/types/ops/EmailTemplateOps.d.ts +36 -3
  341. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  342. package/types/ops/IdmOps.d.ts +28 -40
  343. package/types/ops/IdmOps.d.ts.map +1 -1
  344. package/types/ops/IdpOps.d.ts +88 -10
  345. package/types/ops/IdpOps.d.ts.map +1 -1
  346. package/types/ops/InfoOps.d.ts +12 -1
  347. package/types/ops/InfoOps.d.ts.map +1 -1
  348. package/types/ops/JourneyOps.d.ts +237 -34
  349. package/types/ops/JourneyOps.d.ts.map +1 -1
  350. package/types/ops/ManagedObjectOps.d.ts +37 -8
  351. package/types/ops/ManagedObjectOps.d.ts.map +1 -1
  352. package/types/ops/NodeOps.d.ts +61 -6
  353. package/types/ops/NodeOps.d.ts.map +1 -1
  354. package/types/ops/OAuth2ClientOps.d.ts +104 -10
  355. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  356. package/types/ops/OAuth2ProviderOps.d.ts +8 -5
  357. package/types/ops/OAuth2ProviderOps.d.ts.map +1 -1
  358. package/types/ops/OpsTypes.d.ts +12 -1
  359. package/types/ops/OpsTypes.d.ts.map +1 -1
  360. package/types/ops/OrganizationOps.d.ts +24 -3
  361. package/types/ops/OrganizationOps.d.ts.map +1 -1
  362. package/types/ops/PolicyOps.d.ts +103 -28
  363. package/types/ops/PolicyOps.d.ts.map +1 -1
  364. package/types/ops/PolicySetOps.d.ts +76 -30
  365. package/types/ops/PolicySetOps.d.ts.map +1 -1
  366. package/types/ops/RealmOps.d.ts +34 -14
  367. package/types/ops/RealmOps.d.ts.map +1 -1
  368. package/types/ops/ResourceTypeOps.d.ts +116 -29
  369. package/types/ops/ResourceTypeOps.d.ts.map +1 -1
  370. package/types/ops/Saml2Ops.d.ts +124 -41
  371. package/types/ops/Saml2Ops.d.ts.map +1 -1
  372. package/types/ops/ScriptOps.d.ts +88 -23
  373. package/types/ops/ScriptOps.d.ts.map +1 -1
  374. package/types/ops/ServiceOps.d.ts +94 -8
  375. package/types/ops/ServiceOps.d.ts.map +1 -1
  376. package/types/ops/ThemeOps.d.ts +113 -9
  377. package/types/ops/ThemeOps.d.ts.map +1 -1
  378. package/types/ops/cloud/FeatureOps.d.ts +23 -2
  379. package/types/ops/cloud/FeatureOps.d.ts.map +1 -1
  380. package/types/ops/cloud/LogOps.d.ts +61 -3
  381. package/types/ops/cloud/LogOps.d.ts.map +1 -1
  382. package/types/ops/cloud/SecretsOps.d.ts +77 -63
  383. package/types/ops/cloud/SecretsOps.d.ts.map +1 -1
  384. package/types/ops/cloud/ServiceAccountOps.d.ts +48 -3
  385. package/types/ops/cloud/ServiceAccountOps.d.ts.map +1 -1
  386. package/types/ops/cloud/StartupOps.d.ts +25 -2
  387. package/types/ops/cloud/StartupOps.d.ts.map +1 -1
  388. package/types/ops/cloud/VariablesOps.d.ts +39 -39
  389. package/types/ops/cloud/VariablesOps.d.ts.map +1 -1
  390. package/types/ops/utils/Console.d.ts.map +1 -1
  391. package/types/ops/utils/DataProtection.d.ts +1 -1
  392. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  393. package/types/ops/utils/ExportImportUtils.d.ts +29 -11
  394. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  395. package/types/ops/utils/OpsUtils.d.ts +4 -1
  396. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  397. package/types/ops/utils/ScriptValidationUtils.d.ts.map +1 -0
  398. package/types/ops/utils/Version.d.ts +5 -1
  399. package/types/ops/utils/Version.d.ts.map +1 -1
  400. package/types/shared/State.d.ts +80 -177
  401. package/types/shared/State.d.ts.map +1 -1
  402. package/types/utils/AutoSetupPolly.d.ts.map +1 -1
  403. package/cjs/ops/utils/ValidationUtils.js.map +0 -1
  404. package/cjs/ops/utils/ValidationUtils.test.js.map +0 -1
  405. package/types/ops/utils/ValidationUtils.d.ts.map +0 -1
  406. /package/types/ops/utils/{ValidationUtils.d.ts → ScriptValidationUtils.d.ts} +0 -0
@@ -1,283 +1,332 @@
1
- import fs from 'fs';
2
- import _ from 'lodash';
3
- import { createTable, printMessage, createProgressIndicator, updateProgressIndicator, stopProgressIndicator } from './utils/Console';
4
- import { getCirclesOfTrust, getCircleOfTrust, createCircleOfTrust } from '../api/CirclesOfTrustApi';
5
- import { getRealmString, getTypedFilename, saveJsonToFile, validateImport } from './utils/ExportImportUtils';
1
+ import { debugMessage } from './utils/Console';
2
+ import { getCirclesOfTrust as _getCirclesOfTrust, getCircleOfTrust, createCircleOfTrust, updateCircleOfTrust } from '../api/CirclesOfTrustApi';
3
+ import { getMetadata } from './utils/ExportImportUtils';
4
+ export default class CirclesOfTrustOps {
5
+ constructor(state) {
6
+ this.state = state;
7
+ }
6
8
 
7
- // use a function vs a template variable to avoid problems in loops
8
- function getFileDataTemplate() {
9
- return {
10
- meta: {},
11
- script: {},
12
- saml: {
13
- hosted: {},
14
- remote: {},
15
- metadata: {},
16
- cot: {}
17
- }
18
- };
19
- }
9
+ /**
10
+ * Get SAML circle of trust
11
+ * @param {String} cotId circle of trust id/name
12
+ */
13
+ async getCircleOfTrust(cotId) {
14
+ return getCircleOfTrust({
15
+ cotId,
16
+ state: this.state
17
+ });
18
+ }
20
19
 
21
- /**
22
- * List entity providers
23
- * @param {String} long Long list format with details
24
- */
25
- export async function listCirclesOfTrust(long = false) {
26
- let cotList = [];
27
- try {
28
- cotList = (await getCirclesOfTrust()).result;
29
- } catch (error) {
30
- printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');
31
- printMessage(error, 'data');
20
+ /**
21
+ * Get SAML circles of trust
22
+ */
23
+ async getCirclesOfTrust() {
24
+ return getCirclesOfTrust({
25
+ state: this.state
26
+ });
32
27
  }
33
- cotList.sort((a, b) => a._id.localeCompare(b._id));
34
- if (!long) {
35
- cotList.forEach(cot => {
36
- printMessage(`${cot._id}`, 'data');
28
+
29
+ /**
30
+ * Export SAML circle of trust
31
+ * @param {String} cotId circle of trust id/name
32
+ */
33
+ async exportCircleOfTrust(cotId) {
34
+ return exportCircleOfTrust({
35
+ cotId,
36
+ state: this.state
37
37
  });
38
- } else {
39
- const table = createTable(['Name'['brightCyan'], 'Description'['brightCyan'], 'Status'['brightCyan'], 'Trusted Providers'['brightCyan']]);
40
- cotList.forEach(cot => {
41
- table.push([cot._id, cot.description, cot.status, cot.trustedProviders.map(provider => provider.split('|')[0]).join('\n')]);
38
+ }
39
+
40
+ /**
41
+ * Export all SAML circles of trust
42
+ */
43
+ async exportCirclesOfTrust() {
44
+ return exportCirclesOfTrust({
45
+ state: this.state
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Import a SAML circle of trust by id/name from file
51
+ * @param {String} cotId Circle of trust id/name
52
+ * @param {CirclesOfTrustExportInterface} importData Import data
53
+ */
54
+ async importCircleOfTrust(cotId, importData) {
55
+ return importCircleOfTrust({
56
+ cotId,
57
+ importData,
58
+ state: this.state
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Import first SAML circle of trust
64
+ * @param {CirclesOfTrustExportInterface} importData Import data
65
+ */
66
+ async importFirstCircleOfTrust(importData) {
67
+ return importFirstCircleOfTrust({
68
+ importData,
69
+ state: this.state
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Import all SAML circles of trust
75
+ * @param {CirclesOfTrustExportInterface} importData Import file name
76
+ */
77
+ async importCirclesOfTrust(importData) {
78
+ return importCirclesOfTrust({
79
+ importData,
80
+ state: this.state
42
81
  });
43
- printMessage(table.toString());
44
82
  }
45
83
  }
46
84
 
47
85
  /**
48
- * Include dependencies in the export file
49
- * @param {Object} cotData Object representing a SAML circle of trust
50
- * @param {Object} fileData File data object to add dependencies to
86
+ * Create an empty agent export template
87
+ * @returns {CirclesOfTrustExportInterface} an empty agent export template
51
88
  */
52
- async function exportDependencies(cotData, fileData) {
53
- // TODO: Export dependencies
54
- return [cotData, fileData];
89
+ function createCirclesOfTrustExportTemplate({
90
+ state
91
+ }) {
92
+ return {
93
+ meta: getMetadata({
94
+ state
95
+ }),
96
+ script: {},
97
+ saml: {
98
+ hosted: {},
99
+ remote: {},
100
+ metadata: {},
101
+ cot: {}
102
+ }
103
+ };
55
104
  }
105
+ export { getCircleOfTrust };
56
106
 
57
107
  /**
58
- * Export a single circle of trust to file
59
- * @param {String} cotId circle of trust id/name
60
- * @param {String} file Optional filename
108
+ * Get circles of trust
61
109
  */
62
- export async function exportCircleOfTrust(cotId, file = null) {
63
- let fileName = file;
64
- if (!fileName) {
65
- fileName = getTypedFilename(cotId, 'cot.saml');
66
- }
67
- createProgressIndicator(1, `Exporting circle of trust ${cotId}`);
68
- try {
69
- const cotData = _.cloneDeep(getCircleOfTrust(cotId));
70
- delete cotData['_rev'];
71
- updateProgressIndicator(`Exporting ${cotId}`);
72
- const fileData = getFileDataTemplate();
73
- fileData.saml.cot[cotId] = cotData;
74
- await exportDependencies(cotData, fileData);
75
- saveJsonToFile(fileData, fileName);
76
- stopProgressIndicator(`Exported ${cotId.brightCyan} to ${fileName.brightCyan}.`);
77
- } catch (err) {
78
- stopProgressIndicator(`${err}`);
79
- printMessage(err, 'error');
80
- }
110
+ export async function getCirclesOfTrust({
111
+ state
112
+ }) {
113
+ const {
114
+ result
115
+ } = await _getCirclesOfTrust({
116
+ state
117
+ });
118
+ return result;
81
119
  }
82
120
 
83
121
  /**
84
- * Export all circles of trust to one file
85
- * @param {String} file Optional filename
122
+ * Export circle of trust
123
+ * @param {string} cotId circle of trust id/name
124
+ * @returns {Promise<CirclesOfTrustExportInterface>} a promise that resolves to an CirclesOfTrustExportInterface object
86
125
  */
87
- export async function exportCirclesOfTrustToFile(file = null) {
88
- let fileName = file;
89
- if (!fileName) {
90
- fileName = getTypedFilename(`all${getRealmString()}CirclesOfTrust`, 'cot.saml');
91
- }
92
- const fileData = getFileDataTemplate();
93
- let allCotData = [];
126
+ export async function exportCircleOfTrust({
127
+ cotId,
128
+ state
129
+ }) {
130
+ debugMessage(`CirclesOfTrustOps.exportCircleOfTrust: start`);
131
+ const exportData = createCirclesOfTrustExportTemplate({
132
+ state
133
+ });
134
+ const errors = [];
94
135
  try {
95
- allCotData = _.cloneDeep((await getCirclesOfTrust()).result);
96
- createProgressIndicator(allCotData.length, 'Exporting circles of trust');
97
- for (const cotData of allCotData) {
98
- delete cotData._rev;
99
- updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);
100
- // eslint-disable-next-line no-await-in-loop
101
- await exportDependencies(cotData, fileData);
102
- fileData.saml.cot[cotData._id] = cotData;
103
- }
104
- saveJsonToFile(fileData, fileName);
105
- stopProgressIndicator(`${allCotData.length} circle(s) of trust exported to ${fileName}.`);
136
+ const cotData = await getCircleOfTrust({
137
+ cotId,
138
+ state
139
+ });
140
+ exportData.saml.cot[cotData._id] = cotData;
106
141
  } catch (error) {
107
- printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');
108
- printMessage(error, 'data');
142
+ errors.push(error);
109
143
  }
144
+ if (errors.length) {
145
+ const errorMessages = errors.map(error => {
146
+ var _error$response;
147
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
148
+ return `Circle of trust ${cotId} does not exist in realm ${state.getRealm()}`;
149
+ } else {
150
+ var _error$response2, _error$response2$data;
151
+ return ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || error.message;
152
+ }
153
+ }).join('\n');
154
+ throw new Error(`Export error:\n${errorMessages}`);
155
+ }
156
+ debugMessage(`CirclesOfTrustOps.exportCircleOfTrust: end`);
157
+ return exportData;
110
158
  }
111
159
 
112
160
  /**
113
- * Export all circles of trust to individual files
161
+ * Export circles of trust
162
+ * @returns {Promise<CirclesOfTrustExportInterface>} a promise that resolves to an CirclesOfTrustExportInterface object
114
163
  */
115
- export async function exportCirclesOfTrustToFiles() {
116
- let allCotData = [];
164
+ export async function exportCirclesOfTrust({
165
+ state
166
+ }) {
167
+ debugMessage(`CirclesOfTrustOps.exportCirclesOfTrust: start`);
168
+ const exportData = createCirclesOfTrustExportTemplate({
169
+ state
170
+ });
171
+ const errors = [];
117
172
  try {
118
- allCotData = _.cloneDeep((await getCirclesOfTrust()).result);
119
- createProgressIndicator(allCotData.length, 'Exporting circles of trust');
120
- for (const cotData of allCotData) {
121
- delete cotData._rev;
122
- updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);
123
- const fileName = getTypedFilename(cotData._id, 'cot.saml');
124
- const fileData = getFileDataTemplate();
125
- // eslint-disable-next-line no-await-in-loop
126
- await exportDependencies(cotData, fileData);
127
- fileData.saml.cot[cotData._id] = cotData;
128
- saveJsonToFile(fileData, fileName);
173
+ const cots = await getCirclesOfTrust({
174
+ state
175
+ });
176
+ for (const cot of cots) {
177
+ exportData.saml.cot[cot._id] = cot;
129
178
  }
130
- stopProgressIndicator(`${allCotData.length} providers exported.`);
131
179
  } catch (error) {
132
- printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');
133
- printMessage(error, 'data');
180
+ errors.push(error);
134
181
  }
135
- }
136
-
137
- /**
138
- * Include dependencies from the import file
139
- * @param {Object} cotData Object representing a SAML circle of trust
140
- * @param {Object} fileData File data object to read dependencies from
141
- */
142
- async function importDependencies(cotData, fileData) {
143
- // TODO: Import dependencies
144
- return [cotData, fileData];
182
+ if (errors.length) {
183
+ const errorMessages = errors.map(error => error.message).join('\n');
184
+ throw new Error(`Export error:\n${errorMessages}`);
185
+ }
186
+ debugMessage(`CirclesOfTrustOps.exportCirclesOfTrust: end`);
187
+ return exportData;
145
188
  }
146
189
 
147
190
  /**
148
191
  * Import a SAML circle of trust by id/name from file
149
192
  * @param {String} cotId Circle of trust id/name
150
- * @param {String} file Import file name
193
+ * @param {CirclesOfTrustExportInterface} importData import data
151
194
  */
152
- export async function importCircleOfTrust(cotId, file) {
153
- fs.readFile(file, 'utf8', async (err, data) => {
154
- if (err) throw err;
155
- const fileData = JSON.parse(data);
156
- if (validateImport(fileData.meta)) {
157
- createProgressIndicator(1, 'Importing circle of trust...');
158
- const cotData = _.get(fileData, ['saml', 'cot', cotId]);
159
- if (cotData) {
160
- updateProgressIndicator(`Importing ${cotId}`);
161
- await importDependencies(cotData, fileData);
195
+ export async function importCircleOfTrust({
196
+ cotId,
197
+ importData,
198
+ state
199
+ }) {
200
+ let response = null;
201
+ const errors = [];
202
+ const imported = [];
203
+ for (const id of Object.keys(importData.saml.cot)) {
204
+ if (id === cotId) {
205
+ try {
206
+ const cotData = importData.saml.cot[id];
207
+ delete cotData._rev;
162
208
  try {
163
- await createCircleOfTrust(cotData);
164
- stopProgressIndicator(`Successfully imported ${cotId}.`);
165
- } catch (createProviderErr) {
166
- stopProgressIndicator(`Error importing ${cotId}.`);
167
- printMessage(`Error importing ${cotId}`, 'error');
168
- printMessage(createProviderErr.response.data, 'error');
209
+ response = await createCircleOfTrust({
210
+ cotData,
211
+ state
212
+ });
213
+ } catch (createError) {
214
+ var _createError$response;
215
+ if (((_createError$response = createError.response) === null || _createError$response === void 0 ? void 0 : _createError$response.status) === 409) response = await updateCircleOfTrust({
216
+ cotId: id,
217
+ cotData,
218
+ state
219
+ });else throw createError;
169
220
  }
170
- } else {
171
- stopProgressIndicator(`Circle of trust ${cotId.brightCyan} not found in ${file.brightCyan}!`);
221
+ imported.push(id);
222
+ } catch (error) {
223
+ errors.push(error);
172
224
  }
173
- } else {
174
- printMessage('Import validation failed...', 'error');
175
225
  }
176
- });
177
- }
178
-
179
- /**
180
- * Import first SAML circle of trust from file
181
- * @param {String} file Import file name
182
- */
183
- export async function importFirstCircleOfTrust(file) {
184
- fs.readFile(file, 'utf8', async (err, data) => {
185
- if (err) throw err;
186
- const fileData = JSON.parse(data);
187
- if (validateImport(fileData.meta)) {
188
- createProgressIndicator(1, 'Importing circle of trust...');
189
- for (const cotId in fileData.saml.cot) {
190
- if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {
191
- const cotData = _.cloneDeep(fileData.saml.cot[cotId]);
192
- updateProgressIndicator(`Importing ${cotId}`);
193
- // eslint-disable-next-line no-await-in-loop
194
- await importDependencies(cotData, fileData);
195
- try {
196
- await createCircleOfTrust(cotData);
197
- stopProgressIndicator(`Successfully imported ${cotId}.`);
198
- } catch (createCircleOfTrustErr) {
199
- stopProgressIndicator(`Error importing ${cotId}.`);
200
- printMessage(`Error importing ${cotId}`, 'error');
201
- printMessage(createCircleOfTrustErr.response.data, 'error');
202
- }
203
- break;
204
- }
205
- }
206
- } else {
207
- printMessage('Import validation failed...', 'error');
208
- }
209
- });
226
+ }
227
+ if (errors.length) {
228
+ const errorMessages = errors.map(error => {
229
+ var _error$response3, _error$response3$data;
230
+ return ((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : (_error$response3$data = _error$response3.data) === null || _error$response3$data === void 0 ? void 0 : _error$response3$data.message) || error.message;
231
+ }).join('\n');
232
+ throw new Error(`Import error:\n${errorMessages}`);
233
+ }
234
+ if (0 === imported.length) {
235
+ throw new Error(`Import error:\n${cotId} not found in import data!`);
236
+ }
237
+ return response;
210
238
  }
211
239
 
212
240
  /**
213
- * Import all SAML circles of trust from file
214
- * @param {String} file Import file name
241
+ * Import first SAML circle of trust
242
+ * @param {CirclesOfTrustExportInterface} importData import data
215
243
  */
216
- export async function importCirclesOfTrustFromFile(file) {
217
- fs.readFile(file, 'utf8', async (err, data) => {
218
- if (err) throw err;
219
- const fileData = JSON.parse(data);
220
- if (validateImport(fileData.meta)) {
221
- createProgressIndicator(Object.keys(fileData.saml.cot).length, 'Importing circles of trust...');
222
- for (const cotId in fileData.saml.cot) {
223
- if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {
224
- const cotData = _.cloneDeep(fileData.saml.cot[cotId]);
225
- // eslint-disable-next-line no-await-in-loop
226
- await importDependencies(cotData, fileData);
227
- try {
228
- // eslint-disable-next-line no-await-in-loop
229
- await createCircleOfTrust(cotData);
230
- updateProgressIndicator(`Imported ${cotId}`);
231
- } catch (createCircleOfTrustErr) {
232
- printMessage(`\nError importing ${cotId}`, 'error');
233
- printMessage(createCircleOfTrustErr.response.data, 'error');
234
- }
235
- }
244
+ export async function importFirstCircleOfTrust({
245
+ importData,
246
+ state
247
+ }) {
248
+ let response = null;
249
+ const errors = [];
250
+ const imported = [];
251
+ for (const id of Object.keys(importData.saml.cot)) {
252
+ try {
253
+ const cotData = importData.saml.cot[id];
254
+ delete cotData._rev;
255
+ try {
256
+ response = await createCircleOfTrust({
257
+ cotData,
258
+ state
259
+ });
260
+ } catch (createError) {
261
+ var _createError$response2;
262
+ if (((_createError$response2 = createError.response) === null || _createError$response2 === void 0 ? void 0 : _createError$response2.status) === 409) response = await updateCircleOfTrust({
263
+ cotId: id,
264
+ cotData,
265
+ state
266
+ });else throw createError;
236
267
  }
237
- stopProgressIndicator(`Circles of trust imported.`);
238
- } else {
239
- printMessage('Import validation failed...', 'error');
268
+ imported.push(id);
269
+ } catch (error) {
270
+ errors.push(error);
240
271
  }
241
- });
272
+ break;
273
+ }
274
+ if (errors.length) {
275
+ const errorMessages = errors.map(error => {
276
+ var _error$response4, _error$response4$data;
277
+ return ((_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : (_error$response4$data = _error$response4.data) === null || _error$response4$data === void 0 ? void 0 : _error$response4$data.message) || error.message;
278
+ }).join('\n');
279
+ throw new Error(`Import error:\n${errorMessages}`);
280
+ }
281
+ if (0 === imported.length) {
282
+ throw new Error(`Import error:\nNo circles of trust found in import data!`);
283
+ }
284
+ return response;
242
285
  }
243
286
 
244
287
  /**
245
- * Import all SAML circles of trust from all *.cot.saml.json files in the current directory
288
+ * Import SAML circles of trust
289
+ * @param {CirclesOfTrustExportInterface} importData import data
246
290
  */
247
- export async function importCirclesOfTrustFromFiles() {
248
- const names = fs.readdirSync('.');
249
- const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.cot.saml.json'));
250
- createProgressIndicator(jsonFiles.length, 'Importing circles or trust...');
251
- let total = 0;
252
- let totalErrors = 0;
253
- for (const file of jsonFiles) {
254
- const data = fs.readFileSync(file, 'utf8');
255
- const fileData = JSON.parse(data);
256
- if (validateImport(fileData.meta)) {
257
- total += _.keys(fileData.saml.cot).length;
258
- let errors = 0;
259
- for (const cotId in fileData.saml.cot) {
260
- if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {
261
- const cotData = _.cloneDeep(fileData.saml.cot[cotId]);
262
- // eslint-disable-next-line no-await-in-loop
263
- await importDependencies(cotData, fileData);
264
- try {
265
- // eslint-disable-next-line no-await-in-loop
266
- await createCircleOfTrust(cotData);
267
- // updateProgressIndicator(`Imported ${cotId}`);
268
- } catch (createCircleOfTrustErr) {
269
- errors += 1;
270
- printMessage(`\nError importing ${cotId}`, 'error');
271
- printMessage(createCircleOfTrustErr.response.data, 'error');
272
- }
273
- }
291
+ export async function importCirclesOfTrust({
292
+ importData,
293
+ state
294
+ }) {
295
+ const response = [];
296
+ const errors = [];
297
+ const imported = [];
298
+ for (const id of Object.keys(importData.saml.cot)) {
299
+ try {
300
+ const cotData = importData.saml.cot[id];
301
+ delete cotData._rev;
302
+ try {
303
+ response.push(await createCircleOfTrust({
304
+ cotData,
305
+ state
306
+ }));
307
+ } catch (createError) {
308
+ var _createError$response3;
309
+ if (((_createError$response3 = createError.response) === null || _createError$response3 === void 0 ? void 0 : _createError$response3.status) === 409) response.push(await updateCircleOfTrust({
310
+ cotId: id,
311
+ cotData,
312
+ state
313
+ }));else throw createError;
274
314
  }
275
- totalErrors += errors;
276
- updateProgressIndicator(`Imported ${_.keys(fileData.saml.cot).length - errors} circle(s) of trust from ${file}`);
277
- } else {
278
- printMessage(`Validation of ${file} failed!`, 'error');
315
+ imported.push(id);
316
+ } catch (error) {
317
+ errors.push(error);
279
318
  }
280
319
  }
281
- stopProgressIndicator(`Imported ${total - totalErrors} of ${total} circle(s) of trust from ${jsonFiles.length} file(s).`);
320
+ if (errors.length) {
321
+ const errorMessages = errors.map(error => {
322
+ var _error$response5, _error$response5$data;
323
+ return ((_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : (_error$response5$data = _error$response5.data) === null || _error$response5$data === void 0 ? void 0 : _error$response5$data.message) || error.message;
324
+ }).join('\n');
325
+ throw new Error(`Import error:\n${errorMessages}`);
326
+ }
327
+ if (0 === imported.length) {
328
+ throw new Error(`Import error:\nNo circles of trust found in import data!`);
329
+ }
330
+ return response;
282
331
  }
283
332
  //# sourceMappingURL=CirclesOfTrustOps.js.map