@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.
- package/CHANGELOG.md +36 -0
- package/package.json +15 -12
- package/run-provision-accounts.mjs +3 -0
- package/run-provision-admin.mjs +3 -0
- package/scripts/ProvisionAccounts.res +325 -0
- package/scripts/ProvisionAccounts.res.mjs +337 -0
- package/scripts/ProvisionAdmin.res +275 -0
- package/scripts/ProvisionAdmin.res.mjs +289 -0
- package/scripts/ProvisionCognito.res +149 -0
- package/scripts/ProvisionCognito.res.mjs +98 -0
- package/scripts/ProvisionIdentity.res +84 -14
- package/scripts/ProvisionIdentity.res.mjs +72 -7
- package/scripts/ProvisionProvider.res +104 -0
- package/scripts/ProvisionProvider.res.mjs +123 -0
- package/src/Platform.res +358 -329
- package/src/Platform.res.mjs +24 -12
- package/src/Platform_Casts.res +13 -4
- package/src/Platform_Stack.res +119 -9
- package/src/Platform_Stack.res.mjs +42 -4
- package/src/adapter/Api/AppSyncEventsSigner_Ops.res +8 -4
- package/src/adapter/Api/AppSync_EventsApi.res +12 -14
- package/src/adapter/Api/AppSync_Resolver_Native.res +3 -4
- package/src/adapter/Api/AppSync_Resolver_Retrying.res +78 -70
- package/src/adapter/Api/AppSync_SourceApiAssociation_Retrying.res +11 -8
- package/src/adapter/Api/Platform_AdminScan_Ops.res +15 -14
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res +10 -2
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda_Ops.res +40 -50
- package/src/adapter/Api/Platform_UIFragments_Lambda.res +39 -32
- package/src/adapter/Api/Platform_UIFragments_Lambda_Ops.res +5 -2
- package/src/adapter/Auth/Auth_ActiveRolePoolAttachment.res +0 -1
- package/src/adapter/Auth/Auth_ActiveRoleStore.res +1 -2
- package/src/adapter/Auth/Auth_ActiveRoleStore_Schema.res +1 -4
- package/src/adapter/Auth/Auth_ActiveRoleTrigger_Ops.res +5 -2
- package/src/adapter/Auth/Auth_Cognito.res +3 -9
- package/src/adapter/Auth/Auth_LoginIdentifier.res +66 -0
- package/src/adapter/Auth/Auth_LoginIdentifier.res.mjs +70 -0
- package/src/adapter/Auth/Auth_SignUpMode.res +78 -0
- package/src/adapter/Auth/Auth_SignUpMode.res.mjs +56 -0
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync.res +1 -4
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_NoOp.res +3 -1
- package/src/adapter/CommandGenerator/InboundTranslationResolvers_AppSync.res +1 -4
- package/src/adapter/CommandTopic/CommandTopicChannel_SQS.res +7 -4
- package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Async.res +6 -1
- package/src/adapter/CommandTopic/CommandTopicChannel_SQS_FIFO.res +7 -4
- package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res +24 -18
- package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Sync.res +9 -4
- package/src/adapter/CommandTopic/CommandTopicRegistry.res +1 -4
- package/src/adapter/Counter/CounterHandler_DynamoDbStream.res +15 -15
- package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb.res +9 -5
- package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res +179 -213
- package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream.res +5 -5
- package/src/adapter/EventCollector/EventCollectorChannel_Helpers.res +6 -2
- package/src/adapter/EventCollector/EventCollectorChannel_SQS.res +14 -7
- package/src/adapter/EventCollector/EventCollectorChannel_SQS_FIFO.res +14 -7
- package/src/adapter/EventCollector/EventCollectorChannel_SQS_Runtime.res +6 -3
- package/src/adapter/EventLog/EventLogStorage_DynamoDbStream.res +6 -1
- package/src/adapter/EventLog/EventLogStorage_DynamoDb_Runtime.res +13 -17
- package/src/adapter/EventLog/EventLogStorage_Postgres.res +7 -4
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res +12 -7
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync_Ops.res +4 -2
- package/src/adapter/EventTopic/EventTopicPublisher_DynamoDbStream.res +3 -2
- package/src/adapter/EventTopic/EventTopicPublisher_SNS.res +20 -12
- package/src/adapter/EventTopic/EventTopicPublisher_SNS_FIFO.res +21 -9
- package/src/adapter/EventTopic/EventTopicPublisher_SNS_Runtime.res +5 -3
- package/src/adapter/Geocoder/Geocoder_AwsLocation_Resolver.res +6 -3
- package/src/adapter/Mcp/MCP_Lambda.res +31 -46
- package/src/adapter/Messaging/Messaging_Ses_Backend.res +11 -7
- package/src/adapter/Messaging/Messaging_Ses_Backend.res.mjs +2 -4
- package/src/adapter/Monitoring/Monitoring_CloudWatch.res +16 -16
- package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res +5 -10
- package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res +4 -2
- package/src/adapter/Postgres/PgConnection.res +6 -5
- package/src/adapter/Postgres/PgMigration_Builder.res +4 -8
- package/src/adapter/Postgres/PgRuntime.res +4 -7
- package/src/adapter/QueryDb/PgQueryResolver_Builder.res +9 -11
- package/src/adapter/QueryDb/PgQueryResolver_Lambda.res +22 -21
- package/src/adapter/QueryDb/QueryDbResolvers_AppSync.res +114 -111
- package/src/adapter/QueryDb/QueryDbResolvers_Lambda.res +1 -7
- package/src/adapter/QueryDb/QueryDbStorage.res +4 -2
- package/src/adapter/QueryDb/QueryDbStorage_DynamoDb.res +23 -24
- package/src/adapter/QueryDb/QueryDbStorage_DynamoDbStream.res +8 -2
- package/src/adapter/QueryDb/QueryDbStorage_DynamoDb_Runtime.res +71 -73
- package/src/adapter/QueryDb/QueryDbStorage_Postgres.res +5 -2
- package/src/adapter/QueryDb/QueryInterceptor_Provisioning.res +1 -4
- package/src/adapter/QueryEngine/QueryEngine_DynamoDb.res +8 -2
- package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res +73 -81
- package/src/adapter/Runtime/AggregateRuntime_Builder_Micro_Async.res +72 -78
- package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res +44 -67
- package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate_Async.res +44 -67
- package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res +53 -82
- package/src/adapter/Runtime/AggregateRuntime_Builder_Single_Async.res +47 -77
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +23 -11
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res.mjs +5 -1
- package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res +80 -97
- package/src/adapter/Runtime/CounterEntryPoint_Ops.res +2 -7
- package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res +16 -10
- package/src/adapter/Runtime/EventCollectorEntryPoint_Ops.res +24 -15
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res +17 -37
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +31 -57
- package/src/adapter/Runtime/EventMapperEntryPoint_Ops.res +18 -24
- package/src/adapter/Runtime/ExtensionPointEntryPoint_Ops.res +1 -5
- package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res +4 -3
- package/src/adapter/Runtime/HeartbeatEntryPoint.res +0 -1
- package/src/adapter/Runtime/PgChangeFeedRelayEntryPoint.res +4 -2
- package/src/adapter/Runtime/PgMigrationEntryPoint.res +0 -1
- package/src/adapter/Runtime/PgQueryResolverEntryPoint_Ops.res +3 -2
- package/src/adapter/Runtime/PluginExtensionPointEntryPoint.res +1 -2
- package/src/adapter/Runtime/ProjectionEntryPoint_Ops.res +4 -5
- package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res +22 -10
- package/src/adapter/Runtime/RuntimeExtensionEntryPoint_Ops.res +8 -2
- package/src/adapter/Runtime/SideEffectHandlerRuntime_Builder_Single.res +14 -31
- package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res +16 -17
- package/src/adapter/Runtime/StateViewSliceEntryPoint_Ops.res +10 -9
- package/src/adapter/Runtime/StateViewSliceRuntime_Builder_Single.res +46 -52
- package/src/adapter/Runtime/StreamRoutedEntryPoint_Ops.res +36 -41
- package/src/adapter/Runtime/TaskBucketEntryPoint_Ops.res +31 -37
- package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res +6 -7
- package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents.res +4 -6
- package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents_Runtime.res +2 -6
- package/src/adapter/StateTopic/StateTopic_AppSync.res +21 -16
- package/src/adapter/StateTopic/StateTopic_AppSync_Ops.res +36 -32
- package/src/adapter/Task/TaskBucket_S3.res +6 -1
- package/src/adapter/Upload/Upload_Claim_S3.res +17 -20
- package/src/adapter/Upload/Upload_Claim_S3_Ops.res +5 -2
- package/src/adapter/Upload/Upload_Presign_S3.res +51 -49
- package/src/capability/Capability_Geocoding_AwsLocation.res +4 -1
- package/src/capability/Capability_Messaging.res +4 -5
- package/src/capability/Capability_Messaging_Ses.res +3 -1
- package/src/capability/Capability_ObjectStore_S3.res +1 -7
- package/src/components/Api/AppSync_Adapter.res +80 -109
- package/src/components/Api/AppSync_Adapter.res.mjs +26 -60
- package/src/components/Api/AppSync_SdlDecorate.res +118 -31
- package/src/components/Api/AppSync_SdlDecorate.res.mjs +45 -0
- package/src/components/AutomationSlice_Builder.res +6 -4
- package/src/components/ExtensionPoint_Builder.res +9 -10
- package/src/components/InboundTranslationSlice_Builder.res +7 -8
- package/src/components/OutboundTranslationSlice_Builder.res +14 -8
- package/src/components/OutboundTranslationSlice_Builder.res.mjs +1 -1
- package/src/components/SideEffectHandler_Single.res +4 -4
- package/src/components/StateViewSlice_Builder.res +6 -4
- package/src/components/StateViewSlice_Builder_Stream.res +6 -4
- package/src/components/Task_Builder_PerBucket.res +10 -11
- package/src/plugin/cloner/ClonerRunner_Fargate.res +3 -10
- package/src/plugin/cloner/ClonerRunner_Fargate_Runtime.res +1 -4
- package/src/plugin/heartbeat/HeartbeatRunner_CloudWatchEvents.res +5 -5
- package/src/plugin/runtime/PluginExtensionPointRuntime_Builder.res +19 -21
- package/src/plugin/runtime/PluginRuntime_Builder.res +167 -188
- package/src/plugin/runtime/Util_PluginMessage_Runtime.res +6 -5
- package/src/plugin/stack/Plugin_Stack.res +104 -103
- package/src/util/Util_AlarmSpec.res +2 -1
- package/src/util/Util_AppSync.res +8 -2
- package/src/util/Util_AppSync_Caller.res +15 -14
- package/src/util/Util_Bundle.res +46 -42
- package/src/util/Util_CognitoGroupUser_Runtime.res +32 -34
- package/src/util/Util_Cognito_Runtime.res +11 -7
- package/src/util/Util_DeadLetterQueue.res +12 -2
- package/src/util/Util_DynamoDb.res +5 -3
- package/src/util/Util_DynamoDbStream.res +7 -3
- package/src/util/Util_DynamoDbStream_Runtime.res +1 -2
- package/src/util/Util_DynamoDb_Runtime.res +23 -41
- package/src/util/Util_HostUiDomain.res +6 -1
- package/src/util/Util_Kinesis_Runtime.res +10 -11
- package/src/util/Util_Lambda.res +12 -5
- package/src/util/Util_LambdaEnvBudget.res +5 -5
- package/src/util/Util_LambdaLogging.res +1 -2
- package/src/util/Util_LogGroup_Adopting.res +1 -4
- package/src/util/Util_ResourceNaming.res +1 -2
- package/src/util/Util_SNS.res +8 -3
- package/src/util/Util_SNS_FIFO.res +1 -1
- package/src/util/Util_SNS_Runtime.res +11 -10
- package/src/util/Util_SQS.res +4 -2
- package/src/util/Util_SQS_FIFO.res +5 -2
- package/src/util/Util_SQS_Runtime.res +37 -36
- package/src/util/Util_ShellConfig.res +3 -2
- package/src/util/Util_StaticBundle.res +1 -3
- package/src/util/Util_StoreLayout.res +4 -1
- package/tests/AWS_TagsTest.res +16 -5
- package/tests/AppSyncEventsSigner_OpsTest.res +11 -2
- package/tests/AppSync_AdapterTest.res +286 -224
- package/tests/AppSync_AdapterTest.res.mjs +69 -0
- package/tests/AppSync_Resolver_RetryingTest.res +64 -44
- package/tests/AppSync_RetirementNarrowingTest.res +59 -46
- package/tests/AppSync_SdlDecorateTest.res +22 -20
- package/tests/AppSync_SourceApiAssociation_RetryingTest.res +40 -22
- package/tests/Auth_ActiveRolePoolAttachmentTest.res +114 -107
- package/tests/Auth_ActiveRoleStoreTest.res +12 -9
- package/tests/Auth_ActiveRoleStore_SchemaTest.res +2 -1
- package/tests/Auth_ActiveRoleTrigger_OpsTest.res +20 -16
- package/tests/Auth_CognitoTest.res +31 -46
- package/tests/Auth_LoginIdentifierTest.res +51 -0
- package/tests/Auth_LoginIdentifierTest.res.mjs +51 -0
- package/tests/Auth_SignUpModeTest.res +56 -0
- package/tests/Auth_SignUpModeTest.res.mjs +53 -0
- package/tests/AutomationSliceEntryPoint_OpsTest.res +69 -67
- package/tests/BakeConvergenceTest.res +22 -25
- package/tests/Capability_MessagingTest.res +28 -12
- package/tests/CommandTopicQueuePolicyTest.res +1 -2
- package/tests/CounterEntryPoint_OpsTest.res +3 -7
- package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res +306 -210
- package/tests/EventCollectorConnectLambdaPreviewTest.res +14 -7
- package/tests/EventCollectorEntryPoint_OpsTest.res +12 -4
- package/tests/EventCollectorPluginDefinitionAssetTest.res +18 -11
- package/tests/EventCollectorReadyGateTest.res +5 -4
- package/tests/EventLogStorage_DynamoDb_RuntimeTest.res +1 -2
- package/tests/EventMapperEntryPoint_OpsTest.res +1 -3
- package/tests/ExtensionPointEntryPoint_OpsTest.res +1 -4
- package/tests/HandlerFactoryDispatchTest.res +97 -70
- package/tests/MCP_LambdaTest.res +16 -27
- package/tests/PgChangeFeedRelay_IntegrationTest.res +123 -93
- package/tests/PgChangeFeedRelay_RuntimeTest.res +13 -10
- package/tests/PgMigrationEntryPoint_IntegrationTest.res +0 -1
- package/tests/PgPipeline_IntegrationTest.res +80 -66
- package/tests/PgQueryDbUnion_IntegrationTest.res +1 -2
- package/tests/PgQueryResolverEntryPoint_OpsTest.res +2 -6
- package/tests/PgQueryResolver_LambdaTest.res +41 -24
- package/tests/Platform_AdminScan_OpsTest.res +4 -1
- package/tests/Platform_ComponentDefinitions_Lambda_OpsTest.res +137 -129
- package/tests/ProjectionEntryPoint_DisplayNameTest.res +7 -3
- package/tests/ProjectionEntryPoint_UnionStampTest.res +3 -2
- package/tests/ProvisionAccountsTest.res +142 -0
- package/tests/ProvisionAccountsTest.res.mjs +153 -0
- package/tests/ProvisionAdminTest.res +55 -0
- package/tests/ProvisionAdminTest.res.mjs +66 -0
- package/tests/ProvisionIdentityTest.res +91 -9
- package/tests/ProvisionIdentityTest.res.mjs +66 -1
- package/tests/QueryDbOwnerIndexTableTest.res +6 -4
- package/tests/QueryDbResolvers_AppSyncTest.res +23 -16
- package/tests/QueryInterceptor_LambdaTest.res +11 -13
- package/tests/ReadModelEntryPoint_OpsTest.res +43 -41
- package/tests/RuntimeExtensionEntryPoint_OpsTest.res +4 -3
- package/tests/SideEffectEntryPoint_OpsTest.res +23 -18
- package/tests/StateChangeDescriptorParityTest.res +28 -26
- package/tests/StateTopicKeySchemaTest.res +18 -15
- package/tests/StateViewSliceEntryPoint_OpsTest.res +55 -44
- package/tests/TaskBucketEntryPoint_OpsTest.res +13 -13
- package/tests/Upload_ClaimTest.res +3 -3
- package/tests/Util_AwsErrorTest.res +4 -7
- package/tests/Util_BundleDependencyClosureTest.res +15 -3
- package/tests/Util_BundleEsmLoaderTest.res +3 -3
- package/tests/Util_BundleResolveTest.res +4 -6
- package/tests/Util_BundleRuntimeExtensionTest.res +17 -18
- package/tests/Util_DcbMetricsTest.res +6 -6
- package/tests/Util_DynamoDbStreamTest.res +4 -5
- package/tests/Util_DynamoDbTest.res +3 -2
- package/tests/Util_LambdaEnvBudgetTest.res +22 -18
- package/tests/Util_LambdaLoggingTest.res +9 -8
- package/tests/Util_LogGroup_AdoptingTest.res +10 -5
- package/tests/Util_LogRetentionTest.res +6 -2
- package/tests/Util_OwnerScopeEnvTest.res +35 -8
- package/tests/Util_OwnerScopeEnvTest.res.mjs +13 -0
- package/tests/Util_SQS_RuntimeTest.res +5 -7
- package/tests/Util_ShellConfigTest.res +7 -17
- package/tests/Util_StaticBundleTest.res +3 -8
- package/tests/Util_StoreLayoutTest.res +17 -12
- package/tests/integration/AggregateEntryPoint_IntegrationTest.res +1 -4
- package/tests/integration/DcbCommandTopicEntryPoint_IntegrationTest.res +15 -15
- package/tests/integration/DcbEventLogStorage_DynamoDb_IntegrationTest.res +296 -232
- package/tests/integration/DcbIntegrationHarness.res +8 -8
- package/tests/integration/EpCompositeSlice.res +16 -8
- package/tests/integration/QueryDbUnion_DynamoDb_IntegrationTest.res +8 -10
- package/tests/integration/StateViewSliceEntryPoint_IntegrationTest.res +10 -10
- package/tests/integration/SvsTestSlice_Projection.res +1 -3
- package/tests/util/Util_AlarmSpecTest.res +62 -49
|
@@ -38,6 +38,8 @@ module Schema = Auth_ActiveRoleStore_Schema
|
|
|
38
38
|
type args = {
|
|
39
39
|
poolName: string,
|
|
40
40
|
providerId: option<string>,
|
|
41
|
+
loginIdentifier: Auth_LoginIdentifier.t,
|
|
42
|
+
signUpMode: Auth_SignUpMode.t,
|
|
41
43
|
help: bool,
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -47,7 +49,15 @@ let defaultPoolName = "ReventlessIdentity"
|
|
|
47
49
|
`--provider-id` that parsed as "absent" would create a *second* pool beside the
|
|
48
50
|
one the operator meant to extend. */
|
|
49
51
|
let parseArgs = (argv: array<string>): result<args, string> => {
|
|
50
|
-
let acc = ref(
|
|
52
|
+
let acc = ref(
|
|
53
|
+
Ok({
|
|
54
|
+
poolName: defaultPoolName,
|
|
55
|
+
providerId: None,
|
|
56
|
+
loginIdentifier: Auth_LoginIdentifier.default,
|
|
57
|
+
signUpMode: Auth_SignUpMode.default,
|
|
58
|
+
help: false,
|
|
59
|
+
}),
|
|
60
|
+
)
|
|
51
61
|
let i = ref(0)
|
|
52
62
|
let count = argv->Array.length
|
|
53
63
|
while i.contents < count {
|
|
@@ -61,10 +71,23 @@ let parseArgs = (argv: array<string>): result<args, string> => {
|
|
|
61
71
|
| (Ok(a), "--provider-id", Some(v)) =>
|
|
62
72
|
acc := Ok({...a, providerId: Some(v)})
|
|
63
73
|
i := i.contents + 2
|
|
74
|
+
| (Ok(a), "--login-identifier", Some(v)) =>
|
|
75
|
+
acc :=
|
|
76
|
+
Auth_LoginIdentifier.parse(Some(v))->Result.map(loginIdentifier => {
|
|
77
|
+
...a,
|
|
78
|
+
loginIdentifier,
|
|
79
|
+
})
|
|
80
|
+
i := i.contents + 2
|
|
81
|
+
| (Ok(a), "--sign-up-mode", Some(v)) =>
|
|
82
|
+
acc := Auth_SignUpMode.parse(Some(v))->Result.map(signUpMode => {...a, signUpMode})
|
|
83
|
+
i := i.contents + 2
|
|
64
84
|
| (Ok(a), "--help", _) | (Ok(a), "-h", _) =>
|
|
65
85
|
acc := Ok({...a, help: true})
|
|
66
86
|
i := i.contents + 1
|
|
67
|
-
| (Ok(_), "--name", None)
|
|
87
|
+
| (Ok(_), "--name", None)
|
|
88
|
+
| (Ok(_), "--provider-id", None)
|
|
89
|
+
| (Ok(_), "--login-identifier", None)
|
|
90
|
+
| (Ok(_), "--sign-up-mode", None) =>
|
|
68
91
|
acc := Error(`${flag} needs a value`)
|
|
69
92
|
| (Ok(_), unknown, _) => acc := Error(`unknown argument "${unknown}"`)
|
|
70
93
|
}
|
|
@@ -72,12 +95,28 @@ let parseArgs = (argv: array<string>): result<args, string> => {
|
|
|
72
95
|
acc.contents
|
|
73
96
|
}
|
|
74
97
|
|
|
98
|
+
let _loginIdentifiers =
|
|
99
|
+
Auth_LoginIdentifier.all->Array.map(Auth_LoginIdentifier.toString)->Array.join(" | ")
|
|
100
|
+
|
|
101
|
+
let _defaultLoginIdentifier = Auth_LoginIdentifier.toString(Auth_LoginIdentifier.default)
|
|
102
|
+
|
|
103
|
+
let _signUpModes = Auth_SignUpMode.all->Array.map(Auth_SignUpMode.toString)->Array.join(" | ")
|
|
104
|
+
|
|
105
|
+
let _defaultSignUpMode = Auth_SignUpMode.toString(Auth_SignUpMode.default)
|
|
106
|
+
|
|
75
107
|
let usage = `
|
|
76
108
|
Provision a Reventless identity provider and its active-role store.
|
|
77
109
|
|
|
78
110
|
--name <name> Pool name to create or adopt (default: ${defaultPoolName})
|
|
79
111
|
--provider-id <id> Use this existing pool instead of creating one; only the
|
|
80
112
|
store is provisioned
|
|
113
|
+
--login-identifier <a> Sign-in attribute for a pool this creates: ${_loginIdentifiers}
|
|
114
|
+
(default: ${_defaultLoginIdentifier}). Fixed at creation —
|
|
115
|
+
no later change is possible without replacing the pool
|
|
116
|
+
and losing every account in it.
|
|
117
|
+
--sign-up-mode <m> Whether a stranger may register themselves: ${_signUpModes}
|
|
118
|
+
(default: ${_defaultSignUpMode}). Correctable later, but on a
|
|
119
|
+
pool shared between stacks it applies to all of them.
|
|
81
120
|
|
|
82
121
|
Creates nothing that a platform stack owns, and never attaches a trigger.
|
|
83
122
|
Region and credentials come from the environment, as for any AWS SDK call.
|
|
@@ -85,15 +124,28 @@ Region and credentials come from the environment, as for any AWS SDK call.
|
|
|
85
124
|
|
|
86
125
|
// ── The pool ─────────────────────────────────────────────────────────────────
|
|
87
126
|
|
|
88
|
-
/** SPA-friendly defaults, matching what auto mode declares:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
127
|
+
/** SPA-friendly defaults, matching what auto mode declares: a 12-character
|
|
128
|
+
password policy, no MFA, admin-only user creation. An operator wanting
|
|
129
|
+
something else edits the pool afterwards rather than having this script grow a
|
|
130
|
+
flag per Cognito setting.
|
|
131
|
+
|
|
132
|
+
Two settings are exceptions and have flags, for two different reasons. The
|
|
133
|
+
sign-in attribute, because it is the one setting no later edit can reach —
|
|
134
|
+
Cognito offers no update for it. Sign-up mode, because a stack pointed at a
|
|
135
|
+
supplied pool holds no handle to set it on, so "edit it afterwards" is the only
|
|
136
|
+
other answer and it leaves the pool's two identity choices in two places. Both
|
|
137
|
+
describe the pool itself rather than a policy detail. */
|
|
138
|
+
let poolSettings = (
|
|
139
|
+
~poolName: string,
|
|
140
|
+
~loginIdentifier: Auth_LoginIdentifier.t,
|
|
141
|
+
~signUpMode: Auth_SignUpMode.t,
|
|
142
|
+
): CognitoIdentityServiceProvider.CreateUserPoolCommand.input => {
|
|
93
143
|
poolName,
|
|
94
|
-
usernameAttributes:
|
|
144
|
+
usernameAttributes: loginIdentifier->Auth_LoginIdentifier.usernameAttributes,
|
|
95
145
|
mfaConfiguration: "OFF",
|
|
96
|
-
adminCreateUserConfig: {
|
|
146
|
+
adminCreateUserConfig: {
|
|
147
|
+
allowAdminCreateUserOnly: signUpMode->Auth_SignUpMode.allowAdminCreateUserOnly,
|
|
148
|
+
},
|
|
97
149
|
policies: {
|
|
98
150
|
passwordPolicy: {
|
|
99
151
|
minimumLength: 12,
|
|
@@ -140,7 +192,9 @@ let findPoolByName = async (~poolName: string): result<option<string>, string> =
|
|
|
140
192
|
| [only] => Ok(Some(only))
|
|
141
193
|
| several =>
|
|
142
194
|
Error(
|
|
143
|
-
`${several
|
|
195
|
+
`${several
|
|
196
|
+
->Array.length
|
|
197
|
+
->Int.toString} user pools are named "${poolName}" (${several->Array.join(
|
|
144
198
|
", ",
|
|
145
199
|
)}). Pass --provider-id to say which one to use; this script will not guess.`,
|
|
146
200
|
)
|
|
@@ -165,12 +219,20 @@ let resolvePool = async (~args: args): result<string, string> =>
|
|
|
165
219
|
Ok(existing)
|
|
166
220
|
| Ok(None) =>
|
|
167
221
|
let created = await CognitoIdentityServiceProvider.CreateUserPoolCommand.make(
|
|
168
|
-
poolSettings(
|
|
222
|
+
poolSettings(
|
|
223
|
+
~poolName=args.poolName,
|
|
224
|
+
~loginIdentifier=args.loginIdentifier,
|
|
225
|
+
~signUpMode=args.signUpMode,
|
|
226
|
+
),
|
|
169
227
|
)->CognitoIdentityServiceProvider.CreateUserPoolCommand.send
|
|
170
228
|
switch created.userPool->Option.flatMap(p => p.id) {
|
|
171
229
|
| None => Error("CreateUserPool returned no pool id")
|
|
172
230
|
| Some(id) =>
|
|
173
|
-
Console.log(
|
|
231
|
+
Console.log(
|
|
232
|
+
`pool ${id} (created, named "${args.poolName}", sign-in on ${Auth_LoginIdentifier.toString(
|
|
233
|
+
args.loginIdentifier,
|
|
234
|
+
)}, sign-up ${Auth_SignUpMode.toString(args.signUpMode)})`,
|
|
235
|
+
)
|
|
174
236
|
Ok(id)
|
|
175
237
|
}
|
|
176
238
|
}
|
|
@@ -246,7 +308,8 @@ let provisionStore = async (~tableName: string): result<unit, string> =>
|
|
|
246
308
|
|
|
247
309
|
/** Printed rather than assumed: nothing here owns these resources, so nothing
|
|
248
310
|
here can wire them up either. */
|
|
249
|
-
let nextSteps = (~providerId: string) =>
|
|
311
|
+
let nextSteps = (~providerId: string) =>
|
|
312
|
+
`
|
|
250
313
|
Configure each platform stack that should use this provider:
|
|
251
314
|
|
|
252
315
|
pulumi config set platform:identityProviderId ${providerId}
|
|
@@ -255,7 +318,14 @@ or set REVENTLESS_IDENTITY_PROVIDER_ID in CI. Every stack on this provider
|
|
|
255
318
|
derives the same store, so there is nothing else to configure.
|
|
256
319
|
|
|
257
320
|
The pre-token-generation trigger is attached by the deploy, not by this script.
|
|
258
|
-
|
|
321
|
+
|
|
322
|
+
Once a stack has deployed against this provider, make the first administrator:
|
|
323
|
+
|
|
324
|
+
pnpm exec provision-admin --provider-id ${providerId} --email you@example.com
|
|
325
|
+
|
|
326
|
+
That is a separate bin because it provisions nothing a stack owns, and because it
|
|
327
|
+
is needed on a pool created here and on one a stack created for itself alike. See
|
|
328
|
+
[ProvisionAdmin].`
|
|
259
329
|
|
|
260
330
|
let run = async (): result<unit, string> =>
|
|
261
331
|
// argv[0] is node, argv[1] this script.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
4
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
4
5
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
5
6
|
import * as ClientDynamodb from "@aws-sdk/client-dynamodb";
|
|
6
7
|
import * as DynamoDb_DynamoDb$AwsSdk from "@reventlessdev/rescript-aws-sdk/src/DynamoDb_DynamoDb.res.mjs";
|
|
7
8
|
import * as Util_AwsError$ReventlessAws from "../src/util/Util_AwsError.res.mjs";
|
|
9
|
+
import * as Auth_SignUpMode$ReventlessAws from "../src/adapter/Auth/Auth_SignUpMode.res.mjs";
|
|
10
|
+
import * as Auth_LoginIdentifier$ReventlessAws from "../src/adapter/Auth/Auth_LoginIdentifier.res.mjs";
|
|
8
11
|
import * as CognitoIdentityServiceProvider$AwsSdk from "@reventlessdev/rescript-aws-sdk/src/CognitoIdentityServiceProvider.res.mjs";
|
|
9
12
|
import * as ClientCognitoIdentityProvider from "@aws-sdk/client-cognito-identity-provider";
|
|
10
13
|
import * as Auth_ActiveRoleStore_Schema$ReventlessAws from "../src/adapter/Auth/Auth_ActiveRoleStore_Schema.res.mjs";
|
|
@@ -17,6 +20,8 @@ function parseArgs(argv) {
|
|
|
17
20
|
_0: {
|
|
18
21
|
poolName: defaultPoolName,
|
|
19
22
|
providerId: undefined,
|
|
23
|
+
loginIdentifier: Auth_LoginIdentifier$ReventlessAws.default,
|
|
24
|
+
signUpMode: Auth_SignUpMode$ReventlessAws.default,
|
|
20
25
|
help: false
|
|
21
26
|
}
|
|
22
27
|
};
|
|
@@ -31,6 +36,20 @@ function parseArgs(argv) {
|
|
|
31
36
|
let a = match._0;
|
|
32
37
|
let exit$1 = 0;
|
|
33
38
|
switch (flag) {
|
|
39
|
+
case "--login-identifier" :
|
|
40
|
+
if (value !== undefined) {
|
|
41
|
+
acc = Stdlib_Result.map(Auth_LoginIdentifier$ReventlessAws.parse(value), loginIdentifier => ({
|
|
42
|
+
poolName: a.poolName,
|
|
43
|
+
providerId: a.providerId,
|
|
44
|
+
loginIdentifier: loginIdentifier,
|
|
45
|
+
signUpMode: a.signUpMode,
|
|
46
|
+
help: a.help
|
|
47
|
+
}));
|
|
48
|
+
i = i + 2 | 0;
|
|
49
|
+
} else {
|
|
50
|
+
exit = 1;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
34
53
|
case "--name" :
|
|
35
54
|
if (value !== undefined) {
|
|
36
55
|
acc = {
|
|
@@ -38,6 +57,8 @@ function parseArgs(argv) {
|
|
|
38
57
|
_0: {
|
|
39
58
|
poolName: value,
|
|
40
59
|
providerId: a.providerId,
|
|
60
|
+
loginIdentifier: a.loginIdentifier,
|
|
61
|
+
signUpMode: a.signUpMode,
|
|
41
62
|
help: a.help
|
|
42
63
|
}
|
|
43
64
|
};
|
|
@@ -53,6 +74,8 @@ function parseArgs(argv) {
|
|
|
53
74
|
_0: {
|
|
54
75
|
poolName: a.poolName,
|
|
55
76
|
providerId: value,
|
|
77
|
+
loginIdentifier: a.loginIdentifier,
|
|
78
|
+
signUpMode: a.signUpMode,
|
|
56
79
|
help: a.help
|
|
57
80
|
}
|
|
58
81
|
};
|
|
@@ -61,6 +84,20 @@ function parseArgs(argv) {
|
|
|
61
84
|
exit = 1;
|
|
62
85
|
}
|
|
63
86
|
break;
|
|
87
|
+
case "--sign-up-mode" :
|
|
88
|
+
if (value !== undefined) {
|
|
89
|
+
acc = Stdlib_Result.map(Auth_SignUpMode$ReventlessAws.parse(value), signUpMode => ({
|
|
90
|
+
poolName: a.poolName,
|
|
91
|
+
providerId: a.providerId,
|
|
92
|
+
loginIdentifier: a.loginIdentifier,
|
|
93
|
+
signUpMode: signUpMode,
|
|
94
|
+
help: a.help
|
|
95
|
+
}));
|
|
96
|
+
i = i + 2 | 0;
|
|
97
|
+
} else {
|
|
98
|
+
exit = 1;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
64
101
|
case "--help" :
|
|
65
102
|
case "-h" :
|
|
66
103
|
exit$1 = 2;
|
|
@@ -77,6 +114,8 @@ function parseArgs(argv) {
|
|
|
77
114
|
_0: {
|
|
78
115
|
poolName: a.poolName,
|
|
79
116
|
providerId: a.providerId,
|
|
117
|
+
loginIdentifier: a.loginIdentifier,
|
|
118
|
+
signUpMode: a.signUpMode,
|
|
80
119
|
help: true
|
|
81
120
|
}
|
|
82
121
|
};
|
|
@@ -95,21 +134,36 @@ function parseArgs(argv) {
|
|
|
95
134
|
return acc;
|
|
96
135
|
}
|
|
97
136
|
|
|
137
|
+
let _loginIdentifiers = Auth_LoginIdentifier$ReventlessAws.all.map(Auth_LoginIdentifier$ReventlessAws.toString).join(" | ");
|
|
138
|
+
|
|
139
|
+
let _defaultLoginIdentifier = Auth_LoginIdentifier$ReventlessAws.toString(Auth_LoginIdentifier$ReventlessAws.default);
|
|
140
|
+
|
|
141
|
+
let _signUpModes = Auth_SignUpMode$ReventlessAws.all.map(Auth_SignUpMode$ReventlessAws.toString).join(" | ");
|
|
142
|
+
|
|
143
|
+
let _defaultSignUpMode = Auth_SignUpMode$ReventlessAws.toString(Auth_SignUpMode$ReventlessAws.default);
|
|
144
|
+
|
|
98
145
|
let usage = `
|
|
99
146
|
Provision a Reventless identity provider and its active-role store.
|
|
100
147
|
|
|
101
148
|
--name <name> Pool name to create or adopt (default: ` + defaultPoolName + `)
|
|
102
149
|
--provider-id <id> Use this existing pool instead of creating one; only the
|
|
103
150
|
store is provisioned
|
|
151
|
+
--login-identifier <a> Sign-in attribute for a pool this creates: ` + _loginIdentifiers + `
|
|
152
|
+
(default: ` + _defaultLoginIdentifier + `). Fixed at creation —
|
|
153
|
+
no later change is possible without replacing the pool
|
|
154
|
+
and losing every account in it.
|
|
155
|
+
--sign-up-mode <m> Whether a stranger may register themselves: ` + _signUpModes + `
|
|
156
|
+
(default: ` + _defaultSignUpMode + `). Correctable later, but on a
|
|
157
|
+
pool shared between stacks it applies to all of them.
|
|
104
158
|
|
|
105
159
|
Creates nothing that a platform stack owns, and never attaches a trigger.
|
|
106
160
|
Region and credentials come from the environment, as for any AWS SDK call.
|
|
107
161
|
`;
|
|
108
162
|
|
|
109
|
-
function poolSettings(poolName) {
|
|
163
|
+
function poolSettings(poolName, loginIdentifier, signUpMode) {
|
|
110
164
|
return {
|
|
111
165
|
PoolName: poolName,
|
|
112
|
-
UsernameAttributes:
|
|
166
|
+
UsernameAttributes: Auth_LoginIdentifier$ReventlessAws.usernameAttributes(loginIdentifier),
|
|
113
167
|
MfaConfiguration: "OFF",
|
|
114
168
|
Policies: {
|
|
115
169
|
PasswordPolicy: {
|
|
@@ -120,7 +174,7 @@ function poolSettings(poolName) {
|
|
|
120
174
|
}
|
|
121
175
|
},
|
|
122
176
|
AdminCreateUserConfig: {
|
|
123
|
-
AllowAdminCreateUserOnly:
|
|
177
|
+
AllowAdminCreateUserOnly: Auth_SignUpMode$ReventlessAws.allowAdminCreateUserOnly(signUpMode)
|
|
124
178
|
}
|
|
125
179
|
};
|
|
126
180
|
}
|
|
@@ -194,10 +248,10 @@ async function resolvePool(args) {
|
|
|
194
248
|
_0: existing
|
|
195
249
|
};
|
|
196
250
|
}
|
|
197
|
-
let created = await CognitoIdentityServiceProvider$AwsSdk.CreateUserPoolCommand.send(new ClientCognitoIdentityProvider.CreateUserPoolCommand(poolSettings(args.poolName)));
|
|
251
|
+
let created = await CognitoIdentityServiceProvider$AwsSdk.CreateUserPoolCommand.send(new ClientCognitoIdentityProvider.CreateUserPoolCommand(poolSettings(args.poolName, args.loginIdentifier, args.signUpMode)));
|
|
198
252
|
let id$1 = Stdlib_Option.flatMap(created.UserPool, p => p.Id);
|
|
199
253
|
if (id$1 !== undefined) {
|
|
200
|
-
console.log(`pool ` + id$1 + ` (created, named "` + args.poolName + `")`);
|
|
254
|
+
console.log(`pool ` + id$1 + ` (created, named "` + args.poolName + `", sign-in on ` + Auth_LoginIdentifier$ReventlessAws.toString(args.loginIdentifier) + `, sign-up ` + Auth_SignUpMode$ReventlessAws.toString(args.signUpMode) + `)`);
|
|
201
255
|
return {
|
|
202
256
|
TAG: "Ok",
|
|
203
257
|
_0: id$1
|
|
@@ -305,7 +359,14 @@ or set REVENTLESS_IDENTITY_PROVIDER_ID in CI. Every stack on this provider
|
|
|
305
359
|
derives the same store, so there is nothing else to configure.
|
|
306
360
|
|
|
307
361
|
The pre-token-generation trigger is attached by the deploy, not by this script.
|
|
308
|
-
|
|
362
|
+
|
|
363
|
+
Once a stack has deployed against this provider, make the first administrator:
|
|
364
|
+
|
|
365
|
+
pnpm exec provision-admin --provider-id ` + providerId + ` --email you@example.com
|
|
366
|
+
|
|
367
|
+
That is a separate bin because it provisions nothing a stack owns, and because it
|
|
368
|
+
is needed on a pool created here and on one a stack created for itself alike. See
|
|
369
|
+
[ProvisionAdmin].`;
|
|
309
370
|
}
|
|
310
371
|
|
|
311
372
|
async function run() {
|
|
@@ -361,6 +422,10 @@ export {
|
|
|
361
422
|
Schema,
|
|
362
423
|
defaultPoolName,
|
|
363
424
|
parseArgs,
|
|
425
|
+
_loginIdentifiers,
|
|
426
|
+
_defaultLoginIdentifier,
|
|
427
|
+
_signUpModes,
|
|
428
|
+
_defaultSignUpMode,
|
|
364
429
|
usage,
|
|
365
430
|
poolSettings,
|
|
366
431
|
findPoolByName,
|
|
@@ -373,4 +438,4 @@ export {
|
|
|
373
438
|
run,
|
|
374
439
|
main,
|
|
375
440
|
}
|
|
376
|
-
/*
|
|
441
|
+
/* _loginIdentifiers Not a pure module */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/***
|
|
2
|
+
Which identity provider a provisioning run is about.
|
|
3
|
+
|
|
4
|
+
Both bins ask the same question and neither should make the operator answer it
|
|
5
|
+
twice. The docs used to say `--provider-id $(pulumi stack output
|
|
6
|
+
identityProviderId)`, which is a command substitution a tool can perform.
|
|
7
|
+
|
|
8
|
+
🚨 **Three sources, in this order, and the last is a fallback rather than the
|
|
9
|
+
path.** An explicit `--provider-id` wins, then `REVENTLESS_IDENTITY_PROVIDER_ID`
|
|
10
|
+
— the variable [Platform_Stack] reads for the same value, so a CI shell that
|
|
11
|
+
already exports it needs no second spelling — and only then the stack.
|
|
12
|
+
|
|
13
|
+
Reading the stack works in *both* modes, which is the fact that makes this worth
|
|
14
|
+
doing rather than a convenience for auto deployments only: [Platform_Stack]
|
|
15
|
+
exports `identityProviderId` whether it created the pool or was handed one, so a
|
|
16
|
+
BYO deployment re-exports the provider it was given.
|
|
17
|
+
|
|
18
|
+
🚨 **It always reports which source answered, and which stack.** `pulumi stack
|
|
19
|
+
output` with no `--stack` reads whichever stack happens to be selected, so a run
|
|
20
|
+
against `alpha` while the operator believes they are on `beta` would succeed —
|
|
21
|
+
in the wrong pool, leaving working accounts somewhere nobody is looking. That is
|
|
22
|
+
worse than failing. So the stack is resolved by name, named in the output, and
|
|
23
|
+
overridable with `--stack`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Where an id came from, so a run can say so rather than leave it inferred. */
|
|
27
|
+
type source =
|
|
28
|
+
| Flag
|
|
29
|
+
| Environment
|
|
30
|
+
| Stack(string)
|
|
31
|
+
|
|
32
|
+
let describe = (source: source): string =>
|
|
33
|
+
switch source {
|
|
34
|
+
| Flag => "--provider-id"
|
|
35
|
+
| Environment => "REVENTLESS_IDENTITY_PROVIDER_ID"
|
|
36
|
+
| Stack(stack) => `stack ${stack}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The same variable [Platform_Stack] reads for the same value. */
|
|
40
|
+
let envKey = "REVENTLESS_IDENTITY_PROVIDER_ID"
|
|
41
|
+
|
|
42
|
+
/** `stdio` leaves stderr to the caller's terminal but keeps stdout, so a Pulumi
|
|
43
|
+
failure is legible where it happens instead of being swallowed and re-reported
|
|
44
|
+
as a vaguer message here. */
|
|
45
|
+
let pulumi = (args: array<string>): string =>
|
|
46
|
+
NodeChildProcess.execFileSync(
|
|
47
|
+
"pulumi",
|
|
48
|
+
args,
|
|
49
|
+
{encoding: "utf8", stdio: ["ignore", "pipe", "ignore"]},
|
|
50
|
+
)->String.trim
|
|
51
|
+
|
|
52
|
+
/** The stack the working directory currently has selected. `None` when there is
|
|
53
|
+
no Pulumi project here, no stack selected, or no `pulumi` on the PATH — all of
|
|
54
|
+
which are ordinary for someone running against a BYO pool, and none of which
|
|
55
|
+
should be an error until the id is actually needed. */
|
|
56
|
+
let selectedStack = (): option<string> =>
|
|
57
|
+
switch pulumi(["stack", "--show-name"]) {
|
|
58
|
+
| "" => None
|
|
59
|
+
| name => Some(name)
|
|
60
|
+
| exception _ => None
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
The provider id a stack exports.
|
|
65
|
+
|
|
66
|
+
`--stack` is passed explicitly even when it names the already-selected stack, so
|
|
67
|
+
the value read and the name reported cannot drift apart between the two calls.
|
|
68
|
+
*/
|
|
69
|
+
let fromStack = (~stack: string): result<string, string> =>
|
|
70
|
+
switch pulumi(["stack", "output", "identityProviderId", "--stack", stack]) {
|
|
71
|
+
| "" =>
|
|
72
|
+
Error(
|
|
73
|
+
`stack "${stack}" exports no identityProviderId — deploy the platform stack first, or pass --provider-id`,
|
|
74
|
+
)
|
|
75
|
+
| id => Ok(id)
|
|
76
|
+
| exception _ =>
|
|
77
|
+
Error(
|
|
78
|
+
`could not read identityProviderId from stack "${stack}" — is pulumi installed, logged in, and the stack deployed? Pass --provider-id to skip this lookup`,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
The provider this run is about, and where the answer came from.
|
|
84
|
+
|
|
85
|
+
The error names all three sources rather than only the one that was tried last:
|
|
86
|
+
someone who has no Pulumi project here needs to be told about the flag, and
|
|
87
|
+
someone who has one needs to be told it was consulted and came back empty.
|
|
88
|
+
*/
|
|
89
|
+
let resolve = (~given: option<string>, ~stack: option<string>): result<(string, source), string> =>
|
|
90
|
+
switch given {
|
|
91
|
+
| Some(id) => Ok((id, Flag))
|
|
92
|
+
| None =>
|
|
93
|
+
switch NodeProcess.env->Dict.get(envKey) {
|
|
94
|
+
| Some(id) if id->String.trim != "" => Ok((id, Environment))
|
|
95
|
+
| _ =>
|
|
96
|
+
switch stack->Option.orElse(selectedStack()) {
|
|
97
|
+
| None =>
|
|
98
|
+
Error(
|
|
99
|
+
`--provider-id is required (or set ${envKey}). It is also read from a deployed stack, but no Pulumi stack is selected here — run this from the platform package, or pass --stack`,
|
|
100
|
+
)
|
|
101
|
+
| Some(stack) => fromStack(~stack)->Result.map(id => (id, Stack(stack)))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
5
|
+
import * as Nodechild_process from "node:child_process";
|
|
6
|
+
|
|
7
|
+
function describe(source) {
|
|
8
|
+
if (typeof source !== "object") {
|
|
9
|
+
if (source === "Flag") {
|
|
10
|
+
return "--provider-id";
|
|
11
|
+
} else {
|
|
12
|
+
return "REVENTLESS_IDENTITY_PROVIDER_ID";
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
return `stack ` + source._0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let envKey = "REVENTLESS_IDENTITY_PROVIDER_ID";
|
|
20
|
+
|
|
21
|
+
function pulumi(args) {
|
|
22
|
+
return Nodechild_process.execFileSync("pulumi", args, {
|
|
23
|
+
encoding: "utf8",
|
|
24
|
+
stdio: [
|
|
25
|
+
"ignore",
|
|
26
|
+
"pipe",
|
|
27
|
+
"ignore"
|
|
28
|
+
]
|
|
29
|
+
}).trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function selectedStack() {
|
|
33
|
+
let name;
|
|
34
|
+
try {
|
|
35
|
+
name = pulumi([
|
|
36
|
+
"stack",
|
|
37
|
+
"--show-name"
|
|
38
|
+
]);
|
|
39
|
+
} catch (exn) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (name === "") {
|
|
43
|
+
return;
|
|
44
|
+
} else {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fromStack(stack) {
|
|
50
|
+
let id;
|
|
51
|
+
try {
|
|
52
|
+
id = pulumi([
|
|
53
|
+
"stack",
|
|
54
|
+
"output",
|
|
55
|
+
"identityProviderId",
|
|
56
|
+
"--stack",
|
|
57
|
+
stack
|
|
58
|
+
]);
|
|
59
|
+
} catch (exn) {
|
|
60
|
+
return {
|
|
61
|
+
TAG: "Error",
|
|
62
|
+
_0: `could not read identityProviderId from stack "` + stack + `" — is pulumi installed, logged in, and the stack deployed? Pass --provider-id to skip this lookup`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (id === "") {
|
|
66
|
+
return {
|
|
67
|
+
TAG: "Error",
|
|
68
|
+
_0: `stack "` + stack + `" exports no identityProviderId — deploy the platform stack first, or pass --provider-id`
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
71
|
+
return {
|
|
72
|
+
TAG: "Ok",
|
|
73
|
+
_0: id
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function resolve(given, stack) {
|
|
79
|
+
if (given !== undefined) {
|
|
80
|
+
return {
|
|
81
|
+
TAG: "Ok",
|
|
82
|
+
_0: [
|
|
83
|
+
given,
|
|
84
|
+
"Flag"
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let id = process.env[envKey];
|
|
89
|
+
if (id !== undefined && id.trim() !== "") {
|
|
90
|
+
return {
|
|
91
|
+
TAG: "Ok",
|
|
92
|
+
_0: [
|
|
93
|
+
id,
|
|
94
|
+
"Environment"
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
let stack$1 = Stdlib_Option.orElse(stack, selectedStack());
|
|
99
|
+
if (stack$1 !== undefined) {
|
|
100
|
+
return Stdlib_Result.map(fromStack(stack$1), id => [
|
|
101
|
+
id,
|
|
102
|
+
{
|
|
103
|
+
TAG: "Stack",
|
|
104
|
+
_0: stack$1
|
|
105
|
+
}
|
|
106
|
+
]);
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
TAG: "Error",
|
|
110
|
+
_0: `--provider-id is required (or set ` + envKey + `). It is also read from a deployed stack, but no Pulumi stack is selected here — run this from the platform package, or pass --stack`
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
describe,
|
|
117
|
+
envKey,
|
|
118
|
+
pulumi,
|
|
119
|
+
selectedStack,
|
|
120
|
+
fromStack,
|
|
121
|
+
resolve,
|
|
122
|
+
}
|
|
123
|
+
/* node:child_process Not a pure module */
|