alchemy 0.1.17 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/lib/alchemy.d.ts +67 -0
  2. package/lib/alchemy.js +40 -0
  3. package/lib/apply.d.ts +3 -20
  4. package/lib/apply.js +86 -78
  5. package/lib/aws/account-id.d.ts +0 -1
  6. package/lib/aws/account-id.js +0 -1
  7. package/lib/aws/bucket.d.ts +4 -7
  8. package/lib/aws/bucket.js +8 -12
  9. package/lib/aws/function.d.ts +4 -7
  10. package/lib/aws/function.js +9 -30
  11. package/lib/aws/index.d.ts +1 -1
  12. package/lib/aws/index.js +1 -1
  13. package/lib/aws/oidc/github-oidc-provider.d.ts +2 -6
  14. package/lib/aws/oidc/github-oidc-provider.js +10 -15
  15. package/lib/aws/oidc/index.d.ts +0 -1
  16. package/lib/aws/oidc/index.js +0 -1
  17. package/lib/aws/oidc/oidc-provider.d.ts +4 -6
  18. package/lib/aws/oidc/oidc-provider.js +9 -11
  19. package/lib/aws/policy-attachment.d.ts +9 -0
  20. package/lib/aws/policy-attachment.js +20 -0
  21. package/lib/aws/policy.d.ts +4 -16
  22. package/lib/aws/policy.js +9 -40
  23. package/lib/aws/queue.d.ts +4 -34
  24. package/lib/aws/queue.js +10 -20
  25. package/lib/aws/role.d.ts +4 -7
  26. package/lib/aws/role.js +17 -26
  27. package/lib/aws/ses.d.ts +4 -10
  28. package/lib/aws/ses.js +118 -131
  29. package/lib/aws/table.d.ts +4 -7
  30. package/lib/aws/table.js +8 -11
  31. package/lib/cloudflare/api.d.ts +0 -1
  32. package/lib/cloudflare/api.js +0 -1
  33. package/lib/cloudflare/asset-manifest.d.ts +0 -1
  34. package/lib/cloudflare/asset-manifest.js +0 -1
  35. package/lib/cloudflare/auth.d.ts +0 -1
  36. package/lib/cloudflare/auth.js +0 -1
  37. package/lib/cloudflare/bindings.d.ts +4 -3
  38. package/lib/cloudflare/bindings.js +3 -2
  39. package/lib/cloudflare/bound.d.ts +7 -0
  40. package/lib/cloudflare/bound.js +1 -0
  41. package/lib/cloudflare/bucket.d.ts +7 -15
  42. package/lib/cloudflare/bucket.js +12 -19
  43. package/lib/cloudflare/durable-object-namespace.d.ts +0 -3
  44. package/lib/cloudflare/durable-object-namespace.js +0 -4
  45. package/lib/cloudflare/generate-asset-manifest.d.ts +0 -1
  46. package/lib/cloudflare/generate-asset-manifest.js +1 -2
  47. package/lib/cloudflare/index.d.ts +0 -1
  48. package/lib/cloudflare/index.js +0 -1
  49. package/lib/cloudflare/kv-namespace.d.ts +6 -9
  50. package/lib/cloudflare/kv-namespace.js +16 -20
  51. package/lib/cloudflare/state.d.ts +0 -1
  52. package/lib/cloudflare/state.js +0 -1
  53. package/lib/cloudflare/static-site-router.d.ts +0 -1
  54. package/lib/cloudflare/static-site-router.js +0 -4
  55. package/lib/cloudflare/static-site.d.ts +5 -11
  56. package/lib/cloudflare/static-site.js +16 -28
  57. package/lib/cloudflare/types.d.ts +0 -1
  58. package/lib/cloudflare/types.js +0 -1
  59. package/lib/cloudflare/upload-asset-manifest.d.ts +0 -1
  60. package/lib/cloudflare/upload-asset-manifest.js +0 -1
  61. package/lib/cloudflare/worker-metadata.d.ts +0 -1
  62. package/lib/cloudflare/worker-metadata.js +0 -1
  63. package/lib/cloudflare/worker-migration.d.ts +0 -1
  64. package/lib/cloudflare/worker-migration.js +0 -1
  65. package/lib/cloudflare/worker.d.ts +13 -13
  66. package/lib/cloudflare/worker.js +43 -43
  67. package/lib/context.d.ts +58 -0
  68. package/lib/context.js +36 -0
  69. package/lib/destroy.d.ts +10 -13
  70. package/lib/destroy.js +104 -43
  71. package/lib/{esbuild.d.ts → esbuild/bundle.d.ts} +4 -18
  72. package/lib/{esbuild.js → esbuild/bundle.js} +10 -24
  73. package/lib/esbuild/index.d.ts +1 -0
  74. package/lib/esbuild/index.js +1 -0
  75. package/lib/fs/file.d.ts +13 -0
  76. package/lib/fs/file.js +20 -0
  77. package/lib/fs/folder.d.ts +10 -0
  78. package/lib/fs/folder.js +16 -0
  79. package/lib/fs/index.d.ts +2 -0
  80. package/lib/fs/index.js +2 -0
  81. package/lib/github/client.d.ts +0 -1
  82. package/lib/github/client.js +0 -1
  83. package/lib/github/index.d.ts +0 -1
  84. package/lib/github/index.js +0 -1
  85. package/lib/github/secret.d.ts +6 -7
  86. package/lib/github/secret.js +30 -36
  87. package/lib/index.d.ts +7 -10
  88. package/lib/index.js +6 -9
  89. package/lib/resource.d.ts +34 -62
  90. package/lib/resource.js +29 -270
  91. package/lib/scope.d.ts +35 -14
  92. package/lib/scope.js +78 -23
  93. package/lib/secret.d.ts +7 -0
  94. package/lib/secret.js +17 -0
  95. package/lib/state.d.ts +14 -10
  96. package/lib/state.js +15 -13
  97. package/lib/stripe/index.d.ts +0 -1
  98. package/lib/stripe/index.js +0 -1
  99. package/lib/stripe/price.d.ts +4 -5
  100. package/lib/stripe/price.js +10 -20
  101. package/lib/stripe/product.d.ts +4 -5
  102. package/lib/stripe/product.js +10 -20
  103. package/lib/stripe/webhook.d.ts +4 -6
  104. package/lib/stripe/webhook.js +12 -25
  105. package/lib/test/bun.d.ts +19 -0
  106. package/lib/test/bun.js +55 -0
  107. package/lib/{utils → util}/content-type.d.ts +0 -1
  108. package/lib/{utils → util}/content-type.js +0 -1
  109. package/lib/util/encrypt.d.ts +16 -0
  110. package/lib/util/encrypt.js +44 -0
  111. package/lib/{error.d.ts → util/ignore.d.ts} +0 -1
  112. package/lib/{error.js → util/ignore.js} +0 -1
  113. package/lib/{utils → util}/retry.d.ts +0 -1
  114. package/lib/{utils → util}/retry.js +0 -1
  115. package/lib/util/serde.d.ts +3 -0
  116. package/lib/util/serde.js +46 -0
  117. package/lib/util/slugify.d.ts +1 -0
  118. package/lib/util/slugify.js +3 -0
  119. package/package.json +5 -7
  120. package/src/alchemy.ts +120 -0
  121. package/src/apply.ts +109 -111
  122. package/src/aws/bucket.ts +11 -14
  123. package/src/aws/function.ts +13 -33
  124. package/src/aws/index.ts +1 -0
  125. package/src/aws/oidc/github-oidc-provider.ts +14 -19
  126. package/src/aws/oidc/oidc-provider.ts +19 -12
  127. package/src/aws/policy-attachment.ts +51 -0
  128. package/src/aws/policy.ts +15 -60
  129. package/src/aws/queue.ts +17 -21
  130. package/src/aws/role.ts +25 -28
  131. package/src/aws/ses.ts +150 -164
  132. package/src/aws/table.ts +15 -15
  133. package/src/cloudflare/bindings.ts +12 -2
  134. package/src/cloudflare/bound.ts +18 -0
  135. package/src/cloudflare/bucket.ts +40 -48
  136. package/src/cloudflare/durable-object-namespace.ts +0 -10
  137. package/src/cloudflare/generate-asset-manifest.ts +1 -1
  138. package/src/cloudflare/kv-namespace.ts +35 -33
  139. package/src/cloudflare/static-site-router.ts +0 -3
  140. package/src/cloudflare/static-site.ts +43 -59
  141. package/src/cloudflare/worker.ts +76 -64
  142. package/src/context.ts +122 -0
  143. package/src/destroy.ts +124 -73
  144. package/src/{esbuild.ts → esbuild/bundle.ts} +16 -28
  145. package/src/esbuild/index.ts +1 -0
  146. package/src/fs/file.ts +39 -0
  147. package/src/fs/folder.ts +32 -0
  148. package/src/fs/index.ts +2 -0
  149. package/src/github/secret.ts +53 -49
  150. package/src/index.ts +8 -15
  151. package/src/resource.ts +101 -462
  152. package/src/scope.ts +101 -36
  153. package/src/secret.ts +18 -0
  154. package/src/state.ts +30 -20
  155. package/src/stripe/price.ts +17 -22
  156. package/src/stripe/product.ts +17 -22
  157. package/src/stripe/webhook.ts +21 -27
  158. package/src/test/bun.ts +105 -0
  159. package/src/util/encrypt.ts +79 -0
  160. package/src/util/serde.ts +53 -0
  161. package/src/util/slugify.ts +3 -0
  162. package/lib/$.d.ts +0 -12
  163. package/lib/$.d.ts.map +0 -1
  164. package/lib/$.js +0 -42
  165. package/lib/$.js.map +0 -1
  166. package/lib/alchemize.d.ts +0 -43
  167. package/lib/alchemize.d.ts.map +0 -1
  168. package/lib/alchemize.js +0 -112
  169. package/lib/alchemize.js.map +0 -1
  170. package/lib/apply.d.ts.map +0 -1
  171. package/lib/apply.js.map +0 -1
  172. package/lib/aws/account-id.d.ts.map +0 -1
  173. package/lib/aws/account-id.js.map +0 -1
  174. package/lib/aws/bucket.d.ts.map +0 -1
  175. package/lib/aws/bucket.js.map +0 -1
  176. package/lib/aws/function.d.ts.map +0 -1
  177. package/lib/aws/function.js.map +0 -1
  178. package/lib/aws/index.d.ts.map +0 -1
  179. package/lib/aws/index.js.map +0 -1
  180. package/lib/aws/oidc/github-oidc-provider.d.ts.map +0 -1
  181. package/lib/aws/oidc/github-oidc-provider.js.map +0 -1
  182. package/lib/aws/oidc/index.d.ts.map +0 -1
  183. package/lib/aws/oidc/index.js.map +0 -1
  184. package/lib/aws/oidc/oidc-provider.d.ts.map +0 -1
  185. package/lib/aws/oidc/oidc-provider.js.map +0 -1
  186. package/lib/aws/policy.d.ts.map +0 -1
  187. package/lib/aws/policy.js.map +0 -1
  188. package/lib/aws/queue.d.ts.map +0 -1
  189. package/lib/aws/queue.js.map +0 -1
  190. package/lib/aws/role.d.ts.map +0 -1
  191. package/lib/aws/role.js.map +0 -1
  192. package/lib/aws/ses.d.ts.map +0 -1
  193. package/lib/aws/ses.js.map +0 -1
  194. package/lib/aws/table.d.ts.map +0 -1
  195. package/lib/aws/table.js.map +0 -1
  196. package/lib/cloudflare/api.d.ts.map +0 -1
  197. package/lib/cloudflare/api.js.map +0 -1
  198. package/lib/cloudflare/asset-manifest.d.ts.map +0 -1
  199. package/lib/cloudflare/asset-manifest.js.map +0 -1
  200. package/lib/cloudflare/auth.d.ts.map +0 -1
  201. package/lib/cloudflare/auth.js.map +0 -1
  202. package/lib/cloudflare/bindings.d.ts.map +0 -1
  203. package/lib/cloudflare/bindings.js.map +0 -1
  204. package/lib/cloudflare/bucket.d.ts.map +0 -1
  205. package/lib/cloudflare/bucket.js.map +0 -1
  206. package/lib/cloudflare/durable-object-namespace.d.ts.map +0 -1
  207. package/lib/cloudflare/durable-object-namespace.js.map +0 -1
  208. package/lib/cloudflare/generate-asset-manifest.d.ts.map +0 -1
  209. package/lib/cloudflare/generate-asset-manifest.js.map +0 -1
  210. package/lib/cloudflare/index.d.ts.map +0 -1
  211. package/lib/cloudflare/index.js.map +0 -1
  212. package/lib/cloudflare/kv-namespace.d.ts.map +0 -1
  213. package/lib/cloudflare/kv-namespace.js.map +0 -1
  214. package/lib/cloudflare/state.d.ts.map +0 -1
  215. package/lib/cloudflare/state.js.map +0 -1
  216. package/lib/cloudflare/static-site-router.d.ts.map +0 -1
  217. package/lib/cloudflare/static-site-router.js.map +0 -1
  218. package/lib/cloudflare/static-site.d.ts.map +0 -1
  219. package/lib/cloudflare/static-site.js.map +0 -1
  220. package/lib/cloudflare/types.d.ts.map +0 -1
  221. package/lib/cloudflare/types.js.map +0 -1
  222. package/lib/cloudflare/upload-asset-manifest.d.ts.map +0 -1
  223. package/lib/cloudflare/upload-asset-manifest.js.map +0 -1
  224. package/lib/cloudflare/worker-metadata.d.ts.map +0 -1
  225. package/lib/cloudflare/worker-metadata.js.map +0 -1
  226. package/lib/cloudflare/worker-migration.d.ts.map +0 -1
  227. package/lib/cloudflare/worker-migration.js.map +0 -1
  228. package/lib/cloudflare/worker.d.ts.map +0 -1
  229. package/lib/cloudflare/worker.js.map +0 -1
  230. package/lib/destroy.d.ts.map +0 -1
  231. package/lib/destroy.js.map +0 -1
  232. package/lib/error.d.ts.map +0 -1
  233. package/lib/error.js.map +0 -1
  234. package/lib/esbuild.d.ts.map +0 -1
  235. package/lib/esbuild.js.map +0 -1
  236. package/lib/fs.d.ts +0 -12
  237. package/lib/fs.d.ts.map +0 -1
  238. package/lib/fs.js +0 -41
  239. package/lib/fs.js.map +0 -1
  240. package/lib/github/client.d.ts.map +0 -1
  241. package/lib/github/client.js.map +0 -1
  242. package/lib/github/index.d.ts.map +0 -1
  243. package/lib/github/index.js.map +0 -1
  244. package/lib/github/secret.d.ts.map +0 -1
  245. package/lib/github/secret.js.map +0 -1
  246. package/lib/global.d.ts +0 -16
  247. package/lib/global.d.ts.map +0 -1
  248. package/lib/global.js +0 -42
  249. package/lib/global.js.map +0 -1
  250. package/lib/index.d.ts.map +0 -1
  251. package/lib/index.js.map +0 -1
  252. package/lib/input.d.ts +0 -6
  253. package/lib/input.d.ts.map +0 -1
  254. package/lib/input.js +0 -2
  255. package/lib/input.js.map +0 -1
  256. package/lib/main.d.ts +0 -3
  257. package/lib/main.d.ts.map +0 -1
  258. package/lib/main.js +0 -32
  259. package/lib/main.js.map +0 -1
  260. package/lib/output.d.ts +0 -24
  261. package/lib/output.d.ts.map +0 -1
  262. package/lib/output.js +0 -23
  263. package/lib/output.js.map +0 -1
  264. package/lib/print.d.ts +0 -7
  265. package/lib/print.d.ts.map +0 -1
  266. package/lib/print.js +0 -10
  267. package/lib/print.js.map +0 -1
  268. package/lib/resource.d.ts.map +0 -1
  269. package/lib/resource.js.map +0 -1
  270. package/lib/scope.d.ts.map +0 -1
  271. package/lib/scope.js.map +0 -1
  272. package/lib/slug.d.ts +0 -2
  273. package/lib/slug.d.ts.map +0 -1
  274. package/lib/slug.js +0 -4
  275. package/lib/slug.js.map +0 -1
  276. package/lib/state.d.ts.map +0 -1
  277. package/lib/state.js.map +0 -1
  278. package/lib/stripe/index.d.ts.map +0 -1
  279. package/lib/stripe/index.js.map +0 -1
  280. package/lib/stripe/price.d.ts.map +0 -1
  281. package/lib/stripe/price.js.map +0 -1
  282. package/lib/stripe/product.d.ts.map +0 -1
  283. package/lib/stripe/product.js.map +0 -1
  284. package/lib/stripe/webhook.d.ts.map +0 -1
  285. package/lib/stripe/webhook.js.map +0 -1
  286. package/lib/utils/content-type.d.ts.map +0 -1
  287. package/lib/utils/content-type.js.map +0 -1
  288. package/lib/utils/retry.d.ts.map +0 -1
  289. package/lib/utils/retry.js.map +0 -1
  290. package/src/$.ts +0 -69
  291. package/src/alchemize.ts +0 -186
  292. package/src/fs.ts +0 -47
  293. package/src/global.ts +0 -63
  294. package/src/input.ts +0 -16
  295. package/src/main.ts +0 -34
  296. package/src/output.ts +0 -71
  297. package/src/print.ts +0 -18
  298. package/src/slug.ts +0 -3
  299. /package/src/{utils → util}/content-type.ts +0 -0
  300. /package/src/{error.ts → util/ignore.ts} +0 -0
  301. /package/src/{utils → util}/retry.ts +0 -0
