alchemy 2.0.0-beta.1 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/bin/alchemy-effect.js +31 -16
  2. package/bin/alchemy-effect.js.map +1 -1
  3. package/bin/alchemy-effect.sh +2 -3
  4. package/bin/alchemy-effect.ts +3 -3
  5. package/lib/cli/index.d.ts +39 -36
  6. package/lib/cli/index.d.ts.map +1 -1
  7. package/package.json +18 -9
  8. package/src/AWS/ACM/Certificate.ts +49 -46
  9. package/src/AWS/AutoScaling/AutoScalingGroup.ts +4 -1
  10. package/src/AWS/AutoScaling/LaunchTemplate.ts +3 -1
  11. package/src/AWS/AutoScaling/ScalingPolicy.ts +4 -1
  12. package/src/AWS/CloudFront/Distribution.ts +4 -1
  13. package/src/AWS/CloudFront/Function.ts +4 -1
  14. package/src/AWS/CloudFront/Invalidation.ts +4 -1
  15. package/src/AWS/CloudFront/KeyValueStore.ts +4 -1
  16. package/src/AWS/CloudFront/KvEntries.ts +4 -1
  17. package/src/AWS/CloudFront/KvRoutesUpdate.ts +4 -1
  18. package/src/AWS/CloudFront/OriginAccessControl.ts +4 -1
  19. package/src/AWS/CloudWatch/Alarm.ts +4 -1
  20. package/src/AWS/CloudWatch/AlarmMuteRule.ts +4 -1
  21. package/src/AWS/CloudWatch/AnomalyDetector.ts +4 -1
  22. package/src/AWS/CloudWatch/CompositeAlarm.ts +4 -1
  23. package/src/AWS/CloudWatch/Dashboard.ts +4 -1
  24. package/src/AWS/CloudWatch/InsightRule.ts +4 -1
  25. package/src/AWS/CloudWatch/MetricStream.ts +4 -1
  26. package/src/AWS/DynamoDB/Table.ts +3 -1
  27. package/src/AWS/EC2/EIP.ts +4 -1
  28. package/src/AWS/EC2/EgressOnlyInternetGateway.ts +4 -1
  29. package/src/AWS/EC2/Instance.ts +3 -1
  30. package/src/AWS/EC2/InternetGateway.ts +4 -1
  31. package/src/AWS/EC2/NatGateway.ts +4 -1
  32. package/src/AWS/EC2/NetworkAcl.ts +4 -1
  33. package/src/AWS/EC2/NetworkAclAssociation.ts +4 -1
  34. package/src/AWS/EC2/NetworkAclEntry.ts +4 -1
  35. package/src/AWS/EC2/Route.ts +4 -1
  36. package/src/AWS/EC2/RouteTable.ts +4 -1
  37. package/src/AWS/EC2/RouteTableAssociation.ts +4 -1
  38. package/src/AWS/EC2/SecurityGroup.ts +4 -1
  39. package/src/AWS/EC2/SecurityGroupRule.ts +4 -1
  40. package/src/AWS/EC2/Subnet.ts +4 -1
  41. package/src/AWS/EC2/Vpc.ts +4 -1
  42. package/src/AWS/EC2/VpcEndpoint.ts +4 -1
  43. package/src/AWS/ECR/Repository.ts +4 -1
  44. package/src/AWS/ECS/Cluster.ts +4 -1
  45. package/src/AWS/ECS/Service.ts +4 -1
  46. package/src/AWS/ECS/Task.ts +3 -1
  47. package/src/AWS/EKS/AccessEntry.ts +4 -1
  48. package/src/AWS/EKS/Addon.ts +4 -1
  49. package/src/AWS/EKS/Cluster.ts +3 -1
  50. package/src/AWS/EKS/PodIdentityAssociation.ts +4 -1
  51. package/src/AWS/ELBv2/Listener.ts +4 -1
  52. package/src/AWS/ELBv2/LoadBalancer.ts +4 -1
  53. package/src/AWS/ELBv2/TargetGroup.ts +4 -1
  54. package/src/AWS/EventBridge/EventBus.ts +4 -1
  55. package/src/AWS/EventBridge/Permission.ts +4 -1
  56. package/src/AWS/EventBridge/Rule.ts +4 -1
  57. package/src/AWS/IAM/AccessKey.ts +4 -1
  58. package/src/AWS/IAM/AccountAlias.ts +4 -1
  59. package/src/AWS/IAM/AccountPasswordPolicy.ts +4 -1
  60. package/src/AWS/IAM/Group.ts +4 -1
  61. package/src/AWS/IAM/GroupMembership.ts +4 -1
  62. package/src/AWS/IAM/InstanceProfile.ts +4 -1
  63. package/src/AWS/IAM/LoginProfile.ts +4 -1
  64. package/src/AWS/IAM/OpenIDConnectProvider.ts +4 -1
  65. package/src/AWS/IAM/Policy.ts +4 -1
  66. package/src/AWS/IAM/Role.ts +4 -1
  67. package/src/AWS/IAM/SAMLProvider.ts +4 -1
  68. package/src/AWS/IAM/SSHPublicKey.ts +4 -1
  69. package/src/AWS/IAM/ServerCertificate.ts +4 -1
  70. package/src/AWS/IAM/ServiceSpecificCredential.ts +4 -1
  71. package/src/AWS/IAM/SigningCertificate.ts +4 -1
  72. package/src/AWS/IAM/User.ts +4 -1
  73. package/src/AWS/IAM/VirtualMFADevice.ts +4 -1
  74. package/src/AWS/IdentityCenter/AccountAssignment.ts +4 -1
  75. package/src/AWS/IdentityCenter/Group.ts +4 -1
  76. package/src/AWS/IdentityCenter/Instance.ts +4 -1
  77. package/src/AWS/IdentityCenter/PermissionSet.ts +4 -1
  78. package/src/AWS/Kinesis/Stream.ts +4 -1
  79. package/src/AWS/Kinesis/StreamConsumer.ts +4 -1
  80. package/src/AWS/Lambda/EventSourceMapping.ts +4 -1
  81. package/src/AWS/Lambda/Function.ts +3 -1
  82. package/src/AWS/Lambda/Permission.ts +4 -1
  83. package/src/AWS/Logs/LogGroup.ts +4 -1
  84. package/src/AWS/Organizations/Account.ts +4 -1
  85. package/src/AWS/Organizations/DelegatedAdministrator.ts +4 -1
  86. package/src/AWS/Organizations/Organization.ts +4 -1
  87. package/src/AWS/Organizations/OrganizationResourcePolicy.ts +4 -1
  88. package/src/AWS/Organizations/OrganizationalUnit.ts +4 -1
  89. package/src/AWS/Organizations/Policy.ts +4 -1
  90. package/src/AWS/Organizations/PolicyAttachment.ts +4 -1
  91. package/src/AWS/Organizations/Root.ts +4 -1
  92. package/src/AWS/Organizations/RootPolicyType.ts +4 -1
  93. package/src/AWS/Organizations/TrustedServiceAccess.ts +4 -1
  94. package/src/AWS/Providers.ts +484 -438
  95. package/src/AWS/RDS/DBCluster.ts +4 -1
  96. package/src/AWS/RDS/DBClusterEndpoint.ts +4 -1
  97. package/src/AWS/RDS/DBClusterParameterGroup.ts +4 -1
  98. package/src/AWS/RDS/DBInstance.ts +4 -1
  99. package/src/AWS/RDS/DBParameterGroup.ts +4 -1
  100. package/src/AWS/RDS/DBProxy.ts +4 -1
  101. package/src/AWS/RDS/DBProxyEndpoint.ts +4 -1
  102. package/src/AWS/RDS/DBProxyTargetGroup.ts +4 -1
  103. package/src/AWS/RDS/DBSubnetGroup.ts +4 -1
  104. package/src/AWS/Route53/Record.ts +4 -1
  105. package/src/AWS/S3/Bucket.ts +3 -1
  106. package/src/AWS/SNS/Subscription.ts +4 -1
  107. package/src/AWS/SNS/Topic.ts +4 -1
  108. package/src/AWS/SQS/Queue.ts +3 -1
  109. package/src/AWS/Scheduler/Schedule.ts +4 -1
  110. package/src/AWS/Scheduler/ScheduleGroup.ts +4 -1
  111. package/src/AWS/SecretsManager/Secret.ts +4 -1
  112. package/src/AWS/Website/AssetDeployment.ts +4 -1
  113. package/src/Apply.ts +3 -3
  114. package/src/Binding.ts +18 -17
  115. package/src/Cloudflare/Container/Container.ts +122 -0
  116. package/src/Cloudflare/Container/ContainerApplication.ts +6 -1
  117. package/src/Cloudflare/Container/ContainerBinding.ts +1 -1
  118. package/src/Cloudflare/Container/StartContainer.ts +1 -1
  119. package/src/Cloudflare/D1/D1Database.ts +27 -5
  120. package/src/Cloudflare/KV/KVNamespace.ts +32 -4
  121. package/src/Cloudflare/Providers.ts +62 -60
  122. package/src/Cloudflare/R2/R2Bucket.ts +47 -1
  123. package/src/Cloudflare/R2/R2BucketBinding.ts +26 -31
  124. package/src/Cloudflare/Website/StaticSite.ts +57 -0
  125. package/src/Cloudflare/Website/Vite.ts +52 -8
  126. package/src/Cloudflare/Workers/{DurableObject.ts → DurableObjectNamespace.ts} +242 -0
  127. package/src/Cloudflare/Workers/DynamicWorkerLoader.ts +66 -7
  128. package/src/Cloudflare/Workers/WebSocket.ts +1 -1
  129. package/src/Cloudflare/Workers/Worker.ts +315 -8
  130. package/src/Cloudflare/Workers/Workflow.ts +56 -12
  131. package/src/Cloudflare/Workers/index.ts +1 -1
  132. package/src/GitHub/Comment.ts +224 -0
  133. package/src/GitHub/Secret.ts +212 -0
  134. package/src/GitHub/Variable.ts +123 -0
  135. package/src/GitHub/index.ts +3 -0
  136. package/src/Plan.ts +595 -596
  137. package/src/Platform.ts +9 -8
  138. package/src/Provider.ts +145 -23
  139. package/src/Resource.ts +10 -3
  140. package/src/Stack.ts +1 -1
  141. package/src/Util/dedent.ts +56 -0
  142. package/src/Util/index.ts +1 -0
  143. package/src/Util/service.ts +1 -1
  144. package/src/index.ts +10 -7
