auth0-deploy-cli 8.20.4-beta.0 → 8.21.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 (318) hide show
  1. package/.circleci/config.yml +5 -46
  2. package/.eslintignore +5 -0
  3. package/.eslintrc +69 -0
  4. package/CHANGELOG.md +15 -6
  5. package/lib/args.js +1 -0
  6. package/lib/args.js.map +1 -0
  7. package/lib/commands/export.js +49 -41
  8. package/lib/commands/export.js.map +1 -0
  9. package/lib/commands/import.js +43 -36
  10. package/lib/commands/import.js.map +1 -0
  11. package/lib/commands/index.js +1 -0
  12. package/lib/commands/index.js.map +1 -0
  13. package/lib/configFactory.js +1 -0
  14. package/lib/configFactory.js.map +1 -0
  15. package/lib/context/defaults.js +10 -38
  16. package/lib/context/defaults.js.map +1 -0
  17. package/lib/context/directory/handlers/actions.js +39 -40
  18. package/lib/context/directory/handlers/actions.js.map +1 -0
  19. package/lib/context/directory/handlers/attackProtection.js +34 -22
  20. package/lib/context/directory/handlers/attackProtection.js.map +1 -0
  21. package/lib/context/directory/handlers/branding.js +21 -12
  22. package/lib/context/directory/handlers/branding.js.map +1 -0
  23. package/lib/context/directory/handlers/clientGrants.js +62 -52
  24. package/lib/context/directory/handlers/clientGrants.js.map +1 -0
  25. package/lib/context/directory/handlers/clients.js +60 -17
  26. package/lib/context/directory/handlers/clients.js.map +1 -0
  27. package/lib/context/directory/handlers/connectionProfiles.d.ts +11 -0
  28. package/lib/context/directory/handlers/connectionProfiles.js +59 -0
  29. package/lib/context/directory/handlers/connectionProfiles.js.map +1 -0
  30. package/lib/context/directory/handlers/connections.js +41 -32
  31. package/lib/context/directory/handlers/connections.js.map +1 -0
  32. package/lib/context/directory/handlers/customDomains.js +21 -9
  33. package/lib/context/directory/handlers/customDomains.js.map +1 -0
  34. package/lib/context/directory/handlers/databases.js +35 -37
  35. package/lib/context/directory/handlers/databases.js.map +1 -0
  36. package/lib/context/directory/handlers/emailProvider.js +36 -22
  37. package/lib/context/directory/handlers/emailProvider.js.map +1 -0
  38. package/lib/context/directory/handlers/emailTemplates.js +29 -20
  39. package/lib/context/directory/handlers/emailTemplates.js.map +1 -0
  40. package/lib/context/directory/handlers/flowVaultConnections.js +49 -39
  41. package/lib/context/directory/handlers/flowVaultConnections.js.map +1 -0
  42. package/lib/context/directory/handlers/flows.js +48 -38
  43. package/lib/context/directory/handlers/flows.js.map +1 -0
  44. package/lib/context/directory/handlers/forms.js +48 -38
  45. package/lib/context/directory/handlers/forms.js.map +1 -0
  46. package/lib/context/directory/handlers/guardianFactorProviders.js +21 -9
  47. package/lib/context/directory/handlers/guardianFactorProviders.js.map +1 -0
  48. package/lib/context/directory/handlers/guardianFactorTemplates.js +21 -9
  49. package/lib/context/directory/handlers/guardianFactorTemplates.js.map +1 -0
  50. package/lib/context/directory/handlers/guardianFactors.js +21 -9
  51. package/lib/context/directory/handlers/guardianFactors.js.map +1 -0
  52. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +20 -8
  53. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
  54. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +20 -8
  55. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
  56. package/lib/context/directory/handlers/guardianPolicies.js +20 -8
  57. package/lib/context/directory/handlers/guardianPolicies.js.map +1 -0
  58. package/lib/context/directory/handlers/hooks.js +34 -24
  59. package/lib/context/directory/handlers/hooks.js.map +1 -0
  60. package/lib/context/directory/handlers/index.js +3 -0
  61. package/lib/context/directory/handlers/index.js.map +1 -0
  62. package/lib/context/directory/handlers/logStreams.js +24 -12
  63. package/lib/context/directory/handlers/logStreams.js.map +1 -0
  64. package/lib/context/directory/handlers/networkACLs.js +34 -22
  65. package/lib/context/directory/handlers/networkACLs.js.map +1 -0
  66. package/lib/context/directory/handlers/organizations.js +44 -39
  67. package/lib/context/directory/handlers/organizations.js.map +1 -0
  68. package/lib/context/directory/handlers/pages.js +37 -31
  69. package/lib/context/directory/handlers/pages.js.map +1 -0
  70. package/lib/context/directory/handlers/phoneProvider.js +24 -12
  71. package/lib/context/directory/handlers/phoneProvider.js.map +1 -0
  72. package/lib/context/directory/handlers/prompts.js +76 -58
  73. package/lib/context/directory/handlers/prompts.js.map +1 -0
  74. package/lib/context/directory/handlers/resourceServers.d.ts +1 -1
  75. package/lib/context/directory/handlers/resourceServers.js +30 -18
  76. package/lib/context/directory/handlers/resourceServers.js.map +1 -0
  77. package/lib/context/directory/handlers/roles.js +31 -21
  78. package/lib/context/directory/handlers/roles.js.map +1 -0
  79. package/lib/context/directory/handlers/rules.js +32 -22
  80. package/lib/context/directory/handlers/rules.js.map +1 -0
  81. package/lib/context/directory/handlers/rulesConfigs.js +15 -3
  82. package/lib/context/directory/handlers/rulesConfigs.js.map +1 -0
  83. package/lib/context/directory/handlers/selfServiceProfiles.js +40 -28
  84. package/lib/context/directory/handlers/selfServiceProfiles.js.map +1 -0
  85. package/lib/context/directory/handlers/tenant.js +34 -14
  86. package/lib/context/directory/handlers/tenant.js.map +1 -0
  87. package/lib/context/directory/handlers/themes.js +21 -9
  88. package/lib/context/directory/handlers/themes.js.map +1 -0
  89. package/lib/context/directory/handlers/triggers.d.ts +1 -1
  90. package/lib/context/directory/handlers/triggers.js +26 -16
  91. package/lib/context/directory/handlers/triggers.js.map +1 -0
  92. package/lib/context/directory/handlers/userAttributeProfiles.d.ts +1 -1
  93. package/lib/context/directory/handlers/userAttributeProfiles.js +26 -16
  94. package/lib/context/directory/handlers/userAttributeProfiles.js.map +1 -0
  95. package/lib/context/directory/index.js +80 -66
  96. package/lib/context/directory/index.js.map +1 -0
  97. package/lib/context/index.js +20 -9
  98. package/lib/context/index.js.map +1 -0
  99. package/lib/context/yaml/handlers/actions.js +41 -39
  100. package/lib/context/yaml/handlers/actions.js.map +1 -0
  101. package/lib/context/yaml/handlers/attackProtection.js +41 -27
  102. package/lib/context/yaml/handlers/attackProtection.js.map +1 -0
  103. package/lib/context/yaml/handlers/branding.js +69 -47
  104. package/lib/context/yaml/handlers/branding.js.map +1 -0
  105. package/lib/context/yaml/handlers/clientGrants.js +40 -26
  106. package/lib/context/yaml/handlers/clientGrants.js.map +1 -0
  107. package/lib/context/yaml/handlers/clients.js +85 -41
  108. package/lib/context/yaml/handlers/clients.js.map +1 -0
  109. package/lib/context/yaml/handlers/connectionProfiles.d.ts +11 -0
  110. package/lib/context/yaml/handlers/connectionProfiles.js +44 -0
  111. package/lib/context/yaml/handlers/connectionProfiles.js.map +1 -0
  112. package/lib/context/yaml/handlers/connections.js +67 -63
  113. package/lib/context/yaml/handlers/connections.js.map +1 -0
  114. package/lib/context/yaml/handlers/customDomains.js +19 -7
  115. package/lib/context/yaml/handlers/customDomains.js.map +1 -0
  116. package/lib/context/yaml/handlers/databases.js +65 -63
  117. package/lib/context/yaml/handlers/databases.js.map +1 -0
  118. package/lib/context/yaml/handlers/emailProvider.js +37 -22
  119. package/lib/context/yaml/handlers/emailProvider.js.map +1 -0
  120. package/lib/context/yaml/handlers/emailTemplates.js +39 -28
  121. package/lib/context/yaml/handlers/emailTemplates.js.map +1 -0
  122. package/lib/context/yaml/handlers/flowVaultConnections.js +50 -36
  123. package/lib/context/yaml/handlers/flowVaultConnections.js.map +1 -0
  124. package/lib/context/yaml/handlers/flows.js +66 -55
  125. package/lib/context/yaml/handlers/flows.js.map +1 -0
  126. package/lib/context/yaml/handlers/forms.js +66 -55
  127. package/lib/context/yaml/handlers/forms.js.map +1 -0
  128. package/lib/context/yaml/handlers/guardianFactorProviders.js +19 -7
  129. package/lib/context/yaml/handlers/guardianFactorProviders.js.map +1 -0
  130. package/lib/context/yaml/handlers/guardianFactorTemplates.js +19 -7
  131. package/lib/context/yaml/handlers/guardianFactorTemplates.js.map +1 -0
  132. package/lib/context/yaml/handlers/guardianFactors.js +19 -7
  133. package/lib/context/yaml/handlers/guardianFactors.js.map +1 -0
  134. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +19 -7
  135. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
  136. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +19 -7
  137. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
  138. package/lib/context/yaml/handlers/guardianPolicies.js +19 -7
  139. package/lib/context/yaml/handlers/guardianPolicies.js.map +1 -0
  140. package/lib/context/yaml/handlers/hooks.js +48 -34
  141. package/lib/context/yaml/handlers/hooks.js.map +1 -0
  142. package/lib/context/yaml/handlers/index.js +3 -0
  143. package/lib/context/yaml/handlers/index.js.map +1 -0
  144. package/lib/context/yaml/handlers/logStreams.js +30 -16
  145. package/lib/context/yaml/handlers/logStreams.js.map +1 -0
  146. package/lib/context/yaml/handlers/networkACLs.js +39 -25
  147. package/lib/context/yaml/handlers/networkACLs.js.map +1 -0
  148. package/lib/context/yaml/handlers/organizations.js +46 -37
  149. package/lib/context/yaml/handlers/organizations.js.map +1 -0
  150. package/lib/context/yaml/handlers/pages.js +39 -31
  151. package/lib/context/yaml/handlers/pages.js.map +1 -0
  152. package/lib/context/yaml/handlers/phoneProvider.js +31 -17
  153. package/lib/context/yaml/handlers/phoneProvider.js.map +1 -0
  154. package/lib/context/yaml/handlers/prompts.js +47 -22
  155. package/lib/context/yaml/handlers/prompts.js.map +1 -0
  156. package/lib/context/yaml/handlers/resourceServers.d.ts +1 -1
  157. package/lib/context/yaml/handlers/resourceServers.js +33 -21
  158. package/lib/context/yaml/handlers/resourceServers.js.map +1 -0
  159. package/lib/context/yaml/handlers/roles.js +33 -19
  160. package/lib/context/yaml/handlers/roles.js.map +1 -0
  161. package/lib/context/yaml/handlers/rules.js +39 -28
  162. package/lib/context/yaml/handlers/rules.js.map +1 -0
  163. package/lib/context/yaml/handlers/rulesConfigs.js +28 -14
  164. package/lib/context/yaml/handlers/rulesConfigs.js.map +1 -0
  165. package/lib/context/yaml/handlers/selfServiceProfiles.js +43 -29
  166. package/lib/context/yaml/handlers/selfServiceProfiles.js.map +1 -0
  167. package/lib/context/yaml/handlers/tenant.js +41 -19
  168. package/lib/context/yaml/handlers/tenant.js.map +1 -0
  169. package/lib/context/yaml/handlers/themes.js +19 -7
  170. package/lib/context/yaml/handlers/themes.js.map +1 -0
  171. package/lib/context/yaml/handlers/triggers.d.ts +1 -1
  172. package/lib/context/yaml/handlers/triggers.js +29 -15
  173. package/lib/context/yaml/handlers/triggers.js.map +1 -0
  174. package/lib/context/yaml/handlers/userAttributeProfiles.d.ts +1 -1
  175. package/lib/context/yaml/handlers/userAttributeProfiles.js +19 -7
  176. package/lib/context/yaml/handlers/userAttributeProfiles.js.map +1 -0
  177. package/lib/context/yaml/index.js +128 -120
  178. package/lib/context/yaml/index.js.map +1 -0
  179. package/lib/index.d.ts +96 -4
  180. package/lib/index.js +34 -24
  181. package/lib/index.js.map +1 -0
  182. package/lib/keywordPreservation.d.ts +1 -1
  183. package/lib/keywordPreservation.js +6 -10
  184. package/lib/keywordPreservation.js.map +1 -0
  185. package/lib/logger.js +1 -0
  186. package/lib/logger.js.map +1 -0
  187. package/lib/readonly.js +4 -3
  188. package/lib/readonly.js.map +1 -0
  189. package/lib/sessionDurationsToMinutes.js +1 -0
  190. package/lib/sessionDurationsToMinutes.js.map +1 -0
  191. package/lib/tools/auth0/client.js +127 -108
  192. package/lib/tools/auth0/client.js.map +1 -0
  193. package/lib/tools/auth0/handlers/actions.d.ts +26 -8
  194. package/lib/tools/auth0/handlers/actions.js +149 -138
  195. package/lib/tools/auth0/handlers/actions.js.map +1 -0
  196. package/lib/tools/auth0/handlers/attackProtection.js +92 -80
  197. package/lib/tools/auth0/handlers/attackProtection.js.map +1 -0
  198. package/lib/tools/auth0/handlers/branding.js +99 -75
  199. package/lib/tools/auth0/handlers/branding.js.map +1 -0
  200. package/lib/tools/auth0/handlers/clientGrants.d.ts +9 -2
  201. package/lib/tools/auth0/handlers/clientGrants.js +72 -65
  202. package/lib/tools/auth0/handlers/clientGrants.js.map +1 -0
  203. package/lib/tools/auth0/handlers/clients.d.ts +85 -7
  204. package/lib/tools/auth0/handlers/clients.js +187 -66
  205. package/lib/tools/auth0/handlers/clients.js.map +1 -0
  206. package/lib/tools/auth0/handlers/connectionProfiles.d.ts +182 -0
  207. package/lib/tools/auth0/handlers/connectionProfiles.js +239 -0
  208. package/lib/tools/auth0/handlers/connectionProfiles.js.map +1 -0
  209. package/lib/tools/auth0/handlers/connections.d.ts +1 -3
  210. package/lib/tools/auth0/handlers/connections.js +135 -130
  211. package/lib/tools/auth0/handlers/connections.js.map +1 -0
  212. package/lib/tools/auth0/handlers/customDomains.d.ts +1 -4
  213. package/lib/tools/auth0/handlers/customDomains.js +53 -43
  214. package/lib/tools/auth0/handlers/customDomains.js.map +1 -0
  215. package/lib/tools/auth0/handlers/databases.js +114 -94
  216. package/lib/tools/auth0/handlers/databases.js.map +1 -0
  217. package/lib/tools/auth0/handlers/default.d.ts +2 -2
  218. package/lib/tools/auth0/handlers/default.js +171 -210
  219. package/lib/tools/auth0/handlers/default.js.map +1 -0
  220. package/lib/tools/auth0/handlers/emailProvider.js +52 -41
  221. package/lib/tools/auth0/handlers/emailProvider.js.map +1 -0
  222. package/lib/tools/auth0/handlers/emailTemplates.js +71 -49
  223. package/lib/tools/auth0/handlers/emailTemplates.js.map +1 -0
  224. package/lib/tools/auth0/handlers/flowVaultConnections.d.ts +12 -5
  225. package/lib/tools/auth0/handlers/flowVaultConnections.js +143 -108
  226. package/lib/tools/auth0/handlers/flowVaultConnections.js.map +1 -0
  227. package/lib/tools/auth0/handlers/flows.d.ts +3 -2
  228. package/lib/tools/auth0/handlers/flows.js +129 -92
  229. package/lib/tools/auth0/handlers/flows.js.map +1 -0
  230. package/lib/tools/auth0/handlers/forms.d.ts +3 -3
  231. package/lib/tools/auth0/handlers/forms.js +112 -98
  232. package/lib/tools/auth0/handlers/forms.js.map +1 -0
  233. package/lib/tools/auth0/handlers/guardianFactorProviders.js +84 -61
  234. package/lib/tools/auth0/handlers/guardianFactorProviders.js.map +1 -0
  235. package/lib/tools/auth0/handlers/guardianFactorTemplates.js +68 -46
  236. package/lib/tools/auth0/handlers/guardianFactorTemplates.js.map +1 -0
  237. package/lib/tools/auth0/handlers/guardianFactors.js +45 -35
  238. package/lib/tools/auth0/handlers/guardianFactors.js.map +1 -0
  239. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +45 -29
  240. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
  241. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +45 -29
  242. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
  243. package/lib/tools/auth0/handlers/guardianPolicies.js +35 -20
  244. package/lib/tools/auth0/handlers/guardianPolicies.js.map +1 -0
  245. package/lib/tools/auth0/handlers/hooks.js +153 -123
  246. package/lib/tools/auth0/handlers/hooks.js.map +1 -0
  247. package/lib/tools/auth0/handlers/index.js +3 -0
  248. package/lib/tools/auth0/handlers/index.js.map +1 -0
  249. package/lib/tools/auth0/handlers/logStreams.js +47 -42
  250. package/lib/tools/auth0/handlers/logStreams.js.map +1 -0
  251. package/lib/tools/auth0/handlers/networkACLs.d.ts +4 -5
  252. package/lib/tools/auth0/handlers/networkACLs.js +133 -115
  253. package/lib/tools/auth0/handlers/networkACLs.js.map +1 -0
  254. package/lib/tools/auth0/handlers/organizations.d.ts +9 -10
  255. package/lib/tools/auth0/handlers/organizations.js +429 -360
  256. package/lib/tools/auth0/handlers/organizations.js.map +1 -0
  257. package/lib/tools/auth0/handlers/pages.js +83 -74
  258. package/lib/tools/auth0/handlers/pages.js.map +1 -0
  259. package/lib/tools/auth0/handlers/phoneProvider.d.ts +2 -2
  260. package/lib/tools/auth0/handlers/phoneProvider.js +82 -69
  261. package/lib/tools/auth0/handlers/phoneProvider.js.map +1 -0
  262. package/lib/tools/auth0/handlers/prompts.d.ts +5 -5
  263. package/lib/tools/auth0/handlers/prompts.js +235 -240
  264. package/lib/tools/auth0/handlers/prompts.js.map +1 -0
  265. package/lib/tools/auth0/handlers/resourceServers.d.ts +1 -3
  266. package/lib/tools/auth0/handlers/resourceServers.js +60 -59
  267. package/lib/tools/auth0/handlers/resourceServers.js.map +1 -0
  268. package/lib/tools/auth0/handlers/roles.js +178 -162
  269. package/lib/tools/auth0/handlers/roles.js.map +1 -0
  270. package/lib/tools/auth0/handlers/rules.js +162 -144
  271. package/lib/tools/auth0/handlers/rules.js.map +1 -0
  272. package/lib/tools/auth0/handlers/rulesConfigs.js +39 -30
  273. package/lib/tools/auth0/handlers/rulesConfigs.js.map +1 -0
  274. package/lib/tools/auth0/handlers/scimHandler.d.ts +3 -4
  275. package/lib/tools/auth0/handlers/scimHandler.js +132 -110
  276. package/lib/tools/auth0/handlers/scimHandler.js.map +1 -0
  277. package/lib/tools/auth0/handlers/selfServiceProfiles.d.ts +5 -13
  278. package/lib/tools/auth0/handlers/selfServiceProfiles.js +204 -170
  279. package/lib/tools/auth0/handlers/selfServiceProfiles.js.map +1 -0
  280. package/lib/tools/auth0/handlers/tenant.d.ts +3 -5
  281. package/lib/tools/auth0/handlers/tenant.js +52 -45
  282. package/lib/tools/auth0/handlers/tenant.js.map +1 -0
  283. package/lib/tools/auth0/handlers/themes.d.ts +12 -12
  284. package/lib/tools/auth0/handlers/themes.js +102 -86
  285. package/lib/tools/auth0/handlers/themes.js.map +1 -0
  286. package/lib/tools/auth0/handlers/triggers.js +75 -59
  287. package/lib/tools/auth0/handlers/triggers.js.map +1 -0
  288. package/lib/tools/auth0/handlers/userAttributeProfiles.d.ts +4 -4
  289. package/lib/tools/auth0/handlers/userAttributeProfiles.js +63 -56
  290. package/lib/tools/auth0/handlers/userAttributeProfiles.js.map +1 -0
  291. package/lib/tools/auth0/index.js +48 -35
  292. package/lib/tools/auth0/index.js.map +1 -0
  293. package/lib/tools/auth0/schema.js +4 -6
  294. package/lib/tools/auth0/schema.js.map +1 -0
  295. package/lib/tools/calculateChanges.js +15 -24
  296. package/lib/tools/calculateChanges.js.map +1 -0
  297. package/lib/tools/constants.d.ts +3 -2
  298. package/lib/tools/constants.js +2 -0
  299. package/lib/tools/constants.js.map +1 -0
  300. package/lib/tools/deploy.js +29 -17
  301. package/lib/tools/deploy.js.map +1 -0
  302. package/lib/tools/index.d.ts +89 -3
  303. package/lib/tools/index.js +2 -3
  304. package/lib/tools/index.js.map +1 -0
  305. package/lib/tools/utils.d.ts +1 -1
  306. package/lib/tools/utils.js +22 -12
  307. package/lib/tools/utils.js.map +1 -0
  308. package/lib/tools/validationError.js +1 -0
  309. package/lib/tools/validationError.js.map +1 -0
  310. package/lib/types.d.ts +6 -9
  311. package/lib/types.js +1 -0
  312. package/lib/types.js.map +1 -0
  313. package/lib/utils.d.ts +58 -3
  314. package/lib/utils.js +5 -8
  315. package/lib/utils.js.map +1 -0
  316. package/package.json +10 -11
  317. package/tsconfig.json +3 -4
  318. package/eslint.config.js +0 -130
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -38,7 +47,7 @@ exports.schema = {
38
47
  properties: {
39
48
  mechanism: {
40
49
  type: 'string',
41
- enum: Object.values(auth0_1.Management.ResourceServerProofOfPossessionMechanismEnum),
50
+ enum: Object.values(auth0_1.ResourceServerProofOfPossessionMechanismEnum),
42
51
  },
43
52
  required: { type: 'boolean' },
44
53
  },
@@ -53,7 +62,7 @@ exports.schema = {
53
62
  properties: {
54
63
  policy: {
55
64
  type: 'string',
56
- enum: Object.values(auth0_1.Management.ResourceServerSubjectTypeAuthorizationUserPolicyEnum),
65
+ enum: Object.values(auth0_1.ResourceServerSubjectTypeAuthorizationUserPolicyEnum),
57
66
  },
58
67
  },
59
68
  },
@@ -63,7 +72,7 @@ exports.schema = {
63
72
  properties: {
64
73
  policy: {
65
74
  type: 'string',
66
- enum: Object.values(auth0_1.Management.ResourceServerSubjectTypeAuthorizationClientPolicyEnum),
75
+ enum: Object.values(auth0_1.ResourceServerSubjectTypeAuthorizationClientPolicyEnum),
67
76
  },
68
77
  },
69
78
  },
@@ -81,71 +90,63 @@ exports.schema = {
81
90
  };
82
91
  class ResourceServersHandler extends default_1.default {
83
92
  constructor(options) {
84
- super({
85
- ...options,
86
- type: 'resourceServers',
87
- identifiers: ['id', 'identifier'],
88
- stripCreateFields: ['client_id'],
89
- stripUpdateFields: ['identifier', 'client_id'],
90
- functions: {
91
- update: async ({ id }, bodyParams) => this.client.resourceServers.update(id, bodyParams),
92
- },
93
- });
93
+ super(Object.assign(Object.assign({}, options), { type: 'resourceServers', identifiers: ['id', 'identifier'], stripCreateFields: ['client_id'], stripUpdateFields: ['identifier', 'client_id', 'is_system'] }));
94
94
  }
95
95
  objString(resourceServer) {
96
96
  return super.objString({ name: resourceServer.name, identifier: resourceServer.identifier });
97
97
  }
98
- async getType() {
99
- if (this.existing)
100
- return this.existing;
101
- const resourceServers = await (0, client_1.paginate)(this.client.resourceServers.list, {
102
- paginate: true,
98
+ getType() {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ if (this.existing)
101
+ return this.existing;
102
+ const resourceServers = yield (0, client_1.paginate)(this.client.resourceServers.getAll, {
103
+ paginate: true,
104
+ include_totals: true,
105
+ });
106
+ return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
103
107
  });
104
- return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
105
108
  }
106
- async calcChanges(assets) {
107
- let { resourceServers } = assets;
108
- // Do nothing if not set
109
- if (!resourceServers)
110
- return {
111
- del: [],
112
- create: [],
113
- conflicts: [],
114
- update: [],
115
- };
116
- const excluded = (assets.exclude && assets.exclude.resourceServers) || [];
117
- let existing = await this.getType();
118
- // Filter excluded
119
- resourceServers = resourceServers.filter((r) => r.name && !excluded.includes(r.name));
120
- existing = existing.filter((r) => r.name && !excluded.includes(r.name));
121
- return (0, calculateChanges_1.calculateChanges)({
122
- handler: this,
123
- assets: resourceServers,
124
- existing,
125
- identifiers: this.identifiers,
126
- allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
109
+ calcChanges(assets) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ let { resourceServers } = assets;
112
+ // Do nothing if not set
113
+ if (!resourceServers)
114
+ return {
115
+ del: [],
116
+ create: [],
117
+ conflicts: [],
118
+ update: [],
119
+ };
120
+ const excluded = (assets.exclude && assets.exclude.resourceServers) || [];
121
+ let existing = yield this.getType();
122
+ // Filter excluded
123
+ resourceServers = resourceServers.filter((r) => !excluded.includes(r.name));
124
+ existing = existing.filter((r) => !excluded.includes(r.name));
125
+ return (0, calculateChanges_1.calculateChanges)({
126
+ handler: this,
127
+ assets: resourceServers,
128
+ existing,
129
+ identifiers: this.identifiers,
130
+ allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
131
+ });
127
132
  });
128
133
  }
129
- async validate(assets) {
130
- const { resourceServers } = assets;
131
- // Do nothing if not set
132
- if (!resourceServers)
133
- return;
134
- const mgmtAPIResource = resourceServers.find((r) => r.name === constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
135
- if (mgmtAPIResource) {
136
- throw new validationError_1.default(`You can not configure the '${constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
137
- }
138
- await super.validate(assets);
139
- }
140
- async processChanges(assets) {
141
- const { resourceServers } = assets;
142
- // Do nothing if not set
143
- if (!resourceServers)
144
- return;
145
- const changes = await this.calcChanges(assets);
146
- await super.processChanges(assets, {
147
- ...changes,
134
+ validate(assets) {
135
+ const _super = Object.create(null, {
136
+ validate: { get: () => super.validate }
137
+ });
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const { resourceServers } = assets;
140
+ // Do nothing if not set
141
+ if (!resourceServers)
142
+ return;
143
+ const mgmtAPIResource = resourceServers.find((r) => r.name === constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
144
+ if (mgmtAPIResource) {
145
+ throw new validationError_1.default(`You can not configure the '${constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
146
+ }
147
+ yield _super.validate.call(this, assets);
148
148
  });
149
149
  }
150
150
  }
151
151
  exports.default = ResourceServersHandler;
152
+ //# sourceMappingURL=resourceServers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceServers.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/resourceServers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAKe;AACf,4EAAoD;AAEpD,gEAAwC;AACxC,wDAAuC;AACvC,6DAA0D;AAE1D,sCAAqC;AAExB,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC1B,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC9B,MAAM,EAAE;gBACN,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,Q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C,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5E,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAE9D,OAAO,IAAA,mCAAgB,EAAC;gBACtB,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,eAAe;gBACvB,QAAQ;gBACR,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;aACjD,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,QAAQ,CAAC,MAAc;;;;;YAC3B,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;YAEnC,wBAAwB;YACxB,IAAI,CAAC,eAAe;gBAAE,OAAO;YAE7B,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAS,CAAC,oCAAoC,CACjE,CAAC;YACF,IAAI,eAAe,EAAE,CAAC;gBACpB,MAAM,IAAI,yBAAe,CACvB,8BAA8B,mBAAS,CAAC,oCAAoC,IAAI,CACjF,CAAC;YACJ,CAAC;YAED,MAAM,OAAM,QAAQ,YAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;KAAA;CACF;AA3ED,yCA2EC"}
@@ -38,11 +38,21 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
40
  })();