package/lib/aws/ses.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import { CreateConfigurationSetCommand, CreateEmailIdentityCommand, DeleteConfigurationSetCommand, DeleteEmailIdentityCommand, GetConfigurationSetCommand, GetEmailIdentityCommand, NotFoundException, PutConfigurationSetDeliveryOptionsCommand, PutConfigurationSetReputationOptionsCommand, PutConfigurationSetSendingOptionsCommand, PutConfigurationSetSuppressionOptionsCommand, PutConfigurationSetTrackingOptionsCommand, PutEmailIdentityDkimAttributesCommand, SESv2Client, } from "@aws-sdk/client-sesv2";
2
- import { ignore } from "../error";
3
2
  import { Resource } from "../resource";
3
+ import { ignore } from "../util/ignore";
4
4
  /**
5
5
  * AWS SES resource for creating and configuring Simple Email Service
6
6
  */
7
- export class SES extends Resource("aws::SES", async (ctx, props) => {
7
+ export const SES = Resource("aws::SES", async function (id, props) {
8
8
  // Create SES client
9
9
  const client = new SESv2Client({});
10
10
  // Resource ID is either based on the configuration set name or email identity
11
- const id = props.configurationSetName || props.emailIdentity || ctx.resourceID;
11
+ // const id =
12
+ // props.configurationSetName || props.emailIdentity || this.resourceID;
12
13
  // Handle deletion
13
- if (ctx.event === "delete") {
14
- const output = ctx.output;
14
+ if (this.phase === "delete") {
15
+ const output = this.output;
15
16
  // Delete configuration set if it exists
16
17
  if (output?.configurationSetName) {
17
18
  await ignore(NotFoundException.name, () => client.send(new DeleteConfigurationSetCommand({
@@ -25,7 +26,7 @@ export class SES extends Resource("aws::SES", async (ctx, props) => {
25
26
  })));
26
27
  }
27
28
  // Return empty output for delete
28
- return;
29
+ return this.destroy();
29
30
  }
30
31
  // Created resources
31
32
  let configurationSetArn;
@@ -34,156 +35,142 @@ export class SES extends Resource("aws::SES", async (ctx, props) => {
34
35
  let dkimVerificationStatus;
35
36
  // Create or update configuration set if specified
36
37
  if (props.configurationSetName) {
38
+ // Check if configuration set exists
39
+ let configSetExists = false;
37
40
  try {
38
- // Check if configuration set exists
39
- let configSetExists = false;
40
- try {
41
- await client.send(new GetConfigurationSetCommand({
41
+ await client.send(new GetConfigurationSetCommand({
42
+ ConfigurationSetName: props.configurationSetName,
43
+ }));
44
+ configSetExists = true;
45
+ }
46
+ catch (error) {
47
+ if (error instanceof NotFoundException) {
48
+ configSetExists = false;
49
+ }
50
+ else {
51
+ throw error;
52
+ }
53
+ }
54
+ if (configSetExists) {
55
+ // Update existing configuration set using appropriate update commands
56
+ if (props.sendingOptions) {
57
+ await client.send(new PutConfigurationSetSendingOptionsCommand({
42
58
  ConfigurationSetName: props.configurationSetName,
59
+ SendingEnabled: props.sendingOptions.SendingEnabled,
43
60
  }));
44
- configSetExists = true;
45
61
  }
46
- catch (error) {
47
- if (error instanceof NotFoundException) {
48
- configSetExists = false;
49
- }
50
- else {
51
- throw error;
52
- }
62
+ if (props.reputationOptions) {
63
+ await client.send(new PutConfigurationSetReputationOptionsCommand({
64
+ ConfigurationSetName: props.configurationSetName,
65
+ ReputationMetricsEnabled: props.reputationOptions.ReputationMetricsEnabled,
66
+ }));
53
67
  }
54
- if (configSetExists) {
55
- // Update existing configuration set using appropriate update commands
56
- if (props.sendingOptions) {
57
- await client.send(new PutConfigurationSetSendingOptionsCommand({
58
- ConfigurationSetName: props.configurationSetName,
59
- SendingEnabled: props.sendingOptions.SendingEnabled,
60
- }));
61
- }
62
- if (props.reputationOptions) {
63
- await client.send(new PutConfigurationSetReputationOptionsCommand({
64
- ConfigurationSetName: props.configurationSetName,
65
- ReputationMetricsEnabled: props.reputationOptions.ReputationMetricsEnabled,
66
- }));
67
- }
68
- if (props.trackingOptions) {
69
- await client.send(new PutConfigurationSetTrackingOptionsCommand({
70
- ConfigurationSetName: props.configurationSetName,
71
- CustomRedirectDomain: props.trackingOptions.CustomRedirectDomain,
72
- }));
73
- }
74
- if (props.suppressionOptions) {
75
- await client.send(new PutConfigurationSetSuppressionOptionsCommand({
76
- ConfigurationSetName: props.configurationSetName,
77
- SuppressedReasons: props.suppressionOptions.SuppressedReasons,
78
- }));
79
- }
80
- if (props.deliveryOptions) {
81
- await client.send(new PutConfigurationSetDeliveryOptionsCommand({
82
- ConfigurationSetName: props.configurationSetName,
83
- TlsPolicy: props.deliveryOptions.TlsPolicy,
84
- SendingPoolName: props.deliveryOptions.SendingPoolName,
85
- }));
86
- }
87
- // In SESv2, the ARN isn't directly returned in the response
88
- configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
68
+ if (props.trackingOptions) {
69
+ await client.send(new PutConfigurationSetTrackingOptionsCommand({
70
+ ConfigurationSetName: props.configurationSetName,
71
+ CustomRedirectDomain: props.trackingOptions.CustomRedirectDomain,
72
+ }));
89
73
  }
90
- else {
91
- // Create new configuration set
92
- await client.send(new CreateConfigurationSetCommand({
74
+ if (props.suppressionOptions) {
75
+ await client.send(new PutConfigurationSetSuppressionOptionsCommand({
76
+ ConfigurationSetName: props.configurationSetName,
77
+ SuppressedReasons: props.suppressionOptions.SuppressedReasons,
78
+ }));
79
+ }
80
+ if (props.deliveryOptions) {
81
+ await client.send(new PutConfigurationSetDeliveryOptionsCommand({
93
82
  ConfigurationSetName: props.configurationSetName,
94
- SendingOptions: props.sendingOptions,
95
- ReputationOptions: props.reputationOptions,
96
- TrackingOptions: props.trackingOptions,
97
- SuppressionOptions: props.suppressionOptions,
98
- DeliveryOptions: props.deliveryOptions,
99
- Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
100
- Key,
101
- Value,
102
- })),
83
+ TlsPolicy: props.deliveryOptions.TlsPolicy,
84
+ SendingPoolName: props.deliveryOptions.SendingPoolName,
103
85
  }));
104
- // In SESv2, the ARN isn't directly returned in the response
105
- configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
106
86
  }
87
+ // In SESv2, the ARN isn't directly returned in the response
88
+ configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
107
89
  }
108
- catch (error) {
109
- throw error;
90
+ else {
91
+ // Create new configuration set
92
+ await client.send(new CreateConfigurationSetCommand({
93
+ ConfigurationSetName: props.configurationSetName,
94
+ SendingOptions: props.sendingOptions,
95
+ ReputationOptions: props.reputationOptions,
96
+ TrackingOptions: props.trackingOptions,
97
+ SuppressionOptions: props.suppressionOptions,
98
+ DeliveryOptions: props.deliveryOptions,
99
+ Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
100
+ Key,
101
+ Value,
102
+ })),
103
+ }));
104
+ // In SESv2, the ARN isn't directly returned in the response
105
+ configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
110
106
  }
111
107
  }
112
108
  // Create or verify email identity if specified
113
109
  if (props.emailIdentity) {
110
+ // Check if identity exists
111
+ let getIdentityResult;
114
112
  try {
115
- // Check if identity exists
116
- let getIdentityResult;
117
- try {
118
- getIdentityResult = await client.send(new GetEmailIdentityCommand({
119
- EmailIdentity: props.emailIdentity,
120
- }));
121
- }
122
- catch (error) {
123
- if (error instanceof NotFoundException) {
124
- getIdentityResult = null;
125
- }
126
- else {
127
- throw error;
128
- }
129
- }
130
- if (!getIdentityResult) {
131
- // Create new email identity
132
- const createIdentityResult = await client.send(new CreateEmailIdentityCommand({
133
- EmailIdentity: props.emailIdentity,
134
- Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
135
- Key,
136
- Value,
137
- })),
138
- }));
139
- // If it's an email address, we don't need to explicitly verify in v2
140
- // The verification email is automatically sent by SES in v2
141
- // Store the identity information
142
- emailIdentityArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:identity/${props.emailIdentity}`;
143
- emailIdentityVerificationStatus =
144
- createIdentityResult.VerifiedForSendingStatus
145
- ? "VERIFIED"
146
- : "PENDING";
113
+ getIdentityResult = await client.send(new GetEmailIdentityCommand({
114
+ EmailIdentity: props.emailIdentity,
115
+ }));
116
+ }
117
+ catch (error) {
118
+ if (error instanceof NotFoundException) {
119
+ getIdentityResult = null;
147
120
  }
148
121
  else {
149
- // Store the identity information
150
- emailIdentityArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:identity/${props.emailIdentity}`;
151
- emailIdentityVerificationStatus =
152
- getIdentityResult.VerifiedForSendingStatus ? "VERIFIED" : "PENDING";
153
- // Update DKIM settings if requested
154
- if (props.enableDkim !== undefined) {
155
- if (props.enableDkim) {
156
- await client.send(new PutEmailIdentityDkimAttributesCommand({
157
- EmailIdentity: props.emailIdentity,
158
- SigningEnabled: true,
159
- }));
160
- // We can check the current status of DKIM
161
- dkimVerificationStatus = "PENDING"; // Default to pending
162
- // Get the updated identity to check DKIM status
163
- const updatedIdentity = await client.send(new GetEmailIdentityCommand({
164
- EmailIdentity: props.emailIdentity,
165
- }));
166
- if (updatedIdentity.DkimAttributes?.Status) {
167
- dkimVerificationStatus = updatedIdentity.DkimAttributes.Status;
168
- }
122
+ throw error;
123
+ }
124
+ }
125
+ if (!getIdentityResult) {
126
+ // Create new email identity
127
+ const createIdentityResult = await client.send(new CreateEmailIdentityCommand({
128
+ EmailIdentity: props.emailIdentity,
129
+ Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
130
+ Key,
131
+ Value,
132
+ })),
133
+ }));
134
+ // If it's an email address, we don't need to explicitly verify in v2
135
+ // The verification email is automatically sent by SES in v2
136
+ // Store the identity information
137
+ emailIdentityArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:identity/${props.emailIdentity}`;
138
+ emailIdentityVerificationStatus =
139
+ createIdentityResult.VerifiedForSendingStatus
140
+ ? "VERIFIED"
141
+ : "PENDING";
142
+ }
143
+ else {
144
+ // Store the identity information
145
+ emailIdentityArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:identity/${props.emailIdentity}`;
146
+ emailIdentityVerificationStatus =
147
+ getIdentityResult.VerifiedForSendingStatus ? "VERIFIED" : "PENDING";
148
+ // Update DKIM settings if requested
149
+ if (props.enableDkim !== undefined) {
150
+ if (props.enableDkim) {
151
+ await client.send(new PutEmailIdentityDkimAttributesCommand({
152
+ EmailIdentity: props.emailIdentity,
153
+ SigningEnabled: true,
154
+ }));
155
+ // We can check the current status of DKIM
156
+ dkimVerificationStatus = "PENDING"; // Default to pending
157
+ // Get the updated identity to check DKIM status
158
+ const updatedIdentity = await client.send(new GetEmailIdentityCommand({
159
+ EmailIdentity: props.emailIdentity,
160
+ }));
161
+ if (updatedIdentity.DkimAttributes?.Status) {
162
+ dkimVerificationStatus = updatedIdentity.DkimAttributes.Status;
169
163
  }
170
164
  }
171
165
  }
172
166
  }
173
- catch (error) {
174
- console.error(`Error configuring email identity ${props.emailIdentity}:`, error);
175
- throw error;
176
- }
177
167
  }
178
168
  // Return the resource output
179
- return {
169
+ return this({
180
170
  ...props,
181
- id,
182
171
  configurationSetArn,
183
172
  emailIdentityArn,
184
173
  emailIdentityVerificationStatus,
185
174
  dkimVerificationStatus,
186
- };
187
- }) {
188
- }
189
- //# sourceMappingURL=ses.js.map
175
+ });
176
+ });
@@ -1,3 +1,5 @@
1
+ import type { Context } from "../context";
2
+ import { Resource } from "../resource";
1
3
  export interface TableProps {
2
4
  tableName: string;
3
5
  partitionKey: {
@@ -13,14 +15,9 @@ export interface TableProps {
13
15
  writeCapacity?: number;
14
16
  tags?: Record<string, string>;
15
17
  }
16
- export interface TableOutput extends TableProps {
17
- id: string;
18
+ export interface Table extends Resource<"dynamo::Table">, TableProps {
18
19
  arn: string;
19
20
  streamArn?: string;
20
21
  tableId: string;
21
22
  }
22
- declare const Table_base: import("../resource").Provider<"dynamo::Table", [props: TableProps], TableOutput>;
23
- export declare class Table extends Table_base {
24
- }
25
- export {};
26
- //# sourceMappingURL=table.d.ts.map
23
+ export declare const Table: ((this: Context<Table>, id: string, props: TableProps) => Promise<Table>) | (((this: any, id: string, props: TableProps) => never) & (new (_: never) => never));
package/lib/aws/table.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { CreateTableCommand, DeleteTableCommand, DescribeTableCommand, DynamoDBClient, InternalServerError, ResourceInUseException, ResourceNotFoundException, } from "@aws-sdk/client-dynamodb";
2
- import { ignore } from "../error";
3
2
  import { Resource } from "../resource";
4
- import { withExponentialBackoff } from "../utils/retry";
5
- export class Table extends Resource("dynamo::Table", async (ctx, props) => {
3
+ import { ignore } from "../util/ignore";
4
+ import { withExponentialBackoff } from "../util/retry";
5
+ export const Table = Resource("dynamo::Table", async function (id, props) {
6
6
  const client = new DynamoDBClient({});
7
- if (ctx.event === "delete") {
7
+ if (this.phase === "delete") {
8
8
  await withExponentialBackoff(async () => {
9
9
  await ignore(ResourceNotFoundException.name, () => client.send(new DeleteTableCommand({
10
10
  TableName: props.tableName,
@@ -39,7 +39,7 @@ export class Table extends Resource("dynamo::Table", async (ctx, props) => {
39
39
  if (!tableDeleted) {
40
40
  throw new Error(`Timed out waiting for table ${props.tableName} to be deleted`);
41
41
  }
42
- return;
42
+ return this.destroy();
43
43
  }
44
44
  else {
45
45
  // Setup for table creation
@@ -141,14 +141,11 @@ export class Table extends Resource("dynamo::Table", async (ctx, props) => {
141
141
  if (!tableActive) {
142
142
  throw new Error(`Timed out waiting for table ${props.tableName} to become active`);
143
143
  }
144
- return {
144
+ return this({
145
145
  ...props,
146
- id: props.tableName,
147
146
  arn: tableDescription.TableArn,
148
147
  streamArn: tableDescription.LatestStreamArn,
149
148
  tableId: tableDescription.TableId,
150
- };
149
+ });
151
150
  }
152
- }) {
153
- }
154
- //# sourceMappingURL=table.js.map
151
+ });
@@ -85,4 +85,3 @@ export declare class CloudflareApi {
85
85
  */
86
86
  delete(path: string, init?: RequestInit): Promise<Response>;
87
87
  }
88
- //# sourceMappingURL=api.d.ts.map
@@ -181,4 +181,3 @@ async function fetchAccountId() {
181
181
  // Return the first account ID
182
182
  return accounts[0].id;
183
183
  }
184
- //# sourceMappingURL=api.js.map
@@ -12,4 +12,3 @@ export interface FileOption {
12
12
  contentType?: string;
13
13
  ignore?: string[];
14
14
  }
15
- //# sourceMappingURL=asset-manifest.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=asset-manifest.js.map
@@ -49,4 +49,3 @@ export declare function getCloudflareAuth(options?: CloudflareAuthOptions): Prom
49
49
  * @returns Complete headers for the request
50
50
  */
51
51
  export declare function getCloudflareHeaders(contentType?: string, options?: CloudflareAuthOptions): Promise<Record<string, string>>;
52
- //# sourceMappingURL=auth.d.ts.map
@@ -111,4 +111,3 @@ export async function getCloudflareHeaders(contentType = "application/json", opt
111
111
  ...auth.headers,
112
112
  };
113
113
  }
114
- //# sourceMappingURL=auth.js.map
@@ -3,7 +3,8 @@
3
3
  * Based on Cloudflare API documentation:
4
4
  * https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/
5
5
  */
6
- import type { Bucket } from "./bucket";
6
+ import type { Secret } from "../secret";
7
+ import type { R2Bucket } from "./bucket";
7
8
  import type { DurableObjectNamespace } from "./durable-object-namespace";
8
9
  import type { KVNamespace } from "./kv-namespace";
9
10
  import type { Worker } from "./worker";
@@ -13,7 +14,8 @@ export type Bindings = {
13
14
  /**
14
15
  * L2 Binding Resources.
15
16
  */
16
- export type Binding = DurableObjectNamespace | KVNamespace | Worker | Bucket | string;
17
+ export type Binding = DurableObjectNamespace | KVNamespace | Worker | R2Bucket | Secret | string;
18
+ export declare function isDurableObjectNamespace(binding: Binding): binding is DurableObjectNamespace;
17
19
  /**
18
20
  * Union type for all Worker binding types (API spec)
19
21
  */
@@ -257,4 +259,3 @@ export interface WorkerBindingStaticContent {
257
259
  /** Type identifier for Static Content binding */
258
260
  type: "static_content";
259
261
  }
260
- //# sourceMappingURL=bindings.d.ts.map
@@ -1,2 +1,3 @@
1
- export {};
2
- //# sourceMappingURL=bindings.js.map
1
+ export function isDurableObjectNamespace(binding) {
2
+ return (typeof binding === "object" && binding.type === "durable_object_namespace");
3
+ }
@@ -0,0 +1,7 @@
1
+ import type { Secret } from "../secret";
2
+ import type { Binding } from "./bindings";
3
+ import type { R2Bucket as _R2Bucket } from "./bucket";
4
+ import type { DurableObjectNamespace as _DurableObjectNamespace } from "./durable-object-namespace";
5
+ import type { KVNamespace as _KVNamespace } from "./kv-namespace";
6
+ import type { Worker as _Worker } from "./worker";
7
+ export type Bound<T extends Binding> = T extends _DurableObjectNamespace ? DurableObjectNamespace : T extends _KVNamespace ? KVNamespace : T extends _Worker ? Worker : T extends _R2Bucket ? R2Bucket : T extends Secret ? string : never;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
- import type { Resolved } from "../output";
1
+ import type { Context } from "../context";
2
+ import { Resource } from "../resource";
2
3
  /**
3
4
  * Properties for creating or updating an R2 Bucket
4
5
  */
@@ -8,7 +9,7 @@ export interface BucketProps {
8
9
  * Names can only contain lowercase letters (a-z), numbers (0-9), and hyphens (-)
9
10
  * Cannot begin or end with a hyphen
10
11
  */
11
- name?: string;
12
+ name: string;
12
13
  /**
13
14
  * Optional location hint for the bucket
14
15
  * Indicates the primary geographical location data will be accessed from
@@ -28,11 +29,11 @@ export interface BucketProps {
28
29
  /**
29
30
  * Output returned after R2 Bucket creation/update
30
31
  */
31
- export interface BucketOutput extends BucketProps {
32
+ export interface R2Bucket extends Resource<"cloudflare::R2Bucket">, BucketProps {
32
33
  /**
33
- * The ID of the bucket (same as name)
34
+ * Resource type identifier
34
35
  */
35
- id: string;
36
+ type: "r2_bucket";
36
37
  /**
37
38
  * Location of the bucket
38
39
  */
@@ -41,14 +42,5 @@ export interface BucketOutput extends BucketProps {
41
42
  * Time at which the bucket was created (Unix timestamp in seconds)
42
43
  */
43
44
  creationDate: number;
44
- /**
45
- * Resource type identifier
46
- */
47
- type: "r2_bucket";
48
- }
49
- export declare function isBucket(resource: any): resource is Resolved<Bucket>;
50
- declare const Bucket_base: import("../resource").Provider<"cloudflare::Bucket", [props: BucketProps], BucketOutput>;
51
- export declare class Bucket extends Bucket_base {
52
45
  }
53
- export {};
54
- //# sourceMappingURL=bucket.d.ts.map
46
+ export declare const R2Bucket: ((this: Context<R2Bucket>, id: string, props: BucketProps) => Promise<R2Bucket>) | (((this: any, id: string, props: BucketProps) => never) & (new (_: never) => never));
@@ -1,21 +1,18 @@
1
1
  import { Resource } from "../resource";
2
2
  import { createCloudflareApi } from "./api";
3
- export function isBucket(resource) {
4
- return (resource && typeof resource === "object" && resource.id && resource.location);
5
- }
6
- export class Bucket extends Resource("cloudflare::Bucket", async (ctx, props) => {
3
+ export const R2Bucket = Resource("cloudflare::R2Bucket", async function (id, props) {
7
4
  // Create Cloudflare API client with automatic account discovery
8
5
  const api = await createCloudflareApi();
9
6
  // Resource ID defaults to bucket name if provided
10
- const bucketName = props.name || ctx.resourceID;
11
- if (ctx.event === "delete") {
12
- if (ctx.output?.id) {
7
+ const bucketName = props.name || this.id;
8
+ if (this.phase === "delete") {
9
+ if (this.output?.name) {
13
10
  // Delete R2 bucket
14
11
  const headers = {};
15
12
  if (props.jurisdiction && props.jurisdiction !== "default") {
16
13
  headers["cf-r2-jurisdiction"] = props.jurisdiction;
17
14
  }
18
- const deleteResponse = await api.delete(`/accounts/${api.accountId}/r2/buckets/${ctx.output.id}`, { headers });
15
+ const deleteResponse = await api.delete(`/accounts/${api.accountId}/r2/buckets/${this.output.name}`, { headers });
19
16
  if (!deleteResponse.ok && deleteResponse.status !== 404) {
20
17
  const errorData = await deleteResponse.json().catch(() => ({
21
18
  errors: [{ message: deleteResponse.statusText }],
@@ -24,12 +21,12 @@ export class Bucket extends Resource("cloudflare::Bucket", async (ctx, props) =>
24
21
  }
25
22
  }
26
23
  // Return void (a deleted bucket has no content)
27
- return;
24
+ return this.destroy();
28
25
  }
29
26
  else {
30
27
  try {
31
28
  let bucketOutput;
32
- if (ctx.event === "update" && ctx.output?.id) {
29
+ if (this.phase === "update" && this.output?.name) {
33
30
  // Get bucket details to verify it exists
34
31
  const headers = {};
35
32
  if (props.jurisdiction && props.jurisdiction !== "default") {
@@ -43,14 +40,13 @@ export class Bucket extends Resource("cloudflare::Bucket", async (ctx, props) =>
43
40
  throw new Error(`Error getting R2 bucket '${bucketName}': ${errorData.errors?.[0]?.message || getResponse.statusText}`);
44
41
  }
45
42
  const result = (await getResponse.json());
46
- bucketOutput = {
47
- id: result.result.name,
43
+ bucketOutput = this({
48
44
  name: result.result.name,
49
45
  location: result.result.location || "default",
50
46
  creationDate: Math.floor(new Date(result.result.creation_date).getTime() / 1000),
51
47
  jurisdiction: props.jurisdiction || "default",
52
48
  type: "r2_bucket",
53
- };
49
+ });
54
50
  // Update public access setting if it has changed
55
51
  if (props.allowPublicAccess !== undefined) {
56
52
  await updatePublicAccess(api, bucketName, props.allowPublicAccess);
@@ -76,14 +72,13 @@ export class Bucket extends Resource("cloudflare::Bucket", async (ctx, props) =>
76
72
  throw new Error(`Error creating R2 bucket '${bucketName}': ${errorData.errors?.[0]?.message || createResponse.statusText}`);
77
73
  }
78
74
  const result = (await createResponse.json());
79
- bucketOutput = {
80
- id: result.result.name,
75
+ bucketOutput = this({
81
76
  name: result.result.name,
82
77
  location: result.result.location || "default",
83
78
  creationDate: Math.floor(new Date(result.result.creation_date).getTime() / 1000),
84
79
  jurisdiction: props.jurisdiction || "default",
85
80
  type: "r2_bucket",
86
- };
81
+ });
87
82
  // Set public access if requested
88
83
  if (props.allowPublicAccess) {
89
84
  await updatePublicAccess(api, bucketName, true);
@@ -96,8 +91,7 @@ export class Bucket extends Resource("cloudflare::Bucket", async (ctx, props) =>
96
91
  throw error;
97
92
  }
98
93
  }
99
- }) {
100
- }
94
+ });
101
95
  /**
102
96
  * Helper function to update the public access setting for a bucket
103
97
  */
@@ -117,4 +111,3 @@ async function updatePublicAccess(api, bucketName, allowPublicAccess) {
117
111
  console.warn("Could not set public access:", error);
118
112
  }
119
113
  }
120
- //# sourceMappingURL=bucket.js.map
@@ -1,4 +1,3 @@
1
- import type { Resolved } from "../output";
2
1
  export interface DurableObjectNamespaceInput {
3
2
  className: string;
4
3
  scriptName?: string | undefined;
@@ -6,7 +5,6 @@ export interface DurableObjectNamespaceInput {
6
5
  sqlite?: boolean | undefined;
7
6
  namespaceId?: string | undefined;
8
7
  }
9
- export declare function isDurableObjectNamespace(binding: any): binding is Resolved<DurableObjectNamespace>;
10
8
  export declare class DurableObjectNamespace implements DurableObjectNamespaceInput {
11
9
  readonly id: string;
12
10
  readonly type: "durable_object_namespace";
@@ -17,4 +15,3 @@ export declare class DurableObjectNamespace implements DurableObjectNamespaceInp
17
15
  readonly namespaceId?: string | undefined;
18
16
  constructor(id: string, input: DurableObjectNamespaceInput);
19
17
  }
20
- //# sourceMappingURL=durable-object-namespace.d.ts.map
@@ -1,6 +1,3 @@
1
- export function isDurableObjectNamespace(binding) {
2
- return (typeof binding === "object" && binding.type === "durable_object_namespace");
3
- }
4
1
  export class DurableObjectNamespace {
5
2
  id;
6
3
  type = "durable_object_namespace";
@@ -18,4 +15,3 @@ export class DurableObjectNamespace {
18
15
  this.sqlite = input.sqlite;
19
16
  }
20
17
  }
21
- //# sourceMappingURL=durable-object-namespace.js.map
@@ -1,3 +1,2 @@
1
1
  import type { AssetManifest, FileOption } from "./asset-manifest";
2
2
  export declare function generateAssetManifest(dir: string, fileOptions?: FileOption[]): Promise<AssetManifest>;
3
- //# sourceMappingURL=generate-asset-manifest.d.ts.map
@@ -2,7 +2,7 @@ import crypto from "crypto";
2
2
  import { promises as fs } from "fs";
3
3
  import { glob } from "glob";
4
4
  import path from "path";
5
- import { getContentType } from "../utils/content-type";
5
+ import { getContentType } from "../util/content-type";
6
6
  export async function generateAssetManifest(dir, fileOptions = [
7
7
  {
8
8
  files: "**",
@@ -66,4 +66,3 @@ export async function generateAssetManifest(dir, fileOptions = [
66
66
  }));
67
67
  return manifestEntries;
68
68
  }
69
- //# sourceMappingURL=generate-asset-manifest.js.map
@@ -5,4 +5,3 @@ export * from "./kv-namespace";
5
5
  export * from "./state";
6
6
  export * from "./static-site";
7
7
  export * from "./worker";
8
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@ export * from "./kv-namespace";
5
5
  export * from "./state";
6
6
  export * from "./static-site";
7
7
  export * from "./worker";
8
- //# sourceMappingURL=index.js.map