@@ -7,6 +7,7 @@ import { isResolved } from "../../Diff.ts";
7
7
  import { createPhysicalName } from "../../PhysicalName.ts";
8
8
  import * as Provider from "../../Provider.ts";
9
9
  import { Resource } from "../../Resource.ts";
10
+ import type { Providers } from "../Providers.ts";
10
11
  import { createInternalTags, diffTags } from "../../Tags.ts";
11
12
 
12
13
  export interface DBClusterProps {
@@ -116,7 +117,9 @@ export interface DBCluster extends Resource<
116
117
  vpcSecurityGroupIds: string[];
117
118
  httpEndpointEnabled: boolean | undefined;
118
119
  tags: Record<string, string>;
119
- }
120
+ },
121
+ never,
122
+ Providers
120
123
  > {}
121
124
 
122
125
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import { createInternalTags, diffTags } from "../../Tags.ts";
8
9
 
9
10
  export interface DBClusterEndpointProps {
@@ -47,7 +48,9 @@ export interface DBClusterEndpoint extends Resource<
47
48
  staticMembers: string[];
48
49
  excludedMembers: string[];
49
50
  tags: Record<string, string>;
50
- }
51
+ },
52
+ never,
53
+ Providers
51
54
  > {}
52
55
 
53
56
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import { createInternalTags, diffTags } from "../../Tags.ts";
8
9
 
