@reventlessdev/reventless-aws 3.0.0-alpha.344 → 3.0.0-alpha.346

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 (263) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.json +15 -12
  3. package/run-provision-accounts.mjs +3 -0
  4. package/run-provision-admin.mjs +3 -0
  5. package/scripts/ProvisionAccounts.res +325 -0
  6. package/scripts/ProvisionAccounts.res.mjs +337 -0
  7. package/scripts/ProvisionAdmin.res +275 -0
  8. package/scripts/ProvisionAdmin.res.mjs +289 -0
  9. package/scripts/ProvisionCognito.res +149 -0
  10. package/scripts/ProvisionCognito.res.mjs +98 -0
  11. package/scripts/ProvisionIdentity.res +84 -14
  12. package/scripts/ProvisionIdentity.res.mjs +72 -7
  13. package/scripts/ProvisionProvider.res +104 -0
  14. package/scripts/ProvisionProvider.res.mjs +123 -0
  15. package/src/Platform.res +358 -329
  16. package/src/Platform.res.mjs +24 -12
  17. package/src/Platform_Casts.res +13 -4
  18. package/src/Platform_Stack.res +119 -9
  19. package/src/Platform_Stack.res.mjs +42 -4
  20. package/src/adapter/Api/AppSyncEventsSigner_Ops.res +8 -4
  21. package/src/adapter/Api/AppSync_EventsApi.res +12 -14
  22. package/src/adapter/Api/AppSync_Resolver_Native.res +3 -4
  23. package/src/adapter/Api/AppSync_Resolver_Retrying.res +78 -70
  24. package/src/adapter/Api/AppSync_SourceApiAssociation_Retrying.res +11 -8
  25. package/src/adapter/Api/Platform_AdminScan_Ops.res +15 -14
  26. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res +10 -2
  27. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda_Ops.res +40 -50
  28. package/src/adapter/Api/Platform_UIFragments_Lambda.res +39 -32
  29. package/src/adapter/Api/Platform_UIFragments_Lambda_Ops.res +5 -2
  30. package/src/adapter/Auth/Auth_ActiveRolePoolAttachment.res +0 -1
  31. package/src/adapter/Auth/Auth_ActiveRoleStore.res +1 -2
  32. package/src/adapter/Auth/Auth_ActiveRoleStore_Schema.res +1 -4
  33. package/src/adapter/Auth/Auth_ActiveRoleTrigger_Ops.res +5 -2
  34. package/src/adapter/Auth/Auth_Cognito.res +3 -9
  35. package/src/adapter/Auth/Auth_LoginIdentifier.res +66 -0
  36. package/src/adapter/Auth/Auth_LoginIdentifier.res.mjs +70 -0
  37. package/src/adapter/Auth/Auth_SignUpMode.res +78 -0
  38. package/src/adapter/Auth/Auth_SignUpMode.res.mjs +56 -0
  39. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync.res +1 -4
  40. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_NoOp.res +3 -1
  41. package/src/adapter/CommandGenerator/InboundTranslationResolvers_AppSync.res +1 -4
  42. package/src/adapter/CommandTopic/CommandTopicChannel_SQS.res +7 -4
  43. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Async.res +6 -1
  44. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_FIFO.res +7 -4
  45. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res +24 -18
  46. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Sync.res +9 -4
  47. package/src/adapter/CommandTopic/CommandTopicRegistry.res +1 -4
  48. package/src/adapter/Counter/CounterHandler_DynamoDbStream.res +15 -15
  49. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb.res +9 -5
  50. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res +179 -213
  51. package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream.res +5 -5
  52. package/src/adapter/EventCollector/EventCollectorChannel_Helpers.res +6 -2
  53. package/src/adapter/EventCollector/EventCollectorChannel_SQS.res +14 -7
  54. package/src/adapter/EventCollector/EventCollectorChannel_SQS_FIFO.res +14 -7
  55. package/src/adapter/EventCollector/EventCollectorChannel_SQS_Runtime.res +6 -3
  56. package/src/adapter/EventLog/EventLogStorage_DynamoDbStream.res +6 -1
  57. package/src/adapter/EventLog/EventLogStorage_DynamoDb_Runtime.res +13 -17
  58. package/src/adapter/EventLog/EventLogStorage_Postgres.res +7 -4
  59. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res +12 -7
  60. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync_Ops.res +4 -2
  61. package/src/adapter/EventTopic/EventTopicPublisher_DynamoDbStream.res +3 -2
  62. package/src/adapter/EventTopic/EventTopicPublisher_SNS.res +20 -12
  63. package/src/adapter/EventTopic/EventTopicPublisher_SNS_FIFO.res +21 -9
  64. package/src/adapter/EventTopic/EventTopicPublisher_SNS_Runtime.res +5 -3
  65. package/src/adapter/Geocoder/Geocoder_AwsLocation_Resolver.res +6 -3
  66. package/src/adapter/Mcp/MCP_Lambda.res +31 -46
  67. package/src/adapter/Messaging/Messaging_Ses_Backend.res +11 -7
  68. package/src/adapter/Messaging/Messaging_Ses_Backend.res.mjs +2 -4
  69. package/src/adapter/Monitoring/Monitoring_CloudWatch.res +16 -16
  70. package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res +5 -10
  71. package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res +4 -2
  72. package/src/adapter/Postgres/PgConnection.res +6 -5
  73. package/src/adapter/Postgres/PgMigration_Builder.res +4 -8
  74. package/src/adapter/Postgres/PgRuntime.res +4 -7
  75. package/src/adapter/QueryDb/PgQueryResolver_Builder.res +9 -11
  76. package/src/adapter/QueryDb/PgQueryResolver_Lambda.res +22 -21
  77. package/src/adapter/QueryDb/QueryDbResolvers_AppSync.res +114 -111
  78. package/src/adapter/QueryDb/QueryDbResolvers_Lambda.res +1 -7
  79. package/src/adapter/QueryDb/QueryDbStorage.res +4 -2
  80. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb.res +23 -24
  81. package/src/adapter/QueryDb/QueryDbStorage_DynamoDbStream.res +8 -2
  82. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb_Runtime.res +71 -73
  83. package/src/adapter/QueryDb/QueryDbStorage_Postgres.res +5 -2
  84. package/src/adapter/QueryDb/QueryInterceptor_Provisioning.res +1 -4
  85. package/src/adapter/QueryEngine/QueryEngine_DynamoDb.res +8 -2
  86. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res +73 -81
  87. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro_Async.res +72 -78
  88. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res +44 -67
  89. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate_Async.res +44 -67
  90. package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res +53 -82
  91. package/src/adapter/Runtime/AggregateRuntime_Builder_Single_Async.res +47 -77
  92. package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +23 -11
  93. package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res.mjs +5 -1
  94. package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res +80 -97
  95. package/src/adapter/Runtime/CounterEntryPoint_Ops.res +2 -7
  96. package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res +16 -10
  97. package/src/adapter/Runtime/EventCollectorEntryPoint_Ops.res +24 -15
  98. package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res +17 -37
  99. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +31 -57
  100. package/src/adapter/Runtime/EventMapperEntryPoint_Ops.res +18 -24
  101. package/src/adapter/Runtime/ExtensionPointEntryPoint_Ops.res +1 -5
  102. package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res +4 -3
  103. package/src/adapter/Runtime/HeartbeatEntryPoint.res +0 -1
  104. package/src/adapter/Runtime/PgChangeFeedRelayEntryPoint.res +4 -2
  105. package/src/adapter/Runtime/PgMigrationEntryPoint.res +0 -1
  106. package/src/adapter/Runtime/PgQueryResolverEntryPoint_Ops.res +3 -2
  107. package/src/adapter/Runtime/PluginExtensionPointEntryPoint.res +1 -2
  108. package/src/adapter/Runtime/ProjectionEntryPoint_Ops.res +4 -5
  109. package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res +22 -10
  110. package/src/adapter/Runtime/RuntimeExtensionEntryPoint_Ops.res +8 -2
  111. package/src/adapter/Runtime/SideEffectHandlerRuntime_Builder_Single.res +14 -31
  112. package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res +16 -17
  113. package/src/adapter/Runtime/StateViewSliceEntryPoint_Ops.res +10 -9
  114. package/src/adapter/Runtime/StateViewSliceRuntime_Builder_Single.res +46 -52
  115. package/src/adapter/Runtime/StreamRoutedEntryPoint_Ops.res +36 -41
  116. package/src/adapter/Runtime/TaskBucketEntryPoint_Ops.res +31 -37
  117. package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res +6 -7
  118. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents.res +4 -6
  119. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents_Runtime.res +2 -6
  120. package/src/adapter/StateTopic/StateTopic_AppSync.res +21 -16
  121. package/src/adapter/StateTopic/StateTopic_AppSync_Ops.res +36 -32
  122. package/src/adapter/Task/TaskBucket_S3.res +6 -1
  123. package/src/adapter/Upload/Upload_Claim_S3.res +17 -20
  124. package/src/adapter/Upload/Upload_Claim_S3_Ops.res +5 -2
  125. package/src/adapter/Upload/Upload_Presign_S3.res +51 -49
  126. package/src/capability/Capability_Geocoding_AwsLocation.res +4 -1
  127. package/src/capability/Capability_Messaging.res +4 -5
  128. package/src/capability/Capability_Messaging_Ses.res +3 -1
  129. package/src/capability/Capability_ObjectStore_S3.res +1 -7
  130. package/src/components/Api/AppSync_Adapter.res +80 -109
  131. package/src/components/Api/AppSync_Adapter.res.mjs +26 -60
  132. package/src/components/Api/AppSync_SdlDecorate.res +118 -31
  133. package/src/components/Api/AppSync_SdlDecorate.res.mjs +45 -0
  134. package/src/components/AutomationSlice_Builder.res +6 -4
  135. package/src/components/ExtensionPoint_Builder.res +9 -10
  136. package/src/components/InboundTranslationSlice_Builder.res +7 -8
  137. package/src/components/OutboundTranslationSlice_Builder.res +14 -8
  138. package/src/components/OutboundTranslationSlice_Builder.res.mjs +1 -1
  139. package/src/components/SideEffectHandler_Single.res +4 -4
  140. package/src/components/StateViewSlice_Builder.res +6 -4
  141. package/src/components/StateViewSlice_Builder_Stream.res +6 -4
  142. package/src/components/Task_Builder_PerBucket.res +10 -11
  143. package/src/plugin/cloner/ClonerRunner_Fargate.res +3 -10
  144. package/src/plugin/cloner/ClonerRunner_Fargate_Runtime.res +1 -4
  145. package/src/plugin/heartbeat/HeartbeatRunner_CloudWatchEvents.res +5 -5
  146. package/src/plugin/runtime/PluginExtensionPointRuntime_Builder.res +19 -21
  147. package/src/plugin/runtime/PluginRuntime_Builder.res +167 -188
  148. package/src/plugin/runtime/Util_PluginMessage_Runtime.res +6 -5
  149. package/src/plugin/stack/Plugin_Stack.res +104 -103
  150. package/src/util/Util_AlarmSpec.res +2 -1
  151. package/src/util/Util_AppSync.res +8 -2
  152. package/src/util/Util_AppSync_Caller.res +15 -14
  153. package/src/util/Util_Bundle.res +46 -42
  154. package/src/util/Util_CognitoGroupUser_Runtime.res +32 -34
  155. package/src/util/Util_Cognito_Runtime.res +11 -7
  156. package/src/util/Util_DeadLetterQueue.res +12 -2
  157. package/src/util/Util_DynamoDb.res +5 -3
  158. package/src/util/Util_DynamoDbStream.res +7 -3
  159. package/src/util/Util_DynamoDbStream_Runtime.res +1 -2
  160. package/src/util/Util_DynamoDb_Runtime.res +23 -41
  161. package/src/util/Util_HostUiDomain.res +6 -1
  162. package/src/util/Util_Kinesis_Runtime.res +10 -11
  163. package/src/util/Util_Lambda.res +12 -5
  164. package/src/util/Util_LambdaEnvBudget.res +5 -5
  165. package/src/util/Util_LambdaLogging.res +1 -2
  166. package/src/util/Util_LogGroup_Adopting.res +1 -4
  167. package/src/util/Util_ResourceNaming.res +1 -2
  168. package/src/util/Util_SNS.res +8 -3
  169. package/src/util/Util_SNS_FIFO.res +1 -1
  170. package/src/util/Util_SNS_Runtime.res +11 -10
  171. package/src/util/Util_SQS.res +4 -2
  172. package/src/util/Util_SQS_FIFO.res +5 -2
  173. package/src/util/Util_SQS_Runtime.res +37 -36
  174. package/src/util/Util_ShellConfig.res +3 -2
  175. package/src/util/Util_StaticBundle.res +1 -3
  176. package/src/util/Util_StoreLayout.res +4 -1
  177. package/tests/AWS_TagsTest.res +16 -5
  178. package/tests/AppSyncEventsSigner_OpsTest.res +11 -2
  179. package/tests/AppSync_AdapterTest.res +286 -224
  180. package/tests/AppSync_AdapterTest.res.mjs +69 -0
  181. package/tests/AppSync_Resolver_RetryingTest.res +64 -44
  182. package/tests/AppSync_RetirementNarrowingTest.res +59 -46
  183. package/tests/AppSync_SdlDecorateTest.res +22 -20
  184. package/tests/AppSync_SourceApiAssociation_RetryingTest.res +40 -22
  185. package/tests/Auth_ActiveRolePoolAttachmentTest.res +114 -107
  186. package/tests/Auth_ActiveRoleStoreTest.res +12 -9
  187. package/tests/Auth_ActiveRoleStore_SchemaTest.res +2 -1
  188. package/tests/Auth_ActiveRoleTrigger_OpsTest.res +20 -16
  189. package/tests/Auth_CognitoTest.res +31 -46
  190. package/tests/Auth_LoginIdentifierTest.res +51 -0
  191. package/tests/Auth_LoginIdentifierTest.res.mjs +51 -0
  192. package/tests/Auth_SignUpModeTest.res +56 -0
  193. package/tests/Auth_SignUpModeTest.res.mjs +53 -0
  194. package/tests/AutomationSliceEntryPoint_OpsTest.res +69 -67
  195. package/tests/BakeConvergenceTest.res +22 -25
  196. package/tests/Capability_MessagingTest.res +28 -12
  197. package/tests/CommandTopicQueuePolicyTest.res +1 -2
  198. package/tests/CounterEntryPoint_OpsTest.res +3 -7
  199. package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res +306 -210
  200. package/tests/EventCollectorConnectLambdaPreviewTest.res +14 -7
  201. package/tests/EventCollectorEntryPoint_OpsTest.res +12 -4
  202. package/tests/EventCollectorPluginDefinitionAssetTest.res +18 -11
  203. package/tests/EventCollectorReadyGateTest.res +5 -4
  204. package/tests/EventLogStorage_DynamoDb_RuntimeTest.res +1 -2
  205. package/tests/EventMapperEntryPoint_OpsTest.res +1 -3
  206. package/tests/ExtensionPointEntryPoint_OpsTest.res +1 -4
  207. package/tests/HandlerFactoryDispatchTest.res +97 -70
  208. package/tests/MCP_LambdaTest.res +16 -27
  209. package/tests/PgChangeFeedRelay_IntegrationTest.res +123 -93
  210. package/tests/PgChangeFeedRelay_RuntimeTest.res +13 -10
  211. package/tests/PgMigrationEntryPoint_IntegrationTest.res +0 -1
  212. package/tests/PgPipeline_IntegrationTest.res +80 -66
  213. package/tests/PgQueryDbUnion_IntegrationTest.res +1 -2
  214. package/tests/PgQueryResolverEntryPoint_OpsTest.res +2 -6
  215. package/tests/PgQueryResolver_LambdaTest.res +41 -24
  216. package/tests/Platform_AdminScan_OpsTest.res +4 -1
  217. package/tests/Platform_ComponentDefinitions_Lambda_OpsTest.res +137 -129
  218. package/tests/ProjectionEntryPoint_DisplayNameTest.res +7 -3
  219. package/tests/ProjectionEntryPoint_UnionStampTest.res +3 -2
  220. package/tests/ProvisionAccountsTest.res +142 -0
  221. package/tests/ProvisionAccountsTest.res.mjs +153 -0
  222. package/tests/ProvisionAdminTest.res +55 -0
  223. package/tests/ProvisionAdminTest.res.mjs +66 -0
  224. package/tests/ProvisionIdentityTest.res +91 -9
  225. package/tests/ProvisionIdentityTest.res.mjs +66 -1
  226. package/tests/QueryDbOwnerIndexTableTest.res +6 -4
  227. package/tests/QueryDbResolvers_AppSyncTest.res +23 -16
  228. package/tests/QueryInterceptor_LambdaTest.res +11 -13
  229. package/tests/ReadModelEntryPoint_OpsTest.res +43 -41
  230. package/tests/RuntimeExtensionEntryPoint_OpsTest.res +4 -3
  231. package/tests/SideEffectEntryPoint_OpsTest.res +23 -18
  232. package/tests/StateChangeDescriptorParityTest.res +28 -26
  233. package/tests/StateTopicKeySchemaTest.res +18 -15
  234. package/tests/StateViewSliceEntryPoint_OpsTest.res +55 -44
  235. package/tests/TaskBucketEntryPoint_OpsTest.res +13 -13
  236. package/tests/Upload_ClaimTest.res +3 -3
  237. package/tests/Util_AwsErrorTest.res +4 -7
  238. package/tests/Util_BundleDependencyClosureTest.res +15 -3
  239. package/tests/Util_BundleEsmLoaderTest.res +3 -3
  240. package/tests/Util_BundleResolveTest.res +4 -6
  241. package/tests/Util_BundleRuntimeExtensionTest.res +17 -18
  242. package/tests/Util_DcbMetricsTest.res +6 -6
  243. package/tests/Util_DynamoDbStreamTest.res +4 -5
  244. package/tests/Util_DynamoDbTest.res +3 -2
  245. package/tests/Util_LambdaEnvBudgetTest.res +22 -18
  246. package/tests/Util_LambdaLoggingTest.res +9 -8
  247. package/tests/Util_LogGroup_AdoptingTest.res +10 -5
  248. package/tests/Util_LogRetentionTest.res +6 -2
  249. package/tests/Util_OwnerScopeEnvTest.res +35 -8
  250. package/tests/Util_OwnerScopeEnvTest.res.mjs +13 -0
  251. package/tests/Util_SQS_RuntimeTest.res +5 -7
  252. package/tests/Util_ShellConfigTest.res +7 -17
  253. package/tests/Util_StaticBundleTest.res +3 -8
  254. package/tests/Util_StoreLayoutTest.res +17 -12
  255. package/tests/integration/AggregateEntryPoint_IntegrationTest.res +1 -4
  256. package/tests/integration/DcbCommandTopicEntryPoint_IntegrationTest.res +15 -15
  257. package/tests/integration/DcbEventLogStorage_DynamoDb_IntegrationTest.res +296 -232
  258. package/tests/integration/DcbIntegrationHarness.res +8 -8
  259. package/tests/integration/EpCompositeSlice.res +16 -8
  260. package/tests/integration/QueryDbUnion_DynamoDb_IntegrationTest.res +8 -10
  261. package/tests/integration/StateViewSliceEntryPoint_IntegrationTest.res +10 -10
  262. package/tests/integration/SvsTestSlice_Projection.res +1 -3
  263. package/tests/util/Util_AlarmSpecTest.res +62 -49
