alchemy 2.0.0-beta.41 → 2.0.0-beta.43
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/bin/exec.js +2 -9
- package/bin/exec.js.map +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmContributors.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmContributors.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmHistory.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmHistory.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarms.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarms.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmsForMetric.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeAlarmsForMetric.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DescribeAnomalyDetectors.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeAnomalyDetectors.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DescribeInsightRules.d.ts +1 -1
- package/lib/AWS/CloudWatch/DescribeInsightRules.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DisableAlarmActions.d.ts +1 -1
- package/lib/AWS/CloudWatch/DisableAlarmActions.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/DisableInsightRules.d.ts +1 -1
- package/lib/AWS/CloudWatch/DisableInsightRules.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/EnableAlarmActions.d.ts +1 -1
- package/lib/AWS/CloudWatch/EnableAlarmActions.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetAlarmMuteRule.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetAlarmMuteRule.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetDashboard.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetDashboard.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetInsightRuleReport.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetInsightRuleReport.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetMetricData.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetMetricData.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetMetricStatistics.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetMetricStatistics.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetMetricStream.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetMetricStream.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/GetMetricWidgetImage.d.ts +1 -1
- package/lib/AWS/CloudWatch/GetMetricWidgetImage.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListAlarmMuteRules.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListAlarmMuteRules.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListDashboards.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListDashboards.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListManagedInsightRules.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListManagedInsightRules.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListMetricStreams.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListMetricStreams.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListMetrics.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListMetrics.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/ListTagsForResource.d.ts +1 -1
- package/lib/AWS/CloudWatch/ListTagsForResource.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/PutMetricData.d.ts +1 -1
- package/lib/AWS/CloudWatch/PutMetricData.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/SetAlarmState.d.ts +1 -1
- package/lib/AWS/CloudWatch/SetAlarmState.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/BatchExecuteStatement.d.ts +1 -1
- package/lib/AWS/DynamoDB/BatchExecuteStatement.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/BatchGetItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/BatchGetItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/BatchWriteItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/BatchWriteItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/DeleteItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/DeleteItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/DescribeTable.d.ts +1 -1
- package/lib/AWS/DynamoDB/DescribeTable.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/DescribeTimeToLive.d.ts +1 -1
- package/lib/AWS/DynamoDB/DescribeTimeToLive.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/ExecuteStatement.d.ts +1 -1
- package/lib/AWS/DynamoDB/ExecuteStatement.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/ExecuteTransaction.d.ts +1 -1
- package/lib/AWS/DynamoDB/ExecuteTransaction.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/GetItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/GetItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/ListTables.d.ts +1 -1
- package/lib/AWS/DynamoDB/ListTables.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/ListTagsOfResource.d.ts +1 -1
- package/lib/AWS/DynamoDB/ListTagsOfResource.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/PutItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/PutItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/Query.d.ts +1 -1
- package/lib/AWS/DynamoDB/Query.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/RestoreTableToPointInTime.d.ts +1 -1
- package/lib/AWS/DynamoDB/RestoreTableToPointInTime.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/Scan.d.ts +1 -1
- package/lib/AWS/DynamoDB/Scan.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/TransactGetItems.d.ts +1 -1
- package/lib/AWS/DynamoDB/TransactGetItems.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/TransactWriteItems.d.ts +1 -1
- package/lib/AWS/DynamoDB/TransactWriteItems.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/UpdateItem.d.ts +1 -1
- package/lib/AWS/DynamoDB/UpdateItem.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/UpdateTimeToLive.d.ts +1 -1
- package/lib/AWS/DynamoDB/UpdateTimeToLive.d.ts.map +1 -1
- package/lib/AWS/ECS/DescribeTasks.d.ts +1 -1
- package/lib/AWS/ECS/DescribeTasks.d.ts.map +1 -1
- package/lib/AWS/ECS/ListTasks.d.ts +1 -1
- package/lib/AWS/ECS/ListTasks.d.ts.map +1 -1
- package/lib/AWS/ECS/RunTask.d.ts +1 -1
- package/lib/AWS/ECS/RunTask.d.ts.map +1 -1
- package/lib/AWS/ECS/StopTask.d.ts +1 -1
- package/lib/AWS/ECS/StopTask.d.ts.map +1 -1
- package/lib/AWS/EventBridge/DescribeEventBus.d.ts +1 -1
- package/lib/AWS/EventBridge/DescribeEventBus.d.ts.map +1 -1
- package/lib/AWS/EventBridge/DescribeRule.d.ts +1 -1
- package/lib/AWS/EventBridge/DescribeRule.d.ts.map +1 -1
- package/lib/AWS/EventBridge/EventSource.d.ts +2 -2
- package/lib/AWS/EventBridge/ListEventBuses.d.ts +1 -1
- package/lib/AWS/EventBridge/ListEventBuses.d.ts.map +1 -1
- package/lib/AWS/EventBridge/ListRules.d.ts +1 -1
- package/lib/AWS/EventBridge/ListRules.d.ts.map +1 -1
- package/lib/AWS/EventBridge/ListTargetsByRule.d.ts +1 -1
- package/lib/AWS/EventBridge/ListTargetsByRule.d.ts.map +1 -1
- package/lib/AWS/EventBridge/PutEvents.d.ts +1 -1
- package/lib/AWS/EventBridge/PutEvents.d.ts.map +1 -1
- package/lib/AWS/EventBridge/TestEventPattern.d.ts +1 -1
- package/lib/AWS/EventBridge/TestEventPattern.d.ts.map +1 -1
- package/lib/AWS/EventBridge/ToLambda.d.ts +1 -1
- package/lib/AWS/EventBridge/ToLambda.d.ts.map +1 -1
- package/lib/AWS/EventBridge/ToQueue.d.ts +1 -1
- package/lib/AWS/EventBridge/ToQueue.d.ts.map +1 -1
- package/lib/AWS/Kinesis/DescribeAccountSettings.d.ts +1 -1
- package/lib/AWS/Kinesis/DescribeAccountSettings.d.ts.map +1 -1
- package/lib/AWS/Kinesis/DescribeLimits.d.ts +1 -1
- package/lib/AWS/Kinesis/DescribeLimits.d.ts.map +1 -1
- package/lib/AWS/Kinesis/DescribeStream.d.ts +1 -1
- package/lib/AWS/Kinesis/DescribeStream.d.ts.map +1 -1
- package/lib/AWS/Kinesis/DescribeStreamConsumer.d.ts +1 -1
- package/lib/AWS/Kinesis/DescribeStreamConsumer.d.ts.map +1 -1
- package/lib/AWS/Kinesis/DescribeStreamSummary.d.ts +1 -1
- package/lib/AWS/Kinesis/DescribeStreamSummary.d.ts.map +1 -1
- package/lib/AWS/Kinesis/GetRecords.d.ts +1 -1
- package/lib/AWS/Kinesis/GetRecords.d.ts.map +1 -1
- package/lib/AWS/Kinesis/GetResourcePolicy.d.ts +1 -1
- package/lib/AWS/Kinesis/GetResourcePolicy.d.ts.map +1 -1
- package/lib/AWS/Kinesis/GetShardIterator.d.ts +1 -1
- package/lib/AWS/Kinesis/GetShardIterator.d.ts.map +1 -1
- package/lib/AWS/Kinesis/ListShards.d.ts +1 -1
- package/lib/AWS/Kinesis/ListShards.d.ts.map +1 -1
- package/lib/AWS/Kinesis/ListStreamConsumers.d.ts +1 -1
- package/lib/AWS/Kinesis/ListStreamConsumers.d.ts.map +1 -1
- package/lib/AWS/Kinesis/ListStreams.d.ts +1 -1
- package/lib/AWS/Kinesis/ListStreams.d.ts.map +1 -1
- package/lib/AWS/Kinesis/ListTagsForResource.d.ts +1 -1
- package/lib/AWS/Kinesis/ListTagsForResource.d.ts.map +1 -1
- package/lib/AWS/Kinesis/PutRecord.d.ts +1 -1
- package/lib/AWS/Kinesis/PutRecord.d.ts.map +1 -1
- package/lib/AWS/Kinesis/PutRecords.d.ts +1 -1
- package/lib/AWS/Kinesis/PutRecords.d.ts.map +1 -1
- package/lib/AWS/Kinesis/StreamSink.d.ts +1 -1
- package/lib/AWS/Kinesis/StreamSink.d.ts.map +1 -1
- package/lib/AWS/Kinesis/SubscribeToShard.d.ts +1 -1
- package/lib/AWS/Kinesis/SubscribeToShard.d.ts.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/InvokeFunction.d.ts +1 -1
- package/lib/AWS/Lambda/InvokeFunction.d.ts.map +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +2 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/RDS/Connect.d.ts +1 -1
- package/lib/AWS/RDS/Connect.d.ts.map +1 -1
- package/lib/AWS/RDSData/BatchExecuteStatement.d.ts +1 -1
- package/lib/AWS/RDSData/BatchExecuteStatement.d.ts.map +1 -1
- package/lib/AWS/RDSData/BeginTransaction.d.ts +1 -1
- package/lib/AWS/RDSData/BeginTransaction.d.ts.map +1 -1
- package/lib/AWS/RDSData/CommitTransaction.d.ts +1 -1
- package/lib/AWS/RDSData/CommitTransaction.d.ts.map +1 -1
- package/lib/AWS/RDSData/ExecuteSql.d.ts +1 -1
- package/lib/AWS/RDSData/ExecuteSql.d.ts.map +1 -1
- package/lib/AWS/RDSData/ExecuteStatement.d.ts +1 -1
- package/lib/AWS/RDSData/ExecuteStatement.d.ts.map +1 -1
- package/lib/AWS/RDSData/RollbackTransaction.d.ts +1 -1
- package/lib/AWS/RDSData/RollbackTransaction.d.ts.map +1 -1
- package/lib/AWS/S3/AbortMultipartUpload.d.ts +1 -1
- package/lib/AWS/S3/AbortMultipartUpload.d.ts.map +1 -1
- package/lib/AWS/S3/CompleteMultipartUpload.d.ts +1 -1
- package/lib/AWS/S3/CompleteMultipartUpload.d.ts.map +1 -1
- package/lib/AWS/S3/CopyObject.d.ts +1 -1
- package/lib/AWS/S3/CopyObject.d.ts.map +1 -1
- package/lib/AWS/S3/CreateMultipartUpload.d.ts +1 -1
- package/lib/AWS/S3/CreateMultipartUpload.d.ts.map +1 -1
- package/lib/AWS/S3/DeleteObject.d.ts +1 -1
- package/lib/AWS/S3/DeleteObject.d.ts.map +1 -1
- package/lib/AWS/S3/GetObject.d.ts +1 -1
- package/lib/AWS/S3/GetObject.d.ts.map +1 -1
- package/lib/AWS/S3/HeadObject.d.ts +1 -1
- package/lib/AWS/S3/HeadObject.d.ts.map +1 -1
- package/lib/AWS/S3/ListObjectsV2.d.ts +1 -1
- package/lib/AWS/S3/ListObjectsV2.d.ts.map +1 -1
- package/lib/AWS/S3/PutObject.d.ts +1 -1
- package/lib/AWS/S3/PutObject.d.ts.map +1 -1
- package/lib/AWS/S3/UploadPart.d.ts +1 -1
- package/lib/AWS/S3/UploadPart.d.ts.map +1 -1
- package/lib/AWS/SNS/AddPermission.d.ts +1 -1
- package/lib/AWS/SNS/AddPermission.d.ts.map +1 -1
- package/lib/AWS/SNS/ConfirmSubscription.d.ts +1 -1
- package/lib/AWS/SNS/ConfirmSubscription.d.ts.map +1 -1
- package/lib/AWS/SNS/GetDataProtectionPolicy.d.ts +1 -1
- package/lib/AWS/SNS/GetDataProtectionPolicy.d.ts.map +1 -1
- package/lib/AWS/SNS/GetSubscriptionAttributes.d.ts +1 -1
- package/lib/AWS/SNS/GetSubscriptionAttributes.d.ts.map +1 -1
- package/lib/AWS/SNS/GetTopicAttributes.d.ts +1 -1
- package/lib/AWS/SNS/GetTopicAttributes.d.ts.map +1 -1
- package/lib/AWS/SNS/ListSubscriptions.d.ts +1 -1
- package/lib/AWS/SNS/ListSubscriptions.d.ts.map +1 -1
- package/lib/AWS/SNS/ListSubscriptionsByTopic.d.ts +1 -1
- package/lib/AWS/SNS/ListSubscriptionsByTopic.d.ts.map +1 -1
- package/lib/AWS/SNS/ListTagsForResource.d.ts +1 -1
- package/lib/AWS/SNS/ListTagsForResource.d.ts.map +1 -1
- package/lib/AWS/SNS/ListTopics.d.ts +1 -1
- package/lib/AWS/SNS/ListTopics.d.ts.map +1 -1
- package/lib/AWS/SNS/Publish.d.ts +1 -1
- package/lib/AWS/SNS/Publish.d.ts.map +1 -1
- package/lib/AWS/SNS/PublishBatch.d.ts +1 -1
- package/lib/AWS/SNS/PublishBatch.d.ts.map +1 -1
- package/lib/AWS/SNS/PutDataProtectionPolicy.d.ts +1 -1
- package/lib/AWS/SNS/PutDataProtectionPolicy.d.ts.map +1 -1
- package/lib/AWS/SNS/RemovePermission.d.ts +1 -1
- package/lib/AWS/SNS/RemovePermission.d.ts.map +1 -1
- package/lib/AWS/SNS/SetSubscriptionAttributes.d.ts +1 -1
- package/lib/AWS/SNS/SetSubscriptionAttributes.d.ts.map +1 -1
- package/lib/AWS/SNS/SetTopicAttributes.d.ts +1 -1
- package/lib/AWS/SNS/SetTopicAttributes.d.ts.map +1 -1
- package/lib/AWS/SNS/TagResource.d.ts +1 -1
- package/lib/AWS/SNS/TagResource.d.ts.map +1 -1
- package/lib/AWS/SNS/TopicSink.d.ts +1 -1
- package/lib/AWS/SNS/TopicSink.d.ts.map +1 -1
- package/lib/AWS/SNS/UntagResource.d.ts +1 -1
- package/lib/AWS/SNS/UntagResource.d.ts.map +1 -1
- package/lib/AWS/SQS/DeleteMessage.d.ts +1 -1
- package/lib/AWS/SQS/DeleteMessage.d.ts.map +1 -1
- package/lib/AWS/SQS/DeleteMessageBatch.d.ts +1 -1
- package/lib/AWS/SQS/DeleteMessageBatch.d.ts.map +1 -1
- package/lib/AWS/SQS/QueueSink.d.ts +1 -1
- package/lib/AWS/SQS/QueueSink.d.ts.map +1 -1
- package/lib/AWS/SQS/ReceiveMessage.d.ts +1 -1
- package/lib/AWS/SQS/ReceiveMessage.d.ts.map +1 -1
- package/lib/AWS/SQS/SendMessage.d.ts +1 -1
- package/lib/AWS/SQS/SendMessage.d.ts.map +1 -1
- package/lib/AWS/SQS/SendMessageBatch.d.ts +1 -1
- package/lib/AWS/SQS/SendMessageBatch.d.ts.map +1 -1
- package/lib/AWS/SecretsManager/DescribeSecret.d.ts +1 -1
- package/lib/AWS/SecretsManager/DescribeSecret.d.ts.map +1 -1
- package/lib/AWS/SecretsManager/GetRandomPassword.d.ts +1 -1
- package/lib/AWS/SecretsManager/GetRandomPassword.d.ts.map +1 -1
- package/lib/AWS/SecretsManager/GetSecretValue.d.ts +1 -1
- package/lib/AWS/SecretsManager/GetSecretValue.d.ts.map +1 -1
- package/lib/AWS/SecretsManager/ListSecrets.d.ts +1 -1
- package/lib/AWS/SecretsManager/ListSecrets.d.ts.map +1 -1
- package/lib/AWS/SecretsManager/PutSecretValue.d.ts +1 -1
- package/lib/AWS/SecretsManager/PutSecretValue.d.ts.map +1 -1
- package/lib/Binding.d.ts +1 -1
- package/lib/Binding.d.ts.map +1 -1
- package/lib/Bundle/Docker.d.ts.map +1 -1
- package/lib/Bundle/Docker.js +12 -13
- package/lib/Bundle/Docker.js.map +1 -1
- package/lib/Cli/commands/deploy.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.js +1 -0
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts +8 -7
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.js +2 -6
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.js.map +1 -1
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.d.ts +4 -3
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.d.ts.map +1 -1
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.js +2 -1
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.js.map +1 -1
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.d.ts +8 -7
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.js +2 -2
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.js.map +1 -1
- package/lib/Cloudflare/D1/D1Connection.d.ts +12 -10
- package/lib/Cloudflare/D1/D1Connection.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Connection.js +2 -2
- package/lib/Cloudflare/D1/D1Connection.js.map +1 -1
- package/lib/Cloudflare/D1/D1Database.js +1 -1
- package/lib/Cloudflare/D1/D1Database.js.map +1 -1
- package/lib/Cloudflare/D1/D1Migrations.d.ts +2 -2
- package/lib/Cloudflare/D1/D1Migrations.d.ts.map +1 -1
- package/lib/Cloudflare/Email/SendEmailBinding.d.ts +5 -4
- package/lib/Cloudflare/Email/SendEmailBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Email/SendEmailBinding.js +2 -1
- package/lib/Cloudflare/Email/SendEmailBinding.js.map +1 -1
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts +10 -8
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js +2 -2
- package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js.map +1 -1
- package/lib/Cloudflare/Images/ImagesBinding.d.ts +5 -4
- package/lib/Cloudflare/Images/ImagesBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Images/ImagesBinding.js +4 -2
- package/lib/Cloudflare/Images/ImagesBinding.js.map +1 -1
- package/lib/Cloudflare/KV/KVNamespaceBinding.d.ts +33 -32
- package/lib/Cloudflare/KV/KVNamespaceBinding.d.ts.map +1 -1
- package/lib/Cloudflare/KV/KVNamespaceBinding.js +5 -2
- package/lib/Cloudflare/KV/KVNamespaceBinding.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.d.ts +5 -4
- package/lib/Cloudflare/Queue/QueueBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.js +2 -2
- package/lib/Cloudflare/Queue/QueueBinding.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts +1 -2
- package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2BucketBinding.d.ts +13 -12
- package/lib/Cloudflare/R2/R2BucketBinding.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2BucketBinding.js +2 -2
- package/lib/Cloudflare/R2/R2BucketBinding.js.map +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +5 -4
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.js +2 -2
- package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +1 -1
- package/lib/Cloudflare/Workers/CronEventSource.d.ts +1 -2
- package/lib/Cloudflare/Workers/CronEventSource.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js +6 -3
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/DynamicWorkerLoader.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DynamicWorkerLoader.js +3 -3
- package/lib/Cloudflare/Workers/DynamicWorkerLoader.js.map +1 -1
- package/lib/Cloudflare/Workers/Fetch.d.ts +1 -1
- package/lib/Cloudflare/Workers/Fetch.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/RpcAsync.d.ts +55 -0
- package/lib/Cloudflare/Workers/RpcAsync.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/RpcAsync.js +55 -0
- package/lib/Cloudflare/Workers/RpcAsync.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +3 -3
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +9 -2
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +2 -0
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts +4 -4
- package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +6 -3
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Neon/Branch.js +1 -1
- package/lib/Neon/Branch.js.map +1 -1
- package/lib/Neon/Migrations.d.ts +1 -1
- package/lib/Neon/Migrations.d.ts.map +1 -1
- package/lib/Neon/Project.d.ts.map +1 -1
- package/lib/Neon/Project.js +1 -15
- package/lib/Neon/Project.js.map +1 -1
- package/lib/Phase.d.ts +2 -2
- package/lib/Phase.d.ts.map +1 -1
- package/lib/Phase.js +2 -1
- package/lib/Phase.js.map +1 -1
- package/lib/Planetscale/AuthProvider.d.ts +59 -0
- package/lib/Planetscale/AuthProvider.d.ts.map +1 -0
- package/lib/Planetscale/AuthProvider.js +131 -0
- package/lib/Planetscale/AuthProvider.js.map +1 -0
- package/lib/Planetscale/Branch.d.ts +113 -0
- package/lib/Planetscale/Branch.d.ts.map +1 -0
- package/lib/Planetscale/Branch.js +287 -0
- package/lib/Planetscale/Branch.js.map +1 -0
- package/lib/Planetscale/Credentials.d.ts +35 -0
- package/lib/Planetscale/Credentials.d.ts.map +1 -0
- package/lib/Planetscale/Credentials.js +56 -0
- package/lib/Planetscale/Credentials.js.map +1 -0
- package/lib/Planetscale/Database.d.ts +117 -0
- package/lib/Planetscale/Database.d.ts.map +1 -0
- package/lib/Planetscale/Database.js +1 -0
- package/lib/Planetscale/Database.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLBranch.d.ts +86 -0
- package/lib/Planetscale/MySQL/MySQLBranch.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLBranch.js +14 -0
- package/lib/Planetscale/MySQL/MySQLBranch.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLClusterSize.d.ts +23 -0
- package/lib/Planetscale/MySQL/MySQLClusterSize.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLClusterSize.js +44 -0
- package/lib/Planetscale/MySQL/MySQLClusterSize.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts +119 -0
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLDatabase.js +237 -0
- package/lib/Planetscale/MySQL/MySQLDatabase.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLMigrations.d.ts +18 -0
- package/lib/Planetscale/MySQL/MySQLMigrations.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLMigrations.js +157 -0
- package/lib/Planetscale/MySQL/MySQLMigrations.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLOrigin.d.ts +15 -0
- package/lib/Planetscale/MySQL/MySQLOrigin.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLOrigin.js +2 -0
- package/lib/Planetscale/MySQL/MySQLOrigin.js.map +1 -0
- package/lib/Planetscale/MySQL/MySQLPassword.d.ts +115 -0
- package/lib/Planetscale/MySQL/MySQLPassword.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/MySQLPassword.js +197 -0
- package/lib/Planetscale/MySQL/MySQLPassword.js.map +1 -0
- package/lib/Planetscale/MySQL/index.d.ts +6 -0
- package/lib/Planetscale/MySQL/index.d.ts.map +1 -0
- package/lib/Planetscale/MySQL/index.js +6 -0
- package/lib/Planetscale/MySQL/index.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresBranch.d.ts +67 -0
- package/lib/Planetscale/Postgres/PostgresBranch.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresBranch.js +14 -0
- package/lib/Planetscale/Postgres/PostgresBranch.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresClusterSize.d.ts +44 -0
- package/lib/Planetscale/Postgres/PostgresClusterSize.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresClusterSize.js +72 -0
- package/lib/Planetscale/Postgres/PostgresClusterSize.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresDatabase.d.ts +73 -0
- package/lib/Planetscale/Postgres/PostgresDatabase.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresDatabase.js +241 -0
- package/lib/Planetscale/Postgres/PostgresDatabase.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresDefaultRole.d.ts +85 -0
- package/lib/Planetscale/Postgres/PostgresDefaultRole.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresDefaultRole.js +142 -0
- package/lib/Planetscale/Postgres/PostgresDefaultRole.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresMigrations.d.ts +18 -0
- package/lib/Planetscale/Postgres/PostgresMigrations.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresMigrations.js +148 -0
- package/lib/Planetscale/Postgres/PostgresMigrations.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresOrigin.d.ts +15 -0
- package/lib/Planetscale/Postgres/PostgresOrigin.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresOrigin.js +2 -0
- package/lib/Planetscale/Postgres/PostgresOrigin.js.map +1 -0
- package/lib/Planetscale/Postgres/PostgresRole.d.ts +121 -0
- package/lib/Planetscale/Postgres/PostgresRole.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/PostgresRole.js +228 -0
- package/lib/Planetscale/Postgres/PostgresRole.js.map +1 -0
- package/lib/Planetscale/Postgres/index.d.ts +7 -0
- package/lib/Planetscale/Postgres/index.d.ts.map +1 -0
- package/lib/Planetscale/Postgres/index.js +7 -0
- package/lib/Planetscale/Postgres/index.js.map +1 -0
- package/lib/Planetscale/Providers.d.ts +25 -0
- package/lib/Planetscale/Providers.d.ts.map +1 -0
- package/lib/Planetscale/Providers.js +40 -0
- package/lib/Planetscale/Providers.js.map +1 -0
- package/lib/Planetscale/Util.d.ts +182 -0
- package/lib/Planetscale/Util.d.ts.map +1 -0
- package/lib/Planetscale/Util.js +98 -0
- package/lib/Planetscale/Util.js.map +1 -0
- package/lib/Planetscale/index.d.ts +9 -0
- package/lib/Planetscale/index.d.ts.map +1 -0
- package/lib/Planetscale/index.js +9 -0
- package/lib/Planetscale/index.js.map +1 -0
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +7 -2
- package/lib/Platform.js.map +1 -1
- package/lib/RuntimeContext.d.ts +7 -3
- package/lib/RuntimeContext.d.ts.map +1 -1
- package/lib/RuntimeContext.js +3 -2
- package/lib/RuntimeContext.js.map +1 -1
- package/lib/Server/S3BucketEventSource.d.ts +1 -1
- package/lib/Server/S3BucketEventSource.d.ts.map +1 -1
- package/lib/{Neon → Sql}/SqlFile.d.ts +2 -0
- package/lib/Sql/SqlFile.d.ts.map +1 -0
- package/lib/{Neon → Sql}/SqlFile.js +14 -0
- package/lib/Sql/SqlFile.js.map +1 -0
- package/lib/Sql/index.d.ts +2 -0
- package/lib/Sql/index.d.ts.map +1 -0
- package/lib/Sql/index.js +2 -0
- package/lib/Sql/index.js.map +1 -0
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +20 -6
- package/src/Binding.ts +1 -1
- package/src/Bundle/Docker.ts +12 -15
- package/src/Cli/commands/deploy.ts +1 -0
- package/src/Cloudflare/AiGateway/AiGatewayBinding.ts +11 -16
- package/src/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.ts +7 -9
- package/src/Cloudflare/Artifacts/ArtifactsBinding.ts +11 -22
- package/src/Cloudflare/D1/D1Connection.ts +31 -18
- package/src/Cloudflare/D1/D1Database.ts +1 -1
- package/src/Cloudflare/D1/D1Migrations.ts +2 -2
- package/src/Cloudflare/Email/SendEmailBinding.ts +7 -5
- package/src/Cloudflare/Hyperdrive/HyperdriveBinding.ts +16 -12
- package/src/Cloudflare/Images/ImagesBinding.ts +8 -8
- package/src/Cloudflare/KV/KVNamespaceBinding.ts +38 -38
- package/src/Cloudflare/Queue/QueueBinding.ts +7 -6
- package/src/Cloudflare/R2/R2BucketBinding.ts +16 -19
- package/src/Cloudflare/SecretsStore/SecretBinding.ts +11 -13
- package/src/Cloudflare/Workers/DurableObjectNamespace.ts +6 -6
- package/src/Cloudflare/Workers/DynamicWorkerLoader.ts +4 -5
- package/src/Cloudflare/Workers/RpcAsync.ts +55 -0
- package/src/Cloudflare/Workers/Worker.ts +17 -5
- package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +2 -0
- package/src/Cloudflare/Workers/Workflow.ts +10 -11
- package/src/Neon/Branch.ts +1 -1
- package/src/Neon/Migrations.ts +1 -1
- package/src/Neon/Project.ts +6 -20
- package/src/Phase.ts +2 -0
- package/src/Planetscale/AuthProvider.ts +285 -0
- package/src/Planetscale/Branch.ts +508 -0
- package/src/Planetscale/Credentials.ts +96 -0
- package/src/Planetscale/Database.ts +129 -0
- package/src/Planetscale/MySQL/MySQLBranch.ts +112 -0
- package/src/Planetscale/MySQL/MySQLClusterSize.ts +102 -0
- package/src/Planetscale/MySQL/MySQLDatabase.ts +446 -0
- package/src/Planetscale/MySQL/MySQLMigrations.ts +271 -0
- package/src/Planetscale/MySQL/MySQLOrigin.ts +15 -0
- package/src/Planetscale/MySQL/MySQLPassword.ts +387 -0
- package/src/Planetscale/MySQL/index.ts +5 -0
- package/src/Planetscale/Postgres/PostgresBranch.ts +97 -0
- package/src/Planetscale/Postgres/PostgresClusterSize.ts +125 -0
- package/src/Planetscale/Postgres/PostgresDatabase.ts +404 -0
- package/src/Planetscale/Postgres/PostgresDefaultRole.ts +270 -0
- package/src/Planetscale/Postgres/PostgresMigrations.ts +256 -0
- package/src/Planetscale/Postgres/PostgresOrigin.ts +15 -0
- package/src/Planetscale/Postgres/PostgresRole.ts +469 -0
- package/src/Planetscale/Postgres/index.ts +6 -0
- package/src/Planetscale/Providers.ts +80 -0
- package/src/Planetscale/Util.ts +160 -0
- package/src/Planetscale/index.ts +18 -0
- package/src/Platform.ts +13 -1
- package/src/RuntimeContext.ts +7 -8
- package/src/{Neon → Sql}/SqlFile.ts +22 -0
- package/src/Sql/index.ts +1 -0
- package/lib/Cloudflare/D1/D1SqlFile.d.ts +0 -20
- package/lib/Cloudflare/D1/D1SqlFile.d.ts.map +0 -1
- package/lib/Cloudflare/D1/D1SqlFile.js +0 -46
- package/lib/Cloudflare/D1/D1SqlFile.js.map +0 -1
- package/lib/Neon/SqlFile.d.ts.map +0 -1
- package/lib/Neon/SqlFile.js.map +0 -1
- package/src/Cloudflare/D1/D1SqlFile.ts +0 -55
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import * as ops from "@distilled.cloud/planetscale/Operations";
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
import * as Schedule from "effect/Schedule";
|
|
6
|
+
import { createConnection, type Connection } from "mysql2/promise";
|
|
7
|
+
import { listSqlFiles, readSqlFile, type SqlFile } from "../../Sql/SqlFile.ts";
|
|
8
|
+
|
|
9
|
+
const MIGRATION_PASSWORD_TTL_SECONDS = 600;
|
|
10
|
+
|
|
11
|
+
export class MySQLMigrationError extends Data.TaggedError(
|
|
12
|
+
"Planetscale::MySQLMigrationError",
|
|
13
|
+
)<{
|
|
14
|
+
message: string;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
}> {}
|
|
17
|
+
|
|
18
|
+
export interface MySQLMigrationTarget {
|
|
19
|
+
organization: string;
|
|
20
|
+
database: string;
|
|
21
|
+
branch: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const runMySQLMigrations = (
|
|
25
|
+
target: MySQLMigrationTarget,
|
|
26
|
+
migrationsDir: string,
|
|
27
|
+
migrationsTable: string,
|
|
28
|
+
) =>
|
|
29
|
+
Effect.gen(function* () {
|
|
30
|
+
const files = yield* listSqlFiles(migrationsDir);
|
|
31
|
+
if (files.length > 0) {
|
|
32
|
+
yield* applyMySQLMigrations({
|
|
33
|
+
target,
|
|
34
|
+
migrationsTable,
|
|
35
|
+
migrationsFiles: files,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const hashes: Record<string, string> = {};
|
|
39
|
+
for (const file of files) hashes[file.id] = file.hash;
|
|
40
|
+
return hashes;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const runMySQLImports = (
|
|
44
|
+
target: MySQLMigrationTarget,
|
|
45
|
+
importFiles: ReadonlyArray<string>,
|
|
46
|
+
rootDir: string,
|
|
47
|
+
previous: Record<string, string>,
|
|
48
|
+
) =>
|
|
49
|
+
Effect.gen(function* () {
|
|
50
|
+
const hashes: Record<string, string> = { ...previous };
|
|
51
|
+
for (const filePath of importFiles) {
|
|
52
|
+
const file = yield* readSqlFile(rootDir, filePath);
|
|
53
|
+
if (previous[filePath] === file.hash) {
|
|
54
|
+
hashes[filePath] = file.hash;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
yield* runMySQLSql(target, file.sql);
|
|
58
|
+
hashes[filePath] = file.hash;
|
|
59
|
+
}
|
|
60
|
+
const tracked = new Set(importFiles);
|
|
61
|
+
for (const key of Object.keys(hashes)) {
|
|
62
|
+
if (!tracked.has(key)) delete hashes[key];
|
|
63
|
+
}
|
|
64
|
+
return hashes;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
interface ApplyMigrationsOptions {
|
|
68
|
+
target: MySQLMigrationTarget;
|
|
69
|
+
migrationsTable: string;
|
|
70
|
+
migrationsFiles: ReadonlyArray<SqlFile>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const applyMySQLMigrations = (options: ApplyMigrationsOptions) =>
|
|
74
|
+
withMySQLConnection(options.target, (connection) =>
|
|
75
|
+
Effect.gen(function* () {
|
|
76
|
+
const table = quoteMySQLIdentifier(options.migrationsTable);
|
|
77
|
+
yield* mysqlQuery(
|
|
78
|
+
connection,
|
|
79
|
+
`CREATE TABLE IF NOT EXISTS ${table} (
|
|
80
|
+
id varchar(255) NOT NULL PRIMARY KEY,
|
|
81
|
+
name varchar(1024) NOT NULL,
|
|
82
|
+
applied_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
83
|
+
);`,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const applied = yield* mysqlQueryRows<{ name: string }>(
|
|
87
|
+
connection,
|
|
88
|
+
`SELECT name FROM ${table};`,
|
|
89
|
+
).pipe(Effect.map((rows) => new Set(rows.map((row) => row.name))));
|
|
90
|
+
let nextSeq = yield* getNextMySQLSeq(connection, table);
|
|
91
|
+
|
|
92
|
+
for (const file of options.migrationsFiles) {
|
|
93
|
+
if (applied.has(file.id)) continue;
|
|
94
|
+
const migrationId = nextSeq.toString().padStart(5, "0");
|
|
95
|
+
nextSeq += 1;
|
|
96
|
+
yield* Effect.gen(function* () {
|
|
97
|
+
yield* mysqlQuery(connection, "START TRANSACTION");
|
|
98
|
+
for (const statement of splitMySQLStatements(file.sql)) {
|
|
99
|
+
yield* mysqlQuery(connection, statement);
|
|
100
|
+
}
|
|
101
|
+
yield* mysqlExecute(
|
|
102
|
+
connection,
|
|
103
|
+
`INSERT INTO ${table} (id, name) VALUES (?, ?);`,
|
|
104
|
+
[migrationId, file.id],
|
|
105
|
+
);
|
|
106
|
+
yield* mysqlQuery(connection, "COMMIT");
|
|
107
|
+
}).pipe(
|
|
108
|
+
Effect.catch((error) =>
|
|
109
|
+
mysqlQuery(connection, "ROLLBACK").pipe(
|
|
110
|
+
Effect.catch(() => Effect.void),
|
|
111
|
+
Effect.andThen(Effect.fail(error)),
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const runMySQLSql = (target: MySQLMigrationTarget, sql: string) =>
|
|
120
|
+
withMySQLConnection(target, (connection) =>
|
|
121
|
+
Effect.gen(function* () {
|
|
122
|
+
for (const statement of splitMySQLStatements(sql)) {
|
|
123
|
+
yield* mysqlQuery(connection, statement);
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Drizzle (and other migration tools) emit `--> statement-breakpoint` as a
|
|
129
|
+
// separator between statements. PlanetScale's Vitess parser rejects the `-->`
|
|
130
|
+
// token ("syntax error at position 2") because MySQL line comments require
|
|
131
|
+
// whitespace after `--`. Split on the marker and run each statement
|
|
132
|
+
// individually so the connector never sees the breakpoint comment.
|
|
133
|
+
const STATEMENT_BREAKPOINT = /\r?\n\s*-->\s*statement-breakpoint\s*\r?\n?/g;
|
|
134
|
+
|
|
135
|
+
const splitMySQLStatements = (sql: string): string[] =>
|
|
136
|
+
sql
|
|
137
|
+
.split(STATEMENT_BREAKPOINT)
|
|
138
|
+
.map((s) => s.trim())
|
|
139
|
+
.filter((s) => s.length > 0);
|
|
140
|
+
|
|
141
|
+
const getNextMySQLSeq = (connection: Connection, table: string) =>
|
|
142
|
+
mysqlQueryRows<{ id: string }>(connection, `SELECT id FROM ${table};`).pipe(
|
|
143
|
+
Effect.map((rows) => {
|
|
144
|
+
let max = 0;
|
|
145
|
+
for (const { id } of rows) {
|
|
146
|
+
if (/^\d+$/.test(String(id))) {
|
|
147
|
+
max = Math.max(max, Number.parseInt(String(id), 10));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return max + 1;
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const withMySQLConnection = <A, E, R>(
|
|
155
|
+
target: MySQLMigrationTarget,
|
|
156
|
+
use: (connection: Connection) => Effect.Effect<A, E, R>,
|
|
157
|
+
) =>
|
|
158
|
+
withTemporaryMySQLPassword(target, (password) =>
|
|
159
|
+
Effect.acquireUseRelease(
|
|
160
|
+
Effect.tryPromise({
|
|
161
|
+
try: () =>
|
|
162
|
+
createConnection({
|
|
163
|
+
host: password.host,
|
|
164
|
+
user: password.username,
|
|
165
|
+
password: Redacted.value(password.password),
|
|
166
|
+
database: target.database,
|
|
167
|
+
multipleStatements: true,
|
|
168
|
+
ssl: { rejectUnauthorized: true },
|
|
169
|
+
}),
|
|
170
|
+
catch: toMigrationError,
|
|
171
|
+
}),
|
|
172
|
+
use,
|
|
173
|
+
(connection) =>
|
|
174
|
+
Effect.tryPromise({
|
|
175
|
+
try: () => connection.end(),
|
|
176
|
+
catch: toMigrationError,
|
|
177
|
+
}).pipe(Effect.catch(() => Effect.void)),
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const withTemporaryMySQLPassword = <A, E, R>(
|
|
182
|
+
target: MySQLMigrationTarget,
|
|
183
|
+
use: (password: {
|
|
184
|
+
id: string;
|
|
185
|
+
host: string;
|
|
186
|
+
username: string;
|
|
187
|
+
password: Redacted.Redacted<string>;
|
|
188
|
+
}) => Effect.Effect<A, E, R>,
|
|
189
|
+
) =>
|
|
190
|
+
Effect.acquireUseRelease(
|
|
191
|
+
Effect.gen(function* () {
|
|
192
|
+
const created = yield* ops.createPassword({
|
|
193
|
+
organization: target.organization,
|
|
194
|
+
database: target.database,
|
|
195
|
+
branch: target.branch,
|
|
196
|
+
role: "admin",
|
|
197
|
+
ttl: MIGRATION_PASSWORD_TTL_SECONDS,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
id: created.id,
|
|
202
|
+
host: created.access_host_url,
|
|
203
|
+
username: created.username,
|
|
204
|
+
password: created.plain_text,
|
|
205
|
+
};
|
|
206
|
+
}),
|
|
207
|
+
use,
|
|
208
|
+
(password) =>
|
|
209
|
+
ops
|
|
210
|
+
.deletePassword({
|
|
211
|
+
organization: target.organization,
|
|
212
|
+
database: target.database,
|
|
213
|
+
branch: target.branch,
|
|
214
|
+
id: password.id,
|
|
215
|
+
})
|
|
216
|
+
.pipe(
|
|
217
|
+
// Already-deleted passwords are a success: nothing to clean up.
|
|
218
|
+
Effect.catchTag("NotFound", () => Effect.void),
|
|
219
|
+
Effect.retry({
|
|
220
|
+
schedule: Schedule.exponential("500 millis").pipe(
|
|
221
|
+
Schedule.both(Schedule.recurs(5)),
|
|
222
|
+
),
|
|
223
|
+
}),
|
|
224
|
+
// Migrations succeeded; don't fail the parent over a release-step
|
|
225
|
+
// hiccup. The password's TTL bounds the orphan window; log loudly
|
|
226
|
+
// so an operator can clean it up manually if needed.
|
|
227
|
+
Effect.catch((cause: unknown) =>
|
|
228
|
+
Effect.logWarning(
|
|
229
|
+
`Failed to delete temporary Planetscale migration password after retries. ` +
|
|
230
|
+
`It will expire via TTL (~${MIGRATION_PASSWORD_TTL_SECONDS}s). ` +
|
|
231
|
+
`organization=${target.organization} database=${target.database} ` +
|
|
232
|
+
`branch=${target.branch} id=${password.id}`,
|
|
233
|
+
cause,
|
|
234
|
+
),
|
|
235
|
+
),
|
|
236
|
+
),
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const mysqlQuery = (connection: Connection, sql: string) =>
|
|
240
|
+
Effect.tryPromise({
|
|
241
|
+
try: () => connection.query(sql).then(() => undefined),
|
|
242
|
+
catch: toMigrationError,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const mysqlExecute = (
|
|
246
|
+
connection: Connection,
|
|
247
|
+
sql: string,
|
|
248
|
+
values?: ReadonlyArray<string>,
|
|
249
|
+
) =>
|
|
250
|
+
Effect.tryPromise({
|
|
251
|
+
try: () =>
|
|
252
|
+
connection
|
|
253
|
+
.execute(sql, values ? [...values] : undefined)
|
|
254
|
+
.then(() => undefined),
|
|
255
|
+
catch: toMigrationError,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const mysqlQueryRows = <A>(connection: Connection, sql: string) =>
|
|
259
|
+
Effect.tryPromise({
|
|
260
|
+
try: () => connection.query(sql).then(([rows]) => rows as A[]),
|
|
261
|
+
catch: toMigrationError,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const toMigrationError = (cause: unknown) =>
|
|
265
|
+
new MySQLMigrationError({
|
|
266
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
267
|
+
cause,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const quoteMySQLIdentifier = (identifier: string) =>
|
|
271
|
+
`\`${identifier.replaceAll("`", "``")}\``;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Redacted from "effect/Redacted";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shape `Cloudflare.Hyperdrive` and other MySQL consumers accept as an
|
|
5
|
+
* origin. Materialized on `Planetscale.MySQLPassword` so callers can wire
|
|
6
|
+
* password credentials into Hyperdrive directly.
|
|
7
|
+
*/
|
|
8
|
+
export type MySQLOrigin = {
|
|
9
|
+
scheme: "mysql";
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
database: string;
|
|
13
|
+
user: string;
|
|
14
|
+
password: Redacted.Redacted<string>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { Credentials } from "@distilled.cloud/planetscale/Credentials";
|
|
2
|
+
import * as ops from "@distilled.cloud/planetscale/Operations";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
import { deepEqual, isResolved } from "../../Diff.ts";
|
|
6
|
+
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
7
|
+
import * as Provider from "../../Provider.ts";
|
|
8
|
+
import { Resource } from "../../Resource.ts";
|
|
9
|
+
import type { Providers } from "../Providers.ts";
|
|
10
|
+
import type { MySQLBranch } from "./MySQLBranch.ts";
|
|
11
|
+
import type { MySQLDatabase } from "./MySQLDatabase.ts";
|
|
12
|
+
import type { MySQLOrigin } from "./MySQLOrigin.ts";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Properties for creating or updating a PlanetScale MySQL password.
|
|
16
|
+
*
|
|
17
|
+
* Passwords are only meant for MySQL databases. For PostgreSQL,
|
|
18
|
+
* use {@link PostgresRole} instead.
|
|
19
|
+
*/
|
|
20
|
+
export interface MySQLPasswordProps {
|
|
21
|
+
/**
|
|
22
|
+
* Password name. If omitted, a unique name is generated from
|
|
23
|
+
* `${app}-${stage}-${id}`.
|
|
24
|
+
*/
|
|
25
|
+
name?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* MySQL database — string name or {@link MySQLDatabase} resource.
|
|
29
|
+
*/
|
|
30
|
+
database: string | MySQLDatabase;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Branch — string name or {@link MySQLBranch} resource.
|
|
34
|
+
* @default "main"
|
|
35
|
+
*/
|
|
36
|
+
branch?: string | MySQLBranch;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The MySQL role granted to the password.
|
|
40
|
+
*/
|
|
41
|
+
role: "reader" | "writer" | "admin" | "readwriter";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether the password is for a read replica.
|
|
45
|
+
*/
|
|
46
|
+
replica?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Time to live (seconds). The password is invalidated after this period.
|
|
50
|
+
*/
|
|
51
|
+
ttl?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* IP CIDR ranges allowed to use this password.
|
|
55
|
+
*/
|
|
56
|
+
cidrs?: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Output attributes of a deployed PlanetScale password.
|
|
61
|
+
*/
|
|
62
|
+
export interface MySQLPasswordAttributes {
|
|
63
|
+
/** Unique identifier for the password (stable). */
|
|
64
|
+
id: string;
|
|
65
|
+
/** Password name. If omitted, a unique name is generated from `${app}-${stage}-${id}`. */
|
|
66
|
+
name: string;
|
|
67
|
+
/** ISO 8601 timestamp at which the password expires. `null` if no TTL. */
|
|
68
|
+
expiresAt: string | null;
|
|
69
|
+
/** Hostname for the database connection. */
|
|
70
|
+
host: string;
|
|
71
|
+
/** Username for database authentication. */
|
|
72
|
+
username: string;
|
|
73
|
+
/** Password for database authentication (Redacted). */
|
|
74
|
+
password: Redacted.Redacted<string>;
|
|
75
|
+
/** Parsed connection components ready to feed into Cloudflare Hyperdrive. */
|
|
76
|
+
origin: MySQLOrigin;
|
|
77
|
+
/** Resolved organization slug. */
|
|
78
|
+
organization: string;
|
|
79
|
+
/** Resolved database name. */
|
|
80
|
+
database: string;
|
|
81
|
+
/** Resolved branch name. */
|
|
82
|
+
branch: string;
|
|
83
|
+
/** The role granted. */
|
|
84
|
+
role: "reader" | "writer" | "admin" | "readwriter";
|
|
85
|
+
/** Whether this password is for a read replica. */
|
|
86
|
+
replica: boolean | undefined;
|
|
87
|
+
/** TTL in seconds (if set). */
|
|
88
|
+
ttl: number | undefined;
|
|
89
|
+
/** IP CIDR ranges allowed to use this password. */
|
|
90
|
+
cidrs: readonly string[] | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A PlanetScale password for accessing a MySQL database branch.
|
|
95
|
+
*
|
|
96
|
+
* For PostgreSQL databases, use {@link PostgresRole} instead.
|
|
97
|
+
*
|
|
98
|
+
* @section Creating a Password
|
|
99
|
+
* @example Reader password
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const reader = yield* Planetscale.MySQLPassword("AppReader", {
|
|
102
|
+
* database: "my-db",
|
|
103
|
+
* role: "reader",
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @example Writer password with TTL
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const writer = yield* Planetscale.MySQLPassword("AppWriter", {
|
|
110
|
+
* database: "my-db",
|
|
111
|
+
* role: "writer",
|
|
112
|
+
* ttl: 86400,
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @example Admin password with IP allowlist
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const admin = yield* Planetscale.MySQLPassword("Admin", {
|
|
119
|
+
* database: "my-db",
|
|
120
|
+
* role: "admin",
|
|
121
|
+
* cidrs: ["203.0.113.0/24", "198.51.100.0/24"],
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export type MySQLPassword = Resource<
|
|
126
|
+
"Planetscale.MySQLPassword",
|
|
127
|
+
MySQLPasswordProps,
|
|
128
|
+
MySQLPasswordAttributes,
|
|
129
|
+
never,
|
|
130
|
+
Providers
|
|
131
|
+
>;
|
|
132
|
+
|
|
133
|
+
export const MySQLPassword = Resource<MySQLPassword>(
|
|
134
|
+
"Planetscale.MySQLPassword",
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// At runtime, Resource references in props are resolved to their full
|
|
138
|
+
// attributes — so `news.database` (when a Database resource was passed)
|
|
139
|
+
// is `{ name: string; organization: string; ... }` rather than the
|
|
140
|
+
// statically-typed Resource (whose attributes are `Output<...>`). We
|
|
141
|
+
// cast through structural shapes here.
|
|
142
|
+
type DatabaseRef = string | { name: string; organization?: string };
|
|
143
|
+
type BranchRef = string | { name: string };
|
|
144
|
+
|
|
145
|
+
const resolveDatabaseName = (database: string | MySQLDatabase): string => {
|
|
146
|
+
const ref = database as unknown as DatabaseRef;
|
|
147
|
+
return typeof ref === "string" ? ref : ref.name;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const resolveDatabaseOrg = (
|
|
151
|
+
database: string | MySQLDatabase,
|
|
152
|
+
): string | undefined => {
|
|
153
|
+
const ref = database as unknown as DatabaseRef;
|
|
154
|
+
return typeof ref === "string" ? undefined : ref.organization;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const resolveBranchName = (
|
|
158
|
+
branch: string | MySQLBranch | undefined,
|
|
159
|
+
): string => {
|
|
160
|
+
const ref = branch as unknown as BranchRef | undefined;
|
|
161
|
+
return !ref ? "main" : typeof ref === "string" ? ref : ref.name;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const createPasswordName = (id: string, name: string | undefined) =>
|
|
165
|
+
Effect.gen(function* () {
|
|
166
|
+
return (
|
|
167
|
+
name ??
|
|
168
|
+
(yield* createPhysicalName({ id, lowercase: true, maxLength: 63 }))
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Normalize the API's nullable `cidrs` field into the `string[] | undefined`
|
|
173
|
+
// shape we persist so downstream comparisons line up regardless of the
|
|
174
|
+
// API returning `null` vs `[]` vs an actual list.
|
|
175
|
+
const normalizeCidrs = (
|
|
176
|
+
cidrs: readonly string[] | null | undefined,
|
|
177
|
+
): readonly string[] | undefined =>
|
|
178
|
+
cidrs == null || cidrs.length === 0 ? undefined : cidrs;
|
|
179
|
+
|
|
180
|
+
const buildAttributes = (
|
|
181
|
+
password: {
|
|
182
|
+
id: string;
|
|
183
|
+
name: string;
|
|
184
|
+
expires_at: string | null;
|
|
185
|
+
access_host_url: string;
|
|
186
|
+
username: string;
|
|
187
|
+
role: "reader" | "writer" | "admin" | "readwriter";
|
|
188
|
+
replica: boolean;
|
|
189
|
+
ttl_seconds: number | null;
|
|
190
|
+
cidrs: readonly string[] | null;
|
|
191
|
+
},
|
|
192
|
+
plaintext: Redacted.Redacted<string>,
|
|
193
|
+
context: {
|
|
194
|
+
organization: string;
|
|
195
|
+
database: string;
|
|
196
|
+
branch: string;
|
|
197
|
+
},
|
|
198
|
+
): MySQLPasswordAttributes => ({
|
|
199
|
+
id: password.id,
|
|
200
|
+
name: password.name,
|
|
201
|
+
expiresAt: password.expires_at,
|
|
202
|
+
host: password.access_host_url,
|
|
203
|
+
username: password.username,
|
|
204
|
+
password: plaintext,
|
|
205
|
+
origin: {
|
|
206
|
+
scheme: "mysql",
|
|
207
|
+
host: password.access_host_url,
|
|
208
|
+
port: 3306,
|
|
209
|
+
database: context.database,
|
|
210
|
+
user: password.username,
|
|
211
|
+
password: plaintext,
|
|
212
|
+
},
|
|
213
|
+
organization: context.organization,
|
|
214
|
+
database: context.database,
|
|
215
|
+
branch: context.branch,
|
|
216
|
+
role: password.role,
|
|
217
|
+
replica: password.replica,
|
|
218
|
+
ttl: password.ttl_seconds ?? undefined,
|
|
219
|
+
cidrs: normalizeCidrs(password.cidrs),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
export const MySQLPasswordProvider = () =>
|
|
223
|
+
Provider.effect(
|
|
224
|
+
MySQLPassword,
|
|
225
|
+
Effect.gen(function* () {
|
|
226
|
+
const createPwd = yield* ops.createPassword;
|
|
227
|
+
const getPwd = yield* ops.getPassword;
|
|
228
|
+
const updatePwd = yield* ops.updatePassword;
|
|
229
|
+
const deletePwd = yield* ops.deletePassword;
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
stables: ["id"],
|
|
233
|
+
|
|
234
|
+
diff: Effect.fn(function* ({ olds = {}, news }) {
|
|
235
|
+
if (!isResolved(news)) return undefined;
|
|
236
|
+
|
|
237
|
+
// Replace on any immutable-in-place change; engine falls through
|
|
238
|
+
// to reconcile for everything else (which authoritatively diffs
|
|
239
|
+
// against observed cloud state).
|
|
240
|
+
if (news.role !== olds.role) return { action: "replace" } as const;
|
|
241
|
+
if (news.replica !== olds.replica) {
|
|
242
|
+
return { action: "replace" } as const;
|
|
243
|
+
}
|
|
244
|
+
if (news.ttl !== olds.ttl) return { action: "replace" } as const;
|
|
245
|
+
|
|
246
|
+
const newDb = resolveDatabaseName(news.database);
|
|
247
|
+
const oldDb = olds.database
|
|
248
|
+
? resolveDatabaseName(olds.database)
|
|
249
|
+
: undefined;
|
|
250
|
+
if (oldDb && newDb !== oldDb) {
|
|
251
|
+
return { action: "replace" } as const;
|
|
252
|
+
}
|
|
253
|
+
const newBranch = resolveBranchName(news.branch);
|
|
254
|
+
const oldBranch = resolveBranchName(olds.branch);
|
|
255
|
+
if (newBranch !== oldBranch) {
|
|
256
|
+
return { action: "replace" } as const;
|
|
257
|
+
}
|
|
258
|
+
return undefined;
|
|
259
|
+
}),
|
|
260
|
+
|
|
261
|
+
read: Effect.fn(function* ({ output }) {
|
|
262
|
+
// Adoption (no cached output) is impossible: the PlanetScale API
|
|
263
|
+
// never re-issues plaintext, so even if we found a matching live
|
|
264
|
+
// password by listing+name we couldn't deliver the `password`
|
|
265
|
+
// attribute. Fall through to greenfield create in `reconcile`.
|
|
266
|
+
if (!output) return undefined;
|
|
267
|
+
|
|
268
|
+
// Refresh — verify the cached password still exists and
|
|
269
|
+
// re-emit the persisted output (with plaintext intact).
|
|
270
|
+
// If it's gone, return undefined so the engine routes to
|
|
271
|
+
// reconcile, which will surface the unrecoverable-rotation
|
|
272
|
+
// condition explicitly.
|
|
273
|
+
return yield* getPwd({
|
|
274
|
+
organization: output.organization,
|
|
275
|
+
database: output.database,
|
|
276
|
+
branch: output.branch,
|
|
277
|
+
id: output.id,
|
|
278
|
+
}).pipe(
|
|
279
|
+
Effect.map((password) =>
|
|
280
|
+
buildAttributes(password, output.password, {
|
|
281
|
+
organization: output.organization,
|
|
282
|
+
database: output.database,
|
|
283
|
+
branch: output.branch,
|
|
284
|
+
}),
|
|
285
|
+
),
|
|
286
|
+
Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
|
|
287
|
+
);
|
|
288
|
+
}),
|
|
289
|
+
|
|
290
|
+
reconcile: Effect.fn(function* ({ id, news, output }) {
|
|
291
|
+
const newName = yield* createPasswordName(id, news.name);
|
|
292
|
+
|
|
293
|
+
// Identifiers — stable across update (diff replaces on
|
|
294
|
+
// database/branch changes), so we can pull from `output` first
|
|
295
|
+
// and fall back to `news` for greenfield.
|
|
296
|
+
const { organization: envOrg } = yield* Credentials;
|
|
297
|
+
const organization =
|
|
298
|
+
output?.organization ?? resolveDatabaseOrg(news.database) ?? envOrg;
|
|
299
|
+
const databaseName =
|
|
300
|
+
output?.database ?? resolveDatabaseName(news.database);
|
|
301
|
+
const branchName = output?.branch ?? resolveBranchName(news.branch);
|
|
302
|
+
|
|
303
|
+
// 1. Observe — read live state. The PlanetScale API has no
|
|
304
|
+
// "lookup by name" path (names aren't unique within a branch)
|
|
305
|
+
// so the only way to find the live password is by id. Without
|
|
306
|
+
// a cached output we cannot observe and fall straight through
|
|
307
|
+
// to ensure (greenfield create).
|
|
308
|
+
const observed = output
|
|
309
|
+
? yield* getPwd({
|
|
310
|
+
organization,
|
|
311
|
+
database: databaseName,
|
|
312
|
+
branch: branchName,
|
|
313
|
+
id: output.id,
|
|
314
|
+
}).pipe(
|
|
315
|
+
Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
|
|
316
|
+
)
|
|
317
|
+
: undefined;
|
|
318
|
+
|
|
319
|
+
// 2. Ensure — create the password if it doesn't exist live.
|
|
320
|
+
// This single branch covers greenfield (no output) AND the
|
|
321
|
+
// out-of-band-deletion case (output cached but cloud lost it).
|
|
322
|
+
// The latter is structurally a rotation: the new password
|
|
323
|
+
// has a fresh id/host/username/plaintext that propagate
|
|
324
|
+
// downstream through the dependency graph. There is no path
|
|
325
|
+
// to recover the original plaintext, so recreating is the
|
|
326
|
+
// only way to converge.
|
|
327
|
+
let live: ops.GetPasswordOutput;
|
|
328
|
+
let plaintext: Redacted.Redacted<string>;
|
|
329
|
+
if (observed) {
|
|
330
|
+
live = observed;
|
|
331
|
+
// We re-use the cached plaintext: the API never re-issues it.
|
|
332
|
+
plaintext = output!.password;
|
|
333
|
+
} else {
|
|
334
|
+
const created = yield* createPwd({
|
|
335
|
+
organization,
|
|
336
|
+
database: databaseName,
|
|
337
|
+
branch: branchName,
|
|
338
|
+
name: newName,
|
|
339
|
+
role: news.role,
|
|
340
|
+
replica: news.replica,
|
|
341
|
+
ttl: news.ttl,
|
|
342
|
+
cidrs: news.cidrs,
|
|
343
|
+
});
|
|
344
|
+
plaintext = created.plain_text;
|
|
345
|
+
live = created;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// 3. Sync — diff observed cloud state against desired and patch
|
|
349
|
+
// only what changed. Only `name` and `cidrs` are mutable in
|
|
350
|
+
// place; everything else triggers a replace via diff().
|
|
351
|
+
// Skip the API entirely when there's no delta.
|
|
352
|
+
const wantsRename = newName !== live.name;
|
|
353
|
+
const observedCidrs = normalizeCidrs(live.cidrs);
|
|
354
|
+
const desiredCidrs = normalizeCidrs(news.cidrs);
|
|
355
|
+
const wantsCidrs = !deepEqual(desiredCidrs, observedCidrs);
|
|
356
|
+
|
|
357
|
+
if (wantsRename || wantsCidrs) {
|
|
358
|
+
live = yield* updatePwd({
|
|
359
|
+
organization,
|
|
360
|
+
database: databaseName,
|
|
361
|
+
branch: branchName,
|
|
362
|
+
id: live.id,
|
|
363
|
+
name: wantsRename ? newName : undefined,
|
|
364
|
+
cidrs: wantsCidrs ? news.cidrs : undefined,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 4. Return — fresh attrs sourced from observed cloud state,
|
|
369
|
+
// re-using cached plaintext when we didn't just create.
|
|
370
|
+
return buildAttributes(live, plaintext, {
|
|
371
|
+
organization,
|
|
372
|
+
database: databaseName,
|
|
373
|
+
branch: branchName,
|
|
374
|
+
});
|
|
375
|
+
}),
|
|
376
|
+
|
|
377
|
+
delete: Effect.fn(function* ({ output }) {
|
|
378
|
+
yield* deletePwd({
|
|
379
|
+
organization: output.organization,
|
|
380
|
+
database: output.database,
|
|
381
|
+
branch: output.branch,
|
|
382
|
+
id: output.id,
|
|
383
|
+
}).pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
384
|
+
}),
|
|
385
|
+
};
|
|
386
|
+
}),
|
|
387
|
+
);
|