9
10
  export interface DBClusterParameterGroupProps {
@@ -34,7 +35,9 @@ export interface DBClusterParameterGroup extends Resource<
34
35
  family: string;
35
36
  description: string | undefined;
36
37
  tags: Record<string, string>;
37
- }
38
+ },
39
+ never,
40
+ Providers
38
41
  > {}
39
42
 
40
43
  /**
@@ -5,6 +5,7 @@ import { isResolved } from "../../Diff.ts";
5
5
  import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
  import { createInternalTags, diffTags } from "../../Tags.ts";
9
10
 
10
11
  export interface DBInstanceProps {
@@ -80,7 +81,9 @@ export interface DBInstance extends Resource<
80
81
  dbSubnetGroupName: string | undefined;
81
82
  dbParameterGroupNames: string[];
82
83
  tags: Record<string, string>;
83
- }
84
+ },
85
+ never,
86
+ Providers
84
87
  > {}
85
88
 
86
89
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import { createInternalTags, diffTags } from "../../Tags.ts";
8
9
 
9
10
  export interface DBParameterGroupProps {
@@ -34,7 +35,9 @@ export interface DBParameterGroup extends Resource<
34
35
  family: string;
35
36
  description: string | undefined;
36
37
  tags: Record<string, string>;
37
- }
38
+ },
39
+ never,
40
+ Providers
38
41
  > {}
39
42
 
40
43
  /**
@@ -5,6 +5,7 @@ import { isResolved } from "../../Diff.ts";
5
5
  import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
  import { createInternalTags, diffTags } from "../../Tags.ts";
9
10
 
10
11
  export interface DBProxyProps {
@@ -75,7 +76,9 @@ export interface DBProxy extends Resource<
75
76
  idleClientTimeout: number | undefined;
76
77
  debugLogging: boolean | undefined;
77
78
  tags: Record<string, string>;
78
- }
79
+ },
80
+ never,
81
+ Providers
79
82
  > {}
80
83
 
81
84
  /**
@@ -5,6 +5,7 @@ import { isResolved } from "../../Diff.ts";
5
5
  import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
  import { createInternalTags, diffTags } from "../../Tags.ts";
9
10
 
10
11
  export interface DBProxyEndpointProps {
@@ -52,7 +53,9 @@ export interface DBProxyEndpoint extends Resource<
52
53
  vpcSecurityGroupIds: string[];
53
54
  targetRole: string | undefined;
54
55
  tags: Record<string, string>;
55
- }
56
+ },
57
+ never,
58
+ Providers
56
59
  > {}
57
60
 
58
61
  /**
@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";
3
3
  import { isResolved } from "../../Diff.ts";
4
4
  import * as Provider from "../../Provider.ts";
5
5
  import { Resource } from "../../Resource.ts";
6
+ import type { Providers } from "../Providers.ts";
6
7
 
7
8
  export interface DBProxyTargetGroupProps {
8
9
  /**
@@ -40,7 +41,9 @@ export interface DBProxyTargetGroup extends Resource<
40
41
  connectionPoolConfig: rds.ConnectionPoolConfigurationInfo | undefined;
41
42
  dbClusterIdentifiers: string[];
42
43
  dbInstanceIdentifiers: string[];
43
- }
44
+ },
45
+ never,
46
+ Providers
44
47
  > {}
45
48
 
46
49
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import { createInternalTags, diffTags } from "../../Tags.ts";
8
9
  import type { SubnetId } from "../EC2/Subnet.ts";
9
10
 
@@ -38,7 +39,9 @@ export interface DBSubnetGroup extends Resource<
38
39
  status: string | undefined;
39
40
  supportedNetworkTypes: string[] | undefined;
40
41
  tags: Record<string, string>;
41
- }
42
+ },
43
+ never,
44
+ Providers
42
45
  > {}
43
46
 
44
47
  /**
@@ -5,6 +5,7 @@ import { isResolved } from "../../Diff.ts";
5
5
  import type { Input } from "../../Input.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
 
9
10
  export interface RecordAliasTarget {
10
11
  /**
@@ -92,7 +93,9 @@ export interface Record extends Resource<
92
93
  * Optional routing set identifier.
93
94
  */