41
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
+ return new (P || (P = Promise))(function (resolve, reject) {
44
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
41
50
  var __importDefault = (this && this.__importDefault) || function (mod) {
42
51
  return (mod && mod.__esModule) ? mod : { "default": mod };
43
52
  };
44
53
  Object.defineProperty(exports, "__esModule", { value: true });
45
54
  exports.schema = void 0;
55
+ const lodash_1 = require("lodash");
46
56
  const default_1 = __importStar(require("./default"));
47
57
  const calculateChanges_1 = require("../../calculateChanges");
48
58
  const logger_1 = __importDefault(require("../../../logger"));
@@ -71,190 +81,196 @@ exports.schema = {
71
81
  };
72
82
  class RolesHandler extends default_1.default {
73
83
  constructor(config) {
74
- super({
75
- ...config,
76
- type: 'roles',
77
- id: 'id',
78
- });
79
- }
80
- async createRole(data) {
81
- const role = { ...data };
82
- delete role.permissions;
83
- const created = await this.client.roles.create(role);
84
- if (created.id && typeof data.permissions !== 'undefined' && data.permissions.length > 0) {
85
- await this.client.roles.permissions.add(created.id, { permissions: data.permissions });
86
- }
87
- return created;
88
- }
89
- async createRoles(creates) {
90
- await this.client.pool
91
- .addEachTask({
92
- data: creates || [],
93
- generator: (item) => this.createRole(item)
94
- .then((data) => {
95
- this.didCreate(data);
96
- this.created += 1;
97
- })
98
- .catch((err) => {
99
- throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
100
- }),
101
- })
102
- .promise();
84
+ super(Object.assign(Object.assign({}, config), { type: 'roles', id: 'id' }));
103
85
  }
104
- async deleteRole(data) {
105
- await this.client.roles.delete(data.id);
86
+ createRole(data) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const role = Object.assign({}, data);
89
+ delete role.permissions;
90
+ const { data: created } = yield this.client.roles.create(role);
91
+ if (typeof data.permissions !== 'undefined' && data.permissions.length > 0) {
92
+ yield this.client.roles.addPermissions({ id: created.id }, { permissions: data.permissions });
93
+ }
94
+ return created;
95
+ });
106
96
  }
107
- async deleteRoles(dels) {
108
- if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
109
- this.config('AUTH0_ALLOW_DELETE') === true) {
110
- await this.client.pool
97
+ createRoles(creates) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ yield this.client.pool
111
100
  .addEachTask({
112
- data: dels || [],
113
- generator: (item) => this.deleteRole(item)
114
- .then(() => {
115
- this.didDelete(item);
116
- this.deleted += 1;
101
+ data: creates || [],
102
+ generator: (item) => this.createRole(item)
103
+ .then((data) => {
104
+ this.didCreate(data);
105
+ this.created += 1;
117
106
  })
118
107
  .catch((err) => {
119
- throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
108
+ throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
120
109
  }),
121
110
  })
122
111
  .promise();
123
- }
124
- else {
125
- logger_1.default.warn(`Detected the following roles should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
112
+ });
113
+ }
114
+ deleteRole(data) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ yield this.client.roles.delete({ id: data.id });
117
+ });
118
+ }
119
+ deleteRoles(dels) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
122
+ this.config('AUTH0_ALLOW_DELETE') === true) {
123
+ yield this.client.pool
124
+ .addEachTask({
125
+ data: dels || [],
126
+ generator: (item) => this.deleteRole(item)
127
+ .then(() => {
128
+ this.didDelete(item);
129
+ this.deleted += 1;
130
+ })
131
+ .catch((err) => {
132
+ throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
133
+ }),
134
+ })
135
+ .promise();
136
+ }
137
+ else {
138
+ logger_1.default.warn(`Detected the following roles should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
126
139
  \n${dels.map((i) => this.objString(i)).join('\n')}`);
127
- }
140
+ }
141
+ });
128
142
  }
129
- async updateRole(data, roles) {
130
- const existingRole = await roles.find((roleDataForUpdate) => roleDataForUpdate.name === data.name);
131
- const params = { id: data.id };
132
- const newPermissions = data.permissions;
133
- delete data.permissions;
134
- delete data.id;
135
- await this.client.roles.update(params.id, data);
136
- if (typeof existingRole.permissions !== 'undefined' && existingRole.permissions.length > 0) {
137
- await this.client.roles.permissions.delete(params.id, {
138
- permissions: existingRole.permissions,
139
- });
140
- }
141
- if (typeof newPermissions !== 'undefined' && newPermissions.length > 0) {
142
- await this.client.roles.permissions.add(params.id, { permissions: newPermissions });
143
- }
144
- return params;
143
+ updateRole(data, roles) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const existingRole = yield roles.find((roleDataForUpdate) => roleDataForUpdate.name === data.name);
146
+ const params = { id: data.id };
147
+ const newPermissions = data.permissions;
148
+ delete data.permissions;
149
+ delete data.id;
150
+ yield this.client.roles.update(params, data);
151
+ if (typeof existingRole.permissions !== 'undefined' && existingRole.permissions.length > 0) {
152
+ yield this.client.roles.deletePermissions(params, { permissions: existingRole.permissions });
153
+ }
154
+ if (typeof newPermissions !== 'undefined' && newPermissions.length > 0) {
155
+ yield this.client.roles.addPermissions(params, { permissions: newPermissions });
156
+ }
157
+ return params;
158
+ });
145
159
  }
146
- async updateRoles(updates, roles) {
147
- await this.client.pool
148
- .addEachTask({
149
- data: updates || [],
150
- generator: (item) => this.updateRole(item, roles)
151
- .then((data) => {
152
- this.didUpdate(data);
153
- this.updated += 1;
160
+ updateRoles(updates, roles) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ yield this.client.pool
163
+ .addEachTask({
164
+ data: updates || [],
165
+ generator: (item) => this.updateRole(item, roles)
166
+ .then((data) => {
167
+ this.didUpdate(data);
168
+ this.updated += 1;
169
+ })
170
+ .catch((err) => {
171
+ throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
172
+ }),
154
173
  })
155
- .catch((err) => {
156
- throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
157
- }),
158
- })
159
- .promise();
174
+ .promise();
175
+ });
160
176
  }
161
- async getType() {
162
- if (this.existing) {
163
- return this.existing;
164
- }
165
- try {
166
- const roles = await (0, client_1.paginate)(this.client.roles.list, {
167
- paginate: true,
168
- include_totals: true,
169
- });
170
- for (let index = 0; index < roles.length; index++) {
171
- const allPermission = [];
172
- /*
173
- let page = 0;
174
- while (true) {
175
- const {
176
- data: { permissions, total },
177
- } = await this.client.roles.permissions.list({
177
+ getType() {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ if (this.existing) {
180
+ return this.existing;
181
+ }
182
+ // in case client version does not support roles
183
+ if (!this.client.roles || typeof this.client.roles.getAll !== 'function') {
184
+ return [];
185
+ }
186
+ try {
187
+ const roles = yield (0, client_1.paginate)(this.client.roles.getAll, {
188
+ paginate: true,
178
189
  include_totals: true,
179
- id: roles[index].id,
180
- page: page,
181
- per_page: 100,
182
- });
183
-
184
- allPermission.push(...permissions);
185
- page += 1;
186
- if (allPermission.length === total) {
187
- break;
188
- }
189
- // if we get an unexpected response, break the loop to avoid infinite loop
190
- if (!isArray(permissions) || typeof total !== 'number') {
191
- break;
192
- }
190
+ });
191
+ for (let index = 0; index < roles.length; index++) {
192
+ // paginate without paginate<T> helper as this is not getAll but getPermissions
193
+ // paginate through all permissions for each role
194
+ const allPermission = [];
195
+ let page = 0;
196
+ while (true) {
197
+ const { data: { permissions, total }, } = yield this.client.roles.getPermissions({
198
+ include_totals: true,
199
+ id: roles[index].id,
200
+ page: page,
201
+ per_page: 100,
202
+ });
203
+ allPermission.push(...permissions);
204
+ page += 1;
205
+ if (allPermission.length === total) {
206
+ break;
207
+ }
208
+ // if we get an unexpected response, break the loop to avoid infinite loop
209
+ if (!(0, lodash_1.isArray)(permissions) || typeof total !== 'number') {
210
+ break;
211
+ }
212
+ }
213
+ const strippedPerms = yield Promise.all(allPermission.map((permission) => __awaiter(this, void 0, void 0, function* () {
214
+ delete permission.resource_server_name;
215
+ delete permission.description;
216
+ return permission;
217
+ })));
218
+ roles[index].permissions = strippedPerms;
193
219
  }
194
- */
195
- const rolesId = roles[index].id;
196
- let permissions = await this.client.roles.permissions.list(rolesId, { per_page: 100 });
197
- do {
198
- allPermission.push(...permissions.data);
199
- permissions = await permissions.getNextPage();
200
- } while (permissions.hasNextPage());
201
- const strippedPerms = await Promise.all(allPermission.map(async (permission) => {
202
- delete permission.resource_server_name;
203
- delete permission.description;
204
- return permission;
205
- }));
206
- roles[index].permissions = strippedPerms;
220
+ this.existing = roles;
221
+ return this.existing;
207
222
  }
208
- this.existing = roles;
209
- return this.existing;
210
- }
211
- catch (err) {
212
- if (err.statusCode === 404 || err.statusCode === 501) {
213
- return [];
223
+ catch (err) {
224
+ if (err.statusCode === 404 || err.statusCode === 501) {
225
+ return [];
226
+ }
227
+ throw err;
214
228
  }
215
- throw err;
216
- }
229
+ });
217
230
  }
218
- async processChanges(assets) {
219
- const { roles } = assets;
220
- // Do nothing if not set
221
- if (!roles)
222
- return;
223
- // Gets roles from destination tenant
224
- const existing = await this.getType();
225
- const changes = (0, calculateChanges_1.calculateChanges)({
226
- handler: this,
227
- assets: roles,
228
- existing,
229
- identifiers: this.identifiers,
230
- allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
231
+ processChanges(assets) {
232
+ return __awaiter(this, void 0, void 0, function* () {
233
+ const { roles } = assets;
234
+ // Do nothing if not set
235
+ if (!roles)
236
+ return;
237
+ // Gets roles from destination tenant
238
+ const existing = yield this.getType();
239
+ const changes = (0, calculateChanges_1.calculateChanges)({
240
+ handler: this,
241
+ assets: roles,
242
+ existing,
243
+ identifiers: this.identifiers,
244
+ allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
245
+ });
246
+ logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
247
+ const myChanges = [
248
+ { del: changes.del },
249
+ { create: changes.create },
250
+ { update: changes.update },
251
+ ];
252
+ yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
253
+ switch (true) {
254
+ case change.del && change.del.length > 0:
255
+ if (change.del)
256
+ yield this.deleteRoles(change.del);
257
+ break;
258
+ case change.create && change.create.length > 0:
259
+ yield this.createRoles(changes.create); //TODO: fix this tho change.create
260
+ break;
261
+ case change.update && change.update.length > 0:
262
+ if (change.update)
263
+ yield this.updateRoles(change.update, existing);
264
+ break;
265
+ default:
266
+ break;
267
+ }
268
+ })));
231
269
  });
232
- logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
233
- const myChanges = [
234
- { del: changes.del },
235
- { create: changes.create },
236
- { update: changes.update },
237
- ];
238
- await Promise.all(myChanges.map(async (change) => {
239
- switch (true) {
240
- case change.del && change.del.length > 0:
241
- if (change.del)
242
- await this.deleteRoles(change.del);
243
- break;
244
- case change.create && change.create.length > 0:
245
- await this.createRoles(changes.create);
246
- break;
247
- case change.update && change.update.length > 0:
248
- if (change.update)
249
- await this.updateRoles(change.update, existing);
250
- break;
251
- default:
252
- break;
253
- }
254
- }));
255
270
  }
256
271
  }
257
272
  exports.default = RolesHandler;
258
273
  __decorate([
259
274
  (0, default_1.order)('60')
260
275
  ], RolesHandler.prototype, "processChanges", null);
276
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roles.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/roles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAiC;AACjC,qDAAkD;AAClD,6DAA0D;AAC1D,6DAAkC;AAElC,sCAAqC;AAExB,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,EAAE,EAAE,E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