@@ -0,0 +1,289 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
4
+ import * as AdminGroup$Reventless from "@reventlessdev/reventless-spec/src/types/AdminGroup.res.mjs";
5
+ import * as Util_Password$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Password.res.mjs";
6
+ import * as Util_AwsError$ReventlessAws from "../src/util/Util_AwsError.res.mjs";
7
+ import * as ProvisionCognito$ReventlessAws from "./ProvisionCognito.res.mjs";
8
+ import * as ProvisionProvider$ReventlessAws from "./ProvisionProvider.res.mjs";
9
+
10
+ function parseArgs(argv) {
11
+ let acc = {
12
+ TAG: "Ok",
13
+ _0: {
14
+ providerId: undefined,
15
+ stack: undefined,
16
+ email: undefined,
17
+ help: false
18
+ }
19
+ };
20
+ let i = 0;
21
+ let count = argv.length;
22
+ while (i < count) {
23
+ let flag = argv[i];
24
+ let value = argv[i + 1 | 0];
25
+ let match = acc;
26
+ let exit = 0;
27
+ if (match.TAG === "Ok") {
28
+ let a = match._0;
29
+ let exit$1 = 0;
30
+ switch (flag) {
31
+ case "--email" :
32
+ if (value !== undefined) {
33
+ acc = {
34
+ TAG: "Ok",
35
+ _0: {
36
+ providerId: a.providerId,
37
+ stack: a.stack,
38
+ email: value,
39
+ help: a.help
40
+ }
41
+ };
42
+ i = i + 2 | 0;
43
+ } else {
44
+ exit = 1;
45
+ }
46
+ break;
47
+ case "--provider-id" :
48
+ if (value !== undefined) {
49
+ acc = {
50
+ TAG: "Ok",
51
+ _0: {
52
+ providerId: value,
53
+ stack: a.stack,
54
+ email: a.email,
55
+ help: a.help
56
+ }
57
+ };
58
+ i = i + 2 | 0;
59
+ } else {
60
+ exit = 1;
61
+ }
62
+ break;
63
+ case "--stack" :
64
+ if (value !== undefined) {
65
+ acc = {
66
+ TAG: "Ok",
67
+ _0: {
68
+ providerId: a.providerId,
69
+ stack: value,
70
+ email: a.email,
71
+ help: a.help
72
+ }
73
+ };
74
+ i = i + 2 | 0;
75
+ } else {
76
+ exit = 1;
77
+ }
78
+ break;
79
+ case "--help" :
80
+ case "-h" :
81
+ exit$1 = 2;
82
+ break;
83
+ default:
84
+ acc = {
85
+ TAG: "Error",
86
+ _0: `unknown argument "` + flag + `"`
87
+ };
88
+ }
89
+ if (exit$1 === 2) {
90
+ acc = {
91
+ TAG: "Ok",
92
+ _0: {
93
+ providerId: a.providerId,
94
+ stack: a.stack,
95
+ email: a.email,
96
+ help: true
97
+ }
98
+ };
99
+ i = i + 1 | 0;
100
+ }
101
+ } else {
102
+ i = count;
103
+ }
104
+ if (exit === 1) {
105
+ acc = {
106
+ TAG: "Error",
107
+ _0: flag + ` needs a value`
108
+ };
109
+ }
110
+ };
111
+ return acc;
112
+ }
113
+
114
+ let usage = `
115
+ Make the first administrator of a Reventless deployment.
116
+
117
+ --provider-id <id> The identity provider to create the account in. Usually
118
+ omitted: it falls back to ` + ProvisionProvider$ReventlessAws.envKey + `,
119
+ then to the identityProviderId exported by the selected
120
+ Pulumi stack — which every deployment exports, whether it
121
+ created the pool or was handed one.
122
+ --stack <name> Read that output from this stack instead of the selected
123
+ one. The run always names the stack it used.
124
+ --email <address> The address they sign in with.
125
+
126
+ Creates the "` + AdminGroup$Reventless.name + `" group if it is missing, the account if
127
+ it is missing, a working password, and the membership between them. Provisions
128
+ nothing that a platform stack owns. Region and credentials come from the
129
+ environment, as for any AWS SDK call.
130
+ `;
131
+
132
+ async function checkPoolAcceptsEmail(providerId) {
133
+ let e = await ProvisionCognito$ReventlessAws.usernameAttributes(providerId);
134
+ if (e.TAG !== "Ok") {
135
+ return e;
136
+ }
137
+ let attributes = e._0;
138
+ if (attributes.length === 0 || attributes.includes("email")) {
139
+ console.log(`pool ` + providerId);
140
+ return {
141
+ TAG: "Ok",
142
+ _0: undefined
143
+ };
144
+ } else {
145
+ return {
146
+ TAG: "Error",
147
+ _0: `pool "` + providerId + `" signs in on ` + attributes.join(", ") + `, not email, so an account created from --email could never authenticate. The sign-in attribute is fixed at pool creation and no update can change it.`
148
+ };
149
+ }
150
+ }
151
+
152
+ function describe(outcome) {
153
+ if (outcome === "Created") {
154
+ return "created";
155
+ } else {
156
+ return "already present";
157
+ }
158
+ }
159
+
160
+ async function ensureGroup(providerId, group) {
161
+ let outcome = await ProvisionCognito$ReventlessAws.ensureGroup(providerId, group, "Reventless administrators");
162
+ console.log(`group ` + group + ` (` + describe(outcome) + `)`);
163
+ }
164
+
165
+ async function ensureUser(providerId, email) {
166
+ let attributes = [
167
+ {
168
+ Name: "email",
169
+ Value: email
170
+ },
171
+ {
172
+ Name: "email_verified",
173
+ Value: "true"
174
+ }
175
+ ];
176
+ let outcome = await ProvisionCognito$ReventlessAws.ensureUser(providerId, email, attributes);
177
+ console.log(`user ` + email + ` (` + describe(outcome) + `)`);
178
+ }
179
+
180
+ async function setPassword(providerId, email, password) {
181
+ await ProvisionCognito$ReventlessAws.setPassword(providerId, email, password);
182
+ console.log(`password (set, permanent)`);
183
+ }
184
+
185
+ async function addToGroup(providerId, email, group) {
186
+ await ProvisionCognito$ReventlessAws.addToGroup(providerId, email, group);
187
+ console.log(`member ` + email + ` in ` + group);
188
+ }
189
+
190
+ let passwordNote = `
191
+ 🚨 This is a bootstrap credential and it is printed above because that is the only
192
+ place it exists — Cognito keeps no recoverable copy. It is now in this
193
+ terminal's scrollback. Sign in, change it, and do not paste it where logs are
194
+ kept. Running this again mints a new one.`;
195
+
196
+ function signInDetails(providerId, email, password, group) {
197
+ return `
198
+ The first administrator is ready.
199
+
200
+ provider ` + providerId + `
201
+ sign in as ` + email + `
202
+ password ` + password + `
203
+ group ` + group + `
204
+ ` + passwordNote + `
205
+
206
+ This script bootstraps the first account only, which is the one that cannot be
207
+ made through a signed-in session because there is no signed-in session yet. The
208
+ rest of the cast is a list rather than a command: declare it in
209
+ .reventless/users.yaml and run \`pnpm exec provision-accounts\`.`;
210
+ }
211
+
212
+ async function run() {
213
+ let e = parseArgs(process.argv.slice(2, process.argv.length));
214
+ if (e.TAG !== "Ok") {
215
+ return e;
216
+ }
217
+ let args = e._0;
218
+ if (args.help) {
219
+ console.log(usage);
220
+ return {
221
+ TAG: "Ok",
222
+ _0: undefined
223
+ };
224
+ }
225
+ let email = args.email;
226
+ if (email === undefined) {
227
+ return {
228
+ TAG: "Error",
229
+ _0: "--email is required — it is the address the administrator signs in with"
230
+ };
231
+ }
232
+ let e$1 = ProvisionProvider$ReventlessAws.resolve(args.providerId, args.stack);
233
+ if (e$1.TAG !== "Ok") {
234
+ return e$1;
235
+ }
236
+ let match = e$1._0;
237
+ let providerId = match[0];
238
+ console.log(`provider ` + providerId + ` (from ` + ProvisionProvider$ReventlessAws.describe(match[1]) + `)`);
239
+ let e$2 = await checkPoolAcceptsEmail(providerId);
240
+ if (e$2.TAG !== "Ok") {
241
+ return e$2;
242
+ }
243
+ let password = Util_Password$Reventless.generate();
244
+ await ensureGroup(providerId, AdminGroup$Reventless.name);
245
+ await ensureUser(providerId, email);
246
+ await setPassword(providerId, email, password);
247
+ await addToGroup(providerId, email, AdminGroup$Reventless.name);
248
+ console.log(signInDetails(providerId, email, password, AdminGroup$Reventless.name));
249
+ return {
250
+ TAG: "Ok",
251
+ _0: undefined
252
+ };
253
+ }
254
+
255
+ async function main() {
256
+ let message;
257
+ try {
258
+ message = await run();
259
+ } catch (raw_exn) {
260
+ let exn = Primitive_exceptions.internalToException(raw_exn);
261
+ console.error(`provision-admin: ` + Util_AwsError$ReventlessAws.describe(exn));
262
+ process.exit(1);
263
+ return;
264
+ }
265
+ if (message.TAG === "Ok") {
266
+ return;
267
+ }
268
+ console.error(`provision-admin: ` + message._0);
269
+ process.exit(1);
270
+ }
271
+
272
+ let Cognito;
273
+
274
+ export {
275
+ Cognito,
276
+ parseArgs,
277
+ usage,
278
+ checkPoolAcceptsEmail,
279
+ describe,
280
+ ensureGroup,
281
+ ensureUser,
282
+ setPassword,
283
+ addToGroup,
284
+ passwordNote,
285
+ signInDetails,
286
+ run,
287
+ main,
288
+ }
289
+ /* Util_Password-Reventless Not a pure module */
@@ -0,0 +1,149 @@
1
+ /***
2
+ The Cognito operations a provisioning run performs, once.
3
+
4
+ Two bins now do the same four things — ensure a group, ensure an account, set a
5
+ permanent password, apply a membership — and `provision-admin` did them first.
6
+ Extracted here rather than copied for the reason [Auth_LoginIdentifier] and
7
+ [Auth_SignUpMode] were: a second copy drifts, and the half that drifts is
8
+ whichever one nobody re-reads.
9
+
10
+ 🚨 **These report rather than print.** `provision-admin` has a line format its
11
+ tests and its docs both describe, and an extraction that took the printing with it
12
+ would have changed that script's output while claiming to change nothing. Each
13
+ caller phrases its own run; what is shared is what the API does.
14
+
15
+ The password generator that used to sit beside these moved further, to
16
+ [Util_Password] in `spec` — the manifest's platform-neutral half needs it, and
17
+ that half must not reach into this package.
18
+ */
19
+
20
+ open AwsSdk
21
+
22
+ module Cognito = CognitoIdentityServiceProvider
23
+
24
+ /** Whether the call made the thing or found it. Both are success; the difference
25
+ is only worth a word in the output, and a caller that treats "already there" as
26
+ a failure makes the second run of a provisioning script an error. */
27
+ type outcome =
28
+ | Created
29
+ | AlreadyPresent
30
+
31
+ /**
32
+ The sign-in attributes a pool was created with.
33
+
34
+ Fixed at pool creation and unchangeable — see [Auth_LoginIdentifier] — so this is
35
+ the one pool fact a provisioning run must read before it writes. An empty list
36
+ means the pool signs in on a plain username, which takes an email-shaped one
37
+ happily; a list naming `email` means a plain username can never authenticate.
38
+
39
+ Described rather than assumed because the symptom of getting it wrong is a
40
+ correctly-created account that simply cannot log in, arriving at a login screen
41
+ far from the run that caused it.
42
+ */
43
+ let usernameAttributes = async (~providerId: string): result<array<string>, string> => {
44
+ let described = await Cognito.DescribeUserPoolCommand.make({
45
+ userPoolId: providerId,
46
+ })->Cognito.DescribeUserPoolCommand.send
47
+ switch described.userPool {
48
+ | None => Error(`DescribeUserPool returned nothing for "${providerId}"`)
49
+ | Some(pool) => Ok(pool.usernameAttributes->Option.getOr([]))
50
+ }
51
+ }
52
+
53
+ /** The group, where a stack has not already declared it.
54
+
55
+ In auto mode the platform stack declares the administrator group as an ordinary
56
+ child of the pool it owns, so this is a no-op. On a supplied pool no stack does,
57
+ because two stacks sharing a provider would both declare it and the second would
58
+ fail on a name that already exists. Every other group a manifest names is in the
59
+ same position: nothing else creates it. */
60
+ let ensureGroup = async (~providerId: string, ~group: string, ~description: string): outcome =>
61
+ try {
62
+ let _ = await Cognito.CreateGroupCommand.make({
63
+ groupName: group,
64
+ userPoolId: providerId,
65
+ description,
66
+ })->Cognito.CreateGroupCommand.send
67
+ Created
68
+ } catch {
69
+ | exn if exn->Util_AwsError.hasCode(~code="GroupExistsException") => AlreadyPresent
70
+ }
71
+
72
+ /**
73
+ The account, where it is not already there.
74
+
75
+ `MessageAction: "SUPPRESS"` stops Cognito emailing an invitation. The invitation
76
+ carries the temporary password the run is about to replace, so sending it would
77
+ tell the new account holder to sign in with a credential that no longer works —
78
+ and on an admin-create-only pool these accounts may carry no deliverable address
79
+ at all.
80
+
81
+ Attributes are the caller's: an administrator created from an email address wants
82
+ `email` and `email_verified` stamped, and a demo account called `shopper` has
83
+ neither and needs none.
84
+ */
85
+ let ensureUser = async (
86
+ ~providerId: string,
87
+ ~username: string,
88
+ ~attributes: array<Cognito.AdminCreateUserCommand.attributeType>,
89
+ ): outcome =>
90
+ try {
91
+ let _ = await Cognito.AdminCreateUserCommand.make({
92
+ userPoolId: providerId,
93
+ username,
94
+ userAttributes: attributes,
95
+ messageAction: "SUPPRESS",
96
+ })->Cognito.AdminCreateUserCommand.send
97
+ Created
98
+ } catch {
99
+ | exn if exn->Util_AwsError.hasCode(~code="UsernameExistsException") => AlreadyPresent
100
+ }
101
+
102
+ /**
103
+ A password the account can actually be used with.
104
+
105
+ 🚨 **The step it is easiest to leave out, and leaving it out reproduces the defect
106
+ these scripts exist to remove.** An administrator-created account holds a
107
+ *temporary* password and lands in `FORCE_CHANGE_PASSWORD`: the first sign-in meets
108
+ a `NEW_PASSWORD_REQUIRED` challenge, which the host UI is not known to handle and
109
+ which the seed client rejects outright — it gets a `ChallengeName` where it
110
+ expects a token. So this sets a permanent password, and the account is `CONFIRMED`
111
+ when it returns.
112
+ */
113
+ let setPassword = async (~providerId: string, ~username: string, ~password: string): unit =>
114
+ await Cognito.AdminSetUserPasswordCommand.make({
115
+ userPoolId: providerId,
116
+ username,
117
+ password,
118
+ permanent: true,
119
+ })->Cognito.AdminSetUserPasswordCommand.send
120
+
121
+ /** Idempotent at the API: adding a user already in the group is not an error, so
122
+ this needs no existence check of its own. */
123
+ let addToGroup = async (~providerId: string, ~username: string, ~group: string): unit =>
124
+ await Cognito.AdminAddUserToGroupCommand.make({
125
+ username,
126
+ groupName: group,
127
+ userPoolId: providerId,
128
+ })->Cognito.AdminAddUserToGroupCommand.send
129
+
130
+ /**
131
+ The id the pool minted for an account.
132
+
133
+ No request supplies it and `AdminCreateUser` does not return it, so it is read
134
+ back — the same way for an account this run just made and one that was already
135
+ there, which is what lets a re-run correct a manifest written by hand.
136
+
137
+ `None` when the pool answers without a `sub`, which should not happen; the caller
138
+ reports it rather than writing a blank id into a file that is read as authority.
139
+ */
140
+ let subOf = async (~providerId: string, ~username: string): option<string> => {
141
+ let user = await Cognito.AdminGetUserCommand.make({
142
+ userPoolId: providerId,
143
+ username,
144
+ })->Cognito.AdminGetUserCommand.send
145
+ user.userAttributes
146
+ ->Option.getOr([])
147
+ ->Array.find(attribute => attribute.name == "sub")
148
+ ->Option.map(attribute => attribute.value)
149
+ }
@@ -0,0 +1,98 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
5
+ import * as Util_AwsError$ReventlessAws from "../src/util/Util_AwsError.res.mjs";
6
+ import * as CognitoIdentityServiceProvider$AwsSdk from "@reventlessdev/rescript-aws-sdk/src/CognitoIdentityServiceProvider.res.mjs";
7
+ import * as ClientCognitoIdentityProvider from "@aws-sdk/client-cognito-identity-provider";
8
+
9
+ async function usernameAttributes(providerId) {
10
+ let described = await CognitoIdentityServiceProvider$AwsSdk.DescribeUserPoolCommand.send(new ClientCognitoIdentityProvider.DescribeUserPoolCommand({
11
+ UserPoolId: providerId
12
+ }));
13
+ let pool = described.UserPool;
14
+ if (pool !== undefined) {
15
+ return {
16
+ TAG: "Ok",
17
+ _0: Stdlib_Option.getOr(pool.UsernameAttributes, [])
18
+ };
19
+ } else {
20
+ return {
21
+ TAG: "Error",
22
+ _0: `DescribeUserPool returned nothing for "` + providerId + `"`
23
+ };
24
+ }
25
+ }
26
+
27
+ async function ensureGroup(providerId, group, description) {
28
+ try {
29
+ await CognitoIdentityServiceProvider$AwsSdk.CreateGroupCommand.send(new ClientCognitoIdentityProvider.CreateGroupCommand({
30
+ GroupName: group,
31
+ UserPoolId: providerId,
32
+ Description: description
33
+ }));
34
+ return "Created";
35
+ } catch (raw_exn) {
36
+ let exn = Primitive_exceptions.internalToException(raw_exn);
37
+ if (Util_AwsError$ReventlessAws.hasCode(exn, "GroupExistsException")) {
38
+ return "AlreadyPresent";
39
+ }
40
+ throw exn;
41
+ }
42
+ }
43
+
44
+ async function ensureUser(providerId, username, attributes) {
45
+ try {
46
+ await CognitoIdentityServiceProvider$AwsSdk.AdminCreateUserCommand.send(new ClientCognitoIdentityProvider.AdminCreateUserCommand({
47
+ UserPoolId: providerId,
48
+ Username: username,
49
+ UserAttributes: attributes,
50
+ MessageAction: "SUPPRESS"
51
+ }));
52
+ return "Created";
53
+ } catch (raw_exn) {
54
+ let exn = Primitive_exceptions.internalToException(raw_exn);
55
+ if (Util_AwsError$ReventlessAws.hasCode(exn, "UsernameExistsException")) {
56
+ return "AlreadyPresent";
57
+ }
58
+ throw exn;
59
+ }
60
+ }
61
+
62
+ async function setPassword(providerId, username, password) {
63
+ return await CognitoIdentityServiceProvider$AwsSdk.AdminSetUserPasswordCommand.send(new ClientCognitoIdentityProvider.AdminSetUserPasswordCommand({
64
+ UserPoolId: providerId,
65
+ Username: username,
66
+ Password: password,
67
+ Permanent: true
68
+ }));
69
+ }
70
+
71
+ async function addToGroup(providerId, username, group) {
72
+ return await CognitoIdentityServiceProvider$AwsSdk.AdminAddUserToGroupCommand.send(new ClientCognitoIdentityProvider.AdminAddUserToGroupCommand({
73
+ Username: username,
74
+ GroupName: group,
75
+ UserPoolId: providerId
76
+ }));
77
+ }
78
+
79
+ async function subOf(providerId, username) {
80
+ let user = await CognitoIdentityServiceProvider$AwsSdk.AdminGetUserCommand.send(new ClientCognitoIdentityProvider.AdminGetUserCommand({
81
+ UserPoolId: providerId,
82
+ Username: username
83
+ }));
84
+ return Stdlib_Option.map(Stdlib_Option.getOr(user.UserAttributes, []).find(attribute => attribute.Name === "sub"), attribute => attribute.Value);
85
+ }
86
+
87
+ let Cognito;
88
+
89
+ export {
90
+ Cognito,
91
+ usernameAttributes,
92
+ ensureGroup,
93
+ ensureUser,
94
+ setPassword,
95
+ addToGroup,
96
+ subOf,
97
+ }
98
+ /* Util_AwsError-ReventlessAws Not a pure module */