94
95
  setIdentifier: string | undefined;
95
- }
96
+ },
97
+ never,
98
+ Providers
96
99
  > {}
97
100
 
98
101
  /**
@@ -8,6 +8,7 @@ import { isResolved } from "../../Diff.ts";
8
8
  import { createPhysicalName } from "../../PhysicalName.ts";
9
9
  import * as Provider from "../../Provider.ts";
10
10
  import { Resource, type ResourceBinding } from "../../Resource.ts";
11
+ import type { Providers } from "../Providers.ts";
11
12
  import { diffTags } from "../../Tags.ts";
12
13
  import { Account, type AccountID } from "../Account.ts";
13
14
  import type { PolicyStatement } from "../IAM/Policy.ts";
@@ -76,7 +77,8 @@ export interface Bucket extends Resource<
76
77
  * Policy statements for the bucket.
77
78
  */
78
79
  policyStatements?: PolicyStatement[];
79
- }
80
+ },
81
+ Providers
80
82
  > {}
81
83
 
82
84
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import type { Input } from "../../Input.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
 
8
9
  export type SubscriptionArn = string;
9
10
 
@@ -42,7 +43,9 @@ export interface Subscription extends Resource<
42
43
  owner: string | undefined;
43
44
  pendingConfirmation: boolean;
44
45
  attributes: Record<string, string>;
45
- }
46
+ },
47
+ never,
48
+ Providers
46
49
  > {}
47
50
 
48
51
  /**
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import { createInternalTags, createTagsList, diffTags } from "../../Tags.ts";
8
9
  import type { AccountID } from "../Account.ts";
9
10
  import type { RegionID } from "../Region.ts";
@@ -50,7 +51,9 @@ export interface Topic extends Resource<
50
51
  attributes: Record<string, string>;
51
52
  dataProtectionPolicy: string | undefined;
52
53
  tags: Record<string, string>;
53
- }
54
+ },
55
+ never,
56
+ Providers
54
57
  > {}
55
58
 
56
59
  /**
@@ -6,6 +6,7 @@ import { isResolved } from "../../Diff.ts";
6
6
  import { createPhysicalName } from "../../PhysicalName.ts";
7
7
  import * as Provider from "../../Provider.ts";
8
8
  import { Resource, type ResourceBinding } from "../../Resource.ts";
9
+ import type { Providers } from "../Providers.ts";
9
10
  import { Account, type AccountID } from "../Account.ts";
10
11
  import type { PolicyStatement } from "../IAM/Policy.ts";
11
12
  import type { RegionID } from "../Region.ts";
@@ -82,7 +83,8 @@ export interface Queue extends Resource<
82
83
  },
83
84
  {
84
85
  policyStatements: PolicyStatement[];
85
- }
86
+ },
87
+ Providers
86
88
  > {}
87
89
 
88
90
  export const Queue = Resource<Queue>("AWS.SQS.Queue");
@@ -5,6 +5,7 @@ import type { Input } from "../../Input.ts";
5
5
  import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
  import {
9
10
  createInternalTags,
10
11
  createTagsList,
@@ -97,7 +98,9 @@ export interface Schedule extends Resource<
97
98
  scheduleName: string;
98
99
  groupName: string;
99
100
  state: string | undefined;
100
- }
101
+ },
102
+ never,
103
+ Providers
101
104
  > {}
102
105
 
103
106
  export const Schedule = Resource<Schedule>("AWS.Scheduler.Schedule");
@@ -4,6 +4,7 @@ import { isResolved } from "../../Diff.ts";
4
4
  import { createPhysicalName } from "../../PhysicalName.ts";
5
5
  import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
+ import type { Providers } from "../Providers.ts";
7
8
  import {
8
9
  createInternalTags,
9
10
  createTagsList,
@@ -45,7 +46,9 @@ export interface ScheduleGroup extends Resource<
45
46
  scheduleGroupArn: string;
46
47
  scheduleGroupName: string;
47
48
  state: string | undefined;
48
- }
49
+ },
50
+ never,
51
+ Providers
49
52
  > {}
50
53
 
51
54
  export const ScheduleGroup = Resource<ScheduleGroup>(
@@ -5,6 +5,7 @@ import { isResolved } from "../../Diff.ts";
5
5
  import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
+ import type { Providers } from "../Providers.ts";
8
9
  import { createInternalTags, diffTags } from "../../Tags.ts";
9
10
 
10
11
  export interface GenerateSecretStringProps
@@ -62,7 +63,9 @@ export interface Secret extends Resource<
62
63
  description: string | undefined;
63
64
  kmsKeyId: string | undefined;
64
65
  tags: Record<string, string>;
65
- }
66
+ },
67
+ never,
68
+ Providers
66
69
  > {}
67
70
 
68
71
  /**
@@ -7,6 +7,7 @@ import { readdir, readFile } from "node:fs/promises";
7
7
  import path from "node:path";
8
8
  import * as Provider from "../../Provider.ts";
9
9
  import { Resource } from "../../Resource.ts";
10
+ import type { Providers } from "../Providers.ts";
10
11
  import type { WebsiteTextEncoding } from "./shared.ts";
11
12
 
12
13
  export interface AssetFileOption {
@@ -67,7 +68,9 @@ export interface AssetDeployment extends Resource<
67
68
  prefix: string;
68
69
  version: string;
69
70
  fileCount: number;
70
- }
71
+ },
72
+ never,
73
+ Providers
71
74
  > {}
72
75
 
73
76
  /**
package/src/Apply.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as Deferred from "effect/Deferred";
2
2
  import * as Effect from "effect/Effect";
3
+ import * as Option from "effect/Option";
3
4
  import type { Simplify } from "effect/Types";
4
5
  import {
5
6
  Artifacts,
@@ -8,7 +9,6 @@ import {
8
9
  ensureArtifactStore,
9
10
  makeScopedArtifacts,
10
11
  } from "./Artifacts.ts";
11
- import * as Option from "effect/Option";
12
12
  import {
13
13
  type PlanStatusSession,
14
14
  type ScopedPlanStatusSession,
@@ -21,7 +21,7 @@ import type { Input } from "./Input.ts";
21
21
  import { generateInstanceId, InstanceId } from "./InstanceId.ts";
22
22
  import * as Output from "./Output.ts";
23
23
  import { type Apply, type Delete, type Plan } from "./Plan.ts";
24
- import { getProviderByType } from "./Provider.ts";
24
+ import { findProviderByType } from "./Provider.ts";
25
25
  import type { ResourceBinding } from "./Resource.ts";
26
26
  import { Stack } from "./Stack.ts";
27
27
  import { Stage } from "./Stage.ts";
@@ -927,7 +927,7 @@ const collectGarbage = Effect.fnUntraced(function* (
927
927
  downstream: node.old.downstream,
928
928
  props: node.old.props,
929
929
  attr: node.old.attr,
930
- provider: yield* getProviderByType(node.old.resourceType),
930
+ provider: yield* findProviderByType(node.old.resourceType),
931
931
  };
932
932
 
933
933
  const fqn = toFqn(namespace, logicalId);
package/src/Binding.ts CHANGED
@@ -6,6 +6,7 @@ import { SingleShotGen } from "effect/Utils";
6
6
  import { ExecutionContext } from "./ExecutionContext.ts";
7
7
  import * as Namespace from "./Namespace.ts";
8
8
  import { ALCHEMY_PHASE } from "./Phase.ts";
9
+ import { tryFindProviderByType } from "./Provider.ts";
9
10
  import type { ResourceLike } from "./Resource.ts";
10
11
  import { Self } from "./Self.ts";
11
12
  import { CurrentStack } from "./Stack.ts";
@@ -133,24 +134,24 @@ export const Policy =
133
134
 
134
135
  // we use a service option because at runtime (e.g. in a Lambda Function or Cloudflare Worker)
135
136
  // the Policy Layer is not provided and this becomes a no-op
136
- const Service = Effect.serviceOption(self)
137
- .asEffect()
138
- .pipe(
139
- Effect.map(Option.getOrUndefined),
140
- Effect.flatMap((service) =>
141
- service
142
- ? Effect.succeed(service)
143
- : Effect.all([CurrentStack, ALCHEMY_PHASE.asEffect()]).pipe(
144
- Effect.flatMap(([stack, phase]) =>
145
- stack && phase === "plan"
146
- ? Effect.die(
147
- `Binding.Policy provider '${Identifier}' was not provided at Plan Time in Stack '${stack.name}'`,
148
- )
149
- : Effect.succeed((() => Effect.void) as any as Shape),
150
- ),
137
+ const Service = tryFindProviderByType<Policy<Self, Identifier, Shape>>(
138
+ self.key as Identifier,
139
+ ).pipe(
140
+ Effect.map(Option.getOrUndefined),
141
+ Effect.flatMap((service) =>
142
+ service
143
+ ? Effect.succeed(service)
144
+ : Effect.all([CurrentStack, ALCHEMY_PHASE.asEffect()]).pipe(
145
+ Effect.flatMap(([stack, phase]) =>
146
+ stack && phase === "plan"
147
+ ? Effect.die(
148
+ `Binding.Policy provider 'Policy<${Identifier}>' was not provided at Plan Time in Stack '${stack.name}'`,
149
+ )
150
+ : Effect.succeed((() => Effect.void) as any as Shape),
151
151
  ),
152
- ),
153
- );
152
+ ),
153
+ ),
154
+ );
154
155
 
155
156
  const asEffect = () =>
156
157
  Effect.all([Self.asEffect(), Service]).pipe(
@@ -48,6 +48,128 @@ export type Container = {
48
48
  interceptAllOutboundHttp(binding: Fetcher): Effect.Effect<void>;
49
49
  };
50
50
 
51
+ /**
52
+ * A Cloudflare Container that runs a long-lived process alongside a
53
+ * Durable Object.
54
+ *
55
+ * Containers always use the **Container Layer** pattern — the class
56
+ * and `.make()` must live in separate files. A Container must be
57
+ * bound to a Durable Object, and the DO imports the class to get a
58
+ * typed handle. If the class and `.make()` lived in the same file,
59
+ * the DO's bundle would pull in all of the container's runtime
60
+ * dependencies (process spawners, Node APIs, SDKs, etc.), which
61
+ * would bloat the bundle and likely break the Cloudflare Workers
62
+ * runtime. Keeping them separate ensures the bundler only includes
63
+ * the tiny class in the DO's output.
64
+ *
65
+ * See the {@link https://alchemy.run/concepts/platform | Platform
66
+ * concept} page for how this fits into the async / effect / layer
67
+ * progression.
68
+ *
69
+ * @section Container Layer
70
+ * Define the class and `.make()` in separate files. The class
71
+ * declares the container's identity, configuration, and typed
72
+ * shape. `.make()` provides the runtime implementation as a
73
+ * default export. Use `Container.of` to construct the typed
74
+ * shape — it ensures your implementation matches the methods
75
+ * declared on the class.
76
+ *
77
+ * @example Container class
78
+ * ```typescript
79
+ * // src/Sandbox.ts
80
+ * export class Sandbox extends Cloudflare.Container<
81
+ * Sandbox,
82
+ * {
83
+ * exec: (cmd: string) => Effect.Effect<{
84
+ * exitCode: number;
85
+ * stdout: string;
86
+ * stderr: string;
87
+ * }>;
88
+ * }
89
+ * >()(
90
+ * "Sandbox",
91
+ * { main: import.meta.filename },
92
+ * ) {}
93
+ * ```
94
+ *
95
+ * @example Container .make()
96
+ * ```typescript
97
+ * // src/Sandbox.runtime.ts
98
+ * export default Sandbox.make(
99
+ * Effect.gen(function* () {
100
+ * const cp = yield* ChildProcessSpawner;
101
+ *
102
+ * return Sandbox.of({
103
+ * exec: (cmd) =>
104
+ * cp.spawn(ChildProcess.make(cmd, { shell: true })).pipe(
105
+ * Effect.map(({ exitCode, stdout, stderr }) => ({
106
+ * exitCode, stdout, stderr,
107
+ * })),
108
+ * Effect.scoped,
109
+ * ),
110
+ * fetch: Effect.succeed(
111
+ * HttpServerResponse.text("Hello from container!"),
112
+ * ),
113
+ * });
114
+ * }),
115
+ * );
116
+ * ```
117
+ *
118
+ * @section Configuration
119
+ * The props object accepts `main` (entrypoint file), `instanceType`
120
+ * (compute size), `runtime` (`"bun"` or `"node"`), and
121
+ * `observability` settings. Use `Stack.useSync` to vary config by
122
+ * stage.
123
+ *
124
+ * @example Stage-dependent configuration
125
+ * ```typescript
126
+ * export class Sandbox extends Cloudflare.Container<Sandbox>()(
127
+ * "Sandbox",
128
+ * Stack.useSync((stack) => ({
129
+ * main: import.meta.filename,
130
+ * instanceType: stack.stage === "prod" ? "standard-1" : "dev",
131
+ * observability: { logs: { enabled: true } },
132
+ * })),
133
+ * ) {}
134
+ * ```
135
+ *
136
+ * @section Starting from a Durable Object
137
+ * Use `Cloudflare.Container.bind` in the outer init phase to bind
138
+ * the container class, then `Cloudflare.start` in the inner
139
+ * per-instance phase to start it. Because the DO only imports the
140
+ * class, the runtime implementation is completely excluded from the
141
+ * DO's bundle.
142
+ *
143
+ * @example Binding and starting a container
144
+ * ```typescript
145
+ * // init (outer Effect) — only imports the class
146
+ * const sandbox = yield* Cloudflare.Container.bind(Sandbox);
147
+ *
148
+ * // per-instance (inner Effect)
149
+ * return Effect.gen(function* () {
150
+ * const container = yield* Cloudflare.start(sandbox);
151
+ *
152
+ * return {
153
+ * exec: (cmd: string) => container.exec(cmd),
154
+ * };
155
+ * });
156
+ * ```
157
+ *
158
+ * @section HTTP Requests to Container Ports
159
+ * Use `getTcpPort` to get a `fetch` handle for a specific port on
160
+ * the running container. This lets you make HTTP requests to
161
+ * servers running inside the container process.
162
+ *
163
+ * @example Fetching from a container port
164
+ * ```typescript
165
+ * const container = yield* Cloudflare.start(sandbox);
166
+ * const { fetch } = yield* container.getTcpPort(3000);
167
+ *
168
+ * const response = yield* fetch(
169
+ * HttpClientRequest.get("http://container/health"),
170
+ * );
171
+ * ```
172
+ */
51
173
  export const Container: Platform<
52
174
  ContainerApplication,
53
175
  ContainerServices,
@@ -33,6 +33,7 @@ import { sha256Object } from "../../Util/sha256.ts";
33
33
  import { normalizeNulls } from "../../Util/stable.ts";
34
34
  import { Account } from "../Account.ts";
35
35
  import { CloudflareLogs, type TelemetryFilter } from "../Logs.ts";
36
+ import type { Providers } from "../Providers.ts";
36
37
  import { Container, ContainerTypeId } from "./Container.ts";
37
38
 
38
39
  export { Credentials } from "@distilled.cloud/cloudflare/Credentials";
@@ -222,6 +223,9 @@ export type ContainerServices =
222
223
 
223
224
  export type ContainerShape = Main<ContainerServices>;
224
225
 
226
+ /**
227
+ * @internal
228
+ */
225
229
  export interface ContainerApplication<Shape = unknown> extends Resource<
226
230
  ContainerTypeId,
227
231
  ContainerApplicationProps,
@@ -254,7 +258,8 @@ export interface ContainerApplication<Shape = unknown> extends Resource<
254
258
  namespaceId: string;
255
259
  };
256
260
  env?: Record<string, any>;
257
- }
261
+ },
262
+ Providers
258
263
  > {
259
264
  /** @internal phantom */
260
265
  Shape: Shape;
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  DurableObjectNamespace,
10
10
  DurableObjectState,
11
- } from "../Workers/DurableObject.ts";
11
+ } from "../Workers/DurableObjectNamespace.ts";
12
12
  import { Worker } from "../Workers/Worker.ts";
13
13
  import type { Container } from "./Container.ts";
14
14
  import type { ContainerApplication } from "./ContainerApplication.ts";
@@ -6,7 +6,7 @@ import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
6
6
  import * as HttpServerRequest from "effect/unstable/http/HttpServerRequest";
7
7
  import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
8
8
  import { type Fetcher } from "../Fetcher.ts";
9
- import { DurableObjectState } from "../Workers/DurableObject.ts";
9
+ import { DurableObjectState } from "../Workers/DurableObjectNamespace.ts";
10
10
  import { type Container, ContainerError } from "./Container.ts";
11
11
 
12
12
  /**
@@ -6,6 +6,7 @@ import { createPhysicalName } from "../../PhysicalName.ts";
6
6
  import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
8
  import { Account } from "../Account.ts";
9
+ import type { Providers } from "../Providers.ts";
9
10
 
10
11
  export type Jurisdiction = "default" | "eu" | "fedramp";
11
12
  export type PrimaryLocationHint =
@@ -48,24 +49,45 @@ export type D1Database = Resource<
48
49
  jurisdiction: Jurisdiction;
49
50
  readReplication: { mode: "auto" | "disabled" } | undefined;
50
51
  accountId: string;
51
- }
52
+ },
53
+ never,
54
+ Providers
52
55
  >;
53
56
 
54
57
  /**
55
58
  * A Cloudflare D1 serverless SQL database built on SQLite.
56
59
  *
60
+ * D1 is a serverless relational database that runs at the edge. Create a
61
+ * database as a resource, then bind it to a Worker to run SQL queries.
62
+ *
57
63
  * @section Creating a Database
58
- * @example Basic Database
64
+ * @example Basic database
59
65
  * ```typescript
60
- * const db = yield* Database("my-db", {});
66
+ * const db = yield* Cloudflare.D1Database("my-db");
61
67
  * ```
62
68
  *
63
- * @example Database with Location Hint
69
+ * @example Database with location hint
64
70
  * ```typescript
65
- * const db = yield* Database("my-db", {
71
+ * const db = yield* Cloudflare.D1Database("my-db", {
66
72
  * primaryLocationHint: "wnam",
67
73
  * });
68
74
  * ```
75
+ *
76
+ * @section Binding to a Worker
77
+ * @example Using D1 inside a Worker
78
+ * ```typescript
79
+ * const db = yield* Cloudflare.D1Connection.bind(MyDB);
80
+ *
81
+ * // Run a query
82
+ * const results = yield* db.prepare("SELECT * FROM users WHERE id = ?")
83
+ * .bind(userId)
84
+ * .all();
85
+ *
86
+ * // Execute a mutation
87
+ * yield* db.prepare("INSERT INTO users (id, name) VALUES (?, ?)")
88
+ * .bind(newId, name)
89
+ * .run();
90
+ * ```
69
91
  */
70
92
  export const D1Database = Resource<D1Database>("Cloudflare.D1Database");
71
93